@namzu/sdk 63.0.0 → 64.0.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 (123) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/dist/agents/QueryAgent.d.ts.map +1 -1
  3. package/dist/agents/QueryAgent.js +2 -1
  4. package/dist/agents/QueryAgent.js.map +1 -1
  5. package/dist/compaction/hooks.d.ts +57 -0
  6. package/dist/compaction/hooks.d.ts.map +1 -0
  7. package/dist/compaction/hooks.js +44 -0
  8. package/dist/compaction/hooks.js.map +1 -0
  9. package/dist/compaction/manual.d.ts +9 -0
  10. package/dist/compaction/manual.d.ts.map +1 -1
  11. package/dist/compaction/manual.js +74 -5
  12. package/dist/compaction/manual.js.map +1 -1
  13. package/dist/compaction/model-summary.d.ts +6 -0
  14. package/dist/compaction/model-summary.d.ts.map +1 -1
  15. package/dist/compaction/model-summary.js +13 -3
  16. package/dist/compaction/model-summary.js.map +1 -1
  17. package/dist/compaction/verifier.d.ts +8 -2
  18. package/dist/compaction/verifier.d.ts.map +1 -1
  19. package/dist/compaction/verifier.js +23 -7
  20. package/dist/compaction/verifier.js.map +1 -1
  21. package/dist/plugin/hook-context.d.ts +16 -0
  22. package/dist/plugin/hook-context.d.ts.map +1 -1
  23. package/dist/plugin/hook-context.js +40 -0
  24. package/dist/plugin/hook-context.js.map +1 -1
  25. package/dist/plugin/index.d.ts +4 -3
  26. package/dist/plugin/index.d.ts.map +1 -1
  27. package/dist/plugin/index.js +3 -2
  28. package/dist/plugin/index.js.map +1 -1
  29. package/dist/plugin/shell-hook-command.d.ts +25 -0
  30. package/dist/plugin/shell-hook-command.d.ts.map +1 -0
  31. package/dist/plugin/shell-hook-command.js +218 -0
  32. package/dist/plugin/shell-hook-command.js.map +1 -0
  33. package/dist/plugin/shell-hook-tool-names.d.ts +20 -0
  34. package/dist/plugin/shell-hook-tool-names.d.ts.map +1 -0
  35. package/dist/plugin/shell-hook-tool-names.js +43 -0
  36. package/dist/plugin/shell-hook-tool-names.js.map +1 -0
  37. package/dist/plugin/shell-hook.d.ts +62 -20
  38. package/dist/plugin/shell-hook.d.ts.map +1 -1
  39. package/dist/plugin/shell-hook.js +372 -85
  40. package/dist/plugin/shell-hook.js.map +1 -1
  41. package/dist/public-runtime.d.ts +3 -1
  42. package/dist/public-runtime.d.ts.map +1 -1
  43. package/dist/public-runtime.js +2 -1
  44. package/dist/public-runtime.js.map +1 -1
  45. package/dist/public-types.d.ts +2 -1
  46. package/dist/public-types.d.ts.map +1 -1
  47. package/dist/runtime/query/compact-session.d.ts +7 -1
  48. package/dist/runtime/query/compact-session.d.ts.map +1 -1
  49. package/dist/runtime/query/compact-session.js +8 -3
  50. package/dist/runtime/query/compact-session.js.map +1 -1
  51. package/dist/runtime/query/executor/tool-call-admission.d.ts +1 -1
  52. package/dist/runtime/query/executor/tool-call-admission.d.ts.map +1 -1
  53. package/dist/runtime/query/executor/tool-call-admission.js +4 -3
  54. package/dist/runtime/query/executor/tool-call-admission.js.map +1 -1
  55. package/dist/runtime/query/executor.d.ts +8 -0
  56. package/dist/runtime/query/executor.d.ts.map +1 -1
  57. package/dist/runtime/query/executor.js +17 -7
  58. package/dist/runtime/query/executor.js.map +1 -1
  59. package/dist/runtime/query/finalize-turn.d.ts.map +1 -1
  60. package/dist/runtime/query/finalize-turn.js +9 -2
  61. package/dist/runtime/query/finalize-turn.js.map +1 -1
  62. package/dist/runtime/query/iteration/index.d.ts.map +1 -1
  63. package/dist/runtime/query/iteration/index.js +4 -1
  64. package/dist/runtime/query/iteration/index.js.map +1 -1
  65. package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
  66. package/dist/runtime/query/iteration/phases/compaction.js +24 -12
  67. package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
  68. package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
  69. package/dist/runtime/query/iteration/phases/tool-review.js +2 -0
  70. package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
  71. package/dist/runtime/query/plugin-hooks.d.ts +13 -0
  72. package/dist/runtime/query/plugin-hooks.d.ts.map +1 -1
  73. package/dist/runtime/query/plugin-hooks.js +29 -2
  74. package/dist/runtime/query/plugin-hooks.js.map +1 -1
  75. package/dist/runtime/query/turn/outcome-ledger.d.ts +4 -0
  76. package/dist/runtime/query/turn/outcome-ledger.d.ts.map +1 -1
  77. package/dist/runtime/query/turn/outcome-ledger.js +2 -1
  78. package/dist/runtime/query/turn/outcome-ledger.js.map +1 -1
  79. package/dist/tools/builtins/bash.d.ts.map +1 -1
  80. package/dist/tools/builtins/bash.js +10 -2
  81. package/dist/tools/builtins/bash.js.map +1 -1
  82. package/dist/tools/coordinator/index.d.ts.map +1 -1
  83. package/dist/tools/coordinator/index.js +1 -0
  84. package/dist/tools/coordinator/index.js.map +1 -1
  85. package/dist/types/agent/query.d.ts +8 -0
  86. package/dist/types/agent/query.d.ts.map +1 -1
  87. package/dist/types/plugin/index.d.ts +55 -11
  88. package/dist/types/plugin/index.d.ts.map +1 -1
  89. package/dist/types/plugin/index.js.map +1 -1
  90. package/dist/types/session/events.d.ts +2 -0
  91. package/dist/types/session/events.d.ts.map +1 -1
  92. package/dist/types/session/events.js.map +1 -1
  93. package/dist/types/tool/index.d.ts +13 -1
  94. package/dist/types/tool/index.d.ts.map +1 -1
  95. package/dist/types/tool/index.js.map +1 -1
  96. package/package.json +1 -1
  97. package/src/agents/QueryAgent.ts +2 -1
  98. package/src/compaction/hooks.ts +104 -0
  99. package/src/compaction/manual.ts +117 -4
  100. package/src/compaction/model-summary.ts +19 -3
  101. package/src/compaction/verifier.ts +33 -3
  102. package/src/plugin/hook-context.ts +46 -0
  103. package/src/plugin/index.ts +14 -0
  104. package/src/plugin/shell-hook-command.ts +215 -0
  105. package/src/plugin/shell-hook-tool-names.ts +46 -0
  106. package/src/plugin/shell-hook.ts +405 -79
  107. package/src/public-runtime.ts +12 -0
  108. package/src/public-types.ts +2 -0
  109. package/src/runtime/query/compact-session.ts +16 -4
  110. package/src/runtime/query/executor/tool-call-admission.ts +10 -2
  111. package/src/runtime/query/executor.ts +33 -8
  112. package/src/runtime/query/finalize-turn.ts +9 -2
  113. package/src/runtime/query/iteration/index.ts +4 -1
  114. package/src/runtime/query/iteration/phases/compaction.ts +31 -12
  115. package/src/runtime/query/iteration/phases/tool-review.ts +2 -0
  116. package/src/runtime/query/plugin-hooks.ts +32 -2
  117. package/src/runtime/query/turn/outcome-ledger.ts +6 -1
  118. package/src/tools/builtins/bash.ts +16 -3
  119. package/src/tools/coordinator/index.ts +1 -0
  120. package/src/types/agent/query.ts +9 -0
  121. package/src/types/plugin/index.ts +66 -22
  122. package/src/types/session/events.ts +2 -0
  123. package/src/types/tool/index.ts +14 -1
