@probelabs/probe 0.6.0-rc135 → 0.6.0-rc136
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/build/agent/index.js +82351 -215
- package/build/agent/schemaUtils.js +5 -2
- package/build/agent/telemetry.js +3 -4
- package/build/index.js +7 -1
- package/cjs/agent/ProbeAgent.cjs +706 -662
- package/cjs/agent/simpleTelemetry.cjs +250 -0
- package/cjs/agent/telemetry.cjs +373 -0
- package/cjs/index.cjs +1283 -613
- package/index.d.ts +155 -0
- package/package.json +5 -1
- package/src/agent/schemaUtils.js +5 -2
- package/src/agent/telemetry.js +3 -4
- package/src/index.js +7 -1
package/index.d.ts
CHANGED
|
@@ -560,5 +560,160 @@ export interface ProbeAgentEvents {
|
|
|
560
560
|
removeAllListeners(event?: 'toolCall'): this;
|
|
561
561
|
}
|
|
562
562
|
|
|
563
|
+
/**
|
|
564
|
+
* Simple telemetry configuration (no OpenTelemetry dependencies)
|
|
565
|
+
*/
|
|
566
|
+
export interface SimpleTelemetryOptions {
|
|
567
|
+
/** Enable console logging */
|
|
568
|
+
enableConsole?: boolean;
|
|
569
|
+
/** Enable file logging */
|
|
570
|
+
enableFile?: boolean;
|
|
571
|
+
/** File path for logs */
|
|
572
|
+
filePath?: string;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* Simple telemetry class for basic tracing without OpenTelemetry
|
|
577
|
+
*/
|
|
578
|
+
export declare class SimpleTelemetry {
|
|
579
|
+
constructor(options?: SimpleTelemetryOptions);
|
|
580
|
+
log(message: string, data?: any): void;
|
|
581
|
+
flush(): Promise<void>;
|
|
582
|
+
shutdown(): Promise<void>;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* Simple application tracer for basic operations
|
|
587
|
+
*/
|
|
588
|
+
export declare class SimpleAppTracer {
|
|
589
|
+
constructor(telemetry?: SimpleTelemetry, sessionId?: string);
|
|
590
|
+
isEnabled(): boolean;
|
|
591
|
+
log(operation: string, data?: any): void;
|
|
592
|
+
flush(): Promise<void>;
|
|
593
|
+
shutdown(): Promise<void>;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* Initialize simple telemetry from options
|
|
598
|
+
*/
|
|
599
|
+
export declare function initializeSimpleTelemetryFromOptions(options: any): SimpleTelemetry;
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* Full OpenTelemetry configuration options
|
|
603
|
+
*/
|
|
604
|
+
export interface TelemetryConfigOptions {
|
|
605
|
+
/** Service name for tracing */
|
|
606
|
+
serviceName?: string;
|
|
607
|
+
/** Service version */
|
|
608
|
+
serviceVersion?: string;
|
|
609
|
+
/** Enable file export */
|
|
610
|
+
enableFile?: boolean;
|
|
611
|
+
/** Enable remote OTLP export */
|
|
612
|
+
enableRemote?: boolean;
|
|
613
|
+
/** Enable console export */
|
|
614
|
+
enableConsole?: boolean;
|
|
615
|
+
/** File path for trace export */
|
|
616
|
+
filePath?: string;
|
|
617
|
+
/** Remote OTLP endpoint URL */
|
|
618
|
+
remoteEndpoint?: string;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* Full OpenTelemetry configuration class
|
|
623
|
+
*/
|
|
624
|
+
export declare class TelemetryConfig {
|
|
625
|
+
constructor(options?: TelemetryConfigOptions);
|
|
626
|
+
|
|
627
|
+
/** Initialize the OpenTelemetry SDK */
|
|
628
|
+
initialize(): void;
|
|
629
|
+
|
|
630
|
+
/** Get the tracer instance */
|
|
631
|
+
getTracer(): any;
|
|
632
|
+
|
|
633
|
+
/** Create a span with attributes */
|
|
634
|
+
createSpan(name: string, attributes?: Record<string, any>): any;
|
|
635
|
+
|
|
636
|
+
/** Wrap a function with automatic span creation */
|
|
637
|
+
wrapFunction(name: string, fn: Function, attributes?: Record<string, any>): Function;
|
|
638
|
+
|
|
639
|
+
/** Force flush all pending spans */
|
|
640
|
+
forceFlush(): Promise<void>;
|
|
641
|
+
|
|
642
|
+
/** Shutdown telemetry */
|
|
643
|
+
shutdown(): Promise<void>;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* Application-specific tracing layer for AI operations
|
|
648
|
+
*/
|
|
649
|
+
export declare class AppTracer {
|
|
650
|
+
constructor(telemetryConfig?: TelemetryConfig, sessionId?: string);
|
|
651
|
+
|
|
652
|
+
/** Check if tracing is enabled */
|
|
653
|
+
isEnabled(): boolean;
|
|
654
|
+
|
|
655
|
+
/** Create a root span for the agent session */
|
|
656
|
+
createSessionSpan(attributes?: Record<string, any>): any;
|
|
657
|
+
|
|
658
|
+
/** Create a span for AI model requests */
|
|
659
|
+
createAISpan(modelName: string, provider: string, attributes?: Record<string, any>): any;
|
|
660
|
+
|
|
661
|
+
/** Create a span for tool calls */
|
|
662
|
+
createToolSpan(toolName: string, attributes?: Record<string, any>): any;
|
|
663
|
+
|
|
664
|
+
/** Create a span for code search operations */
|
|
665
|
+
createSearchSpan(query: string, attributes?: Record<string, any>): any;
|
|
666
|
+
|
|
667
|
+
/** Create a span for code extraction operations */
|
|
668
|
+
createExtractSpan(files: string | string[], attributes?: Record<string, any>): any;
|
|
669
|
+
|
|
670
|
+
/** Create a span for agent iterations */
|
|
671
|
+
createIterationSpan(iteration: number, attributes?: Record<string, any>): any;
|
|
672
|
+
|
|
673
|
+
/** Create a span for delegation operations */
|
|
674
|
+
createDelegationSpan(task: string, attributes?: Record<string, any>): any;
|
|
675
|
+
|
|
676
|
+
/** Create a span for JSON validation operations */
|
|
677
|
+
createJsonValidationSpan(responseLength: number, attributes?: Record<string, any>): any;
|
|
678
|
+
|
|
679
|
+
/** Create a span for Mermaid validation operations */
|
|
680
|
+
createMermaidValidationSpan(diagramCount: number, attributes?: Record<string, any>): any;
|
|
681
|
+
|
|
682
|
+
/** Create a span for schema processing operations */
|
|
683
|
+
createSchemaProcessingSpan(schemaType: string, attributes?: Record<string, any>): any;
|
|
684
|
+
|
|
685
|
+
/** Record delegation events */
|
|
686
|
+
recordDelegationEvent(eventType: string, data?: Record<string, any>): void;
|
|
687
|
+
|
|
688
|
+
/** Record JSON validation events */
|
|
689
|
+
recordJsonValidationEvent(eventType: string, data?: Record<string, any>): void;
|
|
690
|
+
|
|
691
|
+
/** Record Mermaid validation events */
|
|
692
|
+
recordMermaidValidationEvent(eventType: string, data?: Record<string, any>): void;
|
|
693
|
+
|
|
694
|
+
/** Add an event to the current span */
|
|
695
|
+
addEvent(name: string, attributes?: Record<string, any>): void;
|
|
696
|
+
|
|
697
|
+
/** Set attributes on the current span */
|
|
698
|
+
setAttributes(attributes: Record<string, any>): void;
|
|
699
|
+
|
|
700
|
+
/** Wrap a function with automatic span creation */
|
|
701
|
+
wrapFunction(spanName: string, fn: Function, attributes?: Record<string, any>): Function;
|
|
702
|
+
|
|
703
|
+
/** Execute a function within a span context */
|
|
704
|
+
withSpan(spanName: string, fn: Function, attributes?: Record<string, any>): Promise<any>;
|
|
705
|
+
|
|
706
|
+
/** Force flush all pending spans */
|
|
707
|
+
flush(): Promise<void>;
|
|
708
|
+
|
|
709
|
+
/** Shutdown tracing */
|
|
710
|
+
shutdown(): Promise<void>;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* Initialize full OpenTelemetry telemetry from options
|
|
715
|
+
*/
|
|
716
|
+
export declare function initializeTelemetryFromOptions(options: any): TelemetryConfig;
|
|
717
|
+
|
|
563
718
|
// Default export for ES modules
|
|
564
719
|
export { ProbeAgent as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@probelabs/probe",
|
|
3
|
-
"version": "0.6.0-
|
|
3
|
+
"version": "0.6.0-rc136",
|
|
4
4
|
"description": "Node.js wrapper for the probe code search tool",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -21,6 +21,10 @@
|
|
|
21
21
|
"import": "./src/agent/simpleTelemetry.js",
|
|
22
22
|
"require": "./cjs/agent/simpleTelemetry.cjs"
|
|
23
23
|
},
|
|
24
|
+
"./telemetry/full": {
|
|
25
|
+
"import": "./src/agent/telemetry.js",
|
|
26
|
+
"require": "./cjs/agent/telemetry.cjs"
|
|
27
|
+
},
|
|
24
28
|
"./agent/mcp": {
|
|
25
29
|
"import": "./src/agent/mcp/index.js"
|
|
26
30
|
}
|
package/src/agent/schemaUtils.js
CHANGED
|
@@ -765,6 +765,9 @@ Ensure all Mermaid diagrams are properly formatted within \`\`\`mermaid code blo
|
|
|
765
765
|
return prompt;
|
|
766
766
|
}
|
|
767
767
|
|
|
768
|
+
// Counter to ensure unique session IDs even when created in the same millisecond
|
|
769
|
+
let sessionIdCounter = 0;
|
|
770
|
+
|
|
768
771
|
/**
|
|
769
772
|
* Specialized JSON fixing agent
|
|
770
773
|
* Uses a separate ProbeAgent instance optimized for JSON syntax correction
|
|
@@ -774,7 +777,7 @@ export class JsonFixingAgent {
|
|
|
774
777
|
// Import ProbeAgent dynamically to avoid circular dependencies
|
|
775
778
|
this.ProbeAgent = null;
|
|
776
779
|
this.options = {
|
|
777
|
-
sessionId: options.sessionId || `json-fixer-${Date.now()}`,
|
|
780
|
+
sessionId: options.sessionId || `json-fixer-${Date.now()}-${sessionIdCounter++}`,
|
|
778
781
|
path: options.path || process.cwd(),
|
|
779
782
|
provider: options.provider,
|
|
780
783
|
model: options.model,
|
|
@@ -1001,7 +1004,7 @@ export class MermaidFixingAgent {
|
|
|
1001
1004
|
// Import ProbeAgent dynamically to avoid circular dependencies
|
|
1002
1005
|
this.ProbeAgent = null;
|
|
1003
1006
|
this.options = {
|
|
1004
|
-
sessionId: options.sessionId || `mermaid-fixer-${Date.now()}`,
|
|
1007
|
+
sessionId: options.sessionId || `mermaid-fixer-${Date.now()}-${sessionIdCounter++}`,
|
|
1005
1008
|
path: options.path || process.cwd(),
|
|
1006
1009
|
provider: options.provider,
|
|
1007
1010
|
model: options.model,
|
package/src/agent/telemetry.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import nodeSDKPkg from '@opentelemetry/sdk-node';
|
|
2
2
|
import resourcesPkg from '@opentelemetry/resources';
|
|
3
|
-
import
|
|
3
|
+
import { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION } from '@opentelemetry/semantic-conventions';
|
|
4
4
|
import { trace, context, SpanStatusCode } from '@opentelemetry/api';
|
|
5
5
|
import otlpPkg from '@opentelemetry/exporter-trace-otlp-http';
|
|
6
6
|
import spanPkg from '@opentelemetry/sdk-trace-base';
|
|
@@ -10,8 +10,7 @@ import { dirname } from 'path';
|
|
|
10
10
|
import { FileSpanExporter } from './fileSpanExporter.js';
|
|
11
11
|
|
|
12
12
|
const { NodeSDK } = nodeSDKPkg;
|
|
13
|
-
const {
|
|
14
|
-
const { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION } = semanticConventionsPkg;
|
|
13
|
+
const { Resource } = resourcesPkg;
|
|
15
14
|
const { OTLPTraceExporter } = otlpPkg;
|
|
16
15
|
const { BatchSpanProcessor, ConsoleSpanExporter } = spanPkg;
|
|
17
16
|
|
|
@@ -40,7 +39,7 @@ export class TelemetryConfig {
|
|
|
40
39
|
return;
|
|
41
40
|
}
|
|
42
41
|
|
|
43
|
-
const resource =
|
|
42
|
+
const resource = new Resource({
|
|
44
43
|
[ATTR_SERVICE_NAME]: this.serviceName,
|
|
45
44
|
[ATTR_SERVICE_VERSION]: this.serviceVersion,
|
|
46
45
|
});
|
package/src/index.js
CHANGED
|
@@ -35,6 +35,8 @@ import { searchTool, queryTool, extractTool, delegateTool } from './tools/vercel
|
|
|
35
35
|
import { bashTool } from './tools/bash.js';
|
|
36
36
|
import { ProbeAgent } from './agent/ProbeAgent.js';
|
|
37
37
|
import { SimpleTelemetry, SimpleAppTracer, initializeSimpleTelemetryFromOptions } from './agent/simpleTelemetry.js';
|
|
38
|
+
import { TelemetryConfig, initializeTelemetryFromOptions } from './agent/telemetry.js';
|
|
39
|
+
import { AppTracer } from './agent/appTracer.js';
|
|
38
40
|
import { listFilesToolInstance, searchFilesToolInstance } from './agent/probeTool.js';
|
|
39
41
|
import { StorageAdapter, InMemoryStorageAdapter } from './agent/storage/index.js';
|
|
40
42
|
import { HookManager, HOOK_TYPES } from './agent/hooks/index.js';
|
|
@@ -58,10 +60,14 @@ export {
|
|
|
58
60
|
// Export hooks
|
|
59
61
|
HookManager,
|
|
60
62
|
HOOK_TYPES,
|
|
61
|
-
// Export telemetry classes
|
|
63
|
+
// Export simple telemetry classes (no OpenTelemetry dependencies)
|
|
62
64
|
SimpleTelemetry,
|
|
63
65
|
SimpleAppTracer,
|
|
64
66
|
initializeSimpleTelemetryFromOptions,
|
|
67
|
+
// Export full OpenTelemetry telemetry classes
|
|
68
|
+
TelemetryConfig,
|
|
69
|
+
AppTracer,
|
|
70
|
+
initializeTelemetryFromOptions,
|
|
65
71
|
// Export tool generators directly
|
|
66
72
|
searchTool,
|
|
67
73
|
queryTool,
|