studiograph 1.3.48-next.2 → 1.3.48-next.201
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 +26 -16
- package/dist/agent/agent-pool.d.ts +117 -0
- package/dist/agent/agent-pool.js +287 -0
- package/dist/agent/agent-pool.js.map +1 -0
- package/dist/agent/followups.d.ts +34 -0
- package/dist/agent/followups.js +52 -0
- package/dist/agent/followups.js.map +1 -0
- package/dist/agent/orchestrator.d.ts +113 -22
- package/dist/agent/orchestrator.js +574 -181
- package/dist/agent/orchestrator.js.map +1 -1
- package/dist/agent/prompts/entity-types-section.d.ts +34 -0
- package/dist/agent/prompts/entity-types-section.js +76 -0
- package/dist/agent/prompts/entity-types-section.js.map +1 -0
- package/dist/agent/prompts/system.md +147 -69
- package/dist/agent/skill-loader.d.ts +30 -17
- package/dist/agent/skill-loader.js +63 -30
- package/dist/agent/skill-loader.js.map +1 -1
- package/dist/agent/skills/entity-schema.md +77 -433
- package/dist/agent/skills/interview/entity-templates.md +193 -0
- package/dist/agent/skills/interview/question-domains.md +391 -0
- package/dist/agent/skills/interview/skill.md +204 -0
- package/dist/agent/skills/schema-rules.md +54 -0
- package/dist/agent/tools/capture-tools.d.ts +31 -0
- package/dist/agent/tools/capture-tools.js +40 -0
- package/dist/agent/tools/capture-tools.js.map +1 -0
- package/dist/agent/tools/folder-tools.d.ts +47 -0
- package/dist/agent/tools/folder-tools.js +249 -0
- package/dist/agent/tools/folder-tools.js.map +1 -0
- package/dist/agent/tools/fs-tools.d.ts +7 -6
- package/dist/agent/tools/fs-tools.js +5 -4
- package/dist/agent/tools/fs-tools.js.map +1 -1
- package/dist/agent/tools/graph-tools.d.ts +21 -58
- package/dist/agent/tools/graph-tools.js +664 -333
- package/dist/agent/tools/graph-tools.js.map +1 -1
- package/dist/agent/tools/history-tools.d.ts +95 -0
- package/dist/agent/tools/history-tools.js +461 -0
- package/dist/agent/tools/history-tools.js.map +1 -0
- package/dist/agent/tools/load-skill.d.ts +6 -5
- package/dist/agent/tools/load-skill.js +3 -3
- package/dist/agent/tools/load-skill.js.map +1 -1
- package/dist/agent/tools/ops-tools.d.ts +5 -4
- package/dist/agent/tools/ops-tools.js +130 -236
- package/dist/agent/tools/ops-tools.js.map +1 -1
- package/dist/agent/tools/permission-tools.d.ts +87 -17
- package/dist/agent/tools/permission-tools.js +233 -38
- package/dist/agent/tools/permission-tools.js.map +1 -1
- package/dist/agent/tools/tool-loader.js +5 -4
- package/dist/agent/tools/tool-loader.js.map +1 -1
- package/dist/agent/tools/web-tools.js +58 -9
- package/dist/agent/tools/web-tools.js.map +1 -1
- package/dist/cli/commands/about.d.ts +1 -0
- package/dist/cli/commands/about.js +55 -3
- package/dist/cli/commands/about.js.map +1 -1
- package/dist/cli/commands/admin/audit-workspace.d.ts +23 -0
- package/dist/cli/commands/admin/audit-workspace.js +133 -0
- package/dist/cli/commands/admin/audit-workspace.js.map +1 -0
- package/dist/cli/commands/admin/audit.d.ts +21 -0
- package/dist/cli/commands/admin/audit.js +174 -0
- package/dist/cli/commands/admin/audit.js.map +1 -0
- package/dist/cli/commands/admin/backup.d.ts +54 -0
- package/dist/cli/commands/admin/backup.js +207 -0
- package/dist/cli/commands/admin/backup.js.map +1 -0
- package/dist/cli/commands/admin/folder.d.ts +11 -0
- package/dist/cli/commands/admin/folder.js +186 -0
- package/dist/cli/commands/admin/folder.js.map +1 -0
- package/dist/cli/commands/admin/index.d.ts +16 -0
- package/dist/cli/commands/admin/index.js +46 -0
- package/dist/cli/commands/admin/index.js.map +1 -0
- package/dist/cli/commands/admin/migrate-assets.d.ts +53 -0
- package/dist/cli/commands/admin/migrate-assets.js +184 -0
- package/dist/cli/commands/admin/migrate-assets.js.map +1 -0
- package/dist/cli/commands/admin/migrate.d.ts +56 -0
- package/dist/cli/commands/admin/migrate.js +263 -0
- package/dist/cli/commands/admin/migrate.js.map +1 -0
- package/dist/cli/commands/admin/restore.d.ts +24 -0
- package/dist/cli/commands/admin/restore.js +228 -0
- package/dist/cli/commands/admin/restore.js.map +1 -0
- package/dist/cli/commands/admin/secrets.d.ts +23 -0
- package/dist/cli/commands/admin/secrets.js +256 -0
- package/dist/cli/commands/admin/secrets.js.map +1 -0
- package/dist/cli/commands/admin/settings.d.ts +28 -0
- package/dist/cli/commands/admin/settings.js +284 -0
- package/dist/cli/commands/admin/settings.js.map +1 -0
- package/dist/cli/commands/admin/token.d.ts +42 -0
- package/dist/cli/commands/admin/token.js +126 -0
- package/dist/cli/commands/admin/token.js.map +1 -0
- package/dist/cli/commands/admin/transfer-ownership.d.ts +15 -0
- package/dist/cli/commands/admin/transfer-ownership.js +106 -0
- package/dist/cli/commands/admin/transfer-ownership.js.map +1 -0
- package/dist/cli/commands/admin/user.d.ts +11 -0
- package/dist/cli/commands/admin/user.js +187 -0
- package/dist/cli/commands/admin/user.js.map +1 -0
- package/dist/cli/commands/clone.d.ts +25 -3
- package/dist/cli/commands/clone.js +142 -36
- package/dist/cli/commands/clone.js.map +1 -1
- package/dist/cli/commands/commit.d.ts +1 -1
- package/dist/cli/commands/commit.js +24 -11
- package/dist/cli/commands/commit.js.map +1 -1
- package/dist/cli/commands/config.d.ts +23 -107
- package/dist/cli/commands/config.js +52 -260
- package/dist/cli/commands/config.js.map +1 -1
- package/dist/cli/commands/connector.d.ts +10 -13
- package/dist/cli/commands/connector.js +16 -58
- package/dist/cli/commands/connector.js.map +1 -1
- package/dist/cli/commands/deploy.js +215 -68
- package/dist/cli/commands/deploy.js.map +1 -1
- package/dist/cli/commands/index.js +2 -2
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/commands/init.js +10 -30
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/mcp.js +12 -4
- package/dist/cli/commands/mcp.js.map +1 -1
- package/dist/cli/commands/orphans.js +14 -30
- package/dist/cli/commands/orphans.js.map +1 -1
- package/dist/cli/commands/r2.d.ts +3 -0
- package/dist/cli/commands/r2.js +223 -204
- package/dist/cli/commands/r2.js.map +1 -1
- package/dist/cli/commands/redeploy.js +65 -12
- package/dist/cli/commands/redeploy.js.map +1 -1
- package/dist/cli/commands/reset.d.ts +22 -6
- package/dist/cli/commands/reset.js +142 -63
- package/dist/cli/commands/reset.js.map +1 -1
- package/dist/cli/commands/serve.js +218 -24
- package/dist/cli/commands/serve.js.map +1 -1
- package/dist/cli/commands/sync.d.ts +1 -1
- package/dist/cli/commands/sync.js +372 -202
- package/dist/cli/commands/sync.js.map +1 -1
- package/dist/cli/crypto-bundle.d.ts +39 -0
- package/dist/cli/crypto-bundle.js +94 -0
- package/dist/cli/crypto-bundle.js.map +1 -0
- package/dist/cli/index.js +24 -35
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/railway-pin.d.ts +68 -0
- package/dist/cli/railway-pin.js +96 -0
- package/dist/cli/railway-pin.js.map +1 -0
- package/dist/cli/railway-provisioning.d.ts +53 -0
- package/dist/cli/railway-provisioning.js +85 -0
- package/dist/cli/railway-provisioning.js.map +1 -0
- package/dist/cli/setup-wizard.d.ts +33 -52
- package/dist/cli/setup-wizard.js +43 -68
- package/dist/cli/setup-wizard.js.map +1 -1
- package/dist/core/accent-palette.d.ts +22 -0
- package/dist/core/accent-palette.js +47 -0
- package/dist/core/accent-palette.js.map +1 -0
- package/dist/core/cell-anchor.d.ts +29 -0
- package/dist/core/cell-anchor.js +53 -0
- package/dist/core/cell-anchor.js.map +1 -0
- package/dist/core/comment-anchor.d.ts +41 -0
- package/dist/core/comment-anchor.js +147 -0
- package/dist/core/comment-anchor.js.map +1 -0
- package/dist/core/commit-messages.d.ts +57 -0
- package/dist/core/commit-messages.js +85 -0
- package/dist/core/commit-messages.js.map +1 -0
- package/dist/core/embeds.d.ts +77 -0
- package/dist/core/embeds.js +147 -0
- package/dist/core/embeds.js.map +1 -0
- package/dist/core/entity-body-templates.d.ts +21 -0
- package/dist/core/entity-body-templates.js +53 -0
- package/dist/core/entity-body-templates.js.map +1 -0
- package/dist/core/entity-types-catalog.d.ts +65 -0
- package/dist/core/entity-types-catalog.js +140 -0
- package/dist/core/entity-types-catalog.js.map +1 -0
- package/dist/core/folder-paths.d.ts +41 -0
- package/dist/core/folder-paths.js +95 -0
- package/dist/core/folder-paths.js.map +1 -0
- package/dist/core/folder-sidecar.d.ts +36 -0
- package/dist/core/folder-sidecar.js +91 -0
- package/dist/core/folder-sidecar.js.map +1 -0
- package/dist/core/format-registry.d.ts +170 -0
- package/dist/core/format-registry.js +404 -0
- package/dist/core/format-registry.js.map +1 -0
- package/dist/core/graph.d.ts +731 -14
- package/dist/core/graph.js +2202 -315
- package/dist/core/graph.js.map +1 -1
- package/dist/core/history-diff.d.ts +35 -0
- package/dist/core/history-diff.js +114 -0
- package/dist/core/history-diff.js.map +1 -0
- package/dist/core/refs.d.ts +41 -0
- package/dist/core/refs.js +80 -0
- package/dist/core/refs.js.map +1 -0
- package/dist/core/schema-registry.d.ts +82 -0
- package/dist/core/schema-registry.js +238 -0
- package/dist/core/schema-registry.js.map +1 -1
- package/dist/core/schemas/connector.d.ts +67 -0
- package/dist/core/schemas/connector.js +100 -0
- package/dist/core/schemas/connector.js.map +1 -0
- package/dist/core/schemas/workspace.d.ts +122 -0
- package/dist/core/schemas/workspace.js +211 -0
- package/dist/core/schemas/workspace.js.map +1 -0
- package/dist/core/secrets/SecretStore.d.ts +77 -0
- package/dist/core/secrets/SecretStore.js +13 -0
- package/dist/core/secrets/SecretStore.js.map +1 -0
- package/dist/core/secrets/SettingsResolver.d.ts +54 -0
- package/dist/core/secrets/SettingsResolver.js +80 -0
- package/dist/core/secrets/SettingsResolver.js.map +1 -0
- package/dist/core/secrets/SettingsStore.d.ts +30 -0
- package/dist/core/secrets/SettingsStore.js +9 -0
- package/dist/core/secrets/SettingsStore.js.map +1 -0
- package/dist/core/secrets/SqliteEncryptedStore.d.ts +90 -0
- package/dist/core/secrets/SqliteEncryptedStore.js +598 -0
- package/dist/core/secrets/SqliteEncryptedStore.js.map +1 -0
- package/dist/core/secrets/audit.d.ts +36 -0
- package/dist/core/secrets/audit.js +60 -0
- package/dist/core/secrets/audit.js.map +1 -0
- package/dist/core/secrets/auth-db-migration.d.ts +129 -0
- package/dist/core/secrets/auth-db-migration.js +653 -0
- package/dist/core/secrets/auth-db-migration.js.map +1 -0
- package/dist/core/secrets/bundle.d.ts +141 -0
- package/dist/core/secrets/bundle.js +435 -0
- package/dist/core/secrets/bundle.js.map +1 -0
- package/dist/core/secrets/dual-write.d.ts +81 -0
- package/dist/core/secrets/dual-write.js +247 -0
- package/dist/core/secrets/dual-write.js.map +1 -0
- package/dist/core/secrets/encryption.d.ts +44 -0
- package/dist/core/secrets/encryption.js +97 -0
- package/dist/core/secrets/encryption.js.map +1 -0
- package/dist/core/secrets/index.d.ts +49 -0
- package/dist/core/secrets/index.js +74 -0
- package/dist/core/secrets/index.js.map +1 -0
- package/dist/core/secrets/master-key.d.ts +38 -0
- package/dist/core/secrets/master-key.js +122 -0
- package/dist/core/secrets/master-key.js.map +1 -0
- package/dist/core/secrets/probes/anthropic.d.ts +98 -0
- package/dist/core/secrets/probes/anthropic.js +300 -0
- package/dist/core/secrets/probes/anthropic.js.map +1 -0
- package/dist/core/secrets/probes/brave.d.ts +9 -0
- package/dist/core/secrets/probes/brave.js +15 -0
- package/dist/core/secrets/probes/brave.js.map +1 -0
- package/dist/core/secrets/probes/r2.d.ts +15 -0
- package/dist/core/secrets/probes/r2.js +14 -0
- package/dist/core/secrets/probes/r2.js.map +1 -0
- package/dist/core/secrets/probes/tavily.d.ts +18 -0
- package/dist/core/secrets/probes/tavily.js +58 -0
- package/dist/core/secrets/probes/tavily.js.map +1 -0
- package/dist/core/secrets/probes/voyage.d.ts +13 -0
- package/dist/core/secrets/probes/voyage.js +52 -0
- package/dist/core/secrets/probes/voyage.js.map +1 -0
- package/dist/core/secrets/r2-structural-migration.d.ts +39 -0
- package/dist/core/secrets/r2-structural-migration.js +109 -0
- package/dist/core/secrets/r2-structural-migration.js.map +1 -0
- package/dist/core/secrets/read-flip.d.ts +59 -0
- package/dist/core/secrets/read-flip.js +87 -0
- package/dist/core/secrets/read-flip.js.map +1 -0
- package/dist/core/secrets/registry.d.ts +188 -0
- package/dist/core/secrets/registry.js +616 -0
- package/dist/core/secrets/registry.js.map +1 -0
- package/dist/core/types.d.ts +80 -475
- package/dist/core/types.js +27 -3
- package/dist/core/types.js.map +1 -1
- package/dist/core/user-config.d.ts +75 -7
- package/dist/core/user-config.js +155 -7
- package/dist/core/user-config.js.map +1 -1
- package/dist/core/validation.d.ts +731 -1790
- package/dist/core/validation.js +442 -228
- package/dist/core/validation.js.map +1 -1
- package/dist/core/workspace-manager.d.ts +89 -12
- package/dist/core/workspace-manager.js +225 -73
- package/dist/core/workspace-manager.js.map +1 -1
- package/dist/core/workspace.d.ts +19 -5
- package/dist/core/workspace.js +69 -35
- package/dist/core/workspace.js.map +1 -1
- package/dist/mcp/comment-virtual-entity.d.ts +36 -0
- package/dist/mcp/comment-virtual-entity.js +71 -0
- package/dist/mcp/comment-virtual-entity.js.map +1 -0
- package/dist/mcp/connector-manager.d.ts +94 -13
- package/dist/mcp/connector-manager.js +283 -62
- package/dist/mcp/connector-manager.js.map +1 -1
- package/dist/mcp/oauth-provider.d.ts +27 -33
- package/dist/mcp/oauth-provider.js +65 -134
- package/dist/mcp/oauth-provider.js.map +1 -1
- package/dist/mcp/oauth-registry.d.ts +62 -0
- package/dist/mcp/oauth-registry.js +85 -0
- package/dist/mcp/oauth-registry.js.map +1 -0
- package/dist/mcp/server.d.ts +11 -3
- package/dist/mcp/server.js +30 -5
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/state-signer.d.ts +62 -0
- package/dist/mcp/state-signer.js +205 -0
- package/dist/mcp/state-signer.js.map +1 -0
- package/dist/mcp/tools.d.ts +35 -2
- package/dist/mcp/tools.js +1361 -112
- package/dist/mcp/tools.js.map +1 -1
- package/dist/server/__tests__/helpers/graph-api.d.ts +16 -0
- package/dist/server/__tests__/helpers/graph-api.js +16 -0
- package/dist/server/__tests__/helpers/graph-api.js.map +1 -0
- package/dist/server/asset-index-queue.d.ts +96 -0
- package/dist/server/asset-index-queue.js +191 -0
- package/dist/server/asset-index-queue.js.map +1 -0
- package/dist/server/body-write-coordinator.d.ts +151 -0
- package/dist/server/body-write-coordinator.js +161 -0
- package/dist/server/body-write-coordinator.js.map +1 -0
- package/dist/server/cloud-billing-flow.d.ts +32 -0
- package/dist/server/cloud-billing-flow.js +75 -0
- package/dist/server/cloud-billing-flow.js.map +1 -0
- package/dist/server/commit-audit.d.ts +26 -0
- package/dist/server/commit-audit.js +30 -0
- package/dist/server/commit-audit.js.map +1 -0
- package/dist/server/index.d.ts +22 -3
- package/dist/server/index.js +622 -198
- package/dist/server/index.js.map +1 -1
- package/dist/server/middleware/sanitize.d.ts +46 -0
- package/dist/server/middleware/sanitize.js +171 -0
- package/dist/server/middleware/sanitize.js.map +1 -0
- package/dist/server/routes/asset-api.d.ts +31 -0
- package/dist/server/routes/asset-api.js +593 -0
- package/dist/server/routes/asset-api.js.map +1 -0
- package/dist/server/routes/audit-api.d.ts +24 -0
- package/dist/server/routes/audit-api.js +117 -0
- package/dist/server/routes/audit-api.js.map +1 -0
- package/dist/server/routes/auth-api.d.ts +3 -2
- package/dist/server/routes/auth-api.js +573 -39
- package/dist/server/routes/auth-api.js.map +1 -1
- package/dist/server/routes/capture-api.d.ts +18 -0
- package/dist/server/routes/capture-api.js +257 -0
- package/dist/server/routes/capture-api.js.map +1 -0
- package/dist/server/routes/chat-sessions-api.d.ts +9 -0
- package/dist/server/routes/chat-sessions-api.js +121 -0
- package/dist/server/routes/chat-sessions-api.js.map +1 -0
- package/dist/server/routes/chat.d.ts +12 -1
- package/dist/server/routes/chat.js +318 -88
- package/dist/server/routes/chat.js.map +1 -1
- package/dist/server/routes/comments-api.d.ts +15 -0
- package/dist/server/routes/comments-api.js +444 -0
- package/dist/server/routes/comments-api.js.map +1 -0
- package/dist/server/routes/config-api.d.ts +21 -0
- package/dist/server/routes/config-api.js +256 -0
- package/dist/server/routes/config-api.js.map +1 -0
- package/dist/server/routes/connectors-api.d.ts +17 -0
- package/dist/server/routes/connectors-api.js +410 -0
- package/dist/server/routes/connectors-api.js.map +1 -0
- package/dist/server/routes/event-ingest-api.d.ts +15 -0
- package/dist/server/routes/event-ingest-api.js +125 -0
- package/dist/server/routes/event-ingest-api.js.map +1 -0
- package/dist/server/routes/git-http.d.ts +3 -3
- package/dist/server/routes/git-http.js +86 -38
- package/dist/server/routes/git-http.js.map +1 -1
- package/dist/server/routes/graph-api-access.d.ts +57 -0
- package/dist/server/routes/graph-api-access.js +112 -0
- package/dist/server/routes/graph-api-access.js.map +1 -0
- package/dist/server/routes/graph-api.d.ts +1 -1
- package/dist/server/routes/graph-api.js +1529 -263
- package/dist/server/routes/graph-api.js.map +1 -1
- package/dist/server/routes/health.d.ts +18 -0
- package/dist/server/routes/health.js +74 -0
- package/dist/server/routes/health.js.map +1 -0
- package/dist/server/routes/import-batch.d.ts +24 -0
- package/dist/server/routes/import-batch.js +33 -0
- package/dist/server/routes/import-batch.js.map +1 -0
- package/dist/server/routes/insights-api.d.ts +9 -2
- package/dist/server/routes/insights-api.js +384 -38
- package/dist/server/routes/insights-api.js.map +1 -1
- package/dist/server/routes/mcp.d.ts +7 -3
- package/dist/server/routes/mcp.js +22 -6
- package/dist/server/routes/mcp.js.map +1 -1
- package/dist/server/routes/oauth-api.d.ts +67 -0
- package/dist/server/routes/oauth-api.js +421 -0
- package/dist/server/routes/oauth-api.js.map +1 -0
- package/dist/server/routes/permissions-api.d.ts +9 -2
- package/dist/server/routes/permissions-api.js +87 -30
- package/dist/server/routes/permissions-api.js.map +1 -1
- package/dist/server/routes/r2-api.d.ts +25 -0
- package/dist/server/routes/r2-api.js +276 -0
- package/dist/server/routes/r2-api.js.map +1 -0
- package/dist/server/routes/secrets-api.d.ts +36 -0
- package/dist/server/routes/secrets-api.js +308 -0
- package/dist/server/routes/secrets-api.js.map +1 -0
- package/dist/server/routes/settings-api.d.ts +29 -0
- package/dist/server/routes/settings-api.js +180 -0
- package/dist/server/routes/settings-api.js.map +1 -0
- package/dist/server/routes/share-api.d.ts +32 -0
- package/dist/server/routes/share-api.js +234 -0
- package/dist/server/routes/share-api.js.map +1 -0
- package/dist/server/routes/url-api.d.ts +7 -0
- package/dist/server/routes/url-api.js +74 -0
- package/dist/server/routes/url-api.js.map +1 -0
- package/dist/server/routes/views-api.js +75 -7
- package/dist/server/routes/views-api.js.map +1 -1
- package/dist/server/routes/workspace-api.d.ts +2 -1
- package/dist/server/routes/workspace-api.js +129 -35
- package/dist/server/routes/workspace-api.js.map +1 -1
- package/dist/server/routes/ws.d.ts +2 -1
- package/dist/server/routes/ws.js +68 -16
- package/dist/server/routes/ws.js.map +1 -1
- package/dist/server/session-manager.d.ts +48 -5
- package/dist/server/session-manager.js +182 -15
- package/dist/server/session-manager.js.map +1 -1
- package/dist/server/ws-hub.d.ts +138 -14
- package/dist/server/ws-hub.js +0 -0
- package/dist/server/ws-hub.js.map +1 -1
- package/dist/server/yjs-manager.d.ts +285 -7
- package/dist/server/yjs-manager.js +907 -36
- package/dist/server/yjs-manager.js.map +1 -1
- package/dist/server/yjs-persistence.d.ts +165 -0
- package/dist/server/yjs-persistence.js +557 -0
- package/dist/server/yjs-persistence.js.map +1 -0
- package/dist/server/yjs-text-diff.d.ts +32 -0
- package/dist/server/yjs-text-diff.js +61 -0
- package/dist/server/yjs-text-diff.js.map +1 -0
- package/dist/services/access-control.d.ts +73 -0
- package/dist/services/access-control.js +165 -0
- package/dist/services/access-control.js.map +1 -0
- package/dist/services/asset-caption-service.d.ts +102 -0
- package/dist/services/asset-caption-service.js +184 -0
- package/dist/services/asset-caption-service.js.map +1 -0
- package/dist/services/asset-delete-authz.d.ts +31 -0
- package/dist/services/asset-delete-authz.js +61 -0
- package/dist/services/asset-delete-authz.js.map +1 -0
- package/dist/services/asset-finalize-service.d.ts +58 -0
- package/dist/services/asset-finalize-service.js +207 -0
- package/dist/services/asset-finalize-service.js.map +1 -0
- package/dist/services/asset-import-service.d.ts +111 -0
- package/dist/services/asset-import-service.js +394 -0
- package/dist/services/asset-import-service.js.map +1 -0
- package/dist/services/asset-index-sweep.d.ts +92 -0
- package/dist/services/asset-index-sweep.js +258 -0
- package/dist/services/asset-index-sweep.js.map +1 -0
- package/dist/services/asset-lifecycle-check.d.ts +22 -0
- package/dist/services/asset-lifecycle-check.js +80 -0
- package/dist/services/asset-lifecycle-check.js.map +1 -0
- package/dist/services/asset-listing.d.ts +72 -0
- package/dist/services/asset-listing.js +321 -0
- package/dist/services/asset-listing.js.map +1 -0
- package/dist/services/asset-presign-service.d.ts +68 -0
- package/dist/services/asset-presign-service.js +124 -0
- package/dist/services/asset-presign-service.js.map +1 -0
- package/dist/services/asset-sidecar-service.d.ts +30 -0
- package/dist/services/asset-sidecar-service.js +96 -0
- package/dist/services/asset-sidecar-service.js.map +1 -0
- package/dist/services/asset-upload-errors.d.ts +41 -0
- package/dist/services/asset-upload-errors.js +45 -0
- package/dist/services/asset-upload-errors.js.map +1 -0
- package/dist/services/asset-upload-service.d.ts +74 -0
- package/dist/services/asset-upload-service.js +244 -0
- package/dist/services/asset-upload-service.js.map +1 -0
- package/dist/services/asset-upload-token.d.ts +58 -0
- package/dist/services/asset-upload-token.js +75 -0
- package/dist/services/asset-upload-token.js.map +1 -0
- package/dist/services/assets/asset-index-service.d.ts +127 -0
- package/dist/services/assets/asset-index-service.js +227 -0
- package/dist/services/assets/asset-index-service.js.map +1 -0
- package/dist/services/assets/base.d.ts +118 -1
- package/dist/services/assets/base.js +77 -1
- package/dist/services/assets/base.js.map +1 -1
- package/dist/services/assets/index.d.ts +103 -1
- package/dist/services/assets/index.js +192 -0
- package/dist/services/assets/index.js.map +1 -1
- package/dist/services/assets/local.d.ts +16 -1
- package/dist/services/assets/local.js +110 -1
- package/dist/services/assets/local.js.map +1 -1
- package/dist/services/assets/r2-sync.d.ts +88 -0
- package/dist/services/assets/r2-sync.js +412 -0
- package/dist/services/assets/r2-sync.js.map +1 -0
- package/dist/services/assets/r2.d.ts +87 -1
- package/dist/services/assets/r2.js +203 -1
- package/dist/services/assets/r2.js.map +1 -1
- package/dist/services/auth-service.d.ts +350 -36
- package/dist/services/auth-service.js +1179 -140
- package/dist/services/auth-service.js.map +1 -1
- package/dist/services/bookmark-import-service.d.ts +49 -0
- package/dist/services/bookmark-import-service.js +250 -0
- package/dist/services/bookmark-import-service.js.map +1 -0
- package/dist/services/chat-session-service.d.ts +96 -0
- package/dist/services/chat-session-service.js +316 -0
- package/dist/services/chat-session-service.js.map +1 -0
- package/dist/services/cloud-inference-billing.d.ts +64 -0
- package/dist/services/cloud-inference-billing.js +313 -0
- package/dist/services/cloud-inference-billing.js.map +1 -0
- package/dist/services/comment-service.d.ts +97 -0
- package/dist/services/comment-service.js +341 -0
- package/dist/services/comment-service.js.map +1 -0
- package/dist/services/convert-service.d.ts +64 -0
- package/dist/services/convert-service.js +68 -0
- package/dist/services/convert-service.js.map +1 -0
- package/dist/services/csv-service.d.ts +22 -17
- package/dist/services/csv-service.js +55 -92
- package/dist/services/csv-service.js.map +1 -1
- package/dist/services/entity-mutations.d.ts +210 -0
- package/dist/services/entity-mutations.js +377 -0
- package/dist/services/entity-mutations.js.map +1 -0
- package/dist/services/event-processor.d.ts +104 -0
- package/dist/services/event-processor.js +441 -0
- package/dist/services/event-processor.js.map +1 -0
- package/dist/services/extract/docx.d.ts +1 -0
- package/dist/services/extract/docx.js +233 -0
- package/dist/services/extract/docx.js.map +1 -0
- package/dist/services/extract/index.d.ts +9 -0
- package/dist/services/extract/index.js +10 -0
- package/dist/services/extract/index.js.map +1 -0
- package/dist/services/extract/pdf.d.ts +13 -0
- package/dist/services/extract/pdf.js +69 -0
- package/dist/services/extract/pdf.js.map +1 -0
- package/dist/services/folder-creation.d.ts +33 -0
- package/dist/services/folder-creation.js +103 -0
- package/dist/services/folder-creation.js.map +1 -0
- package/dist/services/git.d.ts +54 -0
- package/dist/services/git.js +188 -54
- package/dist/services/git.js.map +1 -1
- package/dist/services/graph-maintenance.d.ts +42 -0
- package/dist/services/graph-maintenance.js +143 -0
- package/dist/services/graph-maintenance.js.map +1 -0
- package/dist/services/import-service.d.ts +58 -3
- package/dist/services/import-service.js +316 -100
- package/dist/services/import-service.js.map +1 -1
- package/dist/services/lint-service.js +10 -17
- package/dist/services/lint-service.js.map +1 -1
- package/dist/services/markdown.d.ts +12 -1
- package/dist/services/markdown.js +77 -9
- package/dist/services/markdown.js.map +1 -1
- package/dist/services/memory-service.d.ts +22 -14
- package/dist/services/memory-service.js +53 -35
- package/dist/services/memory-service.js.map +1 -1
- package/dist/services/mention-detector.d.ts +23 -0
- package/dist/services/mention-detector.js +47 -0
- package/dist/services/mention-detector.js.map +1 -0
- package/dist/services/model-capabilities.d.ts +41 -0
- package/dist/services/model-capabilities.js +107 -0
- package/dist/services/model-capabilities.js.map +1 -0
- package/dist/services/notification-broadcast.d.ts +32 -0
- package/dist/services/notification-broadcast.js +38 -0
- package/dist/services/notification-broadcast.js.map +1 -0
- package/dist/services/notification-service.d.ts +41 -0
- package/dist/services/notification-service.js +100 -0
- package/dist/services/notification-service.js.map +1 -0
- package/dist/services/oauth-server-store.d.ts +147 -0
- package/dist/services/oauth-server-store.js +319 -0
- package/dist/services/oauth-server-store.js.map +1 -0
- package/dist/services/orphan-service.js +2 -2
- package/dist/services/orphan-service.js.map +1 -1
- package/dist/services/personal-folder.d.ts +40 -0
- package/dist/services/personal-folder.js +101 -0
- package/dist/services/personal-folder.js.map +1 -0
- package/dist/services/share-link-service.d.ts +57 -0
- package/dist/services/share-link-service.js +142 -0
- package/dist/services/share-link-service.js.map +1 -0
- package/dist/services/user-person-bridge.d.ts +136 -0
- package/dist/services/user-person-bridge.js +340 -0
- package/dist/services/user-person-bridge.js.map +1 -0
- package/dist/services/vector-service.d.ts +260 -6
- package/dist/services/vector-service.js +574 -31
- package/dist/services/vector-service.js.map +1 -1
- package/dist/services/workspace-access.d.ts +108 -0
- package/dist/services/workspace-access.js +149 -0
- package/dist/services/workspace-access.js.map +1 -0
- package/dist/services/workspace-assets-folder.d.ts +46 -0
- package/dist/services/workspace-assets-folder.js +75 -0
- package/dist/services/workspace-assets-folder.js.map +1 -0
- package/dist/utils/git.d.ts +17 -2
- package/dist/utils/git.js +23 -7
- package/dist/utils/git.js.map +1 -1
- package/dist/utils/log.d.ts +42 -0
- package/dist/utils/log.js +137 -0
- package/dist/utils/log.js.map +1 -0
- package/dist/utils/preflight.js +2 -2
- package/dist/utils/preflight.js.map +1 -1
- package/dist/utils/version-checker.d.ts +12 -19
- package/dist/utils/version-checker.js +14 -104
- package/dist/utils/version-checker.js.map +1 -1
- package/dist/web/_app/immutable/assets/0.BZHoBJEc.css +2 -0
- package/dist/web/_app/immutable/assets/12.DlIf1mKh.css +1 -0
- package/dist/web/_app/immutable/assets/13.7d-Q37wc.css +1 -0
- package/dist/web/_app/immutable/assets/14.BwBFdc1D.css +1 -0
- package/dist/web/_app/immutable/assets/15.CmLrbzZp.css +1 -0
- package/dist/web/_app/immutable/assets/16.B0GwXar3.css +1 -0
- package/dist/web/_app/immutable/assets/2.C9Vt4JHy.css +1 -0
- package/dist/web/_app/immutable/assets/3.BFvgCYSk.css +1 -0
- package/dist/web/_app/immutable/assets/4.OmdYF47-.css +1 -0
- package/dist/web/_app/immutable/assets/5.C6MySjPq.css +1 -0
- package/dist/web/_app/immutable/assets/BulkActionsBar.Bx7nxMjH.css +1 -0
- package/dist/web/_app/immutable/assets/CalendarView.lBCvS3X5.css +1 -0
- package/dist/web/_app/immutable/assets/CodeMirrorEditor.D6hf2pNJ.css +1 -0
- package/dist/web/_app/immutable/assets/CopyField.DVGZtw4U.css +1 -0
- package/dist/web/_app/immutable/assets/FolderMembersPanel.DX1oBeF_.css +1 -0
- package/dist/web/_app/immutable/assets/FolderMutationDialogs.D2B7KrRn.css +1 -0
- package/dist/web/_app/immutable/assets/FolderPicker.B5KdvRYl.css +1 -0
- package/dist/web/_app/immutable/assets/GalleryView.CF48FWYQ.css +1 -0
- package/dist/web/_app/immutable/assets/GraphView.BJtGL9py.css +1 -0
- package/dist/web/_app/immutable/assets/KanbanView.BOaI5KFL.css +1 -0
- package/dist/web/_app/immutable/assets/Link.vV0ne105.css +1 -0
- package/dist/web/_app/immutable/assets/Markdown.BqgpZCv5.css +1 -0
- package/dist/web/_app/immutable/assets/Rail.f8lsriOT.css +1 -0
- package/dist/web/_app/immutable/assets/SettingsDialog.DwMus2u2.css +1 -0
- package/dist/web/_app/immutable/assets/Spinner.UBfl0pab.css +1 -0
- package/dist/web/_app/immutable/assets/StopFilledAlt.fNlDN65D.css +1 -0
- package/dist/web/_app/immutable/assets/TimelineView.DriOGAKB.css +1 -0
- package/dist/web/_app/immutable/assets/WorkspaceView.u5VdwRR6.css +1 -0
- package/dist/web/_app/immutable/assets/button.BlLm4Dg1.css +1 -0
- package/dist/web/_app/immutable/assets/checkbox.DK0MgYgb.css +1 -0
- package/dist/web/_app/immutable/assets/dist.DDCWxn3B.css +1 -0
- package/dist/web/_app/immutable/assets/ibm-plex-mono-latin-400-normal.CvHOgSBP.woff +0 -0
- package/dist/web/_app/immutable/assets/ibm-plex-mono-latin-400-normal.DMJ8VG8y.woff2 +0 -0
- package/dist/web/_app/immutable/assets/ibm-plex-mono-latin-500-normal.CB9ihrfo.woff +0 -0
- package/dist/web/_app/immutable/assets/ibm-plex-mono-latin-500-normal.DSY6xOcd.woff2 +0 -0
- package/dist/web/_app/immutable/assets/ibm-plex-sans-latin-400-italic.CZTNEAuW.woff2 +0 -0
- package/dist/web/_app/immutable/assets/ibm-plex-sans-latin-400-italic.CsGl1sm0.woff +0 -0
- package/dist/web/_app/immutable/assets/ibm-plex-sans-latin-400-normal.CDDApCn2.woff2 +0 -0
- package/dist/web/_app/immutable/assets/ibm-plex-sans-latin-400-normal.CYLoc0-x.woff +0 -0
- package/dist/web/_app/immutable/assets/ibm-plex-sans-latin-500-italic.BNK2_mGO.woff2 +0 -0
- package/dist/web/_app/immutable/assets/ibm-plex-sans-latin-500-italic.DpEwFAQM.woff +0 -0
- package/dist/web/_app/immutable/assets/ibm-plex-sans-latin-500-normal.6ng42L7E.woff2 +0 -0
- package/dist/web/_app/immutable/assets/ibm-plex-sans-latin-500-normal.BgVn5rGT.woff +0 -0
- package/dist/web/_app/immutable/assets/ibm-plex-sans-latin-600-normal.Cu4Hd6ag.woff +0 -0
- package/dist/web/_app/immutable/assets/ibm-plex-sans-latin-600-normal.CuJfVYMP.woff2 +0 -0
- package/dist/web/_app/immutable/assets/inline-list.cqga56xT.css +1 -0
- package/dist/web/_app/immutable/assets/list-columns.DiLB0G5L.css +1 -0
- package/dist/web/_app/immutable/assets/select.BFL238eD.css +1 -0
- package/dist/web/_app/immutable/assets/sheet.4rY4hpfJ.css +1 -0
- package/dist/web/_app/immutable/chunks/2oYV6q4R.js +2 -0
- package/dist/web/_app/immutable/chunks/4XSri7g0.js +1 -0
- package/dist/web/_app/immutable/chunks/4iaT0dG72.js +1 -0
- package/dist/web/_app/immutable/chunks/5_TKU9QS2.js +1 -0
- package/dist/web/_app/immutable/chunks/8Yh26Z9_2.js +1 -0
- package/dist/web/_app/immutable/chunks/Atl8xKOm.js +2 -0
- package/dist/web/_app/immutable/chunks/B-Z_xZy_.js +4 -0
- package/dist/web/_app/immutable/chunks/B0pk0Lyx.js +1 -0
- package/dist/web/_app/immutable/chunks/B1RnjnNt.js +1 -0
- package/dist/web/_app/immutable/chunks/B2n86UNJ.js +1 -0
- package/dist/web/_app/immutable/chunks/B318GEUB2.js +1 -0
- package/dist/web/_app/immutable/chunks/B6Lt-qaJ.js +1 -0
- package/dist/web/_app/immutable/chunks/B8yrQWxT2.js +1 -0
- package/dist/web/_app/immutable/chunks/BADt8daH.js +2 -0
- package/dist/web/_app/immutable/chunks/BBGt-XQo.js +3 -0
- package/dist/web/_app/immutable/chunks/BDIUHcEz.js +1 -0
- package/dist/web/_app/immutable/chunks/BDSuq3KH.js +1 -0
- package/dist/web/_app/immutable/chunks/BGiLU5VN.js +1 -0
- package/dist/web/_app/immutable/chunks/BJgOZTHR.js +1 -0
- package/dist/web/_app/immutable/chunks/BOSiTh-42.js +1 -0
- package/dist/web/_app/immutable/chunks/BPxcCdjn.js +1 -0
- package/dist/web/_app/immutable/chunks/BVPNAzAK.js +1 -0
- package/dist/web/_app/immutable/chunks/BcOvJgjM.js +1 -0
- package/dist/web/_app/immutable/chunks/BdYQewoD.js +1 -0
- package/dist/web/_app/immutable/chunks/BfCWIy8t.js +8 -0
- package/dist/web/_app/immutable/chunks/BgRT-K6w.js +5 -0
- package/dist/web/_app/immutable/chunks/BibveGGd.js +1 -0
- package/dist/web/_app/immutable/chunks/BmM5VZ4W.js +1 -0
- package/dist/web/_app/immutable/chunks/BnIYzuS1.js +66 -0
- package/dist/web/_app/immutable/chunks/BoDmwOTJ.js +1 -0
- package/dist/web/_app/immutable/chunks/BoglwbZW.js +1 -0
- package/dist/web/_app/immutable/chunks/Bqm_YrIg2.js +23 -0
- package/dist/web/_app/immutable/chunks/BtMRrdc4.js +2 -0
- package/dist/web/_app/immutable/chunks/C-AnzvKr.js +7 -0
- package/dist/web/_app/immutable/chunks/C1Y3tUpz.js +1 -0
- package/dist/web/_app/immutable/chunks/C6VZhhwF.js +1 -0
- package/dist/web/_app/immutable/chunks/C8IMrD4G2.js +3 -0
- package/dist/web/_app/immutable/chunks/CAXXrbj52.js +1 -0
- package/dist/web/_app/immutable/chunks/CB-0u-Pc2.js +1 -0
- package/dist/web/_app/immutable/chunks/CEniyZ1Z2.js +6 -0
- package/dist/web/_app/immutable/chunks/CJhElIkU2.js +1 -0
- package/dist/web/_app/immutable/chunks/CK8tIaYT.js +1 -0
- package/dist/web/_app/immutable/chunks/CM8uYli8.js +1 -0
- package/dist/web/_app/immutable/chunks/CTzjJm_m2.js +1 -0
- package/dist/web/_app/immutable/chunks/CUXqa1nn2.js +1 -0
- package/dist/web/_app/immutable/chunks/CY0iY_WO.js +1 -0
- package/dist/web/_app/immutable/chunks/CbCfNNV_2.js +2692 -0
- package/dist/web/_app/immutable/chunks/CbuGIyDu2.js +22 -0
- package/dist/web/_app/immutable/chunks/CcRGXA-t.js +1 -0
- package/dist/web/_app/immutable/chunks/CcXmQaYs2.js +1 -0
- package/dist/web/_app/immutable/chunks/CcaQuaSt2.js +1 -0
- package/dist/web/_app/immutable/chunks/CoHaBDpN2.js +2 -0
- package/dist/web/_app/immutable/chunks/Cvbd3myc2.js +14 -0
- package/dist/web/_app/immutable/chunks/D20C1thX2.js +1 -0
- package/dist/web/_app/immutable/chunks/D3JoMtWC.js +7 -0
- package/dist/web/_app/immutable/chunks/D3ch71s_.js +1 -0
- package/dist/web/_app/immutable/chunks/D4xXlMEU.js +2 -0
- package/dist/web/_app/immutable/chunks/D5GipQqN2.js +1 -0
- package/dist/web/_app/immutable/chunks/D9TyJuu_.js +1 -0
- package/dist/web/_app/immutable/chunks/DBFijAmG.js +1 -0
- package/dist/web/_app/immutable/chunks/DHLjkH7T.js +1 -0
- package/dist/web/_app/immutable/chunks/DIfdPIt_2.js +1 -0
- package/dist/web/_app/immutable/chunks/DO_sw49q2.js +1 -0
- package/dist/web/_app/immutable/chunks/DP69PpIj.js +1 -0
- package/dist/web/_app/immutable/chunks/DQ3HSZMs.js +2 -0
- package/dist/web/_app/immutable/chunks/DQMWa2t7.js +1 -0
- package/dist/web/_app/immutable/chunks/DT0wzK622.js +1 -0
- package/dist/web/_app/immutable/chunks/DTnEJArL.js +1 -0
- package/dist/web/_app/immutable/chunks/DToS-G202.js +1 -0
- package/dist/web/_app/immutable/chunks/DZcU6mGe2.js +1 -0
- package/dist/web/_app/immutable/chunks/DbslMybD.js +1 -0
- package/dist/web/_app/immutable/chunks/DcGThsSF.js +1 -0
- package/dist/web/_app/immutable/chunks/DcPrzUMJ.js +1 -0
- package/dist/web/_app/immutable/chunks/De0g5qop2.js +1 -0
- package/dist/web/_app/immutable/chunks/DimS8dbZ2.js +1 -0
- package/dist/web/_app/immutable/chunks/DjuqhOjF.js +1 -0
- package/dist/web/_app/immutable/chunks/Dk6sAhpo.js +3 -0
- package/dist/web/_app/immutable/chunks/Dl6cnwyk.js +1 -0
- package/dist/web/_app/immutable/chunks/DnIQzIOz.js +1 -0
- package/dist/web/_app/immutable/chunks/DnXYAo60.js +1 -0
- package/dist/web/_app/immutable/chunks/DnrImJan.js +1 -0
- package/dist/web/_app/immutable/chunks/Dpuq25vu2.js +1 -0
- package/dist/web/_app/immutable/chunks/DrMZDWru.js +1 -0
- package/dist/web/_app/immutable/chunks/DsVOtl0N.js +1 -0
- package/dist/web/_app/immutable/chunks/DuTXsWdP.js +2 -0
- package/dist/web/_app/immutable/chunks/Dw-frCfE.js +1 -0
- package/dist/web/_app/immutable/chunks/Dz34u8Ie2.js +185 -0
- package/dist/web/_app/immutable/chunks/DzcFeQZU2.js +2 -0
- package/dist/web/_app/immutable/chunks/DzrRTvug.js +1 -0
- package/dist/web/_app/immutable/chunks/G5oUVQa92.js +1 -0
- package/dist/web/_app/immutable/chunks/HyhOhoeq2.js +2 -0
- package/dist/web/_app/immutable/chunks/J5nb9xxj.js +1 -0
- package/dist/web/_app/immutable/chunks/JCjEwqH9.js +1 -0
- package/dist/web/_app/immutable/chunks/JN_nsXUm2.js +1 -0
- package/dist/web/_app/immutable/chunks/JS2_GaB1.js +1 -0
- package/dist/web/_app/immutable/chunks/MtI6dyxu.js +1 -0
- package/dist/web/_app/immutable/chunks/N6vnY5Si2.js +1 -0
- package/dist/web/_app/immutable/chunks/PcEbaKam.js +2 -0
- package/dist/web/_app/immutable/chunks/VTYhCLh9.js +2 -0
- package/dist/web/_app/immutable/chunks/Wowi_89k.js +5 -0
- package/dist/web/_app/immutable/chunks/Y_asqJqs2.js +83 -0
- package/dist/web/_app/immutable/chunks/Yhg5Q4MT.js +1 -0
- package/dist/web/_app/immutable/chunks/f_eYccPf2.js +1 -0
- package/dist/web/_app/immutable/chunks/hm_8RsuL.js +1 -0
- package/dist/web/_app/immutable/chunks/iPCkjliu.js +3 -0
- package/dist/web/_app/immutable/chunks/j2AvgZGz.js +1 -0
- package/dist/web/_app/immutable/chunks/kNaey6uv.js +1 -0
- package/dist/web/_app/immutable/chunks/l1761xxj.js +1 -0
- package/dist/web/_app/immutable/chunks/liGRFQqV2.js +184 -0
- package/dist/web/_app/immutable/chunks/lq1kR86d.js +1 -0
- package/dist/web/_app/immutable/chunks/mIykYR4F2.js +1 -0
- package/dist/web/_app/immutable/chunks/rbhlO_t8.js +1 -0
- package/dist/web/_app/immutable/chunks/tJpAwaTl.js +1 -0
- package/dist/web/_app/immutable/chunks/tcegdii0.js +2 -0
- package/dist/web/_app/immutable/chunks/u8G2EUvz2.js +224 -0
- package/dist/web/_app/immutable/chunks/vgsM0KTm2.js +1 -0
- package/dist/web/_app/immutable/chunks/xcGI4fuV.js +1 -0
- package/dist/web/_app/immutable/chunks/xihTtKlq.js +1 -0
- package/dist/web/_app/immutable/chunks/yEYlhV9G2.js +1 -0
- package/dist/web/_app/immutable/entry/app.DSf_XGp8.js +2 -0
- package/dist/web/_app/immutable/entry/start.B7ScfxPc.js +1 -0
- package/dist/web/_app/immutable/nodes/0.BMSOOETY.js +2 -0
- package/dist/web/_app/immutable/nodes/1.B0lBUpHt.js +1 -0
- package/dist/web/_app/immutable/nodes/10.DmDbUH1j.js +1 -0
- package/dist/web/_app/immutable/nodes/11.gwY7gZdR.js +1 -0
- package/dist/web/_app/immutable/nodes/12.BpGHSr2y.js +1 -0
- package/dist/web/_app/immutable/nodes/13.Bf178QF_.js +1 -0
- package/dist/web/_app/immutable/nodes/14.D_x8-nk9.js +1 -0
- package/dist/web/_app/immutable/nodes/15.DY4XeagL.js +1 -0
- package/dist/web/_app/immutable/nodes/16.DPqftx8x.js +77 -0
- package/dist/web/_app/immutable/nodes/2.OM2LGRpi.js +109 -0
- package/dist/web/_app/immutable/nodes/3.e8ZoPCmC.js +6 -0
- package/dist/web/_app/immutable/nodes/4.BdYR1hNQ.js +11 -0
- package/dist/web/_app/immutable/nodes/5.B8sOFna9.js +5 -0
- package/dist/web/_app/immutable/nodes/6.L1BbYsmo.js +1 -0
- package/dist/web/_app/immutable/nodes/7.B7zoemJD.js +1 -0
- package/dist/web/_app/immutable/nodes/8.B1VtnfMK.js +1 -0
- package/dist/web/_app/immutable/nodes/9.BE3VCQzk.js +1 -0
- package/dist/web/_app/version.json +1 -1
- package/dist/web/favicon-16.png +0 -0
- package/dist/web/favicon-180.png +0 -0
- package/dist/web/favicon-32.png +0 -0
- package/dist/web/favicon-48.png +0 -0
- package/dist/web/favicon-512.png +0 -0
- package/dist/web/favicon.ico +0 -0
- package/dist/web/favicon.svg +8 -0
- package/dist/web/index.html +58 -19
- package/dist/web/studiograph-logomark.svg +29 -0
- package/package.json +38 -14
- package/dist/agent/skills/enrich-entities.md +0 -136
- package/dist/agent/skills/obsidian-source-setup.md +0 -246
- package/dist/agent/skills/skill-loader.d.ts +0 -48
- package/dist/agent/skills/skill-loader.js +0 -166
- package/dist/agent/skills/skill-loader.js.map +0 -1
- package/dist/agent/skills/sync-configuration.md +0 -119
- package/dist/agent/skills/sync-setup.md +0 -82
- package/dist/agent/tools/sync-tools.d.ts +0 -35
- package/dist/agent/tools/sync-tools.js +0 -992
- package/dist/agent/tools/sync-tools.js.map +0 -1
- package/dist/auth/github.d.ts +0 -56
- package/dist/auth/github.js +0 -169
- package/dist/auth/github.js.map +0 -1
- package/dist/cli/commands/access.d.ts +0 -11
- package/dist/cli/commands/access.js +0 -156
- package/dist/cli/commands/access.js.map +0 -1
- package/dist/cli/commands/app.d.ts +0 -7
- package/dist/cli/commands/app.js +0 -268
- package/dist/cli/commands/app.js.map +0 -1
- package/dist/cli/commands/auth.d.ts +0 -10
- package/dist/cli/commands/auth.js +0 -79
- package/dist/cli/commands/auth.js.map +0 -1
- package/dist/cli/commands/clear.d.ts +0 -5
- package/dist/cli/commands/clear.js +0 -36
- package/dist/cli/commands/clear.js.map +0 -1
- package/dist/cli/commands/collection.d.ts +0 -10
- package/dist/cli/commands/collection.js +0 -187
- package/dist/cli/commands/collection.js.map +0 -1
- package/dist/cli/commands/enrich.d.ts +0 -11
- package/dist/cli/commands/enrich.js +0 -135
- package/dist/cli/commands/enrich.js.map +0 -1
- package/dist/cli/commands/graphrag.d.ts +0 -12
- package/dist/cli/commands/graphrag.js +0 -122
- package/dist/cli/commands/graphrag.js.map +0 -1
- package/dist/cli/commands/join.d.ts +0 -9
- package/dist/cli/commands/join.js +0 -255
- package/dist/cli/commands/join.js.map +0 -1
- package/dist/cli/commands/members.d.ts +0 -11
- package/dist/cli/commands/members.js +0 -230
- package/dist/cli/commands/members.js.map +0 -1
- package/dist/cli/commands/org.d.ts +0 -10
- package/dist/cli/commands/org.js +0 -132
- package/dist/cli/commands/org.js.map +0 -1
- package/dist/cli/commands/provision.d.ts +0 -8
- package/dist/cli/commands/provision.js +0 -116
- package/dist/cli/commands/provision.js.map +0 -1
- package/dist/cli/commands/resolve.d.ts +0 -8
- package/dist/cli/commands/resolve.js +0 -85
- package/dist/cli/commands/resolve.js.map +0 -1
- package/dist/cli/commands/review.d.ts +0 -19
- package/dist/cli/commands/review.js +0 -128
- package/dist/cli/commands/review.js.map +0 -1
- package/dist/cli/commands/source.d.ts +0 -16
- package/dist/cli/commands/source.js +0 -159
- package/dist/cli/commands/source.js.map +0 -1
- package/dist/cli/commands/start.d.ts +0 -7
- package/dist/cli/commands/start.js +0 -589
- package/dist/cli/commands/start.js.map +0 -1
- package/dist/cli/commands/sync-collection.d.ts +0 -14
- package/dist/cli/commands/sync-collection.js +0 -355
- package/dist/cli/commands/sync-collection.js.map +0 -1
- package/dist/cli/commands/sync-entities.d.ts +0 -13
- package/dist/cli/commands/sync-entities.js +0 -242
- package/dist/cli/commands/sync-entities.js.map +0 -1
- package/dist/cli/commands/team.d.ts +0 -12
- package/dist/cli/commands/team.js +0 -185
- package/dist/cli/commands/team.js.map +0 -1
- package/dist/cli/commands/update.d.ts +0 -8
- package/dist/cli/commands/update.js +0 -155
- package/dist/cli/commands/update.js.map +0 -1
- package/dist/cli/commands/user.d.ts +0 -7
- package/dist/cli/commands/user.js +0 -153
- package/dist/cli/commands/user.js.map +0 -1
- package/dist/cli/scaffolding.d.ts +0 -12
- package/dist/cli/scaffolding.js +0 -397
- package/dist/cli/scaffolding.js.map +0 -1
- package/dist/cli/sync-review-interactive.d.ts +0 -31
- package/dist/cli/sync-review-interactive.js +0 -393
- package/dist/cli/sync-review-interactive.js.map +0 -1
- package/dist/core/migration-runner.d.ts +0 -42
- package/dist/core/migration-runner.js +0 -232
- package/dist/core/migration-runner.js.map +0 -1
- package/dist/core/migration-types.d.ts +0 -101
- package/dist/core/migration-types.js +0 -21
- package/dist/core/migration-types.js.map +0 -1
- package/dist/core/migrations/20260219-formalize-memory-location.d.ts +0 -2
- package/dist/core/migrations/20260219-formalize-memory-location.js +0 -35
- package/dist/core/migrations/20260219-formalize-memory-location.js.map +0 -1
- package/dist/core/migrations/20260220-add-workspace-metadata.d.ts +0 -12
- package/dist/core/migrations/20260220-add-workspace-metadata.js +0 -65
- package/dist/core/migrations/20260220-add-workspace-metadata.js.map +0 -1
- package/dist/core/migrations/20260220-add-workspace-readme.d.ts +0 -11
- package/dist/core/migrations/20260220-add-workspace-readme.js +0 -82
- package/dist/core/migrations/20260220-add-workspace-readme.js.map +0 -1
- package/dist/core/migrations/20260220-migrate-yaml-to-json.d.ts +0 -9
- package/dist/core/migrations/20260220-migrate-yaml-to-json.js +0 -64
- package/dist/core/migrations/20260220-migrate-yaml-to-json.js.map +0 -1
- package/dist/core/migrations/index.d.ts +0 -11
- package/dist/core/migrations/index.js +0 -23
- package/dist/core/migrations/index.js.map +0 -1
- package/dist/integrations/asana.d.ts +0 -26
- package/dist/integrations/asana.js +0 -78
- package/dist/integrations/asana.js.map +0 -1
- package/dist/integrations/figma-local.d.ts +0 -16
- package/dist/integrations/figma-local.js +0 -10
- package/dist/integrations/figma-local.js.map +0 -1
- package/dist/integrations/figma.d.ts +0 -17
- package/dist/integrations/figma.js +0 -17
- package/dist/integrations/figma.js.map +0 -1
- package/dist/integrations/granola.d.ts +0 -24
- package/dist/integrations/granola.js +0 -60
- package/dist/integrations/granola.js.map +0 -1
- package/dist/integrations/linear.d.ts +0 -14
- package/dist/integrations/linear.js +0 -80
- package/dist/integrations/linear.js.map +0 -1
- package/dist/integrations/paper-local.d.ts +0 -14
- package/dist/integrations/paper-local.js +0 -10
- package/dist/integrations/paper-local.js.map +0 -1
- package/dist/integrations/paper.d.ts +0 -2
- package/dist/integrations/paper.js +0 -10
- package/dist/integrations/paper.js.map +0 -1
- package/dist/integrations/pipedrive.d.ts +0 -26
- package/dist/integrations/pipedrive.js +0 -97
- package/dist/integrations/pipedrive.js.map +0 -1
- package/dist/integrations/registry.d.ts +0 -15
- package/dist/integrations/registry.js +0 -27
- package/dist/integrations/registry.js.map +0 -1
- package/dist/integrations/types.d.ts +0 -38
- package/dist/integrations/types.js +0 -9
- package/dist/integrations/types.js.map +0 -1
- package/dist/lib/lib/utils.d.ts +0 -2
- package/dist/lib/lib/utils.js +0 -6
- package/dist/lib/lib/utils.js.map +0 -1
- package/dist/mcp/connectors/asana.d.ts +0 -2
- package/dist/mcp/connectors/asana.js +0 -20
- package/dist/mcp/connectors/asana.js.map +0 -1
- package/dist/mcp/connectors/definitions.d.ts +0 -45
- package/dist/mcp/connectors/definitions.js +0 -32
- package/dist/mcp/connectors/definitions.js.map +0 -1
- package/dist/mcp/connectors/figma.d.ts +0 -5
- package/dist/mcp/connectors/figma.js +0 -21
- package/dist/mcp/connectors/figma.js.map +0 -1
- package/dist/mcp/connectors/gdrive.d.ts +0 -2
- package/dist/mcp/connectors/gdrive.js +0 -20
- package/dist/mcp/connectors/gdrive.js.map +0 -1
- package/dist/mcp/connectors/granola.d.ts +0 -2
- package/dist/mcp/connectors/granola.js +0 -12
- package/dist/mcp/connectors/granola.js.map +0 -1
- package/dist/mcp/connectors/linear.d.ts +0 -2
- package/dist/mcp/connectors/linear.js +0 -19
- package/dist/mcp/connectors/linear.js.map +0 -1
- package/dist/mcp/connectors/obsidian.d.ts +0 -2
- package/dist/mcp/connectors/obsidian.js +0 -19
- package/dist/mcp/connectors/obsidian.js.map +0 -1
- package/dist/mcp/connectors/pipedrive.d.ts +0 -2
- package/dist/mcp/connectors/pipedrive.js +0 -20
- package/dist/mcp/connectors/pipedrive.js.map +0 -1
- package/dist/mcp/connectors/slack.d.ts +0 -2
- package/dist/mcp/connectors/slack.js +0 -21
- package/dist/mcp/connectors/slack.js.map +0 -1
- package/dist/mcp/server-oauth-provider.d.ts +0 -56
- package/dist/mcp/server-oauth-provider.js +0 -142
- package/dist/mcp/server-oauth-provider.js.map +0 -1
- package/dist/server/chrome/chrome.css +0 -691
- package/dist/server/chrome/chrome.js +0 -374
- package/dist/server/collab-authority.d.ts +0 -70
- package/dist/server/collab-authority.js +0 -218
- package/dist/server/collab-authority.js.map +0 -1
- package/dist/server/collab.d.ts +0 -29
- package/dist/server/collab.js +0 -195
- package/dist/server/collab.js.map +0 -1
- package/dist/server/commit-scheduler.d.ts +0 -39
- package/dist/server/commit-scheduler.js +0 -113
- package/dist/server/commit-scheduler.js.map +0 -1
- package/dist/server/plugin-loader.d.ts +0 -53
- package/dist/server/plugin-loader.js +0 -155
- package/dist/server/plugin-loader.js.map +0 -1
- package/dist/server/routes/collab.d.ts +0 -6
- package/dist/server/routes/collab.js +0 -10
- package/dist/server/routes/collab.js.map +0 -1
- package/dist/server/routes/git-api.d.ts +0 -9
- package/dist/server/routes/git-api.js +0 -82
- package/dist/server/routes/git-api.js.map +0 -1
- package/dist/server/routes/meeting-ingest-api.d.ts +0 -15
- package/dist/server/routes/meeting-ingest-api.js +0 -323
- package/dist/server/routes/meeting-ingest-api.js.map +0 -1
- package/dist/server/routes/sync-api.d.ts +0 -26
- package/dist/server/routes/sync-api.js +0 -814
- package/dist/server/routes/sync-api.js.map +0 -1
- package/dist/server/routes/webhook.d.ts +0 -14
- package/dist/server/routes/webhook.js +0 -102
- package/dist/server/routes/webhook.js.map +0 -1
- package/dist/services/github-provisioner.d.ts +0 -36
- package/dist/services/github-provisioner.js +0 -126
- package/dist/services/github-provisioner.js.map +0 -1
- package/dist/services/github-service.d.ts +0 -99
- package/dist/services/github-service.js +0 -310
- package/dist/services/github-service.js.map +0 -1
- package/dist/services/insights.d.ts +0 -38
- package/dist/services/insights.js +0 -246
- package/dist/services/insights.js.map +0 -1
- package/dist/services/sync/collection-sync.d.ts +0 -60
- package/dist/services/sync/collection-sync.js +0 -509
- package/dist/services/sync/collection-sync.js.map +0 -1
- package/dist/services/sync/commit.d.ts +0 -60
- package/dist/services/sync/commit.js +0 -354
- package/dist/services/sync/commit.js.map +0 -1
- package/dist/services/sync/context-index.d.ts +0 -69
- package/dist/services/sync/context-index.js +0 -280
- package/dist/services/sync/context-index.js.map +0 -1
- package/dist/services/sync/data-fetcher.d.ts +0 -31
- package/dist/services/sync/data-fetcher.js +0 -12
- package/dist/services/sync/data-fetcher.js.map +0 -1
- package/dist/services/sync/derive.d.ts +0 -34
- package/dist/services/sync/derive.js +0 -164
- package/dist/services/sync/derive.js.map +0 -1
- package/dist/services/sync/enrichment-state.d.ts +0 -31
- package/dist/services/sync/enrichment-state.js +0 -63
- package/dist/services/sync/enrichment-state.js.map +0 -1
- package/dist/services/sync/enrichment.d.ts +0 -25
- package/dist/services/sync/enrichment.js +0 -121
- package/dist/services/sync/enrichment.js.map +0 -1
- package/dist/services/sync/entity-refresh.d.ts +0 -30
- package/dist/services/sync/entity-refresh.js +0 -275
- package/dist/services/sync/entity-refresh.js.map +0 -1
- package/dist/services/sync/frontmatter-extractor.d.ts +0 -40
- package/dist/services/sync/frontmatter-extractor.js +0 -279
- package/dist/services/sync/frontmatter-extractor.js.map +0 -1
- package/dist/services/sync/graph-match-state.d.ts +0 -33
- package/dist/services/sync/graph-match-state.js +0 -61
- package/dist/services/sync/graph-match-state.js.map +0 -1
- package/dist/services/sync/graph-match.d.ts +0 -53
- package/dist/services/sync/graph-match.js +0 -316
- package/dist/services/sync/graph-match.js.map +0 -1
- package/dist/services/sync/graphrag-client.d.ts +0 -43
- package/dist/services/sync/graphrag-client.js +0 -94
- package/dist/services/sync/graphrag-client.js.map +0 -1
- package/dist/services/sync/graphrag-config.d.ts +0 -16
- package/dist/services/sync/graphrag-config.js +0 -39
- package/dist/services/sync/graphrag-config.js.map +0 -1
- package/dist/services/sync/graphrag-context.d.ts +0 -14
- package/dist/services/sync/graphrag-context.js +0 -109
- package/dist/services/sync/graphrag-context.js.map +0 -1
- package/dist/services/sync/graphrag-indexer.d.ts +0 -30
- package/dist/services/sync/graphrag-indexer.js +0 -358
- package/dist/services/sync/graphrag-indexer.js.map +0 -1
- package/dist/services/sync/llm.d.ts +0 -32
- package/dist/services/sync/llm.js +0 -115
- package/dist/services/sync/llm.js.map +0 -1
- package/dist/services/sync/mcp-client.d.ts +0 -71
- package/dist/services/sync/mcp-client.js +0 -299
- package/dist/services/sync/mcp-client.js.map +0 -1
- package/dist/services/sync/model-factory.d.ts +0 -13
- package/dist/services/sync/model-factory.js +0 -38
- package/dist/services/sync/model-factory.js.map +0 -1
- package/dist/services/sync/name-quality.d.ts +0 -31
- package/dist/services/sync/name-quality.js +0 -60
- package/dist/services/sync/name-quality.js.map +0 -1
- package/dist/services/sync/output-schemas.d.ts +0 -92
- package/dist/services/sync/output-schemas.js +0 -43
- package/dist/services/sync/output-schemas.js.map +0 -1
- package/dist/services/sync/prompts.d.ts +0 -19
- package/dist/services/sync/prompts.js +0 -128
- package/dist/services/sync/prompts.js.map +0 -1
- package/dist/services/sync/reconciler.d.ts +0 -48
- package/dist/services/sync/reconciler.js +0 -294
- package/dist/services/sync/reconciler.js.map +0 -1
- package/dist/services/sync/rest-client.d.ts +0 -40
- package/dist/services/sync/rest-client.js +0 -100
- package/dist/services/sync/rest-client.js.map +0 -1
- package/dist/services/sync/source-config.d.ts +0 -67
- package/dist/services/sync/source-config.js +0 -304
- package/dist/services/sync/source-config.js.map +0 -1
- package/dist/services/sync/source-definitions/asana.d.ts +0 -14
- package/dist/services/sync/source-definitions/asana.js +0 -42
- package/dist/services/sync/source-definitions/asana.js.map +0 -1
- package/dist/services/sync/source-definitions/definitions.d.ts +0 -8
- package/dist/services/sync/source-definitions/definitions.js +0 -8
- package/dist/services/sync/source-definitions/definitions.js.map +0 -1
- package/dist/services/sync/source-definitions/gdrive.d.ts +0 -16
- package/dist/services/sync/source-definitions/gdrive.js +0 -68
- package/dist/services/sync/source-definitions/gdrive.js.map +0 -1
- package/dist/services/sync/source-definitions/granola.d.ts +0 -2
- package/dist/services/sync/source-definitions/granola.js +0 -21
- package/dist/services/sync/source-definitions/granola.js.map +0 -1
- package/dist/services/sync/source-definitions/linear.d.ts +0 -2
- package/dist/services/sync/source-definitions/linear.js +0 -62
- package/dist/services/sync/source-definitions/linear.js.map +0 -1
- package/dist/services/sync/source-definitions/obsidian.d.ts +0 -2
- package/dist/services/sync/source-definitions/obsidian.js +0 -55
- package/dist/services/sync/source-definitions/obsidian.js.map +0 -1
- package/dist/services/sync/source-definitions/pipedrive.d.ts +0 -2
- package/dist/services/sync/source-definitions/pipedrive.js +0 -43
- package/dist/services/sync/source-definitions/pipedrive.js.map +0 -1
- package/dist/services/sync/staging.d.ts +0 -53
- package/dist/services/sync/staging.js +0 -130
- package/dist/services/sync/staging.js.map +0 -1
- package/dist/services/sync/structured-extractor.d.ts +0 -57
- package/dist/services/sync/structured-extractor.js +0 -584
- package/dist/services/sync/structured-extractor.js.map +0 -1
- package/dist/services/sync/sync-runner.d.ts +0 -32
- package/dist/services/sync/sync-runner.js +0 -195
- package/dist/services/sync/sync-runner.js.map +0 -1
- package/dist/services/sync/sync-state.d.ts +0 -43
- package/dist/services/sync/sync-state.js +0 -154
- package/dist/services/sync/sync-state.js.map +0 -1
- package/dist/services/sync/types.d.ts +0 -381
- package/dist/services/sync/types.js +0 -8
- package/dist/services/sync/types.js.map +0 -1
- package/dist/services/sync/unstructured-extractor.d.ts +0 -27
- package/dist/services/sync/unstructured-extractor.js +0 -185
- package/dist/services/sync/unstructured-extractor.js.map +0 -1
- package/dist/utils/merge-resolver.d.ts +0 -59
- package/dist/utils/merge-resolver.js +0 -303
- package/dist/utils/merge-resolver.js.map +0 -1
- package/dist/utils/workspace-config.d.ts +0 -8
- package/dist/utils/workspace-config.js +0 -22
- package/dist/utils/workspace-config.js.map +0 -1
- package/dist/web/_app/immutable/assets/0.DdizXOKi.css +0 -1
- package/dist/web/_app/immutable/assets/10.BUrHkYry.css +0 -1
- package/dist/web/_app/immutable/assets/2.n7-yW_Fs.css +0 -1
- package/dist/web/_app/immutable/assets/3.BtaZagnv.css +0 -1
- package/dist/web/_app/immutable/assets/4.DT7X0x5S.css +0 -1
- package/dist/web/_app/immutable/assets/5.DFeGxLYf.css +0 -1
- package/dist/web/_app/immutable/assets/6.CquhUpOu.css +0 -1
- package/dist/web/_app/immutable/assets/7.CjbDRbuG.css +0 -1
- package/dist/web/_app/immutable/assets/8.S1QdUGNM.css +0 -1
- package/dist/web/_app/immutable/assets/9.CT4xL4K3.css +0 -1
- package/dist/web/_app/immutable/assets/Copy.FS8bdfxr.css +0 -1
- package/dist/web/_app/immutable/assets/Toaster.rN8r_Hzv.css +0 -1
- package/dist/web/_app/immutable/assets/ViewToolbar.D-QW2oKe.css +0 -1
- package/dist/web/_app/immutable/assets/index.D6tMDJWk.css +0 -1
- package/dist/web/_app/immutable/chunks/-iaeBIWN.js +0 -1
- package/dist/web/_app/immutable/chunks/37NdyH6G.js +0 -32
- package/dist/web/_app/immutable/chunks/4Hhzb6pv.js +0 -1
- package/dist/web/_app/immutable/chunks/72bZS3G9.js +0 -1
- package/dist/web/_app/immutable/chunks/7S2LGqoP.js +0 -2
- package/dist/web/_app/immutable/chunks/B340SUKR.js +0 -1
- package/dist/web/_app/immutable/chunks/B3Z4_Sps.js +0 -1
- package/dist/web/_app/immutable/chunks/BB_5th5W.js +0 -3383
- package/dist/web/_app/immutable/chunks/BPWYOQXG.js +0 -1
- package/dist/web/_app/immutable/chunks/BR77jbfR.js +0 -1
- package/dist/web/_app/immutable/chunks/BS2rFAVq.js +0 -1
- package/dist/web/_app/immutable/chunks/BSsDC_p4.js +0 -1
- package/dist/web/_app/immutable/chunks/BTX2Jr8_.js +0 -1
- package/dist/web/_app/immutable/chunks/Bq_KShUL.js +0 -4
- package/dist/web/_app/immutable/chunks/Bsacq2UX.js +0 -1
- package/dist/web/_app/immutable/chunks/ByunV8un.js +0 -1
- package/dist/web/_app/immutable/chunks/BzPu-Eht.js +0 -1
- package/dist/web/_app/immutable/chunks/C7VoTosa.js +0 -2
- package/dist/web/_app/immutable/chunks/CDV5Q7RN.js +0 -1
- package/dist/web/_app/immutable/chunks/CGc1sIb_.js +0 -1
- package/dist/web/_app/immutable/chunks/CJ8__CWt.js +0 -1
- package/dist/web/_app/immutable/chunks/CJUKmosC.js +0 -5
- package/dist/web/_app/immutable/chunks/CSVbGg_b.js +0 -5
- package/dist/web/_app/immutable/chunks/CT6oIU-C.js +0 -1
- package/dist/web/_app/immutable/chunks/CTRxNfZk.js +0 -1
- package/dist/web/_app/immutable/chunks/CWQRQXxy.js +0 -1
- package/dist/web/_app/immutable/chunks/CX87mIM8.js +0 -1
- package/dist/web/_app/immutable/chunks/CXH6iFbA.js +0 -1
- package/dist/web/_app/immutable/chunks/CX_61fY8.js +0 -5
- package/dist/web/_app/immutable/chunks/CYrVHOHA.js +0 -1
- package/dist/web/_app/immutable/chunks/CdeYcEuU.js +0 -1
- package/dist/web/_app/immutable/chunks/CmCtpZ1Y.js +0 -1
- package/dist/web/_app/immutable/chunks/Cpsr8-Xy.js +0 -1
- package/dist/web/_app/immutable/chunks/CqkleIqs.js +0 -1
- package/dist/web/_app/immutable/chunks/CrdV0ttd.js +0 -1
- package/dist/web/_app/immutable/chunks/CscoF-YL.js +0 -18
- package/dist/web/_app/immutable/chunks/Cx4YdFMk.js +0 -1
- package/dist/web/_app/immutable/chunks/D7ZqAKi9.js +0 -3
- package/dist/web/_app/immutable/chunks/DGbA7IXh.js +0 -2
- package/dist/web/_app/immutable/chunks/DTZE-yoq.js +0 -2
- package/dist/web/_app/immutable/chunks/DbbB6Up5.js +0 -1
- package/dist/web/_app/immutable/chunks/DnL9f0lc.js +0 -7
- package/dist/web/_app/immutable/chunks/DtM5cEDu.js +0 -1
- package/dist/web/_app/immutable/chunks/Eqahi7_S.js +0 -2
- package/dist/web/_app/immutable/chunks/O9Eb9k00.js +0 -1
- package/dist/web/_app/immutable/chunks/PPVm8Dsz.js +0 -1
- package/dist/web/_app/immutable/chunks/QF8MAmnc.js +0 -1
- package/dist/web/_app/immutable/chunks/UjzxCpxn.js +0 -1
- package/dist/web/_app/immutable/chunks/WSUKABI_.js +0 -1
- package/dist/web/_app/immutable/chunks/Y90OgS-9.js +0 -1
- package/dist/web/_app/immutable/chunks/cLyZlkXv.js +0 -1
- package/dist/web/_app/immutable/chunks/iDtAARVW.js +0 -2
- package/dist/web/_app/immutable/chunks/oC_W7W7p.js +0 -1
- package/dist/web/_app/immutable/chunks/rJdWIgh-.js +0 -1
- package/dist/web/_app/immutable/chunks/tvOsokaa.js +0 -1
- package/dist/web/_app/immutable/chunks/uLEXaPwE.js +0 -1
- package/dist/web/_app/immutable/chunks/vSaooFHB.js +0 -1
- package/dist/web/_app/immutable/entry/app.BeUKh4sD.js +0 -2
- package/dist/web/_app/immutable/entry/start.CZJnFuQn.js +0 -1
- package/dist/web/_app/immutable/nodes/0.DyF_RsLg.js +0 -2
- package/dist/web/_app/immutable/nodes/1.7iDQmMPh.js +0 -1
- package/dist/web/_app/immutable/nodes/10.Btl8d8HT.js +0 -1
- package/dist/web/_app/immutable/nodes/2.LDRE62jN.js +0 -168
- package/dist/web/_app/immutable/nodes/3.BaW1XB1x.js +0 -1
- package/dist/web/_app/immutable/nodes/4.D0Q8kpkI.js +0 -12
- package/dist/web/_app/immutable/nodes/5.n7j2UG9h.js +0 -4
- package/dist/web/_app/immutable/nodes/6.DQYxR0iy.js +0 -2
- package/dist/web/_app/immutable/nodes/7.BsURvFAp.js +0 -2
- package/dist/web/_app/immutable/nodes/8.CsiErG0p.js +0 -1
- package/dist/web/_app/immutable/nodes/9.CnN6OZgC.js +0 -1
package/dist/mcp/tools.js
CHANGED
|
@@ -5,11 +5,36 @@
|
|
|
5
5
|
* methods — no new business logic. Results are returned as JSON text so the
|
|
6
6
|
* MCP client (Claude Desktop) can process structured data.
|
|
7
7
|
*
|
|
8
|
+
* Every tool enforces per-user access control via `services/access-control.ts`.
|
|
9
|
+
* Callers (the HTTP /mcp route, the stdio MCP server) must resolve a user
|
|
10
|
+
* identity before registering tools — `registerTools` requires a user in its
|
|
11
|
+
* `McpAccessContext` argument so there is no anonymous MCP path.
|
|
12
|
+
*
|
|
8
13
|
* Note: `inputSchema` is cast to `any` at each call site because the MCP SDK's
|
|
9
14
|
* ZodRawShapeCompat type does not accept ZodObject in TypeScript's strict mode.
|
|
10
15
|
* Runtime schema validation is handled correctly by the SDK regardless.
|
|
11
16
|
*/
|
|
12
17
|
import { z } from 'zod';
|
|
18
|
+
import { ENTITY_SCHEMAS } from '../core/validation.js';
|
|
19
|
+
import { getAccessibleRepos, hasRepoAccess, canWriteRepo, getAccessibleEntityIds, filterWikilinks, } from '../services/access-control.js';
|
|
20
|
+
import { createSharedFolder, FolderCreationError } from '../services/folder-creation.js';
|
|
21
|
+
import { validateFolderPath } from '../core/folder-paths.js';
|
|
22
|
+
import { existsSync } from 'fs';
|
|
23
|
+
import { join } from 'path';
|
|
24
|
+
import { isCuratedEntityType } from '../core/entity-types-catalog.js';
|
|
25
|
+
import { getAgentAllowedEntityTypes } from '../agent/prompts/entity-types-section.js';
|
|
26
|
+
import * as commentVirtualEntity from './comment-virtual-entity.js';
|
|
27
|
+
import { buildActor, prepareCreatePayload, prepareUpdatePayload, diagnosedUpdate, DroppedAssetError, assertEntityRefs, } from '../services/entity-mutations.js';
|
|
28
|
+
import { BridgeError, validateUserHandleInPayload, assertCanChangeUserHandle } from '../services/user-person-bridge.js';
|
|
29
|
+
import { extractAssetEmbeds, stripFrontmatter, assetEmbed } from '../core/embeds.js';
|
|
30
|
+
import { listRepoAssets } from '../services/asset-listing.js';
|
|
31
|
+
import { presignAssetUpload } from '../services/asset-presign-service.js';
|
|
32
|
+
import { finalizeAssetUpload } from '../services/asset-finalize-service.js';
|
|
33
|
+
import { importAssetAsEntity } from '../services/asset-import-service.js';
|
|
34
|
+
import { AssetUploadError } from '../services/asset-upload-errors.js';
|
|
35
|
+
import { presignMimeAllowlist, inlineUploadMimeAllowlist, resolveFormat, isInlineUploadAllowed } from '../core/format-registry.js';
|
|
36
|
+
import { resolveWorkspaceAssetsRepo } from '../services/workspace-assets-folder.js';
|
|
37
|
+
import { Workspace } from '../core/workspace.js';
|
|
13
38
|
// ── helpers ───────────────────────────────────────────────────────────────────
|
|
14
39
|
function ok(data) {
|
|
15
40
|
return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
|
|
@@ -18,30 +43,198 @@ function fail(err) {
|
|
|
18
43
|
const msg = err instanceof Error ? err.message : String(err);
|
|
19
44
|
return { content: [{ type: 'text', text: msg }], isError: true };
|
|
20
45
|
}
|
|
46
|
+
/** Deny-without-leaking helper — same wording as a missing repo/entity. */
|
|
47
|
+
function notFound(repo) {
|
|
48
|
+
return fail(new Error(`Folder "${repo}" not found`));
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Map an AssetUploadError (or any Error with a stable `code` discriminator)
|
|
52
|
+
* onto the MCP `fail()` envelope, embedding the code so the client can
|
|
53
|
+
* branch programmatically. Wraps `fail()` rather than replacing it so any
|
|
54
|
+
* non-typed error falls through to the existing "unknown" path.
|
|
55
|
+
*
|
|
56
|
+
* The code makes its way into the text payload as a JSON object — MCP
|
|
57
|
+
* clients that parse the text get a structured shape; pure-text consumers
|
|
58
|
+
* still get a readable line.
|
|
59
|
+
*/
|
|
60
|
+
function errorToMcpResult(err) {
|
|
61
|
+
if (err instanceof AssetUploadError) {
|
|
62
|
+
return {
|
|
63
|
+
content: [{
|
|
64
|
+
type: 'text',
|
|
65
|
+
text: JSON.stringify({ error: err.message, code: err.code }, null, 2),
|
|
66
|
+
}],
|
|
67
|
+
isError: true,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return fail(err);
|
|
71
|
+
}
|
|
21
72
|
// Strip frontmatter fields that duplicate the top-level id/type keys
|
|
22
73
|
function shape(id, entityType, data, extra) {
|
|
23
74
|
const { id: _id, entity_type: _et, ...rest } = data;
|
|
24
75
|
return { id, type: entityType, ...rest, ...extra };
|
|
25
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Default subfolders for entity types when the caller omits `folder_path`.
|
|
79
|
+
* Existing entries with no folder live at the repo root; new entries of these
|
|
80
|
+
* types route into a typed subfolder so the repo stays organised by default.
|
|
81
|
+
* An explicit `folder_path: ""` (or any explicit value) overrides this map.
|
|
82
|
+
*/
|
|
83
|
+
const DEFAULT_FOLDER_BY_TYPE = {
|
|
84
|
+
person: 'People',
|
|
85
|
+
organization: 'Organizations',
|
|
86
|
+
};
|
|
87
|
+
/** Convert an absolute entity path to a repo-relative POSIX path. */
|
|
88
|
+
function relPathOf(absPath, repoRoot) {
|
|
89
|
+
return absPath.startsWith(repoRoot + '/') ? absPath.slice(repoRoot.length + 1) : absPath;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Presign MIME enum for `create_asset_upload`, derived from the format registry
|
|
93
|
+
* (P4-V1) so the tool's accepted set can't drift from the presign service's gate.
|
|
94
|
+
* z.enum needs a non-empty tuple; the registry always yields ≥1 image MIME, but
|
|
95
|
+
* fall back to png/jpeg defensively so a registry edit can never produce an
|
|
96
|
+
* empty enum that throws at module load.
|
|
97
|
+
*/
|
|
98
|
+
const PRESIGN_MIME_TUPLE = (() => {
|
|
99
|
+
const mimes = presignMimeAllowlist();
|
|
100
|
+
return mimes.length > 0 ? mimes : ['image/png', 'image/jpeg'];
|
|
101
|
+
})();
|
|
102
|
+
/** Inline-upload (upload_asset_inline) caps + accepted-MIME display list,
|
|
103
|
+
* computed once at module load from the registry (not per /mcp request). */
|
|
104
|
+
const INLINE_MAX_BYTES = 6 * 1024 * 1024; // ~4.5MB pre-base64; keeps the model payload sane.
|
|
105
|
+
const INLINE_UPLOAD_MIME_LIST = inlineUploadMimeAllowlist().sort();
|
|
26
106
|
// ── tool registration ─────────────────────────────────────────────────────────
|
|
27
|
-
export function registerTools(server, wm, authService) {
|
|
107
|
+
export function registerTools(server, wm, authService, ctx) {
|
|
108
|
+
const { user, wsHub, apiTokenName, commentService } = ctx;
|
|
109
|
+
// External-agent identity: "<owner>'s <token name>", or "<owner>'s agent"
|
|
110
|
+
// as a fallback when the token has no name (older tokens or contexts that
|
|
111
|
+
// didn't thread the token through). `userId` lets the client paint the chip
|
|
112
|
+
// with the same accent as the owning user's avatar.
|
|
113
|
+
const agentLabel = apiTokenName
|
|
114
|
+
? `${user.displayName}'s ${apiTokenName}`
|
|
115
|
+
: `${user.displayName}'s agent`;
|
|
116
|
+
const agentIdentity = {
|
|
117
|
+
kind: 'external',
|
|
118
|
+
label: agentLabel,
|
|
119
|
+
userId: String(user.id),
|
|
120
|
+
};
|
|
121
|
+
// Match the broadcast shape used by src/server/routes/graph-api.ts so the
|
|
122
|
+
// realtime listener in web/src/lib/stores/realtime.svelte.ts treats MCP
|
|
123
|
+
// mutations identically to web-UI mutations. The `agent` tag lets clients
|
|
124
|
+
// distinguish agent-driven mutations from human-driven ones.
|
|
125
|
+
function emitEntityChange(action, repo, entityType, entityId) {
|
|
126
|
+
wsHub?.broadcast({
|
|
127
|
+
type: 'entity_change',
|
|
128
|
+
action,
|
|
129
|
+
repo,
|
|
130
|
+
entityType,
|
|
131
|
+
entityId,
|
|
132
|
+
actor: user.displayName,
|
|
133
|
+
source: 'api',
|
|
134
|
+
agent: agentIdentity,
|
|
135
|
+
timestamp: new Date().toISOString(),
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Wrap a mutation tool call so the sidebar can show a live "X's agent is
|
|
140
|
+
* acting" chip in the affected folder. `enter` fires before the work,
|
|
141
|
+
* `leave` after — wsHub TTL-cleans on crash. `verb` shapes the chip copy.
|
|
142
|
+
*/
|
|
143
|
+
async function withAgentActivity(repo, verb, fn) {
|
|
144
|
+
wsHub?.handleAgentActivity('enter', repo, agentIdentity, verb);
|
|
145
|
+
try {
|
|
146
|
+
return await fn();
|
|
147
|
+
}
|
|
148
|
+
finally {
|
|
149
|
+
wsHub?.handleAgentActivity('leave', repo, agentIdentity, verb);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
// Entity types the MCP surface may create. Matches the agent's allowlist so
|
|
153
|
+
// a workspace looks identical across the main app and MCP clients: the full
|
|
154
|
+
// canonical catalog plus workspace custom types. See
|
|
155
|
+
// src/core/entity-types-catalog.ts.
|
|
156
|
+
const builtinTypeKeys = new Set(Object.keys(ENTITY_SCHEMAS));
|
|
157
|
+
const customWorkspaceTypes = wm.getSchemaRegistry().getAllTypes()
|
|
158
|
+
.filter(t => !builtinTypeKeys.has(t));
|
|
159
|
+
const mcpAllowedCreateTypes = getAgentAllowedEntityTypes(customWorkspaceTypes);
|
|
160
|
+
const mcpAllowedSet = new Set(mcpAllowedCreateTypes);
|
|
28
161
|
// ── list_repos ────────────────────────────────────────────────────────────
|
|
29
|
-
server.registerTool('list_repos', { description: 'List
|
|
162
|
+
server.registerTool('list_repos', { description: 'List folders in the Studiograph workspace that you have access to' }, async () => ok(getAccessibleRepos(user, wm, authService)));
|
|
163
|
+
// ── create_repo ───────────────────────────────────────────────────────────
|
|
164
|
+
//
|
|
165
|
+
// Creates a new shared folder in the workspace and grants the
|
|
166
|
+
// caller folder-admin access. Shares its implementation with the web route
|
|
167
|
+
// POST /api/repos via services/folder-creation.ts so both surfaces behave
|
|
168
|
+
// identically. After creation, use create_entity with the new folder name
|
|
169
|
+
// to add entries. Folder names are immutable slugs; the display name is
|
|
170
|
+
// editable later via the web UI.
|
|
171
|
+
const createRepoSchema = z.object({
|
|
172
|
+
name: z.string().describe('Folder slug — lowercase kebab-case (letters, digits, hyphens; must start with a letter or digit). ' +
|
|
173
|
+
'This becomes the folder id and directory name; it cannot be changed without a rename.'),
|
|
174
|
+
display_name: z.string().optional().describe('Human-readable name shown in the UI (e.g. "Client Projects"). Defaults to the slug.'),
|
|
175
|
+
description: z.string().optional().describe('Short description of what this folder is for.'),
|
|
176
|
+
});
|
|
177
|
+
server.registerTool('create_repo', {
|
|
178
|
+
description: 'Create a new shared folder in the workspace. Use this when an agent or ' +
|
|
179
|
+
'user needs a fresh container for a new project, client area, or topic and no existing ' +
|
|
180
|
+
'folder fits. The caller is automatically granted folder-admin access. ' +
|
|
181
|
+
'Follow up with create_entity (passing the new folder name as `repo`) to seed entries. ' +
|
|
182
|
+
'Folder names must be kebab-case and unique; the private per-user "entries-<id>" ' +
|
|
183
|
+
'namespace is reserved and will be rejected.',
|
|
184
|
+
inputSchema: createRepoSchema,
|
|
185
|
+
}, async (args) => {
|
|
186
|
+
const { name, display_name, description } = createRepoSchema.parse(args);
|
|
187
|
+
try {
|
|
188
|
+
const repo = await createSharedFolder(wm, authService, { name, display_name, description }, user, wsHub);
|
|
189
|
+
return ok({ success: true, ...repo });
|
|
190
|
+
}
|
|
191
|
+
catch (err) {
|
|
192
|
+
if (err instanceof FolderCreationError) {
|
|
193
|
+
return fail(new Error(err.message));
|
|
194
|
+
}
|
|
195
|
+
return fail(err);
|
|
196
|
+
}
|
|
197
|
+
});
|
|
30
198
|
// ── list_entities ─────────────────────────────────────────────────────────
|
|
31
199
|
const listEntitiesSchema = z.object({
|
|
32
|
-
repo: z.string().optional().describe('
|
|
33
|
-
entity_type: z.string().optional().describe('Entity type filter (project, client, person,
|
|
200
|
+
repo: z.string().optional().describe('Folder name — omit to list across all folders'),
|
|
201
|
+
entity_type: z.string().optional().describe('Entity type filter (project, client, person, event…)'),
|
|
34
202
|
limit: z.number().int().positive().optional().describe('Maximum number of results'),
|
|
35
203
|
});
|
|
36
|
-
server.registerTool('list_entities', { description: 'List entities in a
|
|
204
|
+
server.registerTool('list_entities', { description: 'List entities in a folder (or all folders). Optionally filter by entity type.', inputSchema: listEntitiesSchema }, async (args) => {
|
|
37
205
|
const { repo, entity_type, limit } = listEntitiesSchema.parse(args);
|
|
38
206
|
try {
|
|
207
|
+
// Comments live in SQLite, not the filesystem graph — dispatch through
|
|
208
|
+
// the virtual-entity adapter when the caller asks for them explicitly.
|
|
209
|
+
if (entity_type === 'comment' && commentService) {
|
|
210
|
+
if (repo && !hasRepoAccess(user, repo, wm, authService))
|
|
211
|
+
return notFound(repo);
|
|
212
|
+
const accessibleNames = new Set(getAccessibleRepos(user, wm, authService).map(r => r.name));
|
|
213
|
+
const envelopes = commentVirtualEntity.listComments(commentService, { repo, limit });
|
|
214
|
+
const filtered = envelopes.filter(e => accessibleNames.has(e.data.repo));
|
|
215
|
+
return ok(filtered.map(e => shape(e.id, e.entityType, e.data, { repo: e.data.repo })));
|
|
216
|
+
}
|
|
39
217
|
if (repo) {
|
|
218
|
+
if (!hasRepoAccess(user, repo, wm, authService))
|
|
219
|
+
return notFound(repo);
|
|
40
220
|
const entities = wm.getGraph(repo).list(entity_type, limit);
|
|
41
221
|
return ok(entities.map(e => shape(e.id, e.entityType, e.data)));
|
|
42
222
|
}
|
|
43
|
-
|
|
44
|
-
|
|
223
|
+
// No repo specified → iterate only over the user's accessible folders.
|
|
224
|
+
const accessible = getAccessibleRepos(user, wm, authService);
|
|
225
|
+
const results = [];
|
|
226
|
+
for (const r of accessible) {
|
|
227
|
+
try {
|
|
228
|
+
const list = wm.getGraph(r.name).list(entity_type);
|
|
229
|
+
for (const e of list) {
|
|
230
|
+
results.push(shape(e.id, e.entityType, e.data, { repo: r.name }));
|
|
231
|
+
if (limit && results.length >= limit)
|
|
232
|
+
return ok(results);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
catch { /* skip unmounted repos */ }
|
|
236
|
+
}
|
|
237
|
+
return ok(results);
|
|
45
238
|
}
|
|
46
239
|
catch (err) {
|
|
47
240
|
return fail(err);
|
|
@@ -49,15 +242,34 @@ export function registerTools(server, wm, authService) {
|
|
|
49
242
|
});
|
|
50
243
|
// ── get_entity ────────────────────────────────────────────────────────────
|
|
51
244
|
const getEntitySchema = z.object({
|
|
52
|
-
repo: z.string().describe('
|
|
245
|
+
repo: z.string().describe('Folder name'),
|
|
53
246
|
entity_type: z.string().describe('Entity type (project, client, person…)'),
|
|
54
247
|
entity_id: z.string().describe('Entity ID (kebab-case slug)'),
|
|
55
248
|
});
|
|
56
249
|
server.registerTool('get_entity', { description: 'Get a specific entity — includes full markdown content and frontmatter', inputSchema: getEntitySchema }, async (args) => {
|
|
57
250
|
const { repo, entity_type, entity_id } = getEntitySchema.parse(args);
|
|
251
|
+
if (!hasRepoAccess(user, repo, wm, authService))
|
|
252
|
+
return notFound(repo);
|
|
58
253
|
try {
|
|
59
|
-
|
|
60
|
-
|
|
254
|
+
if (entity_type === 'comment' && commentService) {
|
|
255
|
+
const envelope = commentVirtualEntity.getComment(commentService, entity_id);
|
|
256
|
+
if (!envelope)
|
|
257
|
+
return fail(new Error(`Comment "${entity_id}" not found`));
|
|
258
|
+
if (envelope.data.repo !== repo)
|
|
259
|
+
return notFound(repo);
|
|
260
|
+
return ok({ id: envelope.id, type: envelope.entityType, data: envelope.data, content: envelope.document.content });
|
|
261
|
+
}
|
|
262
|
+
const graph = wm.getGraph(repo);
|
|
263
|
+
const entity = graph.get(entity_type, entity_id);
|
|
264
|
+
// Prefer the live editor body when a seeded Y.Doc is open: graph.get
|
|
265
|
+
// reads disk, which lags the editor by the autosave debounce, so a
|
|
266
|
+
// user's freshly-placed image/asset embed may not be on disk yet.
|
|
267
|
+
// Returning disk content here is what let agents edit-then-overwrite
|
|
268
|
+
// and silently drop those embeds. null => no live doc, disk is
|
|
269
|
+
// authoritative.
|
|
270
|
+
const liveBody = graph.getLiveBody(entity_type, entity_id);
|
|
271
|
+
const content = liveBody ?? entity.document.content;
|
|
272
|
+
return ok({ id: entity.id, type: entity.entityType, data: entity.data, content });
|
|
61
273
|
}
|
|
62
274
|
catch (err) {
|
|
63
275
|
return fail(err);
|
|
@@ -67,13 +279,19 @@ export function registerTools(server, wm, authService) {
|
|
|
67
279
|
const searchSchema = z.object({
|
|
68
280
|
query: z.string().optional().describe('Text search query'),
|
|
69
281
|
entity_type: z.string().optional().describe('Filter by entity type'),
|
|
70
|
-
repos: z.array(z.string()).optional().describe('Limit to specific
|
|
282
|
+
repos: z.array(z.string()).optional().describe('Limit to specific folder names'),
|
|
71
283
|
limit: z.number().int().positive().optional().describe('Maximum number of results'),
|
|
72
284
|
});
|
|
73
|
-
server.registerTool('search_entities', { description: 'Full-text search for entities across
|
|
285
|
+
server.registerTool('search_entities', { description: 'Full-text search for entities across folders you can access', inputSchema: searchSchema }, async (args) => {
|
|
74
286
|
const { query, entity_type, repos, limit } = searchSchema.parse(args);
|
|
75
287
|
try {
|
|
76
|
-
const
|
|
288
|
+
const accessibleNames = new Set(getAccessibleRepos(user, wm, authService).map(r => r.name));
|
|
289
|
+
const scoped = repos
|
|
290
|
+
? repos.filter(r => accessibleNames.has(r))
|
|
291
|
+
: [...accessibleNames];
|
|
292
|
+
if (scoped.length === 0)
|
|
293
|
+
return ok([]);
|
|
294
|
+
const results = await wm.search({ query, entityType: entity_type, repoNames: scoped, limit });
|
|
77
295
|
return ok(results.map(e => shape(e.id, e.entityType, e.data, { repo: e.repoName })));
|
|
78
296
|
}
|
|
79
297
|
catch (err) {
|
|
@@ -81,62 +299,808 @@ export function registerTools(server, wm, authService) {
|
|
|
81
299
|
}
|
|
82
300
|
});
|
|
83
301
|
// ── create_entity ─────────────────────────────────────────────────────────
|
|
302
|
+
// Constrain `entity_type` to the allowlist so MCP clients (e.g. Claude Desktop)
|
|
303
|
+
// see the same type surface as the main agent. Existing canonical-type entities
|
|
304
|
+
// remain readable/updatable via other tools.
|
|
305
|
+
const createEntityTypeSchema = mcpAllowedCreateTypes.length > 0
|
|
306
|
+
? z.enum(mcpAllowedCreateTypes)
|
|
307
|
+
: z.string();
|
|
84
308
|
const createSchema = z.object({
|
|
85
|
-
repo: z.string().describe('
|
|
86
|
-
entity_type:
|
|
309
|
+
repo: z.string().describe('Folder name'),
|
|
310
|
+
entity_type: createEntityTypeSchema.describe(`Entity type. Allowed: ${mcpAllowedCreateTypes.join(', ')}.`),
|
|
87
311
|
entity_id: z.string().describe('Entity ID (kebab-case slug)'),
|
|
88
|
-
data: z.record(z.unknown()).describe('
|
|
312
|
+
data: z.record(z.string(), z.unknown()).describe('Type-specific frontmatter fields (e.g. for person: name, email, organization, role). ' +
|
|
313
|
+
'Base fields (entity_id, entity_type, created_at, updated_at, created_by, updated_by) ' +
|
|
314
|
+
'are stamped automatically — do not include them.'),
|
|
89
315
|
content: z.string().optional().describe('Markdown body content'),
|
|
316
|
+
folder_path: z.string().optional().describe('Repo-relative subfolder to place the entry in (e.g. "People", "clients/acme"). ' +
|
|
317
|
+
'Omit to use the per-type default (person → People, organization → Organizations); ' +
|
|
318
|
+
'pass an empty string to force the repo root. Parent folders are auto-created.'),
|
|
90
319
|
});
|
|
91
|
-
server.registerTool('create_entity', {
|
|
92
|
-
|
|
320
|
+
server.registerTool('create_entity', {
|
|
321
|
+
description: 'Create a new entity in a folder. Commits to git automatically. ' +
|
|
322
|
+
'Base frontmatter (entity_id, created_at, updated_at, created_by, updated_by) is ' +
|
|
323
|
+
'stamped automatically — `data` should only carry type-specific fields. ' +
|
|
324
|
+
'For person entries, `status` accepts synonyms (active/prospective/inactive/past/etc.) ' +
|
|
325
|
+
'and normalizes to `current` | `former`; defaults to `current` when omitted. ' +
|
|
326
|
+
'Without `folder_path`, person entries route to People/ and organization entries to Organizations/; ' +
|
|
327
|
+
'other types land at the repo root. Pass `folder_path: ""` to force the repo root, ' +
|
|
328
|
+
'or any subfolder string (e.g. "Clients/Acme") to place it explicitly. ' +
|
|
329
|
+
'Response includes the final repo-relative `path`.',
|
|
330
|
+
inputSchema: createSchema,
|
|
331
|
+
}, async (args) => {
|
|
332
|
+
const { repo, entity_type, entity_id, data, content, folder_path } = createSchema.parse(args);
|
|
333
|
+
if (!hasRepoAccess(user, repo, wm, authService))
|
|
334
|
+
return notFound(repo);
|
|
335
|
+
if (!canWriteRepo(user, repo, wm, authService)) {
|
|
336
|
+
return fail(new Error(`You do not have write access to folder "${repo}"`));
|
|
337
|
+
}
|
|
338
|
+
// Defense in depth: MCP SDK may not enforce zod enum strictly on all clients.
|
|
339
|
+
if (!mcpAllowedSet.has(entity_type)) {
|
|
340
|
+
const hint = isCuratedEntityType(entity_type)
|
|
341
|
+
? '' // shouldn't happen for any other curated type — they're all allowed
|
|
342
|
+
: ` Allowed: ${mcpAllowedCreateTypes.join(', ')}.`;
|
|
343
|
+
return fail(new Error(`Entity type "${entity_type}" is not a known canonical or workspace custom type.${hint}`));
|
|
344
|
+
}
|
|
345
|
+
// Explicit folder_path (including "") wins; otherwise apply the per-type
|
|
346
|
+
// default so the agent doesn't have to know the workspace convention.
|
|
347
|
+
const effectiveFolder = folder_path !== undefined
|
|
348
|
+
? folder_path
|
|
349
|
+
: (DEFAULT_FOLDER_BY_TYPE[entity_type] ?? '');
|
|
350
|
+
// Enforce the user↔person bridge invariant on person creates, matching
|
|
351
|
+
// graph-api + graph-tools: at most one person entity per auth handle
|
|
352
|
+
// workspace-wide (validateUserHandleInPayload), and only a workspace
|
|
353
|
+
// owner may stamp a handle (assertCanChangeUserHandle). Without this,
|
|
354
|
+
// create_entity over MCP was the one write path that could plant a
|
|
355
|
+
// SECOND linked record — violating "multiple person entries, but only
|
|
356
|
+
// one linked".
|
|
357
|
+
if (entity_type === 'person') {
|
|
358
|
+
try {
|
|
359
|
+
const incoming = (data ?? {});
|
|
360
|
+
validateUserHandleInPayload(wm, incoming);
|
|
361
|
+
if (Object.prototype.hasOwnProperty.call(incoming, 'user_handle')) {
|
|
362
|
+
assertCanChangeUserHandle(user, '', incoming.user_handle);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
catch (err) {
|
|
366
|
+
if (err instanceof BridgeError)
|
|
367
|
+
return fail(err);
|
|
368
|
+
throw err;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
// Scope ref fields (today: task.assignee → person). Reject a wikilink
|
|
372
|
+
// that resolves to a non-person; forward references are allowed.
|
|
93
373
|
try {
|
|
94
|
-
|
|
95
|
-
entityType: entity_type,
|
|
96
|
-
entityId: entity_id,
|
|
97
|
-
data: data,
|
|
98
|
-
content,
|
|
99
|
-
});
|
|
100
|
-
return ok({ success: true, id: entity.id, type: entity.entityType });
|
|
374
|
+
assertEntityRefs(wm, entity_type, data, { userExists: (id) => !!authService.findUserById(Number(id)) });
|
|
101
375
|
}
|
|
102
376
|
catch (err) {
|
|
103
377
|
return fail(err);
|
|
104
378
|
}
|
|
379
|
+
const actor = buildActor(user);
|
|
380
|
+
const options = prepareCreatePayload({
|
|
381
|
+
entityType: entity_type,
|
|
382
|
+
entityId: entity_id,
|
|
383
|
+
data: data,
|
|
384
|
+
content,
|
|
385
|
+
folderPath: effectiveFolder || undefined,
|
|
386
|
+
}, actor);
|
|
387
|
+
return withAgentActivity(repo, 'creating', async () => {
|
|
388
|
+
try {
|
|
389
|
+
const graph = wm.getGraph(repo);
|
|
390
|
+
// Detect implicit subfolder creation: if the entity lands in a folder
|
|
391
|
+
// that didn't exist yet, the entity_change below only refreshes the
|
|
392
|
+
// entry list — clients need a _folder event to refetch the folder
|
|
393
|
+
// tree (sidebar + list/gallery folder rows). Normalize the same way
|
|
394
|
+
// graph.create does so the existence check matches the real path.
|
|
395
|
+
const normFolder = effectiveFolder ? validateFolderPath(effectiveFolder) : '';
|
|
396
|
+
const folderExisted = !normFolder || existsSync(join(graph.getRepoPath(), normFolder));
|
|
397
|
+
const entity = await graph.create(options);
|
|
398
|
+
emitEntityChange('created', repo, entity.entityType, entity.id);
|
|
399
|
+
if (!folderExisted)
|
|
400
|
+
emitEntityChange('created', repo, '_folder', normFolder);
|
|
401
|
+
return ok({
|
|
402
|
+
success: true,
|
|
403
|
+
id: entity.id,
|
|
404
|
+
type: entity.entityType,
|
|
405
|
+
repo,
|
|
406
|
+
path: relPathOf(entity.path, graph.getRepoPath()),
|
|
407
|
+
folder_path: entity.folder_path,
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
catch (err) {
|
|
411
|
+
return fail(err);
|
|
412
|
+
}
|
|
413
|
+
});
|
|
105
414
|
});
|
|
106
415
|
// ── update_entity ─────────────────────────────────────────────────────────
|
|
416
|
+
//
|
|
417
|
+
// Bare success envelopes were misleading agents: callers couldn't tell
|
|
418
|
+
// whether their write landed, whether validation silently dropped a field,
|
|
419
|
+
// or whether they'd just rewritten the file with identical bytes. The
|
|
420
|
+
// response now includes path, commit, before/after hashes, per-section
|
|
421
|
+
// changed flags, and the post-write entity snapshot so agents can verify
|
|
422
|
+
// their intent matches reality without a follow-up get_entity round-trip.
|
|
423
|
+
//
|
|
424
|
+
// No-op detection compares semantic frontmatter (excluding auto-stamped
|
|
425
|
+
// `updated_at` / `updated_by`) and raw content. A no-op is reported as
|
|
426
|
+
// success with `noop: true` — not an error — so idempotent re-runs are
|
|
427
|
+
// explicit. If the caller passed data or content but the on-disk file is
|
|
428
|
+
// byte-identical after the write, that's a silent-drop signal: the call
|
|
429
|
+
// fails loudly with a message that names which inputs were ignored.
|
|
107
430
|
const updateSchema = z.object({
|
|
108
|
-
repo: z.string().describe('
|
|
431
|
+
repo: z.string().describe('Folder name'),
|
|
109
432
|
entity_type: z.string().describe('Entity type'),
|
|
110
433
|
entity_id: z.string().describe('Entity ID'),
|
|
111
|
-
data: z.record(z.unknown()).optional().describe('Frontmatter fields to update (merged with existing)'),
|
|
112
|
-
content: z.string().optional().describe('New markdown body content'),
|
|
434
|
+
data: z.record(z.string(), z.unknown()).optional().describe('Frontmatter fields to update (merged with existing)'),
|
|
435
|
+
content: z.string().optional().describe('New markdown body content (replaces the entire body)'),
|
|
436
|
+
allow_image_removal: z.boolean().optional().describe('Whole-body writes are rejected with code ASSET_REMOVAL_BLOCKED when the submitted content would drop ' +
|
|
437
|
+
'image/attachment embeds that the current document still has (a common silent-data-loss bug when an agent ' +
|
|
438
|
+
'edits stale content). Set true ONLY when you intend to delete those embeds. Prefer patch_entity for small edits.'),
|
|
113
439
|
});
|
|
114
|
-
server.registerTool('update_entity', {
|
|
115
|
-
|
|
440
|
+
server.registerTool('update_entity', {
|
|
441
|
+
description: 'Update an existing entity. Data fields are merged with existing frontmatter; content replaces the markdown body. ' +
|
|
442
|
+
'Callers do not need to resend immutable base fields (entity_id, created_at, created_by) — they are preserved from disk. ' +
|
|
443
|
+
'`updated_at` and `updated_by` are stamped automatically. ' +
|
|
444
|
+
'For person entries, `status` synonyms are normalized to `current` | `former` when supplied. ' +
|
|
445
|
+
'Returns the post-write entity snapshot plus diagnostic flags (frontmatter_changed, content_changed, noop, commit) ' +
|
|
446
|
+
'so the caller can verify the change landed without a separate get_entity call.',
|
|
447
|
+
inputSchema: updateSchema,
|
|
448
|
+
}, async (args) => {
|
|
449
|
+
const { repo, entity_type, entity_id, data, content, allow_image_removal } = updateSchema.parse(args);
|
|
450
|
+
if (!hasRepoAccess(user, repo, wm, authService))
|
|
451
|
+
return notFound(repo);
|
|
452
|
+
if (!canWriteRepo(user, repo, wm, authService)) {
|
|
453
|
+
return fail(new Error(`You do not have write access to folder "${repo}"`));
|
|
454
|
+
}
|
|
455
|
+
if (data === undefined && content === undefined) {
|
|
456
|
+
return fail(new Error('update_entity requires at least one of `data` or `content`'));
|
|
457
|
+
}
|
|
458
|
+
// Enforce the user↔person bridge invariant on person updates, matching
|
|
459
|
+
// graph-api + graph-tools: workspace-wide handle uniqueness (skipping the
|
|
460
|
+
// entity being written) + owner-only authz to change `user_handle`. Keeps
|
|
461
|
+
// update_entity from becoming a back door around "only one linked record".
|
|
462
|
+
if (entity_type === 'person' && data) {
|
|
463
|
+
try {
|
|
464
|
+
const incoming = data;
|
|
465
|
+
validateUserHandleInPayload(wm, incoming, { repo, entityId: entity_id });
|
|
466
|
+
if (Object.prototype.hasOwnProperty.call(incoming, 'user_handle')) {
|
|
467
|
+
let currentHandle = '';
|
|
468
|
+
try {
|
|
469
|
+
currentHandle = (wm.getGraph(repo).get('person', entity_id)?.data?.user_handle ?? '');
|
|
470
|
+
}
|
|
471
|
+
catch { /* new/missing entity — treat as empty */ }
|
|
472
|
+
assertCanChangeUserHandle(user, currentHandle, incoming.user_handle);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
catch (err) {
|
|
476
|
+
if (err instanceof BridgeError)
|
|
477
|
+
return fail(err);
|
|
478
|
+
throw err;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
// Scope ref fields (today: task.assignee → person). Reject a wikilink
|
|
482
|
+
// that resolves to a non-person; forward references are allowed.
|
|
116
483
|
try {
|
|
117
|
-
|
|
118
|
-
entityType: entity_type,
|
|
119
|
-
entityId: entity_id,
|
|
120
|
-
data: data,
|
|
121
|
-
content,
|
|
122
|
-
});
|
|
123
|
-
return ok({ success: true, id: entity.id, type: entity.entityType });
|
|
484
|
+
assertEntityRefs(wm, entity_type, data, { userExists: (id) => !!authService.findUserById(Number(id)) });
|
|
124
485
|
}
|
|
125
486
|
catch (err) {
|
|
126
487
|
return fail(err);
|
|
127
488
|
}
|
|
489
|
+
const actor = buildActor(user);
|
|
490
|
+
const options = prepareUpdatePayload({
|
|
491
|
+
entityType: entity_type,
|
|
492
|
+
entityId: entity_id,
|
|
493
|
+
data: data,
|
|
494
|
+
content,
|
|
495
|
+
}, actor);
|
|
496
|
+
return withAgentActivity(repo, 'editing', async () => {
|
|
497
|
+
try {
|
|
498
|
+
const graph = wm.getGraph(repo);
|
|
499
|
+
// Diagnosed update (shared with the agent surface): snapshots
|
|
500
|
+
// before, runs the server-write path (disk + commit serialize via
|
|
501
|
+
// the per-doc lock; live clients get the post-commit broadcast),
|
|
502
|
+
// and throws SilentDropError when the caller intended a change
|
|
503
|
+
// that produced no on-disk diff. The outer catch maps that to fail.
|
|
504
|
+
const { entity, frontmatter_changed, content_changed, noop, broadcast } = await diagnosedUpdate(graph, options, { data, content }, { allowAssetRemoval: allow_image_removal });
|
|
505
|
+
emitEntityChange('updated', repo, entity.entityType, entity.id);
|
|
506
|
+
// Repo-relative path so external agents don't see the workspace
|
|
507
|
+
// absolute path. The HEAD commit is captured after graph.update
|
|
508
|
+
// commits the transaction — null when noGit is on or no commit
|
|
509
|
+
// was produced (e.g. transaction self-cleared because there was
|
|
510
|
+
// no staged diff).
|
|
511
|
+
const repoRoot = graph.getRepoPath();
|
|
512
|
+
const relPath = entity.path.startsWith(repoRoot + '/')
|
|
513
|
+
? entity.path.slice(repoRoot.length + 1)
|
|
514
|
+
: entity.path;
|
|
515
|
+
const commit = graph.getGitService()?.getHeadCommit() ?? null;
|
|
516
|
+
return ok({
|
|
517
|
+
success: true,
|
|
518
|
+
id: entity.id,
|
|
519
|
+
type: entity.entityType,
|
|
520
|
+
repo,
|
|
521
|
+
path: relPath,
|
|
522
|
+
commit,
|
|
523
|
+
frontmatter_changed,
|
|
524
|
+
content_changed,
|
|
525
|
+
noop,
|
|
526
|
+
broadcast,
|
|
527
|
+
updated_at: entity.data.updated_at ?? null,
|
|
528
|
+
entity: {
|
|
529
|
+
id: entity.id,
|
|
530
|
+
type: entity.entityType,
|
|
531
|
+
data: entity.data,
|
|
532
|
+
content: entity.document.content,
|
|
533
|
+
},
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
catch (err) {
|
|
537
|
+
if (err instanceof DroppedAssetError) {
|
|
538
|
+
return ok({
|
|
539
|
+
success: false,
|
|
540
|
+
code: 'ASSET_REMOVAL_BLOCKED',
|
|
541
|
+
droppedAssets: err.dropped,
|
|
542
|
+
message: err.message,
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
return fail(err);
|
|
546
|
+
}
|
|
547
|
+
});
|
|
548
|
+
});
|
|
549
|
+
// ── patch_entity ──────────────────────────────────────────────────────────
|
|
550
|
+
//
|
|
551
|
+
// Surgical body edit: replace an exact substring without resending the
|
|
552
|
+
// whole body. The motivating failure was an agent fetching content,
|
|
553
|
+
// renaming a heading, and resending the entire body — which dropped
|
|
554
|
+
// editor-placed image embeds it never saw. patch_entity can't drop what it
|
|
555
|
+
// doesn't send: it reads the CURRENT body (live editor when open, else
|
|
556
|
+
// disk), applies the literal find→replace, and writes the result through
|
|
557
|
+
// the same guarded server-write path. The asset-drop guard still runs, so
|
|
558
|
+
// a patch that happens to delete an embed is rejected unless the substring
|
|
559
|
+
// is itself the embed being intentionally removed.
|
|
560
|
+
const patchEntitySchema = z.object({
|
|
561
|
+
repo: z.string().describe('Folder name'),
|
|
562
|
+
entity_type: z.string().describe('Entity type'),
|
|
563
|
+
entity_id: z.string().describe('Entity ID'),
|
|
564
|
+
find: z.string().describe('Exact substring to locate in the current body (verbatim, including whitespace).'),
|
|
565
|
+
replace: z.string().describe('Replacement text. Empty string deletes the matched substring.'),
|
|
566
|
+
expected_count: z.number().int().positive().optional().describe('Optional safety check: require `find` to occur exactly this many times. The patch is rejected with ' +
|
|
567
|
+
'NO_MATCH / AMBIGUOUS_MATCH when the actual count differs, so you never edit the wrong occurrence.'),
|
|
568
|
+
});
|
|
569
|
+
server.registerTool('patch_entity', {
|
|
570
|
+
description: 'Surgically edit an entry body by replacing an exact substring — without rewriting the whole body. ' +
|
|
571
|
+
'Prefer this over update_entity for small edits (renaming a heading, fixing a sentence): it operates on ' +
|
|
572
|
+
'the live editor body and cannot drop image/asset embeds it did not touch. Returns the same diagnostic ' +
|
|
573
|
+
'flags as update_entity. Use `expected_count` to guard against ambiguous matches.',
|
|
574
|
+
inputSchema: patchEntitySchema,
|
|
575
|
+
}, async (args) => {
|
|
576
|
+
const { repo, entity_type, entity_id, find, replace, expected_count } = patchEntitySchema.parse(args);
|
|
577
|
+
if (!hasRepoAccess(user, repo, wm, authService))
|
|
578
|
+
return notFound(repo);
|
|
579
|
+
if (!canWriteRepo(user, repo, wm, authService)) {
|
|
580
|
+
return fail(new Error(`You do not have write access to folder "${repo}"`));
|
|
581
|
+
}
|
|
582
|
+
if (find === '')
|
|
583
|
+
return fail(new Error('patch_entity requires a non-empty `find` string'));
|
|
584
|
+
if (find === replace)
|
|
585
|
+
return fail(new Error('patch_entity `find` and `replace` are identical — nothing to do'));
|
|
586
|
+
return withAgentActivity(repo, 'editing', async () => {
|
|
587
|
+
try {
|
|
588
|
+
const graph = wm.getGraph(repo);
|
|
589
|
+
const entity = graph.get(entity_type, entity_id);
|
|
590
|
+
// Patch against the live editor body when one is open, so we don't
|
|
591
|
+
// reintroduce the stale-read problem we're fixing.
|
|
592
|
+
const currentBody = graph.getLiveBody(entity_type, entity_id) ?? entity.document.content;
|
|
593
|
+
// Count occurrences of the literal substring (no regex).
|
|
594
|
+
let count = 0;
|
|
595
|
+
for (let i = currentBody.indexOf(find); i !== -1; i = currentBody.indexOf(find, i + find.length))
|
|
596
|
+
count++;
|
|
597
|
+
if (count === 0) {
|
|
598
|
+
return ok({ success: false, code: 'NO_MATCH', message: `\`find\` substring not present in ${entity_type}/${entity_id}.` });
|
|
599
|
+
}
|
|
600
|
+
if (expected_count !== undefined && count !== expected_count) {
|
|
601
|
+
return ok({ success: false, code: 'AMBIGUOUS_MATCH', occurrences: count, message: `Expected ${expected_count} occurrence(s) of \`find\`, found ${count}.` });
|
|
602
|
+
}
|
|
603
|
+
const newBody = currentBody.split(find).join(replace);
|
|
604
|
+
const options = prepareUpdatePayload({ entityType: entity_type, entityId: entity_id, content: newBody }, buildActor(user));
|
|
605
|
+
const { entity: updated, frontmatter_changed, content_changed, noop, broadcast } = await diagnosedUpdate(graph, options, { content: newBody });
|
|
606
|
+
emitEntityChange('updated', repo, updated.entityType, updated.id);
|
|
607
|
+
const repoRoot = graph.getRepoPath();
|
|
608
|
+
const relPath = updated.path.startsWith(repoRoot + '/') ? updated.path.slice(repoRoot.length + 1) : updated.path;
|
|
609
|
+
return ok({
|
|
610
|
+
success: true,
|
|
611
|
+
id: updated.id, type: updated.entityType, repo, path: relPath,
|
|
612
|
+
commit: graph.getGitService()?.getHeadCommit() ?? null,
|
|
613
|
+
occurrences: count, frontmatter_changed, content_changed, noop, broadcast,
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
catch (err) {
|
|
617
|
+
if (err instanceof DroppedAssetError) {
|
|
618
|
+
return ok({ success: false, code: 'ASSET_REMOVAL_BLOCKED', droppedAssets: err.dropped, message: err.message });
|
|
619
|
+
}
|
|
620
|
+
return fail(err);
|
|
621
|
+
}
|
|
622
|
+
});
|
|
623
|
+
});
|
|
624
|
+
// ── list_assets ─────────────────────────────────────────────────────────
|
|
625
|
+
//
|
|
626
|
+
// Read-only discovery of assets (images, PDFs, files) already uploaded to a
|
|
627
|
+
// folder. Shares listRepoAssets() with the HTTP asset endpoints, so the
|
|
628
|
+
// shape — including the render-safe `embed` string — is identical. Assets
|
|
629
|
+
// are created only through the upload routes / workspace UI; this tool never
|
|
630
|
+
// creates one, it only surfaces existing ones so an agent can reference them
|
|
631
|
+
// in an entry body without guessing a URL or embed syntax.
|
|
632
|
+
const listAssetsSchema = z.object({
|
|
633
|
+
repo: z.string().describe('Folder name'),
|
|
634
|
+
entity_type: z.string().optional().describe('Filter to assets owned by entries of this type'),
|
|
635
|
+
entity_id: z.string().optional().describe('Filter to assets owned by this entry id'),
|
|
636
|
+
});
|
|
637
|
+
server.registerTool('list_assets', {
|
|
638
|
+
description: 'List assets (images, PDFs, files) already uploaded to a folder. Each result includes a ready-to-paste ' +
|
|
639
|
+
'`embed` — standard markdown `` — that renders in the editor. To display an asset in an entry, ' +
|
|
640
|
+
'place that exact `embed` string via attach_asset_to_entity (or patch_entity for append/insert). ' +
|
|
641
|
+
'NEVER write `![[filename]]` transclusion syntax: it does not resolve to a stored asset and shows as dead ' +
|
|
642
|
+
'text. Assets are uploaded via the workspace UI — this tool only references existing ones. Optionally ' +
|
|
643
|
+
'filter by entity_type and/or entity_id to list a single entry\'s assets.',
|
|
644
|
+
inputSchema: listAssetsSchema,
|
|
645
|
+
}, async (args) => {
|
|
646
|
+
const { repo, entity_type, entity_id } = listAssetsSchema.parse(args);
|
|
647
|
+
if (!hasRepoAccess(user, repo, wm, authService))
|
|
648
|
+
return notFound(repo);
|
|
649
|
+
try {
|
|
650
|
+
wm.getGraph(repo);
|
|
651
|
+
}
|
|
652
|
+
catch {
|
|
653
|
+
return notFound(repo);
|
|
654
|
+
}
|
|
655
|
+
let assets = await listRepoAssets(repo, wm);
|
|
656
|
+
if (entity_type)
|
|
657
|
+
assets = assets.filter(a => a.entityType === entity_type);
|
|
658
|
+
if (entity_id)
|
|
659
|
+
assets = assets.filter(a => a.entityId === entity_id);
|
|
660
|
+
return ok({
|
|
661
|
+
repo,
|
|
662
|
+
count: assets.length,
|
|
663
|
+
assets: assets.map(a => ({
|
|
664
|
+
asset_id: a.assetId,
|
|
665
|
+
filename: a.filename,
|
|
666
|
+
mime_type: a.contentType,
|
|
667
|
+
entity_type: a.entityType,
|
|
668
|
+
entity_id: a.entityId,
|
|
669
|
+
entity_name: a.entityName,
|
|
670
|
+
url: a.url,
|
|
671
|
+
embed: a.embed,
|
|
672
|
+
})),
|
|
673
|
+
});
|
|
674
|
+
});
|
|
675
|
+
// ── attach_asset_to_entity ──────────────────────────────────────────────
|
|
676
|
+
//
|
|
677
|
+
// Place an already-uploaded asset (from list_assets) into an entry body
|
|
678
|
+
// without rewriting the whole body. Thin convenience over the patch_entity
|
|
679
|
+
// machinery: it builds the render-safe `` embed and either
|
|
680
|
+
// appends it or swaps a placeholder for it, then writes through the same
|
|
681
|
+
// guarded server-write path.
|
|
682
|
+
//
|
|
683
|
+
// `replace_placeholder` is the sanctioned way to fix a dead `![[Foo.png]]`
|
|
684
|
+
// placeholder. Note: that swap necessarily *drops* the transclusion target
|
|
685
|
+
// (`Foo.png`) the asset-drop guard recognizes, so a plain patch_entity of
|
|
686
|
+
// the same span would be rejected with ASSET_REMOVAL_BLOCKED. Here we pass
|
|
687
|
+
// allowAssetRemoval for replace_placeholder only — the agent is explicitly
|
|
688
|
+
// targeting that placeholder and we're re-adding the image as a working
|
|
689
|
+
// embed, so no real asset is lost. `append` keeps the guard on.
|
|
690
|
+
const attachAssetSchema = z.object({
|
|
691
|
+
repo: z.string().describe('Folder name'),
|
|
692
|
+
entity_type: z.string().describe('Entity type of the target entry'),
|
|
693
|
+
entity_id: z.string().describe('Entity ID of the target entry'),
|
|
694
|
+
url: z.string().describe('Asset url, taken verbatim from list_assets (e.g. /api/assets/<id>/<file>)'),
|
|
695
|
+
alt: z.string().optional().describe('Alt text / caption for the embed. Defaults to the asset filename.'),
|
|
696
|
+
mode: z.enum(['append', 'replace_placeholder']).default('append').describe('"append" adds the embed at the end of the body. "replace_placeholder" swaps `placeholder` text ' +
|
|
697
|
+
'(e.g. a dead `![[Foo.png]]` written earlier) for the working embed.'),
|
|
698
|
+
placeholder: z.string().optional().describe('Required when mode="replace_placeholder": exact text to replace.'),
|
|
699
|
+
expected_count: z.number().int().positive().optional().describe('For replace_placeholder: require `placeholder` to occur exactly this many times, else reject (AMBIGUOUS_MATCH).'),
|
|
700
|
+
});
|
|
701
|
+
server.registerTool('attach_asset_to_entity', {
|
|
702
|
+
description: 'Embed an already-uploaded asset (from list_assets) into an entry body using its render-safe markdown, ' +
|
|
703
|
+
'without rewriting the whole body. mode="append" adds it at the end; mode="replace_placeholder" swaps dead ' +
|
|
704
|
+
'placeholder text (e.g. an `![[Foo.png]]` an agent wrote earlier) for the working embed. Drop-guarded on ' +
|
|
705
|
+
'append: rejects with ASSET_REMOVAL_BLOCKED if it would remove other image embeds.',
|
|
706
|
+
inputSchema: attachAssetSchema,
|
|
707
|
+
}, async (args) => {
|
|
708
|
+
const { repo, entity_type, entity_id, url, alt, mode, placeholder, expected_count } = attachAssetSchema.parse(args);
|
|
709
|
+
if (!hasRepoAccess(user, repo, wm, authService))
|
|
710
|
+
return notFound(repo);
|
|
711
|
+
if (!canWriteRepo(user, repo, wm, authService)) {
|
|
712
|
+
return fail(new Error(`You do not have write access to folder "${repo}"`));
|
|
713
|
+
}
|
|
714
|
+
if (!url.trim())
|
|
715
|
+
return fail(new Error('attach_asset_to_entity requires a non-empty `url`'));
|
|
716
|
+
if (mode === 'replace_placeholder' && !placeholder) {
|
|
717
|
+
return fail(new Error('mode="replace_placeholder" requires a non-empty `placeholder`'));
|
|
718
|
+
}
|
|
719
|
+
const filename = alt ?? (url.split('/').pop() || 'asset').split('?')[0];
|
|
720
|
+
const embed = assetEmbed(filename, url);
|
|
721
|
+
return withAgentActivity(repo, 'editing', async () => {
|
|
722
|
+
try {
|
|
723
|
+
const graph = wm.getGraph(repo);
|
|
724
|
+
const entity = graph.get(entity_type, entity_id);
|
|
725
|
+
const currentBody = graph.getLiveBody(entity_type, entity_id) ?? entity.document.content;
|
|
726
|
+
let newBody;
|
|
727
|
+
let occurrences;
|
|
728
|
+
let allowAssetRemoval = false;
|
|
729
|
+
if (mode === 'replace_placeholder') {
|
|
730
|
+
const ph = placeholder;
|
|
731
|
+
let count = 0;
|
|
732
|
+
for (let i = currentBody.indexOf(ph); i !== -1; i = currentBody.indexOf(ph, i + ph.length))
|
|
733
|
+
count++;
|
|
734
|
+
if (count === 0) {
|
|
735
|
+
return ok({ success: false, code: 'NO_MATCH', message: `placeholder not present in ${entity_type}/${entity_id}.` });
|
|
736
|
+
}
|
|
737
|
+
if (expected_count !== undefined && count !== expected_count) {
|
|
738
|
+
return ok({ success: false, code: 'AMBIGUOUS_MATCH', occurrences: count, message: `Expected ${expected_count} occurrence(s) of placeholder, found ${count}.` });
|
|
739
|
+
}
|
|
740
|
+
occurrences = count;
|
|
741
|
+
newBody = currentBody.split(ph).join(embed);
|
|
742
|
+
// The placeholder we're removing is itself a recognized embed
|
|
743
|
+
// target; swapping it for the working embed is the whole point.
|
|
744
|
+
allowAssetRemoval = true;
|
|
745
|
+
}
|
|
746
|
+
else {
|
|
747
|
+
if (currentBody.includes(embed)) {
|
|
748
|
+
return ok({ success: false, code: 'ALREADY_PRESENT', message: `Asset embed already present in ${entity_type}/${entity_id}.` });
|
|
749
|
+
}
|
|
750
|
+
newBody = currentBody.trimEnd() + '\n\n' + embed + '\n';
|
|
751
|
+
}
|
|
752
|
+
const options = prepareUpdatePayload({ entityType: entity_type, entityId: entity_id, content: newBody }, buildActor(user));
|
|
753
|
+
const { entity: updated, frontmatter_changed, content_changed, noop, broadcast } = await diagnosedUpdate(graph, options, { content: newBody }, { allowAssetRemoval });
|
|
754
|
+
emitEntityChange('updated', repo, updated.entityType, updated.id);
|
|
755
|
+
const repoRoot = graph.getRepoPath();
|
|
756
|
+
const relPath = updated.path.startsWith(repoRoot + '/') ? updated.path.slice(repoRoot.length + 1) : updated.path;
|
|
757
|
+
return ok({
|
|
758
|
+
success: true,
|
|
759
|
+
id: updated.id, type: updated.entityType, repo, path: relPath,
|
|
760
|
+
embed, mode, occurrences,
|
|
761
|
+
commit: graph.getGitService()?.getHeadCommit() ?? null,
|
|
762
|
+
frontmatter_changed, content_changed, noop, broadcast,
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
catch (err) {
|
|
766
|
+
if (err instanceof DroppedAssetError) {
|
|
767
|
+
return ok({ success: false, code: 'ASSET_REMOVAL_BLOCKED', droppedAssets: err.dropped, message: err.message });
|
|
768
|
+
}
|
|
769
|
+
return fail(err);
|
|
770
|
+
}
|
|
771
|
+
});
|
|
772
|
+
});
|
|
773
|
+
// ── create_asset_upload ─────────────────────────────────────────────────
|
|
774
|
+
//
|
|
775
|
+
// Step 1 of 3 for the pre-signed asset upload flow. Validates request,
|
|
776
|
+
// resolves target folder (defaults to the workspace_wide Assets store),
|
|
777
|
+
// mints a pre-signed PUT URL the agent uploads to directly, and returns
|
|
778
|
+
// an HMAC token to pass back to finalize_asset_upload. Bytes never travel
|
|
779
|
+
// through this MCP server — only authz + indexing do.
|
|
780
|
+
//
|
|
781
|
+
// The tool description is load-bearing: it's what the agent reads to
|
|
782
|
+
// plan the three-step flow. Be explicit about each step and the exact
|
|
783
|
+
// shape of the PUT.
|
|
784
|
+
const createAssetUploadSchema = z.object({
|
|
785
|
+
repo: z.string().optional().describe('Folder name. Omit to upload into the shared "Assets" store (created on first use).'),
|
|
786
|
+
filename: z.string().describe('Filename including extension (e.g. "logo.png"). Sanitized server-side; no path segments.'),
|
|
787
|
+
// Registry-driven (P4-V1): the presign path only accepts formats safe as
|
|
788
|
+
// raw bytes (the app never holds them, so it can't sanitize). SVG +
|
|
789
|
+
// documents are excluded here and go through upload_asset_inline instead.
|
|
790
|
+
mime_type: z.enum(PRESIGN_MIME_TUPLE).describe(`Image MIME accepted by the presign flow: ${PRESIGN_MIME_TUPLE.join(', ')}. ` +
|
|
791
|
+
`SVG and documents are not presignable (use upload_asset_inline).`),
|
|
792
|
+
});
|
|
793
|
+
server.registerTool('create_asset_upload', {
|
|
794
|
+
description: 'STEP 1 of 3 for uploading an image (PNG or JPEG, max 20MB) from outside the model context. ' +
|
|
795
|
+
'Returns { assetId, uploadUrl, headers, token, expiresAt, repo }.\n\n' +
|
|
796
|
+
'STEP 2 (not an MCP tool): issue an HTTP PUT to `uploadUrl` with the raw image bytes as the body and ' +
|
|
797
|
+
'the returned `headers` set verbatim (notably `Content-Type`). The URL expires in 15 minutes. ' +
|
|
798
|
+
'Most HTTP clients can do this; if yours cannot PUT binary, use the workspace upload UI instead.\n\n' +
|
|
799
|
+
'STEP 3: call `finalize_asset_upload({ token })` to register the asset and get a permanent URL. ' +
|
|
800
|
+
'Optionally call `attach_asset_to_entity({ url, ... })` after that to embed the asset into an entry body.\n\n' +
|
|
801
|
+
'Errors with code "local_backend" when the workspace uses local filesystem storage (R2 only).',
|
|
802
|
+
inputSchema: createAssetUploadSchema,
|
|
803
|
+
}, async (args) => {
|
|
804
|
+
const parsed = createAssetUploadSchema.parse(args);
|
|
805
|
+
try {
|
|
806
|
+
// Asset-as-embed (B2): the upload always produces a FREE-STANDING,
|
|
807
|
+
// folder-owned asset. There is no entity-ownership handoff — embed it
|
|
808
|
+
// into an entry afterwards via attach_asset_to_entity.
|
|
809
|
+
const result = await presignAssetUpload({
|
|
810
|
+
workspaceManager: wm,
|
|
811
|
+
authService,
|
|
812
|
+
user,
|
|
813
|
+
repo: parsed.repo,
|
|
814
|
+
filename: parsed.filename,
|
|
815
|
+
mimeType: parsed.mime_type,
|
|
816
|
+
});
|
|
817
|
+
return ok({
|
|
818
|
+
assetId: result.assetId,
|
|
819
|
+
uploadUrl: result.uploadUrl,
|
|
820
|
+
headers: result.headers,
|
|
821
|
+
token: result.token,
|
|
822
|
+
expiresAt: result.expiresAt,
|
|
823
|
+
repo: result.repo,
|
|
824
|
+
});
|
|
825
|
+
}
|
|
826
|
+
catch (err) {
|
|
827
|
+
return errorToMcpResult(err);
|
|
828
|
+
}
|
|
829
|
+
});
|
|
830
|
+
// ── finalize_asset_upload ───────────────────────────────────────────────
|
|
831
|
+
//
|
|
832
|
+
// Step 3 of 3. Verifies the upload landed at the pre-signed URL,
|
|
833
|
+
// validates content-type + size at the wire, promotes the blob from
|
|
834
|
+
// `pending/` into the canonical keyspace, and registers a FREE-STANDING,
|
|
835
|
+
// folder-owned asset (no entity). Idempotent on token replay:
|
|
836
|
+
// a second call returns the existing assetId + URL.
|
|
837
|
+
//
|
|
838
|
+
// Identity-bound (R1): the user calling finalize must be the same user
|
|
839
|
+
// who minted the token — leaked tokens cannot be replayed by another
|
|
840
|
+
// folder-writer. Workspace owners are NOT exempt.
|
|
841
|
+
const finalizeAssetUploadSchema = z.object({
|
|
842
|
+
token: z.string().describe('HMAC token returned by create_asset_upload.'),
|
|
843
|
+
name: z.string().optional().describe('Optional display name for the asset entry. Defaults to a title-cased version of the filename stem.'),
|
|
844
|
+
});
|
|
845
|
+
server.registerTool('finalize_asset_upload', {
|
|
846
|
+
description: 'STEP 3 of 3. Call this after PUTting bytes to the uploadUrl returned by create_asset_upload. ' +
|
|
847
|
+
'Verifies the upload landed, validates content type and size, registers a free-standing asset, and returns ' +
|
|
848
|
+
'{ assetId, url, ownerType, ownerId, repo }. Embed it into an entry afterwards via attach_asset_to_entity. ' +
|
|
849
|
+
'Idempotent: calling with the same token twice returns the existing asset.\n\n' +
|
|
850
|
+
'Errors with code "upload_not_received" if the PUT never happened (or the 15-min window expired); ' +
|
|
851
|
+
'"upload_validation" if content type or size doesn\'t match the presign contract; "token_invalid" if ' +
|
|
852
|
+
'the token is tampered or expired; "forbidden" if the caller is not the original presigner or has lost ' +
|
|
853
|
+
'folder access in the interim.',
|
|
854
|
+
inputSchema: finalizeAssetUploadSchema,
|
|
855
|
+
}, async (args) => {
|
|
856
|
+
const parsed = finalizeAssetUploadSchema.parse(args);
|
|
857
|
+
try {
|
|
858
|
+
const result = await finalizeAssetUpload({
|
|
859
|
+
workspaceManager: wm,
|
|
860
|
+
authService,
|
|
861
|
+
user,
|
|
862
|
+
token: parsed.token,
|
|
863
|
+
name: parsed.name,
|
|
864
|
+
});
|
|
865
|
+
// Asset-as-embed (B2): finalize registers a FREE-STANDING asset, not an
|
|
866
|
+
// entity, so there's no entity_change to broadcast — it surfaces in the
|
|
867
|
+
// asset manager on its next load. Its image caption is derived for
|
|
868
|
+
// search by the asset-index sweep (the legacy live drain was keyed to
|
|
869
|
+
// `asset` entities, which this no longer creates).
|
|
870
|
+
return ok({
|
|
871
|
+
assetId: result.assetId,
|
|
872
|
+
url: result.url,
|
|
873
|
+
ownerType: result.ownerType,
|
|
874
|
+
ownerId: result.ownerId,
|
|
875
|
+
repo: result.repo,
|
|
876
|
+
});
|
|
877
|
+
}
|
|
878
|
+
catch (err) {
|
|
879
|
+
return errorToMcpResult(err);
|
|
880
|
+
}
|
|
881
|
+
});
|
|
882
|
+
// ── upload_asset_inline ─────────────────────────────────────────────────────
|
|
883
|
+
//
|
|
884
|
+
// V3: single-call asset upload for SMALL files where the bytes can ride
|
|
885
|
+
// inline (base64). Unlike create_asset_upload (R2-only presign, 3 steps,
|
|
886
|
+
// bytes never touch the app), this works on local OR R2 backends and is one
|
|
887
|
+
// round-trip — the tradeoff is a tight size cap (base64 inflates the model
|
|
888
|
+
// context ~33%, and the bytes traverse this server). For large files or when
|
|
889
|
+
// an R2 backend is available, prefer the presign flow.
|
|
890
|
+
//
|
|
891
|
+
// Indexing reaches web parity: after the asset entity is committed we enqueue
|
|
892
|
+
// the live caption/extract drain (same as a web upload), so an inline-
|
|
893
|
+
// uploaded image is captioned while the server runs.
|
|
894
|
+
const uploadAssetInlineSchema = z.object({
|
|
895
|
+
repo: z.string().optional().describe('Folder name. Omit to upload into the shared "Assets" store (created on first use).'),
|
|
896
|
+
filename: z.string().describe('Filename including extension (e.g. "diagram.png"). Sanitized server-side; no path segments.'),
|
|
897
|
+
data_base64: z.string().describe('The file bytes, base64-encoded. Keep under ~4.5MB raw (6MB base64) — larger files must use create_asset_upload.'),
|
|
898
|
+
name: z.string().optional().describe('Optional display name for the asset entry. Defaults to a title-cased filename stem.'),
|
|
899
|
+
folder_path: z.string().optional().describe('Optional repo-relative subfolder for the entry .md (e.g. "Diagrams"). Defaults to repo root.'),
|
|
900
|
+
});
|
|
901
|
+
server.registerTool('upload_asset_inline', {
|
|
902
|
+
description: 'Ingest a SMALL file (image or document) as a typed entry in ONE call by passing its bytes ' +
|
|
903
|
+
'base64-encoded. The file is stored as a free-standing asset and a typed entry that embeds it ' +
|
|
904
|
+
'is created — image→material, doc/pdf→document (extracted text in the body), xlsx/csv→dataset — ' +
|
|
905
|
+
'exactly as a web import would. Returns { assetId, url, repo, entities: [{ entityType, entityId }] }.\n\n' +
|
|
906
|
+
'Size limit ~4.5MB raw (6MB base64) — for larger files use create_asset_upload (R2 presign, 3 steps). ' +
|
|
907
|
+
'Accepted types are the workspace upload set (images + documents); SVG is not yet accepted here. ' +
|
|
908
|
+
'Images are captioned for search automatically in the background.',
|
|
909
|
+
inputSchema: uploadAssetInlineSchema,
|
|
910
|
+
}, async (args) => {
|
|
911
|
+
const parsed = uploadAssetInlineSchema.parse(args);
|
|
912
|
+
// 1. Format gate: resolve the filename to a registry format and check it
|
|
913
|
+
// directly via isInlineUploadAllowed — NOT via detectContentType, whose
|
|
914
|
+
// CONTENT_TYPES map returns application/octet-stream for several
|
|
915
|
+
// registry-accepted assets (.tsv/.psd/.ai/.aac/...), which would wrongly
|
|
916
|
+
// reject them. Both the gate and the allowlist now derive from the same
|
|
917
|
+
// registry predicate, so they can't disagree. Rejects SVG (transitional
|
|
918
|
+
// until sanitize-html), unaccepted docs, and unknown types (fallback).
|
|
919
|
+
const format = resolveFormat(parsed.filename);
|
|
920
|
+
if (!isInlineUploadAllowed(format)) {
|
|
921
|
+
return fail(new Error(`"${parsed.filename}" is not accepted by upload_asset_inline. ` +
|
|
922
|
+
`Accepted: ${INLINE_UPLOAD_MIME_LIST.join(', ')}.`));
|
|
923
|
+
}
|
|
924
|
+
// 2. Decode + size gate. Node's Buffer.from(..,'base64') silently DROPS
|
|
925
|
+
// invalid characters instead of throwing, so a garbage string would
|
|
926
|
+
// "decode" to junk bytes. Validate the shape first (strip one optional
|
|
927
|
+
// data: prefix + whitespace, then assert the strict base64 charset),
|
|
928
|
+
// and re-encode-compare to catch truncation.
|
|
929
|
+
const raw = parsed.data_base64.replace(/^data:[^;]+;base64,/, '').replace(/\s+/g, '');
|
|
930
|
+
if (raw.length === 0 || !/^[A-Za-z0-9+/]+={0,2}$/.test(raw) || raw.length % 4 !== 0) {
|
|
931
|
+
return fail(new Error('data_base64 is not valid base64.'));
|
|
932
|
+
}
|
|
933
|
+
const buffer = Buffer.from(raw, 'base64');
|
|
934
|
+
if (buffer.length === 0 || buffer.toString('base64') !== raw) {
|
|
935
|
+
return fail(new Error('data_base64 is not valid base64.'));
|
|
936
|
+
}
|
|
937
|
+
if (buffer.length > INLINE_MAX_BYTES) {
|
|
938
|
+
return fail(new Error(`Decoded size ${buffer.length} bytes exceeds the inline ${INLINE_MAX_BYTES}-byte cap. Use create_asset_upload for larger files.`));
|
|
939
|
+
}
|
|
940
|
+
// 3. Resolve the target repo (default → shared Assets store) + authz.
|
|
941
|
+
let repo;
|
|
942
|
+
try {
|
|
943
|
+
repo = parsed.repo
|
|
944
|
+
?? await resolveWorkspaceAssetsRepo(new Workspace(wm.getWorkspacePath()), wm);
|
|
945
|
+
}
|
|
946
|
+
catch (err) {
|
|
947
|
+
return errorToMcpResult(err);
|
|
948
|
+
}
|
|
949
|
+
if (!canWriteRepo(user, repo, wm, authService)) {
|
|
950
|
+
return fail(`You don't have permission to write to "${repo}". Editor or admin role required.`);
|
|
951
|
+
}
|
|
952
|
+
let graph;
|
|
953
|
+
try {
|
|
954
|
+
graph = wm.getGraph(repo);
|
|
955
|
+
}
|
|
956
|
+
catch (err) {
|
|
957
|
+
return errorToMcpResult(err);
|
|
958
|
+
}
|
|
959
|
+
// 4. Ingest via the asset-as-embed import: store the bytes as a
|
|
960
|
+
// free-standing folder-owned asset + create the typed entry(ies) whose
|
|
961
|
+
// body embeds it (image→material, doc→document, xlsx→dataset×N).
|
|
962
|
+
// Auto-commits. Same path as web import/drag-drop.
|
|
963
|
+
try {
|
|
964
|
+
const result = await withAgentActivity(repo, 'creating', () => importAssetAsEntity({
|
|
965
|
+
graph,
|
|
966
|
+
filename: parsed.filename,
|
|
967
|
+
buffer,
|
|
968
|
+
folderPath: parsed.folder_path || undefined,
|
|
969
|
+
name: parsed.name,
|
|
970
|
+
user: buildActor(user),
|
|
971
|
+
uploaderUserId: String(user.id),
|
|
972
|
+
}));
|
|
973
|
+
for (const e of result.entities)
|
|
974
|
+
emitEntityChange('created', repo, e.entityType, e.entityId);
|
|
975
|
+
// V3 indexing parity: the created entries' bodies are vector-indexed
|
|
976
|
+
// natively; the embedded image asset's caption drains in the background.
|
|
977
|
+
return ok({
|
|
978
|
+
assetId: result.assetId,
|
|
979
|
+
url: result.asset_url,
|
|
980
|
+
repo,
|
|
981
|
+
entities: result.entities.map(e => ({ entityType: e.entityType, entityId: e.entityId })),
|
|
982
|
+
});
|
|
983
|
+
}
|
|
984
|
+
catch (err) {
|
|
985
|
+
return errorToMcpResult(err);
|
|
986
|
+
}
|
|
987
|
+
});
|
|
988
|
+
// ── move_entity ───────────────────────────────────────────────────────────
|
|
989
|
+
//
|
|
990
|
+
// Relocate an entity to a different folder within the same repo. Wraps
|
|
991
|
+
// graph.move() which renames the file on disk and commits the rename so
|
|
992
|
+
// git's similarity detection preserves history. The (type, id) identity
|
|
993
|
+
// is unchanged — get_entity, search, list, validate_wikilinks, and the
|
|
994
|
+
// history tools all walk the entire repo tree and continue to find the
|
|
995
|
+
// entry at its new path. For cross-repo transfers, the web UI's bulk-move
|
|
996
|
+
// dialog or POST /api/repos/:repo/transfer is the right surface.
|
|
997
|
+
const moveEntitySchema = z.object({
|
|
998
|
+
repo: z.string().describe('Folder name containing the entry'),
|
|
999
|
+
entity_type: z.string().describe('Entity type'),
|
|
1000
|
+
entity_id: z.string().describe('Entity ID'),
|
|
1001
|
+
folder_path: z.string().describe('Target repo-relative folder path (e.g. "People", "Clients/Acme"). ' +
|
|
1002
|
+
'Empty string moves the entry to the repo root. Parent folders are auto-created.'),
|
|
1003
|
+
overwrite: z.boolean().optional().describe('When true, replace an existing entry at the destination. The occupant ' +
|
|
1004
|
+
'must itself be a parseable entity — README/.gitkeep/etc. are never ' +
|
|
1005
|
+
'clobbered. Defaults to false; the call errors with "Path already ' +
|
|
1006
|
+
'occupied" when the destination is taken.'),
|
|
1007
|
+
});
|
|
1008
|
+
server.registerTool('move_entity', {
|
|
1009
|
+
description: 'Move an existing entry to a different folder within the same folder/repo. ' +
|
|
1010
|
+
'Preserves frontmatter, markdown content, entity ID, and git history (file is renamed, not rewritten). ' +
|
|
1011
|
+
'Use this to organise entries into subfolders after creation — e.g. moving a person into People/. ' +
|
|
1012
|
+
'By default, errors if the destination already has an entry; pass `overwrite: true` to replace.',
|
|
1013
|
+
inputSchema: moveEntitySchema,
|
|
1014
|
+
}, async (args) => {
|
|
1015
|
+
const { repo, entity_type, entity_id, folder_path, overwrite } = moveEntitySchema.parse(args);
|
|
1016
|
+
if (!hasRepoAccess(user, repo, wm, authService))
|
|
1017
|
+
return notFound(repo);
|
|
1018
|
+
if (!canWriteRepo(user, repo, wm, authService)) {
|
|
1019
|
+
return fail(new Error(`You do not have write access to folder "${repo}"`));
|
|
1020
|
+
}
|
|
1021
|
+
const actor = buildActor(user);
|
|
1022
|
+
return withAgentActivity(repo, 'editing', async () => {
|
|
1023
|
+
try {
|
|
1024
|
+
const graph = wm.getGraph(repo);
|
|
1025
|
+
// If the destination folder doesn't exist yet, the move creates it —
|
|
1026
|
+
// emit a _folder event (alongside the entry update) so clients
|
|
1027
|
+
// refetch the folder tree, not just the entry list.
|
|
1028
|
+
const normTarget = folder_path ? validateFolderPath(folder_path) : '';
|
|
1029
|
+
const targetExisted = !normTarget || existsSync(join(graph.getRepoPath(), normTarget));
|
|
1030
|
+
const moved = await graph.move(entity_type, entity_id, folder_path, undefined, actor, overwrite);
|
|
1031
|
+
emitEntityChange('updated', repo, moved.entityType, moved.id);
|
|
1032
|
+
if (!targetExisted)
|
|
1033
|
+
emitEntityChange('created', repo, '_folder', normTarget);
|
|
1034
|
+
return ok({
|
|
1035
|
+
success: true,
|
|
1036
|
+
id: moved.id,
|
|
1037
|
+
type: moved.entityType,
|
|
1038
|
+
repo,
|
|
1039
|
+
path: relPathOf(moved.path, graph.getRepoPath()),
|
|
1040
|
+
folder_path: moved.folder_path,
|
|
1041
|
+
});
|
|
1042
|
+
}
|
|
1043
|
+
catch (err) {
|
|
1044
|
+
return fail(err);
|
|
1045
|
+
}
|
|
1046
|
+
});
|
|
1047
|
+
});
|
|
1048
|
+
// ── create_subfolder ──────────────────────────────────────────────────────
|
|
1049
|
+
//
|
|
1050
|
+
// Create a nested subfolder inside an existing folder/collection. Wraps
|
|
1051
|
+
// graph.createFolder(). Distinct from create_repo, which registers a new
|
|
1052
|
+
// top-level collection. Emits the _folder sentinel so live clients refetch
|
|
1053
|
+
// the folder tree (sidebar + list/gallery folder rows) without a reload.
|
|
1054
|
+
const createSubfolderSchema = z.object({
|
|
1055
|
+
repo: z.string().describe('Folder name (collection) to create the subfolder inside'),
|
|
1056
|
+
path: z.string().describe('Repo-relative POSIX path of the new subfolder (e.g. "Clients/Acme"). Parent segments are auto-created.'),
|
|
1057
|
+
display_name: z.string().optional().describe('Optional human-readable label. Omit when the title-cased folder name is the right display ' +
|
|
1058
|
+
'(pass it for casing the slug can\'t express, e.g. "HR" or "Schema_OS").'),
|
|
1059
|
+
});
|
|
1060
|
+
server.registerTool('create_subfolder', {
|
|
1061
|
+
description: 'Create a new subfolder inside an existing folder/collection. Path is repo-relative POSIX (e.g. "Clients/Acme"); parent segments are auto-created. ' +
|
|
1062
|
+
'Use it to organise entries, then place entries inside via create_entity (folder_path) or move_entity. ' +
|
|
1063
|
+
'For a brand-new top-level collection, use create_repo instead.',
|
|
1064
|
+
inputSchema: createSubfolderSchema,
|
|
1065
|
+
}, async (args) => {
|
|
1066
|
+
const { repo, path, display_name } = createSubfolderSchema.parse(args);
|
|
1067
|
+
if (!hasRepoAccess(user, repo, wm, authService))
|
|
1068
|
+
return notFound(repo);
|
|
1069
|
+
if (!canWriteRepo(user, repo, wm, authService)) {
|
|
1070
|
+
return fail(new Error(`You do not have write access to folder "${repo}"`));
|
|
1071
|
+
}
|
|
1072
|
+
const actor = buildActor(user);
|
|
1073
|
+
return withAgentActivity(repo, 'creating', async () => {
|
|
1074
|
+
try {
|
|
1075
|
+
const graph = wm.getGraph(repo);
|
|
1076
|
+
await graph.createFolder(path, undefined, actor, { displayName: display_name });
|
|
1077
|
+
emitEntityChange('created', repo, '_folder', path);
|
|
1078
|
+
return ok({ success: true, repo, path, folder_path: path });
|
|
1079
|
+
}
|
|
1080
|
+
catch (err) {
|
|
1081
|
+
return fail(err);
|
|
1082
|
+
}
|
|
1083
|
+
});
|
|
128
1084
|
});
|
|
129
1085
|
// ── validate_wikilinks ────────────────────────────────────────────────────
|
|
130
1086
|
const validateWikilinksSchema = z.object({
|
|
131
|
-
repo: z.string().describe('
|
|
1087
|
+
repo: z.string().describe('Folder name'),
|
|
132
1088
|
entity_type: z.string().describe('Entity type'),
|
|
133
1089
|
entity_id: z.string().describe('Entity ID'),
|
|
134
1090
|
});
|
|
135
1091
|
server.registerTool('validate_wikilinks', { description: 'Check which wikilinks in an entity resolve to real entities and which are broken', inputSchema: validateWikilinksSchema }, async (args) => {
|
|
136
1092
|
const { repo, entity_type, entity_id } = validateWikilinksSchema.parse(args);
|
|
1093
|
+
if (!hasRepoAccess(user, repo, wm, authService))
|
|
1094
|
+
return notFound(repo);
|
|
137
1095
|
try {
|
|
138
1096
|
const result = wm.getGraph(repo).validateWikilinks(entity_type, entity_id);
|
|
139
|
-
|
|
1097
|
+
const accessibleIds = getAccessibleEntityIds(user, wm, authService);
|
|
1098
|
+
const valid = filterWikilinks(result.valid, accessibleIds);
|
|
1099
|
+
// Anything the user can't see is reported as broken rather than valid —
|
|
1100
|
+
// it shouldn't leak the target's existence.
|
|
1101
|
+
const hiddenFromValid = result.valid.filter(id => !valid.includes(id));
|
|
1102
|
+
const broken = [...result.broken, ...hiddenFromValid];
|
|
1103
|
+
return ok({ entity_id, valid, broken, total: valid.length + broken.length });
|
|
140
1104
|
}
|
|
141
1105
|
catch (err) {
|
|
142
1106
|
return fail(err);
|
|
@@ -144,7 +1108,7 @@ export function registerTools(server, wm, authService) {
|
|
|
144
1108
|
});
|
|
145
1109
|
// ── find_related ──────────────────────────────────────────────────────────
|
|
146
1110
|
const relatedSchema = z.object({
|
|
147
|
-
repo: z.string().describe('
|
|
1111
|
+
repo: z.string().describe('Folder name'),
|
|
148
1112
|
entity_type: z.string().describe('Entity type'),
|
|
149
1113
|
entity_id: z.string().describe('Entity ID'),
|
|
150
1114
|
direction: z.enum(['outgoing', 'incoming', 'both']).default('both')
|
|
@@ -152,15 +1116,33 @@ export function registerTools(server, wm, authService) {
|
|
|
152
1116
|
});
|
|
153
1117
|
server.registerTool('find_related', { description: 'Find entities related via wikilinks (outgoing) or backlinks (incoming)', inputSchema: relatedSchema }, async (args) => {
|
|
154
1118
|
const { repo, entity_type, entity_id, direction } = relatedSchema.parse(args);
|
|
1119
|
+
if (!hasRepoAccess(user, repo, wm, authService))
|
|
1120
|
+
return notFound(repo);
|
|
155
1121
|
try {
|
|
1122
|
+
const accessibleIds = getAccessibleEntityIds(user, wm, authService);
|
|
156
1123
|
const results = [];
|
|
157
1124
|
if (direction === 'outgoing' || direction === 'both') {
|
|
158
1125
|
const related = wm.getGraph(repo).getRelated(entity_type, entity_id);
|
|
159
|
-
|
|
1126
|
+
for (const e of related) {
|
|
1127
|
+
if (accessibleIds && !accessibleIds.has(e.id))
|
|
1128
|
+
continue;
|
|
1129
|
+
results.push(shape(e.id, e.entityType, e.data, { direction: 'outgoing' }));
|
|
1130
|
+
}
|
|
160
1131
|
}
|
|
161
1132
|
if (direction === 'incoming' || direction === 'both') {
|
|
1133
|
+
// Comments anchored to this entry surface as incoming backlinks.
|
|
1134
|
+
if (commentService) {
|
|
1135
|
+
const anchored = commentVirtualEntity.findRelatedComments(commentService, repo, entity_type, entity_id);
|
|
1136
|
+
for (const e of anchored) {
|
|
1137
|
+
results.push(shape(e.id, e.entityType, e.data, { direction: 'incoming', repo }));
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
162
1140
|
const backlinks = wm.getBacklinks(repo, entity_type, entity_id);
|
|
163
|
-
|
|
1141
|
+
for (const e of backlinks) {
|
|
1142
|
+
if (!hasRepoAccess(user, e.repoName, wm, authService))
|
|
1143
|
+
continue;
|
|
1144
|
+
results.push(shape(e.id, e.entityType, e.data, { direction: 'incoming', repo: e.repoName }));
|
|
1145
|
+
}
|
|
164
1146
|
}
|
|
165
1147
|
return ok(results);
|
|
166
1148
|
}
|
|
@@ -168,84 +1150,351 @@ export function registerTools(server, wm, authService) {
|
|
|
168
1150
|
return fail(err);
|
|
169
1151
|
}
|
|
170
1152
|
});
|
|
171
|
-
// ──
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
1153
|
+
// ── list_skills ──────────────────────────────────────────────────────────
|
|
1154
|
+
//
|
|
1155
|
+
// Surfaces user-authored `skill` entities to external MCP clients so
|
|
1156
|
+
// connected agents (Claude Desktop, Cursor, etc.) can discover and run
|
|
1157
|
+
// the workspace's codified workflows. Only graph skills (entities) are
|
|
1158
|
+
// exposed; bundled filesystem skills (onboarding/interview/enrichment
|
|
1159
|
+
// prompts) stay internal to Studiograph's own agent.
|
|
1160
|
+
const listSkillsSchema = z.object({
|
|
1161
|
+
repo: z.string().optional().describe('Folder name — omit to list across all folders you have access to'),
|
|
1162
|
+
});
|
|
1163
|
+
function projectSkill(entity, repo) {
|
|
1164
|
+
const data = entity.data;
|
|
1165
|
+
return {
|
|
1166
|
+
id: entity.id,
|
|
1167
|
+
name: data.name || entity.id,
|
|
1168
|
+
description: data.description ?? '',
|
|
1169
|
+
repo,
|
|
1170
|
+
loading: data.loading === 'eager' ? 'eager' : 'on-demand',
|
|
1171
|
+
};
|
|
1172
|
+
}
|
|
1173
|
+
// `graph.list('skill')` is lenient — root-level .md files without a
|
|
1174
|
+
// declared `entity_type` (READMEs, CHANGELOGs) get tagged as whatever the
|
|
1175
|
+
// caller asks for. For MCP we want only real skills, so require the
|
|
1176
|
+
// frontmatter to explicitly say `entity_type: skill`.
|
|
1177
|
+
function isRealSkill(entity) {
|
|
1178
|
+
return entity.data.entity_type === 'skill';
|
|
1179
|
+
}
|
|
1180
|
+
server.registerTool('list_skills', {
|
|
1181
|
+
description: 'List skills (reusable agent instructions) available in the Studiograph workspace. ' +
|
|
1182
|
+
'Skills are user-authored markdown — call get_skill to read the full body and follow ' +
|
|
1183
|
+
'its instructions. Optionally filter by folder.',
|
|
1184
|
+
inputSchema: listSkillsSchema,
|
|
1185
|
+
}, async (args) => {
|
|
1186
|
+
const { repo } = listSkillsSchema.parse(args);
|
|
1187
|
+
try {
|
|
1188
|
+
if (repo) {
|
|
1189
|
+
if (!hasRepoAccess(user, repo, wm, authService))
|
|
1190
|
+
return notFound(repo);
|
|
1191
|
+
const skills = wm.getGraph(repo).list('skill');
|
|
1192
|
+
return ok(skills.filter(isRealSkill).map(e => projectSkill(e, repo)));
|
|
176
1193
|
}
|
|
177
|
-
|
|
178
|
-
|
|
1194
|
+
const accessible = getAccessibleRepos(user, wm, authService);
|
|
1195
|
+
const results = [];
|
|
1196
|
+
for (const r of accessible) {
|
|
1197
|
+
try {
|
|
1198
|
+
const skills = wm.getGraph(r.name).list('skill');
|
|
1199
|
+
for (const e of skills) {
|
|
1200
|
+
if (isRealSkill(e))
|
|
1201
|
+
results.push(projectSkill(e, r.name));
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
catch { /* skip unmounted repos */ }
|
|
179
1205
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
1206
|
+
return ok(results);
|
|
1207
|
+
}
|
|
1208
|
+
catch (err) {
|
|
1209
|
+
return fail(err);
|
|
1210
|
+
}
|
|
1211
|
+
});
|
|
1212
|
+
// ── get_skill ────────────────────────────────────────────────────────────
|
|
1213
|
+
//
|
|
1214
|
+
// Returns the full markdown body of a skill alongside its metadata. The
|
|
1215
|
+
// body is instructions to follow — the MCP client is the runtime. No
|
|
1216
|
+
// server-side agent loop, no parameter substitution in v1.
|
|
1217
|
+
const getSkillSchema = z.object({
|
|
1218
|
+
name: z.string().describe('Skill id (the entity_id of the skill entity)'),
|
|
1219
|
+
repo: z.string().optional().describe('Folder to look in. Omit to search across all accessible folders.'),
|
|
1220
|
+
});
|
|
1221
|
+
server.registerTool('get_skill', {
|
|
1222
|
+
description: 'Fetch the full content of a skill. Returns the skill\'s markdown body along with its ' +
|
|
1223
|
+
'metadata. The body contains instructions to follow — read it and apply it to the current task.',
|
|
1224
|
+
inputSchema: getSkillSchema,
|
|
1225
|
+
}, async (args) => {
|
|
1226
|
+
const { name, repo } = getSkillSchema.parse(args);
|
|
1227
|
+
try {
|
|
1228
|
+
if (repo) {
|
|
1229
|
+
if (!hasRepoAccess(user, repo, wm, authService))
|
|
1230
|
+
return notFound(repo);
|
|
1231
|
+
try {
|
|
1232
|
+
const entity = wm.getGraph(repo).get('skill', name);
|
|
1233
|
+
if (!isRealSkill({ data: entity.data })) {
|
|
1234
|
+
return fail(new Error(`Skill "${name}" not found`));
|
|
1235
|
+
}
|
|
1236
|
+
return ok({
|
|
1237
|
+
...projectSkill({ id: entity.id, data: entity.data }, repo),
|
|
1238
|
+
content: entity.document.content,
|
|
1239
|
+
});
|
|
1240
|
+
}
|
|
1241
|
+
catch {
|
|
1242
|
+
return fail(new Error(`Skill "${name}" not found`));
|
|
1243
|
+
}
|
|
198
1244
|
}
|
|
199
|
-
|
|
200
|
-
|
|
1245
|
+
// No repo — search accessible folders for the skill by id.
|
|
1246
|
+
const accessible = getAccessibleRepos(user, wm, authService);
|
|
1247
|
+
const matches = [];
|
|
1248
|
+
for (const r of accessible) {
|
|
1249
|
+
try {
|
|
1250
|
+
const entity = wm.getGraph(r.name).get('skill', name);
|
|
1251
|
+
if (!isRealSkill({ data: entity.data }))
|
|
1252
|
+
continue;
|
|
1253
|
+
matches.push({ repo: r.name, entity });
|
|
1254
|
+
}
|
|
1255
|
+
catch { /* not in this repo */ }
|
|
201
1256
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
1257
|
+
if (matches.length === 0)
|
|
1258
|
+
return fail(new Error(`Skill "${name}" not found`));
|
|
1259
|
+
if (matches.length > 1) {
|
|
1260
|
+
const folders = matches.map(m => m.repo).join(', ');
|
|
1261
|
+
return fail(new Error(`Skill "${name}" exists in multiple folders (${folders}). Specify repo.`));
|
|
1262
|
+
}
|
|
1263
|
+
const { repo: matchRepo, entity } = matches[0];
|
|
1264
|
+
return ok({
|
|
1265
|
+
...projectSkill({ id: entity.id, data: entity.data }, matchRepo),
|
|
1266
|
+
content: entity.document.content,
|
|
1267
|
+
});
|
|
1268
|
+
}
|
|
1269
|
+
catch (err) {
|
|
1270
|
+
return fail(err);
|
|
1271
|
+
}
|
|
1272
|
+
});
|
|
1273
|
+
// ── Git history tools ──────────────────────────────────────────────────────
|
|
1274
|
+
//
|
|
1275
|
+
// Mirrors the agent's history-tools.ts surface so external MCP clients get
|
|
1276
|
+
// the same primitives. Reads gated on hasRepoAccess; restore_file gated on
|
|
1277
|
+
// canWriteRepo. Single-entity scope only — multi-entity rollback is
|
|
1278
|
+
// intentionally absent (deferred to a future revert_commit).
|
|
1279
|
+
const listFileHistorySchema = z.object({
|
|
1280
|
+
repo: z.string().describe('Folder name'),
|
|
1281
|
+
entity_type: z.string().describe('Entity type'),
|
|
1282
|
+
entity_id: z.string().describe('Entry ID'),
|
|
1283
|
+
limit: z.number().optional().describe('Max commits (default 20, max 100)'),
|
|
1284
|
+
});
|
|
1285
|
+
server.registerTool('list_file_history', { description: 'List commits that touched a single entry, newest first.', inputSchema: listFileHistorySchema }, async (args) => {
|
|
1286
|
+
const { repo, entity_type, entity_id, limit } = listFileHistorySchema.parse(args);
|
|
1287
|
+
try {
|
|
1288
|
+
if (!hasRepoAccess(user, repo, wm, authService))
|
|
1289
|
+
return fail(`Folder "${repo}" not found`);
|
|
1290
|
+
const graph = wm.getGraph(repo);
|
|
1291
|
+
const gitService = graph.getGitService();
|
|
1292
|
+
if (!gitService)
|
|
1293
|
+
return fail('Folder is not git-backed');
|
|
1294
|
+
let entityPath;
|
|
211
1295
|
try {
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
const fields = {};
|
|
216
|
-
if (name)
|
|
217
|
-
fields.name = name;
|
|
218
|
-
if (selected_type !== undefined || group_by !== undefined) {
|
|
219
|
-
const config = { ...existing.config };
|
|
220
|
-
if (selected_type !== undefined)
|
|
221
|
-
config.selectedType = selected_type === 'all' ? null : selected_type;
|
|
222
|
-
if (group_by !== undefined)
|
|
223
|
-
config.groupBy = group_by === 'none' ? null : group_by;
|
|
224
|
-
fields.config = config;
|
|
225
|
-
}
|
|
226
|
-
authService.updateUserView(id, 0, fields);
|
|
227
|
-
return ok({ success: true });
|
|
1296
|
+
const entity = graph.get(entity_type, entity_id);
|
|
1297
|
+
const { relative: relativePath } = await import('path');
|
|
1298
|
+
entityPath = relativePath(graph.getRepoPath(), entity.path);
|
|
228
1299
|
}
|
|
229
|
-
catch
|
|
230
|
-
|
|
1300
|
+
catch {
|
|
1301
|
+
const idLower = `${entity_id}.md`.toLowerCase();
|
|
1302
|
+
const match = gitService.listRecentDeletions(30).find((d) => d.filePath.toLowerCase().endsWith(idLower));
|
|
1303
|
+
if (!match)
|
|
1304
|
+
return fail(`Entry ${entity_type}/${entity_id} not found in "${repo}".`);
|
|
1305
|
+
entityPath = match.filePath;
|
|
231
1306
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
1307
|
+
const cap = Math.min(100, Math.max(1, limit ?? 20));
|
|
1308
|
+
const commits = gitService.getFileHistory(entityPath, cap).map((c) => ({
|
|
1309
|
+
hash: c.hash.slice(0, 8),
|
|
1310
|
+
fullHash: c.hash,
|
|
1311
|
+
author: c.author,
|
|
1312
|
+
timestamp: c.timestamp,
|
|
1313
|
+
message: c.message,
|
|
1314
|
+
}));
|
|
1315
|
+
return ok({ repo, entityType: entity_type, entityId: entity_id, commits });
|
|
1316
|
+
}
|
|
1317
|
+
catch (err) {
|
|
1318
|
+
return fail(err);
|
|
1319
|
+
}
|
|
1320
|
+
});
|
|
1321
|
+
const listFolderHistorySchema = z.object({
|
|
1322
|
+
repo: z.string().describe('Folder name'),
|
|
1323
|
+
limit: z.number().optional().describe('Max commits (default 30, max 200)'),
|
|
1324
|
+
});
|
|
1325
|
+
server.registerTool('list_folder_history', { description: 'List recent commits across an entire folder.', inputSchema: listFolderHistorySchema }, async (args) => {
|
|
1326
|
+
const { repo, limit } = listFolderHistorySchema.parse(args);
|
|
1327
|
+
try {
|
|
1328
|
+
if (!hasRepoAccess(user, repo, wm, authService))
|
|
1329
|
+
return fail(`Folder "${repo}" not found`);
|
|
1330
|
+
const gitService = wm.getGraph(repo).getGitService();
|
|
1331
|
+
if (!gitService)
|
|
1332
|
+
return fail('Folder is not git-backed');
|
|
1333
|
+
const cap = Math.min(200, Math.max(1, limit ?? 30));
|
|
1334
|
+
const commits = gitService.getHistory(cap).map((c) => ({
|
|
1335
|
+
hash: c.hash.slice(0, 8),
|
|
1336
|
+
fullHash: c.hash,
|
|
1337
|
+
author: c.author,
|
|
1338
|
+
timestamp: c.timestamp,
|
|
1339
|
+
message: c.message,
|
|
1340
|
+
}));
|
|
1341
|
+
return ok({ repo, commits });
|
|
1342
|
+
}
|
|
1343
|
+
catch (err) {
|
|
1344
|
+
return fail(err);
|
|
1345
|
+
}
|
|
1346
|
+
});
|
|
1347
|
+
const listRecentDeletionsSchema = z.object({
|
|
1348
|
+
repo: z.string().describe('Folder name'),
|
|
1349
|
+
within_days: z.number().optional().describe('Lookback window (default 7, max 90)'),
|
|
1350
|
+
});
|
|
1351
|
+
server.registerTool('list_recent_deletions', { description: 'List entries deleted within the last N days. Use before restore_file to find a target.', inputSchema: listRecentDeletionsSchema }, async (args) => {
|
|
1352
|
+
const { repo, within_days } = listRecentDeletionsSchema.parse(args);
|
|
1353
|
+
try {
|
|
1354
|
+
if (!hasRepoAccess(user, repo, wm, authService))
|
|
1355
|
+
return fail(`Folder "${repo}" not found`);
|
|
1356
|
+
const gitService = wm.getGraph(repo).getGitService();
|
|
1357
|
+
if (!gitService)
|
|
1358
|
+
return fail('Folder is not git-backed');
|
|
1359
|
+
const days = Math.min(90, Math.max(1, within_days ?? 7));
|
|
1360
|
+
const raw = gitService.listRecentDeletions(days);
|
|
1361
|
+
// Naive coords: use filename basename for entity_id; entity_type
|
|
1362
|
+
// sniffed from frontmatter at lastVersionCommit.
|
|
1363
|
+
const deletions = raw.map((d) => {
|
|
1364
|
+
const idMatch = d.filePath.match(/([^/]+)\.md$/i);
|
|
1365
|
+
const entityId = idMatch ? idMatch[1] : null;
|
|
1366
|
+
const content = entityId ? gitService.getFileAtCommit(d.filePath, d.lastVersionCommit) : null;
|
|
1367
|
+
let entityType = null;
|
|
1368
|
+
if (content) {
|
|
1369
|
+
const fm = content.match(/^---\s*\n([\s\S]*?)\n---/);
|
|
1370
|
+
const tm = fm?.[1].match(/^entity_type:\s*['"]?([\w-]+)['"]?\s*$/m);
|
|
1371
|
+
if (tm)
|
|
1372
|
+
entityType = tm[1];
|
|
1373
|
+
}
|
|
1374
|
+
if (!entityId || !entityType)
|
|
1375
|
+
return null;
|
|
1376
|
+
return {
|
|
1377
|
+
entityType,
|
|
1378
|
+
entityId,
|
|
1379
|
+
deletedAt: d.deletedAt,
|
|
1380
|
+
deletedBy: d.deletedBy.name,
|
|
1381
|
+
deletedInCommit: d.deletedAtCommit.slice(0, 8),
|
|
1382
|
+
lastVersionCommit: d.lastVersionCommit,
|
|
1383
|
+
commitMessage: d.commitMessage,
|
|
1384
|
+
path: d.filePath,
|
|
1385
|
+
};
|
|
1386
|
+
}).filter((x) => x !== null);
|
|
1387
|
+
return ok({ repo, withinDays: days, deletions });
|
|
1388
|
+
}
|
|
1389
|
+
catch (err) {
|
|
1390
|
+
return fail(err);
|
|
1391
|
+
}
|
|
1392
|
+
});
|
|
1393
|
+
const readFileAtCommitSchema = z.object({
|
|
1394
|
+
repo: z.string().describe('Folder name'),
|
|
1395
|
+
entity_type: z.string().describe('Entity type'),
|
|
1396
|
+
entity_id: z.string().describe('Entry ID'),
|
|
1397
|
+
commit_hash: z.string().describe('Commit hash (short or full)'),
|
|
1398
|
+
});
|
|
1399
|
+
server.registerTool('read_file_at_commit', { description: 'Read an entry\'s full content at a specific commit.', inputSchema: readFileAtCommitSchema }, async (args) => {
|
|
1400
|
+
const { repo, entity_type, entity_id, commit_hash } = readFileAtCommitSchema.parse(args);
|
|
1401
|
+
try {
|
|
1402
|
+
if (!hasRepoAccess(user, repo, wm, authService))
|
|
1403
|
+
return fail(`Folder "${repo}" not found`);
|
|
1404
|
+
const graph = wm.getGraph(repo);
|
|
1405
|
+
const found = graph.getEntityAtCommit(entity_type, entity_id, commit_hash);
|
|
1406
|
+
if (!found)
|
|
1407
|
+
return fail(`Entry ${entity_type}/${entity_id} not found at commit ${commit_hash}`);
|
|
1408
|
+
// Surface the image/asset embeds present in the body at this commit so
|
|
1409
|
+
// a caller can verify whether images existed here without diffing the
|
|
1410
|
+
// raw markdown by eye. Asset *binaries* aren't in git — these are the
|
|
1411
|
+
// body references, the only image evidence git retains.
|
|
1412
|
+
const embeds = extractAssetEmbeds(stripFrontmatter(found.content));
|
|
1413
|
+
return ok({ repo, entityType: entity_type, entityId: entity_id, commitHash: commit_hash, path: found.path, content: found.content, embeds, embedCount: embeds.length });
|
|
1414
|
+
}
|
|
1415
|
+
catch (err) {
|
|
1416
|
+
return fail(err);
|
|
1417
|
+
}
|
|
1418
|
+
});
|
|
1419
|
+
const restoreFileSchema = z.object({
|
|
1420
|
+
repo: z.string().describe('Folder name'),
|
|
1421
|
+
entity_type: z.string().describe('Entity type'),
|
|
1422
|
+
entity_id: z.string().describe('Entry ID'),
|
|
1423
|
+
commit_hash: z.string().describe('Commit hash to restore from'),
|
|
1424
|
+
confirm: z.boolean().optional().describe('Set to true ONLY after the user has approved the preview. Defaults to false.'),
|
|
1425
|
+
});
|
|
1426
|
+
server.registerTool('restore_file', { description: 'Restore an entry to its content at a specific commit. Preview-then-confirm: first call returns the preview payload, re-invoke with confirm: true to execute.', inputSchema: restoreFileSchema }, async (args) => {
|
|
1427
|
+
const { repo, entity_type, entity_id, commit_hash, confirm } = restoreFileSchema.parse(args);
|
|
1428
|
+
try {
|
|
1429
|
+
if (!hasRepoAccess(user, repo, wm, authService))
|
|
1430
|
+
return fail(`Folder "${repo}" not found`);
|
|
1431
|
+
if (!canWriteRepo(user, repo, wm, authService))
|
|
1432
|
+
return fail(`You don't have permission to write to "${repo}". Editor or admin role required.`);
|
|
1433
|
+
const graph = wm.getGraph(repo);
|
|
1434
|
+
if (confirm !== true) {
|
|
1435
|
+
const found = graph.getEntityAtCommit(entity_type, entity_id, commit_hash);
|
|
1436
|
+
if (!found)
|
|
1437
|
+
return fail(`Entry ${entity_type}/${entity_id} not found at commit ${commit_hash}`);
|
|
1438
|
+
let action = 'recreate';
|
|
1439
|
+
try {
|
|
1440
|
+
graph.get(entity_type, entity_id);
|
|
1441
|
+
action = 'overwrite';
|
|
1442
|
+
}
|
|
1443
|
+
catch { }
|
|
1444
|
+
const sizeBytes = Buffer.byteLength(found.content, 'utf-8');
|
|
1445
|
+
const shortHash = commit_hash.length > 8 ? commit_hash.slice(0, 8) : commit_hash;
|
|
1446
|
+
// Embeds the restored body will re-link. Restore rewrites the .md
|
|
1447
|
+
// body only; asset binaries live outside git and are NOT touched by
|
|
1448
|
+
// restore — they remain wherever they are (intact unless separately
|
|
1449
|
+
// deleted), so restoring the body re-links any that still exist.
|
|
1450
|
+
const embeds = extractAssetEmbeds(stripFrontmatter(found.content));
|
|
1451
|
+
const assetNote = embeds.length
|
|
1452
|
+
? `Restores the body and re-links ${embeds.length} embedded asset reference(s): ${embeds.join(', ')}. ` +
|
|
1453
|
+
`Asset binaries are stored outside git and are not modified by restore (they remain intact unless separately deleted). `
|
|
1454
|
+
: '';
|
|
1455
|
+
return ok({
|
|
1456
|
+
success: false,
|
|
1457
|
+
code: 'PREVIEW_REQUIRED',
|
|
1458
|
+
preview: { action, targetPath: found.path, sizeBytes, commitHash: shortHash, embeds, embedCount: embeds.length },
|
|
1459
|
+
message: `Will ${action} ${entity_type}/${entity_id} from ${shortHash} (${sizeBytes} bytes). ${assetNote}Re-invoke with confirm: true after approval.`,
|
|
1460
|
+
});
|
|
244
1461
|
}
|
|
245
|
-
|
|
246
|
-
|
|
1462
|
+
const result = await withAgentActivity(repo, 'editing', async () => {
|
|
1463
|
+
const { PathConflictError } = await import('../core/graph.js');
|
|
1464
|
+
try {
|
|
1465
|
+
return await graph.restoreFile(entity_type, entity_id, commit_hash);
|
|
1466
|
+
}
|
|
1467
|
+
catch (err) {
|
|
1468
|
+
if (err instanceof PathConflictError) {
|
|
1469
|
+
return { conflict: { path: err.path, occupiedBy: err.occupiedBy } };
|
|
1470
|
+
}
|
|
1471
|
+
throw err;
|
|
1472
|
+
}
|
|
1473
|
+
});
|
|
1474
|
+
if ('conflict' in result) {
|
|
1475
|
+
return ok({
|
|
1476
|
+
success: false,
|
|
1477
|
+
code: 'PATH_CONFLICT',
|
|
1478
|
+
conflict: result.conflict,
|
|
1479
|
+
message: `Cannot restore — ${result.conflict.path} is occupied by ${result.conflict.occupiedBy.entityType}/${result.conflict.occupiedBy.entityId}.`,
|
|
1480
|
+
});
|
|
247
1481
|
}
|
|
248
|
-
|
|
249
|
-
|
|
1482
|
+
emitEntityChange(result.action === 'recreate' ? 'created' : 'updated', repo, entity_type, entity_id);
|
|
1483
|
+
const shortHash = commit_hash.length > 8 ? commit_hash.slice(0, 8) : commit_hash;
|
|
1484
|
+
return ok({
|
|
1485
|
+
success: true,
|
|
1486
|
+
repo,
|
|
1487
|
+
entityType: entity_type,
|
|
1488
|
+
entityId: entity_id,
|
|
1489
|
+
action: result.action,
|
|
1490
|
+
path: result.path,
|
|
1491
|
+
commitHash: shortHash,
|
|
1492
|
+
message: `Restored ${entity_type}/${entity_id} from ${shortHash} (${result.action}).`,
|
|
1493
|
+
});
|
|
1494
|
+
}
|
|
1495
|
+
catch (err) {
|
|
1496
|
+
return fail(err);
|
|
1497
|
+
}
|
|
1498
|
+
});
|
|
250
1499
|
}
|
|
251
1500
|
//# sourceMappingURL=tools.js.map
|