@sema-agent/client-core 0.90.0 → 0.91.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 +193 -0
- package/README.md +24 -18
- package/dist/adapt/arms.js +9 -0
- package/dist/adapter/downstream/eventToSdkMessage.js +4 -2
- package/dist/adapter/downstream/wiringManifestView.d.ts +6 -0
- package/dist/adapter/downstream/wiringManifestView.js +16 -0
- package/dist/adapter/runStream.js +37 -20
- package/dist/askSurvivesStandingAnswer.d.ts +10 -0
- package/dist/askSurvivesStandingAnswer.js +40 -0
- package/dist/attachmentSeatCapability.d.ts +11 -0
- package/dist/attachmentSeatCapability.js +27 -0
- package/dist/attachmentsWireCaps.d.ts +9 -0
- package/dist/attachmentsWireCaps.js +74 -21
- package/dist/compensations.js +10 -14
- package/dist/controlRouter.d.ts +9 -2
- package/dist/controlRouter.js +66 -28
- package/dist/decideFailureNote.js +4 -2
- package/dist/disableSkillsWire.d.ts +1 -0
- package/dist/disableSkillsWire.js +8 -1
- package/dist/displayUntrusted.js +153 -4
- package/dist/engineCapsCache.d.ts +3 -1
- package/dist/engineCapsCache.js +56 -6
- package/dist/engineClosedSets.d.ts +2 -0
- package/dist/engineClosedSets.js +3 -0
- package/dist/engineErrorCodes.d.ts +3 -0
- package/dist/engineErrorCodes.js +10 -0
- package/dist/generated/engineFactTables.d.ts +12 -0
- package/dist/generated/engineFactTables.js +47 -0
- package/dist/hitl/askGateWire.d.ts +1 -1
- package/dist/hitl/askGateWire.js +1 -1
- package/dist/hitl/crashConverged.d.ts +7 -0
- package/dist/hitl/crashConverged.js +57 -0
- package/dist/hitl/crashConvergedNotice.d.ts +4 -0
- package/dist/hitl/crashConvergedNotice.js +57 -0
- package/dist/hitl/hitlBridge.d.ts +7 -4
- package/dist/hitl/parkResolver.d.ts +7 -2
- package/dist/hitl/parkResolver.js +19 -7
- package/dist/hitl/planReviewWire.d.ts +1 -1
- package/dist/hitl/planReviewWire.js +18 -4
- package/dist/hitl/sessionPolicyWire.d.ts +5 -0
- package/dist/hitl/sessionPolicyWire.js +63 -0
- package/dist/hitl/suspendedReopen.js +2 -2
- package/dist/hitl/toolApprovalWire.d.ts +4 -1
- package/dist/hitl/toolApprovalWire.js +20 -0
- package/dist/hookMatcherVerdict.d.ts +29 -0
- package/dist/hookMatcherVerdict.js +265 -0
- package/dist/humanTurn.d.ts +91 -0
- package/dist/humanTurn.js +253 -0
- package/dist/humanTurnRead.d.ts +105 -0
- package/dist/humanTurnRead.js +331 -0
- package/dist/index.d.ts +25 -8
- package/dist/index.js +16 -6
- package/dist/inheritEnvWire.js +1 -1
- package/dist/liveModelCatalog.d.ts +2 -0
- package/dist/liveModelCatalog.js +51 -3
- package/dist/permissionRuleIssue.d.ts +1 -1
- package/dist/permissionRuleIssue.js +22 -3
- package/dist/permissionsAllowGrantCapability.d.ts +2 -1
- package/dist/permissionsAllowGrantCapability.js +11 -2
- package/dist/permissionsDeclaration.d.ts +23 -0
- package/dist/permissionsDeclaration.js +133 -53
- package/dist/promptDelivery.d.ts +11 -3
- package/dist/promptDelivery.js +164 -29
- package/dist/providerRejection.d.ts +1 -0
- package/dist/providerRejection.js +20 -0
- package/dist/readDenyTiers.d.ts +10 -0
- package/dist/readDenyTiers.js +29 -0
- package/dist/request/taskRequest.js +2 -2
- package/dist/resumeRefusalCopy.d.ts +11 -0
- package/dist/resumeRefusalCopy.js +61 -4
- package/dist/rewindArchiveCapability.js +4 -4
- package/dist/rewindWireCaps.d.ts +2 -1
- package/dist/rewindWireCaps.js +19 -2
- package/dist/seam.d.ts +2 -0
- package/dist/taskRequestWords.d.ts +7 -1
- package/dist/taskRequestWords.js +18 -8
- package/dist/toolHistoryBadTurn.d.ts +1 -0
- package/dist/toolHistoryBadTurn.js +89 -0
- package/dist/toolHistoryMismatch.d.ts +2 -1
- package/dist/toolHistoryMismatch.js +19 -6
- package/dist/userAttachmentEnvelope.d.ts +61 -0
- package/dist/userAttachmentEnvelope.js +204 -0
- package/dist/wireFailureShape.d.ts +1 -0
- package/dist/wireFailureShape.js +4 -0
- package/dist/wireRefusalCopy.d.ts +6 -0
- package/dist/wireRefusalCopy.js +26 -3
- package/docs/INTEGRATION-CLIENTS.md +875 -14
- package/package.json +2 -2
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { ImageInput } from './imagesWireCaps.js';
|
|
2
|
+
import type { UserAttachmentDescriptor, UserAttachmentNotIncludedReason, UserAttachmentSource } from './userAttachmentEnvelope.js';
|
|
3
|
+
import type { HumanTurnAttachment, HumanTurnEncoding, HumanTurnInput, HumanTurnMissing } from './humanTurn.js';
|
|
4
|
+
import type { ImageVision } from './liveModelCatalog.js';
|
|
5
|
+
export interface CellView {
|
|
6
|
+
cellType: string | undefined;
|
|
7
|
+
source: string | undefined;
|
|
8
|
+
cellId: string | undefined;
|
|
9
|
+
language: string | undefined;
|
|
10
|
+
outputs: {
|
|
11
|
+
text: string | undefined;
|
|
12
|
+
hasImage: boolean;
|
|
13
|
+
}[];
|
|
14
|
+
outputsTooLarge: boolean;
|
|
15
|
+
}
|
|
16
|
+
export type DescriptorView = {
|
|
17
|
+
kind: 'text';
|
|
18
|
+
source: UserAttachmentSource;
|
|
19
|
+
name: string;
|
|
20
|
+
path: string;
|
|
21
|
+
lines: string[];
|
|
22
|
+
startLine: number;
|
|
23
|
+
totalLines: number;
|
|
24
|
+
complete: boolean;
|
|
25
|
+
} | {
|
|
26
|
+
kind: 'notebook';
|
|
27
|
+
source: UserAttachmentSource;
|
|
28
|
+
name: string;
|
|
29
|
+
path: string;
|
|
30
|
+
cells: CellView[];
|
|
31
|
+
} | {
|
|
32
|
+
kind: 'image';
|
|
33
|
+
source: UserAttachmentSource;
|
|
34
|
+
name: string;
|
|
35
|
+
path: string;
|
|
36
|
+
sizeBytes: number | null;
|
|
37
|
+
delivery: 'attached' | 'not-attached' | undefined;
|
|
38
|
+
} | {
|
|
39
|
+
kind: 'pdf';
|
|
40
|
+
source: UserAttachmentSource;
|
|
41
|
+
name: string;
|
|
42
|
+
path: string;
|
|
43
|
+
sizeBytes: number | null;
|
|
44
|
+
pageCount: number | null;
|
|
45
|
+
} | {
|
|
46
|
+
kind: 'directory';
|
|
47
|
+
name: string;
|
|
48
|
+
path: string;
|
|
49
|
+
entries: string[];
|
|
50
|
+
totalEntries: number;
|
|
51
|
+
} | {
|
|
52
|
+
kind: 'not-included';
|
|
53
|
+
target: 'file' | 'directory' | 'path';
|
|
54
|
+
name: string;
|
|
55
|
+
path: string;
|
|
56
|
+
sizeBytes: number | null;
|
|
57
|
+
reason: UserAttachmentNotIncludedReason;
|
|
58
|
+
};
|
|
59
|
+
export declare function readDescriptor(x: UserAttachmentDescriptor | HumanTurnAttachment['descriptor'], imageDelivery: 'required' | 'ignored'): DescriptorView | undefined;
|
|
60
|
+
type Reason = Exclude<Extract<HumanTurnEncoding, {
|
|
61
|
+
ok: false;
|
|
62
|
+
}>['reason'], 'steer_hold' | 'oversize'>;
|
|
63
|
+
export interface AttachmentView {
|
|
64
|
+
uuid: string;
|
|
65
|
+
d: DescriptorView;
|
|
66
|
+
pixels: {
|
|
67
|
+
data: string;
|
|
68
|
+
mimeType: string;
|
|
69
|
+
} | undefined;
|
|
70
|
+
}
|
|
71
|
+
export interface RiderView {
|
|
72
|
+
uuid: string;
|
|
73
|
+
role: string;
|
|
74
|
+
textIncluded: boolean;
|
|
75
|
+
}
|
|
76
|
+
export interface MissingView {
|
|
77
|
+
kind: HumanTurnMissing['kind'];
|
|
78
|
+
ref: string | undefined;
|
|
79
|
+
reason: HumanTurnMissing['reason'];
|
|
80
|
+
}
|
|
81
|
+
export interface ItemView {
|
|
82
|
+
uuid: string;
|
|
83
|
+
text: string;
|
|
84
|
+
images: ImageInput[];
|
|
85
|
+
attachments: AttachmentView[];
|
|
86
|
+
attachmentIds: string[];
|
|
87
|
+
riders: RiderView[];
|
|
88
|
+
missing: MissingView[];
|
|
89
|
+
}
|
|
90
|
+
export interface InputView {
|
|
91
|
+
lane: 'objective' | 'steer';
|
|
92
|
+
vision: ImageVision;
|
|
93
|
+
otherBodyBytes: number;
|
|
94
|
+
items: ItemView[];
|
|
95
|
+
}
|
|
96
|
+
export declare function readHumanTurnInput(input: HumanTurnInput): InputView | {
|
|
97
|
+
readonly reject: Reason;
|
|
98
|
+
};
|
|
99
|
+
export interface ShareView {
|
|
100
|
+
uuid: string;
|
|
101
|
+
level: 'full' | 'partial' | 'none';
|
|
102
|
+
riderUuids: string[];
|
|
103
|
+
}
|
|
104
|
+
export declare function readEncodingShares(encoding: HumanTurnEncoding): ShareView[] | undefined;
|
|
105
|
+
export {};
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
const descriptorKindsAligned = true;
|
|
2
|
+
void descriptorKindsAligned;
|
|
3
|
+
const MALFORMED = Object.freeze({});
|
|
4
|
+
const bad = () => {
|
|
5
|
+
throw MALFORMED;
|
|
6
|
+
};
|
|
7
|
+
function isPlainObject(x) {
|
|
8
|
+
if (x === null || typeof x !== 'object' || Array.isArray(x))
|
|
9
|
+
return false;
|
|
10
|
+
const p = Object.getPrototypeOf(x);
|
|
11
|
+
return p === Object.prototype || p === null;
|
|
12
|
+
}
|
|
13
|
+
function ownData(o, key) {
|
|
14
|
+
const d = Object.getOwnPropertyDescriptor(o, key);
|
|
15
|
+
if (d === undefined)
|
|
16
|
+
return undefined;
|
|
17
|
+
if (!('value' in d))
|
|
18
|
+
bad();
|
|
19
|
+
return d.value;
|
|
20
|
+
}
|
|
21
|
+
function ownArray(x) {
|
|
22
|
+
if (!Array.isArray(x))
|
|
23
|
+
bad();
|
|
24
|
+
const arr = x;
|
|
25
|
+
const n = ownData(arr, 'length');
|
|
26
|
+
if (typeof n !== 'number' || !Number.isSafeInteger(n) || n < 0)
|
|
27
|
+
bad();
|
|
28
|
+
const out = [];
|
|
29
|
+
for (let i = 0; i < n; i += 1) {
|
|
30
|
+
const d = Object.getOwnPropertyDescriptor(arr, i);
|
|
31
|
+
if (d === undefined || !('value' in d))
|
|
32
|
+
bad();
|
|
33
|
+
out.push(d.value);
|
|
34
|
+
}
|
|
35
|
+
return out;
|
|
36
|
+
}
|
|
37
|
+
const str = (v) => (typeof v === 'string' ? v : bad());
|
|
38
|
+
const optStr = (v) => (v === undefined ? undefined : str(v));
|
|
39
|
+
const strArray = (v) => ownArray(v).map(str);
|
|
40
|
+
const sizeOf = (v) => (v === null ? null : typeof v === 'number' ? v : bad());
|
|
41
|
+
const posInt = (v) => (typeof v === 'number' && Number.isSafeInteger(v) && v >= 1 ? v : bad());
|
|
42
|
+
const natInt = (v) => (typeof v === 'number' && Number.isSafeInteger(v) && v >= 0 ? v : bad());
|
|
43
|
+
function sourceOf(v) {
|
|
44
|
+
return v === 'at-mention' || v === 'compact-restore' ? v : bad();
|
|
45
|
+
}
|
|
46
|
+
function readCell(x) {
|
|
47
|
+
if (!isPlainObject(x))
|
|
48
|
+
bad();
|
|
49
|
+
const c = x;
|
|
50
|
+
const outputsRaw = ownData(c, 'outputs');
|
|
51
|
+
const outputs = outputsRaw === undefined
|
|
52
|
+
? []
|
|
53
|
+
: ownArray(outputsRaw).map((o) => {
|
|
54
|
+
if (!isPlainObject(o))
|
|
55
|
+
bad();
|
|
56
|
+
const hasImage = ownData(o, 'hasImage');
|
|
57
|
+
if (hasImage !== undefined && typeof hasImage !== 'boolean')
|
|
58
|
+
bad();
|
|
59
|
+
return { text: optStr(ownData(o, 'text')), hasImage: hasImage === true };
|
|
60
|
+
});
|
|
61
|
+
const tooLarge = ownData(c, 'outputsTooLarge');
|
|
62
|
+
if (tooLarge !== undefined && typeof tooLarge !== 'boolean')
|
|
63
|
+
bad();
|
|
64
|
+
return {
|
|
65
|
+
cellType: optStr(ownData(c, 'cellType')),
|
|
66
|
+
source: optStr(ownData(c, 'source')),
|
|
67
|
+
cellId: optStr(ownData(c, 'cellId')),
|
|
68
|
+
language: optStr(ownData(c, 'language')),
|
|
69
|
+
outputs,
|
|
70
|
+
outputsTooLarge: tooLarge === true,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function readDescriptorAny(x, imageDelivery) {
|
|
74
|
+
try {
|
|
75
|
+
if (!isPlainObject(x))
|
|
76
|
+
return undefined;
|
|
77
|
+
const o = x;
|
|
78
|
+
const kind = ownData(o, 'kind');
|
|
79
|
+
const name = () => str(ownData(o, 'name'));
|
|
80
|
+
const path = () => str(ownData(o, 'path'));
|
|
81
|
+
switch (kind) {
|
|
82
|
+
case 'text': {
|
|
83
|
+
const complete = ownData(o, 'complete');
|
|
84
|
+
if (typeof complete !== 'boolean')
|
|
85
|
+
bad();
|
|
86
|
+
return {
|
|
87
|
+
kind,
|
|
88
|
+
source: sourceOf(ownData(o, 'source')),
|
|
89
|
+
name: name(),
|
|
90
|
+
path: path(),
|
|
91
|
+
lines: strArray(ownData(o, 'lines')),
|
|
92
|
+
startLine: posInt(ownData(o, 'startLine')),
|
|
93
|
+
totalLines: natInt(ownData(o, 'totalLines')),
|
|
94
|
+
complete: complete,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
case 'notebook':
|
|
98
|
+
return { kind, source: sourceOf(ownData(o, 'source')), name: name(), path: path(), cells: ownArray(ownData(o, 'cells')).map(readCell) };
|
|
99
|
+
case 'image': {
|
|
100
|
+
let delivery;
|
|
101
|
+
if (imageDelivery === 'required') {
|
|
102
|
+
const d = ownData(o, 'delivery');
|
|
103
|
+
delivery = d === 'attached' || d === 'not-attached' ? d : bad();
|
|
104
|
+
}
|
|
105
|
+
return { kind, source: sourceOf(ownData(o, 'source')), name: name(), path: path(), sizeBytes: sizeOf(ownData(o, 'sizeBytes')), delivery };
|
|
106
|
+
}
|
|
107
|
+
case 'pdf': {
|
|
108
|
+
const pc = ownData(o, 'pageCount');
|
|
109
|
+
return {
|
|
110
|
+
kind,
|
|
111
|
+
source: sourceOf(ownData(o, 'source')),
|
|
112
|
+
name: name(),
|
|
113
|
+
path: path(),
|
|
114
|
+
sizeBytes: sizeOf(ownData(o, 'sizeBytes')),
|
|
115
|
+
pageCount: pc === null ? null : typeof pc === 'number' ? pc : bad(),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
case 'directory':
|
|
119
|
+
return { kind, name: name(), path: path(), entries: strArray(ownData(o, 'entries')), totalEntries: natInt(ownData(o, 'totalEntries')) };
|
|
120
|
+
case 'not-included': {
|
|
121
|
+
const target = ownData(o, 'target');
|
|
122
|
+
const reason = ownData(o, 'reason');
|
|
123
|
+
if (target !== 'file' && target !== 'directory' && target !== 'path')
|
|
124
|
+
bad();
|
|
125
|
+
if (reason !== 'too-large' && reason !== 'unreadable' && reason !== 'read-denied')
|
|
126
|
+
bad();
|
|
127
|
+
return {
|
|
128
|
+
kind,
|
|
129
|
+
target: target,
|
|
130
|
+
name: name(),
|
|
131
|
+
path: path(),
|
|
132
|
+
sizeBytes: sizeOf(ownData(o, 'sizeBytes')),
|
|
133
|
+
reason: reason,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
default:
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
export function readDescriptor(x, imageDelivery) {
|
|
145
|
+
return readDescriptorAny(x, imageDelivery);
|
|
146
|
+
}
|
|
147
|
+
const REASON_LIST = ['empty', 'malformed_input', 'malformed_item', 'duplicate_uuid', 'rider_collides_primary'];
|
|
148
|
+
const reasonListExhaustive = true;
|
|
149
|
+
void reasonListExhaustive;
|
|
150
|
+
const REJECT_SENTINELS = new Map(REASON_LIST.map((r) => [Object.freeze({}), r]));
|
|
151
|
+
const sentinelOf = (reason) => {
|
|
152
|
+
for (const [s, r] of REJECT_SENTINELS)
|
|
153
|
+
if (r === reason)
|
|
154
|
+
return s;
|
|
155
|
+
return MALFORMED;
|
|
156
|
+
};
|
|
157
|
+
const reject = (reason) => {
|
|
158
|
+
throw sentinelOf(reason);
|
|
159
|
+
};
|
|
160
|
+
const rejectReasonOf = (e) => (typeof e === 'object' && e !== null ? REJECT_SENTINELS.get(e) : undefined);
|
|
161
|
+
const nonEmpty = (v) => (typeof v === 'string' && v.length > 0 ? v : reject('malformed_item'));
|
|
162
|
+
const optArray = (v) => (v === undefined ? [] : ownArray(v));
|
|
163
|
+
function readImage(x) {
|
|
164
|
+
if (!isPlainObject(x))
|
|
165
|
+
reject('malformed_item');
|
|
166
|
+
const o = x;
|
|
167
|
+
const data = ownData(o, 'data');
|
|
168
|
+
const mimeType = ownData(o, 'mimeType');
|
|
169
|
+
const url = ownData(o, 'url');
|
|
170
|
+
if (url === undefined && data !== undefined)
|
|
171
|
+
return { data: nonEmpty(data), mimeType: nonEmpty(mimeType) };
|
|
172
|
+
if (data === undefined && mimeType === undefined)
|
|
173
|
+
return { url: nonEmpty(url) };
|
|
174
|
+
return reject('malformed_item');
|
|
175
|
+
}
|
|
176
|
+
const MISSING_KIND_LIST = ['rider_text', 'image', 'attachment_ref', 'non_text'];
|
|
177
|
+
const MISSING_REASON_LIST = ['not_persisted', 'not_found', 'non_text_filtered', 'projection_failed'];
|
|
178
|
+
const missingListsExhaustive = true;
|
|
179
|
+
void missingListsExhaustive;
|
|
180
|
+
const MISSING_KINDS = new Set(MISSING_KIND_LIST);
|
|
181
|
+
const MISSING_REASONS = new Set(MISSING_REASON_LIST);
|
|
182
|
+
function readItem(x) {
|
|
183
|
+
if (!isPlainObject(x))
|
|
184
|
+
reject('malformed_item');
|
|
185
|
+
const o = x;
|
|
186
|
+
const text = ownData(o, 'text');
|
|
187
|
+
if (typeof text !== 'string')
|
|
188
|
+
reject('malformed_item');
|
|
189
|
+
const attachments = optArray(ownData(o, 'attachments')).map((a) => {
|
|
190
|
+
if (!isPlainObject(a))
|
|
191
|
+
reject('malformed_item');
|
|
192
|
+
const ao = a;
|
|
193
|
+
const d = readDescriptorAny(ownData(ao, 'descriptor'), 'ignored');
|
|
194
|
+
if (d === undefined)
|
|
195
|
+
reject('malformed_item');
|
|
196
|
+
const px = ownData(ao, 'pixels');
|
|
197
|
+
let pixels;
|
|
198
|
+
if (px !== undefined) {
|
|
199
|
+
if (d.kind !== 'image' || !isPlainObject(px))
|
|
200
|
+
reject('malformed_item');
|
|
201
|
+
pixels = { data: nonEmpty(ownData(px, 'data')), mimeType: nonEmpty(ownData(px, 'mimeType')) };
|
|
202
|
+
}
|
|
203
|
+
return { uuid: nonEmpty(ownData(ao, 'uuid')), d: d, pixels };
|
|
204
|
+
});
|
|
205
|
+
return {
|
|
206
|
+
uuid: nonEmpty(ownData(o, 'uuid')),
|
|
207
|
+
text: text,
|
|
208
|
+
images: optArray(ownData(o, 'images')).map(readImage),
|
|
209
|
+
attachments,
|
|
210
|
+
attachmentIds: optArray(ownData(o, 'attachmentIds')).map(nonEmpty),
|
|
211
|
+
riders: optArray(ownData(o, 'riders')).map((r) => {
|
|
212
|
+
if (!isPlainObject(r))
|
|
213
|
+
reject('malformed_item');
|
|
214
|
+
const ti = ownData(r, 'textIncluded');
|
|
215
|
+
if (typeof ti !== 'boolean')
|
|
216
|
+
reject('malformed_item');
|
|
217
|
+
return { uuid: nonEmpty(ownData(r, 'uuid')), role: nonEmpty(ownData(r, 'role')), textIncluded: ti };
|
|
218
|
+
}),
|
|
219
|
+
missing: optArray(ownData(o, 'missing')).map((m) => {
|
|
220
|
+
if (!isPlainObject(m))
|
|
221
|
+
reject('malformed_item');
|
|
222
|
+
const kind = ownData(m, 'kind');
|
|
223
|
+
const reason = ownData(m, 'reason');
|
|
224
|
+
const ref = ownData(m, 'ref');
|
|
225
|
+
if (typeof kind !== 'string' || !MISSING_KINDS.has(kind))
|
|
226
|
+
reject('malformed_item');
|
|
227
|
+
if (typeof reason !== 'string' || !MISSING_REASONS.has(reason))
|
|
228
|
+
reject('malformed_item');
|
|
229
|
+
if (ref !== undefined && typeof ref !== 'string')
|
|
230
|
+
reject('malformed_item');
|
|
231
|
+
return { kind: kind, ref: ref, reason: reason };
|
|
232
|
+
}),
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
function readInputAny(x) {
|
|
236
|
+
if (!isPlainObject(x))
|
|
237
|
+
reject('malformed_input');
|
|
238
|
+
const o = x;
|
|
239
|
+
const lane = ownData(o, 'lane');
|
|
240
|
+
if (lane !== 'objective' && lane !== 'steer')
|
|
241
|
+
reject('malformed_input');
|
|
242
|
+
const caps = ownData(o, 'caps');
|
|
243
|
+
if (!isPlainObject(caps))
|
|
244
|
+
reject('malformed_input');
|
|
245
|
+
const vision = ownData(caps, 'vision');
|
|
246
|
+
if (vision !== undefined && vision !== 'yes' && vision !== 'no' && vision !== 'unknown')
|
|
247
|
+
reject('malformed_input');
|
|
248
|
+
let otherBodyBytes = 0;
|
|
249
|
+
if (lane === 'objective') {
|
|
250
|
+
const ob = ownData(o, 'otherBodyBytes');
|
|
251
|
+
if (typeof ob !== 'number' || !Number.isSafeInteger(ob) || ob < 2)
|
|
252
|
+
reject('malformed_input');
|
|
253
|
+
otherBodyBytes = ob;
|
|
254
|
+
}
|
|
255
|
+
const raw = ownData(o, 'items');
|
|
256
|
+
if (!Array.isArray(raw))
|
|
257
|
+
reject('malformed_input');
|
|
258
|
+
let rawItems;
|
|
259
|
+
try {
|
|
260
|
+
rawItems = ownArray(raw);
|
|
261
|
+
}
|
|
262
|
+
catch {
|
|
263
|
+
return reject('malformed_input');
|
|
264
|
+
}
|
|
265
|
+
if (rawItems.length === 0)
|
|
266
|
+
reject('empty');
|
|
267
|
+
const items = rawItems.map((x) => {
|
|
268
|
+
try {
|
|
269
|
+
return readItem(x);
|
|
270
|
+
}
|
|
271
|
+
catch (e) {
|
|
272
|
+
return reject(rejectReasonOf(e) ?? 'malformed_item');
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
const primaries = new Set();
|
|
276
|
+
for (const it of items) {
|
|
277
|
+
if (primaries.has(it.uuid))
|
|
278
|
+
reject('duplicate_uuid');
|
|
279
|
+
primaries.add(it.uuid);
|
|
280
|
+
}
|
|
281
|
+
const secondaries = new Set();
|
|
282
|
+
for (const it of items) {
|
|
283
|
+
for (const u of [...it.riders.map((r) => r.uuid), ...it.attachments.map((a) => a.uuid)]) {
|
|
284
|
+
if (primaries.has(u))
|
|
285
|
+
reject('rider_collides_primary');
|
|
286
|
+
if (secondaries.has(u))
|
|
287
|
+
reject('malformed_item');
|
|
288
|
+
secondaries.add(u);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
if (items.every((it) => it.text.length === 0 && it.images.length === 0 && it.attachments.length === 0 && it.attachmentIds.length === 0))
|
|
292
|
+
reject('empty');
|
|
293
|
+
return { lane: lane, vision: vision ?? 'unknown', otherBodyBytes, items };
|
|
294
|
+
}
|
|
295
|
+
export function readHumanTurnInput(input) {
|
|
296
|
+
try {
|
|
297
|
+
return readInputAny(input);
|
|
298
|
+
}
|
|
299
|
+
catch (e) {
|
|
300
|
+
return { reject: rejectReasonOf(e) ?? 'malformed_input' };
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
export function readEncodingShares(encoding) {
|
|
304
|
+
try {
|
|
305
|
+
if (!isPlainObject(encoding) || ownData(encoding, 'ok') !== true)
|
|
306
|
+
return undefined;
|
|
307
|
+
const out = [];
|
|
308
|
+
for (const s of ownArray(ownData(encoding, 'shares'))) {
|
|
309
|
+
if (!isPlainObject(s))
|
|
310
|
+
return undefined;
|
|
311
|
+
const level = ownData(s, 'level');
|
|
312
|
+
const uuid = ownData(s, 'uuid');
|
|
313
|
+
const riders = ownArray(ownData(s, 'riderUuids'));
|
|
314
|
+
if (typeof uuid !== 'string' || uuid.length === 0)
|
|
315
|
+
return undefined;
|
|
316
|
+
if (level !== 'full' && level !== 'partial' && level !== 'none')
|
|
317
|
+
return undefined;
|
|
318
|
+
const riderUuids = [];
|
|
319
|
+
for (const r of riders) {
|
|
320
|
+
if (typeof r !== 'string' || r.length === 0)
|
|
321
|
+
return undefined;
|
|
322
|
+
riderUuids.push(r);
|
|
323
|
+
}
|
|
324
|
+
out.push({ uuid, level, riderUuids });
|
|
325
|
+
}
|
|
326
|
+
return out;
|
|
327
|
+
}
|
|
328
|
+
catch {
|
|
329
|
+
return undefined;
|
|
330
|
+
}
|
|
331
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -31,7 +31,8 @@ export * from './executionLaneCapability.js';
|
|
|
31
31
|
export * from './approvalsStreamLiveCapability.js';
|
|
32
32
|
export * from './peerLaneCapability.js';
|
|
33
33
|
export * from './permissionRulesWriteCapability.js';
|
|
34
|
-
export
|
|
34
|
+
export { __resetPermissionsAllowGrantReadingsForTests, forgetPermissionsAllowGrantReading, noteEngineCapsForPermissionsAllowGrant, observedPermissionsAllowGrant, permissionsAllowGrantAvailable, permissionsAllowGrantDoctorDetail, projectPermissionsAllowGrantCapability, } from './permissionsAllowGrantCapability.js';
|
|
35
|
+
export type { PermissionsAllowGrantReading } from './permissionsAllowGrantCapability.js';
|
|
35
36
|
export * from './sessionPolicyCapability.js';
|
|
36
37
|
export * from './memoryComplianceCapability.js';
|
|
37
38
|
export * from './memoryOriginCapability.js';
|
|
@@ -68,7 +69,7 @@ export type { DisplayUntrustedOptions, DisplayMark, DisplayMarkSpan, DisplayUntr
|
|
|
68
69
|
export type * from './types/engineState.js';
|
|
69
70
|
export * from './hostEnv.js';
|
|
70
71
|
export * from './unrefTimer.js';
|
|
71
|
-
export { ControlRouter, ControlSafetyError, errCodes, type ControlClientLike, type ControlRouterOptions, type ControlSafetyCode, type ErrCodes, type QueuedCommand, type QueuePriority, type RunsResourceLike, } from './controlRouter.js';
|
|
72
|
+
export { ControlRouter, ControlSafetyError, errCodes, steerRefusalAdviceOf, steeringRefusedBeforeEngine, type ControlClientLike, type ControlRouterOptions, type ControlSafetyCode, type ErrCodes, type QueuedCommand, type QueuePriority, type RunsResourceLike, type SteerRefusalAdvice, type SteeringRefusedBeforeEngine, } from './controlRouter.js';
|
|
72
73
|
export * from './sseIdleTriage.js';
|
|
73
74
|
export * from './engineWireSdk.js';
|
|
74
75
|
export * from './classifierVerdictWire.js';
|
|
@@ -110,17 +111,18 @@ export * from './effortWire.js';
|
|
|
110
111
|
export * from './adapter/types.js';
|
|
111
112
|
export * from './adapter/downstream/turnUsageToModelUsage.js';
|
|
112
113
|
export * from './adapter/downstream/eventToSdkMessage.js';
|
|
113
|
-
export type { WiringManifestView, WiringManifestSections } from './adapter/downstream/wiringManifestView.js';
|
|
114
|
+
export type { WiringManifestView, WiringManifestSections, WiringManifestFleetView } from './adapter/downstream/wiringManifestView.js';
|
|
114
115
|
export * from './adapter/downstream/terminalToSdkResult.js';
|
|
115
116
|
export * from './adapter/runStream.js';
|
|
116
117
|
export * from './adapter/activeRunSelfHeal.js';
|
|
117
118
|
export * from './request/taskRequest.js';
|
|
118
|
-
export { disableSkillsDeclaration } from './disableSkillsWire.js';
|
|
119
|
+
export { disableSkillsDeclaration, disableSkillsDeclarationSettled } from './disableSkillsWire.js';
|
|
119
120
|
export type { DisableSkillsDeclaration } from './disableSkillsWire.js';
|
|
120
|
-
export { permissionsDeclaration } from './permissionsDeclaration.js';
|
|
121
|
-
export type { PermissionsDeclaration, PermissionsDeclarationBuckets, PermissionsDeclarationInput, WireRuleOrigin, WireRuleOrigins } from './permissionsDeclaration.js';
|
|
121
|
+
export { PERMISSIONS_KEPT_REASONS, permissionsDeclaration, permissionsDeclarationReport } from './permissionsDeclaration.js';
|
|
122
|
+
export type { PermissionsDeclaration, PermissionsDeclarationBuckets, PermissionsDeclarationInput, PermissionsDeclarationReport, PermissionsKeptReason, PermissionsKeptRule, PermissionsRewrittenRule, PermissionsUncheckedRule, WireRuleOrigin, WireRuleOrigins, } from './permissionsDeclaration.js';
|
|
122
123
|
export * from './clientSlice.js';
|
|
123
124
|
export * from './host.js';
|
|
125
|
+
export { abortableSleep } from './abortableSleep.js';
|
|
124
126
|
export { DEFAULT_SESSION_KEY } from './sessionSlot.js';
|
|
125
127
|
export * from './scratchpadWireCaps.js';
|
|
126
128
|
export * from './toolResult.js';
|
|
@@ -153,11 +155,19 @@ export * from './principalWire.js';
|
|
|
153
155
|
export * from './wireErrorTriage.js';
|
|
154
156
|
export * from './corruptSession.js';
|
|
155
157
|
export * from './corruptSessionCopy.js';
|
|
156
|
-
export { classifyToolHistoryMismatch, resolveToolHistoryRewindTarget } from './toolHistoryMismatch.js';
|
|
158
|
+
export { classifyToolHistoryMismatch, readToolHistoryMismatchKey, resolveToolHistoryRewindTarget } from './toolHistoryMismatch.js';
|
|
159
|
+
export type { ToolHistoryMismatchRowKey } from './toolHistoryMismatch.js';
|
|
160
|
+
export { toolHistoryBadTurnSentence } from './toolHistoryBadTurn.js';
|
|
157
161
|
export { classifyRegistryConflict, isScopeGoneError } from './registryConflict.js';
|
|
158
162
|
export type { RegistryConflictClass } from './registryConflict.js';
|
|
159
163
|
export { createPromptDeliveryLedger, promptKnownUndelivered, withoutUndeliveredPrompts } from './promptDelivery.js';
|
|
160
164
|
export type { PromptDeliveryLedger, PromptDeliveryRecord } from './promptDelivery.js';
|
|
165
|
+
export { mintUserAttachmentEnvelope } from './userAttachmentEnvelope.js';
|
|
166
|
+
export type { UserAttachmentDescriptor, UserAttachmentNotebookCell } from './userAttachmentEnvelope.js';
|
|
167
|
+
export { encodeHumanTurn, deliveredUuidsOf } from './humanTurn.js';
|
|
168
|
+
export type { HumanTurnInput, HumanTurnItem, HumanTurnAttachment, HumanTurnRider, HumanTurnMissing, HumanTurnCaps, HumanTurnEncoding, HumanTurnShare, HumanTurnSharePart, HumanTurnDegraded, HumanTurnDelivered, } from './humanTurn.js';
|
|
169
|
+
export { noteEngineCapsForAttachmentSeat, observedAttachmentSeat, forgetAttachmentSeatReading, __resetAttachmentSeatReadingsForTests, } from './attachmentSeatCapability.js';
|
|
170
|
+
export type { AttachmentSeatReading } from './attachmentSeatCapability.js';
|
|
161
171
|
export * from './resumeRefusalCopy.js';
|
|
162
172
|
export * from './wireRefusalCopy.js';
|
|
163
173
|
export * from './inheritEnvWire.js';
|
|
@@ -171,6 +181,11 @@ export * from './workflowClient.js';
|
|
|
171
181
|
export * from './hooksWireCaps.js';
|
|
172
182
|
export { ENGINE_FIRED_HOOK_EVENTS, PLUGIN_HOOK_DISPOSITIONS, PLUGIN_HOOK_REASONS, PLUGIN_HOOK_EXCLUSION_REASONS, SETTINGS_HOOK_DROP_REASONS, isEngineFiredHookEvent, pluginHookVerdictOf, pluginHookReasonText, settingsHookDropText, pluginHookExecutorLabel, hooksNotRunNotice, settingsHooksKeptLocally, type EngineFiredHookEvent, type PluginHookDisposition, type PluginHookReason, type PluginHookExclusionReason, type SettingsHookDropReason, type HookSettingsSource, type PluginHookKey, type PluginHookVerdict, type PluginHookExclusion, type SettingsHookDrop, type SettingsHookVerdict, type SettingsHookExclusion, type HooksWireEngineFacts, type PluginHookReaderState, type HooksWirePlan, type HooksWirePlanOptions, } from './pluginHooksWire.js';
|
|
173
183
|
export { hookToolAliasesOf, canonicalHookToolName } from './hookToolAliases.js';
|
|
184
|
+
export { hookMatcherVerdict } from './hookMatcherVerdict.js';
|
|
185
|
+
export type { HookMatcherVerdict, HookMatcherUnjudgedReason } from './hookMatcherVerdict.js';
|
|
186
|
+
export { ASK_EVIDENCE_ABSENCE_VALUES, SYSTEM_INJECTION_PRIORITIES } from './engineClosedSets.js';
|
|
187
|
+
export { READ_DENY_BUILTIN_TIERS, READ_DENY_DEFAULT_TIERS, parseReadDenyBuiltinTiers, type ReadDenyBuiltinTiersParse } from './readDenyTiers.js';
|
|
188
|
+
export { MODE_ARBITRATION, askSurvivesStandingAnswer, type StandingAnswerVerdict } from './askSurvivesStandingAnswer.js';
|
|
174
189
|
export * from './liveInitToolFace.js';
|
|
175
190
|
export * from './printInitToolFace.js';
|
|
176
191
|
export * from './model/providerPresets.js';
|
|
@@ -201,7 +216,9 @@ export * from './hitl/sessionPolicyDeliverable.js';
|
|
|
201
216
|
export * from './hitl/approvalsFeed.js';
|
|
202
217
|
export * from './hitl/livePendingAsk.js';
|
|
203
218
|
export * from './hitl/askSurvivesPosture.js';
|
|
204
|
-
export
|
|
219
|
+
export { projectCrashConverged } from './hitl/crashConverged.js';
|
|
220
|
+
export type { ApprovalsListEnvelope, CrashConvergedOrphanState, CrashConvergedProjection, CrashConvergedRow } from './hitl/crashConverged.js';
|
|
221
|
+
export * from './hitl/crashConvergedNotice.js';
|
|
205
222
|
export * from './interactiveHalt.js';
|
|
206
223
|
export * from './compensations.js';
|
|
207
224
|
export * from './request/printNotification.js';
|
package/dist/index.js
CHANGED
|
@@ -26,7 +26,7 @@ export * from './executionLaneCapability.js';
|
|
|
26
26
|
export * from './approvalsStreamLiveCapability.js';
|
|
27
27
|
export * from './peerLaneCapability.js';
|
|
28
28
|
export * from './permissionRulesWriteCapability.js';
|
|
29
|
-
export
|
|
29
|
+
export { __resetPermissionsAllowGrantReadingsForTests, forgetPermissionsAllowGrantReading, noteEngineCapsForPermissionsAllowGrant, observedPermissionsAllowGrant, permissionsAllowGrantAvailable, permissionsAllowGrantDoctorDetail, projectPermissionsAllowGrantCapability, } from './permissionsAllowGrantCapability.js';
|
|
30
30
|
export * from './sessionPolicyCapability.js';
|
|
31
31
|
export * from './memoryComplianceCapability.js';
|
|
32
32
|
export * from './memoryOriginCapability.js';
|
|
@@ -61,7 +61,7 @@ export * from './fleetTaskDesc.js';
|
|
|
61
61
|
export { displayUntrusted, displayUntrustedMarks } from './displayUntrusted.js';
|
|
62
62
|
export * from './hostEnv.js';
|
|
63
63
|
export * from './unrefTimer.js';
|
|
64
|
-
export { ControlRouter, ControlSafetyError, errCodes, } from './controlRouter.js';
|
|
64
|
+
export { ControlRouter, ControlSafetyError, errCodes, steerRefusalAdviceOf, steeringRefusedBeforeEngine, } from './controlRouter.js';
|
|
65
65
|
export * from './sseIdleTriage.js';
|
|
66
66
|
export * from './engineWireSdk.js';
|
|
67
67
|
export * from './classifierVerdictWire.js';
|
|
@@ -105,10 +105,11 @@ export * from './adapter/downstream/terminalToSdkResult.js';
|
|
|
105
105
|
export * from './adapter/runStream.js';
|
|
106
106
|
export * from './adapter/activeRunSelfHeal.js';
|
|
107
107
|
export * from './request/taskRequest.js';
|
|
108
|
-
export { disableSkillsDeclaration } from './disableSkillsWire.js';
|
|
109
|
-
export { permissionsDeclaration } from './permissionsDeclaration.js';
|
|
108
|
+
export { disableSkillsDeclaration, disableSkillsDeclarationSettled } from './disableSkillsWire.js';
|
|
109
|
+
export { PERMISSIONS_KEPT_REASONS, permissionsDeclaration, permissionsDeclarationReport } from './permissionsDeclaration.js';
|
|
110
110
|
export * from './clientSlice.js';
|
|
111
111
|
export * from './host.js';
|
|
112
|
+
export { abortableSleep } from './abortableSleep.js';
|
|
112
113
|
export { DEFAULT_SESSION_KEY } from './sessionSlot.js';
|
|
113
114
|
export * from './scratchpadWireCaps.js';
|
|
114
115
|
export * from './toolResult.js';
|
|
@@ -138,9 +139,13 @@ export * from './principalWire.js';
|
|
|
138
139
|
export * from './wireErrorTriage.js';
|
|
139
140
|
export * from './corruptSession.js';
|
|
140
141
|
export * from './corruptSessionCopy.js';
|
|
141
|
-
export { classifyToolHistoryMismatch, resolveToolHistoryRewindTarget } from './toolHistoryMismatch.js';
|
|
142
|
+
export { classifyToolHistoryMismatch, readToolHistoryMismatchKey, resolveToolHistoryRewindTarget } from './toolHistoryMismatch.js';
|
|
143
|
+
export { toolHistoryBadTurnSentence } from './toolHistoryBadTurn.js';
|
|
142
144
|
export { classifyRegistryConflict, isScopeGoneError } from './registryConflict.js';
|
|
143
145
|
export { createPromptDeliveryLedger, promptKnownUndelivered, withoutUndeliveredPrompts } from './promptDelivery.js';
|
|
146
|
+
export { mintUserAttachmentEnvelope } from './userAttachmentEnvelope.js';
|
|
147
|
+
export { encodeHumanTurn, deliveredUuidsOf } from './humanTurn.js';
|
|
148
|
+
export { noteEngineCapsForAttachmentSeat, observedAttachmentSeat, forgetAttachmentSeatReading, __resetAttachmentSeatReadingsForTests, } from './attachmentSeatCapability.js';
|
|
144
149
|
export * from './resumeRefusalCopy.js';
|
|
145
150
|
export * from './wireRefusalCopy.js';
|
|
146
151
|
export * from './inheritEnvWire.js';
|
|
@@ -153,6 +158,10 @@ export * from './workflowClient.js';
|
|
|
153
158
|
export * from './hooksWireCaps.js';
|
|
154
159
|
export { ENGINE_FIRED_HOOK_EVENTS, PLUGIN_HOOK_DISPOSITIONS, PLUGIN_HOOK_REASONS, PLUGIN_HOOK_EXCLUSION_REASONS, SETTINGS_HOOK_DROP_REASONS, isEngineFiredHookEvent, pluginHookVerdictOf, pluginHookReasonText, settingsHookDropText, pluginHookExecutorLabel, hooksNotRunNotice, settingsHooksKeptLocally, } from './pluginHooksWire.js';
|
|
155
160
|
export { hookToolAliasesOf, canonicalHookToolName } from './hookToolAliases.js';
|
|
161
|
+
export { hookMatcherVerdict } from './hookMatcherVerdict.js';
|
|
162
|
+
export { ASK_EVIDENCE_ABSENCE_VALUES, SYSTEM_INJECTION_PRIORITIES } from './engineClosedSets.js';
|
|
163
|
+
export { READ_DENY_BUILTIN_TIERS, READ_DENY_DEFAULT_TIERS, parseReadDenyBuiltinTiers } from './readDenyTiers.js';
|
|
164
|
+
export { MODE_ARBITRATION, askSurvivesStandingAnswer } from './askSurvivesStandingAnswer.js';
|
|
156
165
|
export * from './liveInitToolFace.js';
|
|
157
166
|
export * from './printInitToolFace.js';
|
|
158
167
|
export * from './model/providerPresets.js';
|
|
@@ -181,7 +190,8 @@ export * from './hitl/sessionPolicyDeliverable.js';
|
|
|
181
190
|
export * from './hitl/approvalsFeed.js';
|
|
182
191
|
export * from './hitl/livePendingAsk.js';
|
|
183
192
|
export * from './hitl/askSurvivesPosture.js';
|
|
184
|
-
export
|
|
193
|
+
export { projectCrashConverged } from './hitl/crashConverged.js';
|
|
194
|
+
export * from './hitl/crashConvergedNotice.js';
|
|
185
195
|
export * from './interactiveHalt.js';
|
|
186
196
|
export * from './compensations.js';
|
|
187
197
|
export * from './request/printNotification.js';
|
package/dist/inheritEnvWire.js
CHANGED
|
@@ -77,7 +77,7 @@ export function inheritEnvRefusalFromError(err, sentRequest) {
|
|
|
77
77
|
return null;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
const REFUSAL_NOT_ACCEPTED = 'The engine refused this request as invalid
|
|
80
|
+
const REFUSAL_NOT_ACCEPTED = 'The engine refused this request as invalid, under a refusal code that many different request fields share · ' +
|
|
81
81
|
"This request asked for the shell to inherit this machine's whole environment, which the engine accepts only when tools run directly on its own machine and the request belongs to a session; if that is what it refused, send it again without that setting (or with the default)";
|
|
82
82
|
export function inheritEnvRefusalContent(_detail) {
|
|
83
83
|
return REFUSAL_NOT_ACCEPTED;
|
|
@@ -16,6 +16,8 @@ export declare function setLiveModelCatalogRefresher(fn: (() => Promise<LiveMode
|
|
|
16
16
|
export declare function refreshLiveModelCatalog(): Promise<boolean>;
|
|
17
17
|
export declare function getLiveModelCatalog(): LiveModelCatalog | null;
|
|
18
18
|
export declare function normalizeLiveModelRef(ref: string): string;
|
|
19
|
+
export type ImageVision = 'yes' | 'no' | 'unknown';
|
|
20
|
+
export declare function imageVisionOf(model: string | undefined, catalog?: LiveModelCatalog | null): ImageVision;
|
|
19
21
|
export declare function liveDefaultModelName(): string | null;
|
|
20
22
|
export interface RoutePairingVerdict {
|
|
21
23
|
verdict: 'ok' | 'broken' | 'unknown';
|
package/dist/liveModelCatalog.js
CHANGED
|
@@ -26,10 +26,58 @@ export function getLiveModelCatalog() {
|
|
|
26
26
|
export function normalizeLiveModelRef(ref) {
|
|
27
27
|
if (!catalog || !ref)
|
|
28
28
|
return ref;
|
|
29
|
-
|
|
29
|
+
const row = liveModelRowOf(catalog, ref);
|
|
30
|
+
if (row === undefined)
|
|
30
31
|
return ref;
|
|
31
|
-
const
|
|
32
|
-
return
|
|
32
|
+
const name = ownDataOf(row, 'name');
|
|
33
|
+
return typeof name === 'string' && name ? name : ref;
|
|
34
|
+
}
|
|
35
|
+
function ownDataOf(o, key) {
|
|
36
|
+
try {
|
|
37
|
+
const d = Object.getOwnPropertyDescriptor(o, key);
|
|
38
|
+
return d !== undefined && 'value' in d ? d.value : undefined;
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function liveModelRowOf(cat, ref) {
|
|
45
|
+
const models = ownDataOf(cat, 'models');
|
|
46
|
+
if (!Array.isArray(models))
|
|
47
|
+
return undefined;
|
|
48
|
+
const n = ownDataOf(models, 'length');
|
|
49
|
+
if (typeof n !== 'number' || !Number.isSafeInteger(n) || n < 0)
|
|
50
|
+
return undefined;
|
|
51
|
+
const rows = [];
|
|
52
|
+
for (let i = 0; i < n; i += 1) {
|
|
53
|
+
const row = ownDataOf(models, String(i));
|
|
54
|
+
if (row !== null && typeof row === 'object')
|
|
55
|
+
rows.push(row);
|
|
56
|
+
}
|
|
57
|
+
return rows.find((row) => ownDataOf(row, 'name') === ref) ?? rows.find((row) => ownDataOf(row, 'id') === ref);
|
|
58
|
+
}
|
|
59
|
+
export function imageVisionOf(model, catalog = getLiveModelCatalog()) {
|
|
60
|
+
try {
|
|
61
|
+
if (model !== undefined && typeof model !== 'string')
|
|
62
|
+
return 'unknown';
|
|
63
|
+
if (catalog === null || typeof catalog !== 'object' || Array.isArray(catalog))
|
|
64
|
+
return 'unknown';
|
|
65
|
+
let target = model !== undefined && model.length > 0 ? model : undefined;
|
|
66
|
+
if (target === undefined) {
|
|
67
|
+
const def = ownDataOf(catalog, 'default');
|
|
68
|
+
target = typeof def === 'string' && def.length > 0 ? def : undefined;
|
|
69
|
+
}
|
|
70
|
+
if (target === undefined)
|
|
71
|
+
return 'unknown';
|
|
72
|
+
const row = liveModelRowOf(catalog, target);
|
|
73
|
+
if (row === undefined)
|
|
74
|
+
return 'unknown';
|
|
75
|
+
const vision = ownDataOf(row, 'vision');
|
|
76
|
+
return vision === true ? 'yes' : vision === false ? 'no' : 'unknown';
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return 'unknown';
|
|
80
|
+
}
|
|
33
81
|
}
|
|
34
82
|
export function liveDefaultModelName() {
|
|
35
83
|
if (!catalog?.default)
|