@namzu/sdk 62.4.0 → 62.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 (101) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/agents/QueryAgent.d.ts.map +1 -1
  3. package/dist/agents/QueryAgent.js +3 -0
  4. package/dist/agents/QueryAgent.js.map +1 -1
  5. package/dist/agents/runAgent.d.ts +3 -1
  6. package/dist/agents/runAgent.d.ts.map +1 -1
  7. package/dist/agents/runAgent.js +1 -0
  8. package/dist/agents/runAgent.js.map +1 -1
  9. package/dist/bridge/a2a/mapper.d.ts.map +1 -1
  10. package/dist/bridge/a2a/mapper.js +5 -3
  11. package/dist/bridge/a2a/mapper.js.map +1 -1
  12. package/dist/pricing/catalogue.generated.d.ts.map +1 -1
  13. package/dist/pricing/catalogue.generated.js +5 -0
  14. package/dist/pricing/catalogue.generated.js.map +1 -1
  15. package/dist/provider/fallback.d.ts.map +1 -1
  16. package/dist/provider/fallback.js +23 -1
  17. package/dist/provider/fallback.js.map +1 -1
  18. package/dist/public-runtime.d.ts +1 -1
  19. package/dist/public-runtime.d.ts.map +1 -1
  20. package/dist/public-runtime.js +1 -1
  21. package/dist/public-runtime.js.map +1 -1
  22. package/dist/runtime/query/index.d.ts +21 -0
  23. package/dist/runtime/query/index.d.ts.map +1 -1
  24. package/dist/runtime/query/index.js +4 -0
  25. package/dist/runtime/query/index.js.map +1 -1
  26. package/dist/runtime/query/iteration/index.d.ts +10 -0
  27. package/dist/runtime/query/iteration/index.d.ts.map +1 -1
  28. package/dist/runtime/query/iteration/index.js +59 -6
  29. package/dist/runtime/query/iteration/index.js.map +1 -1
  30. package/dist/runtime/query/iteration/phases/context.d.ts +4 -0
  31. package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
  32. package/dist/runtime/query/iteration/phases/context.js.map +1 -1
  33. package/dist/runtime/query/iteration/step-shaping.d.ts.map +1 -1
  34. package/dist/runtime/query/iteration/step-shaping.js +3 -0
  35. package/dist/runtime/query/iteration/step-shaping.js.map +1 -1
  36. package/dist/runtime/query/prepare-turn.d.ts.map +1 -1
  37. package/dist/runtime/query/prepare-turn.js +5 -2
  38. package/dist/runtime/query/prepare-turn.js.map +1 -1
  39. package/dist/runtime/query/request-rich-content.d.ts +7 -1
  40. package/dist/runtime/query/request-rich-content.d.ts.map +1 -1
  41. package/dist/runtime/query/request-rich-content.js +8 -2
  42. package/dist/runtime/query/request-rich-content.js.map +1 -1
  43. package/dist/turn/index.d.ts +1 -1
  44. package/dist/turn/index.d.ts.map +1 -1
  45. package/dist/turn/index.js +1 -1
  46. package/dist/turn/index.js.map +1 -1
  47. package/dist/turn/memory-recall.d.ts +13 -0
  48. package/dist/turn/memory-recall.d.ts.map +1 -1
  49. package/dist/turn/memory-recall.js +38 -1
  50. package/dist/turn/memory-recall.js.map +1 -1
  51. package/dist/types/agent/base.d.ts +2 -0
  52. package/dist/types/agent/base.d.ts.map +1 -1
  53. package/dist/types/agent/query.d.ts +4 -0
  54. package/dist/types/agent/query.d.ts.map +1 -1
  55. package/dist/types/common/index.d.ts +7 -0
  56. package/dist/types/common/index.d.ts.map +1 -1
  57. package/dist/types/common/index.js +3 -0
  58. package/dist/types/common/index.js.map +1 -1
  59. package/dist/types/provider/chat.d.ts +10 -0
  60. package/dist/types/provider/chat.d.ts.map +1 -1
  61. package/dist/types/provider/config.d.ts +8 -0
  62. package/dist/types/provider/config.d.ts.map +1 -1
  63. package/dist/types/provider/index.d.ts +1 -1
  64. package/dist/types/provider/index.d.ts.map +1 -1
  65. package/dist/types/session/config.d.ts +10 -0
  66. package/dist/types/session/config.d.ts.map +1 -1
  67. package/dist/types/session/events.d.ts +8 -1
  68. package/dist/types/session/events.d.ts.map +1 -1
  69. package/dist/types/session/events.js.map +1 -1
  70. package/dist/types/session/prepare-step.d.ts +7 -0
  71. package/dist/types/session/prepare-step.d.ts.map +1 -1
  72. package/dist/utils/cost.d.ts +7 -0
  73. package/dist/utils/cost.d.ts.map +1 -1
  74. package/dist/utils/cost.js +15 -0
  75. package/dist/utils/cost.js.map +1 -1
  76. package/package.json +1 -1
  77. package/src/agents/QueryAgent.ts +3 -0
  78. package/src/agents/runAgent.ts +9 -1
  79. package/src/bridge/a2a/mapper.ts +5 -3
  80. package/src/pricing/catalogue.generated.ts +5 -0
  81. package/src/pricing/rates.source.json +15 -5
  82. package/src/provider/fallback.ts +33 -1
  83. package/src/public-runtime.ts +1 -1
  84. package/src/runtime/query/index.ts +27 -0
  85. package/src/runtime/query/iteration/index.ts +70 -5
  86. package/src/runtime/query/iteration/phases/context.ts +4 -0
  87. package/src/runtime/query/iteration/step-shaping.ts +3 -0
  88. package/src/runtime/query/prepare-turn.ts +6 -2
  89. package/src/runtime/query/request-rich-content.ts +11 -2
  90. package/src/turn/index.ts +1 -1
  91. package/src/turn/memory-recall.ts +40 -0
  92. package/src/types/agent/base.ts +2 -0
  93. package/src/types/agent/query.ts +4 -0
  94. package/src/types/common/index.ts +11 -0
  95. package/src/types/provider/chat.ts +12 -0
  96. package/src/types/provider/config.ts +8 -0
  97. package/src/types/provider/index.ts +1 -0
  98. package/src/types/session/config.ts +11 -0
  99. package/src/types/session/events.ts +8 -1
  100. package/src/types/session/prepare-step.ts +7 -0
  101. package/src/utils/cost.ts +23 -0
