@sema-agent/server 1.311.0 → 1.313.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/dist/auth-keys.d.ts +14 -0
- package/dist/auth-keys.js +31 -0
- package/dist/brain.d.ts +1 -1
- package/dist/capabilities/select-environment-tool.d.ts +1 -1
- package/dist/config-types.d.ts +306 -0
- package/dist/config-types.js +2 -0
- package/dist/config.d.ts +4 -305
- package/dist/config.js +1 -1
- package/dist/env-facts.d.ts +1 -1
- package/dist/fleet/fleet-bus.d.ts +1 -0
- package/dist/fleet/fleet-bus.js +1 -0
- package/dist/hooks/hook-llm.d.ts +1 -1
- package/dist/http/server.d.ts +5 -85
- package/dist/http/wire-types.d.ts +84 -0
- package/dist/http/wire-types.js +2 -0
- package/dist/images/manifest.d.ts +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/per-task-image.d.ts +2 -2
- package/dist/plugins/file-run-store.d.ts +1 -1
- package/dist/plugins/local-session-store.d.ts +2 -2
- package/dist/plugins/local-session-store.js +1 -1
- package/dist/plugins/mailbox-store-sql.d.ts +2 -2
- package/dist/plugins/mailbox-store-sql.js +8 -4
- package/dist/plugins/memory-run-store.d.ts +1 -1
- package/dist/plugins/pg-image-bake.d.ts +2 -2
- package/dist/plugins/pg-image-bake.js +1 -1
- package/dist/plugins/pg-image-index.d.ts +2 -2
- package/dist/plugins/pg-image-index.js +1 -1
- package/dist/plugins/pg-pool.d.ts +1 -1
- package/dist/plugins/pg-run-store.d.ts +1 -1
- package/dist/plugins/pg-run-store.js +1 -1
- package/dist/plugins/pg-session-storage.d.ts +2 -2
- package/dist/plugins/pg-session-storage.js +2 -2
- package/dist/plugins/pg-tool-result-store.js +1 -1
- package/dist/plugins/session-store.d.ts +1 -1
- package/dist/plugins/sql-escape.d.ts +2 -0
- package/dist/plugins/sql-escape.js +4 -0
- package/dist/plugins/store-backend.d.ts +1 -1
- package/dist/plugins/store-contracts.d.ts +205 -0
- package/dist/plugins/store-contracts.js +61 -0
- package/dist/plugins/tidb-image-bake.d.ts +3 -95
- package/dist/plugins/tidb-image-bake.js +3 -35
- package/dist/plugins/tidb-image-index.d.ts +3 -76
- package/dist/plugins/tidb-image-index.js +2 -26
- package/dist/plugins/tidb-pool.d.ts +1 -1
- package/dist/plugins/tidb-run-store.d.ts +2 -32
- package/dist/plugins/tidb-run-store.js +1 -1
- package/dist/plugins/tidb-session-store.d.ts +2 -2
- package/dist/plugins/tidb-session-store.js +2 -2
- package/dist/plugins/tidb-tool-result-store.d.ts +1 -1
- package/dist/plugins/tidb-tool-result-store.js +2 -3
- package/dist/security.d.ts +6 -16
- package/dist/security.js +1 -30
- package/dist/sema-registry.d.ts +1 -1
- package/dist/session-sync-kernel.d.ts +47 -0
- package/dist/session-sync-kernel.js +47 -0
- package/dist/session-sync.d.ts +3 -45
- package/dist/session-sync.js +2 -46
- package/dist/trace/artifacts.d.ts +1 -1
- package/dist/trace/core-keyset-guard.d.ts +2 -2
- package/dist/trace/project.d.ts +2 -1
- package/dist/trace/project.js +1 -0
- package/package.json +2 -2
package/dist/fleet/fleet-bus.js
CHANGED
|
@@ -391,6 +391,7 @@ export function fleetBackgroundChildPublisher(bus, log) {
|
|
|
391
391
|
...(e.summary ? { summary: redactSecrets(e.summary) } : {}),
|
|
392
392
|
scope: (m.sessionScoped || e.sessionScoped) ? "session" : "task",
|
|
393
393
|
...(m.parentTaskId ? { parentTaskId: m.parentTaskId } : m.resolvedParentId ? { parentTaskId: m.resolvedParentId } : {}),
|
|
394
|
+
...(e.completionId ? { completionId: e.completionId } : {}),
|
|
394
395
|
...(e.stoppedBy ? { stoppedBy: e.stoppedBy } : {}),
|
|
395
396
|
...(e.resumable !== undefined ? { resumable: e.resumable } : {}),
|
|
396
397
|
...(e.recentSteps !== undefined
|
package/dist/hooks/hook-llm.d.ts
CHANGED
package/dist/http/server.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import http from "node:http";
|
|
2
2
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
3
|
-
import { type
|
|
4
|
-
import type {
|
|
3
|
+
import { type Runner, type TaskSpec, type TaskResult, type CascadeConfig, type QuestionAnswer, type WorkflowRunStore, type MemoryEntry } from "@sema-agent/core";
|
|
4
|
+
import type { TaskRequestBody } from "./wire-types.js";
|
|
5
|
+
import type { ServiceConfig } from "../config-types.js";
|
|
5
6
|
import { type RestartSignal, type SessionMirrorRuling } from "../sema-registry.js";
|
|
6
7
|
import { type OwnerAwareSessionStore } from "../security.js";
|
|
7
|
-
import type { BakeState, BakeErrorCode } from "../plugins/
|
|
8
|
+
import type { BakeState, BakeErrorCode } from "../plugins/store-contracts.js";
|
|
8
9
|
import type { RunStore, ApprovalStore, ImageIndex, ImageBake, CheckpointStoreFull, ResumeAnchorStore, ApprovalExemptionStore, ServiceSessionPolicyStore, ServiceFileSnapshotStore, StoreBackend } from "../plugins/store-backend.js";
|
|
9
10
|
import { type MemorySyncRequest, type MemorySyncResponse } from "../memory-sync.js";
|
|
10
11
|
import type { TaskAttachmentStore } from "../plugins/task-attachment-store.js";
|
|
@@ -159,88 +160,7 @@ export interface ServiceDeps {
|
|
|
159
160
|
blocked?: string[];
|
|
160
161
|
} | undefined;
|
|
161
162
|
}
|
|
162
|
-
export
|
|
163
|
-
objective: string;
|
|
164
|
-
sessionId?: string;
|
|
165
|
-
images?: Array<{
|
|
166
|
-
data: string;
|
|
167
|
-
mimeType: string;
|
|
168
|
-
} | {
|
|
169
|
-
url: string;
|
|
170
|
-
}>;
|
|
171
|
-
attachmentIds?: string[];
|
|
172
|
-
clientContext?: {
|
|
173
|
-
timeZone?: string;
|
|
174
|
-
userEmail?: string;
|
|
175
|
-
};
|
|
176
|
-
systemPrompt?: string;
|
|
177
|
-
appendSystemPrompt?: string;
|
|
178
|
-
model?: string;
|
|
179
|
-
compactionModel?: string;
|
|
180
|
-
maxCostUsd?: number;
|
|
181
|
-
maxTokens?: number;
|
|
182
|
-
verify?: boolean;
|
|
183
|
-
verifyRounds?: number;
|
|
184
|
-
cascade?: boolean;
|
|
185
|
-
jobId?: string;
|
|
186
|
-
skills?: Array<{
|
|
187
|
-
name: string;
|
|
188
|
-
description: string;
|
|
189
|
-
content: string;
|
|
190
|
-
}>;
|
|
191
|
-
sandboxImageProfile?: string;
|
|
192
|
-
capabilitiesNeeded?: string[];
|
|
193
|
-
outputSchema?: Record<string, unknown>;
|
|
194
|
-
reasoningEffort?: string;
|
|
195
|
-
resumeAt?: string;
|
|
196
|
-
resumeAtMode?: string;
|
|
197
|
-
requireExistingSession?: boolean;
|
|
198
|
-
suggestNextPrompts?: boolean | {
|
|
199
|
-
count?: number;
|
|
200
|
-
role?: string;
|
|
201
|
-
};
|
|
202
|
-
rewindFiles?: boolean;
|
|
203
|
-
rewindFilesTo?: string;
|
|
204
|
-
resilience?: {
|
|
205
|
-
allowDegrade?: boolean;
|
|
206
|
-
allowFailover?: boolean;
|
|
207
|
-
bypassBreaker?: boolean;
|
|
208
|
-
};
|
|
209
|
-
finalVerification?: boolean;
|
|
210
|
-
limits?: {
|
|
211
|
-
timeoutSec?: number;
|
|
212
|
-
maxOutputTokens?: number;
|
|
213
|
-
maxTurns?: number;
|
|
214
|
-
};
|
|
215
|
-
attachments?: {
|
|
216
|
-
todoReminder?: boolean;
|
|
217
|
-
changedFiles?: boolean | {
|
|
218
|
-
maxFiles?: number;
|
|
219
|
-
};
|
|
220
|
-
planModeReminder?: boolean;
|
|
221
|
-
backgroundTasks?: boolean;
|
|
222
|
-
toolsDelta?: boolean;
|
|
223
|
-
};
|
|
224
|
-
forwardSubagentEvents?: boolean;
|
|
225
|
-
scratchpadDir?: string;
|
|
226
|
-
retainSubagentSessions?: boolean | {
|
|
227
|
-
ttlMs?: number;
|
|
228
|
-
max?: number;
|
|
229
|
-
};
|
|
230
|
-
agents?: AgentDefinition[];
|
|
231
|
-
retainBackgroundProcesses?: boolean;
|
|
232
|
-
excludeTools?: string[];
|
|
233
|
-
deferTools?: string[];
|
|
234
|
-
promptProfile?: "simple" | "classic";
|
|
235
|
-
permissionMode?: string;
|
|
236
|
-
memoryWrite?: boolean;
|
|
237
|
-
projectId?: string;
|
|
238
|
-
cwd?: string;
|
|
239
|
-
mcpServers?: McpServerSpec[];
|
|
240
|
-
selfOrchestration?: boolean;
|
|
241
|
-
enableFork?: boolean;
|
|
242
|
-
[k: string]: unknown;
|
|
243
|
-
}
|
|
163
|
+
export type { TaskRequestBody } from "./wire-types.js";
|
|
244
164
|
export declare const MAX_USER_SKILLS = 10;
|
|
245
165
|
export declare const MAX_SKILL_CONTENT_CHARS = 1048576;
|
|
246
166
|
export declare const MAX_SYSTEM_PROMPT_CHARS = 16384;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { AgentDefinition, McpServerSpec } from "@sema-agent/core";
|
|
2
|
+
export interface TaskRequestBody {
|
|
3
|
+
objective: string;
|
|
4
|
+
sessionId?: string;
|
|
5
|
+
images?: Array<{
|
|
6
|
+
data: string;
|
|
7
|
+
mimeType: string;
|
|
8
|
+
} | {
|
|
9
|
+
url: string;
|
|
10
|
+
}>;
|
|
11
|
+
attachmentIds?: string[];
|
|
12
|
+
clientContext?: {
|
|
13
|
+
timeZone?: string;
|
|
14
|
+
userEmail?: string;
|
|
15
|
+
};
|
|
16
|
+
systemPrompt?: string;
|
|
17
|
+
appendSystemPrompt?: string;
|
|
18
|
+
model?: string;
|
|
19
|
+
compactionModel?: string;
|
|
20
|
+
maxCostUsd?: number;
|
|
21
|
+
maxTokens?: number;
|
|
22
|
+
verify?: boolean;
|
|
23
|
+
verifyRounds?: number;
|
|
24
|
+
cascade?: boolean;
|
|
25
|
+
jobId?: string;
|
|
26
|
+
skills?: Array<{
|
|
27
|
+
name: string;
|
|
28
|
+
description: string;
|
|
29
|
+
content: string;
|
|
30
|
+
}>;
|
|
31
|
+
sandboxImageProfile?: string;
|
|
32
|
+
capabilitiesNeeded?: string[];
|
|
33
|
+
outputSchema?: Record<string, unknown>;
|
|
34
|
+
reasoningEffort?: string;
|
|
35
|
+
resumeAt?: string;
|
|
36
|
+
resumeAtMode?: string;
|
|
37
|
+
requireExistingSession?: boolean;
|
|
38
|
+
suggestNextPrompts?: boolean | {
|
|
39
|
+
count?: number;
|
|
40
|
+
role?: string;
|
|
41
|
+
};
|
|
42
|
+
rewindFiles?: boolean;
|
|
43
|
+
rewindFilesTo?: string;
|
|
44
|
+
resilience?: {
|
|
45
|
+
allowDegrade?: boolean;
|
|
46
|
+
allowFailover?: boolean;
|
|
47
|
+
bypassBreaker?: boolean;
|
|
48
|
+
};
|
|
49
|
+
finalVerification?: boolean;
|
|
50
|
+
limits?: {
|
|
51
|
+
timeoutSec?: number;
|
|
52
|
+
maxOutputTokens?: number;
|
|
53
|
+
maxTurns?: number;
|
|
54
|
+
};
|
|
55
|
+
attachments?: {
|
|
56
|
+
todoReminder?: boolean;
|
|
57
|
+
changedFiles?: boolean | {
|
|
58
|
+
maxFiles?: number;
|
|
59
|
+
};
|
|
60
|
+
planModeReminder?: boolean;
|
|
61
|
+
backgroundTasks?: boolean;
|
|
62
|
+
toolsDelta?: boolean;
|
|
63
|
+
};
|
|
64
|
+
forwardSubagentEvents?: boolean;
|
|
65
|
+
scratchpadDir?: string;
|
|
66
|
+
retainSubagentSessions?: boolean | {
|
|
67
|
+
ttlMs?: number;
|
|
68
|
+
max?: number;
|
|
69
|
+
};
|
|
70
|
+
agents?: AgentDefinition[];
|
|
71
|
+
retainBackgroundProcesses?: boolean;
|
|
72
|
+
excludeTools?: string[];
|
|
73
|
+
deferTools?: string[];
|
|
74
|
+
promptProfile?: "simple" | "classic";
|
|
75
|
+
permissionMode?: string;
|
|
76
|
+
memoryWrite?: boolean;
|
|
77
|
+
projectId?: string;
|
|
78
|
+
cwd?: string;
|
|
79
|
+
mcpServers?: McpServerSpec[];
|
|
80
|
+
selfOrchestration?: boolean;
|
|
81
|
+
enableFork?: boolean;
|
|
82
|
+
[k: string]: unknown;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=wire-types.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ImageIndexUpsert, ImageNestedBuildMode, ImageStatus } from "../plugins/
|
|
1
|
+
import type { ImageIndexUpsert, ImageNestedBuildMode, ImageStatus } from "../plugins/store-contracts.js";
|
|
2
2
|
export declare function nestedBuildModeOf(v: string | boolean | undefined): ImageNestedBuildMode;
|
|
3
3
|
export interface BuildManifest {
|
|
4
4
|
profile?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ export { createTidbPool, ensureSchema, SCHEMA_STATEMENTS } from "./plugins/tidb-
|
|
|
5
5
|
export { TiDBSessionStore } from "./plugins/tidb-session-store.js";
|
|
6
6
|
export { TiDBSessionStorage } from "./plugins/tidb-session-storage.js";
|
|
7
7
|
export { CachingSessionStore, type CachingOptions } from "./plugins/caching-session-store.js";
|
|
8
|
-
export { TiDBRunStore
|
|
8
|
+
export { TiDBRunStore } from "./plugins/tidb-run-store.js";
|
|
9
|
+
export type { RunRecord, RunEvent } from "./plugins/store-contracts.js";
|
|
9
10
|
export { runInBackground } from "./runs.js";
|
|
10
11
|
export { TiDBApprovalStore, type ApprovalRow, type ApprovalStatus, } from "./plugins/tidb-approval-store.js";
|
|
11
12
|
export { createOaApprovalPolicy, type OaApprovalOptions } from "./approval.js";
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ export { createTidbPool, ensureSchema, SCHEMA_STATEMENTS } from "./plugins/tidb-
|
|
|
5
5
|
export { TiDBSessionStore } from "./plugins/tidb-session-store.js";
|
|
6
6
|
export { TiDBSessionStorage } from "./plugins/tidb-session-storage.js";
|
|
7
7
|
export { CachingSessionStore } from "./plugins/caching-session-store.js";
|
|
8
|
-
export { TiDBRunStore
|
|
8
|
+
export { TiDBRunStore } from "./plugins/tidb-run-store.js";
|
|
9
9
|
export { runInBackground } from "./runs.js";
|
|
10
10
|
export { TiDBApprovalStore, } from "./plugins/tidb-approval-store.js";
|
|
11
11
|
export { createOaApprovalPolicy } from "./approval.js";
|
package/dist/per-task-image.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { ImageViewer, ImageIndexEntry } from "./plugins/
|
|
1
|
+
import type { ImageViewer, ImageIndexEntry } from "./plugins/store-contracts.js";
|
|
2
2
|
export interface SandboxImageResolver {
|
|
3
3
|
latestPublished(profile: string, viewer: ImageViewer): Promise<Pick<ImageIndexEntry, "repo" | "digest" | "capabilities"> | null>;
|
|
4
4
|
}
|
|
5
5
|
export type SandboxImageResolution = {
|
|
6
6
|
ok: true;
|
|
7
7
|
ref: string;
|
|
8
|
-
capabilities?: import("./plugins/
|
|
8
|
+
capabilities?: import("./plugins/store-contracts.js").ImageCapabilities;
|
|
9
9
|
} | {
|
|
10
10
|
ok: false;
|
|
11
11
|
status: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type UsageRow } from "../usage-analytics.js";
|
|
2
2
|
import type { TaskResult, TaskStatus } from "@sema-agent/core";
|
|
3
|
-
import type { RunRecord, SessionSummary, RunEvent } from "./
|
|
3
|
+
import type { RunRecord, SessionSummary, RunEvent } from "./store-contracts.js";
|
|
4
4
|
import type { RunStoreCheckpointProbe } from "./memory-run-store.js";
|
|
5
5
|
export declare class FileRunStore {
|
|
6
6
|
private readonly runsDir;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type AcquiredSession, type SessionStore, type SessionRepo, type SessionTreeEntry } from "@sema-agent/core";
|
|
2
|
-
import type { SessionSummary } from "./
|
|
3
|
-
import { type StagingHandle } from "../session-sync.js";
|
|
2
|
+
import type { SessionSummary } from "./store-contracts.js";
|
|
3
|
+
import { type StagingHandle } from "../session-sync-kernel.js";
|
|
4
4
|
export declare class LocalSessionStore implements SessionStore {
|
|
5
5
|
private readonly repo;
|
|
6
6
|
private readonly pending;
|
|
@@ -2,7 +2,7 @@ import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
|
2
2
|
import { join, resolve } from "node:path";
|
|
3
3
|
import { SessionError, validateEntriesForImport } from "@sema-agent/core";
|
|
4
4
|
import { identicalIdsAlsoIdenticalContent } from "../session-sync-content.js";
|
|
5
|
-
import { classifySyncRelationshipByIds, SyncConflictError, stagingIdFor, } from "../session-sync.js";
|
|
5
|
+
import { classifySyncRelationshipByIds, SyncConflictError, stagingIdFor, } from "../session-sync-kernel.js";
|
|
6
6
|
const ownerEq = (a, b) => (a ?? null) === (b ?? null);
|
|
7
7
|
const isNotFound = (e) => e instanceof SessionError && e.code === "not_found";
|
|
8
8
|
function userText(entry) {
|
|
@@ -15,7 +15,7 @@ export declare class TiDBMailboxStore implements MailboxStore {
|
|
|
15
15
|
sentAt: number;
|
|
16
16
|
}): Promise<number>;
|
|
17
17
|
claimLease(scope: string, handle: string, owner: string, ttlMs: number, now?: number): Promise<MailboxLease | null>;
|
|
18
|
-
ack(scope: string, handle: string, upToSeq: number): Promise<void>;
|
|
18
|
+
ack(scope: string, handle: string, owner: string, upToSeq: number): Promise<void>;
|
|
19
19
|
releaseLease(scope: string, handle: string, owner: string): Promise<void>;
|
|
20
20
|
peekCount(scope: string, handle: string): Promise<number>;
|
|
21
21
|
drop(scope: string, handle: string): Promise<void>;
|
|
@@ -34,7 +34,7 @@ export declare class PgMailboxStore implements MailboxStore {
|
|
|
34
34
|
sentAt: number;
|
|
35
35
|
}): Promise<number>;
|
|
36
36
|
claimLease(scope: string, handle: string, owner: string, ttlMs: number, now?: number): Promise<MailboxLease | null>;
|
|
37
|
-
ack(scope: string, handle: string, upToSeq: number): Promise<void>;
|
|
37
|
+
ack(scope: string, handle: string, owner: string, upToSeq: number): Promise<void>;
|
|
38
38
|
releaseLease(scope: string, handle: string, owner: string): Promise<void>;
|
|
39
39
|
peekCount(scope: string, handle: string): Promise<number>;
|
|
40
40
|
drop(scope: string, handle: string): Promise<void>;
|
|
@@ -123,9 +123,11 @@ export class TiDBMailboxStore {
|
|
|
123
123
|
return { messages: msgs.map(rowToMessage), maxSeq };
|
|
124
124
|
});
|
|
125
125
|
}
|
|
126
|
-
async ack(scope, handle, upToSeq) {
|
|
126
|
+
async ack(scope, handle, owner, upToSeq) {
|
|
127
127
|
await this.tx(async (c) => {
|
|
128
|
-
await c.query(`SELECT
|
|
128
|
+
const [rows] = (await c.query(`SELECT lease_owner FROM ${MAILBOX_TABLE} WHERE scope_key = ? AND handle = ? FOR UPDATE`, [scope, handle]));
|
|
129
|
+
if (rows.length === 0 || rows[0].lease_owner == null || bufToStr(rows[0].lease_owner) !== owner)
|
|
130
|
+
return;
|
|
129
131
|
await c.query(`DELETE FROM ${MAILBOX_MSG_TABLE} WHERE scope_key = ? AND handle = ? AND seq <= ?`, [scope, handle, upToSeq]);
|
|
130
132
|
await c.query(`UPDATE ${MAILBOX_TABLE} SET lease_owner = NULL, lease_expires_at_ms = NULL, lease_max_seq = NULL
|
|
131
133
|
WHERE scope_key = ? AND handle = ? AND lease_max_seq IS NOT NULL AND lease_max_seq <= ?`, [scope, handle, upToSeq]);
|
|
@@ -241,9 +243,11 @@ export class PgMailboxStore {
|
|
|
241
243
|
return { messages: msgs.map((r) => rowToMessage(r)), maxSeq };
|
|
242
244
|
});
|
|
243
245
|
}
|
|
244
|
-
async ack(scope, handle, upToSeq) {
|
|
246
|
+
async ack(scope, handle, owner, upToSeq) {
|
|
245
247
|
await this.tx(async (c) => {
|
|
246
|
-
await c.query(`SELECT
|
|
248
|
+
const r = (await c.query(`SELECT lease_owner FROM ${MAILBOX_TABLE} WHERE scope_key = $1 AND handle = $2 FOR UPDATE`, [scope, handle]));
|
|
249
|
+
if (r.rows.length === 0 || r.rows[0].lease_owner == null || bufToStr(r.rows[0].lease_owner) !== owner)
|
|
250
|
+
return;
|
|
247
251
|
await c.query(`DELETE FROM ${MAILBOX_MSG_TABLE} WHERE scope_key = $1 AND handle = $2 AND seq <= $3`, [scope, handle, upToSeq]);
|
|
248
252
|
await c.query(`UPDATE ${MAILBOX_TABLE} SET lease_owner = NULL, lease_expires_at_ms = NULL, lease_max_seq = NULL
|
|
249
253
|
WHERE scope_key = $1 AND handle = $2 AND lease_max_seq IS NOT NULL AND lease_max_seq <= $3`, [scope, handle, upToSeq]);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type UsageRow } from "../usage-analytics.js";
|
|
2
2
|
import type { TaskResult, TaskStatus } from "@sema-agent/core";
|
|
3
|
-
import type { RunRecord, SessionSummary, RunEvent } from "./
|
|
3
|
+
import type { RunRecord, SessionSummary, RunEvent } from "./store-contracts.js";
|
|
4
4
|
export interface RunStoreCheckpointProbe {
|
|
5
5
|
hasPending(sessionId: string): Promise<boolean>;
|
|
6
6
|
hasExpired(sessionId: string): Promise<boolean>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Pool, PoolClient } from "pg";
|
|
2
|
-
import type { BakeStatus, BakeState, BakeRecord, BakeEvent, CreateBakeInput, BakeTerminal } from "./
|
|
3
|
-
export type { BakeStatus, BakeState, BakeErrorCode, BakeRecord, BakeEvent, CreateBakeInput, BakeTerminal, } from "./
|
|
2
|
+
import type { BakeStatus, BakeState, BakeRecord, BakeEvent, CreateBakeInput, BakeTerminal } from "./store-contracts.js";
|
|
3
|
+
export type { BakeStatus, BakeState, BakeErrorCode, BakeRecord, BakeEvent, CreateBakeInput, BakeTerminal, } from "./store-contracts.js";
|
|
4
4
|
export declare const PG_IMAGE_BAKE_SCHEMA: string[];
|
|
5
5
|
export declare function ensureSchema(pool: Pool | PoolClient, poolName?: string): Promise<void>;
|
|
6
6
|
export declare class PgImageBake {
|
|
@@ -2,7 +2,7 @@ import { uuidv7 } from "@sema-agent/core";
|
|
|
2
2
|
import { randomBytes } from "node:crypto";
|
|
3
3
|
import { pgSanitizeText, pgSafeJsonStringify, pgHasUnstorable } from "./pg-safe-json.js";
|
|
4
4
|
import { parseJsonOr as parseJson, toIso as iso } from "./sql-row-helpers.js";
|
|
5
|
-
import { mapRow, SELECT_COLS } from "./
|
|
5
|
+
import { mapBakeRow as mapRow, BAKE_SELECT_COLS as SELECT_COLS } from "./store-contracts.js";
|
|
6
6
|
export const PG_IMAGE_BAKE_SCHEMA = [
|
|
7
7
|
`CREATE TABLE IF NOT EXISTS image_bake (
|
|
8
8
|
bake_id VARCHAR(64) NOT NULL,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Pool, PoolClient } from "pg";
|
|
2
|
-
import { type ImageStatus, type ImageIndexEntry, type ImageIndexUpsert, type ImageViewer, type ImageListFilter } from "./
|
|
3
|
-
export type { ImageNestedBuildMode, ImageCapabilities, ImagePodContract, ImageStatus, ImageVisibility, ImageIndexEntry, ImageIndexUpsert, ImageViewer, ImageListFilter, } from "./
|
|
2
|
+
import { type ImageStatus, type ImageIndexEntry, type ImageIndexUpsert, type ImageViewer, type ImageListFilter } from "./store-contracts.js";
|
|
3
|
+
export type { ImageNestedBuildMode, ImageCapabilities, ImagePodContract, ImageStatus, ImageVisibility, ImageIndexEntry, ImageIndexUpsert, ImageViewer, ImageListFilter, } from "./store-contracts.js";
|
|
4
4
|
export declare const PG_IMAGE_INDEX_SCHEMA: string[];
|
|
5
5
|
export declare function ensureSchema(pool: Pool | PoolClient): Promise<void>;
|
|
6
6
|
export declare class PgImageIndex {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { pgSafeJsonStringify, pgSanitizeText, pgHasUnstorable, PgUnstorableError } from "./pg-safe-json.js";
|
|
3
|
-
import { mapRow, } from "./
|
|
3
|
+
import { mapImageRow as mapRow, } from "./store-contracts.js";
|
|
4
4
|
export const PG_IMAGE_INDEX_SCHEMA = [
|
|
5
5
|
`CREATE TABLE IF NOT EXISTS sandbox_image_index (
|
|
6
6
|
id VARCHAR(64) NOT NULL,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import pg from "pg";
|
|
2
|
-
import type { ServiceConfig } from "../config.js";
|
|
2
|
+
import type { ServiceConfig } from "../config-types.js";
|
|
3
3
|
export declare const PG_SCHEMA_STATEMENTS: readonly string[];
|
|
4
4
|
export declare function pgPoolOptions(pgCfg: NonNullable<ServiceConfig["pg"]>, dbQueryTimeoutMs?: number): pg.PoolConfig;
|
|
5
5
|
export declare function createPgPool(opts: string | pg.PoolConfig): pg.Pool;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { TaskResult, TaskStatus } from "@sema-agent/core";
|
|
2
2
|
import { type UsageRow } from "../usage-analytics.js";
|
|
3
3
|
import type { Pool } from "pg";
|
|
4
|
-
import type { RunRecord, RunEvent, SessionSummary } from "./
|
|
4
|
+
import type { RunRecord, RunEvent, SessionSummary } from "./store-contracts.js";
|
|
5
5
|
export declare class PgRunStore {
|
|
6
6
|
private readonly pool;
|
|
7
7
|
constructor(pool: Pool);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { projectUsageStats, USAGE_SCAN_LIMIT } from "../usage-analytics.js";
|
|
2
|
-
import { escapeLike } from "./
|
|
2
|
+
import { escapeLike } from "./sql-escape.js";
|
|
3
3
|
import { pgSafeJsonStringify, pgSanitizeText } from "./pg-safe-json.js";
|
|
4
4
|
import { parseJsonLenient as parseJson, toIso as iso } from "./sql-row-helpers.js";
|
|
5
5
|
function isDupKey(err) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseSessionStorage, type PromptEpochDescriptor, type AcquiredSession, type SessionMetadata, type SessionStore, type SessionTreeEntry, type SessionWriteOptions } from "@sema-agent/core";
|
|
2
2
|
import type { Pool, PoolClient } from "pg";
|
|
3
|
-
import type { SessionSummary } from "./
|
|
4
|
-
import { type StagingHandle } from "../session-sync.js";
|
|
3
|
+
import type { SessionSummary } from "./store-contracts.js";
|
|
4
|
+
import { type StagingHandle } from "../session-sync-kernel.js";
|
|
5
5
|
export declare const PG_SESSION_SCHEMA: string[];
|
|
6
6
|
export declare function ensureSchema(pool: Pool | PoolClient): Promise<void>;
|
|
7
7
|
export declare class PgSessionStorage extends BaseSessionStorage {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { emitLeafAdvance } from "../session-leaf-bus.js";
|
|
2
2
|
import { BaseSessionStorage, StoredSession, SessionError, uuidv7, validateEntriesForImport, leafIdAfterEntry, normalizePromptEpoch, } from "@sema-agent/core";
|
|
3
|
-
import { escapeLike } from "./
|
|
3
|
+
import { escapeLike } from "./sql-escape.js";
|
|
4
4
|
import { pgSafeJsonStringify } from "./pg-safe-json.js";
|
|
5
5
|
import { toIso } from "./sql-row-helpers.js";
|
|
6
|
-
import { classifySyncRelationshipByIds, SyncConflictError, stagingIdFor, STAGING_ID_MARKER, } from "../session-sync.js";
|
|
6
|
+
import { classifySyncRelationshipByIds, SyncConflictError, stagingIdFor, STAGING_ID_MARKER, } from "../session-sync-kernel.js";
|
|
7
7
|
const STAGING_GC_GRACE_MS = 3_600_000;
|
|
8
8
|
function isDupKey(err) {
|
|
9
9
|
return Boolean(err) && err.code === "23505";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type SessionStore } from "@sema-agent/core";
|
|
2
|
-
import type { ServiceConfig } from "../config.js";
|
|
2
|
+
import type { ServiceConfig } from "../config-types.js";
|
|
3
3
|
import type { StoreBackend } from "./store-backend.js";
|
|
4
4
|
export declare function createSessionStore(config: ServiceConfig, backend?: StoreBackend, metrics?: {
|
|
5
5
|
inc(name: string, labels?: Record<string, string>, n?: number): void;
|
|
@@ -11,7 +11,7 @@ import { type ApprovalExemptionStore } from "./approval-exemption-store.js";
|
|
|
11
11
|
import { type SendFileLedger } from "./send-file-ledger.js";
|
|
12
12
|
import { TiDBResumeAnchorStore } from "./tidb-resume-anchor-store.js";
|
|
13
13
|
import { PgResumeAnchorStore } from "./pg-resume-anchor-store.js";
|
|
14
|
-
import type { ServiceConfig } from "../config.js";
|
|
14
|
+
import type { ServiceConfig } from "../config-types.js";
|
|
15
15
|
import { TiDBRunStore } from "./tidb-run-store.js";
|
|
16
16
|
import { PgRunStore } from "./pg-run-store.js";
|
|
17
17
|
import { TiDBCheckpointStore } from "./tidb-checkpoint-store.js";
|