@namzu/sdk 52.3.0 → 52.5.0

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 (176) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/dist/authorization/gate.d.ts +11 -0
  3. package/dist/authorization/gate.d.ts.map +1 -1
  4. package/dist/authorization/gate.js +35 -0
  5. package/dist/authorization/gate.js.map +1 -1
  6. package/dist/authorization/removal.js +11 -6
  7. package/dist/authorization/removal.js.map +1 -1
  8. package/dist/authorization/rules.d.ts.map +1 -1
  9. package/dist/authorization/rules.js +30 -2
  10. package/dist/authorization/rules.js.map +1 -1
  11. package/dist/authorization/shell-paths.d.ts +20 -0
  12. package/dist/authorization/shell-paths.d.ts.map +1 -1
  13. package/dist/authorization/shell-paths.js +254 -52
  14. package/dist/authorization/shell-paths.js.map +1 -1
  15. package/dist/bridge/acp/server.d.ts +8 -0
  16. package/dist/bridge/acp/server.d.ts.map +1 -1
  17. package/dist/bridge/acp/server.js +7 -0
  18. package/dist/bridge/acp/server.js.map +1 -1
  19. package/dist/connector/web/guarded-fetch.d.ts.map +1 -1
  20. package/dist/connector/web/guarded-fetch.js +44 -0
  21. package/dist/connector/web/guarded-fetch.js.map +1 -1
  22. package/dist/manager/resident/outbox.d.ts +4 -4
  23. package/dist/process/kill-tree.d.ts +3 -2
  24. package/dist/process/kill-tree.d.ts.map +1 -1
  25. package/dist/process/kill-tree.js.map +1 -1
  26. package/dist/public-runtime.d.ts +3 -2
  27. package/dist/public-runtime.d.ts.map +1 -1
  28. package/dist/public-runtime.js +4 -1
  29. package/dist/public-runtime.js.map +1 -1
  30. package/dist/public-tools.d.ts +2 -1
  31. package/dist/public-tools.d.ts.map +1 -1
  32. package/dist/public-tools.js +1 -1
  33. package/dist/public-tools.js.map +1 -1
  34. package/dist/public-types.d.ts +1 -0
  35. package/dist/public-types.d.ts.map +1 -1
  36. package/dist/runtime/jobs/registry.d.ts +80 -2
  37. package/dist/runtime/jobs/registry.d.ts.map +1 -1
  38. package/dist/runtime/jobs/registry.js +70 -5
  39. package/dist/runtime/jobs/registry.js.map +1 -1
  40. package/dist/runtime/jobs/websocket-source.d.ts +120 -0
  41. package/dist/runtime/jobs/websocket-source.d.ts.map +1 -0
  42. package/dist/runtime/jobs/websocket-source.js +379 -0
  43. package/dist/runtime/jobs/websocket-source.js.map +1 -0
  44. package/dist/runtime/query/auto-review/classifier.d.ts +130 -0
  45. package/dist/runtime/query/auto-review/classifier.d.ts.map +1 -0
  46. package/dist/runtime/query/auto-review/classifier.js +244 -0
  47. package/dist/runtime/query/auto-review/classifier.js.map +1 -0
  48. package/dist/runtime/query/auto-review/index.d.ts +7 -0
  49. package/dist/runtime/query/auto-review/index.d.ts.map +1 -0
  50. package/dist/runtime/query/auto-review/index.js +4 -0
  51. package/dist/runtime/query/auto-review/index.js.map +1 -0
  52. package/dist/runtime/query/auto-review/prompt.d.ts +20 -0
  53. package/dist/runtime/query/auto-review/prompt.d.ts.map +1 -0
  54. package/dist/runtime/query/auto-review/prompt.js +89 -0
  55. package/dist/runtime/query/auto-review/prompt.js.map +1 -0
  56. package/dist/runtime/query/auto-review/rules.d.ts +49 -0
  57. package/dist/runtime/query/auto-review/rules.d.ts.map +1 -0
  58. package/dist/runtime/query/auto-review/rules.js +81 -0
  59. package/dist/runtime/query/auto-review/rules.js.map +1 -0
  60. package/dist/runtime/query/auto-review/transcript.d.ts +59 -0
  61. package/dist/runtime/query/auto-review/transcript.d.ts.map +1 -0
  62. package/dist/runtime/query/auto-review/transcript.js +116 -0
  63. package/dist/runtime/query/auto-review/transcript.js.map +1 -0
  64. package/dist/runtime/query/auto-review/verdict.d.ts +21 -0
  65. package/dist/runtime/query/auto-review/verdict.d.ts.map +1 -0
  66. package/dist/runtime/query/auto-review/verdict.js +45 -0
  67. package/dist/runtime/query/auto-review/verdict.js.map +1 -0
  68. package/dist/runtime/query/executor.d.ts +7 -0
  69. package/dist/runtime/query/executor.d.ts.map +1 -1
  70. package/dist/runtime/query/executor.js +26 -2
  71. package/dist/runtime/query/executor.js.map +1 -1
  72. package/dist/runtime/query/index.js +2 -2
  73. package/dist/runtime/query/index.js.map +1 -1
  74. package/dist/runtime/query/iteration/phases/context.d.ts +0 -9
  75. package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
  76. package/dist/runtime/query/iteration/phases/context.js +11 -2
  77. package/dist/runtime/query/iteration/phases/context.js.map +1 -1
  78. package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
  79. package/dist/runtime/query/iteration/phases/tool-review.js +39 -0
  80. package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
  81. package/dist/runtime/query/path-escalation.d.ts.map +1 -1
  82. package/dist/runtime/query/path-escalation.js +43 -10
  83. package/dist/runtime/query/path-escalation.js.map +1 -1
  84. package/dist/runtime/query/resume-pending.d.ts.map +1 -1
  85. package/dist/runtime/query/resume-pending.js +14 -0
  86. package/dist/runtime/query/resume-pending.js.map +1 -1
  87. package/dist/runtime/query/review-policy.d.ts +88 -1
  88. package/dist/runtime/query/review-policy.d.ts.map +1 -1
  89. package/dist/runtime/query/review-policy.js +504 -11
  90. package/dist/runtime/query/review-policy.js.map +1 -1
  91. package/dist/runtime/query/steering.d.ts +2 -2
  92. package/dist/runtime/query/steering.d.ts.map +1 -1
  93. package/dist/runtime/query/steering.js +16 -3
  94. package/dist/runtime/query/steering.js.map +1 -1
  95. package/dist/tools/builtins/bash.d.ts.map +1 -1
  96. package/dist/tools/builtins/bash.js +2 -0
  97. package/dist/tools/builtins/bash.js.map +1 -1
  98. package/dist/tools/builtins/classifier-input.d.ts +9 -0
  99. package/dist/tools/builtins/classifier-input.d.ts.map +1 -0
  100. package/dist/tools/builtins/classifier-input.js +20 -0
  101. package/dist/tools/builtins/classifier-input.js.map +1 -0
  102. package/dist/tools/builtins/code-analysis.d.ts +2 -0
  103. package/dist/tools/builtins/code-analysis.d.ts.map +1 -1
  104. package/dist/tools/builtins/code-analysis.js +196 -119
  105. package/dist/tools/builtins/code-analysis.js.map +1 -1
  106. package/dist/tools/builtins/computer-use.d.ts +10 -10
  107. package/dist/tools/builtins/edit.d.ts.map +1 -1
  108. package/dist/tools/builtins/edit.js +12 -0
  109. package/dist/tools/builtins/edit.js.map +1 -1
  110. package/dist/tools/builtins/monitor.d.ts +38 -4
  111. package/dist/tools/builtins/monitor.d.ts.map +1 -1
  112. package/dist/tools/builtins/monitor.js +239 -97
  113. package/dist/tools/builtins/monitor.js.map +1 -1
  114. package/dist/tools/builtins/web.d.ts.map +1 -1
  115. package/dist/tools/builtins/web.js +3 -0
  116. package/dist/tools/builtins/web.js.map +1 -1
  117. package/dist/tools/builtins/write-file.d.ts.map +1 -1
  118. package/dist/tools/builtins/write-file.js +6 -0
  119. package/dist/tools/builtins/write-file.js.map +1 -1
  120. package/dist/tools/defineTool.d.ts +2 -0
  121. package/dist/tools/defineTool.d.ts.map +1 -1
  122. package/dist/tools/defineTool.js +1 -0
  123. package/dist/tools/defineTool.js.map +1 -1
  124. package/dist/types/acp/index.d.ts +7 -0
  125. package/dist/types/acp/index.d.ts.map +1 -1
  126. package/dist/types/code-analysis/index.d.ts +54 -3
  127. package/dist/types/code-analysis/index.d.ts.map +1 -1
  128. package/dist/types/hitl/index.d.ts +45 -1
  129. package/dist/types/hitl/index.d.ts.map +1 -1
  130. package/dist/types/hitl/index.js.map +1 -1
  131. package/dist/types/sandbox/index.d.ts +10 -0
  132. package/dist/types/sandbox/index.d.ts.map +1 -1
  133. package/dist/types/sandbox/index.js.map +1 -1
  134. package/dist/types/tool/index.d.ts +51 -0
  135. package/dist/types/tool/index.d.ts.map +1 -1
  136. package/dist/types/tool/index.js.map +1 -1
  137. package/package.json +4 -2
  138. package/src/authorization/gate.ts +35 -0
  139. package/src/authorization/removal.ts +12 -6
  140. package/src/authorization/rules.ts +27 -2
  141. package/src/authorization/shell-paths.ts +264 -51
  142. package/src/bridge/acp/server.ts +20 -0
  143. package/src/connector/web/guarded-fetch.ts +41 -0
  144. package/src/process/kill-tree.ts +4 -2
  145. package/src/public-runtime.ts +19 -1
  146. package/src/public-tools.ts +3 -0
  147. package/src/public-types.ts +11 -0
  148. package/src/runtime/jobs/registry.ts +162 -13
  149. package/src/runtime/jobs/websocket-source.ts +438 -0
  150. package/src/runtime/query/auto-review/classifier.ts +404 -0
  151. package/src/runtime/query/auto-review/index.ts +23 -0
  152. package/src/runtime/query/auto-review/prompt.ts +97 -0
  153. package/src/runtime/query/auto-review/rules.ts +106 -0
  154. package/src/runtime/query/auto-review/transcript.ts +159 -0
  155. package/src/runtime/query/auto-review/verdict.ts +50 -0
  156. package/src/runtime/query/executor.ts +29 -2
  157. package/src/runtime/query/index.ts +2 -2
  158. package/src/runtime/query/iteration/phases/context.ts +17 -3
  159. package/src/runtime/query/iteration/phases/tool-review.ts +41 -0
  160. package/src/runtime/query/path-escalation.ts +44 -9
  161. package/src/runtime/query/resume-pending.ts +14 -0
  162. package/src/runtime/query/review-policy.ts +591 -14
  163. package/src/runtime/query/steering.ts +32 -6
  164. package/src/tools/builtins/bash.ts +3 -0
  165. package/src/tools/builtins/classifier-input.ts +19 -0
  166. package/src/tools/builtins/code-analysis.ts +211 -119
  167. package/src/tools/builtins/edit.ts +13 -0
  168. package/src/tools/builtins/monitor.ts +297 -123
  169. package/src/tools/builtins/web.ts +3 -0
  170. package/src/tools/builtins/write-file.ts +6 -0
  171. package/src/tools/defineTool.ts +3 -0
  172. package/src/types/acp/index.ts +7 -0
  173. package/src/types/code-analysis/index.ts +51 -3
  174. package/src/types/hitl/index.ts +49 -1
  175. package/src/types/sandbox/index.ts +10 -0
  176. package/src/types/tool/index.ts +44 -0
