@tangle-network/agent-app 0.60.118 → 0.60.120

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 (54) hide show
  1. package/dist/assistant/index.js +10 -10
  2. package/dist/catalog/index.js +1 -1
  3. package/dist/chat-react/index.js +5 -5
  4. package/dist/chat-routes/index.js +105 -115
  5. package/dist/chat-routes/index.js.map +1 -1
  6. package/dist/chat-routes/protected-runtime-producer.d.ts +8 -4
  7. package/dist/{chunk-CLB4IQEG.js → chunk-26N7PO6M.js} +4 -4
  8. package/dist/chunk-2HGAMEOY.js +222 -0
  9. package/dist/chunk-2HGAMEOY.js.map +1 -0
  10. package/dist/{chunk-7H5SGOL3.js → chunk-4U2CA7N2.js} +106 -34
  11. package/dist/chunk-4U2CA7N2.js.map +1 -0
  12. package/dist/{chunk-KYAUKYCR.js → chunk-6KCN2VQS.js} +3 -3
  13. package/dist/{chunk-XEURJVS5.js → chunk-ANHMZ5BS.js} +2 -2
  14. package/dist/{chunk-7DXRHQZO.js → chunk-GS6LD5P2.js} +2 -2
  15. package/dist/chunk-GS6LD5P2.js.map +1 -0
  16. package/dist/{chunk-BPN4TEAT.js → chunk-HYR3XFTY.js} +3 -3
  17. package/dist/{chunk-HG4OONJA.js → chunk-I2SDMEM7.js} +43 -9
  18. package/dist/chunk-I2SDMEM7.js.map +1 -0
  19. package/dist/{chunk-KHCJKVQN.js → chunk-PTTPLOWC.js} +3 -3
  20. package/dist/{chunk-7YA4QNTU.js → chunk-RFLC7BPY.js} +1 -1
  21. package/dist/chunk-RFLC7BPY.js.map +1 -0
  22. package/dist/{chunk-NJDQ2JCP.js → chunk-VTYNU3LN.js} +2 -2
  23. package/dist/{chunk-2FLSODOX.js → chunk-WEMHBHV2.js} +3 -3
  24. package/dist/{mention-editor-5KXHSBDJ.js → mention-editor-MEUNCF5P.js} +3 -3
  25. package/dist/public-consultation/index.d.ts +1 -1
  26. package/dist/runtime/index.d.ts +1 -0
  27. package/dist/runtime/index.js +8 -4
  28. package/dist/runtime/index.js.map +1 -1
  29. package/dist/runtime/model-catalog.d.ts +12 -0
  30. package/dist/runtime/openai-stream.d.ts +8 -0
  31. package/dist/runtime/protected-router-turn.d.ts +57 -0
  32. package/dist/runtime/router-turn.d.ts +34 -1
  33. package/dist/runtime/router-turn.js +2 -2
  34. package/dist/studio-react/index.js +4 -4
  35. package/dist/web-react/agent-profile-editor.js +5 -5
  36. package/dist/web-react/controls.d.ts +7 -0
  37. package/dist/web-react/index.d.ts +1 -1
  38. package/dist/web-react/index.js +12 -10
  39. package/dist/workspace-react/index.js +5 -5
  40. package/package.json +1 -1
  41. package/dist/chunk-7DXRHQZO.js.map +0 -1
  42. package/dist/chunk-7H5SGOL3.js.map +0 -1
  43. package/dist/chunk-7YA4QNTU.js.map +0 -1
  44. package/dist/chunk-HG4OONJA.js.map +0 -1
  45. package/dist/chunk-RN2N75EI.js +0 -119
  46. package/dist/chunk-RN2N75EI.js.map +0 -1
  47. /package/dist/{chunk-CLB4IQEG.js.map → chunk-26N7PO6M.js.map} +0 -0
  48. /package/dist/{chunk-KYAUKYCR.js.map → chunk-6KCN2VQS.js.map} +0 -0
  49. /package/dist/{chunk-XEURJVS5.js.map → chunk-ANHMZ5BS.js.map} +0 -0
  50. /package/dist/{chunk-BPN4TEAT.js.map → chunk-HYR3XFTY.js.map} +0 -0
  51. /package/dist/{chunk-KHCJKVQN.js.map → chunk-PTTPLOWC.js.map} +0 -0
  52. /package/dist/{chunk-NJDQ2JCP.js.map → chunk-VTYNU3LN.js.map} +0 -0
  53. /package/dist/{chunk-2FLSODOX.js.map → chunk-WEMHBHV2.js.map} +0 -0
  54. /package/dist/{mention-editor-5KXHSBDJ.js.map → mention-editor-MEUNCF5P.js.map} +0 -0
