@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
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The public extension runtime API (EXT-17, EXT-18, EXT-19).
|
|
3
|
+
*
|
|
4
|
+
* These are the interfaces an extension author implements and a host calls. The
|
|
5
|
+
* SDK owns them because an author must be able to build and test against them
|
|
6
|
+
* WITHOUT DSH or the Tool Mode host present (EXT-02): an extension that imported
|
|
7
|
+
* host internals would be unbuildable for anyone who has not installed the host,
|
|
8
|
+
* and would break on every host refactor.
|
|
9
|
+
*
|
|
10
|
+
* The context objects are deliberately narrow. `ExtensionContextV1` carries no
|
|
11
|
+
* DSH `ctx`, no registry mutation, no global credentials and no unfiltered
|
|
12
|
+
* environment; `InvocationContextV1` carries no caller-supplied authority and no
|
|
13
|
+
* arbitrary tool dispatch. An extension that needs a file or a secret asks the
|
|
14
|
+
* host through a broker whose grants are the operator's, not the extension's.
|
|
15
|
+
*
|
|
16
|
+
* @module @try-works/tool-mode-extension-sdk/runtime
|
|
17
|
+
*/
|
|
18
|
+
import type { ModelReadiness } from './state.ts';
|
|
19
|
+
/** A lossless JSON value. */
|
|
20
|
+
export type JsonValue = null | boolean | number | string | JsonValue[] | {
|
|
21
|
+
[key: string]: JsonValue;
|
|
22
|
+
};
|
|
23
|
+
/** A lossless JSON object, the shape every request and result uses. */
|
|
24
|
+
export type JsonObject = {
|
|
25
|
+
[key: string]: JsonValue;
|
|
26
|
+
};
|
|
27
|
+
/** Why an extension is being disposed. */
|
|
28
|
+
export type DisposeReason = 'deactivate' | 'upgrade' | 'uninstall' | 'shutdown' | 'fault';
|
|
29
|
+
/** A bounded diagnostic logger. It carries no credentials and cannot be silenced upward. */
|
|
30
|
+
export interface ExtensionLoggerV1 {
|
|
31
|
+
/**
|
|
32
|
+
* Record a diagnostic.
|
|
33
|
+
* @param level - severity.
|
|
34
|
+
* @param message - what happened. Must not contain secrets.
|
|
35
|
+
* @param fields - bounded structured detail.
|
|
36
|
+
*/
|
|
37
|
+
log(level: 'debug' | 'info' | 'warn' | 'error', message: string, fields?: JsonObject): void;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Extension-private storage.
|
|
41
|
+
*
|
|
42
|
+
* Private means private to the extension across its own calls; it is not a shared
|
|
43
|
+
* scratch space and not a route to the operator's filesystem.
|
|
44
|
+
*/
|
|
45
|
+
export interface ExtensionStorageV1 {
|
|
46
|
+
/**
|
|
47
|
+
* Read a value.
|
|
48
|
+
* @param key - the key.
|
|
49
|
+
* @returns the stored value, or undefined.
|
|
50
|
+
*/
|
|
51
|
+
read(key: string): Promise<JsonValue | undefined>;
|
|
52
|
+
/**
|
|
53
|
+
* Write a value.
|
|
54
|
+
* @param key - the key.
|
|
55
|
+
* @param value - the value to store.
|
|
56
|
+
*/
|
|
57
|
+
write(key: string, value: JsonValue): Promise<void>;
|
|
58
|
+
/** Absolute path this extension may use for private files. */
|
|
59
|
+
readonly directory: string;
|
|
60
|
+
}
|
|
61
|
+
/** Host-issued context for one activated extension generation (EXT-18). */
|
|
62
|
+
export interface ExtensionContextV1 {
|
|
63
|
+
/** The extension identity, as the host resolved it. */
|
|
64
|
+
readonly extensionId: string;
|
|
65
|
+
/** The installed package version. */
|
|
66
|
+
readonly extensionVersion: string;
|
|
67
|
+
/**
|
|
68
|
+
* Catalog generation this activation belongs to.
|
|
69
|
+
*
|
|
70
|
+
* An extension may branch on it, but the HOST decides publication; an extension
|
|
71
|
+
* cannot publish by incrementing anything it holds.
|
|
72
|
+
*/
|
|
73
|
+
readonly activationGeneration: number;
|
|
74
|
+
/** Extension-private storage. */
|
|
75
|
+
readonly storage: ExtensionStorageV1;
|
|
76
|
+
/** Bounded diagnostics. */
|
|
77
|
+
readonly logger: ExtensionLoggerV1;
|
|
78
|
+
/** Aborted when the host begins disposing this generation. */
|
|
79
|
+
readonly signal: AbortSignal;
|
|
80
|
+
/** Host-provided preparation state, when the host has prepared assets. */
|
|
81
|
+
readonly configuration: Readonly<JsonObject>;
|
|
82
|
+
}
|
|
83
|
+
/** What an inspection found (EXT-18). Read-only; never downloads or infers. */
|
|
84
|
+
export interface ProviderInspectionV1 {
|
|
85
|
+
/**
|
|
86
|
+
* Current deployment readiness/residency using the RES-04 state vocabulary.
|
|
87
|
+
* Prepared-but-cold deployments report `prepared-cold`, not `ready`: readiness
|
|
88
|
+
* determines whether a call is possible, while residency determines whether a
|
|
89
|
+
* call must load before running.
|
|
90
|
+
*/
|
|
91
|
+
readonly readiness: ModelReadiness;
|
|
92
|
+
/** Features this build actually provides, as opposed to what it declares. */
|
|
93
|
+
readonly features: readonly string[];
|
|
94
|
+
/** Prerequisites that are absent, each with a reason. */
|
|
95
|
+
readonly missing: readonly {
|
|
96
|
+
readonly name: string;
|
|
97
|
+
readonly reason: string;
|
|
98
|
+
}[];
|
|
99
|
+
/** The runtime the provider would use, e.g. a library version. */
|
|
100
|
+
readonly runtimeVersion?: string;
|
|
101
|
+
/** Why the deployment is in this state. */
|
|
102
|
+
readonly reason?: string;
|
|
103
|
+
}
|
|
104
|
+
/** A verified local asset handle (EXT-18). */
|
|
105
|
+
export interface PreparedAssetMapV1 {
|
|
106
|
+
/**
|
|
107
|
+
* Resolve an asset.
|
|
108
|
+
* @param assetId - the manifest asset id.
|
|
109
|
+
* @returns the local path and the digest the host verified, or undefined.
|
|
110
|
+
*/
|
|
111
|
+
get(assetId: string): {
|
|
112
|
+
readonly path: string;
|
|
113
|
+
readonly digest: string;
|
|
114
|
+
} | undefined;
|
|
115
|
+
/** The asset ids the host verified for this deployment. */
|
|
116
|
+
readonly assetIds: readonly string[];
|
|
117
|
+
}
|
|
118
|
+
/** Call-scoped, host-granted access (EXT-18). */
|
|
119
|
+
export interface InvocationContextV1 {
|
|
120
|
+
/** Opaque invocation identity, host-issued and not forgeable by a caller. */
|
|
121
|
+
readonly invocationId: string;
|
|
122
|
+
/** Required abort signal. Implementations must observe it. */
|
|
123
|
+
readonly signal: AbortSignal;
|
|
124
|
+
/** Effective limits in force for this call. */
|
|
125
|
+
readonly limits: {
|
|
126
|
+
readonly maxInputBytes: number;
|
|
127
|
+
readonly maxAudioSeconds: number;
|
|
128
|
+
readonly maxResultBytes: number;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Resolve a caller-supplied path against the caller's grants.
|
|
132
|
+
* @param candidate - the path the caller supplied.
|
|
133
|
+
* @returns the canonical authorized path.
|
|
134
|
+
*/
|
|
135
|
+
resolvePath(candidate: string): string;
|
|
136
|
+
/**
|
|
137
|
+
* Perform an approved network operation.
|
|
138
|
+
* @param destination - the destination origin, which must be approved.
|
|
139
|
+
* @param request - the request body.
|
|
140
|
+
*/
|
|
141
|
+
fetch?(destination: string, request: JsonObject): Promise<JsonObject>;
|
|
142
|
+
}
|
|
143
|
+
/** One model deployment's provider (EXT-17). */
|
|
144
|
+
export interface ModelProviderV1 {
|
|
145
|
+
/**
|
|
146
|
+
* Report readiness and features from approved local state only.
|
|
147
|
+
*
|
|
148
|
+
* MUST NOT download, infer, or authenticate to a remote endpoint.
|
|
149
|
+
* @param signal - cancellation.
|
|
150
|
+
*/
|
|
151
|
+
inspect(signal: AbortSignal): Promise<ProviderInspectionV1>;
|
|
152
|
+
/**
|
|
153
|
+
* Load the prepared assets.
|
|
154
|
+
*
|
|
155
|
+
* The host calls this once per selected exact deployment, before any invoke.
|
|
156
|
+
* @param request - the verified assets and cancellation.
|
|
157
|
+
*/
|
|
158
|
+
load(request: {
|
|
159
|
+
readonly assets: Readonly<PreparedAssetMapV1>;
|
|
160
|
+
readonly signal: AbortSignal;
|
|
161
|
+
}): Promise<void>;
|
|
162
|
+
/**
|
|
163
|
+
* Run one invocation.
|
|
164
|
+
*
|
|
165
|
+
* Returns the domain payload with the reserved root `meta` OMITTED: the host
|
|
166
|
+
* authors that field, and an extension supplying one is rejected.
|
|
167
|
+
* @param request - what to run.
|
|
168
|
+
* @returns the domain payload.
|
|
169
|
+
*/
|
|
170
|
+
invoke(request: {
|
|
171
|
+
readonly implementationId: string;
|
|
172
|
+
readonly input: Readonly<JsonObject>;
|
|
173
|
+
readonly context: InvocationContextV1;
|
|
174
|
+
}): Promise<JsonObject>;
|
|
175
|
+
/**
|
|
176
|
+
* Release loaded resources, keeping the provider usable.
|
|
177
|
+
* @param signal - cancellation.
|
|
178
|
+
*/
|
|
179
|
+
unload(signal: AbortSignal): Promise<void>;
|
|
180
|
+
/** Release everything. Idempotent, and settles only after owned resources stop. */
|
|
181
|
+
dispose(): Promise<void>;
|
|
182
|
+
}
|
|
183
|
+
/** An activated extension (EXT-17). */
|
|
184
|
+
export interface ExtensionInstanceV1 {
|
|
185
|
+
/**
|
|
186
|
+
* Create a provider for one model deployment.
|
|
187
|
+
*
|
|
188
|
+
* Creates a handle; it does not download or load. EXT-19 requires `create()` and
|
|
189
|
+
* this call to stay lightweight.
|
|
190
|
+
* @param request - which deployment, and its configuration.
|
|
191
|
+
*/
|
|
192
|
+
createProvider(request: {
|
|
193
|
+
readonly modelId: string;
|
|
194
|
+
readonly configuration: Readonly<JsonObject>;
|
|
195
|
+
}): Promise<ModelProviderV1>;
|
|
196
|
+
/**
|
|
197
|
+
* Release this instance.
|
|
198
|
+
* @param reason - why it is being disposed.
|
|
199
|
+
*/
|
|
200
|
+
dispose(reason: DisposeReason): Promise<void>;
|
|
201
|
+
}
|
|
202
|
+
/** What a module extension's `./tool-mode` entry default-exports (EXT-17). */
|
|
203
|
+
export interface ToolModeExtensionV1 {
|
|
204
|
+
/** The runtime API major. Only 1 exists. */
|
|
205
|
+
readonly apiVersion: 1;
|
|
206
|
+
/**
|
|
207
|
+
* Activate.
|
|
208
|
+
*
|
|
209
|
+
* MUST be lightweight: no automatic downloads, model loads, inference,
|
|
210
|
+
* listening sockets, global registration or unbounded background loops.
|
|
211
|
+
* @param context - the host-issued context.
|
|
212
|
+
*/
|
|
213
|
+
create(context: ExtensionContextV1): Promise<ExtensionInstanceV1>;
|
|
214
|
+
}
|
|
215
|
+
/** The only apiVersion this SDK implements. */
|
|
216
|
+
export declare const EXTENSION_API_VERSION = 1;
|
|
217
|
+
/**
|
|
218
|
+
* Declare an extension, with its shape checked at the declaration site.
|
|
219
|
+
*
|
|
220
|
+
* Authors use this rather than exporting an object literal: it makes a typo in
|
|
221
|
+
* `apiVersion` a compile error instead of a load-time rejection, which is the
|
|
222
|
+
* difference between finding the mistake in an editor and in an operator's log.
|
|
223
|
+
* @param extension - the extension to declare.
|
|
224
|
+
* @returns the same extension, typed.
|
|
225
|
+
*/
|
|
226
|
+
export declare function defineExtension(extension: ToolModeExtensionV1): ToolModeExtensionV1;
|
|
227
|
+
/**
|
|
228
|
+
* The reserved root field the host authors, which an extension must not supply.
|
|
229
|
+
*
|
|
230
|
+
* EXT-17 reserves it so provenance cannot be forged: an extension that returned
|
|
231
|
+
* its own `meta` would be asserting who ran it and under what receipt.
|
|
232
|
+
*/
|
|
233
|
+
export declare const RESERVED_META_FIELD = "meta";
|
|
234
|
+
/**
|
|
235
|
+
* Reject an extension result that tries to supply the reserved `meta` field.
|
|
236
|
+
*
|
|
237
|
+
* @param payload - the payload an extension returned.
|
|
238
|
+
* @param implementationId - for the error message.
|
|
239
|
+
* @throws Error when the payload carries `meta`.
|
|
240
|
+
*/
|
|
241
|
+
export declare function assertNoReservedMeta(payload: JsonObject, implementationId: string): void;
|
|
242
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEhD,6BAA6B;AAC7B,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,EAAE,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAA;AAErG,uEAAuE;AACvE,MAAM,MAAM,UAAU,GAAG;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AAC,mBAAmB,CAAC,CAAA;CAClE;AAED,+CAA+C;AAC/C,eAAO,MAAM,qBAAqB,IAAI,CAAA;AAEtC;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,mBAAmB,GAAG,mBAAmB,CAUnF;AAED;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,SAAS,CAAA;AAEzC;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAOxF"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The public extension runtime API (EXT-17, EXT-18, EXT-19).
|
|
3
|
+
*
|
|
4
|
+
* These are the interfaces an extension author implements and a host calls. The
|
|
5
|
+
* SDK owns them because an author must be able to build and test against them
|
|
6
|
+
* WITHOUT DSH or the Tool Mode host present (EXT-02): an extension that imported
|
|
7
|
+
* host internals would be unbuildable for anyone who has not installed the host,
|
|
8
|
+
* and would break on every host refactor.
|
|
9
|
+
*
|
|
10
|
+
* The context objects are deliberately narrow. `ExtensionContextV1` carries no
|
|
11
|
+
* DSH `ctx`, no registry mutation, no global credentials and no unfiltered
|
|
12
|
+
* environment; `InvocationContextV1` carries no caller-supplied authority and no
|
|
13
|
+
* arbitrary tool dispatch. An extension that needs a file or a secret asks the
|
|
14
|
+
* host through a broker whose grants are the operator's, not the extension's.
|
|
15
|
+
*
|
|
16
|
+
* @module @try-works/tool-mode-extension-sdk/runtime
|
|
17
|
+
*/
|
|
18
|
+
/** The only apiVersion this SDK implements. */
|
|
19
|
+
export const EXTENSION_API_VERSION = 1;
|
|
20
|
+
/**
|
|
21
|
+
* Declare an extension, with its shape checked at the declaration site.
|
|
22
|
+
*
|
|
23
|
+
* Authors use this rather than exporting an object literal: it makes a typo in
|
|
24
|
+
* `apiVersion` a compile error instead of a load-time rejection, which is the
|
|
25
|
+
* difference between finding the mistake in an editor and in an operator's log.
|
|
26
|
+
* @param extension - the extension to declare.
|
|
27
|
+
* @returns the same extension, typed.
|
|
28
|
+
*/
|
|
29
|
+
export function defineExtension(extension) {
|
|
30
|
+
if (extension.apiVersion !== EXTENSION_API_VERSION) {
|
|
31
|
+
throw new Error(`extension apiVersion ${String(extension.apiVersion)} is not supported; this SDK implements ${EXTENSION_API_VERSION}`);
|
|
32
|
+
}
|
|
33
|
+
if (typeof extension.create !== 'function') {
|
|
34
|
+
throw new Error('extension must implement create(context)');
|
|
35
|
+
}
|
|
36
|
+
return extension;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The reserved root field the host authors, which an extension must not supply.
|
|
40
|
+
*
|
|
41
|
+
* EXT-17 reserves it so provenance cannot be forged: an extension that returned
|
|
42
|
+
* its own `meta` would be asserting who ran it and under what receipt.
|
|
43
|
+
*/
|
|
44
|
+
export const RESERVED_META_FIELD = 'meta';
|
|
45
|
+
/**
|
|
46
|
+
* Reject an extension result that tries to supply the reserved `meta` field.
|
|
47
|
+
*
|
|
48
|
+
* @param payload - the payload an extension returned.
|
|
49
|
+
* @param implementationId - for the error message.
|
|
50
|
+
* @throws Error when the payload carries `meta`.
|
|
51
|
+
*/
|
|
52
|
+
export function assertNoReservedMeta(payload, implementationId) {
|
|
53
|
+
if (RESERVED_META_FIELD in payload) {
|
|
54
|
+
throw new Error(`implementation ${implementationId} returned a reserved root "${RESERVED_META_FIELD}" field; `
|
|
55
|
+
+ 'the host authors that metadata and will not accept an extension-supplied one');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orthogonal extension state (EXT-25).
|
|
3
|
+
*
|
|
4
|
+
* The governing rule is that ONE boolean cannot describe six independent facts.
|
|
5
|
+
* A package can be installed but never activated; activated but its model not yet
|
|
6
|
+
* prepared; prepared but its tool disabled for this profile; enabled but not
|
|
7
|
+
* exported to an external client. Collapsing those into `enabled` is how a UI ends
|
|
8
|
+
* up claiming a tool works when a caller cannot reach it.
|
|
9
|
+
*
|
|
10
|
+
* This module models each dimension separately and derives the operator-facing
|
|
11
|
+
* summary from them, so the summary can never disagree with the parts.
|
|
12
|
+
*
|
|
13
|
+
* @module @try-works/tool-mode-extension-sdk/state
|
|
14
|
+
*/
|
|
15
|
+
/** Host-owned package inventory state (EXT-25, dimension 1). */
|
|
16
|
+
export type InstallationState = 'absent' | 'staged' | 'installed' | 'uninstalling' | 'cleanup-pending';
|
|
17
|
+
/** What the operator asked for, per named profile (EXT-25, dimension 2). */
|
|
18
|
+
export type DesiredActivation = 'active' | 'inactive';
|
|
19
|
+
/** What the host observes, per named profile (EXT-25, dimension 3). */
|
|
20
|
+
export type ObservedActivation = 'inactive' | 'activating' | 'active' | 'deactivating' | 'failed' | 'quarantined';
|
|
21
|
+
/**
|
|
22
|
+
* Per-deployment readiness (EXT-25 dimension 4; the RES-04 state set).
|
|
23
|
+
*
|
|
24
|
+
* The eight states answer TWO questions, and conflating them is the mistake RES-04
|
|
25
|
+
* names: readiness determines whether a call is POSSIBLE, while residency determines
|
|
26
|
+
* how it is ADMITTED. A prepared-but-cold deployment is callable — it simply loads
|
|
27
|
+
* first — and reporting it as uncallable would withdraw a working tool and make the
|
|
28
|
+
* tool surface flicker on every warm/cold transition.
|
|
29
|
+
*/
|
|
30
|
+
export type ModelReadiness = 'unavailable' | 'needs-preparation' | 'preparing' | 'prepared-cold' | 'loading' | 'ready' | 'busy' | 'failed';
|
|
31
|
+
/** Per-profile tool selection (EXT-25, dimension 5). */
|
|
32
|
+
export interface ToolSelection {
|
|
33
|
+
readonly toolName: string;
|
|
34
|
+
/** Whether the tool is enabled in this profile. */
|
|
35
|
+
readonly enabled: boolean;
|
|
36
|
+
/** The implementation selected to serve it, when the host chose one. */
|
|
37
|
+
readonly selectedImplementation?: string;
|
|
38
|
+
}
|
|
39
|
+
/** Separate server/client grants and licence decisions (EXT-25, dimension 6). */
|
|
40
|
+
export type ExportAuthorization = 'not-exported' | 'granted' | 'denied' | 'revoked';
|
|
41
|
+
/** The complete orthogonal state of one extension in one profile. */
|
|
42
|
+
export interface ExtensionState {
|
|
43
|
+
/** Extension identity. */
|
|
44
|
+
readonly extensionId: string;
|
|
45
|
+
/** Host-owned package inventory state; not profile-scoped. */
|
|
46
|
+
readonly installation: InstallationState;
|
|
47
|
+
/** What the operator asked for in this profile. */
|
|
48
|
+
readonly desiredActivation: DesiredActivation;
|
|
49
|
+
/** What the host observes in this profile. */
|
|
50
|
+
readonly observedActivation: ObservedActivation;
|
|
51
|
+
/** Model readiness keyed by exact deployment identity, not by model name. */
|
|
52
|
+
readonly readiness: Readonly<Record<string, ModelReadiness>>;
|
|
53
|
+
/** Tool selection in this profile. */
|
|
54
|
+
readonly tools: readonly ToolSelection[];
|
|
55
|
+
/** Export authorization, which is independent of local enablement. */
|
|
56
|
+
readonly export: ExportAuthorization;
|
|
57
|
+
/**
|
|
58
|
+
* The process that published this extension's surface, when it is active.
|
|
59
|
+
*
|
|
60
|
+
* Publication handles are IN-MEMORY, so a fresh process cannot see whether the
|
|
61
|
+
* handles it lacks died with a previous process or belong to a live one. Recording
|
|
62
|
+
* the owner makes that distinction durable: a restarted process may restore an
|
|
63
|
+
* `active` extension whose owner is gone, and must refuse one whose owner is alive.
|
|
64
|
+
*/
|
|
65
|
+
readonly ownerPid?: number;
|
|
66
|
+
}
|
|
67
|
+
/** The operator-facing summary, derived rather than stored. */
|
|
68
|
+
export type ExtensionSummary =
|
|
69
|
+
/** Available and callable. */
|
|
70
|
+
'ready'
|
|
71
|
+
/** Installed and activated, but a model is not prepared yet. */
|
|
72
|
+
| 'preparing'
|
|
73
|
+
/** Installed and activated, but every tool is disabled here. */
|
|
74
|
+
| 'no-tools-enabled'
|
|
75
|
+
/** Installed, deliberately not activated. */
|
|
76
|
+
| 'inactive'
|
|
77
|
+
/** Activation failed or the host quarantined it. */
|
|
78
|
+
| 'faulted'
|
|
79
|
+
/** Uninstall started; deletion is pending. */
|
|
80
|
+
| 'cleanup-pending'
|
|
81
|
+
/** Not installed. */
|
|
82
|
+
| 'absent';
|
|
83
|
+
/**
|
|
84
|
+
* Derive the operator-facing summary from the orthogonal state.
|
|
85
|
+
*
|
|
86
|
+
* Ordering is the whole point: a faulted activation outranks a readiness problem,
|
|
87
|
+
* because reporting "preparing" for a package whose activation failed would tell
|
|
88
|
+
* an operator to wait for something that will never finish.
|
|
89
|
+
* @param state - the orthogonal state.
|
|
90
|
+
* @returns the summary an operator surface should show.
|
|
91
|
+
*/
|
|
92
|
+
export declare function summarize(state: ExtensionState): ExtensionSummary;
|
|
93
|
+
/**
|
|
94
|
+
* Whether a caller may invoke a tool right now, using ONLY persisted state.
|
|
95
|
+
*
|
|
96
|
+
* Export authorization is deliberately NOT part of this check: a local caller
|
|
97
|
+
* being able to call a tool says nothing about whether an external client may, and
|
|
98
|
+
* conflating the two is exactly what EXT-25 separates.
|
|
99
|
+
*
|
|
100
|
+
* SCOPE — read this before using it as an admission decision. This helper sees the
|
|
101
|
+
* state FILE, which records operator intent and readiness; it cannot see which
|
|
102
|
+
* contributions were actually PUBLISHED, because that is process-local. It therefore
|
|
103
|
+
* answers "is this tool enabled and is every declared deployment callable", which is
|
|
104
|
+
* NOT the same question as "was this tool published and can it be dispatched".
|
|
105
|
+
*
|
|
106
|
+
* `ExtensionLifecycle.admits()` is the admission decision: it additionally requires the
|
|
107
|
+
* tool to be in the committed published surface, and it evaluates readiness per BINDING
|
|
108
|
+
* rather than over every deployment. This function remains the pure-state predicate the
|
|
109
|
+
* state tests exercise, and a host that used it alone would admit tools that publication
|
|
110
|
+
* withheld. Prefer `ExtensionLifecycle.admits()` wherever a lifecycle is available.
|
|
111
|
+
* @param state - the orthogonal state.
|
|
112
|
+
* @param toolName - the tool being invoked.
|
|
113
|
+
* @returns whether the persisted state alone admits the invocation.
|
|
114
|
+
*/
|
|
115
|
+
export declare function admitsInvocation(state: ExtensionState, toolName: string): boolean;
|
|
116
|
+
/** Build the state of a newly installed but not yet activated extension. */
|
|
117
|
+
export declare function installedInactive(extensionId: string): ExtensionState;
|
|
118
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,gEAAgE;AAChE,MAAM,MAAM,iBAAiB,GACzB,QAAQ,GACR,QAAQ,GACR,WAAW,GACX,cAAc,GACd,iBAAiB,CAAA;AAErB,4EAA4E;AAC5E,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,UAAU,CAAA;AAErD,uEAAuE;AACvE,MAAM,MAAM,kBAAkB,GAC1B,UAAU,GACV,YAAY,GACZ,QAAQ,GACR,cAAc,GACd,QAAQ,GACR,aAAa,CAAA;AAEjB;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,GACtB,aAAa,GACb,mBAAmB,GACnB,WAAW,GACX,eAAe,GACf,SAAS,GACT,OAAO,GACP,MAAM,GACN,QAAQ,CAAA;AAEZ,wDAAwD;AACxD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,mDAAmD;IACnD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,wEAAwE;IACxE,QAAQ,CAAC,sBAAsB,CAAC,EAAE,MAAM,CAAA;CACzC;AAED,iFAAiF;AACjF,MAAM,MAAM,mBAAmB,GAAG,cAAc,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAA;AAEnF,qEAAqE;AACrE,MAAM,WAAW,cAAc;IAC7B,0BAA0B;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,8DAA8D;IAC9D,QAAQ,CAAC,YAAY,EAAE,iBAAiB,CAAA;IACxC,mDAAmD;IACnD,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAA;IAC7C,8CAA8C;IAC9C,QAAQ,CAAC,kBAAkB,EAAE,kBAAkB,CAAA;IAC/C,6EAA6E;IAC7E,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAA;IAC5D,sCAAsC;IACtC,QAAQ,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,CAAA;IACxC,sEAAsE;IACtE,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAA;IACpC;;;;;;;OAOG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAC3B;AAED,+DAA+D;AAC/D,MAAM,MAAM,gBAAgB;AAC1B,8BAA8B;AAC5B,OAAO;AACT,gEAAgE;GAC9D,WAAW;AACb,gEAAgE;GAC9D,kBAAkB;AACpB,6CAA6C;GAC3C,UAAU;AACZ,oDAAoD;GAClD,SAAS;AACX,8CAA8C;GAC5C,iBAAiB;AACnB,qBAAqB;GACnB,QAAQ,CAAA;AAEZ;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,gBAAgB,CAwBjE;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAWjF;AAcD,4EAA4E;AAC5E,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,cAAc,CAUrE"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orthogonal extension state (EXT-25).
|
|
3
|
+
*
|
|
4
|
+
* The governing rule is that ONE boolean cannot describe six independent facts.
|
|
5
|
+
* A package can be installed but never activated; activated but its model not yet
|
|
6
|
+
* prepared; prepared but its tool disabled for this profile; enabled but not
|
|
7
|
+
* exported to an external client. Collapsing those into `enabled` is how a UI ends
|
|
8
|
+
* up claiming a tool works when a caller cannot reach it.
|
|
9
|
+
*
|
|
10
|
+
* This module models each dimension separately and derives the operator-facing
|
|
11
|
+
* summary from them, so the summary can never disagree with the parts.
|
|
12
|
+
*
|
|
13
|
+
* @module @try-works/tool-mode-extension-sdk/state
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Derive the operator-facing summary from the orthogonal state.
|
|
17
|
+
*
|
|
18
|
+
* Ordering is the whole point: a faulted activation outranks a readiness problem,
|
|
19
|
+
* because reporting "preparing" for a package whose activation failed would tell
|
|
20
|
+
* an operator to wait for something that will never finish.
|
|
21
|
+
* @param state - the orthogonal state.
|
|
22
|
+
* @returns the summary an operator surface should show.
|
|
23
|
+
*/
|
|
24
|
+
export function summarize(state) {
|
|
25
|
+
if (state.installation === 'absent')
|
|
26
|
+
return 'absent';
|
|
27
|
+
if (state.installation === 'cleanup-pending' || state.installation === 'uninstalling') {
|
|
28
|
+
return 'cleanup-pending';
|
|
29
|
+
}
|
|
30
|
+
if (state.observedActivation === 'failed' || state.observedActivation === 'quarantined') {
|
|
31
|
+
return 'faulted';
|
|
32
|
+
}
|
|
33
|
+
// Desired-inactive is reported as inactive even mid-transition, because the
|
|
34
|
+
// operator's intent is what the surface is describing.
|
|
35
|
+
if (state.desiredActivation === 'inactive')
|
|
36
|
+
return 'inactive';
|
|
37
|
+
if (state.observedActivation !== 'active')
|
|
38
|
+
return 'inactive';
|
|
39
|
+
const readiness = Object.values(state.readiness);
|
|
40
|
+
if (readiness.some(value => value === 'failed' || value === 'unavailable'))
|
|
41
|
+
return 'faulted';
|
|
42
|
+
// A COLD deployment is not "preparing": it is usable and will load on first use, so
|
|
43
|
+
// reporting it as preparing would tell an operator to wait for something that
|
|
44
|
+
// already works.
|
|
45
|
+
if (readiness.some(value => value === 'needs-preparation' || value === 'preparing' || value === 'loading')) {
|
|
46
|
+
return 'preparing';
|
|
47
|
+
}
|
|
48
|
+
if (!state.tools.some(tool => tool.enabled))
|
|
49
|
+
return 'no-tools-enabled';
|
|
50
|
+
return 'ready';
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Whether a caller may invoke a tool right now, using ONLY persisted state.
|
|
54
|
+
*
|
|
55
|
+
* Export authorization is deliberately NOT part of this check: a local caller
|
|
56
|
+
* being able to call a tool says nothing about whether an external client may, and
|
|
57
|
+
* conflating the two is exactly what EXT-25 separates.
|
|
58
|
+
*
|
|
59
|
+
* SCOPE — read this before using it as an admission decision. This helper sees the
|
|
60
|
+
* state FILE, which records operator intent and readiness; it cannot see which
|
|
61
|
+
* contributions were actually PUBLISHED, because that is process-local. It therefore
|
|
62
|
+
* answers "is this tool enabled and is every declared deployment callable", which is
|
|
63
|
+
* NOT the same question as "was this tool published and can it be dispatched".
|
|
64
|
+
*
|
|
65
|
+
* `ExtensionLifecycle.admits()` is the admission decision: it additionally requires the
|
|
66
|
+
* tool to be in the committed published surface, and it evaluates readiness per BINDING
|
|
67
|
+
* rather than over every deployment. This function remains the pure-state predicate the
|
|
68
|
+
* state tests exercise, and a host that used it alone would admit tools that publication
|
|
69
|
+
* withheld. Prefer `ExtensionLifecycle.admits()` wherever a lifecycle is available.
|
|
70
|
+
* @param state - the orthogonal state.
|
|
71
|
+
* @param toolName - the tool being invoked.
|
|
72
|
+
* @returns whether the persisted state alone admits the invocation.
|
|
73
|
+
*/
|
|
74
|
+
export function admitsInvocation(state, toolName) {
|
|
75
|
+
if (state.installation !== 'installed')
|
|
76
|
+
return false;
|
|
77
|
+
if (state.desiredActivation !== 'active')
|
|
78
|
+
return false;
|
|
79
|
+
if (state.observedActivation !== 'active')
|
|
80
|
+
return false;
|
|
81
|
+
const tool = state.tools.find(candidate => candidate.toolName === toolName);
|
|
82
|
+
if (tool === undefined || !tool.enabled)
|
|
83
|
+
return false;
|
|
84
|
+
// PREPARATION determines callability; RESIDENCY does not. An earlier version
|
|
85
|
+
// required `ready` here, which made a prepared-but-cold deployment uncallable and
|
|
86
|
+
// so withdrew a tool that works. `prepared-cold`, `loading` and `busy` are all
|
|
87
|
+
// callable; only a deployment that is unavailable, unprepared or failed is not.
|
|
88
|
+
return Object.values(state.readiness).every(value => CALLABLE_READINESS.has(value));
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The readiness states in which a call is possible (RES-04).
|
|
92
|
+
*
|
|
93
|
+
* A cold but prepared deployment is callable: the call simply loads first.
|
|
94
|
+
*/
|
|
95
|
+
const CALLABLE_READINESS = new Set([
|
|
96
|
+
'prepared-cold',
|
|
97
|
+
'loading',
|
|
98
|
+
'ready',
|
|
99
|
+
'busy',
|
|
100
|
+
]);
|
|
101
|
+
/** Build the state of a newly installed but not yet activated extension. */
|
|
102
|
+
export function installedInactive(extensionId) {
|
|
103
|
+
return {
|
|
104
|
+
extensionId,
|
|
105
|
+
installation: 'installed',
|
|
106
|
+
desiredActivation: 'inactive',
|
|
107
|
+
observedActivation: 'inactive',
|
|
108
|
+
readiness: {},
|
|
109
|
+
tools: [],
|
|
110
|
+
export: 'not-exported',
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-child.d.ts","sourceRoot":"","sources":["../../src/worker/worker-child.ts"],"names":[],"mappings":""}
|