@sema-agent/server 1.311.0 → 1.312.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/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/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/project.d.ts +1 -1
- package/package.json +1 -1
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) {
|
|
@@ -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";
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import type { TaskResult, TaskStatus } from "@sema-agent/core";
|
|
2
|
+
export interface RunRecord {
|
|
3
|
+
taskId: string;
|
|
4
|
+
sessionId: string;
|
|
5
|
+
owner: string | null;
|
|
6
|
+
status: "running" | TaskStatus;
|
|
7
|
+
result: TaskResult | null;
|
|
8
|
+
error: string | null;
|
|
9
|
+
errorCode: string | null;
|
|
10
|
+
jobId: string | null;
|
|
11
|
+
source: string | null;
|
|
12
|
+
instanceId: string | null;
|
|
13
|
+
objectivePreview: string | null;
|
|
14
|
+
createdAt: string;
|
|
15
|
+
updatedAt: string;
|
|
16
|
+
}
|
|
17
|
+
export interface SessionSummary {
|
|
18
|
+
sessionId: string;
|
|
19
|
+
owner: string | null;
|
|
20
|
+
lastActivityAt: string;
|
|
21
|
+
firstActivityAt: string;
|
|
22
|
+
runCount: number;
|
|
23
|
+
objectivePreview: string | null;
|
|
24
|
+
lastStatus: string;
|
|
25
|
+
lastRunId: string | null;
|
|
26
|
+
title: string | null;
|
|
27
|
+
}
|
|
28
|
+
export interface RunEvent {
|
|
29
|
+
seq: number;
|
|
30
|
+
type: string;
|
|
31
|
+
data: unknown;
|
|
32
|
+
ts: string;
|
|
33
|
+
}
|
|
34
|
+
export type BakeStatus = "queued" | "running" | "done" | "failed";
|
|
35
|
+
export type BakeState = "PENDING" | "BUILDING" | "PUSHING" | "VERIFYING" | "REGISTERING" | "COMPLETE" | "FAILED" | "CANCELLED";
|
|
36
|
+
export type BakeErrorCode = "band-conflict" | "duplicate" | "disk" | "timeout" | "cancelled" | null;
|
|
37
|
+
export interface BakeRecord {
|
|
38
|
+
bakeId: string;
|
|
39
|
+
profile: string;
|
|
40
|
+
bands: string[] | null;
|
|
41
|
+
baseRef: string | null;
|
|
42
|
+
push: boolean;
|
|
43
|
+
dryRun: boolean;
|
|
44
|
+
logs: boolean;
|
|
45
|
+
argv: string[];
|
|
46
|
+
status: BakeStatus;
|
|
47
|
+
state: BakeState | null;
|
|
48
|
+
digest: string | null;
|
|
49
|
+
repo: string | null;
|
|
50
|
+
ref: string | null;
|
|
51
|
+
indexId: string | null;
|
|
52
|
+
exitCode: number | null;
|
|
53
|
+
error: string | null;
|
|
54
|
+
errorCode: BakeErrorCode;
|
|
55
|
+
manifestSha: string | null;
|
|
56
|
+
tag: string | null;
|
|
57
|
+
idemKey: string | null;
|
|
58
|
+
ingestSecret: string | null;
|
|
59
|
+
runnerId: string | null;
|
|
60
|
+
leaseUntil: string | null;
|
|
61
|
+
cancelRequested: boolean;
|
|
62
|
+
requestedBy: string | null;
|
|
63
|
+
createdAt: string;
|
|
64
|
+
updatedAt: string;
|
|
65
|
+
}
|
|
66
|
+
export interface BakeEvent {
|
|
67
|
+
seq: number;
|
|
68
|
+
lineOrd: number | null;
|
|
69
|
+
kind: string;
|
|
70
|
+
level: string | null;
|
|
71
|
+
data: unknown;
|
|
72
|
+
ts: string;
|
|
73
|
+
}
|
|
74
|
+
export interface CreateBakeInput {
|
|
75
|
+
profile: string;
|
|
76
|
+
bands: string[] | null;
|
|
77
|
+
baseRef: string | null;
|
|
78
|
+
push: boolean;
|
|
79
|
+
dryRun: boolean;
|
|
80
|
+
logs: boolean;
|
|
81
|
+
argv: string[];
|
|
82
|
+
idemKey: string | null;
|
|
83
|
+
requestedBy: string | null;
|
|
84
|
+
}
|
|
85
|
+
export interface BakeTerminal {
|
|
86
|
+
status: "done" | "failed";
|
|
87
|
+
state: BakeState;
|
|
88
|
+
digest?: string | null;
|
|
89
|
+
repo?: string | null;
|
|
90
|
+
ref?: string | null;
|
|
91
|
+
indexId?: string | null;
|
|
92
|
+
exitCode?: number | null;
|
|
93
|
+
error?: string | null;
|
|
94
|
+
errorCode?: BakeErrorCode;
|
|
95
|
+
manifestSha?: string | null;
|
|
96
|
+
tag?: string | null;
|
|
97
|
+
}
|
|
98
|
+
export interface BakeRow {
|
|
99
|
+
bake_id: string;
|
|
100
|
+
profile: string;
|
|
101
|
+
bands: unknown;
|
|
102
|
+
base_ref: string | null;
|
|
103
|
+
push: number;
|
|
104
|
+
dry_run: number;
|
|
105
|
+
logs: number;
|
|
106
|
+
argv: unknown;
|
|
107
|
+
status: string;
|
|
108
|
+
state: string | null;
|
|
109
|
+
digest: string | null;
|
|
110
|
+
repo: string | null;
|
|
111
|
+
ref: string | null;
|
|
112
|
+
index_id: string | null;
|
|
113
|
+
exit_code: number | string | null;
|
|
114
|
+
error: string | null;
|
|
115
|
+
error_code: string | null;
|
|
116
|
+
manifest_sha: string | null;
|
|
117
|
+
tag: string | null;
|
|
118
|
+
idem_key: string | null;
|
|
119
|
+
ingest_secret: string | null;
|
|
120
|
+
runner_id: string | null;
|
|
121
|
+
lease_until: Date | string | null;
|
|
122
|
+
cancel_requested: number;
|
|
123
|
+
requested_by: string | null;
|
|
124
|
+
created_at: Date | string;
|
|
125
|
+
updated_at: Date | string;
|
|
126
|
+
}
|
|
127
|
+
export declare function mapBakeRow(r: BakeRow): BakeRecord;
|
|
128
|
+
export declare const BAKE_SELECT_COLS: string;
|
|
129
|
+
export type ImageNestedBuildMode = "none" | "docker-cli-only" | "rootless-buildkit" | "privileged-dind";
|
|
130
|
+
export interface ImageCapabilities {
|
|
131
|
+
browser?: boolean;
|
|
132
|
+
db?: boolean;
|
|
133
|
+
nestedBuild?: boolean;
|
|
134
|
+
nestedBuildMode?: ImageNestedBuildMode;
|
|
135
|
+
}
|
|
136
|
+
export interface ImagePodContract {
|
|
137
|
+
devShmMB?: number;
|
|
138
|
+
minMemMB?: number;
|
|
139
|
+
minCpu?: string;
|
|
140
|
+
readyTimeoutSec?: number;
|
|
141
|
+
securityContext?: Record<string, unknown>;
|
|
142
|
+
}
|
|
143
|
+
export type ImageStatus = "building" | "published" | "deprecated" | "failed";
|
|
144
|
+
export type ImageVisibility = "public" | "tenant";
|
|
145
|
+
export interface ImageIndexEntry {
|
|
146
|
+
id: string;
|
|
147
|
+
profile: string;
|
|
148
|
+
bands: string[];
|
|
149
|
+
repo: string;
|
|
150
|
+
tag: string;
|
|
151
|
+
digest: string;
|
|
152
|
+
toolchainVersions: Record<string, string>;
|
|
153
|
+
capabilities: ImageCapabilities;
|
|
154
|
+
podContract: ImagePodContract;
|
|
155
|
+
sizeBytes: number | null;
|
|
156
|
+
status: ImageStatus;
|
|
157
|
+
visibility: ImageVisibility;
|
|
158
|
+
tenantId: string | null;
|
|
159
|
+
manifestSha: string | null;
|
|
160
|
+
recipeGitSha: string | null;
|
|
161
|
+
generatorVersion: string | null;
|
|
162
|
+
buildDate: string | null;
|
|
163
|
+
supersedes: string | null;
|
|
164
|
+
signed: boolean;
|
|
165
|
+
createdAt: string;
|
|
166
|
+
updatedAt: string;
|
|
167
|
+
}
|
|
168
|
+
export type ImageIndexUpsert = Omit<ImageIndexEntry, "id" | "createdAt" | "updatedAt">;
|
|
169
|
+
export interface ImageViewer {
|
|
170
|
+
operator?: boolean;
|
|
171
|
+
tenantId?: string | null;
|
|
172
|
+
}
|
|
173
|
+
export interface ImageListFilter extends ImageViewer {
|
|
174
|
+
profile?: string;
|
|
175
|
+
status?: ImageStatus;
|
|
176
|
+
capability?: keyof ImageCapabilities;
|
|
177
|
+
latestOnly?: boolean;
|
|
178
|
+
limit?: number;
|
|
179
|
+
cursor?: string;
|
|
180
|
+
}
|
|
181
|
+
export interface ImageRow {
|
|
182
|
+
id: string;
|
|
183
|
+
profile: string;
|
|
184
|
+
bands: unknown;
|
|
185
|
+
repo: string;
|
|
186
|
+
tag: string;
|
|
187
|
+
digest: string;
|
|
188
|
+
toolchain_versions: unknown;
|
|
189
|
+
capabilities: unknown;
|
|
190
|
+
pod_contract: unknown;
|
|
191
|
+
size_bytes: number | string | null;
|
|
192
|
+
status: string;
|
|
193
|
+
visibility: string;
|
|
194
|
+
tenant_id: string | null;
|
|
195
|
+
manifest_sha: string | null;
|
|
196
|
+
recipe_git_sha: string | null;
|
|
197
|
+
generator_version: string | null;
|
|
198
|
+
build_date: Date | string | null;
|
|
199
|
+
supersedes: string | null;
|
|
200
|
+
signed: number;
|
|
201
|
+
created_at: Date | string;
|
|
202
|
+
updated_at: Date | string;
|
|
203
|
+
}
|
|
204
|
+
export declare function mapImageRow(r: ImageRow): ImageIndexEntry;
|
|
205
|
+
//# sourceMappingURL=store-contracts.d.ts.map
|