@namzu/sdk 4.0.0 → 5.1.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 (107) hide show
  1. package/CHANGELOG.md +282 -0
  2. package/README.md +2 -2
  3. package/dist/agents/SupervisorAgent.d.ts.map +1 -1
  4. package/dist/agents/SupervisorAgent.js +6 -0
  5. package/dist/agents/SupervisorAgent.js.map +1 -1
  6. package/dist/agents/__tests__/run-agent.test.d.ts +2 -0
  7. package/dist/agents/__tests__/run-agent.test.d.ts.map +1 -0
  8. package/dist/agents/__tests__/run-agent.test.js +143 -0
  9. package/dist/agents/__tests__/run-agent.test.js.map +1 -0
  10. package/dist/agents/index.d.ts +2 -0
  11. package/dist/agents/index.d.ts.map +1 -1
  12. package/dist/agents/index.js +1 -0
  13. package/dist/agents/index.js.map +1 -1
  14. package/dist/agents/runAgent.d.ts +104 -0
  15. package/dist/agents/runAgent.d.ts.map +1 -0
  16. package/dist/agents/runAgent.js +92 -0
  17. package/dist/agents/runAgent.js.map +1 -0
  18. package/dist/provider/__tests__/thinking-support.test.d.ts +2 -0
  19. package/dist/provider/__tests__/thinking-support.test.d.ts.map +1 -0
  20. package/dist/provider/__tests__/thinking-support.test.js +47 -0
  21. package/dist/provider/__tests__/thinking-support.test.js.map +1 -0
  22. package/dist/provider/__tests__/typed-error-classification.test.d.ts +2 -0
  23. package/dist/provider/__tests__/typed-error-classification.test.d.ts.map +1 -0
  24. package/dist/provider/__tests__/typed-error-classification.test.js +123 -0
  25. package/dist/provider/__tests__/typed-error-classification.test.js.map +1 -0
  26. package/dist/provider/retry.d.ts.map +1 -1
  27. package/dist/provider/retry.js +23 -7
  28. package/dist/provider/retry.js.map +1 -1
  29. package/dist/provider/thinking-support.d.ts +30 -0
  30. package/dist/provider/thinking-support.d.ts.map +1 -0
  31. package/dist/provider/thinking-support.js +32 -0
  32. package/dist/provider/thinking-support.js.map +1 -0
  33. package/dist/public-runtime.d.ts +4 -1
  34. package/dist/public-runtime.d.ts.map +1 -1
  35. package/dist/public-runtime.js +10 -1
  36. package/dist/public-runtime.js.map +1 -1
  37. package/dist/public-tools.d.ts +1 -0
  38. package/dist/public-tools.d.ts.map +1 -1
  39. package/dist/public-tools.js +4 -0
  40. package/dist/public-tools.js.map +1 -1
  41. package/dist/public-types.d.ts +1 -1
  42. package/dist/public-types.d.ts.map +1 -1
  43. package/dist/runtime/query/__tests__/steering-reaches-the-model.test.d.ts +2 -0
  44. package/dist/runtime/query/__tests__/steering-reaches-the-model.test.d.ts.map +1 -0
  45. package/dist/runtime/query/__tests__/steering-reaches-the-model.test.js +94 -0
  46. package/dist/runtime/query/__tests__/steering-reaches-the-model.test.js.map +1 -0
  47. package/dist/runtime/query/__tests__/steering.test.d.ts +2 -0
  48. package/dist/runtime/query/__tests__/steering.test.d.ts.map +1 -0
  49. package/dist/runtime/query/__tests__/steering.test.js +92 -0
  50. package/dist/runtime/query/__tests__/steering.test.js.map +1 -0
  51. package/dist/runtime/query/__tests__/stream-recovery.test.js +5 -0
  52. package/dist/runtime/query/__tests__/stream-recovery.test.js.map +1 -1
  53. package/dist/runtime/query/index.d.ts +10 -0
  54. package/dist/runtime/query/index.d.ts.map +1 -1
  55. package/dist/runtime/query/index.js +1 -0
  56. package/dist/runtime/query/index.js.map +1 -1
  57. package/dist/runtime/query/iteration/phases/context.d.ts +8 -0
  58. package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
  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 +7 -1
  62. package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
  63. package/dist/runtime/query/steering.d.ts +81 -0
  64. package/dist/runtime/query/steering.d.ts.map +1 -0
  65. package/dist/runtime/query/steering.js +77 -0
  66. package/dist/runtime/query/steering.js.map +1 -0
  67. package/dist/types/agent/manager.d.ts +11 -4
  68. package/dist/types/agent/manager.d.ts.map +1 -1
  69. package/dist/types/agent/supervisor.d.ts +9 -0
  70. package/dist/types/agent/supervisor.d.ts.map +1 -1
  71. package/dist/types/common/index.d.ts +12 -0
  72. package/dist/types/common/index.d.ts.map +1 -1
  73. package/dist/types/common/index.js +7 -0
  74. package/dist/types/common/index.js.map +1 -1
  75. package/dist/types/provider/chat.d.ts +57 -5
  76. package/dist/types/provider/chat.d.ts.map +1 -1
  77. package/dist/types/provider/errors.d.ts +0 -17
  78. package/dist/types/provider/errors.d.ts.map +1 -1
  79. package/dist/types/provider/errors.js +60 -0
  80. package/dist/types/provider/errors.js.map +1 -1
  81. package/dist/types/provider/index.d.ts +1 -1
  82. package/dist/types/provider/index.d.ts.map +1 -1
  83. package/package.json +1 -1
  84. package/src/agents/SupervisorAgent.ts +6 -0
  85. package/src/agents/__tests__/run-agent.test.ts +165 -0
  86. package/src/agents/index.ts +2 -0
  87. package/src/agents/runAgent.ts +179 -0
  88. package/src/provider/__tests__/thinking-support.test.ts +60 -0
  89. package/src/provider/__tests__/typed-error-classification.test.ts +143 -0
  90. package/src/provider/retry.ts +23 -7
  91. package/src/provider/thinking-support.ts +37 -0
  92. package/src/public-runtime.ts +10 -0
  93. package/src/public-tools.ts +4 -0
  94. package/src/public-types.ts +7 -1
  95. package/src/runtime/query/__tests__/steering-reaches-the-model.test.ts +117 -0
  96. package/src/runtime/query/__tests__/steering.test.ts +121 -0
  97. package/src/runtime/query/__tests__/stream-recovery.test.ts +5 -0
  98. package/src/runtime/query/index.ts +12 -0
  99. package/src/runtime/query/iteration/phases/context.ts +9 -0
  100. package/src/runtime/query/iteration/phases/tool-review.ts +7 -1
  101. package/src/runtime/query/steering.ts +135 -0
  102. package/src/types/agent/manager.ts +11 -4
  103. package/src/types/agent/supervisor.ts +10 -0
  104. package/src/types/common/index.ts +20 -0
  105. package/src/types/provider/chat.ts +61 -5
  106. package/src/types/provider/errors.ts +71 -0
  107. package/src/types/provider/index.ts +1 -0
