@nebulaos/core 0.2.2 → 0.2.4
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/agent/Agent.js +11 -1
- package/dist/tracing/index.d.ts +9 -0
- package/dist/tracing/index.js +44 -0
- package/package.json +4 -4
package/dist/agent/Agent.js
CHANGED
|
@@ -397,7 +397,17 @@ class Agent extends BaseAgent_js_1.BaseAgent {
|
|
|
397
397
|
durationMs: Date.now() - startTime,
|
|
398
398
|
},
|
|
399
399
|
});
|
|
400
|
-
await agentSpan.end({
|
|
400
|
+
await agentSpan.end({
|
|
401
|
+
status: "error",
|
|
402
|
+
data: {
|
|
403
|
+
error: {
|
|
404
|
+
message: error.message,
|
|
405
|
+
name: error.name,
|
|
406
|
+
code: error.code,
|
|
407
|
+
status: error.status,
|
|
408
|
+
},
|
|
409
|
+
},
|
|
410
|
+
});
|
|
401
411
|
throw err;
|
|
402
412
|
}
|
|
403
413
|
});
|
package/dist/tracing/index.d.ts
CHANGED
|
@@ -85,5 +85,14 @@ export declare class Tracing {
|
|
|
85
85
|
* ITelemetryExporter.
|
|
86
86
|
*/
|
|
87
87
|
static withSpan<T, K extends TelemetrySpanKind>(input: SpanStartInput<K>, fn: (span: ActiveSpan<K>) => Promise<T>): Promise<T>;
|
|
88
|
+
/**
|
|
89
|
+
* Starts a new span without requiring a callback.
|
|
90
|
+
* Useful for async generators or cases where withSpan is not applicable.
|
|
91
|
+
* The caller is responsible for ending the span.
|
|
92
|
+
*
|
|
93
|
+
* Returns undefined if tracing is not configured.
|
|
94
|
+
*/
|
|
95
|
+
static startSpan<K extends TelemetrySpanKind>(input: SpanStartInput<K>): Promise<ActiveSpan<K> | undefined>;
|
|
96
|
+
private static defaultStartSpan;
|
|
88
97
|
private static defaultWithSpan;
|
|
89
98
|
}
|
package/dist/tracing/index.js
CHANGED
|
@@ -133,6 +133,50 @@ class Tracing {
|
|
|
133
133
|
}
|
|
134
134
|
return this.defaultWithSpan(input, fn);
|
|
135
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Starts a new span without requiring a callback.
|
|
138
|
+
* Useful for async generators or cases where withSpan is not applicable.
|
|
139
|
+
* The caller is responsible for ending the span.
|
|
140
|
+
*
|
|
141
|
+
* Returns undefined if tracing is not configured.
|
|
142
|
+
*/
|
|
143
|
+
static async startSpan(input) {
|
|
144
|
+
if (this.provider) {
|
|
145
|
+
return this.provider.startSpan(input);
|
|
146
|
+
}
|
|
147
|
+
return this.defaultStartSpan(input);
|
|
148
|
+
}
|
|
149
|
+
static async defaultStartSpan(input) {
|
|
150
|
+
const parent = storage.getStore();
|
|
151
|
+
const traceId = parent?.traceId ?? generateTraceId();
|
|
152
|
+
const parentSpanId = parent?.spanId;
|
|
153
|
+
const spanId = generateSpanId();
|
|
154
|
+
const startedAt = new Date().toISOString();
|
|
155
|
+
const startEvent = {
|
|
156
|
+
v: 1,
|
|
157
|
+
type: "telemetry:span:start",
|
|
158
|
+
timestamp: startedAt,
|
|
159
|
+
trace: {
|
|
160
|
+
traceId,
|
|
161
|
+
spanId,
|
|
162
|
+
parentSpanId,
|
|
163
|
+
},
|
|
164
|
+
correlationId: input.correlationId,
|
|
165
|
+
executionId: input.executionId,
|
|
166
|
+
span: {
|
|
167
|
+
kind: input.kind,
|
|
168
|
+
name: input.name,
|
|
169
|
+
data: (input.data ?? {}),
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
try {
|
|
173
|
+
await this.exporter.exportBatch([startEvent]);
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
// Telemetry must never break execution.
|
|
177
|
+
}
|
|
178
|
+
return new ActiveSpan(traceId, spanId, parentSpanId, input.kind, input.name, input.correlationId, input.executionId, this.exporter);
|
|
179
|
+
}
|
|
136
180
|
// ---------------------------------------------------------------------------
|
|
137
181
|
// Default (built-in) implementation – used when no provider is set
|
|
138
182
|
// ---------------------------------------------------------------------------
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nebulaos/core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Core primitives for NebulaOS (Agent, Workflow, Providers)",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"uuid": "^9.0.1",
|
|
34
34
|
"zod": "^3.0.0",
|
|
35
35
|
"zod-to-json-schema": "^3.0.0",
|
|
36
|
-
"@nebulaos/types": "0.1.
|
|
36
|
+
"@nebulaos/types": "^0.1.3"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/jest": "^30.0.0",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"ts-jest": "^29.4.6",
|
|
45
45
|
"typescript": "^5.0.0",
|
|
46
46
|
"@nebulaos/oci": "0.0.1",
|
|
47
|
-
"@nebulaos/
|
|
48
|
-
"@nebulaos/
|
|
47
|
+
"@nebulaos/google-gemini": "0.0.1",
|
|
48
|
+
"@nebulaos/openai": "0.1.0"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build": "tsc",
|