@namzu/sdk 64.3.0 → 65.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 (106) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/advisory/executor.d.ts +2 -1
  3. package/dist/advisory/executor.d.ts.map +1 -1
  4. package/dist/advisory/executor.js +8 -2
  5. package/dist/advisory/executor.js.map +1 -1
  6. package/dist/agents/explore.js +1 -1
  7. package/dist/agents/explore.js.map +1 -1
  8. package/dist/agents/plan.js +1 -1
  9. package/dist/agents/plan.js.map +1 -1
  10. package/dist/compaction/context-window.d.ts.map +1 -1
  11. package/dist/compaction/context-window.js +9 -2
  12. package/dist/compaction/context-window.js.map +1 -1
  13. package/dist/eval/judge.d.ts.map +1 -1
  14. package/dist/eval/judge.js +6 -2
  15. package/dist/eval/judge.js.map +1 -1
  16. package/dist/manager/agent/lifecycle.d.ts +1 -0
  17. package/dist/manager/agent/lifecycle.d.ts.map +1 -1
  18. package/dist/manager/agent/lifecycle.js +20 -6
  19. package/dist/manager/agent/lifecycle.js.map +1 -1
  20. package/dist/manager/session/turn-recorder.d.ts.map +1 -1
  21. package/dist/manager/session/turn-recorder.js +11 -2
  22. package/dist/manager/session/turn-recorder.js.map +1 -1
  23. package/dist/prompt/coding-agent-doctrine.d.ts +2 -2
  24. package/dist/prompt/coding-agent-doctrine.d.ts.map +1 -1
  25. package/dist/prompt/coding-agent-doctrine.js +39 -38
  26. package/dist/prompt/coding-agent-doctrine.js.map +1 -1
  27. package/dist/provider/fallback.d.ts.map +1 -1
  28. package/dist/provider/fallback.js +4 -3
  29. package/dist/provider/fallback.js.map +1 -1
  30. package/dist/provider/idle-timeout.js +1 -1
  31. package/dist/provider/idle-timeout.js.map +1 -1
  32. package/dist/provider/instrumentation.js +1 -1
  33. package/dist/provider/instrumentation.js.map +1 -1
  34. package/dist/provider/retry.js +1 -1
  35. package/dist/provider/retry.js.map +1 -1
  36. package/dist/provider/side-request-reasoning.d.ts +32 -0
  37. package/dist/provider/side-request-reasoning.d.ts.map +1 -0
  38. package/dist/provider/side-request-reasoning.js +97 -0
  39. package/dist/provider/side-request-reasoning.js.map +1 -0
  40. package/dist/public-runtime.d.ts +3 -1
  41. package/dist/public-runtime.d.ts.map +1 -1
  42. package/dist/public-runtime.js +2 -1
  43. package/dist/public-runtime.js.map +1 -1
  44. package/dist/runtime/query/auto-review/classifier.d.ts.map +1 -1
  45. package/dist/runtime/query/auto-review/classifier.js +8 -2
  46. package/dist/runtime/query/auto-review/classifier.js.map +1 -1
  47. package/dist/runtime/query/callback-inference.d.ts.map +1 -1
  48. package/dist/runtime/query/callback-inference.js +14 -3
  49. package/dist/runtime/query/callback-inference.js.map +1 -1
  50. package/dist/runtime/query/iteration/index.d.ts +17 -0
  51. package/dist/runtime/query/iteration/index.d.ts.map +1 -1
  52. package/dist/runtime/query/iteration/index.js +82 -10
  53. package/dist/runtime/query/iteration/index.js.map +1 -1
  54. package/dist/runtime/query/prepare-turn.d.ts.map +1 -1
  55. package/dist/runtime/query/prepare-turn.js +3 -0
  56. package/dist/runtime/query/prepare-turn.js.map +1 -1
  57. package/dist/runtime/query/repeat-call.js +2 -2
  58. package/dist/runtime/query/repeat-call.js.map +1 -1
  59. package/dist/runtime/query/turn/stall-monitor.d.ts +47 -2
  60. package/dist/runtime/query/turn/stall-monitor.d.ts.map +1 -1
  61. package/dist/runtime/query/turn/stall-monitor.js +72 -4
  62. package/dist/runtime/query/turn/stall-monitor.js.map +1 -1
  63. package/dist/turn/evidence-query.d.ts.map +1 -1
  64. package/dist/turn/evidence-query.js +7 -1
  65. package/dist/turn/evidence-query.js.map +1 -1
  66. package/dist/types/common/index.d.ts +14 -0
  67. package/dist/types/common/index.d.ts.map +1 -1
  68. package/dist/types/common/index.js +7 -0
  69. package/dist/types/common/index.js.map +1 -1
  70. package/dist/types/provider/config.d.ts +6 -0
  71. package/dist/types/provider/config.d.ts.map +1 -1
  72. package/dist/types/provider/interface.d.ts +8 -6
  73. package/dist/types/provider/interface.d.ts.map +1 -1
  74. package/dist/types/session/prepare-step.d.ts +7 -0
  75. package/dist/types/session/prepare-step.d.ts.map +1 -1
  76. package/dist/utils/cost.d.ts +14 -0
  77. package/dist/utils/cost.d.ts.map +1 -1
  78. package/dist/utils/cost.js +20 -0
  79. package/dist/utils/cost.js.map +1 -1
  80. package/package.json +1 -1
  81. package/src/advisory/executor.ts +13 -2
  82. package/src/agents/explore.ts +1 -1
  83. package/src/agents/plan.ts +1 -1
  84. package/src/compaction/context-window.ts +9 -2
  85. package/src/eval/judge.ts +16 -9
  86. package/src/manager/agent/lifecycle.ts +19 -6
  87. package/src/manager/session/turn-recorder.ts +12 -1
  88. package/src/prompt/coding-agent-doctrine.ts +40 -39
  89. package/src/provider/fallback.ts +4 -3
  90. package/src/provider/idle-timeout.ts +1 -1
  91. package/src/provider/instrumentation.ts +1 -1
  92. package/src/provider/retry.ts +1 -1
  93. package/src/provider/side-request-reasoning.ts +121 -0
  94. package/src/public-runtime.ts +7 -0
  95. package/src/runtime/query/auto-review/classifier.ts +17 -9
  96. package/src/runtime/query/callback-inference.ts +13 -3
  97. package/src/runtime/query/iteration/index.ts +93 -12
  98. package/src/runtime/query/prepare-turn.ts +2 -0
  99. package/src/runtime/query/repeat-call.ts +2 -2
  100. package/src/runtime/query/turn/stall-monitor.ts +92 -4
  101. package/src/turn/evidence-query.ts +8 -1
  102. package/src/types/common/index.ts +22 -0
  103. package/src/types/provider/config.ts +6 -0
  104. package/src/types/provider/interface.ts +8 -6
  105. package/src/types/session/prepare-step.ts +7 -0
  106. package/src/utils/cost.ts +24 -0
