@zvada/agent-server 0.3.25 → 0.3.27
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 +113 -0
- package/README.md +4 -1
- package/dist/client/client.js +27 -11
- package/dist/client/connection.js +35 -3
- package/dist/core/agents/acp/acp-agent.js +91 -14
- package/dist/core/agents/acp/mappings.js +5 -1
- package/dist/core/agents/claude-code/approvals.js +3 -2
- package/dist/core/agents/claude-code/claude-agent.js +12 -2
- package/dist/core/agents/claude-code/mcp.js +9 -1
- package/dist/core/agents/claude-code/models.js +16 -10
- package/dist/core/agents/claude-code/options.js +23 -2
- package/dist/core/agents/claude-code/session.js +21 -1
- package/dist/core/agents/claude-code/tools.js +9 -4
- package/dist/core/agents/claude-code/turn.js +2 -0
- package/dist/core/agents/codex-app-server/adapter.js +2 -0
- package/dist/core/agents/codex-app-server/client.js +8 -5
- package/dist/core/agents/codex-app-server/codex-agent.js +35 -2
- package/dist/core/agents/codex-app-server/effort.js +13 -6
- package/dist/core/agents/codex-app-server/mcp.js +35 -18
- package/dist/core/agents/codex-app-server/models.js +10 -10
- package/dist/core/agents/codex-app-server/options.js +11 -2
- package/dist/core/agents/codex-app-server/plan-approval.js +1 -1
- package/dist/core/agents/codex-app-server/session.js +11 -4
- package/dist/core/agents/codex-app-server/thread-settings.js +30 -11
- package/dist/core/agents/host-tools.js +493 -0
- package/dist/core/agents/mcp-config.js +6 -2
- package/dist/core/agents/scripted/scripted-agent.js +39 -6
- package/dist/core/agents/scripted/steps.js +5 -1
- package/dist/core/agents/session-agent.js +70 -2
- package/dist/core/agents/thinking-levels.js +8 -5
- package/dist/core/index.js +1 -0
- package/dist/core/presets.js +16 -3
- package/dist/core/processes/lifeline.js +9 -5
- package/dist/core/provision/pins.js +7 -16
- package/dist/core/provision/releases.js +25 -25
- package/dist/core/proxy/loopback.js +22 -4
- package/dist/core/runtime/agent-runtime.js +15 -5
- package/dist/core/runtime/event-processor.js +13 -8
- package/dist/core/runtime/origin-line.js +42 -0
- package/dist/core/runtime/request-broker.js +2 -1
- package/dist/core/runtime/steering.js +4 -3
- package/dist/core/runtime/turn.js +6 -4
- package/dist/operator/errors.js +97 -0
- package/dist/operator/index.js +10 -5
- package/dist/operator/mcp.js +7 -12
- package/dist/operator/operator.js +1336 -380
- package/dist/operator/refs.js +59 -0
- package/dist/operator/render.js +171 -74
- package/dist/operator/session-tools.js +87 -0
- package/dist/operator/types.js +30 -0
- package/dist/operator/view.js +82 -27
- package/dist/protocol/config.js +33 -6
- package/dist/protocol/conversation.js +3 -0
- package/dist/protocol/history.js +2 -1
- package/dist/protocol/index.js +1 -0
- package/dist/protocol/lifecycle.js +19 -0
- package/dist/protocol/model-catalog.js +58 -18
- package/dist/protocol/models.js +6 -27
- package/dist/protocol/origin.js +39 -0
- package/dist/protocol/reduce.js +2 -0
- package/dist/protocol/thinking.js +22 -9
- package/dist/protocol/wire-api.js +2 -2
- package/dist/protocol/wire.js +17 -0
- package/dist/server/bin.js +6 -4
- package/dist/server/routes.js +15 -5
- package/dist/types/client/client.d.ts.map +1 -1
- package/dist/types/client/connection.d.ts +14 -2
- package/dist/types/client/connection.d.ts.map +1 -1
- package/dist/types/client/turns.d.ts +2 -2
- package/dist/types/client/turns.d.ts.map +1 -1
- package/dist/types/core/agents/acp/acp-agent.d.ts +15 -0
- package/dist/types/core/agents/acp/acp-agent.d.ts.map +1 -1
- package/dist/types/core/agents/acp/mappings.d.ts +5 -1
- package/dist/types/core/agents/acp/mappings.d.ts.map +1 -1
- package/dist/types/core/agents/acp/requests.d.ts +2 -0
- package/dist/types/core/agents/acp/requests.d.ts.map +1 -1
- package/dist/types/core/agents/base.d.ts +2 -0
- package/dist/types/core/agents/base.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/approvals.d.ts +2 -1
- package/dist/types/core/agents/claude-code/approvals.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/claude-agent.d.ts +1 -0
- package/dist/types/core/agents/claude-code/claude-agent.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/mcp.d.ts +8 -1
- package/dist/types/core/agents/claude-code/mcp.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/models.d.ts +9 -5
- package/dist/types/core/agents/claude-code/models.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/options.d.ts +10 -1
- package/dist/types/core/agents/claude-code/options.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/session.d.ts +2 -0
- package/dist/types/core/agents/claude-code/session.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/tools.d.ts.map +1 -1
- package/dist/types/core/agents/claude-code/turn.d.ts +3 -0
- package/dist/types/core/agents/claude-code/turn.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/adapter.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/client.d.ts +2 -0
- package/dist/types/core/agents/codex-app-server/client.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/codex-agent.d.ts +11 -0
- package/dist/types/core/agents/codex-app-server/codex-agent.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/effort.d.ts +7 -7
- package/dist/types/core/agents/codex-app-server/effort.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/mcp.d.ts +11 -3
- package/dist/types/core/agents/codex-app-server/mcp.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/models.d.ts +4 -1
- package/dist/types/core/agents/codex-app-server/models.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/options.d.ts +9 -2
- package/dist/types/core/agents/codex-app-server/options.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/requests.d.ts +2 -0
- package/dist/types/core/agents/codex-app-server/requests.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/session.d.ts +6 -3
- package/dist/types/core/agents/codex-app-server/session.d.ts.map +1 -1
- package/dist/types/core/agents/codex-app-server/thread-settings.d.ts.map +1 -1
- package/dist/types/core/agents/host-tools.d.ts +162 -0
- package/dist/types/core/agents/host-tools.d.ts.map +1 -0
- package/dist/types/core/agents/mcp-config.d.ts +11 -2
- package/dist/types/core/agents/mcp-config.d.ts.map +1 -1
- package/dist/types/core/agents/scripted/scripted-agent.d.ts +14 -1
- package/dist/types/core/agents/scripted/scripted-agent.d.ts.map +1 -1
- package/dist/types/core/agents/scripted/steps.d.ts.map +1 -1
- package/dist/types/core/agents/session-agent.d.ts +2 -7
- package/dist/types/core/agents/session-agent.d.ts.map +1 -1
- package/dist/types/core/agents/thinking-levels.d.ts +7 -3
- package/dist/types/core/agents/thinking-levels.d.ts.map +1 -1
- package/dist/types/core/index.d.ts +1 -0
- package/dist/types/core/index.d.ts.map +1 -1
- package/dist/types/core/presets.d.ts +11 -1
- package/dist/types/core/presets.d.ts.map +1 -1
- package/dist/types/core/processes/lifeline.d.ts.map +1 -1
- package/dist/types/core/provision/pins.d.ts +5 -4
- package/dist/types/core/provision/pins.d.ts.map +1 -1
- package/dist/types/core/proxy/loopback.d.ts.map +1 -1
- package/dist/types/core/runtime/agent-runtime.d.ts +4 -2
- package/dist/types/core/runtime/agent-runtime.d.ts.map +1 -1
- package/dist/types/core/runtime/event-processor.d.ts +2 -2
- package/dist/types/core/runtime/event-processor.d.ts.map +1 -1
- package/dist/types/core/runtime/origin-line.d.ts +15 -0
- package/dist/types/core/runtime/origin-line.d.ts.map +1 -0
- package/dist/types/core/runtime/request-broker.d.ts +1 -1
- package/dist/types/core/runtime/request-broker.d.ts.map +1 -1
- package/dist/types/core/runtime/steering.d.ts +7 -4
- package/dist/types/core/runtime/steering.d.ts.map +1 -1
- package/dist/types/core/runtime/turn.d.ts.map +1 -1
- package/dist/types/operator/errors.d.ts +83 -0
- package/dist/types/operator/errors.d.ts.map +1 -0
- package/dist/types/operator/index.d.ts +10 -5
- package/dist/types/operator/index.d.ts.map +1 -1
- package/dist/types/operator/mcp.d.ts +1 -1
- package/dist/types/operator/mcp.d.ts.map +1 -1
- package/dist/types/operator/operator.d.ts +15 -197
- package/dist/types/operator/operator.d.ts.map +1 -1
- package/dist/types/operator/refs.d.ts +25 -0
- package/dist/types/operator/refs.d.ts.map +1 -0
- package/dist/types/operator/render.d.ts +59 -19
- package/dist/types/operator/render.d.ts.map +1 -1
- package/dist/types/operator/session-tools.d.ts +61 -0
- package/dist/types/operator/session-tools.d.ts.map +1 -0
- package/dist/types/operator/types.d.ts +441 -0
- package/dist/types/operator/types.d.ts.map +1 -0
- package/dist/types/operator/view.d.ts +19 -29
- package/dist/types/operator/view.d.ts.map +1 -1
- package/dist/types/protocol/config.d.ts +32 -24
- package/dist/types/protocol/config.d.ts.map +1 -1
- package/dist/types/protocol/conversation.d.ts +48 -39
- package/dist/types/protocol/conversation.d.ts.map +1 -1
- package/dist/types/protocol/execution.d.ts +2 -18
- package/dist/types/protocol/execution.d.ts.map +1 -1
- package/dist/types/protocol/history.d.ts +1 -1
- package/dist/types/protocol/history.d.ts.map +1 -1
- package/dist/types/protocol/index.d.ts +1 -0
- package/dist/types/protocol/index.d.ts.map +1 -1
- package/dist/types/protocol/lifecycle.d.ts +48 -74
- package/dist/types/protocol/lifecycle.d.ts.map +1 -1
- package/dist/types/protocol/model-catalog.d.ts.map +1 -1
- package/dist/types/protocol/models.d.ts +4 -42
- package/dist/types/protocol/models.d.ts.map +1 -1
- package/dist/types/protocol/origin.d.ts +49 -0
- package/dist/types/protocol/origin.d.ts.map +1 -0
- package/dist/types/protocol/reduce.d.ts.map +1 -1
- package/dist/types/protocol/thinking.d.ts +19 -19
- package/dist/types/protocol/thinking.d.ts.map +1 -1
- package/dist/types/protocol/wire-api.d.ts +59 -106
- package/dist/types/protocol/wire-api.d.ts.map +1 -1
- package/dist/types/protocol/wire.d.ts +81 -119
- package/dist/types/protocol/wire.d.ts.map +1 -1
- package/dist/types/server/routes.d.ts.map +1 -1
- package/docs/consuming.md +124 -132
- package/docs/deploy.md +6 -5
- package/docs/harnesses.md +79 -31
- package/docs/sync-history.md +2 -1
- package/package.json +4 -4
- package/src/client/client.ts +36 -9
- package/src/client/connection.ts +31 -1
- package/src/client/turns.ts +2 -1
- package/src/core/agents/acp/acp-agent.ts +123 -17
- package/src/core/agents/acp/mappings.ts +5 -1
- package/src/core/agents/acp/requests.ts +2 -0
- package/src/core/agents/base.ts +2 -0
- package/src/core/agents/claude-code/approvals.ts +4 -3
- package/src/core/agents/claude-code/claude-agent.ts +14 -2
- package/src/core/agents/claude-code/mcp.ts +11 -1
- package/src/core/agents/claude-code/models.ts +15 -10
- package/src/core/agents/claude-code/options.ts +33 -3
- package/src/core/agents/claude-code/session.ts +26 -1
- package/src/core/agents/claude-code/tools.ts +10 -4
- package/src/core/agents/claude-code/turn.ts +4 -0
- package/src/core/agents/codex-app-server/adapter.ts +2 -0
- package/src/core/agents/codex-app-server/client.ts +11 -5
- package/src/core/agents/codex-app-server/codex-agent.ts +45 -1
- package/src/core/agents/codex-app-server/effort.ts +15 -20
- package/src/core/agents/codex-app-server/mcp.ts +46 -23
- package/src/core/agents/codex-app-server/models.ts +10 -10
- package/src/core/agents/codex-app-server/options.ts +16 -2
- package/src/core/agents/codex-app-server/plan-approval.ts +1 -1
- package/src/core/agents/codex-app-server/requests.ts +2 -0
- package/src/core/agents/codex-app-server/session.ts +19 -4
- package/src/core/agents/codex-app-server/thread-settings.ts +31 -11
- package/src/core/agents/host-tools.ts +649 -0
- package/src/core/agents/mcp-config.ts +15 -3
- package/src/core/agents/scripted/scripted-agent.ts +51 -5
- package/src/core/agents/scripted/steps.ts +5 -1
- package/src/core/agents/session-agent.ts +78 -2
- package/src/core/agents/thinking-levels.ts +9 -6
- package/src/core/index.ts +9 -0
- package/src/core/presets.ts +28 -4
- package/src/core/processes/lifeline.ts +9 -5
- package/src/core/provision/pins.ts +7 -16
- package/src/core/provision/releases.ts +25 -25
- package/src/core/proxy/loopback.ts +25 -4
- package/src/core/runtime/agent-runtime.ts +31 -7
- package/src/core/runtime/event-processor.ts +13 -6
- package/src/core/runtime/origin-line.ts +43 -0
- package/src/core/runtime/request-broker.ts +2 -0
- package/src/core/runtime/steering.ts +8 -4
- package/src/core/runtime/turn.ts +11 -4
- package/src/operator/errors.ts +218 -0
- package/src/operator/index.ts +18 -23
- package/src/operator/mcp.ts +7 -16
- package/src/operator/operator.ts +1583 -613
- package/src/operator/refs.ts +75 -0
- package/src/operator/render.ts +208 -98
- package/src/operator/session-tools.ts +126 -0
- package/src/operator/types.ts +505 -0
- package/src/operator/view.ts +93 -42
- package/src/protocol/config.ts +36 -7
- package/src/protocol/conversation.ts +3 -0
- package/src/protocol/history.ts +2 -1
- package/src/protocol/index.ts +1 -0
- package/src/protocol/lifecycle.ts +21 -0
- package/src/protocol/model-catalog.ts +58 -18
- package/src/protocol/models.ts +6 -26
- package/src/protocol/origin.ts +47 -0
- package/src/protocol/reduce.ts +4 -0
- package/src/protocol/thinking.ts +27 -14
- package/src/protocol/wire-api.ts +2 -2
- package/src/protocol/wire.ts +18 -0
- package/src/server/bin.ts +6 -4
- package/src/server/routes.ts +16 -5
package/src/protocol/config.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { AgentHarnessSchema } from "./harness.ts";
|
|
3
|
+
import { type Origin, OriginSchema, agentOrigin } from "./origin.ts";
|
|
3
4
|
import { AgentInputSchema } from "./part-input.ts";
|
|
4
5
|
import { ThinkingLevelSchema } from "./thinking.ts";
|
|
5
6
|
import { openVocabulary } from "./vocabulary.ts";
|
|
@@ -29,7 +30,7 @@ export type PermissionMode = z.infer<typeof PermissionModeSchema>;
|
|
|
29
30
|
export type ReportedPermissionMode = PermissionMode | (string & {});
|
|
30
31
|
export const ReportedPermissionModeSchema = openVocabulary(PermissionModeSchema.options);
|
|
31
32
|
|
|
32
|
-
/** The longest `requestTimeoutMs`: a timer's own limit, about 24.8 days. */
|
|
33
|
+
/** The longest `requestTimeoutMs` and the longest MCP `timeoutMs`: a timer's own limit, about 24.8 days. */
|
|
33
34
|
export const MAX_REQUEST_TIMEOUT_MS = 2_147_483_647;
|
|
34
35
|
|
|
35
36
|
/**
|
|
@@ -41,6 +42,24 @@ export const MAX_REQUEST_TIMEOUT_MS = 2_147_483_647;
|
|
|
41
42
|
*/
|
|
42
43
|
const required = z.boolean().optional();
|
|
43
44
|
|
|
45
|
+
/**
|
|
46
|
+
* How long one call to one of the server's tools may run, in milliseconds,
|
|
47
|
+
* on any transport: past it the call fails, and the model is told it timed out.
|
|
48
|
+
* - Claude: the server's `timeout`. A value under 1000 is ignored, as if unset.
|
|
49
|
+
* Unset, a call to an HTTP or SSE server is cut at 60 s unless
|
|
50
|
+
* `MCP_TOOL_TIMEOUT` (ms) is in the turn's or the engine's environment; a
|
|
51
|
+
* call to a stdio server is not cut at 60 s (one ran 70 s), and Claude's
|
|
52
|
+
* own longer limits still apply.
|
|
53
|
+
* - Codex: the server's `tool_timeout_sec`, in whole seconds rounded up
|
|
54
|
+
* (1118 cuts a call at 2 s), as Codex reads a fraction back changed.
|
|
55
|
+
* Unset, a call is cut at 300 s.
|
|
56
|
+
* - An ACP agent is not given it (ACP v1 has no such field): the agent keeps
|
|
57
|
+
* its own limit, if it has one.
|
|
58
|
+
* At most `MAX_REQUEST_TIMEOUT_MS`, a timer's own limit; a larger value is refused.
|
|
59
|
+
* A changed value applies from the next turn of a warm session.
|
|
60
|
+
*/
|
|
61
|
+
const timeoutMs = z.number().int().positive().max(MAX_REQUEST_TIMEOUT_MS).optional();
|
|
62
|
+
|
|
44
63
|
/** Minimal external MCP server descriptor (stdio or http/sse). */
|
|
45
64
|
export const McpServerConfigSchema = z.discriminatedUnion("type", [
|
|
46
65
|
z.object({
|
|
@@ -49,18 +68,21 @@ export const McpServerConfigSchema = z.discriminatedUnion("type", [
|
|
|
49
68
|
args: z.array(z.string()).optional(),
|
|
50
69
|
env: z.record(z.string(), z.string()).optional(),
|
|
51
70
|
required,
|
|
71
|
+
timeoutMs,
|
|
52
72
|
}),
|
|
53
73
|
z.object({
|
|
54
74
|
type: z.literal("http"),
|
|
55
75
|
url: z.string(),
|
|
56
76
|
headers: z.record(z.string(), z.string()).optional(),
|
|
57
77
|
required,
|
|
78
|
+
timeoutMs,
|
|
58
79
|
}),
|
|
59
80
|
z.object({
|
|
60
81
|
type: z.literal("sse"),
|
|
61
82
|
url: z.string(),
|
|
62
83
|
headers: z.record(z.string(), z.string()).optional(),
|
|
63
84
|
required,
|
|
85
|
+
timeoutMs,
|
|
64
86
|
}),
|
|
65
87
|
]);
|
|
66
88
|
export type McpServerConfig = z.infer<typeof McpServerConfigSchema>;
|
|
@@ -140,19 +162,26 @@ export const RunRequestSchema = z.object({
|
|
|
140
162
|
turnId: z.string(),
|
|
141
163
|
input: AgentInputSchema,
|
|
142
164
|
config: RunConfigSchema,
|
|
165
|
+
/** Who sent the input; absent is the person (`OriginSchema`). */
|
|
166
|
+
origin: OriginSchema.optional(),
|
|
143
167
|
});
|
|
144
168
|
export type RunRequest = z.infer<typeof RunRequestSchema>;
|
|
145
169
|
|
|
170
|
+
// @ref LLP 0019#origin-on-the-wire-and-to-the-model — another sender is another turn
|
|
146
171
|
/**
|
|
147
|
-
* What makes a turn the same turn when a client sends its ids again: its
|
|
148
|
-
* and the config that shapes what the agent does. What a
|
|
149
|
-
* can change without making it another turn stays out:
|
|
150
|
-
* per-session URL), the environment, the API key, and
|
|
172
|
+
* What makes a turn the same turn when a client sends its ids again: its
|
|
173
|
+
* input, who sent it, and the config that shapes what the agent does. What a
|
|
174
|
+
* client's own restart can change without making it another turn stays out:
|
|
175
|
+
* MCP endpoints (a fresh per-session URL), the environment, the API key, and
|
|
176
|
+
* raw passthrough. The person's origin, said or not, adds nothing, so a
|
|
177
|
+
* request's identity is what it was before origins existed.
|
|
151
178
|
*/
|
|
152
|
-
export function turnIdentity(request: Pick<RunRequest, "input" | "config">): {
|
|
179
|
+
export function turnIdentity(request: Pick<RunRequest, "input" | "config" | "origin">): {
|
|
153
180
|
input: RunRequest["input"];
|
|
154
181
|
config: Omit<RunConfig, "mcpServers" | "env" | "apiKey" | "includeRaw">;
|
|
182
|
+
origin?: Origin;
|
|
155
183
|
} {
|
|
156
184
|
const { mcpServers: _mcp, env: _env, apiKey: _key, includeRaw: _raw, ...config } = request.config;
|
|
157
|
-
|
|
185
|
+
const origin = agentOrigin(request.origin);
|
|
186
|
+
return { input: request.input, config, ...(origin && { origin }) };
|
|
158
187
|
}
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
StopReasonSchema,
|
|
18
18
|
UnknownEventSchema,
|
|
19
19
|
} from "./lifecycle.ts";
|
|
20
|
+
import { ReportedOriginSchema } from "./origin.ts";
|
|
20
21
|
import { PartSchema, UnknownPartSchema } from "./parts.ts";
|
|
21
22
|
import { EpochMsSchema } from "./time.ts";
|
|
22
23
|
import { DEFAULT_TOKEN_USAGE, TokenUsageSchema } from "./tokens.ts";
|
|
@@ -39,6 +40,8 @@ export const ConversationMessageSchema = z.object({
|
|
|
39
40
|
/** Set when this is a sub-agent's output — nest it under that tool call. */
|
|
40
41
|
parentToolCallId: z.string().optional(),
|
|
41
42
|
model: z.string().optional(),
|
|
43
|
+
/** A user message's sender when it is not the person (`message.started`'s `origin`). */
|
|
44
|
+
origin: ReportedOriginSchema.optional(),
|
|
42
45
|
parts: z.array(z.union([PartSchema, UnknownPartSchema])),
|
|
43
46
|
startedAt: EpochMsSchema,
|
|
44
47
|
endedAt: EpochMsSchema.optional(),
|
package/src/protocol/history.ts
CHANGED
|
@@ -205,7 +205,8 @@ export type HistoryWait = z.input<typeof HistoryWaitSchema>;
|
|
|
205
205
|
|
|
206
206
|
/** Projection cache format changes whenever reducer semantics become incompatible.
|
|
207
207
|
* Raw canonical events remain authoritative and are never pruned by this cache. */
|
|
208
|
-
|
|
208
|
+
// v2: user messages carry `origin` (LLP 0019); a v1 checkpoint was folded without it.
|
|
209
|
+
export const CONVERSATION_CHECKPOINT_FORMAT = "agent-server.conversation.v2";
|
|
209
210
|
export const HistoryCheckpointRequestSchema = z.object({ through: HistoryVersionSchema });
|
|
210
211
|
export type HistoryCheckpointRequest = z.infer<typeof HistoryCheckpointRequestSchema>;
|
|
211
212
|
export const HistoryCheckpointSchema = z.object({
|
package/src/protocol/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { TurnExecutionSchema } from "./execution.ts";
|
|
|
5
5
|
import { isKnownLifecycleEventType } from "./guards.ts";
|
|
6
6
|
import { HarnessIdSchema } from "./harness.ts";
|
|
7
7
|
import { MetaSchema } from "./meta.ts";
|
|
8
|
+
import { ReportedOriginSchema } from "./origin.ts";
|
|
8
9
|
import { type Part, PartSchema, type UnknownPart, decodePart } from "./parts.ts";
|
|
9
10
|
import { EpochMsSchema } from "./time.ts";
|
|
10
11
|
import { TokenUsageSchema } from "./tokens.ts";
|
|
@@ -278,6 +279,12 @@ export const MessageStartedEventSchema = z.object({
|
|
|
278
279
|
* the turn asked for.
|
|
279
280
|
*/
|
|
280
281
|
model: z.string().optional(),
|
|
282
|
+
/**
|
|
283
|
+
* A user message's sender when it is not the person: the request's
|
|
284
|
+
* `origin`, the turn's echo and a steer's alike. Absent on the person's
|
|
285
|
+
* messages and on every assistant message.
|
|
286
|
+
*/
|
|
287
|
+
origin: ReportedOriginSchema.optional(),
|
|
281
288
|
...stamped,
|
|
282
289
|
});
|
|
283
290
|
export type MessageStartedEvent = z.infer<typeof MessageStartedEventSchema>;
|
|
@@ -418,10 +425,24 @@ export type PermissionOutcome = z.infer<typeof PermissionOutcomeSchema>;
|
|
|
418
425
|
* `options` is THE source of buttons — clients render the server's list,
|
|
419
426
|
* never derive affordances from local policy.
|
|
420
427
|
*/
|
|
428
|
+
// @ref LLP 0019#answer_request-write — the kind of a request is said, never read from its options
|
|
429
|
+
/**
|
|
430
|
+
* What a permission request decides. OPEN: `tool`, whether a tool call may
|
|
431
|
+
* run (every built-in harness's tool approvals, and an ACP agent's, whose
|
|
432
|
+
* requests are tool-scoped); `plan`, whether to leave planning and carry out
|
|
433
|
+
* a plan (Claude's and Codex's plan approvals). A value this build does not
|
|
434
|
+
* know, or none, is read as `tool`: the stricter one.
|
|
435
|
+
*/
|
|
436
|
+
export const PERMISSION_PURPOSES = ["tool", "plan"] as const;
|
|
437
|
+
export type PermissionPurpose = (typeof PERMISSION_PURPOSES)[number] | (string & {});
|
|
438
|
+
export const PermissionPurposeSchema = openVocabulary(PERMISSION_PURPOSES);
|
|
439
|
+
|
|
421
440
|
export const PermissionRequestedEventSchema = z.object({
|
|
422
441
|
type: z.literal("permission.requested"),
|
|
423
442
|
...inTurn,
|
|
424
443
|
requestId: z.string(),
|
|
444
|
+
/** What it decides; absent on an older engine's events, which read as `tool`. */
|
|
445
|
+
purpose: PermissionPurposeSchema.optional(),
|
|
425
446
|
/** Human-readable one-line prompt, always present (render this). */
|
|
426
447
|
title: z.string(),
|
|
427
448
|
/**
|
|
@@ -9,8 +9,8 @@ export const GENERATED_MODEL_CATALOG: {
|
|
|
9
9
|
readonly models: readonly ModelDescriptor[];
|
|
10
10
|
} = {
|
|
11
11
|
cli: {
|
|
12
|
-
claude: "0.3.
|
|
13
|
-
codex: "0.
|
|
12
|
+
claude: "0.3.327",
|
|
13
|
+
codex: "0.169.1",
|
|
14
14
|
},
|
|
15
15
|
models: [
|
|
16
16
|
{
|
|
@@ -34,6 +34,16 @@ export const GENERATED_MODEL_CATALOG: {
|
|
|
34
34
|
levels: ["low", "medium", "high", "xhigh", "max"],
|
|
35
35
|
},
|
|
36
36
|
},
|
|
37
|
+
{
|
|
38
|
+
id: "fable",
|
|
39
|
+
harness: "claude-code",
|
|
40
|
+
label: "Fable 5.2",
|
|
41
|
+
description: "For your toughest challenges",
|
|
42
|
+
resolvedId: "claude-fable-5-2",
|
|
43
|
+
thinking: {
|
|
44
|
+
levels: ["low", "medium", "high", "xhigh", "max"],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
37
47
|
{
|
|
38
48
|
id: "sonnet",
|
|
39
49
|
harness: "claude-code",
|
|
@@ -45,21 +55,29 @@ export const GENERATED_MODEL_CATALOG: {
|
|
|
45
55
|
},
|
|
46
56
|
},
|
|
47
57
|
{
|
|
48
|
-
id: "
|
|
58
|
+
id: "haiku",
|
|
59
|
+
harness: "claude-code",
|
|
60
|
+
label: "Haiku 5.5",
|
|
61
|
+
description: "Fastest for quick answers",
|
|
62
|
+
resolvedId: "claude-haiku-5-5",
|
|
63
|
+
thinking: {
|
|
64
|
+
levels: ["low", "medium", "high", "xhigh", "max"],
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
id: "claude-fable-5-1",
|
|
49
69
|
harness: "claude-code",
|
|
50
70
|
label: "Fable 5.1",
|
|
51
71
|
description: "Most capable for your hardest and longest-running tasks",
|
|
52
|
-
resolvedId: "claude-fable-5-1",
|
|
53
72
|
thinking: {
|
|
54
73
|
levels: ["low", "medium", "high", "xhigh", "max"],
|
|
55
74
|
},
|
|
56
75
|
},
|
|
57
76
|
{
|
|
58
|
-
id: "haiku",
|
|
77
|
+
id: "claude-haiku-4-5-20251001",
|
|
59
78
|
harness: "claude-code",
|
|
60
79
|
label: "Haiku 4.5",
|
|
61
80
|
description: "Fastest for quick answers",
|
|
62
|
-
resolvedId: "claude-haiku-4-5-20251001",
|
|
63
81
|
thinking: {
|
|
64
82
|
levels: [],
|
|
65
83
|
},
|
|
@@ -128,10 +146,10 @@ export const GENERATED_MODEL_CATALOG: {
|
|
|
128
146
|
},
|
|
129
147
|
},
|
|
130
148
|
{
|
|
131
|
-
id: "gpt-6.
|
|
149
|
+
id: "gpt-6.2-sol",
|
|
132
150
|
harness: "codex-app-server",
|
|
133
|
-
label: "GPT-6.
|
|
134
|
-
description: "
|
|
151
|
+
label: "GPT-6.2-Sol",
|
|
152
|
+
description: "Fast, go-to model for coding and everyday work.",
|
|
135
153
|
isDefault: true,
|
|
136
154
|
thinking: {
|
|
137
155
|
levels: ["low", "medium", "high", "xhigh", "max", "ultra"],
|
|
@@ -140,13 +158,13 @@ export const GENERATED_MODEL_CATALOG: {
|
|
|
140
158
|
images: true,
|
|
141
159
|
},
|
|
142
160
|
{
|
|
143
|
-
id: "gpt-6-astra",
|
|
161
|
+
id: "gpt-6.2-astra",
|
|
144
162
|
harness: "codex-app-server",
|
|
145
|
-
label: "GPT-6-Astra",
|
|
146
|
-
description: "
|
|
163
|
+
label: "GPT-6.2-Astra",
|
|
164
|
+
description: "Our most capable model for complex coding and professional work.",
|
|
147
165
|
thinking: {
|
|
148
166
|
levels: ["low", "medium", "high", "xhigh", "max", "ultra"],
|
|
149
|
-
default: "
|
|
167
|
+
default: "low",
|
|
150
168
|
},
|
|
151
169
|
images: true,
|
|
152
170
|
},
|
|
@@ -154,18 +172,40 @@ export const GENERATED_MODEL_CATALOG: {
|
|
|
154
172
|
id: "gpt-6.1-terra",
|
|
155
173
|
harness: "codex-app-server",
|
|
156
174
|
label: "GPT-6.1 Terra",
|
|
157
|
-
description: "
|
|
175
|
+
description: "Efficient model that excels at visual understanding and computer use.",
|
|
176
|
+
thinking: {
|
|
177
|
+
levels: ["low", "medium", "high", "xhigh", "max", "ultra"],
|
|
178
|
+
default: "low",
|
|
179
|
+
},
|
|
180
|
+
images: true,
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
id: "gpt-6.1-sol",
|
|
184
|
+
harness: "codex-app-server",
|
|
185
|
+
label: "GPT-6.1-Sol",
|
|
186
|
+
description: "Previous generation model for coding and everyday work.",
|
|
158
187
|
thinking: {
|
|
159
188
|
levels: ["low", "medium", "high", "xhigh", "max", "ultra"],
|
|
160
189
|
default: "low",
|
|
161
190
|
},
|
|
162
191
|
images: true,
|
|
163
192
|
},
|
|
193
|
+
{
|
|
194
|
+
id: "gpt-6-astra",
|
|
195
|
+
harness: "codex-app-server",
|
|
196
|
+
label: "GPT-6-Astra",
|
|
197
|
+
description: "Previous generation model for complex coding and professional work.",
|
|
198
|
+
thinking: {
|
|
199
|
+
levels: ["low", "medium", "high", "xhigh", "max", "ultra"],
|
|
200
|
+
default: "medium",
|
|
201
|
+
},
|
|
202
|
+
images: true,
|
|
203
|
+
},
|
|
164
204
|
{
|
|
165
205
|
id: "gpt-6-sol",
|
|
166
206
|
harness: "codex-app-server",
|
|
167
207
|
label: "GPT-6-Sol",
|
|
168
|
-
description: "
|
|
208
|
+
description: "Legacy model for coding and everyday work.",
|
|
169
209
|
thinking: {
|
|
170
210
|
levels: ["low", "medium", "high", "xhigh", "max", "ultra"],
|
|
171
211
|
default: "medium",
|
|
@@ -187,7 +227,7 @@ export const GENERATED_MODEL_CATALOG: {
|
|
|
187
227
|
id: "gpt-5.6-sol",
|
|
188
228
|
harness: "codex-app-server",
|
|
189
229
|
label: "GPT-5.6-Sol",
|
|
190
|
-
description: "
|
|
230
|
+
description: "Legacy model for coding and everyday work.",
|
|
191
231
|
thinking: {
|
|
192
232
|
levels: ["low", "medium", "high", "xhigh", "max", "ultra"],
|
|
193
233
|
default: "low",
|
|
@@ -198,7 +238,7 @@ export const GENERATED_MODEL_CATALOG: {
|
|
|
198
238
|
id: "gpt-5.6-terra",
|
|
199
239
|
harness: "codex-app-server",
|
|
200
240
|
label: "GPT-5.6-Terra",
|
|
201
|
-
description: "
|
|
241
|
+
description: "Legacy balanced model for agentic coding.",
|
|
202
242
|
thinking: {
|
|
203
243
|
levels: ["low", "medium", "high", "xhigh", "max", "ultra"],
|
|
204
244
|
default: "medium",
|
|
@@ -209,7 +249,7 @@ export const GENERATED_MODEL_CATALOG: {
|
|
|
209
249
|
id: "gpt-5.6-luna",
|
|
210
250
|
harness: "codex-app-server",
|
|
211
251
|
label: "GPT-5.6-Luna",
|
|
212
|
-
description: "
|
|
252
|
+
description: "Legacy fast model for simpler tasks.",
|
|
213
253
|
thinking: {
|
|
214
254
|
levels: ["low", "medium", "high", "xhigh", "max"],
|
|
215
255
|
default: "medium",
|
package/src/protocol/models.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
import { type AgentHarness, AgentHarnessSchema } from "./harness.ts";
|
|
3
3
|
import { MetaSchema } from "./meta.ts";
|
|
4
4
|
import { GENERATED_MODEL_CATALOG } from "./model-catalog.ts";
|
|
5
|
-
import { type ThinkingLevel, ThinkingLevelSchema
|
|
5
|
+
import { type ThinkingLevel, ThinkingLevelSchema } from "./thinking.ts";
|
|
6
6
|
import { EpochMsSchema } from "./time.ts";
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -20,7 +20,11 @@ export const ModelDescriptorSchema = z.object({
|
|
|
20
20
|
/** The model a turn runs when its config names none. */
|
|
21
21
|
isDefault: z.boolean().optional(),
|
|
22
22
|
thinking: z.object({
|
|
23
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* The levels the model runs as distinct settings, by the harness's own
|
|
25
|
+
* names and in its order (both CLIs list lowest first); a name may be
|
|
26
|
+
* one this build does not know. Empty: no thinking control.
|
|
27
|
+
*/
|
|
24
28
|
levels: z.array(ThinkingLevelSchema),
|
|
25
29
|
/** The model's own default, when the harness states one. Never invented. */
|
|
26
30
|
default: ThinkingLevelSchema.optional(),
|
|
@@ -52,30 +56,6 @@ export const ModelListSchema = z.object({
|
|
|
52
56
|
});
|
|
53
57
|
export type ModelList = z.infer<typeof ModelListSchema>;
|
|
54
58
|
|
|
55
|
-
/**
|
|
56
|
-
* Parse a model list from a server that may be newer than this build: a
|
|
57
|
-
* thinking level this build does not know is dropped from `levels` (and from
|
|
58
|
-
* `default`) instead of failing the whole list.
|
|
59
|
-
*/
|
|
60
|
-
export function decodeModelList(value: unknown): ModelList {
|
|
61
|
-
const raw = value as { models?: unknown };
|
|
62
|
-
if (!Array.isArray(raw?.models)) return ModelListSchema.parse(value);
|
|
63
|
-
const models = raw.models.map((model: unknown) => {
|
|
64
|
-
const thinking = (model as { thinking?: { levels?: unknown; default?: unknown } })?.thinking;
|
|
65
|
-
if (!thinking || typeof thinking !== "object") return model;
|
|
66
|
-
const levels = Array.isArray(thinking.levels)
|
|
67
|
-
? thinking.levels.filter((level) => typeof level === "string" && isThinkingLevel(level))
|
|
68
|
-
: thinking.levels;
|
|
69
|
-
const known = typeof thinking.default === "string" && isThinkingLevel(thinking.default);
|
|
70
|
-
const { default: _dropped, ...rest } = thinking;
|
|
71
|
-
return {
|
|
72
|
-
...(model as object),
|
|
73
|
-
thinking: { ...rest, levels, ...(known && { default: thinking.default }) },
|
|
74
|
-
};
|
|
75
|
-
});
|
|
76
|
-
return ModelListSchema.parse({ ...(value as object), models });
|
|
77
|
-
}
|
|
78
|
-
|
|
79
59
|
/**
|
|
80
60
|
* The models each harness's pinned CLI listed when this release was built
|
|
81
61
|
* (`bun run models:refresh`), for a picker without a live list. The live list
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
// @ref LLP 0019#origin-on-the-wire-and-to-the-model — who sent a message, carried from the request to the echo
|
|
4
|
+
/**
|
|
5
|
+
* Who sent a turn's or a steer's message. Absent, or `person`, is the person
|
|
6
|
+
* the product serves; anything else is an agent, and the engine tells the
|
|
7
|
+
* receiving model so in one line before the input it is given. `name` is the
|
|
8
|
+
* host's, untrusted: the engine quotes it.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* The longest id or name an origin carries, in UTF-16 units: at most 765
|
|
12
|
+
* bytes of UTF-8, under the 1 KiB below which a journal never cuts a string
|
|
13
|
+
* to fit (`sync/fit.ts`), so a kept origin reads back exactly as it was sent.
|
|
14
|
+
* The line the model reads clips a name further, to 200 characters.
|
|
15
|
+
*/
|
|
16
|
+
export const ORIGIN_FIELD_MAX = 255;
|
|
17
|
+
const field = z.string().min(1).max(ORIGIN_FIELD_MAX);
|
|
18
|
+
|
|
19
|
+
export const OriginSchema = z.discriminatedUnion("kind", [
|
|
20
|
+
z.object({ kind: z.literal("person") }),
|
|
21
|
+
/** Another session; `name` is how the host's tools name it (`deus/voyager:2`). */
|
|
22
|
+
z.object({ kind: z.literal("session"), sessionId: field, name: field.optional() }),
|
|
23
|
+
/** An outside assistant the person connected. */
|
|
24
|
+
z.object({ kind: z.literal("assistant"), id: field, name: field }),
|
|
25
|
+
]);
|
|
26
|
+
const KNOWN_ORIGIN_KINDS: readonly string[] = ["person", "session", "assistant"];
|
|
27
|
+
export type Origin = z.infer<typeof OriginSchema>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* An origin as the stream reports it (the user message's `origin`): one this
|
|
31
|
+
* build knows, or a newer engine's kind, kept intact rather than refused.
|
|
32
|
+
*/
|
|
33
|
+
export const ReportedOriginSchema = z.union([
|
|
34
|
+
OriginSchema,
|
|
35
|
+
// A kind this build does not know, kept whole; a known kind must be well formed.
|
|
36
|
+
z
|
|
37
|
+
.looseObject({ kind: z.string().min(1).regex(/\S/, "must not be blank") })
|
|
38
|
+
.refine((origin) => !KNOWN_ORIGIN_KINDS.includes(origin.kind), "a malformed known origin"),
|
|
39
|
+
]);
|
|
40
|
+
export type ReportedOrigin = z.infer<typeof ReportedOriginSchema>;
|
|
41
|
+
|
|
42
|
+
/** The origin as the engine carries it: undefined for the person, whose messages carry none. */
|
|
43
|
+
export function agentOrigin(
|
|
44
|
+
origin: Origin | undefined,
|
|
45
|
+
): Exclude<Origin, { kind: "person" }> | undefined {
|
|
46
|
+
return origin && origin.kind !== "person" ? origin : undefined;
|
|
47
|
+
}
|
package/src/protocol/reduce.ts
CHANGED
|
@@ -14,6 +14,7 @@ import type {
|
|
|
14
14
|
StopReason,
|
|
15
15
|
UnknownEvent,
|
|
16
16
|
} from "./lifecycle.ts";
|
|
17
|
+
import type { ReportedOrigin } from "./origin.ts";
|
|
17
18
|
import type { Part, ToolPart, UnknownPart } from "./parts.ts";
|
|
18
19
|
import { addTokenUsage } from "./tokens.ts";
|
|
19
20
|
import { closeToolLeftOpen } from "./tool-closure.ts";
|
|
@@ -118,6 +119,7 @@ function openMessage(
|
|
|
118
119
|
role: "user" | "assistant";
|
|
119
120
|
parentToolCallId?: string;
|
|
120
121
|
model?: string;
|
|
122
|
+
origin?: ReportedOrigin;
|
|
121
123
|
},
|
|
122
124
|
record: ChangeRecorder,
|
|
123
125
|
): ConversationState {
|
|
@@ -138,6 +140,8 @@ function openMessage(
|
|
|
138
140
|
// depth alongside the producer gate: a hand-built or replayed
|
|
139
141
|
// `message.started{role:"user", model}` does not leak into the fold.
|
|
140
142
|
...(init.role === "assistant" && init.model !== undefined && { model: init.model }),
|
|
143
|
+
// Who sent a user message, when not the person; never on the agent's own.
|
|
144
|
+
...(init.role === "user" && init.origin !== undefined && { origin: init.origin }),
|
|
141
145
|
parts: [],
|
|
142
146
|
startedAt: init.timestamp,
|
|
143
147
|
};
|
package/src/protocol/thinking.ts
CHANGED
|
@@ -1,35 +1,48 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { openVocabulary } from "./vocabulary.ts";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* A single, harness-agnostic reasoning dial. Each harness maps it to its own
|
|
5
5
|
* native control: Claude -> adaptive `thinking` + `effort`; Codex ->
|
|
6
|
-
* `ReasoningEffort`. What runs depends on the model:
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* `ReasoningEffort`. What runs depends on the model: each harness runs the
|
|
7
|
+
* nearest level the model accepts (`ultra` on a Claude model topping out at
|
|
8
|
+
* `max` runs `max`).
|
|
9
|
+
*
|
|
10
|
+
* The levels this build knows, in order, lowest first. A harness may list
|
|
11
|
+
* others for a model: the names are an open vocabulary, the harness's own.
|
|
9
12
|
*/
|
|
10
13
|
export const THINKING_LEVELS = ["off", "low", "medium", "high", "xhigh", "max", "ultra"] as const;
|
|
11
|
-
|
|
12
|
-
export
|
|
14
|
+
/** A level this build knows and orders. */
|
|
15
|
+
export type KnownThinkingLevel = (typeof THINKING_LEVELS)[number];
|
|
16
|
+
/** A thinking level: one this build knows, or another a harness lists. OPEN. */
|
|
17
|
+
export type ThinkingLevel = KnownThinkingLevel | (string & {});
|
|
18
|
+
// @ref LLP 0002#open-vocabularies — a level a harness lists is kept, known or not
|
|
19
|
+
export const ThinkingLevelSchema = openVocabulary(THINKING_LEVELS);
|
|
13
20
|
|
|
14
|
-
|
|
21
|
+
/** Whether `v` is a level this build knows. */
|
|
22
|
+
export function isThinkingLevel(v: string): v is KnownThinkingLevel {
|
|
15
23
|
return (THINKING_LEVELS as readonly string[]).includes(v);
|
|
16
24
|
}
|
|
17
25
|
|
|
18
|
-
const rank = (level:
|
|
26
|
+
const rank = (level: KnownThinkingLevel) => THINKING_LEVELS.indexOf(level);
|
|
19
27
|
|
|
20
28
|
/**
|
|
21
|
-
* The level a model runs when it offers only `supported
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* `
|
|
29
|
+
* The level a model runs when it offers only `supported`. A level it lists is
|
|
30
|
+
* itself. Otherwise, for a level this build knows, the highest known level it
|
|
31
|
+
* lists at or below `level`, else its lowest known one: use it when switching
|
|
32
|
+
* models, so `ultra` on a model topping out at `max` becomes `max`, not a
|
|
33
|
+
* fixed fallback. `undefined` for a level this build does not know and the
|
|
34
|
+
* model does not list, and when the model offers none.
|
|
25
35
|
*/
|
|
26
36
|
export function clampThinkingLevel(
|
|
27
37
|
level: ThinkingLevel,
|
|
28
38
|
supported: readonly ThinkingLevel[],
|
|
29
39
|
): ThinkingLevel | undefined {
|
|
30
|
-
|
|
31
|
-
|
|
40
|
+
if (supported.includes(level)) return level;
|
|
41
|
+
if (!isThinkingLevel(level)) return undefined;
|
|
42
|
+
let below: KnownThinkingLevel | undefined;
|
|
43
|
+
let lowest: KnownThinkingLevel | undefined;
|
|
32
44
|
for (const candidate of supported) {
|
|
45
|
+
if (!isThinkingLevel(candidate)) continue;
|
|
33
46
|
if (lowest === undefined || rank(candidate) < rank(lowest)) lowest = candidate;
|
|
34
47
|
if (rank(candidate) <= rank(level) && (below === undefined || rank(candidate) > rank(below)))
|
|
35
48
|
below = candidate;
|
package/src/protocol/wire-api.ts
CHANGED
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
HistoryWaitSchema,
|
|
28
28
|
SessionRefSchema,
|
|
29
29
|
} from "./history.ts";
|
|
30
|
-
import { ModelListSchema
|
|
30
|
+
import { ModelListSchema } from "./models.ts";
|
|
31
31
|
import {
|
|
32
32
|
DurableSessionSchema,
|
|
33
33
|
ElicitationRespondParamsSchema,
|
|
@@ -106,7 +106,7 @@ const API = {
|
|
|
106
106
|
EventsReplayResultSchema,
|
|
107
107
|
decodeEventsReplayResult,
|
|
108
108
|
),
|
|
109
|
-
[WIRE_METHODS.modelsList]: method(ModelsListParamsSchema, ModelListSchema
|
|
109
|
+
[WIRE_METHODS.modelsList]: method(ModelsListParamsSchema, ModelListSchema),
|
|
110
110
|
[WIRE_METHODS.clisList]: method(ClisParamsSchema, ClisResultSchema),
|
|
111
111
|
[WIRE_METHODS.clisPrepare]: method(ClisParamsSchema, ClisResultSchema),
|
|
112
112
|
[WIRE_METHODS.authStatus]: method(AuthStatusParamsSchema, AuthStatusResultSchema),
|
package/src/protocol/wire.ts
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
decodeLifecycleEvent,
|
|
12
12
|
} from "./lifecycle.ts";
|
|
13
13
|
import { ModelListSchema } from "./models.ts";
|
|
14
|
+
import { OriginSchema } from "./origin.ts";
|
|
14
15
|
import { AgentInputSchema } from "./part-input.ts";
|
|
15
16
|
|
|
16
17
|
/**
|
|
@@ -44,6 +45,17 @@ import { AgentInputSchema } from "./part-input.ts";
|
|
|
44
45
|
*/
|
|
45
46
|
export const WIRE_PROTOCOL_VERSION = 6;
|
|
46
47
|
|
|
48
|
+
/**
|
|
49
|
+
* What a server takes beyond its protocol version, named in `initialize`'s
|
|
50
|
+
* `features`. A field a server's schema does not know is stripped, not
|
|
51
|
+
* refused, so a client asks before it sends one whose loss would change
|
|
52
|
+
* what the agent does.
|
|
53
|
+
* - `origin`: `turn/start` and `turn/steer` carry who sent the input, and the
|
|
54
|
+
* agent is told when it is not the person (LLP 0019). A client sends a
|
|
55
|
+
* non-person origin only to a server that names it.
|
|
56
|
+
*/
|
|
57
|
+
export const WIRE_FEATURES = { origin: "origin" } as const;
|
|
58
|
+
|
|
47
59
|
// ---- JSON-RPC 2.0 envelopes --------------------------------------------------
|
|
48
60
|
|
|
49
61
|
export const JsonRpcIdSchema = z.union([z.string(), z.number()]);
|
|
@@ -208,6 +220,8 @@ export const InitializeResultSchema = z.object({
|
|
|
208
220
|
historyId: z.string().optional(),
|
|
209
221
|
/** Capabilities per registered harness — only available harnesses appear. */
|
|
210
222
|
harnesses: z.record(z.string(), AgentCapabilitiesSchema),
|
|
223
|
+
/** What it takes beyond the protocol version (`WIRE_FEATURES`); absent on older servers. */
|
|
224
|
+
features: z.array(z.string()).optional(),
|
|
211
225
|
});
|
|
212
226
|
export type InitializeResult = z.infer<typeof InitializeResultSchema>;
|
|
213
227
|
|
|
@@ -222,6 +236,8 @@ export const TurnStartParamsSchema = z.object({
|
|
|
222
236
|
turnId: z.string().min(1).optional(),
|
|
223
237
|
input: AgentInputSchema,
|
|
224
238
|
config: RunConfigSchema,
|
|
239
|
+
/** Who sent the input; absent is the person. The agent is told when it is not (LLP 0019). */
|
|
240
|
+
origin: OriginSchema.optional(),
|
|
225
241
|
/**
|
|
226
242
|
* Stream the session to the caller from the head at admission until the
|
|
227
243
|
* turn ends, as `session/subscribe {sessionId, turnId}` does. Default true;
|
|
@@ -299,6 +315,8 @@ export const TurnSteerParamsSchema = z.object({
|
|
|
299
315
|
(input) => (typeof input === "string" ? input.trim() !== "" : input.length > 0),
|
|
300
316
|
"a steer carries input",
|
|
301
317
|
),
|
|
318
|
+
/** Who sent the input; absent is the person. Part of the steer's identity, as its input is. */
|
|
319
|
+
origin: OriginSchema.optional(),
|
|
302
320
|
});
|
|
303
321
|
export type TurnSteerParams = z.infer<typeof TurnSteerParamsSchema>;
|
|
304
322
|
|
package/src/server/bin.ts
CHANGED
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
resolveHarnessName,
|
|
34
34
|
scriptedFile,
|
|
35
35
|
} from "../core/index.ts";
|
|
36
|
-
import { THINKING_LEVELS, type ThinkingLevel
|
|
36
|
+
import { THINKING_LEVELS, type ThinkingLevel } from "../protocol/index.ts";
|
|
37
37
|
import { AgentServer } from "./agent-server.ts";
|
|
38
38
|
import { runFeedbackCommand } from "./feedback.ts";
|
|
39
39
|
import { installedLine, nothingToInstall, runInstall, toolsFor } from "./install.ts";
|
|
@@ -88,7 +88,8 @@ function usage(exitCode: number): never {
|
|
|
88
88
|
" --stdio serve NDJSON JSON-RPC on stdio (the default)",
|
|
89
89
|
" --acp speak ACP v1 on stdio instead (be the agent)",
|
|
90
90
|
" --model <id> every turn runs on this model (default: the harness's own)",
|
|
91
|
-
` --thinking <level> and at this thinking level (${THINKING_LEVELS.join(", ")}
|
|
91
|
+
` --thinking <level> and at this thinking level (${THINKING_LEVELS.join(", ")},`,
|
|
92
|
+
" or another the model lists);",
|
|
92
93
|
" the operator's choice: an ACP client cannot change either",
|
|
93
94
|
" install download the pinned agent CLIs into the managed cache",
|
|
94
95
|
" (always downloads — run at image build time to erase",
|
|
@@ -237,9 +238,10 @@ function parseArgs(argv: string[]): Args {
|
|
|
237
238
|
if (!args.model) fail("--model needs a model id");
|
|
238
239
|
} else if (arg === "--thinking") {
|
|
239
240
|
const level = next();
|
|
240
|
-
|
|
241
|
+
// A flag where the level belongs means the level was left out.
|
|
242
|
+
if (!level.trim() || level.startsWith("-"))
|
|
241
243
|
fail(
|
|
242
|
-
`--thinking
|
|
244
|
+
`--thinking needs a level: ${THINKING_LEVELS.slice(0, -1).join(", ")} or ${THINKING_LEVELS.at(-1)}, or another the model lists`,
|
|
243
245
|
);
|
|
244
246
|
args.thinking = level;
|
|
245
247
|
} else if (arg === "--credentials-url") {
|