@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
package/dist/packages/index.js
DELETED
|
@@ -1,721 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The packages module in one file: the package source grammar, git/local
|
|
3
|
-
* materialization, inspection, conversation-scope resolution with skill
|
|
4
|
-
* mounts, and the admin add/refresh/remove operations. Exported types live
|
|
5
|
-
* in `types.ts`.
|
|
6
|
-
*/
|
|
7
|
-
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
8
|
-
import { execFileSync } from "node:child_process";
|
|
9
|
-
import { createHash } from "node:crypto";
|
|
10
|
-
import { cpSync, existsSync, lstatSync, realpathSync, rmSync, statSync, writeFileSync, } from "node:fs";
|
|
11
|
-
import { ensureDirExists, readTextFileIfExists } from "../utils/file-guards.js";
|
|
12
|
-
import * as log from "../log.js";
|
|
13
|
-
import { officeStateDir } from "../office/index.js";
|
|
14
|
-
import { loadSkillsFromDir } from "../harness/index.js";
|
|
15
|
-
import { loadGlobalSettings, resolveConversationSettings } from "../config.js";
|
|
16
|
-
import { applyConversationSettings, applyGlobalSettings } from "../settings-mutation.js";
|
|
17
|
-
// ── Package source grammar ────────────────────────────────────────────────────
|
|
18
|
-
/**
|
|
19
|
-
* The package source grammar: one place that turns a human-written source
|
|
20
|
-
* string into a {@link ParsedSource}, and one place that decides when two
|
|
21
|
-
* sources are the same package ({@link sourceIdentity}).
|
|
22
|
-
*
|
|
23
|
-
* Only git and local-path sources are implemented. The tagged union and the
|
|
24
|
-
* identity function are the seams a future `npm:` source slots into: adding it
|
|
25
|
-
* means a new arm here and a new materializer, with nothing downstream —
|
|
26
|
-
* resolution, scope precedence, the portal — needing to know.
|
|
27
|
-
*
|
|
28
|
-
* Grammar:
|
|
29
|
-
*
|
|
30
|
-
* <locator>[@<ref>][#<subpath>]
|
|
31
|
-
*
|
|
32
|
-
* locator: https://… http://… ssh://… git://… file://…
|
|
33
|
-
* git@host:owner/repo
|
|
34
|
-
* git:<any of the above, or host/owner/repo shorthand>
|
|
35
|
-
* github:owner/repo
|
|
36
|
-
* /abs/path ./rel/path (local, used by reference)
|
|
37
|
-
*
|
|
38
|
-
* `@<ref>` is recognized only when what follows the last `@` contains no `/`
|
|
39
|
-
* and no `:` — otherwise the `@` belongs to the URL's authority
|
|
40
|
-
* (`git@github.com:…`). A consequence: refs containing a slash
|
|
41
|
-
* (`release/1.0`) cannot be written in the string form; pin to a tag or a
|
|
42
|
-
* commit sha instead. The admin portal takes the URL and the ref as separate
|
|
43
|
-
* inputs and assembles a canonical string, so this only constrains
|
|
44
|
-
* hand-edited settings.
|
|
45
|
-
*/
|
|
46
|
-
const PROTOCOL_PREFIXES = ["https://", "http://", "ssh://", "git://", "file://"];
|
|
47
|
-
const SCP_LIKE = /^[^@/\s]+@[^:/\s]+:/;
|
|
48
|
-
/**
|
|
49
|
-
* Parse a source string. Throws with a user-facing message rather than
|
|
50
|
-
* returning undefined: every caller (portal, settings load, CLI) needs to tell
|
|
51
|
-
* the human what was wrong with what they typed.
|
|
52
|
-
*/
|
|
53
|
-
export function parseSource(source) {
|
|
54
|
-
const trimmed = source.trim();
|
|
55
|
-
if (!trimmed)
|
|
56
|
-
throw new Error("Package source is empty");
|
|
57
|
-
const { rest: withoutSubpath, subpath } = splitSubpath(trimmed);
|
|
58
|
-
const { rest: locator, ref } = splitRef(withoutSubpath);
|
|
59
|
-
if (locator.startsWith("github:")) {
|
|
60
|
-
const repo = stripGitSuffix(locator.slice("github:".length).replace(/^\/+/, ""));
|
|
61
|
-
if (!repo.includes("/")) {
|
|
62
|
-
throw new Error(`github: source must be owner/repo, got ${JSON.stringify(locator)}`);
|
|
63
|
-
}
|
|
64
|
-
return gitSource(`https://github.com/${repo}.git`, ref, subpath);
|
|
65
|
-
}
|
|
66
|
-
if (locator.startsWith("git:")) {
|
|
67
|
-
const inner = locator.slice("git:".length);
|
|
68
|
-
if (isProtocolUrl(inner) || SCP_LIKE.test(inner))
|
|
69
|
-
return gitSource(inner, ref, subpath);
|
|
70
|
-
// Shorthand: host/owner/repo — only meaningful with the git: prefix,
|
|
71
|
-
// since bare host/owner/repo is ambiguous with a relative path.
|
|
72
|
-
if (!inner.includes("/")) {
|
|
73
|
-
throw new Error(`git: source must include a path, got ${JSON.stringify(locator)}`);
|
|
74
|
-
}
|
|
75
|
-
return gitSource(`https://${stripGitSuffix(inner)}.git`, ref, subpath);
|
|
76
|
-
}
|
|
77
|
-
if (isProtocolUrl(locator) || SCP_LIKE.test(locator))
|
|
78
|
-
return gitSource(locator, ref, subpath);
|
|
79
|
-
if (isAbsolute(locator) || locator.startsWith("./") || locator.startsWith("../")) {
|
|
80
|
-
if (ref)
|
|
81
|
-
throw new Error("A local path source cannot carry an @ref");
|
|
82
|
-
if (subpath)
|
|
83
|
-
throw new Error("A local path source cannot carry a #subpath");
|
|
84
|
-
return { type: "local", path: resolve(locator) };
|
|
85
|
-
}
|
|
86
|
-
throw new Error(`Unrecognized package source ${JSON.stringify(source)}. ` +
|
|
87
|
-
"Use a git URL, github:owner/repo, git:host/owner/repo, or an absolute/relative path.");
|
|
88
|
-
}
|
|
89
|
-
function gitSource(url, ref, subpath) {
|
|
90
|
-
return { type: "git", url, ...(ref ? { ref } : {}), ...(subpath ? { subpath } : {}) };
|
|
91
|
-
}
|
|
92
|
-
function isProtocolUrl(value) {
|
|
93
|
-
return PROTOCOL_PREFIXES.some((prefix) => value.startsWith(prefix));
|
|
94
|
-
}
|
|
95
|
-
function stripGitSuffix(value) {
|
|
96
|
-
return value.replace(/\.git$/, "").replace(/\/+$/, "");
|
|
97
|
-
}
|
|
98
|
-
function splitSubpath(source) {
|
|
99
|
-
const hash = source.indexOf("#");
|
|
100
|
-
if (hash === -1)
|
|
101
|
-
return { rest: source };
|
|
102
|
-
const subpath = source.slice(hash + 1).trim();
|
|
103
|
-
if (!subpath)
|
|
104
|
-
return { rest: source.slice(0, hash) };
|
|
105
|
-
assertSafeRelativePath(subpath, "#subpath");
|
|
106
|
-
return { rest: source.slice(0, hash), subpath };
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Split a trailing `@ref`. The `@` in `git@github.com:owner/repo` is part of
|
|
110
|
-
* the authority, not a ref, so a candidate only counts when its suffix looks
|
|
111
|
-
* like a bare ref (no `/`, no `:`).
|
|
112
|
-
*/
|
|
113
|
-
function splitRef(source) {
|
|
114
|
-
const at = source.lastIndexOf("@");
|
|
115
|
-
if (at <= 0)
|
|
116
|
-
return { rest: source };
|
|
117
|
-
const candidate = source.slice(at + 1);
|
|
118
|
-
if (!candidate || candidate.includes("/") || candidate.includes(":"))
|
|
119
|
-
return { rest: source };
|
|
120
|
-
return { rest: source.slice(0, at), ref: candidate };
|
|
121
|
-
}
|
|
122
|
-
/** Reject traversal and absolute escapes in the parts that become paths. */
|
|
123
|
-
function assertSafeRelativePath(value, label) {
|
|
124
|
-
if (isAbsolute(value) || value.split(/[\\/]/).some((segment) => segment === "..")) {
|
|
125
|
-
throw new Error(`${label} must be a relative path without '..': ${JSON.stringify(value)}`);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Identity of the package a source refers to — the key for deduplication and
|
|
130
|
-
* for letting a conversation's copy shadow the global one.
|
|
131
|
-
*
|
|
132
|
-
* Deliberate choices:
|
|
133
|
-
* - The ref is excluded: the same repo pinned to two refs in two scopes is one
|
|
134
|
-
* package installed twice, and the narrower scope wins.
|
|
135
|
-
* - The subpath is included: two skill packages living at different paths in one
|
|
136
|
-
* monorepo are two packages.
|
|
137
|
-
* - Transport is excluded: `git@github.com:o/r`, `https://github.com/o/r.git`
|
|
138
|
-
* and `ssh://git@github.com/o/r` all identify the same package, so mixing
|
|
139
|
-
* SSH and HTTPS spellings across scopes still dedups.
|
|
140
|
-
*/
|
|
141
|
-
export function sourceIdentity(parsed) {
|
|
142
|
-
if (parsed.type === "local")
|
|
143
|
-
return `local:${parsed.path}`;
|
|
144
|
-
const repo = gitRepoPath(parsed.url);
|
|
145
|
-
return parsed.subpath ? `git:${repo}#${parsed.subpath}` : `git:${repo}`;
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Transport-independent `<host>/<path>` of a git URL, lowercased host, no
|
|
149
|
-
* `.git` suffix, no credentials. It is the base of the on-disk clone layout,
|
|
150
|
-
* so it must stay free of anything that is not a safe path segment.
|
|
151
|
-
*/
|
|
152
|
-
export function gitRepoPath(url) {
|
|
153
|
-
let remainder = url;
|
|
154
|
-
for (const prefix of PROTOCOL_PREFIXES) {
|
|
155
|
-
if (remainder.startsWith(prefix)) {
|
|
156
|
-
remainder = remainder.slice(prefix.length);
|
|
157
|
-
break;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
// Drop any credentials in the authority (`user:pass@host`, `git@host`).
|
|
161
|
-
const scpMatch = /^([^@/\s]+@)?([^:/\s]+)[:/](.+)$/.exec(remainder);
|
|
162
|
-
if (!scpMatch)
|
|
163
|
-
return sanitizeRepoPath(stripGitSuffix(remainder));
|
|
164
|
-
const host = (scpMatch[2] ?? "").toLowerCase();
|
|
165
|
-
const path = stripGitSuffix((scpMatch[3] ?? "").replace(/^\/+/, ""));
|
|
166
|
-
return sanitizeRepoPath(`${host}/${path}`);
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* `file://` URLs used in tests and local mirrors have no host, so the repo path
|
|
170
|
-
* is an absolute filesystem path. Keep every segment filesystem-safe and drop
|
|
171
|
-
* traversal, since this string becomes a directory under the state dir.
|
|
172
|
-
*/
|
|
173
|
-
function sanitizeRepoPath(value) {
|
|
174
|
-
const segments = value
|
|
175
|
-
.split(/[\\/]/)
|
|
176
|
-
.map((segment) => segment.replace(/[^A-Za-z0-9._-]+/g, "-").replace(/^\.+$/, ""))
|
|
177
|
-
.filter((segment) => segment.length > 0);
|
|
178
|
-
if (segments.length === 0)
|
|
179
|
-
throw new Error(`Cannot derive a package path from ${value}`);
|
|
180
|
-
return segments.join("/");
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Canonical string form, used when writing settings so the stored value is
|
|
184
|
-
* stable regardless of how the human spelled it.
|
|
185
|
-
*/
|
|
186
|
-
export function formatSource(parsed) {
|
|
187
|
-
if (parsed.type === "local")
|
|
188
|
-
return parsed.path;
|
|
189
|
-
const ref = parsed.ref ? `@${parsed.ref}` : "";
|
|
190
|
-
const subpath = parsed.subpath ? `#${parsed.subpath}` : "";
|
|
191
|
-
return `${parsed.url}${ref}${subpath}`;
|
|
192
|
-
}
|
|
193
|
-
/** Git operations get a bounded wall clock so a hung remote cannot wedge a save. */
|
|
194
|
-
const GIT_TIMEOUT_MS = 120_000;
|
|
195
|
-
const MATERIALIZED_REF_FILE = "mikan-ref";
|
|
196
|
-
/**
|
|
197
|
-
* How far materialization may go to produce the package's files.
|
|
198
|
-
*
|
|
199
|
-
* - `offline`: use what is already on disk; never touch the network. This is
|
|
200
|
-
* what a conversation load uses, so no chat reply can ever wait on a remote.
|
|
201
|
-
* - `fetch`: clone a package that is not on disk yet, reuse an existing clone
|
|
202
|
-
* when it already has the requested ref, or switch it to a new ref. What the
|
|
203
|
-
* portal uses when a source is added.
|
|
204
|
-
* - `refresh`: additionally re-fetch an existing clone, resetting and cleaning
|
|
205
|
-
* it first. What the portal's Update action uses.
|
|
206
|
-
*
|
|
207
|
-
* One mode rather than two booleans: "re-fetch an existing clone but refuse to
|
|
208
|
-
* create a missing one" is not a state any caller wants, and expressing it
|
|
209
|
-
* should not be possible.
|
|
210
|
-
*/
|
|
211
|
-
/**
|
|
212
|
-
* Root of a scope's host-only assets: `<stateDir>/global` or
|
|
213
|
-
* `<stateDir>/conversations/<id>`. The two are isomorphic by design — both
|
|
214
|
-
* hold conversation-scoped settings and package checkouts.
|
|
215
|
-
*/
|
|
216
|
-
export function packageScopeDir(scope, address, stateDir) {
|
|
217
|
-
if (scope === "global")
|
|
218
|
-
return join(stateDir, "global");
|
|
219
|
-
if (!address)
|
|
220
|
-
throw new Error("A conversation-scoped package needs an office address");
|
|
221
|
-
return officeStateDir(stateDir, address);
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Where a git checkout lives.
|
|
225
|
-
*
|
|
226
|
-
* The unpinned checkout keeps the original path for compatibility. Explicit
|
|
227
|
-
* refs get a sibling keyed by the ref, so two refs can never reset each
|
|
228
|
-
* other's working tree; subpaths of one ref therefore still share a checkout.
|
|
229
|
-
*/
|
|
230
|
-
export function gitCloneDir(url, scopeDir, ref) {
|
|
231
|
-
const repoPath = gitRepoPath(url).split("/");
|
|
232
|
-
const repoName = repoPath[repoPath.length - 1] ?? "repo";
|
|
233
|
-
const parent = repoPath.slice(0, -1);
|
|
234
|
-
const checkoutName = ref === undefined || ref === "HEAD"
|
|
235
|
-
? repoName
|
|
236
|
-
: `${repoName}.mikan-${createHash("sha256").update(ref).digest("hex")}`;
|
|
237
|
-
return join(scopeDir, "git", ...parent, checkoutName);
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Materialize one source and return where its files ended up. Throws with a
|
|
241
|
-
* message meant to be shown to a human — callers render it next to the input
|
|
242
|
-
* that produced it.
|
|
243
|
-
*/
|
|
244
|
-
export function materializeSource(source, options) {
|
|
245
|
-
const parsed = parseSource(source);
|
|
246
|
-
const scopeDir = packageScopeDir(options.scope, options.address, options.stateDir);
|
|
247
|
-
const dir = parsed.type === "local"
|
|
248
|
-
? materializeLocal(parsed)
|
|
249
|
-
: materializeGit(parsed, scopeDir, options.mode ?? "fetch");
|
|
250
|
-
return {
|
|
251
|
-
source,
|
|
252
|
-
parsed,
|
|
253
|
-
identity: sourceIdentity(parsed),
|
|
254
|
-
dir,
|
|
255
|
-
scope: options.scope,
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
function materializeLocal(parsed) {
|
|
259
|
-
if (!existsSync(parsed.path)) {
|
|
260
|
-
throw new Error(`Path does not exist on the mikan host: ${parsed.path}`);
|
|
261
|
-
}
|
|
262
|
-
if (!statSync(parsed.path).isDirectory()) {
|
|
263
|
-
throw new Error(`Package path must be a directory: ${parsed.path}`);
|
|
264
|
-
}
|
|
265
|
-
return parsed.path;
|
|
266
|
-
}
|
|
267
|
-
function materializeGit(parsed, scopeDir, mode) {
|
|
268
|
-
const requestedRef = parsed.ref ?? "HEAD";
|
|
269
|
-
const cloneDir = gitCloneDir(parsed.url, scopeDir, requestedRef);
|
|
270
|
-
migrateLegacyCheckout(parsed.url, scopeDir, cloneDir, requestedRef);
|
|
271
|
-
const alreadyCloned = existsSync(join(cloneDir, ".git"));
|
|
272
|
-
const markerPath = join(cloneDir, ".git", MATERIALIZED_REF_FILE);
|
|
273
|
-
const recordedRef = alreadyCloned ? readTextFileIfExists(markerPath)?.trim() : undefined;
|
|
274
|
-
const canReuse = alreadyCloned &&
|
|
275
|
-
mode !== "refresh" &&
|
|
276
|
-
(recordedRef === requestedRef ||
|
|
277
|
-
(mode === "offline" &&
|
|
278
|
-
recordedRef === undefined &&
|
|
279
|
-
markerlessCheckoutMatchesRef(cloneDir, requestedRef)));
|
|
280
|
-
if (canReuse) {
|
|
281
|
-
return resolveSubpath(cloneDir, parsed);
|
|
282
|
-
}
|
|
283
|
-
if (mode === "offline") {
|
|
284
|
-
throw new Error(`Not fetched on this host yet: ${describeRef(parsed)}`);
|
|
285
|
-
}
|
|
286
|
-
// An incomplete checkout must not retain a marker from an earlier attempt:
|
|
287
|
-
// otherwise a retry could mistake an interrupted fetch or checkout for success.
|
|
288
|
-
if (alreadyCloned)
|
|
289
|
-
rmSync(markerPath, { force: true });
|
|
290
|
-
if (!alreadyCloned) {
|
|
291
|
-
// A leftover directory without .git means a previous attempt died partway.
|
|
292
|
-
if (existsSync(cloneDir))
|
|
293
|
-
rmSync(cloneDir, { recursive: true, force: true });
|
|
294
|
-
ensureDirExists(cloneDir);
|
|
295
|
-
git(cloneDir, ["init", "-q"]);
|
|
296
|
-
git(cloneDir, ["remote", "add", "origin", parsed.url]);
|
|
297
|
-
}
|
|
298
|
-
else {
|
|
299
|
-
// Reconcile: drop anything a previous checkout left behind so the new ref
|
|
300
|
-
// lands on a clean tree.
|
|
301
|
-
git(cloneDir, ["remote", "set-url", "origin", parsed.url]);
|
|
302
|
-
git(cloneDir, ["reset", "--hard", "-q"]);
|
|
303
|
-
git(cloneDir, ["clean", "-qfd"]);
|
|
304
|
-
}
|
|
305
|
-
// One fetch shape for every kind of ref — tag, branch, or commit sha — and
|
|
306
|
-
// `HEAD` for "whatever the remote's default branch is now".
|
|
307
|
-
try {
|
|
308
|
-
git(cloneDir, ["fetch", "--depth", "1", "origin", requestedRef]);
|
|
309
|
-
}
|
|
310
|
-
catch (err) {
|
|
311
|
-
if (!alreadyCloned)
|
|
312
|
-
rmSync(cloneDir, { recursive: true, force: true });
|
|
313
|
-
throw new Error(`Could not fetch ${describeRef(parsed)}: ${gitErrorText(err)}`, { cause: err });
|
|
314
|
-
}
|
|
315
|
-
git(cloneDir, ["checkout", "-q", "--detach", "FETCH_HEAD"]);
|
|
316
|
-
const dir = resolveSubpath(cloneDir, parsed);
|
|
317
|
-
// This is the completion marker, not merely a fetched-ref marker. Write it
|
|
318
|
-
// only after checkout and subpath validation have both succeeded.
|
|
319
|
-
writeFileSync(markerPath, `${requestedRef}\n`);
|
|
320
|
-
return dir;
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* Before keyed checkout paths existed, every ref used the legacy repo path.
|
|
324
|
-
* Copy a matching complete checkout on first use of its keyed path so offline
|
|
325
|
-
* loads keep working. Markerless legacy checkouts are accepted only when git
|
|
326
|
-
* can prove the requested ref is the checked-out commit; a different or
|
|
327
|
-
* unprovable pinned ref is rebuilt by fetch/refresh instead.
|
|
328
|
-
*/
|
|
329
|
-
function migrateLegacyCheckout(url, scopeDir, cloneDir, requestedRef) {
|
|
330
|
-
const legacyDir = gitCloneDir(url, scopeDir);
|
|
331
|
-
if (cloneDir === legacyDir || existsSync(cloneDir))
|
|
332
|
-
return;
|
|
333
|
-
const legacyMarker = join(legacyDir, ".git", MATERIALIZED_REF_FILE);
|
|
334
|
-
if (!existsSync(join(legacyDir, ".git")))
|
|
335
|
-
return;
|
|
336
|
-
const recordedRef = readTextFileIfExists(legacyMarker)?.trim();
|
|
337
|
-
if (recordedRef !== requestedRef) {
|
|
338
|
-
if (recordedRef !== undefined || !markerlessCheckoutMatchesRef(legacyDir, requestedRef)) {
|
|
339
|
-
return;
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
ensureDirExists(dirname(cloneDir));
|
|
343
|
-
cpSync(legacyDir, cloneDir, { recursive: true });
|
|
344
|
-
}
|
|
345
|
-
/**
|
|
346
|
-
* Legacy checkouts have no completion marker. Accept them offline only when
|
|
347
|
-
* the checkout is clean and the local git metadata identifies the requested
|
|
348
|
-
* commit/ref; never infer a pinned ref from HEAD alone.
|
|
349
|
-
*/
|
|
350
|
-
function markerlessCheckoutMatchesRef(cloneDir, requestedRef) {
|
|
351
|
-
let head;
|
|
352
|
-
try {
|
|
353
|
-
head = git(cloneDir, ["rev-parse", "--verify", "HEAD"]).trim();
|
|
354
|
-
if (!head || git(cloneDir, ["status", "--porcelain", "--untracked-files=no"]).trim()) {
|
|
355
|
-
return false;
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
catch {
|
|
359
|
-
return false;
|
|
360
|
-
}
|
|
361
|
-
if (requestedRef === "HEAD")
|
|
362
|
-
return true;
|
|
363
|
-
try {
|
|
364
|
-
if (git(cloneDir, ["rev-parse", "--verify", `${requestedRef}^{commit}`]).trim() === head) {
|
|
365
|
-
return true;
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
catch {
|
|
369
|
-
// A shallow legacy fetch may retain only FETCH_HEAD, not a local ref.
|
|
370
|
-
}
|
|
371
|
-
try {
|
|
372
|
-
if (git(cloneDir, ["symbolic-ref", "--quiet", "--short", "HEAD"]).trim() === requestedRef) {
|
|
373
|
-
return true;
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
catch {
|
|
377
|
-
// Detached checkouts do not have a symbolic branch.
|
|
378
|
-
}
|
|
379
|
-
const fetchHead = readTextFileIfExists(join(cloneDir, ".git", "FETCH_HEAD"));
|
|
380
|
-
if (!fetchHead)
|
|
381
|
-
return false;
|
|
382
|
-
return fetchHead.split("\n").some((line) => {
|
|
383
|
-
const match = /^(\w+)\s+.*(?:branch|tag) '([^']+)'/.exec(line);
|
|
384
|
-
return match?.[1] === head && match[2] === requestedRef;
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
|
-
function resolveSubpath(cloneDir, parsed) {
|
|
388
|
-
if (!parsed.subpath)
|
|
389
|
-
return cloneDir;
|
|
390
|
-
const dir = join(cloneDir, parsed.subpath);
|
|
391
|
-
if (!existsSync(dir)) {
|
|
392
|
-
throw new Error(`Subpath not found in repository: ${parsed.subpath}`);
|
|
393
|
-
}
|
|
394
|
-
// A symlink inside the repository must not select files outside the clone:
|
|
395
|
-
// the returned directory is mounted into the runtime, so follow
|
|
396
|
-
// links before deciding the subpath stayed inside.
|
|
397
|
-
const relation = relative(realpathSync(cloneDir), realpathSync(dir));
|
|
398
|
-
if (isAbsolute(relation) || relation === ".." || relation.startsWith(`..${sep}`)) {
|
|
399
|
-
throw new Error(`Subpath escapes repository: ${parsed.subpath}`);
|
|
400
|
-
}
|
|
401
|
-
return dir;
|
|
402
|
-
}
|
|
403
|
-
function git(cwd, args) {
|
|
404
|
-
return execFileSync("git", args, {
|
|
405
|
-
cwd,
|
|
406
|
-
timeout: GIT_TIMEOUT_MS,
|
|
407
|
-
encoding: "utf-8",
|
|
408
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
409
|
-
env: {
|
|
410
|
-
...process.env,
|
|
411
|
-
// Never block a portal save on an interactive credential prompt.
|
|
412
|
-
GIT_TERMINAL_PROMPT: "0",
|
|
413
|
-
GIT_SSH_COMMAND: process.env.GIT_SSH_COMMAND ?? "ssh -o BatchMode=yes -o ConnectTimeout=10",
|
|
414
|
-
},
|
|
415
|
-
});
|
|
416
|
-
}
|
|
417
|
-
function describeRef(parsed) {
|
|
418
|
-
return parsed.ref ? `${parsed.url} at ${parsed.ref}` : parsed.url;
|
|
419
|
-
}
|
|
420
|
-
/** Prefer git's stderr over the generic "Command failed" wrapper. */
|
|
421
|
-
function gitErrorText(err) {
|
|
422
|
-
if (err && typeof err === "object" && "stderr" in err) {
|
|
423
|
-
const stderr = err.stderr;
|
|
424
|
-
const text = typeof stderr === "string" ? stderr.trim() : "";
|
|
425
|
-
if (text)
|
|
426
|
-
return text.split("\n").slice(-3).join(" ");
|
|
427
|
-
}
|
|
428
|
-
return err instanceof Error ? err.message : String(err);
|
|
429
|
-
}
|
|
430
|
-
/**
|
|
431
|
-
* Inventory both scopes for one conversation. Never throws and never fetches:
|
|
432
|
-
* the portal renders this on page load, so it reports the current on-disk
|
|
433
|
-
* truth rather than going to the network behind the admin's back.
|
|
434
|
-
*/
|
|
435
|
-
export async function inspectConversationPackages(options) {
|
|
436
|
-
const conversationIdentities = new Set(declaredSources("conversation", options).map(safeIdentityOrEmpty).filter(Boolean));
|
|
437
|
-
return {
|
|
438
|
-
global: await Promise.all(declaredSources("global", options).map((source) => describe(source, "global", options, conversationIdentities))),
|
|
439
|
-
conversation: await Promise.all(declaredSources("conversation", options).map((source) => describe(source, "conversation", options, new Set()))),
|
|
440
|
-
};
|
|
441
|
-
}
|
|
442
|
-
/** Sources one scope declares, or an empty list when its settings are unreadable. */
|
|
443
|
-
function declaredSources(scope, options) {
|
|
444
|
-
try {
|
|
445
|
-
const settings = scope === "global" ? loadGlobalSettings() : resolveConversationSettings(options.office);
|
|
446
|
-
return settings.packages ?? [];
|
|
447
|
-
}
|
|
448
|
-
catch {
|
|
449
|
-
return [];
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
function safeIdentityOrEmpty(source) {
|
|
453
|
-
try {
|
|
454
|
-
return sourceIdentity(parseSource(source));
|
|
455
|
-
}
|
|
456
|
-
catch {
|
|
457
|
-
return "";
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
async function describe(source, scope, options, shadowedBy) {
|
|
461
|
-
const base = { source, scope, ready: false, skills: [] };
|
|
462
|
-
let identity;
|
|
463
|
-
try {
|
|
464
|
-
identity = sourceIdentity(parseSource(source));
|
|
465
|
-
}
|
|
466
|
-
catch (err) {
|
|
467
|
-
return { ...base, error: messageOf(err) };
|
|
468
|
-
}
|
|
469
|
-
let dir;
|
|
470
|
-
try {
|
|
471
|
-
dir = materializeSource(source, {
|
|
472
|
-
scope,
|
|
473
|
-
address: options.office.address,
|
|
474
|
-
stateDir: options.office.workspace.stateDir,
|
|
475
|
-
mode: "offline",
|
|
476
|
-
}).dir;
|
|
477
|
-
}
|
|
478
|
-
catch (err) {
|
|
479
|
-
return { ...base, error: messageOf(err) };
|
|
480
|
-
}
|
|
481
|
-
return {
|
|
482
|
-
...base,
|
|
483
|
-
ready: true,
|
|
484
|
-
dir,
|
|
485
|
-
...(shadowedBy.has(identity) ? { shadowed: true } : {}),
|
|
486
|
-
skills: contributedSkills(dir),
|
|
487
|
-
};
|
|
488
|
-
}
|
|
489
|
-
function contributedSkills(dir) {
|
|
490
|
-
const skillsDir = join(dir, "skills");
|
|
491
|
-
return loadSkillsFromDir({ dir: skillsDir, source: "package", rejectSymlinks: true }).skills.map((skill) => skill.name);
|
|
492
|
-
}
|
|
493
|
-
/** Conventional resource directory inside a package, mirroring pi's layout. */
|
|
494
|
-
const SKILLS_SUBDIR = "skills";
|
|
495
|
-
/** Slug length cap; long identities keep a digest tail instead of colliding. */
|
|
496
|
-
const SLUG_MAX_LENGTH = 96;
|
|
497
|
-
/**
|
|
498
|
-
* Where package resources appear inside the sandbox.
|
|
499
|
-
*
|
|
500
|
-
* Deliberately OUTSIDE `/workspace`. In `full` workspace-mount mode
|
|
501
|
-
* `/workspace` is the entire working directory, so a `/workspace/packages`
|
|
502
|
-
* mount would shadow a real `packages/` directory in the user's tree — mikan's
|
|
503
|
-
* own repository has one. Living outside also keeps
|
|
504
|
-
* `translateMountedRuntimePathToHost` correct by construction: it maps only
|
|
505
|
-
* the `/workspace` prefix and returns everything else untouched, so a package
|
|
506
|
-
* path can never be mistranslated into a host path that does not exist.
|
|
507
|
-
*
|
|
508
|
-
* Skills are referenced by absolute path in the system prompt, so the location
|
|
509
|
-
* costs nothing in usability.
|
|
510
|
-
*/
|
|
511
|
-
const PACKAGE_RUNTIME_ROOT = "/mikan/packages";
|
|
512
|
-
/** Runtime path a package's skills directory is mounted at. */
|
|
513
|
-
export function packageSkillRuntimeDir(slug) {
|
|
514
|
-
return `${PACKAGE_RUNTIME_ROOT}/${slug}/${SKILLS_SUBDIR}`;
|
|
515
|
-
}
|
|
516
|
-
/**
|
|
517
|
-
* Read-only mounts exposing every resolved package's skills to the sandbox.
|
|
518
|
-
*
|
|
519
|
-
* Read-only rather than read-write because the host owns these files: the
|
|
520
|
-
* directory is a git checkout that an update replaces wholesale, so an agent
|
|
521
|
-
* edit would be silently discarded on the next refresh. Making the filesystem
|
|
522
|
-
* refuse the write turns a confusing data-loss bug into an obvious error.
|
|
523
|
-
*
|
|
524
|
-
* This pure step consumes an already resolved package set and never reaches the network.
|
|
525
|
-
*/
|
|
526
|
-
export function conversationPackageSkillMounts(packages) {
|
|
527
|
-
return packages.skillDirs.flatMap(({ slug, dir }) => isNonSymlinkDirectory(dir)
|
|
528
|
-
? [{ source: dir, target: packageSkillRuntimeDir(slug), readOnly: true }]
|
|
529
|
-
: []);
|
|
530
|
-
}
|
|
531
|
-
/**
|
|
532
|
-
* Resolve the package set for one conversation. Reads both scopes' settings,
|
|
533
|
-
* dedups, and reports the directories to load from.
|
|
534
|
-
*/
|
|
535
|
-
export function resolveConversationPackages(options) {
|
|
536
|
-
const declarations = [...readScope("global", options), ...readScope("conversation", options)];
|
|
537
|
-
const errors = [];
|
|
538
|
-
const byIdentity = new Map();
|
|
539
|
-
for (const declaration of declarations) {
|
|
540
|
-
let identity;
|
|
541
|
-
try {
|
|
542
|
-
identity = sourceIdentity(parseSource(declaration.source));
|
|
543
|
-
}
|
|
544
|
-
catch (err) {
|
|
545
|
-
errors.push({ source: declaration.source, message: messageOf(err) });
|
|
546
|
-
continue;
|
|
547
|
-
}
|
|
548
|
-
// Later scopes overwrite earlier ones: global is read first, so a
|
|
549
|
-
// conversation declaring the same package shadows it.
|
|
550
|
-
const existing = byIdentity.get(identity);
|
|
551
|
-
if (existing && existing.scope !== declaration.scope) {
|
|
552
|
-
log.logInfo(`Package ${identity} declared in both scopes; using the conversation's copy`);
|
|
553
|
-
}
|
|
554
|
-
const materialized = materialize(declaration, options, errors);
|
|
555
|
-
if (materialized)
|
|
556
|
-
byIdentity.set(identity, materialized);
|
|
557
|
-
else
|
|
558
|
-
byIdentity.delete(identity);
|
|
559
|
-
}
|
|
560
|
-
const packages = [...byIdentity.values()].toSorted(scopeOrder);
|
|
561
|
-
return {
|
|
562
|
-
packages,
|
|
563
|
-
skillDirs: packages.flatMap(packageSkillDir),
|
|
564
|
-
errors,
|
|
565
|
-
};
|
|
566
|
-
}
|
|
567
|
-
function readScope(scope, options) {
|
|
568
|
-
try {
|
|
569
|
-
const sources = scope === "global"
|
|
570
|
-
? loadGlobalSettings().packages
|
|
571
|
-
: resolveConversationSettings(options.office).packages;
|
|
572
|
-
return (sources ?? []).map((source) => ({ source, scope }));
|
|
573
|
-
}
|
|
574
|
-
catch (err) {
|
|
575
|
-
// Unreadable settings must not take the conversation down; the other
|
|
576
|
-
// scope, and the convention directories, still load.
|
|
577
|
-
log.logWarning(`Could not read ${scope} package list`, messageOf(err));
|
|
578
|
-
return [];
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
function materialize(declaration, options, errors) {
|
|
582
|
-
try {
|
|
583
|
-
return materializeSource(declaration.source, {
|
|
584
|
-
scope: declaration.scope,
|
|
585
|
-
address: options.office.address,
|
|
586
|
-
stateDir: options.office.workspace.stateDir,
|
|
587
|
-
mode: options.fetchMissing ? "fetch" : "offline",
|
|
588
|
-
});
|
|
589
|
-
}
|
|
590
|
-
catch (err) {
|
|
591
|
-
errors.push({ source: declaration.source, message: messageOf(err) });
|
|
592
|
-
return undefined;
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
function packageSkillDir(pkg) {
|
|
596
|
-
const dir = join(pkg.dir, SKILLS_SUBDIR);
|
|
597
|
-
return isNonSymlinkDirectory(dir) ? [{ slug: packageSlug(pkg), dir }] : [];
|
|
598
|
-
}
|
|
599
|
-
function isNonSymlinkDirectory(path) {
|
|
600
|
-
if (!existsSync(path))
|
|
601
|
-
return false;
|
|
602
|
-
try {
|
|
603
|
-
const stats = lstatSync(path);
|
|
604
|
-
return !stats.isSymbolicLink() && stats.isDirectory();
|
|
605
|
-
}
|
|
606
|
-
catch (err) {
|
|
607
|
-
log.logWarning(`Could not inspect package skills directory ${path}`, messageOf(err));
|
|
608
|
-
return false;
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
/**
|
|
612
|
-
* Filesystem-safe, collision-resistant name for a package, used as the mount
|
|
613
|
-
* path segment for its skills. Derived from the identity rather than the
|
|
614
|
-
* source string so the same package spelled two ways gets one name.
|
|
615
|
-
*/
|
|
616
|
-
function packageSlug(pkg) {
|
|
617
|
-
const readable = pkg.identity
|
|
618
|
-
.replace(/^(git|local):/, "")
|
|
619
|
-
.toLowerCase()
|
|
620
|
-
.replace(/[^a-z0-9._-]+/g, "-")
|
|
621
|
-
.replace(/^-+|-+$/g, "");
|
|
622
|
-
if (readable.length <= SLUG_MAX_LENGTH)
|
|
623
|
-
return readable;
|
|
624
|
-
// Truncation alone would let two long identities sharing a prefix (deeply
|
|
625
|
-
// nested self-hosted groups, file:// paths) land on the same slug — and
|
|
626
|
-
// therefore the same mount target, where one package's skills would quietly
|
|
627
|
-
// replace the other's. The digest makes the tail collision-resistant.
|
|
628
|
-
const digest = createHash("sha256").update(pkg.identity).digest("hex").slice(0, 8);
|
|
629
|
-
return `${readable.slice(0, SLUG_MAX_LENGTH - digest.length - 1)}-${digest}`;
|
|
630
|
-
}
|
|
631
|
-
/** Global packages load before conversation ones. */
|
|
632
|
-
function scopeRank(scope) {
|
|
633
|
-
return scope === "global" ? 0 : 1;
|
|
634
|
-
}
|
|
635
|
-
function scopeOrder(a, b) {
|
|
636
|
-
return scopeRank(a.scope) - scopeRank(b.scope);
|
|
637
|
-
}
|
|
638
|
-
function messageOf(err) {
|
|
639
|
-
return err instanceof Error ? err.message : String(err);
|
|
640
|
-
}
|
|
641
|
-
/**
|
|
642
|
-
* Add a source to a scope, or move an existing one to a new ref. Fetches and
|
|
643
|
-
* validates before writing, and is idempotent: adding a source already present
|
|
644
|
-
* re-materializes it and leaves the list unchanged.
|
|
645
|
-
*/
|
|
646
|
-
export function addPackage(scope, rawSource, context) {
|
|
647
|
-
const source = formatSource(parseSource(rawSource));
|
|
648
|
-
const materialized = materializeSource(source, {
|
|
649
|
-
scope,
|
|
650
|
-
address: context.office.address,
|
|
651
|
-
stateDir: context.office.workspace.stateDir,
|
|
652
|
-
mode: "fetch",
|
|
653
|
-
});
|
|
654
|
-
const existing = declaredSources(scope, context);
|
|
655
|
-
// Replace any entry for the same package so re-adding with a new ref moves
|
|
656
|
-
// the pin instead of leaving two conflicting lines in settings.
|
|
657
|
-
const identity = sameIdentityFilter(source);
|
|
658
|
-
writePackages(scope, [...existing.filter((entry) => !identity(entry)), source], context);
|
|
659
|
-
return { source, dir: materialized.dir };
|
|
660
|
-
}
|
|
661
|
-
/**
|
|
662
|
-
* Drop a source from a scope's list. The materialized clone is left on disk —
|
|
663
|
-
* removal is a declaration change, and keeping the checkout makes re-adding
|
|
664
|
-
* instant and lets an admin undo a mistake without a network round trip.
|
|
665
|
-
*/
|
|
666
|
-
export function removePackage(scope, rawSource, context) {
|
|
667
|
-
const existing = declaredSources(scope, context);
|
|
668
|
-
const remaining = existing.filter((entry) => entry !== rawSource);
|
|
669
|
-
if (remaining.length === existing.length)
|
|
670
|
-
return false;
|
|
671
|
-
writePackages(scope, remaining, context);
|
|
672
|
-
return true;
|
|
673
|
-
}
|
|
674
|
-
/** Re-fetch a package that is already declared, moving it to its ref's current tip. */
|
|
675
|
-
export function refreshPackage(scope, rawSource, context) {
|
|
676
|
-
if (!declaredSources(scope, context).includes(rawSource)) {
|
|
677
|
-
throw new Error(`Not declared in the ${scope} scope: ${rawSource}`);
|
|
678
|
-
}
|
|
679
|
-
const materialized = materializeSource(rawSource, {
|
|
680
|
-
scope,
|
|
681
|
-
address: context.office.address,
|
|
682
|
-
stateDir: context.office.workspace.stateDir,
|
|
683
|
-
mode: "refresh",
|
|
684
|
-
});
|
|
685
|
-
return { source: rawSource, dir: materialized.dir };
|
|
686
|
-
}
|
|
687
|
-
function sameIdentityFilter(source) {
|
|
688
|
-
const target = safeIdentity(source);
|
|
689
|
-
return (entry) => safeIdentity(entry) === target;
|
|
690
|
-
}
|
|
691
|
-
/**
|
|
692
|
-
* Identity of a declared entry, falling back to the raw string when it does
|
|
693
|
-
* not parse. A malformed entry must still be matchable so an admin can replace
|
|
694
|
-
* or remove the exact line they typed.
|
|
695
|
-
*/
|
|
696
|
-
function safeIdentity(source) {
|
|
697
|
-
try {
|
|
698
|
-
return sourceIdentity(parseSource(source));
|
|
699
|
-
}
|
|
700
|
-
catch {
|
|
701
|
-
return `raw:${source}`;
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
/**
|
|
705
|
-
* Writes go through the settings-mutation seam rather than touching config
|
|
706
|
-
* directly, so package edits obey the same runner-cache policy as every other
|
|
707
|
-
* portal write. Packages are not a cached-runner key, so this writes and
|
|
708
|
-
* leaves live conversations alone until their next harness instance.
|
|
709
|
-
*/
|
|
710
|
-
function writePackages(scope, packages, context) {
|
|
711
|
-
if (scope === "global") {
|
|
712
|
-
applyGlobalSettings(context.runtime, { packages });
|
|
713
|
-
return;
|
|
714
|
-
}
|
|
715
|
-
const result = applyConversationSettings(context.runtime, context.office, {
|
|
716
|
-
packages,
|
|
717
|
-
});
|
|
718
|
-
if (!result.ok)
|
|
719
|
-
throw new Error("Conversation is busy; try again when the current run ends");
|
|
720
|
-
}
|
|
721
|
-
//# sourceMappingURL=index.js.map
|