@niscorp/signal 0.1.3 → 0.1.5
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 +18 -0
- package/DOCS.md +58 -4
- package/dist/index.cjs +20 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +20 -58
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -516,6 +516,8 @@ declare const modelRegistry: Record<string, ModelEntry>;
|
|
|
516
516
|
declare const UNMEASURED_MODEL: ModelCapabilities;
|
|
517
517
|
declare const modelKey: (provider: string, model: string) => string;
|
|
518
518
|
declare const modelEntry: (provider: string, model: string) => ModelEntry | undefined;
|
|
519
|
+
type ModelDefaults = Pick<SignalOptions, 'temperature' | 'topP' | 'maxTokens'>;
|
|
520
|
+
declare const modelDefaults: Record<string, ModelDefaults>;
|
|
519
521
|
declare const chatProviderEntry: (id: string) => ChatProviderEntry | undefined;
|
|
520
522
|
|
|
521
523
|
type ErrorWireStrategy = {
|
|
@@ -588,4 +590,4 @@ type ResolvedTransport = {
|
|
|
588
590
|
declare const RESPOND_TOOL_NAME = "respond";
|
|
589
591
|
declare const resolveTransport: (spec: TransportSpec, caps: Capabilities) => ResolvedTransport;
|
|
590
592
|
|
|
591
|
-
export { type AssistantToolCall, type CalibratedDecision, type Capabilities, type ChatProviderEntry, type ChoiceQuestion, type ContentPart, type CountInput, type CustomChatProviderConfig, type CustomDecisionProviderConfig, type CustomProviderConfig, type DecideMeta, type DecideRequest, type DecideResult, type DecideState, type DecisionProviderEntry, type EmbedOptions, type EmbedRequest, type EmbedResponse, type EndpointCapabilities, ErrorCode, type ErrorWireStrategy, type ExtractResult, type ImageSource, type Message, type ModelCapabilities, type ModelEntry, type NoulQuestion, type OutputTransport, type ProviderEntry, type ProviderError, type Question, type Questions, REASONING_EFFORTS, RESPOND_TOOL_NAME, type ReasoningEffort, type Rejection, type ResolvedTransport, type ResponseFormat, type ResponseWireStrategy, type ScoreQuestion, type Signal, type SignalConfig, type SignalDescription, SignalError, type SignalMeta, type SignalOptions, type SignalResult, type StepInputMessage, type StepOutcome, type StepRequest, type StepResult, type StepStreamEvent, type StepToolCall, type StepToolDescriptor, type StreamEvent, type StreamOptions, type Tool, type ToolCallRecord, type ToolConfig, type TransportSpec, UNMEASURED_MODEL, type UncalibratedDecision, type WireReport, type WireStrategy, chatProviderEntry, closeTruncated, createSignal, decodeJsonish, deepDecodeJsonish, defineTool, extractJson, isTruncatedJson, modelEntry, modelKey, modelRegistry, providerRegistry, repairEscapeDamage, resolveTransport, routeRejection, routeResponse };
|
|
593
|
+
export { type AssistantToolCall, type CalibratedDecision, type Capabilities, type ChatProviderEntry, type ChoiceQuestion, type ContentPart, type CountInput, type CustomChatProviderConfig, type CustomDecisionProviderConfig, type CustomProviderConfig, type DecideMeta, type DecideRequest, type DecideResult, type DecideState, type DecisionProviderEntry, type EmbedOptions, type EmbedRequest, type EmbedResponse, type EndpointCapabilities, ErrorCode, type ErrorWireStrategy, type ExtractResult, type ImageSource, type Message, type ModelCapabilities, type ModelDefaults, type ModelEntry, type NoulQuestion, type OutputTransport, type ProviderEntry, type ProviderError, type Question, type Questions, REASONING_EFFORTS, RESPOND_TOOL_NAME, type ReasoningEffort, type Rejection, type ResolvedTransport, type ResponseFormat, type ResponseWireStrategy, type ScoreQuestion, type Signal, type SignalConfig, type SignalDescription, SignalError, type SignalMeta, type SignalOptions, type SignalResult, type StepInputMessage, type StepOutcome, type StepRequest, type StepResult, type StepStreamEvent, type StepToolCall, type StepToolDescriptor, type StreamEvent, type StreamOptions, type Tool, type ToolCallRecord, type ToolConfig, type TransportSpec, UNMEASURED_MODEL, type UncalibratedDecision, type WireReport, type WireStrategy, chatProviderEntry, closeTruncated, createSignal, decodeJsonish, deepDecodeJsonish, defineTool, extractJson, isTruncatedJson, modelDefaults, modelEntry, modelKey, modelRegistry, providerRegistry, repairEscapeDamage, resolveTransport, routeRejection, routeResponse };
|
package/dist/index.d.ts
CHANGED
|
@@ -516,6 +516,8 @@ declare const modelRegistry: Record<string, ModelEntry>;
|
|
|
516
516
|
declare const UNMEASURED_MODEL: ModelCapabilities;
|
|
517
517
|
declare const modelKey: (provider: string, model: string) => string;
|
|
518
518
|
declare const modelEntry: (provider: string, model: string) => ModelEntry | undefined;
|
|
519
|
+
type ModelDefaults = Pick<SignalOptions, 'temperature' | 'topP' | 'maxTokens'>;
|
|
520
|
+
declare const modelDefaults: Record<string, ModelDefaults>;
|
|
519
521
|
declare const chatProviderEntry: (id: string) => ChatProviderEntry | undefined;
|
|
520
522
|
|
|
521
523
|
type ErrorWireStrategy = {
|
|
@@ -588,4 +590,4 @@ type ResolvedTransport = {
|
|
|
588
590
|
declare const RESPOND_TOOL_NAME = "respond";
|
|
589
591
|
declare const resolveTransport: (spec: TransportSpec, caps: Capabilities) => ResolvedTransport;
|
|
590
592
|
|
|
591
|
-
export { type AssistantToolCall, type CalibratedDecision, type Capabilities, type ChatProviderEntry, type ChoiceQuestion, type ContentPart, type CountInput, type CustomChatProviderConfig, type CustomDecisionProviderConfig, type CustomProviderConfig, type DecideMeta, type DecideRequest, type DecideResult, type DecideState, type DecisionProviderEntry, type EmbedOptions, type EmbedRequest, type EmbedResponse, type EndpointCapabilities, ErrorCode, type ErrorWireStrategy, type ExtractResult, type ImageSource, type Message, type ModelCapabilities, type ModelEntry, type NoulQuestion, type OutputTransport, type ProviderEntry, type ProviderError, type Question, type Questions, REASONING_EFFORTS, RESPOND_TOOL_NAME, type ReasoningEffort, type Rejection, type ResolvedTransport, type ResponseFormat, type ResponseWireStrategy, type ScoreQuestion, type Signal, type SignalConfig, type SignalDescription, SignalError, type SignalMeta, type SignalOptions, type SignalResult, type StepInputMessage, type StepOutcome, type StepRequest, type StepResult, type StepStreamEvent, type StepToolCall, type StepToolDescriptor, type StreamEvent, type StreamOptions, type Tool, type ToolCallRecord, type ToolConfig, type TransportSpec, UNMEASURED_MODEL, type UncalibratedDecision, type WireReport, type WireStrategy, chatProviderEntry, closeTruncated, createSignal, decodeJsonish, deepDecodeJsonish, defineTool, extractJson, isTruncatedJson, modelEntry, modelKey, modelRegistry, providerRegistry, repairEscapeDamage, resolveTransport, routeRejection, routeResponse };
|
|
593
|
+
export { type AssistantToolCall, type CalibratedDecision, type Capabilities, type ChatProviderEntry, type ChoiceQuestion, type ContentPart, type CountInput, type CustomChatProviderConfig, type CustomDecisionProviderConfig, type CustomProviderConfig, type DecideMeta, type DecideRequest, type DecideResult, type DecideState, type DecisionProviderEntry, type EmbedOptions, type EmbedRequest, type EmbedResponse, type EndpointCapabilities, ErrorCode, type ErrorWireStrategy, type ExtractResult, type ImageSource, type Message, type ModelCapabilities, type ModelDefaults, type ModelEntry, type NoulQuestion, type OutputTransport, type ProviderEntry, type ProviderError, type Question, type Questions, REASONING_EFFORTS, RESPOND_TOOL_NAME, type ReasoningEffort, type Rejection, type ResolvedTransport, type ResponseFormat, type ResponseWireStrategy, type ScoreQuestion, type Signal, type SignalConfig, type SignalDescription, SignalError, type SignalMeta, type SignalOptions, type SignalResult, type StepInputMessage, type StepOutcome, type StepRequest, type StepResult, type StepStreamEvent, type StepToolCall, type StepToolDescriptor, type StreamEvent, type StreamOptions, type Tool, type ToolCallRecord, type ToolConfig, type TransportSpec, UNMEASURED_MODEL, type UncalibratedDecision, type WireReport, type WireStrategy, chatProviderEntry, closeTruncated, createSignal, decodeJsonish, deepDecodeJsonish, defineTool, extractJson, isTruncatedJson, modelDefaults, modelEntry, modelKey, modelRegistry, providerRegistry, repairEscapeDamage, resolveTransport, routeRejection, routeResponse };
|
package/dist/index.js
CHANGED
|
@@ -50,17 +50,11 @@ var providerRegistry = {
|
|
|
50
50
|
endpoint: {
|
|
51
51
|
nativeTools: true,
|
|
52
52
|
nativeJsonMode: true,
|
|
53
|
-
// Groq validates tool args server-side (tool_use_failed 400s).
|
|
54
53
|
validatesToolArgs: true,
|
|
55
54
|
supportsEmbedding: false
|
|
56
55
|
},
|
|
57
56
|
adapter: "openai-compatible",
|
|
58
|
-
// tool_use_failed / json_validate_failed 400s carry the model's
|
|
59
|
-
// attempt in failed_generation — recover and route it.
|
|
60
57
|
wire: ["failed-generation"],
|
|
61
|
-
// Reasoning models stream their trace only when asked to parse it out;
|
|
62
|
-
// `reasoning_format` is rejected on the non-reasoning ones, which is why
|
|
63
|
-
// this is opt-in (see reasoningRequest above).
|
|
64
58
|
reasoningRequest: { reasoning_format: "parsed" }
|
|
65
59
|
},
|
|
66
60
|
openai: {
|
|
@@ -75,8 +69,6 @@ var providerRegistry = {
|
|
|
75
69
|
supportsEmbedding: true
|
|
76
70
|
},
|
|
77
71
|
adapter: "openai-compatible",
|
|
78
|
-
// 4o-era models occasionally emit JSONL where one value was asked
|
|
79
|
-
// for; the acceptance gate decides, so this can never misfire.
|
|
80
72
|
wire: ["jsonl-lines"]
|
|
81
73
|
},
|
|
82
74
|
openrouter: {
|
|
@@ -91,8 +83,6 @@ var providerRegistry = {
|
|
|
91
83
|
supportsEmbedding: false
|
|
92
84
|
},
|
|
93
85
|
adapter: "openai-compatible",
|
|
94
|
-
// OpenRouter unifies reasoning across the models it routes; `enabled` turns
|
|
95
|
-
// the trace on for those that have one and is ignored by those that don't.
|
|
96
86
|
reasoningRequest: { reasoning: { enabled: true } }
|
|
97
87
|
},
|
|
98
88
|
anthropic: {
|
|
@@ -125,97 +115,78 @@ var providerRegistry = {
|
|
|
125
115
|
id: "typesafe",
|
|
126
116
|
baseUrl: "https://api.typesafe.ai/v1",
|
|
127
117
|
envKey: "TYPESAFE_API_KEY",
|
|
128
|
-
// The moving alias. A caller that records calibration against a model pins
|
|
129
|
-
// a version (`jev-1.13.0`) with `.model()`.
|
|
130
118
|
defaultModel: "jev-latest",
|
|
131
119
|
adapter: "systemone"
|
|
132
120
|
}
|
|
133
121
|
};
|
|
134
122
|
var modelRegistry = {
|
|
135
|
-
// ── groq ──
|
|
136
123
|
"groq/qwen/qwen3.8-27b": {
|
|
137
124
|
capabilities: { nativeJsonSchema: false, toolsWithStructuredOutput: false, manglesNestedToolArgs: true, multimodal: true },
|
|
138
|
-
// nested: 3 of 20 trials failed
|
|
139
125
|
reasoningEfforts: ["none", "default", "low", "medium", "high"],
|
|
140
126
|
verified: "2026-09-24"
|
|
141
127
|
},
|
|
142
128
|
"groq/openai/gpt-oss-120b": {
|
|
143
129
|
capabilities: { nativeJsonSchema: true, toolsWithStructuredOutput: false, manglesNestedToolArgs: true, multimodal: false },
|
|
144
|
-
// nested: 1 of 20 trials failed
|
|
145
130
|
reasoningEfforts: ["low", "medium", "high"],
|
|
146
131
|
verified: "2026-09-24"
|
|
147
132
|
},
|
|
148
133
|
"groq/openai/gpt-oss-20b": {
|
|
149
134
|
capabilities: { nativeJsonSchema: true, toolsWithStructuredOutput: false, manglesNestedToolArgs: true, multimodal: false },
|
|
150
|
-
// nested: 6 of 20 trials failed
|
|
151
135
|
reasoningEfforts: ["low", "medium", "high"],
|
|
152
136
|
verified: "2026-09-24"
|
|
153
137
|
},
|
|
154
|
-
// ── openai ──
|
|
155
138
|
"openai/gpt-4o": {
|
|
156
139
|
capabilities: { nativeJsonSchema: true, toolsWithStructuredOutput: true, manglesNestedToolArgs: false, multimodal: true },
|
|
157
|
-
// nested: 0 of 20 trials failed
|
|
158
140
|
reasoningEfforts: [],
|
|
159
141
|
verified: "2026-09-24"
|
|
160
142
|
},
|
|
161
143
|
"openai/gpt-4o-mini": {
|
|
162
144
|
capabilities: { nativeJsonSchema: true, toolsWithStructuredOutput: true, manglesNestedToolArgs: false, multimodal: true },
|
|
163
|
-
// nested: 0 of 20 trials failed
|
|
164
145
|
reasoningEfforts: [],
|
|
165
146
|
verified: "2026-09-24"
|
|
166
147
|
},
|
|
167
148
|
"openai/gpt-4.1-mini": {
|
|
168
149
|
capabilities: { nativeJsonSchema: true, toolsWithStructuredOutput: true, manglesNestedToolArgs: false, multimodal: true },
|
|
169
|
-
// nested: 0 of 20 trials failed
|
|
170
150
|
reasoningEfforts: [],
|
|
171
151
|
verified: "2026-09-24"
|
|
172
152
|
},
|
|
173
|
-
// ── openrouter ──
|
|
174
153
|
"openrouter/qwen/qwen3.8-27b": {
|
|
175
154
|
capabilities: { nativeJsonSchema: true, toolsWithStructuredOutput: true, manglesNestedToolArgs: false, multimodal: true },
|
|
176
|
-
// nested: 0 of 20 trials failed
|
|
177
155
|
reasoningEfforts: ["none", "minimal", "low", "medium", "high", "xhigh", "max"],
|
|
178
156
|
verified: "2026-09-24"
|
|
179
157
|
},
|
|
180
158
|
"openrouter/openai/gpt-4o": {
|
|
181
159
|
capabilities: { nativeJsonSchema: true, toolsWithStructuredOutput: true, manglesNestedToolArgs: false, multimodal: true },
|
|
182
|
-
// nested: 0 of 20 trials failed
|
|
183
160
|
reasoningEfforts: ["none", "minimal", "low", "medium", "high", "xhigh", "max"],
|
|
184
161
|
verified: "2026-09-24"
|
|
185
162
|
},
|
|
186
163
|
"openrouter/openai/gpt-4o-mini": {
|
|
187
164
|
capabilities: { nativeJsonSchema: true, toolsWithStructuredOutput: true, manglesNestedToolArgs: false, multimodal: true },
|
|
188
|
-
// nested: 0 of 20 trials failed
|
|
189
165
|
reasoningEfforts: ["none", "minimal", "low", "medium", "high", "xhigh", "max"],
|
|
190
166
|
verified: "2026-09-24"
|
|
191
167
|
},
|
|
192
168
|
"openrouter/openai/gpt-oss-120b": {
|
|
193
169
|
capabilities: { nativeJsonSchema: false, toolsWithStructuredOutput: true, manglesNestedToolArgs: false, multimodal: false },
|
|
194
|
-
// nested: 0 of 20 trials failed
|
|
195
170
|
reasoningEfforts: ["minimal", "low", "medium", "high", "xhigh", "max"],
|
|
196
171
|
verified: "2026-09-24"
|
|
197
172
|
},
|
|
198
173
|
"openrouter/z-ai/glm-5.2": {
|
|
199
174
|
capabilities: { nativeJsonSchema: true, toolsWithStructuredOutput: true, manglesNestedToolArgs: true, multimodal: false },
|
|
200
|
-
// nested: 1 of 20 trials failed
|
|
201
175
|
reasoningEfforts: ["none", "minimal", "low", "medium", "high", "xhigh", "max"],
|
|
202
176
|
verified: "2026-09-24"
|
|
203
177
|
},
|
|
204
178
|
"openrouter/openai/gpt-5.6-luna": {
|
|
205
179
|
capabilities: { nativeJsonSchema: true, toolsWithStructuredOutput: true, manglesNestedToolArgs: false, multimodal: true },
|
|
206
|
-
// nested: 0 of 20 trials failed
|
|
207
180
|
reasoningEfforts: ["none", "minimal", "low", "medium", "high", "xhigh", "max"],
|
|
208
181
|
verified: "2026-09-24"
|
|
209
182
|
},
|
|
210
183
|
"openrouter/openai/gpt-oss-20b": {
|
|
211
184
|
capabilities: { nativeJsonSchema: false, toolsWithStructuredOutput: true, manglesNestedToolArgs: false, multimodal: false },
|
|
212
|
-
// nested: 0 of 20 trials failed
|
|
213
185
|
reasoningEfforts: ["minimal", "low", "medium", "high", "xhigh", "max"],
|
|
214
186
|
verified: "2026-09-24"
|
|
215
187
|
},
|
|
216
188
|
"openrouter/meta-llama/llama-3.3-70b-instruct": {
|
|
217
189
|
capabilities: { nativeJsonSchema: false, toolsWithStructuredOutput: true, manglesNestedToolArgs: true, multimodal: false },
|
|
218
|
-
// nested: 9 of 20 trials failed
|
|
219
190
|
reasoningEfforts: ["none", "minimal", "low", "medium", "high", "xhigh", "max"],
|
|
220
191
|
verified: "2026-09-24"
|
|
221
192
|
}
|
|
@@ -228,6 +199,11 @@ var UNMEASURED_MODEL = {
|
|
|
228
199
|
};
|
|
229
200
|
var modelKey = (provider, model) => `${provider}/${model}`;
|
|
230
201
|
var modelEntry = (provider, model) => modelRegistry[modelKey(provider, model)];
|
|
202
|
+
var GPT_OSS_ON_GROQ = { temperature: 1, topP: 1, maxTokens: 16384 };
|
|
203
|
+
var modelDefaults = {
|
|
204
|
+
"groq/openai/gpt-oss-120b": GPT_OSS_ON_GROQ,
|
|
205
|
+
"groq/openai/gpt-oss-20b": GPT_OSS_ON_GROQ
|
|
206
|
+
};
|
|
231
207
|
var resolveApiKey = (envKey, explicitKey) => explicitKey ?? (typeof process !== "undefined" ? process.env?.[envKey] : void 0);
|
|
232
208
|
var chatProviderEntry = (id) => {
|
|
233
209
|
const entry = providerRegistry[id];
|
|
@@ -379,9 +355,8 @@ var createOpenAICompatibleAdapter = async (config) => {
|
|
|
379
355
|
async function* chatStream(request, options) {
|
|
380
356
|
const streamParams = {
|
|
381
357
|
...buildParams(request),
|
|
382
|
-
//
|
|
383
|
-
//
|
|
384
|
-
// the non-stream `chat` path never sees these, so its content is unmoved.
|
|
358
|
+
// Only when the caller set reasoningEffort: Groq answers `reasoning_format` with a 400
|
|
359
|
+
// on its non-reasoning models.
|
|
385
360
|
...request.options?.reasoningEffort !== void 0 && config.reasoningRequest !== void 0 ? config.reasoningRequest : {},
|
|
386
361
|
stream: true,
|
|
387
362
|
stream_options: { include_usage: true }
|
|
@@ -707,8 +682,6 @@ async function* executeStepStream(config) {
|
|
|
707
682
|
contentBuffer += delta.text;
|
|
708
683
|
yield { type: "text", text: delta.text };
|
|
709
684
|
break;
|
|
710
|
-
// Reasoning is passed straight through and deliberately NOT added to
|
|
711
|
-
// contentBuffer: it is the model thinking, not its answer.
|
|
712
685
|
case "reasoning":
|
|
713
686
|
yield { type: "reasoning", text: delta.text };
|
|
714
687
|
break;
|
|
@@ -1341,6 +1314,10 @@ var modelRowOf = (config) => {
|
|
|
1341
1314
|
const model = config.model ?? entry.defaultModel;
|
|
1342
1315
|
return { provider: config.provider, model, row: modelEntry(config.provider, model) };
|
|
1343
1316
|
};
|
|
1317
|
+
var defaultsOf = (config) => {
|
|
1318
|
+
const resolved = modelRowOf(config);
|
|
1319
|
+
return resolved === void 0 ? void 0 : modelDefaults[modelKey(resolved.provider, resolved.model)];
|
|
1320
|
+
};
|
|
1344
1321
|
var resolveCapabilities = (config) => {
|
|
1345
1322
|
if (typeof config.provider === "string") {
|
|
1346
1323
|
const entry = providerRegistry[config.provider];
|
|
@@ -1387,10 +1364,7 @@ var buildMessages = (config, input) => {
|
|
|
1387
1364
|
var recoveredStepResult = (recovered, routed, raw, sent) => ({
|
|
1388
1365
|
content: "",
|
|
1389
1366
|
toolCalls: routed.outcome.kind === "tool_calls" ? routed.outcome.calls : [],
|
|
1390
|
-
//
|
|
1391
|
-
// billed for it — and the 400 body carries none. The prompt is known exactly
|
|
1392
|
-
// and the model's attempt is in the rejection, so this is countable rather
|
|
1393
|
-
// than lost. Marked unreported, because it is a reckoning.
|
|
1367
|
+
// The provider bills a rejected generation and its 400 carries no usage.
|
|
1394
1368
|
usage: estimateUsage(sent, recovered.rejection.argsText, routed.outcome.kind === "tool_calls" ? routed.outcome.calls : []),
|
|
1395
1369
|
finishReason: "error_recovered",
|
|
1396
1370
|
raw,
|
|
@@ -1409,6 +1383,7 @@ var createSignalFromConfig = (config) => {
|
|
|
1409
1383
|
let cachedAdapterKey;
|
|
1410
1384
|
const wireStrategies = resolveWireStrategies(wireIdsOf(config));
|
|
1411
1385
|
assertEffort(config, config.options?.reasoningEffort);
|
|
1386
|
+
const defaults = defaultsOf(config);
|
|
1412
1387
|
const getAdapter = async () => {
|
|
1413
1388
|
const resolved = resolveProvider(config);
|
|
1414
1389
|
const key = `${resolved.adapterType}:${resolved.baseUrl}:${resolved.apiKey}`;
|
|
@@ -1445,12 +1420,8 @@ var createSignalFromConfig = (config) => {
|
|
|
1445
1420
|
...providerTools && { tools: providerTools },
|
|
1446
1421
|
...request.toolChoice !== void 0 && { toolChoice: request.toolChoice },
|
|
1447
1422
|
...request.responseFormat !== void 0 && { responseFormat: request.responseFormat },
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
// step used to drop them, so a configured client behaved differently
|
|
1451
|
-
// depending on which door the caller came through.
|
|
1452
|
-
...(config.options !== void 0 || request.options !== void 0) && {
|
|
1453
|
-
options: { ...config.options, ...request.options }
|
|
1423
|
+
...(defaults !== void 0 || config.options !== void 0 || request.options !== void 0) && {
|
|
1424
|
+
options: { ...defaults, ...config.options, ...request.options }
|
|
1454
1425
|
}
|
|
1455
1426
|
};
|
|
1456
1427
|
assertEffort(config, providerRequest.options?.reasoningEffort);
|
|
@@ -1483,8 +1454,7 @@ var createSignalFromConfig = (config) => {
|
|
|
1483
1454
|
const result = {
|
|
1484
1455
|
content: response.content,
|
|
1485
1456
|
toolCalls,
|
|
1486
|
-
//
|
|
1487
|
-
// zero rather than a missing frame.
|
|
1457
|
+
// A non-streaming body always carries usage, so a zero here is a reported zero.
|
|
1488
1458
|
usage: { ...response.usage, reported: true },
|
|
1489
1459
|
finishReason: response.finishReason,
|
|
1490
1460
|
raw: response.raw
|
|
@@ -1505,7 +1475,7 @@ var createSignalFromConfig = (config) => {
|
|
|
1505
1475
|
const adapter = await getChatAdapter(verb);
|
|
1506
1476
|
const resolved = resolveProvider(config);
|
|
1507
1477
|
const declared = new Set((request.tools ?? []).map((tool) => tool.name));
|
|
1508
|
-
const merged = config.options !== void 0 || request.options !== void 0 ? { ...request, options: { ...config.options, ...request.options } } : request;
|
|
1478
|
+
const merged = defaults !== void 0 || config.options !== void 0 || request.options !== void 0 ? { ...request, options: { ...defaults, ...config.options, ...request.options } } : request;
|
|
1509
1479
|
assertEffort(config, merged.options?.reasoningEffort);
|
|
1510
1480
|
try {
|
|
1511
1481
|
for await (const event of executeStepStream({
|
|
@@ -1580,8 +1550,7 @@ var createSignalFromConfig = (config) => {
|
|
|
1580
1550
|
decisions: acceptUncalibrated(request.questions, result.response, result.meta.provider.raw),
|
|
1581
1551
|
meta: {
|
|
1582
1552
|
model: result.meta.model,
|
|
1583
|
-
// complete()
|
|
1584
|
-
// and does not say which, so this total cannot be vouched for as measured.
|
|
1553
|
+
// complete() adds reported usage to estimated usage and does not say which.
|
|
1585
1554
|
usage: { ...result.meta.usage, reported: false },
|
|
1586
1555
|
durationMs: Date.now() - started,
|
|
1587
1556
|
provider: { raw: result.meta.provider.raw }
|
|
@@ -1589,7 +1558,6 @@ var createSignalFromConfig = (config) => {
|
|
|
1589
1558
|
};
|
|
1590
1559
|
};
|
|
1591
1560
|
return {
|
|
1592
|
-
// Builder methods
|
|
1593
1561
|
apiKey: (key) => fork({ apiKey: key }),
|
|
1594
1562
|
model: (m) => fork({ model: m }),
|
|
1595
1563
|
systemPrompt: (prompt) => fork({ systemPrompt: prompt }),
|
|
@@ -1619,7 +1587,6 @@ var createSignalFromConfig = (config) => {
|
|
|
1619
1587
|
modelKnown: false
|
|
1620
1588
|
};
|
|
1621
1589
|
},
|
|
1622
|
-
// Execution — thin wrappers over the step core (src/complete.ts).
|
|
1623
1590
|
complete: async (input) => runComplete(
|
|
1624
1591
|
{
|
|
1625
1592
|
messages: buildMessages(config, input),
|
|
@@ -1645,10 +1612,8 @@ var createSignalFromConfig = (config) => {
|
|
|
1645
1612
|
},
|
|
1646
1613
|
{ stepStream: stepStreamAs("stream"), model: resolveProvider(config).model, capabilities: resolveCapabilities(config) }
|
|
1647
1614
|
),
|
|
1648
|
-
// ─── Low-level primitives — the execution core itself ────
|
|
1649
1615
|
step,
|
|
1650
1616
|
stepStream,
|
|
1651
|
-
// ─── Embedding ────────────────────────────────────────────
|
|
1652
1617
|
embed: (async (input, options) => {
|
|
1653
1618
|
const adapter = await getChatAdapter("embed");
|
|
1654
1619
|
if (!adapter.embed) {
|
|
@@ -1668,7 +1633,6 @@ var createSignalFromConfig = (config) => {
|
|
|
1668
1633
|
}
|
|
1669
1634
|
return response.embeddings;
|
|
1670
1635
|
}),
|
|
1671
|
-
// ─── Decisions ────────────────────────────────────────────
|
|
1672
1636
|
decide: async (request) => {
|
|
1673
1637
|
assertQuestions(request.questions);
|
|
1674
1638
|
const started = Date.now();
|
|
@@ -1676,7 +1640,6 @@ var createSignalFromConfig = (config) => {
|
|
|
1676
1640
|
const model = resolveProvider(config).model;
|
|
1677
1641
|
return adapter.kind === "decisions" ? decideCalibrated(adapter, model, request, started) : decideEmulated(model, request, started);
|
|
1678
1642
|
},
|
|
1679
|
-
// ─── Low-level: token counting (heuristic) ───────────────
|
|
1680
1643
|
count: async (input) => {
|
|
1681
1644
|
const CHARS_PER_TOKEN2 = 4;
|
|
1682
1645
|
if (typeof input === "string") {
|
|
@@ -1784,8 +1747,7 @@ var resolveTransport = (spec, caps) => {
|
|
|
1784
1747
|
responseMode: spec.responseMode,
|
|
1785
1748
|
responseFormat: {
|
|
1786
1749
|
type: "json_schema",
|
|
1787
|
-
//
|
|
1788
|
-
// keywords; non-strict still constrains and never hard-fails.
|
|
1750
|
+
// Strict mode rejects open records and several keywords; non-strict still constrains.
|
|
1789
1751
|
jsonSchema: { name: "envelope", strict: false, schema: serialized }
|
|
1790
1752
|
},
|
|
1791
1753
|
injectSchemaDoc: injectSchemaDoc2,
|
|
@@ -1821,6 +1783,6 @@ var resolveTransport = (spec, caps) => {
|
|
|
1821
1783
|
// src/types.ts
|
|
1822
1784
|
var REASONING_EFFORTS = ["none", "default", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
1823
1785
|
|
|
1824
|
-
export { ErrorCode, REASONING_EFFORTS, RESPOND_TOOL_NAME, SignalError, UNMEASURED_MODEL, chatProviderEntry, closeTruncated, createSignal, decodeJsonish, deepDecodeJsonish, defineTool, extractJson, isTruncatedJson, modelEntry, modelKey, modelRegistry, providerRegistry, repairEscapeDamage, resolveTransport, routeRejection, routeResponse };
|
|
1786
|
+
export { ErrorCode, REASONING_EFFORTS, RESPOND_TOOL_NAME, SignalError, UNMEASURED_MODEL, chatProviderEntry, closeTruncated, createSignal, decodeJsonish, deepDecodeJsonish, defineTool, extractJson, isTruncatedJson, modelDefaults, modelEntry, modelKey, modelRegistry, providerRegistry, repairEscapeDamage, resolveTransport, routeRejection, routeResponse };
|
|
1825
1787
|
//# sourceMappingURL=index.js.map
|
|
1826
1788
|
//# sourceMappingURL=index.js.map
|