@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
|
@@ -5,6 +5,53 @@ import {
|
|
|
5
5
|
tryParseJson
|
|
6
6
|
} from "./chunk-VTOREEXF.js";
|
|
7
7
|
|
|
8
|
+
// src/human-input.ts
|
|
9
|
+
function isActionableHumanInputRequest(request, nowMs = Date.now()) {
|
|
10
|
+
if (request.status !== "pending") return false;
|
|
11
|
+
if (!request.expiresAt) return true;
|
|
12
|
+
const deadline = Date.parse(request.expiresAt);
|
|
13
|
+
return Number.isFinite(deadline) && deadline > nowMs;
|
|
14
|
+
}
|
|
15
|
+
function humanInputRequestFromEvent(event) {
|
|
16
|
+
if (event.type !== "session.humanInput.requested" || !isRecord(event.payload)) return null;
|
|
17
|
+
const request = event.payload.request;
|
|
18
|
+
if (!isRecord(request) || typeof request.id !== "string" || !Array.isArray(request.questions)) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
id: request.id,
|
|
23
|
+
turnId: event.turnId ?? null,
|
|
24
|
+
questions: request.questions,
|
|
25
|
+
allowSkip: request.allowSkip === true,
|
|
26
|
+
expiresAt: typeof request.expiresAt === "string" ? request.expiresAt : null
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function projectPendingHumanInputRequests(events) {
|
|
30
|
+
const pending = /* @__PURE__ */ new Map();
|
|
31
|
+
for (const event of events) {
|
|
32
|
+
const requested = humanInputRequestFromEvent(event);
|
|
33
|
+
if (requested) {
|
|
34
|
+
pending.set(requested.id, requested);
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (event.type === "user.humanInputResponse" && isRecord(event.payload)) {
|
|
38
|
+
if (typeof event.payload.requestId === "string") pending.delete(event.payload.requestId);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (event.type === "turn.completed" || event.type === "turn.failed" || event.type === "turn.cancelled") {
|
|
42
|
+
for (const [id, request] of pending) {
|
|
43
|
+
if (request.turnId === null || event.turnId === null || event.turnId === void 0 || request.turnId === event.turnId) {
|
|
44
|
+
pending.delete(id);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return [...pending.values()];
|
|
50
|
+
}
|
|
51
|
+
function isRecord(value) {
|
|
52
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
53
|
+
}
|
|
54
|
+
|
|
8
55
|
// src/older-history.ts
|
|
9
56
|
var activeReceiptCapture;
|
|
10
57
|
function invokeOlderHistoryLoaderWithReceiptCapture(load, capture) {
|
|
@@ -65,6 +112,7 @@ var FLEET_ACTUAL_REASONS = [
|
|
|
65
112
|
"rotation",
|
|
66
113
|
"active",
|
|
67
114
|
"all_capped",
|
|
115
|
+
"allocator_disabled",
|
|
68
116
|
"none"
|
|
69
117
|
];
|
|
70
118
|
var FLEET_SHADOW_OUTCOMES = ["selected", "paced", "none"];
|
|
@@ -282,7 +330,7 @@ function fleetComparisonIsConsistent(comparison, actualOutcome, actualCandidateK
|
|
|
282
330
|
return comparableActualOutcome !== "selected" || actualCandidateKey === shadowCandidateKey;
|
|
283
331
|
}
|
|
284
332
|
function fleetDecisionSemanticsAreConsistent(input) {
|
|
285
|
-
const actualConsistent = input.actualOutcome === "selected" ? ["lease_reused", "pin", "rotation", "active"].includes(input.actualReason) : input.actualOutcome === "waiting" ? input.actualReason
|
|
333
|
+
const actualConsistent = input.actualOutcome === "selected" ? ["lease_reused", "pin", "rotation", "active"].includes(input.actualReason) : input.actualOutcome === "waiting" ? ["all_capped", "allocator_disabled"].includes(input.actualReason) : input.actualReason === "none";
|
|
286
334
|
const shadowConsistent = input.shadowOutcome === "selected" ? ["fenced_in_flight", "best_score", "affinity_best", "hysteresis_hold"].includes(
|
|
287
335
|
input.shadowReason
|
|
288
336
|
) : input.shadowOutcome === "paced" ? input.shadowReason === "admission_paced" : ["fenced_candidate_missing", "no_eligible_candidate", "overlay_isolated_empty"].includes(
|
|
@@ -341,6 +389,8 @@ function buildTimeline(events) {
|
|
|
341
389
|
const items = [];
|
|
342
390
|
const prescan = prescanTurnAnchors(events);
|
|
343
391
|
const ordered = orderTimelineEvents(events, prescan);
|
|
392
|
+
const pendingWaitOutcomeByTurn = /* @__PURE__ */ new Map();
|
|
393
|
+
const latestAgentResponseByTurn = /* @__PURE__ */ new Map();
|
|
344
394
|
const humanInputRequests = humanInputRequestsById(events);
|
|
345
395
|
const humanInputToolCallIds = new Set(
|
|
346
396
|
[...humanInputRequests.values()].map((request) => stringValue(request.toolCallId)).filter(Boolean)
|
|
@@ -403,6 +453,23 @@ function buildTimeline(events) {
|
|
|
403
453
|
startupPhases.set(key, [item, startupAttemptId, startupRecoveryRevision]);
|
|
404
454
|
};
|
|
405
455
|
const last = () => items[items.length - 1];
|
|
456
|
+
const rememberAgentResponse = (turnId, item, completed) => {
|
|
457
|
+
latestAgentResponseByTurn.set(turnId, { item, completed });
|
|
458
|
+
};
|
|
459
|
+
const takePendingWaitOutcome = (turnId) => {
|
|
460
|
+
const outcome = pendingWaitOutcomeByTurn.get(turnId);
|
|
461
|
+
pendingWaitOutcomeByTurn.delete(turnId);
|
|
462
|
+
return outcome;
|
|
463
|
+
};
|
|
464
|
+
const takeAgentResponse = (turnId) => {
|
|
465
|
+
const response = latestAgentResponseByTurn.get(turnId);
|
|
466
|
+
latestAgentResponseByTurn.delete(turnId);
|
|
467
|
+
return response;
|
|
468
|
+
};
|
|
469
|
+
const clearUnscopedTerminalTracking = () => {
|
|
470
|
+
latestAgentResponseByTurn.delete(null);
|
|
471
|
+
pendingWaitOutcomeByTurn.delete(null);
|
|
472
|
+
};
|
|
406
473
|
const closeStreamingTail = () => {
|
|
407
474
|
const open = last();
|
|
408
475
|
if ((open?.kind === "agent-message" || open?.kind === "reasoning") && open.streaming) {
|
|
@@ -453,6 +520,7 @@ function buildTimeline(events) {
|
|
|
453
520
|
}
|
|
454
521
|
switch (event.type) {
|
|
455
522
|
case "user.message": {
|
|
523
|
+
clearUnscopedTerminalTracking();
|
|
456
524
|
closeStreamingTail();
|
|
457
525
|
const childCompletion = workerCompletionPayload(payload.childCompletion);
|
|
458
526
|
if (childCompletion) {
|
|
@@ -524,17 +592,20 @@ function buildTimeline(events) {
|
|
|
524
592
|
const open = last();
|
|
525
593
|
if (open?.kind === "agent-message" && open.streaming && open.turnId === turnId) {
|
|
526
594
|
open.text += text;
|
|
595
|
+
rememberAgentResponse(turnId, open, false);
|
|
527
596
|
break;
|
|
528
597
|
}
|
|
529
598
|
closeStreamingTail();
|
|
530
|
-
|
|
599
|
+
const item = {
|
|
531
600
|
kind: "agent-message",
|
|
532
601
|
id: event.id,
|
|
533
602
|
turnId,
|
|
534
603
|
text,
|
|
535
604
|
streaming: true,
|
|
536
605
|
occurredAt: event.occurredAt
|
|
537
|
-
}
|
|
606
|
+
};
|
|
607
|
+
items.push(item);
|
|
608
|
+
rememberAgentResponse(turnId, item, false);
|
|
538
609
|
break;
|
|
539
610
|
}
|
|
540
611
|
case "agent.message.completed": {
|
|
@@ -569,10 +640,11 @@ function buildTimeline(events) {
|
|
|
569
640
|
items.splice(openIndex, 1);
|
|
570
641
|
items.push(open);
|
|
571
642
|
}
|
|
643
|
+
rememberAgentResponse(turnId, open, true);
|
|
572
644
|
break;
|
|
573
645
|
}
|
|
574
646
|
if (text) {
|
|
575
|
-
|
|
647
|
+
const item = {
|
|
576
648
|
kind: "agent-message",
|
|
577
649
|
id: event.id,
|
|
578
650
|
turnId,
|
|
@@ -588,7 +660,9 @@ function buildTimeline(events) {
|
|
|
588
660
|
turnId,
|
|
589
661
|
text
|
|
590
662
|
}
|
|
591
|
-
}
|
|
663
|
+
};
|
|
664
|
+
items.push(item);
|
|
665
|
+
rememberAgentResponse(turnId, item, true);
|
|
592
666
|
}
|
|
593
667
|
break;
|
|
594
668
|
}
|
|
@@ -711,6 +785,7 @@ function buildTimeline(events) {
|
|
|
711
785
|
break;
|
|
712
786
|
}
|
|
713
787
|
case "turn.started": {
|
|
788
|
+
if (turnId) clearUnscopedTerminalTracking();
|
|
714
789
|
if (!turnId) break;
|
|
715
790
|
const queuedAt = queuedAtByTurn.get(turnId);
|
|
716
791
|
if (!queuedAt) break;
|
|
@@ -817,6 +892,16 @@ ${message}` : message;
|
|
|
817
892
|
});
|
|
818
893
|
break;
|
|
819
894
|
}
|
|
895
|
+
case "codex.capacity.waiting": {
|
|
896
|
+
items.push({
|
|
897
|
+
kind: "notice",
|
|
898
|
+
id: event.id,
|
|
899
|
+
tone: "waiting",
|
|
900
|
+
text: stringValue(payload.detail) ?? stringValue(payload.error) ?? "Waiting for Codex capacity.",
|
|
901
|
+
occurredAt: event.occurredAt
|
|
902
|
+
});
|
|
903
|
+
break;
|
|
904
|
+
}
|
|
820
905
|
case "session.requiresAction": {
|
|
821
906
|
finalizeOpen(turnId, "complete", event.occurredAt);
|
|
822
907
|
items.push({
|
|
@@ -901,7 +986,10 @@ ${message}` : message;
|
|
|
901
986
|
source: capability ? "capability" : event.type === "tool.auth_needed" ? "tool" : "credential",
|
|
902
987
|
providerDomain: stringValue(payload.providerDomain),
|
|
903
988
|
connectionId: typeof payload.connectionId === "string" ? payload.connectionId : null,
|
|
904
|
-
|
|
989
|
+
authoritySource: payload.authoritySource === "host" ? "host" : null,
|
|
990
|
+
reason: authNeededReason(
|
|
991
|
+
payload.authoritySource === "host" && typeof payload.authorizationUrl === "string" ? payload.hostReason ?? payload.reason : payload.reason
|
|
992
|
+
),
|
|
905
993
|
scopes: stringList(payload.scopes),
|
|
906
994
|
resource: typeof payload.resource === "string" ? payload.resource : null,
|
|
907
995
|
toolName: typeof payload.toolName === "string" ? payload.toolName : null,
|
|
@@ -914,10 +1002,14 @@ ${message}` : message;
|
|
|
914
1002
|
case "turn.completed": {
|
|
915
1003
|
if (payload.maintenance === "context_compaction") {
|
|
916
1004
|
finalizeOpen(turnId, "complete", event.occurredAt);
|
|
1005
|
+
takeAgentResponse(turnId);
|
|
1006
|
+
takePendingWaitOutcome(turnId);
|
|
917
1007
|
break;
|
|
918
1008
|
}
|
|
919
1009
|
if (isCreditExhaustionPayload(payload)) {
|
|
920
1010
|
finalizeOpen(turnId, "complete", event.occurredAt);
|
|
1011
|
+
takeAgentResponse(turnId);
|
|
1012
|
+
takePendingWaitOutcome(turnId);
|
|
921
1013
|
items.push(turnEndItem(event, "failed", CREDIT_EXHAUSTION_MESSAGE));
|
|
922
1014
|
items.push({
|
|
923
1015
|
kind: "notice",
|
|
@@ -928,11 +1020,53 @@ ${message}` : message;
|
|
|
928
1020
|
});
|
|
929
1021
|
break;
|
|
930
1022
|
}
|
|
1023
|
+
const latestAgentResponse = takeAgentResponse(turnId);
|
|
1024
|
+
const finalOutput = stringValue(payload.output);
|
|
1025
|
+
const visibleFinalOutput = stripOpaqueCitationTokens(finalOutput).trim();
|
|
1026
|
+
const visibleTrackedResponse = stripOpaqueCitationTokens(
|
|
1027
|
+
latestAgentResponse?.item.text ?? ""
|
|
1028
|
+
).trim();
|
|
1029
|
+
const finalOutputMirrorsCommentary = latestAgentResponse?.item.phase === "commentary" && visibleTrackedResponse === visibleFinalOutput;
|
|
1030
|
+
const hasAuthoritativeFinalOutput = Boolean(visibleFinalOutput) && !finalOutputMirrorsCommentary;
|
|
1031
|
+
const pendingWaitOutcome = takePendingWaitOutcome(turnId);
|
|
1032
|
+
if (hasAuthoritativeFinalOutput) {
|
|
1033
|
+
if (latestAgentResponse && !latestAgentResponse.completed && finalOutput.startsWith(latestAgentResponse.item.text)) {
|
|
1034
|
+
latestAgentResponse.item.text = finalOutput;
|
|
1035
|
+
latestAgentResponse.item.streaming = false;
|
|
1036
|
+
latestAgentResponse.item.occurredAt = event.occurredAt;
|
|
1037
|
+
const responseIndex = items.indexOf(latestAgentResponse.item);
|
|
1038
|
+
if (responseIndex >= 0 && responseIndex < items.length - 1) {
|
|
1039
|
+
items.splice(responseIndex, 1);
|
|
1040
|
+
items.push(latestAgentResponse.item);
|
|
1041
|
+
}
|
|
1042
|
+
} else if (visibleTrackedResponse !== visibleFinalOutput) {
|
|
1043
|
+
items.push({
|
|
1044
|
+
kind: "agent-message",
|
|
1045
|
+
id: `${event.id}-output-message`,
|
|
1046
|
+
turnId,
|
|
1047
|
+
text: finalOutput,
|
|
1048
|
+
streaming: false,
|
|
1049
|
+
occurredAt: event.occurredAt
|
|
1050
|
+
});
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
931
1053
|
finalizeOpen(turnId, "complete", event.occurredAt);
|
|
932
1054
|
items.push(turnEndItem(event, "complete", null));
|
|
1055
|
+
const hasCompletedFinalResponse = latestAgentResponse?.completed === true && latestAgentResponse.item.phase !== "commentary" && Boolean(visibleTrackedResponse);
|
|
1056
|
+
if (!hasAuthoritativeFinalOutput && !hasCompletedFinalResponse && pendingWaitOutcome) {
|
|
1057
|
+
items.push({
|
|
1058
|
+
kind: "notice",
|
|
1059
|
+
id: `${pendingWaitOutcome.id}-visible-outcome`,
|
|
1060
|
+
tone: "waiting",
|
|
1061
|
+
text: waitingOutcomeText(pendingWaitOutcome.reason),
|
|
1062
|
+
occurredAt: pendingWaitOutcome.occurredAt
|
|
1063
|
+
});
|
|
1064
|
+
}
|
|
933
1065
|
break;
|
|
934
1066
|
}
|
|
935
1067
|
case "turn.failed": {
|
|
1068
|
+
takeAgentResponse(turnId);
|
|
1069
|
+
takePendingWaitOutcome(turnId);
|
|
936
1070
|
const hadActivity = hasTurnActivity(items, turnId);
|
|
937
1071
|
const failureText = isCreditExhaustionPayload(payload) ? CREDIT_EXHAUSTION_MESSAGE : failureMessage(payload);
|
|
938
1072
|
finalizeOpen(turnId, "cancelled", event.occurredAt);
|
|
@@ -952,6 +1086,8 @@ ${message}` : message;
|
|
|
952
1086
|
if (turnId && !prescan.startedTurnIds.has(turnId)) {
|
|
953
1087
|
break;
|
|
954
1088
|
}
|
|
1089
|
+
takeAgentResponse(turnId);
|
|
1090
|
+
takePendingWaitOutcome(turnId);
|
|
955
1091
|
const hadActivity = hasTurnActivity(items, turnId);
|
|
956
1092
|
finalizeOpen(turnId, "cancelled", event.occurredAt);
|
|
957
1093
|
items.push(turnEndItem(event, "cancelled", null));
|
|
@@ -991,6 +1127,9 @@ ${message}` : message;
|
|
|
991
1127
|
case "goal.cleared":
|
|
992
1128
|
case "goal.held":
|
|
993
1129
|
case "goal.continuation": {
|
|
1130
|
+
if (event.type === "goal.held" && payload.actor === "agent") {
|
|
1131
|
+
rememberPendingWaitOutcome(pendingWaitOutcomeByTurn, event, payload, turnId);
|
|
1132
|
+
}
|
|
994
1133
|
if (shouldSuppressAgentGoalLandmark(event.type, payload)) {
|
|
995
1134
|
break;
|
|
996
1135
|
}
|
|
@@ -1003,6 +1142,12 @@ ${message}` : message;
|
|
|
1003
1142
|
});
|
|
1004
1143
|
break;
|
|
1005
1144
|
}
|
|
1145
|
+
case "session.wait.started": {
|
|
1146
|
+
if (payload.actor === "agent") {
|
|
1147
|
+
rememberPendingWaitOutcome(pendingWaitOutcomeByTurn, event, payload, turnId);
|
|
1148
|
+
}
|
|
1149
|
+
break;
|
|
1150
|
+
}
|
|
1006
1151
|
default:
|
|
1007
1152
|
break;
|
|
1008
1153
|
}
|
|
@@ -1637,6 +1782,8 @@ var SESSION_STATUSES = [
|
|
|
1637
1782
|
"running",
|
|
1638
1783
|
"idle",
|
|
1639
1784
|
"requires_action",
|
|
1785
|
+
"recovering",
|
|
1786
|
+
"waiting_capacity",
|
|
1640
1787
|
"failed",
|
|
1641
1788
|
"cancelled"
|
|
1642
1789
|
];
|
|
@@ -1789,6 +1936,15 @@ function goalText(payload) {
|
|
|
1789
1936
|
}
|
|
1790
1937
|
return null;
|
|
1791
1938
|
}
|
|
1939
|
+
function rememberPendingWaitOutcome(pending, event, payload, eventTurnId) {
|
|
1940
|
+
const reason = stringValue(payload.reason).trim();
|
|
1941
|
+
if (!reason) return;
|
|
1942
|
+
const turnId = eventTurnId || stringValue(payload.waitTurnId) || stringValue(payload.turnId) || null;
|
|
1943
|
+
pending.set(turnId, { id: event.id, reason, occurredAt: event.occurredAt });
|
|
1944
|
+
}
|
|
1945
|
+
function waitingOutcomeText(reason) {
|
|
1946
|
+
return /^waiting\b/i.test(reason) ? reason : `Waiting: ${reason}`;
|
|
1947
|
+
}
|
|
1792
1948
|
function shouldSuppressAgentGoalLandmark(type, payload) {
|
|
1793
1949
|
if (type === "goal.completed") {
|
|
1794
1950
|
return true;
|
|
@@ -1971,54 +2127,10 @@ function looksLikeId(value) {
|
|
|
1971
2127
|
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
|
|
1972
2128
|
}
|
|
1973
2129
|
|
|
1974
|
-
// src/human-input.ts
|
|
1975
|
-
function isActionableHumanInputRequest(request, nowMs = Date.now()) {
|
|
1976
|
-
if (request.status !== "pending") return false;
|
|
1977
|
-
if (!request.expiresAt) return true;
|
|
1978
|
-
const deadline = Date.parse(request.expiresAt);
|
|
1979
|
-
return Number.isFinite(deadline) && deadline > nowMs;
|
|
1980
|
-
}
|
|
1981
|
-
function humanInputRequestFromEvent(event) {
|
|
1982
|
-
if (event.type !== "session.humanInput.requested" || !isRecord(event.payload)) return null;
|
|
1983
|
-
const request = event.payload.request;
|
|
1984
|
-
if (!isRecord(request) || typeof request.id !== "string" || !Array.isArray(request.questions)) {
|
|
1985
|
-
return null;
|
|
1986
|
-
}
|
|
1987
|
-
return {
|
|
1988
|
-
id: request.id,
|
|
1989
|
-
turnId: event.turnId ?? null,
|
|
1990
|
-
questions: request.questions,
|
|
1991
|
-
allowSkip: request.allowSkip === true,
|
|
1992
|
-
expiresAt: typeof request.expiresAt === "string" ? request.expiresAt : null
|
|
1993
|
-
};
|
|
1994
|
-
}
|
|
1995
|
-
function projectPendingHumanInputRequests(events) {
|
|
1996
|
-
const pending = /* @__PURE__ */ new Map();
|
|
1997
|
-
for (const event of events) {
|
|
1998
|
-
const requested = humanInputRequestFromEvent(event);
|
|
1999
|
-
if (requested) {
|
|
2000
|
-
pending.set(requested.id, requested);
|
|
2001
|
-
continue;
|
|
2002
|
-
}
|
|
2003
|
-
if (event.type === "user.humanInputResponse" && isRecord(event.payload)) {
|
|
2004
|
-
if (typeof event.payload.requestId === "string") pending.delete(event.payload.requestId);
|
|
2005
|
-
continue;
|
|
2006
|
-
}
|
|
2007
|
-
if (event.type === "turn.completed" || event.type === "turn.failed" || event.type === "turn.cancelled") {
|
|
2008
|
-
for (const [id, request] of pending) {
|
|
2009
|
-
if (request.turnId === null || event.turnId === null || event.turnId === void 0 || request.turnId === event.turnId) {
|
|
2010
|
-
pending.delete(id);
|
|
2011
|
-
}
|
|
2012
|
-
}
|
|
2013
|
-
}
|
|
2014
|
-
}
|
|
2015
|
-
return [...pending.values()];
|
|
2016
|
-
}
|
|
2017
|
-
function isRecord(value) {
|
|
2018
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
2019
|
-
}
|
|
2020
|
-
|
|
2021
2130
|
export {
|
|
2131
|
+
isActionableHumanInputRequest,
|
|
2132
|
+
humanInputRequestFromEvent,
|
|
2133
|
+
projectPendingHumanInputRequests,
|
|
2022
2134
|
invokeOlderHistoryLoaderWithReceiptCapture,
|
|
2023
2135
|
createOlderHistoryLoadReceipt,
|
|
2024
2136
|
mcpToolLeaf,
|
|
@@ -2027,9 +2139,6 @@ export {
|
|
|
2027
2139
|
creditExhaustedFromEvents,
|
|
2028
2140
|
sessionStatusFromEvents,
|
|
2029
2141
|
groupTimeline,
|
|
2030
|
-
extractSessionRef
|
|
2031
|
-
isActionableHumanInputRequest,
|
|
2032
|
-
humanInputRequestFromEvent,
|
|
2033
|
-
projectPendingHumanInputRequests
|
|
2142
|
+
extractSessionRef
|
|
2034
2143
|
};
|
|
2035
|
-
//# sourceMappingURL=chunk-
|
|
2144
|
+
//# sourceMappingURL=chunk-FJBOU2TH.js.map
|