yepanywhere 0.1.0
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/bundled/@yep-anywhere/shared/dist/app-types.d.ts +229 -0
- package/bundled/@yep-anywhere/shared/dist/app-types.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/app-types.js +46 -0
- package/bundled/@yep-anywhere/shared/dist/app-types.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/DocumentContentSchema.d.ts +16 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/DocumentContentSchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/DocumentContentSchema.js +17 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/DocumentContentSchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/ImageContentSchema.d.ts +15 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/ImageContentSchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/ImageContentSchema.js +10 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/ImageContentSchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/TextContentSchema.d.ts +6 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/TextContentSchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/TextContentSchema.js +6 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/TextContentSchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/ThinkingContentSchema.d.ts +7 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/ThinkingContentSchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/ThinkingContentSchema.js +7 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/ThinkingContentSchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/ToolResultContentSchema.d.ts +24 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/ToolResultContentSchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/ToolResultContentSchema.js +13 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/ToolResultContentSchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/ToolUseContentSchema.d.ts +8 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/ToolUseContentSchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/ToolUseContentSchema.js +8 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/content/ToolUseContentSchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/AssistantEntrySchema.d.ts +78 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/AssistantEntrySchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/AssistantEntrySchema.js +13 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/AssistantEntrySchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/BaseEntrySchema.d.ts +18 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/BaseEntrySchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/BaseEntrySchema.js +19 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/BaseEntrySchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/FileHistorySnapshotEntrySchema.d.ts +13 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/FileHistorySnapshotEntrySchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/FileHistorySnapshotEntrySchema.js +14 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/FileHistorySnapshotEntrySchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/QueueOperationEntrySchema.d.ts +68 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/QueueOperationEntrySchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/QueueOperationEntrySchema.js +37 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/QueueOperationEntrySchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/SummaryEntrySchema.d.ts +8 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/SummaryEntrySchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/SummaryEntrySchema.js +7 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/SummaryEntrySchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/SystemEntrySchema.d.ts +52 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/SystemEntrySchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/SystemEntrySchema.js +29 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/SystemEntrySchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/UserEntrySchema.d.ts +72 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/UserEntrySchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/UserEntrySchema.js +10 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/UserEntrySchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/normalizeQueueOperationContent.d.ts +14 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/normalizeQueueOperationContent.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/normalizeQueueOperationContent.js +39 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/normalizeQueueOperationContent.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/guards.d.ts +15 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/guards.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/guards.js +26 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/guards.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/index.d.ts +566 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/index.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/index.js +39 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/index.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/message/AssistantMessageSchema.d.ts +93 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/message/AssistantMessageSchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/message/AssistantMessageSchema.js +40 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/message/AssistantMessageSchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/message/UserMessageSchema.d.ts +105 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/message/UserMessageSchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/message/UserMessageSchema.js +20 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/message/UserMessageSchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/CommonToolSchema.d.ts +53 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/CommonToolSchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/CommonToolSchema.js +54 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/CommonToolSchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/StructuredPatchSchema.d.ts +9 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/StructuredPatchSchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/StructuredPatchSchema.js +9 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/StructuredPatchSchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/TodoSchema.d.ts +32 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/TodoSchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/TodoSchema.js +12 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/TodoSchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/ToolResultSchemas.d.ts +288 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/ToolResultSchemas.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/ToolResultSchemas.js +293 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/ToolResultSchemas.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/index.d.ts +83 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/index.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/index.js +10 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/index.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/types.d.ts +42 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/types.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/types.js +11 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/types.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/codex-schema/content.d.ts +99 -0
- package/bundled/@yep-anywhere/shared/dist/codex-schema/content.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/codex-schema/content.js +64 -0
- package/bundled/@yep-anywhere/shared/dist/codex-schema/content.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/codex-schema/index.d.ts +17 -0
- package/bundled/@yep-anywhere/shared/dist/codex-schema/index.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/codex-schema/index.js +17 -0
- package/bundled/@yep-anywhere/shared/dist/codex-schema/index.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/codex-schema/session.d.ts +600 -0
- package/bundled/@yep-anywhere/shared/dist/codex-schema/session.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/codex-schema/session.js +282 -0
- package/bundled/@yep-anywhere/shared/dist/codex-schema/session.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/codex-schema/types.d.ts +7 -0
- package/bundled/@yep-anywhere/shared/dist/codex-schema/types.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/codex-schema/types.js +6 -0
- package/bundled/@yep-anywhere/shared/dist/codex-schema/types.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/dag.d.ts +35 -0
- package/bundled/@yep-anywhere/shared/dist/dag.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/dag.js +75 -0
- package/bundled/@yep-anywhere/shared/dist/dag.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/filePathDetection.d.ts +72 -0
- package/bundled/@yep-anywhere/shared/dist/filePathDetection.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/filePathDetection.js +376 -0
- package/bundled/@yep-anywhere/shared/dist/filePathDetection.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/content.d.ts +95 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/content.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/content.js +57 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/content.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/events.d.ts +174 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/events.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/events.js +117 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/events.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/index.d.ts +18 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/index.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/index.js +18 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/index.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/session.d.ts +267 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/session.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/session.js +147 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/session.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/types.d.ts +7 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/types.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/types.js +6 -0
- package/bundled/@yep-anywhere/shared/dist/gemini-schema/types.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/ideMetadata.d.ts +30 -0
- package/bundled/@yep-anywhere/shared/dist/ideMetadata.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/ideMetadata.js +58 -0
- package/bundled/@yep-anywhere/shared/dist/ideMetadata.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/index.d.ts +24 -0
- package/bundled/@yep-anywhere/shared/dist/index.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/index.js +17 -0
- package/bundled/@yep-anywhere/shared/dist/index.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/opencode-schema/events.d.ts +457 -0
- package/bundled/@yep-anywhere/shared/dist/opencode-schema/events.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/opencode-schema/events.js +217 -0
- package/bundled/@yep-anywhere/shared/dist/opencode-schema/events.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/opencode-schema/index.d.ts +23 -0
- package/bundled/@yep-anywhere/shared/dist/opencode-schema/index.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/opencode-schema/index.js +23 -0
- package/bundled/@yep-anywhere/shared/dist/opencode-schema/index.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/opencode-schema/session.d.ts +149 -0
- package/bundled/@yep-anywhere/shared/dist/opencode-schema/session.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/opencode-schema/session.js +158 -0
- package/bundled/@yep-anywhere/shared/dist/opencode-schema/session.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/opencode-schema/types.d.ts +7 -0
- package/bundled/@yep-anywhere/shared/dist/opencode-schema/types.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/opencode-schema/types.js +6 -0
- package/bundled/@yep-anywhere/shared/dist/opencode-schema/types.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/projectId.d.ts +48 -0
- package/bundled/@yep-anywhere/shared/dist/projectId.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/projectId.js +74 -0
- package/bundled/@yep-anywhere/shared/dist/projectId.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/session/SessionView.d.ts +171 -0
- package/bundled/@yep-anywhere/shared/dist/session/SessionView.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/session/SessionView.js +189 -0
- package/bundled/@yep-anywhere/shared/dist/session/SessionView.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/session/UnifiedSession.d.ts +31 -0
- package/bundled/@yep-anywhere/shared/dist/session/UnifiedSession.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/session/UnifiedSession.js +2 -0
- package/bundled/@yep-anywhere/shared/dist/session/UnifiedSession.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/session/index.d.ts +3 -0
- package/bundled/@yep-anywhere/shared/dist/session/index.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/session/index.js +2 -0
- package/bundled/@yep-anywhere/shared/dist/session/index.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/types.d.ts +172 -0
- package/bundled/@yep-anywhere/shared/dist/types.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/types.js +33 -0
- package/bundled/@yep-anywhere/shared/dist/types.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/upload.d.ts +58 -0
- package/bundled/@yep-anywhere/shared/dist/upload.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/upload.js +6 -0
- package/bundled/@yep-anywhere/shared/dist/upload.js.map +1 -0
- package/bundled/@yep-anywhere/shared/package.json +7 -0
- package/client-dist/assets/index-C7DeAWG4.css +1 -0
- package/client-dist/assets/index-yX0HPwrz.js +147 -0
- package/client-dist/badge-96.png +0 -0
- package/client-dist/badge.svg +20 -0
- package/client-dist/debug-streaming.html +746 -0
- package/client-dist/favicon.ico +0 -0
- package/client-dist/icon-192.png +0 -0
- package/client-dist/icon-512.png +0 -0
- package/client-dist/icon.svg +27 -0
- package/client-dist/index.html +35 -0
- package/client-dist/manifest.json +23 -0
- package/client-dist/sw.js +482 -0
- package/dist/app.d.ts +67 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +236 -0
- package/dist/app.js.map +1 -0
- package/dist/augments/augment-generator.d.ts +30 -0
- package/dist/augments/augment-generator.d.ts.map +1 -0
- package/dist/augments/augment-generator.js +171 -0
- package/dist/augments/augment-generator.js.map +1 -0
- package/dist/augments/block-detector.d.ts +81 -0
- package/dist/augments/block-detector.d.ts.map +1 -0
- package/dist/augments/block-detector.js +615 -0
- package/dist/augments/block-detector.js.map +1 -0
- package/dist/augments/edit-augments.d.ts +138 -0
- package/dist/augments/edit-augments.d.ts.map +1 -0
- package/dist/augments/edit-augments.js +665 -0
- package/dist/augments/edit-augments.js.map +1 -0
- package/dist/augments/index.d.ts +14 -0
- package/dist/augments/index.d.ts.map +1 -0
- package/dist/augments/index.js +20 -0
- package/dist/augments/index.js.map +1 -0
- package/dist/augments/markdown-augments.d.ts +33 -0
- package/dist/augments/markdown-augments.d.ts.map +1 -0
- package/dist/augments/markdown-augments.js +128 -0
- package/dist/augments/markdown-augments.js.map +1 -0
- package/dist/augments/read-augments.d.ts +40 -0
- package/dist/augments/read-augments.d.ts.map +1 -0
- package/dist/augments/read-augments.js +64 -0
- package/dist/augments/read-augments.js.map +1 -0
- package/dist/augments/stream-coordinator.d.ts +32 -0
- package/dist/augments/stream-coordinator.d.ts.map +1 -0
- package/dist/augments/stream-coordinator.js +115 -0
- package/dist/augments/stream-coordinator.js.map +1 -0
- package/dist/augments/write-augments.d.ts +32 -0
- package/dist/augments/write-augments.d.ts.map +1 -0
- package/dist/augments/write-augments.js +27 -0
- package/dist/augments/write-augments.js.map +1 -0
- package/dist/auth/AuthService.d.ts +98 -0
- package/dist/auth/AuthService.d.ts.map +1 -0
- package/dist/auth/AuthService.js +217 -0
- package/dist/auth/AuthService.js.map +1 -0
- package/dist/auth/index.d.ts +3 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +3 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/routes.d.ts +13 -0
- package/dist/auth/routes.d.ts.map +1 -0
- package/dist/auth/routes.js +149 -0
- package/dist/auth/routes.js.map +1 -0
- package/dist/cli.d.ts +19 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +152 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +76 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +124 -0
- package/dist/config.js.map +1 -0
- package/dist/dev-mock.d.ts +18 -0
- package/dist/dev-mock.d.ts.map +1 -0
- package/dist/dev-mock.js +260 -0
- package/dist/dev-mock.js.map +1 -0
- package/dist/frontend/index.d.ts +10 -0
- package/dist/frontend/index.d.ts.map +1 -0
- package/dist/frontend/index.js +10 -0
- package/dist/frontend/index.js.map +1 -0
- package/dist/frontend/proxy.d.ts +70 -0
- package/dist/frontend/proxy.d.ts.map +1 -0
- package/dist/frontend/proxy.js +329 -0
- package/dist/frontend/proxy.js.map +1 -0
- package/dist/frontend/static.d.ts +16 -0
- package/dist/frontend/static.d.ts.map +1 -0
- package/dist/frontend/static.js +106 -0
- package/dist/frontend/static.js.map +1 -0
- package/dist/highlighting/index.d.ts +43 -0
- package/dist/highlighting/index.d.ts.map +1 -0
- package/dist/highlighting/index.js +224 -0
- package/dist/highlighting/index.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +259 -0
- package/dist/index.js.map +1 -0
- package/dist/indexes/SessionIndexService.d.ts +106 -0
- package/dist/indexes/SessionIndexService.d.ts.map +1 -0
- package/dist/indexes/SessionIndexService.js +356 -0
- package/dist/indexes/SessionIndexService.js.map +1 -0
- package/dist/indexes/index.d.ts +3 -0
- package/dist/indexes/index.d.ts.map +1 -0
- package/dist/indexes/index.js +2 -0
- package/dist/indexes/index.js.map +1 -0
- package/dist/indexes/types.d.ts +55 -0
- package/dist/indexes/types.d.ts.map +1 -0
- package/dist/indexes/types.js +8 -0
- package/dist/indexes/types.js.map +1 -0
- package/dist/logging/index.d.ts +2 -0
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/logging/index.js +2 -0
- package/dist/logging/index.js.map +1 -0
- package/dist/logging/logger.d.ts +81 -0
- package/dist/logging/logger.d.ts.map +1 -0
- package/dist/logging/logger.js +257 -0
- package/dist/logging/logger.js.map +1 -0
- package/dist/maintenance/debug-routes.d.ts +39 -0
- package/dist/maintenance/debug-routes.d.ts.map +1 -0
- package/dist/maintenance/debug-routes.js +561 -0
- package/dist/maintenance/debug-routes.js.map +1 -0
- package/dist/maintenance/index.d.ts +3 -0
- package/dist/maintenance/index.d.ts.map +1 -0
- package/dist/maintenance/index.js +3 -0
- package/dist/maintenance/index.js.map +1 -0
- package/dist/maintenance/server.d.ts +53 -0
- package/dist/maintenance/server.d.ts.map +1 -0
- package/dist/maintenance/server.js +419 -0
- package/dist/maintenance/server.js.map +1 -0
- package/dist/metadata/SessionMetadataService.d.ts +96 -0
- package/dist/metadata/SessionMetadataService.d.ts.map +1 -0
- package/dist/metadata/SessionMetadataService.js +209 -0
- package/dist/metadata/SessionMetadataService.js.map +1 -0
- package/dist/metadata/index.d.ts +2 -0
- package/dist/metadata/index.d.ts.map +1 -0
- package/dist/metadata/index.js +2 -0
- package/dist/metadata/index.js.map +1 -0
- package/dist/middleware/auth.d.ts +18 -0
- package/dist/middleware/auth.d.ts.map +1 -0
- package/dist/middleware/auth.js +53 -0
- package/dist/middleware/auth.js.map +1 -0
- package/dist/middleware/security.d.ts +4 -0
- package/dist/middleware/security.d.ts.map +1 -0
- package/dist/middleware/security.js +28 -0
- package/dist/middleware/security.js.map +1 -0
- package/dist/notifications/NotificationService.d.ts +76 -0
- package/dist/notifications/NotificationService.d.ts.map +1 -0
- package/dist/notifications/NotificationService.js +155 -0
- package/dist/notifications/NotificationService.js.map +1 -0
- package/dist/notifications/index.d.ts +2 -0
- package/dist/notifications/index.d.ts.map +1 -0
- package/dist/notifications/index.js +2 -0
- package/dist/notifications/index.js.map +1 -0
- package/dist/projects/codex-scanner.d.ts +52 -0
- package/dist/projects/codex-scanner.d.ts.map +1 -0
- package/dist/projects/codex-scanner.js +167 -0
- package/dist/projects/codex-scanner.js.map +1 -0
- package/dist/projects/gemini-project-map.d.ts +54 -0
- package/dist/projects/gemini-project-map.d.ts.map +1 -0
- package/dist/projects/gemini-project-map.js +116 -0
- package/dist/projects/gemini-project-map.js.map +1 -0
- package/dist/projects/gemini-scanner.d.ts +58 -0
- package/dist/projects/gemini-scanner.d.ts.map +1 -0
- package/dist/projects/gemini-scanner.js +210 -0
- package/dist/projects/gemini-scanner.js.map +1 -0
- package/dist/projects/index.d.ts +16 -0
- package/dist/projects/index.d.ts.map +1 -0
- package/dist/projects/index.js +17 -0
- package/dist/projects/index.js.map +1 -0
- package/dist/projects/paths.d.ts +127 -0
- package/dist/projects/paths.d.ts.map +1 -0
- package/dist/projects/paths.js +185 -0
- package/dist/projects/paths.js.map +1 -0
- package/dist/projects/scanner.d.ts +45 -0
- package/dist/projects/scanner.d.ts.map +1 -0
- package/dist/projects/scanner.js +287 -0
- package/dist/projects/scanner.js.map +1 -0
- package/dist/push/PushNotifier.d.ts +48 -0
- package/dist/push/PushNotifier.d.ts.map +1 -0
- package/dist/push/PushNotifier.js +145 -0
- package/dist/push/PushNotifier.js.map +1 -0
- package/dist/push/PushService.d.ts +95 -0
- package/dist/push/PushService.d.ts.map +1 -0
- package/dist/push/PushService.js +245 -0
- package/dist/push/PushService.js.map +1 -0
- package/dist/push/index.d.ts +9 -0
- package/dist/push/index.d.ts.map +1 -0
- package/dist/push/index.js +8 -0
- package/dist/push/index.js.map +1 -0
- package/dist/push/routes.d.ts +10 -0
- package/dist/push/routes.d.ts.map +1 -0
- package/dist/push/routes.js +111 -0
- package/dist/push/routes.js.map +1 -0
- package/dist/push/types.d.ts +80 -0
- package/dist/push/types.d.ts.map +1 -0
- package/dist/push/types.js +5 -0
- package/dist/push/types.js.map +1 -0
- package/dist/push/vapid.d.ts +42 -0
- package/dist/push/vapid.d.ts.map +1 -0
- package/dist/push/vapid.js +132 -0
- package/dist/push/vapid.js.map +1 -0
- package/dist/recents/RecentsService.d.ts +77 -0
- package/dist/recents/RecentsService.d.ts.map +1 -0
- package/dist/recents/RecentsService.js +155 -0
- package/dist/recents/RecentsService.js.map +1 -0
- package/dist/recents/index.d.ts +2 -0
- package/dist/recents/index.d.ts.map +1 -0
- package/dist/recents/index.js +2 -0
- package/dist/recents/index.js.map +1 -0
- package/dist/routes/activity.d.ts +7 -0
- package/dist/routes/activity.d.ts.map +1 -0
- package/dist/routes/activity.js +80 -0
- package/dist/routes/activity.js.map +1 -0
- package/dist/routes/beads.d.ts +42 -0
- package/dist/routes/beads.d.ts.map +1 -0
- package/dist/routes/beads.js +101 -0
- package/dist/routes/beads.js.map +1 -0
- package/dist/routes/debug-streaming.d.ts +7 -0
- package/dist/routes/debug-streaming.d.ts.map +1 -0
- package/dist/routes/debug-streaming.js +88 -0
- package/dist/routes/debug-streaming.js.map +1 -0
- package/dist/routes/dev.d.ts +11 -0
- package/dist/routes/dev.d.ts.map +1 -0
- package/dist/routes/dev.js +55 -0
- package/dist/routes/dev.js.map +1 -0
- package/dist/routes/files.d.ts +7 -0
- package/dist/routes/files.d.ts.map +1 -0
- package/dist/routes/files.js +429 -0
- package/dist/routes/files.js.map +1 -0
- package/dist/routes/global-sessions.d.ts +76 -0
- package/dist/routes/global-sessions.d.ts.map +1 -0
- package/dist/routes/global-sessions.js +207 -0
- package/dist/routes/global-sessions.js.map +1 -0
- package/dist/routes/health.d.ts +3 -0
- package/dist/routes/health.d.ts.map +1 -0
- package/dist/routes/health.js +6 -0
- package/dist/routes/health.js.map +1 -0
- package/dist/routes/inbox.d.ts +45 -0
- package/dist/routes/inbox.d.ts.map +1 -0
- package/dist/routes/inbox.js +174 -0
- package/dist/routes/inbox.js.map +1 -0
- package/dist/routes/processes.d.ts +16 -0
- package/dist/routes/processes.d.ts.map +1 -0
- package/dist/routes/processes.js +82 -0
- package/dist/routes/processes.js.map +1 -0
- package/dist/routes/projects.d.ts +30 -0
- package/dist/routes/projects.d.ts.map +1 -0
- package/dist/routes/projects.js +316 -0
- package/dist/routes/projects.js.map +1 -0
- package/dist/routes/providers.d.ts +9 -0
- package/dist/routes/providers.d.ts.map +1 -0
- package/dist/routes/providers.js +63 -0
- package/dist/routes/providers.js.map +1 -0
- package/dist/routes/recents.d.ts +14 -0
- package/dist/routes/recents.d.ts.map +1 -0
- package/dist/routes/recents.js +82 -0
- package/dist/routes/recents.js.map +1 -0
- package/dist/routes/sessions.d.ts +26 -0
- package/dist/routes/sessions.d.ts.map +1 -0
- package/dist/routes/sessions.js +962 -0
- package/dist/routes/sessions.js.map +1 -0
- package/dist/routes/stream.d.ts +7 -0
- package/dist/routes/stream.d.ts.map +1 -0
- package/dist/routes/stream.js +561 -0
- package/dist/routes/stream.js.map +1 -0
- package/dist/routes/upload.d.ts +14 -0
- package/dist/routes/upload.d.ts.map +1 -0
- package/dist/routes/upload.js +278 -0
- package/dist/routes/upload.js.map +1 -0
- package/dist/sdk/cli-detection.d.ts +47 -0
- package/dist/sdk/cli-detection.d.ts.map +1 -0
- package/dist/sdk/cli-detection.js +122 -0
- package/dist/sdk/cli-detection.js.map +1 -0
- package/dist/sdk/messageLogger.d.ts +15 -0
- package/dist/sdk/messageLogger.d.ts.map +1 -0
- package/dist/sdk/messageLogger.js +68 -0
- package/dist/sdk/messageLogger.js.map +1 -0
- package/dist/sdk/messageQueue.d.ts +49 -0
- package/dist/sdk/messageQueue.d.ts.map +1 -0
- package/dist/sdk/messageQueue.js +186 -0
- package/dist/sdk/messageQueue.js.map +1 -0
- package/dist/sdk/mock.d.ts +16 -0
- package/dist/sdk/mock.d.ts.map +1 -0
- package/dist/sdk/mock.js +81 -0
- package/dist/sdk/mock.js.map +1 -0
- package/dist/sdk/providers/__mocks__/base.d.ts +78 -0
- package/dist/sdk/providers/__mocks__/base.d.ts.map +1 -0
- package/dist/sdk/providers/__mocks__/base.js +185 -0
- package/dist/sdk/providers/__mocks__/base.js.map +1 -0
- package/dist/sdk/providers/__mocks__/claude.d.ts +33 -0
- package/dist/sdk/providers/__mocks__/claude.d.ts.map +1 -0
- package/dist/sdk/providers/__mocks__/claude.js +146 -0
- package/dist/sdk/providers/__mocks__/claude.js.map +1 -0
- package/dist/sdk/providers/__mocks__/codex.d.ts +45 -0
- package/dist/sdk/providers/__mocks__/codex.d.ts.map +1 -0
- package/dist/sdk/providers/__mocks__/codex.js +160 -0
- package/dist/sdk/providers/__mocks__/codex.js.map +1 -0
- package/dist/sdk/providers/__mocks__/factory.d.ts +40 -0
- package/dist/sdk/providers/__mocks__/factory.d.ts.map +1 -0
- package/dist/sdk/providers/__mocks__/factory.js +183 -0
- package/dist/sdk/providers/__mocks__/factory.js.map +1 -0
- package/dist/sdk/providers/__mocks__/gemini.d.ts +43 -0
- package/dist/sdk/providers/__mocks__/gemini.d.ts.map +1 -0
- package/dist/sdk/providers/__mocks__/gemini.js +198 -0
- package/dist/sdk/providers/__mocks__/gemini.js.map +1 -0
- package/dist/sdk/providers/__mocks__/index.d.ts +23 -0
- package/dist/sdk/providers/__mocks__/index.d.ts.map +1 -0
- package/dist/sdk/providers/__mocks__/index.js +25 -0
- package/dist/sdk/providers/__mocks__/index.js.map +1 -0
- package/dist/sdk/providers/__mocks__/opencode.d.ts +33 -0
- package/dist/sdk/providers/__mocks__/opencode.d.ts.map +1 -0
- package/dist/sdk/providers/__mocks__/opencode.js +136 -0
- package/dist/sdk/providers/__mocks__/opencode.js.map +1 -0
- package/dist/sdk/providers/__mocks__/types.d.ts +50 -0
- package/dist/sdk/providers/__mocks__/types.d.ts.map +1 -0
- package/dist/sdk/providers/__mocks__/types.js +8 -0
- package/dist/sdk/providers/__mocks__/types.js.map +1 -0
- package/dist/sdk/providers/claude.d.ts +63 -0
- package/dist/sdk/providers/claude.d.ts.map +1 -0
- package/dist/sdk/providers/claude.js +252 -0
- package/dist/sdk/providers/claude.js.map +1 -0
- package/dist/sdk/providers/codex-oss.d.ts +108 -0
- package/dist/sdk/providers/codex-oss.d.ts.map +1 -0
- package/dist/sdk/providers/codex-oss.js +744 -0
- package/dist/sdk/providers/codex-oss.js.map +1 -0
- package/dist/sdk/providers/codex.d.ts +82 -0
- package/dist/sdk/providers/codex.d.ts.map +1 -0
- package/dist/sdk/providers/codex.js +597 -0
- package/dist/sdk/providers/codex.js.map +1 -0
- package/dist/sdk/providers/gemini.d.ts +78 -0
- package/dist/sdk/providers/gemini.d.ts.map +1 -0
- package/dist/sdk/providers/gemini.js +536 -0
- package/dist/sdk/providers/gemini.js.map +1 -0
- package/dist/sdk/providers/index.d.ts +22 -0
- package/dist/sdk/providers/index.d.ts.map +1 -0
- package/dist/sdk/providers/index.js +53 -0
- package/dist/sdk/providers/index.js.map +1 -0
- package/dist/sdk/providers/opencode.d.ts +95 -0
- package/dist/sdk/providers/opencode.d.ts.map +1 -0
- package/dist/sdk/providers/opencode.js +586 -0
- package/dist/sdk/providers/opencode.js.map +1 -0
- package/dist/sdk/providers/types.d.ts +99 -0
- package/dist/sdk/providers/types.d.ts.map +1 -0
- package/dist/sdk/providers/types.js +2 -0
- package/dist/sdk/providers/types.js.map +1 -0
- package/dist/sdk/real.d.ts +20 -0
- package/dist/sdk/real.d.ts.map +1 -0
- package/dist/sdk/real.js +22 -0
- package/dist/sdk/real.js.map +1 -0
- package/dist/sdk/types.d.ts +113 -0
- package/dist/sdk/types.d.ts.map +1 -0
- package/dist/sdk/types.js +3 -0
- package/dist/sdk/types.js.map +1 -0
- package/dist/sessions/Session.d.ts +80 -0
- package/dist/sessions/Session.d.ts.map +1 -0
- package/dist/sessions/Session.js +119 -0
- package/dist/sessions/Session.js.map +1 -0
- package/dist/sessions/codex-reader.d.ts +166 -0
- package/dist/sessions/codex-reader.d.ts.map +1 -0
- package/dist/sessions/codex-reader.js +664 -0
- package/dist/sessions/codex-reader.js.map +1 -0
- package/dist/sessions/dag.d.ts +62 -0
- package/dist/sessions/dag.d.ts.map +1 -0
- package/dist/sessions/dag.js +175 -0
- package/dist/sessions/dag.js.map +1 -0
- package/dist/sessions/fork.d.ts +34 -0
- package/dist/sessions/fork.d.ts.map +1 -0
- package/dist/sessions/fork.js +58 -0
- package/dist/sessions/fork.js.map +1 -0
- package/dist/sessions/gemini-reader.d.ts +103 -0
- package/dist/sessions/gemini-reader.d.ts.map +1 -0
- package/dist/sessions/gemini-reader.js +332 -0
- package/dist/sessions/gemini-reader.js.map +1 -0
- package/dist/sessions/normalization.d.ts +7 -0
- package/dist/sessions/normalization.d.ts.map +1 -0
- package/dist/sessions/normalization.js +429 -0
- package/dist/sessions/normalization.js.map +1 -0
- package/dist/sessions/opencode-reader.d.ts +99 -0
- package/dist/sessions/opencode-reader.d.ts.map +1 -0
- package/dist/sessions/opencode-reader.js +370 -0
- package/dist/sessions/opencode-reader.js.map +1 -0
- package/dist/sessions/reader.d.ts +118 -0
- package/dist/sessions/reader.d.ts.map +1 -0
- package/dist/sessions/reader.js +444 -0
- package/dist/sessions/reader.js.map +1 -0
- package/dist/sessions/types.d.ts +77 -0
- package/dist/sessions/types.d.ts.map +1 -0
- package/dist/sessions/types.js +8 -0
- package/dist/sessions/types.js.map +1 -0
- package/dist/supervisor/ExternalSessionTracker.d.ts +94 -0
- package/dist/supervisor/ExternalSessionTracker.d.ts.map +1 -0
- package/dist/supervisor/ExternalSessionTracker.js +507 -0
- package/dist/supervisor/ExternalSessionTracker.js.map +1 -0
- package/dist/supervisor/Process.d.ts +230 -0
- package/dist/supervisor/Process.d.ts.map +1 -0
- package/dist/supervisor/Process.js +878 -0
- package/dist/supervisor/Process.js.map +1 -0
- package/dist/supervisor/Supervisor.d.ts +191 -0
- package/dist/supervisor/Supervisor.d.ts.map +1 -0
- package/dist/supervisor/Supervisor.js +933 -0
- package/dist/supervisor/Supervisor.js.map +1 -0
- package/dist/supervisor/WorkerQueue.d.ts +113 -0
- package/dist/supervisor/WorkerQueue.d.ts.map +1 -0
- package/dist/supervisor/WorkerQueue.js +148 -0
- package/dist/supervisor/WorkerQueue.js.map +1 -0
- package/dist/supervisor/types.d.ts +176 -0
- package/dist/supervisor/types.d.ts.map +1 -0
- package/dist/supervisor/types.js +7 -0
- package/dist/supervisor/types.js.map +1 -0
- package/dist/testing/mockProjectData.d.ts +5 -0
- package/dist/testing/mockProjectData.d.ts.map +1 -0
- package/dist/testing/mockProjectData.js +27 -0
- package/dist/testing/mockProjectData.js.map +1 -0
- package/dist/uploads/index.d.ts +3 -0
- package/dist/uploads/index.d.ts.map +1 -0
- package/dist/uploads/index.js +2 -0
- package/dist/uploads/index.js.map +1 -0
- package/dist/uploads/manager.d.ts +84 -0
- package/dist/uploads/manager.d.ts.map +1 -0
- package/dist/uploads/manager.js +215 -0
- package/dist/uploads/manager.js.map +1 -0
- package/dist/utils/fileLock.d.ts +57 -0
- package/dist/utils/fileLock.d.ts.map +1 -0
- package/dist/utils/fileLock.js +91 -0
- package/dist/utils/fileLock.js.map +1 -0
- package/dist/watcher/BatchProcessor.d.ts +58 -0
- package/dist/watcher/BatchProcessor.d.ts.map +1 -0
- package/dist/watcher/BatchProcessor.js +105 -0
- package/dist/watcher/BatchProcessor.js.map +1 -0
- package/dist/watcher/EventBus.d.ts +157 -0
- package/dist/watcher/EventBus.d.ts.map +1 -0
- package/dist/watcher/EventBus.js +36 -0
- package/dist/watcher/EventBus.js.map +1 -0
- package/dist/watcher/FileWatcher.d.ts +42 -0
- package/dist/watcher/FileWatcher.d.ts.map +1 -0
- package/dist/watcher/FileWatcher.js +165 -0
- package/dist/watcher/FileWatcher.js.map +1 -0
- package/dist/watcher/SourceWatcher.d.ts +36 -0
- package/dist/watcher/SourceWatcher.d.ts.map +1 -0
- package/dist/watcher/SourceWatcher.js +97 -0
- package/dist/watcher/SourceWatcher.js.map +1 -0
- package/dist/watcher/index.d.ts +9 -0
- package/dist/watcher/index.d.ts.map +1 -0
- package/dist/watcher/index.js +5 -0
- package/dist/watcher/index.js.map +1 -0
- package/package.json +54 -0
- package/scripts/postinstall.js +48 -0
|
@@ -0,0 +1,878 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { getLogger } from "../logging/logger.js";
|
|
4
|
+
import { DEFAULT_IDLE_TIMEOUT_MS } from "./types.js";
|
|
5
|
+
/**
|
|
6
|
+
* IMPORTANT: Never filter out messages by type before emitting to SSE!
|
|
7
|
+
*
|
|
8
|
+
* Tool results are user-type messages containing tool_result content blocks.
|
|
9
|
+
* If you filter out user messages, tool calls will appear stuck in "pending"
|
|
10
|
+
* state until the page is refreshed (when JSONL is fetched from disk).
|
|
11
|
+
*
|
|
12
|
+
* The client-side mergeMessages handles deduplication by UUID, so duplicate
|
|
13
|
+
* emissions are safe and expected (queueMessage emits user messages, and
|
|
14
|
+
* the iterator also yields them).
|
|
15
|
+
*
|
|
16
|
+
* @returns true - always emit the message
|
|
17
|
+
*/
|
|
18
|
+
export function shouldEmitMessage(_message) {
|
|
19
|
+
// Always emit. DO NOT add filtering here!
|
|
20
|
+
// See docstring above for why this is critical.
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
export class Process {
|
|
24
|
+
sdkIterator;
|
|
25
|
+
id;
|
|
26
|
+
_sessionId;
|
|
27
|
+
projectPath;
|
|
28
|
+
projectId;
|
|
29
|
+
startedAt;
|
|
30
|
+
provider;
|
|
31
|
+
model;
|
|
32
|
+
legacyQueue = [];
|
|
33
|
+
messageQueue;
|
|
34
|
+
abortFn;
|
|
35
|
+
_state = { type: "running" };
|
|
36
|
+
listeners = new Set();
|
|
37
|
+
idleTimer = null;
|
|
38
|
+
idleTimeoutMs;
|
|
39
|
+
iteratorDone = false;
|
|
40
|
+
/** Set synchronously when transport/spawn fails to prevent race with queueMessage */
|
|
41
|
+
transportFailed = false;
|
|
42
|
+
/** In-memory message history for mock SDK (real SDK persists to disk) */
|
|
43
|
+
messageHistory = [];
|
|
44
|
+
/** Accumulated streaming text for catch-up when clients connect mid-stream */
|
|
45
|
+
_streamingText = "";
|
|
46
|
+
/** Message ID for current streaming response */
|
|
47
|
+
_streamingMessageId = null;
|
|
48
|
+
/** Pending tool approval requests (from canUseTool callback) - supports concurrent approvals */
|
|
49
|
+
pendingToolApprovals = new Map();
|
|
50
|
+
/** Order of pending approval request IDs for FIFO processing */
|
|
51
|
+
pendingToolApprovalQueue = [];
|
|
52
|
+
/** Current permission mode for tool approvals */
|
|
53
|
+
_permissionMode = "default";
|
|
54
|
+
/** Version counter for permission mode changes (for multi-tab sync) */
|
|
55
|
+
_modeVersion = 0;
|
|
56
|
+
/** Max thinking tokens this process was created with (undefined = thinking disabled) */
|
|
57
|
+
_maxThinkingTokens;
|
|
58
|
+
/** Resolvers waiting for the real session ID */
|
|
59
|
+
sessionIdResolvers = [];
|
|
60
|
+
sessionIdResolved = false;
|
|
61
|
+
/** Whether the process is held (soft pause) */
|
|
62
|
+
_isHeld = false;
|
|
63
|
+
/** When hold mode was activated */
|
|
64
|
+
_holdSince = null;
|
|
65
|
+
/** Resolver to wake up the iterator loop when resumed */
|
|
66
|
+
_holdResolve = null;
|
|
67
|
+
constructor(sdkIterator, options) {
|
|
68
|
+
this.sdkIterator = sdkIterator;
|
|
69
|
+
this.id = randomUUID();
|
|
70
|
+
this._sessionId = options.sessionId;
|
|
71
|
+
this.projectPath = options.projectPath;
|
|
72
|
+
this.projectId = options.projectId;
|
|
73
|
+
this.startedAt = new Date();
|
|
74
|
+
this.idleTimeoutMs = options.idleTimeoutMs ?? DEFAULT_IDLE_TIMEOUT_MS;
|
|
75
|
+
// Real SDK provides these, mock SDK doesn't
|
|
76
|
+
this.messageQueue = options.queue ?? null;
|
|
77
|
+
this.abortFn = options.abortFn ?? null;
|
|
78
|
+
this._permissionMode = options.permissionMode ?? "default";
|
|
79
|
+
this.provider = options.provider;
|
|
80
|
+
this.model = options.model;
|
|
81
|
+
this._maxThinkingTokens = options.maxThinkingTokens;
|
|
82
|
+
// Start processing messages from the SDK
|
|
83
|
+
this.processMessages();
|
|
84
|
+
}
|
|
85
|
+
get sessionId() {
|
|
86
|
+
return this._sessionId;
|
|
87
|
+
}
|
|
88
|
+
get state() {
|
|
89
|
+
return this._state;
|
|
90
|
+
}
|
|
91
|
+
get queueDepth() {
|
|
92
|
+
if (this.messageQueue) {
|
|
93
|
+
return this.messageQueue.depth;
|
|
94
|
+
}
|
|
95
|
+
return this.legacyQueue.length;
|
|
96
|
+
}
|
|
97
|
+
get permissionMode() {
|
|
98
|
+
return this._permissionMode;
|
|
99
|
+
}
|
|
100
|
+
get modeVersion() {
|
|
101
|
+
return this._modeVersion;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Max thinking tokens this process was created with.
|
|
105
|
+
* undefined means thinking is disabled.
|
|
106
|
+
*/
|
|
107
|
+
get maxThinkingTokens() {
|
|
108
|
+
return this._maxThinkingTokens;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Whether the process has been terminated (either manually or due to error).
|
|
112
|
+
* A terminated process cannot accept new messages.
|
|
113
|
+
*/
|
|
114
|
+
get isTerminated() {
|
|
115
|
+
return this._state.type === "terminated";
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Get the termination reason if the process was terminated.
|
|
119
|
+
*/
|
|
120
|
+
get terminationReason() {
|
|
121
|
+
if (this._state.type === "terminated") {
|
|
122
|
+
return this._state.reason;
|
|
123
|
+
}
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Whether the process is currently held (soft pause).
|
|
128
|
+
*/
|
|
129
|
+
get isHeld() {
|
|
130
|
+
return this._isHeld;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* When the hold started, if currently held.
|
|
134
|
+
*/
|
|
135
|
+
get holdSince() {
|
|
136
|
+
return this._holdSince;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Set hold mode (soft pause) for this process.
|
|
140
|
+
* When held, the iterator loop will pause before calling next().
|
|
141
|
+
* When resumed, it continues from where it left off.
|
|
142
|
+
*/
|
|
143
|
+
setHold(enabled) {
|
|
144
|
+
if (enabled === this._isHeld) {
|
|
145
|
+
return; // No change
|
|
146
|
+
}
|
|
147
|
+
const log = getLogger();
|
|
148
|
+
this._isHeld = enabled;
|
|
149
|
+
if (enabled) {
|
|
150
|
+
// Entering hold mode
|
|
151
|
+
this._holdSince = new Date();
|
|
152
|
+
this.clearIdleTimer(); // Don't auto-complete while held
|
|
153
|
+
this.setState({ type: "hold", since: this._holdSince });
|
|
154
|
+
log.info({
|
|
155
|
+
event: "process_hold_enabled",
|
|
156
|
+
sessionId: this._sessionId,
|
|
157
|
+
processId: this.id,
|
|
158
|
+
projectId: this.projectId,
|
|
159
|
+
}, `Process held: ${this._sessionId}`);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
// Resuming from hold
|
|
163
|
+
log.info({
|
|
164
|
+
event: "process_hold_disabled",
|
|
165
|
+
sessionId: this._sessionId,
|
|
166
|
+
processId: this.id,
|
|
167
|
+
projectId: this.projectId,
|
|
168
|
+
holdDurationMs: this._holdSince
|
|
169
|
+
? Date.now() - this._holdSince.getTime()
|
|
170
|
+
: 0,
|
|
171
|
+
}, `Process resumed: ${this._sessionId}`);
|
|
172
|
+
this._holdSince = null;
|
|
173
|
+
// Wake up the iterator loop
|
|
174
|
+
if (this._holdResolve) {
|
|
175
|
+
this._holdResolve();
|
|
176
|
+
this._holdResolve = null;
|
|
177
|
+
}
|
|
178
|
+
// Transition back to running (or idle if iterator is done)
|
|
179
|
+
if (this.iteratorDone) {
|
|
180
|
+
this.transitionToIdle();
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
this.setState({ type: "running" });
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Wait until hold mode is disabled.
|
|
189
|
+
* Called by processMessages() when held.
|
|
190
|
+
*/
|
|
191
|
+
waitUntilResumed() {
|
|
192
|
+
return new Promise((resolve) => {
|
|
193
|
+
this._holdResolve = resolve;
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Update the permission mode for this process.
|
|
198
|
+
* Increments modeVersion and emits a mode-change event for multi-tab sync.
|
|
199
|
+
*/
|
|
200
|
+
setPermissionMode(mode) {
|
|
201
|
+
this._permissionMode = mode;
|
|
202
|
+
this._modeVersion++;
|
|
203
|
+
this.emit({ type: "mode-change", mode, version: this._modeVersion });
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Mark the process as terminated due to an error or external termination.
|
|
207
|
+
* Emits a terminated event and cleans up resources.
|
|
208
|
+
*/
|
|
209
|
+
markTerminated(reason, error) {
|
|
210
|
+
if (this._state.type === "terminated") {
|
|
211
|
+
return; // Already terminated
|
|
212
|
+
}
|
|
213
|
+
const log = getLogger();
|
|
214
|
+
const durationMs = Date.now() - this.startedAt.getTime();
|
|
215
|
+
const pendingApprovalCount = this.pendingToolApprovals.size;
|
|
216
|
+
log.warn({
|
|
217
|
+
event: "process_terminated",
|
|
218
|
+
sessionId: this._sessionId,
|
|
219
|
+
processId: this.id,
|
|
220
|
+
projectId: this.projectId,
|
|
221
|
+
reason,
|
|
222
|
+
errorMessage: error?.message,
|
|
223
|
+
errorStack: error?.stack,
|
|
224
|
+
durationMs,
|
|
225
|
+
pendingApprovalCount,
|
|
226
|
+
previousState: this._state.type,
|
|
227
|
+
}, `Process terminated: ${this._sessionId} - ${reason}`);
|
|
228
|
+
this.clearIdleTimer();
|
|
229
|
+
this.iteratorDone = true;
|
|
230
|
+
// Wake up hold wait if held (so processMessages loop can exit)
|
|
231
|
+
if (this._holdResolve) {
|
|
232
|
+
this._holdResolve();
|
|
233
|
+
this._holdResolve = null;
|
|
234
|
+
}
|
|
235
|
+
this._isHeld = false;
|
|
236
|
+
// Resolve all pending tool approvals with denial
|
|
237
|
+
for (const pending of this.pendingToolApprovals.values()) {
|
|
238
|
+
pending.resolve({
|
|
239
|
+
behavior: "deny",
|
|
240
|
+
message: `Process terminated: ${reason}`,
|
|
241
|
+
interrupt: true,
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
this.pendingToolApprovals.clear();
|
|
245
|
+
this.pendingToolApprovalQueue = [];
|
|
246
|
+
this.setState({ type: "terminated", reason, error });
|
|
247
|
+
this.emit({ type: "terminated", reason, error });
|
|
248
|
+
this.emit({ type: "complete" });
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Wait for the real session ID from the SDK's init message.
|
|
252
|
+
* Returns immediately if already received, or waits with a timeout.
|
|
253
|
+
*/
|
|
254
|
+
waitForSessionId(timeoutMs = 5000) {
|
|
255
|
+
if (this.sessionIdResolved) {
|
|
256
|
+
return Promise.resolve(this._sessionId);
|
|
257
|
+
}
|
|
258
|
+
return new Promise((resolve) => {
|
|
259
|
+
this.sessionIdResolvers.push(resolve);
|
|
260
|
+
// Timeout fallback - resolve with current ID even if not updated
|
|
261
|
+
setTimeout(() => {
|
|
262
|
+
const index = this.sessionIdResolvers.indexOf(resolve);
|
|
263
|
+
if (index >= 0) {
|
|
264
|
+
this.sessionIdResolvers.splice(index, 1);
|
|
265
|
+
resolve(this._sessionId);
|
|
266
|
+
}
|
|
267
|
+
}, timeoutMs);
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
getInfo() {
|
|
271
|
+
let stateType;
|
|
272
|
+
if (this._state.type === "terminated") {
|
|
273
|
+
stateType = "terminated";
|
|
274
|
+
}
|
|
275
|
+
else if (this._state.type === "waiting-input") {
|
|
276
|
+
stateType = "waiting-input";
|
|
277
|
+
}
|
|
278
|
+
else if (this._state.type === "idle") {
|
|
279
|
+
stateType = "idle";
|
|
280
|
+
}
|
|
281
|
+
else if (this._state.type === "hold") {
|
|
282
|
+
stateType = "hold";
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
stateType = "running";
|
|
286
|
+
}
|
|
287
|
+
const info = {
|
|
288
|
+
id: this.id,
|
|
289
|
+
sessionId: this._sessionId,
|
|
290
|
+
projectId: this.projectId,
|
|
291
|
+
projectPath: this.projectPath,
|
|
292
|
+
projectName: path.basename(this.projectPath),
|
|
293
|
+
sessionTitle: null, // Will be populated by Supervisor with session data
|
|
294
|
+
state: stateType,
|
|
295
|
+
startedAt: this.startedAt.toISOString(),
|
|
296
|
+
queueDepth: this.queueDepth,
|
|
297
|
+
provider: this.provider,
|
|
298
|
+
maxThinkingTokens: this._maxThinkingTokens,
|
|
299
|
+
};
|
|
300
|
+
// Add idleSince if idle
|
|
301
|
+
if (this._state.type === "idle") {
|
|
302
|
+
info.idleSince = this._state.since.toISOString();
|
|
303
|
+
}
|
|
304
|
+
// Add holdSince if held
|
|
305
|
+
if (this._state.type === "hold") {
|
|
306
|
+
info.holdSince = this._state.since.toISOString();
|
|
307
|
+
}
|
|
308
|
+
return info;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Get the in-memory message history.
|
|
312
|
+
* Used by mock SDK sessions where messages aren't persisted to disk.
|
|
313
|
+
*/
|
|
314
|
+
getMessageHistory() {
|
|
315
|
+
return [...this.messageHistory];
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Get accumulated streaming text for catch-up when clients connect mid-stream.
|
|
319
|
+
* Returns the message ID and accumulated text, or null if not streaming.
|
|
320
|
+
*/
|
|
321
|
+
getStreamingContent() {
|
|
322
|
+
if (!this._streamingMessageId || !this._streamingText) {
|
|
323
|
+
return null;
|
|
324
|
+
}
|
|
325
|
+
return {
|
|
326
|
+
messageId: this._streamingMessageId,
|
|
327
|
+
text: this._streamingText,
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Accumulate streaming text from a delta.
|
|
332
|
+
* Called by stream routes when processing stream_event messages.
|
|
333
|
+
*/
|
|
334
|
+
accumulateStreamingText(messageId, text) {
|
|
335
|
+
if (this._streamingMessageId !== messageId) {
|
|
336
|
+
// New streaming message, reset accumulator
|
|
337
|
+
this._streamingMessageId = messageId;
|
|
338
|
+
this._streamingText = text;
|
|
339
|
+
}
|
|
340
|
+
else {
|
|
341
|
+
this._streamingText += text;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Clear streaming text accumulator (called when stream ends).
|
|
346
|
+
*/
|
|
347
|
+
clearStreamingText() {
|
|
348
|
+
this._streamingText = "";
|
|
349
|
+
this._streamingMessageId = null;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Add initial user message to history without queuing to SDK.
|
|
353
|
+
* Used for real SDK sessions where the initial message is passed directly
|
|
354
|
+
* to the SDK but needs to be in history for SSE replay to late-joining clients.
|
|
355
|
+
*
|
|
356
|
+
* @param text - The message text
|
|
357
|
+
* @param uuid - The UUID to use (should match what was passed to SDK)
|
|
358
|
+
* @param tempId - Optional client temp ID for optimistic UI tracking
|
|
359
|
+
*/
|
|
360
|
+
addInitialUserMessage(text, uuid, tempId) {
|
|
361
|
+
const sdkMessage = {
|
|
362
|
+
type: "user",
|
|
363
|
+
uuid,
|
|
364
|
+
tempId,
|
|
365
|
+
message: { role: "user", content: text },
|
|
366
|
+
};
|
|
367
|
+
this.messageHistory.push(sdkMessage);
|
|
368
|
+
this.emit({ type: "message", message: sdkMessage });
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Format file size for display.
|
|
372
|
+
*/
|
|
373
|
+
formatSize(bytes) {
|
|
374
|
+
if (bytes < 1024)
|
|
375
|
+
return `${bytes} B`;
|
|
376
|
+
if (bytes < 1024 * 1024)
|
|
377
|
+
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
378
|
+
if (bytes < 1024 * 1024 * 1024)
|
|
379
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
380
|
+
return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Build user message content that matches what MessageQueue sends to the SDK.
|
|
384
|
+
* This ensures SSE/history messages can be deduplicated against JSONL.
|
|
385
|
+
*/
|
|
386
|
+
buildUserMessageContent(message) {
|
|
387
|
+
let text = message.text;
|
|
388
|
+
// Append attachment paths (same format as MessageQueue.toSDKMessage)
|
|
389
|
+
if (message.attachments?.length) {
|
|
390
|
+
const lines = message.attachments.map((f) => `- ${f.originalName} (${this.formatSize(f.size)}, ${f.mimeType}): ${f.path}`);
|
|
391
|
+
text += `\n\nUser uploaded files:\n${lines.join("\n")}`;
|
|
392
|
+
}
|
|
393
|
+
return text;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Queue a message to be sent to the SDK.
|
|
397
|
+
* For real SDK, pushes to MessageQueue.
|
|
398
|
+
* For mock SDK, uses legacy queue behavior.
|
|
399
|
+
*
|
|
400
|
+
* @returns Object with success status and queue position or error
|
|
401
|
+
*/
|
|
402
|
+
queueMessage(message) {
|
|
403
|
+
// Check if process is terminated or transport failed
|
|
404
|
+
if (this._state.type === "terminated") {
|
|
405
|
+
return {
|
|
406
|
+
success: false,
|
|
407
|
+
error: `Process terminated: ${this._state.reason}`,
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
// Check if transport failed (spawn error, etc.) - this flag is set synchronously
|
|
411
|
+
// to prevent race conditions where queueMessage is called before markTerminated completes
|
|
412
|
+
if (this.transportFailed) {
|
|
413
|
+
return {
|
|
414
|
+
success: false,
|
|
415
|
+
error: "Process transport failed",
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
// Create user message with UUID - this UUID will be used by both SSE and SDK
|
|
419
|
+
const uuid = randomUUID();
|
|
420
|
+
const messageWithUuid = { ...message, uuid };
|
|
421
|
+
// Build content that matches what the SDK will write to JSONL.
|
|
422
|
+
// This ensures SSE/history messages can be deduplicated against JSONL.
|
|
423
|
+
const content = this.buildUserMessageContent(message);
|
|
424
|
+
const sdkMessage = {
|
|
425
|
+
type: "user",
|
|
426
|
+
uuid,
|
|
427
|
+
tempId: message.tempId,
|
|
428
|
+
message: { role: "user", content },
|
|
429
|
+
};
|
|
430
|
+
// Add to history for SSE replay to late-joining clients.
|
|
431
|
+
// The client-side deduplication (mergeSSEMessage, mergeJSONLMessages) handles
|
|
432
|
+
// any duplicates when JSONL is later fetched. This is especially important
|
|
433
|
+
// for the two-phase flow (createSession + queueMessage) where the client
|
|
434
|
+
// may connect before the JSONL is written.
|
|
435
|
+
if (shouldEmitMessage(sdkMessage)) {
|
|
436
|
+
// Check for duplicates in history before adding
|
|
437
|
+
// This prevents duplicates if the provider echoes the message back with the same UUID
|
|
438
|
+
const isDuplicate = this.messageHistory.some((m) => m.uuid && m.uuid === sdkMessage.uuid);
|
|
439
|
+
if (!isDuplicate) {
|
|
440
|
+
this.messageHistory.push(sdkMessage);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
// Emit to current SSE subscribers so other clients see it immediately
|
|
444
|
+
// Include the session ID so client can associate it correctly
|
|
445
|
+
// The provider will echo this message back, but if we ensure UUIDs match,
|
|
446
|
+
// the client will merge them.
|
|
447
|
+
if (shouldEmitMessage(sdkMessage)) {
|
|
448
|
+
this.emit({
|
|
449
|
+
type: "message",
|
|
450
|
+
message: { ...sdkMessage, session_id: this._sessionId },
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
if (this.messageQueue) {
|
|
454
|
+
// Transition to running if we were idle
|
|
455
|
+
if (this._state.type === "idle") {
|
|
456
|
+
this.clearIdleTimer();
|
|
457
|
+
this.setState({ type: "running" });
|
|
458
|
+
}
|
|
459
|
+
// Pass message with UUID so SDK uses the same UUID we emitted via SSE
|
|
460
|
+
const position = this.messageQueue.push(messageWithUuid);
|
|
461
|
+
return { success: true, position };
|
|
462
|
+
}
|
|
463
|
+
// Legacy behavior for mock SDK
|
|
464
|
+
this.legacyQueue.push(message);
|
|
465
|
+
if (this._state.type === "idle") {
|
|
466
|
+
this.processNextInQueue();
|
|
467
|
+
}
|
|
468
|
+
return { success: true, position: this.legacyQueue.length };
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Handle tool approval request from SDK's canUseTool callback.
|
|
472
|
+
* This is called by the Supervisor when creating the session.
|
|
473
|
+
* Behavior depends on current permission mode:
|
|
474
|
+
* - default: Ask user for approval
|
|
475
|
+
* - acceptEdits: Auto-approve Edit/Write tools, ask for others
|
|
476
|
+
* - plan: Auto-approve read-only tools (Read, Glob, Grep, etc.), prompt for others
|
|
477
|
+
* - bypassPermissions: Auto-approve all tools
|
|
478
|
+
*/
|
|
479
|
+
async handleToolApproval(toolName, input, options) {
|
|
480
|
+
// Check if aborted
|
|
481
|
+
if (options.signal.aborted) {
|
|
482
|
+
return {
|
|
483
|
+
behavior: "deny",
|
|
484
|
+
message: "Operation aborted",
|
|
485
|
+
interrupt: true,
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
// Handle based on permission mode
|
|
489
|
+
switch (this._permissionMode) {
|
|
490
|
+
case "bypassPermissions":
|
|
491
|
+
// Auto-approve all tools
|
|
492
|
+
return { behavior: "allow" };
|
|
493
|
+
case "plan": {
|
|
494
|
+
// Read-only tools are auto-allowed - essential for creating good plans
|
|
495
|
+
const readOnlyTools = [
|
|
496
|
+
"Read",
|
|
497
|
+
"Glob",
|
|
498
|
+
"Grep",
|
|
499
|
+
"LSP",
|
|
500
|
+
"WebFetch",
|
|
501
|
+
"WebSearch",
|
|
502
|
+
"Task", // Subagent exploration
|
|
503
|
+
"TaskOutput", // Reading subagent results
|
|
504
|
+
];
|
|
505
|
+
if (readOnlyTools.includes(toolName)) {
|
|
506
|
+
return { behavior: "allow" };
|
|
507
|
+
}
|
|
508
|
+
// Allow Write to .claude/plans/ directory for saving plans
|
|
509
|
+
if (toolName === "Write") {
|
|
510
|
+
const filePath = input?.file_path ?? "";
|
|
511
|
+
if (filePath.includes(".claude/plans/")) {
|
|
512
|
+
return { behavior: "allow" };
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
// ExitPlanMode and AskUserQuestion should prompt the user
|
|
516
|
+
// ExitPlanMode: user must approve the plan before exiting plan mode
|
|
517
|
+
// AskUserQuestion: clarifying questions are valid during planning
|
|
518
|
+
if (toolName === "ExitPlanMode" || toolName === "AskUserQuestion") {
|
|
519
|
+
break; // Fall through to ask user for approval
|
|
520
|
+
}
|
|
521
|
+
// Other tools (Bash, Edit, Write to non-plan files, etc.) - prompt user
|
|
522
|
+
// Agent typically won't use these in plan mode, but if they have a good
|
|
523
|
+
// reason (e.g., checking git log, verifying dependencies), let them ask
|
|
524
|
+
break; // Fall through to ask user for approval
|
|
525
|
+
}
|
|
526
|
+
case "acceptEdits": {
|
|
527
|
+
// Auto-approve file editing tools, ask for others
|
|
528
|
+
const editTools = ["Edit", "Write", "NotebookEdit"];
|
|
529
|
+
if (editTools.includes(toolName)) {
|
|
530
|
+
return { behavior: "allow" };
|
|
531
|
+
}
|
|
532
|
+
// Fall through to ask user for non-edit tools
|
|
533
|
+
break;
|
|
534
|
+
}
|
|
535
|
+
default: {
|
|
536
|
+
// Read-only tools are auto-allowed - no need to prompt for reads
|
|
537
|
+
// "Ask before edits" means ask before WRITES, not reads
|
|
538
|
+
const readOnlyTools = [
|
|
539
|
+
"Read",
|
|
540
|
+
"Glob",
|
|
541
|
+
"Grep",
|
|
542
|
+
"LSP",
|
|
543
|
+
"WebFetch",
|
|
544
|
+
"WebSearch",
|
|
545
|
+
"Task", // Subagent exploration
|
|
546
|
+
"TaskOutput", // Reading subagent results
|
|
547
|
+
];
|
|
548
|
+
if (readOnlyTools.includes(toolName)) {
|
|
549
|
+
return { behavior: "allow" };
|
|
550
|
+
}
|
|
551
|
+
// Fall through to ask user for mutating tools
|
|
552
|
+
break;
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
// Default behavior: ask user for approval
|
|
556
|
+
const request = {
|
|
557
|
+
id: randomUUID(),
|
|
558
|
+
sessionId: this._sessionId,
|
|
559
|
+
type: "tool-approval",
|
|
560
|
+
prompt: `Allow ${toolName}?`,
|
|
561
|
+
toolName,
|
|
562
|
+
toolInput: input,
|
|
563
|
+
timestamp: new Date().toISOString(),
|
|
564
|
+
};
|
|
565
|
+
// Add to the pending approvals map and queue
|
|
566
|
+
// The first pending approval is shown to the user, others wait in queue
|
|
567
|
+
const isFirstPending = this.pendingToolApprovals.size === 0;
|
|
568
|
+
// Create a promise that will be resolved by respondToInput
|
|
569
|
+
return new Promise((resolve) => {
|
|
570
|
+
this.pendingToolApprovals.set(request.id, { request, resolve });
|
|
571
|
+
this.pendingToolApprovalQueue.push(request.id);
|
|
572
|
+
// Handle abort signal
|
|
573
|
+
const onAbort = () => {
|
|
574
|
+
if (this.pendingToolApprovals.has(request.id)) {
|
|
575
|
+
this.pendingToolApprovals.delete(request.id);
|
|
576
|
+
this.pendingToolApprovalQueue = this.pendingToolApprovalQueue.filter((id) => id !== request.id);
|
|
577
|
+
// If this was the current request being shown, emit the next one
|
|
578
|
+
if (isFirstPending) {
|
|
579
|
+
this.emitNextPendingApproval();
|
|
580
|
+
}
|
|
581
|
+
resolve({
|
|
582
|
+
behavior: "deny",
|
|
583
|
+
message: "Operation aborted",
|
|
584
|
+
interrupt: true,
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
options.signal.addEventListener("abort", onAbort, { once: true });
|
|
589
|
+
// Only emit state change for the first pending approval
|
|
590
|
+
// Subsequent approvals wait in queue until the first is resolved
|
|
591
|
+
if (isFirstPending) {
|
|
592
|
+
this.setState({ type: "waiting-input", request });
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* Emit the next pending approval to the client, or transition to running if none left.
|
|
598
|
+
*/
|
|
599
|
+
emitNextPendingApproval() {
|
|
600
|
+
const nextId = this.pendingToolApprovalQueue[0];
|
|
601
|
+
if (nextId !== undefined) {
|
|
602
|
+
const next = this.pendingToolApprovals.get(nextId);
|
|
603
|
+
if (next) {
|
|
604
|
+
this.setState({ type: "waiting-input", request: next.request });
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
// No more pending approvals
|
|
609
|
+
this.setState({ type: "running" });
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Respond to a pending input request (tool approval).
|
|
613
|
+
* Called from the API when user approves/denies a tool.
|
|
614
|
+
* For AskUserQuestion, answers can be passed to update the tool input.
|
|
615
|
+
* For deny with feedback, the feedback message is passed to the SDK.
|
|
616
|
+
* Works for both real SDK (canUseTool callback) and mock SDK (input_request message).
|
|
617
|
+
*/
|
|
618
|
+
respondToInput(requestId, response, answers, feedback) {
|
|
619
|
+
const pending = this.pendingToolApprovals.get(requestId);
|
|
620
|
+
// For mock SDK: check if requestId matches the state's request
|
|
621
|
+
if (!pending) {
|
|
622
|
+
if (this._state.type === "waiting-input" &&
|
|
623
|
+
this._state.request.id === requestId) {
|
|
624
|
+
// Mock SDK case - just transition back to idle/running
|
|
625
|
+
this.setState({ type: "running" });
|
|
626
|
+
return true;
|
|
627
|
+
}
|
|
628
|
+
return false;
|
|
629
|
+
}
|
|
630
|
+
// Build the result with optional updated input for AskUserQuestion
|
|
631
|
+
// If deny has feedback, use that as the message
|
|
632
|
+
const denyMessage = feedback || "User denied permission";
|
|
633
|
+
// If user just clicked "No" without feedback, set interrupt: true to stop retrying.
|
|
634
|
+
// If user provided feedback, set interrupt: false so Claude can incorporate the guidance.
|
|
635
|
+
const shouldInterrupt = response === "deny" && !feedback;
|
|
636
|
+
const result = {
|
|
637
|
+
behavior: response === "approve" ? "allow" : "deny",
|
|
638
|
+
message: response === "deny" ? denyMessage : undefined,
|
|
639
|
+
interrupt: response === "deny" ? shouldInterrupt : undefined,
|
|
640
|
+
};
|
|
641
|
+
// If answers provided (AskUserQuestion), pass them as updatedInput
|
|
642
|
+
if (answers && response === "approve") {
|
|
643
|
+
const originalInput = pending.request.toolInput;
|
|
644
|
+
result.updatedInput = {
|
|
645
|
+
...originalInput,
|
|
646
|
+
answers,
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
// If EnterPlanMode is approved, switch to plan mode
|
|
650
|
+
if (response === "approve" &&
|
|
651
|
+
pending.request.toolName === "EnterPlanMode") {
|
|
652
|
+
this.setPermissionMode("plan");
|
|
653
|
+
}
|
|
654
|
+
// If ExitPlanMode is approved, switch back to default mode
|
|
655
|
+
if (response === "approve" && pending.request.toolName === "ExitPlanMode") {
|
|
656
|
+
this.setPermissionMode("default");
|
|
657
|
+
}
|
|
658
|
+
// Resolve the promise and remove from tracking
|
|
659
|
+
pending.resolve(result);
|
|
660
|
+
this.pendingToolApprovals.delete(requestId);
|
|
661
|
+
this.pendingToolApprovalQueue = this.pendingToolApprovalQueue.filter((id) => id !== requestId);
|
|
662
|
+
// Emit the next pending approval, or transition to running if none left
|
|
663
|
+
this.emitNextPendingApproval();
|
|
664
|
+
return true;
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* Get the current pending input request (first in queue), if any.
|
|
668
|
+
* Works for both real SDK (canUseTool callback) and mock SDK (input_request message).
|
|
669
|
+
*/
|
|
670
|
+
getPendingInputRequest() {
|
|
671
|
+
// Check real SDK pending approvals queue first
|
|
672
|
+
const firstId = this.pendingToolApprovalQueue[0];
|
|
673
|
+
if (firstId !== undefined) {
|
|
674
|
+
return this.pendingToolApprovals.get(firstId)?.request ?? null;
|
|
675
|
+
}
|
|
676
|
+
// For mock SDK, check state directly
|
|
677
|
+
if (this._state.type === "waiting-input") {
|
|
678
|
+
return this._state.request;
|
|
679
|
+
}
|
|
680
|
+
return null;
|
|
681
|
+
}
|
|
682
|
+
subscribe(listener) {
|
|
683
|
+
this.listeners.add(listener);
|
|
684
|
+
return () => {
|
|
685
|
+
this.listeners.delete(listener);
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
async abort() {
|
|
689
|
+
this.clearIdleTimer();
|
|
690
|
+
// Call the SDK's abort function if available
|
|
691
|
+
if (this.abortFn) {
|
|
692
|
+
this.abortFn();
|
|
693
|
+
}
|
|
694
|
+
// Signal completion to subscribers
|
|
695
|
+
this.emit({ type: "complete" });
|
|
696
|
+
this.listeners.clear();
|
|
697
|
+
}
|
|
698
|
+
async processMessages() {
|
|
699
|
+
try {
|
|
700
|
+
while (!this.iteratorDone) {
|
|
701
|
+
// Check if held - pause before calling iterator.next()
|
|
702
|
+
if (this._isHeld) {
|
|
703
|
+
await this.waitUntilResumed();
|
|
704
|
+
// After resuming, check if we should continue or if terminated while held
|
|
705
|
+
if (this.iteratorDone || this._state.type === "terminated") {
|
|
706
|
+
break;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
const result = await this.sdkIterator.next();
|
|
710
|
+
if (result.done) {
|
|
711
|
+
this.iteratorDone = true;
|
|
712
|
+
// Don't transition to idle if we're waiting for input
|
|
713
|
+
if (this._state.type !== "waiting-input") {
|
|
714
|
+
this.transitionToIdle();
|
|
715
|
+
}
|
|
716
|
+
break;
|
|
717
|
+
}
|
|
718
|
+
const message = result.value;
|
|
719
|
+
// Store message in history (for mock SDK that doesn't persist to disk)
|
|
720
|
+
// See shouldEmitMessage() for why we never filter messages
|
|
721
|
+
if (shouldEmitMessage(message)) {
|
|
722
|
+
// Check for duplicates before adding to history
|
|
723
|
+
// This handles the case where queueMessage added the optimistic message
|
|
724
|
+
// and now the provider is echoing it back with the same UUID
|
|
725
|
+
const isDuplicate = message.type === "user" &&
|
|
726
|
+
message.uuid &&
|
|
727
|
+
this.messageHistory.some((m) => m.uuid === message.uuid);
|
|
728
|
+
if (!isDuplicate) {
|
|
729
|
+
this.messageHistory.push(message);
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
// Extract session ID from init message
|
|
733
|
+
if (message.type === "system" &&
|
|
734
|
+
message.subtype === "init" &&
|
|
735
|
+
message.session_id) {
|
|
736
|
+
const log = getLogger();
|
|
737
|
+
const oldSessionId = this._sessionId;
|
|
738
|
+
this._sessionId = message.session_id;
|
|
739
|
+
this.sessionIdResolved = true;
|
|
740
|
+
log.info({
|
|
741
|
+
event: "session_id_received",
|
|
742
|
+
sessionId: this._sessionId,
|
|
743
|
+
previousTempId: oldSessionId,
|
|
744
|
+
processId: this.id,
|
|
745
|
+
projectId: this.projectId,
|
|
746
|
+
}, `Session ID received from SDK: ${this._sessionId}`);
|
|
747
|
+
// Emit session-id-changed event so Supervisor can update its mapping
|
|
748
|
+
// This is critical for ExternalSessionTracker to correctly identify owned sessions
|
|
749
|
+
if (oldSessionId !== this._sessionId) {
|
|
750
|
+
this.emit({
|
|
751
|
+
type: "session-id-changed",
|
|
752
|
+
oldSessionId,
|
|
753
|
+
newSessionId: this._sessionId,
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
// Resolve any waiters
|
|
757
|
+
for (const resolve of this.sessionIdResolvers) {
|
|
758
|
+
resolve(this._sessionId);
|
|
759
|
+
}
|
|
760
|
+
this.sessionIdResolvers = [];
|
|
761
|
+
}
|
|
762
|
+
// Emit to SSE subscribers
|
|
763
|
+
// See shouldEmitMessage() for why we never filter messages
|
|
764
|
+
if (shouldEmitMessage(message)) {
|
|
765
|
+
this.emit({ type: "message", message });
|
|
766
|
+
}
|
|
767
|
+
// Handle special message types
|
|
768
|
+
if (message.type === "system" && message.subtype === "input_request") {
|
|
769
|
+
// Legacy mock SDK behavior - handle input_request message
|
|
770
|
+
this.handleInputRequest(message);
|
|
771
|
+
}
|
|
772
|
+
else if (message.type === "result") {
|
|
773
|
+
this.transitionToIdle();
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
catch (error) {
|
|
778
|
+
const err = error;
|
|
779
|
+
const log = getLogger();
|
|
780
|
+
log.error({
|
|
781
|
+
event: "process_error",
|
|
782
|
+
sessionId: this._sessionId,
|
|
783
|
+
processId: this.id,
|
|
784
|
+
projectId: this.projectId,
|
|
785
|
+
errorMessage: err.message,
|
|
786
|
+
errorStack: err.stack,
|
|
787
|
+
currentState: this._state.type,
|
|
788
|
+
}, `Process error: ${this._sessionId} - ${err.message}`);
|
|
789
|
+
this.emit({ type: "error", error: err });
|
|
790
|
+
// Detect process termination errors - set flag synchronously BEFORE markTerminated
|
|
791
|
+
// to prevent race where queueMessage is called before state changes to terminated
|
|
792
|
+
if (this.isProcessTerminationError(err)) {
|
|
793
|
+
this.transportFailed = true;
|
|
794
|
+
this.markTerminated("underlying process terminated", err);
|
|
795
|
+
return;
|
|
796
|
+
}
|
|
797
|
+
// Don't transition to idle if we're waiting for input
|
|
798
|
+
if (this._state.type !== "waiting-input") {
|
|
799
|
+
this.transitionToIdle();
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* Check if an error indicates the underlying Claude process was terminated.
|
|
805
|
+
*/
|
|
806
|
+
isProcessTerminationError(error) {
|
|
807
|
+
const message = error.message || "";
|
|
808
|
+
return (message.includes("ProcessTransport is not ready") ||
|
|
809
|
+
message.includes("not ready for writing") ||
|
|
810
|
+
message.includes("process exited") ||
|
|
811
|
+
message.includes("SIGTERM") ||
|
|
812
|
+
message.includes("SIGKILL") ||
|
|
813
|
+
message.includes("spawn ENOENT"));
|
|
814
|
+
}
|
|
815
|
+
/**
|
|
816
|
+
* Handle input_request message from mock SDK.
|
|
817
|
+
* Real SDK uses canUseTool callback instead.
|
|
818
|
+
*/
|
|
819
|
+
handleInputRequest(message) {
|
|
820
|
+
if (!message.input_request)
|
|
821
|
+
return;
|
|
822
|
+
const request = {
|
|
823
|
+
id: message.input_request.id,
|
|
824
|
+
sessionId: this._sessionId,
|
|
825
|
+
type: message.input_request.type,
|
|
826
|
+
prompt: message.input_request.prompt,
|
|
827
|
+
options: message.input_request.options,
|
|
828
|
+
timestamp: new Date().toISOString(),
|
|
829
|
+
};
|
|
830
|
+
this.setState({ type: "waiting-input", request });
|
|
831
|
+
}
|
|
832
|
+
transitionToIdle() {
|
|
833
|
+
this.clearIdleTimer();
|
|
834
|
+
this.setState({ type: "idle", since: new Date() });
|
|
835
|
+
this.startIdleTimer();
|
|
836
|
+
this.processNextInQueue();
|
|
837
|
+
}
|
|
838
|
+
/**
|
|
839
|
+
* Process next message in legacy queue (for mock SDK).
|
|
840
|
+
*/
|
|
841
|
+
processNextInQueue() {
|
|
842
|
+
if (this.legacyQueue.length === 0)
|
|
843
|
+
return;
|
|
844
|
+
const nextMessage = this.legacyQueue.shift();
|
|
845
|
+
if (nextMessage) {
|
|
846
|
+
// In real implementation with MessageQueue, this happens automatically
|
|
847
|
+
// For mock SDK, we just transition back to running
|
|
848
|
+
this.setState({ type: "running" });
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
startIdleTimer() {
|
|
852
|
+
this.idleTimer = setTimeout(() => {
|
|
853
|
+
// Emit completion - Supervisor will clean up
|
|
854
|
+
this.emit({ type: "complete" });
|
|
855
|
+
}, this.idleTimeoutMs);
|
|
856
|
+
}
|
|
857
|
+
clearIdleTimer() {
|
|
858
|
+
if (this.idleTimer) {
|
|
859
|
+
clearTimeout(this.idleTimer);
|
|
860
|
+
this.idleTimer = null;
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
setState(state) {
|
|
864
|
+
this._state = state;
|
|
865
|
+
this.emit({ type: "state-change", state });
|
|
866
|
+
}
|
|
867
|
+
emit(event) {
|
|
868
|
+
for (const listener of this.listeners) {
|
|
869
|
+
try {
|
|
870
|
+
listener(event);
|
|
871
|
+
}
|
|
872
|
+
catch {
|
|
873
|
+
// Ignore listener errors
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
//# sourceMappingURL=Process.js.map
|