@try-works/dsh-model-as-tool 0.1.2 → 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/lang-detect.d.ts +16 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/lang-detect.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/lang-detect.js +85 -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/stt-transcribe.d.ts +20 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/stt-transcribe.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/contracts/stt-transcribe.js +112 -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 +82 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/dsh.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/dsh.js +274 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/index.d.ts +26 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/index.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/index.js +48 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/meta.d.ts +104 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/meta.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/meta.js +55 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/registry.d.ts +107 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/registry.d.ts.map +1 -0
- package/node_modules/@try-works/tool-mode-contracts/lib/registry.js +246 -0
- package/node_modules/@try-works/tool-mode-contracts/package.json +34 -0
- 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 +50 -17
- 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
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `stt.transcribe` — the canonical transcription contract (TOOL-01).
|
|
3
|
+
*
|
|
4
|
+
* This contract is model-free on purpose. Any conforming implementation binds to
|
|
5
|
+
* it, so a caller addresses `stt_transcribe` once and the host decides which
|
|
6
|
+
* model runs (BASE-02). Adding a second transcription model must not add a
|
|
7
|
+
* second tool.
|
|
8
|
+
*
|
|
9
|
+
* The semantics block is the part a schema cannot express and the part the spec
|
|
10
|
+
* insists on (DECL-01, TOOL-01): whether this transcribes or translates, what
|
|
11
|
+
* the timestamps mean, and what an empty result means.
|
|
12
|
+
*
|
|
13
|
+
* @module @try-works/tool-mode-contracts/contracts/stt-transcribe
|
|
14
|
+
*/
|
|
15
|
+
import { withMeta } from "../meta.js";
|
|
16
|
+
/** Accepted audio container/codec combinations for the bounded decoder. */
|
|
17
|
+
export const STT_ADMITTED_FORMATS = ['wav-pcm16'];
|
|
18
|
+
/** The `stt.transcribe` contract at version 1.0.0. */
|
|
19
|
+
export const sttTranscribe = {
|
|
20
|
+
contract: 'stt.transcribe',
|
|
21
|
+
version: '1.0.0',
|
|
22
|
+
toolName: 'stt_transcribe',
|
|
23
|
+
description: 'Transcribe a local audio recording into text with optional word timestamps. '
|
|
24
|
+
+ 'Runs on device by default; the caller selects no model. Accepts 16 kHz mono PCM16 WAV '
|
|
25
|
+
+ 'directly, and other encodings only through a tested decoder. Reports partial coverage '
|
|
26
|
+
+ 'rather than presenting an incomplete clip as fully transcribed.',
|
|
27
|
+
inputSchema: {
|
|
28
|
+
type: 'object',
|
|
29
|
+
additionalProperties: false,
|
|
30
|
+
required: ['audio'],
|
|
31
|
+
properties: {
|
|
32
|
+
audio: {
|
|
33
|
+
type: 'object',
|
|
34
|
+
additionalProperties: false,
|
|
35
|
+
required: ['path'],
|
|
36
|
+
properties: {
|
|
37
|
+
path: { type: 'string', minLength: 1, description: 'Absolute path to the recording.' },
|
|
38
|
+
sampleRateHz: {
|
|
39
|
+
type: 'integer',
|
|
40
|
+
minimum: 8000,
|
|
41
|
+
maximum: 48000,
|
|
42
|
+
description: 'Declared sample rate; inspected against the file header, not trusted.',
|
|
43
|
+
},
|
|
44
|
+
channels: { type: 'integer', minimum: 1, maximum: 2 },
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
language: {
|
|
48
|
+
type: 'string',
|
|
49
|
+
minLength: 2,
|
|
50
|
+
description: 'Requested language as a BCP-47/ISO 639 code. An unsupported request is an error, never a silent fallback.',
|
|
51
|
+
},
|
|
52
|
+
timestamps: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
enum: ['none', 'word'],
|
|
55
|
+
default: 'none',
|
|
56
|
+
description: 'Word timestamps when requested; an implementation that cannot supply them must error rather than omit them.',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
outputSchema: withMeta({
|
|
61
|
+
text: { type: 'string' },
|
|
62
|
+
coverage: {
|
|
63
|
+
type: 'object',
|
|
64
|
+
additionalProperties: false,
|
|
65
|
+
required: ['complete', 'transcribedSeconds'],
|
|
66
|
+
properties: {
|
|
67
|
+
complete: { type: 'boolean' },
|
|
68
|
+
transcribedSeconds: { type: 'number', minimum: 0 },
|
|
69
|
+
totalSeconds: { type: ['number', 'null'], minimum: 0 },
|
|
70
|
+
reason: { type: ['string', 'null'] },
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
words: {
|
|
74
|
+
type: ['array', 'null'],
|
|
75
|
+
items: {
|
|
76
|
+
type: 'object',
|
|
77
|
+
additionalProperties: false,
|
|
78
|
+
required: ['text', 'start', 'end'],
|
|
79
|
+
properties: {
|
|
80
|
+
text: { type: 'string' },
|
|
81
|
+
start: { type: 'number', minimum: 0, description: 'Seconds from the start of the audio.' },
|
|
82
|
+
end: { type: 'number', minimum: 0 },
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
language: { type: ['string', 'null'], description: 'The language actually recognized, when the implementation reports it.' },
|
|
87
|
+
}, ['text', 'coverage']),
|
|
88
|
+
semantics: {
|
|
89
|
+
operation: 'transcription',
|
|
90
|
+
translation: false,
|
|
91
|
+
timestampUnit: 'seconds',
|
|
92
|
+
timestampReference: 'start-of-audio',
|
|
93
|
+
emptyResultMeaning: 'valid-empty-transcript',
|
|
94
|
+
partialResultMeaning: 'coverage.complete is false; the transcript is incomplete, not wrong',
|
|
95
|
+
languageMismatch: 'error',
|
|
96
|
+
unsupportedTimestampRequest: 'error',
|
|
97
|
+
},
|
|
98
|
+
limits: {
|
|
99
|
+
maxAudioSeconds: 3600,
|
|
100
|
+
maxAudioBytes: 512 * 1024 * 1024,
|
|
101
|
+
admittedSampleRateHz: 16000,
|
|
102
|
+
admittedChannels: 1,
|
|
103
|
+
},
|
|
104
|
+
unsupported: [
|
|
105
|
+
'Encoding without a tested decoder: only wav-pcm16 is admitted directly; assume nothing from the file extension.',
|
|
106
|
+
'Translation: this contract transcribes, it does not translate.',
|
|
107
|
+
'Diarization or speaker attribution: separate capability.',
|
|
108
|
+
'Timestamps when the selected implementation cannot produce them: reported as an error.',
|
|
109
|
+
'Live/streaming audio: the input is a completed local file.',
|
|
110
|
+
],
|
|
111
|
+
};
|
|
112
|
+
//# sourceMappingURL=stt-transcribe.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `text.embed` — the legacy MiniLM text-embedding contract (TOOL-04, BASE-12).
|
|
3
|
+
*
|
|
4
|
+
* Model-free: any conforming implementation binds to it. This is the 384-
|
|
5
|
+
* dimensional MiniLM space, PRESERVED separately from the EmbeddingGemma 2
|
|
6
|
+
* 768-dimensional space — the two must never be mixed, and a stored 384-d
|
|
7
|
+
* index must never be quietly fed 768-wide vectors.
|
|
8
|
+
*
|
|
9
|
+
* @module @try-works/tool-mode-contracts/contracts/text-embed
|
|
10
|
+
*/
|
|
11
|
+
import type { ToolContract } from '../registry.ts';
|
|
12
|
+
/** The `text.embed` contract at version 1.0.0. */
|
|
13
|
+
export declare const textEmbed: ToolContract;
|
|
14
|
+
//# sourceMappingURL=text-embed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-embed.d.ts","sourceRoot":"","sources":["../../src/contracts/text-embed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElD,kDAAkD;AAClD,eAAO,MAAM,SAAS,EAAE,YA0DvB,CAAA"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `text.embed` — the legacy MiniLM text-embedding contract (TOOL-04, BASE-12).
|
|
3
|
+
*
|
|
4
|
+
* Model-free: any conforming implementation binds to it. This is the 384-
|
|
5
|
+
* dimensional MiniLM space, PRESERVED separately from the EmbeddingGemma 2
|
|
6
|
+
* 768-dimensional space — the two must never be mixed, and a stored 384-d
|
|
7
|
+
* index must never be quietly fed 768-wide vectors.
|
|
8
|
+
*
|
|
9
|
+
* @module @try-works/tool-mode-contracts/contracts/text-embed
|
|
10
|
+
*/
|
|
11
|
+
import { withMeta } from "../meta.js";
|
|
12
|
+
/** The `text.embed` contract at version 1.0.0. */
|
|
13
|
+
export const textEmbed = {
|
|
14
|
+
contract: 'text.embed',
|
|
15
|
+
version: '1.0.0',
|
|
16
|
+
toolName: 'text_embed',
|
|
17
|
+
description: 'Embed a batch of texts into the legacy 384-dimensional MiniLM embedding space (mean pooling, '
|
|
18
|
+
+ 'L2-normalized, input order preserved). This is a compatibility space: stored 384-d vectors and '
|
|
19
|
+
+ 'indexes remain pinned to it, and switching to another model requires explicit re-embedding. '
|
|
20
|
+
+ 'All values are finite; an empty or overlong batch is refused, never silently truncated.',
|
|
21
|
+
inputSchema: {
|
|
22
|
+
type: 'object',
|
|
23
|
+
additionalProperties: false,
|
|
24
|
+
required: ['texts'],
|
|
25
|
+
properties: {
|
|
26
|
+
texts: {
|
|
27
|
+
type: 'array',
|
|
28
|
+
minItems: 1,
|
|
29
|
+
maxItems: 32,
|
|
30
|
+
items: { type: 'string', minLength: 1, maxLength: 32768 },
|
|
31
|
+
description: 'The texts in the caller\'s order; that order is the embedding order (TOOL-04).',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
outputSchema: withMeta({
|
|
36
|
+
embeddings: {
|
|
37
|
+
type: 'array',
|
|
38
|
+
items: {
|
|
39
|
+
type: 'array',
|
|
40
|
+
items: { type: 'number' },
|
|
41
|
+
description: 'One 384-dimensional L2-normalized vector per input text, in input order.',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
dimensions: { const: 384 },
|
|
45
|
+
normalized: { const: true },
|
|
46
|
+
}, ['embeddings', 'dimensions', 'normalized']),
|
|
47
|
+
semantics: {
|
|
48
|
+
scoreKind: 'none',
|
|
49
|
+
calibrated: false,
|
|
50
|
+
emptyInputMeaning: 'binding-error',
|
|
51
|
+
appliesTo: 'written-text-only',
|
|
52
|
+
},
|
|
53
|
+
limits: {
|
|
54
|
+
maxTexts: 32,
|
|
55
|
+
maxInputCharacters: 32768,
|
|
56
|
+
dimensions: 384,
|
|
57
|
+
},
|
|
58
|
+
unsupported: [
|
|
59
|
+
'Mixing 384-dimensional and 768-dimensional vectors in one index.',
|
|
60
|
+
'Silently truncating an overlong batch.',
|
|
61
|
+
],
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=text-embed.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `text.rerank` — the cross-encoder reranking contract (TOOL-05).
|
|
3
|
+
*
|
|
4
|
+
* Model-free: any conforming implementation binds to it. The scores are
|
|
5
|
+
* RANKING LOGITS from a cross-encoder — not embedding cosines, and the two
|
|
6
|
+
* score kinds are never interchangeable (the semantic_rank tool's
|
|
7
|
+
* cosine_similarity is a different quantity).
|
|
8
|
+
*
|
|
9
|
+
* @module @try-works/tool-mode-contracts/contracts/text-rerank
|
|
10
|
+
*/
|
|
11
|
+
import type { ToolContract } from '../registry.ts';
|
|
12
|
+
/** The `text.rerank` contract at version 1.0.0. */
|
|
13
|
+
export declare const textRerank: ToolContract;
|
|
14
|
+
//# sourceMappingURL=text-rerank.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-rerank.d.ts","sourceRoot":"","sources":["../../src/contracts/text-rerank.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElD,mDAAmD;AACnD,eAAO,MAAM,UAAU,EAAE,YAuExB,CAAA"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `text.rerank` — the cross-encoder reranking contract (TOOL-05).
|
|
3
|
+
*
|
|
4
|
+
* Model-free: any conforming implementation binds to it. The scores are
|
|
5
|
+
* RANKING LOGITS from a cross-encoder — not embedding cosines, and the two
|
|
6
|
+
* score kinds are never interchangeable (the semantic_rank tool's
|
|
7
|
+
* cosine_similarity is a different quantity).
|
|
8
|
+
*
|
|
9
|
+
* @module @try-works/tool-mode-contracts/contracts/text-rerank
|
|
10
|
+
*/
|
|
11
|
+
import { withMeta } from "../meta.js";
|
|
12
|
+
/** The `text.rerank` contract at version 1.0.0. */
|
|
13
|
+
export const textRerank = {
|
|
14
|
+
contract: 'text.rerank',
|
|
15
|
+
version: '1.0.0',
|
|
16
|
+
toolName: 'text_rerank',
|
|
17
|
+
description: 'Score query/document pairs with a cross-encoder and return the caller\'s own ids in descending '
|
|
18
|
+
+ 'ranking-logit order with exact ties broken by input order. The scores are cross-encoder '
|
|
19
|
+
+ 'logits (scoreKind "ranking_logit"), NOT embedding cosines: the two are not interchangeable. '
|
|
20
|
+
+ 'A positive top_k within the candidate count is required when supplied.',
|
|
21
|
+
inputSchema: {
|
|
22
|
+
type: 'object',
|
|
23
|
+
additionalProperties: false,
|
|
24
|
+
required: ['query', 'documents'],
|
|
25
|
+
properties: {
|
|
26
|
+
query: { type: 'string', minLength: 1, maxLength: 32768 },
|
|
27
|
+
documents: {
|
|
28
|
+
type: 'array',
|
|
29
|
+
minItems: 1,
|
|
30
|
+
maxItems: 256,
|
|
31
|
+
items: {
|
|
32
|
+
type: 'object',
|
|
33
|
+
additionalProperties: false,
|
|
34
|
+
required: ['id', 'text'],
|
|
35
|
+
properties: {
|
|
36
|
+
id: { type: 'string', minLength: 1, maxLength: 128 },
|
|
37
|
+
text: { type: 'string', minLength: 1, maxLength: 32768 },
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
description: 'The documents in the caller\'s order; that order breaks exact score ties (TOOL-05).',
|
|
41
|
+
},
|
|
42
|
+
top_k: { type: 'integer', minimum: 1, maximum: 256 },
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
outputSchema: withMeta({
|
|
46
|
+
results: {
|
|
47
|
+
type: 'array',
|
|
48
|
+
items: {
|
|
49
|
+
type: 'object',
|
|
50
|
+
additionalProperties: false,
|
|
51
|
+
required: ['id', 'score'],
|
|
52
|
+
properties: {
|
|
53
|
+
id: { type: 'string' },
|
|
54
|
+
score: { type: 'number' },
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
scoreKind: { const: 'ranking_logit' },
|
|
59
|
+
}, ['results', 'scoreKind']),
|
|
60
|
+
semantics: {
|
|
61
|
+
scoreKind: 'ranking-logit',
|
|
62
|
+
calibrated: false,
|
|
63
|
+
emptyInputMeaning: 'binding-error',
|
|
64
|
+
appliesTo: 'written-text-only',
|
|
65
|
+
},
|
|
66
|
+
limits: {
|
|
67
|
+
maxDocuments: 256,
|
|
68
|
+
maxInputCharacters: 32768,
|
|
69
|
+
maxTopK: 256,
|
|
70
|
+
},
|
|
71
|
+
unsupported: [
|
|
72
|
+
'Treating ranking logits as embedding cosines.',
|
|
73
|
+
'Negative or zero top_k when supplied.',
|
|
74
|
+
],
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=text-rerank.js.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Projection of a contract into DSH's parameter DSL (DECL-01).
|
|
3
|
+
*
|
|
4
|
+
* DECL-01 requires that DSH registration, MCP projection and Code Mode types all
|
|
5
|
+
* come from one source. The contract's JSON Schema is that source; this module is
|
|
6
|
+
* the DSH-specific projection of it.
|
|
7
|
+
*
|
|
8
|
+
* It replaces the old registrar behaviour that inferred the required input from
|
|
9
|
+
* parameter ORDER (BASE-04). Requiredness now comes from the schema's `required`
|
|
10
|
+
* array, so a contract cannot silently change meaning when a property is
|
|
11
|
+
* reordered.
|
|
12
|
+
*
|
|
13
|
+
* @module @try-works/tool-mode-contracts/dsh
|
|
14
|
+
*/
|
|
15
|
+
import type { ToolContract } from './registry.ts';
|
|
16
|
+
/** One DSH parameter property: a JSON-Schema subset plus `required`. */
|
|
17
|
+
type DshProperty = Record<string, unknown> & {
|
|
18
|
+
required?: true;
|
|
19
|
+
};
|
|
20
|
+
/** The implicit-open-object parameter map DSH expects. */
|
|
21
|
+
export type DshParameters = Record<string, DshProperty>;
|
|
22
|
+
/** The result of projecting a contract into DSH's narrower DSL. */
|
|
23
|
+
export interface DshProjection {
|
|
24
|
+
/** What the model-facing parameter schema advertises. */
|
|
25
|
+
readonly parameters: DshParameters;
|
|
26
|
+
/**
|
|
27
|
+
* Contract keywords the parameter schema cannot advertise, in `path.keyword`
|
|
28
|
+
* form. They remain enforced at runtime against the full contract schema.
|
|
29
|
+
*/
|
|
30
|
+
readonly runtimeEnforced: readonly string[];
|
|
31
|
+
}
|
|
32
|
+
/** Raised when a contract uses a schema shape the DSH DSL cannot express. */
|
|
33
|
+
export declare class ProjectionError extends Error {
|
|
34
|
+
readonly name = "ProjectionError";
|
|
35
|
+
readonly unsupported: readonly string[];
|
|
36
|
+
constructor(contract: string, unsupported: readonly string[]);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Project a contract's input schema into DSH parameters.
|
|
40
|
+
*
|
|
41
|
+
* DSH's DSL is narrower than JSON Schema — it has no `minLength`, `minimum` or
|
|
42
|
+
* `pattern` at any nesting level — so the projection is deliberately lossy in what
|
|
43
|
+
* it ADVERTISES while remaining complete in what it ENFORCES. BASE-04 forbids
|
|
44
|
+
* silently discarding a constraint, so every keyword left out is returned in
|
|
45
|
+
* {@link DshProjection.runtimeEnforced} and is checked by `assertValidInput`
|
|
46
|
+
* against the untouched contract.
|
|
47
|
+
* @param contract - the contract to project.
|
|
48
|
+
* @returns the parameter map plus the keywords enforced only at runtime.
|
|
49
|
+
*/
|
|
50
|
+
export declare function projectToDsh(contract: ToolContract): DshProjection;
|
|
51
|
+
/**
|
|
52
|
+
* Project a contract's input schema into DSH parameters.
|
|
53
|
+
* @param contract - the contract to project.
|
|
54
|
+
* @returns the parameter map.
|
|
55
|
+
* @throws ProjectionError when the schema is internally inconsistent.
|
|
56
|
+
*/
|
|
57
|
+
export declare function toDshParameters(contract: ToolContract): DshParameters;
|
|
58
|
+
/**
|
|
59
|
+
* Cross-field constraints the DSH parameter DSL cannot express (BASE-04).
|
|
60
|
+
*
|
|
61
|
+
* Each returns a violation message, or undefined when the arguments are
|
|
62
|
+
* acceptable. They run after schema validation, so each may assume its fields
|
|
63
|
+
* are present and correctly typed.
|
|
64
|
+
*/
|
|
65
|
+
export type CrossFieldRule = (args: Record<string, unknown>) => string | undefined;
|
|
66
|
+
/** The cross-field rules that apply to a given contract. */
|
|
67
|
+
export declare function crossFieldRules(contract: ToolContract): CrossFieldRule[];
|
|
68
|
+
/**
|
|
69
|
+
* Project an arbitrary JSON Schema into the subset DSH can advertise (DECL-02).
|
|
70
|
+
*
|
|
71
|
+
* Written for the OUTPUT schema, which needs the same treatment the input schema
|
|
72
|
+
* already gets. Using the contract's raw output schema would crash registration on the
|
|
73
|
+
* first keyword the DSL cannot express — the failure that produced `runtimeEnforced` in
|
|
74
|
+
* the first place — and using an unconstrained `{type: "object", additionalProperties:
|
|
75
|
+
* true}` instead, which is what this replaced, publishes a tool whose result shape is
|
|
76
|
+
* declared to be anything at all.
|
|
77
|
+
* @param schema - the schema to project.
|
|
78
|
+
* @returns the projected schema plus the keywords left to runtime enforcement.
|
|
79
|
+
*/
|
|
80
|
+
export declare function projectSchemaToDsh(schema: Readonly<Record<string, unknown>>): DshProjection;
|
|
81
|
+
export {};
|
|
82
|
+
//# sourceMappingURL=dsh.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dsh.d.ts","sourceRoot":"","sources":["../src/dsh.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD,wEAAwE;AACxE,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,IAAI,CAAA;CAAE,CAAA;AAEhE,0DAA0D;AAC1D,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;AAEvD,mEAAmE;AACnE,MAAM,WAAW,aAAa;IAC5B,yDAAyD;IACzD,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAA;IAClC;;;OAGG;IACH,QAAQ,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAA;CAC5C;AAED,6EAA6E;AAC7E,qBAAa,eAAgB,SAAQ,KAAK;IACxC,SAAkB,IAAI,qBAAoB;IAC1C,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAA;gBAC3B,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,MAAM,EAAE;CAO7D;AAuHD;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,YAAY,GAAG,aAAa,CAuBlE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,YAAY,GAAG,aAAa,CAErE;AAED;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,GAAG,SAAS,CAAA;AAElF,4DAA4D;AAC5D,wBAAgB,eAAe,CAAC,QAAQ,EAAE,YAAY,GAAG,cAAc,EAAE,CAqCxE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,aAAa,CAiB3F"}
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Projection of a contract into DSH's parameter DSL (DECL-01).
|
|
3
|
+
*
|
|
4
|
+
* DECL-01 requires that DSH registration, MCP projection and Code Mode types all
|
|
5
|
+
* come from one source. The contract's JSON Schema is that source; this module is
|
|
6
|
+
* the DSH-specific projection of it.
|
|
7
|
+
*
|
|
8
|
+
* It replaces the old registrar behaviour that inferred the required input from
|
|
9
|
+
* parameter ORDER (BASE-04). Requiredness now comes from the schema's `required`
|
|
10
|
+
* array, so a contract cannot silently change meaning when a property is
|
|
11
|
+
* reordered.
|
|
12
|
+
*
|
|
13
|
+
* @module @try-works/tool-mode-contracts/dsh
|
|
14
|
+
*/
|
|
15
|
+
/** Raised when a contract uses a schema shape the DSH DSL cannot express. */
|
|
16
|
+
export class ProjectionError extends Error {
|
|
17
|
+
name = 'ProjectionError';
|
|
18
|
+
unsupported;
|
|
19
|
+
constructor(contract, unsupported) {
|
|
20
|
+
super(`${contract} cannot be projected into the DSH parameter DSL: ${unsupported.join('; ')}. `
|
|
21
|
+
+ 'Weakening the schema silently is not permitted (BASE-04), so the contract must be reshaped.');
|
|
22
|
+
this.unsupported = unsupported;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* JSON-Schema keywords the DSH value-schema DSL can carry.
|
|
27
|
+
*
|
|
28
|
+
* Anything outside this set is not DISCARDED: it stays in the contract and is
|
|
29
|
+
* enforced at runtime by {@link assertValidInput}, which validates arguments
|
|
30
|
+
* against the full contract schema before the implementation runs. This module
|
|
31
|
+
* only decides what the model-facing parameter schema advertises.
|
|
32
|
+
*/
|
|
33
|
+
const DSH_SUPPORTED = new Set([
|
|
34
|
+
'type', 'enum', 'const', 'description', 'default', 'examples',
|
|
35
|
+
'items', 'properties', 'additionalProperties', 'required',
|
|
36
|
+
]);
|
|
37
|
+
/**
|
|
38
|
+
* Project one JSON-Schema node into the subset DSH can carry.
|
|
39
|
+
*
|
|
40
|
+
* Recursive because DSH validates nested object properties too, so a constraint
|
|
41
|
+
* on `audio.path` reaches the same DSL limit as one on a top-level property.
|
|
42
|
+
* @param node - the schema node to project.
|
|
43
|
+
* @param path - dotted path for reporting what was left out.
|
|
44
|
+
* @param runtimeEnforced - accumulates `path.keyword` entries.
|
|
45
|
+
* @returns the projected node.
|
|
46
|
+
*/
|
|
47
|
+
function projectNode(node, path, runtimeEnforced) {
|
|
48
|
+
const out = {};
|
|
49
|
+
/**
|
|
50
|
+
* Requiredness is expressed PER PROPERTY, at every nesting level.
|
|
51
|
+
*
|
|
52
|
+
* DSH's value schema DSL does not admit a `required` array anywhere — it rejected
|
|
53
|
+
* `schema.required` at the root and `items.required` inside an array — so the list is
|
|
54
|
+
* folded into `required: true` on each named property, which the DSL does understand.
|
|
55
|
+
* Doing it here rather than at the root is what makes it work at depth: an output
|
|
56
|
+
* schema's array items have required fields of their own.
|
|
57
|
+
*/
|
|
58
|
+
const requiredNames = new Set(node.required ?? []);
|
|
59
|
+
for (const [keyword, value] of Object.entries(node)) {
|
|
60
|
+
if (!DSH_SUPPORTED.has(keyword)) {
|
|
61
|
+
runtimeEnforced.push(`${path}.${keyword}`);
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
// Handled through `properties` above; the DSL has no array form.
|
|
65
|
+
if (keyword === 'required')
|
|
66
|
+
continue;
|
|
67
|
+
if (keyword === 'properties' && typeof value === 'object' && value !== null) {
|
|
68
|
+
const nested = {};
|
|
69
|
+
for (const [name, child] of Object.entries(value)) {
|
|
70
|
+
const projected = typeof child === 'object' && child !== null
|
|
71
|
+
? projectNode(child, `${path}.${name}`, runtimeEnforced)
|
|
72
|
+
: child;
|
|
73
|
+
nested[name] = requiredNames.has(name) && typeof projected === 'object' && projected !== null
|
|
74
|
+
? { ...projected, required: true }
|
|
75
|
+
: projected;
|
|
76
|
+
}
|
|
77
|
+
out[keyword] = nested;
|
|
78
|
+
}
|
|
79
|
+
else if (keyword === 'items' && typeof value === 'object' && value !== null) {
|
|
80
|
+
out[keyword] = projectNode(value, `${path}[]`, runtimeEnforced);
|
|
81
|
+
}
|
|
82
|
+
else if (keyword === 'type' && Array.isArray(value)) {
|
|
83
|
+
/**
|
|
84
|
+
* A union `type` array is advertised as `type: 'json'` (unconstrained), NOT
|
|
85
|
+
* narrowed to one member.
|
|
86
|
+
*
|
|
87
|
+
* An earlier version advertised the concrete non-null member, which made the
|
|
88
|
+
* advertised schema STRICTER than the contract: `{ type: ['string','null'] }`
|
|
89
|
+
* was projected to `type: 'string'`, and the registry VALIDATES success values
|
|
90
|
+
* against the advertised schema, so a legitimate null result was rejected.
|
|
91
|
+
* Dropping the type entirely also fails: the DSL requires every property to
|
|
92
|
+
* have a type or oneOf. `type: 'json'` is the loosest the DSL accepts, it is
|
|
93
|
+
* strictly looser than any union, and the runtime contract check still enforces
|
|
94
|
+
* the union itself.
|
|
95
|
+
*/
|
|
96
|
+
runtimeEnforced.push(`${path}.type(union -> json)`);
|
|
97
|
+
out.type = 'json';
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
out[keyword] = value;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Post-pass the DSL rejects but projectNode would otherwise emit:
|
|
105
|
+
*
|
|
106
|
+
* - `type: 'json'` cannot carry `items`/`enum`/`const` siblings, so a union-typed
|
|
107
|
+
* array whose element schema (or scalar constraints) survived the pass is
|
|
108
|
+
* stripped HERE, with the keyword recorded rather than silently lost.
|
|
109
|
+
* - A NON-SCALAR `enum` is dropped everywhere: the DSL requires "a non-empty array
|
|
110
|
+
* of scalar values", and the confidence contract (DECL-04) enumerates OBJECT
|
|
111
|
+
* members to distinguish vendor-reported from calibrated from unavailable.
|
|
112
|
+
* Membership is still enforced at runtime against the untouched contract.
|
|
113
|
+
* - An annotation-only node (every keyword dropped to runtimeEnforced) has no
|
|
114
|
+
* `type`/`oneOf`, which the DSL rejects; advertising `type: 'json'` keeps it
|
|
115
|
+
* strictly looser than the original instead of crashing registration.
|
|
116
|
+
*/
|
|
117
|
+
if (out.type === undefined && out.oneOf === undefined) {
|
|
118
|
+
runtimeEnforced.push(`${path}.type(annotation-only -> json)`);
|
|
119
|
+
out.type = 'json';
|
|
120
|
+
}
|
|
121
|
+
if (out.type === 'json') {
|
|
122
|
+
for (const sibling of ['items', 'enum', 'const']) {
|
|
123
|
+
if (sibling in out) {
|
|
124
|
+
runtimeEnforced.push(`${path}.${sibling}`);
|
|
125
|
+
delete out[sibling];
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (out.type !== 'json' && Array.isArray(out.enum) && !out.enum.every(member => isScalar(member))) {
|
|
130
|
+
runtimeEnforced.push(`${path}.enum`);
|
|
131
|
+
delete out.enum;
|
|
132
|
+
}
|
|
133
|
+
return out;
|
|
134
|
+
}
|
|
135
|
+
/** A scalar the DSL's `enum` admits. */
|
|
136
|
+
function isScalar(member) {
|
|
137
|
+
return typeof member === 'string' || typeof member === 'number' || typeof member === 'boolean';
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Project a contract's input schema into DSH parameters.
|
|
141
|
+
*
|
|
142
|
+
* DSH's DSL is narrower than JSON Schema — it has no `minLength`, `minimum` or
|
|
143
|
+
* `pattern` at any nesting level — so the projection is deliberately lossy in what
|
|
144
|
+
* it ADVERTISES while remaining complete in what it ENFORCES. BASE-04 forbids
|
|
145
|
+
* silently discarding a constraint, so every keyword left out is returned in
|
|
146
|
+
* {@link DshProjection.runtimeEnforced} and is checked by `assertValidInput`
|
|
147
|
+
* against the untouched contract.
|
|
148
|
+
* @param contract - the contract to project.
|
|
149
|
+
* @returns the parameter map plus the keywords enforced only at runtime.
|
|
150
|
+
*/
|
|
151
|
+
export function projectToDsh(contract) {
|
|
152
|
+
const schema = contract.inputSchema;
|
|
153
|
+
const properties = schema.properties ?? {};
|
|
154
|
+
const required = new Set(schema.required ?? []);
|
|
155
|
+
const runtimeEnforced = [];
|
|
156
|
+
const out = {};
|
|
157
|
+
for (const [name, property] of Object.entries(properties)) {
|
|
158
|
+
const projected = projectNode(property, name, runtimeEnforced);
|
|
159
|
+
if (required.has(name))
|
|
160
|
+
projected.required = true;
|
|
161
|
+
out[name] = projected;
|
|
162
|
+
}
|
|
163
|
+
// A required property that is not declared cannot be satisfied by any caller.
|
|
164
|
+
const undeclared = [...required].filter(name => !(name in properties));
|
|
165
|
+
if (undeclared.length > 0) {
|
|
166
|
+
throw new ProjectionError(contract.contract, undeclared.map(name => `required property "${name}" is not declared`));
|
|
167
|
+
}
|
|
168
|
+
return { parameters: out, runtimeEnforced };
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Project a contract's input schema into DSH parameters.
|
|
172
|
+
* @param contract - the contract to project.
|
|
173
|
+
* @returns the parameter map.
|
|
174
|
+
* @throws ProjectionError when the schema is internally inconsistent.
|
|
175
|
+
*/
|
|
176
|
+
export function toDshParameters(contract) {
|
|
177
|
+
return projectToDsh(contract).parameters;
|
|
178
|
+
}
|
|
179
|
+
/** The cross-field rules that apply to a given contract. */
|
|
180
|
+
export function crossFieldRules(contract) {
|
|
181
|
+
switch (contract.contract) {
|
|
182
|
+
case 'stt.transcribe':
|
|
183
|
+
return [
|
|
184
|
+
(args) => {
|
|
185
|
+
const timestamps = args.timestamps;
|
|
186
|
+
if (timestamps === 'word' && args.language === undefined) {
|
|
187
|
+
// Not a hard error, but a caller asking for word timing without
|
|
188
|
+
// declaring a language gets worse results on code-switched audio.
|
|
189
|
+
return undefined;
|
|
190
|
+
}
|
|
191
|
+
return undefined;
|
|
192
|
+
},
|
|
193
|
+
(args) => {
|
|
194
|
+
const audio = args.audio;
|
|
195
|
+
if (audio?.channels !== undefined && audio.channels !== 1) {
|
|
196
|
+
return 'audio.channels must be 1: the admitted input is 16 kHz mono';
|
|
197
|
+
}
|
|
198
|
+
if (audio?.sampleRateHz !== undefined && audio.sampleRateHz !== 16000) {
|
|
199
|
+
return 'audio.sampleRateHz must be 16000: resampling is not part of this contract';
|
|
200
|
+
}
|
|
201
|
+
return undefined;
|
|
202
|
+
},
|
|
203
|
+
];
|
|
204
|
+
case 'text.language_detect':
|
|
205
|
+
return [
|
|
206
|
+
(args) => {
|
|
207
|
+
const text = args.text;
|
|
208
|
+
if (typeof text === 'string' && text.trim().length === 0) {
|
|
209
|
+
return 'text must contain at least one non-whitespace character';
|
|
210
|
+
}
|
|
211
|
+
return undefined;
|
|
212
|
+
},
|
|
213
|
+
];
|
|
214
|
+
default:
|
|
215
|
+
return [];
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Project an arbitrary JSON Schema into the subset DSH can advertise (DECL-02).
|
|
220
|
+
*
|
|
221
|
+
* Written for the OUTPUT schema, which needs the same treatment the input schema
|
|
222
|
+
* already gets. Using the contract's raw output schema would crash registration on the
|
|
223
|
+
* first keyword the DSL cannot express — the failure that produced `runtimeEnforced` in
|
|
224
|
+
* the first place — and using an unconstrained `{type: "object", additionalProperties:
|
|
225
|
+
* true}` instead, which is what this replaced, publishes a tool whose result shape is
|
|
226
|
+
* declared to be anything at all.
|
|
227
|
+
* @param schema - the schema to project.
|
|
228
|
+
* @returns the projected schema plus the keywords left to runtime enforcement.
|
|
229
|
+
*/
|
|
230
|
+
export function projectSchemaToDsh(schema) {
|
|
231
|
+
const runtimeEnforced = [];
|
|
232
|
+
const projected = projectNode(schema, '', runtimeEnforced);
|
|
233
|
+
/**
|
|
234
|
+
* Nested array `items` are RETAINED, not stripped.
|
|
235
|
+
*
|
|
236
|
+
* An earlier version stripped every `items` at depth, on evidence that the registry
|
|
237
|
+
* rejected `schema.properties.words.items`. That evidence is stale against the pinned
|
|
238
|
+
* `dsh-tools@0.2.0-rc.2`, which compiles nested array items (probed: a `words` schema
|
|
239
|
+
* with a full item schema registers and validates). Stripping by key name was also a
|
|
240
|
+
* stricter-than-contract bug in waiting: a payload field legitimately NAMED `items`
|
|
241
|
+
* would lose its advertisement. Union-typed arrays (`type: ['array','null']`) become
|
|
242
|
+
* `type: 'json'` in projectNode, which already removes the `items` sibling with the
|
|
243
|
+
* keyword recorded, so nothing here needs to strip it again.
|
|
244
|
+
*/
|
|
245
|
+
const parameters = stripItems(projected.properties ?? {}, '', runtimeEnforced);
|
|
246
|
+
return { parameters: parameters, runtimeEnforced };
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Deep-clone a projected schema while preserving ARRAYS as arrays (DECL-02).
|
|
250
|
+
*
|
|
251
|
+
* The post-pass in projectNode removed every keyword the DSL rejects, so this
|
|
252
|
+
* function no longer edits keywords — it exists so no recursion turns a scalar
|
|
253
|
+
* `enum` array like ['host','device'] into a record {0:'host',1:'device'}, which
|
|
254
|
+
* is an invalid schema the registry rejects.
|
|
255
|
+
* @param node - the projected node.
|
|
256
|
+
* @param path - the path, for diagnostics.
|
|
257
|
+
* @param runtimeEnforced - collected keyword paths (unused; kept for the signature).
|
|
258
|
+
* @returns the node, arrays intact.
|
|
259
|
+
*/
|
|
260
|
+
function stripItems(node, path, runtimeEnforced) {
|
|
261
|
+
void path;
|
|
262
|
+
void runtimeEnforced;
|
|
263
|
+
if (typeof node !== 'object' || node === null)
|
|
264
|
+
return node;
|
|
265
|
+
if (Array.isArray(node)) {
|
|
266
|
+
return node.map((child, index) => stripItems(child, `${path}[${index}]`, runtimeEnforced));
|
|
267
|
+
}
|
|
268
|
+
const out = {};
|
|
269
|
+
for (const [key, value] of Object.entries(node)) {
|
|
270
|
+
out[key] = stripItems(value, `${path}.${key}`, runtimeEnforced);
|
|
271
|
+
}
|
|
272
|
+
return out;
|
|
273
|
+
}
|
|
274
|
+
//# sourceMappingURL=dsh.js.map
|