studiograph 1.1.2 → 1.2.0-beta.1
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/LICENSE +191 -0
- package/README.md +301 -10
- package/dist/agent/orchestrator.d.ts +17 -9
- package/dist/agent/orchestrator.js +142 -97
- package/dist/agent/orchestrator.js.map +1 -1
- package/dist/agent/prompts/system.md +186 -0
- package/dist/agent/skill-loader.d.ts +48 -0
- package/dist/agent/skill-loader.js +166 -0
- package/dist/agent/skill-loader.js.map +1 -0
- package/dist/agent/skills/enrich-entities.md +136 -0
- package/dist/agent/skills/entity-schema.md +502 -0
- package/dist/agent/skills/gather-context.md +46 -0
- package/dist/agent/skills/obsidian-source-setup.md +246 -0
- package/dist/agent/skills/skill-loader.d.ts +48 -0
- package/dist/agent/skills/skill-loader.js +166 -0
- package/dist/agent/skills/skill-loader.js.map +1 -0
- package/dist/agent/skills/sync-configuration.md +144 -0
- package/dist/agent/skills/sync-setup.md +68 -0
- package/dist/agent/tools/connector-tools.d.ts +37 -0
- package/dist/agent/tools/connector-tools.js +132 -0
- package/dist/agent/tools/connector-tools.js.map +1 -0
- package/dist/agent/tools/fs-tools.d.ts +39 -0
- package/dist/agent/tools/fs-tools.js +106 -0
- package/dist/agent/tools/fs-tools.js.map +1 -0
- package/dist/agent/tools/graph-tools.d.ts +30 -2
- package/dist/agent/tools/graph-tools.js +154 -37
- package/dist/agent/tools/graph-tools.js.map +1 -1
- package/dist/agent/tools/load-skill.d.ts +42 -0
- package/dist/agent/tools/load-skill.js +45 -0
- package/dist/agent/tools/load-skill.js.map +1 -0
- package/dist/agent/tools/sync-tools.d.ts +25 -0
- package/dist/agent/tools/sync-tools.js +691 -0
- package/dist/agent/tools/sync-tools.js.map +1 -0
- package/dist/agent/tools/tool-loader.d.ts +25 -0
- package/dist/agent/tools/tool-loader.js +73 -0
- package/dist/agent/tools/tool-loader.js.map +1 -0
- package/dist/auth/github.d.ts +11 -8
- package/dist/auth/github.js +56 -75
- package/dist/auth/github.js.map +1 -1
- package/dist/cli/colors.d.ts +54 -0
- package/dist/cli/colors.js +133 -0
- package/dist/cli/colors.js.map +1 -0
- package/dist/cli/commands/app.d.ts +7 -0
- package/dist/cli/commands/app.js +167 -0
- package/dist/cli/commands/app.js.map +1 -0
- package/dist/cli/commands/auth.d.ts +1 -1
- package/dist/cli/commands/auth.js +26 -10
- package/dist/cli/commands/auth.js.map +1 -1
- package/dist/cli/commands/clone.d.ts +9 -0
- package/dist/cli/commands/clone.js +167 -0
- package/dist/cli/commands/clone.js.map +1 -0
- package/dist/cli/commands/commit.d.ts +8 -0
- package/dist/cli/commands/commit.js +43 -0
- package/dist/cli/commands/commit.js.map +1 -0
- package/dist/cli/commands/config.d.ts +13 -0
- package/dist/cli/commands/config.js +276 -0
- package/dist/cli/commands/config.js.map +1 -0
- package/dist/cli/commands/connector.d.ts +33 -0
- package/dist/cli/commands/connector.js +178 -0
- package/dist/cli/commands/connector.js.map +1 -0
- package/dist/cli/commands/deploy.d.ts +11 -0
- package/dist/cli/commands/deploy.js +153 -0
- package/dist/cli/commands/deploy.js.map +1 -0
- package/dist/cli/commands/enrich.d.ts +11 -0
- package/dist/cli/commands/enrich.js +135 -0
- package/dist/cli/commands/enrich.js.map +1 -0
- package/dist/cli/commands/graphrag.d.ts +12 -0
- package/dist/cli/commands/graphrag.js +122 -0
- package/dist/cli/commands/graphrag.js.map +1 -0
- package/dist/cli/commands/index.d.ts +15 -0
- package/dist/cli/commands/index.js +117 -0
- package/dist/cli/commands/index.js.map +1 -0
- package/dist/cli/commands/init.js +110 -210
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/join.js +89 -24
- package/dist/cli/commands/join.js.map +1 -1
- package/dist/cli/commands/lint.d.ts +8 -0
- package/dist/cli/commands/lint.js +70 -0
- package/dist/cli/commands/lint.js.map +1 -0
- package/dist/cli/commands/mcp.d.ts +27 -0
- package/dist/cli/commands/mcp.js +56 -0
- package/dist/cli/commands/mcp.js.map +1 -0
- package/dist/cli/commands/orphans.d.ts +8 -0
- package/dist/cli/commands/orphans.js +125 -0
- package/dist/cli/commands/orphans.js.map +1 -0
- package/dist/cli/commands/provision.d.ts +8 -0
- package/dist/cli/commands/provision.js +116 -0
- package/dist/cli/commands/provision.js.map +1 -0
- package/dist/cli/commands/r2.d.ts +2 -0
- package/dist/cli/commands/r2.js +87 -6
- package/dist/cli/commands/r2.js.map +1 -1
- package/dist/cli/commands/reset.d.ts +12 -0
- package/dist/cli/commands/reset.js +137 -0
- package/dist/cli/commands/reset.js.map +1 -0
- package/dist/cli/commands/review.d.ts +19 -0
- package/dist/cli/commands/review.js +128 -0
- package/dist/cli/commands/review.js.map +1 -0
- package/dist/cli/commands/serve.js +47 -2
- package/dist/cli/commands/serve.js.map +1 -1
- package/dist/cli/commands/source.d.ts +16 -0
- package/dist/cli/commands/source.js +159 -0
- package/dist/cli/commands/source.js.map +1 -0
- package/dist/cli/commands/start.js +472 -103
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/commands/sync-entities.d.ts +13 -0
- package/dist/cli/commands/sync-entities.js +242 -0
- package/dist/cli/commands/sync-entities.js.map +1 -0
- package/dist/cli/commands/sync.js +40 -9
- package/dist/cli/commands/sync.js.map +1 -1
- package/dist/cli/commands/update.d.ts +8 -0
- package/dist/cli/commands/update.js +155 -0
- package/dist/cli/commands/update.js.map +1 -0
- package/dist/cli/index.js +114 -3
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/scaffolding.d.ts +10 -0
- package/dist/cli/scaffolding.js +302 -0
- package/dist/cli/scaffolding.js.map +1 -0
- package/dist/cli/setup-wizard.d.ts +30 -0
- package/dist/cli/setup-wizard.js +244 -0
- package/dist/cli/setup-wizard.js.map +1 -0
- package/dist/cli/sync-review-interactive.d.ts +31 -0
- package/dist/cli/sync-review-interactive.js +393 -0
- package/dist/cli/sync-review-interactive.js.map +1 -0
- package/dist/cli/theme.d.ts +31 -0
- package/dist/cli/theme.js +116 -0
- package/dist/cli/theme.js.map +1 -0
- package/dist/core/graph.d.ts +16 -9
- package/dist/core/graph.js +263 -145
- package/dist/core/graph.js.map +1 -1
- package/dist/core/migration-runner.d.ts +42 -0
- package/dist/core/migration-runner.js +232 -0
- package/dist/core/migration-runner.js.map +1 -0
- package/dist/core/migration-types.d.ts +101 -0
- package/dist/core/migration-types.js +21 -0
- package/dist/core/migration-types.js.map +1 -0
- package/dist/core/migrations/20260219-formalize-memory-location.d.ts +2 -0
- package/dist/core/migrations/20260219-formalize-memory-location.js +35 -0
- package/dist/core/migrations/20260219-formalize-memory-location.js.map +1 -0
- package/dist/core/migrations/20260220-add-workspace-metadata.d.ts +12 -0
- package/dist/core/migrations/20260220-add-workspace-metadata.js +65 -0
- package/dist/core/migrations/20260220-add-workspace-metadata.js.map +1 -0
- package/dist/core/migrations/20260220-add-workspace-readme.d.ts +11 -0
- package/dist/core/migrations/20260220-add-workspace-readme.js +82 -0
- package/dist/core/migrations/20260220-add-workspace-readme.js.map +1 -0
- package/dist/core/migrations/20260220-migrate-yaml-to-json.d.ts +9 -0
- package/dist/core/migrations/20260220-migrate-yaml-to-json.js +64 -0
- package/dist/core/migrations/20260220-migrate-yaml-to-json.js.map +1 -0
- package/dist/core/migrations/index.d.ts +11 -0
- package/dist/core/migrations/index.js +23 -0
- package/dist/core/migrations/index.js.map +1 -0
- package/dist/core/schema-registry.d.ts +36 -0
- package/dist/core/schema-registry.js +161 -0
- package/dist/core/schema-registry.js.map +1 -0
- package/dist/core/types.d.ts +242 -3
- package/dist/core/types.js +21 -2
- package/dist/core/types.js.map +1 -1
- package/dist/core/user-config.d.ts +16 -0
- package/dist/core/user-config.js +8 -0
- package/dist/core/user-config.js.map +1 -1
- package/dist/core/validation.d.ts +973 -32
- package/dist/core/validation.js +163 -4
- package/dist/core/validation.js.map +1 -1
- package/dist/core/workspace-manager.d.ts +26 -2
- package/dist/core/workspace-manager.js +113 -15
- package/dist/core/workspace-manager.js.map +1 -1
- package/dist/core/workspace.d.ts +20 -11
- package/dist/core/workspace.js +123 -34
- package/dist/core/workspace.js.map +1 -1
- package/dist/mcp/connector-manager.d.ts +65 -0
- package/dist/mcp/connector-manager.js +223 -0
- package/dist/mcp/connector-manager.js.map +1 -0
- package/dist/mcp/connectors/asana.d.ts +2 -0
- package/dist/mcp/connectors/asana.js +20 -0
- package/dist/mcp/connectors/asana.js.map +1 -0
- package/dist/mcp/connectors/definitions.d.ts +45 -0
- package/dist/mcp/connectors/definitions.js +32 -0
- package/dist/mcp/connectors/definitions.js.map +1 -0
- package/dist/mcp/connectors/figma.d.ts +5 -0
- package/dist/mcp/connectors/figma.js +21 -0
- package/dist/mcp/connectors/figma.js.map +1 -0
- package/dist/mcp/connectors/gdrive.d.ts +2 -0
- package/dist/mcp/connectors/gdrive.js +20 -0
- package/dist/mcp/connectors/gdrive.js.map +1 -0
- package/dist/mcp/connectors/granola.d.ts +2 -0
- package/dist/mcp/connectors/granola.js +12 -0
- package/dist/mcp/connectors/granola.js.map +1 -0
- package/dist/mcp/connectors/linear.d.ts +2 -0
- package/dist/mcp/connectors/linear.js +19 -0
- package/dist/mcp/connectors/linear.js.map +1 -0
- package/dist/mcp/connectors/obsidian.d.ts +2 -0
- package/dist/mcp/connectors/obsidian.js +19 -0
- package/dist/mcp/connectors/obsidian.js.map +1 -0
- package/dist/mcp/connectors/pipedrive.d.ts +2 -0
- package/dist/mcp/connectors/pipedrive.js +20 -0
- package/dist/mcp/connectors/pipedrive.js.map +1 -0
- package/dist/mcp/connectors/slack.d.ts +2 -0
- package/dist/mcp/connectors/slack.js +21 -0
- package/dist/mcp/connectors/slack.js.map +1 -0
- package/dist/mcp/oauth-provider.d.ts +41 -0
- package/dist/mcp/oauth-provider.js +160 -0
- package/dist/mcp/oauth-provider.js.map +1 -0
- package/dist/mcp/server.d.ts +11 -0
- package/dist/mcp/server.js +28 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools.d.ts +14 -0
- package/dist/mcp/tools.js +172 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/server/index.js +17 -4
- package/dist/server/index.js.map +1 -1
- package/dist/server/plugin-loader.d.ts +15 -0
- package/dist/server/plugin-loader.js +68 -2
- package/dist/server/plugin-loader.js.map +1 -1
- package/dist/server/routes/graph-api.js +1 -1
- package/dist/server/routes/graph-api.js.map +1 -1
- package/dist/server/routes/webhook.js +33 -0
- package/dist/server/routes/webhook.js.map +1 -1
- package/dist/services/github-provisioner.d.ts +9 -3
- package/dist/services/github-provisioner.js +46 -8
- package/dist/services/github-provisioner.js.map +1 -1
- package/dist/services/lint-service.d.ts +27 -0
- package/dist/services/lint-service.js +83 -0
- package/dist/services/lint-service.js.map +1 -0
- package/dist/services/markdown.d.ts +9 -0
- package/dist/services/markdown.js +26 -5
- package/dist/services/markdown.js.map +1 -1
- package/dist/services/memory-service.d.ts +1 -2
- package/dist/services/memory-service.js +5 -4
- package/dist/services/memory-service.js.map +1 -1
- package/dist/services/orphan-service.d.ts +31 -0
- package/dist/services/orphan-service.js +100 -0
- package/dist/services/orphan-service.js.map +1 -0
- package/dist/services/sync/commit.d.ts +58 -0
- package/dist/services/sync/commit.js +350 -0
- package/dist/services/sync/commit.js.map +1 -0
- package/dist/services/sync/context-index.d.ts +69 -0
- package/dist/services/sync/context-index.js +280 -0
- package/dist/services/sync/context-index.js.map +1 -0
- package/dist/services/sync/derive.d.ts +34 -0
- package/dist/services/sync/derive.js +164 -0
- package/dist/services/sync/derive.js.map +1 -0
- package/dist/services/sync/enrichment-state.d.ts +31 -0
- package/dist/services/sync/enrichment-state.js +63 -0
- package/dist/services/sync/enrichment-state.js.map +1 -0
- package/dist/services/sync/enrichment.d.ts +25 -0
- package/dist/services/sync/enrichment.js +121 -0
- package/dist/services/sync/enrichment.js.map +1 -0
- package/dist/services/sync/frontmatter-extractor.d.ts +40 -0
- package/dist/services/sync/frontmatter-extractor.js +273 -0
- package/dist/services/sync/frontmatter-extractor.js.map +1 -0
- package/dist/services/sync/graph-match-state.d.ts +33 -0
- package/dist/services/sync/graph-match-state.js +61 -0
- package/dist/services/sync/graph-match-state.js.map +1 -0
- package/dist/services/sync/graph-match.d.ts +53 -0
- package/dist/services/sync/graph-match.js +316 -0
- package/dist/services/sync/graph-match.js.map +1 -0
- package/dist/services/sync/graphrag-client.d.ts +43 -0
- package/dist/services/sync/graphrag-client.js +94 -0
- package/dist/services/sync/graphrag-client.js.map +1 -0
- package/dist/services/sync/graphrag-config.d.ts +16 -0
- package/dist/services/sync/graphrag-config.js +39 -0
- package/dist/services/sync/graphrag-config.js.map +1 -0
- package/dist/services/sync/graphrag-context.d.ts +14 -0
- package/dist/services/sync/graphrag-context.js +109 -0
- package/dist/services/sync/graphrag-context.js.map +1 -0
- package/dist/services/sync/graphrag-indexer.d.ts +30 -0
- package/dist/services/sync/graphrag-indexer.js +358 -0
- package/dist/services/sync/graphrag-indexer.js.map +1 -0
- package/dist/services/sync/llm.d.ts +32 -0
- package/dist/services/sync/llm.js +115 -0
- package/dist/services/sync/llm.js.map +1 -0
- package/dist/services/sync/mcp-client.d.ts +59 -0
- package/dist/services/sync/mcp-client.js +285 -0
- package/dist/services/sync/mcp-client.js.map +1 -0
- package/dist/services/sync/model-factory.d.ts +10 -0
- package/dist/services/sync/model-factory.js +24 -0
- package/dist/services/sync/model-factory.js.map +1 -0
- package/dist/services/sync/name-quality.d.ts +31 -0
- package/dist/services/sync/name-quality.js +60 -0
- package/dist/services/sync/name-quality.js.map +1 -0
- package/dist/services/sync/output-schemas.d.ts +92 -0
- package/dist/services/sync/output-schemas.js +43 -0
- package/dist/services/sync/output-schemas.js.map +1 -0
- package/dist/services/sync/prompts.d.ts +19 -0
- package/dist/services/sync/prompts.js +128 -0
- package/dist/services/sync/prompts.js.map +1 -0
- package/dist/services/sync/reconciler.d.ts +48 -0
- package/dist/services/sync/reconciler.js +295 -0
- package/dist/services/sync/reconciler.js.map +1 -0
- package/dist/services/sync/source-config.d.ts +45 -0
- package/dist/services/sync/source-config.js +208 -0
- package/dist/services/sync/source-config.js.map +1 -0
- package/dist/services/sync/source-definitions/asana.d.ts +15 -0
- package/dist/services/sync/source-definitions/asana.js +48 -0
- package/dist/services/sync/source-definitions/asana.js.map +1 -0
- package/dist/services/sync/source-definitions/definitions.d.ts +21 -0
- package/dist/services/sync/source-definitions/definitions.js +26 -0
- package/dist/services/sync/source-definitions/definitions.js.map +1 -0
- package/dist/services/sync/source-definitions/gdrive.d.ts +16 -0
- package/dist/services/sync/source-definitions/gdrive.js +68 -0
- package/dist/services/sync/source-definitions/gdrive.js.map +1 -0
- package/dist/services/sync/source-definitions/granola.d.ts +2 -0
- package/dist/services/sync/source-definitions/granola.js +28 -0
- package/dist/services/sync/source-definitions/granola.js.map +1 -0
- package/dist/services/sync/source-definitions/linear.d.ts +2 -0
- package/dist/services/sync/source-definitions/linear.js +60 -0
- package/dist/services/sync/source-definitions/linear.js.map +1 -0
- package/dist/services/sync/source-definitions/obsidian.d.ts +2 -0
- package/dist/services/sync/source-definitions/obsidian.js +55 -0
- package/dist/services/sync/source-definitions/obsidian.js.map +1 -0
- package/dist/services/sync/source-definitions/pipedrive.d.ts +2 -0
- package/dist/services/sync/source-definitions/pipedrive.js +52 -0
- package/dist/services/sync/source-definitions/pipedrive.js.map +1 -0
- package/dist/services/sync/staging.d.ts +53 -0
- package/dist/services/sync/staging.js +131 -0
- package/dist/services/sync/staging.js.map +1 -0
- package/dist/services/sync/structured-extractor.d.ts +49 -0
- package/dist/services/sync/structured-extractor.js +344 -0
- package/dist/services/sync/structured-extractor.js.map +1 -0
- package/dist/services/sync/sync-runner.d.ts +32 -0
- package/dist/services/sync/sync-runner.js +195 -0
- package/dist/services/sync/sync-runner.js.map +1 -0
- package/dist/services/sync/sync-state.d.ts +43 -0
- package/dist/services/sync/sync-state.js +154 -0
- package/dist/services/sync/sync-state.js.map +1 -0
- package/dist/services/sync/types.d.ts +203 -0
- package/dist/services/sync/types.js +8 -0
- package/dist/services/sync/types.js.map +1 -0
- package/dist/services/sync/unstructured-extractor.d.ts +29 -0
- package/dist/services/sync/unstructured-extractor.js +197 -0
- package/dist/services/sync/unstructured-extractor.js.map +1 -0
- package/dist/services/vector-service.d.ts +88 -0
- package/dist/services/vector-service.js +322 -0
- package/dist/services/vector-service.js.map +1 -0
- package/dist/utils/git.d.ts +26 -4
- package/dist/utils/git.js +55 -7
- package/dist/utils/git.js.map +1 -1
- package/dist/utils/merge-resolver.d.ts +34 -0
- package/dist/utils/merge-resolver.js +201 -0
- package/dist/utils/merge-resolver.js.map +1 -0
- package/dist/utils/preflight.d.ts +2 -1
- package/dist/utils/preflight.js +8 -1
- package/dist/utils/preflight.js.map +1 -1
- package/dist/utils/version-checker.d.ts +23 -0
- package/dist/utils/version-checker.js +116 -0
- package/dist/utils/version-checker.js.map +1 -0
- package/dist/utils/workspace-config.d.ts +8 -0
- package/dist/utils/workspace-config.js +22 -0
- package/dist/utils/workspace-config.js.map +1 -0
- package/package.json +24 -11
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sync-setup
|
|
3
|
+
description: Guide for setting up and running entity sync from external sources
|
|
4
|
+
loading: eager
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Entity Sync
|
|
8
|
+
|
|
9
|
+
You can sync data from external sources (Linear, Pipedrive, Granola, Obsidian, etc.) into the knowledge graph using the sync tools.
|
|
10
|
+
|
|
11
|
+
## First-Time Setup
|
|
12
|
+
|
|
13
|
+
1. **Check what's available:** Call `sync_list_sources` immediately — it returns configured sources (with full entity_mappings), available connectors, and known source definitions
|
|
14
|
+
2. **Verify the connector exists** — connectors hold API credentials and are CLI-only for security. If missing, tell the user:
|
|
15
|
+
> "You'll need to set up the connector first. Run `studiograph connector add <name>` in your terminal."
|
|
16
|
+
3. **Add the source:** `sync_setup_source({ name: "linear" })` — uses default mappings from built-in definitions when available
|
|
17
|
+
4. **Customize if needed:** Built-in definitions (Pipedrive, Granola, Linear, Asana) provide ready-to-use defaults. To customize, pass `entity_mappings` to `sync_setup_source` to override field maps, add co-location, change target repos, or add status maps. See the `sync-configuration` skill for field map syntax and options.
|
|
18
|
+
5. **No built-in definition?** Guide the user through building `entity_mappings` from scratch — choose extraction mode, define field maps, set target repo. Reference the `sync-configuration` skill for the full mapping schema.
|
|
19
|
+
6. **Run the sync:** `sync_run({ sources: ["linear"] })`
|
|
20
|
+
7. **Review staging:** `sync_status` — show the user what will be committed
|
|
21
|
+
8. **Apply on confirmation:** Only call `sync_apply` after the user approves
|
|
22
|
+
9. **Review & commit:** `studiograph review` (interactive diff review with approve/reject per entity), then `studiograph commit` (git commit across all repos)
|
|
23
|
+
|
|
24
|
+
## Modifying an Existing Source
|
|
25
|
+
|
|
26
|
+
When a user asks to adjust, change, or view a source config, **immediately call `sync_list_sources`** to read the current configuration. Do not ask the user to paste the config — you can read it yourself.
|
|
27
|
+
|
|
28
|
+
1. `sync_list_sources` — call this FIRST, before asking questions (returns full `entity_mappings` with field maps, transforms, etc.)
|
|
29
|
+
2. Show the user the relevant parts of their config and ask what they want to change
|
|
30
|
+
3. Build the updated `entity_mappings` array (you must pass the complete array — it replaces, not merges)
|
|
31
|
+
4. `sync_setup_source({ name: "...", entity_mappings: [...], force: true })` — overwrite with updated config
|
|
32
|
+
|
|
33
|
+
Common adjustments: changing `field_map` entries, adding/removing entity mappings, changing `target_repo`, adding `co_locate`, switching `write_mode`, adjusting `status_map`, adding `list_tool`/`read_tool`.
|
|
34
|
+
|
|
35
|
+
## Repeat Sync Flow
|
|
36
|
+
|
|
37
|
+
1. `sync_run({ incremental: true })` — only fetches records updated since last sync
|
|
38
|
+
2. `sync_status` — present the summary
|
|
39
|
+
3. Wait for user confirmation
|
|
40
|
+
4. `sync_apply` — writes entity files (no git commit)
|
|
41
|
+
5. `workspace_status` — show what files changed across repos
|
|
42
|
+
6. `workspace_review` — show diffs (optionally filter by `entityType`)
|
|
43
|
+
7. `workspace_commit({ messagePrefix: "sync" })` — git commits across repos (or let user run `studiograph commit`)
|
|
44
|
+
|
|
45
|
+
## Post-Apply Results
|
|
46
|
+
|
|
47
|
+
After `sync_apply`, explain what happened to the user:
|
|
48
|
+
|
|
49
|
+
- **Standard entities** are written as: `{target_repo}/{entity_id}/main.md` (entity folder with sentinel file)
|
|
50
|
+
- **Co-located entities** are written as: `{target_repo}/{parent_id}/{subfolder}/{entity_id}.md` (flat file inside parent folder). Co-located files are sub-content, not graph entities.
|
|
51
|
+
- **Skipped entities** — when co-location is configured but the parent field is empty or missing, those entities are skipped (not an error)
|
|
52
|
+
- **Auto-registered repos** — if a `target_repo` doesn't exist yet, it's automatically created and registered in the workspace
|
|
53
|
+
|
|
54
|
+
## Troubleshooting
|
|
55
|
+
|
|
56
|
+
- **"Uncommitted changes"** — sync requires a clean working tree. Tell the user to commit or stash changes first, or use `--force` to override
|
|
57
|
+
- **"Connector not found"** — the connector isn't set up. User must run `studiograph connector add <name>` in terminal
|
|
58
|
+
- **Entities skipped during apply** — for co-located entities, check that the `parent_field` has a value in the extracted frontmatter. Missing parent = skip.
|
|
59
|
+
- **Obsidian template file** — Obsidian creates a `.template` file instead of default mappings (every vault is different). Tell the user to copy mappings from the template into the source config and adjust `directory_patterns` and `field_map` for their vault.
|
|
60
|
+
|
|
61
|
+
## Important Rules
|
|
62
|
+
|
|
63
|
+
- **Never auto-commit** — always show `sync_status` and get user confirmation before `sync_apply`
|
|
64
|
+
- **Connector management is CLI-only** — API keys and tokens must be set up via `studiograph connector add/remove`. Never ask users to provide API keys in chat
|
|
65
|
+
- **Use incremental for repeat syncs** — avoids re-processing unchanged records
|
|
66
|
+
- **Use dry run for previews** — `sync_run({ dryRun: true })` shows what would be extracted without writing staging
|
|
67
|
+
- **Abort if needed** — `sync_abort` clears staging if the user wants to start over
|
|
68
|
+
- **sync_commit is deprecated** — use `sync_apply` then `workspace_commit` instead
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* On-demand connector tools
|
|
3
|
+
*
|
|
4
|
+
* Instead of registering hundreds of individual MCP connector tools with the
|
|
5
|
+
* agent (which bloats every API call), this module provides two lightweight
|
|
6
|
+
* proxy tools:
|
|
7
|
+
*
|
|
8
|
+
* connector_list — discover available connectors and their tools
|
|
9
|
+
* connector_call — route a call to a specific connector tool
|
|
10
|
+
*
|
|
11
|
+
* The actual MCP tool wrappers are stored in a registry built from
|
|
12
|
+
* ConnectorManager.buildTools() output.
|
|
13
|
+
*/
|
|
14
|
+
export interface ConnectorToolEntry {
|
|
15
|
+
/** Namespaced name: "pipedrive__deals_search" */
|
|
16
|
+
name: string;
|
|
17
|
+
/** Local name within the connector: "deals_search" */
|
|
18
|
+
localName: string;
|
|
19
|
+
/** Connector name: "pipedrive" */
|
|
20
|
+
connector: string;
|
|
21
|
+
description: string;
|
|
22
|
+
parameters: any;
|
|
23
|
+
execute: (toolCallId: string, params: any) => Promise<any>;
|
|
24
|
+
}
|
|
25
|
+
export interface ConnectorRegistry {
|
|
26
|
+
connectors: Map<string, ConnectorToolEntry[]>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Build a registry from ConnectorManager's wrapped tool objects.
|
|
30
|
+
* Parses the namespaced tool names (e.g. "pipedrive__deals_search")
|
|
31
|
+
* into connector → tool[] groupings.
|
|
32
|
+
*/
|
|
33
|
+
export declare function buildConnectorRegistry(tools: any[]): ConnectorRegistry;
|
|
34
|
+
/**
|
|
35
|
+
* Create two proxy tools for on-demand connector access.
|
|
36
|
+
*/
|
|
37
|
+
export declare function createConnectorTools(registry: ConnectorRegistry): any[];
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* On-demand connector tools
|
|
3
|
+
*
|
|
4
|
+
* Instead of registering hundreds of individual MCP connector tools with the
|
|
5
|
+
* agent (which bloats every API call), this module provides two lightweight
|
|
6
|
+
* proxy tools:
|
|
7
|
+
*
|
|
8
|
+
* connector_list — discover available connectors and their tools
|
|
9
|
+
* connector_call — route a call to a specific connector tool
|
|
10
|
+
*
|
|
11
|
+
* The actual MCP tool wrappers are stored in a registry built from
|
|
12
|
+
* ConnectorManager.buildTools() output.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Build a registry from ConnectorManager's wrapped tool objects.
|
|
16
|
+
* Parses the namespaced tool names (e.g. "pipedrive__deals_search")
|
|
17
|
+
* into connector → tool[] groupings.
|
|
18
|
+
*/
|
|
19
|
+
export function buildConnectorRegistry(tools) {
|
|
20
|
+
const connectors = new Map();
|
|
21
|
+
for (const tool of tools) {
|
|
22
|
+
const sep = tool.name.indexOf('__');
|
|
23
|
+
const connector = sep !== -1 ? tool.name.slice(0, sep) : tool.name;
|
|
24
|
+
const localName = sep !== -1 ? tool.name.slice(sep + 2) : tool.name;
|
|
25
|
+
if (!connectors.has(connector))
|
|
26
|
+
connectors.set(connector, []);
|
|
27
|
+
connectors.get(connector).push({
|
|
28
|
+
name: tool.name,
|
|
29
|
+
localName,
|
|
30
|
+
connector,
|
|
31
|
+
description: tool.description ?? '',
|
|
32
|
+
parameters: tool.parameters,
|
|
33
|
+
execute: tool.execute,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return { connectors };
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Create two proxy tools for on-demand connector access.
|
|
40
|
+
*/
|
|
41
|
+
export function createConnectorTools(registry) {
|
|
42
|
+
return [
|
|
43
|
+
{
|
|
44
|
+
name: 'connector_list',
|
|
45
|
+
description: 'List available external connectors and their tools. Call with no arguments to see all connectors, or with connector name to see its tools, or with both connector and tool to see a tool\'s parameter schema.',
|
|
46
|
+
parameters: {
|
|
47
|
+
type: 'object',
|
|
48
|
+
properties: {
|
|
49
|
+
connector: {
|
|
50
|
+
type: 'string',
|
|
51
|
+
description: 'Show tools for this connector (e.g. "pipedrive", "linear")',
|
|
52
|
+
},
|
|
53
|
+
tool: {
|
|
54
|
+
type: 'string',
|
|
55
|
+
description: 'Show the parameter schema for this specific tool',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
execute: async (_toolCallId, params) => {
|
|
60
|
+
// Specific tool schema
|
|
61
|
+
if (params.connector && params.tool) {
|
|
62
|
+
const tools = registry.connectors.get(params.connector);
|
|
63
|
+
if (!tools) {
|
|
64
|
+
return { content: [{ type: 'text', text: `Connector "${params.connector}" not found. Available: ${[...registry.connectors.keys()].join(', ')}` }] };
|
|
65
|
+
}
|
|
66
|
+
const tool = tools.find(t => t.localName === params.tool);
|
|
67
|
+
if (!tool) {
|
|
68
|
+
return { content: [{ type: 'text', text: `Tool "${params.tool}" not found in ${params.connector}.` }] };
|
|
69
|
+
}
|
|
70
|
+
return { content: [{ type: 'text', text: `${params.connector} / ${params.tool}\n${tool.description}\n\nParameters:\n${JSON.stringify(tool.parameters, null, 2)}` }] };
|
|
71
|
+
}
|
|
72
|
+
// Tools for a specific connector
|
|
73
|
+
if (params.connector) {
|
|
74
|
+
const tools = registry.connectors.get(params.connector);
|
|
75
|
+
if (!tools) {
|
|
76
|
+
return { content: [{ type: 'text', text: `Connector "${params.connector}" not found. Available: ${[...registry.connectors.keys()].join(', ')}` }] };
|
|
77
|
+
}
|
|
78
|
+
const list = tools.map(t => `- ${t.localName}: ${t.description}`).join('\n');
|
|
79
|
+
return { content: [{ type: 'text', text: `${params.connector} (${tools.length} tools):\n${list}` }] };
|
|
80
|
+
}
|
|
81
|
+
// All connectors overview
|
|
82
|
+
const summary = [...registry.connectors.entries()]
|
|
83
|
+
.map(([name, tools]) => `- ${name} (${tools.length} tools)`)
|
|
84
|
+
.join('\n');
|
|
85
|
+
return { content: [{ type: 'text', text: `Available connectors:\n${summary}\n\nCall with connector to see available tools.` }] };
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: 'connector_call',
|
|
90
|
+
description: 'Call a tool on an external service (Pipedrive, Linear, Granola, Asana, Obsidian). Use connector_list first to discover available tools and their parameters.',
|
|
91
|
+
parameters: {
|
|
92
|
+
type: 'object',
|
|
93
|
+
properties: {
|
|
94
|
+
connector: {
|
|
95
|
+
type: 'string',
|
|
96
|
+
description: 'Connector name (e.g. "pipedrive", "linear", "granola")',
|
|
97
|
+
},
|
|
98
|
+
tool: {
|
|
99
|
+
type: 'string',
|
|
100
|
+
description: 'Tool name within the connector (e.g. "deals_search", "list_issues")',
|
|
101
|
+
},
|
|
102
|
+
arguments: {
|
|
103
|
+
type: 'object',
|
|
104
|
+
description: 'Arguments to pass to the tool',
|
|
105
|
+
additionalProperties: true,
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
required: ['connector', 'tool'],
|
|
109
|
+
},
|
|
110
|
+
execute: async (_toolCallId, params) => {
|
|
111
|
+
const tools = registry.connectors.get(params.connector);
|
|
112
|
+
if (!tools) {
|
|
113
|
+
return {
|
|
114
|
+
content: [{ type: 'text', text: `Connector "${params.connector}" not found. Available: ${[...registry.connectors.keys()].join(', ')}` }],
|
|
115
|
+
isError: true,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
const tool = tools.find(t => t.localName === params.tool);
|
|
119
|
+
if (!tool) {
|
|
120
|
+
const available = tools.slice(0, 20).map(t => t.localName).join(', ');
|
|
121
|
+
const suffix = tools.length > 20 ? ` ... and ${tools.length - 20} more` : '';
|
|
122
|
+
return {
|
|
123
|
+
content: [{ type: 'text', text: `Tool "${params.tool}" not found in ${params.connector}. Available: ${available}${suffix}` }],
|
|
124
|
+
isError: true,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
return tool.execute(_toolCallId, params.arguments || {});
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
];
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=connector-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connector-tools.js","sourceRoot":"","sources":["../../../src/agent/tools/connector-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAkBH;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAAY;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C,MAAM,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;oBAC7E,OAAO;wBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,SAAS,MAAM,CAAC,IAAI,kBAAkB,MAAM,CAAC,SAAS,gBAAgB,SAAS,GAAG,MAAM,EAAE,EAAE,CAAC;wBACtI,OAAO,EAAE,IAAI;qBACd,CAAC;gBACJ,CAAC;gBACD,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;YAC3D,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filesystem tools for the agent.
|
|
3
|
+
*
|
|
4
|
+
* Gives the agent read/write access to local files outside the workspace
|
|
5
|
+
* (e.g. Obsidian vaults, project docs, config files).
|
|
6
|
+
*/
|
|
7
|
+
export declare function createFsTools(): ({
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
parameters: import("@sinclair/typebox").TObject<{
|
|
11
|
+
path: import("@sinclair/typebox").TString;
|
|
12
|
+
}>;
|
|
13
|
+
execute: (_toolCallId: string, params: {
|
|
14
|
+
path: string;
|
|
15
|
+
}) => Promise<{
|
|
16
|
+
content: {
|
|
17
|
+
type: "text";
|
|
18
|
+
text: string;
|
|
19
|
+
}[];
|
|
20
|
+
details: any;
|
|
21
|
+
}>;
|
|
22
|
+
} | {
|
|
23
|
+
name: string;
|
|
24
|
+
description: string;
|
|
25
|
+
parameters: import("@sinclair/typebox").TObject<{
|
|
26
|
+
path: import("@sinclair/typebox").TString;
|
|
27
|
+
content: import("@sinclair/typebox").TString;
|
|
28
|
+
}>;
|
|
29
|
+
execute: (_toolCallId: string, params: {
|
|
30
|
+
path: string;
|
|
31
|
+
content: string;
|
|
32
|
+
}) => Promise<{
|
|
33
|
+
content: {
|
|
34
|
+
type: "text";
|
|
35
|
+
text: string;
|
|
36
|
+
}[];
|
|
37
|
+
details: any;
|
|
38
|
+
}>;
|
|
39
|
+
})[];
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filesystem tools for the agent.
|
|
3
|
+
*
|
|
4
|
+
* Gives the agent read/write access to local files outside the workspace
|
|
5
|
+
* (e.g. Obsidian vaults, project docs, config files).
|
|
6
|
+
*/
|
|
7
|
+
import { readFileSync, writeFileSync, mkdirSync, readdirSync, statSync, existsSync } from 'fs';
|
|
8
|
+
import { join, resolve, dirname } from 'path';
|
|
9
|
+
import { Type as T } from '@sinclair/typebox';
|
|
10
|
+
import { wrapToolResult } from './graph-tools.js';
|
|
11
|
+
export function createFsTools() {
|
|
12
|
+
return [
|
|
13
|
+
{
|
|
14
|
+
name: 'read_file',
|
|
15
|
+
description: 'Read a file from the local filesystem by absolute or ~-relative path. ' +
|
|
16
|
+
'Returns the file contents as text. Use for reading docs, configs, or any file outside the workspace.',
|
|
17
|
+
parameters: T.Object({
|
|
18
|
+
path: T.String({ description: 'Absolute path or ~/relative path to the file' }),
|
|
19
|
+
}),
|
|
20
|
+
execute: async (_toolCallId, params) => {
|
|
21
|
+
try {
|
|
22
|
+
const resolved = resolvePath(params.path);
|
|
23
|
+
const stat = statSync(resolved);
|
|
24
|
+
if (stat.isDirectory()) {
|
|
25
|
+
return wrapToolResult({
|
|
26
|
+
success: false,
|
|
27
|
+
error: `Path is a directory, not a file. Use list_directory instead.`,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
const content = readFileSync(resolved, 'utf-8');
|
|
31
|
+
return wrapToolResult({ success: true, path: resolved, content });
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
return wrapToolResult({
|
|
35
|
+
success: false,
|
|
36
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'list_directory',
|
|
43
|
+
description: 'List files and subdirectories at a given path. ' +
|
|
44
|
+
'Returns names with a trailing / for directories. Use to explore folders before reading files.',
|
|
45
|
+
parameters: T.Object({
|
|
46
|
+
path: T.String({ description: 'Absolute path or ~/relative path to the directory' }),
|
|
47
|
+
}),
|
|
48
|
+
execute: async (_toolCallId, params) => {
|
|
49
|
+
try {
|
|
50
|
+
const resolved = resolvePath(params.path);
|
|
51
|
+
if (!existsSync(resolved)) {
|
|
52
|
+
return wrapToolResult({ success: false, error: `Path not found: ${resolved}` });
|
|
53
|
+
}
|
|
54
|
+
const entries = readdirSync(resolved).map(name => {
|
|
55
|
+
const full = join(resolved, name);
|
|
56
|
+
try {
|
|
57
|
+
return statSync(full).isDirectory() ? `${name}/` : name;
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return name;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
return wrapToolResult({ success: true, path: resolved, entries });
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
return wrapToolResult({
|
|
67
|
+
success: false,
|
|
68
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: 'write_file',
|
|
75
|
+
description: 'Write content to a file on the local filesystem. Creates parent directories if needed. ' +
|
|
76
|
+
'Overwrites the file if it already exists. Use for creating or updating docs, configs, or any file outside the workspace.',
|
|
77
|
+
parameters: T.Object({
|
|
78
|
+
path: T.String({ description: 'Absolute path or ~/relative path to the file' }),
|
|
79
|
+
content: T.String({ description: 'Full file content to write' }),
|
|
80
|
+
}),
|
|
81
|
+
execute: async (_toolCallId, params) => {
|
|
82
|
+
try {
|
|
83
|
+
const resolved = resolvePath(params.path);
|
|
84
|
+
mkdirSync(dirname(resolved), { recursive: true });
|
|
85
|
+
writeFileSync(resolved, params.content, 'utf-8');
|
|
86
|
+
return wrapToolResult({ success: true, path: resolved, bytesWritten: Buffer.byteLength(params.content, 'utf-8') });
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
return wrapToolResult({
|
|
90
|
+
success: false,
|
|
91
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
];
|
|
97
|
+
}
|
|
98
|
+
/** Expand ~ and resolve to absolute path */
|
|
99
|
+
function resolvePath(p) {
|
|
100
|
+
if (p.startsWith('~/') || p === '~') {
|
|
101
|
+
const home = process.env.HOME ?? process.env.USERPROFILE ?? '';
|
|
102
|
+
return resolve(join(home, p.slice(1)));
|
|
103
|
+
}
|
|
104
|
+
return resolve(p);
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=fs-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-tools.js","sourceRoot":"","sources":["../../../src/agent/tools/fs-tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAC/F,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,EAAE,IAAI,IAAI,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,UAAU,aAAa;IAC3B,OAAO;QACL;YACE,IAAI,EAAE,WAAW;YACjB,WAAW,EACT,wEAAwE;gBACxE,sGAAsG;YACxG,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC;gBACnB,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,8CAA8C,EAAE,CAAC;aAChF,CAAC;YACF,OAAO,EAAE,KAAK,EAAE,WAAmB,EAAE,MAAw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AAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;oBAClD,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;oBACjD,OAAO,cAAc,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;gBACrH,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,OAAO,cAAc,CAAC;wBACpB,OAAO,EAAE,KAAK;wBACd,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe;qBAChE,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;SACF;KACF,CAAC;AACJ,CAAC;AAED,4CAA4C;AAC5C,SAAS,WAAW,CAAC,CAAS;IAC5B,IAAI,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QACpC,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,CAAC;QAC/D,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC"}
|
|
@@ -8,6 +8,16 @@
|
|
|
8
8
|
* - Upload assets
|
|
9
9
|
*/
|
|
10
10
|
import { WorkspaceManager } from '../../core/workspace-manager.js';
|
|
11
|
+
/**
|
|
12
|
+
* Helper to wrap tool results in AgentToolResult format
|
|
13
|
+
*/
|
|
14
|
+
export declare function wrapToolResult(result: any): {
|
|
15
|
+
content: {
|
|
16
|
+
type: "text";
|
|
17
|
+
text: string;
|
|
18
|
+
}[];
|
|
19
|
+
details: any;
|
|
20
|
+
};
|
|
11
21
|
/**
|
|
12
22
|
* Create graph tools for the agent
|
|
13
23
|
*/
|
|
@@ -15,7 +25,7 @@ export declare function createGraphTools(workspaceManager: WorkspaceManager, git
|
|
|
15
25
|
id: string;
|
|
16
26
|
name: string;
|
|
17
27
|
email: string;
|
|
18
|
-
}): {
|
|
28
|
+
}, workspacePath?: string): ({
|
|
19
29
|
name: string;
|
|
20
30
|
label: string;
|
|
21
31
|
description: string;
|
|
@@ -27,4 +37,22 @@ export declare function createGraphTools(workspaceManager: WorkspaceManager, git
|
|
|
27
37
|
}[];
|
|
28
38
|
details: any;
|
|
29
39
|
}>;
|
|
30
|
-
}
|
|
40
|
+
} | {
|
|
41
|
+
name: string;
|
|
42
|
+
label: string;
|
|
43
|
+
description: string;
|
|
44
|
+
parameters: import("@sinclair/typebox").TObject<{
|
|
45
|
+
repo: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
46
|
+
entityType: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
47
|
+
}>;
|
|
48
|
+
execute: (toolCallId: string, params: {
|
|
49
|
+
repo?: string;
|
|
50
|
+
entityType?: string;
|
|
51
|
+
}) => Promise<{
|
|
52
|
+
content: {
|
|
53
|
+
type: "text";
|
|
54
|
+
text: string;
|
|
55
|
+
}[];
|
|
56
|
+
details: any;
|
|
57
|
+
}>;
|
|
58
|
+
})[];
|