@tangle-network/agent-app 0.60.142 → 0.60.144

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.
@@ -121,9 +121,9 @@ export declare function createPublicConsultation(options: PublicConsultationOpti
121
121
  executionBudget?: ChatTurnExecutionLimits;
122
122
  maxOutputTokens?: number;
123
123
  }) => Promise<{
124
+ start?: undefined;
124
125
  status: 'unsupported';
125
126
  reason: string;
126
- start?: undefined;
127
127
  } | {
128
128
  reason?: undefined;
129
129
  status: 'prepared';
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Network budget for the browser checks (`shell-alignment`, `surface-ladder`,
3
+ * `workspace-surface`) when they run against a live site.
4
+ *
5
+ * Every Tangle app sits behind one Cloudflare zone that allows 1000 requests per
6
+ * 10 s per IP, and the fleet's Beelinks and workstation share one egress IP. On
7
+ * 2026-10-12 a production sweep of these checks sent 1533-1782 requests a minute:
8
+ * each page load pulled every asset, and Cloudflare's speculation rules made
9
+ * Chromium prerender every rail link as a hidden full page. It blocked a
10
+ * production canary on another app. So the checks:
11
+ *
12
+ * - launch Chromium with prerender and speculative prefetch off, and abort the
13
+ * zone's `/cdn-cgi/speculation` rules;
14
+ * - count every request a context makes and wait before a navigation whenever
15
+ * the last 10 s already holds `REQUEST_BUDGET_PER_10S`;
16
+ * - report the total and the busiest 10 s, so a run can be checked against the
17
+ * edge's own count.
18
+ */
19
+ import type { BrowserContext } from 'playwright';
20
+ /** Chromium flags that stop prerender and speculative prefetch of linked pages. */
21
+ export declare const QUIET_CHROMIUM_ARGS: readonly string[];
22
+ /** Requests per 10 s a check may send; a quarter of the shared zone limit. */
23
+ export declare const REQUEST_BUDGET_PER_10S = 250;
24
+ export interface NetworkCount {
25
+ /** Requests the browser sent during the run. */
26
+ readonly requests: number;
27
+ /** The most requests inside any 10 s window. */
28
+ readonly peak10s: number;
29
+ }
30
+ export interface RequestMeter {
31
+ /** Count one request. */
32
+ record(now?: number): void;
33
+ /** Resolve once the last 10 s holds fewer than the budget. */
34
+ pace(): Promise<void>;
35
+ count(): NetworkCount;
36
+ }
37
+ export declare function createRequestMeter(budget?: number, sleep?: (ms: number) => Promise<void>): RequestMeter;
38
+ /** Abort the zone's speculation rules and count every request the context sends. */
39
+ export declare function meterContext(context: BrowserContext, meter: RequestMeter): Promise<void>;
40
+ export declare function formatNetworkCount(count: NetworkCount): string;
@@ -6,7 +6,7 @@ import {
6
6
  runSignoff,
7
7
  runSurfaceLadderCli,
8
8
  runWorkspaceSurfaceCli
9
- } from "../chunk-NK3ZVZPP.js";
9
+ } from "../chunk-XAU3UN32.js";
10
10
  import {
11
11
  invokedAsScript
12
12
  } from "../chunk-C3CAYGGQ.js";
