@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
|
@@ -83,7 +83,12 @@ export function extractSystemInstruction(items) {
|
|
|
83
83
|
remaining,
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
|
+
/** Framework-owned extension items (`noetic:*`, e.g. a trigger's `noetic:connection_event`) are never sent to a provider. */
|
|
87
|
+
const FRAMEWORK_ITEM_PREFIX = 'noetic:';
|
|
86
88
|
function itemToInputItem(item) {
|
|
89
|
+
if (typeof item.type === 'string' && item.type.startsWith(FRAMEWORK_ITEM_PREFIX)) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
87
92
|
if (item.type === 'message' && 'content' in item && 'role' in item) {
|
|
88
93
|
// All message types (input and output) are converted to EasyInputMessage
|
|
89
94
|
// because the SDK's input union does not accept ResponsesOutputMessage directly.
|
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
import type { ContextData } from '@noetic-tools/context';
|
|
2
|
-
import type { StepConditional, StepInParallelAll, StepInParallelRace, StepInParallelSettle } from '@noetic-tools/types';
|
|
2
|
+
import type { Context, ExecuteStepFn, StepConditional, StepInParallelAll, StepInParallelRace, StepInParallelSettle, Steps } from '@noetic-tools/types';
|
|
3
3
|
/**
|
|
4
4
|
* Options for `inParallel()`, one shape per mode. `merge` is required for `all`
|
|
5
5
|
* and `settle` and absent for `race`.
|
|
6
6
|
* @public
|
|
7
7
|
*/
|
|
8
8
|
export type InParallelOpts<TContext = ContextData, I = unknown, O = unknown> = InParallelRaceOpts<TContext, I, O> | InParallelAllOpts<TContext, I, O> | InParallelSettleOpts<TContext, I, O>;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
/** Each parallel path is a step, or an array of steps run in sequence. */
|
|
10
|
+
interface PathsOpt<TContext, I, O> {
|
|
11
|
+
paths: (input: I, ctx: Context<TContext>) => Array<Steps<TContext, I, O>>;
|
|
12
|
+
}
|
|
13
|
+
type InParallelRaceOpts<TContext, I, O> = Omit<StepInParallelRace<TContext, I, O>, 'kind' | 'paths'> & PathsOpt<TContext, I, O>;
|
|
14
|
+
type InParallelAllOpts<TContext, I, O> = Omit<StepInParallelAll<TContext, I, O>, 'kind' | 'paths'> & PathsOpt<TContext, I, O>;
|
|
15
|
+
type InParallelSettleOpts<TContext, I, O> = Omit<StepInParallelSettle<TContext, I, O>, 'kind' | 'paths'> & PathsOpt<TContext, I, O>;
|
|
16
|
+
/**
|
|
17
|
+
* @public Options for `conditional()`. `route` may pick a step or an array of
|
|
18
|
+
* steps run in sequence.
|
|
19
|
+
*/
|
|
20
|
+
export type ConditionalOpts<TContext = ContextData, I = unknown, O = unknown> = Omit<StepConditional<TContext, I, O>, 'kind' | 'route'> & {
|
|
21
|
+
route: (input: I, ctx: Context<TContext>, run: ExecuteStepFn) => Steps<TContext, I, O> | null | Promise<Steps<TContext, I, O> | null>;
|
|
22
|
+
};
|
|
14
23
|
/**
|
|
15
24
|
* Creates a parallel execution step that races paths and returns the first result.
|
|
16
25
|
*
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { frameworkCast, NoeticConfigError } from '@noetic-tools/types';
|
|
2
2
|
import { getDefaultRegistrar } from '../types/step-registrar.js';
|
|
3
|
+
import { toStep } from './sequence.js';
|
|
3
4
|
export function inParallel(opts) {
|
|
4
5
|
if (!opts.id || opts.id.trim() === '') {
|
|
5
6
|
throw new NoeticConfigError({
|
|
@@ -15,9 +16,11 @@ export function inParallel(opts) {
|
|
|
15
16
|
hint: 'Provide a merge function that combines path results into a single output.',
|
|
16
17
|
});
|
|
17
18
|
}
|
|
19
|
+
const paths = opts.paths;
|
|
18
20
|
const built = frameworkCast({
|
|
19
21
|
kind: 'inParallel',
|
|
20
22
|
...opts,
|
|
23
|
+
paths: (input, ctx) => paths(input, ctx).map((path) => toStep(path)),
|
|
21
24
|
});
|
|
22
25
|
getDefaultRegistrar().register(built);
|
|
23
26
|
return built;
|
|
@@ -49,9 +52,14 @@ export function conditional(opts) {
|
|
|
49
52
|
hint: 'Provide a route function that selects the next step at runtime.',
|
|
50
53
|
});
|
|
51
54
|
}
|
|
55
|
+
const route = opts.route;
|
|
52
56
|
const built = {
|
|
53
57
|
kind: 'conditional',
|
|
54
58
|
...opts,
|
|
59
|
+
route: async (input, ctx, run) => {
|
|
60
|
+
const picked = await route(input, ctx, run);
|
|
61
|
+
return picked === null ? null : toStep(picked);
|
|
62
|
+
},
|
|
55
63
|
};
|
|
56
64
|
getDefaultRegistrar().register(built);
|
|
57
65
|
return built;
|
|
@@ -24,10 +24,8 @@ export interface StepDecideOpts<TContext, Q extends DecideQuestions, I = unknown
|
|
|
24
24
|
type NonEmpty<Q> = keyof Q extends never ? {
|
|
25
25
|
'decide needs at least one question': never;
|
|
26
26
|
} : unknown;
|
|
27
|
-
|
|
28
|
-
export type StepInput
|
|
29
|
-
/** @public The output a step produces. */
|
|
30
|
-
export type StepOutput<S> = S extends Step<infer _C, infer _I, infer O> ? O : never;
|
|
27
|
+
import type { StepInput, StepOutput } from '@noetic-tools/types';
|
|
28
|
+
export type { StepInput, StepOutput };
|
|
31
29
|
/** A step of any kind, as far as a case needs to be one. */
|
|
32
30
|
type CaseStep = Pick<Step, 'kind' | 'id'>;
|
|
33
31
|
/** Maps every key the switch does not route to onto `never`, so a misspelled case is a type error. */
|
|
@@ -83,4 +81,3 @@ export declare function decide<const Q extends DecideQuestions, TContext = Conte
|
|
|
83
81
|
*/
|
|
84
82
|
export declare function routeSwitch<TContext, const Q extends DecideQuestions, const C extends string, const Cases extends Partial<Record<C, CaseStep>>, D extends CaseStep, U extends CaseStep = D>(opts: RouteSwitchByFunctionOpts<TContext, Q, C, Cases, D, U>): StepConditional<TContext, StepInput<Cases[keyof Cases] | D | U>, StepOutput<Cases[keyof Cases] | D | U>>;
|
|
85
83
|
export declare function routeSwitch<TContext, const Q extends DecideQuestions, const K extends keyof Q & string, const Cases extends Record<CaseKeyOf<Q[K]>, CaseStep>, U extends CaseStep>(opts: RouteSwitchByKeyOpts<TContext, Q, K, Cases, U>): StepConditional<TContext, StepInput<Cases[keyof Cases] | U>, StepOutput<Cases[keyof Cases] | U>>;
|
|
86
|
-
export {};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* then hydrates and runs it within the same harness session.
|
|
4
4
|
*/
|
|
5
5
|
import type { ContextData, ContextLayer } from '@noetic-tools/context';
|
|
6
|
-
import type { AgentHarnessContract, Context, Step, Tool } from '@noetic-tools/types';
|
|
6
|
+
import type { AcpAgent, AcpAllowlist, AgentHarnessContract, ConnectionAllowlist, Context, McpAllowlist, Step, Tool } from '@noetic-tools/types';
|
|
7
7
|
import type { ExpressionLimits } from '../expression/jsonata.js';
|
|
8
8
|
import type { WorkflowDocument } from '../schemas/workflow.js';
|
|
9
9
|
/** @public Options for creating a dynamic workflow step. */
|
|
@@ -15,6 +15,28 @@ export interface DynamicWorkflowOpts {
|
|
|
15
15
|
maxRevisions?: number;
|
|
16
16
|
/** Bounds on each expression evaluation; unset fields use `DEFAULT_EXPRESSION_LIMITS`. */
|
|
17
17
|
expressionLimits?: ExpressionLimits;
|
|
18
|
+
/**
|
|
19
|
+
* What a generated document may use of the harness's connections (spec 35 §
|
|
20
|
+
* What a document may use). Required for the planner to use connections at
|
|
21
|
+
* all: a document asking for a connection without it fails validation with
|
|
22
|
+
* `CONNECTION_NOT_ALLOWED`. The planner is shown only these connections.
|
|
23
|
+
*/
|
|
24
|
+
connections?: ConnectionAllowlist;
|
|
25
|
+
/** ACP agent adapters, keyed by `agentId`, that the document's `acp-agent` nodes may run. Default: none. */
|
|
26
|
+
acpAgents?: ReadonlyMap<string, AcpAgent>;
|
|
27
|
+
/**
|
|
28
|
+
* The most a generated `acp-agent` node may ask of each agent: permissions,
|
|
29
|
+
* `cwd`, client capabilities and sessions (spec 26 § ACP agents). An agent
|
|
30
|
+
* without an entry gets the narrowest defaults; a node asking for more fails
|
|
31
|
+
* validation with `CONNECTION_NOT_ALLOWED`. The planner is shown these limits.
|
|
32
|
+
*/
|
|
33
|
+
acp?: AcpAllowlist;
|
|
34
|
+
/**
|
|
35
|
+
* The MCP servers a generated `acp-agent` node may hand its agent (spec 26 §
|
|
36
|
+
* MCP servers). Without it, a node naming any server fails validation with
|
|
37
|
+
* `CONNECTION_NOT_ALLOWED`. The planner is shown only these servers.
|
|
38
|
+
*/
|
|
39
|
+
mcp?: McpAllowlist;
|
|
18
40
|
}
|
|
19
41
|
/**
|
|
20
42
|
* Creates a step that uses an LLM to generate a workflow as JSON, then
|
|
@@ -31,6 +53,7 @@ export interface DynamicWorkflowOpts {
|
|
|
31
53
|
* @returns A `Step` that dynamically plans and executes.
|
|
32
54
|
* @throws `NoeticConfigError` with code `INVALID_EXPRESSION_LIMITS` (at execution) if `expressionLimits` holds a value that is not a positive integer or `Infinity`.
|
|
33
55
|
* @throws `NoeticConfigError` with code `EXPRESSION_LIMIT_EXCEEDED` (at execution) if an expression in the generated workflow exceeds its limits.
|
|
56
|
+
* @throws `NoeticConfigError` with code `CONNECTION_NOT_ALLOWED` (at execution) if, on the last revision, the document asks for more than `connections`, `acp` or `mcp` grants.
|
|
34
57
|
*/
|
|
35
58
|
export declare function dynamicWorkflow(opts: DynamicWorkflowOpts): Step<ContextData, string, string>;
|
|
36
59
|
/** @public Options for `parseAndRunWorkflow`. */
|
|
@@ -47,7 +70,12 @@ export interface ParseAndRunWorkflowOpts {
|
|
|
47
70
|
* host that runs layer-bearing workflows must pass its layers here.
|
|
48
71
|
*/
|
|
49
72
|
layers?: ReadonlyMap<string, ContextLayer>;
|
|
50
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* Named sub-workflows the document's `subflow` nodes may reference via `ref`.
|
|
75
|
+
* A named workflow runs as the host wrote it, not held to `connections`,
|
|
76
|
+
* `acp` or `mcp`: register only workflows you would let any document run
|
|
77
|
+
* with their own settings.
|
|
78
|
+
*/
|
|
51
79
|
workflows?: ReadonlyMap<string, WorkflowDocument>;
|
|
52
80
|
/**
|
|
53
81
|
* Deepest allowed chain of named-ref resolutions on one execution path —
|
|
@@ -57,6 +85,27 @@ export interface ParseAndRunWorkflowOpts {
|
|
|
57
85
|
maxRecursionDepth?: number;
|
|
58
86
|
/** Bounds on each expression evaluation; unset fields use `DEFAULT_EXPRESSION_LIMITS`. */
|
|
59
87
|
expressionLimits?: ExpressionLimits;
|
|
88
|
+
/**
|
|
89
|
+
* What the document may use of the harness's connections (spec 35 § What a
|
|
90
|
+
* document may use). When given, a manifest asking for more fails with
|
|
91
|
+
* `CONNECTION_NOT_ALLOWED`.
|
|
92
|
+
*/
|
|
93
|
+
connections?: ConnectionAllowlist;
|
|
94
|
+
/** ACP agent adapters, keyed by `agentId`, that the document's `acp-agent` nodes may run. Default: none. */
|
|
95
|
+
acpAgents?: ReadonlyMap<string, AcpAgent>;
|
|
96
|
+
/**
|
|
97
|
+
* The most the document's `acp-agent` nodes may ask of each agent:
|
|
98
|
+
* permissions, `cwd`, client capabilities and sessions (spec 26 § ACP
|
|
99
|
+
* agents). An agent without an entry gets the narrowest defaults; a node
|
|
100
|
+
* asking for more fails validation with `CONNECTION_NOT_ALLOWED`.
|
|
101
|
+
*/
|
|
102
|
+
acp?: AcpAllowlist;
|
|
103
|
+
/**
|
|
104
|
+
* The MCP servers the document's `acp-agent` nodes may hand their agent
|
|
105
|
+
* (spec 26 § MCP servers). Unlike `connections`, absence grants nothing: a
|
|
106
|
+
* node naming any server fails validation with `CONNECTION_NOT_ALLOWED`.
|
|
107
|
+
*/
|
|
108
|
+
mcp?: McpAllowlist;
|
|
60
109
|
}
|
|
61
110
|
/**
|
|
62
111
|
* Parses raw JSON into a `WorkflowDocument`, hydrates it into a live step
|
|
@@ -76,5 +125,8 @@ export interface ParseAndRunWorkflowOpts {
|
|
|
76
125
|
* @throws `NoeticConfigError` with code `UNKNOWN_TOOL_REFERENCE` if a tool reference cannot be resolved.
|
|
77
126
|
* @throws `NoeticConfigError` with code `INVALID_EXPRESSION_LIMITS` if `expressionLimits` holds a value that is not a positive integer or `Infinity`.
|
|
78
127
|
* @throws `NoeticConfigError` with code `EXPRESSION_LIMIT_EXCEEDED` if an expression exceeds its limits.
|
|
128
|
+
* @throws `NoeticConfigError` with code `CONNECTION_UNKNOWN` if a node uses a connection the document does not declare, or the allowlist names one the harness does not have.
|
|
129
|
+
* @throws `NoeticConfigError` with code `CONNECTION_NOT_ALLOWED` if the document asks for more than `connections` grants, or an `acp-agent` node asks for more than `acp` or `mcp` grants.
|
|
130
|
+
* @throws `NoeticConfigError` with code `CONNECTION_INVALID` if an MCP server uses a `$secret` and the harness has no `environment.secrets`.
|
|
79
131
|
*/
|
|
80
132
|
export declare function parseAndRunWorkflow(opts: ParseAndRunWorkflowOpts): Promise<string>;
|
|
@@ -3,12 +3,17 @@
|
|
|
3
3
|
* then hydrates and runs it within the same harness session.
|
|
4
4
|
*/
|
|
5
5
|
import { exportSpans } from '@noetic-tools/context';
|
|
6
|
-
import { frameworkCast, NoeticConfigError } from '@noetic-tools/types';
|
|
6
|
+
import { frameworkCast, isNoeticConfigError, NoeticConfigError } from '@noetic-tools/types';
|
|
7
7
|
import { expressionErrors } from '../expression/check.js';
|
|
8
8
|
import { NoeticAttr } from '../observability/genai-attributes.js';
|
|
9
9
|
import { WorkflowDocumentSchema, workflowDepth, workflowGraph } from '../schemas/workflow.js';
|
|
10
|
+
import { harnessInternal } from '../util/harness-internals.js';
|
|
11
|
+
import { outputText } from './output-text.js';
|
|
10
12
|
import { callModel, runCode } from './step-builders.js';
|
|
13
|
+
import { acpBounds, acpPrompt, checkAcpAgents } from './workflow-acp-grants.js';
|
|
14
|
+
import { checkConnectionAllowlist, checkDocumentConnections, globMatches, } from './workflow-connections.js';
|
|
11
15
|
import { hydrateWorkflow } from './workflow-hydrator.js';
|
|
16
|
+
import { checkMcpServers, mcpPrompt } from './workflow-mcp-servers.js';
|
|
12
17
|
//#endregion
|
|
13
18
|
//#region Constants
|
|
14
19
|
const DEFAULT_MAX_DEPTH = 5;
|
|
@@ -36,7 +41,7 @@ A WorkflowNode is one of:
|
|
|
36
41
|
- { "kind": "schedule", "id": "<unique>", "step": <WorkflowNode>, "interval": <ms>, "onError": "continue"|"fail" } (re-runs the step forever on an interval and never returns — only emit for an explicitly daemon-style task)
|
|
37
42
|
- { "kind": "routeSwitch", "id": "<unique>", "decide": { "kind": "decide", "id": "<unique>", "questions": { "<question-id>": { "type": "choice", "instructions": "<question>", "choices": ["<option>", ...] } } }, "on": "<question-id>", "cases": { "<option>": <WorkflowNode>, ... }, "uncertain": <WorkflowNode>, "minConfidence": <optional 0-1> } (a model decides, then the input goes to the matching case; a "boolean" question has cases "true" and "false"; a "score" question has "levels": ["<low>", ..., "<high>"] and routes by level; every outcome needs a case)
|
|
38
43
|
- { "kind": "subflow", "id": "<unique>", "document": { "version": 1, "root": <WorkflowNode> } } (an inline sub-workflow run as one step; only emit the inline form — named refs require a registry this planner does not provide)
|
|
39
|
-
- { "kind": "acp-agent", "id": "<unique>", "agent": "<
|
|
44
|
+
- { "kind": "acp-agent", "id": "<unique>", "agent": "<an agent id listed below>", "prompt": "<turn prompt>", "mode": "<optional session mode>", "model": "<optional>", "mcpServers": [<optional; only servers listed below>], "cwd": "<optional absolute dir>", "permissions": { "default": "deny", "allow": [{ "kind": "<tool kind>", "title": "<substring>" }] }, "clientCapabilities": { "readTextFile": <bool>, "writeTextFile": <bool>, "terminal": <bool> }, "session": { "reuse": "<key>", "keepAlive": "step"|"run" } } (every field after "model" is optional and only within the agent's limits listed below)
|
|
40
45
|
|
|
41
46
|
Every entry of a callModel node's "tools" is an OBJECT, never a bare string. Use { "type": "<tool-name>" } to let the model call one of the tools listed below. Two provider-executed tools are also available without being listed: { "type": "openrouter:web_search" } and { "type": "openrouter:web_fetch" }, each accepting an optional "parameters" object.
|
|
42
47
|
|
|
@@ -66,6 +71,7 @@ Respond with ONLY the JSON document, no markdown fences or explanation.`;
|
|
|
66
71
|
* @returns A `Step` that dynamically plans and executes.
|
|
67
72
|
* @throws `NoeticConfigError` with code `INVALID_EXPRESSION_LIMITS` (at execution) if `expressionLimits` holds a value that is not a positive integer or `Infinity`.
|
|
68
73
|
* @throws `NoeticConfigError` with code `EXPRESSION_LIMIT_EXCEEDED` (at execution) if an expression in the generated workflow exceeds its limits.
|
|
74
|
+
* @throws `NoeticConfigError` with code `CONNECTION_NOT_ALLOWED` (at execution) if, on the last revision, the document asks for more than `connections`, `acp` or `mcp` grants.
|
|
69
75
|
*/
|
|
70
76
|
export function dynamicWorkflow(opts) {
|
|
71
77
|
const model = opts.model ?? DEFAULT_MODEL;
|
|
@@ -83,11 +89,18 @@ export function dynamicWorkflow(opts) {
|
|
|
83
89
|
hint: 'Execute this step via AgentHarness.run() or ensure ctx.harness is set.',
|
|
84
90
|
});
|
|
85
91
|
}
|
|
92
|
+
checkAllowlistNames(opts.connections, ctx);
|
|
93
|
+
// Read once: the planner is shown, the document checked against, and its
|
|
94
|
+
// acp-agent nodes run in this cwd, even if the harness's moves meanwhile.
|
|
95
|
+
const cwd = ctx.cwdState.cwd;
|
|
86
96
|
const toolList = opts.tools.map((t) => `- ${t.name}: ${t.description}`).join('\n');
|
|
87
97
|
const basePrompt = [
|
|
88
98
|
opts.instructions,
|
|
89
99
|
PLANNER_INSTRUCTIONS,
|
|
90
100
|
`\nAvailable tools:\n${toolList}`,
|
|
101
|
+
connectionsPrompt(opts.connections, plannerConnections(opts.connections, ctx)),
|
|
102
|
+
acpPrompt(opts.acpAgents, opts.acp, cwd),
|
|
103
|
+
mcpPrompt(opts.mcp),
|
|
91
104
|
`\nTask: ${input}`,
|
|
92
105
|
]
|
|
93
106
|
.filter(Boolean)
|
|
@@ -97,17 +110,30 @@ export function dynamicWorkflow(opts) {
|
|
|
97
110
|
const prompt = lastError
|
|
98
111
|
? `${basePrompt}\n\nPrevious attempt failed with error: ${lastError}\nPlease fix the workflow and try again.`
|
|
99
112
|
: basePrompt;
|
|
113
|
+
// The planner only writes the document: it never sees the harness's tools or
|
|
114
|
+
// connections, so it cannot drive a connection around the allowlist.
|
|
100
115
|
const plannerStep = callModel({
|
|
101
116
|
id: `dynamic-workflow-planner-${revision}`,
|
|
102
117
|
model,
|
|
103
118
|
instructions: prompt,
|
|
119
|
+
tools: [],
|
|
104
120
|
});
|
|
105
121
|
const executeStep = frameworkCast(harness.run.bind(harness));
|
|
106
122
|
const rawOutput = await executeStep(plannerStep, input, ctx);
|
|
107
123
|
const text = coerceToString(rawOutput);
|
|
108
|
-
const parseResult = tryParseWorkflow(text, maxDepth
|
|
124
|
+
const parseResult = tryParseWorkflow(text, maxDepth, {
|
|
125
|
+
allowlist: opts.connections ?? {},
|
|
126
|
+
ranges: profileVersions(ctx),
|
|
127
|
+
acp: opts.acp,
|
|
128
|
+
cwd,
|
|
129
|
+
mcp: opts.mcp,
|
|
130
|
+
secrets: harnessInternal(harness, 'secrets'),
|
|
131
|
+
});
|
|
109
132
|
if (!parseResult.ok) {
|
|
110
133
|
lastError = parseResult.error;
|
|
134
|
+
if (revision === maxRevisions - 1 && parseResult.configError) {
|
|
135
|
+
throw parseResult.configError;
|
|
136
|
+
}
|
|
111
137
|
if (revision === maxRevisions - 1) {
|
|
112
138
|
throw new NoeticConfigError({
|
|
113
139
|
code: 'WORKFLOW_VALIDATION_FAILED',
|
|
@@ -120,6 +146,8 @@ export function dynamicWorkflow(opts) {
|
|
|
120
146
|
const hydrationCtx = {
|
|
121
147
|
tools: toolMap,
|
|
122
148
|
executeStep,
|
|
149
|
+
acpAgents: opts.acpAgents,
|
|
150
|
+
acpBounds: acpBounds(opts.acp, cwd),
|
|
123
151
|
expressionLimits: opts.expressionLimits,
|
|
124
152
|
};
|
|
125
153
|
const hydrated = hydrateWorkflow(parseResult.doc, hydrationCtx);
|
|
@@ -151,9 +179,23 @@ export function dynamicWorkflow(opts) {
|
|
|
151
179
|
* @throws `NoeticConfigError` with code `UNKNOWN_TOOL_REFERENCE` if a tool reference cannot be resolved.
|
|
152
180
|
* @throws `NoeticConfigError` with code `INVALID_EXPRESSION_LIMITS` if `expressionLimits` holds a value that is not a positive integer or `Infinity`.
|
|
153
181
|
* @throws `NoeticConfigError` with code `EXPRESSION_LIMIT_EXCEEDED` if an expression exceeds its limits.
|
|
182
|
+
* @throws `NoeticConfigError` with code `CONNECTION_UNKNOWN` if a node uses a connection the document does not declare, or the allowlist names one the harness does not have.
|
|
183
|
+
* @throws `NoeticConfigError` with code `CONNECTION_NOT_ALLOWED` if the document asks for more than `connections` grants, or an `acp-agent` node asks for more than `acp` or `mcp` grants.
|
|
184
|
+
* @throws `NoeticConfigError` with code `CONNECTION_INVALID` if an MCP server uses a `$secret` and the harness has no `environment.secrets`.
|
|
154
185
|
*/
|
|
155
186
|
export async function parseAndRunWorkflow(opts) {
|
|
156
|
-
|
|
187
|
+
checkAllowlistNames(opts.connections, opts.ctx);
|
|
188
|
+
const cwd = opts.ctx.cwdState.cwd;
|
|
189
|
+
const parseResult = tryParseWorkflow(opts.json, opts.maxDepth ?? DEFAULT_MAX_DEPTH, {
|
|
190
|
+
allowlist: opts.connections,
|
|
191
|
+
acp: opts.acp,
|
|
192
|
+
cwd,
|
|
193
|
+
mcp: opts.mcp,
|
|
194
|
+
secrets: harnessInternal(opts.harness, 'secrets'),
|
|
195
|
+
});
|
|
196
|
+
if (!parseResult.ok && parseResult.configError) {
|
|
197
|
+
throw parseResult.configError;
|
|
198
|
+
}
|
|
157
199
|
if (!parseResult.ok) {
|
|
158
200
|
throw new NoeticConfigError({
|
|
159
201
|
code: 'WORKFLOW_VALIDATION_FAILED',
|
|
@@ -167,6 +209,8 @@ export async function parseAndRunWorkflow(opts) {
|
|
|
167
209
|
executeStep,
|
|
168
210
|
layers: opts.layers,
|
|
169
211
|
workflows: opts.workflows,
|
|
212
|
+
acpAgents: opts.acpAgents,
|
|
213
|
+
acpBounds: acpBounds(opts.acp, cwd),
|
|
170
214
|
maxRecursionDepth: opts.maxRecursionDepth,
|
|
171
215
|
expressionLimits: opts.expressionLimits,
|
|
172
216
|
};
|
|
@@ -217,25 +261,32 @@ function buildToolMap(tools) {
|
|
|
217
261
|
t,
|
|
218
262
|
]));
|
|
219
263
|
}
|
|
264
|
+
/** A workflow's output as text, written the way every node writes its output (objects as JSON). */
|
|
220
265
|
function coerceToString(value) {
|
|
221
|
-
|
|
222
|
-
return value;
|
|
223
|
-
}
|
|
224
|
-
return String(value ?? '');
|
|
266
|
+
return outputText(value);
|
|
225
267
|
}
|
|
226
|
-
function tryParseWorkflow(raw, maxDepth) {
|
|
227
|
-
const
|
|
228
|
-
if (
|
|
268
|
+
function tryParseWorkflow(raw, maxDepth, check) {
|
|
269
|
+
const json = typeof raw === 'string' ? safeParse(raw) : raw;
|
|
270
|
+
if (json === null) {
|
|
229
271
|
return {
|
|
230
272
|
ok: false,
|
|
231
273
|
error: 'Input is not valid JSON.',
|
|
232
274
|
};
|
|
233
275
|
}
|
|
276
|
+
const parsed = check.ranges ? withProfileRanges(json, check.ranges) : json;
|
|
234
277
|
const result = WorkflowDocumentSchema.safeParse(parsed);
|
|
235
278
|
if (!result.success) {
|
|
279
|
+
const manifestError = manifestErrorOf(result.error.issues);
|
|
236
280
|
return {
|
|
237
281
|
ok: false,
|
|
238
|
-
error:
|
|
282
|
+
error: manifestError
|
|
283
|
+
? `${manifestError.code}: ${manifestError.message} ${manifestError.hint}`
|
|
284
|
+
: result.error.message,
|
|
285
|
+
...(manifestError
|
|
286
|
+
? {
|
|
287
|
+
configError: manifestError,
|
|
288
|
+
}
|
|
289
|
+
: {}),
|
|
239
290
|
};
|
|
240
291
|
}
|
|
241
292
|
const depth = workflowDepth(result.data.root);
|
|
@@ -252,11 +303,195 @@ function tryParseWorkflow(raw, maxDepth) {
|
|
|
252
303
|
error: errors.join(' '),
|
|
253
304
|
};
|
|
254
305
|
}
|
|
306
|
+
const connectionError = connectionErrorOf(result.data, check);
|
|
307
|
+
if (connectionError) {
|
|
308
|
+
return {
|
|
309
|
+
ok: false,
|
|
310
|
+
error: `${connectionError.code}: ${connectionError.message} ${connectionError.hint}`,
|
|
311
|
+
configError: connectionError,
|
|
312
|
+
};
|
|
313
|
+
}
|
|
255
314
|
return {
|
|
256
315
|
ok: true,
|
|
257
316
|
doc: result.data,
|
|
258
317
|
};
|
|
259
318
|
}
|
|
319
|
+
/** The error a document has, checked against its manifest, (when given) the host connection allowlist, and what its `acp-agent` nodes may ask. */
|
|
320
|
+
function connectionErrorOf(doc, check) {
|
|
321
|
+
try {
|
|
322
|
+
if (check.allowlist === undefined) {
|
|
323
|
+
checkDocumentConnections(doc);
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
checkConnectionAllowlist(doc, check.allowlist);
|
|
327
|
+
}
|
|
328
|
+
checkAcpAgents(doc, check.acp, check.cwd);
|
|
329
|
+
checkMcpServers(doc, check.mcp, check.secrets);
|
|
330
|
+
return undefined;
|
|
331
|
+
}
|
|
332
|
+
catch (error) {
|
|
333
|
+
if (isNoeticConfigError(error)) {
|
|
334
|
+
return error;
|
|
335
|
+
}
|
|
336
|
+
throw error;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Checks an allowlist names only connections the harness has, when the harness
|
|
341
|
+
* has a connection registry to ask.
|
|
342
|
+
*
|
|
343
|
+
* @throws `NoeticConfigError` `CONNECTION_UNKNOWN` for a name the harness does not have.
|
|
344
|
+
*/
|
|
345
|
+
function checkAllowlistNames(allowlist, ctx) {
|
|
346
|
+
// Structural: builders sit below the connection registry and must not import it.
|
|
347
|
+
const registry = harnessInternal(ctx.harness, 'connectionRegistry');
|
|
348
|
+
if (!allowlist || !registry) {
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
const known = new Set(registry.names());
|
|
352
|
+
for (const name of Object.keys(allowlist)) {
|
|
353
|
+
if (known.has(name)) {
|
|
354
|
+
continue;
|
|
355
|
+
}
|
|
356
|
+
throw new NoeticConfigError({
|
|
357
|
+
code: 'CONNECTION_UNKNOWN',
|
|
358
|
+
message: `The connection allowlist names '${name}', which the harness does not have.`,
|
|
359
|
+
hint: `Harness connections: ${[
|
|
360
|
+
...known,
|
|
361
|
+
].join(', ') || '(none)'}.`,
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* A malformed manifest entry (spec 35 § Errors) is `CONNECTION_INVALID`, not a
|
|
367
|
+
* generic validation failure: the issues under the root `connections` map.
|
|
368
|
+
*/
|
|
369
|
+
function manifestErrorOf(issues) {
|
|
370
|
+
const manifest = issues.filter((issue) => issue.path[0] === 'connections');
|
|
371
|
+
if (manifest.length === 0) {
|
|
372
|
+
return undefined;
|
|
373
|
+
}
|
|
374
|
+
const detail = manifest
|
|
375
|
+
.map((issue) => `${issue.path.map(String).join('.')}: ${issue.message}`)
|
|
376
|
+
.join('; ');
|
|
377
|
+
return new NoeticConfigError({
|
|
378
|
+
code: 'CONNECTION_INVALID',
|
|
379
|
+
message: `The document's connections map is malformed: ${detail}`,
|
|
380
|
+
hint: 'Each entry is { "profile": "<profile>@<range>", "extensions"?, "from"?, "fresh"?, "setup"? } or { "events": [...] }.',
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
function registryOf(ctx) {
|
|
384
|
+
return harnessInternal(ctx.harness, 'connectionRegistry');
|
|
385
|
+
}
|
|
386
|
+
/** The profile versions each harness connection serves right now. */
|
|
387
|
+
function profileVersions(ctx) {
|
|
388
|
+
const registry = registryOf(ctx);
|
|
389
|
+
const versions = new Map();
|
|
390
|
+
for (const name of registry?.names() ?? []) {
|
|
391
|
+
const profiles = registry?.current?.(name)?.manifest.profiles;
|
|
392
|
+
if (profiles) {
|
|
393
|
+
versions.set(name, profiles);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
return versions;
|
|
397
|
+
}
|
|
398
|
+
/** `^<major>` of `version`, or undefined when it is not a version. */
|
|
399
|
+
function caretRange(version) {
|
|
400
|
+
const major = version?.split('.')[0];
|
|
401
|
+
return major && /^\d+$/.test(major) ? `^${major}` : undefined;
|
|
402
|
+
}
|
|
403
|
+
/** `json` with each manifest entry's bare `"profile": "<name>"` given the range its connection serves. */
|
|
404
|
+
function withProfileRanges(json, ranges) {
|
|
405
|
+
if (!isRecord(json) || !isRecord(json.connections)) {
|
|
406
|
+
return json;
|
|
407
|
+
}
|
|
408
|
+
const connections = {};
|
|
409
|
+
for (const [name, entry] of Object.entries(json.connections)) {
|
|
410
|
+
connections[name] = withProfileRange(name, entry, ranges);
|
|
411
|
+
}
|
|
412
|
+
return {
|
|
413
|
+
...json,
|
|
414
|
+
connections,
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
function withProfileRange(name, entry, ranges) {
|
|
418
|
+
if (!isRecord(entry) || typeof entry.profile !== 'string' || entry.profile.includes('@')) {
|
|
419
|
+
return entry;
|
|
420
|
+
}
|
|
421
|
+
const target = typeof entry.from === 'string' ? entry.from : name;
|
|
422
|
+
const range = caretRange(ranges.get(target)?.[entry.profile]);
|
|
423
|
+
return range
|
|
424
|
+
? {
|
|
425
|
+
...entry,
|
|
426
|
+
profile: `${entry.profile}@${range}`,
|
|
427
|
+
}
|
|
428
|
+
: entry;
|
|
429
|
+
}
|
|
430
|
+
function isRecord(value) {
|
|
431
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
432
|
+
}
|
|
433
|
+
/** What the planner may see of each allowed connection: its profiles and allowed operations with their schemas. */
|
|
434
|
+
function plannerConnections(allowlist, ctx) {
|
|
435
|
+
const registry = registryOf(ctx);
|
|
436
|
+
const out = new Map();
|
|
437
|
+
for (const [name, entry] of Object.entries(allowlist ?? {})) {
|
|
438
|
+
const manifest = registry?.current?.(name)?.manifest;
|
|
439
|
+
if (!manifest) {
|
|
440
|
+
continue;
|
|
441
|
+
}
|
|
442
|
+
const operations = Object.entries(manifest.operations)
|
|
443
|
+
.filter(([op]) => (entry.ops ?? []).some((pattern) => globMatches(pattern, op)))
|
|
444
|
+
.map(([op, info]) => ({
|
|
445
|
+
name: op,
|
|
446
|
+
inputSchema: info.inputSchema,
|
|
447
|
+
}));
|
|
448
|
+
out.set(name, {
|
|
449
|
+
profiles: manifest.profiles,
|
|
450
|
+
operations,
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
return out;
|
|
454
|
+
}
|
|
455
|
+
function connectionLine(name, entry, known) {
|
|
456
|
+
const profiles = Object.keys(known?.profiles ?? {});
|
|
457
|
+
const parts = [
|
|
458
|
+
...(profiles.length > 0
|
|
459
|
+
? [
|
|
460
|
+
`profiles: ${profiles.join(', ')}`,
|
|
461
|
+
]
|
|
462
|
+
: []),
|
|
463
|
+
`ops: ${(entry.ops ?? []).join(', ') || '(none)'}`,
|
|
464
|
+
`events: ${(entry.events ?? []).join(', ') || '(none)'}`,
|
|
465
|
+
];
|
|
466
|
+
if (entry.setup) {
|
|
467
|
+
parts.push(`setup fields: ${Object.keys(entry.setup).join(', ')}`);
|
|
468
|
+
}
|
|
469
|
+
if (entry.secrets) {
|
|
470
|
+
parts.push(`secrets: ${Object.entries(entry.secrets)
|
|
471
|
+
.map(([secret, field]) => `${secret} (only in ${field})`)
|
|
472
|
+
.join(', ')}`);
|
|
473
|
+
}
|
|
474
|
+
const schemas = (known?.operations ?? []).map((op) => ` - ${op.name} args: ${JSON.stringify(op.inputSchema)}`);
|
|
475
|
+
return [
|
|
476
|
+
`- ${name}: ${parts.join('; ')}`,
|
|
477
|
+
...schemas,
|
|
478
|
+
].join('\n');
|
|
479
|
+
}
|
|
480
|
+
/** The planner's view of the connections it may use: only the allowed ones, with their operations and argument schemas. */
|
|
481
|
+
function connectionsPrompt(allowlist, known) {
|
|
482
|
+
const entries = Object.entries(allowlist ?? {});
|
|
483
|
+
if (entries.length === 0) {
|
|
484
|
+
return '\nNo connections are available: do not emit call, wait or verify nodes or a "connections" map.';
|
|
485
|
+
}
|
|
486
|
+
const lines = entries.map(([name, entry]) => connectionLine(name, entry, known.get(name)));
|
|
487
|
+
return `\nConnections you may use (a document lists the ones it needs in a root "connections" map, e.g. "connections": { "app": { "profile": "<profile>", "from": "<connection>" } } — the version range is filled in for you — or { "events": [...] } for an event source):
|
|
488
|
+
${lines.join('\n')}
|
|
489
|
+
Connection nodes:
|
|
490
|
+
- { "kind": "call", "id": "<unique>", "connection": "<name>", "op": "<operation>", "args": { ... } } (run one operation; values may be { "$expr": "<JSONata on the input; $steps.<id> reads an earlier node's output>" }, { "$literal": ... }, or { "$secret": "<name>" })
|
|
491
|
+
- { "kind": "wait", "id": "<unique>", "connection": "<name>", "event": "<event>", "filter": "<JSONata test on { event, input }>", "around": [<steps>], "timeoutMs": <ms> } (listen, run around, then wait for the event)
|
|
492
|
+
- { "kind": "verify", "id": "<unique>", "subject": "<name>", "expect": [{ "<sense>": "<pattern>" }, ...], "never": [<matchers>], "act": [<steps>], "witnesses": ["<name>"], "close": { "until": "quiet"|"event"|"done"|"exit" } } (run act on the subject and check what was expected happened; act names operations by name)
|
|
493
|
+
Inside "around", "act" or a sequence's "steps", { "<operation>": { ...args } } is a call on the enclosing connection.`;
|
|
494
|
+
}
|
|
260
495
|
function safeParse(text) {
|
|
261
496
|
try {
|
|
262
497
|
return JSON.parse(text);
|
package/dist/builders/every.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ContextData } from '@noetic-tools/context';
|
|
2
|
-
import type { Channel, ScheduleErrorPolicy,
|
|
2
|
+
import type { Channel, ScheduleErrorPolicy, StepReplay, StepSchedule, Steps } from '@noetic-tools/types';
|
|
3
3
|
/**
|
|
4
4
|
* Configuration options accepted by the `schedule()` builder, excluding the `kind`
|
|
5
5
|
* discriminant. `schedule()` schedules a body step on a fixed-interval, optionally
|
|
@@ -10,8 +10,8 @@ import type { Channel, ScheduleErrorPolicy, Step, StepReplay, StepSchedule } fro
|
|
|
10
10
|
export interface ScheduleOptions<TContext = ContextData, I = unknown, O = unknown> extends StepReplay<TContext, I> {
|
|
11
11
|
/** Unique step identifier used in traces and error messages. */
|
|
12
12
|
id: string;
|
|
13
|
-
/** Body
|
|
14
|
-
step:
|
|
13
|
+
/** Body executed on each iteration: a step, or an array of steps run in sequence. */
|
|
14
|
+
step: Steps<TContext, I, O>;
|
|
15
15
|
/** Park duration between iterations in milliseconds. Must be >= 0. */
|
|
16
16
|
interval: number;
|
|
17
17
|
/** Optional channel that wakes the parking interval when any value arrives. */
|
package/dist/builders/every.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NoeticConfigError } from '@noetic-tools/types';
|
|
2
2
|
import { getDefaultRegistrar } from '../types/step-registrar.js';
|
|
3
|
+
import { toStep } from './sequence.js';
|
|
3
4
|
/**
|
|
4
5
|
* Creates a `schedule` step that runs a body step on a fixed-interval schedule.
|
|
5
6
|
*
|
|
@@ -52,7 +53,7 @@ export function schedule(opts) {
|
|
|
52
53
|
const built = {
|
|
53
54
|
kind: 'schedule',
|
|
54
55
|
id: opts.id,
|
|
55
|
-
step: opts.step,
|
|
56
|
+
step: toStep(opts.step),
|
|
56
57
|
interval: opts.interval,
|
|
57
58
|
inbox: opts.inbox,
|
|
58
59
|
onError: opts.onError ?? 'continue',
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The URL patterns of a host's `mcp` allowlist (spec 26 § MCP servers). A
|
|
3
|
+
* pattern is matched part by part — scheme, host, port, then path — so a `*`
|
|
4
|
+
* can never stand for a `/`, `?`, `#` or `@` that moves the URL to another
|
|
5
|
+
* host: `https://*.example.com/*` does not match
|
|
6
|
+
* `https://evil.com/.example.com/`.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Whether `url` matches the host's pattern.
|
|
10
|
+
*
|
|
11
|
+
* @throws `NoeticConfigError` `CONNECTION_INVALID` when the pattern is not `<scheme>://<host>[:<port>]<path>` with `*` only as a leading host label, the port, or in the path, or when a leading `*.` is followed by fewer than two labels (`*.com`).
|
|
12
|
+
*/
|
|
13
|
+
export declare function urlPatternMatches(pattern: string, url: URL): boolean;
|