@tangle-network/agent-app 0.60.221 → 0.60.222

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 (42) hide show
  1. package/dist/assistant/index.js +3 -2
  2. package/dist/assistant/index.js.map +1 -1
  3. package/dist/chat-react/index.js +2 -1
  4. package/dist/chat-routes/hybrid-producer.d.ts +93 -0
  5. package/dist/chat-routes/index.d.ts +1 -0
  6. package/dist/chat-routes/index.js +116 -3
  7. package/dist/chat-routes/index.js.map +1 -1
  8. package/dist/chat-routes/router-producer.d.ts +3 -1
  9. package/dist/{chunk-DMXEPYB5.js → chunk-4WEC4NOU.js} +3 -1
  10. package/dist/chunk-4WEC4NOU.js.map +1 -0
  11. package/dist/{chunk-KNTRS7OZ.js → chunk-BQILMP73.js} +70 -115
  12. package/dist/chunk-BQILMP73.js.map +1 -0
  13. package/dist/{chunk-2XUIWCRW.js → chunk-DA5XLDZR.js} +7 -2
  14. package/dist/chunk-DA5XLDZR.js.map +1 -0
  15. package/dist/chunk-OXUBZ5SE.js +54 -0
  16. package/dist/chunk-OXUBZ5SE.js.map +1 -0
  17. package/dist/{chunk-A5DGO2XT.js → chunk-QGEYQ7SU.js} +2 -2
  18. package/dist/{chunk-N7WTF5P2.js → chunk-XWJDF34U.js} +10 -2
  19. package/dist/chunk-XWJDF34U.js.map +1 -0
  20. package/dist/{chunk-C7WAGXQN.js → chunk-YS2RYZQG.js} +9 -8
  21. package/dist/{chunk-C7WAGXQN.js.map → chunk-YS2RYZQG.js.map} +1 -1
  22. package/dist/public-consultation/index.d.ts +1 -1
  23. package/dist/runtime/index.js +2 -2
  24. package/dist/runtime/router-turn.d.ts +6 -0
  25. package/dist/runtime/router-turn.js +1 -1
  26. package/dist/sandbox/escalation-speculator.d.ts +15 -27
  27. package/dist/sandbox/index.js +1 -3
  28. package/dist/sandbox/sandbox-run-tool.d.ts +4 -3
  29. package/dist/signoff/cli.js +1 -1
  30. package/dist/signoff/index.js +1 -1
  31. package/dist/web-react/chat-composer.d.ts +2 -1
  32. package/dist/web-react/index.js +10 -4
  33. package/dist/web-react/workspace-prewarm.d.ts +7 -0
  34. package/dist/workspace-react/index.d.ts +9 -1
  35. package/dist/workspace-react/index.js +8 -2
  36. package/dist/workspace-react/index.js.map +1 -1
  37. package/package.json +1 -1
  38. package/dist/chunk-2XUIWCRW.js.map +0 -1
  39. package/dist/chunk-DMXEPYB5.js.map +0 -1
  40. package/dist/chunk-KNTRS7OZ.js.map +0 -1
  41. package/dist/chunk-N7WTF5P2.js.map +0 -1
  42. /package/dist/{chunk-A5DGO2XT.js.map → chunk-QGEYQ7SU.js.map} +0 -0
@@ -121,9 +121,9 @@ export declare function createPublicConsultation(options: PublicConsultationOpti
121
121
  executionBudget?: ChatTurnExecutionLimits;
122
122
  maxOutputTokens?: number;
123
123
  }) => Promise<{
124
- start?: undefined;
125
124
  status: 'unsupported';
126
125
  reason: string;
126
+ start?: undefined;
127
127
  } | {
128
128
  reason?: undefined;
129
129
  status: 'prepared';
@@ -2,7 +2,7 @@ import {
2
2
  ProtectedModelSettlementError,
3
3
  createRouterProtectedModelPort,
4
4
  runProtectedRouterTurn
5
- } from "../chunk-A5DGO2XT.js";
5
+ } from "../chunk-QGEYQ7SU.js";
6
6
  import {
7
7
  DURABLE_HOP_BUDGET_MS,
8
8
  asksForLanguage,
@@ -24,7 +24,7 @@ import {
24
24
  turnKnowledgeInstructions,
25
25
  workspaceKnowledgeForTurn,
26
26
  workspaceTurnCheckpoints
27
- } from "../chunk-DMXEPYB5.js";
27
+ } from "../chunk-4WEC4NOU.js";
28
28
  import "../chunk-J63KUZBE.js";