@@ -69,6 +69,17 @@ export interface TurnConfig {
69
69
  */
70
70
  effort?: import('../provider/index.js').ReasoningEffort
71
71
 
72
+ /**
73
+ * Inference speed for every model call in the turn: `'fast'` asks for the
74
+ * provider's premium low-latency mode (billed at a multiple of the standard
75
+ * rate), absent and `'standard'` are the ordinary request. Turn-level for
76
+ * the same reason as {@link TurnConfig.effort}: speeds do not share a
77
+ * prompt-cache prefix, so a value that moves between steps pays for a cache
78
+ * miss each time. A driver or model without the mode REFUSES `'fast'`
79
+ * rather than serving it slowly.
80
+ */
81
+ speed?: import('../provider/index.js').InferenceSpeed
82
+
72
83
  /**
73
84
  * How the turn bounds its reasoning. On by default.
74
85
  *
@@ -519,7 +519,14 @@ type CoreSessionEvent =
519
519
  /** The model that declined. */
520
520
  model: string
521
521
  providerId: string
522
- outcome: 'fallback' | 'retry' | 'declined'
522
+ outcome: 'fallback' | 'retry' | 'withheld' | 'declined'
523
+ /**
524
+ * Set only with `outcome: 'withheld'`: the recorded-context keys the
525
+ * re-run leaves out of the request (see `QueryParams.withholdOnRefusal`).
526
+ */
527
+ withheldKeys?: string[]
528
+ /** With `'withheld'`: the ids of the recalled memories those entries carried. */
529
+ withheldMemoryIds?: string[]
523
530
  /** The model the request moves to. Set only with `outcome: 'fallback'`. */
524
531
  fallbackModel?: string
525
532
  /** The provider's own classification, when it gave one. */
@@ -98,6 +98,13 @@ export interface PrepareStepContext {
98
98
  }
99
99
  /** Every completed step, in order. */
100
100
  readonly steps: readonly StepResult[]
101
+ /**
102
+ * Recorded-context keys the request leaves out: set aside by a refused
103
+ * request (`QueryParams.withholdOnRefusal`) or by the host
104
+ * (`QueryParams.withheldKeys`). A stage that records text under one of
105
+ * these keys should add nothing now; whatever it records is also left out.
106
+ */
107
+ readonly withheldKeys?: readonly string[]
101
108
 
102
109
  /**
103
110
  * What the stages before this one decided, when several were supplied.
package/src/utils/cost.ts CHANGED
@@ -41,6 +41,13 @@ export interface ModelPricing {
41
41
  * part. The catalogue always supplies this.
42
42
  */
43
43
  cache?: CacheRates
44
+ /**
45
+ * The vendor's published multiple of every rate on this card for a request
46
+ * served in fast mode (`TokenUsage.speed === 'fast'`). Absent means there is
47
+ * no published fast price: fast usage is then counted as unpriced, never
48
+ * charged at the standard rate, which would under-report it.
49
+ */
50
+ fastMultiplier?: number
44
51
  }
45
52
 
46
53
  export { ZERO_COST }
@@ -54,6 +61,22 @@ interface Priced {
54
61
  }
55
62
 
56
63
  function priceUsage(usage: TokenUsage, pricing: ModelPricing): Priced {
64
+ if (usage.speed === 'fast') {
65
+ const multiplier = pricing.fastMultiplier
66
+ if (multiplier === undefined) {
67
+ return { cost: 0, cacheDiscount: 0, unpriced: usage.totalTokens }
68
+ }
69
+ const standard = priceStandard({ ...usage, speed: undefined }, pricing)
70
+ return {
71
+ cost: standard.cost * multiplier,
72
+ cacheDiscount: standard.cacheDiscount * multiplier,
73
+ unpriced: standard.unpriced,
74
+ }
75
+ }
76
+ return priceStandard(usage, pricing)
77
+ }
78
+
79
+ function priceStandard(usage: TokenUsage, pricing: ModelPricing): Priced {
57
80
  const perMillion = (tokens: number, rate: number) => (tokens / 1_000_000) * rate
58
81
 
59
82
  const cache = pricing.cache