@sema-agent/client-core 0.98.0 → 0.100.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 +376 -0
- package/README.md +61 -35
- package/dist/adapt/arms.js +120 -55
- package/dist/adapt/panelTasks.d.ts +3 -2
- package/dist/adapt/panelTasks.js +34 -11
- package/dist/adapt/textStream.d.ts +1 -1
- package/dist/adapt/textStream.js +51 -28
- package/dist/adapter/activeRunSelfHeal.d.ts +11 -3
- package/dist/adapter/activeRunSelfHeal.js +210 -294
- package/dist/adapter/downstream/eventToSdkMessage.d.ts +25 -6
- package/dist/adapter/downstream/eventToSdkMessage.js +176 -12
- package/dist/adapter/downstream/terminalToSdkResult.js +10 -0
- package/dist/adapter/downstream/wiringManifestView.d.ts +3 -1
- package/dist/adapter/downstream/wiringManifestView.js +1 -0
- package/dist/adapter/runStream.js +82 -40
- package/dist/adapter/types.d.ts +2 -0
- package/dist/adapter/types.js +2 -1
- package/dist/agentSession/engineSessionBackgroundStop.js +16 -8
- package/dist/agentsWireCaps.d.ts +7 -3
- package/dist/agentsWireCaps.js +133 -39
- package/dist/cloudConfigWireCaps.d.ts +10 -1
- package/dist/cloudConfigWireCaps.js +181 -65
- package/dist/compactionStatus.d.ts +34 -0
- package/dist/compactionStatus.js +196 -0
- package/dist/controlRouter.d.ts +4 -2
- package/dist/controlRouter.js +39 -51
- package/dist/coreValuePorts.d.ts +26 -1
- package/dist/coreValuePorts.js +10 -0
- package/dist/corruptSessionCopy.d.ts +2 -1
- package/dist/corruptSessionCopy.js +3 -3
- package/dist/decideFailureNote.js +3 -3
- package/dist/declared/supportFloorDeclared.js +1 -1
- package/dist/detachWire.js +3 -2
- package/dist/devicesFace.d.ts +34 -0
- package/dist/devicesFace.js +90 -0
- package/dist/displayUntrusted.d.ts +1 -0
- package/dist/displayUntrusted.js +153 -5
- package/dist/engineAgentPanelStore.d.ts +14 -4
- package/dist/engineAgentPanelStore.js +14 -0
- package/dist/engineCapReader.d.ts +2 -1
- package/dist/engineCapReader.js +7 -5
- package/dist/engineCapsCache.d.ts +8 -0
- package/dist/engineCapsCache.js +59 -6
- package/dist/engineCapsChange.d.ts +2 -0
- package/dist/engineCapsChange.js +9 -0
- package/dist/engineErrorCodes.d.ts +11 -2
- package/dist/engineErrorCodes.js +11 -12
- package/dist/engineRowRef.js +4 -0
- package/dist/engineSessionMessages.d.ts +1 -0
- package/dist/engineSessionMessages.js +7 -1
- package/dist/engineTargetSeat.d.ts +27 -0
- package/dist/engineTargetSeat.js +199 -0
- package/dist/engineToolDirectory.d.ts +3 -0
- package/dist/engineToolDirectory.js +4 -2
- package/dist/engineWireFor.js +3 -8
- package/dist/env/uiLanguage.d.ts +2 -1
- package/dist/env/uiLanguage.js +3 -2
- package/dist/eventLeg.d.ts +7 -5
- package/dist/eventLeg.js +68 -49
- package/dist/fileHistoryCaptureCapability.d.ts +2 -4
- package/dist/fileHistoryCaptureCapability.js +12 -22
- package/dist/fileHistoryLegNotice.d.ts +2 -1
- package/dist/fileHistoryLegNotice.js +3 -3
- package/dist/frameBinding.d.ts +3 -0
- package/dist/frameBinding.js +12 -0
- package/dist/gateOutcome.js +16 -2
- package/dist/gateVocabulary.d.ts +8 -7
- package/dist/gateVocabulary.js +71 -73
- package/dist/generated/engineFactTables.d.ts +18 -1
- package/dist/generated/engineFactTables.js +56 -0
- package/dist/generated/engineNoticeTables.js +12 -3
- package/dist/generated/settingsSchemaFns.d.ts +18 -0
- package/dist/generated/settingsSchemaFns.js +70 -0
- package/dist/generated/settingsSchemaHooksClassifier.d.ts +2 -0
- package/dist/generated/settingsSchemaHooksClassifier.js +254 -0
- package/dist/generated/settingsSchemaMcpRequestEntry.d.ts +1 -0
- package/dist/generated/settingsSchemaMcpRequestEntry.js +162 -0
- package/dist/generated/settingsSchemaTables.d.ts +2 -0
- package/dist/generated/settingsSchemaTables.js +9 -0
- package/dist/generated/settingsSchemaTypes.d.ts +133 -0
- package/dist/generated/settingsSchemaTypes.js +1 -0
- package/dist/hitl/allowRuleShadow.d.ts +2 -1
- package/dist/hitl/allowRuleShadow.js +18 -15
- package/dist/hitl/approvalCardReasons.d.ts +3 -2
- package/dist/hitl/approvalCardReasons.js +29 -30
- package/dist/hitl/approvalHolds.d.ts +17 -0
- package/dist/hitl/approvalHolds.js +114 -29
- package/dist/hitl/askClassPair.d.ts +2 -2
- package/dist/hitl/askClassPair.js +16 -0
- package/dist/hitl/askGateWire.js +2 -1
- package/dist/hitl/askSettlementLine.d.ts +14 -4
- package/dist/hitl/askSettlementLine.js +67 -47
- package/dist/hitl/attributionLadder.d.ts +23 -0
- package/dist/hitl/attributionLadder.js +67 -0
- package/dist/hitl/automaticAnswerVerdict.d.ts +2 -1
- package/dist/hitl/automaticAnswerVerdict.js +8 -8
- package/dist/hitl/crashConvergedNotice.d.ts +5 -4
- package/dist/hitl/crashConvergedNotice.js +28 -41
- package/dist/hitl/decisionLedger.d.ts +55 -0
- package/dist/hitl/decisionLedger.js +156 -0
- package/dist/hitl/decisionRefusal.d.ts +1 -0
- package/dist/hitl/decisionRefusal.js +1 -1
- package/dist/hitl/decisionSend.d.ts +113 -0
- package/dist/hitl/decisionSend.js +579 -0
- package/dist/hitl/frameRouter.js +7 -8
- package/dist/hitl/hitlBridge.d.ts +1 -0
- package/dist/hitl/hitlBridge.js +21 -9
- package/dist/hitl/persistedRulesWire.d.ts +6 -5
- package/dist/hitl/persistedRulesWire.js +55 -73
- package/dist/hitl/planReviewWire.d.ts +5 -0
- package/dist/hitl/planReviewWire.js +53 -76
- package/dist/hitl/sessionPolicyDeliverable.d.ts +2 -0
- package/dist/hitl/sessionPolicyDeliverable.js +49 -9
- package/dist/hitl/sessionPolicyWire.d.ts +2 -1
- package/dist/hitl/sessionPolicyWire.js +23 -24
- package/dist/hitl/suspendedReopen.d.ts +2 -1
- package/dist/hitl/suspendedReopen.js +7 -10
- package/dist/hitl/toolApprovalWire.d.ts +17 -5
- package/dist/hitl/toolApprovalWire.js +120 -147
- package/dist/hooksWireCaps.js +145 -56
- package/dist/host.d.ts +21 -0
- package/dist/hostTurnSettings.d.ts +110 -0
- package/dist/hostTurnSettings.js +692 -0
- package/dist/humanTurn.d.ts +15 -1
- package/dist/humanTurn.js +100 -12
- package/dist/humanTurnRead.d.ts +2 -0
- package/dist/humanTurnRead.js +22 -1
- package/dist/i18n/messages.en.d.ts +713 -0
- package/dist/i18n/messages.en.js +713 -0
- package/dist/i18n/messages.zh.js +854 -1
- package/dist/index.d.ts +45 -13
- package/dist/index.js +27 -9
- package/dist/inheritEnvCapability.d.ts +4 -2
- package/dist/inheritEnvCapability.js +12 -5
- package/dist/inheritEnvWire.d.ts +3 -2
- package/dist/inheritEnvWire.js +14 -16
- package/dist/injectionLaneNotice.d.ts +5 -0
- package/dist/injectionLaneNotice.js +46 -0
- package/dist/interactiveHalt.js +17 -6
- package/dist/liveModelCatalog.d.ts +2 -1
- package/dist/liveModelCatalog.js +14 -8
- package/dist/mcpPanel.d.ts +10 -1
- package/dist/mcpPanel.js +42 -13
- package/dist/mcpProbeCapability.d.ts +2 -1
- package/dist/mcpProbeCapability.js +7 -11
- package/dist/mcpProbeWire.d.ts +3 -1
- package/dist/mcpProbeWire.js +5 -0
- package/dist/mcpReconnect.js +2 -2
- package/dist/mcpToolToggles.d.ts +6 -0
- package/dist/mcpToolToggles.js +46 -0
- package/dist/mcpWireCaps.d.ts +43 -3
- package/dist/mcpWireCaps.js +194 -59
- package/dist/mcpWireTransport.d.ts +4 -0
- package/dist/mcpWireTransport.js +18 -0
- package/dist/memoryEntriesWire.js +5 -10
- package/dist/model/onboardJudgement.d.ts +93 -0
- package/dist/model/onboardJudgement.js +415 -0
- package/dist/model/tierVocabulary.d.ts +2 -0
- package/dist/model/tierVocabulary.js +17 -5
- package/dist/modelCapabilityProbe.d.ts +65 -0
- package/dist/modelCapabilityProbe.js +601 -0
- package/dist/modelIdentityResolvability.d.ts +5 -0
- package/dist/modelIdentityResolvability.js +49 -22
- package/dist/ownKey.d.ts +33 -0
- package/dist/ownKey.js +109 -0
- package/dist/panelReduce.d.ts +11 -1
- package/dist/panelReduce.js +95 -16
- package/dist/panelStateHolder.d.ts +1 -0
- package/dist/panelStateHolder.js +10 -1
- package/dist/permissionRuleIssue.d.ts +2 -1
- package/dist/permissionRuleIssue.js +23 -20
- package/dist/permissionRulesWriteCapability.d.ts +2 -1
- package/dist/permissionRulesWriteCapability.js +8 -6
- package/dist/pluginHooksWire.d.ts +46 -3
- package/dist/pluginHooksWire.js +220 -12
- package/dist/prepareRefusal.d.ts +8 -0
- package/dist/prepareRefusal.js +72 -0
- package/dist/printModelStatus.d.ts +63 -0
- package/dist/printModelStatus.js +155 -0
- package/dist/request/taskRequest.d.ts +16 -10
- package/dist/request/taskRequest.js +195 -58
- package/dist/resumeRefusalCopy.d.ts +14 -9
- package/dist/resumeRefusalCopy.js +89 -144
- package/dist/retryStatus.d.ts +55 -0
- package/dist/retryStatus.js +155 -19
- package/dist/ruleRefusalSentence.d.ts +4 -0
- package/dist/ruleRefusalSentence.js +58 -0
- package/dist/sandboxWire.d.ts +2 -1
- package/dist/sandboxWire.js +55 -21
- package/dist/scenarioRefusal.d.ts +10 -0
- package/dist/scenarioRefusal.js +111 -0
- package/dist/seam.d.ts +48 -9
- package/dist/seam.js +54 -5
- package/dist/seatContract.d.ts +272 -14
- package/dist/seatContract.js +711 -23
- package/dist/selfOrchestrationDenial.js +7 -19
- package/dist/sessionIdSegment.d.ts +6 -0
- package/dist/sessionIdSegment.js +24 -0
- package/dist/sessionMemoryStatus.js +6 -11
- package/dist/sessionPolicyCapability.d.ts +2 -1
- package/dist/sessionPolicyCapability.js +8 -6
- package/dist/settingsCredentialKeyPaths.d.ts +8 -0
- package/dist/settingsCredentialKeyPaths.js +219 -0
- package/dist/settingsHooksSalvage.d.ts +44 -0
- package/dist/settingsHooksSalvage.js +211 -0
- package/dist/skillToolListsCapability.d.ts +2 -1
- package/dist/skillToolListsCapability.js +8 -6
- package/dist/skillsWireCaps.d.ts +0 -3
- package/dist/skillsWireCaps.js +1 -2
- package/dist/sseIdleTriage.js +3 -2
- package/dist/subagent/engineSubagentResume.js +15 -9
- package/dist/subagentContentStore.d.ts +4 -0
- package/dist/subagentContentStore.js +157 -27
- package/dist/toolHistoryMismatch.js +3 -2
- package/dist/toolRoster.d.ts +3 -2
- package/dist/toolRoster.js +21 -20
- package/dist/toolsFlagNames.d.ts +8 -0
- package/dist/toolsFlagNames.js +110 -0
- package/dist/turnFailurePresentation.d.ts +12 -1
- package/dist/turnFailurePresentation.js +220 -15
- package/dist/usageAnalytics.js +6 -11
- package/dist/userAttachmentEnvelope.d.ts +1 -0
- package/dist/userAttachmentEnvelope.js +37 -7
- package/dist/userAttachmentSeat.d.ts +21 -0
- package/dist/userAttachmentSeat.js +75 -0
- package/dist/userInvokedSkillsCapability.d.ts +11 -1
- package/dist/userInvokedSkillsCapability.js +31 -7
- package/dist/wireErrorTriage.d.ts +7 -0
- package/dist/wireErrorTriage.js +23 -1
- package/dist/wireFailureShape.js +2 -1
- package/dist/wireRefusalCopy.d.ts +62 -16
- package/dist/wireRefusalCopy.js +307 -148
- package/dist/workflowsJournalCapability.d.ts +2 -1
- package/dist/workflowsJournalCapability.js +8 -6
- package/docs/INTEGRATION-CLIENTS.md +951 -42
- package/package.json +5 -5
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { msg, renderMessage } from './i18n/translate.js';
|
|
2
|
+
import { readBlockedBy, readErrorNumber, readErrorString, readThrownSlot } from './wireFailureShape.js';
|
|
2
3
|
import { guardedRead, ownDataField, readOwnDataNonEmptyString, readOwnDataValue } from './ownKey.js';
|
|
3
4
|
import { CORE_RESUME_STARTUP_CAUSES } from './generated/engineFactTables.js';
|
|
4
5
|
import { RESUME_CONTEXT_UNAVAILABLE, RESUME_PLACEMENT_MISMATCH, RESUME_PREFLIGHT_REJECTED, RESUME_POLICY_FOLD_CODE, PARKED_RESUME_STARTUP_FAILED, isStatusDerivedCoarseCode, RESUME_SESSION_NOT_FOUND, REQUEST_FIELD_CONFLICT, CHECKPOINT_UNSUPPORTED_VERSION, CHECKPOINT_WALLTIME_AXIS_RETIRED, CHECKPOINT_CONFIG_REFUSED, isRefusedParkCode, refusalSaysStillPending, refusalRetriableReading, } from './engineErrorCodes.js';
|
|
@@ -27,51 +28,30 @@ export function resumeRefusalFromError(err) {
|
|
|
27
28
|
...(timed.retryAfterSec !== undefined ? { retryAfterSec: timed.retryAfterSec } : {}),
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
|
-
export function resumeRefusalContent(detail) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
parts.push('The engine refused it before consuming anything — the parked work is untouched');
|
|
35
|
-
parts.push('Retry with the recorded root, or omit the placement root to inherit it');
|
|
36
|
-
return parts.join(' · ');
|
|
37
|
-
}
|
|
38
|
-
parts.push("The deployment's resume preflight refused this attempt");
|
|
39
|
-
parts.push('The refusal happened before the commit — your decision was not consumed');
|
|
40
|
-
parts.push(detail.waitable
|
|
41
|
-
? 'The engine supplied a wait, so this token stays redeemable once the obstacle clears'
|
|
42
|
-
:
|
|
43
|
-
'The engine supplied no wait, so this refusal does not say whether the token stays redeemable');
|
|
44
|
-
return parts.join(' · ');
|
|
31
|
+
export function resumeRefusalContent(detail, lang) {
|
|
32
|
+
if (detail.code === RESUME_PLACEMENT_MISMATCH)
|
|
33
|
+
return renderMessage(msg('resume.refusal.placementMismatch'), lang);
|
|
34
|
+
return renderMessage(msg(detail.waitable ? 'resume.refusal.preflightWaitable' : 'resume.refusal.preflightNoWait'), lang);
|
|
45
35
|
}
|
|
46
36
|
export function resumePolicyBlockFromError(err) {
|
|
47
37
|
if (typeof err !== 'object' || err === null)
|
|
48
38
|
return null;
|
|
49
39
|
const o = err;
|
|
50
|
-
|
|
51
|
-
try {
|
|
52
|
-
outer = o['errorCode'];
|
|
53
|
-
}
|
|
54
|
-
catch {
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
40
|
+
const outer = guardedRead(() => ownDataField(err, 'errorCode'));
|
|
57
41
|
if (outer !== RESUME_POLICY_FOLD_CODE)
|
|
58
42
|
return null;
|
|
59
43
|
return { blockedBy: readBlockedBy(o) };
|
|
60
44
|
}
|
|
61
|
-
export function resumePolicyBlockContent(detail) {
|
|
45
|
+
export function resumePolicyBlockContent(detail, lang) {
|
|
62
46
|
const b = detail.blockedBy;
|
|
63
47
|
const reason = b.kind === 'named'
|
|
64
48
|
? isStatusDerivedCoarseCode(b.code)
|
|
65
|
-
?
|
|
66
|
-
:
|
|
49
|
+
? msg('resume.refusal.policyBlockReason.coarse', { code: b.code })
|
|
50
|
+
: msg('resume.refusal.policyBlockReason.named', { code: capForDisplay(b.code, 80) })
|
|
67
51
|
: b.kind === 'absent'
|
|
68
|
-
? '
|
|
69
|
-
: '
|
|
70
|
-
return
|
|
71
|
-
'The engine refused to resume this parked work at its admission check (the engine reports that its admission policy changed since the work was first accepted)',
|
|
72
|
-
reason,
|
|
73
|
-
"This refusal does not say whether anything was consumed before it or whether a retry would pass — check the task's current state before deciding again, and ask whoever operates this deployment if it keeps happening",
|
|
74
|
-
].join(' · ');
|
|
52
|
+
? msg('resume.refusal.policyBlockReason.absent')
|
|
53
|
+
: msg('resume.refusal.policyBlockReason.unreadable');
|
|
54
|
+
return renderMessage(msg('resume.refusal.policyBlock', { reason }), lang);
|
|
75
55
|
}
|
|
76
56
|
export { resumeReopenFromError, resumeReopenContent } from './hitl/suspendedReopen.js';
|
|
77
57
|
const REQUIRE_EXISTING_BY_STATUS = new Map([
|
|
@@ -82,27 +62,29 @@ export function requireExistingSessionRefusalFromError(err) {
|
|
|
82
62
|
if (typeof err !== 'object' || err === null)
|
|
83
63
|
return null;
|
|
84
64
|
try {
|
|
85
|
-
const
|
|
86
|
-
const status = o['status'];
|
|
65
|
+
const status = readThrownSlot(err, 'status', 'data');
|
|
87
66
|
const byStatus = typeof status === 'number' ? REQUIRE_EXISTING_BY_STATUS.get(status) : undefined;
|
|
88
67
|
if (byStatus === undefined)
|
|
89
68
|
return null;
|
|
90
|
-
return
|
|
69
|
+
return readThrownSlot(err, 'errorCode', 'data') === byStatus.code ? Object.freeze({ code: RESUME_SESSION_NOT_FOUND, form: byStatus.form }) : null;
|
|
91
70
|
}
|
|
92
71
|
catch {
|
|
93
72
|
return null;
|
|
94
73
|
}
|
|
95
74
|
}
|
|
96
|
-
const
|
|
97
|
-
session_not_found: '
|
|
98
|
-
session_id_missing: '
|
|
75
|
+
const REQUIRE_EXISTING_SESSION_KEYS = Object.freeze({
|
|
76
|
+
session_not_found: 'resume.refusal.requireExisting.sessionNotFound',
|
|
77
|
+
session_id_missing: 'resume.refusal.requireExisting.sessionIdMissing',
|
|
99
78
|
});
|
|
100
|
-
const REQUIRE_EXISTING_SESSION_GENERIC = '
|
|
101
|
-
export function requireExistingSessionRefusalContent(detail) {
|
|
79
|
+
const REQUIRE_EXISTING_SESSION_GENERIC = 'resume.refusal.requireExisting.generic';
|
|
80
|
+
export function requireExistingSessionRefusalContent(detail, lang) {
|
|
81
|
+
return renderMessage(msg(requireExistingSessionKey(detail)), lang);
|
|
82
|
+
}
|
|
83
|
+
function requireExistingSessionKey(detail) {
|
|
102
84
|
try {
|
|
103
85
|
const form = detail?.form;
|
|
104
|
-
return typeof form === 'string' && Object.hasOwn(
|
|
105
|
-
?
|
|
86
|
+
return typeof form === 'string' && Object.hasOwn(REQUIRE_EXISTING_SESSION_KEYS, form)
|
|
87
|
+
? REQUIRE_EXISTING_SESSION_KEYS[form]
|
|
106
88
|
: REQUIRE_EXISTING_SESSION_GENERIC;
|
|
107
89
|
}
|
|
108
90
|
catch {
|
|
@@ -112,8 +94,7 @@ export function requireExistingSessionRefusalContent(detail) {
|
|
|
112
94
|
export function resumeContextUnavailableFromError(err) {
|
|
113
95
|
if (typeof err !== 'object' || err === null)
|
|
114
96
|
return null;
|
|
115
|
-
|
|
116
|
-
if (e.errorCode !== RESUME_CONTEXT_UNAVAILABLE)
|
|
97
|
+
if (readThrownSlot(err, 'errorCode', 'data') !== RESUME_CONTEXT_UNAVAILABLE)
|
|
117
98
|
return null;
|
|
118
99
|
const sec = readErrorNumber(err, 'staleAfterSec');
|
|
119
100
|
const staleSec = sec !== undefined && Number.isInteger(sec) && sec >= 1 ? sec : undefined;
|
|
@@ -125,17 +106,11 @@ export function resumeContextUnavailableFromError(err) {
|
|
|
125
106
|
...(runId !== undefined ? { runId } : {}),
|
|
126
107
|
};
|
|
127
108
|
}
|
|
128
|
-
export function resumeContextUnavailableContent(d) {
|
|
109
|
+
export function resumeContextUnavailableContent(d, lang) {
|
|
129
110
|
const sec = d.staleAfterSec;
|
|
130
|
-
const retention = typeof sec === 'number' && Number.isSafeInteger(sec) && sec >= 1 ?
|
|
131
|
-
const third = (d.runId !== undefined
|
|
132
|
-
|
|
133
|
-
: 'The error carries no run id: go back to the run list, find this run and recover it yourself, then decide again; raising the conversation retention time only prevents this from happening again and cannot rescue this one') + retention;
|
|
134
|
-
return [
|
|
135
|
-
'This approval has nowhere to be delivered: the conversation that started this run has no usable context to continue it right now',
|
|
136
|
-
'Nothing was decided and your decision was not consumed; this card is still waiting',
|
|
137
|
-
third,
|
|
138
|
-
].join(' · ');
|
|
111
|
+
const retention = typeof sec === 'number' && Number.isSafeInteger(sec) && sec >= 1 ? msg('resume.refusal.contextRetention', { sec }) : '';
|
|
112
|
+
const third = msg(d.runId !== undefined ? 'resume.refusal.contextThird.withRun' : 'resume.refusal.contextThird.noRun', { retention });
|
|
113
|
+
return renderMessage(msg('resume.refusal.contextUnavailable', { third }), lang);
|
|
139
114
|
}
|
|
140
115
|
function parkedResumeStartupCauseWord(err) {
|
|
141
116
|
let named;
|
|
@@ -150,6 +125,7 @@ function parkedResumeStartupCauseWord(err) {
|
|
|
150
125
|
function isResumeStartupCause(v) {
|
|
151
126
|
return typeof v === 'string' && CORE_RESUME_STARTUP_CAUSES.includes(v);
|
|
152
127
|
}
|
|
128
|
+
const RESUME_CAUSE_CORE_AHEAD = Object.freeze(['transcript_corrupt']);
|
|
153
129
|
const _startupCausePin = true;
|
|
154
130
|
void _startupCausePin;
|
|
155
131
|
export function parkedResumeStartupFromError(err, decision) {
|
|
@@ -176,62 +152,28 @@ export function parkedResumeStartupFromError(err, decision) {
|
|
|
176
152
|
denyStaysOpen: true,
|
|
177
153
|
};
|
|
178
154
|
}
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
'The engine could not start the parked work to apply this decision (its session may be gone, or the engine rejected the decision itself; this client cannot tell which)',
|
|
183
|
-
PARKED_RESUME_STARTUP_STATE,
|
|
184
|
-
'If the card is still there, decide it again from the fresh list',
|
|
185
|
-
].join(' · '),
|
|
186
|
-
undetermined: [
|
|
187
|
-
'The engine could not start the parked work to apply this decision',
|
|
188
|
-
PARKED_RESUME_STARTUP_STATE,
|
|
189
|
-
'If the card is still there: when the engine rejected the decision itself (for example an answer given to the wrong question), correct it and decide again; when the approved tool is one the agent inherits from the task that started it, approving it again will not work on this server — deny the card, or wait for a server upgrade',
|
|
190
|
-
].join(' · '),
|
|
155
|
+
const PARKED_RESUME_STARTUP_KEYS = Object.freeze({
|
|
156
|
+
resume_rejected: 'resume.refusal.startup.resumeRejected',
|
|
157
|
+
undetermined: 'resume.refusal.startup.undetermined',
|
|
191
158
|
});
|
|
192
|
-
const
|
|
193
|
-
environment:
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
'The engine could not start the parked work to apply this decision: the session of the agent it would resume is gone',
|
|
200
|
-
PARKED_RESUME_STARTUP_STATE,
|
|
201
|
-
'If the card is still there, deny it to close it; the work it was waiting on cannot be resumed',
|
|
202
|
-
].join(' · '),
|
|
203
|
-
tool_unavailable: [
|
|
204
|
-
'The engine could not start the parked work to apply this decision: the approved tool is not available to the resumed work (it is gone, or a different tool now has its name)',
|
|
205
|
-
PARKED_RESUME_STARTUP_STATE,
|
|
206
|
-
'This approval cannot run as decided — if the card is still there, decide it afresh (denying it settles it)',
|
|
207
|
-
].join(' · '),
|
|
208
|
-
configuration: [
|
|
209
|
-
"The engine could not start the parked work to apply this decision: this deployment's configuration refuses the resumed work",
|
|
210
|
-
PARKED_RESUME_STARTUP_STATE,
|
|
211
|
-
'Deciding again under the same configuration fails the same way — the configuration has to change first; denying the card settles it',
|
|
212
|
-
].join(' · '),
|
|
213
|
-
decision_rejected: [
|
|
214
|
-
'The engine could not start the parked work to apply this decision: the engine rejected the decision itself (for example an answer given to the wrong question, or an edited input the constraints refuse)',
|
|
215
|
-
PARKED_RESUME_STARTUP_STATE,
|
|
216
|
-
'If the card is still there, correct the decision and decide it again from the fresh list',
|
|
217
|
-
].join(' · '),
|
|
159
|
+
const PARKED_RESUME_STARTUP_CAUSE_KEYS = Object.freeze({
|
|
160
|
+
environment: 'resume.refusal.startup.cause.environment',
|
|
161
|
+
session_gone: 'resume.refusal.startup.cause.sessionGone',
|
|
162
|
+
tool_unavailable: 'resume.refusal.startup.cause.toolUnavailable',
|
|
163
|
+
configuration: 'resume.refusal.startup.cause.configuration',
|
|
164
|
+
decision_rejected: 'resume.refusal.startup.cause.decisionRejected',
|
|
165
|
+
transcript_corrupt: 'resume.refusal.startup.cause.transcriptCorrupt',
|
|
218
166
|
});
|
|
219
|
-
export function parkedResumeStartupContent(detail) {
|
|
167
|
+
export function parkedResumeStartupContent(detail, lang) {
|
|
220
168
|
const word = guardedRead(() => readOwnDataValue(detail, 'startupCause'));
|
|
221
169
|
if (isResumeStartupCause(word))
|
|
222
|
-
return
|
|
223
|
-
return detail.cause === 'resume_rejected' ?
|
|
170
|
+
return renderMessage(msg(PARKED_RESUME_STARTUP_CAUSE_KEYS[word]), lang);
|
|
171
|
+
return renderMessage(msg(detail.cause === 'resume_rejected' ? PARKED_RESUME_STARTUP_KEYS.resume_rejected : PARKED_RESUME_STARTUP_KEYS.undetermined), lang);
|
|
224
172
|
}
|
|
225
173
|
export function checkpointUnsupportedVersionFromError(err) {
|
|
226
174
|
if (typeof err !== 'object' || err === null)
|
|
227
175
|
return null;
|
|
228
|
-
|
|
229
|
-
try {
|
|
230
|
-
code = err.errorCode;
|
|
231
|
-
}
|
|
232
|
-
catch {
|
|
233
|
-
return null;
|
|
234
|
-
}
|
|
176
|
+
const code = guardedRead(() => ownDataField(err, 'errorCode'));
|
|
235
177
|
if (code !== CHECKPOINT_UNSUPPORTED_VERSION || !refusalSaysStillPending(err))
|
|
236
178
|
return null;
|
|
237
179
|
const writerVersion = readErrorString(err, 'writerVersion');
|
|
@@ -257,10 +199,7 @@ function checkpointUnsupportedHasRun(kind) {
|
|
|
257
199
|
return undefined;
|
|
258
200
|
}
|
|
259
201
|
}
|
|
260
|
-
|
|
261
|
-
const CHECKPOINT_UNSUPPORTED_STILL_WAITING = 'Nothing was decided or resumed and the parked work is still waiting, but sending the same request again will not by itself continue it';
|
|
262
|
-
const CHECKPOINT_UNSUPPORTED_DRAIN = " — whoever operates this deployment can find such parked work before an upgrade with the server's pre-upgrade drain check";
|
|
263
|
-
export function checkpointUnsupportedVersionContent(detail, ctx) {
|
|
202
|
+
export function checkpointUnsupportedVersionContent(detail, ctx, lang) {
|
|
264
203
|
let writer;
|
|
265
204
|
let reader;
|
|
266
205
|
try {
|
|
@@ -272,11 +211,7 @@ export function checkpointUnsupportedVersionContent(detail, ctx) {
|
|
|
272
211
|
reader = undefined;
|
|
273
212
|
}
|
|
274
213
|
if (writerEngineIsNewer(writer, reader)) {
|
|
275
|
-
return
|
|
276
|
-
`This parked work was stored by a newer engine version (${String(writer)}) than this engine (${String(reader)})`,
|
|
277
|
-
CHECKPOINT_UNSUPPORTED_STILL_WAITING,
|
|
278
|
-
`Continue it on an engine at version ${String(writer)} or newer`,
|
|
279
|
-
].join(' · ');
|
|
214
|
+
return renderMessage(msg('resume.refusal.checkpoint.newerEngine', { writer: String(writer), reader: String(reader) }), lang);
|
|
280
215
|
}
|
|
281
216
|
let kind;
|
|
282
217
|
let runId;
|
|
@@ -291,19 +226,19 @@ export function checkpointUnsupportedVersionContent(detail, ctx) {
|
|
|
291
226
|
const hasRun = checkpointUnsupportedHasRun(kind);
|
|
292
227
|
let outlet;
|
|
293
228
|
if (hasRun === true) {
|
|
294
|
-
const named = typeof runId === 'string' && runId.length > 0 ?
|
|
295
|
-
outlet =
|
|
229
|
+
const named = typeof runId === 'string' && runId.length > 0 ? msg('resume.refusal.checkpoint.runNamed', { runId: capForDisplay(runId, 80) }) : '';
|
|
230
|
+
outlet = msg('resume.refusal.checkpoint.outletWithRun', { named });
|
|
296
231
|
}
|
|
297
232
|
else if (hasRun === false) {
|
|
298
|
-
outlet = '
|
|
233
|
+
outlet = msg('resume.refusal.checkpoint.outletNoRun');
|
|
299
234
|
}
|
|
300
235
|
else {
|
|
301
|
-
outlet =
|
|
302
|
-
'If it was parked before this server was upgraded, submit the work again as a new task (this client cannot tell which kind of parked work this is, so both ways out are given): when it still has a run waiting on it (a tool approval, a plan review or a paused resource), cancel that run first; when it was waiting to be woken up, or was a workflow step continuing its host conversation, there is no run to cancel, so start a new task in that conversation';
|
|
236
|
+
outlet = msg('resume.refusal.checkpoint.outletUnknownKind');
|
|
303
237
|
}
|
|
304
|
-
return
|
|
238
|
+
return renderMessage(msg('resume.refusal.checkpoint.content', { outlet }), lang);
|
|
305
239
|
}
|
|
306
240
|
const REFUSED_PARK_FIELD_TOKEN = /^[A-Za-z][A-Za-z0-9_]{0,63}$/;
|
|
241
|
+
const REFUSED_PARK_CODE_TOKEN = /^(?=.{1,128}$)[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z0-9_]+)*$/;
|
|
307
242
|
export function refusedParkFromError(failure) {
|
|
308
243
|
if (typeof failure !== 'object' || failure === null)
|
|
309
244
|
return null;
|
|
@@ -324,10 +259,22 @@ export function refusedParkFromError(failure) {
|
|
|
324
259
|
const stillPending = reading === true ? true : status === 409 && reading === false ? false : undefined;
|
|
325
260
|
const rawField = code === CHECKPOINT_CONFIG_REFUSED ? readErrorString(failure, 'field') : undefined;
|
|
326
261
|
const field = rawField !== undefined && REFUSED_PARK_FIELD_TOKEN.test(rawField) ? rawField : undefined;
|
|
262
|
+
let blockedBy;
|
|
263
|
+
try {
|
|
264
|
+
const b = readBlockedBy(failure);
|
|
265
|
+
blockedBy = b.kind === 'named' && REFUSED_PARK_CODE_TOKEN.test(b.code) ? b.code : undefined;
|
|
266
|
+
}
|
|
267
|
+
catch {
|
|
268
|
+
blockedBy = undefined;
|
|
269
|
+
}
|
|
270
|
+
const rawReason = readErrorString(failure, 'reason');
|
|
271
|
+
const reason = rawReason !== undefined && REFUSED_PARK_FIELD_TOKEN.test(rawReason) ? rawReason : undefined;
|
|
327
272
|
return Object.freeze({
|
|
328
273
|
code,
|
|
329
274
|
...(field !== undefined ? { field } : {}),
|
|
330
275
|
...(stillPending !== undefined ? { stillPending } : {}),
|
|
276
|
+
...(blockedBy !== undefined ? { blockedBy } : {}),
|
|
277
|
+
...(reason !== undefined ? { reason } : {}),
|
|
331
278
|
});
|
|
332
279
|
}
|
|
333
280
|
function refusedParkShownRunId(runId) {
|
|
@@ -336,22 +283,23 @@ function refusedParkShownRunId(runId) {
|
|
|
336
283
|
function refusedParkWhy(code, field) {
|
|
337
284
|
switch (code) {
|
|
338
285
|
case CHECKPOINT_WALLTIME_AXIS_RETIRED:
|
|
339
|
-
return '
|
|
286
|
+
return msg('resume.refusal.park.whyWalltime');
|
|
340
287
|
case CHECKPOINT_CONFIG_REFUSED:
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
288
|
+
if (field === 'deps')
|
|
289
|
+
return msg('resume.refusal.park.whyDeps');
|
|
290
|
+
return msg(field === 'inheritedGate' ? 'resume.refusal.park.whyInheritedGate' : 'resume.refusal.park.whyConfigRefused');
|
|
344
291
|
default:
|
|
345
|
-
return '
|
|
292
|
+
return msg('resume.refusal.park.whyUnsupported');
|
|
346
293
|
}
|
|
347
294
|
}
|
|
348
|
-
export function refusedParkContent(input) {
|
|
295
|
+
export function refusedParkContent(input, lang) {
|
|
349
296
|
let what;
|
|
350
297
|
let lane;
|
|
351
298
|
let runId;
|
|
352
299
|
let rawCode;
|
|
353
300
|
let field;
|
|
354
301
|
let stillPending;
|
|
302
|
+
let blockedBy;
|
|
355
303
|
try {
|
|
356
304
|
what = input.what;
|
|
357
305
|
lane = input.lane;
|
|
@@ -365,35 +313,32 @@ export function refusedParkContent(input) {
|
|
|
365
313
|
rawCode = facts.code;
|
|
366
314
|
field = facts.field;
|
|
367
315
|
stillPending = facts.stillPending;
|
|
316
|
+
blockedBy = facts.blockedBy;
|
|
368
317
|
}
|
|
369
318
|
catch {
|
|
370
|
-
rawCode = field = stillPending = undefined;
|
|
319
|
+
rawCode = field = stillPending = blockedBy = undefined;
|
|
371
320
|
}
|
|
372
321
|
const code = rawCode === CHECKPOINT_WALLTIME_AXIS_RETIRED || rawCode === CHECKPOINT_CONFIG_REFUSED ? rawCode : CHECKPOINT_UNSUPPORTED_VERSION;
|
|
373
|
-
const shownWhat = typeof what === 'string' && what !== '' ? capForDisplay(what, 40) : '
|
|
322
|
+
const shownWhat = typeof what === 'string' && what !== '' ? capForDisplay(what, 40) : msg('resume.refusal.park.whatDefault');
|
|
374
323
|
const why = refusedParkWhy(code, typeof field === 'string' ? field : undefined);
|
|
375
324
|
const shownRun = refusedParkShownRunId(runId);
|
|
376
|
-
const head =
|
|
377
|
-
|
|
378
|
-
const configMayReturn = code === CHECKPOINT_CONFIG_REFUSED && field !== 'inheritedGate' ? ' If that configuration is restored, the same answer can go through again.' : '';
|
|
325
|
+
const head = msg('resume.refusal.park.head', { what: shownWhat, why });
|
|
326
|
+
const configMayReturn = code === CHECKPOINT_CONFIG_REFUSED && field !== 'inheritedGate' ? msg(field === 'deps' ? 'resume.refusal.park.depsMayReturn' : 'resume.refusal.park.configMayReturn') : '';
|
|
379
327
|
if (lane === 'print') {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
328
|
+
const blocked = typeof blockedBy === 'string' && REFUSED_PARK_CODE_TOKEN.test(blockedBy) ? msg('resume.refusal.park.blockedByTail', { blockedBy }) : '';
|
|
329
|
+
if (stillPending === false)
|
|
330
|
+
return renderMessage(msg('resume.refusal.park.printEnded', { head, code, blocked }), lang);
|
|
383
331
|
const cancel = `POST /v1/runs/${shownRun ?? '<run id>'}/cancel`;
|
|
384
|
-
return
|
|
385
|
-
}
|
|
386
|
-
if (stillPending === false) {
|
|
387
|
-
return `${head} The engine ended that parked run, so this conversation is free: send the work again as a new message.`;
|
|
332
|
+
return renderMessage(msg('resume.refusal.park.printHolds', { head, configMayReturn, code, cancel, blocked }), lang);
|
|
388
333
|
}
|
|
389
|
-
|
|
334
|
+
if (stillPending === false)
|
|
335
|
+
return renderMessage(msg('resume.refusal.park.interactiveEnded', { head }), lang);
|
|
336
|
+
return renderMessage(msg('resume.refusal.park.interactiveBusy', { head, configMayReturn }), lang);
|
|
390
337
|
}
|
|
391
|
-
export function refusedParkBlockedContent(taskId, lane = 'interactive') {
|
|
338
|
+
export function refusedParkBlockedContent(taskId, lane = 'interactive', lang) {
|
|
392
339
|
const runId = refusedParkShownRunId(taskId);
|
|
393
|
-
const
|
|
394
|
-
if (lane === 'print')
|
|
395
|
-
return
|
|
396
|
-
}
|
|
397
|
-
return (`${head} To free this conversation, send a message to bring the card back and answer it — sema then offers to cancel ` +
|
|
398
|
-
`that run, after which you can send the work again as a new message.`);
|
|
340
|
+
const run = runId ?? '<unknown>';
|
|
341
|
+
if (lane === 'print')
|
|
342
|
+
return renderMessage(msg('resume.refusal.park.blockedPrint', { run, cancel: `POST /v1/runs/${runId ?? '<run id>'}/cancel` }), lang);
|
|
343
|
+
return renderMessage(msg('resume.refusal.park.blockedInteractive', { run }), lang);
|
|
399
344
|
}
|
package/dist/retryStatus.d.ts
CHANGED
|
@@ -71,12 +71,67 @@ export interface BrainStatusPayload {
|
|
|
71
71
|
}
|
|
72
72
|
export declare const BRAIN_STATUS_PAYLOAD_KEYS: readonly ["phase", "detail", "retryInSec", "retryInMs", "attempt", "maxRetries", "errClass", "retryAtMs", "errorStatus", "elapsedMs", "timeoutMs", "providerCondition", "providerConditionSource"];
|
|
73
73
|
export declare function mapBrainStatusToRetry(p: BrainStatusPayload, nowMs: number): RetryStatus | null;
|
|
74
|
+
export interface RetryStatusArmLike {
|
|
75
|
+
readonly phase?: string;
|
|
76
|
+
readonly detail?: string;
|
|
77
|
+
readonly retryInSec?: number;
|
|
78
|
+
readonly retryInMs?: number;
|
|
79
|
+
readonly attempt?: number;
|
|
80
|
+
readonly maxRetries?: number;
|
|
81
|
+
readonly errClass?: string;
|
|
82
|
+
readonly retryAtMs?: number;
|
|
83
|
+
readonly errorStatus?: number;
|
|
84
|
+
readonly elapsedMs?: number;
|
|
85
|
+
readonly timeoutMs?: number;
|
|
86
|
+
readonly providerCondition?: string;
|
|
87
|
+
readonly providerConditionSource?: string;
|
|
88
|
+
readonly parentToolCallId?: string;
|
|
89
|
+
}
|
|
90
|
+
export declare function retryStatusFromArm(arm: RetryStatusArmLike | null | undefined, nowMs: number): RetryStatus | null | undefined;
|
|
74
91
|
export interface RetryStatusNotice {
|
|
75
92
|
readonly line: string;
|
|
76
93
|
readonly recourse?: 'switch_model' | 'wait' | 'fix_request';
|
|
77
94
|
readonly phase: 'retrying' | 'reconnecting' | 'waiting_first_token' | 'gave_up' | 'cleared';
|
|
78
95
|
}
|
|
96
|
+
export interface RetryStatusParts {
|
|
97
|
+
readonly phase: RetryStatusNotice['phase'];
|
|
98
|
+
readonly model?: string;
|
|
99
|
+
readonly condition?: string;
|
|
100
|
+
readonly resendNote?: string;
|
|
101
|
+
readonly httpStatus?: number;
|
|
102
|
+
readonly source?: string;
|
|
103
|
+
readonly attempt?: number;
|
|
104
|
+
readonly maxAttempts?: number;
|
|
105
|
+
readonly elapsedMs?: number;
|
|
106
|
+
readonly timeoutMs?: number;
|
|
107
|
+
readonly retryAtMs?: number;
|
|
108
|
+
readonly detail?: string;
|
|
109
|
+
readonly recourse?: RetryStatusNotice['recourse'];
|
|
110
|
+
}
|
|
111
|
+
export declare function retryStatusParts(status: RetryStatus | null, ctx?: {
|
|
112
|
+
readonly modelName?: string;
|
|
113
|
+
}): RetryStatusParts;
|
|
79
114
|
export declare function retryStatusNotice(status: RetryStatus | null, ctx?: {
|
|
80
115
|
readonly modelName?: string;
|
|
81
116
|
}): RetryStatusNotice;
|
|
117
|
+
export interface ApiErrorRowLike {
|
|
118
|
+
readonly _sema_api_error_status?: number;
|
|
119
|
+
readonly _sema_provider_condition?: string;
|
|
120
|
+
readonly _sema_api_error_code?: string;
|
|
121
|
+
}
|
|
122
|
+
export interface ApiErrorRowFacts {
|
|
123
|
+
readonly status?: number;
|
|
124
|
+
readonly providerCondition?: string;
|
|
125
|
+
readonly errorCode?: string;
|
|
126
|
+
}
|
|
127
|
+
export interface ApiErrorNotice {
|
|
128
|
+
readonly line: string;
|
|
129
|
+
readonly recourse?: NonNullable<RetryStatusNotice['recourse']> | 'check_credentials';
|
|
130
|
+
}
|
|
131
|
+
export interface ApiErrorNoticeCtx {
|
|
132
|
+
readonly modelName?: string;
|
|
133
|
+
readonly providerText?: string;
|
|
134
|
+
}
|
|
135
|
+
export declare function apiErrorFactsOfRow(row: ApiErrorRowLike | null | undefined): ApiErrorRowFacts;
|
|
136
|
+
export declare function apiErrorNotice(facts: ApiErrorRowFacts | null | undefined, ctx?: ApiErrorNoticeCtx): ApiErrorNotice | undefined;
|
|
82
137
|
export {};
|