@zvada/agent-server 0.3.26 → 0.3.28

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 (262) hide show
  1. package/CHANGELOG.md +71 -0
  2. package/README.md +7 -5
  3. package/dist/client/client.js +27 -11
  4. package/dist/client/connection.js +35 -3
  5. package/dist/core/agents/acp/account.js +111 -0
  6. package/dist/core/agents/acp/acp-agent.js +247 -158
  7. package/dist/core/agents/acp/adapter.js +103 -34
  8. package/dist/core/agents/acp/client.js +169 -42
  9. package/dist/core/agents/acp/known-agents.js +12 -5
  10. package/dist/core/agents/acp/mappings.js +84 -20
  11. package/dist/core/agents/acp/models.js +59 -0
  12. package/dist/core/agents/acp/profile.js +36 -0
  13. package/dist/core/agents/acp/prompts.js +248 -0
  14. package/dist/core/agents/acp/requests.js +4 -4
  15. package/dist/core/agents/claude-code/approvals.js +1 -1
  16. package/dist/core/agents/claude-code/login.js +4 -1
  17. package/dist/core/agents/claude-code/session.js +38 -10
  18. package/dist/core/agents/claude-code/spawn.js +0 -26
  19. package/dist/core/agents/codex-app-server/client.js +12 -13
  20. package/dist/core/agents/codex-app-server/login.js +4 -1
  21. package/dist/core/agents/codex-app-server/plan-approval.js +1 -1
  22. package/dist/core/agents/gemini/failures.js +133 -0
  23. package/dist/core/agents/gemini/login.js +173 -0
  24. package/dist/core/agents/gemini/profile.js +137 -0
  25. package/dist/core/agents/gemini/tools.js +91 -0
  26. package/dist/core/agents/login.js +8 -6
  27. package/dist/core/agents/scripted/scripted-agent.js +30 -3
  28. package/dist/core/agents/stderr-tail.js +5 -2
  29. package/dist/core/presets.js +17 -1
  30. package/dist/core/processes/native-processes.js +23 -1
  31. package/dist/core/provision/install-build.js +70 -26
  32. package/dist/core/provision/pins.js +5 -0
  33. package/dist/core/provision/provisioner.js +39 -16
  34. package/dist/core/provision/releases.js +39 -1
  35. package/dist/core/provision/tools.js +87 -28
  36. package/dist/core/runtime/agent-runtime.js +15 -5
  37. package/dist/core/runtime/event-processor.js +13 -8
  38. package/dist/core/runtime/origin-line.js +42 -0
  39. package/dist/core/runtime/request-broker.js +2 -1
  40. package/dist/core/runtime/steering.js +4 -3
  41. package/dist/core/runtime/turn.js +6 -4
  42. package/dist/operator/errors.js +97 -0
  43. package/dist/operator/index.js +10 -5
  44. package/dist/operator/mcp.js +7 -12
  45. package/dist/operator/operator.js +1431 -378
  46. package/dist/operator/refs.js +59 -0
  47. package/dist/operator/render.js +199 -94
  48. package/dist/operator/session-tools.js +88 -0
  49. package/dist/operator/types.js +30 -0
  50. package/dist/operator/view.js +82 -27
  51. package/dist/protocol/account.js +5 -1
  52. package/dist/protocol/auth.js +5 -1
  53. package/dist/protocol/config.js +12 -5
  54. package/dist/protocol/conversation.js +3 -0
  55. package/dist/protocol/credentials.js +9 -1
  56. package/dist/protocol/harness.js +9 -1
  57. package/dist/protocol/history.js +2 -1
  58. package/dist/protocol/index.js +1 -0
  59. package/dist/protocol/lifecycle.js +19 -0
  60. package/dist/protocol/origin.js +39 -0
  61. package/dist/protocol/reduce.js +2 -0
  62. package/dist/protocol/wire.js +17 -0
  63. package/dist/server/bin.js +22 -7
  64. package/dist/server/install.js +6 -4
  65. package/dist/server/routes.js +15 -5
  66. package/dist/types/client/client.d.ts.map +1 -1
  67. package/dist/types/client/connection.d.ts +14 -2
  68. package/dist/types/client/connection.d.ts.map +1 -1
  69. package/dist/types/client/turns.d.ts +2 -2
  70. package/dist/types/client/turns.d.ts.map +1 -1
  71. package/dist/types/core/agents/acp/account.d.ts +55 -0
  72. package/dist/types/core/agents/acp/account.d.ts.map +1 -0
  73. package/dist/types/core/agents/acp/acp-agent.d.ts +65 -36
  74. package/dist/types/core/agents/acp/acp-agent.d.ts.map +1 -1
  75. package/dist/types/core/agents/acp/adapter.d.ts +28 -3
  76. package/dist/types/core/agents/acp/adapter.d.ts.map +1 -1
  77. package/dist/types/core/agents/acp/client.d.ts +66 -4
  78. package/dist/types/core/agents/acp/client.d.ts.map +1 -1
  79. package/dist/types/core/agents/acp/known-agents.d.ts +4 -2
  80. package/dist/types/core/agents/acp/known-agents.d.ts.map +1 -1
  81. package/dist/types/core/agents/acp/mappings.d.ts +53 -7
  82. package/dist/types/core/agents/acp/mappings.d.ts.map +1 -1
  83. package/dist/types/core/agents/acp/models.d.ts +22 -0
  84. package/dist/types/core/agents/acp/models.d.ts.map +1 -0
  85. package/dist/types/core/agents/acp/profile.d.ts +92 -0
  86. package/dist/types/core/agents/acp/profile.d.ts.map +1 -0
  87. package/dist/types/core/agents/acp/prompts.d.ts +108 -0
  88. package/dist/types/core/agents/acp/prompts.d.ts.map +1 -0
  89. package/dist/types/core/agents/acp/requests.d.ts +7 -1
  90. package/dist/types/core/agents/acp/requests.d.ts.map +1 -1
  91. package/dist/types/core/agents/base.d.ts +2 -0
  92. package/dist/types/core/agents/base.d.ts.map +1 -1
  93. package/dist/types/core/agents/claude-code/login.d.ts.map +1 -1
  94. package/dist/types/core/agents/claude-code/session.d.ts +3 -0
  95. package/dist/types/core/agents/claude-code/session.d.ts.map +1 -1
  96. package/dist/types/core/agents/claude-code/spawn.d.ts +0 -8
  97. package/dist/types/core/agents/claude-code/spawn.d.ts.map +1 -1
  98. package/dist/types/core/agents/codex-app-server/client.d.ts.map +1 -1
  99. package/dist/types/core/agents/codex-app-server/login.d.ts.map +1 -1
  100. package/dist/types/core/agents/gemini/failures.d.ts +25 -0
  101. package/dist/types/core/agents/gemini/failures.d.ts.map +1 -0
  102. package/dist/types/core/agents/gemini/login.d.ts +28 -0
  103. package/dist/types/core/agents/gemini/login.d.ts.map +1 -0
  104. package/dist/types/core/agents/gemini/profile.d.ts +30 -0
  105. package/dist/types/core/agents/gemini/profile.d.ts.map +1 -0
  106. package/dist/types/core/agents/gemini/tools.d.ts +18 -0
  107. package/dist/types/core/agents/gemini/tools.d.ts.map +1 -0
  108. package/dist/types/core/agents/login.d.ts +15 -5
  109. package/dist/types/core/agents/login.d.ts.map +1 -1
  110. package/dist/types/core/agents/scripted/scripted-agent.d.ts +14 -1
  111. package/dist/types/core/agents/scripted/scripted-agent.d.ts.map +1 -1
  112. package/dist/types/core/agents/stderr-tail.d.ts +1 -1
  113. package/dist/types/core/agents/stderr-tail.d.ts.map +1 -1
  114. package/dist/types/core/presets.d.ts +2 -2
  115. package/dist/types/core/presets.d.ts.map +1 -1
  116. package/dist/types/core/processes/native-processes.d.ts +6 -0
  117. package/dist/types/core/processes/native-processes.d.ts.map +1 -1
  118. package/dist/types/core/provision/checksums.d.ts +7 -1
  119. package/dist/types/core/provision/checksums.d.ts.map +1 -1
  120. package/dist/types/core/provision/install-build.d.ts +32 -6
  121. package/dist/types/core/provision/install-build.d.ts.map +1 -1
  122. package/dist/types/core/provision/pins.d.ts +4 -0
  123. package/dist/types/core/provision/pins.d.ts.map +1 -1
  124. package/dist/types/core/provision/provisioner.d.ts +18 -7
  125. package/dist/types/core/provision/provisioner.d.ts.map +1 -1
  126. package/dist/types/core/provision/releases.d.ts +2 -1
  127. package/dist/types/core/provision/releases.d.ts.map +1 -1
  128. package/dist/types/core/provision/tools.d.ts +36 -7
  129. package/dist/types/core/provision/tools.d.ts.map +1 -1
  130. package/dist/types/core/runtime/agent-runtime.d.ts +4 -2
  131. package/dist/types/core/runtime/agent-runtime.d.ts.map +1 -1
  132. package/dist/types/core/runtime/event-processor.d.ts +2 -2
  133. package/dist/types/core/runtime/event-processor.d.ts.map +1 -1
  134. package/dist/types/core/runtime/origin-line.d.ts +15 -0
  135. package/dist/types/core/runtime/origin-line.d.ts.map +1 -0
  136. package/dist/types/core/runtime/request-broker.d.ts +1 -1
  137. package/dist/types/core/runtime/request-broker.d.ts.map +1 -1
  138. package/dist/types/core/runtime/steering.d.ts +7 -4
  139. package/dist/types/core/runtime/steering.d.ts.map +1 -1
  140. package/dist/types/core/runtime/turn.d.ts.map +1 -1
  141. package/dist/types/operator/errors.d.ts +87 -0
  142. package/dist/types/operator/errors.d.ts.map +1 -0
  143. package/dist/types/operator/index.d.ts +10 -5
  144. package/dist/types/operator/index.d.ts.map +1 -1
  145. package/dist/types/operator/mcp.d.ts +1 -1
  146. package/dist/types/operator/mcp.d.ts.map +1 -1
  147. package/dist/types/operator/operator.d.ts +15 -197
  148. package/dist/types/operator/operator.d.ts.map +1 -1
  149. package/dist/types/operator/refs.d.ts +25 -0
  150. package/dist/types/operator/refs.d.ts.map +1 -0
  151. package/dist/types/operator/render.d.ts +67 -22
  152. package/dist/types/operator/render.d.ts.map +1 -1
  153. package/dist/types/operator/session-tools.d.ts +61 -0
  154. package/dist/types/operator/session-tools.d.ts.map +1 -0
  155. package/dist/types/operator/types.d.ts +442 -0
  156. package/dist/types/operator/types.d.ts.map +1 -0
  157. package/dist/types/operator/view.d.ts +19 -29
  158. package/dist/types/operator/view.d.ts.map +1 -1
  159. package/dist/types/protocol/account.d.ts +4 -2
  160. package/dist/types/protocol/account.d.ts.map +1 -1
  161. package/dist/types/protocol/auth.d.ts +10 -7
  162. package/dist/types/protocol/auth.d.ts.map +1 -1
  163. package/dist/types/protocol/clis.d.ts +4 -3
  164. package/dist/types/protocol/clis.d.ts.map +1 -1
  165. package/dist/types/protocol/config.d.ts +22 -5
  166. package/dist/types/protocol/config.d.ts.map +1 -1
  167. package/dist/types/protocol/conversation.d.ts +47 -6
  168. package/dist/types/protocol/conversation.d.ts.map +1 -1
  169. package/dist/types/protocol/credentials.d.ts +8 -0
  170. package/dist/types/protocol/credentials.d.ts.map +1 -1
  171. package/dist/types/protocol/execution.d.ts +1 -1
  172. package/dist/types/protocol/harness.d.ts +5 -2
  173. package/dist/types/protocol/harness.d.ts.map +1 -1
  174. package/dist/types/protocol/history.d.ts +1 -1
  175. package/dist/types/protocol/history.d.ts.map +1 -1
  176. package/dist/types/protocol/index.d.ts +1 -0
  177. package/dist/types/protocol/index.d.ts.map +1 -1
  178. package/dist/types/protocol/lifecycle.d.ts +48 -10
  179. package/dist/types/protocol/lifecycle.d.ts.map +1 -1
  180. package/dist/types/protocol/models.d.ts +3 -0
  181. package/dist/types/protocol/models.d.ts.map +1 -1
  182. package/dist/types/protocol/origin.d.ts +49 -0
  183. package/dist/types/protocol/origin.d.ts.map +1 -0
  184. package/dist/types/protocol/reduce.d.ts.map +1 -1
  185. package/dist/types/protocol/wire-api.d.ts +78 -30
  186. package/dist/types/protocol/wire-api.d.ts.map +1 -1
  187. package/dist/types/protocol/wire.d.ts +78 -12
  188. package/dist/types/protocol/wire.d.ts.map +1 -1
  189. package/dist/types/server/install.d.ts +2 -1
  190. package/dist/types/server/install.d.ts.map +1 -1
  191. package/dist/types/server/routes.d.ts.map +1 -1
  192. package/docs/consuming.md +62 -121
  193. package/docs/deploy.md +17 -8
  194. package/docs/harnesses.md +166 -44
  195. package/docs/sync-history.md +2 -1
  196. package/package.json +1 -1
  197. package/src/client/client.ts +36 -9
  198. package/src/client/connection.ts +31 -1
  199. package/src/client/turns.ts +2 -1
  200. package/src/core/agents/acp/account.ts +158 -0
  201. package/src/core/agents/acp/acp-agent.ts +288 -178
  202. package/src/core/agents/acp/adapter.ts +126 -35
  203. package/src/core/agents/acp/client.ts +196 -49
  204. package/src/core/agents/acp/known-agents.ts +14 -5
  205. package/src/core/agents/acp/mappings.ts +112 -21
  206. package/src/core/agents/acp/models.ts +72 -0
  207. package/src/core/agents/acp/profile.ts +127 -0
  208. package/src/core/agents/acp/prompts.ts +287 -0
  209. package/src/core/agents/acp/requests.ts +16 -9
  210. package/src/core/agents/base.ts +2 -0
  211. package/src/core/agents/claude-code/approvals.ts +2 -2
  212. package/src/core/agents/claude-code/login.ts +4 -1
  213. package/src/core/agents/claude-code/session.ts +38 -8
  214. package/src/core/agents/claude-code/spawn.ts +0 -26
  215. package/src/core/agents/codex-app-server/client.ts +11 -18
  216. package/src/core/agents/codex-app-server/login.ts +4 -5
  217. package/src/core/agents/codex-app-server/plan-approval.ts +1 -1
  218. package/src/core/agents/gemini/failures.ts +148 -0
  219. package/src/core/agents/gemini/login.ts +188 -0
  220. package/src/core/agents/gemini/profile.ts +162 -0
  221. package/src/core/agents/gemini/tools.ts +99 -0
  222. package/src/core/agents/login.ts +14 -8
  223. package/src/core/agents/scripted/scripted-agent.ts +42 -3
  224. package/src/core/agents/stderr-tail.ts +5 -2
  225. package/src/core/presets.ts +19 -3
  226. package/src/core/processes/native-processes.ts +32 -1
  227. package/src/core/provision/checksums.ts +12 -2
  228. package/src/core/provision/install-build.ts +122 -55
  229. package/src/core/provision/pins.ts +5 -0
  230. package/src/core/provision/provisioner.ts +62 -27
  231. package/src/core/provision/releases.ts +47 -1
  232. package/src/core/provision/tools.ts +124 -31
  233. package/src/core/runtime/agent-runtime.ts +31 -7
  234. package/src/core/runtime/event-processor.ts +13 -6
  235. package/src/core/runtime/origin-line.ts +43 -0
  236. package/src/core/runtime/request-broker.ts +2 -0
  237. package/src/core/runtime/steering.ts +8 -4
  238. package/src/core/runtime/turn.ts +11 -4
  239. package/src/operator/errors.ts +221 -0
  240. package/src/operator/index.ts +18 -23
  241. package/src/operator/mcp.ts +7 -16
  242. package/src/operator/operator.ts +1684 -610
  243. package/src/operator/refs.ts +75 -0
  244. package/src/operator/render.ts +260 -118
  245. package/src/operator/session-tools.ts +127 -0
  246. package/src/operator/types.ts +506 -0
  247. package/src/operator/view.ts +93 -42
  248. package/src/protocol/account.ts +5 -2
  249. package/src/protocol/auth.ts +5 -1
  250. package/src/protocol/config.ts +14 -6
  251. package/src/protocol/conversation.ts +3 -0
  252. package/src/protocol/credentials.ts +11 -2
  253. package/src/protocol/harness.ts +9 -1
  254. package/src/protocol/history.ts +2 -1
  255. package/src/protocol/index.ts +1 -0
  256. package/src/protocol/lifecycle.ts +21 -0
  257. package/src/protocol/origin.ts +47 -0
  258. package/src/protocol/reduce.ts +4 -0
  259. package/src/protocol/wire.ts +18 -0
  260. package/src/server/bin.ts +20 -6
  261. package/src/server/install.ts +6 -3
  262. package/src/server/routes.ts +16 -5
