@a5c-ai/genty-runtime 5.1.1-staging.0007199a1cb2
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/README.md +69 -0
- package/dist/apiResult.d.ts +19 -0
- package/dist/apiResult.d.ts.map +1 -0
- package/dist/apiResult.js +16 -0
- package/dist/background/state.d.ts +20 -0
- package/dist/background/state.d.ts.map +1 -0
- package/dist/background/state.js +52 -0
- package/dist/backgroundProcessRegistry.d.ts +124 -0
- package/dist/backgroundProcessRegistry.d.ts.map +1 -0
- package/dist/backgroundProcessRegistry.js +427 -0
- package/dist/cost/claudeCodeParser.d.ts +81 -0
- package/dist/cost/claudeCodeParser.d.ts.map +1 -0
- package/dist/cost/claudeCodeParser.js +232 -0
- package/dist/cost/collector.d.ts +42 -0
- package/dist/cost/collector.d.ts.map +1 -0
- package/dist/cost/collector.js +105 -0
- package/dist/cost/effectCost.d.ts +23 -0
- package/dist/cost/effectCost.d.ts.map +1 -0
- package/dist/cost/effectCost.js +26 -0
- package/dist/cost/index.d.ts +19 -0
- package/dist/cost/index.d.ts.map +1 -0
- package/dist/cost/index.js +39 -0
- package/dist/cost/journal.d.ts +40 -0
- package/dist/cost/journal.d.ts.map +1 -0
- package/dist/cost/journal.js +137 -0
- package/dist/cost/types.d.ts +164 -0
- package/dist/cost/types.d.ts.map +1 -0
- package/dist/cost/types.js +228 -0
- package/dist/daemon/automationExecutor.d.ts +16 -0
- package/dist/daemon/automationExecutor.d.ts.map +1 -0
- package/dist/daemon/automationExecutor.js +222 -0
- package/dist/daemon/config.d.ts +8 -0
- package/dist/daemon/config.d.ts.map +1 -0
- package/dist/daemon/config.js +245 -0
- package/dist/daemon/daemonLog.d.ts +30 -0
- package/dist/daemon/daemonLog.d.ts.map +1 -0
- package/dist/daemon/daemonLog.js +140 -0
- package/dist/daemon/durableQueue.d.ts +41 -0
- package/dist/daemon/durableQueue.d.ts.map +1 -0
- package/dist/daemon/durableQueue.js +183 -0
- package/dist/daemon/fileWatcher.d.ts +9 -0
- package/dist/daemon/fileWatcher.d.ts.map +1 -0
- package/dist/daemon/fileWatcher.js +144 -0
- package/dist/daemon/index.d.ts +15 -0
- package/dist/daemon/index.d.ts.map +1 -0
- package/dist/daemon/index.js +25 -0
- package/dist/daemon/lifecycle.d.ts +13 -0
- package/dist/daemon/lifecycle.d.ts.map +1 -0
- package/dist/daemon/lifecycle.js +320 -0
- package/dist/daemon/loop.d.ts +27 -0
- package/dist/daemon/loop.d.ts.map +1 -0
- package/dist/daemon/loop.js +387 -0
- package/dist/daemon/timerScheduler.d.ts +13 -0
- package/dist/daemon/timerScheduler.d.ts.map +1 -0
- package/dist/daemon/timerScheduler.js +212 -0
- package/dist/daemon/types.d.ts +122 -0
- package/dist/daemon/types.d.ts.map +1 -0
- package/dist/daemon/types.js +25 -0
- package/dist/daemon/webhookListener.d.ts +6 -0
- package/dist/daemon/webhookListener.d.ts.map +1 -0
- package/dist/daemon/webhookListener.js +132 -0
- package/dist/execution/index.d.ts +10 -0
- package/dist/execution/index.d.ts.map +1 -0
- package/dist/execution/index.js +20 -0
- package/dist/execution/modes/docker.d.ts +26 -0
- package/dist/execution/modes/docker.d.ts.map +1 -0
- package/dist/execution/modes/docker.js +183 -0
- package/dist/execution/modes/index.d.ts +10 -0
- package/dist/execution/modes/index.d.ts.map +1 -0
- package/dist/execution/modes/index.js +14 -0
- package/dist/execution/modes/kubernetes.d.ts +46 -0
- package/dist/execution/modes/kubernetes.d.ts.map +1 -0
- package/dist/execution/modes/kubernetes.js +334 -0
- package/dist/execution/modes/local.d.ts +23 -0
- package/dist/execution/modes/local.d.ts.map +1 -0
- package/dist/execution/modes/local.js +117 -0
- package/dist/execution/modes/ssh.d.ts +23 -0
- package/dist/execution/modes/ssh.d.ts.map +1 -0
- package/dist/execution/modes/ssh.js +144 -0
- package/dist/execution/policy.d.ts +15 -0
- package/dist/execution/policy.d.ts.map +1 -0
- package/dist/execution/policy.js +121 -0
- package/dist/execution/provider.d.ts +32 -0
- package/dist/execution/provider.d.ts.map +1 -0
- package/dist/execution/provider.js +90 -0
- package/dist/execution/types.d.ts +189 -0
- package/dist/execution/types.d.ts.map +1 -0
- package/dist/execution/types.js +9 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +44 -0
- package/dist/observability/diagnostics.d.ts +25 -0
- package/dist/observability/diagnostics.d.ts.map +1 -0
- package/dist/observability/diagnostics.js +98 -0
- package/dist/observability/health.d.ts +19 -0
- package/dist/observability/health.d.ts.map +1 -0
- package/dist/observability/health.js +145 -0
- package/dist/observability/index.d.ts +7 -0
- package/dist/observability/index.d.ts.map +1 -0
- package/dist/observability/index.js +25 -0
- package/dist/observability/runStatus.d.ts +44 -0
- package/dist/observability/runStatus.d.ts.map +1 -0
- package/dist/observability/runStatus.js +170 -0
- package/dist/observability/timeline.d.ts +11 -0
- package/dist/observability/timeline.d.ts.map +1 -0
- package/dist/observability/timeline.js +176 -0
- package/dist/observability/types.d.ts +65 -0
- package/dist/observability/types.d.ts.map +1 -0
- package/dist/observability/types.js +8 -0
- package/dist/observability/webhooks.d.ts +68 -0
- package/dist/observability/webhooks.d.ts.map +1 -0
- package/dist/observability/webhooks.js +132 -0
- package/dist/resources/budget-tracker.d.ts +56 -0
- package/dist/resources/budget-tracker.d.ts.map +1 -0
- package/dist/resources/budget-tracker.js +131 -0
- package/dist/resources/concurrency-guard.d.ts +55 -0
- package/dist/resources/concurrency-guard.d.ts.map +1 -0
- package/dist/resources/concurrency-guard.js +132 -0
- package/dist/resources/index.d.ts +12 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +20 -0
- package/dist/resources/manager.d.ts +52 -0
- package/dist/resources/manager.d.ts.map +1 -0
- package/dist/resources/manager.js +150 -0
- package/dist/resources/timeout-cascade.d.ts +56 -0
- package/dist/resources/timeout-cascade.d.ts.map +1 -0
- package/dist/resources/timeout-cascade.js +145 -0
- package/dist/resources/types.d.ts +130 -0
- package/dist/resources/types.d.ts.map +1 -0
- package/dist/resources/types.js +9 -0
- package/dist/rpc/index.d.ts +5 -0
- package/dist/rpc/index.d.ts.map +1 -0
- package/dist/rpc/index.js +7 -0
- package/dist/rpc/server.d.ts +13 -0
- package/dist/rpc/server.d.ts.map +1 -0
- package/dist/rpc/server.js +64 -0
- package/dist/rpc/server.test.d.ts +2 -0
- package/dist/rpc/server.test.d.ts.map +1 -0
- package/dist/rpc/server.test.js +35 -0
- package/dist/rpc/types.d.ts +23 -0
- package/dist/rpc/types.d.ts.map +1 -0
- package/dist/rpc/types.js +20 -0
- package/dist/session/context.d.ts +22 -0
- package/dist/session/context.d.ts.map +1 -0
- package/dist/session/context.js +113 -0
- package/dist/session/continuityState.d.ts +39 -0
- package/dist/session/continuityState.d.ts.map +1 -0
- package/dist/session/continuityState.js +164 -0
- package/dist/session/cost.d.ts +63 -0
- package/dist/session/cost.d.ts.map +1 -0
- package/dist/session/cost.js +194 -0
- package/dist/session/discovery.d.ts +24 -0
- package/dist/session/discovery.d.ts.map +1 -0
- package/dist/session/discovery.js +43 -0
- package/dist/session/export.d.ts +4 -0
- package/dist/session/export.d.ts.map +1 -0
- package/dist/session/export.js +56 -0
- package/dist/session/export.test.d.ts +2 -0
- package/dist/session/export.test.d.ts.map +1 -0
- package/dist/session/export.test.js +42 -0
- package/dist/session/history.d.ts +30 -0
- package/dist/session/history.d.ts.map +1 -0
- package/dist/session/history.js +143 -0
- package/dist/session/index.d.ts +20 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +78 -0
- package/dist/session/memoryExtraction.d.ts +65 -0
- package/dist/session/memoryExtraction.d.ts.map +1 -0
- package/dist/session/memoryExtraction.js +201 -0
- package/dist/session/parse.d.ts +45 -0
- package/dist/session/parse.d.ts.map +1 -0
- package/dist/session/parse.js +170 -0
- package/dist/session/persistence.d.ts +46 -0
- package/dist/session/persistence.d.ts.map +1 -0
- package/dist/session/persistence.js +180 -0
- package/dist/session/rewind.d.ts +45 -0
- package/dist/session/rewind.d.ts.map +1 -0
- package/dist/session/rewind.js +68 -0
- package/dist/session/rewind.test.d.ts +2 -0
- package/dist/session/rewind.test.d.ts.map +1 -0
- package/dist/session/rewind.test.js +96 -0
- package/dist/session/tree.d.ts +29 -0
- package/dist/session/tree.d.ts.map +1 -0
- package/dist/session/tree.js +115 -0
- package/dist/session/tree.test.d.ts +2 -0
- package/dist/session/tree.test.d.ts.map +1 -0
- package/dist/session/tree.test.js +75 -0
- package/dist/session/types.d.ts +267 -0
- package/dist/session/types.d.ts.map +1 -0
- package/dist/session/types.js +45 -0
- package/dist/session/write.d.ts +61 -0
- package/dist/session/write.d.ts.map +1 -0
- package/dist/session/write.js +213 -0
- package/dist/shellInvocation.d.ts +6 -0
- package/dist/shellInvocation.d.ts.map +1 -0
- package/dist/shellInvocation.js +8 -0
- package/dist/shellInvocation.test.d.ts +2 -0
- package/dist/shellInvocation.test.d.ts.map +1 -0
- package/dist/shellInvocation.test.js +18 -0
- package/dist/storage/journal.d.ts +17 -0
- package/dist/storage/journal.d.ts.map +1 -0
- package/dist/storage/journal.js +165 -0
- package/dist/storage/runFiles.d.ts +10 -0
- package/dist/storage/runFiles.d.ts.map +1 -0
- package/dist/storage/runFiles.js +54 -0
- package/dist/telemetry/audit-log.d.ts +56 -0
- package/dist/telemetry/audit-log.d.ts.map +1 -0
- package/dist/telemetry/audit-log.js +59 -0
- package/dist/telemetry/exporters.d.ts +35 -0
- package/dist/telemetry/exporters.d.ts.map +1 -0
- package/dist/telemetry/exporters.js +141 -0
- package/dist/telemetry/index.d.ts +12 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +25 -0
- package/dist/telemetry/provider.d.ts +57 -0
- package/dist/telemetry/provider.d.ts.map +1 -0
- package/dist/telemetry/provider.js +261 -0
- package/dist/telemetry/span-tree.d.ts +46 -0
- package/dist/telemetry/span-tree.d.ts.map +1 -0
- package/dist/telemetry/span-tree.js +93 -0
- package/dist/telemetry/traceContext.d.ts +10 -0
- package/dist/telemetry/traceContext.d.ts.map +1 -0
- package/dist/telemetry/traceContext.js +43 -0
- package/dist/telemetry/types.d.ts +109 -0
- package/dist/telemetry/types.d.ts.map +1 -0
- package/dist/telemetry/types.js +21 -0
- package/dist/types/sdk.d.ts +66 -0
- package/dist/types/sdk.d.ts.map +1 -0
- package/dist/types/sdk.js +9 -0
- package/dist/utils/ulid.d.ts +11 -0
- package/dist/utils/ulid.d.ts.map +1 -0
- package/dist/utils/ulid.js +62 -0
- package/package.json +137 -0
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* InMemoryTelemetryProvider — in-process telemetry backend for development,
|
|
4
|
+
* testing, and single-process agent runtimes.
|
|
5
|
+
*
|
|
6
|
+
* Stores spans in memory and supports flush/drain for export pipelines.
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.InMemoryTelemetryProvider = exports.HttpTelemetryExporter = exports.FileTelemetryExporter = void 0;
|
|
43
|
+
const node_crypto_1 = require("node:crypto");
|
|
44
|
+
const node_fs_1 = require("node:fs");
|
|
45
|
+
const path = __importStar(require("node:path"));
|
|
46
|
+
const types_1 = require("./types");
|
|
47
|
+
class FileTelemetryExporter {
|
|
48
|
+
filePath;
|
|
49
|
+
constructor(filePath) {
|
|
50
|
+
this.filePath = filePath;
|
|
51
|
+
}
|
|
52
|
+
async export(spans) {
|
|
53
|
+
if (spans.length === 0)
|
|
54
|
+
return { ok: true, exported: 0 };
|
|
55
|
+
await node_fs_1.promises.mkdir(path.dirname(this.filePath), { recursive: true });
|
|
56
|
+
const payload = spans.map((span) => JSON.stringify(redactSpan(span))).join("\n") + "\n";
|
|
57
|
+
await node_fs_1.promises.appendFile(this.filePath, payload, "utf-8");
|
|
58
|
+
return { ok: true, exported: spans.length };
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.FileTelemetryExporter = FileTelemetryExporter;
|
|
62
|
+
class HttpTelemetryExporter {
|
|
63
|
+
url;
|
|
64
|
+
send;
|
|
65
|
+
constructor(url, send = defaultHttpSend) {
|
|
66
|
+
this.url = url;
|
|
67
|
+
this.send = send;
|
|
68
|
+
}
|
|
69
|
+
async export(spans) {
|
|
70
|
+
if (spans.length === 0)
|
|
71
|
+
return { ok: true, exported: 0 };
|
|
72
|
+
await this.send(this.url, toOtlpPayload(spans.map(redactSpan)));
|
|
73
|
+
return { ok: true, exported: spans.length };
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.HttpTelemetryExporter = HttpTelemetryExporter;
|
|
77
|
+
function toReadonly(span) {
|
|
78
|
+
return {
|
|
79
|
+
...span,
|
|
80
|
+
attributes: { ...span.attributes },
|
|
81
|
+
events: span.events.map((event) => ({
|
|
82
|
+
...event,
|
|
83
|
+
attributes: event.attributes ? { ...event.attributes } : undefined,
|
|
84
|
+
})),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* In-memory telemetry provider that satisfies the TelemetryProvider interface.
|
|
89
|
+
*
|
|
90
|
+
* - `startSpan` creates a new span and tracks it as active.
|
|
91
|
+
* - `endSpan` marks a span as completed and moves it to the completed set.
|
|
92
|
+
* - `recordEvent` appends a discrete event to an active span.
|
|
93
|
+
* - `flush` returns all completed spans and clears the completed buffer.
|
|
94
|
+
* - `getActiveSpans` returns all currently open (un-ended) spans.
|
|
95
|
+
*/
|
|
96
|
+
class InMemoryTelemetryProvider {
|
|
97
|
+
/** Active (in-flight) spans keyed by spanId. */
|
|
98
|
+
active = new Map();
|
|
99
|
+
/** Completed spans awaiting flush. */
|
|
100
|
+
completed = [];
|
|
101
|
+
/** Maps spanId -> traceId so child spans inherit the parent's trace. */
|
|
102
|
+
traceIndex = new Map();
|
|
103
|
+
exporters;
|
|
104
|
+
constructor(options) {
|
|
105
|
+
this.exporters = options?.exporters ?? [];
|
|
106
|
+
}
|
|
107
|
+
async startSpan(name, optionsOrParentSpanId) {
|
|
108
|
+
const spanId = (0, node_crypto_1.randomUUID)();
|
|
109
|
+
const options = typeof optionsOrParentSpanId === "string"
|
|
110
|
+
? { parentSpanId: optionsOrParentSpanId }
|
|
111
|
+
: optionsOrParentSpanId;
|
|
112
|
+
const parentSpanId = options?.traceContext?.spanId ?? options?.parentSpanId;
|
|
113
|
+
let traceId;
|
|
114
|
+
if (options?.traceContext) {
|
|
115
|
+
traceId = options.traceContext.traceId;
|
|
116
|
+
}
|
|
117
|
+
else if (parentSpanId) {
|
|
118
|
+
// Inherit traceId from the parent span.
|
|
119
|
+
traceId = this.traceIndex.get(parentSpanId) ?? (0, node_crypto_1.randomUUID)();
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
traceId = (0, node_crypto_1.randomUUID)();
|
|
123
|
+
}
|
|
124
|
+
const span = {
|
|
125
|
+
name,
|
|
126
|
+
traceId,
|
|
127
|
+
spanId,
|
|
128
|
+
parentSpanId,
|
|
129
|
+
startTime: new Date().toISOString(),
|
|
130
|
+
status: types_1.TelemetrySpanStatus.Unset,
|
|
131
|
+
attributes: {
|
|
132
|
+
...options?.attributes,
|
|
133
|
+
...(options?.correlationId
|
|
134
|
+
? { "babysitter.correlation_id": options.correlationId }
|
|
135
|
+
: {}),
|
|
136
|
+
...(options?.traceContext?.correlationId && !options?.correlationId
|
|
137
|
+
? { "babysitter.correlation_id": options.traceContext.correlationId }
|
|
138
|
+
: {}),
|
|
139
|
+
},
|
|
140
|
+
events: [],
|
|
141
|
+
};
|
|
142
|
+
this.active.set(spanId, span);
|
|
143
|
+
this.traceIndex.set(spanId, traceId);
|
|
144
|
+
return toReadonly(span);
|
|
145
|
+
}
|
|
146
|
+
async endSpan(spanId, status) {
|
|
147
|
+
const span = this.active.get(spanId);
|
|
148
|
+
if (!span) {
|
|
149
|
+
return; // Silently ignore unknown/already-ended spans.
|
|
150
|
+
}
|
|
151
|
+
span.endTime = new Date().toISOString();
|
|
152
|
+
span.status = status ?? types_1.TelemetrySpanStatus.Ok;
|
|
153
|
+
this.active.delete(spanId);
|
|
154
|
+
this.completed.push(span);
|
|
155
|
+
}
|
|
156
|
+
async recordEvent(spanId, event) {
|
|
157
|
+
const span = this.active.get(spanId);
|
|
158
|
+
if (!span) {
|
|
159
|
+
return; // Silently ignore events on unknown/ended spans.
|
|
160
|
+
}
|
|
161
|
+
span.events.push(event);
|
|
162
|
+
}
|
|
163
|
+
async flush() {
|
|
164
|
+
const spans = this.completed.map(toReadonly);
|
|
165
|
+
for (const exporter of this.exporters) {
|
|
166
|
+
await exporter.export(spans);
|
|
167
|
+
}
|
|
168
|
+
this.completed.length = 0;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Drain completed spans — returns and clears the completed buffer.
|
|
172
|
+
*
|
|
173
|
+
* Unlike `flush()` (which satisfies the TelemetryProvider interface and
|
|
174
|
+
* returns void), this method hands the span data back to the caller.
|
|
175
|
+
*/
|
|
176
|
+
async drain() {
|
|
177
|
+
return this.completed.splice(0).map(toReadonly);
|
|
178
|
+
}
|
|
179
|
+
// ---------- Extra helpers (not on interface) ----------
|
|
180
|
+
/** Return a snapshot of all currently open (un-ended) spans. */
|
|
181
|
+
getActiveSpans() {
|
|
182
|
+
return [...this.active.values()].map(toReadonly);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
exports.InMemoryTelemetryProvider = InMemoryTelemetryProvider;
|
|
186
|
+
function redactSpan(span) {
|
|
187
|
+
return {
|
|
188
|
+
...span,
|
|
189
|
+
attributes: redactAttributes(span.attributes),
|
|
190
|
+
events: span.events.map((event) => ({
|
|
191
|
+
...event,
|
|
192
|
+
attributes: event.attributes ? redactAttributes(event.attributes) : undefined,
|
|
193
|
+
})),
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
function redactAttributes(attributes) {
|
|
197
|
+
return Object.fromEntries(Object.entries(attributes).map(([key, value]) => [
|
|
198
|
+
key,
|
|
199
|
+
isSecretKey(key) || (typeof value === "string" && looksSecretValue(value))
|
|
200
|
+
? "[REDACTED]"
|
|
201
|
+
: value,
|
|
202
|
+
]));
|
|
203
|
+
}
|
|
204
|
+
function isSecretKey(key) {
|
|
205
|
+
return /(token|secret|password|api[_-]?key|authorization|credential)/i.test(key);
|
|
206
|
+
}
|
|
207
|
+
function looksSecretValue(value) {
|
|
208
|
+
return /(bearer\s+\S+|token=\S+|password=\S+|secret=\S+)/i.test(value);
|
|
209
|
+
}
|
|
210
|
+
function toOtlpPayload(spans) {
|
|
211
|
+
return {
|
|
212
|
+
resourceSpans: [
|
|
213
|
+
{
|
|
214
|
+
resource: { attributes: [] },
|
|
215
|
+
scopeSpans: [
|
|
216
|
+
{
|
|
217
|
+
scope: { name: "@a5c-ai/genty-runtime" },
|
|
218
|
+
spans: spans.map((span) => ({
|
|
219
|
+
traceId: span.traceId,
|
|
220
|
+
spanId: span.spanId,
|
|
221
|
+
parentSpanId: span.parentSpanId,
|
|
222
|
+
name: span.name,
|
|
223
|
+
startTimeUnixNano: isoToUnixNano(span.startTime),
|
|
224
|
+
endTimeUnixNano: span.endTime ? isoToUnixNano(span.endTime) : undefined,
|
|
225
|
+
status: { code: span.status },
|
|
226
|
+
attributes: toOtlpAttributes(span.attributes),
|
|
227
|
+
events: span.events.map((event) => ({
|
|
228
|
+
name: event.name,
|
|
229
|
+
timeUnixNano: isoToUnixNano(event.timestamp),
|
|
230
|
+
attributes: event.attributes ? toOtlpAttributes(event.attributes) : [],
|
|
231
|
+
})),
|
|
232
|
+
})),
|
|
233
|
+
},
|
|
234
|
+
],
|
|
235
|
+
},
|
|
236
|
+
],
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
function toOtlpAttributes(attributes) {
|
|
240
|
+
return Object.entries(attributes).map(([key, value]) => ({
|
|
241
|
+
key,
|
|
242
|
+
value: typeof value === "string"
|
|
243
|
+
? { stringValue: value }
|
|
244
|
+
: typeof value === "number"
|
|
245
|
+
? { doubleValue: value }
|
|
246
|
+
: { boolValue: value },
|
|
247
|
+
}));
|
|
248
|
+
}
|
|
249
|
+
function isoToUnixNano(value) {
|
|
250
|
+
return String(BigInt(new Date(value).getTime()) * 1000000n);
|
|
251
|
+
}
|
|
252
|
+
async function defaultHttpSend(url, payload) {
|
|
253
|
+
const response = await fetch(url, {
|
|
254
|
+
method: "POST",
|
|
255
|
+
headers: { "content-type": "application/json" },
|
|
256
|
+
body: JSON.stringify(payload),
|
|
257
|
+
});
|
|
258
|
+
if (!response.ok) {
|
|
259
|
+
throw new Error(`Telemetry export failed with HTTP ${response.status}`);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SpanTree — builds a parent/child tree from a flat list of TelemetrySpans.
|
|
3
|
+
*
|
|
4
|
+
* Useful for rendering trace waterfalls, computing subtree durations, and
|
|
5
|
+
* serializing trace hierarchies to JSON for the observer UI.
|
|
6
|
+
*/
|
|
7
|
+
import type { TelemetrySpan } from "./types";
|
|
8
|
+
/** A tree node wrapping a span with its children. */
|
|
9
|
+
export interface SpanTreeNode {
|
|
10
|
+
readonly span: TelemetrySpan;
|
|
11
|
+
readonly children: SpanTreeNode[];
|
|
12
|
+
}
|
|
13
|
+
/** Serializable representation of a SpanTreeNode. */
|
|
14
|
+
export interface SerializedSpanTreeNode {
|
|
15
|
+
readonly spanId: string;
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly traceId: string;
|
|
18
|
+
readonly parentSpanId?: string;
|
|
19
|
+
readonly startTime: string;
|
|
20
|
+
readonly endTime?: string;
|
|
21
|
+
readonly status: string;
|
|
22
|
+
readonly attributes: Record<string, string | number | boolean>;
|
|
23
|
+
readonly events: Array<{
|
|
24
|
+
readonly name: string;
|
|
25
|
+
readonly timestamp: string;
|
|
26
|
+
readonly attributes?: Record<string, string | number | boolean>;
|
|
27
|
+
}>;
|
|
28
|
+
readonly children: SerializedSpanTreeNode[];
|
|
29
|
+
}
|
|
30
|
+
/** Tree built from a flat span list. */
|
|
31
|
+
export declare class SpanTree {
|
|
32
|
+
/** All nodes keyed by spanId for O(1) lookup. */
|
|
33
|
+
private readonly nodes;
|
|
34
|
+
/** Root node ids (spans with no parent or whose parent is unknown). */
|
|
35
|
+
private readonly rootIds;
|
|
36
|
+
/** Insert a span into the tree, linking it to its parent if present. */
|
|
37
|
+
addSpan(span: TelemetrySpan): void;
|
|
38
|
+
/** Get direct children of a span. */
|
|
39
|
+
getChildren(spanId: string): TelemetrySpan[];
|
|
40
|
+
/** Get top-level spans (those with no parent). */
|
|
41
|
+
getRoots(): TelemetrySpan[];
|
|
42
|
+
/** Serialize the full tree to a JSON-safe structure. */
|
|
43
|
+
toJSON(): SerializedSpanTreeNode[];
|
|
44
|
+
private serializeNode;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=span-tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"span-tree.d.ts","sourceRoot":"","sources":["../../src/telemetry/span-tree.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAM7C,qDAAqD;AACrD,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,YAAY,EAAE,CAAC;CACnC;AAED,qDAAqD;AACrD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;IAC/D,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC;QACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;QAC3B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;KACjE,CAAC,CAAC;IACH,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,EAAE,CAAC;CAC7C;AAMD,wCAAwC;AACxC,qBAAa,QAAQ;IACnB,iDAAiD;IACjD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAmC;IACzD,uEAAuE;IACvE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;IAExC,wEAAwE;IACxE,OAAO,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI;IAgClC,qCAAqC;IACrC,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,EAAE;IAM5C,kDAAkD;IAClD,QAAQ,IAAI,aAAa,EAAE;IAO3B,wDAAwD;IACxD,MAAM,IAAI,sBAAsB,EAAE;IAOlC,OAAO,CAAC,aAAa;CAmBtB"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* SpanTree — builds a parent/child tree from a flat list of TelemetrySpans.
|
|
4
|
+
*
|
|
5
|
+
* Useful for rendering trace waterfalls, computing subtree durations, and
|
|
6
|
+
* serializing trace hierarchies to JSON for the observer UI.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.SpanTree = void 0;
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
// Implementation
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
/** Tree built from a flat span list. */
|
|
14
|
+
class SpanTree {
|
|
15
|
+
/** All nodes keyed by spanId for O(1) lookup. */
|
|
16
|
+
nodes = new Map();
|
|
17
|
+
/** Root node ids (spans with no parent or whose parent is unknown). */
|
|
18
|
+
rootIds = [];
|
|
19
|
+
/** Insert a span into the tree, linking it to its parent if present. */
|
|
20
|
+
addSpan(span) {
|
|
21
|
+
// Create or retrieve the node for this span.
|
|
22
|
+
let node = this.nodes.get(span.spanId);
|
|
23
|
+
if (node) {
|
|
24
|
+
// Node was pre-created as a placeholder by a child — update the span.
|
|
25
|
+
node.span = span;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
node = { span, children: [] };
|
|
29
|
+
this.nodes.set(span.spanId, node);
|
|
30
|
+
}
|
|
31
|
+
if (span.parentSpanId) {
|
|
32
|
+
let parentNode = this.nodes.get(span.parentSpanId);
|
|
33
|
+
if (!parentNode) {
|
|
34
|
+
// Parent hasn't been added yet — create a placeholder.
|
|
35
|
+
parentNode = {
|
|
36
|
+
span: undefined,
|
|
37
|
+
children: [],
|
|
38
|
+
};
|
|
39
|
+
this.nodes.set(span.parentSpanId, parentNode);
|
|
40
|
+
}
|
|
41
|
+
// Avoid duplicate children on re-add.
|
|
42
|
+
if (!parentNode.children.some((c) => c.span?.spanId === span.spanId)) {
|
|
43
|
+
parentNode.children.push(node);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
if (!this.rootIds.includes(span.spanId)) {
|
|
48
|
+
this.rootIds.push(span.spanId);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/** Get direct children of a span. */
|
|
53
|
+
getChildren(spanId) {
|
|
54
|
+
const node = this.nodes.get(spanId);
|
|
55
|
+
if (!node)
|
|
56
|
+
return [];
|
|
57
|
+
return node.children.map((c) => c.span);
|
|
58
|
+
}
|
|
59
|
+
/** Get top-level spans (those with no parent). */
|
|
60
|
+
getRoots() {
|
|
61
|
+
return this.rootIds
|
|
62
|
+
.map((id) => this.nodes.get(id))
|
|
63
|
+
.filter((n) => n != null && n.span != null)
|
|
64
|
+
.map((n) => n.span);
|
|
65
|
+
}
|
|
66
|
+
/** Serialize the full tree to a JSON-safe structure. */
|
|
67
|
+
toJSON() {
|
|
68
|
+
return this.getRoots()
|
|
69
|
+
.map((root) => this.nodes.get(root.spanId))
|
|
70
|
+
.filter((n) => n != null)
|
|
71
|
+
.map((n) => this.serializeNode(n));
|
|
72
|
+
}
|
|
73
|
+
serializeNode(node) {
|
|
74
|
+
const { span } = node;
|
|
75
|
+
return {
|
|
76
|
+
spanId: span.spanId,
|
|
77
|
+
name: span.name,
|
|
78
|
+
traceId: span.traceId,
|
|
79
|
+
parentSpanId: span.parentSpanId,
|
|
80
|
+
startTime: span.startTime,
|
|
81
|
+
endTime: span.endTime,
|
|
82
|
+
status: span.status,
|
|
83
|
+
attributes: { ...span.attributes },
|
|
84
|
+
events: span.events.map((e) => ({
|
|
85
|
+
name: e.name,
|
|
86
|
+
timestamp: e.timestamp,
|
|
87
|
+
...(e.attributes ? { attributes: { ...e.attributes } } : {}),
|
|
88
|
+
})),
|
|
89
|
+
children: node.children.map((c) => this.serializeNode(c)),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.SpanTree = SpanTree;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TraceContext } from "./types";
|
|
2
|
+
export declare function parseTraceParent(header: string): TraceContext | null;
|
|
3
|
+
export declare function serializeTraceParent(context: TraceContext): string;
|
|
4
|
+
export interface CreateTraceContextOptions {
|
|
5
|
+
parent?: TraceContext;
|
|
6
|
+
correlationId?: string;
|
|
7
|
+
sampled?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function createTraceContext(options?: CreateTraceContextOptions): TraceContext;
|
|
10
|
+
//# sourceMappingURL=traceContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traceContext.d.ts","sourceRoot":"","sources":["../../src/telemetry/traceContext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAQ5C,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAQpE;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,CAElE;AAED,MAAM,WAAW,yBAAyB;IACxC,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE,yBAAyB,GAAG,YAAY,CAYpF"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseTraceParent = parseTraceParent;
|
|
4
|
+
exports.serializeTraceParent = serializeTraceParent;
|
|
5
|
+
exports.createTraceContext = createTraceContext;
|
|
6
|
+
const node_crypto_1 = require("node:crypto");
|
|
7
|
+
const TRACEPARENT_PATTERN = /^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})$/;
|
|
8
|
+
function allZero(value) {
|
|
9
|
+
return /^0+$/.test(value);
|
|
10
|
+
}
|
|
11
|
+
function parseTraceParent(header) {
|
|
12
|
+
const match = TRACEPARENT_PATTERN.exec(header.trim());
|
|
13
|
+
if (!match)
|
|
14
|
+
return null;
|
|
15
|
+
const [, version, traceId, spanId, traceFlags] = match;
|
|
16
|
+
if (version !== "00" || allZero(traceId) || allZero(spanId)) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return { version, traceId, spanId, traceFlags };
|
|
20
|
+
}
|
|
21
|
+
function serializeTraceParent(context) {
|
|
22
|
+
return `${context.version}-${context.traceId}-${context.spanId}-${context.traceFlags}`;
|
|
23
|
+
}
|
|
24
|
+
function createTraceContext(options) {
|
|
25
|
+
const traceId = options?.parent?.traceId ?? randomHex(16);
|
|
26
|
+
const spanId = randomHex(8);
|
|
27
|
+
const traceFlags = options?.sampled === false ? "00" : options?.parent?.traceFlags ?? "01";
|
|
28
|
+
return {
|
|
29
|
+
version: "00",
|
|
30
|
+
traceId,
|
|
31
|
+
spanId,
|
|
32
|
+
traceFlags,
|
|
33
|
+
parentSpanId: options?.parent?.spanId,
|
|
34
|
+
correlationId: options?.correlationId ?? options?.parent?.correlationId,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function randomHex(bytes) {
|
|
38
|
+
let value = (0, node_crypto_1.randomBytes)(bytes).toString("hex");
|
|
39
|
+
while (allZero(value)) {
|
|
40
|
+
value = (0, node_crypto_1.randomBytes)(bytes).toString("hex");
|
|
41
|
+
}
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenTelemetry-aligned structured telemetry interfaces for Babysitter Agent Runtime.
|
|
3
|
+
*
|
|
4
|
+
* These are interface-only type stubs — implementations will follow in issue #217.
|
|
5
|
+
*/
|
|
6
|
+
/** Status of a telemetry span, aligned with OpenTelemetry StatusCode. */
|
|
7
|
+
export declare enum TelemetrySpanStatus {
|
|
8
|
+
/** The span completed without error. */
|
|
9
|
+
Ok = "Ok",
|
|
10
|
+
/** The span ended with an error. */
|
|
11
|
+
Error = "Error",
|
|
12
|
+
/** Status has not been explicitly set (default). */
|
|
13
|
+
Unset = "Unset"
|
|
14
|
+
}
|
|
15
|
+
/** A discrete event recorded within a span. */
|
|
16
|
+
export interface TelemetryEvent {
|
|
17
|
+
/** Human-readable event name. */
|
|
18
|
+
readonly name: string;
|
|
19
|
+
/** ISO-8601 timestamp of when the event occurred. */
|
|
20
|
+
readonly timestamp: string;
|
|
21
|
+
/** Optional key-value attributes attached to the event. */
|
|
22
|
+
readonly attributes?: Record<string, string | number | boolean>;
|
|
23
|
+
}
|
|
24
|
+
/** A unit of work within a trace, aligned with the OpenTelemetry Span model. */
|
|
25
|
+
export interface TelemetrySpan {
|
|
26
|
+
/** Human-readable span name. */
|
|
27
|
+
readonly name: string;
|
|
28
|
+
/** Trace identifier shared across the entire distributed trace. */
|
|
29
|
+
readonly traceId: string;
|
|
30
|
+
/** Unique identifier for this span within the trace. */
|
|
31
|
+
readonly spanId: string;
|
|
32
|
+
/** Span ID of the parent span, if this is a child span. */
|
|
33
|
+
readonly parentSpanId?: string;
|
|
34
|
+
/** ISO-8601 timestamp when the span started. */
|
|
35
|
+
readonly startTime: string;
|
|
36
|
+
/** ISO-8601 timestamp when the span ended; undefined while in-flight. */
|
|
37
|
+
readonly endTime?: string;
|
|
38
|
+
/** Terminal status of the span. */
|
|
39
|
+
readonly status: TelemetrySpanStatus;
|
|
40
|
+
/** Key-value attributes attached to the span. */
|
|
41
|
+
readonly attributes: Record<string, string | number | boolean>;
|
|
42
|
+
/** Discrete events recorded during the span's lifetime. */
|
|
43
|
+
readonly events: TelemetryEvent[];
|
|
44
|
+
}
|
|
45
|
+
export interface TraceContext {
|
|
46
|
+
readonly version: "00";
|
|
47
|
+
readonly traceId: string;
|
|
48
|
+
readonly spanId: string;
|
|
49
|
+
readonly traceFlags: string;
|
|
50
|
+
readonly parentSpanId?: string;
|
|
51
|
+
readonly correlationId?: string;
|
|
52
|
+
}
|
|
53
|
+
export interface TelemetrySpanStartOptions {
|
|
54
|
+
readonly parentSpanId?: string;
|
|
55
|
+
readonly traceContext?: TraceContext;
|
|
56
|
+
readonly correlationId?: string;
|
|
57
|
+
readonly attributes?: Record<string, string | number | boolean>;
|
|
58
|
+
}
|
|
59
|
+
/** Abstraction over a telemetry backend (e.g. OTLP exporter, console, no-op). */
|
|
60
|
+
export interface TelemetryProvider {
|
|
61
|
+
/**
|
|
62
|
+
* Begin a new span.
|
|
63
|
+
*
|
|
64
|
+
* @param name - Human-readable span name.
|
|
65
|
+
* @param parentSpanId - Optional parent span to nest under.
|
|
66
|
+
* @returns The newly created span.
|
|
67
|
+
*/
|
|
68
|
+
startSpan(name: string, parentSpanId?: string): Promise<TelemetrySpan>;
|
|
69
|
+
startSpan(name: string, options?: TelemetrySpanStartOptions): Promise<TelemetrySpan>;
|
|
70
|
+
/**
|
|
71
|
+
* End an in-flight span.
|
|
72
|
+
*
|
|
73
|
+
* @param spanId - ID of the span to end.
|
|
74
|
+
* @param status - Terminal status; defaults to `Ok` if omitted.
|
|
75
|
+
*/
|
|
76
|
+
endSpan(spanId: string, status?: TelemetrySpanStatus): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Record a discrete event on an active span.
|
|
79
|
+
*
|
|
80
|
+
* @param spanId - ID of the span to attach the event to.
|
|
81
|
+
* @param event - The event payload.
|
|
82
|
+
*/
|
|
83
|
+
recordEvent(spanId: string, event: TelemetryEvent): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Flush any buffered telemetry data to the configured exporters.
|
|
86
|
+
*/
|
|
87
|
+
flush(): Promise<void>;
|
|
88
|
+
}
|
|
89
|
+
/** Configuration for the telemetry subsystem. */
|
|
90
|
+
export interface TelemetryConfig {
|
|
91
|
+
/** Whether telemetry collection is enabled. */
|
|
92
|
+
readonly enabled: boolean;
|
|
93
|
+
/** Provider implementation to use; when absent a no-op provider is assumed. */
|
|
94
|
+
readonly provider?: TelemetryProvider;
|
|
95
|
+
/** Sampling rate between 0 (none) and 1 (all traces). */
|
|
96
|
+
readonly sampleRate?: number;
|
|
97
|
+
/** Named exporters to send telemetry data to (e.g. "otlp", "console", "file"). */
|
|
98
|
+
readonly exporters?: string[];
|
|
99
|
+
}
|
|
100
|
+
export interface TelemetryExportResult {
|
|
101
|
+
readonly ok: boolean;
|
|
102
|
+
readonly exported: number;
|
|
103
|
+
readonly error?: string;
|
|
104
|
+
}
|
|
105
|
+
export interface TelemetryExporter {
|
|
106
|
+
export(spans: readonly TelemetrySpan[]): Promise<TelemetryExportResult>;
|
|
107
|
+
flush?(): Promise<TelemetryExportResult>;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/telemetry/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,yEAAyE;AAC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CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACxE,KAAK,CAAC,IAAI,OAAO,CAAC,qBAAqB,CAAC,CAAC;CAC1C"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* OpenTelemetry-aligned structured telemetry interfaces for Babysitter Agent Runtime.
|
|
4
|
+
*
|
|
5
|
+
* These are interface-only type stubs — implementations will follow in issue #217.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.TelemetrySpanStatus = void 0;
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
// Span Status
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
/** Status of a telemetry span, aligned with OpenTelemetry StatusCode. */
|
|
13
|
+
var TelemetrySpanStatus;
|
|
14
|
+
(function (TelemetrySpanStatus) {
|
|
15
|
+
/** The span completed without error. */
|
|
16
|
+
TelemetrySpanStatus["Ok"] = "Ok";
|
|
17
|
+
/** The span ended with an error. */
|
|
18
|
+
TelemetrySpanStatus["Error"] = "Error";
|
|
19
|
+
/** Status has not been explicitly set (default). */
|
|
20
|
+
TelemetrySpanStatus["Unset"] = "Unset";
|
|
21
|
+
})(TelemetrySpanStatus || (exports.TelemetrySpanStatus = TelemetrySpanStatus = {}));
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Locally-defined types that mirror the SDK storage/runtime types needed
|
|
3
|
+
* by genty-runtime modules.
|
|
4
|
+
*
|
|
5
|
+
* These replace direct `@a5c-ai/babysitter-sdk` type imports so the runtime
|
|
6
|
+
* package does not depend on SDK type definitions at compile time.
|
|
7
|
+
*/
|
|
8
|
+
/** A JSON-serialisable record. */
|
|
9
|
+
export type JsonRecord = Record<string, unknown>;
|
|
10
|
+
export interface JournalEvent {
|
|
11
|
+
seq: number;
|
|
12
|
+
ulid: string;
|
|
13
|
+
filename: string;
|
|
14
|
+
path: string;
|
|
15
|
+
type: string;
|
|
16
|
+
recordedAt: string;
|
|
17
|
+
sdkVersion?: string;
|
|
18
|
+
data: JsonRecord;
|
|
19
|
+
checksum?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface AppendEventOptions {
|
|
22
|
+
runDir: string;
|
|
23
|
+
event: JsonRecord;
|
|
24
|
+
eventType: string;
|
|
25
|
+
}
|
|
26
|
+
export interface AppendEventResult {
|
|
27
|
+
seq: number;
|
|
28
|
+
ulid: string;
|
|
29
|
+
filename: string;
|
|
30
|
+
checksum: string;
|
|
31
|
+
path: string;
|
|
32
|
+
recordedAt: string;
|
|
33
|
+
}
|
|
34
|
+
export interface RunEntrypointMetadata {
|
|
35
|
+
importPath: string;
|
|
36
|
+
exportName?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface RunMetadata extends JsonRecord {
|
|
39
|
+
runId: string;
|
|
40
|
+
request: string;
|
|
41
|
+
processId: string;
|
|
42
|
+
sdkVersion?: string;
|
|
43
|
+
harness?: string;
|
|
44
|
+
entrypoint: RunEntrypointMetadata;
|
|
45
|
+
processPath?: string;
|
|
46
|
+
processRevision?: string;
|
|
47
|
+
layoutVersion: string;
|
|
48
|
+
createdAt: string;
|
|
49
|
+
prompt?: string;
|
|
50
|
+
}
|
|
51
|
+
/** Index over all effects in a run, queryable by effectId. */
|
|
52
|
+
export interface EffectIndex {
|
|
53
|
+
listEffects(): Array<{
|
|
54
|
+
effectId: string;
|
|
55
|
+
taskId: string;
|
|
56
|
+
kind?: string;
|
|
57
|
+
status?: string;
|
|
58
|
+
inputTokens?: number;
|
|
59
|
+
outputTokens?: number;
|
|
60
|
+
cacheCreationInputTokens?: number;
|
|
61
|
+
cacheReadInputTokens?: number;
|
|
62
|
+
costUsd?: number;
|
|
63
|
+
costModel?: string;
|
|
64
|
+
}>;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=sdk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/types/sdk.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,kCAAkC;AAClC,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAIjD,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,UAAU,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB;AAID,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,WAAY,SAAQ,UAAU;IAC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