@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
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { SDKAssistantMessageError } from '@sema-agent/agent-types';
|
|
2
|
+
import { type RetryStatus, type RetryStatusArmLike, type RetryStatusNotice } from './retryStatus.js';
|
|
3
|
+
export declare const PRINT_MODEL_STATUS_SUBTYPE = "_sema_model_status";
|
|
4
|
+
export declare const PRINT_LAST_MODEL_STATUS_KEY = "_sema_last_model_status";
|
|
5
|
+
export interface PrintModelStatusCtx {
|
|
6
|
+
readonly sessionId: string;
|
|
7
|
+
readonly nowMs: number;
|
|
8
|
+
readonly mintUuid: () => string;
|
|
9
|
+
readonly model?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface PrintModelStatusPayload {
|
|
12
|
+
readonly kind: RetryStatus['kind'];
|
|
13
|
+
readonly terminal?: true;
|
|
14
|
+
readonly attempt?: number;
|
|
15
|
+
readonly max_retries?: number;
|
|
16
|
+
readonly retry_delay_ms?: number;
|
|
17
|
+
readonly error_status?: number;
|
|
18
|
+
readonly provider_condition?: string;
|
|
19
|
+
readonly err_class?: string;
|
|
20
|
+
readonly elapsed_ms?: number;
|
|
21
|
+
readonly timeout_ms?: number;
|
|
22
|
+
readonly model?: string;
|
|
23
|
+
readonly phase: RetryStatusNotice['phase'];
|
|
24
|
+
readonly recourse?: NonNullable<RetryStatusNotice['recourse']>;
|
|
25
|
+
readonly message: string;
|
|
26
|
+
}
|
|
27
|
+
export interface PrintApiRetryFrame {
|
|
28
|
+
readonly type: 'system';
|
|
29
|
+
readonly subtype: 'api_retry';
|
|
30
|
+
readonly attempt: number;
|
|
31
|
+
readonly max_retries: number;
|
|
32
|
+
readonly retry_delay_ms: number;
|
|
33
|
+
readonly error_status: number | null;
|
|
34
|
+
readonly error: SDKAssistantMessageError;
|
|
35
|
+
readonly _sema_provider_condition?: string;
|
|
36
|
+
readonly _sema_model?: string;
|
|
37
|
+
readonly _sema_message: string;
|
|
38
|
+
readonly uuid: string;
|
|
39
|
+
readonly session_id: string;
|
|
40
|
+
}
|
|
41
|
+
export interface PrintModelStatusSupersetFrame {
|
|
42
|
+
readonly type: 'system';
|
|
43
|
+
readonly subtype: typeof PRINT_MODEL_STATUS_SUBTYPE;
|
|
44
|
+
readonly _sema_model_status: PrintModelStatusPayload & {
|
|
45
|
+
readonly refresh?: true;
|
|
46
|
+
};
|
|
47
|
+
readonly uuid: string;
|
|
48
|
+
readonly session_id: string;
|
|
49
|
+
}
|
|
50
|
+
export type PrintModelStatusFrame = PrintApiRetryFrame | PrintModelStatusSupersetFrame;
|
|
51
|
+
export interface PrintModelStatusResultFields {
|
|
52
|
+
readonly _sema_last_model_status?: PrintModelStatusPayload;
|
|
53
|
+
}
|
|
54
|
+
export interface PrintLaneArmLike extends RetryStatusArmLike {
|
|
55
|
+
readonly type?: string;
|
|
56
|
+
readonly event?: RetryStatusArmLike;
|
|
57
|
+
}
|
|
58
|
+
export interface PrintModelStatusTracker {
|
|
59
|
+
take(msg: PrintLaneArmLike | null | undefined, ctx: PrintModelStatusCtx): PrintModelStatusFrame | null;
|
|
60
|
+
beginTurn(): void;
|
|
61
|
+
resultFields(nowMs: number): PrintModelStatusResultFields;
|
|
62
|
+
}
|
|
63
|
+
export declare function createPrintModelStatusTracker(): PrintModelStatusTracker;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { retryStatusFromArm, retryStatusNotice } from './retryStatus.js';
|
|
2
|
+
import { guardedRead, readOwnDataFiniteNumber, readOwnDataNonEmptyString, readOwnDataValue } from './ownKey.js';
|
|
3
|
+
export const PRINT_MODEL_STATUS_SUBTYPE = '_sema_model_status';
|
|
4
|
+
export const PRINT_LAST_MODEL_STATUS_KEY = '_sema_last_model_status';
|
|
5
|
+
function httpStatusOf(v) {
|
|
6
|
+
return typeof v === 'number' && Number.isInteger(v) && v > 0 && v <= 999 ? v : undefined;
|
|
7
|
+
}
|
|
8
|
+
function ccRetryErrorCategory(status) {
|
|
9
|
+
const code = httpStatusOf(status.errorStatus);
|
|
10
|
+
if (code === 529 || status.providerCondition === 'overloaded')
|
|
11
|
+
return 'overloaded';
|
|
12
|
+
if (code === 429)
|
|
13
|
+
return 'rate_limit';
|
|
14
|
+
if (code === 401 || code === 403)
|
|
15
|
+
return 'authentication_failed';
|
|
16
|
+
if (code !== undefined && code >= 408)
|
|
17
|
+
return 'server_error';
|
|
18
|
+
return 'unknown';
|
|
19
|
+
}
|
|
20
|
+
function modelStatusPayload(status, ctx) {
|
|
21
|
+
const code = httpStatusOf(status.errorStatus);
|
|
22
|
+
const terminal = 'terminal' in status && status.terminal === true;
|
|
23
|
+
const sane = (v) => (typeof v === 'number' && Number.isFinite(v) && v >= 0 ? v : undefined);
|
|
24
|
+
const count = (v) => (typeof v === 'number' && Number.isInteger(v) && v >= 0 ? v : undefined);
|
|
25
|
+
const retryDelayMs = status.kind !== 'waiting' && !terminal ? sane(Math.max(0, status.deadline - ctx.nowMs)) : undefined;
|
|
26
|
+
const attempt = count(status.attempt);
|
|
27
|
+
const maxRetries = count(status.maxRetries);
|
|
28
|
+
const elapsed = sane(status.elapsedMs);
|
|
29
|
+
const ceiling = sane(status.timeoutMs);
|
|
30
|
+
const model = ctx.model !== undefined && ctx.model.length > 0 ? ctx.model : undefined;
|
|
31
|
+
const notice = retryStatusNotice(status, model !== undefined ? { modelName: model } : undefined);
|
|
32
|
+
return {
|
|
33
|
+
kind: status.kind,
|
|
34
|
+
...(terminal ? { terminal: true } : {}),
|
|
35
|
+
...(attempt !== undefined ? { attempt } : {}),
|
|
36
|
+
...(maxRetries !== undefined ? { max_retries: maxRetries } : {}),
|
|
37
|
+
...(retryDelayMs !== undefined ? { retry_delay_ms: retryDelayMs } : {}),
|
|
38
|
+
...(code !== undefined ? { error_status: code } : {}),
|
|
39
|
+
...(typeof status.providerCondition === 'string' ? { provider_condition: status.providerCondition } : {}),
|
|
40
|
+
...(typeof status.errClass === 'string' ? { err_class: status.errClass } : {}),
|
|
41
|
+
...(elapsed !== undefined ? { elapsed_ms: elapsed } : {}),
|
|
42
|
+
...(ceiling !== undefined ? { timeout_ms: ceiling } : {}),
|
|
43
|
+
...(model !== undefined ? { model } : {}),
|
|
44
|
+
phase: notice.phase,
|
|
45
|
+
...(notice.recourse !== undefined ? { recourse: notice.recourse } : {}),
|
|
46
|
+
message: notice.line,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function apiRetryKeyOf(status) {
|
|
50
|
+
const terminal = 'terminal' in status && status.terminal === true;
|
|
51
|
+
const ok = (v) => typeof v === 'number' && Number.isInteger(v) && v >= 0;
|
|
52
|
+
if (status.kind === 'waiting' || terminal || !ok(status.attempt) || !ok(status.maxRetries))
|
|
53
|
+
return null;
|
|
54
|
+
return `${String(status.attempt)}/${String(status.maxRetries)}/${String(status.errClass ?? '')}/${String(status.errorStatus ?? '')}`;
|
|
55
|
+
}
|
|
56
|
+
function statusFrameOf(status, ctx, uuid, refresh) {
|
|
57
|
+
const payload = modelStatusPayload(status, ctx);
|
|
58
|
+
if (apiRetryKeyOf(status) !== null && !refresh) {
|
|
59
|
+
return {
|
|
60
|
+
type: 'system',
|
|
61
|
+
subtype: 'api_retry',
|
|
62
|
+
attempt: status.attempt ?? 0,
|
|
63
|
+
max_retries: status.maxRetries ?? 0,
|
|
64
|
+
retry_delay_ms: payload.retry_delay_ms ?? 0,
|
|
65
|
+
error_status: payload.error_status ?? null,
|
|
66
|
+
error: ccRetryErrorCategory(status),
|
|
67
|
+
...(payload.provider_condition !== undefined ? { _sema_provider_condition: payload.provider_condition } : {}),
|
|
68
|
+
...(payload.model !== undefined ? { _sema_model: payload.model } : {}),
|
|
69
|
+
_sema_message: payload.message,
|
|
70
|
+
uuid,
|
|
71
|
+
session_id: ctx.sessionId,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
return { type: 'system', subtype: PRINT_MODEL_STATUS_SUBTYPE, _sema_model_status: { ...payload, ...(refresh ? { refresh: true } : {}) }, uuid, session_id: ctx.sessionId };
|
|
75
|
+
}
|
|
76
|
+
function isMainLaneArm(msg) {
|
|
77
|
+
const tri = (o, key) => {
|
|
78
|
+
try {
|
|
79
|
+
const d = Object.getOwnPropertyDescriptor(o, key);
|
|
80
|
+
if (d !== undefined && !('value' in d))
|
|
81
|
+
return { ok: false };
|
|
82
|
+
return { ok: true, v: readOwnDataValue(o, key) };
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
return { ok: false };
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
const top = tri(msg, 'parentToolCallId');
|
|
89
|
+
if (!top.ok)
|
|
90
|
+
return false;
|
|
91
|
+
const event = tri(msg, 'event');
|
|
92
|
+
if (!event.ok)
|
|
93
|
+
return false;
|
|
94
|
+
const nested = typeof event.v === 'object' && event.v !== null ? tri(event.v, 'parentToolCallId') : { ok: true, v: undefined };
|
|
95
|
+
if (!nested.ok)
|
|
96
|
+
return false;
|
|
97
|
+
return typeof top.v !== 'string' && typeof nested.v !== 'string';
|
|
98
|
+
}
|
|
99
|
+
export function createPrintModelStatusTracker() {
|
|
100
|
+
let last = null;
|
|
101
|
+
let lastApiRetryKey = null;
|
|
102
|
+
const clear = () => {
|
|
103
|
+
last = null;
|
|
104
|
+
lastApiRetryKey = null;
|
|
105
|
+
};
|
|
106
|
+
return {
|
|
107
|
+
take(msg, ctx) {
|
|
108
|
+
try {
|
|
109
|
+
const type = guardedRead(() => readOwnDataValue(msg, 'type'));
|
|
110
|
+
if (type === 'stream_event' || type === 'tool_end_result') {
|
|
111
|
+
if (msg !== null && msg !== undefined && isMainLaneArm(msg))
|
|
112
|
+
clear();
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
if (type !== 'retry_status')
|
|
116
|
+
return null;
|
|
117
|
+
const sessionId = readOwnDataNonEmptyString(ctx, 'sessionId');
|
|
118
|
+
const mintUuid = readOwnDataValue(ctx, 'mintUuid');
|
|
119
|
+
const nowMs = readOwnDataFiniteNumber(ctx, 'nowMs');
|
|
120
|
+
if (sessionId === undefined || typeof mintUuid !== 'function' || nowMs === undefined)
|
|
121
|
+
return null;
|
|
122
|
+
const status = retryStatusFromArm(msg, nowMs);
|
|
123
|
+
if (status === undefined)
|
|
124
|
+
return null;
|
|
125
|
+
if (status === null) {
|
|
126
|
+
clear();
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
const model = readOwnDataNonEmptyString(ctx, 'model');
|
|
130
|
+
const key = apiRetryKeyOf(status);
|
|
131
|
+
const refresh = key !== null && key === lastApiRetryKey;
|
|
132
|
+
const safeCtx = { sessionId, nowMs, mintUuid, ...(model !== undefined ? { model } : {}) };
|
|
133
|
+
const frame = statusFrameOf(status, safeCtx, mintUuid(), refresh);
|
|
134
|
+
lastApiRetryKey = key;
|
|
135
|
+
last = { status, model };
|
|
136
|
+
return frame;
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
beginTurn: clear,
|
|
143
|
+
resultFields(nowMs) {
|
|
144
|
+
try {
|
|
145
|
+
if (last === null)
|
|
146
|
+
return {};
|
|
147
|
+
const now = typeof nowMs === 'number' && Number.isFinite(nowMs) ? nowMs : 0;
|
|
148
|
+
return { _sema_last_model_status: modelStatusPayload(last.status, { ...(last.model !== undefined ? { model: last.model } : {}), nowMs: now }) };
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
return {};
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { TaskRequest } from '@sema-agent/sdk';
|
|
1
|
+
import type { TaskRequest, UserAttachment } from '@sema-agent/sdk';
|
|
2
2
|
import { type OutputStyleSeatReading } from '../outputStyleSeatCapability.js';
|
|
3
3
|
import { type ApprovalReachWord } from '../approvalReachWire.js';
|
|
4
|
+
import { type HostSettingNotice, type HostTurnSettings, type HostTurnSettingsInput } from '../hostTurnSettings.js';
|
|
4
5
|
export type RequestLane = 'interactive' | 'print' | 'utility';
|
|
5
6
|
export type TaskRequestLike = Record<string, unknown>;
|
|
6
7
|
export interface RequestFieldSpec {
|
|
@@ -22,7 +23,9 @@ export interface TaskRequestInput {
|
|
|
22
23
|
reasoningEffort?: string;
|
|
23
24
|
model?: string;
|
|
24
25
|
images?: readonly unknown[];
|
|
26
|
+
userAttachments?: readonly UserAttachment[];
|
|
25
27
|
skills?: unknown;
|
|
28
|
+
userInvokedSkills?: readonly string[];
|
|
26
29
|
mcpServers?: unknown;
|
|
27
30
|
clientContext?: Record<string, unknown>;
|
|
28
31
|
scratchpadDir?: string;
|
|
@@ -51,19 +54,14 @@ export interface TaskRequestInput {
|
|
|
51
54
|
fallbackModel?: string;
|
|
52
55
|
maxThinkingTokens?: number;
|
|
53
56
|
memoryCapture?: 'off';
|
|
54
|
-
memory?: 'off';
|
|
55
|
-
fileHistory?: TaskRequest['fileHistory'];
|
|
56
57
|
inheritEnv?: InheritEnvWord;
|
|
57
58
|
requireExistingSession?: TaskRequest['requireExistingSession'];
|
|
58
59
|
disableSkills?: TaskRequest['disableSkills'];
|
|
59
60
|
rewind?: Record<string, unknown>;
|
|
60
61
|
repo?: string;
|
|
62
|
+
hostSettings: HostTurnSettings;
|
|
61
63
|
settings?: {
|
|
62
|
-
resolved?: Record<string, unknown>;
|
|
63
|
-
webSearch?: Record<string, unknown>;
|
|
64
64
|
ultracode?: boolean;
|
|
65
|
-
hooks?: Record<string, unknown>;
|
|
66
|
-
outputStyle?: string;
|
|
67
65
|
};
|
|
68
66
|
}
|
|
69
67
|
export declare const TASK_REQUEST_OMISSION_CAUSES: readonly ["upstream_absent", "other_channel", "off_lane", "not_live"];
|
|
@@ -78,6 +76,7 @@ export declare function taskRequestOmissionCauseNotice(cause: unknown): string;
|
|
|
78
76
|
export interface TaskRequestAssembly {
|
|
79
77
|
readonly request: TaskRequestLike;
|
|
80
78
|
readonly omitted: readonly TaskRequestOmission[];
|
|
79
|
+
readonly host: HostTurnSettings;
|
|
81
80
|
}
|
|
82
81
|
export type TaskRequestSeatReading = {
|
|
83
82
|
readonly seat: 'seated';
|
|
@@ -95,14 +94,21 @@ export interface UpstreamAbsentRequestIntent {
|
|
|
95
94
|
export declare const UPSTREAM_ABSENT_REQUEST_INTENTS: readonly UpstreamAbsentRequestIntent[];
|
|
96
95
|
export declare const REQUEST_LANES: readonly RequestLane[];
|
|
97
96
|
export declare function taskRequestSeatOf(key: string, lane: RequestLane): TaskRequestSeatReading;
|
|
97
|
+
export declare function hostTurnSettings(input: HostTurnSettingsInput): HostTurnSettings;
|
|
98
|
+
export type HostSettingsRefilterResult = {
|
|
99
|
+
readonly kind: 'send';
|
|
100
|
+
readonly request: TaskRequestLike;
|
|
101
|
+
readonly hooksDropped: number;
|
|
102
|
+
} | {
|
|
103
|
+
readonly kind: 'refuse';
|
|
104
|
+
readonly notice: HostSettingNotice;
|
|
105
|
+
};
|
|
106
|
+
export declare function refilterHostSettings(request: TaskRequestLike, fresh: HostTurnSettings, lane: RequestLane): HostSettingsRefilterResult;
|
|
98
107
|
export declare const MEMORY_CAPTURE_OFF: "off";
|
|
99
108
|
export declare function memoryCaptureDeclarationField(declared: boolean): {
|
|
100
109
|
memoryCapture: 'off';
|
|
101
110
|
} | Record<string, never>;
|
|
102
111
|
export declare const MEMORY_OFF: "off";
|
|
103
|
-
export declare function memoryOffDeclarationField(declared: boolean): {
|
|
104
|
-
memory: 'off';
|
|
105
|
-
} | Record<string, never>;
|
|
106
112
|
export declare const FILE_HISTORY_DISABLED: "disabled";
|
|
107
113
|
export declare const INHERIT_ENV_WORDS: readonly ["all", "scrub"];
|
|
108
114
|
export type InheritEnvWord = (typeof INHERIT_ENV_WORDS)[number];
|