@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,20 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* The `dsh-tool-mode-credentials` executable (SEC-01).
|
|
4
|
+
*
|
|
5
|
+
* The HUMAN-ONLY credential surface: the model-visible `model_tools`
|
|
6
|
+
* management action refuses generation (a generated secret must never enter a
|
|
7
|
+
* model transcript), and this CLI is the operator's terminal instead. The
|
|
8
|
+
* stream discipline is the stdio bridge's own: STDOUT carries the credential
|
|
9
|
+
* (the secret exactly once) and nothing else; diagnostics and usage go to
|
|
10
|
+
* stderr. The secret is never logged and never recoverable.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { runCredentialsCli } from '../lib/mcp/credential-cli.js'
|
|
14
|
+
|
|
15
|
+
const exit = runCredentialsCli(process.argv.slice(2), {
|
|
16
|
+
out: line => process.stdout.write(`${line}\n`),
|
|
17
|
+
err: line => process.stderr.write(`${line}\n`),
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
process.exit(exit)
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* The `dsh-tool-mode` launcher (RUN-03/RUN-04): serve / doctor / prepare /
|
|
4
|
+
* mcp-stdio.
|
|
5
|
+
*
|
|
6
|
+
* - `serve` boots the headless host composition. The host package ships no
|
|
7
|
+
* composition entry of its own (no src/host.ts — the recorded seam): serve
|
|
8
|
+
* attempts to resolve the DSH composition runtime and, when it is not
|
|
9
|
+
* resolvable from this artifact, exits non-zero with the exact missing seam
|
|
10
|
+
* rather than inventing service constructors.
|
|
11
|
+
* - `doctor` reports configuration, package/runtime compatibility, platform
|
|
12
|
+
* readiness and the launcher seam WITHOUT secrets.
|
|
13
|
+
* - `prepare --tool <name>` resolves the installed extension that serves the
|
|
14
|
+
* tool and runs the digest-verified prepared-assets acquisition (a REAL
|
|
15
|
+
* download is opt-in: the operator runs this command deliberately).
|
|
16
|
+
* - `mcp-stdio` reuses the existing stdio relay (same env contract as the
|
|
17
|
+
* standalone binary).
|
|
18
|
+
*
|
|
19
|
+
* Every subcommand: `--json` emits structured JSON on stdout; failures exit
|
|
20
|
+
* non-zero; an unattended launch never hangs (P26-16).
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import { readFileSync } from 'node:fs'
|
|
24
|
+
import { createHash } from 'node:crypto'
|
|
25
|
+
import { existsSync, mkdirSync, readdirSync, statSync } from 'node:fs'
|
|
26
|
+
import { dirname, join, resolve } from 'node:path'
|
|
27
|
+
import { createPreparedAssetRegistry, parseAssetLock, plannedAssets, lockGroups, identityFor } from '../lib/prepared-assets.js'
|
|
28
|
+
import { planPreparation } from '../lib/deployment-coordinator.js'
|
|
29
|
+
import { createHttpSource } from '../lib/http-acquisition.js'
|
|
30
|
+
import { createStdioBridge } from '../lib/mcp/stdio.js'
|
|
31
|
+
import { discoverExtension } from '@try-works/tool-mode-extension-sdk'
|
|
32
|
+
|
|
33
|
+
const args = process.argv.slice(2)
|
|
34
|
+
const command = args[0] ?? '--help'
|
|
35
|
+
const flag = name => {
|
|
36
|
+
const index = args.indexOf(name)
|
|
37
|
+
return index === -1 || index + 1 >= args.length ? undefined : args[index + 1]
|
|
38
|
+
}
|
|
39
|
+
const jsonOut = args.includes('--json')
|
|
40
|
+
const report = (value) => {
|
|
41
|
+
process.stdout.write(`${JSON.stringify(value, null, 2)}\n`)
|
|
42
|
+
process.exit(0)
|
|
43
|
+
}
|
|
44
|
+
const fail = (message, code = 2) => {
|
|
45
|
+
if (jsonOut) process.stdout.write(`${JSON.stringify({ ok: false, error: message })}\n`)
|
|
46
|
+
else process.stderr.write(`dsh-tool-mode: ${message}\n`)
|
|
47
|
+
process.exit(code)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Read the config document, tolerating its absence for the read-only commands. */
|
|
51
|
+
function readConfig(path) {
|
|
52
|
+
const target = path ?? process.env.DSH_TOOL_MODE_CONFIG ?? './tool-mode.json'
|
|
53
|
+
try {
|
|
54
|
+
return JSON.parse(readFileSync(target, 'utf8'))
|
|
55
|
+
} catch {
|
|
56
|
+
return {}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (command === 'mcp-stdio') {
|
|
61
|
+
const url = process.env.DSH_TOOL_MODE_MCP_URL ?? 'http://127.0.0.1:3765/mcp'
|
|
62
|
+
const token = process.env.DSH_TOOL_MODE_MCP_TOKEN
|
|
63
|
+
if (token === undefined || token.length === 0) {
|
|
64
|
+
process.stderr.write('dsh-tool-mode mcp-stdio: no credential configured (DSH_TOOL_MODE_MCP_TOKEN).\n')
|
|
65
|
+
process.exit(2)
|
|
66
|
+
}
|
|
67
|
+
const bridge = createStdioBridge(
|
|
68
|
+
{
|
|
69
|
+
url,
|
|
70
|
+
token,
|
|
71
|
+
fetch: async (target, init) => {
|
|
72
|
+
const response = await fetch(target, {
|
|
73
|
+
method: init.method,
|
|
74
|
+
headers: init.headers,
|
|
75
|
+
body: init.body,
|
|
76
|
+
signal: init.signal,
|
|
77
|
+
})
|
|
78
|
+
const headers = {}
|
|
79
|
+
response.headers.forEach((value, key) => { headers[key] = value })
|
|
80
|
+
return { status: response.status, headers, body: await response.text() }
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
protocol: line => process.stdout.write(`${line}\n`),
|
|
85
|
+
diagnostic: line => process.stderr.write(`${line}\n`),
|
|
86
|
+
},
|
|
87
|
+
)
|
|
88
|
+
bridge.start()
|
|
89
|
+
process.on('SIGINT', () => process.exit(0))
|
|
90
|
+
} else if (command === 'doctor') {
|
|
91
|
+
const config = readConfig(flag('--config'))
|
|
92
|
+
const platform = `${process.platform} ${process.arch}`
|
|
93
|
+
const nodeVersion = process.version
|
|
94
|
+
const mcpPort = config.mcpV3?.port ?? config.mcp?.port ?? 3765
|
|
95
|
+
const extensionStore = config.extensionStore ?? config.extensions?.registry ?? 'unset'
|
|
96
|
+
const result = {
|
|
97
|
+
ok: true,
|
|
98
|
+
command: 'doctor',
|
|
99
|
+
platform: { os: process.platform, arch: process.arch, node: nodeVersion, accelerator: 'cpu' },
|
|
100
|
+
configuration: {
|
|
101
|
+
schemaVersion: config.schemaVersion ?? 'legacy (v1/v2 flat shape)',
|
|
102
|
+
mcp: { host: '127.0.0.1', port: mcpPort, path: config.mcpV3?.path ?? '/mcp' },
|
|
103
|
+
extensionStore,
|
|
104
|
+
fixedFalseFlags: {
|
|
105
|
+
automaticUpdates: false,
|
|
106
|
+
runInstallScripts: false,
|
|
107
|
+
automaticActivation: false,
|
|
108
|
+
allowExecutableTemplates: false,
|
|
109
|
+
inheritConversation: false,
|
|
110
|
+
allowModelToolCalls: false,
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
launcherSeam:
|
|
114
|
+
'`serve` boots the headless composition in lib/headless.js: config -> catalog -> contract bindings -> MCP host -> '
|
|
115
|
+
+ 'HTTP with credential authentication, without the DSH CLI or a browser (RUN-03). Harness-backed program '
|
|
116
|
+
+ 'execution (tool_mode_run) stays refused headless: it needs the DSH PtcHostContext (CODE-10).',
|
|
117
|
+
serverStatus: 'not running (doctor does not start the listener)',
|
|
118
|
+
}
|
|
119
|
+
report(result)
|
|
120
|
+
} else if (command === 'prepare') {
|
|
121
|
+
const tool = flag('--tool')
|
|
122
|
+
if (tool === undefined) fail('prepare requires --tool <toolName> (RUN-04)')
|
|
123
|
+
const config = readConfig(flag('--config'))
|
|
124
|
+
const storeDir = config.extensionStore
|
|
125
|
+
if (typeof storeDir !== 'string' || storeDir.length === 0) {
|
|
126
|
+
fail('prepare requires the extension store (config.extensionStore); the store is not configured')
|
|
127
|
+
}
|
|
128
|
+
// Resolve the installed extension whose manifest serves the requested tool.
|
|
129
|
+
const found = []
|
|
130
|
+
if (existsSync(storeDir)) {
|
|
131
|
+
for (const entry of readdirSync(storeDir)) {
|
|
132
|
+
const root = join(storeDir, entry)
|
|
133
|
+
if (!statSync(root).isDirectory()) continue
|
|
134
|
+
for (const id of readdirSync(root)) {
|
|
135
|
+
const scope = join(root, id)
|
|
136
|
+
if (!statSync(scope).isDirectory()) continue
|
|
137
|
+
for (const version of readdirSync(scope)) {
|
|
138
|
+
const installPath = join(scope, version)
|
|
139
|
+
if (!existsSync(join(installPath, 'tool-mode.extension.json'))) continue
|
|
140
|
+
try {
|
|
141
|
+
const discovery = discoverExtension(installPath)
|
|
142
|
+
const serves = discovery.manifest.tools.some(t => t.name === tool)
|
|
143
|
+
|| discovery.manifest.implementations.some(impl => {
|
|
144
|
+
const owner = discovery.manifest.tools.find(t => t.contractId === impl.contractId)
|
|
145
|
+
return owner?.name === tool
|
|
146
|
+
})
|
|
147
|
+
if (serves) found.push({ discovery, installPath })
|
|
148
|
+
} catch {
|
|
149
|
+
// A broken package is skipped: prepare never guesses.
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (found.length === 0) fail(`no installed extension serves the tool ${JSON.stringify(tool)} (prepare never guesses)`)
|
|
156
|
+
const { discovery, installPath } = found[0]
|
|
157
|
+
const model = discovery.manifest.models[0]
|
|
158
|
+
if (model === undefined) fail(`the extension serving ${tool} declares no model deployment`)
|
|
159
|
+
const lockPath = join(dirname(discovery.manifestPath), model.assetLock)
|
|
160
|
+
const lock = parseAssetLock(readFileSync(lockPath, 'utf8'))
|
|
161
|
+
const groups = lockGroups(lock, model.assetSet)
|
|
162
|
+
const plan = planPreparation(identityFor(discovery.manifest.id, model.id, lock), plannedAssets(lock, model.assetSet), lock.license)
|
|
163
|
+
const statePath = config.stateFile ?? join(process.env.LOCALAPPDATA ?? process.env.TEMP ?? '.', 'dsh-model-as-tool', 'state.json')
|
|
164
|
+
const registry = createPreparedAssetRegistry({ cacheRoot: join(dirname(resolve(statePath)), 'asset-cache') })
|
|
165
|
+
const outcome = await registry.prepare(discovery.manifest.id, plan, groups, {
|
|
166
|
+
source: createHttpSource(),
|
|
167
|
+
allowExecutable: false,
|
|
168
|
+
signal: new AbortController().signal,
|
|
169
|
+
})
|
|
170
|
+
if (!outcome.ok) fail(`the preparation failed: ${outcome.reason}`, 1)
|
|
171
|
+
const transferred = outcome.groups.map(group => group.digests.map(digest => createHash('sha256').update(digest).digest('hex')))
|
|
172
|
+
report({
|
|
173
|
+
ok: true,
|
|
174
|
+
command: 'prepare',
|
|
175
|
+
tool,
|
|
176
|
+
extension: discovery.manifest.id,
|
|
177
|
+
model: model.id,
|
|
178
|
+
revision: lock.revision,
|
|
179
|
+
groups: outcome.groups.map(group => ({ groupId: group.groupId, path: group.path, digests: group.digests })),
|
|
180
|
+
note: `transferred digests (${transferred.length} groups) are the content hashes; sizes are per-asset in the lock`,
|
|
181
|
+
})
|
|
182
|
+
} else if (command === 'serve') {
|
|
183
|
+
// The REAL headless composition (RUN-03, task-74): config load, catalog
|
|
184
|
+
// resolution, contract bindings, the MCP HTTP listener, and a bounded
|
|
185
|
+
// SIGINT/SIGTERM shutdown — composed from the host's own services, no DSH
|
|
186
|
+
// CLI required.
|
|
187
|
+
const { runHeadlessServe } = await import('../lib/headless.js')
|
|
188
|
+
const exit = await runHeadlessServe(
|
|
189
|
+
{ configPath: flag('--config'), json: jsonOut },
|
|
190
|
+
{ out: line => process.stdout.write(`${line}\n`), err: line => process.stderr.write(`${line}\n`) },
|
|
191
|
+
)
|
|
192
|
+
process.exit(exit)
|
|
193
|
+
} else {
|
|
194
|
+
process.stderr.write(
|
|
195
|
+
'dsh-tool-mode: usage\n'
|
|
196
|
+
+ ' dsh-tool-mode serve [--config tool-mode.json] [--json]\n'
|
|
197
|
+
+ ' dsh-tool-mode doctor [--config tool-mode.json] [--json]\n'
|
|
198
|
+
+ ' dsh-tool-mode prepare --tool <toolName> [--config tool-mode.json] [--json]\n'
|
|
199
|
+
+ ' dsh-tool-mode mcp-stdio\n',
|
|
200
|
+
)
|
|
201
|
+
process.exit(command === '--help' || command === '-h' ? 0 : 2)
|
|
202
|
+
}
|