@elevasis/sdk 1.39.0 → 1.41.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/dist/cli.cjs +10 -26
- package/dist/index.d.ts +200 -8
- package/dist/index.js +9 -25
- package/dist/node/index.d.ts +180 -8
- package/dist/test-utils/index.d.ts +200 -8
- package/dist/test-utils/index.js +360 -179
- package/dist/types/worker/adapters/llm.d.ts +1 -1
- package/dist/worker/index.js +361 -180
- package/package.json +4 -4
- package/reference/claude-config/hooks/scaffold-registry-reminder.mjs +187 -188
- package/reference/claude-config/sync-notes/2026-07-24-claude-5-models-and-session-surface-fixes.md +116 -0
- package/reference/claude-config/sync-notes/2026-07-27-agent-strict-output-and-turn-drift.md +73 -0
- package/reference/index.mdx +1 -1
- package/reference/packages/core/src/business/README.md +52 -52
- package/reference/rules/frontend.md +1 -1
- package/reference/rules/package-taxonomy.md +1 -1
- package/reference/rules/platform.md +3 -3
- package/reference/scaffold/operations/scaffold-maintenance.md +112 -112
- package/reference/scaffold/operations/workflow-recipes.md +525 -525
- package/reference/scaffold/recipes/customize-crm-actions.md +391 -391
- package/reference/scaffold/recipes/extend-crm.md +4 -4
- package/reference/scaffold/recipes/extend-lead-gen.md +4 -4
- package/reference/scaffold/reference/glossary.md +1 -1
- package/reference/scaffold/ui/customization.md +243 -243
- package/reference/sdk/platform-tools/index.mdx +1 -1
- package/reference/sdk/platform-tools/type-safety.mdx +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -41214,12 +41214,7 @@ var GoogleConfigSchema = external_exports.object({
|
|
|
41214
41214
|
});
|
|
41215
41215
|
var AnthropicOptionsSchema = external_exports.object({}).strict();
|
|
41216
41216
|
var AnthropicStandardConfigSchema = external_exports.object({
|
|
41217
|
-
model: external_exports.enum([
|
|
41218
|
-
"claude-sonnet-4-6",
|
|
41219
|
-
"claude-haiku-4-5-20251001",
|
|
41220
|
-
"claude-haiku-4-5",
|
|
41221
|
-
"claude-sonnet-4-5"
|
|
41222
|
-
]),
|
|
41217
|
+
model: external_exports.enum(["claude-haiku-4-5-20251001", "claude-haiku-4-5"]),
|
|
41223
41218
|
provider: external_exports.literal("anthropic"),
|
|
41224
41219
|
apiKey: external_exports.string(),
|
|
41225
41220
|
temperature: external_exports.number().min(0).max(1).optional(),
|
|
@@ -41228,8 +41223,8 @@ var AnthropicStandardConfigSchema = external_exports.object({
|
|
|
41228
41223
|
topP: external_exports.number().min(0).max(1).optional(),
|
|
41229
41224
|
modelOptions: AnthropicOptionsSchema.optional()
|
|
41230
41225
|
});
|
|
41231
|
-
var
|
|
41232
|
-
model: external_exports.
|
|
41226
|
+
var AnthropicClaude5ConfigSchema = external_exports.object({
|
|
41227
|
+
model: external_exports.enum(["claude-opus-5", "claude-sonnet-5"]),
|
|
41233
41228
|
provider: external_exports.literal("anthropic"),
|
|
41234
41229
|
apiKey: external_exports.string(),
|
|
41235
41230
|
temperature: external_exports.literal(1).optional(),
|
|
@@ -41241,7 +41236,7 @@ var AnthropicOpus48ConfigSchema = external_exports.object({
|
|
|
41241
41236
|
modelOptions: AnthropicOptionsSchema.optional()
|
|
41242
41237
|
});
|
|
41243
41238
|
var AnthropicConfigSchema = external_exports.discriminatedUnion("model", [
|
|
41244
|
-
|
|
41239
|
+
AnthropicClaude5ConfigSchema,
|
|
41245
41240
|
AnthropicStandardConfigSchema
|
|
41246
41241
|
]);
|
|
41247
41242
|
var MODEL_INFO = {
|
|
@@ -41336,7 +41331,7 @@ var MODEL_INFO = {
|
|
|
41336
41331
|
configSchema: GoogleConfigSchema
|
|
41337
41332
|
},
|
|
41338
41333
|
// Anthropic Claude Models (direct SDK access via @anthropic-ai/sdk)
|
|
41339
|
-
"claude-opus-
|
|
41334
|
+
"claude-opus-5": {
|
|
41340
41335
|
inputCostPer1M: 500,
|
|
41341
41336
|
// $5.00 per 1M tokens
|
|
41342
41337
|
outputCostPer1M: 2500,
|
|
@@ -41349,7 +41344,9 @@ var MODEL_INFO = {
|
|
|
41349
41344
|
category: "reasoning",
|
|
41350
41345
|
configSchema: AnthropicConfigSchema
|
|
41351
41346
|
},
|
|
41352
|
-
"claude-sonnet-
|
|
41347
|
+
"claude-sonnet-5": {
|
|
41348
|
+
// List pricing. An introductory rate of $2.00/$10.00 runs through 2026-08-31; encoding the
|
|
41349
|
+
// temporary rate would make historical cost analytics wrong once it lapses.
|
|
41353
41350
|
inputCostPer1M: 300,
|
|
41354
41351
|
// $3.00 per 1M tokens
|
|
41355
41352
|
outputCostPer1M: 1500,
|
|
@@ -41358,7 +41355,7 @@ var MODEL_INFO = {
|
|
|
41358
41355
|
recommendedTokens: 8e3,
|
|
41359
41356
|
maxTokens: 1e6,
|
|
41360
41357
|
// 1M context window
|
|
41361
|
-
maxOutputTokens:
|
|
41358
|
+
maxOutputTokens: 128e3,
|
|
41362
41359
|
category: "standard",
|
|
41363
41360
|
configSchema: AnthropicConfigSchema
|
|
41364
41361
|
},
|
|
@@ -41387,19 +41384,6 @@ var MODEL_INFO = {
|
|
|
41387
41384
|
maxOutputTokens: 64e3,
|
|
41388
41385
|
category: "standard",
|
|
41389
41386
|
configSchema: AnthropicConfigSchema
|
|
41390
|
-
},
|
|
41391
|
-
"claude-sonnet-4-5": {
|
|
41392
|
-
inputCostPer1M: 300,
|
|
41393
|
-
// $3.00 per 1M tokens
|
|
41394
|
-
outputCostPer1M: 1500,
|
|
41395
|
-
// $15.00 per 1M tokens
|
|
41396
|
-
minTokens: 4e3,
|
|
41397
|
-
recommendedTokens: 8e3,
|
|
41398
|
-
maxTokens: 2e5,
|
|
41399
|
-
// 200k context window
|
|
41400
|
-
maxOutputTokens: 64e3,
|
|
41401
|
-
category: "standard",
|
|
41402
|
-
configSchema: AnthropicConfigSchema
|
|
41403
41387
|
}
|
|
41404
41388
|
};
|
|
41405
41389
|
function getModelInfo(model) {
|
|
@@ -45850,7 +45834,7 @@ function wrapAction(commandName, fn) {
|
|
|
45850
45834
|
// package.json
|
|
45851
45835
|
var package_default = {
|
|
45852
45836
|
name: "@elevasis/sdk",
|
|
45853
|
-
version: "1.
|
|
45837
|
+
version: "1.41.0",
|
|
45854
45838
|
description: "SDK for building Elevasis organization resources",
|
|
45855
45839
|
type: "module",
|
|
45856
45840
|
bin: {
|
package/dist/index.d.ts
CHANGED
|
@@ -426,7 +426,7 @@ type GoogleModel = 'gemini-3-flash-preview' | 'gemini-3.1-flash-lite-preview';
|
|
|
426
426
|
/**
|
|
427
427
|
* Supported Anthropic models (direct SDK access via @anthropic-ai/sdk)
|
|
428
428
|
*/
|
|
429
|
-
type AnthropicModel = 'claude-opus-
|
|
429
|
+
type AnthropicModel = 'claude-opus-5' | 'claude-sonnet-5' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5';
|
|
430
430
|
/** Supported LLM models */
|
|
431
431
|
type LLMModel = OpenAIModel | OpenRouterModel | GoogleModel | AnthropicModel | 'mock';
|
|
432
432
|
/**
|
|
@@ -1062,6 +1062,20 @@ interface LLMGenerateResponse<T = unknown> {
|
|
|
1062
1062
|
totalTokens: number;
|
|
1063
1063
|
};
|
|
1064
1064
|
cost?: number;
|
|
1065
|
+
/**
|
|
1066
|
+
* Why this call went out WITHOUT `strict`, on an adapter that tried to send it with one.
|
|
1067
|
+
*
|
|
1068
|
+
* Present only on a refusal, so absence means either "strict was in effect" or "this adapter
|
|
1069
|
+
* does not attempt strict at all" — the two are distinguished by which adapter answered, not by
|
|
1070
|
+
* this field. `toStrictSchema` already computes these reasons and, until now, nothing consumed
|
|
1071
|
+
* them at the call site: an unstrict call was indistinguishable from a strict one anywhere
|
|
1072
|
+
* outside a dev-only flow log. That invisibility is what let every tenant run unstrict against a
|
|
1073
|
+
* strict-capable API for as long as it took someone to recognise a pre-strict error signature.
|
|
1074
|
+
*
|
|
1075
|
+
* Internal-only, like `usage` — `UniversalLLMAdapter` lifts it onto the `ai_calls` row and
|
|
1076
|
+
* strips it before the response reaches callers.
|
|
1077
|
+
*/
|
|
1078
|
+
strictRefusalReasons?: string[];
|
|
1065
1079
|
}
|
|
1066
1080
|
/**
|
|
1067
1081
|
* LLM Adapter interface
|
|
@@ -1093,6 +1107,14 @@ interface LLMAdapter {
|
|
|
1093
1107
|
* Memory types mirror action types for clarity and filtering
|
|
1094
1108
|
*/
|
|
1095
1109
|
type MemoryEntryType = 'context' | 'input' | 'reasoning' | 'tool-result' | 'delegation-result' | 'error';
|
|
1110
|
+
/**
|
|
1111
|
+
* Who authored an entry's content.
|
|
1112
|
+
*
|
|
1113
|
+
* This is what lets the assembled prompt tell framework-authored text apart from text that
|
|
1114
|
+
* originated outside the trust boundary. `'framework'` content is ours; the other three are not
|
|
1115
|
+
* and are rendered inside the JSON data envelope (see `MemoryManager.toContextParts`).
|
|
1116
|
+
*/
|
|
1117
|
+
type MemoryEntrySource = 'framework' | 'user' | 'tool' | 'model';
|
|
1096
1118
|
/**
|
|
1097
1119
|
* Memory entry - represents a single entry in agent memory
|
|
1098
1120
|
* Stored in agent memory, translated by adapters to vendor-specific formats
|
|
@@ -1103,6 +1125,16 @@ interface MemoryEntry {
|
|
|
1103
1125
|
timestamp: number;
|
|
1104
1126
|
turnNumber: number | null;
|
|
1105
1127
|
iterationNumber: number | null;
|
|
1128
|
+
/**
|
|
1129
|
+
* Provenance. **Optional on purpose** — `undefined` means unknown, which is what every
|
|
1130
|
+
* pre-existing snapshot and every not-yet-redeployed tenant bundle produces. Read sites MUST
|
|
1131
|
+
* test `== null`, never `=== undefined`: the `inTurnScope` predicate in `manager.ts` is the
|
|
1132
|
+
* cautionary precedent, where a `=== undefined` check silently dropped every `null`-stamped
|
|
1133
|
+
* entry. `isMemoryEntry` is deliberately NOT tightened to require this field; doing so would
|
|
1134
|
+
* make every stored snapshot fail validation, and `restoreSessionMemory` fails open by
|
|
1135
|
+
* starting the agent with empty memory rather than throwing.
|
|
1136
|
+
*/
|
|
1137
|
+
source?: MemoryEntrySource;
|
|
1106
1138
|
}
|
|
1107
1139
|
/**
|
|
1108
1140
|
* Agent memory - Self-orchestrated memory with session + working storage
|
|
@@ -1130,8 +1162,17 @@ interface MemoryStatus {
|
|
|
1130
1162
|
sessionMemoryKeys: number;
|
|
1131
1163
|
sessionMemoryLimit: number;
|
|
1132
1164
|
currentKeys: string[];
|
|
1165
|
+
sessionMemoryTokens: number;
|
|
1166
|
+
sessionMemoryTokenLimit: number;
|
|
1167
|
+
/**
|
|
1168
|
+
* History tokens as a percentage of `historyBudget` — history ALONE, not history plus session
|
|
1169
|
+
* memory. It previously reported the combined total under this name, so session memory growth
|
|
1170
|
+
* read as history pressure and triggered history compaction that could not relieve it.
|
|
1171
|
+
*/
|
|
1133
1172
|
historyPercent: number;
|
|
1134
1173
|
historyTokens: number;
|
|
1174
|
+
historyBudget: number;
|
|
1175
|
+
totalTokens: number;
|
|
1135
1176
|
tokenBudget: number;
|
|
1136
1177
|
}
|
|
1137
1178
|
/**
|
|
@@ -1148,6 +1189,20 @@ interface MemoryConstraints {
|
|
|
1148
1189
|
* Agent provides strings, framework handles wrapping and auto-compaction
|
|
1149
1190
|
*/
|
|
1150
1191
|
|
|
1192
|
+
/**
|
|
1193
|
+
* The framework's own framing message and the untrusted data envelope, as separate strings.
|
|
1194
|
+
*
|
|
1195
|
+
* They are separate because the model must be able to tell them apart, and so must the input
|
|
1196
|
+
* sanitizer: the framing is framework-authored and trusted, the envelope is not. Concatenating
|
|
1197
|
+
* them — which is what this replaced — made that distinction undecidable at the adapter and left
|
|
1198
|
+
* the framework's own section headers inside the region scanned for delimiter injection.
|
|
1199
|
+
*/
|
|
1200
|
+
interface MemoryContextParts {
|
|
1201
|
+
/** Framework-authored. Memory status and a description of the envelope. Carries NO stored content. */
|
|
1202
|
+
framing: string;
|
|
1203
|
+
/** Every stored fragment, JSON-encoded and source-tagged. Untrusted. */
|
|
1204
|
+
dataEnvelope: string;
|
|
1205
|
+
}
|
|
1151
1206
|
/**
|
|
1152
1207
|
* Memory Manager - Agent memory orchestration
|
|
1153
1208
|
* Provides ultra-simple API for agents (strings only)
|
|
@@ -1164,7 +1219,7 @@ declare class MemoryManager {
|
|
|
1164
1219
|
* @param key - Session memory key
|
|
1165
1220
|
* @param content - String content from agent
|
|
1166
1221
|
*/
|
|
1167
|
-
set(key: string, content: string): void;
|
|
1222
|
+
set(key: string, content: string, source?: MemoryEntrySource): void;
|
|
1168
1223
|
/**
|
|
1169
1224
|
* Get session memory entry content
|
|
1170
1225
|
* @param key - Session memory key
|
|
@@ -1193,6 +1248,15 @@ declare class MemoryManager {
|
|
|
1193
1248
|
* Emergency fallback if agent exceeds limits
|
|
1194
1249
|
*/
|
|
1195
1250
|
enforceHardLimits(): void;
|
|
1251
|
+
/**
|
|
1252
|
+
* Evict oldest session memory entries until the pool fits its token limit.
|
|
1253
|
+
*
|
|
1254
|
+
* Key count and token count are different constraints: 25 short keys are fine, 25 large ones
|
|
1255
|
+
* are not. Eviction is oldest-first by timestamp, matching the key-count path, and always
|
|
1256
|
+
* leaves at least one entry so a single oversized key degrades to "one key" rather than to
|
|
1257
|
+
* "memory silently emptied".
|
|
1258
|
+
*/
|
|
1259
|
+
private enforceSessionMemoryTokenLimit;
|
|
1196
1260
|
/**
|
|
1197
1261
|
* Get history length (for logging and introspection)
|
|
1198
1262
|
* @returns Number of entries in history
|
|
@@ -1216,14 +1280,29 @@ declare class MemoryManager {
|
|
|
1216
1280
|
*/
|
|
1217
1281
|
getSnapshot(): AgentMemory | undefined;
|
|
1218
1282
|
/**
|
|
1219
|
-
* Build
|
|
1220
|
-
*
|
|
1221
|
-
*
|
|
1283
|
+
* Build the framework framing and the untrusted data envelope for an LLM call.
|
|
1284
|
+
*
|
|
1285
|
+
* These are two separate strings because they are two different trust levels, and they used to
|
|
1286
|
+
* be one. Concatenated, the framework's own `=== ... ===` section headers sat in the same string
|
|
1287
|
+
* as stored tool output and user text, so the input sanitizer matched its own scaffolding on
|
|
1288
|
+
* every call and nothing downstream could tell which half a match came from. Splitting them
|
|
1289
|
+
* makes that distinction structural: the framing is ours, the envelope is not.
|
|
1290
|
+
*
|
|
1291
|
+
* The envelope is JSON, which additionally neutralizes the anchored-delimiter attack class —
|
|
1292
|
+
* `JSON.stringify` escapes newlines, so a stored fragment cannot produce a line that starts
|
|
1293
|
+
* with `===` no matter what it contains.
|
|
1294
|
+
*
|
|
1295
|
+
* The current turn's own input is deliberately NOT in either string. It travels as its own
|
|
1296
|
+
* `role:'user'` message (see `buildAgentMessages`), which is the whole point: a model asked to
|
|
1297
|
+
* treat "everything in this block" as data was also being handed the live question inside that
|
|
1298
|
+
* block.
|
|
1299
|
+
*
|
|
1300
|
+
* Shows current iteration entries FIRST (reverse chronological) for LLM attention.
|
|
1301
|
+
*
|
|
1222
1302
|
* @param currentIteration - Current iteration number (0 = pre-iteration)
|
|
1223
1303
|
* @param currentTurn - Current turn number (optional, for session context filtering)
|
|
1224
|
-
* @returns Formatted memory context for LLM prompt
|
|
1225
1304
|
*/
|
|
1226
|
-
|
|
1305
|
+
toContextParts(currentIteration: number, currentTurn?: number): MemoryContextParts;
|
|
1227
1306
|
}
|
|
1228
1307
|
|
|
1229
1308
|
/**
|
|
@@ -1345,7 +1424,7 @@ interface AgentConfig extends ResourceDefinition {
|
|
|
1345
1424
|
* Security level for system prompt hardening (auto-derived if omitted)
|
|
1346
1425
|
*
|
|
1347
1426
|
* - 'standard': Lightweight defense (3 rules) - default for non-session agents
|
|
1348
|
-
* - 'hardened': Comprehensive defense (
|
|
1427
|
+
* - 'hardened': Comprehensive defense (5 rules) - default for session-capable agents
|
|
1349
1428
|
* - 'none': No security prompt - for pure internal agents with no external input
|
|
1350
1429
|
*
|
|
1351
1430
|
* If omitted, derived from sessionCapable:
|
|
@@ -1422,6 +1501,12 @@ interface IterationContext {
|
|
|
1422
1501
|
modelConfig: ModelConfig;
|
|
1423
1502
|
adapterFactory: LLMAdapterFactory;
|
|
1424
1503
|
knowledgeMap?: KnowledgeMap;
|
|
1504
|
+
/**
|
|
1505
|
+
* The validated input for this execution, serialized. It travels here because the model gets
|
|
1506
|
+
* it as its own `role:'user'` message; nothing else in this context carried it, so the input
|
|
1507
|
+
* had to be read back out of memory history and shipped inside the memory block.
|
|
1508
|
+
*/
|
|
1509
|
+
currentInput: string;
|
|
1425
1510
|
}
|
|
1426
1511
|
|
|
1427
1512
|
type Json = string | number | boolean | null | {
|
|
@@ -4168,6 +4253,7 @@ type Database = {
|
|
|
4168
4253
|
deleted_at: string | null;
|
|
4169
4254
|
ended_at: string | null;
|
|
4170
4255
|
memory_snapshot: Json;
|
|
4256
|
+
memory_version: number;
|
|
4171
4257
|
metadata: Json | null;
|
|
4172
4258
|
organization_id: string;
|
|
4173
4259
|
resource_id: string;
|
|
@@ -4184,6 +4270,7 @@ type Database = {
|
|
|
4184
4270
|
deleted_at?: string | null;
|
|
4185
4271
|
ended_at?: string | null;
|
|
4186
4272
|
memory_snapshot: Json;
|
|
4273
|
+
memory_version?: number;
|
|
4187
4274
|
metadata?: Json | null;
|
|
4188
4275
|
organization_id: string;
|
|
4189
4276
|
resource_id: string;
|
|
@@ -4200,6 +4287,7 @@ type Database = {
|
|
|
4200
4287
|
deleted_at?: string | null;
|
|
4201
4288
|
ended_at?: string | null;
|
|
4202
4289
|
memory_snapshot?: Json;
|
|
4290
|
+
memory_version?: number;
|
|
4203
4291
|
metadata?: Json | null;
|
|
4204
4292
|
organization_id?: string;
|
|
4205
4293
|
resource_id?: string;
|
|
@@ -4537,9 +4625,14 @@ type Database = {
|
|
|
4537
4625
|
p_session_id: string;
|
|
4538
4626
|
};
|
|
4539
4627
|
Returns: {
|
|
4628
|
+
context_window_size: number;
|
|
4540
4629
|
created_at: string;
|
|
4630
|
+
cumulative_input_tokens: number;
|
|
4631
|
+
cumulative_output_tokens: number;
|
|
4632
|
+
deleted_at: string;
|
|
4541
4633
|
ended_at: string;
|
|
4542
4634
|
memory_snapshot: Json;
|
|
4635
|
+
memory_version: number;
|
|
4543
4636
|
metadata: Json;
|
|
4544
4637
|
organization_id: string;
|
|
4545
4638
|
resource_id: string;
|
|
@@ -4581,6 +4674,18 @@ type Database = {
|
|
|
4581
4674
|
};
|
|
4582
4675
|
Returns: boolean;
|
|
4583
4676
|
};
|
|
4677
|
+
increment_session_tokens: {
|
|
4678
|
+
Args: {
|
|
4679
|
+
p_input_tokens: number;
|
|
4680
|
+
p_output_tokens: number;
|
|
4681
|
+
p_session_id: string;
|
|
4682
|
+
};
|
|
4683
|
+
Returns: {
|
|
4684
|
+
context_window_size: number;
|
|
4685
|
+
cumulative_input_tokens: number;
|
|
4686
|
+
cumulative_output_tokens: number;
|
|
4687
|
+
}[];
|
|
4688
|
+
};
|
|
4584
4689
|
is_org_member: {
|
|
4585
4690
|
Args: {
|
|
4586
4691
|
org_id: string;
|
|
@@ -11072,6 +11177,25 @@ declare class MetricsCollector {
|
|
|
11072
11177
|
buildExecutionMetrics(metricsConfig?: ResourceMetricsConfig): ExecutionMetricsSummary;
|
|
11073
11178
|
}
|
|
11074
11179
|
|
|
11180
|
+
/**
|
|
11181
|
+
* Which `role:'user'` message slot a sanitizer warning came from, derived from the request's
|
|
11182
|
+
* message array (no new plumbing from callers):
|
|
11183
|
+
* - `'memory-context'` — the framework's framing message, identified by the `=== MEMORY STATUS ===`
|
|
11184
|
+
* banner. Framework-authored and trusted; it is no longer scanned at all, so this source should
|
|
11185
|
+
* not appear for agent calls. Retained because stale tenant bundles still emit the old combined
|
|
11186
|
+
* block, and their rows must stay readable.
|
|
11187
|
+
* - `'data-envelope'` — the JSON envelope carrying every stored fragment. Untrusted, and the slot
|
|
11188
|
+
* where a match is genuine signal.
|
|
11189
|
+
* - `'input'` — the turn's own input, on its own message. Also untrusted.
|
|
11190
|
+
* - `'history'` — replayed prior turns. Untrusted, but already screened at their own front door,
|
|
11191
|
+
* so warnings here are recorded and never block (see `screenInput`).
|
|
11192
|
+
*/
|
|
11193
|
+
type InputWarningSource = 'memory-context' | 'data-envelope' | 'history' | 'input';
|
|
11194
|
+
/** Per-source breakdown of sanitizer warnings, so a memory-context echo is distinguishable from a genuine hit. */
|
|
11195
|
+
interface SourcedInputWarnings {
|
|
11196
|
+
source: InputWarningSource;
|
|
11197
|
+
warnings: string[];
|
|
11198
|
+
}
|
|
11075
11199
|
interface BaseAICall {
|
|
11076
11200
|
callSequence: number;
|
|
11077
11201
|
callType: 'agent-reasoning' | 'agent-completion' | 'workflow-step' | 'tool' | 'other';
|
|
@@ -11081,6 +11205,62 @@ interface BaseAICall {
|
|
|
11081
11205
|
costUsd: number;
|
|
11082
11206
|
latencyMs: number;
|
|
11083
11207
|
context?: AICallContext;
|
|
11208
|
+
/**
|
|
11209
|
+
* Distinct prompt-injection pattern types detected in the request's user-role messages.
|
|
11210
|
+
* Present only when the input sanitizer matched something. Non-blocking matches ride along on
|
|
11211
|
+
* the successful call's row; a blocked call records a row of its own (see `inputBlocked`).
|
|
11212
|
+
*
|
|
11213
|
+
* Flat union across all `role:'user'` messages — unchanged shape, kept for existing readers.
|
|
11214
|
+
* See `inputWarningsBySource` for the per-slot breakdown.
|
|
11215
|
+
*/
|
|
11216
|
+
inputWarnings?: string[];
|
|
11217
|
+
/**
|
|
11218
|
+
* Additive breakdown of `inputWarnings` by message slot (see `InputWarningSource`). Present only
|
|
11219
|
+
* when at least one source produced a warning. Existing readers that only look at the flat
|
|
11220
|
+
* `inputWarnings` array are unaffected.
|
|
11221
|
+
*/
|
|
11222
|
+
inputWarningsBySource?: SourcedInputWarnings[];
|
|
11223
|
+
/**
|
|
11224
|
+
* True when the sanitizer blocked the request and no provider call was made.
|
|
11225
|
+
* Such a row carries zero tokens, zero cost, and zero latency — it exists so a hard,
|
|
11226
|
+
* user-visible failure is observable at all. Before this, a blocked call produced no row.
|
|
11227
|
+
*/
|
|
11228
|
+
inputBlocked?: boolean;
|
|
11229
|
+
/**
|
|
11230
|
+
* The validator's message when the provider responded but its output failed `responseSchema`
|
|
11231
|
+
* validation (e.g. `missing required field 'nextActions'`). Present only on such a row.
|
|
11232
|
+
*
|
|
11233
|
+
* This is NOT the blocked-input case: the provider DID respond and tokens WERE spent, so the row
|
|
11234
|
+
* carries real `inputTokens`, `outputTokens`, cost and latency. It is a paid call that produced
|
|
11235
|
+
* nothing usable, and before this it produced no row at all.
|
|
11236
|
+
*
|
|
11237
|
+
* One row per failed attempt — the adapter retries a validation failure up to `LLM_MAX_ATTEMPTS`,
|
|
11238
|
+
* so a turn that exhausts its retries records three. Reading `inputTokens` across these rows is
|
|
11239
|
+
* what measures malformed-output rate against context size rather than inferring it.
|
|
11240
|
+
*
|
|
11241
|
+
* Existing readers that only look at the fields above are unaffected.
|
|
11242
|
+
*/
|
|
11243
|
+
outputValidationError?: string;
|
|
11244
|
+
/**
|
|
11245
|
+
* The raw model output that failed validation, JSON-stringified and truncated to a bounded
|
|
11246
|
+
* length. Truncation is visible in the value itself (a trailing `…[truncated: N chars total]`),
|
|
11247
|
+
* never silent. Present only alongside `outputValidationError`.
|
|
11248
|
+
*/
|
|
11249
|
+
unvalidatedOutput?: string;
|
|
11250
|
+
/**
|
|
11251
|
+
* Why this call went out without `strict` structured output, on an adapter that tried to send it
|
|
11252
|
+
* with one. Present ONLY on a refusal — its absence on a row from a strict-capable adapter means
|
|
11253
|
+
* strict was in effect.
|
|
11254
|
+
*
|
|
11255
|
+
* This is the row that answers "is this agent's output actually being enforced?" without reading
|
|
11256
|
+
* source. Counting rows that carry it, per resource, is the refusal count: a redeployed agent on
|
|
11257
|
+
* a current bundle should read zero. It exists because the previous answer was a dev-only flow
|
|
11258
|
+
* log, which meant production had no answer — and every sync-managed tenant ran unstrict against
|
|
11259
|
+
* a strict-capable API until a 14-turn session surfaced a pre-strict error signature.
|
|
11260
|
+
*
|
|
11261
|
+
* Existing readers that only look at the fields above are unaffected.
|
|
11262
|
+
*/
|
|
11263
|
+
strictRefusalReasons?: string[];
|
|
11084
11264
|
}
|
|
11085
11265
|
type AICallContext = AgentReasoningContext | AgentCompletionContext | WorkflowStepContext | ToolCallContext | OtherCallContext;
|
|
11086
11266
|
interface AgentReasoningContext {
|
|
@@ -11126,6 +11306,18 @@ interface LLMUsageData {
|
|
|
11126
11306
|
latencyMs: number;
|
|
11127
11307
|
/** Actual cost from provider in USD (when available, e.g., OpenRouter) */
|
|
11128
11308
|
cost?: number;
|
|
11309
|
+
/** Distinct prompt-injection pattern types detected in the request's user-role messages */
|
|
11310
|
+
inputWarnings?: string[];
|
|
11311
|
+
/** Additive per-source breakdown of `inputWarnings` — see `SourcedInputWarnings` */
|
|
11312
|
+
inputWarningsBySource?: SourcedInputWarnings[];
|
|
11313
|
+
/** True when the sanitizer blocked the request and no provider call was made */
|
|
11314
|
+
inputBlocked?: boolean;
|
|
11315
|
+
/** Validator message when the provider responded but the output failed `responseSchema` validation */
|
|
11316
|
+
outputValidationError?: string;
|
|
11317
|
+
/** Raw model output that failed validation — JSON-stringified, truncated, truncation marked inline */
|
|
11318
|
+
unvalidatedOutput?: string;
|
|
11319
|
+
/** Why the call went out unstrict, when a strict-capable adapter refused the schema */
|
|
11320
|
+
strictRefusalReasons?: string[];
|
|
11129
11321
|
}
|
|
11130
11322
|
interface AIUsageSummary {
|
|
11131
11323
|
model: LLMModel;
|
package/dist/index.js
CHANGED
|
@@ -1472,12 +1472,7 @@ var GoogleConfigSchema = z.object({
|
|
|
1472
1472
|
});
|
|
1473
1473
|
var AnthropicOptionsSchema = z.object({}).strict();
|
|
1474
1474
|
var AnthropicStandardConfigSchema = z.object({
|
|
1475
|
-
model: z.enum([
|
|
1476
|
-
"claude-sonnet-4-6",
|
|
1477
|
-
"claude-haiku-4-5-20251001",
|
|
1478
|
-
"claude-haiku-4-5",
|
|
1479
|
-
"claude-sonnet-4-5"
|
|
1480
|
-
]),
|
|
1475
|
+
model: z.enum(["claude-haiku-4-5-20251001", "claude-haiku-4-5"]),
|
|
1481
1476
|
provider: z.literal("anthropic"),
|
|
1482
1477
|
apiKey: z.string(),
|
|
1483
1478
|
temperature: z.number().min(0).max(1).optional(),
|
|
@@ -1486,8 +1481,8 @@ var AnthropicStandardConfigSchema = z.object({
|
|
|
1486
1481
|
topP: z.number().min(0).max(1).optional(),
|
|
1487
1482
|
modelOptions: AnthropicOptionsSchema.optional()
|
|
1488
1483
|
});
|
|
1489
|
-
var
|
|
1490
|
-
model: z.
|
|
1484
|
+
var AnthropicClaude5ConfigSchema = z.object({
|
|
1485
|
+
model: z.enum(["claude-opus-5", "claude-sonnet-5"]),
|
|
1491
1486
|
provider: z.literal("anthropic"),
|
|
1492
1487
|
apiKey: z.string(),
|
|
1493
1488
|
temperature: z.literal(1).optional(),
|
|
@@ -1499,7 +1494,7 @@ var AnthropicOpus48ConfigSchema = z.object({
|
|
|
1499
1494
|
modelOptions: AnthropicOptionsSchema.optional()
|
|
1500
1495
|
});
|
|
1501
1496
|
var AnthropicConfigSchema = z.discriminatedUnion("model", [
|
|
1502
|
-
|
|
1497
|
+
AnthropicClaude5ConfigSchema,
|
|
1503
1498
|
AnthropicStandardConfigSchema
|
|
1504
1499
|
]);
|
|
1505
1500
|
var MODEL_INFO = {
|
|
@@ -1594,7 +1589,7 @@ var MODEL_INFO = {
|
|
|
1594
1589
|
configSchema: GoogleConfigSchema
|
|
1595
1590
|
},
|
|
1596
1591
|
// Anthropic Claude Models (direct SDK access via @anthropic-ai/sdk)
|
|
1597
|
-
"claude-opus-
|
|
1592
|
+
"claude-opus-5": {
|
|
1598
1593
|
inputCostPer1M: 500,
|
|
1599
1594
|
// $5.00 per 1M tokens
|
|
1600
1595
|
outputCostPer1M: 2500,
|
|
@@ -1607,7 +1602,9 @@ var MODEL_INFO = {
|
|
|
1607
1602
|
category: "reasoning",
|
|
1608
1603
|
configSchema: AnthropicConfigSchema
|
|
1609
1604
|
},
|
|
1610
|
-
"claude-sonnet-
|
|
1605
|
+
"claude-sonnet-5": {
|
|
1606
|
+
// List pricing. An introductory rate of $2.00/$10.00 runs through 2026-08-31; encoding the
|
|
1607
|
+
// temporary rate would make historical cost analytics wrong once it lapses.
|
|
1611
1608
|
inputCostPer1M: 300,
|
|
1612
1609
|
// $3.00 per 1M tokens
|
|
1613
1610
|
outputCostPer1M: 1500,
|
|
@@ -1616,7 +1613,7 @@ var MODEL_INFO = {
|
|
|
1616
1613
|
recommendedTokens: 8e3,
|
|
1617
1614
|
maxTokens: 1e6,
|
|
1618
1615
|
// 1M context window
|
|
1619
|
-
maxOutputTokens:
|
|
1616
|
+
maxOutputTokens: 128e3,
|
|
1620
1617
|
category: "standard",
|
|
1621
1618
|
configSchema: AnthropicConfigSchema
|
|
1622
1619
|
},
|
|
@@ -1645,19 +1642,6 @@ var MODEL_INFO = {
|
|
|
1645
1642
|
maxOutputTokens: 64e3,
|
|
1646
1643
|
category: "standard",
|
|
1647
1644
|
configSchema: AnthropicConfigSchema
|
|
1648
|
-
},
|
|
1649
|
-
"claude-sonnet-4-5": {
|
|
1650
|
-
inputCostPer1M: 300,
|
|
1651
|
-
// $3.00 per 1M tokens
|
|
1652
|
-
outputCostPer1M: 1500,
|
|
1653
|
-
// $15.00 per 1M tokens
|
|
1654
|
-
minTokens: 4e3,
|
|
1655
|
-
recommendedTokens: 8e3,
|
|
1656
|
-
maxTokens: 2e5,
|
|
1657
|
-
// 200k context window
|
|
1658
|
-
maxOutputTokens: 64e3,
|
|
1659
|
-
category: "standard",
|
|
1660
|
-
configSchema: AnthropicConfigSchema
|
|
1661
1645
|
}
|
|
1662
1646
|
};
|
|
1663
1647
|
function getModelInfo(model) {
|