@tonyclaw/agent-inspector 2.0.38 → 2.0.40
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/.output/cli.js +528 -24
- package/.output/nitro.json +1 -1
- package/.output/public/assets/{CompareDrawer-hc5OoAls.js → CompareDrawer-p0uYxW7_.js} +1 -1
- package/.output/public/assets/{ProxyViewerContainer-BMKBs8Qz.js → ProxyViewerContainer-BGqeiYKD.js} +26 -26
- package/.output/public/assets/{ReplayDialog-CN-KM2nu.js → ReplayDialog-TTTVCMe9.js} +1 -1
- package/.output/public/assets/{RequestAnatomy-B1kTlAUk.js → RequestAnatomy-c8ru0pS-.js} +1 -1
- package/.output/public/assets/{ResponseView-BchUjKjt.js → ResponseView-D59jTMy4.js} +1 -1
- package/.output/public/assets/{StreamingChunkSequence-BQOxI9Hi.js → StreamingChunkSequence-UlAMVF9j.js} +1 -1
- package/.output/public/assets/_sessionId-EHPexdPl.js +1 -0
- package/.output/public/assets/index-CZP-XfpB.js +1 -0
- package/.output/public/assets/{main-Blykwzsn.js → main-CKYe6UUv.js} +2 -2
- package/.output/server/{_sessionId-BUNZz2zZ.mjs → _sessionId-CkwhOzdS.mjs} +2 -2
- package/.output/server/_ssr/{CompareDrawer-VaDYPM5G.mjs → CompareDrawer-BHDiuYMw.mjs} +2 -2
- package/.output/server/_ssr/{ProxyViewerContainer-CpdWs7Pk.mjs → ProxyViewerContainer-0c2_DBMX.mjs} +57 -6
- package/.output/server/_ssr/{ReplayDialog-DbfIjJhb.mjs → ReplayDialog-CTjwzDDH.mjs} +3 -3
- package/.output/server/_ssr/{RequestAnatomy-CrD8h6As.mjs → RequestAnatomy-D36oujv2.mjs} +2 -2
- package/.output/server/_ssr/{ResponseView-BalvDwtU.mjs → ResponseView-ClZ3oODE.mjs} +2 -2
- package/.output/server/_ssr/{StreamingChunkSequence-RxatDbPV.mjs → StreamingChunkSequence-Ck5l4p1m.mjs} +2 -2
- package/.output/server/_ssr/{index-11qAtV9d.mjs → index-DKBYH0TC.mjs} +2 -2
- package/.output/server/_ssr/index.mjs +2 -2
- package/.output/server/_ssr/{router-C4OdRnqX.mjs → router-D4I3ZyVS.mjs} +434 -6
- package/.output/server/{_tanstack-start-manifest_v-F6bwcl33.mjs → _tanstack-start-manifest_v-D4vSn_wD.mjs} +1 -1
- package/.output/server/index.mjs +54 -54
- package/README.md +7 -0
- package/package.json +1 -1
- package/src/cli/onboard.ts +629 -21
- package/src/components/providers/SettingsDialog.tsx +30 -0
- package/src/components/proxy-viewer/LogEntry.tsx +15 -1
- package/src/components/proxy-viewer/LogEntryHeader.tsx +20 -0
- package/src/contracts/log.ts +1 -0
- package/src/proxy/logFinalizer.ts +58 -0
- package/src/proxy/logSearch.ts +1 -0
- package/src/proxy/toolSchemaWarnings.ts +515 -0
- package/.output/public/assets/_sessionId-CVw5e8TK.js +0 -1
- package/.output/public/assets/index-BdUTMQL6.js +0 -1
|
@@ -93,7 +93,7 @@ function RootDocument({ children }) {
|
|
|
93
93
|
] })
|
|
94
94
|
] });
|
|
95
95
|
}
|
|
96
|
-
const $$splitComponentImporter$1 = () => import("./index-
|
|
96
|
+
const $$splitComponentImporter$1 = () => import("./index-DKBYH0TC.mjs");
|
|
97
97
|
const Route$y = createFileRoute("/")({
|
|
98
98
|
component: lazyRouteComponent($$splitComponentImporter$1, "component")
|
|
99
99
|
});
|
|
@@ -136,7 +136,7 @@ function decodeSessionIdFromPath(encoded) {
|
|
|
136
136
|
function getSessionPath(sessionId) {
|
|
137
137
|
return `/session/${encodeSessionIdForPath(sessionId)}`;
|
|
138
138
|
}
|
|
139
|
-
const $$splitComponentImporter = () => import("../_sessionId-
|
|
139
|
+
const $$splitComponentImporter = () => import("../_sessionId-CkwhOzdS.mjs");
|
|
140
140
|
const Route$x = createFileRoute("/session/$sessionId")({
|
|
141
141
|
component: lazyRouteComponent($$splitComponentImporter, "component"),
|
|
142
142
|
parseParams: (params) => ({
|
|
@@ -407,6 +407,7 @@ const CapturedLogSchema = object({
|
|
|
407
407
|
rawRequestBodyBytes: number().int().nonnegative().nullable().optional(),
|
|
408
408
|
responseTextBytes: number().int().nonnegative().nullable().optional(),
|
|
409
409
|
bodyContentMode: _enum(["full", "compact", "truncated"]).optional(),
|
|
410
|
+
warnings: array(string()).optional(),
|
|
410
411
|
/** Error message from streaming response (e.g., SSE error event) */
|
|
411
412
|
error: string().nullable().optional()
|
|
412
413
|
});
|
|
@@ -4171,6 +4172,394 @@ function firstChunkMsFromChunks(chunks) {
|
|
|
4171
4172
|
if (!Number.isFinite(first.timestamp) || first.timestamp < 0) return null;
|
|
4172
4173
|
return Math.floor(first.timestamp);
|
|
4173
4174
|
}
|
|
4175
|
+
function parseJson(raw) {
|
|
4176
|
+
if (raw === null) return { ok: false };
|
|
4177
|
+
try {
|
|
4178
|
+
return { ok: true, value: JSON.parse(raw) };
|
|
4179
|
+
} catch {
|
|
4180
|
+
return { ok: false };
|
|
4181
|
+
}
|
|
4182
|
+
}
|
|
4183
|
+
function isRecord(value) {
|
|
4184
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4185
|
+
}
|
|
4186
|
+
function readProperty(value, key) {
|
|
4187
|
+
if (!isRecord(value)) return void 0;
|
|
4188
|
+
return Object.getOwnPropertyDescriptor(value, key)?.value;
|
|
4189
|
+
}
|
|
4190
|
+
function hasOwnProperty(value, key) {
|
|
4191
|
+
return Object.getOwnPropertyDescriptor(value, key) !== void 0;
|
|
4192
|
+
}
|
|
4193
|
+
function readString(value, key) {
|
|
4194
|
+
const property = readProperty(value, key);
|
|
4195
|
+
return typeof property === "string" ? property : null;
|
|
4196
|
+
}
|
|
4197
|
+
function readArray(value, key) {
|
|
4198
|
+
const property = readProperty(value, key);
|
|
4199
|
+
return Array.isArray(property) ? property : [];
|
|
4200
|
+
}
|
|
4201
|
+
function readStringArray(value, key) {
|
|
4202
|
+
return readArray(value, key).filter((item) => typeof item === "string");
|
|
4203
|
+
}
|
|
4204
|
+
function readObject(value, key) {
|
|
4205
|
+
const property = readProperty(value, key);
|
|
4206
|
+
return isRecord(property) ? property : null;
|
|
4207
|
+
}
|
|
4208
|
+
function normalizeExpectedType(typeName) {
|
|
4209
|
+
switch (typeName) {
|
|
4210
|
+
case "array":
|
|
4211
|
+
case "boolean":
|
|
4212
|
+
case "integer":
|
|
4213
|
+
case "null":
|
|
4214
|
+
case "number":
|
|
4215
|
+
case "object":
|
|
4216
|
+
case "string":
|
|
4217
|
+
return typeName;
|
|
4218
|
+
default:
|
|
4219
|
+
return null;
|
|
4220
|
+
}
|
|
4221
|
+
}
|
|
4222
|
+
function schemaTypes(schema) {
|
|
4223
|
+
const typeValue = readProperty(schema, "type");
|
|
4224
|
+
const rawTypes = Array.isArray(typeValue) ? typeValue : [typeValue];
|
|
4225
|
+
const types = [];
|
|
4226
|
+
for (const rawType of rawTypes) {
|
|
4227
|
+
if (typeof rawType !== "string") continue;
|
|
4228
|
+
const normalized = normalizeExpectedType(rawType);
|
|
4229
|
+
if (normalized !== null && !types.includes(normalized)) {
|
|
4230
|
+
types.push(normalized);
|
|
4231
|
+
}
|
|
4232
|
+
}
|
|
4233
|
+
return types;
|
|
4234
|
+
}
|
|
4235
|
+
function actualType(value) {
|
|
4236
|
+
if (value === null) return "null";
|
|
4237
|
+
if (Array.isArray(value)) return "array";
|
|
4238
|
+
switch (typeof value) {
|
|
4239
|
+
case "boolean":
|
|
4240
|
+
return "boolean";
|
|
4241
|
+
case "number":
|
|
4242
|
+
return Number.isInteger(value) ? "integer" : "number";
|
|
4243
|
+
case "string":
|
|
4244
|
+
return "string";
|
|
4245
|
+
case "undefined":
|
|
4246
|
+
return "undefined";
|
|
4247
|
+
case "bigint":
|
|
4248
|
+
case "function":
|
|
4249
|
+
case "object":
|
|
4250
|
+
case "symbol":
|
|
4251
|
+
return isRecord(value) ? "object" : "unknown";
|
|
4252
|
+
}
|
|
4253
|
+
return "unknown";
|
|
4254
|
+
}
|
|
4255
|
+
function matchesExpectedType(value, expected) {
|
|
4256
|
+
switch (expected) {
|
|
4257
|
+
case "array":
|
|
4258
|
+
return Array.isArray(value);
|
|
4259
|
+
case "boolean":
|
|
4260
|
+
return typeof value === "boolean";
|
|
4261
|
+
case "integer":
|
|
4262
|
+
return typeof value === "number" && Number.isInteger(value);
|
|
4263
|
+
case "null":
|
|
4264
|
+
return value === null;
|
|
4265
|
+
case "number":
|
|
4266
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
4267
|
+
case "object":
|
|
4268
|
+
return isRecord(value);
|
|
4269
|
+
case "string":
|
|
4270
|
+
return typeof value === "string";
|
|
4271
|
+
}
|
|
4272
|
+
}
|
|
4273
|
+
function matchesAnyExpectedType(value, expectedTypes) {
|
|
4274
|
+
return expectedTypes.some((expected) => matchesExpectedType(value, expected));
|
|
4275
|
+
}
|
|
4276
|
+
function formatExpectedTypes(expectedTypes) {
|
|
4277
|
+
return expectedTypes.join(" or ");
|
|
4278
|
+
}
|
|
4279
|
+
function pathLabel(path2) {
|
|
4280
|
+
return path2 === "" ? "arguments" : `argument "${path2}"`;
|
|
4281
|
+
}
|
|
4282
|
+
function childPath(parent, key) {
|
|
4283
|
+
return parent === "" ? key : `${parent}.${key}`;
|
|
4284
|
+
}
|
|
4285
|
+
function jsonString(value) {
|
|
4286
|
+
try {
|
|
4287
|
+
const serialized = JSON.stringify(value);
|
|
4288
|
+
return serialized === void 0 ? null : serialized;
|
|
4289
|
+
} catch {
|
|
4290
|
+
return null;
|
|
4291
|
+
}
|
|
4292
|
+
}
|
|
4293
|
+
function jsonValuesEqual(left, right) {
|
|
4294
|
+
const leftJson = jsonString(left);
|
|
4295
|
+
const rightJson = jsonString(right);
|
|
4296
|
+
return leftJson !== null && rightJson !== null && leftJson === rightJson;
|
|
4297
|
+
}
|
|
4298
|
+
function formatJsonValue(value) {
|
|
4299
|
+
const serialized = jsonString(value);
|
|
4300
|
+
return serialized ?? String(value);
|
|
4301
|
+
}
|
|
4302
|
+
function enumMatches(value, enumValues) {
|
|
4303
|
+
return enumValues.some((enumValue) => jsonValuesEqual(value, enumValue));
|
|
4304
|
+
}
|
|
4305
|
+
function schemaHasObjectKeywords(schema) {
|
|
4306
|
+
return readStringArray(schema, "required").length > 0 || readObject(schema, "properties") !== null;
|
|
4307
|
+
}
|
|
4308
|
+
function schemaAllowsObjectValidation(schema, expectedTypes) {
|
|
4309
|
+
if (expectedTypes.length === 0) return schemaHasObjectKeywords(schema);
|
|
4310
|
+
return expectedTypes.includes("object");
|
|
4311
|
+
}
|
|
4312
|
+
function schemaAllowsArrayValidation(schema, expectedTypes) {
|
|
4313
|
+
if (expectedTypes.length === 0) return readProperty(schema, "items") !== void 0;
|
|
4314
|
+
return expectedTypes.includes("array");
|
|
4315
|
+
}
|
|
4316
|
+
function addTypeWarning(warnings, toolName, path2, expectedTypes, value) {
|
|
4317
|
+
warnings.push(
|
|
4318
|
+
`Tool call "${toolName}" ${pathLabel(path2)} expected ${formatExpectedTypes(
|
|
4319
|
+
expectedTypes
|
|
4320
|
+
)} but got ${actualType(value)}.`
|
|
4321
|
+
);
|
|
4322
|
+
}
|
|
4323
|
+
function validateObjectSchema(schema, value, toolName, path2, warnings) {
|
|
4324
|
+
for (const requiredName of readStringArray(schema, "required")) {
|
|
4325
|
+
if (!hasOwnProperty(value, requiredName)) {
|
|
4326
|
+
warnings.push(
|
|
4327
|
+
`Tool call "${toolName}" is missing required ${pathLabel(childPath(path2, requiredName))}.`
|
|
4328
|
+
);
|
|
4329
|
+
}
|
|
4330
|
+
}
|
|
4331
|
+
const properties = readObject(schema, "properties");
|
|
4332
|
+
if (properties === null) return;
|
|
4333
|
+
for (const [propertyName, propertySchema] of Object.entries(properties)) {
|
|
4334
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, propertyName);
|
|
4335
|
+
if (descriptor === void 0) continue;
|
|
4336
|
+
validateValueAgainstSchema(
|
|
4337
|
+
propertySchema,
|
|
4338
|
+
descriptor.value,
|
|
4339
|
+
toolName,
|
|
4340
|
+
childPath(path2, propertyName),
|
|
4341
|
+
warnings
|
|
4342
|
+
);
|
|
4343
|
+
}
|
|
4344
|
+
}
|
|
4345
|
+
function validateArraySchema(schema, value, toolName, path2, warnings) {
|
|
4346
|
+
const itemsSchema = readProperty(schema, "items");
|
|
4347
|
+
if (itemsSchema === void 0) return;
|
|
4348
|
+
let index = 0;
|
|
4349
|
+
for (const item of value) {
|
|
4350
|
+
validateValueAgainstSchema(itemsSchema, item, toolName, `${path2}[${index}]`, warnings);
|
|
4351
|
+
index++;
|
|
4352
|
+
}
|
|
4353
|
+
}
|
|
4354
|
+
function validateEnum(schema, value, toolName, path2, warnings) {
|
|
4355
|
+
const enumValue = readProperty(schema, "enum");
|
|
4356
|
+
if (Array.isArray(enumValue) && enumValue.length > 0 && !enumMatches(value, enumValue)) {
|
|
4357
|
+
warnings.push(
|
|
4358
|
+
`Tool call "${toolName}" ${pathLabel(path2)} expected one of ${formatJsonValue(
|
|
4359
|
+
enumValue
|
|
4360
|
+
)} but got ${formatJsonValue(value)}.`
|
|
4361
|
+
);
|
|
4362
|
+
}
|
|
4363
|
+
const constDescriptor = Object.getOwnPropertyDescriptor(schema, "const");
|
|
4364
|
+
if (constDescriptor !== void 0 && !jsonValuesEqual(value, constDescriptor.value)) {
|
|
4365
|
+
warnings.push(
|
|
4366
|
+
`Tool call "${toolName}" ${pathLabel(path2)} expected ${formatJsonValue(
|
|
4367
|
+
constDescriptor.value
|
|
4368
|
+
)} but got ${formatJsonValue(value)}.`
|
|
4369
|
+
);
|
|
4370
|
+
}
|
|
4371
|
+
}
|
|
4372
|
+
function validateValueAgainstSchema(schema, value, toolName, path2, warnings) {
|
|
4373
|
+
if (!isRecord(schema)) return;
|
|
4374
|
+
const expectedTypes = schemaTypes(schema);
|
|
4375
|
+
if (expectedTypes.length > 0 && !matchesAnyExpectedType(value, expectedTypes)) {
|
|
4376
|
+
addTypeWarning(warnings, toolName, path2, expectedTypes, value);
|
|
4377
|
+
return;
|
|
4378
|
+
}
|
|
4379
|
+
validateEnum(schema, value, toolName, path2, warnings);
|
|
4380
|
+
if (schemaAllowsObjectValidation(schema, expectedTypes)) {
|
|
4381
|
+
if (isRecord(value)) {
|
|
4382
|
+
validateObjectSchema(schema, value, toolName, path2, warnings);
|
|
4383
|
+
} else if (expectedTypes.length === 0) {
|
|
4384
|
+
warnings.push(
|
|
4385
|
+
`Tool call "${toolName}" ${pathLabel(path2)} expected object but got ${actualType(value)}.`
|
|
4386
|
+
);
|
|
4387
|
+
}
|
|
4388
|
+
}
|
|
4389
|
+
if (schemaAllowsArrayValidation(schema, expectedTypes)) {
|
|
4390
|
+
if (Array.isArray(value)) {
|
|
4391
|
+
validateArraySchema(schema, value, toolName, path2, warnings);
|
|
4392
|
+
} else if (expectedTypes.length === 0) {
|
|
4393
|
+
warnings.push(
|
|
4394
|
+
`Tool call "${toolName}" ${pathLabel(path2)} expected array but got ${actualType(value)}.`
|
|
4395
|
+
);
|
|
4396
|
+
}
|
|
4397
|
+
}
|
|
4398
|
+
}
|
|
4399
|
+
function extractAnthropicToolSchemas(request) {
|
|
4400
|
+
const tools = /* @__PURE__ */ new Map();
|
|
4401
|
+
for (const tool of readArray(request, "tools")) {
|
|
4402
|
+
if (!isRecord(tool)) continue;
|
|
4403
|
+
const name = readString(tool, "name");
|
|
4404
|
+
if (name === null || name === "") continue;
|
|
4405
|
+
tools.set(name, {
|
|
4406
|
+
name,
|
|
4407
|
+
schema: readObject(tool, "input_schema")
|
|
4408
|
+
});
|
|
4409
|
+
}
|
|
4410
|
+
return tools;
|
|
4411
|
+
}
|
|
4412
|
+
function extractOpenAIToolSchemas(request) {
|
|
4413
|
+
const tools = /* @__PURE__ */ new Map();
|
|
4414
|
+
for (const tool of readArray(request, "tools")) {
|
|
4415
|
+
const functionDefinition = readObject(tool, "function");
|
|
4416
|
+
if (functionDefinition === null) continue;
|
|
4417
|
+
const name = readString(functionDefinition, "name");
|
|
4418
|
+
if (name === null || name === "") continue;
|
|
4419
|
+
tools.set(name, {
|
|
4420
|
+
name,
|
|
4421
|
+
schema: readObject(functionDefinition, "parameters")
|
|
4422
|
+
});
|
|
4423
|
+
}
|
|
4424
|
+
return tools;
|
|
4425
|
+
}
|
|
4426
|
+
function mergeToolSchemas(primary, secondary) {
|
|
4427
|
+
const merged = new Map(primary);
|
|
4428
|
+
for (const [name, schema] of secondary) {
|
|
4429
|
+
if (!merged.has(name)) merged.set(name, schema);
|
|
4430
|
+
}
|
|
4431
|
+
return merged;
|
|
4432
|
+
}
|
|
4433
|
+
function extractToolSchemas(request, apiFormat) {
|
|
4434
|
+
switch (apiFormat) {
|
|
4435
|
+
case "anthropic":
|
|
4436
|
+
return extractAnthropicToolSchemas(request);
|
|
4437
|
+
case "openai":
|
|
4438
|
+
return extractOpenAIToolSchemas(request);
|
|
4439
|
+
case "unknown":
|
|
4440
|
+
return mergeToolSchemas(
|
|
4441
|
+
extractOpenAIToolSchemas(request),
|
|
4442
|
+
extractAnthropicToolSchemas(request)
|
|
4443
|
+
);
|
|
4444
|
+
}
|
|
4445
|
+
}
|
|
4446
|
+
function parseOpenAIArguments(argumentsValue) {
|
|
4447
|
+
if (argumentsValue === void 0) {
|
|
4448
|
+
return { value: {}, issue: "arguments field is missing" };
|
|
4449
|
+
}
|
|
4450
|
+
if (typeof argumentsValue !== "string") {
|
|
4451
|
+
return { value: argumentsValue, issue: null };
|
|
4452
|
+
}
|
|
4453
|
+
try {
|
|
4454
|
+
return { value: JSON.parse(argumentsValue), issue: null };
|
|
4455
|
+
} catch {
|
|
4456
|
+
return { value: {}, issue: "arguments are not valid JSON" };
|
|
4457
|
+
}
|
|
4458
|
+
}
|
|
4459
|
+
function extractOpenAIToolCalls(response) {
|
|
4460
|
+
const calls = [];
|
|
4461
|
+
let choiceIndex = 0;
|
|
4462
|
+
for (const choice of readArray(response, "choices")) {
|
|
4463
|
+
const message = readObject(choice, "message");
|
|
4464
|
+
if (message === null) {
|
|
4465
|
+
choiceIndex++;
|
|
4466
|
+
continue;
|
|
4467
|
+
}
|
|
4468
|
+
let callIndex = 0;
|
|
4469
|
+
for (const call of readArray(message, "tool_calls")) {
|
|
4470
|
+
const functionCall = readObject(call, "function");
|
|
4471
|
+
const name = functionCall === null ? null : readString(functionCall, "name");
|
|
4472
|
+
const parsedArguments = functionCall === null ? { value: {}, issue: "function block is missing" } : parseOpenAIArguments(readProperty(functionCall, "arguments"));
|
|
4473
|
+
calls.push({
|
|
4474
|
+
name,
|
|
4475
|
+
arguments: parsedArguments.value,
|
|
4476
|
+
argumentIssue: parsedArguments.issue,
|
|
4477
|
+
location: `choices[${choiceIndex}].message.tool_calls[${callIndex}]`
|
|
4478
|
+
});
|
|
4479
|
+
callIndex++;
|
|
4480
|
+
}
|
|
4481
|
+
const legacyFunctionCall = readObject(message, "function_call");
|
|
4482
|
+
if (legacyFunctionCall !== null) {
|
|
4483
|
+
const parsedArguments = parseOpenAIArguments(readProperty(legacyFunctionCall, "arguments"));
|
|
4484
|
+
calls.push({
|
|
4485
|
+
name: readString(legacyFunctionCall, "name"),
|
|
4486
|
+
arguments: parsedArguments.value,
|
|
4487
|
+
argumentIssue: parsedArguments.issue,
|
|
4488
|
+
location: `choices[${choiceIndex}].message.function_call`
|
|
4489
|
+
});
|
|
4490
|
+
}
|
|
4491
|
+
choiceIndex++;
|
|
4492
|
+
}
|
|
4493
|
+
return calls;
|
|
4494
|
+
}
|
|
4495
|
+
function extractAnthropicToolCalls(response) {
|
|
4496
|
+
const calls = [];
|
|
4497
|
+
let contentIndex = 0;
|
|
4498
|
+
for (const block of readArray(response, "content")) {
|
|
4499
|
+
if (readString(block, "type") !== "tool_use") {
|
|
4500
|
+
contentIndex++;
|
|
4501
|
+
continue;
|
|
4502
|
+
}
|
|
4503
|
+
calls.push({
|
|
4504
|
+
name: readString(block, "name"),
|
|
4505
|
+
arguments: readProperty(block, "input") ?? {},
|
|
4506
|
+
argumentIssue: null,
|
|
4507
|
+
location: `content[${contentIndex}]`
|
|
4508
|
+
});
|
|
4509
|
+
contentIndex++;
|
|
4510
|
+
}
|
|
4511
|
+
return calls;
|
|
4512
|
+
}
|
|
4513
|
+
function extractToolCalls(response, apiFormat) {
|
|
4514
|
+
switch (apiFormat) {
|
|
4515
|
+
case "anthropic":
|
|
4516
|
+
return extractAnthropicToolCalls(response);
|
|
4517
|
+
case "openai":
|
|
4518
|
+
return extractOpenAIToolCalls(response);
|
|
4519
|
+
case "unknown":
|
|
4520
|
+
return [...extractOpenAIToolCalls(response), ...extractAnthropicToolCalls(response)];
|
|
4521
|
+
}
|
|
4522
|
+
}
|
|
4523
|
+
function uniqueWarnings(warnings) {
|
|
4524
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4525
|
+
const unique2 = [];
|
|
4526
|
+
for (const warning of warnings) {
|
|
4527
|
+
if (seen.has(warning)) continue;
|
|
4528
|
+
seen.add(warning);
|
|
4529
|
+
unique2.push(warning);
|
|
4530
|
+
}
|
|
4531
|
+
return unique2;
|
|
4532
|
+
}
|
|
4533
|
+
function analyzeToolSchemaWarnings(input) {
|
|
4534
|
+
const request = parseJson(input.rawRequestBody);
|
|
4535
|
+
const response = parseJson(input.responseText);
|
|
4536
|
+
if (!request.ok || !response.ok) return [];
|
|
4537
|
+
const toolSchemas = extractToolSchemas(request.value, input.apiFormat);
|
|
4538
|
+
const toolCalls = extractToolCalls(response.value, input.apiFormat);
|
|
4539
|
+
if (toolCalls.length === 0) return [];
|
|
4540
|
+
const warnings = [];
|
|
4541
|
+
for (const call of toolCalls) {
|
|
4542
|
+
if (call.name === null || call.name === "") {
|
|
4543
|
+
warnings.push(`Tool call at ${call.location} is missing a tool name.`);
|
|
4544
|
+
continue;
|
|
4545
|
+
}
|
|
4546
|
+
const schema = toolSchemas.get(call.name);
|
|
4547
|
+
if (schema === void 0) {
|
|
4548
|
+
warnings.push(
|
|
4549
|
+
toolSchemas.size === 0 ? `Tool call "${call.name}" was returned, but the request did not define any tools.` : `Tool call "${call.name}" was returned, but it is not defined in the request tools.`
|
|
4550
|
+
);
|
|
4551
|
+
continue;
|
|
4552
|
+
}
|
|
4553
|
+
if (call.argumentIssue !== null) {
|
|
4554
|
+
warnings.push(`Tool call "${call.name}" ${call.argumentIssue}.`);
|
|
4555
|
+
continue;
|
|
4556
|
+
}
|
|
4557
|
+
if (schema.schema !== null) {
|
|
4558
|
+
validateValueAgainstSchema(schema.schema, call.arguments, schema.name, "", warnings);
|
|
4559
|
+
}
|
|
4560
|
+
}
|
|
4561
|
+
return uniqueWarnings(warnings);
|
|
4562
|
+
}
|
|
4174
4563
|
const DEFAULT_MAX_FINALIZE_STREAM_BYTES = 20 * 1024 * 1024;
|
|
4175
4564
|
function resolveMaxFinalizeStreamBytes() {
|
|
4176
4565
|
const raw = process.env["AGENT_INSPECTOR_MAX_FINALIZE_STREAM_BYTES"];
|
|
@@ -4208,6 +4597,7 @@ function buildFileLogEntry(log, upstreamUrl) {
|
|
|
4208
4597
|
clientProjectFolder: log.clientProjectFolder,
|
|
4209
4598
|
streamingChunks: log.streamingChunks,
|
|
4210
4599
|
streamingChunksPath: log.streamingChunksPath,
|
|
4600
|
+
warnings: log.warnings,
|
|
4211
4601
|
error: log.error
|
|
4212
4602
|
};
|
|
4213
4603
|
}
|
|
@@ -4256,6 +4646,38 @@ function applyOptionalStreamingTiming(log, job) {
|
|
|
4256
4646
|
return;
|
|
4257
4647
|
}
|
|
4258
4648
|
}
|
|
4649
|
+
let toolSchemaWarningQueue = Promise.resolve();
|
|
4650
|
+
function deferToolSchemaWarningAnalysis() {
|
|
4651
|
+
return new Promise((resolve2) => {
|
|
4652
|
+
setTimeout(resolve2, 0);
|
|
4653
|
+
});
|
|
4654
|
+
}
|
|
4655
|
+
function withToolSchemaWarnings(log) {
|
|
4656
|
+
const warnings = analyzeToolSchemaWarnings({
|
|
4657
|
+
rawRequestBody: log.rawRequestBody,
|
|
4658
|
+
responseText: log.responseText,
|
|
4659
|
+
apiFormat: log.apiFormat
|
|
4660
|
+
});
|
|
4661
|
+
if (warnings.length === 0) return null;
|
|
4662
|
+
const mergedWarnings = Array.from(/* @__PURE__ */ new Set([...log.warnings ?? [], ...warnings]));
|
|
4663
|
+
if (mergedWarnings.length === (log.warnings?.length ?? 0)) return null;
|
|
4664
|
+
return { ...log, warnings: mergedWarnings };
|
|
4665
|
+
}
|
|
4666
|
+
async function runToolSchemaWarningAnalysis(job) {
|
|
4667
|
+
await deferToolSchemaWarningAnalysis();
|
|
4668
|
+
const updatedLog = withToolSchemaWarnings(job.log);
|
|
4669
|
+
if (updatedLog === null) return;
|
|
4670
|
+
appendLogEntry({ ...buildFileLogEntry(updatedLog, job.upstreamUrl), error: job.error });
|
|
4671
|
+
finalizeLogUpdate(updatedLog);
|
|
4672
|
+
}
|
|
4673
|
+
function scheduleToolSchemaWarningAnalysis(job) {
|
|
4674
|
+
toolSchemaWarningQueue = toolSchemaWarningQueue.catch(() => void 0).then(() => runToolSchemaWarningAnalysis(job)).catch((err) => {
|
|
4675
|
+
logger.warn(
|
|
4676
|
+
`[logFinalizer] Tool schema warning analysis failed for log #${job.log.id}:`,
|
|
4677
|
+
errorMessage$2(err)
|
|
4678
|
+
);
|
|
4679
|
+
});
|
|
4680
|
+
}
|
|
4259
4681
|
function finalizeNonStreaming(job, log) {
|
|
4260
4682
|
const formatHandler = formatForPath(log.path);
|
|
4261
4683
|
if (formatHandler === null) {
|
|
@@ -4453,6 +4875,11 @@ function buildFinalizeLogResult(job) {
|
|
|
4453
4875
|
function commitFinalizeLogResult(result) {
|
|
4454
4876
|
appendLogEntry({ ...buildFileLogEntry(result.log, result.upstreamUrl), error: result.error });
|
|
4455
4877
|
finalizeLogUpdate(result.log);
|
|
4878
|
+
scheduleToolSchemaWarningAnalysis({
|
|
4879
|
+
log: cloneLog(result.log),
|
|
4880
|
+
upstreamUrl: result.upstreamUrl,
|
|
4881
|
+
error: result.error
|
|
4882
|
+
});
|
|
4456
4883
|
if (result.cleanupRawStreamPath !== void 0 && result.cleanupRawStreamPath !== null) {
|
|
4457
4884
|
try {
|
|
4458
4885
|
rmSync(result.cleanupRawStreamPath, { force: true });
|
|
@@ -6096,7 +6523,7 @@ const Route$s = createFileRoute("/api/models")({
|
|
|
6096
6523
|
}
|
|
6097
6524
|
}
|
|
6098
6525
|
});
|
|
6099
|
-
const version = "2.0.
|
|
6526
|
+
const version = "2.0.40";
|
|
6100
6527
|
const packageJson = {
|
|
6101
6528
|
version
|
|
6102
6529
|
};
|
|
@@ -6294,8 +6721,8 @@ function writeGroups(groups) {
|
|
|
6294
6721
|
function sortedGroups(groups) {
|
|
6295
6722
|
return [...groups].sort((left, right) => right.updatedAt.localeCompare(left.updatedAt));
|
|
6296
6723
|
}
|
|
6297
|
-
function isPathInside(parentPath,
|
|
6298
|
-
const relativePath = relative(parentPath,
|
|
6724
|
+
function isPathInside(parentPath, childPath2) {
|
|
6725
|
+
const relativePath = relative(parentPath, childPath2);
|
|
6299
6726
|
return relativePath === "" || relativePath.length > 0 && !relativePath.startsWith("..") && !isAbsolute(relativePath);
|
|
6300
6727
|
}
|
|
6301
6728
|
function evidenceDirectoryFor(group) {
|
|
@@ -8202,7 +8629,8 @@ function searchableFields(log) {
|
|
|
8202
8629
|
optionalText(log.clientPid),
|
|
8203
8630
|
optionalText(log.clientCwd),
|
|
8204
8631
|
optionalText(log.clientProjectFolder),
|
|
8205
|
-
optionalText(log.error)
|
|
8632
|
+
optionalText(log.error),
|
|
8633
|
+
...log.warnings ?? []
|
|
8206
8634
|
].filter((value) => value !== null && value.length > 0);
|
|
8207
8635
|
}
|
|
8208
8636
|
function matchesTerms(log, terms) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const tsrStartManifest = () => ({ "routes": { "__root__": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/__root.tsx", "children": ["/", "/api/config", "/api/groups", "/api/health", "/api/logs", "/api/mcp", "/api/models", "/api/providers", "/api/runs", "/api/sessions", "/proxy/$", "/session/$sessionId", "/api/knowledge/candidates", "/api/knowledge/project-context", "/api/knowledge/search", "/api/knowledge/sessions/$sessionId/candidates"], "preloads": ["/assets/main-
|
|
1
|
+
const tsrStartManifest = () => ({ "routes": { "__root__": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/__root.tsx", "children": ["/", "/api/config", "/api/groups", "/api/health", "/api/logs", "/api/mcp", "/api/models", "/api/providers", "/api/runs", "/api/sessions", "/proxy/$", "/session/$sessionId", "/api/knowledge/candidates", "/api/knowledge/project-context", "/api/knowledge/search", "/api/knowledge/sessions/$sessionId/candidates"], "preloads": ["/assets/main-CKYe6UUv.js"], "assets": [] }, "/": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/index.tsx", "assets": [], "preloads": ["/assets/index-CZP-XfpB.js", "/assets/ProxyViewerContainer-BGqeiYKD.js"] }, "/api/config": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/api/config.ts", "children": ["/api/config/paths"] }, "/api/groups": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/api/groups.ts", "children": ["/api/groups/$groupId"] }, "/api/health": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/api/health.ts" }, "/api/logs": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/api/logs.ts", "children": ["/api/logs/$id", "/api/logs/stream"] }, "/api/mcp": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/api/mcp.ts" }, "/api/models": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/api/models.ts" }, "/api/providers": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/api/providers.ts", "children": ["/api/providers/$providerId", "/api/providers/export", "/api/providers/import", "/api/providers/scan"] }, "/api/runs": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/api/runs.ts", "children": ["/api/runs/$runId"] }, "/api/sessions": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/api/sessions.ts" }, "/proxy/$": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/proxy/$.ts" }, "/session/$sessionId": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/session/$sessionId.tsx", "assets": [], "preloads": ["/assets/_sessionId-EHPexdPl.js", "/assets/ProxyViewerContainer-BGqeiYKD.js"] }, "/api/config/paths": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/api/config.paths.ts" }, "/api/groups/$groupId": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/api/groups.$groupId.ts", "children": ["/api/groups/$groupId/evidence", "/api/groups/$groupId/sessions"] }, "/api/knowledge/candidates": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/api/knowledge.candidates.ts", "children": ["/api/knowledge/candidates/$candidateId"] }, "/api/knowledge/project-context": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/api/knowledge.project-context.ts" }, "/api/knowledge/search": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/api/knowledge.search.ts" }, "/api/logs/$id": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/api/logs.$id.ts", "children": ["/api/logs/$id/chunks", "/api/logs/$id/replay"] }, "/api/logs/stream": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/api/logs.stream.ts" }, "/api/providers/$providerId": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/api/providers.$providerId.ts", "children": ["/api/providers/$providerId/model-metadata", "/api/providers/$providerId/test"] }, "/api/providers/export": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/api/providers.export.ts" }, "/api/providers/import": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/api/providers.import.ts" }, "/api/providers/scan": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/api/providers.scan.ts" }, "/api/runs/$runId": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/api/runs.$runId.ts", "children": ["/api/runs/$runId/evidence"] }, "/api/groups/$groupId/evidence": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/api/groups.$groupId.evidence.ts" }, "/api/groups/$groupId/sessions": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/api/groups.$groupId.sessions.ts" }, "/api/knowledge/candidates/$candidateId": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/api/knowledge.candidates.$candidateId.ts", "children": ["/api/knowledge/candidates/$candidateId/promote"] }, "/api/logs/$id/chunks": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/api/logs.$id.chunks.ts" }, "/api/logs/$id/replay": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/api/logs.$id.replay.ts" }, "/api/providers/$providerId/model-metadata": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/api/providers.$providerId.model-metadata.ts" }, "/api/providers/$providerId/test": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/api/providers.$providerId.test.ts", "children": ["/api/providers/$providerId/test/log"] }, "/api/runs/$runId/evidence": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/api/runs.$runId.evidence.ts" }, "/api/knowledge/candidates/$candidateId/promote": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/api/knowledge.candidates.$candidateId.promote.ts" }, "/api/knowledge/sessions/$sessionId/candidates": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/api/knowledge.sessions.$sessionId.candidates.ts" }, "/api/providers/$providerId/test/log": { "filePath": "C:/Users/claw/workspace/agent-inspector/src/routes/api/providers.$providerId.test.log.ts" } }, "clientEntry": "/assets/main-CKYe6UUv.js" });
|
|
2
2
|
export {
|
|
3
3
|
tsrStartManifest
|
|
4
4
|
};
|