operon-agents-core 0.1.0-alpha.2 → 0.1.0-alpha.21
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/dist/agent/agent.d.ts +8 -7
- package/dist/agent/compose-hooks.d.ts +10 -1
- package/dist/agent/compose-hooks.js +61 -6
- package/dist/agent/concurrency.js +1 -1
- package/dist/agent/context-report.d.ts +2 -2
- package/dist/agent/durable-state.d.ts +22 -0
- package/dist/agent/durable-state.js +54 -0
- package/dist/agent/index.d.ts +2 -2
- package/dist/agent/index.js +1 -1
- package/dist/agent/instruction-context.d.ts +6 -6
- package/dist/agent/instruction-context.js +23 -23
- package/dist/agent/profile-builtins.js +1 -1
- package/dist/agent/run-support.d.ts +1 -1
- package/dist/agent/run-support.js +6 -5
- package/dist/agent/runner.d.ts +25 -22
- package/dist/agent/runner.js +217 -121
- package/dist/agent/session.d.ts +262 -156
- package/dist/agent/session.js +590 -418
- package/dist/agent/subagent-tools.js +3 -3
- package/dist/agent/subagent.js +28 -13
- package/dist/agent/toolset.d.ts +1 -0
- package/dist/agent/toolset.js +13 -7
- package/dist/agent/workflow/journal.d.ts +2 -2
- package/dist/agent/workflow/journal.js +2 -2
- package/dist/agent/workflow/manager.d.ts +1 -1
- package/dist/agent/workflow/manager.js +1 -1
- package/dist/agent/workflow/prompt.js +2 -2
- package/dist/agent/workflow/sandbox.d.ts +1 -1
- package/dist/agent/workflow/sandbox.js +1 -1
- package/dist/agent/workflow/tool.js +30 -43
- package/dist/agent/worktree.d.ts +8 -8
- package/dist/agent/worktree.js +15 -15
- package/dist/capabilities/assembler.d.ts +29 -5
- package/dist/capabilities/assembler.js +85 -9
- package/dist/capabilities/background/code-task.d.ts +43 -0
- package/dist/capabilities/background/code-task.js +75 -0
- package/dist/capabilities/background/command-task.d.ts +9 -2
- package/dist/capabilities/background/command-task.js +22 -6
- package/dist/capabilities/background/index.d.ts +6 -1
- package/dist/capabilities/background/index.js +26 -20
- package/dist/capabilities/background/manager.d.ts +57 -1
- package/dist/capabilities/background/manager.js +210 -45
- package/dist/capabilities/background/persist-disk.d.ts +1 -1
- package/dist/capabilities/background/persist-disk.js +1 -1
- package/dist/capabilities/background/persist.js +4 -2
- package/dist/capabilities/background/projections.d.ts +16 -0
- package/dist/capabilities/background/projections.js +86 -0
- package/dist/capabilities/background/stall-watchdog.d.ts +41 -0
- package/dist/capabilities/background/stall-watchdog.js +85 -0
- package/dist/capabilities/background/task.d.ts +8 -7
- package/dist/capabilities/background/tools.js +33 -7
- package/dist/capabilities/capability-data.d.ts +52 -0
- package/dist/capabilities/capability-data.js +88 -0
- package/dist/capabilities/capability-state.d.ts +2 -4
- package/dist/capabilities/capability-state.js +5 -23
- package/dist/capabilities/capability.d.ts +203 -38
- package/dist/capabilities/compaction/index.js +10 -4
- package/dist/capabilities/compaction/service.d.ts +20 -5
- package/dist/capabilities/compaction/service.js +27 -11
- package/dist/capabilities/goal/goal-store.d.ts +76 -12
- package/dist/capabilities/goal/goal-store.js +137 -53
- package/dist/capabilities/goal/index.d.ts +1 -1
- package/dist/capabilities/goal/index.js +30 -7
- package/dist/capabilities/index.d.ts +9 -6
- package/dist/capabilities/index.js +4 -3
- package/dist/capabilities/plan/index.js +22 -5
- package/dist/capabilities/plan/plan-mode.d.ts +30 -9
- package/dist/capabilities/plan/plan-mode.js +57 -32
- package/dist/capabilities/plan/tools.js +1 -1
- package/dist/capabilities/skills/flow-provider.js +3 -3
- package/dist/capabilities/skills/index.d.ts +13 -1
- package/dist/capabilities/skills/index.js +30 -21
- package/dist/capabilities/skills/parser.d.ts +2 -2
- package/dist/capabilities/skills/parser.js +3 -3
- package/dist/capabilities/skills/registry.d.ts +5 -6
- package/dist/capabilities/skills/registry.js +6 -9
- package/dist/capabilities/skills/scanner.d.ts +3 -3
- package/dist/capabilities/skills/scanner.js +14 -14
- package/dist/capabilities/skills/service.d.ts +2 -1
- package/dist/capabilities/skills/service.js +3 -3
- package/dist/capabilities/skills/skill-tool.d.ts +2 -0
- package/dist/capabilities/skills/skill-tool.js +1 -1
- package/dist/capabilities/task/index.js +2 -1
- package/dist/capabilities/task/persist-disk.d.ts +1 -1
- package/dist/capabilities/task/persist-disk.js +1 -1
- package/dist/capabilities/task/persist.js +1 -1
- package/dist/capabilities/todo/index.js +11 -6
- package/dist/capabilities/todo/injector.js +2 -1
- package/dist/capabilities/todo/todo-store.d.ts +28 -7
- package/dist/capabilities/todo/todo-store.js +44 -11
- package/dist/capabilities/todo/tools.js +8 -3
- package/dist/capabilities/tool-provider.d.ts +3 -3
- package/dist/capabilities/user-hooks/engine.d.ts +3 -3
- package/dist/capabilities/user-hooks/engine.js +7 -7
- package/dist/capabilities/user-hooks/index.js +2 -1
- package/dist/capabilities/workflow/index.d.ts +5 -3
- package/dist/capabilities/workflow/index.js +3 -2
- package/dist/commands/index.js +34 -32
- package/dist/config/index.d.ts +1 -1
- package/dist/config/provider-manager.js +0 -28
- package/dist/config/schema.d.ts +53 -4
- package/dist/config/schema.js +53 -1
- package/dist/events/events.d.ts +43 -11
- package/dist/events/events.js +1 -0
- package/dist/events/index.d.ts +2 -2
- package/dist/events/index.js +1 -1
- package/dist/events/projection.d.ts +49 -1
- package/dist/events/projection.js +144 -19
- package/dist/events/publisher.js +2 -21
- package/dist/home.d.ts +1 -1
- package/dist/home.js +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/internal.d.ts +5 -2
- package/dist/internal.js +5 -2
- package/dist/llm/define-model.d.ts +4 -0
- package/dist/llm/define-model.js +63 -25
- package/dist/llm/index.d.ts +1 -0
- package/dist/llm/index.js +1 -0
- package/dist/llm/model.d.ts +2 -0
- package/dist/llm/provider.d.ts +17 -0
- package/dist/llm/provider.js +14 -0
- package/dist/llm/retry.js +1 -1
- package/dist/loop/context.d.ts +21 -1
- package/dist/loop/context.js +47 -9
- package/dist/loop/events.d.ts +5 -1
- package/dist/loop/index.d.ts +2 -2
- package/dist/loop/index.js +1 -1
- package/dist/loop/interruption.d.ts +9 -4
- package/dist/loop/interruption.js +11 -25
- package/dist/loop/run-turn.d.ts +16 -3
- package/dist/loop/run-turn.js +13 -4
- package/dist/loop/steer.d.ts +78 -12
- package/dist/loop/steer.js +101 -38
- package/dist/loop/tool-call.d.ts +13 -2
- package/dist/loop/tool-call.js +135 -5
- package/dist/loop/turn-step.d.ts +13 -2
- package/dist/loop/turn-step.js +29 -7
- package/dist/loop/types.d.ts +6 -0
- package/dist/mcp/auth-tool.d.ts +3 -1
- package/dist/mcp/auth-tool.js +2 -2
- package/dist/mcp/capability.d.ts +13 -0
- package/dist/mcp/capability.js +36 -17
- package/dist/mcp/config-loader.d.ts +5 -5
- package/dist/mcp/config-loader.js +17 -17
- package/dist/mcp/credentials.d.ts +35 -0
- package/dist/mcp/credentials.js +2 -0
- package/dist/mcp/filter.d.ts +2 -2
- package/dist/mcp/index.d.ts +4 -3
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/manager.d.ts +108 -6
- package/dist/mcp/manager.js +262 -18
- package/dist/mcp/oauth/callback-server.d.ts +10 -1
- package/dist/mcp/oauth/callback-server.js +82 -16
- package/dist/mcp/oauth/index.d.ts +2 -2
- package/dist/mcp/oauth/provider.d.ts +18 -0
- package/dist/mcp/oauth/provider.js +31 -1
- package/dist/mcp/oauth/service.d.ts +9 -3
- package/dist/mcp/oauth/service.js +29 -4
- package/dist/mcp/sdk-transport.js +1 -1
- package/dist/mcp/server.js +1 -1
- package/dist/permission/auto-approver/prompts-data.d.ts +1 -1
- package/dist/permission/auto-approver/prompts-data.js +1 -1
- package/dist/permission/manager.d.ts +5 -3
- package/dist/permission/manager.js +7 -3
- package/dist/permission/policies.d.ts +2 -2
- package/dist/permission/policies.js +4 -4
- package/dist/plugins/fields.d.ts +14 -0
- package/dist/plugins/fields.js +30 -0
- package/dist/plugins/hooks.d.ts +2 -2
- package/dist/plugins/hooks.js +12 -12
- package/dist/plugins/index.js +1 -0
- package/dist/plugins/manager.d.ts +8 -3
- package/dist/plugins/manager.js +18 -7
- package/dist/plugins/manifest.d.ts +2 -2
- package/dist/plugins/manifest.js +101 -91
- package/dist/plugins/marketplace.js +76 -57
- package/dist/plugins/store.d.ts +3 -3
- package/dist/plugins/store.js +6 -6
- package/dist/protocol/index.d.ts +1 -1
- package/dist/store/catalog-store.d.ts +4 -1
- package/dist/store/catalog-store.js +5 -1
- package/dist/store/checkpointing-store.d.ts +41 -0
- package/dist/store/checkpointing-store.js +86 -0
- package/dist/store/disk-store.d.ts +8 -0
- package/dist/store/disk-store.js +127 -5
- package/dist/store/index.d.ts +3 -2
- package/dist/store/index.js +2 -1
- package/dist/store/log-store.d.ts +9 -1
- package/dist/store/log-store.js +68 -4
- package/dist/store/migrate.d.ts +8 -2
- package/dist/store/migrate.js +9 -2
- package/dist/store/origin.d.ts +31 -6
- package/dist/store/origin.js +0 -14
- package/dist/store/pg.d.ts +1 -0
- package/dist/store/pg.js +37 -2
- package/dist/store/redis.d.ts +1 -0
- package/dist/store/redis.js +30 -0
- package/dist/store/repository.d.ts +13 -1
- package/dist/store/repository.js +45 -2
- package/dist/store/session-catalog.d.ts +4 -0
- package/dist/store/session-catalog.js +6 -0
- package/dist/store/storage.js +3 -0
- package/dist/store/store.d.ts +97 -34
- package/dist/store/store.js +64 -10
- package/dist/telemetry/appender.d.ts +43 -0
- package/dist/telemetry/appender.js +46 -0
- package/dist/telemetry/events.d.ts +142 -0
- package/dist/telemetry/events.js +141 -0
- package/dist/telemetry/index.d.ts +10 -0
- package/dist/telemetry/index.js +6 -0
- package/dist/telemetry/projection.d.ts +23 -0
- package/dist/telemetry/projection.js +185 -0
- package/dist/telemetry/redact.d.ts +20 -0
- package/dist/telemetry/redact.js +40 -0
- package/dist/telemetry/service.d.ts +49 -0
- package/dist/telemetry/service.js +137 -0
- package/dist/testing.d.ts +58 -0
- package/dist/testing.js +123 -0
- package/dist/tool/background.d.ts +9 -6
- package/dist/tool/background.js +7 -1
- package/dist/tool/builtin/ask-user-question.js +6 -5
- package/dist/tool/builtin/bash.d.ts +6 -0
- package/dist/tool/builtin/bash.js +79 -42
- package/dist/tool/builtin/edit.js +82 -109
- package/dist/tool/builtin/glob.js +13 -13
- package/dist/tool/builtin/grep.js +13 -13
- package/dist/tool/builtin/read.js +25 -15
- package/dist/tool/builtin/write.js +49 -33
- package/dist/tool/define.d.ts +14 -8
- package/dist/tool/define.js +8 -2
- package/dist/tool/{machine-base.d.ts → environment-base.d.ts} +37 -37
- package/dist/tool/{machine-base.js → environment-base.js} +45 -119
- package/dist/tool/{machine-local.d.ts → environment-local.d.ts} +9 -8
- package/dist/tool/{machine-local.js → environment-local.js} +60 -81
- package/dist/tool/{machine-null.d.ts → environment-null.d.ts} +9 -9
- package/dist/tool/{machine-null.js → environment-null.js} +9 -9
- package/dist/tool/{machine-ssh.d.ts → environment-ssh.d.ts} +33 -18
- package/dist/tool/{machine-ssh.js → environment-ssh.js} +118 -149
- package/dist/tool/{machine.d.ts → environment.d.ts} +53 -82
- package/dist/tool/environment.js +2 -0
- package/dist/tool/file-freshness.d.ts +33 -19
- package/dist/tool/file-freshness.js +39 -30
- package/dist/tool/filesystem-tools.d.ts +1 -1
- package/dist/tool/filesystem-tools.js +1 -1
- package/dist/tool/git-context.d.ts +2 -2
- package/dist/tool/git-context.js +8 -8
- package/dist/tool/index.d.ts +12 -12
- package/dist/tool/index.js +12 -10
- package/dist/tool/policies/path-access.d.ts +4 -4
- package/dist/tool/policies/path-access.js +12 -12
- package/dist/tool/questions.d.ts +8 -0
- package/dist/tool/search/catalog.d.ts +37 -0
- package/dist/tool/search/catalog.js +182 -0
- package/dist/tool/search/deferral.d.ts +3 -2
- package/dist/tool/search/loaded.d.ts +32 -0
- package/dist/tool/search/loaded.js +96 -0
- package/dist/tool/search/search-tool.d.ts +2 -6
- package/dist/tool/search/search-tool.js +16 -15
- package/dist/tool/shell-env.js +4 -0
- package/dist/tool/support/bash-paths.js +38 -7
- package/dist/tool/support/{machine-ops.d.ts → environment-ops.d.ts} +12 -14
- package/dist/tool/support/{machine-ops.js → environment-ops.js} +21 -2
- package/dist/tool/support/git-worktree.d.ts +3 -3
- package/dist/tool/support/git-worktree.js +6 -6
- package/dist/tool/support/rg-locator.d.ts +6 -6
- package/dist/tool/support/rg-locator.js +6 -6
- package/dist/tool/support/ripgrep-run.d.ts +5 -5
- package/dist/tool/support/ripgrep-run.js +3 -3
- package/dist/tool/support/tool-path.d.ts +3 -3
- package/dist/tool/support/tool-path.js +7 -7
- package/dist/tool/types.d.ts +54 -10
- package/dist/tool/web/fetch-url.js +1 -1
- package/dist/tool/web/web-search.js +1 -1
- package/dist/tool/workspace-spec.d.ts +3 -3
- package/dist/tool/workspace-spec.js +27 -27
- package/dist/tracing/bridge.d.ts +9 -1
- package/dist/tracing/bridge.js +307 -77
- package/dist/tracing/index.d.ts +2 -2
- package/dist/tracing/otel.d.ts +28 -1
- package/dist/tracing/otel.js +150 -38
- package/dist/tracing/processor.d.ts +22 -0
- package/dist/tracing/processor.js +2 -0
- package/dist/tracing/spans.d.ts +54 -0
- package/dist/tracing/spans.js +5 -0
- package/package.json +6 -2
- package/dist/tool/machine.js +0 -15
- package/dist/tool/search/activation.d.ts +0 -13
- package/dist/tool/search/activation.js +0 -31
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { defineTool } from "../../tool/define.js";
|
|
3
3
|
import { ToolAccesses } from "../../tool/access.js";
|
|
4
|
+
import { DEFAULT_ADDRESS } from "../../store/index.js";
|
|
4
5
|
import { TODO_LIST_TOOL_NAME } from "./todo-store.js";
|
|
5
6
|
export { TODO_LIST_TOOL_NAME } from "./todo-store.js";
|
|
6
7
|
const TODO_LIST_WRITE_REMINDER = "Ensure that you continue to use the todo list to track progress. Mark tasks done immediately after finishing them, and keep exactly one task in_progress when work is underway.";
|
|
@@ -34,12 +35,16 @@ export function todoListTool(store) {
|
|
|
34
35
|
approvalRule: TODO_LIST_TOOL_NAME,
|
|
35
36
|
accesses: ToolAccesses.none(),
|
|
36
37
|
display: { title },
|
|
37
|
-
run: async () => {
|
|
38
|
+
run: async (ctx) => {
|
|
39
|
+
// Whose list this is: the frame running the call. A subagent plans its own work, and
|
|
40
|
+
// its result lands in its own shard, so the fold on resume puts it back where it came
|
|
41
|
+
// from. `address` is absent only in a hand-built context — treat that as the root.
|
|
42
|
+
const address = ctx.address ?? DEFAULT_ADDRESS;
|
|
38
43
|
// Read mode carries the current list too, so a resumed/forked session reconstructs
|
|
39
44
|
// from the latest TodoList result even when the last write was on a parent node.
|
|
40
45
|
if (args.todos === undefined)
|
|
41
|
-
return todoResult(renderTodoList(store.get()), store.get());
|
|
42
|
-
const stored = store.set(args.todos);
|
|
46
|
+
return todoResult(renderTodoList(store.get(address)), store.get(address));
|
|
47
|
+
const stored = store.set(address, args.todos);
|
|
43
48
|
if (stored.length === 0)
|
|
44
49
|
return todoResult("Todo list cleared.", stored);
|
|
45
50
|
return todoResult(`Todo list updated.\n${renderTodoList(stored)}\n\n${TODO_LIST_WRITE_REMINDER}`, stored);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Tool } from "../tool/types.ts";
|
|
2
|
-
import type {
|
|
2
|
+
import type { RunContext } from "./capability.ts";
|
|
3
3
|
export interface ToolProvider {
|
|
4
4
|
readonly id: string;
|
|
5
|
-
listTools(ctx:
|
|
6
|
-
start?(ctx:
|
|
5
|
+
listTools(ctx: RunContext): Promise<readonly Tool[]> | readonly Tool[];
|
|
6
|
+
start?(ctx: RunContext): Promise<void> | void;
|
|
7
7
|
stop?(): Promise<void> | void;
|
|
8
8
|
}
|
|
9
9
|
export declare function staticToolProvider(id: string, tools: readonly Tool[]): ToolProvider;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Environment } from "../../tool/environment.ts";
|
|
2
2
|
import { type HookBlockResult, type HookDef, type HookEventType, type HookTriggerArgs } from "./types.ts";
|
|
3
3
|
export declare class HookEngine {
|
|
4
4
|
private readonly hooks;
|
|
5
|
-
private
|
|
5
|
+
private environment;
|
|
6
6
|
constructor(hooks: readonly HookDef[]);
|
|
7
|
-
|
|
7
|
+
attachEnvironment(environment: Environment): void;
|
|
8
8
|
has(event: HookEventType): boolean;
|
|
9
9
|
triggerBlock(event: HookEventType, args?: HookTriggerArgs): Promise<HookBlockResult>;
|
|
10
10
|
trigger(event: HookEventType, args?: HookTriggerArgs): Promise<string>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { DEFAULT_HOOK_TIMEOUT_MS, } from "./types.js";
|
|
2
2
|
export class HookEngine {
|
|
3
3
|
hooks;
|
|
4
|
-
|
|
4
|
+
environment = null;
|
|
5
5
|
constructor(hooks) {
|
|
6
6
|
this.hooks = hooks;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
this.
|
|
8
|
+
attachEnvironment(environment) {
|
|
9
|
+
this.environment = environment;
|
|
10
10
|
}
|
|
11
11
|
has(event) {
|
|
12
12
|
return this.hooks.some((h) => h.event === event);
|
|
@@ -65,11 +65,11 @@ export class HookEngine {
|
|
|
65
65
|
* timed-out hook has no opinion to report.
|
|
66
66
|
*/
|
|
67
67
|
async runHook(hook, args) {
|
|
68
|
-
if (!this.
|
|
69
|
-
throw new Error("HookEngine has no
|
|
68
|
+
if (!this.environment)
|
|
69
|
+
throw new Error("HookEngine has no environment attached.");
|
|
70
70
|
const timeoutMs = hook.timeout ?? DEFAULT_HOOK_TIMEOUT_MS;
|
|
71
|
-
const shell = this.
|
|
72
|
-
const result = await this.
|
|
71
|
+
const shell = this.environment.osInfo.shellPath || "/bin/sh";
|
|
72
|
+
const result = await this.environment.run([shell, "-c", hook.command], {
|
|
73
73
|
stdin: JSON.stringify(args.inputData ?? {}),
|
|
74
74
|
timeoutMs,
|
|
75
75
|
...(args.signal !== undefined ? { signal: args.signal } : {}),
|
|
@@ -50,6 +50,7 @@ export function userHooksCapability(hooks) {
|
|
|
50
50
|
let unsubscribe;
|
|
51
51
|
return {
|
|
52
52
|
name: "user-hooks",
|
|
53
|
+
contract: "invariant",
|
|
53
54
|
policies: [preToolCallHookPolicy(engine)],
|
|
54
55
|
injectors: [new SessionStartInjector(() => sessionStartOutput)],
|
|
55
56
|
hooks: {
|
|
@@ -67,7 +68,7 @@ export function userHooksCapability(hooks) {
|
|
|
67
68
|
},
|
|
68
69
|
service: engine,
|
|
69
70
|
openSession: async (ctx) => {
|
|
70
|
-
engine.
|
|
71
|
+
engine.attachEnvironment(ctx.environment);
|
|
71
72
|
if (engine.has("SessionStart")) {
|
|
72
73
|
sessionStartOutput = await engine
|
|
73
74
|
.trigger("SessionStart", { inputData: { session_id: ctx.sessionId }, signal: ctx.signal })
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Workflow capability — exposes the WorkflowManager as a session service
|
|
3
|
-
* (`session.workflow`), mirroring how `background` exposes the
|
|
3
|
+
* (`session.workflow`, i.e. `session.service("workflow")`), mirroring how `background` exposes the
|
|
4
|
+
* BackgroundManager.
|
|
4
5
|
*
|
|
5
6
|
* It contributes NO tools: the `Workflow` tool is built by the Runner (it needs
|
|
6
7
|
* runLoop to spawn subagents), and reaches this service through the session to read
|
|
7
8
|
* its configured directories and persist run snapshots. The capability's job is
|
|
8
|
-
* purely to make the management/read
|
|
9
|
-
* `/workflows` command.
|
|
9
|
+
* purely to make the management/read environment available to upper layers and the
|
|
10
|
+
* `/workflows` command. A session opened WITHOUT this capability still has a
|
|
11
|
+
* `workflow` service: `Session.open` provides an in-memory fallback.
|
|
10
12
|
*/
|
|
11
13
|
import type { Capability } from "../capability.ts";
|
|
12
14
|
import { WorkflowManager } from "../../agent/workflow/manager.ts";
|
|
@@ -3,10 +3,11 @@ export { WorkflowManager } from "../../agent/workflow/manager.js";
|
|
|
3
3
|
export function workflowCapability(manager = new WorkflowManager()) {
|
|
4
4
|
return {
|
|
5
5
|
name: "workflow",
|
|
6
|
+
contract: "detachable",
|
|
6
7
|
service: manager,
|
|
7
8
|
openSession: (ctx) => {
|
|
8
|
-
// Bookkeeping goes through the SessionStore, never the
|
|
9
|
-
//
|
|
9
|
+
// Bookkeeping goes through the SessionStore, never the Environment: without a durable
|
|
10
|
+
// store the manager stays on its in-memory store for the session's lifetime.
|
|
10
11
|
if (ctx.store !== undefined)
|
|
11
12
|
manager.attachStore(ctx.store);
|
|
12
13
|
},
|
package/dist/commands/index.js
CHANGED
|
@@ -33,15 +33,17 @@ export class CommandRegistry {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
|
-
* Commands
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
36
|
+
* Commands the session's open capabilities contribute: each one's `commands`, plus — for the
|
|
37
|
+
* extensions runtime, whose commands are registered while the session runs — any service that
|
|
38
|
+
* exposes `sessionCommands(): HeadlessCommand[]`. No names, no imports: the registry stays
|
|
39
|
+
* ignorant of who contributes.
|
|
40
40
|
*/
|
|
41
41
|
function dynamicCommands(session) {
|
|
42
42
|
const out = [];
|
|
43
43
|
for (const capability of session.capabilities) {
|
|
44
|
-
|
|
44
|
+
if (capability.commands !== undefined)
|
|
45
|
+
out.push(...capability.commands);
|
|
46
|
+
const service = session.service(capability.name);
|
|
45
47
|
if (typeof service?.sessionCommands === "function")
|
|
46
48
|
out.push(...service.sessionCommands());
|
|
47
49
|
}
|
|
@@ -69,7 +71,7 @@ export function registerExtensionCommands(registry) {
|
|
|
69
71
|
name: "skills",
|
|
70
72
|
description: "List available skills.",
|
|
71
73
|
run: async ({ session }) => {
|
|
72
|
-
const skills = await session.listSkills();
|
|
74
|
+
const skills = await session.skills.listSkills();
|
|
73
75
|
return { ok: true, message: `${skills.length} skill(s) available.`, data: skills };
|
|
74
76
|
},
|
|
75
77
|
});
|
|
@@ -80,7 +82,7 @@ export function registerExtensionCommands(registry) {
|
|
|
80
82
|
const { head: name, tail: skillArgs } = splitHead(args);
|
|
81
83
|
if (name.length === 0)
|
|
82
84
|
return { ok: false, message: "Usage: /skill <name> [args] or /skill:<name> [args]" };
|
|
83
|
-
const activation = await session.activateSkill({ name, args: skillArgs, trigger: "user-slash" });
|
|
85
|
+
const activation = await session.skills.activateSkill({ name, args: skillArgs, trigger: "user-slash" });
|
|
84
86
|
return { ok: true, message: `Activated skill ${activation.skillName}.`, data: activation };
|
|
85
87
|
},
|
|
86
88
|
});
|
|
@@ -90,38 +92,38 @@ export function registerExtensionCommands(registry) {
|
|
|
90
92
|
run: async ({ session }, rawArgs) => {
|
|
91
93
|
const { head: sub, tail } = splitHead(rawArgs);
|
|
92
94
|
if (sub.length === 0 || sub === "list") {
|
|
93
|
-
const plugins = await session.
|
|
95
|
+
const plugins = await session.plugins.summaries();
|
|
94
96
|
return { ok: true, message: `${plugins.length} plugin(s) installed.`, data: plugins };
|
|
95
97
|
}
|
|
96
98
|
if (sub === "install") {
|
|
97
99
|
if (tail.length === 0)
|
|
98
100
|
return { ok: false, message: "Usage: /plugins install <local-path-or-zip-url>" };
|
|
99
|
-
const plugin = await session.
|
|
101
|
+
const plugin = await session.plugins.installSummary(tail);
|
|
100
102
|
return { ok: true, message: `Installed plugin ${plugin.id}.`, data: plugin };
|
|
101
103
|
}
|
|
102
104
|
if (sub === "enable" || sub === "disable") {
|
|
103
105
|
const { head: id } = splitHead(tail);
|
|
104
106
|
if (id.length === 0)
|
|
105
107
|
return { ok: false, message: `Usage: /plugins ${sub} <id>` };
|
|
106
|
-
await session.
|
|
108
|
+
await session.plugins.setEnabled(id, sub === "enable");
|
|
107
109
|
return { ok: true, message: `${sub === "enable" ? "Enabled" : "Disabled"} plugin ${id}.` };
|
|
108
110
|
}
|
|
109
111
|
if (sub === "remove") {
|
|
110
112
|
const { head: id } = splitHead(tail);
|
|
111
113
|
if (id.length === 0)
|
|
112
114
|
return { ok: false, message: "Usage: /plugins remove <id>" };
|
|
113
|
-
await session.
|
|
115
|
+
await session.plugins.remove(id);
|
|
114
116
|
return { ok: true, message: `Removed plugin ${id}.` };
|
|
115
117
|
}
|
|
116
118
|
if (sub === "reload") {
|
|
117
|
-
const summary = await session.
|
|
119
|
+
const summary = await session.plugins.reload();
|
|
118
120
|
return { ok: true, message: "Reloaded plugins.", data: summary };
|
|
119
121
|
}
|
|
120
122
|
if (sub === "info") {
|
|
121
123
|
const { head: id } = splitHead(tail);
|
|
122
124
|
if (id.length === 0)
|
|
123
125
|
return { ok: false, message: "Usage: /plugins info <id>" };
|
|
124
|
-
const info = await session.
|
|
126
|
+
const info = await session.plugins.info(id);
|
|
125
127
|
return info === undefined
|
|
126
128
|
? { ok: false, message: `Plugin "${id}" is not installed.` }
|
|
127
129
|
: { ok: true, message: `Plugin ${info.id}.`, data: info };
|
|
@@ -133,10 +135,10 @@ export function registerExtensionCommands(registry) {
|
|
|
133
135
|
if ((action !== "enable" && action !== "disable") || id.length === 0 || server.length === 0) {
|
|
134
136
|
return { ok: false, message: "Usage: /plugins mcp enable|disable <id> <server>" };
|
|
135
137
|
}
|
|
136
|
-
await session.
|
|
138
|
+
await session.plugins.setMcpServerEnabled(id, server, action === "enable");
|
|
137
139
|
return { ok: true, message: `${action === "enable" ? "Enabled" : "Disabled"} MCP server ${server} for ${id}.` };
|
|
138
140
|
}
|
|
139
|
-
const info = await session.
|
|
141
|
+
const info = await session.plugins.info(sub);
|
|
140
142
|
return info === undefined
|
|
141
143
|
? { ok: false, message: `Unknown /plugins action or plugin: ${sub}` }
|
|
142
144
|
: { ok: true, message: `Plugin ${info.id}.`, data: info };
|
|
@@ -152,21 +154,21 @@ export function registerCapabilityCommands(registry) {
|
|
|
152
154
|
const { head: sub, tail } = splitHead(rawArgs);
|
|
153
155
|
if (sub.length === 0 || sub === "list" || sub === "active") {
|
|
154
156
|
const activeOnly = sub === "active" || tail.trim() === "active";
|
|
155
|
-
const tasks =
|
|
157
|
+
const tasks = session.requireService("background").list(activeOnly, undefined);
|
|
156
158
|
return { ok: true, message: `${tasks.length} background task(s).`, data: tasks };
|
|
157
159
|
}
|
|
158
160
|
if (sub === "output") {
|
|
159
161
|
const { head: id } = splitHead(tail);
|
|
160
162
|
if (id.length === 0)
|
|
161
163
|
return { ok: false, message: "Usage: /tasks output <id>" };
|
|
162
|
-
const snapshot = await session.
|
|
164
|
+
const snapshot = await session.requireService("background").readOutput(id, 16 * 1024);
|
|
163
165
|
return { ok: true, message: `Output for task ${id}.`, data: snapshot };
|
|
164
166
|
}
|
|
165
167
|
if (sub === "stop") {
|
|
166
168
|
const { head: id, tail: reason } = splitHead(tail);
|
|
167
169
|
if (id.length === 0)
|
|
168
170
|
return { ok: false, message: "Usage: /tasks stop <id> [reason]" };
|
|
169
|
-
const info = await session.
|
|
171
|
+
const info = await session.requireService("background").stop(id, reason.length > 0 ? reason : undefined);
|
|
170
172
|
return info === undefined
|
|
171
173
|
? { ok: false, message: `No background task "${id}".` }
|
|
172
174
|
: { ok: true, message: `Stopped task ${id}.`, data: info };
|
|
@@ -180,7 +182,7 @@ export function registerCapabilityCommands(registry) {
|
|
|
180
182
|
run: async ({ session }, rawArgs) => {
|
|
181
183
|
const { head: sub, tail } = splitHead(rawArgs);
|
|
182
184
|
if (sub.length === 0 || sub === "show" || sub === "status") {
|
|
183
|
-
const goal = await session.
|
|
185
|
+
const goal = await session.goal.snapshot();
|
|
184
186
|
return goal === null
|
|
185
187
|
? { ok: true, message: "No active goal.", data: null }
|
|
186
188
|
: { ok: true, message: `Goal is ${goal.status}.`, data: goal };
|
|
@@ -189,16 +191,16 @@ export function registerCapabilityCommands(registry) {
|
|
|
189
191
|
const objective = tail.trim();
|
|
190
192
|
if (objective.length === 0)
|
|
191
193
|
return { ok: false, message: "Usage: /goal set <objective>" };
|
|
192
|
-
const goal = await session.
|
|
194
|
+
const goal = await session.goal.create({ objective });
|
|
193
195
|
return { ok: true, message: "Goal set.", data: goal };
|
|
194
196
|
}
|
|
195
197
|
if (sub === "pause" || sub === "resume" || sub === "cancel") {
|
|
196
198
|
const reason = tail.trim().length > 0 ? tail.trim() : undefined;
|
|
197
199
|
const goal = sub === "pause"
|
|
198
|
-
? await session.
|
|
200
|
+
? await session.goal.pause(reason)
|
|
199
201
|
: sub === "resume"
|
|
200
|
-
? await session.
|
|
201
|
-
: await session.
|
|
202
|
+
? await session.goal.resume(reason)
|
|
203
|
+
: await session.goal.cancel(reason);
|
|
202
204
|
if (goal === null)
|
|
203
205
|
return { ok: false, message: "No active goal." };
|
|
204
206
|
const verb = sub === "pause" ? "Paused" : sub === "resume" ? "Resumed" : "Cancelled";
|
|
@@ -208,7 +210,7 @@ export function registerCapabilityCommands(registry) {
|
|
|
208
210
|
const budget = parseGoalBudget(tail);
|
|
209
211
|
if (budget === undefined)
|
|
210
212
|
return { ok: false, message: "Usage: /goal budget <turns=N tokens=N wallClockMs=N>" };
|
|
211
|
-
const goal = await session.
|
|
213
|
+
const goal = await session.goal.changeBudget(budget);
|
|
212
214
|
if (goal === null)
|
|
213
215
|
return { ok: false, message: "No active goal." };
|
|
214
216
|
return { ok: true, message: "Goal budget updated.", data: goal };
|
|
@@ -223,14 +225,14 @@ export function registerCapabilityCommands(registry) {
|
|
|
223
225
|
run: async ({ session }, rawArgs) => {
|
|
224
226
|
const { head: sub, tail } = splitHead(rawArgs);
|
|
225
227
|
if (sub.length === 0 || sub === "list") {
|
|
226
|
-
const runs = await session.listWorkflows();
|
|
228
|
+
const runs = await session.background?.listWorkflows() ?? [];
|
|
227
229
|
return { ok: true, message: `${runs.length} workflow run(s).`, data: runs };
|
|
228
230
|
}
|
|
229
231
|
if (sub === "info" || sub === "show" || sub === "get") {
|
|
230
232
|
const { head: runId } = splitHead(tail);
|
|
231
233
|
if (runId.length === 0)
|
|
232
234
|
return { ok: false, message: "Usage: /workflows info <runId>" };
|
|
233
|
-
const run = await session.getWorkflow(runId);
|
|
235
|
+
const run = await session.background?.getWorkflow(runId);
|
|
234
236
|
return run === undefined
|
|
235
237
|
? { ok: false, message: `No workflow run "${runId}".` }
|
|
236
238
|
: { ok: true, message: `Workflow ${run.workflowName} is ${run.status}.`, data: run };
|
|
@@ -244,15 +246,15 @@ export function registerCapabilityCommands(registry) {
|
|
|
244
246
|
run: async ({ session }, rawArgs) => {
|
|
245
247
|
const { head: sub } = splitHead(rawArgs);
|
|
246
248
|
if (sub.length === 0 || sub === "show" || sub === "status") {
|
|
247
|
-
const plan = await session.
|
|
249
|
+
const plan = await session.plan.data();
|
|
248
250
|
return { ok: true, message: plan === null ? "Plan mode is off." : "Plan mode is on.", data: plan };
|
|
249
251
|
}
|
|
250
252
|
if (sub === "on" || sub === "enter") {
|
|
251
|
-
const plan = await session.
|
|
253
|
+
const plan = await session.plan.setEnabled(true);
|
|
252
254
|
return { ok: true, message: "Plan mode on.", data: plan };
|
|
253
255
|
}
|
|
254
256
|
if (sub === "off" || sub === "exit" || sub === "clear") {
|
|
255
|
-
const plan = await session.
|
|
257
|
+
const plan = await session.plan.setEnabled(false);
|
|
256
258
|
return { ok: true, message: "Plan mode off.", data: plan };
|
|
257
259
|
}
|
|
258
260
|
return { ok: false, message: `Unknown /plan action: ${sub}` };
|
|
@@ -264,17 +266,17 @@ export function registerCapabilityCommands(registry) {
|
|
|
264
266
|
run: async ({ session }, rawArgs) => {
|
|
265
267
|
const lower = rawArgs.trim().toLowerCase();
|
|
266
268
|
if (lower === "status" || lower === "pending") {
|
|
267
|
-
const pending = await session.
|
|
269
|
+
const pending = await session.compaction.pending();
|
|
268
270
|
return { ok: true, message: pending === null ? "No pending compaction." : "Compaction pending.", data: pending };
|
|
269
271
|
}
|
|
270
272
|
if (lower === "cancel") {
|
|
271
|
-
const cancelled = await session.
|
|
273
|
+
const cancelled = await session.compaction.cancel();
|
|
272
274
|
return cancelled === null
|
|
273
275
|
? { ok: false, message: "No pending compaction to cancel." }
|
|
274
276
|
: { ok: true, message: "Cancelled pending compaction.", data: cancelled };
|
|
275
277
|
}
|
|
276
278
|
const instruction = rawArgs.trim();
|
|
277
|
-
const pending =
|
|
279
|
+
const pending = session.compaction.request(instruction.length > 0 ? { instruction } : {});
|
|
278
280
|
return { ok: true, message: "Compaction requested.", data: pending };
|
|
279
281
|
},
|
|
280
282
|
});
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { AgentFrameworkConfigSchema, ModelCredentialsSchema, ModelAliasSchema, McpServerConfigSchema, PermissionRuleConfigSchema, ProviderConfigSchema, parseConfig, } from "./schema.ts";
|
|
2
|
-
export type { AgentFrameworkConfig, HookDefConfig, LoopControl, McpServerConfig, ModelAlias, ModelCredentialsConfig, PermissionConfig, PermissionRuleConfig, PluginRef, ProviderConfig, ProviderType, ThinkingConfig, } from "./schema.ts";
|
|
2
|
+
export type { AgentFrameworkConfig, HookDefConfig, LoopControl, McpServerConfig, McpOAuthClientConfig, ModelAlias, ModelCredentialsConfig, PermissionConfig, PermissionRuleConfig, PluginRef, ProviderConfig, ProviderType, ThinkingConfig, } from "./schema.ts";
|
|
3
3
|
export { mergeConfigs } from "./merge.ts";
|
|
4
4
|
export { ModelCatalog } from "./model-catalog.ts";
|
|
5
5
|
export type { ModelCapabilityInfo } from "./model-catalog.ts";
|
|
@@ -159,16 +159,6 @@ function configureKnownModel(model, providerId, config) {
|
|
|
159
159
|
...(config.customHeaders !== undefined
|
|
160
160
|
? { headers: { ...(model.headers ?? {}), ...config.customHeaders } }
|
|
161
161
|
: {}),
|
|
162
|
-
...(config.type === "kimi"
|
|
163
|
-
? { compat: { ...model.compat, deferredToolsMode: "kimi" } }
|
|
164
|
-
: config.type === "anthropic"
|
|
165
|
-
? {
|
|
166
|
-
compat: {
|
|
167
|
-
...model.compat,
|
|
168
|
-
supportsToolReferences: defaultAnthropicToolReferences(model.id),
|
|
169
|
-
},
|
|
170
|
-
}
|
|
171
|
-
: {}),
|
|
172
162
|
};
|
|
173
163
|
}
|
|
174
164
|
function buildCustomPiModel(alias, providerId, providerConfig) {
|
|
@@ -177,11 +167,6 @@ function buildCustomPiModel(alias, providerId, providerConfig) {
|
|
|
177
167
|
? ["text", "image"]
|
|
178
168
|
: ["text"];
|
|
179
169
|
const api = apiForProviderType(providerConfig.type);
|
|
180
|
-
const compat = providerConfig.type === "kimi"
|
|
181
|
-
? { deferredToolsMode: "kimi" }
|
|
182
|
-
: providerConfig.type === "anthropic"
|
|
183
|
-
? { supportsToolReferences: defaultAnthropicToolReferences(alias.model) }
|
|
184
|
-
: undefined;
|
|
185
170
|
return {
|
|
186
171
|
id: alias.model,
|
|
187
172
|
name: alias.displayName ?? alias.model,
|
|
@@ -198,7 +183,6 @@ function buildCustomPiModel(alias, providerId, providerConfig) {
|
|
|
198
183
|
...(providerConfig.customHeaders !== undefined
|
|
199
184
|
? { headers: providerConfig.customHeaders }
|
|
200
185
|
: {}),
|
|
201
|
-
...(compat !== undefined ? { compat } : {}),
|
|
202
186
|
};
|
|
203
187
|
}
|
|
204
188
|
function configuredAuth(providerId, config, base, resolveApiKey) {
|
|
@@ -328,17 +312,5 @@ function apiForProviderType(type) {
|
|
|
328
312
|
return "google-vertex";
|
|
329
313
|
}
|
|
330
314
|
}
|
|
331
|
-
function defaultAnthropicToolReferences(modelId) {
|
|
332
|
-
if (modelId.includes("haiku"))
|
|
333
|
-
return false;
|
|
334
|
-
const version = modelId.match(/^claude-(?:opus|sonnet|fable)-(\d+)(?:-(\d+))?(?:-|$)/);
|
|
335
|
-
if (version === null)
|
|
336
|
-
return false;
|
|
337
|
-
const major = Number(version[1]);
|
|
338
|
-
const minor = version[2] !== undefined && version[2].length < 8
|
|
339
|
-
? Number(version[2])
|
|
340
|
-
: 0;
|
|
341
|
-
return major > 4 || (major === 4 && minor >= 5);
|
|
342
|
-
}
|
|
343
315
|
export { UNKNOWN_CAPABILITY };
|
|
344
316
|
//# sourceMappingURL=provider-manager.js.map
|
package/dist/config/schema.d.ts
CHANGED
|
@@ -137,7 +137,13 @@ export declare const ThinkingConfigSchema: z.ZodObject<{
|
|
|
137
137
|
high: "high";
|
|
138
138
|
}>>;
|
|
139
139
|
}, z.core.$strip>;
|
|
140
|
-
export declare const
|
|
140
|
+
export declare const McpOAuthClientConfigSchema: z.ZodObject<{
|
|
141
|
+
clientId: z.ZodString;
|
|
142
|
+
clientSecret: z.ZodOptional<z.ZodString>;
|
|
143
|
+
callbackPort: z.ZodOptional<z.ZodNumber>;
|
|
144
|
+
callbackUrl: z.ZodOptional<z.ZodString>;
|
|
145
|
+
}, z.core.$strip>;
|
|
146
|
+
export declare const McpServerConfigSchema: z.ZodPreprocess<z.ZodPipe<z.ZodObject<{
|
|
141
147
|
type: z.ZodOptional<z.ZodEnum<{
|
|
142
148
|
stdio: "stdio";
|
|
143
149
|
http: "http";
|
|
@@ -160,6 +166,13 @@ export declare const McpServerConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
160
166
|
bearerTokenEnvVar: z.ZodOptional<z.ZodString>;
|
|
161
167
|
keepAliveIntervalMs: z.ZodOptional<z.ZodNumber>;
|
|
162
168
|
keepAliveTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
169
|
+
oauth: z.ZodOptional<z.ZodObject<{
|
|
170
|
+
clientId: z.ZodString;
|
|
171
|
+
clientSecret: z.ZodOptional<z.ZodString>;
|
|
172
|
+
callbackPort: z.ZodOptional<z.ZodNumber>;
|
|
173
|
+
callbackUrl: z.ZodOptional<z.ZodString>;
|
|
174
|
+
}, z.core.$strip>>;
|
|
175
|
+
scopes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
163
176
|
}, z.core.$strip>, z.ZodTransform<{
|
|
164
177
|
transport: "stdio" | "http";
|
|
165
178
|
command?: string | undefined;
|
|
@@ -176,6 +189,13 @@ export declare const McpServerConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
176
189
|
bearerTokenEnvVar?: string | undefined;
|
|
177
190
|
keepAliveIntervalMs?: number | undefined;
|
|
178
191
|
keepAliveTimeoutMs?: number | undefined;
|
|
192
|
+
oauth?: {
|
|
193
|
+
clientId: string;
|
|
194
|
+
clientSecret?: string | undefined;
|
|
195
|
+
callbackPort?: number | undefined;
|
|
196
|
+
callbackUrl?: string | undefined;
|
|
197
|
+
} | undefined;
|
|
198
|
+
scopes?: string[] | undefined;
|
|
179
199
|
}, {
|
|
180
200
|
type?: "stdio" | "http" | undefined;
|
|
181
201
|
transport?: "stdio" | "http" | undefined;
|
|
@@ -193,7 +213,14 @@ export declare const McpServerConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
193
213
|
bearerTokenEnvVar?: string | undefined;
|
|
194
214
|
keepAliveIntervalMs?: number | undefined;
|
|
195
215
|
keepAliveTimeoutMs?: number | undefined;
|
|
196
|
-
|
|
216
|
+
oauth?: {
|
|
217
|
+
clientId: string;
|
|
218
|
+
clientSecret?: string | undefined;
|
|
219
|
+
callbackPort?: number | undefined;
|
|
220
|
+
callbackUrl?: string | undefined;
|
|
221
|
+
} | undefined;
|
|
222
|
+
scopes?: string[] | undefined;
|
|
223
|
+
}>>>;
|
|
197
224
|
export declare const HookDefConfigSchema: z.ZodObject<{
|
|
198
225
|
event: z.ZodString;
|
|
199
226
|
matcher: z.ZodOptional<z.ZodString>;
|
|
@@ -297,7 +324,7 @@ export declare const AgentFrameworkConfigSchema: z.ZodObject<{
|
|
|
297
324
|
high: "high";
|
|
298
325
|
}>>;
|
|
299
326
|
}, z.core.$strip>>;
|
|
300
|
-
mcpServers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodObject<{
|
|
327
|
+
mcpServers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodPreprocess<z.ZodPipe<z.ZodObject<{
|
|
301
328
|
type: z.ZodOptional<z.ZodEnum<{
|
|
302
329
|
stdio: "stdio";
|
|
303
330
|
http: "http";
|
|
@@ -320,6 +347,13 @@ export declare const AgentFrameworkConfigSchema: z.ZodObject<{
|
|
|
320
347
|
bearerTokenEnvVar: z.ZodOptional<z.ZodString>;
|
|
321
348
|
keepAliveIntervalMs: z.ZodOptional<z.ZodNumber>;
|
|
322
349
|
keepAliveTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
350
|
+
oauth: z.ZodOptional<z.ZodObject<{
|
|
351
|
+
clientId: z.ZodString;
|
|
352
|
+
clientSecret: z.ZodOptional<z.ZodString>;
|
|
353
|
+
callbackPort: z.ZodOptional<z.ZodNumber>;
|
|
354
|
+
callbackUrl: z.ZodOptional<z.ZodString>;
|
|
355
|
+
}, z.core.$strip>>;
|
|
356
|
+
scopes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
323
357
|
}, z.core.$strip>, z.ZodTransform<{
|
|
324
358
|
transport: "stdio" | "http";
|
|
325
359
|
command?: string | undefined;
|
|
@@ -336,6 +370,13 @@ export declare const AgentFrameworkConfigSchema: z.ZodObject<{
|
|
|
336
370
|
bearerTokenEnvVar?: string | undefined;
|
|
337
371
|
keepAliveIntervalMs?: number | undefined;
|
|
338
372
|
keepAliveTimeoutMs?: number | undefined;
|
|
373
|
+
oauth?: {
|
|
374
|
+
clientId: string;
|
|
375
|
+
clientSecret?: string | undefined;
|
|
376
|
+
callbackPort?: number | undefined;
|
|
377
|
+
callbackUrl?: string | undefined;
|
|
378
|
+
} | undefined;
|
|
379
|
+
scopes?: string[] | undefined;
|
|
339
380
|
}, {
|
|
340
381
|
type?: "stdio" | "http" | undefined;
|
|
341
382
|
transport?: "stdio" | "http" | undefined;
|
|
@@ -353,7 +394,14 @@ export declare const AgentFrameworkConfigSchema: z.ZodObject<{
|
|
|
353
394
|
bearerTokenEnvVar?: string | undefined;
|
|
354
395
|
keepAliveIntervalMs?: number | undefined;
|
|
355
396
|
keepAliveTimeoutMs?: number | undefined;
|
|
356
|
-
|
|
397
|
+
oauth?: {
|
|
398
|
+
clientId: string;
|
|
399
|
+
clientSecret?: string | undefined;
|
|
400
|
+
callbackPort?: number | undefined;
|
|
401
|
+
callbackUrl?: string | undefined;
|
|
402
|
+
} | undefined;
|
|
403
|
+
scopes?: string[] | undefined;
|
|
404
|
+
}>>>>>;
|
|
357
405
|
hooks: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
358
406
|
event: z.ZodString;
|
|
359
407
|
matcher: z.ZodOptional<z.ZodString>;
|
|
@@ -382,6 +430,7 @@ export type PermissionConfig = z.infer<typeof PermissionConfigSchema>;
|
|
|
382
430
|
export type LoopControl = z.infer<typeof LoopControlSchema>;
|
|
383
431
|
export type ThinkingConfig = z.infer<typeof ThinkingConfigSchema>;
|
|
384
432
|
export type McpServerConfig = z.infer<typeof McpServerConfigSchema>;
|
|
433
|
+
export type McpOAuthClientConfig = z.infer<typeof McpOAuthClientConfigSchema>;
|
|
385
434
|
export type HookDefConfig = z.infer<typeof HookDefConfigSchema>;
|
|
386
435
|
export type PluginRef = z.infer<typeof PluginRefSchema>;
|
|
387
436
|
export type AgentFrameworkConfig = z.infer<typeof AgentFrameworkConfigSchema>;
|
package/dist/config/schema.js
CHANGED
|
@@ -68,7 +68,55 @@ export const ThinkingConfigSchema = z.object({
|
|
|
68
68
|
mode: z.enum(["auto", "on", "off"]),
|
|
69
69
|
effort: z.enum(["low", "medium", "high"]).optional(),
|
|
70
70
|
});
|
|
71
|
-
|
|
71
|
+
// A pre-registered OAuth client for an MCP server (Codex `.mcp.json` `oauth` block). When set, the
|
|
72
|
+
// login flow uses this client instead of dynamic client registration — for providers that don't
|
|
73
|
+
// support DCR (GitHub, Slack) and publish a public client for local agents.
|
|
74
|
+
export const McpOAuthClientConfigSchema = z.object({
|
|
75
|
+
clientId: z.string().min(1),
|
|
76
|
+
clientSecret: z.string().min(1).optional(),
|
|
77
|
+
// Fixed loopback port for the callback listener (the provider registered it). Random when unset.
|
|
78
|
+
callbackPort: z.number().int().min(1).max(65535).optional(),
|
|
79
|
+
// Exact redirect URI the provider registered; its port and path drive the callback listener.
|
|
80
|
+
callbackUrl: z.string().url().optional(),
|
|
81
|
+
});
|
|
82
|
+
// Codex writes `.mcp.json` in snake_case (`bearer_token_env_var`, `oauth.client_id`, …). Rename
|
|
83
|
+
// those keys to the camelCase config spelling before validation so a plugin's server config keeps
|
|
84
|
+
// them instead of having zod strip them as unknown keys.
|
|
85
|
+
const MCP_SNAKE_CASE_KEYS = {
|
|
86
|
+
bearer_token_env_var: "bearerTokenEnvVar",
|
|
87
|
+
allowed_tools: "allowedTools",
|
|
88
|
+
blocked_tools: "blockedTools",
|
|
89
|
+
startup_timeout_ms: "startupTimeoutMs",
|
|
90
|
+
tool_timeout_ms: "toolTimeoutMs",
|
|
91
|
+
};
|
|
92
|
+
const MCP_OAUTH_SNAKE_CASE_KEYS = {
|
|
93
|
+
client_id: "clientId",
|
|
94
|
+
client_secret: "clientSecret",
|
|
95
|
+
callback_port: "callbackPort",
|
|
96
|
+
callback_url: "callbackUrl",
|
|
97
|
+
};
|
|
98
|
+
function renameKeys(value, keys) {
|
|
99
|
+
const out = {};
|
|
100
|
+
for (const [key, v] of Object.entries(value)) {
|
|
101
|
+
const renamed = keys[key];
|
|
102
|
+
// An explicit camelCase key wins over its snake_case twin.
|
|
103
|
+
if (renamed !== undefined && renamed in value)
|
|
104
|
+
continue;
|
|
105
|
+
out[renamed ?? key] = v;
|
|
106
|
+
}
|
|
107
|
+
return out;
|
|
108
|
+
}
|
|
109
|
+
function normalizeMcpServerKeys(value) {
|
|
110
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
111
|
+
return value;
|
|
112
|
+
const out = renameKeys(value, MCP_SNAKE_CASE_KEYS);
|
|
113
|
+
const oauth = out["oauth"];
|
|
114
|
+
if (typeof oauth === "object" && oauth !== null && !Array.isArray(oauth)) {
|
|
115
|
+
out["oauth"] = renameKeys(oauth, MCP_OAUTH_SNAKE_CASE_KEYS);
|
|
116
|
+
}
|
|
117
|
+
return out;
|
|
118
|
+
}
|
|
119
|
+
const McpServerConfigObjectSchema = z.object({
|
|
72
120
|
// spelling. Accept both, but normalise output to `transport`.
|
|
73
121
|
type: z.enum(["stdio", "http"]).optional(),
|
|
74
122
|
transport: z.enum(["stdio", "http"]).optional(),
|
|
@@ -87,6 +135,9 @@ export const McpServerConfigSchema = z.object({
|
|
|
87
135
|
bearerTokenEnvVar: z.string().min(1).optional(),
|
|
88
136
|
keepAliveIntervalMs: z.number().int().min(1).optional(),
|
|
89
137
|
keepAliveTimeoutMs: z.number().int().min(1).optional(),
|
|
138
|
+
oauth: McpOAuthClientConfigSchema.optional(),
|
|
139
|
+
// OAuth scopes to request. Overrides what the server's protected-resource metadata advertises.
|
|
140
|
+
scopes: z.array(z.string().min(1)).optional(),
|
|
90
141
|
}).superRefine((value, ctx) => {
|
|
91
142
|
if (value.type !== undefined && value.transport !== undefined && value.type !== value.transport) {
|
|
92
143
|
ctx.addIssue({
|
|
@@ -99,6 +150,7 @@ export const McpServerConfigSchema = z.object({
|
|
|
99
150
|
...rest,
|
|
100
151
|
transport: transport ?? type ?? "stdio",
|
|
101
152
|
}));
|
|
153
|
+
export const McpServerConfigSchema = z.preprocess(normalizeMcpServerKeys, McpServerConfigObjectSchema);
|
|
102
154
|
export const HookDefConfigSchema = z.object({
|
|
103
155
|
event: z.string(),
|
|
104
156
|
matcher: z.string().optional(),
|