@tangle-network/agent-app 0.46.42 → 0.46.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +2 -2
  2. package/dist/assistant/index.js +9 -8
  3. package/dist/assistant/index.js.map +1 -1
  4. package/dist/catalog/index.d.ts +1 -1
  5. package/dist/catalog/index.js +5 -3
  6. package/dist/chat-react/index.js +6 -5
  7. package/dist/chat-routes/gateway-adapter.d.ts +4 -2
  8. package/dist/chat-routes/index.js +115 -24
  9. package/dist/chat-routes/index.js.map +1 -1
  10. package/dist/chat-routes/turn-routes.d.ts +20 -8
  11. package/dist/chat-routes/wire.d.ts +7 -1
  12. package/dist/chat-store/index.js +3 -2
  13. package/dist/chat-store/index.js.map +1 -1
  14. package/dist/chat-store/store.d.ts +3 -0
  15. package/dist/{chunk-KWXUBMXU.js → chunk-DXHUQ5NO.js} +1 -1
  16. package/dist/chunk-DXHUQ5NO.js.map +1 -0
  17. package/dist/{chunk-U2UAQTFY.js → chunk-HHCUPBYW.js} +3 -3
  18. package/dist/{chunk-5ZTFZBS6.js → chunk-IRYULX3R.js} +2 -2
  19. package/dist/{chunk-TH7L265V.js → chunk-MCYJON3F.js} +12 -5
  20. package/dist/chunk-MCYJON3F.js.map +1 -0
  21. package/dist/{chunk-Z4TPWP6A.js → chunk-MLJQYITH.js} +2 -2
  22. package/dist/{chunk-PZOTRGGQ.js → chunk-N55NM3W2.js} +143 -8
  23. package/dist/chunk-N55NM3W2.js.map +1 -0
  24. package/dist/{chunk-QK4IFP3E.js → chunk-P3L5HF53.js} +5 -5
  25. package/dist/{chunk-YNMPMW3G.js → chunk-SUO2R2ET.js} +2 -2
  26. package/dist/{chunk-PYDMEYWA.js → chunk-TIQKVTOD.js} +26 -9
  27. package/dist/chunk-TIQKVTOD.js.map +1 -0
  28. package/dist/{chunk-OAGD7RDM.js → chunk-UEDFSZ3E.js} +43 -16
  29. package/dist/chunk-UEDFSZ3E.js.map +1 -0
  30. package/dist/harness/index.d.ts +10 -4
  31. package/dist/harness/index.js +1 -1
  32. package/dist/{mention-editor-CBLT6LE3.js → mention-editor-Y45HQYOA.js} +3 -2
  33. package/dist/{mention-editor-CBLT6LE3.js.map → mention-editor-Y45HQYOA.js.map} +1 -1
  34. package/dist/run/index.js +1 -1
  35. package/dist/runtime/index.js +4 -2
  36. package/dist/runtime/index.js.map +1 -1
  37. package/dist/runtime/model-catalog.d.ts +9 -1
  38. package/dist/sandbox/index.d.ts +33 -0
  39. package/dist/sandbox/index.js +4 -2
  40. package/dist/skills-placement/index.js +1 -1
  41. package/dist/studio-react/index.js +3 -2
  42. package/dist/studio-react/index.js.map +1 -1
  43. package/dist/web-react/controls.d.ts +4 -4
  44. package/dist/web-react/index.js +9 -8
  45. package/package.json +15 -13
  46. package/dist/chunk-KWXUBMXU.js.map +0 -1
  47. package/dist/chunk-OAGD7RDM.js.map +0 -1
  48. package/dist/chunk-PYDMEYWA.js.map +0 -1
  49. package/dist/chunk-PZOTRGGQ.js.map +0 -1
  50. package/dist/chunk-TH7L265V.js.map +0 -1
  51. /package/dist/{chunk-U2UAQTFY.js.map → chunk-HHCUPBYW.js.map} +0 -0
  52. /package/dist/{chunk-5ZTFZBS6.js.map → chunk-IRYULX3R.js.map} +0 -0
  53. /package/dist/{chunk-Z4TPWP6A.js.map → chunk-MLJQYITH.js.map} +0 -0
  54. /package/dist/{chunk-QK4IFP3E.js.map → chunk-P3L5HF53.js.map} +0 -0
  55. /package/dist/{chunk-YNMPMW3G.js.map → chunk-SUO2R2ET.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  assertHarnessModelCompatible
3
- } from "./chunk-TH7L265V.js";
3
+ } from "./chunk-MCYJON3F.js";
4
4
  import {
5
5
  assertProfilePromptWithinBudget,
6
6
  fingerprintAgentProfile
@@ -2232,6 +2232,83 @@ function attachReasoningEffort(profile, harness, effort) {
2232
2232
  }
2233
2233
  };
