@geminixiang/mikan 1.0.0-beta.44 → 1.0.0-beta.46
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 +32 -0
- package/README.md +12 -19
- package/dist/adapter.d.ts +1 -1
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js.map +1 -1
- package/dist/adapters/discord/bot.d.ts +3 -1
- package/dist/adapters/discord/bot.d.ts.map +1 -1
- package/dist/adapters/discord/bot.js +143 -141
- package/dist/adapters/discord/bot.js.map +1 -1
- package/dist/adapters/discord/context.d.ts +2 -8
- package/dist/adapters/discord/context.d.ts.map +1 -1
- package/dist/adapters/discord/context.js +1 -1
- package/dist/adapters/discord/context.js.map +1 -1
- package/dist/adapters/discord/format.d.ts.map +1 -1
- package/dist/adapters/discord/format.js +2 -4
- package/dist/adapters/discord/format.js.map +1 -1
- package/dist/adapters/github/bot.d.ts.map +1 -1
- package/dist/adapters/github/bot.js +1 -4
- package/dist/adapters/github/bot.js.map +1 -1
- package/dist/adapters/github/context.d.ts +2 -9
- package/dist/adapters/github/context.d.ts.map +1 -1
- package/dist/adapters/github/context.js.map +1 -1
- package/dist/adapters/github/github-ops.d.ts +4 -17
- package/dist/adapters/github/github-ops.d.ts.map +1 -1
- package/dist/adapters/github/github-ops.js +17 -86
- package/dist/adapters/github/github-ops.js.map +1 -1
- package/dist/adapters/github/tool-pack.d.ts.map +1 -1
- package/dist/adapters/github/tool-pack.js +0 -1
- package/dist/adapters/github/tool-pack.js.map +1 -1
- package/dist/adapters/github/tools/checks.d.ts +0 -1
- package/dist/adapters/github/tools/checks.d.ts.map +1 -1
- package/dist/adapters/github/tools/checks.js +3 -22
- package/dist/adapters/github/tools/checks.js.map +1 -1
- package/dist/adapters/github/types.d.ts +0 -33
- package/dist/adapters/github/types.d.ts.map +1 -1
- package/dist/adapters/github/types.js.map +1 -1
- package/dist/adapters/progressive-renderer.d.ts.map +1 -1
- package/dist/adapters/progressive-renderer.js +311 -318
- package/dist/adapters/progressive-renderer.js.map +1 -1
- package/dist/adapters/slack/blocks.d.ts.map +1 -1
- package/dist/adapters/slack/blocks.js +1 -4
- package/dist/adapters/slack/blocks.js.map +1 -1
- package/dist/adapters/slack/bot.d.ts +12 -0
- package/dist/adapters/slack/bot.d.ts.map +1 -1
- package/dist/adapters/slack/bot.js +158 -178
- package/dist/adapters/slack/bot.js.map +1 -1
- package/dist/adapters/slack/context.d.ts +2 -8
- package/dist/adapters/slack/context.d.ts.map +1 -1
- package/dist/adapters/slack/context.js +1 -1
- package/dist/adapters/slack/context.js.map +1 -1
- package/dist/adapters/slack/response-lifecycle.d.ts.map +1 -1
- package/dist/adapters/slack/response-lifecycle.js +135 -123
- package/dist/adapters/slack/response-lifecycle.js.map +1 -1
- package/dist/adapters/slack/stream-limits.d.ts +1 -1
- package/dist/adapters/slack/stream-limits.js +1 -1
- package/dist/adapters/slack/stream-limits.js.map +1 -1
- package/dist/adapters/slack/types.d.ts +4 -0
- package/dist/adapters/slack/types.d.ts.map +1 -1
- package/dist/adapters/slack/types.js.map +1 -1
- package/dist/adapters/telegram/context.d.ts +2 -8
- package/dist/adapters/telegram/context.d.ts.map +1 -1
- package/dist/adapters/telegram/context.js +1 -2
- package/dist/adapters/telegram/context.js.map +1 -1
- package/dist/adapters/types.d.ts +11 -5
- package/dist/adapters/types.d.ts.map +1 -1
- package/dist/adapters/types.js.map +1 -1
- package/dist/agent/catalog.d.ts +6 -18
- package/dist/agent/catalog.d.ts.map +1 -1
- package/dist/agent/catalog.js +19 -155
- package/dist/agent/catalog.js.map +1 -1
- package/dist/agent/execution.d.ts +0 -7
- package/dist/agent/execution.d.ts.map +1 -1
- package/dist/agent/execution.js +23 -21
- package/dist/agent/execution.js.map +1 -1
- package/dist/agent/presenter.d.ts +7 -9
- package/dist/agent/presenter.d.ts.map +1 -1
- package/dist/agent/presenter.js +355 -357
- package/dist/agent/presenter.js.map +1 -1
- package/dist/agent/prompt.d.ts +5 -12
- package/dist/agent/prompt.d.ts.map +1 -1
- package/dist/agent/prompt.js +56 -81
- package/dist/agent/prompt.js.map +1 -1
- package/dist/agent/runner.d.ts +0 -7
- package/dist/agent/runner.d.ts.map +1 -1
- package/dist/agent/runner.js +255 -308
- package/dist/agent/runner.js.map +1 -1
- package/dist/agent/types.d.ts +21 -17
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js +0 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/cli/boot.d.ts.map +1 -1
- package/dist/cli/boot.js +7 -10
- package/dist/cli/boot.js.map +1 -1
- package/dist/cli/onboard.d.ts +10 -0
- package/dist/cli/onboard.d.ts.map +1 -0
- package/dist/cli/onboard.js +237 -0
- package/dist/cli/onboard.js.map +1 -0
- package/dist/cli/types.d.ts +8 -3
- package/dist/cli/types.d.ts.map +1 -1
- package/dist/cli/types.js.map +1 -1
- package/dist/commands/auto-reply.d.ts.map +1 -1
- package/dist/commands/auto-reply.js +5 -12
- package/dist/commands/auto-reply.js.map +1 -1
- package/dist/commands/manifest.d.ts.map +1 -1
- package/dist/commands/manifest.js +9 -16
- package/dist/commands/manifest.js.map +1 -1
- package/dist/commands/new.d.ts.map +1 -1
- package/dist/commands/new.js +15 -10
- package/dist/commands/new.js.map +1 -1
- package/dist/commands/registry.d.ts.map +1 -1
- package/dist/commands/registry.js +0 -2
- package/dist/commands/registry.js.map +1 -1
- package/dist/commands/sandbox.d.ts.map +1 -1
- package/dist/commands/sandbox.js +89 -70
- package/dist/commands/sandbox.js.map +1 -1
- package/dist/commands/session-view.js +9 -2
- package/dist/commands/session-view.js.map +1 -1
- package/dist/commands/types.d.ts +4 -3
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/commands/types.js.map +1 -1
- package/dist/config.d.ts +13 -17
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +39 -37
- package/dist/config.js.map +1 -1
- package/dist/dream/index.d.ts +20 -0
- package/dist/dream/index.d.ts.map +1 -0
- package/dist/dream/index.js +253 -0
- package/dist/dream/index.js.map +1 -0
- package/dist/dream/types.d.ts +30 -0
- package/dist/dream/types.d.ts.map +1 -0
- package/dist/dream/types.js.map +1 -0
- package/dist/env-manifest.d.ts.map +1 -1
- package/dist/env-manifest.js +2 -34
- package/dist/env-manifest.js.map +1 -1
- package/dist/execution-resolver.d.ts +9 -2
- package/dist/execution-resolver.d.ts.map +1 -1
- package/dist/execution-resolver.js +26 -27
- package/dist/execution-resolver.js.map +1 -1
- package/dist/harness/event-format.d.ts +1 -2
- package/dist/harness/event-format.d.ts.map +1 -1
- package/dist/harness/event-format.js +9 -15
- package/dist/harness/event-format.js.map +1 -1
- package/dist/harness/index.d.ts +1 -7
- package/dist/harness/index.d.ts.map +1 -1
- package/dist/harness/index.js +0 -4
- package/dist/harness/index.js.map +1 -1
- package/dist/harness/models.d.ts.map +1 -1
- package/dist/harness/models.js +15 -35
- package/dist/harness/models.js.map +1 -1
- package/dist/harness/runner.d.ts +7 -16
- package/dist/harness/runner.d.ts.map +1 -1
- package/dist/harness/runner.js +13 -131
- package/dist/harness/runner.js.map +1 -1
- package/dist/harness/session-store.d.ts +1 -1
- package/dist/harness/session-store.d.ts.map +1 -1
- package/dist/harness/session-store.js +1 -1
- package/dist/harness/session-store.js.map +1 -1
- package/dist/harness/subagent-runner.d.ts +2 -2
- package/dist/harness/subagent-runner.d.ts.map +1 -1
- package/dist/harness/subagent-runner.js +157 -162
- package/dist/harness/subagent-runner.js.map +1 -1
- package/dist/harness/types.d.ts +1 -13
- package/dist/harness/types.d.ts.map +1 -1
- package/dist/harness/types.js.map +1 -1
- package/dist/index.d.ts +3 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -5
- package/dist/index.js.map +1 -1
- package/dist/main.js +31 -212
- package/dist/main.js.map +1 -1
- package/dist/mcp/catalog.d.ts +5 -0
- package/dist/mcp/catalog.d.ts.map +1 -0
- package/dist/mcp/catalog.js +135 -0
- package/dist/mcp/catalog.js.map +1 -0
- package/dist/mcp/loader.d.ts.map +1 -1
- package/dist/mcp/loader.js +3 -6
- package/dist/mcp/loader.js.map +1 -1
- package/dist/mcp/types.d.ts +22 -0
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/mcp/types.js.map +1 -1
- package/dist/office/index.d.ts +136 -8
- package/dist/office/index.d.ts.map +1 -1
- package/dist/office/index.js +1050 -9
- package/dist/office/index.js.map +1 -1
- package/dist/office/types.d.ts +19 -1
- package/dist/office/types.d.ts.map +1 -1
- package/dist/office/types.js.map +1 -1
- package/dist/packages/index.d.ts +168 -5
- package/dist/packages/index.d.ts.map +1 -1
- package/dist/packages/index.js +749 -5
- package/dist/packages/index.js.map +1 -1
- package/dist/packages/types.d.ts +1 -5
- package/dist/packages/types.d.ts.map +1 -1
- package/dist/packages/types.js.map +1 -1
- package/dist/provisioner.d.ts +2 -9
- package/dist/provisioner.d.ts.map +1 -1
- package/dist/provisioner.js +3 -12
- package/dist/provisioner.js.map +1 -1
- package/dist/runtime/conversation-runtime.d.ts.map +1 -1
- package/dist/runtime/conversation-runtime.js +117 -380
- package/dist/runtime/conversation-runtime.js.map +1 -1
- package/dist/runtime/session-lifecycle.d.ts +32 -18
- package/dist/runtime/session-lifecycle.d.ts.map +1 -1
- package/dist/runtime/session-lifecycle.js +159 -46
- package/dist/runtime/session-lifecycle.js.map +1 -1
- package/dist/runtime/types.d.ts +4 -26
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/runtime/types.js.map +1 -1
- package/dist/sandbox/cloudflare.d.ts.map +1 -1
- package/dist/sandbox/cloudflare.js +2 -3
- package/dist/sandbox/cloudflare.js.map +1 -1
- package/dist/sandbox/container.d.ts +0 -1
- package/dist/sandbox/container.d.ts.map +1 -1
- package/dist/sandbox/container.js +2 -3
- package/dist/sandbox/container.js.map +1 -1
- package/dist/sandbox/host.d.ts.map +1 -1
- package/dist/sandbox/host.js +4 -2
- package/dist/sandbox/host.js.map +1 -1
- package/dist/sandbox/identity.d.ts +10 -19
- package/dist/sandbox/identity.d.ts.map +1 -1
- package/dist/sandbox/identity.js +8 -8
- package/dist/sandbox/identity.js.map +1 -1
- package/dist/sandbox/index.d.ts +7 -10
- package/dist/sandbox/index.d.ts.map +1 -1
- package/dist/sandbox/index.js +45 -16
- package/dist/sandbox/index.js.map +1 -1
- package/dist/sandbox/types.d.ts +13 -45
- 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 +10 -0
- package/dist/sandbox/utils.js.map +1 -1
- package/dist/sessions/chat-history-sync.d.ts +1 -3
- package/dist/sessions/chat-history-sync.d.ts.map +1 -1
- package/dist/sessions/chat-history-sync.js +58 -11
- package/dist/sessions/chat-history-sync.js.map +1 -1
- package/dist/sessions/migrate-v3.d.ts +2 -5
- package/dist/sessions/migrate-v3.d.ts.map +1 -1
- package/dist/sessions/migrate-v3.js +34 -4
- package/dist/sessions/migrate-v3.js.map +1 -1
- package/dist/sessions/store.d.ts +5 -6
- package/dist/sessions/store.d.ts.map +1 -1
- package/dist/sessions/store.js +62 -2
- package/dist/sessions/store.js.map +1 -1
- package/dist/sessions/types.d.ts +9 -0
- package/dist/sessions/types.d.ts.map +1 -1
- package/dist/sessions/types.js.map +1 -1
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +2 -10
- package/dist/tools/bash.js.map +1 -1
- package/dist/tools/read.js +2 -2
- package/dist/tools/read.js.map +1 -1
- package/dist/tools/sandbox.d.ts.map +1 -1
- package/dist/tools/sandbox.js +2 -3
- package/dist/tools/sandbox.js.map +1 -1
- package/dist/tools/subagent.d.ts +1 -1
- package/dist/tools/subagent.js.map +1 -1
- package/dist/types.d.ts +38 -127
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/vault/index.d.ts +9 -2
- package/dist/vault/index.d.ts.map +1 -1
- package/dist/vault/index.js +29 -5
- package/dist/vault/index.js.map +1 -1
- package/dist/web/admin/portal.d.ts +12 -1
- package/dist/web/admin/portal.d.ts.map +1 -1
- package/dist/web/admin/portal.js +437 -422
- package/dist/web/admin/portal.js.map +1 -1
- package/dist/web/admin/types.d.ts +2 -2
- package/dist/web/admin/types.d.ts.map +1 -1
- package/dist/web/admin/types.js.map +1 -1
- package/dist/web/login/portal.d.ts +7 -1
- package/dist/web/login/portal.d.ts.map +1 -1
- package/dist/web/login/portal.js +143 -78
- package/dist/web/login/portal.js.map +1 -1
- package/dist/web/portal-shell.d.ts +1 -0
- package/dist/web/portal-shell.d.ts.map +1 -1
- package/dist/web/portal-shell.js +12 -1
- package/dist/web/portal-shell.js.map +1 -1
- package/dist/web/server.d.ts +3 -3
- package/dist/web/server.d.ts.map +1 -1
- package/dist/web/server.js.map +1 -1
- package/dist/web/session-view/portal.d.ts +8 -1
- package/dist/web/session-view/portal.d.ts.map +1 -1
- package/dist/web/session-view/portal.js +609 -132
- package/dist/web/session-view/portal.js.map +1 -1
- package/dist/web/session-view/types.d.ts +8 -0
- package/dist/web/session-view/types.d.ts.map +1 -1
- package/dist/web/session-view/types.js.map +1 -1
- package/dist/workspace-projection/index.d.ts +14 -2
- package/dist/workspace-projection/index.d.ts.map +1 -1
- package/dist/workspace-projection/index.js +102 -14
- package/dist/workspace-projection/index.js.map +1 -1
- package/dist/workspace-projection/types.d.ts +14 -1
- package/dist/workspace-projection/types.d.ts.map +1 -1
- package/dist/workspace-projection/types.js.map +1 -1
- package/package.json +3 -5
- package/dist/adapters/github/cloudbuild.d.ts +0 -19
- package/dist/adapters/github/cloudbuild.d.ts.map +0 -1
- package/dist/adapters/github/cloudbuild.js +0 -71
- package/dist/adapters/github/cloudbuild.js.map +0 -1
- package/dist/adapters/github/gcp-auth.d.ts +0 -28
- package/dist/adapters/github/gcp-auth.d.ts.map +0 -1
- package/dist/adapters/github/gcp-auth.js +0 -196
- package/dist/adapters/github/gcp-auth.js.map +0 -1
- package/dist/agent/index.d.ts +0 -9
- package/dist/agent/index.d.ts.map +0 -1
- package/dist/agent/index.js +0 -8
- package/dist/agent/index.js.map +0 -1
- package/dist/cli/ext-dev.d.ts +0 -2
- package/dist/cli/ext-dev.d.ts.map +0 -1
- package/dist/cli/ext-dev.js +0 -188
- package/dist/cli/ext-dev.js.map +0 -1
- package/dist/cli/ext.d.ts +0 -2
- package/dist/cli/ext.d.ts.map +0 -1
- package/dist/cli/ext.js +0 -324
- package/dist/cli/ext.js.map +0 -1
- package/dist/commands/extensions.d.ts +0 -26
- package/dist/commands/extensions.d.ts.map +0 -1
- package/dist/commands/extensions.js +0 -103
- package/dist/commands/extensions.js.map +0 -1
- package/dist/extension-schedules.d.ts +0 -31
- package/dist/extension-schedules.d.ts.map +0 -1
- package/dist/extension-schedules.js +0 -229
- package/dist/extension-schedules.js.map +0 -1
- package/dist/harness/auth.d.ts +0 -17
- package/dist/harness/auth.d.ts.map +0 -1
- package/dist/harness/auth.js +0 -92
- package/dist/harness/auth.js.map +0 -1
- package/dist/harness/extensions/loader.d.ts +0 -40
- package/dist/harness/extensions/loader.d.ts.map +0 -1
- package/dist/harness/extensions/loader.js +0 -723
- package/dist/harness/extensions/loader.js.map +0 -1
- package/dist/harness/extensions/registry.d.ts +0 -155
- package/dist/harness/extensions/registry.d.ts.map +0 -1
- package/dist/harness/extensions/registry.js +0 -420
- package/dist/harness/extensions/registry.js.map +0 -1
- package/dist/harness/extensions/types.d.ts +0 -665
- package/dist/harness/extensions/types.d.ts.map +0 -1
- package/dist/harness/extensions/types.js.map +0 -1
- package/dist/office/address.d.ts +0 -31
- package/dist/office/address.d.ts.map +0 -1
- package/dist/office/address.js +0 -113
- package/dist/office/address.js.map +0 -1
- package/dist/office/layout.d.ts +0 -27
- package/dist/office/layout.d.ts.map +0 -1
- package/dist/office/layout.js +0 -97
- package/dist/office/layout.js.map +0 -1
- package/dist/office/migration.d.ts +0 -44
- package/dist/office/migration.d.ts.map +0 -1
- package/dist/office/migration.js +0 -255
- package/dist/office/migration.js.map +0 -1
- package/dist/office/registry.d.ts +0 -75
- package/dist/office/registry.d.ts.map +0 -1
- package/dist/office/registry.js +0 -646
- package/dist/office/registry.js.map +0 -1
- package/dist/packages/admin.d.ts +0 -17
- package/dist/packages/admin.d.ts.map +0 -1
- package/dist/packages/admin.js +0 -98
- package/dist/packages/admin.js.map +0 -1
- package/dist/packages/inspect.d.ts +0 -11
- package/dist/packages/inspect.d.ts.map +0 -1
- package/dist/packages/inspect.js +0 -98
- package/dist/packages/inspect.js.map +0 -1
- package/dist/packages/materialize.d.ts +0 -40
- package/dist/packages/materialize.d.ts.map +0 -1
- package/dist/packages/materialize.js +0 -297
- package/dist/packages/materialize.js.map +0 -1
- package/dist/packages/resolve.d.ts +0 -25
- package/dist/packages/resolve.d.ts.map +0 -1
- package/dist/packages/resolve.js +0 -208
- package/dist/packages/resolve.js.map +0 -1
- package/dist/packages/source.d.ts +0 -39
- package/dist/packages/source.d.ts.map +0 -1
- package/dist/packages/source.js +0 -189
- package/dist/packages/source.js.map +0 -1
- package/dist/sandbox/errors.d.ts +0 -6
- package/dist/sandbox/errors.d.ts.map +0 -1
- package/dist/sandbox/errors.js +0 -11
- package/dist/sandbox/errors.js.map +0 -1
- package/dist/sandbox/firecracker.d.ts +0 -18
- package/dist/sandbox/firecracker.d.ts.map +0 -1
- package/dist/sandbox/firecracker.js +0 -223
- package/dist/sandbox/firecracker.js.map +0 -1
- package/dist/sandbox/gondolin.d.ts +0 -57
- package/dist/sandbox/gondolin.d.ts.map +0 -1
- package/dist/sandbox/gondolin.js +0 -764
- package/dist/sandbox/gondolin.js.map +0 -1
- package/dist/sandbox/image.d.ts +0 -3
- package/dist/sandbox/image.d.ts.map +0 -1
- package/dist/sandbox/image.js +0 -29
- package/dist/sandbox/image.js.map +0 -1
- package/dist/sessions/conversation-log.d.ts +0 -9
- package/dist/sessions/conversation-log.d.ts.map +0 -1
- package/dist/sessions/conversation-log.js +0 -50
- package/dist/sessions/conversation-log.js.map +0 -1
- package/dist/sessions/rotation.d.ts +0 -2
- package/dist/sessions/rotation.d.ts.map +0 -1
- package/dist/sessions/rotation.js +0 -41
- package/dist/sessions/rotation.js.map +0 -1
- package/dist/vault/disabled.d.ts +0 -9
- package/dist/vault/disabled.d.ts.map +0 -1
- package/dist/vault/disabled.js +0 -25
- package/dist/vault/disabled.js.map +0 -1
- package/dist/web/admin/store.d.ts +0 -13
- package/dist/web/admin/store.d.ts.map +0 -1
- package/dist/web/admin/store.js +0 -14
- package/dist/web/admin/store.js.map +0 -1
- package/dist/web/login/store.d.ts +0 -8
- package/dist/web/login/store.d.ts.map +0 -1
- package/dist/web/login/store.js +0 -15
- package/dist/web/login/store.js.map +0 -1
- package/dist/web/session-view/service.d.ts +0 -6
- package/dist/web/session-view/service.d.ts.map +0 -1
- package/dist/web/session-view/service.js +0 -517
- package/dist/web/session-view/service.js.map +0 -1
- package/dist/web/session-view/store.d.ts +0 -8
- package/dist/web/session-view/store.d.ts.map +0 -1
- package/dist/web/session-view/store.js +0 -15
- package/dist/web/session-view/store.js.map +0 -1
- /package/dist/{harness/extensions → dream}/types.js +0 -0
|
@@ -1,8 +1,48 @@
|
|
|
1
|
-
import { dirname } from "node:path";
|
|
2
|
-
import { lstatSync, mkdirSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { ensureDirExists } from "../utils/file-guards.js";
|
|
1
|
+
import { dirname, join } from "node:path";
|
|
2
|
+
import { lstatSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { atomicWritePrivateFile, ensureDirExists } from "../utils/file-guards.js";
|
|
4
4
|
import { resolveConversationSettings } from "../config.js";
|
|
5
5
|
import * as log from "../log.js";
|
|
6
|
+
const CHANNEL_KIND_FILE = "channel-kind";
|
|
7
|
+
const CHANNEL_KINDS = [
|
|
8
|
+
"public_channel",
|
|
9
|
+
"private_channel",
|
|
10
|
+
"im",
|
|
11
|
+
"external",
|
|
12
|
+
];
|
|
13
|
+
/**
|
|
14
|
+
* Record the platform's own channel kind for this conversation, as observed
|
|
15
|
+
* by the adapter at message intake. Stored under the host-only office state
|
|
16
|
+
* dir (never the sandbox-mounted workspace), so sandboxed code cannot
|
|
17
|
+
* promote its own conversation into the shared pool. Written only on change;
|
|
18
|
+
* the value is a snapshot as of the last message, which is exactly the
|
|
19
|
+
* freshness the projection needs — a conversation that never speaks again
|
|
20
|
+
* never needs a fresher value.
|
|
21
|
+
*/
|
|
22
|
+
export function recordPlatformChannelKind(office, kind) {
|
|
23
|
+
if (readPlatformChannelKind(office) === kind)
|
|
24
|
+
return;
|
|
25
|
+
ensureDirExists(office.stateDir);
|
|
26
|
+
atomicWritePrivateFile(join(office.stateDir, CHANNEL_KIND_FILE), kind + "\n");
|
|
27
|
+
}
|
|
28
|
+
/** The recorded platform channel kind, or undefined when never observed. */
|
|
29
|
+
export function readPlatformChannelKind(office) {
|
|
30
|
+
const path = join(office.stateDir, CHANNEL_KIND_FILE);
|
|
31
|
+
let raw;
|
|
32
|
+
try {
|
|
33
|
+
raw = readFileSync(path, "utf-8");
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
if (err.code === "ENOENT")
|
|
37
|
+
return undefined;
|
|
38
|
+
log.logWarning("Could not read platform channel kind; falling back to isolated workspace", `${path}: ${err instanceof Error ? err.message : String(err)}`);
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
const value = raw.trim();
|
|
42
|
+
return CHANNEL_KINDS.includes(value)
|
|
43
|
+
? value
|
|
44
|
+
: undefined;
|
|
45
|
+
}
|
|
6
46
|
/**
|
|
7
47
|
* The single policy seam for a managed office. It both materializes the
|
|
8
48
|
* host-side roots and authorizes the prompt sources that describe them.
|
|
@@ -19,11 +59,26 @@ export function resolveWorkspaceProjection(office) {
|
|
|
19
59
|
ensureDirectoryRoot(workspace.skillsDir, "Workspace skills");
|
|
20
60
|
ensureDirectoryRoot(workspace.eventsDir, "Workspace events");
|
|
21
61
|
}
|
|
62
|
+
// Private visibility only changes anything for shared-support: the shared
|
|
63
|
+
// MEMORY.md is the one file that leaks information between offices when
|
|
64
|
+
// writable, so a private office reads it but cannot write it (modeled on
|
|
65
|
+
// Claude Tag's private-channel memory). "full" mounts the whole workspace
|
|
66
|
+
// as one read-write bind with no separate memory file to gate, and
|
|
67
|
+
// "conversation" never sees workspace memory at all.
|
|
68
|
+
//
|
|
69
|
+
// The `readOnly` mount flag below is a kernel-enforced boundary only for
|
|
70
|
+
// backends with managed Workspace projection. Runner and actor execution
|
|
71
|
+
// resolution reject every other backend before the agent can start.
|
|
72
|
+
const globalMemoryReadOnly = shared && effective.visibility === "private";
|
|
22
73
|
const mounts = effective.layout === "full"
|
|
23
74
|
? [{ source: workspace.root, target: "/workspace" }]
|
|
24
75
|
: effective.layout === "shared-support"
|
|
25
76
|
? [
|
|
26
|
-
{
|
|
77
|
+
{
|
|
78
|
+
source: workspace.memoryPath,
|
|
79
|
+
target: "/workspace/MEMORY.md",
|
|
80
|
+
...(globalMemoryReadOnly ? { readOnly: true } : {}),
|
|
81
|
+
},
|
|
27
82
|
{ source: workspace.skillsDir, target: "/workspace/skills" },
|
|
28
83
|
{ source: workspace.eventsDir, target: "/workspace/events" },
|
|
29
84
|
{ source: office.dir, target: `/workspace/${office.key}` },
|
|
@@ -37,7 +92,11 @@ export function resolveWorkspaceProjection(office) {
|
|
|
37
92
|
conversationMemoryPath: office.memoryPath,
|
|
38
93
|
conversationSkillsDir: office.skillsDir,
|
|
39
94
|
...(effective.layout === "shared-support" || effective.layout === "full"
|
|
40
|
-
? {
|
|
95
|
+
? {
|
|
96
|
+
globalMemoryPath: workspace.memoryPath,
|
|
97
|
+
globalSkillsDir: workspace.skillsDir,
|
|
98
|
+
...(globalMemoryReadOnly ? { globalMemoryReadOnly: true } : {}),
|
|
99
|
+
}
|
|
41
100
|
: {}),
|
|
42
101
|
},
|
|
43
102
|
};
|
|
@@ -46,9 +105,12 @@ function resolveEffectiveWorkspace(office) {
|
|
|
46
105
|
try {
|
|
47
106
|
const settings = resolveConversationSettings(office).sandbox;
|
|
48
107
|
if (settings?.workspace) {
|
|
49
|
-
return normalizeWorkspace(settings.workspace.doorPolicy, settings.workspace.layout);
|
|
108
|
+
return normalizeWorkspace(settings.workspace.doorPolicy, settings.workspace.layout, settings.workspace.visibility);
|
|
109
|
+
}
|
|
110
|
+
if (settings?.image?.workspaceMount) {
|
|
111
|
+
return legacyWorkspace(settings.image.workspaceMount);
|
|
50
112
|
}
|
|
51
|
-
return
|
|
113
|
+
return platformDerivedWorkspace(office);
|
|
52
114
|
}
|
|
53
115
|
catch (err) {
|
|
54
116
|
// Settings are host-authoritative. A malformed file must not fall back to
|
|
@@ -57,18 +119,44 @@ function resolveEffectiveWorkspace(office) {
|
|
|
57
119
|
throw new Error("Cannot resolve workspace projection: settings are malformed", { cause: err });
|
|
58
120
|
}
|
|
59
121
|
}
|
|
60
|
-
|
|
122
|
+
/**
|
|
123
|
+
* No explicit workspace setting anywhere: follow the platform's own channel
|
|
124
|
+
* vocabulary (modeled on Claude Tag). A public channel's knowledge is shared
|
|
125
|
+
* workspace-wide read-write; a private channel reads the shared pool but
|
|
126
|
+
* writes only its own conversation memory; DMs, externally shared channels,
|
|
127
|
+
* and conversations whose kind was never observed stay fully isolated —
|
|
128
|
+
* platform-public is a necessary condition for sharing, never assumed.
|
|
129
|
+
* An admin's explicit setting (conversation or global) always wins over this.
|
|
130
|
+
*/
|
|
131
|
+
function platformDerivedWorkspace(office) {
|
|
132
|
+
switch (readPlatformChannelKind(office)) {
|
|
133
|
+
case "public_channel":
|
|
134
|
+
return { doorPolicy: "trusted", layout: "shared-support", visibility: "public" };
|
|
135
|
+
case "private_channel":
|
|
136
|
+
return { doorPolicy: "trusted", layout: "shared-support", visibility: "private" };
|
|
137
|
+
default:
|
|
138
|
+
return { doorPolicy: "isolated", layout: "conversation", visibility: "public" };
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function normalizeWorkspace(doorPolicy, layout, visibility) {
|
|
61
142
|
const policy = doorPolicy ?? "isolated";
|
|
62
|
-
if (policy === "isolated")
|
|
63
|
-
return { doorPolicy: policy, layout: "conversation" };
|
|
64
|
-
|
|
143
|
+
if (policy === "isolated") {
|
|
144
|
+
return { doorPolicy: policy, layout: "conversation", visibility: "public" };
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
doorPolicy: policy,
|
|
148
|
+
layout: layout === "full" ? "full" : "shared-support",
|
|
149
|
+
// Missing visibility defaults to "public": every office that predates this
|
|
150
|
+
// setting keeps today's read-write shared MEMORY.md behavior unchanged.
|
|
151
|
+
visibility: visibility ?? "public",
|
|
152
|
+
};
|
|
65
153
|
}
|
|
66
154
|
function legacyWorkspace(mode) {
|
|
67
155
|
return mode === "full"
|
|
68
|
-
? { doorPolicy: "trusted", layout: "full" }
|
|
156
|
+
? { doorPolicy: "trusted", layout: "full", visibility: "public" }
|
|
69
157
|
: mode === "private"
|
|
70
|
-
? { doorPolicy: "trusted", layout: "shared-support" }
|
|
71
|
-
: { doorPolicy: "isolated", layout: "conversation" };
|
|
158
|
+
? { doorPolicy: "trusted", layout: "shared-support", visibility: "public" }
|
|
159
|
+
: { doorPolicy: "isolated", layout: "conversation", visibility: "public" };
|
|
72
160
|
}
|
|
73
161
|
function ensureDirectoryRoot(path, label) {
|
|
74
162
|
if (!exists(path)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/workspace-projection/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAE3D,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AAMjC;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CAA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KAAK,yBAAyB,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;IAC3E,CAAC;IACD,IAAI,KAAK,CAAC,cAAc,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,wCAAwC,IAAI,EAAE,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CAAC,IAAY,EAAE,KAAa;IAClD,IAAI,KAAK,CAAC;IACV,IAAI,CAAC;QACH,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,yBAAyB,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;IAC3E,CAAC;IACD,IAAI,KAAK,CAAC,cAAc,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;QACnD,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,6CAA6C,IAAI,EAAE,CAAC,CAAC;IAC/E,CAAC;AACH,CAAC;AAED,SAAS,MAAM,CAAC,IAAY;IAC1B,IAAI,CAAC;QACH,SAAS,CAAC,IAAI,CAAC,CAAC;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAK,GAA6B,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QACnE,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC","sourcesContent":["import { dirname } from \"node:path\";\nimport { lstatSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { ensureDirExists } from \"../utils/file-guards.js\";\nimport { resolveConversationSettings } from \"../config.js\";\nimport type { Office } from \"../office/index.js\";\nimport * as log from \"../log.js\";\nimport type { ImageWorkspaceMountMode, WorkspaceDoorPolicy, WorkspaceLayout } from \"../types.js\";\nimport type { WorkspaceProjection } from \"./types.js\";\n\nexport type { WorkspaceProjection } from \"./types.js\";\n\n/**\n * The single policy seam for a managed office. It both materializes the\n * host-side roots and authorizes the prompt sources that describe them.\n * Legacy image settings are deliberately translated here, never at callers.\n */\nexport function resolveWorkspaceProjection(office: Office): WorkspaceProjection {\n const { workspace } = office;\n const effective = resolveEffectiveWorkspace(office);\n\n assertDirectory(workspace.root, \"Host workspace root\");\n office.ensure();\n const shared = effective.layout === \"shared-support\";\n if (shared) {\n ensureRegularFile(workspace.memoryPath, \"Workspace memory\");\n ensureDirectoryRoot(workspace.skillsDir, \"Workspace skills\");\n ensureDirectoryRoot(workspace.eventsDir, \"Workspace events\");\n }\n\n const mounts =\n effective.layout === \"full\"\n ? [{ source: workspace.root, target: \"/workspace\" }]\n : effective.layout === \"shared-support\"\n ? [\n { source: workspace.memoryPath, target: \"/workspace/MEMORY.md\" },\n { source: workspace.skillsDir, target: \"/workspace/skills\" },\n { source: workspace.eventsDir, target: \"/workspace/events\" },\n { source: office.dir, target: `/workspace/${office.key}` },\n ]\n : [{ source: office.dir, target: `/workspace/${office.key}` }];\n\n return {\n ...effective,\n mounts,\n promptSources: {\n conversationDir: office.dir,\n conversationMemoryPath: office.memoryPath,\n conversationSkillsDir: office.skillsDir,\n ...(effective.layout === \"shared-support\" || effective.layout === \"full\"\n ? { globalMemoryPath: workspace.memoryPath, globalSkillsDir: workspace.skillsDir }\n : {}),\n },\n };\n}\n\nfunction resolveEffectiveWorkspace(\n office: Office,\n): Pick<WorkspaceProjection, \"doorPolicy\" | \"layout\"> {\n try {\n const settings = resolveConversationSettings(office).sandbox;\n if (settings?.workspace) {\n return normalizeWorkspace(settings.workspace.doorPolicy, settings.workspace.layout);\n }\n return legacyWorkspace(settings?.image?.workspaceMount);\n } catch (err) {\n // Settings are host-authoritative. A malformed file must not fall back to\n // an unvalidated value from a mounted legacy location.\n log.logWarning(\n \"Refusing to resolve workspace projection from malformed settings\",\n err instanceof Error ? err.message : String(err),\n );\n throw new Error(\"Cannot resolve workspace projection: settings are malformed\", { cause: err });\n }\n}\n\nfunction normalizeWorkspace(\n doorPolicy: WorkspaceDoorPolicy | undefined,\n layout: WorkspaceLayout | undefined,\n): Pick<WorkspaceProjection, \"doorPolicy\" | \"layout\"> {\n const policy = doorPolicy ?? \"isolated\";\n if (policy === \"isolated\") return { doorPolicy: policy, layout: \"conversation\" };\n return { doorPolicy: policy, layout: layout === \"full\" ? \"full\" : \"shared-support\" };\n}\n\nfunction legacyWorkspace(\n mode: ImageWorkspaceMountMode | undefined,\n): Pick<WorkspaceProjection, \"doorPolicy\" | \"layout\"> {\n return mode === \"full\"\n ? { doorPolicy: \"trusted\", layout: \"full\" }\n : mode === \"private\"\n ? { doorPolicy: \"trusted\", layout: \"shared-support\" }\n : { doorPolicy: \"isolated\", layout: \"conversation\" };\n}\n\nfunction ensureDirectoryRoot(path: string, label: string): void {\n if (!exists(path)) {\n mkdirSync(path, { recursive: true, mode: 0o700 });\n return;\n }\n assertDirectory(path, label);\n}\n\nfunction ensureRegularFile(path: string, label: string): void {\n if (!exists(path)) {\n ensureDirExists(dirname(path));\n writeFileSync(path, \"\", { mode: 0o600, flag: \"wx\" });\n return;\n }\n let stats;\n try {\n stats = lstatSync(path);\n } catch (err) {\n throw new Error(`${label} cannot be inspected: ${path}`, { cause: err });\n }\n if (stats.isSymbolicLink() || !stats.isFile()) {\n throw new Error(`${label} must be a regular non-symlink file: ${path}`);\n }\n}\n\nfunction assertDirectory(path: string, label: string): void {\n let stats;\n try {\n stats = lstatSync(path);\n } catch (err) {\n throw new Error(`${label} cannot be inspected: ${path}`, { cause: err });\n }\n if (stats.isSymbolicLink() || !stats.isDirectory()) {\n throw new Error(`${label} must be a regular non-symlink directory: ${path}`);\n }\n}\n\nfunction exists(path: string): boolean {\n try {\n lstatSync(path);\n return true;\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === \"ENOENT\") return false;\n throw err;\n }\n}\n"]}
|
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AI,CAAC;IACd,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAK,GAA6B,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QACnE,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC","sourcesContent":["import { dirname, join } from \"node:path\";\nimport { lstatSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { atomicWritePrivateFile, ensureDirExists } from \"../utils/file-guards.js\";\nimport { resolveConversationSettings } from \"../config.js\";\nimport type { Office } from \"../office/index.js\";\nimport * as log from \"../log.js\";\nimport type {\n ImageWorkspaceMountMode,\n WorkspaceDoorPolicy,\n WorkspaceLayout,\n WorkspaceVisibility,\n} from \"../types.js\";\nimport type { PlatformChannelKind, WorkspaceProjection } from \"./types.js\";\n\nexport type { PlatformChannelKind, WorkspaceProjection } from \"./types.js\";\n\nconst CHANNEL_KIND_FILE = \"channel-kind\";\nconst CHANNEL_KINDS: readonly PlatformChannelKind[] = [\n \"public_channel\",\n \"private_channel\",\n \"im\",\n \"external\",\n];\n\n/**\n * Record the platform's own channel kind for this conversation, as observed\n * by the adapter at message intake. Stored under the host-only office state\n * dir (never the sandbox-mounted workspace), so sandboxed code cannot\n * promote its own conversation into the shared pool. Written only on change;\n * the value is a snapshot as of the last message, which is exactly the\n * freshness the projection needs — a conversation that never speaks again\n * never needs a fresher value.\n */\nexport function recordPlatformChannelKind(office: Office, kind: PlatformChannelKind): void {\n if (readPlatformChannelKind(office) === kind) return;\n ensureDirExists(office.stateDir);\n atomicWritePrivateFile(join(office.stateDir, CHANNEL_KIND_FILE), kind + \"\\n\");\n}\n\n/** The recorded platform channel kind, or undefined when never observed. */\nexport function readPlatformChannelKind(office: Office): PlatformChannelKind | undefined {\n const path = join(office.stateDir, CHANNEL_KIND_FILE);\n let raw: string;\n try {\n raw = readFileSync(path, \"utf-8\");\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === \"ENOENT\") return undefined;\n log.logWarning(\n \"Could not read platform channel kind; falling back to isolated workspace\",\n `${path}: ${err instanceof Error ? err.message : String(err)}`,\n );\n return undefined;\n }\n const value = raw.trim();\n return (CHANNEL_KINDS as readonly string[]).includes(value)\n ? (value as PlatformChannelKind)\n : undefined;\n}\n\n/**\n * The single policy seam for a managed office. It both materializes the\n * host-side roots and authorizes the prompt sources that describe them.\n * Legacy image settings are deliberately translated here, never at callers.\n */\nexport function resolveWorkspaceProjection(office: Office): WorkspaceProjection {\n const { workspace } = office;\n const effective = resolveEffectiveWorkspace(office);\n\n assertDirectory(workspace.root, \"Host workspace root\");\n office.ensure();\n const shared = effective.layout === \"shared-support\";\n if (shared) {\n ensureRegularFile(workspace.memoryPath, \"Workspace memory\");\n ensureDirectoryRoot(workspace.skillsDir, \"Workspace skills\");\n ensureDirectoryRoot(workspace.eventsDir, \"Workspace events\");\n }\n\n // Private visibility only changes anything for shared-support: the shared\n // MEMORY.md is the one file that leaks information between offices when\n // writable, so a private office reads it but cannot write it (modeled on\n // Claude Tag's private-channel memory). \"full\" mounts the whole workspace\n // as one read-write bind with no separate memory file to gate, and\n // \"conversation\" never sees workspace memory at all.\n //\n // The `readOnly` mount flag below is a kernel-enforced boundary only for\n // backends with managed Workspace projection. Runner and actor execution\n // resolution reject every other backend before the agent can start.\n const globalMemoryReadOnly = shared && effective.visibility === \"private\";\n const mounts =\n effective.layout === \"full\"\n ? [{ source: workspace.root, target: \"/workspace\" }]\n : effective.layout === \"shared-support\"\n ? [\n {\n source: workspace.memoryPath,\n target: \"/workspace/MEMORY.md\",\n ...(globalMemoryReadOnly ? { readOnly: true as const } : {}),\n },\n { source: workspace.skillsDir, target: \"/workspace/skills\" },\n { source: workspace.eventsDir, target: \"/workspace/events\" },\n { source: office.dir, target: `/workspace/${office.key}` },\n ]\n : [{ source: office.dir, target: `/workspace/${office.key}` }];\n\n return {\n ...effective,\n mounts,\n promptSources: {\n conversationDir: office.dir,\n conversationMemoryPath: office.memoryPath,\n conversationSkillsDir: office.skillsDir,\n ...(effective.layout === \"shared-support\" || effective.layout === \"full\"\n ? {\n globalMemoryPath: workspace.memoryPath,\n globalSkillsDir: workspace.skillsDir,\n ...(globalMemoryReadOnly ? { globalMemoryReadOnly: true } : {}),\n }\n : {}),\n },\n };\n}\n\nfunction resolveEffectiveWorkspace(\n office: Office,\n): Pick<WorkspaceProjection, \"doorPolicy\" | \"layout\" | \"visibility\"> {\n try {\n const settings = resolveConversationSettings(office).sandbox;\n if (settings?.workspace) {\n return normalizeWorkspace(\n settings.workspace.doorPolicy,\n settings.workspace.layout,\n settings.workspace.visibility,\n );\n }\n if (settings?.image?.workspaceMount) {\n return legacyWorkspace(settings.image.workspaceMount);\n }\n return platformDerivedWorkspace(office);\n } catch (err) {\n // Settings are host-authoritative. A malformed file must not fall back to\n // an unvalidated value from a mounted legacy location.\n log.logWarning(\n \"Refusing to resolve workspace projection from malformed settings\",\n err instanceof Error ? err.message : String(err),\n );\n throw new Error(\"Cannot resolve workspace projection: settings are malformed\", { cause: err });\n }\n}\n\n/**\n * No explicit workspace setting anywhere: follow the platform's own channel\n * vocabulary (modeled on Claude Tag). A public channel's knowledge is shared\n * workspace-wide read-write; a private channel reads the shared pool but\n * writes only its own conversation memory; DMs, externally shared channels,\n * and conversations whose kind was never observed stay fully isolated —\n * platform-public is a necessary condition for sharing, never assumed.\n * An admin's explicit setting (conversation or global) always wins over this.\n */\nfunction platformDerivedWorkspace(\n office: Office,\n): Pick<WorkspaceProjection, \"doorPolicy\" | \"layout\" | \"visibility\"> {\n switch (readPlatformChannelKind(office)) {\n case \"public_channel\":\n return { doorPolicy: \"trusted\", layout: \"shared-support\", visibility: \"public\" };\n case \"private_channel\":\n return { doorPolicy: \"trusted\", layout: \"shared-support\", visibility: \"private\" };\n default:\n return { doorPolicy: \"isolated\", layout: \"conversation\", visibility: \"public\" };\n }\n}\n\nfunction normalizeWorkspace(\n doorPolicy: WorkspaceDoorPolicy | undefined,\n layout: WorkspaceLayout | undefined,\n visibility: WorkspaceVisibility | undefined,\n): Pick<WorkspaceProjection, \"doorPolicy\" | \"layout\" | \"visibility\"> {\n const policy = doorPolicy ?? \"isolated\";\n if (policy === \"isolated\") {\n return { doorPolicy: policy, layout: \"conversation\", visibility: \"public\" };\n }\n return {\n doorPolicy: policy,\n layout: layout === \"full\" ? \"full\" : \"shared-support\",\n // Missing visibility defaults to \"public\": every office that predates this\n // setting keeps today's read-write shared MEMORY.md behavior unchanged.\n visibility: visibility ?? \"public\",\n };\n}\n\nfunction legacyWorkspace(\n mode: ImageWorkspaceMountMode | undefined,\n): Pick<WorkspaceProjection, \"doorPolicy\" | \"layout\" | \"visibility\"> {\n return mode === \"full\"\n ? { doorPolicy: \"trusted\", layout: \"full\", visibility: \"public\" }\n : mode === \"private\"\n ? { doorPolicy: \"trusted\", layout: \"shared-support\", visibility: \"public\" }\n : { doorPolicy: \"isolated\", layout: \"conversation\", visibility: \"public\" };\n}\n\nfunction ensureDirectoryRoot(path: string, label: string): void {\n if (!exists(path)) {\n mkdirSync(path, { recursive: true, mode: 0o700 });\n return;\n }\n assertDirectory(path, label);\n}\n\nfunction ensureRegularFile(path: string, label: string): void {\n if (!exists(path)) {\n ensureDirExists(dirname(path));\n writeFileSync(path, \"\", { mode: 0o600, flag: \"wx\" });\n return;\n }\n let stats;\n try {\n stats = lstatSync(path);\n } catch (err) {\n throw new Error(`${label} cannot be inspected: ${path}`, { cause: err });\n }\n if (stats.isSymbolicLink() || !stats.isFile()) {\n throw new Error(`${label} must be a regular non-symlink file: ${path}`);\n }\n}\n\nfunction assertDirectory(path: string, label: string): void {\n let stats;\n try {\n stats = lstatSync(path);\n } catch (err) {\n throw new Error(`${label} cannot be inspected: ${path}`, { cause: err });\n }\n if (stats.isSymbolicLink() || !stats.isDirectory()) {\n throw new Error(`${label} must be a regular non-symlink directory: ${path}`);\n }\n}\n\nfunction exists(path: string): boolean {\n try {\n lstatSync(path);\n return true;\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === \"ENOENT\") return false;\n throw err;\n }\n}\n"]}
|
|
@@ -1,14 +1,27 @@
|
|
|
1
|
-
import type { ContainerMount, WorkspaceDoorPolicy, WorkspaceLayout } from "../types.js";
|
|
1
|
+
import type { ContainerMount, WorkspaceDoorPolicy, WorkspaceLayout, WorkspaceVisibility } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* The conversation's platform-native channel kind, using the platform's own
|
|
4
|
+
* vocabulary (Slack conversation types), not a mikan-invented one. Recorded
|
|
5
|
+
* at message intake and used to derive the workspace projection when no
|
|
6
|
+
* explicit workspace setting exists: public channels share workspace memory
|
|
7
|
+
* read-write, private channels read it without writing back, DMs and
|
|
8
|
+
* externally shared channels stay isolated.
|
|
9
|
+
*/
|
|
10
|
+
export type PlatformChannelKind = "public_channel" | "private_channel" | "im" | "external";
|
|
2
11
|
interface WorkspacePromptSources {
|
|
3
12
|
conversationDir: string;
|
|
4
13
|
conversationMemoryPath: string;
|
|
5
14
|
conversationSkillsDir: string;
|
|
6
15
|
globalMemoryPath?: string;
|
|
7
16
|
globalSkillsDir?: string;
|
|
17
|
+
/** True when globalMemoryPath is mounted read-only (shared-support + private visibility). */
|
|
18
|
+
globalMemoryReadOnly?: boolean;
|
|
8
19
|
}
|
|
9
20
|
export interface WorkspaceProjection {
|
|
10
21
|
doorPolicy: WorkspaceDoorPolicy;
|
|
11
22
|
layout: WorkspaceLayout;
|
|
23
|
+
/** Only meaningful for shared-support layout; "public" is the default and preserves prior read-write behavior. */
|
|
24
|
+
visibility: WorkspaceVisibility;
|
|
12
25
|
mounts: ContainerMount[];
|
|
13
26
|
promptSources: WorkspacePromptSources;
|
|
14
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/workspace-projection/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/workspace-projection/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACpB,MAAM,aAAa,CAAC;AAErB;;;;;;;GAOG;AACH,MAAM,MAAM,mBAAmB,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,IAAI,GAAG,UAAU,CAAC;AAE3F,UAAU,sBAAsB;IAC9B,eAAe,EAAE,MAAM,CAAC;IACxB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,6FAA6F;IAC7F,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,mBAAmB,CAAC;IAChC,MAAM,EAAE,eAAe,CAAC;IACxB,kHAAkH;IAClH,UAAU,EAAE,mBAAmB,CAAC;IAChC,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,aAAa,EAAE,sBAAsB,CAAC;CACvC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/workspace-projection/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/workspace-projection/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n ContainerMount,\n WorkspaceDoorPolicy,\n WorkspaceLayout,\n WorkspaceVisibility,\n} from \"../types.js\";\n\n/**\n * The conversation's platform-native channel kind, using the platform's own\n * vocabulary (Slack conversation types), not a mikan-invented one. Recorded\n * at message intake and used to derive the workspace projection when no\n * explicit workspace setting exists: public channels share workspace memory\n * read-write, private channels read it without writing back, DMs and\n * externally shared channels stay isolated.\n */\nexport type PlatformChannelKind = \"public_channel\" | \"private_channel\" | \"im\" | \"external\";\n\ninterface WorkspacePromptSources {\n conversationDir: string;\n conversationMemoryPath: string;\n conversationSkillsDir: string;\n globalMemoryPath?: string;\n globalSkillsDir?: string;\n /** True when globalMemoryPath is mounted read-only (shared-support + private visibility). */\n globalMemoryReadOnly?: boolean;\n}\n\nexport interface WorkspaceProjection {\n doorPolicy: WorkspaceDoorPolicy;\n layout: WorkspaceLayout;\n /** Only meaningful for shared-support layout; \"public\" is the default and preserves prior read-write behavior. */\n visibility: WorkspaceVisibility;\n mounts: ContainerMount[];\n promptSources: WorkspacePromptSources;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geminixiang/mikan",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.46",
|
|
4
4
|
"description": "Multi-platform AI coding agent for Slack, Telegram, Discord, and GitHub",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -59,13 +59,11 @@
|
|
|
59
59
|
"test:e2e": "vitest --run --config .config/vitest.e2e.config.ts",
|
|
60
60
|
"test:e2e:slack": "vitest --run --config .config/vitest.e2e.config.ts e2e/slack",
|
|
61
61
|
"test:e2e:slack:coverage": "vitest --run --coverage --coverage.reportsDirectory=.workspace/coverage --config .config/vitest.e2e.config.ts e2e/slack",
|
|
62
|
-
"gondolin:image:build": "sh scripts/build-gondolin-image.sh",
|
|
63
62
|
"docs:dev": "astro dev --config .config/astro.config.mjs",
|
|
64
63
|
"docs:build": "astro build --config .config/astro.config.mjs",
|
|
65
64
|
"docs:preview": "astro preview --config .config/astro.config.mjs"
|
|
66
65
|
},
|
|
67
66
|
"dependencies": {
|
|
68
|
-
"@earendil-works/gondolin": "0.12.0",
|
|
69
67
|
"@earendil-works/pi-agent-core": "^0.84.3",
|
|
70
68
|
"@earendil-works/pi-ai": "^0.84.3",
|
|
71
69
|
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
@@ -78,7 +76,6 @@
|
|
|
78
76
|
"diff": "^9.0.0",
|
|
79
77
|
"discord.js": "^14.26.4",
|
|
80
78
|
"grammy": "^1.44.0",
|
|
81
|
-
"jiti": "^2.7.0",
|
|
82
79
|
"markdown-it": "^14.2.0",
|
|
83
80
|
"undici": "^8.5.0"
|
|
84
81
|
},
|
|
@@ -99,7 +96,8 @@
|
|
|
99
96
|
"remark-gfm": "^4.0.1",
|
|
100
97
|
"shx": "^0.4.0",
|
|
101
98
|
"typescript": "^6.0.3",
|
|
102
|
-
"vitest": "^4.1.9"
|
|
99
|
+
"vitest": "^4.1.9",
|
|
100
|
+
"zod": "^4.0.0"
|
|
103
101
|
},
|
|
104
102
|
"overrides": {
|
|
105
103
|
"@discordjs/rest": {
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export type { CloudBuildLogOptions } from "./types.js";
|
|
2
|
-
import type { CloudBuildLogOptions } from "./types.js";
|
|
3
|
-
/** Check runs reported by this app slug are Cloud Build builds. */
|
|
4
|
-
export declare const CLOUD_BUILD_APP_SLUG = "google-cloud-build";
|
|
5
|
-
export declare function isCloudBuildId(value: string): boolean;
|
|
6
|
-
/** GCP project (id or number) from a Cloud Build details_url, or null. */
|
|
7
|
-
export declare function projectFromDetailsUrl(detailsUrl: string | null | undefined): string | null;
|
|
8
|
-
export declare class CloudBuildLogUnavailableError extends Error {
|
|
9
|
-
readonly consoleUrl?: string | undefined;
|
|
10
|
-
constructor(message: string, consoleUrl?: string | undefined);
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Fetch one build's log text: builds.get → the `log-<id>.txt` object in the
|
|
14
|
-
* build's logs bucket. Throws CloudBuildLogUnavailableError (with the console
|
|
15
|
-
* url when known) whenever the log cannot be read — access denied, build not
|
|
16
|
-
* found, or CLOUD_LOGGING_ONLY builds that write no GCS object.
|
|
17
|
-
*/
|
|
18
|
-
export declare function fetchCloudBuildLog(options: CloudBuildLogOptions): Promise<string>;
|
|
19
|
-
//# sourceMappingURL=cloudbuild.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cloudbuild.d.ts","sourceRoot":"","sources":["../../../src/adapters/github/cloudbuild.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAevD,mEAAmE;AACnE,eAAO,MAAM,oBAAoB,uBAAuB,CAAC;AAIzD,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAErD;AAED,0EAA0E;AAC1E,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAQ1F;AAQD,qBAAa,6BAA8B,SAAQ,KAAK;aAGpC,UAAU,CAAC,EAAE,MAAM;IAFrC,YACE,OAAO,EAAE,MAAM,EACC,UAAU,CAAC,EAAE,MAAM,YAAA,EAIpC;CACF;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC,CAyCvF"}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Host-side Cloud Build log retrieval for `github_checks`. Cloud Build's
|
|
3
|
-
* GitHub App reports check runs whose `external_id` is the build UUID and
|
|
4
|
-
* whose `details_url` carries the GCP project; with ADC on the host (e.g. a
|
|
5
|
-
* WIF external_account file) the build's log object can be read from GCS.
|
|
6
|
-
*
|
|
7
|
-
* Required IAM for the ADC principal: roles/cloudbuild.builds.viewer on the
|
|
8
|
-
* project and roles/storage.objectViewer on the logs bucket.
|
|
9
|
-
*/
|
|
10
|
-
const CLOUDBUILD_API = "https://cloudbuild.googleapis.com/v1";
|
|
11
|
-
const GCS_API = "https://storage.googleapis.com/storage/v1";
|
|
12
|
-
/** Check runs reported by this app slug are Cloud Build builds. */
|
|
13
|
-
export const CLOUD_BUILD_APP_SLUG = "google-cloud-build";
|
|
14
|
-
const BUILD_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
15
|
-
export function isCloudBuildId(value) {
|
|
16
|
-
return BUILD_ID_PATTERN.test(value);
|
|
17
|
-
}
|
|
18
|
-
/** GCP project (id or number) from a Cloud Build details_url, or null. */
|
|
19
|
-
export function projectFromDetailsUrl(detailsUrl) {
|
|
20
|
-
if (!detailsUrl)
|
|
21
|
-
return null;
|
|
22
|
-
try {
|
|
23
|
-
const project = new URL(detailsUrl).searchParams.get("project");
|
|
24
|
-
return project || null;
|
|
25
|
-
}
|
|
26
|
-
catch {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
export class CloudBuildLogUnavailableError extends Error {
|
|
31
|
-
constructor(message, consoleUrl) {
|
|
32
|
-
super(message);
|
|
33
|
-
this.consoleUrl = consoleUrl;
|
|
34
|
-
this.name = "CloudBuildLogUnavailableError";
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Fetch one build's log text: builds.get → the `log-<id>.txt` object in the
|
|
39
|
-
* build's logs bucket. Throws CloudBuildLogUnavailableError (with the console
|
|
40
|
-
* url when known) whenever the log cannot be read — access denied, build not
|
|
41
|
-
* found, or CLOUD_LOGGING_ONLY builds that write no GCS object.
|
|
42
|
-
*/
|
|
43
|
-
export async function fetchCloudBuildLog(options) {
|
|
44
|
-
const fetchImpl = options.fetchImpl ?? fetch;
|
|
45
|
-
const token = await options.tokenProvider.getAccessToken();
|
|
46
|
-
const authHeaders = { Authorization: `Bearer ${token}` };
|
|
47
|
-
const buildResponse = await fetchImpl(`${CLOUDBUILD_API}/projects/${encodeURIComponent(options.project)}/builds/${encodeURIComponent(options.buildId)}`, { headers: authHeaders });
|
|
48
|
-
if (!buildResponse.ok) {
|
|
49
|
-
throw new CloudBuildLogUnavailableError(`Cloud Build builds.get failed with ${buildResponse.status} — check that the ADC ` +
|
|
50
|
-
`principal has roles/cloudbuild.builds.viewer on project ${options.project}.`);
|
|
51
|
-
}
|
|
52
|
-
const build = (await buildResponse.json());
|
|
53
|
-
if (!build.logsBucket) {
|
|
54
|
-
throw new CloudBuildLogUnavailableError("This build stores logs in Cloud Logging only (no GCS log object); read them in the console.", build.logUrl);
|
|
55
|
-
}
|
|
56
|
-
// logsBucket may be spelled gs://bucket or gs://bucket/some/prefix.
|
|
57
|
-
const bucketPath = build.logsBucket.replace(/^gs:\/\//, "");
|
|
58
|
-
const [bucket, ...prefixParts] = bucketPath.split("/");
|
|
59
|
-
const prefix = prefixParts.length > 0 ? `${prefixParts.join("/")}/` : "";
|
|
60
|
-
const objectName = encodeURIComponent(`${prefix}log-${options.buildId}.txt`);
|
|
61
|
-
const logResponse = await fetchImpl(`${GCS_API}/b/${bucket}/o/${objectName}?alt=media`, {
|
|
62
|
-
headers: authHeaders,
|
|
63
|
-
});
|
|
64
|
-
if (!logResponse.ok) {
|
|
65
|
-
throw new CloudBuildLogUnavailableError(`Cloud Build log object gs://${bucket}/${prefix}log-${options.buildId}.txt returned ` +
|
|
66
|
-
`${logResponse.status} — the ADC principal may lack roles/storage.objectViewer on the ` +
|
|
67
|
-
`logs bucket, or the build writes logs elsewhere.`, build.logUrl);
|
|
68
|
-
}
|
|
69
|
-
return logResponse.text();
|
|
70
|
-
}
|
|
71
|
-
//# sourceMappingURL=cloudbuild.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cloudbuild.js","sourceRoot":"","sources":["../../../src/adapters/github/cloudbuild.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AAEH,MAAM,cAAc,GAAG,sCAAsC,CAAC;AAC9D,MAAM,OAAO,GAAG,2CAA2C,CAAC;AAE5D,mEAAmE;AACnE,MAAM,CAAC,MAAM,oBAAoB,GAAG,oBAAoB,CAAC;AAEzD,MAAM,gBAAgB,GAAG,iEAAiE,CAAC;AAE3F,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,OAAO,gBAAgB,CAAC,IAAI,CAAC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AAa,CAAC,IAAI,EAAE,CAAoB,CAAC;IAE9D,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;QACtB,MAAM,IAAI,6BAA6B,CACrC,6FAA6F,EAC7F,KAAK,CAAC,MAAM,CACb,CAAC;IACJ,CAAC;IACD,oEAAoE;IACpE,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAC5D,MAAM,CAAC,MAAM,EAAE,GAAG,WAAW,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACvD,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACzE,MAAM,UAAU,GAAG,kBAAkB,CAAC,GAAG,MAAM,OAAO,OAAO,CAAC,OAAO,MAAM,CAAC,CAAC;IAE7E,MAAM,WAAW,GAAG,MAAM,SAAS,CAAC,GAAG,OAAO,MAAM,MAAM,MAAM,UAAU,YAAY,EAAE;QACtF,OAAO,EAAE,WAAW;KACrB,CAAC,CAAC;IACH,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,CAAC;QACpB,MAAM,IAAI,6BAA6B,CACrC,+BAA+B,MAAM,IAAI,MAAM,OAAO,OAAO,CAAC,OAAO,gBAAgB;YACnF,GAAG,WAAW,CAAC,MAAM,kEAAkE;YACvF,kDAAkD,EACpD,KAAK,CAAC,MAAM,CACb,CAAC;IACJ,CAAC;IACD,OAAO,WAAW,CAAC,IAAI,EAAE,CAAC;AAC5B,CAAC","sourcesContent":["export type { CloudBuildLogOptions } from \"./types.js\";\nimport type { CloudBuildLogOptions } from \"./types.js\";\n\n/**\n * Host-side Cloud Build log retrieval for `github_checks`. Cloud Build's\n * GitHub App reports check runs whose `external_id` is the build UUID and\n * whose `details_url` carries the GCP project; with ADC on the host (e.g. a\n * WIF external_account file) the build's log object can be read from GCS.\n *\n * Required IAM for the ADC principal: roles/cloudbuild.builds.viewer on the\n * project and roles/storage.objectViewer on the logs bucket.\n */\n\nconst CLOUDBUILD_API = \"https://cloudbuild.googleapis.com/v1\";\nconst GCS_API = \"https://storage.googleapis.com/storage/v1\";\n\n/** Check runs reported by this app slug are Cloud Build builds. */\nexport const CLOUD_BUILD_APP_SLUG = \"google-cloud-build\";\n\nconst BUILD_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\nexport function isCloudBuildId(value: string): boolean {\n return BUILD_ID_PATTERN.test(value);\n}\n\n/** GCP project (id or number) from a Cloud Build details_url, or null. */\nexport function projectFromDetailsUrl(detailsUrl: string | null | undefined): string | null {\n if (!detailsUrl) return null;\n try {\n const project = new URL(detailsUrl).searchParams.get(\"project\");\n return project || null;\n } catch {\n return null;\n }\n}\n\ninterface CloudBuildBuild {\n status?: string;\n logsBucket?: string;\n logUrl?: string;\n}\n\nexport class CloudBuildLogUnavailableError extends Error {\n constructor(\n message: string,\n public readonly consoleUrl?: string,\n ) {\n super(message);\n this.name = \"CloudBuildLogUnavailableError\";\n }\n}\n\n/**\n * Fetch one build's log text: builds.get → the `log-<id>.txt` object in the\n * build's logs bucket. Throws CloudBuildLogUnavailableError (with the console\n * url when known) whenever the log cannot be read — access denied, build not\n * found, or CLOUD_LOGGING_ONLY builds that write no GCS object.\n */\nexport async function fetchCloudBuildLog(options: CloudBuildLogOptions): Promise<string> {\n const fetchImpl = options.fetchImpl ?? fetch;\n const token = await options.tokenProvider.getAccessToken();\n const authHeaders = { Authorization: `Bearer ${token}` };\n\n const buildResponse = await fetchImpl(\n `${CLOUDBUILD_API}/projects/${encodeURIComponent(options.project)}/builds/${encodeURIComponent(options.buildId)}`,\n { headers: authHeaders },\n );\n if (!buildResponse.ok) {\n throw new CloudBuildLogUnavailableError(\n `Cloud Build builds.get failed with ${buildResponse.status} — check that the ADC ` +\n `principal has roles/cloudbuild.builds.viewer on project ${options.project}.`,\n );\n }\n const build = (await buildResponse.json()) as CloudBuildBuild;\n\n if (!build.logsBucket) {\n throw new CloudBuildLogUnavailableError(\n \"This build stores logs in Cloud Logging only (no GCS log object); read them in the console.\",\n build.logUrl,\n );\n }\n // logsBucket may be spelled gs://bucket or gs://bucket/some/prefix.\n const bucketPath = build.logsBucket.replace(/^gs:\\/\\//, \"\");\n const [bucket, ...prefixParts] = bucketPath.split(\"/\");\n const prefix = prefixParts.length > 0 ? `${prefixParts.join(\"/\")}/` : \"\";\n const objectName = encodeURIComponent(`${prefix}log-${options.buildId}.txt`);\n\n const logResponse = await fetchImpl(`${GCS_API}/b/${bucket}/o/${objectName}?alt=media`, {\n headers: authHeaders,\n });\n if (!logResponse.ok) {\n throw new CloudBuildLogUnavailableError(\n `Cloud Build log object gs://${bucket}/${prefix}log-${options.buildId}.txt returned ` +\n `${logResponse.status} — the ADC principal may lack roles/storage.objectViewer on the ` +\n `logs bucket, or the build writes logs elsewhere.`,\n build.logUrl,\n );\n }\n return logResponse.text();\n}\n"]}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export type { GcpTokenProviderOptions } from "./types.js";
|
|
2
|
-
import type { GcpTokenProviderOptions } from "./types.js";
|
|
3
|
-
export declare class GcpAuthError extends Error {
|
|
4
|
-
constructor(message: string, options?: {
|
|
5
|
-
cause?: unknown;
|
|
6
|
-
});
|
|
7
|
-
}
|
|
8
|
-
export declare class GcpTokenProvider {
|
|
9
|
-
private readonly credentialsPath;
|
|
10
|
-
private readonly fetchImpl;
|
|
11
|
-
private credentials;
|
|
12
|
-
private cached;
|
|
13
|
-
private inFlight;
|
|
14
|
-
constructor(options: GcpTokenProviderOptions);
|
|
15
|
-
/** A valid cloud-platform access token, cached until near expiry. */
|
|
16
|
-
getAccessToken(): Promise<string>;
|
|
17
|
-
private loadCredentials;
|
|
18
|
-
private mintToken;
|
|
19
|
-
private postForm;
|
|
20
|
-
/** WIF: read the subject token, exchange at STS, optionally impersonate. */
|
|
21
|
-
private mintExternalAccount;
|
|
22
|
-
private readSubjectToken;
|
|
23
|
-
/** Service-account key: self-signed RS256 JWT → assertion grant. */
|
|
24
|
-
private mintServiceAccount;
|
|
25
|
-
/** gcloud user ADC: refresh-token grant. */
|
|
26
|
-
private mintAuthorizedUser;
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=gcp-auth.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gcp-auth.d.ts","sourceRoot":"","sources":["../../../src/adapters/github/gcp-auth.ts"],"names":[],"mappings":"AAEA,YAAY,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AA2D1D,qBAAa,YAAa,SAAQ,KAAK;IACrC,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,EAGzD;CACF;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IACzC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAe;IACzC,OAAO,CAAC,WAAW,CAA+B;IAClD,OAAO,CAAC,MAAM,CAAqD;IACnE,OAAO,CAAC,QAAQ,CAAgC;IAEhD,YAAY,OAAO,EAAE,uBAAuB,EAG3C;IAED,qEAAqE;IAC/D,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,CAStC;IAED,OAAO,CAAC,eAAe;YAqBT,SAAS;YAqBT,QAAQ;IAiBtB,4EAA4E;YAC9D,mBAAmB;YA4CnB,gBAAgB;IA+B9B,oEAAoE;YACtD,kBAAkB;IAiChC,4CAA4C;YAC9B,kBAAkB;CAkBjC"}
|