@synap-core/cli 1.11.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 +218 -168
- 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 +1 -13
- 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 +7 -1
- package/dist/commands/context.js.map +1 -1
- package/dist/commands/data-extra.d.ts +34 -0
- package/dist/commands/data-extra.js +193 -23
- package/dist/commands/data-extra.js.map +1 -1
- package/dist/commands/data.d.ts +120 -2
- package/dist/commands/data.js +293 -20
- package/dist/commands/data.js.map +1 -1
- package/dist/commands/diagnose.d.ts +66 -4
- package/dist/commands/diagnose.js +285 -28
- package/dist/commands/diagnose.js.map +1 -1
- package/dist/commands/doc.d.ts +11 -4
- package/dist/commands/doc.js +39 -14
- package/dist/commands/doc.js.map +1 -1
- package/dist/commands/doctor.d.ts +112 -3
- package/dist/commands/doctor.js +657 -32
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/explain.js +5 -5
- package/dist/commands/explain.js.map +1 -1
- package/dist/commands/import.d.ts +368 -13
- package/dist/commands/import.js +1064 -54
- 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 +22 -6
- package/dist/commands/knowledge.js +117 -55
- package/dist/commands/knowledge.js.map +1 -1
- package/dist/commands/lens.d.ts +37 -1
- package/dist/commands/lens.js +192 -71
- package/dist/commands/lens.js.map +1 -1
- package/dist/commands/market-authoring.d.ts +29 -2
- package/dist/commands/market-authoring.js +348 -7
- package/dist/commands/market-authoring.js.map +1 -1
- 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 +400 -16
- package/dist/commands/market.js +1802 -146
- package/dist/commands/market.js.map +1 -1
- package/dist/commands/mcp.d.ts +60 -25
- package/dist/commands/mcp.js +251 -64
- 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 +5 -0
- package/dist/commands/pods.js +97 -116
- package/dist/commands/pods.js.map +1 -1
- package/dist/commands/proposals-actions.d.ts +62 -0
- package/dist/commands/proposals-actions.js +143 -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 +478 -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 +16 -0
- 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 +41 -3
- package/dist/commands/upload.js +120 -18
- package/dist/commands/upload.js.map +1 -1
- 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 +900 -180
- 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 +6 -5
- package/dist/lib/capture-lane.js.map +1 -1
- package/dist/lib/capture-structure.d.ts +230 -11
- package/dist/lib/capture-structure.js +251 -13
- package/dist/lib/capture-structure.js.map +1 -1
- 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 +167 -11
- package/dist/lib/cp-packages.js +253 -21
- 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 +29 -8
- package/dist/lib/hub-client.js +328 -55
- package/dist/lib/hub-client.js.map +1 -1
- 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 +66 -112
- package/dist/lib/pod.js +134 -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 +4 -0
- package/dist/lib/template-file.js.map +1 -1
- 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 +23 -17
- package/skills/README.md +12 -10
- package/skills/agent-os/SKILL.md +214 -99
- package/skills/manifest.json +1 -1
- package/skills/onboard/SKILL.md +55 -26
- package/skills/synap/README.md +5 -8
- package/skills/synap/SKILL.md +1086 -283
- 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 +5 -0
- package/skills/synap/cli-operations.md +24 -18
- package/skills/synap/concepts.md +28 -0
- package/skills/synap/content-os.md +10 -1
- package/skills/synap/creative-loop.md +15 -10
- package/skills/synap/crm.md +21 -52
- 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 +17 -15
- 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 +4 -5
- package/skills/synap/workspace-design.md +14 -10
- package/skills/synap/writes.md +97 -24
- package/skills/synap/writing-titles.md +63 -0
- package/skills/synap-app/SKILL.md +2 -2
- package/skills/synap-app/_skill.yaml +1 -1
- package/skills/synap-app/install-commands.md +1 -1
- 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 +306 -16
- package/skills/synap-market/_skill.yaml +1 -1
- package/skills/synap-market/author-and-publish.md +145 -8
- package/skills/synap-market/governance-and-catalog.md +7 -0
- package/skills/synap-market/install.md +79 -1
- package/skills/synap-market/overview.md +74 -6
- 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/commands/template.d.ts +0 -42
- package/dist/commands/template.js +0 -191
- package/dist/commands/template.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
- package/node_modules/@synap/hub-rest-client/dist/index.cjs +0 -1261
- package/node_modules/@synap/hub-rest-client/dist/index.d.cts +0 -1647
- package/node_modules/@synap/hub-rest-client/dist/index.d.ts +0 -1647
- package/node_modules/@synap/hub-rest-client/dist/index.js +0 -1231
- package/node_modules/@synap/hub-rest-client/package.json +0 -45
- package/node_modules/@synap/hub-rest-client/src/client.ts +0 -1631
- package/node_modules/@synap/hub-rest-client/src/errors.ts +0 -30
- package/node_modules/@synap/hub-rest-client/src/index.ts +0 -153
- package/node_modules/@synap/hub-rest-client/src/setup.ts +0 -133
- package/node_modules/@synap/hub-rest-client/src/types.ts +0 -1299
|
@@ -1,1261 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
HubApiError: () => HubApiError,
|
|
24
|
-
HubRestClient: () => HubRestClient,
|
|
25
|
-
checkPodHealth: () => checkPodHealth,
|
|
26
|
-
setupAgent: () => setupAgent
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(index_exports);
|
|
29
|
-
|
|
30
|
-
// src/errors.ts
|
|
31
|
-
var HubApiError = class extends Error {
|
|
32
|
-
constructor(message, statusCode, body) {
|
|
33
|
-
super(message);
|
|
34
|
-
this.statusCode = statusCode;
|
|
35
|
-
this.body = body;
|
|
36
|
-
this.name = "HubApiError";
|
|
37
|
-
}
|
|
38
|
-
get isUnauthorized() {
|
|
39
|
-
return this.statusCode === 401;
|
|
40
|
-
}
|
|
41
|
-
get isForbidden() {
|
|
42
|
-
return this.statusCode === 403;
|
|
43
|
-
}
|
|
44
|
-
get isNotFound() {
|
|
45
|
-
return this.statusCode === 404;
|
|
46
|
-
}
|
|
47
|
-
get isServerError() {
|
|
48
|
-
return this.statusCode >= 500;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
// src/client.ts
|
|
53
|
-
function normalizeUrl(url) {
|
|
54
|
-
return url.replace(/\/$/, "");
|
|
55
|
-
}
|
|
56
|
-
function formatHubErrorMessage(status, statusText, errorBody) {
|
|
57
|
-
let detail = "";
|
|
58
|
-
if (errorBody && typeof errorBody === "object" && "error" in errorBody) {
|
|
59
|
-
detail = String(errorBody.error);
|
|
60
|
-
}
|
|
61
|
-
const base = `Hub API error: ${status} ${statusText}`;
|
|
62
|
-
let msg = detail ? `${base} \u2014 ${detail}` : base;
|
|
63
|
-
if (status === 403 && /hub-protocol\.write/i.test(detail)) {
|
|
64
|
-
msg += " Create or reconnect an API key that includes the hub-protocol.write scope (Settings \u2192 API keys on your pod).";
|
|
65
|
-
}
|
|
66
|
-
return msg;
|
|
67
|
-
}
|
|
68
|
-
function unwrapList(result) {
|
|
69
|
-
return Array.isArray(result) ? result : result.data ?? [];
|
|
70
|
-
}
|
|
71
|
-
function unwrapWorkspacesResponse(result) {
|
|
72
|
-
if (Array.isArray(result)) return result;
|
|
73
|
-
if (result && typeof result === "object" && "workspaces" in result) {
|
|
74
|
-
const w = result.workspaces;
|
|
75
|
-
return Array.isArray(w) ? w : [];
|
|
76
|
-
}
|
|
77
|
-
return unwrapList(result);
|
|
78
|
-
}
|
|
79
|
-
function unwrapSingle(result) {
|
|
80
|
-
if (result && typeof result === "object" && "data" in result) {
|
|
81
|
-
return result.data;
|
|
82
|
-
}
|
|
83
|
-
return result;
|
|
84
|
-
}
|
|
85
|
-
var HubRestClient = class {
|
|
86
|
-
base;
|
|
87
|
-
headers;
|
|
88
|
-
timeoutMs;
|
|
89
|
-
readTimeoutMs;
|
|
90
|
-
writeTimeoutMs;
|
|
91
|
-
maxAttempts;
|
|
92
|
-
workspaceId;
|
|
93
|
-
/** Cached from GET /users/me — avoids repeated identity calls. */
|
|
94
|
-
resolvedUserId = null;
|
|
95
|
-
constructor(config) {
|
|
96
|
-
this.base = normalizeUrl(config.podUrl);
|
|
97
|
-
this.headers = {
|
|
98
|
-
Authorization: `Bearer ${config.apiKey}`,
|
|
99
|
-
"Content-Type": "application/json"
|
|
100
|
-
};
|
|
101
|
-
this.workspaceId = config.workspaceId;
|
|
102
|
-
this.timeoutMs = config.timeoutMs ?? 3e4;
|
|
103
|
-
this.readTimeoutMs = config.readTimeoutMs ?? this.timeoutMs;
|
|
104
|
-
this.writeTimeoutMs = config.writeTimeoutMs ?? this.timeoutMs;
|
|
105
|
-
this.maxAttempts = Math.max(1, config.maxAttempts ?? 3);
|
|
106
|
-
}
|
|
107
|
-
/** User id for the current API key (Hub REST requires userId on several GETs). */
|
|
108
|
-
async resolveUserId() {
|
|
109
|
-
if (this.resolvedUserId) return this.resolvedUserId;
|
|
110
|
-
const me = await this.getMe();
|
|
111
|
-
this.resolvedUserId = me.id;
|
|
112
|
-
return me.id;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* The ONE shared request loop. Per-method timeout (GET = read, else write, or a
|
|
116
|
-
* caller override) + up to `maxAttempts` with exponential backoff. Retries ONLY
|
|
117
|
-
* on a network failure or 5xx; NEVER on a 4xx or a caller abort. Returns the raw
|
|
118
|
-
* `Response` for any non-5xx (ok OR 4xx) — the typed entry points below decide
|
|
119
|
-
* how to interpret it. This is the single source of retry/timeout truth, shared
|
|
120
|
-
* by the CLI and the IS's `ISHubClient` (which reuses the protected entry points
|
|
121
|
-
* rather than re-implementing fetch).
|
|
122
|
-
*/
|
|
123
|
-
async fetchWithRetry(method, path, body, signal, timeoutMsOverride) {
|
|
124
|
-
const url = `${this.base}${path}`;
|
|
125
|
-
const perAttemptTimeout = timeoutMsOverride ?? (method.toUpperCase() === "GET" ? this.readTimeoutMs : this.writeTimeoutMs);
|
|
126
|
-
let lastError;
|
|
127
|
-
for (let attempt = 0; attempt < this.maxAttempts; attempt++) {
|
|
128
|
-
if (attempt > 0) {
|
|
129
|
-
await new Promise((r) => setTimeout(r, 1e3 * attempt));
|
|
130
|
-
}
|
|
131
|
-
const timeout = AbortSignal.timeout(perAttemptTimeout);
|
|
132
|
-
const combined = signal ? AbortSignal.any([signal, timeout]) : timeout;
|
|
133
|
-
try {
|
|
134
|
-
const res = await fetch(url, {
|
|
135
|
-
method,
|
|
136
|
-
headers: this.headers,
|
|
137
|
-
body: body !== void 0 ? JSON.stringify(body) : void 0,
|
|
138
|
-
signal: combined
|
|
139
|
-
});
|
|
140
|
-
if (res.status < 500) return res;
|
|
141
|
-
lastError = new Error(`HTTP ${res.status}`);
|
|
142
|
-
} catch (err) {
|
|
143
|
-
if (signal?.aborted) throw err;
|
|
144
|
-
lastError = err;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
throw lastError;
|
|
148
|
-
}
|
|
149
|
-
/** Build a HubApiError from a non-ok Response (reads the JSON error body). */
|
|
150
|
-
async toHubError(res) {
|
|
151
|
-
const errorBody = await res.json().catch(() => ({}));
|
|
152
|
-
return new HubApiError(
|
|
153
|
-
formatHubErrorMessage(res.status, res.statusText, errorBody),
|
|
154
|
-
res.status,
|
|
155
|
-
errorBody
|
|
156
|
-
);
|
|
157
|
-
}
|
|
158
|
-
/** Parse a 2xx body, tolerating an empty/204 response (returns undefined). */
|
|
159
|
-
async parseBody(res) {
|
|
160
|
-
const text = await res.text();
|
|
161
|
-
return text ? JSON.parse(text) : void 0;
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Typed JSON request — throws `HubApiError` on any non-2xx. Protected so the IS
|
|
165
|
-
* subclass reuses it. Tolerates an empty/204 body (returns `undefined`).
|
|
166
|
-
*/
|
|
167
|
-
async request(method, path, body, signal) {
|
|
168
|
-
const res = await this.fetchWithRetry(method, path, body, signal);
|
|
169
|
-
if (!res.ok) throw await this.toHubError(res);
|
|
170
|
-
return this.parseBody(res);
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Like `request<T>` but returns `null` on 404/403 (the "absent/forbidden →
|
|
174
|
-
* empty" contract several IS reads use) instead of throwing.
|
|
175
|
-
*/
|
|
176
|
-
async requestOrNull(method, path, body, signal) {
|
|
177
|
-
const res = await this.fetchWithRetry(method, path, body, signal);
|
|
178
|
-
if (res.status === 404 || res.status === 403) return null;
|
|
179
|
-
if (!res.ok) throw await this.toHubError(res);
|
|
180
|
-
return this.parseBody(res);
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* The raw `Response` (same retry/timeout infra), for the few callers that read
|
|
184
|
-
* `.text()`, branch on status themselves, or need a per-call timeout override.
|
|
185
|
-
*/
|
|
186
|
-
async requestRaw(method, path, body, signal, timeoutMsOverride) {
|
|
187
|
-
return this.fetchWithRetry(method, path, body, signal, timeoutMsOverride);
|
|
188
|
-
}
|
|
189
|
-
// ─── Identity ─────────────────────────────────────────────────────────────
|
|
190
|
-
async getMe() {
|
|
191
|
-
return this.request("GET", "/api/hub/users/me");
|
|
192
|
-
}
|
|
193
|
-
async getWorkspaces() {
|
|
194
|
-
const result = await this.request("GET", "/api/hub/workspaces");
|
|
195
|
-
return unwrapWorkspacesResponse(result);
|
|
196
|
-
}
|
|
197
|
-
async provisionAgentWorkspace(input) {
|
|
198
|
-
return this.request(
|
|
199
|
-
"POST",
|
|
200
|
-
"/api/hub/workspaces/provision-agent",
|
|
201
|
-
input
|
|
202
|
-
);
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Get full activity context for a user — recent entities, active threads, workspace summary.
|
|
206
|
-
* Use at session start to orient the agent to the user's current state.
|
|
207
|
-
*/
|
|
208
|
-
async getUserContext(userId, options) {
|
|
209
|
-
const params = new URLSearchParams();
|
|
210
|
-
const wsId = options?.workspaceId ?? this.workspaceId;
|
|
211
|
-
if (wsId) params.set("workspaceId", wsId);
|
|
212
|
-
const qs = params.toString() ? `?${params}` : "";
|
|
213
|
-
return this.request(
|
|
214
|
-
"GET",
|
|
215
|
-
`/api/hub/users/${userId}/context${qs}`
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
// ─── Entities ─────────────────────────────────────────────────────────────
|
|
219
|
-
async searchEntities(query, options, signal) {
|
|
220
|
-
const params = new URLSearchParams({ q: query });
|
|
221
|
-
if (options?.profileSlug) params.set("profileSlug", options.profileSlug);
|
|
222
|
-
if (options?.scope !== "all") {
|
|
223
|
-
const wsId = options?.workspaceId ?? this.workspaceId;
|
|
224
|
-
if (wsId) params.set("workspaceId", wsId);
|
|
225
|
-
}
|
|
226
|
-
if (options?.limit) params.set("limit", String(options.limit));
|
|
227
|
-
const result = await this.request(
|
|
228
|
-
"GET",
|
|
229
|
-
`/api/hub/entities?${params}`,
|
|
230
|
-
void 0,
|
|
231
|
-
signal
|
|
232
|
-
);
|
|
233
|
-
return unwrapList(result);
|
|
234
|
-
}
|
|
235
|
-
async getEntity(id) {
|
|
236
|
-
const result = await this.request(
|
|
237
|
-
"GET",
|
|
238
|
-
`/api/hub/entities/${id}`
|
|
239
|
-
);
|
|
240
|
-
return unwrapSingle(result);
|
|
241
|
-
}
|
|
242
|
-
async getRecentEntities(options) {
|
|
243
|
-
const params = new URLSearchParams({
|
|
244
|
-
sort: "updatedAt:desc",
|
|
245
|
-
limit: String(options?.limit ?? 20)
|
|
246
|
-
});
|
|
247
|
-
if (options?.profileSlug) params.set("profileSlug", options.profileSlug);
|
|
248
|
-
if (options?.scope !== "all") {
|
|
249
|
-
const wsId = options?.workspaceId ?? this.workspaceId;
|
|
250
|
-
if (wsId) params.set("workspaceId", wsId);
|
|
251
|
-
}
|
|
252
|
-
const result = await this.request(
|
|
253
|
-
"GET",
|
|
254
|
-
`/api/hub/entities?${params}`
|
|
255
|
-
);
|
|
256
|
-
return unwrapList(result);
|
|
257
|
-
}
|
|
258
|
-
async createEntity(input) {
|
|
259
|
-
const { content, url, status, priority, dueDate, properties, ...rest } = input;
|
|
260
|
-
return this.request("POST", "/api/hub/entities", {
|
|
261
|
-
...rest,
|
|
262
|
-
// Entity placement is a write decision, never an ambient client default.
|
|
263
|
-
// Omitted means pod/base behavior; an explicit workspace opts into its
|
|
264
|
-
// overlay/membership lens. This deliberately differs from read helpers.
|
|
265
|
-
...rest.workspaceId ? { workspaceId: rest.workspaceId } : {},
|
|
266
|
-
...content !== void 0 ? { content } : {},
|
|
267
|
-
properties: {
|
|
268
|
-
...properties,
|
|
269
|
-
...url !== void 0 ? { url } : {},
|
|
270
|
-
...status !== void 0 ? { status } : {},
|
|
271
|
-
...priority !== void 0 ? { priority } : {},
|
|
272
|
-
...dueDate !== void 0 ? { dueDate } : {}
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
async updateEntity(id, input) {
|
|
277
|
-
const { properties, content, url, status, priority, dueDate, ...rest } = input;
|
|
278
|
-
return this.request(
|
|
279
|
-
"PATCH",
|
|
280
|
-
`/api/hub/entities/${id}`,
|
|
281
|
-
{
|
|
282
|
-
...rest,
|
|
283
|
-
metadata: {
|
|
284
|
-
...properties,
|
|
285
|
-
...content !== void 0 ? { content } : {},
|
|
286
|
-
...url !== void 0 ? { url } : {},
|
|
287
|
-
...status !== void 0 ? { status } : {},
|
|
288
|
-
...priority !== void 0 ? { priority } : {},
|
|
289
|
-
...dueDate !== void 0 ? { dueDate } : {}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
);
|
|
293
|
-
}
|
|
294
|
-
// ─── Unified Search ───────────────────────────────────────────────────────
|
|
295
|
-
/**
|
|
296
|
-
* Unified full-text search across entities, documents, and views.
|
|
297
|
-
* Use when you don't know the content type. For entity-only search use searchEntities().
|
|
298
|
-
*
|
|
299
|
-
* Note: The backend GET /search requires userId as a query param; this method resolves
|
|
300
|
-
* the current user automatically.
|
|
301
|
-
*/
|
|
302
|
-
async search(query, options, signal) {
|
|
303
|
-
const userId = await this.resolveUserId();
|
|
304
|
-
const wsId = options?.workspaceId ?? this.workspaceId;
|
|
305
|
-
const params = new URLSearchParams({ userId, query });
|
|
306
|
-
if (wsId) params.set("workspaceId", wsId);
|
|
307
|
-
if (options?.collections?.length)
|
|
308
|
-
params.set("collections", options.collections.join(","));
|
|
309
|
-
if (options?.limit) params.set("limit", String(options.limit));
|
|
310
|
-
return this.request(
|
|
311
|
-
"GET",
|
|
312
|
-
`/api/hub/search?${params}`,
|
|
313
|
-
void 0,
|
|
314
|
-
signal
|
|
315
|
-
);
|
|
316
|
-
}
|
|
317
|
-
// ─── Relations & Graph ────────────────────────────────────────────────────
|
|
318
|
-
/**
|
|
319
|
-
* Get all relations for an entity — inbound and outbound.
|
|
320
|
-
* Use to discover connections before graph traversal.
|
|
321
|
-
*
|
|
322
|
-
* Note: The backend GET /relations requires both userId and workspaceId.
|
|
323
|
-
* This method resolves userId automatically; workspaceId falls back to client default.
|
|
324
|
-
*/
|
|
325
|
-
async getRelations(entityId, options) {
|
|
326
|
-
const userId = await this.resolveUserId();
|
|
327
|
-
const wsId = options?.workspaceId ?? this.workspaceId;
|
|
328
|
-
if (!wsId) throw new Error("workspaceId is required for getRelations");
|
|
329
|
-
const params = new URLSearchParams({ userId, workspaceId: wsId, entityId });
|
|
330
|
-
const result = await this.request("GET", `/api/hub/relations?${params}`);
|
|
331
|
-
return unwrapList(result);
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
* Create a typed relation between two entities.
|
|
335
|
-
* Type is a free string — conventions: "related_to", "parent_of", "child_of",
|
|
336
|
-
* "belongs_to", "authored_by", "depends_on", "references".
|
|
337
|
-
* Goes through governance — may return "proposed".
|
|
338
|
-
*/
|
|
339
|
-
async createRelation(input) {
|
|
340
|
-
const userId = input.userId ?? await this.resolveUserId();
|
|
341
|
-
const wsId = input.workspaceId ?? this.workspaceId;
|
|
342
|
-
if (!wsId) throw new Error("workspaceId is required for createRelation");
|
|
343
|
-
return this.request("POST", "/api/hub/relations", {
|
|
344
|
-
userId,
|
|
345
|
-
workspaceId: wsId,
|
|
346
|
-
sourceEntityId: input.sourceEntityId,
|
|
347
|
-
targetEntityId: input.targetEntityId,
|
|
348
|
-
type: input.type
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
/**
|
|
352
|
-
* Attach a role-profile through the canonical governed facet door. A result
|
|
353
|
-
* may be `proposed`; callers must surface its review information instead of
|
|
354
|
-
* claiming the role was applied.
|
|
355
|
-
*/
|
|
356
|
-
async attachFacet(input) {
|
|
357
|
-
const userId = await this.resolveUserId();
|
|
358
|
-
return this.request(
|
|
359
|
-
"POST",
|
|
360
|
-
`/api/hub/entities/${input.entityId}/facets`,
|
|
361
|
-
{
|
|
362
|
-
userId,
|
|
363
|
-
profileSlug: input.profileSlug,
|
|
364
|
-
profileId: input.profileId,
|
|
365
|
-
workspaceId: input.workspaceId ?? this.workspaceId,
|
|
366
|
-
contextEntityId: input.contextEntityId,
|
|
367
|
-
status: input.status,
|
|
368
|
-
properties: input.properties,
|
|
369
|
-
reasoning: input.reasoning
|
|
370
|
-
}
|
|
371
|
-
);
|
|
372
|
-
}
|
|
373
|
-
/**
|
|
374
|
-
* Delete a relation by ID (get from getRelations()).
|
|
375
|
-
*/
|
|
376
|
-
async deleteRelation(relationId) {
|
|
377
|
-
const userId = await this.resolveUserId();
|
|
378
|
-
await this.request("DELETE", `/api/hub/relations/${relationId}`, {
|
|
379
|
-
userId
|
|
380
|
-
});
|
|
381
|
-
}
|
|
382
|
-
/**
|
|
383
|
-
* Traverse the knowledge graph from an entity using BFS.
|
|
384
|
-
* Returns nodes and edges up to maxDepth hops away.
|
|
385
|
-
* maxDepth: 1=direct neighbors, 2=neighborhood (recommended), 3=extended (expensive).
|
|
386
|
-
*
|
|
387
|
-
* @example
|
|
388
|
-
* const graph = await client.traverseGraph(projectId, { maxDepth: 2 });
|
|
389
|
-
* const tasks = graph.nodes.filter(n => n.profileSlug === "task");
|
|
390
|
-
*/
|
|
391
|
-
async traverseGraph(entityId, options) {
|
|
392
|
-
const userId = await this.resolveUserId();
|
|
393
|
-
const params = new URLSearchParams({
|
|
394
|
-
userId,
|
|
395
|
-
startEntityId: entityId,
|
|
396
|
-
maxDepth: String(options?.maxDepth ?? 2)
|
|
397
|
-
});
|
|
398
|
-
const wsId = options?.workspaceId ?? this.workspaceId;
|
|
399
|
-
if (wsId) params.set("workspaceId", wsId);
|
|
400
|
-
return this.request(
|
|
401
|
-
"GET",
|
|
402
|
-
`/api/hub/graph/traverse?${params}`
|
|
403
|
-
);
|
|
404
|
-
}
|
|
405
|
-
/**
|
|
406
|
-
* Unified view of everything connected to an entity across the local graph:
|
|
407
|
-
* 1. Graph relations — explicit rows in the relations table (both directions)
|
|
408
|
-
* 2. Structural links — inbound and outbound `entity_id` property edges
|
|
409
|
-
* 3. Channel and focus-session connections around this entity
|
|
410
|
-
*
|
|
411
|
-
* Prefer this over `getRelations()` / `traverseGraph()` when you want the complete
|
|
412
|
-
* picture — those only see the relations table and miss property-based links that
|
|
413
|
-
* haven't been synced (notably custom profiles without a `relationDefId` mapping).
|
|
414
|
-
*
|
|
415
|
-
* Each connection carries a `source` field so callers can filter by origin.
|
|
416
|
-
*
|
|
417
|
-
* @example
|
|
418
|
-
* const { connections } = await client.getConnections(entityId);
|
|
419
|
-
* const tasks = connections.filter(c => c.entity?.profileSlug === "task");
|
|
420
|
-
*/
|
|
421
|
-
async getConnections(entityId, options) {
|
|
422
|
-
const userId = await this.resolveUserId();
|
|
423
|
-
const wsId = options?.workspaceId ?? this.workspaceId;
|
|
424
|
-
const params = new URLSearchParams({ userId });
|
|
425
|
-
if (wsId) params.set("workspaceId", wsId);
|
|
426
|
-
if (options?.limit) params.set("limit", String(options.limit));
|
|
427
|
-
return this.request(
|
|
428
|
-
"GET",
|
|
429
|
-
`/api/hub/entities/${entityId}/connections?${params}`
|
|
430
|
-
);
|
|
431
|
-
}
|
|
432
|
-
// ─── Session orientation & profile discovery ─────────────────────────────
|
|
433
|
-
/**
|
|
434
|
-
* Canonical session bootstrap shared by the MCP, CLI, and external surfaces.
|
|
435
|
-
* It is deliberately a lens map, not a profile/schema dump; use discover()
|
|
436
|
-
* only for the selected profiles needed by the next action.
|
|
437
|
-
*/
|
|
438
|
-
async orient(options) {
|
|
439
|
-
const params = new URLSearchParams();
|
|
440
|
-
if (options?.detail) params.set("detail", options.detail);
|
|
441
|
-
if (options?.scope?.length) params.set("scope", options.scope.join(","));
|
|
442
|
-
if (options?.workspaceId) params.set("workspaceId", options.workspaceId);
|
|
443
|
-
if (options?.projectId) params.set("projectId", options.projectId);
|
|
444
|
-
const qs = params.toString() ? `?${params}` : "";
|
|
445
|
-
return this.request("GET", `/api/hub/orient${qs}`);
|
|
446
|
-
}
|
|
447
|
-
// ─── Profiles & Schema ────────────────────────────────────────────────────
|
|
448
|
-
/**
|
|
449
|
-
* List all entity profile types in the workspace.
|
|
450
|
-
* Always call before creating entities to discover what types are available.
|
|
451
|
-
* Returns system profiles (always present) + custom workspace profiles.
|
|
452
|
-
*/
|
|
453
|
-
async listProfiles(workspaceId, options) {
|
|
454
|
-
const userId = await this.resolveUserId();
|
|
455
|
-
const params = new URLSearchParams({ userId, workspaceId });
|
|
456
|
-
if (options?.detail) params.set("detail", options.detail);
|
|
457
|
-
const result = await this.request("GET", `/api/hub/profiles?${params}`);
|
|
458
|
-
return unwrapList(result);
|
|
459
|
-
}
|
|
460
|
-
/**
|
|
461
|
-
* List property definitions for a workspace, optionally filtered by profile.
|
|
462
|
-
*/
|
|
463
|
-
async listPropertyDefs(workspaceId, options) {
|
|
464
|
-
const userId = await this.resolveUserId();
|
|
465
|
-
const params = new URLSearchParams({ userId, workspaceId });
|
|
466
|
-
if (options?.profileSlug) params.set("profileId", options.profileSlug);
|
|
467
|
-
const result = await this.request("GET", `/api/hub/property-defs?${params}`);
|
|
468
|
-
return unwrapList(result);
|
|
469
|
-
}
|
|
470
|
-
/**
|
|
471
|
-
* Runtime discovery — profiles with property schemas + command tree.
|
|
472
|
-
*
|
|
473
|
-
* Call once per session at session start. Returns ground-truth profile
|
|
474
|
-
* schemas (including custom workspace profiles) and the canonical CLI
|
|
475
|
-
* command map. Replaces static skill file profile descriptions.
|
|
476
|
-
*/
|
|
477
|
-
async discover(options) {
|
|
478
|
-
const userId = await this.resolveUserId();
|
|
479
|
-
const normalized = typeof options === "string" ? { workspaceId: options } : options ?? {};
|
|
480
|
-
const params = new URLSearchParams({ userId });
|
|
481
|
-
if (normalized.workspaceId)
|
|
482
|
-
params.set("workspaceId", normalized.workspaceId);
|
|
483
|
-
if (normalized.summary !== void 0)
|
|
484
|
-
params.set("summary", String(normalized.summary));
|
|
485
|
-
if (normalized.profileSlugs?.length)
|
|
486
|
-
params.set("profileSlugs", normalized.profileSlugs.join(","));
|
|
487
|
-
return this.request(
|
|
488
|
-
"GET",
|
|
489
|
-
`/api/hub/discover?${params}`
|
|
490
|
-
);
|
|
491
|
-
}
|
|
492
|
-
// ─── Threads & Channels ───────────────────────────────────────────────────
|
|
493
|
-
/**
|
|
494
|
-
* List threads (channels) accessible to a user.
|
|
495
|
-
*/
|
|
496
|
-
async listThreads(userId, options) {
|
|
497
|
-
const wsId = options?.workspaceId ?? this.workspaceId;
|
|
498
|
-
const params = new URLSearchParams({ userId });
|
|
499
|
-
if (wsId) params.set("workspaceId", wsId);
|
|
500
|
-
if (options?.type) params.set("type", options.type);
|
|
501
|
-
const result = await this.request(
|
|
502
|
-
"GET",
|
|
503
|
-
`/api/hub/threads?${params}`
|
|
504
|
-
);
|
|
505
|
-
return unwrapList(result);
|
|
506
|
-
}
|
|
507
|
-
/**
|
|
508
|
-
* Get the user's personal channel — their private AI conversation thread.
|
|
509
|
-
* Use as default destination for messages and proactive posts.
|
|
510
|
-
*
|
|
511
|
-
* Note: The backend GET /channels/personal requires both userId and workspaceId.
|
|
512
|
-
*/
|
|
513
|
-
async getPersonalChannel(userId, workspaceId) {
|
|
514
|
-
const wsId = workspaceId ?? this.workspaceId;
|
|
515
|
-
if (!wsId)
|
|
516
|
-
throw new Error("workspaceId is required for getPersonalChannel");
|
|
517
|
-
const params = new URLSearchParams({ userId, workspaceId: wsId });
|
|
518
|
-
return this.request(
|
|
519
|
-
"GET",
|
|
520
|
-
`/api/hub/channels/personal?${params}`
|
|
521
|
-
);
|
|
522
|
-
}
|
|
523
|
-
/**
|
|
524
|
-
* Create a new thread. Pass entityId to auto-link on creation.
|
|
525
|
-
*
|
|
526
|
-
* Note: The backend POST /threads requires workspaceId in the body.
|
|
527
|
-
*/
|
|
528
|
-
async createThread(input) {
|
|
529
|
-
const userId = input.userId ?? await this.resolveUserId();
|
|
530
|
-
const wsId = input.workspaceId ?? this.workspaceId;
|
|
531
|
-
if (!wsId) throw new Error("workspaceId is required for createThread");
|
|
532
|
-
return this.request("POST", "/api/hub/threads", {
|
|
533
|
-
userId,
|
|
534
|
-
workspaceId: wsId,
|
|
535
|
-
title: input.name,
|
|
536
|
-
agentType: input.agentType,
|
|
537
|
-
contextObjectType: input.entityId ? "entity" : input.documentId ? "document" : void 0,
|
|
538
|
-
contextObjectId: input.entityId ?? input.documentId
|
|
539
|
-
});
|
|
540
|
-
}
|
|
541
|
-
/**
|
|
542
|
-
* Get full thread context: messages + all linked entities and documents.
|
|
543
|
-
* Call before sending a message to orient the AI with conversation history.
|
|
544
|
-
*/
|
|
545
|
-
async getThreadContext(threadId) {
|
|
546
|
-
return this.request(
|
|
547
|
-
"GET",
|
|
548
|
-
`/api/hub/threads/${threadId}/context`
|
|
549
|
-
);
|
|
550
|
-
}
|
|
551
|
-
/**
|
|
552
|
-
* Get messages in a thread.
|
|
553
|
-
*/
|
|
554
|
-
async getMessages(threadId, _options) {
|
|
555
|
-
const result = await this.request("GET", `/api/hub/threads/${threadId}/messages`);
|
|
556
|
-
return unwrapList(result);
|
|
557
|
-
}
|
|
558
|
-
/**
|
|
559
|
-
* Link an entity to a thread so it appears in thread context for AI.
|
|
560
|
-
*/
|
|
561
|
-
async linkEntityToThread(threadId, entityId) {
|
|
562
|
-
const userId = await this.resolveUserId();
|
|
563
|
-
await this.request(
|
|
564
|
-
"POST",
|
|
565
|
-
`/api/hub/threads/${threadId}/link-entity`,
|
|
566
|
-
{ userId, entityId }
|
|
567
|
-
);
|
|
568
|
-
}
|
|
569
|
-
/**
|
|
570
|
-
* Link a document to a thread.
|
|
571
|
-
*/
|
|
572
|
-
async linkDocumentToThread(threadId, documentId) {
|
|
573
|
-
const userId = await this.resolveUserId();
|
|
574
|
-
await this.request(
|
|
575
|
-
"POST",
|
|
576
|
-
`/api/hub/threads/${threadId}/link-document`,
|
|
577
|
-
{ userId, documentId }
|
|
578
|
-
);
|
|
579
|
-
}
|
|
580
|
-
/**
|
|
581
|
-
* Get research branches of a thread — parallel AI investigations.
|
|
582
|
-
*/
|
|
583
|
-
async getThreadBranches(threadId) {
|
|
584
|
-
const result = await this.request("GET", `/api/hub/threads/${threadId}/branches`);
|
|
585
|
-
return result.branches ?? [];
|
|
586
|
-
}
|
|
587
|
-
// ─── Memory ───────────────────────────────────────────────────────────────
|
|
588
|
-
async storeMemory(input) {
|
|
589
|
-
const userId = await this.resolveUserId();
|
|
590
|
-
const fact = input.context && String(input.context).trim().length > 0 ? `[${String(input.context).trim()}] ${input.fact}` : input.fact;
|
|
591
|
-
return this.request("POST", "/api/hub/memory", {
|
|
592
|
-
userId,
|
|
593
|
-
fact
|
|
594
|
-
});
|
|
595
|
-
}
|
|
596
|
-
async recallMemory(query, options) {
|
|
597
|
-
const wsId = options?.workspaceId ?? this.workspaceId;
|
|
598
|
-
const userId = await this.resolveUserId();
|
|
599
|
-
const params = new URLSearchParams({
|
|
600
|
-
userId,
|
|
601
|
-
query,
|
|
602
|
-
limit: String(options?.limit ?? 10)
|
|
603
|
-
});
|
|
604
|
-
if (wsId) params.set("workspaceId", wsId);
|
|
605
|
-
const result = await this.request("GET", `/api/hub/memory?${params}`);
|
|
606
|
-
return unwrapList(result);
|
|
607
|
-
}
|
|
608
|
-
/**
|
|
609
|
-
* Delete a stored memory fact by ID.
|
|
610
|
-
*/
|
|
611
|
-
async deleteMemory(memoryId) {
|
|
612
|
-
const userId = await this.resolveUserId();
|
|
613
|
-
const params = new URLSearchParams({ userId });
|
|
614
|
-
await this.request(
|
|
615
|
-
"DELETE",
|
|
616
|
-
`/api/hub/memory/${memoryId}?${params}`
|
|
617
|
-
);
|
|
618
|
-
}
|
|
619
|
-
// ─── Channels (Hub REST: channels are listed via GET /threads) ────────────
|
|
620
|
-
async getChannels(options) {
|
|
621
|
-
const wsId = options?.workspaceId ?? this.workspaceId;
|
|
622
|
-
const userId = await this.resolveUserId();
|
|
623
|
-
const params = new URLSearchParams({ userId });
|
|
624
|
-
if (wsId) params.set("workspaceId", wsId);
|
|
625
|
-
const result = await this.request("GET", `/api/hub/threads?${params}`);
|
|
626
|
-
return unwrapList(result);
|
|
627
|
-
}
|
|
628
|
-
async sendToChannel(input) {
|
|
629
|
-
const userId = input.userId ?? await this.resolveUserId();
|
|
630
|
-
return this.request(
|
|
631
|
-
"POST",
|
|
632
|
-
`/api/hub/threads/${input.channelId}/messages`,
|
|
633
|
-
{
|
|
634
|
-
role: input.role ?? "user",
|
|
635
|
-
content: input.content,
|
|
636
|
-
userId,
|
|
637
|
-
...input.autoRespond !== void 0 ? { autoRespond: input.autoRespond } : {}
|
|
638
|
-
}
|
|
639
|
-
);
|
|
640
|
-
}
|
|
641
|
-
// ─── Proposals ────────────────────────────────────────────────────────────
|
|
642
|
-
/**
|
|
643
|
-
* List proposals — pending AI writes awaiting human review.
|
|
644
|
-
* Filter by status: "pending" (needs review), "approved", "rejected".
|
|
645
|
-
*/
|
|
646
|
-
async listProposals(options) {
|
|
647
|
-
const userId = await this.resolveUserId();
|
|
648
|
-
const params = new URLSearchParams({ userId });
|
|
649
|
-
if (options?.scope !== "all") {
|
|
650
|
-
const wsId = options?.workspaceId ?? this.workspaceId;
|
|
651
|
-
if (wsId) params.set("workspaceId", wsId);
|
|
652
|
-
}
|
|
653
|
-
if (options?.status) params.set("status", options.status);
|
|
654
|
-
if (options?.limit) params.set("limit", String(options.limit));
|
|
655
|
-
const result = await this.request("GET", `/api/hub/proposals?${params}`);
|
|
656
|
-
return unwrapList(result);
|
|
657
|
-
}
|
|
658
|
-
/**
|
|
659
|
-
* Approve or reject a proposal.
|
|
660
|
-
*
|
|
661
|
-
* Note: The backend PATCH /proposals/:id is an AI-revision endpoint that updates
|
|
662
|
-
* the proposal data/summary, not a review (approve/reject) endpoint.
|
|
663
|
-
* Use this to update proposal data before human review.
|
|
664
|
-
*/
|
|
665
|
-
async reviewProposal(proposalId, decision, reason) {
|
|
666
|
-
return this.request(
|
|
667
|
-
"PATCH",
|
|
668
|
-
`/api/hub/proposals/${proposalId}`,
|
|
669
|
-
{
|
|
670
|
-
data: { status: decision },
|
|
671
|
-
summary: reason
|
|
672
|
-
}
|
|
673
|
-
);
|
|
674
|
-
}
|
|
675
|
-
// ─── Views ────────────────────────────────────────────────────────────────
|
|
676
|
-
/**
|
|
677
|
-
* List data views in a workspace.
|
|
678
|
-
*/
|
|
679
|
-
async listViews(workspaceId, options) {
|
|
680
|
-
const userId = await this.resolveUserId();
|
|
681
|
-
const params = new URLSearchParams({ userId, workspaceId });
|
|
682
|
-
if (options?.profileSlug) params.set("profileId", options.profileSlug);
|
|
683
|
-
const result = await this.request(
|
|
684
|
-
"GET",
|
|
685
|
-
`/api/hub/views?${params}`
|
|
686
|
-
);
|
|
687
|
-
return unwrapList(result);
|
|
688
|
-
}
|
|
689
|
-
/**
|
|
690
|
-
* Create a new view. Goes through governance.
|
|
691
|
-
*/
|
|
692
|
-
async createView(input) {
|
|
693
|
-
const userId = input.userId ?? await this.resolveUserId();
|
|
694
|
-
return this.request("POST", "/api/hub/views", {
|
|
695
|
-
userId,
|
|
696
|
-
workspaceId: input.workspaceId ?? this.workspaceId,
|
|
697
|
-
name: input.name,
|
|
698
|
-
type: input.type,
|
|
699
|
-
profileId: input.profileSlug,
|
|
700
|
-
config: input.config,
|
|
701
|
-
metadata: input.metadata,
|
|
702
|
-
agentUserId: input.agentUserId,
|
|
703
|
-
reasoning: input.reasoning,
|
|
704
|
-
sourceMessageId: input.sourceMessageId
|
|
705
|
-
});
|
|
706
|
-
}
|
|
707
|
-
/** Update a view through the existing governed Hub route. */
|
|
708
|
-
async updateView(viewId, input) {
|
|
709
|
-
const userId = input.userId ?? await this.resolveUserId();
|
|
710
|
-
return this.request(
|
|
711
|
-
"PATCH",
|
|
712
|
-
`/api/hub/views/${viewId}`,
|
|
713
|
-
{
|
|
714
|
-
userId,
|
|
715
|
-
workspaceId: input.workspaceId ?? this.workspaceId,
|
|
716
|
-
name: input.name,
|
|
717
|
-
config: input.config,
|
|
718
|
-
metadata: input.metadata,
|
|
719
|
-
agentUserId: input.agentUserId,
|
|
720
|
-
reasoning: input.reasoning,
|
|
721
|
-
sourceMessageId: input.sourceMessageId
|
|
722
|
-
}
|
|
723
|
-
);
|
|
724
|
-
}
|
|
725
|
-
/** Replace a bento view's widget arrangement through the existing Hub route. */
|
|
726
|
-
async arrangeBentoView(viewId, input) {
|
|
727
|
-
const userId = input.userId ?? await this.resolveUserId();
|
|
728
|
-
const workspaceId = input.workspaceId ?? this.workspaceId;
|
|
729
|
-
if (!workspaceId) {
|
|
730
|
-
throw new Error("workspaceId is required for arrangeBentoView");
|
|
731
|
-
}
|
|
732
|
-
return this.request(
|
|
733
|
-
"POST",
|
|
734
|
-
`/api/hub/views/${viewId}/arrange`,
|
|
735
|
-
{
|
|
736
|
-
userId,
|
|
737
|
-
workspaceId,
|
|
738
|
-
widgets: input.widgets,
|
|
739
|
-
agentUserId: input.agentUserId,
|
|
740
|
-
reasoning: input.reasoning,
|
|
741
|
-
sourceMessageId: input.sourceMessageId
|
|
742
|
-
}
|
|
743
|
-
);
|
|
744
|
-
}
|
|
745
|
-
// ─── Documents ────────────────────────────────────────────────────────────
|
|
746
|
-
/**
|
|
747
|
-
* Get a document by ID with full markdown content.
|
|
748
|
-
*/
|
|
749
|
-
async getDocument(documentId) {
|
|
750
|
-
const userId = await this.resolveUserId();
|
|
751
|
-
const params = new URLSearchParams({ userId });
|
|
752
|
-
const result = await this.request(
|
|
753
|
-
"GET",
|
|
754
|
-
`/api/hub/documents/${documentId}?${params}`
|
|
755
|
-
);
|
|
756
|
-
return "document" in result ? result.document : result;
|
|
757
|
-
}
|
|
758
|
-
/**
|
|
759
|
-
* Create a document. Use for long-form content: meeting notes, research, writeups.
|
|
760
|
-
* Goes through governance.
|
|
761
|
-
*/
|
|
762
|
-
async createDocument(input) {
|
|
763
|
-
const userId = await this.resolveUserId();
|
|
764
|
-
return this.request("POST", "/api/hub/documents", {
|
|
765
|
-
userId,
|
|
766
|
-
workspaceId: input.workspaceId ?? this.workspaceId,
|
|
767
|
-
title: input.title,
|
|
768
|
-
content: input.content ?? "",
|
|
769
|
-
type: input.type,
|
|
770
|
-
reasoning: input.reasoning,
|
|
771
|
-
agentUserId: input.agentUserId,
|
|
772
|
-
sourceMessageId: input.sourceMessageId,
|
|
773
|
-
sessionId: input.sessionId
|
|
774
|
-
});
|
|
775
|
-
}
|
|
776
|
-
/** Propose a full document-content replacement through the governed Hub route. */
|
|
777
|
-
async updateDocument(documentId, input) {
|
|
778
|
-
const userId = await this.resolveUserId();
|
|
779
|
-
return this.request(
|
|
780
|
-
"PATCH",
|
|
781
|
-
`/api/hub/documents/${documentId}`,
|
|
782
|
-
{
|
|
783
|
-
userId,
|
|
784
|
-
content: input.content,
|
|
785
|
-
title: input.title,
|
|
786
|
-
agentUserId: input.agentUserId,
|
|
787
|
-
sourceMessageId: input.sourceMessageId,
|
|
788
|
-
sessionId: input.sessionId
|
|
789
|
-
}
|
|
790
|
-
);
|
|
791
|
-
}
|
|
792
|
-
/** Submit a structured, reviewable document-edit proposal. */
|
|
793
|
-
async createDocumentProposal(input) {
|
|
794
|
-
const userId = await this.resolveUserId();
|
|
795
|
-
return this.request(
|
|
796
|
-
"POST",
|
|
797
|
-
"/api/hub/documents/proposals",
|
|
798
|
-
{
|
|
799
|
-
userId,
|
|
800
|
-
...input
|
|
801
|
-
}
|
|
802
|
-
);
|
|
803
|
-
}
|
|
804
|
-
// ─── Capabilities & teaching substrate ───────────────────────────────────
|
|
805
|
-
/** Flat capability read-model. Prefer getCapabilityCatalog() for presentation. */
|
|
806
|
-
async listCapabilities(options) {
|
|
807
|
-
const workspaceId = options?.workspaceId ?? this.workspaceId;
|
|
808
|
-
if (!workspaceId) {
|
|
809
|
-
throw new Error("workspaceId is required for listCapabilities");
|
|
810
|
-
}
|
|
811
|
-
const params = new URLSearchParams({ workspaceId });
|
|
812
|
-
const result = await this.request(
|
|
813
|
-
"GET",
|
|
814
|
-
`/api/hub/capabilities?${params}`
|
|
815
|
-
);
|
|
816
|
-
return result.capabilities;
|
|
817
|
-
}
|
|
818
|
-
/** Status-computed, pack-grouped capability catalog for every external surface. */
|
|
819
|
-
async getCapabilityCatalog(options) {
|
|
820
|
-
const workspaceId = options?.workspaceId ?? this.workspaceId;
|
|
821
|
-
if (!workspaceId) {
|
|
822
|
-
throw new Error("workspaceId is required for getCapabilityCatalog");
|
|
823
|
-
}
|
|
824
|
-
const params = new URLSearchParams({ workspaceId });
|
|
825
|
-
if (options?.extraKey) params.set("extraKey", options.extraKey);
|
|
826
|
-
return this.request(
|
|
827
|
-
"GET",
|
|
828
|
-
`/api/hub/capabilities/catalog?${params}`
|
|
829
|
-
);
|
|
830
|
-
}
|
|
831
|
-
/** List only approved, connected actions that this client can execute now. */
|
|
832
|
-
async listRunnableCapabilityActions(options) {
|
|
833
|
-
const workspaceId = options?.workspaceId ?? this.workspaceId;
|
|
834
|
-
if (!workspaceId) {
|
|
835
|
-
throw new Error(
|
|
836
|
-
"workspaceId is required for listRunnableCapabilityActions"
|
|
837
|
-
);
|
|
838
|
-
}
|
|
839
|
-
const params = new URLSearchParams({ workspaceId });
|
|
840
|
-
if (options?.query) params.set("query", options.query);
|
|
841
|
-
if (options?.kind) params.set("kind", options.kind);
|
|
842
|
-
if (options?.limit !== void 0)
|
|
843
|
-
params.set("limit", String(options.limit));
|
|
844
|
-
return this.request(
|
|
845
|
-
"GET",
|
|
846
|
-
`/api/hub/capabilities/actions?${params}`
|
|
847
|
-
);
|
|
848
|
-
}
|
|
849
|
-
/** Run one registered capability through the shared governance gate. */
|
|
850
|
-
async executeCapability(input) {
|
|
851
|
-
return this.request(
|
|
852
|
-
"POST",
|
|
853
|
-
"/api/hub/capabilities/execute",
|
|
854
|
-
{
|
|
855
|
-
...input,
|
|
856
|
-
// Graph proposals follow the same explicit-scope rule as direct writes.
|
|
857
|
-
...input.workspaceId ? { workspaceId: input.workspaceId } : {}
|
|
858
|
-
}
|
|
859
|
-
);
|
|
860
|
-
}
|
|
861
|
-
/** List the compact system teaching catalog, or search the available skill index. */
|
|
862
|
-
async listAgentSkills(options) {
|
|
863
|
-
const params = new URLSearchParams();
|
|
864
|
-
if (options?.topic) params.set("topic", options.topic);
|
|
865
|
-
if (options?.query) params.set("q", options.query);
|
|
866
|
-
if (options?.tag) params.set("tag", options.tag);
|
|
867
|
-
if (options?.system !== void 0)
|
|
868
|
-
params.set("system", String(options.system));
|
|
869
|
-
const workspaceId = options?.workspaceId ?? this.workspaceId;
|
|
870
|
-
if (workspaceId) params.set("workspaceId", workspaceId);
|
|
871
|
-
if (options?.limit !== void 0)
|
|
872
|
-
params.set("limit", String(options.limit));
|
|
873
|
-
if (options?.offset !== void 0)
|
|
874
|
-
params.set("offset", String(options.offset));
|
|
875
|
-
const qs = params.toString() ? `?${params}` : "";
|
|
876
|
-
return this.request(
|
|
877
|
-
"GET",
|
|
878
|
-
`/api/hub/agent-skills${qs}`
|
|
879
|
-
);
|
|
880
|
-
}
|
|
881
|
-
/** Load one skill body only when it is relevant to the agent's next action. */
|
|
882
|
-
async getAgentSkillBySlug(slug, options) {
|
|
883
|
-
const workspaceId = options?.workspaceId ?? this.workspaceId;
|
|
884
|
-
const qs = workspaceId ? `?${new URLSearchParams({ workspaceId })}` : "";
|
|
885
|
-
return this.request(
|
|
886
|
-
"GET",
|
|
887
|
-
`/api/hub/agent-skills/by-slug/${encodeURIComponent(slug)}${qs}`
|
|
888
|
-
);
|
|
889
|
-
}
|
|
890
|
-
/** Compose just-in-time teaching and governance briefs for selected tools. */
|
|
891
|
-
async getCapabilityBriefs(input) {
|
|
892
|
-
if (input.tools.length === 0) return { briefs: {} };
|
|
893
|
-
const workspaceId = input.workspaceId ?? this.workspaceId;
|
|
894
|
-
const params = new URLSearchParams({ tools: input.tools.join(",") });
|
|
895
|
-
if (workspaceId) params.set("workspaceId", workspaceId);
|
|
896
|
-
if (input.door) params.set("door", input.door);
|
|
897
|
-
return this.request(
|
|
898
|
-
"GET",
|
|
899
|
-
`/api/hub/briefs?${params}`
|
|
900
|
-
);
|
|
901
|
-
}
|
|
902
|
-
// ─── Commands & Agents ────────────────────────────────────────────────────
|
|
903
|
-
/**
|
|
904
|
-
* List available commands (automation shortcuts) in the workspace.
|
|
905
|
-
*/
|
|
906
|
-
async listCommands(workspaceId) {
|
|
907
|
-
const wsId = workspaceId ?? this.workspaceId;
|
|
908
|
-
const params = new URLSearchParams();
|
|
909
|
-
if (wsId) params.set("workspaceId", wsId);
|
|
910
|
-
const qs = params.toString() ? `?${params}` : "";
|
|
911
|
-
const result = await this.request("GET", `/api/hub/commands${qs}`);
|
|
912
|
-
return unwrapList(result);
|
|
913
|
-
}
|
|
914
|
-
/**
|
|
915
|
-
* Execute a command by slug.
|
|
916
|
-
*
|
|
917
|
-
* Note: The backend POST /commands/execute uses a `command` field (the shell command
|
|
918
|
-
* string) and `userId`, not a `slug`. This maps ExecuteCommandInput.slug to `command`.
|
|
919
|
-
*/
|
|
920
|
-
async executeCommand(input) {
|
|
921
|
-
const userId = input.userId ?? await this.resolveUserId();
|
|
922
|
-
return this.request(
|
|
923
|
-
"POST",
|
|
924
|
-
"/api/hub/commands/execute",
|
|
925
|
-
{
|
|
926
|
-
command: input.slug,
|
|
927
|
-
userId,
|
|
928
|
-
workspaceId: input.workspaceId ?? this.workspaceId,
|
|
929
|
-
...input.parameters ? { parameters: input.parameters } : {}
|
|
930
|
-
}
|
|
931
|
-
);
|
|
932
|
-
}
|
|
933
|
-
/**
|
|
934
|
-
* List agent users provisioned in the workspace.
|
|
935
|
-
*/
|
|
936
|
-
async listAgentUsers(workspaceId) {
|
|
937
|
-
const wsId = workspaceId ?? this.workspaceId;
|
|
938
|
-
const params = new URLSearchParams();
|
|
939
|
-
if (wsId) params.set("workspaceId", wsId);
|
|
940
|
-
const qs = params.toString() ? `?${params}` : "";
|
|
941
|
-
const result = await this.request("GET", `/api/hub/agent-users${qs}`);
|
|
942
|
-
return unwrapList(result);
|
|
943
|
-
}
|
|
944
|
-
// ─── Proactive posting ────────────────────────────────────────────────────
|
|
945
|
-
/**
|
|
946
|
-
* Post a proactive message to the user's personal channel.
|
|
947
|
-
* For AI-initiated insights and summaries. Rate-limited: 3/hour, 10/day.
|
|
948
|
-
* proactiveType must be one of: insight, suggestion, alert, nudge,
|
|
949
|
-
* morning_briefing, weekly_digest, health_check.
|
|
950
|
-
*/
|
|
951
|
-
async postProactive(userId, content, options) {
|
|
952
|
-
const wsId = options?.workspaceId ?? this.workspaceId;
|
|
953
|
-
if (!wsId) throw new Error("workspaceId is required for postProactive");
|
|
954
|
-
return this.request("POST", "/api/hub/proactive/post", {
|
|
955
|
-
userId,
|
|
956
|
-
workspaceId: wsId,
|
|
957
|
-
content,
|
|
958
|
-
proactiveType: options?.type ?? "insight"
|
|
959
|
-
});
|
|
960
|
-
}
|
|
961
|
-
// ─── Capture pipeline ─────────────────────────────────────────────────────
|
|
962
|
-
async captureStructure(input) {
|
|
963
|
-
const userId = await this.resolveUserId();
|
|
964
|
-
return this.request(
|
|
965
|
-
"POST",
|
|
966
|
-
"/api/hub/capture/structure",
|
|
967
|
-
{
|
|
968
|
-
userId,
|
|
969
|
-
text: input.text,
|
|
970
|
-
url: input.url,
|
|
971
|
-
workspaceId: input.workspaceId ?? this.workspaceId,
|
|
972
|
-
previousEntities: input.previousEntities
|
|
973
|
-
}
|
|
974
|
-
);
|
|
975
|
-
}
|
|
976
|
-
async captureExecute(input) {
|
|
977
|
-
const userId = await this.resolveUserId();
|
|
978
|
-
return this.request(
|
|
979
|
-
"POST",
|
|
980
|
-
"/api/hub/capture/execute",
|
|
981
|
-
{
|
|
982
|
-
userId,
|
|
983
|
-
entities: input.entities,
|
|
984
|
-
relations: input.relations ?? [],
|
|
985
|
-
workspaceId: input.workspaceId ?? this.workspaceId,
|
|
986
|
-
// Keep this exact routing bundle in lockstep with CaptureExecuteInput
|
|
987
|
-
// and the REST codec. Dropping it here silently made CLI/Raycast capture
|
|
988
|
-
// behave differently from MCP despite all three using the same backend.
|
|
989
|
-
projectId: input.projectId,
|
|
990
|
-
targetWorkspaceId: input.targetWorkspaceId,
|
|
991
|
-
keepRaw: input.keepRaw,
|
|
992
|
-
file: input.file,
|
|
993
|
-
idempotencyKey: input.idempotencyKey,
|
|
994
|
-
workspaceRouting: input.workspaceRouting,
|
|
995
|
-
aiWorkspaceId: input.aiWorkspaceId,
|
|
996
|
-
aiWorkspaceConfidence: input.aiWorkspaceConfidence,
|
|
997
|
-
aiWorkspaceReason: input.aiWorkspaceReason
|
|
998
|
-
}
|
|
999
|
-
);
|
|
1000
|
-
}
|
|
1001
|
-
/**
|
|
1002
|
-
* Submit a designed entity graph as ONE reviewable composite proposal.
|
|
1003
|
-
*
|
|
1004
|
-
* This is intentionally distinct from captureExecute(): execute materializes
|
|
1005
|
-
* a prior structure result immediately, while this door keeps an autonomous
|
|
1006
|
-
* graph plan reviewable and applies entities, relations, and bindings together
|
|
1007
|
-
* only after approval.
|
|
1008
|
-
*/
|
|
1009
|
-
async submitCaptureGraph(input) {
|
|
1010
|
-
const { workspaceId, relations, bindings, ...body } = input;
|
|
1011
|
-
return this.request(
|
|
1012
|
-
"POST",
|
|
1013
|
-
"/api/hub/capture/graph",
|
|
1014
|
-
{
|
|
1015
|
-
...body,
|
|
1016
|
-
// Proposal audience and schema overlays are explicit write choices.
|
|
1017
|
-
...workspaceId ? { workspaceId } : {},
|
|
1018
|
-
relations: relations ?? [],
|
|
1019
|
-
bindings: bindings ?? []
|
|
1020
|
-
}
|
|
1021
|
-
);
|
|
1022
|
-
}
|
|
1023
|
-
// ─── Recall: the one door ──────────────────────────────────────────────────
|
|
1024
|
-
/**
|
|
1025
|
-
* `ask` — the unified recall verb. Routes a natural-language question across
|
|
1026
|
-
* all knowledge substrates (semantic entities, procedural runbooks, episodic
|
|
1027
|
-
* facts) server-side and returns ONE provenance-tagged answer. The canonical
|
|
1028
|
-
* recall door — prefer it over the fragmented searchEntities / recallMemory.
|
|
1029
|
-
* The server builds the profile catalog from the caller's workspace; the
|
|
1030
|
-
* client only sends the query (+ optional scope).
|
|
1031
|
-
*/
|
|
1032
|
-
async ask(input) {
|
|
1033
|
-
return this.request("POST", "/api/hub/knowledge/ask", {
|
|
1034
|
-
query: input.query,
|
|
1035
|
-
workspaceId: input.workspaceId ?? this.workspaceId,
|
|
1036
|
-
limit: input.limit,
|
|
1037
|
-
parseOnly: input.parseOnly
|
|
1038
|
-
});
|
|
1039
|
-
}
|
|
1040
|
-
// ─── Automations ───────────────────────────────────────────────────────────
|
|
1041
|
-
/**
|
|
1042
|
-
* List automations for the current user, optionally filtered by workspace and status.
|
|
1043
|
-
*/
|
|
1044
|
-
async listAutomations(options) {
|
|
1045
|
-
const userId = await this.resolveUserId();
|
|
1046
|
-
const wsId = options?.workspaceId ?? this.workspaceId;
|
|
1047
|
-
const params = new URLSearchParams({ userId });
|
|
1048
|
-
if (wsId) params.set("workspaceId", wsId);
|
|
1049
|
-
if (options?.status) params.set("status", options.status);
|
|
1050
|
-
if (options?.limit) params.set("limit", String(options.limit));
|
|
1051
|
-
const result = await this.request("GET", `/api/hub/automations?${params}`);
|
|
1052
|
-
return unwrapList(result);
|
|
1053
|
-
}
|
|
1054
|
-
/**
|
|
1055
|
-
* Get a single automation by ID.
|
|
1056
|
-
*/
|
|
1057
|
-
async getAutomation(automationId, options) {
|
|
1058
|
-
const userId = await this.resolveUserId();
|
|
1059
|
-
const wsId = options?.workspaceId ?? this.workspaceId;
|
|
1060
|
-
const params = new URLSearchParams({ userId });
|
|
1061
|
-
if (wsId) params.set("workspaceId", wsId);
|
|
1062
|
-
return this.request(
|
|
1063
|
-
"GET",
|
|
1064
|
-
`/api/hub/automations/${automationId}?${params}`
|
|
1065
|
-
);
|
|
1066
|
-
}
|
|
1067
|
-
/**
|
|
1068
|
-
* Create an automation. Defaults to status=draft.
|
|
1069
|
-
* Use activateAutomation() to enable it.
|
|
1070
|
-
*/
|
|
1071
|
-
async createAutomation(input) {
|
|
1072
|
-
const userId = input.userId ?? await this.resolveUserId();
|
|
1073
|
-
const wsId = input.workspaceId ?? this.workspaceId;
|
|
1074
|
-
return this.request("POST", "/api/hub/automations/create", {
|
|
1075
|
-
...input,
|
|
1076
|
-
userId,
|
|
1077
|
-
workspaceId: wsId ?? null
|
|
1078
|
-
});
|
|
1079
|
-
}
|
|
1080
|
-
/**
|
|
1081
|
-
* Update an automation's definition or metadata.
|
|
1082
|
-
*/
|
|
1083
|
-
async updateAutomation(automationId, input) {
|
|
1084
|
-
const userId = input.userId ?? await this.resolveUserId();
|
|
1085
|
-
const wsId = input.workspaceId ?? this.workspaceId;
|
|
1086
|
-
if (!wsId) throw new Error("workspaceId is required for updateAutomation");
|
|
1087
|
-
return this.request(
|
|
1088
|
-
"PATCH",
|
|
1089
|
-
`/api/hub/automations/${automationId}`,
|
|
1090
|
-
{ ...input, userId, workspaceId: wsId }
|
|
1091
|
-
);
|
|
1092
|
-
}
|
|
1093
|
-
/**
|
|
1094
|
-
* Manually trigger an automation once with an optional payload.
|
|
1095
|
-
* Bypasses the automation's normal trigger config.
|
|
1096
|
-
*/
|
|
1097
|
-
async triggerAutomation(automationId, options) {
|
|
1098
|
-
const userId = await this.resolveUserId();
|
|
1099
|
-
const wsId = options?.workspaceId ?? this.workspaceId;
|
|
1100
|
-
return this.request(
|
|
1101
|
-
"POST",
|
|
1102
|
-
`/api/hub/automations/${automationId}/trigger`,
|
|
1103
|
-
{ userId, workspaceId: wsId ?? null, payload: options?.payload }
|
|
1104
|
-
);
|
|
1105
|
-
}
|
|
1106
|
-
/**
|
|
1107
|
-
* Activate a draft or paused automation (sets status=active).
|
|
1108
|
-
*/
|
|
1109
|
-
async activateAutomation(automationId, options) {
|
|
1110
|
-
const userId = await this.resolveUserId();
|
|
1111
|
-
const wsId = options?.workspaceId ?? this.workspaceId;
|
|
1112
|
-
if (!wsId)
|
|
1113
|
-
throw new Error("workspaceId is required for activateAutomation");
|
|
1114
|
-
return this.request(
|
|
1115
|
-
"POST",
|
|
1116
|
-
`/api/hub/automations/${automationId}/activate`,
|
|
1117
|
-
{ userId, workspaceId: wsId }
|
|
1118
|
-
);
|
|
1119
|
-
}
|
|
1120
|
-
/**
|
|
1121
|
-
* Pause an active automation (sets status=paused).
|
|
1122
|
-
*/
|
|
1123
|
-
async pauseAutomation(automationId, options) {
|
|
1124
|
-
const userId = await this.resolveUserId();
|
|
1125
|
-
const wsId = options?.workspaceId ?? this.workspaceId;
|
|
1126
|
-
if (!wsId) throw new Error("workspaceId is required for pauseAutomation");
|
|
1127
|
-
return this.request(
|
|
1128
|
-
"POST",
|
|
1129
|
-
`/api/hub/automations/${automationId}/pause`,
|
|
1130
|
-
{ userId, workspaceId: wsId }
|
|
1131
|
-
);
|
|
1132
|
-
}
|
|
1133
|
-
// ─── Subscriptions / Reactions (Pulse) ────────────────────────────────────
|
|
1134
|
-
/**
|
|
1135
|
-
* List the user-wide Pulse feed — the timestamp-sorted union of reactive events.
|
|
1136
|
-
* Call getSubscriptionFanout() on an individual event for its dense reactions[].
|
|
1137
|
-
*/
|
|
1138
|
-
async listSubscriptions(options) {
|
|
1139
|
-
const wsId = options?.workspaceId ?? this.workspaceId;
|
|
1140
|
-
const params = new URLSearchParams();
|
|
1141
|
-
if (wsId) params.set("workspaceId", wsId);
|
|
1142
|
-
if (options?.kind) params.set("kind", options.kind);
|
|
1143
|
-
if (options?.eventType) params.set("eventType", options.eventType);
|
|
1144
|
-
if (options?.lens) params.set("lens", options.lens);
|
|
1145
|
-
if (options?.limit) params.set("limit", String(options.limit));
|
|
1146
|
-
const qs = params.toString() ? `?${params}` : "";
|
|
1147
|
-
const result = await this.request("GET", `/api/hub/subscriptions${qs}`);
|
|
1148
|
-
return unwrapList(result);
|
|
1149
|
-
}
|
|
1150
|
-
/**
|
|
1151
|
-
* Get the reaction fan-out for a single event — full reactions[] populated.
|
|
1152
|
-
*/
|
|
1153
|
-
async getSubscriptionFanout(eventId, options) {
|
|
1154
|
-
const params = new URLSearchParams();
|
|
1155
|
-
if (options?.lens) params.set("lens", options.lens);
|
|
1156
|
-
const qs = params.toString() ? `?${params}` : "";
|
|
1157
|
-
return this.request(
|
|
1158
|
-
"GET",
|
|
1159
|
-
`/api/hub/subscriptions/${eventId}/fanout${qs}`
|
|
1160
|
-
);
|
|
1161
|
-
}
|
|
1162
|
-
// ─── Notifications ─────────────────────────────────────────────────────────
|
|
1163
|
-
/**
|
|
1164
|
-
* Persist a notification and emit notification:new to the frontend.
|
|
1165
|
-
* Use for IS-originated events (skill.triggered, agent actions, etc.).
|
|
1166
|
-
* Backend-originated notifications (vault, proposals) use NotificationService directly.
|
|
1167
|
-
*/
|
|
1168
|
-
async createNotification(input) {
|
|
1169
|
-
return this.request(
|
|
1170
|
-
"POST",
|
|
1171
|
-
"/api/hub/notifications",
|
|
1172
|
-
input
|
|
1173
|
-
);
|
|
1174
|
-
}
|
|
1175
|
-
// ─── Webhooks ──────────────────────────────────────────────────────────────
|
|
1176
|
-
/**
|
|
1177
|
-
* List delivery log for a webhook subscription.
|
|
1178
|
-
* Powers the Reactions Health tab and replay flows.
|
|
1179
|
-
*/
|
|
1180
|
-
async getWebhookDeliveries(subscriptionId, options) {
|
|
1181
|
-
const params = new URLSearchParams();
|
|
1182
|
-
if (options?.limit) params.set("limit", String(options.limit));
|
|
1183
|
-
const qs = params.toString() ? `?${params}` : "";
|
|
1184
|
-
const result = await this.request("GET", `/api/hub/webhooks/${subscriptionId}/deliveries${qs}`);
|
|
1185
|
-
return unwrapList(result);
|
|
1186
|
-
}
|
|
1187
|
-
};
|
|
1188
|
-
|
|
1189
|
-
// src/setup.ts
|
|
1190
|
-
function normalizeUrl2(url) {
|
|
1191
|
-
return url.replace(/\/$/, "");
|
|
1192
|
-
}
|
|
1193
|
-
function assertValidPodUrl(url, opts = {}) {
|
|
1194
|
-
let parsed;
|
|
1195
|
-
try {
|
|
1196
|
-
parsed = new URL(url);
|
|
1197
|
-
} catch {
|
|
1198
|
-
throw new HubApiError(`Invalid pod URL: ${url}`, 0, {
|
|
1199
|
-
code: "INVALID_POD_URL"
|
|
1200
|
-
});
|
|
1201
|
-
}
|
|
1202
|
-
if (parsed.username || parsed.password) {
|
|
1203
|
-
throw new HubApiError("Pod URL must not contain embedded credentials", 0, {
|
|
1204
|
-
code: "INVALID_POD_URL"
|
|
1205
|
-
});
|
|
1206
|
-
}
|
|
1207
|
-
const isHttps = parsed.protocol === "https:";
|
|
1208
|
-
const isHttp = parsed.protocol === "http:";
|
|
1209
|
-
if (!isHttps && !(isHttp && opts.allowHttp)) {
|
|
1210
|
-
throw new HubApiError(
|
|
1211
|
-
`Pod URL must use https:// (got ${parsed.protocol}//)`,
|
|
1212
|
-
0,
|
|
1213
|
-
{ code: "INSECURE_POD_URL" }
|
|
1214
|
-
);
|
|
1215
|
-
}
|
|
1216
|
-
}
|
|
1217
|
-
async function checkPodHealth(podUrl) {
|
|
1218
|
-
const url = normalizeUrl2(podUrl);
|
|
1219
|
-
const status = { url, healthy: false };
|
|
1220
|
-
try {
|
|
1221
|
-
const res = await fetch(`${url}/health`, {
|
|
1222
|
-
signal: AbortSignal.timeout(5e3)
|
|
1223
|
-
});
|
|
1224
|
-
if (res.ok) {
|
|
1225
|
-
status.healthy = true;
|
|
1226
|
-
const data = await res.json();
|
|
1227
|
-
status.version = data.version;
|
|
1228
|
-
}
|
|
1229
|
-
} catch {
|
|
1230
|
-
}
|
|
1231
|
-
return status;
|
|
1232
|
-
}
|
|
1233
|
-
async function setupAgent(podUrl, provisioningToken, agentType, opts = {}) {
|
|
1234
|
-
assertValidPodUrl(podUrl, { allowHttp: opts.allowHttp });
|
|
1235
|
-
const url = normalizeUrl2(podUrl);
|
|
1236
|
-
const res = await fetch(`${url}/api/hub/setup/agent`, {
|
|
1237
|
-
method: "POST",
|
|
1238
|
-
headers: {
|
|
1239
|
-
"Content-Type": "application/json",
|
|
1240
|
-
Authorization: `Bearer ${provisioningToken}`
|
|
1241
|
-
},
|
|
1242
|
-
body: JSON.stringify({ agentType }),
|
|
1243
|
-
signal: AbortSignal.timeout(15e3)
|
|
1244
|
-
});
|
|
1245
|
-
if (!res.ok) {
|
|
1246
|
-
const body = await res.json().catch(() => ({}));
|
|
1247
|
-
throw new HubApiError(
|
|
1248
|
-
`Agent setup failed (HTTP ${res.status})`,
|
|
1249
|
-
res.status,
|
|
1250
|
-
body
|
|
1251
|
-
);
|
|
1252
|
-
}
|
|
1253
|
-
return res.json();
|
|
1254
|
-
}
|
|
1255
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
1256
|
-
0 && (module.exports = {
|
|
1257
|
-
HubApiError,
|
|
1258
|
-
HubRestClient,
|
|
1259
|
-
checkPodHealth,
|
|
1260
|
-
setupAgent
|
|
1261
|
-
});
|