@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.
- package/CHANGELOG.md +20 -0
- package/dist/agents/QueryAgent.d.ts.map +1 -1
- package/dist/agents/QueryAgent.js +3 -0
- package/dist/agents/QueryAgent.js.map +1 -1
- package/dist/agents/runAgent.d.ts +3 -1
- package/dist/agents/runAgent.d.ts.map +1 -1
- package/dist/agents/runAgent.js +1 -0
- package/dist/agents/runAgent.js.map +1 -1
- package/dist/bridge/a2a/mapper.d.ts.map +1 -1
- package/dist/bridge/a2a/mapper.js +5 -3
- package/dist/bridge/a2a/mapper.js.map +1 -1
- package/dist/pricing/catalogue.generated.d.ts.map +1 -1
- package/dist/pricing/catalogue.generated.js +5 -0
- package/dist/pricing/catalogue.generated.js.map +1 -1
- package/dist/provider/fallback.d.ts.map +1 -1
- package/dist/provider/fallback.js +23 -1
- package/dist/provider/fallback.js.map +1 -1
- package/dist/public-runtime.d.ts +1 -1
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +1 -1
- package/dist/public-runtime.js.map +1 -1
- package/dist/runtime/query/index.d.ts +21 -0
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +4 -0
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts +10 -0
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +59 -6
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts +4 -0
- package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/context.js.map +1 -1
- package/dist/runtime/query/iteration/step-shaping.d.ts.map +1 -1
- package/dist/runtime/query/iteration/step-shaping.js +3 -0
- package/dist/runtime/query/iteration/step-shaping.js.map +1 -1
- package/dist/runtime/query/prepare-turn.d.ts.map +1 -1
- package/dist/runtime/query/prepare-turn.js +5 -2
- package/dist/runtime/query/prepare-turn.js.map +1 -1
- package/dist/runtime/query/request-rich-content.d.ts +7 -1
- package/dist/runtime/query/request-rich-content.d.ts.map +1 -1
- package/dist/runtime/query/request-rich-content.js +8 -2
- package/dist/runtime/query/request-rich-content.js.map +1 -1
- package/dist/turn/index.d.ts +1 -1
- package/dist/turn/index.d.ts.map +1 -1
- package/dist/turn/index.js +1 -1
- package/dist/turn/index.js.map +1 -1
- package/dist/turn/memory-recall.d.ts +13 -0
- package/dist/turn/memory-recall.d.ts.map +1 -1
- package/dist/turn/memory-recall.js +38 -1
- package/dist/turn/memory-recall.js.map +1 -1
- package/dist/types/agent/base.d.ts +2 -0
- package/dist/types/agent/base.d.ts.map +1 -1
- package/dist/types/agent/query.d.ts +4 -0
- package/dist/types/agent/query.d.ts.map +1 -1
- package/dist/types/common/index.d.ts +7 -0
- package/dist/types/common/index.d.ts.map +1 -1
- package/dist/types/common/index.js +3 -0
- package/dist/types/common/index.js.map +1 -1
- package/dist/types/provider/chat.d.ts +10 -0
- package/dist/types/provider/chat.d.ts.map +1 -1
- package/dist/types/provider/config.d.ts +8 -0
- package/dist/types/provider/config.d.ts.map +1 -1
- package/dist/types/provider/index.d.ts +1 -1
- package/dist/types/provider/index.d.ts.map +1 -1
- package/dist/types/session/config.d.ts +10 -0
- package/dist/types/session/config.d.ts.map +1 -1
- package/dist/types/session/events.d.ts +8 -1
- package/dist/types/session/events.d.ts.map +1 -1
- package/dist/types/session/events.js.map +1 -1
- package/dist/types/session/prepare-step.d.ts +7 -0
- package/dist/types/session/prepare-step.d.ts.map +1 -1
- package/dist/utils/cost.d.ts +7 -0
- package/dist/utils/cost.d.ts.map +1 -1
- package/dist/utils/cost.js +15 -0
- package/dist/utils/cost.js.map +1 -1
- package/package.json +1 -1
- package/src/agents/QueryAgent.ts +3 -0
- package/src/agents/runAgent.ts +9 -1
- package/src/bridge/a2a/mapper.ts +5 -3
- package/src/pricing/catalogue.generated.ts +5 -0
- package/src/pricing/rates.source.json +15 -5
- package/src/provider/fallback.ts +33 -1
- package/src/public-runtime.ts +1 -1
- package/src/runtime/query/index.ts +27 -0
- package/src/runtime/query/iteration/index.ts +70 -5
- package/src/runtime/query/iteration/phases/context.ts +4 -0
- package/src/runtime/query/iteration/step-shaping.ts +3 -0
- package/src/runtime/query/prepare-turn.ts +6 -2
- package/src/runtime/query/request-rich-content.ts +11 -2
- package/src/turn/index.ts +1 -1
- package/src/turn/memory-recall.ts +40 -0
- package/src/types/agent/base.ts +2 -0
- package/src/types/agent/query.ts +4 -0
- package/src/types/common/index.ts +11 -0
- package/src/types/provider/chat.ts +12 -0
- package/src/types/provider/config.ts +8 -0
- package/src/types/provider/index.ts +1 -0
- package/src/types/session/config.ts +11 -0
- package/src/types/session/events.ts +8 -1
- package/src/types/session/prepare-step.ts +7 -0
- 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
|