@noetic-tools/core 5.19.1 → 5.19.3
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/dist/adapters/openrouter.js +5 -0
- package/dist/builders/control-flow-builders.d.ts +15 -6
- package/dist/builders/control-flow-builders.js +8 -0
- package/dist/builders/decide-builders.d.ts +2 -5
- package/dist/builders/dynamic-workflow.d.ts +54 -2
- package/dist/builders/dynamic-workflow.js +247 -12
- package/dist/builders/every.d.ts +3 -3
- package/dist/builders/every.js +2 -1
- package/dist/builders/mcp-url-pattern.d.ts +13 -0
- package/dist/builders/mcp-url-pattern.js +85 -0
- package/dist/builders/provide-builder.d.ts +3 -2
- package/dist/builders/provide-builder.js +2 -1
- package/dist/builders/sequence.d.ts +14 -0
- package/dist/builders/sequence.js +103 -0
- package/dist/builders/spawn-builder.d.ts +3 -2
- package/dist/builders/spawn-builder.js +3 -2
- package/dist/builders/step-builders.d.ts +80 -1
- package/dist/builders/step-builders.js +115 -1
- package/dist/builders/verify-builder.d.ts +79 -0
- package/dist/builders/verify-builder.js +69 -0
- package/dist/builders/workflow-acp-grants.d.ts +42 -0
- package/dist/builders/workflow-acp-grants.js +224 -0
- package/dist/builders/workflow-child-nodes.d.ts +21 -0
- package/dist/builders/workflow-child-nodes.js +336 -0
- package/dist/builders/workflow-connection-nodes.d.ts +25 -0
- package/dist/builders/workflow-connection-nodes.js +198 -0
- package/dist/builders/workflow-connections.d.ts +90 -0
- package/dist/builders/workflow-connections.js +560 -0
- package/dist/builders/workflow-control-nodes.d.ts +13 -0
- package/dist/builders/workflow-control-nodes.js +213 -0
- package/dist/builders/workflow-hydrator.d.ts +56 -3
- package/dist/builders/workflow-hydrator.js +53 -520
- package/dist/builders/workflow-mcp-servers.d.ts +24 -0
- package/dist/builders/workflow-mcp-servers.js +220 -0
- package/dist/builders/workflow-verify.d.ts +19 -0
- package/dist/builders/workflow-verify.js +194 -0
- package/dist/conditions/conditions.d.ts +7 -5
- package/dist/conditions/conditions.js +7 -4
- package/dist/connections/blobs.d.ts +33 -0
- package/dist/connections/blobs.js +77 -0
- package/dist/connections/cron-schedule.d.ts +32 -0
- package/dist/connections/cron-schedule.js +213 -0
- package/dist/connections/durability.d.ts +65 -0
- package/dist/connections/durability.js +54 -0
- package/dist/connections/errors.d.ts +30 -0
- package/dist/connections/errors.js +100 -0
- package/dist/connections/event-stream.d.ts +24 -0
- package/dist/connections/event-stream.js +176 -0
- package/dist/connections/gates.d.ts +94 -0
- package/dist/connections/gates.js +271 -0
- package/dist/connections/glob.d.ts +10 -0
- package/dist/connections/glob.js +46 -0
- package/dist/connections/handle.d.ts +22 -0
- package/dist/connections/handle.js +84 -0
- package/dist/connections/harness-wiring.d.ts +52 -0
- package/dist/connections/harness-wiring.js +143 -0
- package/dist/connections/in-memory-connection.d.ts +147 -0
- package/dist/connections/in-memory-connection.js +593 -0
- package/dist/connections/index.d.ts +34 -0
- package/dist/connections/index.js +23 -0
- package/dist/connections/json-schema.d.ts +28 -0
- package/dist/connections/json-schema.js +338 -0
- package/dist/connections/model-tools.d.ts +46 -0
- package/dist/connections/model-tools.js +466 -0
- package/dist/connections/negotiation.d.ts +30 -0
- package/dist/connections/negotiation.js +159 -0
- package/dist/connections/policy.d.ts +21 -0
- package/dist/connections/policy.js +34 -0
- package/dist/connections/pool.d.ts +111 -0
- package/dist/connections/pool.js +339 -0
- package/dist/connections/refs.d.ts +74 -0
- package/dist/connections/refs.js +316 -0
- package/dist/connections/registry-types.d.ts +141 -0
- package/dist/connections/registry-types.js +14 -0
- package/dist/connections/registry.d.ts +125 -0
- package/dist/connections/registry.js +775 -0
- package/dist/connections/secrets.d.ts +59 -0
- package/dist/connections/secrets.js +153 -0
- package/dist/connections/settle.d.ts +9 -0
- package/dist/connections/settle.js +26 -0
- package/dist/connections/sources.d.ts +27 -0
- package/dist/connections/sources.js +300 -0
- package/dist/connections/triggers.d.ts +78 -0
- package/dist/connections/triggers.js +310 -0
- package/dist/connections/values.d.ts +26 -0
- package/dist/connections/values.js +93 -0
- package/dist/connections/views.d.ts +31 -0
- package/dist/connections/views.js +176 -0
- package/dist/expression/check.js +80 -1
- package/dist/expression/jsonata.d.ts +14 -4
- package/dist/expression/jsonata.js +27 -9
- package/dist/expression/step-outputs.d.ts +25 -0
- package/dist/expression/step-outputs.js +78 -0
- package/dist/harness/agent-harness.d.ts +69 -166
- package/dist/harness/agent-harness.js +170 -262
- package/dist/harness/call-span-collector.d.ts +33 -0
- package/dist/harness/call-span-collector.js +83 -0
- package/dist/harness/connection-gate.d.ts +78 -0
- package/dist/harness/connection-gate.js +170 -0
- package/dist/harness/deps/interpreter.d.ts +1 -0
- package/dist/harness/deps/interpreter.js +1 -0
- package/dist/harness/deps/runtime.d.ts +1 -1
- package/dist/harness/deps/types.d.ts +1 -1
- package/dist/harness/harness-options.d.ts +153 -0
- package/dist/harness/harness-options.js +36 -0
- package/dist/harness/harness-tracing.d.ts +16 -0
- package/dist/harness/harness-tracing.js +35 -0
- package/dist/harness/llm-client.d.ts +71 -0
- package/dist/harness/llm-client.js +218 -0
- package/dist/harness/model-call.d.ts +2 -7
- package/dist/harness/model-call.js +21 -549
- package/dist/harness/model-request.d.ts +42 -0
- package/dist/harness/model-request.js +159 -0
- package/dist/harness/model-stream.d.ts +39 -0
- package/dist/harness/model-stream.js +131 -0
- package/dist/harness/model-tool-round.d.ts +37 -0
- package/dist/harness/model-tool-round.js +197 -0
- package/dist/harness/spend.d.ts +2 -0
- package/dist/harness/spend.js +5 -1
- package/dist/index.d.ts +33 -8
- package/dist/index.js +18 -1
- package/dist/interpreter/connection-steps.d.ts +194 -0
- package/dist/interpreter/connection-steps.js +537 -0
- package/dist/interpreter/execute-action.d.ts +2 -8
- package/dist/interpreter/execute-action.js +3 -178
- package/dist/interpreter/execute-call.d.ts +19 -0
- package/dist/interpreter/execute-call.js +99 -0
- package/dist/interpreter/execute-control.d.ts +6 -1
- package/dist/interpreter/execute-control.js +14 -0
- package/dist/interpreter/execute-invoke-tool.d.ts +11 -0
- package/dist/interpreter/execute-invoke-tool.js +183 -0
- package/dist/interpreter/execute-verify.d.ts +21 -0
- package/dist/interpreter/execute-verify.js +391 -0
- package/dist/interpreter/execute-wait.d.ts +21 -0
- package/dist/interpreter/execute-wait.js +233 -0
- package/dist/interpreter/execute.js +24 -133
- package/dist/interpreter/step-kind-dispatch.d.ts +24 -0
- package/dist/interpreter/step-kind-dispatch.js +157 -0
- package/dist/interpreter/step-walk.d.ts +2 -0
- package/dist/interpreter/step-walk.js +24 -0
- package/dist/interpreter/verify-host.d.ts +40 -0
- package/dist/interpreter/verify-host.js +245 -0
- package/dist/runtime/durable/step-ledger.d.ts +31 -1
- package/dist/runtime/durable/step-ledger.js +87 -1
- package/dist/runtime/in-memory-artifact-store.d.ts +24 -0
- package/dist/runtime/in-memory-artifact-store.js +240 -0
- package/dist/schemas/workflow.d.ts +2 -2
- package/dist/schemas/workflow.js +1 -1
- package/dist/util/harness-internals.d.ts +25 -0
- package/dist/util/harness-internals.js +35 -0
- package/package.json +3 -3
- package/schema/noetic-workflow.schema.json +1309 -180
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The JSON Schema subset the connection gates need (spec 35 § Gates, gate 2
|
|
3
|
+
* and gate 6). A connection's manifest publishes operation schemas as JSON
|
|
4
|
+
* Schema — from a profile through `z.toJSONSchema`, or from an MCP server's
|
|
5
|
+
* tool list — so the harness checks arguments against them without a profile
|
|
6
|
+
* object in hand.
|
|
7
|
+
*
|
|
8
|
+
* `validateJsonSchema` covers the keywords profiles and MCP tools use: `type`,
|
|
9
|
+
* `properties`, `required`, `additionalProperties`, `items`, `enum`, `const`,
|
|
10
|
+
* `anyOf`/`oneOf`/`allOf`, string length and pattern, number bounds, and local
|
|
11
|
+
* `$ref`s into `$defs`/`definitions`. Unknown keywords are ignored rather than
|
|
12
|
+
* failing a call. Nothing is ever defaulted on the caller's behalf.
|
|
13
|
+
*/
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region Helpers
|
|
16
|
+
const MAX_DEPTH = 64;
|
|
17
|
+
function isRecord(value) {
|
|
18
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
19
|
+
}
|
|
20
|
+
function asSchema(value) {
|
|
21
|
+
return isRecord(value) ? value : undefined;
|
|
22
|
+
}
|
|
23
|
+
function asSchemaList(value) {
|
|
24
|
+
if (!Array.isArray(value)) {
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
return value.filter(isRecord);
|
|
28
|
+
}
|
|
29
|
+
function formatPath(path) {
|
|
30
|
+
if (path.length === 0) {
|
|
31
|
+
return '(root)';
|
|
32
|
+
}
|
|
33
|
+
return path
|
|
34
|
+
.map((p) => (typeof p === 'number' ? `[${p}]` : `.${p}`))
|
|
35
|
+
.join('')
|
|
36
|
+
.slice(0);
|
|
37
|
+
}
|
|
38
|
+
function typeOf(value) {
|
|
39
|
+
if (value === null) {
|
|
40
|
+
return 'null';
|
|
41
|
+
}
|
|
42
|
+
if (Array.isArray(value)) {
|
|
43
|
+
return 'array';
|
|
44
|
+
}
|
|
45
|
+
if (typeof value === 'number') {
|
|
46
|
+
return Number.isInteger(value) ? 'integer' : 'number';
|
|
47
|
+
}
|
|
48
|
+
return typeof value;
|
|
49
|
+
}
|
|
50
|
+
function matchesType(expected, value) {
|
|
51
|
+
const actual = typeOf(value);
|
|
52
|
+
if (expected === 'number') {
|
|
53
|
+
return actual === 'number' || actual === 'integer';
|
|
54
|
+
}
|
|
55
|
+
return expected === actual;
|
|
56
|
+
}
|
|
57
|
+
function deepEqual(a, b) {
|
|
58
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
59
|
+
}
|
|
60
|
+
/** Follows a local `$ref` (`#/$defs/X` or `#/definitions/X`); unknown refs resolve to `{}`. */
|
|
61
|
+
function deref(schema, root) {
|
|
62
|
+
const ref = schema.$ref;
|
|
63
|
+
if (typeof ref !== 'string' || !ref.startsWith('#')) {
|
|
64
|
+
return schema;
|
|
65
|
+
}
|
|
66
|
+
let current = root;
|
|
67
|
+
for (const part of ref.slice(1).split('/').filter(Boolean)) {
|
|
68
|
+
current = isRecord(current) ? current[part.replace(/~1/g, '/').replace(/~0/g, '~')] : undefined;
|
|
69
|
+
}
|
|
70
|
+
return asSchema(current) ?? {};
|
|
71
|
+
}
|
|
72
|
+
/** Builds a `Visit`. */
|
|
73
|
+
function at(schema, value, path) {
|
|
74
|
+
return {
|
|
75
|
+
schema,
|
|
76
|
+
value,
|
|
77
|
+
path,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function errorsFor(visit, state) {
|
|
81
|
+
const sub = {
|
|
82
|
+
root: state.root,
|
|
83
|
+
errors: [],
|
|
84
|
+
depth: state.depth,
|
|
85
|
+
};
|
|
86
|
+
check(visit, sub);
|
|
87
|
+
return sub.errors;
|
|
88
|
+
}
|
|
89
|
+
const checkType = ({ schema, value, path }, state) => {
|
|
90
|
+
const type = schema.type;
|
|
91
|
+
const types = Array.isArray(type)
|
|
92
|
+
? type
|
|
93
|
+
: typeof type === 'string'
|
|
94
|
+
? [
|
|
95
|
+
type,
|
|
96
|
+
]
|
|
97
|
+
: [];
|
|
98
|
+
if (types.length === 0) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (types.some((t) => typeof t === 'string' && matchesType(t, value))) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
state.errors.push(`${formatPath(path)}: expected ${types.join(' | ')}, got ${typeOf(value)}`);
|
|
105
|
+
};
|
|
106
|
+
const checkEnum = ({ schema, value, path }, state) => {
|
|
107
|
+
if ('const' in schema && !deepEqual(schema.const, value)) {
|
|
108
|
+
state.errors.push(`${formatPath(path)}: expected ${JSON.stringify(schema.const)}`);
|
|
109
|
+
}
|
|
110
|
+
const options = schema.enum;
|
|
111
|
+
if (!Array.isArray(options)) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (!options.some((option) => deepEqual(option, value))) {
|
|
115
|
+
state.errors.push(`${formatPath(path)}: must be one of ${JSON.stringify(options)}`);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
const checkObject = ({ schema, value, path }, state) => {
|
|
119
|
+
if (!isRecord(value)) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const properties = asSchema(schema.properties) ?? {};
|
|
123
|
+
const required = Array.isArray(schema.required) ? schema.required : [];
|
|
124
|
+
for (const key of required) {
|
|
125
|
+
if (typeof key === 'string' && !(key in value)) {
|
|
126
|
+
state.errors.push(`${formatPath([
|
|
127
|
+
...path,
|
|
128
|
+
key,
|
|
129
|
+
])}: required`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
for (const [key, child] of Object.entries(value)) {
|
|
133
|
+
const propertySchema = asSchema(properties[key]);
|
|
134
|
+
if (propertySchema) {
|
|
135
|
+
check(at(propertySchema, child, [
|
|
136
|
+
...path,
|
|
137
|
+
key,
|
|
138
|
+
]), state);
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (schema.additionalProperties === false) {
|
|
142
|
+
state.errors.push(`${formatPath([
|
|
143
|
+
...path,
|
|
144
|
+
key,
|
|
145
|
+
])}: unexpected property`);
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
const additional = asSchema(schema.additionalProperties);
|
|
149
|
+
if (additional) {
|
|
150
|
+
check(at(additional, child, [
|
|
151
|
+
...path,
|
|
152
|
+
key,
|
|
153
|
+
]), state);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
const checkArray = ({ schema, value, path }, state) => {
|
|
158
|
+
if (!Array.isArray(value)) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const items = asSchema(schema.items);
|
|
162
|
+
if (items) {
|
|
163
|
+
value.forEach((item, i) => {
|
|
164
|
+
check(at(items, item, [
|
|
165
|
+
...path,
|
|
166
|
+
i,
|
|
167
|
+
]), state);
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
if (typeof schema.minItems === 'number' && value.length < schema.minItems) {
|
|
171
|
+
state.errors.push(`${formatPath(path)}: needs at least ${schema.minItems} items`);
|
|
172
|
+
}
|
|
173
|
+
if (typeof schema.maxItems === 'number' && value.length > schema.maxItems) {
|
|
174
|
+
state.errors.push(`${formatPath(path)}: allows at most ${schema.maxItems} items`);
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
const checkString = ({ schema, value, path }, state) => {
|
|
178
|
+
if (typeof value !== 'string') {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
if (typeof schema.minLength === 'number' && value.length < schema.minLength) {
|
|
182
|
+
state.errors.push(`${formatPath(path)}: shorter than ${schema.minLength}`);
|
|
183
|
+
}
|
|
184
|
+
if (typeof schema.maxLength === 'number' && value.length > schema.maxLength) {
|
|
185
|
+
state.errors.push(`${formatPath(path)}: longer than ${schema.maxLength}`);
|
|
186
|
+
}
|
|
187
|
+
if (typeof schema.pattern === 'string' && !new RegExp(schema.pattern, 'u').test(value)) {
|
|
188
|
+
state.errors.push(`${formatPath(path)}: does not match ${schema.pattern}`);
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
const checkNumber = ({ schema, value, path }, state) => {
|
|
192
|
+
if (typeof value !== 'number') {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
if (typeof schema.minimum === 'number' && value < schema.minimum) {
|
|
196
|
+
state.errors.push(`${formatPath(path)}: below ${schema.minimum}`);
|
|
197
|
+
}
|
|
198
|
+
if (typeof schema.maximum === 'number' && value > schema.maximum) {
|
|
199
|
+
state.errors.push(`${formatPath(path)}: above ${schema.maximum}`);
|
|
200
|
+
}
|
|
201
|
+
if (typeof schema.exclusiveMinimum === 'number' && value <= schema.exclusiveMinimum) {
|
|
202
|
+
state.errors.push(`${formatPath(path)}: must exceed ${schema.exclusiveMinimum}`);
|
|
203
|
+
}
|
|
204
|
+
if (typeof schema.exclusiveMaximum === 'number' && value >= schema.exclusiveMaximum) {
|
|
205
|
+
state.errors.push(`${formatPath(path)}: must be below ${schema.exclusiveMaximum}`);
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
const checkCombinators = ({ schema, value, path }, state) => {
|
|
209
|
+
for (const sub of asSchemaList(schema.allOf)) {
|
|
210
|
+
check({
|
|
211
|
+
schema: sub,
|
|
212
|
+
value: value,
|
|
213
|
+
path: path,
|
|
214
|
+
}, state);
|
|
215
|
+
}
|
|
216
|
+
const anyOf = [
|
|
217
|
+
...asSchemaList(schema.anyOf),
|
|
218
|
+
...asSchemaList(schema.oneOf),
|
|
219
|
+
];
|
|
220
|
+
if (anyOf.length === 0) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
const passes = anyOf.some((sub) => errorsFor({
|
|
224
|
+
schema: sub,
|
|
225
|
+
value,
|
|
226
|
+
path,
|
|
227
|
+
}, state).length === 0);
|
|
228
|
+
if (!passes) {
|
|
229
|
+
state.errors.push(`${formatPath(path)}: matches none of the allowed shapes`);
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
const KEYWORD_CHECKS = [
|
|
233
|
+
checkType,
|
|
234
|
+
checkEnum,
|
|
235
|
+
checkObject,
|
|
236
|
+
checkArray,
|
|
237
|
+
checkString,
|
|
238
|
+
checkNumber,
|
|
239
|
+
checkCombinators,
|
|
240
|
+
];
|
|
241
|
+
function check({ schema: rawSchema, value, path }, state) {
|
|
242
|
+
if (state.depth > MAX_DEPTH) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
state.depth += 1;
|
|
246
|
+
const schema = deref(rawSchema, state.root);
|
|
247
|
+
for (const keywordCheck of KEYWORD_CHECKS) {
|
|
248
|
+
keywordCheck({
|
|
249
|
+
schema,
|
|
250
|
+
value,
|
|
251
|
+
path,
|
|
252
|
+
}, state);
|
|
253
|
+
}
|
|
254
|
+
state.depth -= 1;
|
|
255
|
+
}
|
|
256
|
+
/** The branches a schema offers at one level: itself, or each `anyOf`/`oneOf` alternative. */
|
|
257
|
+
function branches(schema, root) {
|
|
258
|
+
const resolved = deref(schema, root);
|
|
259
|
+
const alternatives = [
|
|
260
|
+
...asSchemaList(resolved.anyOf),
|
|
261
|
+
...asSchemaList(resolved.oneOf),
|
|
262
|
+
].map((s) => deref(s, root));
|
|
263
|
+
const all = [
|
|
264
|
+
resolved,
|
|
265
|
+
...alternatives,
|
|
266
|
+
...asSchemaList(resolved.allOf).map((s) => deref(s, root)),
|
|
267
|
+
];
|
|
268
|
+
return all;
|
|
269
|
+
}
|
|
270
|
+
/** Whether a schema accepts a `{ $secret }` object at this level (a `sensitive()` field). */
|
|
271
|
+
function acceptsSecretHere(schema, root) {
|
|
272
|
+
return branches(schema, root).some((branch) => {
|
|
273
|
+
const properties = asSchema(branch.properties);
|
|
274
|
+
return properties !== undefined && '$secret' in properties;
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
function childSchemas(schema, root, step) {
|
|
278
|
+
const found = [];
|
|
279
|
+
for (const branch of branches(schema, root)) {
|
|
280
|
+
if (typeof step === 'number') {
|
|
281
|
+
const items = asSchema(branch.items);
|
|
282
|
+
if (items) {
|
|
283
|
+
found.push(items);
|
|
284
|
+
}
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
const property = asSchema(asSchema(branch.properties)?.[step]);
|
|
288
|
+
if (property) {
|
|
289
|
+
found.push(property);
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
const additional = asSchema(branch.additionalProperties);
|
|
293
|
+
if (additional) {
|
|
294
|
+
found.push(additional);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return found;
|
|
298
|
+
}
|
|
299
|
+
//#endregion
|
|
300
|
+
//#region Public API
|
|
301
|
+
/**
|
|
302
|
+
* Checks `value` against a JSON Schema.
|
|
303
|
+
* @returns One message per problem; empty when the value matches.
|
|
304
|
+
*/
|
|
305
|
+
export function validateJsonSchema(schema, value) {
|
|
306
|
+
const state = {
|
|
307
|
+
root: schema,
|
|
308
|
+
errors: [],
|
|
309
|
+
depth: 0,
|
|
310
|
+
};
|
|
311
|
+
check({
|
|
312
|
+
schema: schema,
|
|
313
|
+
value: value,
|
|
314
|
+
path: [],
|
|
315
|
+
}, state);
|
|
316
|
+
return state.errors;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Whether the field at `path` is `sensitive` — its schema accepts a
|
|
320
|
+
* `{ $secret }` value (spec 36 `sensitive()` publishes as `anyOf: [T, { $secret }]`).
|
|
321
|
+
*/
|
|
322
|
+
export function secretAllowedAt(schema, path) {
|
|
323
|
+
let level = [
|
|
324
|
+
schema,
|
|
325
|
+
];
|
|
326
|
+
for (const step of path) {
|
|
327
|
+
level = level.flatMap((s) => childSchemas(s, schema, step));
|
|
328
|
+
if (level.length === 0) {
|
|
329
|
+
return false;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
return level.some((s) => acceptsSecretHere(s, schema));
|
|
333
|
+
}
|
|
334
|
+
/** Renders a path the way validation messages do: `.thread.id`, `[0]`. */
|
|
335
|
+
export function describeJsonPath(path) {
|
|
336
|
+
return formatPath(path);
|
|
337
|
+
}
|
|
338
|
+
//#endregion
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model tools (spec 35 § Model tools). How a connection's operations reach the
|
|
3
|
+
* model is its `expose` setting:
|
|
4
|
+
*
|
|
5
|
+
* - `'eager'` (default): the operations its profile marks `eager`, plus
|
|
6
|
+
* `<name>_ops` (lists the rest) and `<name>_call` (runs one, or reads an
|
|
7
|
+
* `'ask'` read). A connection with no profile has no eager set, so its tools
|
|
8
|
+
* are exposed as they are.
|
|
9
|
+
* - `'all'`: every operation as its own tool.
|
|
10
|
+
* - `'none'`: none; the connection is for steps and triggers only.
|
|
11
|
+
*
|
|
12
|
+
* Tools are named `<name>_<op>` (dots become underscores). When two
|
|
13
|
+
* connections offer the same profile operation, the model gets one tool named
|
|
14
|
+
* after the operation (`ui_tap`) with a `target` argument naming the
|
|
15
|
+
* connection. Two operations that would still share a name are a
|
|
16
|
+
* `CONNECTION_TOOL_COLLISION`. Every call passes the same gates as a step.
|
|
17
|
+
*
|
|
18
|
+
* `connectionTools(handle, { ops })` builds tools for one handle, for a
|
|
19
|
+
* `callModel` step that narrows what it offers.
|
|
20
|
+
*/
|
|
21
|
+
import type { ConnectionHandle, Tool } from '@noetic-tools/types';
|
|
22
|
+
import type { ConnectionRuntime } from './registry.js';
|
|
23
|
+
/** `connectionTools()` options. */
|
|
24
|
+
export interface ConnectionToolsOptions {
|
|
25
|
+
/** Operation globs to offer; default every operation. */
|
|
26
|
+
readonly ops?: ReadonlyArray<string>;
|
|
27
|
+
}
|
|
28
|
+
/** `<connection>_<op>` with dots and other characters a tool name cannot carry as `_`. */
|
|
29
|
+
export declare function connectionToolName(connection: string, op: string): string;
|
|
30
|
+
/** The registry a harness exposes, if it has one. */
|
|
31
|
+
export declare function runtimeOf(harness: unknown): ConnectionRuntime | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* The model tools for every ready connection in `runtime`, built fresh each
|
|
34
|
+
* turn so a renegotiated connection's tools change at the next turn, never
|
|
35
|
+
* mid-turn.
|
|
36
|
+
*
|
|
37
|
+
* @throws NoeticConfigError `CONNECTION_TOOL_COLLISION` when two operations would share a tool name.
|
|
38
|
+
*/
|
|
39
|
+
export declare function buildConnectionTools(runtime: ConnectionRuntime): Tool[];
|
|
40
|
+
/**
|
|
41
|
+
* @public
|
|
42
|
+
* Tools for one connection handle, for a `callModel` step that narrows what it
|
|
43
|
+
* offers: one tool per profile operation matching `ops`, or — for a handle with
|
|
44
|
+
* no profile — one `<name>_call` tool limited to `ops`.
|
|
45
|
+
*/
|
|
46
|
+
export declare function connectionTools(handle: ConnectionHandle, options?: ConnectionToolsOptions): Tool[];
|