@try-works/extension-laya 0.0.0-stage → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +38 -2
  2. package/lib/index.d.ts +18 -0
  3. package/lib/index.js +172 -0
  4. package/lib/index.js.map +1 -0
  5. package/lib/pure.d.ts +35 -0
  6. package/lib/pure.js +71 -0
  7. package/lib/pure.js.map +1 -0
  8. package/models.lock.json +63 -0
  9. package/package.json +39 -4
  10. package/schema/decision-choose.input.json +22 -0
  11. package/schema/decision-choose.output.json +20 -0
  12. package/schema/decision-score.input.json +18 -0
  13. package/schema/decision-score.output.json +18 -0
  14. package/schema/decision-test.input.json +10 -0
  15. package/schema/decision-test.output.json +18 -0
  16. package/tool-mode.extension.json +87 -0
  17. package/vendor/LICENSE.laya-ts +176 -0
  18. package/vendor/laya-ts/agent.d.ts +216 -0
  19. package/vendor/laya-ts/agent.js +631 -0
  20. package/vendor/laya-ts/common.d.ts +167 -0
  21. package/vendor/laya-ts/common.js +478 -0
  22. package/vendor/laya-ts/dx.d.ts +17 -0
  23. package/vendor/laya-ts/dx.js +46 -0
  24. package/vendor/laya-ts/email.d.ts +2 -0
  25. package/vendor/laya-ts/email.js +184 -0
  26. package/vendor/laya-ts/hooks.d.ts +134 -0
  27. package/vendor/laya-ts/hooks.js +379 -0
  28. package/vendor/laya-ts/index.d.ts +22 -0
  29. package/vendor/laya-ts/index.js +13 -0
  30. package/vendor/laya-ts/lang.d.ts +24 -0
  31. package/vendor/laya-ts/lang.js +590 -0
  32. package/vendor/laya-ts/presets.d.ts +5 -0
  33. package/vendor/laya-ts/presets.js +175 -0
  34. package/vendor/laya-ts/providers.d.ts +67 -0
  35. package/vendor/laya-ts/providers.js +668 -0
  36. package/vendor/laya-ts/router.d.ts +186 -0
  37. package/vendor/laya-ts/router.js +757 -0
  38. package/vendor/laya-ts/shortlist.d.ts +65 -0
  39. package/vendor/laya-ts/shortlist.js +407 -0
  40. package/vendor/laya-ts/structured.d.ts +89 -0
  41. package/vendor/laya-ts/structured.js +256 -0
  42. package/vendor/laya-ts/tokenizer.d.ts +66 -0
  43. package/vendor/laya-ts/tokenizer.js +482 -0
