@geminixiang/mikan 1.0.0-beta.53 → 1.0.0-beta.55
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 +29 -0
- package/README.md +3 -2
- package/dist/adapters/commands/admin.d.ts.map +1 -0
- package/dist/{commands → adapters/commands}/admin.js +4 -8
- package/dist/adapters/commands/admin.js.map +1 -0
- package/dist/adapters/commands/login.d.ts.map +1 -0
- package/dist/adapters/commands/login.js +166 -0
- package/dist/adapters/commands/login.js.map +1 -0
- package/dist/adapters/commands/manifest.d.ts.map +1 -0
- package/dist/{commands → adapters/commands}/manifest.js +0 -7
- package/dist/adapters/commands/manifest.js.map +1 -0
- package/dist/{commands → adapters/commands}/model.d.ts +6 -0
- package/dist/adapters/commands/model.d.ts.map +1 -0
- package/dist/{commands → adapters/commands}/model.js +56 -44
- package/dist/adapters/commands/model.js.map +1 -0
- package/dist/adapters/commands/new.d.ts.map +1 -0
- package/dist/{commands → adapters/commands}/new.js +7 -8
- package/dist/adapters/commands/new.js.map +1 -0
- package/dist/adapters/commands/registry.d.ts.map +1 -0
- package/dist/{commands → adapters/commands}/registry.js +1 -3
- package/dist/adapters/commands/registry.js.map +1 -0
- package/dist/adapters/commands/sandbox.d.ts.map +1 -0
- package/dist/{commands → adapters/commands}/sandbox.js +22 -21
- package/dist/adapters/commands/sandbox.js.map +1 -0
- package/dist/adapters/commands/session-view.d.ts.map +1 -0
- package/dist/{commands → adapters/commands}/session-view.js +8 -11
- package/dist/adapters/commands/session-view.js.map +1 -0
- package/dist/{commands → adapters/commands}/types.d.ts +6 -6
- package/dist/adapters/commands/types.d.ts.map +1 -0
- package/dist/adapters/commands/types.js.map +1 -0
- package/dist/adapters/commands/utils.d.ts +14 -0
- package/dist/adapters/commands/utils.d.ts.map +1 -0
- package/dist/{commands → adapters/commands}/utils.js +18 -1
- package/dist/adapters/commands/utils.js.map +1 -0
- package/dist/adapters/discord/bot.d.ts.map +1 -1
- package/dist/adapters/discord/bot.js +4 -5
- package/dist/adapters/discord/bot.js.map +1 -1
- package/dist/adapters/github/bot.d.ts.map +1 -1
- package/dist/adapters/github/bot.js +3 -4
- package/dist/adapters/github/bot.js.map +1 -1
- package/dist/adapters/github/client.d.ts.map +1 -1
- package/dist/adapters/github/client.js +5 -18
- package/dist/adapters/github/client.js.map +1 -1
- package/dist/adapters/github/tool-pack.d.ts +1 -1
- package/dist/adapters/github/tool-pack.d.ts.map +1 -1
- package/dist/adapters/github/tool-pack.js.map +1 -1
- package/dist/adapters/github/tools/checks.js +1 -1
- package/dist/adapters/github/tools/checks.js.map +1 -1
- package/dist/adapters/github/tools/issue.js +1 -1
- package/dist/adapters/github/tools/issue.js.map +1 -1
- package/dist/adapters/github/tools/pr.js +1 -1
- package/dist/adapters/github/tools/pr.js.map +1 -1
- package/dist/adapters/github/tools/read.d.ts.map +1 -1
- package/dist/adapters/github/tools/read.js +53 -53
- package/dist/adapters/github/tools/read.js.map +1 -1
- package/dist/adapters/github/tools/review-reply.js +1 -1
- package/dist/adapters/github/tools/review-reply.js.map +1 -1
- package/dist/adapters/github/tools/sync.js +1 -1
- package/dist/adapters/github/tools/sync.js.map +1 -1
- package/dist/adapters/intake.d.ts +1 -1
- package/dist/adapters/intake.d.ts.map +1 -1
- package/dist/adapters/intake.js +2 -6
- package/dist/adapters/intake.js.map +1 -1
- package/dist/adapters/markdown-tables.d.ts +0 -13
- package/dist/adapters/markdown-tables.d.ts.map +1 -1
- package/dist/adapters/markdown-tables.js +26 -38
- package/dist/adapters/markdown-tables.js.map +1 -1
- package/dist/adapters/shared.js +1 -1
- package/dist/adapters/shared.js.map +1 -1
- package/dist/adapters/slack/bot.d.ts +7 -4
- package/dist/adapters/slack/bot.d.ts.map +1 -1
- package/dist/adapters/slack/bot.js +104 -122
- package/dist/adapters/slack/bot.js.map +1 -1
- package/dist/adapters/slack/response-lifecycle.d.ts.map +1 -1
- package/dist/adapters/slack/response-lifecycle.js +33 -25
- package/dist/adapters/slack/response-lifecycle.js.map +1 -1
- package/dist/adapters/slack/tool-pack.d.ts +1 -1
- package/dist/adapters/slack/tool-pack.d.ts.map +1 -1
- package/dist/adapters/slack/tool-pack.js.map +1 -1
- package/dist/adapters/slack/update-diagnostics.d.ts.map +1 -1
- package/dist/adapters/slack/update-diagnostics.js +8 -24
- package/dist/adapters/slack/update-diagnostics.js.map +1 -1
- package/dist/adapters/telegram/bot.d.ts.map +1 -1
- package/dist/adapters/telegram/bot.js +3 -4
- package/dist/adapters/telegram/bot.js.map +1 -1
- package/dist/adapters/types.d.ts +2 -4
- package/dist/adapters/types.d.ts.map +1 -1
- package/dist/adapters/types.js.map +1 -1
- package/dist/{web → adapters/web}/admin/portal.d.ts +3 -3
- package/dist/adapters/web/admin/portal.d.ts.map +1 -0
- package/dist/{web → adapters/web}/admin/portal.js +535 -709
- package/dist/adapters/web/admin/portal.js.map +1 -0
- package/dist/{web → adapters/web}/admin/provider-models.d.ts +1 -1
- package/dist/adapters/web/admin/provider-models.d.ts.map +1 -0
- package/dist/adapters/web/admin/provider-models.js.map +1 -0
- package/dist/{web → adapters/web}/admin/types.d.ts +5 -5
- package/dist/adapters/web/admin/types.d.ts.map +1 -0
- package/dist/adapters/web/admin/types.js.map +1 -0
- package/dist/adapters/web/login/oauth.d.ts.map +1 -0
- package/dist/{web → adapters/web}/login/oauth.js +50 -54
- package/dist/adapters/web/login/oauth.js.map +1 -0
- package/dist/{web → adapters/web}/login/portal.d.ts +2 -2
- package/dist/adapters/web/login/portal.d.ts.map +1 -0
- package/dist/{web → adapters/web}/login/portal.js +6 -6
- package/dist/adapters/web/login/portal.js.map +1 -0
- package/dist/{web → adapters/web}/login/types.d.ts +1 -1
- package/dist/adapters/web/login/types.d.ts.map +1 -0
- package/dist/adapters/web/login/types.js.map +1 -0
- package/dist/{web → adapters/web}/portal-shell.d.ts +2 -2
- package/dist/adapters/web/portal-shell.d.ts.map +1 -0
- package/dist/{web → adapters/web}/portal-shell.js +2 -2
- package/dist/adapters/web/portal-shell.js.map +1 -0
- package/dist/{web → adapters/web}/server.d.ts +5 -5
- package/dist/adapters/web/server.d.ts.map +1 -0
- package/dist/{web → adapters/web}/server.js +4 -7
- package/dist/adapters/web/server.js.map +1 -0
- package/dist/adapters/web/session-view/portal.d.ts.map +1 -0
- package/dist/{web → adapters/web}/session-view/portal.js +9 -9
- package/dist/adapters/web/session-view/portal.js.map +1 -0
- package/dist/{web → adapters/web}/session-view/types.d.ts +3 -3
- package/dist/adapters/web/session-view/types.d.ts.map +1 -0
- package/dist/adapters/web/session-view/types.js.map +1 -0
- package/dist/adapters/web/token-store.d.ts.map +1 -0
- package/dist/adapters/web/token-store.js.map +1 -0
- package/dist/adapters/web/types.d.ts.map +1 -0
- package/dist/adapters/web/types.js.map +1 -0
- package/dist/cli/arg-grammar.d.ts +24 -0
- package/dist/cli/arg-grammar.d.ts.map +1 -1
- package/dist/cli/arg-grammar.js +39 -8
- package/dist/cli/arg-grammar.js.map +1 -1
- package/dist/cli/boot.d.ts.map +1 -1
- package/dist/cli/boot.js +48 -62
- package/dist/cli/boot.js.map +1 -1
- package/dist/cli/download.d.ts.map +1 -1
- package/dist/cli/download.js +51 -54
- package/dist/cli/download.js.map +1 -1
- package/dist/cli/office.d.ts.map +1 -1
- package/dist/cli/office.js +9 -26
- package/dist/cli/office.js.map +1 -1
- package/dist/cli/onboard.d.ts.map +1 -1
- package/dist/cli/onboard.js +15 -11
- package/dist/cli/onboard.js.map +1 -1
- package/dist/cli/sessions.d.ts.map +1 -1
- package/dist/cli/sessions.js +49 -52
- package/dist/cli/sessions.js.map +1 -1
- package/dist/config.d.ts +4 -28
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +7 -112
- package/dist/config.js.map +1 -1
- package/dist/dream/index.d.ts.map +1 -1
- package/dist/dream/index.js +8 -2
- package/dist/dream/index.js.map +1 -1
- package/dist/dream/types.d.ts +1 -1
- package/dist/dream/types.d.ts.map +1 -1
- package/dist/dream/types.js.map +1 -1
- package/dist/env-manifest.d.ts +2 -0
- package/dist/env-manifest.d.ts.map +1 -1
- package/dist/env-manifest.js +29 -8
- package/dist/env-manifest.js.map +1 -1
- package/dist/events/index.d.ts +150 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/{harness/event-format.js → events/index.js} +80 -2
- package/dist/events/index.js.map +1 -0
- package/dist/{events.d.ts → events/watcher.d.ts} +4 -4
- package/dist/events/watcher.d.ts.map +1 -0
- package/dist/{events.js → events/watcher.js} +8 -8
- package/dist/events/watcher.js.map +1 -0
- package/dist/file-guards.d.ts.map +1 -0
- package/dist/file-guards.js.map +1 -0
- package/dist/harness/execution-env.d.ts +19 -0
- package/dist/harness/execution-env.d.ts.map +1 -0
- package/dist/harness/execution-env.js +262 -0
- package/dist/harness/execution-env.js.map +1 -0
- package/dist/harness/execution-resolver.d.ts +25 -0
- package/dist/harness/execution-resolver.d.ts.map +1 -0
- package/dist/{execution-resolver.js → harness/execution-resolver.js} +12 -21
- package/dist/harness/execution-resolver.js.map +1 -0
- package/dist/harness/index.d.ts +9 -9
- package/dist/harness/index.d.ts.map +1 -1
- package/dist/harness/index.js +8 -8
- package/dist/harness/index.js.map +1 -1
- package/dist/harness/mcp.d.ts +38 -0
- package/dist/harness/mcp.d.ts.map +1 -0
- package/dist/{mcp/loader.js → harness/mcp.js} +155 -6
- package/dist/harness/mcp.js.map +1 -0
- package/dist/harness/models.js +1 -1
- package/dist/harness/models.js.map +1 -1
- package/dist/harness/open-connector.d.ts.map +1 -0
- package/dist/{mcp → harness}/open-connector.js +1 -1
- package/dist/harness/open-connector.js.map +1 -0
- package/dist/{agent → harness}/presenter.d.ts +2 -9
- package/dist/harness/presenter.d.ts.map +1 -0
- package/dist/{agent → harness}/presenter.js +170 -146
- package/dist/harness/presenter.js.map +1 -0
- package/dist/{agent → harness}/prompt.d.ts +10 -3
- package/dist/harness/prompt.d.ts.map +1 -0
- package/dist/{agent → harness}/prompt.js +137 -41
- package/dist/harness/prompt.js.map +1 -0
- package/dist/harness/runner.d.ts +2 -109
- package/dist/harness/runner.d.ts.map +1 -1
- package/dist/harness/runner.js +499 -467
- package/dist/harness/runner.js.map +1 -1
- package/dist/harness/session.d.ts +119 -0
- package/dist/harness/session.d.ts.map +1 -0
- package/dist/harness/session.js +561 -0
- package/dist/harness/session.js.map +1 -0
- package/dist/harness/skills.d.ts +10 -2
- package/dist/harness/skills.d.ts.map +1 -1
- package/dist/harness/skills.js +62 -39
- package/dist/harness/skills.js.map +1 -1
- package/dist/harness/{subagent-runner.d.ts → subagent.d.ts} +25 -6
- package/dist/harness/subagent.d.ts.map +1 -0
- package/dist/harness/{subagent-runner.js → subagent.js} +106 -54
- package/dist/harness/subagent.js.map +1 -0
- package/dist/harness/tools/attach.d.ts.map +1 -0
- package/dist/harness/tools/attach.js.map +1 -0
- package/dist/{tools → harness/tools}/event.d.ts +3 -32
- package/dist/harness/tools/event.d.ts.map +1 -0
- package/dist/harness/tools/event.js +178 -0
- package/dist/harness/tools/event.js.map +1 -0
- package/dist/harness/tools/generate-image.d.ts.map +1 -0
- package/dist/harness/tools/generate-image.js.map +1 -0
- package/dist/harness/tools/host-fn-tool.d.ts.map +1 -0
- package/dist/harness/tools/host-fn-tool.js.map +1 -0
- package/dist/{tools → harness/tools}/index.d.ts +5 -6
- package/dist/harness/tools/index.d.ts.map +1 -0
- package/dist/{tools → harness/tools}/index.js +12 -16
- package/dist/harness/tools/index.js.map +1 -0
- package/dist/harness/tools/pi-tools.d.ts +18 -0
- package/dist/harness/tools/pi-tools.d.ts.map +1 -0
- package/dist/harness/tools/pi-tools.js +84 -0
- package/dist/harness/tools/pi-tools.js.map +1 -0
- package/dist/harness/tools/react.d.ts.map +1 -0
- package/dist/harness/tools/react.js.map +1 -0
- package/dist/{tools → harness/tools}/sandbox.d.ts +2 -2
- package/dist/harness/tools/sandbox.d.ts.map +1 -0
- package/dist/{tools → harness/tools}/sandbox.js +1 -1
- package/dist/harness/tools/sandbox.js.map +1 -0
- package/dist/{tools → harness/tools}/subagent.d.ts +28 -1
- package/dist/harness/tools/subagent.d.ts.map +1 -0
- package/dist/{tools → harness/tools}/subagent.js +218 -2
- package/dist/harness/tools/subagent.js.map +1 -0
- package/dist/{tools → harness/tools}/types.d.ts +0 -33
- package/dist/harness/tools/types.d.ts.map +1 -0
- package/dist/harness/tools/types.js.map +1 -0
- package/dist/harness/types.d.ts +180 -97
- package/dist/harness/types.d.ts.map +1 -1
- package/dist/harness/types.js +1 -1
- package/dist/harness/types.js.map +1 -1
- package/dist/index.d.ts +12 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/main.js +10 -12
- package/dist/main.js.map +1 -1
- package/dist/observability/index.d.ts +33 -0
- package/dist/observability/index.d.ts.map +1 -0
- package/dist/observability/index.js +256 -0
- package/dist/observability/index.js.map +1 -0
- package/dist/observability/instrument.js +7 -1
- package/dist/observability/instrument.js.map +1 -1
- package/dist/observability/otel.d.ts +10 -0
- package/dist/observability/otel.d.ts.map +1 -0
- package/dist/observability/otel.js +183 -0
- package/dist/observability/otel.js.map +1 -0
- package/dist/observability/sentry.d.ts +22 -5
- package/dist/observability/sentry.d.ts.map +1 -1
- package/dist/observability/sentry.js +68 -23
- package/dist/observability/sentry.js.map +1 -1
- package/dist/observability/types.d.ts +6 -2
- package/dist/observability/types.d.ts.map +1 -1
- package/dist/observability/types.js.map +1 -1
- package/dist/office/index.d.ts +2 -3
- package/dist/office/index.d.ts.map +1 -1
- package/dist/office/index.js +172 -140
- package/dist/office/index.js.map +1 -1
- package/dist/{workspace-projection/index.d.ts → office/projection.d.ts} +2 -2
- package/dist/office/projection.d.ts.map +1 -0
- package/dist/{workspace-projection/index.js → office/projection.js} +2 -2
- package/dist/office/projection.js.map +1 -0
- package/dist/office/types.d.ts +29 -2
- package/dist/office/types.d.ts.map +1 -1
- package/dist/office/types.js.map +1 -1
- package/dist/process-lifecycle.d.ts +1 -1
- package/dist/process-lifecycle.d.ts.map +1 -1
- package/dist/process-lifecycle.js +3 -3
- package/dist/process-lifecycle.js.map +1 -1
- package/dist/runtime/conversation-runtime.d.ts.map +1 -1
- package/dist/runtime/conversation-runtime.js +106 -107
- package/dist/runtime/conversation-runtime.js.map +1 -1
- package/dist/runtime/session-lifecycle.d.ts +10 -0
- package/dist/runtime/session-lifecycle.d.ts.map +1 -1
- package/dist/runtime/session-lifecycle.js +42 -24
- package/dist/runtime/session-lifecycle.js.map +1 -1
- package/dist/runtime/types.d.ts +3 -3
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/runtime/types.js.map +1 -1
- package/dist/sandbox/cloudflare.d.ts +1 -0
- package/dist/sandbox/cloudflare.d.ts.map +1 -1
- package/dist/sandbox/cloudflare.js +41 -50
- package/dist/sandbox/cloudflare.js.map +1 -1
- package/dist/sandbox/container.d.ts.map +1 -1
- package/dist/sandbox/container.js +7 -4
- package/dist/sandbox/container.js.map +1 -1
- package/dist/sandbox/host.d.ts.map +1 -1
- package/dist/sandbox/host.js +27 -35
- package/dist/sandbox/host.js.map +1 -1
- package/dist/sandbox/index.d.ts.map +1 -1
- package/dist/sandbox/index.js +8 -15
- package/dist/sandbox/index.js.map +1 -1
- package/dist/{provisioner.d.ts → sandbox/provisioner.d.ts} +2 -2
- package/dist/sandbox/provisioner.d.ts.map +1 -0
- package/dist/{provisioner.js → sandbox/provisioner.js} +3 -3
- package/dist/sandbox/provisioner.js.map +1 -0
- package/dist/sandbox/types.d.ts +2 -0
- package/dist/sandbox/types.d.ts.map +1 -1
- package/dist/sandbox/types.js.map +1 -1
- package/dist/sandbox/utils.d.ts +5 -0
- package/dist/sandbox/utils.d.ts.map +1 -1
- package/dist/sandbox/utils.js +14 -0
- package/dist/sandbox/utils.js.map +1 -1
- package/dist/sessions/chat-history-sync.d.ts.map +1 -1
- package/dist/sessions/chat-history-sync.js +72 -62
- package/dist/sessions/chat-history-sync.js.map +1 -1
- package/dist/sessions/migrate-common.d.ts +43 -0
- package/dist/sessions/migrate-common.d.ts.map +1 -0
- package/dist/sessions/migrate-common.js +99 -0
- package/dist/sessions/migrate-common.js.map +1 -0
- package/dist/sessions/migrate-pi-084.d.ts.map +1 -1
- package/dist/sessions/migrate-pi-084.js +152 -203
- package/dist/sessions/migrate-pi-084.js.map +1 -1
- package/dist/sessions/migrate-v3.d.ts +5 -0
- package/dist/sessions/migrate-v3.d.ts.map +1 -1
- package/dist/sessions/migrate-v3.js +161 -209
- package/dist/sessions/migrate-v3.js.map +1 -1
- package/dist/{harness → sessions}/session-store.d.ts +12 -1
- package/dist/sessions/session-store.d.ts.map +1 -0
- package/dist/{harness → sessions}/session-store.js +74 -35
- package/dist/sessions/session-store.js.map +1 -0
- package/dist/sessions/store.d.ts +1 -1
- package/dist/sessions/store.d.ts.map +1 -1
- package/dist/sessions/store.js +18 -17
- package/dist/sessions/store.js.map +1 -1
- package/dist/sessions/types.d.ts +40 -1
- package/dist/sessions/types.d.ts.map +1 -1
- package/dist/sessions/types.js +1 -1
- package/dist/sessions/types.js.map +1 -1
- package/dist/types.d.ts +7 -99
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/vault/index.d.ts.map +1 -1
- package/dist/vault/index.js +70 -53
- package/dist/vault/index.js.map +1 -1
- package/package.json +10 -4
- package/dist/adapters/slack/tools/attach.d.ts.map +0 -1
- package/dist/adapters/slack/tools/attach.js.map +0 -1
- package/dist/agent/catalog.d.ts +0 -22
- package/dist/agent/catalog.d.ts.map +0 -1
- package/dist/agent/catalog.js +0 -104
- package/dist/agent/catalog.js.map +0 -1
- package/dist/agent/execution.d.ts +0 -25
- package/dist/agent/execution.d.ts.map +0 -1
- package/dist/agent/execution.js +0 -171
- package/dist/agent/execution.js.map +0 -1
- package/dist/agent/presenter.d.ts.map +0 -1
- package/dist/agent/presenter.js.map +0 -1
- package/dist/agent/prompt.d.ts.map +0 -1
- package/dist/agent/prompt.js.map +0 -1
- package/dist/agent/runner.d.ts +0 -3
- package/dist/agent/runner.d.ts.map +0 -1
- package/dist/agent/runner.js +0 -452
- package/dist/agent/runner.js.map +0 -1
- package/dist/agent/types.d.ts +0 -101
- package/dist/agent/types.d.ts.map +0 -1
- package/dist/agent/types.js +0 -3
- package/dist/agent/types.js.map +0 -1
- package/dist/agent-events.d.ts +0 -6
- package/dist/agent-events.d.ts.map +0 -1
- package/dist/agent-events.js +0 -44
- package/dist/agent-events.js.map +0 -1
- package/dist/commands/admin.d.ts.map +0 -1
- package/dist/commands/admin.js.map +0 -1
- package/dist/commands/auto-reply.d.ts +0 -8
- package/dist/commands/auto-reply.d.ts.map +0 -1
- package/dist/commands/auto-reply.js +0 -65
- package/dist/commands/auto-reply.js.map +0 -1
- package/dist/commands/login.d.ts.map +0 -1
- package/dist/commands/login.js +0 -158
- package/dist/commands/login.js.map +0 -1
- package/dist/commands/manifest.d.ts.map +0 -1
- package/dist/commands/manifest.js.map +0 -1
- package/dist/commands/model.d.ts.map +0 -1
- package/dist/commands/model.js.map +0 -1
- package/dist/commands/new.d.ts.map +0 -1
- package/dist/commands/new.js.map +0 -1
- package/dist/commands/registry.d.ts.map +0 -1
- package/dist/commands/registry.js.map +0 -1
- package/dist/commands/sandbox.d.ts.map +0 -1
- package/dist/commands/sandbox.js.map +0 -1
- package/dist/commands/session-view.d.ts.map +0 -1
- package/dist/commands/session-view.js.map +0 -1
- package/dist/commands/types.d.ts.map +0 -1
- package/dist/commands/types.js.map +0 -1
- package/dist/commands/utils.d.ts +0 -11
- package/dist/commands/utils.d.ts.map +0 -1
- package/dist/commands/utils.js.map +0 -1
- package/dist/events.d.ts.map +0 -1
- package/dist/events.js.map +0 -1
- package/dist/execution-resolver.d.ts +0 -27
- package/dist/execution-resolver.d.ts.map +0 -1
- package/dist/execution-resolver.js.map +0 -1
- package/dist/harness/event-format.d.ts +0 -33
- package/dist/harness/event-format.d.ts.map +0 -1
- package/dist/harness/event-format.js.map +0 -1
- package/dist/harness/session-store.d.ts.map +0 -1
- package/dist/harness/session-store.js.map +0 -1
- package/dist/harness/settings.d.ts +0 -29
- package/dist/harness/settings.d.ts.map +0 -1
- package/dist/harness/settings.js +0 -40
- package/dist/harness/settings.js.map +0 -1
- package/dist/harness/subagent-runner.d.ts.map +0 -1
- package/dist/harness/subagent-runner.js.map +0 -1
- package/dist/harness/subagent-slots.d.ts +0 -28
- package/dist/harness/subagent-slots.d.ts.map +0 -1
- package/dist/harness/subagent-slots.js +0 -72
- package/dist/harness/subagent-slots.js.map +0 -1
- package/dist/harness/usage.d.ts +0 -11
- package/dist/harness/usage.d.ts.map +0 -1
- package/dist/harness/usage.js +0 -38
- package/dist/harness/usage.js.map +0 -1
- package/dist/mcp/catalog.d.ts +0 -5
- package/dist/mcp/catalog.d.ts.map +0 -1
- package/dist/mcp/catalog.js +0 -68
- package/dist/mcp/catalog.js.map +0 -1
- package/dist/mcp/loader.d.ts +0 -12
- package/dist/mcp/loader.d.ts.map +0 -1
- package/dist/mcp/loader.js.map +0 -1
- package/dist/mcp/open-connector.d.ts.map +0 -1
- package/dist/mcp/open-connector.js.map +0 -1
- package/dist/mcp/types.d.ts +0 -66
- package/dist/mcp/types.d.ts.map +0 -1
- package/dist/mcp/types.js.map +0 -1
- package/dist/packages/index.d.ts +0 -169
- package/dist/packages/index.d.ts.map +0 -1
- package/dist/packages/index.js +0 -721
- package/dist/packages/index.js.map +0 -1
- package/dist/packages/types.d.ts +0 -100
- package/dist/packages/types.d.ts.map +0 -1
- package/dist/packages/types.js.map +0 -1
- package/dist/provisioner.d.ts.map +0 -1
- package/dist/provisioner.js.map +0 -1
- package/dist/subagent-progress.d.ts +0 -39
- package/dist/subagent-progress.d.ts.map +0 -1
- package/dist/subagent-progress.js +0 -225
- package/dist/subagent-progress.js.map +0 -1
- package/dist/tools/bash.d.ts +0 -12
- package/dist/tools/bash.d.ts.map +0 -1
- package/dist/tools/bash.js +0 -80
- package/dist/tools/bash.js.map +0 -1
- package/dist/tools/edit.d.ts +0 -11
- package/dist/tools/edit.d.ts.map +0 -1
- package/dist/tools/edit.js +0 -132
- package/dist/tools/edit.js.map +0 -1
- package/dist/tools/event.d.ts.map +0 -1
- package/dist/tools/event.js +0 -255
- package/dist/tools/event.js.map +0 -1
- package/dist/tools/generate-image.d.ts.map +0 -1
- package/dist/tools/generate-image.js.map +0 -1
- package/dist/tools/host-fn-tool.d.ts.map +0 -1
- package/dist/tools/host-fn-tool.js.map +0 -1
- package/dist/tools/index.d.ts.map +0 -1
- package/dist/tools/index.js.map +0 -1
- package/dist/tools/react.d.ts.map +0 -1
- package/dist/tools/react.js.map +0 -1
- package/dist/tools/read.d.ts +0 -12
- package/dist/tools/read.d.ts.map +0 -1
- package/dist/tools/read.js +0 -140
- package/dist/tools/read.js.map +0 -1
- package/dist/tools/sandbox.d.ts.map +0 -1
- package/dist/tools/sandbox.js.map +0 -1
- package/dist/tools/subagent.d.ts.map +0 -1
- package/dist/tools/subagent.js.map +0 -1
- package/dist/tools/types.d.ts.map +0 -1
- package/dist/tools/types.js.map +0 -1
- package/dist/tools/write.d.ts +0 -10
- package/dist/tools/write.d.ts.map +0 -1
- package/dist/tools/write.js +0 -23
- package/dist/tools/write.js.map +0 -1
- package/dist/trigger.d.ts +0 -23
- package/dist/trigger.d.ts.map +0 -1
- package/dist/trigger.js +0 -97
- package/dist/trigger.js.map +0 -1
- package/dist/utils/file-guards.d.ts.map +0 -1
- package/dist/utils/file-guards.js.map +0 -1
- package/dist/web/admin/portal.d.ts.map +0 -1
- package/dist/web/admin/portal.js.map +0 -1
- package/dist/web/admin/provider-models.d.ts.map +0 -1
- package/dist/web/admin/provider-models.js.map +0 -1
- package/dist/web/admin/types.d.ts.map +0 -1
- package/dist/web/admin/types.js.map +0 -1
- package/dist/web/login/oauth.d.ts.map +0 -1
- package/dist/web/login/oauth.js.map +0 -1
- package/dist/web/login/portal.d.ts.map +0 -1
- package/dist/web/login/portal.js.map +0 -1
- package/dist/web/login/types.d.ts.map +0 -1
- package/dist/web/login/types.js.map +0 -1
- package/dist/web/portal-shell.d.ts.map +0 -1
- package/dist/web/portal-shell.js.map +0 -1
- package/dist/web/server.d.ts.map +0 -1
- package/dist/web/server.js.map +0 -1
- package/dist/web/session-view/portal.d.ts.map +0 -1
- package/dist/web/session-view/portal.js.map +0 -1
- package/dist/web/session-view/types.d.ts.map +0 -1
- package/dist/web/session-view/types.js +0 -2
- package/dist/web/session-view/types.js.map +0 -1
- package/dist/web/token-store.d.ts.map +0 -1
- package/dist/web/token-store.js.map +0 -1
- package/dist/web/types.d.ts.map +0 -1
- package/dist/web/types.js +0 -2
- package/dist/web/types.js.map +0 -1
- package/dist/workspace-projection/index.d.ts.map +0 -1
- package/dist/workspace-projection/index.js.map +0 -1
- package/dist/workspace-projection/types.d.ts +0 -29
- package/dist/workspace-projection/types.d.ts.map +0 -1
- package/dist/workspace-projection/types.js +0 -2
- package/dist/workspace-projection/types.js.map +0 -1
- /package/dist/{commands → adapters/commands}/admin.d.ts +0 -0
- /package/dist/{commands → adapters/commands}/login.d.ts +0 -0
- /package/dist/{commands → adapters/commands}/manifest.d.ts +0 -0
- /package/dist/{commands → adapters/commands}/new.d.ts +0 -0
- /package/dist/{commands → adapters/commands}/registry.d.ts +0 -0
- /package/dist/{commands → adapters/commands}/sandbox.d.ts +0 -0
- /package/dist/{commands → adapters/commands}/session-view.d.ts +0 -0
- /package/dist/{commands → adapters/commands}/types.js +0 -0
- /package/dist/{web → adapters/web}/admin/provider-models.js +0 -0
- /package/dist/{mcp → adapters/web/admin}/types.js +0 -0
- /package/dist/{web → adapters/web}/login/oauth.d.ts +0 -0
- /package/dist/{packages → adapters/web/login}/types.js +0 -0
- /package/dist/{web → adapters/web}/session-view/portal.d.ts +0 -0
- /package/dist/{tools → adapters/web/session-view}/types.js +0 -0
- /package/dist/{web → adapters/web}/token-store.d.ts +0 -0
- /package/dist/{web → adapters/web}/token-store.js +0 -0
- /package/dist/{web → adapters/web}/types.d.ts +0 -0
- /package/dist/{web/admin → adapters/web}/types.js +0 -0
- /package/dist/{utils/file-guards.d.ts → file-guards.d.ts} +0 -0
- /package/dist/{utils/file-guards.js → file-guards.js} +0 -0
- /package/dist/{mcp → harness}/open-connector.d.ts +0 -0
- /package/dist/{adapters/slack → harness}/tools/attach.d.ts +0 -0
- /package/dist/{adapters/slack → harness}/tools/attach.js +0 -0
- /package/dist/{tools → harness/tools}/generate-image.d.ts +0 -0
- /package/dist/{tools → harness/tools}/generate-image.js +0 -0
- /package/dist/{tools → harness/tools}/host-fn-tool.d.ts +0 -0
- /package/dist/{tools → harness/tools}/host-fn-tool.js +0 -0
- /package/dist/{tools → harness/tools}/react.d.ts +0 -0
- /package/dist/{tools → harness/tools}/react.js +0 -0
- /package/dist/{web/login → harness/tools}/types.js +0 -0
|
@@ -16,11 +16,14 @@
|
|
|
16
16
|
* v3 context computed by the reference converter below. The original file
|
|
17
17
|
* is kept beside the migrated one as `<name>.v3.bak`.
|
|
18
18
|
*/
|
|
19
|
-
import {
|
|
20
|
-
import { join } from "node:path";
|
|
19
|
+
import { readFileSync } from "node:fs";
|
|
21
20
|
import { createBranchSummaryMessage, createCompactionSummaryMessage, createCustomMessage, } from "@earendil-works/pi-agent-core";
|
|
22
|
-
import { SessionStore } from "
|
|
23
|
-
import {
|
|
21
|
+
import { SessionStore } from "./session-store.js";
|
|
22
|
+
import { commitMigration, findSessionFiles, optionalAnnotations, V4FileWriter, } from "./migrate-common.js";
|
|
23
|
+
/** `session_info`, `label` and `leaf` become v4 values, not tree entries. */
|
|
24
|
+
function isFactEntry(entry) {
|
|
25
|
+
return entry.type === "session_info" || entry.type === "label" || entry.type === "leaf";
|
|
26
|
+
}
|
|
24
27
|
/** Whether a file's first non-empty line is a v3 session header. */
|
|
25
28
|
export function isV3SessionFile(filePath) {
|
|
26
29
|
try {
|
|
@@ -35,8 +38,8 @@ export function isV3SessionFile(filePath) {
|
|
|
35
38
|
return false;
|
|
36
39
|
}
|
|
37
40
|
}
|
|
38
|
-
/**
|
|
39
|
-
function
|
|
41
|
+
/** Parse every non-empty line, tolerating a torn final line (crash tail). */
|
|
42
|
+
function parseJsonLines(filePath) {
|
|
40
43
|
const lines = readFileSync(filePath, "utf-8")
|
|
41
44
|
.split("\n")
|
|
42
45
|
.map((line) => line.trim())
|
|
@@ -52,24 +55,37 @@ function readV3SessionFile(filePath) {
|
|
|
52
55
|
throw new Error(`Invalid JSON on line ${index + 1} of ${filePath}`, { cause: error });
|
|
53
56
|
}
|
|
54
57
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
return records;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Crash-era v3 files can contain duplicated lines (a retried append wrote the
|
|
62
|
+
* header+entry pair twice). The v3 runtime read entries into a Map, so
|
|
63
|
+
* duplicates were silently collapsed; v4 rejects duplicate mutation ids.
|
|
64
|
+
* Reproduce the v3 Map semantics: a repeated id replaces its payload while
|
|
65
|
+
* retaining the id's original insertion position.
|
|
66
|
+
*/
|
|
67
|
+
function dedupeEntries(records) {
|
|
64
68
|
const entriesById = new Map();
|
|
65
|
-
for (const record of records
|
|
69
|
+
for (const record of records) {
|
|
66
70
|
if (typeof record.type !== "string" || typeof record.id !== "string")
|
|
67
71
|
continue;
|
|
68
72
|
if (record.type === "session")
|
|
69
73
|
continue;
|
|
70
74
|
entriesById.set(record.id, record);
|
|
71
75
|
}
|
|
72
|
-
return
|
|
76
|
+
return [...entriesById.values()];
|
|
77
|
+
}
|
|
78
|
+
/** Read a v3 session file, ignoring a torn final line (crash tail). */
|
|
79
|
+
function readV3SessionFile(filePath) {
|
|
80
|
+
const records = parseJsonLines(filePath);
|
|
81
|
+
const header = records[0];
|
|
82
|
+
if (!header || header.type !== "session" || typeof header.id !== "string") {
|
|
83
|
+
throw new Error(`Not a v3 session file: ${filePath}`);
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
header: header,
|
|
87
|
+
entries: dedupeEntries(records.slice(1)),
|
|
88
|
+
};
|
|
73
89
|
}
|
|
74
90
|
function toEpochMillis(timestamp) {
|
|
75
91
|
const parsed = Date.parse(timestamp);
|
|
@@ -96,6 +112,10 @@ function v3LeafId(entries) {
|
|
|
96
112
|
}
|
|
97
113
|
return leafId;
|
|
98
114
|
}
|
|
115
|
+
/** v3 kept `custom_message` payloads out of band; v4 stores a real message. */
|
|
116
|
+
function customMessageOf(entry) {
|
|
117
|
+
return createCustomMessage(entry.customType, entry.content, entry.display, entry.details, toEpochMillis(entry.timestamp));
|
|
118
|
+
}
|
|
99
119
|
/** Convert one tree-shaping v3 entry to its v4 counterpart (facts excluded). */
|
|
100
120
|
function convertEntry(entry, entries) {
|
|
101
121
|
const base = {
|
|
@@ -108,11 +128,7 @@ function convertEntry(entry, entries) {
|
|
|
108
128
|
case "message":
|
|
109
129
|
return { ...base, type: "message", message: entry.message };
|
|
110
130
|
case "custom_message":
|
|
111
|
-
return {
|
|
112
|
-
...base,
|
|
113
|
-
type: "message",
|
|
114
|
-
message: createCustomMessage(entry.customType, entry.content, entry.display, entry.details, toEpochMillis(entry.timestamp)),
|
|
115
|
-
};
|
|
131
|
+
return { ...base, type: "message", message: customMessageOf(entry) };
|
|
116
132
|
case "thinking_level_change":
|
|
117
133
|
case "model_change":
|
|
118
134
|
case "active_tools_change": {
|
|
@@ -132,8 +148,7 @@ function convertEntry(entry, entries) {
|
|
|
132
148
|
retainedTail: entry.retainedTail ?? compactionKeptMessages(entry, entries),
|
|
133
149
|
tokensBefore: entry.tokensBefore,
|
|
134
150
|
fromHook: false,
|
|
135
|
-
...(entry
|
|
136
|
-
...(entry.usage !== undefined ? { usage: entry.usage } : {}),
|
|
151
|
+
...optionalAnnotations(entry),
|
|
137
152
|
};
|
|
138
153
|
case "branch_summary":
|
|
139
154
|
return {
|
|
@@ -142,8 +157,7 @@ function convertEntry(entry, entries) {
|
|
|
142
157
|
fromId: entry.fromId ?? null,
|
|
143
158
|
summary: entry.summary,
|
|
144
159
|
fromHook: false,
|
|
145
|
-
...(entry
|
|
146
|
-
...(entry.usage !== undefined ? { usage: entry.usage } : {}),
|
|
160
|
+
...optionalAnnotations(entry),
|
|
147
161
|
};
|
|
148
162
|
case "custom":
|
|
149
163
|
return {
|
|
@@ -169,9 +183,8 @@ function resolveV4Parent(entry, entries) {
|
|
|
169
183
|
const parent = byId.get(parentId);
|
|
170
184
|
if (!parent)
|
|
171
185
|
return null;
|
|
172
|
-
if (parent
|
|
186
|
+
if (!isFactEntry(parent))
|
|
173
187
|
return parentId;
|
|
174
|
-
}
|
|
175
188
|
parentId = parent.parentId;
|
|
176
189
|
}
|
|
177
190
|
return null;
|
|
@@ -191,60 +204,58 @@ function compactionKeptMessages(compaction, entries) {
|
|
|
191
204
|
for (const entry of ancestors.slice(keptStart)) {
|
|
192
205
|
if (entry.type === "message")
|
|
193
206
|
messages.push(entry.message);
|
|
194
|
-
else if (entry.type === "custom_message")
|
|
195
|
-
messages.push(
|
|
196
|
-
}
|
|
207
|
+
else if (entry.type === "custom_message")
|
|
208
|
+
messages.push(customMessageOf(entry));
|
|
197
209
|
}
|
|
198
210
|
return messages;
|
|
199
211
|
}
|
|
200
212
|
// ── reference converter (verification oracle) ───────────────────────────────
|
|
201
213
|
/**
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
* runtime shim did before mikan moved to native v4 files, and serves as
|
|
206
|
-
* the verification oracle for migrated output.
|
|
214
|
+
* Reorder a v3 branch the way the pi-0.83 context shim did: the last
|
|
215
|
+
* compaction moves ahead of its kept range. The branch is returned unchanged
|
|
216
|
+
* when there is no such compaction or it already carries a `retainedTail`.
|
|
207
217
|
*/
|
|
208
|
-
function
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
lastCompactionIndex = i;
|
|
213
|
-
break;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
const lastCompaction = branch[lastCompactionIndex];
|
|
217
|
-
const firstKeptId = lastCompaction && !lastCompaction.retainedTail ? lastCompaction.firstKeptEntryId : undefined;
|
|
218
|
+
function orderForReference(branch) {
|
|
219
|
+
const lastIndex = branch.findLastIndex((entry) => entry.type === "compaction");
|
|
220
|
+
const lastCompaction = branch[lastIndex];
|
|
221
|
+
const firstKeptId = lastCompaction?.retainedTail ? undefined : lastCompaction?.firstKeptEntryId;
|
|
218
222
|
const firstKeptIndex = firstKeptId === undefined ? -1 : branch.findIndex((entry) => entry.id === firstKeptId);
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
ordered
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
223
|
+
if (firstKeptIndex === -1 || !lastCompaction)
|
|
224
|
+
return { ordered: branch };
|
|
225
|
+
return {
|
|
226
|
+
ordered: [
|
|
227
|
+
...branch.slice(0, firstKeptIndex),
|
|
228
|
+
lastCompaction,
|
|
229
|
+
...branch.filter((_, index) => index >= firstKeptIndex && index !== lastIndex),
|
|
230
|
+
],
|
|
231
|
+
repositioned: lastCompaction,
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
/** A repositioned compaction drops its kept range: the range now follows it. */
|
|
235
|
+
function emptiedCompaction(entry) {
|
|
236
|
+
return {
|
|
237
|
+
type: "compaction",
|
|
238
|
+
id: entry.id,
|
|
239
|
+
seq: 0,
|
|
240
|
+
parentId: null,
|
|
241
|
+
timestamp: toEpochMillis(entry.timestamp),
|
|
242
|
+
summary: entry.summary,
|
|
243
|
+
retainedTail: [],
|
|
244
|
+
tokensBefore: entry.tokensBefore,
|
|
245
|
+
fromHook: false,
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Convert a v3 branch to v4 entries with the pi-0.83 context semantics, so
|
|
250
|
+
* pi's v4 transform reproduces the v3 context exactly. This mirrors what the
|
|
251
|
+
* runtime shim did before mikan moved to native v4 files, and serves as the
|
|
252
|
+
* verification oracle for migrated output.
|
|
253
|
+
*/
|
|
254
|
+
function referenceContextEntries(branch) {
|
|
255
|
+
const { ordered, repositioned } = orderForReference(branch);
|
|
231
256
|
const converted = [];
|
|
232
257
|
for (const entry of ordered) {
|
|
233
|
-
|
|
234
|
-
converted.push({
|
|
235
|
-
type: "compaction",
|
|
236
|
-
id: entry.id,
|
|
237
|
-
seq: 0,
|
|
238
|
-
parentId: null,
|
|
239
|
-
timestamp: toEpochMillis(entry.timestamp),
|
|
240
|
-
summary: entry.summary,
|
|
241
|
-
retainedTail: [],
|
|
242
|
-
tokensBefore: entry.tokensBefore,
|
|
243
|
-
fromHook: false,
|
|
244
|
-
});
|
|
245
|
-
continue;
|
|
246
|
-
}
|
|
247
|
-
const piEntry = convertEntry(entry, []);
|
|
258
|
+
const piEntry = repositioned === entry ? emptiedCompaction(repositioned) : convertEntry(entry, []);
|
|
248
259
|
if (piEntry)
|
|
249
260
|
converted.push(piEntry);
|
|
250
261
|
}
|
|
@@ -262,25 +273,25 @@ function isCurrentContextMessage(message) {
|
|
|
262
273
|
message.stopReason !== "aborted" &&
|
|
263
274
|
message.stopReason !== "deferred"));
|
|
264
275
|
}
|
|
276
|
+
function contextMessagesOf(entry) {
|
|
277
|
+
if (entry.type === "message") {
|
|
278
|
+
return isCurrentContextMessage(entry.message) ? [entry.message] : [];
|
|
279
|
+
}
|
|
280
|
+
if (entry.type === "compaction") {
|
|
281
|
+
return [
|
|
282
|
+
createCompactionSummaryMessage(entry.summary, entry.tokensBefore, entry.timestamp),
|
|
283
|
+
...entry.retainedTail.filter(isCurrentContextMessage),
|
|
284
|
+
];
|
|
285
|
+
}
|
|
286
|
+
if (entry.type === "branch_summary" && entry.summary) {
|
|
287
|
+
return [createBranchSummaryMessage(entry.summary, entry.fromId, entry.timestamp)];
|
|
288
|
+
}
|
|
289
|
+
return [];
|
|
290
|
+
}
|
|
265
291
|
function referenceContextMessages(entries) {
|
|
266
292
|
const compactionIndex = entries.findLastIndex((entry) => entry.type === "compaction");
|
|
267
|
-
const visible = compactionIndex === -1
|
|
268
|
-
|
|
269
|
-
: [entries[compactionIndex], ...entries.slice(compactionIndex + 1)];
|
|
270
|
-
const messages = [];
|
|
271
|
-
for (const entry of visible) {
|
|
272
|
-
if (entry.type === "message") {
|
|
273
|
-
if (isCurrentContextMessage(entry.message))
|
|
274
|
-
messages.push(entry.message);
|
|
275
|
-
}
|
|
276
|
-
else if (entry.type === "compaction") {
|
|
277
|
-
messages.push(createCompactionSummaryMessage(entry.summary, entry.tokensBefore, entry.timestamp), ...entry.retainedTail.filter(isCurrentContextMessage));
|
|
278
|
-
}
|
|
279
|
-
else if (entry.type === "branch_summary" && entry.summary) {
|
|
280
|
-
messages.push(createBranchSummaryMessage(entry.summary, entry.fromId, entry.timestamp));
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
return messages;
|
|
293
|
+
const visible = compactionIndex === -1 ? entries : entries.slice(compactionIndex);
|
|
294
|
+
return visible.flatMap(contextMessagesOf);
|
|
284
295
|
}
|
|
285
296
|
// ── v4 encoding ─────────────────────────────────────────────────────────────
|
|
286
297
|
function buildV4Header(header) {
|
|
@@ -297,86 +308,68 @@ function buildV4Header(header) {
|
|
|
297
308
|
: {}),
|
|
298
309
|
};
|
|
299
310
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
const push = (write) => lines.push(JSON.stringify(write));
|
|
304
|
-
let name;
|
|
311
|
+
/** Split a v3 entry stream into tree entries and the facts v4 stores as values. */
|
|
312
|
+
function partitionEntries(entries) {
|
|
313
|
+
const tree = [];
|
|
305
314
|
const labels = [];
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
315
|
+
let name;
|
|
316
|
+
for (const entry of entries) {
|
|
317
|
+
switch (entry.type) {
|
|
318
|
+
case "session_info":
|
|
319
|
+
name = entry.name?.trim() || undefined;
|
|
320
|
+
break;
|
|
321
|
+
case "label":
|
|
322
|
+
labels.push({ targetId: entry.targetId, label: entry.label });
|
|
323
|
+
break;
|
|
324
|
+
case "leaf":
|
|
325
|
+
break;
|
|
326
|
+
default:
|
|
327
|
+
tree.push(entry);
|
|
314
328
|
}
|
|
315
|
-
if (entry.type === "leaf")
|
|
316
|
-
continue;
|
|
317
|
-
const converted = convertEntry(entry, file.entries);
|
|
318
|
-
if (!converted)
|
|
319
|
-
continue;
|
|
320
|
-
converted.seq = ++seq;
|
|
321
|
-
push({ kind: "entry", ...converted });
|
|
322
329
|
}
|
|
323
|
-
|
|
324
|
-
|
|
330
|
+
return { tree, name, labels };
|
|
331
|
+
}
|
|
332
|
+
/** The v4 branch tip: the v3 leaf, walked back past fact-only entries. */
|
|
333
|
+
function resolveV4Leaf(entries) {
|
|
334
|
+
const byId = new Map(entries.map((entry) => [entry.id, entry]));
|
|
335
|
+
let leafId = v3LeafId(entries);
|
|
325
336
|
while (leafId !== null) {
|
|
326
337
|
const target = byId.get(leafId);
|
|
327
|
-
if (!target)
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
if (target.type !== "session_info" && target.type !== "label" && target.type !== "leaf")
|
|
332
|
-
break;
|
|
338
|
+
if (!target)
|
|
339
|
+
return null;
|
|
340
|
+
if (!isFactEntry(target))
|
|
341
|
+
return leafId;
|
|
333
342
|
leafId = target.parentId;
|
|
334
343
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
key: "main",
|
|
341
|
-
value: leafId,
|
|
342
|
-
});
|
|
343
|
-
if (name !== undefined) {
|
|
344
|
-
push({
|
|
345
|
-
kind: "value",
|
|
346
|
-
op: "set",
|
|
347
|
-
seq: ++seq,
|
|
348
|
-
namespace: "pi.session.name",
|
|
349
|
-
key: "",
|
|
350
|
-
value: name,
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
for (const { targetId, label } of labels) {
|
|
354
|
-
if (label === undefined)
|
|
355
|
-
continue;
|
|
356
|
-
push({
|
|
357
|
-
kind: "value",
|
|
358
|
-
op: "set",
|
|
359
|
-
seq: ++seq,
|
|
360
|
-
namespace: "pi.entry.label",
|
|
361
|
-
key: targetId,
|
|
362
|
-
value: label,
|
|
363
|
-
});
|
|
364
|
-
}
|
|
365
|
-
const { type: _type, version: _version, id: _id, timestamp: _timestamp, cwd: _cwd, parentSession, parentSessionId: _parentSessionId, ...extras } = file.header;
|
|
344
|
+
return null;
|
|
345
|
+
}
|
|
346
|
+
/** Header fields v4 does not model survive as the durable `mikan/metadata` value. */
|
|
347
|
+
function headerMetadata(header) {
|
|
348
|
+
const { type: _type, version: _version, id: _id, timestamp: _timestamp, cwd: _cwd, parentSession, parentSessionId: _parentSessionId, ...extras } = header;
|
|
366
349
|
const metadata = extras;
|
|
367
350
|
if (parentSession !== undefined)
|
|
368
351
|
metadata.parentSessionPath = parentSession;
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
352
|
+
return Object.keys(metadata).length > 0 ? metadata : undefined;
|
|
353
|
+
}
|
|
354
|
+
function encodeV4File(file) {
|
|
355
|
+
const writer = new V4FileWriter(buildV4Header(file.header));
|
|
356
|
+
const { tree, name, labels } = partitionEntries(file.entries);
|
|
357
|
+
for (const entry of tree) {
|
|
358
|
+
const converted = convertEntry(entry, file.entries);
|
|
359
|
+
if (converted)
|
|
360
|
+
writer.entry(converted);
|
|
361
|
+
}
|
|
362
|
+
writer.set("pi.branch.tip", "main", resolveV4Leaf(file.entries));
|
|
363
|
+
if (name !== undefined)
|
|
364
|
+
writer.set("pi.session.name", "", name);
|
|
365
|
+
for (const { targetId, label } of labels) {
|
|
366
|
+
if (label !== undefined)
|
|
367
|
+
writer.set("pi.entry.label", targetId, label);
|
|
378
368
|
}
|
|
379
|
-
|
|
369
|
+
const metadata = headerMetadata(file.header);
|
|
370
|
+
if (metadata)
|
|
371
|
+
writer.set("mikan", "metadata", metadata);
|
|
372
|
+
return writer.toString();
|
|
380
373
|
}
|
|
381
374
|
// ── migration driver ────────────────────────────────────────────────────────
|
|
382
375
|
async function verifyMigratedFile(v4Path, source) {
|
|
@@ -402,15 +395,6 @@ async function verifyMigratedFile(v4Path, source) {
|
|
|
402
395
|
* the v3 reference semantics before it replaces the original; the original
|
|
403
396
|
* is preserved as `<file>.v3.bak`.
|
|
404
397
|
*/
|
|
405
|
-
function backupAlreadyLinked(sourcePath, backupPath) {
|
|
406
|
-
if (!existsSync(backupPath))
|
|
407
|
-
return false;
|
|
408
|
-
const source = statSync(sourcePath);
|
|
409
|
-
const backup = statSync(backupPath);
|
|
410
|
-
if (source.dev === backup.dev && source.ino === backup.ino)
|
|
411
|
-
return true;
|
|
412
|
-
throw new Error(`Backup already exists: ${backupPath}`);
|
|
413
|
-
}
|
|
414
398
|
export async function migrateSessionFile(filePath, options) {
|
|
415
399
|
if (!isV3SessionFile(filePath))
|
|
416
400
|
return { file: filePath, status: "already-v4" };
|
|
@@ -418,50 +402,18 @@ export async function migrateSessionFile(filePath, options) {
|
|
|
418
402
|
const source = readV3SessionFile(filePath);
|
|
419
403
|
if (options?.dryRun)
|
|
420
404
|
return { file: filePath, status: "migrated", detail: "dry run" };
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
if (!backupLinked)
|
|
430
|
-
linkSync(filePath, backupPath);
|
|
431
|
-
renameSync(tempPath, filePath);
|
|
432
|
-
}
|
|
433
|
-
catch (error) {
|
|
434
|
-
rmSync(tempPath, { force: true });
|
|
435
|
-
throw new Error(`Migration failed for ${filePath}`, { cause: error });
|
|
436
|
-
}
|
|
405
|
+
await commitMigration({
|
|
406
|
+
filePath,
|
|
407
|
+
sourceBytes,
|
|
408
|
+
encoded: encodeV4File(source),
|
|
409
|
+
tempPath: `${filePath}.v4.tmp`,
|
|
410
|
+
backupPath: `${filePath}.v3.bak`,
|
|
411
|
+
verify: (candidatePath) => verifyMigratedFile(candidatePath, source),
|
|
412
|
+
});
|
|
437
413
|
return { file: filePath, status: "migrated" };
|
|
438
414
|
}
|
|
439
415
|
/** Recursively find candidate session files (.jsonl with a v3 header). */
|
|
440
416
|
export function findV3SessionFiles(root) {
|
|
441
|
-
|
|
442
|
-
return [];
|
|
443
|
-
const found = [];
|
|
444
|
-
const walk = (dir) => {
|
|
445
|
-
for (const name of readdirSync(dir)) {
|
|
446
|
-
const path = join(dir, name);
|
|
447
|
-
let stats;
|
|
448
|
-
try {
|
|
449
|
-
stats = lstatSync(path);
|
|
450
|
-
}
|
|
451
|
-
catch {
|
|
452
|
-
continue;
|
|
453
|
-
}
|
|
454
|
-
if (stats.isSymbolicLink())
|
|
455
|
-
continue;
|
|
456
|
-
if (stats.isDirectory()) {
|
|
457
|
-
walk(path);
|
|
458
|
-
}
|
|
459
|
-
else if (name.endsWith(".jsonl") && isV3SessionFile(path)) {
|
|
460
|
-
found.push(path);
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
};
|
|
464
|
-
walk(root);
|
|
465
|
-
return found;
|
|
417
|
+
return findSessionFiles(root, isV3SessionFile);
|
|
466
418
|
}
|
|
467
419
|
//# sourceMappingURL=migrate-v3.js.map
|