@@ -1,5 +1,6 @@
1
1
  import type { CostInfo, TokenUsage } from '../common/index.js'
2
2
  import type { CheckpointId, PlanId, SessionId, TurnId } from '../ids/index.js'
3
+ import type { Message } from '../message/index.js'
3
4
 
4
5
  export type { CheckpointId }
5
6
 
@@ -139,7 +140,28 @@ export type HITLDecisionRequest =
139
140
  question: UserQuestionData
140
141
  }
141
142
 
142
- export type ResumeHandler = (request: HITLDecisionRequest) => Promise<HITLResumeDecision>
143
+ /**
144
+ * What the turn offers a resume handler besides the request, in memory only.
145
+ *
146
+ * Kept out of {@link HITLDecisionRequest} on purpose: the request is written
147
+ * to the session log when a decision takes long, and a transcript does not
148
+ * belong there. A handler that does not need it ignores the argument; one that
149
+ * wraps another passes it on.
150
+ */
151
+ export interface ResumeContext {
152
+ /**
153
+ * The conversation as it stands now, the batch under review included.
154
+ * Read on demand; the array is the turn's own, so a caller must not change it.
155
+ */
156
+ readonly transcript: () => readonly Message[]
157
+ /** The turn's cancellation signal, when it has one. */
158
+ readonly signal?: AbortSignal
159
+ }
160
+
161
+ export type ResumeHandler = (
162
+ request: HITLDecisionRequest,
163
+ context?: ResumeContext,
164
+ ) => Promise<HITLResumeDecision>
143
165
 
