@sema-agent/client-core 0.97.1 → 0.98.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 +408 -0
- package/README.md +74 -37
- package/dist/adapt/arms.d.ts +1 -0
- package/dist/adapt/arms.js +128 -34
- package/dist/adapt/ids.d.ts +12 -1
- package/dist/adapt/ids.js +59 -8
- package/dist/adapt/instanceLedger.d.ts +50 -0
- package/dist/adapt/instanceLedger.js +147 -0
- package/dist/adapt/textStream.d.ts +1 -0
- package/dist/adapt/textStream.js +24 -7
- package/dist/adapt/toolCards.d.ts +27 -5
- package/dist/adapt/toolCards.js +39 -6
- package/dist/adapt/wireShapes.js +6 -2
- package/dist/adapt.d.ts +2 -0
- package/dist/adapt.js +8 -3
- package/dist/adapter/activeRunSelfHeal.d.ts +5 -0
- package/dist/adapter/activeRunSelfHeal.js +51 -28
- package/dist/adapter/downstream/eventToSdkMessage.d.ts +2 -5
- package/dist/adapter/downstream/eventToSdkMessage.js +27 -34
- package/dist/adapter/downstream/terminalToSdkResult.js +11 -4
- package/dist/adapter/downstream/turnUsageToModelUsage.d.ts +5 -2
- package/dist/adapter/downstream/turnUsageToModelUsage.js +2 -0
- package/dist/adapter/runStream.js +29 -13
- package/dist/adapter/types.d.ts +4 -4
- package/dist/agentSession/backgroundView.js +2 -1
- package/dist/agentSession/engineAgentRegistryRead.d.ts +2 -2
- package/dist/agentSession/engineAgentRegistryRead.js +12 -13
- package/dist/agentsWireCaps.d.ts +8 -8
- package/dist/agentsWireCaps.js +168 -175
- package/dist/approvalDecidedByCapability.d.ts +0 -4
- package/dist/approvalDecidedByCapability.js +0 -6
- package/dist/approvalsStreamLiveCapability.d.ts +0 -4
- package/dist/approvalsStreamLiveCapability.js +0 -6
- package/dist/assistantInbox.d.ts +34 -0
- package/dist/assistantInbox.js +118 -0
- package/dist/centerWiringCapability.js +9 -1
- package/dist/clientSlice.d.ts +0 -9
- package/dist/clientSlice.js +0 -3
- package/dist/cloudConfigWireCaps.d.ts +4 -2
- package/dist/cloudConfigWireCaps.js +81 -61
- package/dist/compensations.js +1 -1
- package/dist/connectorStatus.d.ts +21 -0
- package/dist/connectorStatus.js +112 -0
- package/dist/controlRouter.d.ts +14 -1
- package/dist/controlRouter.js +68 -17
- package/dist/coreValuePorts.d.ts +3 -3
- package/dist/decideReceipt.d.ts +2 -2
- package/dist/decideReceipt.js +5 -2
- package/dist/declared/supportFloorDeclared.js +3 -3
- package/dist/deviceExecutorManagementCapability.d.ts +0 -4
- package/dist/deviceExecutorManagementCapability.js +0 -6
- package/dist/deviceRebind.d.ts +49 -1
- package/dist/deviceRebind.js +221 -3
- package/dist/displayUntrusted.d.ts +1 -0
- package/dist/displayUntrusted.js +250 -76
- package/dist/engineAgentAbsence.d.ts +1 -1
- package/dist/engineAgentPanelStore.d.ts +5 -4
- package/dist/engineAgentPanelStore.js +3 -12
- package/dist/engineCapReader.d.ts +0 -4
- package/dist/engineCapReader.js +1 -5
- package/dist/engineCapsCache.d.ts +4 -0
- package/dist/engineCapsCache.js +17 -12
- package/dist/engineClosedSets.d.ts +1 -0
- package/dist/engineClosedSets.js +4 -1
- package/dist/engineErrorCodes.d.ts +9 -2
- package/dist/engineErrorCodes.js +9 -1
- package/dist/engineIdentity.d.ts +1 -0
- package/dist/engineIdentity.js +8 -0
- package/dist/engineRowRef.d.ts +28 -0
- package/dist/engineRowRef.js +111 -0
- package/dist/engineSessionMessages.d.ts +67 -0
- package/dist/engineSessionMessages.js +364 -0
- package/dist/engineToolDirectory.d.ts +0 -9
- package/dist/engineToolDirectory.js +1 -94
- package/dist/engineUrl.d.ts +18 -0
- package/dist/engineUrl.js +52 -0
- package/dist/env/uiLanguage.d.ts +9 -0
- package/dist/env/uiLanguage.js +35 -0
- package/dist/eventLeg.d.ts +92 -0
- package/dist/eventLeg.js +285 -0
- package/dist/executionLaneCapability.d.ts +0 -4
- package/dist/executionLaneCapability.js +3 -16
- package/dist/fileHistoryCaptureCapability.d.ts +0 -4
- package/dist/fileHistoryCaptureCapability.js +5 -7
- package/dist/fleet/fleetLedger.d.ts +0 -3
- package/dist/fleet/fleetLedger.js +21 -36
- package/dist/fleet/fleetProjection.d.ts +2 -2
- package/dist/fleet/fleetProjection.js +10 -8
- package/dist/frameBinding.d.ts +5 -0
- package/dist/frameBinding.js +23 -0
- package/dist/gateFailureCodes.d.ts +2 -0
- package/dist/gateFailureCodes.js +15 -0
- package/dist/gateOutcome.d.ts +3 -1
- package/dist/gateOutcome.js +25 -6
- package/dist/gateVocabulary.d.ts +5 -0
- package/dist/gateVocabulary.js +64 -2
- package/dist/generated/engineAskFaceTables.js +2 -2
- package/dist/generated/engineFactTables.d.ts +6 -3
- package/dist/generated/engineFactTables.js +22 -4
- package/dist/generated/engineNoticeTables.js +9 -0
- package/dist/generated/toolNameTables.d.ts +1 -0
- package/dist/generated/toolNameTables.js +1 -0
- package/dist/hitl/allowRuleShadow.d.ts +6 -1
- package/dist/hitl/allowRuleShadow.js +21 -17
- package/dist/hitl/approvalCardReading.d.ts +15 -0
- package/dist/hitl/approvalCardReading.js +154 -0
- package/dist/hitl/approvalCardReasons.d.ts +13 -0
- package/dist/hitl/approvalCardReasons.js +120 -0
- package/dist/hitl/approvalHolds.d.ts +47 -15
- package/dist/hitl/approvalHolds.js +134 -28
- package/dist/hitl/approvalResolution.d.ts +51 -26
- package/dist/hitl/approvalResolution.js +86 -122
- package/dist/hitl/approvalsFeed.js +6 -18
- package/dist/hitl/askClassPair.d.ts +2 -0
- package/dist/hitl/askClassPair.js +1 -0
- package/dist/hitl/askGateWire.d.ts +20 -2
- package/dist/hitl/askGateWire.js +49 -1
- package/dist/hitl/askParkRowRouting.d.ts +5 -0
- package/dist/hitl/askParkRowRouting.js +32 -1
- package/dist/hitl/askSettlementLine.d.ts +18 -0
- package/dist/hitl/askSettlementLine.js +79 -0
- package/dist/hitl/automaticAnswerVerdict.d.ts +1 -1
- package/dist/hitl/automaticAnswerVerdict.js +21 -5
- package/dist/hitl/crashConverged.d.ts +11 -20
- package/dist/hitl/crashConverged.js +56 -0
- package/dist/hitl/crashConvergedNotice.d.ts +3 -1
- package/dist/hitl/crashConvergedNotice.js +48 -11
- package/dist/hitl/decisionConflict.js +3 -10
- package/dist/hitl/decisionRefusal.d.ts +40 -1
- package/dist/hitl/decisionRefusal.js +199 -42
- package/dist/hitl/frameRouter.d.ts +5 -2
- package/dist/hitl/frameRouter.js +20 -16
- package/dist/hitl/gateLedger.d.ts +2 -0
- package/dist/hitl/gateLedger.js +50 -13
- package/dist/hitl/hitlBridge.d.ts +1 -2
- package/dist/hitl/hitlBridge.js +10 -7
- package/dist/hitl/livePendingAsk.d.ts +3 -3
- package/dist/hitl/livePendingAsk.js +7 -18
- package/dist/hitl/parkResolver.d.ts +2 -24
- package/dist/hitl/parkResolver.js +61 -97
- package/dist/hitl/persistedRulesWire.d.ts +24 -0
- package/dist/hitl/persistedRulesWire.js +122 -2
- package/dist/hitl/planReviewWire.d.ts +26 -13
- package/dist/hitl/planReviewWire.js +112 -78
- package/dist/hitl/refusedToolNameProse.d.ts +0 -1
- package/dist/hitl/refusedToolNameProse.js +0 -3
- package/dist/hitl/replayedApproval.d.ts +4 -3
- package/dist/hitl/replayedApproval.js +7 -4
- package/dist/hitl/sessionPolicyDeliverable.js +2 -4
- package/dist/hitl/sessionPolicyWire.d.ts +32 -20
- package/dist/hitl/sessionPolicyWire.js +162 -52
- package/dist/hitl/standingRows.d.ts +20 -2
- package/dist/hitl/standingRows.js +69 -8
- package/dist/hitl/toolApprovalWire.d.ts +87 -152
- package/dist/hitl/toolApprovalWire.js +591 -380
- package/dist/hookMatcherVerdict.d.ts +6 -1
- package/dist/hookMatcherVerdict.js +14 -7
- package/dist/hooksWireCaps.d.ts +2 -2
- package/dist/hooksWireCaps.js +59 -55
- package/dist/i18n/messages.en.d.ts +121 -0
- package/dist/i18n/messages.en.js +119 -0
- package/dist/i18n/messages.zh.d.ts +3 -0
- package/dist/i18n/messages.zh.js +120 -0
- package/dist/i18n/translate.d.ts +25 -0
- package/dist/i18n/translate.js +127 -0
- package/dist/index.d.ts +53 -20
- package/dist/index.js +38 -11
- package/dist/inheritEnvCapability.d.ts +31 -0
- package/dist/inheritEnvCapability.js +104 -0
- package/dist/liveModelCatalog.d.ts +1 -2
- package/dist/liveModelCatalog.js +2 -6
- package/dist/liveQuestionStore.d.ts +2 -21
- package/dist/mcpLiveness.d.ts +2 -1
- package/dist/mcpProbeWire.d.ts +6 -1
- package/dist/mcpProbeWire.js +1 -1
- package/dist/mcpWireCaps.d.ts +13 -2
- package/dist/mcpWireCaps.js +48 -0
- package/dist/memoryEntriesWire.d.ts +4 -9
- package/dist/model/modelSupplyRules.d.ts +0 -2
- package/dist/model/modelSupplyRules.js +3 -12
- package/dist/model/modelsPolicy.d.ts +0 -5
- package/dist/model/modelsPolicy.js +6 -36
- package/dist/model/subagentModelWord.d.ts +31 -0
- package/dist/model/subagentModelWord.js +261 -0
- package/dist/notifications.d.ts +6 -0
- package/dist/notifications.js +71 -23
- package/dist/outputStyleSeatCapability.d.ts +0 -3
- package/dist/outputStyleSeatCapability.js +0 -3
- package/dist/ownKey.d.ts +15 -0
- package/dist/ownKey.js +60 -3
- package/dist/panelReduce.d.ts +15 -9
- package/dist/panelReduce.js +680 -549
- package/dist/panelStateHolder.d.ts +3 -7
- package/dist/panelStateHolder.js +14 -130
- package/dist/peerLaneCapability.d.ts +0 -4
- package/dist/peerLaneCapability.js +0 -6
- package/dist/permissionRulesWriteCapability.d.ts +0 -4
- package/dist/permissionRulesWriteCapability.js +0 -6
- package/dist/permissionWireCaps.d.ts +2 -2
- package/dist/permissionWireCaps.js +2 -0
- package/dist/permissionsAllowGrantCapability.d.ts +0 -4
- package/dist/permissionsAllowGrantCapability.js +0 -6
- package/dist/permissionsDeclaration.d.ts +0 -11
- package/dist/permissionsDeclaration.js +60 -53
- package/dist/pluginHooksWire.d.ts +1 -1
- package/dist/pluginHooksWire.js +3 -6
- package/dist/preemptWire.d.ts +44 -0
- package/dist/preemptWire.js +83 -0
- package/dist/printToolResultFrame.js +15 -4
- package/dist/replayBody.d.ts +3 -0
- package/dist/replayBody.js +14 -0
- package/dist/request/taskRequest.d.ts +0 -1
- package/dist/request/taskRequest.js +0 -3
- package/dist/resumeRefusalCopy.d.ts +2 -1
- package/dist/resumeRefusalCopy.js +38 -2
- package/dist/retryStatus.d.ts +8 -0
- package/dist/retryStatus.js +106 -1
- package/dist/rewindArchiveCapability.d.ts +0 -4
- package/dist/rewindArchiveCapability.js +2 -10
- package/dist/rewindArchiveReading.d.ts +0 -1
- package/dist/rewindArchiveReading.js +0 -3
- package/dist/runCancelContext.d.ts +2 -1
- package/dist/runCancelContext.js +4 -2
- package/dist/runReattachPolicy.d.ts +31 -0
- package/dist/runReattachPolicy.js +46 -0
- package/dist/runTerminal.d.ts +3 -6
- package/dist/runTerminal.js +8 -9
- package/dist/sandboxWire.d.ts +3 -1
- package/dist/sandboxWire.js +76 -27
- package/dist/scenarioWire.js +1 -1
- package/dist/seam.d.ts +24 -2
- package/dist/seam.js +15 -3
- package/dist/seatContract.d.ts +53 -10
- package/dist/seatContract.js +132 -81
- package/dist/sessionPolicyCapability.d.ts +0 -4
- package/dist/sessionPolicyCapability.js +0 -6
- package/dist/sessionSyncFileHistoryCapability.d.ts +0 -3
- package/dist/sessionSyncFileHistoryCapability.js +0 -3
- package/dist/skillToolListsCapability.d.ts +0 -3
- package/dist/skillToolListsCapability.js +0 -3
- package/dist/sqlEngineCapability.d.ts +0 -4
- package/dist/sqlEngineCapability.js +0 -6
- package/dist/steerPriorityCapability.d.ts +0 -3
- package/dist/steerPriorityCapability.js +0 -3
- package/dist/streamDrainingLegs.d.ts +4 -0
- package/dist/streamDrainingLegs.js +6 -1
- package/dist/subagent/engineCompactWire.d.ts +0 -1
- package/dist/subagent/engineCompactWire.js +7 -5
- package/dist/subagent/engineTaskHandleWire.js +4 -7
- package/dist/subagentContentStore.js +1 -11
- package/dist/submitReopen.d.ts +24 -0
- package/dist/submitReopen.js +75 -0
- package/dist/terminalStatuses.d.ts +3 -0
- package/dist/terminalStatuses.js +10 -2
- package/dist/toolResult.d.ts +10 -1
- package/dist/toolResult.js +34 -6
- package/dist/toolRoster.d.ts +0 -2
- package/dist/toolRoster.js +0 -2
- package/dist/turnFailurePresentation.d.ts +28 -0
- package/dist/turnFailurePresentation.js +205 -0
- package/dist/userInvokedSkillsCapability.d.ts +0 -3
- package/dist/userInvokedSkillsCapability.js +0 -3
- package/dist/webSearchBackendCapability.d.ts +0 -4
- package/dist/webSearchBackendCapability.js +0 -6
- package/dist/wireErrorTriage.js +5 -24
- package/dist/wireFailureShape.d.ts +62 -5
- package/dist/wireFailureShape.js +105 -5
- package/dist/wireRefusalCopy.d.ts +12 -2
- package/dist/wireRefusalCopy.js +50 -52
- package/dist/workflowsJournalCapability.d.ts +0 -4
- package/dist/workflowsJournalCapability.js +0 -6
- package/dist/writeProtectionCapability.d.ts +0 -4
- package/dist/writeProtectionCapability.js +0 -6
- package/docs/INTEGRATION-CLIENTS.md +1253 -46
- package/package.json +5 -4
- package/dist/attachmentSeatCapability.d.ts +0 -12
- package/dist/attachmentSeatCapability.js +0 -23
- package/dist/hitl/approvalOutcomeNote.d.ts +0 -10
- package/dist/hitl/approvalOutcomeNote.js +0 -29
- package/dist/sessionReadRedactionCapability.d.ts +0 -13
- package/dist/sessionReadRedactionCapability.js +0 -35
package/dist/agentsWireCaps.js
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import { hostEnv } from './hostEnv.js';
|
|
2
|
-
import { ownDataField } from './ownKey.js';
|
|
3
2
|
import { makeEngineWireClient } from './engineWireSdk.js';
|
|
4
3
|
import { frozenSet } from './frozenSet.js';
|
|
5
4
|
import { settleWithinDeadline } from './abortableSleep.js';
|
|
5
|
+
import { engineCapValue, engineCapValueVia, engineCapsGeneration, engineCapsLandingOf, engineCapsSettled, kickEngineCapsProbe } from './engineCapsCache.js';
|
|
6
6
|
import { ruleToolNameVerdictOf } from './protocolSegment.js';
|
|
7
7
|
import { CORE_PROTOCOL_PREFIXES } from './generated/toolNameTables.js';
|
|
8
8
|
import { rosterMountedNames } from './rosterMountedNames.js';
|
|
9
9
|
import { capForDisplay } from './fleetTaskDesc.js';
|
|
10
|
-
import { deniedEntryToolName
|
|
10
|
+
import { deniedEntryToolName } from './engineToolDirectory.js';
|
|
11
|
+
import { assemblyRefusal } from './wireFailureShape.js';
|
|
11
12
|
export const MAX_TASK_AGENTS = 32;
|
|
12
|
-
export const MAX_AGENT_NAME_CHARS = 64;
|
|
13
13
|
export const MAX_AGENT_TEXT_CHARS = 4_096;
|
|
14
14
|
export const MAX_AGENT_SYSTEM_PROMPT_CHARS = 65_536;
|
|
15
|
-
export const MAX_AGENT_TOOLS = 64;
|
|
16
|
-
export const MAX_AGENT_TOOL_NAME_CHARS = 128;
|
|
17
15
|
export const MAX_AGENT_SKILL_CONTENT_CHARS = 1_048_576;
|
|
18
|
-
export const MAX_AGENT_MAX_TURNS = 1_000;
|
|
19
16
|
export const TASK_AGENT_WIRE_FIELDS = [
|
|
20
17
|
'name',
|
|
21
18
|
'whenToUse',
|
|
@@ -120,10 +117,6 @@ export function projectAgentsForWire(defs, deps) {
|
|
|
120
117
|
const name = def.agentType;
|
|
121
118
|
if (typeof name !== 'string' || name.length === 0)
|
|
122
119
|
continue;
|
|
123
|
-
if (name.length > MAX_AGENT_NAME_CHARS) {
|
|
124
|
-
warnings.push(`agents wire: agent name "${name.slice(0, 40)}…" exceeds ${MAX_AGENT_NAME_CHARS} chars — definition skipped`);
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
120
|
if (seen.has(name))
|
|
128
121
|
continue;
|
|
129
122
|
seen.add(name);
|
|
@@ -137,27 +130,19 @@ export function projectAgentsForWire(defs, deps) {
|
|
|
137
130
|
warnings.push(`agents wire: agent "${name}" description truncated to ${MAX_AGENT_TEXT_CHARS} chars`);
|
|
138
131
|
}
|
|
139
132
|
}
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
const kept = list.filter(t => typeof t === 'string' && t.length > 0 && t.length <= MAX_AGENT_TOOL_NAME_CHARS);
|
|
144
|
-
if (kept.length !== list.length) {
|
|
133
|
+
const toolEntries = (list, label) => {
|
|
134
|
+
const entries = list.filter((t) => typeof t === 'string' && t.length > 0);
|
|
135
|
+
if (entries.length !== list.length)
|
|
145
136
|
warnings.push(`agents wire: agent "${name}" ${label} had invalid entries — dropped`);
|
|
146
|
-
|
|
147
|
-
if (kept.length === 0)
|
|
148
|
-
return undefined;
|
|
149
|
-
if (kept.length > MAX_AGENT_TOOLS) {
|
|
150
|
-
warnings.push(`agents wire: agent "${name}" ${label} truncated to ${MAX_AGENT_TOOLS} entries`);
|
|
151
|
-
return kept.slice(0, MAX_AGENT_TOOLS);
|
|
152
|
-
}
|
|
153
|
-
return kept;
|
|
137
|
+
return entries;
|
|
154
138
|
};
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
139
|
+
if (Array.isArray(def.tools))
|
|
140
|
+
item.allowTools = toolEntries(def.tools, 'tools');
|
|
141
|
+
if (Array.isArray(def.disallowedTools)) {
|
|
142
|
+
const denyTools = toolEntries(def.disallowedTools, 'disallowedTools');
|
|
143
|
+
if (denyTools.length > 0)
|
|
144
|
+
item.denyTools = denyTools;
|
|
145
|
+
}
|
|
161
146
|
let whoMemo;
|
|
162
147
|
const whoOf = () => {
|
|
163
148
|
if (whoMemo !== undefined)
|
|
@@ -172,67 +157,29 @@ export function projectAgentsForWire(defs, deps) {
|
|
|
172
157
|
whoMemo = `agent "${name}"${typeof source === 'string' && source.length > 0 ? ` (${capForDisplay(source, 120)})` : ''}`;
|
|
173
158
|
return whoMemo;
|
|
174
159
|
};
|
|
175
|
-
const
|
|
176
|
-
const
|
|
177
|
-
|
|
160
|
+
const rosterInHand = typeof rosterMountedNames(deps.toolRoster) === 'object';
|
|
161
|
+
const flaws = agentToolListFlaws([item], deps.toolRoster).map((f) => {
|
|
162
|
+
if (!rosterInHand || f.list !== 'disallowedTools' || f.kind !== 'retired' || f.currentName === undefined || f.toolName !== undefined)
|
|
163
|
+
return f;
|
|
164
|
+
const to = f.currentName;
|
|
165
|
+
if (item.denyTools !== undefined)
|
|
166
|
+
item.denyTools = item.denyTools.map((e) => (e === f.entry ? to : e));
|
|
167
|
+
return { ...f, rewritten: true };
|
|
168
|
+
});
|
|
178
169
|
if (flaws.length > 0) {
|
|
179
170
|
const who = whoOf();
|
|
180
171
|
toolListFlaws.push(...flaws);
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
if (denyFlaws.length > 0) {
|
|
184
|
-
const what = `its disallowedTools ${denyFlaws.length === 1 ? 'entry' : 'entries'} ${denyFlaws.map(toolListFlawPhrase).join('; ')}`;
|
|
185
|
-
warnings.push(withhold
|
|
186
|
-
? `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.`
|
|
187
|
-
: `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.`);
|
|
188
|
-
}
|
|
189
|
-
if (!withhold) {
|
|
190
|
-
for (const f of flaws) {
|
|
191
|
-
if (f.list !== 'tools')
|
|
192
|
-
continue;
|
|
193
|
-
warnings.push(f.kind === 'unjudged'
|
|
194
|
-
? `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.`
|
|
195
|
-
: `agents wire: ${who}: its tools entry ${toolListFlawPhrase(f)} — tool names are matched exactly, so no tool answers to this entry; it is omitted (newer engines refuse a request whose agent definitions name it). Fix the entry in the agent definition.`);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
if (withhold)
|
|
199
|
-
continue;
|
|
200
|
-
}
|
|
201
|
-
const filterList = (key, label) => {
|
|
202
|
-
const entries = item[key];
|
|
203
|
-
if (entries === undefined)
|
|
204
|
-
return;
|
|
205
|
-
const kept = [];
|
|
206
|
-
for (const entry of entries) {
|
|
207
|
-
if (label === 'tools' && omittedAllowFlaws.has(entry))
|
|
208
|
-
continue;
|
|
209
|
-
if (flawedEntries.has(`${label}\u0000${entry}`)) {
|
|
210
|
-
kept.push(entry);
|
|
172
|
+
for (const f of flaws) {
|
|
173
|
+
if (f.rewritten !== true)
|
|
211
174
|
continue;
|
|
212
|
-
}
|
|
213
|
-
const toolName = label === 'disallowedTools' ? deniedEntryToolName(entry) : entry;
|
|
214
|
-
const reading = toolName === undefined ? 'outside' : mcpEntryReadingOf(toolName, deps.toolDirectory);
|
|
215
|
-
if (reading === 'unanswered') {
|
|
216
|
-
warnings.push(`agents wire: ${whoOf()} ${label} entry ${JSON.stringify(entry)} names no tool this deployment answers to — omitted: no MCP server of that name is declared for this session, so there is nothing to ${label === 'tools' ? 'give' : 'hide'}, and newer engines refuse a request whose agent definitions name such a tool. Remove the entry or configure the server.`);
|
|
217
|
-
continue;
|
|
218
|
-
}
|
|
219
|
-
if (reading === 'unchecked') {
|
|
220
|
-
warnings.push(`agents wire: ${whoOf()} ${label} entry ${JSON.stringify(entry)} could not be checked against the MCP servers this session declares — sent as written; if no such server is declared, newer engines refuse the whole request until the entry is removed.`);
|
|
221
|
-
}
|
|
222
|
-
kept.push(entry);
|
|
223
|
-
}
|
|
224
|
-
if (key === 'allowTools') {
|
|
225
|
-
item.allowTools = kept;
|
|
226
|
-
}
|
|
227
|
-
else if (kept.length > 0) {
|
|
228
|
-
item.denyTools = kept;
|
|
175
|
+
warnings.push(`agents wire: ${who}: its disallowedTools entry ${toolListFlawPhrase(f)} — rewritten to ${JSON.stringify(f.currentName)} for this run (this run's tools include none named ${JSON.stringify(f.entry)}). Update the entry in the agent definition.`);
|
|
229
176
|
}
|
|
230
|
-
|
|
231
|
-
|
|
177
|
+
for (const f of flaws) {
|
|
178
|
+
if (f.list !== 'tools')
|
|
179
|
+
continue;
|
|
180
|
+
warnings.push(`agents wire: ${who}: its tools entry ${toolListFlawPhrase(f)} — sent as written; tool names are matched exactly, so this entry gives the agent nothing unless this run has a tool with exactly that name. Fix the entry in the agent definition.`);
|
|
232
181
|
}
|
|
233
|
-
}
|
|
234
|
-
filterList('denyTools', 'disallowedTools');
|
|
235
|
-
filterList('allowTools', 'tools');
|
|
182
|
+
}
|
|
236
183
|
if (def.memory !== undefined) {
|
|
237
184
|
if (typeof def.memory === 'string' && AGENT_MEMORY_WORDS.has(def.memory)) {
|
|
238
185
|
item.memory = { scopes: [`agent:${name}`], writeScope: `agent:${name}` };
|
|
@@ -297,62 +244,58 @@ export function projectAgentsForWire(defs, deps) {
|
|
|
297
244
|
item.systemPrompt = prompt;
|
|
298
245
|
}
|
|
299
246
|
}
|
|
300
|
-
if (def.maxTurns !== undefined)
|
|
301
|
-
|
|
302
|
-
Number.isInteger(def.maxTurns) &&
|
|
303
|
-
def.maxTurns >= 1 &&
|
|
304
|
-
def.maxTurns <= MAX_AGENT_MAX_TURNS) {
|
|
305
|
-
item.maxTurns = def.maxTurns;
|
|
306
|
-
}
|
|
307
|
-
else {
|
|
308
|
-
warnings.push(`agents wire: agent "${name}" maxTurns ${String(def.maxTurns)} out of range (1..${MAX_AGENT_MAX_TURNS}) — dropped`);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
247
|
+
if (def.maxTurns !== undefined)
|
|
248
|
+
item.maxTurns = def.maxTurns;
|
|
311
249
|
out.push(item);
|
|
312
250
|
}
|
|
313
251
|
return { agents: out.length > 0 ? out : undefined, warnings, ...(toolListFlaws.length > 0 ? { toolListFlaws } : {}) };
|
|
314
252
|
}
|
|
253
|
+
function taskAgentsVerdictOf(v) {
|
|
254
|
+
switch (v.kind) {
|
|
255
|
+
case 'value':
|
|
256
|
+
return v.value === true;
|
|
257
|
+
case 'unobserved':
|
|
258
|
+
case 'unreadable':
|
|
259
|
+
return undefined;
|
|
260
|
+
default:
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
const TASK_AGENTS_CAPS_SETTLE_MS = 3000;
|
|
315
265
|
export async function engineSupportsTaskAgents(baseUrl, opts) {
|
|
266
|
+
const budget = opts?.timeoutMs ?? TASK_AGENTS_CAPS_SETTLE_MS;
|
|
316
267
|
if (opts?.client !== undefined) {
|
|
317
268
|
const injected = opts.client;
|
|
318
269
|
if (typeof injected?.capabilities !== 'function')
|
|
319
270
|
return undefined;
|
|
320
|
-
|
|
321
|
-
|
|
271
|
+
return taskAgentsVerdictOf(await engineCapValueVia(undefined, 'taskAgents', async () => {
|
|
272
|
+
const got = await settleWithinDeadline(budget, (signal) => injected.capabilities({ signal }));
|
|
273
|
+
if (got.kind !== 'value')
|
|
274
|
+
throw new Error('capabilities probe did not settle within its budget');
|
|
275
|
+
return got.value;
|
|
276
|
+
}));
|
|
322
277
|
}
|
|
323
278
|
const client = makeEngineWireClient({
|
|
324
279
|
baseUrl,
|
|
325
280
|
...(opts?.authToken ? { token: opts.authToken } : {}),
|
|
326
281
|
...(opts?.principal ? { principal: opts.principal } : {}),
|
|
327
|
-
timeoutMs:
|
|
282
|
+
timeoutMs: budget,
|
|
328
283
|
...(opts?.fetchImpl ? { fetchImpl: opts.fetchImpl } : {}),
|
|
329
284
|
});
|
|
330
285
|
if (!client)
|
|
331
286
|
return undefined;
|
|
332
|
-
|
|
333
|
-
const caps = await client.capabilities();
|
|
334
|
-
return taskAgentsOf(caps);
|
|
335
|
-
}
|
|
336
|
-
catch {
|
|
337
|
-
return undefined;
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
function taskAgentsOf(caps) {
|
|
341
|
-
if (caps === null || typeof caps !== 'object')
|
|
342
|
-
return false;
|
|
343
|
-
try {
|
|
344
|
-
return ownDataField(caps, 'taskAgents') === true;
|
|
345
|
-
}
|
|
346
|
-
catch {
|
|
347
|
-
return undefined;
|
|
348
|
-
}
|
|
287
|
+
return taskAgentsVerdictOf(await engineCapValueVia(undefined, 'taskAgents', () => client.capabilities()));
|
|
349
288
|
}
|
|
350
289
|
let activeProjector = null;
|
|
351
290
|
let preparedKey = null;
|
|
291
|
+
let preparedCapsGen = null;
|
|
352
292
|
let preparedPromise = null;
|
|
353
293
|
let payload;
|
|
354
|
-
let
|
|
355
|
-
|
|
294
|
+
let currentGeneration = null;
|
|
295
|
+
function concludeGeneration(generation, outcome) {
|
|
296
|
+
if (generation !== null && preparedPromise === generation && currentGeneration !== null)
|
|
297
|
+
currentGeneration.outcome = outcome;
|
|
298
|
+
}
|
|
356
299
|
const emittedWarnings = new Set();
|
|
357
300
|
function warnOnce(msg) {
|
|
358
301
|
if (emittedWarnings.has(msg))
|
|
@@ -360,45 +303,60 @@ function warnOnce(msg) {
|
|
|
360
303
|
emittedWarnings.add(msg);
|
|
361
304
|
console.error(`[sema] ${msg}`);
|
|
362
305
|
}
|
|
306
|
+
function capsVerdictAt(baseUrl) {
|
|
307
|
+
return baseUrl === null ? undefined : taskAgentsVerdictOf(engineCapValue(baseUrl, 'taskAgents'));
|
|
308
|
+
}
|
|
309
|
+
function capsSettledAt(baseUrl) {
|
|
310
|
+
return baseUrl === null ? Promise.resolve() : engineCapsSettled(baseUrl, { withinMs: TASK_AGENTS_CAPS_SETTLE_MS });
|
|
311
|
+
}
|
|
312
|
+
function kickTaskAgentsCaps(cfg) {
|
|
313
|
+
if (engineCapsLandingOf(cfg.baseUrl).kind !== 'not_landed')
|
|
314
|
+
return;
|
|
315
|
+
const client = makeEngineWireClient({
|
|
316
|
+
baseUrl: cfg.baseUrl,
|
|
317
|
+
...(cfg.authToken ? { token: cfg.authToken } : {}),
|
|
318
|
+
...(cfg.principal ? { principal: cfg.principal } : {}),
|
|
319
|
+
timeoutMs: TASK_AGENTS_CAPS_SETTLE_MS,
|
|
320
|
+
});
|
|
321
|
+
if (!client)
|
|
322
|
+
return;
|
|
323
|
+
kickEngineCapsProbe(cfg.baseUrl, () => client.capabilities());
|
|
324
|
+
}
|
|
325
|
+
function watchCapsVerdict(baseUrl) {
|
|
326
|
+
void engineCapsSettled(baseUrl).then(() => {
|
|
327
|
+
if (preparedKey !== baseUrl || capsVerdictAt(baseUrl) !== false)
|
|
328
|
+
return;
|
|
329
|
+
payload = undefined;
|
|
330
|
+
concludeGeneration(preparedPromise, 'ok');
|
|
331
|
+
currentGeneration?.settle();
|
|
332
|
+
});
|
|
333
|
+
}
|
|
363
334
|
function applyProjectionIfCurrent(generation, projected) {
|
|
364
335
|
if (generation === null || preparedPromise !== generation)
|
|
365
336
|
return false;
|
|
366
|
-
const accepted =
|
|
337
|
+
const accepted = capsVerdictAt(preparedKey) !== false;
|
|
367
338
|
if (accepted) {
|
|
368
339
|
for (const w of projected.warnings)
|
|
369
340
|
warnOnce(w);
|
|
370
341
|
payload = projected.agents;
|
|
371
342
|
}
|
|
372
|
-
|
|
343
|
+
else {
|
|
344
|
+
payload = undefined;
|
|
345
|
+
}
|
|
346
|
+
concludeGeneration(generation, 'ok');
|
|
347
|
+
currentGeneration?.settle();
|
|
373
348
|
return accepted;
|
|
374
349
|
}
|
|
375
|
-
function
|
|
376
|
-
const land = (verdict) => {
|
|
377
|
-
if (capsVerdict !== probe)
|
|
378
|
-
return verdict;
|
|
379
|
-
capsVerdict = verdict;
|
|
380
|
-
if (verdict === false) {
|
|
381
|
-
payload = undefined;
|
|
382
|
-
settleGeneration?.();
|
|
383
|
-
}
|
|
384
|
-
return verdict;
|
|
385
|
-
};
|
|
386
|
-
const probe = engineSupportsTaskAgents(cfg.baseUrl, {
|
|
387
|
-
authToken: cfg.authToken,
|
|
388
|
-
principal: cfg.principal,
|
|
389
|
-
}).then(land, () => land(undefined));
|
|
390
|
-
capsVerdict = probe;
|
|
391
|
-
return probe;
|
|
392
|
-
}
|
|
393
|
-
function capsSettled() {
|
|
394
|
-
return capsVerdict instanceof Promise ? capsVerdict : Promise.resolve();
|
|
395
|
-
}
|
|
396
|
-
async function runPrepare(cfg, projector, probe, generation) {
|
|
350
|
+
async function runPrepare(cfg, projector, generation) {
|
|
397
351
|
try {
|
|
398
|
-
const [
|
|
399
|
-
if (
|
|
400
|
-
if (
|
|
401
|
-
|
|
352
|
+
const [, projected] = await Promise.all([capsSettledAt(cfg.baseUrl), projector()]);
|
|
353
|
+
if (capsVerdictAt(cfg.baseUrl) === false) {
|
|
354
|
+
if (preparedKey === cfg.baseUrl) {
|
|
355
|
+
payload = undefined;
|
|
356
|
+
concludeGeneration(generation, 'ok');
|
|
357
|
+
if (projected.agents) {
|
|
358
|
+
warnOnce(`agents wire: this engine does not support per-task custom agents (capabilities.taskAgents is not true: the engine does not report it, or this deployment turns it off, for example a multi-tenant one; this client cannot tell which) — ${projected.agents.length} custom agent definition(s) will NOT be sent`);
|
|
359
|
+
}
|
|
402
360
|
}
|
|
403
361
|
return;
|
|
404
362
|
}
|
|
@@ -411,29 +369,33 @@ async function runPrepare(cfg, projector, probe, generation) {
|
|
|
411
369
|
catch (e) {
|
|
412
370
|
if (preparedPromise === generation)
|
|
413
371
|
payload = undefined;
|
|
372
|
+
concludeGeneration(generation, 'failed');
|
|
414
373
|
if (hostEnv().SEMA_DEBUG) {
|
|
415
|
-
console.error('[sema] agents wire prepare
|
|
374
|
+
console.error('[sema] agents wire prepare failed (the readiness gate refuses this turn):', e);
|
|
416
375
|
}
|
|
417
376
|
}
|
|
418
377
|
}
|
|
419
378
|
export function prepareTaskAgentsWireWith(cfg, projector) {
|
|
420
379
|
const key = cfg.baseUrl;
|
|
421
|
-
|
|
380
|
+
kickTaskAgentsCaps(cfg);
|
|
381
|
+
const capsGen = engineCapsGeneration(key);
|
|
382
|
+
if (preparedPromise && preparedKey === key && preparedCapsGen === capsGen)
|
|
422
383
|
return preparedPromise;
|
|
423
384
|
preparedKey = key;
|
|
385
|
+
preparedCapsGen = capsGen;
|
|
424
386
|
activeProjector = projector;
|
|
425
|
-
|
|
426
|
-
return startGeneration(generation => runPrepare(cfg, projector,
|
|
387
|
+
watchCapsVerdict(key);
|
|
388
|
+
return startGeneration(generation => runPrepare(cfg, projector, generation));
|
|
427
389
|
}
|
|
428
390
|
function startGeneration(run) {
|
|
429
391
|
let settle;
|
|
430
392
|
const generation = new Promise(resolve => {
|
|
431
393
|
settle = resolve;
|
|
432
394
|
});
|
|
433
|
-
const superseded =
|
|
395
|
+
const superseded = currentGeneration;
|
|
434
396
|
preparedPromise = generation;
|
|
435
|
-
|
|
436
|
-
superseded?.();
|
|
397
|
+
currentGeneration = { settle, outcome: undefined };
|
|
398
|
+
superseded?.settle();
|
|
437
399
|
void run(generation).then(settle, settle);
|
|
438
400
|
return generation;
|
|
439
401
|
}
|
|
@@ -445,28 +407,36 @@ export function invalidateTaskAgentsWire() {
|
|
|
445
407
|
return startGeneration(generation => runReproject(projector, generation));
|
|
446
408
|
}
|
|
447
409
|
async function runReproject(projector, generation) {
|
|
410
|
+
const base = preparedKey;
|
|
448
411
|
try {
|
|
449
412
|
let projected;
|
|
450
413
|
try {
|
|
451
414
|
projected = await projector();
|
|
452
415
|
}
|
|
453
416
|
catch (e) {
|
|
417
|
+
concludeGeneration(generation, 'failed');
|
|
454
418
|
if (hostEnv().SEMA_DEBUG) {
|
|
455
|
-
console.error('[sema] agents wire re-project
|
|
419
|
+
console.error('[sema] agents wire re-project failed (the readiness gate refuses until a projection succeeds):', e);
|
|
456
420
|
}
|
|
457
421
|
return;
|
|
458
422
|
}
|
|
459
|
-
await
|
|
423
|
+
await capsSettledAt(base);
|
|
460
424
|
applyProjectionIfCurrent(generation, projected);
|
|
461
425
|
}
|
|
462
426
|
catch {
|
|
427
|
+
concludeGeneration(generation, 'failed');
|
|
463
428
|
}
|
|
464
429
|
}
|
|
465
430
|
export async function awaitTaskAgentsWire(timeoutMs = 4000) {
|
|
466
431
|
if (!preparedPromise)
|
|
467
|
-
return;
|
|
468
|
-
if (
|
|
469
|
-
return;
|
|
432
|
+
return taskAgentsReady();
|
|
433
|
+
if (capsVerdictAt(preparedKey) === false)
|
|
434
|
+
return taskAgentsReady();
|
|
435
|
+
const projector = activeProjector;
|
|
436
|
+
if (currentGeneration?.outcome === 'failed' && projector !== null) {
|
|
437
|
+
payload = undefined;
|
|
438
|
+
void startGeneration(generation => runReproject(projector, generation));
|
|
439
|
+
}
|
|
470
440
|
let timeoutHandle;
|
|
471
441
|
let timedOut = false;
|
|
472
442
|
const deadline = new Promise(resolve => {
|
|
@@ -486,33 +456,56 @@ export async function awaitTaskAgentsWire(timeoutMs = 4000) {
|
|
|
486
456
|
if (timeoutHandle !== undefined)
|
|
487
457
|
clearTimeout(timeoutHandle);
|
|
488
458
|
}
|
|
459
|
+
if (preparedPromise === null || capsVerdictAt(preparedKey) === false)
|
|
460
|
+
return taskAgentsReady();
|
|
461
|
+
const outcome = currentGeneration?.outcome;
|
|
462
|
+
if (outcome === 'ok')
|
|
463
|
+
return taskAgentsReady();
|
|
464
|
+
if (outcome === 'failed')
|
|
465
|
+
return Object.freeze({ ok: false, refusal: assemblyRefusal('agents_projection_failed') });
|
|
466
|
+
kickTaskAgentsRefresh();
|
|
467
|
+
return Object.freeze({ ok: false, refusal: assemblyRefusal('agents_not_ready') });
|
|
468
|
+
}
|
|
469
|
+
function taskAgentsReady() {
|
|
470
|
+
return Object.freeze({ ok: true });
|
|
471
|
+
}
|
|
472
|
+
function kickTaskAgentsRefresh() {
|
|
473
|
+
const projector = activeProjector;
|
|
474
|
+
if (!preparedPromise || projector === null)
|
|
475
|
+
return false;
|
|
476
|
+
const generation = preparedPromise;
|
|
477
|
+
const base = preparedKey;
|
|
478
|
+
let refreshing;
|
|
479
|
+
try {
|
|
480
|
+
refreshing = projector();
|
|
481
|
+
}
|
|
482
|
+
catch {
|
|
483
|
+
return false;
|
|
484
|
+
}
|
|
485
|
+
void refreshing
|
|
486
|
+
.then(async (p) => {
|
|
487
|
+
await capsSettledAt(base);
|
|
488
|
+
applyProjectionIfCurrent(generation, p);
|
|
489
|
+
})
|
|
490
|
+
.catch(() => { });
|
|
491
|
+
return true;
|
|
489
492
|
}
|
|
490
493
|
export function taskAgentsField() {
|
|
491
|
-
const
|
|
492
|
-
if (
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
try {
|
|
496
|
-
refreshing = activeProjector();
|
|
497
|
-
}
|
|
498
|
-
catch {
|
|
499
|
-
return current ? { agents: current } : {};
|
|
500
|
-
}
|
|
501
|
-
void refreshing
|
|
502
|
-
.then(async (p) => {
|
|
503
|
-
await capsSettled();
|
|
504
|
-
applyProjectionIfCurrent(generation, p);
|
|
505
|
-
})
|
|
506
|
-
.catch(() => { });
|
|
494
|
+
const base = preparedKey;
|
|
495
|
+
if (capsVerdictAt(base) === false) {
|
|
496
|
+
payload = undefined;
|
|
497
|
+
return {};
|
|
507
498
|
}
|
|
499
|
+
const current = payload;
|
|
500
|
+
kickTaskAgentsRefresh();
|
|
508
501
|
return current ? { agents: current } : {};
|
|
509
502
|
}
|
|
510
503
|
export function _resetAgentsWireForTest() {
|
|
511
504
|
activeProjector = null;
|
|
512
505
|
preparedKey = null;
|
|
506
|
+
preparedCapsGen = null;
|
|
513
507
|
preparedPromise = null;
|
|
514
|
-
|
|
508
|
+
currentGeneration = null;
|
|
515
509
|
payload = undefined;
|
|
516
|
-
capsVerdict = undefined;
|
|
517
510
|
emittedWarnings.clear();
|
|
518
511
|
}
|
|
@@ -9,9 +9,5 @@ export type ApprovalDecidedByReading = {
|
|
|
9
9
|
value: true;
|
|
10
10
|
};
|
|
11
11
|
export declare function projectApprovalDecidedByCapability(caps: unknown): ApprovalDecidedByReading | undefined;
|
|
12
|
-
export declare function noteEngineCapsForApprovalDecidedBy(baseUrl: string, caps: unknown, opts?: {
|
|
13
|
-
generation?: number;
|
|
14
|
-
}): void;
|
|
15
12
|
export declare function observedApprovalDecidedBy(baseUrl?: string | undefined): ApprovalDecidedByReading;
|
|
16
13
|
export declare function approvalDecidedByAdmitted(reading: ApprovalDecidedByReading | undefined): boolean;
|
|
17
|
-
export declare function __resetApprovalDecidedByReadingsForTests(): void;
|
|
@@ -18,9 +18,6 @@ const reader = createEngineCapReader({
|
|
|
18
18
|
name: 'approvalDecidedBy',
|
|
19
19
|
project: projectApprovalDecidedByCapability,
|
|
20
20
|
});
|
|
21
|
-
export function noteEngineCapsForApprovalDecidedBy(baseUrl, caps, opts) {
|
|
22
|
-
reader.note(baseUrl, caps, opts);
|
|
23
|
-
}
|
|
24
21
|
export function observedApprovalDecidedBy(baseUrl = engineWireTarget()?.baseUrl) {
|
|
25
22
|
return reader.observed(baseUrl);
|
|
26
23
|
}
|
|
@@ -36,6 +33,3 @@ export function approvalDecidedByAdmitted(reading) {
|
|
|
36
33
|
return false;
|
|
37
34
|
}
|
|
38
35
|
}
|
|
39
|
-
export function __resetApprovalDecidedByReadingsForTests() {
|
|
40
|
-
reader.__resetForTests();
|
|
41
|
-
}
|
|
@@ -9,10 +9,6 @@ export type ApprovalsStreamLiveReading = {
|
|
|
9
9
|
live: boolean;
|
|
10
10
|
};
|
|
11
11
|
export declare function projectApprovalsStreamLiveCapability(caps: unknown): ApprovalsStreamLiveReading | undefined;
|
|
12
|
-
export declare function noteEngineCapsForApprovalsStreamLive(baseUrl: string, caps: unknown, opts?: {
|
|
13
|
-
generation?: number;
|
|
14
|
-
}): void;
|
|
15
12
|
export declare function observedApprovalsStreamLive(baseUrl?: string | undefined): ApprovalsStreamLiveReading;
|
|
16
13
|
export declare function livePendingNeedsReconcile(reading: ApprovalsStreamLiveReading): boolean;
|
|
17
14
|
export declare function approvalsStreamLiveDoctorDetail(reading: ApprovalsStreamLiveReading): string;
|
|
18
|
-
export declare function __resetApprovalsStreamLiveReadingsForTests(): void;
|
|
@@ -22,9 +22,6 @@ const reader = createEngineCapReader({
|
|
|
22
22
|
name: 'approvalsStreamLive',
|
|
23
23
|
project: projectApprovalsStreamLiveCapability,
|
|
24
24
|
});
|
|
25
|
-
export function noteEngineCapsForApprovalsStreamLive(baseUrl, caps, opts) {
|
|
26
|
-
reader.note(baseUrl, caps, opts);
|
|
27
|
-
}
|
|
28
25
|
export function observedApprovalsStreamLive(baseUrl = engineWireTarget()?.baseUrl) {
|
|
29
26
|
return reader.observed(baseUrl);
|
|
30
27
|
}
|
|
@@ -45,6 +42,3 @@ export function approvalsStreamLiveDoctorDetail(reading) {
|
|
|
45
42
|
: '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';
|
|
46
43
|
}
|
|
47
44
|
}
|
|
48
|
-
export function __resetApprovalsStreamLiveReadingsForTests() {
|
|
49
|
-
reader.__resetForTests();
|
|
50
|
-
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { AgentClient } from '@sema-agent/sdk';
|
|
2
|
+
export type AssistantInboxVerb = Pick<AgentClient['assistant'], 'inbox'>;
|
|
3
|
+
export interface AssistantInboxEntry {
|
|
4
|
+
readonly sessionId: string;
|
|
5
|
+
readonly scope?: string;
|
|
6
|
+
readonly gateKind?: string;
|
|
7
|
+
readonly severity?: 1 | 2 | 3 | 4 | 5;
|
|
8
|
+
readonly spentMicroUsd?: number;
|
|
9
|
+
readonly deadlineMs?: number;
|
|
10
|
+
readonly createdAtMs?: number;
|
|
11
|
+
readonly objective?: string;
|
|
12
|
+
readonly inputPreview?: string;
|
|
13
|
+
readonly requiresRealApproval?: true;
|
|
14
|
+
readonly mandated?: true;
|
|
15
|
+
readonly hasBidiControls?: true;
|
|
16
|
+
}
|
|
17
|
+
export type AssistantInboxUnavailableReason = 'unauthorized' | 'unreadable' | 'failed';
|
|
18
|
+
export type AssistantInboxReading = {
|
|
19
|
+
readonly kind: 'present';
|
|
20
|
+
readonly entries: readonly AssistantInboxEntry[];
|
|
21
|
+
readonly dropped: number;
|
|
22
|
+
} | {
|
|
23
|
+
readonly kind: 'unavailable';
|
|
24
|
+
readonly reason: AssistantInboxUnavailableReason;
|
|
25
|
+
readonly status?: number;
|
|
26
|
+
readonly errorCode?: string;
|
|
27
|
+
} | {
|
|
28
|
+
readonly kind: 'not-reported';
|
|
29
|
+
readonly via: 'lane-absent' | 'unarmed';
|
|
30
|
+
};
|
|
31
|
+
export declare function isAssistantLaneAbsent(err: {} | null | undefined): boolean;
|
|
32
|
+
export declare function readAssistantInbox(assistant: AssistantInboxVerb | null | undefined, opts?: {
|
|
33
|
+
readonly signal?: AbortSignal | undefined;
|
|
34
|
+
}): Promise<AssistantInboxReading>;
|