@dsh-cc/tools 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/LICENSE +201 -0
  2. package/README.i18n.yaml +6 -0
  3. package/README.md +209 -0
  4. package/README.zh.md +200 -0
  5. package/lib/abort-utils.d.ts +80 -0
  6. package/lib/abort-utils.d.ts.map +1 -0
  7. package/lib/abort-utils.js +186 -0
  8. package/lib/abort-utils.js.map +1 -0
  9. package/lib/cc-names.d.ts +100 -0
  10. package/lib/cc-names.d.ts.map +1 -0
  11. package/lib/cc-names.js +197 -0
  12. package/lib/cc-names.js.map +1 -0
  13. package/lib/code-mode.d.ts +46 -0
  14. package/lib/code-mode.d.ts.map +1 -0
  15. package/lib/code-mode.js +380 -0
  16. package/lib/code-mode.js.map +1 -0
  17. package/lib/define-tool.d.ts +103 -0
  18. package/lib/define-tool.d.ts.map +1 -0
  19. package/lib/define-tool.js +354 -0
  20. package/lib/define-tool.js.map +1 -0
  21. package/lib/index.d.ts +348 -0
  22. package/lib/index.d.ts.map +1 -0
  23. package/lib/index.js +289 -0
  24. package/lib/index.js.map +1 -0
  25. package/lib/invariant.d.ts +13 -0
  26. package/lib/invariant.d.ts.map +1 -0
  27. package/lib/invariant.js +123 -0
  28. package/lib/invariant.js.map +1 -0
  29. package/lib/json-render.d.ts +18 -0
  30. package/lib/json-render.d.ts.map +1 -0
  31. package/lib/json-render.js +111 -0
  32. package/lib/json-render.js.map +1 -0
  33. package/lib/json-schema-value.d.ts +18 -0
  34. package/lib/json-schema-value.d.ts.map +1 -0
  35. package/lib/json-schema-value.js +238 -0
  36. package/lib/json-schema-value.js.map +1 -0
  37. package/lib/json-schema.d.ts +101 -0
  38. package/lib/json-schema.d.ts.map +1 -0
  39. package/lib/json-schema.js +351 -0
  40. package/lib/json-schema.js.map +1 -0
  41. package/lib/presentation.d.ts +367 -0
  42. package/lib/presentation.d.ts.map +1 -0
  43. package/lib/presentation.js +8 -0
  44. package/lib/presentation.js.map +1 -0
  45. package/lib/py-names.d.ts +163 -0
  46. package/lib/py-names.d.ts.map +1 -0
  47. package/lib/py-names.js +236 -0
  48. package/lib/py-names.js.map +1 -0
  49. package/lib/py-render.d.ts +23 -0
  50. package/lib/py-render.d.ts.map +1 -0
  51. package/lib/py-render.js +434 -0
  52. package/lib/py-render.js.map +1 -0
  53. package/lib/py-sdk-doc.d.ts +29 -0
  54. package/lib/py-sdk-doc.d.ts.map +1 -0
  55. package/lib/py-sdk-doc.js +114 -0
  56. package/lib/py-sdk-doc.js.map +1 -0
  57. package/lib/py-types.d.ts +34 -0
  58. package/lib/py-types.d.ts.map +1 -0
  59. package/lib/py-types.js +40 -0
  60. package/lib/py-types.js.map +1 -0
  61. package/lib/run-code-defs.d.ts +77 -0
  62. package/lib/run-code-defs.d.ts.map +1 -0
  63. package/lib/run-code-defs.js +98 -0
  64. package/lib/run-code-defs.js.map +1 -0
  65. package/lib/runtime-code.d.ts +65 -0
  66. package/lib/runtime-code.d.ts.map +1 -0
  67. package/lib/runtime-code.js +129 -0
  68. package/lib/runtime-code.js.map +1 -0
  69. package/lib/runtime-core.d.ts +130 -0
  70. package/lib/runtime-core.d.ts.map +1 -0
  71. package/lib/runtime-core.js +33 -0
  72. package/lib/runtime-core.js.map +1 -0
  73. package/lib/runtime-execute.d.ts +82 -0
  74. package/lib/runtime-execute.d.ts.map +1 -0
  75. package/lib/runtime-execute.js +333 -0
  76. package/lib/runtime-execute.js.map +1 -0
  77. package/lib/runtime-registry.d.ts +131 -0
  78. package/lib/runtime-registry.d.ts.map +1 -0
  79. package/lib/runtime-registry.js +269 -0
  80. package/lib/runtime-registry.js.map +1 -0
  81. package/lib/runtime-results.d.ts +32 -0
  82. package/lib/runtime-results.d.ts.map +1 -0
  83. package/lib/runtime-results.js +163 -0
  84. package/lib/runtime-results.js.map +1 -0
  85. package/lib/runtime-schemas.d.ts +112 -0
  86. package/lib/runtime-schemas.d.ts.map +1 -0
  87. package/lib/runtime-schemas.js +222 -0
  88. package/lib/runtime-schemas.js.map +1 -0
  89. package/lib/scheduler.d.ts +22 -0
  90. package/lib/scheduler.d.ts.map +1 -0
  91. package/lib/scheduler.js +21 -0
  92. package/lib/scheduler.js.map +1 -0
  93. package/lib/schema-spec.d.ts +154 -0
  94. package/lib/schema-spec.d.ts.map +1 -0
  95. package/lib/schema-spec.js +9 -0
  96. package/lib/schema-spec.js.map +1 -0
  97. package/lib/schema.d.ts +5 -0
  98. package/lib/schema.d.ts.map +1 -0
  99. package/lib/schema.js +3 -0
  100. package/lib/schema.js.map +1 -0
  101. package/lib/testing.d.ts +25 -0
  102. package/lib/testing.d.ts.map +1 -0
  103. package/lib/testing.js +25 -0
  104. package/lib/testing.js.map +1 -0
  105. package/lib/tool-layer.d.ts +49 -0
  106. package/lib/tool-layer.d.ts.map +1 -0
  107. package/lib/tool-layer.js +57 -0
  108. package/lib/tool-layer.js.map +1 -0
  109. package/lib/tool-types.d.ts +385 -0
  110. package/lib/tool-types.d.ts.map +1 -0
  111. package/lib/tool-types.js +11 -0
  112. package/lib/tool-types.js.map +1 -0
  113. package/lib/ts-types.d.ts +37 -0
  114. package/lib/ts-types.d.ts.map +1 -0
  115. package/lib/ts-types.js +265 -0
  116. package/lib/ts-types.js.map +1 -0
  117. package/lib/types.d.ts +55 -0
  118. package/lib/types.d.ts.map +1 -0
  119. package/lib/types.js +7 -0
  120. package/lib/types.js.map +1 -0
  121. package/package.json +65 -0