package/README.md CHANGED
@@ -1,3 +1,39 @@
1
- # Temporary Holding Version
1
+ # extension-laya — the Laya decision family (H5)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ `decision_choose`, `decision_test` and `decision_score` over the pinned
4
+ multilingual Laya checkpoint, running through the **vendored** laya-ts
5
+ runtime.
6
+
7
+ ## Vendored runtime + attribution
8
+
9
+ `vendor/laya-ts/` is the BUILT `dist/` of the upstream `laya-ts` package,
10
+ vendored verbatim (26 files: 13 modules + their declarations) from
11
+
12
+ - **github.com/NandhaKishorM/laya**, commit `c73908d96ff73c0062c340a11bf7c54ec7d8bc4d`
13
+ (tag `v0.4.6`), Apache License 2.0 — the license text is vendored at
14
+ `vendor/LICENSE.laya-ts`.
15
+
16
+ No unpublished npm dependency is required: the runtime ships inside this
17
+ package. The vendored code is upstream's built output, not a fork; any change
18
+ to it must be a new upstream pin recorded here.
19
+
20
+ ## Honesty posture (DEC-08)
21
+
22
+ Every confidence this extension returns is the runtime's **uncalibrated**
23
+ probability mass, marked `calibrated: false` in every answer. The upstream
24
+ model card ships uncalibrated logits with a clamping warning; DEC-08 stays
25
+ NOT_RUN until a real calibration corpus measures it.
26
+
27
+ ## Artifacts
28
+
29
+ `models.lock.json` pins the six-artifact split ONNX export (encoder + head
30
+ with external data, the tokenizer and the RL-agent config) by SHA-256; the
31
+ host acquires and verifies them through extensions-prepare, and the vendored
32
+ runtime re-verifies the digests at load (`createNodeProvider` with
33
+ `expectedSha256`).
34
+
35
+ ## Qualification
36
+
37
+ `node scripts/qualify-laya.mjs` (env `LAYA_MODEL_DIR` overrides the default
38
+ `E:\tmp\laya-investigation\laya\model-ml`) verifies the six digests and runs
39
+ real decision calls, writing `docs/tool-mode/qualification/laya.json`.
package/lib/index.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ /**
2
+ * The Laya decision-family extension (H5): decision_choose, decision_test and
3
+ * decision_score over the pinned multilingual Laya checkpoint, running through
4
+ * the VENDORED laya-ts runtime (Apache-2.0, pinned upstream commit
5
+ * c73908d96ff73c0062c340a11bf7c54ec7d8bc4d, tag v0.4.6 — see
6
+ * vendor/laya-ts + README.md for the attribution).
7
+ *
8
+ * Honesty posture (DEC-08): every confidence returned is the runtime's
9
+ * uncalibrated probability mass, marked `calibrated: false`. The upstream
10
+ * model card ships uncalibrated logits with a clamping warning; this extension
11
+ * never presents them as calibrated probabilities.
12
+ */
13
+ import type { ExtensionContextV1, ExtensionInstanceV1 } from '@try-works/tool-mode-extension-sdk';
14
+ declare const _default: {
15
+ apiVersion: number;
16
+ create(context: ExtensionContextV1): Promise<ExtensionInstanceV1>;
17
+ };
18
+ export default _default;
package/lib/index.js ADDED
@@ -0,0 +1,172 @@
1
+ /**
2
+ * The Laya decision-family extension (H5): decision_choose, decision_test and
3
+ * decision_score over the pinned multilingual Laya checkpoint, running through
4
+ * the VENDORED laya-ts runtime (Apache-2.0, pinned upstream commit
5
+ * c73908d96ff73c0062c340a11bf7c54ec7d8bc4d, tag v0.4.6 — see
6
+ * vendor/laya-ts + README.md for the attribution).
7
+ *
8
+ * Honesty posture (DEC-08): every confidence returned is the runtime's
9
+ * uncalibrated probability mass, marked `calibrated: false`. The upstream
10
+ * model card ships uncalibrated logits with a clamping warning; this extension
11
+ * never presents them as calibrated probabilities.
12
+ */
13
+ import { Agent, createNodeProvider, decide } from '../vendor/laya-ts/index.js';
14
+ import { decideFromLogits, MAX_OPTIONS, MAX_SCORE_LEVELS, validateOptions } from './pure.js';
15
+ const MODEL_ID = 'laya';
16
+ const ALL_GROUPS = ['text-backbone', 'decision-head', 'tokenizer-config'];
17
+ /** The six pinned digests, mirrored from models.lock.json for the load-time check. */
18
+ const EXPECTED_SHA256 = {
19
+ 'encoder.onnx': 'A774C5C634B99D1A4CED21ACBF11B9617A5CD55C7C7957BD52480B17D95A97F4',
20
+ 'encoder.onnx.data': 'F1E49A027352064D72831863456BE6160748854296BFF8332DF14130DBF79834',
21
+ 'head.onnx': '7F6B9AC15D5FDF9EEBB352E66BDD3CE799D32885F1446014D268D8C53207858B',
22
+ 'head.onnx.data': '0292A4EB478C2C3EC0B6555B4A4093BC802E965654D7AEB4AC22907A17F261D3',
23
+ 'tokenizer.json': '609D8F4C067CD3950F88594C5A802616CEA245823836EF5848EE4FC40AAB5B6F',
24
+ 'rl_agent_config.json': '25061739243B617AD88D1219BA6F8A9C86C5881CA28DF024FA2D9B3B2FCC30C6',
25
+ };
26
+ function renderAnswer(raw) {
27
+ const answer = (raw.answers ?? {});
28
+ const one = Object.values(answer)[0];
29
+ const probs = (one?.probabilities ?? {});
30
+ const act = one?.action;
31
+ return {
32
+ ...(one?.type === 'choice' ? { chosen: one.choice ?? null } : {}),
33
+ ...(one?.type === 'score' ? { score: one.score ?? null } : {}),
34
+ confidence: Number(one?.confidence ?? one?.answer_confidence ?? 0),
35
+ answer_confidence: Number(one?.answer_confidence ?? one?.confidence ?? 0),
36
+ calibrated: false,
37
+ probabilities: probs,
38
+ abstained: one?.choice === null && one?.score === null,
39
+ ...act === undefined ? {} : { action: { act_probability: Number(act.act_probability) } },
40
+ };
41
+ }
42
+ function createLayaProvider(context) {
43
+ let disposed = false;
44
+ let sessionPromise;
45
+ return {
46
+ async inspect(signal) {
47
+ if (signal.aborted)
48
+ throw new Error('aborted');
49
+ return {
50
+ readiness: sessionPromise === undefined ? 'prepared-cold' : 'ready',
51
+ features: ['decision-family'],
52
+ missing: [],
53
+ ...sessionPromise === undefined
54
+ ? { reason: 'the Laya decision checkpoint is prepared but cold; it loads on first use with the host-verified asset groups' }
55
+ : {},
56
+ };
57
+ },
58
+ async load(request) {
59
+ if (request.signal.aborted)
60
+ throw new Error('aborted');
61
+ const group = request.assets.get('text-backbone');
62
+ if (group === undefined) {
63
+ throw new Error('the "text-backbone" asset group was not prepared, so the decision family cannot run (MOD-02). '
64
+ + 'The host prepares the six pinned artifacts and verifies every SHA-256 before load');
65
+ }
66
+ void ALL_GROUPS;
67
+ sessionPromise ??= (async () => {
68
+ const provider = await createNodeProvider(group.path, {
69
+ expectedSha256: EXPECTED_SHA256,
70
+ device: 'cpu',
71
+ });
72
+ const agent = new Agent({ provider });
73
+ return {
74
+ agent,
75
+ dispose: async () => {
76
+ // The vendored provider owns the sessions; the extension's dispose
77
+ // releases the reference — the runtime's sessions are GC'd with it.
78
+ void provider;
79
+ },
80
+ };
81
+ })();
82
+ await sessionPromise;
83
+ },
84
+ async invoke({ implementationId, input, context: invocation }) {
85
+ if (invocation.signal.aborted)
86
+ throw new Error('aborted');
87
+ if (disposed)
88
+ throw new Error('the provider has been disposed');
89
+ const session = await sessionPromise;
90
+ if (session === undefined)
91
+ throw new Error('the Laya checkpoint is not prepared: load() must be called (MOD-02)');
92
+ const prompt = input.prompt;
93
+ if (typeof prompt !== 'string' || prompt.length === 0 || prompt.length > 4096) {
94
+ throw new Error('"prompt" must be a non-empty string of at most 4096 characters');
95
+ }
96
+ const allowAbstain = input.allow_abstain !== false;
97
+ void allowAbstain; // The runtime's act gate is reported honestly; no threshold is invented.
98
+ let questionType;
99
+ let criteria;
100
+ if (implementationId === 'laya-onnx-decision-test') {
101
+ questionType = 'choice';
102
+ criteria = { yes: null, no: null };
103
+ }
104
+ else if (implementationId === 'laya-onnx-decision-choose') {
105
+ const options = validateOptions((input.options ?? []), MAX_OPTIONS);
106
+ questionType = 'choice';
107
+ criteria = Object.fromEntries(options.map(option => [option, null]));
108
+ }
109
+ else if (implementationId === 'laya-onnx-decision-score') {
110
+ const levels = validateOptions((input.levels ?? []), MAX_SCORE_LEVELS);
111
+ questionType = 'score';
112
+ // The vendored runtime takes a score question's criteria as a LIST of
113
+ // level descriptions, index 0 first.
114
+ criteria = [...levels];
115
+ }
116
+ else {
117
+ throw new Error(`this extension implements the decision family, not ${JSON.stringify(implementationId)}`);
118
+ }
119
+ const result = await decide(session.agent, prompt, null, { questions: { answer: { type: questionType, instructions: prompt, criteria } } });
120
+ const values = result;
121
+ // Without returnDetails, decide() returns the answers map itself: the
122
+ // question's answer sits at result.answer (the question id).
123
+ const answer = (values.answer ?? Object.values(values.answers ?? {})[0] ?? {});
124
+ if (answer === undefined || Object.keys(answer).length === 0)
125
+ throw new Error('the checkpoint produced no decision');
126
+ const probs = (answer.probabilities ?? {});
127
+ const act = answer.action;
128
+ if (implementationId === 'laya-onnx-decision-test') {
129
+ const labels = ['yes', 'no'];
130
+ const logits = labels.map(label => Math.log(Math.max(Number(probs[label]) || 1e-9, 1e-12)));
131
+ const boundary = decideFromLogits(labels, logits);
132
+ return {
133
+ decision: boundary.label,
134
+ confidence: boundary.confidence,
135
+ calibrated: false,
136
+ probabilities: probs,
137
+ abstained: false,
138
+ ...act === undefined ? {} : { action: { act_probability: Number(act.act_probability) } },
139
+ };
140
+ }
141
+ return renderAnswer({ answers: { answer } });
142
+ },
143
+ async unload(signal) {
144
+ void signal;
145
+ const session = await sessionPromise?.catch(() => undefined);
146
+ sessionPromise = undefined;
147
+ await session?.dispose();
148
+ },
149
+ async dispose() {
150
+ disposed = true;
151
+ await this.unload(new AbortController().signal);
152
+ context.logger.log('debug', 'laya decision provider disposed');
153
+ },
154
+ };
155
+ }
156
+ export default {
157
+ apiVersion: 1,
158
+ async create(context) {
159
+ return {
160
+ async createProvider({ modelId }) {
161
+ if (modelId !== MODEL_ID) {
162
+ throw new Error(`this extension implements the "${MODEL_ID}" model, not "${modelId}"`);
163
+ }
164
+ return createLayaProvider(context);
165
+ },
166
+ async dispose(reason) {
167
+ context.logger.log('debug', `laya extension disposed: ${reason}`);
168
+ },
169
+ };
170
+ },
171
+ };
172
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAWH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CAAA;QACvE,CAAC;QAED,KAAK,CAAC,MAAM,CAAC,MAAmB;YAC9B,KAAK,MAAM,CAAA;YACX,MAAM,OAAO,GAAG,MAAM,cAAc,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;YAC5D,cAAc,GAAG,SAAS,CAAA;YAC1B,MAAM,OAAO,EAAE,OAAO,EAAE,CAAA;QAC1B,CAAC;QAED,KAAK,CAAC,OAAO;YACX,QAAQ,GAAG,IAAI,CAAA;YACf,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,eAAe,EAAE,CAAC,MAAM,CAAC,CAAA;YAC/C,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,iCAAiC,CAAC,CAAA;QAChE,CAAC;KACF,CAAA;AACH,CAAC;AAED,eAAe;IACb,UAAU,EAAE,CAAC;IACb,KAAK,CAAC,MAAM,CAAC,OAA2B;QACtC,OAAO;YACL,KAAK,CAAC,cAAc,CAAC,EAAE,OAAO,EAAE;gBAC9B,IAAI,OAAO,KAAK,QAAQ,EAAE,CAAC;oBACzB,MAAM,IAAI,KAAK,CAAC,kCAAkC,QAAQ,iBAAiB,OAAO,GAAG,CAAC,CAAA;gBACxF,CAAC;gBACD,OAAO,kBAAkB,CAAC,OAAO,CAAC,CAAA;YACpC,CAAC;YACD,KAAK,CAAC,OAAO,CAAC,MAAM;gBAClB,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,4BAA4B,MAAM,EAAE,CAAC,CAAA;YACnE,CAAC;SACF,CAAA;IACH,CAAC;CACF,CAAA"}
package/lib/pure.d.ts ADDED
@@ -0,0 +1,35 @@
1
+ /**
2
+ * The deterministic decision maths (H5), model-free and mirroring the vendored
3
+ * runtime's formulas so the tests can pin the mapping WITHOUT weights.
4
+ *
5
+ * The vendored laya-ts `common.js` is the authority for these formulas
6
+ * (softmax, confidenceFromProbs, answerConfidence); this module re-states the
7
+ * same arithmetic so the extension's boundary — logit → label → confidence —
8
+ * is testable in isolation, and so a reviewer can see that the reported
9
+ * confidence is EXACTLY the runtime's uncalibrated probability mass (DEC-08).
10
+ */
11
+ /** The option-count bounds the vendored runtime enforces (structured.js). */
12
+ export declare const MAX_OPTIONS = 32;
13
+ export declare const MAX_SCORE_LEVELS = 10;
14
+ /** Softmax, mirroring the vendored common.js exactly. */
15
+ export declare function softmax(z: readonly number[]): number[];
16
+ /** Probability mass on the reported answer — the vendored answerConfidence. */
17
+ export declare function answerConfidence(p: readonly number[]): number;
18
+ /** One boundary decision: logits → label + confidence. */
19
+ export interface BoundaryDecision {
20
+ readonly index: number;
21
+ readonly label: string;
22
+ readonly confidence: number;
23
+ readonly probabilities: readonly number[];
24
+ }
25
+ /**
26
+ * Map logits to a boundary decision: softmax, argmax, and ties broken by the
27
+ * INPUT order of the labels (deterministic; the vendored runtime's stable
28
+ * argmax does the same).
29
+ */
30
+ export declare function decideFromLogits(labels: readonly string[], logits: readonly number[]): BoundaryDecision;
31
+ /**
32
+ * Validate the caller's options: the bounds, the uniqueness and the shape the
33
+ * schema enforces, re-asserted here so the runtime refusal is precise.
34
+ */
35
+ export declare function validateOptions(options: readonly string[], max: number): string[];
package/lib/pure.js ADDED
@@ -0,0 +1,71 @@
1
+ /**
2
+ * The deterministic decision maths (H5), model-free and mirroring the vendored
3
+ * runtime's formulas so the tests can pin the mapping WITHOUT weights.
4
+ *
5
+ * The vendored laya-ts `common.js` is the authority for these formulas
6
+ * (softmax, confidenceFromProbs, answerConfidence); this module re-states the
7
+ * same arithmetic so the extension's boundary — logit → label → confidence —
8
+ * is testable in isolation, and so a reviewer can see that the reported
9
+ * confidence is EXACTLY the runtime's uncalibrated probability mass (DEC-08).
10
+ */
11
+ /** The option-count bounds the vendored runtime enforces (structured.js). */
12
+ export const MAX_OPTIONS = 32;
13
+ export const MAX_SCORE_LEVELS = 10;
14
+ /** Softmax, mirroring the vendored common.js exactly. */
15
+ export function softmax(z) {
16
+ const m = Math.max(...z);
17
+ const e = z.map(v => Math.exp(v - m));
18
+ const s = e.reduce((a, b) => a + b, 0);
19
+ return e.map(v => v / s);
20
+ }
21
+ /** Probability mass on the reported answer — the vendored answerConfidence. */
22
+ export function answerConfidence(p) {
23
+ if (p.length < 1)
24
+ return 1;
25
+ return Math.min(1, Math.max(0, Math.max(...p)));
26
+ }
27
+ /**
28
+ * Map logits to a boundary decision: softmax, argmax, and ties broken by the
29
+ * INPUT order of the labels (deterministic; the vendored runtime's stable
30
+ * argmax does the same).
31
+ */
32
+ export function decideFromLogits(labels, logits) {
33
+ if (labels.length === 0)
34
+ throw new Error('at least one label is required');
35
+ if (labels.length !== logits.length)
36
+ throw new Error('one logit per label');
37
+ const probabilities = softmax(logits);
38
+ let index = 0;
39
+ for (let i = 1; i < probabilities.length; i += 1) {
40
+ if (probabilities[i] > probabilities[index])
41
+ index = i;
42
+ }
43
+ return {
44
+ index,
45
+ label: labels[index],
46
+ confidence: answerConfidence(probabilities),
47
+ probabilities,
48
+ };
49
+ }
50
+ /**
51
+ * Validate the caller's options: the bounds, the uniqueness and the shape the
52
+ * schema enforces, re-asserted here so the runtime refusal is precise.
53
+ */
54
+ export function validateOptions(options, max) {
55
+ if (!Array.isArray(options))
56
+ throw new Error('"options" must be an array of strings');
57
+ if (options.length < 2)
58
+ throw new Error(`at least 2 options are required, got ${options.length}`);
59
+ if (options.length > max)
60
+ throw new Error(`${options.length} options exceed the ${max}-option bound`);
61
+ const seen = new Set();
62
+ for (const option of options) {
63
+ if (typeof option !== 'string' || option.length === 0)
64
+ throw new Error('every option must be a non-empty string');
65
+ if (seen.has(option))
66
+ throw new Error(`duplicate option label ${JSON.stringify(option)} is refused`);
67
+ seen.add(option);
68
+ }
69
+ return [...options];
70
+ }
71
+ //# sourceMappingURL=pure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pure.js","sourceRoot":"","sources":["../src/pure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,6EAA6E;AAC7E,MAAM,CAAC,MAA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 +1,63 @@
1
+ {
2
+ "lockVersion": 1,
3
+ "assetSets": {
4
+ "laya-decision-onnx": {
5
+ "model": {
6
+ "provider": "NandhaKishorM",
7
+ "identity": "NandhaKishorM/laya (multilingual decision checkpoint)",
8
+ "url": "https://github.com/NandhaKishorM/laya",
9
+ "modalities": ["text"],
10
+ "note": "The Laya decision-family checkpoint at commit c73908d96ff73c0062c340a11bf7c54ec7d8bc4d (tag v0.4.6, Apache-2.0). The model card ships UNCALIBRATED logits with a clamping warning — every confidence this extension returns is marked calibrated: false (DEC-08)."
11
+ },
12
+ "conversion": {
13
+ "identity": "upstream scripts/export_onnx.py split export (encoder + head with external data)",
14
+ "url": "https://github.com/NandhaKishorM/laya/blob/c73908d96ff73c0062c340a11bf7c54ec7d8bc4d/scripts/export_onnx.py",
15
+ "kind": "upstream six-artifact split ONNX export of the source checkpoint",
16
+ "quantizationProfile": "unquantized fp32",
17
+ "revision": "7b928d828b7b0e022f929d9bd2e44165aa270148",
18
+ "note": "The six artifacts below were exported from the pinned checkpoint and measured on this host; torch-vs-ONNX parity passed 3/3 (worst logits diff 1.0e-06, act_probs 0.0e+00) per docs/tool-mode/LAYA-INTEGRATION-FINDINGS.md. The encoder takes input_ids/attention_mask; the head takes hidden_states/marker_pos/marker_mask/qtype/attention_mask and returns logits + act_logits."
19
+ },
20
+ "engine": {
21
+ "kind": "onnxruntime-node (native CPU execution provider) driven by the vendored laya-ts runtime",
22
+ "version": "onnxruntime-node ^1.20.0 + vendored laya-ts dist from the pinned commit",
23
+ "note": "The vendored runtime creates the ONNX sessions DIRECTLY over encoder.onnx + head.onnx and verifies every artifact's SHA-256 before loading (the loadNodeBundle refusal)."
24
+ },
25
+ "tokenizer": {
26
+ "kind": "the checkpoint's own tokenizer.json (metaspace BPE, vocab 50285 with the ModernBERT special ids)",
27
+ "identity": "ships with the pinned checkpoint; parsed by the vendored laya-ts tokenizer (parseTokenizerJson)",
28
+ "note": "No external tokenizer package is required: the vendored runtime parses the pinned tokenizer.json itself."
29
+ },
30
+ "pinning": {
31
+ "state": "measured",
32
+ "revision": "7b928d828b7b0e022f929d9bd2e44165aa270148",
33
+ "reason": "This is the revision the six split-ONNX artifacts were exported at, recorded once already in the conversion section above; the planner needs it as the deployment's pinned model revision so a preparation can be planned. No digest, byte count or source is restated or changed here, and no additional revision is claimed. The asset sources below are descriptions of the split export rather than fetchable locations: the host-driven acquisition step has NOT been exercised against them, so a Settings-page Prepare for Laya refuses at the transport rather than pretending to download."
34
+ },
35
+ "groups": [
36
+ {
37
+ "id": "text-backbone",
38
+ "enables": ["text"],
39
+ "assets": [
40
+ { "id": "laya-encoder-onnx", "file": "encoder.onnx", "bytes": 2451566, "source": "the split export of the pinned checkpoint", "digest": "A774C5C634B99D1A4CED21ACBF11B9617A5CD55C7C7957BD52480B17D95A97F4", "executable": false },
41
+ { "id": "laya-encoder-onnx-data", "file": "encoder.onnx.data", "bytes": 1227816960, "source": "the split export of the pinned checkpoint", "digest": "F1E49A027352064D72831863456BE6160748854296BFF8332DF14130DBF79834", "executable": false }
42
+ ]
43
+ },
44
+ {
45
+ "id": "decision-head",
46
+ "enables": ["text"],
47
+ "assets": [
48
+ { "id": "laya-head-onnx", "file": "head.onnx", "bytes": 245312, "source": "the split export of the pinned checkpoint", "digest": "7F6B9AC15D5FDF9EEBB352E66BDD3CE799D32885F1446014D268D8C53207858B", "executable": false },
49
+ { "id": "laya-head-onnx-data", "file": "head.onnx.data", "bytes": 59899904, "source": "the split export of the pinned checkpoint", "digest": "0292A4EB478C2C3EC0B6555B4A4093BC802E965654D7AEB4AC22907A17F261D3", "executable": false }
50
+ ]
51
+ },
52
+ {
53
+ "id": "tokenizer-config",
54
+ "enables": ["text"],
55
+ "assets": [
56
+ { "id": "laya-tokenizer", "file": "tokenizer.json", "bytes": 34363188, "source": "the split export of the pinned checkpoint", "digest": "609D8F4C067CD3950F88594C5A802616CEA245823836EF5848EE4FC40AAB5B6F", "executable": false },
57
+ { "id": "laya-rl-agent-config", "file": "rl_agent_config.json", "bytes": 472, "source": "the split export of the pinned checkpoint", "digest": "25061739243B617AD88D1219BA6F8A9C86C5881CA28DF024FA2D9B3B2FCC30C6", "executable": false }
58
+ ]
59
+ }
60
+ ]
61
+ }
62
+ }
63
+ }
package/package.json CHANGED
@@ -1,6 +1,41 @@
1
1
  {
2
2
  "name": "@try-works/extension-laya",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.1",
4
+ "type": "module",
5
+ "description": "Tool Mode extension implementing the Laya decision family (decision_choose / decision_test / decision_score) on the pinned multilingual Laya checkpoint, with the vendored laya-ts runtime.",
6
+ "license": "Apache-2.0",
7
+ "exports": {
8
+ "./tool-mode": "./lib/index.js",
9
+ "./package.json": "./package.json"
10
+ },
11
+ "files": [
12
+ "tool-mode.extension.json",
13
+ "lib",
14
+ "models.lock.json",
15
+ "schema",
16
+ "vendor",
17
+ "README.md"
18
+ ],
19
+ "toolMode": {
20
+ "manifest": "./tool-mode.extension.json"
21
+ },
22
+ "scripts": {
23
+ "build": "tsc -p tsconfig.build.json",
24
+ "typecheck": "tsc --noEmit -p tsconfig.json",
25
+ "test": "tsx --test tests/*.test.ts"
26
+ },
27
+ "dependencies": {
28
+ "onnxruntime-node": "^1.20.0"
29
+ },
30
+ "peerDependencies": {
31
+ "@try-works/tool-mode-extension-sdk": "^0.1.0"
32
+ },
33
+ "devDependencies": {
34
+ "@try-works/tool-mode-extension-sdk": "workspace:*",
35
+ "ajv": "^8.20.0"
36
+ },
37
+ "publishConfig": {
38
+ "access": "public",
39
+ "registry": "https://registry.npmjs.org/"
40
+ }
41
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "type": "object",
4
+ "additionalProperties": false,
5
+ "required": ["prompt", "options"],
6
+ "properties": {
7
+ "prompt": { "type": "string", "minLength": 1, "maxLength": 4096, "description": "The decision prompt." },
8
+ "options": {
9
+ "type": "array",
10
+ "minItems": 2,
11
+ "maxItems": 32,
12
+ "items": { "type": "string", "minLength": 1, "maxLength": 512 },
13
+ "uniqueItems": true,
14
+ "description": "The mutually exclusive options to choose from; duplicate labels are refused."
15
+ },
16
+ "allow_abstain": {
17
+ "type": "boolean",
18
+ "default": true,
19
+ "description": "Whether the model's act/no-act gate may abstain instead of forcing a choice."
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "type": "object",
4
+ "additionalProperties": false,
5
+ "required": ["chosen", "confidence", "calibrated", "probabilities", "abstained"],
6
+ "properties": {
7
+ "chosen": { "type": ["string", "null"], "description": "The chosen option label, or null when abstained." },
8
+ "confidence": { "type": "number", "minimum": 0, "maximum": 1, "description": "EXPLICITLY UNCALIBRATED: the probability mass on the reported answer (DEC-08)." },
9
+ "calibrated": { "const": false, "description": "The upstream model ships uncalibrated logits with a clamping warning; this is never a calibrated probability (DEC-08)." },
10
+ "answer_confidence": { "type": "number", "minimum": 0, "maximum": 1, "description": "The same mass as confidence, named for parity with the vendored runtime's fields." },
11
+ "probabilities": { "type": "object", "additionalProperties": true, "description": "Per-option softmax scores (uncalibrated)." },
12
+ "abstained": { "type": "boolean", "description": "True when the model's act gate declined and allow_abstain permitted it." },
13
+ "action": {
14
+ "type": "object",
15
+ "additionalProperties": false,
16
+ "properties": { "act_probability": { "type": "number" } },
17
+ "description": "The model's act-gate output, when the runtime reported one."
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "type": "object",
4
+ "additionalProperties": false,
5
+ "required": ["prompt", "levels"],
6
+ "properties": {
7
+ "prompt": { "type": "string", "minLength": 1, "maxLength": 4096, "description": "The scoring prompt." },
8
+ "levels": {
9
+ "type": "array",
10
+ "minItems": 2,
11
+ "maxItems": 10,
12
+ "items": { "type": "string", "minLength": 1, "maxLength": 128 },
13
+ "uniqueItems": true,
14
+ "description": "The ordinal levels from lowest to highest; duplicate labels are refused."
15
+ },
16
+ "allow_abstain": { "type": "boolean", "default": true }
17
+ }
18
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "type": "object",
4
+ "additionalProperties": false,
5
+ "required": ["score", "confidence", "calibrated", "probabilities", "abstained"],
6
+ "properties": {
7
+ "score": { "type": ["string", "null"], "description": "The scored level label, or null when abstained." },
8
+ "confidence": { "type": "number", "minimum": 0, "maximum": 1, "description": "EXPLICITLY UNCALIBRATED (DEC-08)." },
9
+ "calibrated": { "const": false },
10
+ "probabilities": { "type": "object", "additionalProperties": true, "description": "Per-level softmax scores (uncalibrated)." },
11
+ "abstained": { "type": "boolean" },
12
+ "action": {
13
+ "type": "object",
14
+ "additionalProperties": false,
15
+ "properties": { "act_probability": { "type": "number" } }
16
+ }
17
+ }
18
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "type": "object",
4
+ "additionalProperties": false,
5
+ "required": ["prompt"],
6
+ "properties": {
7
+ "prompt": { "type": "string", "minLength": 1, "maxLength": 4096, "description": "The yes/no question." },
8
+ "allow_abstain": { "type": "boolean", "default": true, "description": "Whether the act gate may abstain." }
9
+ }
10
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "type": "object",
4
+ "additionalProperties": false,
5
+ "required": ["decision", "confidence", "calibrated", "probabilities", "abstained"],
6
+ "properties": {
7
+ "decision": { "type": ["string", "null"], "enum": ["yes", "no", null], "description": "The yes/no decision, or null when abstained." },
8
+ "confidence": { "type": "number", "minimum": 0, "maximum": 1, "description": "EXPLICITLY UNCALIBRATED (DEC-08)." },
9
+ "calibrated": { "const": false },
10
+ "probabilities": { "type": "object", "additionalProperties": true, "description": "{yes, no} softmax scores (uncalibrated)." },
11
+ "abstained": { "type": "boolean" },
12
+ "action": {
13
+ "type": "object",
14
+ "additionalProperties": false,
15
+ "properties": { "act_probability": { "type": "number" } }
16
+ }
17
+ }
18
+ }