profclaw 0.0.1-beta.3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -38
- package/CONTRIBUTING.md +3 -5
- package/README.md +128 -63
- package/dist/chat/execution/tools/index.d.ts +1 -1
- package/dist/chat/execution/tools/index.js +41 -2
- package/dist/chat/providers/slack/index.d.ts +2 -2
- package/dist/cli/commands/models.js +39 -26
- package/dist/cli/commands/onboard.js +64 -79
- package/dist/cli/commands/setup.js +293 -90
- package/dist/cli/index.js +0 -6
- package/dist/cli/providers.d.ts +15 -0
- package/dist/cli/providers.js +41 -0
- package/dist/core/deployment.js +2 -0
- package/dist/providers/ai-sdk.js +26 -6
- package/dist/routes/channels.d.ts +12 -0
- package/dist/routes/channels.js +166 -0
- package/dist/server/route-loader.js +1 -0
- package/dist/server.js +115 -109
- package/package.json +1 -1
- package/skills/git-workflow/SKILL.md +3 -3
- package/ui/dist/assets/{ActivityView-DIPQSJ_d.js → ActivityView-BeshZXmE.js} +1 -1
- package/ui/dist/assets/{AgentList-CqyaYrcq.js → AgentList-QVHeldPi.js} +1 -1
- package/ui/dist/assets/{AnalyticsDashboard-C-mjuGHT.js → AnalyticsDashboard-C9R97dXE.js} +1 -1
- package/ui/dist/assets/{AreaChart-CfYWmbtr.js → AreaChart-B73gaiVQ.js} +1 -1
- package/ui/dist/assets/{CartesianChart-BaQ3It0c.js → CartesianChart-CXYL2R-A.js} +1 -1
- package/ui/dist/assets/{ChatView-DxxQy6pl.js → ChatView-qjZErlrp.js} +1 -1
- package/ui/dist/assets/{CostsDashboard-CDBBcGkg.js → CostsDashboard-O4DCLy1i.js} +1 -1
- package/ui/dist/assets/{EstimateSelect-CDjf5qKl.js → EstimateSelect-1hQf4Osk.js} +1 -1
- package/ui/dist/assets/{FloatingChatbot-CZHjvJIe.js → FloatingChatbot-BZBzrJxd.js} +1 -1
- package/ui/dist/assets/{InviteCodeManagement-DTm-IPTm.js → InviteCodeManagement-LEoGqYeA.js} +1 -1
- package/ui/dist/assets/{ProjectDetail-DlYUcOss.js → ProjectDetail--gPfvATB.js} +1 -1
- package/ui/dist/assets/{ProjectIcon-BMRpnM04.js → ProjectIcon-Chd_ofsw.js} +1 -1
- package/ui/dist/assets/{ProjectList-D85TN0i0.js → ProjectList-BvUfVB6c.js} +1 -1
- package/ui/dist/assets/{Settings-CgPqzUvj.js → Settings-1kaf7VHE.js} +1 -1
- package/ui/dist/assets/{StatusIndicator-yig0uZEA.js → StatusIndicator-pRfkNcdV.js} +1 -1
- package/ui/dist/assets/{SummaryDetail-CwLAfHgJ.js → SummaryDetail-DV3AmONk.js} +1 -1
- package/ui/dist/assets/{SummaryList-BvS5Idnu.js → SummaryList-B6kXiTxL.js} +1 -1
- package/ui/dist/assets/{TaskDetail-zarC1fOt.js → TaskDetail-CV6CzbOS.js} +1 -1
- package/ui/dist/assets/{TaskList-CyJq3ANE.js → TaskList-DL7brQKd.js} +1 -1
- package/ui/dist/assets/{TicketBoard-BlWr3-iH.js → TicketBoard-CrkkFj7C.js} +1 -1
- package/ui/dist/assets/{TicketDetail-DmqWKj2W.js → TicketDetail-hnnYclpD.js} +1 -1
- package/ui/dist/assets/{TicketList-Scj4pMWa.js → TicketList-CsDAyQCL.js} +1 -1
- package/ui/dist/assets/{UserManagement-BH7uG7dw.js → UserManagement-BGFQyTSr.js} +1 -1
- package/ui/dist/assets/{ViewSwitcher-3HzZUdWn.js → ViewSwitcher-CnL0OqA8.js} +1 -1
- package/ui/dist/assets/{alert-dialog-DWPb2IfQ.js → alert-dialog-SKM6Gjz4.js} +1 -1
- package/ui/dist/assets/{archive-CGck7gxR.js → archive-BsLa7brF.js} +1 -1
- package/ui/dist/assets/{badge-DEmc3Z_l.js → badge-CVHH1a-v.js} +1 -1
- package/ui/dist/assets/{brain-CfFdLVqb.js → brain-6o_RHVpe.js} +1 -1
- package/ui/dist/assets/{bug-DqSGPUUE.js → bug-CmZI7jqM.js} +1 -1
- package/ui/dist/assets/{calendar-BuZ4zbPW.js → calendar-Bf0t2B82.js} +1 -1
- package/ui/dist/assets/{chevron-up-DcJ4LL_N.js → chevron-up-CoUsOvZj.js} +1 -1
- package/ui/dist/assets/{circle-x-C78PNZjF.js → circle-x-Dgw11LgT.js} +1 -1
- package/ui/dist/assets/{constants-DhDjZe4P.js → constants-Q5Zivl-a.js} +1 -1
- package/ui/dist/assets/{cpu-Ck6AoG8c.js → cpu-DiPMQICV.js} +1 -1
- package/ui/dist/assets/{database-CA2w8Lvt.js → database-BwTfupDi.js} +1 -1
- package/ui/dist/assets/{dialog-BOdGWhgE.js → dialog-BUqN9Psj.js} +1 -1
- package/ui/dist/assets/{ellipsis-FhHKRbfl.js → ellipsis-UJx4Xnf6.js} +1 -1
- package/ui/dist/assets/{ellipsis-vertical-CO0UqE4-.js → ellipsis-vertical-DoULYEKn.js} +1 -1
- package/ui/dist/assets/{file-code-ChnhYYj1.js → file-code-B2UrJLwi.js} +1 -1
- package/ui/dist/assets/{folder-open-CHwA1-ve.js → folder-open-BJi577JH.js} +1 -1
- package/ui/dist/assets/{funnel-ByEjRFNB.js → funnel-PkaD_HSR.js} +1 -1
- package/ui/dist/assets/{git-branch-GTOPQgU4.js → git-branch-C_K30am0.js} +1 -1
- package/ui/dist/assets/{git-commit-horizontal-F5M84Kut.js → git-commit-horizontal-IT6ecxWQ.js} +1 -1
- package/ui/dist/assets/{globe-CQWfr7hT.js → globe-f-jjCa_g.js} +1 -1
- package/ui/dist/assets/{hash-nKC9gtLg.js → hash-DNEv8Elo.js} +1 -1
- package/ui/dist/assets/{history-DfFSA9xJ.js → history-BQSBo_1Q.js} +1 -1
- package/ui/dist/assets/{index-DHGvP9mp.js → index-BUmnwPQr.js} +1 -1
- package/ui/dist/assets/{index-Z4-RtZcs.js → index-BfF5G4Cw.js} +1 -1
- package/ui/dist/assets/{index-DeI8lKRR.js → index-C8N375c2.js} +1 -1
- package/ui/dist/assets/index-CuxnqVVz.css +1 -0
- package/ui/dist/assets/{index-Ca3vk7Gq.js → index-CzMM3QOk.js} +1 -1
- package/ui/dist/assets/{index--JkIxVXb.js → index-lJlNPFVJ.js} +3 -3
- package/ui/dist/assets/{index-a4Fxq0Hb.js → index-nS3EErDg.js} +1 -1
- package/ui/dist/assets/{layers-DFeLExSa.js → layers-jFqVrWMD.js} +1 -1
- package/ui/dist/assets/{layout-dashboard-WmgjMhWF.js → layout-dashboard-CcKt1hXw.js} +1 -1
- package/ui/dist/assets/{lightbulb-Bo8hEr7B.js → lightbulb-Jhp7FvbU.js} +1 -1
- package/ui/dist/assets/{link-2-YqrpQXBH.js → link-2-DdO7ostF.js} +1 -1
- package/ui/dist/assets/{markdown-renderer-Croje6Xe.js → markdown-renderer-n1ToC4XQ.js} +1 -1
- package/ui/dist/assets/{message-square-CD0H5hot.js → message-square-CBgH65X7.js} +1 -1
- package/ui/dist/assets/{pencil-DpFnj5dn.js → pencil-CYXCEPQh.js} +1 -1
- package/ui/dist/assets/{play-DVgea_jT.js → play-d1ONaH0-.js} +1 -1
- package/ui/dist/assets/{popover-JXecfWG5.js → popover-CrmZgoWu.js} +1 -1
- package/ui/dist/assets/{progress-C1ghf1Fu.js → progress-uv4SPkL5.js} +1 -1
- package/ui/dist/assets/{rocket-BFxPYGx9.js → rocket-DhvUetsk.js} +1 -1
- package/ui/dist/assets/{select-MADP8m6Q.js → select-CeQ8AHGy.js} +1 -1
- package/ui/dist/assets/{send-eYnW_7n-.js → send-P0r5D7td.js} +1 -1
- package/ui/dist/assets/{server-CPMaysH8.js → server-CVHTZB72.js} +1 -1
- package/ui/dist/assets/{settings-2-scXUOuE_.js → settings-2-ocj5uHGx.js} +1 -1
- package/ui/dist/assets/{sheet-r6NSOxi-.js → sheet-DuQExSho.js} +1 -1
- package/ui/dist/assets/{shield-check-PEr7nmVw.js → shield-check-DfVdE34l.js} +1 -1
- package/ui/dist/assets/{shield-off-CLtXio62.js → shield-off-8l0J6R-8.js} +1 -1
- package/ui/dist/assets/{skeleton-C9oEzNlU.js → skeleton-TFiFJ3nB.js} +1 -1
- package/ui/dist/assets/{smartphone-DusFfY0U.js → smartphone-77_g3SQn.js} +1 -1
- package/ui/dist/assets/{square-e1yxB2eR.js → square-Ckzsr3Rn.js} +1 -1
- package/ui/dist/assets/{switch-tNs0n-kz.js → switch-CAePkd6k.js} +1 -1
- package/ui/dist/assets/{table-CXxtLicg.js → table-ZjAZ7hkt.js} +1 -1
- package/ui/dist/assets/{tag-tAwMmQ9G.js → tag-C35mgoEv.js} +1 -1
- package/ui/dist/assets/{textarea-BjiEeIWh.js → textarea-DsVPnSgR.js} +1 -1
- package/ui/dist/assets/{timer-Vel1N3RP.js → timer-DHJBS2w1.js} +1 -1
- package/ui/dist/assets/{tooltip-ZMwtfr1J.js → tooltip-BYmQ331W.js} +1 -1
- package/ui/dist/assets/{trash-2-eM-CNwsZ.js → trash-2-keO5tKPE.js} +1 -1
- package/ui/dist/assets/{trending-up-BGafmjRo.js → trending-up-BBv8KbrY.js} +1 -1
- package/ui/dist/assets/{wand-sparkles-DPvcd9Pi.js → wand-sparkles-BusQ52ZK.js} +1 -1
- package/ui/dist/assets/{wrench-B8s3zYVV.js → wrench-02YaOSiK.js} +1 -1
- package/ui/dist/index.html +2 -2
- package/dist/chat/auto-reply.d.ts +0 -90
- package/dist/chat/auto-reply.js +0 -272
- package/dist/chat/execution/pty.d.ts +0 -92
- package/dist/chat/execution/pty.js +0 -285
- package/dist/chat/execution/tools/glinr-ops.d.ts +0 -202
- package/dist/chat/execution/tools/glinr-ops.js +0 -694
- package/dist/cli/commands/browser.d.ts +0 -3
- package/dist/cli/commands/browser.js +0 -138
- package/dist/cli/commands/canvas.d.ts +0 -3
- package/dist/cli/commands/canvas.js +0 -155
- package/dist/cli/commands/nodes.d.ts +0 -3
- package/dist/cli/commands/nodes.js +0 -193
- package/dist/diagnostics/exporters.d.ts +0 -21
- package/dist/diagnostics/exporters.js +0 -138
- package/dist/diagnostics/index.d.ts +0 -10
- package/dist/diagnostics/index.js +0 -9
- package/dist/diagnostics/middleware.d.ts +0 -12
- package/dist/diagnostics/middleware.js +0 -58
- package/dist/diagnostics/tracer.d.ts +0 -133
- package/dist/diagnostics/tracer.js +0 -257
- package/dist/discovery/index.d.ts +0 -8
- package/dist/discovery/index.js +0 -7
- package/dist/discovery/mdns.d.ts +0 -40
- package/dist/discovery/mdns.js +0 -249
- package/dist/plugins/registry.d.ts +0 -122
- package/dist/plugins/registry.js +0 -352
- package/dist/plugins/sandbox.d.ts +0 -77
- package/dist/plugins/sandbox.js +0 -287
- package/dist/plugins/search/brave.d.ts +0 -9
- package/dist/plugins/search/brave.js +0 -157
- package/dist/plugins/search/duckduckgo.d.ts +0 -9
- package/dist/plugins/search/duckduckgo.js +0 -171
- package/dist/plugins/search/index.d.ts +0 -13
- package/dist/plugins/search/index.js +0 -23
- package/dist/plugins/search/searxng.d.ts +0 -9
- package/dist/plugins/search/searxng.js +0 -170
- package/dist/plugins/search/serper.d.ts +0 -9
- package/dist/plugins/search/serper.js +0 -135
- package/dist/plugins/search/tavily.d.ts +0 -9
- package/dist/plugins/search/tavily.js +0 -146
- package/dist/providers/adapters/anthropic.d.ts +0 -26
- package/dist/providers/adapters/anthropic.js +0 -306
- package/dist/providers/adapters/base.d.ts +0 -53
- package/dist/providers/adapters/base.js +0 -99
- package/dist/providers/adapters/ollama.d.ts +0 -30
- package/dist/providers/adapters/ollama.js +0 -292
- package/dist/utils/ai-cache.d.ts +0 -72
- package/dist/utils/ai-cache.js +0 -204
- package/dist/utils/file-lock.d.ts +0 -85
- package/dist/utils/file-lock.js +0 -204
- package/ui/dist/assets/index-WclMPci1.css +0 -1
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Diagnostics Middleware for Hono
|
|
3
|
-
*
|
|
4
|
-
* Automatically traces HTTP requests and propagates W3C traceparent context.
|
|
5
|
-
*/
|
|
6
|
-
import type { Context, Next } from 'hono';
|
|
7
|
-
/**
|
|
8
|
-
* Request tracing middleware.
|
|
9
|
-
* Adds a server span to every request and propagates W3C traceparent.
|
|
10
|
-
*/
|
|
11
|
-
export declare function tracingMiddleware(c: Context, next: Next): Promise<void>;
|
|
12
|
-
//# sourceMappingURL=middleware.d.ts.map
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Diagnostics Middleware for Hono
|
|
3
|
-
*
|
|
4
|
-
* Automatically traces HTTP requests and propagates W3C traceparent context.
|
|
5
|
-
*/
|
|
6
|
-
import { startSpan, endSpan, setSpanAttribute, parseTraceparent, formatTraceparent, incrementCounter, recordMetric, } from './tracer.js';
|
|
7
|
-
/**
|
|
8
|
-
* Request tracing middleware.
|
|
9
|
-
* Adds a server span to every request and propagates W3C traceparent.
|
|
10
|
-
*/
|
|
11
|
-
export async function tracingMiddleware(c, next) {
|
|
12
|
-
// Parse incoming traceparent to continue an existing trace
|
|
13
|
-
const traceparentHeader = c.req.header('traceparent');
|
|
14
|
-
const parentContext = traceparentHeader ? parseTraceparent(traceparentHeader) : null;
|
|
15
|
-
const spanKind = 'server';
|
|
16
|
-
const span = startSpan(`${c.req.method} ${c.req.routePath || c.req.path}`, {
|
|
17
|
-
kind: spanKind,
|
|
18
|
-
traceId: parentContext?.traceId,
|
|
19
|
-
parentSpanId: parentContext?.spanId,
|
|
20
|
-
attributes: {
|
|
21
|
-
'http.method': c.req.method,
|
|
22
|
-
'http.url': c.req.path,
|
|
23
|
-
'http.user_agent': c.req.header('User-Agent') ?? 'unknown',
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
// Propagate trace context to the response so callers can correlate
|
|
27
|
-
c.header('traceparent', formatTraceparent({
|
|
28
|
-
traceId: span.traceId,
|
|
29
|
-
spanId: span.spanId,
|
|
30
|
-
traceFlags: 1,
|
|
31
|
-
}));
|
|
32
|
-
// Store span in Hono context variables for downstream handlers
|
|
33
|
-
c.set('span', span);
|
|
34
|
-
incrementCounter('http.requests', {
|
|
35
|
-
method: c.req.method,
|
|
36
|
-
path: c.req.routePath || c.req.path,
|
|
37
|
-
});
|
|
38
|
-
const startTime = Date.now();
|
|
39
|
-
try {
|
|
40
|
-
await next();
|
|
41
|
-
const status = c.res.status;
|
|
42
|
-
setSpanAttribute(span, 'http.status_code', status);
|
|
43
|
-
const durationMs = Date.now() - startTime;
|
|
44
|
-
recordMetric('http.response_time_ms', durationMs, {
|
|
45
|
-
method: c.req.method,
|
|
46
|
-
path: c.req.routePath || c.req.path,
|
|
47
|
-
status: String(status),
|
|
48
|
-
});
|
|
49
|
-
endSpan(span, status >= 400 ? 'error' : 'ok');
|
|
50
|
-
}
|
|
51
|
-
catch (error) {
|
|
52
|
-
setSpanAttribute(span, 'error', true);
|
|
53
|
-
setSpanAttribute(span, 'error.message', error instanceof Error ? error.message : String(error));
|
|
54
|
-
endSpan(span, 'error');
|
|
55
|
-
throw error;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
//# sourceMappingURL=middleware.js.map
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lightweight Tracing / Diagnostics
|
|
3
|
-
*
|
|
4
|
-
* OpenTelemetry-compatible trace context without the full SDK.
|
|
5
|
-
* Provides:
|
|
6
|
-
* - Span creation and nesting
|
|
7
|
-
* - Trace context propagation (W3C traceparent)
|
|
8
|
-
* - Performance metrics collection
|
|
9
|
-
* - Export interface for future OTEL integration
|
|
10
|
-
*/
|
|
11
|
-
export interface Span {
|
|
12
|
-
traceId: string;
|
|
13
|
-
spanId: string;
|
|
14
|
-
parentSpanId?: string;
|
|
15
|
-
name: string;
|
|
16
|
-
kind: SpanKind;
|
|
17
|
-
startTime: number;
|
|
18
|
-
endTime?: number;
|
|
19
|
-
status: SpanStatus;
|
|
20
|
-
attributes: Record<string, string | number | boolean>;
|
|
21
|
-
events: SpanEvent[];
|
|
22
|
-
}
|
|
23
|
-
export interface SpanEvent {
|
|
24
|
-
name: string;
|
|
25
|
-
timestamp: number;
|
|
26
|
-
attributes?: Record<string, string | number | boolean>;
|
|
27
|
-
}
|
|
28
|
-
export type SpanKind = 'internal' | 'server' | 'client' | 'producer' | 'consumer';
|
|
29
|
-
export type SpanStatus = 'unset' | 'ok' | 'error';
|
|
30
|
-
export interface TraceContext {
|
|
31
|
-
traceId: string;
|
|
32
|
-
spanId: string;
|
|
33
|
-
traceFlags: number;
|
|
34
|
-
}
|
|
35
|
-
export interface MetricPoint {
|
|
36
|
-
name: string;
|
|
37
|
-
value: number;
|
|
38
|
-
labels: Record<string, string>;
|
|
39
|
-
timestamp: number;
|
|
40
|
-
}
|
|
41
|
-
export interface SpanExporter {
|
|
42
|
-
export: (spans: Span[]) => Promise<void>;
|
|
43
|
-
}
|
|
44
|
-
export interface DiagnosticsConfig {
|
|
45
|
-
enabled: boolean;
|
|
46
|
-
sampleRate: number;
|
|
47
|
-
maxSpans: number;
|
|
48
|
-
exportIntervalMs: number;
|
|
49
|
-
exporter?: SpanExporter;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Parse W3C traceparent header.
|
|
53
|
-
* Format: version-traceId-parentId-traceFlags
|
|
54
|
-
* Example: 00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01
|
|
55
|
-
*/
|
|
56
|
-
export declare function parseTraceparent(header: string): TraceContext | null;
|
|
57
|
-
/**
|
|
58
|
-
* Format W3C traceparent header
|
|
59
|
-
*/
|
|
60
|
-
export declare function formatTraceparent(ctx: TraceContext): string;
|
|
61
|
-
/**
|
|
62
|
-
* Start a new span
|
|
63
|
-
*/
|
|
64
|
-
export declare function startSpan(name: string, options?: {
|
|
65
|
-
kind?: SpanKind;
|
|
66
|
-
parentSpanId?: string;
|
|
67
|
-
traceId?: string;
|
|
68
|
-
attributes?: Record<string, string | number | boolean>;
|
|
69
|
-
}): Span;
|
|
70
|
-
/**
|
|
71
|
-
* End a span and record its duration
|
|
72
|
-
*/
|
|
73
|
-
export declare function endSpan(span: Span, status?: SpanStatus): void;
|
|
74
|
-
/**
|
|
75
|
-
* Add an event to a span
|
|
76
|
-
*/
|
|
77
|
-
export declare function addSpanEvent(span: Span, name: string, attributes?: Record<string, string | number | boolean>): void;
|
|
78
|
-
/**
|
|
79
|
-
* Set a span attribute
|
|
80
|
-
*/
|
|
81
|
-
export declare function setSpanAttribute(span: Span, key: string, value: string | number | boolean): void;
|
|
82
|
-
/**
|
|
83
|
-
* Convenience: trace an async function execution as a span
|
|
84
|
-
*/
|
|
85
|
-
export declare function trace<T>(name: string, fn: (span: Span) => Promise<T>, options?: {
|
|
86
|
-
kind?: SpanKind;
|
|
87
|
-
attributes?: Record<string, string | number | boolean>;
|
|
88
|
-
}): Promise<T>;
|
|
89
|
-
/**
|
|
90
|
-
* Record a metric point
|
|
91
|
-
*/
|
|
92
|
-
export declare function recordMetric(name: string, value: number, labels?: Record<string, string>): void;
|
|
93
|
-
/**
|
|
94
|
-
* Increment a counter metric by 1
|
|
95
|
-
*/
|
|
96
|
-
export declare function incrementCounter(name: string, labels?: Record<string, string>): void;
|
|
97
|
-
export interface MetricSummary {
|
|
98
|
-
count: number;
|
|
99
|
-
avg: number;
|
|
100
|
-
min: number;
|
|
101
|
-
max: number;
|
|
102
|
-
}
|
|
103
|
-
export interface DiagnosticsSnapshot {
|
|
104
|
-
activeSpans: number;
|
|
105
|
-
completedSpans: number;
|
|
106
|
-
metricsCount: number;
|
|
107
|
-
config: Omit<DiagnosticsConfig, 'exporter'>;
|
|
108
|
-
recentSpans: Array<{
|
|
109
|
-
name: string;
|
|
110
|
-
durationMs: number;
|
|
111
|
-
status: SpanStatus;
|
|
112
|
-
traceId: string;
|
|
113
|
-
}>;
|
|
114
|
-
metricsSummary: Record<string, MetricSummary>;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Get a snapshot of current diagnostics state
|
|
118
|
-
*/
|
|
119
|
-
export declare function getDiagnostics(): DiagnosticsSnapshot;
|
|
120
|
-
/**
|
|
121
|
-
* Get all completed spans belonging to a specific trace
|
|
122
|
-
*/
|
|
123
|
-
export declare function getTraceSpans(traceId: string): Span[];
|
|
124
|
-
/**
|
|
125
|
-
* Configure the diagnostics system.
|
|
126
|
-
* Restarts the export interval if the interval or exporter changed.
|
|
127
|
-
*/
|
|
128
|
-
export declare function configureDiagnostics(newConfig: Partial<DiagnosticsConfig>): void;
|
|
129
|
-
/**
|
|
130
|
-
* Stop the diagnostics system and clear all buffers
|
|
131
|
-
*/
|
|
132
|
-
export declare function stopDiagnostics(): void;
|
|
133
|
-
//# sourceMappingURL=tracer.d.ts.map
|
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lightweight Tracing / Diagnostics
|
|
3
|
-
*
|
|
4
|
-
* OpenTelemetry-compatible trace context without the full SDK.
|
|
5
|
-
* Provides:
|
|
6
|
-
* - Span creation and nesting
|
|
7
|
-
* - Trace context propagation (W3C traceparent)
|
|
8
|
-
* - Performance metrics collection
|
|
9
|
-
* - Export interface for future OTEL integration
|
|
10
|
-
*/
|
|
11
|
-
import { randomBytes } from 'crypto';
|
|
12
|
-
import { logger } from '../utils/logger.js';
|
|
13
|
-
// --- State ---
|
|
14
|
-
const DEFAULT_CONFIG = {
|
|
15
|
-
enabled: true,
|
|
16
|
-
sampleRate: 1.0,
|
|
17
|
-
maxSpans: 1000,
|
|
18
|
-
exportIntervalMs: 30_000,
|
|
19
|
-
};
|
|
20
|
-
let config = { ...DEFAULT_CONFIG };
|
|
21
|
-
const activeSpans = new Map();
|
|
22
|
-
const completedSpans = [];
|
|
23
|
-
const metrics = [];
|
|
24
|
-
let exportInterval = null;
|
|
25
|
-
/** Null trace ID sentinel for unsampled spans */
|
|
26
|
-
const NULL_TRACE_ID = '0'.repeat(32);
|
|
27
|
-
// --- Trace Context (W3C traceparent) ---
|
|
28
|
-
/**
|
|
29
|
-
* Generate a new trace ID (32 hex chars)
|
|
30
|
-
*/
|
|
31
|
-
function generateTraceId() {
|
|
32
|
-
return randomBytes(16).toString('hex');
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Generate a new span ID (16 hex chars)
|
|
36
|
-
*/
|
|
37
|
-
function generateSpanId() {
|
|
38
|
-
return randomBytes(8).toString('hex');
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Parse W3C traceparent header.
|
|
42
|
-
* Format: version-traceId-parentId-traceFlags
|
|
43
|
-
* Example: 00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01
|
|
44
|
-
*/
|
|
45
|
-
export function parseTraceparent(header) {
|
|
46
|
-
const parts = header.split('-');
|
|
47
|
-
if (parts.length !== 4)
|
|
48
|
-
return null;
|
|
49
|
-
if (parts[0] !== '00')
|
|
50
|
-
return null; // Only version 00
|
|
51
|
-
if (parts[1].length !== 32 || parts[2].length !== 16)
|
|
52
|
-
return null;
|
|
53
|
-
return {
|
|
54
|
-
traceId: parts[1],
|
|
55
|
-
spanId: parts[2],
|
|
56
|
-
traceFlags: parseInt(parts[3], 16),
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Format W3C traceparent header
|
|
61
|
-
*/
|
|
62
|
-
export function formatTraceparent(ctx) {
|
|
63
|
-
return `00-${ctx.traceId}-${ctx.spanId}-${ctx.traceFlags.toString(16).padStart(2, '0')}`;
|
|
64
|
-
}
|
|
65
|
-
// --- Span Operations ---
|
|
66
|
-
/**
|
|
67
|
-
* Start a new span
|
|
68
|
-
*/
|
|
69
|
-
export function startSpan(name, options = {}) {
|
|
70
|
-
// Return a no-op span when disabled or not sampled
|
|
71
|
-
if (!config.enabled || Math.random() > config.sampleRate) {
|
|
72
|
-
return {
|
|
73
|
-
traceId: NULL_TRACE_ID,
|
|
74
|
-
spanId: '0'.repeat(16),
|
|
75
|
-
name,
|
|
76
|
-
kind: 'internal',
|
|
77
|
-
startTime: Date.now(),
|
|
78
|
-
status: 'unset',
|
|
79
|
-
attributes: {},
|
|
80
|
-
events: [],
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
const span = {
|
|
84
|
-
traceId: options.traceId ?? generateTraceId(),
|
|
85
|
-
spanId: generateSpanId(),
|
|
86
|
-
parentSpanId: options.parentSpanId,
|
|
87
|
-
name,
|
|
88
|
-
kind: options.kind ?? 'internal',
|
|
89
|
-
startTime: Date.now(),
|
|
90
|
-
status: 'unset',
|
|
91
|
-
attributes: options.attributes ?? {},
|
|
92
|
-
events: [],
|
|
93
|
-
};
|
|
94
|
-
activeSpans.set(span.spanId, span);
|
|
95
|
-
return span;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* End a span and record its duration
|
|
99
|
-
*/
|
|
100
|
-
export function endSpan(span, status) {
|
|
101
|
-
span.endTime = Date.now();
|
|
102
|
-
span.status = status ?? 'ok';
|
|
103
|
-
activeSpans.delete(span.spanId);
|
|
104
|
-
// Only store sampled spans
|
|
105
|
-
if (span.traceId !== NULL_TRACE_ID) {
|
|
106
|
-
completedSpans.push(span);
|
|
107
|
-
// Evict oldest if buffer full
|
|
108
|
-
while (completedSpans.length > config.maxSpans) {
|
|
109
|
-
completedSpans.shift();
|
|
110
|
-
}
|
|
111
|
-
// Record duration metric
|
|
112
|
-
recordMetric('span.duration_ms', span.endTime - span.startTime, {
|
|
113
|
-
name: span.name,
|
|
114
|
-
kind: span.kind,
|
|
115
|
-
status: span.status,
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Add an event to a span
|
|
121
|
-
*/
|
|
122
|
-
export function addSpanEvent(span, name, attributes) {
|
|
123
|
-
span.events.push({ name, timestamp: Date.now(), attributes });
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Set a span attribute
|
|
127
|
-
*/
|
|
128
|
-
export function setSpanAttribute(span, key, value) {
|
|
129
|
-
span.attributes[key] = value;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Convenience: trace an async function execution as a span
|
|
133
|
-
*/
|
|
134
|
-
export async function trace(name, fn, options) {
|
|
135
|
-
const span = startSpan(name, options);
|
|
136
|
-
try {
|
|
137
|
-
const result = await fn(span);
|
|
138
|
-
endSpan(span, 'ok');
|
|
139
|
-
return result;
|
|
140
|
-
}
|
|
141
|
-
catch (error) {
|
|
142
|
-
span.attributes['error.message'] = error instanceof Error ? error.message : String(error);
|
|
143
|
-
span.attributes['error.type'] = error instanceof Error ? error.constructor.name : 'unknown';
|
|
144
|
-
endSpan(span, 'error');
|
|
145
|
-
throw error;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
// --- Metrics ---
|
|
149
|
-
/**
|
|
150
|
-
* Record a metric point
|
|
151
|
-
*/
|
|
152
|
-
export function recordMetric(name, value, labels = {}) {
|
|
153
|
-
if (!config.enabled)
|
|
154
|
-
return;
|
|
155
|
-
metrics.push({ name, value, labels, timestamp: Date.now() });
|
|
156
|
-
// Evict old metrics (keep last 5000)
|
|
157
|
-
while (metrics.length > 5000) {
|
|
158
|
-
metrics.shift();
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Increment a counter metric by 1
|
|
163
|
-
*/
|
|
164
|
-
export function incrementCounter(name, labels = {}) {
|
|
165
|
-
recordMetric(name, 1, labels);
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Get a snapshot of current diagnostics state
|
|
169
|
-
*/
|
|
170
|
-
export function getDiagnostics() {
|
|
171
|
-
// Summarize the 20 most recent completed spans
|
|
172
|
-
const recentSpans = completedSpans.slice(-20).map(s => ({
|
|
173
|
-
name: s.name,
|
|
174
|
-
durationMs: (s.endTime ?? Date.now()) - s.startTime,
|
|
175
|
-
status: s.status,
|
|
176
|
-
traceId: s.traceId,
|
|
177
|
-
}));
|
|
178
|
-
// Aggregate metrics by name
|
|
179
|
-
const metricsSummary = {};
|
|
180
|
-
for (const m of metrics) {
|
|
181
|
-
if (!metricsSummary[m.name]) {
|
|
182
|
-
metricsSummary[m.name] = { count: 0, avg: 0, min: Infinity, max: -Infinity };
|
|
183
|
-
}
|
|
184
|
-
const s = metricsSummary[m.name];
|
|
185
|
-
s.avg = (s.avg * s.count + m.value) / (s.count + 1);
|
|
186
|
-
s.count += 1;
|
|
187
|
-
s.min = Math.min(s.min, m.value);
|
|
188
|
-
s.max = Math.max(s.max, m.value);
|
|
189
|
-
}
|
|
190
|
-
// Omit exporter (not serialisable) from config snapshot
|
|
191
|
-
const { exporter: _exporter, ...configWithoutExporter } = config;
|
|
192
|
-
return {
|
|
193
|
-
activeSpans: activeSpans.size,
|
|
194
|
-
completedSpans: completedSpans.length,
|
|
195
|
-
metricsCount: metrics.length,
|
|
196
|
-
config: configWithoutExporter,
|
|
197
|
-
recentSpans,
|
|
198
|
-
metricsSummary,
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Get all completed spans belonging to a specific trace
|
|
203
|
-
*/
|
|
204
|
-
export function getTraceSpans(traceId) {
|
|
205
|
-
return completedSpans.filter(s => s.traceId === traceId);
|
|
206
|
-
}
|
|
207
|
-
// --- Configuration ---
|
|
208
|
-
/**
|
|
209
|
-
* Configure the diagnostics system.
|
|
210
|
-
* Restarts the export interval if the interval or exporter changed.
|
|
211
|
-
*/
|
|
212
|
-
export function configureDiagnostics(newConfig) {
|
|
213
|
-
config = { ...config, ...newConfig };
|
|
214
|
-
// Restart export interval
|
|
215
|
-
if (exportInterval) {
|
|
216
|
-
clearInterval(exportInterval);
|
|
217
|
-
exportInterval = null;
|
|
218
|
-
}
|
|
219
|
-
if (config.enabled && config.exporter) {
|
|
220
|
-
exportInterval = setInterval(() => {
|
|
221
|
-
exportSpans().catch((err) => {
|
|
222
|
-
logger.warn('[Diagnostics] Export failed', {
|
|
223
|
-
error: err instanceof Error ? err.message : String(err),
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
}, config.exportIntervalMs);
|
|
227
|
-
}
|
|
228
|
-
logger.info('[Diagnostics] Configuration updated', {
|
|
229
|
-
enabled: config.enabled,
|
|
230
|
-
sampleRate: config.sampleRate,
|
|
231
|
-
maxSpans: config.maxSpans,
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Flush and export all completed spans via the configured exporter
|
|
236
|
-
*/
|
|
237
|
-
async function exportSpans() {
|
|
238
|
-
if (!config.exporter || completedSpans.length === 0)
|
|
239
|
-
return;
|
|
240
|
-
const toExport = completedSpans.splice(0, completedSpans.length);
|
|
241
|
-
await config.exporter.export(toExport);
|
|
242
|
-
logger.debug('[Diagnostics] Exported spans', { count: toExport.length });
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* Stop the diagnostics system and clear all buffers
|
|
246
|
-
*/
|
|
247
|
-
export function stopDiagnostics() {
|
|
248
|
-
if (exportInterval) {
|
|
249
|
-
clearInterval(exportInterval);
|
|
250
|
-
exportInterval = null;
|
|
251
|
-
}
|
|
252
|
-
activeSpans.clear();
|
|
253
|
-
completedSpans.length = 0;
|
|
254
|
-
metrics.length = 0;
|
|
255
|
-
logger.info('[Diagnostics] Stopped');
|
|
256
|
-
}
|
|
257
|
-
//# sourceMappingURL=tracer.js.map
|
package/dist/discovery/index.js
DELETED
package/dist/discovery/mdns.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* mDNS/DNS-SD Local Discovery
|
|
3
|
-
*
|
|
4
|
-
* Announces profClaw instance on the local network using multicast DNS.
|
|
5
|
-
* Enables automatic discovery of profClaw nodes on the LAN.
|
|
6
|
-
* Uses Node.js dgram (UDP) - no external dependencies.
|
|
7
|
-
*/
|
|
8
|
-
export interface MDNSConfig {
|
|
9
|
-
serviceName?: string;
|
|
10
|
-
serviceType?: string;
|
|
11
|
-
port: number;
|
|
12
|
-
instanceName?: string;
|
|
13
|
-
txtRecords?: Record<string, string>;
|
|
14
|
-
}
|
|
15
|
-
interface DiscoveredNode {
|
|
16
|
-
name: string;
|
|
17
|
-
host: string;
|
|
18
|
-
port: number;
|
|
19
|
-
addresses: string[];
|
|
20
|
-
txt: Record<string, string>;
|
|
21
|
-
lastSeen: number;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Start mDNS announcement
|
|
25
|
-
*/
|
|
26
|
-
export declare function startMDNS(config: MDNSConfig): void;
|
|
27
|
-
/**
|
|
28
|
-
* Stop mDNS announcement
|
|
29
|
-
*/
|
|
30
|
-
export declare function stopMDNS(): void;
|
|
31
|
-
/**
|
|
32
|
-
* Get list of discovered profClaw nodes on the network
|
|
33
|
-
*/
|
|
34
|
-
export declare function getDiscoveredNodes(): DiscoveredNode[];
|
|
35
|
-
/**
|
|
36
|
-
* Check if mDNS is currently running
|
|
37
|
-
*/
|
|
38
|
-
export declare function isMDNSRunning(): boolean;
|
|
39
|
-
export {};
|
|
40
|
-
//# sourceMappingURL=mdns.d.ts.map
|