@noetic-tools/core 5.19.1 → 5.19.2

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 (146) hide show
  1. package/dist/adapters/openrouter.js +5 -0
  2. package/dist/builders/control-flow-builders.d.ts +15 -6
  3. package/dist/builders/control-flow-builders.js +8 -0
  4. package/dist/builders/decide-builders.d.ts +2 -5
  5. package/dist/builders/dynamic-workflow.d.ts +16 -1
  6. package/dist/builders/dynamic-workflow.js +222 -11
  7. package/dist/builders/every.d.ts +3 -3
  8. package/dist/builders/every.js +2 -1
  9. package/dist/builders/provide-builder.d.ts +3 -2
  10. package/dist/builders/provide-builder.js +2 -1
  11. package/dist/builders/sequence.d.ts +14 -0
  12. package/dist/builders/sequence.js +103 -0
  13. package/dist/builders/spawn-builder.d.ts +3 -2
  14. package/dist/builders/spawn-builder.js +3 -2
  15. package/dist/builders/step-builders.d.ts +80 -1
  16. package/dist/builders/step-builders.js +115 -1
  17. package/dist/builders/verify-builder.d.ts +79 -0
  18. package/dist/builders/verify-builder.js +69 -0
  19. package/dist/builders/workflow-child-nodes.d.ts +21 -0
  20. package/dist/builders/workflow-child-nodes.js +335 -0
  21. package/dist/builders/workflow-connection-nodes.d.ts +17 -0
  22. package/dist/builders/workflow-connection-nodes.js +160 -0
  23. package/dist/builders/workflow-connections.d.ts +90 -0
  24. package/dist/builders/workflow-connections.js +560 -0
  25. package/dist/builders/workflow-control-nodes.d.ts +13 -0
  26. package/dist/builders/workflow-control-nodes.js +213 -0
  27. package/dist/builders/workflow-hydrator.d.ts +44 -3
  28. package/dist/builders/workflow-hydrator.js +53 -495
  29. package/dist/builders/workflow-verify.d.ts +19 -0
  30. package/dist/builders/workflow-verify.js +194 -0
  31. package/dist/conditions/conditions.d.ts +7 -5
  32. package/dist/conditions/conditions.js +7 -4
  33. package/dist/connections/blobs.d.ts +33 -0
  34. package/dist/connections/blobs.js +77 -0
  35. package/dist/connections/cron-schedule.d.ts +32 -0
  36. package/dist/connections/cron-schedule.js +213 -0
  37. package/dist/connections/durability.d.ts +65 -0
  38. package/dist/connections/durability.js +54 -0
  39. package/dist/connections/errors.d.ts +30 -0
  40. package/dist/connections/errors.js +100 -0
  41. package/dist/connections/event-stream.d.ts +24 -0
  42. package/dist/connections/event-stream.js +176 -0
  43. package/dist/connections/gates.d.ts +94 -0
  44. package/dist/connections/gates.js +271 -0
  45. package/dist/connections/glob.d.ts +10 -0
  46. package/dist/connections/glob.js +46 -0
  47. package/dist/connections/handle.d.ts +22 -0
  48. package/dist/connections/handle.js +84 -0
  49. package/dist/connections/harness-wiring.d.ts +52 -0
  50. package/dist/connections/harness-wiring.js +143 -0
  51. package/dist/connections/in-memory-connection.d.ts +147 -0
  52. package/dist/connections/in-memory-connection.js +593 -0
  53. package/dist/connections/index.d.ts +34 -0
  54. package/dist/connections/index.js +23 -0
  55. package/dist/connections/json-schema.d.ts +28 -0
  56. package/dist/connections/json-schema.js +338 -0
  57. package/dist/connections/model-tools.d.ts +46 -0
  58. package/dist/connections/model-tools.js +466 -0
  59. package/dist/connections/negotiation.d.ts +30 -0
  60. package/dist/connections/negotiation.js +159 -0
  61. package/dist/connections/policy.d.ts +21 -0
  62. package/dist/connections/policy.js +34 -0
  63. package/dist/connections/pool.d.ts +111 -0
  64. package/dist/connections/pool.js +339 -0
  65. package/dist/connections/refs.d.ts +74 -0
  66. package/dist/connections/refs.js +316 -0
  67. package/dist/connections/registry-types.d.ts +141 -0
  68. package/dist/connections/registry-types.js +14 -0
  69. package/dist/connections/registry.d.ts +125 -0
  70. package/dist/connections/registry.js +775 -0
  71. package/dist/connections/secrets.d.ts +59 -0
  72. package/dist/connections/secrets.js +153 -0
  73. package/dist/connections/settle.d.ts +9 -0
  74. package/dist/connections/settle.js +26 -0
  75. package/dist/connections/sources.d.ts +27 -0
  76. package/dist/connections/sources.js +300 -0
  77. package/dist/connections/triggers.d.ts +78 -0
  78. package/dist/connections/triggers.js +310 -0
  79. package/dist/connections/values.d.ts +26 -0
  80. package/dist/connections/values.js +93 -0
  81. package/dist/connections/views.d.ts +31 -0
  82. package/dist/connections/views.js +176 -0
  83. package/dist/expression/check.js +80 -1
  84. package/dist/expression/jsonata.d.ts +14 -4
  85. package/dist/expression/jsonata.js +27 -9
  86. package/dist/expression/step-outputs.d.ts +25 -0
  87. package/dist/expression/step-outputs.js +78 -0
  88. package/dist/harness/agent-harness.d.ts +69 -166
  89. package/dist/harness/agent-harness.js +170 -262
  90. package/dist/harness/call-span-collector.d.ts +33 -0
  91. package/dist/harness/call-span-collector.js +83 -0
  92. package/dist/harness/connection-gate.d.ts +78 -0
  93. package/dist/harness/connection-gate.js +169 -0
  94. package/dist/harness/deps/interpreter.d.ts +1 -0
  95. package/dist/harness/deps/interpreter.js +1 -0
  96. package/dist/harness/deps/runtime.d.ts +1 -1
  97. package/dist/harness/deps/types.d.ts +1 -1
  98. package/dist/harness/harness-options.d.ts +153 -0
  99. package/dist/harness/harness-options.js +36 -0
  100. package/dist/harness/harness-tracing.d.ts +16 -0
  101. package/dist/harness/harness-tracing.js +35 -0
  102. package/dist/harness/llm-client.d.ts +71 -0
  103. package/dist/harness/llm-client.js +218 -0
  104. package/dist/harness/model-call.d.ts +2 -7
  105. package/dist/harness/model-call.js +21 -549
  106. package/dist/harness/model-request.d.ts +42 -0
  107. package/dist/harness/model-request.js +159 -0
  108. package/dist/harness/model-stream.d.ts +39 -0
  109. package/dist/harness/model-stream.js +131 -0
  110. package/dist/harness/model-tool-round.d.ts +37 -0
  111. package/dist/harness/model-tool-round.js +197 -0
  112. package/dist/harness/spend.d.ts +2 -0
  113. package/dist/harness/spend.js +5 -1
  114. package/dist/index.d.ts +31 -6
  115. package/dist/index.js +18 -1
  116. package/dist/interpreter/connection-steps.d.ts +194 -0
  117. package/dist/interpreter/connection-steps.js +537 -0
  118. package/dist/interpreter/execute-action.d.ts +2 -8
  119. package/dist/interpreter/execute-action.js +3 -178
  120. package/dist/interpreter/execute-call.d.ts +19 -0
  121. package/dist/interpreter/execute-call.js +99 -0
  122. package/dist/interpreter/execute-control.d.ts +6 -1
  123. package/dist/interpreter/execute-control.js +14 -0
  124. package/dist/interpreter/execute-invoke-tool.d.ts +11 -0
  125. package/dist/interpreter/execute-invoke-tool.js +183 -0
  126. package/dist/interpreter/execute-verify.d.ts +21 -0
  127. package/dist/interpreter/execute-verify.js +391 -0
  128. package/dist/interpreter/execute-wait.d.ts +21 -0
  129. package/dist/interpreter/execute-wait.js +233 -0
  130. package/dist/interpreter/execute.js +24 -133
  131. package/dist/interpreter/step-kind-dispatch.d.ts +24 -0
  132. package/dist/interpreter/step-kind-dispatch.js +157 -0
  133. package/dist/interpreter/step-walk.d.ts +2 -0
  134. package/dist/interpreter/step-walk.js +24 -0
  135. package/dist/interpreter/verify-host.d.ts +40 -0
  136. package/dist/interpreter/verify-host.js +245 -0
  137. package/dist/runtime/durable/step-ledger.d.ts +31 -1
  138. package/dist/runtime/durable/step-ledger.js +87 -1
  139. package/dist/runtime/in-memory-artifact-store.d.ts +24 -0
  140. package/dist/runtime/in-memory-artifact-store.js +240 -0
  141. package/dist/schemas/workflow.d.ts +2 -2
  142. package/dist/schemas/workflow.js +1 -1
  143. package/dist/util/harness-internals.d.ts +23 -0
  144. package/dist/util/harness-internals.js +35 -0
  145. package/package.json +3 -3
  146. package/schema/noetic-workflow.schema.json +1170 -92