@@ -67,17 +67,69 @@ export interface ChatCompletionParams {
67
67
  * Drivers that do not support it ignore the field.
68
68
  */
69
69
  thinking?: ThinkingConfig;
70
+ /**
71
+ * How much work to put into the response. See {@link ReasoningEffort}.
72
+ *
73
+ * Drivers that do not support it ignore the field.
74
+ */
75
+ effort?: ReasoningEffort;
70
76
  }
71
77
  export interface ThinkingConfig {
72
- type: 'enabled' | 'disabled';
73
- /** Token allowance for the thinking pass. */
78
+ /**
79
+ * Which thinking mode to ask for.
80
+ *
81
+ * `'adaptive'` lets the model decide whether and how deeply to think per
82
+ * request; depth is steered by {@link ChatCompletionParams.effort} rather
83
+ * than a token budget. `'enabled'` is the older manual mode, where
84
+ * {@link budgetTokens} fixes the depth and the model thinks on every
85
+ * request.
86
+ *
87
+ * **These are not interchangeable, and a driver must not guess.** Vendors
88
+ * reject the wrong one for a given model outright rather than degrading:
89
+ * newer models refuse `'enabled'`, older ones refuse `'adaptive'`, and
90
+ * some refuse `'disabled'` because they cannot stop thinking at all. A
91
+ * driver that sends a mode the model does not accept produces a failed
92
+ * request, not a worse answer — which is why this is a declared intent
93
+ * that each driver resolves against the model it is about to call.
94
+ */
95
+ type: 'adaptive' | 'enabled' | 'disabled';
96
+ /**
97
+ * Token allowance for the thinking pass. Manual mode only — the adaptive
98
+ * mode has no budget, and depth is set by `effort`.
99
+ */
74
100
  budgetTokens?: number;
75
101
  /**
76
- * Whether the provider should return full thinking text or a summary.
77
- * Purely a request hint; the runtime stores whatever comes back.
102
+ * Whether the thinking text comes back or only its signature.
103
+ *
104
+ * `'omitted'` returns the blocks with an empty body and a signature, which
105
+ * is enough to replay them on the next turn (see `replayReasoning`) while
106
+ * keeping the text out of the response. `'summarized'` returns a summary
107
+ * of the reasoning.
108
+ *
109
+ * Worth setting explicitly. This defaults to `'omitted'` on newer models,
110
+ * so a caller that wants to show reasoning and does not ask for it gets
111
+ * thinking blocks whose text is empty and no indication why.
112
+ *
113
+ * The values were `'full' | 'summarized'` here, and `'full'` was never a
114
+ * value any vendor accepted — a declared option that could only ever have
115
+ * been rejected, next to a real one that was missing.
78
116
  */
79
- display?: 'full' | 'summarized';
117
+ display?: 'summarized' | 'omitted';
80
118
  }
