@geminixiang/mikan 1.0.0-beta.83 → 1.0.0-beta.85
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/CHANGELOG.md +28 -0
- package/README.md +2 -2
- package/dist/adapters/slack/bot.d.ts +1 -0
- package/dist/adapters/slack/bot.d.ts.map +1 -1
- package/dist/adapters/slack/bot.js +8 -2
- package/dist/adapters/slack/bot.js.map +1 -1
- package/dist/adapters/slack/response-lifecycle.js +2 -2
- package/dist/adapters/slack/response-lifecycle.js.map +1 -1
- package/dist/cli/boot.d.ts.map +1 -1
- package/dist/cli/boot.js +4 -6
- package/dist/cli/boot.js.map +1 -1
- package/dist/cli/migrate.d.ts +3 -0
- package/dist/cli/migrate.d.ts.map +1 -0
- package/dist/cli/migrate.js +75 -0
- package/dist/cli/migrate.js.map +1 -0
- package/dist/cli/office.d.ts.map +1 -1
- package/dist/cli/office.js +8 -129
- package/dist/cli/office.js.map +1 -1
- package/dist/cli/onboard.d.ts.map +1 -1
- package/dist/cli/onboard.js +3 -0
- package/dist/cli/onboard.js.map +1 -1
- package/dist/cli/types.d.ts +2 -3
- package/dist/cli/types.d.ts.map +1 -1
- package/dist/cli/types.js.map +1 -1
- package/dist/events/index.d.ts +2 -13
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +1 -58
- package/dist/events/index.js.map +1 -1
- package/dist/harness/budget-stop.d.ts +3 -0
- package/dist/harness/budget-stop.d.ts.map +1 -0
- package/dist/harness/budget-stop.js +36 -0
- package/dist/harness/budget-stop.js.map +1 -0
- package/dist/harness/execution-resolver.d.ts.map +1 -1
- package/dist/harness/execution-resolver.js +5 -9
- package/dist/harness/execution-resolver.js.map +1 -1
- package/dist/harness/open-connector.d.ts +0 -9
- package/dist/harness/open-connector.d.ts.map +1 -1
- package/dist/harness/open-connector.js +1 -62
- package/dist/harness/open-connector.js.map +1 -1
- package/dist/harness/presenter.d.ts.map +1 -1
- package/dist/harness/presenter.js +31 -2
- package/dist/harness/presenter.js.map +1 -1
- package/dist/harness/prompt.js +1 -1
- package/dist/harness/prompt.js.map +1 -1
- package/dist/harness/run-events.d.ts.map +1 -1
- package/dist/harness/run-events.js +6 -1
- package/dist/harness/run-events.js.map +1 -1
- package/dist/harness/skills.d.ts.map +1 -1
- package/dist/harness/skills.js +19 -14
- package/dist/harness/skills.js.map +1 -1
- package/dist/harness/tools/jev-browser.d.ts.map +1 -1
- package/dist/harness/tools/jev-browser.js +13 -15
- package/dist/harness/tools/jev-browser.js.map +1 -1
- package/dist/harness/types.d.ts +16 -0
- package/dist/harness/types.d.ts.map +1 -1
- package/dist/harness/types.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/main.js +8 -50
- package/dist/main.js.map +1 -1
- package/dist/migrations/actor-vaults.d.ts +3 -0
- package/dist/migrations/actor-vaults.d.ts.map +1 -0
- package/dist/migrations/actor-vaults.js +43 -0
- package/dist/migrations/actor-vaults.js.map +1 -0
- package/dist/migrations/conversation-settings.d.ts +3 -0
- package/dist/migrations/conversation-settings.d.ts.map +1 -0
- package/dist/migrations/conversation-settings.js +31 -0
- package/dist/migrations/conversation-settings.js.map +1 -0
- package/dist/migrations/index.d.ts +14 -0
- package/dist/migrations/index.d.ts.map +1 -0
- package/dist/migrations/index.js +97 -0
- package/dist/migrations/index.js.map +1 -0
- package/dist/migrations/models-json.d.ts +3 -0
- package/dist/migrations/models-json.d.ts.map +1 -0
- package/dist/migrations/models-json.js +18 -0
- package/dist/migrations/models-json.js.map +1 -0
- package/dist/migrations/office-layout.d.ts +4 -0
- package/dist/migrations/office-layout.d.ts.map +1 -0
- package/dist/migrations/office-layout.js +94 -0
- package/dist/migrations/office-layout.js.map +1 -0
- package/dist/migrations/sandbox-containers.d.ts +3 -0
- package/dist/migrations/sandbox-containers.d.ts.map +1 -0
- package/dist/migrations/sandbox-containers.js +36 -0
- package/dist/migrations/sandbox-containers.js.map +1 -0
- package/dist/{sessions/migrate-common.d.ts → migrations/session-files.d.ts} +1 -2
- package/dist/migrations/session-files.d.ts.map +1 -0
- package/dist/{sessions/migrate-common.js → migrations/session-files.js} +2 -2
- package/dist/migrations/session-files.js.map +1 -0
- package/dist/{sessions/migrate-v3.d.ts → migrations/sessions-v3.d.ts} +4 -3
- package/dist/migrations/sessions-v3.d.ts.map +1 -0
- package/dist/{sessions/migrate-v3.js → migrations/sessions-v3.js} +14 -4
- package/dist/migrations/sessions-v3.js.map +1 -0
- package/dist/migrations/types.d.ts +30 -0
- package/dist/migrations/types.d.ts.map +1 -0
- package/dist/migrations/types.js +2 -0
- package/dist/migrations/types.js.map +1 -0
- package/dist/migrations/workspace-events.d.ts +3 -0
- package/dist/migrations/workspace-events.d.ts.map +1 -0
- package/dist/migrations/workspace-events.js +43 -0
- package/dist/migrations/workspace-events.js.map +1 -0
- package/dist/office/index.d.ts +2 -23
- package/dist/office/index.d.ts.map +1 -1
- package/dist/office/index.js +12 -574
- package/dist/office/index.js.map +1 -1
- package/dist/office/types.d.ts +0 -10
- package/dist/office/types.d.ts.map +1 -1
- package/dist/office/types.js.map +1 -1
- package/dist/sandbox/identity.d.ts +2 -3
- package/dist/sandbox/identity.d.ts.map +1 -1
- package/dist/sandbox/identity.js +6 -13
- package/dist/sandbox/identity.js.map +1 -1
- package/dist/sandbox/layout.d.ts +0 -2
- package/dist/sandbox/layout.d.ts.map +1 -1
- package/dist/sandbox/layout.js +2 -2
- package/dist/sandbox/layout.js.map +1 -1
- package/dist/sandbox/provisioner.d.ts +3 -37
- package/dist/sandbox/provisioner.d.ts.map +1 -1
- package/dist/sandbox/provisioner.js +13 -452
- package/dist/sandbox/provisioner.js.map +1 -1
- package/dist/sessions/session-store.d.ts.map +1 -1
- package/dist/sessions/session-store.js +1 -8
- package/dist/sessions/session-store.js.map +1 -1
- package/dist/sessions/types.d.ts +0 -10
- package/dist/sessions/types.d.ts.map +1 -1
- package/dist/sessions/types.js.map +1 -1
- package/dist/settings/index.d.ts +0 -48
- package/dist/settings/index.d.ts.map +1 -1
- package/dist/settings/index.js +6 -37
- package/dist/settings/index.js.map +1 -1
- package/dist/types.d.ts +0 -28
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/vault/index.d.ts +0 -7
- package/dist/vault/index.d.ts.map +1 -1
- package/dist/vault/index.js +1 -36
- package/dist/vault/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/cli/sandbox.d.ts +0 -3
- package/dist/cli/sandbox.d.ts.map +0 -1
- package/dist/cli/sandbox.js +0 -80
- package/dist/cli/sandbox.js.map +0 -1
- package/dist/cli/sessions.d.ts +0 -2
- package/dist/cli/sessions.d.ts.map +0 -1
- package/dist/cli/sessions.js +0 -78
- package/dist/cli/sessions.js.map +0 -1
- package/dist/sessions/migrate-common.d.ts.map +0 -1
- package/dist/sessions/migrate-common.js.map +0 -1
- package/dist/sessions/migrate-pi-084.d.ts +0 -7
- package/dist/sessions/migrate-pi-084.d.ts.map +0 -1
- package/dist/sessions/migrate-pi-084.js +0 -293
- package/dist/sessions/migrate-pi-084.js.map +0 -1
- package/dist/sessions/migrate-v3.d.ts.map +0 -1
- package/dist/sessions/migrate-v3.js.map +0 -1
- package/dist/settings/migrate.d.ts +0 -16
- package/dist/settings/migrate.d.ts.map +0 -1
- package/dist/settings/migrate.js +0 -70
- package/dist/settings/migrate.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"office-layout.js","sourceRoot":"","sources":["../../src/migrations/office-layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACzE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,mBAAmB,EACnB,SAAS,EACT,SAAS,EACT,cAAc,EACd,wBAAwB,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Y,CAAC,OAAO,CAAC,CAAC;IAChF,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC5B,IAAI,CAAC,OAAO,CAAC,MAAM;QAAE,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAc,MAAM,CAAC,MAAM,CAAC;IAC5D,EAAE,EAAE,oBAAoB;IACxB,OAAO,EAAE,+DAA+D;IACxE,KAAK,CAAC,GAAG,CAAC,OAAyB;QACjC,MAAM,SAAS,GAAG,gBAAgB,CAAC,oBAAoB,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC,CAAC;QACzF,KAAK,MAAM,OAAO,IAAI,SAAS;YAAE,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { existsSync, lstatSync, readdirSync, renameSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport {\n createOfficeAddress,\n isOfficeKey,\n OFFICE_LOG_FILENAME,\n officeDir,\n officeKey,\n OfficeRegistry,\n RESERVED_WORKSPACE_NAMES,\n} from \"../office/index.js\";\nimport type { OfficeAddress, PlatformName } from \"../types.js\";\nimport type { Migration, MigrationContext } from \"./types.js\";\n\nconst LEGACY_ID_FORMATS: Readonly<Record<PlatformName, RegExp>> = Object.freeze({\n slack: /^[A-Z][A-Z0-9]*$/,\n telegram: /^-?\\d+$/,\n discord: /^\\d+$/,\n github: /^$/,\n});\n\nexport function legacyResourceKey(conversationId: string): string {\n const sanitized = conversationId\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n return sanitized || \"unknown\";\n}\n\nfunction listLegacyOfficeDirs(workspaceRoot: string): string[] {\n if (!existsSync(workspaceRoot)) return [];\n return readdirSync(workspaceRoot, { withFileTypes: true })\n .filter(\n (entry) =>\n entry.isDirectory() &&\n !entry.name.startsWith(\".\") &&\n !RESERVED_WORKSPACE_NAMES.has(entry.name) &&\n !isOfficeKey(entry.name) &&\n (existsSync(join(workspaceRoot, entry.name, OFFICE_LOG_FILENAME)) ||\n existsSync(join(workspaceRoot, entry.name, \"sessions\"))),\n )\n .map((entry) => entry.name)\n .toSorted();\n}\n\nfunction resolveOwner(conversationId: string, context: MigrationContext): PlatformName | undefined {\n const explicit = context.owners.get(conversationId);\n if (explicit) return explicit;\n const candidates = context.enabledPlatforms.filter((platform) =>\n LEGACY_ID_FORMATS[platform].test(conversationId),\n );\n return candidates.length === 1 ? candidates[0] : undefined;\n}\n\nfunction resolveAddresses(ids: readonly string[], context: MigrationContext): OfficeAddress[] {\n const addresses: OfficeAddress[] = [];\n const unowned: string[] = [];\n for (const id of ids) {\n const platform = resolveOwner(id, context);\n if (platform) addresses.push(createOfficeAddress(platform, id));\n else unowned.push(id);\n }\n if (unowned.length > 0) {\n throw new Error(\n [\n \"These conversation directories match no single enabled platform:\",\n ...unowned.map((id) => ` - ${id}`),\n \"Enable the owning platform's token, or name it with --owner <conversationId>=<platform>.\",\n ].join(\"\\n\"),\n );\n }\n return addresses;\n}\n\nfunction moveVault(context: MigrationContext, address: OfficeAddress): void {\n const vaultsDir = join(context.stateDir, \"vaults\");\n const source = join(vaultsDir, legacyResourceKey(address.conversationId));\n if (!existsSync(source)) return;\n const target = join(vaultsDir, officeKey(address));\n if (existsSync(target)) {\n throw new Error(`Both a legacy and an office vault exist; merge ${source} into ${target}`);\n }\n context.report(` vault ${legacyResourceKey(address.conversationId)} -> ${officeKey(address)}`);\n if (!context.dryRun) renameSync(source, target);\n}\n\nfunction moveOffice(context: MigrationContext, address: OfficeAddress): void {\n const source = join(context.workspaceRoot, address.conversationId);\n const target = officeDir(context.workspaceRoot, address);\n if (lstatSync(source).isSymbolicLink()) {\n throw new Error(`Conversation directory must not be a symlink: ${source}`);\n }\n if (existsSync(target)) {\n throw new Error(`Both a legacy and an office directory exist; merge ${source} into ${target}`);\n }\n context.report(` office ${address.conversationId} -> ${officeKey(address)}`);\n if (!context.dryRun) new OfficeRegistry(context.stateDir).recordOffice(address);\n moveVault(context, address);\n if (!context.dryRun) renameSync(source, target);\n}\n\nexport const officeLayoutMigration: Migration = Object.freeze({\n id: \"0001-office-layout\",\n summary: \"move conversation directories and their vaults to office keys\",\n async run(context: MigrationContext): Promise<void> {\n const addresses = resolveAddresses(listLegacyOfficeDirs(context.workspaceRoot), context);\n for (const address of addresses) moveOffice(context, address);\n },\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-containers.d.ts","sourceRoot":"","sources":["../../src/migrations/sandbox-containers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAoB,MAAM,YAAY,CAAC;AAgB9D,eAAO,MAAM,0BAA0B,EAAE,SAiBvC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { listRegisteredOffices } from "../office/index.js";
|
|
2
|
+
import { legacyResourceKey } from "./office-layout.js";
|
|
3
|
+
function isMissingExecutable(error) {
|
|
4
|
+
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
5
|
+
}
|
|
6
|
+
async function listContainerNames(context) {
|
|
7
|
+
try {
|
|
8
|
+
const stdout = await context.docker(["ps", "-a", "--format", "{{.Names}}"]);
|
|
9
|
+
return new Set(stdout.split("\n").map((name) => name.trim()));
|
|
10
|
+
}
|
|
11
|
+
catch (error) {
|
|
12
|
+
if (isMissingExecutable(error))
|
|
13
|
+
return undefined;
|
|
14
|
+
throw error;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export const sandboxContainersMigration = Object.freeze({
|
|
18
|
+
id: "0006-sandbox-containers",
|
|
19
|
+
summary: "remove sandbox containers named by raw conversation IDs; offices recreate their own",
|
|
20
|
+
async run(context) {
|
|
21
|
+
const existing = await listContainerNames(context);
|
|
22
|
+
if (!existing) {
|
|
23
|
+
context.report(" docker is not installed; no containers to remove");
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const legacyNames = listRegisteredOffices(context.stateDir)
|
|
27
|
+
.map((office) => `mikan-sandbox-${legacyResourceKey(office.conversationId)}`)
|
|
28
|
+
.filter((name) => existing.has(name));
|
|
29
|
+
for (const name of new Set(legacyNames)) {
|
|
30
|
+
context.report(` container ${name}`);
|
|
31
|
+
if (!context.dryRun)
|
|
32
|
+
await context.docker(["rm", "-f", name]);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=sandbox-containers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-containers.js","sourceRoot":"","sources":["../../src/migrations/sandbox-containers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAGvD,SAAS,mBAAmB,CAAC,KAAc;IACzC,OAAO,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC;AAC9E,CAAC;AAED,KAAK,UAAU,kBAAkB,CAAC,OAAyB;IACzD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC;QAC5E,OAAO,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAChE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,mBAAmB,CAAC,KAAK,CAAC;YAAE,OAAO,SAAS,CAAC;QACjD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,0BAA0B,GAAc,MAAM,CAAC,MAAM,CAAC;IACjE,EAAE,EAAE,yBAAyB;IAC7B,OAAO,EAAE,qFAAqF;IAC9F,KAAK,CAAC,GAAG,CAAC,OAAyB;QACjC,MAAM,QAAQ,GAAG,MAAM,kBAAkB,CAAC,OAAO,CAAC,CAAC;QACnD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,OAAO,CAAC,MAAM,CAAC,oDAAoD,CAAC,CAAC;YACrE,OAAO;QACT,CAAC;QACD,MAAM,WAAW,GAAG,qBAAqB,CAAC,OAAO,CAAC,QAAQ,CAAC;aACxD,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,iBAAiB,iBAAiB,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC;aAC5E,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;QACxC,KAAK,MAAM,IAAI,IAAI,IAAI,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YACxC,OAAO,CAAC,MAAM,CAAC,eAAe,IAAI,EAAE,CAAC,CAAC;YACtC,IAAI,CAAC,OAAO,CAAC,MAAM;gBAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;QAChE,CAAC;IACH,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { listRegisteredOffices } from \"../office/index.js\";\nimport { legacyResourceKey } from \"./office-layout.js\";\nimport type { Migration, MigrationContext } from \"./types.js\";\n\nfunction isMissingExecutable(error: unknown): boolean {\n return error instanceof Error && \"code\" in error && error.code === \"ENOENT\";\n}\n\nasync function listContainerNames(context: MigrationContext): Promise<Set<string> | undefined> {\n try {\n const stdout = await context.docker([\"ps\", \"-a\", \"--format\", \"{{.Names}}\"]);\n return new Set(stdout.split(\"\\n\").map((name) => name.trim()));\n } catch (error) {\n if (isMissingExecutable(error)) return undefined;\n throw error;\n }\n}\n\nexport const sandboxContainersMigration: Migration = Object.freeze({\n id: \"0006-sandbox-containers\",\n summary: \"remove sandbox containers named by raw conversation IDs; offices recreate their own\",\n async run(context: MigrationContext): Promise<void> {\n const existing = await listContainerNames(context);\n if (!existing) {\n context.report(\" docker is not installed; no containers to remove\");\n return;\n }\n const legacyNames = listRegisteredOffices(context.stateDir)\n .map((office) => `mikan-sandbox-${legacyResourceKey(office.conversationId)}`)\n .filter((name) => existing.has(name));\n for (const name of new Set(legacyNames)) {\n context.report(` container ${name}`);\n if (!context.dryRun) await context.docker([\"rm\", \"-f\", name]);\n }\n },\n});\n"]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Entry as PiEntry, JsonValue } from "@earendil-works/pi-agent-core";
|
|
2
2
|
import type { Usage } from "@earendil-works/pi-ai";
|
|
3
|
-
export declare function jsonValue(value: unknown): JsonValue;
|
|
4
3
|
export declare function optionalAnnotations(source: {
|
|
5
4
|
details?: unknown;
|
|
6
5
|
usage?: unknown;
|
|
@@ -25,4 +24,4 @@ export declare function commitMigration(options: {
|
|
|
25
24
|
backupPath: string;
|
|
26
25
|
verify: (candidatePath: string) => Promise<void>;
|
|
27
26
|
}): Promise<void>;
|
|
28
|
-
//# sourceMappingURL=
|
|
27
|
+
//# sourceMappingURL=session-files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-files.d.ts","sourceRoot":"","sources":["../../src/migrations/session-files.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,KAAK,IAAI,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAOnD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG;IACnF,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf,CAKA;AAED,qBAAa,YAAY;;IAIvB,YAAY,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAE1C;IAED,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAE1B;IAED,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAExD;IAED,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAE3D;IAMD,QAAQ,IAAI,MAAM,CAEjB;CACF;AAeD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAAG,MAAM,EAAE,CAK/F;AAUD,wBAAsB,eAAe,CAAC,OAAO,EAAE;IAC7C,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAClD,GAAG,OAAO,CAAC,IAAI,CAAC,CAehB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, linkSync, readFileSync, readdirSync, renameSync, rmSync, statSync, } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { atomicWritePrivateFile } from "../file-guards.js";
|
|
4
|
-
|
|
4
|
+
function jsonValue(value) {
|
|
5
5
|
return JSON.parse(JSON.stringify(value));
|
|
6
6
|
}
|
|
7
7
|
export function optionalAnnotations(source) {
|
|
@@ -77,4 +77,4 @@ export async function commitMigration(options) {
|
|
|
77
77
|
throw new Error(`Migration failed for ${filePath}`, { cause: error });
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
//# sourceMappingURL=
|
|
80
|
+
//# sourceMappingURL=session-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-files.js","sourceRoot":"","sources":["../../src/migrations/session-files.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,UAAU,EACV,MAAM,EACN,QAAQ,GACT,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAc,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,MAA8C;IAIhF,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS;QAC7E,KAAK,EAAE,MAAM,CAAC,KAA0B;KACzC,CAAC;AACJ,CAAC;AAED,MAAM,OAAO,YAAY;IACd,MAAM,CAAW;IAC1B,IAAI,GAAG,CAAC,CAAC;IAET,YAAY,MAA+B;QACzC,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,KAAc;QAClB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,GAAG,EAAE,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAClF,CAAC;IAED,GAAG,CAAC,SAAiB,EAAE,GAAW,EAAE,KAAc;QAChD,IAAI,CAAC,MAAM,CAAC,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jC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAClC,MAAM,IAAI,KAAK,CAAC,wBAAwB,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACxE,CAAC;AACH,CAAC","sourcesContent":["import {\n existsSync,\n linkSync,\n readFileSync,\n readdirSync,\n renameSync,\n rmSync,\n statSync,\n} from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { Entry as PiEntry, JsonValue } from \"@earendil-works/pi-agent-core\";\nimport type { Usage } from \"@earendil-works/pi-ai\";\nimport { atomicWritePrivateFile } from \"../file-guards.js\";\n\nfunction jsonValue(value: unknown): JsonValue {\n return JSON.parse(JSON.stringify(value)) as JsonValue;\n}\n\nexport function optionalAnnotations(source: { details?: unknown; usage?: unknown }): {\n details?: JsonValue;\n usage?: Usage;\n} {\n return {\n details: source.details !== undefined ? jsonValue(source.details) : undefined,\n usage: source.usage as Usage | undefined,\n };\n}\n\nexport class V4FileWriter {\n readonly #lines: string[];\n #seq = 0;\n\n constructor(header: Record<string, unknown>) {\n this.#lines = [JSON.stringify(header)];\n }\n\n entry(entry: PiEntry): void {\n this.#lines.push(JSON.stringify({ kind: \"entry\", ...entry, seq: ++this.#seq }));\n }\n\n set(namespace: string, key: string, value: unknown): void {\n this.#write(\"value\", \"set\", namespace, key, value);\n }\n\n append(namespace: string, key: string, value: unknown): void {\n this.#write(\"list\", \"append\", namespace, key, value);\n }\n\n #write(kind: string, op: string, namespace: string, key: string, value: unknown): void {\n this.#lines.push(JSON.stringify({ kind, op, seq: ++this.#seq, namespace, key, value }));\n }\n\n toString(): string {\n return `${this.#lines.join(\"\\n\")}\\n`;\n }\n}\n\nfunction collectSessionFiles(\n dir: string,\n isCandidate: (path: string) => boolean,\n found: string[],\n): void {\n for (const entry of readdirSync(dir, { withFileTypes: true })) {\n const path = join(dir, entry.name);\n if (entry.isSymbolicLink()) continue;\n if (entry.isDirectory()) collectSessionFiles(path, isCandidate, found);\n else if (entry.name.endsWith(\".jsonl\") && isCandidate(path)) found.push(path);\n }\n}\n\nexport function findSessionFiles(root: string, isCandidate: (path: string) => boolean): string[] {\n if (!existsSync(root)) return [];\n const found: string[] = [];\n collectSessionFiles(root, isCandidate, found);\n return found;\n}\n\nfunction backupAlreadyLinked(sourcePath: string, backupPath: string): boolean {\n if (!existsSync(backupPath)) return false;\n const source = statSync(sourcePath);\n const backup = statSync(backupPath);\n if (source.dev === backup.dev && source.ino === backup.ino) return true;\n throw new Error(`Backup already exists: ${backupPath}`);\n}\n\nexport async function commitMigration(options: {\n filePath: string;\n sourceBytes: Buffer;\n encoded: string;\n tempPath: string;\n backupPath: string;\n verify: (candidatePath: string) => Promise<void>;\n}): Promise<void> {\n const { filePath, tempPath, backupPath } = options;\n const backupLinked = backupAlreadyLinked(filePath, backupPath);\n atomicWritePrivateFile(tempPath, options.encoded);\n try {\n await options.verify(tempPath);\n if (!readFileSync(filePath).equals(options.sourceBytes)) {\n throw new Error(\"source changed during migration\");\n }\n if (!backupLinked) linkSync(filePath, backupPath);\n renameSync(tempPath, filePath);\n } catch (error) {\n rmSync(tempPath, { force: true });\n throw new Error(`Migration failed for ${filePath}`, { cause: error });\n }\n}\n"]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Migration, SessionMigrationResult } from "./types.js";
|
|
2
2
|
export declare function isV3SessionFile(filePath: string): boolean;
|
|
3
3
|
export declare function migrateSessionFile(filePath: string, options?: {
|
|
4
4
|
dryRun?: boolean;
|
|
5
|
-
}): Promise<
|
|
5
|
+
}): Promise<SessionMigrationResult>;
|
|
6
6
|
export declare function findV3SessionFiles(root: string): string[];
|
|
7
|
-
|
|
7
|
+
export declare const sessionsV3Migration: Migration;
|
|
8
|
+
//# sourceMappingURL=sessions-v3.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessions-v3.d.ts","sourceRoot":"","sources":["../../src/migrations/sessions-v3.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,SAAS,EAAoB,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAmEtF,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAUzD;AAoVD,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAC7B,OAAO,CAAC,sBAAsB,CAAC,CAejC;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAEzD;AAED,eAAO,MAAM,mBAAmB,EAAE,SAShC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import { createBranchSummaryMessage, createCompactionSummaryMessage, createCustomMessage, } from "@earendil-works/pi-agent-core";
|
|
3
|
-
import { SessionStore } from "
|
|
4
|
-
import { commitMigration, findSessionFiles, optionalAnnotations, V4FileWriter, } from "./
|
|
3
|
+
import { SessionStore } from "../sessions/session-store.js";
|
|
4
|
+
import { commitMigration, findSessionFiles, optionalAnnotations, V4FileWriter, } from "./session-files.js";
|
|
5
5
|
function isFactEntry(entry) {
|
|
6
6
|
return entry.type === "session_info" || entry.type === "label" || entry.type === "leaf";
|
|
7
7
|
}
|
|
@@ -330,7 +330,7 @@ async function verifyMigratedFile(v4Path, source) {
|
|
|
330
330
|
}
|
|
331
331
|
export async function migrateSessionFile(filePath, options) {
|
|
332
332
|
if (!isV3SessionFile(filePath))
|
|
333
|
-
return { file: filePath, status: "already-
|
|
333
|
+
return { file: filePath, status: "already-current" };
|
|
334
334
|
const sourceBytes = readFileSync(filePath);
|
|
335
335
|
const source = readV3SessionFile(filePath);
|
|
336
336
|
if (options?.dryRun)
|
|
@@ -348,4 +348,14 @@ export async function migrateSessionFile(filePath, options) {
|
|
|
348
348
|
export function findV3SessionFiles(root) {
|
|
349
349
|
return findSessionFiles(root, isV3SessionFile);
|
|
350
350
|
}
|
|
351
|
-
|
|
351
|
+
export const sessionsV3Migration = Object.freeze({
|
|
352
|
+
id: "0004-sessions-v3",
|
|
353
|
+
summary: "convert v3 session files to the current Pi session format, keeping *.v3.bak",
|
|
354
|
+
async run(context) {
|
|
355
|
+
for (const file of findV3SessionFiles(context.workspaceRoot)) {
|
|
356
|
+
context.report(` session ${file}`);
|
|
357
|
+
await migrateSessionFile(file, { dryRun: context.dryRun });
|
|
358
|
+
}
|
|
359
|
+
},
|
|
360
|
+
});
|
|
361
|
+
//# sourceMappingURL=sessions-v3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessions-v3.js","sourceRoot":"","sources":["../../src/migrations/sessions-v3.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EACL,0BAA0B,EAC1B,8BAA8B,EAC9B,mBAAmB,GAIpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,YAAY,GACb,MAAM,oBAAoB,CAAC;AAgE5B,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,KAAK,CAAC,IAAI,KAAK,cAAc,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC;AAC1F,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAChD,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IA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AAI,kBAAkB,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC;YAC7D,OAAO,CAAC,MAAM,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC;YACpC,MAAM,kBAAkB,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { readFileSync } from \"node:fs\";\nimport {\n createBranchSummaryMessage,\n createCompactionSummaryMessage,\n createCustomMessage,\n type AgentMessage,\n type Entry as PiEntry,\n type JsonValue,\n} from \"@earendil-works/pi-agent-core\";\nimport { SessionStore } from \"../sessions/session-store.js\";\nimport {\n commitMigration,\n findSessionFiles,\n optionalAnnotations,\n V4FileWriter,\n} from \"./session-files.js\";\nimport type { Migration, MigrationContext, SessionMigrationResult } from \"./types.js\";\n\ninterface V3EntryBase {\n type: string;\n id: string;\n parentId: string | null;\n timestamp: string;\n}\n\ntype V3Entry = V3EntryBase &\n (\n | { type: \"message\"; message: AgentMessage }\n | { type: \"thinking_level_change\"; thinkingLevel: string }\n | { type: \"model_change\"; provider: string; modelId: string }\n | { type: \"active_tools_change\"; activeToolNames: string[] }\n | {\n type: \"compaction\";\n summary: string;\n firstKeptEntryId?: string;\n tokensBefore: number;\n retainedTail?: AgentMessage[];\n details?: unknown;\n usage?: unknown;\n }\n | {\n type: \"branch_summary\";\n fromId: string;\n summary: string;\n details?: unknown;\n usage?: unknown;\n }\n | { type: \"custom\"; customType: string; data?: unknown }\n | {\n type: \"custom_message\";\n customType: string;\n content: Parameters<typeof createCustomMessage>[1];\n display: boolean;\n details?: unknown;\n }\n | { type: \"label\"; targetId: string; label: string | undefined }\n | { type: \"session_info\"; name?: string }\n | { type: \"leaf\"; targetId: string | null }\n );\n\ntype V3Compaction = Extract<V3Entry, { type: \"compaction\" }>;\ntype V3CustomMessage = Extract<V3Entry, { type: \"custom_message\" }>;\n\ninterface V3SessionHeader {\n type: \"session\";\n version?: number;\n id: string;\n timestamp: string;\n cwd: string;\n parentSession?: string;\n parentSessionId?: string;\n [extra: string]: unknown;\n}\n\ninterface V3SessionFile {\n header: V3SessionHeader;\n entries: V3Entry[];\n}\n\nfunction isFactEntry(entry: V3Entry): boolean {\n return entry.type === \"session_info\" || entry.type === \"label\" || entry.type === \"leaf\";\n}\n\nexport function isV3SessionFile(filePath: string): boolean {\n try {\n const content = readFileSync(filePath, \"utf-8\");\n const firstLine = content.split(\"\\n\").find((line) => line.trim().length > 0);\n if (!firstLine) return false;\n const parsed = JSON.parse(firstLine) as { type?: unknown };\n return parsed.type === \"session\";\n } catch {\n return false;\n }\n}\n\nfunction parseJsonLines(filePath: string): Record<string, unknown>[] {\n const lines = readFileSync(filePath, \"utf-8\")\n .split(\"\\n\")\n .map((line) => line.trim())\n .filter((line) => line.length > 0);\n const records: Record<string, unknown>[] = [];\n for (const [index, line] of lines.entries()) {\n try {\n records.push(JSON.parse(line) as Record<string, unknown>);\n } catch (error) {\n if (index === lines.length - 1 && index > 0) continue;\n throw new Error(`Invalid JSON on line ${index + 1} of ${filePath}`, { cause: error });\n }\n }\n return records;\n}\n\nfunction dedupeEntries(records: Record<string, unknown>[]): V3Entry[] {\n const entriesById = new Map<string, V3Entry>();\n for (const record of records) {\n if (typeof record.type !== \"string\" || typeof record.id !== \"string\") continue;\n if (record.type === \"session\") continue;\n entriesById.set(record.id, record as unknown as V3Entry);\n }\n return [...entriesById.values()];\n}\n\nfunction readV3SessionFile(filePath: string): V3SessionFile {\n const records = parseJsonLines(filePath);\n const header = records[0];\n if (!header || header.type !== \"session\" || typeof header.id !== \"string\") {\n throw new Error(`Not a v3 session file: ${filePath}`);\n }\n return {\n header: header as unknown as V3SessionHeader,\n entries: dedupeEntries(records.slice(1)),\n };\n}\n\nfunction toEpochMillis(timestamp: string): number {\n const parsed = Date.parse(timestamp);\n return Number.isNaN(parsed) ? 0 : parsed;\n}\n\nfunction v3Branch(entries: V3Entry[], fromId: string | null): V3Entry[] {\n const byId = new Map(entries.map((entry) => [entry.id, entry]));\n const path: V3Entry[] = [];\n let currentId = fromId;\n while (currentId) {\n const entry = byId.get(currentId);\n if (!entry) break;\n path.push(entry);\n currentId = entry.parentId;\n }\n return path.toReversed();\n}\n\nfunction v3LeafId(entries: V3Entry[]): string | null {\n let leafId: string | null = null;\n for (const entry of entries) {\n leafId = entry.type === \"leaf\" ? entry.targetId : entry.id;\n }\n return leafId;\n}\n\nfunction customMessageOf(entry: V3CustomMessage): AgentMessage {\n return createCustomMessage(\n entry.customType,\n entry.content,\n entry.display,\n entry.details,\n toEpochMillis(entry.timestamp),\n );\n}\n\nfunction convertEntry(entry: V3Entry, entries: V3Entry[]): PiEntry | null {\n const base = {\n id: entry.id,\n seq: 0,\n parentId: resolveV4Parent(entry, entries),\n timestamp: toEpochMillis(entry.timestamp),\n };\n switch (entry.type) {\n case \"message\":\n return { ...base, type: \"message\", message: entry.message };\n case \"custom_message\":\n return { ...base, type: \"message\", message: customMessageOf(entry) };\n case \"thinking_level_change\":\n case \"model_change\":\n case \"active_tools_change\": {\n const { id: _id, parentId: _parentId, timestamp: _timestamp, type, ...data } = entry;\n return {\n ...base,\n type: \"custom\",\n customType: `mikan.legacy.${type}`,\n data: data as JsonValue,\n };\n }\n case \"compaction\":\n return {\n ...base,\n type: \"compaction\",\n summary: entry.summary,\n retainedTail: entry.retainedTail ?? compactionKeptMessages(entry, entries),\n tokensBefore: entry.tokensBefore,\n fromHook: false,\n ...optionalAnnotations(entry),\n } as unknown as PiEntry;\n case \"branch_summary\":\n return {\n ...base,\n type: \"branch_summary\",\n fromId: entry.fromId ?? null,\n summary: entry.summary,\n fromHook: false,\n ...optionalAnnotations(entry),\n } as unknown as PiEntry;\n case \"custom\":\n return {\n ...base,\n type: \"custom\",\n customType: entry.customType,\n data: entry.data as JsonValue | undefined,\n };\n default:\n return null;\n }\n}\n\nfunction resolveV4Parent(entry: V3Entry, entries: V3Entry[]): string | null {\n const byId = new Map(entries.map((item) => [item.id, item]));\n let parentId = entry.parentId;\n while (parentId !== null) {\n const parent = byId.get(parentId);\n if (!parent) return null;\n if (!isFactEntry(parent)) return parentId;\n parentId = parent.parentId;\n }\n return null;\n}\n\nfunction compactionKeptMessages(compaction: V3Compaction, entries: V3Entry[]): AgentMessage[] {\n if (!compaction.firstKeptEntryId) return [];\n const ancestors = v3Branch(entries, compaction.parentId);\n const keptStart = ancestors.findIndex((entry) => entry.id === compaction.firstKeptEntryId);\n if (keptStart === -1) return [];\n const messages: AgentMessage[] = [];\n for (const entry of ancestors.slice(keptStart)) {\n if (entry.type === \"message\") messages.push(entry.message);\n else if (entry.type === \"custom_message\") messages.push(customMessageOf(entry));\n }\n return messages;\n}\n\nfunction orderForReference(branch: V3Entry[]): {\n ordered: V3Entry[];\n repositioned?: V3Compaction;\n} {\n const lastIndex = branch.findLastIndex((entry) => entry.type === \"compaction\");\n const lastCompaction = branch[lastIndex] as V3Compaction | undefined;\n const firstKeptId = lastCompaction?.retainedTail ? undefined : lastCompaction?.firstKeptEntryId;\n const firstKeptIndex =\n firstKeptId === undefined ? -1 : branch.findIndex((entry) => entry.id === firstKeptId);\n if (firstKeptIndex === -1 || !lastCompaction) return { ordered: branch };\n return {\n ordered: [\n ...branch.slice(0, firstKeptIndex),\n lastCompaction,\n ...branch.filter((_, index) => index >= firstKeptIndex && index !== lastIndex),\n ],\n repositioned: lastCompaction,\n };\n}\n\nfunction emptiedCompaction(entry: V3Compaction): PiEntry {\n return {\n type: \"compaction\",\n id: entry.id,\n seq: 0,\n parentId: null,\n timestamp: toEpochMillis(entry.timestamp),\n summary: entry.summary,\n retainedTail: [],\n tokensBefore: entry.tokensBefore,\n fromHook: false,\n };\n}\n\nfunction referenceContextEntries(branch: V3Entry[]): PiEntry[] {\n const { ordered, repositioned } = orderForReference(branch);\n const converted: PiEntry[] = [];\n for (const entry of ordered) {\n const piEntry =\n repositioned === entry ? emptiedCompaction(repositioned) : convertEntry(entry, []);\n if (piEntry) converted.push(piEntry);\n }\n let previousId: string | null = null;\n for (const [index, entry] of converted.entries()) {\n entry.seq = index;\n entry.parentId = previousId;\n previousId = entry.id;\n }\n return converted;\n}\n\nfunction isCurrentContextMessage(message: AgentMessage): boolean {\n return (\n message.role !== \"assistant\" ||\n (message.stopReason !== \"error\" &&\n message.stopReason !== \"aborted\" &&\n message.stopReason !== \"deferred\")\n );\n}\n\nfunction contextMessagesOf(entry: PiEntry): AgentMessage[] {\n if (entry.type === \"message\") {\n return isCurrentContextMessage(entry.message) ? [entry.message] : [];\n }\n if (entry.type === \"compaction\") {\n return [\n createCompactionSummaryMessage(entry.summary, entry.tokensBefore, entry.timestamp),\n ...entry.retainedTail.filter(isCurrentContextMessage),\n ];\n }\n if (entry.type === \"branch_summary\" && entry.summary) {\n return [createBranchSummaryMessage(entry.summary, entry.fromId, entry.timestamp)];\n }\n return [];\n}\n\nfunction referenceContextMessages(entries: PiEntry[]): AgentMessage[] {\n const compactionIndex = entries.findLastIndex((entry) => entry.type === \"compaction\");\n const visible = compactionIndex === -1 ? entries : entries.slice(compactionIndex);\n return visible.flatMap(contextMessagesOf);\n}\n\nfunction buildV4Header(header: V3SessionHeader): Record<string, unknown> {\n return {\n v: 4,\n kind: \"header\",\n id: header.id,\n storageVersion: 1,\n createdAt: toEpochMillis(header.timestamp),\n cwd: header.cwd,\n parentSessionId: header.parentSessionId,\n legacyParentSessionPath: header.parentSession,\n };\n}\n\nfunction partitionEntries(entries: V3Entry[]): {\n tree: V3Entry[];\n name?: string;\n labels: Array<{ targetId: string; label: string | undefined }>;\n} {\n const tree: V3Entry[] = [];\n const labels: Array<{ targetId: string; label: string | undefined }> = [];\n let name: string | undefined;\n for (const entry of entries) {\n switch (entry.type) {\n case \"session_info\":\n name = entry.name?.trim() || undefined;\n break;\n case \"label\":\n labels.push({ targetId: entry.targetId, label: entry.label });\n break;\n case \"leaf\":\n break;\n default:\n tree.push(entry);\n }\n }\n return { tree, name, labels };\n}\n\nfunction resolveV4Leaf(entries: V3Entry[]): string | null {\n const byId = new Map(entries.map((entry) => [entry.id, entry]));\n let leafId = v3LeafId(entries);\n while (leafId !== null) {\n const target = byId.get(leafId);\n if (!target) return null;\n if (!isFactEntry(target)) return leafId;\n leafId = target.parentId;\n }\n return null;\n}\n\nfunction headerMetadata(header: V3SessionHeader): Record<string, JsonValue> | undefined {\n const {\n type: _type,\n version: _version,\n id: _id,\n timestamp: _timestamp,\n cwd: _cwd,\n parentSession,\n parentSessionId: _parentSessionId,\n ...extras\n } = header;\n const metadata: Record<string, JsonValue> = extras as Record<string, JsonValue>;\n if (parentSession !== undefined) metadata.parentSessionPath = parentSession;\n return Object.keys(metadata).length > 0 ? metadata : undefined;\n}\n\nfunction encodeV4File(file: V3SessionFile): string {\n const writer = new V4FileWriter(buildV4Header(file.header));\n const { tree, name, labels } = partitionEntries(file.entries);\n for (const entry of tree) {\n const converted = convertEntry(entry, file.entries);\n if (converted) writer.entry(converted);\n }\n writer.set(\"pi.branch.tip\", \"main\", resolveV4Leaf(file.entries));\n if (name !== undefined) writer.set(\"pi.session.name\", \"\", name);\n for (const { targetId, label } of labels) {\n if (label !== undefined) writer.set(\"pi.entry.label\", targetId, label);\n }\n const metadata = headerMetadata(file.header);\n if (metadata) writer.set(\"mikan\", \"metadata\", metadata);\n return writer.toString();\n}\n\nasync function verifyMigratedFile(v4Path: string, source: V3SessionFile): Promise<void> {\n const store = await SessionStore.inspect(v4Path);\n const migratedContext = await store.buildSessionContext();\n const branch = v3Branch(source.entries, v3LeafId(source.entries));\n const migrated = JSON.stringify(migratedContext.messages);\n const reference = JSON.stringify(referenceContextMessages(referenceContextEntries(branch)));\n if (migrated !== reference) {\n throw new Error(\"migrated context does not match the v3 reference context\");\n }\n const migratedName = await store.getSessionName();\n const v3Name = [...source.entries]\n .toReversed()\n .find((entry) => entry.type === \"session_info\")\n ?.name?.trim();\n if ((migratedName ?? \"\") !== (v3Name || \"\")) {\n throw new Error(\"migrated session name does not match the v3 session name\");\n }\n}\n\nexport async function migrateSessionFile(\n filePath: string,\n options?: { dryRun?: boolean },\n): Promise<SessionMigrationResult> {\n if (!isV3SessionFile(filePath)) return { file: filePath, status: \"already-current\" };\n const sourceBytes = readFileSync(filePath);\n const source = readV3SessionFile(filePath);\n if (options?.dryRun) return { file: filePath, status: \"migrated\", detail: \"dry run\" };\n\n await commitMigration({\n filePath,\n sourceBytes,\n encoded: encodeV4File(source),\n tempPath: `${filePath}.v4.tmp`,\n backupPath: `${filePath}.v3.bak`,\n verify: (candidatePath) => verifyMigratedFile(candidatePath, source),\n });\n return { file: filePath, status: \"migrated\" };\n}\n\nexport function findV3SessionFiles(root: string): string[] {\n return findSessionFiles(root, isV3SessionFile);\n}\n\nexport const sessionsV3Migration: Migration = Object.freeze({\n id: \"0004-sessions-v3\",\n summary: \"convert v3 session files to the current Pi session format, keeping *.v3.bak\",\n async run(context: MigrationContext): Promise<void> {\n for (const file of findV3SessionFiles(context.workspaceRoot)) {\n context.report(` session ${file}`);\n await migrateSessionFile(file, { dryRun: context.dryRun });\n }\n },\n});\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { SandboxConfig } from "../sandbox/types.js";
|
|
2
|
+
import type { PlatformName } from "../types.js";
|
|
3
|
+
export type DockerCli = (args: readonly string[]) => Promise<string>;
|
|
4
|
+
export interface MigrationContext {
|
|
5
|
+
readonly workspaceRoot: string;
|
|
6
|
+
readonly stateDir: string;
|
|
7
|
+
readonly dryRun: boolean;
|
|
8
|
+
readonly owners: ReadonlyMap<string, PlatformName>;
|
|
9
|
+
readonly enabledPlatforms: readonly PlatformName[];
|
|
10
|
+
readonly sandbox: SandboxConfig;
|
|
11
|
+
readonly piAgentDir: string;
|
|
12
|
+
readonly modelsPath: string;
|
|
13
|
+
readonly docker: DockerCli;
|
|
14
|
+
report(line: string): void;
|
|
15
|
+
}
|
|
16
|
+
export interface Migration {
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly summary: string;
|
|
19
|
+
run(context: MigrationContext): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
export interface AppliedMigration {
|
|
22
|
+
readonly id: string;
|
|
23
|
+
readonly appliedAt: string;
|
|
24
|
+
}
|
|
25
|
+
export interface SessionMigrationResult {
|
|
26
|
+
file: string;
|
|
27
|
+
status: "migrated" | "already-current";
|
|
28
|
+
detail?: string;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/migrations/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,MAAM,SAAS,GAAG,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAErE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACnD,QAAQ,CAAC,gBAAgB,EAAE,SAAS,YAAY,EAAE,CAAC;IACnD,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IAChC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,GAAG,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/C;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,UAAU,GAAG,iBAAiB,CAAC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/migrations/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SandboxConfig } from \"../sandbox/types.js\";\nimport type { PlatformName } from \"../types.js\";\n\nexport type DockerCli = (args: readonly string[]) => Promise<string>;\n\nexport interface MigrationContext {\n readonly workspaceRoot: string;\n readonly stateDir: string;\n readonly dryRun: boolean;\n readonly owners: ReadonlyMap<string, PlatformName>;\n readonly enabledPlatforms: readonly PlatformName[];\n readonly sandbox: SandboxConfig;\n readonly piAgentDir: string;\n readonly modelsPath: string;\n readonly docker: DockerCli;\n report(line: string): void;\n}\n\nexport interface Migration {\n readonly id: string;\n readonly summary: string;\n run(context: MigrationContext): Promise<void>;\n}\n\nexport interface AppliedMigration {\n readonly id: string;\n readonly appliedAt: string;\n}\n\nexport interface SessionMigrationResult {\n file: string;\n status: \"migrated\" | \"already-current\";\n detail?: string;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-events.d.ts","sourceRoot":"","sources":["../../src/migrations/workspace-events.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,SAAS,EAAoB,MAAM,YAAY,CAAC;AAU9D,eAAO,MAAM,wBAAwB,EAAE,SAyBrC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, rmdirSync, rmSync, } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { officeEventsDir, parseEventPayload } from "../events/index.js";
|
|
4
|
+
import { atomicWritePrivateFile } from "../file-guards.js";
|
|
5
|
+
import { assertPlatformName, createOfficeAddress, createWorkspace } from "../office/index.js";
|
|
6
|
+
function eventAddress(source, filename) {
|
|
7
|
+
const payload = parseEventPayload(readFileSync(source, "utf-8"), filename);
|
|
8
|
+
if (!payload.platform) {
|
|
9
|
+
throw new Error(`Event has no platform, so its conversation is unknown: ${source}`);
|
|
10
|
+
}
|
|
11
|
+
return createOfficeAddress(assertPlatformName(payload.platform), payload.conversationId);
|
|
12
|
+
}
|
|
13
|
+
export const workspaceEventsMigration = Object.freeze({
|
|
14
|
+
id: "0005-workspace-events",
|
|
15
|
+
summary: "move scheduled events from <workspace>/events into each office's host state",
|
|
16
|
+
async run(context) {
|
|
17
|
+
const legacyDir = join(context.workspaceRoot, "events");
|
|
18
|
+
if (!existsSync(legacyDir))
|
|
19
|
+
return;
|
|
20
|
+
const workspace = createWorkspace({ root: context.workspaceRoot, stateDir: context.stateDir });
|
|
21
|
+
const filenames = readdirSync(legacyDir)
|
|
22
|
+
.filter((name) => name.endsWith(".json") && lstatSync(join(legacyDir, name)).isFile())
|
|
23
|
+
.toSorted();
|
|
24
|
+
for (const filename of filenames) {
|
|
25
|
+
const source = join(legacyDir, filename);
|
|
26
|
+
const office = workspace.office(eventAddress(source, filename));
|
|
27
|
+
const targetDir = officeEventsDir(office);
|
|
28
|
+
const target = join(targetDir, filename);
|
|
29
|
+
if (existsSync(target))
|
|
30
|
+
throw new Error(`Event already exists in its office: ${target}`);
|
|
31
|
+
context.report(` event ${filename} -> ${office.key}`);
|
|
32
|
+
if (context.dryRun)
|
|
33
|
+
continue;
|
|
34
|
+
office.ensure();
|
|
35
|
+
mkdirSync(targetDir, { recursive: true, mode: 0o700 });
|
|
36
|
+
atomicWritePrivateFile(target, readFileSync(source, "utf-8"));
|
|
37
|
+
rmSync(source);
|
|
38
|
+
}
|
|
39
|
+
if (!context.dryRun && readdirSync(legacyDir).length === 0)
|
|
40
|
+
rmdirSync(legacyDir);
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=workspace-events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-events.js","sourceRoot":"","sources":["../../src/migrations/workspace-events.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,SAAS,EACT,WAAW,EACX,YAAY,EACZ,SAAS,EACT,MAAM,GACP,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAI9F,SAAS,YAAY,CAAC,MAAc,EAAE,QAAgB;IACpD,MAAM,OAAO,GAAG,iBAAiB,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAC;IAC3E,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,0DAA0D,MAAM,EAAE,CAAC,CAAC;IACtF,CAAC;IACD,OAAO,mBAAmB,CAAC,kBAAkB,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;AAC3F,CAAC;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAc,MAAM,CAAC,MAAM,CAAC;IAC/D,EAAE,EAAE,uBAAuB;IAC3B,OAAO,EAAE,6EAA6E;IACtF,KAAK,CAAC,GAAG,CAAC,OAAyB;QACjC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,Q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AAM,CAAC,MAAM,CAAC,CAAC;QACjB,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,WAAW,CAAC,SAAS,CAAC,CAAC,MAAM,KAAK,CAAC;YAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACnF,CAAC;CACF,CAAC,CAAC","sourcesContent":["import {\n existsSync,\n lstatSync,\n mkdirSync,\n readdirSync,\n readFileSync,\n rmdirSync,\n rmSync,\n} from \"node:fs\";\nimport { join } from \"node:path\";\nimport { officeEventsDir, parseEventPayload } from \"../events/index.js\";\nimport { atomicWritePrivateFile } from \"../file-guards.js\";\nimport { assertPlatformName, createOfficeAddress, createWorkspace } from \"../office/index.js\";\nimport type { OfficeAddress } from \"../types.js\";\nimport type { Migration, MigrationContext } from \"./types.js\";\n\nfunction eventAddress(source: string, filename: string): OfficeAddress {\n const payload = parseEventPayload(readFileSync(source, \"utf-8\"), filename);\n if (!payload.platform) {\n throw new Error(`Event has no platform, so its conversation is unknown: ${source}`);\n }\n return createOfficeAddress(assertPlatformName(payload.platform), payload.conversationId);\n}\n\nexport const workspaceEventsMigration: Migration = Object.freeze({\n id: \"0005-workspace-events\",\n summary: \"move scheduled events from <workspace>/events into each office's host state\",\n async run(context: MigrationContext): Promise<void> {\n const legacyDir = join(context.workspaceRoot, \"events\");\n if (!existsSync(legacyDir)) return;\n const workspace = createWorkspace({ root: context.workspaceRoot, stateDir: context.stateDir });\n const filenames = readdirSync(legacyDir)\n .filter((name) => name.endsWith(\".json\") && lstatSync(join(legacyDir, name)).isFile())\n .toSorted();\n for (const filename of filenames) {\n const source = join(legacyDir, filename);\n const office = workspace.office(eventAddress(source, filename));\n const targetDir = officeEventsDir(office);\n const target = join(targetDir, filename);\n if (existsSync(target)) throw new Error(`Event already exists in its office: ${target}`);\n context.report(` event ${filename} -> ${office.key}`);\n if (context.dryRun) continue;\n office.ensure();\n mkdirSync(targetDir, { recursive: true, mode: 0o700 });\n atomicWritePrivateFile(target, readFileSync(source, \"utf-8\"));\n rmSync(source);\n }\n if (!context.dryRun && readdirSync(legacyDir).length === 0) rmdirSync(legacyDir);\n },\n});\n"]}
|
package/dist/office/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ConversationEvent, ConversationMessage, OfficeAddress, OfficeKey,
|
|
2
|
-
import type { GithubConversationRef,
|
|
1
|
+
import type { ConversationEvent, ConversationMessage, OfficeAddress, OfficeKey, OfficeRecord, OfficeRegistryState, PlatformName } from "../types.js";
|
|
2
|
+
import type { GithubConversationRef, Workspace } from "./types.js";
|
|
3
3
|
export declare const OFFICE_LOG_FILENAME = "log.jsonl";
|
|
4
4
|
export declare function createOfficeAddress(platform: PlatformName, conversationId: string): OfficeAddress;
|
|
5
5
|
export declare function validateOfficeAddress(value: unknown): OfficeAddress;
|
|
@@ -41,34 +41,13 @@ export declare class OfficeRegistry {
|
|
|
41
41
|
constructor(stateDir: string, options?: OfficeRegistryOptions);
|
|
42
42
|
reload(): OfficeRegistryState;
|
|
43
43
|
getState(): OfficeRegistryState;
|
|
44
|
-
getMigration(rawConversationId: string): OfficeMigrationRecord | undefined;
|
|
45
|
-
enablePlatform(platform: PlatformName): OfficeRegistryState;
|
|
46
44
|
recordOffice(address: OfficeAddress): OfficeRecord;
|
|
47
45
|
getOffices(): readonly OfficeRecord[];
|
|
48
46
|
private findOffice;
|
|
49
|
-
prepareLegacyMigration(options: OfficeMigrationPreparation): OfficeMigrationRecord;
|
|
50
|
-
markMoving(rawConversationId: string): OfficeMigrationRecord;
|
|
51
|
-
markCommitted(rawConversationId: string): OfficeMigrationRecord;
|
|
52
|
-
markFailed(rawConversationId: string, error: string): OfficeMigrationRecord;
|
|
53
|
-
private resolveOwner;
|
|
54
|
-
private requireMigration;
|
|
55
|
-
private failRecord;
|
|
56
|
-
private replaceMigration;
|
|
57
47
|
private replaceState;
|
|
58
48
|
private withExclusiveLease;
|
|
59
49
|
private readState;
|
|
60
50
|
}
|
|
61
51
|
export declare function listRegisteredOffices(stateDir: string): readonly OfficeRecord[];
|
|
62
|
-
export declare function migrateLegacyOffices(options: {
|
|
63
|
-
workspaceRoot: string;
|
|
64
|
-
stateDir: string;
|
|
65
|
-
enabledPlatforms: readonly PlatformName[];
|
|
66
|
-
}): OfficeMigrationRunSummary;
|
|
67
|
-
export declare function formatUnmigratedOfficesError(summary: OfficeMigrationRunSummary): string;
|
|
68
|
-
export declare function buildContainerBindTranslator(options: {
|
|
69
|
-
offices: readonly OfficeRecord[];
|
|
70
|
-
workspaceRoot: string;
|
|
71
|
-
stateDir: string;
|
|
72
|
-
}): (bindSpec: string) => string;
|
|
73
52
|
export {};
|
|
74
53
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/office/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/office/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EACb,SAAS,EACT,YAAY,EACZ,mBAAmB,EACnB,YAAY,EACb,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,qBAAqB,EAAU,SAAS,EAAE,MAAM,YAAY,CAAC;AAI3E,eAAO,MAAM,mBAAmB,cAAc,CAAC;AAS/C,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,GAAG,aAAa,CAIjG;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,CASnE;AAMD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAG9D;AAOD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQ1D;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,aAAa,GAAG,SAAS,CAQ3D;AAED,wBAAgB,SAAS,CAAC,aAAa,EAA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