@synap-core/cli 1.10.0 → 1.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -198
- package/dist/build-info.json +6 -0
- package/dist/commands/agent-run.js +3 -2
- package/dist/commands/agent-run.js.map +1 -1
- package/dist/commands/agents.d.ts +33 -17
- package/dist/commands/agents.js +203 -237
- package/dist/commands/agents.js.map +1 -1
- package/dist/commands/app.d.ts +143 -0
- package/dist/commands/app.js +523 -0
- package/dist/commands/app.js.map +1 -0
- package/dist/commands/automate.d.ts +21 -0
- package/dist/commands/automate.js +42 -0
- package/dist/commands/automate.js.map +1 -0
- package/dist/commands/automation-schema.test.d.ts +16 -0
- package/dist/commands/automation-schema.test.js +77 -0
- package/dist/commands/automation-schema.test.js.map +1 -0
- package/dist/commands/automation.d.ts +12 -0
- package/dist/commands/automation.js +80 -35
- package/dist/commands/automation.js.map +1 -1
- package/dist/commands/bridge-setup.d.ts +14 -1
- package/dist/commands/bridge-setup.js +392 -128
- package/dist/commands/bridge-setup.js.map +1 -1
- package/dist/commands/cap-connections.d.ts +4 -4
- package/dist/commands/cap-connections.js +14 -14
- package/dist/commands/cap-connections.js.map +1 -1
- package/dist/commands/capability.d.ts +2 -0
- package/dist/commands/capability.js +297 -176
- package/dist/commands/capability.js.map +1 -1
- package/dist/commands/catalog.d.ts +275 -0
- package/dist/commands/catalog.js +481 -0
- package/dist/commands/catalog.js.map +1 -0
- package/dist/commands/cell.d.ts +155 -8
- package/dist/commands/cell.js +416 -40
- package/dist/commands/cell.js.map +1 -1
- package/dist/commands/centrality.js +3 -14
- package/dist/commands/centrality.js.map +1 -1
- package/dist/commands/connect.d.ts +38 -13
- package/dist/commands/connect.js +68 -167
- package/dist/commands/connect.js.map +1 -1
- package/dist/commands/connections.d.ts +3 -2
- package/dist/commands/connections.js +95 -25
- package/dist/commands/connections.js.map +1 -1
- package/dist/commands/context.js +9 -2
- package/dist/commands/context.js.map +1 -1
- package/dist/commands/data-extra.d.ts +34 -0
- package/dist/commands/data-extra.js +198 -25
- package/dist/commands/data-extra.js.map +1 -1
- package/dist/commands/data.d.ts +120 -2
- package/dist/commands/data.js +307 -24
- package/dist/commands/data.js.map +1 -1
- package/dist/commands/diagnose.d.ts +66 -4
- package/dist/commands/diagnose.js +329 -29
- package/dist/commands/diagnose.js.map +1 -1
- package/dist/commands/digest.js +2 -1
- package/dist/commands/digest.js.map +1 -1
- package/dist/commands/doc.d.ts +25 -4
- package/dist/commands/doc.js +100 -18
- package/dist/commands/doc.js.map +1 -1
- package/dist/commands/doctor.d.ts +130 -0
- package/dist/commands/doctor.js +814 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/events.js +3 -1
- package/dist/commands/events.js.map +1 -1
- package/dist/commands/explain.js +5 -5
- package/dist/commands/explain.js.map +1 -1
- package/dist/commands/graph.js +5 -3
- package/dist/commands/graph.js.map +1 -1
- package/dist/commands/import.d.ts +368 -13
- package/dist/commands/import.js +1096 -55
- package/dist/commands/import.js.map +1 -1
- package/dist/commands/init.d.ts +20 -9
- package/dist/commands/init.js +433 -973
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/keys.d.ts +1 -0
- package/dist/commands/keys.js +15 -2
- package/dist/commands/keys.js.map +1 -1
- package/dist/commands/knowledge.d.ts +28 -6
- package/dist/commands/knowledge.js +358 -73
- package/dist/commands/knowledge.js.map +1 -1
- package/dist/commands/launch.js +2 -2
- package/dist/commands/launch.js.map +1 -1
- package/dist/commands/lens.d.ts +37 -1
- package/dist/commands/lens.js +193 -72
- package/dist/commands/lens.js.map +1 -1
- package/dist/commands/market-authoring.d.ts +72 -0
- package/dist/commands/market-authoring.js +566 -0
- package/dist/commands/market-authoring.js.map +1 -0
- package/dist/commands/market-official.d.ts +58 -0
- package/dist/commands/market-official.js +84 -0
- package/dist/commands/market-official.js.map +1 -0
- package/dist/commands/market.d.ts +419 -20
- package/dist/commands/market.js +2124 -193
- package/dist/commands/market.js.map +1 -1
- package/dist/commands/mcp.d.ts +70 -13
- package/dist/commands/mcp.js +308 -40
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/open.d.ts +39 -9
- package/dist/commands/open.js +80 -25
- package/dist/commands/open.js.map +1 -1
- package/dist/commands/playbook.d.ts +42 -0
- package/dist/commands/playbook.js +162 -0
- package/dist/commands/playbook.js.map +1 -0
- package/dist/commands/pod.js +1 -1
- package/dist/commands/pod.js.map +1 -1
- package/dist/commands/pods.d.ts +19 -0
- package/dist/commands/pods.js +220 -85
- package/dist/commands/pods.js.map +1 -1
- package/dist/commands/proposals-actions.d.ts +62 -0
- package/dist/commands/proposals-actions.js +146 -8
- package/dist/commands/proposals-actions.js.map +1 -1
- package/dist/commands/proposals-await.d.ts +68 -0
- package/dist/commands/proposals-await.js +248 -0
- package/dist/commands/proposals-await.js.map +1 -0
- package/dist/commands/proton-setup.d.ts +73 -0
- package/dist/commands/proton-setup.js +577 -0
- package/dist/commands/proton-setup.js.map +1 -0
- package/dist/commands/providers.d.ts +23 -0
- package/dist/commands/providers.js +126 -1
- package/dist/commands/providers.js.map +1 -1
- package/dist/commands/raycast.js +6 -2
- package/dist/commands/raycast.js.map +1 -1
- package/dist/commands/rule.d.ts +150 -0
- package/dist/commands/rule.js +447 -0
- package/dist/commands/rule.js.map +1 -0
- package/dist/commands/session-wait.d.ts +111 -0
- package/dist/commands/session-wait.js +209 -0
- package/dist/commands/session-wait.js.map +1 -0
- package/dist/commands/sessions.d.ts +52 -0
- package/dist/commands/sessions.js +479 -58
- package/dist/commands/sessions.js.map +1 -1
- package/dist/commands/skill-manage.d.ts +21 -0
- package/dist/commands/skill-manage.js +136 -19
- package/dist/commands/skill-manage.js.map +1 -1
- package/dist/commands/skills.js +19 -1
- package/dist/commands/skills.js.map +1 -1
- package/dist/commands/status.d.ts +1 -4
- package/dist/commands/status.js +5 -34
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/statusline.backoff.test.d.ts +13 -0
- package/dist/commands/statusline.backoff.test.js +100 -0
- package/dist/commands/statusline.backoff.test.js.map +1 -0
- package/dist/commands/statusline.js +16 -9
- package/dist/commands/statusline.js.map +1 -1
- package/dist/commands/sync-status.d.ts +12 -0
- package/dist/commands/sync-status.js +125 -0
- package/dist/commands/sync-status.js.map +1 -0
- package/dist/commands/templates-retire.d.ts +34 -0
- package/dist/commands/templates-retire.js +192 -0
- package/dist/commands/templates-retire.js.map +1 -0
- package/dist/commands/tools.js +6 -21
- package/dist/commands/tools.js.map +1 -1
- package/dist/commands/tracks.d.ts +51 -0
- package/dist/commands/tracks.js +291 -0
- package/dist/commands/tracks.js.map +1 -0
- package/dist/commands/update.d.ts +3 -11
- package/dist/commands/update.js +5 -134
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/upload.d.ts +68 -0
- package/dist/commands/upload.js +257 -0
- package/dist/commands/upload.js.map +1 -0
- package/dist/commands/vendor.d.ts +28 -0
- package/dist/commands/vendor.js +110 -0
- package/dist/commands/vendor.js.map +1 -0
- package/dist/commands/versions.js +6 -0
- package/dist/commands/versions.js.map +1 -1
- package/dist/commands/view.js +10 -5
- package/dist/commands/view.js.map +1 -1
- package/dist/commands/whoami.d.ts +23 -3
- package/dist/commands/whoami.js +169 -23
- package/dist/commands/whoami.js.map +1 -1
- package/dist/commands/worker.d.ts +122 -0
- package/dist/commands/worker.js +435 -0
- package/dist/commands/worker.js.map +1 -0
- package/dist/commands/worker.test.d.ts +1 -0
- package/dist/commands/worker.test.js +116 -0
- package/dist/commands/worker.test.js.map +1 -0
- package/dist/commands/workspace-ops.d.ts +35 -0
- package/dist/commands/workspace-ops.js +153 -0
- package/dist/commands/workspace-ops.js.map +1 -0
- package/dist/index.d.ts +6 -6
- package/dist/index.js +1009 -171
- package/dist/index.js.map +1 -1
- package/dist/lib/agent-connections.d.ts +31 -0
- package/dist/lib/agent-connections.js +33 -0
- package/dist/lib/agent-connections.js.map +1 -0
- package/dist/lib/agent-detect.d.ts +27 -0
- package/dist/lib/agent-detect.js +71 -0
- package/dist/lib/agent-detect.js.map +1 -0
- package/dist/lib/agent-door.d.ts +138 -0
- package/dist/lib/agent-door.js +426 -0
- package/dist/lib/agent-door.js.map +1 -0
- package/dist/lib/agents-config.d.ts +2 -0
- package/dist/lib/agents-config.js +4 -9
- package/dist/lib/agents-config.js.map +1 -1
- package/dist/lib/approval-poll.d.ts +31 -2
- package/dist/lib/approval-poll.js +20 -7
- package/dist/lib/approval-poll.js.map +1 -1
- package/dist/lib/atomic-file.d.ts +48 -0
- package/dist/lib/atomic-file.js +129 -0
- package/dist/lib/atomic-file.js.map +1 -0
- package/dist/lib/auth.d.ts +14 -9
- package/dist/lib/auth.js +44 -61
- package/dist/lib/auth.js.map +1 -1
- package/dist/lib/batch-approval.d.ts +85 -0
- package/dist/lib/batch-approval.js +170 -0
- package/dist/lib/batch-approval.js.map +1 -0
- package/dist/lib/capture-lane.d.ts +6 -5
- package/dist/lib/capture-lane.js +11 -8
- package/dist/lib/capture-lane.js.map +1 -1
- package/dist/lib/capture-structure.d.ts +342 -0
- package/dist/lib/capture-structure.js +295 -0
- package/dist/lib/capture-structure.js.map +1 -0
- package/dist/lib/catalog-templates.d.ts +59 -0
- package/dist/lib/catalog-templates.js +126 -0
- package/dist/lib/catalog-templates.js.map +1 -0
- package/dist/lib/cli-build.d.ts +19 -0
- package/dist/lib/cli-build.js +37 -0
- package/dist/lib/cli-build.js.map +1 -0
- package/dist/lib/conversation-headers.d.ts +18 -0
- package/dist/lib/conversation-headers.js +32 -0
- package/dist/lib/conversation-headers.js.map +1 -0
- package/dist/lib/cp-packages.d.ts +216 -4
- package/dist/lib/cp-packages.js +414 -11
- package/dist/lib/cp-packages.js.map +1 -1
- package/dist/lib/credential-class.d.ts +117 -0
- package/dist/lib/credential-class.js +116 -0
- package/dist/lib/credential-class.js.map +1 -0
- package/dist/lib/describe-lens.d.ts +35 -0
- package/dist/lib/describe-lens.js +40 -0
- package/dist/lib/describe-lens.js.map +1 -1
- package/dist/lib/device-connect.d.ts +125 -0
- package/dist/lib/device-connect.js +256 -0
- package/dist/lib/device-connect.js.map +1 -0
- package/dist/lib/directory-lens.d.ts +99 -0
- package/dist/lib/directory-lens.js +187 -0
- package/dist/lib/directory-lens.js.map +1 -0
- package/dist/lib/exporter-coverage.d.ts +71 -0
- package/dist/lib/exporter-coverage.js +97 -0
- package/dist/lib/exporter-coverage.js.map +1 -0
- package/dist/lib/hub-client.d.ts +43 -9
- package/dist/lib/hub-client.js +429 -65
- package/dist/lib/hub-client.js.map +1 -1
- package/dist/lib/id.d.ts +23 -0
- package/dist/lib/id.js +35 -0
- package/dist/lib/id.js.map +1 -0
- package/dist/lib/init-connect.d.ts +41 -0
- package/dist/lib/init-connect.js +75 -0
- package/dist/lib/init-connect.js.map +1 -0
- package/dist/lib/init-exit.d.ts +24 -0
- package/dist/lib/init-exit.js +41 -0
- package/dist/lib/init-exit.js.map +1 -0
- package/dist/lib/init-flow.d.ts +25 -0
- package/dist/lib/init-flow.js +40 -0
- package/dist/lib/init-flow.js.map +1 -0
- package/dist/lib/init-handoff.d.ts +16 -0
- package/dist/lib/init-handoff.js +19 -0
- package/dist/lib/init-handoff.js.map +1 -0
- package/dist/lib/init-output.d.ts +18 -0
- package/dist/lib/init-output.js +43 -0
- package/dist/lib/init-output.js.map +1 -0
- package/dist/lib/init-pod.d.ts +45 -0
- package/dist/lib/init-pod.js +36 -0
- package/dist/lib/init-pod.js.map +1 -0
- package/dist/lib/installed.d.ts +210 -11
- package/dist/lib/installed.js +234 -36
- package/dist/lib/installed.js.map +1 -1
- package/dist/lib/key-approval.d.ts +57 -0
- package/dist/lib/key-approval.js +117 -0
- package/dist/lib/key-approval.js.map +1 -0
- package/dist/lib/key-diagnosis.d.ts +56 -0
- package/dist/lib/key-diagnosis.js +227 -0
- package/dist/lib/key-diagnosis.js.map +1 -0
- package/dist/lib/key-doctor.d.ts +136 -0
- package/dist/lib/key-doctor.js +286 -0
- package/dist/lib/key-doctor.js.map +1 -0
- package/dist/lib/key-locations.d.ts +120 -0
- package/dist/lib/key-locations.js +326 -0
- package/dist/lib/key-locations.js.map +1 -0
- package/dist/lib/key-source.d.ts +66 -0
- package/dist/lib/key-source.js +106 -0
- package/dist/lib/key-source.js.map +1 -0
- package/dist/lib/key-state.d.ts +70 -0
- package/dist/lib/key-state.js +115 -0
- package/dist/lib/key-state.js.map +1 -0
- package/dist/lib/kind-package.d.ts +181 -0
- package/dist/lib/kind-package.js +679 -0
- package/dist/lib/kind-package.js.map +1 -0
- package/dist/lib/knowledge-title.d.ts +24 -0
- package/dist/lib/knowledge-title.js +46 -0
- package/dist/lib/knowledge-title.js.map +1 -0
- package/dist/lib/knowledge-title.test.d.ts +1 -0
- package/dist/lib/knowledge-title.test.js +34 -0
- package/dist/lib/knowledge-title.test.js.map +1 -0
- package/dist/lib/machine-instance.d.ts +64 -0
- package/dist/lib/machine-instance.js +142 -0
- package/dist/lib/machine-instance.js.map +1 -0
- package/dist/lib/mcp-bridge.d.ts +42 -0
- package/dist/lib/mcp-bridge.js +147 -0
- package/dist/lib/mcp-bridge.js.map +1 -0
- package/dist/lib/mcp-bridge.test.d.ts +1 -0
- package/dist/lib/mcp-bridge.test.js +90 -0
- package/dist/lib/mcp-bridge.test.js.map +1 -0
- package/dist/lib/mcp-call.d.ts +30 -0
- package/dist/lib/mcp-call.js +107 -0
- package/dist/lib/mcp-call.js.map +1 -0
- package/dist/lib/mcp-snippets.d.ts +53 -0
- package/dist/lib/mcp-snippets.js +82 -0
- package/dist/lib/mcp-snippets.js.map +1 -0
- package/dist/lib/next-steps.d.ts +8 -0
- package/dist/lib/next-steps.js +31 -1
- package/dist/lib/next-steps.js.map +1 -1
- package/dist/lib/package-wire.d.ts +179 -0
- package/dist/lib/package-wire.js +68 -0
- package/dist/lib/package-wire.js.map +1 -0
- package/dist/lib/pair-link.d.ts +38 -0
- package/dist/lib/pair-link.js +68 -0
- package/dist/lib/pair-link.js.map +1 -0
- package/dist/lib/pod-wide.d.ts +40 -0
- package/dist/lib/pod-wide.js +46 -0
- package/dist/lib/pod-wide.js.map +1 -0
- package/dist/lib/pod.d.ts +119 -115
- package/dist/lib/pod.js +206 -412
- package/dist/lib/pod.js.map +1 -1
- package/dist/lib/project-ref.d.ts +9 -3
- package/dist/lib/project-ref.js +10 -4
- package/dist/lib/project-ref.js.map +1 -1
- package/dist/lib/review-credential.d.ts +119 -0
- package/dist/lib/review-credential.js +147 -0
- package/dist/lib/review-credential.js.map +1 -0
- package/dist/lib/safe-open.d.ts +49 -0
- package/dist/lib/safe-open.js +119 -0
- package/dist/lib/safe-open.js.map +1 -0
- package/dist/lib/session-lens.d.ts +40 -1
- package/dist/lib/session-lens.js +54 -4
- package/dist/lib/session-lens.js.map +1 -1
- package/dist/lib/superwhisper-import.d.ts +8 -0
- package/dist/lib/superwhisper-import.js +14 -7
- package/dist/lib/superwhisper-import.js.map +1 -1
- package/dist/lib/superwhisper-title.test.d.ts +1 -0
- package/dist/lib/superwhisper-title.test.js +18 -0
- package/dist/lib/superwhisper-title.test.js.map +1 -0
- package/dist/lib/targets.d.ts +134 -10
- package/dist/lib/targets.js +962 -258
- package/dist/lib/targets.js.map +1 -1
- package/dist/lib/template-file.d.ts +78 -0
- package/dist/lib/template-file.js +140 -0
- package/dist/lib/template-file.js.map +1 -0
- package/dist/lib/template-lifecycle.d.ts +217 -0
- package/dist/lib/template-lifecycle.js +433 -0
- package/dist/lib/template-lifecycle.js.map +1 -0
- package/dist/lib/template-steps.d.ts +88 -0
- package/dist/lib/template-steps.js +118 -0
- package/dist/lib/template-steps.js.map +1 -0
- package/dist/lib/time-ago.d.ts +2 -0
- package/dist/lib/time-ago.js +15 -0
- package/dist/lib/time-ago.js.map +1 -0
- package/dist/utils/logger.js +5 -2
- package/dist/utils/logger.js.map +1 -1
- package/package.json +25 -18
- package/skills/README.md +12 -10
- package/skills/agent-os/SKILL.md +220 -99
- package/skills/manifest.json +2 -2
- package/skills/onboard/SKILL.md +61 -25
- package/skills/synap/README.md +5 -8
- package/skills/synap/SKILL.md +1185 -301
- package/skills/synap/_order.txt +7 -0
- package/skills/synap/_skill.yaml +1 -1
- package/skills/synap/automations.md +15 -0
- package/skills/synap/capture.md +54 -151
- package/skills/synap/cli-operations.md +24 -18
- package/skills/synap/common-mistakes.md +1 -0
- package/skills/synap/concepts.md +28 -0
- package/skills/synap/content-os.md +92 -0
- package/skills/synap/creative-loop.md +15 -10
- package/skills/synap/crm.md +21 -52
- package/skills/synap/digesting-a-channel.md +25 -0
- package/skills/synap/document-embeds.md +141 -47
- package/skills/synap/escalation-ladder.md +20 -10
- package/skills/synap/focus-sessions.md +47 -21
- package/skills/synap/from-intent.md +142 -0
- package/skills/synap/governance-rules.md +4 -4
- package/skills/synap/governance.md +10 -7
- package/skills/synap/hand-off.md +33 -0
- package/skills/synap/inline-patterns.md +15 -7
- package/skills/synap/lenses.md +33 -15
- package/skills/synap/linking.md +41 -40
- package/skills/synap/mcp-remote-servers.md +64 -0
- package/skills/synap/mental-model.md +24 -22
- package/skills/synap/multi-entity-capture.md +6 -4
- package/skills/synap/operating-mode-rules.md +1 -1
- package/skills/synap/processes.md +118 -0
- package/skills/synap/quick-reference.md +5 -1
- package/skills/synap/reading.md +3 -1
- package/skills/synap/reflexes.md +12 -42
- package/skills/synap/viewframe-cells.md +38 -5
- package/skills/synap/work-flow.md +1 -1
- package/skills/synap/work-model.md +96 -0
- package/skills/synap/worked-examples.md +21 -1
- package/skills/synap/workspace-design.md +14 -10
- package/skills/synap/writes.md +165 -35
- package/skills/synap/writing-titles.md +63 -0
- package/skills/synap-app/SKILL.md +319 -0
- package/skills/synap-app/_order.txt +5 -0
- package/skills/synap-app/_skill.yaml +20 -0
- package/skills/synap-app/creating-the-base-app.md +64 -0
- package/skills/synap-app/governance.md +42 -0
- package/skills/synap-app/install-commands.md +55 -0
- package/skills/synap-app/overview.md +50 -0
- package/skills/synap-app/using-the-sdk.md +73 -0
- package/skills/synap-design/SKILL.md +474 -0
- package/skills/synap-design/_order.txt +4 -0
- package/skills/synap-design/_skill.yaml +21 -0
- package/skills/synap-design/loop.md +134 -0
- package/skills/synap-design/overview.md +44 -0
- package/skills/synap-design/principles.md +130 -0
- package/skills/synap-design/system.md +133 -0
- package/skills/synap-market/SKILL.md +625 -0
- package/skills/synap-market/_order.txt +5 -0
- package/skills/synap-market/_skill.yaml +24 -0
- package/skills/synap-market/author-and-publish.md +212 -0
- package/skills/synap-market/discover-and-fetch.md +59 -0
- package/skills/synap-market/governance-and-catalog.md +63 -0
- package/skills/synap-market/install.md +133 -0
- package/skills/synap-market/overview.md +119 -0
- package/skills/synap-schema/SKILL.md +172 -10
- package/skills/synap-schema/_order.txt +2 -0
- package/skills/synap-schema/_skill.yaml +4 -2
- package/skills/synap-schema/common-mistakes.md +4 -2
- package/skills/synap-schema/discover-profiles.md +1 -1
- package/skills/synap-schema/entity-scope.md +15 -3
- package/skills/synap-schema/extend-first.md +29 -0
- package/skills/synap-schema/extend-vs-create.md +1 -1
- package/skills/synap-schema/intent-vocabulary-ssot.md +111 -0
- package/skills/synap-schema/property-types.md +1 -1
- package/skills/synap-schema/relations.md +1 -1
- package/skills/synap-ui/SKILL.md +19 -12
- package/skills/synap-ui/_skill.yaml +1 -1
- package/skills/synap-ui/ai-companion.md +1 -1
- package/skills/synap-ui/arranging-bento.md +2 -0
- package/skills/synap-ui/bento-layouts.md +10 -10
- package/skills/synap-ui/bento-recipes.md +313 -543
- package/skills/synap-ui/four-builds.md +5 -0
- package/skills/synap-ui/view-types.md +2 -2
- package/skills/synap-ui/widget-catalog.md +22 -278
- package/templates/automations/bookmark-enrichment.automation.json +290 -13
- package/templates/automations/url-bookmark-capture.automation.json +73 -11
- package/templates/skills/authoring-playbooks/SKILL.md +6 -3
- package/templates/skills/authoring-playbooks/reference/stages-contract.md +15 -0
- package/templates/skills/authoring-playbooks/reference/worked-example.md +3 -0
- package/dist/commands/infra.d.ts +0 -21
- package/dist/commands/infra.js +0 -262
- package/dist/commands/infra.js.map +0 -1
- package/dist/lib/browser-auth.d.ts +0 -35
- package/dist/lib/browser-auth.js +0 -170
- package/dist/lib/browser-auth.js.map +0 -1
- package/dist/lib/openclaw.d.ts +0 -32
- package/dist/lib/openclaw.js +0 -164
- package/dist/lib/openclaw.js.map +0 -1
- package/dist/lib/seed.d.ts +0 -13
- package/dist/lib/seed.js +0 -135
- package/dist/lib/seed.js.map +0 -1
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* synap rule — the fourth door.
|
|
3
|
+
*
|
|
4
|
+
* `ask` recalls, `capture` writes a fact, `diagnose` inspects. `rule` states a
|
|
5
|
+
* STANDING instruction: something that should keep holding, not something to do
|
|
6
|
+
* once.
|
|
7
|
+
*
|
|
8
|
+
* WHAT THIS DOOR DOES NOT DO — and deliberately never pretends to:
|
|
9
|
+
* synthesising the BEHAVIOUR half (an automation flow) from a sentence needs an
|
|
10
|
+
* agent, and that is not this wave. This command classifies the sentence, shows
|
|
11
|
+
* the reading (including the literal cues that fired, so an AI-authored routing
|
|
12
|
+
* is inspectable rather than oracular), refuses to guess when the classifier
|
|
13
|
+
* asks for clarification, creates the rule RECORD through the governed door,
|
|
14
|
+
* and then says plainly that no behaviour is attached yet.
|
|
15
|
+
*
|
|
16
|
+
* It does NOT point at `synap automate`: that door asks the agent for a
|
|
17
|
+
* standalone automation and never links it back to this rule (the only
|
|
18
|
+
* callers of `linkRuleHalves` are the rule create/update doors), so the hint
|
|
19
|
+
* sent users to make an orphan. The door that CAN attach behaviour to an
|
|
20
|
+
* existing rule is `skills.updateRule` with a sentence — reachable today from
|
|
21
|
+
* Relay's rule editor (Rules → the rule → Edit). The browser's rule modal is
|
|
22
|
+
* not that door: it writes a new automation, not an edit to this rule.
|
|
23
|
+
*
|
|
24
|
+
* The expensive failure this command exists to prevent is materialising a
|
|
25
|
+
* ONE-OFF request ("we're working on Stellar Grants — research the process")
|
|
26
|
+
* as a permanent rule. The classifier flags it; we stop and ask.
|
|
27
|
+
*/
|
|
28
|
+
import chalk from "chalk";
|
|
29
|
+
import prompts from "prompts";
|
|
30
|
+
import { log } from "../utils/logger.js";
|
|
31
|
+
import { renderNextSteps } from "../lib/next-steps.js";
|
|
32
|
+
import { resolveHubConfig, hubGet, hubPost, HubError, } from "../lib/hub-client.js";
|
|
33
|
+
/**
|
|
34
|
+
* How many automations this rule activates.
|
|
35
|
+
*
|
|
36
|
+
* Prefers the pod's edge-derived projection and falls back to the JSONB only
|
|
37
|
+
* when the field is ABSENT — an older pod — never when it is an empty array,
|
|
38
|
+
* which is a real answer meaning "no behaviour". Coalescing those two would
|
|
39
|
+
* resurrect the divergence this function exists to end.
|
|
40
|
+
*/
|
|
41
|
+
function behaviourCountOf(r) {
|
|
42
|
+
return r.automationIds !== undefined
|
|
43
|
+
? r.automationIds.length
|
|
44
|
+
: (r.rule.behaviours?.length ?? 0);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The classify door is not deployed on the pod we are talking to. This is a
|
|
48
|
+
* distinct outcome from "the pod said no": we refuse to write a rule we could
|
|
49
|
+
* not read, so this fails CLOSED rather than falling back to a blind create.
|
|
50
|
+
*/
|
|
51
|
+
export class ClassifyDoorMissingError extends Error {
|
|
52
|
+
door;
|
|
53
|
+
constructor(door) {
|
|
54
|
+
// User-facing sentence first, route second. "no rule-intent classifier
|
|
55
|
+
// door" named an internal component: true, and useless to someone deciding
|
|
56
|
+
// what to do about it. The route stays in parentheses because this is a
|
|
57
|
+
// terminal — the reader may well be the person who deploys the pod.
|
|
58
|
+
super(`This pod can't read rules yet — it's running a build from before rules existed (${door} not found).`);
|
|
59
|
+
this.door = door;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The door exists and the pod is current — this API KEY simply lacks the Bearer
|
|
64
|
+
* scope. A third distinct cause, and it must never be reported as either of the
|
|
65
|
+
* other two: "your pod is old" sends the user to an upgrade they don't need,
|
|
66
|
+
* and "your sentence is ambiguous" sends them to rewrite a fine sentence.
|
|
67
|
+
*/
|
|
68
|
+
export class MissingScopeError extends Error {
|
|
69
|
+
scope;
|
|
70
|
+
constructor(scope) {
|
|
71
|
+
super(`This API key lacks the \`${scope}\` scope.`);
|
|
72
|
+
this.scope = scope;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/** Discriminate the door's two different 403s by their body. */
|
|
76
|
+
function scopeErrorOrRethrow(err, scope) {
|
|
77
|
+
if (err instanceof HubError && err.status === 403) {
|
|
78
|
+
throw new MissingScopeError(scope);
|
|
79
|
+
}
|
|
80
|
+
throw err;
|
|
81
|
+
}
|
|
82
|
+
// ── Transport: the Hub-REST rule doors ───────────────────────────────────────
|
|
83
|
+
// NOT `${podUrl}/trpc/skills.*`. Those are `protectedProcedure`, and
|
|
84
|
+
// `src/commands/automation.ts:118-131` documents that a `protectedProcedure`
|
|
85
|
+
// trips an identity-remap bug for API-key-authenticated CLI callers and answers
|
|
86
|
+
// a bare 403. The Hub-REST doors reach the same logic through
|
|
87
|
+
// `scopedProcedure`, which is API-key-native.
|
|
88
|
+
//
|
|
89
|
+
// Every door the CLI touches is named here and nowhere else, so a backend
|
|
90
|
+
// contract correction is a one-place change.
|
|
91
|
+
const CLASSIFY_DOOR = "POST /api/hub/rules/classify";
|
|
92
|
+
const liveDeps = {
|
|
93
|
+
// Body is `{ text, context? }` — the door takes NO workspaceId. `context`
|
|
94
|
+
// (the pod's capability + profile slugs) is optional grounding that only
|
|
95
|
+
// sharpens confidences and can never raise a shape on its own, so it is
|
|
96
|
+
// deliberately not fetched: two extra round-trips before every `synap rule`
|
|
97
|
+
// would buy nothing the verdict depends on.
|
|
98
|
+
classify: async (text, cfg) => {
|
|
99
|
+
try {
|
|
100
|
+
return (await hubPost("/rules/classify", { text }, cfg));
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
// A pod on an older build has no such route — a DIFFERENT outcome from
|
|
104
|
+
// both "your sentence is ambiguous" and "your key lacks the scope".
|
|
105
|
+
if (err instanceof HubError && err.status === 404) {
|
|
106
|
+
throw new ClassifyDoorMissingError(CLASSIFY_DOOR);
|
|
107
|
+
}
|
|
108
|
+
scopeErrorOrRethrow(err, "hub-protocol.read");
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
create: async (input, cfg) => {
|
|
112
|
+
try {
|
|
113
|
+
return (await hubPost("/rules", { ...input, automationIds: [] }, cfg));
|
|
114
|
+
}
|
|
115
|
+
catch (err) {
|
|
116
|
+
// The door answers a governance DENIAL with 403 + the verdict body
|
|
117
|
+
// (`{ status:"denied", reason }`), and a missing Bearer scope with 403 +
|
|
118
|
+
// `{ error }`. Same status, different causes — discriminate on the body,
|
|
119
|
+
// and hand the denial back as the normal result it is.
|
|
120
|
+
if (err instanceof HubError && err.status === 403) {
|
|
121
|
+
const body = err.body;
|
|
122
|
+
if (body?.status === "denied") {
|
|
123
|
+
return {
|
|
124
|
+
status: "denied",
|
|
125
|
+
reason: String(body.reason ?? "no reason given"),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
scopeErrorOrRethrow(err, "hub-protocol.write");
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
// `includeProposed=true` is ALWAYS sent: this listing answers "what rules are
|
|
133
|
+
// there", and a rule awaiting review is one of them. Without it the door
|
|
134
|
+
// returns 0 straight after `synap rule "…"` proposes one, and the next reader
|
|
135
|
+
// (human or agent) proposes the same rule again. Proposed rows arrive marked
|
|
136
|
+
// (`status:"proposed"` + `proposalId`) and are rendered as pending, never
|
|
137
|
+
// silently mixed in with rules that are actually in effect. An older pod
|
|
138
|
+
// ignores the param and answers exactly as before.
|
|
139
|
+
list: async (cfg, workspaceId) => {
|
|
140
|
+
try {
|
|
141
|
+
const res = (await hubGet("/rules", { ...(workspaceId ? { workspaceId } : {}), includeProposed: "true" }, cfg));
|
|
142
|
+
return res?.rules ?? [];
|
|
143
|
+
}
|
|
144
|
+
catch (err) {
|
|
145
|
+
scopeErrorOrRethrow(err, "hub-protocol.read");
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
config: (opts) => resolveHubConfig(opts),
|
|
149
|
+
confirm: async (message) => {
|
|
150
|
+
if (!process.stdin.isTTY)
|
|
151
|
+
return false;
|
|
152
|
+
const { ok } = await prompts({ type: "confirm", name: "ok", message, initial: false });
|
|
153
|
+
return Boolean(ok);
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
// ── Rendering ────────────────────────────────────────────────────────────────
|
|
157
|
+
const SHAPE_MEANING = {
|
|
158
|
+
fact: "an instruction the agent should keep in mind",
|
|
159
|
+
behaviour: "something that should happen automatically",
|
|
160
|
+
structure: "how things should be organised",
|
|
161
|
+
schedule: "something recurring on a clock",
|
|
162
|
+
notification: "someone should be told",
|
|
163
|
+
extraction: "data should be pulled out of something",
|
|
164
|
+
unknown: "not recognisable as a standing rule",
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Show WHY it read the sentence that way. A routing the user cannot inspect is
|
|
168
|
+
* exactly what this product refuses to ship, so the cues are printed beside
|
|
169
|
+
* every shape — not just the verdict.
|
|
170
|
+
*
|
|
171
|
+
* Cues are human-readable LABELS, not necessarily substrings of the input
|
|
172
|
+
* (some are synthetic, e.g. "identity attribute" / "capability: calendly"), so
|
|
173
|
+
* they are printed as a `because:` list and never highlighted in the sentence.
|
|
174
|
+
* `shapes` is never empty: the unclassifiable/one-off case arrives as a single
|
|
175
|
+
* `unknown` entry, which still carries the cues that led there — so it is
|
|
176
|
+
* rendered, not filtered away.
|
|
177
|
+
*/
|
|
178
|
+
function renderReading(route) {
|
|
179
|
+
log.heading(" Understood as");
|
|
180
|
+
const width = Math.max(...route.shapes.map((s) => s.shape.length));
|
|
181
|
+
for (const s of route.shapes) {
|
|
182
|
+
const label = s.shape.padEnd(width);
|
|
183
|
+
const lead = s.shape === route.primary ? chalk.bold(label) : chalk.dim(label);
|
|
184
|
+
// Confidences are numbers in a column — pad so the decimal points align.
|
|
185
|
+
// Never rendered as a percentage: the classifier caps at 0.95 on purpose.
|
|
186
|
+
const conf = s.confidence.toFixed(2).padStart(5);
|
|
187
|
+
console.log(` ${lead} ${chalk.cyan(conf)} ${chalk.dim(SHAPE_MEANING[s.shape])}`);
|
|
188
|
+
if (s.cues.length > 0) {
|
|
189
|
+
console.log(chalk.dim(` ${" ".repeat(width)} because: ${s.cues.join(", ")}`));
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
function scopeLabel(scope) {
|
|
194
|
+
return scope.kind === "workspace" && scope.workspaceId
|
|
195
|
+
? `workspace ${scope.workspaceId.slice(0, 8)}…`
|
|
196
|
+
: scope.kind;
|
|
197
|
+
}
|
|
198
|
+
export async function rule(text, opts, deps = liveDeps) {
|
|
199
|
+
const intent = text.trim();
|
|
200
|
+
if (!intent) {
|
|
201
|
+
console.error(chalk.red('Error: a rule is required. Usage: synap rule "your rule"'));
|
|
202
|
+
process.exit(1);
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
let cfg;
|
|
206
|
+
try {
|
|
207
|
+
cfg = await deps.config({ podUrl: opts.podUrl, apiKey: opts.apiKey });
|
|
208
|
+
}
|
|
209
|
+
catch (err) {
|
|
210
|
+
log.error(err instanceof Error ? err.message : String(err));
|
|
211
|
+
process.exit(1);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
const workspaceId = opts.podWide ? undefined : (opts.workspace ?? cfg.workspaceId);
|
|
215
|
+
const scope = workspaceId
|
|
216
|
+
? { kind: "workspace", workspaceId }
|
|
217
|
+
: { kind: "pod" };
|
|
218
|
+
// 1. READ before writing. A rule we could not classify is a rule we refuse
|
|
219
|
+
// to create — nothing here falls back to a blind create.
|
|
220
|
+
let route;
|
|
221
|
+
let classifyOutcome = "classify-failed";
|
|
222
|
+
try {
|
|
223
|
+
route = await deps.classify(intent, cfg);
|
|
224
|
+
}
|
|
225
|
+
catch (err) {
|
|
226
|
+
if (err instanceof ClassifyDoorMissingError) {
|
|
227
|
+
classifyOutcome = "classify-door-missing";
|
|
228
|
+
log.error(err.message);
|
|
229
|
+
log.hint("This is your POD's build, not your sentence — update the pod, then retry.");
|
|
230
|
+
log.hint("`synap rule` will not create a rule it could not read first.");
|
|
231
|
+
}
|
|
232
|
+
else if (err instanceof MissingScopeError) {
|
|
233
|
+
classifyOutcome = "missing-scope";
|
|
234
|
+
log.error(err.message);
|
|
235
|
+
log.hint("This is your API KEY, not your pod or your sentence — re-issue it with that scope:");
|
|
236
|
+
log.hint(" synap connect --target=<surface>");
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
log.error(err instanceof Error ? err.message : String(err));
|
|
240
|
+
}
|
|
241
|
+
if (opts.json) {
|
|
242
|
+
console.log(JSON.stringify({ ok: false, outcome: classifyOutcome, intent }, null, 2));
|
|
243
|
+
}
|
|
244
|
+
process.exit(1);
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
if (!opts.json) {
|
|
248
|
+
log.heading(" Rule");
|
|
249
|
+
log.dim(`"${intent}"`);
|
|
250
|
+
renderReading(route);
|
|
251
|
+
log.blank();
|
|
252
|
+
console.log(chalk.dim(` scope: ${scopeLabel(scope)}`));
|
|
253
|
+
}
|
|
254
|
+
// 2. Refuse to guess. `--yes` does NOT override this: the classifier is
|
|
255
|
+
// saying it cannot route the sentence, and skipping a confirmation is not
|
|
256
|
+
// the same as answering the question.
|
|
257
|
+
if (route.needsClarification) {
|
|
258
|
+
if (opts.json) {
|
|
259
|
+
console.log(JSON.stringify({ ok: false, outcome: "needs-clarification", intent, route }, null, 2));
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
log.blank();
|
|
263
|
+
log.warn(`Ambiguous: ${route.needsClarification.reason}`);
|
|
264
|
+
log.hint(route.needsClarification.question);
|
|
265
|
+
log.hint("Nothing was created — this is your sentence, not your pod. Re-run with a clearer one.");
|
|
266
|
+
}
|
|
267
|
+
process.exit(1);
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
// 3. A one-off request is not a rule. Creating a permanent rule from a
|
|
271
|
+
// one-shot ask is the expensive mistake — stop and confirm.
|
|
272
|
+
if (route.oneShot) {
|
|
273
|
+
if (opts.json && !opts.yes) {
|
|
274
|
+
console.log(JSON.stringify({ ok: false, outcome: "one-shot-refused", intent, route }, null, 2));
|
|
275
|
+
process.exit(1);
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
if (!opts.json) {
|
|
279
|
+
log.blank();
|
|
280
|
+
log.warn("This reads as a ONE-OFF request, not a standing rule.");
|
|
281
|
+
log.hint("A rule is permanent — it keeps applying. For a one-time job, ask the agent:");
|
|
282
|
+
log.hint(` synap ask "${intent}"`);
|
|
283
|
+
}
|
|
284
|
+
if (!opts.yes) {
|
|
285
|
+
const confirmed = await deps.confirm("Create a permanent rule anyway?");
|
|
286
|
+
if (!confirmed) {
|
|
287
|
+
log.blank();
|
|
288
|
+
log.info("No rule created.");
|
|
289
|
+
renderNextSteps([
|
|
290
|
+
{ command: `synap ask "${intent}"`, why: "run this once instead of standing it up as a rule" },
|
|
291
|
+
{ command: "synap rule --yes \"<text>\"", why: "create it as a rule anyway" },
|
|
292
|
+
]);
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
// 4. Governed write. `proposed` is the normal agent outcome — a PR, not a
|
|
298
|
+
// failure — and is never rendered as an error.
|
|
299
|
+
let result;
|
|
300
|
+
try {
|
|
301
|
+
result = await deps.create({ intent, scope }, cfg);
|
|
302
|
+
}
|
|
303
|
+
catch (err) {
|
|
304
|
+
log.error(err instanceof Error ? err.message : String(err));
|
|
305
|
+
if (err instanceof MissingScopeError) {
|
|
306
|
+
log.hint("Re-issue the key with that scope: synap connect --target=<surface>");
|
|
307
|
+
}
|
|
308
|
+
if (opts.json) {
|
|
309
|
+
console.log(JSON.stringify({
|
|
310
|
+
ok: false,
|
|
311
|
+
outcome: err instanceof MissingScopeError ? "missing-scope" : "create-failed",
|
|
312
|
+
intent,
|
|
313
|
+
}, null, 2));
|
|
314
|
+
}
|
|
315
|
+
process.exit(1);
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
const nextSteps = [];
|
|
319
|
+
if (result.status === "proposed" && result.proposalId) {
|
|
320
|
+
nextSteps.push({
|
|
321
|
+
command: `synap open proposal ${result.proposalId}`,
|
|
322
|
+
why: "review and approve the rule",
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
nextSteps.push({ command: "synap rule list", why: "see every rule and what is attached" });
|
|
326
|
+
if (opts.json) {
|
|
327
|
+
console.log(JSON.stringify({
|
|
328
|
+
ok: result.status !== "denied",
|
|
329
|
+
outcome: result.status,
|
|
330
|
+
intent,
|
|
331
|
+
scope,
|
|
332
|
+
route,
|
|
333
|
+
...(result.ruleId ? { ruleId: result.ruleId } : {}),
|
|
334
|
+
...(result.proposalId ? { proposalId: result.proposalId } : {}),
|
|
335
|
+
...(result.reason ? { reason: result.reason } : {}),
|
|
336
|
+
// Honest about the half that does not exist yet.
|
|
337
|
+
behaviourAttached: false,
|
|
338
|
+
nextSteps,
|
|
339
|
+
}, null, 2));
|
|
340
|
+
if (result.status === "denied")
|
|
341
|
+
process.exit(1);
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
log.blank();
|
|
345
|
+
if (result.status === "denied") {
|
|
346
|
+
log.error(`Rule refused: ${result.reason ?? "no reason given"}`);
|
|
347
|
+
process.exit(1);
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
if (result.status === "proposed") {
|
|
351
|
+
log.info("Rule — proposed (queued for your review)");
|
|
352
|
+
if (result.proposalId)
|
|
353
|
+
log.dim(` proposal: ${result.proposalId}`);
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
log.success(`Rule created${result.ruleId ? " " + chalk.dim(result.ruleId) : ""}`);
|
|
357
|
+
}
|
|
358
|
+
log.warn("Intent recorded only — no behaviour is attached, so this rule will not run anything.");
|
|
359
|
+
log.hint(`${result.status === "proposed" ? "Once approved, open it" : "To make it run, open it"} in Relay (Rules → this rule → Edit) and set its WHEN and THEN.`);
|
|
360
|
+
log.hint("`synap automate` would build a separate automation that is not linked to this rule.");
|
|
361
|
+
renderNextSteps(nextSteps);
|
|
362
|
+
}
|
|
363
|
+
export async function ruleList(opts, deps = liveDeps) {
|
|
364
|
+
let cfg;
|
|
365
|
+
let rows;
|
|
366
|
+
try {
|
|
367
|
+
cfg = await deps.config({ podUrl: opts.podUrl, apiKey: opts.apiKey });
|
|
368
|
+
rows = await deps.list(cfg, opts.workspace ?? cfg.workspaceId);
|
|
369
|
+
}
|
|
370
|
+
catch (err) {
|
|
371
|
+
log.error(err instanceof Error ? err.message : String(err));
|
|
372
|
+
if (err instanceof MissingScopeError) {
|
|
373
|
+
log.hint("Re-issue the key with that scope: synap connect --target=<surface>");
|
|
374
|
+
}
|
|
375
|
+
process.exit(1);
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
if (opts.json) {
|
|
379
|
+
console.log(JSON.stringify({
|
|
380
|
+
ok: true,
|
|
381
|
+
count: rows.length,
|
|
382
|
+
rules: rows.map((r) => ({
|
|
383
|
+
id: r.id,
|
|
384
|
+
name: r.name,
|
|
385
|
+
approved: r.approved,
|
|
386
|
+
// A pod that predates the proposed-rule read sends no `status`;
|
|
387
|
+
// every row it returns IS a materialized rule.
|
|
388
|
+
status: r.status ?? "active",
|
|
389
|
+
...(r.proposalId ? { proposalId: r.proposalId } : {}),
|
|
390
|
+
intent: r.rule.intent,
|
|
391
|
+
scope: r.rule.scope,
|
|
392
|
+
trust: r.rule.trust,
|
|
393
|
+
behaviourCount: behaviourCountOf(r),
|
|
394
|
+
behaviourAttached: behaviourCountOf(r) > 0,
|
|
395
|
+
})),
|
|
396
|
+
}, null, 2));
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
log.heading(` Rules ${chalk.cyan(String(rows.length))}`);
|
|
400
|
+
if (rows.length === 0) {
|
|
401
|
+
log.dim("none yet");
|
|
402
|
+
renderNextSteps([
|
|
403
|
+
{ command: 'synap rule "<your rule>"', why: "state a standing rule in plain language" },
|
|
404
|
+
]);
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
const intents = rows.map((r) => r.rule.intent);
|
|
408
|
+
const intentWidth = Math.min(56, Math.max(...intents.map((i) => i.length)));
|
|
409
|
+
const scopes = rows.map((r) => scopeLabel(r.rule.scope));
|
|
410
|
+
const scopeWidth = Math.max(...scopes.map((s) => s.length));
|
|
411
|
+
for (const [i, r] of rows.entries()) {
|
|
412
|
+
// Three states, not two. A PROPOSED rule does not exist on the pod yet —
|
|
413
|
+
// collapsing it into "awaiting review" (which an unapproved but REAL row
|
|
414
|
+
// also is) would hide that nothing was written.
|
|
415
|
+
const proposed = r.status === "proposed";
|
|
416
|
+
const badge = proposed
|
|
417
|
+
? chalk.magenta("◇")
|
|
418
|
+
: r.approved
|
|
419
|
+
? chalk.green("●")
|
|
420
|
+
: chalk.yellow("○");
|
|
421
|
+
const intent = intents[i].length > intentWidth
|
|
422
|
+
? intents[i].slice(0, intentWidth - 1) + "…"
|
|
423
|
+
: intents[i].padEnd(intentWidth);
|
|
424
|
+
const count = behaviourCountOf(r);
|
|
425
|
+
// Counts are a column — pad the PLAIN text, then colour, so ANSI codes
|
|
426
|
+
// never enter the width arithmetic.
|
|
427
|
+
const plain = count > 0
|
|
428
|
+
? `${String(count).padStart(2)} automation${count === 1 ? "" : "s"}`
|
|
429
|
+
: " — no behaviour";
|
|
430
|
+
const behaviour = count > 0 ? chalk.green(plain.padEnd(14)) : chalk.dim(plain.padEnd(14));
|
|
431
|
+
// A proposed rule's own id is not addressable yet — show the PROPOSAL id,
|
|
432
|
+
// which is the only id that opens anything (`synap open proposal <id>`).
|
|
433
|
+
const trailingId = proposed
|
|
434
|
+
? chalk.magenta(`proposal ${(r.proposalId ?? "").slice(0, 8)}…`)
|
|
435
|
+
: chalk.dim(r.id.slice(0, 8) + "…");
|
|
436
|
+
console.log(` ${badge} ${intent} ${chalk.dim(scopes[i].padEnd(scopeWidth))} ${behaviour} ${trailingId}`);
|
|
437
|
+
}
|
|
438
|
+
log.blank();
|
|
439
|
+
console.log(chalk.dim(` ${chalk.green("●")} approved ${chalk.yellow("○")} awaiting review ${chalk.magenta("◇")} proposed — not written yet`));
|
|
440
|
+
renderNextSteps([
|
|
441
|
+
{ command: "synap open proposal <id>", why: "approve a rule that is awaiting review" },
|
|
442
|
+
]);
|
|
443
|
+
if (rows.some((r) => behaviourCountOf(r) === 0)) {
|
|
444
|
+
log.hint("A rule with no behaviour runs nothing — set its WHEN and THEN in Relay (Rules → the rule → Edit).");
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
//# sourceMappingURL=rule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule.js","sourceRoot":"","sources":["../../src/commands/rule.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,eAAe,EAAiB,MAAM,sBAAsB,CAAC;AACtE,OAAO,EACL,gBAAgB,EAChB,MAAM,EACN,OAAO,EACP,QAAQ,GAET,MAAM,sBAAsB,CAAC;AAoF9B;;;;;;;GAOG;AACH,SAAS,gBAAgB,CAAC,CAAU;IAClC,OAAO,CAAC,CAAC,aAAa,KAAK,SAAS;QAClC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM;QACxB,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,IAAI,CAAC,CAAC,CAAC;AACvC,CAAC;AAED;;;;GAIG;AACH,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IAC5B;IAArB,YAAqB,IAAY;QAC/B,uEAAuE;QACvE,2EAA2E;QAC3E,wEAA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AAC,CAAC;QACtC,OAAO,CAAC,GAAG,CACT,KAAK,KAAK,KAAK,MAAM,KAAK,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,KAAK,SAAS,KAAK,UAAU,EAAE,CACjG,CAAC;IACJ,CAAC;IACD,GAAG,CAAC,KAAK,EAAE,CAAC;IACZ,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,GAAG,CACP,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,eAAe,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,sBAAsB,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAC7H,CACF,CAAC;IACF,eAAe,CAAC;QACd,EAAE,OAAO,EAAE,0BAA0B,EAAE,GAAG,EAAE,wCAAwC,EAAE;KACvF,CAAC,CAAC;IACH,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QAChD,GAAG,CAAC,IAAI,CACN,mGAAmG,CACpG,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `synap session wait <sessionId>` — block until the session's human owner
|
|
3
|
+
* replies in the room.
|
|
4
|
+
*
|
|
5
|
+
* The loop-back half of the "ask, then wait" shape: an agent posts a question
|
|
6
|
+
* into the session room (`synap_post_message` / the room), then calls this
|
|
7
|
+
* command instead of a hand-rolled sleep loop or a blind re-invocation. It
|
|
8
|
+
* polls `GET /api/hub/focus-sessions/:id/answers` (owner-floored; `since`
|
|
9
|
+
* exclusive; contract in
|
|
10
|
+
* `~/.claude/projects/-Users-antoine-Documents-Code-synap/memory/
|
|
11
|
+
* scratch-lane-answer-loop-2026-09-25.md`) and exits the moment a reply
|
|
12
|
+
* arrives, printing it so the calling agent (Claude Code or any shell agent)
|
|
13
|
+
* can read it back and continue.
|
|
14
|
+
*
|
|
15
|
+
* Reuses `pollForApproval` — the ONE poll loop already shared by CP login,
|
|
16
|
+
* agent-key provisioning, and `proposals await`. No second poller. The
|
|
17
|
+
* generic `onTick` hook (data:null on a network blip or non-2xx) is enough to
|
|
18
|
+
* add one behaviour pollForApproval doesn't have on its own: a FAILED read is
|
|
19
|
+
* not "no answer yet". A handful of transient blips are tolerated (the
|
|
20
|
+
* existing per-tick interval IS the backoff), but a run of them means the
|
|
21
|
+
* read is genuinely broken, not merely pending — so this throws out of the
|
|
22
|
+
* poll loop rather than silently accumulating toward a "timeout" verdict that
|
|
23
|
+
* would misreport a broken pod as "the human hasn't answered".
|
|
24
|
+
*/
|
|
25
|
+
import { type HubConfig } from "../lib/hub-client.js";
|
|
26
|
+
import { type BaseOpts } from "./data.js";
|
|
27
|
+
/**
|
|
28
|
+
* The TYPED half of an answer, when the slot carried an `ask` (the pod's
|
|
29
|
+
* `SlotAnswerValue`). `text` stays the readable summary either way; this is
|
|
30
|
+
* the machine-readable pick. Loose on purpose: a CLI older than a new arm
|
|
31
|
+
* still prints it rather than dropping it.
|
|
32
|
+
*/
|
|
33
|
+
export type SessionAnswerValue = {
|
|
34
|
+
type: string;
|
|
35
|
+
} & Record<string, unknown>;
|
|
36
|
+
export interface SessionAnswer {
|
|
37
|
+
id: string;
|
|
38
|
+
text: string;
|
|
39
|
+
/** Absent on pods that predate typed answers; `null` for a free-text one. */
|
|
40
|
+
value?: SessionAnswerValue | null;
|
|
41
|
+
answeredAt: string;
|
|
42
|
+
answeredBy: string;
|
|
43
|
+
messageId: string | null;
|
|
44
|
+
slot: {
|
|
45
|
+
label: string;
|
|
46
|
+
kind: string;
|
|
47
|
+
question: string | null;
|
|
48
|
+
} | null;
|
|
49
|
+
question: {
|
|
50
|
+
messageId: string;
|
|
51
|
+
text: string;
|
|
52
|
+
askedAt: string;
|
|
53
|
+
askedBy: string | null;
|
|
54
|
+
} | null;
|
|
55
|
+
}
|
|
56
|
+
export interface AnswersPage {
|
|
57
|
+
sessionId: string;
|
|
58
|
+
since: string | null;
|
|
59
|
+
answers: SessionAnswer[];
|
|
60
|
+
nextSince: string | null;
|
|
61
|
+
hasMore: boolean;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Thrown when a read FAILED (bad response shape, repeated non-2xx, or the
|
|
65
|
+
* network dropping) — never confused with "the human hasn't answered yet".
|
|
66
|
+
* Distinct from pollForApproval's own timeout error so the command can give
|
|
67
|
+
* each a different exit code.
|
|
68
|
+
*/
|
|
69
|
+
export declare class SessionWaitReadFailure extends Error {
|
|
70
|
+
}
|
|
71
|
+
export interface WaitForAnswersOptions {
|
|
72
|
+
/** Only answers strictly after this ISO timestamp. Omit for "everything so far". */
|
|
73
|
+
since?: string;
|
|
74
|
+
timeoutMs: number;
|
|
75
|
+
intervalMs: number;
|
|
76
|
+
limit?: number;
|
|
77
|
+
}
|
|
78
|
+
export interface WaitForAnswersResult {
|
|
79
|
+
answers: SessionAnswer[];
|
|
80
|
+
/** Cursor to pass as `--since` on the next call — advances even on a timeout. */
|
|
81
|
+
nextSince: string | null;
|
|
82
|
+
elapsedMs: number;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Wait for at least one answer to land, or the deadline to elapse.
|
|
86
|
+
*
|
|
87
|
+
* Two phases, both against the same door: an IMMEDIATE first check (so an
|
|
88
|
+
* already-waiting answer, or a broken/owner-mismatched session, surfaces
|
|
89
|
+
* without paying one poll interval — same shape as `awaitProposal`'s first
|
|
90
|
+
* check), then the shared poll loop for the pending case.
|
|
91
|
+
*/
|
|
92
|
+
export declare function waitForAnswers(sessionId: string, cfg: HubConfig, opts: WaitForAnswersOptions): Promise<WaitForAnswersResult>;
|
|
93
|
+
/**
|
|
94
|
+
* The answer's typed value worth printing: a structured pick (confirm, chip,
|
|
95
|
+
* form, provide). A `{type:"text"}` value adds nothing to the text line, and a
|
|
96
|
+
* malformed one (no string `type`) is not printed as if it were an answer.
|
|
97
|
+
*/
|
|
98
|
+
export declare function typedValue(a: SessionAnswer): SessionAnswerValue | null;
|
|
99
|
+
/** Exit codes — documented on the command's `--help` (see index.ts). */
|
|
100
|
+
export declare const SESSION_WAIT_EXIT: {
|
|
101
|
+
readonly ANSWERED: 0;
|
|
102
|
+
readonly TIMEOUT: 1;
|
|
103
|
+
readonly FAILURE: 2;
|
|
104
|
+
};
|
|
105
|
+
export interface WaitSessionOpts extends BaseOpts {
|
|
106
|
+
since?: string;
|
|
107
|
+
timeout?: string;
|
|
108
|
+
interval?: string;
|
|
109
|
+
limit?: string;
|
|
110
|
+
}
|
|
111
|
+
export declare function waitSessionCommand(sessionId: string, opts: WaitSessionOpts): Promise<void>;
|