@sema-agent/client-core 0.110.0 → 0.111.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 +169 -0
- package/README.md +50 -18
- package/dist/abortableSleep.d.ts +7 -0
- package/dist/abortableSleep.js +37 -0
- package/dist/adapt/arms.js +25 -4
- package/dist/adapt/toolCards.d.ts +3 -1
- package/dist/adapt/toolCards.js +4 -2
- package/dist/adapter/activeRunSelfHeal.d.ts +39 -0
- package/dist/adapter/activeRunSelfHeal.js +171 -3
- package/dist/adapter/downstream/eventToSdkMessage.js +10 -10
- package/dist/adapter/downstream/terminalToSdkResult.d.ts +2 -0
- package/dist/adapter/downstream/terminalToSdkResult.js +11 -0
- package/dist/adapter/runStream.d.ts +5 -0
- package/dist/adapter/runStream.js +15 -3
- package/dist/attachmentRoute.d.ts +20 -0
- package/dist/attachmentRoute.js +39 -0
- package/dist/attachmentsWireCaps.js +1 -1
- package/dist/builtinOutputStyles.d.ts +12 -0
- package/dist/builtinOutputStyles.js +147 -0
- package/dist/compactionStatus.d.ts +9 -0
- package/dist/compactionStatus.js +29 -5
- package/dist/controlRouter.js +2 -1
- package/dist/coreValuePorts.d.ts +39 -1
- package/dist/coreValuePorts.js +10 -0
- package/dist/displayUntrusted.d.ts +1 -0
- package/dist/displayUntrusted.js +6 -0
- package/dist/engineHealthFacts.d.ts +11 -0
- package/dist/engineHealthFacts.js +21 -0
- package/dist/engineHealthProbeVerdict.d.ts +23 -0
- package/dist/engineHealthProbeVerdict.js +115 -0
- package/dist/engineNoticeCodes.js +5 -7
- package/dist/engineRepoint.d.ts +12 -5
- package/dist/engineRepoint.js +44 -19
- package/dist/engineRowRef.d.ts +3 -0
- package/dist/engineRowRef.js +11 -1
- package/dist/engineSwapCrossing.d.ts +57 -0
- package/dist/engineSwapCrossing.js +297 -0
- package/dist/engineUnavailable.d.ts +44 -0
- package/dist/engineUnavailable.js +492 -0
- package/dist/eventLeg.js +3 -3
- package/dist/generated/sdkFactTables.d.ts +1 -1
- package/dist/generated/sdkFactTables.js +1 -0
- package/dist/generated/settingsSchemaTables.d.ts +4 -0
- package/dist/generated/settingsSchemaTables.js +1 -0
- package/dist/hitl/approvalDelivery.d.ts +1 -0
- package/dist/hitl/approvalDelivery.js +1 -1
- package/dist/hitl/approvalResolution.d.ts +1 -1
- package/dist/hitl/approvalResolution.js +2 -1
- package/dist/hitl/askGateWire.js +5 -6
- package/dist/hitl/decisionRefusal.d.ts +2 -0
- package/dist/hitl/decisionRefusal.js +7 -8
- package/dist/hitl/decisionRefusalCarrier.d.ts +3 -0
- package/dist/hitl/decisionRefusalCarrier.js +348 -0
- package/dist/hitl/decisionSend.d.ts +7 -0
- package/dist/hitl/decisionSend.js +34 -12
- package/dist/hitl/editedApprovalAcceptance.js +1 -1
- package/dist/hitl/elicitationRefusal.d.ts +4 -0
- package/dist/hitl/elicitationRefusal.js +23 -0
- package/dist/hitl/frameRouter.d.ts +2 -2
- package/dist/hitl/frameRouter.js +8 -15
- package/dist/hitl/gateIdentity.d.ts +5 -0
- package/dist/hitl/gateIdentity.js +23 -0
- package/dist/hitl/hitlBridge.d.ts +6 -0
- package/dist/hitl/hitlBridge.js +10 -4
- package/dist/hitl/hitlHostSurface.d.ts +2 -1
- package/dist/hitl/hitlHostSurface.js +7 -2
- package/dist/hitl/localAllowRedemption.d.ts +67 -0
- package/dist/hitl/localAllowRedemption.js +256 -0
- package/dist/hitl/parkResolver.js +7 -4
- package/dist/hitl/persistedRulesWire.d.ts +16 -0
- package/dist/hitl/persistedRulesWire.js +70 -0
- package/dist/hitl/planReviewWire.d.ts +3 -0
- package/dist/hitl/planReviewWire.js +23 -6
- package/dist/hitl/policyDenyCause.d.ts +1 -1
- package/dist/hitl/policyDenyCause.js +1 -1
- package/dist/hitl/resumeRunningCard.d.ts +1 -0
- package/dist/hitl/resumeRunningCard.js +1 -0
- package/dist/hitl/screenCardCarriers.d.ts +15 -0
- package/dist/hitl/screenCardCarriers.js +41 -0
- package/dist/hitl/screenDecisionCards.d.ts +98 -0
- package/dist/hitl/screenDecisionCards.js +362 -0
- package/dist/hitl/standingRows.d.ts +3 -1
- package/dist/hitl/standingRows.js +18 -0
- package/dist/hitl/toolApprovalWire.d.ts +30 -8
- package/dist/hitl/toolApprovalWire.js +264 -121
- package/dist/hooksWireCaps.js +3 -3
- package/dist/hostSettingNoticeArm.d.ts +3 -0
- package/dist/hostSettingNoticeArm.js +12 -0
- package/dist/hostTurnSettings.d.ts +3 -0
- package/dist/hostTurnSettings.js +38 -5
- package/dist/humanTurnRead.js +11 -1
- package/dist/i18n/messages.en.d.ts +129 -0
- package/dist/i18n/messages.en.js +135 -7
- package/dist/i18n/messages.zh.js +142 -6
- package/dist/i18n/translate.d.ts +3 -0
- package/dist/i18n/translate.js +78 -10
- package/dist/i18n/zh.d.ts +1 -0
- package/dist/i18n/zh.js +1 -0
- package/dist/index.d.ts +43 -17
- package/dist/index.js +30 -12
- package/dist/interactiveHalt.js +2 -1
- package/dist/interactiveInterrupt.js +20 -2
- package/dist/liveModelCatalog.js +2 -2
- package/dist/localEngineSeatReading.d.ts +2 -2
- package/dist/localEngineSeatReading.js +5 -3
- package/dist/localEngineSpawn.d.ts +0 -7
- package/dist/localEngineSpawn.js +0 -92
- package/dist/localEngineStep.d.ts +2 -2
- package/dist/localEngineStep.js +2 -0
- package/dist/mcpReconnect.js +3 -3
- package/dist/mcpWireCaps.js +1 -1
- package/dist/model/engineModelWords.d.ts +3 -0
- package/dist/model/engineModelWords.js +13 -0
- package/dist/model/subagentModelWord.d.ts +21 -2
- package/dist/model/subagentModelWord.js +100 -29
- package/dist/modelCapabilityProbe.js +3 -40
- package/dist/notifications.d.ts +19 -0
- package/dist/notifications.js +114 -12
- package/dist/ownKey.d.ts +6 -0
- package/dist/ownKey.js +31 -0
- package/dist/pendingUserRow.d.ts +4 -0
- package/dist/pendingUserRow.js +16 -0
- package/dist/permissionsDeclaration.d.ts +1 -0
- package/dist/permissionsDeclaration.js +11 -1
- package/dist/planReviewCardFacts.d.ts +3 -0
- package/dist/planReviewCardFacts.js +52 -2
- package/dist/pluginHooksWire.d.ts +9 -1
- package/dist/pluginHooksWire.js +40 -6
- package/dist/printToolResultFrame.js +4 -2
- package/dist/promptBlockedCopy.js +11 -6
- package/dist/promptSuggestionBatch.d.ts +7 -0
- package/dist/promptSuggestionBatch.js +9 -0
- package/dist/promptSuggestionsTail.d.ts +39 -0
- package/dist/promptSuggestionsTail.js +116 -0
- package/dist/request/taskRequest.js +10 -6
- package/dist/requestCoordinate.d.ts +1 -0
- package/dist/requestCoordinate.js +13 -0
- package/dist/rewindArchiveReading.js +4 -4
- package/dist/runCancelContext.d.ts +2 -1
- package/dist/runCancelContext.js +1 -0
- package/dist/runPermissionModeSwitch.js +2 -2
- package/dist/scenarioRefusal.js +11 -13
- package/dist/scenarioSkills.js +11 -6
- package/dist/seam.d.ts +16 -2
- package/dist/seam.js +10 -0
- package/dist/seatContract.d.ts +109 -9
- package/dist/seatContract.js +218 -15
- package/dist/sessionCostReading.d.ts +70 -0
- package/dist/sessionCostReading.js +150 -0
- package/dist/sessionHooksRoster.d.ts +4 -0
- package/dist/sessionHooksRoster.js +158 -0
- package/dist/sessionMemoryStatus.js +2 -2
- package/dist/sessionReadRedaction.d.ts +7 -0
- package/dist/sessionReadRedaction.js +26 -0
- package/dist/sessionSyncFileHistory.js +8 -9
- package/dist/settingsHooksSalvage.js +2 -1
- package/dist/sseIdleTriage.js +2 -1
- package/dist/storeDurabilityWord.d.ts +15 -0
- package/dist/storeDurabilityWord.js +18 -0
- package/dist/storePostureCapability.d.ts +7 -3
- package/dist/storePostureCapability.js +69 -39
- package/dist/subagent/engineSubagentResume.js +2 -2
- package/dist/subagent/engineSubagentTail.js +2 -1
- package/dist/subagentContentStore.d.ts +11 -0
- package/dist/subagentContentStore.js +28 -2
- package/dist/toolResult.d.ts +1 -0
- package/dist/toolResult.js +2 -0
- package/dist/userAttachmentEnvelope.d.ts +2 -1
- package/dist/userAttachmentEnvelope.js +10 -0
- package/dist/wireErrorTriage.js +2 -1
- package/dist/wireFailureShape.d.ts +4 -0
- package/dist/wireFailureShape.js +141 -19
- package/dist/wireRefusalCopy.d.ts +6 -5
- package/dist/wireRefusalCopy.js +49 -92
- package/docs/INTEGRATION-CLIENTS.md +2118 -17
- package/package.json +6 -2
|
@@ -4,7 +4,10 @@ import { PROMPT_BLOCKED_BY_HOOK_ROW_LEAD } from './rowKind.js';
|
|
|
4
4
|
export { PROMPT_BLOCKED_BY_HOOK_ROW_LEAD };
|
|
5
5
|
const RUN_BLOCKED_REASONED = 'Run blocked';
|
|
6
6
|
const RUN_BLOCKED_NO_REASON = 'Run blocked (the agent reported it cannot proceed)';
|
|
7
|
-
const
|
|
7
|
+
const WORDS_SHOWN_MAX = 1000;
|
|
8
|
+
function shownWords(words) {
|
|
9
|
+
return displayUntrusted(words, { max: WORDS_SHOWN_MAX }).trim();
|
|
10
|
+
}
|
|
8
11
|
const CAUSE_CLAUSE = Object.freeze({
|
|
9
12
|
crashed: 'the hook failed before it answered; the prompt was not submitted',
|
|
10
13
|
timeout: 'the hook did not answer in time; the prompt was not submitted',
|
|
@@ -13,7 +16,7 @@ const CAUSE_CLAUSE = Object.freeze({
|
|
|
13
16
|
function shownHookWords(words) {
|
|
14
17
|
if (words === undefined)
|
|
15
18
|
return undefined;
|
|
16
|
-
const shown = stripSystemReminderTagTokens(
|
|
19
|
+
const shown = stripSystemReminderTagTokens(shownWords(stripSystemReminderTagTokens(words))).trim();
|
|
17
20
|
return shown === '' ? undefined : shown;
|
|
18
21
|
}
|
|
19
22
|
export function runBlockedText(blocked) {
|
|
@@ -29,8 +32,10 @@ export function runBlockedText(blocked) {
|
|
|
29
32
|
if (reason === undefined)
|
|
30
33
|
return RUN_BLOCKED_NO_REASON;
|
|
31
34
|
const unwrapped = unwrapSystemReminder(reason);
|
|
32
|
-
if (unwrapped === reason)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
if (unwrapped === reason) {
|
|
36
|
+
const shown = shownWords(reason);
|
|
37
|
+
return shown === '' ? RUN_BLOCKED_NO_REASON : `${RUN_BLOCKED_REASONED}: ${shown}`;
|
|
38
|
+
}
|
|
39
|
+
const body = shownHookWords(unwrapped);
|
|
40
|
+
return body === undefined ? RUN_BLOCKED_NO_REASON : `${RUN_BLOCKED_REASONED}: ${body}`;
|
|
36
41
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const SUGGESTION_BATCH_CAP = 8;
|
|
2
|
+
export declare const SUGGESTION_CHARS_CAP = 200;
|
|
3
|
+
export interface PromptSuggestionBatch {
|
|
4
|
+
readonly list: readonly string[];
|
|
5
|
+
readonly truncatedCount?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function promptSuggestionBatchOf(raw: {} | null | undefined): PromptSuggestionBatch | undefined;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const SUGGESTION_BATCH_CAP = 8;
|
|
2
|
+
export const SUGGESTION_CHARS_CAP = 200;
|
|
3
|
+
export function promptSuggestionBatchOf(raw) {
|
|
4
|
+
const filtered = (Array.isArray(raw) ? raw : []).filter((s) => typeof s === 'string' && s.trim().length > 0);
|
|
5
|
+
const list = filtered.slice(0, SUGGESTION_BATCH_CAP).map((s) => (s.length > SUGGESTION_CHARS_CAP ? `${s.slice(0, SUGGESTION_CHARS_CAP)}…` : s));
|
|
6
|
+
if (list.length === 0)
|
|
7
|
+
return undefined;
|
|
8
|
+
return { list, ...(filtered.length > list.length ? { truncatedCount: filtered.length - list.length } : {}) };
|
|
9
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { AgentClient } from '@sema-agent/sdk';
|
|
2
|
+
import type { LaneProof } from './seam.js';
|
|
3
|
+
export declare const PROMPT_SUGGESTIONS_TAIL_MAX_ATTEMPTS = 6;
|
|
4
|
+
export declare const PROMPT_SUGGESTIONS_TAIL_BUDGET_MS = 12000;
|
|
5
|
+
export interface PromptSuggestionsTailEvent {
|
|
6
|
+
readonly kind: 'prompt_suggestions';
|
|
7
|
+
readonly laneProof: LaneProof;
|
|
8
|
+
readonly suggestions: readonly string[];
|
|
9
|
+
}
|
|
10
|
+
export type PromptSuggestionsStreamSeen = 'frame' | 'done' | 'cut';
|
|
11
|
+
export interface PromptSuggestionsTailInput {
|
|
12
|
+
readonly runs: Pick<AgentClient['runs'], 'get'>;
|
|
13
|
+
readonly runId: string;
|
|
14
|
+
readonly sessionId?: string | undefined;
|
|
15
|
+
readonly requested: boolean;
|
|
16
|
+
readonly stream: PromptSuggestionsStreamSeen;
|
|
17
|
+
readonly baseUrl: string | undefined;
|
|
18
|
+
readonly signal?: AbortSignal | undefined;
|
|
19
|
+
readonly sleep?: ((ms: number) => Promise<void>) | undefined;
|
|
20
|
+
readonly now?: (() => number) | undefined;
|
|
21
|
+
}
|
|
22
|
+
export type PromptSuggestionsTailOutcome = {
|
|
23
|
+
readonly kind: 'skipped';
|
|
24
|
+
readonly why: 'not_requested' | 'frame_on_stream' | 'settled_on_stream';
|
|
25
|
+
} | {
|
|
26
|
+
readonly kind: 'settled';
|
|
27
|
+
readonly event?: PromptSuggestionsTailEvent;
|
|
28
|
+
} | {
|
|
29
|
+
readonly kind: 'not_completed';
|
|
30
|
+
readonly attempts: number;
|
|
31
|
+
} | {
|
|
32
|
+
readonly kind: 'gave_up';
|
|
33
|
+
readonly attempts: number;
|
|
34
|
+
} | {
|
|
35
|
+
readonly kind: 'unavailable';
|
|
36
|
+
readonly attempts: number;
|
|
37
|
+
};
|
|
38
|
+
export declare function promptSuggestionsOnStream(baseUrl: string | undefined): boolean;
|
|
39
|
+
export declare function followUpPromptSuggestions(input: PromptSuggestionsTailInput): Promise<PromptSuggestionsTailOutcome>;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { abortableSleep, requestDeadline } from './abortableSleep.js';
|
|
2
|
+
import { engineCapString, engineCapValue } from './engineCapsCache.js';
|
|
3
|
+
import { readOwnDataValue } from './ownKey.js';
|
|
4
|
+
import { promptSuggestionBatchOf } from './promptSuggestionBatch.js';
|
|
5
|
+
import { engineVersionTier } from './supportFloor.js';
|
|
6
|
+
export const PROMPT_SUGGESTIONS_TAIL_MAX_ATTEMPTS = 6;
|
|
7
|
+
export const PROMPT_SUGGESTIONS_TAIL_BUDGET_MS = 12_000;
|
|
8
|
+
const RETRY_STEP_MS = 750;
|
|
9
|
+
const RETRY_CAP_MS = 3_000;
|
|
10
|
+
const ON_STREAM_SERVER_FLOOR = '7.149.0';
|
|
11
|
+
const MAY_STILL_SUGGEST = Object.freeze(['completed', 'running']);
|
|
12
|
+
export function promptSuggestionsOnStream(baseUrl) {
|
|
13
|
+
try {
|
|
14
|
+
const bit = engineCapValue(baseUrl, 'promptSuggestions');
|
|
15
|
+
if (bit.kind !== 'value' || bit.value !== true)
|
|
16
|
+
return false;
|
|
17
|
+
return engineVersionTier(engineCapString(baseUrl, 'version'), ON_STREAM_SERVER_FLOOR) === 'engine';
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const freeze = (o) => Object.freeze(o);
|
|
24
|
+
const own = (o, key) => {
|
|
25
|
+
try {
|
|
26
|
+
return typeof o === 'object' && o !== null ? readOwnDataValue(o, key) : undefined;
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
function eventOf(raw) {
|
|
33
|
+
const batch = promptSuggestionBatchOf(raw);
|
|
34
|
+
return batch === undefined ? undefined : freeze({ kind: 'prompt_suggestions', laneProof: freeze({ lane: 'main' }), suggestions: freeze([...batch.list]) });
|
|
35
|
+
}
|
|
36
|
+
function skipWhy(input) {
|
|
37
|
+
if (own(input, 'requested') !== true)
|
|
38
|
+
return 'not_requested';
|
|
39
|
+
const seen = own(input, 'stream');
|
|
40
|
+
if (seen === 'frame')
|
|
41
|
+
return 'frame_on_stream';
|
|
42
|
+
if (seen === 'done' && promptSuggestionsOnStream(own(input, 'baseUrl')))
|
|
43
|
+
return 'settled_on_stream';
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
export async function followUpPromptSuggestions(input) {
|
|
47
|
+
let attempts = 0;
|
|
48
|
+
try {
|
|
49
|
+
const why = skipWhy(input);
|
|
50
|
+
if (why !== undefined)
|
|
51
|
+
return freeze({ kind: 'skipped', why });
|
|
52
|
+
const runs = own(input, 'runs');
|
|
53
|
+
const runId = own(input, 'runId');
|
|
54
|
+
const get = typeof runs === 'object' && runs !== null ? runs.get : undefined;
|
|
55
|
+
if (typeof get !== 'function' || typeof runId !== 'string' || runId.length === 0)
|
|
56
|
+
return freeze({ kind: 'unavailable', attempts });
|
|
57
|
+
const sessionId = own(input, 'sessionId');
|
|
58
|
+
const signal = own(input, 'signal');
|
|
59
|
+
const sleepIn = own(input, 'sleep');
|
|
60
|
+
const nowIn = own(input, 'now');
|
|
61
|
+
const sleep = typeof sleepIn === 'function' ? sleepIn : (ms) => abortableSleep(ms, signal ?? new AbortController().signal);
|
|
62
|
+
const now = typeof nowIn === 'function' ? nowIn : Date.now;
|
|
63
|
+
const signalState = () => {
|
|
64
|
+
if (signal === undefined || signal === null)
|
|
65
|
+
return 'live';
|
|
66
|
+
try {
|
|
67
|
+
return signal.aborted === true ? 'aborted' : 'live';
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return 'unreadable';
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const t0 = now();
|
|
74
|
+
for (;;) {
|
|
75
|
+
if (signalState() !== 'live')
|
|
76
|
+
return freeze({ kind: 'unavailable', attempts });
|
|
77
|
+
const left = PROMPT_SUGGESTIONS_TAIL_BUDGET_MS - (now() - t0);
|
|
78
|
+
if (!(left > 0))
|
|
79
|
+
return freeze({ kind: 'gave_up', attempts });
|
|
80
|
+
attempts++;
|
|
81
|
+
const d = requestDeadline(left, signal);
|
|
82
|
+
let rec;
|
|
83
|
+
try {
|
|
84
|
+
rec = await d.race(Promise.resolve(get.call(runs, runId, {
|
|
85
|
+
...(typeof sessionId === 'string' && sessionId.length > 0 ? { session: sessionId } : {}),
|
|
86
|
+
signal: d.signal,
|
|
87
|
+
})));
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return freeze({ kind: d.expired() ? 'gave_up' : 'unavailable', attempts });
|
|
91
|
+
}
|
|
92
|
+
finally {
|
|
93
|
+
d.abort();
|
|
94
|
+
}
|
|
95
|
+
const suggestions = own(rec, 'suggestions');
|
|
96
|
+
if (Array.isArray(suggestions)) {
|
|
97
|
+
const event = eventOf(suggestions);
|
|
98
|
+
return freeze({ kind: 'settled', ...(event !== undefined ? { event } : {}) });
|
|
99
|
+
}
|
|
100
|
+
const status = own(rec, 'status');
|
|
101
|
+
if (typeof status === 'string' && !MAY_STILL_SUGGEST.includes(status))
|
|
102
|
+
return freeze({ kind: 'not_completed', attempts });
|
|
103
|
+
if (attempts >= PROMPT_SUGGESTIONS_TAIL_MAX_ATTEMPTS)
|
|
104
|
+
return freeze({ kind: 'gave_up', attempts });
|
|
105
|
+
const rest = PROMPT_SUGGESTIONS_TAIL_BUDGET_MS - (now() - t0);
|
|
106
|
+
if (!(rest > 0))
|
|
107
|
+
return freeze({ kind: 'gave_up', attempts });
|
|
108
|
+
if (signalState() !== 'live')
|
|
109
|
+
return freeze({ kind: 'unavailable', attempts });
|
|
110
|
+
await sleep(Math.min(RETRY_STEP_MS * attempts, RETRY_CAP_MS, rest));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
return freeze({ kind: 'unavailable', attempts });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -548,8 +548,12 @@ export function refilterHostSettings(request, fresh, lane) {
|
|
|
548
548
|
}
|
|
549
549
|
}
|
|
550
550
|
}
|
|
551
|
-
|
|
552
|
-
|
|
551
|
+
const nowEnv = intake.carried.env;
|
|
552
|
+
const envUnwired = intake.dispositions['settings.env'] === 'unwired';
|
|
553
|
+
const envMaybeAdded = nowEnv !== undefined && !envUnwired && hostRefuseRowSeated('settings.env', lane, true);
|
|
554
|
+
const hasSentEnv = Object.hasOwn(nextSettings, 'env');
|
|
555
|
+
if (hasSentEnv || envMaybeAdded) {
|
|
556
|
+
const sentEnv = hasSentEnv ? nextSettings.env : {};
|
|
553
557
|
if (!isPlainRecord(sentEnv))
|
|
554
558
|
return unjudged();
|
|
555
559
|
let names;
|
|
@@ -559,14 +563,14 @@ export function refilterHostSettings(request, fresh, lane) {
|
|
|
559
563
|
catch {
|
|
560
564
|
return unjudged();
|
|
561
565
|
}
|
|
562
|
-
const nowEnv = intake.carried.env;
|
|
563
|
-
const envUnwired = intake.dispositions['settings.env'] === 'unwired';
|
|
564
566
|
const sentKeys = Object.keys(sentEnv);
|
|
565
567
|
const kept = sentKeys.filter((k) => names.includes(k) && (envUnwired || (nowEnv !== undefined && Object.hasOwn(nowEnv, k))));
|
|
566
|
-
|
|
568
|
+
const added = envMaybeAdded && nowEnv !== undefined ? names.filter((n) => !sentKeys.includes(n) && Object.hasOwn(nowEnv, n)) : [];
|
|
569
|
+
if (kept.length !== sentKeys.length || added.length > 0) {
|
|
567
570
|
const { env: _sentEnv, ...restSettings } = nextSettings;
|
|
568
571
|
void _sentEnv;
|
|
569
|
-
|
|
572
|
+
const rows = [...kept.map((k) => [k, sentEnv[k]]), ...added.map((n) => [n, nowEnv?.[n]])];
|
|
573
|
+
nextSettings = rows.length === 0 ? restSettings : { ...restSettings, env: Object.fromEntries(rows) };
|
|
570
574
|
}
|
|
571
575
|
}
|
|
572
576
|
if (nextSettings === settings)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function requestCoordinateText(root: string, segs: readonly (string | number)[], label?: (seg: string) => string): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const PLAIN_SEGMENT = /^[^.[\]"\s\p{Cc}]+$/u;
|
|
2
|
+
export function requestCoordinateText(root, segs, label) {
|
|
3
|
+
let out = root;
|
|
4
|
+
for (const seg of segs) {
|
|
5
|
+
if (typeof seg === 'number') {
|
|
6
|
+
out += `[${seg}]`;
|
|
7
|
+
continue;
|
|
8
|
+
}
|
|
9
|
+
const shown = label === undefined ? seg : label(seg);
|
|
10
|
+
out += PLAIN_SEGMENT.test(shown) ? `.${shown}` : `[${JSON.stringify(shown)}]`;
|
|
11
|
+
}
|
|
12
|
+
return out;
|
|
13
|
+
}
|
|
@@ -2,9 +2,8 @@ import { createEngineCapReader } from './engineCapReader.js';
|
|
|
2
2
|
import { ownDataField } from './ownKey.js';
|
|
3
3
|
const CAPS_KEYS = {
|
|
4
4
|
conversationAnchor: 'resumeAt',
|
|
5
|
-
|
|
5
|
+
restoreFiles: 'restoreFiles',
|
|
6
6
|
codeOnly: 'rewindFilesTo',
|
|
7
|
-
restoreFilesEpoch: 'restoreFiles',
|
|
8
7
|
};
|
|
9
8
|
const _capsKeyPin = true;
|
|
10
9
|
void _capsKeyPin;
|
|
@@ -22,12 +21,13 @@ export function projectRewindArchiveCapability(caps) {
|
|
|
22
21
|
try {
|
|
23
22
|
if (caps === null || typeof caps !== 'object' || Array.isArray(caps))
|
|
24
23
|
return undefined;
|
|
24
|
+
const restoreFiles = bitOf(caps, CAPS_KEYS.restoreFiles);
|
|
25
25
|
return {
|
|
26
26
|
kind: 'present',
|
|
27
27
|
conversationAnchor: bitOf(caps, CAPS_KEYS.conversationAnchor),
|
|
28
|
-
forkRestore:
|
|
28
|
+
forkRestore: restoreFiles,
|
|
29
29
|
codeOnly: bitOf(caps, CAPS_KEYS.codeOnly),
|
|
30
|
-
restoreFilesEpoch:
|
|
30
|
+
restoreFilesEpoch: restoreFiles,
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
catch {
|
|
@@ -31,9 +31,10 @@ export type RunAbortCause = {
|
|
|
31
31
|
export declare const RUN_CANCELLED_CODE: "cancelled";
|
|
32
32
|
export declare function classifyRunAbortCause(record: unknown): RunAbortCause;
|
|
33
33
|
export type { AbortCause };
|
|
34
|
+
export type AbortCauseWord = AbortCause | 'stall_verdict';
|
|
34
35
|
export type AbortCauseReading = {
|
|
35
36
|
readonly kind: 'known';
|
|
36
|
-
readonly cause:
|
|
37
|
+
readonly cause: AbortCauseWord;
|
|
37
38
|
} | {
|
|
38
39
|
readonly kind: 'unrecognized';
|
|
39
40
|
readonly word: string;
|
package/dist/runCancelContext.js
CHANGED
|
@@ -100,6 +100,7 @@ const ABORT_CAUSE_SENTENCES = Object.freeze({
|
|
|
100
100
|
ask_park_grace_exhausted: 'Aborted: the connection dropped while a question or approval was pending, and the run could not be parked for later resumption in time ' +
|
|
101
101
|
'(cause ask_park_grace_exhausted) — not an engine error.',
|
|
102
102
|
cancel_verb: 'Cancelled: a cancel request to the engine stopped this run (cause cancel_verb) — not an engine error.',
|
|
103
|
+
stall_verdict: 'Aborted: the server had already marked this run as stalled (its heartbeat lapsed), so this leg stopped itself (cause stall_verdict) — not an engine error.',
|
|
103
104
|
});
|
|
104
105
|
const ABORT_CAUSE_UNRECOGNIZED_SENTENCE = 'Aborted by the engine for a reason this client does not recognize — not an engine error.';
|
|
105
106
|
function secondsText(ms) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { atMostOnceVerdictOf } from './atMostOnce.js';
|
|
2
2
|
import { readPermissionModeReceiptSegment } from './adapter/downstream/wiringManifestView.js';
|
|
3
3
|
import { displayUntrusted } from './displayUntrusted.js';
|
|
4
|
+
import { STEERING_NOT_RUNNING } from './engineErrorCodes.js';
|
|
4
5
|
import { SDK_PERMISSION_MODE_ADMISSION_FOLDS, SDK_PERMISSION_MODE_PERSIST_MISSES } from './generated/sdkFactTables.js';
|
|
5
6
|
import { msg, renderMessage } from './i18n/translate.js';
|
|
6
7
|
import { ownDataField, readOwnDataValue } from './ownKey.js';
|
|
@@ -8,7 +9,6 @@ import { permissionModeWriteAvailable } from './permissionModeWriteCapability.js
|
|
|
8
9
|
import { permissionModeTitle } from './permissionWireCaps.js';
|
|
9
10
|
import { isDisplayableWireCode } from './wireFailureShape.js';
|
|
10
11
|
export const PERMISSION_MODE_SWITCH_RESULT_KEYS = Object.freeze(['taskId', 'sessionId', 'status', 'permissionMode', 'admission', 'persisted', 'persistMiss']);
|
|
11
|
-
const NOT_RUNNING_CODE = 'steering.not_running';
|
|
12
12
|
const PRE_SWITCH_CORRUPT_CODE = 'corrupt';
|
|
13
13
|
function guardedSlot(o, key) {
|
|
14
14
|
if (o === null || (typeof o !== 'object' && typeof o !== 'function'))
|
|
@@ -79,7 +79,7 @@ function failureOutcomeOf(e) {
|
|
|
79
79
|
if (v.delivery === 'rejected' && v.status !== undefined) {
|
|
80
80
|
if (v.status === 404)
|
|
81
81
|
return Object.freeze({ kind: 'not-found' });
|
|
82
|
-
if (v.status === 409 && v.code ===
|
|
82
|
+
if (v.status === 409 && v.code === STEERING_NOT_RUNNING)
|
|
83
83
|
return Object.freeze({ kind: 'not-running' });
|
|
84
84
|
return Object.freeze({ kind: 'refused', status: v.status, ...(v.code !== undefined ? { errorCode: v.code } : {}) });
|
|
85
85
|
}
|
package/dist/scenarioRefusal.js
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
import { capForDisplay } from './fleetTaskDesc.js';
|
|
2
2
|
import { readOwnDataValue } from './ownKey.js';
|
|
3
3
|
import { SCENARIO_ASSIGNMENT_UNKNOWN_ERROR_CODE } from './engineErrorCodes.js';
|
|
4
|
-
import {
|
|
4
|
+
import { liftLegacyRefusalFacts, readErrorString } from './wireFailureShape.js';
|
|
5
5
|
import { effectiveWireErrorCode } from './wireErrorTriage.js';
|
|
6
6
|
import { msg, renderMessage } from './i18n/translate.js';
|
|
7
7
|
const SCENARIO_REFUSAL_ERROR_MAX = 200;
|
|
8
|
-
function
|
|
9
|
-
if (detail === undefined)
|
|
10
|
-
return {};
|
|
8
|
+
function scenarioBits(read) {
|
|
11
9
|
let scenario;
|
|
12
10
|
let source;
|
|
13
11
|
try {
|
|
14
|
-
scenario =
|
|
12
|
+
scenario = read('scenario');
|
|
15
13
|
}
|
|
16
14
|
catch {
|
|
17
15
|
scenario = undefined;
|
|
18
16
|
}
|
|
19
17
|
try {
|
|
20
|
-
source =
|
|
18
|
+
source = read('source');
|
|
21
19
|
}
|
|
22
20
|
catch {
|
|
23
21
|
source = undefined;
|
|
@@ -42,20 +40,20 @@ export function scenarioRefusalOf(body) {
|
|
|
42
40
|
try {
|
|
43
41
|
if (!isPlainRecord(raw))
|
|
44
42
|
return Object.freeze({});
|
|
45
|
-
const
|
|
43
|
+
const ownOf = (o) => (key) => {
|
|
46
44
|
try {
|
|
47
|
-
return readOwnDataValue(
|
|
45
|
+
return readOwnDataValue(o, key);
|
|
48
46
|
}
|
|
49
47
|
catch {
|
|
50
48
|
return undefined;
|
|
51
49
|
}
|
|
52
50
|
};
|
|
53
|
-
const errorCode =
|
|
54
|
-
const error =
|
|
55
|
-
const
|
|
51
|
+
const errorCode = ownOf(raw)('errorCode');
|
|
52
|
+
const error = ownOf(raw)('error');
|
|
53
|
+
const facts = liftLegacyRefusalFacts(SCENARIO_ASSIGNMENT_UNKNOWN_ERROR_CODE, raw);
|
|
56
54
|
let bits = {};
|
|
57
55
|
try {
|
|
58
|
-
bits =
|
|
56
|
+
bits = scenarioBits(ownOf(facts));
|
|
59
57
|
}
|
|
60
58
|
catch {
|
|
61
59
|
bits = {};
|
|
@@ -80,7 +78,7 @@ export function scenarioRefusalFromError(err) {
|
|
|
80
78
|
return Object.freeze({
|
|
81
79
|
errorCode: SCENARIO_ASSIGNMENT_UNKNOWN_ERROR_CODE,
|
|
82
80
|
...(error !== undefined && error.length > 0 ? { error: capForDisplay(error, SCENARIO_REFUSAL_ERROR_MAX) } : {}),
|
|
83
|
-
...
|
|
81
|
+
...scenarioBits((key) => readErrorString(err, key)),
|
|
84
82
|
});
|
|
85
83
|
}
|
|
86
84
|
catch {
|
package/dist/scenarioSkills.js
CHANGED
|
@@ -49,24 +49,29 @@ export function scenarioSkillsOf(card) {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
const SCENARIO_SKILLS_CAPABILITY_KEY = 'scenarioSkills';
|
|
52
|
+
const CAP_CONFIRMED = Object.freeze({ kind: 'confirmed' });
|
|
53
|
+
const CAP_ABSENT = Object.freeze({ kind: 'absent' });
|
|
54
|
+
const CAP_DECLINED = Object.freeze({ kind: 'declined' });
|
|
55
|
+
const CAP_UNREADABLE = Object.freeze({ kind: 'unreadable' });
|
|
56
|
+
const CAP_UNOBSERVED = Object.freeze({ kind: 'unobserved' });
|
|
52
57
|
export function observedScenarioSkillsCapability(baseUrl) {
|
|
53
58
|
try {
|
|
54
59
|
const base = baseUrl === undefined ? engineWireTargetBaseUrl() : baseUrl;
|
|
55
60
|
const slot = engineCapValue(typeof base === 'string' ? base : undefined, SCENARIO_SKILLS_CAPABILITY_KEY);
|
|
56
61
|
switch (slot.kind) {
|
|
57
62
|
case 'unobserved':
|
|
58
|
-
return
|
|
63
|
+
return CAP_UNOBSERVED;
|
|
59
64
|
case 'not_reported':
|
|
60
|
-
return
|
|
65
|
+
return CAP_ABSENT;
|
|
61
66
|
case 'unreadable':
|
|
62
|
-
return
|
|
67
|
+
return CAP_UNREADABLE;
|
|
63
68
|
case 'null':
|
|
64
|
-
return
|
|
69
|
+
return CAP_DECLINED;
|
|
65
70
|
case 'value':
|
|
66
|
-
return slot.value === true ?
|
|
71
|
+
return slot.value === true ? CAP_CONFIRMED : CAP_DECLINED;
|
|
67
72
|
}
|
|
68
73
|
}
|
|
69
74
|
catch {
|
|
70
|
-
return
|
|
75
|
+
return CAP_UNOBSERVED;
|
|
71
76
|
}
|
|
72
77
|
}
|
package/dist/seam.d.ts
CHANGED
|
@@ -10,7 +10,8 @@ import type { ToolKillCause } from './toolResult.js';
|
|
|
10
10
|
import type { HumanInputAttachmentView } from './ownKey.js';
|
|
11
11
|
import type { SubagentAliasScope } from './subagentContentStore.js';
|
|
12
12
|
import type { SessionBoxNoticeFacts } from './peerFrames.js';
|
|
13
|
-
import type {
|
|
13
|
+
import type { HostSettingNotice } from './hostTurnSettings.js';
|
|
14
|
+
import type { ResupplyTruncatedSource, TaskNotificationFields } from './notifications.js';
|
|
14
15
|
export interface AbortSignalLike {
|
|
15
16
|
readonly aborted: boolean;
|
|
16
17
|
}
|
|
@@ -167,7 +168,7 @@ export type ChromeEvent = {
|
|
|
167
168
|
} | ({
|
|
168
169
|
kind: 'run_cost_reconciled';
|
|
169
170
|
laneProof: LaneProof;
|
|
170
|
-
} & RunCostReconcile) | HumanInputChromeEvent | MessageCommittedChromeEvent | EngineNoticeChromeEvent | TextSegmentEndChromeEvent | ThinkingSegmentEndChromeEvent | ToolDisclosureChromeEvent | ToolProgressChromeEvent | ToolRosterDeltaChromeEvent | ContextUsageChromeEvent | CompactionOutcomeChromeEvent | CompactionStartedChromeEvent | SubagentStartedChromeEvent | PromptAssembledChromeEvent | MemorySavedChromeEvent | WiringManifestChromeEvent | ResultTextDivergedChromeEvent | ResultReplayedChromeEvent | ToolParkedChromeEvent | SubagentAliasChromeEvent | SessionBoxNoticeChromeEvent | ApprovalRequestChromeEvent | ApprovalRevokeChromeEvent | ApprovalCompleteChromeEvent | SessionTitledChromeEvent | {
|
|
171
|
+
} & RunCostReconcile) | HumanInputChromeEvent | MessageCommittedChromeEvent | EngineNoticeChromeEvent | TextSegmentEndChromeEvent | ThinkingSegmentEndChromeEvent | ToolDisclosureChromeEvent | ToolProgressChromeEvent | ToolRosterDeltaChromeEvent | ContextUsageChromeEvent | CompactionOutcomeChromeEvent | CompactionStartedChromeEvent | SubagentStartedChromeEvent | PromptAssembledChromeEvent | MemorySavedChromeEvent | WiringManifestChromeEvent | ResultTextDivergedChromeEvent | ResultReplayedChromeEvent | ToolParkedChromeEvent | SubagentAliasChromeEvent | SessionBoxNoticeChromeEvent | ResupplyTruncatedChromeEvent | HostSettingNoticeChromeEvent | ApprovalRequestChromeEvent | ApprovalRevokeChromeEvent | ApprovalCompleteChromeEvent | SessionTitledChromeEvent | {
|
|
171
172
|
kind: 'suspended_reopened';
|
|
172
173
|
laneProof: LaneProof;
|
|
173
174
|
reopen: Extract<SuspendedReopenReading, {
|
|
@@ -358,6 +359,19 @@ export interface SubagentAliasChromeEvent {
|
|
|
358
359
|
seq?: number;
|
|
359
360
|
}
|
|
360
361
|
export type SessionBoxNoticeChromeEvent = SessionBoxNoticeChromeEnvelope & SessionBoxNoticeFacts;
|
|
362
|
+
export interface ResupplyTruncatedChromeEvent {
|
|
363
|
+
kind: 'resupply_truncated';
|
|
364
|
+
laneProof: LaneProof;
|
|
365
|
+
source: ResupplyTruncatedSource;
|
|
366
|
+
taskId: string;
|
|
367
|
+
bytes: number;
|
|
368
|
+
droppedKeys: readonly string[];
|
|
369
|
+
text: string;
|
|
370
|
+
}
|
|
371
|
+
export type HostSettingNoticeChromeEvent = {
|
|
372
|
+
kind: 'host_setting_notice';
|
|
373
|
+
laneProof: LaneProof;
|
|
374
|
+
} & HostSettingNotice;
|
|
361
375
|
export interface SessionBoxNoticeChromeEnvelope {
|
|
362
376
|
kind: 'session_box_notice';
|
|
363
377
|
laneProof: LaneProof;
|
package/dist/seam.js
CHANGED
|
@@ -152,6 +152,16 @@ const CHROME_ARM_TABLE = {
|
|
|
152
152
|
'渲 `text`(数据面英文)或按界面语言调 `sessionBoxNoticeSentence(本臂, lang)`;🔴 同一条通告有两个载体(转录行 + 本臂),接本臂的宿主按 `rowUuid` 把那一行摘掉、只渲一个;' +
|
|
153
153
|
'`state` 是开集机读位,别回显、别按它猜句子;typed 正体缺席时本臂整个不发(不铸状态词)。',
|
|
154
154
|
},
|
|
155
|
+
resupply_truncated: {
|
|
156
|
+
required: false,
|
|
157
|
+
duty: '可选:停驻补投帧只带了最小形的披露 —— 渲 `text`(数据面英文)或按界面语言调 `resupplyTruncatedSentence(本臂, lang)`,放在这条通知的转录行旁(task_notification)或完成通告旁(workflow_complete)。' +
|
|
158
|
+
'`droppedKeys` / `bytes` 是机读位,别拼进句子;披露位缺席(全形帧 / 老服务端)或坏形时本臂整个不发,不要自己据「摘要很短」推断截断。',
|
|
159
|
+
},
|
|
160
|
+
host_setting_notice: {
|
|
161
|
+
required: false,
|
|
162
|
+
duty: '可选:宿主自供设置项的一句通告(`hostTurnSettings()` 产物 `notices` 的一句;载荷 = `HostSettingNotice` 原样)。按 `plane` 呈现:`turn` 本回合系统行 / `session` 每会话每句一次 / ' +
|
|
163
|
+
'`diagnostic` 不渲只记;🔴 非终态:不是失败卡、不改回合状态;`key` / `cause` 缺席 = 这一句不挂某一行,不是坏形。铸口只有 `hostSettingNoticeEventsOf`,别手拼。',
|
|
164
|
+
},
|
|
155
165
|
result_text_diverged: {
|
|
156
166
|
required: false,
|
|
157
167
|
duty: '可选:终帧正文与已上屏正文**互相都不是对方前缀**时的诚实披露。🔴 处置是把这一拍的转录行**改口**' +
|