@sema-agent/client-core 0.108.0 → 0.110.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 +294 -0
- package/README.md +77 -40
- package/dist/adapt/arms.js +41 -13
- package/dist/adapt/textStream.d.ts +2 -0
- package/dist/adapt/textStream.js +37 -16
- package/dist/adapter/activeRunSelfHeal.js +1 -1
- package/dist/adapter/downstream/eventToSdkMessage.js +11 -5
- package/dist/agentSession/engineAgentRegistryRead.js +2 -0
- package/dist/bashExitReading.d.ts +12 -0
- package/dist/bashExitReading.js +44 -0
- package/dist/checkpointRowVerdict.d.ts +1 -1
- package/dist/checkpointRowVerdict.js +4 -2
- package/dist/compensations.js +1 -1
- package/dist/declared/supportFloorDeclared.js +1 -1
- package/dist/displayUntrusted.js +132 -14
- package/dist/engineAgentAbsence.d.ts +2 -0
- package/dist/engineAgentAbsence.js +28 -0
- package/dist/engineErrorCodes.d.ts +7 -0
- package/dist/engineErrorCodes.js +7 -0
- package/dist/engineHealthFacts.d.ts +26 -0
- package/dist/engineHealthFacts.js +63 -4
- package/dist/engineInlineTaskStats.d.ts +4 -3
- package/dist/engineInlineTaskStats.js +18 -2
- package/dist/engineNoticeCodes.d.ts +138 -0
- package/dist/engineNoticeCodes.js +662 -55
- package/dist/engineRepoint.d.ts +140 -0
- package/dist/engineRepoint.js +285 -0
- package/dist/engineRowRef.js +2 -0
- package/dist/engineSessionMessages.d.ts +2 -1
- package/dist/engineSessionMessages.js +5 -0
- package/dist/errorSupplementRoles.js +5 -1
- package/dist/fleet/fleetProjection.js +3 -2
- package/dist/fleetTaskDesc.js +3 -3
- package/dist/generated/engineFactTables.d.ts +3 -0
- package/dist/generated/engineFactTables.js +18 -0
- package/dist/generated/engineNoticeTables.js +3 -0
- package/dist/generated/sdkFactTables.d.ts +1 -0
- package/dist/generated/sdkFactTables.js +4 -0
- package/dist/hitl/approvalAskers.d.ts +6 -0
- package/dist/hitl/approvalAskers.js +30 -0
- package/dist/hitl/approvalCardReasons.js +25 -4
- package/dist/hitl/approvalRequestFrameReading.d.ts +21 -0
- package/dist/hitl/approvalRequestFrameReading.js +90 -0
- package/dist/hitl/approvalResolution.d.ts +8 -1
- package/dist/hitl/approvalResolution.js +4 -0
- package/dist/hitl/approvalsFeed.js +1 -1
- package/dist/hitl/askGateWire.js +0 -2
- package/dist/hitl/askParkRowRouting.js +5 -2
- package/dist/hitl/automaticAnswerVerdict.d.ts +5 -2
- package/dist/hitl/automaticAnswerVerdict.js +18 -4
- package/dist/hitl/decisionConflict.d.ts +2 -1
- package/dist/hitl/decisionConflict.js +10 -4
- package/dist/hitl/decisionRefusal.js +1 -0
- package/dist/hitl/decisionSend.d.ts +3 -0
- package/dist/hitl/decisionSend.js +29 -11
- package/dist/hitl/editedApprovalAcceptance.d.ts +25 -0
- package/dist/hitl/editedApprovalAcceptance.js +26 -0
- package/dist/hitl/frameRouter.js +13 -19
- package/dist/hitl/gateLedger.d.ts +0 -4
- package/dist/hitl/gateLedger.js +0 -19
- package/dist/hitl/hitlBridge.d.ts +5 -0
- package/dist/hitl/hitlBridge.js +13 -9
- package/dist/hitl/hitlHostSurface.d.ts +1 -0
- package/dist/hitl/hitlHostSurface.js +7 -2
- package/dist/hitl/hostWithdrawal.d.ts +15 -0
- package/dist/hitl/hostWithdrawal.js +38 -0
- package/dist/hitl/livePendingAsk.js +17 -16
- package/dist/hitl/localAllowRule.js +2 -1
- package/dist/hitl/noAllowCause.d.ts +1 -1
- package/dist/hitl/noAllowCause.js +4 -2
- package/dist/hitl/parkExpiryJudgements.js +26 -1
- package/dist/hitl/parkOwnership.d.ts +2 -0
- package/dist/hitl/parkOwnership.js +48 -8
- package/dist/hitl/parkResolver.js +32 -16
- package/dist/hitl/parkedUnresumable.d.ts +13 -0
- package/dist/hitl/parkedUnresumable.js +80 -0
- package/dist/hitl/permissionRuleScope.d.ts +4 -0
- package/dist/hitl/permissionRuleScope.js +31 -0
- package/dist/hitl/persistedRulesWire.d.ts +2 -0
- package/dist/hitl/persistedRulesWire.js +13 -12
- package/dist/hitl/planReviewWire.js +14 -4
- package/dist/hitl/sessionAllowRoute.js +5 -4
- package/dist/hitl/sessionPolicyWire.js +6 -4
- package/dist/hitl/standingRows.d.ts +2 -5
- package/dist/hitl/standingRows.js +30 -15
- package/dist/hitl/toolApprovalWire.d.ts +42 -9
- package/dist/hitl/toolApprovalWire.js +267 -44
- package/dist/hooksWireCaps.js +35 -4
- package/dist/hostSettingsSource.js +2 -0
- package/dist/hostTurnSettings.d.ts +10 -4
- package/dist/hostTurnSettings.js +112 -5
- package/dist/i18n/messages.en.d.ts +251 -0
- package/dist/i18n/messages.en.js +254 -2
- package/dist/i18n/messages.zh.js +264 -2
- package/dist/index.d.ts +48 -12
- package/dist/index.js +29 -7
- package/dist/inheritEnvCapability.js +2 -0
- package/dist/inputAuthor.d.ts +16 -0
- package/dist/inputAuthor.js +44 -0
- package/dist/interruptRefusalNote.d.ts +2 -0
- package/dist/interruptRefusalNote.js +17 -0
- package/dist/liveModelCatalog.d.ts +2 -0
- package/dist/liveModelCatalog.js +21 -7
- package/dist/liveQuestionStore.d.ts +4 -1
- package/dist/liveQuestionStore.js +12 -3
- package/dist/localEngineJudge.d.ts +75 -0
- package/dist/localEngineJudge.js +242 -0
- package/dist/localEngineOccupancy.d.ts +88 -0
- package/dist/localEngineOccupancy.js +269 -0
- package/dist/localEngineSeatReading.d.ts +29 -0
- package/dist/localEngineSeatReading.js +294 -0
- package/dist/localEngineSpawn.d.ts +113 -0
- package/dist/localEngineSpawn.js +486 -0
- package/dist/localEngineStep.d.ts +286 -0
- package/dist/localEngineStep.js +1086 -0
- package/dist/localEngineStopLadder.d.ts +29 -0
- package/dist/localEngineStopLadder.js +139 -0
- package/dist/localEngineSwapCard.d.ts +43 -0
- package/dist/localEngineSwapCard.js +205 -0
- package/dist/localEngineTiming.d.ts +8 -0
- package/dist/localEngineTiming.js +8 -0
- package/dist/mcpEngineLeg.d.ts +3 -0
- package/dist/mcpEngineLeg.js +38 -1
- package/dist/mcpPanel.js +2 -0
- package/dist/mcpReconnect.d.ts +9 -1
- package/dist/mcpReconnect.js +132 -20
- package/dist/mcpWireCaps.js +2 -2
- package/dist/memoryEntriesWire.d.ts +1 -1
- package/dist/memoryEntriesWire.js +5 -0
- package/dist/modelCapabilityProbe.js +4 -3
- package/dist/modsFace.d.ts +8 -1
- package/dist/modsFace.js +27 -0
- package/dist/noticePresentation.d.ts +2 -0
- package/dist/noticePresentation.js +79 -1
- package/dist/notifications.d.ts +17 -6
- package/dist/notifications.js +67 -19
- package/dist/ownKey.d.ts +5 -0
- package/dist/ownKey.js +8 -1
- package/dist/peerFrames.d.ts +40 -2
- package/dist/peerFrames.js +158 -3
- package/dist/pluginHooksWire.d.ts +2 -1
- package/dist/pluginHooksWire.js +56 -1
- package/dist/replayBody.js +10 -2
- package/dist/request/taskRequest.d.ts +5 -0
- package/dist/request/taskRequest.js +138 -21
- package/dist/resumeRefusalCopy.d.ts +1 -3
- package/dist/resumeRefusalCopy.js +2 -1
- package/dist/retryStatus.d.ts +2 -2
- package/dist/retryStatus.js +2 -0
- package/dist/ruleReadings.js +1 -1
- package/dist/seam.d.ts +24 -2
- package/dist/seam.js +15 -2
- package/dist/seatContract.d.ts +125 -10
- package/dist/seatContract.js +373 -7
- package/dist/sessionBackground.js +4 -1
- package/dist/sessionBackgroundHandoff.js +2 -1
- package/dist/sessionEngine.d.ts +2 -0
- package/dist/sessionEngine.js +111 -0
- package/dist/sessionMemoryStatus.d.ts +2 -1
- package/dist/sessionSyncFileHistory.d.ts +4 -0
- package/dist/sessionSyncFileHistory.js +28 -0
- package/dist/sseIdleTriage.d.ts +13 -1
- package/dist/sseIdleTriage.js +24 -6
- package/dist/subagent/engineSubagentTail.js +6 -0
- package/dist/subagentContentStore.d.ts +12 -0
- package/dist/subagentContentStore.js +72 -11
- package/dist/terminalStatuses.d.ts +1 -0
- package/dist/terminalStatuses.js +4 -1
- package/dist/toolResult.js +18 -5
- package/dist/turnFailurePresentation.js +9 -2
- package/dist/typePins.d.ts +11 -0
- package/dist/usageAnalytics.d.ts +17 -0
- package/dist/usageAnalytics.js +44 -2
- package/dist/wireFailureShape.d.ts +22 -5
- package/dist/wireFailureShape.js +47 -26
- package/dist/wireRefusalCopy.d.ts +31 -1
- package/dist/wireRefusalCopy.js +167 -2
- package/docs/INTEGRATION-CLIENTS.md +3269 -21
- package/package.json +5 -5
package/dist/adapt/arms.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
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
|
-
import { classifyPeerNotification, renderPeerFrameTranscriptText } from '../peerFrames.js';
|
|
4
|
+
import { classifyPeerNotification, renderPeerFrameTranscriptText, sessionBoxNoticeOf } from '../peerFrames.js';
|
|
5
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';
|
|
9
9
|
import { recordEngineToolLabel } from '../engineToolLabelStore.js';
|
|
10
|
-
import {
|
|
10
|
+
import { publishEngineInlineTaskModel } from '../engineInlineTaskStats.js';
|
|
11
|
+
import { applySubagentAlias } from '../subagentContentStore.js';
|
|
11
12
|
import { readAsyncLaunchedAgentReceipt } from '../toolResult.js';
|
|
12
13
|
import { recordWorkflowAgentTaskId } from '../workflow.js';
|
|
13
14
|
import { isCoreTaskNotificationTerminal, isCoreTaskNotificationTerminalNotSuccess, isCoreTaskProgressTerminal, isCoreTaskProgressTerminalNotSuccess } from '../terminalStatuses.js';
|
|
@@ -16,6 +17,7 @@ import { isMintedRowCcError, readProviderRejectionResendKey } from '../providerR
|
|
|
16
17
|
import { rowKindOf } from '../rowKind.js';
|
|
17
18
|
import { terminalCodedDetailOf } from '../runTerminal.js';
|
|
18
19
|
import { contextUsageReadingOf, guardedRead, humanInputAttachmentsOf, ownSnapshotRecord, ownSnapshotWhenTyped, readOwnDataNonEmptyString, readOwnDataValue, promptManifestIdentityOfFrame, promptManifestSectionViewOf, readFrameStringKey, readFrameTrueMark, workflowCompletionExtrasOf } from '../ownKey.js';
|
|
20
|
+
import { humanInputAuthorKeys, runOriginKeys } from '../inputAuthor.js';
|
|
19
21
|
import { CORE_USER_ATTACHMENT_LABEL_MAX } from '../generated/engineFactTables.js';
|
|
20
22
|
import { ESCAPE_FACE, paintAndCap, washCredentials } from '../displayUntrusted.js';
|
|
21
23
|
import { resolveEnginePanelTaskId } from '../engineAgentPanelStore.js';
|
|
@@ -236,7 +238,9 @@ const userArm = function* (m, { ctx, idOf }) {
|
|
|
236
238
|
return;
|
|
237
239
|
yield transcript({ ...m, uuid: idOf(m), session_id: ctx.sessionId }, ctx.now());
|
|
238
240
|
};
|
|
239
|
-
const systemArm = function* (m, { ctx, idOf }) {
|
|
241
|
+
const systemArm = function* (m, { ctx, idOf, text }) {
|
|
242
|
+
if (readFrameStringKey(m, 'subtype') === 'compact_boundary')
|
|
243
|
+
text.noteModelSegmentBoundary();
|
|
240
244
|
yield transcript(m, ctx.now());
|
|
241
245
|
const attachedFiles = m._sema_attached_files;
|
|
242
246
|
if (Array.isArray(attachedFiles)) {
|
|
@@ -325,13 +329,21 @@ const humanInputArm = function* (m) {
|
|
|
325
329
|
...(str(m.entryId) !== undefined ? { entryId: str(m.entryId) } : {}),
|
|
326
330
|
...(str(m.eventId) !== undefined ? { eventId: str(m.eventId) } : {}),
|
|
327
331
|
...humanInputAttachmentsForChrome(m),
|
|
332
|
+
...humanInputAuthorKeys(m),
|
|
333
|
+
...runOriginKeys(m),
|
|
328
334
|
});
|
|
329
335
|
};
|
|
330
336
|
function humanInputAttachmentsForChrome(m) {
|
|
331
337
|
const rows = humanInputAttachmentsOf(m);
|
|
332
338
|
if (rows === undefined)
|
|
333
339
|
return {};
|
|
334
|
-
return {
|
|
340
|
+
return {
|
|
341
|
+
attachments: rows.map((r) => ({
|
|
342
|
+
...r,
|
|
343
|
+
...(r.label !== undefined ? { label: paintAndCap(r.label, ESCAPE_FACE, CORE_USER_ATTACHMENT_LABEL_MAX) } : {}),
|
|
344
|
+
...(r.declinedBy !== undefined ? { declinedBy: { kind: r.declinedBy.kind, name: paintAndCap(r.declinedBy.name, ESCAPE_FACE, CORE_USER_ATTACHMENT_LABEL_MAX) } } : {}),
|
|
345
|
+
})),
|
|
346
|
+
};
|
|
335
347
|
}
|
|
336
348
|
const messageCommittedArm = function* (m) {
|
|
337
349
|
if (typeof m.parentToolCallId === 'string')
|
|
@@ -515,7 +527,7 @@ const compactionStartedArm = function* (m) {
|
|
|
515
527
|
...(eventId !== undefined ? { eventId } : {}),
|
|
516
528
|
});
|
|
517
529
|
};
|
|
518
|
-
const taskStartedArm = function* (m) {
|
|
530
|
+
const taskStartedArm = function* (m, { cards }) {
|
|
519
531
|
const str = (v) => (typeof v === 'string' && v.length > 0 ? v : undefined);
|
|
520
532
|
const num = (v) => (typeof v === 'number' && Number.isFinite(v) ? v : undefined);
|
|
521
533
|
const taskId = str(m.taskId);
|
|
@@ -542,6 +554,8 @@ const taskStartedArm = function* (m) {
|
|
|
542
554
|
const eventId = str(idSnap.eventId);
|
|
543
555
|
if (agentType !== undefined && workflowRunId === undefined)
|
|
544
556
|
recordFleetRowAgentType(taskId, agentType);
|
|
557
|
+
if (model !== undefined && parent !== undefined && workflowRunId === undefined && !cards.has(parent))
|
|
558
|
+
publishEngineInlineTaskModel(parent, model);
|
|
545
559
|
yield chrome({
|
|
546
560
|
kind: 'subagent_started',
|
|
547
561
|
laneProof,
|
|
@@ -623,6 +637,7 @@ const textSegmentEndArm = function* (m, { text }) {
|
|
|
623
637
|
if (content.length === 0)
|
|
624
638
|
return;
|
|
625
639
|
text.anchorWindow(m);
|
|
640
|
+
yield* text.admitEndOnlyBlock(content, m);
|
|
626
641
|
const r = text.replaceAnswerSegment(content, m);
|
|
627
642
|
yield* text.drainLive();
|
|
628
643
|
yield chrome({
|
|
@@ -677,8 +692,9 @@ const toolEndResultArm = function* (m, deps) {
|
|
|
677
692
|
const structured = ownSnapshotWhenTyped(m.structured, 'task-output');
|
|
678
693
|
if (callId !== undefined) {
|
|
679
694
|
const launched = readAsyncLaunchedAgentReceipt(structured);
|
|
680
|
-
if (launched !== null)
|
|
681
|
-
|
|
695
|
+
if (launched !== null && applySubagentAlias(callId, launched.taskId, 'content') !== 'rejected') {
|
|
696
|
+
yield chrome({ kind: 'subagent_alias', laneProof: { lane: 'subagent', parentToolCallId: callId }, parentToolCallId: callId, taskId: launched.taskId, scope: 'content' });
|
|
697
|
+
}
|
|
682
698
|
}
|
|
683
699
|
if (callId !== undefined && isUnsettledHeldToolEnd(m)) {
|
|
684
700
|
const held = cards.detach(callId);
|
|
@@ -769,8 +785,12 @@ const taskProgressArm = function* (m, { ctx, cards, panel, inst }) {
|
|
|
769
785
|
}));
|
|
770
786
|
return;
|
|
771
787
|
}
|
|
772
|
-
if (explicitParent !== undefined)
|
|
773
|
-
|
|
788
|
+
if (explicitParent !== undefined) {
|
|
789
|
+
const aliasSeq = cycleSeqValue(m.seq);
|
|
790
|
+
if (applySubagentAlias(explicitParent, taskId, 'full', aliasSeq) !== 'rejected') {
|
|
791
|
+
yield chrome({ kind: 'subagent_alias', laneProof: { lane: 'subagent', parentToolCallId: explicitParent }, parentToolCallId: explicitParent, taskId, scope: 'full', ...(aliasSeq !== undefined ? { seq: aliasSeq } : {}) });
|
|
792
|
+
}
|
|
793
|
+
}
|
|
774
794
|
const cardId = panel.bind(taskId, explicitParent);
|
|
775
795
|
const usage = (m.usage ?? {});
|
|
776
796
|
ctx.probe?.('tick', JSON.stringify({
|
|
@@ -948,7 +968,7 @@ const resultArm = function* (m, { ctx, idOf, text, cards, panel, flags }) {
|
|
|
948
968
|
if (isReplayMarked(m))
|
|
949
969
|
yield chrome({ kind: 'result_replayed', laneProof: mainLane(), text: RESULT_REPLAYED_TEXT });
|
|
950
970
|
};
|
|
951
|
-
const taskNotificationArm = function* (m, { ctx, idOf, panel, inst }) {
|
|
971
|
+
const taskNotificationArm = function* (m, { ctx, idOf, panel, inst, pass }) {
|
|
952
972
|
const n = ownSnapshotRecord(guardedRead(() => readOwnDataValue(m, 'notification'))) ?? {};
|
|
953
973
|
const fields = normalizeTaskNotification(n);
|
|
954
974
|
if (fields === null)
|
|
@@ -968,13 +988,18 @@ const taskNotificationArm = function* (m, { ctx, idOf, panel, inst }) {
|
|
|
968
988
|
: {}),
|
|
969
989
|
});
|
|
970
990
|
}
|
|
971
|
-
const
|
|
991
|
+
const peerFrame = classifyPeerNotification(n);
|
|
992
|
+
const baseKeys = taskNotificationRenderKeys({
|
|
972
993
|
taskId,
|
|
973
994
|
status: rawStatus,
|
|
974
995
|
...(typeof n.seq === 'number' || typeof n.seq === 'string' ? { seq: n.seq } : {}),
|
|
975
996
|
...(typeof n.task_type === 'string' ? { taskType: n.task_type } : {}),
|
|
976
997
|
...(fields.completionId !== undefined ? { completionId: fields.completionId } : {}),
|
|
977
998
|
});
|
|
999
|
+
const inboxRunId = peerFrame !== null && peerFrame.lane === 'inbox_notice' ? readFrameStringKey(n, 'eventId') : undefined;
|
|
1000
|
+
const dedupKeys = peerFrame !== null && peerFrame.lane === 'inbox_notice'
|
|
1001
|
+
? [`${baseKeys[0]}@${inboxRunId !== undefined ? `e:${inboxRunId}` : `p:${pass}`}`, ...baseKeys.slice(1)]
|
|
1002
|
+
: baseKeys;
|
|
978
1003
|
const sameFrameSeen = inst.hasRenderedNotification(dedupKeys[0]);
|
|
979
1004
|
const sameCompletionSeen = !sameFrameSeen && dedupKeys.slice(1).some((k) => inst.hasRenderedNotification(k));
|
|
980
1005
|
for (const k of dedupKeys)
|
|
@@ -995,7 +1020,6 @@ const taskNotificationArm = function* (m, { ctx, idOf, panel, inst }) {
|
|
|
995
1020
|
yield* panel.settleFromNotification(taskId, isCoreTaskNotificationTerminalNotSuccess(rawStatus), bgSessionId);
|
|
996
1021
|
}
|
|
997
1022
|
}
|
|
998
|
-
const peerFrame = classifyPeerNotification(n);
|
|
999
1023
|
if (peerFrame === null && n.task_type !== 'external' && isWorkflowCompletionCardEnqueued(taskId))
|
|
1000
1024
|
return;
|
|
1001
1025
|
if (peerFrame === null && n.task_type !== 'external')
|
|
@@ -1003,6 +1027,10 @@ const taskNotificationArm = function* (m, { ctx, idOf, panel, inst }) {
|
|
|
1003
1027
|
const fact = peerFrame === null ? freezeTaskNotificationFields(fields) : undefined;
|
|
1004
1028
|
if (sameCompletionSeen)
|
|
1005
1029
|
return;
|
|
1030
|
+
const rowUuid = idOf(m);
|
|
1031
|
+
const boxNotice = peerFrame === null ? undefined : sessionBoxNoticeOf(peerFrame);
|
|
1032
|
+
if (boxNotice !== undefined)
|
|
1033
|
+
yield chrome({ kind: 'session_box_notice', laneProof: mainLane(), ...boxNotice, rowUuid });
|
|
1006
1034
|
yield transcript({
|
|
1007
1035
|
type: 'user',
|
|
1008
1036
|
message: {
|
|
@@ -1014,7 +1042,7 @@ const taskNotificationArm = function* (m, { ctx, idOf, panel, inst }) {
|
|
|
1014
1042
|
},
|
|
1015
1043
|
],
|
|
1016
1044
|
},
|
|
1017
|
-
uuid:
|
|
1045
|
+
uuid: rowUuid,
|
|
1018
1046
|
session_id: ctx.sessionId,
|
|
1019
1047
|
...(fact !== undefined ? { _sema_task_notification: fact } : {}),
|
|
1020
1048
|
}, ctx.now());
|
|
@@ -18,6 +18,8 @@ interface ThinkingSegmentReplacement {
|
|
|
18
18
|
}
|
|
19
19
|
export interface TextStream {
|
|
20
20
|
feedText(delta: string, frame: Frame): Generator<AdapterOutput>;
|
|
21
|
+
admitEndOnlyBlock(content: string, frame: Frame): Generator<AdapterOutput>;
|
|
22
|
+
noteModelSegmentBoundary(): void;
|
|
21
23
|
feedThinking(delta: string, frame: Frame): Generator<AdapterOutput>;
|
|
22
24
|
drainLive(): Generator<AdapterOutput>;
|
|
23
25
|
takeThinking(): Generator<AdapterOutput>;
|
package/dist/adapt/textStream.js
CHANGED
|
@@ -39,6 +39,10 @@ export function createTextStream(ctx, idOf) {
|
|
|
39
39
|
let segmentCommitted = '';
|
|
40
40
|
let previousSegmentCommitted = '';
|
|
41
41
|
let segmentWindowCloseArmed = false;
|
|
42
|
+
let wholeBlockDelivered = false;
|
|
43
|
+
const closeWholeBlockMark = () => {
|
|
44
|
+
wholeBlockDelivered = false;
|
|
45
|
+
};
|
|
42
46
|
const flushEveryMs = typeof ctx.coalesceIntervalMs === 'number' && ctx.coalesceIntervalMs >= 0
|
|
43
47
|
? ctx.coalesceIntervalMs
|
|
44
48
|
: FLUSH_INTERVAL_MS;
|
|
@@ -122,6 +126,7 @@ export function createTextStream(ctx, idOf) {
|
|
|
122
126
|
}
|
|
123
127
|
function* takeAnswerSegment() {
|
|
124
128
|
idleFlushUsedInSegment = false;
|
|
129
|
+
closeWholeBlockMark();
|
|
125
130
|
yield* emitAnswerSegment();
|
|
126
131
|
previousSegmentCommitted += segmentCommitted;
|
|
127
132
|
segmentCommitted = '';
|
|
@@ -166,23 +171,37 @@ export function createTextStream(ctx, idOf) {
|
|
|
166
171
|
textPending = '';
|
|
167
172
|
}
|
|
168
173
|
}
|
|
174
|
+
function* feedText(delta, frame) {
|
|
175
|
+
if (delta.length === 0 && segmentWindowCloseArmed && previousSegmentCommitted + segmentCommitted !== '')
|
|
176
|
+
return;
|
|
177
|
+
consumeArmedClose();
|
|
178
|
+
if (thinking.length > 0 || thinkingPending.length > 0) {
|
|
179
|
+
yield* drainLive();
|
|
180
|
+
yield* takeThinking();
|
|
181
|
+
}
|
|
182
|
+
if (answerSegment.length === 0)
|
|
183
|
+
segmentAnchor = frame;
|
|
184
|
+
segmentLast = frame;
|
|
185
|
+
openSegmentWindow(frame);
|
|
186
|
+
answer += delta;
|
|
187
|
+
answerSegment += delta;
|
|
188
|
+
textPending += delta;
|
|
189
|
+
}
|
|
190
|
+
function* admitEndOnlyBlock(content, frame) {
|
|
191
|
+
if (content.length === 0 || wholeBlockDelivered)
|
|
192
|
+
return;
|
|
193
|
+
const verdict = resolveTextSegmentAuthority(content, {
|
|
194
|
+
committedPrefix: previousSegmentCommitted + segmentCommitted,
|
|
195
|
+
openSegment: answerSegment,
|
|
196
|
+
});
|
|
197
|
+
if (verdict.form !== 'untouched')
|
|
198
|
+
return;
|
|
199
|
+
yield* feedText(content, frame);
|
|
200
|
+
}
|
|
169
201
|
return {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
consumeArmedClose();
|
|
174
|
-
if (thinking.length > 0 || thinkingPending.length > 0) {
|
|
175
|
-
yield* drainLive();
|
|
176
|
-
yield* takeThinking();
|
|
177
|
-
}
|
|
178
|
-
if (answerSegment.length === 0)
|
|
179
|
-
segmentAnchor = frame;
|
|
180
|
-
segmentLast = frame;
|
|
181
|
-
openSegmentWindow(frame);
|
|
182
|
-
answer += delta;
|
|
183
|
-
answerSegment += delta;
|
|
184
|
-
textPending += delta;
|
|
185
|
-
},
|
|
202
|
+
feedText,
|
|
203
|
+
admitEndOnlyBlock,
|
|
204
|
+
noteModelSegmentBoundary: closeWholeBlockMark,
|
|
186
205
|
*feedThinking(delta, frame) {
|
|
187
206
|
if (thinkingSettled) {
|
|
188
207
|
if (thinking.length > 0) {
|
|
@@ -335,6 +354,8 @@ export function createTextStream(ctx, idOf) {
|
|
|
335
354
|
emittedAssistantText = true;
|
|
336
355
|
if (typeof committed === 'string')
|
|
337
356
|
committedText += committed;
|
|
357
|
+
if (typeof committed === 'string' && committed.length > 0)
|
|
358
|
+
wholeBlockDelivered = true;
|
|
338
359
|
},
|
|
339
360
|
replaceThinkingSegment: (content, anchor) => {
|
|
340
361
|
const rows = committedThinking;
|
|
@@ -1231,7 +1231,7 @@ function activeRunSelfHealBaseRow(outcome, wayOut, following = false, keepSessio
|
|
|
1231
1231
|
if (outcome.rowVerdict !== undefined) {
|
|
1232
1232
|
return say(lang, 'session.selfHeal.row.askReopenFailed.rowUnresumable', {
|
|
1233
1233
|
taskId: outcome.taskId,
|
|
1234
|
-
sentence: checkpointRowBarSentence(outcome.rowVerdict),
|
|
1234
|
+
sentence: checkpointRowBarSentence(outcome.rowVerdict, lang),
|
|
1235
1235
|
unbound: rowBarWayOutContent(outcome.rowVerdict, outcome.rowDeadline ?? 'unknown', lang),
|
|
1236
1236
|
});
|
|
1237
1237
|
}
|
|
@@ -6,6 +6,7 @@ import { projectToolRoster, projectToolRosterDelta } from '../../toolRoster.js';
|
|
|
6
6
|
import { projectHandsSection } from '../../handsSeam.js';
|
|
7
7
|
import { readMcpAuthorization, readMcpLiveness } from '../../mcpLiveness.js';
|
|
8
8
|
import { contextUsageReadingOf, humanInputAttachmentsOf, guardedRead, markMcpSectionDroppedNamedRows, ownSnapshotTyped, promptManifestIdentityOfFrame, promptManifestSectionViewOf, readFrameStringKey, readFrameTrueMark, readOwnDataFiniteNumber, readOwnDataNonEmptyString, workflowCompletionExtrasOf } from '../../ownKey.js';
|
|
9
|
+
import { humanInputAuthorKeys, runOriginKeys } from '../../inputAuthor.js';
|
|
9
10
|
import { SEGMENT_END_IDENTITY_KEYS, eventSeq, stripToolUseSideChannels } from '../types.js';
|
|
10
11
|
import { frozenSet } from '../../frozenSet.js';
|
|
11
12
|
import { isCoreWorkflowRunTerminal } from '../../terminalStatuses.js';
|
|
@@ -72,9 +73,6 @@ function streamEventArm(ctx, event) {
|
|
|
72
73
|
const projected = (message) => ({ kind: 'message', message });
|
|
73
74
|
const nothing = (why) => ({ kind: 'none', why });
|
|
74
75
|
const dropped = (why, type) => ({ kind: 'dropped', why, type });
|
|
75
|
-
function isCompactionStartedFrame(ev) {
|
|
76
|
-
return ev.type === 'compaction_started';
|
|
77
|
-
}
|
|
78
76
|
const BEYOND_FLOOR_ARMS = Object.freeze(['cross_boundary_taint', 'approval_complete', 'session_titled']);
|
|
79
77
|
function isBeyondFloorArm(ev) {
|
|
80
78
|
const word = ev.type;
|
|
@@ -111,8 +109,6 @@ function withEngineIdentity(p, ev, ctx, identityFrame = ev) {
|
|
|
111
109
|
return projected(Object.assign({}, env, { uuid: envelopeUuidOf(eventId, env.type), _sema_engine_ref: ref }));
|
|
112
110
|
}
|
|
113
111
|
function projectEvent(ev, ctx) {
|
|
114
|
-
if (isCompactionStartedFrame(ev))
|
|
115
|
-
return compactionStartedProjection(ev, ctx);
|
|
116
112
|
if (isBeyondFloorArm(ev)) {
|
|
117
113
|
const word = ev.type;
|
|
118
114
|
if (word === 'cross_boundary_taint')
|
|
@@ -127,6 +123,8 @@ function projectEvent(ev, ctx) {
|
|
|
127
123
|
switch (ev.type) {
|
|
128
124
|
case 'task_started':
|
|
129
125
|
return taskStartedProjection(ev, ctx);
|
|
126
|
+
case 'compaction_started':
|
|
127
|
+
return compactionStartedProjection(ev, ctx);
|
|
130
128
|
case 'text_end':
|
|
131
129
|
return textEndProjection(ev, ctx);
|
|
132
130
|
case 'reasoning_end':
|
|
@@ -954,6 +952,8 @@ function humanInputProjection(ev, ctx) {
|
|
|
954
952
|
...(str(ev.eventId) !== undefined ? { eventId: str(ev.eventId) } : {}),
|
|
955
953
|
...(str(ev.parentToolCallId) !== undefined ? { parentToolCallId: str(ev.parentToolCallId) } : {}),
|
|
956
954
|
...attachmentsKey(humanInputAttachmentsOf(ev)),
|
|
955
|
+
...humanInputAuthorKeys(ev),
|
|
956
|
+
...runOriginKeys(ev),
|
|
957
957
|
})));
|
|
958
958
|
}
|
|
959
959
|
function attachmentsKey(rows) {
|
|
@@ -973,3 +973,9 @@ export function turnEndUsage(ev) {
|
|
|
973
973
|
export function gateKind(gate) {
|
|
974
974
|
return gate?.kind ?? 'human';
|
|
975
975
|
}
|
|
976
|
+
const _pinCompaction = [true, true, true, true, true, true, true, true, true, true, true];
|
|
977
|
+
void _pinCompaction;
|
|
978
|
+
const _pinMods = [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true];
|
|
979
|
+
void _pinMods;
|
|
980
|
+
const _pinPrompt = [true, true, true, true, true, true, true, true, true, true];
|
|
981
|
+
void _pinPrompt;
|
|
@@ -77,6 +77,7 @@ function readRow(v) {
|
|
|
77
77
|
const description = Object.hasOwn(o, 'description') ? o.description : undefined;
|
|
78
78
|
const createdAt = Object.hasOwn(o, 'createdAt') ? o.createdAt : undefined;
|
|
79
79
|
const childSessionId = type === 'background_agent' ? guardedRead(() => readOwnDataValue(o, 'sessionId')) : undefined;
|
|
80
|
+
const retained = guardedRead(() => readOwnDataValue(o, 'retained')) === true;
|
|
80
81
|
return {
|
|
81
82
|
id,
|
|
82
83
|
type,
|
|
@@ -84,6 +85,7 @@ function readRow(v) {
|
|
|
84
85
|
...(typeof description === 'string' && description.length > 0 ? { description } : {}),
|
|
85
86
|
...(typeof createdAt === 'number' && Number.isFinite(createdAt) ? { createdAt } : {}),
|
|
86
87
|
...(typeof childSessionId === 'string' && childSessionId.length > 0 ? { sessionId: childSessionId } : {}),
|
|
88
|
+
...(retained ? { retained: true } : {}),
|
|
87
89
|
};
|
|
88
90
|
}
|
|
89
91
|
export async function readEngineAgentRegistry(client, sessionId, capsBaseUrl, opts) {
|
|
@@ -8,3 +8,15 @@ export interface BashExitReading {
|
|
|
8
8
|
}
|
|
9
9
|
export declare function bashExitOf(structured: unknown, parseFrame: () => BashFrameExit | null): BashExitReading;
|
|
10
10
|
export declare function bashExitReadingFailed(r: BashExitReading): boolean;
|
|
11
|
+
export type BashCurtailmentKind = 'timedOut' | 'livenessNoOutput' | 'aborted' | 'callbackError';
|
|
12
|
+
export interface BashCurtailment {
|
|
13
|
+
readonly kind: BashCurtailmentKind;
|
|
14
|
+
readonly timeoutSec?: number;
|
|
15
|
+
readonly noOutputSec?: number;
|
|
16
|
+
}
|
|
17
|
+
export declare function bashCurtailmentOf(structured: unknown): BashCurtailment | undefined;
|
|
18
|
+
export declare function bashCurtailmentSentence(c: BashCurtailment): string;
|
|
19
|
+
export declare function bashCurtailedResultPart(stderr: string, c: BashCurtailment | undefined): {
|
|
20
|
+
stderr: string;
|
|
21
|
+
_sema_curtailed?: BashCurtailment;
|
|
22
|
+
};
|
package/dist/bashExitReading.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { guardedRead, readOwnDataValue } from './ownKey.js';
|
|
1
2
|
export function bashExitOf(structured, parseFrame) {
|
|
2
3
|
const s = typeof structured === 'object' && structured !== null ? structured : undefined;
|
|
3
4
|
const interp = typeof s?.returnCodeInterpretation === 'string' && s.returnCodeInterpretation.length > 0 ? s.returnCodeInterpretation : undefined;
|
|
@@ -10,3 +11,46 @@ export function bashExitOf(structured, parseFrame) {
|
|
|
10
11
|
export function bashExitReadingFailed(r) {
|
|
11
12
|
return r.exitCode !== null && r.exitCode !== 0 && r.benignNote === undefined;
|
|
12
13
|
}
|
|
14
|
+
export function bashCurtailmentOf(structured) {
|
|
15
|
+
if (typeof structured !== 'object' || structured === null)
|
|
16
|
+
return undefined;
|
|
17
|
+
const own = (key) => guardedRead(() => readOwnDataValue(structured, key));
|
|
18
|
+
if (own('type') !== 'bash')
|
|
19
|
+
return undefined;
|
|
20
|
+
const secOf = (key) => {
|
|
21
|
+
const v = own(key);
|
|
22
|
+
return typeof v === 'number' && Number.isSafeInteger(v) && v >= 0 ? (v === 0 ? 0 : v) : undefined;
|
|
23
|
+
};
|
|
24
|
+
if (own('timedOut') === true) {
|
|
25
|
+
const timeoutSec = secOf('timeoutSec');
|
|
26
|
+
return timeoutSec === undefined ? { kind: 'timedOut' } : { kind: 'timedOut', timeoutSec };
|
|
27
|
+
}
|
|
28
|
+
if (own('livenessNoOutput') === true) {
|
|
29
|
+
const noOutputSec = secOf('noOutputSec');
|
|
30
|
+
return noOutputSec === undefined ? { kind: 'livenessNoOutput' } : { kind: 'livenessNoOutput', noOutputSec };
|
|
31
|
+
}
|
|
32
|
+
if (own('aborted') === true)
|
|
33
|
+
return { kind: 'aborted' };
|
|
34
|
+
if (own('callbackError') === true)
|
|
35
|
+
return { kind: 'callbackError' };
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
export function bashCurtailmentSentence(c) {
|
|
39
|
+
switch (c.kind) {
|
|
40
|
+
case 'timedOut':
|
|
41
|
+
return c.timeoutSec === undefined ? 'Command timed out' : `Command timed out after ${c.timeoutSec}s`;
|
|
42
|
+
case 'livenessNoOutput':
|
|
43
|
+
return c.noOutputSec === undefined ? 'Command killed: no output' : `Command killed: no output for ${c.noOutputSec}s`;
|
|
44
|
+
case 'aborted':
|
|
45
|
+
return 'Command was interrupted';
|
|
46
|
+
case 'callbackError':
|
|
47
|
+
return 'Command ended: output stream failed';
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export function bashCurtailedResultPart(stderr, c) {
|
|
51
|
+
if (c === undefined)
|
|
52
|
+
return { stderr };
|
|
53
|
+
const sentence = bashCurtailmentSentence(c);
|
|
54
|
+
const alreadyLeads = stderr.startsWith(sentence) && stderr.charAt(sentence.length).trim() === '';
|
|
55
|
+
return { stderr: stderr.length === 0 ? sentence : alreadyLeads ? stderr : `${sentence} ${stderr}`, _sema_curtailed: { ...c } };
|
|
56
|
+
}
|
|
@@ -27,7 +27,7 @@ export type CheckpointRowBar = Exclude<CheckpointRowVerdictReading, {
|
|
|
27
27
|
}>;
|
|
28
28
|
export declare function checkpointRowBarOf(row: object | null | undefined): CheckpointRowBar | undefined;
|
|
29
29
|
export declare const CHECKPOINT_ROW_BAR_SENTENCE: string;
|
|
30
|
-
export declare function checkpointRowBarSentence(bar: CheckpointRowBar): string;
|
|
30
|
+
export declare function checkpointRowBarSentence(bar: CheckpointRowBar, lang?: UiLanguage | (string & {})): string;
|
|
31
31
|
export type CheckpointDeadlineState = 'armed' | 'none' | 'unknown';
|
|
32
32
|
export declare function checkpointDeadlineStateOf(row: object | null | undefined): CheckpointDeadlineState;
|
|
33
33
|
export declare function unboundWayOutContent(state: CheckpointDeadlineState, lang?: UiLanguage | (string & {})): string;
|
|
@@ -94,8 +94,10 @@ export function checkpointRowBarOf(row) {
|
|
|
94
94
|
return v === undefined || v.kind === 'ok' ? undefined : v;
|
|
95
95
|
}
|
|
96
96
|
export const CHECKPOINT_ROW_BAR_SENTENCE = renderMessage(msg('approval.rowUnresumable.fallback'));
|
|
97
|
-
export function checkpointRowBarSentence(bar) {
|
|
98
|
-
return bar.kind !== 'unreadable' && typeof bar.sentence === 'string' && bar.sentence !== ''
|
|
97
|
+
export function checkpointRowBarSentence(bar, lang) {
|
|
98
|
+
return bar.kind !== 'unreadable' && typeof bar.sentence === 'string' && bar.sentence !== ''
|
|
99
|
+
? bar.sentence
|
|
100
|
+
: renderMessage(msg('approval.rowUnresumable.fallback'), isUiLanguage(lang) ? lang : undefined);
|
|
99
101
|
}
|
|
100
102
|
export function checkpointDeadlineStateOf(row) {
|
|
101
103
|
try {
|
package/dist/compensations.js
CHANGED
|
@@ -118,7 +118,7 @@ export const MIGRATED_COMPENSATIONS = [
|
|
|
118
118
|
id: 'T49',
|
|
119
119
|
what: 'subagent alias 只能在 tick 上学 —— content 帧只带 parentToolCallId、没有 taskId',
|
|
120
120
|
disposition: 'in-library',
|
|
121
|
-
libraryHalf: 'adapt.ts task_progress 臂
|
|
121
|
+
libraryHalf: 'adapt.ts task_progress 臂 applySubagentAlias(explicitParent, taskId, \'full\')(与 registerSubagentAlias 同一实现)',
|
|
122
122
|
chromeArm: null,
|
|
123
123
|
hostHalf: null,
|
|
124
124
|
retireOn: 'RL-40',
|