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,84 @@
|
|
|
1
|
+
import { type WriteStream } from "node:fs";
|
|
2
|
+
import type { UploadedFile } from "@yep-anywhere/shared";
|
|
3
|
+
/** Root directory for uploads (uses dataDir from config for profile support) */
|
|
4
|
+
export declare const UPLOADS_DIR: string;
|
|
5
|
+
/**
|
|
6
|
+
* State machine for a single upload operation.
|
|
7
|
+
* Handles streaming chunks to disk with proper cleanup on error.
|
|
8
|
+
*/
|
|
9
|
+
export interface UploadState {
|
|
10
|
+
id: string;
|
|
11
|
+
originalName: string;
|
|
12
|
+
sanitizedName: string;
|
|
13
|
+
filePath: string;
|
|
14
|
+
expectedSize: number;
|
|
15
|
+
bytesReceived: number;
|
|
16
|
+
mimeType: string;
|
|
17
|
+
writeStream: WriteStream | null;
|
|
18
|
+
status: "pending" | "streaming" | "complete" | "error" | "cancelled";
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Sanitize filename to prevent path traversal and invalid characters.
|
|
22
|
+
*
|
|
23
|
+
* - Strips directory components (handles both Unix and Windows paths)
|
|
24
|
+
* - Replaces dangerous characters
|
|
25
|
+
* - Adds UUID prefix to prevent collisions
|
|
26
|
+
*/
|
|
27
|
+
export declare function sanitizeFilename(original: string): {
|
|
28
|
+
id: string;
|
|
29
|
+
sanitized: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Get the upload directory for a project+session.
|
|
33
|
+
* Creates the directory if it doesn't exist.
|
|
34
|
+
*
|
|
35
|
+
* @param encodedProjectPath - base64url encoded project path
|
|
36
|
+
* @param sessionId - Session identifier
|
|
37
|
+
* @param uploadsDir - Base uploads directory (defaults to UPLOADS_DIR)
|
|
38
|
+
*/
|
|
39
|
+
export declare function getUploadDir(encodedProjectPath: string, sessionId: string, uploadsDir?: string): Promise<string>;
|
|
40
|
+
export interface UploadManagerOptions {
|
|
41
|
+
uploadsDir?: string;
|
|
42
|
+
/** Maximum upload file size in bytes. 0 = unlimited */
|
|
43
|
+
maxUploadSizeBytes?: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Manages file upload operations with streaming to disk.
|
|
47
|
+
*/
|
|
48
|
+
export declare class UploadManager {
|
|
49
|
+
private uploads;
|
|
50
|
+
private uploadsDir;
|
|
51
|
+
private maxUploadSizeBytes;
|
|
52
|
+
constructor(options?: UploadManagerOptions);
|
|
53
|
+
/**
|
|
54
|
+
* Start a new upload.
|
|
55
|
+
*
|
|
56
|
+
* @returns Upload ID for tracking this upload
|
|
57
|
+
* @throws Error if file size exceeds maxUploadSizeBytes limit
|
|
58
|
+
*/
|
|
59
|
+
startUpload(encodedProjectPath: string, sessionId: string, originalName: string, expectedSize: number, mimeType: string): Promise<{
|
|
60
|
+
uploadId: string;
|
|
61
|
+
state: UploadState;
|
|
62
|
+
}>;
|
|
63
|
+
/**
|
|
64
|
+
* Write a chunk of data to the upload.
|
|
65
|
+
* Opens the write stream on first chunk (lazy initialization).
|
|
66
|
+
* @throws Error if writing would exceed maxUploadSizeBytes limit
|
|
67
|
+
*/
|
|
68
|
+
writeChunk(uploadId: string, chunk: Buffer): Promise<number>;
|
|
69
|
+
/**
|
|
70
|
+
* Complete an upload.
|
|
71
|
+
* Closes the write stream and verifies the file.
|
|
72
|
+
*/
|
|
73
|
+
completeUpload(uploadId: string): Promise<UploadedFile>;
|
|
74
|
+
/**
|
|
75
|
+
* Cancel or cleanup a failed upload.
|
|
76
|
+
* Closes stream and removes partial file.
|
|
77
|
+
*/
|
|
78
|
+
cancelUpload(uploadId: string): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Get current state of an upload.
|
|
81
|
+
*/
|
|
82
|
+
getState(uploadId: string): UploadState | undefined;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/uploads/manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAqB,MAAM,SAAS,CAAC;AAG9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGzD,gFAAgF;AAChF,eAAO,MAAM,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,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAmDlE;;;OAGG;IACG,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAoC7D;;;OAGG;IACG,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAuBnD;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;CAGpD"}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { createWriteStream } from "node:fs";
|
|
3
|
+
import { mkdir, rm, stat } from "node:fs/promises";
|
|
4
|
+
import { extname, join } from "node:path";
|
|
5
|
+
import { getDataDir } from "../config.js";
|
|
6
|
+
/** Root directory for uploads (uses dataDir from config for profile support) */
|
|
7
|
+
export const UPLOADS_DIR = join(getDataDir(), "uploads");
|
|
8
|
+
/**
|
|
9
|
+
* Sanitize filename to prevent path traversal and invalid characters.
|
|
10
|
+
*
|
|
11
|
+
* - Strips directory components (handles both Unix and Windows paths)
|
|
12
|
+
* - Replaces dangerous characters
|
|
13
|
+
* - Adds UUID prefix to prevent collisions
|
|
14
|
+
*/
|
|
15
|
+
export function sanitizeFilename(original) {
|
|
16
|
+
const id = randomUUID();
|
|
17
|
+
// Extract just the filename (handle both Unix and Windows path separators)
|
|
18
|
+
// On Linux, basename() doesn't handle Windows paths, so we manually split first
|
|
19
|
+
let baseFilename = original;
|
|
20
|
+
const lastSlash = Math.max(original.lastIndexOf("/"), original.lastIndexOf("\\"));
|
|
21
|
+
if (lastSlash >= 0) {
|
|
22
|
+
baseFilename = original.slice(lastSlash + 1);
|
|
23
|
+
}
|
|
24
|
+
// Remove null bytes and other dangerous characters
|
|
25
|
+
let sanitized = baseFilename
|
|
26
|
+
.replace(/\0/g, "")
|
|
27
|
+
.replace(/[<>:"/\\|?*]/g, "_") // Windows-invalid chars (includes path separators)
|
|
28
|
+
.replace(/\.\./g, "_") // path traversal
|
|
29
|
+
.trim();
|
|
30
|
+
// Handle empty or only-underscore/dot names
|
|
31
|
+
if (!sanitized || /^[_.\s]*$/.test(sanitized)) {
|
|
32
|
+
sanitized = "unnamed";
|
|
33
|
+
}
|
|
34
|
+
// Ensure reasonable length (keep extension)
|
|
35
|
+
const ext = extname(sanitized);
|
|
36
|
+
const nameWithoutExt = sanitized.slice(0, sanitized.length - ext.length);
|
|
37
|
+
if (nameWithoutExt.length > 200) {
|
|
38
|
+
sanitized = nameWithoutExt.slice(0, 200) + ext;
|
|
39
|
+
}
|
|
40
|
+
// Prefix with UUID
|
|
41
|
+
return {
|
|
42
|
+
id,
|
|
43
|
+
sanitized: `${id}_${sanitized}`,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Get the upload directory for a project+session.
|
|
48
|
+
* Creates the directory if it doesn't exist.
|
|
49
|
+
*
|
|
50
|
+
* @param encodedProjectPath - base64url encoded project path
|
|
51
|
+
* @param sessionId - Session identifier
|
|
52
|
+
* @param uploadsDir - Base uploads directory (defaults to UPLOADS_DIR)
|
|
53
|
+
*/
|
|
54
|
+
export async function getUploadDir(encodedProjectPath, sessionId, uploadsDir = UPLOADS_DIR) {
|
|
55
|
+
const dir = join(uploadsDir, encodedProjectPath, sessionId);
|
|
56
|
+
await mkdir(dir, { recursive: true });
|
|
57
|
+
return dir;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Manages file upload operations with streaming to disk.
|
|
61
|
+
*/
|
|
62
|
+
export class UploadManager {
|
|
63
|
+
uploads = new Map();
|
|
64
|
+
uploadsDir;
|
|
65
|
+
maxUploadSizeBytes;
|
|
66
|
+
constructor(options = {}) {
|
|
67
|
+
this.uploadsDir = options.uploadsDir ?? UPLOADS_DIR;
|
|
68
|
+
this.maxUploadSizeBytes = options.maxUploadSizeBytes ?? 0;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Start a new upload.
|
|
72
|
+
*
|
|
73
|
+
* @returns Upload ID for tracking this upload
|
|
74
|
+
* @throws Error if file size exceeds maxUploadSizeBytes limit
|
|
75
|
+
*/
|
|
76
|
+
async startUpload(encodedProjectPath, sessionId, originalName, expectedSize, mimeType) {
|
|
77
|
+
// Check file size limit
|
|
78
|
+
if (this.maxUploadSizeBytes > 0 && expectedSize > this.maxUploadSizeBytes) {
|
|
79
|
+
const maxMB = Math.round(this.maxUploadSizeBytes / (1024 * 1024));
|
|
80
|
+
throw new Error(`File size exceeds maximum allowed size of ${maxMB}MB`);
|
|
81
|
+
}
|
|
82
|
+
const uploadDir = await getUploadDir(encodedProjectPath, sessionId, this.uploadsDir);
|
|
83
|
+
const { id, sanitized } = sanitizeFilename(originalName);
|
|
84
|
+
const filePath = join(uploadDir, sanitized);
|
|
85
|
+
const state = {
|
|
86
|
+
id,
|
|
87
|
+
originalName,
|
|
88
|
+
sanitizedName: sanitized,
|
|
89
|
+
filePath,
|
|
90
|
+
expectedSize,
|
|
91
|
+
bytesReceived: 0,
|
|
92
|
+
mimeType,
|
|
93
|
+
writeStream: null,
|
|
94
|
+
status: "pending",
|
|
95
|
+
};
|
|
96
|
+
this.uploads.set(id, state);
|
|
97
|
+
return { uploadId: id, state };
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Write a chunk of data to the upload.
|
|
101
|
+
* Opens the write stream on first chunk (lazy initialization).
|
|
102
|
+
* @throws Error if writing would exceed maxUploadSizeBytes limit
|
|
103
|
+
*/
|
|
104
|
+
async writeChunk(uploadId, chunk) {
|
|
105
|
+
const state = this.uploads.get(uploadId);
|
|
106
|
+
if (!state) {
|
|
107
|
+
throw new Error(`Upload not found: ${uploadId}`);
|
|
108
|
+
}
|
|
109
|
+
if (state.status === "cancelled" || state.status === "error") {
|
|
110
|
+
throw new Error(`Upload is ${state.status}`);
|
|
111
|
+
}
|
|
112
|
+
// Check if this chunk would exceed the size limit
|
|
113
|
+
if (this.maxUploadSizeBytes > 0) {
|
|
114
|
+
const newTotal = state.bytesReceived + chunk.length;
|
|
115
|
+
if (newTotal > this.maxUploadSizeBytes) {
|
|
116
|
+
const maxMB = Math.round(this.maxUploadSizeBytes / (1024 * 1024));
|
|
117
|
+
throw new Error(`Upload exceeds maximum allowed size of ${maxMB}MB`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// Lazy-create write stream on first chunk
|
|
121
|
+
if (!state.writeStream) {
|
|
122
|
+
state.writeStream = createWriteStream(state.filePath);
|
|
123
|
+
state.status = "streaming";
|
|
124
|
+
// Handle stream errors
|
|
125
|
+
state.writeStream.on("error", () => {
|
|
126
|
+
state.status = "error";
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
// Write chunk and track bytes
|
|
130
|
+
return new Promise((resolve, reject) => {
|
|
131
|
+
const canContinue = state.writeStream?.write(chunk, (err) => {
|
|
132
|
+
if (err) {
|
|
133
|
+
state.status = "error";
|
|
134
|
+
reject(err);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
state.bytesReceived += chunk.length;
|
|
138
|
+
resolve(state.bytesReceived);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
// Handle backpressure - wait for drain if buffer is full
|
|
142
|
+
if (!canContinue) {
|
|
143
|
+
state.writeStream?.once("drain", () => {
|
|
144
|
+
// Already resolved in callback above
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Complete an upload.
|
|
151
|
+
* Closes the write stream and verifies the file.
|
|
152
|
+
*/
|
|
153
|
+
async completeUpload(uploadId) {
|
|
154
|
+
const state = this.uploads.get(uploadId);
|
|
155
|
+
if (!state) {
|
|
156
|
+
throw new Error(`Upload not found: ${uploadId}`);
|
|
157
|
+
}
|
|
158
|
+
if (state.status !== "streaming" && state.status !== "pending") {
|
|
159
|
+
throw new Error(`Cannot complete upload in status: ${state.status}`);
|
|
160
|
+
}
|
|
161
|
+
// Close the write stream
|
|
162
|
+
if (state.writeStream) {
|
|
163
|
+
await new Promise((resolve, reject) => {
|
|
164
|
+
state.writeStream?.end((err) => {
|
|
165
|
+
if (err)
|
|
166
|
+
reject(err);
|
|
167
|
+
else
|
|
168
|
+
resolve();
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
// Verify file exists and get actual size
|
|
173
|
+
const stats = await stat(state.filePath);
|
|
174
|
+
state.status = "complete";
|
|
175
|
+
this.uploads.delete(uploadId);
|
|
176
|
+
return {
|
|
177
|
+
id: state.id,
|
|
178
|
+
originalName: state.originalName,
|
|
179
|
+
name: state.sanitizedName,
|
|
180
|
+
path: state.filePath,
|
|
181
|
+
size: stats.size,
|
|
182
|
+
mimeType: state.mimeType,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Cancel or cleanup a failed upload.
|
|
187
|
+
* Closes stream and removes partial file.
|
|
188
|
+
*/
|
|
189
|
+
async cancelUpload(uploadId) {
|
|
190
|
+
const state = this.uploads.get(uploadId);
|
|
191
|
+
if (!state) {
|
|
192
|
+
return; // Already cleaned up
|
|
193
|
+
}
|
|
194
|
+
state.status = "cancelled";
|
|
195
|
+
// Close the write stream
|
|
196
|
+
if (state.writeStream) {
|
|
197
|
+
state.writeStream.destroy();
|
|
198
|
+
}
|
|
199
|
+
// Remove partial file
|
|
200
|
+
try {
|
|
201
|
+
await rm(state.filePath, { force: true });
|
|
202
|
+
}
|
|
203
|
+
catch {
|
|
204
|
+
// Ignore - file may not exist yet
|
|
205
|
+
}
|
|
206
|
+
this.uploads.delete(uploadId);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Get current state of an upload.
|
|
210
|
+
*/
|
|
211
|
+
getState(uploadId) {
|
|
212
|
+
return this.uploads.get(uploadId);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
//# sourceMappingURL=man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AE,KAAK,CAAC,YAAY;YAChC,IAAI,EAAE,KAAK,CAAC,aAAa;YACzB,IAAI,EAAE,KAAK,CAAC,QAAQ;YACpB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,QAAQ,EAAE,KAAK,CAAC,QAAQ;SACzB,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,YAAY,CAAC,QAAgB;QACjC,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACzC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,qBAAqB;QAC/B,CAAC;QAED,KAAK,CAAC,MAAM,GAAG,WAAW,CAAC;QAE3B,yBAAyB;QACzB,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;YACtB,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QAC9B,CAAC;QAED,sBAAsB;QACtB,IAAI,CAAC;YACH,MAAM,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5C,CAAC;QAAC,MAAM,CAAC;YACP,kCAAkC;QACpC,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,QAAgB;QACvB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC;CACF"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File locking utilities for coordinating access to shared data files
|
|
3
|
+
* across multiple yep-anywhere server instances.
|
|
4
|
+
*
|
|
5
|
+
* Uses proper-lockfile which:
|
|
6
|
+
* - Uses mkdir for atomic lock acquisition (works on local + network FS)
|
|
7
|
+
* - Periodically updates mtime to detect stale locks from crashed processes
|
|
8
|
+
* - Pure JS, no native dependencies
|
|
9
|
+
*/
|
|
10
|
+
export interface FileLockOptions {
|
|
11
|
+
/** Number of retries if lock is held (default: 3) */
|
|
12
|
+
retries?: number;
|
|
13
|
+
/** Lock considered stale after this many ms (default: 10000) */
|
|
14
|
+
stale?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Execute a function while holding an exclusive lock on a file.
|
|
18
|
+
* Use this for read-modify-write operations on shared files.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* await withFileLock(metadataPath, async () => {
|
|
22
|
+
* const data = JSON.parse(await fs.readFile(metadataPath, 'utf-8'));
|
|
23
|
+
* data.starred = true;
|
|
24
|
+
* await fs.writeFile(metadataPath, JSON.stringify(data, null, 2));
|
|
25
|
+
* });
|
|
26
|
+
*/
|
|
27
|
+
export declare function withFileLock<T>(filePath: string, fn: () => Promise<T>, options?: FileLockOptions): Promise<T>;
|
|
28
|
+
export interface CacheWriterOptions {
|
|
29
|
+
/** Lock considered stale after this many ms (default: 30000) */
|
|
30
|
+
stale?: number;
|
|
31
|
+
/** Heartbeat interval in ms (default: 10000) */
|
|
32
|
+
update?: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Try to claim exclusive cache writer rights for this process.
|
|
36
|
+
* Only one process should write cache/index files to avoid conflicts.
|
|
37
|
+
*
|
|
38
|
+
* Returns a release function if lock acquired, null if another process holds it.
|
|
39
|
+
* The lock is maintained via periodic heartbeat until released or process exits.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* const release = await tryClaimCacheWriter(dataDir);
|
|
43
|
+
* if (release) {
|
|
44
|
+
* console.log('I am the cache writer');
|
|
45
|
+
* // Write cache files...
|
|
46
|
+
* // On shutdown: await release();
|
|
47
|
+
* } else {
|
|
48
|
+
* console.log('Another process is the cache writer');
|
|
49
|
+
* }
|
|
50
|
+
*/
|
|
51
|
+
export declare function tryClaimCacheWriter(dataDir: string, options?: CacheWriterOptions): Promise<(() => Promise<void>) | null>;
|
|
52
|
+
/**
|
|
53
|
+
* Check if a file is currently locked.
|
|
54
|
+
* Useful for diagnostics/testing.
|
|
55
|
+
*/
|
|
56
|
+
export declare function isFileLocked(filePath: string): Promise<boolean>;
|
|
57
|
+
//# sourceMappingURL=fileLock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileLock.d.ts","sourceRoot":"","sources":["../../src/utils/fileLock.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,MAAM,WAAW,eAAe;IAC9B,qDAAqD;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAClC,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,CAAC,CAAC,CAUZ;AAED,MAAM,WAAW,kBAAkB;IACjC,gEAAgE;IAChE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAyBvC;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAMrE"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File locking utilities for coordinating access to shared data files
|
|
3
|
+
* across multiple yep-anywhere server instances.
|
|
4
|
+
*
|
|
5
|
+
* Uses proper-lockfile which:
|
|
6
|
+
* - Uses mkdir for atomic lock acquisition (works on local + network FS)
|
|
7
|
+
* - Periodically updates mtime to detect stale locks from crashed processes
|
|
8
|
+
* - Pure JS, no native dependencies
|
|
9
|
+
*/
|
|
10
|
+
import * as fs from "node:fs/promises";
|
|
11
|
+
import * as path from "node:path";
|
|
12
|
+
import lockfile from "proper-lockfile";
|
|
13
|
+
/**
|
|
14
|
+
* Execute a function while holding an exclusive lock on a file.
|
|
15
|
+
* Use this for read-modify-write operations on shared files.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* await withFileLock(metadataPath, async () => {
|
|
19
|
+
* const data = JSON.parse(await fs.readFile(metadataPath, 'utf-8'));
|
|
20
|
+
* data.starred = true;
|
|
21
|
+
* await fs.writeFile(metadataPath, JSON.stringify(data, null, 2));
|
|
22
|
+
* });
|
|
23
|
+
*/
|
|
24
|
+
export async function withFileLock(filePath, fn, options) {
|
|
25
|
+
const release = await lockfile.lock(filePath, {
|
|
26
|
+
stale: options?.stale ?? 10000,
|
|
27
|
+
retries: options?.retries ?? 3,
|
|
28
|
+
});
|
|
29
|
+
try {
|
|
30
|
+
return await fn();
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
await release();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Try to claim exclusive cache writer rights for this process.
|
|
38
|
+
* Only one process should write cache/index files to avoid conflicts.
|
|
39
|
+
*
|
|
40
|
+
* Returns a release function if lock acquired, null if another process holds it.
|
|
41
|
+
* The lock is maintained via periodic heartbeat until released or process exits.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* const release = await tryClaimCacheWriter(dataDir);
|
|
45
|
+
* if (release) {
|
|
46
|
+
* console.log('I am the cache writer');
|
|
47
|
+
* // Write cache files...
|
|
48
|
+
* // On shutdown: await release();
|
|
49
|
+
* } else {
|
|
50
|
+
* console.log('Another process is the cache writer');
|
|
51
|
+
* }
|
|
52
|
+
*/
|
|
53
|
+
export async function tryClaimCacheWriter(dataDir, options) {
|
|
54
|
+
const sentinelPath = path.join(dataDir, "cache-writer.sentinel");
|
|
55
|
+
// Ensure data dir and sentinel file exist (lockfile needs the file to exist)
|
|
56
|
+
await fs.mkdir(dataDir, { recursive: true });
|
|
57
|
+
try {
|
|
58
|
+
await fs.writeFile(sentinelPath, "", { flag: "wx" }); // create only if not exists
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
// File already exists, that's fine
|
|
62
|
+
if (e.code !== "EEXIST") {
|
|
63
|
+
throw e;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
const release = await lockfile.lock(sentinelPath, {
|
|
68
|
+
stale: options?.stale ?? 30000,
|
|
69
|
+
update: options?.update ?? 10000,
|
|
70
|
+
retries: 0, // Don't wait, fail immediately if held
|
|
71
|
+
});
|
|
72
|
+
return release;
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
// Lock held by another process (or other error - treat as "can't acquire")
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Check if a file is currently locked.
|
|
81
|
+
* Useful for diagnostics/testing.
|
|
82
|
+
*/
|
|
83
|
+
export async function isFileLocked(filePath) {
|
|
84
|
+
try {
|
|
85
|
+
return await lockfile.check(filePath);
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=fileLock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileLock.js","sourceRoot":"","sources":["../../src/utils/fileLock.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AASvC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,QAAgB,EACh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,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,QAAgB;IACjD,IAAI,CAAC;QACH,OAAO,MAAM,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BatchProcessor collects async tasks and processes them with limited concurrency.
|
|
3
|
+
*
|
|
4
|
+
* Designed to prevent memory spikes from processing many file change events simultaneously.
|
|
5
|
+
* Tasks are deduplicated by key - if the same key is enqueued multiple times before
|
|
6
|
+
* the batch flushes, only the last task runs.
|
|
7
|
+
*/
|
|
8
|
+
type Task<T> = () => Promise<T>;
|
|
9
|
+
export interface BatchProcessorOptions<T> {
|
|
10
|
+
/** Max concurrent tasks (default: 5) */
|
|
11
|
+
concurrency?: number;
|
|
12
|
+
/** Batch window in ms - wait this long to collect events before processing (default: 300) */
|
|
13
|
+
batchMs?: number;
|
|
14
|
+
/** Called for each successful result */
|
|
15
|
+
onResult?: (key: string, result: T) => void;
|
|
16
|
+
/** Called on task error */
|
|
17
|
+
onError?: (key: string, error: Error) => void;
|
|
18
|
+
}
|
|
19
|
+
export declare class BatchProcessor<T> {
|
|
20
|
+
private pending;
|
|
21
|
+
private processing;
|
|
22
|
+
private flushTimeout;
|
|
23
|
+
private concurrency;
|
|
24
|
+
private batchMs;
|
|
25
|
+
private onResult?;
|
|
26
|
+
private onError?;
|
|
27
|
+
constructor(options?: BatchProcessorOptions<T>);
|
|
28
|
+
/**
|
|
29
|
+
* Queue a task for processing.
|
|
30
|
+
* If the same key is queued again before the batch flushes, the previous task is replaced.
|
|
31
|
+
*/
|
|
32
|
+
enqueue(key: string, task: Task<T>): void;
|
|
33
|
+
/**
|
|
34
|
+
* Get the number of pending tasks waiting to be processed.
|
|
35
|
+
*/
|
|
36
|
+
get pendingCount(): number;
|
|
37
|
+
/**
|
|
38
|
+
* Check if the processor is currently processing a batch.
|
|
39
|
+
*/
|
|
40
|
+
get isProcessing(): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Force immediate processing of pending tasks.
|
|
43
|
+
* Useful for testing or shutdown scenarios.
|
|
44
|
+
*/
|
|
45
|
+
flush(): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Cancel all pending tasks and clear the queue.
|
|
48
|
+
*/
|
|
49
|
+
clear(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Dispose of the processor, clearing all pending tasks.
|
|
52
|
+
*/
|
|
53
|
+
dispose(): void;
|
|
54
|
+
private scheduleFlush;
|
|
55
|
+
private processBatch;
|
|
56
|
+
}
|
|
57
|
+
export {};
|
|
58
|
+
//# sourceMappingURL=BatchProcessor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BatchProcessor.d.ts","sourceRoot":"","sources":["../../src/watcher/BatchProcessor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,KAAK,IAAI,CAAC,CAAC,IAAI,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC;AAEhC,MAAM,WAAW,qBAAqB,CAAC,CAAC;IACtC,wCAAwC;IACxC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6FAA6F;IAC7F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,KAAK,IAAI,CAAC;IAC5C,2BAA2B;IAC3B,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAC/C;AAED,qBAAa,cAAc,CAAC,CAAC;IAC3B,OAAO,CAAC,OAAO,CAAmC;IAClD,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,YAAY,CAA+B;IACnD,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAC,CAAmC;IACpD,OAAO,CAAC,OAAO,CAAC,CAAsC;gBAE1C,OAAO,GAAE,qBAAqB,CAAC,CAAC,CAAM;IAOlD;;;OAGG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI;IAKzC;;OAEG;IACH,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED;;OAEG;IACH,IAAI,YAAY,IAAI,OAAO,CAE1B;IAED;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ5B;;OAEG;IACH,KAAK,IAAI,IAAI;IAQb;;OAEG;IACH,OAAO,IAAI,IAAI;IAIf,OAAO,CAAC,aAAa;YASP,YAAY;CAgC3B"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BatchProcessor collects async tasks and processes them with limited concurrency.
|
|
3
|
+
*
|
|
4
|
+
* Designed to prevent memory spikes from processing many file change events simultaneously.
|
|
5
|
+
* Tasks are deduplicated by key - if the same key is enqueued multiple times before
|
|
6
|
+
* the batch flushes, only the last task runs.
|
|
7
|
+
*/
|
|
8
|
+
export class BatchProcessor {
|
|
9
|
+
pending = new Map();
|
|
10
|
+
processing = false;
|
|
11
|
+
flushTimeout = null;
|
|
12
|
+
concurrency;
|
|
13
|
+
batchMs;
|
|
14
|
+
onResult;
|
|
15
|
+
onError;
|
|
16
|
+
constructor(options = {}) {
|
|
17
|
+
this.concurrency = options.concurrency ?? 5;
|
|
18
|
+
this.batchMs = options.batchMs ?? 300;
|
|
19
|
+
this.onResult = options.onResult;
|
|
20
|
+
this.onError = options.onError;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Queue a task for processing.
|
|
24
|
+
* If the same key is queued again before the batch flushes, the previous task is replaced.
|
|
25
|
+
*/
|
|
26
|
+
enqueue(key, task) {
|
|
27
|
+
this.pending.set(key, task);
|
|
28
|
+
this.scheduleFlush();
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get the number of pending tasks waiting to be processed.
|
|
32
|
+
*/
|
|
33
|
+
get pendingCount() {
|
|
34
|
+
return this.pending.size;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Check if the processor is currently processing a batch.
|
|
38
|
+
*/
|
|
39
|
+
get isProcessing() {
|
|
40
|
+
return this.processing;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Force immediate processing of pending tasks.
|
|
44
|
+
* Useful for testing or shutdown scenarios.
|
|
45
|
+
*/
|
|
46
|
+
async flush() {
|
|
47
|
+
if (this.flushTimeout) {
|
|
48
|
+
clearTimeout(this.flushTimeout);
|
|
49
|
+
this.flushTimeout = null;
|
|
50
|
+
}
|
|
51
|
+
await this.processBatch();
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Cancel all pending tasks and clear the queue.
|
|
55
|
+
*/
|
|
56
|
+
clear() {
|
|
57
|
+
if (this.flushTimeout) {
|
|
58
|
+
clearTimeout(this.flushTimeout);
|
|
59
|
+
this.flushTimeout = null;
|
|
60
|
+
}
|
|
61
|
+
this.pending.clear();
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Dispose of the processor, clearing all pending tasks.
|
|
65
|
+
*/
|
|
66
|
+
dispose() {
|
|
67
|
+
this.clear();
|
|
68
|
+
}
|
|
69
|
+
scheduleFlush() {
|
|
70
|
+
if (this.flushTimeout)
|
|
71
|
+
return;
|
|
72
|
+
this.flushTimeout = setTimeout(() => {
|
|
73
|
+
this.flushTimeout = null;
|
|
74
|
+
this.processBatch();
|
|
75
|
+
}, this.batchMs);
|
|
76
|
+
}
|
|
77
|
+
async processBatch() {
|
|
78
|
+
if (this.processing || this.pending.size === 0)
|
|
79
|
+
return;
|
|
80
|
+
this.processing = true;
|
|
81
|
+
// Grab current batch and clear pending
|
|
82
|
+
const batch = new Map(this.pending);
|
|
83
|
+
this.pending.clear();
|
|
84
|
+
const entries = Array.from(batch.entries());
|
|
85
|
+
// Process in chunks of `concurrency` size
|
|
86
|
+
for (let i = 0; i < entries.length; i += this.concurrency) {
|
|
87
|
+
const chunk = entries.slice(i, i + this.concurrency);
|
|
88
|
+
await Promise.all(chunk.map(async ([key, task]) => {
|
|
89
|
+
try {
|
|
90
|
+
const result = await task();
|
|
91
|
+
this.onResult?.(key, result);
|
|
92
|
+
}
|
|
93
|
+
catch (err) {
|
|
94
|
+
this.onError?.(key, err);
|
|
95
|
+
}
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
this.processing = false;
|
|
99
|
+
// If more events arrived during processing, schedule another flush
|
|
100
|
+
if (this.pending.size > 0) {
|
|
101
|
+
this.scheduleFlush();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=BatchProcessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BatchProcessor.js","sourceRoot":"","sources":["../../src/watcher/BatchProcessor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAeH,MAAM,OAAO,cAAc;IACjB,OAAO,GAAyB,IAAI,GAAG,EAAE,CAAC;IAC1C,UAAU,GAAG,KAAK,CAAC;IACnB,YAAY,GAA0B,IAAI,CAAC;IAC3C,WAAW,CAAS;IACpB,OAAO,CAAS;IAChB,QAAQ,CAAoC;IAC5C,OAAO,CAAuC;IAEtD,YAAY,UAAoC,EAAE;QAChD,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,CAAC,CAAC;QAC5C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,GAAG,CAAC;QACtC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IACjC,CAAC;IAED;;;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