@@ -0,0 +1,87 @@
1
+ /**
2
+ * The refusals: a closed set of codes (`OPERATOR_ERROR_CODES`), each with its
3
+ * sentence. A refusal reads `refused (<code>): <sentence>`, then the host's
4
+ * words, then the next call, which names only a tool that is installed.
5
+ */
6
+ import type { OperatorErrorCode, Refusal } from "./types.ts";
7
+ /**
8
+ * A host's refusal at its own commit (`start`, `archive`, `send`): the code
9
+ * and the sessions it is about, by id; the package words it as its own
10
+ * refusal of that code, naming the sessions as the caller sees them.
11
+ */
12
+ export declare class Refused extends Error {
13
+ readonly refusal: Refusal;
14
+ name: string;
15
+ constructor(refusal: Refusal);
16
+ }
17
+ /**
18
+ * What can be archived, as `archive` takes it: a chat on its own, or, for a
19
+ * chat that is its workspace's only one, the workspace (a host may refuse
20
+ * archiving a workspace's last chat on its own).
21
+ */
22
+ export interface Archivable {
23
+ sessions: readonly string[];
24
+ workspaces: readonly string[];
25
+ }
26
+ /** A refusal a model can act on. Anything else a tool throws is `failed`. */
27
+ export declare class OperatorError extends Error {
28
+ readonly code: OperatorErrorCode;
29
+ readonly extra: {
30
+ /** The host's words: trusted, one line, said after the sentence. */
31
+ detail?: string;
32
+ /** The next call, already built from the installed tools. */
33
+ next?: string;
34
+ retryAfter?: number;
35
+ /** What was done before the refusal, when something was. */
36
+ done?: string;
37
+ };
38
+ name: string;
39
+ constructor(code: OperatorErrorCode, sentence: string, extra?: {
40
+ /** The host's words: trusted, one line, said after the sentence. */
41
+ detail?: string;
42
+ /** The next call, already built from the installed tools. */
43
+ next?: string;
44
+ retryAfter?: number;
45
+ /** What was done before the refusal, when something was. */
46
+ done?: string;
47
+ });
48
+ get retryAfter(): number | undefined;
49
+ /** A refusal whose words are already built (a batch whose every item was refused). */
50
+ static said(code: OperatorErrorCode, text: string): OperatorError;
51
+ }
52
+ /** Build a hint for a call, or nothing when that tool is not installed. */
53
+ export type Hint = (tool: string, args?: Record<string, unknown>) => string | undefined;
54
+ /**
55
+ * Every refusal, by code. Each takes what its sentence names and the `hint`
56
+ * of the operator that refuses, so its next call is one the caller has.
57
+ */
58
+ export declare const refuse: {
59
+ invalidInput: (tool: string, field: string, problem: string) => OperatorError;
60
+ notFound: (hint: Hint, ref: string, known: readonly string[]) => OperatorError;
61
+ ambiguous: (ref: string, refs: readonly string[]) => OperatorError;
62
+ archived: (hint: Hint, ref: string, project?: string) => OperatorError;
63
+ self: (what: "session" | "workspace") => OperatorError;
64
+ readOnly: () => OperatorError;
65
+ access: (detail?: string) => OperatorError;
66
+ notYoursArchive: (ref: string, busy: readonly string[]) => OperatorError;
67
+ notYoursAnswer: (ref: string) => OperatorError;
68
+ notYoursPermission: () => OperatorError;
69
+ hasChildren: (hint: Hint, ref: string, children: readonly string[], archive: Archivable) => OperatorError;
70
+ busy: (hint: Hint, ref: string, state: "working" | "waiting on an answer" | "being set up", undone: "archived" | "started in it" | "sent") => OperatorError;
71
+ notWaiting: (hint: Hint, ref: string, status: string, current?: string) => OperatorError;
72
+ personOnly: (ref: string, why: string) => OperatorError;
73
+ setupFailed: (hint: Hint, ref: string, reason: string, done?: string) => OperatorError;
74
+ limitDepth: (depth: number) => OperatorError;
75
+ limitSessions: (hint: Hint, count: number, settled: Archivable) => OperatorError;
76
+ limitSettingUp: (retryAfter: number, detail?: string) => OperatorError;
77
+ limitRate: (count: number, retryAfter: number) => OperatorError;
78
+ limitResources: (retryAfter: number | undefined, detail?: string) => OperatorError;
79
+ staleCursor: (hint: Hint, ref: string, selection?: {
80
+ after: string;
81
+ } | {
82
+ last: number;
83
+ }) => OperatorError;
84
+ unsupported: (detail?: string) => OperatorError;
85
+ failed: () => OperatorError;
86
+ };
87
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/operator/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE7D;;;;GAIG;AACH,qBAAa,OAAQ,SAAQ,KAAK;IAErB,QAAQ,CAAC,OAAO,EAAE,OAAO;IAD5B,IA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SAAS,MAAM,EAAE;qBAK/B,IAAI,OAAO,MAAM,YAAY,MAAM;iBAIvC,SAAS,GAAG,WAAW;;sBAUlB,MAAM;2BAED,MAAM,QAAQ,SAAS,MAAM,EAAE;0BAKhC,MAAM;;wBAUR,IAAI,OAAO,MAAM,YAAY,SAAS,MAAM,EAAE,WAAW,UAAU;iBAOhF,IAAI,OACL,MAAM,SACJ,SAAS,GAAG,sBAAsB,GAAG,cAAc,UAClD,UAAU,GAAG,eAAe,GAAG,MAAM;uBAQ3B,IAAI,OAAO,MAAM,UAAU,MAAM,YAAY,MAAM;sBAUpD,MAAM,OAAO,MAAM;wBAKjB,IAAI,OAAO,MAAM,UAAU,MAAM,SAAS,MAAM;wBAShD,MAAM;0BAKJ,IAAI,SAAS,MAAM,WAAW,UAAU;iCAMjC,MAAM,WAAW,MAAM;uBAMjC,MAAM,cAAc,MAAM;iCAMhB,MAAM,GAAG,SAAS,WAAW,MAAM;wBAM5C,IAAI,OAAO,MAAM,cAAc;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;2BAWhE,MAAM;;CAO7B,CAAC"}
@@ -1,11 +1,16 @@
1
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).
2
+ * `@zvada/agent-server/operator`: the session tools an outside agent, or a
3
+ * product's own session, operates a product's coding agents with, and their
4
+ * MCP binding. Imports only the protocol and zod; the product is the
5
+ * `OperatorHost` (LLP 0014, LLP 0019).
5
6
  */