@@ -61,6 +61,18 @@ export interface CatalogModel {
61
61
  prompt?: string;
62
62
  completion?: string;
63
63
  };
64
+ /** What one generation produces. Text when absent. */
65
+ output?: 'text' | 'image' | 'video' | 'audio' | 'speech';
66
+ /** USD for one unit of output, for media models: one image, one second of
67
+ * video, one minute of audio, or 1,000 characters of speech. */
68
+ outputPrice?: {
69
+ usd: number;
70
+ unit: 'image' | 'second' | 'minute' | '1k_chars';
71
+ };
72
+ /** An example of the model's output (an image, or a video poster frame). */
73
+ previewUrl?: string;
74
+ /** One line on what the model is for, shown under its name. */
75
+ capability?: string;
64
76
  supportsTools: boolean;
65
77
  supportsReasoning: boolean;
66
78
  featured: boolean;
@@ -140,3 +140,11 @@ export interface OpenAICompatStreamTurnOptions {
140
140
  * streamAppToolLoop({ streamTurn: createOpenAICompatStreamTurn({ ...cfg, tools }), executeToolCall, ... })
141
141
  */
142
142
  export declare function createOpenAICompatStreamTurn(opts: OpenAICompatStreamTurnOptions): (messages: LoopMessage[]) => AsyncIterable<LoopEvent>;
143
+ /**
144
+ * The buffered sibling of {@link createOpenAICompatStreamTurn}: one
145
+ * `/chat/completions` request without `stream`, answered by one JSON
146
+ * completion, yielded as the same `LoopEvent`s (the same tool-call assembly and
147
+ * served-model attribution). For an endpoint or ledger that expects one buffered
148
+ * completion per model call.
149
+ */
150
+ export declare function createOpenAICompatCompletionTurn(opts: OpenAICompatStreamTurnOptions): (messages: LoopMessage[]) => AsyncIterable<LoopEvent>;
@@ -0,0 +1,57 @@
1
+ /**
2
+ * A Router turn under a protected model grant.
3
+ *
4
+ * Runtime resolves, reserves, activates and settles the grant around exactly
5
+ * one `runRouterTurn` (`runProtectedAgentCandidateModelGrant`); the turn's model
6
+ * calls use the grant's scoped key and base URL; the settled ledger is the
7
+ * turn's only usage. GTM's bounded lane and Legal's paid consultations run here
8
+ * through `createProtectedRuntimeChatProducer`, on the same engine as every
9
+ * other Router turn. This module stays off the `./router-turn` entry: the grant
10
+ * client pulls agent-runtime chunks a Worker bundle cannot build
11
+ * (tests/router-turn-entry.test.ts).
12
+ *
13
+ * Every refusal and failure is a typed outcome. Codes:
14
+ * - `grant_deadline`, `grant_model_unsupported`, `grant_activation_missing`:
15
+ * refused before any model call.
16
+ * - `grant_failed`: the grant could not be resolved, reserved or activated.
17
+ * - `grant_unsettled`: the turn failed and its grant did not settle either.
18
+ * - `settlement_over_limit`, `settlement_unauthorized_reasoning`,
19
+ * `settlement_audit_failed`: the turn answered, but its settled ledger failed
20
+ * a check; the answer stands and the turn still fails.
21
+ * - `turn_deadline`: the grant's deadline ended the turn.
22
+ * - Anything else is the turn's own failure (`turn_aborted`, `turn_tool_limit`,
23
+ * `model_http_<status>`, ...), settled as `failed`.
24
+ */
25
+ import { type RunProtectedAgentCandidateModelGrantOptions } from '@tangle-network/agent-runtime/candidate-execution';
26
+ import { type RouterTurnOptions, type RouterTurnOutcome } from './router-turn';
27
+ /** Runtime's grant inputs for one turn: the port, the model request, the reservation and its deadline. */
28
+ export type RouterTurnGrant = Omit<RunProtectedAgentCandidateModelGrantOptions<void>, 'execute'>;
29
+ type GrantSettlement = Awaited<ReturnType<RouterTurnGrant['port']['settleGrant']>>;
30
+ /** A turn under a grant. The grant supplies the key and base URL; one grant never repeats a turn.
31
+ * Placement is decided before a grant is reserved, so it is not an option here. */
32
+ export type ProtectedRouterTurnOptions = Omit<RouterTurnOptions, 'apiKey' | 'baseUrl' | 'repeat' | 'placement'> & {
33
+ grant: RouterTurnGrant;
34
+ };
35
+ export interface ProtectedRouterTurnOutcome extends RouterTurnOutcome {
36
+ /** What the grant settled, present whenever it settled, including for a failed turn. */
37
+ settlement?: RouterTurnSettlement;
38
+ }
39
+ /** What the grant settled for the turn. */
40
+ export interface RouterTurnSettlement {
41
+ /** Runtime's settled ledger, retained even when a check on it fails. */
42
+ receipt: GrantSettlement;
43
+ /** The model the grant resolved and reserved. */
44
+ model?: string;
45
+ usage: {
46
+ inputTokens: number;
47
+ outputTokens: number;
48
+ reasoningTokens: number;
49
+ costUsd: number;
50
+ };
51
+ /** Router certified the usage within the grant's limits, and no call reasoned under a grant
52
+ * that disabled reasoning. */
53
+ budgetEnforced: boolean;
54
+ }
55
+ /** Run one `runRouterTurn` under `options.grant`. */
56
+ export declare function runProtectedRouterTurn(options: ProtectedRouterTurnOptions): Promise<ProtectedRouterTurnOutcome>;
57
+ export {};
@@ -13,6 +13,10 @@
13
13
  * thrown errors, and a retry after a tool ran would repeat that tool's effect
14
14
  * ("never re-run a turn automatically", docs/agent-app-lessons.md). The only
15
15
  * automatic repeat is one model call that failed before any word or tool.
16
+ *
17
+ * Bounded paid lanes run this same engine inside a protected Router model grant
18
+ * (`runProtectedRouterTurn` in `./protected-router-turn`, outside this entry so a
19
+ * Worker bundle never pulls the grant client).
16
20
  */
17
21
  import { type LoopMessage } from './loop';
18
22
  import { type TurnKnowledgeFile } from './turn-knowledge';
@@ -82,7 +86,9 @@ export type RouterTurnEvent = {
82
86
  type: 'tool_event';
83
87
  } & RouterTurnToolEvent);
