@opengeni/react 3.3.2 → 3.7.0-canary.0
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/dist/artifacts.d.ts +1 -1
- package/dist/artifacts.js +241 -18
- package/dist/artifacts.js.map +1 -1
- package/dist/{browser-viewer-MKKFRRRV.js → browser-viewer-E5DDEFQ4.js} +3 -3
- package/dist/{chunk-2DZVYHVO.js → chunk-4JFUT22W.js} +39 -13
- package/dist/chunk-4JFUT22W.js.map +1 -0
- package/dist/{chunk-ELIYWBZR.js → chunk-BV5A4OTE.js} +4 -4
- package/dist/{chunk-3AGBGTRT.js → chunk-C6WDLHBA.js} +148 -26
- package/dist/chunk-C6WDLHBA.js.map +1 -0
- package/dist/{chunk-YG4QEQF5.js → chunk-DOK4KZF2.js} +7863 -7736
- package/dist/chunk-DOK4KZF2.js.map +1 -0
- package/dist/{chunk-JAQ5K7W6.js → chunk-FJBOU2TH.js} +167 -58
- package/dist/chunk-FJBOU2TH.js.map +1 -0
- package/dist/{chunk-XYRDDSXF.js → chunk-R55HFTT3.js} +80 -34
- package/dist/chunk-R55HFTT3.js.map +1 -0
- package/dist/{chunk-ZPBTI3TE.js → chunk-W2RGYBCV.js} +4 -4
- package/dist/{chunk-WSK7G5LE.js → chunk-W3OUAH6M.js} +80 -80
- package/dist/chunk-W3OUAH6M.js.map +1 -0
- package/dist/{chunk-X4A66EWZ.js → chunk-WMGF4Z7X.js} +41 -43
- package/dist/chunk-WMGF4Z7X.js.map +1 -0
- package/dist/client.d.ts +1 -1
- package/dist/components/artifacts/index.d.ts +1 -1
- package/dist/components/artifacts/published-html-artifact-frame.d.ts +45 -3
- package/dist/components/composer.d.ts +2 -0
- package/dist/components/session-chrome.d.ts +1 -1
- package/dist/composer.js +4 -4
- package/dist/{computer-viewer-FWEZISW4.js → computer-viewer-7TEZC6Y2.js} +3 -3
- package/dist/{fleet-decision-row-GGCAT4E4.js → fleet-decision-row-YZ3ZKWMM.js} +2 -1
- package/dist/fleet-decision-row-YZ3ZKWMM.js.map +1 -0
- package/dist/hooks/use-file-attachments.d.ts +8 -0
- package/dist/hooks/use-sandbox-files.d.ts +4 -1
- package/dist/hooks/use-session-events.d.ts +1 -1
- package/dist/hooks/use-workspace-edit.d.ts +4 -0
- package/dist/index.js +195 -141
- package/dist/index.js.map +1 -1
- package/dist/interaction.js +3 -3
- package/dist/model-policy.d.ts +2 -1
- package/dist/model-policy.js +1 -1
- package/dist/{queue-surface-implementation-BSKUWHRI.js → queue-surface-implementation-XL2A6PBM.js} +2 -2
- package/dist/realtime.js +2 -2
- package/dist/session-ui.js +6 -6
- package/dist/session.js +4 -4
- package/dist/timeline/registry.d.ts +2 -0
- package/dist/timeline/types.d.ts +3 -1
- package/package.json +2 -2
- package/src/artifacts.ts +3 -0
- package/src/client.ts +2 -1
- package/src/components/artifacts/index.ts +3 -0
- package/src/components/artifacts/published-html-artifact-frame.tsx +284 -4
- package/src/components/composer.tsx +103 -29
- package/src/components/message-timeline.tsx +48 -10
- package/src/components/model-policy-picker.tsx +37 -10
- package/src/components/sandbox-workspace.tsx +18 -7
- package/src/components/session-chrome.tsx +3 -3
- package/src/hooks/use-file-attachments.ts +62 -2
- package/src/hooks/use-sandbox-files.ts +68 -20
- package/src/hooks/use-session-events.ts +176 -21
- package/src/hooks/use-workspace-edit.ts +23 -5
- package/src/model-policy.ts +48 -53
- package/src/timeline/fleet-decision-projection.ts +2 -1
- package/src/timeline/fleet-decision-row.tsx +1 -0
- package/src/timeline/projection.ts +157 -8
- package/src/timeline/registry.ts +15 -3
- package/src/timeline/tool-renderers.tsx +117 -1
- package/src/timeline/types.ts +10 -1
- package/styles/compiled.css +5 -0
- package/dist/chunk-2DZVYHVO.js.map +0 -1
- package/dist/chunk-3AGBGTRT.js.map +0 -1
- package/dist/chunk-JAQ5K7W6.js.map +0 -1
- package/dist/chunk-WSK7G5LE.js.map +0 -1
- package/dist/chunk-X4A66EWZ.js.map +0 -1
- package/dist/chunk-XYRDDSXF.js.map +0 -1
- package/dist/chunk-YG4QEQF5.js.map +0 -1
- package/dist/fleet-decision-row-GGCAT4E4.js.map +0 -1
- /package/dist/{browser-viewer-MKKFRRRV.js.map → browser-viewer-E5DDEFQ4.js.map} +0 -0
- /package/dist/{chunk-ELIYWBZR.js.map → chunk-BV5A4OTE.js.map} +0 -0
- /package/dist/{chunk-ZPBTI3TE.js.map → chunk-W2RGYBCV.js.map} +0 -0
- /package/dist/{computer-viewer-FWEZISW4.js.map → computer-viewer-7TEZC6Y2.js.map} +0 -0
- /package/dist/{queue-surface-implementation-BSKUWHRI.js.map → queue-surface-implementation-XL2A6PBM.js.map} +0 -0
package/src/model-policy.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
compareModelPickerOrder,
|
|
3
|
+
modelPickerBillingClassFor,
|
|
4
|
+
type ModelPickerBillingClass,
|
|
5
|
+
} from "@opengeni/sdk/model-picker-order";
|
|
1
6
|
import type { ClientModel, ReasoningEffort, WorkspaceModelCatalogModel } from "@opengeni/sdk";
|
|
2
7
|
|
|
3
|
-
export type PickerBillingClass =
|
|
4
|
-
| "opengeni_credits"
|
|
5
|
-
| "external"
|
|
6
|
-
| "codex_subscription"
|
|
7
|
-
| "supergrok_subscription"
|
|
8
|
-
| "byok";
|
|
8
|
+
export type PickerBillingClass = ModelPickerBillingClass;
|
|
9
9
|
|
|
10
10
|
export type PickerModelRow<TCatalog extends ClientModel = WorkspaceModelCatalogModel> = {
|
|
11
11
|
id: string;
|
|
@@ -23,20 +23,13 @@ export type PickerModelRow<TCatalog extends ClientModel = WorkspaceModelCatalogM
|
|
|
23
23
|
|
|
24
24
|
export type LatencyModeId = "standard" | "priority" | "fast";
|
|
25
25
|
|
|
26
|
-
const BILLING_CLASS_ORDER: PickerBillingClass[] = [
|
|
27
|
-
"opengeni_credits",
|
|
28
|
-
"external",
|
|
29
|
-
"codex_subscription",
|
|
30
|
-
"supergrok_subscription",
|
|
31
|
-
"byok",
|
|
32
|
-
];
|
|
33
|
-
|
|
34
26
|
const BILLING_CLASS_LABELS: Record<PickerBillingClass, string> = {
|
|
35
27
|
opengeni_credits: "OpenGeni",
|
|
36
28
|
external: "External",
|
|
37
29
|
codex_subscription: "Codex",
|
|
38
30
|
supergrok_subscription: "SuperGrok",
|
|
39
|
-
byok: "
|
|
31
|
+
byok: "Workspace providers",
|
|
32
|
+
organization_byok: "Organization providers",
|
|
40
33
|
};
|
|
41
34
|
|
|
42
35
|
const AVAILABILITY_REASON_LABELS: Record<string, string> = {
|
|
@@ -50,33 +43,13 @@ const AVAILABILITY_REASON_LABELS: Record<string, string> = {
|
|
|
50
43
|
};
|
|
51
44
|
|
|
52
45
|
export function billingClassForModel(model: ClientModel): PickerBillingClass {
|
|
53
|
-
if (model.
|
|
54
|
-
return "
|
|
55
|
-
}
|
|
56
|
-
if (model.source === "supergrok") {
|
|
57
|
-
return "supergrok_subscription";
|
|
46
|
+
if (model.provider === "organization-gateway" || model.provider === "organization-openrouter") {
|
|
47
|
+
return "organization_byok";
|
|
58
48
|
}
|
|
59
|
-
if (model.
|
|
60
|
-
return "codex_subscription";
|
|
61
|
-
}
|
|
62
|
-
if (model.source === "workspace_gateway") {
|
|
49
|
+
if (model.provider === "workspace-gateway" || model.provider === "workspace-openrouter") {
|
|
63
50
|
return "byok";
|
|
64
51
|
}
|
|
65
|
-
|
|
66
|
-
return model.credentialSource.provider === "xai"
|
|
67
|
-
? "supergrok_subscription"
|
|
68
|
-
: "codex_subscription";
|
|
69
|
-
}
|
|
70
|
-
if (model.credentialSource?.kind === "workspace_connection") {
|
|
71
|
-
return "byok";
|
|
72
|
-
}
|
|
73
|
-
if (model.billing?.upstreamPayer === "connected_subscription") {
|
|
74
|
-
return "codex_subscription";
|
|
75
|
-
}
|
|
76
|
-
if (model.billing?.upstreamPayer === "workspace") {
|
|
77
|
-
return "byok";
|
|
78
|
-
}
|
|
79
|
-
return "opengeni_credits";
|
|
52
|
+
return modelPickerBillingClassFor(model);
|
|
80
53
|
}
|
|
81
54
|
|
|
82
55
|
export function billingClassLabel(billingClass: PickerBillingClass): string {
|
|
@@ -144,6 +117,23 @@ export function labelReasoningEffort(effort: ReasoningEffort): string {
|
|
|
144
117
|
}
|
|
145
118
|
|
|
146
119
|
export function payerSummaryForModel(model: ClientModel): string {
|
|
120
|
+
if (model.cost === "free") {
|
|
121
|
+
return "Free in this deployment";
|
|
122
|
+
}
|
|
123
|
+
if (model.cost === "credits") {
|
|
124
|
+
return "OpenGeni credits";
|
|
125
|
+
}
|
|
126
|
+
if (model.cost === "subscription") {
|
|
127
|
+
return model.source === "supergrok"
|
|
128
|
+
? "SuperGrok subscription · external billing"
|
|
129
|
+
: "Codex subscription · external billing";
|
|
130
|
+
}
|
|
131
|
+
if (model.cost === "workspace") {
|
|
132
|
+
return workspaceProviderPayerSummary(model);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Older client-config payloads do not carry `cost`; preserve their existing
|
|
136
|
+
// settlement-derived label until every deployment has rolled forward.
|
|
147
137
|
const billing = model.billing;
|
|
148
138
|
if (!billing) {
|
|
149
139
|
return "Route unknown";
|
|
@@ -157,7 +147,7 @@ export function payerSummaryForModel(model: ClientModel): string {
|
|
|
157
147
|
: "Codex subscription · external billing";
|
|
158
148
|
}
|
|
159
149
|
if (billing.upstreamPayer === "workspace") {
|
|
160
|
-
return
|
|
150
|
+
return workspaceProviderPayerSummary(model);
|
|
161
151
|
}
|
|
162
152
|
return "External provider · no OpenGeni credits";
|
|
163
153
|
}
|
|
@@ -175,7 +165,13 @@ export function advancedSourceSummary(model: ClientModel): string | null {
|
|
|
175
165
|
: "Connected Codex subscription";
|
|
176
166
|
}
|
|
177
167
|
if (source.kind === "workspace_connection") {
|
|
178
|
-
|
|
168
|
+
if (model.provider === "workspace-openrouter") {
|
|
169
|
+
return "Workspace OpenRouter connection";
|
|
170
|
+
}
|
|
171
|
+
if (model.provider === "workspace-gateway" || model.source === "workspace_gateway") {
|
|
172
|
+
return "Workspace Vercel AI Gateway";
|
|
173
|
+
}
|
|
174
|
+
return "Workspace provider connection";
|
|
179
175
|
}
|
|
180
176
|
if (source.kind === "deployment") {
|
|
181
177
|
return source.mechanism === "azure_ad_bearer"
|
|
@@ -185,6 +181,16 @@ export function advancedSourceSummary(model: ClientModel): string | null {
|
|
|
185
181
|
return null;
|
|
186
182
|
}
|
|
187
183
|
|
|
184
|
+
function workspaceProviderPayerSummary(model: ClientModel): string {
|
|
185
|
+
if (model.provider === "workspace-openrouter") {
|
|
186
|
+
return "Billed to the workspace OpenRouter account";
|
|
187
|
+
}
|
|
188
|
+
if (model.provider === "workspace-gateway" || model.source === "workspace_gateway") {
|
|
189
|
+
return "Billed to the workspace Vercel account";
|
|
190
|
+
}
|
|
191
|
+
return "Billed to the workspace provider account";
|
|
192
|
+
}
|
|
193
|
+
|
|
188
194
|
export function projectPickerRows(models: WorkspaceModelCatalogModel[]): PickerModelRow[] {
|
|
189
195
|
return models
|
|
190
196
|
.filter((catalog) => {
|
|
@@ -232,18 +238,7 @@ export function projectClientModelRows(models: ClientModel[]): PickerModelRow<Cl
|
|
|
232
238
|
export function sortPickerRows<TCatalog extends ClientModel>(
|
|
233
239
|
rows: PickerModelRow<TCatalog>[],
|
|
234
240
|
): PickerModelRow<TCatalog>[] {
|
|
235
|
-
return [...rows].sort(
|
|
236
|
-
const classDelta =
|
|
237
|
-
BILLING_CLASS_ORDER.indexOf(left.billingClass) -
|
|
238
|
-
BILLING_CLASS_ORDER.indexOf(right.billingClass);
|
|
239
|
-
if (classDelta !== 0) {
|
|
240
|
-
return classDelta;
|
|
241
|
-
}
|
|
242
|
-
if (left.selectable !== right.selectable) {
|
|
243
|
-
return left.selectable ? -1 : 1;
|
|
244
|
-
}
|
|
245
|
-
return left.label.localeCompare(right.label);
|
|
246
|
-
});
|
|
241
|
+
return [...rows].sort(compareModelPickerOrder);
|
|
247
242
|
}
|
|
248
243
|
|
|
249
244
|
export function findPickerRow<TCatalog extends ClientModel>(
|
|
@@ -8,6 +8,7 @@ const FLEET_ACTUAL_REASONS = [
|
|
|
8
8
|
"rotation",
|
|
9
9
|
"active",
|
|
10
10
|
"all_capped",
|
|
11
|
+
"allocator_disabled",
|
|
11
12
|
"none",
|
|
12
13
|
] as const;
|
|
13
14
|
const FLEET_SHADOW_OUTCOMES = ["selected", "paced", "none"] as const;
|
|
@@ -334,7 +335,7 @@ function fleetDecisionSemanticsAreConsistent(input: {
|
|
|
334
335
|
input.actualOutcome === "selected"
|
|
335
336
|
? ["lease_reused", "pin", "rotation", "active"].includes(input.actualReason)
|
|
336
337
|
: input.actualOutcome === "waiting"
|
|
337
|
-
? input.actualReason
|
|
338
|
+
? ["all_capped", "allocator_disabled"].includes(input.actualReason)
|
|
338
339
|
: input.actualReason === "none";
|
|
339
340
|
const shadowConsistent =
|
|
340
341
|
input.shadowOutcome === "selected"
|
|
@@ -28,6 +28,7 @@ const FLEET_ACTUAL_REASON_LABEL: Record<FleetDecisionItem["actualReason"], strin
|
|
|
28
28
|
rotation: "Rotated for capacity",
|
|
29
29
|
active: "Used the active subscription",
|
|
30
30
|
all_capped: "All observed subscriptions were capped",
|
|
31
|
+
allocator_disabled: "The policy-selected subscription was disabled for new allocations",
|
|
31
32
|
none: "No production candidate was selected",
|
|
32
33
|
};
|
|
33
34
|
|
|
@@ -58,6 +58,8 @@ const WORKER_SPAWN_TOOL = "session_create";
|
|
|
58
58
|
const WORKER_MESSAGE_TOOL = "session_send_message";
|
|
59
59
|
const WORKER_FAILURE_CODE_MAX_LENGTH = 128;
|
|
60
60
|
const WORKER_FAILURE_MESSAGE_MAX_UTF8_BYTES = 1_024;
|
|
61
|
+
type PendingWaitOutcome = { id: string; reason: string; occurredAt: string };
|
|
62
|
+
type TrackedAgentResponse = { item: AgentMessageItem; completed: boolean };
|
|
61
63
|
|
|
62
64
|
/**
|
|
63
65
|
* Tools whose durable side-effect events already own the timeline (MemoryRow).
|
|
@@ -131,6 +133,8 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
|
|
|
131
133
|
const items: TimelineItem[] = [];
|
|
132
134
|
const prescan = prescanTurnAnchors(events);
|
|
133
135
|
const ordered = orderTimelineEvents(events, prescan);
|
|
136
|
+
const pendingWaitOutcomeByTurn = new Map<string | null, PendingWaitOutcome>();
|
|
137
|
+
const latestAgentResponseByTurn = new Map<string | null, TrackedAgentResponse>();
|
|
134
138
|
const humanInputRequests = humanInputRequestsById(events);
|
|
135
139
|
const humanInputToolCallIds = new Set(
|
|
136
140
|
[...humanInputRequests.values()]
|
|
@@ -220,6 +224,31 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
|
|
|
220
224
|
|
|
221
225
|
const last = (): TimelineItem | undefined => items[items.length - 1];
|
|
222
226
|
|
|
227
|
+
const rememberAgentResponse = (
|
|
228
|
+
turnId: string | null,
|
|
229
|
+
item: AgentMessageItem,
|
|
230
|
+
completed: boolean,
|
|
231
|
+
): void => {
|
|
232
|
+
latestAgentResponseByTurn.set(turnId, { item, completed });
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
const takePendingWaitOutcome = (turnId: string | null): PendingWaitOutcome | undefined => {
|
|
236
|
+
const outcome = pendingWaitOutcomeByTurn.get(turnId);
|
|
237
|
+
pendingWaitOutcomeByTurn.delete(turnId);
|
|
238
|
+
return outcome;
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
const takeAgentResponse = (turnId: string | null): TrackedAgentResponse | undefined => {
|
|
242
|
+
const response = latestAgentResponseByTurn.get(turnId);
|
|
243
|
+
latestAgentResponseByTurn.delete(turnId);
|
|
244
|
+
return response;
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
const clearUnscopedTerminalTracking = (): void => {
|
|
248
|
+
latestAgentResponseByTurn.delete(null);
|
|
249
|
+
pendingWaitOutcomeByTurn.delete(null);
|
|
250
|
+
};
|
|
251
|
+
|
|
223
252
|
/** A new item of a different kind ends whatever was streaming at the tail. */
|
|
224
253
|
const closeStreamingTail = (): void => {
|
|
225
254
|
const open = last();
|
|
@@ -298,6 +327,7 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
|
|
|
298
327
|
case "user.message": {
|
|
299
328
|
// A steering message must not mark in-flight tools complete; it only
|
|
300
329
|
// ends whatever text was streaming. Turn lifecycle events finalize.
|
|
330
|
+
clearUnscopedTerminalTracking();
|
|
301
331
|
closeStreamingTail();
|
|
302
332
|
const childCompletion = workerCompletionPayload(payload.childCompletion);
|
|
303
333
|
if (childCompletion) {
|
|
@@ -381,17 +411,20 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
|
|
|
381
411
|
const open = last();
|
|
382
412
|
if (open?.kind === "agent-message" && open.streaming && open.turnId === turnId) {
|
|
383
413
|
open.text += text;
|
|
414
|
+
rememberAgentResponse(turnId, open, false);
|
|
384
415
|
break;
|
|
385
416
|
}
|
|
386
417
|
closeStreamingTail();
|
|
387
|
-
|
|
418
|
+
const item: AgentMessageItem = {
|
|
388
419
|
kind: "agent-message",
|
|
389
420
|
id: event.id,
|
|
390
421
|
turnId,
|
|
391
422
|
text,
|
|
392
423
|
streaming: true,
|
|
393
424
|
occurredAt: event.occurredAt,
|
|
394
|
-
}
|
|
425
|
+
};
|
|
426
|
+
items.push(item);
|
|
427
|
+
rememberAgentResponse(turnId, item, false);
|
|
395
428
|
break;
|
|
396
429
|
}
|
|
397
430
|
|
|
@@ -447,10 +480,11 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
|
|
|
447
480
|
items.splice(openIndex, 1);
|
|
448
481
|
items.push(open);
|
|
449
482
|
}
|
|
483
|
+
rememberAgentResponse(turnId, open, true);
|
|
450
484
|
break;
|
|
451
485
|
}
|
|
452
486
|
if (text) {
|
|
453
|
-
|
|
487
|
+
const item: AgentMessageItem = {
|
|
454
488
|
kind: "agent-message",
|
|
455
489
|
id: event.id,
|
|
456
490
|
turnId,
|
|
@@ -466,7 +500,9 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
|
|
|
466
500
|
turnId,
|
|
467
501
|
text,
|
|
468
502
|
},
|
|
469
|
-
}
|
|
503
|
+
};
|
|
504
|
+
items.push(item);
|
|
505
|
+
rememberAgentResponse(turnId, item, true);
|
|
470
506
|
}
|
|
471
507
|
break;
|
|
472
508
|
}
|
|
@@ -616,6 +652,7 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
|
|
|
616
652
|
}
|
|
617
653
|
|
|
618
654
|
case "turn.started": {
|
|
655
|
+
if (turnId) clearUnscopedTerminalTracking();
|
|
619
656
|
if (!turnId) break;
|
|
620
657
|
const queuedAt = queuedAtByTurn.get(turnId);
|
|
621
658
|
if (!queuedAt) break;
|
|
@@ -781,6 +818,20 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
|
|
|
781
818
|
break;
|
|
782
819
|
}
|
|
783
820
|
|
|
821
|
+
case "codex.capacity.waiting": {
|
|
822
|
+
items.push({
|
|
823
|
+
kind: "notice",
|
|
824
|
+
id: event.id,
|
|
825
|
+
tone: "waiting",
|
|
826
|
+
text:
|
|
827
|
+
stringValue(payload.detail) ??
|
|
828
|
+
stringValue(payload.error) ??
|
|
829
|
+
"Waiting for Codex capacity.",
|
|
830
|
+
occurredAt: event.occurredAt,
|
|
831
|
+
});
|
|
832
|
+
break;
|
|
833
|
+
}
|
|
834
|
+
|
|
784
835
|
case "session.requiresAction": {
|
|
785
836
|
finalizeOpen(turnId, "complete", event.occurredAt);
|
|
786
837
|
items.push({
|
|
@@ -897,7 +948,12 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
|
|
|
897
948
|
: "credential",
|
|
898
949
|
providerDomain: stringValue(payload.providerDomain),
|
|
899
950
|
connectionId: typeof payload.connectionId === "string" ? payload.connectionId : null,
|
|
900
|
-
|
|
951
|
+
authoritySource: payload.authoritySource === "host" ? "host" : null,
|
|
952
|
+
reason: authNeededReason(
|
|
953
|
+
payload.authoritySource === "host" && typeof payload.authorizationUrl === "string"
|
|
954
|
+
? (payload.hostReason ?? payload.reason)
|
|
955
|
+
: payload.reason,
|
|
956
|
+
),
|
|
901
957
|
scopes: stringList(payload.scopes),
|
|
902
958
|
resource: typeof payload.resource === "string" ? payload.resource : null,
|
|
903
959
|
toolName: typeof payload.toolName === "string" ? payload.toolName : null,
|
|
@@ -917,6 +973,8 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
|
|
|
917
973
|
// extra agent response.
|
|
918
974
|
if (payload.maintenance === "context_compaction") {
|
|
919
975
|
finalizeOpen(turnId, "complete", event.occurredAt);
|
|
976
|
+
takeAgentResponse(turnId);
|
|
977
|
+
takePendingWaitOutcome(turnId);
|
|
920
978
|
break;
|
|
921
979
|
}
|
|
922
980
|
// Credit exhaustion arrives as a NOMINALLY completed turn (`detail:
|
|
@@ -927,6 +985,8 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
|
|
|
927
985
|
// projects exactly like a failed turn plus an explicit notice.
|
|
928
986
|
if (isCreditExhaustionPayload(payload)) {
|
|
929
987
|
finalizeOpen(turnId, "complete", event.occurredAt);
|
|
988
|
+
takeAgentResponse(turnId);
|
|
989
|
+
takePendingWaitOutcome(turnId);
|
|
930
990
|
items.push(turnEndItem(event, "failed", CREDIT_EXHAUSTION_MESSAGE));
|
|
931
991
|
items.push({
|
|
932
992
|
kind: "notice",
|
|
@@ -937,12 +997,68 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
|
|
|
937
997
|
});
|
|
938
998
|
break;
|
|
939
999
|
}
|
|
1000
|
+
const latestAgentResponse = takeAgentResponse(turnId);
|
|
1001
|
+
const finalOutput = stringValue(payload.output);
|
|
1002
|
+
const visibleFinalOutput = stripOpaqueCitationTokens(finalOutput).trim();
|
|
1003
|
+
const visibleTrackedResponse = stripOpaqueCitationTokens(
|
|
1004
|
+
latestAgentResponse?.item.text ?? "",
|
|
1005
|
+
).trim();
|
|
1006
|
+
const finalOutputMirrorsCommentary =
|
|
1007
|
+
latestAgentResponse?.item.phase === "commentary" &&
|
|
1008
|
+
visibleTrackedResponse === visibleFinalOutput;
|
|
1009
|
+
const hasAuthoritativeFinalOutput =
|
|
1010
|
+
Boolean(visibleFinalOutput) && !finalOutputMirrorsCommentary;
|
|
1011
|
+
const pendingWaitOutcome = takePendingWaitOutcome(turnId);
|
|
1012
|
+
if (hasAuthoritativeFinalOutput) {
|
|
1013
|
+
// `agent.message.completed` and `turn.completed` normally commit
|
|
1014
|
+
// together, but legacy or partially compacted ledgers may retain only
|
|
1015
|
+
// the terminal output receipt. Keep that authoritative response
|
|
1016
|
+
// visible instead of leaving it trapped in raw audit data.
|
|
1017
|
+
if (
|
|
1018
|
+
latestAgentResponse &&
|
|
1019
|
+
!latestAgentResponse.completed &&
|
|
1020
|
+
finalOutput.startsWith(latestAgentResponse.item.text)
|
|
1021
|
+
) {
|
|
1022
|
+
latestAgentResponse.item.text = finalOutput;
|
|
1023
|
+
latestAgentResponse.item.streaming = false;
|
|
1024
|
+
latestAgentResponse.item.occurredAt = event.occurredAt;
|
|
1025
|
+
const responseIndex = items.indexOf(latestAgentResponse.item);
|
|
1026
|
+
if (responseIndex >= 0 && responseIndex < items.length - 1) {
|
|
1027
|
+
items.splice(responseIndex, 1);
|
|
1028
|
+
items.push(latestAgentResponse.item);
|
|
1029
|
+
}
|
|
1030
|
+
} else if (visibleTrackedResponse !== visibleFinalOutput) {
|
|
1031
|
+
items.push({
|
|
1032
|
+
kind: "agent-message",
|
|
1033
|
+
id: `${event.id}-output-message`,
|
|
1034
|
+
turnId,
|
|
1035
|
+
text: finalOutput,
|
|
1036
|
+
streaming: false,
|
|
1037
|
+
occurredAt: event.occurredAt,
|
|
1038
|
+
});
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
940
1041
|
finalizeOpen(turnId, "complete", event.occurredAt);
|
|
941
1042
|
items.push(turnEndItem(event, "complete", null));
|
|
1043
|
+
const hasCompletedFinalResponse =
|
|
1044
|
+
latestAgentResponse?.completed === true &&
|
|
1045
|
+
latestAgentResponse.item.phase !== "commentary" &&
|
|
1046
|
+
Boolean(visibleTrackedResponse);
|
|
1047
|
+
if (!hasAuthoritativeFinalOutput && !hasCompletedFinalResponse && pendingWaitOutcome) {
|
|
1048
|
+
items.push({
|
|
1049
|
+
kind: "notice",
|
|
1050
|
+
id: `${pendingWaitOutcome.id}-visible-outcome`,
|
|
1051
|
+
tone: "waiting",
|
|
1052
|
+
text: waitingOutcomeText(pendingWaitOutcome.reason),
|
|
1053
|
+
occurredAt: pendingWaitOutcome.occurredAt,
|
|
1054
|
+
});
|
|
1055
|
+
}
|
|
942
1056
|
break;
|
|
943
1057
|
}
|
|
944
1058
|
|
|
945
1059
|
case "turn.failed": {
|
|
1060
|
+
takeAgentResponse(turnId);
|
|
1061
|
+
takePendingWaitOutcome(turnId);
|
|
946
1062
|
const hadActivity = hasTurnActivity(items, turnId);
|
|
947
1063
|
// Credit death can hide behind fields `failureMessage` doesn't read
|
|
948
1064
|
// (detail/segmentLimit), so classify the whole payload before falling
|
|
@@ -975,6 +1091,8 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
|
|
|
975
1091
|
if (turnId && !prescan.startedTurnIds.has(turnId)) {
|
|
976
1092
|
break;
|
|
977
1093
|
}
|
|
1094
|
+
takeAgentResponse(turnId);
|
|
1095
|
+
takePendingWaitOutcome(turnId);
|
|
978
1096
|
const hadActivity = hasTurnActivity(items, turnId);
|
|
979
1097
|
finalizeOpen(turnId, "cancelled", event.occurredAt);
|
|
980
1098
|
items.push(turnEndItem(event, "cancelled", null));
|
|
@@ -1020,6 +1138,9 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
|
|
|
1020
1138
|
case "goal.cleared":
|
|
1021
1139
|
case "goal.held":
|
|
1022
1140
|
case "goal.continuation": {
|
|
1141
|
+
if (event.type === "goal.held" && payload.actor === "agent") {
|
|
1142
|
+
rememberPendingWaitOutcome(pendingWaitOutcomeByTurn, event, payload, turnId);
|
|
1143
|
+
}
|
|
1023
1144
|
// Agent tool mutations already appear as tool-call rows in the activity
|
|
1024
1145
|
// cluster. Re-emitting them as GoalRow landmarks splits "N steps" mid-turn.
|
|
1025
1146
|
if (shouldSuppressAgentGoalLandmark(event.type, payload)) {
|
|
@@ -1038,6 +1159,13 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
|
|
|
1038
1159
|
break;
|
|
1039
1160
|
}
|
|
1040
1161
|
|
|
1162
|
+
case "session.wait.started": {
|
|
1163
|
+
if (payload.actor === "agent") {
|
|
1164
|
+
rememberPendingWaitOutcome(pendingWaitOutcomeByTurn, event, payload, turnId);
|
|
1165
|
+
}
|
|
1166
|
+
break;
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1041
1169
|
default:
|
|
1042
1170
|
break;
|
|
1043
1171
|
}
|
|
@@ -1948,6 +2076,8 @@ const SESSION_STATUSES: readonly SessionStatus[] = [
|
|
|
1948
2076
|
"running",
|
|
1949
2077
|
"idle",
|
|
1950
2078
|
"requires_action",
|
|
2079
|
+
"recovering",
|
|
2080
|
+
"waiting_capacity",
|
|
1951
2081
|
"failed",
|
|
1952
2082
|
"cancelled",
|
|
1953
2083
|
];
|
|
@@ -2168,11 +2298,30 @@ function goalText(payload: Record<string, unknown>): string | null {
|
|
|
2168
2298
|
return null;
|
|
2169
2299
|
}
|
|
2170
2300
|
|
|
2301
|
+
function rememberPendingWaitOutcome(
|
|
2302
|
+
pending: Map<string | null, PendingWaitOutcome>,
|
|
2303
|
+
event: SessionEvent,
|
|
2304
|
+
payload: Record<string, unknown>,
|
|
2305
|
+
eventTurnId: string | null,
|
|
2306
|
+
): void {
|
|
2307
|
+
const reason = stringValue(payload.reason).trim();
|
|
2308
|
+
if (!reason) return;
|
|
2309
|
+
const turnId =
|
|
2310
|
+
eventTurnId || stringValue(payload.waitTurnId) || stringValue(payload.turnId) || null;
|
|
2311
|
+
pending.set(turnId, { id: event.id, reason, occurredAt: event.occurredAt });
|
|
2312
|
+
}
|
|
2313
|
+
|
|
2314
|
+
function waitingOutcomeText(reason: string): string {
|
|
2315
|
+
return /^waiting\b/i.test(reason) ? reason : `Waiting: ${reason}`;
|
|
2316
|
+
}
|
|
2317
|
+
|
|
2171
2318
|
/**
|
|
2172
2319
|
* Agent-owned goal mutations already have an in-cluster tool row. Suppress the
|
|
2173
|
-
* breakaway landmark for those only.
|
|
2174
|
-
* and
|
|
2175
|
-
*
|
|
2320
|
+
* breakaway landmark for those only. Empty wait turns retain the durable hold
|
|
2321
|
+
* reason and surface it after the folded steps. `goal.completed` has no actor
|
|
2322
|
+
* field today and is only emitted by the agent tool, so it is always
|
|
2323
|
+
* suppressed. API / system / create-session / continuation landmarks stay
|
|
2324
|
+
* visible.
|
|
2176
2325
|
*/
|
|
2177
2326
|
function shouldSuppressAgentGoalLandmark(type: string, payload: Record<string, unknown>): boolean {
|
|
2178
2327
|
if (type === "goal.completed") {
|
package/src/timeline/registry.ts
CHANGED
|
@@ -13,7 +13,7 @@ import type { ToolCallItem } from "./types";
|
|
|
13
13
|
Resolution order (most → least specific):
|
|
14
14
|
1. exact match on `raw.type` (e.g. "apply_patch_call", "computer_call")
|
|
15
15
|
2. exact match on the tool `name` (e.g. "exec_command", "web_search_call")
|
|
16
|
-
3. leaf match after MCP `__` prefix (e.g. opengeni__environment_set_variable)
|
|
16
|
+
3. allowed leaf match after MCP `__` prefix (e.g. opengeni__environment_set_variable)
|
|
17
17
|
4. the registry's generic fallback
|
|
18
18
|
|
|
19
19
|
A consumer extends the defaults without forking by passing overrides to
|
|
@@ -48,7 +48,13 @@ export type ToolRenderer = ComponentType<ToolRendererProps>;
|
|
|
48
48
|
/** A registry entry: which key it matches and the component that renders it. */
|
|
49
49
|
export type ToolRegistryEntry =
|
|
50
50
|
| { match: "rawType"; type: string; render: ToolRenderer }
|
|
51
|
-
| {
|
|
51
|
+
| {
|
|
52
|
+
match: "name";
|
|
53
|
+
name: string;
|
|
54
|
+
render: ToolRenderer;
|
|
55
|
+
/** Disable untrusted `<server>__${name}` leaf matching for identity-sensitive renderers. */
|
|
56
|
+
matchPrefixedLeaf?: boolean | undefined;
|
|
57
|
+
};
|
|
52
58
|
|
|
53
59
|
export type ToolRegistry = {
|
|
54
60
|
/** Resolve the renderer for a call (never null — falls back to generic). */
|
|
@@ -92,6 +98,7 @@ export function createToolRegistry(
|
|
|
92
98
|
|
|
93
99
|
const byRawType = new Map<string, ToolRenderer>();
|
|
94
100
|
const byName = new Map<string, ToolRenderer>();
|
|
101
|
+
const byPrefixedLeaf = new Map<string, ToolRenderer>();
|
|
95
102
|
for (const entry of entries) {
|
|
96
103
|
if (entry.match === "rawType") {
|
|
97
104
|
if (!byRawType.has(entry.type)) {
|
|
@@ -100,6 +107,11 @@ export function createToolRegistry(
|
|
|
100
107
|
} else if (!byName.has(entry.name)) {
|
|
101
108
|
byName.set(entry.name, entry.render);
|
|
102
109
|
}
|
|
110
|
+
if (entry.match === "name" && entry.matchPrefixedLeaf !== false) {
|
|
111
|
+
if (!byPrefixedLeaf.has(entry.name)) {
|
|
112
|
+
byPrefixedLeaf.set(entry.name, entry.render);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
103
115
|
}
|
|
104
116
|
|
|
105
117
|
const resolve = (item: ToolCallItem): ToolRenderer => {
|
|
@@ -116,7 +128,7 @@ export function createToolRegistry(
|
|
|
116
128
|
}
|
|
117
129
|
const leaf = mcpToolLeaf(item.name);
|
|
118
130
|
if (leaf !== item.name) {
|
|
119
|
-
const byLeaf =
|
|
131
|
+
const byLeaf = byPrefixedLeaf.get(leaf);
|
|
120
132
|
if (byLeaf) {
|
|
121
133
|
return byLeaf;
|
|
122
134
|
}
|
|
@@ -1085,6 +1085,98 @@ function SandboxFilePublishRenderer({ item, loadRetainedArtifact }: ToolRenderer
|
|
|
1085
1085
|
);
|
|
1086
1086
|
}
|
|
1087
1087
|
|
|
1088
|
+
type PublishedSiteReceipt = {
|
|
1089
|
+
workspaceId: string;
|
|
1090
|
+
artifactId: string;
|
|
1091
|
+
title: string;
|
|
1092
|
+
revision: number;
|
|
1093
|
+
replayed: boolean;
|
|
1094
|
+
};
|
|
1095
|
+
|
|
1096
|
+
function publishedSiteReceipt(output: unknown): PublishedSiteReceipt | null {
|
|
1097
|
+
const { text, isError } = unwrapMcpOutput(output);
|
|
1098
|
+
if (isError) return null;
|
|
1099
|
+
const parsed = tryParseJson(text);
|
|
1100
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
|
1101
|
+
const artifact = (parsed as Record<string, unknown>).artifact;
|
|
1102
|
+
const version = (parsed as Record<string, unknown>).version;
|
|
1103
|
+
if (
|
|
1104
|
+
!artifact ||
|
|
1105
|
+
typeof artifact !== "object" ||
|
|
1106
|
+
Array.isArray(artifact) ||
|
|
1107
|
+
!version ||
|
|
1108
|
+
typeof version !== "object" ||
|
|
1109
|
+
Array.isArray(version)
|
|
1110
|
+
) {
|
|
1111
|
+
return null;
|
|
1112
|
+
}
|
|
1113
|
+
const artifactRecord = artifact as Record<string, unknown>;
|
|
1114
|
+
const versionRecord = version as Record<string, unknown>;
|
|
1115
|
+
if (
|
|
1116
|
+
typeof artifactRecord.workspaceId !== "string" ||
|
|
1117
|
+
typeof artifactRecord.id !== "string" ||
|
|
1118
|
+
typeof artifactRecord.title !== "string" ||
|
|
1119
|
+
typeof versionRecord.revision !== "number" ||
|
|
1120
|
+
!Number.isInteger(versionRecord.revision) ||
|
|
1121
|
+
versionRecord.revision < 1
|
|
1122
|
+
) {
|
|
1123
|
+
return null;
|
|
1124
|
+
}
|
|
1125
|
+
return {
|
|
1126
|
+
workspaceId: artifactRecord.workspaceId,
|
|
1127
|
+
artifactId: artifactRecord.id,
|
|
1128
|
+
title: artifactRecord.title,
|
|
1129
|
+
revision: versionRecord.revision,
|
|
1130
|
+
replayed: (parsed as Record<string, unknown>).replayed === true,
|
|
1131
|
+
};
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
function SiteOpenLink({ receipt }: { receipt: PublishedSiteReceipt }) {
|
|
1135
|
+
const href = `/workspaces/${encodeURIComponent(receipt.workspaceId)}/artifacts/${encodeURIComponent(receipt.artifactId)}`;
|
|
1136
|
+
return (
|
|
1137
|
+
<a
|
|
1138
|
+
href={href}
|
|
1139
|
+
aria-label={`Open ${receipt.title}`}
|
|
1140
|
+
className="inline-flex min-h-7 items-center rounded-og-sm px-2 text-og-sm font-medium text-og-accent-strong hover:bg-og-surface-2 hover:underline focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-og-accent pointer-coarse:min-h-10"
|
|
1141
|
+
onClick={(event) => event.stopPropagation()}
|
|
1142
|
+
onKeyDown={(event) => event.stopPropagation()}
|
|
1143
|
+
>
|
|
1144
|
+
Open
|
|
1145
|
+
</a>
|
|
1146
|
+
);
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
function SiteArtifactRenderer({ item }: ToolRendererProps) {
|
|
1150
|
+
const leaf = mcpToolLeaf(item.name);
|
|
1151
|
+
const publishingExisting = leaf === "artifacts_publish";
|
|
1152
|
+
if (item.status === "running") {
|
|
1153
|
+
return (
|
|
1154
|
+
<ActivityDisclosure
|
|
1155
|
+
icon={<PanelsTopLeftIcon className={ICON_SIZE} />}
|
|
1156
|
+
iconTone="running"
|
|
1157
|
+
title={publishingExisting ? "Publishing Site update" : "Publishing Site"}
|
|
1158
|
+
running
|
|
1159
|
+
preview={<RunningPreview>retaining source and compiled HTML…</RunningPreview>}
|
|
1160
|
+
/>
|
|
1161
|
+
);
|
|
1162
|
+
}
|
|
1163
|
+
const receipt = publishedSiteReceipt(item.output);
|
|
1164
|
+
if (!receipt || item.status === "failed") return <GenericRenderer item={item} />;
|
|
1165
|
+
return (
|
|
1166
|
+
<ActivityDisclosure
|
|
1167
|
+
icon={<PanelsTopLeftIcon className={ICON_SIZE} />}
|
|
1168
|
+
iconTone="accent"
|
|
1169
|
+
title={publishingExisting ? `Updated ${receipt.title}` : `Published ${receipt.title}`}
|
|
1170
|
+
media={<SiteOpenLink receipt={receipt} />}
|
|
1171
|
+
>
|
|
1172
|
+
<BodyNote>
|
|
1173
|
+
Version {receipt.revision} is live
|
|
1174
|
+
{receipt.replayed ? " (replayed from the original publication)." : "."}
|
|
1175
|
+
</BodyNote>
|
|
1176
|
+
</ActivityDisclosure>
|
|
1177
|
+
);
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1088
1180
|
function GeneratedImageDisclosure({
|
|
1089
1181
|
receipt,
|
|
1090
1182
|
load,
|
|
@@ -2198,7 +2290,7 @@ function goalToolPreview(name: string, args: unknown): string | null {
|
|
|
2198
2290
|
leaf !== "goal_update" &&
|
|
2199
2291
|
leaf !== "goal_complete" &&
|
|
2200
2292
|
leaf !== "goal_pause" &&
|
|
2201
|
-
leaf !== "
|
|
2293
|
+
leaf !== "wait_for_input"
|
|
2202
2294
|
) {
|
|
2203
2295
|
return null;
|
|
2204
2296
|
}
|
|
@@ -2308,6 +2400,30 @@ const BASE_ENTRIES: ToolRegistryEntry[] = [
|
|
|
2308
2400
|
{ match: "name", name: "tool_search", render: ToolSearchRenderer },
|
|
2309
2401
|
{ match: "name", name: "view_image", render: ViewImageRenderer },
|
|
2310
2402
|
{ match: "name", name: "sandbox_file_publish", render: SandboxFilePublishRenderer },
|
|
2403
|
+
{
|
|
2404
|
+
match: "name",
|
|
2405
|
+
name: "artifacts_create",
|
|
2406
|
+
render: SiteArtifactRenderer,
|
|
2407
|
+
matchPrefixedLeaf: false,
|
|
2408
|
+
},
|
|
2409
|
+
{
|
|
2410
|
+
match: "name",
|
|
2411
|
+
name: "artifacts_publish",
|
|
2412
|
+
render: SiteArtifactRenderer,
|
|
2413
|
+
matchPrefixedLeaf: false,
|
|
2414
|
+
},
|
|
2415
|
+
{
|
|
2416
|
+
match: "name",
|
|
2417
|
+
name: "opengeni__artifacts_create",
|
|
2418
|
+
render: SiteArtifactRenderer,
|
|
2419
|
+
matchPrefixedLeaf: false,
|
|
2420
|
+
},
|
|
2421
|
+
{
|
|
2422
|
+
match: "name",
|
|
2423
|
+
name: "opengeni__artifacts_publish",
|
|
2424
|
+
render: SiteArtifactRenderer,
|
|
2425
|
+
matchPrefixedLeaf: false,
|
|
2426
|
+
},
|
|
2311
2427
|
{ match: "name", name: "environment_set_variable", render: SecretSetRenderer },
|
|
2312
2428
|
{ match: "name", name: "variable_set_set_variable", render: SecretSetRenderer },
|
|
2313
2429
|
{ match: "name", name: "search_documents", render: DocsSearchRenderer },
|