@@ -59,5 +59,6 @@ export { checkSurfaceLadder, collectSurfaceLadder, composite, contrastRatio, for
59
59
  export { parseSurfaceLadderArgs, runSurfaceLadderCli } from './surface-ladder-cli';
60
60
  export { checkWorkspaceSurface, collectWorkspaceSurface, formatWorkspaceSurfaceReport, judgeWorkspaceSurface, HEADER_TOP_TOLERANCE_PX, type WorkspaceSurfaceFinding, type WorkspaceSurfaceOptions, type WorkspaceSurfaceReport, type WorkspaceSurfaceSample, } from './workspace-surface';
61
61
  export { runWorkspaceSurfaceCli } from './workspace-surface-cli';
62
+ export { createRequestMeter, formatNetworkCount, meterContext, QUIET_CHROMIUM_ARGS, REQUEST_BUDGET_PER_10S, type NetworkCount, type RequestMeter, } from './browser-budget';
62
63
  export { checkWorkerDefaults, formatWorkerDefaults, WORKER_COMPATIBILITY_DATE_FLOOR, type WorkerDefaultsFinding, type WorkerDefaultsResult, } from './worker-defaults';
63
64
  export type { LoadedSignoffConfig, SignoffAttempt, SignoffConfig, SignoffConfigOrigin, SignoffEvent, SignoffHostFacts, SignoffInstallResult, SignoffInstallSpec, SignoffRepoFacts, SignoffReport, SignoffShuffleSpec, SignoffSource, SignoffStepResult, SignoffStepSpec, SignoffStepStatus, } from './types';
@@ -1,5 +1,7 @@
1
1
  import {
2
2
  HEADER_TOP_TOLERANCE_PX,
3
+ QUIET_CHROMIUM_ARGS,
4
+ REQUEST_BUDGET_PER_10S,
3
5
  SHELL_ALIGNMENT_TOLERANCE_PX,
4
6
  SURFACE_LADDER_MAX_WORDS,
5
7
  SURFACE_LADDER_MIN_BORDER_CONTRAST,
@@ -14,6 +16,8 @@ import {
14
16
  collectWorkspaceSurface,
15
17
  composite,
16
18
  contrastRatio,
19
+ createRequestMeter,
20
+ formatNetworkCount,
17
21
  formatShellAlignmentReport,
18
22
  formatSignoffReport,
19
23
  formatSurfaceLadderReport,
@@ -23,6 +27,7 @@ import {
23
27
  judgeSurfaceLadder,
24
28
  judgeWorkspaceSurface,
25
29
  loadSignoffConfig,
30
+ meterContext,
26
31
  oklchL,
27
32
  parseShellAlignmentArgs,
28
33
  parseSurfaceLadderArgs,
@@ -32,9 +37,11 @@ import {
32
37
  runWorkspaceSurfaceCli,
33
38
  summarizeSurfacePage,
34
39
  surfaceDeltaL
35
- } from "../chunk-NK3ZVZPP.js";
40
+ } from "../chunk-XAU3UN32.js";
36
41
  export {
37
42
  HEADER_TOP_TOLERANCE_PX,
43
+ QUIET_CHROMIUM_ARGS,
44
+ REQUEST_BUDGET_PER_10S,
38
45
  SHELL_ALIGNMENT_TOLERANCE_PX,
39
46
  SURFACE_LADDER_MAX_WORDS,
40
47
  SURFACE_LADDER_MIN_BORDER_CONTRAST,
@@ -49,6 +56,8 @@ export {
49
56
  collectWorkspaceSurface,
50
57
  composite,
51
58
  contrastRatio,
59
+ createRequestMeter,
60
+ formatNetworkCount,
52
61
  formatShellAlignmentReport,
53
62
  formatSignoffReport,
54
63
  formatSurfaceLadderReport,
@@ -58,6 +67,7 @@ export {
58
67
  judgeSurfaceLadder,
59
68
  judgeWorkspaceSurface,
60
69
  loadSignoffConfig,
70
+ meterContext,
61
71
  oklchL,
62
72
  parseShellAlignmentArgs,
63
73
  parseSurfaceLadderArgs,
@@ -11,6 +11,7 @@
11
11
  * The browser half (`collectShellDividers`) only reads geometry; the decision
12
12
  * (`judgeShellAlignment`) is a pure function so it is unit-tested without a browser.
13
13
  */
14
+ import { type NetworkCount } from './browser-budget';
14
15
  /** A horizontal divider: the bottom border of a top-anchored row. Coordinates in CSS px. */
15
16
  export interface ShellDivider {
16
17
  readonly label: string;
@@ -73,6 +74,8 @@ export interface ShellAlignmentOptions {
73
74
  readonly readySelector?: string;
74
75
  }
75
76
  export interface ShellAlignmentReport {
77
+ /** Requests the run sent and its busiest 10 s (see browser-budget.ts). */
78
+ readonly network?: NetworkCount;
76
79
  readonly samples: readonly ShellDividerSample[];
77
80
  readonly findings: readonly ShellAlignmentFinding[];
78
81
  readonly maxOffsetPx: number;
@@ -24,6 +24,7 @@
24
24
  * the decision (`judgeSurfaceLadder`) and the color math are pure functions, so
25
25
  * they are unit-tested without a browser.
26
26
  */
27
+ import { type NetworkCount } from './browser-budget';
27
28
  /** sRGB channels 0–255. */
28
29
  export type Rgb = readonly [number, number, number];
29
30
  /** sRGB channels 0–255 plus alpha 0–1. */
@@ -130,6 +131,8 @@ export interface SurfacePageSummary {
130
131
  readonly medianCardWords: number | null;
131
132
  }
132
133
  export interface SurfaceLadderReport {
134
+ /** Requests the run sent and its busiest 10 s (see browser-budget.ts). */
135
+ readonly network?: NetworkCount;
133
136
  readonly samples: readonly SurfaceSample[];
134
137
  readonly pages: readonly SurfacePageSummary[];
135
138
  readonly findings: readonly SurfaceFinding[];
@@ -10,6 +10,7 @@
10
10
  * the rendered page, so a wrapper that only looks right in the source cannot
11
11
  * pass it.
12
12
  */
13
+ import { type NetworkCount } from './browser-budget';
13
14
  export interface WorkspaceSurfaceSample {
14
15
  readonly route: string;
15
16
  readonly width: number;
@@ -43,6 +44,8 @@ export interface WorkspaceSurfaceOptions {
43
44
  readonly readySelector?: string;
44
45
  }
45
46
  export interface WorkspaceSurfaceReport {
47
+ /** Requests the run sent and its busiest 10 s (see browser-budget.ts). */
48
+ readonly network?: NetworkCount;
46
49
  readonly samples: readonly WorkspaceSurfaceSample[];
47
50
  readonly findings: readonly WorkspaceSurfaceFinding[];
48
51
  }
@@ -45,6 +45,10 @@ export interface ChatStreamCallbacks {
45
45
  onIntent?: (intent: TurnIntentData) => void;
46
46
  onText?: (delta: string) => void;
47
47
  onReasoning?: (delta: string) => void;
48
+ /** The message's reasoning so far, when it started and when it ended, after every reasoning delta and once
49
+ * when thinking ends. Spread it onto `ReasoningRow`. `consumeChatStream` and `streamChatTurn` keep it;
50
+ * a consumer that calls `dispatchChatStreamLine` itself wraps its callbacks with `trackChatReasoning`. */
51
+ onReasoningState?: (state: ChatReasoningState) => void;
48
52
  onToolCall?: (call: ChatStreamToolCall) => void;
49
53
  onToolResult?: (result: ChatStreamToolResult) => void;
50
54
  onUsage?: (usage: {
@@ -79,6 +83,51 @@ export interface ChatStreamCallbacks {
79
83
  /** A durable-plan snapshot from any plan lifecycle event. */
80
84
  onPlan?: (plan: ChatPlan) => void;
81
85
  }
86
+ /**
87
+ * One message's reasoning as the stream delivers it: the text so far, when the
88
+ * model started reasoning and when it stopped. Its fields are `ReasoningRow`'s
89
+ * props. Live state comes from `onReasoningState`; a saved message's comes from
90
+ * `chatReasoningFromParts`.
91
+ */
92
+ export interface ChatReasoningState {
93
+ text: string;
94
+ /** Epoch ms of the first reasoning delta. Absent only on history saved without times. */
95
+ startedAt?: number;
96
+ /** Epoch ms the reasoning ended: the answer's first text, an error, or the end of the turn. */
97
+ endedAt?: number;
98
+ /** Reasoning deltas are still arriving and nothing has ended them yet. */
99
+ thinking: boolean;
100
+ }
101
+ /** Callbacks that keep the turn's reasoning state, plus the two moments only the transport knows. */
102
+ export type TrackedChatStreamCallbacks = ChatStreamCallbacks & {
103
+ /** The turn's stream is over, or failed for good: thinking that is still open ends now. */
104
+ end: () => void;
105
+ /** The stream will replay the turn from its first event (a resume from 0): the text is rebuilt from the
106
+ * replay, and the start time of the first delta is kept, so "Thought for N seconds" still counts from it. */
107
+ replay: () => void;
108
+ };
109
+ /**
110
+ * Keep one turn's reasoning state from its stream: the first reasoning delta
111
+ * starts the clock, the answer's first text, an error or `end()` stops it, and
112
+ * every change reaches `callbacks.onReasoningState`. Reasoning that resumes
113
+ * after a tool call or an answer continues the same state as a new paragraph,
114
+ * the way a reload joins the turn's saved reasoning parts.
115
+ *
116
+ * It takes callbacks, not a stream, so it is the entry point for any
117
+ * transport: `streamChatTurn` and `consumeChatStream` apply it themselves; an
118
+ * app that dispatches lines one at a time (`dispatchChatStreamLine`) or reads
119
+ * its own frames (a Durable Object's live parts, server-side events) wraps its
120
+ * handlers with it, feeds `onReasoning` / `onText` / `onToolCall`, and calls
121
+ * `end()` when its stream closes.
122
+ */
123
+ export declare function trackChatReasoning(callbacks: ChatStreamCallbacks, now?: () => number): TrackedChatStreamCallbacks;
124
+ /**
125
+ * A saved message's reasoning, settled, from its persisted parts: every
126
+ * `{ type: 'reasoning', text, time }` part joined in order, from the first
127
+ * part's start to the last part's end. A reload shows it collapsed with how
128
+ * long the model thought. Undefined when the message has no reasoning text.
129
+ */
130
+ export declare function chatReasoningFromParts(parts: ReadonlyArray<unknown> | null | undefined): ChatReasoningState | undefined;
82
131
  /** Represent the result of consuming a chat stream including turn ID and content reception status */
83
132
  export interface ConsumeChatStreamResult {
84
133
  turnId: string | null;
@@ -3,7 +3,7 @@
3
3
  * every agent app's web UI hand-rolls: a model picker over the runtime's
4
4
  * model catalogue, a reasoning-effort selector, and a message thread with
5
5
  * User/Agent identity, per-message model + cost + tokens/sec metrics,
6
- * canonical tool rows, and a collapsible thinking section.
6
+ * canonical tool rows, and the shared reasoning row (`ReasoningRow`).
7
7
  *
8
8
  * Works for BOTH chat shapes: router-backed copilots (LoopEvents from
9
9
  * `runtime/openai-stream`) and sandbox-backed chats — the thread renders
@@ -30,6 +30,7 @@ import type { WorkProductPersistedPart } from '../work-product/types';
30
30
  import type { TurnPhaseData } from '../chat-routes/turn-progress';
31
31
  export * from './chat-stream';
32
32
  export { TurnProgress, type TurnProgressProps } from './turn-progress';
33
+ export { ReasoningRow, type ReasoningRowProps } from './reasoning-row';
33
34
  export * from './chat-interactions';
34
35
  export * from './chat-composer';
35
36
  export * from './workspace-prewarm';
@@ -157,7 +158,12 @@ export interface ChatUiMessage extends ChatMessageMetrics {
157
158
  id: string;
158
159
  role: 'user' | 'assistant' | 'system';
159
160
  content: string;
161
+ /** The model's reasoning for this message, shown in a {@link ReasoningRow} above the answer. */
160
162
  reasoning?: string;
163
+ /** When the model started reasoning (epoch ms): `ChatReasoningState.startedAt` from the stream or the saved parts. */
164
+ reasoningStartedAt?: number;
165
+ /** When the reasoning ended (epoch ms). Set, the row reads "Thought for N seconds"; unset while streaming, it is still thinking. */
166
+ reasoningEndedAt?: number;
161
167
  toolCalls?: ChatToolCallInfo[];
162
168
  /** Ordered text/tool sequence for true chronological interleaving. When
163
169
  * present and non-empty it is rendered in place of `content` + `toolCalls`;
@@ -291,10 +297,10 @@ export type ToolDetailRenderers = Record<string, (call: ChatToolCallInfo, messag
291
297
  * so `state.time` stays unset and the row shows no duration.
292
298
  */
293
299
  export declare function chatToolCallPart(call: ChatToolCallInfo): ToolPart;
294
- /** Whole seconds elapsed while `active`, ticking once a second. Powers the live
295
- * "thinking" timers (the pre-first-token row and the reasoning box) so a long
296
- * thinking gap shows progress instead of a frozen label. Counts from when
297
- * `active` first turns true; freezes when it clears. */
300
+ /** Whole seconds elapsed while `active`, ticking once a second; counts from
301
+ * when `active` first turns true and freezes when it clears. Kept for
302
+ * existing consumers: `ReasoningRow` times reasoning from the stream's own
303
+ * start instead. */
298
304
  export declare function useThinkingSeconds(active: boolean): number;
299
305
  /**
300
306
  * The message thread: one centered column; user messages are right-aligned
@@ -37,6 +37,7 @@ import {
37
37
  ProvenanceLegend,
38
38
  ProvenanceValue,
39
39
  QuestionOptionList,
40
+ ReasoningRow,
40
41
  RecordGrid,
41
42
  RunDrillIn,
42
43
  SeatPaywall,
@@ -46,6 +47,7 @@ import {
46
47
  activityTone,
47
48
  buildAnswerData,
48
49
  cancelChatInteraction,
50
+ chatReasoningFromParts,
49
51
  chatToolCallPart,
50
52
  consumeChatStream,
51
53
  createDurableInteractionAnswerSubmitter,
@@ -119,6 +121,7 @@ import {
119
121
  streamChatTurn,
120
122
  sumRecordGridColumn,
121
123
  terminalizePendingChatInteractions,
124
+ trackChatReasoning,
122
125
  triggerAttachmentDownload,
123
126
  upsertChatInteraction,
124
127
  useChatInteractions,
@@ -138,7 +141,7 @@ import {
138
141
  withoutRecordGridCreated,
139
142
  withoutRecordGridRemoved,
140
143
  withoutRecordGridUpdate
141
- } from "../chunk-EGEULRT2.js";
144
+ } from "../chunk-T4JJXUJI.js";
142
145
  import {
143
146
  SessionHistoryPanel,
144
147
  formatSessionTimestamp,
@@ -369,6 +372,7 @@ export {
369
372
  ProviderLogo,
370
373
  QualityCheckList,
371
374
  QuestionOptionList,
375
+ ReasoningRow,
372
376
  RecordGrid,
373
377
  ReviewQueuePanel,
374
378
  RouteChunkBoundary,
@@ -402,6 +406,7 @@ export {
402
406
  canTransitionInteractionStatus,
403
407
  cancelChatInteraction,
404
408
  cancelStatusFor,
409
+ chatReasoningFromParts,
405
410
  chatToolCallPart,
406
411
  chatTurnRequestInit,
407
412
  composerAnswerData,
@@ -521,6 +526,7 @@ export {
521
526
  sumRecordGridColumn,
522
527
  tabTerminalConnectionId,
523
528
  terminalizePendingChatInteractions,
529
+ trackChatReasoning,
524
530
  triggerAttachmentDownload,
525
531
  upsertChatInteraction,
526
532
  useChatInteractions,
@@ -0,0 +1,34 @@
1
+ /**
2
+ * The reasoning row every agent app shows above an answer. While the model
3
+ * reasons, its reasoning streams in live under "Thinking · 12s"; when the
4
+ * answer starts the row collapses to "Thought for 12 seconds", and a click
5
+ * opens it again. It renders nothing when the turn has no reasoning.
6
+ *
7
+ * The props are a `ChatReasoningState` (`./chat-stream`): spread the state the
8
+ * stream keeps (`onReasoningState`), or a saved message's
9
+ * (`chatReasoningFromParts`), onto the row. `ChatMessages` renders it for
10
+ * every assistant message that carries `reasoning`.
11
+ *
12
+ * It is built on the shared run-row shell (`RunRowShell` from
13
+ * `@tangle-network/ui/run`), so it reads as one family with the tool rows, and
14
+ * styles only with the shared design tokens.
15
+ */
16
+ import { type ReactNode } from 'react';
17
+ /** Props for {@link ReasoningRow}: the fields of a `ChatReasoningState`, plus presentation. */
18
+ export interface ReasoningRowProps {
19
+ /** The reasoning so far. While it is blank the row renders nothing. */
20
+ text: string;
21
+ /** When the model started reasoning (epoch ms). The live timer counts from here; without it, from when the row first saw the model thinking. */
22
+ startedAt?: number;
23
+ /** When the reasoning ended (epoch ms). With `startedAt`, the settled row reads "Thought for N seconds". */
24
+ endedAt?: number;
25
+ /** The model is still reasoning. Defaults to true while `startedAt` is set and `endedAt` is not. */
26
+ thinking?: boolean;
27
+ /** Open a settled row. Default false: once thinking ends the row is collapsed until the reader opens it. */
28
+ defaultOpen?: boolean;
29
+ /** Render the reasoning text. Default: the shared markdown renderer. */
30
+ renderText?: (text: string) => ReactNode;
31
+ className?: string;
32
+ }
33
+ /** The model's reasoning for one message: live while it thinks, collapsed once it answers. */
34
+ export declare function ReasoningRow({ text, startedAt, endedAt, thinking: thinkingProp, defaultOpen, renderText, className, }: ReasoningRowProps): import("react").JSX.Element | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-app",
3
- "version": "0.60.142",
3
+ "version": "0.60.144",
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": [