@sema-agent/client-core 0.111.0 → 0.112.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.
Files changed (106) hide show
  1. package/CHANGELOG.md +75 -0
  2. package/README.md +15 -6
  3. package/dist/agentSession/engineSessionBackgroundStop.js +2 -2
  4. package/dist/checkpointRowVerdict.d.ts +3 -0
  5. package/dist/checkpointRowVerdict.js +14 -1
  6. package/dist/consoleCaPin.d.ts +136 -0
  7. package/dist/consoleCaPin.js +827 -0
  8. package/dist/decideReceipt.d.ts +2 -1
  9. package/dist/deviceRebind.js +3 -3
  10. package/dist/effectiveFacts.d.ts +9 -0
  11. package/dist/effectiveFacts.js +33 -0
  12. package/dist/engineAddress.d.ts +1 -0
  13. package/dist/engineAddress.js +4 -1
  14. package/dist/engineCredentialRelease.d.ts +54 -0
  15. package/dist/engineCredentialRelease.js +146 -0
  16. package/dist/engineErrorCodes.d.ts +1 -0
  17. package/dist/engineErrorCodes.js +1 -0
  18. package/dist/engineHealthFacts.d.ts +0 -11
  19. package/dist/engineHealthFacts.js +0 -21
  20. package/dist/engineHealthProbeVerdict.d.ts +1 -0
  21. package/dist/engineHealthProbeVerdict.js +21 -13
  22. package/dist/engineUnavailable.d.ts +3 -2
  23. package/dist/engineUnavailable.js +16 -12
  24. package/dist/engineUrl.js +4 -2
  25. package/dist/gateFailureCodes.js +2 -2
  26. package/dist/generated/sdkFactTables.d.ts +1 -0
  27. package/dist/generated/sdkFactTables.js +13 -0
  28. package/dist/generated/settingsSchemaFns.d.ts +1 -0
  29. package/dist/generated/settingsSchemaFns.js +3 -0
  30. package/dist/generated/settingsSchemaHooksClassifier.js +38 -9
  31. package/dist/generated/settingsSchemaTables.d.ts +52 -0
  32. package/dist/generated/settingsSchemaTables.js +18 -0
  33. package/dist/generated/settingsSchemaTypes.d.ts +23 -13
  34. package/dist/generated/settingsSchemaUrlShape.d.ts +1 -0
  35. package/dist/generated/settingsSchemaUrlShape.js +17 -0
  36. package/dist/hitl/decisionRefusal.d.ts +4 -0
  37. package/dist/hitl/decisionRefusal.js +12 -2
  38. package/dist/hitl/localAllowRedemption.d.ts +9 -6
  39. package/dist/hitl/localAllowRedemption.js +20 -0
  40. package/dist/hitl/parkOwnership.js +2 -1
  41. package/dist/hitl/parkResolver.js +7 -0
  42. package/dist/hitl/screenDecisionCards.js +3 -2
  43. package/dist/hitl/sessionPolicyWire.js +2 -2
  44. package/dist/hitl/standingRows.d.ts +4 -2
  45. package/dist/hitl/standingRows.js +10 -3
  46. package/dist/hooksReaderGenerations.js +1 -1
  47. package/dist/i18n/messages.en.d.ts +163 -0
  48. package/dist/i18n/messages.en.js +163 -0
  49. package/dist/i18n/messages.zh.js +174 -0
  50. package/dist/index.d.ts +30 -5
  51. package/dist/index.js +15 -2
  52. package/dist/liveModelCatalog.d.ts +4 -0
  53. package/dist/liveModelCatalog.js +10 -1
  54. package/dist/localConfig/documents.d.ts +61 -0
  55. package/dist/localConfig/documents.js +51 -0
  56. package/dist/localConfig/kernel.d.ts +149 -0
  57. package/dist/localConfig/kernel.js +597 -0
  58. package/dist/localConfig/mcp/edit.d.ts +161 -0
  59. package/dist/localConfig/mcp/edit.js +846 -0
  60. package/dist/localConfig/mcp/servers.d.ts +165 -0
  61. package/dist/localConfig/mcp/servers.js +776 -0
  62. package/dist/localConfig/mcp/views.d.ts +170 -0
  63. package/dist/localConfig/mcp/views.js +429 -0
  64. package/dist/localConfig/modelPool.d.ts +262 -0
  65. package/dist/localConfig/modelPool.js +1489 -0
  66. package/dist/localConfig/modelPoolWords.d.ts +13 -0
  67. package/dist/localConfig/modelPoolWords.js +20 -0
  68. package/dist/localConfig/receiptShape.d.ts +7 -0
  69. package/dist/localConfig/receiptShape.js +135 -0
  70. package/dist/localConfig/settingsWrite.d.ts +127 -0
  71. package/dist/localConfig/settingsWrite.js +237 -0
  72. package/dist/localConfig/skills.d.ts +124 -0
  73. package/dist/localConfig/skills.js +397 -0
  74. package/dist/localConfig/skillsWords.d.ts +10 -0
  75. package/dist/localConfig/skillsWords.js +5 -0
  76. package/dist/mcpProbeWire.js +2 -1
  77. package/dist/mcpWireCaps.js +1 -1
  78. package/dist/memoryVerbsWire.js +3 -2
  79. package/dist/model/onboardJudgement.d.ts +14 -4
  80. package/dist/model/onboardJudgement.js +91 -139
  81. package/dist/modelConfigGapNotice.d.ts +20 -0
  82. package/dist/modelConfigGapNotice.js +102 -0
  83. package/dist/modsKernelIdentity.js +2 -47
  84. package/dist/ownKey.d.ts +1 -0
  85. package/dist/ownKey.js +40 -8
  86. package/dist/permissionsDeclaration.d.ts +2 -1
  87. package/dist/permissionsDeclaration.js +31 -17
  88. package/dist/promptBlockedCopy.js +2 -2
  89. package/dist/resumeRefusalCopy.d.ts +3 -1
  90. package/dist/resumeRefusalCopy.js +12 -4
  91. package/dist/runLedgerSnapshot.js +3 -3
  92. package/dist/runPermissionModeSwitch.js +2 -3
  93. package/dist/seatContract.d.ts +154 -4
  94. package/dist/seatContract.js +228 -2
  95. package/dist/sessionIdSegment.d.ts +1 -0
  96. package/dist/sessionIdSegment.js +4 -1
  97. package/dist/sessionMemoryErase.js +2 -1
  98. package/dist/sha256Bytes.d.ts +1 -0
  99. package/dist/sha256Bytes.js +46 -0
  100. package/dist/skillOverrideChain.d.ts +83 -0
  101. package/dist/skillOverrideChain.js +378 -0
  102. package/dist/skillsWireCaps.d.ts +3 -0
  103. package/dist/skillsWireCaps.js +16 -1
  104. package/dist/turnFailurePresentation.js +4 -10
  105. package/docs/INTEGRATION-CLIENTS.md +614 -14
  106. package/package.json +3 -3
