Skip to content

Commit 84f21ec

Browse files
committed
chore: trim unrelated discovery kit changes
Revert files that leaked into the squashed discovery diff so the PR stays focused on the Discord and automation work reviewers actually need to read.
1 parent 598e8e5 commit 84f21ec

10 files changed

Lines changed: 116 additions & 231 deletions

File tree

flexus_client_kit/erp_schema.py

Lines changed: 0 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -310,130 +310,12 @@ class ComRefund:
310310
order: Optional[ComOrder] = field(default=None, metadata={"fk_field": "refund_order_id", "description": "included via include=['order']"})
311311

312312

313-
@dataclass
314-
class CrmPerson:
315-
ws_id: str
316-
person_id: str = field(default="", metadata={"pkey": True, "display_name": "Person ID"})
317-
person_label: str = field(default="", metadata={"importance": 1, "display_name": "Label"})
318-
person_details: dict = field(default_factory=dict, metadata={"display_name": "Details", "description": "Custom JSON attributes for this person"})
319-
person_created_ts: float = field(default=0.0, metadata={"importance": 1, "display_name": "Created at"})
320-
person_modified_ts: float = field(default=0.0, metadata={"display_name": "Modified at"})
321-
person_archived_ts: float = field(default=0.0, metadata={"display_name": "Archived at"})
322-
323-
identities: Optional[List["CrmPersonIdentity"]] = field(default=None, metadata={"inbound_fk_table": "crm_person_identity", "inbound_fk_col": "person_id"})
324-
applications: Optional[List["CrmApplication"]] = field(default=None, metadata={"inbound_fk_table": "crm_application", "inbound_fk_col": "person_id"})
325-
326-
327-
@dataclass
328-
class CrmPersonIdentity:
329-
ws_id: str
330-
person_id: str = field(metadata={"importance": 1, "display_name": "Person"})
331-
identity_platform: str = field(metadata={"importance": 1, "display_name": "Platform", "description": "e.g. discord, slack, telegram, email, github"})
332-
identity_external_user_id: str = field(metadata={"importance": 1, "display_name": "External User ID"})
333-
identity_id: str = field(default="", metadata={"pkey": True, "display_name": "Identity ID"})
334-
identity_external_endpoint: str = field(default="", metadata={"importance": 1, "display_name": "Endpoint", "description": "Channel ID, DM endpoint, webhook URL, etc."})
335-
identity_status: str = field(default="linked", metadata={"importance": 1, "display_name": "Status", "enum": [
336-
{"value": "linked", "label": "Linked"},
337-
{"value": "verified", "label": "Verified"},
338-
{"value": "revoked", "label": "Revoked"},
339-
]})
340-
identity_details: dict = field(default_factory=dict, metadata={"display_name": "Details"})
341-
identity_created_ts: float = field(default=0.0, metadata={"display_name": "Created at"})
342-
identity_modified_ts: float = field(default=0.0, metadata={"display_name": "Modified at"})
343-
identity_archived_ts: float = field(default=0.0, metadata={"display_name": "Archived at"})
344-
345-
person: Optional[CrmPerson] = field(default=None, metadata={"fk_field": "person_id", "description": "included via include=['person']"})
346-
347-
348-
@dataclass
349-
class CrmApplication:
350-
ws_id: str
351-
application_id: str = field(default="", metadata={"pkey": True, "display_name": "Application ID"})
352-
person_id: Optional[str] = field(default=None, metadata={"importance": 1, "display_name": "Person"})
353-
contact_id: Optional[str] = field(default=None, metadata={"importance": 1, "display_name": "Contact"})
354-
application_source: str = field(default="", metadata={"importance": 1, "display_name": "Source", "description": "Originating channel/system, e.g. discord_onboarding"})
355-
application_platform: str = field(default="", metadata={"importance": 1, "display_name": "Platform", "enum": [
356-
{"value": "discord", "label": "Discord"},
357-
{"value": "slack", "label": "Slack"},
358-
{"value": "web", "label": "Web"},
359-
{"value": "email", "label": "Email"},
360-
{"value": "telegram", "label": "Telegram"},
361-
]})
362-
application_status: str = field(default="PENDING", metadata={"importance": 1, "display_name": "Status", "enum": [
363-
{"value": "PENDING", "label": "Pending"},
364-
{"value": "REVIEWING", "label": "Reviewing"},
365-
{"value": "DECIDED", "label": "Decided"},
366-
{"value": "CLOSED", "label": "Closed"},
367-
]})
368-
application_decision: str = field(default="", metadata={"importance": 1, "display_name": "Decision", "enum": [
369-
{"value": "", "label": "—"},
370-
{"value": "APPROVED", "label": "Approved"},
371-
{"value": "REJECTED", "label": "Rejected"},
372-
{"value": "WAITLISTED", "label": "Waitlisted"},
373-
]})
374-
application_payload: dict = field(default_factory=dict, metadata={"display_name": "Payload", "description": "Raw inbound data from the originating event"})
375-
application_details: dict = field(default_factory=dict, metadata={"display_name": "Details", "description": "Enriched/processed data and bot annotations"})
376-
application_created_ts: float = field(default=0.0, metadata={"importance": 1, "display_name": "Created at"})
377-
application_modified_ts: float = field(default=0.0, metadata={"display_name": "Modified at"})
378-
application_archived_ts: float = field(default=0.0, metadata={"display_name": "Archived at"})
379-
application_decision_ts: float = field(default=0.0, metadata={"importance": 1, "display_name": "Decided at"})
380-
381-
person: Optional[CrmPerson] = field(default=None, metadata={"fk_field": "person_id", "description": "included via include=['person']"})
382-
383-
384-
@dataclass
385-
class CrmThreadParticipationPolicy:
386-
ws_id: str
387-
ft_id: str = field(metadata={"importance": 1, "display_name": "Thread ID"})
388-
policy_id: str = field(default="", metadata={"pkey": True, "display_name": "Policy ID"})
389-
persona_id: Optional[str] = field(default=None, metadata={"importance": 1, "display_name": "Persona"})
390-
person_id: Optional[str] = field(default=None, metadata={"importance": 1, "display_name": "Person"})
391-
policy_mode: str = field(default="ACTIVE", metadata={"importance": 1, "display_name": "Mode", "enum": [
392-
{"value": "ACTIVE", "label": "Active"},
393-
{"value": "PAUSED", "label": "Paused"},
394-
{"value": "TAKEOVER", "label": "Takeover"},
395-
{"value": "CLOSED", "label": "Closed"},
396-
]})
397-
policy_active: bool = field(default=True, metadata={"importance": 1, "display_name": "Active"})
398-
policy_timeout_ts: float = field(default=0.0, metadata={"display_name": "Timeout at", "description": "Epoch timestamp when mode should auto-expire; 0 = no timeout"})
399-
policy_last_actor: str = field(default="", metadata={"display_name": "Last Actor", "description": "fuser_id, persona_id, or 'system'"})
400-
policy_details: dict = field(default_factory=dict, metadata={"display_name": "Details"})
401-
policy_created_ts: float = field(default=0.0, metadata={"display_name": "Created at"})
402-
policy_modified_ts: float = field(default=0.0, metadata={"display_name": "Modified at"})
403-
404-
405-
@dataclass
406-
class CrmExternalConnection:
407-
ws_id: str
408-
connection_provider: str = field(metadata={"importance": 1, "display_name": "Provider", "description": "e.g. discord, slack, github, google"})
409-
connection_id: str = field(default="", metadata={"pkey": True, "display_name": "Connection ID"})
410-
persona_id: Optional[str] = field(default=None, metadata={"importance": 1, "display_name": "Persona"})
411-
auth_id: Optional[str] = field(default=None, metadata={"display_name": "Auth ID"})
412-
connection_platform: str = field(default="", metadata={"importance": 1, "display_name": "Platform", "description": "Sub-platform or environment hint"})
413-
connection_resource_type: str = field(default="", metadata={"importance": 1, "display_name": "Resource Type", "description": "e.g. guild, channel, workspace, dm, repo"})
414-
connection_external_id: str = field(default="", metadata={"importance": 1, "display_name": "External ID"})
415-
connection_status: str = field(default="active", metadata={"importance": 1, "display_name": "Status", "enum": [
416-
{"value": "active", "label": "Active"},
417-
{"value": "revoked", "label": "Revoked"},
418-
{"value": "error", "label": "Error"},
419-
]})
420-
connection_details: dict = field(default_factory=dict, metadata={"display_name": "Details"})
421-
connection_created_ts: float = field(default=0.0, metadata={"display_name": "Created at"})
422-
connection_modified_ts: float = field(default=0.0, metadata={"display_name": "Modified at"})
423-
connection_archived_ts: float = field(default=0.0, metadata={"display_name": "Archived at"})
424-
425-
426313
ERP_TABLE_TO_SCHEMA: Dict[str, Type] = {
427314
"crm_activity": CrmActivity,
428-
"crm_application": CrmApplication,
429315
"crm_contact": CrmContact,
430316
"crm_deal": CrmDeal,
431-
"crm_external_connection": CrmExternalConnection,
432-
"crm_person": CrmPerson,
433-
"crm_person_identity": CrmPersonIdentity,
434317
"crm_pipeline": CrmPipeline,
435318
"crm_pipeline_stage": CrmPipelineStage,
436-
"crm_thread_participation_policy": CrmThreadParticipationPolicy,
437319
"com_order": ComOrder,
438320
"com_order_item": ComOrderItem,
439321
"com_payment": ComPayment,
@@ -460,15 +342,10 @@ class CrmExternalConnection:
460342

461343
ERP_DISPLAY_NAME_CONFIGS: Dict[str, str] = {
462344
"crm_activity": "{activity_title}",
463-
"crm_application": "{application_platform} {application_status}",
464345
"crm_contact": "{contact_first_name} {contact_last_name}",
465346
"crm_deal": "{deal_name}",
466-
"crm_external_connection": "{connection_provider} {connection_resource_type}",
467-
"crm_person": "{person_label}",
468-
"crm_person_identity": "{identity_platform} {identity_external_user_id}",
469347
"crm_pipeline": "{pipeline_name}",
470348
"crm_pipeline_stage": "{stage_name}",
471-
"crm_thread_participation_policy": "{ft_id} {policy_mode}",
472349
"com_order": "{order_number}",
473350
"com_order_item": "{oitem_name}",
474351
"com_payment": "{pay_id}",

flexus_client_kit/format_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class TextOutputResult:
2525
lines: List[str]
2626
line1: int # 1-based first line shown
2727
line2: int # 1-based last line shown (inclusive)
28+
total_lines: int
2829
safety_valve_hit: bool
2930
header: str
3031
warnings: List[str] = field(default_factory=list)
@@ -182,6 +183,7 @@ def format_text_output(
182183
lines=result,
183184
line1=line_offset + start + 1,
184185
line2=line_offset + actual_end + 1,
186+
total_lines=len(lines),
185187
safety_valve_hit=hit,
186188
header=header,
187189
warnings=warnings,

flexus_client_kit/integrations/fi_pdoc.py

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
parameters={
3737
"type": "object",
3838
"properties": {
39-
"op": {"type": "string", "enum": ["help", "list", "cat", "activate", "create", "create_draft_qa", "create_draft_from_template", "overwrite", "update_json_text", "translate_qa", "cp", "mv", "rm"]},
39+
"op": {"type": "string", "enum": ["help", "list", "cat", "activate", "create", "create_draft_qa", "create_draft_from_template", "overwrite", "update_at_location", "translate_qa", "cp", "mv", "rm"]},
4040
"args": {"type": "object"}, # model guesses p= to write here quite well for some reason, without help, must be something in prompt
4141
},
4242
},
@@ -71,15 +71,15 @@
7171
Create a new policy document from a known template. Automatically prepends current date between
7272
output_dir and slug, e.g. /plans/20260325-my-thing. Fails if the document already exists.
7373
74-
flexus_policy_document(op="update_json_text", args={"p": "/folder/file", "json_path": "section1.field", "text": "new value", "expected_md5": "abc123"})
75-
Update a specific field in a document using json_path with dot notation.
76-
Example: "operations_overview.governance" updates doc["operations_overview"]["governance"]
77-
Pass expected_md5 (from a previous cat/update) to avoid overwriting concurrent changes.
78-
If md5 doesn't match, changes are not saved and latest content is returned so you can retry.
74+
flexus_policy_document(op="update_at_location", args={"p": "/folder/file", "expected_md5": "abc123", "updates": [["toptag.section1.field1", "value1"], ["toptag.section1.field2", "value2"]]})
75+
Update fields in a document using dot notation for path. This normally updates strings, but you can try to set
76+
any structure or number, if schema in available in the document.
77+
NEVER call this tool in parallel, backend will serialize calls and only the first will pass md5 gate.
78+
Instead use "updates" array to set multiple fields at once.
7979
8080
flexus_policy_document(op="translate_qa", args={"p": "/folder/file", "expected_md5": "abc123", "translation": [["top-tag.section01-product.question01-description.q", "Translated text"], ...]})
8181
Batch-update question texts in a QA document, typically for translation.
82-
Each entry in translation is [json_path, text] where json_path uses dot notation (same as update_json_text).
82+
Each entry in translation is [json_path, text] where json_path uses dot notation (same as update_at_location).
8383
Pass expected_md5 to avoid overwriting concurrent changes.
8484
Returns list of still-empty "q" and "a" fields and the new md5.
8585
@@ -425,19 +425,27 @@ async def called_by_model(self, toolcall: ckit_cloudtool.FCloudtoolCall, model_p
425425
raise
426426
r += f"✍️ {p}\nmd5={_pdoc_md5(doc)}\n\n✓ Created from template '{template}'"
427427

428-
elif op == "update_json_text":
428+
elif op == "update_at_location":
429429
p = ckit_cloudtool.try_best_to_find_argument(args, model_produced_args, "p", "")
430430
p = p or ckit_cloudtool.try_best_to_find_argument(args, model_produced_args, "path", "")
431-
json_path = ckit_cloudtool.try_best_to_find_argument(args, model_produced_args, "json_path", "")
432-
text = ckit_cloudtool.try_best_to_find_argument(args, model_produced_args, "text", "")
433431
expected_md5 = ckit_cloudtool.try_best_to_find_argument(args, model_produced_args, "expected_md5", "")
434-
if not p or not json_path or not text:
435-
return f"Error: p, json_path, and text parameters required\n\n{HELP}"
432+
# batch: updates=[[json_path, text], ...] or single: json_path= text=
433+
updates_raw = ckit_cloudtool.try_best_to_find_argument(args, model_produced_args, "updates", None)
434+
if updates_raw and isinstance(updates_raw, list):
435+
updates = [{"json_path": u[0], "text": u[1]} for u in updates_raw]
436+
else:
437+
json_path = ckit_cloudtool.try_best_to_find_argument(args, model_produced_args, "json_path", "")
438+
text = ckit_cloudtool.try_best_to_find_argument(args, model_produced_args, "text", "")
439+
if not json_path or not text:
440+
return f"Error: provide json_path+text or updates list\n\n{HELP}"
441+
updates = [{"json_path": json_path, "text": text}]
442+
if not p:
443+
return f"Error: p parameter required\n\n{HELP}"
436444

437445
if self.is_fake:
438446
return await ckit_scenario.scenario_generate_tool_result_via_model(self.fclient, toolcall, open(__file__).read())
439447

440-
upd = await self.pdoc_update_json_text(p, json_path, text, persona_id=self.rcx.persona.persona_id, fcall_untrusted_key=toolcall.fcall_untrusted_key, expected_md5=expected_md5)
448+
upd = await self.pdoc_update_at_location(p, updates, persona_id=self.rcx.persona.persona_id, fcall_untrusted_key=toolcall.fcall_untrusted_key, expected_md5=expected_md5)
441449
if upd.changes_saved:
442450
r += f"✍️ {p}\n"
443451
r += f"changes_saved=true\n\n"
@@ -613,20 +621,20 @@ async def pdoc_overwrite(self, p: str, text: str, persona_id: str, fcall_untrust
613621
)
614622
return gql_utils.dataclass_from_dict(r["policydoc_overwrite"], PdocOverwriteResult)
615623

616-
async def pdoc_update_json_text(self, p: str, json_path: str, text: str, persona_id: str, fcall_untrusted_key: str, expected_md5: str = "") -> PdocUpdateJsonTextResult:
624+
async def pdoc_update_at_location(self, p: str, updates: list, persona_id: str, fcall_untrusted_key: str, expected_md5: str = "") -> PdocUpdateJsonTextResult:
617625
http = await self._http(persona_id, fcall_untrusted_key)
618626
async with http as h:
619627
result = await h.execute(
620628
gql.gql(f"""
621-
mutation PdocUpdateJsonText($fgroup_id: String!, $p: String!, $json_path: String!, $text: String!, $expected_md5: String) {{
622-
policydoc_update_json_text(fgroup_id: $fgroup_id, p: $p, json_path: $json_path, text: $text, expected_md5: $expected_md5) {{
629+
mutation PdocUpdateAtPath($fgroup_id: String!, $p: String!, $updates: [PolicyDocJsonUpdate!]!, $expected_md5: String) {{
630+
policydoc_update_at_location(fgroup_id: $fgroup_id, p: $p, updates: $updates, expected_md5: $expected_md5) {{
623631
{gql_utils.gql_fields(PdocUpdateJsonTextResult)}
624632
}}
625633
}}
626634
"""),
627-
variable_values={"fgroup_id": self.fgroup_id, "p": p, "json_path": json_path, "text": text, "expected_md5": expected_md5},
635+
variable_values={"fgroup_id": self.fgroup_id, "p": p, "updates": updates, "expected_md5": expected_md5},
628636
)
629-
return gql_utils.dataclass_from_dict(result["policydoc_update_json_text"], PdocUpdateJsonTextResult)
637+
return gql_utils.dataclass_from_dict(result["policydoc_update_at_location"], PdocUpdateJsonTextResult)
630638

631639
async def pdoc_cp(self, p1: str, p2: str, persona_id: str, fcall_untrusted_key: str) -> None:
632640
http = await self._http(persona_id, fcall_untrusted_key)

flexus_simple_bots/boss/boss_bot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ async def handle_plan_update_section(
206206
section_data[k] = v.replace("\\n", "\n")
207207
if isinstance(v, str) and "
" in v and "\n" not in v:
208208
section_data[k] = section_data[k].replace("
", "\n")
209-
upd = await pdoc_integration.pdoc_update_json_text(path, f"plan.{section}", json.dumps(section_data, ensure_ascii=False), persona_id=rcx.persona.persona_id, fcall_untrusted_key=uk, expected_md5=expected_md5)
209+
upd = await pdoc_integration.pdoc_update_at_location(path, [{"json_path": f"plan.{section}", "text": json.dumps(section_data, ensure_ascii=False)}], persona_id=rcx.persona.persona_id, fcall_untrusted_key=uk, expected_md5=expected_md5)
210210
if not upd.changes_saved:
211211
return f"📄 {path}\nmd5_requested={upd.md5_requested}\nmd5_found={upd.md5_found}\nchanges_saved=false\n\n{upd.problem_message or 'Document changed, please retry'}\n\n{upd.latest_text}"
212212

@@ -237,7 +237,7 @@ async def handle_plan_progress_add(
237237
return f"Error: plan {path} not found"
238238
prev = existing.pdoc_content.get("plan", {}).get("section03-progress", {}).get(field, "").rstrip("\n")
239239
new_value = (prev + "\n" + line).lstrip("\n")
240-
upd = await pdoc_integration.pdoc_update_json_text(path, f"plan.section03-progress.{field}", new_value, persona_id=rcx.persona.persona_id, fcall_untrusted_key=uk, expected_md5=expected_md5)
240+
upd = await pdoc_integration.pdoc_update_at_location(path, [{"json_path": f"plan.section03-progress.{field}", "text": new_value}], persona_id=rcx.persona.persona_id, fcall_untrusted_key=uk, expected_md5=expected_md5)
241241
if not upd.changes_saved:
242242
return f"📄 {path}\nmd5_requested={upd.md5_requested}\nmd5_found={upd.md5_found}\nchanges_saved=false\n\n{upd.problem_message or 'Document changed, please retry.'}\n\n{upd.latest_text}"
243243
return f"✍️ {path}\nmd5={upd.md5_found}\n\nAppended to {field}"

flexus_simple_bots/frog/frog_bot.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"gmail",
4646
"google_business",
4747
"google_ads",
48+
"google_sheets",
4849
"telegram",
4950
"slack",
5051
"skills"

0 commit comments

Comments
 (0)