@try-works/dsh-model-as-tool 0.1.3 → 0.3.6
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/bin/dsh-tool-mode-credentials.mjs +20 -0
- package/bin/dsh-tool-mode.mjs +202 -0
- package/catalog/desert-ant-models.json +693 -693
- package/client/client.model-tools.js +592 -0
- package/client/index.js +1679 -0
- package/lib/adapters/index.d.ts.map +1 -1
- package/lib/adapters/index.js +4 -4
- package/lib/bindings.d.ts.map +1 -1
- package/lib/bindings.js +26 -25
- package/lib/capability.d.ts.map +1 -1
- package/lib/capability.js +17 -0
- package/lib/capture-path.d.ts +97 -0
- package/lib/capture-path.d.ts.map +1 -0
- package/lib/capture-path.js +152 -0
- package/lib/diagnostics.d.ts +166 -0
- package/lib/diagnostics.d.ts.map +1 -0
- package/lib/diagnostics.js +135 -0
- package/lib/extension-dependencies.d.ts +197 -0
- package/lib/extension-dependencies.d.ts.map +1 -0
- package/lib/extension-dependencies.js +369 -0
- package/lib/extension-dispatch.d.ts +117 -0
- package/lib/extension-dispatch.d.ts.map +1 -0
- package/lib/extension-dispatch.js +124 -0
- package/lib/extension-registrar.d.ts +100 -0
- package/lib/extension-registrar.d.ts.map +1 -0
- package/lib/extension-registrar.js +134 -0
- package/lib/extensions-api.d.ts +217 -0
- package/lib/extensions-api.d.ts.map +1 -0
- package/lib/extensions-api.js +17 -0
- package/lib/extensions-remote.d.ts +54 -0
- package/lib/extensions-remote.d.ts.map +1 -0
- package/lib/extensions-remote.js +66 -0
- package/lib/extensions-service.d.ts +334 -0
- package/lib/extensions-service.d.ts.map +1 -0
- package/lib/extensions-service.js +1351 -0
- package/lib/harness-llm.d.ts +138 -0
- package/lib/harness-llm.d.ts.map +1 -0
- package/lib/harness-llm.js +218 -0
- package/lib/harness-serving.d.ts +95 -0
- package/lib/harness-serving.d.ts.map +1 -0
- package/lib/harness-serving.js +157 -0
- package/lib/headless.d.ts +97 -0
- package/lib/headless.d.ts.map +1 -0
- package/lib/headless.js +349 -0
- package/lib/http-acquisition.d.ts +27 -0
- package/lib/http-acquisition.d.ts.map +1 -0
- package/lib/http-acquisition.js +136 -0
- package/lib/index.d.ts +250 -7
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2625 -70
- package/lib/invocation-accounting.d.ts +169 -0
- package/lib/invocation-accounting.d.ts.map +1 -0
- package/lib/invocation-accounting.js +148 -0
- package/lib/legacy-migration.d.ts +95 -0
- package/lib/legacy-migration.d.ts.map +1 -0
- package/lib/legacy-migration.js +429 -0
- package/lib/managed-workers.d.ts +151 -0
- package/lib/managed-workers.d.ts.map +1 -0
- package/lib/managed-workers.js +249 -0
- package/lib/mcp/client-grant.d.ts +74 -0
- package/lib/mcp/client-grant.d.ts.map +1 -0
- package/lib/mcp/client-grant.js +60 -0
- package/lib/mcp/credential-cli.d.ts +38 -0
- package/lib/mcp/credential-cli.d.ts.map +1 -0
- package/lib/mcp/credential-cli.js +148 -0
- package/lib/mcp/credential-store.d.ts +143 -0
- package/lib/mcp/credential-store.d.ts.map +1 -0
- package/lib/mcp/credential-store.js +454 -0
- package/lib/mcp/host-binding.d.ts +25 -0
- package/lib/mcp/host-binding.d.ts.map +1 -1
- package/lib/mcp/host-binding.js +107 -14
- package/lib/mcp/http.d.ts +68 -18
- package/lib/mcp/http.d.ts.map +1 -1
- package/lib/mcp/http.js +390 -62
- package/lib/mcp/oauth.d.ts +149 -0
- package/lib/mcp/oauth.d.ts.map +1 -0
- package/lib/mcp/oauth.js +396 -0
- package/lib/mcp/protocol.d.ts +46 -7
- package/lib/mcp/protocol.d.ts.map +1 -1
- package/lib/mcp/protocol.js +63 -16
- package/lib/mcp/rate-limit.d.ts +68 -0
- package/lib/mcp/rate-limit.d.ts.map +1 -0
- package/lib/mcp/rate-limit.js +114 -0
- package/lib/mcp/sdk-v2.d.ts +17 -0
- package/lib/mcp/sdk-v2.d.ts.map +1 -0
- package/lib/mcp/sdk-v2.js +181 -0
- package/lib/mcp/server.d.ts +11 -1
- package/lib/mcp/server.d.ts.map +1 -1
- package/lib/mcp/server.js +80 -13
- package/lib/mcp/stdio.d.ts.map +1 -1
- package/lib/mcp/stdio.js +9 -1
- package/lib/mcp/subscriptions.d.ts +43 -1
- package/lib/mcp/subscriptions.d.ts.map +1 -1
- package/lib/mcp/subscriptions.js +90 -9
- package/lib/model-qualification.d.ts +192 -0
- package/lib/model-qualification.d.ts.map +1 -0
- package/lib/model-qualification.js +178 -0
- package/lib/planning.d.ts +246 -0
- package/lib/planning.d.ts.map +1 -0
- package/lib/planning.js +457 -0
- package/lib/prepared-assets.d.ts +178 -0
- package/lib/prepared-assets.d.ts.map +1 -0
- package/lib/prepared-assets.js +286 -0
- package/lib/provider-bridge.d.ts +37 -0
- package/lib/provider-bridge.d.ts.map +1 -1
- package/lib/provider-bridge.js +189 -12
- package/lib/ptc-authority.d.ts +140 -0
- package/lib/ptc-authority.d.ts.map +1 -0
- package/lib/ptc-authority.js +216 -0
- package/lib/ptc-runtime.d.ts +156 -0
- package/lib/ptc-runtime.d.ts.map +1 -0
- package/lib/ptc-runtime.js +191 -0
- package/lib/publication.d.ts +2 -1
- package/lib/publication.d.ts.map +1 -1
- package/lib/publication.js +13 -5
- package/lib/receipt.d.ts.map +1 -1
- package/lib/receipt.js +8 -0
- package/lib/title-proposal.d.ts +194 -0
- package/lib/title-proposal.d.ts.map +1 -0
- package/lib/title-proposal.js +244 -0
- package/lib/tool-mode-run.d.ts +235 -0
- package/lib/tool-mode-run.d.ts.map +1 -0
- package/lib/tool-mode-run.js +283 -0
- package/lib/types.d.ts +3 -1
- package/lib/types.d.ts.map +1 -1
- package/lib/update-surface.d.ts +79 -0
- package/lib/update-surface.d.ts.map +1 -0
- package/lib/update-surface.js +224 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/standard.d.ts +38 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/standard.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/standard.js +445 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-embed.d.ts +14 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-embed.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-embed.js +63 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-rerank.d.ts +14 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-rerank.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-rerank.js +76 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/dsh.d.ts.map +1 -1
- package/node_modules/@try-works/tool-mode-contracts/lib/dsh.js +69 -55
- package/node_modules/@try-works/tool-mode-contracts/lib/index.d.ts +4 -1
- package/node_modules/@try-works/tool-mode-contracts/lib/index.d.ts.map +1 -1
- package/node_modules/@try-works/tool-mode-contracts/lib/index.js +26 -2
- package/node_modules/@try-works/tool-mode-contracts/lib/registry.d.ts +28 -2
- package/node_modules/@try-works/tool-mode-contracts/lib/registry.d.ts.map +1 -1
- package/node_modules/@try-works/tool-mode-contracts/lib/registry.js +93 -10
- package/node_modules/@try-works/tool-mode-contracts/package.json +0 -1
- package/node_modules/@try-works/tool-mode-extension-sdk/bin/dsh-tool-mode.mjs +20 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/cli.d.ts +80 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/cli.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/cli.js +533 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/declarative-recipes.d.ts +83 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/declarative-recipes.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/declarative-recipes.js +125 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/discovery.d.ts +70 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/discovery.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/discovery.js +201 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/errors.d.ts +57 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/errors.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/errors.js +83 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/index.d.ts +31 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/index.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/index.js +31 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/archive.d.ts +86 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/archive.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/archive.js +185 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/dependencies.d.ts +126 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/dependencies.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/dependencies.js +297 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/lifecycle.d.ts +216 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/lifecycle.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/lifecycle.js +800 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/migration.d.ts +210 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/migration.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/migration.js +368 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/runtime-link.d.ts +63 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/runtime-link.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/runtime-link.js +149 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/source-directory.d.ts +35 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/source-directory.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/source-directory.js +179 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/staged.d.ts +179 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/staged.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/staged.js +235 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/store.d.ts +367 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/store.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/store.js +807 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/update-flow.d.ts +185 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/update-flow.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/update-flow.js +504 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/zip-source.d.ts +17 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/zip-source.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/zip-source.js +80 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/load.d.ts +52 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/load.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/load.js +102 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/manifest.d.ts +171 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/manifest.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/manifest.js +271 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/runtime.d.ts +242 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/runtime.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/runtime.js +58 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/state.d.ts +118 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/state.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/state.js +113 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker/worker-child.d.ts +2 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker/worker-child.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker/worker-child.js +351 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker.d.ts +150 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker.js +670 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/package.json +53 -0
- package/node_modules/@try-works/tool-mode-extension-sdk/schema/extension-manifest-1.1.0.schema.json +253 -0
- package/node_modules/@try-works/tool-mode-recipes/bin/tool-mode-recipe.mjs +15 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/broker.d.ts +427 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/broker.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/broker.js +592 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/cli.d.ts +60 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/cli.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/cli.js +936 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/dsh-adapter.d.ts +237 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/dsh-adapter.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/dsh-adapter.js +200 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/fixture-provider.d.ts +85 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/fixture-provider.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/fixture-provider.js +176 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/images.d.ts +105 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/images.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/images.js +129 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/index.d.ts +25 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/index.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/index.js +25 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/recipe-format.d.ts +325 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/recipe-format.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/recipe-format.js +1310 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/templates.d.ts +51 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/templates.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/templates.js +310 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/titles.d.ts +227 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/titles.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-recipes/lib/titles.js +407 -0
- package/node_modules/@try-works/tool-mode-recipes/package.json +56 -0
- package/node_modules/@try-works/tool-mode-recipes/recipes/describe-image.json +38 -0
- package/node_modules/@try-works/tool-mode-recipes/recipes/text-title.json +45 -0
- package/node_modules/@try-works/tool-mode-recipes/schema/harness-model-recipe.schema.json +273 -0
- package/package.json +43 -15
- package/remote/spec.mjs +439 -0
- package/remote/typert.host.mjs +14 -0
- package/remote/typert.remote-client.mjs +16 -0
- package/lib/adapters/tongue.d.ts +0 -31
- package/lib/adapters/tongue.d.ts.map +0 -1
- package/lib/adapters/tongue.js +0 -93
- package/lib/adapters/voz.d.ts +0 -28
- package/lib/adapters/voz.d.ts.map +0 -1
- package/lib/adapters/voz.js +0 -102
- /package/{lib → node_modules/@try-works/tool-mode-extension-sdk/lib}/licensing.d.ts +0 -0
- /package/{lib → node_modules/@try-works/tool-mode-extension-sdk/lib}/licensing.d.ts.map +0 -0
- /package/{lib → node_modules/@try-works/tool-mode-extension-sdk/lib}/licensing.js +0 -0
package/remote/spec.mjs
ADDED
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The single source of truth for the `modelTools` Remote namespace.
|
|
3
|
+
*
|
|
4
|
+
* Three artifacts are built from this module and must never drift:
|
|
5
|
+
* - `typert.host.mjs`: the Host Loader face the `typert-loader` registers as
|
|
6
|
+
* strict invocation descriptors (`./typert` package export);
|
|
7
|
+
* - `typert.remote-client.mjs`: the mountable Client contribution (`./remote`);
|
|
8
|
+
* - `client/client.model-tools.js`: the package-local lazy-CJS chunk the
|
|
9
|
+
* plugin's browser half loads with `require.async('./client.model-tools.js')`
|
|
10
|
+
* (the client module system serves only `./client`, so the contribution the
|
|
11
|
+
* page mounts travels as a sibling chunk).
|
|
12
|
+
*
|
|
13
|
+
* The wire method for install is `installExtension`, not `install`: DSH's
|
|
14
|
+
* client RemoteNamespaceService owns a private method `install` and refuses a
|
|
15
|
+
* descriptor method that collides with it. The Host service keeps its member
|
|
16
|
+
* name `install`; the descriptor's `implementation` maps the two.
|
|
17
|
+
*
|
|
18
|
+
* These functions stay dependency-free and self-contained because
|
|
19
|
+
* `scripts/gen-remote-artifacts.mjs` inlines their source into the browser
|
|
20
|
+
* chunk; changing one to reference an enclosing binding breaks the chunk.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/** npm package that owns the namespace. */
|
|
24
|
+
export const PACKAGE = '@try-works/dsh-model-as-tool'
|
|
25
|
+
/** Cordis service key the Host dispatch resolves. */
|
|
26
|
+
export const SERVICE = 'modelTools'
|
|
27
|
+
/** Wire namespace exposed as `ctx.remote.modelTools`. */
|
|
28
|
+
export const NAMESPACE = 'modelTools'
|
|
29
|
+
/** Browser-facing install method (see the collision note above). */
|
|
30
|
+
export const INSTALL_WIRE_METHOD = 'installExtension'
|
|
31
|
+
|
|
32
|
+
/** Structural validators for the JSON values the wire carries. */
|
|
33
|
+
const STRING = { kind: 'string' }
|
|
34
|
+
const BOOLEAN = { kind: 'boolean' }
|
|
35
|
+
const NULLABLE_STRING = { kind: 'nullable', of: STRING }
|
|
36
|
+
const STRING_LIST = { kind: 'array', of: STRING }
|
|
37
|
+
const INTEGRITY = {
|
|
38
|
+
kind: 'union',
|
|
39
|
+
of: [
|
|
40
|
+
{ kind: 'literal', value: 'unchanged' },
|
|
41
|
+
{ kind: 'literal', value: 'changed' },
|
|
42
|
+
{ kind: 'literal', value: 'unknown' },
|
|
43
|
+
],
|
|
44
|
+
}
|
|
45
|
+
/** The preflight prerequisite vocabulary (`extensions-api.ts` task-92). */
|
|
46
|
+
const REQUIREMENT_KIND = {
|
|
47
|
+
kind: 'union',
|
|
48
|
+
of: [
|
|
49
|
+
'store',
|
|
50
|
+
'source',
|
|
51
|
+
'dependencies',
|
|
52
|
+
'assets',
|
|
53
|
+
'executable',
|
|
54
|
+
'harness-model',
|
|
55
|
+
'platform',
|
|
56
|
+
'integrity',
|
|
57
|
+
'activation',
|
|
58
|
+
].map(value => ({ kind: 'literal', value })),
|
|
59
|
+
}
|
|
60
|
+
/** The action that clears an unmet requirement. */
|
|
61
|
+
const REQUIREMENT_ACTION = {
|
|
62
|
+
kind: 'union',
|
|
63
|
+
of: ['install', 'prepare', 'enable', 'config', 'none'].map(value => ({ kind: 'literal', value })),
|
|
64
|
+
}
|
|
65
|
+
const EXTENSION_REQUIREMENT = {
|
|
66
|
+
kind: 'object',
|
|
67
|
+
fields: {
|
|
68
|
+
kind: REQUIREMENT_KIND,
|
|
69
|
+
satisfied: BOOLEAN,
|
|
70
|
+
reason: STRING,
|
|
71
|
+
action: REQUIREMENT_ACTION,
|
|
72
|
+
},
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* One extension row.
|
|
76
|
+
*
|
|
77
|
+
* `requirements` and `blocked` are ADDITIVE against the older row shape: both
|
|
78
|
+
* are optional here so a Host that predates the requirements model still
|
|
79
|
+
* validates. The browser half treats an absent `requirements` as "the host did
|
|
80
|
+
* not check" (no invented rows) and an absent `blocked` as false.
|
|
81
|
+
*/
|
|
82
|
+
const EXTENSION_STATE = {
|
|
83
|
+
kind: 'object',
|
|
84
|
+
fields: {
|
|
85
|
+
id: STRING,
|
|
86
|
+
package: NULLABLE_STRING,
|
|
87
|
+
version: NULLABLE_STRING,
|
|
88
|
+
installed: BOOLEAN,
|
|
89
|
+
active: BOOLEAN,
|
|
90
|
+
disabled: BOOLEAN,
|
|
91
|
+
integrity: INTEGRITY,
|
|
92
|
+
tools: STRING_LIST,
|
|
93
|
+
reason: NULLABLE_STRING,
|
|
94
|
+
requirements: { kind: 'optional', of: { kind: 'array', of: EXTENSION_REQUIREMENT } },
|
|
95
|
+
blocked: { kind: 'optional', of: BOOLEAN },
|
|
96
|
+
},
|
|
97
|
+
}
|
|
98
|
+
const DESCRIBE_RESULT = {
|
|
99
|
+
kind: 'object',
|
|
100
|
+
fields: {
|
|
101
|
+
store: NULLABLE_STRING,
|
|
102
|
+
writable: BOOLEAN,
|
|
103
|
+
sourceDir: NULLABLE_STRING,
|
|
104
|
+
extensions: { kind: 'array', of: EXTENSION_STATE },
|
|
105
|
+
},
|
|
106
|
+
}
|
|
107
|
+
const INSTALL_RESULT = {
|
|
108
|
+
kind: 'object',
|
|
109
|
+
fields: { id: STRING, version: STRING, active: BOOLEAN },
|
|
110
|
+
}
|
|
111
|
+
const TOGGLE_RESULT = {
|
|
112
|
+
kind: 'object',
|
|
113
|
+
fields: { id: STRING, active: BOOLEAN, disabled: BOOLEAN },
|
|
114
|
+
}
|
|
115
|
+
const OPTIONAL_STRING = { kind: 'optional', of: STRING }
|
|
116
|
+
const NUMBER = { kind: 'number' }
|
|
117
|
+
/** The readiness vocabulary from `extensions-api.ts` (EXT-25 / RES-04). */
|
|
118
|
+
const MODEL_READINESS = {
|
|
119
|
+
kind: 'union',
|
|
120
|
+
of: ['unavailable', 'needs-preparation', 'preparing', 'prepared-cold', 'loading', 'ready', 'busy', 'failed']
|
|
121
|
+
.map(value => ({ kind: 'literal', value })),
|
|
122
|
+
}
|
|
123
|
+
const PREPARATION_ASSET = {
|
|
124
|
+
kind: 'object',
|
|
125
|
+
fields: { assetId: STRING, bytes: NUMBER, source: STRING, executable: BOOLEAN },
|
|
126
|
+
}
|
|
127
|
+
const PREPARATION_LICENSE = {
|
|
128
|
+
kind: 'object',
|
|
129
|
+
fields: { name: STRING, url: STRING },
|
|
130
|
+
}
|
|
131
|
+
const PREPARATION_PLAN = {
|
|
132
|
+
kind: 'object',
|
|
133
|
+
fields: {
|
|
134
|
+
modelId: STRING,
|
|
135
|
+
modelRevision: STRING,
|
|
136
|
+
assets: { kind: 'array', of: PREPARATION_ASSET },
|
|
137
|
+
totalBytes: NUMBER,
|
|
138
|
+
storageBytes: NUMBER,
|
|
139
|
+
requiresExecutableApproval: BOOLEAN,
|
|
140
|
+
license: PREPARATION_LICENSE,
|
|
141
|
+
},
|
|
142
|
+
}
|
|
143
|
+
const PREPARE_RESULT = {
|
|
144
|
+
kind: 'object',
|
|
145
|
+
fields: {
|
|
146
|
+
id: STRING,
|
|
147
|
+
prepared: BOOLEAN,
|
|
148
|
+
reason: NULLABLE_STRING,
|
|
149
|
+
plan: { kind: 'nullable', of: PREPARATION_PLAN },
|
|
150
|
+
readiness: { kind: 'record', of: MODEL_READINESS },
|
|
151
|
+
groups: STRING_LIST,
|
|
152
|
+
activationReady: BOOLEAN,
|
|
153
|
+
},
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Validate one boundary value against the declarative schema.
|
|
158
|
+
* @param schema - schema node from the METHOD_SPECS data.
|
|
159
|
+
* @param value - untrusted boundary value.
|
|
160
|
+
* @returns the validated value; objects are rebuilt without undeclared fields.
|
|
161
|
+
* @throws TypeError when the value does not match.
|
|
162
|
+
*/
|
|
163
|
+
export function parseModelToolsValue(schema, value) {
|
|
164
|
+
switch (schema.kind) {
|
|
165
|
+
case 'string':
|
|
166
|
+
if (typeof value !== 'string') throw new TypeError('expected a string')
|
|
167
|
+
return value
|
|
168
|
+
case 'boolean':
|
|
169
|
+
if (typeof value !== 'boolean') throw new TypeError('expected a boolean')
|
|
170
|
+
return value
|
|
171
|
+
case 'number':
|
|
172
|
+
if (typeof value !== 'number' || !Number.isFinite(value)) throw new TypeError('expected a finite number')
|
|
173
|
+
return value
|
|
174
|
+
case 'null':
|
|
175
|
+
if (value !== null) throw new TypeError('expected null')
|
|
176
|
+
return null
|
|
177
|
+
case 'literal':
|
|
178
|
+
if (value !== schema.value) throw new TypeError('expected ' + JSON.stringify(schema.value))
|
|
179
|
+
return value
|
|
180
|
+
case 'optional':
|
|
181
|
+
return value === undefined ? undefined : parseModelToolsValue(schema.of, value)
|
|
182
|
+
case 'nullable':
|
|
183
|
+
return value === null ? null : parseModelToolsValue(schema.of, value)
|
|
184
|
+
case 'array':
|
|
185
|
+
if (!Array.isArray(value)) throw new TypeError('expected an array')
|
|
186
|
+
return value.map((item) => parseModelToolsValue(schema.of, item))
|
|
187
|
+
case 'record': {
|
|
188
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
189
|
+
throw new TypeError('expected a string-keyed record')
|
|
190
|
+
}
|
|
191
|
+
const parsed = {}
|
|
192
|
+
for (const [key, item] of Object.entries(value)) parsed[key] = parseModelToolsValue(schema.of, item)
|
|
193
|
+
return parsed
|
|
194
|
+
}
|
|
195
|
+
case 'object': {
|
|
196
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
197
|
+
throw new TypeError('expected an object')
|
|
198
|
+
}
|
|
199
|
+
const parsed = {}
|
|
200
|
+
for (const [key, field] of Object.entries(schema.fields)) {
|
|
201
|
+
const raw = value[key]
|
|
202
|
+
if (field.kind === 'optional') {
|
|
203
|
+
const item = parseModelToolsValue(field, raw)
|
|
204
|
+
if (item !== undefined) parsed[key] = item
|
|
205
|
+
continue
|
|
206
|
+
}
|
|
207
|
+
if (raw === undefined) throw new TypeError('missing field ' + JSON.stringify(key))
|
|
208
|
+
parsed[key] = parseModelToolsValue(field, raw)
|
|
209
|
+
}
|
|
210
|
+
return parsed
|
|
211
|
+
}
|
|
212
|
+
case 'union': {
|
|
213
|
+
let last
|
|
214
|
+
for (const variant of schema.of) {
|
|
215
|
+
try {
|
|
216
|
+
return parseModelToolsValue(variant, value)
|
|
217
|
+
} catch (error) {
|
|
218
|
+
last = error
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
throw new TypeError('value matched no union variant: ' + last.message)
|
|
222
|
+
}
|
|
223
|
+
default:
|
|
224
|
+
throw new TypeError('unknown schema kind ' + JSON.stringify(schema.kind))
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Build one strict boundary codec from a declarative schema.
|
|
230
|
+
* @param typeSymbol - stable type identity recorded on the codec.
|
|
231
|
+
* @param schema - declarative schema the parser enforces.
|
|
232
|
+
* @returns strict codec with a cached parser factory.
|
|
233
|
+
*/
|
|
234
|
+
export function codecForModelToolsValue(typeSymbol, schema) {
|
|
235
|
+
let parser
|
|
236
|
+
return {
|
|
237
|
+
mode: 'strict',
|
|
238
|
+
typeSymbol,
|
|
239
|
+
create: () => (parser ??= { parse: (value) => parseModelToolsValue(schema, value) }),
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Turn the static method specs into Host/client invocation descriptors.
|
|
245
|
+
* @param packageName - owning npm package.
|
|
246
|
+
* @param serviceKey - Cordis service key the Host dispatch resolves.
|
|
247
|
+
* @param namespace - wire namespace (also the Client Remote service suffix).
|
|
248
|
+
* @param specs - METHOD_SPECS.
|
|
249
|
+
* @returns fresh descriptors both the Host registry and the Client mount accept.
|
|
250
|
+
*/
|
|
251
|
+
export function descriptorsFromModelToolsSpecs(packageName, serviceKey, namespace, specs) {
|
|
252
|
+
return specs.map((spec) => {
|
|
253
|
+
const descriptor = {
|
|
254
|
+
id: packageName + '#' + namespace + '/' + spec.method,
|
|
255
|
+
service: serviceKey,
|
|
256
|
+
namespace,
|
|
257
|
+
method: spec.method,
|
|
258
|
+
description: spec.description,
|
|
259
|
+
invocation: { kind: 'direct' },
|
|
260
|
+
parameters: spec.parameters.map((parameter) => {
|
|
261
|
+
const entry = {
|
|
262
|
+
name: parameter.name,
|
|
263
|
+
wire: parameter.wire,
|
|
264
|
+
source: 'json',
|
|
265
|
+
codec: codecForModelToolsValue(parameter.typeSymbol, parameter.schema),
|
|
266
|
+
strictCodec: codecForModelToolsValue(parameter.strictTypeSymbol, parameter.schema),
|
|
267
|
+
}
|
|
268
|
+
if (parameter.description !== undefined) entry.description = parameter.description
|
|
269
|
+
if (parameter.acceptsUndefined === true) entry.acceptsUndefined = true
|
|
270
|
+
return entry
|
|
271
|
+
}),
|
|
272
|
+
cancellation: { parameter: 'signal' },
|
|
273
|
+
result: {
|
|
274
|
+
mode: 'strict',
|
|
275
|
+
typeSymbol: spec.result.typeSymbol,
|
|
276
|
+
create: codecForModelToolsValue(spec.result.typeSymbol, spec.result.schema).create,
|
|
277
|
+
description: spec.result.description,
|
|
278
|
+
},
|
|
279
|
+
}
|
|
280
|
+
if (spec.implementation !== undefined) descriptor.implementation = spec.implementation
|
|
281
|
+
return descriptor
|
|
282
|
+
})
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/** Static method specs. JSON-safe so the browser chunk can embed them verbatim. */
|
|
286
|
+
export const METHOD_SPECS = [
|
|
287
|
+
{
|
|
288
|
+
method: 'describe',
|
|
289
|
+
description: 'Read the current extension state; the page calls it on mount and after each action.',
|
|
290
|
+
parameters: [],
|
|
291
|
+
result: {
|
|
292
|
+
typeSymbol: PACKAGE + '#' + NAMESPACE + '/describe:result',
|
|
293
|
+
description: 'the extension surface as the host currently sees it.',
|
|
294
|
+
schema: DESCRIBE_RESULT,
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
method: INSTALL_WIRE_METHOD,
|
|
299
|
+
implementation: 'install',
|
|
300
|
+
description: 'Install one extension from `source`, or the configured first-party source.',
|
|
301
|
+
parameters: [
|
|
302
|
+
{
|
|
303
|
+
name: 'id',
|
|
304
|
+
wire: 'id',
|
|
305
|
+
description: 'the extension id, for example `@try-works/extension-laya`.',
|
|
306
|
+
acceptsUndefined: false,
|
|
307
|
+
typeSymbol: PACKAGE + '#' + NAMESPACE + '/install:id',
|
|
308
|
+
strictTypeSymbol: PACKAGE + '#' + NAMESPACE + '/install:id',
|
|
309
|
+
schema: STRING,
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
name: 'source',
|
|
313
|
+
wire: 'source',
|
|
314
|
+
description: 'an explicit install directory; absent means the configured first-party source.',
|
|
315
|
+
acceptsUndefined: true,
|
|
316
|
+
typeSymbol: PACKAGE + '#' + NAMESPACE + '/install:source',
|
|
317
|
+
strictTypeSymbol: PACKAGE + '#' + NAMESPACE + '/install:source',
|
|
318
|
+
schema: OPTIONAL_STRING,
|
|
319
|
+
},
|
|
320
|
+
],
|
|
321
|
+
result: {
|
|
322
|
+
typeSymbol: PACKAGE + '#' + NAMESPACE + '/install:result',
|
|
323
|
+
description: 'the installed extension; installation is not activation.',
|
|
324
|
+
schema: INSTALL_RESULT,
|
|
325
|
+
},
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
method: 'enable',
|
|
329
|
+
description: 'Activate an installed extension (removes it from `disabledExtensions`).',
|
|
330
|
+
parameters: [
|
|
331
|
+
{
|
|
332
|
+
name: 'id',
|
|
333
|
+
wire: 'id',
|
|
334
|
+
description: 'the extension id to activate.',
|
|
335
|
+
acceptsUndefined: false,
|
|
336
|
+
typeSymbol: PACKAGE + '#' + NAMESPACE + '/enable:id',
|
|
337
|
+
strictTypeSymbol: PACKAGE + '#' + NAMESPACE + '/enable:id',
|
|
338
|
+
schema: STRING,
|
|
339
|
+
},
|
|
340
|
+
],
|
|
341
|
+
result: {
|
|
342
|
+
typeSymbol: PACKAGE + '#' + NAMESPACE + '/enable:result',
|
|
343
|
+
description: 'the extension state after activation.',
|
|
344
|
+
schema: TOGGLE_RESULT,
|
|
345
|
+
},
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
method: 'disable',
|
|
349
|
+
description: 'Deactivate an extension (adds it to `disabledExtensions`).',
|
|
350
|
+
parameters: [
|
|
351
|
+
{
|
|
352
|
+
name: 'id',
|
|
353
|
+
wire: 'id',
|
|
354
|
+
description: 'the extension id to deactivate.',
|
|
355
|
+
acceptsUndefined: false,
|
|
356
|
+
typeSymbol: PACKAGE + '#' + NAMESPACE + '/disable:id',
|
|
357
|
+
strictTypeSymbol: PACKAGE + '#' + NAMESPACE + '/disable:id',
|
|
358
|
+
schema: STRING,
|
|
359
|
+
},
|
|
360
|
+
],
|
|
361
|
+
result: {
|
|
362
|
+
typeSymbol: PACKAGE + '#' + NAMESPACE + '/disable:result',
|
|
363
|
+
description: 'the extension state after deactivation.',
|
|
364
|
+
schema: TOGGLE_RESULT,
|
|
365
|
+
},
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
method: 'prepare',
|
|
369
|
+
description: 'Acquire and verify the installed extension\'s model assets, then record the readiness a following enable needs.',
|
|
370
|
+
parameters: [
|
|
371
|
+
{
|
|
372
|
+
name: 'id',
|
|
373
|
+
wire: 'id',
|
|
374
|
+
description: 'the installed extension id to prepare.',
|
|
375
|
+
acceptsUndefined: false,
|
|
376
|
+
typeSymbol: PACKAGE + '#' + NAMESPACE + '/prepare:id',
|
|
377
|
+
strictTypeSymbol: PACKAGE + '#' + NAMESPACE + '/prepare:id',
|
|
378
|
+
schema: STRING,
|
|
379
|
+
},
|
|
380
|
+
],
|
|
381
|
+
result: {
|
|
382
|
+
typeSymbol: PACKAGE + '#' + NAMESPACE + '/prepare:result',
|
|
383
|
+
description: 'the preparation outcome, its RES-02 disclosure, and the readiness recorded for each declared model.',
|
|
384
|
+
schema: PREPARE_RESULT,
|
|
385
|
+
},
|
|
386
|
+
},
|
|
387
|
+
]
|
|
388
|
+
|
|
389
|
+
/** The mountable Client contribution (and the Host artifact's invocation source). */
|
|
390
|
+
export function buildContribution() {
|
|
391
|
+
return {
|
|
392
|
+
package: PACKAGE,
|
|
393
|
+
descriptors: descriptorsFromModelToolsSpecs(PACKAGE, SERVICE, NAMESPACE, METHOD_SPECS),
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/** Host documentation for the methods, kept beside their specs. */
|
|
398
|
+
const SERVICE_MODEL = {
|
|
399
|
+
description: 'Host service backing the generated `ctx.remote.modelTools` namespace. It reports the extension store truthfully (store null when unconfigured), performs staged installs, persisted enable/disable, and model-asset preparation with the RES-02 disclosure.',
|
|
400
|
+
summary: 'Host service backing the generated `ctx.remote.modelTools` namespace.',
|
|
401
|
+
tags: [],
|
|
402
|
+
jsDoc: '/** Host service backing the generated `ctx.remote.modelTools` namespace. */',
|
|
403
|
+
key: SERVICE,
|
|
404
|
+
exportName: 'ExtensionsService',
|
|
405
|
+
members: METHOD_SPECS.map((spec) => ({
|
|
406
|
+
kind: 'method',
|
|
407
|
+
name: spec.implementation ?? spec.method,
|
|
408
|
+
signature: spec.method === 'describe'
|
|
409
|
+
? 'describe(signal?: AbortSignal): Promise<ExtensionsDescribeResult>'
|
|
410
|
+
: spec.method === 'installExtension'
|
|
411
|
+
? 'install(id: string, source?: string, signal?: AbortSignal): Promise<ExtensionInstallResult>'
|
|
412
|
+
: spec.method === 'prepare'
|
|
413
|
+
? 'prepare(id: string, signal?: AbortSignal): Promise<ExtensionPrepareResult>'
|
|
414
|
+
: `${spec.method}(id: string, signal?: AbortSignal): Promise<ExtensionToggleResult>`,
|
|
415
|
+
description: spec.description,
|
|
416
|
+
jsDoc: `/** ${spec.description} */`,
|
|
417
|
+
})),
|
|
418
|
+
types: [],
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* Build the Host Loader manifest the `typert-loader` validates and registers.
|
|
423
|
+
* @returns `TYPERT` host-face contribution.
|
|
424
|
+
*/
|
|
425
|
+
export function buildHostManifest() {
|
|
426
|
+
return {
|
|
427
|
+
package: PACKAGE,
|
|
428
|
+
face: 'host',
|
|
429
|
+
schemas: [],
|
|
430
|
+
get invocations() {
|
|
431
|
+
return buildContribution().descriptors
|
|
432
|
+
},
|
|
433
|
+
model: {
|
|
434
|
+
services: [SERVICE_MODEL],
|
|
435
|
+
events: [],
|
|
436
|
+
objects: [],
|
|
437
|
+
},
|
|
438
|
+
}
|
|
439
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host Loader face of the `modelTools` Remote namespace (`./typert` export).
|
|
3
|
+
*
|
|
4
|
+
* `@deepseek-ai/dsh-typert-loader` imports this module for the `model-tools`
|
|
5
|
+
* Loader entry, validates the manifest, and registers `TYPERT.invocations` in
|
|
6
|
+
* the Host Typert registry, where the Gateway dispatches them. The descriptors
|
|
7
|
+
* come from `./spec.mjs`, the same source the Client artifact and the browser
|
|
8
|
+
* chunk are built from.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { buildHostManifest } from './spec.mjs'
|
|
12
|
+
|
|
13
|
+
/** Host contribution registered by the Typert loader. */
|
|
14
|
+
export const TYPERT = buildHostManifest()
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client face of the `modelTools` Remote namespace (`./remote` export).
|
|
3
|
+
*
|
|
4
|
+
* A standard DSH Client assembly imports this module and mounts it through
|
|
5
|
+
* `ctx.remote.$mount(...)`; this plugin's own browser half mounts the same
|
|
6
|
+
* contribution from its package-local lazy-CJS chunk
|
|
7
|
+
* (`client/client.model-tools.js`), because the client module system serves
|
|
8
|
+
* only `./client` for an installed plugin.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { buildContribution } from './spec.mjs'
|
|
12
|
+
|
|
13
|
+
/** Mountable contribution exposing `describe`, `installExtension`, `enable`, `disable`. */
|
|
14
|
+
export const TYPERT_REMOTE = buildContribution()
|
|
15
|
+
|
|
16
|
+
export default TYPERT_REMOTE
|
package/lib/adapters/tongue.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tongue adapter — on-device language identification for short text.
|
|
3
|
-
*
|
|
4
|
-
* Tongue is the one Desert Ant model that runs in plain Node on every platform:
|
|
5
|
-
* it is pure JavaScript with no WASM or inference runtime, and its 2 MB model
|
|
6
|
-
* ships inside the npm package. That makes it the reference adapter: the module
|
|
7
|
-
* is imported on first use, the loaded model is cached for the process, and the
|
|
8
|
-
* synchronous `detect()` is wrapped in the async tool contract.
|
|
9
|
-
*
|
|
10
|
-
* @module @try-works/dsh-model-as-tool/adapters/tongue
|
|
11
|
-
*/
|
|
12
|
-
import type { ModelCatalogEntry } from '../types.ts';
|
|
13
|
-
import { type ModelAdapter } from './types.ts';
|
|
14
|
-
/** The npm package this adapter knows how to call. */
|
|
15
|
-
export declare const TONGUE_PACKAGE = "@desert-ant-labs/tongue";
|
|
16
|
-
/**
|
|
17
|
-
* Build the Tongue adapter.
|
|
18
|
-
*
|
|
19
|
-
* The factory is keyed on the PACKAGE, not the catalog id: an adapter's job is to
|
|
20
|
-
* know how to call one SDK, so any catalog row bound to this package can share it.
|
|
21
|
-
* Keying on the model id instead would mean a second conforming implementation of
|
|
22
|
-
* the same contract could never be served — exactly the model-name switch BASE-02
|
|
23
|
-
* and EXT-01 exist to prevent.
|
|
24
|
-
*
|
|
25
|
-
* The model is loaded once and reused, because `Tongue.load()` parses the bundled
|
|
26
|
-
* 2 MB weight file and detection afterwards is synchronous.
|
|
27
|
-
* @param entry - the catalog entry this adapter serves.
|
|
28
|
-
* @returns the adapter, or undefined if the entry does not use this SDK.
|
|
29
|
-
*/
|
|
30
|
-
export declare function createTongueAdapter(entry: ModelCatalogEntry): ModelAdapter | undefined;
|
|
31
|
-
//# sourceMappingURL=tongue.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tongue.d.ts","sourceRoot":"","sources":["../../src/adapters/tongue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EAKL,KAAK,YAAY,EAClB,MAAM,YAAY,CAAA;AAwBnB,sDAAsD;AACtD,eAAO,MAAM,cAAc,4BAA4B,CAAA;AAMvD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,iBAAiB,GAAG,YAAY,GAAG,SAAS,CAwDtF"}
|
package/lib/adapters/tongue.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tongue adapter — on-device language identification for short text.
|
|
3
|
-
*
|
|
4
|
-
* Tongue is the one Desert Ant model that runs in plain Node on every platform:
|
|
5
|
-
* it is pure JavaScript with no WASM or inference runtime, and its 2 MB model
|
|
6
|
-
* ships inside the npm package. That makes it the reference adapter: the module
|
|
7
|
-
* is imported on first use, the loaded model is cached for the process, and the
|
|
8
|
-
* synchronous `detect()` is wrapped in the async tool contract.
|
|
9
|
-
*
|
|
10
|
-
* @module @try-works/dsh-model-as-tool/adapters/tongue
|
|
11
|
-
*/
|
|
12
|
-
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
13
|
-
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
14
|
-
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
15
|
-
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
return path;
|
|
19
|
-
};
|
|
20
|
-
import { optionalInteger, requireString, throwIfAborted, } from "./types.js";
|
|
21
|
-
/** The npm package this adapter knows how to call. */
|
|
22
|
-
export const TONGUE_PACKAGE = '@desert-ant-labs/tongue';
|
|
23
|
-
/** Default number of runner-up candidates reported to the model. */
|
|
24
|
-
const DEFAULT_TOP = 3;
|
|
25
|
-
const MAX_TOP = 20;
|
|
26
|
-
/**
|
|
27
|
-
* Build the Tongue adapter.
|
|
28
|
-
*
|
|
29
|
-
* The factory is keyed on the PACKAGE, not the catalog id: an adapter's job is to
|
|
30
|
-
* know how to call one SDK, so any catalog row bound to this package can share it.
|
|
31
|
-
* Keying on the model id instead would mean a second conforming implementation of
|
|
32
|
-
* the same contract could never be served — exactly the model-name switch BASE-02
|
|
33
|
-
* and EXT-01 exist to prevent.
|
|
34
|
-
*
|
|
35
|
-
* The model is loaded once and reused, because `Tongue.load()` parses the bundled
|
|
36
|
-
* 2 MB weight file and detection afterwards is synchronous.
|
|
37
|
-
* @param entry - the catalog entry this adapter serves.
|
|
38
|
-
* @returns the adapter, or undefined if the entry does not use this SDK.
|
|
39
|
-
*/
|
|
40
|
-
export function createTongueAdapter(entry) {
|
|
41
|
-
if (entry.npmPackage !== TONGUE_PACKAGE)
|
|
42
|
-
return undefined;
|
|
43
|
-
let loaded;
|
|
44
|
-
const load = async () => {
|
|
45
|
-
loaded ??= (async () => {
|
|
46
|
-
try {
|
|
47
|
-
// A dynamic import keyed off a variable keeps this out of the module
|
|
48
|
-
// graph until the tool is actually called: the package is an optional
|
|
49
|
-
// dependency, so a static import would break installs that skip it.
|
|
50
|
-
const specifier = entry.npmPackage;
|
|
51
|
-
const module = await import(__rewriteRelativeImportExtension(specifier));
|
|
52
|
-
return await module.Tongue.load();
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
// Clear the cache so a transient failure (or a later install) can be
|
|
56
|
-
// retried by the next call rather than poisoning the tool for the life
|
|
57
|
-
// of the plugin.
|
|
58
|
-
loaded = undefined;
|
|
59
|
-
throw new Error(`Tongue could not be loaded: ${error instanceof Error ? error.message : String(error)}`);
|
|
60
|
-
}
|
|
61
|
-
})();
|
|
62
|
-
return loaded;
|
|
63
|
-
};
|
|
64
|
-
return {
|
|
65
|
-
modelId: entry.id,
|
|
66
|
-
async invoke({ args, signal }) {
|
|
67
|
-
throwIfAborted(signal);
|
|
68
|
-
const text = requireString(args, 'text');
|
|
69
|
-
const top = optionalInteger(args, 'top', { min: 1, max: MAX_TOP, fallback: DEFAULT_TOP });
|
|
70
|
-
const tongue = await load();
|
|
71
|
-
throwIfAborted(signal);
|
|
72
|
-
const detection = tongue.detect(text);
|
|
73
|
-
const candidates = (detection.candidates ?? []).slice(0, top);
|
|
74
|
-
return {
|
|
75
|
-
language: detection.language,
|
|
76
|
-
reliability: detection.reliability ?? 'unknown',
|
|
77
|
-
isTooCloseToCall: detection.isTooCloseToCall ?? false,
|
|
78
|
-
candidates: candidates.map(candidate => ({
|
|
79
|
-
language: candidate.language,
|
|
80
|
-
probability: candidate.probability,
|
|
81
|
-
})),
|
|
82
|
-
};
|
|
83
|
-
},
|
|
84
|
-
async dispose() {
|
|
85
|
-
if (loaded === undefined)
|
|
86
|
-
return;
|
|
87
|
-
const instance = await loaded.catch(() => undefined);
|
|
88
|
-
instance?.dispose?.();
|
|
89
|
-
loaded = undefined;
|
|
90
|
-
},
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
//# sourceMappingURL=tongue.js.map
|
package/lib/adapters/voz.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Voz adapter — on-device speech recognition with word timestamps.
|
|
3
|
-
*
|
|
4
|
-
* Voz has no prebuilt Node core; it runs the same WebAssembly/ONNX Runtime
|
|
5
|
-
* pipeline everywhere and requires the caller to hand it an ONNX Runtime
|
|
6
|
-
* module. `onnxruntime-node` ships win32-x64 binaries, which is what makes Voz
|
|
7
|
-
* the one audio model that works on Windows.
|
|
8
|
-
*
|
|
9
|
-
* Loading is expensive (the weights are ~349 MB and ONNX Runtime compiles three
|
|
10
|
-
* graphs), so the instance is cached for the process and reused.
|
|
11
|
-
*
|
|
12
|
-
* @module @try-works/dsh-model-as-tool/adapters/voz
|
|
13
|
-
*/
|
|
14
|
-
import type { ModelCatalogEntry } from '../types.ts';
|
|
15
|
-
import { type ModelAdapter } from './types.ts';
|
|
16
|
-
/** The npm package this adapter knows how to call. */
|
|
17
|
-
export declare const VOZ_PACKAGE = "@desert-ant-labs/voz";
|
|
18
|
-
/**
|
|
19
|
-
* Build the Voz adapter.
|
|
20
|
-
*
|
|
21
|
-
* Keyed on the package rather than the catalog id, for the same reason as the
|
|
22
|
-
* Tongue adapter: the adapter knows an SDK, so any catalog row bound to it can be
|
|
23
|
-
* served, which is what lets a second implementation join the contract.
|
|
24
|
-
* @param entry - the catalog entry this adapter serves.
|
|
25
|
-
* @returns the adapter, or undefined if the entry does not use this SDK.
|
|
26
|
-
*/
|
|
27
|
-
export declare function createVozAdapter(entry: ModelCatalogEntry): ModelAdapter | undefined;
|
|
28
|
-
//# sourceMappingURL=voz.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"voz.d.ts","sourceRoot":"","sources":["../../src/adapters/voz.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EAKL,KAAK,YAAY,EAClB,MAAM,YAAY,CAAA;AAgCnB,sDAAsD;AACtD,eAAO,MAAM,WAAW,yBAAyB,CAAA;AAKjD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,GAAG,YAAY,GAAG,SAAS,CAsEnF"}
|