@@ -246,12 +246,36 @@ export interface PluginModelResponse {
246
246
 
247
247
  /** What a compaction hook is shown about the pass. */
248
248
  export interface PluginCompactionInfo {
249
- /** `threshold`: the estimate crossed the line. `overflow`: the provider rejected the prompt. */
250
- readonly reason: 'threshold' | 'overflow'
249
+ /**
250
+ * `threshold`: the estimate crossed the line. `overflow`: the provider
251
+ * rejected the prompt. `manual`: a host asked for the pass outside a turn
252
+ * (a person's `/compact`, a summarised span, an idle pass); test `trigger`
253
+ * to tell a person's request from the kernel's own.
254
+ */
255
+ readonly reason: 'threshold' | 'overflow' | 'manual'
251
256
  readonly tokensBefore: number
252
257
  /** Present on `post_compact`. */
253
258
  readonly tokensAfter?: number
254
259
  readonly contextWindowTokens: number
260
+ /**
261
+ * Who started the pass: `manual` for one a person asked for (`/compact`,
262
+ * summarising a span), `auto` for every pass the kernel or a host started
263
+ * on its own (the threshold, a provider overflow, an idle pass). The
264
+ * kernel always sets it; it is optional only so a host that builds this
265
+ * context by hand keeps compiling. A matcher on these two events tests it.
266
+ */
267
+ readonly trigger?: 'manual' | 'auto'
268
+ /**
269
+ * On `pre_compact`: what the person typed with the command, or `null` when
270
+ * they typed nothing or the pass is not one a person asked for.
271
+ */
272
+ readonly instructions?: string | null
273
+ /**
274
+ * On `post_compact`: the summary the pass wrote, cut to
275
+ * `MAX_COMPACTION_SUMMARY_HOOK_CHARS`. Absent when the pass wrote none (a
276
+ * context reducer shed the history, or the pass shed nothing).
277
+ */
278
+ readonly summary?: string
255
279
  }
256
280
 
257
281
  /** One call in a `post_tool_batch` hook's context. */
@@ -275,19 +299,22 @@ export interface PluginNotificationInfo {
275
299
  }
276
300
 
277
301
  /**
278
- * Why a session started, on `session_start`: `startup` for a conversation
302
+ * Why a conversation began, on `session_start`: `startup` for a conversation
279
303
  * with no earlier turn, `resume` for one that already had turns (a resumed
280
- * conversation, a `--continue`, or a session rebuilt under a running one).
304
+ * conversation, a `--continue`, a fork, or a session rebuilt under a running
305
+ * one), `clear` for the empty conversation a host opens when the person
306
+ * clears the old one (`/clear`, `/new`).
281
307
  */
282
- export type PluginSessionSource = 'startup' | 'resume'
308
+ export type PluginSessionSource = 'startup' | 'resume' | 'clear'
283
309
 
284
310
  /**
285
- * Why a session closed, on `session_end`: `exit` when the host is finishing
286
- * with it (the process ends, the person quits), `replaced` when the host
287
- * builds another session in its place (a model or account switch, another
288
- * conversation opened).
311
+ * Why a conversation ended, on `session_end`: `exit` when the host is
312
+ * finishing with it (the process ends, the person quits), `replaced` when the
313
+ * host moves to another session or conversation in its place (a model or
314
+ * account switch, another conversation opened or forked), `clear` when the
315
+ * person cleared it and a new, empty conversation begins (`/clear`, `/new`).
289
316
  */
290
- export type PluginSessionEndReason = 'exit' | 'replaced'
317
+ export type PluginSessionEndReason = 'exit' | 'replaced' | 'clear'
291
318
 
292
319
  export interface PluginHookContext {
293
320
  /** The turn the hook fired in. Absent on `session_start` and `session_end`. */
@@ -311,6 +338,14 @@ export interface PluginHookContext {
311
338
  /** The pass, on `pre_compact` and `post_compact`. */
312
339
  readonly compaction?: PluginCompactionInfo
313
340
  readonly toolName?: string
341
+ /**
342
+ * The id of the call, on `pre_tool_use`, `post_tool_use`,
343
+ * `post_tool_use_failure`, `permission_request` and `permission_denied`: the
344
+ * same id `post_tool_batch` carries as `toolCallId`, so a hook can pair a
345
+ * before with an after. Absent on a call a tool makes through
346
+ * `dispatchTool` (it has no model-issued id).
347
+ */
348
+ readonly toolCallId?: string
314
349
  readonly toolInput?: unknown
315
350
  readonly toolResult?: ToolResult
316
351
  /** The calls of one model step with their outcomes, on `post_tool_batch`. */
@@ -328,6 +363,13 @@ export interface PluginHookContext {
328
363
  * keep the model working until the turn's own limits stop it.
329
364
  */
330
365
  readonly stopHookActive?: boolean
366
+ /**
367
+ * On `turn_end` and `subagent_stop`: the text of the model's last message
368
+ * of the turn, cut to `MAX_LAST_MESSAGE_HOOK_CHARS`. Absent when the turn
369
+ * produced no text (it ended on a tool call, was interrupted before the
370
+ * model wrote anything, or failed).
371
+ */
372
+ readonly lastAssistantMessage?: string
331
373
  readonly iteration?: number
332
374
  /**
333
375
  * Why the turn was stopped, on `turn_interrupt`.
@@ -501,18 +543,20 @@ export type PluginHookResultFor<E extends PluginHookEvent> = E extends 'user_pro
501
543
  ? Extract<PluginHookResult, { action: 'continue' | 'error' }>
502
544
  : E extends 'permission_request'
503
545
  ? Extract<PluginHookResult, { action: 'continue' | 'skip' }>
504
- : E extends 'turn_end' | 'subagent_stop' | 'pre_compact'
505
- ? Extract<PluginHookResult, { action: 'continue' | 'skip' | 'error' }>
506
- : E extends 'session_start'
507
- ? Extract<PluginHookResult, { action: 'continue' | 'annotate' }>
508
- : E extends
509
- | 'turn_interrupt'
510
- | 'session_end'
511
- | 'notification'
512
- | 'turn_failure'
513
- | 'permission_denied'
514
- ? Extract<PluginHookResult, { action: 'continue' }>
515
- : Extract<PluginHookResult, { action: 'continue' | 'error' }>
546
+ : E extends 'pre_compact'
547
+ ? Extract<PluginHookResult, { action: 'continue' | 'annotate' | 'skip' | 'error' }>
548
+ : E extends 'turn_end' | 'subagent_stop'
549
+ ? Extract<PluginHookResult, { action: 'continue' | 'skip' | 'error' }>
550
+ : E extends 'session_start'
551
+ ? Extract<PluginHookResult, { action: 'continue' | 'annotate' }>
552
+ : E extends
553
+ | 'turn_interrupt'
554
+ | 'session_end'
555
+ | 'notification'
556
+ | 'turn_failure'
557
+ | 'permission_denied'
558
+ ? Extract<PluginHookResult, { action: 'continue' }>
559
+ : Extract<PluginHookResult, { action: 'continue' | 'error' }>
516
560
 
517
561
  /** The event and its handler verdict stay correlated, including in hook arrays. */
518
562
  export type PluginHookDefinition<E extends PluginHookEvent = PluginHookEvent> =
@@ -435,6 +435,8 @@ type CoreSessionEvent =
435
435
  message: string
436
436
  /** Optional completion in [0,1] when the tool genuinely knows it. */
437
437
  fraction?: number
438
+ /** Lines of output the call has produced so far, when the tool counts them (a shell command). Cumulative: the newest report wins. */
439
+ outputLines?: number
438
440
  }
439
441
  /** Provider-executed activity, retained as evidence rather than a local tool request. */
440
442
  | {
@@ -940,7 +940,13 @@ export interface ToolContext {
940
940
  *
941
941
  * Absent when the executing surface has no event stream to write to.
942
942
  */
943
- report?: (message: string, fraction?: number) => void
943
+ report?: (message: string, fraction?: number, details?: ToolProgressDetails) => void
944
+ }
945
+
946
+ /** Facts a tool can attach to a progress report besides its words. */
947
+ export interface ToolProgressDetails {
948
+ /** Lines of output the call has produced so far, counted by the tool itself (never by a renderer from what it was shown). */
949
+ readonly outputLines?: number
944
950
  }
945
951
 
946
952
  export interface ToolResult {
@@ -1009,6 +1015,13 @@ export interface ToolResult {
1009
1015
  * the child's turn fails with {@link ToolHandoff.reason} instead.
1010
1016
  */
1011
1017
  handoff?: ToolHandoff
1018
+ /**
1019
+ * This call only started work that goes on after it returned (a sub-agent
1020
+ * launched in the background, or one whose wait was released): the call itself
1021
+ * changed nothing. The turn's outcome record does not count it as a call that
1022
+ * may have changed files; what the started work does is its own record.
1023
+ */
1024
+ launched?: true
1012
1025
  /**
1013
1026
  * What this call did, as typed fields for the PERSON's view: the exit code
1014
1027
  * and the two streams of a command, the path and size of a read, whether a