@namzu/sdk 52.4.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 (143) hide show
  1. package/CHANGELOG.md +27 -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/manager/resident/outbox.d.ts +4 -4
  20. package/dist/public-runtime.d.ts +2 -1
  21. package/dist/public-runtime.d.ts.map +1 -1
  22. package/dist/public-runtime.js +4 -1
  23. package/dist/public-runtime.js.map +1 -1
  24. package/dist/public-types.d.ts +1 -0
  25. package/dist/public-types.d.ts.map +1 -1
  26. package/dist/runtime/query/auto-review/classifier.d.ts +130 -0
  27. package/dist/runtime/query/auto-review/classifier.d.ts.map +1 -0
  28. package/dist/runtime/query/auto-review/classifier.js +244 -0
  29. package/dist/runtime/query/auto-review/classifier.js.map +1 -0
  30. package/dist/runtime/query/auto-review/index.d.ts +7 -0
  31. package/dist/runtime/query/auto-review/index.d.ts.map +1 -0
  32. package/dist/runtime/query/auto-review/index.js +4 -0
  33. package/dist/runtime/query/auto-review/index.js.map +1 -0
  34. package/dist/runtime/query/auto-review/prompt.d.ts +20 -0
  35. package/dist/runtime/query/auto-review/prompt.d.ts.map +1 -0
  36. package/dist/runtime/query/auto-review/prompt.js +89 -0
  37. package/dist/runtime/query/auto-review/prompt.js.map +1 -0
  38. package/dist/runtime/query/auto-review/rules.d.ts +49 -0
  39. package/dist/runtime/query/auto-review/rules.d.ts.map +1 -0
  40. package/dist/runtime/query/auto-review/rules.js +81 -0
  41. package/dist/runtime/query/auto-review/rules.js.map +1 -0
  42. package/dist/runtime/query/auto-review/transcript.d.ts +59 -0
  43. package/dist/runtime/query/auto-review/transcript.d.ts.map +1 -0
  44. package/dist/runtime/query/auto-review/transcript.js +116 -0
  45. package/dist/runtime/query/auto-review/transcript.js.map +1 -0
  46. package/dist/runtime/query/auto-review/verdict.d.ts +21 -0
  47. package/dist/runtime/query/auto-review/verdict.d.ts.map +1 -0
  48. package/dist/runtime/query/auto-review/verdict.js +45 -0
  49. package/dist/runtime/query/auto-review/verdict.js.map +1 -0
  50. package/dist/runtime/query/executor.d.ts +7 -0
  51. package/dist/runtime/query/executor.d.ts.map +1 -1
  52. package/dist/runtime/query/executor.js +26 -2
  53. package/dist/runtime/query/executor.js.map +1 -1
  54. package/dist/runtime/query/index.js +2 -2
  55. package/dist/runtime/query/index.js.map +1 -1
  56. package/dist/runtime/query/iteration/phases/context.d.ts +0 -9
  57. package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
  58. package/dist/runtime/query/iteration/phases/context.js +11 -2
  59. package/dist/runtime/query/iteration/phases/context.js.map +1 -1
  60. package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
  61. package/dist/runtime/query/iteration/phases/tool-review.js +39 -0
  62. package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
  63. package/dist/runtime/query/path-escalation.d.ts.map +1 -1
  64. package/dist/runtime/query/path-escalation.js +43 -10
  65. package/dist/runtime/query/path-escalation.js.map +1 -1
  66. package/dist/runtime/query/resume-pending.d.ts.map +1 -1
  67. package/dist/runtime/query/resume-pending.js +14 -0
  68. package/dist/runtime/query/resume-pending.js.map +1 -1
  69. package/dist/runtime/query/review-policy.d.ts +88 -1
  70. package/dist/runtime/query/review-policy.d.ts.map +1 -1
  71. package/dist/runtime/query/review-policy.js +504 -11
  72. package/dist/runtime/query/review-policy.js.map +1 -1
  73. package/dist/tools/builtins/bash.d.ts.map +1 -1
  74. package/dist/tools/builtins/bash.js +2 -0
  75. package/dist/tools/builtins/bash.js.map +1 -1
  76. package/dist/tools/builtins/classifier-input.d.ts +9 -0
  77. package/dist/tools/builtins/classifier-input.d.ts.map +1 -0
  78. package/dist/tools/builtins/classifier-input.js +20 -0
  79. package/dist/tools/builtins/classifier-input.js.map +1 -0
  80. package/dist/tools/builtins/code-analysis.d.ts +2 -0
  81. package/dist/tools/builtins/code-analysis.d.ts.map +1 -1
  82. package/dist/tools/builtins/code-analysis.js +196 -119
  83. package/dist/tools/builtins/code-analysis.js.map +1 -1
  84. package/dist/tools/builtins/computer-use.d.ts +10 -10
  85. package/dist/tools/builtins/edit.d.ts.map +1 -1
  86. package/dist/tools/builtins/edit.js +12 -0
  87. package/dist/tools/builtins/edit.js.map +1 -1
  88. package/dist/tools/builtins/monitor.d.ts.map +1 -1
  89. package/dist/tools/builtins/monitor.js +3 -0
  90. package/dist/tools/builtins/monitor.js.map +1 -1
  91. package/dist/tools/builtins/web.d.ts.map +1 -1
  92. package/dist/tools/builtins/web.js +3 -0
  93. package/dist/tools/builtins/web.js.map +1 -1
  94. package/dist/tools/builtins/write-file.d.ts.map +1 -1
  95. package/dist/tools/builtins/write-file.js +6 -0
  96. package/dist/tools/builtins/write-file.js.map +1 -1
  97. package/dist/tools/defineTool.d.ts +2 -0
  98. package/dist/tools/defineTool.d.ts.map +1 -1
  99. package/dist/tools/defineTool.js +1 -0
  100. package/dist/tools/defineTool.js.map +1 -1
  101. package/dist/types/acp/index.d.ts +7 -0
  102. package/dist/types/acp/index.d.ts.map +1 -1
  103. package/dist/types/code-analysis/index.d.ts +54 -3
  104. package/dist/types/code-analysis/index.d.ts.map +1 -1
  105. package/dist/types/hitl/index.d.ts +45 -1
  106. package/dist/types/hitl/index.d.ts.map +1 -1
  107. package/dist/types/hitl/index.js.map +1 -1
  108. package/dist/types/tool/index.d.ts +16 -0
  109. package/dist/types/tool/index.d.ts.map +1 -1
  110. package/dist/types/tool/index.js.map +1 -1
  111. package/package.json +1 -1
  112. package/src/authorization/gate.ts +35 -0
  113. package/src/authorization/removal.ts +12 -6
  114. package/src/authorization/rules.ts +27 -2
  115. package/src/authorization/shell-paths.ts +264 -51
  116. package/src/bridge/acp/server.ts +20 -0
  117. package/src/public-runtime.ts +18 -0
  118. package/src/public-types.ts +11 -0
  119. package/src/runtime/query/auto-review/classifier.ts +404 -0
  120. package/src/runtime/query/auto-review/index.ts +23 -0
  121. package/src/runtime/query/auto-review/prompt.ts +97 -0
  122. package/src/runtime/query/auto-review/rules.ts +106 -0
  123. package/src/runtime/query/auto-review/transcript.ts +159 -0
  124. package/src/runtime/query/auto-review/verdict.ts +50 -0
  125. package/src/runtime/query/executor.ts +29 -2
  126. package/src/runtime/query/index.ts +2 -2
  127. package/src/runtime/query/iteration/phases/context.ts +17 -3
  128. package/src/runtime/query/iteration/phases/tool-review.ts +41 -0
  129. package/src/runtime/query/path-escalation.ts +44 -9
  130. package/src/runtime/query/resume-pending.ts +14 -0
  131. package/src/runtime/query/review-policy.ts +591 -14
  132. package/src/tools/builtins/bash.ts +3 -0
  133. package/src/tools/builtins/classifier-input.ts +19 -0
  134. package/src/tools/builtins/code-analysis.ts +211 -119
  135. package/src/tools/builtins/edit.ts +13 -0
  136. package/src/tools/builtins/monitor.ts +4 -0
  137. package/src/tools/builtins/web.ts +3 -0
  138. package/src/tools/builtins/write-file.ts +6 -0
  139. package/src/tools/defineTool.ts +3 -0
  140. package/src/types/acp/index.ts +7 -0
  141. package/src/types/code-analysis/index.ts +51 -3
  142. package/src/types/hitl/index.ts +49 -1
  143. package/src/types/tool/index.ts +17 -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 {
@@ -1178,6 +1178,23 @@ export interface ToolDefinition<TInput = unknown> extends ToolPresentation<TInpu
1178
1178
  */
1179
1179
  requiresApproval?(input: TInput): boolean
1180
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
+
1181
1198
  /**
1182
1199
  * Free-form, tool-author-declared data for filtering and behaviour
1183
1200
  * customization — never a classification the runtime itself reads.