@sema-agent/client-core 0.93.1 → 0.95.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 +554 -0
- package/README.md +89 -55
- package/dist/adapt/arms.js +13 -11
- package/dist/adapt/panelTasks.js +4 -10
- package/dist/adapt/toolCards.js +2 -2
- package/dist/adapt/wireShapes.js +3 -8
- package/dist/adapter/activeRunSelfHeal.d.ts +8 -3
- package/dist/adapter/activeRunSelfHeal.js +20 -12
- package/dist/adapter/downstream/eventToSdkMessage.js +24 -17
- package/dist/adapter/downstream/terminalToSdkResult.js +13 -6
- package/dist/adapter/runStream.js +2 -1
- package/dist/adapter/types.d.ts +7 -0
- package/dist/adapter/types.js +15 -0
- package/dist/agentSession/backgroundView.js +5 -1
- package/dist/agentSession/engineAgentRegistryRead.js +2 -1
- package/dist/agentSession/engineSessionBackgroundStop.js +5 -3
- package/dist/agentsWireCaps.d.ts +17 -0
- package/dist/agentsWireCaps.js +111 -1
- package/dist/approvalDecidedByCapability.d.ts +0 -1
- package/dist/approvalDecidedByCapability.js +2 -7
- package/dist/approvalReachWire.d.ts +18 -0
- package/dist/approvalReachWire.js +58 -0
- package/dist/approvalsStreamLiveCapability.d.ts +0 -1
- package/dist/approvalsStreamLiveCapability.js +15 -14
- package/dist/atMostOnce.d.ts +8 -0
- package/dist/atMostOnce.js +36 -0
- package/dist/attachmentSeatCapability.d.ts +0 -1
- package/dist/attachmentSeatCapability.js +0 -3
- package/dist/attachmentsWireCaps.js +11 -6
- package/dist/bashExitReading.d.ts +10 -0
- package/dist/bashExitReading.js +12 -0
- package/dist/callerCwdCapability.d.ts +15 -0
- package/dist/callerCwdCapability.js +42 -0
- package/dist/centerWiringCapability.d.ts +1 -3
- package/dist/centerWiringCapability.js +18 -21
- package/dist/classifierStatus.js +4 -4
- package/dist/cloudConfigWireCaps.js +43 -21
- package/dist/compensations.js +1 -1
- package/dist/controlRouter.js +3 -10
- package/dist/coreValuePorts.d.ts +64 -1
- package/dist/coreValuePorts.js +30 -0
- package/dist/cycleOrder.d.ts +15 -0
- package/dist/cycleOrder.js +45 -0
- package/dist/decideFailureNote.js +4 -1
- package/dist/decideReceipt.d.ts +2 -1
- package/dist/decideReceipt.js +41 -13
- package/dist/declared/supportFloorDeclared.d.ts +1 -0
- package/dist/declared/supportFloorDeclared.js +5 -0
- package/dist/detachWire.d.ts +1 -4
- package/dist/detachWire.js +1 -1
- package/dist/deviceExecutorManagementCapability.d.ts +0 -1
- package/dist/deviceExecutorManagementCapability.js +36 -40
- package/dist/deviceFlowPolling.d.ts +5 -0
- package/dist/deviceFlowPolling.js +28 -0
- package/dist/deviceRebind.d.ts +88 -0
- package/dist/deviceRebind.js +242 -0
- package/dist/displayUntrusted.d.ts +1 -0
- package/dist/displayUntrusted.js +963 -30
- package/dist/engineAgentAbsence.d.ts +2 -2
- package/dist/engineAgentPanelStore.d.ts +8 -18
- package/dist/engineAgentPanelStore.js +19 -537
- package/dist/engineCapReader.d.ts +6 -6
- package/dist/engineCapReader.js +30 -43
- package/dist/engineCapsCache.d.ts +7 -2
- package/dist/engineCapsCache.js +64 -26
- package/dist/engineCredentialRequirement.d.ts +9 -0
- package/dist/engineCredentialRequirement.js +23 -0
- package/dist/engineEnvSourcing.d.ts +53 -0
- package/dist/engineEnvSourcing.js +81 -0
- package/dist/engineErrorCodes.d.ts +19 -4
- package/dist/engineErrorCodes.js +39 -21
- package/dist/engineIdentity.js +2 -0
- package/dist/engineNoticeCodes.d.ts +22 -2
- package/dist/engineNoticeCodes.js +73 -6
- package/dist/engineRefusedToolName.d.ts +1 -0
- package/dist/engineRefusedToolName.js +8 -0
- package/dist/engineWireSdk.js +2 -2
- package/dist/executionLaneCapability.d.ts +2 -3
- package/dist/executionLaneCapability.js +28 -28
- package/dist/fileHistoryCaptureCapability.d.ts +0 -1
- package/dist/fileHistoryCaptureCapability.js +13 -12
- package/dist/fileHistoryLegNotice.d.ts +14 -2
- package/dist/fileHistoryLegNotice.js +101 -15
- package/dist/fleet/fleetLedger.d.ts +2 -0
- package/dist/fleet/fleetLedger.js +74 -52
- package/dist/fleet/fleetProjection.d.ts +0 -3
- package/dist/fleet/fleetProjection.js +9 -16
- package/dist/fleetAgentPanelProjection.d.ts +4 -17
- package/dist/fleetAgentPanelProjection.js +7 -197
- package/dist/fleetAgentRowLike.d.ts +16 -0
- package/dist/fleetAgentRowLike.js +1 -0
- package/dist/gateOutcome.d.ts +2 -1
- package/dist/gateOutcome.js +33 -18
- package/dist/gateVocabulary.js +1 -1
- package/dist/generated/engineAskFaceTables.d.ts +3 -0
- package/dist/generated/engineAskFaceTables.js +12 -0
- package/dist/generated/engineFactTables.d.ts +4 -2
- package/dist/generated/engineFactTables.js +13 -0
- package/dist/generated/engineNoticeTables.d.ts +5 -0
- package/dist/generated/engineNoticeTables.js +7 -0
- package/dist/generated/sdkFactTables.d.ts +5 -0
- package/dist/generated/sdkFactTables.js +34 -0
- package/dist/generated/settingsSchemaFns.d.ts +10 -0
- package/dist/generated/settingsSchemaFns.js +22 -0
- package/dist/generated/settingsSchemaTables.d.ts +3 -0
- package/dist/generated/settingsSchemaTables.js +3 -0
- package/dist/headlessPermissionModeWire.d.ts +2 -2
- package/dist/headlessPermissionModeWire.js +11 -21
- package/dist/headlessReconnectWire.js +49 -20
- package/dist/hitl/allowRuleShadow.d.ts +1 -1
- package/dist/hitl/allowRuleShadow.js +49 -8
- package/dist/hitl/approvalCompleteParked.d.ts +1 -0
- package/dist/hitl/approvalCompleteParked.js +14 -0
- package/dist/hitl/approvalEndingCause.d.ts +5 -0
- package/dist/hitl/approvalEndingCause.js +61 -0
- package/dist/hitl/approvalHolds.d.ts +46 -0
- package/dist/hitl/approvalHolds.js +140 -0
- package/dist/hitl/approvalOutcomeNote.js +2 -1
- package/dist/hitl/approvalResolution.js +9 -1
- package/dist/hitl/approvalsFeed.js +23 -6
- package/dist/hitl/askGateWire.d.ts +2 -1
- package/dist/hitl/askGateWire.js +29 -1
- package/dist/hitl/automaticAnswerVerdict.d.ts +8 -2
- package/dist/hitl/automaticAnswerVerdict.js +71 -23
- package/dist/hitl/crashConverged.js +2 -0
- package/dist/hitl/decisionConflict.d.ts +3 -0
- package/dist/hitl/decisionConflict.js +43 -0
- package/dist/hitl/decisionRefusal.d.ts +23 -0
- package/dist/hitl/decisionRefusal.js +88 -0
- package/dist/hitl/frameRouter.d.ts +10 -0
- package/dist/hitl/frameRouter.js +71 -32
- package/dist/hitl/gateLedger.d.ts +8 -0
- package/dist/hitl/gateLedger.js +38 -0
- package/dist/hitl/hitlBridge.d.ts +14 -3
- package/dist/hitl/hitlBridge.js +75 -62
- package/dist/hitl/hitlHostSurface.d.ts +3 -0
- package/dist/hitl/hitlHostSurface.js +17 -15
- package/dist/hitl/livePendingAsk.d.ts +16 -6
- package/dist/hitl/livePendingAsk.js +36 -4
- package/dist/hitl/localAllowRule.js +2 -1
- package/dist/hitl/noAllowCause.d.ts +9 -0
- package/dist/hitl/noAllowCause.js +26 -0
- package/dist/hitl/parkExpiryJudgements.d.ts +19 -0
- package/dist/hitl/parkExpiryJudgements.js +46 -0
- package/dist/hitl/parkResolver.d.ts +3 -7
- package/dist/hitl/parkResolver.js +55 -28
- package/dist/hitl/parkRowBirthWait.js +2 -1
- package/dist/hitl/persistedRulesWire.d.ts +6 -1
- package/dist/hitl/persistedRulesWire.js +16 -4
- package/dist/hitl/planReviewWire.d.ts +2 -3
- package/dist/hitl/planReviewWire.js +86 -39
- package/dist/hitl/replayedApproval.d.ts +8 -0
- package/dist/hitl/replayedApproval.js +125 -10
- package/dist/hitl/resumeRunningCard.d.ts +2 -0
- package/dist/hitl/resumeRunningCard.js +15 -4
- package/dist/hitl/sessionPolicyDeliverable.d.ts +1 -1
- package/dist/hitl/sessionPolicyDeliverable.js +3 -8
- package/dist/hitl/sessionPolicyWire.js +1 -1
- package/dist/hitl/toolApprovalWire.d.ts +50 -5
- package/dist/hitl/toolApprovalWire.js +368 -56
- package/dist/hooksWireCaps.js +38 -6
- package/dist/host.d.ts +5 -0
- package/dist/host.js +3 -1
- package/dist/hostCallbackGuard.d.ts +1 -0
- package/dist/hostCallbackGuard.js +25 -0
- package/dist/humanTurnRead.d.ts +15 -1
- package/dist/humanTurnRead.js +28 -2
- package/dist/index.d.ts +45 -14
- package/dist/index.js +33 -12
- package/dist/interactiveInterrupt.d.ts +8 -0
- package/dist/interactiveInterrupt.js +54 -0
- package/dist/limitsWire.d.ts +5 -1
- package/dist/limitsWire.js +51 -13
- package/dist/liveModelCatalog.d.ts +109 -0
- package/dist/liveModelCatalog.js +344 -18
- package/dist/mcpEngineLeg.d.ts +25 -0
- package/dist/mcpEngineLeg.js +71 -15
- package/dist/mcpPanel.js +2 -1
- package/dist/mcpProbeCapability.d.ts +0 -1
- package/dist/mcpProbeCapability.js +13 -12
- package/dist/mcpReconnect.d.ts +1 -3
- package/dist/mcpReconnect.js +20 -10
- package/dist/memoryComplianceCapability.d.ts +0 -1
- package/dist/memoryComplianceCapability.js +14 -13
- package/dist/memoryOriginCapability.d.ts +0 -1
- package/dist/memoryOriginCapability.js +14 -13
- package/dist/memoryVerbsWire.d.ts +1 -1
- package/dist/memoryVerbsWire.js +4 -0
- package/dist/model/liveCatalogShape.d.ts +14 -0
- package/dist/model/liveCatalogShape.js +71 -0
- package/dist/model/modelSupplyRules.d.ts +1 -0
- package/dist/model/modelSupplyRules.js +30 -9
- package/dist/model/modelsPolicy.d.ts +21 -0
- package/dist/model/modelsPolicy.js +90 -0
- package/dist/modelIdentityResolvability.d.ts +4 -2
- package/dist/modelIdentityResolvability.js +25 -5
- package/dist/modelSwitchFallback.d.ts +69 -0
- package/dist/modelSwitchFallback.js +206 -0
- package/dist/notifications.js +12 -11
- package/dist/outputStyleSeatCapability.d.ts +15 -0
- package/dist/outputStyleSeatCapability.js +42 -0
- package/dist/ownKey.d.ts +7 -0
- package/dist/ownKey.js +58 -0
- package/dist/panelReduce.d.ts +114 -0
- package/dist/panelReduce.js +1135 -0
- package/dist/panelStateHolder.d.ts +17 -0
- package/dist/panelStateHolder.js +201 -0
- package/dist/peerLaneCapability.d.ts +0 -1
- package/dist/peerLaneCapability.js +15 -14
- package/dist/permissionModesCapability.d.ts +0 -1
- package/dist/permissionModesCapability.js +5 -10
- package/dist/permissionRuleIssue.js +1 -1
- package/dist/permissionRulesWriteCapability.d.ts +0 -1
- package/dist/permissionRulesWriteCapability.js +15 -14
- package/dist/permissionsAllowGrantCapability.d.ts +2 -1
- package/dist/permissionsAllowGrantCapability.js +35 -19
- package/dist/permissionsDeclaration.d.ts +16 -1
- package/dist/permissionsDeclaration.js +142 -15
- package/dist/printToolResultFrame.js +2 -10
- package/dist/promptDelivery.js +0 -8
- package/dist/protocolSegment.d.ts +1 -0
- package/dist/protocolSegment.js +13 -1
- package/dist/request/taskRequest.d.ts +11 -3
- package/dist/request/taskRequest.js +13 -1
- package/dist/resultFrameKeys.d.ts +4 -0
- package/dist/resultFrameKeys.js +13 -0
- package/dist/resumeRefusalCopy.d.ts +18 -1
- package/dist/resumeRefusalCopy.js +132 -31
- package/dist/retryStatus.js +6 -4
- package/dist/rewindArchiveCapability.d.ts +2 -1
- package/dist/rewindArchiveCapability.js +28 -15
- package/dist/rewindEngineAction.d.ts +21 -0
- package/dist/rewindEngineAction.js +36 -0
- package/dist/rewindWireCaps.d.ts +2 -1
- package/dist/rewindWireCaps.js +1 -0
- package/dist/{hitl/rosterMountedNames.d.ts → rosterMountedNames.d.ts} +1 -1
- package/dist/runCancelContext.js +2 -1
- package/dist/runTerminal.d.ts +0 -11
- package/dist/runTerminal.js +4 -27
- package/dist/sdkRegistryTransit.d.ts +2 -1
- package/dist/sdkRegistryTransit.js +1 -0
- package/dist/sealedKeyCapability.d.ts +0 -1
- package/dist/sealedKeyCapability.js +19 -20
- package/dist/seatContract.d.ts +85 -28
- package/dist/seatContract.js +512 -148
- package/dist/sessionIdSegment.d.ts +1 -0
- package/dist/sessionIdSegment.js +11 -0
- package/dist/sessionMemoryErase.d.ts +1 -1
- package/dist/sessionMemoryErase.js +6 -1
- package/dist/sessionMemoryStatus.js +3 -2
- package/dist/sessionPolicyCapability.d.ts +0 -1
- package/dist/sessionPolicyCapability.js +14 -13
- package/dist/sessionReadRedactionCapability.d.ts +15 -0
- package/dist/sessionReadRedactionCapability.js +42 -0
- package/dist/sessionSyncFileHistoryCapability.d.ts +0 -1
- package/dist/sessionSyncFileHistoryCapability.js +13 -12
- package/dist/skillToolListsCapability.d.ts +0 -1
- package/dist/skillToolListsCapability.js +13 -12
- package/dist/skillsWireCaps.d.ts +4 -0
- package/dist/skillsWireCaps.js +66 -1
- package/dist/sqlEngineCapability.d.ts +0 -1
- package/dist/sqlEngineCapability.js +21 -21
- package/dist/steerPriorityCapability.d.ts +0 -1
- package/dist/steerPriorityCapability.js +18 -19
- package/dist/storePostureCapability.d.ts +1 -1
- package/dist/storePostureCapability.js +16 -16
- package/dist/streamDrainingLegs.d.ts +6 -0
- package/dist/streamDrainingLegs.js +23 -0
- package/dist/subagent/agentStateDetail.d.ts +1 -0
- package/dist/subagent/agentStateDetail.js +41 -0
- package/dist/subagent/engineCompactWire.d.ts +15 -0
- package/dist/subagent/engineCompactWire.js +82 -45
- package/dist/subagent/engineDelegatedPrompt.js +10 -6
- package/dist/subagent/engineSubagentOutput.d.ts +0 -1
- package/dist/subagent/engineSubagentOutput.js +5 -20
- package/dist/subagent/engineSubagentTail.d.ts +0 -1
- package/dist/subagent/engineSubagentTail.js +7 -32
- package/dist/subagentContentStore.js +3 -3
- package/dist/supportFloor.js +2 -5
- package/dist/taskRequestWords.d.ts +2 -4
- package/dist/taskRequestWords.js +3 -2
- package/dist/terminalStatuses.d.ts +30 -0
- package/dist/terminalStatuses.js +67 -0
- package/dist/toolResult.d.ts +5 -0
- package/dist/toolResult.js +88 -36
- package/dist/types/engineState.d.ts +2 -1
- package/dist/usageAnalytics.d.ts +146 -0
- package/dist/usageAnalytics.js +311 -0
- package/dist/userAttachmentEnvelope.d.ts +22 -1
- package/dist/userAttachmentEnvelope.js +90 -2
- package/dist/userInvokedSkillsCapability.d.ts +0 -1
- package/dist/userInvokedSkillsCapability.js +13 -12
- package/dist/webSearchBackendCapability.d.ts +0 -1
- package/dist/webSearchBackendCapability.js +20 -19
- package/dist/webSearchWireCaps.js +3 -11
- package/dist/wireErrorTriage.d.ts +11 -0
- package/dist/wireErrorTriage.js +35 -0
- package/dist/wireFailureShape.d.ts +10 -0
- package/dist/wireFailureShape.js +72 -5
- package/dist/wireRefusalCopy.d.ts +6 -1
- package/dist/wireRefusalCopy.js +23 -25
- package/dist/wiringInstructionsAttribution.d.ts +10 -0
- package/dist/wiringInstructionsAttribution.js +67 -0
- package/dist/workflowClient.js +19 -2
- package/dist/workflowsJournalCapability.d.ts +0 -1
- package/dist/workflowsJournalCapability.js +13 -12
- package/dist/writeProtectionCapability.d.ts +0 -1
- package/dist/writeProtectionCapability.js +26 -26
- package/docs/INTEGRATION-CLIENTS.md +1733 -52
- package/package.json +5 -5
- package/dist/askSurvivesStandingAnswer.d.ts +0 -13
- package/dist/askSurvivesStandingAnswer.js +0 -53
- package/dist/engineCapsGenerationGuard.d.ts +0 -4
- package/dist/engineCapsGenerationGuard.js +0 -19
- package/dist/hitl/askSurvivesPosture.d.ts +0 -20
- package/dist/hitl/askSurvivesPosture.js +0 -48
- package/dist/panelRunningHistory.d.ts +0 -22
- package/dist/panelRunningHistory.js +0 -82
- package/dist/registryConflict.d.ts +0 -3
- package/dist/registryConflict.js +0 -44
- /package/dist/{hitl/rosterMountedNames.js → rosterMountedNames.js} +0 -0
package/dist/agentsWireCaps.js
CHANGED
|
@@ -2,6 +2,10 @@ import { hostEnv } from './hostEnv.js';
|
|
|
2
2
|
import { makeEngineWireClient } from './engineWireSdk.js';
|
|
3
3
|
import { frozenSet } from './frozenSet.js';
|
|
4
4
|
import { settleWithinDeadline } from './abortableSleep.js';
|
|
5
|
+
import { isEngineRefusedToolName } from './engineRefusedToolName.js';
|
|
6
|
+
import { CORE_PROTOCOL_PREFIXES, CORE_RETIRED_TOOL_CURRENT_NAMES } from './generated/toolNameTables.js';
|
|
7
|
+
import { rosterMountedNames } from './rosterMountedNames.js';
|
|
8
|
+
import { capForDisplay } from './fleetTaskDesc.js';
|
|
5
9
|
export const MAX_TASK_AGENTS = 32;
|
|
6
10
|
export const MAX_AGENT_NAME_CHARS = 64;
|
|
7
11
|
export const MAX_AGENT_TEXT_CHARS = 4_096;
|
|
@@ -38,6 +42,82 @@ const SOURCE_RANK = {
|
|
|
38
42
|
function sourceRank(source) {
|
|
39
43
|
return SOURCE_RANK[source] ?? 5;
|
|
40
44
|
}
|
|
45
|
+
const RETIRED_TABLE_CURRENT_NAMES = frozenSet([...CORE_RETIRED_TOOL_CURRENT_NAMES.values()].filter((v) => typeof v === 'string'));
|
|
46
|
+
function unescapedIndexOf(s, ch, last) {
|
|
47
|
+
for (let k = 0; k < s.length; k++) {
|
|
48
|
+
const i = last ? s.length - 1 - k : k;
|
|
49
|
+
if (s[i] !== ch)
|
|
50
|
+
continue;
|
|
51
|
+
let backslashes = 0;
|
|
52
|
+
for (let j = i - 1; j >= 0 && s[j] === '\\'; j--)
|
|
53
|
+
backslashes++;
|
|
54
|
+
if (backslashes % 2 === 0)
|
|
55
|
+
return i;
|
|
56
|
+
}
|
|
57
|
+
return -1;
|
|
58
|
+
}
|
|
59
|
+
function deniedEntryToolName(entry) {
|
|
60
|
+
if (entry !== entry.trim())
|
|
61
|
+
return undefined;
|
|
62
|
+
const open = unescapedIndexOf(entry, '(', false);
|
|
63
|
+
if (open === -1)
|
|
64
|
+
return entry;
|
|
65
|
+
const close = unescapedIndexOf(entry, ')', true);
|
|
66
|
+
if (close === -1 || close <= open || close !== entry.length - 1)
|
|
67
|
+
return entry;
|
|
68
|
+
const name = entry.substring(0, open);
|
|
69
|
+
return name.length === 0 ? entry : name.trim();
|
|
70
|
+
}
|
|
71
|
+
function toolNameFlawOf(entry, names, list) {
|
|
72
|
+
if (typeof entry !== 'string' || entry.length === 0 || entry === '*')
|
|
73
|
+
return undefined;
|
|
74
|
+
const name = list === 'disallowedTools' ? deniedEntryToolName(entry) : entry.includes('(') ? undefined : entry;
|
|
75
|
+
if (name === undefined || name.length === 0 || name === '*' || names.has(name))
|
|
76
|
+
return undefined;
|
|
77
|
+
const named = name !== entry ? { toolName: name } : {};
|
|
78
|
+
if (isEngineRefusedToolName(name)) {
|
|
79
|
+
const current = CORE_RETIRED_TOOL_CURRENT_NAMES.get(name);
|
|
80
|
+
if (current === undefined)
|
|
81
|
+
return { kind: 'unprefixed_namespace', ...named };
|
|
82
|
+
return typeof current === 'string' ? { kind: 'retired', currentName: current, ...named } : { kind: 'retired', ...named };
|
|
83
|
+
}
|
|
84
|
+
if (CORE_PROTOCOL_PREFIXES.some((prefix) => name.startsWith(prefix)))
|
|
85
|
+
return undefined;
|
|
86
|
+
const folded = name.toLowerCase();
|
|
87
|
+
for (const n of names)
|
|
88
|
+
if (n !== name && n.toLowerCase() === folded)
|
|
89
|
+
return { kind: 'case_twin', currentName: n, ...named };
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
export function agentToolListFlaws(agents, roster) {
|
|
93
|
+
if (!Array.isArray(agents) || agents.length === 0)
|
|
94
|
+
return [];
|
|
95
|
+
const mounted = rosterMountedNames(roster);
|
|
96
|
+
const names = typeof mounted === 'object' ? mounted : RETIRED_TABLE_CURRENT_NAMES;
|
|
97
|
+
const out = [];
|
|
98
|
+
for (const a of agents) {
|
|
99
|
+
if (a === null || typeof a !== 'object' || typeof a.name !== 'string')
|
|
100
|
+
continue;
|
|
101
|
+
for (const [list, entries] of [['disallowedTools', a.denyTools], ['tools', a.allowTools]]) {
|
|
102
|
+
if (!Array.isArray(entries))
|
|
103
|
+
continue;
|
|
104
|
+
for (const entry of entries) {
|
|
105
|
+
const f = toolNameFlawOf(entry, names, list);
|
|
106
|
+
if (f !== undefined)
|
|
107
|
+
out.push({ agent: a.name, list, entry: entry, ...f });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return out;
|
|
112
|
+
}
|
|
113
|
+
function toolListFlawPhrase(f) {
|
|
114
|
+
const entry = f.toolName !== undefined ? `${JSON.stringify(f.entry)} names the tool ${JSON.stringify(f.toolName)}, which` : JSON.stringify(f.entry);
|
|
115
|
+
if (f.kind === 'retired')
|
|
116
|
+
return `${entry} is a retired tool name${f.currentName !== undefined ? ` (now ${JSON.stringify(f.currentName)})` : ' (no longer available under any name)'}`;
|
|
117
|
+
if (f.kind === 'unprefixed_namespace')
|
|
118
|
+
return `${entry} contains "__" but does not start with a tool protocol prefix`;
|
|
119
|
+
return `${entry} differs from the tool ${JSON.stringify(f.currentName ?? '')} only in letter case`;
|
|
120
|
+
}
|
|
41
121
|
export function projectAgentsForWire(defs, deps) {
|
|
42
122
|
const warnings = [];
|
|
43
123
|
const customs = defs
|
|
@@ -51,6 +131,7 @@ export function projectAgentsForWire(defs, deps) {
|
|
|
51
131
|
warnings.push(`agents wire: ${customs.length} custom agents exceed the engine cap of ${MAX_TASK_AGENTS} — keeping the ${MAX_TASK_AGENTS} highest-precedence definitions, dropped: ${dropped.join(', ')}`);
|
|
52
132
|
}
|
|
53
133
|
const out = [];
|
|
134
|
+
const toolListFlaws = [];
|
|
54
135
|
const seen = new Set();
|
|
55
136
|
for (const def of capped) {
|
|
56
137
|
const name = def.agentType;
|
|
@@ -94,6 +175,35 @@ export function projectAgentsForWire(defs, deps) {
|
|
|
94
175
|
const denyTools = projectTools(def.disallowedTools, 'disallowedTools');
|
|
95
176
|
if (denyTools)
|
|
96
177
|
item.denyTools = denyTools;
|
|
178
|
+
const flaws = agentToolListFlaws([item], deps.toolRoster);
|
|
179
|
+
if (flaws.length > 0) {
|
|
180
|
+
let source;
|
|
181
|
+
try {
|
|
182
|
+
source = deps.agentSourceLabel?.(name);
|
|
183
|
+
}
|
|
184
|
+
catch {
|
|
185
|
+
source = undefined;
|
|
186
|
+
}
|
|
187
|
+
const who = `agent "${name}"${typeof source === 'string' && source.length > 0 ? ` (${capForDisplay(source, 120)})` : ''}`;
|
|
188
|
+
toolListFlaws.push(...flaws);
|
|
189
|
+
const denyFlaws = flaws.filter(f => f.list === 'disallowedTools');
|
|
190
|
+
const withhold = denyFlaws.length > 0 && deps.withholdRefusedDenyLists === true;
|
|
191
|
+
if (denyFlaws.length > 0) {
|
|
192
|
+
const what = `its disallowedTools ${denyFlaws.length === 1 ? 'entry' : 'entries'} ${denyFlaws.map(toolListFlawPhrase).join('; ')}`;
|
|
193
|
+
warnings.push(withhold
|
|
194
|
+
? `agents wire: ${who} is not sent to the engine — ${what}, and this engine refuses to start a run whose agent definitions name a tool that way. Fix the entry in the agent definition; until then this agent is not available.`
|
|
195
|
+
: `agents wire: ${who}: ${what} — tool names are matched exactly, so ${denyFlaws.length === 1 ? 'this entry hides' : 'these entries hide'} nothing from the agent, and newer engines refuse to start a run with it. Fix the entry in the agent definition.`);
|
|
196
|
+
}
|
|
197
|
+
if (!withhold) {
|
|
198
|
+
for (const f of flaws) {
|
|
199
|
+
if (f.list !== 'tools')
|
|
200
|
+
continue;
|
|
201
|
+
warnings.push(`agents wire: ${who}: its tools entry ${toolListFlawPhrase(f)} — tool names are matched exactly, so this entry does not give the agent that tool. Fix the entry in the agent definition.`);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (withhold)
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
97
207
|
if (def.memory !== undefined) {
|
|
98
208
|
if (typeof def.memory === 'string' && AGENT_MEMORY_WORDS.has(def.memory)) {
|
|
99
209
|
item.memory = { scopes: [`agent:${name}`], writeScope: `agent:${name}` };
|
|
@@ -171,7 +281,7 @@ export function projectAgentsForWire(defs, deps) {
|
|
|
171
281
|
}
|
|
172
282
|
out.push(item);
|
|
173
283
|
}
|
|
174
|
-
return { agents: out.length > 0 ? out : undefined, warnings };
|
|
284
|
+
return { agents: out.length > 0 ? out : undefined, warnings, ...(toolListFlaws.length > 0 ? { toolListFlaws } : {}) };
|
|
175
285
|
}
|
|
176
286
|
export async function engineSupportsTaskAgents(baseUrl, opts) {
|
|
177
287
|
if (opts?.client !== undefined) {
|
|
@@ -12,5 +12,4 @@ export declare function noteEngineCapsForApprovalDecidedBy(baseUrl: string, caps
|
|
|
12
12
|
}): void;
|
|
13
13
|
export declare function observedApprovalDecidedBy(baseUrl?: string | undefined): ApprovalDecidedByReading;
|
|
14
14
|
export declare function approvalDecidedByAdmitted(reading: ApprovalDecidedByReading | undefined): boolean;
|
|
15
|
-
export declare function forgetApprovalDecidedByReading(baseUrl: string | undefined): void;
|
|
16
15
|
export declare function __resetApprovalDecidedByReadingsForTests(): void;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { engineWireTarget } from './engineWireTarget.js';
|
|
2
2
|
import { createEngineCapReader } from './engineCapReader.js';
|
|
3
|
-
import { readOwnDataValue } from './ownKey.js';
|
|
3
|
+
import { ownDataField, readOwnDataValue } from './ownKey.js';
|
|
4
4
|
export function projectApprovalDecidedByCapability(caps) {
|
|
5
5
|
try {
|
|
6
6
|
if (caps === null || typeof caps !== 'object' || Array.isArray(caps))
|
|
7
7
|
return undefined;
|
|
8
|
-
|
|
9
|
-
return { kind: 'not_reported' };
|
|
10
|
-
const v = caps.approvalDecidedBy;
|
|
8
|
+
const v = ownDataField(caps, 'approvalDecidedBy');
|
|
11
9
|
if (v === undefined)
|
|
12
10
|
return { kind: 'not_reported' };
|
|
13
11
|
return v === true ? { kind: 'present', value: true } : undefined;
|
|
@@ -39,9 +37,6 @@ export function approvalDecidedByAdmitted(reading) {
|
|
|
39
37
|
return false;
|
|
40
38
|
}
|
|
41
39
|
}
|
|
42
|
-
export function forgetApprovalDecidedByReading(baseUrl) {
|
|
43
|
-
reader.forget(baseUrl);
|
|
44
|
-
}
|
|
45
40
|
export function __resetApprovalDecidedByReadingsForTests() {
|
|
46
41
|
reader.__resetForTests();
|
|
47
42
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CORE_APPROVAL_REACH } from './generated/engineFactTables.js';
|
|
2
|
+
export type ApprovalReachWord = (typeof CORE_APPROVAL_REACH)[number];
|
|
3
|
+
export declare function refuseBadApprovalReach(v: unknown, who: string): void;
|
|
4
|
+
export type ApprovalReachWithheldCause = 'not_reported' | 'unsupported' | 'unprobed' | 'unreadable';
|
|
5
|
+
export type ApprovalReachDeclaration = {
|
|
6
|
+
readonly field: {
|
|
7
|
+
readonly approvalReach: Extract<ApprovalReachWord, 'none'>;
|
|
8
|
+
};
|
|
9
|
+
readonly withheld?: undefined;
|
|
10
|
+
} | {
|
|
11
|
+
readonly field: Readonly<Record<string, never>>;
|
|
12
|
+
readonly withheld?: {
|
|
13
|
+
readonly cause: ApprovalReachWithheldCause;
|
|
14
|
+
readonly text: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export declare function approvalReachDeclaration(approverReachable: boolean | null | undefined, baseUrl: string | undefined): ApprovalReachDeclaration;
|
|
18
|
+
export declare function approvalReachDeclarationSettled(approverReachable: boolean | null | undefined, baseUrl: string | undefined, withinMs: number): Promise<ApprovalReachDeclaration>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { CORE_APPROVAL_REACH } from './generated/engineFactTables.js';
|
|
2
|
+
import { engineCapState, engineCapsSettled } from './engineCapsCache.js';
|
|
3
|
+
const KEY = 'approvalReach';
|
|
4
|
+
const APPROVAL_REACH_NONE = 'none';
|
|
5
|
+
const WORDS = new Set(CORE_APPROVAL_REACH);
|
|
6
|
+
const shapeOf = (v) => {
|
|
7
|
+
try {
|
|
8
|
+
return v === null ? 'null' : Array.isArray(v) ? 'typeof=object / array' : typeof v === 'string' ? `typeof=string(长 ${v.length})` : `typeof=${typeof v}`;
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return `typeof=${typeof v} / unreadable`;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
export function refuseBadApprovalReach(v, who) {
|
|
15
|
+
if (v === undefined || v === null)
|
|
16
|
+
return;
|
|
17
|
+
if (typeof v === 'string' && WORDS.has(v))
|
|
18
|
+
return;
|
|
19
|
+
throw new TypeError(`${who}: approvalReach 只接受引擎闭集里的词(${[...CORE_APPROVAL_REACH].join(' / ')})或缺席(undefined/null)—— 收到 ${shapeOf(v)}。` +
|
|
20
|
+
'这一位是「这条运行上没有人能答审批」的声明,值只经片段口 approvalReachDeclaration 铸;本层若把坏值折成缺席,这一发会照常发审批卡而声明方不会知道。' +
|
|
21
|
+
'上游对闭集外的值同样拒收。错误文本只报形状,不回显值。');
|
|
22
|
+
}
|
|
23
|
+
function refuseBadApproverReachable(v, who) {
|
|
24
|
+
if (v === undefined || v === null || v === true || v === false)
|
|
25
|
+
return;
|
|
26
|
+
throw new TypeError(`${who}: approverReachable 只接受布尔或缺席(undefined/null)—— 收到 ${shapeOf(v)}。` +
|
|
27
|
+
'这一位是「这一车道上有没有能答审批的面」这一事实:false = 没有(片段口据此声明),true / 缺席 = 有或没说(不声明,与今天的行为相同)。错误文本只报形状,不回显值。');
|
|
28
|
+
}
|
|
29
|
+
const WITHHELD_TEXT = Object.freeze({
|
|
30
|
+
not_reported: 'Approval requests on this run will still be sent to this session: the connected engine does not report that it can be told nobody here can answer them, and an engine that does not know this setting rejects the whole request, so the setting was left out.',
|
|
31
|
+
unsupported: 'Approval requests on this run will still be sent to this session: the connected engine reports that it cannot be told nobody here can answer them, so the setting was left out.',
|
|
32
|
+
unprobed: 'Approval requests on this run will still be sent to this session: what the connected engine supports has not been read yet, and an engine that does not know this setting rejects the whole request, so the setting was held back.',
|
|
33
|
+
unreadable: 'Approval requests on this run will still be sent to this session: the connected engine reported whether it can be told nobody here can answer them in a form this version cannot read, so the setting was left out.',
|
|
34
|
+
});
|
|
35
|
+
const WITHHELD_CAUSE_OF = {
|
|
36
|
+
absent: 'not_reported',
|
|
37
|
+
false: 'unsupported',
|
|
38
|
+
unprobed: 'unprobed',
|
|
39
|
+
non_boolean: 'unreadable',
|
|
40
|
+
};
|
|
41
|
+
const EMPTY = Object.freeze({ field: Object.freeze({}) });
|
|
42
|
+
export function approvalReachDeclaration(approverReachable, baseUrl) {
|
|
43
|
+
refuseBadApproverReachable(approverReachable, 'approvalReachDeclaration');
|
|
44
|
+
if (approverReachable !== false)
|
|
45
|
+
return EMPTY;
|
|
46
|
+
const state = engineCapState(baseUrl, KEY);
|
|
47
|
+
if (state === 'true')
|
|
48
|
+
return Object.freeze({ field: Object.freeze({ approvalReach: APPROVAL_REACH_NONE }) });
|
|
49
|
+
const cause = WITHHELD_CAUSE_OF[state];
|
|
50
|
+
return Object.freeze({ field: Object.freeze({}), withheld: Object.freeze({ cause, text: WITHHELD_TEXT[cause] }) });
|
|
51
|
+
}
|
|
52
|
+
export async function approvalReachDeclarationSettled(approverReachable, baseUrl, withinMs) {
|
|
53
|
+
refuseBadApproverReachable(approverReachable, 'approvalReachDeclarationSettled');
|
|
54
|
+
if (approverReachable !== false)
|
|
55
|
+
return approvalReachDeclaration(approverReachable, baseUrl);
|
|
56
|
+
await engineCapsSettled(baseUrl, { withinMs: typeof withinMs === 'number' ? withinMs : 0 });
|
|
57
|
+
return approvalReachDeclaration(approverReachable, baseUrl);
|
|
58
|
+
}
|
|
@@ -13,5 +13,4 @@ export declare function noteEngineCapsForApprovalsStreamLive(baseUrl: string, ca
|
|
|
13
13
|
export declare function observedApprovalsStreamLive(baseUrl?: string | undefined): ApprovalsStreamLiveReading;
|
|
14
14
|
export declare function livePendingNeedsReconcile(reading: ApprovalsStreamLiveReading): boolean;
|
|
15
15
|
export declare function approvalsStreamLiveDoctorDetail(reading: ApprovalsStreamLiveReading): string;
|
|
16
|
-
export declare function forgetApprovalsStreamLiveReading(baseUrl: string | undefined): void;
|
|
17
16
|
export declare function __resetApprovalsStreamLiveReadingsForTests(): void;
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import { engineWireTarget } from './engineWireTarget.js';
|
|
2
2
|
import { createEngineCapReader } from './engineCapReader.js';
|
|
3
|
+
import { ownDataField } from './ownKey.js';
|
|
3
4
|
export function projectApprovalsStreamLiveCapability(caps) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
try {
|
|
6
|
+
if (caps === null || typeof caps !== 'object')
|
|
7
|
+
return undefined;
|
|
8
|
+
if (caps === null || typeof caps !== 'object' || Array.isArray(caps))
|
|
9
|
+
return undefined;
|
|
10
|
+
const v = ownDataField(caps, 'approvalsStreamLive');
|
|
11
|
+
if (v === undefined)
|
|
12
|
+
return { kind: 'not_reported' };
|
|
13
|
+
if (typeof v !== 'boolean')
|
|
14
|
+
return undefined;
|
|
15
|
+
return { kind: 'present', live: v };
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
14
18
|
return undefined;
|
|
15
|
-
|
|
19
|
+
}
|
|
16
20
|
}
|
|
17
21
|
const reader = createEngineCapReader({
|
|
18
22
|
name: 'approvalsStreamLive',
|
|
@@ -40,9 +44,6 @@ export function approvalsStreamLiveDoctorDetail(reading) {
|
|
|
40
44
|
: 'live approval push off on this deployment (no checkpoint store or tool approvals disabled; the engine reports one bit for both, so this client cannot tell which) — suspended asks are only visible through the reconcile cadence, so the client polls for them';
|
|
41
45
|
}
|
|
42
46
|
}
|
|
43
|
-
export function forgetApprovalsStreamLiveReading(baseUrl) {
|
|
44
|
-
reader.forget(baseUrl);
|
|
45
|
-
}
|
|
46
47
|
export function __resetApprovalsStreamLiveReadingsForTests() {
|
|
47
48
|
reader.__resetForTests();
|
|
48
49
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function atMostOnceFailureClass(e: unknown): 'rejected' | 'unknown';
|
|
2
|
+
export interface AtMostOnceVerdict {
|
|
3
|
+
readonly delivery: 'rejected' | 'unknown';
|
|
4
|
+
readonly status?: number;
|
|
5
|
+
readonly code?: string;
|
|
6
|
+
readonly name?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function atMostOnceVerdictOf(e: unknown): AtMostOnceVerdict;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { errCodes, steeringRefusedBeforeEngine, steeringStatusIs4xx } from './controlRouter.js';
|
|
2
|
+
function errorSlot(e, key) {
|
|
3
|
+
if (e === null || e === undefined)
|
|
4
|
+
return undefined;
|
|
5
|
+
try {
|
|
6
|
+
return e[key];
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export function atMostOnceFailureClass(e) {
|
|
13
|
+
const s = atMostOnceSnapshotOf(e);
|
|
14
|
+
if (steeringStatusIs4xx(s))
|
|
15
|
+
return 'rejected';
|
|
16
|
+
return steeringRefusedBeforeEngine(s) !== undefined ? 'rejected' : 'unknown';
|
|
17
|
+
}
|
|
18
|
+
function atMostOnceSnapshotOf(e) {
|
|
19
|
+
return {
|
|
20
|
+
status: errorSlot(e, 'status'),
|
|
21
|
+
statusCode: errorSlot(e, 'statusCode'),
|
|
22
|
+
errorCode: errorSlot(e, 'errorCode'),
|
|
23
|
+
name: errorSlot(e, 'name'),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export function atMostOnceVerdictOf(e) {
|
|
27
|
+
const snapshot = atMostOnceSnapshotOf(e);
|
|
28
|
+
const delivery = atMostOnceFailureClass(snapshot);
|
|
29
|
+
const { status, code, name } = errCodes(snapshot);
|
|
30
|
+
return {
|
|
31
|
+
delivery,
|
|
32
|
+
...(status !== undefined ? { status } : {}),
|
|
33
|
+
...(code !== undefined && code !== '' ? { code } : {}),
|
|
34
|
+
...(name !== undefined && name !== '' ? { name } : {}),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -7,5 +7,4 @@ export declare function noteEngineCapsForAttachmentSeat(baseUrl: string, caps: u
|
|
|
7
7
|
generation?: number;
|
|
8
8
|
}): void;
|
|
9
9
|
export declare function observedAttachmentSeat(baseUrl?: string | undefined): AttachmentSeatReading;
|
|
10
|
-
export declare function forgetAttachmentSeatReading(baseUrl: string | undefined): void;
|
|
11
10
|
export declare function __resetAttachmentSeatReadingsForTests(): void;
|
|
@@ -19,9 +19,6 @@ export function noteEngineCapsForAttachmentSeat(baseUrl, caps, opts) {
|
|
|
19
19
|
export function observedAttachmentSeat(baseUrl = engineWireTarget()?.baseUrl) {
|
|
20
20
|
return reader.observed(baseUrl);
|
|
21
21
|
}
|
|
22
|
-
export function forgetAttachmentSeatReading(baseUrl) {
|
|
23
|
-
reader.forget(baseUrl);
|
|
24
|
-
}
|
|
25
22
|
export function __resetAttachmentSeatReadingsForTests() {
|
|
26
23
|
reader.__resetForTests();
|
|
27
24
|
}
|
|
@@ -23,8 +23,14 @@ const OPT_IN_KEYS = [
|
|
|
23
23
|
'mcpInstructions',
|
|
24
24
|
];
|
|
25
25
|
const DEFAULT_ON_ONLY_KEYS = ['agentListing', 'skillsListing'];
|
|
26
|
-
const
|
|
27
|
-
|
|
26
|
+
const PRODUCT_DEFAULT_KEYS = ['backgroundTasks', 'toolsDelta', 'todoReminder'];
|
|
27
|
+
function productDefaultAttachments() {
|
|
28
|
+
const out = {};
|
|
29
|
+
for (const k of PRODUCT_DEFAULT_KEYS)
|
|
30
|
+
out[k] = true;
|
|
31
|
+
return out;
|
|
32
|
+
}
|
|
33
|
+
const _attachmentsKeyPins = [true, true, true, true, true, true, true];
|
|
28
34
|
void _attachmentsKeyPins;
|
|
29
35
|
const TODO_REMINDER_MODES = ['baseline', 'off'];
|
|
30
36
|
export class AttachmentsSpecRefused extends TypeError {
|
|
@@ -61,11 +67,11 @@ function judgeAttachmentsEnv(raw) {
|
|
|
61
67
|
return { ok: false, refusal: { kind: 'retired_key', token, why: named.why, entry: i + 1, key: named.key, retired: named } };
|
|
62
68
|
}
|
|
63
69
|
if (tokens.length === 0)
|
|
64
|
-
return { ok: true, spec:
|
|
70
|
+
return { ok: true, spec: productDefaultAttachments() };
|
|
65
71
|
if (tokens.length === 1 && (tokens[0] === 'full' || tokens[0] === 'all'))
|
|
66
72
|
return { ok: true, spec: allLiteralTrue() };
|
|
67
73
|
if (tokens.length === 1 && !isKnownToken(tokens[0])) {
|
|
68
|
-
return { ok: true, spec:
|
|
74
|
+
return { ok: true, spec: productDefaultAttachments() };
|
|
69
75
|
}
|
|
70
76
|
const spec = {};
|
|
71
77
|
for (const [i, token] of tokens.entries()) {
|
|
@@ -74,8 +80,7 @@ function judgeAttachmentsEnv(raw) {
|
|
|
74
80
|
continue;
|
|
75
81
|
}
|
|
76
82
|
if (token === 'default') {
|
|
77
|
-
|
|
78
|
-
spec[k] = true;
|
|
83
|
+
Object.assign(spec, productDefaultAttachments());
|
|
79
84
|
continue;
|
|
80
85
|
}
|
|
81
86
|
if (token.startsWith('-')) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface BashFrameExit {
|
|
2
|
+
readonly exitCode: number | null;
|
|
3
|
+
readonly note?: string;
|
|
4
|
+
}
|
|
5
|
+
export interface BashExitReading {
|
|
6
|
+
readonly exitCode: number | null;
|
|
7
|
+
readonly benignNote: string | undefined;
|
|
8
|
+
}
|
|
9
|
+
export declare function bashExitOf(structured: unknown, parseFrame: () => BashFrameExit | null): BashExitReading;
|
|
10
|
+
export declare function bashExitReadingFailed(r: BashExitReading): boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function bashExitOf(structured, parseFrame) {
|
|
2
|
+
const s = typeof structured === 'object' && structured !== null ? structured : undefined;
|
|
3
|
+
const interp = typeof s?.returnCodeInterpretation === 'string' && s.returnCodeInterpretation.length > 0 ? s.returnCodeInterpretation : undefined;
|
|
4
|
+
if (s?.type === 'bash' && typeof s.exitCode === 'number')
|
|
5
|
+
return { exitCode: s.exitCode, benignNote: interp };
|
|
6
|
+
const parsed = parseFrame();
|
|
7
|
+
const note = typeof parsed?.note === 'string' && parsed.note.length > 0 ? parsed.note : undefined;
|
|
8
|
+
return { exitCode: parsed?.exitCode ?? null, benignNote: interp ?? note };
|
|
9
|
+
}
|
|
10
|
+
export function bashExitReadingFailed(r) {
|
|
11
|
+
return r.exitCode !== null && r.exitCode !== 0 && r.benignNote === undefined;
|
|
12
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type CallerCwdReading = {
|
|
2
|
+
kind: 'unobserved';
|
|
3
|
+
} | {
|
|
4
|
+
kind: 'not_reported';
|
|
5
|
+
} | {
|
|
6
|
+
kind: 'present';
|
|
7
|
+
value: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare function projectCallerCwdCapability(caps: unknown): CallerCwdReading | undefined;
|
|
10
|
+
export declare function noteEngineCapsForCallerCwd(baseUrl: string, caps: unknown, opts?: {
|
|
11
|
+
generation?: number;
|
|
12
|
+
}): void;
|
|
13
|
+
export declare function observedCallerCwd(baseUrl?: string | undefined): CallerCwdReading;
|
|
14
|
+
export declare function callerCwdAdmitted(reading: CallerCwdReading | undefined): boolean;
|
|
15
|
+
export declare function __resetCallerCwdReadingsForTests(): void;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { engineWireTarget } from './engineWireTarget.js';
|
|
2
|
+
import { createEngineCapReader } from './engineCapReader.js';
|
|
3
|
+
import { ownDataField, readOwnDataValue } from './ownKey.js';
|
|
4
|
+
export function projectCallerCwdCapability(caps) {
|
|
5
|
+
try {
|
|
6
|
+
if (caps === null || typeof caps !== 'object' || Array.isArray(caps))
|
|
7
|
+
return undefined;
|
|
8
|
+
const v = ownDataField(caps, 'callerCwd');
|
|
9
|
+
if (v === undefined)
|
|
10
|
+
return { kind: 'not_reported' };
|
|
11
|
+
return typeof v === 'boolean' ? { kind: 'present', value: v } : undefined;
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const reader = createEngineCapReader({
|
|
18
|
+
name: 'callerCwd',
|
|
19
|
+
project: projectCallerCwdCapability,
|
|
20
|
+
makeUnobserved: () => ({ kind: 'unobserved' }),
|
|
21
|
+
});
|
|
22
|
+
export function noteEngineCapsForCallerCwd(baseUrl, caps, opts) {
|
|
23
|
+
reader.note(baseUrl, caps, opts);
|
|
24
|
+
}
|
|
25
|
+
export function observedCallerCwd(baseUrl = engineWireTarget()?.baseUrl) {
|
|
26
|
+
return reader.observed(baseUrl);
|
|
27
|
+
}
|
|
28
|
+
export function callerCwdAdmitted(reading) {
|
|
29
|
+
try {
|
|
30
|
+
if (reading === null || reading === undefined || typeof reading !== 'object' || Array.isArray(reading))
|
|
31
|
+
return false;
|
|
32
|
+
if (readOwnDataValue(reading, 'kind') !== 'present')
|
|
33
|
+
return false;
|
|
34
|
+
return readOwnDataValue(reading, 'value') === true;
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export function __resetCallerCwdReadingsForTests() {
|
|
41
|
+
reader.__resetForTests();
|
|
42
|
+
}
|
|
@@ -15,11 +15,10 @@ export interface CenterWiringView {
|
|
|
15
15
|
usageReport: boolean;
|
|
16
16
|
issuer: string;
|
|
17
17
|
caller?: CenterWiringCallerView;
|
|
18
|
+
worker?: string;
|
|
18
19
|
}
|
|
19
20
|
export type CenterWiringReading = {
|
|
20
21
|
kind: 'unobserved';
|
|
21
|
-
} | {
|
|
22
|
-
kind: 'not_reported';
|
|
23
22
|
} | {
|
|
24
23
|
kind: 'none';
|
|
25
24
|
} | {
|
|
@@ -34,5 +33,4 @@ export declare function observedCenterWiring(baseUrl?: string | undefined): Cent
|
|
|
34
33
|
export type CallerQuotaLease = 'enforced' | 'not-enforced' | 'exhausted' | 'unobserved' | 'no-lease' | 'unknown';
|
|
35
34
|
export declare function callerQuotaLease(reading: CenterWiringReading): CallerQuotaLease;
|
|
36
35
|
export declare function centerWiringDoctorDetail(reading: CenterWiringReading): string;
|
|
37
|
-
export declare function forgetCenterWiringReading(baseUrl: string | undefined): void;
|
|
38
36
|
export declare function __resetCenterWiringReadingsForTests(): void;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { capForDisplay } from './fleetTaskDesc.js';
|
|
2
2
|
import { engineWireTarget } from './engineWireTarget.js';
|
|
3
|
-
import {
|
|
3
|
+
import { createEngineCapReader } from './engineCapReader.js';
|
|
4
|
+
import { ownDataField } from './ownKey.js';
|
|
4
5
|
const nonEmpty = (v) => typeof v === 'string' && v !== '';
|
|
5
6
|
const isPlainObject = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
6
7
|
function optionalSeat(o, key) {
|
|
7
|
-
|
|
8
|
-
return { state: 'absent' };
|
|
9
|
-
const value = o[key];
|
|
8
|
+
const value = ownDataField(o, key);
|
|
10
9
|
return value === undefined ? { state: 'absent' } : { state: 'value', value };
|
|
11
10
|
}
|
|
12
11
|
export function projectCenterWiringCapability(caps) {
|
|
@@ -20,16 +19,16 @@ export function projectCenterWiringCapability(caps) {
|
|
|
20
19
|
function projectCenterWiringOf(caps) {
|
|
21
20
|
if (!isPlainObject(caps))
|
|
22
21
|
return undefined;
|
|
23
|
-
const cw =
|
|
22
|
+
const cw = ownDataField(caps, 'centerWiring');
|
|
24
23
|
if (cw === undefined)
|
|
25
|
-
return
|
|
24
|
+
return { kind: 'none' };
|
|
26
25
|
if (!isPlainObject(cw))
|
|
27
26
|
return undefined;
|
|
28
|
-
const effectivePull = cw
|
|
29
|
-
const revisionRaw = cw
|
|
30
|
-
const lease = cw
|
|
31
|
-
const usageReport = cw
|
|
32
|
-
const issuer = cw
|
|
27
|
+
const effectivePull = ownDataField(cw, 'effectivePull');
|
|
28
|
+
const revisionRaw = ownDataField(cw, 'effectiveRevision');
|
|
29
|
+
const lease = ownDataField(cw, 'lease');
|
|
30
|
+
const usageReport = ownDataField(cw, 'usageReport');
|
|
31
|
+
const issuer = ownDataField(cw, 'issuer');
|
|
33
32
|
if (typeof effectivePull !== 'boolean' || typeof usageReport !== 'boolean')
|
|
34
33
|
return undefined;
|
|
35
34
|
if (!nonEmpty(lease) || !nonEmpty(issuer))
|
|
@@ -41,8 +40,8 @@ function projectCenterWiringOf(caps) {
|
|
|
41
40
|
else {
|
|
42
41
|
if (!isPlainObject(revisionRaw))
|
|
43
42
|
return undefined;
|
|
44
|
-
const version = revisionRaw
|
|
45
|
-
const updatedAt = revisionRaw
|
|
43
|
+
const version = ownDataField(revisionRaw, 'version');
|
|
44
|
+
const updatedAt = ownDataField(revisionRaw, 'updatedAt');
|
|
46
45
|
if (typeof version !== 'number' || !Number.isFinite(version) || !nonEmpty(updatedAt))
|
|
47
46
|
return undefined;
|
|
48
47
|
effectiveRevision = { version, updatedAt };
|
|
@@ -58,7 +57,7 @@ function projectCenterWiringOf(caps) {
|
|
|
58
57
|
if (callerSeat.state === 'value') {
|
|
59
58
|
if (!isPlainObject(callerSeat.value))
|
|
60
59
|
return undefined;
|
|
61
|
-
const callerLease = callerSeat.value
|
|
60
|
+
const callerLease = ownDataField(callerSeat.value, 'lease');
|
|
62
61
|
if (!nonEmpty(callerLease))
|
|
63
62
|
return undefined;
|
|
64
63
|
const wait = optionalSeat(callerSeat.value, 'retryAfterSec');
|
|
@@ -66,6 +65,9 @@ function projectCenterWiringOf(caps) {
|
|
|
66
65
|
return undefined;
|
|
67
66
|
caller = { lease: callerLease, ...(wait.state === 'value' ? { retryAfterSec: wait.value } : {}) };
|
|
68
67
|
}
|
|
68
|
+
const workerSeat = optionalSeat(cw, 'worker');
|
|
69
|
+
if (workerSeat.state === 'value' && !nonEmpty(workerSeat.value))
|
|
70
|
+
return undefined;
|
|
69
71
|
return {
|
|
70
72
|
kind: 'present',
|
|
71
73
|
view: {
|
|
@@ -77,6 +79,7 @@ function projectCenterWiringOf(caps) {
|
|
|
77
79
|
usageReport,
|
|
78
80
|
issuer,
|
|
79
81
|
...(caller !== undefined ? { caller } : {}),
|
|
82
|
+
...(workerSeat.state === 'value' ? { worker: workerSeat.value } : {}),
|
|
80
83
|
},
|
|
81
84
|
};
|
|
82
85
|
}
|
|
@@ -96,7 +99,7 @@ function guarded(reading) {
|
|
|
96
99
|
return undefined;
|
|
97
100
|
try {
|
|
98
101
|
const kind = reading.kind;
|
|
99
|
-
if (kind === '
|
|
102
|
+
if (kind === 'unobserved' || kind === 'none')
|
|
100
103
|
return { kind };
|
|
101
104
|
if (kind !== 'present')
|
|
102
105
|
return undefined;
|
|
@@ -158,9 +161,6 @@ function failModeClause(v) {
|
|
|
158
161
|
export function centerWiringDoctorDetail(reading) {
|
|
159
162
|
const unobserved = 'center wiring not observed — the engine reports it on /v1/capabilities; this process has no usable capabilities reading cached for it, so whether this engine is connected to a configuration center is unknown';
|
|
160
163
|
const r = guarded(reading);
|
|
161
|
-
if (r?.kind === 'not_reported') {
|
|
162
|
-
return 'center wiring not reported by this engine; this does not say whether the engine is connected to a configuration center';
|
|
163
|
-
}
|
|
164
164
|
if (r?.kind === 'none') {
|
|
165
165
|
return 'no configuration center on this deployment — the engine runs on its own local configuration; no quota lease or usage reporting goes through a center';
|
|
166
166
|
}
|
|
@@ -194,9 +194,6 @@ export function centerWiringDoctorDetail(reading) {
|
|
|
194
194
|
return unobserved;
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
|
-
export function forgetCenterWiringReading(baseUrl) {
|
|
198
|
-
reader.forget(baseUrl);
|
|
199
|
-
}
|
|
200
197
|
export function __resetCenterWiringReadingsForTests() {
|
|
201
198
|
reader.__resetForTests();
|
|
202
199
|
}
|
package/dist/classifierStatus.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { classifierDenyCauseOf } from './autoModeUnavailable.js';
|
|
2
|
+
import { readAskOrigin } from './ownKey.js';
|
|
2
3
|
export const CLASSIFIER_STATUS_STATES = Object.freeze([
|
|
3
4
|
'armed',
|
|
4
5
|
'available',
|
|
@@ -8,14 +9,13 @@ const CLASSIFIER_RAN_ORIGINS = new Set(['denial_limit_fallback']);
|
|
|
8
9
|
function askOriginOf(ask) {
|
|
9
10
|
if (typeof ask !== 'object' || ask === null || Array.isArray(ask))
|
|
10
11
|
return undefined;
|
|
11
|
-
const top = ask
|
|
12
|
-
if (
|
|
12
|
+
const top = readAskOrigin(ask);
|
|
13
|
+
if (top !== undefined)
|
|
13
14
|
return top;
|
|
14
15
|
const gate = ask.gate;
|
|
15
16
|
if (typeof gate !== 'object' || gate === null || Array.isArray(gate))
|
|
16
17
|
return undefined;
|
|
17
|
-
|
|
18
|
-
return typeof inner === 'string' && inner.length > 0 ? inner : undefined;
|
|
18
|
+
return readAskOrigin(gate);
|
|
19
19
|
}
|
|
20
20
|
const NOT_A_ROUND_FAILURE = new Set(['parse_error']);
|
|
21
21
|
export function classifierStatusOf(autoMode, ask) {
|