6
7
  export { PLAN_OPTIONS, PLAN_TITLE } from "../protocol/plan.ts";
8
+ export { type Archivable, type Hint, OperatorError, Refused, refuse } from "./errors.ts";
7
9
  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";
10
+ export { DEFAULT_LIMITS, DEFAULT_WAITS, createOperator, tool } from "./operator.ts";
11
+ export { refOf } from "./refs.ts";
12
+ export { OPERATOR_GUIDANCE, type SessionTool, type SessionToolCaller, type SessionToolContent, type SessionToolSource, operatorSessionTools, } from "./session-tools.ts";
9
13
  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";
14
+ export * from "./types.ts";
15
+ export { type DecisionRequest, type QuestionRequest, type ViewMessage, settledStatus, turnOf, viewOf, waitingOf, } from "./view.ts";
11
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/operator/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACzF,OAAO,EACN,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,gBAAgB,GAChB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACpF,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EACN,iBAAiB,EACjB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,oBAAoB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,KAAK,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC5E,cAAc,YAAY,CAAC;AAC3B,OAAO,EACN,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,aAAa,EACb,MAAM,EACN,MAAM,EACN,SAAS,GACT,MAAM,WAAW,CAAC"}
@@ -8,7 +8,7 @@
8
8
  * result is null (a notification). It answers GET with `405`: the server