@@ -183,15 +183,17 @@ export interface LLMProvider {
183
183
  * Whether `model` takes a forced tool choice (`toolChoice: 'required'` or a
184
184
  * named function) under the thinking configuration the request will carry.
185
185
  *
186
- * The kernel asks before it requires a tool call on a step it wants to act,
187
- * and when the answer is `false` it keeps the step at low effort and asks the
188
- * model in words instead of sending a choice the driver would refuse. `effort`
186
+ * The kernel asks before a guard requires a tool call on a step it wants to
187
+ * act, and sends a forced choice only when the answer is `true` and the
188
+ * request does not turn thinking on. Otherwise it keeps the step at low effort
189
+ * and asks the model in words. `effort`
189
190
  * is the level the request will carry, for a driver where the level also
190
191
  * decides whether thinking is on (a provider that does not need it ignores
191
192
  * it). Optional:
192
- * a provider that does not declare it is treated as taking the choice, so
193
- * every existing driver behaves as before. A wrapper that rebuilds a provider
194
- * forwards it.
193
+ * a provider that does not declare it is not sent a guard's forced choice (the
194
+ * words are used). A host's own `toolChoice` is sent as given. A wrapper that
195
+ * rebuilds a provider forwards it; a chain answers `true` only when every
196
+ * member does.
195
197
  */
196
198
  acceptsForcedToolChoiceFor?(
197
199
  model: string,
@@ -33,6 +33,13 @@ export interface PreparationTextResult {
33
33
  readonly text: string
34
34
  readonly usage: TokenUsage
35
35
  readonly servedBy: StepProvenance
36
+ /**
37
+ * Why the provider stopped. `'length'` means the answer allowance ran out,
38
+ * which on a reasoning model can leave `text` empty or cut off mid-way; a
39
+ * caller that needs complete text treats it as no answer. Absent when the
40
+ * provider reported none.
41
+ */
42
+ readonly finishReason?: 'stop' | 'tool_calls' | 'length' | 'content_filter'
36
43
  }
37
44
 
38
45
  /**
package/src/utils/cost.ts CHANGED
@@ -241,6 +241,30 @@ export function accumulateUnpricedCost(current: CostInfo, additionalUsage: Token
241
241
  }
242
242
  }
243
243
 
244
+ /**
245
+ * Record a call whose cost the provider reported.
246
+ *
247
+ * The vendor's figure is what the account was charged, so it wins over a rate
248
+ * card: a card is an estimate of one model at one list price, while the report
249
+ * already includes the route that served the call, the cache discount and any
250
+ * tier. The rate fields go, as for unpriced tokens: no single card describes
251
+ * a total that holds a reported figure.
252
+ */
253
+ export function accumulateReportedCost(current: CostInfo, reportedCostUsd: number): CostInfo {
254
+ return {
255
+ totalCost: current.totalCost + reportedCostUsd,
256
+ cacheDiscount: current.cacheDiscount,
257
+ unpricedTokens: current.unpricedTokens,
258
+ }
259
+ }
260
+
261
+ /** Whether a usage frame carries a usable vendor-reported cost. */
262
+ export function hasReportedCost(
263
+ usage: TokenUsage,
264
+ ): usage is TokenUsage & { reportedCostUsd: number } {
265
+ return Number.isFinite(usage.reportedCostUsd) && (usage.reportedCostUsd as number) >= 0
266
+ }
267
+
244
268
  export function formatCost(usd: number): string {
245
269
  if (usd === 0) return '$0.00'
246
270
  if (usd < 0.01) return `$${usd.toFixed(4)}`