@@ -0,0 +1,222 @@
1
+ /**
2
+ * ToolRuntime presentation collaborators: the presentation-mode resolver, the
3
+ * `code` collapse statement, prompt-section assembly, and the model-facing
4
+ * schema projections. Bodies are verbatim moves from the former `ToolRuntime`
5
+ * methods with `this.` → `rt.`.
6
+ * @module
7
+ */
8
+ import { scopeOf } from '@deepseek-ai/dsh-scope';
9
+ import { snapshotJsonValue } from '@deepseek-ai/dsh-session';
10
+ import { RUN_CODE_NAME, SDK_SECTION_ORDER } from "./code-mode.js";
11
+ import { SDK_RENDERERS } from "./runtime-core.js";
12
+ /**
13
+ * Prompt order of the `code` collapse statement: after the persona and before
14
+ * the 100-199 per-tool guidance band, so the model reads which tools it may
15
+ * call before it reads what each one is for.
16
+ */
17
+ const COLLAPSE_SECTION_ORDER = 99;
18
+ /**
19
+ * The model-facing statement of the `code` collapse. Names the consequence
20
+ * (the call fails) and the route (inside the program), because a rule the
21
+ * model can only discover by being denied is one it corrects too late.
22
+ */
23
+ const CODE_ONLY_INSTRUCTION = `\`${RUN_CODE_NAME}\` is the only tool you can call directly — a tool call naming any other tool fails. Reach every tool the SDK declares below from inside the program.`;
24
+ /**
25
+ * The prompt statement of the `code` executor collapse, registered wherever
26
+ * `sdkSection` is and rendering empty outside an effective `code`.
27
+ *
28
+ * Every tool contributes its own guidance section naming its tool, none of
29
+ * them qualify how that tool is reached, and they all render before the SDK
30
+ * (orders 100-199 against `SDK_SECTION_ORDER`). Without this the model
31
+ * reads a catalog of tools it is told to use and no statement that only
32
+ * `run_code` may be called, so it emits a native call, receives
33
+ * `UNKNOWN_TOOL` for a tool the prompt just declared, and concludes the
34
+ * deployment is inconsistent. `COLLAPSE_SECTION_ORDER` places the rule
35
+ * before that guidance rather than after it.
36
+ *
37
+ * `both` renders empty: native calls do execute there, so the rule is false.
38
+ * @param rt - the owning runtime.
39
+ * @returns the section registration.
40
+ */
41
+ export function collapseSection(rt) {
42
+ return {
43
+ name: 'tools:code-only',
44
+ order: COLLAPSE_SECTION_ORDER,
45
+ // The SAME predicate the executor denies by, so the prompt cannot state
46
+ // a rule the registry does not enforce (see `collapses`).
47
+ text: context => rt.modeFor(context.scope) === 'code' ? CODE_ONLY_INSTRUCTION : '',
48
+ };
49
+ }
50
+ /**
51
+ * The generated-SDK prompt section, registered globally by a code-mode
52
+ * deployment and per scope by `presentAs`.
53
+ *
54
+ * The body regenerates from the CALLING scope, and renders empty for an
55
+ * agent presenting natively — an agent that opted out under a code-mode
56
+ * deployment still sees the global registration, and an empty section is
57
+ * dropped from the rendered prompt.
58
+ * @param rt - the owning runtime.
59
+ * @returns the section registration.
60
+ */
61
+ export function sdkSection(rt) {
62
+ return {
63
+ name: 'tools:sdk',
64
+ order: SDK_SECTION_ORDER,
65
+ // Regenerate from the calling scope's visible tools in stable order.
66
+ text: (context) => {
67
+ const mode = rt.modeFor(context.scope);
68
+ if (mode === 'native')
69
+ return '';
70
+ const runtime = rt.requireCodeRuntime(mode);
71
+ // Own-property read: a language like `toString`/`constructor` would
72
+ // otherwise resolve an inherited Object.prototype member as a renderer.
73
+ const render = SDK_RENDERERS[runtime.language];
74
+ /* v8 ignore next -- requireCodeRuntime rejects an unknown language before this runs. */
75
+ if (render === undefined)
76
+ throw new Error(`dsh-tools: no SDK renderer for ${runtime.language}`);
77
+ return render(rt.sdkSchemas(context.scope));
78
+ },
79
+ };
80
+ }
81
+ /**
82
+ * The presentation one scope's agent sees: its own declaration, else the
83
+ * deployment default.
84
+ * @param rt - the owning runtime.
85
+ * @param scope - the calling agent, or undefined for the global view.
86
+ * @returns the resolved presentation mode.
87
+ */
88
+ export function modeFor(rt, scope) {
89
+ // Nearest scope wins along the chain: a preset's standing declaration
90
+ // covers every agent parented under it, and an agent's own (were one ever
91
+ // declared) would override its preset's. The mode decides what the model
92
+ // SEES, which is exactly the class of fact the chain inherits.
93
+ const layers = rt.layers.chainLayers(scope);
94
+ for (let index = layers.length - 1; index >= 0; index -= 1) {
95
+ const mode = layers[index]?.mode;
96
+ if (mode !== undefined)
97
+ return mode;
98
+ }
99
+ return rt.defaultMode;
100
+ }
101
+ /**
102
+ * Present the calling scope's tools in `mode` instead of the deployment
103
+ * default. Nearest scope on the chain wins, so a preset's standing
104
+ * declaration covers every agent joined under it.
105
+ *
106
+ * Scoped only, and one declaration per scope: this is how an agent preset
107
+ * composes Code Mode agents beside native ones in the same process, and a
108
+ * process-global override would be the `mode` config field instead.
109
+ * @param rt - the owning runtime.
110
+ * @param mode - the presentation the covered agents' models see.
111
+ * @returns the exact disposer that restores the deployment default.
112
+ */
113
+ export function presentAs(rt, mode) {
114
+ const ctx = rt.ctx;
115
+ if (scopeOf(ctx) === undefined) {
116
+ throw new Error('tools.presentAs() requires a scoped context (agent.ctx): a context-global presentation is the `mode` config field on the tools row');
117
+ }
118
+ const dispose = ctx.effect(function* () {
119
+ yield this.layers.effect(ctx, (layer) => {
120
+ if (layer.mode !== undefined) {
121
+ throw new Error(`tools.presentAs("${mode}") conflicts with "${layer.mode}" already declared for this scope; one composition selects one presentation`);
122
+ }
123
+ layer.mode = mode;
124
+ return () => { layer.mode = undefined; };
125
+ }, { label: 'tools.presentAs()' });
126
+ // The SDK and collapse sections are per scope for the same reason the
127
+ // mode is. Under a deployment that already defaults to a code mode this
128
+ // shadows the global registration with an identical body, which costs
129
+ // nothing and keeps one rule instead of a case analysis.
130
+ if (mode !== 'native') {
131
+ yield ctx.systemPrompt.section(this.collapseSection());
132
+ yield ctx.systemPrompt.section(this.sdkSection());
133
+ }
134
+ }.bind(rt), 'tools.presentAs()');
135
+ return dispose;
136
+ }
137
+ /**
138
+ * Build one scope's wire schemas and names for prompt-order validation.
139
+ * Restrictions do not make known tools invalid, but a mode collapse does.
140
+ */
141
+ export function wireSchemas(rt, scope) {
142
+ const view = rt.view(scope);
143
+ const mode = rt.modeFor(scope);
144
+ if (mode === 'native') {
145
+ const schemas = [...view.visible.values()].map(definition => rt.schemaOf(definition, false));
146
+ return { schemas, knownNames: [...view.knownNames] };
147
+ }
148
+ // Validate the runtime language BEFORE projecting schemas: schemaOf reads
149
+ // run_code's language-aware description/parameters getters, whose own
150
+ // flavor-table guard would otherwise surface first. This keeps the
151
+ // renderer-table rejection the canonical assembly-time error for a
152
+ // language with no SDK renderer.
153
+ rt.requireCodeRuntime(mode);
154
+ const schemas = [...view.visible.values()].map(definition => rt.schemaOf(definition, false));
155
+ if (mode === 'code') {
156
+ return {
157
+ schemas: schemas.filter(schema => schema.name === RUN_CODE_NAME),
158
+ knownNames: [RUN_CODE_NAME],
159
+ };
160
+ }
161
+ return { schemas, knownNames: [...view.knownNames, RUN_CODE_NAME] };
162
+ }
163
+ /**
164
+ * Project visible definitions onto the allowlisted model-facing schema fields,
165
+ * excluding execution and presentation callbacks.
166
+ * @param rt - the owning runtime.
167
+ * @param scope - the viewing scope (the agent); omitted = the global view.
168
+ * @returns one deep-cloned schema per visible tool.
169
+ */
170
+ export function schemas(rt, scope) {
171
+ return [...rt.view(scope).visible.values()].map(definition => rt.schemaOf(definition, true));
172
+ }
173
+ /** Project visible callable tools onto the generated Code Mode SDK contract. */
174
+ export function sdkSchemas(rt, scope) {
175
+ return [...rt.view(scope).visible.values()]
176
+ .filter(definition => definition.name !== RUN_CODE_NAME)
177
+ .map((definition) => {
178
+ const output = snapshotJsonValue(definition.output.schema);
179
+ /* v8 ignore next -- registration already validated and retained this schema as lossless JSON. */
180
+ if (output === undefined) {
181
+ throw new Error(`tool "${definition.name}" output schema must be lossless JSON before SDK projection`);
182
+ }
183
+ return {
184
+ ...rt.schemaOf(definition, true),
185
+ output,
186
+ };
187
+ });
188
+ }
189
+ /** Project one definition onto the model-facing schema fields. */
190
+ export function schemaOf(_rt, definition, detachParameters) {
191
+ const { name, description, parameters } = definition;
192
+ const detached = detachParameters ? snapshotJsonValue(parameters) : parameters;
193
+ if (detached === undefined) {
194
+ throw new Error(`tool "${name}" parameters must be lossless JSON before schema projection`);
195
+ }
196
+ return {
197
+ name,
198
+ description,
199
+ parameters: detached,
200
+ };
201
+ }
202
+ /**
203
+ * Whether the `code` mode collapse denies a model-direct call: only the
204
+ * reserved `run_code` transport may be named. Nested sub-dispatches (a
205
+ * `parent` token set) bypass the collapse. One home for the
206
+ * security-relevant predicate, shared by `resolveExecution` and
207
+ * `createExecution` so the two can never drift apart.
208
+ *
209
+ * Resolved through `modeFor`, NOT `defaultMode`: an agent given `code`
210
+ * by an agent preset under a native deployment is the composition
211
+ * `dsh-agent-tool-presentation` exists for, and reading the deployment default would
212
+ * leave exactly that agent uncollapsed — announcing one surface while
213
+ * executing another, which is the bypass this collapse closes.
214
+ * @param rt - the owning runtime.
215
+ * @param name - the tool name as registered.
216
+ * @param scope - the viewing scope whose effective presentation mode applies.
217
+ * @param nested - whether the call is a transport sub-dispatch, not a model-direct call.
218
+ */
219
+ export function collapses(rt, name, scope, nested) {
220
+ return !nested && rt.modeFor(scope) === 'code' && name !== RUN_CODE_NAME;
221
+ }
222
+ //# sourceMappingURL=runtime-schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-schemas.js","sourceRoot":"","sources":["../src/runtime-schemas.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAGhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAE5D,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAGjE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAGjD;;;;GAIG;AACH,MAAM,sBAAsB,GAAG,EAAE,CAAA;AAEjC;;;;GAIG;AACH,MAAM,qBAAqB,GAAG,KAAK,aAAa,uJAAuJ,CAAA;AAEvM;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,eAAe,CAAC,EAAmB;IACjD,OAAO;QACL,IAAI,EAAE,iBAAiB;QACvB,KAAK,EAAE,sBAAsB;QAC7B,wEAAwE;QACxE,0DAA0D;QAC1D,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAAE;KACnF,CAAA;AACH,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,UAAU,CAAC,EAAmB;IAC5C,OAAO;QACL,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,iBAAiB;QACxB,qEAAqE;QACrE,IAAI,EAAE,CAAC,OAAO,EAA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AA;AAC1E,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Upstream scheduler symbol binding, isolated as a leaf module so neither the
3
+ * package barrel nor Code Mode needs to import runtime values from the other.
4
+ * @module @dsh-cc/tools/src/scheduler
5
+ */
6
+ declare const upstreamSchedulerSymbol: unique symbol;
7
+ /**
8
+ * Scheduler entry point omitted from the generated named service API.
9
+ * The value MUST be the upstream symbol instance: the in-box agent loop reads
10
+ * the staged scheduler off the registry through the symbol exported by
11
+ * `@deepseek-ai/dsh-tools`, and a `Symbol()` is identity-unique — minting a
12
+ * private one here leaves the loop reading `undefined` and crashing every
13
+ * turn's first tool call (`undefined.prepare`). The binding is a type-erased
14
+ * `createRequire` rather than a static import so upstream's declaration graph
15
+ * (its own `Context` augmentation, whose vendored copy this package also
16
+ * ships) never enters downstream type programs; the dependency stays
17
+ * runtime-only (peer-declared).
18
+ * @internal
19
+ */
20
+ export declare const TOOL_RUNTIME_SCHEDULER: typeof upstreamSchedulerSymbol;
21
+ export {};
22
+ //# sourceMappingURL=scheduler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../src/scheduler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,CAAC,MAAM,uBAAuB,EAAE,OAAO,MAAM,CAAA;AAEpD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,sBAAsB,EAAE,OAAO,uBAEpB,CAAA"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Upstream scheduler symbol binding, isolated as a leaf module so neither the
3
+ * package barrel nor Code Mode needs to import runtime values from the other.
4
+ * @module @dsh-cc/tools/src/scheduler
5
+ */
6
+ import { createRequire } from 'node:module';
7
+ /**
8
+ * Scheduler entry point omitted from the generated named service API.
9
+ * The value MUST be the upstream symbol instance: the in-box agent loop reads
10
+ * the staged scheduler off the registry through the symbol exported by
11
+ * `@deepseek-ai/dsh-tools`, and a `Symbol()` is identity-unique — minting a
12
+ * private one here leaves the loop reading `undefined` and crashing every
13
+ * turn's first tool call (`undefined.prepare`). The binding is a type-erased
14
+ * `createRequire` rather than a static import so upstream's declaration graph
15
+ * (its own `Context` augmentation, whose vendored copy this package also
16
+ * ships) never enters downstream type programs; the dependency stays
17
+ * runtime-only (peer-declared).
18
+ * @internal
19
+ */
20
+ export const TOOL_RUNTIME_SCHEDULER = createRequire(import.meta.url)('@deepseek-ai/dsh-tools').TOOL_RUNTIME_SCHEDULER;
21
+ //# sourceMappingURL=scheduler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scheduler.js","sourceRoot":"","sources":["../src/scheduler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAI3C;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,sBAAsB,GACjC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,wBAAwB,CACxD,CAAC,sBAAsB,CAAA"}
@@ -0,0 +1,154 @@
1
+ /**
2
+ * Author-facing value-schema DSL types and compile-time inference for the
3
+ * unified JSON-value schema. Runtime compilation lives in
4
+ * {@link ./define-tool.ts}; the raw JSON Schema subset lives in
5
+ * {@link ./json-schema.ts}.
6
+ * @module dsh-tools/schema-spec
7
+ */
8
+ import type { JsonValue } from '@deepseek-ai/dsh-session';
9
+ import type { JsonSchemaNode, ObjectJsonSchema } from './json-schema.ts';
10
+ /** Annotation keywords shared by every author-facing schema node. */
11
+ export interface ValueSchemaAnnotations {
12
+ /** Human-readable description projected into JSON Schema and generated types. */
13
+ description?: string;
14
+ /** Human-readable title projected into JSON Schema. */
15
+ title?: string;
16
+ /** Non-validating default annotation; it must be lossless JSON data. */
17
+ default?: JsonValue;
18
+ /** Non-validating examples annotation; it must be lossless JSON data. */
19
+ examples?: JsonValue;
20
+ }
21
+ /** String value schema with type-correct literal constraints. */
22
+ export interface StringValueSchemaSpec extends ValueSchemaAnnotations {
23
+ type: 'string';
24
+ enum?: readonly string[];
25
+ const?: string;
26
+ }
27
+ /** Finite JSON-number schema with type-correct literal constraints. */
28
+ export interface NumberValueSchemaSpec extends ValueSchemaAnnotations {
29
+ type: 'number';
30
+ enum?: readonly number[];
31
+ const?: number;
32
+ }
33
+ /** Integer schema with type-correct literal constraints. */
34
+ export interface IntegerValueSchemaSpec extends ValueSchemaAnnotations {
35
+ type: 'integer';
36
+ enum?: readonly number[];
37
+ const?: number;
38
+ }
39
+ /** Boolean value schema with type-correct literal constraints. */
40
+ export interface BooleanValueSchemaSpec extends ValueSchemaAnnotations {
41
+ type: 'boolean';
42
+ enum?: readonly boolean[];
43
+ const?: boolean;
44
+ }
45
+ /** Null value schema with type-correct literal constraints. */
46
+ export interface NullValueSchemaSpec extends ValueSchemaAnnotations {
47
+ type: 'null';
48
+ enum?: readonly null[];
49
+ const?: null;
50
+ }
51
+ /** Array value schema; omitted `items` accepts any lossless JSON item. */
52
+ export interface ArrayValueSchemaSpec extends ValueSchemaAnnotations {
53
+ type: 'array';
54
+ items?: ValueSchemaSpec;
55
+ }
56
+ /**
57
+ * Explicit object value schema. Openness is mandatory so a nested or output
58
+ * object never acquires an accidental JSON Schema default.
59
+ */
60
+ export interface ObjectValueSchemaSpec extends ValueSchemaAnnotations {
61
+ type: 'object';
62
+ properties?: ParameterSchemaSpec;
63
+ additionalProperties: boolean;
64
+ }
65
+ /** Author-only unconstrained lossless JSON node. */
66
+ export interface JsonValueSchemaSpec extends ValueSchemaAnnotations {
67
+ type: 'json';
68
+ }
69
+ /** Exact-one union schema; at least two branches are required. */
70
+ export interface OneOfValueSchemaSpec extends ValueSchemaAnnotations {
71
+ oneOf: readonly [ValueSchemaSpec, ValueSchemaSpec, ...ValueSchemaSpec[]];
72
+ }
73
+ /** One author-facing schema for any lossless JSON value root. */
74
+ export type ValueSchemaSpec = StringValueSchemaSpec | NumberValueSchemaSpec | IntegerValueSchemaSpec | BooleanValueSchemaSpec | NullValueSchemaSpec | ArrayValueSchemaSpec | ObjectValueSchemaSpec | JsonValueSchemaSpec | OneOfValueSchemaSpec;
75
+ /** One implicit parameter-root property, optionally required. */
76
+ export type ParameterPropertySpec = ValueSchemaSpec & {
77
+ required?: true;
78
+ };
79
+ /**
80
+ * Tool parameter schema. The map itself is an implicit open object root;
81
+ * requiredness remains a per-property `required: true` annotation.
82
+ */
83
+ export type ParameterSchemaSpec = {
84
+ [key: string]: ParameterPropertySpec;
85
+ [key: symbol]: never;
86
+ };
87
+ /** Raw JSON Schema projection of the implicit parameter object. */
88
+ export interface ParameterJsonSchema extends ObjectJsonSchema {
89
+ properties: Record<string, JsonSchemaNode>;
90
+ }
91
+ /** Flatten an intersection into one object type for readable hovers. */
92
+ type Simplify<T> = {
93
+ [K in keyof T]: T[K];
94
+ } & {};
95
+ /** String keys of one property map; runtime compilation rejects symbol keys. */
96
+ type StringKeyOf<S> = Extract<keyof S, string>;
97
+ /** Keys of a property map marked `required: true`. */
98
+ type RequiredKeys<S> = {
99
+ [K in StringKeyOf<S>]: S[K] extends {
100
+ required: true;
101
+ } ? K : never;
102
+ }[StringKeyOf<S>];
103
+ /** Infer the declared value of one parameter property without key optionality. */
104
+ type InferProperty<P, Depth extends unknown[]> = InferValueAt<P, Depth>;
105
+ /** Infer an implicit property map into required and optional object keys. */
106
+ type InferProperties<S, Depth extends unknown[]> = Simplify<{
107
+ [K in RequiredKeys<S>]: InferProperty<S[K], Depth>;
108
+ } & {
109
+ [K in Exclude<StringKeyOf<S>, RequiredKeys<S>>]?: InferProperty<S[K], Depth>;
110
+ }>;
111
+ /** Infer an explicit object node, including its declared openness. */
112
+ type InferObject<S extends {
113
+ additionalProperties: boolean;
114
+ }, Depth extends unknown[]> = S extends {
115
+ properties: infer P;
116
+ } ? S['additionalProperties'] extends true ? InferProperties<P, Depth> & Record<string, JsonValue> : InferProperties<P, Depth> : S['additionalProperties'] extends true ? Record<string, JsonValue> : Record<string, never>;
117
+ /** Infer a scalar node's literal constraint before its broad primitive type. */
118
+ type InferScalar<S, Fallback> = S extends {
119
+ const: infer C;
120
+ } ? C : S extends {
121
+ enum: readonly (infer E)[];
122
+ } ? E : Fallback;
123
+ /** Add one schema-container level to bounded compile-time inference. */
124
+ type NextInferenceDepth<Depth extends unknown[]> = [unknown, ...Depth];
125
+ /** Infer one node without recursively checking it against the full author union. */
126
+ type InferValueAt<S, Depth extends unknown[]> = Depth['length'] extends 16 ? JsonValue : S extends {
127
+ type: 'string';
128
+ } ? InferScalar<S, string> : S extends {
129
+ type: 'number' | 'integer';
130
+ } ? InferScalar<S, number> : S extends {
131
+ type: 'boolean';
132
+ } ? InferScalar<S, boolean> : S extends {
133
+ type: 'null';
134
+ } ? null : S extends {
135
+ type: 'array';
136
+ } ? S extends {
137
+ items: infer I;
138
+ } ? InferValueAt<I, NextInferenceDepth<Depth>>[] : JsonValue[] : S extends {
139
+ type: 'object';
140
+ additionalProperties: boolean;
141
+ } ? InferObject<S, NextInferenceDepth<Depth>> : S extends {
142
+ type: 'json';
143
+ } ? JsonValue : S extends {
144
+ oneOf: readonly unknown[];
145
+ } ? InferValueAt<S['oneOf'][number], NextInferenceDepth<Depth>> : never;
146
+ /**
147
+ * Infer the TypeScript value accepted by an author-facing value schema. Exact
148
+ * inference is bounded to 16 container levels, then falls back to `JsonValue`.
149
+ */
150
+ export type InferValue<S> = InferValueAt<S, []>;
151
+ /** Infer the TypeScript argument object for an implicit parameter schema. */
152
+ export type InferArgs<S> = InferProperties<S, []>;
153
+ export {};
154
+ //# sourceMappingURL=schema-spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-spec.d.ts","sourceRoot":"","sources":["../src/schema-spec.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAExE,qEAAqE;AACrE,MAAM,WAAW,sBAAsB;IACrC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tC,CAAC,SAAS;IAAE,KAAK,EAAE,SAAS,OAAO,EAAE,CAAA;CAAE,GACnC,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,EAAE,kBAAkB,CAAC,KAAK,CAAC,CAAC,GAC3D,KAAK,CAAA;AAE3B;;;GAGG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,YAAY,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AAE/C,6EAA6E;AAC7E,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,eAAe,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Author-facing value-schema DSL types and compile-time inference for the
3
+ * unified JSON-value schema. Runtime compilation lives in
4
+ * {@link ./define-tool.ts}; the raw JSON Schema subset lives in
5
+ * {@link ./json-schema.ts}.
6
+ * @module dsh-tools/schema-spec
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=schema-spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-spec.js","sourceRoot":"","sources":["../src/schema-spec.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
@@ -0,0 +1,5 @@
1
+ /** Unified JSON-value schema DSL, inference, compilation, and typed tool helper. @module dsh-tools/schema */
2
+ export type { ArrayValueSchemaSpec, BooleanValueSchemaSpec, InferArgs, InferValue, IntegerValueSchemaSpec, JsonValueSchemaSpec, NullValueSchemaSpec, NumberValueSchemaSpec, ObjectValueSchemaSpec, OneOfValueSchemaSpec, ParameterJsonSchema, ParameterPropertySpec, ParameterSchemaSpec, StringValueSchemaSpec, ValueSchemaAnnotations, ValueSchemaSpec, } from './schema-spec.ts';
3
+ export { defineTool, parameterSchemaSpecToJsonSchema, ToolArgsError, validateArgs, valueSchemaSpecToJsonSchema } from './define-tool.ts';
4
+ export type { DefineToolOptions } from './define-tool.ts';
5
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,6GAA6G;AAE7G,YAAY,EACV,oBAAoB,EACpB,sBAAsB,EACtB,SAAS,EACT,UAAU,EACV,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,eAAe,GAChB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,UAAU,EAAE,+BAA+B,EAAE,aAAa,EAAE,YAAY,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAA;AACxI,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA"}
package/lib/schema.js ADDED
@@ -0,0 +1,3 @@
1
+ /** Unified JSON-value schema DSL, inference, compilation, and typed tool helper. @module dsh-tools/schema */
2
+ export { defineTool, parameterSchemaSpecToJsonSchema, ToolArgsError, validateArgs, valueSchemaSpecToJsonSchema } from "./define-tool.js";
3
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,6GAA6G;AAoB7G,OAAO,EAAE,UAAU,EAAE,+BAA+B,EAAE,aAAa,EAAE,YAAY,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAA"}
@@ -0,0 +1,25 @@
1
+ /** Canonical tool-definition fixtures for repository tests. @module dsh-tools/testing */
2
+ import type { ContentBlock } from '@deepseek-ai/dsh-llm';
3
+ import type { DefineToolOptions, ParameterSchemaSpec } from './schema.ts';
4
+ import type { ToolDefinition, ToolRunContext } from './index.ts';
5
+ declare const CONTENT_VALUE_SCHEMA: {
6
+ readonly type: "array";
7
+ readonly items: {
8
+ readonly type: "json";
9
+ };
10
+ };
11
+ /** Options for a fixture whose canonical value is its rendered content array. */
12
+ export type ContentToolFixtureOptions<S extends ParameterSchemaSpec> = Omit<DefineToolOptions<S, typeof CONTENT_VALUE_SCHEMA>, 'output' | 'execute'> & {
13
+ /** Produce the fixture's content blocks as its canonical test value. */
14
+ execute(args: import('./schema.ts').InferArgs<S>, exec: ToolRunContext): Promise<ContentBlock[]>;
15
+ };
16
+ /**
17
+ * Define a test fixture that deliberately uses its content blocks as the
18
+ * canonical JSON value. Product tools must declare domain-owned DTOs instead.
19
+ * @param options - ordinary fixture fields plus a content-producing body.
20
+ * @returns a registry-ready tool with an explicit JSON-array output contract.
21
+ * @internal
22
+ */
23
+ export declare function defineContentToolFixture<const S extends ParameterSchemaSpec>(options: ContentToolFixtureOptions<S>): ToolDefinition;
24
+ export {};
25
+ //# sourceMappingURL=testing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,yFAAyF;AAEzF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAGxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEhE,QAAA,MAAM,oBAAoB;;;;;CAAsD,CAAA;AAEhF,iFAAiF;AACjF,MAAM,MAAM,yBAAyB,CAAC,CAAC,SAAS,mBAAmB,IAAI,IAAI,CACzE,iBAAiB,CAAC,CAAC,EAAE,OAAO,oBAAoB,CAAC,EACjD,QAAQ,GAAG,SAAS,CACrB,GAAG;IACF,wEAAwE;IACxE,OAAO,CAAC,IAAI,EAAE,OAAO,aAAa,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAAA;CACjG,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,CAAC,CAAC,SAAS,mBAAmB,EAC1E,OAAO,EAAE,yBAAyB,CAAC,CAAC,CAAC,GACpC,cAAc,CAahB"}
package/lib/testing.js ADDED
@@ -0,0 +1,25 @@
1
+ /** Canonical tool-definition fixtures for repository tests. @module dsh-tools/testing */
2
+ import { defineTool } from "./schema.js";
3
+ const CONTENT_VALUE_SCHEMA = { type: 'array', items: { type: 'json' } };
4
+ /**
5
+ * Define a test fixture that deliberately uses its content blocks as the
6
+ * canonical JSON value. Product tools must declare domain-owned DTOs instead.
7
+ * @param options - ordinary fixture fields plus a content-producing body.
8
+ * @returns a registry-ready tool with an explicit JSON-array output contract.
9
+ * @internal
10
+ */
11
+ export function defineContentToolFixture(options) {
12
+ // oxlint-disable-next-line typescript/unbound-method
13
+ const execute = options.execute;
14
+ return defineTool({
15
+ ...options,
16
+ output: {
17
+ schema: CONTENT_VALUE_SCHEMA,
18
+ render: (_args, value) => value,
19
+ },
20
+ async execute(args, exec) {
21
+ return await execute(args, exec);
22
+ },
23
+ });
24
+ }
25
+ //# sourceMappingURL=testing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing.js","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,yFAAyF;AAIzF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAIxC,MAAM,oBAAoB,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAW,CAAA;AAWhF;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CACtC,OAAqC;IAErC,qDAAqD;IACrD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;IAC/B,OAAO,UAAU,CAAC;QAChB,GAAG,OAAO;QACV,MAAM,EAAE;YACN,MAAM,EAAE,oBAAoB;YAC5B,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAkC;SAC7D;QACD,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI;YACtB,OAAO,MAAM,OAAO,CAAC,IAAI,EAAE,IAAI,CAA2B,CAAA;QAC5D,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * One scope's tool-registry contribution: visibility, reservations,
3
+ * restrictions, guards, and per-scope presentation shadowing.
4
+ * @module tool-layer
5
+ */
6
+ import { AnonymousEntries, NamedEntries } from '@deepseek-ai/dsh-scope';
7
+ import type { ScopeKey, ScopeLayer } from '@deepseek-ai/dsh-scope';
8
+ import type { CompiledToolRestriction, ToolDefinition, ToolExecution, ToolGuard, PreToolDecision, ToolPresentationMode } from './tool-types.ts';
9
+ /** One scope's complete tool-registry contribution. */
10
+ export declare class ToolLayer implements ScopeLayer {
11
+ readonly tools: NamedEntries<ToolDefinition>;
12
+ /** Known-but-invisible capability names, so a scoped restriction can gate a tool before it loads. */
13
+ readonly reserved: NamedEntries<undefined>;
14
+ readonly restrictions: AnonymousEntries<CompiledToolRestriction>;
15
+ readonly guards: AnonymousEntries<ToolGuard>;
16
+ /**
17
+ * Presentation this scope's agent declared for itself, shadowing the
18
+ * deployment default. One cell rather than an entry table: two answers to
19
+ * "which form does the model see" is a contradiction, not a merge.
20
+ */
21
+ mode: ToolPresentationMode | undefined;
22
+ constructor(scope: ScopeKey | undefined);
23
+ /** Whether every contribution table in this aggregate layer is empty. */
24
+ isEmpty(): boolean;
25
+ /** Whether every compiled restriction in this layer admits a global tool name. */
26
+ admits(name: string): boolean;
27
+ /** First monotonic denial from this layer's live guard registrations. */
28
+ guardReason(exec: ToolExecution): string | undefined;
29
+ }
30
+ /** Approval decision plus whether the approval channel reported cancellation. */
31
+ export interface ToolAskResolution {
32
+ readonly decision: Extract<PreToolDecision, {
33
+ kind: 'allow' | 'deny';
34
+ }>;
35
+ readonly approvalCancelled: boolean;
36
+ }
37
+ /** Caller cancellation and dispatch state kept outside the around-wrapper view. */
38
+ export interface ToolCancellationState {
39
+ readonly callerSignal: AbortSignal;
40
+ bodyInvoked: boolean;
41
+ }
42
+ /** One dispatch-scoped fused signal plus listener cleanup after the body settles. */
43
+ export interface FusedToolSignal {
44
+ readonly signal: AbortSignal;
45
+ dispose(): void;
46
+ }
47
+ /** Resolve the run_code overlap cap at the owning config boundary (direct construction bypasses the Loader schema). */
48
+ export declare function resolveMaxParallelSubCalls(value: number | undefined): number;
49
+ //# sourceMappingURL=tool-layer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-layer.d.ts","sourceRoot":"","sources":["../src/tool-layer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACvE,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAClE,OAAO,KAAK,EAAE,uBAAuB,EAAE,cAAc,EAAE,aAAa,EAAE,SAAS,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAE/I,uDAAuD;AACvD,qBAAa,SAAU,YAAW,UAAU;IAC1C,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC,cAAc,CAAC,CAAA;IAC5C,qGAAqG;IACrG,QAAQ,CAAC,QAAQ,0BAA0G;IAC3H,QAAQ,CAAC,YAAY,4CAAkD;IACvE,QAAQ,CAAC,MAAM,8BAAoC;IACnD;;;;OAIG;IACH,IAAI,EAAE,oBAAoB,GAAG,SAAS,CAAA;gBAE1B,KAAK,EAAE,QAAQ,GAAG,SAAS;IAMvC,yEAAyE;IACzE,OAAO,IAAI,OAAO;IAKlB,kFAAkF;IAClF,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAQ7B,yEAAyE;IACzE,WAAW,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS;CAOrD;AAED,iFAAiF;AACjF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,eAAe,EAAE;QAAE,IAAI,EAAE,OAAO,GAAG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