9
9
  * never opens a stream of its own.
10
10
  */
11
- import { type ToolInfo } from "./operator.ts";
11
+ import type { ToolInfo } from "./types.ts";
12
12
  /** Anything that lists and runs tools: an operator, or a host's wrapper around one. */
13
13
  export interface ToolSource<Caller> {
14
14
  tools(caller: Caller): ToolInfo[];
@@ -1 +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"}
1
+ {"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../../src/operator/mcp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,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,CA0FpB"}
@@ -1,206 +1,24 @@
1
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).
2
+ * Operator tools: what a person does with a set of agent sessions, as calls an
3
+ * agent can make, whether it is an outside assistant or one of the product's
4
+ * own sessions (LLP 0014, LLP 0019). See who you are, list the sessions, read
5
+ * one, wait for some, start one, message one, answer what it asks, stop it,
6
+ * archive it. The product is the `OperatorHost`; the package owns the words,
7
+ * the waits, the rules and the limits, and holds nothing between calls.
15
8
  */
16
9
  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: {
10
+ import type { CallScope, Caller, Effect, ExtraTool, Limits, Operator, OperatorHost, OperatorOptions, WaitCaps } from "./types.ts";
11
+ /** Declare a tool, typed by its input. Hosts use this for their own (`effect`: what it does, honestly). */
12
+ export declare function tool<Shape extends z.ZodRawShape, Auth = unknown>(def: {
148
13
  name: string;
149
14
  title: string;
150
15
  description: string;
151
16
  input: Shape;
152
- readOnly: boolean;
17
+ effect: Effect;
153
18
  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>;
19
+ run(args: z.infer<z.ZodObject<Shape>>, caller: Caller<Auth>, call: CallScope): Promise<string>;
20
+ }): ExtraTool<Auth>;
21
+ export declare const DEFAULT_LIMITS: Limits;
22
+ export declare const DEFAULT_WAITS: WaitCaps;
23
+ export declare function createOperator<Auth = unknown>(host: OperatorHost<Auth>, options?: OperatorOptions<Auth>): Operator<Auth>;
206
24
  //# sourceMappingURL=operator.d.ts.map
@@ -1 +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,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AAM,YAAY,CAAC;AAGpB,2GAA2G;AAC3G,wBAAgB,IAAI,CAAC,KAAK,SAAS,CAAC,CAAC,WAAW,EAAE,IAAI,GAAG,OAAO,EAAE,GAAG,EAAE;IACtE,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC/F,GAAG,SAAS,CAAC,IAAI,CAAC,CAElB;AAED,eAAO,MAAM,cAAc,EAAE,MAI5B,CAAC;AACF,eAAO,MAAM,aAAa,EAAE,QAG3B,CAAC;AA+FF,wBAAgB,cAAc,CAAC,IAAI,GAAG,OAAO,EAC5C,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC,EACxB,OAAO,GAAE,eAAe,CAAC,IAAI,CAAM,GACjC,QAAQ,CAAC,IAAI,CAAC,CA+oDhB"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * References a model types: `id / [project "/"] workspace [":" chat]`. What
3
+ * the tools print is always explicit (`workspace:N`, or the session's id when
4
+ * the host numbers no chats), so a printed reference never moves to another
5
+ * chat.
6
+ */
7
+ import type { Entry } from "./types.ts";
8
+ /** How the tools print an entry: `[project/]workspace:N`, or its id when it has no number. */
9
+ export declare function refOf(entry: Entry, all: readonly Entry[]): string;
10
+ /** What a reference resolved to: one entry, several, or none. */
11
+ export type Resolved = {
12
+ found: Entry;
13
+ } | {
14
+ ambiguous: Entry[];
15
+ } | {
16
+ missing: true;
17
+ };
18
+ /**
19
+ * The entry `ref` names among `all` (everything the caller may see, archived
20
+ * included). An id is exact: a session's, or a workspace's (its current
21
+ * chat). A name is case-insensitive; a bare workspace means its current chat,
22
+ * resolved now.
23
+ */
24
+ export declare function resolve(ref: string, all: readonly Entry[]): Resolved;
25
+ //# sourceMappingURL=refs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refs.d.ts","sourceRoot":"","sources":["../../../src/operator/refs.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,8FAA8F;AAC9F,wBAAgB,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,KAAK,EAAE,GAAG,MAAM,CASjE;AAED,iEAAiE;AACjE,MAAM,MAAM,QAAQ,GAAG;IAAE,KAAK,EAAE,KAAK,CAAA;CAAE,GAAG;IAAE,SAAS,EAAE,KAAK,EAAE,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,CAAC;AAErF;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,KAAK,EAAE,GAAG,QAAQ,CA6BpE"}
@@ -6,12 +6,17 @@
6
6
  * name alone is ambiguous.
7
7
  */
8
8
  import type { ElicitationOutcome, PermissionOutcome } from "../protocol/lifecycle.ts";
9
+ import type { Origin, ReportedOrigin } from "../protocol/origin.ts";
9
10
  import type { Part, UnknownPart } from "../protocol/parts.ts";
10
- import { type SessionView, type ViewMessage, type Waiting } from "./view.ts";
11
+ import type { Hint } from "./errors.ts";
12
+ import type { SessionView, Waiting } from "./types.ts";
13
+ import type { ViewMessage } from "./view.ts";
11
14
  /** The marker every line of untrusted text begins with. */
12
15
  export declare const QUOTE = " | ";
13
16
  /** The most messages `read_session` reads. */
14
17
  export declare const MAX_LAST = 100;
18
+ /** A full read fits in one tool result, its continuation included. */
19
+ export declare const FULL_READ_LIMIT = 20000;
15
20
  /** Untrusted text as one line: no line breaks or controls, runs of space collapsed. */
16
21
  export declare function oneLine(text: string): string;
17
22
  /** Untrusted text as a block: each of its lines carried after `QUOTE`. */
@@ -22,7 +27,16 @@ export declare const quoted: (text: string) => string;
22
27
  * The next step, as the tool call that takes it:
23
28
  * `-> answer_request(session: "voyager", answer: "<your answer>")`.
24
29
  */
25
- export declare function callHint(tool: string, args?: Record<string, string | number | boolean>): string;
30
+ /**
31
+ * A value as JSON on one line, losslessly: `\uXXXX` for what JSON leaves raw
32
+ * (U+2028, C1, bidi controls), so it reads back the same and breaks no line.
33
+ */
34
+ export declare const json: (value: unknown) => string;
35
+ export declare function callHint(tool: string, args?: Record<string, unknown>): string;
36
+ type Selection = {
37
+ after?: string;
38
+ last?: number;
39
+ };
26
40
  /**
27
41
  * One tool call on one line: its name, what it acted on, and whether it failed.
28
42
  * `working: false` (its session runs no turn) shows a tool left open as
@@ -39,32 +53,62 @@ export declare function toolLine(part: Part | UnknownPart, root?: string, workin
39
53
  */
40
54
  export declare function personOnly(waiting: Waiting): string | undefined;
41
55
  /**
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. Paths under
44
- * `root` read relative to it.
56
+ * One request's context: named by the broker's own id when more than one
57
+ * waits, and offered the answer only when this caller may give that one.
45
58
  */
46
- export declare function describeWaiting(waiting: Waiting, ref: string, root?: string): string;
47
- /** The agent's words since the person last spoke. */
48
- export declare function lastReply(messages: readonly ViewMessage[]): string;
59
+ export declare function perRequest<C extends WaitingContext>(context: C, waiting: Waiting): C;
60
+ /** What a request waiting in a session is, in the words a model reads. */
61
+ export interface WaitingContext {
62
+ /** How hints name the session. */
63
+ ref: string;
64
+ /** The request's handle, said when the session waits on more than one. */
65
+ handle?: string;
66
+ /** Whether this caller may answer it: the answer hint is offered only then. */
67
+ canAnswer?: boolean;
68
+ /** Whether this caller may answer each waiting request, by the one rule the write uses. */
69
+ answerable?: ReadonlySet<string>;
70
+ /** Paths under it read relative to it. */
71
+ root?: string;
72
+ hint: Hint;
73
+ }
49
74
  /**
50
- * How a turn stands: finished, waiting on the person, failed, or still going.
51
- * `waitedSeconds` is how long this call waited; `note` is the host's line of
52
- * facts for a turn that is not working any more; paths under `root` in what it
53
- * waits on read relative to it.
75
+ * What the agent waits on, and the call that answers it, when that tool is
76
+ * installed. What only the person can answer (`personOnly`) is one line, with
77
+ * no call.
54
78
  */
55
- export declare function renderOutcome(view: SessionView, ref: string, waitedSeconds?: number, note?: string, root?: string): string;
56
- export interface RenderOptions {
57
- /** How many recent messages (default 10). */
58
- last?: number;
59
- /** Paths in tool lines are shown relative to this folder. */
60
- root?: string;
79
+ export declare function describeWaiting(waiting: Waiting, context: WaitingContext): string;
80
+ /** Every message of a view, oldest first. */
81
+ export declare const messagesOf: (view: Pick<SessionView, "turns">) => ViewMessage[];
82
+ /** How the waits and outcomes word a view; `waited` is how long the call waited. */
83
+ export interface OutcomeContext extends WaitingContext {
84
+ waited?: number;
85
+ /** The host's line of facts for a settled turn. */
86
+ note?: string;
87
+ /** Messages after the turn this outcome follows, when it already has a successor. */
88
+ newer?: number;
89
+ }
90
+ /**
91
+ * How a session stands: done, stopped, waiting on someone, failed, or still
92
+ * going. Each request it waits on is said with the call that answers it.
93
+ */
94
+ export declare function renderOutcome(view: SessionView, context: OutcomeContext): string;
95
+ /** Who a user message is from, as `read_session` labels it; `you` is the caller's own origin. */
96
+ export declare function senderLabel(origin: ReportedOrigin | undefined, you: Origin): string;
97
+ /** Whether two origins are the same sender. */
98
+ export declare function sameOrigin(a: ReportedOrigin | undefined, b: ReportedOrigin | undefined): boolean;
99
+ export interface RenderOptions extends WaitingContext, Selection {
100
+ full?: boolean;
101
+ /** The caller's own origin: its messages read `[you]`. */
102
+ you: Origin;
103
+ /** The header line (the session, its id, who started it). */
104
+ header?: string;
61
105
  }
62
106
  /**
63
- * The conversation, condensed: what was asked, what the agent said, which
64
- * tools it ran, and under a call that asked the person its questions and
65
- * what the agent was told (or its plan).
107
+ * The conversation, condensed: each user message under its own sender, what
108
+ * the agent said, which tools it ran (with what a call asked the person),
109
+ * how each turn ended, and what the session waits on.
66
110
  */
67
- export declare function renderConversation(view: SessionView, ref: string, options?: RenderOptions): string;
111
+ export declare function renderConversation(view: SessionView, options: RenderOptions): string;
68
112
  /** A person's words as the engine takes them, for the request the agent waits on. */
69
113
  export type Answer = {
70
114
  kind: "question";
@@ -86,4 +130,5 @@ export type Answer = {
86
130
  * the reason); anything else cancels it.
87
131
  */
88
132
  export declare function answerFor(waiting: Waiting, text: string): Answer;
133
+ export {};
89
134
  //# sourceMappingURL=render.d.ts.map
@@ -1 +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,EAEN,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,OAAO,EAGZ,MAAM,WAAW,CAAC;AAUnB,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,QAA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AG,EAAE,MAAM,GAAG,MAAM,CASnF;AAED,+CAA+C;AAC/C,wBAAgB,UAAU,CAAC,CAAC,EAAE,cAAc,GAAG,SAAS,EAAE,CAAC,EAAE,cAAc,GAAG,SAAS,GAAG,OAAO,CAUhG;AAaD,MAAM,WAAW,aAAc,SAAQ,cAAc,EAAE,SAAS;IAC/D,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,0DAA0D;IAC1D,GAAG,EAAE,MAAM,CAAC;IACZ,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,CAkEpF;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,61 @@
1
+ /**
2
+ * The operator as a session's own tools: what a host returns from the
3
+ * engine's `hostTools` (LLP 0018 (host tools)), its other tools for the
4
+ * session in the same one source. The shapes are the engine's, said here by
5
+ * structure: the operator imports nothing of the engine's core.
6
+ */
7
+ import type { Operator } from "./types.ts";
8
+ /**
9
+ * What a host adds to the instructions of every session that has these
10
+ * tools, or can receive messages from sessions that do.
11
+ */
12
+ export declare const OPERATOR_GUIDANCE: string;
13
+ /** Who calls, as the engine fills it at the moment of the call (`HostToolCaller`). */
14
+ export interface SessionToolCaller {
15
+ sessionId: string;
16
+ harness: string;
17
+ turnId: string;
18
+ permissionMode: string;
19
+ }
20
+ /** A tool as the engine delivers it (`HostTool`). */
21
+ export interface SessionTool {
22
+ name: string;
23
+ description: string;
24
+ inputSchema: Record<string, unknown>;
25
+ annotations?: {
26
+ readOnly?: boolean;
27
+ destructive?: boolean;
28
+ };
29
+ }
30
+ export type SessionToolContent = {
31
+ type: "text";
32
+ text: string;
33
+ } | {
34
+ type: "image";
35
+ data: string;
36
+ mimeType: string;
37
+ };
38
+ /** A session's one source of tools (`HostToolSource`). */
39
+ export interface SessionToolSource {
40
+ name: string;
41
+ tools: readonly SessionTool[];
42
+ instructions?: string;
43
+ timeoutMs?: number;
44
+ call(name: string, args: Record<string, unknown>, caller: SessionToolCaller, signal: AbortSignal): Promise<{
45
+ content: SessionToolContent[];
46
+ isError?: boolean;
47
+ }>;
48
+ }
49
+ /**
50
+ * A session's tools: the operator's, and the host's other tools for the
51
+ * session (`with`) in the same source, as the engine gives a session one.
52
+ * The caller is the engine's, so no model can name another; a refusal is an
53
+ * `isError` result in its words, any other failure `refused (failed)` with
54
+ * none of its text; a call the agent gives up ends its wait.
55
+ */
56
+ export declare function operatorSessionTools<Auth>(operator: Operator<Auth>, options: {
57
+ name: string;
58
+ with?: SessionToolSource;
59
+ instructions?: string;
60
+ }): SessionToolSource;
61
+ //# sourceMappingURL=session-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-tools.d.ts","sourceRoot":"","sources":["../../../src/operator/session-tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C;;;GAGG;AACH,eAAO,MAAM,iBAAiB,QAkBnB,CAAC;AAEZ,sFAAsF;AACtF,MAAM,WAAW,iBAAiB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;CACvB;AAED,qDAAqD;AACrD,MAAM,WAAW,WAAW;IA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