@try-works/dsh-model-as-tool 0.4.3 → 0.4.5
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/client/index.js +3 -3
- package/lib/bindings.d.ts +29 -0
- package/lib/bindings.d.ts.map +1 -1
- package/lib/bindings.js +74 -0
- package/lib/contract-payload.d.ts +4 -12
- package/lib/contract-payload.d.ts.map +1 -1
- package/lib/contract-payload.js +20 -101
- package/lib/extension-dispatch.d.ts +33 -0
- package/lib/extension-dispatch.d.ts.map +1 -1
- package/lib/extension-dispatch.js +54 -0
- package/lib/extension-registrar.d.ts +16 -0
- package/lib/extension-registrar.d.ts.map +1 -1
- package/lib/extension-registrar.js +17 -7
- package/lib/extensions-service.d.ts +3 -1
- package/lib/extensions-service.d.ts.map +1 -1
- package/lib/extensions-service.js +39 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +80 -5
- package/lib/prepared-assets.d.ts +36 -0
- package/lib/prepared-assets.d.ts.map +1 -1
- package/lib/prepared-assets.js +53 -0
- package/package.json +1 -1
package/client/index.js
CHANGED
|
@@ -280,7 +280,7 @@ window.__ModuleLoader__.load({
|
|
|
280
280
|
"id": "@try-works/extension-embeddinggemma",
|
|
281
281
|
"name": "EmbeddingGemma 2",
|
|
282
282
|
"package": "@try-works/extension-embeddinggemma",
|
|
283
|
-
"version": "0.1.
|
|
283
|
+
"version": "0.1.1",
|
|
284
284
|
"license": "MIT",
|
|
285
285
|
"summary": "Multimodal embedding and retrieval tools over EmbeddingGemma 2 (google/embeddinggemma-2 through a pinned ONNX conversion): multimodal_embed produces 768-, 51…",
|
|
286
286
|
"models": [
|
|
@@ -307,7 +307,7 @@ window.__ModuleLoader__.load({
|
|
|
307
307
|
"id": "@try-works/extension-laya",
|
|
308
308
|
"name": "Laya",
|
|
309
309
|
"package": "@try-works/extension-laya",
|
|
310
|
-
"version": "1.0.
|
|
310
|
+
"version": "1.0.1",
|
|
311
311
|
"license": "Apache-2.0",
|
|
312
312
|
"summary": "The Laya decision family (H5): decision_choose (a choice over the caller's options), decision_test (yes/no) and decision_score (an ordinal level) over the pi…",
|
|
313
313
|
"models": [
|
|
@@ -358,7 +358,7 @@ window.__ModuleLoader__.load({
|
|
|
358
358
|
"id": "@try-works/extension-needle",
|
|
359
359
|
"name": "Needle 3",
|
|
360
360
|
"package": "@try-works/extension-needle",
|
|
361
|
-
"version": "0.1.
|
|
361
|
+
"version": "0.1.1",
|
|
362
362
|
"license": "MIT",
|
|
363
363
|
"summary": "Tool proposal and structured extraction over the pinned Cactus Needle 3 native engine (Cactus-Compute/needle3, windows-x86_64/needle.exe at revision 93e88ede…",
|
|
364
364
|
"models": [
|
package/lib/bindings.d.ts
CHANGED
|
@@ -112,4 +112,33 @@ export declare function registerContractTool(ctx: {
|
|
|
112
112
|
toolName: string;
|
|
113
113
|
dispose: () => void;
|
|
114
114
|
};
|
|
115
|
+
/**
|
|
116
|
+
* Register a STANDARD contract tool served by an ACTIVE extension's
|
|
117
|
+
* IMPLEMENTATION (TASK-121), mirroring {@link registerContractTool} with the
|
|
118
|
+
* execution bound to a host-supplied dispatch instead of a catalogue adapter.
|
|
119
|
+
*
|
|
120
|
+
* The tool name, description and schemas come from the CONTRACT definition —
|
|
121
|
+
* never invented per extension — and the dispatch hands the CONTRACT-shaped
|
|
122
|
+
* input to the extension's implementation (the extension reads the standard
|
|
123
|
+
* shapes directly). Input/output validation, the grant authorization, the
|
|
124
|
+
* meta stamping and the receipt are the SAME discipline the catalogue path
|
|
125
|
+
* applies, so the two routes cannot diverge.
|
|
126
|
+
* @param ctx - the context whose tool registry receives the definition.
|
|
127
|
+
* @param contract - the standard contract definition.
|
|
128
|
+
* @param host - host identity to stamp into results.
|
|
129
|
+
* @param dispatch - executes through the extension implementation.
|
|
130
|
+
* @returns the registered tool name and the registry disposer.
|
|
131
|
+
*/
|
|
132
|
+
export declare function registerContractImplementationTool(ctx: {
|
|
133
|
+
tools: {
|
|
134
|
+
register(definition: unknown): () => void;
|
|
135
|
+
};
|
|
136
|
+
}, contract: ToolContract, host: HostIdentity, dispatch: (args: Record<string, unknown>, signal: AbortSignal) => Promise<Record<string, unknown>>, implementation: {
|
|
137
|
+
readonly id: string;
|
|
138
|
+
readonly extensionId: string;
|
|
139
|
+
readonly modelId: string;
|
|
140
|
+
}): {
|
|
141
|
+
toolName: string;
|
|
142
|
+
dispose: () => void;
|
|
143
|
+
};
|
|
115
144
|
//# sourceMappingURL=bindings.d.ts.map
|
package/lib/bindings.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bindings.d.ts","sourceRoot":"","sources":["../src/bindings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAOL,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,QAAQ,EACd,MAAM,gCAAgC,CAAA;AACvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE/D,OAAO,EAA0B,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAC7E,OAAO,EAGL,KAAK,mBAAmB,EACxB,KAAK,SAAS,EACf,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAEvD,+CAA+C;AAC/C,MAAM,WAAW,YAAY;IAC3B,6BAA6B;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,gCAAgC;IAChC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;IACjC,wEAAwE;IACxE,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAA;IACrC,iEAAiE;IACjE,QAAQ,CAAC,aAAa,EAAE,MAAM,MAAM,CAAA;IACpC;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;IACzB,2CAA2C;IAC3C,QAAQ,CAAC,UAAU,EAAE,mBAAmB,CAAC,YAAY,CAAC,CA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AAQ,EAAE,YAAY,EACtB,IAAI,EAAE,YAAY,EAClB,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAClG,cAAc,EAAE;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAC9F;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,CA0D3C"}
|
package/lib/bindings.js
CHANGED
|
@@ -205,6 +205,80 @@ export function registerContractTool(ctx, binding, host) {
|
|
|
205
205
|
void implementation;
|
|
206
206
|
return { toolName: contract.toolName, dispose: ctx.tools.register(definition) };
|
|
207
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* Register a STANDARD contract tool served by an ACTIVE extension's
|
|
210
|
+
* IMPLEMENTATION (TASK-121), mirroring {@link registerContractTool} with the
|
|
211
|
+
* execution bound to a host-supplied dispatch instead of a catalogue adapter.
|
|
212
|
+
*
|
|
213
|
+
* The tool name, description and schemas come from the CONTRACT definition —
|
|
214
|
+
* never invented per extension — and the dispatch hands the CONTRACT-shaped
|
|
215
|
+
* input to the extension's implementation (the extension reads the standard
|
|
216
|
+
* shapes directly). Input/output validation, the grant authorization, the
|
|
217
|
+
* meta stamping and the receipt are the SAME discipline the catalogue path
|
|
218
|
+
* applies, so the two routes cannot diverge.
|
|
219
|
+
* @param ctx - the context whose tool registry receives the definition.
|
|
220
|
+
* @param contract - the standard contract definition.
|
|
221
|
+
* @param host - host identity to stamp into results.
|
|
222
|
+
* @param dispatch - executes through the extension implementation.
|
|
223
|
+
* @returns the registered tool name and the registry disposer.
|
|
224
|
+
*/
|
|
225
|
+
export function registerContractImplementationTool(ctx, contract, host, dispatch, implementation) {
|
|
226
|
+
assertValidContract(contract);
|
|
227
|
+
const rules = crossFieldRules(contract);
|
|
228
|
+
// The minimal binding-lite the provenance builders read: the meta names the
|
|
229
|
+
// extension's implementation, and the receipt records the extension package.
|
|
230
|
+
const bindingLite = {
|
|
231
|
+
contract,
|
|
232
|
+
implementation: {
|
|
233
|
+
id: implementation.id,
|
|
234
|
+
provider: { extension: implementation.extensionId, modelId: implementation.modelId },
|
|
235
|
+
},
|
|
236
|
+
route: 'extension',
|
|
237
|
+
};
|
|
238
|
+
const definition = defineTool({
|
|
239
|
+
name: contract.toolName,
|
|
240
|
+
description: contract.description,
|
|
241
|
+
parameters: toDshParameters(contract),
|
|
242
|
+
output: {
|
|
243
|
+
schema: {
|
|
244
|
+
type: 'object',
|
|
245
|
+
properties: projectSchemaToDsh(contract.outputSchema).parameters,
|
|
246
|
+
additionalProperties: false,
|
|
247
|
+
},
|
|
248
|
+
render: (_args, value) => {
|
|
249
|
+
const record = value;
|
|
250
|
+
return [{ type: 'text', text: renderForModel(contract, record) }];
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
async execute(args, exec) {
|
|
254
|
+
const record = args;
|
|
255
|
+
assertValidInput(contract, record);
|
|
256
|
+
for (const rule of rules) {
|
|
257
|
+
const violation = rule(record);
|
|
258
|
+
if (violation !== undefined) {
|
|
259
|
+
throw new Error(`${contract.toolName}: ${violation}`);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
authorizeTool(host.grant, contract.toolName);
|
|
263
|
+
const value = await dispatch(record, exec.signal);
|
|
264
|
+
const meta = buildMeta(bindingLite, host);
|
|
265
|
+
const stamped = { ...value, meta };
|
|
266
|
+
assertValidOutput(contract, stamped);
|
|
267
|
+
host.recordReceipt?.(buildReceipt(bindingLite, host, meta));
|
|
268
|
+
return stamped;
|
|
269
|
+
},
|
|
270
|
+
presentCall(callArgs) {
|
|
271
|
+
const primary = Object.values(callArgs)[0];
|
|
272
|
+
return {
|
|
273
|
+
card: 'generic',
|
|
274
|
+
title: contract.toolName,
|
|
275
|
+
kind: 'read',
|
|
276
|
+
...typeof primary === 'string' ? { rawInput: primary } : {},
|
|
277
|
+
};
|
|
278
|
+
},
|
|
279
|
+
});
|
|
280
|
+
return { toolName: contract.toolName, dispose: ctx.tools.register(definition) };
|
|
281
|
+
}
|
|
208
282
|
/**
|
|
209
283
|
* Render a contract result for the model.
|
|
210
284
|
*
|
|
@@ -20,19 +20,11 @@ export declare class PayloadTranslationError extends Error {
|
|
|
20
20
|
readonly name = "PayloadTranslationError";
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
|
-
* Translate
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* speaks its SDK's vocabulary — `audio_path` — while the contract publishes the
|
|
27
|
-
* caller's vocabulary — `audio.path`. Without this translation the contract layer
|
|
28
|
-
* would be cosmetic: the model would advertise one shape and the implementation
|
|
29
|
-
* would read another, and every call would fail on a name that no longer exists.
|
|
30
|
-
*
|
|
31
|
-
* The contract is the authority here too, so the mapping is explicit and total
|
|
32
|
-
* rather than a spread that happens to overlap.
|
|
33
|
-
* @param contractId - the contract the call was validated against.
|
|
23
|
+
* Translate the contract's caller-facing arguments into the implementation's
|
|
24
|
+
* native vocabulary.
|
|
25
|
+
* @param contractId - the contract the implementation was selected for.
|
|
34
26
|
* @param contractArgs - the validated contract arguments.
|
|
35
|
-
* @returns the
|
|
27
|
+
* @returns the native argument shape.
|
|
36
28
|
*/
|
|
37
29
|
export declare function toNativeArgs(contractId: string, contractArgs: Readonly<Record<string, unknown>>): Record<string, unknown>;
|
|
38
30
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract-payload.d.ts","sourceRoot":"","sources":["../src/contract-payload.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAEpD,0EAA0E;AAC1E,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,SAAkB,IAAI,6BAA4B;CACnD;
|
|
1
|
+
{"version":3,"file":"contract-payload.d.ts","sourceRoot":"","sources":["../src/contract-payload.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAEpD,0EAA0E;AAC1E,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,SAAkB,IAAI,6BAA4B;CACnD;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAC9C,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAWzB;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EACjC,IAAI,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAM,GAC3C,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAO3B"}
|
package/lib/contract-payload.js
CHANGED
|
@@ -18,101 +18,24 @@
|
|
|
18
18
|
export class PayloadTranslationError extends Error {
|
|
19
19
|
name = 'PayloadTranslationError';
|
|
20
20
|
}
|
|
21
|
-
/** Best-effort read of a numeric field. */
|
|
22
|
-
function numberOf(value) {
|
|
23
|
-
return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Translate a native language-detection result into the `text.language_detect`
|
|
27
|
-
* payload.
|
|
28
|
-
*
|
|
29
|
-
* The only rename is the vendor's `isTooCloseToCall` to the contract's
|
|
30
|
-
* `tooCloseToCall`; every other field already matches, which is what makes this a
|
|
31
|
-
* translation rather than a reshape.
|
|
32
|
-
* @param native - the adapter's result.
|
|
33
|
-
* @returns the contract payload, without the `meta` envelope the host stamps.
|
|
34
|
-
*/
|
|
35
|
-
function languageDetectPayload(native) {
|
|
36
|
-
const candidates = Array.isArray(native.candidates) ? native.candidates : [];
|
|
37
|
-
return {
|
|
38
|
-
// A model that found no language signal returns null rather than a guess.
|
|
39
|
-
language: typeof native.language === 'string' ? native.language : null,
|
|
40
|
-
reliability: typeof native.reliability === 'string' ? native.reliability : 'unknown',
|
|
41
|
-
tooCloseToCall: native.isTooCloseToCall === true,
|
|
42
|
-
candidates: candidates,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Translate a native transcription result into the `stt.transcribe` payload.
|
|
47
|
-
*
|
|
48
|
-
* `coverage` is the interesting field. Voz streams the whole file and fails loudly
|
|
49
|
-
* on a short decode, so a returned transcript covers all the audio it read;
|
|
50
|
-
* `transcribedSeconds` is taken from the last word's end time, which is a lower
|
|
51
|
-
* bound on the audio actually processed. When no words are reported, coverage is
|
|
52
|
-
* reported as zero seconds with `complete: true` only because the engine ran to
|
|
53
|
-
* completion — an empty transcript is a valid result (TOOL-01), not a failure.
|
|
54
|
-
* @param native - the adapter's result.
|
|
55
|
-
* @param requestedWords - whether the caller asked for word timings.
|
|
56
|
-
* @returns the contract payload, without the `meta` envelope the host stamps.
|
|
57
|
-
*/
|
|
58
|
-
function transcribePayload(native, requestedWords) {
|
|
59
|
-
const words = Array.isArray(native.words) ? native.words : null;
|
|
60
|
-
if (requestedWords && words === null) {
|
|
61
|
-
// TOOL-01: an unsupported timestamp request is an error, never a silent
|
|
62
|
-
// omission the caller might read as "there were no word timings".
|
|
63
|
-
throw new PayloadTranslationError('word timestamps were requested but the implementation returned none; '
|
|
64
|
-
+ 'this is reported as an error rather than an empty list');
|
|
65
|
-
}
|
|
66
|
-
let transcribedSeconds = 0;
|
|
67
|
-
if (words !== null && words.length > 0) {
|
|
68
|
-
const last = words[words.length - 1];
|
|
69
|
-
transcribedSeconds = numberOf(last.end) ?? 0;
|
|
70
|
-
}
|
|
71
|
-
const truncated = native.wordsTruncated === true;
|
|
72
|
-
return {
|
|
73
|
-
text: typeof native.text === 'string' ? native.text : '',
|
|
74
|
-
coverage: {
|
|
75
|
-
complete: !truncated,
|
|
76
|
-
transcribedSeconds,
|
|
77
|
-
totalSeconds: null,
|
|
78
|
-
reason: truncated ? 'word list truncated for transport; the transcript text is complete' : null,
|
|
79
|
-
},
|
|
80
|
-
words: words === null ? null : words,
|
|
81
|
-
language: typeof native.language === 'string' ? native.language : null,
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
21
|
/**
|
|
85
|
-
* Translate
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
* speaks its SDK's vocabulary — `audio_path` — while the contract publishes the
|
|
89
|
-
* caller's vocabulary — `audio.path`. Without this translation the contract layer
|
|
90
|
-
* would be cosmetic: the model would advertise one shape and the implementation
|
|
91
|
-
* would read another, and every call would fail on a name that no longer exists.
|
|
92
|
-
*
|
|
93
|
-
* The contract is the authority here too, so the mapping is explicit and total
|
|
94
|
-
* rather than a spread that happens to overlap.
|
|
95
|
-
* @param contractId - the contract the call was validated against.
|
|
22
|
+
* Translate the contract's caller-facing arguments into the implementation's
|
|
23
|
+
* native vocabulary.
|
|
24
|
+
* @param contractId - the contract the implementation was selected for.
|
|
96
25
|
* @param contractArgs - the validated contract arguments.
|
|
97
|
-
* @returns the
|
|
26
|
+
* @returns the native argument shape.
|
|
98
27
|
*/
|
|
99
28
|
export function toNativeArgs(contractId, contractArgs) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
default:
|
|
113
|
-
// `text.language_detect` already shares its argument names with the adapter.
|
|
114
|
-
return { ...contractArgs };
|
|
115
|
-
}
|
|
29
|
+
void contractId;
|
|
30
|
+
/**
|
|
31
|
+
* TASK-115/120/121: the extension implementations now speak the CONTRACT
|
|
32
|
+
* vocabulary on BOTH sides (the tongue/voz mappings published in 0.1.3 and
|
|
33
|
+
* 0.1.5 read {audio:{path}} and emit the contract payloads), so the host's
|
|
34
|
+
* argument translation is a PASS-THROUGH — the old audio_path/include_words
|
|
35
|
+
* native vocabulary no longer exists on the wire. A future implementation
|
|
36
|
+
* with a genuinely different native vocabulary re-introduces its case here.
|
|
37
|
+
*/
|
|
38
|
+
return { ...contractArgs };
|
|
116
39
|
}
|
|
117
40
|
/**
|
|
118
41
|
* Translate a native implementation result into the payload its contract declares.
|
|
@@ -123,15 +46,11 @@ export function toNativeArgs(contractId, contractArgs) {
|
|
|
123
46
|
* @throws PayloadTranslationError when the native result cannot satisfy the contract.
|
|
124
47
|
*/
|
|
125
48
|
export function toContractPayload(contractId, native, args = {}) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
// A contract with no translator returns the native payload unchanged, which
|
|
133
|
-
// the output schema then accepts or rejects on its own terms.
|
|
134
|
-
return native;
|
|
135
|
-
}
|
|
49
|
+
void contractId;
|
|
50
|
+
void args;
|
|
51
|
+
// TASK-115/120/121: the extension implementations emit the CONTRACT payloads
|
|
52
|
+
// directly, so the result translation is the identity; the output schema's
|
|
53
|
+
// validation is the authority that accepts or rejects the payload.
|
|
54
|
+
return native;
|
|
136
55
|
}
|
|
137
56
|
//# sourceMappingURL=contract-payload.js.map
|
|
@@ -108,6 +108,39 @@ export declare function createDispatch(environment: DispatchEnvironment, toolNam
|
|
|
108
108
|
readonly ok: false;
|
|
109
109
|
readonly failure: DispatchFailure;
|
|
110
110
|
}>;
|
|
111
|
+
/**
|
|
112
|
+
* Resolve the implementation chain for a declared CONTRACT id (TASK-121).
|
|
113
|
+
*
|
|
114
|
+
* An extension whose manifest declares ONLY implementations (no `tools[]` —
|
|
115
|
+
* the MiniLM pair's shape) still serves a caller-facing standard tool: the
|
|
116
|
+
* contract id maps to the standard tool name the host knows, and this
|
|
117
|
+
* resolution finds the implementation by the contract id alone.
|
|
118
|
+
* @param manifest - the activated extension's manifest.
|
|
119
|
+
* @param contractId - the contract identity.
|
|
120
|
+
* @returns the implementation, or why the chain is incomplete.
|
|
121
|
+
*/
|
|
122
|
+
export declare function resolveImplementationByContract(manifest: DispatchManifest, contractId: string): {
|
|
123
|
+
readonly ok: true;
|
|
124
|
+
readonly implementation: DeclaredImplementation;
|
|
125
|
+
} | {
|
|
126
|
+
readonly ok: false;
|
|
127
|
+
readonly failure: DispatchFailure;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Build an `execute` for a standard-named contract tool served by an
|
|
131
|
+
* IMPLEMENTATION-ONLY extension (TASK-121). The provider is created lazily on
|
|
132
|
+
* first call, exactly like the declared-tool path.
|
|
133
|
+
* @param environment - how to reach the extension.
|
|
134
|
+
* @param contractId - the contract identity to dispatch.
|
|
135
|
+
* @returns the execute function, or the failure that prevents one.
|
|
136
|
+
*/
|
|
137
|
+
export declare function createDispatchForContract(environment: DispatchEnvironment, contractId: string): Promise<{
|
|
138
|
+
readonly ok: true;
|
|
139
|
+
readonly execute: (args: Record<string, unknown>, signal: AbortSignal) => Promise<Record<string, unknown>>;
|
|
140
|
+
} | {
|
|
141
|
+
readonly ok: false;
|
|
142
|
+
readonly failure: DispatchFailure;
|
|
143
|
+
}>;
|
|
111
144
|
/**
|
|
112
145
|
* Describe a dispatch failure for a caller (EXT-30).
|
|
113
146
|
* @param failure - the failure.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension-dispatch.d.ts","sourceRoot":"","sources":["../src/extension-dispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAE5D,+CAA+C;AAC/C,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,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,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CAAE,GACjI;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAA;CAAE,CAC5D,CA0CA;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,+BAA+B,CAC7C,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EAAE,MAAM,GACjB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,cAAc,EAAE,sBAAsB,CAAA;CAAE,GACrE;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAA;CAAE,CAa5D;AAED;;;;;;;GAOG;AACH,wBAAsB,yBAAyB,CAC7C,WAAW,EAAE,mBAAmB,EAChC,UAAU,EAAE,MAAM,GACjB,OAAO,CACN;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CAAE,GACjI;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAA;CAAE,CAC5D,CAmBA;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAExE"}
|
|
@@ -113,6 +113,60 @@ export async function createDispatch(environment, toolName) {
|
|
|
113
113
|
},
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Resolve the implementation chain for a declared CONTRACT id (TASK-121).
|
|
118
|
+
*
|
|
119
|
+
* An extension whose manifest declares ONLY implementations (no `tools[]` —
|
|
120
|
+
* the MiniLM pair's shape) still serves a caller-facing standard tool: the
|
|
121
|
+
* contract id maps to the standard tool name the host knows, and this
|
|
122
|
+
* resolution finds the implementation by the contract id alone.
|
|
123
|
+
* @param manifest - the activated extension's manifest.
|
|
124
|
+
* @param contractId - the contract identity.
|
|
125
|
+
* @returns the implementation, or why the chain is incomplete.
|
|
126
|
+
*/
|
|
127
|
+
export function resolveImplementationByContract(manifest, contractId) {
|
|
128
|
+
const implementation = manifest.implementations.find(candidate => candidate.contractId === contractId);
|
|
129
|
+
if (implementation === undefined) {
|
|
130
|
+
return {
|
|
131
|
+
ok: false,
|
|
132
|
+
failure: {
|
|
133
|
+
code: 'no-implementation',
|
|
134
|
+
message: `contract ${contractId} has no implementation in this extension's manifest`,
|
|
135
|
+
remedy: 'The extension declares the contract but binds no model to it.',
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
return { ok: true, implementation };
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Build an `execute` for a standard-named contract tool served by an
|
|
143
|
+
* IMPLEMENTATION-ONLY extension (TASK-121). The provider is created lazily on
|
|
144
|
+
* first call, exactly like the declared-tool path.
|
|
145
|
+
* @param environment - how to reach the extension.
|
|
146
|
+
* @param contractId - the contract identity to dispatch.
|
|
147
|
+
* @returns the execute function, or the failure that prevents one.
|
|
148
|
+
*/
|
|
149
|
+
export async function createDispatchForContract(environment, contractId) {
|
|
150
|
+
const resolved = resolveImplementationByContract(environment.getManifest(), contractId);
|
|
151
|
+
if (!resolved.ok)
|
|
152
|
+
return resolved;
|
|
153
|
+
const { implementation } = resolved;
|
|
154
|
+
return {
|
|
155
|
+
ok: true,
|
|
156
|
+
async execute(args, signal) {
|
|
157
|
+
const provider = await environment.providerFor(implementation.modelId);
|
|
158
|
+
const prepared = environment.assetsFor?.();
|
|
159
|
+
await provider.load({ assets: prepared ?? { get: () => undefined, assetIds: [] }, signal, modelId: implementation.modelId });
|
|
160
|
+
const value = await provider.invoke({
|
|
161
|
+
implementationId: implementation.id,
|
|
162
|
+
input: args,
|
|
163
|
+
context: environment.contextFor(implementation.id, signal),
|
|
164
|
+
});
|
|
165
|
+
assertNoReservedMeta(value, implementation.id);
|
|
166
|
+
return value;
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
}
|
|
116
170
|
/**
|
|
117
171
|
* Describe a dispatch failure for a caller (EXT-30).
|
|
118
172
|
* @param failure - the failure.
|
|
@@ -65,6 +65,22 @@ export interface HostRegistrySurface {
|
|
|
65
65
|
readonly name: string;
|
|
66
66
|
readonly contractId?: string;
|
|
67
67
|
}): () => void;
|
|
68
|
+
/**
|
|
69
|
+
* Register the STANDARD-named contract tool for a MODULE implementation
|
|
70
|
+
* whose contract the host knows a standard name for (TASK-121).
|
|
71
|
+
*
|
|
72
|
+
* A module package that declares ONLY implementations (no `tools[]` — the
|
|
73
|
+
* MiniLM pair's shape) serves the standard contract directly: the host maps
|
|
74
|
+
* the contract id to its standard tool name (text.embed -> text_embed) and
|
|
75
|
+
* registers the tool with the contract's own schemas. Returns a disposer
|
|
76
|
+
* when it registered, or undefined when the contract is not a standard one
|
|
77
|
+
* (the declarative branch below then handles it).
|
|
78
|
+
*/
|
|
79
|
+
registerContractImplementation?(contribution: {
|
|
80
|
+
readonly extensionId: string;
|
|
81
|
+
readonly contractId: string;
|
|
82
|
+
readonly implementationId: string;
|
|
83
|
+
}): (() => void) | undefined;
|
|
68
84
|
}
|
|
69
85
|
/** Raised when a contribution cannot be published. */
|
|
70
86
|
export declare class ContributionError extends Error {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension-registrar.d.ts","sourceRoot":"","sources":["../src/extension-registrar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAA;AAE7F,6DAA6D;AAC7D,MAAM,WAAW,eAAe;IAC9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C,OAAO,EAAE,gBAAgB,GAAG,qBAAqB,CA2G5F"}
|
|
@@ -89,15 +89,25 @@ export function createContributionRegistrar(options) {
|
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
else if (contribution.kind === 'implementation' && options.registry.registerDeclarative !== undefined) {
|
|
92
|
-
//
|
|
93
|
-
//
|
|
94
|
-
//
|
|
95
|
-
//
|
|
96
|
-
|
|
92
|
+
// TASK-121: a MODULE implementation whose contract has a standard tool
|
|
93
|
+
// name registers the standard-named contract tool; the hook returns
|
|
94
|
+
// undefined when the contract is not standard, and the declarative
|
|
95
|
+
// branch then handles it (RCP-01).
|
|
96
|
+
const contractRegistration = options.registry.registerContractImplementation?.({
|
|
97
97
|
extensionId: contribution.extensionId,
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
contractId: contribution.contractId ?? '',
|
|
99
|
+
implementationId: contribution.name,
|
|
100
100
|
});
|
|
101
|
+
if (contractRegistration !== undefined) {
|
|
102
|
+
dispose = contractRegistration;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
dispose = options.registry.registerDeclarative({
|
|
106
|
+
extensionId: contribution.extensionId,
|
|
107
|
+
name: contribution.name,
|
|
108
|
+
...contribution.contractId === undefined ? {} : { contractId: contribution.contractId },
|
|
109
|
+
});
|
|
110
|
+
}
|
|
101
111
|
}
|
|
102
112
|
else {
|
|
103
113
|
dispose = () => { };
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
import { stagedInstallFromDirectory, type ExtensionLifecycle, type InstallDependencyGraph } from '@try-works/tool-mode-extension-sdk';
|
|
52
52
|
import type { ExtensionInstallResult, ExtensionPrepareResult, ExtensionToggleResult, ExtensionsDescribeResult, ModelToolsRemote } from './extensions-api.ts';
|
|
53
53
|
import type { AcquisitionSource } from './asset-acquisition.ts';
|
|
54
|
-
import type
|
|
54
|
+
import { type PrepareAssetsSurface } from './prepared-assets.ts';
|
|
55
55
|
/**
|
|
56
56
|
* The default dependency-graph depth bound for registry installs (task-116).
|
|
57
57
|
*
|
|
@@ -122,6 +122,8 @@ export type ExtensionsServiceErrorCode =
|
|
|
122
122
|
| 'extension-requirement-unmet'
|
|
123
123
|
/** The extension's optional tool runtime is not installed, so its tools cannot load. */
|
|
124
124
|
| 'extension-runtime-unavailable'
|
|
125
|
+
/** The asset lock declares no transferable location; preparation is not possible here. */
|
|
126
|
+
| 'extension-asset-source-unavailable'
|
|
125
127
|
/** Registry mode was selected but no registry URL is configured. */
|
|
126
128
|
| 'extension-registry-unconfigured'
|
|
127
129
|
/** The registry has no such package, version, or dist-tag (HTTP 404 / no matching version). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions-service.d.ts","sourceRoot":"","sources":["../src/extensions-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAKH,OAAO,EAQL,0BAA0B,EAC1B,KAAK,kBAAkB,EAEvB,KAAK,sBAAsB,EAG5B,MAAM,oCAAoC,CAAA;AAC3C,OAAO,KAAK,EACV,sBAAsB,EAGtB,sBAAsB,EAMtB,qBAAqB,EACrB,wBAAwB,EACxB,gBAAgB,EACjB,MAAM,qBAAqB,CAAA;AAY5B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE/D,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"extensions-service.d.ts","sourceRoot":"","sources":["../src/extensions-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAKH,OAAO,EAQL,0BAA0B,EAC1B,KAAK,kBAAkB,EAEvB,KAAK,sBAAsB,EAG5B,MAAM,oCAAoC,CAAA;AAC3C,OAAO,KAAK,EACV,sBAAsB,EAGtB,sBAAsB,EAMtB,qBAAqB,EACrB,wBAAwB,EACxB,gBAAgB,EACjB,MAAM,qBAAqB,CAAA;AAY5B,OAAO,K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GAAG,SAAS,CAAA;IACxE;;;;;;;OAOG;IACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,CAAA;CAC7E;AAoCD;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAGzD;AAwgBD;;;;;;GAMG;AACH,qBAAa,iBAAkB,YAAW,gBAAgB;;gBAW5C,OAAO,GAAE,wBAA6B;IAkjBlD;;;;;;;;OAQG;IACG,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAmMvE;;;;;;;;;;;;;;;;;;;OAmBG;IACG,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAya1G;;;;;;;;;;;;OAYG;IACG,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,qBAAqB,CAAC;IA0HvF;;;;;;;;;;;;;;;;;;;OAmBG;IACG,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,sBAAsB,CAAC;IA8FzF;;;;;;;;;;;OAWG;IACG,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAgDzF;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,GAAE,wBAA6B,GAAG,iBAAiB,CAEjG"}
|
|
@@ -54,6 +54,7 @@ import { dirname, join, resolve } from 'node:path';
|
|
|
54
54
|
import { createTarGzipArchiveSource, digestInstalledContent, discoverExtension, ExtensionStore, installDependencyGraph, ManagementError, stagedInstall, stagedInstallFromDirectory, } from '@try-works/tool-mode-extension-sdk';
|
|
55
55
|
import { createFirstPartyDependencyGraph, createRegistryDependencyGraph, createRegistrySession, DEFAULT_REGISTRY_URL, MAX_DEPENDENCY_ARCHIVE_BYTES, RegistryError, resolveFirstPartyDependency, satisfiesRegistryRange, } from "./extension-dependencies.js";
|
|
56
56
|
import { createHttpSource } from "./http-acquisition.js";
|
|
57
|
+
import { assetSourceUnavailableReason, firstUnavailableAssetSource, } from "./prepared-assets.js";
|
|
57
58
|
/**
|
|
58
59
|
* The default dependency-graph depth bound for registry installs (task-116).
|
|
59
60
|
*
|
|
@@ -892,7 +893,15 @@ export class ExtensionsService {
|
|
|
892
893
|
requirements.push(requirement('assets', false, `not installed; ${input.facts.models.join(', ')} need${input.facts.models.length === 1 ? 's' : ''} model assets prepared after installation`, 'install'));
|
|
893
894
|
}
|
|
894
895
|
else if (blockers.length > 0) {
|
|
895
|
-
|
|
896
|
+
/**
|
|
897
|
+
* A lock whose assets carry prose sources (no URL) cannot be prepared by this
|
|
898
|
+
* host. Report action `none` so the page does not offer Prepare as if it could
|
|
899
|
+
* succeed; the reason names the artifact and the documented export.
|
|
900
|
+
*/
|
|
901
|
+
const unavailable = this.#unavailableAssetSource(input.id);
|
|
902
|
+
requirements.push(unavailable === undefined
|
|
903
|
+
? requirement('assets', false, `activation blocked: ${blockers.join('; ')}`, 'prepare')
|
|
904
|
+
: requirement('assets', false, `[ASSET_SOURCE_UNAVAILABLE] ${assetSourceUnavailableReason(unavailable.assetId, unavailable.source)}`, 'none'));
|
|
896
905
|
}
|
|
897
906
|
else {
|
|
898
907
|
requirements.push(requirement('assets', true, `every declared model deployment is prepared or callable (${input.facts.models.join(', ')})`));
|
|
@@ -1008,6 +1017,27 @@ export class ExtensionsService {
|
|
|
1008
1017
|
return requirement('harness-model', false, status.reason
|
|
1009
1018
|
?? 'no harness model provider is configured, so declarative extensions cannot be served; set config.harnessModel to a runnable model', status.action ?? 'config');
|
|
1010
1019
|
}
|
|
1020
|
+
/**
|
|
1021
|
+
* The first planned asset with neither an http(s) source nor cached bytes.
|
|
1022
|
+
*
|
|
1023
|
+
* A prose lock source (laya's "split export of the pinned checkpoint") is not a
|
|
1024
|
+
* download location; preparation must refuse before any transfer. A cache hit is
|
|
1025
|
+
* still a source because acquisition verifies the cached digest.
|
|
1026
|
+
* @param extensionId - the installed extension.
|
|
1027
|
+
* @returns the unavailable asset, or undefined when every source is reachable.
|
|
1028
|
+
*/
|
|
1029
|
+
#unavailableAssetSource(extensionId) {
|
|
1030
|
+
const surface = this.#options.prepareSurface?.();
|
|
1031
|
+
if (surface === undefined)
|
|
1032
|
+
return undefined;
|
|
1033
|
+
try {
|
|
1034
|
+
const plan = surface.plan(extensionId);
|
|
1035
|
+
return firstUnavailableAssetSource(plan.assets.map(asset => ({ assetId: asset.assetId, source: asset.source, digest: asset.digest })), surface.registry.cacheDirectory);
|
|
1036
|
+
}
|
|
1037
|
+
catch {
|
|
1038
|
+
return undefined;
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1011
1041
|
/** The executable requirement for an installed, not-yet-callable model deployment. */
|
|
1012
1042
|
#executableRequirement(extensionId) {
|
|
1013
1043
|
const surface = this.#options.prepareSurface?.();
|
|
@@ -1755,6 +1785,14 @@ export class ExtensionsService {
|
|
|
1755
1785
|
throw new ExtensionsServiceError('extension-preparation-failed', `the preparation plan for ${extensionId} could not be resolved: ${messageOf(error)}`, { cause: error });
|
|
1756
1786
|
}
|
|
1757
1787
|
const lifecycle = this.#lifecycle();
|
|
1788
|
+
/**
|
|
1789
|
+
* A prose source (no URL, no cached bytes) is refused BEFORE the lifecycle
|
|
1790
|
+
* probe or any transfer: a URL-parse failure after waiting is the wrong answer.
|
|
1791
|
+
*/
|
|
1792
|
+
const unavailable = firstUnavailableAssetSource(plan.assets.map(asset => ({ assetId: asset.assetId, source: asset.source, digest: asset.digest })), surface.registry.cacheDirectory);
|
|
1793
|
+
if (unavailable !== undefined) {
|
|
1794
|
+
throw new ExtensionsServiceError('extension-asset-source-unavailable', `[ASSET_SOURCE_UNAVAILABLE] ${assetSourceUnavailableReason(unavailable.assetId, unavailable.source)}`);
|
|
1795
|
+
}
|
|
1758
1796
|
if (lifecycle !== undefined && lifecycle.stateOf(extensionId) === undefined) {
|
|
1759
1797
|
await this.#recordPreparationBlocker(lifecycle, extensionId, record.version);
|
|
1760
1798
|
}
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAMxC,OAAO,EAAqB,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAMxC,OAAO,EAAqB,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAcvE,OAAO,EAAoH,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAC5K,OAAO,EAAe,KAAK,WAAW,EAAuB,MAAM,8BAA8B,CAAA;AAuCjG,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAuB/D,eAAO,MAAM,IAAI,gBAAgB,CAAA;AACjC,eAAO,MAAM,MAAM,UAAY,CAAA;AAE/B;;;GAGG;AACH,eACA,MAAM,qBAAqB,MAAM,CAAA;AAajC,4BAA4B;AAC5B,MAAM,WAAW,MAAM;IACrB,4EAA4E;IAC5E,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,oEAAoE;IACpE,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;;;;;OAQG;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H,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACtE,OAAO,EACL,SAAS,EACT,aAAa,EACb,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,WAAW,EACX,mBAAmB,EACnB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,QAAQ,EACb,KAAK,gBAAgB,GACtB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAA;AACxF,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,gBAAgB,EAChB,UAAU,EACV,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,UAAU,EACV,KAAK,cAAc,EACnB,KAAK,UAAU,GAChB,MAAM,YAAY,CAAA;AACnB,YAAY,EACV,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EACV,UAAU,EACV,cAAc,EACd,UAAU,EACV,aAAa,EACb,cAAc,EACd,cAAc,GACf,MAAM,YAAY,CAAA"}
|
package/lib/index.js
CHANGED
|
@@ -18,10 +18,11 @@ import { loadCatalog } from "./catalog.js";
|
|
|
18
18
|
import { resolveCapability } from "./capability.js";
|
|
19
19
|
import { createAdapter } from "./adapters/index.js";
|
|
20
20
|
import { registerModelTool } from "./registrar.js";
|
|
21
|
-
import { registerContractTool } from "./bindings.js";
|
|
21
|
+
import { registerContractTool, registerContractImplementationTool } from "./bindings.js";
|
|
22
22
|
import { mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
|
|
23
23
|
import { dirname, join, resolve } from 'node:path';
|
|
24
24
|
import { createContributionRegistrar } from "./extension-registrar.js";
|
|
25
|
+
import { createInvocationAuthority } from "./authority.js";
|
|
25
26
|
import { createExternalGrantContext, createProgramRunner, externalRefusal, serveProgram, TOOL_MODE_RUN_CONTRACT, PTC_SERVICE } from "./tool-mode-run.js";
|
|
26
27
|
import { buildDiagnostics } from "./diagnostics.js";
|
|
27
28
|
import { CAPTURE_PATH } from "./capture-path.js";
|
|
@@ -30,7 +31,7 @@ import { createFileCredentialStore, defaultCredentialStoreFile } from "./mcp/cre
|
|
|
30
31
|
import { buildHarnessLlmProvider, discoverDefaultHarnessModel, resolveRunnableHarnessModel } from "./harness-llm.js";
|
|
31
32
|
import { parseRecipe } from '@try-works/tool-mode-recipes';
|
|
32
33
|
import { createManagedWorkerRegistry } from "./managed-workers.js";
|
|
33
|
-
import { createDispatch, describeDispatchFailure, resolveImplementation } from "./extension-dispatch.js";
|
|
34
|
+
import { createDispatch, createDispatchForContract, describeDispatchFailure, resolveImplementation } from "./extension-dispatch.js";
|
|
34
35
|
import { captureToolSchemaSnapshot, describePlanningRejections, hasPlanningInputShape, offerToolsFromSnapshot, PLANNING_EXCLUDED_TOOLS, PLANNING_TOOL_INPUT_SCHEMA, PLANNING_TOOL_NAME, recheckProposals, } from "./planning.js";
|
|
35
36
|
import { discoverExtension, loadExtensionModule, resolveDeclarativeImplementations, resolveExtensionEntry } from '@try-works/tool-mode-extension-sdk';
|
|
36
37
|
import { ExtensionStore, ExtensionLifecycle } from '@try-works/tool-mode-extension-sdk';
|
|
@@ -361,6 +362,7 @@ export async function apply(ctx, config = {}) {
|
|
|
361
362
|
: undefined;
|
|
362
363
|
const catalogueDeferred = new Set();
|
|
363
364
|
const extensionOwnsToolName = (toolName) => {
|
|
365
|
+
console.log(`TEMP-DIAG probe(${toolName}) store=${extensionStore !== undefined}`);
|
|
364
366
|
if (extensionStore === undefined)
|
|
365
367
|
return false;
|
|
366
368
|
try {
|
|
@@ -375,9 +377,19 @@ export async function apply(ctx, config = {}) {
|
|
|
375
377
|
const discovery = discoverExtension(record.installPath);
|
|
376
378
|
if (discovery.manifest.tools.some(tool => tool.name === toolName))
|
|
377
379
|
return true;
|
|
380
|
+
// TASK-121: an implementation-only extension owns the STANDARD tool
|
|
381
|
+
// name of each implementation's contract (text.embed -> text_embed),
|
|
382
|
+
// exactly as the registrar registers it.
|
|
383
|
+
const implementationNames = (discovery.manifest.implementations ?? [])
|
|
384
|
+
.map(implementation => STANDARD_CONTRACTS.find(contract => contract.contract === implementation.contractId)?.toolName)
|
|
385
|
+
.filter((name) => name !== undefined);
|
|
386
|
+
if (implementationNames.includes(toolName))
|
|
387
|
+
return true;
|
|
378
388
|
}
|
|
379
389
|
}
|
|
380
|
-
catch {
|
|
390
|
+
catch (error) {
|
|
391
|
+
// TEMP-DIAG task-123
|
|
392
|
+
console.log(`TEMP-DIAG extensionOwnsToolName(${toolName}) threw: ${error instanceof Error ? error.message : String(error)}`);
|
|
381
393
|
// A broken package cannot own a tool name; the catalogue keeps it.
|
|
382
394
|
return false;
|
|
383
395
|
}
|
|
@@ -1175,7 +1187,7 @@ export async function apply(ctx, config = {}) {
|
|
|
1175
1187
|
toolName = existing.toolName;
|
|
1176
1188
|
dispose = () => { };
|
|
1177
1189
|
}
|
|
1178
|
-
else if (extensionOwnsToolName(entry.tool.name)) {
|
|
1190
|
+
else if (extensionOwnsToolName(entry.tool.name) || extensionOwnsToolName(contractById.get(entry.contract)?.toolName ?? '')) {
|
|
1179
1191
|
/**
|
|
1180
1192
|
* TASK-117: an installed extension OWNS this tool name — its
|
|
1181
1193
|
* activation registers it, so the catalogue registration is SKIPPED
|
|
@@ -2671,7 +2683,26 @@ export async function apply(ctx, config = {}) {
|
|
|
2671
2683
|
},
|
|
2672
2684
|
// The manifest is resolved per call: a deactivated+reactivated extension's
|
|
2673
2685
|
// discovery must be fresh, not a startup snapshot.
|
|
2674
|
-
|
|
2686
|
+
// TASK-123: the invocation context carries the FULL host-granted surface
|
|
2687
|
+
// the SDK contract documents (InvocationContextV1): the invocation id,
|
|
2688
|
+
// the signal, the resource limits, and the path authority broker — the
|
|
2689
|
+
// SAME authority the catalogue/contract path builds, so an extension
|
|
2690
|
+
// that reads a caller-supplied file path asks the host exactly like the
|
|
2691
|
+
// catalogue adapter does. The broker is always present; a composition
|
|
2692
|
+
// without a grant fails with a NAMED error, never undefined.
|
|
2693
|
+
contextFor: (implementationId, signal) => {
|
|
2694
|
+
if (host.grant === undefined) {
|
|
2695
|
+
throw new Error('path access denied: the host has no configured grant, so the path authority broker is unavailable');
|
|
2696
|
+
}
|
|
2697
|
+
const authority = createInvocationAuthority(host.grant, host.callerKind);
|
|
2698
|
+
return {
|
|
2699
|
+
implementationId,
|
|
2700
|
+
signal,
|
|
2701
|
+
invocationId: `inv_${Date.now().toString(36)}_${Math.floor(Math.random() * 1e6).toString(36)}`,
|
|
2702
|
+
limits: authority.limits,
|
|
2703
|
+
resolvePath: (candidate) => authority.resolvePath(candidate),
|
|
2704
|
+
};
|
|
2705
|
+
},
|
|
2675
2706
|
};
|
|
2676
2707
|
}
|
|
2677
2708
|
/**
|
|
@@ -3065,6 +3096,50 @@ export async function apply(ctx, config = {}) {
|
|
|
3065
3096
|
* deployment with no harness composition fails loudly (the narrow rollback
|
|
3066
3097
|
* quarantines it) instead of silently registering nothing.
|
|
3067
3098
|
*/
|
|
3099
|
+
/**
|
|
3100
|
+
* TASK-121: the STANDARD contract tool for an implementation-only
|
|
3101
|
+
* MODULE extension. The contract id maps to the standard tool name
|
|
3102
|
+
* (text.embed -> text_embed — never invented per extension), and the
|
|
3103
|
+
* tool's schemas come from the contract definition itself. The
|
|
3104
|
+
* extension owns the name while active (task-117's probe reads the
|
|
3105
|
+
* implementations' standard names too); the deactivation withdraws it.
|
|
3106
|
+
*/
|
|
3107
|
+
registerContractImplementation: (contribution) => {
|
|
3108
|
+
const record = store.listInstalled().value.find(candidate => candidate.extensionId === contribution.extensionId);
|
|
3109
|
+
if (record === undefined)
|
|
3110
|
+
return undefined;
|
|
3111
|
+
const discovery = discoverExtension(record.installPath);
|
|
3112
|
+
// DECLARATIVE packages are served by the recipe path below, never by
|
|
3113
|
+
// this standard-contract path (their contracts may share standard
|
|
3114
|
+
// names, e.g. text.title, but their execution is the recipe broker).
|
|
3115
|
+
if (discovery.manifest.execution?.kind === 'declarative')
|
|
3116
|
+
return undefined;
|
|
3117
|
+
const contract = STANDARD_CONTRACTS.find(candidate => candidate.contract === contribution.contractId);
|
|
3118
|
+
if (contract === undefined)
|
|
3119
|
+
return undefined;
|
|
3120
|
+
const toolName = contract.toolName;
|
|
3121
|
+
// No duplicate: the extension's own manifest tool (when it declares
|
|
3122
|
+
// one) already serves the contract under the standard name.
|
|
3123
|
+
if (extensionToolOwners.get(toolName) === contribution.extensionId)
|
|
3124
|
+
return () => { };
|
|
3125
|
+
const environment = environmentFor(contribution.extensionId);
|
|
3126
|
+
const manifestImplementation = environment.getManifest().implementations.find(candidate => candidate.contractId === contribution.contractId);
|
|
3127
|
+
const registered = registerContractImplementationTool(ctx, contract, host, async (args, signal) => {
|
|
3128
|
+
const dispatch = await createDispatchForContract(environment, contribution.contractId);
|
|
3129
|
+
if (!dispatch.ok)
|
|
3130
|
+
throw new Error(describeDispatchFailure(dispatch.failure));
|
|
3131
|
+
return dispatch.execute(args, signal);
|
|
3132
|
+
}, {
|
|
3133
|
+
id: contribution.implementationId,
|
|
3134
|
+
extensionId: contribution.extensionId,
|
|
3135
|
+
modelId: manifestImplementation?.modelId ?? contribution.implementationId,
|
|
3136
|
+
});
|
|
3137
|
+
extensionToolOwners.set(toolName, contribution.extensionId);
|
|
3138
|
+
return () => {
|
|
3139
|
+
extensionToolOwners.delete(toolName);
|
|
3140
|
+
registered.dispose();
|
|
3141
|
+
};
|
|
3142
|
+
},
|
|
3068
3143
|
registerDeclarative: (contribution) => {
|
|
3069
3144
|
const record = store.listInstalled().value.find(candidate => candidate.extensionId === contribution.extensionId);
|
|
3070
3145
|
if (record === undefined)
|
package/lib/prepared-assets.d.ts
CHANGED
|
@@ -110,8 +110,44 @@ export declare function identityFor(extensionId: string, modelId: string, lock:
|
|
|
110
110
|
export declare function plannedAssets(lock: ParsedAssetLock, assetSetId: string): readonly PlannedAsset[];
|
|
111
111
|
/** The group map for one asset set, keyed by group id. */
|
|
112
112
|
export declare function lockGroups(lock: ParsedAssetLock, assetSetId: string): readonly LockGroup[];
|
|
113
|
+
/**
|
|
114
|
+
* Whether one lock `source` is a resolvable http(s) download URL.
|
|
115
|
+
* @param source - the lock's source string.
|
|
116
|
+
* @returns whether a transfer can be planned for it.
|
|
117
|
+
*/
|
|
118
|
+
export declare function isFetchableAssetSource(source: string): boolean;
|
|
119
|
+
/** The minimum an asset needs for a source check. */
|
|
120
|
+
export interface AssetSourceProbe {
|
|
121
|
+
readonly assetId: string;
|
|
122
|
+
readonly source: string;
|
|
123
|
+
readonly digest: string;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* The operator-facing reason an asset has no transferable location.
|
|
127
|
+
*
|
|
128
|
+
* A prose `source` (e.g. "the split export of the pinned checkpoint") is not a
|
|
129
|
+
* download URL; the bytes must be produced by the documented export and placed in
|
|
130
|
+
* the prepared-assets cache (file name = the pinned digest) before a transfer-free
|
|
131
|
+
* preparation can succeed.
|
|
132
|
+
* @param assetId - the lock asset id.
|
|
133
|
+
* @param source - the prose/non-URL source.
|
|
134
|
+
* @returns the exact refusal reason.
|
|
135
|
+
*/
|
|
136
|
+
export declare function assetSourceUnavailableReason(assetId: string, source: string): string;
|
|
137
|
+
/**
|
|
138
|
+
* The first planned asset with neither an http(s) URL nor bytes already in the cache.
|
|
139
|
+
*
|
|
140
|
+
* A cache hit is a legitimate source: a later acquisition still verifies the blob
|
|
141
|
+
* against the pinned digest, so pre-seeded artifacts are verified rather than trusted.
|
|
142
|
+
* @param assets - the planned assets to check.
|
|
143
|
+
* @param cacheRoot - the content-addressed cache root (blob filename = digest).
|
|
144
|
+
* @returns the first unavailable asset, or undefined when every asset is reachable.
|
|
145
|
+
*/
|
|
146
|
+
export declare function firstUnavailableAssetSource(assets: readonly AssetSourceProbe[], cacheRoot: string): AssetSourceProbe | undefined;
|
|
113
147
|
/** The host-side prepared-assets registry (session-scoped). */
|
|
114
148
|
export interface PreparedAssetRegistry {
|
|
149
|
+
/** The content-addressed cache root (blob filename = the pinned digest). */
|
|
150
|
+
readonly cacheDirectory: string;
|
|
115
151
|
/** The plan the last extensions-prepare-plan built, per extension id. */
|
|
116
152
|
plans(): ReadonlyMap<string, PreparationPlan>;
|
|
117
153
|
/** The acquired group map per extension id (PreparedAssetMapV1 shapes). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepared-assets.d.ts","sourceRoot":"","sources":["../src/prepared-assets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAMH,OAAO,EAAgB,KAAK,iBAAiB,EAAyB,MAAM,wBAAwB,CAAA;AACpG,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAEpG,iEAAiE;AACjE,UAAU,SAAS;IACjB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAA;CAC7B;AAED,6DAA6D;AAC7D,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,CAAA;CACtC;AAED,8DAA8D;AAC9D,UAAU,YAAY;IACpB,QAAQ,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,CAAA;IACrC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,OAAO,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;CAClE;AAED,+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C,8EAA8E;IAC9E,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,6DAA6D;IAC7D,QAAQ,CAAC,aAAa,CAAC,EAAE,iBAAiB,CAAA;CAC3C;AAED;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC,wEAAwE;IACxE,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,eAAe,CAAA;IAC1C,kFAAkF;IAClF,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,SAAS,EAAE,CAAA;IACxD,+CAA+C;IAC/C,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAAA;IACvC,yDAAyD;IACzD,OAAO,CACL,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE;QAAE,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;QAAC,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;KAAE,GAC/G,OAAO,CAAC,kBAAkB,CAAC,CAAA;IAC9B,kEAAkE;IAClE,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAAA;IAC9D,mDAAmD;IACnD,QAAQ,CAAC,QAAQ,EAAE,qBAAqB,CAAA;CACzC;AASD;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,4BAA4B,GAAG,qBAAqB,CAiIxG"}
|
package/lib/prepared-assets.js
CHANGED
|
@@ -127,6 +127,47 @@ export function lockGroups(lock, assetSetId) {
|
|
|
127
127
|
throw new Error(`the lock declares no asset set "${assetSetId}"`);
|
|
128
128
|
return set.groups;
|
|
129
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* Whether one lock `source` is a resolvable http(s) download URL.
|
|
132
|
+
* @param source - the lock's source string.
|
|
133
|
+
* @returns whether a transfer can be planned for it.
|
|
134
|
+
*/
|
|
135
|
+
export function isFetchableAssetSource(source) {
|
|
136
|
+
/**
|
|
137
|
+
* A source is fetchable when it has a URI SCHEME at all: https/http, a `file:`
|
|
138
|
+
* deployment lock, or the injected-source test scheme (`fixture:`). A PROSE
|
|
139
|
+
* description ("the split export of the pinned checkpoint") has no scheme and
|
|
140
|
+
* cannot plan a transfer.
|
|
141
|
+
*/
|
|
142
|
+
return /^[a-z][a-z0-9+.-]*:/i.test(source.trim());
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* The operator-facing reason an asset has no transferable location.
|
|
146
|
+
*
|
|
147
|
+
* A prose `source` (e.g. "the split export of the pinned checkpoint") is not a
|
|
148
|
+
* download URL; the bytes must be produced by the documented export and placed in
|
|
149
|
+
* the prepared-assets cache (file name = the pinned digest) before a transfer-free
|
|
150
|
+
* preparation can succeed.
|
|
151
|
+
* @param assetId - the lock asset id.
|
|
152
|
+
* @param source - the prose/non-URL source.
|
|
153
|
+
* @returns the exact refusal reason.
|
|
154
|
+
*/
|
|
155
|
+
export function assetSourceUnavailableReason(assetId, source) {
|
|
156
|
+
return `the asset lock declares no download URL for ${assetId}: its source is ${JSON.stringify(source)}; `
|
|
157
|
+
+ 'the artifacts must be produced by the documented export and placed in the prepared-assets cache';
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* The first planned asset with neither an http(s) URL nor bytes already in the cache.
|
|
161
|
+
*
|
|
162
|
+
* A cache hit is a legitimate source: a later acquisition still verifies the blob
|
|
163
|
+
* against the pinned digest, so pre-seeded artifacts are verified rather than trusted.
|
|
164
|
+
* @param assets - the planned assets to check.
|
|
165
|
+
* @param cacheRoot - the content-addressed cache root (blob filename = digest).
|
|
166
|
+
* @returns the first unavailable asset, or undefined when every asset is reachable.
|
|
167
|
+
*/
|
|
168
|
+
export function firstUnavailableAssetSource(assets, cacheRoot) {
|
|
169
|
+
return assets.find(asset => !isFetchableAssetSource(asset.source) && !existsSync(join(cacheRoot, asset.digest)));
|
|
170
|
+
}
|
|
130
171
|
/** The filesystem store acquisition needs, over node:fs. */
|
|
131
172
|
function fsStore() {
|
|
132
173
|
return {
|
|
@@ -175,6 +216,7 @@ export function createPreparedAssetRegistry(options) {
|
|
|
175
216
|
// The content-addressed blob pool, shared across extensions (RES-03: two
|
|
176
217
|
// owners share one set of bytes).
|
|
177
218
|
return {
|
|
219
|
+
cacheDirectory: cacheRoot,
|
|
178
220
|
plans() {
|
|
179
221
|
return new Map([...held.entries()].map(([extensionId, preparation]) => [extensionId, preparation.plan]));
|
|
180
222
|
},
|
|
@@ -215,6 +257,17 @@ export function createPreparedAssetRegistry(options) {
|
|
|
215
257
|
return held.get(extensionId)?.groups ?? [];
|
|
216
258
|
},
|
|
217
259
|
async prepare(extensionId, plan, groups, options) {
|
|
260
|
+
/**
|
|
261
|
+
* A lock whose assets carry PROSE sources (no URL) has no transferable
|
|
262
|
+
* location; refuse BEFORE any acquisition, naming the asset, instead of
|
|
263
|
+
* surfacing a URL-parse error from deep inside the transport. Artifacts
|
|
264
|
+
* already materialized in the content-addressed cache are a legitimate
|
|
265
|
+
* source (a later acquisition still verifies their digest).
|
|
266
|
+
*/
|
|
267
|
+
const unavailable = firstUnavailableAssetSource(groups.flatMap(group => group.assets.map(asset => ({ assetId: `${group.id}/${asset.id}`, source: asset.source, digest: asset.digest }))), cacheRoot);
|
|
268
|
+
if (unavailable !== undefined) {
|
|
269
|
+
return { ok: false, reason: assetSourceUnavailableReason(unavailable.assetId, unavailable.source) };
|
|
270
|
+
}
|
|
218
271
|
if (!options.allowExecutable && plan.requiresExecutableApproval) {
|
|
219
272
|
return {
|
|
220
273
|
ok: false,
|