@useactor/core 0.1.0 → 0.2.3
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/dist/auth/google-auth.d.ts +75 -0
- package/dist/auth/google-auth.d.ts.map +1 -0
- package/dist/auth/google-auth.js +447 -0
- package/dist/auth/google-auth.js.map +1 -0
- package/dist/auth/oauth-callback-page.d.ts +4 -0
- package/dist/auth/oauth-callback-page.d.ts.map +1 -0
- package/dist/auth/oauth-callback-page.js +131 -0
- package/dist/auth/oauth-callback-page.js.map +1 -0
- package/dist/auth/openai-auth.d.ts +48 -0
- package/dist/auth/openai-auth.d.ts.map +1 -0
- package/dist/auth/openai-auth.js +350 -0
- package/dist/auth/openai-auth.js.map +1 -0
- package/dist/{artifacts.d.ts → events/artifacts.d.ts} +1 -1
- package/dist/events/artifacts.d.ts.map +1 -0
- package/dist/events/artifacts.js.map +1 -0
- package/dist/{events.d.ts → events/events.d.ts} +16 -2
- package/dist/events/events.d.ts.map +1 -0
- package/dist/{events.js → events/events.js} +3 -0
- package/dist/events/events.js.map +1 -0
- package/dist/{feedback.d.ts → events/feedback.d.ts} +1 -1
- package/dist/events/feedback.d.ts.map +1 -0
- package/dist/events/feedback.js.map +1 -0
- package/dist/{local-event-logger.d.ts → events/local-event-logger.d.ts} +1 -1
- package/dist/events/local-event-logger.d.ts.map +1 -0
- package/dist/{local-event-logger.js → events/local-event-logger.js} +11 -0
- package/dist/events/local-event-logger.js.map +1 -0
- package/dist/{local-event-schema.d.ts → events/local-event-schema.d.ts} +10 -3
- package/dist/events/local-event-schema.d.ts.map +1 -0
- package/dist/events/local-event-schema.js.map +1 -0
- package/dist/index.d.ts +59 -35
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +59 -35
- package/dist/index.js.map +1 -1
- package/dist/integrations/built-in-integrations.d.ts +2 -0
- package/dist/integrations/built-in-integrations.d.ts.map +1 -0
- package/dist/integrations/built-in-integrations.js +2 -0
- package/dist/integrations/built-in-integrations.js.map +1 -0
- package/dist/integrations/first-party-cli-integration.d.ts +2 -0
- package/dist/integrations/first-party-cli-integration.d.ts.map +1 -0
- package/dist/integrations/first-party-cli-integration.js +2 -0
- package/dist/integrations/first-party-cli-integration.js.map +1 -0
- package/dist/integrations/google-workspace-integration.d.ts +2 -0
- package/dist/integrations/google-workspace-integration.d.ts.map +1 -0
- package/dist/integrations/google-workspace-integration.js +2 -0
- package/dist/integrations/google-workspace-integration.js.map +1 -0
- package/dist/integrations/integrations.d.ts +2 -0
- package/dist/integrations/integrations.d.ts.map +1 -0
- package/dist/integrations/integrations.js +2 -0
- package/dist/integrations/integrations.js.map +1 -0
- package/dist/integrations/monoid-integration.d.ts +2 -0
- package/dist/integrations/monoid-integration.d.ts.map +1 -0
- package/dist/integrations/monoid-integration.js +2 -0
- package/dist/integrations/monoid-integration.js.map +1 -0
- package/dist/integrations/pilfer-integration.d.ts +2 -0
- package/dist/integrations/pilfer-integration.d.ts.map +1 -0
- package/dist/integrations/pilfer-integration.js +2 -0
- package/dist/integrations/pilfer-integration.js.map +1 -0
- package/dist/integrations/wyrdos-integration.d.ts +2 -0
- package/dist/integrations/wyrdos-integration.d.ts.map +1 -0
- package/dist/integrations/wyrdos-integration.js +2 -0
- package/dist/integrations/wyrdos-integration.js.map +1 -0
- package/dist/keybindings/shell-keybindings.d.ts +139 -0
- package/dist/keybindings/shell-keybindings.d.ts.map +1 -0
- package/dist/keybindings/shell-keybindings.js +453 -0
- package/dist/keybindings/shell-keybindings.js.map +1 -0
- package/dist/plugins/built-in-integrations.d.ts +3 -0
- package/dist/plugins/built-in-integrations.d.ts.map +1 -0
- package/dist/plugins/built-in-integrations.js +13 -0
- package/dist/plugins/built-in-integrations.js.map +1 -0
- package/dist/plugins/first-party-cli-integration.d.ts +62 -0
- package/dist/plugins/first-party-cli-integration.d.ts.map +1 -0
- package/dist/plugins/first-party-cli-integration.js +524 -0
- package/dist/plugins/first-party-cli-integration.js.map +1 -0
- package/dist/plugins/google-docs.d.ts +30 -0
- package/dist/plugins/google-docs.d.ts.map +1 -0
- package/dist/plugins/google-docs.js +487 -0
- package/dist/plugins/google-docs.js.map +1 -0
- package/dist/plugins/google-drive.d.ts +84 -0
- package/dist/plugins/google-drive.d.ts.map +1 -0
- package/dist/plugins/google-drive.js +307 -0
- package/dist/plugins/google-drive.js.map +1 -0
- package/dist/plugins/google-sheets.d.ts +122 -0
- package/dist/plugins/google-sheets.d.ts.map +1 -0
- package/dist/plugins/google-sheets.js +290 -0
- package/dist/plugins/google-sheets.js.map +1 -0
- package/dist/plugins/google-slides.d.ts +125 -0
- package/dist/plugins/google-slides.d.ts.map +1 -0
- package/dist/plugins/google-slides.js +285 -0
- package/dist/plugins/google-slides.js.map +1 -0
- package/dist/plugins/google-workspace-api.d.ts +16 -0
- package/dist/plugins/google-workspace-api.d.ts.map +1 -0
- package/dist/plugins/google-workspace-api.js +42 -0
- package/dist/plugins/google-workspace-api.js.map +1 -0
- package/dist/plugins/google-workspace-integration.d.ts +22 -0
- package/dist/plugins/google-workspace-integration.d.ts.map +1 -0
- package/dist/plugins/google-workspace-integration.js +1353 -0
- package/dist/plugins/google-workspace-integration.js.map +1 -0
- package/dist/plugins/google-workspace-oauth.d.ts +80 -0
- package/dist/plugins/google-workspace-oauth.d.ts.map +1 -0
- package/dist/plugins/google-workspace-oauth.js +187 -0
- package/dist/plugins/google-workspace-oauth.js.map +1 -0
- package/dist/plugins/monoid-integration.d.ts +11 -0
- package/dist/plugins/monoid-integration.d.ts.map +1 -0
- package/dist/plugins/monoid-integration.js +14 -0
- package/dist/plugins/monoid-integration.js.map +1 -0
- package/dist/plugins/pilfer-integration.d.ts +10 -0
- package/dist/plugins/pilfer-integration.d.ts.map +1 -0
- package/dist/plugins/pilfer-integration.js +13 -0
- package/dist/plugins/pilfer-integration.js.map +1 -0
- package/dist/plugins/plugins.d.ts +78 -0
- package/dist/plugins/plugins.d.ts.map +1 -0
- package/dist/plugins/plugins.js +81 -0
- package/dist/plugins/plugins.js.map +1 -0
- package/dist/plugins/wyrdos-integration.d.ts +11 -0
- package/dist/plugins/wyrdos-integration.d.ts.map +1 -0
- package/dist/plugins/wyrdos-integration.js +14 -0
- package/dist/plugins/wyrdos-integration.js.map +1 -0
- package/dist/{ai-sdk-provider.d.ts → providers/ai-sdk-provider.d.ts} +2 -2
- package/dist/providers/ai-sdk-provider.d.ts.map +1 -0
- package/dist/{ai-sdk-provider.js → providers/ai-sdk-provider.js} +132 -37
- package/dist/providers/ai-sdk-provider.js.map +1 -0
- package/dist/providers/api-key-providers.d.ts +25 -0
- package/dist/providers/api-key-providers.d.ts.map +1 -0
- package/dist/providers/api-key-providers.js +67 -0
- package/dist/providers/api-key-providers.js.map +1 -0
- package/dist/providers/definitions/anthropic-provider.d.ts +421 -0
- package/dist/providers/definitions/anthropic-provider.d.ts.map +1 -0
- package/dist/providers/definitions/anthropic-provider.js +204 -0
- package/dist/providers/definitions/anthropic-provider.js.map +1 -0
- package/dist/{codex-oauth-provider.d.ts → providers/definitions/codex-oauth-provider.d.ts} +2 -2
- package/dist/providers/definitions/codex-oauth-provider.d.ts.map +1 -0
- package/dist/{codex-oauth-provider.js → providers/definitions/codex-oauth-provider.js} +1 -1
- package/dist/providers/definitions/codex-oauth-provider.js.map +1 -0
- package/dist/providers/definitions/deepseek-provider.d.ts +25 -0
- package/dist/providers/definitions/deepseek-provider.d.ts.map +1 -0
- package/dist/providers/definitions/deepseek-provider.js +28 -0
- package/dist/providers/definitions/deepseek-provider.js.map +1 -0
- package/dist/providers/definitions/google-ai-oauth.d.ts +79 -0
- package/dist/providers/definitions/google-ai-oauth.d.ts.map +1 -0
- package/dist/providers/definitions/google-ai-oauth.js +177 -0
- package/dist/providers/definitions/google-ai-oauth.js.map +1 -0
- package/dist/providers/definitions/google-provider.d.ts +166 -0
- package/dist/providers/definitions/google-provider.d.ts.map +1 -0
- package/dist/providers/definitions/google-provider.js +93 -0
- package/dist/providers/definitions/google-provider.js.map +1 -0
- package/dist/providers/definitions/moonshot-provider.d.ts +28 -0
- package/dist/providers/definitions/moonshot-provider.d.ts.map +1 -0
- package/dist/providers/definitions/moonshot-provider.js +34 -0
- package/dist/providers/definitions/moonshot-provider.js.map +1 -0
- package/dist/{openai-oauth.d.ts → providers/definitions/openai-oauth.d.ts} +1 -1
- package/dist/providers/definitions/openai-oauth.d.ts.map +1 -0
- package/dist/providers/definitions/openai-oauth.js.map +1 -0
- package/dist/providers/definitions/openai-provider.d.ts +177 -0
- package/dist/providers/definitions/openai-provider.d.ts.map +1 -0
- package/dist/{model-catalog.js → providers/definitions/openai-provider.js} +33 -21
- package/dist/providers/definitions/openai-provider.js.map +1 -0
- package/dist/providers/definitions/perplexity-provider.d.ts +34 -0
- package/dist/providers/definitions/perplexity-provider.d.ts.map +1 -0
- package/dist/providers/definitions/perplexity-provider.js +46 -0
- package/dist/providers/definitions/perplexity-provider.js.map +1 -0
- package/dist/providers/definitions/xai-provider.d.ts +68 -0
- package/dist/providers/definitions/xai-provider.d.ts.map +1 -0
- package/dist/providers/definitions/xai-provider.js +102 -0
- package/dist/providers/definitions/xai-provider.js.map +1 -0
- package/dist/{mock-provider.d.ts → providers/mock-provider.d.ts} +1 -1
- package/dist/providers/mock-provider.d.ts.map +1 -0
- package/dist/providers/mock-provider.js.map +1 -0
- package/dist/{model-catalog.d.ts → providers/model-catalog.d.ts} +2 -2
- package/dist/providers/model-catalog.d.ts.map +1 -0
- package/dist/providers/model-catalog.js +31 -0
- package/dist/providers/model-catalog.js.map +1 -0
- package/dist/providers/provider-failures.d.ts +14 -0
- package/dist/providers/provider-failures.d.ts.map +1 -0
- package/dist/providers/provider-failures.js +146 -0
- package/dist/providers/provider-failures.js.map +1 -0
- package/dist/providers/provider-status.d.ts +24 -0
- package/dist/providers/provider-status.d.ts.map +1 -0
- package/dist/providers/provider-status.js +63 -0
- package/dist/providers/provider-status.js.map +1 -0
- package/dist/{providers.d.ts → providers/providers.d.ts} +1 -1
- package/dist/providers/providers.d.ts.map +1 -0
- package/dist/providers/providers.js.map +1 -0
- package/dist/{secrets.d.ts → providers/secrets.d.ts} +24 -0
- package/dist/providers/secrets.d.ts.map +1 -0
- package/dist/{secrets.js → providers/secrets.js} +82 -2
- package/dist/providers/secrets.js.map +1 -0
- package/dist/{app-runtime.d.ts → runtime/app-runtime.d.ts} +8 -7
- package/dist/runtime/app-runtime.d.ts.map +1 -0
- package/dist/{app-runtime.js → runtime/app-runtime.js} +58 -28
- package/dist/runtime/app-runtime.js.map +1 -0
- package/dist/runtime/in-memory-runtime.d.ts +15 -0
- package/dist/runtime/in-memory-runtime.d.ts.map +1 -0
- package/dist/{in-memory-runtime.js → runtime/in-memory-runtime.js} +135 -29
- package/dist/runtime/in-memory-runtime.js.map +1 -0
- package/dist/runtime/renderer-api.d.ts +123 -0
- package/dist/runtime/renderer-api.d.ts.map +1 -0
- package/dist/{renderer-api.js.map → runtime/renderer-api.js.map} +1 -1
- package/dist/{runtime-tool-execution.d.ts → runtime/runtime-tool-execution.d.ts} +8 -3
- package/dist/runtime/runtime-tool-execution.d.ts.map +1 -0
- package/dist/runtime/runtime-tool-execution.js +733 -0
- package/dist/runtime/runtime-tool-execution.js.map +1 -0
- package/dist/{runtime.d.ts → runtime/runtime.d.ts} +31 -4
- package/dist/runtime/runtime.d.ts.map +1 -0
- package/dist/{runtime.js → runtime/runtime.js} +24 -0
- package/dist/runtime/runtime.js.map +1 -0
- package/dist/{history.d.ts → sessions/history.d.ts} +3 -2
- package/dist/sessions/history.d.ts.map +1 -0
- package/dist/{history.js → sessions/history.js} +55 -1
- package/dist/sessions/history.js.map +1 -0
- package/dist/{session-actions.d.ts → sessions/session-actions.d.ts} +2 -2
- package/dist/sessions/session-actions.d.ts.map +1 -0
- package/dist/{session-actions.js → sessions/session-actions.js} +2 -2
- package/dist/sessions/session-actions.js.map +1 -0
- package/dist/{cli-defined-tools.d.ts → tools/cli-defined-tools.d.ts} +2 -2
- package/dist/tools/cli-defined-tools.d.ts.map +1 -0
- package/dist/tools/cli-defined-tools.js.map +1 -0
- package/dist/tools/document-tools.d.ts +92 -0
- package/dist/tools/document-tools.d.ts.map +1 -0
- package/dist/tools/document-tools.js +430 -0
- package/dist/tools/document-tools.js.map +1 -0
- package/dist/{local-tools.d.ts → tools/local-tools.d.ts} +25 -0
- package/dist/tools/local-tools.d.ts.map +1 -0
- package/dist/tools/local-tools.js +944 -0
- package/dist/tools/local-tools.js.map +1 -0
- package/dist/tools/mcp-server-config.d.ts.map +1 -0
- package/dist/tools/mcp-server-config.js.map +1 -0
- package/dist/tools/permission-grant-store.d.ts.map +1 -0
- package/dist/tools/permission-grant-store.js.map +1 -0
- package/dist/{permission-grants.d.ts → tools/permission-grants.d.ts} +1 -1
- package/dist/tools/permission-grants.d.ts.map +1 -0
- package/dist/{permission-grants.js → tools/permission-grants.js} +31 -1
- package/dist/tools/permission-grants.js.map +1 -0
- package/dist/tools/project-app-defaults-tool.d.ts +4 -0
- package/dist/tools/project-app-defaults-tool.d.ts.map +1 -0
- package/dist/tools/project-app-defaults-tool.js +135 -0
- package/dist/tools/project-app-defaults-tool.js.map +1 -0
- package/dist/{project-tool-registry.d.ts → tools/project-tool-registry.d.ts} +2 -2
- package/dist/tools/project-tool-registry.d.ts.map +1 -0
- package/dist/{project-tool-registry.js → tools/project-tool-registry.js} +47 -9
- package/dist/tools/project-tool-registry.js.map +1 -0
- package/dist/{question-requests.d.ts → tools/question-requests.d.ts} +2 -2
- package/dist/tools/question-requests.d.ts.map +1 -0
- package/dist/{question-requests.js → tools/question-requests.js} +3 -2
- package/dist/tools/question-requests.js.map +1 -0
- package/dist/tools/subagent-task-tool.d.ts +8 -0
- package/dist/tools/subagent-task-tool.d.ts.map +1 -0
- package/dist/tools/subagent-task-tool.js +38 -0
- package/dist/tools/subagent-task-tool.js.map +1 -0
- package/dist/{tool-requests.d.ts → tools/tool-requests.d.ts} +4 -3
- package/dist/tools/tool-requests.d.ts.map +1 -0
- package/dist/{tool-requests.js → tools/tool-requests.js} +15 -4
- package/dist/tools/tool-requests.js.map +1 -0
- package/dist/{tools.d.ts → tools/tools.d.ts} +7 -1
- package/dist/tools/tools.d.ts.map +1 -0
- package/dist/{tools.js → tools/tools.js} +21 -0
- package/dist/tools/tools.js.map +1 -0
- package/dist/tools/update-plan-tool.d.ts +14 -0
- package/dist/tools/update-plan-tool.d.ts.map +1 -0
- package/dist/tools/update-plan-tool.js +83 -0
- package/dist/tools/update-plan-tool.js.map +1 -0
- package/dist/{personas.d.ts → workspace/personas.d.ts} +42 -1
- package/dist/workspace/personas.d.ts.map +1 -0
- package/dist/workspace/personas.js +457 -0
- package/dist/workspace/personas.js.map +1 -0
- package/dist/{projects.d.ts → workspace/projects.d.ts} +35 -5
- package/dist/workspace/projects.d.ts.map +1 -0
- package/dist/{projects.js → workspace/projects.js} +111 -3
- package/dist/workspace/projects.js.map +1 -0
- package/dist/{prompt-context.d.ts → workspace/prompt-context.d.ts} +5 -2
- package/dist/workspace/prompt-context.d.ts.map +1 -0
- package/dist/workspace/prompt-context.js +406 -0
- package/dist/workspace/prompt-context.js.map +1 -0
- package/dist/workspace/proposed-plan.d.ts.map +1 -0
- package/dist/workspace/proposed-plan.js.map +1 -0
- package/dist/workspace/repository-instructions.d.ts +20 -0
- package/dist/workspace/repository-instructions.d.ts.map +1 -0
- package/dist/workspace/repository-instructions.js +111 -0
- package/dist/workspace/repository-instructions.js.map +1 -0
- package/dist/{skills.d.ts → workspace/skills.d.ts} +23 -2
- package/dist/workspace/skills.d.ts.map +1 -0
- package/dist/{skills.js → workspace/skills.js} +129 -5
- package/dist/workspace/skills.js.map +1 -0
- package/package.json +15 -2
- package/dist/ai-sdk-provider.d.ts.map +0 -1
- package/dist/ai-sdk-provider.js.map +0 -1
- package/dist/app-runtime.d.ts.map +0 -1
- package/dist/app-runtime.js.map +0 -1
- package/dist/artifacts.d.ts.map +0 -1
- package/dist/artifacts.js.map +0 -1
- package/dist/cli-defined-tools.d.ts.map +0 -1
- package/dist/cli-defined-tools.js.map +0 -1
- package/dist/codex-oauth-provider.d.ts.map +0 -1
- package/dist/codex-oauth-provider.js.map +0 -1
- package/dist/events.d.ts.map +0 -1
- package/dist/events.js.map +0 -1
- package/dist/feedback.d.ts.map +0 -1
- package/dist/feedback.js.map +0 -1
- package/dist/history.d.ts.map +0 -1
- package/dist/history.js.map +0 -1
- package/dist/in-memory-runtime.d.ts +0 -12
- package/dist/in-memory-runtime.d.ts.map +0 -1
- package/dist/in-memory-runtime.js.map +0 -1
- package/dist/integrations.d.ts +0 -37
- package/dist/integrations.d.ts.map +0 -1
- package/dist/integrations.js +0 -48
- package/dist/integrations.js.map +0 -1
- package/dist/local-event-logger.d.ts.map +0 -1
- package/dist/local-event-logger.js.map +0 -1
- package/dist/local-event-schema.d.ts.map +0 -1
- package/dist/local-event-schema.js.map +0 -1
- package/dist/local-tools.d.ts.map +0 -1
- package/dist/local-tools.js +0 -418
- package/dist/local-tools.js.map +0 -1
- package/dist/mcp-server-config.d.ts.map +0 -1
- package/dist/mcp-server-config.js.map +0 -1
- package/dist/mock-provider.d.ts.map +0 -1
- package/dist/mock-provider.js.map +0 -1
- package/dist/model-catalog.d.ts.map +0 -1
- package/dist/model-catalog.js.map +0 -1
- package/dist/monoid-integration.d.ts +0 -33
- package/dist/monoid-integration.d.ts.map +0 -1
- package/dist/monoid-integration.js +0 -184
- package/dist/monoid-integration.js.map +0 -1
- package/dist/openai-oauth.d.ts.map +0 -1
- package/dist/openai-oauth.js.map +0 -1
- package/dist/permission-grant-store.d.ts.map +0 -1
- package/dist/permission-grant-store.js.map +0 -1
- package/dist/permission-grants.d.ts.map +0 -1
- package/dist/permission-grants.js.map +0 -1
- package/dist/personas.d.ts.map +0 -1
- package/dist/personas.js +0 -137
- package/dist/personas.js.map +0 -1
- package/dist/project-tool-registry.d.ts.map +0 -1
- package/dist/project-tool-registry.js.map +0 -1
- package/dist/projects.d.ts.map +0 -1
- package/dist/projects.js.map +0 -1
- package/dist/prompt-context.d.ts.map +0 -1
- package/dist/prompt-context.js +0 -170
- package/dist/prompt-context.js.map +0 -1
- package/dist/proposed-plan.d.ts.map +0 -1
- package/dist/proposed-plan.js.map +0 -1
- package/dist/providers.d.ts.map +0 -1
- package/dist/providers.js.map +0 -1
- package/dist/question-requests.d.ts.map +0 -1
- package/dist/question-requests.js.map +0 -1
- package/dist/renderer-api.d.ts +0 -52
- package/dist/renderer-api.d.ts.map +0 -1
- package/dist/runtime-tool-execution.d.ts.map +0 -1
- package/dist/runtime-tool-execution.js +0 -245
- package/dist/runtime-tool-execution.js.map +0 -1
- package/dist/runtime.d.ts.map +0 -1
- package/dist/runtime.js.map +0 -1
- package/dist/secrets.d.ts.map +0 -1
- package/dist/secrets.js.map +0 -1
- package/dist/session-actions.d.ts.map +0 -1
- package/dist/session-actions.js.map +0 -1
- package/dist/skills.d.ts.map +0 -1
- package/dist/skills.js.map +0 -1
- package/dist/tool-requests.d.ts.map +0 -1
- package/dist/tool-requests.js.map +0 -1
- package/dist/tools.d.ts.map +0 -1
- package/dist/tools.js.map +0 -1
- package/dist/wyrdos-integration.d.ts +0 -32
- package/dist/wyrdos-integration.d.ts.map +0 -1
- package/dist/wyrdos-integration.js +0 -183
- package/dist/wyrdos-integration.js.map +0 -1
- /package/dist/{artifacts.js → events/artifacts.js} +0 -0
- /package/dist/{feedback.js → events/feedback.js} +0 -0
- /package/dist/{local-event-schema.js → events/local-event-schema.js} +0 -0
- /package/dist/{openai-oauth.js → providers/definitions/openai-oauth.js} +0 -0
- /package/dist/{mock-provider.js → providers/mock-provider.js} +0 -0
- /package/dist/{providers.js → providers/providers.js} +0 -0
- /package/dist/{renderer-api.js → runtime/renderer-api.js} +0 -0
- /package/dist/{cli-defined-tools.js → tools/cli-defined-tools.js} +0 -0
- /package/dist/{mcp-server-config.d.ts → tools/mcp-server-config.d.ts} +0 -0
- /package/dist/{mcp-server-config.js → tools/mcp-server-config.js} +0 -0
- /package/dist/{permission-grant-store.d.ts → tools/permission-grant-store.d.ts} +0 -0
- /package/dist/{permission-grant-store.js → tools/permission-grant-store.js} +0 -0
- /package/dist/{proposed-plan.d.ts → workspace/proposed-plan.d.ts} +0 -0
- /package/dist/{proposed-plan.js → workspace/proposed-plan.js} +0 -0
|
@@ -0,0 +1,733 @@
|
|
|
1
|
+
import { createTaskProgressEvent, createToolCallEvent, createToolResultEvent, } from "../events/events.js";
|
|
2
|
+
import { classifyShellSandboxProfile } from "../tools/local-tools.js";
|
|
3
|
+
const googleWorkspaceWriteToolNames = new Set([
|
|
4
|
+
"google_drive_create_folder",
|
|
5
|
+
"google_drive_create_text_file",
|
|
6
|
+
"google_drive_rename_file",
|
|
7
|
+
"google_drive_move_file",
|
|
8
|
+
"google_drive_trash_file",
|
|
9
|
+
"google_docs_create",
|
|
10
|
+
"google_docs_append_text",
|
|
11
|
+
"google_docs_replace_text",
|
|
12
|
+
"google_sheets_create",
|
|
13
|
+
"google_sheets_update_range",
|
|
14
|
+
"google_sheets_append_rows",
|
|
15
|
+
"google_sheets_clear_range",
|
|
16
|
+
"google_sheets_add_sheet",
|
|
17
|
+
"google_sheets_rename_sheet",
|
|
18
|
+
"google_sheets_delete_sheet",
|
|
19
|
+
"google_sheets_format_range",
|
|
20
|
+
"google_sheets_batch_update",
|
|
21
|
+
"google_slides_create",
|
|
22
|
+
"google_slides_create_slide",
|
|
23
|
+
"google_slides_delete_object",
|
|
24
|
+
"google_slides_create_text_box",
|
|
25
|
+
"google_slides_replace_text",
|
|
26
|
+
"google_slides_create_image",
|
|
27
|
+
"google_slides_create_shape",
|
|
28
|
+
"google_slides_create_table",
|
|
29
|
+
"google_slides_update_text_style",
|
|
30
|
+
"google_slides_update_shape_style",
|
|
31
|
+
"google_slides_batch_update",
|
|
32
|
+
]);
|
|
33
|
+
export async function handleToolCall(input) {
|
|
34
|
+
const target = extractPermissionTarget(input.toolName, input.input);
|
|
35
|
+
const sandboxProfile = inferSandboxProfile(input.toolName, input.input);
|
|
36
|
+
const descriptor = {
|
|
37
|
+
toolId: input.toolName,
|
|
38
|
+
action: "call",
|
|
39
|
+
reason: `Model requested tool ${input.toolName}.`,
|
|
40
|
+
riskLevel: inferToolRiskLevel(input.toolName),
|
|
41
|
+
...(sandboxProfile ? { sandboxProfile } : {}),
|
|
42
|
+
...(target ? { target } : {}),
|
|
43
|
+
preview: JSON.stringify(input.input),
|
|
44
|
+
availableDecisions: getAvailableApprovalDecisions(input.toolName, target),
|
|
45
|
+
};
|
|
46
|
+
const tool = input.toolRegistry?.getTool(input.toolName);
|
|
47
|
+
if (!tool) {
|
|
48
|
+
const message = `Tool unavailable: ${input.toolName}`;
|
|
49
|
+
input.emit(createToolResultEvent(input.context, {
|
|
50
|
+
toolCallId: input.toolCallId,
|
|
51
|
+
toolId: input.toolName,
|
|
52
|
+
status: "error",
|
|
53
|
+
durationMs: 0,
|
|
54
|
+
summary: message,
|
|
55
|
+
}));
|
|
56
|
+
return { content: message };
|
|
57
|
+
}
|
|
58
|
+
if (input.toolName === "task" && input.executeSubagentTask) {
|
|
59
|
+
input.emit(createToolCallEvent(input.context, input.toolCallId, descriptor));
|
|
60
|
+
return executeSubagentTaskTool({
|
|
61
|
+
input: input.input,
|
|
62
|
+
context: input.context,
|
|
63
|
+
toolCallId: input.toolCallId,
|
|
64
|
+
toolName: input.toolName,
|
|
65
|
+
executeSubagentTask: input.executeSubagentTask,
|
|
66
|
+
emit: input.emit,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
const executeTool = () => {
|
|
70
|
+
const startedAt = Date.now();
|
|
71
|
+
const context = {
|
|
72
|
+
...input.context,
|
|
73
|
+
timestamp: new Date().toISOString(),
|
|
74
|
+
};
|
|
75
|
+
return tool
|
|
76
|
+
.executor(input.input, {
|
|
77
|
+
sessionId: input.context.sessionId,
|
|
78
|
+
runId: input.context.runId,
|
|
79
|
+
...(input.project ? { project: input.project } : {}),
|
|
80
|
+
})
|
|
81
|
+
.then((result) => {
|
|
82
|
+
emitTaskProgressIfPresent({
|
|
83
|
+
context,
|
|
84
|
+
toolCallId: input.toolCallId,
|
|
85
|
+
toolName: input.toolName,
|
|
86
|
+
result,
|
|
87
|
+
emit: input.emit,
|
|
88
|
+
});
|
|
89
|
+
input.emit(createToolResultEvent(context, {
|
|
90
|
+
toolCallId: input.toolCallId,
|
|
91
|
+
toolId: input.toolName,
|
|
92
|
+
status: "success",
|
|
93
|
+
durationMs: Date.now() - startedAt,
|
|
94
|
+
...summarizeToolResult(descriptor, result),
|
|
95
|
+
}));
|
|
96
|
+
return result;
|
|
97
|
+
})
|
|
98
|
+
.catch((error) => {
|
|
99
|
+
const message = safeErrorMessage(error);
|
|
100
|
+
input.emit(createToolResultEvent(context, {
|
|
101
|
+
toolCallId: input.toolCallId,
|
|
102
|
+
toolId: input.toolName,
|
|
103
|
+
status: "error",
|
|
104
|
+
durationMs: Date.now() - startedAt,
|
|
105
|
+
summary: message,
|
|
106
|
+
}));
|
|
107
|
+
return { content: `Tool failed: ${message}` };
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
if (tool.permissionPolicy === "never" || tool.permissionPolicy === "always") {
|
|
111
|
+
input.emit(createToolCallEvent(input.context, input.toolCallId, descriptor));
|
|
112
|
+
return executeTool();
|
|
113
|
+
}
|
|
114
|
+
const permissionRequest = input.project
|
|
115
|
+
? {
|
|
116
|
+
projectId: input.project.id,
|
|
117
|
+
sessionId: input.context.sessionId,
|
|
118
|
+
toolId: input.toolName,
|
|
119
|
+
action: "call",
|
|
120
|
+
...(target ? { target } : {}),
|
|
121
|
+
}
|
|
122
|
+
: undefined;
|
|
123
|
+
const pendingRequest = {
|
|
124
|
+
runId: input.context.runId,
|
|
125
|
+
sessionId: input.context.sessionId,
|
|
126
|
+
requestId: input.toolCallId,
|
|
127
|
+
descriptor,
|
|
128
|
+
...(permissionRequest ? { permissionRequest } : {}),
|
|
129
|
+
context: input.context,
|
|
130
|
+
};
|
|
131
|
+
const grantResult = await input.lifecycle.executeWithMatchingGrant(pendingRequest, () => {
|
|
132
|
+
input.emit(createToolCallEvent(input.context, input.toolCallId, descriptor));
|
|
133
|
+
return executeTool();
|
|
134
|
+
});
|
|
135
|
+
if (grantResult) {
|
|
136
|
+
return grantResult.toolResult;
|
|
137
|
+
}
|
|
138
|
+
const pending = input.lifecycle.requestToolExecution(pendingRequest, executeTool);
|
|
139
|
+
input.emit(pending.event);
|
|
140
|
+
const decisionResult = await pending.result;
|
|
141
|
+
if (decisionResult.status === "unknown_request") {
|
|
142
|
+
return { content: "Tool request could not be resolved." };
|
|
143
|
+
}
|
|
144
|
+
input.emit(decisionResult.event);
|
|
145
|
+
if (decisionResult.status === "denied") {
|
|
146
|
+
return { content: "Tool request denied by the user." };
|
|
147
|
+
}
|
|
148
|
+
if (decisionResult.status === "redirected") {
|
|
149
|
+
return {
|
|
150
|
+
content: `Tool request redirected by the user: ${decisionResult.instruction}`,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
return decisionResult.toolResult;
|
|
154
|
+
}
|
|
155
|
+
async function executeSubagentTaskTool(input) {
|
|
156
|
+
const startedAt = Date.now();
|
|
157
|
+
const context = {
|
|
158
|
+
...input.context,
|
|
159
|
+
timestamp: new Date().toISOString(),
|
|
160
|
+
};
|
|
161
|
+
try {
|
|
162
|
+
const taskInput = parseRuntimeSubagentTaskInput(input.input);
|
|
163
|
+
const result = await input.executeSubagentTask(taskInput);
|
|
164
|
+
input.emit(createToolResultEvent(context, {
|
|
165
|
+
toolCallId: input.toolCallId,
|
|
166
|
+
toolId: input.toolName,
|
|
167
|
+
status: "success",
|
|
168
|
+
durationMs: Date.now() - startedAt,
|
|
169
|
+
summary: result.content.slice(0, 200),
|
|
170
|
+
metadata: {
|
|
171
|
+
subagent: true,
|
|
172
|
+
...(result.metadata
|
|
173
|
+
? Object.fromEntries(Object.entries(result.metadata).filter((entry) => ["string", "number", "boolean"].includes(typeof entry[1]) || entry[1] === null))
|
|
174
|
+
: {}),
|
|
175
|
+
},
|
|
176
|
+
}));
|
|
177
|
+
return result;
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
const message = safeErrorMessage(error);
|
|
181
|
+
input.emit(createToolResultEvent(context, {
|
|
182
|
+
toolCallId: input.toolCallId,
|
|
183
|
+
toolId: input.toolName,
|
|
184
|
+
status: "error",
|
|
185
|
+
durationMs: Date.now() - startedAt,
|
|
186
|
+
summary: message,
|
|
187
|
+
}));
|
|
188
|
+
return { content: `Tool failed: ${message}` };
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
function parseRuntimeSubagentTaskInput(input) {
|
|
192
|
+
if (!input || typeof input !== "object" || Array.isArray(input)) {
|
|
193
|
+
throw new Error("Subagent task input must be an object.");
|
|
194
|
+
}
|
|
195
|
+
const record = input;
|
|
196
|
+
if (typeof record.task !== "string" || !record.task.trim()) {
|
|
197
|
+
throw new Error("Subagent task is required.");
|
|
198
|
+
}
|
|
199
|
+
return {
|
|
200
|
+
task: record.task,
|
|
201
|
+
...(typeof record.context === "string" && record.context.trim()
|
|
202
|
+
? { context: record.context }
|
|
203
|
+
: {}),
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
function inferSandboxProfile(toolName, input) {
|
|
207
|
+
if (toolName !== "bash" ||
|
|
208
|
+
!input ||
|
|
209
|
+
typeof input !== "object" ||
|
|
210
|
+
Array.isArray(input)) {
|
|
211
|
+
return undefined;
|
|
212
|
+
}
|
|
213
|
+
const command = input.command;
|
|
214
|
+
return typeof command === "string" && command.trim()
|
|
215
|
+
? classifyShellSandboxProfile(command)
|
|
216
|
+
: undefined;
|
|
217
|
+
}
|
|
218
|
+
function extractPermissionTarget(toolName, input) {
|
|
219
|
+
if (!input || typeof input !== "object" || Array.isArray(input)) {
|
|
220
|
+
return undefined;
|
|
221
|
+
}
|
|
222
|
+
const record = input;
|
|
223
|
+
if (toolName === "bash" && typeof record.command === "string") {
|
|
224
|
+
const prefix = deriveCommandPrefix(record.command);
|
|
225
|
+
if (prefix.length > 0) {
|
|
226
|
+
return `command-prefix:${JSON.stringify(prefix)}`;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (toolName.startsWith("google_drive_")) {
|
|
230
|
+
const driveTarget = extractGoogleDrivePermissionTarget(toolName, record);
|
|
231
|
+
if (driveTarget) {
|
|
232
|
+
return driveTarget;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
if (toolName.startsWith("google_docs_")) {
|
|
236
|
+
const docsTarget = extractGoogleDocsPermissionTarget(toolName, record);
|
|
237
|
+
if (docsTarget) {
|
|
238
|
+
return docsTarget;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (toolName.startsWith("google_sheets_")) {
|
|
242
|
+
const sheetsTarget = extractGoogleSheetsPermissionTarget(toolName, record);
|
|
243
|
+
if (sheetsTarget) {
|
|
244
|
+
return sheetsTarget;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
if (toolName.startsWith("google_slides_")) {
|
|
248
|
+
const slidesTarget = extractGoogleSlidesPermissionTarget(toolName, record);
|
|
249
|
+
if (slidesTarget) {
|
|
250
|
+
return slidesTarget;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (typeof record.path === "string" && record.path.trim()) {
|
|
254
|
+
return record.path.trim();
|
|
255
|
+
}
|
|
256
|
+
if (typeof record.target === "string" && record.target.trim()) {
|
|
257
|
+
return record.target.trim();
|
|
258
|
+
}
|
|
259
|
+
if (Array.isArray(record.args) && record.args.length > 0) {
|
|
260
|
+
const args = record.args
|
|
261
|
+
.map((value) => String(value).trim())
|
|
262
|
+
.filter(Boolean);
|
|
263
|
+
if (args.length > 0) {
|
|
264
|
+
return `args:${JSON.stringify(args)}`;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return undefined;
|
|
268
|
+
}
|
|
269
|
+
function getAvailableApprovalDecisions(toolName, target) {
|
|
270
|
+
return (toolName === "bash" && target?.startsWith("command-prefix:")) ||
|
|
271
|
+
(googleWorkspaceWriteToolNames.has(toolName) && target)
|
|
272
|
+
? ["allow_once", "allow_session", "allow_always", "redirect"]
|
|
273
|
+
: ["allow_once", "redirect"];
|
|
274
|
+
}
|
|
275
|
+
function extractGoogleDrivePermissionTarget(toolName, record) {
|
|
276
|
+
if (toolName === "google_drive_create_folder" ||
|
|
277
|
+
toolName === "google_drive_create_text_file") {
|
|
278
|
+
return typeof record.parentId === "string" && record.parentId.trim()
|
|
279
|
+
? `google-drive:folder:${record.parentId.trim()}`
|
|
280
|
+
: "google-drive:root";
|
|
281
|
+
}
|
|
282
|
+
if (typeof record.fileId === "string" && record.fileId.trim()) {
|
|
283
|
+
return `google-drive:file:${record.fileId.trim()}`;
|
|
284
|
+
}
|
|
285
|
+
return undefined;
|
|
286
|
+
}
|
|
287
|
+
function extractGoogleDocsPermissionTarget(toolName, record) {
|
|
288
|
+
if (toolName === "google_docs_create") {
|
|
289
|
+
return "google-docs:create";
|
|
290
|
+
}
|
|
291
|
+
if (typeof record.documentId === "string" && record.documentId.trim()) {
|
|
292
|
+
return `google-docs:document:${record.documentId.trim()}`;
|
|
293
|
+
}
|
|
294
|
+
return undefined;
|
|
295
|
+
}
|
|
296
|
+
function extractGoogleSheetsPermissionTarget(toolName, record) {
|
|
297
|
+
if (toolName === "google_sheets_create") {
|
|
298
|
+
return "google-sheets:create";
|
|
299
|
+
}
|
|
300
|
+
if (typeof record.spreadsheetId === "string" && record.spreadsheetId.trim()) {
|
|
301
|
+
return `google-sheets:spreadsheet:${record.spreadsheetId.trim()}`;
|
|
302
|
+
}
|
|
303
|
+
return undefined;
|
|
304
|
+
}
|
|
305
|
+
function extractGoogleSlidesPermissionTarget(toolName, record) {
|
|
306
|
+
if (toolName === "google_slides_create") {
|
|
307
|
+
return "google-slides:create";
|
|
308
|
+
}
|
|
309
|
+
if (typeof record.presentationId === "string" && record.presentationId.trim()) {
|
|
310
|
+
return `google-slides:presentation:${record.presentationId.trim()}`;
|
|
311
|
+
}
|
|
312
|
+
return undefined;
|
|
313
|
+
}
|
|
314
|
+
function deriveCommandPrefix(command) {
|
|
315
|
+
const firstSegment = firstShellCommandSegment(command);
|
|
316
|
+
return splitShellWords(firstSegment);
|
|
317
|
+
}
|
|
318
|
+
function firstShellCommandSegment(command) {
|
|
319
|
+
let quote;
|
|
320
|
+
let escaped = false;
|
|
321
|
+
for (let index = 0; index < command.length; index += 1) {
|
|
322
|
+
const char = command[index];
|
|
323
|
+
if (escaped) {
|
|
324
|
+
escaped = false;
|
|
325
|
+
continue;
|
|
326
|
+
}
|
|
327
|
+
if (char === "\\") {
|
|
328
|
+
escaped = true;
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
if (quote) {
|
|
332
|
+
if (char === quote)
|
|
333
|
+
quote = undefined;
|
|
334
|
+
continue;
|
|
335
|
+
}
|
|
336
|
+
if (char === "'" || char === '"') {
|
|
337
|
+
quote = char;
|
|
338
|
+
continue;
|
|
339
|
+
}
|
|
340
|
+
const next = command[index + 1];
|
|
341
|
+
if (char === ";" || char === "|" || char === "&" || char === "\n") {
|
|
342
|
+
if (char === "&" && next !== "&") {
|
|
343
|
+
continue;
|
|
344
|
+
}
|
|
345
|
+
return command.slice(0, index).trim();
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
return command.trim();
|
|
349
|
+
}
|
|
350
|
+
function splitShellWords(command) {
|
|
351
|
+
const words = [];
|
|
352
|
+
let current = "";
|
|
353
|
+
let quote;
|
|
354
|
+
let escaped = false;
|
|
355
|
+
for (const char of command) {
|
|
356
|
+
if (escaped) {
|
|
357
|
+
current += char;
|
|
358
|
+
escaped = false;
|
|
359
|
+
continue;
|
|
360
|
+
}
|
|
361
|
+
if (char === "\\") {
|
|
362
|
+
escaped = true;
|
|
363
|
+
continue;
|
|
364
|
+
}
|
|
365
|
+
if (quote) {
|
|
366
|
+
if (char === quote) {
|
|
367
|
+
quote = undefined;
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
current += char;
|
|
371
|
+
}
|
|
372
|
+
continue;
|
|
373
|
+
}
|
|
374
|
+
if (char === "'" || char === '"') {
|
|
375
|
+
quote = char;
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
378
|
+
if (/\s/.test(char)) {
|
|
379
|
+
if (current) {
|
|
380
|
+
words.push(current);
|
|
381
|
+
current = "";
|
|
382
|
+
}
|
|
383
|
+
continue;
|
|
384
|
+
}
|
|
385
|
+
current += char;
|
|
386
|
+
}
|
|
387
|
+
if (current) {
|
|
388
|
+
words.push(current);
|
|
389
|
+
}
|
|
390
|
+
return words;
|
|
391
|
+
}
|
|
392
|
+
function inferToolRiskLevel(toolName) {
|
|
393
|
+
return toolName === "bash" ||
|
|
394
|
+
toolName === "write" ||
|
|
395
|
+
toolName === "edit" ||
|
|
396
|
+
toolName === "write_file" ||
|
|
397
|
+
toolName === "edit_file" ||
|
|
398
|
+
toolName === "document_apply_operations"
|
|
399
|
+
? "destructive"
|
|
400
|
+
: "normal";
|
|
401
|
+
}
|
|
402
|
+
function safeErrorMessage(error) {
|
|
403
|
+
return error instanceof Error ? error.message : String(error);
|
|
404
|
+
}
|
|
405
|
+
function summarizeToolResult(tool, result) {
|
|
406
|
+
const parsed = parseJsonRecord(result.content);
|
|
407
|
+
const metadata = compactMetadata(result.metadata);
|
|
408
|
+
if (tool.toolId === "read" || tool.toolId === "read_file") {
|
|
409
|
+
const content = typeof parsed?.content === "string" ? parsed.content : "";
|
|
410
|
+
return {
|
|
411
|
+
summary: `Read ${tool.target ?? readString(parsed, "relativePath") ?? "file"}`,
|
|
412
|
+
metadata: {
|
|
413
|
+
...(metadata ?? {}),
|
|
414
|
+
bytes: Buffer.byteLength(content, "utf8"),
|
|
415
|
+
lines: content.length ? content.split("\n").length : 0,
|
|
416
|
+
},
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
if (tool.toolId === "list" || tool.toolId === "list_files") {
|
|
420
|
+
const files = Array.isArray(parsed?.files) ? parsed.files : [];
|
|
421
|
+
return {
|
|
422
|
+
summary: `Listed ${files.length} item(s)`,
|
|
423
|
+
metadata: {
|
|
424
|
+
...(metadata ?? {}),
|
|
425
|
+
count: files.length,
|
|
426
|
+
...(typeof parsed?.truncated === "boolean"
|
|
427
|
+
? { truncated: parsed.truncated }
|
|
428
|
+
: {}),
|
|
429
|
+
},
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
if (tool.toolId === "grep" || tool.toolId === "ripgrep") {
|
|
433
|
+
const matches = Array.isArray(parsed?.matches) ? parsed.matches : [];
|
|
434
|
+
return {
|
|
435
|
+
summary: `Found ${matches.length} match(es)`,
|
|
436
|
+
metadata: {
|
|
437
|
+
...(metadata ?? {}),
|
|
438
|
+
count: matches.length,
|
|
439
|
+
...(typeof parsed?.truncated === "boolean"
|
|
440
|
+
? { truncated: parsed.truncated }
|
|
441
|
+
: {}),
|
|
442
|
+
},
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
if (tool.toolId === "glob") {
|
|
446
|
+
const files = Array.isArray(parsed?.files) ? parsed.files : [];
|
|
447
|
+
return {
|
|
448
|
+
summary: `Found ${files.length} file(s)`,
|
|
449
|
+
metadata: {
|
|
450
|
+
...(metadata ?? {}),
|
|
451
|
+
count: files.length,
|
|
452
|
+
...(typeof parsed?.truncated === "boolean"
|
|
453
|
+
? { truncated: parsed.truncated }
|
|
454
|
+
: {}),
|
|
455
|
+
},
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
if (tool.toolId === "write" || tool.toolId === "write_file") {
|
|
459
|
+
return {
|
|
460
|
+
summary: `Wrote ${tool.target ?? readString(parsed, "relativePath") ?? "file"}`,
|
|
461
|
+
...(metadata ? { metadata } : {}),
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
if (tool.toolId === "edit" || tool.toolId === "edit_file") {
|
|
465
|
+
return {
|
|
466
|
+
summary: `Edited ${tool.target ?? readString(parsed, "relativePath") ?? "file"}`,
|
|
467
|
+
...(metadata ? { metadata } : {}),
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
if (tool.toolId === "document_inspect") {
|
|
471
|
+
return {
|
|
472
|
+
summary: `Inspected ${readString(parsed, "path") ?? "document"}`,
|
|
473
|
+
...(metadata ? { metadata } : {}),
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
if (tool.toolId === "document_apply_operations") {
|
|
477
|
+
return {
|
|
478
|
+
summary: `Edited ${readString(parsed, "outputPath") ?? tool.target ?? "document"}`,
|
|
479
|
+
...(metadata ? { metadata } : {}),
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
if (tool.toolId === "bash") {
|
|
483
|
+
const exitCode = readNumber(parsed, "exitCode") ?? readNumber(metadata, "exitCode");
|
|
484
|
+
return {
|
|
485
|
+
summary: `Exited ${exitCode ?? 0}`,
|
|
486
|
+
metadata: {
|
|
487
|
+
...(metadata ?? {}),
|
|
488
|
+
...(exitCode !== undefined ? { exitCode } : {}),
|
|
489
|
+
},
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
if (tool.toolId === "update_plan") {
|
|
493
|
+
const plan = Array.isArray(parsed?.plan) ? parsed.plan : [];
|
|
494
|
+
return {
|
|
495
|
+
summary: `Updated ${plan.length} plan item(s)`,
|
|
496
|
+
...(metadata ? { metadata } : {}),
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
if (tool.toolId === "project_app_defaults") {
|
|
500
|
+
return {
|
|
501
|
+
summary: "Updated project app defaults",
|
|
502
|
+
...(metadata ? { metadata } : {}),
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
if (tool.toolId.startsWith("google_")) {
|
|
506
|
+
return summarizeGoogleWorkspaceToolResult(tool, parsed, metadata);
|
|
507
|
+
}
|
|
508
|
+
return {
|
|
509
|
+
...(metadata ? { metadata } : {}),
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
function summarizeGoogleWorkspaceToolResult(tool, parsed, metadata) {
|
|
513
|
+
if (tool.toolId === "google_workspace_status") {
|
|
514
|
+
const capabilities = readStringArray(parsed, "capabilities");
|
|
515
|
+
return {
|
|
516
|
+
summary: capabilities.length
|
|
517
|
+
? `Connected · ${capabilities.map(capitalizeWord).join(", ")}`
|
|
518
|
+
: "Connected",
|
|
519
|
+
...(metadata ? { metadata } : {}),
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
if (tool.toolId === "google_drive_search") {
|
|
523
|
+
const files = readArray(parsed, "files");
|
|
524
|
+
return {
|
|
525
|
+
summary: `Found ${files.length} file(s)`,
|
|
526
|
+
metadata: {
|
|
527
|
+
...(metadata ?? {}),
|
|
528
|
+
count: files.length,
|
|
529
|
+
...(typeof parsed?.nextPageToken === "string"
|
|
530
|
+
? { hasMore: true }
|
|
531
|
+
: {}),
|
|
532
|
+
},
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
if (tool.toolId === "google_drive_export_text" ||
|
|
536
|
+
tool.toolId === "google_drive_get_metadata") {
|
|
537
|
+
const file = readRecord(parsed, "file");
|
|
538
|
+
const name = readString(file, "name") ?? "file";
|
|
539
|
+
return {
|
|
540
|
+
summary: tool.toolId === "google_drive_export_text"
|
|
541
|
+
? `Exported ${name}`
|
|
542
|
+
: `Read metadata for ${name}`,
|
|
543
|
+
...(metadata ? { metadata } : {}),
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
if (tool.toolId.startsWith("google_drive_")) {
|
|
547
|
+
const file = readRecord(parsed, "file");
|
|
548
|
+
const name = readString(file, "name") ?? tool.target ?? "file";
|
|
549
|
+
return {
|
|
550
|
+
summary: `${googleDriveMutationVerb(tool.toolId)} ${name}`,
|
|
551
|
+
...(metadata ? { metadata } : {}),
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
if (tool.toolId === "google_sheets_get_metadata") {
|
|
555
|
+
const sheets = readArray(parsed, "sheets");
|
|
556
|
+
const title = readString(parsed, "title") ?? "spreadsheet";
|
|
557
|
+
return {
|
|
558
|
+
summary: `Read metadata for ${title} · ${sheets.length} sheet(s)`,
|
|
559
|
+
...(metadata ? { metadata } : {}),
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
if (tool.toolId === "google_sheets_read_range") {
|
|
563
|
+
const values = readArray(parsed, "values");
|
|
564
|
+
const range = readString(parsed, "range") ?? "range";
|
|
565
|
+
return {
|
|
566
|
+
summary: `Read ${values.length} row(s) from ${range}`,
|
|
567
|
+
metadata: { ...(metadata ?? {}), rows: values.length },
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
if (tool.toolId === "google_sheets_search_values") {
|
|
571
|
+
const matches = readArray(parsed, "matches");
|
|
572
|
+
return {
|
|
573
|
+
summary: `Found ${matches.length} match(es)`,
|
|
574
|
+
metadata: { ...(metadata ?? {}), count: matches.length },
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
if (tool.toolId === "google_sheets_create") {
|
|
578
|
+
return {
|
|
579
|
+
summary: `Created spreadsheet ${readString(parsed, "title") ?? ""}`.trim(),
|
|
580
|
+
...(metadata ? { metadata } : {}),
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
if (tool.toolId.startsWith("google_sheets_")) {
|
|
584
|
+
const cells = readNumber(parsed, "updatedCells");
|
|
585
|
+
const replies = readArray(parsed, "replies");
|
|
586
|
+
return {
|
|
587
|
+
summary: cells !== undefined
|
|
588
|
+
? `Updated ${cells} cell(s)`
|
|
589
|
+
: replies.length > 0
|
|
590
|
+
? `Applied ${replies.length} sheet update(s)`
|
|
591
|
+
: "Updated spreadsheet",
|
|
592
|
+
...(metadata ? { metadata } : {}),
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
if (tool.toolId.startsWith("google_docs_")) {
|
|
596
|
+
const target = readString(parsed, "title") ?? readString(parsed, "documentId") ?? "document";
|
|
597
|
+
return {
|
|
598
|
+
summary: `${googleDocsVerb(tool.toolId)} ${target}`,
|
|
599
|
+
...(metadata ? { metadata } : {}),
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
if (tool.toolId === "google_slides_get_metadata" ||
|
|
603
|
+
tool.toolId === "google_slides_read_text") {
|
|
604
|
+
const slideCount = readNumber(parsed, "slideCount") ?? readArray(parsed, "slides").length;
|
|
605
|
+
const title = readString(parsed, "title") ?? "presentation";
|
|
606
|
+
return {
|
|
607
|
+
summary: `Read ${title} · ${slideCount} slide(s)`,
|
|
608
|
+
...(metadata ? { metadata } : {}),
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
if (tool.toolId === "google_slides_create") {
|
|
612
|
+
return {
|
|
613
|
+
summary: `Created presentation ${readString(parsed, "title") ?? ""}`.trim(),
|
|
614
|
+
...(metadata ? { metadata } : {}),
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
if (tool.toolId.startsWith("google_slides_")) {
|
|
618
|
+
const replies = readArray(parsed, "replies");
|
|
619
|
+
return {
|
|
620
|
+
summary: `Applied ${replies.length} slide update(s)`,
|
|
621
|
+
...(metadata ? { metadata } : {}),
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
return {
|
|
625
|
+
summary: "Ran Google Workspace tool",
|
|
626
|
+
...(metadata ? { metadata } : {}),
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
function googleDriveMutationVerb(toolId) {
|
|
630
|
+
if (toolId.includes("create"))
|
|
631
|
+
return "Created";
|
|
632
|
+
if (toolId.includes("rename"))
|
|
633
|
+
return "Renamed";
|
|
634
|
+
if (toolId.includes("move"))
|
|
635
|
+
return "Moved";
|
|
636
|
+
if (toolId.includes("trash"))
|
|
637
|
+
return "Trashed";
|
|
638
|
+
return "Updated";
|
|
639
|
+
}
|
|
640
|
+
function googleDocsVerb(toolId) {
|
|
641
|
+
if (toolId === "google_docs_create")
|
|
642
|
+
return "Created document";
|
|
643
|
+
if (toolId === "google_docs_append_text")
|
|
644
|
+
return "Appended to";
|
|
645
|
+
if (toolId === "google_docs_replace_text")
|
|
646
|
+
return "Updated";
|
|
647
|
+
return "Updated";
|
|
648
|
+
}
|
|
649
|
+
function readRecord(record, key) {
|
|
650
|
+
const value = record?.[key];
|
|
651
|
+
return value && typeof value === "object" && !Array.isArray(value)
|
|
652
|
+
? value
|
|
653
|
+
: undefined;
|
|
654
|
+
}
|
|
655
|
+
function readArray(record, key) {
|
|
656
|
+
const value = record?.[key];
|
|
657
|
+
return Array.isArray(value) ? value : [];
|
|
658
|
+
}
|
|
659
|
+
function readStringArray(record, key) {
|
|
660
|
+
return readArray(record, key).filter((value) => typeof value === "string" && Boolean(value));
|
|
661
|
+
}
|
|
662
|
+
function capitalizeWord(value) {
|
|
663
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
664
|
+
}
|
|
665
|
+
function emitTaskProgressIfPresent(input) {
|
|
666
|
+
if (input.toolName !== "update_plan") {
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
const parsed = parseJsonRecord(input.result.content);
|
|
670
|
+
const rawPlan = parsed?.plan;
|
|
671
|
+
if (!Array.isArray(rawPlan)) {
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
const plan = rawPlan.flatMap((item) => {
|
|
675
|
+
if (!item || typeof item !== "object" || Array.isArray(item))
|
|
676
|
+
return [];
|
|
677
|
+
const record = item;
|
|
678
|
+
const step = record.step;
|
|
679
|
+
const status = record.status;
|
|
680
|
+
if (typeof step !== "string" ||
|
|
681
|
+
!step.trim() ||
|
|
682
|
+
!isTaskProgressStatus(status)) {
|
|
683
|
+
return [];
|
|
684
|
+
}
|
|
685
|
+
return [{ step: step.trim(), status }];
|
|
686
|
+
});
|
|
687
|
+
if (plan.length === 0) {
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
const explanation = readString(parsed, "explanation");
|
|
691
|
+
input.emit(createTaskProgressEvent(input.context, {
|
|
692
|
+
toolCallId: input.toolCallId,
|
|
693
|
+
plan,
|
|
694
|
+
...(explanation ? { explanation } : {}),
|
|
695
|
+
}));
|
|
696
|
+
}
|
|
697
|
+
function isTaskProgressStatus(value) {
|
|
698
|
+
return value === "pending" || value === "in_progress" || value === "completed";
|
|
699
|
+
}
|
|
700
|
+
function parseJsonRecord(value) {
|
|
701
|
+
try {
|
|
702
|
+
const parsed = JSON.parse(value);
|
|
703
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed)
|
|
704
|
+
? parsed
|
|
705
|
+
: undefined;
|
|
706
|
+
}
|
|
707
|
+
catch {
|
|
708
|
+
return undefined;
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
function compactMetadata(metadata) {
|
|
712
|
+
if (!metadata)
|
|
713
|
+
return undefined;
|
|
714
|
+
const compacted = {};
|
|
715
|
+
for (const [key, value] of Object.entries(metadata)) {
|
|
716
|
+
if (typeof value === "string" ||
|
|
717
|
+
typeof value === "number" ||
|
|
718
|
+
typeof value === "boolean" ||
|
|
719
|
+
value === null) {
|
|
720
|
+
compacted[key] = value;
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
return Object.keys(compacted).length ? compacted : undefined;
|
|
724
|
+
}
|
|
725
|
+
function readString(record, key) {
|
|
726
|
+
const value = record?.[key];
|
|
727
|
+
return typeof value === "string" && value.trim() ? value.trim() : undefined;
|
|
728
|
+
}
|
|
729
|
+
function readNumber(record, key) {
|
|
730
|
+
const value = record?.[key];
|
|
731
|
+
return typeof value === "number" ? value : undefined;
|
|
732
|
+
}
|
|
733
|
+
//# sourceMappingURL=runtime-tool-execution.js.map
|