144
166
  export interface ToolCallSummary {
145
167
  id: string
@@ -158,6 +180,24 @@ export interface ToolCallSummary {
158
180
  reason?: string
159
181
  /** A matching rule requested review; read-only exemptions must not bypass it. */
160
182
  explicitReview?: true
183
+ /**
184
+ * A rule written to ask a person (a `review` rule), or a hook that asked
185
+ * for one, requested this review. Unlike {@link explicitReview} it is not
186
+ * set when an `allow` rule was demoted to review because the call reaches
187
+ * past its boundary. `bypass` and `classify` keep this question for a
188
+ * person; they answer the demoted kind themselves.
189
+ */
190
+ askRule?: true
191
+ /**
192
+ * How wide the `allow` rule that settled this call is. `tool` means the
193
+ * rule names the whole tool, a category, a tier or a source, or its
194
+ * pattern matches every input; `pattern` means it matches some inputs
195
+ * only. Present only when `decision` is `allow` and a rule (not the
196
+ * read-only allowance) decided it. The `classify` review mode reads it:
197
+ * a whole-tool allow for a shell tool would let the classifier never
198
+ * see a command.
199
+ */
200
+ allowScope?: 'tool' | 'pattern'
161
201
  }
162
202
  /**
163
203
  * What this call reaches beyond the turn's ordinary boundary, as the
@@ -278,6 +318,14 @@ export interface ToolCallEscalation {
278
318
  * tool that declares `commandArgument`.
279
319
  */
280
320
  dangerousRemoval?: string
321
+ /**
322
+ * Why the kernel could not finish looking at this call: the check that
323
+ * finds the escalations above threw, so none of them is known to be
324
+ * absent. Treated as the most serious escalation there is, because the
325
+ * safety checks did not run: a person is asked in every mode, `bypass`
326
+ * and `classify` included, and it is refused when nobody can be asked.
327
+ */
328
+ unfinishedCheck?: string
281
329
  }