29
29
  import {
30
30
  DEFAULT_TANGLE_BILLING_ENFORCEMENT_ENV_VAR,
@@ -71,6 +71,12 @@ export type RouterTurnEvent = {
71
71
  | {
72
72
  type: 'repeat';
73
73
  model: string;
74
+ }
75
+ /** The model named a tool; its arguments are still streaming. Lets a caller start slow work the call will need
76
+ * (the box `sandbox_run` runs in) seconds before the call itself. `toolName` is the app's name. */
77
+ | {
78
+ type: 'tool_start';
79
+ toolName: string;
74
80
  } | {
75
81
  type: 'tool';
76
82
  callId: string;
@@ -11,7 +11,7 @@ import {
11
11
  turnKnowledgeInstructions,
12
12
  workspaceKnowledgeForTurn,
13
13
  workspaceTurnCheckpoints
14
- } from "../chunk-DMXEPYB5.js";
14
+ } from "../chunk-4WEC4NOU.js";
15
15
  import "../chunk-J63KUZBE.js";
16
16
  import "../chunk-D6UJEOZQ.js";
17
17
  import "../chunk-AMUXRAUO.js";
@@ -1,31 +1,23 @@
1
1
  /**
2
- * `createEscalationSpeculator`: warm a turn's sandbox box when the turn is
2
+ * `createEscalationSpeculator`: start a turn's sandbox box when the turn is
3
3
  * likely to escalate to it, so `sandbox_run` finds the box running instead of
4
4
  * paying the resume (p50 6.4 s on escalated turns, agent turn architecture S8).
5
5
  *
6
6
  * TWO SIGNALS, CHEAPEST FIRST. Deterministic rules on the turn's input fire
7
7
  * before the model is called: an attachment a process must read (PDF, sheet,
8
8
  * archive, code), a fenced code block, or words that ask for execution. Then,
9
- * while the reply streams, `tool_call_start` for an escalation tool fires as
9
+ * while the reply streams, the start of a call to an escalation tool fires as
10
10
  * soon as the model names it, seconds before its arguments finish. Either one
11
- * signals the box's warm lease with reason `escalation-likely`, at most once
12
- * per turn.
11
+ * calls `warm` once per turn.
13
12
  *
14
- * NEVER GATES. Signals are fire-and-forget: the lease dedupes across isolates,
15
- * charges unused warms to the key's daily budget (`escalation-likely` is a
16
- * budgeted reason), and backs off on capacity. A speculation that is wrong
17
- * costs box time within that budget; it never delays or fails the turn.
13
+ * ALWAYS ON. There is no mode: a turn that can reach the box speculates. The
14
+ * hybrid producer (`createHybridTurnProducer` in `/chat-routes`) passes its own
15
+ * single-flight box start as `warm`, so a speculative start and the tool's own
16
+ * start are one start.
18
17
  *
19
- * MEASURING IT. The `sandbox_run` binding calls `leases.turn(boxKey)` when the
20
- * tool runs. A `warm_hit` with reason `escalation-likely` is a box the
21
- * speculation made ready in time. The S8 number is that count over all
22
- * escalated turns.
23
- *
24
- * Off unless the app passes `mode: 'deterministic'` (from `SANDBOX_PREWARM_HINT`).
18
+ * NEVER GATES. `warm` is fire-and-forget. A speculation that is wrong costs a
19
+ * box that idles out; it never delays or fails the turn.
25
20
  */
26
- /** `SANDBOX_PREWARM_HINT`: `off` (default) or `deterministic`. */
27
- export type PrewarmHintMode = 'off' | 'deterministic';
28
- export declare function parsePrewarmHint(value: string | undefined | null): PrewarmHintMode;
29
21
  /** Why a turn was judged likely to escalate. */
30
22
  export type EscalationHint = 'attachment' | 'code-block' | 'execution-words' | 'tool-call-start';
31
23
  export interface EscalationInput {
@@ -35,26 +27,22 @@ export interface EscalationInput {
35
27
  name?: string;
36
28
  }>;
37
29
  }
38
- /** The tools that run in the box. A `tool_call_start` for one of these warms it. */
30
+ /** The tools that run in the box. The start of a call to one of these warms it. */
39
31
  export declare const DEFAULT_ESCALATION_TOOLS: readonly ['sandbox_run', 'sandbox_exec'];
40
32
  /** Pure: the reasons this input suggests the turn will need the box, if any. */
41
33
  export declare function escalationHints(input: EscalationInput): EscalationHint[];
42
34
  export interface EscalationSpeculatorOptions {
43
- mode: PrewarmHintMode;
44
- /** The box's warm lease; only `signal` is used. */
45
- leases: {
46
- signal(key: string, reason: 'escalation-likely'): Promise<unknown>;
47
- };
48
- /** The warm-lease key of the box `sandbox_run` would use for this turn. */
49
- boxKey: string;
35
+ /** Start the box. Called at most once per turn; a rejection is swallowed. */
36
+ warm(): Promise<unknown> | void;
50
37
  escalationTools?: readonly string[];
51
- /** Observability: called once, when the turn's warm is signalled. */
38
+ /** Observability: called once, when the turn's warm starts. */
52
39
  onSpeculate?(hint: EscalationHint): void;
53
40
  }
54
41
  export interface EscalationSpeculator {
55
42
  /** Call with the turn's input before the model call. */
56
43
  onInput(input: EscalationInput): void;
57
- /** Call with each event the model stream yields. Non-tool events are ignored. */
44
+ /** Call with each engine event. Only the start of a call to an escalation tool
45
+ * (`tool_start`, or the loop's `tool_call_start`) is read. */
58
46
  onEvent(event: {
59
47
  type: string;
60
48
  toolName?: string;
@@ -68,7 +68,6 @@ import {
68
68
  mergeExtraMcp,
69
69
  mergeHistoryIntoParts,
70
70
  mintSandboxScopedToken,
71
- parsePrewarmHint,
72
71
  peekWorkspaceSandbox,
73
72
  predictColdArrival,
74
73
  readSandboxBinaryBytes,
@@ -101,7 +100,7 @@ import {
101
100
  warmBinOf,
102
101
  warmWeekdayOf,
103
102
  writeProfileFilesToBox
104
- } from "../chunk-C7WAGXQN.js";
103
+ } from "../chunk-YS2RYZQG.js";
105
104
  import {
106
105
  EGRESS_PROXY_RECOVERY_PHASE,
107
106
  EGRESS_PROXY_RECOVERY_REQUIRED,
@@ -250,7 +249,6 @@ export {
250
249
  mergeExtraMcp,
251
250
  mergeHistoryIntoParts,
252
251
  mintSandboxScopedToken,
253
- parsePrewarmHint,
254
252
  peekWorkspaceSandbox,
255
253
  predictColdArrival,
256
254
  preferredWorkspaceSandboxRecoveryBoxKey,
@@ -13,9 +13,10 @@
13
13
  * fail instead.
14
14
  *
15
15
  * WARM LEASES. When the product passes `warm`, the call counts as a turn on the
16
- * box's lease (`leases.turn(key)`), so an `escalation-likely` warm from
17
- * `createEscalationSpeculator` is recorded as used. The default name is the
18
- * one the speculator listens for (`DEFAULT_ESCALATION_TOOLS`).
16
+ * box's lease (`leases.turn(key)`), so an `escalation-likely` warm the product
17
+ * signalled is recorded as used. The default name is the one the speculator
18
+ * listens for (`DEFAULT_ESCALATION_TOOLS`). `createHybridTurnProducer` in
19
+ * `/chat-routes` mounts this tool with the turn's single box start.
19
20
  */
20
21
  import type { SandboxInstance } from '@tangle-network/sandbox';
21
22
  import type { TurnSpan, TurnTrace } from '../turn-trace/recorder';
@@ -10,7 +10,7 @@ import {
10
10
  runSignoff,
11
11
  runSurfaceLadderCli,
12
12
  runWorkspaceSurfaceCli
13
- } from "../chunk-N7WTF5P2.js";
13
+ } from "../chunk-XWJDF34U.js";
14
14
  import "../chunk-LRYY3OX7.js";
15
15
  import {
16
16
  invokedAsScript
@@ -41,7 +41,7 @@ import {
41
41
  runWorkspaceSurfaceCli,
42
42
  summarizeSurfacePage,
43
43
  surfaceDeltaL
44
- } from "../chunk-N7WTF5P2.js";
44
+ } from "../chunk-XWJDF34U.js";
45
45
  import "../chunk-LRYY3OX7.js";
46
46
  export {
47
47
  HEADER_TOP_TOLERANCE_PX,
@@ -314,7 +314,8 @@ export interface ChatComposerProps {
314
314
  /** Cmd/Ctrl+L focuses the input and shows the hint. Default true. */
315
315
  focusShortcut?: boolean;
316
316
  /** Called when focus enters the composer: the input or any of its controls.
317
- * Pass `useWorkspacePrewarm().reassert` so a box that suspended while the
317
+ * Default: the surrounding workspace shell's prewarm `reassert`
318
+ * (`AgentWorkspaceLayout` with `prewarm`), so a box that suspended while the
318
319
  * tab sat open starts resuming before the member sends. */
319
320
  onFocusWithin?: () => void;
320
321
  /** Float the card on a soft two-layer foreground-tinted shadow (opt-in).
@@ -105,7 +105,6 @@ import {
105
105
  recordGridFail,
106
106
  recordGridOk,
107
107
  recordGridRowLabel,
108
- requestWorkspacePrewarm,
109
108
  resolveChatInteraction,
110
109
  resolveProvenanceStanding,
111
110
  responseErrorMessage,
@@ -131,7 +130,6 @@ import {
131
130
  useFileMentions,
132
131
  useSmoothText,
133
132
  useThinkingSeconds,
134
- useWorkspacePrewarm,
135
133
  validateRecordGridCell,
136
134
  validateRecordGridRow,
137
135
  waterfallLayout,
@@ -143,7 +141,7 @@ import {
143
141
  withoutRecordGridCreated,
144
142
  withoutRecordGridRemoved,
145
143
  withoutRecordGridUpdate
146
- } from "../chunk-KNTRS7OZ.js";
144
+ } from "../chunk-BQILMP73.js";
147
145
  import {
148
146
  MENTION_PILL_CLASS
149
147
  } from "../chunk-3HUFJ5LO.js";
@@ -183,13 +181,19 @@ import {
183
181
  preloadWhenIdle,
184
182
  useComposerAttachments,
185
183
  useDictation
186
- } from "../chunk-2XUIWCRW.js";
184
+ } from "../chunk-DA5XLDZR.js";
187
185
  import "../chunk-L7MB2LLM.js";
188
186
  import {
189
187
  WorkspaceInitial,
190
188
  WorkspaceSwitcher
191
189
  } from "../chunk-GNBBY3KN.js";
192
190
  import "../chunk-A2GG4D4A.js";
191
+ import {
192
+ WorkspacePrewarmContext,
193
+ requestWorkspacePrewarm,
194
+ useWorkspacePrewarm,
195
+ useWorkspacePrewarmHandle
196
+ } from "../chunk-OXUBZ5SE.js";
193
197
  import {
194
198
  tabTerminalConnectionId,
195
199
  useSandboxTerminalConnection
@@ -403,6 +407,7 @@ export {
403
407
  WorkProductCard,
404
408
  WorkProductStatusPill,
405
409
  WorkspaceInitial,
410
+ WorkspacePrewarmContext,
406
411
  WorkspaceSwitcher,
407
412
  __resetAttachmentFileCacheForTests,
408
413
  acceptRejectionReason,
@@ -556,6 +561,7 @@ export {
556
561
  useSmoothText,
557
562
  useThinkingSeconds,
558
563
  useWorkspacePrewarm,
564
+ useWorkspacePrewarmHandle,
559
565
  validateRecordGridCell,
560
566
  validateRecordGridRow,
561
567
  waterfallLayout,
@@ -36,3 +36,10 @@ export interface WorkspacePrewarmHandle {
36
36
  export declare function requestWorkspacePrewarm(url: string, options?: WorkspacePrewarmRequestOptions): boolean;
37
37
  /** Prewarm `url` when the page opens or becomes visible; `reassert` on composer focus. */
38
38
  export declare function useWorkspacePrewarm(options: UseWorkspacePrewarmOptions): WorkspacePrewarmHandle;
39
+ /**
40
+ * The prewarm handle of the workspace shell around this component. `AgentWorkspaceLayout` provides it when the
41
+ * product passes `prewarm`; `ChatComposer` reasserts through it on focus unless the product passes its own
42
+ * `onFocusWithin`. Outside a shell that warms, `reassert` does nothing.
43
+ */
44
+ export declare const WorkspacePrewarmContext: import("react").Context<WorkspacePrewarmHandle | null>;
45
+ export declare function useWorkspacePrewarmHandle(): WorkspacePrewarmHandle | null;
@@ -1,5 +1,6 @@
1
1
  import { type SidebarLayoutNavItem, type SidebarLayoutProps } from '@tangle-network/sandbox-ui/dashboard';
2
2
  import type { ReactNode } from 'react';
3
+ import { type UseWorkspacePrewarmOptions } from '../web-react/workspace-prewarm';
3
4
  import type { WorkspaceAppRecord } from '../workspace-apps';
4
5
  import { type AgentProductIdentity, type AgentWorkspaceIdentity } from './rail-identity';
5
6
  import { type NavRouteDef, type RailPrefetch, type SessionRowActions, type SessionSummary } from '../session-shell';
@@ -93,6 +94,13 @@ export interface AgentWorkspaceLayoutProps extends Omit<SidebarLayoutProps, 'act
93
94
  hideBelow?: SidebarLayoutProps['hideBelow'];
94
95
  /** Show labels beside rail icons. Defaults to `true`. */
95
96
  railLabels?: SidebarLayoutProps['railLabels'];
97
+ /**
98
+ * Warm the open workspace: the shell posts to the product's prewarm route
99
+ * (`createWorkspacePrewarmRoute`) when the page opens in a visible tab, and
100
+ * every `ChatComposer` inside reasserts on focus. Pass the route's URL and
101
+ * whether this member may chat. Omit on pages with no workspace.
102
+ */
103
+ prewarm?: UseWorkspacePrewarmOptions;
96
104
  }
97
105
  /**
98
106
  * The default agent workspace composition.
@@ -105,7 +113,7 @@ export interface AgentWorkspaceLayoutProps extends Omit<SidebarLayoutProps, 'act
105
113
  * with `SessionHistoryPanel` and `EntryComposer` for the complete chat-first
106
114
  * structure.
107
115
  */
108
- export declare function AgentWorkspaceLayout({ children, navItems, sessions, apps, activeRoute, activeId, product, workspace, ...sidebarProps }: AgentWorkspaceLayoutProps): import("react").JSX.Element;
116
+ export declare function AgentWorkspaceLayout({ children, navItems, sessions, apps, activeRoute, activeId, product, workspace, prewarm, ...sidebarProps }: AgentWorkspaceLayoutProps): import("react").JSX.Element;
109
117
  export { AgentWorkspaceCompanion, createAgentWorkspaceCompanionTabs, type AgentWorkspaceCompanionHandle, type AgentWorkspaceCompanionProps, type AgentWorkspaceCompanionTab, type AgentWorkspaceCompanionTool, type AgentWorkspaceCompanionTools, type AgentWorkspaceCompanionNavigation } from './companion';
110
118
  export { WorkspaceSwitcher, type WorkspaceSwitcherItem, type WorkspaceSwitcherProps } from '../web-react/workspace-switcher';
111
119
  export { WorkspaceInitial } from '../web-react/workspace-switcher';
@@ -6,6 +6,10 @@ import {
6
6
  ActionDialog,
7
7
  ActionDialogButton
8
8
  } from "../chunk-A2GG4D4A.js";
9
+ import {
10
+ WorkspacePrewarmContext,
11
+ useWorkspacePrewarm
12
+ } from "../chunk-OXUBZ5SE.js";
9
13
  import {
10
14
  buildSessionNavItem,
11
15
  composeSidebarSessions,
@@ -821,8 +825,10 @@ function AgentWorkspaceLayout({
821
825
  activeId,
822
826
  product,
823
827
  workspace,
828
+ prewarm,
824
829
  ...sidebarProps
825
830
  }) {
831
+ const prewarmHandle = useWorkspacePrewarm(prewarm ?? { url: null });
826
832
  const sessionNav = sessions ? (() => {
827
833
  const composed = composeSidebarSessions({
828
834
  loaderSessions: sessions.sessions,
@@ -918,7 +924,7 @@ function AgentWorkspaceLayout({
918
924
  ...identityProps,
919
925
  ...sidebarProps
920
926
  };
921
- return /* @__PURE__ */ jsx4(
927
+ return /* @__PURE__ */ jsx4(WorkspacePrewarmContext.Provider, { value: prewarm ? prewarmHandle : null, children: /* @__PURE__ */ jsx4(
922
928
  SidebarLayout,
923
929
  {
924
930
  ...layoutProps,
@@ -926,7 +932,7 @@ function AgentWorkspaceLayout({
926
932
  activeId: activeAppId ? appGroup?.id : resolvedActiveId,
927
933
  children
928
934
  }
929
- );
935
+ ) });
930
936
  }
931
937
  export {
932
938
  AgentRailIdentity,