@codemation/node-example 0.0.28 → 0.0.30

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.30
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`a250ab8`](https://github.com/MadeRelevant/codemation/commit/a250ab8b973429cdfe708526a205e2565b004868), [`782e934`](https://github.com/MadeRelevant/codemation/commit/782e93469ea6eee701d976b8f1dc18649d045c79), [`052aba1`](https://github.com/MadeRelevant/codemation/commit/052aba17c9a4faf557bdfaa1a9644a1987ecc25e), [`1a356af`](https://github.com/MadeRelevant/codemation/commit/1a356afae50bd3f982e92c3e9f931e3adbcd131f)]:
8
+ - @codemation/core@0.8.0
9
+
10
+ ## 0.0.29
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies [[`88844f7`](https://github.com/MadeRelevant/codemation/commit/88844f75a48fe051e4cb895c710408855de14da4)]:
15
+ - @codemation/core@0.7.0
16
+
3
17
  ## 0.0.28
4
18
 
5
19
  ### Patch Changes
package/dist/index.d.cts CHANGED
@@ -31,14 +31,106 @@ interface ExponentialRetryPolicySpec {
31
31
  readonly jitter?: boolean;
32
32
  }
33
33
  //#endregion
34
+ //#region ../core/src/contracts/telemetryTypes.d.ts
35
+ type TelemetryAttributePrimitive = string | number | boolean | null;
36
+ interface TelemetryAttributes {
37
+ readonly [key: string]: TelemetryAttributePrimitive | undefined;
38
+ }
39
+ interface TelemetryMetricRecord {
40
+ readonly name: string;
41
+ readonly value: number;
42
+ readonly unit?: string;
43
+ readonly attributes?: TelemetryAttributes;
44
+ }
45
+ interface TelemetrySpanEventRecord {
46
+ readonly name: string;
47
+ readonly occurredAt?: Date;
48
+ readonly attributes?: TelemetryAttributes;
49
+ }
50
+ interface TelemetryArtifactAttachment {
51
+ readonly kind: string;
52
+ readonly contentType: string;
53
+ readonly previewText?: string;
54
+ readonly previewJson?: JsonValue;
55
+ readonly payloadText?: string;
56
+ readonly payloadJson?: JsonValue;
57
+ readonly bytes?: number;
58
+ readonly truncated?: boolean;
59
+ readonly expiresAt?: Date;
60
+ }
61
+ interface TelemetryArtifactReference {
62
+ readonly artifactId: string;
63
+ readonly traceId?: string;
64
+ readonly spanId?: string;
65
+ }
66
+ interface TelemetrySpanEnd {
67
+ readonly status?: "ok" | "error";
68
+ readonly statusMessage?: string;
69
+ readonly endedAt?: Date;
70
+ readonly attributes?: TelemetryAttributes;
71
+ }
72
+ interface TelemetryChildSpanStart {
73
+ readonly name: string;
74
+ readonly kind?: "internal" | "client";
75
+ readonly startedAt?: Date;
76
+ readonly attributes?: TelemetryAttributes;
77
+ }
78
+ interface TelemetryScope {
79
+ readonly traceId?: string;
80
+ readonly spanId?: string;
81
+ readonly costTracking?: CostTrackingTelemetry;
82
+ addSpanEvent(args: TelemetrySpanEventRecord): Promise<void> | void;
83
+ recordMetric(args: TelemetryMetricRecord): Promise<void> | void;
84
+ attachArtifact(args: TelemetryArtifactAttachment): Promise<TelemetryArtifactReference> | TelemetryArtifactReference;
85
+ }
86
+ interface TelemetrySpanScope extends TelemetryScope {
87
+ readonly traceId: string;
88
+ readonly spanId: string;
89
+ end(args?: TelemetrySpanEnd): Promise<void> | void;
90
+ }
91
+ interface NodeExecutionTelemetry extends ExecutionTelemetry, TelemetrySpanScope {
92
+ startChildSpan(args: TelemetryChildSpanStart): TelemetrySpanScope;
93
+ }
94
+ interface ExecutionTelemetry extends TelemetryScope {
95
+ readonly traceId: string;
96
+ readonly spanId: string;
97
+ forNode(args: Readonly<{
98
+ nodeId: NodeId;
99
+ activationId: NodeActivationId;
100
+ }>): NodeExecutionTelemetry;
101
+ }
102
+ //#endregion
103
+ //#region ../core/src/contracts/CostTrackingTelemetryContract.d.ts
104
+ type CostTrackingComponent = "chat" | "ocr" | "rag";
105
+ interface CostTrackingUsageRecord {
106
+ readonly component: CostTrackingComponent;
107
+ readonly provider: string;
108
+ readonly operation: string;
109
+ readonly pricingKey: string;
110
+ readonly usageUnit: string;
111
+ readonly quantity: number;
112
+ readonly modelName?: string;
113
+ readonly attributes?: TelemetryAttributes;
114
+ }
115
+ interface CostTrackingPriceQuote {
116
+ readonly currency: string;
117
+ readonly currencyScale: number;
118
+ readonly estimatedAmountMinor: number;
119
+ readonly estimateKind: "catalog";
120
+ }
121
+ interface CostTrackingTelemetry {
122
+ captureUsage(args: CostTrackingUsageRecord): Promise<CostTrackingPriceQuote | undefined>;
123
+ forScope(scope: TelemetryScope): CostTrackingTelemetry;
124
+ }
125
+ //#endregion
34
126
  //#region ../core/src/contracts/runTypes.d.ts
35
-
36
127
  type NodeInputsByPort = Readonly<Record<InputPortKey, Items>>;
37
128
  type NodeExecutionStatus = "pending" | "queued" | "running" | "completed" | "failed" | "skipped";
38
129
  interface NodeExecutionError {
39
130
  message: string;
40
131
  name?: string;
41
132
  stack?: string;
133
+ details?: JsonValue;
42
134
  }
43
135
  /** Stable id for a single connection invocation row in {@link ConnectionInvocationRecord}. */
44
136
  type ConnectionInvocationId = string;
@@ -119,6 +211,7 @@ interface ExecutionContext {
119
211
  now: () => Date;
120
212
  data: RunDataSnapshot;
121
213
  nodeState?: NodeExecutionStatePublisher;
214
+ telemetry: ExecutionTelemetry;
122
215
  binary: ExecutionBinaryService;
123
216
  getCredential<TSession = unknown>(slotKey: string): Promise<TSession>;
124
217
  }
@@ -126,6 +219,7 @@ interface NodeExecutionContext<TConfig extends NodeConfigBase = NodeConfigBase>
126
219
  nodeId: NodeId;
127
220
  activationId: NodeActivationId;
128
221
  config: TConfig;
222
+ telemetry: NodeExecutionTelemetry;
129
223
  binary: NodeBinaryAttachmentService;
130
224
  }
131
225
  /**
@@ -158,6 +252,9 @@ interface RunnableNode<TConfig extends RunnableNodeConfig<any, any> = RunnableNo
158
252
  //#region ../core/src/contracts/workflowTypes.d.ts
159
253
  type WorkflowId = string;
160
254
  type NodeId = string;
255
+ type NodeIdRef<TJson = unknown> = NodeId & Readonly<{
256
+ __codemationNodeJson?: TJson;
257
+ }>;
161
258
  type OutputPortKey = string;
162
259
  type InputPortKey = string;
163
260
  type NodeKind = "trigger" | "node";
@@ -262,8 +359,8 @@ interface ParentExecutionRef {
262
359
  }
263
360
  interface RunDataSnapshot {
264
361
  getOutputs(nodeId: NodeId): NodeOutputs | undefined;
265
- getOutputItems(nodeId: NodeId, output?: OutputPortKey): Items;
266
- getOutputItem(nodeId: NodeId, itemIndex: number, output?: OutputPortKey): Item | undefined;
362
+ getOutputItems<TJson = unknown>(nodeId: NodeId | NodeIdRef<TJson>, output?: OutputPortKey): Items<TJson>;
363
+ getOutputItem<TJson = unknown>(nodeId: NodeId | NodeIdRef<TJson>, itemIndex: number, output?: OutputPortKey): Item<TJson> | undefined;
267
364
  }
268
365
  interface NodeErrorHandlerArgs<TConfig extends NodeConfigBase = NodeConfigBase> {
269
366
  readonly kind: "single" | "multi";
package/dist/index.d.ts CHANGED
@@ -31,14 +31,106 @@ interface ExponentialRetryPolicySpec {
31
31
  readonly jitter?: boolean;
32
32
  }
33
33
  //#endregion
34
+ //#region ../core/src/contracts/telemetryTypes.d.ts
35
+ type TelemetryAttributePrimitive = string | number | boolean | null;
36
+ interface TelemetryAttributes {
37
+ readonly [key: string]: TelemetryAttributePrimitive | undefined;
38
+ }
39
+ interface TelemetryMetricRecord {
40
+ readonly name: string;
41
+ readonly value: number;
42
+ readonly unit?: string;
43
+ readonly attributes?: TelemetryAttributes;
44
+ }
45
+ interface TelemetrySpanEventRecord {
46
+ readonly name: string;
47
+ readonly occurredAt?: Date;
48
+ readonly attributes?: TelemetryAttributes;
49
+ }
50
+ interface TelemetryArtifactAttachment {
51
+ readonly kind: string;
52
+ readonly contentType: string;
53
+ readonly previewText?: string;
54
+ readonly previewJson?: JsonValue;
55
+ readonly payloadText?: string;
56
+ readonly payloadJson?: JsonValue;
57
+ readonly bytes?: number;
58
+ readonly truncated?: boolean;
59
+ readonly expiresAt?: Date;
60
+ }
61
+ interface TelemetryArtifactReference {
62
+ readonly artifactId: string;
63
+ readonly traceId?: string;
64
+ readonly spanId?: string;
65
+ }
66
+ interface TelemetrySpanEnd {
67
+ readonly status?: "ok" | "error";
68
+ readonly statusMessage?: string;
69
+ readonly endedAt?: Date;
70
+ readonly attributes?: TelemetryAttributes;
71
+ }
72
+ interface TelemetryChildSpanStart {
73
+ readonly name: string;
74
+ readonly kind?: "internal" | "client";
75
+ readonly startedAt?: Date;
76
+ readonly attributes?: TelemetryAttributes;
77
+ }
78
+ interface TelemetryScope {
79
+ readonly traceId?: string;
80
+ readonly spanId?: string;
81
+ readonly costTracking?: CostTrackingTelemetry;
82
+ addSpanEvent(args: TelemetrySpanEventRecord): Promise<void> | void;
83
+ recordMetric(args: TelemetryMetricRecord): Promise<void> | void;
84
+ attachArtifact(args: TelemetryArtifactAttachment): Promise<TelemetryArtifactReference> | TelemetryArtifactReference;
85
+ }
86
+ interface TelemetrySpanScope extends TelemetryScope {
87
+ readonly traceId: string;
88
+ readonly spanId: string;
89
+ end(args?: TelemetrySpanEnd): Promise<void> | void;
90
+ }
91
+ interface NodeExecutionTelemetry extends ExecutionTelemetry, TelemetrySpanScope {
92
+ startChildSpan(args: TelemetryChildSpanStart): TelemetrySpanScope;
93
+ }
94
+ interface ExecutionTelemetry extends TelemetryScope {
95
+ readonly traceId: string;
96
+ readonly spanId: string;
97
+ forNode(args: Readonly<{
98
+ nodeId: NodeId;
99
+ activationId: NodeActivationId;
100
+ }>): NodeExecutionTelemetry;
101
+ }
102
+ //#endregion
103
+ //#region ../core/src/contracts/CostTrackingTelemetryContract.d.ts
104
+ type CostTrackingComponent = "chat" | "ocr" | "rag";
105
+ interface CostTrackingUsageRecord {
106
+ readonly component: CostTrackingComponent;
107
+ readonly provider: string;
108
+ readonly operation: string;
109
+ readonly pricingKey: string;
110
+ readonly usageUnit: string;
111
+ readonly quantity: number;
112
+ readonly modelName?: string;
113
+ readonly attributes?: TelemetryAttributes;
114
+ }
115
+ interface CostTrackingPriceQuote {
116
+ readonly currency: string;
117
+ readonly currencyScale: number;
118
+ readonly estimatedAmountMinor: number;
119
+ readonly estimateKind: "catalog";
120
+ }
121
+ interface CostTrackingTelemetry {
122
+ captureUsage(args: CostTrackingUsageRecord): Promise<CostTrackingPriceQuote | undefined>;
123
+ forScope(scope: TelemetryScope): CostTrackingTelemetry;
124
+ }
125
+ //#endregion
34
126
  //#region ../core/src/contracts/runTypes.d.ts
35
-
36
127
  type NodeInputsByPort = Readonly<Record<InputPortKey, Items>>;
37
128
  type NodeExecutionStatus = "pending" | "queued" | "running" | "completed" | "failed" | "skipped";
38
129
  interface NodeExecutionError {
39
130
  message: string;
40
131
  name?: string;
41
132
  stack?: string;
133
+ details?: JsonValue;
42
134
  }
43
135
  /** Stable id for a single connection invocation row in {@link ConnectionInvocationRecord}. */
44
136
  type ConnectionInvocationId = string;
@@ -119,6 +211,7 @@ interface ExecutionContext {
119
211
  now: () => Date;
120
212
  data: RunDataSnapshot;
121
213
  nodeState?: NodeExecutionStatePublisher;
214
+ telemetry: ExecutionTelemetry;
122
215
  binary: ExecutionBinaryService;
123
216
  getCredential<TSession = unknown>(slotKey: string): Promise<TSession>;
124
217
  }
@@ -126,6 +219,7 @@ interface NodeExecutionContext<TConfig extends NodeConfigBase = NodeConfigBase>
126
219
  nodeId: NodeId;
127
220
  activationId: NodeActivationId;
128
221
  config: TConfig;
222
+ telemetry: NodeExecutionTelemetry;
129
223
  binary: NodeBinaryAttachmentService;
130
224
  }
131
225
  /**
@@ -158,6 +252,9 @@ interface RunnableNode<TConfig extends RunnableNodeConfig<any, any> = RunnableNo
158
252
  //#region ../core/src/contracts/workflowTypes.d.ts
159
253
  type WorkflowId = string;
160
254
  type NodeId = string;
255
+ type NodeIdRef<TJson = unknown> = NodeId & Readonly<{
256
+ __codemationNodeJson?: TJson;
257
+ }>;
161
258
  type OutputPortKey = string;
162
259
  type InputPortKey = string;
163
260
  type NodeKind = "trigger" | "node";
@@ -262,8 +359,8 @@ interface ParentExecutionRef {
262
359
  }
263
360
  interface RunDataSnapshot {
264
361
  getOutputs(nodeId: NodeId): NodeOutputs | undefined;
265
- getOutputItems(nodeId: NodeId, output?: OutputPortKey): Items;
266
- getOutputItem(nodeId: NodeId, itemIndex: number, output?: OutputPortKey): Item | undefined;
362
+ getOutputItems<TJson = unknown>(nodeId: NodeId | NodeIdRef<TJson>, output?: OutputPortKey): Items<TJson>;
363
+ getOutputItem<TJson = unknown>(nodeId: NodeId | NodeIdRef<TJson>, itemIndex: number, output?: OutputPortKey): Item<TJson> | undefined;
267
364
  }
268
365
  interface NodeErrorHandlerArgs<TConfig extends NodeConfigBase = NodeConfigBase> {
269
366
  readonly kind: "single" | "multi";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemation/node-example",
3
- "version": "0.0.28",
3
+ "version": "0.0.30",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -28,7 +28,7 @@
28
28
  }
29
29
  },
30
30
  "dependencies": {
31
- "@codemation/core": "0.6.0"
31
+ "@codemation/core": "0.8.0"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/node": "^25.3.5",