@moinulmoin/eden-runtime-cloudflare 0.1.5 → 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.
Files changed (47) hide show
  1. package/NOTICE +0 -31
  2. package/dist/eden-eve-host-worker.mjs +130 -10
  3. package/dist/eve-host-runtime.d.ts +13 -3
  4. package/dist/eve-host-runtime.js +47 -3
  5. package/dist/eve-host.d.ts +6 -1
  6. package/dist/eve-host.js +20 -11
  7. package/dist/index.d.ts +0 -18
  8. package/dist/index.js +0 -5
  9. package/package.json +2 -6
  10. package/dist/artifact-runtime.d.ts +0 -27
  11. package/dist/artifact-runtime.js +0 -14
  12. package/dist/http-host.d.ts +0 -6
  13. package/dist/http-host.js +0 -419
  14. package/dist/model-adapter-internal.d.ts +0 -12
  15. package/dist/model-adapter-internal.js +0 -172
  16. package/dist/model-adapter.d.ts +0 -9
  17. package/dist/model-adapter.js +0 -56
  18. package/dist/model-contracts.d.ts +0 -92
  19. package/dist/model-contracts.js +0 -2
  20. package/dist/model-normalizers.d.ts +0 -7
  21. package/dist/model-normalizers.js +0 -453
  22. package/dist/session-checkpoint.d.ts +0 -48
  23. package/dist/session-checkpoint.js +0 -300
  24. package/dist/session-identity.d.ts +0 -9
  25. package/dist/session-identity.js +0 -45
  26. package/dist/session-jobs.d.ts +0 -69
  27. package/dist/session-jobs.js +0 -427
  28. package/dist/session-journal.d.ts +0 -154
  29. package/dist/session-journal.js +0 -391
  30. package/dist/session-schema.d.ts +0 -21
  31. package/dist/session-schema.js +0 -247
  32. package/dist/session-state.d.ts +0 -165
  33. package/dist/session-state.js +0 -168
  34. package/dist/session.d.ts +0 -40
  35. package/dist/session.js +0 -792
  36. package/dist/test-execution.d.ts +0 -8
  37. package/dist/test-execution.js +0 -12
  38. package/dist/test-worker.d.ts +0 -12
  39. package/dist/test-worker.js +0 -214
  40. package/dist/tool-harness.d.ts +0 -31
  41. package/dist/tool-harness.js +0 -226
  42. package/dist/turn-runner-storage.d.ts +0 -28
  43. package/dist/turn-runner-storage.js +0 -583
  44. package/dist/turn-runner-types.d.ts +0 -112
  45. package/dist/turn-runner-types.js +0 -21
  46. package/dist/turn-runner.d.ts +0 -6
  47. package/dist/turn-runner.js +0 -370
