@zvada/agent-server 0.3.21 → 0.3.22

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.
Files changed (69) hide show
  1. package/CHANGELOG.md +71 -0
  2. package/README.md +2 -1
  3. package/dist/types/client/connection.d.ts +2 -0
  4. package/dist/types/client/connection.d.ts.map +1 -1
  5. package/dist/types/client/logins.d.ts +2 -2
  6. package/dist/types/client/logins.d.ts.map +1 -1
  7. package/dist/types/core/agents/codex-app-server/client.d.ts +9 -0
  8. package/dist/types/core/agents/codex-app-server/client.d.ts.map +1 -1
  9. package/dist/types/core/agents/codex-app-server/codex-agent.d.ts +3 -1
  10. package/dist/types/core/agents/codex-app-server/codex-agent.d.ts.map +1 -1
  11. package/dist/types/core/agents/codex-app-server/homes.d.ts +7 -5
  12. package/dist/types/core/agents/codex-app-server/homes.d.ts.map +1 -1
  13. package/dist/types/core/agents/codex-app-server/mcp.d.ts +48 -8
  14. package/dist/types/core/agents/codex-app-server/mcp.d.ts.map +1 -1
  15. package/dist/types/core/agents/codex-app-server/options.d.ts +6 -2
  16. package/dist/types/core/agents/codex-app-server/options.d.ts.map +1 -1
  17. package/dist/types/core/agents/codex-app-server/session.d.ts +10 -1
  18. package/dist/types/core/agents/codex-app-server/session.d.ts.map +1 -1
  19. package/dist/types/core/agents/codex-app-server/turn.d.ts +6 -0
  20. package/dist/types/core/agents/codex-app-server/turn.d.ts.map +1 -1
  21. package/dist/types/core/agents/plan.d.ts +2 -13
  22. package/dist/types/core/agents/plan.d.ts.map +1 -1
  23. package/dist/types/core/index.d.ts +1 -1
  24. package/dist/types/core/index.d.ts.map +1 -1
  25. package/dist/types/core/runtime/agent-runtime.d.ts +2 -1
  26. package/dist/types/core/runtime/agent-runtime.d.ts.map +1 -1
  27. package/dist/types/core/runtime/turn.d.ts +2 -0
  28. package/dist/types/core/runtime/turn.d.ts.map +1 -1
  29. package/dist/types/core/utils/errors.d.ts +8 -0
  30. package/dist/types/core/utils/errors.d.ts.map +1 -1
  31. package/dist/types/operator/index.d.ts +11 -0
  32. package/dist/types/operator/index.d.ts.map +1 -0
  33. package/dist/types/operator/mcp.d.ts +33 -0
  34. package/dist/types/operator/mcp.d.ts.map +1 -0
  35. package/dist/types/operator/operator.d.ts +206 -0
  36. package/dist/types/operator/operator.d.ts.map +1 -0
  37. package/dist/types/operator/render.d.ts +87 -0
  38. package/dist/types/operator/render.d.ts.map +1 -0
  39. package/dist/types/operator/view.d.ts +44 -0
  40. package/dist/types/operator/view.d.ts.map +1 -0
  41. package/dist/types/protocol/plan.d.ts +20 -0
  42. package/dist/types/protocol/plan.d.ts.map +1 -0
  43. package/dist/types/server/acp/binding.d.ts.map +1 -1
  44. package/dist/types/sync/worker.d.ts.map +1 -1
  45. package/docs/consuming.md +188 -14
  46. package/docs/harnesses.md +13 -8
  47. package/package.json +6 -1
  48. package/src/client/connection.ts +10 -0
  49. package/src/client/logins.ts +23 -14
  50. package/src/core/agents/codex-app-server/client.ts +32 -2
  51. package/src/core/agents/codex-app-server/codex-agent.ts +26 -5
  52. package/src/core/agents/codex-app-server/homes.ts +16 -9
  53. package/src/core/agents/codex-app-server/mcp.ts +122 -21
  54. package/src/core/agents/codex-app-server/options.ts +10 -1
  55. package/src/core/agents/codex-app-server/session.ts +46 -9
  56. package/src/core/agents/codex-app-server/turn.ts +26 -12
  57. package/src/core/agents/plan.ts +3 -19
  58. package/src/core/index.ts +1 -0
  59. package/src/core/runtime/agent-runtime.ts +22 -16
  60. package/src/core/runtime/turn.ts +2 -0
  61. package/src/core/utils/errors.ts +13 -0
  62. package/src/operator/index.ts +40 -0
  63. package/src/operator/mcp.ts +171 -0
  64. package/src/operator/operator.ts +778 -0
  65. package/src/operator/render.ts +435 -0
  66. package/src/operator/view.ts +82 -0
  67. package/src/protocol/plan.ts +35 -0
  68. package/src/server/acp/binding.ts +3 -2
  69. package/src/sync/worker.ts +4 -0
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","source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gB;gBACzC,OAAO,EAAE,MAAM;CAI3B;AAED,6FAA6F;AAC7F,qBAAa,eAAgB,SAAQ,gBAAgB;IACxC,QAAQ,CAAC,SAAS,EAAE,MAAM;gBAAjB,SAAS,EAAE,MAAM;CAQtC;AAGD;;;GAGG;AACH,qBAAa,0BAA2B,SAAQ,gBAAgB;gBACnD,OAAO,EAAE,MAAM;CAI3B;AAED;;;;GAIG;AACH,qBAAa,kBAAmB,SAAQ,gBAAgB;IAEtD,QAAQ,CAAC,eAAe,EAAE,MAAM;gBAAvB,eAAe,EAAE,MAAM,EAChC,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAW9B;AAED;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,gBAAgB;IAC5C,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBAAzC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAW9D;AAED,qBAAa,gBAAiB,SAAQ,gBAAgB;gBACzC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;CAOvC;AAED,gFAAgF;AAChF,qBAAa,iBAAkB,SAAQ,gBAAgB;gBAC1C,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAK1D"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * `@zvada/agent-server/operator`: the session tools an outside agent operates a
3
+ * product's coding agents with, and their MCP binding. Imports only the
4
+ * protocol and zod; the product is the `OperatorHost` (LLP 0014).
5
+ */
6
+ export { PLAN_OPTIONS, PLAN_TITLE } from "../protocol/plan.ts";
7
+ export { type McpHandler, type McpServerInfo, type ToolSource, createMcpHandler, } from "./mcp.ts";
8
+ export { type Operator, type OperatorClock, type OperatorHost, type OperatorOptions, type SendOptions, type SendResult, type SessionEntry, type StartInput, type StartResult, type Tool, type ToolInfo, type ViewOptions, OperatorError, createOperator, tool, } from "./operator.ts";
9
+ export { type Answer, callHint, oneLine, quote, quoted } from "./render.ts";
10
+ export { type DecisionRequest, type Phase, type QuestionRequest, type SessionView, type ViewMessage, type Waiting, phaseOf, viewOf, } from "./view.ts";
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/operator/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EACN,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,gBAAgB,GAChB,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,IAAI,EACT,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,aAAa,EACb,cAAc,EACd,IAAI,GACJ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EACN,KAAK,eAAe,EACpB,KAAK,KAAK,EACV,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,OAAO,EACP,MAAM,GACN,MAAM,WAAW,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * The operator tools over MCP, with no dependency: one function answers one
3
+ * JSON-RPC message (or a batch) of the Model Context Protocol's tool surface.
4
+ *
5
+ * It serves stateless Streamable HTTP. A product's route parses the POST
6
+ * body, calls the handler with the caller it authenticated, and answers
7
+ * `200 application/json` with the result, or `202` with no body when the
8
+ * result is null (a notification). It answers GET with `405`: the server
9
+ * never opens a stream of its own.
10
+ */
11
+ import { type ToolInfo } from "./operator.ts";
12
+ /** Anything that lists and runs tools: an operator, or a host's wrapper around one. */
13
+ export interface ToolSource<Caller> {
14
+ tools(caller: Caller): ToolInfo[];
15
+ call(name: string, args: unknown, caller: Caller): Promise<string>;
16
+ }
17
+ export interface McpServerInfo {
18
+ name: string;
19
+ version: string;
20
+ title?: string;
21
+ /** Words for the client's model about how to use the server. */
22
+ instructions?: string;
23
+ }
24
+ /**
25
+ * The MCP protocol versions this binding answers, newest first: the list the
26
+ * official SDK (`@modelcontextprotocol/sdk` 1.32, `SUPPORTED_PROTOCOL_VERSIONS`
27
+ * in its `types.js`) accepts. The tool methods used here are the same in each.
28
+ */
29
+ export declare const MCP_PROTOCOL_VERSIONS: readonly ["2025-11-25", "2025-06-18", "2025-03-26", "2024-11-05", "2024-10-07"];
30
+ export type McpHandler<Caller> = (message: unknown, caller: Caller) => Promise<unknown | null>;
31
+ /** Answer one MCP JSON-RPC message (or batch array). Returns the response, or null for a notification. */
32
+ export declare function createMcpHandler<Caller>(source: ToolSource<Caller>, info: McpServerInfo): McpHandler<Caller>;
33
+ //# sourceMappingURL=mcp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../../src/operator/mcp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAiB,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAG7D,uFAAuF;AACvF,MAAM,WAAW,UAAU,CAAC,MAAM;IACjC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,EAAE,CAAC;IAClC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACnE;AAED,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gEAAgE;IAChE,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,iFAMxB,CAAC;AAKX,MAAM,MAAM,UAAU,CAAC,MAAM,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;AAgB/F,0GAA0G;AAC1G,wBAAgB,gBAAgB,CAAC,MAAM,EACtC,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,EAC1B,IAAI,EAAE,aAAa,GACjB,UAAU,CAAC,MAAM,CAAC,CA+FpB"}
@@ -0,0 +1,206 @@
1
+ /**
2
+ * Operator tools: what a person does with a set of agent sessions, as a handful
3
+ * of calls an outside agent can make. See what each session is doing, read one,
4
+ * start one, tell it something, wait for it, answer what it asks, stop it.
5
+ *
6
+ * The tools are transport-neutral: `tools()` lists them (name, words for a
7
+ * model, JSON Schema input, whether they only read) and `call()` runs one and
8
+ * answers in text. `createMcpHandler` (mcp.ts) serves them over MCP; a product
9
+ * adds its own tools (its projects, its diffs) beside them with `tool()` so
10
+ * they read as one set.
11
+ *
12
+ * The product supplies an `OperatorHost`: which sessions exist and what they are
13
+ * called, how to read one, and how to start, stop and answer a turn (it owns the
14
+ * run configuration, the storage and the authorization; the engine owns none).
15
+ */
16
+ import { z } from "zod";
17
+ import { type Answer } from "./render.ts";
18
+ import { type Phase, type SessionView } from "./view.ts";
19
+ /** One session as the host lists it. `name` is what people and agents call it. */
20
+ export interface SessionEntry {
21
+ /** The host's id. */
22
+ id: string;
23
+ /** What people call it; unique within its group. */
24
+ name: string;
25
+ /** What it belongs to (a project, a repository). Listed under it. */
26
+ group?: string;
27
+ phase: Phase;
28
+ title?: string;
29
+ /** Epoch milliseconds. */
30
+ lastActivityAt?: number;
31
+ /** A few words the host adds to the row (lines changed, a pull request). */
32
+ note?: string;
33
+ /** Paths in this session's tool lines are shown relative to this folder. */
34
+ root?: string;
35
+ }
36
+ export interface SendOptions {
37
+ /** `interrupt` stops a running turn first; `auto` is refused while one runs. */
38
+ delivery: "auto" | "interrupt";
39
+ }
40
+ export interface ViewOptions {
41
+ /** The most recent messages wanted. A host may give more; the operator cuts. */
42
+ last?: number;
43
+ }
44
+ export interface StartInput {
45
+ /** The group (project) the new session is listed under. */
46
+ group: string;
47
+ /** Its first task. */
48
+ message: string;
49
+ }
50
+ /**
51
+ * What `send` may resolve to. `duplicate: true`: this caller's identical
52
+ * request is still in flight, so nothing new was sent. Resolving to nothing
53
+ * (or `duplicate` absent or false) means a new turn was sent.
54
+ */
55
+ export interface SendResult {
56
+ duplicate?: boolean;
57
+ /**
58
+ * One line in the host's words about what the send did that the view cannot
59
+ * show (for example, a message the host held that this one replaced).
60
+ * `send_message` says it before the outcome.
61
+ */
62
+ note?: string;
63
+ }
64
+ /**
65
+ * What `start` returns: the session, with `duplicate: true` when this caller's
66
+ * identical start is still in flight (that session is returned) and nothing
67
+ * new was started.
68
+ */
69
+ export interface StartResult extends SessionEntry {
70
+ duplicate?: boolean;
71
+ }
72
+ export interface OperatorHost<Caller = unknown> {
73
+ /** The sessions this caller may see. */
74
+ list(caller: Caller): Promise<SessionEntry[]>;
75
+ view(caller: Caller, sessionId: string, options?: ViewOptions): Promise<SessionView>;
76
+ /**
77
+ * Start a turn. The host chooses the agent, model, permissions and turn id.
78
+ * Refuse (throw an `OperatorError`) a turn while another runs and `delivery`
79
+ * is `auto`. A repeat is the same caller, the same session and the same
80
+ * message (trimmed) while the turn that message started is being sent or has
81
+ * not ended, whatever its `delivery`: send nothing and resolve to
82
+ * `{ duplicate: true }`. The operator then reports that turn as it stands,
83
+ * and never waits for a new one to show. Once that turn has ended, the same
84
+ * words are a new turn. Recognising a repeat is optional: a host that never
85
+ * reports one refuses it as busy, which is safe. With `interrupt`, resolve
86
+ * only once the turn it stops has ended: the operator then takes the next
87
+ * working view as the new turn.
88
+ */
89
+ send(caller: Caller, sessionId: string, message: string, options: SendOptions): Promise<void | SendResult>;
90
+ /**
91
+ * Stop the session's turn. Resolve to `{ note }` when the stop is complete in
92
+ * a way the view cannot show (for example, a message the host held, dropped
93
+ * before it was sent): `stop_session` answers with the note and does not
94
+ * wait for the view to change.
95
+ */
96
+ cancel(caller: Caller, sessionId: string): Promise<void | {
97
+ note: string;
98
+ }>;
99
+ respond(caller: Caller, sessionId: string, answer: Answer): Promise<void>;
100
+ /**
101
+ * Optional: create a session in a group and give it its first task. Enables
102
+ * `start_session`. It may return as soon as the session exists: until its
103
+ * first turn begins, its view is `working` with no messages, and the
104
+ * operator waits through that like a turn. A repeat is the same caller, the
105
+ * same group (case-insensitive) and the same message while the session it
106
+ * made is being set up or its first turn has not ended: return that session
107
+ * with `duplicate: true` and start nothing. Recognising a repeat is
108
+ * optional: a host that never reports one starts a second session.
109
+ */
110
+ start?(caller: Caller, input: StartInput): Promise<StartResult>;
111
+ /**
112
+ * Optional: the name of every group (project) this caller could start a
113
+ * session in, those with no session included. `list_sessions` then shows
114
+ * the empty ones too, and the `start_session` hint names a real one.
115
+ */
116
+ groups?(caller: Caller): Promise<string[]>;
117
+ /**
118
+ * Optional: the session with this id, for one `list` leaves out (a host that
119
+ * lists only its newest). Tried, with the reference as given (trimmed), when
120
+ * it names nothing listed. Throw an `OperatorError` to refuse it in your
121
+ * words: one the host knows but will not act on (archived) is no typo.
122
+ */
123
+ entry?(caller: Caller, sessionId: string): Promise<SessionEntry | undefined>;
124
+ /** Optional: one line of host facts appended when a turn has settled ("changes: a.ts (+4 -0)"). */
125
+ outcome?(caller: Caller, entry: SessionEntry): Promise<string | undefined>;
126
+ /**
127
+ * Optional: resolves when any session may have changed. Remove what it
128
+ * registered when `signal` aborts (it always does, after each look). Without
129
+ * it the operator looks again every half second.
130
+ */
131
+ changed?(signal: AbortSignal): Promise<void>;
132
+ }
133
+ export interface Tool<Caller = unknown> {
134
+ name: string;
135
+ title: string;
136
+ description: string;
137
+ input: z.ZodObject;
138
+ /** A tool that only reads: assistants run these without asking the person. */
139
+ readOnly: boolean;
140
+ /** It reaches past this host (sends something elsewhere): MCP's `openWorldHint`. */
141
+ openWorld?: boolean;
142
+ /** It may undo or lose work (stops a turn, removes something): MCP's `destructiveHint`. */
143
+ destructive?: boolean;
144
+ run(args: never, caller: Caller): Promise<string>;
145
+ }
146
+ /** Declare a tool, typed by its input. Hosts use this for their own tools. */
147
+ export declare function tool<Shape extends z.ZodRawShape, Caller = unknown>(def: {
148
+ name: string;
149
+ title: string;
150
+ description: string;
151
+ input: Shape;
152
+ readOnly: boolean;
153
+ openWorld?: boolean;
154
+ destructive?: boolean;
155
+ run(args: z.infer<z.ZodObject<Shape>>, caller: Caller): Promise<string>;
156
+ }): Tool<Caller>;
157
+ /** A tool as any transport lists it. */
158
+ export interface ToolInfo {
159
+ name: string;
160
+ title: string;
161
+ description: string;
162
+ /** JSON Schema of the arguments (an object). */
163
+ inputSchema: unknown;
164
+ readOnly: boolean;
165
+ /** It reaches past this host: MCP's `openWorldHint`. */
166
+ openWorld?: boolean;
167
+ /** It may undo or lose work: MCP's `destructiveHint`. */
168
+ destructive?: boolean;
169
+ }
170
+ /** Time, for the waits. Tests pass their own; the default is the wall clock. */
171
+ export interface OperatorClock {
172
+ now(): number;
173
+ /** Resolve after `ms`, or as soon as `signal` aborts. */
174
+ pause(ms: number, signal: AbortSignal): Promise<void>;
175
+ }
176
+ export interface OperatorOptions<Caller> {
177
+ /**
178
+ * No held call outlasts this (hosted assistants cut a tool call off after 2
179
+ * to 4 minutes). Default 90. A function is asked once per call, for the
180
+ * calling caller (a host holds a call no longer than the caller's sign-in
181
+ * has left). Below one second, a call does not wait: it looks once and
182
+ * answers, a working session as still working.
183
+ */
184
+ maxWaitSeconds?: number | ((caller: Caller) => number);
185
+ /** The host's own tools, listed after the session tools. */
186
+ extra?: Tool<Caller>[];
187
+ clock?: OperatorClock;
188
+ }
189
+ export interface Operator<Caller = unknown> {
190
+ /**
191
+ * The tools, as any transport lists them: the same for every caller (an
192
+ * assistant keeps the list it got when it connected). A host that limits
193
+ * what a caller may run checks around `call`, in its own words.
194
+ */
195
+ tools(caller: Caller): ToolInfo[];
196
+ /** Run one tool and answer in text. Refusals a model can act on are `OperatorError`s. */
197
+ call(name: string, args: unknown, caller: Caller): Promise<string>;
198
+ /** The session a model's `session` argument names (name, `group/name` or id). */
199
+ find(caller: Caller, ref: string): Promise<SessionEntry>;
200
+ }
201
+ /** A refusal a model can act on: its message says what to do instead. */
202
+ export declare class OperatorError extends Error {
203
+ name: string;
204
+ }
205
+ export declare function createOperator<Caller = unknown>(host: OperatorHost<Caller>, options?: OperatorOptions<Caller>): Operator<Caller>;
206
+ //# sourceMappingURL=operator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operator.d.ts","sourceRoot":"","sources":["../../../src/operator/operator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACN,KAAK,MAAM,EAUX,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,WAAW,EAAW,MAAM,WAAW,CAAC;AAElE,kFAAkF;AAClF,MAAM,WAAW,YAAY;IAC5B,qBAAqB;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0BAA0B;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,4EAA4E;IAC5E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4EAA4E;IAC5E,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AA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MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACnE,iFAAiF;IACjF,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CACzD;AAED,yEAAyE;AACzE,qBAAa,aAAc,SAAQ,KAAK;IAC9B,IAAI,SAAmB;CAChC;AA0DD,wBAAgB,cAAc,CAAC,MAAM,GAAG,OAAO,EAC9C,IAAI,EAAE,YAAY,CAAC,MAAM,CAAC,EAC1B,OAAO,GAAE,eAAe,CAAC,MAAM,CAAM,GACnC,QAAQ,CAAC,MAAM,CAAC,CA8dlB"}
@@ -0,0 +1,87 @@
1
+ /**
2
+ * A session, in words a model can act on: short, with the next step named as
3
+ * the call that takes it. Pure functions over a `SessionView`.
4
+ *
5
+ * `ref` is how the hints name the session: its name, or `group/name` where the
6
+ * name alone is ambiguous.
7
+ */
8
+ import type { ElicitationOutcome, PermissionOutcome } from "../protocol/lifecycle.ts";
9
+ import type { Part, UnknownPart } from "../protocol/parts.ts";
10
+ import { type SessionView, type ViewMessage, type Waiting } from "./view.ts";
11
+ /** The marker every line of untrusted text begins with. */
12
+ export declare const QUOTE = " | ";
13
+ /** The most messages `read_session` reads. */
14
+ export declare const MAX_LAST = 100;
15
+ /** Untrusted text as one line: no line breaks or controls, runs of space collapsed. */
16
+ export declare function oneLine(text: string): string;
17
+ /** Untrusted text as a block: each of its lines carried after `QUOTE`. */
18
+ export declare function quote(text: string): string;
19
+ /** Untrusted text named in prose (a session, a project, an option): one JSON-quoted line. */
20
+ export declare const quoted: (text: string) => string;
21
+ /**
22
+ * The next step, as the tool call that takes it:
23
+ * `-> answer_request(session: "voyager", answer: "<your answer>")`.
24
+ */
25
+ export declare function callHint(tool: string, args?: Record<string, string | number | boolean>): string;
26
+ /**
27
+ * One tool call on one line: its name, what it acted on, and whether it failed.
28
+ * `working: false` (its session runs no turn) shows a tool left open as
29
+ * interrupted, not running: its turn ended without it. Paths under `root` read
30
+ * relative to it, wherever they appear. A call that put a question to the
31
+ * person says whether it was answered, one that put a plan whether it was
32
+ * approved (`askedIn`).
33
+ */
34
+ export declare function toolLine(part: Part | UnknownPart, root?: string, working?: boolean): string | null;
35
+ /**
36
+ * Why only the person can answer what the agent waits on, where the session
37
+ * runs: a form to fill in, a page to visit, a secret to type, or a kind of
38
+ * request these tools do not know. Undefined for one a model may answer.
39
+ */
40
+ export declare function personOnly(waiting: Waiting): string | undefined;
41
+ /**
42
+ * What the agent waits on, and the exact call that answers it. What only the
43
+ * person can answer (`personOnly`) is one line, with no call.
44
+ */
45
+ export declare function describeWaiting(waiting: Waiting, ref: string): string;
46
+ /** The agent's words since the person last spoke. */
47
+ export declare function lastReply(messages: readonly ViewMessage[]): string;
48
+ /**
49
+ * How a turn stands: finished, waiting on the person, failed, or still going.
50
+ * `waitedSeconds` is how long this call waited; `note` is the host's line of
51
+ * facts for a turn that is not working any more.
52
+ */
53
+ export declare function renderOutcome(view: SessionView, ref: string, waitedSeconds?: number, note?: string): string;
54
+ export interface RenderOptions {
55
+ /** How many recent messages (default 10). */
56
+ last?: number;
57
+ /** Paths in tool lines are shown relative to this folder. */
58
+ root?: string;
59
+ }
60
+ /**
61
+ * The conversation, condensed: what was asked, what the agent said, which
62
+ * tools it ran, and under a call that asked the person its questions and
63
+ * what the agent was told (or its plan).
64
+ */
65
+ export declare function renderConversation(view: SessionView, ref: string, options?: RenderOptions): string;
66
+ /** A person's words as the engine takes them, for the request the agent waits on. */
67
+ export type Answer = {
68
+ kind: "question";
69
+ requestId: string;
70
+ outcome: ElicitationOutcome;
71
+ } | {
72
+ kind: "decision";
73
+ requestId: string;
74
+ outcome: PermissionOutcome;
75
+ };
76
+ /**
77
+ * What a person said, as the outcome of the request the agent waits on (one
78
+ * a model may answer: not `personOnly`).
79
+ * A question takes the words (one per question, split on new lines or `;`,
80
+ * matched to an option's label where one fits). A plan is approved only by
81
+ * an answer that is a yes and nothing more ("approve", "ok", "go ahead"), and
82
+ * otherwise sent back with the words as what to change. A permission takes an
83
+ * option's name, a whole yes (allow once) or a no (reject once, the words as
84
+ * the reason); anything else cancels it.
85
+ */
86
+ export declare function answerFor(waiting: Waiting, text: string): Answer;
87
+ //# sourceMappingURL=render.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../src/operator/render.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AACtF,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAE9D,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,WAAW,EAAE,KAAK,OAAO,EAAmB,MAAM,WAAW,CAAC;AAU9F,2DAA2D;AAC3D,eAAO,MAAM,KAAK,SAAS,CAAC;AAU5B,8CAA8C;AAC9C,eAAO,MAAM,QAAQ,MAAM,CAAC;AAE5B,uFAAuF;AACvF,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED,0EAA0E;AAC1E,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM1C;AAED,6FAA6F;AAC7F,eAAO,MAAM,MAAM,GAAI,MAAM,MAAM,WAAkC,CAAC;AAWtE;;;GAGG;AACH,wBAAgB,QAAQ,CACvB,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAM,GAClD,MAAM,CAQR;AA8FD;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,WAAW,EAAE,IAAI,SAAK,EAAE,OAAO,UAAO,GAAG,MAAM,GAAG,IAAI,CAgB3F;AA0BD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAO/D;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAmCrE;AAED,qDAAqD;AACrD,wBAAgB,SAAS,CAAC,QAAQ,EAAE,SAAS,WAAW,EAAE,GAAG,MAAM,CAUlE;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC5B,IAAI,EAAE,WAAW,EACjB,GAAG,EAAE,MAAM,EACX,aAAa,CAAC,EAAE,MAAM,EACtB,IAAI,CAAC,EAAE,MAAM,GACX,MAAM,CAqBR;AAED,MAAM,WAAW,aAAa;IAC7B,6CAA6C;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6DAA6D;IAC7D,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CACjC,IAAI,EAAE,WAAW,EACjB,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,aAAkB,GACzB,MAAM,CAoCR;AAED,qFAAqF;AACrF,MAAM,MAAM,MAAM,GACf;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,kBAAkB,CAAA;CAAE,GACpE;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,iBAAiB,CAAA;CAAE,CAAC;AAQvE;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAsChE"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * What an operator needs to know about one session, however its host keeps it.
3
+ *
4
+ * A host that holds a folded `ConversationState` gets this with `viewOf`. A host
5
+ * that keeps its own rows (messages with their parts, a status column) builds
6
+ * the same shape directly. Nothing here knows about projects, workspaces,
7
+ * accounts or storage: those are the host's.
8
+ */
9
+ import { type ConversationElicitation, type ConversationPermission, type ConversationState } from "../protocol/conversation.ts";
10
+ import type { Part, UnknownPart } from "../protocol/parts.ts";
11
+ export interface ViewMessage {
12
+ role: "user" | "assistant";
13
+ parts: readonly (Part | UnknownPart)[];
14
+ /** A sub-agent's output: shown nested, never as the agent's reply. */
15
+ nested?: boolean;
16
+ }
17
+ /** A question the agent asked, as the engine's `elicitation.requested` carries it. */
18
+ export type QuestionRequest = Pick<ConversationElicitation, "requestId" | "mode" | "message" | "questions" | "url">;
19
+ /** A decision the agent waits on (a tool's approval, or a plan), as `permission.requested` carries it. */
20
+ export type DecisionRequest = Pick<ConversationPermission, "requestId" | "title" | "toolCall" | "options">;
21
+ export type Waiting = {
22
+ kind: "question";
23
+ request: QuestionRequest;
24
+ } | {
25
+ kind: "decision";
26
+ request: DecisionRequest;
27
+ };
28
+ export interface SessionView {
29
+ /** Whether a turn is running. "Waiting on a person" is `waiting`, not a status. */
30
+ status: "idle" | "working" | "error";
31
+ messages: readonly ViewMessage[];
32
+ waiting: readonly Waiting[];
33
+ error?: string;
34
+ /** The host holds earlier messages than the ones given here. */
35
+ older?: boolean;
36
+ }
37
+ /** What a person would call the session's state. Waiting on them is not "finished". */
38
+ export type Phase = "idle" | "working" | "needs_input" | "error";
39
+ export declare function phaseOf(view: Pick<SessionView, "status" | "waiting">): Phase;
40
+ /** A plan's approval is a decision whose options include "keep planning" (`PLAN_OPTIONS`). */
41
+ export declare function isPlan(request: DecisionRequest): boolean;
42
+ /** The view of a session whose events were folded with the engine's reducer. */
43
+ export declare function viewOf(state: ConversationState): SessionView;
44
+ //# sourceMappingURL=view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../../src/operator/view.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACN,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EAItB,MAAM,6BAA6B,CAAC;AACrC,OAAO,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ExD;AAED,gFAAgF;AAChF,wBAAgB,MAAM,CAAC,KAAK,EAAE,iBAAiB,GAAG,WAAW,CAgB5D"}
@@ -0,0 +1,20 @@
1
+ import type { PermissionOption } from "./lifecycle.ts";
2
+ /** The ids of a plan's options: each is the permission mode the session goes on in. */
3
+ export declare const PLAN_OPTION_IDS: {
4
+ readonly acceptEdits: "accept_edits";
5
+ readonly approve: "default";
6
+ readonly keepPlanning: "plan";
7
+ };
8
+ /**
9
+ * How a user answers an agent's plan: go on in a mode, or keep planning. Each
10
+ * option's id is the permission mode the session goes on in. These are Claude
11
+ * Code's own choices; Codex's TUI asks the same ("implement this plan" / "stay
12
+ * in Plan mode"). Auto-accepting edits is a standing choice for the edits to
13
+ * come (`allow_always`, as claude-agent-acp marks it), so an approver that
14
+ * takes the one-time approval implements asking for each edit. No standing
15
+ * rule answers a later plan: the broker keeps none for a harness's options.
16
+ */
17
+ export declare const PLAN_OPTIONS: PermissionOption[];
18
+ /** What a plan's approval asks. */
19
+ export declare const PLAN_TITLE = "Implement this plan?";
20
+ //# sourceMappingURL=plan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../../src/protocol/plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,uFAAuF;AACvF,eAAO,MAAM,eAAe;;;;CAIlB,CAAC;AAGX;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,EAAE,gBAAgB,EAY1C,CAAC;AAEF,mCAAmC;AACnC,eAAO,MAAM,UAAU,yBAAyB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"binding.d.ts","sourceRoot":"","sources":["../../../../src/server/acp/binding.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAa,MAAM,qBAAqB,CAAC;AAEn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