@sema-agent/client-core 0.104.1 → 0.106.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/CHANGELOG.md +310 -0
- package/README.md +36 -14
- package/dist/adapt/arms.js +23 -6
- package/dist/adapter/activeRunSelfHeal.d.ts +14 -2
- package/dist/adapter/activeRunSelfHeal.js +90 -12
- package/dist/adapter/downstream/eventToSdkMessage.d.ts +0 -5
- package/dist/adapter/downstream/eventToSdkMessage.js +24 -23
- package/dist/adapter/downstream/terminalToSdkResult.js +2 -3
- package/dist/adapter/downstream/wiringManifestView.d.ts +7 -3
- package/dist/adapter/downstream/wiringManifestView.js +25 -1
- package/dist/adapter/runStream.js +8 -5
- package/dist/approvalReachWire.d.ts +1 -0
- package/dist/approvalReachWire.js +4 -1
- package/dist/approvalSeat.d.ts +21 -0
- package/dist/approvalSeat.js +73 -0
- package/dist/assistantInbox.d.ts +2 -0
- package/dist/assistantInbox.js +3 -0
- package/dist/checkpointRowVerdict.d.ts +23 -0
- package/dist/checkpointRowVerdict.js +89 -0
- package/dist/cloudConfigWireCaps.js +3 -0
- package/dist/compensations.js +6 -6
- package/dist/coreValuePorts.d.ts +14 -1
- package/dist/coreValuePorts.js +14 -0
- package/dist/decideFailureNote.js +3 -1
- package/dist/decideReceipt.d.ts +9 -0
- package/dist/decideReceipt.js +29 -1
- package/dist/declared/supportFloorDeclared.js +2 -2
- package/dist/deviceRebind.d.ts +7 -0
- package/dist/deviceRebind.js +39 -5
- package/dist/displayUntrusted.d.ts +4 -2
- package/dist/displayUntrusted.js +45 -22
- package/dist/engineAddress.d.ts +3 -0
- package/dist/engineAddress.js +25 -0
- package/dist/engineDirectory.js +9 -17
- package/dist/engineErrorCodes.d.ts +8 -0
- package/dist/engineErrorCodes.js +8 -0
- package/dist/engineGenerationPort.d.ts +11 -2
- package/dist/engineGenerationPort.js +63 -9
- package/dist/engineHealthFacts.d.ts +5 -0
- package/dist/engineHealthFacts.js +11 -0
- package/dist/engineNoticeCodes.d.ts +26 -3
- package/dist/engineNoticeCodes.js +52 -7
- package/dist/engineRowRef.js +1 -1
- package/dist/errorSupplementRoles.js +2 -0
- package/dist/eventLeg.d.ts +3 -3
- package/dist/eventLeg.js +25 -4
- package/dist/fleet/fleetProjection.js +26 -5
- package/dist/generated/engineFactTables.d.ts +3 -1
- package/dist/generated/engineFactTables.js +4 -1
- package/dist/generated/engineNoticeTables.js +19 -4
- package/dist/generated/sdkFactTables.d.ts +5 -0
- package/dist/generated/sdkFactTables.js +24 -0
- package/dist/generated/settingsSchemaFns.d.ts +11 -0
- package/dist/generated/settingsSchemaFns.js +2 -1
- package/dist/generated/settingsSchemaSafetyMergeSpec.js +1 -1
- package/dist/generated/settingsSchemaSettingsSources.d.ts +1 -1
- package/dist/generated/settingsSchemaSettingsSources.js +22 -2
- package/dist/headlessReconnectWire.js +31 -4
- package/dist/hitl/approvalLiveFace.d.ts +17 -0
- package/dist/hitl/approvalLiveFace.js +35 -0
- package/dist/hitl/approvalQueueRow.d.ts +21 -0
- package/dist/hitl/approvalQueueRow.js +69 -0
- package/dist/hitl/approvalsFeed.d.ts +5 -4
- package/dist/hitl/approvalsFeed.js +38 -6
- package/dist/hitl/askGateWire.js +26 -2
- package/dist/hitl/askParkRowRouting.d.ts +4 -3
- package/dist/hitl/askParkRowRouting.js +15 -3
- package/dist/hitl/automaticAnswerVerdict.js +13 -10
- package/dist/hitl/crashConverged.d.ts +5 -1
- package/dist/hitl/decisionConflict.js +2 -1
- package/dist/hitl/decisionRefusal.js +1 -1
- package/dist/hitl/decisionSend.d.ts +1 -0
- package/dist/hitl/decisionSend.js +14 -2
- package/dist/hitl/frameRouter.d.ts +4 -0
- package/dist/hitl/frameRouter.js +18 -5
- package/dist/hitl/gateIdentity.d.ts +1 -0
- package/dist/hitl/gateIdentity.js +3 -0
- package/dist/hitl/hitlBridge.d.ts +1 -1
- package/dist/hitl/hitlBridge.js +26 -5
- package/dist/hitl/livePendingAsk.d.ts +5 -0
- package/dist/hitl/livePendingAsk.js +6 -1
- package/dist/hitl/planReviewCard.d.ts +23 -0
- package/dist/hitl/planReviewCard.js +250 -0
- package/dist/hitl/planReviewWire.d.ts +39 -14
- package/dist/hitl/planReviewWire.js +450 -163
- package/dist/hitl/sessionAllowRoute.d.ts +2 -0
- package/dist/hitl/sessionAllowRoute.js +7 -0
- package/dist/hitl/sessionPolicyWire.d.ts +1 -7
- package/dist/hitl/sessionPolicyWire.js +3 -43
- package/dist/hitl/subagentSource.d.ts +1 -0
- package/dist/hitl/subagentSource.js +13 -0
- package/dist/hitl/toolApprovalWire.d.ts +3 -2
- package/dist/hitl/toolApprovalWire.js +79 -37
- package/dist/hostSettingsSource.d.ts +5 -2
- package/dist/hostSettingsSource.js +19 -10
- package/dist/hostTurnSettings.d.ts +5 -6
- package/dist/hostTurnSettings.js +106 -26
- package/dist/i18n/messages.en.d.ts +85 -12
- package/dist/i18n/messages.en.js +85 -12
- package/dist/i18n/messages.zh.js +88 -12
- package/dist/index.d.ts +35 -4
- package/dist/index.js +19 -2
- package/dist/liveInitToolFace.js +0 -1
- package/dist/liveModelCatalog.d.ts +15 -0
- package/dist/liveModelCatalog.js +40 -0
- package/dist/mcpTransportKindsCapability.d.ts +18 -0
- package/dist/mcpTransportKindsCapability.js +75 -0
- package/dist/mcpWireCaps.d.ts +4 -1
- package/dist/mcpWireCaps.js +25 -14
- package/dist/modelCapabilityProbe.js +66 -33
- package/dist/notifications.d.ts +9 -0
- package/dist/notifications.js +11 -2
- package/dist/ownKey.d.ts +4 -1
- package/dist/ownKey.js +8 -2
- package/dist/permissionModeWriteCapability.d.ts +13 -0
- package/dist/permissionModeWriteCapability.js +35 -0
- package/dist/permissionsAllowGrantCapability.d.ts +3 -0
- package/dist/permissionsAllowGrantCapability.js +26 -3
- package/dist/permissionsDeclaration.d.ts +25 -3
- package/dist/permissionsDeclaration.js +69 -41
- package/dist/planReviewCardFacts.d.ts +116 -0
- package/dist/planReviewCardFacts.js +469 -0
- package/dist/projectSeed.d.ts +39 -0
- package/dist/projectSeed.js +80 -0
- package/dist/promptDelivery.js +1 -1
- package/dist/reattachWindow.d.ts +8 -1
- package/dist/reattachWindow.js +44 -12
- package/dist/replayBody.d.ts +7 -6
- package/dist/replayBody.js +62 -7
- package/dist/request/taskRequest.js +3 -4
- package/dist/ruleCompileVerdict.d.ts +0 -2
- package/dist/ruleCompileVerdict.js +0 -31
- package/dist/ruleRefusalSentence.js +0 -3
- package/dist/runFollow.d.ts +30 -0
- package/dist/runFollow.js +117 -0
- package/dist/runLedgerSnapshot.d.ts +20 -0
- package/dist/runLedgerSnapshot.js +272 -0
- package/dist/runPermissionModeSwitch.d.ts +57 -0
- package/dist/runPermissionModeSwitch.js +135 -0
- package/dist/runReattachPolicy.d.ts +16 -5
- package/dist/runReattachPolicy.js +72 -24
- package/dist/runTerminal.js +30 -8
- package/dist/sandboxWire.d.ts +0 -3
- package/dist/sandboxWire.js +0 -9
- package/dist/seam.d.ts +17 -7
- package/dist/seam.js +13 -1
- package/dist/seatContract.d.ts +57 -7
- package/dist/seatContract.js +133 -3
- package/dist/serverSupportRange.d.ts +18 -0
- package/dist/serverSupportRange.js +25 -0
- package/dist/sessionEngine.d.ts +156 -0
- package/dist/sessionEngine.js +464 -0
- package/dist/sessionMap.d.ts +11 -1
- package/dist/sessionMap.js +35 -9
- package/dist/sessionMemoryErase.d.ts +1 -1
- package/dist/sessionMemoryErase.js +5 -0
- package/dist/sessionMemoryStatus.d.ts +27 -1
- package/dist/sessionMemoryStatus.js +117 -0
- package/dist/sessionMemorySync.d.ts +31 -0
- package/dist/sessionMemorySync.js +95 -0
- package/dist/sessionRowTag.d.ts +4 -0
- package/dist/sessionRowTag.js +18 -0
- package/dist/settingsLayerAdmission.d.ts +1 -0
- package/dist/settingsLayerAdmission.js +4 -1
- package/dist/sseIdleTriage.d.ts +3 -1
- package/dist/sseIdleTriage.js +19 -4
- package/dist/subagent/engineSubagentTail.js +2 -0
- package/dist/subagentContentStore.d.ts +3 -0
- package/dist/subagentContentStore.js +10 -1
- package/dist/toolResult.js +1 -1
- package/dist/turnFailurePresentation.d.ts +5 -2
- package/dist/turnFailurePresentation.js +12 -4
- package/dist/wireRefusalCopy.js +2 -6
- package/docs/INTEGRATION-CLIENTS.md +1507 -18
- package/package.json +5 -5
package/dist/adapt/arms.js
CHANGED
|
@@ -2,7 +2,7 @@ import { ccToolDenialKindForToolEnd, gateOutcomeOf } from '../gateOutcome.js';
|
|
|
2
2
|
import { terminalOwnerOf } from '../seam.js';
|
|
3
3
|
import { isSubFlowSegmentEnd, SEGMENT_END_IDENTITY_KEYS, snapshotSegmentIdentity, snapshotIsSubFlow } from '../adapter/types.js';
|
|
4
4
|
import { classifyPeerNotification, renderPeerFrameTranscriptText } from '../peerFrames.js';
|
|
5
|
-
import { dropQueuedNotificationsForRun, freezeTaskNotificationFields, isEngineWorkflowNotified, isWorkflowCompletionCardEnqueued, markEngineWorkflowNotified, noteOwnWorkflowRun, normalizeTaskNotification, noteWorkflowCompletionCardEnqueued, renderTaskNotificationXml,
|
|
5
|
+
import { dropQueuedNotificationsForRun, freezeTaskNotificationFields, isEngineWorkflowNotified, isWorkflowCompletionCardEnqueued, markEngineWorkflowNotified, noteOwnWorkflowRun, normalizeTaskNotification, noteWorkflowCompletionCardEnqueued, renderTaskNotificationXml, taskNotificationRenderKeys } from '../notifications.js';
|
|
6
6
|
import { retryStatusFromArm } from '../retryStatus.js';
|
|
7
7
|
import { steeringInjectedToAttachments } from '../steering.js';
|
|
8
8
|
import { projectDiagnosticsFrame } from '../diagnostics.js';
|
|
@@ -15,7 +15,7 @@ import { readToolHistoryMismatchKey } from '../toolHistoryMismatch.js';
|
|
|
15
15
|
import { isMintedRowCcError, readProviderRejectionResendKey } from '../providerRejection.js';
|
|
16
16
|
import { rowKindOf } from '../rowKind.js';
|
|
17
17
|
import { terminalCodedDetailOf } from '../runTerminal.js';
|
|
18
|
-
import { contextUsageReadingOf, guardedRead, humanInputAttachmentsOf, ownSnapshotRecord, ownSnapshotWhenTyped, readOwnDataValue, promptManifestIdentityOfFrame, promptManifestSectionViewOf, readFrameStringKey, readFrameTrueMark } from '../ownKey.js';
|
|
18
|
+
import { contextUsageReadingOf, guardedRead, humanInputAttachmentsOf, ownSnapshotRecord, ownSnapshotWhenTyped, readOwnDataNonEmptyString, readOwnDataValue, promptManifestIdentityOfFrame, promptManifestSectionViewOf, readFrameStringKey, readFrameTrueMark, workflowCompletionExtrasOf } from '../ownKey.js';
|
|
19
19
|
import { CORE_USER_ATTACHMENT_LABEL_MAX } from '../generated/engineFactTables.js';
|
|
20
20
|
import { ESCAPE_FACE, paintAndCap, washCredentials } from '../displayUntrusted.js';
|
|
21
21
|
import { resolveEnginePanelTaskId } from '../engineAgentPanelStore.js';
|
|
@@ -388,6 +388,13 @@ const approvalFrameArm = (kind) => function* (m) {
|
|
|
388
388
|
return;
|
|
389
389
|
yield chrome({ kind, laneProof: mainLane(), frame, schemaVersion });
|
|
390
390
|
};
|
|
391
|
+
const sessionTitledArm = function* (m) {
|
|
392
|
+
const sessionId = guardedRead(() => readOwnDataNonEmptyString(m, 'sessionId'));
|
|
393
|
+
const title = guardedRead(() => readOwnDataNonEmptyString(m, 'title'));
|
|
394
|
+
if (sessionId === undefined || title === undefined)
|
|
395
|
+
return;
|
|
396
|
+
yield chrome({ kind: 'session_titled', laneProof: mainLane(), sessionId, title });
|
|
397
|
+
};
|
|
391
398
|
const toolDisclosureArm = function* (m) {
|
|
392
399
|
if (isSubFlowSegmentEnd(m))
|
|
393
400
|
return;
|
|
@@ -961,15 +968,19 @@ const taskNotificationArm = function* (m, { ctx, idOf, panel, inst }) {
|
|
|
961
968
|
: {}),
|
|
962
969
|
});
|
|
963
970
|
}
|
|
964
|
-
const
|
|
971
|
+
const dedupKeys = taskNotificationRenderKeys({
|
|
965
972
|
taskId,
|
|
966
973
|
status: rawStatus,
|
|
967
974
|
...(typeof n.seq === 'number' || typeof n.seq === 'string' ? { seq: n.seq } : {}),
|
|
968
975
|
...(typeof n.task_type === 'string' ? { taskType: n.task_type } : {}),
|
|
976
|
+
...(fields.completionId !== undefined ? { completionId: fields.completionId } : {}),
|
|
969
977
|
});
|
|
970
|
-
|
|
978
|
+
const sameFrameSeen = inst.hasRenderedNotification(dedupKeys[0]);
|
|
979
|
+
const sameCompletionSeen = !sameFrameSeen && dedupKeys.slice(1).some((k) => inst.hasRenderedNotification(k));
|
|
980
|
+
for (const k of dedupKeys)
|
|
981
|
+
inst.addRenderedNotification(k);
|
|
982
|
+
if (sameFrameSeen)
|
|
971
983
|
return;
|
|
972
|
-
inst.addRenderedNotification(dedupKey);
|
|
973
984
|
if (n.task_type !== 'external' && terminal) {
|
|
974
985
|
yield chrome({
|
|
975
986
|
kind: 'notification_terminal',
|
|
@@ -990,6 +1001,8 @@ const taskNotificationArm = function* (m, { ctx, idOf, panel, inst }) {
|
|
|
990
1001
|
if (peerFrame === null && n.task_type !== 'external')
|
|
991
1002
|
markEngineWorkflowNotified(taskId);
|
|
992
1003
|
const fact = peerFrame === null ? freezeTaskNotificationFields(fields) : undefined;
|
|
1004
|
+
if (sameCompletionSeen)
|
|
1005
|
+
return;
|
|
993
1006
|
yield transcript({
|
|
994
1007
|
type: 'user',
|
|
995
1008
|
message: {
|
|
@@ -1019,7 +1032,8 @@ const workflowCompleteArm = function* (frame) {
|
|
|
1019
1032
|
const wfStatus = m.status === 'failed' ? 'failed' : 'completed';
|
|
1020
1033
|
const wfSummary = typeof m.summary === 'string' ? m.summary : '';
|
|
1021
1034
|
noteWorkflowCompletionCardEnqueued(runId);
|
|
1022
|
-
const
|
|
1035
|
+
const extras = workflowCompletionExtrasOf(m);
|
|
1036
|
+
const notification = freezeTaskNotificationFields({ taskId: runId, taskType: 'workflow', status: wfStatus, summary: wfSummary, ...(extras.completionId !== undefined ? { completionId: extras.completionId } : {}) });
|
|
1023
1037
|
yield chrome({
|
|
1024
1038
|
kind: 'workflow_notification_enqueue',
|
|
1025
1039
|
laneProof: mainLane(),
|
|
@@ -1028,6 +1042,7 @@ const workflowCompleteArm = function* (frame) {
|
|
|
1028
1042
|
summary: wfSummary,
|
|
1029
1043
|
message: renderTaskNotificationXml(notification),
|
|
1030
1044
|
notification,
|
|
1045
|
+
...(extras.diagnostics !== undefined ? { diagnostics: extras.diagnostics } : {}),
|
|
1031
1046
|
});
|
|
1032
1047
|
};
|
|
1033
1048
|
const retryStatusArm = function* (m, { ctx, flags }) {
|
|
@@ -1091,6 +1106,8 @@ export const ARMS = new Map([
|
|
|
1091
1106
|
['wiring_manifest', wiringManifestArm],
|
|
1092
1107
|
['approval_request', approvalFrameArm('approval_request')],
|
|
1093
1108
|
['approval_revoke', approvalFrameArm('approval_revoke')],
|
|
1109
|
+
['approval_complete', approvalFrameArm('approval_complete')],
|
|
1110
|
+
['session_titled', sessionTitledArm],
|
|
1094
1111
|
['prompt_suggestions', promptSuggestionsArm],
|
|
1095
1112
|
['retry_status', retryStatusArm],
|
|
1096
1113
|
]);
|
|
@@ -5,7 +5,7 @@ import type { PlanReviewReopenTrigger } from '../hitl/planReviewWire.js';
|
|
|
5
5
|
import { type AskParkAutoReopenBlock } from '../hitl/askParkAutoReopenBlock.js';
|
|
6
6
|
import { atMostOnceFailureClass } from '../atMostOnce.js';
|
|
7
7
|
export declare const PLAN_REVIEW_GATE_KIND = "plan_review";
|
|
8
|
-
export type DurableDecideLeg = 'approval' | 'plan_review' | 'other_gate' | 'unreadable'
|
|
8
|
+
export type DurableDecideLeg = 'approval' | 'plan_review' | 'other_gate' | 'unreadable';
|
|
9
9
|
export declare function durableDecideLegOf(row: {
|
|
10
10
|
readonly gateKind?: string | null;
|
|
11
11
|
} | null | undefined): DurableDecideLeg;
|
|
@@ -75,6 +75,7 @@ export interface ActiveRunSelfHealDeps {
|
|
|
75
75
|
}) => Promise<number>;
|
|
76
76
|
reopenPlanReview?: (taskId: string, opts?: {
|
|
77
77
|
trigger?: PlanReviewReopenTrigger;
|
|
78
|
+
checkpointId?: string;
|
|
78
79
|
}) => ReopenCardVerdict | Promise<ReopenCardVerdict>;
|
|
79
80
|
reopenAskPark?: (taskId: string, opts?: {
|
|
80
81
|
trigger?: PlanReviewReopenTrigger;
|
|
@@ -86,6 +87,7 @@ export interface ActiveRunSelfHealDeps {
|
|
|
86
87
|
signal?: AbortSignal;
|
|
87
88
|
cancelReleaseWaitMs?: number;
|
|
88
89
|
submissionOrigin?: RejectedSubmissionOrigin;
|
|
90
|
+
injectedCarriers?: readonly object[];
|
|
89
91
|
sessionId?: string;
|
|
90
92
|
wasRecentlyTerminatedByUs?: (taskId: string) => boolean;
|
|
91
93
|
interruptedSettle?: InterruptedSettleWindow;
|
|
@@ -170,6 +172,12 @@ export type SelfHealOutcome = {
|
|
|
170
172
|
} | {
|
|
171
173
|
kind: 'running-attach';
|
|
172
174
|
taskId: string;
|
|
175
|
+
} | {
|
|
176
|
+
kind: 'injected-redundant';
|
|
177
|
+
taskId: string;
|
|
178
|
+
} | {
|
|
179
|
+
kind: 'injected-deferred';
|
|
180
|
+
taskId: string;
|
|
173
181
|
} | {
|
|
174
182
|
kind: 'running-cancelled';
|
|
175
183
|
taskId: string;
|
|
@@ -214,7 +222,7 @@ export type SelfHealOutcome = {
|
|
|
214
222
|
alreadyOffered?: true;
|
|
215
223
|
};
|
|
216
224
|
export type { RejectedSubmissionOrigin };
|
|
217
|
-
export type SelfHealSubmissionDisposition = 'held-for-decision' | 'resending' | 'handed-off' | 'not-delivered';
|
|
225
|
+
export type SelfHealSubmissionDisposition = 'held-for-decision' | 'resending' | 'handed-off' | 'not-delivered' | 'superseded' | 'deferred';
|
|
218
226
|
export declare function selfHealSubmissionDisposition(outcome: SelfHealOutcome): SelfHealSubmissionDisposition;
|
|
219
227
|
export type SteerFollowIntent = {
|
|
220
228
|
kind: 'tail';
|
|
@@ -225,11 +233,15 @@ export type SteerFollowIntent = {
|
|
|
225
233
|
} | {
|
|
226
234
|
kind: 'after-wake';
|
|
227
235
|
taskId: string;
|
|
236
|
+
} | {
|
|
237
|
+
kind: 'follow-resumed';
|
|
238
|
+
taskId: string;
|
|
228
239
|
};
|
|
229
240
|
export declare function steerFollowIntent(outcome: SelfHealOutcome | null | undefined): SteerFollowIntent | null;
|
|
230
241
|
export interface SelfHealFollowDeclaration {
|
|
231
242
|
following?: boolean;
|
|
232
243
|
}
|
|
244
|
+
export declare function injectedResubmitAfter(outcome: SelfHealOutcome | null | undefined, runStatus: string | null | undefined): boolean;
|
|
233
245
|
export declare function readCancelRequested(body: unknown): boolean | undefined;
|
|
234
246
|
export { atMostOnceFailureClass };
|
|
235
247
|
export declare function clearRunningChoiceOffer(taskId: string, sessionId?: string): void;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { abortableSleep } from '../abortableSleep.js';
|
|
2
2
|
import { EN_MESSAGES } from '../i18n/messages.en.js';
|
|
3
3
|
import { msg, renderMessage } from '../i18n/translate.js';
|
|
4
|
+
import { registeredPlanReviewCardFacts } from '../planReviewCardFacts.js';
|
|
5
|
+
import { DEFAULT_SESSION_KEY } from '../sessionSlot.js';
|
|
4
6
|
import { ASK_PARK_AUTO_REOPEN_BLOCKS, askParkAutoReopenBlockedContent } from '../hitl/askParkAutoReopenBlock.js';
|
|
5
7
|
import { corruptStoredRowContent, corruptStoredRowWhere, effectiveWireErrorCode } from '../wireErrorTriage.js';
|
|
6
8
|
import { readThrownStatusSlot } from '../wireFailureShape.js';
|
|
9
|
+
import { guardedRead, readOwnDataNonEmptyString, readOwnDataValue } from '../ownKey.js';
|
|
7
10
|
import { steerBodyOf, UNOBSERVED_STEER_PRIORITY } from '../controlRouter.js';
|
|
8
11
|
import { atMostOnceFailureClass } from '../atMostOnce.js';
|
|
9
12
|
import { readSteerReceipt } from '../steerReceipt.js';
|
|
@@ -26,7 +29,7 @@ function gateKindReadingOf(row) {
|
|
|
26
29
|
return { leg: 'unreadable', kind: null };
|
|
27
30
|
}
|
|
28
31
|
if (typeof kind !== 'string' || kind === '')
|
|
29
|
-
return { leg: '
|
|
32
|
+
return { leg: 'unreadable', kind: null };
|
|
30
33
|
if (APPROVAL_LEG_GATE_KINDS.includes(kind))
|
|
31
34
|
return { leg: 'approval', kind };
|
|
32
35
|
if (PLAN_LEG_GATE_KINDS.includes(kind))
|
|
@@ -40,7 +43,7 @@ export function durableDecideLegOf(row) {
|
|
|
40
43
|
}
|
|
41
44
|
export function askParkForeignGateKind(row) {
|
|
42
45
|
const r = gateKindReadingOf(row);
|
|
43
|
-
return r.leg === 'approval'
|
|
46
|
+
return r.leg === 'approval' ? null : (r.kind ?? '(unreadable)');
|
|
44
47
|
}
|
|
45
48
|
export const PLAN_REVIEW_STATES = Object.freeze(['needs_review']);
|
|
46
49
|
export const ASK_PARK_STATES = Object.freeze(['suspended']);
|
|
@@ -68,12 +71,20 @@ export function selfHealSubmissionDisposition(outcome) {
|
|
|
68
71
|
return 'not-delivered';
|
|
69
72
|
case 'running-attach':
|
|
70
73
|
return 'not-delivered';
|
|
74
|
+
case 'injected-redundant':
|
|
75
|
+
return 'superseded';
|
|
76
|
+
case 'injected-deferred':
|
|
77
|
+
return 'deferred';
|
|
71
78
|
default:
|
|
72
79
|
return 'not-delivered';
|
|
73
80
|
}
|
|
74
81
|
}
|
|
75
82
|
export function steerFollowIntent(outcome) {
|
|
76
|
-
if (typeof outcome !== 'object' || outcome === null
|
|
83
|
+
if (typeof outcome !== 'object' || outcome === null)
|
|
84
|
+
return null;
|
|
85
|
+
if (outcome.kind === 'injected-redundant')
|
|
86
|
+
return { kind: 'follow-resumed', taskId: outcome.taskId };
|
|
87
|
+
if (outcome.kind !== 'running-steered')
|
|
77
88
|
return null;
|
|
78
89
|
const taskId = outcome.taskId;
|
|
79
90
|
if (outcome.delivery === 'queued')
|
|
@@ -82,6 +93,58 @@ export function steerFollowIntent(outcome) {
|
|
|
82
93
|
return { kind: 'after-wake', taskId };
|
|
83
94
|
return { kind: 'tail', taskId };
|
|
84
95
|
}
|
|
96
|
+
const injectedResubmitReleased = new WeakSet();
|
|
97
|
+
export function injectedResubmitAfter(outcome, runStatus) {
|
|
98
|
+
try {
|
|
99
|
+
if (typeof outcome !== 'object' || outcome === null || outcome.kind !== 'injected-deferred')
|
|
100
|
+
return false;
|
|
101
|
+
if (!isSdkRunTerminal(runStatus) && !isSdkRunParked(runStatus))
|
|
102
|
+
return false;
|
|
103
|
+
if (injectedResubmitReleased.has(outcome))
|
|
104
|
+
return false;
|
|
105
|
+
injectedResubmitReleased.add(outcome);
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const PLAN_REVIEW_CARRIER_KEY = '_sema_planReviewOutcome';
|
|
113
|
+
function planReviewCarrierOf(item) {
|
|
114
|
+
const meta = guardedRead(() => (typeof item === 'object' && item !== null && !Array.isArray(item) ? readOwnDataValue(item, PLAN_REVIEW_CARRIER_KEY) : undefined));
|
|
115
|
+
if (guardedRead(() => typeof meta === 'object' && meta !== null && !Array.isArray(meta)) !== true)
|
|
116
|
+
return null;
|
|
117
|
+
return { run: guardedRead(() => readOwnDataNonEmptyString(meta, 'taskId')) };
|
|
118
|
+
}
|
|
119
|
+
function injectedCarrierVerdict(items, busyTaskId) {
|
|
120
|
+
const length = guardedRead(() => (Array.isArray(items) ? readOwnDataValue(items, 'length') : undefined));
|
|
121
|
+
if (typeof length !== 'number' || !Number.isSafeInteger(length) || length <= 0)
|
|
122
|
+
return null;
|
|
123
|
+
const keys = guardedRead(() => Object.keys(items));
|
|
124
|
+
if (!Array.isArray(keys))
|
|
125
|
+
return null;
|
|
126
|
+
let present = 0;
|
|
127
|
+
let carriers = 0;
|
|
128
|
+
let allNameBusyRun = true;
|
|
129
|
+
for (let k = 0; k < keys.length; k++) {
|
|
130
|
+
const key = keys[k];
|
|
131
|
+
const index = Number(key);
|
|
132
|
+
if (typeof key !== 'string' || !Number.isSafeInteger(index) || index < 0 || index >= length || String(index) !== key)
|
|
133
|
+
continue;
|
|
134
|
+
present++;
|
|
135
|
+
const carrier = planReviewCarrierOf(guardedRead(() => readOwnDataValue(items, key)));
|
|
136
|
+
if (carrier === null) {
|
|
137
|
+
allNameBusyRun = false;
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
carriers++;
|
|
141
|
+
if (carrier.run === undefined || carrier.run !== busyTaskId)
|
|
142
|
+
allNameBusyRun = false;
|
|
143
|
+
}
|
|
144
|
+
if (carriers === 0)
|
|
145
|
+
return null;
|
|
146
|
+
return allNameBusyRun && present === length ? 'redundant' : 'deferred';
|
|
147
|
+
}
|
|
85
148
|
function sessionOpts(deps) {
|
|
86
149
|
const sessionId = deps?.sessionId;
|
|
87
150
|
return typeof sessionId === 'string' && sessionId.length > 0 ? { session: sessionId } : {};
|
|
@@ -521,9 +584,11 @@ export async function attemptActiveRunSelfHeal(signal, runs, deps) {
|
|
|
521
584
|
};
|
|
522
585
|
}
|
|
523
586
|
const gateKind = signal.pendingGate?.kind ?? null;
|
|
524
|
-
const gateLeg =
|
|
587
|
+
const gateLeg = durableDecideLegOf({ gateKind });
|
|
588
|
+
const pendingCp = signal.pendingGate?.checkpointId;
|
|
589
|
+
const sameTaskCp = pendingCp !== undefined && registeredPlanReviewCardFacts(DEFAULT_SESSION_KEY, taskId, pendingCp) !== undefined ? pendingCp : undefined;
|
|
525
590
|
if (gateLeg === 'plan_review')
|
|
526
|
-
return planReviewArm(taskId, signal, deps);
|
|
591
|
+
return planReviewArm(taskId, signal, deps, sameTaskCp);
|
|
527
592
|
if (gateLeg === 'approval')
|
|
528
593
|
return askParkArm(taskId, signal, runs, deps);
|
|
529
594
|
let status = signal.activeTaskStatus;
|
|
@@ -558,10 +623,11 @@ export async function attemptActiveRunSelfHeal(signal, runs, deps) {
|
|
|
558
623
|
}
|
|
559
624
|
return { kind: 'not-parked', taskId, status, ...triageGate };
|
|
560
625
|
}
|
|
561
|
-
async function planVerdict(taskId, deps) {
|
|
626
|
+
async function planVerdict(taskId, deps, checkpointId) {
|
|
562
627
|
try {
|
|
563
628
|
const trigger = planReviewReopenTriggerFor(deps?.submissionOrigin);
|
|
564
|
-
const
|
|
629
|
+
const second = { ...(trigger !== undefined ? { trigger } : {}), ...(checkpointId !== undefined && checkpointId.length > 0 ? { checkpointId } : {}) };
|
|
630
|
+
const verdict = Object.keys(second).length === 0 ? deps?.reopenPlanReview?.(taskId) : deps?.reopenPlanReview?.(taskId, second);
|
|
565
631
|
return snapshotReopenVerdict(await verdict);
|
|
566
632
|
}
|
|
567
633
|
catch (e) {
|
|
@@ -581,8 +647,8 @@ async function askVerdict(taskId, deps) {
|
|
|
581
647
|
return thrownReopenVerdict(e);
|
|
582
648
|
}
|
|
583
649
|
}
|
|
584
|
-
async function planReviewArm(taskId, signal, deps) {
|
|
585
|
-
const verdict = await planVerdict(taskId, deps);
|
|
650
|
+
async function planReviewArm(taskId, signal, deps, checkpointId) {
|
|
651
|
+
const verdict = await planVerdict(taskId, deps, checkpointId);
|
|
586
652
|
if (reopenDelivered(verdict))
|
|
587
653
|
return { kind: 'plan-review-reopened', taskId, firstSight: verdict.firstSight === true };
|
|
588
654
|
const inFlight = reopenRefusedForDecisionInFlight(verdict);
|
|
@@ -809,15 +875,16 @@ async function runningChoiceArm(taskId, status, busy, statusFromWire, runs, deps
|
|
|
809
875
|
const notParked = { kind: 'not-parked', taskId, status };
|
|
810
876
|
const offer = deps?.offerRunningChoice;
|
|
811
877
|
const injected = deps?.submissionOrigin === 'injected';
|
|
878
|
+
const carrierVerdict = injected ? injectedCarrierVerdict(guardedRead(() => deps?.injectedCarriers), taskId) : null;
|
|
812
879
|
if (typeof offer !== 'function' && !injected)
|
|
813
880
|
return notParked;
|
|
814
881
|
const text = typeof deps?.deniedMessage === 'string' ? deps.deniedMessage : '';
|
|
815
882
|
const canSteer = typeof runs?.steer === 'function' && text.length > 0;
|
|
816
883
|
const canCancel = typeof runs?.cancel === 'function' && typeof runs?.get === 'function';
|
|
817
884
|
const canAttach = runningAttachOffered(deps?.canAttachRunning);
|
|
818
|
-
if (!canSteer && !canCancel && !canAttach)
|
|
885
|
+
if (!canSteer && !canCancel && !canAttach && carrierVerdict === null)
|
|
819
886
|
return notParked;
|
|
820
|
-
if (injected && !canSteer)
|
|
887
|
+
if (injected && !canSteer && carrierVerdict === null)
|
|
821
888
|
return notParked;
|
|
822
889
|
const probeCallerAborted = () => deps?.signal?.aborted === true;
|
|
823
890
|
if (statusFromWire && typeof runs?.get === 'function' && !probeCallerAborted()) {
|
|
@@ -842,6 +909,10 @@ async function runningChoiceArm(taskId, status, busy, statusFromWire, runs, deps
|
|
|
842
909
|
if (injected) {
|
|
843
910
|
if (probeCallerAborted())
|
|
844
911
|
return notParked;
|
|
912
|
+
if (carrierVerdict === 'redundant')
|
|
913
|
+
return { kind: 'injected-redundant', taskId };
|
|
914
|
+
if (carrierVerdict === 'deferred')
|
|
915
|
+
return { kind: 'injected-deferred', taskId };
|
|
845
916
|
choice = 'steer';
|
|
846
917
|
}
|
|
847
918
|
else if (typeof offer === 'function') {
|
|
@@ -993,7 +1064,7 @@ export function activeRunSelfHealRow(outcome, signal, copy, origin, follow, lang
|
|
|
993
1064
|
if (typeof override === 'string')
|
|
994
1065
|
return override;
|
|
995
1066
|
const following = follow?.following === true && steerFollowIntent(outcome)?.kind === 'tail';
|
|
996
|
-
if (origin === 'injected')
|
|
1067
|
+
if (origin === 'injected' || outcome.kind === 'injected-redundant' || outcome.kind === 'injected-deferred')
|
|
997
1068
|
return injectedSubmissionRow(outcome, following, lang);
|
|
998
1069
|
const engineDecide = copy?.engineDecidePath !== false;
|
|
999
1070
|
const keep = (outcome.kind === 'plan-review-reopen-failed' || outcome.kind === 'ask-reopen-failed') &&
|
|
@@ -1066,6 +1137,10 @@ function injectedSubmissionRow(outcome, following = false, lang) {
|
|
|
1066
1137
|
return following
|
|
1067
1138
|
? say(lang, 'session.selfHeal.injected.handedOffFollowing', { lead, id })
|
|
1068
1139
|
: say(lang, 'session.selfHeal.injected.handedOffWatch', { lead, id });
|
|
1140
|
+
case 'superseded':
|
|
1141
|
+
return say(lang, 'session.selfHeal.injected.redundant', { lead, id });
|
|
1142
|
+
case 'deferred':
|
|
1143
|
+
return say(lang, 'session.selfHeal.injected.deferred', { lead, id });
|
|
1069
1144
|
case 'not-delivered': {
|
|
1070
1145
|
const noView = (outcome.kind === 'ask-reopen-failed' || outcome.kind === 'plan-review-reopen-failed') && outcome.noPresentationSurface === true
|
|
1071
1146
|
? msg('session.selfHeal.noCardView.inParens')
|
|
@@ -1177,6 +1252,9 @@ function activeRunSelfHealBaseRow(outcome, wayOut, following = false, keepSessio
|
|
|
1177
1252
|
return outcome.delivery === 'rejected'
|
|
1178
1253
|
? say(lang, 'session.selfHeal.row.steerFailed.rejected', { taskId: outcome.taskId, detail: outcome.detail })
|
|
1179
1254
|
: say(lang, 'session.selfHeal.row.steerFailed.unknown', { taskId: outcome.taskId, detail: outcome.detail });
|
|
1255
|
+
case 'injected-redundant':
|
|
1256
|
+
case 'injected-deferred':
|
|
1257
|
+
return injectedSubmissionRow(outcome, following, lang);
|
|
1180
1258
|
case 'running-attach':
|
|
1181
1259
|
return say(lang, 'session.selfHeal.row.attach', { disclosure: resumeAttachReplayDisclosure(outcome.taskId) });
|
|
1182
1260
|
case 'running-cancelled':
|
|
@@ -60,11 +60,6 @@ export interface WiringManifestAutoConsolidationView {
|
|
|
60
60
|
export interface WiringManifestReadDenyView {
|
|
61
61
|
builtinTiers: readonly string[];
|
|
62
62
|
}
|
|
63
|
-
export interface WiringManifestHookEntryView {
|
|
64
|
-
family: string;
|
|
65
|
-
owner: string;
|
|
66
|
-
observational?: true;
|
|
67
|
-
}
|
|
68
63
|
export interface WiringManifestLspSeamView {
|
|
69
64
|
mounted: boolean;
|
|
70
65
|
lane?: string;
|
|
@@ -5,7 +5,7 @@ import { ccToolDenialKindForToolEnd, gateOutcomeOf, toolInputRewriteOf } from '.
|
|
|
5
5
|
import { projectToolRoster, projectToolRosterDelta } from '../../toolRoster.js';
|
|
6
6
|
import { projectHandsSection } from '../../handsSeam.js';
|
|
7
7
|
import { readMcpAuthorization, readMcpLiveness } from '../../mcpLiveness.js';
|
|
8
|
-
import { contextUsageReadingOf, humanInputAttachmentsOf, guardedRead, markMcpSectionDroppedNamedRows, ownSnapshotTyped, promptManifestIdentityOfFrame, promptManifestSectionViewOf, readFrameStringKey, readFrameTrueMark, readOwnDataFiniteNumber, readOwnDataNonEmptyString } from '../../ownKey.js';
|
|
8
|
+
import { contextUsageReadingOf, humanInputAttachmentsOf, guardedRead, markMcpSectionDroppedNamedRows, ownSnapshotTyped, promptManifestIdentityOfFrame, promptManifestSectionViewOf, readFrameStringKey, readFrameTrueMark, readOwnDataFiniteNumber, readOwnDataNonEmptyString, workflowCompletionExtrasOf } from '../../ownKey.js';
|
|
9
9
|
import { SEGMENT_END_IDENTITY_KEYS, eventSeq, stripToolUseSideChannels } from '../types.js';
|
|
10
10
|
import { frozenSet } from '../../frozenSet.js';
|
|
11
11
|
import { isCoreWorkflowRunTerminal } from '../../terminalStatuses.js';
|
|
@@ -42,7 +42,9 @@ export const INTERNAL_SDK_ARM_TYPES = frozenSet([
|
|
|
42
42
|
'wiring_manifest',
|
|
43
43
|
'approval_request',
|
|
44
44
|
'approval_revoke',
|
|
45
|
+
'approval_complete',
|
|
45
46
|
'message_committed',
|
|
47
|
+
'session_titled',
|
|
46
48
|
]);
|
|
47
49
|
function assistantArm(ctx, content, eventId, parentToolCallId, recovered) {
|
|
48
50
|
const id = typeof eventId === 'string' && eventId.length > 0 ? eventId : undefined;
|
|
@@ -113,7 +115,14 @@ function projectEvent(ev, ctx) {
|
|
|
113
115
|
return compactionStartedProjection(ev, ctx);
|
|
114
116
|
if (isBeyondFloorArm(ev)) {
|
|
115
117
|
const word = ev.type;
|
|
116
|
-
|
|
118
|
+
if (word === 'cross_boundary_taint')
|
|
119
|
+
return nothing('not_in_slice');
|
|
120
|
+
if (word === 'session_titled')
|
|
121
|
+
return sessionTitledProjection(ev, ctx);
|
|
122
|
+
const body = approvalFrameBody(ev);
|
|
123
|
+
if (body === undefined)
|
|
124
|
+
return dropped('malformed', 'approval_complete');
|
|
125
|
+
return projected(internalArmExit(stamp(ctx, armBody({ type: 'approval_complete', ...body }))));
|
|
117
126
|
}
|
|
118
127
|
switch (ev.type) {
|
|
119
128
|
case 'task_started':
|
|
@@ -166,6 +175,7 @@ function projectEvent(ev, ctx) {
|
|
|
166
175
|
runId: wf.runId,
|
|
167
176
|
status: wf.status,
|
|
168
177
|
summary: typeof wf.summary === 'string' ? wf.summary : '',
|
|
178
|
+
...workflowCompletionExtrasOf(wf),
|
|
169
179
|
})));
|
|
170
180
|
}
|
|
171
181
|
case 'text':
|
|
@@ -283,10 +293,9 @@ function projectEvent(ev, ctx) {
|
|
|
283
293
|
const nonEmptyStr = (v) => (typeof v === 'string' && v.length > 0 ? v : undefined);
|
|
284
294
|
const providerCondition = nonEmptyStr(ev.providerCondition);
|
|
285
295
|
const providerConditionSource = nonEmptyStr(ev.providerConditionSource);
|
|
286
|
-
const
|
|
287
|
-
const sleptMsRaw = guardedRead(() => readOwnDataFiniteNumber(stWait, 'sleptMs'));
|
|
296
|
+
const sleptMsRaw = guardedRead(() => readOwnDataFiniteNumber(ev, 'sleptMs'));
|
|
288
297
|
const sleptMs = sleptMsRaw !== undefined && sleptMsRaw >= 0 ? sleptMsRaw : undefined;
|
|
289
|
-
const waitSegment = readFrameStringKey(
|
|
298
|
+
const waitSegment = readFrameStringKey(ev, 'waitSegment');
|
|
290
299
|
const seat = readFrameStringKey(ev, 'seat');
|
|
291
300
|
return projected(stamp(ctx, armBody({
|
|
292
301
|
type: 'retry_status',
|
|
@@ -632,7 +641,6 @@ function wiringManifestSupersetBody(ev) {
|
|
|
632
641
|
const autoMode = projectAutoModeSection(ev.autoMode);
|
|
633
642
|
const mcp = projectMcpSection(ev.mcp);
|
|
634
643
|
const tools = projectToolRoster(ev);
|
|
635
|
-
const hooks = projectHooksSection(ev.hooks);
|
|
636
644
|
const lsp = projectLspSection(ev.lsp);
|
|
637
645
|
const writeProtection = projectWriteProtectionSection(ev.writeProtection);
|
|
638
646
|
const autoConsolidation = projectAutoConsolidationSection(ev.autoConsolidation);
|
|
@@ -642,14 +650,13 @@ function wiringManifestSupersetBody(ev) {
|
|
|
642
650
|
const instructions = readInstructionsSegment(ev, 'instructions');
|
|
643
651
|
const fleet = readFleetSegment(ev, 'fleet');
|
|
644
652
|
const mods = projectModsSection(ev);
|
|
645
|
-
if (modelGate === undefined && autoMode === undefined && mcp === undefined && tools === undefined &&
|
|
653
|
+
if (modelGate === undefined && autoMode === undefined && mcp === undefined && tools === undefined && lsp === undefined && writeProtection === undefined && autoConsolidation === undefined && readDeny === undefined && hands === undefined && fileHistory === undefined && instructions === undefined && fleet === undefined && mods === undefined)
|
|
646
654
|
return undefined;
|
|
647
655
|
return {
|
|
648
656
|
...(modelGate !== undefined ? { _sema_modelGate: modelGate } : {}),
|
|
649
657
|
...(autoMode !== undefined ? { _sema_autoMode: autoMode } : {}),
|
|
650
658
|
...(mcp !== undefined ? { _sema_mcp: mcp } : {}),
|
|
651
659
|
...(tools !== undefined ? { _sema_tools: tools } : {}),
|
|
652
|
-
...(hooks !== undefined ? { _sema_hooks: hooks } : {}),
|
|
653
660
|
...(lsp !== undefined ? { _sema_lsp: lsp } : {}),
|
|
654
661
|
...(writeProtection !== undefined ? { _sema_writeProtection: writeProtection } : {}),
|
|
655
662
|
...(autoConsolidation !== undefined ? { _sema_autoConsolidation: autoConsolidation } : {}),
|
|
@@ -710,20 +717,6 @@ function projectModsSection(holder) {
|
|
|
710
717
|
return undefined;
|
|
711
718
|
}
|
|
712
719
|
}
|
|
713
|
-
function projectHooksSection(raw) {
|
|
714
|
-
if (!Array.isArray(raw))
|
|
715
|
-
return undefined;
|
|
716
|
-
const rows = [];
|
|
717
|
-
for (const r of raw) {
|
|
718
|
-
if (typeof r !== 'object' || r === null || Array.isArray(r))
|
|
719
|
-
continue;
|
|
720
|
-
const o = r;
|
|
721
|
-
if (typeof o.family !== 'string' || o.family.length === 0 || typeof o.owner !== 'string' || o.owner.length === 0)
|
|
722
|
-
continue;
|
|
723
|
-
rows.push({ family: o.family, owner: o.owner, ...(o.observational === true ? { observational: true } : {}) });
|
|
724
|
-
}
|
|
725
|
-
return rows.length > 0 ? rows : undefined;
|
|
726
|
-
}
|
|
727
720
|
function projectLspSection(raw) {
|
|
728
721
|
if (typeof raw !== 'object' || raw === null || Array.isArray(raw))
|
|
729
722
|
return undefined;
|
|
@@ -809,6 +802,13 @@ function compactionOutcomeProjection(frame, ctx) {
|
|
|
809
802
|
...identity,
|
|
810
803
|
}))));
|
|
811
804
|
}
|
|
805
|
+
function sessionTitledProjection(frame, ctx) {
|
|
806
|
+
const sessionId = guardedRead(() => readOwnDataNonEmptyString(frame, 'sessionId'));
|
|
807
|
+
const title = guardedRead(() => readOwnDataNonEmptyString(frame, 'title'));
|
|
808
|
+
if (sessionId === undefined || title === undefined)
|
|
809
|
+
return dropped('malformed', 'session_titled');
|
|
810
|
+
return projected(internalArmExit(stamp(ctx, armBody({ type: 'session_titled', sessionId, title }))));
|
|
811
|
+
}
|
|
812
812
|
function compactionStartedProjection(frame, ctx) {
|
|
813
813
|
const ev = frame;
|
|
814
814
|
const { identity, bad } = identityOrMalformed(ev, 'compaction_started');
|
|
@@ -917,7 +917,8 @@ function engineNoticeProjection(ev, ctx) {
|
|
|
917
917
|
...(seq !== undefined ? { eventSeq: seq } : {}),
|
|
918
918
|
})));
|
|
919
919
|
}
|
|
920
|
-
function approvalFrameBody(
|
|
920
|
+
function approvalFrameBody(frame) {
|
|
921
|
+
const ev = frame;
|
|
921
922
|
const schemaVersion = typeof ev.schemaVersion === 'number' && Number.isFinite(ev.schemaVersion)
|
|
922
923
|
? ev.schemaVersion
|
|
923
924
|
: undefined;
|
|
@@ -702,12 +702,11 @@ export function doneToSdkResult(ev, ctx, observed) {
|
|
|
702
702
|
}
|
|
703
703
|
function doneToSdkResultBody(ev, ctx, observed) {
|
|
704
704
|
const view = doneResultView(ev.result);
|
|
705
|
-
const rRaw = view.
|
|
705
|
+
const rRaw = view.body;
|
|
706
706
|
const rec = typeof rRaw === 'object' && rRaw !== null ? rRaw : {};
|
|
707
707
|
const r = rec;
|
|
708
708
|
const stats = r.stats;
|
|
709
|
-
const
|
|
710
|
-
const echoedSid = typeof nestedSid === 'string' && nestedSid.length > 0 ? nestedSid : view.row?.sessionId;
|
|
709
|
+
const echoedSid = r.sessionId;
|
|
711
710
|
if (typeof echoedSid === 'string' && echoedSid.length > 0)
|
|
712
711
|
ctx.sessionId = echoedSid;
|
|
713
712
|
const terminal = readRunTerminal(ev.result);
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import type { WiringManifestModelGate, WiringManifestAutoMode, WiringManifestMcpEntryView,
|
|
1
|
+
import type { WiringManifestModelGate, WiringManifestAutoMode, WiringManifestMcpEntryView, WiringManifestLspSeamView, WiringManifestWriteProtectionView, WiringManifestAutoConsolidationView, WiringManifestReadDenyView, WiringManifestModView } from './eventToSdkMessage.js';
|
|
2
2
|
import type { ToolRosterView, WiringManifestHandsView } from '../../toolRoster.js';
|
|
3
3
|
export type WiringManifestSections = {
|
|
4
4
|
_sema_modelGate?: WiringManifestModelGate;
|
|
5
5
|
_sema_autoMode?: WiringManifestAutoMode;
|
|
6
6
|
_sema_mcp?: WiringManifestMcpEntryView[];
|
|
7
7
|
_sema_tools?: ToolRosterView;
|
|
8
|
-
_sema_hooks?: WiringManifestHookEntryView[];
|
|
9
8
|
_sema_lsp?: WiringManifestLspSeamView;
|
|
10
9
|
_sema_writeProtection?: WiringManifestWriteProtectionView;
|
|
11
10
|
_sema_autoConsolidation?: WiringManifestAutoConsolidationView;
|
|
@@ -27,7 +26,6 @@ export interface WiringManifestView {
|
|
|
27
26
|
autoMode?: WiringManifestAutoMode;
|
|
28
27
|
mcp?: readonly WiringManifestMcpEntryView[];
|
|
29
28
|
tools?: ToolRosterView;
|
|
30
|
-
hooks?: readonly WiringManifestHookEntryView[];
|
|
31
29
|
lsp?: WiringManifestLspSeamView;
|
|
32
30
|
writeProtection?: WiringManifestWriteProtectionView;
|
|
33
31
|
autoConsolidation?: WiringManifestAutoConsolidationView;
|
|
@@ -47,3 +45,9 @@ export declare function readInstructionsSegment(holder: object, key: 'instructio
|
|
|
47
45
|
export declare function readFleetSegment(holder: object, key: 'fleet' | '_sema_fleet'): WiringManifestFleetView | undefined;
|
|
48
46
|
export declare function wiringManifestViewOf(s: WiringManifestSections): WiringManifestView | undefined;
|
|
49
47
|
export declare function modRowsOf(records: unknown): readonly WiringManifestModView[] | undefined;
|
|
48
|
+
export interface PermissionModeReceiptView {
|
|
49
|
+
readonly requested?: string;
|
|
50
|
+
readonly effective: string;
|
|
51
|
+
readonly foldedBy?: string;
|
|
52
|
+
}
|
|
53
|
+
export declare function readPermissionModeReceiptSegment(holder: object, key: 'permissionMode'): PermissionModeReceiptView | undefined;
|
|
@@ -51,7 +51,6 @@ export function wiringManifestViewOf(s) {
|
|
|
51
51
|
...(isObj(s._sema_autoMode) ? { autoMode: s._sema_autoMode } : {}),
|
|
52
52
|
...(Array.isArray(s._sema_mcp) ? { mcp: s._sema_mcp } : {}),
|
|
53
53
|
...(isObj(s._sema_tools) ? { tools: s._sema_tools } : {}),
|
|
54
|
-
...(Array.isArray(s._sema_hooks) ? { hooks: s._sema_hooks } : {}),
|
|
55
54
|
...(isObj(s._sema_lsp) ? { lsp: s._sema_lsp } : {}),
|
|
56
55
|
...(isObj(s._sema_writeProtection) ? { writeProtection: s._sema_writeProtection } : {}),
|
|
57
56
|
...(isObj(s._sema_autoConsolidation) ? { autoConsolidation: s._sema_autoConsolidation } : {}),
|
|
@@ -208,3 +207,28 @@ export function modRowsOf(records) {
|
|
|
208
207
|
return undefined;
|
|
209
208
|
}
|
|
210
209
|
}
|
|
210
|
+
export function readPermissionModeReceiptSegment(holder, key) {
|
|
211
|
+
try {
|
|
212
|
+
const seg = ownSlot(holder, key);
|
|
213
|
+
if (seg.state !== 'value' || !isModRecordObject(seg.value))
|
|
214
|
+
return undefined;
|
|
215
|
+
const raw = seg.value;
|
|
216
|
+
const effective = nonEmpty(ownSlot(raw, 'effective'));
|
|
217
|
+
if (effective === undefined)
|
|
218
|
+
return undefined;
|
|
219
|
+
const requestedSlot = ownSlot(raw, 'requested');
|
|
220
|
+
const foldedBySlot = ownSlot(raw, 'foldedBy');
|
|
221
|
+
const requested = nonEmpty(requestedSlot);
|
|
222
|
+
const foldedBy = nonEmpty(foldedBySlot);
|
|
223
|
+
if ((requestedSlot.state !== 'absent' && requested === undefined) || (foldedBySlot.state !== 'absent' && foldedBy === undefined))
|
|
224
|
+
return undefined;
|
|
225
|
+
return Object.freeze({
|
|
226
|
+
...(requested !== undefined ? { requested } : {}),
|
|
227
|
+
effective,
|
|
228
|
+
...(foldedBy !== undefined ? { foldedBy } : {}),
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
catch {
|
|
232
|
+
return undefined;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
@@ -5,7 +5,7 @@ import { terminalPartsOfObserved, readRunCostFacts, terminalToSdkResult, TOOL_IN
|
|
|
5
5
|
import { terminalRunIdOf, terminalUuidOf } from '../engineRowRef.js';
|
|
6
6
|
import { publishSubagentContentEvent, subagentContentEventOf } from '../subagentContentStore.js';
|
|
7
7
|
import { OUTPUT_INVALID, activeRunBusyCarrierOf, classifyActiveRunBusy, isCorruptSessionCode, isLimitsExceededCode } from '../engineErrorCodes.js';
|
|
8
|
-
import { doneResultView, isReplayedTerminal } from '../replayBody.js';
|
|
8
|
+
import { doneResultView, isReplayedTerminal, terminalLayerOf } from '../replayBody.js';
|
|
9
9
|
import { carriesAnswerText, guardedRead, readFrameStringKey } from '../ownKey.js';
|
|
10
10
|
import { ccErrorOfProviderStatus } from '../providerRejection.js';
|
|
11
11
|
import { corruptSessionContent } from '../corruptSessionCopy.js';
|
|
@@ -20,6 +20,7 @@ import { MODEL_OUTPUT_ERROR_PREFIX, OUTCOME_UNKNOWN_ROW_PREFIX, RUN_BLOCKED_MESS
|
|
|
20
20
|
export { MODEL_OUTPUT_ERROR_PREFIX, OUTCOME_UNKNOWN_ROW_PREFIX, RUN_BLOCKED_MESSAGE_PREFIX, RUN_STOPPED_MESSAGE_PREFIX };
|
|
21
21
|
import { ccToolDenialKindForToolEnd, gateDeniedBy, gateOutcomeOf } from '../gateOutcome.js';
|
|
22
22
|
import { resumeReopenContent, resumeReopenFromError, suspendedReopenOf } from '../hitl/suspendedReopen.js';
|
|
23
|
+
import { openPlanBodyClaimLeg, planReviewParkFacts, stepPlanBodyClaim } from '../planReviewCardFacts.js';
|
|
23
24
|
import { isCcToolDenialKind, isCcToolDenialKindADenial, isGateDeniedByWord } from '../gateVocabulary.js';
|
|
24
25
|
const ENGINE_TURN_USAGE_KEYS = Object.freeze(['inputTokens', 'totalInputTokens', 'outputTokens', 'cacheReadTokens', 'cacheWriteTokens', 'costMicroUsd']);
|
|
25
26
|
const _engineTurnUsageKeysPin = true;
|
|
@@ -205,8 +206,7 @@ function terminalOwnerOfStream(ctx, busy, busyHandle, runId) {
|
|
|
205
206
|
};
|
|
206
207
|
}
|
|
207
208
|
function engineResultOf(result) {
|
|
208
|
-
|
|
209
|
-
return v.replay ? (v.engine ?? result) : result;
|
|
209
|
+
return doneResultView(result).body;
|
|
210
210
|
}
|
|
211
211
|
function engineSessionIdOf(result) {
|
|
212
212
|
const v = result?.sessionId;
|
|
@@ -370,7 +370,7 @@ function apiErrorTerminalFromFacts(x, facts) {
|
|
|
370
370
|
return none();
|
|
371
371
|
if (type === 'failed')
|
|
372
372
|
return { carrier: mintToolHistoryCarrier(nonEmptyStr(ownDataBit(x, 'errorCode')), undefined, nonEmptyStr(ownDataBit(x, 'errorMessage'))), detail: undefined };
|
|
373
|
-
const result = type === 'done' ? plainObjectOf(
|
|
373
|
+
const result = type === 'done' ? plainObjectOf(terminalLayerOf(ownDataBit(x, 'result'))) : x;
|
|
374
374
|
if (result === undefined)
|
|
375
375
|
return none();
|
|
376
376
|
const snap = ownTerminalSnapshot(result);
|
|
@@ -578,6 +578,7 @@ async function* runStreamInner(events, ctx, handle = {}) {
|
|
|
578
578
|
return false;
|
|
579
579
|
}
|
|
580
580
|
};
|
|
581
|
+
const planLeg = openPlanBodyClaimLeg();
|
|
581
582
|
for await (const rawEv of events) {
|
|
582
583
|
const ev = withStringFailureFields(rawEv);
|
|
583
584
|
const wireSubFlow = wireFrameIsSubFlow(ev);
|
|
@@ -591,6 +592,7 @@ async function* runStreamInner(events, ctx, handle = {}) {
|
|
|
591
592
|
}
|
|
592
593
|
seen.add(seq);
|
|
593
594
|
}
|
|
595
|
+
stepPlanBodyClaim(planLeg, ev, wireSubFlow);
|
|
594
596
|
if (ev.type === 'tool_start') {
|
|
595
597
|
const callId = ev.toolCallId;
|
|
596
598
|
if (typeof callId === 'string' && callId.length > 0 && !toolInputAmbiguous.has(callId)) {
|
|
@@ -853,9 +855,10 @@ async function* runStreamInner(events, ctx, handle = {}) {
|
|
|
853
855
|
accepted: ev.type === 'done' && (doneTerminal?.kind === 'completed' || doneTerminal?.kind === 'paused'),
|
|
854
856
|
}).acceptedSinceMismatch;
|
|
855
857
|
}
|
|
858
|
+
const planReview = ev.type === 'done' ? planReviewParkFacts(planLeg, engineResultOf(ev.result)) : undefined;
|
|
856
859
|
if (ev.type === 'done' && isReviewPark(doneTerminal) && ctx.emitChrome) {
|
|
857
860
|
try {
|
|
858
|
-
await ctx.emitChrome({ kind: 'plan_review_park', laneProof: mainLane(), result: ev.result });
|
|
861
|
+
await ctx.emitChrome({ kind: 'plan_review_park', laneProof: mainLane(), result: ev.result, ...(planReview !== undefined ? { planReview } : {}) });
|
|
859
862
|
}
|
|
860
863
|
catch { }
|
|
861
864
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CORE_APPROVAL_REACH } from './generated/engineFactTables.js';
|
|
2
2
|
export type ApprovalReachWord = (typeof CORE_APPROVAL_REACH)[number];
|
|
3
|
+
export declare function isApprovalReachWord(v: {} | null | undefined): v is ApprovalReachWord;
|
|
3
4
|
export declare function refuseBadApprovalReach(v: unknown, who: string): void;
|
|
4
5
|
export type ApprovalReachWithheldCause = 'not_reported' | 'unsupported' | 'unprobed' | 'unreadable';
|
|
5
6
|
export type ApprovalReachDeclaration = {
|