@geminixiang/mikan 1.0.0-beta.9 → 1.0.0-beta.90
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 +337 -426
- package/README.md +102 -42
- package/dist/adapters/commands/admin.d.ts.map +1 -0
- package/dist/adapters/commands/admin.js +33 -0
- package/dist/adapters/commands/admin.js.map +1 -0
- package/dist/adapters/commands/auto-reply.d.ts +5 -0
- package/dist/adapters/commands/auto-reply.d.ts.map +1 -0
- package/dist/adapters/commands/auto-reply.js +47 -0
- package/dist/adapters/commands/auto-reply.js.map +1 -0
- package/dist/adapters/commands/login.d.ts +6 -0
- package/dist/adapters/commands/login.d.ts.map +1 -0
- package/dist/adapters/commands/login.js +158 -0
- package/dist/adapters/commands/login.js.map +1 -0
- package/dist/adapters/commands/manifest.d.ts +17 -0
- package/dist/adapters/commands/manifest.d.ts.map +1 -0
- package/dist/adapters/commands/manifest.js +121 -0
- package/dist/adapters/commands/manifest.js.map +1 -0
- package/dist/adapters/commands/model.d.ts +9 -0
- package/dist/adapters/commands/model.d.ts.map +1 -0
- package/dist/adapters/commands/model.js +136 -0
- package/dist/adapters/commands/model.js.map +1 -0
- package/dist/adapters/commands/new.d.ts.map +1 -0
- package/dist/adapters/commands/new.js +39 -0
- package/dist/adapters/commands/new.js.map +1 -0
- package/dist/adapters/commands/registry.d.ts +4 -0
- package/dist/adapters/commands/registry.d.ts.map +1 -0
- package/dist/adapters/commands/registry.js +35 -0
- package/dist/adapters/commands/registry.js.map +1 -0
- package/dist/adapters/commands/sandbox.d.ts +6 -0
- package/dist/adapters/commands/sandbox.d.ts.map +1 -0
- package/dist/adapters/commands/sandbox.js +125 -0
- package/dist/adapters/commands/sandbox.js.map +1 -0
- package/dist/adapters/commands/session-view.d.ts.map +1 -0
- package/dist/adapters/commands/session-view.js +46 -0
- package/dist/adapters/commands/session-view.js.map +1 -0
- package/dist/adapters/commands/types.d.ts +105 -0
- 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 +11 -0
- package/dist/adapters/commands/utils.d.ts.map +1 -0
- package/dist/adapters/commands/utils.js +43 -0
- package/dist/adapters/commands/utils.js.map +1 -0
- package/dist/adapters/discord/bot.d.ts +14 -18
- package/dist/adapters/discord/bot.d.ts.map +1 -1
- package/dist/adapters/discord/bot.js +234 -303
- package/dist/adapters/discord/bot.js.map +1 -1
- package/dist/adapters/discord/components.d.ts +4 -0
- package/dist/adapters/discord/components.d.ts.map +1 -0
- package/dist/adapters/discord/components.js +9 -0
- package/dist/adapters/discord/components.js.map +1 -0
- package/dist/adapters/discord/context.d.ts +3 -7
- package/dist/adapters/discord/context.d.ts.map +1 -1
- package/dist/adapters/discord/context.js +57 -219
- package/dist/adapters/discord/context.js.map +1 -1
- package/dist/adapters/discord/format.d.ts +2 -0
- package/dist/adapters/discord/format.d.ts.map +1 -0
- package/dist/adapters/discord/format.js +47 -0
- package/dist/adapters/discord/format.js.map +1 -0
- package/dist/adapters/discord/types.d.ts +91 -1
- package/dist/adapters/discord/types.d.ts.map +1 -1
- package/dist/adapters/discord/types.js.map +1 -1
- package/dist/adapters/github/activity.d.ts +3 -0
- package/dist/adapters/github/activity.d.ts.map +1 -0
- package/dist/adapters/github/activity.js +148 -0
- package/dist/adapters/github/activity.js.map +1 -0
- package/dist/adapters/github/bot.d.ts +24 -37
- package/dist/adapters/github/bot.d.ts.map +1 -1
- package/dist/adapters/github/bot.js +209 -397
- package/dist/adapters/github/bot.js.map +1 -1
- package/dist/adapters/github/client.d.ts +32 -49
- package/dist/adapters/github/client.d.ts.map +1 -1
- package/dist/adapters/github/client.js +108 -118
- package/dist/adapters/github/client.js.map +1 -1
- package/dist/adapters/github/context.d.ts +3 -8
- package/dist/adapters/github/context.d.ts.map +1 -1
- package/dist/adapters/github/context.js +74 -138
- package/dist/adapters/github/context.js.map +1 -1
- package/dist/adapters/github/github-ops.d.ts +14 -0
- package/dist/adapters/github/github-ops.d.ts.map +1 -0
- package/dist/adapters/github/github-ops.js +218 -0
- package/dist/adapters/github/github-ops.js.map +1 -0
- package/dist/adapters/github/ids.d.ts +2 -23
- package/dist/adapters/github/ids.d.ts.map +1 -1
- package/dist/adapters/github/ids.js +6 -36
- package/dist/adapters/github/ids.js.map +1 -1
- package/dist/adapters/github/policy.d.ts +19 -0
- package/dist/adapters/github/policy.d.ts.map +1 -0
- package/dist/adapters/github/policy.js +79 -0
- package/dist/adapters/github/policy.js.map +1 -0
- package/dist/adapters/github/tool-pack.d.ts +4 -0
- package/dist/adapters/github/tool-pack.d.ts.map +1 -0
- package/dist/adapters/github/tool-pack.js +40 -0
- package/dist/adapters/github/tool-pack.js.map +1 -0
- package/dist/adapters/github/tools/checks.d.ts +14 -0
- package/dist/adapters/github/tools/checks.d.ts.map +1 -0
- package/dist/adapters/github/tools/checks.js +78 -0
- package/dist/adapters/github/tools/checks.js.map +1 -0
- package/dist/adapters/github/tools/issue.d.ts +18 -0
- package/dist/adapters/github/tools/issue.d.ts.map +1 -0
- package/dist/adapters/github/tools/issue.js +44 -0
- package/dist/adapters/github/tools/issue.js.map +1 -0
- package/dist/adapters/github/tools/pr.d.ts +17 -0
- package/dist/adapters/github/tools/pr.d.ts.map +1 -0
- package/dist/adapters/github/tools/pr.js +40 -0
- package/dist/adapters/github/tools/pr.js.map +1 -0
- package/dist/adapters/github/tools/read.d.ts +17 -0
- package/dist/adapters/github/tools/read.d.ts.map +1 -0
- package/dist/adapters/github/tools/read.js +134 -0
- package/dist/adapters/github/tools/read.js.map +1 -0
- package/dist/adapters/github/tools/review-reply.d.ts +14 -0
- package/dist/adapters/github/tools/review-reply.d.ts.map +1 -0
- package/dist/adapters/github/tools/review-reply.js +34 -0
- package/dist/adapters/github/tools/review-reply.js.map +1 -0
- package/dist/adapters/github/types.d.ts +200 -57
- package/dist/adapters/github/types.d.ts.map +1 -1
- package/dist/adapters/github/types.js.map +1 -1
- package/dist/adapters/github/webhook.d.ts +7 -0
- package/dist/adapters/github/webhook.d.ts.map +1 -0
- package/dist/adapters/github/webhook.js +104 -0
- package/dist/adapters/github/webhook.js.map +1 -0
- package/dist/adapters/intake.d.ts +4 -10
- package/dist/adapters/intake.d.ts.map +1 -1
- package/dist/adapters/intake.js +85 -32
- package/dist/adapters/intake.js.map +1 -1
- package/dist/adapters/markdown-tables.d.ts +8 -0
- package/dist/adapters/markdown-tables.d.ts.map +1 -0
- package/dist/adapters/markdown-tables.js +111 -0
- package/dist/adapters/markdown-tables.js.map +1 -0
- package/dist/adapters/messages.d.ts +13 -0
- package/dist/adapters/messages.d.ts.map +1 -0
- package/dist/adapters/messages.js +39 -0
- package/dist/adapters/messages.js.map +1 -0
- package/dist/adapters/progressive-renderer.d.ts +7 -0
- package/dist/adapters/progressive-renderer.d.ts.map +1 -0
- package/dist/adapters/progressive-renderer.js +426 -0
- package/dist/adapters/progressive-renderer.js.map +1 -0
- package/dist/adapters/shared.d.ts +27 -53
- package/dist/adapters/shared.d.ts.map +1 -1
- package/dist/adapters/shared.js +167 -91
- package/dist/adapters/shared.js.map +1 -1
- package/dist/adapters/slack/assistant.d.ts +21 -0
- package/dist/adapters/slack/assistant.d.ts.map +1 -0
- package/dist/adapters/slack/assistant.js +103 -0
- package/dist/adapters/slack/assistant.js.map +1 -0
- package/dist/adapters/slack/auto-reply-context.d.ts +14 -0
- package/dist/adapters/slack/auto-reply-context.d.ts.map +1 -0
- package/dist/adapters/slack/auto-reply-context.js +21 -0
- package/dist/adapters/slack/auto-reply-context.js.map +1 -0
- package/dist/adapters/slack/blocks.d.ts +5 -0
- package/dist/adapters/slack/blocks.d.ts.map +1 -1
- package/dist/adapters/slack/blocks.js +144 -145
- package/dist/adapters/slack/blocks.js.map +1 -1
- package/dist/adapters/slack/bot.d.ts +60 -40
- package/dist/adapters/slack/bot.d.ts.map +1 -1
- package/dist/adapters/slack/bot.js +968 -588
- package/dist/adapters/slack/bot.js.map +1 -1
- package/dist/adapters/slack/context.d.ts +3 -9
- package/dist/adapters/slack/context.d.ts.map +1 -1
- package/dist/adapters/slack/context.js +8 -17
- package/dist/adapters/slack/context.js.map +1 -1
- package/dist/adapters/slack/jev-context.d.ts +17 -0
- package/dist/adapters/slack/jev-context.d.ts.map +1 -0
- package/dist/adapters/slack/jev-context.js +57 -0
- package/dist/adapters/slack/jev-context.js.map +1 -0
- package/dist/adapters/slack/markdown.d.ts +2 -0
- package/dist/adapters/slack/markdown.d.ts.map +1 -0
- package/dist/adapters/slack/markdown.js +43 -0
- package/dist/adapters/slack/markdown.js.map +1 -0
- package/dist/adapters/slack/persona.d.ts +6 -0
- package/dist/adapters/slack/persona.d.ts.map +1 -0
- package/dist/adapters/slack/persona.js +13 -0
- package/dist/adapters/slack/persona.js.map +1 -0
- package/dist/adapters/slack/response-lifecycle.d.ts +3 -4
- package/dist/adapters/slack/response-lifecycle.d.ts.map +1 -1
- package/dist/adapters/slack/response-lifecycle.js +222 -348
- package/dist/adapters/slack/response-lifecycle.js.map +1 -1
- package/dist/adapters/slack/session.d.ts +3 -2
- package/dist/adapters/slack/session.d.ts.map +1 -1
- package/dist/adapters/slack/session.js +9 -13
- package/dist/adapters/slack/session.js.map +1 -1
- package/dist/adapters/slack/stream-limits.d.ts +10 -0
- package/dist/adapters/slack/stream-limits.d.ts.map +1 -0
- package/dist/adapters/slack/stream-limits.js +22 -0
- package/dist/adapters/slack/stream-limits.js.map +1 -0
- package/dist/adapters/slack/task-intent.d.ts +19 -0
- package/dist/adapters/slack/task-intent.d.ts.map +1 -0
- package/dist/adapters/slack/task-intent.js +65 -0
- package/dist/adapters/slack/task-intent.js.map +1 -0
- package/dist/adapters/slack/task-status.d.ts +7 -0
- package/dist/adapters/slack/task-status.d.ts.map +1 -0
- package/dist/adapters/slack/task-status.js +96 -0
- package/dist/adapters/slack/task-status.js.map +1 -0
- package/dist/adapters/slack/tool-pack.d.ts +4 -0
- package/dist/adapters/slack/tool-pack.d.ts.map +1 -0
- package/dist/adapters/slack/tool-pack.js +40 -0
- package/dist/adapters/slack/tool-pack.js.map +1 -0
- package/dist/adapters/slack/tools/blockkit.d.ts +17 -0
- package/dist/adapters/slack/tools/blockkit.d.ts.map +1 -0
- package/dist/adapters/slack/tools/blockkit.js +98 -0
- package/dist/adapters/slack/tools/blockkit.js.map +1 -0
- package/dist/adapters/slack/types.d.ts +91 -5
- package/dist/adapters/slack/types.d.ts.map +1 -1
- package/dist/adapters/slack/types.js.map +1 -1
- package/dist/adapters/slack/update-diagnostics.d.ts +13 -0
- package/dist/adapters/slack/update-diagnostics.d.ts.map +1 -0
- package/dist/adapters/slack/update-diagnostics.js +128 -0
- package/dist/adapters/slack/update-diagnostics.js.map +1 -0
- package/dist/adapters/telegram/bot.d.ts +12 -19
- package/dist/adapters/telegram/bot.d.ts.map +1 -1
- package/dist/adapters/telegram/bot.js +114 -239
- package/dist/adapters/telegram/bot.js.map +1 -1
- package/dist/adapters/telegram/context.d.ts +3 -7
- package/dist/adapters/telegram/context.d.ts.map +1 -1
- package/dist/adapters/telegram/context.js +49 -191
- package/dist/adapters/telegram/context.js.map +1 -1
- package/dist/adapters/telegram/types.d.ts +24 -1
- package/dist/adapters/telegram/types.d.ts.map +1 -1
- package/dist/adapters/telegram/types.js.map +1 -1
- package/dist/adapters/types.d.ts +92 -17
- package/dist/adapters/types.d.ts.map +1 -1
- package/dist/adapters/types.js.map +1 -1
- package/dist/adapters/web/admin/client-assets.d.ts +4 -0
- package/dist/adapters/web/admin/client-assets.d.ts.map +1 -0
- package/dist/adapters/web/admin/client-assets.js +1766 -0
- package/dist/adapters/web/admin/client-assets.js.map +1 -0
- package/dist/adapters/web/admin/portal.d.ts +26 -0
- package/dist/adapters/web/admin/portal.d.ts.map +1 -0
- package/dist/adapters/web/admin/portal.js +1490 -0
- package/dist/adapters/web/admin/portal.js.map +1 -0
- package/dist/adapters/web/admin/provider-models.d.ts +10 -0
- package/dist/adapters/web/admin/provider-models.d.ts.map +1 -0
- package/dist/adapters/web/admin/provider-models.js +103 -0
- package/dist/adapters/web/admin/provider-models.js.map +1 -0
- package/dist/adapters/web/admin/types.d.ts +54 -0
- 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 +4 -0
- package/dist/adapters/web/login/oauth.d.ts.map +1 -0
- package/dist/adapters/web/login/oauth.js +219 -0
- package/dist/adapters/web/login/oauth.js.map +1 -0
- package/dist/adapters/web/login/portal.d.ts +10 -0
- package/dist/adapters/web/login/portal.d.ts.map +1 -0
- package/dist/adapters/web/login/portal.js +1336 -0
- package/dist/adapters/web/login/portal.js.map +1 -0
- package/dist/adapters/web/login/types.d.ts +34 -0
- package/dist/adapters/web/login/types.d.ts.map +1 -0
- package/dist/adapters/web/login/types.js.map +1 -0
- package/dist/adapters/web/portal-shell.d.ts +9 -0
- package/dist/adapters/web/portal-shell.d.ts.map +1 -0
- package/dist/adapters/web/portal-shell.js +428 -0
- package/dist/adapters/web/portal-shell.js.map +1 -0
- package/dist/adapters/web/server.d.ts +35 -0
- package/dist/adapters/web/server.d.ts.map +1 -0
- package/dist/adapters/web/server.js +80 -0
- package/dist/adapters/web/server.js.map +1 -0
- package/dist/adapters/web/session-view/portal.d.ts +19 -0
- package/dist/adapters/web/session-view/portal.d.ts.map +1 -0
- package/dist/adapters/web/session-view/portal.js +1833 -0
- package/dist/adapters/web/session-view/portal.js.map +1 -0
- package/dist/adapters/web/session-view/types.d.ts +45 -0
- 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 +10 -0
- package/dist/adapters/web/token-store.d.ts.map +1 -0
- package/dist/adapters/web/token-store.js +42 -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 +8 -0
- package/dist/cli/arg-grammar.d.ts.map +1 -0
- package/dist/cli/arg-grammar.js +47 -0
- package/dist/cli/arg-grammar.js.map +1 -0
- package/dist/cli/boot.d.ts +4 -0
- package/dist/cli/boot.d.ts.map +1 -0
- package/dist/cli/boot.js +79 -0
- package/dist/cli/boot.js.map +1 -0
- package/dist/cli/download.d.ts.map +1 -0
- package/dist/cli/download.js +84 -0
- package/dist/cli/download.js.map +1 -0
- package/dist/cli/migrate.d.ts +3 -0
- package/dist/cli/migrate.d.ts.map +1 -0
- package/dist/cli/migrate.js +74 -0
- package/dist/cli/migrate.js.map +1 -0
- package/dist/cli/office.d.ts +2 -0
- package/dist/cli/office.d.ts.map +1 -0
- package/dist/cli/office.js +30 -0
- package/dist/cli/office.js.map +1 -0
- package/dist/cli/onboard.d.ts +7 -0
- package/dist/cli/onboard.d.ts.map +1 -0
- package/dist/cli/onboard.js +192 -0
- package/dist/cli/onboard.js.map +1 -0
- package/dist/cli/process-lifecycle.d.ts +14 -0
- package/dist/cli/process-lifecycle.d.ts.map +1 -0
- package/dist/cli/process-lifecycle.js +61 -0
- package/dist/cli/process-lifecycle.js.map +1 -0
- package/dist/cli/types.d.ts +20 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/env-manifest.d.ts +14 -0
- package/dist/env-manifest.d.ts.map +1 -0
- package/dist/env-manifest.js +255 -0
- package/dist/env-manifest.js.map +1 -0
- package/dist/events/index.d.ts +105 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +252 -0
- package/dist/events/index.js.map +1 -0
- package/dist/events/scheduler.d.ts +24 -0
- package/dist/events/scheduler.d.ts.map +1 -0
- package/dist/events/scheduler.js +221 -0
- package/dist/events/scheduler.js.map +1 -0
- package/dist/file-guards.d.ts +20 -0
- package/dist/file-guards.d.ts.map +1 -0
- package/dist/file-guards.js +166 -0
- package/dist/file-guards.js.map +1 -0
- package/dist/harness/budget-stop.d.ts +3 -0
- package/dist/harness/budget-stop.d.ts.map +1 -0
- package/dist/harness/budget-stop.js +36 -0
- package/dist/harness/budget-stop.js.map +1 -0
- package/dist/harness/execution-env.d.ts +4 -0
- package/dist/harness/execution-env.d.ts.map +1 -0
- package/dist/harness/execution-env.js +245 -0
- package/dist/harness/execution-env.js.map +1 -0
- package/dist/harness/execution-resolver.d.ts +23 -0
- package/dist/harness/execution-resolver.d.ts.map +1 -0
- package/dist/harness/execution-resolver.js +152 -0
- package/dist/harness/execution-resolver.js.map +1 -0
- package/dist/harness/http.d.ts +0 -12
- package/dist/harness/http.d.ts.map +1 -1
- package/dist/harness/http.js +0 -34
- package/dist/harness/http.js.map +1 -1
- package/dist/harness/index.d.ts +18 -17
- package/dist/harness/index.d.ts.map +1 -1
- package/dist/harness/index.js +11 -15
- package/dist/harness/index.js.map +1 -1
- package/dist/harness/jev.d.ts +67 -0
- package/dist/harness/jev.d.ts.map +1 -0
- package/dist/harness/jev.js +135 -0
- package/dist/harness/jev.js.map +1 -0
- package/dist/harness/loop-guard.d.ts +10 -0
- package/dist/harness/loop-guard.d.ts.map +1 -0
- package/dist/harness/loop-guard.js +111 -0
- package/dist/harness/loop-guard.js.map +1 -0
- package/dist/harness/mcp-result.d.ts +21 -0
- package/dist/harness/mcp-result.d.ts.map +1 -0
- package/dist/harness/mcp-result.js +193 -0
- package/dist/harness/mcp-result.js.map +1 -0
- package/dist/harness/mcp.d.ts +17 -0
- package/dist/harness/mcp.d.ts.map +1 -0
- package/dist/harness/mcp.js +287 -0
- package/dist/harness/mcp.js.map +1 -0
- package/dist/harness/models.d.ts +2 -19
- package/dist/harness/models.d.ts.map +1 -1
- package/dist/harness/models.js +43 -95
- package/dist/harness/models.js.map +1 -1
- package/dist/harness/open-connector.d.ts +3 -0
- package/dist/harness/open-connector.d.ts.map +1 -0
- package/dist/harness/open-connector.js +106 -0
- package/dist/harness/open-connector.js.map +1 -0
- package/dist/harness/presenter.d.ts +11 -0
- package/dist/harness/presenter.d.ts.map +1 -0
- package/dist/harness/presenter.js +867 -0
- package/dist/harness/presenter.js.map +1 -0
- package/dist/harness/prompt.d.ts +17 -0
- package/dist/harness/prompt.d.ts.map +1 -0
- package/dist/harness/prompt.js +348 -0
- package/dist/harness/prompt.js.map +1 -0
- package/dist/harness/run-events.d.ts +10 -0
- package/dist/harness/run-events.d.ts.map +1 -0
- package/dist/harness/run-events.js +126 -0
- package/dist/harness/run-events.js.map +1 -0
- package/dist/harness/runner.d.ts +2 -123
- package/dist/harness/runner.d.ts.map +1 -1
- package/dist/harness/runner.js +570 -414
- package/dist/harness/runner.js.map +1 -1
- package/dist/harness/session.d.ts +102 -0
- package/dist/harness/session.d.ts.map +1 -0
- package/dist/harness/session.js +720 -0
- package/dist/harness/session.js.map +1 -0
- package/dist/harness/skills.d.ts +7 -41
- package/dist/harness/skills.d.ts.map +1 -1
- package/dist/harness/skills.js +120 -69
- package/dist/harness/skills.js.map +1 -1
- package/dist/harness/subagent-profiles.d.ts +3 -0
- package/dist/harness/subagent-profiles.d.ts.map +1 -0
- package/dist/harness/subagent-profiles.js +260 -0
- package/dist/harness/subagent-profiles.js.map +1 -0
- package/dist/harness/subagent.d.ts +39 -0
- package/dist/harness/subagent.d.ts.map +1 -0
- package/dist/harness/subagent.js +613 -0
- package/dist/harness/subagent.js.map +1 -0
- package/dist/harness/tool-args.d.ts +2 -0
- package/dist/harness/tool-args.d.ts.map +1 -0
- package/dist/harness/tool-args.js +20 -0
- package/dist/harness/tool-args.js.map +1 -0
- package/dist/harness/tools/attach.d.ts +13 -0
- package/dist/harness/tools/attach.d.ts.map +1 -0
- package/dist/harness/tools/attach.js +39 -0
- package/dist/harness/tools/attach.js.map +1 -0
- package/dist/harness/tools/codemode.d.ts +3 -0
- package/dist/harness/tools/codemode.d.ts.map +1 -0
- package/dist/harness/tools/codemode.js +173 -0
- package/dist/harness/tools/codemode.js.map +1 -0
- package/dist/harness/tools/event.d.ts +28 -0
- package/dist/harness/tools/event.d.ts.map +1 -0
- package/dist/harness/tools/event.js +183 -0
- package/dist/harness/tools/event.js.map +1 -0
- package/dist/harness/tools/generate-image.d.ts +20 -0
- package/dist/harness/tools/generate-image.d.ts.map +1 -0
- package/dist/harness/tools/generate-image.js +82 -0
- package/dist/harness/tools/generate-image.js.map +1 -0
- package/dist/harness/tools/history.d.ts +20 -0
- package/dist/harness/tools/history.d.ts.map +1 -0
- package/dist/harness/tools/history.js +293 -0
- package/dist/harness/tools/history.js.map +1 -0
- package/dist/harness/tools/host-fn-tool.d.ts +14 -0
- package/dist/harness/tools/host-fn-tool.d.ts.map +1 -0
- package/dist/harness/tools/host-fn-tool.js +39 -0
- package/dist/harness/tools/host-fn-tool.js.map +1 -0
- package/dist/harness/tools/index.d.ts +34 -0
- package/dist/harness/tools/index.d.ts.map +1 -0
- package/dist/harness/tools/index.js +49 -0
- package/dist/harness/tools/index.js.map +1 -0
- package/dist/harness/tools/jev-browser.d.ts +41 -0
- package/dist/harness/tools/jev-browser.d.ts.map +1 -0
- package/dist/harness/tools/jev-browser.js +570 -0
- package/dist/harness/tools/jev-browser.js.map +1 -0
- package/dist/harness/tools/jev.d.ts +15 -0
- package/dist/harness/tools/jev.d.ts.map +1 -0
- package/dist/harness/tools/jev.js +98 -0
- package/dist/harness/tools/jev.js.map +1 -0
- package/dist/harness/tools/pi-tools.d.ts +8 -0
- package/dist/harness/tools/pi-tools.d.ts.map +1 -0
- package/dist/harness/tools/pi-tools.js +81 -0
- package/dist/harness/tools/pi-tools.js.map +1 -0
- package/dist/harness/tools/react.d.ts +12 -0
- package/dist/harness/tools/react.d.ts.map +1 -0
- package/dist/harness/tools/react.js +25 -0
- package/dist/harness/tools/react.js.map +1 -0
- package/dist/harness/tools/sandbox.d.ts +24 -0
- package/dist/harness/tools/sandbox.d.ts.map +1 -0
- package/dist/harness/tools/sandbox.js +79 -0
- package/dist/harness/tools/sandbox.js.map +1 -0
- package/dist/harness/tools/secret-redaction.d.ts +9 -0
- package/dist/harness/tools/secret-redaction.d.ts.map +1 -0
- package/dist/harness/tools/secret-redaction.js +88 -0
- package/dist/harness/tools/secret-redaction.js.map +1 -0
- package/dist/harness/tools/subagent.d.ts +51 -0
- package/dist/harness/tools/subagent.d.ts.map +1 -0
- package/dist/harness/tools/subagent.js +581 -0
- package/dist/harness/tools/subagent.js.map +1 -0
- package/dist/harness/tools/task.d.ts +22 -0
- package/dist/harness/tools/task.d.ts.map +1 -0
- package/dist/harness/tools/task.js +80 -0
- package/dist/harness/tools/task.js.map +1 -0
- package/dist/harness/tools/tool-search.d.ts +5 -0
- package/dist/harness/tools/tool-search.d.ts.map +1 -0
- package/dist/harness/tools/tool-search.js +84 -0
- package/dist/harness/tools/tool-search.js.map +1 -0
- package/dist/harness/tools/types.d.ts +14 -0
- 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 +482 -29
- 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 +31 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -7
- package/dist/index.js.map +1 -1
- package/dist/log.d.ts +0 -4
- package/dist/log.d.ts.map +1 -1
- package/dist/log.js +3 -28
- package/dist/log.js.map +1 -1
- package/dist/main.js +282 -258
- package/dist/main.js.map +1 -1
- package/dist/memory-capture/index.d.ts +15 -0
- package/dist/memory-capture/index.d.ts.map +1 -0
- package/dist/memory-capture/index.js +198 -0
- package/dist/memory-capture/index.js.map +1 -0
- package/dist/memory-capture/types.d.ts +27 -0
- package/dist/memory-capture/types.d.ts.map +1 -0
- package/dist/memory-capture/types.js +2 -0
- package/dist/memory-capture/types.js.map +1 -0
- package/dist/migrations/actor-vaults.d.ts +3 -0
- package/dist/migrations/actor-vaults.d.ts.map +1 -0
- package/dist/migrations/actor-vaults.js +43 -0
- package/dist/migrations/actor-vaults.js.map +1 -0
- package/dist/migrations/conversation-settings.d.ts +3 -0
- package/dist/migrations/conversation-settings.d.ts.map +1 -0
- package/dist/migrations/conversation-settings.js +31 -0
- package/dist/migrations/conversation-settings.js.map +1 -0
- package/dist/migrations/dream-checkpoints.d.ts +3 -0
- package/dist/migrations/dream-checkpoints.d.ts.map +1 -0
- package/dist/migrations/dream-checkpoints.js +23 -0
- package/dist/migrations/dream-checkpoints.js.map +1 -0
- package/dist/migrations/index.d.ts +14 -0
- package/dist/migrations/index.d.ts.map +1 -0
- package/dist/migrations/index.js +105 -0
- package/dist/migrations/index.js.map +1 -0
- package/dist/migrations/models-json.d.ts +3 -0
- package/dist/migrations/models-json.d.ts.map +1 -0
- package/dist/migrations/models-json.js +18 -0
- package/dist/migrations/models-json.js.map +1 -0
- package/dist/migrations/office-layout.d.ts +4 -0
- package/dist/migrations/office-layout.d.ts.map +1 -0
- package/dist/migrations/office-layout.js +94 -0
- package/dist/migrations/office-layout.js.map +1 -0
- package/dist/migrations/office-sessions.d.ts +3 -0
- package/dist/migrations/office-sessions.d.ts.map +1 -0
- package/dist/migrations/office-sessions.js +81 -0
- package/dist/migrations/office-sessions.js.map +1 -0
- package/dist/migrations/private-office-dirs.d.ts +3 -0
- package/dist/migrations/private-office-dirs.d.ts.map +1 -0
- package/dist/migrations/private-office-dirs.js +24 -0
- package/dist/migrations/private-office-dirs.js.map +1 -0
- package/dist/migrations/sandbox-containers.d.ts +3 -0
- package/dist/migrations/sandbox-containers.d.ts.map +1 -0
- package/dist/migrations/sandbox-containers.js +36 -0
- package/dist/migrations/sandbox-containers.js.map +1 -0
- package/dist/migrations/session-files.d.ts +28 -0
- package/dist/migrations/session-files.d.ts.map +1 -0
- package/dist/migrations/session-files.js +80 -0
- package/dist/migrations/session-files.js.map +1 -0
- package/dist/migrations/session-v4.d.ts +77 -0
- package/dist/migrations/session-v4.d.ts.map +1 -0
- package/dist/migrations/session-v4.js +177 -0
- package/dist/migrations/session-v4.js.map +1 -0
- package/dist/migrations/sessions-sqlite.d.ts +3 -0
- package/dist/migrations/sessions-sqlite.d.ts.map +1 -0
- package/dist/migrations/sessions-sqlite.js +215 -0
- package/dist/migrations/sessions-sqlite.js.map +1 -0
- package/dist/migrations/sessions-v3.d.ts +8 -0
- package/dist/migrations/sessions-v3.d.ts.map +1 -0
- package/dist/migrations/sessions-v3.js +350 -0
- package/dist/migrations/sessions-v3.js.map +1 -0
- package/dist/migrations/types.d.ts +25 -0
- package/dist/migrations/types.d.ts.map +1 -0
- package/dist/migrations/types.js +2 -0
- package/dist/migrations/types.js.map +1 -0
- package/dist/migrations/workspace-events.d.ts +3 -0
- package/dist/migrations/workspace-events.d.ts.map +1 -0
- package/dist/migrations/workspace-events.js +43 -0
- package/dist/migrations/workspace-events.js.map +1 -0
- package/dist/observability/index.d.ts +30 -0
- package/dist/observability/index.d.ts.map +1 -0
- package/dist/observability/index.js +273 -0
- package/dist/observability/index.js.map +1 -0
- package/dist/observability/instrument.js +9 -6
- 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 +182 -0
- package/dist/observability/otel.js.map +1 -0
- package/dist/observability/sentry.d.ts +30 -18
- package/dist/observability/sentry.d.ts.map +1 -1
- package/dist/observability/sentry.js +94 -119
- package/dist/observability/sentry.js.map +1 -1
- package/dist/observability/types.d.ts +30 -19
- package/dist/observability/types.d.ts.map +1 -1
- package/dist/observability/types.js.map +1 -1
- package/dist/office/index.d.ts +49 -0
- package/dist/office/index.d.ts.map +1 -0
- package/dist/office/index.js +395 -0
- package/dist/office/index.js.map +1 -0
- package/dist/office/projection.d.ts +11 -0
- package/dist/office/projection.d.ts.map +1 -0
- package/dist/office/projection.js +145 -0
- package/dist/office/projection.js.map +1 -0
- package/dist/office/types.d.ts +44 -0
- package/dist/office/types.d.ts.map +1 -0
- package/dist/office/types.js +2 -0
- package/dist/office/types.js.map +1 -0
- package/dist/runtime/conversation-runtime.d.ts +0 -1
- package/dist/runtime/conversation-runtime.d.ts.map +1 -1
- package/dist/runtime/conversation-runtime.js +365 -155
- package/dist/runtime/conversation-runtime.js.map +1 -1
- package/dist/runtime/session-lifecycle.d.ts +65 -0
- package/dist/runtime/session-lifecycle.d.ts.map +1 -0
- package/dist/runtime/session-lifecycle.js +384 -0
- package/dist/runtime/session-lifecycle.js.map +1 -0
- package/dist/runtime/types.d.ts +42 -20
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/runtime/types.js.map +1 -1
- package/dist/sandbox/cloudflare.d.ts +4 -0
- package/dist/sandbox/cloudflare.d.ts.map +1 -1
- package/dist/sandbox/cloudflare.js +59 -55
- package/dist/sandbox/cloudflare.js.map +1 -1
- package/dist/sandbox/container.d.ts +3 -0
- package/dist/sandbox/container.d.ts.map +1 -1
- package/dist/sandbox/container.js +39 -20
- package/dist/sandbox/container.js.map +1 -1
- package/dist/sandbox/host.d.ts +3 -0
- package/dist/sandbox/host.d.ts.map +1 -1
- package/dist/sandbox/host.js +42 -35
- package/dist/sandbox/host.js.map +1 -1
- package/dist/sandbox/identity.d.ts +12 -0
- package/dist/sandbox/identity.d.ts.map +1 -0
- package/dist/sandbox/identity.js +42 -0
- package/dist/sandbox/identity.js.map +1 -0
- package/dist/sandbox/index.d.ts +5 -15
- package/dist/sandbox/index.d.ts.map +1 -1
- package/dist/sandbox/index.js +5 -51
- package/dist/sandbox/index.js.map +1 -1
- package/dist/sandbox/layout.d.ts +5 -0
- package/dist/sandbox/layout.d.ts.map +1 -0
- package/dist/sandbox/layout.js +13 -0
- package/dist/sandbox/layout.js.map +1 -0
- package/dist/sandbox/provisioner.d.ts +64 -0
- package/dist/sandbox/provisioner.d.ts.map +1 -0
- package/dist/sandbox/provisioner.js +546 -0
- package/dist/sandbox/provisioner.js.map +1 -0
- package/dist/sandbox/registry.d.ts +12 -0
- package/dist/sandbox/registry.d.ts.map +1 -0
- package/dist/sandbox/registry.js +93 -0
- package/dist/sandbox/registry.js.map +1 -0
- package/dist/sandbox/types.d.ts +23 -25
- package/dist/sandbox/types.d.ts.map +1 -1
- package/dist/sandbox/types.js.map +1 -1
- package/dist/sandbox/utils.d.ts +21 -0
- package/dist/sandbox/utils.d.ts.map +1 -1
- package/dist/sandbox/utils.js +100 -8
- package/dist/sandbox/utils.js.map +1 -1
- package/dist/sessions/chat-history-sync.d.ts +19 -0
- package/dist/sessions/chat-history-sync.d.ts.map +1 -0
- package/dist/sessions/chat-history-sync.js +459 -0
- package/dist/sessions/chat-history-sync.js.map +1 -0
- package/dist/sessions/compaction-summary.d.ts +4 -0
- package/dist/sessions/compaction-summary.d.ts.map +1 -0
- package/dist/sessions/compaction-summary.js +16 -0
- package/dist/sessions/compaction-summary.js.map +1 -0
- package/dist/sessions/history-line.d.ts +10 -0
- package/dist/sessions/history-line.d.ts.map +1 -0
- package/dist/sessions/history-line.js +29 -0
- package/dist/sessions/history-line.js.map +1 -0
- package/dist/sessions/session-key.d.ts +19 -0
- package/dist/sessions/session-key.d.ts.map +1 -0
- package/dist/sessions/session-key.js +91 -0
- package/dist/sessions/session-key.js.map +1 -0
- package/dist/sessions/session-store.d.ts +73 -0
- package/dist/sessions/session-store.d.ts.map +1 -0
- package/dist/sessions/session-store.js +722 -0
- package/dist/sessions/session-store.js.map +1 -0
- package/dist/sessions/types.d.ts +90 -34
- package/dist/sessions/types.d.ts.map +1 -1
- package/dist/sessions/types.js +2 -1
- package/dist/sessions/types.js.map +1 -1
- package/dist/settings/apply.d.ts +9 -0
- package/dist/settings/apply.d.ts.map +1 -0
- package/dist/settings/apply.js +31 -0
- package/dist/settings/apply.js.map +1 -0
- package/dist/settings/index.d.ts +28 -0
- package/dist/settings/index.d.ts.map +1 -0
- package/dist/settings/index.js +320 -0
- package/dist/settings/index.js.map +1 -0
- package/dist/types.d.ts +209 -191
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -3
- package/dist/types.js.map +1 -1
- package/dist/unknown-values.d.ts +3 -0
- package/dist/unknown-values.d.ts.map +1 -0
- package/dist/unknown-values.js +7 -0
- package/dist/unknown-values.js.map +1 -0
- package/dist/vault/index.d.ts +28 -11
- package/dist/vault/index.d.ts.map +1 -1
- package/dist/vault/index.js +291 -118
- package/dist/vault/index.js.map +1 -1
- package/dist/vault/types.d.ts +5 -19
- package/dist/vault/types.d.ts.map +1 -1
- package/dist/vault/types.js.map +1 -1
- package/package.json +87 -41
- package/dist/adapter.d.ts +0 -2
- package/dist/adapter.d.ts.map +0 -1
- package/dist/adapter.js +0 -2
- package/dist/adapter.js.map +0 -1
- package/dist/adapters/github/repo.d.ts +0 -19
- package/dist/adapters/github/repo.d.ts.map +0 -1
- package/dist/adapters/github/repo.js +0 -58
- package/dist/adapters/github/repo.js.map +0 -1
- package/dist/adapters/slack/tools/attach.d.ts +0 -12
- package/dist/adapters/slack/tools/attach.d.ts.map +0 -1
- package/dist/adapters/slack/tools/attach.js +0 -39
- package/dist/adapters/slack/tools/attach.js.map +0 -1
- package/dist/adapters/streaming.d.ts +0 -18
- package/dist/adapters/streaming.d.ts.map +0 -1
- package/dist/adapters/streaming.js +0 -44
- package/dist/adapters/streaming.js.map +0 -1
- package/dist/adapters/telegram/html.d.ts +0 -3
- package/dist/adapters/telegram/html.d.ts.map +0 -1
- package/dist/adapters/telegram/html.js +0 -98
- package/dist/adapters/telegram/html.js.map +0 -1
- package/dist/agent-events.d.ts +0 -5
- package/dist/agent-events.d.ts.map +0 -1
- package/dist/agent-events.js +0 -26
- package/dist/agent-events.js.map +0 -1
- package/dist/agent.d.ts +0 -39
- package/dist/agent.d.ts.map +0 -1
- package/dist/agent.js +0 -1299
- package/dist/agent.js.map +0 -1
- package/dist/cli/ext-git.d.ts +0 -22
- package/dist/cli/ext-git.d.ts.map +0 -1
- package/dist/cli/ext-git.js +0 -76
- package/dist/cli/ext-git.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 -217
- package/dist/cli/ext.js.map +0 -1
- package/dist/commands/admin.d.ts.map +0 -1
- package/dist/commands/admin.js +0 -30
- 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 -76
- package/dist/commands/auto-reply.js.map +0 -1
- package/dist/commands/extensions.d.ts +0 -14
- package/dist/commands/extensions.d.ts.map +0 -1
- package/dist/commands/extensions.js +0 -55
- package/dist/commands/extensions.js.map +0 -1
- package/dist/commands/login.d.ts +0 -5
- package/dist/commands/login.d.ts.map +0 -1
- package/dist/commands/login.js +0 -115
- package/dist/commands/login.js.map +0 -1
- package/dist/commands/model.d.ts +0 -10
- package/dist/commands/model.d.ts.map +0 -1
- package/dist/commands/model.js +0 -102
- package/dist/commands/model.js.map +0 -1
- package/dist/commands/new.d.ts.map +0 -1
- package/dist/commands/new.js +0 -25
- package/dist/commands/new.js.map +0 -1
- package/dist/commands/parse.d.ts +0 -7
- package/dist/commands/parse.d.ts.map +0 -1
- package/dist/commands/parse.js +0 -14
- package/dist/commands/parse.js.map +0 -1
- package/dist/commands/registry.d.ts +0 -5
- package/dist/commands/registry.d.ts.map +0 -1
- package/dist/commands/registry.js +0 -31
- package/dist/commands/registry.js.map +0 -1
- package/dist/commands/sandbox.d.ts +0 -7
- package/dist/commands/sandbox.d.ts.map +0 -1
- package/dist/commands/sandbox.js +0 -78
- package/dist/commands/sandbox.js.map +0 -1
- package/dist/commands/session-view.d.ts.map +0 -1
- package/dist/commands/session-view.js +0 -41
- package/dist/commands/session-view.js.map +0 -1
- package/dist/commands/types.d.ts +0 -66
- 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 +0 -29
- package/dist/commands/utils.js.map +0 -1
- package/dist/config.d.ts +0 -78
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -450
- package/dist/config.js.map +0 -1
- package/dist/download.d.ts.map +0 -1
- package/dist/download.js +0 -89
- package/dist/download.js.map +0 -1
- package/dist/events.d.ts +0 -43
- package/dist/events.d.ts.map +0 -1
- package/dist/events.js +0 -456
- package/dist/events.js.map +0 -1
- package/dist/execution-resolver.d.ts +0 -21
- package/dist/execution-resolver.d.ts.map +0 -1
- package/dist/execution-resolver.js +0 -170
- package/dist/execution-resolver.js.map +0 -1
- package/dist/harness/auth.d.ts +0 -16
- package/dist/harness/auth.d.ts.map +0 -1
- package/dist/harness/auth.js +0 -86
- package/dist/harness/auth.js.map +0 -1
- package/dist/harness/extensions/loader.d.ts +0 -86
- package/dist/harness/extensions/loader.d.ts.map +0 -1
- package/dist/harness/extensions/loader.js +0 -525
- package/dist/harness/extensions/loader.js.map +0 -1
- package/dist/harness/extensions/registry.d.ts +0 -23
- package/dist/harness/extensions/registry.d.ts.map +0 -1
- package/dist/harness/extensions/registry.js +0 -45
- package/dist/harness/extensions/registry.js.map +0 -1
- package/dist/harness/extensions/types.d.ts +0 -248
- package/dist/harness/extensions/types.d.ts.map +0 -1
- package/dist/harness/extensions/types.js.map +0 -1
- package/dist/harness/session-store.d.ts +0 -77
- package/dist/harness/session-store.d.ts.map +0 -1
- package/dist/harness/session-store.js +0 -248
- package/dist/harness/session-store.js.map +0 -1
- package/dist/harness/settings.d.ts +0 -47
- package/dist/harness/settings.d.ts.map +0 -1
- package/dist/harness/settings.js +0 -29
- package/dist/harness/settings.js.map +0 -1
- package/dist/model-registry.d.ts +0 -4
- package/dist/model-registry.d.ts.map +0 -1
- package/dist/model-registry.js +0 -7
- package/dist/model-registry.js.map +0 -1
- package/dist/platform-messages.d.ts +0 -12
- package/dist/platform-messages.d.ts.map +0 -1
- package/dist/platform-messages.js +0 -36
- package/dist/platform-messages.js.map +0 -1
- package/dist/portal-shell.d.ts +0 -4
- package/dist/portal-shell.d.ts.map +0 -1
- package/dist/portal-shell.js +0 -366
- package/dist/portal-shell.js.map +0 -1
- package/dist/provisioner.d.ts +0 -61
- package/dist/provisioner.d.ts.map +0 -1
- package/dist/provisioner.js +0 -517
- package/dist/provisioner.js.map +0 -1
- package/dist/runtime/agent-run-controller.d.ts +0 -31
- package/dist/runtime/agent-run-controller.d.ts.map +0 -1
- package/dist/runtime/agent-run-controller.js +0 -195
- package/dist/runtime/agent-run-controller.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 -15
- package/dist/sandbox/firecracker.d.ts.map +0 -1
- package/dist/sandbox/firecracker.js +0 -212
- package/dist/sandbox/firecracker.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 -27
- package/dist/sandbox/image.js.map +0 -1
- package/dist/sandbox/path-context.d.ts +0 -3
- package/dist/sandbox/path-context.d.ts.map +0 -1
- package/dist/sandbox/path-context.js +0 -20
- package/dist/sandbox/path-context.js.map +0 -1
- package/dist/sessions/agent-memory-file-manager.d.ts +0 -19
- package/dist/sessions/agent-memory-file-manager.d.ts.map +0 -1
- package/dist/sessions/agent-memory-file-manager.js +0 -484
- package/dist/sessions/agent-memory-file-manager.js.map +0 -1
- package/dist/sessions/metadata.d.ts +0 -3
- package/dist/sessions/metadata.d.ts.map +0 -1
- package/dist/sessions/metadata.js +0 -11
- package/dist/sessions/metadata.js.map +0 -1
- package/dist/sessions/policy.d.ts +0 -6
- package/dist/sessions/policy.d.ts.map +0 -1
- package/dist/sessions/policy.js +0 -24
- package/dist/sessions/policy.js.map +0 -1
- package/dist/sessions/store.d.ts +0 -72
- package/dist/sessions/store.d.ts.map +0 -1
- package/dist/sessions/store.js +0 -193
- package/dist/sessions/store.js.map +0 -1
- package/dist/store.d.ts +0 -46
- package/dist/store.d.ts.map +0 -1
- package/dist/store.js +0 -177
- package/dist/store.js.map +0 -1
- package/dist/tools/bash.d.ts +0 -10
- 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 -131
- package/dist/tools/edit.js.map +0 -1
- package/dist/tools/event.d.ts +0 -56
- package/dist/tools/event.d.ts.map +0 -1
- package/dist/tools/event.js +0 -252
- package/dist/tools/event.js.map +0 -1
- package/dist/tools/github-pr.d.ts +0 -22
- package/dist/tools/github-pr.d.ts.map +0 -1
- package/dist/tools/github-pr.js +0 -53
- package/dist/tools/github-pr.js.map +0 -1
- package/dist/tools/index.d.ts +0 -25
- package/dist/tools/index.d.ts.map +0 -1
- package/dist/tools/index.js +0 -35
- package/dist/tools/index.js.map +0 -1
- package/dist/tools/react.d.ts +0 -15
- package/dist/tools/react.d.ts.map +0 -1
- package/dist/tools/react.js +0 -40
- package/dist/tools/react.js.map +0 -1
- package/dist/tools/read.d.ts +0 -11
- package/dist/tools/read.d.ts.map +0 -1
- package/dist/tools/read.js +0 -134
- package/dist/tools/read.js.map +0 -1
- package/dist/tools/sandbox.d.ts +0 -22
- package/dist/tools/sandbox.d.ts.map +0 -1
- package/dist/tools/sandbox.js +0 -73
- package/dist/tools/sandbox.js.map +0 -1
- package/dist/tools/truncate.d.ts +0 -33
- package/dist/tools/truncate.d.ts.map +0 -1
- package/dist/tools/truncate.js +0 -184
- package/dist/tools/truncate.js.map +0 -1
- package/dist/tools/types.d.ts +0 -54
- 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 -29
- package/dist/tools/write.js.map +0 -1
- package/dist/trigger.d.ts +0 -22
- package/dist/trigger.d.ts.map +0 -1
- package/dist/trigger.js +0 -100
- package/dist/trigger.js.map +0 -1
- package/dist/utils/date.d.ts +0 -10
- package/dist/utils/date.d.ts.map +0 -1
- package/dist/utils/date.js +0 -23
- package/dist/utils/date.js.map +0 -1
- package/dist/utils/env.d.ts +0 -3
- package/dist/utils/env.d.ts.map +0 -1
- package/dist/utils/env.js +0 -12
- package/dist/utils/env.js.map +0 -1
- package/dist/utils/file-guards.d.ts +0 -9
- package/dist/utils/file-guards.d.ts.map +0 -1
- package/dist/utils/file-guards.js +0 -59
- package/dist/utils/file-guards.js.map +0 -1
- package/dist/utils/fs-atomic.d.ts +0 -10
- package/dist/utils/fs-atomic.d.ts.map +0 -1
- package/dist/utils/fs-atomic.js +0 -45
- package/dist/utils/fs-atomic.js.map +0 -1
- package/dist/utils/html.d.ts +0 -2
- package/dist/utils/html.d.ts.map +0 -1
- package/dist/utils/html.js +0 -4
- package/dist/utils/html.js.map +0 -1
- package/dist/utils/http-body.d.ts +0 -10
- package/dist/utils/http-body.d.ts.map +0 -1
- package/dist/utils/http-body.js +0 -34
- package/dist/utils/http-body.js.map +0 -1
- package/dist/vault/routing.d.ts +0 -3
- package/dist/vault/routing.d.ts.map +0 -1
- package/dist/vault/routing.js +0 -13
- package/dist/vault/routing.js.map +0 -1
- package/dist/web/admin/portal.d.ts +0 -5
- package/dist/web/admin/portal.d.ts.map +0 -1
- package/dist/web/admin/portal.js +0 -2572
- package/dist/web/admin/portal.js.map +0 -1
- package/dist/web/admin/provider-models.d.ts +0 -10
- package/dist/web/admin/provider-models.d.ts.map +0 -1
- package/dist/web/admin/provider-models.js +0 -96
- package/dist/web/admin/provider-models.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/admin/types.d.ts +0 -30
- package/dist/web/admin/types.d.ts.map +0 -1
- package/dist/web/admin/types.js.map +0 -1
- package/dist/web/agent-events/portal.d.ts +0 -3
- package/dist/web/agent-events/portal.d.ts.map +0 -1
- package/dist/web/agent-events/portal.js +0 -18
- package/dist/web/agent-events/portal.js.map +0 -1
- package/dist/web/login/oauth.d.ts +0 -6
- package/dist/web/login/oauth.d.ts.map +0 -1
- package/dist/web/login/oauth.js +0 -258
- package/dist/web/login/oauth.js.map +0 -1
- package/dist/web/login/portal.d.ts +0 -17
- package/dist/web/login/portal.d.ts.map +0 -1
- package/dist/web/login/portal.js +0 -1329
- package/dist/web/login/portal.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/login/types.d.ts +0 -50
- package/dist/web/login/types.d.ts.map +0 -1
- package/dist/web/login/types.js.map +0 -1
- package/dist/web/request.d.ts +0 -3
- package/dist/web/request.d.ts.map +0 -1
- package/dist/web/request.js +0 -13
- package/dist/web/request.js.map +0 -1
- package/dist/web/server.d.ts +0 -28
- package/dist/web/server.d.ts.map +0 -1
- package/dist/web/server.js +0 -66
- package/dist/web/server.js.map +0 -1
- package/dist/web/session-view/command.d.ts +0 -4
- package/dist/web/session-view/command.d.ts.map +0 -1
- package/dist/web/session-view/command.js +0 -7
- package/dist/web/session-view/command.js.map +0 -1
- package/dist/web/session-view/portal.d.ts +0 -13
- package/dist/web/session-view/portal.d.ts.map +0 -1
- package/dist/web/session-view/portal.js +0 -1651
- package/dist/web/session-view/portal.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 -498
- 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/web/session-view/types.d.ts +0 -50
- package/dist/web/session-view/types.d.ts.map +0 -1
- package/dist/web/session-view/types.js.map +0 -1
- package/dist/web/token-store.d.ts +0 -13
- package/dist/web/token-store.d.ts.map +0 -1
- package/dist/web/token-store.js +0 -44
- package/dist/web/token-store.js.map +0 -1
- package/dist/web/types.d.ts.map +0 -1
- package/dist/web/types.js.map +0 -1
- /package/dist/{commands → adapters/commands}/admin.d.ts +0 -0
- /package/dist/{commands → adapters/commands}/new.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/{harness/extensions → adapters/web/admin}/types.js +0 -0
- /package/dist/{tools → adapters/web/login}/types.js +0 -0
- /package/dist/{web/admin → adapters/web/session-view}/types.js +0 -0
- /package/dist/{web → adapters/web}/types.d.ts +0 -0
- /package/dist/{web/login → adapters/web}/types.js +0 -0
- /package/dist/{download.d.ts → cli/download.d.ts} +0 -0
- /package/dist/{web/session-view → cli}/types.js +0 -0
- /package/dist/{web → harness/tools}/types.js +0 -0
|
@@ -0,0 +1,1490 @@
|
|
|
1
|
+
import { validateEventFilename } from "../../../events/index.js";
|
|
2
|
+
import { existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, } from "node:fs";
|
|
3
|
+
import { basename, join, resolve as pathResolve, sep as pathSep } from "node:path";
|
|
4
|
+
import { atomicWritePrivateFile } from "../../../file-guards.js";
|
|
5
|
+
import { MikanModels } from "../../../harness/models.js";
|
|
6
|
+
import { parseFrontmatter, validateSkill } from "../../../harness/skills.js";
|
|
7
|
+
import { SessionStore } from "../../../sessions/session-store.js";
|
|
8
|
+
import { InMemoryTokenStore } from "../token-store.js";
|
|
9
|
+
import { adminViewFunctionsScript, adminViewStartupScript, adminViewStyles, } from "./client-assets.js";
|
|
10
|
+
const ADMIN_TOKEN_TTL_MS = 30 * 60 * 1000;
|
|
11
|
+
export class InMemoryAdminTokenStore extends InMemoryTokenStore {
|
|
12
|
+
create(args) {
|
|
13
|
+
this.deleteWhere((token) => token.platform === args.platform && token.platformUserId === args.platformUserId);
|
|
14
|
+
return this.createRecord(ADMIN_TOKEN_TTL_MS, {
|
|
15
|
+
platform: args.platform,
|
|
16
|
+
platformUserId: args.platformUserId,
|
|
17
|
+
platformUserName: args.platformUserName || undefined,
|
|
18
|
+
conversationId: args.conversationId,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
import { isThinkingLevel, loadOfficeVisibilityOverride, loadGlobalSettings, loadScopeMcpServers, resolveConversationSettings, } from "../../../settings/index.js";
|
|
23
|
+
import { findMcpPreset, listMcpPresets, materializeMcpPreset } from "../../../harness/mcp.js";
|
|
24
|
+
import { loadMcpTools } from "../../../harness/mcp.js";
|
|
25
|
+
import { isValidMcpServerName, parseStandardMcpServers, redactMcpUrl, } from "../../../harness/mcp.js";
|
|
26
|
+
import { applyConversationSettings, applyOfficeVisibility, applyGlobalSettings, } from "../../../settings/apply.js";
|
|
27
|
+
import { escapeHtml, jsonResponse as jsonRes, readJsonBody, renderPortalShell, } from "../portal-shell.js";
|
|
28
|
+
import { PRODUCT_NAME } from "../../messages.js";
|
|
29
|
+
import { credentialAuthorizationKey } from "../../../sandbox/identity.js";
|
|
30
|
+
import { resolveWorkspaceProjection } from "../../../office/projection.js";
|
|
31
|
+
import { sharedVaultKey } from "../../../vault/index.js";
|
|
32
|
+
import { modelKey, resolveAdminModelAccessStatuses } from "./provider-models.js";
|
|
33
|
+
import { assertPlatformName, createOfficeAddress, listRegisteredOffices, sameOffice, } from "../../../office/index.js";
|
|
34
|
+
import { errorMessage } from "../../../unknown-values.js";
|
|
35
|
+
export async function handleAdminRequest(req, res, url, services) {
|
|
36
|
+
if (!url.pathname.startsWith("/admin"))
|
|
37
|
+
return false;
|
|
38
|
+
if (req.method === "GET" && url.pathname === "/admin") {
|
|
39
|
+
const provided = url.searchParams.get("token") ?? "";
|
|
40
|
+
const token = services.adminTokenStore.peek(provided);
|
|
41
|
+
if (!token) {
|
|
42
|
+
res.writeHead(403, { "Content-Type": "text/html; charset=utf-8" });
|
|
43
|
+
res.end(renderAdminErrorPage("Admin link is missing, invalid, or expired. Send `/admin` to the bot to get a fresh link."));
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
res.writeHead(200, {
|
|
47
|
+
"Content-Type": "text/html; charset=utf-8",
|
|
48
|
+
"Cache-Control": "no-store",
|
|
49
|
+
});
|
|
50
|
+
res.end(renderAdminPage(token));
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
if (url.pathname.startsWith("/admin/api/")) {
|
|
54
|
+
await routeApiRequest(req, res, url, services);
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
async function routeApiRequest(req, res, url, services) {
|
|
60
|
+
if (req.method === "GET") {
|
|
61
|
+
await routeGetApiRequest(res, url, services);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (req.method !== "POST") {
|
|
65
|
+
jsonRes(res, 405, { error: "Method not allowed" });
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
await routePostApiRequest(req, res, url, services);
|
|
69
|
+
}
|
|
70
|
+
async function routeGetApiRequest(res, url, services) {
|
|
71
|
+
const token = services.adminTokenStore.peek(url.searchParams.get("token") ?? "");
|
|
72
|
+
if (!token) {
|
|
73
|
+
jsonRes(res, 403, { error: "Unauthorized" });
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
switch (url.pathname) {
|
|
77
|
+
case "/admin/api/conversations":
|
|
78
|
+
return serveConversationsList(res, services);
|
|
79
|
+
case "/admin/api/session-usage":
|
|
80
|
+
return serveSessionUsage(res, services);
|
|
81
|
+
case "/admin/api/conversation-usage":
|
|
82
|
+
return serveConversationUsage(res, url, services);
|
|
83
|
+
case "/admin/api/conversation-state":
|
|
84
|
+
return serveConversationState(res, url, services, token);
|
|
85
|
+
case "/admin/api/settings/global":
|
|
86
|
+
return serveGlobalSettings(res);
|
|
87
|
+
case "/admin/api/models":
|
|
88
|
+
return serveModelsList(res);
|
|
89
|
+
case "/admin/api/workspace/tree":
|
|
90
|
+
return serveWorkspaceTree(res, url, services, token);
|
|
91
|
+
case "/admin/api/workspace/file":
|
|
92
|
+
return serveWorkspaceFile(res, url, services, token);
|
|
93
|
+
case "/admin/api/skills":
|
|
94
|
+
return serveSkillsList(res, url, services, token);
|
|
95
|
+
case "/admin/api/skills/file":
|
|
96
|
+
return serveSkillFile(res, url, services, token);
|
|
97
|
+
case "/admin/api/mcp-servers":
|
|
98
|
+
return serveMcpServersList(res, url, services, token);
|
|
99
|
+
case "/admin/api/events":
|
|
100
|
+
return serveEventsList(res, services);
|
|
101
|
+
case "/admin/api/conversations/events":
|
|
102
|
+
return serveConversationEventsList(res, url, services, token);
|
|
103
|
+
default:
|
|
104
|
+
jsonRes(res, 404, { error: "Not found" });
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async function routePostApiRequest(req, res, url, services) {
|
|
108
|
+
const bodyLimit = url.pathname === "/admin/api/skills/mutate" ? 256 * 1024 : 32 * 1024;
|
|
109
|
+
const body = await readJsonBody(req, res, bodyLimit);
|
|
110
|
+
if (!body)
|
|
111
|
+
return;
|
|
112
|
+
const token = services.adminTokenStore.peek(typeof body.token === "string" ? body.token : "");
|
|
113
|
+
if (!token) {
|
|
114
|
+
jsonRes(res, 403, { error: "Unauthorized" });
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
switch (url.pathname) {
|
|
118
|
+
case "/admin/api/conversations/model":
|
|
119
|
+
return serveConversationModelUpdate(res, body, services, token);
|
|
120
|
+
case "/admin/api/conversations/visibility":
|
|
121
|
+
return serveConversationVisibilityUpdate(res, body, services, token);
|
|
122
|
+
case "/admin/api/conversations/slack":
|
|
123
|
+
return serveConversationSlackUpdate(res, body, services, token);
|
|
124
|
+
case "/admin/api/conversations/session-link":
|
|
125
|
+
return serveConversationSessionLink(res, body, services, token);
|
|
126
|
+
case "/admin/api/conversations/login-link":
|
|
127
|
+
return serveConversationLoginLink(res, body, services, token);
|
|
128
|
+
case "/admin/api/conversations/events/delete":
|
|
129
|
+
return serveConversationEventDelete(res, body, services, token);
|
|
130
|
+
case "/admin/api/mcp-servers/mutate":
|
|
131
|
+
return serveMcpServerMutation(res, body, services, token);
|
|
132
|
+
case "/admin/api/skills/mutate":
|
|
133
|
+
return serveSkillMutation(res, body, services, token);
|
|
134
|
+
case "/admin/api/settings/model":
|
|
135
|
+
return serveGlobalModelUpdate(res, body, services);
|
|
136
|
+
case "/admin/api/settings/sandbox":
|
|
137
|
+
return serveGlobalSandboxUpdate(res, body, services);
|
|
138
|
+
case "/admin/api/settings/slack":
|
|
139
|
+
return serveGlobalSlackUpdate(res, body, services);
|
|
140
|
+
default:
|
|
141
|
+
jsonRes(res, 404, { error: "Not found" });
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
export function resolveConversationScope(requestedId, requestedPlatform, token) {
|
|
145
|
+
const fallback = createOfficeAddress(token.platform, token.conversationId);
|
|
146
|
+
try {
|
|
147
|
+
const address = createOfficeAddress(requestedPlatform ? assertPlatformName(requestedPlatform) : token.platform, requestedId || token.conversationId);
|
|
148
|
+
return { address, conversationId: address.conversationId };
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
return {
|
|
152
|
+
address: fallback,
|
|
153
|
+
conversationId: fallback.conversationId,
|
|
154
|
+
error: "Invalid conversation scope.",
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
function resolveTargetConversation(body, token) {
|
|
159
|
+
const requested = typeof body.conversationId === "string" ? body.conversationId.trim() : "";
|
|
160
|
+
const platform = typeof body.platform === "string" ? body.platform.trim() : "";
|
|
161
|
+
return resolveConversationScope(requested, platform, token);
|
|
162
|
+
}
|
|
163
|
+
function requireAdminWorkspace(res, services) {
|
|
164
|
+
if (!services.workspace) {
|
|
165
|
+
jsonRes(res, 503, { error: "Working directory not available" });
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
return services.workspace;
|
|
169
|
+
}
|
|
170
|
+
function requireConversationWorkspace(res, body, services, token) {
|
|
171
|
+
const scope = resolveTargetConversation(body, token);
|
|
172
|
+
if (scope.error) {
|
|
173
|
+
jsonRes(res, 403, { error: scope.error });
|
|
174
|
+
return undefined;
|
|
175
|
+
}
|
|
176
|
+
const workspace = requireAdminWorkspace(res, services);
|
|
177
|
+
return workspace ? { scope, workspace } : undefined;
|
|
178
|
+
}
|
|
179
|
+
function listAdminOffices(workspace) {
|
|
180
|
+
return listRegisteredOffices(workspace.stateDir)
|
|
181
|
+
.filter((office) => existsSync(workspace.office(office).dir))
|
|
182
|
+
.map((office) => createOfficeAddress(office.platform, office.conversationId))
|
|
183
|
+
.toSorted((a, b) => a.platform.localeCompare(b.platform) || a.conversationId.localeCompare(b.conversationId));
|
|
184
|
+
}
|
|
185
|
+
function conversationLastActivity(workspace, office) {
|
|
186
|
+
const dir = workspace.office(office).dir;
|
|
187
|
+
if (!existsSync(dir))
|
|
188
|
+
return null;
|
|
189
|
+
let latest = 0;
|
|
190
|
+
const visit = (path, depth) => {
|
|
191
|
+
if (depth > 3)
|
|
192
|
+
return;
|
|
193
|
+
let entries;
|
|
194
|
+
try {
|
|
195
|
+
entries = readdirSync(path, { withFileTypes: true });
|
|
196
|
+
}
|
|
197
|
+
catch {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
for (const entry of entries) {
|
|
201
|
+
const full = join(path, entry.name);
|
|
202
|
+
if (entry.isDirectory()) {
|
|
203
|
+
visit(full, depth + 1);
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
try {
|
|
207
|
+
const stats = statSync(full);
|
|
208
|
+
if (stats.mtimeMs > latest)
|
|
209
|
+
latest = stats.mtimeMs;
|
|
210
|
+
}
|
|
211
|
+
catch { }
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
visit(dir, 0);
|
|
215
|
+
return latest > 0 ? latest : null;
|
|
216
|
+
}
|
|
217
|
+
function conversationDisplayLabel(services, office) {
|
|
218
|
+
const bot = services.botsByPlatform?.[office.platform];
|
|
219
|
+
const channel = bot?.getMessagingInfo().channels.find((c) => c.id === office.conversationId);
|
|
220
|
+
if (channel)
|
|
221
|
+
return `${office.platform}:#${channel.name}:${office.conversationId}`;
|
|
222
|
+
return `${office.platform}:${office.conversationId}`;
|
|
223
|
+
}
|
|
224
|
+
function serveConversationsList(res, services) {
|
|
225
|
+
const workspace = requireAdminWorkspace(res, services);
|
|
226
|
+
if (!workspace)
|
|
227
|
+
return;
|
|
228
|
+
const running = services.runtime?.getRunningSessions() ?? [];
|
|
229
|
+
const conversations = listAdminOffices(workspace).map((office) => ({
|
|
230
|
+
platform: office.platform,
|
|
231
|
+
conversationId: office.conversationId,
|
|
232
|
+
label: conversationDisplayLabel(services, office),
|
|
233
|
+
running: running.some((session) => sameOffice(session.address, office)),
|
|
234
|
+
lastActivityAt: conversationLastActivity(workspace, office),
|
|
235
|
+
}));
|
|
236
|
+
jsonRes(res, 200, { conversations });
|
|
237
|
+
}
|
|
238
|
+
async function serveSessionUsage(res, services) {
|
|
239
|
+
const workspace = requireAdminWorkspace(res, services);
|
|
240
|
+
if (!workspace)
|
|
241
|
+
return;
|
|
242
|
+
const usageLists = [];
|
|
243
|
+
for (const office of listAdminOffices(workspace)) {
|
|
244
|
+
usageLists.push(await listConversationSessionUsage(workspace, office, conversationDisplayLabel(services, office)));
|
|
245
|
+
}
|
|
246
|
+
const rows = usageLists
|
|
247
|
+
.flat()
|
|
248
|
+
.toSorted((a, b) => b.total - a.total)
|
|
249
|
+
.slice(0, 20);
|
|
250
|
+
jsonRes(res, 200, { sessions: rows });
|
|
251
|
+
}
|
|
252
|
+
async function listConversationSessionUsage(workspace, office, label) {
|
|
253
|
+
const conversationOffice = workspace.office(office);
|
|
254
|
+
const rows = [];
|
|
255
|
+
for (const session of await SessionStore.list(conversationOffice)) {
|
|
256
|
+
rows.push(...(await readSessionUsage(conversationOffice, session.key, office.conversationId, label)));
|
|
257
|
+
}
|
|
258
|
+
return rows;
|
|
259
|
+
}
|
|
260
|
+
async function readSessionUsage(office, sessionKey, conversationId, label) {
|
|
261
|
+
try {
|
|
262
|
+
const manager = await SessionStore.inspect(office, sessionKey);
|
|
263
|
+
if (!manager)
|
|
264
|
+
return [];
|
|
265
|
+
const header = manager.getHeader();
|
|
266
|
+
const entries = await manager.getEntries();
|
|
267
|
+
const usage = entries.reduce((sum, entry) => {
|
|
268
|
+
if (entry.type !== "message" || entry.message.role !== "assistant")
|
|
269
|
+
return sum;
|
|
270
|
+
const message = entry.message;
|
|
271
|
+
const item = message.usage;
|
|
272
|
+
if (!item)
|
|
273
|
+
return sum;
|
|
274
|
+
sum.input += numberOrZero(item.input);
|
|
275
|
+
sum.output += numberOrZero(item.output);
|
|
276
|
+
sum.cacheRead += numberOrZero(item.cacheRead);
|
|
277
|
+
sum.cacheWrite += numberOrZero(item.cacheWrite);
|
|
278
|
+
sum.cost += numberOrZero(item.cost?.total);
|
|
279
|
+
return sum;
|
|
280
|
+
}, { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0 });
|
|
281
|
+
const total = usage.input + usage.output + usage.cacheRead + usage.cacheWrite;
|
|
282
|
+
if (total <= 0)
|
|
283
|
+
return [];
|
|
284
|
+
return [
|
|
285
|
+
{
|
|
286
|
+
conversationId,
|
|
287
|
+
label,
|
|
288
|
+
sessionKey,
|
|
289
|
+
updatedAt: entries.length > 0
|
|
290
|
+
? new Date(entries.at(-1).timestamp).toISOString()
|
|
291
|
+
: new Date(header.createdAt).toISOString(),
|
|
292
|
+
...usage,
|
|
293
|
+
total,
|
|
294
|
+
},
|
|
295
|
+
];
|
|
296
|
+
}
|
|
297
|
+
catch {
|
|
298
|
+
return [];
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
function numberOrZero(value) {
|
|
302
|
+
return typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
303
|
+
}
|
|
304
|
+
function localDayKey(d) {
|
|
305
|
+
const year = d.getFullYear();
|
|
306
|
+
const month = String(d.getMonth() + 1).padStart(2, "0");
|
|
307
|
+
const day = String(d.getDate()).padStart(2, "0");
|
|
308
|
+
return `${year}-${month}-${day}`;
|
|
309
|
+
}
|
|
310
|
+
function emptyBucket(date) {
|
|
311
|
+
return { date, input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0, cost: 0 };
|
|
312
|
+
}
|
|
313
|
+
async function serveConversationUsage(res, url, services) {
|
|
314
|
+
const workspace = requireAdminWorkspace(res, services);
|
|
315
|
+
if (!workspace)
|
|
316
|
+
return;
|
|
317
|
+
const conversationId = (url.searchParams.get("conversationId") ?? "").trim();
|
|
318
|
+
const platformParam = (url.searchParams.get("platform") ?? "").trim();
|
|
319
|
+
const office = listAdminOffices(workspace).find((candidate) => candidate.conversationId === conversationId &&
|
|
320
|
+
(!platformParam || candidate.platform === platformParam));
|
|
321
|
+
if (!office) {
|
|
322
|
+
jsonRes(res, 400, { error: "Unknown conversationId" });
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
const days = 14;
|
|
326
|
+
const today = new Date();
|
|
327
|
+
today.setHours(0, 0, 0, 0);
|
|
328
|
+
const buckets = new Map();
|
|
329
|
+
const order = [];
|
|
330
|
+
for (let i = days - 1; i >= 0; i--) {
|
|
331
|
+
const d = new Date(today);
|
|
332
|
+
d.setDate(today.getDate() - i);
|
|
333
|
+
const key = localDayKey(d);
|
|
334
|
+
order.push(key);
|
|
335
|
+
buckets.set(key, emptyBucket(key));
|
|
336
|
+
}
|
|
337
|
+
const cutoff = new Date(today);
|
|
338
|
+
cutoff.setDate(today.getDate() - (days - 1));
|
|
339
|
+
const flags = { hasOlder: false };
|
|
340
|
+
const conversationOffice = workspace.office(office);
|
|
341
|
+
for (const session of await SessionStore.list(conversationOffice)) {
|
|
342
|
+
await accumulateSessionUsageByDay(conversationOffice, session.key, cutoff, buckets, flags);
|
|
343
|
+
}
|
|
344
|
+
const series = order.map((key) => buckets.get(key) ?? emptyBucket(key));
|
|
345
|
+
const totals = series.reduce((sum, b) => {
|
|
346
|
+
sum.input += b.input;
|
|
347
|
+
sum.output += b.output;
|
|
348
|
+
sum.cacheRead += b.cacheRead;
|
|
349
|
+
sum.cacheWrite += b.cacheWrite;
|
|
350
|
+
sum.total += b.total;
|
|
351
|
+
sum.cost += b.cost;
|
|
352
|
+
return sum;
|
|
353
|
+
}, emptyBucket(""));
|
|
354
|
+
jsonRes(res, 200, {
|
|
355
|
+
platform: office.platform,
|
|
356
|
+
conversationId,
|
|
357
|
+
label: conversationDisplayLabel(services, office),
|
|
358
|
+
days,
|
|
359
|
+
hasOlder: flags.hasOlder,
|
|
360
|
+
buckets: series,
|
|
361
|
+
totals: {
|
|
362
|
+
input: totals.input,
|
|
363
|
+
output: totals.output,
|
|
364
|
+
cacheRead: totals.cacheRead,
|
|
365
|
+
cacheWrite: totals.cacheWrite,
|
|
366
|
+
total: totals.total,
|
|
367
|
+
cost: totals.cost,
|
|
368
|
+
},
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
async function accumulateSessionUsageByDay(office, sessionKey, cutoff, buckets, flags) {
|
|
372
|
+
try {
|
|
373
|
+
const manager = await SessionStore.inspect(office, sessionKey);
|
|
374
|
+
if (!manager)
|
|
375
|
+
return;
|
|
376
|
+
for (const entry of await manager.getEntries()) {
|
|
377
|
+
if (entry.type !== "message" || entry.message.role !== "assistant")
|
|
378
|
+
continue;
|
|
379
|
+
const usage = entry.message.usage;
|
|
380
|
+
if (!usage || !entry.timestamp)
|
|
381
|
+
continue;
|
|
382
|
+
const when = new Date(entry.timestamp);
|
|
383
|
+
if (Number.isNaN(when.getTime()))
|
|
384
|
+
continue;
|
|
385
|
+
if (when < cutoff) {
|
|
386
|
+
flags.hasOlder = true;
|
|
387
|
+
continue;
|
|
388
|
+
}
|
|
389
|
+
const bucket = buckets.get(localDayKey(when));
|
|
390
|
+
if (!bucket)
|
|
391
|
+
continue;
|
|
392
|
+
const input = numberOrZero(usage.input);
|
|
393
|
+
const output = numberOrZero(usage.output);
|
|
394
|
+
const cacheRead = numberOrZero(usage.cacheRead);
|
|
395
|
+
const cacheWrite = numberOrZero(usage.cacheWrite);
|
|
396
|
+
bucket.input += input;
|
|
397
|
+
bucket.output += output;
|
|
398
|
+
bucket.cacheRead += cacheRead;
|
|
399
|
+
bucket.cacheWrite += cacheWrite;
|
|
400
|
+
bucket.total += input + output + cacheRead + cacheWrite;
|
|
401
|
+
bucket.cost += numberOrZero(usage.cost?.total);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
catch { }
|
|
405
|
+
}
|
|
406
|
+
function serveConversationState(res, url, services, token) {
|
|
407
|
+
const workspace = requireAdminWorkspace(res, services);
|
|
408
|
+
if (!workspace)
|
|
409
|
+
return;
|
|
410
|
+
const scope = resolveConversationFromQuery(url, token);
|
|
411
|
+
if (scope.error) {
|
|
412
|
+
jsonRes(res, 400, { error: scope.error });
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
const conversationId = scope.conversationId;
|
|
416
|
+
const office = workspace.office(scope.address);
|
|
417
|
+
const globalConfig = loadGlobalSettings();
|
|
418
|
+
const conversationConfig = resolveConversationSettings(office);
|
|
419
|
+
const conversationWorkspace = resolveWorkspaceProjection(office);
|
|
420
|
+
jsonRes(res, 200, {
|
|
421
|
+
conversationId,
|
|
422
|
+
provider: conversationConfig.provider,
|
|
423
|
+
model: conversationConfig.model,
|
|
424
|
+
thinkingLevel: conversationConfig.thinkingLevel,
|
|
425
|
+
globalProvider: globalConfig.provider,
|
|
426
|
+
globalModel: globalConfig.model,
|
|
427
|
+
globalThinkingLevel: globalConfig.thinkingLevel,
|
|
428
|
+
officeVisibility: conversationWorkspace.visibility,
|
|
429
|
+
officeVisibilitySource: conversationWorkspace.source,
|
|
430
|
+
officeVisibilityOverride: loadOfficeVisibilityOverride(office),
|
|
431
|
+
slack: {
|
|
432
|
+
replyMode: conversationConfig.slack?.replyMode ?? globalConfig.slack?.replyMode ?? "top-level",
|
|
433
|
+
globalReplyMode: globalConfig.slack?.replyMode ?? "top-level",
|
|
434
|
+
},
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
function serveGlobalSettings(res) {
|
|
438
|
+
try {
|
|
439
|
+
const config = loadGlobalSettings();
|
|
440
|
+
jsonRes(res, 200, {
|
|
441
|
+
provider: config.provider,
|
|
442
|
+
model: config.model,
|
|
443
|
+
thinkingLevel: config.thinkingLevel,
|
|
444
|
+
sandboxCpus: config.sandbox?.cpus ?? null,
|
|
445
|
+
sandboxMemory: config.sandbox?.memory ?? null,
|
|
446
|
+
sandboxBoostCpus: config.sandbox?.boost?.cpus ?? null,
|
|
447
|
+
sandboxBoostMemory: config.sandbox?.boost?.memory ?? null,
|
|
448
|
+
defaultSharedVault: config.sandbox?.defaultSharedVault ?? null,
|
|
449
|
+
slack: {
|
|
450
|
+
replyMode: config.slack?.replyMode ?? "top-level",
|
|
451
|
+
},
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
catch (err) {
|
|
455
|
+
jsonRes(res, 500, { error: errorMessage(err) });
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
async function serveModelsList(res) {
|
|
459
|
+
try {
|
|
460
|
+
const registry = MikanModels.create();
|
|
461
|
+
const availableModels = await registry.getAvailable();
|
|
462
|
+
const statuses = await resolveAdminModelAccessStatuses(registry, availableModels);
|
|
463
|
+
const models = availableModels.map((model) => ({
|
|
464
|
+
provider: model.provider,
|
|
465
|
+
id: model.id,
|
|
466
|
+
name: model.name ?? model.id,
|
|
467
|
+
reasoning: model.reasoning,
|
|
468
|
+
input: model.input,
|
|
469
|
+
contextWindow: model.contextWindow,
|
|
470
|
+
maxTokens: model.maxTokens,
|
|
471
|
+
status: statuses.get(modelKey(model.provider, model.id))?.status ?? "available",
|
|
472
|
+
}));
|
|
473
|
+
jsonRes(res, 200, { models });
|
|
474
|
+
}
|
|
475
|
+
catch (err) {
|
|
476
|
+
jsonRes(res, 500, { error: errorMessage(err) });
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
function serveConversationModelUpdate(res, body, services, token) {
|
|
480
|
+
const provider = typeof body.provider === "string" ? body.provider.trim() : "";
|
|
481
|
+
const model = typeof body.model === "string" ? body.model.trim() : "";
|
|
482
|
+
const thinkingLevel = isThinkingLevel(body.thinkingLevel) ? body.thinkingLevel : undefined;
|
|
483
|
+
if (!provider || !model) {
|
|
484
|
+
jsonRes(res, 400, { error: "Missing provider or model" });
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
const target = requireConversationWorkspace(res, body, services, token);
|
|
488
|
+
if (!target)
|
|
489
|
+
return;
|
|
490
|
+
const { scope, workspace } = target;
|
|
491
|
+
try {
|
|
492
|
+
const result = applyConversationSettings(services.runtime, workspace.office(scope.address), {
|
|
493
|
+
provider,
|
|
494
|
+
model,
|
|
495
|
+
thinkingLevel,
|
|
496
|
+
});
|
|
497
|
+
if (!result.ok) {
|
|
498
|
+
jsonRes(res, 409, {
|
|
499
|
+
error: "Conversation has a running job; retry after it finishes (or /stop it).",
|
|
500
|
+
});
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
jsonRes(res, 200, { ok: true, runtimeSwitched: result.runtimeSwitched });
|
|
504
|
+
}
|
|
505
|
+
catch (err) {
|
|
506
|
+
jsonRes(res, 500, { error: errorMessage(err) });
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
function serveConversationVisibilityUpdate(res, body, services, token) {
|
|
510
|
+
if (body.visibility !== "private" && body.visibility !== "default") {
|
|
511
|
+
jsonRes(res, 400, { error: "visibility must be 'private' or 'default'" });
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
const target = requireConversationWorkspace(res, body, services, token);
|
|
515
|
+
if (!target)
|
|
516
|
+
return;
|
|
517
|
+
const { scope, workspace } = target;
|
|
518
|
+
try {
|
|
519
|
+
const result = applyOfficeVisibility(services.runtime, workspace.office(scope.address), body.visibility === "private" ? "private" : null);
|
|
520
|
+
if (!result.ok) {
|
|
521
|
+
jsonRes(res, 409, { error: "Conversation is busy; retry when the current run finishes" });
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
jsonRes(res, 200, { ok: true });
|
|
525
|
+
}
|
|
526
|
+
catch (err) {
|
|
527
|
+
jsonRes(res, 500, { error: errorMessage(err) });
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
function serveConversationSlackUpdate(res, body, services, token) {
|
|
531
|
+
const replyMode = body.replyMode;
|
|
532
|
+
if (replyMode !== "top-level" && replyMode !== "thread") {
|
|
533
|
+
jsonRes(res, 400, { error: "replyMode must be 'top-level' or 'thread'" });
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
const target = requireConversationWorkspace(res, body, services, token);
|
|
537
|
+
if (!target)
|
|
538
|
+
return;
|
|
539
|
+
const { scope, workspace } = target;
|
|
540
|
+
respondWithSettingsUpdate(res, () => {
|
|
541
|
+
applyConversationSettings(services.runtime, workspace.office(scope.address), {
|
|
542
|
+
slack: { replyMode },
|
|
543
|
+
});
|
|
544
|
+
return { ok: true };
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
async function serveConversationSessionLink(res, body, services, token) {
|
|
548
|
+
const target = requireConversationWorkspace(res, body, services, token);
|
|
549
|
+
if (!target)
|
|
550
|
+
return;
|
|
551
|
+
const { scope, workspace } = target;
|
|
552
|
+
if (!services.sessionViewTokenStore) {
|
|
553
|
+
jsonRes(res, 503, { error: "Session view token store not available" });
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
if (!services.portalBaseUrl) {
|
|
557
|
+
jsonRes(res, 503, {
|
|
558
|
+
error: "Portal URL not configured. Set MIKAN_LINK_URL to enable link generation.",
|
|
559
|
+
});
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
const office = workspace.office(scope.address);
|
|
563
|
+
if (!(await SessionStore.exists(office, scope.conversationId))) {
|
|
564
|
+
jsonRes(res, 404, { error: "No session found for this conversation" });
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
try {
|
|
568
|
+
const { token: viewToken } = services.sessionViewTokenStore.create({
|
|
569
|
+
platform: token.platform,
|
|
570
|
+
platformUserId: token.platformUserId,
|
|
571
|
+
conversationId: scope.conversationId,
|
|
572
|
+
sessionKey: scope.conversationId,
|
|
573
|
+
office,
|
|
574
|
+
platformUserName: token.platformUserName,
|
|
575
|
+
});
|
|
576
|
+
const url = `${services.portalBaseUrl}/session?token=${encodeURIComponent(viewToken)}`;
|
|
577
|
+
jsonRes(res, 200, { ok: true, url });
|
|
578
|
+
}
|
|
579
|
+
catch (err) {
|
|
580
|
+
jsonRes(res, 500, { error: errorMessage(err) });
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
function serveConversationLoginLink(res, body, services, token) {
|
|
584
|
+
const scope = resolveTargetConversation(body, token);
|
|
585
|
+
if (scope.error) {
|
|
586
|
+
jsonRes(res, 403, { error: scope.error });
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
if (!services.portalBaseUrl) {
|
|
590
|
+
jsonRes(res, 503, { error: "Portal URL not configured." });
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
if (!services.sandbox) {
|
|
594
|
+
jsonRes(res, 503, { error: "Sandbox config not available." });
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
const sharedName = typeof body.sharedVault === "string" ? body.sharedVault.trim() : "";
|
|
598
|
+
let vaultId;
|
|
599
|
+
if (sharedName) {
|
|
600
|
+
const key = sharedVaultKey(sharedName);
|
|
601
|
+
if (!key) {
|
|
602
|
+
jsonRes(res, 400, { error: "Invalid shared vault name" });
|
|
603
|
+
return;
|
|
604
|
+
}
|
|
605
|
+
vaultId = key;
|
|
606
|
+
}
|
|
607
|
+
else {
|
|
608
|
+
try {
|
|
609
|
+
vaultId = credentialAuthorizationKey(services.sandbox, {
|
|
610
|
+
userId: token.platformUserId,
|
|
611
|
+
address: scope.address,
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
catch (err) {
|
|
615
|
+
jsonRes(res, 500, { error: errorMessage(err) });
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
try {
|
|
620
|
+
const { token: linkToken } = services.linkTokenStore.create(token.platform, token.platformUserId, scope.conversationId, vaultId, "");
|
|
621
|
+
const url = `${services.portalBaseUrl}/link?token=${encodeURIComponent(linkToken)}`;
|
|
622
|
+
jsonRes(res, 200, { ok: true, url, vaultId });
|
|
623
|
+
}
|
|
624
|
+
catch (err) {
|
|
625
|
+
jsonRes(res, 500, { error: errorMessage(err) });
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
function serveGlobalModelUpdate(res, body, services) {
|
|
629
|
+
const provider = typeof body.provider === "string" ? body.provider.trim() : "";
|
|
630
|
+
const model = typeof body.model === "string" ? body.model.trim() : "";
|
|
631
|
+
const thinkingLevel = isThinkingLevel(body.thinkingLevel) ? body.thinkingLevel : undefined;
|
|
632
|
+
if (!provider || !model) {
|
|
633
|
+
jsonRes(res, 400, { error: "Missing provider or model" });
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
respondWithSettingsUpdate(res, () => {
|
|
637
|
+
const result = applyGlobalSettings(services.runtime, {
|
|
638
|
+
provider,
|
|
639
|
+
model,
|
|
640
|
+
thinkingLevel,
|
|
641
|
+
});
|
|
642
|
+
return {
|
|
643
|
+
ok: true,
|
|
644
|
+
staleConversations: result.staleConversations.map((office) => `${office.platform}:${office.conversationId}`),
|
|
645
|
+
};
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
function serveGlobalSlackUpdate(res, body, services) {
|
|
649
|
+
const replyMode = body.replyMode;
|
|
650
|
+
if (replyMode !== "top-level" && replyMode !== "thread") {
|
|
651
|
+
jsonRes(res, 400, { error: "replyMode must be 'top-level' or 'thread'" });
|
|
652
|
+
return;
|
|
653
|
+
}
|
|
654
|
+
respondWithSettingsUpdate(res, () => {
|
|
655
|
+
applyGlobalSettings(services.runtime, { slack: { replyMode } });
|
|
656
|
+
return { ok: true };
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
function serveGlobalSandboxUpdate(res, body, services) {
|
|
660
|
+
const cpus = typeof body.cpus === "string" ? body.cpus.trim() : "";
|
|
661
|
+
const memory = typeof body.memory === "string" ? body.memory.trim() : "";
|
|
662
|
+
const boostCpus = typeof body.boostCpus === "string" ? body.boostCpus.trim() : "";
|
|
663
|
+
const boostMemory = typeof body.boostMemory === "string" ? body.boostMemory.trim() : "";
|
|
664
|
+
const update = {
|
|
665
|
+
...(cpus ? { cpus } : {}),
|
|
666
|
+
...(memory ? { memory } : {}),
|
|
667
|
+
...(boostCpus || boostMemory
|
|
668
|
+
? {
|
|
669
|
+
boost: {
|
|
670
|
+
...(boostCpus ? { cpus: boostCpus } : {}),
|
|
671
|
+
...(boostMemory ? { memory: boostMemory } : {}),
|
|
672
|
+
},
|
|
673
|
+
}
|
|
674
|
+
: {}),
|
|
675
|
+
};
|
|
676
|
+
if (Object.keys(update).length === 0) {
|
|
677
|
+
jsonRes(res, 400, { error: "No valid sandbox fields provided" });
|
|
678
|
+
return;
|
|
679
|
+
}
|
|
680
|
+
respondWithSettingsUpdate(res, () => {
|
|
681
|
+
applyGlobalSettings(services.runtime, { sandbox: update });
|
|
682
|
+
return { ok: true };
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
function respondWithSettingsUpdate(res, update) {
|
|
686
|
+
try {
|
|
687
|
+
jsonRes(res, 200, update());
|
|
688
|
+
}
|
|
689
|
+
catch (err) {
|
|
690
|
+
jsonRes(res, 500, { error: errorMessage(err) });
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
const WORKSPACE_TREE_MAX_DEPTH = 4;
|
|
694
|
+
const WORKSPACE_TREE_MAX_ENTRIES = 800;
|
|
695
|
+
const PREVIEW_FILE_MAX_BYTES = 256 * 1024;
|
|
696
|
+
const WORKSPACE_TOP_DIRS = new Set(["scratch"]);
|
|
697
|
+
function isWorkspacePathAllowed(rel) {
|
|
698
|
+
if (rel === "")
|
|
699
|
+
return true;
|
|
700
|
+
const first = rel.split("/").find(Boolean);
|
|
701
|
+
if (first === undefined)
|
|
702
|
+
return true;
|
|
703
|
+
return WORKSPACE_TOP_DIRS.has(first);
|
|
704
|
+
}
|
|
705
|
+
function resolveConversationFromQuery(url, token) {
|
|
706
|
+
const requested = (url.searchParams.get("conversationId") ?? "").trim();
|
|
707
|
+
const platform = (url.searchParams.get("platform") ?? "").trim();
|
|
708
|
+
return resolveConversationScope(requested, platform, token);
|
|
709
|
+
}
|
|
710
|
+
function safeJoinUnderRoot(rootDir, relative) {
|
|
711
|
+
if (relative.startsWith("/") || relative.includes("\0")) {
|
|
712
|
+
return { absolute: "", error: "Invalid path" };
|
|
713
|
+
}
|
|
714
|
+
if (relative.split(/[\\/]+/).some((part) => part === ".." || part === "")) {
|
|
715
|
+
if (relative !== "")
|
|
716
|
+
return { absolute: "", error: "Invalid path" };
|
|
717
|
+
}
|
|
718
|
+
const target = pathResolve(rootDir, relative);
|
|
719
|
+
const rootAbs = pathResolve(rootDir);
|
|
720
|
+
if (target !== rootAbs && !target.startsWith(rootAbs + pathSep)) {
|
|
721
|
+
return { absolute: "", error: "Path escapes conversation directory" };
|
|
722
|
+
}
|
|
723
|
+
return { absolute: target };
|
|
724
|
+
}
|
|
725
|
+
function buildTree(startDir, relPrefix) {
|
|
726
|
+
let counter = { value: 0 };
|
|
727
|
+
const walk = (dir, rel, depth) => {
|
|
728
|
+
if (counter.value >= WORKSPACE_TREE_MAX_ENTRIES)
|
|
729
|
+
return null;
|
|
730
|
+
let stats;
|
|
731
|
+
try {
|
|
732
|
+
stats = statSync(dir);
|
|
733
|
+
}
|
|
734
|
+
catch {
|
|
735
|
+
return null;
|
|
736
|
+
}
|
|
737
|
+
const name = rel === "" ? "." : basename(rel);
|
|
738
|
+
if (!stats.isDirectory()) {
|
|
739
|
+
counter.value += 1;
|
|
740
|
+
return {
|
|
741
|
+
name,
|
|
742
|
+
path: rel,
|
|
743
|
+
type: "file",
|
|
744
|
+
};
|
|
745
|
+
}
|
|
746
|
+
counter.value += 1;
|
|
747
|
+
if (depth >= WORKSPACE_TREE_MAX_DEPTH) {
|
|
748
|
+
return { name, path: rel, type: "dir" };
|
|
749
|
+
}
|
|
750
|
+
let entries;
|
|
751
|
+
try {
|
|
752
|
+
entries = readdirSync(dir, { withFileTypes: true });
|
|
753
|
+
}
|
|
754
|
+
catch {
|
|
755
|
+
return { name, path: rel, type: "dir" };
|
|
756
|
+
}
|
|
757
|
+
const children = [];
|
|
758
|
+
for (const entry of entries.toSorted((a, b) => {
|
|
759
|
+
if (a.isDirectory() !== b.isDirectory())
|
|
760
|
+
return a.isDirectory() ? -1 : 1;
|
|
761
|
+
return a.name.localeCompare(b.name);
|
|
762
|
+
})) {
|
|
763
|
+
const childRel = rel === "" ? entry.name : `${rel}/${entry.name}`;
|
|
764
|
+
if (!isWorkspacePathAllowed(childRel))
|
|
765
|
+
continue;
|
|
766
|
+
if (counter.value >= WORKSPACE_TREE_MAX_ENTRIES) {
|
|
767
|
+
break;
|
|
768
|
+
}
|
|
769
|
+
const node = walk(join(dir, entry.name), childRel, depth + 1);
|
|
770
|
+
if (node)
|
|
771
|
+
children.push(node);
|
|
772
|
+
}
|
|
773
|
+
return {
|
|
774
|
+
name,
|
|
775
|
+
path: rel,
|
|
776
|
+
type: "dir",
|
|
777
|
+
children,
|
|
778
|
+
};
|
|
779
|
+
};
|
|
780
|
+
const node = walk(startDir, relPrefix, 0);
|
|
781
|
+
return node;
|
|
782
|
+
}
|
|
783
|
+
function serveWorkspaceTree(res, url, services, token) {
|
|
784
|
+
const scope = resolveConversationFromQuery(url, token);
|
|
785
|
+
if (scope.error) {
|
|
786
|
+
jsonRes(res, 403, { error: scope.error });
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
789
|
+
const workspace = requireAdminWorkspace(res, services);
|
|
790
|
+
if (!workspace)
|
|
791
|
+
return;
|
|
792
|
+
const convDir = workspace.office(scope.address).dir;
|
|
793
|
+
if (!existsSync(convDir)) {
|
|
794
|
+
jsonRes(res, 200, { conversationId: scope.conversationId, tree: null });
|
|
795
|
+
return;
|
|
796
|
+
}
|
|
797
|
+
const requestedSub = (url.searchParams.get("path") ?? "").trim();
|
|
798
|
+
if (!isWorkspacePathAllowed(requestedSub)) {
|
|
799
|
+
jsonRes(res, 403, { error: "Workspace path is not exposed" });
|
|
800
|
+
return;
|
|
801
|
+
}
|
|
802
|
+
const startSafe = safeJoinUnderRoot(convDir, requestedSub);
|
|
803
|
+
if (startSafe.error) {
|
|
804
|
+
jsonRes(res, 400, { error: startSafe.error });
|
|
805
|
+
return;
|
|
806
|
+
}
|
|
807
|
+
const tree = buildTree(startSafe.absolute, requestedSub);
|
|
808
|
+
jsonRes(res, 200, {
|
|
809
|
+
conversationId: scope.conversationId,
|
|
810
|
+
root: requestedSub || ".",
|
|
811
|
+
tree,
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
const BINARY_PROBE_BYTES = 4096;
|
|
815
|
+
function looksTextual(buf) {
|
|
816
|
+
const limit = Math.min(buf.length, BINARY_PROBE_BYTES);
|
|
817
|
+
for (let i = 0; i < limit; i++) {
|
|
818
|
+
const byte = buf[i];
|
|
819
|
+
if (byte === undefined || byte === 0)
|
|
820
|
+
return false;
|
|
821
|
+
if (byte < 9)
|
|
822
|
+
return false;
|
|
823
|
+
if (byte === 11 || byte === 12)
|
|
824
|
+
return false;
|
|
825
|
+
if (byte > 13 && byte < 32)
|
|
826
|
+
return false;
|
|
827
|
+
}
|
|
828
|
+
return true;
|
|
829
|
+
}
|
|
830
|
+
function servePreviewFile(res, absolutePath, metadata, notFoundMessage) {
|
|
831
|
+
let stats;
|
|
832
|
+
try {
|
|
833
|
+
stats = statSync(absolutePath);
|
|
834
|
+
}
|
|
835
|
+
catch {
|
|
836
|
+
jsonRes(res, 404, { error: notFoundMessage });
|
|
837
|
+
return;
|
|
838
|
+
}
|
|
839
|
+
if (!stats.isFile()) {
|
|
840
|
+
jsonRes(res, 400, { error: "Not a file" });
|
|
841
|
+
return;
|
|
842
|
+
}
|
|
843
|
+
if (stats.size > PREVIEW_FILE_MAX_BYTES) {
|
|
844
|
+
jsonRes(res, 413, {
|
|
845
|
+
error: "File too large to preview",
|
|
846
|
+
size: stats.size,
|
|
847
|
+
limit: PREVIEW_FILE_MAX_BYTES,
|
|
848
|
+
});
|
|
849
|
+
return;
|
|
850
|
+
}
|
|
851
|
+
let buf;
|
|
852
|
+
try {
|
|
853
|
+
buf = readFileSync(absolutePath);
|
|
854
|
+
}
|
|
855
|
+
catch (err) {
|
|
856
|
+
jsonRes(res, 500, { error: errorMessage(err) });
|
|
857
|
+
return;
|
|
858
|
+
}
|
|
859
|
+
if (!looksTextual(buf)) {
|
|
860
|
+
jsonRes(res, 200, {
|
|
861
|
+
...metadata,
|
|
862
|
+
size: stats.size,
|
|
863
|
+
mtimeMs: stats.mtimeMs,
|
|
864
|
+
binary: true,
|
|
865
|
+
content: null,
|
|
866
|
+
});
|
|
867
|
+
return;
|
|
868
|
+
}
|
|
869
|
+
jsonRes(res, 200, {
|
|
870
|
+
...metadata,
|
|
871
|
+
size: stats.size,
|
|
872
|
+
mtimeMs: stats.mtimeMs,
|
|
873
|
+
binary: false,
|
|
874
|
+
content: buf.toString("utf-8"),
|
|
875
|
+
});
|
|
876
|
+
}
|
|
877
|
+
function serveWorkspaceFile(res, url, services, token) {
|
|
878
|
+
const scope = resolveConversationFromQuery(url, token);
|
|
879
|
+
if (scope.error) {
|
|
880
|
+
jsonRes(res, 403, { error: scope.error });
|
|
881
|
+
return;
|
|
882
|
+
}
|
|
883
|
+
const workspace = requireAdminWorkspace(res, services);
|
|
884
|
+
if (!workspace)
|
|
885
|
+
return;
|
|
886
|
+
const requestedPath = (url.searchParams.get("path") ?? "").trim();
|
|
887
|
+
if (!requestedPath) {
|
|
888
|
+
jsonRes(res, 400, { error: "Missing path" });
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
891
|
+
if (!isWorkspacePathAllowed(requestedPath)) {
|
|
892
|
+
jsonRes(res, 403, { error: "Workspace path is not exposed" });
|
|
893
|
+
return;
|
|
894
|
+
}
|
|
895
|
+
const convDir = workspace.office(scope.address).dir;
|
|
896
|
+
const safe = safeJoinUnderRoot(convDir, requestedPath);
|
|
897
|
+
if (safe.error) {
|
|
898
|
+
jsonRes(res, 400, { error: safe.error });
|
|
899
|
+
return;
|
|
900
|
+
}
|
|
901
|
+
servePreviewFile(res, safe.absolute, { path: requestedPath }, "File not found");
|
|
902
|
+
}
|
|
903
|
+
function readSkillMeta(filePath) {
|
|
904
|
+
let text;
|
|
905
|
+
try {
|
|
906
|
+
text = readFileSync(filePath, "utf-8");
|
|
907
|
+
}
|
|
908
|
+
catch {
|
|
909
|
+
return {};
|
|
910
|
+
}
|
|
911
|
+
const { values } = parseFrontmatter(text);
|
|
912
|
+
const out = {};
|
|
913
|
+
for (const [key, value] of Object.entries(values)) {
|
|
914
|
+
const normalized = key.toLowerCase();
|
|
915
|
+
if (normalized === "name")
|
|
916
|
+
out.name = value;
|
|
917
|
+
if (normalized === "description")
|
|
918
|
+
out.description = value;
|
|
919
|
+
}
|
|
920
|
+
return out;
|
|
921
|
+
}
|
|
922
|
+
export function readSkillsFromDir(skillsDir, source) {
|
|
923
|
+
if (!existsSync(skillsDir))
|
|
924
|
+
return [];
|
|
925
|
+
const out = [];
|
|
926
|
+
let entries;
|
|
927
|
+
try {
|
|
928
|
+
entries = readdirSync(skillsDir, { withFileTypes: true });
|
|
929
|
+
}
|
|
930
|
+
catch {
|
|
931
|
+
return [];
|
|
932
|
+
}
|
|
933
|
+
for (const entry of entries) {
|
|
934
|
+
if (!entry.isDirectory() || entry.name.startsWith("."))
|
|
935
|
+
continue;
|
|
936
|
+
const skillMd = join(skillsDir, entry.name, "SKILL.md");
|
|
937
|
+
if (!existsSync(skillMd))
|
|
938
|
+
continue;
|
|
939
|
+
const meta = readSkillMeta(skillMd);
|
|
940
|
+
out.push({
|
|
941
|
+
name: meta.name ?? entry.name,
|
|
942
|
+
description: meta.description ?? "",
|
|
943
|
+
source,
|
|
944
|
+
directory: entry.name,
|
|
945
|
+
});
|
|
946
|
+
}
|
|
947
|
+
return out.toSorted((a, b) => a.name.localeCompare(b.name));
|
|
948
|
+
}
|
|
949
|
+
function serveMcpServersList(res, url, services, token) {
|
|
950
|
+
const scope = resolveConversationFromQuery(url, token);
|
|
951
|
+
if (scope.error) {
|
|
952
|
+
jsonRes(res, 403, { error: scope.error });
|
|
953
|
+
return;
|
|
954
|
+
}
|
|
955
|
+
const workspace = requireAdminWorkspace(res, services);
|
|
956
|
+
if (!workspace)
|
|
957
|
+
return;
|
|
958
|
+
const servers = loadScopeMcpServers(workspace.office(scope.address));
|
|
959
|
+
jsonRes(res, 200, {
|
|
960
|
+
conversationId: scope.conversationId,
|
|
961
|
+
presets: listMcpPresets(),
|
|
962
|
+
global: redactMcpServers(servers.global),
|
|
963
|
+
conversation: redactMcpServers(servers.conversation),
|
|
964
|
+
});
|
|
965
|
+
}
|
|
966
|
+
function redactMcpServers(map) {
|
|
967
|
+
return Object.fromEntries(Object.entries(map).map(([name, config]) => [
|
|
968
|
+
name,
|
|
969
|
+
{
|
|
970
|
+
command: config.command,
|
|
971
|
+
args: config.args,
|
|
972
|
+
url: config.url !== undefined ? redactMcpUrl(config.url) : undefined,
|
|
973
|
+
disabled: config.disabled,
|
|
974
|
+
envKeys: Object.keys(config.env ?? {}),
|
|
975
|
+
headerKeys: Object.keys(config.headers ?? {}),
|
|
976
|
+
},
|
|
977
|
+
]));
|
|
978
|
+
}
|
|
979
|
+
function mcpStringMap(value) {
|
|
980
|
+
if (typeof value !== "object" || value === null)
|
|
981
|
+
return undefined;
|
|
982
|
+
const out = {};
|
|
983
|
+
for (const [k, v] of Object.entries(value)) {
|
|
984
|
+
if (typeof v === "string" && k.trim())
|
|
985
|
+
out[k.trim()] = v;
|
|
986
|
+
}
|
|
987
|
+
return Object.keys(out).length > 0 ? out : undefined;
|
|
988
|
+
}
|
|
989
|
+
const MCP_VERIFY_TIMEOUT_MS = 20_000;
|
|
990
|
+
async function verifyMcpServers(servers) {
|
|
991
|
+
const names = Object.keys(servers);
|
|
992
|
+
if (names.length === 0)
|
|
993
|
+
return [];
|
|
994
|
+
const loaded = await loadMcpTools(servers, AbortSignal.timeout(MCP_VERIFY_TIMEOUT_MS));
|
|
995
|
+
try {
|
|
996
|
+
return names.map((name) => {
|
|
997
|
+
const failure = loaded.errors.find((e) => e.server === name);
|
|
998
|
+
if (failure) {
|
|
999
|
+
const url = servers[name]?.url;
|
|
1000
|
+
const error = url ? failure.error.split(url).join(redactMcpUrl(url)) : failure.error;
|
|
1001
|
+
return { error };
|
|
1002
|
+
}
|
|
1003
|
+
const prefix = `mcp__${name}__`;
|
|
1004
|
+
return { tools: loaded.tools.filter((t) => t.name.startsWith(prefix)).length };
|
|
1005
|
+
});
|
|
1006
|
+
}
|
|
1007
|
+
finally {
|
|
1008
|
+
await loaded.dispose();
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
function planMcpMutation(action, body, current) {
|
|
1012
|
+
const next = { ...current };
|
|
1013
|
+
if (action === "import") {
|
|
1014
|
+
const parsed = parseStandardMcpServers(typeof body.json === "string" ? body.json : "");
|
|
1015
|
+
if (!parsed.servers)
|
|
1016
|
+
return { status: 400, error: parsed.error };
|
|
1017
|
+
Object.assign(next, parsed.servers);
|
|
1018
|
+
return { next, touched: parsed.servers };
|
|
1019
|
+
}
|
|
1020
|
+
const preset = action === "install" && typeof body.presetId === "string"
|
|
1021
|
+
? findMcpPreset(body.presetId)
|
|
1022
|
+
: undefined;
|
|
1023
|
+
if (action === "install" && !preset)
|
|
1024
|
+
return { status: 400, error: "unknown MCP preset" };
|
|
1025
|
+
const name = preset?.serverName ?? (typeof body.name === "string" ? body.name.trim() : "");
|
|
1026
|
+
if (!isValidMcpServerName(name)) {
|
|
1027
|
+
return {
|
|
1028
|
+
status: 400,
|
|
1029
|
+
error: "invalid server name (letters, digits, '_' or '-', starting with a letter)",
|
|
1030
|
+
};
|
|
1031
|
+
}
|
|
1032
|
+
if (action === "install") {
|
|
1033
|
+
try {
|
|
1034
|
+
next[name] = materializeMcpPreset(preset, mcpStringMap(body.credentials) ?? {});
|
|
1035
|
+
}
|
|
1036
|
+
catch (err) {
|
|
1037
|
+
return { status: 400, error: errorMessage(err) };
|
|
1038
|
+
}
|
|
1039
|
+
return { next, touched: { [name]: next[name] } };
|
|
1040
|
+
}
|
|
1041
|
+
if (!(name in next))
|
|
1042
|
+
return { status: 404, error: "Not declared here." };
|
|
1043
|
+
if (action === "remove") {
|
|
1044
|
+
delete next[name];
|
|
1045
|
+
return { next, touched: {} };
|
|
1046
|
+
}
|
|
1047
|
+
const entry = next[name];
|
|
1048
|
+
next[name] = entry.disabled ? { ...entry, disabled: undefined } : { ...entry, disabled: true };
|
|
1049
|
+
return { next, touched: {} };
|
|
1050
|
+
}
|
|
1051
|
+
async function serveMcpServerMutation(res, body, services, token) {
|
|
1052
|
+
const action = body.action;
|
|
1053
|
+
if (action !== "import" &&
|
|
1054
|
+
action !== "install" &&
|
|
1055
|
+
action !== "remove" &&
|
|
1056
|
+
action !== "toggle" &&
|
|
1057
|
+
action !== "test") {
|
|
1058
|
+
jsonRes(res, 400, {
|
|
1059
|
+
error: "action must be 'import', 'install', 'remove', 'toggle', or 'test'",
|
|
1060
|
+
});
|
|
1061
|
+
return;
|
|
1062
|
+
}
|
|
1063
|
+
const mutationScope = body.scope === "global" ? "global" : "conversation";
|
|
1064
|
+
const scope = resolveTargetConversation(body, token);
|
|
1065
|
+
if (scope.error) {
|
|
1066
|
+
jsonRes(res, 403, { error: scope.error });
|
|
1067
|
+
return;
|
|
1068
|
+
}
|
|
1069
|
+
const workspace = requireAdminWorkspace(res, services);
|
|
1070
|
+
if (!workspace)
|
|
1071
|
+
return;
|
|
1072
|
+
const office = workspace.office(scope.address);
|
|
1073
|
+
const maps = loadScopeMcpServers(office);
|
|
1074
|
+
const current = mutationScope === "global" ? maps.global : maps.conversation;
|
|
1075
|
+
if (action === "test") {
|
|
1076
|
+
const name = typeof body.name === "string" ? body.name.trim() : "";
|
|
1077
|
+
const entry = current[name];
|
|
1078
|
+
if (!entry) {
|
|
1079
|
+
jsonRes(res, 404, { error: "Not declared here." });
|
|
1080
|
+
return;
|
|
1081
|
+
}
|
|
1082
|
+
const results = await verifyMcpServers({ [name]: { ...entry, disabled: undefined } });
|
|
1083
|
+
jsonRes(res, 200, { ok: true, results });
|
|
1084
|
+
return;
|
|
1085
|
+
}
|
|
1086
|
+
const plan = planMcpMutation(action, body, current);
|
|
1087
|
+
if ("error" in plan) {
|
|
1088
|
+
jsonRes(res, plan.status, { error: plan.error });
|
|
1089
|
+
return;
|
|
1090
|
+
}
|
|
1091
|
+
const result = mutationScope === "global"
|
|
1092
|
+
? applyGlobalSettings(services.runtime, { mcpServers: plan.next })
|
|
1093
|
+
: applyConversationSettings(services.runtime, office, { mcpServers: plan.next });
|
|
1094
|
+
if (!result.ok) {
|
|
1095
|
+
jsonRes(res, 409, { error: "Conversation is busy; try again shortly." });
|
|
1096
|
+
return;
|
|
1097
|
+
}
|
|
1098
|
+
const results = await verifyMcpServers(plan.touched);
|
|
1099
|
+
jsonRes(res, 200, { ok: true, results });
|
|
1100
|
+
}
|
|
1101
|
+
function serveSkillsList(res, url, services, token) {
|
|
1102
|
+
const scope = resolveConversationFromQuery(url, token);
|
|
1103
|
+
if (scope.error) {
|
|
1104
|
+
jsonRes(res, 403, { error: scope.error });
|
|
1105
|
+
return;
|
|
1106
|
+
}
|
|
1107
|
+
const workspace = requireAdminWorkspace(res, services);
|
|
1108
|
+
if (!workspace)
|
|
1109
|
+
return;
|
|
1110
|
+
const global = readSkillsFromDir(workspace.skillsDir, "global");
|
|
1111
|
+
const conversation = readSkillsFromDir(workspace.office(scope.address).skillsDir, "conversation");
|
|
1112
|
+
jsonRes(res, 200, {
|
|
1113
|
+
conversationId: scope.conversationId,
|
|
1114
|
+
skills: [...global, ...conversation],
|
|
1115
|
+
});
|
|
1116
|
+
}
|
|
1117
|
+
function serveSkillFile(res, url, services, token) {
|
|
1118
|
+
const scope = resolveConversationFromQuery(url, token);
|
|
1119
|
+
if (scope.error) {
|
|
1120
|
+
jsonRes(res, 403, { error: scope.error });
|
|
1121
|
+
return;
|
|
1122
|
+
}
|
|
1123
|
+
const workspace = requireAdminWorkspace(res, services);
|
|
1124
|
+
if (!workspace)
|
|
1125
|
+
return;
|
|
1126
|
+
const source = (url.searchParams.get("source") ?? "").trim();
|
|
1127
|
+
const directory = (url.searchParams.get("directory") ?? "").trim();
|
|
1128
|
+
if (source !== "global" && source !== "conversation") {
|
|
1129
|
+
jsonRes(res, 400, { error: "Invalid skill source" });
|
|
1130
|
+
return;
|
|
1131
|
+
}
|
|
1132
|
+
if (!directory ||
|
|
1133
|
+
directory.includes("/") ||
|
|
1134
|
+
directory.includes("\\") ||
|
|
1135
|
+
directory.includes("..")) {
|
|
1136
|
+
jsonRes(res, 400, { error: "Invalid skill directory" });
|
|
1137
|
+
return;
|
|
1138
|
+
}
|
|
1139
|
+
const skillsRoot = source === "global" ? workspace.skillsDir : workspace.office(scope.address).skillsDir;
|
|
1140
|
+
const safe = safeJoinUnderRoot(skillsRoot, join(directory, "SKILL.md"));
|
|
1141
|
+
if (safe.error) {
|
|
1142
|
+
jsonRes(res, 400, { error: safe.error });
|
|
1143
|
+
return;
|
|
1144
|
+
}
|
|
1145
|
+
servePreviewFile(res, safe.absolute, { source, directory }, "Skill file not found");
|
|
1146
|
+
}
|
|
1147
|
+
const SKILL_DIRECTORY_PATTERN = /^[a-z0-9-]+$/;
|
|
1148
|
+
function resolveSkillsRoot(workspace, scope, source) {
|
|
1149
|
+
if (source !== "global" && source !== "conversation") {
|
|
1150
|
+
return { error: "Invalid skill source" };
|
|
1151
|
+
}
|
|
1152
|
+
return {
|
|
1153
|
+
root: source === "global" ? workspace.skillsDir : workspace.office(scope.address).skillsDir,
|
|
1154
|
+
source,
|
|
1155
|
+
};
|
|
1156
|
+
}
|
|
1157
|
+
async function serveSkillMutation(res, body, services, token) {
|
|
1158
|
+
const action = body.action;
|
|
1159
|
+
if (action !== "save" && action !== "delete") {
|
|
1160
|
+
jsonRes(res, 400, { error: "action must be 'save' or 'delete'" });
|
|
1161
|
+
return;
|
|
1162
|
+
}
|
|
1163
|
+
const scope = resolveTargetConversation(body, token);
|
|
1164
|
+
if (scope.error) {
|
|
1165
|
+
jsonRes(res, 403, { error: scope.error });
|
|
1166
|
+
return;
|
|
1167
|
+
}
|
|
1168
|
+
const workspace = requireAdminWorkspace(res, services);
|
|
1169
|
+
if (!workspace)
|
|
1170
|
+
return;
|
|
1171
|
+
const resolved = resolveSkillsRoot(workspace, scope, body.source);
|
|
1172
|
+
if ("error" in resolved) {
|
|
1173
|
+
jsonRes(res, 400, { error: resolved.error });
|
|
1174
|
+
return;
|
|
1175
|
+
}
|
|
1176
|
+
const directory = typeof body.directory === "string" ? body.directory.trim() : "";
|
|
1177
|
+
if (!directory || !SKILL_DIRECTORY_PATTERN.test(directory)) {
|
|
1178
|
+
jsonRes(res, 400, {
|
|
1179
|
+
error: "directory must be lowercase a-z, 0-9 and hyphens",
|
|
1180
|
+
});
|
|
1181
|
+
return;
|
|
1182
|
+
}
|
|
1183
|
+
const safe = safeJoinUnderRoot(resolved.root, directory);
|
|
1184
|
+
if (safe.error) {
|
|
1185
|
+
jsonRes(res, 400, { error: safe.error });
|
|
1186
|
+
return;
|
|
1187
|
+
}
|
|
1188
|
+
if (action === "delete") {
|
|
1189
|
+
if (!existsSync(join(safe.absolute, "SKILL.md"))) {
|
|
1190
|
+
jsonRes(res, 404, { error: "Skill not found" });
|
|
1191
|
+
return;
|
|
1192
|
+
}
|
|
1193
|
+
try {
|
|
1194
|
+
rmSync(safe.absolute, { recursive: true, force: true });
|
|
1195
|
+
}
|
|
1196
|
+
catch (err) {
|
|
1197
|
+
jsonRes(res, 500, { error: errorMessage(err) });
|
|
1198
|
+
return;
|
|
1199
|
+
}
|
|
1200
|
+
jsonRes(res, 200, { ok: true });
|
|
1201
|
+
return;
|
|
1202
|
+
}
|
|
1203
|
+
const name = typeof body.name === "string" ? body.name.trim() : directory;
|
|
1204
|
+
const description = typeof body.description === "string" ? body.description.trim() : "";
|
|
1205
|
+
const content = typeof body.content === "string" ? body.content : "";
|
|
1206
|
+
if (!description) {
|
|
1207
|
+
jsonRes(res, 400, { error: "description is required" });
|
|
1208
|
+
return;
|
|
1209
|
+
}
|
|
1210
|
+
const errors = validateSkill(name, description);
|
|
1211
|
+
if (errors.length > 0) {
|
|
1212
|
+
jsonRes(res, 400, { error: errors.join("; ") });
|
|
1213
|
+
return;
|
|
1214
|
+
}
|
|
1215
|
+
try {
|
|
1216
|
+
if (existsSync(safe.absolute) && lstatSync(safe.absolute).isSymbolicLink()) {
|
|
1217
|
+
throw new Error("Refusing to write through a symlinked skill directory");
|
|
1218
|
+
}
|
|
1219
|
+
mkdirSync(safe.absolute, { recursive: true });
|
|
1220
|
+
const frontmatter = ["---", `name: ${name}`, `description: ${description}`, "---", ""].join("\n");
|
|
1221
|
+
atomicWritePrivateFile(join(safe.absolute, "SKILL.md"), frontmatter + content.trim() + "\n");
|
|
1222
|
+
}
|
|
1223
|
+
catch (err) {
|
|
1224
|
+
jsonRes(res, 500, { error: errorMessage(err) });
|
|
1225
|
+
return;
|
|
1226
|
+
}
|
|
1227
|
+
jsonRes(res, 200, { ok: true, name, directory, source: resolved.source });
|
|
1228
|
+
}
|
|
1229
|
+
export async function listOfficeEvents(store) {
|
|
1230
|
+
const entries = await store.list();
|
|
1231
|
+
return entries.map((entry) => {
|
|
1232
|
+
const payload = entry.payload;
|
|
1233
|
+
return {
|
|
1234
|
+
name: entry.filename,
|
|
1235
|
+
officePlatform: store.address.platform,
|
|
1236
|
+
officeConversationId: store.address.conversationId,
|
|
1237
|
+
size: entry.size,
|
|
1238
|
+
mtimeMs: entry.mtimeMs,
|
|
1239
|
+
type: payload?.type ?? null,
|
|
1240
|
+
platform: payload?.platform ?? null,
|
|
1241
|
+
conversationId: payload?.conversationId ?? null,
|
|
1242
|
+
text: payload?.text ?? null,
|
|
1243
|
+
at: payload?.type === "one-shot" ? payload.at : null,
|
|
1244
|
+
schedule: payload?.type === "periodic" ? payload.schedule : null,
|
|
1245
|
+
timezone: payload?.type === "periodic" ? payload.timezone : null,
|
|
1246
|
+
};
|
|
1247
|
+
});
|
|
1248
|
+
}
|
|
1249
|
+
function requireAdminEventStore(res, services, office) {
|
|
1250
|
+
if (!services.eventStore) {
|
|
1251
|
+
jsonRes(res, 503, { error: "Working directory not available" });
|
|
1252
|
+
return null;
|
|
1253
|
+
}
|
|
1254
|
+
return services.eventStore(office);
|
|
1255
|
+
}
|
|
1256
|
+
async function serveEventsList(res, services) {
|
|
1257
|
+
const workspace = requireAdminWorkspace(res, services);
|
|
1258
|
+
if (!workspace)
|
|
1259
|
+
return;
|
|
1260
|
+
if (!services.eventStore) {
|
|
1261
|
+
jsonRes(res, 503, { error: "Working directory not available" });
|
|
1262
|
+
return;
|
|
1263
|
+
}
|
|
1264
|
+
const events = [];
|
|
1265
|
+
for (const record of listRegisteredOffices(workspace.stateDir)) {
|
|
1266
|
+
events.push(...(await listOfficeEvents(services.eventStore(workspace.office(record)))));
|
|
1267
|
+
}
|
|
1268
|
+
jsonRes(res, 200, { events });
|
|
1269
|
+
}
|
|
1270
|
+
async function serveConversationEventsList(res, url, services, token) {
|
|
1271
|
+
const scope = resolveConversationFromQuery(url, token);
|
|
1272
|
+
if (scope.error) {
|
|
1273
|
+
jsonRes(res, 403, { error: scope.error });
|
|
1274
|
+
return;
|
|
1275
|
+
}
|
|
1276
|
+
const workspace = requireAdminWorkspace(res, services);
|
|
1277
|
+
if (!workspace)
|
|
1278
|
+
return;
|
|
1279
|
+
const store = requireAdminEventStore(res, services, workspace.office(scope.address));
|
|
1280
|
+
if (!store)
|
|
1281
|
+
return;
|
|
1282
|
+
jsonRes(res, 200, {
|
|
1283
|
+
conversationId: scope.conversationId,
|
|
1284
|
+
events: await listOfficeEvents(store),
|
|
1285
|
+
});
|
|
1286
|
+
}
|
|
1287
|
+
async function serveConversationEventDelete(res, body, services, token) {
|
|
1288
|
+
const scope = resolveTargetConversation(body, token);
|
|
1289
|
+
if (scope.error) {
|
|
1290
|
+
jsonRes(res, 403, { error: scope.error });
|
|
1291
|
+
return;
|
|
1292
|
+
}
|
|
1293
|
+
let name;
|
|
1294
|
+
try {
|
|
1295
|
+
name = validateEventFilename(typeof body.name === "string" ? body.name : "");
|
|
1296
|
+
}
|
|
1297
|
+
catch {
|
|
1298
|
+
jsonRes(res, 400, { error: "Invalid name" });
|
|
1299
|
+
return;
|
|
1300
|
+
}
|
|
1301
|
+
const workspace = requireAdminWorkspace(res, services);
|
|
1302
|
+
if (!workspace)
|
|
1303
|
+
return;
|
|
1304
|
+
const store = requireAdminEventStore(res, services, workspace.office(scope.address));
|
|
1305
|
+
if (!store)
|
|
1306
|
+
return;
|
|
1307
|
+
try {
|
|
1308
|
+
await store.delete(name);
|
|
1309
|
+
jsonRes(res, 200, { ok: true });
|
|
1310
|
+
}
|
|
1311
|
+
catch (err) {
|
|
1312
|
+
const message = errorMessage(err);
|
|
1313
|
+
jsonRes(res, /not found/.test(message) ? 404 : 500, { error: message });
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
const esc = escapeHtml;
|
|
1317
|
+
const ICONS = {
|
|
1318
|
+
settings: `<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33h.01a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82v.01a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"/></svg>`,
|
|
1319
|
+
workspace: `<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z"/></svg>`,
|
|
1320
|
+
skills: `<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M4 19.5V5a2 2 0 0 1 2-2h11a1 1 0 0 1 1 1v14"/><path d="M6 17h13v4H6.5A2.5 2.5 0 0 1 4 18.5v0A2.5 2.5 0 0 1 6.5 16H20"/></svg>`,
|
|
1321
|
+
mcp: `<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="7" rx="1.5"/><rect x="3" y="13" width="18" height="7" rx="1.5"/><circle cx="7" cy="7.5" r="1" fill="currentColor" stroke="none"/><circle cx="7" cy="16.5" r="1" fill="currentColor" stroke="none"/></svg>`,
|
|
1322
|
+
vault: `<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="10" rx="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg>`,
|
|
1323
|
+
events: `<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="5" width="18" height="16" rx="2"/><path d="M3 10h18M8 3v4M16 3v4"/></svg>`,
|
|
1324
|
+
session: `<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"/></svg>`,
|
|
1325
|
+
overview: `<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="8" height="8" rx="1.5"/><rect x="13" y="3" width="8" height="5" rx="1.5"/><rect x="13" y="11" width="8" height="10" rx="1.5"/><rect x="3" y="14" width="8" height="7" rx="1.5"/></svg>`,
|
|
1326
|
+
usage: `<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M3 21V3"/><path d="M3 21h18"/><path d="M7 17V11M12 17V7M17 17v-4"/></svg>`,
|
|
1327
|
+
};
|
|
1328
|
+
function railLink(id, label, icon, active = false) {
|
|
1329
|
+
const svg = ICONS[icon];
|
|
1330
|
+
return `<button class="rail-link${active ? " active" : ""}" type="button" data-pane="${id}" aria-current="${active ? "page" : "false"}" aria-label="${esc(label)}" title="${esc(label)}">${svg}<span>${esc(label)}</span></button>`;
|
|
1331
|
+
}
|
|
1332
|
+
function settingsPane(id, title, description, actions, body) {
|
|
1333
|
+
return `<section class="pane" id="pane-${id}" data-pane="${id}">
|
|
1334
|
+
<header class="pane-head">
|
|
1335
|
+
<div><h2 class="pane-title">${esc(title)}</h2><p class="pane-desc">${esc(description)}</p></div>
|
|
1336
|
+
<div class="pane-actions">${actions}</div>
|
|
1337
|
+
</header>
|
|
1338
|
+
<div class="pane-body">${body}</div>
|
|
1339
|
+
</section>`;
|
|
1340
|
+
}
|
|
1341
|
+
const adminViewBody = `<div class="settings-shell">
|
|
1342
|
+
<aside class="settings-rail" aria-label="Admin sections">
|
|
1343
|
+
<div class="rail-scope" role="tablist" aria-label="Scope">
|
|
1344
|
+
<button class="rail-scope-btn active" role="tab" aria-selected="true" aria-controls="panel-conversation" data-tab="conversation">This conversation</button>
|
|
1345
|
+
<button class="rail-scope-btn" role="tab" aria-selected="false" aria-controls="panel-global" data-tab="global">Workspace</button>
|
|
1346
|
+
</div>
|
|
1347
|
+
<nav class="rail-nav" id="rail-nav-conversation" data-scope="conversation">
|
|
1348
|
+
${railLink("settings", "Settings", "settings", true)}
|
|
1349
|
+
${railLink("workspace", "Workspace", "workspace")}
|
|
1350
|
+
${railLink("skills", "Skills", "skills")}
|
|
1351
|
+
${railLink("mcp", "MCP servers", "mcp")}
|
|
1352
|
+
${railLink("vault", "Vault", "vault")}
|
|
1353
|
+
${railLink("events", "Events", "events")}
|
|
1354
|
+
${railLink("session", "Session view", "session")}
|
|
1355
|
+
</nav>
|
|
1356
|
+
<nav class="rail-nav" id="rail-nav-global" data-scope="global" hidden>
|
|
1357
|
+
${railLink("g-overview", "All conversations", "overview", true)}
|
|
1358
|
+
${railLink("g-usage", "Token usage", "usage")}
|
|
1359
|
+
${railLink("g-settings", "Defaults", "settings")}
|
|
1360
|
+
${railLink("g-mcp", "MCP servers", "mcp")}
|
|
1361
|
+
${railLink("g-skills", "Skills", "skills")}
|
|
1362
|
+
${railLink("g-events", "Events", "events")}
|
|
1363
|
+
</nav>
|
|
1364
|
+
</aside>
|
|
1365
|
+
|
|
1366
|
+
<div class="settings-panels">
|
|
1367
|
+
<div class="tab-panel active" id="panel-conversation">
|
|
1368
|
+
${settingsPane("settings", "Settings", "Model, thinking level, auto-reply, and workspace visibility for this conversation.", '<button class="refresh-btn" type="button" aria-label="Refresh" title="Refresh" onclick="loadSettings()">↻</button>', '<div id="settings-content"><div class="loading-msg">Loading…</div></div>')}
|
|
1369
|
+
|
|
1370
|
+
${settingsPane("workspace", "Workspace", "Read-only browser for this conversation's files on disk.", '<button class="refresh-btn" type="button" aria-label="Refresh" title="Refresh" onclick="loadWorkspace()">↻</button>', '<div class="workspace-split"><div id="workspace-tree" class="workspace-tree"><div class="loading-msg">Loading…</div></div><div id="workspace-preview" class="workspace-preview"><div class="placeholder-msg">Click a file to preview</div></div></div>')}
|
|
1371
|
+
|
|
1372
|
+
${settingsPane("skills", "Skills", "Instructions the agent can load for specific tasks in this conversation.", '<button class="primary-action-btn" onclick="openSkillDialog(\'conversation\')">+ New skill</button><button class="refresh-btn" type="button" aria-label="Refresh" title="Refresh" onclick="loadSkills()">↻</button>', '<div class="workspace-split"><div id="skills-content" class="workspace-tree"><div class="loading-msg">Loading…</div></div><div id="skills-preview" class="workspace-preview"><div class="placeholder-msg">Click a skill to preview SKILL.md</div></div></div>')}
|
|
1373
|
+
|
|
1374
|
+
${settingsPane("mcp", "MCP servers", "External tools this conversation can call during a run.", '<button class="refresh-btn" type="button" aria-label="Refresh" title="Refresh" onclick="loadMcpServers()">↻</button>', '<div id="mcp-conv-msg" class="status-msg" style="display:none"></div><div id="mcp-conv-content"><div class="loading-msg">Loading…</div></div>')}
|
|
1375
|
+
|
|
1376
|
+
${settingsPane("vault", "Vault", "Credentials scoped to this conversation.", '<button class="primary-action-btn" onclick="openLogin()">Open in new tab ↗</button>', '<div id="vault-link-result" class="link-result" style="display:none"></div><p class="card-desc">Opens the one-time credential form for this conversation\'s vault in a new tab.</p>')}
|
|
1377
|
+
|
|
1378
|
+
${settingsPane("events", "Events", "Scheduled and one-shot events tied to this conversation.", '<button class="refresh-btn" type="button" aria-label="Refresh" title="Refresh" onclick="loadConversationEvents()">↻</button>', '<div id="events-content"><div class="loading-msg">Loading…</div></div>')}
|
|
1379
|
+
|
|
1380
|
+
${settingsPane("session", "Session view", "The full message and tool-call timeline for this conversation.", '<button class="primary-action-btn" onclick="openSessionView()">Open in new tab ↗</button>', '<div id="session-link-result" class="link-result" style="display:none"></div><p class="card-desc">Opens the session timeline for this conversation in a new tab.</p>')}
|
|
1381
|
+
</div>
|
|
1382
|
+
|
|
1383
|
+
<div class="tab-panel" id="panel-global">
|
|
1384
|
+
${settingsPane("g-overview", "All conversations", "Every registered conversation across every platform.", '<button class="refresh-btn" type="button" aria-label="Refresh" title="Refresh" onclick="loadAllConversations()">↻</button>', '<div id="all-conv-content"><div class="loading-msg">Loading…</div></div>')}
|
|
1385
|
+
|
|
1386
|
+
${settingsPane("g-usage", "Token usage", "Spend and volume across every conversation.", '<button class="refresh-btn" type="button" aria-label="Refresh" title="Refresh" onclick="loadTokenUsage()">↻</button>', '<h3 class="card-subtitle">Top 20 sessions</h3><div id="session-usage-content"><div class="loading-msg">Loading…</div></div><h3 class="card-subtitle" style="margin-top:24px">Usage timeline</h3><div class="timeline-controls"><label>Conversation<select id="timeline-conv" onchange="loadUsageTimeline()"></select></label></div><div id="usage-timeline-content"><div class="loading-msg">Loading…</div></div>')}
|
|
1387
|
+
|
|
1388
|
+
${settingsPane("g-settings", "Workspace defaults", "The fallback model, sandbox limits, and Slack behavior every conversation inherits.", '<button class="refresh-btn" type="button" aria-label="Refresh" title="Refresh" onclick="loadGlobalSettings()">↻</button>', '<div id="global-settings-content"><div class="loading-msg">Loading…</div></div>')}
|
|
1389
|
+
|
|
1390
|
+
${settingsPane("g-mcp", "MCP servers", "External tools available to every conversation in this workspace.", '<button class="refresh-btn" type="button" aria-label="Refresh" title="Refresh" onclick="loadMcpServers()">↻</button>', '<div id="mcp-global-msg" class="status-msg" style="display:none"></div><div id="mcp-global-content"><div class="loading-msg">Loading…</div></div>')}
|
|
1391
|
+
|
|
1392
|
+
${settingsPane("g-skills", "Skills", "Shared instructions available to every conversation in this workspace.", '<button class="primary-action-btn" onclick="openSkillDialog(\'global\')">+ New global skill</button><button class="refresh-btn" type="button" aria-label="Refresh" title="Refresh" onclick="loadGlobalSkills()">↻</button>', '<div class="workspace-split"><div id="global-skills-content" class="workspace-tree"><div class="loading-msg">Loading…</div></div><div id="global-skills-preview" class="workspace-preview"><div class="placeholder-msg">Click a skill to preview SKILL.md</div></div></div>')}
|
|
1393
|
+
|
|
1394
|
+
${settingsPane("g-events", "Global events", "Every scheduled event across the whole workspace.", '<button class="refresh-btn" type="button" aria-label="Refresh" title="Refresh" onclick="loadEvents()">↻</button>', '<div id="global-events-content"><div class="loading-msg">Loading…</div></div>')}
|
|
1395
|
+
</div>
|
|
1396
|
+
</div>
|
|
1397
|
+
</div>
|
|
1398
|
+
|
|
1399
|
+
<dialog id="mcp-install-dialog" class="mcp-dialog" aria-labelledby="mcp-dialog-title">
|
|
1400
|
+
<div class="mcp-dialog-head">
|
|
1401
|
+
<div>
|
|
1402
|
+
<p class="eyebrow">Install MCP preset</p>
|
|
1403
|
+
<h2 id="mcp-dialog-title" class="card-title"></h2>
|
|
1404
|
+
</div>
|
|
1405
|
+
<button class="mcp-dialog-close" type="button" aria-label="Close" onclick="closeMcpInstall()">×</button>
|
|
1406
|
+
</div>
|
|
1407
|
+
<div id="mcp-dialog-content"></div>
|
|
1408
|
+
<div id="mcp-dialog-error" class="inline-result err" style="display:none"></div>
|
|
1409
|
+
<div class="mcp-dialog-actions">
|
|
1410
|
+
<button class="mcp-btn" type="button" onclick="closeMcpInstall()">Cancel</button>
|
|
1411
|
+
<button id="mcp-dialog-install" class="primary-action-btn" type="button" onclick="installMcpPreset(this)">Install preset</button>
|
|
1412
|
+
</div>
|
|
1413
|
+
</dialog>
|
|
1414
|
+
|
|
1415
|
+
<dialog id="mcp-custom-dialog" class="mcp-dialog" aria-labelledby="mcp-custom-dialog-title">
|
|
1416
|
+
<div class="mcp-dialog-head">
|
|
1417
|
+
<div>
|
|
1418
|
+
<p class="eyebrow">Add MCP server</p>
|
|
1419
|
+
<h2 id="mcp-custom-dialog-title" class="card-title">新增自訂 server</h2>
|
|
1420
|
+
</div>
|
|
1421
|
+
<button class="mcp-dialog-close" type="button" aria-label="Close" onclick="closeMcpCustomDialog()">×</button>
|
|
1422
|
+
</div>
|
|
1423
|
+
<div id="mcp-custom-dialog-content"></div>
|
|
1424
|
+
<div id="mcp-custom-dialog-error" class="inline-result err" style="display:none"></div>
|
|
1425
|
+
<div class="mcp-dialog-actions">
|
|
1426
|
+
<button class="mcp-btn" type="button" onclick="closeMcpCustomDialog()">Cancel</button>
|
|
1427
|
+
<button id="mcp-custom-dialog-submit" class="primary-action-btn" type="button" onclick="submitMcpCustomDialog(this)">新增並測試連線</button>
|
|
1428
|
+
</div>
|
|
1429
|
+
</dialog>
|
|
1430
|
+
|
|
1431
|
+
<dialog id="skill-dialog" class="mcp-dialog" aria-labelledby="skill-dialog-title">
|
|
1432
|
+
<div class="mcp-dialog-head">
|
|
1433
|
+
<div>
|
|
1434
|
+
<p class="eyebrow" id="skill-dialog-eyebrow">Skill</p>
|
|
1435
|
+
<h2 id="skill-dialog-title" class="card-title">New skill</h2>
|
|
1436
|
+
</div>
|
|
1437
|
+
<button class="mcp-dialog-close" type="button" aria-label="Close" onclick="closeSkillDialog()">×</button>
|
|
1438
|
+
</div>
|
|
1439
|
+
<div class="mcp-field">
|
|
1440
|
+
<span>Directory</span>
|
|
1441
|
+
<input id="skill-dialog-directory" class="form-input mcp-json" placeholder="my-skill" autocomplete="off" />
|
|
1442
|
+
<small class="mcp-secret-note">Lowercase letters, digits, hyphens. Cannot be changed after creation.</small>
|
|
1443
|
+
</div>
|
|
1444
|
+
<div class="mcp-field">
|
|
1445
|
+
<span>Name</span>
|
|
1446
|
+
<input id="skill-dialog-name" class="form-input mcp-json" placeholder="my-skill" autocomplete="off" />
|
|
1447
|
+
</div>
|
|
1448
|
+
<div class="mcp-field">
|
|
1449
|
+
<span>Description</span>
|
|
1450
|
+
<input id="skill-dialog-description" class="form-input mcp-json" placeholder="Use when …" autocomplete="off" />
|
|
1451
|
+
</div>
|
|
1452
|
+
<div class="mcp-field">
|
|
1453
|
+
<span>Instructions (SKILL.md body)</span>
|
|
1454
|
+
<textarea id="skill-dialog-content" class="form-input mcp-json" spellcheck="false" rows="12" placeholder="# My skill Instructions here."></textarea>
|
|
1455
|
+
</div>
|
|
1456
|
+
<div id="skill-dialog-error" class="inline-result err" style="display:none"></div>
|
|
1457
|
+
<div class="mcp-dialog-actions">
|
|
1458
|
+
<button class="mcp-btn" type="button" onclick="closeSkillDialog()">Cancel</button>
|
|
1459
|
+
<button id="skill-dialog-submit" class="primary-action-btn" type="button" onclick="submitSkillDialog(this)">Save</button>
|
|
1460
|
+
</div>
|
|
1461
|
+
</dialog>`;
|
|
1462
|
+
function renderAdminPage(token) {
|
|
1463
|
+
const userLabel = token.platformUserName ?? token.platformUserId;
|
|
1464
|
+
const script = `
|
|
1465
|
+
const adminToken = ${JSON.stringify(token.token)};
|
|
1466
|
+
const defaultConversationKey = ${JSON.stringify(`${token.platform}:${token.conversationId}`)};
|
|
1467
|
+
${adminViewFunctionsScript}
|
|
1468
|
+
${adminViewStartupScript}`;
|
|
1469
|
+
return renderPortalShell({
|
|
1470
|
+
activeView: "admin",
|
|
1471
|
+
pageTitle: "Admin",
|
|
1472
|
+
identity: { primary: token.platform, secondary: userLabel },
|
|
1473
|
+
conversationSwitcher: { currentId: token.conversationId },
|
|
1474
|
+
body: adminViewBody,
|
|
1475
|
+
extraStyles: adminViewStyles,
|
|
1476
|
+
inlineScript: script,
|
|
1477
|
+
});
|
|
1478
|
+
}
|
|
1479
|
+
function renderAdminErrorPage(message) {
|
|
1480
|
+
return renderPortalShell({
|
|
1481
|
+
activeView: "admin",
|
|
1482
|
+
pageTitle: "Admin",
|
|
1483
|
+
body: `<section class="card" style="text-align:center;padding:40px 32px">
|
|
1484
|
+
<p class="eyebrow">${PRODUCT_NAME} admin</p>
|
|
1485
|
+
<h1 class="page-title" style="margin:12px 0 16px">Access Denied</h1>
|
|
1486
|
+
<div class="err-msg">${esc(message)}</div>
|
|
1487
|
+
</section>`,
|
|
1488
|
+
});
|
|
1489
|
+
}
|
|
1490
|
+
//# sourceMappingURL=portal.js.map
|