@geminixiang/mikan 1.0.0-beta.76 → 1.0.0-beta.78
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 +39 -0
- package/dist/adapters/commands/login.d.ts.map +1 -1
- package/dist/adapters/commands/login.js +0 -9
- package/dist/adapters/commands/login.js.map +1 -1
- package/dist/adapters/commands/manifest.d.ts +0 -19
- package/dist/adapters/commands/manifest.d.ts.map +1 -1
- package/dist/adapters/commands/manifest.js +0 -34
- package/dist/adapters/commands/manifest.js.map +1 -1
- package/dist/adapters/commands/model.d.ts +0 -5
- package/dist/adapters/commands/model.d.ts.map +1 -1
- package/dist/adapters/commands/model.js +0 -5
- package/dist/adapters/commands/model.js.map +1 -1
- package/dist/adapters/commands/new.d.ts.map +1 -1
- package/dist/adapters/commands/new.js +0 -2
- package/dist/adapters/commands/new.js.map +1 -1
- package/dist/adapters/commands/registry.d.ts +0 -1
- package/dist/adapters/commands/registry.d.ts.map +1 -1
- package/dist/adapters/commands/registry.js +0 -8
- package/dist/adapters/commands/registry.js.map +1 -1
- package/dist/adapters/commands/session-view.d.ts.map +1 -1
- package/dist/adapters/commands/session-view.js +0 -2
- package/dist/adapters/commands/session-view.js.map +1 -1
- package/dist/adapters/commands/types.d.ts +0 -29
- package/dist/adapters/commands/types.d.ts.map +1 -1
- package/dist/adapters/commands/types.js.map +1 -1
- package/dist/adapters/commands/utils.d.ts +0 -3
- package/dist/adapters/commands/utils.d.ts.map +1 -1
- package/dist/adapters/commands/utils.js +0 -3
- package/dist/adapters/commands/utils.js.map +1 -1
- package/dist/adapters/discord/bot.d.ts +0 -4
- package/dist/adapters/discord/bot.d.ts.map +1 -1
- package/dist/adapters/discord/bot.js +5 -41
- package/dist/adapters/discord/bot.js.map +1 -1
- package/dist/adapters/discord/components.d.ts +0 -23
- package/dist/adapters/discord/components.d.ts.map +1 -1
- package/dist/adapters/discord/components.js +0 -23
- package/dist/adapters/discord/components.js.map +1 -1
- package/dist/adapters/discord/context.d.ts.map +1 -1
- package/dist/adapters/discord/context.js +1 -11
- package/dist/adapters/discord/context.js.map +1 -1
- package/dist/adapters/discord/format.d.ts +0 -1
- package/dist/adapters/discord/format.d.ts.map +1 -1
- package/dist/adapters/discord/format.js +0 -37
- package/dist/adapters/discord/format.js.map +1 -1
- package/dist/adapters/github/bot.d.ts +0 -44
- package/dist/adapters/github/bot.d.ts.map +1 -1
- package/dist/adapters/github/bot.js +1 -120
- package/dist/adapters/github/bot.js.map +1 -1
- package/dist/adapters/github/client.d.ts +0 -57
- package/dist/adapters/github/client.d.ts.map +1 -1
- package/dist/adapters/github/client.js +0 -59
- package/dist/adapters/github/client.js.map +1 -1
- package/dist/adapters/github/context.d.ts.map +1 -1
- package/dist/adapters/github/context.js +1 -8
- package/dist/adapters/github/context.js.map +1 -1
- package/dist/adapters/github/github-ops.d.ts +0 -55
- package/dist/adapters/github/github-ops.d.ts.map +1 -1
- package/dist/adapters/github/github-ops.js +0 -59
- package/dist/adapters/github/github-ops.js.map +1 -1
- package/dist/adapters/github/ids.d.ts +0 -27
- package/dist/adapters/github/ids.d.ts.map +1 -1
- package/dist/adapters/github/ids.js +0 -29
- package/dist/adapters/github/ids.js.map +1 -1
- package/dist/adapters/github/repo.d.ts +0 -25
- package/dist/adapters/github/repo.d.ts.map +1 -1
- package/dist/adapters/github/repo.js +0 -49
- package/dist/adapters/github/repo.js.map +1 -1
- package/dist/adapters/github/tool-pack.d.ts +0 -10
- package/dist/adapters/github/tool-pack.d.ts.map +1 -1
- package/dist/adapters/github/tool-pack.js +0 -10
- package/dist/adapters/github/tool-pack.js.map +1 -1
- package/dist/adapters/github/tools/checks.d.ts +0 -6
- package/dist/adapters/github/tools/checks.d.ts.map +1 -1
- package/dist/adapters/github/tools/checks.js +0 -7
- package/dist/adapters/github/tools/checks.js.map +1 -1
- package/dist/adapters/github/tools/issue.d.ts +0 -5
- package/dist/adapters/github/tools/issue.d.ts.map +1 -1
- package/dist/adapters/github/tools/issue.js +0 -5
- package/dist/adapters/github/tools/issue.js.map +1 -1
- package/dist/adapters/github/tools/pr.d.ts +0 -7
- package/dist/adapters/github/tools/pr.d.ts.map +1 -1
- package/dist/adapters/github/tools/pr.js +0 -7
- package/dist/adapters/github/tools/pr.js.map +1 -1
- package/dist/adapters/github/tools/read.d.ts +0 -6
- package/dist/adapters/github/tools/read.d.ts.map +1 -1
- package/dist/adapters/github/tools/read.js +0 -8
- package/dist/adapters/github/tools/read.js.map +1 -1
- package/dist/adapters/github/tools/review-reply.d.ts +0 -5
- package/dist/adapters/github/tools/review-reply.d.ts.map +1 -1
- package/dist/adapters/github/tools/review-reply.js +0 -5
- package/dist/adapters/github/tools/review-reply.js.map +1 -1
- package/dist/adapters/github/tools/sync.d.ts +0 -6
- package/dist/adapters/github/tools/sync.d.ts.map +1 -1
- package/dist/adapters/github/tools/sync.js +0 -6
- package/dist/adapters/github/tools/sync.js.map +1 -1
- package/dist/adapters/github/types.d.ts +0 -88
- 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 +0 -13
- package/dist/adapters/github/webhook.d.ts.map +1 -1
- package/dist/adapters/github/webhook.js +0 -16
- package/dist/adapters/github/webhook.js.map +1 -1
- package/dist/adapters/index.d.ts +3 -4
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/adapters/index.js +4 -4
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/intake.d.ts +0 -17
- package/dist/adapters/intake.d.ts.map +1 -1
- package/dist/adapters/intake.js +6 -32
- package/dist/adapters/intake.js.map +1 -1
- package/dist/adapters/markdown-tables.d.ts +0 -10
- package/dist/adapters/markdown-tables.d.ts.map +1 -1
- package/dist/adapters/markdown-tables.js +1 -42
- package/dist/adapters/markdown-tables.js.map +1 -1
- package/dist/adapters/progressive-renderer.d.ts.map +1 -1
- package/dist/adapters/progressive-renderer.js +3 -25
- package/dist/adapters/progressive-renderer.js.map +1 -1
- package/dist/adapters/shared.d.ts +0 -57
- package/dist/adapters/shared.d.ts.map +1 -1
- package/dist/adapters/shared.js +0 -71
- package/dist/adapters/shared.js.map +1 -1
- package/dist/adapters/slack/assistant.d.ts +0 -49
- package/dist/adapters/slack/assistant.d.ts.map +1 -1
- package/dist/adapters/slack/assistant.js +0 -97
- package/dist/adapters/slack/assistant.js.map +1 -1
- package/dist/adapters/slack/auto-reply-context.d.ts +0 -7
- package/dist/adapters/slack/auto-reply-context.d.ts.map +1 -1
- package/dist/adapters/slack/auto-reply-context.js +0 -7
- package/dist/adapters/slack/auto-reply-context.js.map +1 -1
- package/dist/adapters/slack/blocks.d.ts +0 -9
- package/dist/adapters/slack/blocks.d.ts.map +1 -1
- package/dist/adapters/slack/blocks.js +0 -20
- package/dist/adapters/slack/blocks.js.map +1 -1
- package/dist/adapters/slack/bot.d.ts +0 -116
- package/dist/adapters/slack/bot.d.ts.map +1 -1
- package/dist/adapters/slack/bot.js +7 -231
- package/dist/adapters/slack/bot.js.map +1 -1
- package/dist/adapters/slack/context.d.ts.map +1 -1
- package/dist/adapters/slack/context.js +1 -3
- package/dist/adapters/slack/context.js.map +1 -1
- package/dist/adapters/slack/jev-context.d.ts +0 -13
- package/dist/adapters/slack/jev-context.d.ts.map +1 -1
- package/dist/adapters/slack/jev-context.js +0 -12
- package/dist/adapters/slack/jev-context.js.map +1 -1
- package/dist/adapters/slack/markdown.d.ts +0 -1
- package/dist/adapters/slack/markdown.d.ts.map +1 -1
- package/dist/adapters/slack/markdown.js +0 -5
- package/dist/adapters/slack/markdown.js.map +1 -1
- package/dist/adapters/slack/persona.d.ts +0 -9
- package/dist/adapters/slack/persona.d.ts.map +1 -1
- package/dist/adapters/slack/persona.js +0 -9
- package/dist/adapters/slack/persona.js.map +1 -1
- package/dist/adapters/slack/response-lifecycle.d.ts.map +1 -1
- package/dist/adapters/slack/response-lifecycle.js +1 -45
- package/dist/adapters/slack/response-lifecycle.js.map +1 -1
- package/dist/adapters/slack/session.d.ts +2 -1
- package/dist/adapters/slack/session.d.ts.map +1 -1
- package/dist/adapters/slack/session.js +2 -2
- package/dist/adapters/slack/session.js.map +1 -1
- package/dist/adapters/slack/stream-limits.d.ts +0 -25
- package/dist/adapters/slack/stream-limits.d.ts.map +1 -1
- package/dist/adapters/slack/stream-limits.js +0 -34
- package/dist/adapters/slack/stream-limits.js.map +1 -1
- package/dist/adapters/slack/task-intent.d.ts +0 -13
- package/dist/adapters/slack/task-intent.d.ts.map +1 -1
- package/dist/adapters/slack/task-intent.js +0 -7
- package/dist/adapters/slack/task-intent.js.map +1 -1
- package/dist/adapters/slack/task-status.d.ts +0 -1
- package/dist/adapters/slack/task-status.d.ts.map +1 -1
- package/dist/adapters/slack/task-status.js +1 -9
- package/dist/adapters/slack/task-status.js.map +1 -1
- package/dist/adapters/slack/tool-pack.d.ts +0 -6
- package/dist/adapters/slack/tool-pack.d.ts.map +1 -1
- package/dist/adapters/slack/tool-pack.js +0 -6
- package/dist/adapters/slack/tool-pack.js.map +1 -1
- package/dist/adapters/slack/tools/blockkit.d.ts.map +1 -1
- package/dist/adapters/slack/tools/blockkit.js +0 -11
- package/dist/adapters/slack/tools/blockkit.js.map +1 -1
- package/dist/adapters/slack/types.d.ts +0 -19
- 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 +0 -1
- package/dist/adapters/slack/update-diagnostics.d.ts.map +1 -1
- package/dist/adapters/slack/update-diagnostics.js +1 -7
- package/dist/adapters/slack/update-diagnostics.js.map +1 -1
- package/dist/adapters/telegram/bot.d.ts +0 -6
- package/dist/adapters/telegram/bot.d.ts.map +1 -1
- package/dist/adapters/telegram/bot.js +1 -50
- package/dist/adapters/telegram/bot.js.map +1 -1
- package/dist/adapters/telegram/context.d.ts.map +1 -1
- package/dist/adapters/telegram/context.js +1 -8
- package/dist/adapters/telegram/context.js.map +1 -1
- package/dist/adapters/types.d.ts +0 -57
- 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 +1765 -0
- package/dist/adapters/web/admin/client-assets.js.map +1 -0
- package/dist/adapters/web/admin/portal.d.ts +0 -10
- package/dist/adapters/web/admin/portal.d.ts.map +1 -1
- package/dist/adapters/web/admin/portal.js +6 -1909
- package/dist/adapters/web/admin/portal.js.map +1 -1
- package/dist/adapters/web/admin/types.d.ts +0 -3
- package/dist/adapters/web/admin/types.d.ts.map +1 -1
- package/dist/adapters/web/admin/types.js.map +1 -1
- package/dist/adapters/web/login/oauth.d.ts.map +1 -1
- package/dist/adapters/web/login/oauth.js +3 -7
- package/dist/adapters/web/login/oauth.js.map +1 -1
- package/dist/adapters/web/login/portal.d.ts +0 -10
- package/dist/adapters/web/login/portal.d.ts.map +1 -1
- package/dist/adapters/web/login/portal.js +4 -37
- package/dist/adapters/web/login/portal.js.map +1 -1
- package/dist/adapters/web/login/types.d.ts +0 -5
- package/dist/adapters/web/login/types.d.ts.map +1 -1
- package/dist/adapters/web/login/types.js.map +1 -1
- package/dist/adapters/web/portal-shell.d.ts +0 -12
- package/dist/adapters/web/portal-shell.d.ts.map +1 -1
- package/dist/adapters/web/portal-shell.js +8 -25
- package/dist/adapters/web/portal-shell.js.map +1 -1
- package/dist/adapters/web/server.d.ts +0 -1
- package/dist/adapters/web/server.d.ts.map +1 -1
- package/dist/adapters/web/server.js +0 -2
- package/dist/adapters/web/server.js.map +1 -1
- package/dist/adapters/web/session-view/portal.d.ts.map +1 -1
- package/dist/adapters/web/session-view/portal.js +13 -24
- package/dist/adapters/web/session-view/portal.js.map +1 -1
- package/dist/adapters/web/session-view/types.d.ts.map +1 -1
- package/dist/adapters/web/session-view/types.js.map +1 -1
- package/dist/adapters/web/token-store.d.ts +0 -2
- package/dist/adapters/web/token-store.d.ts.map +1 -1
- package/dist/adapters/web/token-store.js +0 -2
- package/dist/adapters/web/token-store.js.map +1 -1
- package/dist/cli/arg-grammar.d.ts +0 -3
- package/dist/cli/arg-grammar.d.ts.map +1 -1
- package/dist/cli/arg-grammar.js +0 -3
- package/dist/cli/arg-grammar.js.map +1 -1
- package/dist/cli/boot.d.ts.map +1 -1
- package/dist/cli/boot.js +3 -12
- package/dist/cli/boot.js.map +1 -1
- package/dist/cli/download.d.ts.map +1 -1
- package/dist/cli/download.js +2 -6
- package/dist/cli/download.js.map +1 -1
- package/dist/cli/office.d.ts.map +1 -1
- package/dist/cli/office.js +0 -31
- package/dist/cli/office.js.map +1 -1
- package/dist/cli/onboard.d.ts +0 -2
- package/dist/cli/onboard.d.ts.map +1 -1
- package/dist/cli/onboard.js +0 -30
- package/dist/cli/onboard.js.map +1 -1
- package/dist/cli/process-lifecycle.d.ts +0 -5
- package/dist/cli/process-lifecycle.d.ts.map +1 -1
- package/dist/cli/process-lifecycle.js +0 -6
- package/dist/cli/process-lifecycle.js.map +1 -1
- package/dist/cli/sandbox.d.ts +3 -0
- package/dist/cli/sandbox.d.ts.map +1 -0
- package/dist/cli/sandbox.js +79 -0
- package/dist/cli/sandbox.js.map +1 -0
- package/dist/cli/sessions.d.ts.map +1 -1
- package/dist/cli/sessions.js +0 -11
- package/dist/cli/sessions.js.map +1 -1
- package/dist/cli/types.d.ts +2 -6
- package/dist/cli/types.d.ts.map +1 -1
- package/dist/cli/types.js.map +1 -1
- package/dist/env-manifest.d.ts +0 -21
- package/dist/env-manifest.d.ts.map +1 -1
- package/dist/env-manifest.js +0 -11
- package/dist/env-manifest.js.map +1 -1
- package/dist/events/index.d.ts +0 -51
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +0 -42
- package/dist/events/index.js.map +1 -1
- package/dist/events/scheduler.d.ts +0 -8
- package/dist/events/scheduler.d.ts.map +1 -1
- package/dist/events/scheduler.js +0 -8
- package/dist/events/scheduler.js.map +1 -1
- package/dist/file-guards.d.ts +0 -15
- package/dist/file-guards.d.ts.map +1 -1
- package/dist/file-guards.js +2 -26
- package/dist/file-guards.js.map +1 -1
- package/dist/harness/execution-env.d.ts +0 -15
- package/dist/harness/execution-env.d.ts.map +1 -1
- package/dist/harness/execution-env.js +4 -55
- package/dist/harness/execution-env.js.map +1 -1
- 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 +4 -7
- package/dist/harness/index.d.ts.map +1 -1
- package/dist/harness/index.js +4 -7
- package/dist/harness/index.js.map +1 -1
- package/dist/harness/jev.d.ts +0 -28
- package/dist/harness/jev.d.ts.map +1 -1
- package/dist/harness/jev.js +0 -45
- package/dist/harness/jev.js.map +1 -1
- package/dist/harness/mcp-result.d.ts +20 -0
- package/dist/harness/mcp-result.d.ts.map +1 -0
- package/dist/harness/mcp-result.js +171 -0
- package/dist/harness/mcp-result.js.map +1 -0
- package/dist/harness/mcp.d.ts +0 -19
- package/dist/harness/mcp.d.ts.map +1 -1
- package/dist/harness/mcp.js +7 -66
- package/dist/harness/mcp.js.map +1 -1
- package/dist/harness/models.d.ts +0 -19
- package/dist/harness/models.d.ts.map +1 -1
- package/dist/harness/models.js +0 -52
- package/dist/harness/models.js.map +1 -1
- package/dist/harness/open-connector.d.ts +0 -12
- package/dist/harness/open-connector.d.ts.map +1 -1
- package/dist/harness/open-connector.js +0 -22
- package/dist/harness/open-connector.js.map +1 -1
- package/dist/harness/presenter.d.ts +1 -0
- package/dist/harness/presenter.d.ts.map +1 -1
- package/dist/harness/presenter.js +16 -66
- package/dist/harness/presenter.js.map +1 -1
- package/dist/harness/prompt.d.ts +0 -11
- package/dist/harness/prompt.d.ts.map +1 -1
- package/dist/harness/prompt.js +1 -18
- package/dist/harness/prompt.js.map +1 -1
- package/dist/harness/runner.d.ts.map +1 -1
- package/dist/harness/runner.js +8 -28
- package/dist/harness/runner.js.map +1 -1
- package/dist/harness/session.d.ts +11 -28
- package/dist/harness/session.d.ts.map +1 -1
- package/dist/harness/session.js +100 -38
- package/dist/harness/session.js.map +1 -1
- package/dist/harness/skills.d.ts +0 -22
- package/dist/harness/skills.d.ts.map +1 -1
- package/dist/harness/skills.js +0 -20
- package/dist/harness/skills.js.map +1 -1
- package/dist/harness/subagent-profiles.d.ts +0 -4
- package/dist/harness/subagent-profiles.d.ts.map +1 -1
- package/dist/harness/subagent-profiles.js +0 -29
- package/dist/harness/subagent-profiles.js.map +1 -1
- package/dist/harness/subagent.d.ts +0 -25
- package/dist/harness/subagent.d.ts.map +1 -1
- package/dist/harness/subagent.js +1 -70
- package/dist/harness/subagent.js.map +1 -1
- package/dist/harness/tools/event.d.ts.map +1 -1
- package/dist/harness/tools/event.js +0 -9
- package/dist/harness/tools/event.js.map +1 -1
- package/dist/harness/tools/generate-image.d.ts +0 -6
- package/dist/harness/tools/generate-image.d.ts.map +1 -1
- package/dist/harness/tools/generate-image.js.map +1 -1
- package/dist/harness/tools/host-fn-tool.d.ts +0 -17
- package/dist/harness/tools/host-fn-tool.d.ts.map +1 -1
- package/dist/harness/tools/host-fn-tool.js +0 -16
- package/dist/harness/tools/host-fn-tool.js.map +1 -1
- package/dist/harness/tools/index.d.ts +1 -7
- package/dist/harness/tools/index.d.ts.map +1 -1
- package/dist/harness/tools/index.js +3 -14
- package/dist/harness/tools/index.js.map +1 -1
- package/dist/harness/tools/jev-browser.d.ts +4 -94
- package/dist/harness/tools/jev-browser.d.ts.map +1 -1
- package/dist/harness/tools/jev-browser.js +203 -92
- package/dist/harness/tools/jev-browser.js.map +1 -1
- package/dist/harness/tools/jev.d.ts +0 -8
- package/dist/harness/tools/jev.d.ts.map +1 -1
- package/dist/harness/tools/jev.js +0 -11
- package/dist/harness/tools/jev.js.map +1 -1
- package/dist/harness/tools/pi-tools.d.ts +1 -11
- package/dist/harness/tools/pi-tools.d.ts.map +1 -1
- package/dist/harness/tools/pi-tools.js +1 -30
- package/dist/harness/tools/pi-tools.js.map +1 -1
- package/dist/harness/tools/react.d.ts +0 -5
- package/dist/harness/tools/react.d.ts.map +1 -1
- package/dist/harness/tools/react.js +0 -5
- package/dist/harness/tools/react.js.map +1 -1
- package/dist/harness/tools/secret-redaction.d.ts +0 -25
- package/dist/harness/tools/secret-redaction.d.ts.map +1 -1
- package/dist/harness/tools/secret-redaction.js +3 -36
- package/dist/harness/tools/secret-redaction.js.map +1 -1
- package/dist/harness/tools/subagent.d.ts +0 -34
- package/dist/harness/tools/subagent.d.ts.map +1 -1
- package/dist/harness/tools/subagent.js +0 -92
- package/dist/harness/tools/subagent.js.map +1 -1
- package/dist/harness/tools/task.d.ts +0 -1
- package/dist/harness/tools/task.d.ts.map +1 -1
- package/dist/harness/tools/task.js +0 -1
- package/dist/harness/tools/task.js.map +1 -1
- package/dist/harness/tools/types.d.ts +0 -16
- package/dist/harness/tools/types.d.ts.map +1 -1
- package/dist/harness/tools/types.js.map +1 -1
- package/dist/harness/types.d.ts +1 -77
- package/dist/harness/types.d.ts.map +1 -1
- package/dist/harness/types.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/log.d.ts.map +1 -1
- package/dist/log.js +0 -13
- package/dist/log.js.map +1 -1
- package/dist/main.js +7 -52
- package/dist/main.js.map +1 -1
- package/dist/memory-capture/index.d.ts +16 -0
- package/dist/memory-capture/index.d.ts.map +1 -0
- package/dist/memory-capture/index.js +194 -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.map +1 -0
- package/dist/observability/index.d.ts +0 -9
- package/dist/observability/index.d.ts.map +1 -1
- package/dist/observability/index.js +0 -9
- package/dist/observability/index.js.map +1 -1
- package/dist/observability/instrument.js +0 -5
- package/dist/observability/instrument.js.map +1 -1
- package/dist/observability/otel.js +0 -1
- package/dist/observability/otel.js.map +1 -1
- package/dist/observability/sentry.d.ts +0 -18
- package/dist/observability/sentry.d.ts.map +1 -1
- package/dist/observability/sentry.js +0 -36
- package/dist/observability/sentry.js.map +1 -1
- package/dist/observability/types.d.ts +1 -10
- package/dist/observability/types.d.ts.map +1 -1
- package/dist/observability/types.js.map +1 -1
- package/dist/office/index.d.ts +0 -76
- package/dist/office/index.d.ts.map +1 -1
- package/dist/office/index.js +4 -154
- package/dist/office/index.js.map +1 -1
- package/dist/office/projection.d.ts +0 -29
- package/dist/office/projection.d.ts.map +1 -1
- package/dist/office/projection.js +5 -41
- package/dist/office/projection.js.map +1 -1
- package/dist/office/types.d.ts +0 -66
- package/dist/office/types.d.ts.map +1 -1
- package/dist/office/types.js.map +1 -1
- package/dist/runtime/conversation-runtime.d.ts.map +1 -1
- package/dist/runtime/conversation-runtime.js +22 -83
- package/dist/runtime/conversation-runtime.js.map +1 -1
- package/dist/runtime/session-lifecycle.d.ts +0 -10
- package/dist/runtime/session-lifecycle.d.ts.map +1 -1
- package/dist/runtime/session-lifecycle.js +0 -12
- package/dist/runtime/session-lifecycle.js.map +1 -1
- package/dist/runtime/types.d.ts +2 -29
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/runtime/types.js.map +1 -1
- package/dist/sandbox/cloudflare.d.ts.map +1 -1
- package/dist/sandbox/cloudflare.js +2 -1
- package/dist/sandbox/cloudflare.js.map +1 -1
- package/dist/sandbox/container.d.ts.map +1 -1
- package/dist/sandbox/container.js +21 -15
- package/dist/sandbox/container.js.map +1 -1
- package/dist/sandbox/host.d.ts.map +1 -1
- package/dist/sandbox/host.js +0 -2
- package/dist/sandbox/host.js.map +1 -1
- package/dist/sandbox/identity.d.ts +0 -28
- package/dist/sandbox/identity.d.ts.map +1 -1
- package/dist/sandbox/identity.js +0 -28
- package/dist/sandbox/identity.js.map +1 -1
- package/dist/sandbox/index.d.ts +0 -18
- package/dist/sandbox/index.d.ts.map +1 -1
- package/dist/sandbox/index.js +2 -19
- package/dist/sandbox/index.js.map +1 -1
- package/dist/sandbox/layout.d.ts +7 -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 +24 -65
- package/dist/sandbox/provisioner.d.ts.map +1 -1
- package/dist/sandbox/provisioner.js +213 -125
- package/dist/sandbox/provisioner.js.map +1 -1
- package/dist/sandbox/types.d.ts +0 -39
- package/dist/sandbox/types.d.ts.map +1 -1
- package/dist/sandbox/types.js.map +1 -1
- package/dist/sandbox/utils.d.ts +2 -5
- package/dist/sandbox/utils.d.ts.map +1 -1
- package/dist/sandbox/utils.js +31 -31
- package/dist/sandbox/utils.js.map +1 -1
- package/dist/sessions/chat-history-sync.d.ts +0 -6
- package/dist/sessions/chat-history-sync.d.ts.map +1 -1
- package/dist/sessions/chat-history-sync.js +1 -33
- package/dist/sessions/chat-history-sync.js.map +1 -1
- package/dist/sessions/history-line.d.ts +0 -20
- package/dist/sessions/history-line.d.ts.map +1 -1
- package/dist/sessions/history-line.js +0 -20
- package/dist/sessions/history-line.js.map +1 -1
- package/dist/sessions/migrate-common.d.ts +0 -15
- package/dist/sessions/migrate-common.d.ts.map +1 -1
- package/dist/sessions/migrate-common.js +0 -19
- package/dist/sessions/migrate-common.js.map +1 -1
- package/dist/sessions/migrate-pi-084.d.ts.map +1 -1
- package/dist/sessions/migrate-pi-084.js +0 -7
- package/dist/sessions/migrate-pi-084.js.map +1 -1
- package/dist/sessions/migrate-v3.d.ts +0 -7
- package/dist/sessions/migrate-v3.d.ts.map +1 -1
- package/dist/sessions/migrate-v3.js +1 -67
- package/dist/sessions/migrate-v3.js.map +1 -1
- package/dist/sessions/session-key.d.ts +3 -17
- package/dist/sessions/session-key.d.ts.map +1 -1
- package/dist/sessions/session-key.js +8 -35
- package/dist/sessions/session-key.js.map +1 -1
- package/dist/sessions/session-store.d.ts +1 -7
- package/dist/sessions/session-store.d.ts.map +1 -1
- package/dist/sessions/session-store.js +8 -50
- package/dist/sessions/session-store.js.map +1 -1
- package/dist/sessions/store.d.ts +0 -60
- package/dist/sessions/store.d.ts.map +1 -1
- package/dist/sessions/store.js +0 -113
- package/dist/sessions/store.js.map +1 -1
- package/dist/sessions/types.d.ts +0 -17
- package/dist/sessions/types.d.ts.map +1 -1
- package/dist/sessions/types.js.map +1 -1
- package/dist/settings/apply.d.ts +0 -6
- package/dist/settings/apply.d.ts.map +1 -1
- package/dist/settings/apply.js +0 -29
- package/dist/settings/apply.js.map +1 -1
- package/dist/settings/index.d.ts +0 -53
- package/dist/settings/index.d.ts.map +1 -1
- package/dist/settings/index.js +0 -77
- package/dist/settings/index.js.map +1 -1
- package/dist/settings/migrate.d.ts +0 -5
- package/dist/settings/migrate.d.ts.map +1 -1
- package/dist/settings/migrate.js +0 -17
- package/dist/settings/migrate.js.map +1 -1
- package/dist/types.d.ts +9 -159
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/vault/index.d.ts +2 -36
- package/dist/vault/index.d.ts.map +1 -1
- package/dist/vault/index.js +135 -65
- package/dist/vault/index.js.map +1 -1
- package/dist/vault/types.d.ts +0 -15
- package/dist/vault/types.d.ts.map +1 -1
- package/dist/vault/types.js.map +1 -1
- package/package.json +1 -1
- package/dist/dream/index.d.ts +0 -20
- package/dist/dream/index.d.ts.map +0 -1
- package/dist/dream/index.js +0 -264
- package/dist/dream/index.js.map +0 -1
- package/dist/dream/types.d.ts +0 -30
- package/dist/dream/types.d.ts.map +0 -1
- package/dist/dream/types.js.map +0 -1
- /package/dist/{dream → memory-capture}/types.js +0 -0
package/dist/harness/skills.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { existsSync, lstatSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
2
2
|
import { basename, dirname, join } from "node:path";
|
|
3
3
|
import * as log from "../log.js";
|
|
4
|
-
/** Register skills under their prompt-side paths; a later source overrides an earlier one. */
|
|
5
4
|
function addSkills(skillMap, skills, rewritePath) {
|
|
6
5
|
for (const skill of skills) {
|
|
7
6
|
skill.filePath = rewritePath(skill.filePath);
|
|
@@ -9,7 +8,6 @@ function addSkills(skillMap, skills, rewritePath) {
|
|
|
9
8
|
skillMap.set(skill.name, skill);
|
|
10
9
|
}
|
|
11
10
|
}
|
|
12
|
-
/** Conversation skill entries that are symlinks are refused, and reported to the prompt. */
|
|
13
11
|
function skippedSymlinkPaths(diagnostics, translatePath) {
|
|
14
12
|
const skipped = [];
|
|
15
13
|
for (const diagnostic of diagnostics) {
|
|
@@ -22,8 +20,6 @@ function skippedSymlinkPaths(diagnostics, translatePath) {
|
|
|
22
20
|
}
|
|
23
21
|
export function loadMikanSkills(office, workspacePath, projection) {
|
|
24
22
|
const skillMap = new Map();
|
|
25
|
-
// workspacePath is the runtime-side root (e.g. /workspace); host paths under
|
|
26
|
-
// the workspace root translate onto it for prompt references.
|
|
27
23
|
const hostWorkspacePath = office.workspace.root;
|
|
28
24
|
const translatePath = (hostPath) => hostPath.startsWith(hostWorkspacePath)
|
|
29
25
|
? workspacePath + hostPath.slice(hostWorkspacePath.length)
|
|
@@ -44,10 +40,6 @@ export function loadMikanSkills(office, workspacePath, projection) {
|
|
|
44
40
|
}
|
|
45
41
|
const MAX_NAME_LENGTH = 64;
|
|
46
42
|
const MAX_DESCRIPTION_LENGTH = 1024;
|
|
47
|
-
/**
|
|
48
|
-
* Parse simple `key: value` YAML frontmatter delimited by `---` lines.
|
|
49
|
-
* Quoted values are unquoted; nested structures are not supported.
|
|
50
|
-
*/
|
|
51
43
|
export function parseFrontmatter(content) {
|
|
52
44
|
const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?/);
|
|
53
45
|
if (!match)
|
|
@@ -69,7 +61,6 @@ export function parseFrontmatter(content) {
|
|
|
69
61
|
}
|
|
70
62
|
return { values, body: content.slice(match[0].length) };
|
|
71
63
|
}
|
|
72
|
-
/** Exposed so the admin portal can validate a skill draft before writing it. */
|
|
73
64
|
export function validateSkill(name, description) {
|
|
74
65
|
const errors = [];
|
|
75
66
|
if (name.length > MAX_NAME_LENGTH) {
|
|
@@ -125,12 +116,6 @@ function loadSkillFromFile(filePath, source) {
|
|
|
125
116
|
return { skills: [], diagnostics };
|
|
126
117
|
}
|
|
127
118
|
}
|
|
128
|
-
/**
|
|
129
|
-
* Load skills from a directory tree.
|
|
130
|
-
* - A directory containing `SKILL.md` is a skill root; no further recursion.
|
|
131
|
-
* - Direct `.md` children of the top-level directory load as skills.
|
|
132
|
-
* - Dot-directories and `node_modules` are skipped.
|
|
133
|
-
*/
|
|
134
119
|
export function loadSkillsFromDir(options) {
|
|
135
120
|
const rejectSymlinks = options.rejectSymlinks === true;
|
|
136
121
|
if (rejectSymlinks && isSymlink(options.dir)) {
|
|
@@ -235,10 +220,6 @@ function escapeXml(str) {
|
|
|
235
220
|
.replace(/"/g, """)
|
|
236
221
|
.replace(/'/g, "'");
|
|
237
222
|
}
|
|
238
|
-
/**
|
|
239
|
-
* Format skills for a system prompt using the Agent Skills XML block.
|
|
240
|
-
* Skills with `disableModelInvocation` are excluded.
|
|
241
|
-
*/
|
|
242
223
|
export function formatSkillsForPrompt(skills) {
|
|
243
224
|
const visible = skills.filter((skill) => !skill.disableModelInvocation);
|
|
244
225
|
if (visible.length === 0)
|
|
@@ -255,7 +236,6 @@ export function formatSkillsForPrompt(skills) {
|
|
|
255
236
|
lines.push(` <name>${escapeXml(skill.name)}</name>`);
|
|
256
237
|
lines.push(` <description>${escapeXml(skill.description)}</description>`);
|
|
257
238
|
if (skill.inline) {
|
|
258
|
-
// Inline skills carry their body: the agent cannot read their file.
|
|
259
239
|
lines.push(` <instructions>${escapeXml(skill.content)}</instructions>`);
|
|
260
240
|
}
|
|
261
241
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skills.js","sourceRoot":"","sources":["../../src/harness/skills.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,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AAK,CAAC,IAAI,CAAC,aAAa,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACxD,KAAK,CAAC,IAAI,CAAC,oBAAoB,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;QAC7E,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;YACjB,oEAAoE;YACpE,KAAK,CAAC,IAAI,CAAC,qBAAqB,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;QAC7E,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,IAAI,CAAC,iBAAiB,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;QACtE,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC3B,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IAClC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC","sourcesContent":["import type { Office } from \"../office/index.js\";\nimport type { MikanSkill, SkillDiagnostic, LoadSkillsResult } from \"./types.js\";\nimport type { WorkspaceProjection } from \"../office/types.js\";\nimport { existsSync, lstatSync, readdirSync, readFileSync, statSync } from \"node:fs\";\nimport { basename, dirname, join } from \"node:path\";\n\nimport * as log from \"../log.js\";\n\n/** Register skills under their prompt-side paths; a later source overrides an earlier one. */\nfunction addSkills(\n skillMap: Map<string, MikanSkill>,\n skills: MikanSkill[],\n rewritePath: (path: string) => string,\n): void {\n for (const skill of skills) {\n skill.filePath = rewritePath(skill.filePath);\n skill.baseDir = rewritePath(skill.baseDir);\n skillMap.set(skill.name, skill);\n }\n}\n\n/** Conversation skill entries that are symlinks are refused, and reported to the prompt. */\nfunction skippedSymlinkPaths(\n diagnostics: SkillDiagnostic[],\n translatePath: (path: string) => string,\n): string[] {\n const skipped: string[] = [];\n for (const diagnostic of diagnostics) {\n if (diagnostic.code !== \"symlink\") continue;\n log.logWarning(\"Skipping conversation skill entry (symlink)\", diagnostic.path);\n skipped.push(translatePath(diagnostic.path));\n }\n return skipped;\n}\n\nexport function loadMikanSkills(\n office: Office,\n workspacePath: string,\n projection: WorkspaceProjection,\n): { skills: MikanSkill[]; skippedSkillLinks: string[] } {\n const skillMap = new Map<string, MikanSkill>();\n\n // workspacePath is the runtime-side root (e.g. /workspace); host paths under\n // the workspace root translate onto it for prompt references.\n const hostWorkspacePath = office.workspace.root;\n const translatePath = (hostPath: string): string =>\n hostPath.startsWith(hostWorkspacePath)\n ? workspacePath + hostPath.slice(hostWorkspacePath.length)\n : hostPath;\n\n const workspaceSkillsDir = projection.promptSources.globalSkillsDir;\n if (workspaceSkillsDir) {\n const loaded = loadSkillsFromDir({ dir: workspaceSkillsDir, source: \"workspace\" });\n addSkills(skillMap, loaded.skills, translatePath);\n }\n\n const conversationSkills = loadSkillsFromDir({\n dir: projection.promptSources.conversationSkillsDir,\n source: \"channel\",\n rejectSymlinks: true,\n });\n const skippedSkillLinks = skippedSymlinkPaths(conversationSkills.diagnostics, translatePath);\n addSkills(skillMap, conversationSkills.skills, translatePath);\n\n return { skills: Array.from(skillMap.values()), skippedSkillLinks };\n}\nexport type { LoadSkillsResult } from \"./types.js\";\nexport type { MikanSkill } from \"./types.js\";\nexport type { SkillDiagnostic } from \"./types.js\";\n\nconst MAX_NAME_LENGTH = 64;\n\nconst MAX_DESCRIPTION_LENGTH = 1024;\n\ninterface Frontmatter {\n values: Record<string, string>;\n body: string;\n}\n\n/**\n * Parse simple `key: value` YAML frontmatter delimited by `---` lines.\n * Quoted values are unquoted; nested structures are not supported.\n */\nexport function parseFrontmatter(content: string): Frontmatter {\n const match = content.match(/^---\\r?\\n([\\s\\S]*?)\\r?\\n---\\r?\\n?/);\n if (!match) return { values: {}, body: content };\n\n const values: Record<string, string> = {};\n for (const line of (match[1] ?? \"\").split(/\\r?\\n/)) {\n const separator = line.indexOf(\":\");\n if (separator === -1) continue;\n const key = line.slice(0, separator).trim();\n if (!key) continue;\n let value = line.slice(separator + 1).trim();\n if (\n (value.startsWith('\"') && value.endsWith('\"')) ||\n (value.startsWith(\"'\") && value.endsWith(\"'\"))\n ) {\n value = value.slice(1, -1);\n }\n values[key] = value;\n }\n return { values, body: content.slice(match[0].length) };\n}\n\n/** Exposed so the admin portal can validate a skill draft before writing it. */\nexport function validateSkill(name: string, description: string): string[] {\n const errors: string[] = [];\n if (name.length > MAX_NAME_LENGTH) {\n errors.push(`name exceeds ${MAX_NAME_LENGTH} characters (${name.length})`);\n }\n if (\n !/^[a-z0-9-]+$/.test(name) ||\n name.startsWith(\"-\") ||\n name.endsWith(\"-\") ||\n name.includes(\"--\")\n ) {\n errors.push(\"name must be lowercase a-z, 0-9 and single hyphens, not at the edges\");\n }\n if (description.length > MAX_DESCRIPTION_LENGTH) {\n errors.push(`description exceeds ${MAX_DESCRIPTION_LENGTH} characters (${description.length})`);\n }\n return errors;\n}\n\nfunction loadSkillFromFile(filePath: string, source: string): LoadSkillsResult {\n const diagnostics: SkillDiagnostic[] = [];\n try {\n const raw = readFileSync(filePath, \"utf-8\");\n const { values, body } = parseFrontmatter(raw);\n const skillDir = dirname(filePath);\n const name = values.name || basename(skillDir);\n const description = values.description ?? \"\";\n\n if (!description.trim()) {\n diagnostics.push({ type: \"warning\", message: \"description is required\", path: filePath });\n return { skills: [], diagnostics };\n }\n for (const error of validateSkill(name, description)) {\n diagnostics.push({ type: \"warning\", message: error, path: filePath });\n }\n\n return {\n skills: [\n {\n name,\n description,\n content: body.trim(),\n filePath,\n baseDir: skillDir,\n source,\n disableModelInvocation: values[\"disable-model-invocation\"] === \"true\",\n },\n ],\n diagnostics,\n };\n } catch (error) {\n diagnostics.push({\n type: \"warning\",\n message: error instanceof Error ? error.message : \"failed to parse skill file\",\n path: filePath,\n });\n return { skills: [], diagnostics };\n }\n}\n\n/**\n * Load skills from a directory tree.\n * - A directory containing `SKILL.md` is a skill root; no further recursion.\n * - Direct `.md` children of the top-level directory load as skills.\n * - Dot-directories and `node_modules` are skipped.\n */\nexport function loadSkillsFromDir(options: {\n dir: string;\n source: string;\n /**\n * Refuse to follow symlinks on any path this load would read, skipping the\n * offending entry with a `code: \"symlink\"` diagnostic instead of loading\n * it. For untrusted trees (conversation offices) the host must never\n * follow an agent-created link; entries the loader never reads — dot\n * directories, vendored node_modules — cannot disqualify anything.\n */\n rejectSymlinks?: boolean;\n}): LoadSkillsResult {\n const rejectSymlinks = options.rejectSymlinks === true;\n if (rejectSymlinks && isSymlink(options.dir)) {\n return {\n skills: [],\n diagnostics: [\n {\n type: \"warning\",\n code: \"symlink\",\n message: \"Skills directory is a symlink; skipped\",\n path: options.dir,\n },\n ],\n };\n }\n return loadSkillsFromDirInternal(options.dir, options.source, true, rejectSymlinks);\n}\n\nfunction isSymlink(path: string): boolean {\n try {\n return lstatSync(path).isSymbolicLink();\n } catch {\n return false;\n }\n}\n\nfunction symlinkDiagnostic(path: string): SkillDiagnostic {\n return {\n type: \"warning\",\n code: \"symlink\",\n message: \"Skill entry is a symlink; skipped\",\n path,\n };\n}\n\nfunction loadSkillsFromDirInternal(\n dir: string,\n source: string,\n includeRootFiles: boolean,\n rejectSymlinks: boolean,\n): LoadSkillsResult {\n const skills: MikanSkill[] = [];\n const diagnostics: SkillDiagnostic[] = [];\n if (!existsSync(dir)) return { skills, diagnostics };\n\n let entries;\n try {\n entries = readdirSync(dir, { withFileTypes: true });\n } catch {\n return { skills, diagnostics };\n }\n\n const skillFile = entries.find((entry) => entry.name === \"SKILL.md\" && isFileLike(dir, entry));\n if (skillFile) {\n if (rejectSymlinks && skillFile.isSymbolicLink()) {\n diagnostics.push(symlinkDiagnostic(join(dir, skillFile.name)));\n return { skills, diagnostics };\n }\n return loadSkillFromFile(join(dir, skillFile.name), source);\n }\n\n for (const entry of entries) {\n if (entry.name.startsWith(\".\") || entry.name === \"node_modules\") continue;\n const fullPath = join(dir, entry.name);\n\n const directory = isDirectoryLike(dir, entry);\n if (!directory && !(includeRootFiles && entry.name.endsWith(\".md\") && isFileLike(dir, entry)))\n continue;\n if (rejectSymlinks && entry.isSymbolicLink()) {\n diagnostics.push(symlinkDiagnostic(fullPath));\n continue;\n }\n const result = directory\n ? loadSkillsFromDirInternal(fullPath, source, false, rejectSymlinks)\n : loadSkillFromFile(fullPath, source);\n skills.push(...result.skills);\n diagnostics.push(...result.diagnostics);\n }\n return { skills, diagnostics };\n}\n\nfunction isFileLike(\n dir: string,\n entry: { name: string; isFile(): boolean; isSymbolicLink(): boolean },\n): boolean {\n if (entry.isFile()) return true;\n if (!entry.isSymbolicLink()) return false;\n try {\n return statSync(join(dir, entry.name)).isFile();\n } catch {\n return false;\n }\n}\n\nfunction isDirectoryLike(\n dir: string,\n entry: { name: string; isDirectory(): boolean; isSymbolicLink(): boolean },\n): boolean {\n if (entry.isDirectory()) return true;\n if (!entry.isSymbolicLink()) return false;\n try {\n return statSync(join(dir, entry.name)).isDirectory();\n } catch {\n return false;\n }\n}\n\nfunction escapeXml(str: string): string {\n return str\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\")\n .replace(/'/g, \"'\");\n}\n\n/**\n * Format skills for a system prompt using the Agent Skills XML block.\n * Skills with `disableModelInvocation` are excluded.\n */\nexport function formatSkillsForPrompt(skills: MikanSkill[]): string {\n const visible = skills.filter((skill) => !skill.disableModelInvocation);\n if (visible.length === 0) return \"\";\n\n const lines = [\n \"\\n\\nThe following skills provide specialized instructions for specific tasks.\",\n \"Use the read tool to load a skill's file when the task matches its description.\",\n \"When a skill file references a relative path, resolve it against the skill directory (parent of SKILL.md / dirname of the path) and use that absolute path in tool commands.\",\n \"\",\n \"<available_skills>\",\n ];\n for (const skill of visible) {\n lines.push(\" <skill>\");\n lines.push(` <name>${escapeXml(skill.name)}</name>`);\n lines.push(` <description>${escapeXml(skill.description)}</description>`);\n if (skill.inline) {\n // Inline skills carry their body: the agent cannot read their file.\n lines.push(` <instructions>${escapeXml(skill.content)}</instructions>`);\n } else {\n lines.push(` <location>${escapeXml(skill.filePath)}</location>`);\n }\n lines.push(\" </skill>\");\n }\n lines.push(\"</available_skills>\");\n return lines.join(\"\\n\");\n}\n"]}
|
|
1
|
+
{"version":3,"file":"skills.js","sourceRoot":"","sources":["../../src/harness/skills.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACrF,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEpD,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AAEjC,SAAS,SAAS,CAChB,QAAiC,EACjC,MAAoB,EACpB,WAAqC;IAErC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,KAAK,CAAC,QAAQ,GAAG,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC7C,KAAK,CAAC,OAAO,GAAG,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3C,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAClC,CAAC;AACH,CAAC;AAED,SAAS,mBAAmB,CAC1B,WAA8B,EAC9B,aAAuC;IAEvC,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,IAAI,UAAU,CAAC,IAAI,KAAK,SAAS;YAAE,SAAS;QAC5C,GAAG,CAAC,UAAU,CAAC,6CAA6C,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;QAC/E,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,MAAc,EACd,aAAqB,EACrB,UAA+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QAC9K,EAAE;QACF,oBAAoB;KACrB,CAAC;IACF,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACxB,KAAK,CAAC,IAAI,CAAC,aAAa,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACxD,KAAK,CAAC,IAAI,CAAC,oBAAoB,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;QAC7E,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;YACjB,KAAK,CAAC,IAAI,CAAC,qBAAqB,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;QAC7E,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,IAAI,CAAC,iBAAiB,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;QACtE,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC3B,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IAClC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC","sourcesContent":["import type { Office } from \"../office/index.js\";\nimport type { MikanSkill, SkillDiagnostic, LoadSkillsResult } from \"./types.js\";\nimport type { WorkspaceProjection } from \"../office/types.js\";\nimport { existsSync, lstatSync, readdirSync, readFileSync, statSync } from \"node:fs\";\nimport { basename, dirname, join } from \"node:path\";\n\nimport * as log from \"../log.js\";\n\nfunction addSkills(\n skillMap: Map<string, MikanSkill>,\n skills: MikanSkill[],\n rewritePath: (path: string) => string,\n): void {\n for (const skill of skills) {\n skill.filePath = rewritePath(skill.filePath);\n skill.baseDir = rewritePath(skill.baseDir);\n skillMap.set(skill.name, skill);\n }\n}\n\nfunction skippedSymlinkPaths(\n diagnostics: SkillDiagnostic[],\n translatePath: (path: string) => string,\n): string[] {\n const skipped: string[] = [];\n for (const diagnostic of diagnostics) {\n if (diagnostic.code !== \"symlink\") continue;\n log.logWarning(\"Skipping conversation skill entry (symlink)\", diagnostic.path);\n skipped.push(translatePath(diagnostic.path));\n }\n return skipped;\n}\n\nexport function loadMikanSkills(\n office: Office,\n workspacePath: string,\n projection: WorkspaceProjection,\n): { skills: MikanSkill[]; skippedSkillLinks: string[] } {\n const skillMap = new Map<string, MikanSkill>();\n\n const hostWorkspacePath = office.workspace.root;\n const translatePath = (hostPath: string): string =>\n hostPath.startsWith(hostWorkspacePath)\n ? workspacePath + hostPath.slice(hostWorkspacePath.length)\n : hostPath;\n\n const workspaceSkillsDir = projection.promptSources.globalSkillsDir;\n if (workspaceSkillsDir) {\n const loaded = loadSkillsFromDir({ dir: workspaceSkillsDir, source: \"workspace\" });\n addSkills(skillMap, loaded.skills, translatePath);\n }\n\n const conversationSkills = loadSkillsFromDir({\n dir: projection.promptSources.conversationSkillsDir,\n source: \"channel\",\n rejectSymlinks: true,\n });\n const skippedSkillLinks = skippedSymlinkPaths(conversationSkills.diagnostics, translatePath);\n addSkills(skillMap, conversationSkills.skills, translatePath);\n\n return { skills: Array.from(skillMap.values()), skippedSkillLinks };\n}\nexport type { LoadSkillsResult } from \"./types.js\";\nexport type { MikanSkill } from \"./types.js\";\nexport type { SkillDiagnostic } from \"./types.js\";\n\nconst MAX_NAME_LENGTH = 64;\n\nconst MAX_DESCRIPTION_LENGTH = 1024;\n\ninterface Frontmatter {\n values: Record<string, string>;\n body: string;\n}\n\nexport function parseFrontmatter(content: string): Frontmatter {\n const match = content.match(/^---\\r?\\n([\\s\\S]*?)\\r?\\n---\\r?\\n?/);\n if (!match) return { values: {}, body: content };\n\n const values: Record<string, string> = {};\n for (const line of (match[1] ?? \"\").split(/\\r?\\n/)) {\n const separator = line.indexOf(\":\");\n if (separator === -1) continue;\n const key = line.slice(0, separator).trim();\n if (!key) continue;\n let value = line.slice(separator + 1).trim();\n if (\n (value.startsWith('\"') && value.endsWith('\"')) ||\n (value.startsWith(\"'\") && value.endsWith(\"'\"))\n ) {\n value = value.slice(1, -1);\n }\n values[key] = value;\n }\n return { values, body: content.slice(match[0].length) };\n}\n\nexport function validateSkill(name: string, description: string): string[] {\n const errors: string[] = [];\n if (name.length > MAX_NAME_LENGTH) {\n errors.push(`name exceeds ${MAX_NAME_LENGTH} characters (${name.length})`);\n }\n if (\n !/^[a-z0-9-]+$/.test(name) ||\n name.startsWith(\"-\") ||\n name.endsWith(\"-\") ||\n name.includes(\"--\")\n ) {\n errors.push(\"name must be lowercase a-z, 0-9 and single hyphens, not at the edges\");\n }\n if (description.length > MAX_DESCRIPTION_LENGTH) {\n errors.push(`description exceeds ${MAX_DESCRIPTION_LENGTH} characters (${description.length})`);\n }\n return errors;\n}\n\nfunction loadSkillFromFile(filePath: string, source: string): LoadSkillsResult {\n const diagnostics: SkillDiagnostic[] = [];\n try {\n const raw = readFileSync(filePath, \"utf-8\");\n const { values, body } = parseFrontmatter(raw);\n const skillDir = dirname(filePath);\n const name = values.name || basename(skillDir);\n const description = values.description ?? \"\";\n\n if (!description.trim()) {\n diagnostics.push({ type: \"warning\", message: \"description is required\", path: filePath });\n return { skills: [], diagnostics };\n }\n for (const error of validateSkill(name, description)) {\n diagnostics.push({ type: \"warning\", message: error, path: filePath });\n }\n\n return {\n skills: [\n {\n name,\n description,\n content: body.trim(),\n filePath,\n baseDir: skillDir,\n source,\n disableModelInvocation: values[\"disable-model-invocation\"] === \"true\",\n },\n ],\n diagnostics,\n };\n } catch (error) {\n diagnostics.push({\n type: \"warning\",\n message: error instanceof Error ? error.message : \"failed to parse skill file\",\n path: filePath,\n });\n return { skills: [], diagnostics };\n }\n}\n\nexport function loadSkillsFromDir(options: {\n dir: string;\n source: string;\n rejectSymlinks?: boolean;\n}): LoadSkillsResult {\n const rejectSymlinks = options.rejectSymlinks === true;\n if (rejectSymlinks && isSymlink(options.dir)) {\n return {\n skills: [],\n diagnostics: [\n {\n type: \"warning\",\n code: \"symlink\",\n message: \"Skills directory is a symlink; skipped\",\n path: options.dir,\n },\n ],\n };\n }\n return loadSkillsFromDirInternal(options.dir, options.source, true, rejectSymlinks);\n}\n\nfunction isSymlink(path: string): boolean {\n try {\n return lstatSync(path).isSymbolicLink();\n } catch {\n return false;\n }\n}\n\nfunction symlinkDiagnostic(path: string): SkillDiagnostic {\n return {\n type: \"warning\",\n code: \"symlink\",\n message: \"Skill entry is a symlink; skipped\",\n path,\n };\n}\n\nfunction loadSkillsFromDirInternal(\n dir: string,\n source: string,\n includeRootFiles: boolean,\n rejectSymlinks: boolean,\n): LoadSkillsResult {\n const skills: MikanSkill[] = [];\n const diagnostics: SkillDiagnostic[] = [];\n if (!existsSync(dir)) return { skills, diagnostics };\n\n let entries;\n try {\n entries = readdirSync(dir, { withFileTypes: true });\n } catch {\n return { skills, diagnostics };\n }\n\n const skillFile = entries.find((entry) => entry.name === \"SKILL.md\" && isFileLike(dir, entry));\n if (skillFile) {\n if (rejectSymlinks && skillFile.isSymbolicLink()) {\n diagnostics.push(symlinkDiagnostic(join(dir, skillFile.name)));\n return { skills, diagnostics };\n }\n return loadSkillFromFile(join(dir, skillFile.name), source);\n }\n\n for (const entry of entries) {\n if (entry.name.startsWith(\".\") || entry.name === \"node_modules\") continue;\n const fullPath = join(dir, entry.name);\n\n const directory = isDirectoryLike(dir, entry);\n if (!directory && !(includeRootFiles && entry.name.endsWith(\".md\") && isFileLike(dir, entry)))\n continue;\n if (rejectSymlinks && entry.isSymbolicLink()) {\n diagnostics.push(symlinkDiagnostic(fullPath));\n continue;\n }\n const result = directory\n ? loadSkillsFromDirInternal(fullPath, source, false, rejectSymlinks)\n : loadSkillFromFile(fullPath, source);\n skills.push(...result.skills);\n diagnostics.push(...result.diagnostics);\n }\n return { skills, diagnostics };\n}\n\nfunction isFileLike(\n dir: string,\n entry: { name: string; isFile(): boolean; isSymbolicLink(): boolean },\n): boolean {\n if (entry.isFile()) return true;\n if (!entry.isSymbolicLink()) return false;\n try {\n return statSync(join(dir, entry.name)).isFile();\n } catch {\n return false;\n }\n}\n\nfunction isDirectoryLike(\n dir: string,\n entry: { name: string; isDirectory(): boolean; isSymbolicLink(): boolean },\n): boolean {\n if (entry.isDirectory()) return true;\n if (!entry.isSymbolicLink()) return false;\n try {\n return statSync(join(dir, entry.name)).isDirectory();\n } catch {\n return false;\n }\n}\n\nfunction escapeXml(str: string): string {\n return str\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\")\n .replace(/'/g, \"'\");\n}\n\nexport function formatSkillsForPrompt(skills: MikanSkill[]): string {\n const visible = skills.filter((skill) => !skill.disableModelInvocation);\n if (visible.length === 0) return \"\";\n\n const lines = [\n \"\\n\\nThe following skills provide specialized instructions for specific tasks.\",\n \"Use the read tool to load a skill's file when the task matches its description.\",\n \"When a skill file references a relative path, resolve it against the skill directory (parent of SKILL.md / dirname of the path) and use that absolute path in tool commands.\",\n \"\",\n \"<available_skills>\",\n ];\n for (const skill of visible) {\n lines.push(\" <skill>\");\n lines.push(` <name>${escapeXml(skill.name)}</name>`);\n lines.push(` <description>${escapeXml(skill.description)}</description>`);\n if (skill.inline) {\n lines.push(` <instructions>${escapeXml(skill.content)}</instructions>`);\n } else {\n lines.push(` <location>${escapeXml(skill.filePath)}</location>`);\n }\n lines.push(\" </skill>\");\n }\n lines.push(\"</available_skills>\");\n return lines.join(\"\\n\");\n}\n"]}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import type { LoadSubagentProfilesResult } from "./types.js";
|
|
2
2
|
export type { LoadSubagentProfilesResult, SubagentProfileDiagnostic } from "./types.js";
|
|
3
|
-
/**
|
|
4
|
-
* Load the built-in profiles, then patch them with `<workspaceDir>/agents/*.md`.
|
|
5
|
-
* Malformed files are reported and skipped, leaving the built-in in place.
|
|
6
|
-
*/
|
|
7
3
|
export declare function loadSubagentProfiles(workspaceDir: string): LoadSubagentProfilesResult;
|
|
8
4
|
//# sourceMappingURL=subagent-profiles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subagent-profiles.d.ts","sourceRoot":"","sources":["../../src/harness/subagent-profiles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"subagent-profiles.d.ts","sourceRoot":"","sources":["../../src/harness/subagent-profiles.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,0BAA0B,EAI3B,MAAM,YAAY,CAAC;AAEpB,YAAY,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAkQxF,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,MAAM,GAAG,0BAA0B,CAiCrF"}
|
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Subagent profiles: the curated capability sets a subagent may be launched
|
|
3
|
-
* with.
|
|
4
|
-
*
|
|
5
|
-
* Profiles exist because the two halves of a subagent definition have
|
|
6
|
-
* different owners. What a profile *does* — its tools, required evidence,
|
|
7
|
-
* prompt and budget — is portable, so it ships as a built-in below and is
|
|
8
|
-
* versioned with the code. Which model runs it is per-installation, so it is
|
|
9
|
-
* overridden by `<workspaceDir>/agents/<name>.md`.
|
|
10
|
-
*
|
|
11
|
-
* A workspace file therefore *patches* the built-in of the same name rather
|
|
12
|
-
* than replacing it: overriding only `model:` must not force an operator to
|
|
13
|
-
* restate the tools and prompt, because a restated copy silently drifts from
|
|
14
|
-
* the built-in it was cloned from. A file whose name matches no built-in
|
|
15
|
-
* defines a new profile and must supply `tools` itself.
|
|
16
|
-
*
|
|
17
|
-
* A malformed file is reported as a diagnostic and skipped, never thrown:
|
|
18
|
-
* these are hand-edited, and one typo must not take the whole workspace down.
|
|
19
|
-
*/
|
|
20
1
|
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
21
2
|
import { basename, join } from "node:path";
|
|
22
3
|
import { parseFrontmatter } from "./skills.js";
|
|
@@ -172,7 +153,6 @@ const THINKING_LEVELS = new Set([
|
|
|
172
153
|
"high",
|
|
173
154
|
"xhigh",
|
|
174
155
|
]);
|
|
175
|
-
/** Parse a comma-separated tool list. The literal `none` is an empty grant. */
|
|
176
156
|
function csv(value) {
|
|
177
157
|
if (value.trim() === "none")
|
|
178
158
|
return [];
|
|
@@ -210,17 +190,12 @@ function parseNonNegativeNumber(value, field) {
|
|
|
210
190
|
}
|
|
211
191
|
return parsed;
|
|
212
192
|
}
|
|
213
|
-
/** Apply `field` from frontmatter onto `patch` only when the file sets it. */
|
|
214
193
|
function applyField(patch, values, key, field, parse) {
|
|
215
194
|
const raw = values[key];
|
|
216
195
|
if (raw === undefined)
|
|
217
196
|
return;
|
|
218
197
|
patch[field] = parse(raw);
|
|
219
198
|
}
|
|
220
|
-
/**
|
|
221
|
-
* Build the overlay a single file contributes. Throws with a human-readable
|
|
222
|
-
* message on malformed input; the caller turns that into a diagnostic.
|
|
223
|
-
*/
|
|
224
199
|
function parseProfilePatch(filePath, base) {
|
|
225
200
|
const { values, body } = parseFrontmatter(readFileSync(filePath, "utf-8"));
|
|
226
201
|
const name = basename(filePath, ".md");
|
|
@@ -250,10 +225,6 @@ function parseProfilePatch(filePath, base) {
|
|
|
250
225
|
};
|
|
251
226
|
return merged;
|
|
252
227
|
}
|
|
253
|
-
/**
|
|
254
|
-
* Load the built-in profiles, then patch them with `<workspaceDir>/agents/*.md`.
|
|
255
|
-
* Malformed files are reported and skipped, leaving the built-in in place.
|
|
256
|
-
*/
|
|
257
228
|
export function loadSubagentProfiles(workspaceDir) {
|
|
258
229
|
const dir = join(workspaceDir, "agents");
|
|
259
230
|
const profiles = new Map(BUILTIN_PROFILES.map((profile) => [profile.name, profile]));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subagent-profiles.js","sourceRoot":"","sources":["../../src/harness/subagent-profiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAA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/D,IAAI,EAAE,QAAQ;aACf,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;AACnC,CAAC","sourcesContent":["/**\n * Subagent profiles: the curated capability sets a subagent may be launched\n * with.\n *\n * Profiles exist because the two halves of a subagent definition have\n * different owners. What a profile *does* — its tools, required evidence,\n * prompt and budget — is portable, so it ships as a built-in below and is\n * versioned with the code. Which model runs it is per-installation, so it is\n * overridden by `<workspaceDir>/agents/<name>.md`.\n *\n * A workspace file therefore *patches* the built-in of the same name rather\n * than replacing it: overriding only `model:` must not force an operator to\n * restate the tools and prompt, because a restated copy silently drifts from\n * the built-in it was cloned from. A file whose name matches no built-in\n * defines a new profile and must supply `tools` itself.\n *\n * A malformed file is reported as a diagnostic and skipped, never thrown:\n * these are hand-edited, and one typo must not take the whole workspace down.\n */\nimport { existsSync, readFileSync, readdirSync } from \"node:fs\";\nimport { basename, join } from \"node:path\";\nimport type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type {\n LoadSubagentProfilesResult,\n SubagentModelSpec,\n SubagentProfile,\n SubagentProfileDiagnostic,\n} from \"./types.js\";\n\nexport type { LoadSubagentProfilesResult, SubagentProfileDiagnostic } from \"./types.js\";\nimport { parseFrontmatter } from \"./skills.js\";\n\nconst BUILTIN_PROFILES: SubagentProfile[] = [\n {\n name: \"worker\",\n description: \"Completes a bounded general-purpose task without adding domain assumptions\",\n systemPrompt: [\n \"You are a general-purpose worker responsible for one clearly bounded delegated task.\",\n \"\",\n \"Use `read` and `bash` to inspect the actual workspace state, and use `edit` or `write` only when the assignment requires changes. Follow applicable skill instructions, preserve behavior outside the stated scope, and do not invent requirements or broaden the task. Verify concrete outputs before reporting success; if the assignment lacks information or a required capability, state the limitation instead of guessing.\",\n \"\",\n \"Keep verbose discovery and command output in this isolated run. Return the completed result, files or artifacts changed, verification performed, and any unresolved blocker.\",\n ].join(\"\\n\"),\n tools: [\"read\", \"bash\", \"edit\", \"write\", \"jev\"],\n thinkingLevel: \"high\",\n maxTurns: 100,\n maxTokens: 1_000_000,\n maxCostUsd: 10,\n },\n {\n name: \"software-engineer\",\n description:\n \"Owns software investigation, implementation, integration, and technical verification\",\n systemPrompt: [\n \"You are the software engineer responsible for one delegated technical outcome.\",\n \"\",\n \"Apply the relevant engineering and vendor skill instructions. Use `bash` to inspect repositories, run development tools, diagnose browser or integration behavior, and make only changes explicitly included in the assignment. Trace failures to their technical cause, preserve existing contracts outside scope, and verify work with the narrowest meaningful checks. Do not treat plausible output as evidence of success.\",\n \"\",\n \"Keep source discovery, build logs, browser traces, and repetitive diagnostics in this isolated run. Return the implemented or diagnosed outcome, decisive technical evidence, changed artifact paths when applicable, verification results, and remaining engineering risk.\",\n ].join(\"\\n\"),\n tools: [\"read\", \"bash\", \"edit\", \"write\", \"jev\"],\n thinkingLevel: \"high\",\n maxTurns: 100,\n maxTokens: 1_000_000,\n maxCostUsd: 10,\n },\n {\n name: \"devops-engineer\",\n description:\n \"Owns cloud access, environments, deployments, and production workflow reliability\",\n systemPrompt: [\n \"You are the DevOps engineer responsible for one delegated infrastructure or production-operations outcome.\",\n \"\",\n \"Apply the relevant setup, GCP, repository-access, service-status, and production workflow skill instructions. Use `bash` to inspect current state before acting. Respect the named project, environment, principal, and resource scope; protect credentials; prefer least privilege; and check idempotency before writes, retries, or provisioning. Do not broaden access or repeat a non-idempotent operation without explicit authorization and evidence that it is needed.\",\n \"\",\n \"Keep verbose CLI, API, and job logs in this isolated run. Return the resulting state, affected resources or job identifiers, verification performed, and concrete follow-up or rollback information.\",\n ].join(\"\\n\"),\n tools: [\"read\", \"bash\", \"edit\", \"write\", \"event\", \"sandbox\"],\n thinkingLevel: \"high\",\n maxTurns: 100,\n maxTokens: 1_000_000,\n maxCostUsd: 10,\n },\n {\n name: \"data-scientist\",\n description:\n \"Owns metric definition, data analysis, reconciliation, and defensible conclusions\",\n systemPrompt: [\n \"You are the data scientist responsible for answering one delegated quantitative question.\",\n \"\",\n \"Apply the relevant Metabase, GAM, accounting, billing, reporting, and parser skill instructions. Use `bash` to run the prescribed queries and analysis tools. Establish the time range, timezone, filters, dimensions, population, and metric definitions before interpreting results. Reconcile totals and cross-check consequential figures when practical. Separate source values, derived calculations, and inference; never fill missing data with guesses.\",\n \"\",\n \"Keep verbose rows and query output in this isolated run. Return the conclusion, key figures with units and scope, methodology and checks, and limitations that affect confidence.\",\n ].join(\"\\n\"),\n tools: [\"read\", \"bash\", \"write\", \"jev\"],\n thinkingLevel: \"high\",\n maxTurns: 100,\n maxTokens: 1_000_000,\n maxCostUsd: 10,\n },\n {\n name: \"account-manager\",\n description:\n \"Owns existing-client onboarding, account coordination, and delivery follow-through\",\n systemPrompt: [\n \"You are the account manager responsible for one delegated existing-client outcome.\",\n \"\",\n \"Apply the relevant onboarding, publisher account, slot, workspace, meeting, and communication skill instructions. Use `bash` to inspect the current customer and account state before acting. Preserve supplied commercial and technical requirements, coordinate dependencies, avoid duplicate account changes, and clearly distinguish completed work from items awaiting another owner. Do not invent customer approval or make an external commitment beyond the assignment.\",\n \"\",\n \"Keep verbose records and operational output in this isolated run. Return the customer-facing outcome, account or artifact identifiers, decisions and blockers, and the next owner and action where follow-through remains.\",\n ].join(\"\\n\"),\n tools: [\"read\", \"bash\", \"write\", \"event\"],\n thinkingLevel: \"high\",\n maxTurns: 100,\n maxTokens: 1_000_000,\n maxCostUsd: 10,\n },\n {\n name: \"business-development\",\n description:\n \"Owns prospect research, qualification, contact discovery, and outreach preparation\",\n systemPrompt: [\n \"You are the business development specialist responsible for one delegated growth opportunity.\",\n \"\",\n \"Apply the relevant prospecting, website sampling, contact-finding, email-validation, and client-approach skill instructions. Use `bash` to gather and verify public evidence. Evaluate fit against the supplied criteria, distinguish verified contacts from inferred ones, and preserve source URLs. Do not contact prospects, submit forms, or represent that outreach occurred unless the assignment explicitly authorizes it.\",\n \"\",\n \"Keep raw pages, candidate lists, and repetitive validation output in this isolated run. Return qualified opportunities, supporting evidence, confidence and disqualifiers, and a concise recommended next action.\",\n ].join(\"\\n\"),\n tools: [\"read\", \"bash\", \"write\"],\n thinkingLevel: \"high\",\n maxTurns: 100,\n maxTokens: 1_000_000,\n maxCostUsd: 10,\n },\n {\n name: \"creative-producer\",\n description: \"Owns media deliverables from creative brief through verified production output\",\n systemPrompt: [\n \"You are the creative producer responsible for one delegated media deliverable.\",\n \"\",\n \"Apply the relevant source acquisition, storyboard, video, image, speech, lipsync, and generation-provider skill instructions. Use `bash` to run the prescribed production tools, and `generate_image` for image deliverables. Confirm the brief, audience, format, dimensions, duration, language, and source inputs; use discovery commands rather than guessing provider or model identifiers. Preserve provenance and generation parameters, and verify that claimed outputs exist and match the requested technical properties.\",\n \"\",\n \"Keep generation logs, intermediate assets, and provider polling in this isolated run. Return deliverable paths or external identifiers, a concise production summary, verification results, and unresolved creative, quality, or rights constraints.\",\n ].join(\"\\n\"),\n tools: [\"read\", \"bash\", \"write\", \"generate_image\"],\n thinkingLevel: \"high\",\n maxTurns: 100,\n maxTokens: 1_000_000,\n maxCostUsd: 10,\n },\n {\n name: \"ad-operations-specialist\",\n description:\n \"Owns ad serving setup, delivery diagnostics, policy checks, and operational health\",\n systemPrompt: [\n \"You are the ad operations specialist responsible for one delegated advertising-delivery outcome.\",\n \"\",\n \"Apply the relevant GAM, ads.txt, player detection, targeting, behavior, monitoring, and policy skill instructions. Use `bash` to run the prescribed browser and reporting tools. Establish the site, account, slot, time window, geography, device, and consent conditions; distinguish configuration, eligibility, request, impression, and playback evidence. Reproduce dynamic behavior when practical, and do not change live serving configuration unless explicitly authorized.\",\n \"\",\n \"Keep browser traces, HAR data, report rows, and repetitive diagnostics in this isolated run. Return the operational conclusion, decisive delivery evidence, affected inventory, remediation or escalation owner, and uncertainty that could change the diagnosis.\",\n ].join(\"\\n\"),\n tools: [\"read\", \"bash\", \"write\"],\n thinkingLevel: \"high\",\n maxTurns: 100,\n maxTokens: 1_000_000,\n maxCostUsd: 10,\n },\n {\n name: \"summarizer\",\n description:\n \"Synthesizes supplied task input and upstream DAG dependency output without claiming external verification\",\n systemPrompt: [\n \"You synthesize only the task text and structured dependency input supplied to this run — typically the combined output of upstream DAG nodes that did their own investigation.\",\n \"\",\n \"Do not claim to have inspected files, executed commands, accessed URLs, or verified external state. Clearly distinguish dependency-provided facts from your own analysis. If the supplied evidence is insufficient, state the limitation instead of inventing details. `jev` is your only tool: use it to classify, rank, or check claims against the supplied input when the volume is large or a calibrated probability helps.\",\n ].join(\"\\n\"),\n tools: [\"jev\"],\n thinkingLevel: \"high\",\n maxTurns: 100,\n maxTokens: 1_000_000,\n maxCostUsd: 10,\n },\n];\n\nconst THINKING_LEVELS = new Set<ThinkingLevel>([\n \"off\",\n \"minimal\",\n \"low\",\n \"medium\",\n \"high\",\n \"xhigh\",\n]);\n\n/** Parse a comma-separated tool list. The literal `none` is an empty grant. */\nfunction csv(value: string): string[] {\n if (value.trim() === \"none\") return [];\n return [\n ...new Set(\n value\n .split(\",\")\n .map((item) => item.trim())\n .filter(Boolean),\n ),\n ];\n}\n\nfunction parseModel(value: string): SubagentModelSpec {\n const separator = value.indexOf(\"/\");\n if (separator <= 0 || separator === value.length - 1) {\n throw new Error(`model must be provider/id, got ${value}`);\n }\n return { provider: value.slice(0, separator), id: value.slice(separator + 1) };\n}\n\nfunction parseThinking(value: string): ThinkingLevel {\n if (!THINKING_LEVELS.has(value as ThinkingLevel)) {\n throw new Error(`unknown thinking level: ${value}`);\n }\n return value as ThinkingLevel;\n}\n\nfunction parsePositiveInteger(value: string, field: string): number {\n const parsed = Number(value);\n if (!Number.isInteger(parsed) || parsed <= 0) {\n throw new Error(`${field} must be a positive integer`);\n }\n return parsed;\n}\n\nfunction parseNonNegativeNumber(value: string, field: string): number {\n const parsed = Number(value);\n if (!Number.isFinite(parsed) || parsed < 0) {\n throw new Error(`${field} must be a non-negative number`);\n }\n return parsed;\n}\n\n/** Apply `field` from frontmatter onto `patch` only when the file sets it. */\nfunction applyField<K extends keyof SubagentProfile>(\n patch: Partial<SubagentProfile>,\n values: Record<string, string>,\n key: string,\n field: K,\n parse: (value: string) => SubagentProfile[K],\n): void {\n const raw = values[key];\n if (raw === undefined) return;\n patch[field] = parse(raw);\n}\n\n/**\n * Build the overlay a single file contributes. Throws with a human-readable\n * message on malformed input; the caller turns that into a diagnostic.\n */\nfunction parseProfilePatch(filePath: string, base: SubagentProfile | undefined): SubagentProfile {\n const { values, body } = parseFrontmatter(readFileSync(filePath, \"utf-8\"));\n const name = basename(filePath, \".md\");\n const patch: Partial<SubagentProfile> = {};\n\n applyField(patch, values, \"description\", \"description\", (value) => value.trim());\n applyField(patch, values, \"tools\", \"tools\", csv);\n applyField(patch, values, \"model\", \"model\", parseModel);\n applyField(patch, values, \"thinking\", \"thinkingLevel\", parseThinking);\n applyField(patch, values, \"max_turns\", \"maxTurns\", (v) => parsePositiveInteger(v, \"max_turns\"));\n applyField(patch, values, \"max_tokens\", \"maxTokens\", (v) =>\n parsePositiveInteger(v, \"max_tokens\"),\n );\n applyField(patch, values, \"max_cost_usd\", \"maxCostUsd\", (v) =>\n parseNonNegativeNumber(v, \"max_cost_usd\"),\n );\n applyField(patch, values, \"max_duration_ms\", \"maxDurationMs\", (v) =>\n parsePositiveInteger(v, \"max_duration_ms\"),\n );\n\n const systemPrompt = body.trim() || base?.systemPrompt;\n if (!base && patch.tools === undefined) {\n throw new Error(`tools is required for a new profile (no built-in named ${name})`);\n }\n if (!systemPrompt) {\n throw new Error(`a new profile needs prompt text in the file body`);\n }\n\n const merged: SubagentProfile = {\n ...base,\n ...patch,\n name,\n description: patch.description || base?.description || name,\n systemPrompt,\n tools: patch.tools ?? base?.tools ?? [],\n };\n return merged;\n}\n\n/**\n * Load the built-in profiles, then patch them with `<workspaceDir>/agents/*.md`.\n * Malformed files are reported and skipped, leaving the built-in in place.\n */\nexport function loadSubagentProfiles(workspaceDir: string): LoadSubagentProfilesResult {\n const dir = join(workspaceDir, \"agents\");\n const profiles = new Map(BUILTIN_PROFILES.map((profile) => [profile.name, profile]));\n const diagnostics: SubagentProfileDiagnostic[] = [];\n if (!existsSync(dir)) return { profiles, diagnostics };\n\n let entries;\n try {\n entries = readdirSync(dir, { withFileTypes: true });\n } catch (error) {\n diagnostics.push({\n type: \"warning\",\n message: error instanceof Error ? error.message : String(error),\n path: dir,\n });\n return { profiles, diagnostics };\n }\n\n for (const entry of entries) {\n if (!entry.isFile() || !entry.name.endsWith(\".md\")) continue;\n const filePath = join(dir, entry.name);\n try {\n const profile = parseProfilePatch(filePath, profiles.get(basename(entry.name, \".md\")));\n profiles.set(profile.name, profile);\n } catch (error) {\n diagnostics.push({\n type: \"warning\",\n message: error instanceof Error ? error.message : String(error),\n path: filePath,\n });\n }\n }\n return { profiles, diagnostics };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"subagent-profiles.js","sourceRoot":"","sources":["../../src/harness/subagent-profiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAU3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,gBAAgB,GAAsB;IAC1C;QACE,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,4EAA4E;QACzF,YAAY,EAAE;YACZ,sFAAsF;YACtF,EAAE;YACF,maAAma;YACna,EAAE;YACF,8KAA8K;SAC/K,CAAC,IAAI,CAAC,IAAI,CAAC;QACZ,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC;QAC/C,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,GAAG;QACb,SAAS,EAAE,SAAS;QACpB,UAAU,EAAE,EAAE;KACf;IACD;QACE,IAAI,EAAE,mBAAmB;QACzB,WAAW,EACT,sFAAsF;QACxF,YAAY,EAAE;YACZ,gFAAgF;YAChF,EAAE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AAC,QAAQ,CAAC,KAAK,CAAC;YAAE,SAAS;QAC7D,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;YACvF,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACtC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,WAAW,CAAC,IAAI,CAAC;gBACf,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;gBAC/D,IAAI,EAAE,QAAQ;aACf,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;AACnC,CAAC","sourcesContent":["import { existsSync, readFileSync, readdirSync } from \"node:fs\";\nimport { basename, join } from \"node:path\";\nimport type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type {\n LoadSubagentProfilesResult,\n SubagentModelSpec,\n SubagentProfile,\n SubagentProfileDiagnostic,\n} from \"./types.js\";\n\nexport type { LoadSubagentProfilesResult, SubagentProfileDiagnostic } from \"./types.js\";\nimport { parseFrontmatter } from \"./skills.js\";\n\nconst BUILTIN_PROFILES: SubagentProfile[] = [\n {\n name: \"worker\",\n description: \"Completes a bounded general-purpose task without adding domain assumptions\",\n systemPrompt: [\n \"You are a general-purpose worker responsible for one clearly bounded delegated task.\",\n \"\",\n \"Use `read` and `bash` to inspect the actual workspace state, and use `edit` or `write` only when the assignment requires changes. Follow applicable skill instructions, preserve behavior outside the stated scope, and do not invent requirements or broaden the task. Verify concrete outputs before reporting success; if the assignment lacks information or a required capability, state the limitation instead of guessing.\",\n \"\",\n \"Keep verbose discovery and command output in this isolated run. Return the completed result, files or artifacts changed, verification performed, and any unresolved blocker.\",\n ].join(\"\\n\"),\n tools: [\"read\", \"bash\", \"edit\", \"write\", \"jev\"],\n thinkingLevel: \"high\",\n maxTurns: 100,\n maxTokens: 1_000_000,\n maxCostUsd: 10,\n },\n {\n name: \"software-engineer\",\n description:\n \"Owns software investigation, implementation, integration, and technical verification\",\n systemPrompt: [\n \"You are the software engineer responsible for one delegated technical outcome.\",\n \"\",\n \"Apply the relevant engineering and vendor skill instructions. Use `bash` to inspect repositories, run development tools, diagnose browser or integration behavior, and make only changes explicitly included in the assignment. Trace failures to their technical cause, preserve existing contracts outside scope, and verify work with the narrowest meaningful checks. Do not treat plausible output as evidence of success.\",\n \"\",\n \"Keep source discovery, build logs, browser traces, and repetitive diagnostics in this isolated run. Return the implemented or diagnosed outcome, decisive technical evidence, changed artifact paths when applicable, verification results, and remaining engineering risk.\",\n ].join(\"\\n\"),\n tools: [\"read\", \"bash\", \"edit\", \"write\", \"jev\"],\n thinkingLevel: \"high\",\n maxTurns: 100,\n maxTokens: 1_000_000,\n maxCostUsd: 10,\n },\n {\n name: \"devops-engineer\",\n description:\n \"Owns cloud access, environments, deployments, and production workflow reliability\",\n systemPrompt: [\n \"You are the DevOps engineer responsible for one delegated infrastructure or production-operations outcome.\",\n \"\",\n \"Apply the relevant setup, GCP, repository-access, service-status, and production workflow skill instructions. Use `bash` to inspect current state before acting. Respect the named project, environment, principal, and resource scope; protect credentials; prefer least privilege; and check idempotency before writes, retries, or provisioning. Do not broaden access or repeat a non-idempotent operation without explicit authorization and evidence that it is needed.\",\n \"\",\n \"Keep verbose CLI, API, and job logs in this isolated run. Return the resulting state, affected resources or job identifiers, verification performed, and concrete follow-up or rollback information.\",\n ].join(\"\\n\"),\n tools: [\"read\", \"bash\", \"edit\", \"write\", \"event\", \"sandbox\"],\n thinkingLevel: \"high\",\n maxTurns: 100,\n maxTokens: 1_000_000,\n maxCostUsd: 10,\n },\n {\n name: \"data-scientist\",\n description:\n \"Owns metric definition, data analysis, reconciliation, and defensible conclusions\",\n systemPrompt: [\n \"You are the data scientist responsible for answering one delegated quantitative question.\",\n \"\",\n \"Apply the relevant Metabase, GAM, accounting, billing, reporting, and parser skill instructions. Use `bash` to run the prescribed queries and analysis tools. Establish the time range, timezone, filters, dimensions, population, and metric definitions before interpreting results. Reconcile totals and cross-check consequential figures when practical. Separate source values, derived calculations, and inference; never fill missing data with guesses.\",\n \"\",\n \"Keep verbose rows and query output in this isolated run. Return the conclusion, key figures with units and scope, methodology and checks, and limitations that affect confidence.\",\n ].join(\"\\n\"),\n tools: [\"read\", \"bash\", \"write\", \"jev\"],\n thinkingLevel: \"high\",\n maxTurns: 100,\n maxTokens: 1_000_000,\n maxCostUsd: 10,\n },\n {\n name: \"account-manager\",\n description:\n \"Owns existing-client onboarding, account coordination, and delivery follow-through\",\n systemPrompt: [\n \"You are the account manager responsible for one delegated existing-client outcome.\",\n \"\",\n \"Apply the relevant onboarding, publisher account, slot, workspace, meeting, and communication skill instructions. Use `bash` to inspect the current customer and account state before acting. Preserve supplied commercial and technical requirements, coordinate dependencies, avoid duplicate account changes, and clearly distinguish completed work from items awaiting another owner. Do not invent customer approval or make an external commitment beyond the assignment.\",\n \"\",\n \"Keep verbose records and operational output in this isolated run. Return the customer-facing outcome, account or artifact identifiers, decisions and blockers, and the next owner and action where follow-through remains.\",\n ].join(\"\\n\"),\n tools: [\"read\", \"bash\", \"write\", \"event\"],\n thinkingLevel: \"high\",\n maxTurns: 100,\n maxTokens: 1_000_000,\n maxCostUsd: 10,\n },\n {\n name: \"business-development\",\n description:\n \"Owns prospect research, qualification, contact discovery, and outreach preparation\",\n systemPrompt: [\n \"You are the business development specialist responsible for one delegated growth opportunity.\",\n \"\",\n \"Apply the relevant prospecting, website sampling, contact-finding, email-validation, and client-approach skill instructions. Use `bash` to gather and verify public evidence. Evaluate fit against the supplied criteria, distinguish verified contacts from inferred ones, and preserve source URLs. Do not contact prospects, submit forms, or represent that outreach occurred unless the assignment explicitly authorizes it.\",\n \"\",\n \"Keep raw pages, candidate lists, and repetitive validation output in this isolated run. Return qualified opportunities, supporting evidence, confidence and disqualifiers, and a concise recommended next action.\",\n ].join(\"\\n\"),\n tools: [\"read\", \"bash\", \"write\"],\n thinkingLevel: \"high\",\n maxTurns: 100,\n maxTokens: 1_000_000,\n maxCostUsd: 10,\n },\n {\n name: \"creative-producer\",\n description: \"Owns media deliverables from creative brief through verified production output\",\n systemPrompt: [\n \"You are the creative producer responsible for one delegated media deliverable.\",\n \"\",\n \"Apply the relevant source acquisition, storyboard, video, image, speech, lipsync, and generation-provider skill instructions. Use `bash` to run the prescribed production tools, and `generate_image` for image deliverables. Confirm the brief, audience, format, dimensions, duration, language, and source inputs; use discovery commands rather than guessing provider or model identifiers. Preserve provenance and generation parameters, and verify that claimed outputs exist and match the requested technical properties.\",\n \"\",\n \"Keep generation logs, intermediate assets, and provider polling in this isolated run. Return deliverable paths or external identifiers, a concise production summary, verification results, and unresolved creative, quality, or rights constraints.\",\n ].join(\"\\n\"),\n tools: [\"read\", \"bash\", \"write\", \"generate_image\"],\n thinkingLevel: \"high\",\n maxTurns: 100,\n maxTokens: 1_000_000,\n maxCostUsd: 10,\n },\n {\n name: \"ad-operations-specialist\",\n description:\n \"Owns ad serving setup, delivery diagnostics, policy checks, and operational health\",\n systemPrompt: [\n \"You are the ad operations specialist responsible for one delegated advertising-delivery outcome.\",\n \"\",\n \"Apply the relevant GAM, ads.txt, player detection, targeting, behavior, monitoring, and policy skill instructions. Use `bash` to run the prescribed browser and reporting tools. Establish the site, account, slot, time window, geography, device, and consent conditions; distinguish configuration, eligibility, request, impression, and playback evidence. Reproduce dynamic behavior when practical, and do not change live serving configuration unless explicitly authorized.\",\n \"\",\n \"Keep browser traces, HAR data, report rows, and repetitive diagnostics in this isolated run. Return the operational conclusion, decisive delivery evidence, affected inventory, remediation or escalation owner, and uncertainty that could change the diagnosis.\",\n ].join(\"\\n\"),\n tools: [\"read\", \"bash\", \"write\"],\n thinkingLevel: \"high\",\n maxTurns: 100,\n maxTokens: 1_000_000,\n maxCostUsd: 10,\n },\n {\n name: \"summarizer\",\n description:\n \"Synthesizes supplied task input and upstream DAG dependency output without claiming external verification\",\n systemPrompt: [\n \"You synthesize only the task text and structured dependency input supplied to this run — typically the combined output of upstream DAG nodes that did their own investigation.\",\n \"\",\n \"Do not claim to have inspected files, executed commands, accessed URLs, or verified external state. Clearly distinguish dependency-provided facts from your own analysis. If the supplied evidence is insufficient, state the limitation instead of inventing details. `jev` is your only tool: use it to classify, rank, or check claims against the supplied input when the volume is large or a calibrated probability helps.\",\n ].join(\"\\n\"),\n tools: [\"jev\"],\n thinkingLevel: \"high\",\n maxTurns: 100,\n maxTokens: 1_000_000,\n maxCostUsd: 10,\n },\n];\n\nconst THINKING_LEVELS = new Set<ThinkingLevel>([\n \"off\",\n \"minimal\",\n \"low\",\n \"medium\",\n \"high\",\n \"xhigh\",\n]);\n\nfunction csv(value: string): string[] {\n if (value.trim() === \"none\") return [];\n return [\n ...new Set(\n value\n .split(\",\")\n .map((item) => item.trim())\n .filter(Boolean),\n ),\n ];\n}\n\nfunction parseModel(value: string): SubagentModelSpec {\n const separator = value.indexOf(\"/\");\n if (separator <= 0 || separator === value.length - 1) {\n throw new Error(`model must be provider/id, got ${value}`);\n }\n return { provider: value.slice(0, separator), id: value.slice(separator + 1) };\n}\n\nfunction parseThinking(value: string): ThinkingLevel {\n if (!THINKING_LEVELS.has(value as ThinkingLevel)) {\n throw new Error(`unknown thinking level: ${value}`);\n }\n return value as ThinkingLevel;\n}\n\nfunction parsePositiveInteger(value: string, field: string): number {\n const parsed = Number(value);\n if (!Number.isInteger(parsed) || parsed <= 0) {\n throw new Error(`${field} must be a positive integer`);\n }\n return parsed;\n}\n\nfunction parseNonNegativeNumber(value: string, field: string): number {\n const parsed = Number(value);\n if (!Number.isFinite(parsed) || parsed < 0) {\n throw new Error(`${field} must be a non-negative number`);\n }\n return parsed;\n}\n\nfunction applyField<K extends keyof SubagentProfile>(\n patch: Partial<SubagentProfile>,\n values: Record<string, string>,\n key: string,\n field: K,\n parse: (value: string) => SubagentProfile[K],\n): void {\n const raw = values[key];\n if (raw === undefined) return;\n patch[field] = parse(raw);\n}\n\nfunction parseProfilePatch(filePath: string, base: SubagentProfile | undefined): SubagentProfile {\n const { values, body } = parseFrontmatter(readFileSync(filePath, \"utf-8\"));\n const name = basename(filePath, \".md\");\n const patch: Partial<SubagentProfile> = {};\n\n applyField(patch, values, \"description\", \"description\", (value) => value.trim());\n applyField(patch, values, \"tools\", \"tools\", csv);\n applyField(patch, values, \"model\", \"model\", parseModel);\n applyField(patch, values, \"thinking\", \"thinkingLevel\", parseThinking);\n applyField(patch, values, \"max_turns\", \"maxTurns\", (v) => parsePositiveInteger(v, \"max_turns\"));\n applyField(patch, values, \"max_tokens\", \"maxTokens\", (v) =>\n parsePositiveInteger(v, \"max_tokens\"),\n );\n applyField(patch, values, \"max_cost_usd\", \"maxCostUsd\", (v) =>\n parseNonNegativeNumber(v, \"max_cost_usd\"),\n );\n applyField(patch, values, \"max_duration_ms\", \"maxDurationMs\", (v) =>\n parsePositiveInteger(v, \"max_duration_ms\"),\n );\n\n const systemPrompt = body.trim() || base?.systemPrompt;\n if (!base && patch.tools === undefined) {\n throw new Error(`tools is required for a new profile (no built-in named ${name})`);\n }\n if (!systemPrompt) {\n throw new Error(`a new profile needs prompt text in the file body`);\n }\n\n const merged: SubagentProfile = {\n ...base,\n ...patch,\n name,\n description: patch.description || base?.description || name,\n systemPrompt,\n tools: patch.tools ?? base?.tools ?? [],\n };\n return merged;\n}\n\nexport function loadSubagentProfiles(workspaceDir: string): LoadSubagentProfilesResult {\n const dir = join(workspaceDir, \"agents\");\n const profiles = new Map(BUILTIN_PROFILES.map((profile) => [profile.name, profile]));\n const diagnostics: SubagentProfileDiagnostic[] = [];\n if (!existsSync(dir)) return { profiles, diagnostics };\n\n let entries;\n try {\n entries = readdirSync(dir, { withFileTypes: true });\n } catch (error) {\n diagnostics.push({\n type: \"warning\",\n message: error instanceof Error ? error.message : String(error),\n path: dir,\n });\n return { profiles, diagnostics };\n }\n\n for (const entry of entries) {\n if (!entry.isFile() || !entry.name.endsWith(\".md\")) continue;\n const filePath = join(dir, entry.name);\n try {\n const profile = parseProfilePatch(filePath, profiles.get(basename(entry.name, \".md\")));\n profiles.set(profile.name, profile);\n } catch (error) {\n diagnostics.push({\n type: \"warning\",\n message: error instanceof Error ? error.message : String(error),\n path: filePath,\n });\n }\n }\n return { profiles, diagnostics };\n}\n"]}
|
|
@@ -8,7 +8,6 @@ export declare const DEFAULT_SUBAGENT_BUDGET: {
|
|
|
8
8
|
readonly maxCostUsd: 10;
|
|
9
9
|
readonly maxDurationMs: number;
|
|
10
10
|
};
|
|
11
|
-
/** Time allowed for an aborted subagent to settle before detached cleanup. */
|
|
12
11
|
export declare const SUBAGENT_ABORT_GRACE_MS = 100;
|
|
13
12
|
interface RunSubagentOptions<TOutputSchema extends TSchema | undefined = undefined> {
|
|
14
13
|
request: SubagentRunRequest<TOutputSchema>;
|
|
@@ -18,47 +17,23 @@ interface RunSubagentOptions<TOutputSchema extends TSchema | undefined = undefin
|
|
|
18
17
|
workspaceDir: string;
|
|
19
18
|
availableTools: MikanHarnessTool[];
|
|
20
19
|
profiles?: ReadonlyMap<string, SubagentProfile>;
|
|
21
|
-
/** Sandbox-backed execution env; may be omitted when no native execution tools are granted. */
|
|
22
20
|
toolContext?: ExecutionToolContext;
|
|
23
|
-
/** Process-wide launch pool shared by all parent runs. */
|
|
24
21
|
slots?: SubagentSlotPool;
|
|
25
|
-
/** Host-snapshotted parent transcript; never sourced from the public request. */
|
|
26
22
|
parentMessages?: AgentMessage[];
|
|
27
|
-
/** Usage attribution sink snapshotted when this invocation begins. */
|
|
28
23
|
onUsage?: SubagentUsageSink;
|
|
29
|
-
/**
|
|
30
|
-
* Called as the run's visible activity changes, so a caller can show what
|
|
31
|
-
* this subagent is doing rather than only that it started. Best-effort: a
|
|
32
|
-
* throwing sink is logged and the run continues.
|
|
33
|
-
*/
|
|
34
24
|
onActivity?: (activity: string) => void;
|
|
35
25
|
}
|
|
36
|
-
/**
|
|
37
|
-
* Execute one non-recursive, fresh subagent run. Never rejects: every
|
|
38
|
-
* failure — including request validation — is a result with a terminal
|
|
39
|
-
* status, so batch callers (`tasks` / `dag`) can never orphan in-flight
|
|
40
|
-
* sibling runs on one bad request. Usage is reported once, after the
|
|
41
|
-
* underlying run settles; an aborted run may report it from detached cleanup.
|
|
42
|
-
*/
|
|
43
26
|
export declare function runSubagent<TOutputSchema extends TSchema | undefined = undefined>(options: RunSubagentOptions<TOutputSchema>): Promise<SubagentRunResult<SubagentRunOutput<TOutputSchema>>>;
|
|
44
|
-
/** Default process-wide ceiling on concurrently live subagent sessions. */
|
|
45
27
|
export declare const DEFAULT_GLOBAL_SUBAGENT_SLOTS = 8;
|
|
46
|
-
/** Async slot pool: at most `capacity` concurrent holders, FIFO waiters. */
|
|
47
28
|
export declare class SubagentSlotPool {
|
|
48
29
|
readonly capacity: number;
|
|
49
30
|
private held;
|
|
50
31
|
private waiters;
|
|
51
32
|
constructor(capacity: number);
|
|
52
|
-
/** Currently held slots (for tests and capacity reporting). */
|
|
53
33
|
get inFlight(): number;
|
|
54
|
-
/**
|
|
55
|
-
* Resolve with a release function once a slot frees up. Call the release
|
|
56
|
-
* exactly once; releasing hands the slot to the oldest waiter.
|
|
57
|
-
*/
|
|
58
34
|
acquire(signal?: AbortSignal): Promise<() => void>;
|
|
59
35
|
private releaser;
|
|
60
36
|
}
|
|
61
|
-
/** A pool that never blocks — the default when no shared ceiling is wired. */
|
|
62
37
|
export declare function unboundedSlotPool(): SubagentSlotPool;
|
|
63
38
|
export {};
|
|
64
39
|
//# sourceMappingURL=subagent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subagent.d.ts","sourceRoot":"","sources":["../../src/harness/subagent.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EACZ,oBAAoB,EACpB,aAAa,EACd,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAe,KAAK,GAAG,EAAyB,KAAK,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACjG,OAAO,EAAc,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EAEf,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EAEjB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAWpB,eAAO,MAAM,uBAAuB;aAClC,QAAQ,EAAE,GAAG;aACb,UAAU,EAAE,EAAE;aACd,aAAa;CACL,CAAC;AAEX,
|
|
1
|
+
{"version":3,"file":"subagent.d.ts","sourceRoot":"","sources":["../../src/harness/subagent.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EACZ,oBAAoB,EACpB,aAAa,EACd,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAe,KAAK,GAAG,EAAyB,KAAK,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACjG,OAAO,EAAc,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EAEf,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EAEjB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAWpB,eAAO,MAAM,uBAAuB;aAClC,QAAQ,EAAE,GAAG;aACb,UAAU,EAAE,EAAE;aACd,aAAa;CACL,CAAC;AAEX,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAyF3C,UAAU,kBAAkB,CAAC,aAAa,SAAS,OAAO,GAAG,SAAS,GAAG,SAAS;IAChF,OAAO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DurationMs: 10 * 60 * 1000,
|
|
15
15
|
};
|
|
16
|
-
/** Time allowed for an aborted subagent to settle before detached cleanup. */
|
|
17
16
|
export const SUBAGENT_ABORT_GRACE_MS = 100;
|
|
18
17
|
const SCHEMA_STRUCTURAL_KEYS = new Set([
|
|
19
18
|
"type",
|
|
@@ -53,18 +52,6 @@ function hydrateObject(schema, options) {
|
|
|
53
52
|
}
|
|
54
53
|
return Type.Object(props, options);
|
|
55
54
|
}
|
|
56
|
-
/**
|
|
57
|
-
* outputSchema arrives over the subagent tool as plain JSON (tool-call
|
|
58
|
-
* arguments never carry TypeBox's Kind symbol), but Value.Check dispatches
|
|
59
|
-
* purely on schema[Kind] and throws ValueCheckUnknownTypeError for anything
|
|
60
|
-
* without it. Hydrate plain JSON Schema into real TypeBox schema nodes so
|
|
61
|
-
* validation runs instead of throwing; schemas built with TypeBox already
|
|
62
|
-
* carry Kind and pass through untouched.
|
|
63
|
-
*
|
|
64
|
-
* Unsupported keywords ($ref, not, patternProperties, if/then/else) degrade to
|
|
65
|
-
* a permissive Unknown — fail-open by design: outputSchema is advisory output
|
|
66
|
-
* validation, not a security boundary.
|
|
67
|
-
*/
|
|
68
55
|
function hydrateSchema(schema) {
|
|
69
56
|
if (isRecord(schema) && Kind in schema)
|
|
70
57
|
return schema;
|
|
@@ -111,16 +98,6 @@ function hydrateSchema(schema) {
|
|
|
111
98
|
return Type.Unknown(options);
|
|
112
99
|
}
|
|
113
100
|
}
|
|
114
|
-
/**
|
|
115
|
-
* Translate a subagent session's event stream into short activity lines.
|
|
116
|
-
*
|
|
117
|
-
* The stream was always there — nothing subscribed to it, so every subagent
|
|
118
|
-
* was silent for its whole run and a slow step looked identical to a hung one.
|
|
119
|
-
*
|
|
120
|
-
* Text is reported as a growing character count rather than its content: it
|
|
121
|
-
* proves liveness during a long single-turn generation, which is the case with
|
|
122
|
-
* nothing else to show, without putting a half-written answer on screen.
|
|
123
|
-
*/
|
|
124
101
|
function reportSubagentActivity(session, onActivity) {
|
|
125
102
|
let characters = 0;
|
|
126
103
|
let reportedAt = 0;
|
|
@@ -155,8 +132,6 @@ function reportSubagentActivity(session, onActivity) {
|
|
|
155
132
|
if (delta?.type !== "text_delta" || !delta.delta)
|
|
156
133
|
return;
|
|
157
134
|
characters += delta.delta.length;
|
|
158
|
-
// Coarse steps: deltas arrive per token, and one report each would churn
|
|
159
|
-
// the dashboard for no added information.
|
|
160
135
|
if (characters - reportedAt < ACTIVITY_CHARS_STEP)
|
|
161
136
|
return;
|
|
162
137
|
reportedAt = characters;
|
|
@@ -164,13 +139,10 @@ function reportSubagentActivity(session, onActivity) {
|
|
|
164
139
|
return;
|
|
165
140
|
}
|
|
166
141
|
if (event.type === "auto_retry_start") {
|
|
167
|
-
// The most valuable line here: a retry is the usual reason a run goes
|
|
168
|
-
// quiet for minutes, and it was completely invisible.
|
|
169
142
|
report("retrying after an error");
|
|
170
143
|
}
|
|
171
144
|
});
|
|
172
145
|
}
|
|
173
|
-
/** How much new text earns a fresh activity line during a long generation. */
|
|
174
146
|
const ACTIVITY_CHARS_STEP = 250;
|
|
175
147
|
function resolveBudget(budget) {
|
|
176
148
|
const resolved = { ...DEFAULT_SUBAGENT_BUDGET, ...budget };
|
|
@@ -260,12 +232,6 @@ function normalizedParentContext(request, messages) {
|
|
|
260
232
|
"</parent_reference_context>",
|
|
261
233
|
].join("\n");
|
|
262
234
|
}
|
|
263
|
-
/**
|
|
264
|
-
* The evidence policy has to name the actual grant. Told to "use granted
|
|
265
|
-
* tools" while holding none, a model will write a tool call as prose and
|
|
266
|
-
* hand that text back as its answer — which then flows to dependent DAG
|
|
267
|
-
* nodes as if it were a finding.
|
|
268
|
-
*/
|
|
269
235
|
function groundingPolicy(toolNames) {
|
|
270
236
|
if (toolNames.length === 0) {
|
|
271
237
|
return [
|
|
@@ -295,12 +261,6 @@ function buildSystemPrompt(base, outputSchema, toolNames) {
|
|
|
295
261
|
JSON.stringify(outputSchema),
|
|
296
262
|
].join("\n");
|
|
297
263
|
}
|
|
298
|
-
/**
|
|
299
|
-
* Every SubagentRunResult's metric fields are born here — one derivation from
|
|
300
|
-
* the session's run stats, so adding a metric is one edit and no terminal
|
|
301
|
-
* site can drift (the abort branch once shipped without toolCallCounts). The
|
|
302
|
-
* terminal sites state only what differs: status, error, text.
|
|
303
|
-
*/
|
|
304
264
|
function baseRunResult(runId, model, startedAt, stats) {
|
|
305
265
|
const usage = stats?.usage ?? createEmptyUsage();
|
|
306
266
|
return {
|
|
@@ -318,13 +278,6 @@ function baseRunResult(runId, model, startedAt, stats) {
|
|
|
318
278
|
function finalAssistant(messages) {
|
|
319
279
|
return messages.findLast((message) => message.role === "assistant");
|
|
320
280
|
}
|
|
321
|
-
/**
|
|
322
|
-
* Execute one non-recursive, fresh subagent run. Never rejects: every
|
|
323
|
-
* failure — including request validation — is a result with a terminal
|
|
324
|
-
* status, so batch callers (`tasks` / `dag`) can never orphan in-flight
|
|
325
|
-
* sibling runs on one bad request. Usage is reported once, after the
|
|
326
|
-
* underlying run settles; an aborted run may report it from detached cleanup.
|
|
327
|
-
*/
|
|
328
281
|
export async function runSubagent(options) {
|
|
329
282
|
const execution = await executeBoundedSubagentRun(options);
|
|
330
283
|
if (execution.cleanup) {
|
|
@@ -396,12 +349,6 @@ async function executeBoundedSubagentRun(options) {
|
|
|
396
349
|
}
|
|
397
350
|
}
|
|
398
351
|
function noop() { }
|
|
399
|
-
/**
|
|
400
|
-
* Expand `request.profile` into the concrete capability set it names. Most
|
|
401
|
-
* profile budgets are caps that callers may only tighten. Token budgets are
|
|
402
|
-
* different: the effective allowance is the larger of the profile default and
|
|
403
|
-
* the caller's request.
|
|
404
|
-
*/
|
|
405
352
|
function resolveProfile(request, options) {
|
|
406
353
|
if (!request.profile)
|
|
407
354
|
return request;
|
|
@@ -579,7 +526,7 @@ async function executeSubagentRun(options) {
|
|
|
579
526
|
if (terminalSignal)
|
|
580
527
|
return;
|
|
581
528
|
terminalSignal = reason;
|
|
582
|
-
run?.session.abort();
|
|
529
|
+
run?.session.abort(reason);
|
|
583
530
|
notifyAbort();
|
|
584
531
|
};
|
|
585
532
|
const onAbort = () => abort("cancelled");
|
|
@@ -613,20 +560,10 @@ async function executeSubagentRun(options) {
|
|
|
613
560
|
request.signal?.removeEventListener("abort", onAbort);
|
|
614
561
|
}
|
|
615
562
|
}
|
|
616
|
-
/**
|
|
617
|
-
* Process-wide subagent fan-out account. The per-conversation queues
|
|
618
|
-
* serialize agent runs, and each run's subagent tool bounds its own fan-out
|
|
619
|
-
* — but without a shared ceiling, N busy conversations hold N × per-run-cap
|
|
620
|
-
* live subagent sessions. Every subagent launch draws a slot from one shared
|
|
621
|
-
* pool; the per-run cap and this global ceiling are the two bounds, enforced
|
|
622
|
-
* where each concrete subagent session is launched.
|
|
623
|
-
*/
|
|
624
563
|
function abortError() {
|
|
625
564
|
return new DOMException("The operation was aborted", "AbortError");
|
|
626
565
|
}
|
|
627
|
-
/** Default process-wide ceiling on concurrently live subagent sessions. */
|
|
628
566
|
export const DEFAULT_GLOBAL_SUBAGENT_SLOTS = 8;
|
|
629
|
-
/** Async slot pool: at most `capacity` concurrent holders, FIFO waiters. */
|
|
630
567
|
export class SubagentSlotPool {
|
|
631
568
|
constructor(capacity) {
|
|
632
569
|
this.capacity = capacity;
|
|
@@ -636,14 +573,9 @@ export class SubagentSlotPool {
|
|
|
636
573
|
throw new Error(`SubagentSlotPool capacity must be >= 1, got ${capacity}`);
|
|
637
574
|
}
|
|
638
575
|
}
|
|
639
|
-
/** Currently held slots (for tests and capacity reporting). */
|
|
640
576
|
get inFlight() {
|
|
641
577
|
return this.held;
|
|
642
578
|
}
|
|
643
|
-
/**
|
|
644
|
-
* Resolve with a release function once a slot frees up. Call the release
|
|
645
|
-
* exactly once; releasing hands the slot to the oldest waiter.
|
|
646
|
-
*/
|
|
647
579
|
async acquire(signal) {
|
|
648
580
|
if (signal?.aborted)
|
|
649
581
|
throw abortError();
|
|
@@ -680,7 +612,6 @@ export class SubagentSlotPool {
|
|
|
680
612
|
};
|
|
681
613
|
}
|
|
682
614
|
}
|
|
683
|
-
/** A pool that never blocks — the default when no shared ceiling is wired. */
|
|
684
615
|
export function unboundedSlotPool() {
|
|
685
616
|
return new SubagentSlotPool(Number.MAX_SAFE_INTEGER);
|
|
686
617
|
}
|