@raindrop-ai/pi-agent 0.0.2
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 +48 -0
- package/dist/chunk-LZIGXU2D.js +922 -0
- package/dist/extension.cjs +1311 -0
- package/dist/extension.d.cts +60 -0
- package/dist/extension.d.ts +60 -0
- package/dist/extension.js +452 -0
- package/dist/index.cjs +1405 -0
- package/dist/index.d-npTVS9Mf.d.cts +216 -0
- package/dist/index.d-npTVS9Mf.d.ts +216 -0
- package/dist/index.d.cts +138 -0
- package/dist/index.d.ts +138 -0
- package/dist/index.js +498 -0
- package/package.json +91 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
type OtlpAnyValue = {
|
|
2
|
+
stringValue?: string;
|
|
3
|
+
intValue?: string;
|
|
4
|
+
doubleValue?: number;
|
|
5
|
+
boolValue?: boolean;
|
|
6
|
+
arrayValue?: {
|
|
7
|
+
values: OtlpAnyValue[];
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
type OtlpKeyValue = {
|
|
11
|
+
key: string;
|
|
12
|
+
value: OtlpAnyValue;
|
|
13
|
+
};
|
|
14
|
+
declare const SpanStatusCode: {
|
|
15
|
+
readonly UNSET: 0;
|
|
16
|
+
readonly OK: 1;
|
|
17
|
+
readonly ERROR: 2;
|
|
18
|
+
};
|
|
19
|
+
type OtlpSpanStatus = {
|
|
20
|
+
code: (typeof SpanStatusCode)[keyof typeof SpanStatusCode] | number;
|
|
21
|
+
message?: string;
|
|
22
|
+
};
|
|
23
|
+
type OtlpSpan = {
|
|
24
|
+
traceId: string;
|
|
25
|
+
spanId: string;
|
|
26
|
+
parentSpanId?: string;
|
|
27
|
+
name: string;
|
|
28
|
+
startTimeUnixNano: string;
|
|
29
|
+
endTimeUnixNano: string;
|
|
30
|
+
attributes?: OtlpKeyValue[];
|
|
31
|
+
status?: OtlpSpanStatus;
|
|
32
|
+
};
|
|
33
|
+
type SpanIds = {
|
|
34
|
+
traceIdB64: string;
|
|
35
|
+
spanIdB64: string;
|
|
36
|
+
parentSpanIdB64?: string;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
type Attachment = {
|
|
40
|
+
type: string;
|
|
41
|
+
role: string;
|
|
42
|
+
name?: string;
|
|
43
|
+
value: string;
|
|
44
|
+
};
|
|
45
|
+
type IdentifyInput = {
|
|
46
|
+
userId: string;
|
|
47
|
+
traits?: Record<string, unknown>;
|
|
48
|
+
};
|
|
49
|
+
type Patch = {
|
|
50
|
+
eventName?: string;
|
|
51
|
+
userId?: string;
|
|
52
|
+
convoId?: string;
|
|
53
|
+
input?: string;
|
|
54
|
+
output?: string;
|
|
55
|
+
model?: string;
|
|
56
|
+
properties?: Record<string, unknown>;
|
|
57
|
+
attachments?: Attachment[];
|
|
58
|
+
isPending?: boolean;
|
|
59
|
+
timestamp?: string;
|
|
60
|
+
};
|
|
61
|
+
type SignalInput = {
|
|
62
|
+
eventId: string;
|
|
63
|
+
name: string;
|
|
64
|
+
type?: "default" | "feedback" | "edit" | "standard" | "agent" | "agent_internal";
|
|
65
|
+
sentiment?: "POSITIVE" | "NEGATIVE";
|
|
66
|
+
timestamp?: string;
|
|
67
|
+
properties?: Record<string, unknown>;
|
|
68
|
+
attachmentId?: string;
|
|
69
|
+
comment?: string;
|
|
70
|
+
after?: string;
|
|
71
|
+
};
|
|
72
|
+
type EventShipperOptions = {
|
|
73
|
+
writeKey?: string;
|
|
74
|
+
endpoint?: string;
|
|
75
|
+
enabled?: boolean;
|
|
76
|
+
debug: boolean;
|
|
77
|
+
partialFlushMs?: number;
|
|
78
|
+
sdkName?: string;
|
|
79
|
+
libraryName?: string;
|
|
80
|
+
libraryVersion?: string;
|
|
81
|
+
defaultEventName?: string;
|
|
82
|
+
};
|
|
83
|
+
declare class EventShipper {
|
|
84
|
+
private baseUrl;
|
|
85
|
+
private writeKey?;
|
|
86
|
+
private enabled;
|
|
87
|
+
private debug;
|
|
88
|
+
private partialFlushMs;
|
|
89
|
+
private sdkName;
|
|
90
|
+
private prefix;
|
|
91
|
+
private defaultEventName;
|
|
92
|
+
private context;
|
|
93
|
+
private buffers;
|
|
94
|
+
private sticky;
|
|
95
|
+
private timers;
|
|
96
|
+
private inFlight;
|
|
97
|
+
constructor(opts: EventShipperOptions);
|
|
98
|
+
isDebugEnabled(): boolean;
|
|
99
|
+
private authHeaders;
|
|
100
|
+
patch(eventId: string, patch: Patch): Promise<void>;
|
|
101
|
+
finish(eventId: string, patch: {
|
|
102
|
+
output?: string;
|
|
103
|
+
model?: string;
|
|
104
|
+
properties?: Record<string, unknown>;
|
|
105
|
+
userId?: string;
|
|
106
|
+
}): Promise<void>;
|
|
107
|
+
flush(): Promise<void>;
|
|
108
|
+
shutdown(): Promise<void>;
|
|
109
|
+
trackSignal(signal: SignalInput): Promise<void>;
|
|
110
|
+
identify(users: IdentifyInput | IdentifyInput[]): Promise<void>;
|
|
111
|
+
private flushOne;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
type InternalSpan = {
|
|
115
|
+
ids: SpanIds;
|
|
116
|
+
name: string;
|
|
117
|
+
startTimeUnixNano: string;
|
|
118
|
+
endTimeUnixNano?: string;
|
|
119
|
+
attributes: Array<OtlpKeyValue | undefined>;
|
|
120
|
+
};
|
|
121
|
+
type TraceShipperOptions = {
|
|
122
|
+
writeKey?: string;
|
|
123
|
+
endpoint?: string;
|
|
124
|
+
enabled?: boolean;
|
|
125
|
+
debug: boolean;
|
|
126
|
+
debugSpans?: boolean;
|
|
127
|
+
flushIntervalMs?: number;
|
|
128
|
+
maxBatchSize?: number;
|
|
129
|
+
maxQueueSize?: number;
|
|
130
|
+
sdkName?: string;
|
|
131
|
+
serviceName?: string;
|
|
132
|
+
serviceVersion?: string;
|
|
133
|
+
};
|
|
134
|
+
declare class TraceShipper {
|
|
135
|
+
private baseUrl;
|
|
136
|
+
private writeKey?;
|
|
137
|
+
private enabled;
|
|
138
|
+
private debug;
|
|
139
|
+
private debugSpans;
|
|
140
|
+
private sdkName;
|
|
141
|
+
private prefix;
|
|
142
|
+
private serviceName;
|
|
143
|
+
private serviceVersion;
|
|
144
|
+
private flushIntervalMs;
|
|
145
|
+
private maxBatchSize;
|
|
146
|
+
private maxQueueSize;
|
|
147
|
+
private queue;
|
|
148
|
+
private timer;
|
|
149
|
+
private inFlight;
|
|
150
|
+
/** URL of the local debugger (from RAINDROP_LOCAL_DEBUGGER env var). */
|
|
151
|
+
private localDebuggerUrl;
|
|
152
|
+
constructor(opts: TraceShipperOptions);
|
|
153
|
+
isDebugEnabled(): boolean;
|
|
154
|
+
private authHeaders;
|
|
155
|
+
startSpan(args: {
|
|
156
|
+
name: string;
|
|
157
|
+
parent?: {
|
|
158
|
+
traceIdB64: string;
|
|
159
|
+
spanIdB64: string;
|
|
160
|
+
};
|
|
161
|
+
eventId: string;
|
|
162
|
+
operationId?: string;
|
|
163
|
+
attributes?: Array<OtlpKeyValue | undefined>;
|
|
164
|
+
startTimeUnixNano?: string;
|
|
165
|
+
}): InternalSpan;
|
|
166
|
+
endSpan(span: InternalSpan, extra?: {
|
|
167
|
+
attributes?: InternalSpan["attributes"];
|
|
168
|
+
error?: unknown;
|
|
169
|
+
status?: OtlpSpanStatus;
|
|
170
|
+
endTimeUnixNano?: string;
|
|
171
|
+
}): void;
|
|
172
|
+
createSpan(args: {
|
|
173
|
+
name: string;
|
|
174
|
+
parent?: {
|
|
175
|
+
traceIdB64: string;
|
|
176
|
+
spanIdB64: string;
|
|
177
|
+
};
|
|
178
|
+
eventId: string;
|
|
179
|
+
startTimeUnixNano: string;
|
|
180
|
+
endTimeUnixNano: string;
|
|
181
|
+
attributes?: Array<OtlpKeyValue | undefined>;
|
|
182
|
+
status?: OtlpSpanStatus;
|
|
183
|
+
}): void;
|
|
184
|
+
enqueue(span: OtlpSpan): void;
|
|
185
|
+
flush(): Promise<void>;
|
|
186
|
+
shutdown(): Promise<void>;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
type ParentSpanContext = {
|
|
190
|
+
traceIdB64: string;
|
|
191
|
+
spanIdB64: string;
|
|
192
|
+
eventId: string;
|
|
193
|
+
};
|
|
194
|
+
interface ContextSpan {
|
|
195
|
+
readonly traceIdB64: string;
|
|
196
|
+
readonly spanIdB64: string;
|
|
197
|
+
readonly eventId: string;
|
|
198
|
+
log?(data: Record<string, unknown>): void;
|
|
199
|
+
}
|
|
200
|
+
interface AsyncLocalStorageLike<T> {
|
|
201
|
+
getStore(): T | undefined;
|
|
202
|
+
run<R>(store: T, callback: () => R): R;
|
|
203
|
+
enterWith?(store: T): void;
|
|
204
|
+
}
|
|
205
|
+
declare abstract class ContextManager {
|
|
206
|
+
abstract getParentSpanIds(): ParentSpanContext | undefined;
|
|
207
|
+
abstract runInContext<R>(span: ContextSpan, callback: () => R): R;
|
|
208
|
+
abstract getCurrentSpan(): ContextSpan | undefined;
|
|
209
|
+
abstract isReady(): boolean;
|
|
210
|
+
}
|
|
211
|
+
declare global {
|
|
212
|
+
var RAINDROP_CONTEXT_MANAGER: (new () => ContextManager) | undefined;
|
|
213
|
+
var RAINDROP_ASYNC_LOCAL_STORAGE: (new <T>() => AsyncLocalStorageLike<T>) | undefined;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export { type Attachment as A, EventShipper as E, type OtlpSpan as O, TraceShipper as T };
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
type OtlpAnyValue = {
|
|
2
|
+
stringValue?: string;
|
|
3
|
+
intValue?: string;
|
|
4
|
+
doubleValue?: number;
|
|
5
|
+
boolValue?: boolean;
|
|
6
|
+
arrayValue?: {
|
|
7
|
+
values: OtlpAnyValue[];
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
type OtlpKeyValue = {
|
|
11
|
+
key: string;
|
|
12
|
+
value: OtlpAnyValue;
|
|
13
|
+
};
|
|
14
|
+
declare const SpanStatusCode: {
|
|
15
|
+
readonly UNSET: 0;
|
|
16
|
+
readonly OK: 1;
|
|
17
|
+
readonly ERROR: 2;
|
|
18
|
+
};
|
|
19
|
+
type OtlpSpanStatus = {
|
|
20
|
+
code: (typeof SpanStatusCode)[keyof typeof SpanStatusCode] | number;
|
|
21
|
+
message?: string;
|
|
22
|
+
};
|
|
23
|
+
type OtlpSpan = {
|
|
24
|
+
traceId: string;
|
|
25
|
+
spanId: string;
|
|
26
|
+
parentSpanId?: string;
|
|
27
|
+
name: string;
|
|
28
|
+
startTimeUnixNano: string;
|
|
29
|
+
endTimeUnixNano: string;
|
|
30
|
+
attributes?: OtlpKeyValue[];
|
|
31
|
+
status?: OtlpSpanStatus;
|
|
32
|
+
};
|
|
33
|
+
type SpanIds = {
|
|
34
|
+
traceIdB64: string;
|
|
35
|
+
spanIdB64: string;
|
|
36
|
+
parentSpanIdB64?: string;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
type Attachment = {
|
|
40
|
+
type: string;
|
|
41
|
+
role: string;
|
|
42
|
+
name?: string;
|
|
43
|
+
value: string;
|
|
44
|
+
};
|
|
45
|
+
type IdentifyInput = {
|
|
46
|
+
userId: string;
|
|
47
|
+
traits?: Record<string, unknown>;
|
|
48
|
+
};
|
|
49
|
+
type Patch = {
|
|
50
|
+
eventName?: string;
|
|
51
|
+
userId?: string;
|
|
52
|
+
convoId?: string;
|
|
53
|
+
input?: string;
|
|
54
|
+
output?: string;
|
|
55
|
+
model?: string;
|
|
56
|
+
properties?: Record<string, unknown>;
|
|
57
|
+
attachments?: Attachment[];
|
|
58
|
+
isPending?: boolean;
|
|
59
|
+
timestamp?: string;
|
|
60
|
+
};
|
|
61
|
+
type SignalInput = {
|
|
62
|
+
eventId: string;
|
|
63
|
+
name: string;
|
|
64
|
+
type?: "default" | "feedback" | "edit" | "standard" | "agent" | "agent_internal";
|
|
65
|
+
sentiment?: "POSITIVE" | "NEGATIVE";
|
|
66
|
+
timestamp?: string;
|
|
67
|
+
properties?: Record<string, unknown>;
|
|
68
|
+
attachmentId?: string;
|
|
69
|
+
comment?: string;
|
|
70
|
+
after?: string;
|
|
71
|
+
};
|
|
72
|
+
type EventShipperOptions = {
|
|
73
|
+
writeKey?: string;
|
|
74
|
+
endpoint?: string;
|
|
75
|
+
enabled?: boolean;
|
|
76
|
+
debug: boolean;
|
|
77
|
+
partialFlushMs?: number;
|
|
78
|
+
sdkName?: string;
|
|
79
|
+
libraryName?: string;
|
|
80
|
+
libraryVersion?: string;
|
|
81
|
+
defaultEventName?: string;
|
|
82
|
+
};
|
|
83
|
+
declare class EventShipper {
|
|
84
|
+
private baseUrl;
|
|
85
|
+
private writeKey?;
|
|
86
|
+
private enabled;
|
|
87
|
+
private debug;
|
|
88
|
+
private partialFlushMs;
|
|
89
|
+
private sdkName;
|
|
90
|
+
private prefix;
|
|
91
|
+
private defaultEventName;
|
|
92
|
+
private context;
|
|
93
|
+
private buffers;
|
|
94
|
+
private sticky;
|
|
95
|
+
private timers;
|
|
96
|
+
private inFlight;
|
|
97
|
+
constructor(opts: EventShipperOptions);
|
|
98
|
+
isDebugEnabled(): boolean;
|
|
99
|
+
private authHeaders;
|
|
100
|
+
patch(eventId: string, patch: Patch): Promise<void>;
|
|
101
|
+
finish(eventId: string, patch: {
|
|
102
|
+
output?: string;
|
|
103
|
+
model?: string;
|
|
104
|
+
properties?: Record<string, unknown>;
|
|
105
|
+
userId?: string;
|
|
106
|
+
}): Promise<void>;
|
|
107
|
+
flush(): Promise<void>;
|
|
108
|
+
shutdown(): Promise<void>;
|
|
109
|
+
trackSignal(signal: SignalInput): Promise<void>;
|
|
110
|
+
identify(users: IdentifyInput | IdentifyInput[]): Promise<void>;
|
|
111
|
+
private flushOne;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
type InternalSpan = {
|
|
115
|
+
ids: SpanIds;
|
|
116
|
+
name: string;
|
|
117
|
+
startTimeUnixNano: string;
|
|
118
|
+
endTimeUnixNano?: string;
|
|
119
|
+
attributes: Array<OtlpKeyValue | undefined>;
|
|
120
|
+
};
|
|
121
|
+
type TraceShipperOptions = {
|
|
122
|
+
writeKey?: string;
|
|
123
|
+
endpoint?: string;
|
|
124
|
+
enabled?: boolean;
|
|
125
|
+
debug: boolean;
|
|
126
|
+
debugSpans?: boolean;
|
|
127
|
+
flushIntervalMs?: number;
|
|
128
|
+
maxBatchSize?: number;
|
|
129
|
+
maxQueueSize?: number;
|
|
130
|
+
sdkName?: string;
|
|
131
|
+
serviceName?: string;
|
|
132
|
+
serviceVersion?: string;
|
|
133
|
+
};
|
|
134
|
+
declare class TraceShipper {
|
|
135
|
+
private baseUrl;
|
|
136
|
+
private writeKey?;
|
|
137
|
+
private enabled;
|
|
138
|
+
private debug;
|
|
139
|
+
private debugSpans;
|
|
140
|
+
private sdkName;
|
|
141
|
+
private prefix;
|
|
142
|
+
private serviceName;
|
|
143
|
+
private serviceVersion;
|
|
144
|
+
private flushIntervalMs;
|
|
145
|
+
private maxBatchSize;
|
|
146
|
+
private maxQueueSize;
|
|
147
|
+
private queue;
|
|
148
|
+
private timer;
|
|
149
|
+
private inFlight;
|
|
150
|
+
/** URL of the local debugger (from RAINDROP_LOCAL_DEBUGGER env var). */
|
|
151
|
+
private localDebuggerUrl;
|
|
152
|
+
constructor(opts: TraceShipperOptions);
|
|
153
|
+
isDebugEnabled(): boolean;
|
|
154
|
+
private authHeaders;
|
|
155
|
+
startSpan(args: {
|
|
156
|
+
name: string;
|
|
157
|
+
parent?: {
|
|
158
|
+
traceIdB64: string;
|
|
159
|
+
spanIdB64: string;
|
|
160
|
+
};
|
|
161
|
+
eventId: string;
|
|
162
|
+
operationId?: string;
|
|
163
|
+
attributes?: Array<OtlpKeyValue | undefined>;
|
|
164
|
+
startTimeUnixNano?: string;
|
|
165
|
+
}): InternalSpan;
|
|
166
|
+
endSpan(span: InternalSpan, extra?: {
|
|
167
|
+
attributes?: InternalSpan["attributes"];
|
|
168
|
+
error?: unknown;
|
|
169
|
+
status?: OtlpSpanStatus;
|
|
170
|
+
endTimeUnixNano?: string;
|
|
171
|
+
}): void;
|
|
172
|
+
createSpan(args: {
|
|
173
|
+
name: string;
|
|
174
|
+
parent?: {
|
|
175
|
+
traceIdB64: string;
|
|
176
|
+
spanIdB64: string;
|
|
177
|
+
};
|
|
178
|
+
eventId: string;
|
|
179
|
+
startTimeUnixNano: string;
|
|
180
|
+
endTimeUnixNano: string;
|
|
181
|
+
attributes?: Array<OtlpKeyValue | undefined>;
|
|
182
|
+
status?: OtlpSpanStatus;
|
|
183
|
+
}): void;
|
|
184
|
+
enqueue(span: OtlpSpan): void;
|
|
185
|
+
flush(): Promise<void>;
|
|
186
|
+
shutdown(): Promise<void>;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
type ParentSpanContext = {
|
|
190
|
+
traceIdB64: string;
|
|
191
|
+
spanIdB64: string;
|
|
192
|
+
eventId: string;
|
|
193
|
+
};
|
|
194
|
+
interface ContextSpan {
|
|
195
|
+
readonly traceIdB64: string;
|
|
196
|
+
readonly spanIdB64: string;
|
|
197
|
+
readonly eventId: string;
|
|
198
|
+
log?(data: Record<string, unknown>): void;
|
|
199
|
+
}
|
|
200
|
+
interface AsyncLocalStorageLike<T> {
|
|
201
|
+
getStore(): T | undefined;
|
|
202
|
+
run<R>(store: T, callback: () => R): R;
|
|
203
|
+
enterWith?(store: T): void;
|
|
204
|
+
}
|
|
205
|
+
declare abstract class ContextManager {
|
|
206
|
+
abstract getParentSpanIds(): ParentSpanContext | undefined;
|
|
207
|
+
abstract runInContext<R>(span: ContextSpan, callback: () => R): R;
|
|
208
|
+
abstract getCurrentSpan(): ContextSpan | undefined;
|
|
209
|
+
abstract isReady(): boolean;
|
|
210
|
+
}
|
|
211
|
+
declare global {
|
|
212
|
+
var RAINDROP_CONTEXT_MANAGER: (new () => ContextManager) | undefined;
|
|
213
|
+
var RAINDROP_ASYNC_LOCAL_STORAGE: (new <T>() => AsyncLocalStorageLike<T>) | undefined;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export { type Attachment as A, EventShipper as E, type OtlpSpan as O, TraceShipper as T };
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { Agent } from '@mariozechner/pi-agent-core';
|
|
2
|
+
import { A as Attachment } from './index.d-npTVS9Mf.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Options for the Raindrop Pi Agent client.
|
|
6
|
+
*/
|
|
7
|
+
interface RaindropPiAgentOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Write key for direct authentication.
|
|
10
|
+
* Optional — when omitted, telemetry shipping is disabled with a warning.
|
|
11
|
+
*/
|
|
12
|
+
writeKey?: string;
|
|
13
|
+
/** API endpoint URL (defaults to production) */
|
|
14
|
+
endpoint?: string;
|
|
15
|
+
/** Default user ID for all events */
|
|
16
|
+
userId?: string;
|
|
17
|
+
/** Default conversation ID to group related events */
|
|
18
|
+
convoId?: string;
|
|
19
|
+
/** Default event name (default: "pi_agent_prompt") */
|
|
20
|
+
eventName?: string;
|
|
21
|
+
/** Default properties attached to every event */
|
|
22
|
+
properties?: Record<string, unknown>;
|
|
23
|
+
/** Trace shipping configuration */
|
|
24
|
+
traces?: {
|
|
25
|
+
/** Enable trace shipping (default: true) */
|
|
26
|
+
enabled?: boolean;
|
|
27
|
+
/** Flush interval in milliseconds */
|
|
28
|
+
flushIntervalMs?: number;
|
|
29
|
+
/** Maximum batch size */
|
|
30
|
+
maxBatchSize?: number;
|
|
31
|
+
/** Maximum queue size */
|
|
32
|
+
maxQueueSize?: number;
|
|
33
|
+
/** Enable debug logging */
|
|
34
|
+
debug?: boolean;
|
|
35
|
+
/** Enable detailed span logging */
|
|
36
|
+
debugSpans?: boolean;
|
|
37
|
+
};
|
|
38
|
+
/** Event shipping configuration */
|
|
39
|
+
events?: {
|
|
40
|
+
/** Enable event shipping (default: true) */
|
|
41
|
+
enabled?: boolean;
|
|
42
|
+
/** Partial flush interval in milliseconds */
|
|
43
|
+
partialFlushMs?: number;
|
|
44
|
+
/** Enable debug logging */
|
|
45
|
+
debug?: boolean;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Per-subscribe overrides for context.
|
|
50
|
+
*/
|
|
51
|
+
interface PiAgentSubscribeOptions {
|
|
52
|
+
/** User ID override for this subscription */
|
|
53
|
+
userId?: string;
|
|
54
|
+
/** Conversation ID override */
|
|
55
|
+
convoId?: string;
|
|
56
|
+
/** Event name override */
|
|
57
|
+
eventName?: string;
|
|
58
|
+
/** Additional properties */
|
|
59
|
+
properties?: Record<string, unknown>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The Raindrop Pi Agent client.
|
|
63
|
+
* Exposes the full API surface: subscribe, events, users, signals, flush, shutdown.
|
|
64
|
+
*/
|
|
65
|
+
interface RaindropPiAgentClient {
|
|
66
|
+
/**
|
|
67
|
+
* Subscribe to a Pi Agent instance for automatic telemetry.
|
|
68
|
+
* Returns an unsubscribe function.
|
|
69
|
+
*
|
|
70
|
+
* @param agent - The Pi Agent instance to observe
|
|
71
|
+
* @param options - Optional per-subscription overrides
|
|
72
|
+
* @returns Unsubscribe function to stop tracking
|
|
73
|
+
*/
|
|
74
|
+
subscribe(agent: Agent, options?: PiAgentSubscribeOptions): () => void;
|
|
75
|
+
/** Event management methods */
|
|
76
|
+
events: {
|
|
77
|
+
/** Patch an existing event with additional data */
|
|
78
|
+
patch(eventId: string, data: Record<string, unknown>): Promise<void>;
|
|
79
|
+
/** Add attachments to an event */
|
|
80
|
+
addAttachments(eventId: string, attachments: Attachment[]): Promise<void>;
|
|
81
|
+
/** Set properties on an event */
|
|
82
|
+
setProperties(eventId: string, properties: Record<string, unknown>): Promise<void>;
|
|
83
|
+
/** Finish an event (trigger immediate shipping) */
|
|
84
|
+
finish(eventId: string): Promise<void>;
|
|
85
|
+
};
|
|
86
|
+
/** User identification methods */
|
|
87
|
+
users: {
|
|
88
|
+
/** Identify a user with traits */
|
|
89
|
+
identify(params: {
|
|
90
|
+
userId: string;
|
|
91
|
+
traits?: Record<string, unknown>;
|
|
92
|
+
}): Promise<void>;
|
|
93
|
+
};
|
|
94
|
+
/** Signal tracking methods */
|
|
95
|
+
signals: {
|
|
96
|
+
/** Track a signal (feedback, user action, etc.) */
|
|
97
|
+
track(params: {
|
|
98
|
+
eventId?: string;
|
|
99
|
+
name: string;
|
|
100
|
+
type?: "default" | "feedback" | "edit";
|
|
101
|
+
sentiment?: "POSITIVE" | "NEGATIVE";
|
|
102
|
+
timestamp?: string;
|
|
103
|
+
attachmentId?: string;
|
|
104
|
+
comment?: string;
|
|
105
|
+
after?: string;
|
|
106
|
+
[key: string]: unknown;
|
|
107
|
+
}): Promise<void>;
|
|
108
|
+
};
|
|
109
|
+
/** Flush all pending events and traces */
|
|
110
|
+
flush(): Promise<void>;
|
|
111
|
+
/** Shutdown the client, flushing all data */
|
|
112
|
+
shutdown(): Promise<void>;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Create a Raindrop Pi Agent client for automatic telemetry capture.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* import { Agent } from "@mariozechner/pi-agent-core";
|
|
121
|
+
* import { createRaindropPiAgent } from "@raindrop-ai/pi-agent";
|
|
122
|
+
*
|
|
123
|
+
* const raindrop = createRaindropPiAgent({
|
|
124
|
+
* writeKey: "rk_...",
|
|
125
|
+
* userId: "user-123",
|
|
126
|
+
* convoId: "session-abc",
|
|
127
|
+
* });
|
|
128
|
+
*
|
|
129
|
+
* const agent = new Agent({ ... });
|
|
130
|
+
* const unsub = raindrop.subscribe(agent);
|
|
131
|
+
*
|
|
132
|
+
* await agent.prompt("Hello!");
|
|
133
|
+
* await raindrop.shutdown();
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
declare function createRaindropPiAgent(opts: RaindropPiAgentOptions): RaindropPiAgentClient;
|
|
137
|
+
|
|
138
|
+
export { Attachment, type PiAgentSubscribeOptions, type RaindropPiAgentClient, type RaindropPiAgentOptions, createRaindropPiAgent };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { Agent } from '@mariozechner/pi-agent-core';
|
|
2
|
+
import { A as Attachment } from './index.d-npTVS9Mf.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Options for the Raindrop Pi Agent client.
|
|
6
|
+
*/
|
|
7
|
+
interface RaindropPiAgentOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Write key for direct authentication.
|
|
10
|
+
* Optional — when omitted, telemetry shipping is disabled with a warning.
|
|
11
|
+
*/
|
|
12
|
+
writeKey?: string;
|
|
13
|
+
/** API endpoint URL (defaults to production) */
|
|
14
|
+
endpoint?: string;
|
|
15
|
+
/** Default user ID for all events */
|
|
16
|
+
userId?: string;
|
|
17
|
+
/** Default conversation ID to group related events */
|
|
18
|
+
convoId?: string;
|
|
19
|
+
/** Default event name (default: "pi_agent_prompt") */
|
|
20
|
+
eventName?: string;
|
|
21
|
+
/** Default properties attached to every event */
|
|
22
|
+
properties?: Record<string, unknown>;
|
|
23
|
+
/** Trace shipping configuration */
|
|
24
|
+
traces?: {
|
|
25
|
+
/** Enable trace shipping (default: true) */
|
|
26
|
+
enabled?: boolean;
|
|
27
|
+
/** Flush interval in milliseconds */
|
|
28
|
+
flushIntervalMs?: number;
|
|
29
|
+
/** Maximum batch size */
|
|
30
|
+
maxBatchSize?: number;
|
|
31
|
+
/** Maximum queue size */
|
|
32
|
+
maxQueueSize?: number;
|
|
33
|
+
/** Enable debug logging */
|
|
34
|
+
debug?: boolean;
|
|
35
|
+
/** Enable detailed span logging */
|
|
36
|
+
debugSpans?: boolean;
|
|
37
|
+
};
|
|
38
|
+
/** Event shipping configuration */
|
|
39
|
+
events?: {
|
|
40
|
+
/** Enable event shipping (default: true) */
|
|
41
|
+
enabled?: boolean;
|
|
42
|
+
/** Partial flush interval in milliseconds */
|
|
43
|
+
partialFlushMs?: number;
|
|
44
|
+
/** Enable debug logging */
|
|
45
|
+
debug?: boolean;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Per-subscribe overrides for context.
|
|
50
|
+
*/
|
|
51
|
+
interface PiAgentSubscribeOptions {
|
|
52
|
+
/** User ID override for this subscription */
|
|
53
|
+
userId?: string;
|
|
54
|
+
/** Conversation ID override */
|
|
55
|
+
convoId?: string;
|
|
56
|
+
/** Event name override */
|
|
57
|
+
eventName?: string;
|
|
58
|
+
/** Additional properties */
|
|
59
|
+
properties?: Record<string, unknown>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The Raindrop Pi Agent client.
|
|
63
|
+
* Exposes the full API surface: subscribe, events, users, signals, flush, shutdown.
|
|
64
|
+
*/
|
|
65
|
+
interface RaindropPiAgentClient {
|
|
66
|
+
/**
|
|
67
|
+
* Subscribe to a Pi Agent instance for automatic telemetry.
|
|
68
|
+
* Returns an unsubscribe function.
|
|
69
|
+
*
|
|
70
|
+
* @param agent - The Pi Agent instance to observe
|
|
71
|
+
* @param options - Optional per-subscription overrides
|
|
72
|
+
* @returns Unsubscribe function to stop tracking
|
|
73
|
+
*/
|
|
74
|
+
subscribe(agent: Agent, options?: PiAgentSubscribeOptions): () => void;
|
|
75
|
+
/** Event management methods */
|
|
76
|
+
events: {
|
|
77
|
+
/** Patch an existing event with additional data */
|
|
78
|
+
patch(eventId: string, data: Record<string, unknown>): Promise<void>;
|
|
79
|
+
/** Add attachments to an event */
|
|
80
|
+
addAttachments(eventId: string, attachments: Attachment[]): Promise<void>;
|
|
81
|
+
/** Set properties on an event */
|
|
82
|
+
setProperties(eventId: string, properties: Record<string, unknown>): Promise<void>;
|
|
83
|
+
/** Finish an event (trigger immediate shipping) */
|
|
84
|
+
finish(eventId: string): Promise<void>;
|
|
85
|
+
};
|
|
86
|
+
/** User identification methods */
|
|
87
|
+
users: {
|
|
88
|
+
/** Identify a user with traits */
|
|
89
|
+
identify(params: {
|
|
90
|
+
userId: string;
|
|
91
|
+
traits?: Record<string, unknown>;
|
|
92
|
+
}): Promise<void>;
|
|
93
|
+
};
|
|
94
|
+
/** Signal tracking methods */
|
|
95
|
+
signals: {
|
|
96
|
+
/** Track a signal (feedback, user action, etc.) */
|
|
97
|
+
track(params: {
|
|
98
|
+
eventId?: string;
|
|
99
|
+
name: string;
|
|
100
|
+
type?: "default" | "feedback" | "edit";
|
|
101
|
+
sentiment?: "POSITIVE" | "NEGATIVE";
|
|
102
|
+
timestamp?: string;
|
|
103
|
+
attachmentId?: string;
|
|
104
|
+
comment?: string;
|
|
105
|
+
after?: string;
|
|
106
|
+
[key: string]: unknown;
|
|
107
|
+
}): Promise<void>;
|
|
108
|
+
};
|
|
109
|
+
/** Flush all pending events and traces */
|
|
110
|
+
flush(): Promise<void>;
|
|
111
|
+
/** Shutdown the client, flushing all data */
|
|
112
|
+
shutdown(): Promise<void>;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Create a Raindrop Pi Agent client for automatic telemetry capture.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* import { Agent } from "@mariozechner/pi-agent-core";
|
|
121
|
+
* import { createRaindropPiAgent } from "@raindrop-ai/pi-agent";
|
|
122
|
+
*
|
|
123
|
+
* const raindrop = createRaindropPiAgent({
|
|
124
|
+
* writeKey: "rk_...",
|
|
125
|
+
* userId: "user-123",
|
|
126
|
+
* convoId: "session-abc",
|
|
127
|
+
* });
|
|
128
|
+
*
|
|
129
|
+
* const agent = new Agent({ ... });
|
|
130
|
+
* const unsub = raindrop.subscribe(agent);
|
|
131
|
+
*
|
|
132
|
+
* await agent.prompt("Hello!");
|
|
133
|
+
* await raindrop.shutdown();
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
declare function createRaindropPiAgent(opts: RaindropPiAgentOptions): RaindropPiAgentClient;
|
|
137
|
+
|
|
138
|
+
export { Attachment, type PiAgentSubscribeOptions, type RaindropPiAgentClient, type RaindropPiAgentOptions, createRaindropPiAgent };
|