282
330
 
283
331
  export interface ToolModification {
@@ -334,6 +334,16 @@ export interface Sandbox {
334
334
  readonly status: SandboxStatus
335
335
  readonly rootDir: string
336
336
  readonly environment: SandboxEnvironment
337
+ /**
338
+ * The network policy in force right now, when the backend can say.
339
+ *
340
+ * Optional, and absent does NOT mean open: a caller that needs to know
341
+ * whether a host is reachable (the host process opening a connection on a
342
+ * turn's behalf, outside the boundary) treats absence as "not allowed" on a
343
+ * tier that isolates the network. A backend that enforces
344
+ * {@link setNetworkPolicy} should report what it enforces here.
345
+ */
346
+ readonly networkPolicy?: SandboxNetworkPolicy
337
347
  exec(command: string, args?: string[], opts?: SandboxExecOptions): Promise<SandboxExecResult>
338
348
 
339
349
  /**
@@ -105,6 +105,20 @@ export interface SkillRegistryRef {
105
105
  names(): readonly string[]
106
106
  }
107
107
 
108
+ /**
109
+ * Where a WebSocket monitor connects, already checked.
110
+ *
111
+ * `addresses` are what the caller verified are outside the host's own
112
+ * network; the connection is pinned to them and never resolves the name
113
+ * itself. A caller that did not check must not hand it a target: the registry
114
+ * trusts it, as it trusts a spawn it is given.
115
+ */
116
+ export interface MonitorWebSocketTarget {
117
+ readonly url: string
118
+ readonly protocols?: readonly string[]
119
+ readonly addresses: readonly { readonly address: string; readonly family: 4 | 6 }[]
120
+ }
121
+
108
122
  /**
109
123
  * The slice of the background job registry a tool is given.
110
124
  *
@@ -135,6 +149,19 @@ export interface BackgroundJobRegistryRef {
135
149
  timeoutMs: number
136
150
  workingDirectory?: string
137
151
  }): { job: { id: string; status: string }; timeoutMs: number }
152
+ /**
153
+ * Start a monitor whose source is a WebSocket connection. Separate from
154
+ * {@link startMonitor} so a host that implements that one for commands is
155
+ * not handed an input it was not written for; a host without this method
156
+ * refuses a `ws` call with a plain message. The target's addresses are
157
+ * already checked; see {@link MonitorWebSocketTarget}.
158
+ */
159
+ startWebSocketMonitor?(params: {
160
+ description: string
161
+ timeoutMs: number
162
+ workingDirectory?: string
163
+ webSocket: MonitorWebSocketTarget
164
+ }): { job: { id: string; status: string }; timeoutMs: number }
138
165
  get(id: string): {
139
166
  id: string
140
167
  status: string
@@ -1151,6 +1178,23 @@ export interface ToolDefinition<TInput = unknown> extends ToolPresentation<TInpu
1151
1178
  */
1152
1179
  requiresApproval?(input: TInput): boolean
1153
1180
 
1181
+ /**
1182
+ * What the auto-mode safety classifier is shown of this call.
1183
+ *
1184
+ * The classifier (`createAutoReviewClassifier`, review mode `classify`)
1185
+ * reads a compact transcript, not raw tool arguments: a tool knows which
1186
+ * part of its own input says what the call DOES. A shell tool returns the
1187
+ * command, a file tool the path and a short summary of the change, a fetch
1188
+ * the address. The string should be short and carry no content the model
1189
+ * could not already be trusted with; the runtime caps its length.
1190
+ *
1191
+ * Absent, the classifier is shown the input as compact JSON. A tool whose
1192
+ * input is large or opaque (a file body, a binary payload) should declare
1193
+ * this so the classifier judges the action rather than the bulk. Never
1194
+ * called with a tool RESULT: results are untrusted and are not shown.
1195
+ */
1196
+ classifierInput?(input: TInput): string
1197
+
1154
1198
  /**
1155
1199
  * Free-form, tool-author-declared data for filtering and behaviour
1156
1200
  * customization — never a classification the runtime itself reads.