119
+ /**
120
+ * How much work the model should put into a response.
121
+ *
122
+ * A sibling of {@link ChatCompletionParams.thinking}, not a field inside it,
123
+ * because it is not exclusively a thinking control: it shapes the whole
124
+ * response, and at least one manual-mode model accepts it alongside a token
125
+ * budget, where effort shapes the answer and the budget sets thinking depth.
126
+ * Nesting it under `thinking` would have made that combination unsayable.
127
+ *
128
+ * In adaptive mode it is the primary depth lever — low effort may skip
129
+ * thinking entirely on easy input. In manual mode `budgetTokens` sets depth
130
+ * and effort does not move it.
131
+ */
132
+ export type ReasoningEffort = 'low' | 'medium' | 'high' | 'xhigh' | 'max';
81
133
  export interface ChatCompletionResponse {
82
134
  id: string;
83
135
  model: string;
@@ -1 +1 @@
1
- {"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../../src/types/provider/chat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAErD,MAAM,MAAM,UAAU,GACnB,MAAM,GACN,MAAM,GACN,UAAU,GACV;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAA;AAEnD,MAAM,MAAM,cAAc,GACvB;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,GACvB;IACA,IAAI,EAAE,aAAa,CAAA;IACnB,WAAW,EAAE;QACZ,IAAI,EAAE,MAAM,CAAA;QACZ,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QAC/B,MAAM,CAAC,EAAE,OAAO,CAAA;K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WAAW,CAAA;QACjB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;QACtB,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAA;QACtB,mEAAmE;QACnE,SAAS,CAAC,EAAE,SAAS,cAAc,EAAE,CAAA;QACrC,kEAAkE;QAClE,SAAS,CAAC,EAAE,SAAS,OAAO,qBAAqB,EAAE,QAAQ,EAAE,CAAA;KAC7D,CAAA;IACD,YAAY,EAAE,MAAM,GAAG,YAAY,GAAG,QAAQ,GAAG,gBAAgB,CAAA;IACjE,KAAK,EAAE,UAAU,CAAA;CACjB"}
@@ -81,22 +81,5 @@ export declare function isProviderError(err: unknown): err is ProviderError;
81
81
  * settles it as `cancelled`. It must never be reclassified or retried.
82
82
  */
83
83
  export declare function isAbortError(err: unknown): boolean;
84
- /**
85
- * Turn whatever a driver threw into a {@link ProviderError}.
86
- *
87
- * Precedence is deliberate: a STRUCTURAL code is the most specific
88
- * signal, then HTTP status, then transport errno, then message text. `context_length_exceeded` is checked
89
- * ahead of the generic 400 mapping because it is the one 4xx the runtime
90
- * can actually act on (shed history and retry) rather than surface.
91
- *
92
- * Every signal is read across the WHOLE cause chain, not off the error
93
- * handed in. Wrapping is the normal case — a vendor SDK wraps its
94
- * transport error and the runtime wraps again on the way out — and reading
95
- * only the outer link meant a rate limit wrapped once classified as
96
- * `unknown`, which is non-retryable. The retry policy was therefore dead
97
- * for every failure that was not the outermost throwable.
98
- *
99
- * Aborts are passed through untouched — see {@link isAbortError}.
100
- */
101
84
  export declare function classifyProviderError(err: unknown, providerId?: string, now?: number): ProviderError;
102
85
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/types/provider/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,iBAAiB;AAC5B,qEAAqE;AACnE,YAAY;AACd,2DAA2D;GACzD,YAAY;AACd,+BAA+B;GAC7B,cAAc;AACh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,GAAG,SAAS,CAAA;IACnC,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAA;IACzC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;gBAEf,IAAI,EAAE,iBAAiB;CAenC;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,aAAa,CAElE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAOlD;AAsSD,wBAAgB,qBAAqB,CACpC,GAAG,EAAE,OAAO,EACZ,UAAU,CAAC,EAAE,MAAM,EACnB,GAAG,GAAE,MAAmB,GACtB,aAAa,CAsHf"}
@@ -293,9 +293,69 @@ function codeFromStructure(err) {
293
293
  *
294
294
  * Aborts are passed through untouched — see {@link isAbortError}.
295
295
  */
296
+ /**
297
+ * Every `ProviderErrorKind`, mapped to what the runtime acts on.
298
+ *
299
+ * Read structurally rather than with `instanceof`: a driver in one package
300
+ * throws this and the runtime in another reads it, and two copies of the SDK
301
+ * in one process make `instanceof` unreliable — the same reason
302
+ * `isProviderRequestError` exists.
303
+ *
304
+ * `retryable` here is about whether resending the SAME request could succeed.
305
+ * `context_overflow` is correctly false — an identical prompt overflows
306
+ * identically — and it maps to `context_length_exceeded` so the loop can reach
307
+ * for compaction, which is a different remedy than a retry.
308
+ */
309
+ const KIND_TO_CODE = {
310
+ throttle: { code: 'rate_limit', retryable: true },
311
+ network: { code: 'network', retryable: true },
312
+ server: { code: 'server_error', retryable: true },
313
+ auth: { code: 'auth', retryable: false },
314
+ context_overflow: { code: 'context_length_exceeded', retryable: false },
315
+ bad_request: { code: 'invalid_request', retryable: false },
316
+ };
317
+ function classifyFromProviderRequestError(err, providerId, now) {
318
+ if (!(err instanceof Error) || err.name !== 'ProviderRequestError')
319
+ return undefined;
320
+ const candidate = err;
321
+ if (typeof candidate.kind !== 'string')
322
+ return undefined;
323
+ const mapped = KIND_TO_CODE[candidate.kind];
324
+ if (!mapped)
325
+ return undefined;
326
+ const retryAfterMs = typeof candidate.retryAfterMs === 'number' ? candidate.retryAfterMs : readRetryAfterMs(err, now);
327
+ return new ProviderError({
328
+ code: mapped.code,
329
+ message: err.message,
330
+ retryable: mapped.retryable,
331
+ cause: err,
332
+ ...(typeof candidate.providerId === 'string'
333
+ ? { providerId: candidate.providerId }
334
+ : providerId !== undefined
335
+ ? { providerId }
336
+ : {}),
337
+ ...(typeof candidate.status === 'number' ? { status: candidate.status } : {}),
338
+ ...(retryAfterMs !== undefined ? { retryAfterMs } : {}),
339
+ });
340
+ }
296
341
  export function classifyProviderError(err, providerId, now = Date.now()) {
297
342
  if (isProviderError(err))
298
343
  return err;
344
+ // A driver that already classified its own failure is read FIRST, and by
345
+ // its `kind` — the field it set on purpose.
346
+ //
347
+ // Without this the classifier fell through to the status heuristics, where
348
+ // a `ProviderRequestError` carrying `kind: 'context_overflow'` and a 400
349
+ // became `invalid_request`, non-retryable. Three of the six kinds landed
350
+ // wrong that way, and the consequences were not cosmetic: the loop's
351
+ // overflow branch tests for `context_length_exceeded`, so compaction relief
352
+ // — the one provider failure this kernel can actually do something about —
353
+ // was unreachable for exactly the drivers that had diagnosed it correctly.
354
+ // A driver that classified its own error came out worse than one that did
355
+ // not, which is the opposite of the incentive the type was created for.
356
+ const fromKind = classifyFromProviderRequestError(err, providerId, now);
357
+ if (fromKind)
358
+ return fromKind;
299
359
  const message = err instanceof Error ? err.message : String(err);
300
360
  const status = readStatus(err);
301
361
  const errno = readErrnoCode(err);
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/types/provider/errors.ts"],"names":[],"mappings":"AAwDA;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAY;IAC7C,KAAK,MAAM,IAAI,IAAI,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACpC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAA;QAC/B,IAAI,OAAO,QAAQ,KA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,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC1D,KAAK,EAAE,GAAG;SACV,CAAC,CAAA;IACH,CAAC;IAED,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACzB,IAAI,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,IAAI,aAAa,CAAC;gBACxB,IAAI,EAAE,SAAS;gBACf,OAAO;gBACP,UAAU;gBACV,SAAS,EAAE,QAAQ;gBACnB,KAAK,EAAE,GAAG;aACV,CAAC,CAAA;QACH,CAAC;QACD,IAAI,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,IAAI,aAAa,CAAC;gBACxB,IAAI,EAAE,SAAS;gBACf,OAAO;gBACP,UAAU;gBACV,SAAS,EAAE,QAAQ;gBACnB,KAAK,EAAE,GAAG;aACV,CAAC,CAAA;QACH,CAAC;IACF,CAAC;IAED,8DAA8D;IAC9D,IAAI,GAAG,YAAY,SAAS,IAAI,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QAChE,OAAO,IAAI,aAAa,CAAC;YACxB,IAAI,EAAE,SAAS;YACf,OAAO;YACP,UAAU;YACV,SAAS,EAAE,QAAQ;YACnB,KAAK,EAAE,GAAG;SACV,CAAC,CAAA;IACH,CAAC;IAED,iEAAiE;IACjE,wEAAwE;IACxE,8DAA8D;IAC9D,OAAO,IAAI,aAAa,CAAC;QACxB,IAAI,EAAE,WAAW,IAAI,SAAS;QAC9B,OAAO;QACP,UAAU;QACV,YAAY;QACZ,SAAS,EAAE,QAAQ;QACnB,KAAK,EAAE,GAAG;KACV,CAAC,CAAA;AACH,CAAC"}
@@ -1,4 +1,4 @@
1
- export type { ToolChoice, ResponseFormat, CacheControl, ChatCompletionParams, ChatCompletionResponse, ThinkingConfig, } from './chat.js';
1
+ export type { ToolChoice, ResponseFormat, CacheControl, ChatCompletionParams, ChatCompletionResponse, ReasoningEffort, ThinkingConfig, } from './chat.js';
2
2
  export type { StreamChunk } from './stream.js';
3
3
  export type { ModelInfo } from './model.js';
4
4
  export type { LLMProvider } from './interface.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/provider/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACX,UAAU,EACV,cAAc,EACd,YAAY,EACZ,oBAAoB,EACpB,sBAAsB,EACtB,cAAc,GACd,MAAM,WAAW,CAAA;AAClB,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAC3C,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACjD,YAAY,EACX,iBAAiB,EACjB,iBAAiB,EACjB,wBAAwB,GACxB,MAAM,YAAY,CAAA;AACnB,YAAY,EACX,sBAAsB,EACtB,YAAY,EACZ,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,GACtB,MAAM,aAAa,CAAA;AACpB,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/provider/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACX,UAAU,EACV,cAAc,EACd,YAAY,EACZ,oBAAoB,EACpB,sBAAsB,EACtB,eAAe,EACf,cAAc,GACd,MAAM,WAAW,CAAA;AAClB,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAC3C,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACjD,YAAY,EACX,iBAAiB,EACjB,iBAAiB,EACjB,wBAAwB,GACxB,MAAM,YAAY,CAAA;AACnB,YAAY,EACX,sBAAsB,EACtB,YAAY,EACZ,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,GACtB,MAAM,aAAa,CAAA;AACpB,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@namzu/sdk",
3
- "version": "4.0.0",
3
+ "version": "5.1.0",
4
4
  "description": "Open-source AI agent SDK with a built-in runtime. Nothing between you and your agents.",
5
5
  "license": "FSL-1.1-MIT",
6
6
  "type": "module",
@@ -300,6 +300,12 @@ export class SupervisorAgent extends AbstractAgent<SupervisorAgentConfig, Superv
300
300
  // auto-approve. drainQuery falls back to autoApproveHandler
301
301
  // when resumeHandler is omitted (= same behaviour as before).
302
302
  ...(config.resumeHandler ? { resumeHandler: config.resumeHandler } : {}),
303
+ // Forwarded for the same reason the handler is. A capability the
304
+ // kernel honours in `drainQuery` but that never reaches the
305
+ // surface a host actually constructs is a capability nobody can
306
+ // use — which is the shape of defect this file has already been
307
+ // corrected for twice.
308
+ ...(config.steering ? { steering: config.steering } : {}),
303
309
  ...(config.verificationGate ? { verificationGate: config.verificationGate } : {}),
304
310
  ...(config.sandboxProvider ? { sandboxProvider: config.sandboxProvider } : {}),
305
311
  // Working-memory / compaction seam (optional; absent => unchanged
@@ -0,0 +1,165 @@
1
+ import { describe, expect, it } from 'vitest'
2
+ import { z } from 'zod'
3
+
4
+ import { MockLLMProvider, registerMock } from '../../provider/index.js'
5
+ import { ToolRegistry } from '../../registry/index.js'
6
+ import { runAgent } from '../runAgent.js'
7
+
8
+ /**
9
+ * `drainQuery` takes eleven required parameters, four of which throw when
10
+ * missing. That is right for a kernel and wrong for the first thing anybody
11
+ * writes — and the proof was in this repo, where the eval suites, the test
12
+ * files and the CLI each hand-assembled the same block.
13
+ *
14
+ * These pin the two things a front door has to get right: that the short form
15
+ * works at all, and that the identity it invents comes back, because a
16
+ * generated session that a caller cannot recover is a conversation that
17
+ * silently restarts on turn two.
18
+ */
19
+
20
+ registerMock()
21
+
22
+ describe('running an agent through the front door', () => {
23
+ it('runs from a provider, a model and a prompt', async () => {
24
+ const { output, run } = await runAgent({
25
+ provider: new MockLLMProvider({ turns: [{ text: 'four' }] }),
26
+ model: 'mock-model',
27
+ prompt: 'What is 2 + 2?',
28
+ })
29
+
30
+ expect(output).toBe('four')
31
+ expect(run.status).toBe('completed')
32
+ expect(run.stopReason).toBe('end_turn')
33
+ })
34
+
35
+ it('hands back the identity it generated, so a second turn can continue', async () => {
36
+ const first = await runAgent({
37
+ provider: new MockLLMProvider({ turns: [{ text: 'noted' }] }),
38
+ model: 'mock-model',
39
+ prompt: 'My name is Ada.',
40
+ })
41
+
42
+ expect(first.identity.sessionId).toBeTruthy()
43
+ expect(first.identity.tenantId).toBeTruthy()
44
+
45
+ const second = await runAgent({
46
+ provider: new MockLLMProvider({ turns: [{ text: 'Ada' }] }),
47
+ model: 'mock-model',
48
+ prompt: 'What is my name?',
49
+ ...first.identity,
50
+ })
51
+
52
+ // The same session, not a new one that happens to work.
53
+ expect(second.identity).toEqual(first.identity)
54
+ })
55
+
56
+ it('generates a distinct identity per run when none is given', async () => {
57
+ const a = await runAgent({
58
+ provider: new MockLLMProvider({ turns: [{ text: 'a' }] }),
59
+ model: 'mock-model',
60
+ prompt: 'x',
61
+ })
62
+ const b = await runAgent({
63
+ provider: new MockLLMProvider({ turns: [{ text: 'b' }] }),
64
+ model: 'mock-model',
65
+ prompt: 'y',
66
+ })
67
+
68
+ expect(a.identity.sessionId).not.toBe(b.identity.sessionId)
69
+ })
70
+
71
+ it('carries prior messages when the prompt is a history', async () => {
72
+ const provider = new MockLLMProvider({ turns: [{ text: 'Ada' }] })
73
+
74
+ await runAgent({
75
+ provider,
76
+ model: 'mock-model',
77
+ prompt: [
78
+ { role: 'user', content: 'My name is Ada.' },
79
+ { role: 'assistant', content: 'Noted.' },
80
+ { role: 'user', content: 'What is my name?' },
81
+ ] as never,
82
+ })
83
+
84
+ const sent = provider.requests[0]?.messages.map((m) => m.content) ?? []
85
+ expect(sent).toContain('My name is Ada.')
86
+ expect(sent).toContain('What is my name?')
87
+ })
88
+
89
+ it('passes instructions through as the system prompt', async () => {
90
+ const provider = new MockLLMProvider({ turns: [{ text: 'ok' }] })
91
+
92
+ await runAgent({
93
+ provider,
94
+ model: 'mock-model',
95
+ prompt: 'hello',
96
+ instructions: 'You only answer in haiku.',
97
+ })
98
+
99
+ const system = JSON.stringify(provider.requests[0]?.messages ?? [])
100
+ expect(system).toContain('You only answer in haiku.')
101
+ })
102
+
103
+ it('runs tools when given a registry', async () => {
104
+ const tools = new ToolRegistry()
105
+ let ran = false
106
+ tools.register({
107
+ name: 'ping',
108
+ description: 'pings',
109
+ inputSchema: z.object({}),
110
+ category: 'custom',
111
+ permissions: [],
112
+ readOnly: true,
113
+ destructive: false,
114
+ concurrencySafe: true,
115
+ execute: async () => {
116
+ ran = true
117
+ return { success: true, output: 'pong' }
118
+ },
119
+ } as never)
120
+
121
+ const { output } = await runAgent({
122
+ provider: new MockLLMProvider({
123
+ turns: [{ toolCalls: [{ id: 'c1', name: 'ping', rawArguments: '{}' }] }, { text: 'done' }],
124
+ }),
125
+ model: 'mock-model',
126
+ prompt: 'ping it',
127
+ tools,
128
+ })
129
+
130
+ expect(ran).toBe(true)
131
+ expect(output).toBe('done')
132
+ })
133
+
134
+ it('caps a runaway loop on its own default', async () => {
135
+ const tools = new ToolRegistry()
136
+ tools.register({
137
+ name: 'again',
138
+ description: 'always asks for more',
139
+ inputSchema: z.object({}),
140
+ category: 'custom',
141
+ permissions: [],
142
+ readOnly: true,
143
+ destructive: false,
144
+ concurrencySafe: true,
145
+ execute: async () => ({ success: true, output: 'and again' }),
146
+ } as never)
147
+
148
+ // The point of a default budget is that a caller who set none is still
149
+ // protected. Two iterations here rather than the default sixteen, so
150
+ // the test pins the mechanism without paying for it.
151
+ const { run } = await runAgent({
152
+ provider: new MockLLMProvider({
153
+ turns: Array.from({ length: 10 }, () => ({
154
+ toolCalls: [{ id: 'c', name: 'again', rawArguments: '{}' }],
155
+ })),
156
+ }),
157
+ model: 'mock-model',
158
+ prompt: 'loop',
159
+ tools,
160
+ maxIterations: 2,
161
+ })
162
+
163
+ expect(run.currentIteration).toBeLessThanOrEqual(2)
164
+ })
165
+ })
@@ -7,3 +7,5 @@ export { defineAgent } from './defineAgent.js'
7
7
  export type { DefineAgentOptions } from './defineAgent.js'
8
8
  export { InvocationLock, ConcurrentInvocationError } from './lock.js'
9
9
  export type { Disposable } from './lock.js'
10
+ export { runAgent } from './runAgent.js'
11
+ export type { AgentIdentity, RunAgentOptions, RunAgentResult } from './runAgent.js'
@@ -0,0 +1,179 @@
1
+ import { ToolRegistry } from '../registry/tool/execute.js'
2
+ import { drainQuery } from '../runtime/query/index.js'
3
+ import type { ProjectId, SessionId, TenantId, ThreadId } from '../types/ids/index.js'
4
+ import type { Message } from '../types/message/index.js'
5
+ import type { LLMProvider } from '../types/provider/index.js'
6
+ import type { Run, RunEventListener } from '../types/run/index.js'
7
+ import type { ToolRegistryContract } from '../types/tool/index.js'
8
+ import {
9
+ generateProjectId,
10
+ generateSessionId,
11
+ generateTenantId,
12
+ generateThreadId,
13
+ } from '../utils/id.js'
14
+
15
+ /**
16
+ * The session a run belongs to.
17
+ *
18
+ * Every field is generated when absent, and the generated values come back on
19
+ * the result so a second turn can be handed the same ones. That pairing is the
20
+ * point: auto-generating alone would make each call its own session, which is
21
+ * right for a one-shot and silently wrong for a conversation — the second turn
22
+ * would start with no history and no shared budget, and nothing would say so.
23
+ */
24
+ export interface AgentIdentity {
25
+ sessionId?: SessionId
26
+ threadId?: ThreadId
27
+ projectId?: ProjectId
28
+ tenantId?: TenantId
29
+ }
30
+
31
+ export interface RunAgentOptions extends AgentIdentity {
32
+ /** The model driver. The one thing with no sensible default. */
33
+ provider: LLMProvider
34
+
35
+ /** What to ask. A string is turned into a single user message. */
36
+ prompt: string | Message[]
37
+
38
+ /** The system prompt. */
39
+ instructions?: string
40
+
41
+ /**
42
+ * Model id.
43
+ *
44
+ * Required, and not defaulted from the provider, because `LLMProvider`
45
+ * carries no model — a driver may have been constructed with one, but the
46
+ * interface does not expose it, so anything this function picked would be
47
+ * a guess billed to the caller. Two required options is a shape someone
48
+ * can hold in their head; a wrong model quietly used is not.
49
+ */
50
+ model: string
51
+
52
+ tools?: ToolRegistryContract
53
+
54
+ /** Defaults to the current working directory. */
55
+ workingDirectory?: string
56
+
57
+ maxIterations?: number
58
+ tokenBudget?: number
59
+ timeoutMs?: number
60
+ temperature?: number
61
+
62
+ /** Names the agent in traces and events. Defaults to `Agent`. */
63
+ name?: string
64
+
65
+ signal?: AbortSignal
66
+ listener?: RunEventListener
67
+ }
68
+
69
+ export interface RunAgentResult {
70
+ /** The model's final text, or `undefined` if it produced none. */
71
+ readonly output: string | undefined
72
+
73
+ /** The full run — usage, cost, steps, stop reason, every message. */
74
+ readonly run: Run
75
+
76
+ /**
77
+ * The identity this run used, with anything generated filled in.
78
+ *
79
+ * Pass it straight back into the next call to continue the same session.
80
+ */
81
+ readonly identity: Required<AgentIdentity>
82
+ }
83
+
84
+ /**
85
+ * Defaults chosen to be safe rather than generous.
86
+ *
87
+ * A front door exists so a first run works without a decision, and the cost of
88
+ * that convenience is that nobody reads these numbers before their first
89
+ * runaway loop. So: a budget that ends a stuck run in seconds rather than
90
+ * dollars, and an iteration cap that stops a tool-calling loop well before a
91
+ * context window does. Every one is overridable and named on the option.
92
+ */
93
+ const DEFAULT_MAX_ITERATIONS = 16
94
+ const DEFAULT_TOKEN_BUDGET = 200_000
95
+ const DEFAULT_TIMEOUT_MS = 300_000
96
+
97
+ /**
98
+ * Run an agent, without assembling a kernel by hand.
99
+ *
100
+ * `drainQuery` is the kernel's real entry point and takes eleven required
101
+ * parameters, four of which are identity fields that throw when missing. That
102
+ * is the correct shape for a kernel — a run with no tenant is a run no auditor
103
+ * can attribute — and it is the wrong shape for the first thing anybody
104
+ * writes. The proof was in this repo: the eval suites, the test files and the
105
+ * CLI each hand-assemble the same block, which is what a missing front door
106
+ * looks like from the inside.
107
+ *
108
+ * So this supplies an environment rather than a new engine. It generates the
109
+ * identity a single-tenant local run has no opinion about, defaults the
110
+ * budgets, points the working directory at the process's own, and hands back
111
+ * both the answer and the identity it used. Everything it fills in is a normal
112
+ * `drainQuery` parameter; there is no second code path, and a caller who
113
+ * outgrows it passes more options until they are calling `drainQuery` in all
114
+ * but name.
115
+ *
116
+ * ```ts
117
+ * const { output } = await runAgent({
118
+ * provider,
119
+ * model: 'claude-sonnet-4-5',
120
+ * prompt: 'What is 2 + 2?',
121
+ * })
122
+ * ```
123
+ *
124
+ * A second turn in the same session is the identity handed back, and the
125
+ * previous messages carried forward:
126
+ *
127
+ * ```ts
128
+ * const first = await runAgent({ provider, model, prompt: 'My name is Ada.' })
129
+ *
130
+ * const second = await runAgent({
131
+ * provider,
132
+ * model,
133
+ * ...first.identity,
134
+ * prompt: [...first.run.messages, createUserMessage('What is my name?')],
135
+ * })
136
+ * ```
137
+ */
138
+ export async function runAgent(options: RunAgentOptions): Promise<RunAgentResult> {
139
+ const identity: Required<AgentIdentity> = {
140
+ sessionId: options.sessionId ?? generateSessionId(),
141
+ threadId: options.threadId ?? generateThreadId(),
142
+ projectId: options.projectId ?? generateProjectId(),
143
+ tenantId: options.tenantId ?? generateTenantId(),
144
+ }
145
+
146
+ const messages: Message[] =
147
+ typeof options.prompt === 'string'
148
+ ? [{ role: 'user', content: options.prompt, timestamp: Date.now() } as Message]
149
+ : options.prompt
150
+
151
+ const run = await drainQuery(
152
+ {
153
+ provider: options.provider,
154
+ tools: options.tools ?? new ToolRegistry(),
155
+ messages,
156
+ workingDirectory: options.workingDirectory ?? process.cwd(),
157
+ runConfig: {
158
+ model: options.model,
159
+ maxIterations: options.maxIterations ?? DEFAULT_MAX_ITERATIONS,
160
+ tokenBudget: options.tokenBudget ?? DEFAULT_TOKEN_BUDGET,
161
+ timeoutMs: options.timeoutMs ?? DEFAULT_TIMEOUT_MS,
162
+ ...(options.temperature !== undefined ? { temperature: options.temperature } : {}),
163
+ },
164
+ // One option covers both. `drainQuery` separates the id from the
165
+ // display name because a fleet needs a stable key and a readable
166
+ // label; a single agent has no such tension, and asking for two
167
+ // strings that will always be the same is the kind of ceremony this
168
+ // function exists to remove.
169
+ agentId: options.name ?? 'agent',
170
+ agentName: options.name ?? 'Agent',
171
+ ...(options.instructions ? { systemPrompt: options.instructions } : {}),
172
+ ...(options.signal ? { signal: options.signal } : {}),
173
+ ...identity,
174
+ } as never,
175
+ options.listener,
176
+ )
177
+
178
+ return { output: run.result, run, identity }
179
+ }