@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,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Local journal read/write utilities for genty-runtime.
|
|
4
|
+
*
|
|
5
|
+
* These are genty-owned implementations that replicate the subset of SDK
|
|
6
|
+
* storage functions needed by runtime modules (observability, cost tracking).
|
|
7
|
+
* They operate on the same on-disk layout as the SDK journal but do not
|
|
8
|
+
* import from @a5c-ai/babysitter-sdk.
|
|
9
|
+
*/
|
|
10
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(o, k2, desc);
|
|
17
|
+
}) : (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
o[k2] = m[k];
|
|
20
|
+
}));
|
|
21
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
22
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
23
|
+
}) : function(o, v) {
|
|
24
|
+
o["default"] = v;
|
|
25
|
+
});
|
|
26
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
27
|
+
var ownKeys = function(o) {
|
|
28
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
29
|
+
var ar = [];
|
|
30
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
31
|
+
return ar;
|
|
32
|
+
};
|
|
33
|
+
return ownKeys(o);
|
|
34
|
+
};
|
|
35
|
+
return function (mod) {
|
|
36
|
+
if (mod && mod.__esModule) return mod;
|
|
37
|
+
var result = {};
|
|
38
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
39
|
+
__setModuleDefault(result, mod);
|
|
40
|
+
return result;
|
|
41
|
+
};
|
|
42
|
+
})();
|
|
43
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
+
exports.appendEvent = appendEvent;
|
|
45
|
+
exports.loadJournal = loadJournal;
|
|
46
|
+
const node_fs_1 = require("node:fs");
|
|
47
|
+
const path = __importStar(require("node:path"));
|
|
48
|
+
const crypto = __importStar(require("node:crypto"));
|
|
49
|
+
const ulid_1 = require("../utils/ulid");
|
|
50
|
+
// ── Constants ────────────────────────────────────────────────────────────
|
|
51
|
+
const JOURNAL_DIR = "journal";
|
|
52
|
+
const RUN_METADATA_FILE = "run.json";
|
|
53
|
+
function getJournalDir(runDir) {
|
|
54
|
+
return path.join(runDir, JOURNAL_DIR);
|
|
55
|
+
}
|
|
56
|
+
function formatSeq(seq) {
|
|
57
|
+
return seq.toString().padStart(6, "0");
|
|
58
|
+
}
|
|
59
|
+
// ── Serialised append queue (prevents concurrent writes to the same run) ─
|
|
60
|
+
const appendQueues = new Map();
|
|
61
|
+
async function withAppendQueue(runDir, op) {
|
|
62
|
+
const key = path.resolve(runDir);
|
|
63
|
+
const prev = appendQueues.get(key) ?? Promise.resolve();
|
|
64
|
+
const next = prev
|
|
65
|
+
.catch(() => {
|
|
66
|
+
/* swallow previous failure so queue keeps moving */
|
|
67
|
+
})
|
|
68
|
+
.then(op);
|
|
69
|
+
const tail = next.then(() => undefined, () => undefined);
|
|
70
|
+
appendQueues.set(key, tail);
|
|
71
|
+
try {
|
|
72
|
+
return await next;
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
if (appendQueues.get(key) === tail) {
|
|
76
|
+
appendQueues.delete(key);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// ── Write ────────────────────────────────────────────────────────────────
|
|
81
|
+
async function getExistingSeqs(journalDir) {
|
|
82
|
+
try {
|
|
83
|
+
const entries = await node_fs_1.promises.readdir(journalDir);
|
|
84
|
+
return entries
|
|
85
|
+
.map((name) => Number(name.split(".")[0]))
|
|
86
|
+
.filter((n) => Number.isFinite(n));
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
const err = error;
|
|
90
|
+
if (err.code === "ENOENT")
|
|
91
|
+
return [];
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async function appendEvent(opts) {
|
|
96
|
+
return withAppendQueue(opts.runDir, async () => {
|
|
97
|
+
const journalDir = getJournalDir(opts.runDir);
|
|
98
|
+
await node_fs_1.promises.mkdir(journalDir, { recursive: true });
|
|
99
|
+
const seqs = await getExistingSeqs(journalDir);
|
|
100
|
+
const seq = (seqs.length ? Math.max(...seqs) : 0) + 1;
|
|
101
|
+
const ulid = (0, ulid_1.nextUlid)();
|
|
102
|
+
const filename = `${formatSeq(seq)}.${ulid}.json`;
|
|
103
|
+
const recordedAt = new Date().toISOString();
|
|
104
|
+
const eventPayload = {
|
|
105
|
+
type: opts.eventType,
|
|
106
|
+
recordedAt,
|
|
107
|
+
data: opts.event,
|
|
108
|
+
};
|
|
109
|
+
const contents = JSON.stringify(eventPayload, null, 2) + "\n";
|
|
110
|
+
const checksum = crypto.createHash("sha256").update(contents).digest("hex");
|
|
111
|
+
const payloadWithChecksum = JSON.stringify({ ...eventPayload, checksum }, null, 2) + "\n";
|
|
112
|
+
const targetPath = path.join(journalDir, filename);
|
|
113
|
+
await node_fs_1.promises.writeFile(targetPath, payloadWithChecksum, "utf8");
|
|
114
|
+
return { seq, ulid, filename, checksum, path: targetPath, recordedAt };
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
// ── Read ─────────────────────────────────────────────────────────────────
|
|
118
|
+
function parseJournalFilename(filename) {
|
|
119
|
+
const [seqPart, ulidPart] = filename.replace(/\.json$/i, "").split(".");
|
|
120
|
+
const seq = Number(seqPart);
|
|
121
|
+
if (!Number.isFinite(seq) || !ulidPart) {
|
|
122
|
+
throw new Error(`Invalid journal filename: ${filename}`);
|
|
123
|
+
}
|
|
124
|
+
return { seq, ulid: ulidPart };
|
|
125
|
+
}
|
|
126
|
+
async function loadJournal(runDir) {
|
|
127
|
+
const journalDir = getJournalDir(runDir);
|
|
128
|
+
try {
|
|
129
|
+
const entries = await node_fs_1.promises.readdir(journalDir);
|
|
130
|
+
const sorted = entries.filter((name) => name.endsWith(".json")).sort();
|
|
131
|
+
const events = [];
|
|
132
|
+
for (const file of sorted) {
|
|
133
|
+
const { seq, ulid } = parseJournalFilename(file);
|
|
134
|
+
const fullPath = path.join(journalDir, file);
|
|
135
|
+
const contents = await node_fs_1.promises.readFile(fullPath, "utf8");
|
|
136
|
+
let raw;
|
|
137
|
+
try {
|
|
138
|
+
raw = JSON.parse(contents);
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
const parseError = new Error(`Failed to parse journal file ${fullPath}: ${error.message}`);
|
|
142
|
+
parseError.code = "JOURNAL_PARSE_FAILED";
|
|
143
|
+
throw parseError;
|
|
144
|
+
}
|
|
145
|
+
events.push({
|
|
146
|
+
seq,
|
|
147
|
+
ulid,
|
|
148
|
+
filename: file,
|
|
149
|
+
path: fullPath,
|
|
150
|
+
type: raw.type ?? "UNKNOWN",
|
|
151
|
+
recordedAt: typeof raw.recordedAt === "string" ? raw.recordedAt : new Date().toISOString(),
|
|
152
|
+
sdkVersion: typeof raw.sdkVersion === "string" ? raw.sdkVersion : undefined,
|
|
153
|
+
data: raw.data ?? {},
|
|
154
|
+
checksum: typeof raw.checksum === "string" ? raw.checksum : undefined,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
return events;
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
const err = error;
|
|
161
|
+
if (err.code === "ENOENT")
|
|
162
|
+
return [];
|
|
163
|
+
throw error;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local run-file utilities for genty-runtime.
|
|
3
|
+
*
|
|
4
|
+
* Reads run metadata from the standard on-disk layout without importing
|
|
5
|
+
* from @a5c-ai/babysitter-sdk.
|
|
6
|
+
*/
|
|
7
|
+
import type { RunMetadata } from "../types/sdk";
|
|
8
|
+
export declare function readRunMetadata(runDir: string): Promise<RunMetadata>;
|
|
9
|
+
export declare function getRunDir(runsRoot: string, runId: string): string;
|
|
10
|
+
//# sourceMappingURL=runFiles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runFiles.d.ts","sourceRoot":"","sources":["../../src/storage/runFiles.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAIhD,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAI1E;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAEjE"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Local run-file utilities for genty-runtime.
|
|
4
|
+
*
|
|
5
|
+
* Reads run metadata from the standard on-disk layout without importing
|
|
6
|
+
* from @a5c-ai/babysitter-sdk.
|
|
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.readRunMetadata = readRunMetadata;
|
|
43
|
+
exports.getRunDir = getRunDir;
|
|
44
|
+
const node_fs_1 = require("node:fs");
|
|
45
|
+
const path = __importStar(require("node:path"));
|
|
46
|
+
const RUN_METADATA_FILE = "run.json";
|
|
47
|
+
async function readRunMetadata(runDir) {
|
|
48
|
+
const metadataPath = path.join(runDir, RUN_METADATA_FILE);
|
|
49
|
+
const raw = await node_fs_1.promises.readFile(metadataPath, "utf8");
|
|
50
|
+
return JSON.parse(raw);
|
|
51
|
+
}
|
|
52
|
+
function getRunDir(runsRoot, runId) {
|
|
53
|
+
return path.join(runsRoot, runId);
|
|
54
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AuditLog — append-only structured log for security-relevant and
|
|
3
|
+
* compliance-relevant actions within a babysitter agent runtime session.
|
|
4
|
+
*
|
|
5
|
+
* Each entry captures *who* did *what* to *which target*, with an optional
|
|
6
|
+
* telemetry span correlation. Entries are queryable by actor, action, and
|
|
7
|
+
* time range.
|
|
8
|
+
*/
|
|
9
|
+
/** A single audit log entry. */
|
|
10
|
+
export interface AuditEntry {
|
|
11
|
+
/** Who performed the action (user id, agent name, system, etc.). */
|
|
12
|
+
readonly actor: string;
|
|
13
|
+
/** What action was performed. */
|
|
14
|
+
readonly action: string;
|
|
15
|
+
/** What the action was performed on (resource, span, task, etc.). */
|
|
16
|
+
readonly target: string;
|
|
17
|
+
/** Optional human-readable detail or serialized context. */
|
|
18
|
+
readonly detail?: string;
|
|
19
|
+
/** Optional telemetry span ID to correlate with the span tree. */
|
|
20
|
+
readonly spanId?: string;
|
|
21
|
+
/** ISO-8601 timestamp of when the entry was recorded. */
|
|
22
|
+
readonly timestamp: string;
|
|
23
|
+
}
|
|
24
|
+
/** Filter criteria for querying the audit log. */
|
|
25
|
+
export interface AuditFilter {
|
|
26
|
+
/** Match entries from this actor. */
|
|
27
|
+
actor?: string;
|
|
28
|
+
/** Match entries with this action. */
|
|
29
|
+
action?: string;
|
|
30
|
+
/** Match entries recorded at or after this ISO-8601 timestamp. */
|
|
31
|
+
from?: string;
|
|
32
|
+
/** Match entries recorded at or before this ISO-8601 timestamp. */
|
|
33
|
+
to?: string;
|
|
34
|
+
}
|
|
35
|
+
/** Append-only in-memory audit log. */
|
|
36
|
+
export declare class AuditLog {
|
|
37
|
+
private readonly entries;
|
|
38
|
+
/**
|
|
39
|
+
* Record a new audit entry.
|
|
40
|
+
*
|
|
41
|
+
* The timestamp is auto-populated to the current time.
|
|
42
|
+
*/
|
|
43
|
+
record(entry: Omit<AuditEntry, "timestamp">): AuditEntry;
|
|
44
|
+
/**
|
|
45
|
+
* Query log entries with optional filters.
|
|
46
|
+
*
|
|
47
|
+
* All supplied filter fields are AND-ed together. Omitted fields match
|
|
48
|
+
* everything.
|
|
49
|
+
*/
|
|
50
|
+
getEntries(filter?: AuditFilter): AuditEntry[];
|
|
51
|
+
/** Total number of entries in the log. */
|
|
52
|
+
get size(): number;
|
|
53
|
+
/** Clear all entries (useful in tests or session resets). */
|
|
54
|
+
clear(): void;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=audit-log.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-log.d.ts","sourceRoot":"","sources":["../../src/telemetry/audit-log.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,gCAAgC;AAChC,MAAM,WAAW,UAAU;IACzB,oEAAoE;IACpE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,iCAAiC;IACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,qEAAqE;IACrE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,4DAA4D;IAC5D,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,kEAAkE;IAClE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,yDAAyD;IACzD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,kDAAkD;AAClD,MAAM,WAAW,WAAW;IAC1B,qCAAqC;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mEAAmE;IACnE,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAMD,uCAAuC;AACvC,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoB;IAE5C;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,GAAG,UAAU;IAMxD;;;;;OAKG;IACH,UAAU,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,UAAU,EAAE;IAc9C,0CAA0C;IAC1C,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,6DAA6D;IAC7D,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AuditLog — append-only structured log for security-relevant and
|
|
4
|
+
* compliance-relevant actions within a babysitter agent runtime session.
|
|
5
|
+
*
|
|
6
|
+
* Each entry captures *who* did *what* to *which target*, with an optional
|
|
7
|
+
* telemetry span correlation. Entries are queryable by actor, action, and
|
|
8
|
+
* time range.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.AuditLog = void 0;
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
// Implementation
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
/** Append-only in-memory audit log. */
|
|
16
|
+
class AuditLog {
|
|
17
|
+
entries = [];
|
|
18
|
+
/**
|
|
19
|
+
* Record a new audit entry.
|
|
20
|
+
*
|
|
21
|
+
* The timestamp is auto-populated to the current time.
|
|
22
|
+
*/
|
|
23
|
+
record(entry) {
|
|
24
|
+
const full = { ...entry, timestamp: new Date().toISOString() };
|
|
25
|
+
this.entries.push(full);
|
|
26
|
+
return full;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Query log entries with optional filters.
|
|
30
|
+
*
|
|
31
|
+
* All supplied filter fields are AND-ed together. Omitted fields match
|
|
32
|
+
* everything.
|
|
33
|
+
*/
|
|
34
|
+
getEntries(filter) {
|
|
35
|
+
if (!filter) {
|
|
36
|
+
return [...this.entries];
|
|
37
|
+
}
|
|
38
|
+
return this.entries.filter((e) => {
|
|
39
|
+
if (filter.actor && e.actor !== filter.actor)
|
|
40
|
+
return false;
|
|
41
|
+
if (filter.action && e.action !== filter.action)
|
|
42
|
+
return false;
|
|
43
|
+
if (filter.from && e.timestamp < filter.from)
|
|
44
|
+
return false;
|
|
45
|
+
if (filter.to && e.timestamp > filter.to)
|
|
46
|
+
return false;
|
|
47
|
+
return true;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/** Total number of entries in the log. */
|
|
51
|
+
get size() {
|
|
52
|
+
return this.entries.length;
|
|
53
|
+
}
|
|
54
|
+
/** Clear all entries (useful in tests or session resets). */
|
|
55
|
+
clear() {
|
|
56
|
+
this.entries.length = 0;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.AuditLog = AuditLog;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { TelemetryExporter, TelemetryExportResult, TelemetrySpan } from "./types";
|
|
2
|
+
export declare class NoopTelemetryExporter implements TelemetryExporter {
|
|
3
|
+
export(spans: readonly TelemetrySpan[]): Promise<TelemetryExportResult>;
|
|
4
|
+
flush(): Promise<TelemetryExportResult>;
|
|
5
|
+
}
|
|
6
|
+
export declare class InMemoryTelemetryExporter implements TelemetryExporter {
|
|
7
|
+
private readonly spans;
|
|
8
|
+
export(spans: readonly TelemetrySpan[]): Promise<TelemetryExportResult>;
|
|
9
|
+
getSpans(): TelemetrySpan[];
|
|
10
|
+
clear(): void;
|
|
11
|
+
}
|
|
12
|
+
export declare class FileTelemetryExporter implements TelemetryExporter {
|
|
13
|
+
private readonly filePath;
|
|
14
|
+
constructor(filePath: string);
|
|
15
|
+
export(spans: readonly TelemetrySpan[]): Promise<TelemetryExportResult>;
|
|
16
|
+
}
|
|
17
|
+
export interface OtlpHttpTraceExporterOptions {
|
|
18
|
+
endpoint: string;
|
|
19
|
+
headers?: Record<string, string>;
|
|
20
|
+
fetch?: (input: string, init: {
|
|
21
|
+
method: string;
|
|
22
|
+
headers: Record<string, string>;
|
|
23
|
+
body: string;
|
|
24
|
+
}) => Promise<{
|
|
25
|
+
ok: boolean;
|
|
26
|
+
status: number;
|
|
27
|
+
text?: () => Promise<string>;
|
|
28
|
+
}>;
|
|
29
|
+
}
|
|
30
|
+
export declare class OtlpHttpTraceExporter implements TelemetryExporter {
|
|
31
|
+
private readonly options;
|
|
32
|
+
constructor(options: OtlpHttpTraceExporterOptions);
|
|
33
|
+
export(spans: readonly TelemetrySpan[]): Promise<TelemetryExportResult>;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=exporters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exporters.d.ts","sourceRoot":"","sources":["../../src/telemetry/exporters.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,iBAAiB,EACjB,qBAAqB,EACrB,aAAa,EACd,MAAM,SAAS,CAAC;AAEjB,qBAAa,qBAAsB,YAAW,iBAAiB;IACvD,MAAM,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAIvE,KAAK,IAAI,OAAO,CAAC,qBAAqB,CAAC;CAG9C;AAED,qBAAa,yBAA0B,YAAW,iBAAiB;IACjE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAuB;IAEvC,MAAM,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAK7E,QAAQ,IAAI,aAAa,EAAE;IAI3B,KAAK,IAAI,IAAI;CAGd;AAED,qBAAa,qBAAsB,YAAW,iBAAiB;IACjD,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,MAAM;IAEvC,MAAM,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAQ9E;AAED,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE;QAC5B,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAChC,IAAI,EAAE,MAAM,CAAC;KACd,KAAK,OAAO,CAAC;QAAE,EAAE,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;KAAE,CAAC,CAAC;CAC9E;AAED,qBAAa,qBAAsB,YAAW,iBAAiB;IACjD,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,4BAA4B;IAE5D,MAAM,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAgC9E"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.OtlpHttpTraceExporter = exports.FileTelemetryExporter = exports.InMemoryTelemetryExporter = exports.NoopTelemetryExporter = void 0;
|
|
37
|
+
const node_fs_1 = require("node:fs");
|
|
38
|
+
const path = __importStar(require("node:path"));
|
|
39
|
+
class NoopTelemetryExporter {
|
|
40
|
+
async export(spans) {
|
|
41
|
+
return { ok: true, exported: spans.length };
|
|
42
|
+
}
|
|
43
|
+
async flush() {
|
|
44
|
+
return { ok: true, exported: 0 };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.NoopTelemetryExporter = NoopTelemetryExporter;
|
|
48
|
+
class InMemoryTelemetryExporter {
|
|
49
|
+
spans = [];
|
|
50
|
+
async export(spans) {
|
|
51
|
+
this.spans.push(...spans.map(cloneSpan));
|
|
52
|
+
return { ok: true, exported: spans.length };
|
|
53
|
+
}
|
|
54
|
+
getSpans() {
|
|
55
|
+
return this.spans.map(cloneSpan);
|
|
56
|
+
}
|
|
57
|
+
clear() {
|
|
58
|
+
this.spans.length = 0;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.InMemoryTelemetryExporter = InMemoryTelemetryExporter;
|
|
62
|
+
class FileTelemetryExporter {
|
|
63
|
+
filePath;
|
|
64
|
+
constructor(filePath) {
|
|
65
|
+
this.filePath = filePath;
|
|
66
|
+
}
|
|
67
|
+
async export(spans) {
|
|
68
|
+
await node_fs_1.promises.mkdir(path.dirname(this.filePath), { recursive: true });
|
|
69
|
+
const lines = spans.map((span) => JSON.stringify(span)).join("\n");
|
|
70
|
+
if (lines) {
|
|
71
|
+
await node_fs_1.promises.appendFile(this.filePath, `${lines}\n`, "utf-8");
|
|
72
|
+
}
|
|
73
|
+
return { ok: true, exported: spans.length };
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.FileTelemetryExporter = FileTelemetryExporter;
|
|
77
|
+
class OtlpHttpTraceExporter {
|
|
78
|
+
options;
|
|
79
|
+
constructor(options) {
|
|
80
|
+
this.options = options;
|
|
81
|
+
}
|
|
82
|
+
async export(spans) {
|
|
83
|
+
const fetchImpl = this.options.fetch ?? globalThis.fetch;
|
|
84
|
+
if (!fetchImpl) {
|
|
85
|
+
return { ok: false, exported: 0, error: "fetch is not available" };
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
const response = await fetchImpl(this.options.endpoint, {
|
|
89
|
+
method: "POST",
|
|
90
|
+
headers: {
|
|
91
|
+
"content-type": "application/json",
|
|
92
|
+
...this.options.headers,
|
|
93
|
+
},
|
|
94
|
+
body: JSON.stringify({ resourceSpans: spans.map(toOtlpSpan) }),
|
|
95
|
+
});
|
|
96
|
+
if (!response.ok) {
|
|
97
|
+
const text = response.text ? await response.text() : "";
|
|
98
|
+
return {
|
|
99
|
+
ok: false,
|
|
100
|
+
exported: 0,
|
|
101
|
+
error: `OTLP HTTP export failed with status ${response.status}${text ? `: ${text}` : ""}`,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
return { ok: true, exported: spans.length };
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
return {
|
|
108
|
+
ok: false,
|
|
109
|
+
exported: 0,
|
|
110
|
+
error: error instanceof Error ? error.message : String(error),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.OtlpHttpTraceExporter = OtlpHttpTraceExporter;
|
|
116
|
+
function cloneSpan(span) {
|
|
117
|
+
return {
|
|
118
|
+
...span,
|
|
119
|
+
attributes: { ...span.attributes },
|
|
120
|
+
events: span.events.map((event) => ({
|
|
121
|
+
...event,
|
|
122
|
+
attributes: event.attributes ? { ...event.attributes } : undefined,
|
|
123
|
+
})),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function toOtlpSpan(span) {
|
|
127
|
+
return {
|
|
128
|
+
traceId: span.traceId,
|
|
129
|
+
spanId: span.spanId,
|
|
130
|
+
parentSpanId: span.parentSpanId,
|
|
131
|
+
name: span.name,
|
|
132
|
+
startTimeUnixNano: Date.parse(span.startTime) * 1_000_000,
|
|
133
|
+
endTimeUnixNano: span.endTime ? Date.parse(span.endTime) * 1_000_000 : undefined,
|
|
134
|
+
status: { code: span.status },
|
|
135
|
+
attributes: Object.entries(span.attributes).map(([key, value]) => ({
|
|
136
|
+
key,
|
|
137
|
+
value,
|
|
138
|
+
})),
|
|
139
|
+
events: span.events,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telemetry module — OpenTelemetry-aligned structured telemetry interfaces
|
|
3
|
+
* and in-memory implementations.
|
|
4
|
+
*/
|
|
5
|
+
export { TelemetrySpanStatus, type TelemetryEvent, type TelemetrySpan, type TelemetryProvider, type TelemetryExporter, type TelemetryConfig, type TraceContext, type TelemetrySpanStartOptions, type TelemetryExportResult, } from "./types";
|
|
6
|
+
export { HttpTelemetryExporter, InMemoryTelemetryProvider, } from "./provider";
|
|
7
|
+
export type { HttpTelemetrySend, InMemoryTelemetryProviderOptions, } from "./provider";
|
|
8
|
+
export { AuditLog, type AuditEntry, type AuditFilter, } from "./audit-log";
|
|
9
|
+
export { SpanTree, type SpanTreeNode, type SerializedSpanTreeNode, } from "./span-tree";
|
|
10
|
+
export { createTraceContext, parseTraceParent, serializeTraceParent, type CreateTraceContextOptions, } from "./traceContext";
|
|
11
|
+
export { FileTelemetryExporter, InMemoryTelemetryExporter, NoopTelemetryExporter, OtlpHttpTraceExporter, type OtlpHttpTraceExporterOptions, } from "./exporters";
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,mBAAmB,EACnB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,GAC3B,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,qBAAqB,EACrB,yBAAyB,GAC1B,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,iBAAiB,EACjB,gCAAgC,GACjC,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,QAAQ,EACR,KAAK,UAAU,EACf,KAAK,WAAW,GACjB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,QAAQ,EACR,KAAK,YAAY,EACjB,KAAK,sBAAsB,GAC5B,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,KAAK,yBAAyB,GAC/B,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EACzB,qBAAqB,EACrB,qBAAqB,EACrB,KAAK,4BAA4B,GAClC,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OtlpHttpTraceExporter = exports.NoopTelemetryExporter = exports.InMemoryTelemetryExporter = exports.FileTelemetryExporter = exports.serializeTraceParent = exports.parseTraceParent = exports.createTraceContext = exports.SpanTree = exports.AuditLog = exports.InMemoryTelemetryProvider = exports.HttpTelemetryExporter = exports.TelemetrySpanStatus = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Telemetry module — OpenTelemetry-aligned structured telemetry interfaces
|
|
6
|
+
* and in-memory implementations.
|
|
7
|
+
*/
|
|
8
|
+
var types_1 = require("./types");
|
|
9
|
+
Object.defineProperty(exports, "TelemetrySpanStatus", { enumerable: true, get: function () { return types_1.TelemetrySpanStatus; } });
|
|
10
|
+
var provider_1 = require("./provider");
|
|
11
|
+
Object.defineProperty(exports, "HttpTelemetryExporter", { enumerable: true, get: function () { return provider_1.HttpTelemetryExporter; } });
|
|
12
|
+
Object.defineProperty(exports, "InMemoryTelemetryProvider", { enumerable: true, get: function () { return provider_1.InMemoryTelemetryProvider; } });
|
|
13
|
+
var audit_log_1 = require("./audit-log");
|
|
14
|
+
Object.defineProperty(exports, "AuditLog", { enumerable: true, get: function () { return audit_log_1.AuditLog; } });
|
|
15
|
+
var span_tree_1 = require("./span-tree");
|
|
16
|
+
Object.defineProperty(exports, "SpanTree", { enumerable: true, get: function () { return span_tree_1.SpanTree; } });
|
|
17
|
+
var traceContext_1 = require("./traceContext");
|
|
18
|
+
Object.defineProperty(exports, "createTraceContext", { enumerable: true, get: function () { return traceContext_1.createTraceContext; } });
|
|
19
|
+
Object.defineProperty(exports, "parseTraceParent", { enumerable: true, get: function () { return traceContext_1.parseTraceParent; } });
|
|
20
|
+
Object.defineProperty(exports, "serializeTraceParent", { enumerable: true, get: function () { return traceContext_1.serializeTraceParent; } });
|
|
21
|
+
var exporters_1 = require("./exporters");
|
|
22
|
+
Object.defineProperty(exports, "FileTelemetryExporter", { enumerable: true, get: function () { return exporters_1.FileTelemetryExporter; } });
|
|
23
|
+
Object.defineProperty(exports, "InMemoryTelemetryExporter", { enumerable: true, get: function () { return exporters_1.InMemoryTelemetryExporter; } });
|
|
24
|
+
Object.defineProperty(exports, "NoopTelemetryExporter", { enumerable: true, get: function () { return exporters_1.NoopTelemetryExporter; } });
|
|
25
|
+
Object.defineProperty(exports, "OtlpHttpTraceExporter", { enumerable: true, get: function () { return exporters_1.OtlpHttpTraceExporter; } });
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* InMemoryTelemetryProvider — in-process telemetry backend for development,
|
|
3
|
+
* testing, and single-process agent runtimes.
|
|
4
|
+
*
|
|
5
|
+
* Stores spans in memory and supports flush/drain for export pipelines.
|
|
6
|
+
*/
|
|
7
|
+
import type { TelemetryExporter, TelemetryExportResult, TelemetryProvider, TelemetrySpan, TelemetryEvent, TelemetrySpanStartOptions } from "./types";
|
|
8
|
+
import { TelemetrySpanStatus } from "./types";
|
|
9
|
+
export interface InMemoryTelemetryProviderOptions {
|
|
10
|
+
exporters?: TelemetryExporter[];
|
|
11
|
+
}
|
|
12
|
+
export declare class FileTelemetryExporter implements TelemetryExporter {
|
|
13
|
+
private readonly filePath;
|
|
14
|
+
constructor(filePath: string);
|
|
15
|
+
export(spans: readonly TelemetrySpan[]): Promise<TelemetryExportResult>;
|
|
16
|
+
}
|
|
17
|
+
export type HttpTelemetrySend = (url: string, payload: unknown) => Promise<void>;
|
|
18
|
+
export declare class HttpTelemetryExporter implements TelemetryExporter {
|
|
19
|
+
private readonly url;
|
|
20
|
+
private readonly send;
|
|
21
|
+
constructor(url: string, send?: HttpTelemetrySend);
|
|
22
|
+
export(spans: readonly TelemetrySpan[]): Promise<TelemetryExportResult>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* In-memory telemetry provider that satisfies the TelemetryProvider interface.
|
|
26
|
+
*
|
|
27
|
+
* - `startSpan` creates a new span and tracks it as active.
|
|
28
|
+
* - `endSpan` marks a span as completed and moves it to the completed set.
|
|
29
|
+
* - `recordEvent` appends a discrete event to an active span.
|
|
30
|
+
* - `flush` returns all completed spans and clears the completed buffer.
|
|
31
|
+
* - `getActiveSpans` returns all currently open (un-ended) spans.
|
|
32
|
+
*/
|
|
33
|
+
export declare class InMemoryTelemetryProvider implements TelemetryProvider {
|
|
34
|
+
/** Active (in-flight) spans keyed by spanId. */
|
|
35
|
+
private readonly active;
|
|
36
|
+
/** Completed spans awaiting flush. */
|
|
37
|
+
private readonly completed;
|
|
38
|
+
/** Maps spanId -> traceId so child spans inherit the parent's trace. */
|
|
39
|
+
private readonly traceIndex;
|
|
40
|
+
private readonly exporters;
|
|
41
|
+
constructor(options?: InMemoryTelemetryProviderOptions);
|
|
42
|
+
startSpan(name: string, parentSpanId?: string): Promise<TelemetrySpan>;
|
|
43
|
+
startSpan(name: string, options?: TelemetrySpanStartOptions): Promise<TelemetrySpan>;
|
|
44
|
+
endSpan(spanId: string, status?: TelemetrySpanStatus): Promise<void>;
|
|
45
|
+
recordEvent(spanId: string, event: TelemetryEvent): Promise<void>;
|
|
46
|
+
flush(): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Drain completed spans — returns and clears the completed buffer.
|
|
49
|
+
*
|
|
50
|
+
* Unlike `flush()` (which satisfies the TelemetryProvider interface and
|
|
51
|
+
* returns void), this method hands the span data back to the caller.
|
|
52
|
+
*/
|
|
53
|
+
drain(): Promise<TelemetrySpan[]>;
|
|
54
|
+
/** Return a snapshot of all currently open (un-ended) spans. */
|
|
55
|
+
getActiveSpans(): TelemetrySpan[];
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/telemetry/provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EACV,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,yBAAyB,EAC1B,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAoB9C,MAAM,WAAW,gCAAgC;IAC/C,SAAS,CAAC,EAAE,iBAAiB,EAAE,CAAC;CACjC;AAED,qBAAa,qBAAsB,YAAW,iBAAiB;IACjD,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,MAAM;IAEvC,MAAM,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAO9E;AAED,MAAM,MAAM,iBAAiB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEjF,qBAAa,qBAAsB,YAAW,iBAAiB;IAE3D,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBADJ,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,iBAAmC;IAGtD,MAAM,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAK9E;AAaD;;;;;;;;GAQG;AACH,qBAAa,yBAA0B,YAAW,iBAAiB;IACjE,gDAAgD;IAChD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkC;IACzD,sCAAsC;IACtC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAqB;IAC/C,wEAAwE;IACxE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA6B;IACxD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAsB;gBAEpC,OAAO,CAAC,EAAE,gCAAgC;IAMhD,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IACtE,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,yBAAyB,GAAG,OAAO,CAAC,aAAa,CAAC;IA2CpF,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAapE,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IASjE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ5B;;;;;OAKG;IACG,KAAK,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IAMvC,gEAAgE;IAChE,cAAc,IAAI,aAAa,EAAE;CAGlC"}
|