@zvada/agent-server 0.3.26 → 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 +33 -0
- package/README.md +1 -1
- package/dist/client/client.js +27 -11
- package/dist/client/connection.js +35 -3
- package/dist/core/agents/claude-code/approvals.js +1 -1
- package/dist/core/agents/codex-app-server/plan-approval.js +1 -1
- package/dist/core/agents/scripted/scripted-agent.js +30 -3
- package/dist/core/presets.js +4 -1
- 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 +12 -5
- 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/origin.js +39 -0
- package/dist/protocol/reduce.js +2 -0
- package/dist/protocol/wire.js +17 -0
- 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/base.d.ts +2 -0
- package/dist/types/core/agents/base.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/presets.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 +20 -5
- package/dist/types/protocol/config.d.ts.map +1 -1
- package/dist/types/protocol/conversation.d.ts +44 -3
- package/dist/types/protocol/conversation.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 +40 -2
- package/dist/types/protocol/lifecycle.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/wire-api.d.ts +39 -1
- package/dist/types/protocol/wire-api.d.ts.map +1 -1
- package/dist/types/protocol/wire.d.ts +65 -2
- package/dist/types/protocol/wire.d.ts.map +1 -1
- package/dist/types/server/routes.d.ts.map +1 -1
- package/docs/consuming.md +56 -121
- package/docs/sync-history.md +2 -1
- package/package.json +1 -1
- 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/base.ts +2 -0
- package/src/core/agents/claude-code/approvals.ts +2 -2
- package/src/core/agents/codex-app-server/plan-approval.ts +1 -1
- package/src/core/agents/scripted/scripted-agent.ts +42 -3
- package/src/core/presets.ts +4 -1
- 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 +14 -6
- 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/origin.ts +47 -0
- package/src/protocol/reduce.ts +4 -0
- package/src/protocol/wire.ts +18 -0
- 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";
|
|
@@ -161,19 +162,26 @@ export const RunRequestSchema = z.object({
|
|
|
161
162
|
turnId: z.string(),
|
|
162
163
|
input: AgentInputSchema,
|
|
163
164
|
config: RunConfigSchema,
|
|
165
|
+
/** Who sent the input; absent is the person (`OriginSchema`). */
|
|
166
|
+
origin: OriginSchema.optional(),
|
|
164
167
|
});
|
|
165
168
|
export type RunRequest = z.infer<typeof RunRequestSchema>;
|
|
166
169
|
|
|
170
|
+
// @ref LLP 0019#origin-on-the-wire-and-to-the-model — another sender is another turn
|
|
167
171
|
/**
|
|
168
|
-
* What makes a turn the same turn when a client sends its ids again: its
|
|
169
|
-
* and the config that shapes what the agent does. What a
|
|
170
|
-
* can change without making it another turn stays out:
|
|
171
|
-
* 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.
|
|
172
178
|
*/
|
|
173
|
-
export function turnIdentity(request: Pick<RunRequest, "input" | "config">): {
|
|
179
|
+
export function turnIdentity(request: Pick<RunRequest, "input" | "config" | "origin">): {
|
|
174
180
|
input: RunRequest["input"];
|
|
175
181
|
config: Omit<RunConfig, "mcpServers" | "env" | "apiKey" | "includeRaw">;
|
|
182
|
+
origin?: Origin;
|
|
176
183
|
} {
|
|
177
184
|
const { mcpServers: _mcp, env: _env, apiKey: _key, includeRaw: _raw, ...config } = request.config;
|
|
178
|
-
|
|
185
|
+
const origin = agentOrigin(request.origin);
|
|
186
|
+
return { input: request.input, config, ...(origin && { origin }) };
|
|
179
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
|
/**
|
|
@@ -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/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/routes.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
type RunRequest,
|
|
8
8
|
type SessionSubscribeResult,
|
|
9
9
|
type TurnEndedEvent,
|
|
10
|
+
WIRE_FEATURES,
|
|
10
11
|
WIRE_METHODS,
|
|
11
12
|
WIRE_PROTOCOL_VERSION,
|
|
12
13
|
type WireEventEnvelope,
|
|
@@ -155,12 +156,17 @@ export function executionRoutes(host: RouteHost): Routes<ExecutionMethod> {
|
|
|
155
156
|
);
|
|
156
157
|
const harnesses: Record<string, AgentCapabilities> = {};
|
|
157
158
|
for (const harness of runtime.harnesses) harnesses[harness] = runtime.capabilities(harness);
|
|
158
|
-
return {
|
|
159
|
+
return {
|
|
160
|
+
protocolVersion: WIRE_PROTOCOL_VERSION,
|
|
161
|
+
...host.identity,
|
|
162
|
+
harnesses,
|
|
163
|
+
features: Object.values(WIRE_FEATURES),
|
|
164
|
+
};
|
|
159
165
|
},
|
|
160
166
|
|
|
161
167
|
[WIRE_METHODS.turnStart]: (parsed, context) => {
|
|
162
168
|
if (!host.accepting()) throw new WireRefusal("shuttingDown", "server is shutting down");
|
|
163
|
-
const { config, input } = parsed;
|
|
169
|
+
const { config, input, origin } = parsed;
|
|
164
170
|
assertHarness(runtime, config.harness);
|
|
165
171
|
const sessionId = parsed.sessionId ?? generateUUIDv7();
|
|
166
172
|
const turnId = parsed.turnId ?? generateUUIDv7();
|
|
@@ -176,7 +182,7 @@ export function executionRoutes(host: RouteHost): Routes<ExecutionMethod> {
|
|
|
176
182
|
// caller to the turn while it runs. A durable store remembers every
|
|
177
183
|
// turn it admitted, the runtime only its recent ones. The same turnId
|
|
178
184
|
// with different input is a caller bug → turnConflict.
|
|
179
|
-
const request = { sessionId, turnId, input, config };
|
|
185
|
+
const request = { sessionId, turnId, input, config, ...(origin && { origin }) };
|
|
180
186
|
const duplicate = store.duplicateOf(request) ?? converged(request);
|
|
181
187
|
if (duplicate) {
|
|
182
188
|
const headSeq = store.point(sessionId)?.headSeq;
|
|
@@ -229,8 +235,13 @@ export function executionRoutes(host: RouteHost): Routes<ExecutionMethod> {
|
|
|
229
235
|
},
|
|
230
236
|
|
|
231
237
|
// @ref LLP 0001#d13--input-while-a-turn-runs-steers-it — the runtime decides
|
|
232
|
-
[WIRE_METHODS.turnSteer]: ({ sessionId, turnId, steerId, input }) =>
|
|
233
|
-
runtime.steer(sessionId, {
|
|
238
|
+
[WIRE_METHODS.turnSteer]: ({ sessionId, turnId, steerId, input, origin }) =>
|
|
239
|
+
runtime.steer(sessionId, {
|
|
240
|
+
turnId,
|
|
241
|
+
steerId: steerId ?? generateUUIDv7(),
|
|
242
|
+
input,
|
|
243
|
+
...(origin && { origin }),
|
|
244
|
+
}),
|
|
234
245
|
|
|
235
246
|
[WIRE_METHODS.sessionClose]: async ({ sessionId }) => {
|
|
236
247
|
gate.assertIdle(sessionId);
|