@sema-agent/client-core 0.109.0 → 0.111.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +342 -0
- package/README.md +88 -32
- package/dist/abortableSleep.d.ts +7 -0
- package/dist/abortableSleep.js +37 -0
- package/dist/adapt/arms.js +45 -11
- package/dist/adapt/toolCards.d.ts +3 -1
- package/dist/adapt/toolCards.js +4 -2
- package/dist/adapter/activeRunSelfHeal.d.ts +39 -0
- package/dist/adapter/activeRunSelfHeal.js +171 -3
- package/dist/adapter/downstream/eventToSdkMessage.js +20 -15
- package/dist/adapter/downstream/terminalToSdkResult.d.ts +2 -0
- package/dist/adapter/downstream/terminalToSdkResult.js +11 -0
- package/dist/adapter/runStream.d.ts +5 -0
- package/dist/adapter/runStream.js +15 -3
- package/dist/attachmentRoute.d.ts +20 -0
- package/dist/attachmentRoute.js +39 -0
- package/dist/attachmentsWireCaps.js +1 -1
- package/dist/builtinOutputStyles.d.ts +12 -0
- package/dist/builtinOutputStyles.js +147 -0
- package/dist/compactionStatus.d.ts +9 -0
- package/dist/compactionStatus.js +29 -5
- package/dist/controlRouter.js +2 -1
- package/dist/coreValuePorts.d.ts +39 -1
- package/dist/coreValuePorts.js +10 -0
- package/dist/declared/supportFloorDeclared.js +1 -1
- package/dist/displayUntrusted.d.ts +1 -0
- package/dist/displayUntrusted.js +138 -14
- package/dist/engineErrorCodes.d.ts +3 -0
- package/dist/engineErrorCodes.js +3 -0
- package/dist/engineHealthFacts.d.ts +20 -0
- package/dist/engineHealthFacts.js +42 -1
- package/dist/engineHealthProbeVerdict.d.ts +23 -0
- package/dist/engineHealthProbeVerdict.js +115 -0
- package/dist/engineInlineTaskStats.d.ts +4 -3
- package/dist/engineInlineTaskStats.js +18 -2
- package/dist/engineNoticeCodes.d.ts +10 -0
- package/dist/engineNoticeCodes.js +36 -6
- package/dist/engineRepoint.d.ts +147 -0
- package/dist/engineRepoint.js +310 -0
- package/dist/engineRowRef.d.ts +3 -0
- package/dist/engineRowRef.js +13 -1
- package/dist/engineSessionMessages.d.ts +2 -1
- package/dist/engineSessionMessages.js +5 -0
- package/dist/engineSwapCrossing.d.ts +57 -0
- package/dist/engineSwapCrossing.js +297 -0
- package/dist/engineUnavailable.d.ts +44 -0
- package/dist/engineUnavailable.js +492 -0
- package/dist/errorSupplementRoles.js +2 -1
- package/dist/eventLeg.js +3 -3
- package/dist/fleet/fleetProjection.js +3 -2
- package/dist/generated/engineFactTables.d.ts +2 -0
- package/dist/generated/engineFactTables.js +12 -0
- package/dist/generated/sdkFactTables.d.ts +2 -1
- package/dist/generated/sdkFactTables.js +5 -0
- package/dist/generated/settingsSchemaTables.d.ts +4 -0
- package/dist/generated/settingsSchemaTables.js +1 -0
- package/dist/hitl/approvalAskers.d.ts +6 -0
- package/dist/hitl/approvalAskers.js +30 -0
- package/dist/hitl/approvalCardReasons.js +6 -3
- package/dist/hitl/approvalDelivery.d.ts +1 -0
- package/dist/hitl/approvalDelivery.js +1 -1
- package/dist/hitl/approvalRequestFrameReading.d.ts +7 -0
- package/dist/hitl/approvalRequestFrameReading.js +11 -0
- package/dist/hitl/approvalResolution.d.ts +9 -2
- package/dist/hitl/approvalResolution.js +6 -1
- package/dist/hitl/askGateWire.js +5 -8
- package/dist/hitl/automaticAnswerVerdict.js +2 -2
- package/dist/hitl/decisionConflict.js +6 -3
- package/dist/hitl/decisionRefusal.d.ts +2 -0
- package/dist/hitl/decisionRefusal.js +8 -8
- package/dist/hitl/decisionRefusalCarrier.d.ts +3 -0
- package/dist/hitl/decisionRefusalCarrier.js +348 -0
- package/dist/hitl/decisionSend.d.ts +10 -0
- package/dist/hitl/decisionSend.js +57 -17
- package/dist/hitl/editedApprovalAcceptance.d.ts +25 -0
- package/dist/hitl/editedApprovalAcceptance.js +26 -0
- package/dist/hitl/elicitationRefusal.d.ts +4 -0
- package/dist/hitl/elicitationRefusal.js +23 -0
- package/dist/hitl/frameRouter.d.ts +2 -2
- package/dist/hitl/frameRouter.js +12 -33
- package/dist/hitl/gateIdentity.d.ts +5 -0
- package/dist/hitl/gateIdentity.js +23 -0
- package/dist/hitl/gateLedger.d.ts +0 -4
- package/dist/hitl/gateLedger.js +0 -19
- package/dist/hitl/hitlBridge.d.ts +7 -0
- package/dist/hitl/hitlBridge.js +14 -8
- package/dist/hitl/hitlHostSurface.d.ts +3 -1
- package/dist/hitl/hitlHostSurface.js +14 -4
- package/dist/hitl/hostWithdrawal.d.ts +15 -0
- package/dist/hitl/hostWithdrawal.js +38 -0
- package/dist/hitl/localAllowRedemption.d.ts +67 -0
- package/dist/hitl/localAllowRedemption.js +256 -0
- package/dist/hitl/parkResolver.js +32 -13
- package/dist/hitl/persistedRulesWire.d.ts +16 -0
- package/dist/hitl/persistedRulesWire.js +72 -2
- package/dist/hitl/planReviewWire.d.ts +3 -0
- package/dist/hitl/planReviewWire.js +37 -10
- package/dist/hitl/policyDenyCause.d.ts +1 -1
- package/dist/hitl/policyDenyCause.js +1 -1
- package/dist/hitl/resumeRunningCard.d.ts +1 -0
- package/dist/hitl/resumeRunningCard.js +1 -0
- package/dist/hitl/screenCardCarriers.d.ts +15 -0
- package/dist/hitl/screenCardCarriers.js +41 -0
- package/dist/hitl/screenDecisionCards.d.ts +98 -0
- package/dist/hitl/screenDecisionCards.js +362 -0
- package/dist/hitl/sessionPolicyWire.js +6 -4
- package/dist/hitl/standingRows.d.ts +4 -1
- package/dist/hitl/standingRows.js +33 -1
- package/dist/hitl/toolApprovalWire.d.ts +64 -15
- package/dist/hitl/toolApprovalWire.js +470 -125
- package/dist/hooksWireCaps.js +31 -1
- package/dist/hostSettingNoticeArm.d.ts +3 -0
- package/dist/hostSettingNoticeArm.js +12 -0
- package/dist/hostTurnSettings.d.ts +13 -4
- package/dist/hostTurnSettings.js +150 -10
- package/dist/humanTurnRead.js +11 -1
- package/dist/i18n/messages.en.d.ts +212 -0
- package/dist/i18n/messages.en.js +217 -5
- package/dist/i18n/messages.zh.js +235 -5
- package/dist/i18n/translate.d.ts +3 -0
- package/dist/i18n/translate.js +78 -10
- package/dist/i18n/zh.d.ts +1 -0
- package/dist/i18n/zh.js +1 -0
- package/dist/index.d.ts +56 -16
- package/dist/index.js +40 -12
- package/dist/inheritEnvCapability.js +2 -0
- package/dist/inputAuthor.d.ts +16 -0
- package/dist/inputAuthor.js +44 -0
- package/dist/interactiveHalt.js +2 -1
- package/dist/interactiveInterrupt.js +20 -2
- package/dist/interruptRefusalNote.d.ts +2 -0
- package/dist/interruptRefusalNote.js +17 -0
- package/dist/liveModelCatalog.d.ts +2 -0
- package/dist/liveModelCatalog.js +23 -9
- package/dist/liveQuestionStore.d.ts +4 -1
- package/dist/liveQuestionStore.js +12 -3
- package/dist/localEngineSeatReading.d.ts +2 -2
- package/dist/localEngineSeatReading.js +5 -3
- package/dist/localEngineSpawn.d.ts +0 -7
- package/dist/localEngineSpawn.js +0 -92
- package/dist/localEngineStep.d.ts +2 -2
- package/dist/localEngineStep.js +2 -0
- package/dist/mcpEngineLeg.d.ts +3 -0
- package/dist/mcpEngineLeg.js +38 -1
- package/dist/mcpPanel.js +2 -0
- package/dist/mcpReconnect.d.ts +9 -1
- package/dist/mcpReconnect.js +124 -19
- package/dist/mcpWireCaps.js +1 -1
- package/dist/model/engineModelWords.d.ts +3 -0
- package/dist/model/engineModelWords.js +13 -0
- package/dist/model/subagentModelWord.d.ts +21 -2
- package/dist/model/subagentModelWord.js +100 -29
- package/dist/modelCapabilityProbe.js +7 -43
- package/dist/modsFace.d.ts +8 -1
- package/dist/modsFace.js +27 -0
- package/dist/notifications.d.ts +36 -6
- package/dist/notifications.js +170 -20
- package/dist/ownKey.d.ts +6 -5
- package/dist/ownKey.js +31 -7
- package/dist/peerFrames.d.ts +40 -2
- package/dist/peerFrames.js +158 -3
- package/dist/pendingUserRow.d.ts +4 -0
- package/dist/pendingUserRow.js +16 -0
- package/dist/permissionsDeclaration.d.ts +1 -0
- package/dist/permissionsDeclaration.js +11 -1
- package/dist/planReviewCardFacts.d.ts +3 -0
- package/dist/planReviewCardFacts.js +52 -2
- package/dist/pluginHooksWire.d.ts +10 -1
- package/dist/pluginHooksWire.js +96 -7
- package/dist/printToolResultFrame.js +4 -2
- package/dist/promptBlockedCopy.js +11 -6
- package/dist/promptSuggestionBatch.d.ts +7 -0
- package/dist/promptSuggestionBatch.js +9 -0
- package/dist/promptSuggestionsTail.d.ts +39 -0
- package/dist/promptSuggestionsTail.js +116 -0
- package/dist/replayBody.js +10 -2
- package/dist/request/taskRequest.d.ts +5 -0
- package/dist/request/taskRequest.js +142 -21
- package/dist/requestCoordinate.d.ts +1 -0
- package/dist/requestCoordinate.js +13 -0
- package/dist/resumeRefusalCopy.d.ts +1 -3
- package/dist/resumeRefusalCopy.js +2 -1
- package/dist/retryStatus.d.ts +2 -2
- package/dist/retryStatus.js +2 -0
- package/dist/rewindArchiveReading.js +4 -4
- package/dist/runCancelContext.d.ts +2 -1
- package/dist/runCancelContext.js +1 -0
- package/dist/runPermissionModeSwitch.js +2 -2
- package/dist/scenarioRefusal.js +11 -13
- package/dist/scenarioSkills.js +11 -6
- package/dist/seam.d.ts +27 -2
- package/dist/seam.js +17 -1
- package/dist/seatContract.d.ts +189 -12
- package/dist/seatContract.js +401 -9
- package/dist/sessionBackground.js +2 -1
- package/dist/sessionBackgroundHandoff.js +2 -1
- package/dist/sessionCostReading.d.ts +70 -0
- package/dist/sessionCostReading.js +150 -0
- package/dist/sessionEngine.d.ts +2 -0
- package/dist/sessionEngine.js +111 -0
- package/dist/sessionHooksRoster.d.ts +4 -0
- package/dist/sessionHooksRoster.js +158 -0
- package/dist/sessionMemoryStatus.d.ts +2 -1
- package/dist/sessionMemoryStatus.js +2 -2
- package/dist/sessionReadRedaction.d.ts +7 -0
- package/dist/sessionReadRedaction.js +26 -0
- package/dist/sessionSyncFileHistory.d.ts +4 -0
- package/dist/sessionSyncFileHistory.js +27 -0
- package/dist/settingsHooksSalvage.js +2 -1
- package/dist/sseIdleTriage.d.ts +13 -1
- package/dist/sseIdleTriage.js +25 -6
- package/dist/storeDurabilityWord.d.ts +15 -0
- package/dist/storeDurabilityWord.js +18 -0
- package/dist/storePostureCapability.d.ts +7 -3
- package/dist/storePostureCapability.js +69 -39
- package/dist/subagent/engineSubagentResume.js +2 -2
- package/dist/subagent/engineSubagentTail.js +8 -1
- package/dist/subagentContentStore.d.ts +11 -0
- package/dist/subagentContentStore.js +28 -2
- package/dist/terminalStatuses.d.ts +1 -0
- package/dist/terminalStatuses.js +4 -1
- package/dist/toolResult.d.ts +1 -0
- package/dist/toolResult.js +2 -0
- package/dist/turnFailurePresentation.js +9 -2
- package/dist/typePins.d.ts +11 -0
- package/dist/usageAnalytics.d.ts +17 -0
- package/dist/usageAnalytics.js +44 -2
- package/dist/userAttachmentEnvelope.d.ts +2 -1
- package/dist/userAttachmentEnvelope.js +10 -0
- package/dist/wireErrorTriage.js +2 -1
- package/dist/wireFailureShape.d.ts +6 -5
- package/dist/wireFailureShape.js +150 -38
- package/dist/wireRefusalCopy.d.ts +16 -5
- package/dist/wireRefusalCopy.js +119 -86
- package/docs/INTEGRATION-CLIENTS.md +4228 -21
- package/package.json +7 -3
package/dist/hooksWireCaps.js
CHANGED
|
@@ -9,7 +9,7 @@ import { admittedLayers, layerAdmissionWord } from './settingsLayerAdmission.js'
|
|
|
9
9
|
import { guardedRead, readOwnDataValue } from './ownKey.js';
|
|
10
10
|
import { HOOK_SETTINGS_SOURCE_TEXT, hooksSalvageMaskOf, salvageSettingsHooksEntries, settingsHooksSalvageNotice } from './settingsHooksSalvage.js';
|
|
11
11
|
import { submissionOriginOf } from './request/submissionIdentity.js';
|
|
12
|
-
import { createSettingsHookJudge, decidePluginHooks, decideSessionHooks, dedupeSettingsHookGroups, filterSettingsHookGroups, hooksWirePlanShapeOf, occupancyOf, } from './pluginHooksWire.js';
|
|
12
|
+
import { createSettingsHookJudge, decidePluginHooks, decideSessionHooks, dedupeSettingsHookGroups, filterSettingsHookGroups, hooksWirePlanShapeOf, hookEntryTypeWordOf, isEngineFiredHookEvent, occupancyOf, } from './pluginHooksWire.js';
|
|
13
13
|
import { MAX_HOOK_NOTICE_TEXT_CHARS } from './notifications.js';
|
|
14
14
|
import { applyHttpHookPolicy, httpHookAdmittedSources, readHttpHookPolicy, wireHasHttpEntry } from './httpHookPolicy.js';
|
|
15
15
|
import { goalStopHookMatcher, __resetGoalStopHookForTests } from './goalStopHook.js';
|
|
@@ -300,6 +300,32 @@ function withheldRowsOf(candidates, trust, layers) {
|
|
|
300
300
|
}
|
|
301
301
|
return rows;
|
|
302
302
|
}
|
|
303
|
+
function closedDropRowsOf(source, doc, reason) {
|
|
304
|
+
const rows = [];
|
|
305
|
+
try {
|
|
306
|
+
const hooks = readOwnDataValue(doc, 'hooks');
|
|
307
|
+
if (typeof hooks !== 'object' || hooks === null || Array.isArray(hooks))
|
|
308
|
+
return rows;
|
|
309
|
+
for (const event of Object.keys(hooks)) {
|
|
310
|
+
const groups = readOwnDataValue(hooks, event);
|
|
311
|
+
if (!Array.isArray(groups))
|
|
312
|
+
continue;
|
|
313
|
+
groups.forEach((group, groupIndex) => {
|
|
314
|
+
if (typeof group !== 'object' || group === null)
|
|
315
|
+
return;
|
|
316
|
+
const entries = readOwnDataValue(group, 'hooks');
|
|
317
|
+
if (!Array.isArray(entries))
|
|
318
|
+
return;
|
|
319
|
+
entries.forEach((entry, hookIndex) => {
|
|
320
|
+
rows.push({ source, event, groupIndex, hookIndex, ...hookEntryTypeWordOf(entry), reason, notRun: true });
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
catch {
|
|
326
|
+
}
|
|
327
|
+
return rows;
|
|
328
|
+
}
|
|
303
329
|
function buildHooksWirePlan(read, engine, shellRuns, promptAuthoredByUser, suppressedLocally, readerNotRead, compactionOnShell = false) {
|
|
304
330
|
const settingsDropped = [];
|
|
305
331
|
const settingsVerdicts = [];
|
|
@@ -333,6 +359,8 @@ function buildHooksWirePlan(read, engine, shellRuns, promptAuthoredByUser, suppr
|
|
|
333
359
|
});
|
|
334
360
|
const closedPlan = (reason) => {
|
|
335
361
|
closedBy = reason;
|
|
362
|
+
for (const source of ALL_HOOK_SOURCES)
|
|
363
|
+
settingsDropped.push(...closedDropRowsOf(source, read.layers[source].doc, reason));
|
|
336
364
|
sessionReader = read.sessionHooks.state;
|
|
337
365
|
const pr = read.plugins;
|
|
338
366
|
if (pr.reading === undefined)
|
|
@@ -472,6 +500,8 @@ function buildHooksWirePlan(read, engine, shellRuns, promptAuthoredByUser, suppr
|
|
|
472
500
|
settingsDropped.push(...kept.drops);
|
|
473
501
|
settingsVerdicts.push(...kept.verdicts);
|
|
474
502
|
settingsExcluded.push(...kept.excluded);
|
|
503
|
+
if (!isEngineFiredHookEvent(event))
|
|
504
|
+
continue;
|
|
475
505
|
settingsStripped += kept.stripped;
|
|
476
506
|
if (kept.groups.length === 0)
|
|
477
507
|
continue;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type HostSettingNotice } from './hostTurnSettings.js';
|
|
2
|
+
import type { HostSettingNoticeChromeEvent } from './seam.js';
|
|
3
|
+
export declare function hostSettingNoticeEventsOf(notices: readonly HostSettingNotice[] | null | undefined): readonly HostSettingNoticeChromeEvent[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { hostSettingNoticeCopiesOf } from './hostTurnSettings.js';
|
|
2
|
+
import { appendOwnElement } from './ownKey.js';
|
|
3
|
+
export function hostSettingNoticeEventsOf(notices) {
|
|
4
|
+
const out = [];
|
|
5
|
+
const copies = hostSettingNoticeCopiesOf(notices);
|
|
6
|
+
for (let i = 0; i < copies.length; i++) {
|
|
7
|
+
const copy = copies[i];
|
|
8
|
+
if (copy !== undefined)
|
|
9
|
+
appendOwnElement(out, Object.freeze({ kind: 'host_setting_notice', laneProof: Object.freeze({ lane: 'main' }), ...copy }));
|
|
10
|
+
}
|
|
11
|
+
return Object.freeze(out);
|
|
12
|
+
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import type { TaskRequest } from '@sema-agent/sdk';
|
|
1
|
+
import type { SemaSettings, TaskRequest } from '@sema-agent/sdk';
|
|
2
2
|
import type { WireHooksConfig } from './finalVerifyWire.js';
|
|
3
3
|
import type { memoryOffDeclared as MemoryOffDeclared } from './request/taskRequest.js';
|
|
4
4
|
import type { EnvLike } from './hostEnv.js';
|
|
5
5
|
import { type SettingsDocument } from './host.js';
|
|
6
|
-
import type
|
|
6
|
+
import { type HooksWirePlan, type HooksWirePlanOptions } from './pluginHooksWire.js';
|
|
7
7
|
import { type HostSettingsLayer, type HostSettingsSession, type HostSettingsSource } from './hostSettingsSource.js';
|
|
8
8
|
import { type SubmissionIdentity } from './request/submissionIdentity.js';
|
|
9
9
|
import { type WebSearchApiKeyFor } from './webSearchWireCaps.js';
|
|
10
10
|
import { type FileHistoryCaptureReading } from './fileHistoryCaptureCapability.js';
|
|
11
11
|
import { type PermissionsAllowGrantReading } from './permissionsAllowGrantCapability.js';
|
|
12
|
-
export declare const HOST_SUPPLIED_KEYS: readonly ["settings.hooks", "settings.resolved", "settings.webSearch", "settings.outputStyle", "memory", "fileHistory"];
|
|
12
|
+
export declare const HOST_SUPPLIED_KEYS: readonly ["settings.hooks", "settings.resolved", "settings.webSearch", "settings.outputStyle", "memory", "fileHistory", "settings.env"];
|
|
13
13
|
export type HostSuppliedKey = (typeof HOST_SUPPLIED_KEYS)[number];
|
|
14
14
|
export declare const HOST_SETTING_CAUSES: readonly ["carried", "entries_dropped", "source_rejected", "projection_failed", "source_unreadable", "empty", "no_source", "host_port_missing", "value_malformed", "held_previous", "policy_withheld"];
|
|
15
15
|
export type HostSettingCause = (typeof HOST_SETTING_CAUSES)[number];
|
|
16
16
|
export declare const HOST_SETTING_DISPOSITIONS: readonly ["carry", "carry_partial", "withhold_notice", "withhold_by_policy", "hold_for_consent", "refuse_turn", "unwired", "nothing_to_carry"];
|
|
17
17
|
export type HostSettingDisposition = (typeof HOST_SETTING_DISPOSITIONS)[number];
|
|
18
18
|
export type HostSettingPlane = 'turn' | 'session' | 'diagnostic';
|
|
19
|
-
export type HostSettingNoticeId = 'HS-UNWIRED' | 'HS-MANAGED-REJECTED' | 'HS-PROJECTION' | 'HS-SOURCE-UNREADABLE' | 'HS-WEBSEARCH-MALFORMED' | 'HS-SWITCH-MALFORMED' | 'HS-FILEHISTORY-UNJUDGED' | 'HS-FILEHISTORY-RESTORE' | 'HS-MANAGED-UNREADABLE' | 'HS-LAYER-NOT-LOADED' | 'HS-HELD-PREVIOUS' | 'HS-STYLE-MISSING' | 'HS-STYLE-SAFE' | 'HS-LAYER-PARTS-UNREAD';
|
|
19
|
+
export type HostSettingNoticeId = 'HS-UNWIRED' | 'HS-MANAGED-REJECTED' | 'HS-PROJECTION' | 'HS-SOURCE-UNREADABLE' | 'HS-WEBSEARCH-MALFORMED' | 'HS-SWITCH-MALFORMED' | 'HS-FILEHISTORY-UNJUDGED' | 'HS-FILEHISTORY-RESTORE' | 'HS-MANAGED-UNREADABLE' | 'HS-LAYER-NOT-LOADED' | 'HS-HELD-PREVIOUS' | 'HS-STYLE-MISSING' | 'HS-STYLE-SAFE' | 'HS-LAYER-PARTS-UNREAD' | 'HS-STYLE-OVERSIZE' | 'HS-STYLE-UNREADABLE';
|
|
20
20
|
export interface HostSettingRow {
|
|
21
21
|
readonly key: HostSuppliedKey;
|
|
22
22
|
readonly cause: HostSettingCause;
|
|
@@ -27,6 +27,8 @@ export interface HostSettingNotice {
|
|
|
27
27
|
readonly id: HostSettingNoticeId;
|
|
28
28
|
readonly plane: HostSettingPlane;
|
|
29
29
|
readonly text: string;
|
|
30
|
+
readonly key?: HostSuppliedKey;
|
|
31
|
+
readonly cause?: HostSettingCause;
|
|
30
32
|
}
|
|
31
33
|
export type HostTurnVerdict = {
|
|
32
34
|
readonly kind: 'send';
|
|
@@ -61,6 +63,9 @@ export interface HostTurnSettingsSources {
|
|
|
61
63
|
readonly reading: FileHistoryCaptureReading;
|
|
62
64
|
readonly captureOff: boolean;
|
|
63
65
|
} | 'none';
|
|
66
|
+
readonly env: {
|
|
67
|
+
readonly env: EnvLike;
|
|
68
|
+
} | 'none';
|
|
64
69
|
}
|
|
65
70
|
export interface HostWebSearchSource {
|
|
66
71
|
readonly env: EnvLike;
|
|
@@ -83,6 +88,7 @@ export interface HostSettingsCarried {
|
|
|
83
88
|
readonly outputStyle?: string;
|
|
84
89
|
readonly memory?: TaskRequest['memory'];
|
|
85
90
|
readonly fileHistory?: TaskRequest['fileHistory'];
|
|
91
|
+
readonly env?: NonNullable<SemaSettings['env']>;
|
|
86
92
|
}
|
|
87
93
|
export interface HostOutputStyleFacts {
|
|
88
94
|
readonly name: string;
|
|
@@ -108,6 +114,7 @@ export interface HostSettingsHeld {
|
|
|
108
114
|
};
|
|
109
115
|
readonly version: string;
|
|
110
116
|
}
|
|
117
|
+
export declare function hookEnvNamesOf(hooks: unknown): readonly string[];
|
|
111
118
|
export interface HostTurnSettingsJudges {
|
|
112
119
|
readonly materialize: HostResolvedMaterializer;
|
|
113
120
|
readonly memoryOffDeclared: typeof MemoryOffDeclared;
|
|
@@ -137,6 +144,7 @@ export declare function hostSettingsAcceptCurrent(product: HostTurnSettings, con
|
|
|
137
144
|
export declare function hostSettingsSelfCheck(product: HostTurnSettings): readonly HostSuppliedKey[];
|
|
138
145
|
export declare const hostProjectionNotice: () => HostSettingNotice;
|
|
139
146
|
export declare const hostFileHistoryRestoreNotice: () => HostSettingNotice;
|
|
147
|
+
export declare const hostStyleNotAppliedNotice: (cause: "oversize" | "unreadable", limit: number) => HostSettingNotice;
|
|
140
148
|
export declare class HostSettingsRefused extends Error {
|
|
141
149
|
readonly notice: HostSettingNotice;
|
|
142
150
|
constructor(n: HostSettingNotice);
|
|
@@ -160,6 +168,7 @@ export interface HostIntakeSnapshot {
|
|
|
160
168
|
readonly error: {} | null | undefined;
|
|
161
169
|
} | undefined;
|
|
162
170
|
}
|
|
171
|
+
export declare function hostSettingNoticeCopiesOf(notices: readonly HostSettingNotice[] | null | undefined): readonly HostSettingNotice[];
|
|
163
172
|
export declare function hostIntakeSnapshotOf(product: HostTurnSettings, onResolved?: (resolved: HostSettingsCarried['resolved']) => void): HostIntakeSnapshot | undefined;
|
|
164
173
|
export declare function hostSettingsRefusedError(n: HostSettingNotice, intake: HostIntakeSnapshot, firstSeatedKey: HostSuppliedKey | undefined): HostSettingsRefused;
|
|
165
174
|
export declare const UNWIRED_HOST_TURN_SETTINGS: HostTurnSettings;
|
package/dist/hostTurnSettings.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SETTINGS_CLASSIFY_HOOKS_CONFIG } from './generated/settingsSchemaFns.js';
|
|
2
2
|
import { hostLog } from './host.js';
|
|
3
|
+
import { isEngineFiredHookEvent } from './pluginHooksWire.js';
|
|
3
4
|
import { layerNotAppliedRefusesTurn, salvageSettingsHooksEntries } from './settingsHooksSalvage.js';
|
|
4
5
|
import { ADOPTED_LAYERS, HOST_SETTINGS_LAYERS, HostSettingsSourceShapeError, TIGHTEN_ONLY_HOST_SETTINGS_LAYERS, permissionBucketOf, permissionRulesOf, MANAGED_READING_DISPOSITIONS, adoptHostSettingsRead, mintHostSettingsSession, readHostSettingsOnce, remintSameContent, sessionSnapshotOf, settingsValueOf, sourceOfRead, } from './hostSettingsSource.js';
|
|
5
6
|
import { hooksWirePlan } from './hooksWireCaps.js';
|
|
@@ -13,8 +14,8 @@ import { assemblyRefusalOf } from './wireFailureShape.js';
|
|
|
13
14
|
import { permissionRuleLayersOn } from './permissionsAllowGrantCapability.js';
|
|
14
15
|
import { layerAdmissionReading, layerAdmitted } from './settingsLayerAdmission.js';
|
|
15
16
|
import { SETTINGS_BUILD_LAYER_PARTS_UNREAD_NOTICE } from './generated/settingsSchemaFns.js';
|
|
16
|
-
import { appendOwnElement, ownDataField } from './ownKey.js';
|
|
17
|
-
export const HOST_SUPPLIED_KEYS = Object.freeze(['settings.hooks', 'settings.resolved', 'settings.webSearch', 'settings.outputStyle', 'memory', 'fileHistory']);
|
|
17
|
+
import { appendOwnElement, ownDataField, readOwnDataValue } from './ownKey.js';
|
|
18
|
+
export const HOST_SUPPLIED_KEYS = Object.freeze(['settings.hooks', 'settings.resolved', 'settings.webSearch', 'settings.outputStyle', 'memory', 'fileHistory', 'settings.env']);
|
|
18
19
|
export const HOST_SETTING_CAUSES = Object.freeze([
|
|
19
20
|
'carried',
|
|
20
21
|
'entries_dropped',
|
|
@@ -44,6 +45,8 @@ const HOST_SETTING_NOTICE_TEXT = {
|
|
|
44
45
|
'HS-STYLE-MISSING': (what) => renderMessage(msg('session.hostSettings.styleMissing', { name: what })),
|
|
45
46
|
'HS-STYLE-SAFE': () => renderMessage(msg('session.hostSettings.styleSafeMode')),
|
|
46
47
|
'HS-LAYER-PARTS-UNREAD': (line) => line,
|
|
48
|
+
'HS-STYLE-OVERSIZE': (what) => renderMessage(msg('session.hostSettings.styleOversize', { limit: what })),
|
|
49
|
+
'HS-STYLE-UNREADABLE': () => renderMessage(msg('session.hostSettings.styleUnreadable')),
|
|
47
50
|
};
|
|
48
51
|
const KEY_NOUN = {
|
|
49
52
|
'settings.hooks': 'the hooks',
|
|
@@ -52,6 +55,7 @@ const KEY_NOUN = {
|
|
|
52
55
|
'settings.outputStyle': 'the output style',
|
|
53
56
|
memory: 'auto-memory',
|
|
54
57
|
fileHistory: 'file checkpoints',
|
|
58
|
+
'settings.env': 'the environment variables your HTTP hooks read',
|
|
55
59
|
};
|
|
56
60
|
const BASE_DISPOSITION = {
|
|
57
61
|
carried: 'carry',
|
|
@@ -204,6 +208,98 @@ function webSearchArm(src, side) {
|
|
|
204
208
|
notices: [notice('HS-WEBSEARCH-MALFORMED', 'turn', webSearchVerdictMessage(verdict, 'submit') ?? '')],
|
|
205
209
|
};
|
|
206
210
|
}
|
|
211
|
+
function ownElementsOf(v) {
|
|
212
|
+
if (!Array.isArray(v))
|
|
213
|
+
return [];
|
|
214
|
+
const len = readOwnDataValue(v, 'length');
|
|
215
|
+
if (typeof len !== 'number' || !Number.isSafeInteger(len) || len < 0)
|
|
216
|
+
return [];
|
|
217
|
+
const out = [];
|
|
218
|
+
for (let i = 0; i < len; i++)
|
|
219
|
+
appendOwnElement(out, readOwnDataValue(v, String(i)));
|
|
220
|
+
return out;
|
|
221
|
+
}
|
|
222
|
+
export function hookEnvNamesOf(hooks) {
|
|
223
|
+
const out = [];
|
|
224
|
+
if (!isRecordShape(hooks))
|
|
225
|
+
return out;
|
|
226
|
+
for (const event of Object.keys(hooks)) {
|
|
227
|
+
if (!isEngineFiredHookEvent(event))
|
|
228
|
+
continue;
|
|
229
|
+
for (const group of ownElementsOf(readOwnDataValue(hooks, event))) {
|
|
230
|
+
if (!isRecordShape(group))
|
|
231
|
+
continue;
|
|
232
|
+
for (const entry of ownElementsOf(readOwnDataValue(group, 'hooks'))) {
|
|
233
|
+
if (!isRecordShape(entry) || readOwnDataValue(entry, 'type') !== 'http')
|
|
234
|
+
continue;
|
|
235
|
+
for (const name of ownElementsOf(readOwnDataValue(entry, 'allowedEnvVars'))) {
|
|
236
|
+
if (typeof name === 'string' && !out.includes(name))
|
|
237
|
+
appendOwnElement(out, name);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return out;
|
|
243
|
+
}
|
|
244
|
+
function hookEnvLayerOf(names, env) {
|
|
245
|
+
const layer = {};
|
|
246
|
+
let n = 0;
|
|
247
|
+
for (const name of names) {
|
|
248
|
+
const v = readOwnDataValue(env, name);
|
|
249
|
+
if (typeof v !== 'string')
|
|
250
|
+
continue;
|
|
251
|
+
Object.defineProperty(layer, name, { value: v, enumerable: true, writable: true, configurable: true });
|
|
252
|
+
n++;
|
|
253
|
+
}
|
|
254
|
+
return n > 0 ? freeze(layer) : undefined;
|
|
255
|
+
}
|
|
256
|
+
function hookEnvConsistent(env, hooks) {
|
|
257
|
+
if (env === undefined)
|
|
258
|
+
return true;
|
|
259
|
+
try {
|
|
260
|
+
if (!isRecordShape(env))
|
|
261
|
+
return false;
|
|
262
|
+
const keys = Reflect.ownKeys(env);
|
|
263
|
+
if (keys.length === 0)
|
|
264
|
+
return false;
|
|
265
|
+
const names = hookEnvNamesOf(hooks);
|
|
266
|
+
return keys.every((k) => typeof k === 'string' && names.includes(k) && typeof readOwnDataValue(env, k) === 'string');
|
|
267
|
+
}
|
|
268
|
+
catch {
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
function envArm(src, hooksCarried) {
|
|
273
|
+
const key = 'settings.env';
|
|
274
|
+
if (src.kind === 'missing')
|
|
275
|
+
return missingArm(key);
|
|
276
|
+
if (src.kind === 'threw')
|
|
277
|
+
return unreadableArm(key);
|
|
278
|
+
const v = src.value;
|
|
279
|
+
if (v === 'none')
|
|
280
|
+
return noSourceArm(key);
|
|
281
|
+
let env;
|
|
282
|
+
try {
|
|
283
|
+
if (!isRecordShape(v) || !Object.hasOwn(v, 'env'))
|
|
284
|
+
throw badSource(key, "{ env } with the host environment (pass 'none' where there is none)");
|
|
285
|
+
env = v.env;
|
|
286
|
+
}
|
|
287
|
+
catch (e) {
|
|
288
|
+
if (e instanceof HostSourceShapeError)
|
|
289
|
+
throw e;
|
|
290
|
+
return unreadableArm(key);
|
|
291
|
+
}
|
|
292
|
+
if (!isRecordShape(env))
|
|
293
|
+
throw badSource(key, '{ env } where env is the environment record');
|
|
294
|
+
let layer;
|
|
295
|
+
try {
|
|
296
|
+
layer = hookEnvLayerOf(hookEnvNamesOf(hooksCarried), env);
|
|
297
|
+
}
|
|
298
|
+
catch {
|
|
299
|
+
return unreadableArm(key);
|
|
300
|
+
}
|
|
301
|
+
return layer === undefined ? emptyArm(key) : carriedArm(key, layer);
|
|
302
|
+
}
|
|
207
303
|
function memoryArm(src, side, judge) {
|
|
208
304
|
const key = 'memory';
|
|
209
305
|
if (src.kind === 'missing')
|
|
@@ -336,7 +432,7 @@ function outputStyleArm(src, side) {
|
|
|
336
432
|
const reminder = state.ok && state.value === 'present' ? ownDataOf(body, 'turnReminder') : undefined;
|
|
337
433
|
if (text !== undefined && text.ok && typeof text.value === 'string' && reminder !== undefined && reminder.ok && (reminder.value === undefined || typeof reminder.value === 'string')) {
|
|
338
434
|
const facts = freeze({ name, body: text.value, ...(reminder.value !== undefined ? { turnReminder: reminder.value } : {}) });
|
|
339
|
-
return { ...carriedArm(key,
|
|
435
|
+
return text.value.trim() === '' ? { ...emptyArm(key), facts } : { ...carriedArm(key, text.value), facts };
|
|
340
436
|
}
|
|
341
437
|
return {
|
|
342
438
|
row: freeze({ key, cause: 'source_unreadable', disposition: 'withhold_notice' }),
|
|
@@ -709,6 +805,7 @@ export function buildHostTurnSettings(input, judges) {
|
|
|
709
805
|
const outputStyle = outputStyleArm(read('outputStyle'), side);
|
|
710
806
|
const memory = memoryArm(read('memory'), side, judges.memoryOffDeclared);
|
|
711
807
|
const fileHistory = fileHistoryArm(read('fileHistory'));
|
|
808
|
+
const envSource = read('env');
|
|
712
809
|
let resolved = resolvedArm;
|
|
713
810
|
let armsByKey = [hooks, resolved, webSearch, outputStyle, memory, fileHistory];
|
|
714
811
|
if (side.kind === 'read' && MANAGED_READING_DISPOSITIONS[side.read.managed].commit === 'refuse') {
|
|
@@ -765,16 +862,20 @@ export function buildHostTurnSettings(input, judges) {
|
|
|
765
862
|
armsByKey = [{ ...mark(armsByKey[0]), ...(hooks.plan !== undefined ? { plan: hooks.plan } : {}) }, mark(armsByKey[1]), armsByKey[2], armsByKey[3], armsByKey[4], armsByKey[5]];
|
|
766
863
|
appendOwnElement(heldNotices, notice('HS-HELD-PREVIOUS', 'diagnostic'));
|
|
767
864
|
}
|
|
768
|
-
const
|
|
865
|
+
const hooksFinal = armsByKey[0];
|
|
866
|
+
const hooksToCarry = hooksFinal.row.disposition === 'carry' || hooksFinal.row.disposition === 'carry_partial' || hooksFinal.row.disposition === 'hold_for_consent' ? hooksFinal.carried : undefined;
|
|
867
|
+
const env = envArm(envSource, hooksToCarry);
|
|
868
|
+
const arms = [...armsByKey, env];
|
|
769
869
|
const rows = freeze(arms.map((a) => a.row));
|
|
770
870
|
const resolvedOut = arms[1]?.row.disposition === 'carry' || arms[1]?.row.disposition === 'carry_partial' || arms[1]?.row.disposition === 'hold_for_consent' ? resolvedCarried : undefined;
|
|
771
871
|
const permissionsRow = arms[1]?.row;
|
|
772
872
|
const permissionsRead = permissionsRow !== undefined && permissionsRow.disposition !== 'refuse_turn' && permissionsRow.disposition !== 'unwired' && permissionsRow.cause !== 'no_source';
|
|
773
873
|
const partsNotices = side.kind === 'read' ? tightenOnlyLayerNotices(side.read, permissionsRead) : [];
|
|
774
|
-
const
|
|
775
|
-
const
|
|
776
|
-
const
|
|
777
|
-
|
|
874
|
+
const armNotices = arms.map((a) => a.notices.map((n) => freeze({ ...n, key: a.row.key, cause: a.row.cause })));
|
|
875
|
+
const notices = freeze([...armNotices.flat(), ...notLoadedNotices, ...heldNotices, ...partsNotices]);
|
|
876
|
+
const refusalAt = arms.findIndex((a) => a.row.disposition === 'refuse_turn');
|
|
877
|
+
const verdict = refusalAt >= 0
|
|
878
|
+
? freeze({ kind: 'refuse', notice: armNotices[refusalAt]?.[0] ?? notices.find((n) => n.plane === 'turn') ?? notice('HS-PROJECTION', 'turn') })
|
|
778
879
|
: consentKey !== undefined
|
|
779
880
|
? freeze({ kind: 'hold', consentKey, notice: notLoadedNotices[0] })
|
|
780
881
|
: freeze({ kind: 'send' });
|
|
@@ -790,8 +891,10 @@ export function buildHostTurnSettings(input, judges) {
|
|
|
790
891
|
...(carriedOf(3) !== undefined ? { outputStyle: carriedOf(3) } : {}),
|
|
791
892
|
...(carriedOf(4) !== undefined ? { memory: 'off' } : {}),
|
|
792
893
|
...(carriedOf(5) !== undefined ? { fileHistory: 'disabled' } : {}),
|
|
894
|
+
...(carriedOf(6) !== undefined ? { env: carriedOf(6) } : {}),
|
|
793
895
|
});
|
|
794
|
-
const
|
|
896
|
+
const styleDisposition = arms[3]?.row.disposition;
|
|
897
|
+
const styleFacts = styleDisposition === 'carry' || styleDisposition === 'nothing_to_carry' ? outputStyle.facts : undefined;
|
|
795
898
|
const product = { verdict, rows, notices, hooks: hooks.plan, carried, session: nextSession, outputStyle: styleFacts, held };
|
|
796
899
|
if (resolvedError !== undefined && resolvedOut !== undefined)
|
|
797
900
|
Object.defineProperty(product, RESOLVED_DEFERRED_ERROR, { value: resolvedError, enumerable: false });
|
|
@@ -910,6 +1013,7 @@ export function hostSettingsSelfCheck(product) {
|
|
|
910
1013
|
}
|
|
911
1014
|
export const hostProjectionNotice = () => notice('HS-PROJECTION', 'turn');
|
|
912
1015
|
export const hostFileHistoryRestoreNotice = () => notice('HS-FILEHISTORY-RESTORE', 'turn');
|
|
1016
|
+
export const hostStyleNotAppliedNotice = (cause, limit) => cause === 'oversize' ? notice('HS-STYLE-OVERSIZE', 'turn', String(limit)) : notice('HS-STYLE-UNREADABLE', 'turn');
|
|
913
1017
|
export class HostSettingsRefused extends Error {
|
|
914
1018
|
notice;
|
|
915
1019
|
constructor(n) {
|
|
@@ -985,6 +1089,8 @@ export function hostTurnSettingsOf(v, depth = 'full') {
|
|
|
985
1089
|
return undefined;
|
|
986
1090
|
if (Object.hasOwn(carried, 'hooks') && carried.hooks !== undefined && !hooksPassJudge(carried.hooks))
|
|
987
1091
|
return undefined;
|
|
1092
|
+
if (!hookEnvConsistent(Object.hasOwn(carried, 'env') ? carried.env : undefined, Object.hasOwn(carried, 'hooks') ? carried.hooks : undefined))
|
|
1093
|
+
return undefined;
|
|
988
1094
|
return shaped;
|
|
989
1095
|
}
|
|
990
1096
|
catch {
|
|
@@ -1106,7 +1212,39 @@ function noticeCopyOf(n) {
|
|
|
1106
1212
|
const text = ownDataOf(n, 'text');
|
|
1107
1213
|
if (!id.ok || !plane.ok || !text.ok || typeof id.value !== 'string' || typeof plane.value !== 'string' || typeof text.value !== 'string')
|
|
1108
1214
|
return undefined;
|
|
1109
|
-
|
|
1215
|
+
if (plane.value !== 'turn' && plane.value !== 'session' && plane.value !== 'diagnostic')
|
|
1216
|
+
return undefined;
|
|
1217
|
+
const key = ownDataOf(n, 'key');
|
|
1218
|
+
const cause = ownDataOf(n, 'cause');
|
|
1219
|
+
const keyWord = key.ok && typeof key.value === 'string' && HOST_SUPPLIED_KEYS.includes(key.value) ? key.value : undefined;
|
|
1220
|
+
const causeWord = cause.ok && typeof cause.value === 'string' && HOST_SETTING_CAUSES.includes(cause.value) ? cause.value : undefined;
|
|
1221
|
+
return freeze({
|
|
1222
|
+
id: id.value,
|
|
1223
|
+
plane: plane.value,
|
|
1224
|
+
text: text.value,
|
|
1225
|
+
...(keyWord !== undefined ? { key: keyWord } : {}),
|
|
1226
|
+
...(causeWord !== undefined ? { cause: causeWord } : {}),
|
|
1227
|
+
});
|
|
1228
|
+
}
|
|
1229
|
+
export function hostSettingNoticeCopiesOf(notices) {
|
|
1230
|
+
const out = [];
|
|
1231
|
+
try {
|
|
1232
|
+
if (!Array.isArray(notices))
|
|
1233
|
+
return freeze(out);
|
|
1234
|
+
const len = ownDataOf(notices, 'length');
|
|
1235
|
+
if (!len.ok || typeof len.value !== 'number')
|
|
1236
|
+
return freeze(out);
|
|
1237
|
+
for (let i = 0; i < len.value; i++) {
|
|
1238
|
+
const e = ownDataOf(notices, String(i));
|
|
1239
|
+
const copy = e.ok ? noticeCopyOf(e.value) : undefined;
|
|
1240
|
+
if (copy !== undefined)
|
|
1241
|
+
appendOwnElement(out, copy);
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
catch {
|
|
1245
|
+
return freeze(out);
|
|
1246
|
+
}
|
|
1247
|
+
return freeze(out);
|
|
1110
1248
|
}
|
|
1111
1249
|
function turnNoticesOf(product) {
|
|
1112
1250
|
try {
|
|
@@ -1225,6 +1363,8 @@ function intakeSnapshotUnguarded(product, onResolved) {
|
|
|
1225
1363
|
return undefined;
|
|
1226
1364
|
if (values.hooks !== undefined && !hooksPassJudge(values.hooks))
|
|
1227
1365
|
return undefined;
|
|
1366
|
+
if (!hookEnvConsistent(values.env, values.hooks))
|
|
1367
|
+
return undefined;
|
|
1228
1368
|
const v = ownDataOf(product, 'verdict');
|
|
1229
1369
|
if (!v.ok)
|
|
1230
1370
|
return undefined;
|
package/dist/humanTurnRead.js
CHANGED
|
@@ -42,7 +42,17 @@ const strArray = (v) => ownArray(v).map(str);
|
|
|
42
42
|
const sizeOf = (v) => (v === null ? null : typeof v === 'number' ? v : bad());
|
|
43
43
|
const posInt = (v) => (typeof v === 'number' && Number.isSafeInteger(v) && v >= 1 ? v : bad());
|
|
44
44
|
const natInt = (v) => (typeof v === 'number' && Number.isSafeInteger(v) && v >= 0 ? v : bad());
|
|
45
|
-
const NOT_INCLUDED_REASON_LIST = [
|
|
45
|
+
const NOT_INCLUDED_REASON_LIST = [
|
|
46
|
+
'too-large',
|
|
47
|
+
'unreadable',
|
|
48
|
+
'read-denied',
|
|
49
|
+
'approval-required',
|
|
50
|
+
'server-not-connected',
|
|
51
|
+
'resource-not-listed',
|
|
52
|
+
'read-failed',
|
|
53
|
+
'tools-elsewhere',
|
|
54
|
+
'tools-location-unconfirmed',
|
|
55
|
+
];
|
|
46
56
|
const notIncludedReasonsExhaustive = true;
|
|
47
57
|
void notIncludedReasonsExhaustive;
|
|
48
58
|
const NOT_INCLUDED_REASONS = new Set(NOT_INCLUDED_REASON_LIST);
|