@a5c-ai/genty-runtime 5.1.1-staging.00ceebd28cf2
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 +169 -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 +22 -0
- package/dist/session/discovery.d.ts.map +1 -0
- package/dist/session/discovery.js +35 -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/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/package.json +137 -0
|
@@ -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;AACzE,oBAAY,mBAAmB;IAC7B,wCAAwC;IACxC,EAAE,OAAO;IACT,oCAAoC;IACpC,KAAK,UAAU;IACf,oDAAoD;IACpD,KAAK,UAAU;CAChB;AAMD,+CAA+C;AAC/C,MAAM,WAAW,cAAc;IAC7B,iCAAiC;IACjC,QAAQ,CAAC,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AAE,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 = {}));
|
package/package.json
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@a5c-ai/genty-runtime",
|
|
3
|
+
"version": "5.1.1-staging.00ceebd28cf2",
|
|
4
|
+
"description": "Agent runtime layer (L5) — daemon, session, resource management, telemetry",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "commonjs",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"require": "./dist/index.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./daemon": {
|
|
16
|
+
"types": "./dist/daemon/index.d.ts",
|
|
17
|
+
"require": "./dist/daemon/index.js",
|
|
18
|
+
"default": "./dist/daemon/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./session": {
|
|
21
|
+
"types": "./dist/session/index.d.ts",
|
|
22
|
+
"require": "./dist/session/index.js",
|
|
23
|
+
"default": "./dist/session/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./cost": {
|
|
26
|
+
"types": "./dist/cost/index.d.ts",
|
|
27
|
+
"require": "./dist/cost/index.js",
|
|
28
|
+
"default": "./dist/cost/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./observability": {
|
|
31
|
+
"types": "./dist/observability/index.d.ts",
|
|
32
|
+
"require": "./dist/observability/index.js",
|
|
33
|
+
"default": "./dist/observability/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./telemetry": {
|
|
36
|
+
"types": "./dist/telemetry/index.d.ts",
|
|
37
|
+
"require": "./dist/telemetry/index.js",
|
|
38
|
+
"default": "./dist/telemetry/index.js"
|
|
39
|
+
},
|
|
40
|
+
"./package.json": "./package.json",
|
|
41
|
+
"./rpc": {
|
|
42
|
+
"import": {
|
|
43
|
+
"types": "./dist/rpc/index.d.ts",
|
|
44
|
+
"default": "./dist/rpc/index.js"
|
|
45
|
+
},
|
|
46
|
+
"require": {
|
|
47
|
+
"types": "./dist/rpc/index.d.ts",
|
|
48
|
+
"default": "./dist/rpc/index.js"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"./session/tree": {
|
|
52
|
+
"import": {
|
|
53
|
+
"types": "./dist/session/tree.d.ts",
|
|
54
|
+
"default": "./dist/session/tree.js"
|
|
55
|
+
},
|
|
56
|
+
"require": {
|
|
57
|
+
"types": "./dist/session/tree.d.ts",
|
|
58
|
+
"default": "./dist/session/tree.js"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"./session/export": {
|
|
62
|
+
"import": {
|
|
63
|
+
"types": "./dist/session/export.d.ts",
|
|
64
|
+
"default": "./dist/session/export.js"
|
|
65
|
+
},
|
|
66
|
+
"require": {
|
|
67
|
+
"types": "./dist/session/export.d.ts",
|
|
68
|
+
"default": "./dist/session/export.js"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"typesVersions": {
|
|
73
|
+
"*": {
|
|
74
|
+
"daemon": [
|
|
75
|
+
"dist/daemon/index.d.ts"
|
|
76
|
+
],
|
|
77
|
+
"session": [
|
|
78
|
+
"dist/session/index.d.ts"
|
|
79
|
+
],
|
|
80
|
+
"cost": [
|
|
81
|
+
"dist/cost/index.d.ts"
|
|
82
|
+
],
|
|
83
|
+
"observability": [
|
|
84
|
+
"dist/observability/index.d.ts"
|
|
85
|
+
],
|
|
86
|
+
"telemetry": [
|
|
87
|
+
"dist/telemetry/index.d.ts"
|
|
88
|
+
],
|
|
89
|
+
"rpc": [
|
|
90
|
+
"dist/rpc/index.d.ts"
|
|
91
|
+
],
|
|
92
|
+
"session/tree": [
|
|
93
|
+
"dist/session/tree.d.ts"
|
|
94
|
+
],
|
|
95
|
+
"session/export": [
|
|
96
|
+
"dist/session/export.d.ts"
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
"files": [
|
|
101
|
+
"dist/",
|
|
102
|
+
"README.md"
|
|
103
|
+
],
|
|
104
|
+
"publishConfig": {
|
|
105
|
+
"access": "public"
|
|
106
|
+
},
|
|
107
|
+
"scripts": {
|
|
108
|
+
"build": "npm run build:sdk --prefix ../../.. && tsc --build --force tsconfig.json",
|
|
109
|
+
"clean": "rimraf dist tsconfig.tsbuildinfo",
|
|
110
|
+
"test": "vitest run --config vitest.config.ts"
|
|
111
|
+
},
|
|
112
|
+
"dependencies": {
|
|
113
|
+
"@a5c-ai/comm-adapter": "5.1.1-staging.00ceebd28cf2",
|
|
114
|
+
"@a5c-ai/babysitter-sdk": "5.1.1-staging.00ceebd28cf2"
|
|
115
|
+
},
|
|
116
|
+
"devDependencies": {
|
|
117
|
+
"@types/node": "^20.11.30",
|
|
118
|
+
"rimraf": "^6.1.3",
|
|
119
|
+
"typescript": "^5.4.2",
|
|
120
|
+
"vitest": "^4.0.18"
|
|
121
|
+
},
|
|
122
|
+
"repository": {
|
|
123
|
+
"type": "git",
|
|
124
|
+
"url": "git+https://github.com/a5c-ai/babysitter.git",
|
|
125
|
+
"directory": "packages/genty/runtime"
|
|
126
|
+
},
|
|
127
|
+
"homepage": "https://github.com/a5c-ai/babysitter/tree/main/packages/genty/runtime#readme",
|
|
128
|
+
"bugs": {
|
|
129
|
+
"url": "https://github.com/a5c-ai/babysitter/issues"
|
|
130
|
+
},
|
|
131
|
+
"atlas": {
|
|
132
|
+
"layers": [
|
|
133
|
+
"L5"
|
|
134
|
+
],
|
|
135
|
+
"muxes": []
|
|
136
|
+
}
|
|
137
|
+
}
|