84
88
  export interface RouterTurnFailure {
85
- /** `model_http_<status>`, `model_unavailable`, `turn_<stopReason>` or `router_unconfigured`. */
89
+ /** `model_http_<status>`, `model_unavailable`, `model_empty`, `turn_<stopReason>`, `turn_aborted`,
90
+ * `turn_tool_limit` or `router_unconfigured`; under a protected grant also the `grant_*` and
91
+ * `settlement_*` codes of `./protected-router-turn`. */
86
92
  code: string;
87
93
  status?: number;
88
94
  message: string;
@@ -130,6 +136,15 @@ export interface RouterTurnPlacementInput {
130
136
  * Throws `PlacementRefusedError` when no tier can meet every requirement.
131
137
  */
132
138
  export declare function placeRouterTurn(input: RouterTurnPlacementInput): PlacementRecord;
139
+ /** One tool call's result as the model reads it. */
140
+ export type RouterTurnToolOutcome = {
141
+ ok: true;
142
+ result: unknown;
143
+ } | {
144
+ ok: false;
145
+ code: string;
146
+ message: string;
147
+ };
133
148
  export interface RouterTurnOptions {
134
149
  apiKey: string;
135
150
  model: string;
@@ -162,6 +177,24 @@ export interface RouterTurnOptions {
162
177
  } | null;
163
178
  /** Called for a tool failure the default mapping hides from the model, for the app's logs. */
164
179
  onToolFailure?: (toolName: string, error: unknown) => void;
180
+ /** Cancels the turn: the model call in flight is aborted, no further tool starts, and the
181
+ * outcome carries `turn_aborted`. Effects of tools that already ran are kept. */
182
+ signal?: AbortSignal;
183
+ /** Default true: one repeat of a model call that failed before any word or tool, and of a blank
184
+ * answer. Pass false when a second billable call needs the caller's own decision; the failure is
185
+ * then returned as it happened. */
186
+ repeat?: boolean;
187
+ /** Default true. False takes each model call as one buffered completion instead of a stream. */
188
+ stream?: boolean;
189
+ /** Sent as `reasoning_effort`. */
190
+ reasoningEffort?: string;
191
+ /** Sent as `max_completion_tokens`: one model call's visible and reasoning tokens together. */
192
+ maxCompletionTokens?: number;
193
+ /** At most this many tool calls run. The next one is refused before it runs and the turn ends
194
+ * with `turn_tool_limit`. */
195
+ maxToolCalls?: number;
196
+ /** Replace the text the model reads for one tool result. `toolName` is the app's name. */
197
+ renderToolResult?: (toolName: string, outcome: RouterTurnToolOutcome) => string;
165
198
  /**
166
199
  * Place the turn before any model call. A turn placed in the sandbox returns at once
167
200
  * with `placement` and failure `placement_sandbox`, so the app runs it there instead.
@@ -6,9 +6,9 @@ import {
6
6
  runRouterTurn,
7
7
  turnKnowledgeInstructions,
8
8
  workspaceKnowledgeForTurn
9
- } from "../chunk-7H5SGOL3.js";
9
+ } from "../chunk-4U2CA7N2.js";
10
10
  import "../chunk-D6UJEOZQ.js";
11
- import "../chunk-7YA4QNTU.js";
11
+ import "../chunk-RFLC7BPY.js";
12
12
  export {
13
13
  budgetTurnKnowledge,
14
14
  composeRouterTurnPrompt,
@@ -39,8 +39,8 @@ import {
39
39
  } from "../chunk-PT7H37YH.js";
40
40
  import {
41
41
  useInfiniteScroll
42
- } from "../chunk-2FLSODOX.js";
43
- import "../chunk-XEURJVS5.js";
42
+ } from "../chunk-WEMHBHV2.js";
43
+ import "../chunk-ANHMZ5BS.js";
44
44
  import {
45
45
  CheckGlyph,
46
46
  ChevronDown,
@@ -49,12 +49,12 @@ import {
49
49
  POPOVER_SURFACE_ATTR,
50
50
  PopoverSurface,
51
51
  usePopover
52
- } from "../chunk-HG4OONJA.js";
52
+ } from "../chunk-I2SDMEM7.js";
53
53
  import "../chunk-SJWIZT7B.js";
54
54
  import {
55
55
  ProviderLogo
56
56
  } from "../chunk-MLG6XKPV.js";
57
- import "../chunk-7YA4QNTU.js";
57
+ import "../chunk-RFLC7BPY.js";
58
58
 
59
59
  // src/studio-react/use-studio-generations.ts
60
60
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  AGENT_PROFILE_EDITOR_SECTIONS,
3
3
  AgentProfileEditor
4
- } from "../chunk-KYAUKYCR.js";
5
- import "../chunk-BPN4TEAT.js";
6
- import "../chunk-NJDQ2JCP.js";
7
- import "../chunk-HG4OONJA.js";
4
+ } from "../chunk-6KCN2VQS.js";
5
+ import "../chunk-HYR3XFTY.js";
6
+ import "../chunk-VTYNU3LN.js";
7
+ import "../chunk-I2SDMEM7.js";
8
8
  import "../chunk-MLG6XKPV.js";
9
9
  import "../chunk-WVESWAJJ.js";
10
10
  import "../chunk-B7CL7ENS.js";
11
11
  import "../chunk-PV33JZKV.js";
12
- import "../chunk-7YA4QNTU.js";
12
+ import "../chunk-RFLC7BPY.js";
13
13
  export {
14
14
  AGENT_PROFILE_EDITOR_SECTIONS,
15
15
  AgentProfileEditor
@@ -244,6 +244,13 @@ export interface ModelPickerProps {
244
244
  label: string;
245
245
  };
246
246
  }
247
+ /**
248
+ * The price a person pays per output, in the unit that output comes in: per
249
+ * million prompt tokens for text, per image, per second of video, per minute of
250
+ * audio, per 1,000 characters of speech. Undefined when the catalogue has no
251
+ * price, so a row never shows a made-up number.
252
+ */
253
+ export declare function formatModelPrice(model: Pick<CatalogModel, 'pricing' | 'outputPrice'>): string | undefined;
247
254
  /**
248
255
  * Searchable model picker pill + popover. A featured model is recommended
249
256
  * when the catalog marks it as a current choice. The first view stays short;
@@ -70,7 +70,7 @@ export * from './command-palette';
70
70
  export * from './sparkline';
71
71
  export * from './insight-card';
72
72
  export * from './use-dictation';
73
- export { usePopover, usePending, PopoverSurface, POPOVER_SURFACE_ATTR, ModelPicker, EffortPicker, EffortMeter, effortMeterFill, effortLevelLabel, effortLevelsFromIds, reconcileEffortLevels, DEFAULT_EFFORT_LEVELS, EFFORT_METER_SEGMENTS, OVERLAY_SHADOW, fieldPickerTriggerClass, type ModelPickerProps, type EffortPickerProps, type EffortLevel, type PickerVariant, type PopoverSurfaceProps, } from './controls';
73
+ export { usePopover, usePending, PopoverSurface, POPOVER_SURFACE_ATTR, ModelPicker, formatModelPrice, EffortPicker, EffortMeter, effortMeterFill, effortLevelLabel, effortLevelsFromIds, reconcileEffortLevels, DEFAULT_EFFORT_LEVELS, EFFORT_METER_SEGMENTS, OVERLAY_SHADOW, fieldPickerTriggerClass, type ModelPickerProps, type EffortPickerProps, type EffortLevel, type PickerVariant, type PopoverSurfaceProps, } from './controls';
74
74
  export { AgentSessionControls, HarnessPicker, type AgentSessionControlsProps, type HarnessPickerProps, } from './agent-session-controls';
75
75
  import type { CatalogModel } from '../runtime/model-catalog';
76
76
  export type { CatalogModel } from '../runtime/model-catalog';
@@ -138,14 +138,14 @@ import {
138
138
  withoutRecordGridCreated,
139
139
  withoutRecordGridRemoved,
140
140
  withoutRecordGridUpdate
141
- } from "../chunk-7DXRHQZO.js";
141
+ } from "../chunk-GS6LD5P2.js";
142
142
  import {
143
143
  SessionHistoryPanel,
144
144
  formatSessionTimestamp,
145
145
  useInfiniteScroll,
146
146
  useSessionActions,
147
147
  useSessionHistory
148
- } from "../chunk-2FLSODOX.js";
148
+ } from "../chunk-WEMHBHV2.js";
149
149
  import {
150
150
  MENTION_PILL_CLASS
151
151
  } from "../chunk-3HUFJ5LO.js";
@@ -154,7 +154,7 @@ import {
154
154
  AGENT_PROFILE_EDITOR_SECTIONS,
155
155
  AgentProfileEditor,
156
156
  AgentProfileRegistryError
157
- } from "../chunk-KYAUKYCR.js";
157
+ } from "../chunk-6KCN2VQS.js";
158
158
  import {
159
159
  EvidenceLineageTable,
160
160
  ExceptionList,
@@ -183,7 +183,7 @@ import {
183
183
  preloadWhenIdle,
184
184
  useComposerAttachments,
185
185
  useDictation
186
- } from "../chunk-CLB4IQEG.js";
186
+ } from "../chunk-26N7PO6M.js";
187
187
  import "../chunk-L7MB2LLM.js";
188
188
  import {
189
189
  AgentSessionControls,
@@ -194,13 +194,13 @@ import {
194
194
  filterAcceptedFiles,
195
195
  isAcceptedFileType,
196
196
  renamePastedImages
197
- } from "../chunk-BPN4TEAT.js";
197
+ } from "../chunk-HYR3XFTY.js";
198
198
  import {
199
199
  WorkspaceInitial,
200
200
  WorkspaceSwitcher
201
- } from "../chunk-KHCJKVQN.js";
202
- import "../chunk-XEURJVS5.js";
203
- import "../chunk-NJDQ2JCP.js";
201
+ } from "../chunk-PTTPLOWC.js";
202
+ import "../chunk-ANHMZ5BS.js";
203
+ import "../chunk-VTYNU3LN.js";
204
204
  import {
205
205
  DEFAULT_EFFORT_LEVELS,
206
206
  EFFORT_METER_SEGMENTS,
@@ -214,10 +214,11 @@ import {
214
214
  effortLevelsFromIds,
215
215
  effortMeterFill,
216
216
  fieldPickerTriggerClass,
217
+ formatModelPrice,
217
218
  reconcileEffortLevels,
218
219
  usePending,
219
220
  usePopover
220
- } from "../chunk-HG4OONJA.js";
221
+ } from "../chunk-I2SDMEM7.js";
221
222
  import {
222
223
  tabTerminalConnectionId,
223
224
  useSandboxTerminalConnection
@@ -234,7 +235,7 @@ import {
234
235
  import "../chunk-WVESWAJJ.js";
235
236
  import "../chunk-B7CL7ENS.js";
236
237
  import "../chunk-PV33JZKV.js";
237
- import "../chunk-7YA4QNTU.js";
238
+ import "../chunk-RFLC7BPY.js";
238
239
  import {
239
240
  attachmentInputToPart,
240
241
  attachmentKindForMime,
@@ -433,6 +434,7 @@ export {
433
434
  formatDictationElapsed,
434
435
  formatInsightDelta,
435
436
  formatModelCost,
437
+ formatModelPrice,
436
438
  formatRecordGridValue,
437
439
  formatSessionTimestamp,
438
440
  formatSparklineValue,
@@ -1,27 +1,27 @@
1
1
  import {
2
2
  WorkspaceInitial,
3
3
  WorkspaceSwitcher
4
- } from "../chunk-KHCJKVQN.js";
4
+ } from "../chunk-PTTPLOWC.js";
5
5
  import {
6
6
  ActionDialog,
7
7
  ActionDialogButton
8
- } from "../chunk-XEURJVS5.js";
8
+ } from "../chunk-ANHMZ5BS.js";
9
9
  import {
10
10
  usePopoverDialog
11
- } from "../chunk-NJDQ2JCP.js";
11
+ } from "../chunk-VTYNU3LN.js";
12
12
  import {
13
13
  CheckGlyph,
14
14
  OVERLAY_SHADOW,
15
15
  PopoverSurface,
16
16
  usePopover
17
- } from "../chunk-HG4OONJA.js";
17
+ } from "../chunk-I2SDMEM7.js";
18
18
  import {
19
19
  buildSessionNavItem,
20
20
  composeSidebarSessions,
21
21
  resolveActiveNavId
22
22
  } from "../chunk-SJWIZT7B.js";
23
23
  import "../chunk-MLG6XKPV.js";
24
- import "../chunk-7YA4QNTU.js";
24
+ import "../chunk-RFLC7BPY.js";
25
25
 
26
26
  // src/workspace-react/index.tsx
27
27
  import { SidebarLayout } from "@tangle-network/sandbox-ui/dashboard";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-app",
3
- "version": "0.60.118",
3
+ "version": "0.60.120",
4
4
  "packageManager": "pnpm@11.24.0",
5
5
  "description": "Build agent applications with typed chat, tools, sandboxes, integrations, billing, and evaluation.",
6
6
  "keywords": [