@runtypelabs/cloudflare-agents 0.1.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/LICENSE +21 -0
- package/README.md +92 -0
- package/dist/chunk-BuRpWjxB.mjs +42 -0
- package/dist/chunk-DBVUQIKL.cjs +53 -0
- package/dist/durable-object.cjs +892 -0
- package/dist/durable-object.d.cts +114 -0
- package/dist/durable-object.d.ts +114 -0
- package/dist/durable-object.mjs +891 -0
- package/dist/index.cjs +344 -0
- package/dist/index.d.cts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.mjs +339 -0
- package/dist/observer-DnEMHl8z.d.cts +121 -0
- package/dist/observer-DnEMHl8z.d.ts +121 -0
- package/package.json +56 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { a as AdapterToolStartedObservation, m as RunIdentity, n as AdapterModelStepObservation, r as AdapterObservation, t as AdapterModelInputObservation } from "./observer-DnEMHl8z.cjs";
|
|
2
|
+
import { DurableObject } from "cloudflare:workers";
|
|
3
|
+
//#region src/otlp.d.ts
|
|
4
|
+
interface AdapterSpan {
|
|
5
|
+
traceId: string;
|
|
6
|
+
spanId: string;
|
|
7
|
+
parentSpanId?: string;
|
|
8
|
+
name: string;
|
|
9
|
+
startTimeUnixNano: string;
|
|
10
|
+
endTimeUnixNano: string;
|
|
11
|
+
attributes: Record<string, string | number | boolean>;
|
|
12
|
+
status?: {
|
|
13
|
+
code: number;
|
|
14
|
+
message?: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/session.d.ts
|
|
19
|
+
interface ModelState {
|
|
20
|
+
index: number;
|
|
21
|
+
startedAt: number;
|
|
22
|
+
input?: AdapterModelInputObservation;
|
|
23
|
+
result?: AdapterModelStepObservation;
|
|
24
|
+
}
|
|
25
|
+
interface ToolState {
|
|
26
|
+
id: string;
|
|
27
|
+
startedAt: number;
|
|
28
|
+
input: AdapterToolStartedObservation;
|
|
29
|
+
ended: boolean;
|
|
30
|
+
}
|
|
31
|
+
interface AdapterSession {
|
|
32
|
+
version: 1;
|
|
33
|
+
identity: RunIdentity;
|
|
34
|
+
exchangeId: string;
|
|
35
|
+
startedAt: number;
|
|
36
|
+
models: ModelState[];
|
|
37
|
+
tools: ToolState[];
|
|
38
|
+
telemetryIncomplete?: boolean;
|
|
39
|
+
terminal?: 'finished' | 'errored' | 'aborted' | 'unsupported' | 'incomplete';
|
|
40
|
+
}
|
|
41
|
+
interface SessionReduction {
|
|
42
|
+
session: AdapterSession;
|
|
43
|
+
spans: AdapterSpan[];
|
|
44
|
+
diagnostic?: 'identity_conflict' | 'session_limit' | 'missing_operation_start' | 'unsupported' | 'incomplete';
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/outbox.d.ts
|
|
48
|
+
interface OtlpBatch {
|
|
49
|
+
version: 1;
|
|
50
|
+
deliveryId: string;
|
|
51
|
+
body: Uint8Array;
|
|
52
|
+
createdAt: number;
|
|
53
|
+
}
|
|
54
|
+
type OutboxReceipt = {
|
|
55
|
+
accepted: true;
|
|
56
|
+
duplicate: boolean;
|
|
57
|
+
queuedAt: number;
|
|
58
|
+
} | {
|
|
59
|
+
accepted: false;
|
|
60
|
+
code: 'invalid_payload' | 'payload_too_large' | 'outbox_full';
|
|
61
|
+
queuedRows: number;
|
|
62
|
+
queuedBytes: number;
|
|
63
|
+
};
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/durable-object.d.ts
|
|
66
|
+
export interface CloudflareOtlpOutboxEnv {
|
|
67
|
+
RUNTYPE_AGENT_ID: string;
|
|
68
|
+
RUNTYPE_API_KEY: string;
|
|
69
|
+
RUNTYPE_BASE_URL: string;
|
|
70
|
+
}
|
|
71
|
+
export interface AdapterObserveReceipt {
|
|
72
|
+
accepted: boolean;
|
|
73
|
+
duplicate: boolean;
|
|
74
|
+
diagnostic?: SessionReduction['diagnostic'] | 'missing_session' | 'outbox_full' | 'payload_too_large' | 'invalid_payload';
|
|
75
|
+
queuedRows?: number;
|
|
76
|
+
queuedBytes?: number;
|
|
77
|
+
}
|
|
78
|
+
export interface AdapterDiagnostics {
|
|
79
|
+
accepted: number;
|
|
80
|
+
duplicate: number;
|
|
81
|
+
missingSession: number;
|
|
82
|
+
identityConflict: number;
|
|
83
|
+
sessionLimit: number;
|
|
84
|
+
missingOperationStart: number;
|
|
85
|
+
incomplete: number;
|
|
86
|
+
unsupported: number;
|
|
87
|
+
outboxRefused: number;
|
|
88
|
+
expired: number;
|
|
89
|
+
rejected: number;
|
|
90
|
+
pendingRows: number;
|
|
91
|
+
pendingBytes: number;
|
|
92
|
+
earliestRetryAt?: number;
|
|
93
|
+
failureCounts: Record<string, number>;
|
|
94
|
+
}
|
|
95
|
+
/** A companion DO; it never reads or modifies an application Agent's alarm. */
|
|
96
|
+
export declare class RuntypeOtlpOutbox extends DurableObject<CloudflareOtlpOutboxEnv> {
|
|
97
|
+
private readonly outbox;
|
|
98
|
+
private readonly storage;
|
|
99
|
+
constructor(ctx: DurableObjectState, env: CloudflareOtlpOutboxEnv);
|
|
100
|
+
observe(observation: AdapterObservation): Promise<AdapterObserveReceipt>;
|
|
101
|
+
diagnostics(): Promise<AdapterDiagnostics>;
|
|
102
|
+
enqueue(batch: OtlpBatch): Promise<OutboxReceipt>;
|
|
103
|
+
alarm(): Promise<void>;
|
|
104
|
+
private markIncomplete;
|
|
105
|
+
private admitSession;
|
|
106
|
+
private batch;
|
|
107
|
+
private diagnosticKey;
|
|
108
|
+
private recordDiagnostic;
|
|
109
|
+
private send;
|
|
110
|
+
private networkFailureCode;
|
|
111
|
+
private armTransaction;
|
|
112
|
+
}
|
|
113
|
+
//#endregion
|
|
114
|
+
export {}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { a as AdapterToolStartedObservation, m as RunIdentity, n as AdapterModelStepObservation, r as AdapterObservation, t as AdapterModelInputObservation } from "./observer-DnEMHl8z.js";
|
|
2
|
+
import { DurableObject } from "cloudflare:workers";
|
|
3
|
+
//#region src/otlp.d.ts
|
|
4
|
+
interface AdapterSpan {
|
|
5
|
+
traceId: string;
|
|
6
|
+
spanId: string;
|
|
7
|
+
parentSpanId?: string;
|
|
8
|
+
name: string;
|
|
9
|
+
startTimeUnixNano: string;
|
|
10
|
+
endTimeUnixNano: string;
|
|
11
|
+
attributes: Record<string, string | number | boolean>;
|
|
12
|
+
status?: {
|
|
13
|
+
code: number;
|
|
14
|
+
message?: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/session.d.ts
|
|
19
|
+
interface ModelState {
|
|
20
|
+
index: number;
|
|
21
|
+
startedAt: number;
|
|
22
|
+
input?: AdapterModelInputObservation;
|
|
23
|
+
result?: AdapterModelStepObservation;
|
|
24
|
+
}
|
|
25
|
+
interface ToolState {
|
|
26
|
+
id: string;
|
|
27
|
+
startedAt: number;
|
|
28
|
+
input: AdapterToolStartedObservation;
|
|
29
|
+
ended: boolean;
|
|
30
|
+
}
|
|
31
|
+
interface AdapterSession {
|
|
32
|
+
version: 1;
|
|
33
|
+
identity: RunIdentity;
|
|
34
|
+
exchangeId: string;
|
|
35
|
+
startedAt: number;
|
|
36
|
+
models: ModelState[];
|
|
37
|
+
tools: ToolState[];
|
|
38
|
+
telemetryIncomplete?: boolean;
|
|
39
|
+
terminal?: 'finished' | 'errored' | 'aborted' | 'unsupported' | 'incomplete';
|
|
40
|
+
}
|
|
41
|
+
interface SessionReduction {
|
|
42
|
+
session: AdapterSession;
|
|
43
|
+
spans: AdapterSpan[];
|
|
44
|
+
diagnostic?: 'identity_conflict' | 'session_limit' | 'missing_operation_start' | 'unsupported' | 'incomplete';
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/outbox.d.ts
|
|
48
|
+
interface OtlpBatch {
|
|
49
|
+
version: 1;
|
|
50
|
+
deliveryId: string;
|
|
51
|
+
body: Uint8Array;
|
|
52
|
+
createdAt: number;
|
|
53
|
+
}
|
|
54
|
+
type OutboxReceipt = {
|
|
55
|
+
accepted: true;
|
|
56
|
+
duplicate: boolean;
|
|
57
|
+
queuedAt: number;
|
|
58
|
+
} | {
|
|
59
|
+
accepted: false;
|
|
60
|
+
code: 'invalid_payload' | 'payload_too_large' | 'outbox_full';
|
|
61
|
+
queuedRows: number;
|
|
62
|
+
queuedBytes: number;
|
|
63
|
+
};
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/durable-object.d.ts
|
|
66
|
+
export interface CloudflareOtlpOutboxEnv {
|
|
67
|
+
RUNTYPE_AGENT_ID: string;
|
|
68
|
+
RUNTYPE_API_KEY: string;
|
|
69
|
+
RUNTYPE_BASE_URL: string;
|
|
70
|
+
}
|
|
71
|
+
export interface AdapterObserveReceipt {
|
|
72
|
+
accepted: boolean;
|
|
73
|
+
duplicate: boolean;
|
|
74
|
+
diagnostic?: SessionReduction['diagnostic'] | 'missing_session' | 'outbox_full' | 'payload_too_large' | 'invalid_payload';
|
|
75
|
+
queuedRows?: number;
|
|
76
|
+
queuedBytes?: number;
|
|
77
|
+
}
|
|
78
|
+
export interface AdapterDiagnostics {
|
|
79
|
+
accepted: number;
|
|
80
|
+
duplicate: number;
|
|
81
|
+
missingSession: number;
|
|
82
|
+
identityConflict: number;
|
|
83
|
+
sessionLimit: number;
|
|
84
|
+
missingOperationStart: number;
|
|
85
|
+
incomplete: number;
|
|
86
|
+
unsupported: number;
|
|
87
|
+
outboxRefused: number;
|
|
88
|
+
expired: number;
|
|
89
|
+
rejected: number;
|
|
90
|
+
pendingRows: number;
|
|
91
|
+
pendingBytes: number;
|
|
92
|
+
earliestRetryAt?: number;
|
|
93
|
+
failureCounts: Record<string, number>;
|
|
94
|
+
}
|
|
95
|
+
/** A companion DO; it never reads or modifies an application Agent's alarm. */
|
|
96
|
+
export declare class RuntypeOtlpOutbox extends DurableObject<CloudflareOtlpOutboxEnv> {
|
|
97
|
+
private readonly outbox;
|
|
98
|
+
private readonly storage;
|
|
99
|
+
constructor(ctx: DurableObjectState, env: CloudflareOtlpOutboxEnv);
|
|
100
|
+
observe(observation: AdapterObservation): Promise<AdapterObserveReceipt>;
|
|
101
|
+
diagnostics(): Promise<AdapterDiagnostics>;
|
|
102
|
+
enqueue(batch: OtlpBatch): Promise<OutboxReceipt>;
|
|
103
|
+
alarm(): Promise<void>;
|
|
104
|
+
private markIncomplete;
|
|
105
|
+
private admitSession;
|
|
106
|
+
private batch;
|
|
107
|
+
private diagnosticKey;
|
|
108
|
+
private recordDiagnostic;
|
|
109
|
+
private send;
|
|
110
|
+
private networkFailureCode;
|
|
111
|
+
private armTransaction;
|
|
112
|
+
}
|
|
113
|
+
//#endregion
|
|
114
|
+
export {}
|