@@ -1,165 +0,0 @@
1
- import type { EdenEvent, EdenEventType, EdenJsonValue, EdenSessionStatus, EdenStepPhase, EdenTurnStatus, EdenVersionSet } from "@moinulmoin/eden-definitions";
2
- import type { EdenSqlStorage } from "./session-journal.js";
3
- interface StepRow {
4
- readonly [key: string]: string | number | null;
5
- readonly step_id: string;
6
- readonly turn_id: string;
7
- readonly logical_key: string;
8
- readonly phase: EdenStepPhase;
9
- readonly status: "pending" | "running" | "completed" | "retryable" | "failed";
10
- readonly attempt_count: number;
11
- readonly result_ref: string | null;
12
- readonly error_id: string | null;
13
- readonly created_at: string;
14
- readonly updated_at: string;
15
- readonly completed_at: string | null;
16
- }
17
- interface MessageRow {
18
- readonly [key: string]: string | number | null;
19
- readonly message_id: string;
20
- readonly turn_id: string | null;
21
- readonly role: "user" | "assistant" | "tool";
22
- readonly content: string;
23
- readonly created_at: string;
24
- readonly completed_at: string | null;
25
- }
26
- interface EffectRow {
27
- readonly [key: string]: string | number | null;
28
- readonly effect_id: string;
29
- readonly turn_id: string;
30
- readonly step_id: string;
31
- readonly call_id: string;
32
- readonly tool_name: string;
33
- readonly idempotency_key: string;
34
- readonly status: "requested" | "running" | "completed" | "failed";
35
- readonly input_json: string;
36
- readonly output_json: string | null;
37
- readonly error_json: string | null;
38
- readonly created_at: string;
39
- readonly updated_at: string;
40
- readonly completed_at: string | null;
41
- }
42
- interface JobRow {
43
- readonly [key: string]: string | number | null;
44
- readonly job_id: string;
45
- readonly kind: string;
46
- readonly status: "pending" | "running" | "completed" | "retryable" | "dead";
47
- readonly due_at: number;
48
- readonly attempts: number;
49
- readonly max_attempts: number;
50
- readonly last_error: string | null;
51
- readonly recovery_action: string | null;
52
- readonly created_at: string;
53
- readonly updated_at: string;
54
- readonly completed_at: string | null;
55
- }
56
- interface ErrorRow {
57
- readonly [key: string]: string | number | null;
58
- readonly error_id: string;
59
- readonly turn_id: string | null;
60
- readonly step_id: string | null;
61
- readonly code: string;
62
- readonly message: string;
63
- readonly retryable: number;
64
- readonly status: "open" | "resolved";
65
- readonly created_at: string;
66
- readonly resolved_at: string | null;
67
- }
68
- export interface EdenSessionMetaState {
69
- readonly sessionId: string;
70
- readonly ownerPrincipal: string;
71
- readonly status: EdenSessionStatus;
72
- readonly createdAt: string;
73
- readonly updatedAt: string;
74
- readonly versions: EdenVersionSet;
75
- readonly sqliteSchemaVersion: number;
76
- }
77
- export interface EdenTurnState {
78
- readonly turnId: string;
79
- readonly status: EdenTurnStatus;
80
- readonly acceptedAt: string;
81
- readonly startedAt: string | null;
82
- readonly completedAt: string | null;
83
- readonly failedAt: string | null;
84
- readonly errorId: string | null;
85
- }
86
- export interface EdenStepState {
87
- readonly stepId: string;
88
- readonly turnId: string;
89
- readonly logicalKey: string;
90
- readonly phase: EdenStepPhase;
91
- readonly status: StepRow["status"];
92
- readonly attemptCount: number;
93
- readonly resultRef: string | null;
94
- readonly errorId: string | null;
95
- readonly createdAt: string;
96
- readonly updatedAt: string;
97
- readonly completedAt: string | null;
98
- }
99
- export interface EdenMessageState {
100
- readonly messageId: string;
101
- readonly turnId: string | null;
102
- readonly role: MessageRow["role"];
103
- readonly content: string;
104
- readonly createdAt: string;
105
- readonly completedAt: string | null;
106
- }
107
- export interface EdenProjectionState {
108
- readonly projectionKey: string;
109
- readonly value: EdenJsonValue;
110
- readonly updatedAt: string;
111
- }
112
- export interface EdenEffectState {
113
- readonly effectId: string;
114
- readonly turnId: string;
115
- readonly stepId: string;
116
- readonly callId: string;
117
- readonly toolName: string;
118
- readonly idempotencyKey: string;
119
- readonly status: EffectRow["status"];
120
- readonly input: EdenJsonValue;
121
- readonly output: EdenJsonValue | null;
122
- readonly error: EdenJsonValue | null;
123
- readonly createdAt: string;
124
- readonly updatedAt: string;
125
- readonly completedAt: string | null;
126
- }
127
- export interface EdenJobState {
128
- readonly jobId: string;
129
- readonly kind: string;
130
- readonly status: JobRow["status"];
131
- readonly dueAt: number;
132
- readonly attempts: number;
133
- readonly maxAttempts: number;
134
- readonly lastError: string | null;
135
- readonly recoveryAction: string | null;
136
- readonly createdAt: string;
137
- readonly updatedAt: string;
138
- readonly completedAt: string | null;
139
- }
140
- export interface EdenErrorState {
141
- readonly errorId: string;
142
- readonly turnId: string | null;
143
- readonly stepId: string | null;
144
- readonly code: string;
145
- readonly message: string;
146
- readonly retryable: boolean;
147
- readonly status: ErrorRow["status"];
148
- readonly createdAt: string;
149
- readonly resolvedAt: string | null;
150
- }
151
- export interface EdenSessionRehydratedState {
152
- readonly sessionMeta: EdenSessionMetaState | null;
153
- readonly latestCursor: number;
154
- readonly events: readonly EdenEvent<EdenEventType>[];
155
- readonly turns: readonly EdenTurnState[];
156
- readonly steps: readonly EdenStepState[];
157
- readonly messages: readonly EdenMessageState[];
158
- readonly projections: readonly EdenProjectionState[];
159
- readonly effects: readonly EdenEffectState[];
160
- readonly jobs: readonly EdenJobState[];
161
- readonly errors: readonly EdenErrorState[];
162
- }
163
- export declare function readSessionRehydratedState(sql: EdenSqlStorage, sessionId: string): EdenSessionRehydratedState;
164
- export {};
165
- //# sourceMappingURL=session-state.d.ts.map
@@ -1,168 +0,0 @@
1
- import { readJournalEvents, readLatestJournalCursor } from "./session-journal.js";
2
- import { readAppliedSessionSchemaVersion } from "./session-schema.js";
3
- function jsonValue(value) {
4
- return JSON.parse(value);
5
- }
6
- function readMeta(sql, sessionId) {
7
- const row = sql
8
- .exec(`SELECT session_id, owner_principal, status, created_at, updated_at,
9
- runtime_version, agent_bundle_version, manifest_version,
10
- protocol_version, schema_version, artifact_schema_version
11
- FROM session_meta
12
- WHERE session_id = ?`, sessionId)
13
- .toArray()[0];
14
- if (row === undefined)
15
- return null;
16
- return {
17
- sessionId: row.session_id,
18
- ownerPrincipal: row.owner_principal,
19
- status: row.status,
20
- createdAt: row.created_at,
21
- updatedAt: row.updated_at,
22
- versions: {
23
- runtime: row.runtime_version,
24
- agentBundle: row.agent_bundle_version,
25
- manifest: row.manifest_version,
26
- protocol: row.protocol_version,
27
- schema: row.artifact_schema_version,
28
- },
29
- sqliteSchemaVersion: readAppliedSessionSchemaVersion(sql),
30
- };
31
- }
32
- export function readSessionRehydratedState(sql, sessionId) {
33
- const turns = sql
34
- .exec(`SELECT turn_id, status, accepted_at, started_at, completed_at,
35
- failed_at, error_id
36
- FROM turns
37
- WHERE session_id = ?
38
- ORDER BY accepted_at ASC, turn_id ASC`, sessionId)
39
- .toArray()
40
- .map((row) => ({
41
- turnId: row.turn_id,
42
- status: row.status,
43
- acceptedAt: row.accepted_at,
44
- startedAt: row.started_at,
45
- completedAt: row.completed_at,
46
- failedAt: row.failed_at,
47
- errorId: row.error_id,
48
- }));
49
- const steps = sql
50
- .exec(`SELECT step_id, turn_id, logical_key, phase, status, attempt_count,
51
- result_ref, error_id, created_at, updated_at, completed_at
52
- FROM steps
53
- WHERE session_id = ?
54
- ORDER BY created_at ASC, step_id ASC`, sessionId)
55
- .toArray()
56
- .map((row) => ({
57
- stepId: row.step_id,
58
- turnId: row.turn_id,
59
- logicalKey: row.logical_key,
60
- phase: row.phase,
61
- status: row.status,
62
- attemptCount: row.attempt_count,
63
- resultRef: row.result_ref,
64
- errorId: row.error_id,
65
- createdAt: row.created_at,
66
- updatedAt: row.updated_at,
67
- completedAt: row.completed_at,
68
- }));
69
- const messages = sql
70
- .exec(`SELECT message_id, turn_id, role, content, created_at, completed_at
71
- FROM messages
72
- WHERE session_id = ?
73
- ORDER BY created_at ASC, message_id ASC`, sessionId)
74
- .toArray()
75
- .map((row) => ({
76
- messageId: row.message_id,
77
- turnId: row.turn_id,
78
- role: row.role,
79
- content: row.content,
80
- createdAt: row.created_at,
81
- completedAt: row.completed_at,
82
- }));
83
- const projections = sql
84
- .exec(`SELECT projection_key, projection_json, updated_at
85
- FROM projections
86
- WHERE session_id = ?
87
- ORDER BY projection_key ASC`, sessionId)
88
- .toArray()
89
- .map((row) => ({
90
- projectionKey: row.projection_key,
91
- value: jsonValue(row.projection_json),
92
- updatedAt: row.updated_at,
93
- }));
94
- const effects = sql
95
- .exec(`SELECT effect_id, turn_id, step_id, call_id, tool_name,
96
- idempotency_key, status, input_json, output_json, error_json,
97
- created_at, updated_at, completed_at
98
- FROM effects
99
- WHERE session_id = ?
100
- ORDER BY created_at ASC, effect_id ASC`, sessionId)
101
- .toArray()
102
- .map((row) => ({
103
- effectId: row.effect_id,
104
- turnId: row.turn_id,
105
- stepId: row.step_id,
106
- callId: row.call_id,
107
- toolName: row.tool_name,
108
- idempotencyKey: row.idempotency_key,
109
- status: row.status,
110
- input: jsonValue(row.input_json),
111
- output: row.output_json === null ? null : jsonValue(row.output_json),
112
- error: row.error_json === null ? null : jsonValue(row.error_json),
113
- createdAt: row.created_at,
114
- updatedAt: row.updated_at,
115
- completedAt: row.completed_at,
116
- }));
117
- const jobs = sql
118
- .exec(`SELECT job_id, kind, status, due_at, attempts, max_attempts,
119
- last_error, recovery_action, created_at, updated_at, completed_at
120
- FROM jobs
121
- WHERE session_id = ?
122
- ORDER BY due_at ASC, job_id ASC`, sessionId)
123
- .toArray()
124
- .map((row) => ({
125
- jobId: row.job_id,
126
- kind: row.kind,
127
- status: row.status,
128
- dueAt: row.due_at,
129
- attempts: row.attempts,
130
- maxAttempts: row.max_attempts,
131
- lastError: row.last_error,
132
- recoveryAction: row.recovery_action,
133
- createdAt: row.created_at,
134
- updatedAt: row.updated_at,
135
- completedAt: row.completed_at,
136
- }));
137
- const errors = sql
138
- .exec(`SELECT error_id, turn_id, step_id, code, message, retryable,
139
- status, created_at, resolved_at
140
- FROM errors
141
- WHERE session_id = ?
142
- ORDER BY created_at ASC, error_id ASC`, sessionId)
143
- .toArray()
144
- .map((row) => ({
145
- errorId: row.error_id,
146
- turnId: row.turn_id,
147
- stepId: row.step_id,
148
- code: row.code,
149
- message: row.message,
150
- retryable: row.retryable === 1,
151
- status: row.status,
152
- createdAt: row.created_at,
153
- resolvedAt: row.resolved_at,
154
- }));
155
- return {
156
- sessionMeta: readMeta(sql, sessionId),
157
- latestCursor: readLatestJournalCursor(sql, sessionId),
158
- events: readJournalEvents(sql, sessionId, 0),
159
- turns,
160
- steps,
161
- messages,
162
- projections,
163
- effects,
164
- jobs,
165
- errors,
166
- };
167
- }
168
- //# sourceMappingURL=session-state.js.map
package/dist/session.d.ts DELETED
@@ -1,40 +0,0 @@
1
- import { DurableObject } from "cloudflare:workers";
2
- import type { EdenVersionSet } from "@moinulmoin/eden-definitions";
3
- import { type RecoveryJobInspectionOptions, type RecoveryJobEnqueueResult, type RecoveryJobInput, type RecoveryJobInspection, type RecoveryJobRecoveryResult } from "./session-jobs.js";
4
- export interface EdenSessionEnvironment {
5
- readonly [key: string]: unknown;
6
- readonly AI?: unknown;
7
- }
8
- type EdenSessionState = ConstructorParameters<typeof DurableObject>[0];
9
- export interface EdenSessionInitialization {
10
- readonly sessionId: string;
11
- readonly ownerPrincipal: string;
12
- readonly versions: EdenVersionSet;
13
- }
14
- export declare class EdenSession extends DurableObject<EdenSessionEnvironment> {
15
- private readonly initialized;
16
- constructor(ctx: EdenSessionState, env: EdenSessionEnvironment);
17
- fetch(request: Request): Promise<Response>;
18
- alarm(): Promise<void>;
19
- enqueueRecoveryJob(input: RecoveryJobInput): Promise<RecoveryJobEnqueueResult>;
20
- inspectRecoveryJobs(options?: RecoveryJobInspectionOptions): RecoveryJobInspection;
21
- recoverRecoveryJob(jobId: string, input?: {
22
- readonly recoveryAction?: string;
23
- readonly dueAt?: number;
24
- }): Promise<RecoveryJobRecoveryResult>;
25
- private schemaResponse;
26
- private eventsResponse;
27
- private initialize;
28
- private acceptCommandResponse;
29
- private readEventsResponse;
30
- private streamEventsResponse;
31
- private requireSessionId;
32
- private recoveryJobsResponse;
33
- private enqueueRecoveryJobResponse;
34
- private recoverRecoveryJobResponse;
35
- private rearmRecoveryAlarm;
36
- private executeRecoveryJob;
37
- private executeBoundedTurnJob;
38
- }
39
- export {};
40
- //# sourceMappingURL=session.d.ts.map