@prefactor/core 0.1.1 → 0.2.1
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 +35 -2
- package/dist/agent/instance-manager.d.ts +16 -0
- package/dist/agent/instance-manager.d.ts.map +1 -0
- package/dist/agent/instance-manager.js +50 -0
- package/dist/agent/instance-manager.js.map +1 -0
- package/dist/config.d.ts +28 -52
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +33 -18
- package/dist/config.js.map +1 -1
- package/dist/create-core.d.ts +10 -0
- package/dist/create-core.d.ts.map +1 -0
- package/dist/create-core.js +31 -0
- package/dist/create-core.js.map +1 -0
- package/dist/index.cjs +632 -256
- package/dist/index.cjs.map +18 -11
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +633 -257
- package/dist/index.js.map +18 -11
- package/dist/queue/actions.d.ts +24 -0
- package/dist/queue/actions.d.ts.map +1 -0
- package/dist/queue/actions.js +2 -0
- package/dist/queue/actions.js.map +1 -0
- package/dist/queue/base.d.ts +19 -0
- package/dist/queue/base.d.ts.map +1 -0
- package/dist/{transport → queue}/base.js.map +1 -1
- package/dist/queue/in-memory-queue.d.ts +11 -0
- package/dist/queue/in-memory-queue.d.ts.map +1 -0
- package/dist/queue/in-memory-queue.js +46 -0
- package/dist/queue/in-memory-queue.js.map +1 -0
- package/dist/queue/task-executor.d.ts +18 -0
- package/dist/queue/task-executor.d.ts.map +1 -0
- package/dist/queue/task-executor.js +77 -0
- package/dist/queue/task-executor.js.map +1 -0
- package/dist/tracing/context.d.ts +12 -0
- package/dist/tracing/context.d.ts.map +1 -1
- package/dist/tracing/context.js +41 -5
- package/dist/tracing/context.js.map +1 -1
- package/dist/tracing/span.d.ts +7 -9
- package/dist/tracing/span.d.ts.map +1 -1
- package/dist/tracing/span.js +6 -8
- package/dist/tracing/span.js.map +1 -1
- package/dist/tracing/tracer.d.ts +5 -16
- package/dist/tracing/tracer.d.ts.map +1 -1
- package/dist/tracing/tracer.js +22 -26
- package/dist/tracing/tracer.js.map +1 -1
- package/dist/transport/http/agent-instance-client.d.ts +23 -0
- package/dist/transport/http/agent-instance-client.d.ts.map +1 -0
- package/dist/transport/http/agent-instance-client.js +25 -0
- package/dist/transport/http/agent-instance-client.js.map +1 -0
- package/dist/transport/http/agent-span-client.d.ts +25 -0
- package/dist/transport/http/agent-span-client.d.ts.map +1 -0
- package/dist/transport/http/agent-span-client.js +37 -0
- package/dist/transport/http/agent-span-client.js.map +1 -0
- package/dist/transport/http/http-client.d.ts +43 -0
- package/dist/transport/http/http-client.d.ts.map +1 -0
- package/dist/transport/http/http-client.js +127 -0
- package/dist/transport/http/http-client.js.map +1 -0
- package/dist/transport/http/retry-policy.d.ts +4 -0
- package/dist/transport/http/retry-policy.d.ts.map +1 -0
- package/dist/transport/http/retry-policy.js +10 -0
- package/dist/transport/http/retry-policy.js.map +1 -0
- package/dist/transport/http.d.ts +30 -72
- package/dist/transport/http.d.ts.map +1 -1
- package/dist/transport/http.js +146 -269
- package/dist/transport/http.js.map +1 -1
- package/dist/utils/logging.d.ts.map +1 -1
- package/dist/utils/logging.js +7 -1
- package/dist/utils/logging.js.map +1 -1
- package/package.json +1 -1
- package/dist/transport/base.d.ts +0 -38
- package/dist/transport/base.d.ts.map +0 -1
- package/dist/transport/stdio.d.ts +0 -48
- package/dist/transport/stdio.d.ts.map +0 -1
- package/dist/transport/stdio.js +0 -71
- package/dist/transport/stdio.js.map +0 -1
- /package/dist/{transport → queue}/base.js +0 -0
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ npm install @prefactor/core
|
|
|
10
10
|
bun add @prefactor/core
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
This package is used as a foundation for framework-specific integrations like `@prefactor/langchain` and `@prefactor/ai`.
|
|
14
14
|
|
|
15
15
|
## When to Use This Package
|
|
16
16
|
|
|
@@ -20,7 +20,7 @@ Use `@prefactor/core` directly when:
|
|
|
20
20
|
- You need manual instrumentation without LangChain.js
|
|
21
21
|
- You're implementing your own middleware or transport
|
|
22
22
|
|
|
23
|
-
For LangChain.js applications, use `@prefactor/
|
|
23
|
+
For LangChain.js applications, use `@prefactor/langchain` for automatic instrumentation.
|
|
24
24
|
|
|
25
25
|
## Exports
|
|
26
26
|
|
|
@@ -55,6 +55,8 @@ import {
|
|
|
55
55
|
type Span,
|
|
56
56
|
type TokenUsage,
|
|
57
57
|
type ErrorInfo,
|
|
58
|
+
type StartSpanOptions,
|
|
59
|
+
type EndSpanOptions,
|
|
58
60
|
} from '@prefactor/core';
|
|
59
61
|
```
|
|
60
62
|
|
|
@@ -79,6 +81,37 @@ import {
|
|
|
79
81
|
} from '@prefactor/core';
|
|
80
82
|
```
|
|
81
83
|
|
|
84
|
+
### Core Runtime
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
import {
|
|
88
|
+
type CoreRuntime,
|
|
89
|
+
createCore,
|
|
90
|
+
} from '@prefactor/core';
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Agent Management
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
import {
|
|
97
|
+
AgentInstanceManager,
|
|
98
|
+
SchemaRegistry,
|
|
99
|
+
} from '@prefactor/core';
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Queue
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
import {
|
|
106
|
+
type Queue,
|
|
107
|
+
InMemoryQueue,
|
|
108
|
+
type QueueAction,
|
|
109
|
+
type AgentInstanceStart,
|
|
110
|
+
type AgentInstanceFinish,
|
|
111
|
+
type SchemaRegistration,
|
|
112
|
+
} from '@prefactor/core';
|
|
113
|
+
```
|
|
114
|
+
|
|
82
115
|
## Usage
|
|
83
116
|
|
|
84
117
|
### Manual Instrumentation
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AgentInstanceOptions, Transport } from '../transport/http.js';
|
|
2
|
+
export type AgentInstanceManagerOptions = {
|
|
3
|
+
allowUnregisteredSchema?: boolean;
|
|
4
|
+
};
|
|
5
|
+
type AgentInstanceStartOptions = AgentInstanceOptions;
|
|
6
|
+
export declare class AgentInstanceManager {
|
|
7
|
+
private transport;
|
|
8
|
+
private options;
|
|
9
|
+
private registeredSchema;
|
|
10
|
+
constructor(transport: Transport, options: AgentInstanceManagerOptions);
|
|
11
|
+
registerSchema(schema: Record<string, unknown>): void;
|
|
12
|
+
startInstance(options?: AgentInstanceStartOptions): void;
|
|
13
|
+
finishInstance(): void;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=instance-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instance-manager.d.ts","sourceRoot":"","sources":["../../src/agent/instance-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAE5E,MAAM,MAAM,2BAA2B,GAAG;IACxC,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC,CAAC;AAEF,KAAK,yBAAyB,GAAG,oBAAoB,CAAC;AAEtD,qBAAa,oBAAoB;IAI7B,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,OAAO;IAJjB,OAAO,CAAC,gBAAgB,CAAwC;gBAGtD,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,2BAA2B;IAG9C,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAgBrD,aAAa,CAAC,OAAO,GAAE,yBAA8B,GAAG,IAAI;IAS5D,cAAc,IAAI,IAAI;CAGvB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export class AgentInstanceManager {
|
|
2
|
+
transport;
|
|
3
|
+
options;
|
|
4
|
+
registeredSchema = null;
|
|
5
|
+
constructor(transport, options) {
|
|
6
|
+
this.transport = transport;
|
|
7
|
+
this.options = options;
|
|
8
|
+
}
|
|
9
|
+
registerSchema(schema) {
|
|
10
|
+
if (this.registeredSchema === null) {
|
|
11
|
+
this.registeredSchema = schema;
|
|
12
|
+
this.transport.registerSchema(schema);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const existingSchema = stableStringify(this.registeredSchema);
|
|
16
|
+
const incomingSchema = stableStringify(schema);
|
|
17
|
+
if (existingSchema !== incomingSchema) {
|
|
18
|
+
console.warn('A different schema was provided after registration; ignoring subsequent schema.');
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
startInstance(options = {}) {
|
|
22
|
+
if (!this.options.allowUnregisteredSchema && this.registeredSchema === null) {
|
|
23
|
+
console.warn('Schema must be registered before starting an agent instance.');
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
this.transport.startAgentInstance(options);
|
|
27
|
+
}
|
|
28
|
+
finishInstance() {
|
|
29
|
+
this.transport.finishAgentInstance();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function stableStringify(value) {
|
|
33
|
+
return JSON.stringify(normalizeValue(value));
|
|
34
|
+
}
|
|
35
|
+
function normalizeValue(value) {
|
|
36
|
+
if (Array.isArray(value)) {
|
|
37
|
+
return value.map((entry) => normalizeValue(entry));
|
|
38
|
+
}
|
|
39
|
+
if (value && typeof value === 'object') {
|
|
40
|
+
const normalized = {};
|
|
41
|
+
const objectValue = value;
|
|
42
|
+
const keys = Object.keys(objectValue).sort((a, b) => a.localeCompare(b));
|
|
43
|
+
for (const key of keys) {
|
|
44
|
+
normalized[key] = normalizeValue(objectValue[key]);
|
|
45
|
+
}
|
|
46
|
+
return normalized;
|
|
47
|
+
}
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=instance-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instance-manager.js","sourceRoot":"","sources":["../../src/agent/instance-manager.ts"],"names":[],"mappings":"AAQA,MAAM,OAAO,oBAAoB;IAIrB;I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AAC,KAAK,CAAC,CAAC,CAAC;IACrD,CAAC;IAED,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACvC,MAAM,UAAU,GAA4B,EAAE,CAAC;QAC/C,MAAM,WAAW,GAAG,KAAgC,CAAC;QACrD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;QACzE,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,UAAU,CAAC,GAAG,CAAC,GAAG,cAAc,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;QACrD,CAAC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -7,24 +7,18 @@ export declare const HttpTransportConfigSchema: z.ZodObject<{
|
|
|
7
7
|
apiUrl: z.ZodString;
|
|
8
8
|
/** Authentication token */
|
|
9
9
|
apiToken: z.ZodString;
|
|
10
|
-
/** Optional agent identifier */
|
|
10
|
+
/** Optional agent instance identifier (internal ID) */
|
|
11
11
|
agentId: z.ZodOptional<z.ZodString>;
|
|
12
|
-
/**
|
|
13
|
-
|
|
12
|
+
/** Agent identifier (external identifier); defaults to v1.0.0 when omitted */
|
|
13
|
+
agentIdentifier: z.ZodDefault<z.ZodString>;
|
|
14
14
|
/** Optional agent name */
|
|
15
15
|
agentName: z.ZodOptional<z.ZodString>;
|
|
16
16
|
/** Optional agent description */
|
|
17
17
|
agentDescription: z.ZodOptional<z.ZodString>;
|
|
18
18
|
/** Optional agent schema for validation (full schema object) */
|
|
19
19
|
agentSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
20
|
-
/** Optional agent schema version identifier (string) */
|
|
21
|
-
agentSchemaVersion: z.ZodOptional<z.ZodString>;
|
|
22
|
-
/** Skip schema validation */
|
|
23
|
-
skipSchema: z.ZodDefault<z.ZodBoolean>;
|
|
24
20
|
/** Request timeout in milliseconds */
|
|
25
21
|
requestTimeout: z.ZodDefault<z.ZodNumber>;
|
|
26
|
-
/** Connection timeout in milliseconds */
|
|
27
|
-
connectTimeout: z.ZodDefault<z.ZodNumber>;
|
|
28
22
|
/** Maximum number of retry attempts */
|
|
29
23
|
maxRetries: z.ZodDefault<z.ZodNumber>;
|
|
30
24
|
/** Initial delay between retries in milliseconds */
|
|
@@ -33,38 +27,36 @@ export declare const HttpTransportConfigSchema: z.ZodObject<{
|
|
|
33
27
|
maxRetryDelay: z.ZodDefault<z.ZodNumber>;
|
|
34
28
|
/** Multiplier for exponential backoff */
|
|
35
29
|
retryMultiplier: z.ZodDefault<z.ZodNumber>;
|
|
30
|
+
/** Status codes that should trigger retries */
|
|
31
|
+
retryOnStatusCodes: z.ZodDefault<z.ZodArray<z.ZodNumber, "many">>;
|
|
36
32
|
}, "strip", z.ZodTypeAny, {
|
|
37
33
|
apiUrl: string;
|
|
38
34
|
apiToken: string;
|
|
39
|
-
|
|
35
|
+
agentIdentifier: string;
|
|
40
36
|
requestTimeout: number;
|
|
41
|
-
connectTimeout: number;
|
|
42
37
|
maxRetries: number;
|
|
43
38
|
initialRetryDelay: number;
|
|
44
39
|
maxRetryDelay: number;
|
|
45
40
|
retryMultiplier: number;
|
|
41
|
+
retryOnStatusCodes: number[];
|
|
46
42
|
agentId?: string | undefined;
|
|
47
|
-
agentVersion?: string | undefined;
|
|
48
43
|
agentName?: string | undefined;
|
|
49
44
|
agentDescription?: string | undefined;
|
|
50
45
|
agentSchema?: Record<string, unknown> | undefined;
|
|
51
|
-
agentSchemaVersion?: string | undefined;
|
|
52
46
|
}, {
|
|
53
47
|
apiUrl: string;
|
|
54
48
|
apiToken: string;
|
|
55
49
|
agentId?: string | undefined;
|
|
56
|
-
|
|
50
|
+
agentIdentifier?: string | undefined;
|
|
57
51
|
agentName?: string | undefined;
|
|
58
52
|
agentDescription?: string | undefined;
|
|
59
53
|
agentSchema?: Record<string, unknown> | undefined;
|
|
60
|
-
agentSchemaVersion?: string | undefined;
|
|
61
|
-
skipSchema?: boolean | undefined;
|
|
62
54
|
requestTimeout?: number | undefined;
|
|
63
|
-
connectTimeout?: number | undefined;
|
|
64
55
|
maxRetries?: number | undefined;
|
|
65
56
|
initialRetryDelay?: number | undefined;
|
|
66
57
|
maxRetryDelay?: number | undefined;
|
|
67
58
|
retryMultiplier?: number | undefined;
|
|
59
|
+
retryOnStatusCodes?: number[] | undefined;
|
|
68
60
|
}>;
|
|
69
61
|
export type HttpTransportConfig = z.infer<typeof HttpTransportConfigSchema>;
|
|
70
62
|
/**
|
|
@@ -74,50 +66,44 @@ export declare const PartialHttpConfigSchema: z.ZodObject<{
|
|
|
74
66
|
apiUrl: z.ZodString;
|
|
75
67
|
apiToken: z.ZodString;
|
|
76
68
|
agentId: z.ZodOptional<z.ZodString>;
|
|
77
|
-
|
|
69
|
+
agentIdentifier: z.ZodOptional<z.ZodString>;
|
|
78
70
|
agentName: z.ZodOptional<z.ZodString>;
|
|
79
71
|
agentDescription: z.ZodOptional<z.ZodString>;
|
|
80
72
|
agentSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
81
|
-
agentSchemaVersion: z.ZodOptional<z.ZodString>;
|
|
82
|
-
skipSchema: z.ZodOptional<z.ZodBoolean>;
|
|
83
73
|
requestTimeout: z.ZodOptional<z.ZodNumber>;
|
|
84
|
-
connectTimeout: z.ZodOptional<z.ZodNumber>;
|
|
85
74
|
maxRetries: z.ZodOptional<z.ZodNumber>;
|
|
86
75
|
initialRetryDelay: z.ZodOptional<z.ZodNumber>;
|
|
87
76
|
maxRetryDelay: z.ZodOptional<z.ZodNumber>;
|
|
88
77
|
retryMultiplier: z.ZodOptional<z.ZodNumber>;
|
|
78
|
+
retryOnStatusCodes: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
89
79
|
}, "strip", z.ZodTypeAny, {
|
|
90
80
|
apiUrl: string;
|
|
91
81
|
apiToken: string;
|
|
92
82
|
agentId?: string | undefined;
|
|
93
|
-
|
|
83
|
+
agentIdentifier?: string | undefined;
|
|
94
84
|
agentName?: string | undefined;
|
|
95
85
|
agentDescription?: string | undefined;
|
|
96
86
|
agentSchema?: Record<string, unknown> | undefined;
|
|
97
|
-
agentSchemaVersion?: string | undefined;
|
|
98
|
-
skipSchema?: boolean | undefined;
|
|
99
87
|
requestTimeout?: number | undefined;
|
|
100
|
-
connectTimeout?: number | undefined;
|
|
101
88
|
maxRetries?: number | undefined;
|
|
102
89
|
initialRetryDelay?: number | undefined;
|
|
103
90
|
maxRetryDelay?: number | undefined;
|
|
104
91
|
retryMultiplier?: number | undefined;
|
|
92
|
+
retryOnStatusCodes?: number[] | undefined;
|
|
105
93
|
}, {
|
|
106
94
|
apiUrl: string;
|
|
107
95
|
apiToken: string;
|
|
108
96
|
agentId?: string | undefined;
|
|
109
|
-
|
|
97
|
+
agentIdentifier?: string | undefined;
|
|
110
98
|
agentName?: string | undefined;
|
|
111
99
|
agentDescription?: string | undefined;
|
|
112
100
|
agentSchema?: Record<string, unknown> | undefined;
|
|
113
|
-
agentSchemaVersion?: string | undefined;
|
|
114
|
-
skipSchema?: boolean | undefined;
|
|
115
101
|
requestTimeout?: number | undefined;
|
|
116
|
-
connectTimeout?: number | undefined;
|
|
117
102
|
maxRetries?: number | undefined;
|
|
118
103
|
initialRetryDelay?: number | undefined;
|
|
119
104
|
maxRetryDelay?: number | undefined;
|
|
120
105
|
retryMultiplier?: number | undefined;
|
|
106
|
+
retryOnStatusCodes?: number[] | undefined;
|
|
121
107
|
}>;
|
|
122
108
|
export type PartialHttpConfig = z.infer<typeof PartialHttpConfigSchema>;
|
|
123
109
|
/**
|
|
@@ -125,7 +111,7 @@ export type PartialHttpConfig = z.infer<typeof PartialHttpConfigSchema>;
|
|
|
125
111
|
*/
|
|
126
112
|
export declare const ConfigSchema: z.ZodObject<{
|
|
127
113
|
/** Transport type to use for span emission */
|
|
128
|
-
transportType: z.ZodDefault<z.ZodEnum<["
|
|
114
|
+
transportType: z.ZodDefault<z.ZodEnum<["http"]>>;
|
|
129
115
|
/** Sampling rate (0.0 to 1.0) */
|
|
130
116
|
sampleRate: z.ZodDefault<z.ZodNumber>;
|
|
131
117
|
/** Whether to capture span inputs */
|
|
@@ -141,53 +127,47 @@ export declare const ConfigSchema: z.ZodObject<{
|
|
|
141
127
|
apiUrl: z.ZodString;
|
|
142
128
|
apiToken: z.ZodString;
|
|
143
129
|
agentId: z.ZodOptional<z.ZodString>;
|
|
144
|
-
|
|
130
|
+
agentIdentifier: z.ZodOptional<z.ZodString>;
|
|
145
131
|
agentName: z.ZodOptional<z.ZodString>;
|
|
146
132
|
agentDescription: z.ZodOptional<z.ZodString>;
|
|
147
133
|
agentSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
148
|
-
agentSchemaVersion: z.ZodOptional<z.ZodString>;
|
|
149
|
-
skipSchema: z.ZodOptional<z.ZodBoolean>;
|
|
150
134
|
requestTimeout: z.ZodOptional<z.ZodNumber>;
|
|
151
|
-
connectTimeout: z.ZodOptional<z.ZodNumber>;
|
|
152
135
|
maxRetries: z.ZodOptional<z.ZodNumber>;
|
|
153
136
|
initialRetryDelay: z.ZodOptional<z.ZodNumber>;
|
|
154
137
|
maxRetryDelay: z.ZodOptional<z.ZodNumber>;
|
|
155
138
|
retryMultiplier: z.ZodOptional<z.ZodNumber>;
|
|
139
|
+
retryOnStatusCodes: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
156
140
|
}, "strip", z.ZodTypeAny, {
|
|
157
141
|
apiUrl: string;
|
|
158
142
|
apiToken: string;
|
|
159
143
|
agentId?: string | undefined;
|
|
160
|
-
|
|
144
|
+
agentIdentifier?: string | undefined;
|
|
161
145
|
agentName?: string | undefined;
|
|
162
146
|
agentDescription?: string | undefined;
|
|
163
147
|
agentSchema?: Record<string, unknown> | undefined;
|
|
164
|
-
agentSchemaVersion?: string | undefined;
|
|
165
|
-
skipSchema?: boolean | undefined;
|
|
166
148
|
requestTimeout?: number | undefined;
|
|
167
|
-
connectTimeout?: number | undefined;
|
|
168
149
|
maxRetries?: number | undefined;
|
|
169
150
|
initialRetryDelay?: number | undefined;
|
|
170
151
|
maxRetryDelay?: number | undefined;
|
|
171
152
|
retryMultiplier?: number | undefined;
|
|
153
|
+
retryOnStatusCodes?: number[] | undefined;
|
|
172
154
|
}, {
|
|
173
155
|
apiUrl: string;
|
|
174
156
|
apiToken: string;
|
|
175
157
|
agentId?: string | undefined;
|
|
176
|
-
|
|
158
|
+
agentIdentifier?: string | undefined;
|
|
177
159
|
agentName?: string | undefined;
|
|
178
160
|
agentDescription?: string | undefined;
|
|
179
161
|
agentSchema?: Record<string, unknown> | undefined;
|
|
180
|
-
agentSchemaVersion?: string | undefined;
|
|
181
|
-
skipSchema?: boolean | undefined;
|
|
182
162
|
requestTimeout?: number | undefined;
|
|
183
|
-
connectTimeout?: number | undefined;
|
|
184
163
|
maxRetries?: number | undefined;
|
|
185
164
|
initialRetryDelay?: number | undefined;
|
|
186
165
|
maxRetryDelay?: number | undefined;
|
|
187
166
|
retryMultiplier?: number | undefined;
|
|
167
|
+
retryOnStatusCodes?: number[] | undefined;
|
|
188
168
|
}>>;
|
|
189
169
|
}, "strip", z.ZodTypeAny, {
|
|
190
|
-
transportType: "
|
|
170
|
+
transportType: "http";
|
|
191
171
|
sampleRate: number;
|
|
192
172
|
captureInputs: boolean;
|
|
193
173
|
captureOutputs: boolean;
|
|
@@ -197,21 +177,19 @@ export declare const ConfigSchema: z.ZodObject<{
|
|
|
197
177
|
apiUrl: string;
|
|
198
178
|
apiToken: string;
|
|
199
179
|
agentId?: string | undefined;
|
|
200
|
-
|
|
180
|
+
agentIdentifier?: string | undefined;
|
|
201
181
|
agentName?: string | undefined;
|
|
202
182
|
agentDescription?: string | undefined;
|
|
203
183
|
agentSchema?: Record<string, unknown> | undefined;
|
|
204
|
-
agentSchemaVersion?: string | undefined;
|
|
205
|
-
skipSchema?: boolean | undefined;
|
|
206
184
|
requestTimeout?: number | undefined;
|
|
207
|
-
connectTimeout?: number | undefined;
|
|
208
185
|
maxRetries?: number | undefined;
|
|
209
186
|
initialRetryDelay?: number | undefined;
|
|
210
187
|
maxRetryDelay?: number | undefined;
|
|
211
188
|
retryMultiplier?: number | undefined;
|
|
189
|
+
retryOnStatusCodes?: number[] | undefined;
|
|
212
190
|
} | undefined;
|
|
213
191
|
}, {
|
|
214
|
-
transportType?: "
|
|
192
|
+
transportType?: "http" | undefined;
|
|
215
193
|
sampleRate?: number | undefined;
|
|
216
194
|
captureInputs?: boolean | undefined;
|
|
217
195
|
captureOutputs?: boolean | undefined;
|
|
@@ -221,18 +199,16 @@ export declare const ConfigSchema: z.ZodObject<{
|
|
|
221
199
|
apiUrl: string;
|
|
222
200
|
apiToken: string;
|
|
223
201
|
agentId?: string | undefined;
|
|
224
|
-
|
|
202
|
+
agentIdentifier?: string | undefined;
|
|
225
203
|
agentName?: string | undefined;
|
|
226
204
|
agentDescription?: string | undefined;
|
|
227
205
|
agentSchema?: Record<string, unknown> | undefined;
|
|
228
|
-
agentSchemaVersion?: string | undefined;
|
|
229
|
-
skipSchema?: boolean | undefined;
|
|
230
206
|
requestTimeout?: number | undefined;
|
|
231
|
-
connectTimeout?: number | undefined;
|
|
232
207
|
maxRetries?: number | undefined;
|
|
233
208
|
initialRetryDelay?: number | undefined;
|
|
234
209
|
maxRetryDelay?: number | undefined;
|
|
235
210
|
retryMultiplier?: number | undefined;
|
|
211
|
+
retryOnStatusCodes?: number[] | undefined;
|
|
236
212
|
} | undefined;
|
|
237
213
|
}>;
|
|
238
214
|
export type Config = z.infer<typeof ConfigSchema>;
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["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D"}
|
package/dist/config.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
const DEFAULT_RETRY_ON_STATUS_CODES = [
|
|
3
|
+
429,
|
|
4
|
+
...Array.from({ length: 100 }, (_, index) => 500 + index),
|
|
5
|
+
];
|
|
6
|
+
const HttpStatusCodeSchema = z.number().int().min(100).max(599);
|
|
2
7
|
/**
|
|
3
8
|
* Configuration schema for HTTP transport
|
|
4
9
|
*/
|
|
@@ -7,24 +12,18 @@ export const HttpTransportConfigSchema = z.object({
|
|
|
7
12
|
apiUrl: z.string().url(),
|
|
8
13
|
/** Authentication token */
|
|
9
14
|
apiToken: z.string().min(1),
|
|
10
|
-
/** Optional agent identifier */
|
|
15
|
+
/** Optional agent instance identifier (internal ID) */
|
|
11
16
|
agentId: z.string().optional(),
|
|
12
|
-
/**
|
|
13
|
-
|
|
17
|
+
/** Agent identifier (external identifier); defaults to v1.0.0 when omitted */
|
|
18
|
+
agentIdentifier: z.string().default('v1.0.0'),
|
|
14
19
|
/** Optional agent name */
|
|
15
20
|
agentName: z.string().optional(),
|
|
16
21
|
/** Optional agent description */
|
|
17
22
|
agentDescription: z.string().optional(),
|
|
18
23
|
/** Optional agent schema for validation (full schema object) */
|
|
19
24
|
agentSchema: z.record(z.unknown()).optional(),
|
|
20
|
-
/** Optional agent schema version identifier (string) */
|
|
21
|
-
agentSchemaVersion: z.string().optional(),
|
|
22
|
-
/** Skip schema validation */
|
|
23
|
-
skipSchema: z.boolean().default(false),
|
|
24
25
|
/** Request timeout in milliseconds */
|
|
25
26
|
requestTimeout: z.number().positive().default(30000),
|
|
26
|
-
/** Connection timeout in milliseconds */
|
|
27
|
-
connectTimeout: z.number().positive().default(10000),
|
|
28
27
|
/** Maximum number of retry attempts */
|
|
29
28
|
maxRetries: z.number().int().nonnegative().default(3),
|
|
30
29
|
/** Initial delay between retries in milliseconds */
|
|
@@ -33,6 +32,8 @@ export const HttpTransportConfigSchema = z.object({
|
|
|
33
32
|
maxRetryDelay: z.number().positive().default(60000),
|
|
34
33
|
/** Multiplier for exponential backoff */
|
|
35
34
|
retryMultiplier: z.number().positive().default(2.0),
|
|
35
|
+
/** Status codes that should trigger retries */
|
|
36
|
+
retryOnStatusCodes: z.array(HttpStatusCodeSchema).default([...DEFAULT_RETRY_ON_STATUS_CODES]),
|
|
36
37
|
});
|
|
37
38
|
/**
|
|
38
39
|
* Partial HTTP config schema for user input (before defaults are applied)
|
|
@@ -41,25 +42,23 @@ export const PartialHttpConfigSchema = z.object({
|
|
|
41
42
|
apiUrl: z.string().url(),
|
|
42
43
|
apiToken: z.string().min(1),
|
|
43
44
|
agentId: z.string().optional(),
|
|
44
|
-
|
|
45
|
+
agentIdentifier: z.string().optional(),
|
|
45
46
|
agentName: z.string().optional(),
|
|
46
47
|
agentDescription: z.string().optional(),
|
|
47
48
|
agentSchema: z.record(z.unknown()).optional(),
|
|
48
|
-
agentSchemaVersion: z.string().optional(),
|
|
49
|
-
skipSchema: z.boolean().optional(),
|
|
50
49
|
requestTimeout: z.number().positive().optional(),
|
|
51
|
-
connectTimeout: z.number().positive().optional(),
|
|
52
50
|
maxRetries: z.number().int().nonnegative().optional(),
|
|
53
51
|
initialRetryDelay: z.number().positive().optional(),
|
|
54
52
|
maxRetryDelay: z.number().positive().optional(),
|
|
55
53
|
retryMultiplier: z.number().positive().optional(),
|
|
54
|
+
retryOnStatusCodes: z.array(HttpStatusCodeSchema).optional(),
|
|
56
55
|
});
|
|
57
56
|
/**
|
|
58
57
|
* Main SDK configuration schema
|
|
59
58
|
*/
|
|
60
59
|
export const ConfigSchema = z.object({
|
|
61
60
|
/** Transport type to use for span emission */
|
|
62
|
-
transportType: z.enum(['
|
|
61
|
+
transportType: z.enum(['http']).default('http'),
|
|
63
62
|
/** Sampling rate (0.0 to 1.0) */
|
|
64
63
|
sampleRate: z.number().min(0).max(1).default(1.0),
|
|
65
64
|
/** Whether to capture span inputs */
|
|
@@ -93,18 +92,34 @@ export const ConfigSchema = z.object({
|
|
|
93
92
|
* ```
|
|
94
93
|
*/
|
|
95
94
|
export function createConfig(options) {
|
|
95
|
+
const retryOnStatusCodesFromEnv = parseRetryOnStatusCodesEnv(process.env.PREFACTOR_RETRY_ON_STATUS_CODES);
|
|
96
96
|
const config = {
|
|
97
|
-
transportType: options?.transportType ??
|
|
98
|
-
process.env.PREFACTOR_TRANSPORT ??
|
|
99
|
-
'stdio',
|
|
97
|
+
transportType: options?.transportType ?? process.env.PREFACTOR_TRANSPORT ?? 'http',
|
|
100
98
|
sampleRate: options?.sampleRate ?? parseFloat(process.env.PREFACTOR_SAMPLE_RATE ?? '1.0'),
|
|
101
99
|
captureInputs: options?.captureInputs ?? process.env.PREFACTOR_CAPTURE_INPUTS !== 'false',
|
|
102
100
|
captureOutputs: options?.captureOutputs ?? process.env.PREFACTOR_CAPTURE_OUTPUTS !== 'false',
|
|
103
101
|
maxInputLength: options?.maxInputLength ?? parseInt(process.env.PREFACTOR_MAX_INPUT_LENGTH ?? '10000', 10),
|
|
104
102
|
maxOutputLength: options?.maxOutputLength ?? parseInt(process.env.PREFACTOR_MAX_OUTPUT_LENGTH ?? '10000', 10),
|
|
105
|
-
httpConfig: options?.httpConfig
|
|
103
|
+
httpConfig: options?.httpConfig
|
|
104
|
+
? {
|
|
105
|
+
...options.httpConfig,
|
|
106
|
+
retryOnStatusCodes: options.httpConfig.retryOnStatusCodes ?? retryOnStatusCodesFromEnv,
|
|
107
|
+
}
|
|
108
|
+
: undefined,
|
|
106
109
|
};
|
|
107
110
|
// Validate and return
|
|
108
111
|
return ConfigSchema.parse(config);
|
|
109
112
|
}
|
|
113
|
+
function parseRetryOnStatusCodesEnv(value) {
|
|
114
|
+
if (!value) {
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
const parsedCodes = value
|
|
118
|
+
.split(',')
|
|
119
|
+
.map((status) => status.trim())
|
|
120
|
+
.filter((status) => /^\d{3}$/.test(status))
|
|
121
|
+
.map((status) => Number(status))
|
|
122
|
+
.filter((status) => status >= 100 && status <= 599);
|
|
123
|
+
return parsedCodes.length > 0 ? parsedCodes : undefined;
|
|
124
|
+
}
|
|
110
125
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,6BAA6B,GAAG;IACpC,GAAG;IACH,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,GAAG,KAAK,CAAC;CAC1D,CAAC;AACF,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAEhE;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChD,uBAAuB;IACvB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IAExB,2BAA2B;IAC3B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAE3B,uDAAuD;IACvD,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAE9B,8EAA8E;IAC9E,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC;IAE7C,0BAA0B;IAC1B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAEhC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U,CAAC,kBAAkB,IAAI,yBAAyB;aACvF;YACH,CAAC,CAAC,SAAS;KACd,CAAC;IAEF,sBAAsB;IACtB,OAAO,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC;AAED,SAAS,0BAA0B,CAAC,KAAyB;IAC3D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,WAAW,GAAG,KAAK;SACtB,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;SAC9B,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SAC1C,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;SAC/B,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,IAAI,GAAG,IAAI,MAAM,IAAI,GAAG,CAAC,CAAC;IAEtD,OAAO,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AgentInstanceManager } from './agent/instance-manager.js';
|
|
2
|
+
import type { Config } from './config.js';
|
|
3
|
+
import { Tracer } from './tracing/tracer.js';
|
|
4
|
+
export type CoreRuntime = {
|
|
5
|
+
tracer: Tracer;
|
|
6
|
+
agentManager: AgentInstanceManager;
|
|
7
|
+
shutdown: () => Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
export declare function createCore(config: Config): CoreRuntime;
|
|
10
|
+
//# sourceMappingURL=create-core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-core.d.ts","sourceRoot":"","sources":["../src/create-core.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAG7C,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,oBAAoB,CAAC;IACnC,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/B,CAAC;AAEF,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CA6BtD"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { extractPartition } from '@prefactor/pfid';
|
|
2
|
+
import { AgentInstanceManager } from './agent/instance-manager.js';
|
|
3
|
+
import { HttpTransportConfigSchema } from './config.js';
|
|
4
|
+
import { Tracer } from './tracing/tracer.js';
|
|
5
|
+
import { HttpTransport } from './transport/http.js';
|
|
6
|
+
export function createCore(config) {
|
|
7
|
+
if (!config.httpConfig) {
|
|
8
|
+
throw new Error('HTTP transport requires httpConfig to be provided in configuration');
|
|
9
|
+
}
|
|
10
|
+
const httpConfig = HttpTransportConfigSchema.parse(config.httpConfig);
|
|
11
|
+
const transport = new HttpTransport(httpConfig);
|
|
12
|
+
let partition;
|
|
13
|
+
if (config.httpConfig.agentId) {
|
|
14
|
+
try {
|
|
15
|
+
partition = extractPartition(config.httpConfig.agentId);
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
partition = undefined;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const tracer = new Tracer(transport, partition);
|
|
22
|
+
const allowUnregisteredSchema = Boolean(config.httpConfig.agentSchema);
|
|
23
|
+
const agentManager = new AgentInstanceManager(transport, {
|
|
24
|
+
allowUnregisteredSchema,
|
|
25
|
+
});
|
|
26
|
+
const shutdown = async () => {
|
|
27
|
+
await tracer.close();
|
|
28
|
+
};
|
|
29
|
+
return { tracer, agentManager, shutdown };
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