@superblocksteam/vite-plugin-file-sync 2.0.123 → 2.0.124-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-service/agent/prompts/build-base-system-prompt.d.ts +16 -1
- package/dist/ai-service/agent/prompts/build-base-system-prompt.d.ts.map +1 -1
- package/dist/ai-service/agent/prompts/build-base-system-prompt.js +32 -1
- package/dist/ai-service/agent/prompts/build-base-system-prompt.js.map +1 -1
- package/dist/ai-service/agent/prompts/build-security-scan-prompt.d.ts.map +1 -1
- package/dist/ai-service/agent/prompts/build-security-scan-prompt.js +3 -1
- package/dist/ai-service/agent/prompts/build-security-scan-prompt.js.map +1 -1
- package/dist/ai-service/agent/tools/apis/api-comparator.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/apis/api-comparator.js +1 -4
- package/dist/ai-service/agent/tools/apis/api-comparator.js.map +1 -1
- package/dist/ai-service/agent/tools/apis/api-testing-state.js +7 -0
- package/dist/ai-service/agent/tools/apis/api-testing-state.js.map +1 -1
- package/dist/ai-service/agent/tools/apis/get-api-docs.d.ts +1 -1
- package/dist/ai-service/agent/tools/apis/write-api.d.ts +2 -2
- package/dist/ai-service/agent/tools/build-capture-screenshot.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-capture-screenshot.js +11 -33
- package/dist/ai-service/agent/tools/build-capture-screenshot.js.map +1 -1
- package/dist/ai-service/agent/tools/build-copy-directory.d.ts +1 -1
- package/dist/ai-service/agent/tools/build-finalize.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-finalize.js +11 -2
- package/dist/ai-service/agent/tools/build-finalize.js.map +1 -1
- package/dist/ai-service/agent/tools/build-install-packages.d.ts +41 -1
- package/dist/ai-service/agent/tools/build-install-packages.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-install-packages.js +217 -0
- package/dist/ai-service/agent/tools/build-install-packages.js.map +1 -1
- package/dist/ai-service/agent/tools/build-lookup-npm-package.d.ts +28 -0
- package/dist/ai-service/agent/tools/build-lookup-npm-package.d.ts.map +1 -0
- package/dist/ai-service/agent/tools/build-lookup-npm-package.js +78 -0
- package/dist/ai-service/agent/tools/build-lookup-npm-package.js.map +1 -0
- package/dist/ai-service/agent/tools/build-manage-checklist.d.ts +4 -4
- package/dist/ai-service/agent/tools/build-navigate-preview.d.ts +16 -0
- package/dist/ai-service/agent/tools/build-navigate-preview.d.ts.map +1 -0
- package/dist/ai-service/agent/tools/build-navigate-preview.js +68 -0
- package/dist/ai-service/agent/tools/build-navigate-preview.js.map +1 -0
- package/dist/ai-service/agent/tools/build-write-file.d.ts +1 -1
- package/dist/ai-service/agent/tools/databases/dev-database.d.ts +9 -9
- package/dist/ai-service/agent/tools/index.d.ts +2 -0
- package/dist/ai-service/agent/tools/index.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/index.js +2 -0
- package/dist/ai-service/agent/tools/index.js.map +1 -1
- package/dist/ai-service/agent/tools/integrations/execute-request.d.ts +3 -3
- package/dist/ai-service/agent/tools/report-security-findings.d.ts +11 -5
- package/dist/ai-service/agent/tools/report-security-findings.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/report-security-findings.js +1 -0
- package/dist/ai-service/agent/tools/report-security-findings.js.map +1 -1
- package/dist/ai-service/agent/tools.d.ts.map +1 -1
- package/dist/ai-service/agent/tools.js +3 -1
- package/dist/ai-service/agent/tools.js.map +1 -1
- package/dist/ai-service/agent/tools2/tools/git.d.ts +2 -2
- package/dist/ai-service/agent/tools2/tools/grep.d.ts +2 -2
- package/dist/ai-service/agent/tools2/tools/update-test-case-status.d.ts +2 -2
- package/dist/ai-service/app-interface/npm-error-parser.d.ts +161 -0
- package/dist/ai-service/app-interface/npm-error-parser.d.ts.map +1 -0
- package/dist/ai-service/app-interface/npm-error-parser.js +510 -0
- package/dist/ai-service/app-interface/npm-error-parser.js.map +1 -0
- package/dist/ai-service/app-interface/npm-package-lookup.d.ts +286 -0
- package/dist/ai-service/app-interface/npm-package-lookup.d.ts.map +1 -0
- package/dist/ai-service/app-interface/npm-package-lookup.js +793 -0
- package/dist/ai-service/app-interface/npm-package-lookup.js.map +1 -0
- package/dist/ai-service/app-interface/npm-registry.d.ts +735 -47
- package/dist/ai-service/app-interface/npm-registry.d.ts.map +1 -1
- package/dist/ai-service/app-interface/npm-registry.js +1882 -153
- package/dist/ai-service/app-interface/npm-registry.js.map +1 -1
- package/dist/ai-service/app-interface/shell.d.ts +118 -1
- package/dist/ai-service/app-interface/shell.d.ts.map +1 -1
- package/dist/ai-service/app-interface/shell.js +590 -157
- package/dist/ai-service/app-interface/shell.js.map +1 -1
- package/dist/ai-service/app-skills/manager.d.ts +1 -1
- package/dist/ai-service/app-skills/manager.d.ts.map +1 -1
- package/dist/ai-service/app-skills/manager.js +39 -7
- package/dist/ai-service/app-skills/manager.js.map +1 -1
- package/dist/ai-service/checklist/api-migration-checklist-gate.d.ts +9 -0
- package/dist/ai-service/checklist/api-migration-checklist-gate.d.ts.map +1 -0
- package/dist/ai-service/checklist/api-migration-checklist-gate.js +30 -0
- package/dist/ai-service/checklist/api-migration-checklist-gate.js.map +1 -0
- package/dist/ai-service/checklist/api-migration-origins.d.ts +4 -0
- package/dist/ai-service/checklist/api-migration-origins.d.ts.map +1 -0
- package/dist/ai-service/checklist/api-migration-origins.js +8 -0
- package/dist/ai-service/checklist/api-migration-origins.js.map +1 -0
- package/dist/ai-service/checklist/persisted-checklist-store.d.ts +2 -3
- package/dist/ai-service/checklist/persisted-checklist-store.d.ts.map +1 -1
- package/dist/ai-service/checklist/persisted-checklist-store.js +6 -7
- package/dist/ai-service/checklist/persisted-checklist-store.js.map +1 -1
- package/dist/ai-service/context-archive-paths.d.ts +4 -0
- package/dist/ai-service/context-archive-paths.d.ts.map +1 -0
- package/dist/ai-service/context-archive-paths.js +28 -0
- package/dist/ai-service/context-archive-paths.js.map +1 -0
- package/dist/ai-service/context-download.d.ts +3 -1
- package/dist/ai-service/context-download.d.ts.map +1 -1
- package/dist/ai-service/context-download.js +48 -9
- package/dist/ai-service/context-download.js.map +1 -1
- package/dist/ai-service/context-upload.d.ts +3 -2
- package/dist/ai-service/context-upload.d.ts.map +1 -1
- package/dist/ai-service/context-upload.js +44 -26
- package/dist/ai-service/context-upload.js.map +1 -1
- package/dist/ai-service/dev-database-client.d.ts +3 -11
- package/dist/ai-service/dev-database-client.d.ts.map +1 -1
- package/dist/ai-service/dev-database-client.js.map +1 -1
- package/dist/ai-service/features.d.ts +4 -0
- package/dist/ai-service/features.d.ts.map +1 -1
- package/dist/ai-service/features.js +8 -0
- package/dist/ai-service/features.js.map +1 -1
- package/dist/ai-service/filter-disabled-tools-for-migration.d.ts.map +1 -1
- package/dist/ai-service/filter-disabled-tools-for-migration.js +4 -0
- package/dist/ai-service/filter-disabled-tools-for-migration.js.map +1 -1
- package/dist/ai-service/index.d.ts +103 -0
- package/dist/ai-service/index.d.ts.map +1 -1
- package/dist/ai-service/index.js +610 -25
- package/dist/ai-service/index.js.map +1 -1
- package/dist/ai-service/llm/client.d.ts +38 -3
- package/dist/ai-service/llm/client.d.ts.map +1 -1
- package/dist/ai-service/llm/client.js +73 -22
- package/dist/ai-service/llm/client.js.map +1 -1
- package/dist/ai-service/llm/context-v2/adapter.d.ts +3 -1
- package/dist/ai-service/llm/context-v2/adapter.d.ts.map +1 -1
- package/dist/ai-service/llm/context-v2/adapter.js +11 -11
- package/dist/ai-service/llm/context-v2/adapter.js.map +1 -1
- package/dist/ai-service/llm/context-v2/compaction/client-side.d.ts +44 -0
- package/dist/ai-service/llm/context-v2/compaction/client-side.d.ts.map +1 -0
- package/dist/ai-service/llm/context-v2/compaction/client-side.js +170 -0
- package/dist/ai-service/llm/context-v2/compaction/client-side.js.map +1 -0
- package/dist/ai-service/llm/context-v2/compaction/compaction-strategy.d.ts +56 -0
- package/dist/ai-service/llm/context-v2/compaction/compaction-strategy.d.ts.map +1 -0
- package/dist/ai-service/llm/context-v2/compaction/compaction-strategy.js +9 -0
- package/dist/ai-service/llm/context-v2/compaction/compaction-strategy.js.map +1 -0
- package/dist/ai-service/llm/context-v2/compaction/index.d.ts +5 -0
- package/dist/ai-service/llm/context-v2/compaction/index.d.ts.map +1 -0
- package/dist/ai-service/llm/context-v2/compaction/index.js +3 -0
- package/dist/ai-service/llm/context-v2/compaction/index.js.map +1 -0
- package/dist/ai-service/llm/context-v2/compaction/server-side.d.ts +30 -0
- package/dist/ai-service/llm/context-v2/compaction/server-side.d.ts.map +1 -0
- package/dist/ai-service/llm/context-v2/compaction/server-side.js +130 -0
- package/dist/ai-service/llm/context-v2/compaction/server-side.js.map +1 -0
- package/dist/ai-service/llm/context-v2/context-management.d.ts +203 -0
- package/dist/ai-service/llm/context-v2/context-management.d.ts.map +1 -0
- package/dist/ai-service/llm/context-v2/context-management.js +183 -0
- package/dist/ai-service/llm/context-v2/context-management.js.map +1 -0
- package/dist/ai-service/llm/context-v2/context.d.ts +64 -22
- package/dist/ai-service/llm/context-v2/context.d.ts.map +1 -1
- package/dist/ai-service/llm/context-v2/context.js +233 -157
- package/dist/ai-service/llm/context-v2/context.js.map +1 -1
- package/dist/ai-service/llm/context-v2/conversation-context.d.ts +24 -7
- package/dist/ai-service/llm/context-v2/conversation-context.d.ts.map +1 -1
- package/dist/ai-service/llm/context-v2/conversation-context.js +1 -1
- package/dist/ai-service/llm/context-v2/index.d.ts +0 -4
- package/dist/ai-service/llm/context-v2/index.d.ts.map +1 -1
- package/dist/ai-service/llm/context-v2/index.js +0 -4
- package/dist/ai-service/llm/context-v2/index.js.map +1 -1
- package/dist/ai-service/llm/context-v2/manager.d.ts +24 -3
- package/dist/ai-service/llm/context-v2/manager.d.ts.map +1 -1
- package/dist/ai-service/llm/context-v2/manager.js +146 -4
- package/dist/ai-service/llm/context-v2/manager.js.map +1 -1
- package/dist/ai-service/llm/context-v2/migrations/v1-to-v2.d.ts +2 -7
- package/dist/ai-service/llm/context-v2/migrations/v1-to-v2.d.ts.map +1 -1
- package/dist/ai-service/llm/context-v2/migrations/v1-to-v2.js +5 -73
- package/dist/ai-service/llm/context-v2/migrations/v1-to-v2.js.map +1 -1
- package/dist/ai-service/llm/context-v2/storage/event-store.d.ts +57 -0
- package/dist/ai-service/llm/context-v2/storage/event-store.d.ts.map +1 -0
- package/dist/ai-service/llm/context-v2/storage/event-store.js +10 -0
- package/dist/ai-service/llm/context-v2/storage/event-store.js.map +1 -0
- package/dist/ai-service/llm/context-v2/storage/event-types.d.ts +50 -0
- package/dist/ai-service/llm/context-v2/storage/event-types.d.ts.map +1 -0
- package/dist/ai-service/llm/context-v2/storage/event-types.js +10 -0
- package/dist/ai-service/llm/context-v2/storage/event-types.js.map +1 -0
- package/dist/ai-service/llm/context-v2/storage/jsonl-event-store.d.ts +87 -0
- package/dist/ai-service/llm/context-v2/storage/jsonl-event-store.d.ts.map +1 -0
- package/dist/ai-service/llm/context-v2/storage/jsonl-event-store.js +184 -0
- package/dist/ai-service/llm/context-v2/storage/jsonl-event-store.js.map +1 -0
- package/dist/ai-service/llm/context-v2/storage/migration.d.ts +49 -0
- package/dist/ai-service/llm/context-v2/storage/migration.d.ts.map +1 -0
- package/dist/ai-service/llm/context-v2/storage/migration.js +126 -0
- package/dist/ai-service/llm/context-v2/storage/migration.js.map +1 -0
- package/dist/ai-service/llm/context-v2/types.d.ts +16 -11
- package/dist/ai-service/llm/context-v2/types.d.ts.map +1 -1
- package/dist/ai-service/llm/context-v2/types.js +2 -2
- package/dist/ai-service/llm/context-v2/types.js.map +1 -1
- package/dist/ai-service/llm/impl/clark.d.ts +8 -0
- package/dist/ai-service/llm/impl/clark.d.ts.map +1 -1
- package/dist/ai-service/llm/impl/clark.js +8 -0
- package/dist/ai-service/llm/impl/clark.js.map +1 -1
- package/dist/ai-service/llm/interaction/adapters/vercel.d.ts.map +1 -1
- package/dist/ai-service/llm/interaction/adapters/vercel.js +17 -1
- package/dist/ai-service/llm/interaction/adapters/vercel.js.map +1 -1
- package/dist/ai-service/llm/provider.d.ts.map +1 -1
- package/dist/ai-service/llm/provider.js +1 -3
- package/dist/ai-service/llm/provider.js.map +1 -1
- package/dist/ai-service/llm/stream/observers/context.d.ts +23 -0
- package/dist/ai-service/llm/stream/observers/context.d.ts.map +1 -1
- package/dist/ai-service/llm/stream/observers/context.js +62 -0
- package/dist/ai-service/llm/stream/observers/context.js.map +1 -1
- package/dist/ai-service/llm/tool-context-integrity.d.ts +25 -0
- package/dist/ai-service/llm/tool-context-integrity.d.ts.map +1 -0
- package/dist/ai-service/llm/tool-context-integrity.js +141 -0
- package/dist/ai-service/llm/tool-context-integrity.js.map +1 -0
- package/dist/ai-service/skills/system/superblocks-migration/skill.generated.d.ts +1 -1
- package/dist/ai-service/skills/system/superblocks-migration/skill.generated.d.ts.map +1 -1
- package/dist/ai-service/skills/system/superblocks-migration/skill.generated.js +6 -1
- package/dist/ai-service/skills/system/superblocks-migration/skill.generated.js.map +1 -1
- package/dist/ai-service/skills/system/third-party-migration/skill.generated.d.ts +1 -1
- package/dist/ai-service/skills/system/third-party-migration/skill.generated.d.ts.map +1 -1
- package/dist/ai-service/skills/system/third-party-migration/skill.generated.js +3 -2
- package/dist/ai-service/skills/system/third-party-migration/skill.generated.js.map +1 -1
- package/dist/ai-service/state-machine/clark-fsm.d.ts +23 -2
- package/dist/ai-service/state-machine/clark-fsm.d.ts.map +1 -1
- package/dist/ai-service/state-machine/clark-fsm.js +37 -2
- package/dist/ai-service/state-machine/clark-fsm.js.map +1 -1
- package/dist/ai-service/state-machine/handlers/agent-planning.d.ts.map +1 -1
- package/dist/ai-service/state-machine/handlers/agent-planning.js +29 -2
- package/dist/ai-service/state-machine/handlers/agent-planning.js.map +1 -1
- package/dist/ai-service/state-machine/handlers/awaiting-user.d.ts.map +1 -1
- package/dist/ai-service/state-machine/handlers/awaiting-user.js +9 -0
- package/dist/ai-service/state-machine/handlers/awaiting-user.js.map +1 -1
- package/dist/ai-service/state-machine/handlers/llm-generating.d.ts.map +1 -1
- package/dist/ai-service/state-machine/handlers/llm-generating.js +25 -2
- package/dist/ai-service/state-machine/handlers/llm-generating.js.map +1 -1
- package/dist/ai-service/state-machine/helpers/fetch-with-reconnect-retry.d.ts +6 -0
- package/dist/ai-service/state-machine/helpers/fetch-with-reconnect-retry.d.ts.map +1 -0
- package/dist/ai-service/state-machine/helpers/fetch-with-reconnect-retry.js +36 -0
- package/dist/ai-service/state-machine/helpers/fetch-with-reconnect-retry.js.map +1 -0
- package/dist/ai-service/state-machine/helpers/stable-peer.d.ts +30 -1
- package/dist/ai-service/state-machine/helpers/stable-peer.d.ts.map +1 -1
- package/dist/ai-service/state-machine/helpers/stable-peer.js +85 -2
- package/dist/ai-service/state-machine/helpers/stable-peer.js.map +1 -1
- package/dist/ai-service/state-machine/helpers/user-preferences.d.ts +8 -0
- package/dist/ai-service/state-machine/helpers/user-preferences.d.ts.map +1 -0
- package/dist/ai-service/state-machine/helpers/user-preferences.js +11 -0
- package/dist/ai-service/state-machine/helpers/user-preferences.js.map +1 -0
- package/dist/ai-service/template-renderer.d.ts +18 -1
- package/dist/ai-service/template-renderer.d.ts.map +1 -1
- package/dist/ai-service/template-renderer.js +85 -20
- package/dist/ai-service/template-renderer.js.map +1 -1
- package/dist/ai-service/types.d.ts +157 -0
- package/dist/ai-service/types.d.ts.map +1 -1
- package/dist/ai-service/types.js +137 -0
- package/dist/ai-service/types.js.map +1 -1
- package/dist/ai-service/util/llm-config-utils.d.ts +21 -22
- package/dist/ai-service/util/llm-config-utils.d.ts.map +1 -1
- package/dist/ai-service/util/llm-config-utils.js +40 -67
- package/dist/ai-service/util/llm-config-utils.js.map +1 -1
- package/dist/file-sync-vite-plugin.d.ts.map +1 -1
- package/dist/file-sync-vite-plugin.js +5 -0
- package/dist/file-sync-vite-plugin.js.map +1 -1
- package/dist/file-system-helpers.d.ts +17 -0
- package/dist/file-system-helpers.d.ts.map +1 -1
- package/dist/file-system-helpers.js +22 -0
- package/dist/file-system-helpers.js.map +1 -1
- package/dist/git-service/index.d.ts.map +1 -1
- package/dist/git-service/index.js +15 -1
- package/dist/git-service/index.js.map +1 -1
- package/dist/migration/migration-routes.d.ts.map +1 -1
- package/dist/migration/migration-routes.js +26 -3
- package/dist/migration/migration-routes.js.map +1 -1
- package/dist/migration/translation-prompt.d.ts.map +1 -1
- package/dist/migration/translation-prompt.js +5 -0
- package/dist/migration/translation-prompt.js.map +1 -1
- package/dist/migration-templates/app-fullstack/package.json +2 -2
- package/dist/policy-gate-callback-mapper.d.ts +24 -0
- package/dist/policy-gate-callback-mapper.d.ts.map +1 -0
- package/dist/policy-gate-callback-mapper.js +61 -0
- package/dist/policy-gate-callback-mapper.js.map +1 -0
- package/dist/policy-gate-runner.d.ts +32 -0
- package/dist/policy-gate-runner.d.ts.map +1 -0
- package/dist/policy-gate-runner.js +191 -0
- package/dist/policy-gate-runner.js.map +1 -0
- package/dist/router-parser.d.ts.map +1 -1
- package/dist/router-parser.js +107 -11
- package/dist/router-parser.js.map +1 -1
- package/dist/sync-service/list-dir.d.ts.map +1 -1
- package/dist/sync-service/list-dir.js +13 -3
- package/dist/sync-service/list-dir.js.map +1 -1
- package/package.json +28 -10
|
@@ -7,9 +7,8 @@
|
|
|
7
7
|
* - toolSummariesById at top level
|
|
8
8
|
*
|
|
9
9
|
* V2 format has:
|
|
10
|
-
* - version: 2, messages
|
|
10
|
+
* - version: 2, messages
|
|
11
11
|
* - StoredMessage format with _superblocks metadata
|
|
12
|
-
* - toolSummaries stored on individual messages
|
|
13
12
|
*/
|
|
14
13
|
function toStoredMessage(msg) {
|
|
15
14
|
const { tokenCount, timestamp, hasBreakPoint, ...rest } = msg;
|
|
@@ -21,65 +20,6 @@ function toStoredMessage(msg) {
|
|
|
21
20
|
},
|
|
22
21
|
};
|
|
23
22
|
}
|
|
24
|
-
/**
|
|
25
|
-
* Convert a message and attach any relevant tool summaries.
|
|
26
|
-
* - For assistant messages: attach input summaries for tool-calls
|
|
27
|
-
* - For tool messages: attach output summaries for tool-results
|
|
28
|
-
*/
|
|
29
|
-
function toStoredMessageWithSummaries(msg, toolSummariesById) {
|
|
30
|
-
const stored = toStoredMessage(msg);
|
|
31
|
-
if (!toolSummariesById) {
|
|
32
|
-
return stored;
|
|
33
|
-
}
|
|
34
|
-
// Extract tool call/result IDs from message content
|
|
35
|
-
if (msg.role === "assistant" && Array.isArray(msg.content)) {
|
|
36
|
-
const inputSummaries = {};
|
|
37
|
-
for (const part of msg.content) {
|
|
38
|
-
if (typeof part === "object" &&
|
|
39
|
-
part !== null &&
|
|
40
|
-
"type" in part &&
|
|
41
|
-
part.type === "tool-call" &&
|
|
42
|
-
"toolCallId" in part) {
|
|
43
|
-
const toolCallId = part.toolCallId;
|
|
44
|
-
const summary = toolSummariesById[toolCallId];
|
|
45
|
-
if (summary?.input) {
|
|
46
|
-
inputSummaries[toolCallId] = summary.input;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
if (Object.keys(inputSummaries).length > 0) {
|
|
51
|
-
stored._superblocks = {
|
|
52
|
-
...stored._superblocks,
|
|
53
|
-
timestamp: stored._superblocks?.timestamp ?? Date.now(),
|
|
54
|
-
toolSummaries: inputSummaries,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
else if (msg.role === "tool" && Array.isArray(msg.content)) {
|
|
59
|
-
const outputSummaries = {};
|
|
60
|
-
for (const part of msg.content) {
|
|
61
|
-
if (typeof part === "object" &&
|
|
62
|
-
part !== null &&
|
|
63
|
-
"type" in part &&
|
|
64
|
-
part.type === "tool-result" &&
|
|
65
|
-
"toolCallId" in part) {
|
|
66
|
-
const toolCallId = part.toolCallId;
|
|
67
|
-
const summary = toolSummariesById[toolCallId];
|
|
68
|
-
if (summary?.output) {
|
|
69
|
-
outputSummaries[toolCallId] = summary.output;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
if (Object.keys(outputSummaries).length > 0) {
|
|
74
|
-
stored._superblocks = {
|
|
75
|
-
...stored._superblocks,
|
|
76
|
-
timestamp: stored._superblocks?.timestamp ?? Date.now(),
|
|
77
|
-
toolSummaries: outputSummaries,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return stored;
|
|
82
|
-
}
|
|
83
23
|
function flattenL3Turn(turn) {
|
|
84
24
|
const messages = [toStoredMessage(turn.user)];
|
|
85
25
|
if (turn.assistant) {
|
|
@@ -94,12 +34,11 @@ function flattenL2Turn(turn) {
|
|
|
94
34
|
}
|
|
95
35
|
return messages;
|
|
96
36
|
}
|
|
97
|
-
function flattenL1Turn(turn
|
|
37
|
+
function flattenL1Turn(turn) {
|
|
98
38
|
const messages = [toStoredMessage(turn.user)];
|
|
99
39
|
for (const step of turn.steps) {
|
|
100
40
|
for (const response of step) {
|
|
101
|
-
|
|
102
|
-
messages.push(toStoredMessageWithSummaries(response, toolSummariesById));
|
|
41
|
+
messages.push(toStoredMessage(response));
|
|
103
42
|
}
|
|
104
43
|
}
|
|
105
44
|
return messages;
|
|
@@ -107,27 +46,20 @@ function flattenL1Turn(turn, toolSummariesById) {
|
|
|
107
46
|
/**
|
|
108
47
|
* Migrate a V1 context record to V2 format.
|
|
109
48
|
*
|
|
110
|
-
* Flattens all turns from oldest to newest (l3
|
|
49
|
+
* Flattens all turns from oldest to newest (l3 -> l2 -> l1) into a single
|
|
111
50
|
* messages array. Does not extract system prompt - the new system prompt
|
|
112
51
|
* will be set when the context is used.
|
|
113
|
-
*
|
|
114
|
-
* Tool summaries from V1 are migrated to message-level storage:
|
|
115
|
-
* - L2/L3 turns are already compacted, so they don't need summaries
|
|
116
|
-
* - L1 turns are un-compacted, so summaries are attached to messages
|
|
117
52
|
*/
|
|
118
53
|
export function migrateV1ToV2(record) {
|
|
119
54
|
const messages = [];
|
|
120
|
-
const { toolSummariesById } = record;
|
|
121
|
-
// L3 and L2 turns are already compacted - no summaries needed
|
|
122
55
|
for (const turn of record.l3Turns) {
|
|
123
56
|
messages.push(...flattenL3Turn(turn));
|
|
124
57
|
}
|
|
125
58
|
for (const turn of record.l2Turns) {
|
|
126
59
|
messages.push(...flattenL2Turn(turn));
|
|
127
60
|
}
|
|
128
|
-
// L1 turns are un-compacted - attach summaries for future compaction
|
|
129
61
|
for (const turn of record.l1Turns) {
|
|
130
|
-
messages.push(...flattenL1Turn(turn
|
|
62
|
+
messages.push(...flattenL1Turn(turn));
|
|
131
63
|
}
|
|
132
64
|
return {
|
|
133
65
|
version: 2,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v1-to-v2.js","sourceRoot":"","sources":["../../../../../src/ai-service/llm/context-v2/migrations/v1-to-v2.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"v1-to-v2.js","sourceRoot":"","sources":["../../../../../src/ai-service/llm/context-v2/migrations/v1-to-v2.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAaH,SAAS,eAAe,CAAC,GAAqB;IAC5C,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,IAAI,EAAE,GAAG,GAAG,CAAC;IAC9D,OAAO;QACL,GAAG,IAAI;QACP,YAAY,EAAE;YACZ,UAAU;YACV,SAAS,EAAE,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE;SACnC;KACe,CAAC;AACrB,CAAC;AAED,SAAS,aAAa,CAAC,IAAkB;IACvC,MAAM,QAAQ,GAAoB,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/D,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;QACnB,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,aAAa,CAAC,IAAkB;IACvC,MAAM,QAAQ,GAAoB,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/D,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,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vB,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EventStore interface for append-only event log storage.
|
|
3
|
+
*
|
|
4
|
+
* Defines the contract for persisting conversation events and
|
|
5
|
+
* reconstructing conversation history from the event log. The
|
|
6
|
+
* primary implementation is `JsonlEventStore`, which stores events
|
|
7
|
+
* as newline-delimited JSON in per-context `.jsonl` files.
|
|
8
|
+
*/
|
|
9
|
+
import type { ContextId, StoredMessage } from "../types.js";
|
|
10
|
+
import type { EventLogEntry } from "./event-types.js";
|
|
11
|
+
/**
|
|
12
|
+
* Append-only event log store for conversation history.
|
|
13
|
+
*
|
|
14
|
+
* Events are written one at a time via `appendEvent`. Message history
|
|
15
|
+
* is reconstructed via `loadMessages`, which scans backward for the
|
|
16
|
+
* last compaction event and reads forward from that point.
|
|
17
|
+
*
|
|
18
|
+
* All operations are keyed by the full {@link ContextId} so that
|
|
19
|
+
* different `{appId, userId, name}` tuples produce isolated logs.
|
|
20
|
+
* Keying by `appId` alone would let one user's history surface in
|
|
21
|
+
* another user's context within the same Superblocks app.
|
|
22
|
+
*/
|
|
23
|
+
export interface EventStore {
|
|
24
|
+
/**
|
|
25
|
+
* Append a single event to the log for the given context.
|
|
26
|
+
*
|
|
27
|
+
* Writes are atomic at the line level -- each call appends exactly
|
|
28
|
+
* one JSON line to the underlying storage.
|
|
29
|
+
*/
|
|
30
|
+
appendEvent(id: ContextId, event: EventLogEntry): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Load conversation messages by scanning backward for the last
|
|
33
|
+
* compaction event, then reading forward from that point.
|
|
34
|
+
*
|
|
35
|
+
* Returns `StoredMessage[]` (not raw events) because consumers need
|
|
36
|
+
* the AI SDK `ModelMessage` shape with `_superblocks` metadata. If
|
|
37
|
+
* no compaction event exists, all events are included. If the file
|
|
38
|
+
* does not exist or is empty, returns an empty array.
|
|
39
|
+
*/
|
|
40
|
+
loadMessages(id: ContextId): Promise<StoredMessage[]>;
|
|
41
|
+
/**
|
|
42
|
+
* Check whether any events exist for the given context.
|
|
43
|
+
*/
|
|
44
|
+
hasEvents(id: ContextId): Promise<boolean>;
|
|
45
|
+
/**
|
|
46
|
+
* Remove the event log for a single context. Idempotent: returns
|
|
47
|
+
* normally when no log exists.
|
|
48
|
+
*/
|
|
49
|
+
deleteEvents(id: ContextId): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Remove the entire event log tree on this store. Used by
|
|
52
|
+
* "new chat"/clear-all flows so prior conversations cannot be
|
|
53
|
+
* silently reloaded from disk.
|
|
54
|
+
*/
|
|
55
|
+
deleteAllEvents(): Promise<void>;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=event-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-store.d.ts","sourceRoot":"","sources":["../../../../../src/ai-service/llm/context-v2/storage/event-store.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEhE;;;;;;;;OAQG;IACH,YAAY,CAAC,EAAE,EAAE,SAAS,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;IAEtD;;OAEG;IACH,SAAS,CAAC,EAAE,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAE3C;;;OAGG;IACH,YAAY,CAAC,EAAE,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3C;;;;OAIG;IACH,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAClC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EventStore interface for append-only event log storage.
|
|
3
|
+
*
|
|
4
|
+
* Defines the contract for persisting conversation events and
|
|
5
|
+
* reconstructing conversation history from the event log. The
|
|
6
|
+
* primary implementation is `JsonlEventStore`, which stores events
|
|
7
|
+
* as newline-delimited JSON in per-context `.jsonl` files.
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=event-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-store.js","sourceRoot":"","sources":["../../../../../src/ai-service/llm/context-v2/storage/event-store.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event type definitions for the JSONL event log.
|
|
3
|
+
*
|
|
4
|
+
* Events are appended to per-app JSONL files as an append-only log.
|
|
5
|
+
* Each line represents a single event (prompt sent, response received,
|
|
6
|
+
* or compaction received). The event log replaces full-context JSON
|
|
7
|
+
* blob storage with an incremental, corruption-tolerant format.
|
|
8
|
+
*/
|
|
9
|
+
import type { SuperblocksMetadata } from "../types.js";
|
|
10
|
+
/**
|
|
11
|
+
* Discriminator for event log entries.
|
|
12
|
+
*
|
|
13
|
+
* - `prompt_sent`: A user prompt was sent to the LLM.
|
|
14
|
+
* - `response_received`: An assistant response was received from the LLM.
|
|
15
|
+
* - `compaction_received`: A server-side compaction summary replaced earlier history.
|
|
16
|
+
*/
|
|
17
|
+
export type EventType = "prompt_sent" | "response_received" | "compaction_received";
|
|
18
|
+
/**
|
|
19
|
+
* Message role aligned with AI SDK's `ModelMessage` role literals.
|
|
20
|
+
*/
|
|
21
|
+
export type MessageRole = "user" | "assistant" | "tool" | "system";
|
|
22
|
+
/**
|
|
23
|
+
* A single entry in the JSONL event log.
|
|
24
|
+
*
|
|
25
|
+
* Each entry captures a conversation turn with enough metadata to
|
|
26
|
+
* reconstruct `StoredMessage[]` for the AI SDK. The `_superblocks`
|
|
27
|
+
* field preserves round-trip metadata (token counts, summary flags)
|
|
28
|
+
* through the storage layer.
|
|
29
|
+
*/
|
|
30
|
+
export interface EventLogEntry {
|
|
31
|
+
/** Event discriminator. */
|
|
32
|
+
readonly type: EventType;
|
|
33
|
+
/** Unix epoch milliseconds when this event occurred. */
|
|
34
|
+
readonly timestamp: number;
|
|
35
|
+
/** Message role matching AI SDK `ModelMessage` role literals. */
|
|
36
|
+
readonly role: MessageRole;
|
|
37
|
+
/** Message content -- string, array of content parts, or other AI SDK content shapes. */
|
|
38
|
+
readonly content: unknown;
|
|
39
|
+
/** Token usage for this turn (typically set on response_received events). */
|
|
40
|
+
readonly usage?: {
|
|
41
|
+
readonly input: number;
|
|
42
|
+
readonly output: number;
|
|
43
|
+
readonly cacheRead: number;
|
|
44
|
+
};
|
|
45
|
+
/** Provider-specific metadata passed through from the AI SDK. */
|
|
46
|
+
readonly providerMetadata?: Record<string, unknown>;
|
|
47
|
+
/** Superblocks metadata preserved through storage round-trip (isSummary, tokenCount, etc.). */
|
|
48
|
+
readonly _superblocks?: SuperblocksMetadata;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=event-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-types.d.ts","sourceRoot":"","sources":["../../../../../src/ai-service/llm/context-v2/storage/event-types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEvD;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GACjB,aAAa,GACb,mBAAmB,GACnB,qBAAqB,CAAC;AAE1B;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEnE;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC5B,2BAA2B;IAC3B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,wDAAwD;IACxD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,iEAAiE;IACjE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,yFAAyF;IACzF,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,6EAA6E;IAC7E,QAAQ,CAAC,KAAK,CAAC,EAAE;QACf,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;KAC5B,CAAC;IACF,iEAAiE;IACjE,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpD,+FAA+F;IAC/F,QAAQ,CAAC,YAAY,CAAC,EAAE,mBAAmB,CAAC;CAC7C"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event type definitions for the JSONL event log.
|
|
3
|
+
*
|
|
4
|
+
* Events are appended to per-app JSONL files as an append-only log.
|
|
5
|
+
* Each line represents a single event (prompt sent, response received,
|
|
6
|
+
* or compaction received). The event log replaces full-context JSON
|
|
7
|
+
* blob storage with an incremental, corruption-tolerant format.
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=event-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-types.js","sourceRoot":"","sources":["../../../../../src/ai-service/llm/context-v2/storage/event-types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSONL file-based EventStore implementation.
|
|
3
|
+
*
|
|
4
|
+
* Stores conversation events as newline-delimited JSON in per-context
|
|
5
|
+
* `.jsonl` files under
|
|
6
|
+
* `{rootDir}/.superblocks/events/{userId}/{name}.jsonl`.
|
|
7
|
+
*
|
|
8
|
+
* Each `ContextId` segment is `encodeURIComponent`-encoded before being
|
|
9
|
+
* joined into the path. This guarantees two things:
|
|
10
|
+
* 1. Different `{userId, name}` tuples cannot collide on disk, so
|
|
11
|
+
* one user's conversation cannot leak into another user's context
|
|
12
|
+
* in the same app workspace.
|
|
13
|
+
* 2. Segments containing `..`, `/`, or other path-control characters
|
|
14
|
+
* cannot escape the `events/` root via path traversal.
|
|
15
|
+
*
|
|
16
|
+
* Writes are append-only (one `appendFile` call per event). Reads
|
|
17
|
+
* scan backward for the most recent compaction anchor, then return
|
|
18
|
+
* messages from that point forward. Corrupted lines (invalid JSON)
|
|
19
|
+
* are skipped with a warning log, making the format tolerant to
|
|
20
|
+
* partial writes or manual edits.
|
|
21
|
+
*/
|
|
22
|
+
import type { ContextId, StoredMessage } from "../types.js";
|
|
23
|
+
import type { EventStore } from "./event-store.js";
|
|
24
|
+
import type { EventLogEntry } from "./event-types.js";
|
|
25
|
+
/**
|
|
26
|
+
* Append-only JSONL event store backed by the local filesystem.
|
|
27
|
+
*
|
|
28
|
+
* Each app's events are stored in a single `.jsonl` file. The file
|
|
29
|
+
* path mirrors the existing `.superblocks/` convention used by
|
|
30
|
+
* `LocalContextStorageV2` but under an `events/` subdirectory.
|
|
31
|
+
*/
|
|
32
|
+
export declare class JsonlEventStore implements EventStore {
|
|
33
|
+
private readonly rootDir;
|
|
34
|
+
private static readonly SUPERBLOCKS_SYSTEM_DIR;
|
|
35
|
+
private static readonly EVENTS_SUBDIR;
|
|
36
|
+
constructor(rootDir: string);
|
|
37
|
+
/**
|
|
38
|
+
* Append a single event to the log for the given context.
|
|
39
|
+
*
|
|
40
|
+
* Creates parent directories if they do not exist. Each call
|
|
41
|
+
* writes exactly one JSON line terminated by `\n`.
|
|
42
|
+
*/
|
|
43
|
+
appendEvent(id: ContextId, event: EventLogEntry): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Check whether any events exist for the given context.
|
|
46
|
+
*/
|
|
47
|
+
hasEvents(id: ContextId): Promise<boolean>;
|
|
48
|
+
/**
|
|
49
|
+
* Remove the event log for a single context. Missing files are
|
|
50
|
+
* treated as success so callers can use this as a fire-and-forget
|
|
51
|
+
* cleanup step.
|
|
52
|
+
*/
|
|
53
|
+
deleteEvents(id: ContextId): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Remove the entire `.superblocks/events/` tree under `rootDir`.
|
|
56
|
+
*
|
|
57
|
+
* Used by clear-all flows so a subsequent `getOrCreateContext` does
|
|
58
|
+
* not silently restore a "deleted" conversation from disk.
|
|
59
|
+
*/
|
|
60
|
+
deleteAllEvents(): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Load conversation messages by scanning backward for the last
|
|
63
|
+
* compaction anchor, then reading forward from that point.
|
|
64
|
+
*
|
|
65
|
+
* A compaction anchor is either:
|
|
66
|
+
* - An event with `type === "compaction_received"`
|
|
67
|
+
* - An event with `_superblocks.isSummary === true` (migration seed)
|
|
68
|
+
*
|
|
69
|
+
* Each `EventLogEntry` is mapped to a `StoredMessage` so that
|
|
70
|
+
* consumers receive the AI SDK `ModelMessage` shape.
|
|
71
|
+
*/
|
|
72
|
+
loadMessages(id: ContextId): Promise<StoredMessage[]>;
|
|
73
|
+
/**
|
|
74
|
+
* Map an EventLogEntry to a StoredMessage (AI SDK ModelMessage shape).
|
|
75
|
+
*
|
|
76
|
+
* The cast is required at this JSON deserialization boundary: `content`
|
|
77
|
+
* is stored as `unknown` because AI SDK content shapes are polymorphic
|
|
78
|
+
* (string, content part arrays, tool results). The role is type-safe
|
|
79
|
+
* via `MessageRole`, but TypeScript cannot narrow the discriminated
|
|
80
|
+
* union without runtime content validation — which would be fragile
|
|
81
|
+
* against SDK version changes.
|
|
82
|
+
*/
|
|
83
|
+
private toStoredMessage;
|
|
84
|
+
private getEventsRoot;
|
|
85
|
+
private getFilePath;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=jsonl-event-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonl-event-store.d.ts","sourceRoot":"","sources":["../../../../../src/ai-service/llm/context-v2/storage/jsonl-event-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAUH,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAe,MAAM,kBAAkB,CAAC;AAInE;;;;;;GAMG;AACH,qBAAa,eAAgB,YAAW,UAAU;IAIpC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAHpC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,sBAAsB,CAAkB;IAChE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAY;gBAEpB,OAAO,EAAE,MAAM;IAE5C;;;;;OAKG;IACG,WAAW,CAAC,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAMrE;;OAEG;IACG,SAAS,CAAC,EAAE,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC;IAYhD;;;;OAIG;IACG,YAAY,CAAC,EAAE,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhD;;;;;OAKG;IACG,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAItC;;;;;;;;;;OAUG;IACG,YAAY,CAAC,EAAE,EAAE,SAAS,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAwE3D;;;;;;;;;OASG;IACH,OAAO,CAAC,eAAe;IAcvB,OAAO,CAAC,aAAa;IAQrB,OAAO,CAAC,WAAW;CAQpB"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSONL file-based EventStore implementation.
|
|
3
|
+
*
|
|
4
|
+
* Stores conversation events as newline-delimited JSON in per-context
|
|
5
|
+
* `.jsonl` files under
|
|
6
|
+
* `{rootDir}/.superblocks/events/{userId}/{name}.jsonl`.
|
|
7
|
+
*
|
|
8
|
+
* Each `ContextId` segment is `encodeURIComponent`-encoded before being
|
|
9
|
+
* joined into the path. This guarantees two things:
|
|
10
|
+
* 1. Different `{userId, name}` tuples cannot collide on disk, so
|
|
11
|
+
* one user's conversation cannot leak into another user's context
|
|
12
|
+
* in the same app workspace.
|
|
13
|
+
* 2. Segments containing `..`, `/`, or other path-control characters
|
|
14
|
+
* cannot escape the `events/` root via path traversal.
|
|
15
|
+
*
|
|
16
|
+
* Writes are append-only (one `appendFile` call per event). Reads
|
|
17
|
+
* scan backward for the most recent compaction anchor, then return
|
|
18
|
+
* messages from that point forward. Corrupted lines (invalid JSON)
|
|
19
|
+
* are skipped with a warning log, making the format tolerant to
|
|
20
|
+
* partial writes or manual edits.
|
|
21
|
+
*/
|
|
22
|
+
import { readFile, appendFile, mkdir, rm } from "node:fs/promises";
|
|
23
|
+
import * as path from "node:path";
|
|
24
|
+
import { getPrefixedLogger } from "../../../../util/logger.js";
|
|
25
|
+
import { encodeContextPathSegment, safeJoinUnderRoot, } from "../../../context-archive-paths.js";
|
|
26
|
+
const logger = getPrefixedLogger("[jsonl-event-store]");
|
|
27
|
+
/**
|
|
28
|
+
* Append-only JSONL event store backed by the local filesystem.
|
|
29
|
+
*
|
|
30
|
+
* Each app's events are stored in a single `.jsonl` file. The file
|
|
31
|
+
* path mirrors the existing `.superblocks/` convention used by
|
|
32
|
+
* `LocalContextStorageV2` but under an `events/` subdirectory.
|
|
33
|
+
*/
|
|
34
|
+
export class JsonlEventStore {
|
|
35
|
+
rootDir;
|
|
36
|
+
static SUPERBLOCKS_SYSTEM_DIR = ".superblocks";
|
|
37
|
+
static EVENTS_SUBDIR = "events";
|
|
38
|
+
constructor(rootDir) {
|
|
39
|
+
this.rootDir = rootDir;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Append a single event to the log for the given context.
|
|
43
|
+
*
|
|
44
|
+
* Creates parent directories if they do not exist. Each call
|
|
45
|
+
* writes exactly one JSON line terminated by `\n`.
|
|
46
|
+
*/
|
|
47
|
+
async appendEvent(id, event) {
|
|
48
|
+
const filePath = this.getFilePath(id);
|
|
49
|
+
await mkdir(path.dirname(filePath), { recursive: true });
|
|
50
|
+
await appendFile(filePath, JSON.stringify(event) + "\n");
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Check whether any events exist for the given context.
|
|
54
|
+
*/
|
|
55
|
+
async hasEvents(id) {
|
|
56
|
+
try {
|
|
57
|
+
const content = await readFile(this.getFilePath(id), "utf-8");
|
|
58
|
+
return content.trimEnd().length > 0;
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
if (err.code === "ENOENT") {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
throw err;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Remove the event log for a single context. Missing files are
|
|
69
|
+
* treated as success so callers can use this as a fire-and-forget
|
|
70
|
+
* cleanup step.
|
|
71
|
+
*/
|
|
72
|
+
async deleteEvents(id) {
|
|
73
|
+
await rm(this.getFilePath(id), { force: true });
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Remove the entire `.superblocks/events/` tree under `rootDir`.
|
|
77
|
+
*
|
|
78
|
+
* Used by clear-all flows so a subsequent `getOrCreateContext` does
|
|
79
|
+
* not silently restore a "deleted" conversation from disk.
|
|
80
|
+
*/
|
|
81
|
+
async deleteAllEvents() {
|
|
82
|
+
await rm(this.getEventsRoot(), { recursive: true, force: true });
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Load conversation messages by scanning backward for the last
|
|
86
|
+
* compaction anchor, then reading forward from that point.
|
|
87
|
+
*
|
|
88
|
+
* A compaction anchor is either:
|
|
89
|
+
* - An event with `type === "compaction_received"`
|
|
90
|
+
* - An event with `_superblocks.isSummary === true` (migration seed)
|
|
91
|
+
*
|
|
92
|
+
* Each `EventLogEntry` is mapped to a `StoredMessage` so that
|
|
93
|
+
* consumers receive the AI SDK `ModelMessage` shape.
|
|
94
|
+
*/
|
|
95
|
+
async loadMessages(id) {
|
|
96
|
+
const filePath = this.getFilePath(id);
|
|
97
|
+
let raw;
|
|
98
|
+
try {
|
|
99
|
+
raw = await readFile(filePath, "utf-8");
|
|
100
|
+
}
|
|
101
|
+
catch (err) {
|
|
102
|
+
if (err.code === "ENOENT") {
|
|
103
|
+
return [];
|
|
104
|
+
}
|
|
105
|
+
throw err;
|
|
106
|
+
}
|
|
107
|
+
const lines = raw.split("\n").filter((line) => line.length > 0);
|
|
108
|
+
if (lines.length === 0) {
|
|
109
|
+
return [];
|
|
110
|
+
}
|
|
111
|
+
// Parse each line, skipping corrupted entries. A corrupted line could
|
|
112
|
+
// be the compaction anchor itself; if that happens the backward scan
|
|
113
|
+
// below will overshoot and return more history than intended, so we
|
|
114
|
+
// log loudly enough that the discrepancy is investigable.
|
|
115
|
+
//
|
|
116
|
+
// The raw line payload is intentionally NOT logged: even a partial
|
|
117
|
+
// JSONL fragment can contain user prompts or tool results, and those
|
|
118
|
+
// would otherwise leak into log sinks that don't share the event
|
|
119
|
+
// store's privacy boundary. Length is enough to debug truncation
|
|
120
|
+
// patterns without spilling content.
|
|
121
|
+
const contextLabel = `${id.appId}/${id.userId}/${id.name}`;
|
|
122
|
+
const events = [];
|
|
123
|
+
let corruptedCount = 0;
|
|
124
|
+
for (let i = 0; i < lines.length; i++) {
|
|
125
|
+
const line = lines[i];
|
|
126
|
+
try {
|
|
127
|
+
events.push(JSON.parse(line));
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
corruptedCount++;
|
|
131
|
+
logger.warn(`Skipping corrupted JSONL line ${i} for context '${contextLabel}' (length=${line.length})`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (corruptedCount > 0) {
|
|
135
|
+
logger.warn(`Encountered ${corruptedCount} corrupted line(s) in event log for context '${contextLabel}'; if any held a compaction anchor the loaded window may extend further back than expected.`);
|
|
136
|
+
}
|
|
137
|
+
// Backward scan: find the last compaction anchor
|
|
138
|
+
let anchorIndex = -1;
|
|
139
|
+
for (let i = events.length - 1; i >= 0; i--) {
|
|
140
|
+
const event = events[i];
|
|
141
|
+
if (event.type === "compaction_received" ||
|
|
142
|
+
event._superblocks?.isSummary === true) {
|
|
143
|
+
anchorIndex = i;
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (anchorIndex < 0 && corruptedCount > 0) {
|
|
148
|
+
logger.error(`No compaction anchor found for context '${contextLabel}' but ${corruptedCount} corrupted line(s) were skipped; the loaded conversation window may be unbounded.`);
|
|
149
|
+
}
|
|
150
|
+
const window = anchorIndex >= 0 ? events.slice(anchorIndex) : events;
|
|
151
|
+
return window.map((event) => this.toStoredMessage(event));
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Map an EventLogEntry to a StoredMessage (AI SDK ModelMessage shape).
|
|
155
|
+
*
|
|
156
|
+
* The cast is required at this JSON deserialization boundary: `content`
|
|
157
|
+
* is stored as `unknown` because AI SDK content shapes are polymorphic
|
|
158
|
+
* (string, content part arrays, tool results). The role is type-safe
|
|
159
|
+
* via `MessageRole`, but TypeScript cannot narrow the discriminated
|
|
160
|
+
* union without runtime content validation — which would be fragile
|
|
161
|
+
* against SDK version changes.
|
|
162
|
+
*/
|
|
163
|
+
toStoredMessage(event) {
|
|
164
|
+
return {
|
|
165
|
+
role: event.role,
|
|
166
|
+
content: event.content,
|
|
167
|
+
...(event.providerMetadata && {
|
|
168
|
+
providerMetadata: event.providerMetadata,
|
|
169
|
+
}),
|
|
170
|
+
_superblocks: {
|
|
171
|
+
timestamp: event.timestamp,
|
|
172
|
+
...event._superblocks,
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
getEventsRoot() {
|
|
177
|
+
return path.join(this.rootDir, JsonlEventStore.SUPERBLOCKS_SYSTEM_DIR, JsonlEventStore.EVENTS_SUBDIR);
|
|
178
|
+
}
|
|
179
|
+
getFilePath(id) {
|
|
180
|
+
const root = this.getEventsRoot();
|
|
181
|
+
return safeJoinUnderRoot(root, encodeContextPathSegment(id.userId, "userId"), `${encodeContextPathSegment(id.name, "name")}.jsonl`);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=jsonl-event-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonl-event-store.js","sourceRoot":"","sources":["../../../../../src/ai-service/llm/context-v2/storage/jsonl-event-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EACL,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,mCAAmC,CAAC;AAK3C,MAAM,MAAM,GAAG,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,OAAO,eAAe;IAIG;IAHrB,MAAM,CAAU,sBAAsB,GAAG,cAAc,CAAC;IACxD,MAAM,CAAU,aAAa,GAAG,QAAQ,CAAC;IAEjD,YAA6B,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;IAAG,CAAC;IAEhD;;;;;OAKG;IACH,KAAK,CAAC,WAAW,CAAC,EAAa,EAAE,KAAoB;QACnD,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QACtC,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACzD,MAAM,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,C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a,EAAE,CAAC;QAClC,OAAO,iBAAiB,CACtB,IAAI,EACJ,wBAAwB,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,EAC7C,GAAG,wBAAwB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,QAAQ,CACrD,CAAC;IACJ,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration from ContextV2 JSON storage to JSONL event log.
|
|
3
|
+
*
|
|
4
|
+
* Reads existing conversation data from the legacy file-per-context
|
|
5
|
+
* JSON storage, finds the last summary anchor, and seeds messages
|
|
6
|
+
* forward into the append-only event log. Old JSON files are left
|
|
7
|
+
* in place for safety.
|
|
8
|
+
*/
|
|
9
|
+
import type { ContextRecordV2 } from "../types.js";
|
|
10
|
+
import type { EventStore } from "./event-store.js";
|
|
11
|
+
import type { ContextStorageV2 } from "./index.js";
|
|
12
|
+
import type { ContextId } from "./types.js";
|
|
13
|
+
/**
|
|
14
|
+
* Migrates conversation history from ContextV2 JSON blobs to the
|
|
15
|
+
* JSONL event log.
|
|
16
|
+
*
|
|
17
|
+
* Migration is idempotent: if the event log already contains events
|
|
18
|
+
* for the app, `migrateIfNeeded` is a no-op. Old JSON files are
|
|
19
|
+
* never deleted — they are left in place for safety.
|
|
20
|
+
*/
|
|
21
|
+
export declare class ContextV2Migrator {
|
|
22
|
+
private readonly legacyStorage;
|
|
23
|
+
private readonly eventStore;
|
|
24
|
+
constructor(legacyStorage: ContextStorageV2, eventStore: EventStore);
|
|
25
|
+
/**
|
|
26
|
+
* Migrate a context from legacy JSON to the JSONL event log if needed.
|
|
27
|
+
*
|
|
28
|
+
* Checks whether the event log already has events (skip if so),
|
|
29
|
+
* loads from legacy storage, finds the last `isSummary` anchor,
|
|
30
|
+
* and seeds messages from that point forward into the event log.
|
|
31
|
+
*
|
|
32
|
+
* @param contextId - The context to migrate
|
|
33
|
+
* @returns `true` if migration occurred, `false` if skipped
|
|
34
|
+
*/
|
|
35
|
+
migrateIfNeeded(contextId: ContextId): Promise<boolean>;
|
|
36
|
+
appendRecordWindow(contextId: ContextId, record: ContextRecordV2): Promise<boolean>;
|
|
37
|
+
/**
|
|
38
|
+
* Scan backward for the last message marked as a summary.
|
|
39
|
+
*
|
|
40
|
+
* @returns Index of the last isSummary message, or -1 if none found
|
|
41
|
+
*/
|
|
42
|
+
private findSummaryAnchor;
|
|
43
|
+
private messagesFromSummaryAnchor;
|
|
44
|
+
/**
|
|
45
|
+
* Convert a StoredMessage to an EventLogEntry for seeding.
|
|
46
|
+
*/
|
|
47
|
+
private toEventLogEntry;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=migration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration.d.ts","sourceRoot":"","sources":["../../../../../src/ai-service/llm/context-v2/storage/migration.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAiB,MAAM,aAAa,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAI5C;;;;;;;GAOG;AACH,qBAAa,iBAAiB;IAE1B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,UAAU;gBADV,aAAa,EAAE,gBAAgB,EAC/B,UAAU,EAAE,UAAU;IAGzC;;;;;;;;;OASG;IACG,eAAe,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC;IA0BvD,kBAAkB,CACtB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,OAAO,CAAC;IA2CnB;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,yBAAyB;IAOjC;;OAEG;IACH,OAAO,CAAC,eAAe;CAgBxB"}
|