@@ -1,5 +1,6 @@
1
1
  import { type GateOutcomeView } from './gateOutcome.js';
2
2
  import { type ResumeReopenDetail } from './hitl/suspendedReopen.js';
3
+ import { ASK_GONE } from './engineErrorCodes.js';
3
4
  import { type CrashConvergedRowReading } from './hitl/crashConverged.js';
4
5
  import type { AskRowEndingCause } from '@sema-agent/sdk';
5
6
  import { SDK_DECIDE_BINDING_KEYS } from './generated/sdkFactTables.js';
@@ -41,7 +42,7 @@ export interface DecideRequiresBindingDetail {
41
42
  export declare function decideRequiresBindingFromError(e: {} | null | undefined): DecideRequiresBindingDetail | null;
42
43
  export declare function decideRequiresBindingContent(_detail?: DecideRequiresBindingDetail, lang?: UiLanguage | (string & {})): string;
43
44
  export interface AskGoneDetail {
44
- code: 'gone.ask';
45
+ code: typeof ASK_GONE;
45
46
  state?: 'VOID' | 'DENIED';
46
47
  endingCause?: AskRowEndingCause;
47
48
  holderGone?: CrashConvergedRowReading['cause'];
@@ -1,5 +1,6 @@
1
1
  import { atMostOnceVerdictOf } from './atMostOnce.js';
2
2
  import { readOwnDataValue } from './ownKey.js';
3
+ import { LIMIT_RATE_EXCEEDED } from './engineErrorCodes.js';
3
4
  import { isDisplayableWireCode, readErrorString, readErrorStrictStringList, readThrownSlot, wireFailureShapeOf } from './wireFailureShape.js';
4
5
  import { EXECUTION_PLACEMENT_DEVICE_LANE, EXECUTION_PLACEMENT_ROLES } from './executionPlacementWords.js';
5
6
  const LANE_ABSENT = 'capability.device_lane_required';
@@ -308,7 +309,6 @@ export function rebindProvesRequestNotApplied(outcome) {
308
309
  return false;
309
310
  }
310
311
  }
311
- const RATE_LIMITED = 'limit.rate_exceeded';
312
312
  const ENROLLMENT_INVALID = 'device.enrollment_invalid';
313
313
  function rateLimitedOf(e) {
314
314
  const sec = wireFailureShapeOf(e).retryAfterSec;
@@ -329,7 +329,7 @@ function issueFailureOf(e) {
329
329
  const common = commonOf(v.status, v.code);
330
330
  if (common !== null)
331
331
  return common.kind === 'not-found' ? refusedOf(404, NOT_FOUND, e) : common;
332
- if (v.status === 429 && v.code === RATE_LIMITED)
332
+ if (v.status === 429 && v.code === LIMIT_RATE_EXCEEDED)
333
333
  return rateLimitedOf(e);
334
334
  return v.status !== undefined ? refusedOf(v.status, v.code, e) : transportOf(v);
335
335
  }
@@ -359,7 +359,7 @@ function enrollFailureOf(e, token) {
359
359
  return common.kind === 'not-found' ? refusedOf(404, NOT_FOUND, e, token) : common;
360
360
  if (v.status === 403 && v.code === ENROLLMENT_INVALID)
361
361
  return { kind: 'enrollment-invalid' };
362
- if (v.status === 429 && v.code === RATE_LIMITED)
362
+ if (v.status === 429 && v.code === LIMIT_RATE_EXCEEDED)
363
363
  return rateLimitedOf(e);
364
364
  if (v.status === 503 && v.code === SERVICE_TOKEN_REQUIRED)
365
365
  return refusedOf(v.status, v.code, e, token);
@@ -30,3 +30,12 @@ export interface EffectiveMemoryScopesView {
30
30
  }
31
31
  export declare function readEffectiveReasoning(v: unknown): EffectiveReasoningView | undefined;
32
32
  export declare function readEffectiveMemoryScopes(v: unknown): EffectiveMemoryScopesView | undefined;
33
+ export type ReadDenyFloorReading = {
34
+ readonly kind: 'unkept';
35
+ readonly message: string;
36
+ } | {
37
+ readonly kind: 'not_reported';
38
+ } | {
39
+ readonly kind: 'unreadable';
40
+ };
41
+ export declare function readDenyFloorOf(result: {} | null | undefined): ReadDenyFloorReading;
@@ -1,3 +1,4 @@
1
+ import { READ_DENY_FLOOR_UNKEPT } from './engineErrorCodes.js';
1
2
  const nonEmpty = (v) => typeof v === 'string' && v.length > 0;
2
3
  const nonBlank = (v) => typeof v === 'string' && v.trim().length > 0;
3
4
  const UNREADABLE = Symbol('unreadable');
@@ -104,3 +105,35 @@ export function readEffectiveMemoryScopes(v) {
104
105
  return undefined;
105
106
  return { state: 'none', reason, scopes: [], writeScope: null };
106
107
  }
108
+ const DENY_FLOOR_NOT_REPORTED = Object.freeze({ kind: 'not_reported' });
109
+ const DENY_FLOOR_UNREADABLE = Object.freeze({ kind: 'unreadable' });
110
+ function ownSlotOf(o, key) {
111
+ const d = Object.getOwnPropertyDescriptor(o, key);
112
+ if (d === undefined)
113
+ return { absent: true };
114
+ if (!Object.hasOwn(d, 'value'))
115
+ throw new TypeError('accessor');
116
+ return { absent: false, value: d.value };
117
+ }
118
+ export function readDenyFloorOf(result) {
119
+ try {
120
+ if (typeof result !== 'object' || result === null)
121
+ return DENY_FLOOR_NOT_REPORTED;
122
+ const slot = ownSlotOf(result, 'readDenyFloor');
123
+ if (slot.absent || slot.value === undefined)
124
+ return DENY_FLOOR_NOT_REPORTED;
125
+ const v = slot.value;
126
+ if (typeof v !== 'object' || v === null || Array.isArray(v))
127
+ return DENY_FLOOR_UNREADABLE;
128
+ const code = ownSlotOf(v, 'code');
129
+ const message = ownSlotOf(v, 'message');
130
+ if (code.absent || code.value !== READ_DENY_FLOOR_UNKEPT)
131
+ return DENY_FLOOR_UNREADABLE;
132
+ if (message.absent || typeof message.value !== 'string' || message.value.length === 0)
133
+ return DENY_FLOOR_UNREADABLE;
134
+ return Object.freeze({ kind: 'unkept', message: message.value });
135
+ }
136
+ catch {
137
+ return DENY_FLOOR_UNREADABLE;
138
+ }
139
+ }
@@ -1,3 +1,4 @@
1
+ export declare function hasUnsafeAddressCharacter(s: string): boolean;
1
2
  export declare function tupleOriginUrlOf(raw: string): URL | undefined;
2
3
  export declare function carriesNoCredentialSlots(u: URL): boolean;
3
4
  export declare function isCenterRelativePath(path: string): boolean;
@@ -1,3 +1,6 @@
1
+ export function hasUnsafeAddressCharacter(s) {
2
+ return /[\s\u0000-\u001f\u007f-\u009f\\]/u.test(s);
3
+ }
1
4
  export function tupleOriginUrlOf(raw) {
2
5
  try {
3
6
  const u = new URL(raw);
@@ -16,7 +19,7 @@ export function isCenterRelativePath(path) {
16
19
  const second = path.charCodeAt(1);
17
20
  if (second === 0x2f || second === 0x5c)
18
21
  return false;
19
- if (/[\s\u0000-\u001f\u007f-\u009f\\?#]/u.test(path))
22
+ if (hasUnsafeAddressCharacter(path) || path.includes('?') || path.includes('#'))
20
23
  return false;
21
24
  return path.split('/').every((segment) => {
22
25
  const decoded = segment.replace(/%2e/gi, '.');
@@ -0,0 +1,54 @@
1
+ import type { AgentClient } from '@sema-agent/sdk';
2
+ import { type EngineIdentityView } from './engineIdentity.js';
3
+ import type { LocalEngineVerdict } from './localEngineJudge.js';
4
+ type OwnershipMismatchWhich = Extract<LocalEngineVerdict, {
5
+ kind: 'stranger';
6
+ }>['mismatch'];
7
+ export type LocalEngineIdentityVerdict = {
8
+ readonly kind: 'match';
9
+ readonly identity: EngineIdentityView;
10
+ readonly provenAt?: number;
11
+ } | {
12
+ readonly kind: 'mismatch';
13
+ readonly which: OwnershipMismatchWhich;
14
+ } | {
15
+ readonly kind: 'unreadable';
16
+ };
17
+ export type EngineCredentialTransport = {
18
+ readonly reuse: 'none';
19
+ readonly fetch: typeof fetch;
20
+ } | {
21
+ readonly reuse: 'generation';
22
+ readonly fetch: typeof fetch;
23
+ readonly boundTo: EngineIdentityView;
24
+ readonly openedAt: number;
25
+ };
26
+ export interface EngineCredentialReleaseInput {
27
+ readonly ownership: LocalEngineIdentityVerdict;
28
+ readonly transport?: EngineCredentialTransport;
29
+ }
30
+ export type EngineCredentialWithholdReason = 'ownership_unreadable' | 'ownership_mismatch' | 'transport_undeclared' | 'transport_predates_proof' | 'transport_generation_unreadable';
31
+ export declare const ENGINE_CREDENTIAL_WITHHOLD_REASONS: readonly EngineCredentialWithholdReason[];
32
+ export type EngineCredentialReleaseVerdict = {
33
+ readonly kind: 'present';
34
+ readonly identity: 'proven';
35
+ } | {
36
+ readonly kind: 'withhold';
37
+ readonly identity: 'unproven';
38
+ readonly reason: EngineCredentialWithholdReason;
39
+ readonly retireTransport: boolean;
40
+ };
41
+ export interface LocalEngineWireClientConfig extends EngineCredentialReleaseInput {
42
+ readonly baseUrl: string;
43
+ readonly token?: string;
44
+ readonly principal?: string;
45
+ readonly timeoutMs?: number;
46
+ readonly maxRetries?: number;
47
+ }
48
+ export interface LocalEngineWireClient {
49
+ readonly client: AgentClient | null;
50
+ readonly release: EngineCredentialReleaseVerdict;
51
+ }
52
+ export declare function engineCredentialReleaseVerdictOf(input: EngineCredentialReleaseInput): EngineCredentialReleaseVerdict;
53
+ export declare function makeLocalEngineWireClient(cfg: LocalEngineWireClientConfig): LocalEngineWireClient;
54
+ export {};
@@ -0,0 +1,146 @@
1
+ import { engineIdentityOf, engineIdentityVerdict } from './engineIdentity.js';
2
+ import { makeEngineWireClient } from './engineWireSdk.js';
3
+ import { readOwnDataValue } from './ownKey.js';
4
+ export const ENGINE_CREDENTIAL_WITHHOLD_REASONS = Object.freeze([
5
+ 'ownership_unreadable',
6
+ 'ownership_mismatch',
7
+ 'transport_undeclared',
8
+ 'transport_predates_proof',
9
+ 'transport_generation_unreadable',
10
+ ]);
11
+ const MISMATCH_WHICH = Object.freeze(['pid', 'generation', 'data-root']);
12
+ const _whichIsJudgeVocabulary = [true, true];
13
+ void _whichIsJudgeVocabulary;
14
+ function isRecord(v) {
15
+ if (typeof v !== 'object' || v === null)
16
+ return false;
17
+ try {
18
+ return !Array.isArray(v);
19
+ }
20
+ catch {
21
+ return false;
22
+ }
23
+ }
24
+ function own(v, key) {
25
+ if (!isRecord(v))
26
+ return undefined;
27
+ try {
28
+ return readOwnDataValue(v, key);
29
+ }
30
+ catch {
31
+ return undefined;
32
+ }
33
+ }
34
+ function identityOwn(v) {
35
+ return engineIdentityOf({ pid: own(v, 'pid'), instanceId: own(v, 'instanceId'), startedAt: own(v, 'startedAt') });
36
+ }
37
+ function isMoment(v) {
38
+ return typeof v === 'number' && Number.isFinite(v) && v >= 0;
39
+ }
40
+ function globalFetch() {
41
+ try {
42
+ return globalThis.fetch;
43
+ }
44
+ catch {
45
+ return undefined;
46
+ }
47
+ }
48
+ function declaredFetch(t) {
49
+ const f = own(t, 'fetch');
50
+ return typeof f === 'function' && f !== globalFetch() ? f : undefined;
51
+ }
52
+ function reuseOf(t) {
53
+ if (declaredFetch(t) === undefined)
54
+ return undefined;
55
+ const r = own(t, 'reuse');
56
+ return r === 'none' || r === 'generation' ? r : undefined;
57
+ }
58
+ function withhold(reason, retireTransport) {
59
+ return Object.freeze({ kind: 'withhold', identity: 'unproven', reason, retireTransport });
60
+ }
61
+ function present() {
62
+ return Object.freeze({ kind: 'present', identity: 'proven' });
63
+ }
64
+ function judge(input) {
65
+ const ownership = own(input, 'ownership');
66
+ const transport = own(input, 'transport');
67
+ const reuse = reuseOf(transport);
68
+ const kind = own(ownership, 'kind');
69
+ if (kind === 'mismatch') {
70
+ const which = own(ownership, 'which');
71
+ return MISMATCH_WHICH.includes(which) ? withhold('ownership_mismatch', reuse === 'generation') : withhold('ownership_unreadable', false);
72
+ }
73
+ const identity = own(ownership, 'identity');
74
+ if (kind !== 'match' || !isRecord(identity))
75
+ return withhold('ownership_unreadable', false);
76
+ if (reuse === undefined)
77
+ return withhold('transport_undeclared', false);
78
+ if (reuse === 'none')
79
+ return present();
80
+ const boundTo = own(transport, 'boundTo');
81
+ const same = isRecord(boundTo) ? engineIdentityVerdict(identityOwn(boundTo), identityOwn(identity)) : 'unknown';
82
+ if (same === 'changed')
83
+ return withhold('transport_predates_proof', true);
84
+ const provenAt = own(ownership, 'provenAt');
85
+ const openedAt = own(transport, 'openedAt');
86
+ if (same !== 'same' || !isMoment(provenAt) || !isMoment(openedAt))
87
+ return withhold('transport_generation_unreadable', true);
88
+ return openedAt >= provenAt ? present() : withhold('transport_predates_proof', true);
89
+ }
90
+ export function engineCredentialReleaseVerdictOf(input) {
91
+ try {
92
+ return judge(input);
93
+ }
94
+ catch {
95
+ return withhold('ownership_unreadable', false);
96
+ }
97
+ }
98
+ function anchorsOf(v) {
99
+ if (!isRecord(v))
100
+ return undefined;
101
+ return Object.freeze({ pid: own(v, 'pid'), instanceId: own(v, 'instanceId'), startedAt: own(v, 'startedAt') });
102
+ }
103
+ function sampleRelease(cfg) {
104
+ try {
105
+ const o = own(cfg, 'ownership');
106
+ const t = own(cfg, 'transport');
107
+ const fetchImpl = declaredFetch(t);
108
+ const ownership = isRecord(o)
109
+ ? Object.freeze({ kind: own(o, 'kind'), which: own(o, 'which'), identity: anchorsOf(own(o, 'identity')), provenAt: own(o, 'provenAt') })
110
+ : undefined;
111
+ const transport = isRecord(t)
112
+ ? Object.freeze({ reuse: own(t, 'reuse'), fetch: fetchImpl, boundTo: anchorsOf(own(t, 'boundTo')), openedAt: own(t, 'openedAt') })
113
+ : undefined;
114
+ return Object.freeze({ input: Object.freeze({ ownership, transport }), fetchImpl });
115
+ }
116
+ catch {
117
+ return Object.freeze({ input: Object.freeze({ ownership: undefined, transport: undefined }), fetchImpl: undefined });
118
+ }
119
+ }
120
+ export function makeLocalEngineWireClient(cfg) {
121
+ const sample = sampleRelease(cfg);
122
+ const release = engineCredentialReleaseVerdictOf(sample.input);
123
+ let client = null;
124
+ try {
125
+ const baseUrl = own(cfg, 'baseUrl');
126
+ if (typeof baseUrl === 'string') {
127
+ const token = own(cfg, 'token');
128
+ const principal = own(cfg, 'principal');
129
+ const timeoutMs = own(cfg, 'timeoutMs');
130
+ const maxRetries = own(cfg, 'maxRetries');
131
+ const fetchImpl = sample.fetchImpl;
132
+ client = makeEngineWireClient({
133
+ baseUrl,
134
+ ...(release.kind === 'present' && fetchImpl !== undefined && typeof token === 'string' && token !== '' ? { token } : {}),
135
+ ...(typeof principal === 'string' ? { principal } : {}),
136
+ ...(typeof timeoutMs === 'number' ? { timeoutMs } : {}),
137
+ ...(typeof maxRetries === 'number' ? { maxRetries } : {}),
138
+ ...(fetchImpl !== undefined ? { fetchImpl } : {}),
139
+ });
140
+ }
141
+ }
142
+ catch {
143
+ client = null;
144
+ }
145
+ return Object.freeze({ client, release });
146
+ }
@@ -165,6 +165,7 @@ export declare function isWorkflowParkRefusalCode(code: unknown): boolean;
165
165
  export declare const DRAINING_ERROR_CODE = "draining";
166
166
  export declare const SCENARIO_NOT_ALLOWED_ERROR_CODE = "scenario_not_allowed";
167
167
  export declare const SCENARIO_ASSIGNMENT_UNKNOWN_ERROR_CODE = "state.scenario_assignment_unknown";
168
+ export declare const READ_DENY_FLOOR_UNKEPT = "config.read_deny_floor_unkept";
168
169
  export declare const USER_ATTACHMENT_INVALID_ERROR_CODE = "config.user_attachment_invalid";
169
170
  export declare const USER_INVOKED_SKILL_UNKNOWN_ERROR_CODE = "config.user_invoked_skill_unknown";
170
171
  export declare const STREAM_MAX_DURATION = "STREAM_MAX_DURATION";
@@ -306,6 +306,7 @@ export function isWorkflowParkRefusalCode(code) {
306
306
  export const DRAINING_ERROR_CODE = 'draining';
307
307
  export const SCENARIO_NOT_ALLOWED_ERROR_CODE = 'scenario_not_allowed';
308
308
  export const SCENARIO_ASSIGNMENT_UNKNOWN_ERROR_CODE = 'state.scenario_assignment_unknown';
309
+ export const READ_DENY_FLOOR_UNKEPT = 'config.read_deny_floor_unkept';
309
310
  export const USER_ATTACHMENT_INVALID_ERROR_CODE = 'config.user_attachment_invalid';
310
311
  export const USER_INVOKED_SKILL_UNKNOWN_ERROR_CODE = 'config.user_invoked_skill_unknown';
311
312
  export const STREAM_MAX_DURATION = 'STREAM_MAX_DURATION';
@@ -1,5 +1,4 @@
1
1
  import type { HealthAuthKind } from '@sema-agent/sdk';
2
- import { type EngineHealthStoreDurability } from './storeDurabilityWord.js';
3
2
  export interface EngineHealthCenterFacts {
4
3
  readonly issuer?: string;
5
4
  readonly webBaseUrl?: string;
@@ -52,14 +51,4 @@ export type ModsDeploymentPackagesReading = {
52
51
  readonly kind: 'unreadable';
53
52
  };
54
53
  export declare function readModsDeploymentPackages(health: object | null | undefined): ModsDeploymentPackagesReading;
55
- export type EngineHealthStoreReading = {
56
- readonly kind: 'reported';
57
- readonly durability: EngineHealthStoreDurability;
58
- } | {
59
- readonly kind: 'unreadable';
60
- readonly word?: string;
61
- } | {
62
- readonly kind: 'absent';
63
- };
64
- export declare function readEngineHealthStore(health: object | null | undefined): EngineHealthStoreReading;
65
54
  export declare function readEngineHealthFacts(health: object | null | undefined): EngineHealthFacts;
@@ -1,5 +1,4 @@
1
1
  import { ownDataField, readOwnDataValue } from './ownKey.js';
2
- import { readStoreDurability } from './storeDurabilityWord.js';
3
2
  const _healthFactsMatchSdk = [true, true, true, true, true, true, true, true, true, true];
4
3
  void _healthFactsMatchSdk;
5
4
  const ENGINE_SIGNAL_KEY = 'engineSignal';
@@ -138,26 +137,6 @@ export function readModsDeploymentPackages(health) {
138
137
  return Object.freeze({ kind: 'unreadable' });
139
138
  }
140
139
  }
141
- export function readEngineHealthStore(health) {
142
- try {
143
- if (!isObject(health))
144
- return Object.freeze({ kind: 'unreadable' });
145
- const store = ownDataField(health, 'store');
146
- if (store === undefined)
147
- return Object.freeze({ kind: 'absent' });
148
- if (!isObject(store))
149
- return Object.freeze({ kind: 'unreadable' });
150
- const read = readStoreDurability(store);
151
- if (read.kind === 'word')
152
- return Object.freeze({ kind: 'reported', durability: read.durability });
153
- if (read.kind === 'unrecognized')
154
- return Object.freeze({ kind: 'unreadable', word: read.word });
155
- return Object.freeze({ kind: 'unreadable' });
156
- }
157
- catch {
158
- return Object.freeze({ kind: 'unreadable' });
159
- }
160
- }
161
140
  export function readEngineHealthFacts(health) {
162
141
  if (!isObject(health))
163
142
  return Object.freeze({});
@@ -19,5 +19,6 @@ export interface TimedHealthAnswer {
19
19
  readonly atMs: number;
20
20
  }
21
21
  export declare function classifyHealthProbe(reading: ProbeHealthResult): HealthProbeVerdict | undefined;
22
+ export declare function healthProbeVerdictOf(v: {} | null | undefined): HealthProbeVerdict | undefined;
22
23
  export declare function healthAnswerClause(verdict: HealthProbeVerdict, lang?: UiLanguage): string | undefined;
23
24
  export declare function latestSegmentHealthAnswer(segmentStartMs: number | undefined, ...seen: ReadonlyArray<TimedHealthAnswer | undefined>): HealthProbeAnsweredNotOk | undefined;
@@ -56,25 +56,33 @@ function answeredNotOkOf(v) {
56
56
  return undefined;
57
57
  return answeredNotOk(reason, http, shownStatusOf(ownValue(v, 'status')));
58
58
  }
59
- export function healthAnswerClause(verdict, lang) {
59
+ export function healthProbeVerdictOf(v) {
60
60
  try {
61
- if (typeof verdict !== 'object' || verdict === null)
61
+ if (typeof v !== 'object' || v === null)
62
62
  return undefined;
63
- const kind = ownValue(verdict, 'kind');
63
+ const kind = ownValue(v, 'kind');
64
64
  if (kind === 'answered_ok')
65
- return renderMessage(msg('localEngine.health.answer.ok'), lang);
65
+ return Object.freeze({ kind: 'answered_ok' });
66
66
  if (kind === 'unanswered') {
67
- const reason = ownValue(verdict, 'reason');
68
- if (reason === 'timeout')
69
- return renderMessage(msg('localEngine.health.answer.unansweredTimeout'), lang);
70
- if (reason === 'network')
71
- return renderMessage(msg('localEngine.health.answer.unansweredNetwork'), lang);
72
- return undefined;
67
+ const reason = ownValue(v, 'reason');
68
+ return typeof reason === 'string' && UNANSWERED_REASONS.has(reason) ? Object.freeze({ kind: 'unanswered', reason: reason }) : undefined;
73
69
  }
74
- const nok = answeredNotOkOf(verdict);
75
- if (nok === undefined)
70
+ return answeredNotOkOf(v);
71
+ }
72
+ catch {
73
+ return undefined;
74
+ }
75
+ }
76
+ export function healthAnswerClause(verdict, lang) {
77
+ try {
78
+ const v = healthProbeVerdictOf(verdict);
79
+ if (v === undefined)
76
80
  return undefined;
77
- return renderMessage(msg(nok.reason === 'not_ok' ? 'localEngine.health.answer.notOkStatus' : 'localEngine.health.answer.notOkHttp', { http: nok.http }), lang);
81
+ if (v.kind === 'answered_ok')
82
+ return renderMessage(msg('localEngine.health.answer.ok'), lang);
83
+ if (v.kind === 'unanswered')
84
+ return renderMessage(msg(v.reason === 'timeout' ? 'localEngine.health.answer.unansweredTimeout' : 'localEngine.health.answer.unansweredNetwork'), lang);
85
+ return renderMessage(msg(v.reason === 'not_ok' ? 'localEngine.health.answer.notOkStatus' : 'localEngine.health.answer.notOkHttp', { http: v.http }), lang);
78
86
  }
79
87
  catch {
80
88
  return undefined;
@@ -1,6 +1,7 @@
1
1
  import type { RequestLane } from './request/taskRequest.js';
2
2
  import type { UiLanguage } from './env/uiLanguage.js';
3
- export declare const ENGINE_UNAVAILABLE_REASONS: readonly ["not_running", "not_answering", "address_refused", "version_refused", "model_setup", "credential_conflict", "credential_refused", "data_root_refused"];
3
+ import { type HealthProbeVerdict } from './engineHealthProbeVerdict.js';
4
+ export declare const ENGINE_UNAVAILABLE_REASONS: readonly ["not_running", "not_answering", "address_refused", "version_refused", "model_setup", "credential_conflict", "credential_refused", "data_root_refused", "previous_not_stopped"];
4
5
  export type EngineUnavailableReason = (typeof ENGINE_UNAVAILABLE_REASONS)[number];
5
6
  export type EngineBootRefusalReason = Extract<EngineUnavailableReason, 'model_setup' | 'credential_conflict' | 'credential_refused' | 'data_root_refused'>;
6
7
  export declare const ENGINE_INSTALL_SHAPES: readonly ["npm-global", "managed", "npm-local", "dev", "app", "unknown"];
@@ -38,7 +39,7 @@ export interface EngineUnavailableFacts {
38
39
  readonly engineExitCode?: number | null;
39
40
  readonly engineSignal?: string | null;
40
41
  readonly pid?: number;
41
- readonly answer?: 'silent' | 'answered' | 'drain-stuck';
42
+ readonly answer?: HealthProbeVerdict;
42
43
  readonly form?: EngineBootRefusalForm;
43
44
  }
44
45
  export declare function engineUnavailableLine(facts: EngineUnavailableFacts, lane: RequestLane, lang?: UiLanguage): string | undefined;
@@ -3,6 +3,7 @@ import { compareReleaseVersions } from './supportFloor.js';
3
3
  import { LOCAL_ENGINE_SPAWN_ENV } from './localEngineSpawn.js';
4
4
  import { SETTINGS_MODEL_PLANE_REFUSAL_CODES, SETTINGS_WEB_ADMIN_TOKEN_ENV } from './generated/settingsSchemaTables.js';
5
5
  import { msg, renderMessage } from './i18n/translate.js';
6
+ import { healthProbeVerdictOf } from './engineHealthProbeVerdict.js';
6
7
  export const ENGINE_UNAVAILABLE_REASONS = Object.freeze([
7
8
  'not_running',
8
9
  'not_answering',
@@ -12,6 +13,7 @@ export const ENGINE_UNAVAILABLE_REASONS = Object.freeze([
12
13
  'credential_conflict',
13
14
  'credential_refused',
14
15
  'data_root_refused',
16
+ 'previous_not_stopped',
15
17
  ]);
16
18
  export const ENGINE_INSTALL_SHAPES = Object.freeze(['npm-global', 'managed', 'npm-local', 'dev', 'app', 'unknown']);
17
19
  const SCHEMA_MISMATCH_CODE = 'config.schema_mismatch';
@@ -345,8 +347,9 @@ function armFix(reason, retry, facts, form) {
345
347
  return msg('engine.unavailable.fix.credentialMultiTenant', { again, token: SETTINGS_WEB_ADMIN_TOKEN_ENV.token, tokenFile: SETTINGS_WEB_ADMIN_TOKEN_ENV.tokenFile });
346
348
  }
347
349
  return msg('engine.unavailable.fix.credential', { again });
348
- case 'not_answering': {
349
- const wait = msg(facts.answer === 'silent' ? 'engine.unavailable.wait.respond' : facts.answer === 'drain-stuck' ? 'engine.unavailable.wait.exit' : 'engine.unavailable.wait.healthy');
350
+ case 'not_answering':
351
+ case 'previous_not_stopped': {
352
+ const wait = msg(reason === 'previous_not_stopped' ? 'engine.unavailable.wait.exit' : facts.answer === 'unanswered' ? 'engine.unavailable.wait.respond' : 'engine.unavailable.wait.healthy');
350
353
  return facts.pid !== undefined ? msg('engine.unavailable.fix.waitPid', { wait, again, pid: facts.pid }) : msg('engine.unavailable.fix.wait', { wait, again });
351
354
  }
352
355
  case 'address_refused':
@@ -427,8 +430,7 @@ export function engineUnavailableLine(facts, lane, lang) {
427
430
  const sigRaw = own(facts, 'engineSignal');
428
431
  const pidRaw = own(facts, 'pid');
429
432
  const pid = typeof pidRaw === 'number' && Number.isInteger(pidRaw) && pidRaw > 0 ? pidRaw : undefined;
430
- const answerRaw = own(facts, 'answer');
431
- const answer = answerRaw === 'silent' || answerRaw === 'answered' || answerRaw === 'drain-stuck' ? answerRaw : undefined;
433
+ const answer = healthProbeVerdictOf(own(facts, 'answer'))?.kind;
432
434
  const refusal = refusalView(own(facts, 'refusal'));
433
435
  const form = formOf(own(facts, 'form'));
434
436
  const reason = refusal.reason ?? hostReason;
@@ -462,14 +464,16 @@ export function engineUnavailableLine(facts, lane, lang) {
462
464
  const head = reason === undefined
463
465
  ? msg('engine.unavailable.head.unknown')
464
466
  : reason === 'not_answering'
465
- ? msg(answer === 'silent' ? 'engine.unavailable.head.notAnswering' : answer === 'drain-stuck' ? 'engine.unavailable.head.drainStuck' : 'engine.unavailable.head.noHealthyAnswer')
466
- : reason === 'address_refused'
467
- ? msg('engine.unavailable.head.addressRefused')
468
- : reason === 'version_refused'
469
- ? msg('engine.unavailable.head.versionRefused')
470
- : reason === 'not_running' || (reason === 'model_setup' && refusal.reason === undefined)
471
- ? msg('engine.unavailable.head.notRunning')
472
- : msg('engine.unavailable.head.refused');
467
+ ? msg(answer === 'unanswered' ? 'engine.unavailable.head.notAnswering' : 'engine.unavailable.head.noHealthyAnswer')
468
+ : reason === 'previous_not_stopped'
469
+ ? msg('engine.unavailable.head.drainStuck')
470
+ : reason === 'address_refused'
471
+ ? msg('engine.unavailable.head.addressRefused')
472
+ : reason === 'version_refused'
473
+ ? msg('engine.unavailable.head.versionRefused')
474
+ : reason === 'not_running' || (reason === 'model_setup' && refusal.reason === undefined)
475
+ ? msg('engine.unavailable.head.notRunning')
476
+ : msg('engine.unavailable.head.refused');
473
477
  let ref;
474
478
  if (reason === 'address_refused' || reason === 'version_refused') {
475
479
  ref = detail !== undefined ? msg('engine.unavailable.lineRefusedUse', { tag, head, detail }) : msg('engine.unavailable.lineRefusedUseNoDetail', { tag, head });
package/dist/engineUrl.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { isLoopbackWireUrl } from './engineWireSdk.js';
2
+ import { SETTINGS_HTTP_URL_FLAWS, SETTINGS_STARTS_WITH_HTTP_SCHEME } from './generated/settingsSchemaFns.js';
2
3
  const SLASH = 47;
3
4
  function refusedBase(reason) {
4
5
  return Object.freeze({ ok: false, reason });
@@ -18,7 +19,7 @@ export function normalizeEngineBaseUrl(raw) {
18
19
  const trimmed = raw.trim();
19
20
  if (trimmed.length === 0)
20
21
  return refusedBase('empty');
21
- if (!/^https?:\/\//i.test(trimmed))
22
+ if (!SETTINGS_STARTS_WITH_HTTP_SCHEME(trimmed))
22
23
  return refusedBase('scheme');
23
24
  let parsed;
24
25
  try {
@@ -29,7 +30,8 @@ export function normalizeEngineBaseUrl(raw) {
29
30
  }
30
31
  if (parsed.username !== '' || parsed.password !== '')
31
32
  return refusedBase('userinfo');
32
- if (trimmed.includes('?') || trimmed.includes('#'))
33
+ const parts = SETTINGS_HTTP_URL_FLAWS(trimmed, ['query', 'fragment']);
34
+ if (parts.includes('query') || parts.includes('fragment'))
33
35
  return refusedBase('query_or_fragment');
34
36
  return Object.freeze({ ok: true, url: withoutTrailingSlashes(trimmed) });
35
37
  }
@@ -1,8 +1,8 @@
1
- import { DECIDE_WORKFLOW_PARK_FORKED, DECIDE_WORKFLOW_PARKS_UNREADABLE, PARKED_RESUME_STARTUP_FAILED, RESUME_POLICY_FOLD_CODE, RESUME_REOPEN_CODES, RESUME_RETRY_LATER_CODES, isRefusedParkCode } from './engineErrorCodes.js';
1
+ import { CORRUPT_ROW_ERROR_CODE, DECIDE_WORKFLOW_PARK_FORKED, DECIDE_WORKFLOW_PARKS_UNREADABLE, PARKED_RESUME_STARTUP_FAILED, RESUME_POLICY_FOLD_CODE, RESUME_REOPEN_CODES, RESUME_RETRY_LATER_CODES, isRefusedParkCode } from './engineErrorCodes.js';
2
2
  import { RESUME_REFUSAL_CODES } from './resumeRefusalCopy.js';
3
3
  export function isGateStandingErrorCode(code, retriable) {
4
4
  return (code === RESUME_POLICY_FOLD_CODE ||
5
- code === 'corrupt' ||
5
+ code === CORRUPT_ROW_ERROR_CODE ||
6
6
  (isRefusedParkCode(code) && retriable === true) ||
7
7
  (typeof code === 'string' && RESUME_REOPEN_CODES.includes(code) && retriable === true) ||
8
8
  code === DECIDE_WORKFLOW_PARKS_UNREADABLE ||
@@ -10,4 +10,5 @@ export declare const SDK_PERMISSION_MODE_PERSIST_MISSES: readonly ["claim_releas
10
10
  export declare const SDK_DECIDE_BINDING_KEYS: readonly ["boundCallId", "boundInputHash"];
11
11
  export declare const SDK_APPROVAL_QUEUE_KINDS: readonly ["checkpoint", "peer_inbound"];
12
12
  export declare const SDK_SESSION_MEMORY_UNOBSERVED_REASONS: readonly ["no_settled_run", "run_result_missing", "run_result_unobserved", "memory_not_mounted", "no_leaf"];
13
+ export declare const SDK_NON_RETRYABLE_CODES: readonly ["corrupt_session", "config.tool_name_too_long", "config.tool_contract_too_long", "config.tool_roster_bound", "config.tool_schema_bound", "state.scenario_assignment_unknown", "corrupt", "internal.memory_control_plane_corrupt", "approvals.read_corrupt", "workflow.journal_incompatible", "internal.org_delivery_quota_unreadable"];
13
14
  export declare const SDK_STREAM_ENDED_REASONS: readonly ["empty_legs", "consecutive_failures"];
@@ -64,6 +64,19 @@ export const SDK_SESSION_MEMORY_UNOBSERVED_REASONS = Object.freeze([
64
64
  "memory_not_mounted",
65
65
  "no_leaf",
66
66
  ]);
67
+ export const SDK_NON_RETRYABLE_CODES = Object.freeze([
68
+ "corrupt_session",
69
+ "config.tool_name_too_long",
70
+ "config.tool_contract_too_long",
71
+ "config.tool_roster_bound",
72
+ "config.tool_schema_bound",
73
+ "state.scenario_assignment_unknown",
74
+ "corrupt",
75
+ "internal.memory_control_plane_corrupt",
76
+ "approvals.read_corrupt",
77
+ "workflow.journal_incompatible",
78
+ "internal.org_delivery_quota_unreadable",
79
+ ]);
67
80
  export const SDK_STREAM_ENDED_REASONS = Object.freeze([
68
81
  "empty_legs",
69
82
  "consecutive_failures",
@@ -111,3 +111,4 @@ export declare const SETTINGS_RESOLVE_CATALOG_DEFAULT_MODEL: (models: {
111
111
  };
112
112
  };
113
113
  export declare const SETTINGS_DEFAULT_ROLE_TIER_LADDER: readonly ["pro", "flash", "lite"];
114
+ export declare const SETTINGS_HTTP_URL_FLAWS: (raw: string, forbid: readonly ("userinfo" | "query" | "fragment")[]) => readonly ("not-http-url" | "userinfo" | "query" | "fragment")[];
@@ -15,6 +15,7 @@ import { SETTINGS_LAYER_SOURCES_CLOSURE } from './settingsSchemaSettingsSources.
15
15
  import { SETTINGS_ACTIVE_TIERS_CLOSURE } from './settingsSchemaActiveTiers.js';
16
16
  import { SETTINGS_TIER_WORDS_CLOSURE } from './settingsSchemaTierWords.js';
17
17
  import { SETTINGS_DEFAULT_MODEL_CLOSURE } from './settingsSchemaDefaultModel.js';
18
+ import { SETTINGS_URL_SHAPE_CLOSURE } from './settingsSchemaUrlShape.js';
18
19
  export const SETTINGS_AT_MENTION_MODES = Object.freeze([
19
20
  "all",
20
21
  "none",
@@ -198,3 +199,5 @@ export const SETTINGS_TIER_LADDER_FROM = SETTINGS_TIER_WORDS.tierLadderFrom;
198
199
  const SETTINGS_DEFAULT_MODEL = SETTINGS_DEFAULT_MODEL_CLOSURE(SETTINGS_RESOLVE_ACTIVE_TIERS, SETTINGS_TIER_LADDER_FROM);
199
200
  export const SETTINGS_RESOLVE_CATALOG_DEFAULT_MODEL = SETTINGS_DEFAULT_MODEL.resolveCatalogDefaultModel;
200
201
  export const SETTINGS_DEFAULT_ROLE_TIER_LADDER = SETTINGS_DEFAULT_MODEL.DEFAULT_ROLE_TIER_LADDER;
202
+ const SETTINGS_URL_SHAPE = SETTINGS_URL_SHAPE_CLOSURE(SETTINGS_IS_HIERARCHICAL_URL);
203
+ export const SETTINGS_HTTP_URL_FLAWS = SETTINGS_URL_SHAPE.httpUrlFlaws;