package/dist/index.js CHANGED
@@ -38,7 +38,9 @@ export { callModel, invokeTool, runCode, step } from './builders/step-builders.j
38
38
  /** @public */
39
39
  export { tool, toolWithGenerator } from './builders/tool-builder.js';
40
40
  /** @public */
41
- export { hydrateNode, hydrateWorkflow } from './builders/workflow-hydrator.js';
41
+ export { verify } from './builders/verify-builder.js';
42
+ /** @public */
43
+ export { hydrateNode, hydrateStepList, hydrateWorkflow } from './builders/workflow-hydrator.js';
42
44
  /** @public */
43
45
  export { workflow } from './builders/workflow-step.js';
44
46
  /** @public */
@@ -85,6 +87,8 @@ export { createInMemoryStorage } from './runtime/in-memory-storage.js';
85
87
  export { dynamicWorkflow, parseAndRunWorkflow } from './builders/dynamic-workflow.js';
86
88
  /** @public */
87
89
  export { DEFAULT_EXPRESSION_LIMITS } from './expression/jsonata.js';
90
+ //#endregion
91
+ //#region Runtime
88
92
  /** @public */
89
93
  export { AgentHarness } from './harness/agent-harness.js';
90
94
  /** @public */
@@ -120,6 +124,19 @@ export { TIMEOUT_ERROR_PREFIX } from '@noetic-tools/types';
120
124
  export { serializeError } from './adapters/in-memory-subprocess/metadata.js';
