@sema-agent/client-core 0.98.0 → 0.100.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +376 -0
- package/README.md +61 -35
- package/dist/adapt/arms.js +120 -55
- package/dist/adapt/panelTasks.d.ts +3 -2
- package/dist/adapt/panelTasks.js +34 -11
- package/dist/adapt/textStream.d.ts +1 -1
- package/dist/adapt/textStream.js +51 -28
- package/dist/adapter/activeRunSelfHeal.d.ts +11 -3
- package/dist/adapter/activeRunSelfHeal.js +210 -294
- package/dist/adapter/downstream/eventToSdkMessage.d.ts +25 -6
- package/dist/adapter/downstream/eventToSdkMessage.js +176 -12
- package/dist/adapter/downstream/terminalToSdkResult.js +10 -0
- package/dist/adapter/downstream/wiringManifestView.d.ts +3 -1
- package/dist/adapter/downstream/wiringManifestView.js +1 -0
- package/dist/adapter/runStream.js +82 -40
- package/dist/adapter/types.d.ts +2 -0
- package/dist/adapter/types.js +2 -1
- package/dist/agentSession/engineSessionBackgroundStop.js +16 -8
- package/dist/agentsWireCaps.d.ts +7 -3
- package/dist/agentsWireCaps.js +133 -39
- package/dist/cloudConfigWireCaps.d.ts +10 -1
- package/dist/cloudConfigWireCaps.js +181 -65
- package/dist/compactionStatus.d.ts +34 -0
- package/dist/compactionStatus.js +196 -0
- package/dist/controlRouter.d.ts +4 -2
- package/dist/controlRouter.js +39 -51
- package/dist/coreValuePorts.d.ts +26 -1
- package/dist/coreValuePorts.js +10 -0
- package/dist/corruptSessionCopy.d.ts +2 -1
- package/dist/corruptSessionCopy.js +3 -3
- package/dist/decideFailureNote.js +3 -3
- package/dist/declared/supportFloorDeclared.js +1 -1
- package/dist/detachWire.js +3 -2
- package/dist/devicesFace.d.ts +34 -0
- package/dist/devicesFace.js +90 -0
- package/dist/displayUntrusted.d.ts +1 -0
- package/dist/displayUntrusted.js +153 -5
- package/dist/engineAgentPanelStore.d.ts +14 -4
- package/dist/engineAgentPanelStore.js +14 -0
- package/dist/engineCapReader.d.ts +2 -1
- package/dist/engineCapReader.js +7 -5
- package/dist/engineCapsCache.d.ts +8 -0
- package/dist/engineCapsCache.js +59 -6
- package/dist/engineCapsChange.d.ts +2 -0
- package/dist/engineCapsChange.js +9 -0
- package/dist/engineErrorCodes.d.ts +11 -2
- package/dist/engineErrorCodes.js +11 -12
- package/dist/engineRowRef.js +4 -0
- package/dist/engineSessionMessages.d.ts +1 -0
- package/dist/engineSessionMessages.js +7 -1
- package/dist/engineTargetSeat.d.ts +27 -0
- package/dist/engineTargetSeat.js +199 -0
- package/dist/engineToolDirectory.d.ts +3 -0
- package/dist/engineToolDirectory.js +4 -2
- package/dist/engineWireFor.js +3 -8
- package/dist/env/uiLanguage.d.ts +2 -1
- package/dist/env/uiLanguage.js +3 -2
- package/dist/eventLeg.d.ts +7 -5
- package/dist/eventLeg.js +68 -49
- package/dist/fileHistoryCaptureCapability.d.ts +2 -4
- package/dist/fileHistoryCaptureCapability.js +12 -22
- package/dist/fileHistoryLegNotice.d.ts +2 -1
- package/dist/fileHistoryLegNotice.js +3 -3
- package/dist/frameBinding.d.ts +3 -0
- package/dist/frameBinding.js +12 -0
- package/dist/gateOutcome.js +16 -2
- package/dist/gateVocabulary.d.ts +8 -7
- package/dist/gateVocabulary.js +71 -73
- package/dist/generated/engineFactTables.d.ts +18 -1
- package/dist/generated/engineFactTables.js +56 -0
- package/dist/generated/engineNoticeTables.js +12 -3
- package/dist/generated/settingsSchemaFns.d.ts +18 -0
- package/dist/generated/settingsSchemaFns.js +70 -0
- package/dist/generated/settingsSchemaHooksClassifier.d.ts +2 -0
- package/dist/generated/settingsSchemaHooksClassifier.js +254 -0
- package/dist/generated/settingsSchemaMcpRequestEntry.d.ts +1 -0
- package/dist/generated/settingsSchemaMcpRequestEntry.js +162 -0
- package/dist/generated/settingsSchemaTables.d.ts +2 -0
- package/dist/generated/settingsSchemaTables.js +9 -0
- package/dist/generated/settingsSchemaTypes.d.ts +133 -0
- package/dist/generated/settingsSchemaTypes.js +1 -0
- package/dist/hitl/allowRuleShadow.d.ts +2 -1
- package/dist/hitl/allowRuleShadow.js +18 -15
- package/dist/hitl/approvalCardReasons.d.ts +3 -2
- package/dist/hitl/approvalCardReasons.js +29 -30
- package/dist/hitl/approvalHolds.d.ts +17 -0
- package/dist/hitl/approvalHolds.js +114 -29
- package/dist/hitl/askClassPair.d.ts +2 -2
- package/dist/hitl/askClassPair.js +16 -0
- package/dist/hitl/askGateWire.js +2 -1
- package/dist/hitl/askSettlementLine.d.ts +14 -4
- package/dist/hitl/askSettlementLine.js +67 -47
- package/dist/hitl/attributionLadder.d.ts +23 -0
- package/dist/hitl/attributionLadder.js +67 -0
- package/dist/hitl/automaticAnswerVerdict.d.ts +2 -1
- package/dist/hitl/automaticAnswerVerdict.js +8 -8
- package/dist/hitl/crashConvergedNotice.d.ts +5 -4
- package/dist/hitl/crashConvergedNotice.js +28 -41
- package/dist/hitl/decisionLedger.d.ts +55 -0
- package/dist/hitl/decisionLedger.js +156 -0
- package/dist/hitl/decisionRefusal.d.ts +1 -0
- package/dist/hitl/decisionRefusal.js +1 -1
- package/dist/hitl/decisionSend.d.ts +113 -0
- package/dist/hitl/decisionSend.js +579 -0
- package/dist/hitl/frameRouter.js +7 -8
- package/dist/hitl/hitlBridge.d.ts +1 -0
- package/dist/hitl/hitlBridge.js +21 -9
- package/dist/hitl/persistedRulesWire.d.ts +6 -5
- package/dist/hitl/persistedRulesWire.js +55 -73
- package/dist/hitl/planReviewWire.d.ts +5 -0
- package/dist/hitl/planReviewWire.js +53 -76
- package/dist/hitl/sessionPolicyDeliverable.d.ts +2 -0
- package/dist/hitl/sessionPolicyDeliverable.js +49 -9
- package/dist/hitl/sessionPolicyWire.d.ts +2 -1
- package/dist/hitl/sessionPolicyWire.js +23 -24
- package/dist/hitl/suspendedReopen.d.ts +2 -1
- package/dist/hitl/suspendedReopen.js +7 -10
- package/dist/hitl/toolApprovalWire.d.ts +17 -5
- package/dist/hitl/toolApprovalWire.js +120 -147
- package/dist/hooksWireCaps.js +145 -56
- package/dist/host.d.ts +21 -0
- package/dist/hostTurnSettings.d.ts +110 -0
- package/dist/hostTurnSettings.js +692 -0
- package/dist/humanTurn.d.ts +15 -1
- package/dist/humanTurn.js +100 -12
- package/dist/humanTurnRead.d.ts +2 -0
- package/dist/humanTurnRead.js +22 -1
- package/dist/i18n/messages.en.d.ts +713 -0
- package/dist/i18n/messages.en.js +713 -0
- package/dist/i18n/messages.zh.js +854 -1
- package/dist/index.d.ts +45 -13
- package/dist/index.js +27 -9
- package/dist/inheritEnvCapability.d.ts +4 -2
- package/dist/inheritEnvCapability.js +12 -5
- package/dist/inheritEnvWire.d.ts +3 -2
- package/dist/inheritEnvWire.js +14 -16
- package/dist/injectionLaneNotice.d.ts +5 -0
- package/dist/injectionLaneNotice.js +46 -0
- package/dist/interactiveHalt.js +17 -6
- package/dist/liveModelCatalog.d.ts +2 -1
- package/dist/liveModelCatalog.js +14 -8
- package/dist/mcpPanel.d.ts +10 -1
- package/dist/mcpPanel.js +42 -13
- package/dist/mcpProbeCapability.d.ts +2 -1
- package/dist/mcpProbeCapability.js +7 -11
- package/dist/mcpProbeWire.d.ts +3 -1
- package/dist/mcpProbeWire.js +5 -0
- package/dist/mcpReconnect.js +2 -2
- package/dist/mcpToolToggles.d.ts +6 -0
- package/dist/mcpToolToggles.js +46 -0
- package/dist/mcpWireCaps.d.ts +43 -3
- package/dist/mcpWireCaps.js +194 -59
- package/dist/mcpWireTransport.d.ts +4 -0
- package/dist/mcpWireTransport.js +18 -0
- package/dist/memoryEntriesWire.js +5 -10
- package/dist/model/onboardJudgement.d.ts +93 -0
- package/dist/model/onboardJudgement.js +415 -0
- package/dist/model/tierVocabulary.d.ts +2 -0
- package/dist/model/tierVocabulary.js +17 -5
- package/dist/modelCapabilityProbe.d.ts +65 -0
- package/dist/modelCapabilityProbe.js +601 -0
- package/dist/modelIdentityResolvability.d.ts +5 -0
- package/dist/modelIdentityResolvability.js +49 -22
- package/dist/ownKey.d.ts +33 -0
- package/dist/ownKey.js +109 -0
- package/dist/panelReduce.d.ts +11 -1
- package/dist/panelReduce.js +95 -16
- package/dist/panelStateHolder.d.ts +1 -0
- package/dist/panelStateHolder.js +10 -1
- package/dist/permissionRuleIssue.d.ts +2 -1
- package/dist/permissionRuleIssue.js +23 -20
- package/dist/permissionRulesWriteCapability.d.ts +2 -1
- package/dist/permissionRulesWriteCapability.js +8 -6
- package/dist/pluginHooksWire.d.ts +46 -3
- package/dist/pluginHooksWire.js +220 -12
- package/dist/prepareRefusal.d.ts +8 -0
- package/dist/prepareRefusal.js +72 -0
- package/dist/printModelStatus.d.ts +63 -0
- package/dist/printModelStatus.js +155 -0
- package/dist/request/taskRequest.d.ts +16 -10
- package/dist/request/taskRequest.js +195 -58
- package/dist/resumeRefusalCopy.d.ts +14 -9
- package/dist/resumeRefusalCopy.js +89 -144
- package/dist/retryStatus.d.ts +55 -0
- package/dist/retryStatus.js +155 -19
- package/dist/ruleRefusalSentence.d.ts +4 -0
- package/dist/ruleRefusalSentence.js +58 -0
- package/dist/sandboxWire.d.ts +2 -1
- package/dist/sandboxWire.js +55 -21
- package/dist/scenarioRefusal.d.ts +10 -0
- package/dist/scenarioRefusal.js +111 -0
- package/dist/seam.d.ts +48 -9
- package/dist/seam.js +54 -5
- package/dist/seatContract.d.ts +272 -14
- package/dist/seatContract.js +711 -23
- package/dist/selfOrchestrationDenial.js +7 -19
- package/dist/sessionIdSegment.d.ts +6 -0
- package/dist/sessionIdSegment.js +24 -0
- package/dist/sessionMemoryStatus.js +6 -11
- package/dist/sessionPolicyCapability.d.ts +2 -1
- package/dist/sessionPolicyCapability.js +8 -6
- package/dist/settingsCredentialKeyPaths.d.ts +8 -0
- package/dist/settingsCredentialKeyPaths.js +219 -0
- package/dist/settingsHooksSalvage.d.ts +44 -0
- package/dist/settingsHooksSalvage.js +211 -0
- package/dist/skillToolListsCapability.d.ts +2 -1
- package/dist/skillToolListsCapability.js +8 -6
- package/dist/skillsWireCaps.d.ts +0 -3
- package/dist/skillsWireCaps.js +1 -2
- package/dist/sseIdleTriage.js +3 -2
- package/dist/subagent/engineSubagentResume.js +15 -9
- package/dist/subagentContentStore.d.ts +4 -0
- package/dist/subagentContentStore.js +157 -27
- package/dist/toolHistoryMismatch.js +3 -2
- package/dist/toolRoster.d.ts +3 -2
- package/dist/toolRoster.js +21 -20
- package/dist/toolsFlagNames.d.ts +8 -0
- package/dist/toolsFlagNames.js +110 -0
- package/dist/turnFailurePresentation.d.ts +12 -1
- package/dist/turnFailurePresentation.js +220 -15
- package/dist/usageAnalytics.js +6 -11
- package/dist/userAttachmentEnvelope.d.ts +1 -0
- package/dist/userAttachmentEnvelope.js +37 -7
- package/dist/userAttachmentSeat.d.ts +21 -0
- package/dist/userAttachmentSeat.js +75 -0
- package/dist/userInvokedSkillsCapability.d.ts +11 -1
- package/dist/userInvokedSkillsCapability.js +31 -7
- package/dist/wireErrorTriage.d.ts +7 -0
- package/dist/wireErrorTriage.js +23 -1
- package/dist/wireFailureShape.js +2 -1
- package/dist/wireRefusalCopy.d.ts +62 -16
- package/dist/wireRefusalCopy.js +307 -148
- package/dist/workflowsJournalCapability.d.ts +2 -1
- package/dist/workflowsJournalCapability.js +8 -6
- package/docs/INTEGRATION-CLIENTS.md +951 -42
- package/package.json +5 -5
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { engineCapsLandingOf } from './engineCapsCache.js';
|
|
2
2
|
import { engineWireTarget } from './engineWireTarget.js';
|
|
3
|
+
import { msg, renderMessage } from './i18n/translate.js';
|
|
3
4
|
function laneOrder() {
|
|
4
5
|
return ['processEnv', 'settingsEnv', 'modelCatalogFile', 'followedSettingsFile', 'followedProviderEnv'];
|
|
5
6
|
}
|
|
@@ -30,6 +31,10 @@ function routeGapOf(reading) {
|
|
|
30
31
|
const v = own(reading, 'routeGap')?.v;
|
|
31
32
|
return v === 'endpoint_missing' || v === 'lane_credential_missing' || v === 'none' ? v : undefined;
|
|
32
33
|
}
|
|
34
|
+
function catalogAdoptionOf(reading) {
|
|
35
|
+
const v = own(reading, 'catalogAdoption')?.v;
|
|
36
|
+
return v === 'absent' || v === 'refused' || v === 'undetermined' ? v : undefined;
|
|
37
|
+
}
|
|
33
38
|
function analyse(reading) {
|
|
34
39
|
try {
|
|
35
40
|
if (!isPlainObject(reading))
|
|
@@ -46,25 +51,30 @@ function analyse(reading) {
|
|
|
46
51
|
const lanesHit = own(reading, 'lanes')?.v;
|
|
47
52
|
const order = laneOrder();
|
|
48
53
|
if (!isPlainObject(lanesHit)) {
|
|
49
|
-
return { verdict: 'unknown', why: 'lanes', unreadable: [], unreported: [...order], unusable: [], catalogUnconfirmed: null, catalogRefused:
|
|
54
|
+
return { verdict: 'unknown', why: 'lanes', unreadable: [], unreported: [...order], unusable: [], catalogUnconfirmed: null, catalogRefused: null };
|
|
50
55
|
}
|
|
51
56
|
const partial = [];
|
|
52
57
|
const unreadable = [];
|
|
53
58
|
const unreported = [];
|
|
54
59
|
const unusable = [];
|
|
55
|
-
let catalogRefused =
|
|
60
|
+
let catalogRefused = null;
|
|
56
61
|
let catalogUnconfirmed = null;
|
|
57
62
|
for (const lane of order) {
|
|
58
63
|
const s = laneState(lanesHit, lane);
|
|
59
64
|
if (lane === 'modelCatalogFile') {
|
|
60
65
|
if (s === 'complete') {
|
|
66
|
+
if (catalogAdoptionOf(reading) === 'refused') {
|
|
67
|
+
partial.push(lane);
|
|
68
|
+
catalogRefused = 'adoption';
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
61
71
|
const bit = own(reading, 'engineAcceptsCatalogDefault');
|
|
62
72
|
const evidence = catalogDefaultEvidence(s, bit?.v);
|
|
63
73
|
if (evidence !== undefined)
|
|
64
74
|
return { verdict: 'resolvable', why: 'catalog_default', evidence };
|
|
65
75
|
if (bit !== undefined && bit.v === false) {
|
|
66
76
|
partial.push(lane);
|
|
67
|
-
catalogRefused =
|
|
77
|
+
catalogRefused = 'engine';
|
|
68
78
|
}
|
|
69
79
|
else {
|
|
70
80
|
catalogUnconfirmed = bit === undefined || bit.v === undefined ? 'not_reported' : 'unusable';
|
|
@@ -99,19 +109,30 @@ function analyse(reading) {
|
|
|
99
109
|
export function modelIdentityResolvability(reading) {
|
|
100
110
|
return analyse(reading).verdict;
|
|
101
111
|
}
|
|
112
|
+
const LANE_LABEL_KEYS = Object.freeze({
|
|
113
|
+
processEnv: 'model.identity.lane.processEnv',
|
|
114
|
+
settingsEnv: 'model.identity.lane.settingsEnv',
|
|
115
|
+
modelCatalogFile: 'model.identity.lane.modelCatalogFile',
|
|
116
|
+
followedSettingsFile: 'model.identity.lane.followedSettingsFile',
|
|
117
|
+
followedProviderEnv: 'model.identity.lane.followedProviderEnv',
|
|
118
|
+
});
|
|
102
119
|
function laneLabel(lane) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
120
|
+
return renderMessage(msg(LANE_LABEL_KEYS[lane]));
|
|
121
|
+
}
|
|
122
|
+
const ROUTE_GAP_FACT_KEYS = Object.freeze({
|
|
123
|
+
endpoint_missing: 'model.identity.routeGap.fact.endpointMissing',
|
|
124
|
+
lane_credential_missing: 'model.identity.routeGap.fact.laneCredentialMissing',
|
|
125
|
+
});
|
|
126
|
+
const isRouteGapKind = (v) => typeof v === 'string' && Object.hasOwn(ROUTE_GAP_FACT_KEYS, v);
|
|
127
|
+
const isLane = (v) => typeof v === 'string' && Object.hasOwn(LANE_LABEL_KEYS, v);
|
|
128
|
+
function routeGapSentenceRef(lane, gap) {
|
|
129
|
+
return msg('model.identity.routeGap.sentence', { lane: msg(LANE_LABEL_KEYS[lane]), fact: msg(ROUTE_GAP_FACT_KEYS[gap]) });
|
|
130
|
+
}
|
|
131
|
+
export function modelRouteGapSentence(lane, gap, lang) {
|
|
132
|
+
return isLane(lane) && isRouteGapKind(gap) ? renderMessage(routeGapSentenceRef(lane, gap), lang) : undefined;
|
|
133
|
+
}
|
|
134
|
+
export function modelRouteGapFact(gap, lang) {
|
|
135
|
+
return isRouteGapKind(gap) ? renderMessage(msg(ROUTE_GAP_FACT_KEYS[gap]), lang) : undefined;
|
|
115
136
|
}
|
|
116
137
|
function joinPhrases(xs) {
|
|
117
138
|
if (xs.length <= 1)
|
|
@@ -133,16 +154,19 @@ export function modelIdentityDetail(reading) {
|
|
|
133
154
|
}
|
|
134
155
|
return `${laneLabel(a.lane)} supplies a model name for the local engine — whether the engine also has a route to reach that model (an endpoint, or credentials for the channel it names) and whether its gateway accepts the name are separate checks`;
|
|
135
156
|
case 'not_resolvable': {
|
|
136
|
-
if (a.why === 'route_gap')
|
|
137
|
-
return a.gap
|
|
138
|
-
? `${laneLabel(a.lane)} supplies a model name, but the local engine has no route to reach it — the model rides the OpenAI-compatible route and no gateway address (MODEL_GATEWAY_BASEURL) is set, and the engine refuses to start without one`
|
|
139
|
-
: `${laneLabel(a.lane)} supplies a model name, but the local engine has no route to reach it — the anthropic channel is selected (MODEL_PROVIDER=anthropic), neither ANTHROPIC_API_KEY nor ANTHROPIC_AUTH_TOKEN is set, and there is no gateway address (MODEL_GATEWAY_BASEURL) to fall back to, so the engine cannot start on any route`;
|
|
140
|
-
}
|
|
157
|
+
if (a.why === 'route_gap')
|
|
158
|
+
return renderMessage(routeGapSentenceRef(a.lane, a.gap));
|
|
141
159
|
const others = a.catalogRefused ? a.partial.filter((l) => l !== 'modelCatalogFile') : a.partial;
|
|
142
160
|
const partialClause = others.length > 0
|
|
143
161
|
? `${joinPhrases(others.map(laneLabel))} ${others.length > 1 ? 'carry' : 'carries'} part of a model configuration (such as a gateway address or a credential) but no model name`
|
|
144
162
|
: '';
|
|
145
|
-
if (a.catalogRefused) {
|
|
163
|
+
if (a.catalogRefused === 'adoption') {
|
|
164
|
+
const clause = msg('model.identity.catalogAdoption.refused', { lane: msg(LANE_LABEL_KEYS.modelCatalogFile) });
|
|
165
|
+
return partialClause !== ''
|
|
166
|
+
? renderMessage(msg('model.identity.catalogAdoption.notResolvableWithPartial', { clause, partial: partialClause }))
|
|
167
|
+
: renderMessage(msg('model.identity.catalogAdoption.notResolvable', { clause }));
|
|
168
|
+
}
|
|
169
|
+
if (a.catalogRefused === 'engine') {
|
|
146
170
|
return (`no model name is configured for the local engine to start with — ${laneLabel('modelCatalogFile')} names a default model, but the local engine is reported not to accept a catalog default in place of a startup model name` +
|
|
147
171
|
(partialClause !== '' ? `, and ${partialClause}` : '') +
|
|
148
172
|
', and the engine does not start without one');
|
|
@@ -170,7 +194,10 @@ export function modelIdentityDetail(reading) {
|
|
|
170
194
|
else if (a.catalogUnconfirmed === 'unusable') {
|
|
171
195
|
parts.push(`${laneLabel('modelCatalogFile')} names a default model, but the report of whether the local engine accepts a catalog default in place of a startup model name gave no usable reading`);
|
|
172
196
|
}
|
|
173
|
-
else if (a.catalogRefused) {
|
|
197
|
+
else if (a.catalogRefused === 'adoption') {
|
|
198
|
+
parts.push(renderMessage(msg('model.identity.catalogAdoption.refused', { lane: msg(LANE_LABEL_KEYS.modelCatalogFile) })));
|
|
199
|
+
}
|
|
200
|
+
else if (a.catalogRefused === 'engine') {
|
|
174
201
|
parts.push(`${laneLabel('modelCatalogFile')} names a default model, but the local engine is reported not to accept a catalog default in place of a startup model name`);
|
|
175
202
|
}
|
|
176
203
|
return `whether the local engine has a model name is unknown — ${joinPhrases(parts)}, and no other place this client reads provides one`;
|
package/dist/ownKey.d.ts
CHANGED
|
@@ -24,5 +24,38 @@ export interface ContextUsageReading {
|
|
|
24
24
|
sections?: readonly ContextUsageSectionRow[];
|
|
25
25
|
}
|
|
26
26
|
export declare function contextUsageReadingOf(payload: {} | null | undefined): ContextUsageReading | undefined;
|
|
27
|
+
export interface HumanInputAttachmentView {
|
|
28
|
+
ordinal: number;
|
|
29
|
+
kind?: string;
|
|
30
|
+
outcome: string;
|
|
31
|
+
label?: string;
|
|
32
|
+
}
|
|
33
|
+
export declare function humanInputAttachmentsOf(frame: {} | null | undefined): HumanInputAttachmentView[] | undefined;
|
|
27
34
|
export declare function markMcpSectionDroppedNamedRows(rows: object, dropped: ReadonlyMap<string, number>): void;
|
|
28
35
|
export declare function mcpSectionDroppedNamedRowsOf(rows: object | null | undefined, name: string): number;
|
|
36
|
+
export interface PromptManifestSectionRow {
|
|
37
|
+
id: string;
|
|
38
|
+
chars: number;
|
|
39
|
+
band?: string;
|
|
40
|
+
locale?: string;
|
|
41
|
+
variant?: string;
|
|
42
|
+
contentHash?: string;
|
|
43
|
+
slot?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface PromptManifestIdentityRow {
|
|
46
|
+
readonly artifact: string;
|
|
47
|
+
readonly layers: PromptIdentityLayersRow;
|
|
48
|
+
readonly epoch: number;
|
|
49
|
+
readonly activatedBy: string;
|
|
50
|
+
}
|
|
51
|
+
export interface PromptIdentityLayersRow {
|
|
52
|
+
readonly catalog: string;
|
|
53
|
+
readonly renderers: Readonly<Record<string, number>>;
|
|
54
|
+
readonly center?: string;
|
|
55
|
+
readonly deploy?: string;
|
|
56
|
+
readonly task?: string;
|
|
57
|
+
readonly binding: string;
|
|
58
|
+
}
|
|
59
|
+
export declare function promptManifestSectionViewOf(row: object): PromptManifestSectionRow | undefined;
|
|
60
|
+
export declare function promptManifestIdentityOfFrame(frame: object): PromptManifestIdentityRow | undefined;
|
|
61
|
+
export declare function promptManifestIdentityOf(raw: {} | null | undefined): PromptManifestIdentityRow | undefined;
|
package/dist/ownKey.js
CHANGED
|
@@ -131,6 +131,40 @@ export function contextUsageReadingOf(payload) {
|
|
|
131
131
|
return undefined;
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
+
const HUMAN_INPUT_ATTACHMENT_ROWS_MAX = 256;
|
|
135
|
+
export function humanInputAttachmentsOf(frame) {
|
|
136
|
+
try {
|
|
137
|
+
if (typeof frame !== 'object' || frame === null || Array.isArray(frame))
|
|
138
|
+
return undefined;
|
|
139
|
+
const raw = guardedRead(() => readOwnDataValue(frame, 'attachments'));
|
|
140
|
+
if (!Array.isArray(raw))
|
|
141
|
+
return undefined;
|
|
142
|
+
const n = guardedRead(() => readOwnDataFiniteNumber(raw, 'length'));
|
|
143
|
+
if (n === undefined)
|
|
144
|
+
return undefined;
|
|
145
|
+
const rows = [];
|
|
146
|
+
for (let i = 0; i < Math.min(n, HUMAN_INPUT_ATTACHMENT_ROWS_MAX); i++) {
|
|
147
|
+
const row = guardedRead(() => {
|
|
148
|
+
const r = readOwnDataValue(raw, String(i));
|
|
149
|
+
if (typeof r !== 'object' || r === null || Array.isArray(r))
|
|
150
|
+
return undefined;
|
|
151
|
+
const ordinal = readOwnDataValue(r, 'ordinal');
|
|
152
|
+
const outcome = readOwnDataNonEmptyString(r, 'outcome');
|
|
153
|
+
if (typeof ordinal !== 'number' || !Number.isSafeInteger(ordinal) || ordinal < 1 || outcome === undefined)
|
|
154
|
+
return undefined;
|
|
155
|
+
const kind = readOwnDataNonEmptyString(r, 'kind');
|
|
156
|
+
const label = readOwnDataNonEmptyString(r, 'label');
|
|
157
|
+
return { ordinal, ...(kind !== undefined ? { kind } : {}), outcome, ...(label !== undefined ? { label } : {}) };
|
|
158
|
+
});
|
|
159
|
+
if (row !== undefined)
|
|
160
|
+
rows.push(row);
|
|
161
|
+
}
|
|
162
|
+
return rows.length > 0 ? rows : undefined;
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
return undefined;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
134
168
|
const DROPPED_NAMED_ROWS = Symbol.for('@sema-agent/client-core/mcpSectionDroppedNamedRows');
|
|
135
169
|
export function markMcpSectionDroppedNamedRows(rows, dropped) {
|
|
136
170
|
if (dropped.size === 0)
|
|
@@ -155,3 +189,78 @@ export function mcpSectionDroppedNamedRowsOf(rows, name) {
|
|
|
155
189
|
return 0;
|
|
156
190
|
}
|
|
157
191
|
}
|
|
192
|
+
export function promptManifestSectionViewOf(row) {
|
|
193
|
+
const o = row;
|
|
194
|
+
const str = (v) => (typeof v === 'string' && v.length > 0 ? v : undefined);
|
|
195
|
+
const id = str(o.id);
|
|
196
|
+
const chars = typeof o.chars === 'number' && Number.isFinite(o.chars) && o.chars >= 0 ? o.chars : undefined;
|
|
197
|
+
if (id === undefined || chars === undefined)
|
|
198
|
+
return undefined;
|
|
199
|
+
const band = str(o.band);
|
|
200
|
+
const locale = str(o.locale);
|
|
201
|
+
const variant = str(o.variant);
|
|
202
|
+
const contentHash = band !== undefined ? str(o.contentHash) : undefined;
|
|
203
|
+
const slot = str(o.slot);
|
|
204
|
+
return {
|
|
205
|
+
id,
|
|
206
|
+
chars,
|
|
207
|
+
...(band !== undefined ? { band } : {}),
|
|
208
|
+
...(locale !== undefined ? { locale } : {}),
|
|
209
|
+
...(variant !== undefined ? { variant } : {}),
|
|
210
|
+
...(contentHash !== undefined ? { contentHash } : {}),
|
|
211
|
+
...(slot !== undefined ? { slot } : {}),
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
export function promptManifestIdentityOfFrame(frame) {
|
|
215
|
+
let raw;
|
|
216
|
+
try {
|
|
217
|
+
raw = frame.identity;
|
|
218
|
+
}
|
|
219
|
+
catch {
|
|
220
|
+
return undefined;
|
|
221
|
+
}
|
|
222
|
+
return promptManifestIdentityOf(typeof raw === 'object' && raw !== null ? raw : undefined);
|
|
223
|
+
}
|
|
224
|
+
export function promptManifestIdentityOf(raw) {
|
|
225
|
+
try {
|
|
226
|
+
const plain = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
227
|
+
const str = (v) => (typeof v === 'string' && v.length > 0 ? v : undefined);
|
|
228
|
+
if (!plain(raw))
|
|
229
|
+
return undefined;
|
|
230
|
+
const artifact = str(raw.artifact);
|
|
231
|
+
const activatedBy = str(raw.activatedBy);
|
|
232
|
+
const epochRaw = raw.epoch;
|
|
233
|
+
const epoch = typeof epochRaw === 'number' && Number.isInteger(epochRaw) && epochRaw >= 0 ? epochRaw : undefined;
|
|
234
|
+
const layersRaw = raw.layers;
|
|
235
|
+
if (artifact === undefined || activatedBy === undefined || epoch === undefined || !plain(layersRaw))
|
|
236
|
+
return undefined;
|
|
237
|
+
const catalog = str(layersRaw.catalog);
|
|
238
|
+
const binding = str(layersRaw.binding);
|
|
239
|
+
if (catalog === undefined || binding === undefined)
|
|
240
|
+
return undefined;
|
|
241
|
+
const optional = {};
|
|
242
|
+
for (const k of ['center', 'deploy', 'task']) {
|
|
243
|
+
const v = layersRaw[k];
|
|
244
|
+
if (v === undefined)
|
|
245
|
+
continue;
|
|
246
|
+
const t = str(v);
|
|
247
|
+
if (t === undefined)
|
|
248
|
+
return undefined;
|
|
249
|
+
optional[k] = t;
|
|
250
|
+
}
|
|
251
|
+
const renderersRaw = layersRaw.renderers;
|
|
252
|
+
if (!plain(renderersRaw))
|
|
253
|
+
return undefined;
|
|
254
|
+
const entries = [];
|
|
255
|
+
for (const [k, v] of Object.entries(renderersRaw)) {
|
|
256
|
+
if (typeof v !== 'number' || !Number.isFinite(v))
|
|
257
|
+
return undefined;
|
|
258
|
+
entries.push([k, v]);
|
|
259
|
+
}
|
|
260
|
+
const renderers = Object.fromEntries(entries);
|
|
261
|
+
return { artifact, layers: { catalog, renderers, ...optional, binding }, epoch, activatedBy };
|
|
262
|
+
}
|
|
263
|
+
catch {
|
|
264
|
+
return undefined;
|
|
265
|
+
}
|
|
266
|
+
}
|
package/dist/panelReduce.d.ts
CHANGED
|
@@ -31,6 +31,11 @@ export type PanelFrame = EngineAgentPanelEvent | {
|
|
|
31
31
|
kind: 'anchor';
|
|
32
32
|
taskId: string;
|
|
33
33
|
transcriptId: string;
|
|
34
|
+
} | {
|
|
35
|
+
kind: 'start';
|
|
36
|
+
taskId: string;
|
|
37
|
+
startedAt?: number;
|
|
38
|
+
workflowRunId?: string;
|
|
34
39
|
};
|
|
35
40
|
export interface PanelRowFields {
|
|
36
41
|
name?: string;
|
|
@@ -97,7 +102,7 @@ export interface PanelStep {
|
|
|
97
102
|
readonly deltas: PanelDelta[];
|
|
98
103
|
readonly facts: PanelFact[];
|
|
99
104
|
}
|
|
100
|
-
export declare function panelEndFact(taskId: string, isError: boolean, extra?: Pick<EndArm, 'report' | 'cycleSeq' | 'startedAt'>): EndArm;
|
|
105
|
+
export declare function panelEndFact(taskId: string, isError: boolean, extra?: Pick<EndArm, 'report' | 'cycleSeq' | 'startedAt' | 'sessionId'>): EndArm;
|
|
101
106
|
export interface EnginePanelTaskIdentity {
|
|
102
107
|
readonly taskId: string;
|
|
103
108
|
readonly origin: 'fleet-row' | 'wire';
|
|
@@ -111,6 +116,11 @@ export declare function reducePanelFrame(state: PanelReduceState, frame: PanelFr
|
|
|
111
116
|
};
|
|
112
117
|
export declare function panelRowSnapshot(state: PanelReduceState): PanelDelta[];
|
|
113
118
|
export declare function panelResolveTaskId(state: PanelReduceState, wireTaskId: string): EnginePanelTaskIdentity;
|
|
119
|
+
export interface PanelSubagentIdentity {
|
|
120
|
+
readonly key: string;
|
|
121
|
+
readonly ids: readonly string[];
|
|
122
|
+
}
|
|
123
|
+
export declare function panelSubagentOf(state: PanelReduceState, id: string): PanelSubagentIdentity | undefined;
|
|
114
124
|
export declare function panelIsResident(state: PanelReduceState, taskId: string): boolean;
|
|
115
125
|
export declare function panelAnchorOf(state: PanelReduceState, taskId: string): string | undefined;
|
|
116
126
|
export declare function panelPresenceSize(state: PanelReduceState, sessionKey: string): number;
|
package/dist/panelReduce.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { rowIdTail } from './workflow.js';
|
|
2
2
|
import { isSdkFleetTaskTerminal, isSdkFleetTaskTerminalNotSuccess } from './terminalStatuses.js';
|
|
3
|
-
import { carryCycle, cycleEmpty, cycleKeysChanged, cycleOf, cycleOrder, mergeCycle, } from './cycleOrder.js';
|
|
3
|
+
import { carryCycle, cycleEmpty, cycleKeysChanged, cycleOf, cycleOrder, cycleSeqValue, mergeCycle, } from './cycleOrder.js';
|
|
4
4
|
export function isStaleEngineAgentPanelEnd(end, current) {
|
|
5
5
|
return cycleOrder(end, current) === 'before';
|
|
6
6
|
}
|
|
@@ -394,6 +394,7 @@ function merge(d, a, b) {
|
|
|
394
394
|
held: rs.held ?? rl.held,
|
|
395
395
|
resident: rs.resident ?? rl.resident,
|
|
396
396
|
anchor: rs.anchor ?? rl.anchor,
|
|
397
|
+
startedAt: rs.startedAt ?? rl.startedAt,
|
|
397
398
|
row: merged.row,
|
|
398
399
|
});
|
|
399
400
|
for (const id of idsOf(rl))
|
|
@@ -423,6 +424,7 @@ function merge(d, a, b) {
|
|
|
423
424
|
mintTerminal(d, key, merged.row.isError === true, merged.row.report, 'end');
|
|
424
425
|
}
|
|
425
426
|
}
|
|
427
|
+
fillStartedAt(d, s);
|
|
426
428
|
return s;
|
|
427
429
|
}
|
|
428
430
|
function genOf(r) {
|
|
@@ -513,6 +515,7 @@ export function panelEndFact(taskId, isError, extra) {
|
|
|
513
515
|
...(extra?.cycleSeq !== undefined ? { cycleSeq: extra.cycleSeq } : {}),
|
|
514
516
|
...(extra?.startedAt !== undefined ? { startedAt: extra.startedAt } : {}),
|
|
515
517
|
...(extra?.report !== undefined ? { report: extra.report } : {}),
|
|
518
|
+
...(typeof extra?.sessionId === 'string' && extra.sessionId.length > 0 ? { sessionId: extra.sessionId } : {}),
|
|
516
519
|
};
|
|
517
520
|
}
|
|
518
521
|
function terminalDelta(key, isError, report, cause) {
|
|
@@ -572,10 +575,26 @@ function fullUsage(key, row) {
|
|
|
572
575
|
return undefined;
|
|
573
576
|
return usageDelta(key, { ...(row.totalTokens !== undefined ? { totalTokens: row.totalTokens } : {}), ...(row.toolUses !== undefined ? { toolUses: row.toolUses } : {}), ...(fin !== undefined ? { final: fin } : {}) });
|
|
574
577
|
}
|
|
578
|
+
function ownDataOf(o, key) {
|
|
579
|
+
if (typeof o !== 'object' || o === null)
|
|
580
|
+
return undefined;
|
|
581
|
+
try {
|
|
582
|
+
const d = Object.getOwnPropertyDescriptor(o, key);
|
|
583
|
+
return d !== undefined && 'value' in d ? d.value : undefined;
|
|
584
|
+
}
|
|
585
|
+
catch {
|
|
586
|
+
return undefined;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
function publisherFinality(f) {
|
|
590
|
+
return { ...(ownDataOf(f, 'totalTokens') === true ? { totalTokens: true } : {}), ...(ownDataOf(f, 'toolUses') === true ? { toolUses: true } : {}) };
|
|
591
|
+
}
|
|
575
592
|
function fleetCarrier(ev) {
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
593
|
+
return { totalTokens: ev.totalTokens, toolUses: ev.toolUses, final: publisherFinality(ownDataOf(ev, 'final')) };
|
|
594
|
+
}
|
|
595
|
+
function tickCycleOf(ev) {
|
|
596
|
+
const c = cycleSeqValue(ownDataOf(ev, 'cycleSeq'));
|
|
597
|
+
return c === undefined ? undefined : { cycleSeq: c };
|
|
579
598
|
}
|
|
580
599
|
function finalityOf(tokens, toolUses) {
|
|
581
600
|
if (tokens === undefined && toolUses === undefined)
|
|
@@ -625,26 +644,30 @@ function announce(d, rid) {
|
|
|
625
644
|
if (r === undefined || row === undefined || row.announced)
|
|
626
645
|
return;
|
|
627
646
|
const key = keyOf(r);
|
|
628
|
-
|
|
647
|
+
const fields = row.fields.startedAt === undefined && r.startedAt !== undefined ? { ...row.fields, startedAt: r.startedAt } : row.fields;
|
|
648
|
+
d.put(rid, { consumerKey: key, announceSeq: d.counts.nextAnnounce, row: { ...row, fields, announced: true } });
|
|
629
649
|
d.counts.nextAnnounce++;
|
|
630
|
-
d.deltas.push({ op: 'upsert', canonicalId: key, created: true, fields: { ...
|
|
650
|
+
d.deltas.push({ op: 'upsert', canonicalId: key, created: true, fields: { ...fields } });
|
|
631
651
|
const u = fullUsage(key, row);
|
|
632
652
|
if (u !== undefined)
|
|
633
653
|
d.deltas.push(u);
|
|
634
654
|
if (row.phase === 'ended')
|
|
635
655
|
mintTerminal(d, key, row.isError === true, row.report, 'end');
|
|
636
656
|
}
|
|
637
|
-
function foldTick(d, rid, ev, cardBound) {
|
|
657
|
+
function foldTick(d, rid, ev, cardBound, final) {
|
|
638
658
|
const r = d.rec(rid);
|
|
639
659
|
if (r === undefined)
|
|
640
660
|
return;
|
|
641
661
|
const row = r.row;
|
|
642
662
|
const gate = cardBound ? { gateBound: true } : {};
|
|
643
663
|
const wireId = ev.wireTaskId ?? ev.taskId;
|
|
644
|
-
const
|
|
664
|
+
const tickCycle = tickCycleOf(ev);
|
|
665
|
+
const attributable = hasCycleSeq(r.cycle)
|
|
666
|
+
? tickCycle !== undefined && cycleOrder(tickCycle, r.cycle) === 'same'
|
|
667
|
+
: r.currentRun === undefined || r.currentRun === wireId;
|
|
645
668
|
if (!attributable)
|
|
646
669
|
d.counts.unattributedTicks++;
|
|
647
|
-
const carrier = attributable ? { totalTokens: ev.totalTokens, toolUses: ev.toolUses } : {};
|
|
670
|
+
const carrier = attributable ? { totalTokens: ev.totalTokens, toolUses: ev.toolUses, final } : {};
|
|
648
671
|
if (row === undefined || !row.announced) {
|
|
649
672
|
const base = row !== undefined
|
|
650
673
|
? { ...row, ...gate, tickSeen: true, fields: { ...row.fields, ...tickFields(ev) } }
|
|
@@ -785,28 +808,37 @@ function foldAbsence(d, rid, a) {
|
|
|
785
808
|
d.deltas.push({ op: 'upsert', canonicalId: keyOf(r), fields: { absence } });
|
|
786
809
|
d.put(rid, { row: { ...row, fields: { ...row.fields, absence } } });
|
|
787
810
|
}
|
|
788
|
-
function
|
|
789
|
-
const
|
|
790
|
-
|
|
791
|
-
|
|
811
|
+
function tickFactBase(ev) {
|
|
812
|
+
const out = {};
|
|
813
|
+
for (const k of Reflect.ownKeys(ev)) {
|
|
814
|
+
if (typeof k !== 'string' || k === 'cardBound' || k === 'final' || k === 'cycleSeq')
|
|
815
|
+
continue;
|
|
816
|
+
if (!Object.prototype.propertyIsEnumerable.call(ev, k))
|
|
817
|
+
continue;
|
|
818
|
+
out[k] = Reflect.get(ev, k);
|
|
819
|
+
}
|
|
820
|
+
return out;
|
|
792
821
|
}
|
|
793
822
|
function emitTick(d, ev) {
|
|
794
823
|
const found = d.find(ev.taskId);
|
|
795
824
|
const fr = found !== undefined ? d.rec(found) : undefined;
|
|
796
825
|
if (fr !== undefined && formerGeneration(fr, ev.taskId))
|
|
797
826
|
return;
|
|
827
|
+
const tickCycle = tickCycleOf(ev);
|
|
828
|
+
if (fr !== undefined && tickCycle !== undefined && cycleOrder(tickCycle, genOf(fr)) === 'before')
|
|
829
|
+
return;
|
|
798
830
|
const rid = found ?? d.create({ id: ev.taskId });
|
|
799
831
|
d.records.touch(rid);
|
|
800
832
|
const r = d.rec(rid);
|
|
801
833
|
if (r === undefined)
|
|
802
834
|
return;
|
|
803
835
|
const key = keyOf(r);
|
|
804
|
-
const plain =
|
|
836
|
+
const plain = { ...tickFactBase(ev), ...(tickCycle !== undefined ? { cycleSeq: tickCycle.cycleSeq } : {}) };
|
|
805
837
|
const fact = key === ev.taskId
|
|
806
838
|
? { ...plain, taskIdOrigin: 'wire' }
|
|
807
839
|
: { ...plain, taskId: key, wireTaskId: ev.taskId, taskIdOrigin: key === r.tail ? 'fleet-row' : 'wire' };
|
|
808
840
|
d.facts.push({ ch: 'event', ev: fact });
|
|
809
|
-
foldTick(d, rid, fact, ev.cardBound === true);
|
|
841
|
+
foldTick(d, rid, fact, ev.cardBound === true, publisherFinality(ownDataOf(ev, 'final')));
|
|
810
842
|
}
|
|
811
843
|
function flushHeld(d, wireTaskId) {
|
|
812
844
|
const held = d.pending.get(wireTaskId);
|
|
@@ -861,7 +893,8 @@ function publishFleetRow(d, ev) {
|
|
|
861
893
|
const stale = order === 'after';
|
|
862
894
|
let newGen = false;
|
|
863
895
|
if (!stale) {
|
|
864
|
-
const
|
|
896
|
+
const endedHere = r.ended !== undefined && (r.cycle === undefined || cycleOrder(r.ended, r.cycle) === 'same') ? r.ended : undefined;
|
|
897
|
+
const endGen = r.row?.phase === 'ended' ? (r.row.endCycle ?? endedHere) : undefined;
|
|
865
898
|
newGen = order === 'before' || (endGen !== undefined && cycleOrder(endGen, rowCycle) === 'before');
|
|
866
899
|
if (!newGen && transcript !== undefined && !hasCycleSeq(r.cycle) && !hasCycleSeq(rowCycle) && r.currentRun !== undefined && r.currentRun !== transcript) {
|
|
867
900
|
newGen = true;
|
|
@@ -901,6 +934,36 @@ function publishTick(d, ev) {
|
|
|
901
934
|
}
|
|
902
935
|
d.pending.set(ev.taskId, { ev, beats: 0 });
|
|
903
936
|
}
|
|
937
|
+
function publishStart(d, ev) {
|
|
938
|
+
if (typeof ev.workflowRunId === 'string' && ev.workflowRunId.length > 0)
|
|
939
|
+
return;
|
|
940
|
+
if (typeof ev.taskId !== 'string' || ev.taskId.length === 0)
|
|
941
|
+
return;
|
|
942
|
+
const startedAt = typeof ev.startedAt === 'number' && Number.isFinite(ev.startedAt) ? ev.startedAt : undefined;
|
|
943
|
+
if (startedAt === undefined)
|
|
944
|
+
return;
|
|
945
|
+
const found = d.find(ev.taskId);
|
|
946
|
+
const former = found !== undefined ? d.rec(found) : undefined;
|
|
947
|
+
if (former !== undefined && formerGeneration(former, ev.taskId))
|
|
948
|
+
return;
|
|
949
|
+
if (found === undefined && d.records.size >= MAX_RECORDS)
|
|
950
|
+
return;
|
|
951
|
+
const rid = found ?? d.create({ id: ev.taskId });
|
|
952
|
+
const r = d.rec(rid);
|
|
953
|
+
if (r === undefined)
|
|
954
|
+
return;
|
|
955
|
+
if (r.startedAt === undefined)
|
|
956
|
+
d.put(rid, { startedAt });
|
|
957
|
+
fillStartedAt(d, rid);
|
|
958
|
+
}
|
|
959
|
+
function fillStartedAt(d, rid) {
|
|
960
|
+
const r = d.rec(rid);
|
|
961
|
+
const row = r?.row;
|
|
962
|
+
if (r === undefined || r.startedAt === undefined || row === undefined || !row.announced || row.phase !== 'running' || row.fields.startedAt !== undefined)
|
|
963
|
+
return;
|
|
964
|
+
d.deltas.push({ op: 'upsert', canonicalId: keyOf(r), fields: { startedAt: r.startedAt } });
|
|
965
|
+
d.put(rid, { row: { ...row, fields: { ...row.fields, startedAt: r.startedAt } } });
|
|
966
|
+
}
|
|
904
967
|
function releaseHeld(d, rid, endCycle) {
|
|
905
968
|
const held = d.rec(rid)?.held;
|
|
906
969
|
if (held === undefined)
|
|
@@ -921,6 +984,15 @@ function settle(d, rid, cycle) {
|
|
|
921
984
|
d.put(rid, { running: undefined, ended: older ? r.ended : mergeCycle(cycleOf(cycle), r.ended) });
|
|
922
985
|
}
|
|
923
986
|
function publishEnd(d, ev) {
|
|
987
|
+
const sessionId = typeof ev.sessionId === 'string' && ev.sessionId.length > 0 && ev.sessionId !== ev.taskId ? ev.sessionId : undefined;
|
|
988
|
+
if (sessionId !== undefined) {
|
|
989
|
+
const at = d.find(ev.taskId);
|
|
990
|
+
const ra = at !== undefined ? d.rec(at) : undefined;
|
|
991
|
+
const evCycle = frameCycleOn(ra, ev.taskId, ev);
|
|
992
|
+
const provablyOld = ra !== undefined && (isStaleEngineAgentPanelEnd(evCycle, ra.cycle) || isStaleEngineAgentPanelEnd(evCycle, ra.ended));
|
|
993
|
+
if (!provablyOld)
|
|
994
|
+
bind(d, ev.taskId, 'tail', sessionId, cycleOf(ev));
|
|
995
|
+
}
|
|
924
996
|
const pre = d.find(ev.taskId);
|
|
925
997
|
const pr = pre !== undefined ? d.rec(pre) : undefined;
|
|
926
998
|
if (pre !== undefined && pr !== undefined)
|
|
@@ -1187,6 +1259,9 @@ export function stepPanelFrame(state, frame) {
|
|
|
1187
1259
|
case 'resident-clear-wire':
|
|
1188
1260
|
clearResidentByWire(d, frame.taskId, frame.cycle);
|
|
1189
1261
|
break;
|
|
1262
|
+
case 'start':
|
|
1263
|
+
publishStart(d, frame);
|
|
1264
|
+
break;
|
|
1190
1265
|
case 'anchor':
|
|
1191
1266
|
if (frame.taskId && frame.transcriptId)
|
|
1192
1267
|
d.put(bind(d, frame.taskId, 'unknown', frame.transcriptId, undefined), { anchor: frame.transcriptId });
|
|
@@ -1231,6 +1306,10 @@ export function panelResolveTaskId(state, wireTaskId) {
|
|
|
1231
1306
|
return { taskId: wireTaskId, origin: 'wire' };
|
|
1232
1307
|
return { taskId: r.tail, origin: 'fleet-row', ...cycleOf(bindingOf(r, wireTaskId)?.gen) };
|
|
1233
1308
|
}
|
|
1309
|
+
export function panelSubagentOf(state, id) {
|
|
1310
|
+
const r = recordOfId(state, id);
|
|
1311
|
+
return r === undefined ? undefined : { key: keyOf(r), ids: idsOf(r) };
|
|
1312
|
+
}
|
|
1234
1313
|
export function panelIsResident(state, taskId) {
|
|
1235
1314
|
return recordOfId(state, taskId)?.resident === true;
|
|
1236
1315
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type PanelDelta, type PanelFact, type PanelFrame, type PanelReduceState } from './panelReduce.js';
|
|
2
2
|
export declare function panelStateNow(): PanelReduceState;
|
|
3
|
+
export declare function panelSubagentIdsNow(id: string): readonly string[] | undefined;
|
|
3
4
|
export declare function stepEnginePanel(frame: PanelFrame): void;
|
|
4
5
|
export declare function replaceEnginePanelState(fn: (s: PanelReduceState) => PanelReduceState): void;
|
|
5
6
|
export declare function clearEnginePanelIdentity(): void;
|
package/dist/panelStateHolder.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import { createPanelReduceState, panelClearAnchors, panelClearIdentity, panelClearRows, panelRowSnapshot, stepPanelFrame, } from './panelReduce.js';
|
|
1
|
+
import { createPanelReduceState, panelClearAnchors, panelClearIdentity, panelClearRows, panelRowSnapshot, panelSubagentOf, stepPanelFrame, } from './panelReduce.js';
|
|
2
|
+
import { bindSubagentIdentityReader } from './subagentContentStore.js';
|
|
2
3
|
let state = createPanelReduceState();
|
|
3
4
|
export function panelStateNow() {
|
|
4
5
|
return state;
|
|
5
6
|
}
|
|
7
|
+
export function panelSubagentIdsNow(id) {
|
|
8
|
+
return panelSubagentOf(state, id)?.ids;
|
|
9
|
+
}
|
|
10
|
+
function bindIdentityReader() {
|
|
11
|
+
bindSubagentIdentityReader(panelSubagentIdsNow);
|
|
12
|
+
}
|
|
6
13
|
export function stepEnginePanel(frame) {
|
|
14
|
+
bindIdentityReader();
|
|
7
15
|
const r = stepPanelFrame(state, frame);
|
|
8
16
|
state = r.state;
|
|
9
17
|
if (rowListener !== null)
|
|
@@ -18,6 +26,7 @@ export function stepEnginePanel(frame) {
|
|
|
18
26
|
}
|
|
19
27
|
}
|
|
20
28
|
export function replaceEnginePanelState(fn) {
|
|
29
|
+
bindIdentityReader();
|
|
21
30
|
state = fn(state);
|
|
22
31
|
}
|
|
23
32
|
export function clearEnginePanelIdentity() {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { UiLanguage } from './env/uiLanguage.js';
|
|
1
2
|
export declare const PERMISSION_RULE_ISSUE_CODES: readonly string[];
|
|
2
3
|
export declare const RETIRED_PERMISSION_RULE_ISSUE_CODES: readonly string[];
|
|
3
|
-
export declare function permissionRuleIssueDetail(code: unknown, message: unknown, rule?: string): string;
|
|
4
|
+
export declare function permissionRuleIssueDetail(code: unknown, message: unknown, rule?: string, lang?: UiLanguage): string;
|