@ixo/oracle-runtime-workers 0.9.0 → 0.11.0
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 +5 -2
- package/package.json +1 -1
- package/src/core/context-budget.ts +201 -0
- package/src/core/context-window.ts +289 -0
- package/src/core/env.ts +38 -0
- package/src/core/main-agent-types.ts +46 -0
- package/src/core/main-agent.ts +86 -9
- package/src/core/middlewares/context-guard.ts +270 -0
- package/src/core/middlewares/result-cap.ts +180 -0
- package/src/core/middlewares/summarization.ts +87 -6
- package/src/core/middlewares/tool-marks.ts +209 -0
- package/src/core/openrouter-pricing.ts +42 -1
- package/src/core/read-result-tool.ts +77 -0
- package/src/core/runtime-context.ts +7 -0
- package/src/core/sub-agent-fallback.ts +20 -3
- package/src/core/wrap-plugin-tool.ts +24 -3
- package/src/do/ambient.ts +17 -0
- package/src/do/contracts.ts +249 -0
- package/src/do/result-store-test-do.ts +88 -0
- package/src/do/result-store.ts +339 -0
- package/src/do/run-buffer.ts +204 -0
- package/src/do/run-coordinator.ts +572 -0
- package/src/do/run-request.ts +52 -0
- package/src/do/run-store-test-do.ts +130 -0
- package/src/do/run-store.ts +604 -0
- package/src/do/session-id-migration.ts +85 -0
- package/src/do/speaker-prefix.ts +37 -0
- package/src/do/sse-stream.ts +567 -400
- package/src/do/transcript.ts +238 -0
- package/src/do/turn-body.ts +10 -0
- package/src/do/user-oracle-do.ts +1019 -169
- package/src/matrix/gateway-do.ts +230 -29
- package/src/matrix/group-chat-summarizer.ts +107 -0
- package/src/matrix/group-chat.ts +1163 -0
- package/src/matrix/inbox-store.ts +23 -3
- package/src/matrix/ingest.ts +54 -11
- package/src/matrix/reply-chain.ts +34 -25
- package/src/owner-store/ixo-vfs-store.ts +12 -5
- package/src/owner-store/matrix-media-store.ts +12 -7
- package/src/owner-store/measure.ts +39 -0
- package/src/owner-store/migrating-store.ts +9 -3
- package/src/owner-store/types.ts +14 -4
- package/src/plugin-api/tool-helper.ts +9 -1
- package/src/plugin-api/types.ts +86 -0
- package/src/plugins/index.ts +3 -0
- package/src/plugins/matrix-group-chats/README.md +70 -0
- package/src/plugins/matrix-group-chats/index.ts +132 -0
- package/src/plugins/matrix-group-chats/tools.ts +172 -0
- package/src/plugins/tasks/tasks-tools.ts +4 -0
- package/src/shell/app.ts +78 -0
- package/src/sqlite/cache-config.ts +27 -6
- package/src/sqlite/chunk-layout.ts +14 -0
- package/src/sqlite/database.ts +188 -19
- package/src/sqlite/do-vfs.ts +963 -99
- package/src/sqlite/index.ts +13 -0
- package/src/sqlite/page-tier.ts +668 -0
- package/src/sqlite/sqlite-saver.ts +81 -0
- package/src/tasks/scheduler.ts +134 -3
- package/src/tasks/store.ts +22 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test-only Durable Object driving `RunStore` over a real DO-backed SQLite
|
|
3
|
+
* inside workerd. Bound as `RUN_STORE_TEST` by `test/wrangler.test.jsonc`.
|
|
4
|
+
* Not part of the runtime.
|
|
5
|
+
*/
|
|
6
|
+
import { DurableObject } from 'cloudflare:workers';
|
|
7
|
+
import { DoSqliteDatabase } from '../sqlite/database';
|
|
8
|
+
import type { PackedSegment } from './run-buffer';
|
|
9
|
+
import { RunStore, type RunRecord, type ToolMark } from './run-store';
|
|
10
|
+
|
|
11
|
+
export class RunStoreTestDO extends DurableObject {
|
|
12
|
+
private db: DoSqliteDatabase | undefined;
|
|
13
|
+
|
|
14
|
+
private store: RunStore | undefined;
|
|
15
|
+
|
|
16
|
+
private nowMs = Date.parse('2026-09-13T10:00:00.000Z');
|
|
17
|
+
|
|
18
|
+
private async runStore(): Promise<RunStore> {
|
|
19
|
+
if (!this.db || !this.db.isOpen) {
|
|
20
|
+
this.db = await DoSqliteDatabase.open(this.ctx, 'runs-test.db');
|
|
21
|
+
this.store = undefined;
|
|
22
|
+
}
|
|
23
|
+
this.store ??= new RunStore(this.db, () => this.nowMs);
|
|
24
|
+
return this.store;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async setNow(ms: number): Promise<void> {
|
|
28
|
+
this.nowMs = ms;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Run raw SQL on the store's database before/around the store (migration tests). */
|
|
32
|
+
async rawRun(sql: string): Promise<void> {
|
|
33
|
+
if (!this.db || !this.db.isOpen) {
|
|
34
|
+
this.db = await DoSqliteDatabase.open(this.ctx, 'runs-test.db');
|
|
35
|
+
this.store = undefined;
|
|
36
|
+
}
|
|
37
|
+
await this.db.run(sql);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async columnsOf(table: string): Promise<string[]> {
|
|
41
|
+
if (!this.db || !this.db.isOpen) {
|
|
42
|
+
this.db = await DoSqliteDatabase.open(this.ctx, 'runs-test.db');
|
|
43
|
+
this.store = undefined;
|
|
44
|
+
}
|
|
45
|
+
const rows = await this.db.exec<{ name: string }>(
|
|
46
|
+
`PRAGMA table_info(${table})`,
|
|
47
|
+
);
|
|
48
|
+
return rows.map((r) => r.name);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async create(input: Parameters<RunStore['create']>[0]): Promise<void> {
|
|
52
|
+
await (await this.runStore()).create(input);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async get(runId: string): Promise<RunRecord | undefined> {
|
|
56
|
+
return (await this.runStore()).get(runId);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async update(
|
|
60
|
+
runId: string,
|
|
61
|
+
patch: Parameters<RunStore['update']>[1],
|
|
62
|
+
): Promise<void> {
|
|
63
|
+
await (await this.runStore()).update(runId, patch);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async activeForSession(sessionId: string): Promise<RunRecord | undefined> {
|
|
67
|
+
return (await this.runStore()).activeForSession(sessionId);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async listActive(): Promise<RunRecord[]> {
|
|
71
|
+
return (await this.runStore()).listActive();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async queuedForSession(sessionId: string): Promise<RunRecord[]> {
|
|
75
|
+
return (await this.runStore()).queuedForSession(sessionId);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async appendSegment(runId: string, segment: PackedSegment): Promise<void> {
|
|
79
|
+
await (await this.runStore()).appendSegment(runId, segment);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
async readSegments(runId: string, after = 0): Promise<PackedSegment[]> {
|
|
83
|
+
return (await this.runStore()).readSegments(runId, after);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async deleteSegments(runId: string): Promise<void> {
|
|
87
|
+
await (await this.runStore()).deleteSegments(runId);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async countSegments(runId: string): Promise<number> {
|
|
91
|
+
return (await this.runStore()).countSegments(runId);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async startMark(
|
|
95
|
+
input: Parameters<RunStore['startMark']>[0],
|
|
96
|
+
): Promise<ToolMark | undefined> {
|
|
97
|
+
return (await this.runStore()).startMark(input);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async bumpMark(runId: string, toolCallId: string): Promise<void> {
|
|
101
|
+
await (await this.runStore()).bumpMark(runId, toolCallId);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async finishMark(
|
|
105
|
+
runId: string,
|
|
106
|
+
toolCallId: string,
|
|
107
|
+
outcome: 'ok' | 'error' | 'interrupted',
|
|
108
|
+
): Promise<void> {
|
|
109
|
+
await (await this.runStore()).finishMark(runId, toolCallId, outcome);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async listMarks(runId: string): Promise<ToolMark[]> {
|
|
113
|
+
return (await this.runStore()).listMarks(runId);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Close the database so the next call re-opens it (a fresh `RunStore`, setup again). */
|
|
117
|
+
async reopen(): Promise<void> {
|
|
118
|
+
await this.db?.close();
|
|
119
|
+
this.db = undefined;
|
|
120
|
+
this.store = undefined;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async rowCount(table: string): Promise<number> {
|
|
124
|
+
await this.runStore();
|
|
125
|
+
const row = await this.db!.get<{ n: number }>(
|
|
126
|
+
`SELECT COUNT(*) AS n FROM ${table}`,
|
|
127
|
+
);
|
|
128
|
+
return Number(row?.n ?? 0);
|
|
129
|
+
}
|
|
130
|
+
}
|