@codemation/node-example 0.0.31 → 0.0.33

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @codemation/node-example
2
2
 
3
+ ## 0.0.33
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`ed75183`](https://github.com/MadeRelevant/codemation/commit/ed75183f51ae71b06aa2e57ae4fc48ce9db2e4ce)]:
8
+ - @codemation/core@1.0.1
9
+
10
+ ## 0.0.32
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies [[`640e303`](https://github.com/MadeRelevant/codemation/commit/640e3032b1386568df725980a27761b6e230302c), [`640e303`](https://github.com/MadeRelevant/codemation/commit/640e3032b1386568df725980a27761b6e230302c)]:
15
+ - @codemation/core@1.0.0
16
+
3
17
  ## 0.0.31
4
18
 
5
19
  ### Patch Changes
package/dist/index.d.cts CHANGED
@@ -2,8 +2,37 @@ import { ReadableStream } from "node:stream/web";
2
2
  import { InjectionToken as TypeToken } from "tsyringe";
3
3
  import { ZodType } from "zod";
4
4
 
5
- //#region ../core/src/contracts/retryPolicySpec.types.d.ts
5
+ //#region ../core/src/contracts/runTypes.d.ts
6
6
 
7
+ type NodeInputsByPort = Readonly<Record<InputPortKey, Items>>;
8
+ type NodeExecutionStatus = "pending" | "queued" | "running" | "completed" | "failed" | "skipped";
9
+ interface NodeExecutionError {
10
+ message: string;
11
+ name?: string;
12
+ stack?: string;
13
+ details?: JsonValue;
14
+ }
15
+ /** Stable id for a single connection invocation row in {@link ConnectionInvocationRecord}. */
16
+ type ConnectionInvocationId = string;
17
+ /** Arguments for appending a {@link ConnectionInvocationRecord} (engine fills run/workflow ids and timestamps). */
18
+ type ConnectionInvocationAppendArgs = Readonly<{
19
+ invocationId: ConnectionInvocationId;
20
+ connectionNodeId: NodeId;
21
+ parentAgentNodeId: NodeId;
22
+ parentAgentActivationId: NodeActivationId;
23
+ status: NodeExecutionStatus;
24
+ managedInput?: JsonValue;
25
+ managedOutput?: JsonValue;
26
+ error?: NodeExecutionError;
27
+ queuedAt?: string;
28
+ startedAt?: string;
29
+ finishedAt?: string;
30
+ iterationId?: NodeIterationId;
31
+ itemIndex?: number;
32
+ parentInvocationId?: ConnectionInvocationId;
33
+ }>;
34
+ //#endregion
35
+ //#region ../core/src/contracts/retryPolicySpec.types.d.ts
7
36
  /**
8
37
  * In-process retry policy for runnable nodes. Serialized configs use the same
9
38
  * `kind` discriminator (`JSON.stringify` / persisted workflows).
@@ -87,6 +116,17 @@ interface TelemetrySpanScope extends TelemetryScope {
87
116
  readonly traceId: string;
88
117
  readonly spanId: string;
89
118
  end(args?: TelemetrySpanEnd): Promise<void> | void;
119
+ /**
120
+ * Lift this span into a {@link NodeExecutionTelemetry} scoped to a different (nodeId, activationId).
121
+ * Children created via the returned telemetry's `startChildSpan` get this span as their parent.
122
+ *
123
+ * Used at the sub-agent boundary so that nested runtime telemetry parents under the agent.tool.call
124
+ * span instead of the orchestrator's node-level span.
125
+ */
126
+ asNodeTelemetry(args: Readonly<{
127
+ nodeId: NodeId;
128
+ activationId: NodeActivationId;
129
+ }>): NodeExecutionTelemetry;
90
130
  }
91
131
  interface NodeExecutionTelemetry extends ExecutionTelemetry, TelemetrySpanScope {
92
132
  startChildSpan(args: TelemetryChildSpanStart): TelemetrySpanScope;
@@ -123,32 +163,6 @@ interface CostTrackingTelemetry {
123
163
  forScope(scope: TelemetryScope): CostTrackingTelemetry;
124
164
  }
125
165
  //#endregion
126
- //#region ../core/src/contracts/runTypes.d.ts
127
- type NodeInputsByPort = Readonly<Record<InputPortKey, Items>>;
128
- type NodeExecutionStatus = "pending" | "queued" | "running" | "completed" | "failed" | "skipped";
129
- interface NodeExecutionError {
130
- message: string;
131
- name?: string;
132
- stack?: string;
133
- details?: JsonValue;
134
- }
135
- /** Stable id for a single connection invocation row in {@link ConnectionInvocationRecord}. */
136
- type ConnectionInvocationId = string;
137
- /** Arguments for appending a {@link ConnectionInvocationRecord} (engine fills run/workflow ids and timestamps). */
138
- type ConnectionInvocationAppendArgs = Readonly<{
139
- invocationId: ConnectionInvocationId;
140
- connectionNodeId: NodeId;
141
- parentAgentNodeId: NodeId;
142
- parentAgentActivationId: NodeActivationId;
143
- status: NodeExecutionStatus;
144
- managedInput?: JsonValue;
145
- managedOutput?: JsonValue;
146
- error?: NodeExecutionError;
147
- queuedAt?: string;
148
- startedAt?: string;
149
- finishedAt?: string;
150
- }>;
151
- //#endregion
152
166
  //#region ../core/src/contracts/runtimeTypes.d.ts
153
167
  interface NodeExecutionStatePublisher {
154
168
  markQueued(args: {
@@ -214,6 +228,12 @@ interface ExecutionContext {
214
228
  telemetry: ExecutionTelemetry;
215
229
  binary: ExecutionBinaryService;
216
230
  getCredential<TSession = unknown>(slotKey: string): Promise<TSession>;
231
+ /** Per-item iteration id, set by {@link NodeExecutor} on the ctx passed into runnable `execute`. */
232
+ iterationId?: NodeIterationId;
233
+ /** Item index (0-based) within the current activation's batch; set alongside {@link iterationId}. */
234
+ itemIndex?: number;
235
+ /** When set, this ctx is executing inside a sub-agent triggered by the named parent invocation. */
236
+ parentInvocationId?: ConnectionInvocationId;
217
237
  }
218
238
  interface NodeExecutionContext<TConfig extends NodeConfigBase = NodeConfigBase> extends ExecutionContext {
219
239
  nodeId: NodeId;
@@ -346,6 +366,12 @@ type Items<TJson = unknown> = ReadonlyArray<Item<TJson>>;
346
366
  type NodeOutputs = Partial<Record<OutputPortKey, Items>>;
347
367
  type RunId = string;
348
368
  type NodeActivationId = string;
369
+ /**
370
+ * One per-item iteration of a runnable node's execute loop. Refines `NodeActivationId` for
371
+ * per-item connection invocations and telemetry. Undefined when the executing node is a batch
372
+ * node or trigger that does not iterate items.
373
+ */
374
+ type NodeIterationId = string;
349
375
  interface ParentExecutionRef {
350
376
  runId: RunId;
351
377
  workflowId: WorkflowId;
package/dist/index.d.ts CHANGED
@@ -2,8 +2,37 @@ import { ReadableStream } from "node:stream/web";
2
2
  import { InjectionToken as TypeToken } from "tsyringe";
3
3
  import { ZodType } from "zod";
4
4
 
5
- //#region ../core/src/contracts/retryPolicySpec.types.d.ts
5
+ //#region ../core/src/contracts/runTypes.d.ts
6
6
 
7
+ type NodeInputsByPort = Readonly<Record<InputPortKey, Items>>;
8
+ type NodeExecutionStatus = "pending" | "queued" | "running" | "completed" | "failed" | "skipped";
9
+ interface NodeExecutionError {
10
+ message: string;
11
+ name?: string;
12
+ stack?: string;
13
+ details?: JsonValue;
14
+ }
15
+ /** Stable id for a single connection invocation row in {@link ConnectionInvocationRecord}. */
16
+ type ConnectionInvocationId = string;
17
+ /** Arguments for appending a {@link ConnectionInvocationRecord} (engine fills run/workflow ids and timestamps). */
18
+ type ConnectionInvocationAppendArgs = Readonly<{
19
+ invocationId: ConnectionInvocationId;
20
+ connectionNodeId: NodeId;
21
+ parentAgentNodeId: NodeId;
22
+ parentAgentActivationId: NodeActivationId;
23
+ status: NodeExecutionStatus;
24
+ managedInput?: JsonValue;
25
+ managedOutput?: JsonValue;
26
+ error?: NodeExecutionError;
27
+ queuedAt?: string;
28
+ startedAt?: string;
29
+ finishedAt?: string;
30
+ iterationId?: NodeIterationId;
31
+ itemIndex?: number;
32
+ parentInvocationId?: ConnectionInvocationId;
33
+ }>;
34
+ //#endregion
35
+ //#region ../core/src/contracts/retryPolicySpec.types.d.ts
7
36
  /**
8
37
  * In-process retry policy for runnable nodes. Serialized configs use the same
9
38
  * `kind` discriminator (`JSON.stringify` / persisted workflows).
@@ -87,6 +116,17 @@ interface TelemetrySpanScope extends TelemetryScope {
87
116
  readonly traceId: string;
88
117
  readonly spanId: string;
89
118
  end(args?: TelemetrySpanEnd): Promise<void> | void;
119
+ /**
120
+ * Lift this span into a {@link NodeExecutionTelemetry} scoped to a different (nodeId, activationId).
121
+ * Children created via the returned telemetry's `startChildSpan` get this span as their parent.
122
+ *
123
+ * Used at the sub-agent boundary so that nested runtime telemetry parents under the agent.tool.call
124
+ * span instead of the orchestrator's node-level span.
125
+ */
126
+ asNodeTelemetry(args: Readonly<{
127
+ nodeId: NodeId;
128
+ activationId: NodeActivationId;
129
+ }>): NodeExecutionTelemetry;
90
130
  }
91
131
  interface NodeExecutionTelemetry extends ExecutionTelemetry, TelemetrySpanScope {
92
132
  startChildSpan(args: TelemetryChildSpanStart): TelemetrySpanScope;
@@ -123,32 +163,6 @@ interface CostTrackingTelemetry {
123
163
  forScope(scope: TelemetryScope): CostTrackingTelemetry;
124
164
  }
125
165
  //#endregion
126
- //#region ../core/src/contracts/runTypes.d.ts
127
- type NodeInputsByPort = Readonly<Record<InputPortKey, Items>>;
128
- type NodeExecutionStatus = "pending" | "queued" | "running" | "completed" | "failed" | "skipped";
129
- interface NodeExecutionError {
130
- message: string;
131
- name?: string;
132
- stack?: string;
133
- details?: JsonValue;
134
- }
135
- /** Stable id for a single connection invocation row in {@link ConnectionInvocationRecord}. */
136
- type ConnectionInvocationId = string;
137
- /** Arguments for appending a {@link ConnectionInvocationRecord} (engine fills run/workflow ids and timestamps). */
138
- type ConnectionInvocationAppendArgs = Readonly<{
139
- invocationId: ConnectionInvocationId;
140
- connectionNodeId: NodeId;
141
- parentAgentNodeId: NodeId;
142
- parentAgentActivationId: NodeActivationId;
143
- status: NodeExecutionStatus;
144
- managedInput?: JsonValue;
145
- managedOutput?: JsonValue;
146
- error?: NodeExecutionError;
147
- queuedAt?: string;
148
- startedAt?: string;
149
- finishedAt?: string;
150
- }>;
151
- //#endregion
152
166
  //#region ../core/src/contracts/runtimeTypes.d.ts
153
167
  interface NodeExecutionStatePublisher {
154
168
  markQueued(args: {
@@ -214,6 +228,12 @@ interface ExecutionContext {
214
228
  telemetry: ExecutionTelemetry;
215
229
  binary: ExecutionBinaryService;
216
230
  getCredential<TSession = unknown>(slotKey: string): Promise<TSession>;
231
+ /** Per-item iteration id, set by {@link NodeExecutor} on the ctx passed into runnable `execute`. */
232
+ iterationId?: NodeIterationId;
233
+ /** Item index (0-based) within the current activation's batch; set alongside {@link iterationId}. */
234
+ itemIndex?: number;
235
+ /** When set, this ctx is executing inside a sub-agent triggered by the named parent invocation. */
236
+ parentInvocationId?: ConnectionInvocationId;
217
237
  }
218
238
  interface NodeExecutionContext<TConfig extends NodeConfigBase = NodeConfigBase> extends ExecutionContext {
219
239
  nodeId: NodeId;
@@ -346,6 +366,12 @@ type Items<TJson = unknown> = ReadonlyArray<Item<TJson>>;
346
366
  type NodeOutputs = Partial<Record<OutputPortKey, Items>>;
347
367
  type RunId = string;
348
368
  type NodeActivationId = string;
369
+ /**
370
+ * One per-item iteration of a runnable node's execute loop. Refines `NodeActivationId` for
371
+ * per-item connection invocations and telemetry. Undefined when the executing node is a batch
372
+ * node or trigger that does not iterate items.
373
+ */
374
+ type NodeIterationId = string;
349
375
  interface ParentExecutionRef {
350
376
  runId: RunId;
351
377
  workflowId: WorkflowId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemation/node-example",
3
- "version": "0.0.31",
3
+ "version": "0.0.33",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -28,7 +28,7 @@
28
28
  }
29
29
  },
30
30
  "dependencies": {
31
- "@codemation/core": "0.8.1"
31
+ "@codemation/core": "1.0.1"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/node": "^25.3.5",