121
125
  /** @public */
122
126
  export { createLiveHandles } from './adapters/live-handles.js';
127
+ /** @public */
128
+ /** @public */
129
+ export { ARTIFACT_URI_PREFIX, artifactDigest, artifactUri, ConnectionUnsatisfiedError, DEFAULT_ARTIFACT_MAX_BYTES_PER_RUN, DEFAULT_ARTIFACT_MAX_COUNT_PER_RUN, isBlobRef, isConnectionUnsatisfiedError, isRef, isSecret, refId, secret, } from '@noetic-tools/types';
130
+ /** @public */
131
+ export { connection, isConnectionHandle } from './connections/handle.js';
132
+ /** @public */
133
+ export { createInMemoryConnection, InMemoryRefusal, inMemoryRefusal, } from './connections/in-memory-connection.js';
134
+ /** @public */
135
+ export { connectionTools } from './connections/model-tools.js';
136
+ /** @public */
137
+ export { cron, defineSource } from './connections/sources.js';
138
+ /** @public */
139
+ export { createInMemoryArtifactStore } from './runtime/in-memory-artifact-store.js';
123
140
  //#endregion
124
141
  //#region Until
125
142
  /** @public */
@@ -0,0 +1,194 @@
1
+ /**
2
+ * What `call` and `wait` steps share (spec 35 § Steps, § Durability; spec 23a
3
+ * § Connection Steps): finding the harness registry, resolving the step's
4
+ * connection through it, deriving idempotency keys, and the pending ledger
5
+ * entries a resumed run picks up from.
6
+ *
7
+ * Steps never hold a provider's `Connection`: everything goes through the
8
+ * registry contract in `connections/registry-types.ts`.
9
+ */
10
+ import type { AnyProfile, ConnectionHandle, ConnectionIdentity, ConnectionRequirement, Context, Step, StepConnectionTarget, StorageAdapter } from '@noetic-tools/types';
11
+ import { z } from 'zod';
12
+ import type { ResumeDecision } from '../connections/durability.js';
13
+ import type { ConnectionRegistry, ConnectionScope, ResolvedConnection } from '../connections/registry-types.js';
14
+ /** A step's connection after its target is evaluated. */
15
+ export interface ConnectionTargetInfo {
16
+ /** The name the step uses: a handle's name, or a harness connection name. */
17
+ name: string;
18
+ handle?: ConnectionHandle;
19
+ }
20
+ /** What a step needs of its connection beyond its handle: the operation or event it uses. */
21
+ export interface StepUse {
22
+ op?: string;
23
+ event?: string;
24
+ }
25
+ /** A connection step's resolved connection plus the run facts it records against. */
26
+ export interface StepConnection {
27
+ resolved: ResolvedConnection;
28
+ scope: ConnectionScope;
29
+ /** Run-and-step idempotency key, stable across a resume. */
30
+ idempotencyKey: string;
31
+ pending: PendingEntries | undefined;
32
+ }
33
+ /** A pending ledger entry: what a `call` or `wait` recorded before it reached a server. */
34
+ export type PendingEntry = z.infer<typeof PendingEntrySchema>;
35
+ declare const PendingEntrySchema: z.ZodObject<{
36
+ stepId: z.ZodString;
37
+ kind: z.ZodEnum<{
38
+ call: "call";
39
+ wait: "wait";
40
+ }>;
41
+ connection: z.ZodString;
42
+ key: z.ZodString;
43
+ identity: z.ZodObject<{
44
+ surface: z.ZodString;
45
+ instance: z.ZodString;
46
+ epoch: z.ZodOptional<z.ZodNumber>;
47
+ }, z.core.$strip>;
48
+ taskId: z.ZodOptional<z.ZodString>;
49
+ leaseId: z.ZodOptional<z.ZodString>;
50
+ cursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
51
+ deadline: z.ZodOptional<z.ZodNumber>;
52
+ }, z.core.$strip>;
53
+ /**
54
+ * The harness's connection registry.
55
+ *
56
+ * @throws `NoeticConfigError` `CONNECTION_UNKNOWN` when the harness has no connections.
57
+ */
58
+ export declare function connectionRegistryOf(ctx: Context, name: string): ConnectionRegistry;
59
+ /** The topmost ancestor of `ctx`: the run's root context, whose id names the run. */
60
+ export declare function runRootOf(ctx: Context): Context;
61
+ /** The abort signal of `ctx`, or one that never fires for a context without one (test stubs). */
62
+ export declare function signalOf(ctx: Context): AbortSignal;
63
+ /**
64
+ * The lease scope of a resolution. `fresh: 'run'` scopes to the run; `fresh:
65
+ * 'path'` to the parallel path the step runs on (the nearest context that is not
66
+ * the run root — each `inParallel` path runs in its own child context).
67
+ */
68
+ export declare function scopeFor(ctx: Context, fresh: 'run' | 'path' | undefined): ConnectionScope;
69
+ /** The lease scope key of a `fresh: 'path'` connection drawn on `ctx`. */
70
+ export declare function pathScopeKey(ctx: Context): string;
71
+ /**
72
+ * Returns every `fresh: 'path'` lease the given parallel path contexts hold
73
+ * (spec 35 § Fresh connections: "gives it back when the scope ends"). A no-op
74
+ * when the harness has no connections.
75
+ */
76
+ export declare function releasePathLeases(paths: ReadonlyArray<Context>): Promise<void>;
77
+ /** The ledger path of the step running on `ctx`, when it runs on a lane. */
78
+ export declare function stepPathOf(ctx: Context): string | undefined;
79
+ /** The run-and-step key a call carries, stable across a resume of the same run (spec 35 § Durability). */
80
+ export declare function idempotencyKeyFor(ctx: Context, stepId: string, ledgerKey?: string): string;
81
+ /**
82
+ * Evaluates a step's connection target.
83
+ *
84
+ * @throws `NoeticConfigError` `CONNECTION_INVALID` when it gives neither a handle nor a non-empty name.
85
+ */
86
+ export declare function evaluateTarget<TContext, I>(target: StepConnectionTarget<TContext, I>, input: I, ctx: Context<TContext>, stepId: string): Promise<ConnectionTargetInfo>;
87
+ /** What a handle (or a bare name) requires for one use: its profile and extensions, plus the op or event. */
88
+ export declare function requirementFor(target: ConnectionTargetInfo, use: StepUse): ConnectionRequirement;
89
+ /** What a harness graph needs of one connection, found before it runs. */
90
+ export interface GraphConnectionNeed {
91
+ /** The harness connection (or pool) the handle binds to. */
92
+ readonly name: string;
93
+ readonly profile?: AnyProfile;
94
+ readonly requirement: ConnectionRequirement;
95
+ /**
96
+ * Whether the handle passes a pool a setup. A pool's provider may offer a
97
+ * different manifest per setup, so such a need is checked on the lease.
98
+ */
99
+ readonly setup: boolean;
100
+ }
101
+ /**
102
+ * Every connection need a graph states up front: each `call` and `wait` whose
103
+ * connection is a static handle, with its profile and requirement. The harness
104
+ * registers these profiles (ref kinds) and requirements (start-time
105
+ * negotiation, renegotiated on a manifest change) when it is built.
106
+ */
107
+ export declare function graphConnectionNeeds(graph: Step): GraphConnectionNeed[];
108
+ /**
109
+ * Resolves the step's connection through the registry and prepares what a
110
+ * gated call or listen needs. Throws whatever `registry.resolve` throws.
111
+ */
112
+ export declare function resolveStepConnection(opts: {
113
+ ctx: Context;
114
+ stepId: string;
115
+ target: ConnectionTargetInfo;
116
+ use: StepUse;
117
+ ledgerKey: string | undefined;
118
+ }): Promise<StepConnection>;
119
+ /**
120
+ * Runs `fn` (a verify's `act`) with `witnesses` guarded: any `call` on one of
121
+ * them that has effects — however its connection was named, by a function or
122
+ * an expression too — is refused with `VERIFY_INVALID` (spec 37 § Witnesses).
123
+ */
124
+ export declare function withWitnessGuard<T>(ctx: Context, witnesses: ReadonlyArray<string>, fn: () => Promise<T>): Promise<T>;
125
+ /**
126
+ * Refuses a call on a witness inside a verify's `act` unless the operation is
127
+ * declared without effects.
128
+ *
129
+ * @throws `NoeticConfigError` `VERIFY_INVALID`.
130
+ */
131
+ export declare function refuseWitnessAct(ctx: Context, resolved: ResolvedConnection, op: string): void;
132
+ /**
133
+ * Pending ledger entries for one run (spec 23a § Connection Steps): written
134
+ * before a call or wait reaches a server, removed once it has a result. Kept
135
+ * in the harness `StorageAdapter` next to the run's ledger.
136
+ */
137
+ export declare class PendingEntries {
138
+ private readonly storage;
139
+ private readonly key;
140
+ constructor(storage: StorageAdapter, key: string);
141
+ /** The entry a previous attempt left, or undefined when there is none (or it does not parse). */
142
+ load(): Promise<PendingEntry | undefined>;
143
+ write(entry: PendingEntry): Promise<void>;
144
+ clear(): Promise<void>;
145
+ }
146
+ /** The storage key of a step's pending entry. */
147
+ export declare function pendingEntryKey(executionId: string, ledgerKey: string): string;
148
+ /**
149
+ * Deletes every pending entry a completed run left behind (an entry is normally
150
+ * cleared when its step gets a result; this catches steps a run never resumed).
151
+ */
152
+ export declare function clearPendingEntries(storage: StorageAdapter, executionId: string): Promise<void>;
153
+ /**
154
+ * Decides what a resumed step does with the pending entry a previous attempt
155
+ * left (spec 35 § Durability), through the one resume policy in
156
+ * `connections/durability.ts`. Against the same identity instance it returns the
157
+ * entry so the step picks up where it was. Against a replaced connection:
158
+ * `harness.restore(id, { rerun })` naming it, or `replayPrefix: 'free'`, runs
159
+ * live; `'costly'` with a reset resets first; anything else — including a
160
+ * connection that declares no determinism — refuses.
161
+ *
162
+ * @throws `NoeticErrorImpl` `connection_resume_refused` when the replaced connection cannot be driven again.
163
+ */
164
+ export declare function reconcilePending(connection: StepConnection, signal: AbortSignal, ctx?: Context): Promise<PendingEntry | undefined>;
165
+ /** What run-level reconciliation needs of the registry. */
166
+ export interface ResumeChecker {
167
+ checkResume(params: {
168
+ readonly executionId: string;
169
+ readonly name: string;
170
+ readonly recorded: ConnectionIdentity;
171
+ readonly signal: AbortSignal;
172
+ }): Promise<ResumeDecision>;
173
+ }
174
+ /**
175
+ * Before a resumed run replays anything, checks every connection its ledger
176
+ * and pending entries were recorded against (spec 35 § Durability). For a
177
+ * replaced connection that may run live (after a reset when that is the
178
+ * decision), the ledger is discarded from the first entry that used it —
179
+ * everything after runs live too, model rounds included — and its pending
180
+ * entries are dropped (their idempotency keys derive from the run and step,
181
+ * so `once` calls still carry their original keys). Resolves the number of
182
+ * ledger entries discarded.
183
+ *
184
+ * @throws `NoeticErrorImpl` `connection_resume_refused` when a replaced connection cannot be driven again.
185
+ */
186
+ export declare function reconcileResumedConnections(opts: {
187
+ ctx: Context;
188
+ registry: ResumeChecker;
189
+ storage: StorageAdapter | undefined;
190
+ signal: AbortSignal;
191
+ }): Promise<number>;
192
+ /** Emits a connection framework event (`connection_event`, `connection_task`, `stream_changed`). */
193
+ export declare function emitConnectionEvent(ctx: Context, eventType: string, data: Record<string, unknown>): void;
194
+ export {};