2234
2234
  }
2235
+ function positiveSafeInteger(value, field) {
2236
+ if (value === void 0) return void 0;
2237
+ if (!Number.isSafeInteger(value) || value <= 0) {
2238
+ throw new Error(`${field} must be a positive safe integer`);
2239
+ }
2240
+ return value;
2241
+ }
2242
+ function lowerCeiling(current, requested) {
2243
+ if (current === void 0) return requested;
2244
+ if (requested === void 0) return current;
2245
+ return Math.min(current, requested);
2246
+ }
2247
+ function applyPromptTokenLimits(profile, limits) {
2248
+ const requestedVisible = positiveSafeInteger(
2249
+ limits.maxVisibleOutputTokens,
2250
+ "maxVisibleOutputTokens"
2251
+ );
2252
+ const requestedReasoning = positiveSafeInteger(
2253
+ limits.maxReasoningTokens,
2254
+ "maxReasoningTokens"
2255
+ );
2256
+ const requestedTotal = positiveSafeInteger(
2257
+ limits.maxTotalOutputTokens,
2258
+ "maxTotalOutputTokens"
2259
+ );
2260
+ if (requestedVisible === void 0 && requestedReasoning === void 0 && requestedTotal === void 0) return profile;
2261
+ const maxTotalOutputTokens = lowerCeiling(
2262
+ profile.model?.maxTotalOutputTokens,
2263
+ requestedTotal
2264
+ );
2265
+ let maxVisibleOutputTokens = lowerCeiling(
2266
+ profile.model?.maxVisibleOutputTokens,
2267
+ requestedVisible
2268
+ );
2269
+ let maxReasoningTokens = lowerCeiling(
2270
+ profile.model?.maxReasoningTokens,
2271
+ requestedReasoning
2272
+ );
2273
+ if (maxTotalOutputTokens !== void 0) {
2274
+ if (maxVisibleOutputTokens !== void 0) {
2275
+ maxVisibleOutputTokens = Math.min(maxVisibleOutputTokens, maxTotalOutputTokens);
2276
+ }
2277
+ if (maxReasoningTokens !== void 0) {
2278
+ maxReasoningTokens = Math.min(maxReasoningTokens, maxTotalOutputTokens);
2279
+ }
2280
+ }
2281
+ return {
2282
+ ...profile,
2283
+ model: {
2284
+ ...profile.model ?? {},
2285
+ ...maxVisibleOutputTokens !== void 0 ? { maxVisibleOutputTokens } : {},
2286
+ ...maxReasoningTokens !== void 0 ? { maxReasoningTokens } : {},
2287
+ ...maxTotalOutputTokens !== void 0 ? { maxTotalOutputTokens } : {}
2288
+ }
2289
+ };
2290
+ }
2291
+ function optionalNonNegativeNumber(value, field) {
2292
+ if (value === void 0) return void 0;
2293
+ if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
2294
+ throw new Error(`sandbox gateway event ${field} is invalid`);
2295
+ }
2296
+ return value;
2297
+ }
2298
+ function optionalNonNegativeSafeInteger(value, field) {
2299
+ const number = optionalNonNegativeNumber(value, field);
2300
+ if (number !== void 0 && !Number.isSafeInteger(number)) {
2301
+ throw new Error(`sandbox gateway event ${field} is invalid`);
2302
+ }
2303
+ return number;
2304
+ }
2305
+ function optionalGatewayRecord(value, field) {
2306
+ if (value === void 0) return void 0;
2307
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
2308
+ throw new Error(`sandbox gateway event ${field} is invalid`);
2309
+ }
2310
+ return value;
2311
+ }
2235
2312
  function adaptSandboxStream(events) {
2236
2313
  return (async function* () {
2237
2314
  for await (const rawEvent of events) {
@@ -2250,6 +2327,56 @@ function adaptSandboxStream(events) {
2250
2327
  }
2251
2328
  if (typeof dataRecord?.delta === "string") data.delta = dataRecord.delta;
2252
2329
  if (typeof dataRecord?.finalText === "string") data.finalText = dataRecord.finalText;
2330
+ if (typeof dataRecord?.code === "string") data.code = dataRecord.code;
2331
+ if (typeof dataRecord?.message === "string") data.message = dataRecord.message;
2332
+ const rawDetails = dataRecord?.details;
2333
+ if (rawDetails && typeof rawDetails === "object" && !Array.isArray(rawDetails)) {
2334
+ data.details = rawDetails;
2335
+ }
2336
+ const usageRecord = optionalGatewayRecord(dataRecord?.usage, "usage");
2337
+ if (usageRecord) {
2338
+ const usage = {};
2339
+ for (const field of [
2340
+ "inputTokens",
2341
+ "outputTokens",
2342
+ "reasoningTokens",
2343
+ "toolTokens",
2344
+ "toolCallCount"
2345
+ ]) {
2346
+ const value = optionalNonNegativeSafeInteger(usageRecord[field], `usage.${field}`);
2347
+ if (value !== void 0) usage[field] = value;
2348
+ }
2349
+ const providerCostUsd = optionalNonNegativeNumber(
2350
+ usageRecord.providerCostUsd,
2351
+ "usage.providerCostUsd"
2352
+ );
2353
+ if (providerCostUsd !== void 0) usage.providerCostUsd = providerCostUsd;
2354
+ if (usageRecord.budgetEnforced !== void 0) {
2355
+ if (typeof usageRecord.budgetEnforced !== "boolean") {
2356
+ throw new Error("sandbox gateway event usage.budgetEnforced is invalid");
2357
+ }
2358
+ usage.budgetEnforced = usageRecord.budgetEnforced;
2359
+ }
2360
+ if (Object.keys(usage).length > 0) data.usage = usage;
2361
+ }
2362
+ const toolRecord = optionalGatewayRecord(dataRecord?.tool, "tool");
2363
+ if (toolRecord) {
2364
+ const tool = {};
2365
+ if (typeof toolRecord.name === "string") tool.name = toolRecord.name;
2366
+ const inputTokens = optionalNonNegativeSafeInteger(toolRecord.inputTokens, "tool.inputTokens");
2367
+ const outputTokens = optionalNonNegativeSafeInteger(toolRecord.outputTokens, "tool.outputTokens");
2368
+ if (inputTokens !== void 0) tool.inputTokens = inputTokens;
2369
+ if (outputTokens !== void 0) tool.outputTokens = outputTokens;
2370
+ if (Object.keys(tool).length > 0) data.tool = tool;
2371
+ }
2372
+ const reasoningRecord = optionalGatewayRecord(dataRecord?.reasoning, "reasoning");
2373
+ if (reasoningRecord) {
2374
+ const tokens = optionalNonNegativeSafeInteger(
2375
+ reasoningRecord.tokens,
2376
+ "reasoning.tokens"
2377
+ );
2378
+ if (tokens !== void 0) data.reasoning = { tokens };
2379
+ }
2253
2380
  const rawInputRequired = dataRecord?.inputRequired;
2254
2381
  if (rawInputRequired && typeof rawInputRequired === "object" && !Array.isArray(rawInputRequired)) {
2255
2382
  const prompt = rawInputRequired.prompt;
@@ -2271,21 +2398,28 @@ async function* streamSandboxPrompt(shell, box, message, options) {
2271
2398
  }),
2272
2399
  "streamSandboxPrompt"
2273
2400
  );
2274
- if (model?.model) assertHarnessModelCompatible(harness, model.model);
2401
+ if (model?.model) assertHarnessModelCompatible(harness, model);
2275
2402
  const prompt = typeof message === "string" ? flattenHistory(message, options?.history) : mergeHistoryIntoParts(message, options?.history);
2276
2403
  const appToolMcp = options?.appToolMcp ?? {};
2277
2404
  const extraMcp = mergeExtraMcp(appToolMcp, options?.baseProfileMcp ?? {}, options?.extraMcp);
2278
2405
  const profile = shell.profile({ systemPrompt: options?.systemPrompt, extraMcp, harness });
2279
- const profileWithEffort = attachReasoningEffort(profile, harness, options?.effort);
2406
+ const profileWithLimits = applyPromptTokenLimits(
2407
+ attachReasoningEffort(profile, harness, options?.effort),
2408
+ {
2409
+ maxVisibleOutputTokens: options?.maxOutputTokens,
2410
+ maxReasoningTokens: options?.maxReasoningTokens,
2411
+ maxTotalOutputTokens: options?.maxTotalOutputTokens
2412
+ }
2413
+ );
2280
2414
  assertProfilePromptWithinBudget(
2281
- profileWithEffort,
2415
+ profileWithLimits,
2282
2416
  shell.promptBudget ?? {},
2283
2417
  "streamSandboxPrompt profile systemPrompt",
2284
2418
  SHELL_PROMPT_BUDGET_HINT
2285
2419
  );
2286
2420
  if (options?.onProfileResolved) {
2287
2421
  options.onProfileResolved(
2288
- await fingerprintAgentProfile(profileWithEffort, { model: model?.model, harness })
2422
+ await fingerprintAgentProfile(profileWithLimits, { model: model?.model, harness })
2289
2423
  );
2290
2424
  }
2291
2425
  const stream = box.streamPrompt(prompt, {
@@ -2299,7 +2433,7 @@ async function* streamSandboxPrompt(shell, box, message, options) {
2299
2433
  ...options?.detach ? { detach: true } : {},
2300
2434
  backend: {
2301
2435
  type: harness,
2302
- profile: profileWithEffort,
2436
+ profile: profileWithLimits,
2303
2437
  ...model ? { model } : {},
2304
2438
  ...options?.interactions ? { interactions: options.interactions } : {}
2305
2439
  }
@@ -2459,7 +2593,7 @@ async function driveSandboxTurn(shell, box, message, options) {
2459
2593
  }),
2460
2594
  "driveSandboxTurn"
2461
2595
  );
2462
- if (model?.model) assertHarnessModelCompatible(harness, model.model);
2596
+ if (model?.model) assertHarnessModelCompatible(harness, model);
2463
2597
  const prompt = typeof message === "string" ? flattenHistory(message, options.history) : mergeHistoryIntoParts(message, options.history);
2464
2598
  const appToolMcp = options.appToolMcp ?? {};
2465
2599
  const extraMcp = mergeExtraMcp(appToolMcp, options.baseProfileMcp ?? {}, options.extraMcp);
@@ -2619,6 +2753,7 @@ export {
2619
2753
  mergeHistoryIntoParts,
2620
2754
  mergeExtraMcp,
2621
2755
  attachReasoningEffort,
2756
+ applyPromptTokenLimits,
2622
2757
  adaptSandboxStream,
2623
2758
  streamSandboxPrompt,
2624
2759
  collectSandboxPromptText,
@@ -2635,4 +2770,4 @@ export {
2635
2770
  isTerminalPromptEvent,
2636
2771
  detectInteractiveQuestion
2637
2772
  };
2638
- //# sourceMappingURL=chunk-PZOTRGGQ.js.map
2773
+ //# sourceMappingURL=chunk-N55NM3W2.js.map