@opengeni/core 0.12.10 → 0.14.4
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/access/index.d.ts +22 -0
- package/dist/application/new-session-drafts.d.ts +14 -0
- package/dist/application/session-commands.d.ts +107 -0
- package/dist/billing/limits.d.ts +29 -0
- package/dist/dependencies.d.ts +137 -0
- package/dist/domain/capabilities.d.ts +62 -0
- package/dist/domain/environments.d.ts +33 -0
- package/dist/domain/insights.d.ts +11 -0
- package/dist/domain/packs.d.ts +27 -0
- package/dist/domain/resources.d.ts +32 -0
- package/dist/domain/scheduled-tasks.d.ts +72 -0
- package/dist/domain/session-tool-policy.d.ts +31 -0
- package/dist/domain/sessions.d.ts +256 -0
- package/dist/domain/slack-bot.d.ts +19 -0
- package/dist/domain/workspace-members.d.ts +34 -0
- package/dist/index.d.ts +23 -1199
- package/dist/index.js +693 -53
- package/dist/index.js.map +1 -1
- package/dist/managed-auth-type.d.ts +2 -0
- package/dist/rigs/index.d.ts +57 -0
- package/dist/sandbox/fleet.d.ts +197 -0
- package/dist/sandbox/routing.d.ts +55 -0
- package/dist/sandbox-types.d.ts +52 -0
- package/dist/session-authorization.d.ts +36 -0
- package/dist/transcription.d.ts +71 -0
- package/dist/workflow-wake-contract.d.ts +4 -0
- package/package.json +11 -11
- package/src/access/index.ts +73 -2
- package/src/application/new-session-drafts.ts +3 -0
- package/src/application/session-commands.ts +3 -1
- package/src/dependencies.ts +5 -0
- package/src/domain/insights.ts +480 -0
- package/src/domain/session-tool-policy.ts +17 -25
- package/src/domain/sessions.ts +75 -4
- package/src/domain/slack-bot.ts +2 -4
- package/src/index.ts +2 -0
- package/src/sandbox/fleet.ts +96 -33
- package/src/sandbox/routing.ts +29 -7
- package/src/transcription.ts +142 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,1199 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
runAs?: string;
|
|
25
|
-
yieldTimeMs?: number;
|
|
26
|
-
maxOutputTokens?: number;
|
|
27
|
-
}): Promise<unknown>;
|
|
28
|
-
execCommand?(args: {
|
|
29
|
-
cmd: string;
|
|
30
|
-
workdir?: string;
|
|
31
|
-
runAs?: string;
|
|
32
|
-
yieldTimeMs?: number;
|
|
33
|
-
maxOutputTokens?: number;
|
|
34
|
-
}): Promise<string>;
|
|
35
|
-
shutdown?(options?: unknown): Promise<void>;
|
|
36
|
-
delete?(options?: unknown): Promise<void>;
|
|
37
|
-
close?(): Promise<void>;
|
|
38
|
-
};
|
|
39
|
-
type ApiSandboxClient = {
|
|
40
|
-
backendId: string;
|
|
41
|
-
deserializeSessionState?(state: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
42
|
-
resume?(state: Record<string, unknown>, options?: unknown): Promise<ApiSandboxSession>;
|
|
43
|
-
delete?(state: Record<string, unknown>): Promise<void>;
|
|
44
|
-
};
|
|
45
|
-
type ResumeBoxByIdInput = {
|
|
46
|
-
/**
|
|
47
|
-
* The backend the box was created on — the lease's `resume_backend_id`. Must
|
|
48
|
-
* match the API's configured sandbox client backendId, or the resume is
|
|
49
|
-
* rejected (a cross-backend envelope can never deserialize correctly).
|
|
50
|
-
*/
|
|
51
|
-
backend: string;
|
|
52
|
-
/**
|
|
53
|
-
* The serialized resume-state envelope — the lease's `resume_state` jsonb
|
|
54
|
-
* (the record produced by `client.serializeSessionState(state)`). This is the
|
|
55
|
-
* box identity + reattach descriptor; resume() reattaches to the live box by
|
|
56
|
-
* id (warm reattach) or cold-restores from its snapshot.
|
|
57
|
-
*/
|
|
58
|
-
resumeState: Record<string, unknown>;
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* A live, resumed sandbox session for a SINGLE in-process op. The caller
|
|
62
|
-
* resumes → uses (exec/readFile/resolvePort) → drops it; lifecycle/refcount is
|
|
63
|
-
* the lease's job (P1.x), NOT this handle's. The session is non-owned by
|
|
64
|
-
* construction (resume-by-id never owns the box), so dropping it does not
|
|
65
|
-
* terminate the box.
|
|
66
|
-
*/
|
|
67
|
-
type ResumedSandboxSession = ApiSandboxSession;
|
|
68
|
-
|
|
69
|
-
type SessionWorkflowClient = {
|
|
70
|
-
signalUserMessage: (input: {
|
|
71
|
-
sessionId: string;
|
|
72
|
-
eventId: string;
|
|
73
|
-
workflowId: string;
|
|
74
|
-
}) => Promise<void>;
|
|
75
|
-
wakeSessionWorkflow: (input: {
|
|
76
|
-
accountId: string;
|
|
77
|
-
workspaceId: string;
|
|
78
|
-
sessionId: string;
|
|
79
|
-
workflowId: string;
|
|
80
|
-
wakeRevision: number;
|
|
81
|
-
interruptionRequested?: boolean;
|
|
82
|
-
}) => Promise<void>;
|
|
83
|
-
/** Trigger one bounded drain of already-committed workflow-wake revisions. */
|
|
84
|
-
requestSessionWorkflowWakeDispatch: () => Promise<void>;
|
|
85
|
-
signalCodexCapacity?: (input: {
|
|
86
|
-
accountId: string;
|
|
87
|
-
workspaceId: string;
|
|
88
|
-
sessionId: string;
|
|
89
|
-
workflowId: string;
|
|
90
|
-
wakeRevision: number;
|
|
91
|
-
workflowWakeRevision: number;
|
|
92
|
-
}) => Promise<void>;
|
|
93
|
-
signalApprovalDecision: (input: {
|
|
94
|
-
accountId: string;
|
|
95
|
-
workspaceId: string;
|
|
96
|
-
sessionId: string;
|
|
97
|
-
eventId: string;
|
|
98
|
-
workflowId: string;
|
|
99
|
-
workflowWakeRevision: number;
|
|
100
|
-
}) => Promise<void>;
|
|
101
|
-
syncScheduledTask: (input: {
|
|
102
|
-
task: ScheduledTask;
|
|
103
|
-
}) => Promise<void>;
|
|
104
|
-
deleteScheduledTaskSchedule: (input: {
|
|
105
|
-
temporalScheduleId: string;
|
|
106
|
-
}) => Promise<void>;
|
|
107
|
-
triggerScheduledTask: (input: {
|
|
108
|
-
task: ScheduledTask;
|
|
109
|
-
agentRunUsageIdempotencyKey: string;
|
|
110
|
-
triggerWorkflowId: string;
|
|
111
|
-
initiator: TurnInitiator;
|
|
112
|
-
}) => Promise<void>;
|
|
113
|
-
startRigVerification: (input: {
|
|
114
|
-
workspaceId: string;
|
|
115
|
-
changeId?: string;
|
|
116
|
-
versionId?: string;
|
|
117
|
-
workflowId?: string;
|
|
118
|
-
}) => Promise<void>;
|
|
119
|
-
check?: () => Promise<void>;
|
|
120
|
-
};
|
|
121
|
-
type DocumentIndexClient = {
|
|
122
|
-
indexDocument: (input: {
|
|
123
|
-
accountId: string;
|
|
124
|
-
workspaceId: string;
|
|
125
|
-
documentId: string;
|
|
126
|
-
}) => Promise<Document | void>;
|
|
127
|
-
};
|
|
128
|
-
type AppDependencies = {
|
|
129
|
-
settings: Settings;
|
|
130
|
-
db: Database;
|
|
131
|
-
bus: EventBus;
|
|
132
|
-
workflowClient: SessionWorkflowClient;
|
|
133
|
-
/** Optional provider override for deterministic API/object-storage tests. */
|
|
134
|
-
objectStorage?: ObjectStorageDependency;
|
|
135
|
-
documentIndexer?: DocumentIndexClient;
|
|
136
|
-
documentServices?: DocumentServices;
|
|
137
|
-
observability?: Observability;
|
|
138
|
-
readinessChecks?: Partial<Record<"db" | "nats" | "temporal", () => Promise<void> | void>>;
|
|
139
|
-
githubStateSecret?: string;
|
|
140
|
-
/**
|
|
141
|
-
* Optional host-provided GitHub App API seam. Embedded hosts can authorize
|
|
142
|
-
* users, inspect installations, and list repositories with their own GitHub
|
|
143
|
-
* App credentials; standalone deployments fall back to @opengeni/github.
|
|
144
|
-
*/
|
|
145
|
-
githubAppApi?: GitHubAppApiPort;
|
|
146
|
-
/**
|
|
147
|
-
* Optional host-owned connection credential seam. API-side consumers use
|
|
148
|
-
* the MCP leg for Toolspace/Code Mode; worker consumers bind the same port
|
|
149
|
-
* for model MCP, Git, and sandbox-secret resolution.
|
|
150
|
-
*/
|
|
151
|
-
connectionCredentials?: ConnectionCredentialsPort | null;
|
|
152
|
-
/**
|
|
153
|
-
* Optional embedding-host session ACL. Unset preserves standalone workspace
|
|
154
|
-
* authorization; once bound, every session-addressed surface fails closed on
|
|
155
|
-
* an unavailable or invalid host decision.
|
|
156
|
-
*/
|
|
157
|
-
sessionAuthorization?: SessionAuthorizationPort | null;
|
|
158
|
-
managedAuth?: ManagedAuth | null;
|
|
159
|
-
/** Injectable Codex HTTP transport for deterministic API/provider tests. */
|
|
160
|
-
codexFetch?: typeof fetch;
|
|
161
|
-
/** Injectable Slack Web API transport for deterministic bot-connection tests. */
|
|
162
|
-
slackFetch?: typeof fetch;
|
|
163
|
-
sandboxClient?: ApiSandboxClient;
|
|
164
|
-
/**
|
|
165
|
-
* Resume a box by id from a serialized resume_state envelope (the lease's
|
|
166
|
-
* `resume_state` + `resume_backend_id` from P1.1) and return a live session
|
|
167
|
-
* for a single in-process op. resume → use → drop; the lease owns lifecycle,
|
|
168
|
-
* the returned handle does NOT own the box. Throws SandboxResumeError on a
|
|
169
|
-
* backend mismatch or a resume failure.
|
|
170
|
-
*/
|
|
171
|
-
resumeBoxById?: (input: ResumeBoxByIdInput) => Promise<ResumedSandboxSession>;
|
|
172
|
-
};
|
|
173
|
-
type ObjectStorageDependency = ReturnType<typeof createObjectStorage>;
|
|
174
|
-
type ApiRouteDeps = AppDependencies & {
|
|
175
|
-
objectStorage: ObjectStorageDependency;
|
|
176
|
-
githubStateSecret: string;
|
|
177
|
-
documentIndexer: DocumentIndexClient;
|
|
178
|
-
getDocumentServices: () => DocumentServices;
|
|
179
|
-
resumeBoxById: (input: ResumeBoxByIdInput) => Promise<ResumedSandboxSession>;
|
|
180
|
-
};
|
|
181
|
-
/**
|
|
182
|
-
* The exact dependency slice used by `acceptSessionUserMessage`.
|
|
183
|
-
*
|
|
184
|
-
* Keeping this narrower than `ApiRouteDeps` lets control-plane callers reuse
|
|
185
|
-
* the canonical admission path without constructing unrelated HTTP, document,
|
|
186
|
-
* or sandbox services. The public API still passes its `ApiRouteDeps` superset.
|
|
187
|
-
*/
|
|
188
|
-
type AcceptSessionUserMessageDependencies = Pick<AppDependencies, "settings" | "db" | "bus" | "sessionAuthorization"> & {
|
|
189
|
-
workflowClient: Pick<SessionWorkflowClient, "wakeSessionWorkflow">;
|
|
190
|
-
objectStorage: ObjectStorageDependency;
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
/** One global Temporal Schedule owns bounded delivery of committed session wakes. */
|
|
194
|
-
declare const SESSION_WORKFLOW_WAKE_DISPATCHER_SCHEDULE_ID = "opengeni-session-workflow-wake-dispatcher";
|
|
195
|
-
declare const SESSION_WORKFLOW_WAKE_DISPATCHER_WORKFLOW_TYPE = "sessionWorkflowWakeDispatcherWorkflow";
|
|
196
|
-
declare const SESSION_WORKFLOW_WAKE_DISPATCHER_PERIOD_MS = 10000;
|
|
197
|
-
|
|
198
|
-
type FleetServices = {
|
|
199
|
-
db: Database;
|
|
200
|
-
settings: Settings;
|
|
201
|
-
bus?: EventBus;
|
|
202
|
-
/** API-direct readiness owner for the session's home group. Production wires
|
|
203
|
-
* this to the same viewer/provider verification + rematerialization path; core
|
|
204
|
-
* tests may omit it when exercising pointer mechanics only. */
|
|
205
|
-
ensureSessionGroupReady?: (ctx: FleetContext) => Promise<FleetReadinessHold>;
|
|
206
|
-
};
|
|
207
|
-
type FleetReadinessHold = {
|
|
208
|
-
/** Release target liveness only after route publication settles. */
|
|
209
|
-
release: () => Promise<void>;
|
|
210
|
-
};
|
|
211
|
-
type FleetContext = {
|
|
212
|
-
accountId: string;
|
|
213
|
-
workspaceId: string;
|
|
214
|
-
/** The calling session (the pointer the attach/swap mutates + whose group box
|
|
215
|
-
* is the default fleet member). */
|
|
216
|
-
sessionId: string;
|
|
217
|
-
/** The session's own group sandbox backend (modal/selfhosted/…). */
|
|
218
|
-
sessionBackend: string;
|
|
219
|
-
/** The session's own group sandbox id (the lease group). */
|
|
220
|
-
sessionGroupId: string;
|
|
221
|
-
};
|
|
222
|
-
/**
|
|
223
|
-
* Build a session-scoped {@link FleetContext}: load the session (workspace-
|
|
224
|
-
* scoped), reject a session with no box (backend:none — the fleet is only
|
|
225
|
-
* meaningful for a sandboxed session), and project its group backend/id. Shared
|
|
226
|
-
* by the worker-signed MCP fleet tools and the user-authenticated swap REST
|
|
227
|
-
* route so both resolve the SAME context (no drift). The `accountId`/`workspaceId`/
|
|
228
|
-
* `sessionId` come from the trusted grant/route; the backend + group id come from
|
|
229
|
-
* the session row.
|
|
230
|
-
*/
|
|
231
|
-
declare function buildFleetContextForSession(deps: {
|
|
232
|
-
db: Database;
|
|
233
|
-
}, ctx: {
|
|
234
|
-
accountId: string;
|
|
235
|
-
workspaceId: string;
|
|
236
|
-
sessionId: string;
|
|
237
|
-
}): Promise<FleetContext>;
|
|
238
|
-
/** The dominant liveness of a fleet member, surfaced to the dock + the agent. */
|
|
239
|
-
type FleetLiveness = "online" | "reconnecting" | "offline";
|
|
240
|
-
/**
|
|
241
|
-
* A fleet member as the agent + the dock see it (the M8b/M9 UI seam — the
|
|
242
|
-
* `sandboxes_list` response entry the dock renders). STABLE shape: the dock keys
|
|
243
|
-
* on `id`, renders `name`/`kind`/`liveness`, and marks `active`. The session's own
|
|
244
|
-
* Modal group box is a synthetic entry with `id: groupId`, `kind: "modal"`, and a
|
|
245
|
-
* null `enrollmentId`; an enrolled machine carries its sandbox + enrollment ids.
|
|
246
|
-
*/
|
|
247
|
-
type FleetSandboxEntry = {
|
|
248
|
-
/** The sandbox id used as the attach/swap/run_on `target`. For the session's
|
|
249
|
-
* own group box this is the group id (a null active pointer == this box). */
|
|
250
|
-
id: string;
|
|
251
|
-
kind: "modal" | "selfhosted";
|
|
252
|
-
name: string;
|
|
253
|
-
liveness: FleetLiveness;
|
|
254
|
-
/** True for the session's currently-active sandbox (the routing target). */
|
|
255
|
-
active: boolean;
|
|
256
|
-
/** True for the session's own group box (the default/home sandbox). */
|
|
257
|
-
isSessionGroup: boolean;
|
|
258
|
-
enrollmentId: string | null;
|
|
259
|
-
/** Whether this target can be attached/swapped to right now (live + addressable). */
|
|
260
|
-
attachable: boolean;
|
|
261
|
-
/** Selfhosted only: whether whole-machine + screen-control consent is acked. */
|
|
262
|
-
consented?: boolean;
|
|
263
|
-
/** Selfhosted only: whether a display (real/Xvfb) is present. */
|
|
264
|
-
hasDisplay?: boolean;
|
|
265
|
-
lastSeenAt?: string | null;
|
|
266
|
-
/** Orthogonal truth dimensions. `liveness` is only their conservative UI
|
|
267
|
-
* projection and is never evidence for a specific dimension. */
|
|
268
|
-
providerStatus: "not_created" | "creating" | "exists" | "missing" | "unknown";
|
|
269
|
-
leaseLiveness: "cold" | "warming" | "warm" | "draining" | null;
|
|
270
|
-
routeStatus: "attached" | "detached";
|
|
271
|
-
archiveStatus: "none" | "available" | "unverified" | "invalid";
|
|
272
|
-
restoreStatus: "not_required" | "pending" | "restoring" | "verifying" | "ready" | "degraded" | "unrecoverable";
|
|
273
|
-
workspaceStatus: "unknown" | "not_ready" | "ready" | "degraded" | "unrecoverable";
|
|
274
|
-
leaseEpoch: number | null;
|
|
275
|
-
routeEpoch: number;
|
|
276
|
-
/** Numeric/boolean persistence truth only. Archive locations, content hashes,
|
|
277
|
-
* provider identities, and storage handles are intentionally not projected. */
|
|
278
|
-
workspaceGeneration: number | null;
|
|
279
|
-
archiveGeneration: number | null;
|
|
280
|
-
archiveComplete: boolean;
|
|
281
|
-
};
|
|
282
|
-
type FleetListResult = {
|
|
283
|
-
/** The session's currently-active sandbox id, or null == the group box. */
|
|
284
|
-
activeSandboxId: string | null;
|
|
285
|
-
activeEpoch: number;
|
|
286
|
-
sandboxes: FleetSandboxEntry[];
|
|
287
|
-
};
|
|
288
|
-
/** A swap/attach outcome the tool returns. On a rejection, `code` carries the
|
|
289
|
-
* typed reason (issue #341 typed diagnostics) alongside the human `reason`. */
|
|
290
|
-
type FleetSwapResult = {
|
|
291
|
-
swapped: boolean;
|
|
292
|
-
activeSandboxId: string | null;
|
|
293
|
-
activeEpoch: number;
|
|
294
|
-
reason?: string;
|
|
295
|
-
code?: BackendUnresolvableCode | "concurrent_swap" | "recovery_in_progress" | "recovery_degraded" | "recovery_unrecoverable";
|
|
296
|
-
};
|
|
297
|
-
/**
|
|
298
|
-
* List the fleet: the session's own Modal group box (a synthetic entry) + the
|
|
299
|
-
* workspace's first-class selfhosted sandboxes (each probed for liveness), each
|
|
300
|
-
* with an `active` marker derived from the session's active pointer.
|
|
301
|
-
*/
|
|
302
|
-
declare function listFleet(services: FleetServices, ctx: FleetContext): Promise<FleetListResult>;
|
|
303
|
-
/**
|
|
304
|
-
* THE SWAP (and attach — identical mechanic). Validate the target's ownership +
|
|
305
|
-
* liveness, then repoint the session via the epoch-fenced CAS `setActiveSandbox`:
|
|
306
|
-
* read the current epoch, then CAS on it. A concurrent double-swap lets exactly
|
|
307
|
-
* one win; the loser re-reads + may retry. The bumped epoch fences any in-flight
|
|
308
|
-
* op cached against the old pointer, which then retries against the new active
|
|
309
|
-
* sandbox (the routing proxy's fenced-retry role).
|
|
310
|
-
*/
|
|
311
|
-
declare function swapActiveSandbox(services: FleetServices, ctx: FleetContext, target: string, workingDir?: string | null): Promise<FleetSwapResult>;
|
|
312
|
-
type RunOnOp = {
|
|
313
|
-
kind: "exec";
|
|
314
|
-
cmd: string;
|
|
315
|
-
workdir?: string;
|
|
316
|
-
} | {
|
|
317
|
-
kind: "read";
|
|
318
|
-
path: string;
|
|
319
|
-
} | {
|
|
320
|
-
kind: "write";
|
|
321
|
-
path: string;
|
|
322
|
-
content: string;
|
|
323
|
-
};
|
|
324
|
-
type RunOnResult = {
|
|
325
|
-
target: string;
|
|
326
|
-
kind: string;
|
|
327
|
-
ok: boolean;
|
|
328
|
-
stdout?: string;
|
|
329
|
-
stderr?: string;
|
|
330
|
-
exitCode?: number | null;
|
|
331
|
-
content?: string;
|
|
332
|
-
bytesWritten?: number;
|
|
333
|
-
reason?: string;
|
|
334
|
-
};
|
|
335
|
-
/**
|
|
336
|
-
* Run a ONE-OFF op against a SPECIFIC target WITHOUT changing the active pointer
|
|
337
|
-
* (the design `run_on`). Only selfhosted targets are routable as a one-off here
|
|
338
|
-
* (a Modal target is the session's group box, reached via the normal Channel-A /
|
|
339
|
-
* turn path — `run_on` is for reaching a NON-active enrolled machine without
|
|
340
|
-
* swapping). The op is fenced under the target's enrollment, addressed to its
|
|
341
|
-
* agent subject; an offline machine surfaces a clear reason, never a wrong-box
|
|
342
|
-
* landing.
|
|
343
|
-
*/
|
|
344
|
-
declare function runOnSandbox(services: FleetServices, ctx: FleetContext, target: string, op: RunOnOp): Promise<RunOnResult>;
|
|
345
|
-
type ProvisionResult = {
|
|
346
|
-
kind: "selfhosted";
|
|
347
|
-
instructions: string;
|
|
348
|
-
installCommandUnix: string;
|
|
349
|
-
installCommandWindows: string;
|
|
350
|
-
verificationUri: string;
|
|
351
|
-
note: string;
|
|
352
|
-
} | {
|
|
353
|
-
kind: "modal";
|
|
354
|
-
sandbox: SandboxRecord;
|
|
355
|
-
note: string;
|
|
356
|
-
};
|
|
357
|
-
/**
|
|
358
|
-
* Provision a new fleet member.
|
|
359
|
-
* - selfhosted → return the device-flow enrollment instructions (the agent
|
|
360
|
-
* surfaces them to a HUMAN, who installs the agent + enrolls — the agent
|
|
361
|
-
* cannot click the loud whole-machine consent itself).
|
|
362
|
-
* - modal → create a first-class named modal `sandboxes` record (a swap target).
|
|
363
|
-
* NOTE: the Modal BOX is materialized lazily when first swapped-to (Modal
|
|
364
|
-
* lifecycle is owned by the lease — unchanged per).
|
|
365
|
-
*/
|
|
366
|
-
declare function provisionSandbox(services: FleetServices, ctx: FleetContext, input: {
|
|
367
|
-
kind: "selfhosted" | "modal";
|
|
368
|
-
name?: string;
|
|
369
|
-
}): Promise<ProvisionResult>;
|
|
370
|
-
|
|
371
|
-
type ChannelARoutingServices = {
|
|
372
|
-
db: Database;
|
|
373
|
-
settings: Settings;
|
|
374
|
-
bus?: EventBus;
|
|
375
|
-
};
|
|
376
|
-
/** Map the deployment relay URL to the leaf's `SelfhostedRelayConfig` shape. The
|
|
377
|
-
* relay URL (`OPENGENI_SELFHOSTED_RELAY_URL`) may carry a path (the relay's wss
|
|
378
|
-
* route); a path-less URL defaults to the relay's `/stream` route (M8b). */
|
|
379
|
-
declare function relayConfigFromSettings(settings: Settings): SelfhostedRelayConfig;
|
|
380
|
-
/** The canonical relay dial-BASE URL (`scheme://host[:port]/stream`) handed to the
|
|
381
|
-
* agent PRODUCER. The agent's relay channel appends ONLY its routing query to
|
|
382
|
-
* this base (`channel.rs`: `format!("{relay_url}{sep}{query}")`) and relies on the
|
|
383
|
-
* base ALREADY carrying the relay's `/stream` route. `OPENGENI_SELFHOSTED_RELAY_URL`
|
|
384
|
-
* is frequently pathless (e.g. `wss://relay.<env>.app.opengeni.ai`), which made the
|
|
385
|
-
* producer dial a path-less URL the relay 400s. Derive the base from the SAME parser
|
|
386
|
-
* the CONSUMER uses (`relayConfigFromSettings`) so producer + consumer always agree
|
|
387
|
-
* on `/stream` — even when the configured URL omits it. An unconfigured relay maps to
|
|
388
|
-
* `""` (graceful degrade: the agent reports no-relay rather than dialing a synthetic
|
|
389
|
-
* host). Fixes preview AND managed prod with no agent rebuild. */
|
|
390
|
-
declare function relayDialBaseFromSettings(settings: Settings): string;
|
|
391
|
-
/** Whether the routing proxy should wrap the Channel-A box: gated by the
|
|
392
|
-
* selfhosted flag (the active pointer + swap are only meaningful then). */
|
|
393
|
-
declare function routingEnabled(settings: Settings): boolean;
|
|
394
|
-
/**
|
|
395
|
-
* Wrap an established home session in a `RoutingSandboxSession` so a Channel-A
|
|
396
|
-
* op routes to the session's currently-active sandbox. Provider homes supply a
|
|
397
|
-
* lease; machine homes supply a pinned selfhosted identity and no lease. Returns
|
|
398
|
-
* the established handle with its `session` replaced by the stable proxy.
|
|
399
|
-
*/
|
|
400
|
-
declare function wrapChannelABoxWithRouting(services: ChannelARoutingServices, ids: {
|
|
401
|
-
accountId: string;
|
|
402
|
-
workspaceId: string;
|
|
403
|
-
sessionId: string;
|
|
404
|
-
homeLease?: {
|
|
405
|
-
sandboxGroupId: string;
|
|
406
|
-
leaseEpoch: number;
|
|
407
|
-
instanceId: string;
|
|
408
|
-
backend: string;
|
|
409
|
-
};
|
|
410
|
-
/** A machine-home Channel-A request has no cloud/home lease. Its already
|
|
411
|
-
* established SelfhostedSession is pinned to the durable active pointer so
|
|
412
|
-
* the first command uses the exact machine instance and epoch. */
|
|
413
|
-
pinnedSelfhosted?: {
|
|
414
|
-
sandboxId: string;
|
|
415
|
-
epoch: number;
|
|
416
|
-
};
|
|
417
|
-
directRequest: {
|
|
418
|
-
requestId: string;
|
|
419
|
-
holderId: string;
|
|
420
|
-
};
|
|
421
|
-
}, established: EstablishedSandboxSession): EstablishedSandboxSession;
|
|
422
|
-
|
|
423
|
-
type AccessDeps = {
|
|
424
|
-
db: Database;
|
|
425
|
-
settings: Settings;
|
|
426
|
-
managedAuth?: ManagedAuth | null;
|
|
427
|
-
};
|
|
428
|
-
declare function requireAccessContext(c: Context, deps: AccessDeps): Promise<AccessContext>;
|
|
429
|
-
declare function requireAccessGrant(c: Context, deps: AccessDeps, workspaceId: string, permission?: Permission): Promise<AccessGrant>;
|
|
430
|
-
declare function requirePermission(grant: AccessGrant, permission: Permission): void;
|
|
431
|
-
declare function hasPermission(permissions: Permission[], permission: Permission): boolean;
|
|
432
|
-
|
|
433
|
-
type SessionAuthorizationDependencies = Pick<AppDependencies, "db" | "sessionAuthorization">;
|
|
434
|
-
/** Maximum time an omitted host hint leaves a live session stream unchecked. */
|
|
435
|
-
declare const SESSION_AUTHORIZATION_DEFAULT_REAUTHORIZE_MS = 15000;
|
|
436
|
-
declare class SessionAuthorizationDeniedError extends Error {
|
|
437
|
-
readonly reason: "not_found" | "forbidden" | "revoked" | "caller_stale";
|
|
438
|
-
readonly code = "SESSION_NOT_FOUND_OR_DENIED";
|
|
439
|
-
constructor(reason: "not_found" | "forbidden" | "revoked" | "caller_stale");
|
|
440
|
-
}
|
|
441
|
-
declare class SessionAuthorizationUnavailableError extends Error {
|
|
442
|
-
readonly code = "SESSION_AUTHORIZATION_UNAVAILABLE";
|
|
443
|
-
constructor(options?: ErrorOptions);
|
|
444
|
-
}
|
|
445
|
-
type ResolvedSessionAuthorization = {
|
|
446
|
-
actor: SessionAuthorizationActor;
|
|
447
|
-
target: SessionAuthorizationTarget;
|
|
448
|
-
relatedSessionAccess: "target" | "root";
|
|
449
|
-
reauthorizeAfterMs: number | null;
|
|
450
|
-
};
|
|
451
|
-
/**
|
|
452
|
-
* Resolve and enforce the host ACL for one session. The target and agent actor
|
|
453
|
-
* are reconstructed from workspace-scoped durable state. A request can supply
|
|
454
|
-
* an immediate target id and signed attempt claims, but can never nominate a
|
|
455
|
-
* lineage root or frozen initiator.
|
|
456
|
-
*
|
|
457
|
-
* Returns null when no host port is bound so standalone behavior stays byte-
|
|
458
|
-
* for-byte unchanged and pays no additional lineage lookup.
|
|
459
|
-
*/
|
|
460
|
-
declare function requireSessionAuthorization(deps: SessionAuthorizationDependencies, grant: AccessGrant, input: {
|
|
461
|
-
sessionId: string;
|
|
462
|
-
operation: SessionAuthorizationOperation;
|
|
463
|
-
surface: SessionAuthorizationSurface;
|
|
464
|
-
}): Promise<ResolvedSessionAuthorization | null>;
|
|
465
|
-
/** Resolve the host's complete current list scope for an in-database query. */
|
|
466
|
-
declare function requireSessionAuthorizationListScope(deps: SessionAuthorizationDependencies, grant: AccessGrant, surface: SessionAuthorizationSurface): Promise<SessionAuthorizationListScope | null>;
|
|
467
|
-
|
|
468
|
-
type LimitDependencies = Pick<ApiRouteDeps, "db" | "settings">;
|
|
469
|
-
type LimitCheckInput = {
|
|
470
|
-
accountId: string;
|
|
471
|
-
workspaceId?: string;
|
|
472
|
-
action: LimitAction;
|
|
473
|
-
quantity?: number;
|
|
474
|
-
model?: string | null;
|
|
475
|
-
};
|
|
476
|
-
declare function requireLimit(deps: LimitDependencies, input: LimitCheckInput): Promise<void>;
|
|
477
|
-
declare function checkLimit(deps: LimitDependencies, input: LimitCheckInput): Promise<LimitDecision>;
|
|
478
|
-
declare function recordWorkspaceUsage(deps: LimitDependencies, input: {
|
|
479
|
-
accountId: string;
|
|
480
|
-
workspaceId: string;
|
|
481
|
-
subjectId?: string | null;
|
|
482
|
-
eventType: "agent_run.created" | "file.uploaded" | "document.indexed" | "scheduled_task.fired";
|
|
483
|
-
quantity: number;
|
|
484
|
-
unit: string;
|
|
485
|
-
sourceResourceType: string;
|
|
486
|
-
sourceResourceId: string;
|
|
487
|
-
sessionId?: string | null;
|
|
488
|
-
turnId?: string | null;
|
|
489
|
-
turnAttemptId?: string | null;
|
|
490
|
-
initiator?: TurnInitiator | null;
|
|
491
|
-
initiatorContext?: TurnInitiatorContext;
|
|
492
|
-
origin?: SessionTurnSource | null;
|
|
493
|
-
idempotencyKey: string;
|
|
494
|
-
}): Promise<void>;
|
|
495
|
-
|
|
496
|
-
declare const officialMcpRegistryUrl = "https://registry.modelcontextprotocol.io";
|
|
497
|
-
declare function buildCapabilityCatalog(input: {
|
|
498
|
-
db: Database;
|
|
499
|
-
workspaceId: string;
|
|
500
|
-
settings: Settings;
|
|
501
|
-
}): Promise<CapabilityCatalogResponse>;
|
|
502
|
-
declare function createCatalogItem(input: {
|
|
503
|
-
db: Database;
|
|
504
|
-
accountId: string;
|
|
505
|
-
workspaceId: string;
|
|
506
|
-
payload: CreateCapabilityCatalogItemRequest;
|
|
507
|
-
}): Promise<CapabilityCatalogItem>;
|
|
508
|
-
declare function enableCapability(input: {
|
|
509
|
-
db: Database;
|
|
510
|
-
grant: AccessGrant;
|
|
511
|
-
accountId: string;
|
|
512
|
-
workspaceId: string;
|
|
513
|
-
settings: Settings;
|
|
514
|
-
capabilityId: string;
|
|
515
|
-
payload: EnableCapabilityRequest;
|
|
516
|
-
probeMcpServer?: McpCapabilityProbe;
|
|
517
|
-
}): Promise<CapabilityInstallation>;
|
|
518
|
-
type McpCapabilityProbeInput = {
|
|
519
|
-
id: string;
|
|
520
|
-
name: string;
|
|
521
|
-
url: string;
|
|
522
|
-
timeoutMs: number;
|
|
523
|
-
headers?: Record<string, string>;
|
|
524
|
-
};
|
|
525
|
-
type McpCapabilityProbeResult = {
|
|
526
|
-
toolCount: number;
|
|
527
|
-
};
|
|
528
|
-
type McpCapabilityProbe = (input: McpCapabilityProbeInput) => Promise<McpCapabilityProbeResult>;
|
|
529
|
-
declare function validateMcpCapabilityConnection(item: CapabilityCatalogItem, probe?: McpCapabilityProbe, headers?: Record<string, string>): Promise<Record<string, unknown>>;
|
|
530
|
-
declare function disableCapability(input: {
|
|
531
|
-
db: Database;
|
|
532
|
-
accountId: string;
|
|
533
|
-
workspaceId: string;
|
|
534
|
-
settings: Settings;
|
|
535
|
-
capabilityId: string;
|
|
536
|
-
}): Promise<CapabilityInstallation>;
|
|
537
|
-
declare function settingsWithEnabledCapabilityMcpServers(db: Database, workspaceId: string, settings: Settings): Promise<Settings>;
|
|
538
|
-
/**
|
|
539
|
-
* Register Codex Apps as an optional runtime MCP when the deployment enables
|
|
540
|
-
* it. Registration only makes the server selectable; the session tool policy
|
|
541
|
-
* decides whether the model sees it, and Codex credential resolution
|
|
542
|
-
* independently decides whether calls can authenticate.
|
|
543
|
-
*/
|
|
544
|
-
declare function settingsWithCodexAppsMcpServer(settings: Settings): Settings;
|
|
545
|
-
declare function settingsWithMcpCapabilityServers(settings: Settings, enabled: EnabledMcpCapabilityServer[]): Settings;
|
|
546
|
-
declare function discoverMcpRegistryCapabilities(input: {
|
|
547
|
-
query?: string;
|
|
548
|
-
limit?: number;
|
|
549
|
-
fetchImpl?: McpRegistryFetch;
|
|
550
|
-
timeoutMs?: number;
|
|
551
|
-
}): Promise<CapabilityCatalogItem[]>;
|
|
552
|
-
|
|
553
|
-
type McpRegistryFetch = (input: URL, init?: RequestInit) => Promise<Response>;
|
|
554
|
-
declare function applyCapabilityEnablement(item: CapabilityCatalogItem, installation: CapabilityInstallation | undefined, activePackIds: Set<string>): CapabilityCatalogItem;
|
|
555
|
-
|
|
556
|
-
declare const MAX_ENVIRONMENTS_PER_WORKSPACE = 25;
|
|
557
|
-
declare const MAX_VARIABLES_PER_ENVIRONMENT = 100;
|
|
558
|
-
declare function assertAllowedVariableSetVariableName(name: string): void;
|
|
559
|
-
/** @deprecated use assertAllowedVariableSetVariableName */
|
|
560
|
-
declare const assertAllowedEnvironmentVariableName: typeof assertAllowedVariableSetVariableName;
|
|
561
|
-
declare function requireVariableSetEncryption(settings: Settings): Uint8Array;
|
|
562
|
-
/** @deprecated use requireVariableSetEncryption */
|
|
563
|
-
declare const requireEnvironmentEncryption: typeof requireVariableSetEncryption;
|
|
564
|
-
declare function requireVariableSetForApi(db: Database, workspaceId: string, variableSetId: string): Promise<VariableSet>;
|
|
565
|
-
/**
|
|
566
|
-
* Validates an variableSet attachment supplied in a request payload (session
|
|
567
|
-
* create, scheduled task create/update, pack enable). Requires the
|
|
568
|
-
* `variable-sets:use` permission unless the attachment was already authorized
|
|
569
|
-
* (pack-installation-inherited attachments), and maps a missing or
|
|
570
|
-
* cross-variable set to 422 because the id is payload, not the route
|
|
571
|
-
* target. RLS plus the workspace_id clause make cross-workspace ids
|
|
572
|
-
* indistinguishable from missing ones.
|
|
573
|
-
*/
|
|
574
|
-
declare function validateVariableSetAttachment(deps: {
|
|
575
|
-
settings: Settings;
|
|
576
|
-
db: Database;
|
|
577
|
-
}, grant: AccessGrant, workspaceId: string, variableSetId: string, options?: {
|
|
578
|
-
preauthorized?: boolean;
|
|
579
|
-
}): Promise<VariableSet>;
|
|
580
|
-
declare function recordVariableSetAuditEvent(db: Database, input: {
|
|
581
|
-
grant: AccessGrant;
|
|
582
|
-
action: "variable_set.created" | "variable_set.updated" | "variable_set.deleted" | "variable_set.variable.set" | "variable_set.variable.deleted";
|
|
583
|
-
variableSetId: string;
|
|
584
|
-
variableName?: string;
|
|
585
|
-
}): Promise<void>;
|
|
586
|
-
|
|
587
|
-
declare const MAX_RIGS_PER_WORKSPACE = 50;
|
|
588
|
-
declare const MAX_CHECKS_PER_RIG = 100;
|
|
589
|
-
declare const MAX_CREDENTIAL_HOOKS_PER_RIG = 50;
|
|
590
|
-
declare const MAX_DEFAULT_VARIABLE_SETS_PER_RIG = 25;
|
|
591
|
-
type RigServices = {
|
|
592
|
-
db: Database;
|
|
593
|
-
};
|
|
594
|
-
type RigAuditAction = "rig.created" | "rig.updated" | "rig.deleted" | "rig.change.proposed" | "rig.change.verified" | "rig.change.rejected" | "rig.change.failed" | "rig.change.merged" | "rig.verification.started" | "rig.verification.passed" | "rig.verification.failed" | "rig.version.activated" | "rig.version.promoted";
|
|
595
|
-
declare function recordRigAuditEvent(db: Database, input: {
|
|
596
|
-
grant: AccessGrant;
|
|
597
|
-
action: RigAuditAction;
|
|
598
|
-
rigId: string;
|
|
599
|
-
metadata?: Record<string, unknown>;
|
|
600
|
-
}): Promise<void>;
|
|
601
|
-
declare function rigActorForGrant(grant: AccessGrant): string;
|
|
602
|
-
declare function requireRigForApi(db: Database, workspaceId: string, rigId: string): Promise<Rig>;
|
|
603
|
-
declare function requireRigChangeForApi(db: Database, workspaceId: string, rigId: string, changeId: string): Promise<RigChange>;
|
|
604
|
-
declare function createRigForApi(deps: RigServices, grant: AccessGrant, payload: CreateRigRequest): Promise<Rig>;
|
|
605
|
-
declare function updateRigForApi(deps: RigServices, grant: AccessGrant, rig: Rig, payload: UpdateRigRequest): Promise<Rig>;
|
|
606
|
-
declare function deleteRigForApi(deps: RigServices, grant: AccessGrant, rig: Rig): Promise<void>;
|
|
607
|
-
declare function proposeRigChangeForApi(deps: RigServices, grant: AccessGrant, rig: Rig, request: ProposeRigChangeRequest, options?: {
|
|
608
|
-
proposedBy?: string;
|
|
609
|
-
}): Promise<RigChange>;
|
|
610
|
-
type RigVerificationClassification = {
|
|
611
|
-
status: "merged";
|
|
612
|
-
action: "auto_promote";
|
|
613
|
-
} | {
|
|
614
|
-
status: "proposed";
|
|
615
|
-
action: "await_manage_promote";
|
|
616
|
-
} | {
|
|
617
|
-
status: "rejected";
|
|
618
|
-
action: "reject";
|
|
619
|
-
} | {
|
|
620
|
-
status: "failed";
|
|
621
|
-
action: "retryable_failure";
|
|
622
|
-
};
|
|
623
|
-
declare function classifyRigVerificationOutcome(input: {
|
|
624
|
-
kind: "setup_append" | "definition_edit";
|
|
625
|
-
passed: boolean;
|
|
626
|
-
infraError?: boolean;
|
|
627
|
-
}): RigVerificationClassification;
|
|
628
|
-
declare function appendRigSetupCommand(baseSetupScript: string | null | undefined, command: string): string;
|
|
629
|
-
declare function promoteSetupAppendChange(deps: RigServices, grant: AccessGrant, rig: Rig, change: RigChange): Promise<{
|
|
630
|
-
change: RigChange;
|
|
631
|
-
version: RigVersion;
|
|
632
|
-
}>;
|
|
633
|
-
declare function promoteVerifiedDefinitionEditChangeForApi(deps: RigServices, grant: AccessGrant, rig: Rig, change: RigChange): Promise<{
|
|
634
|
-
change: RigChange;
|
|
635
|
-
version: RigVersion;
|
|
636
|
-
}>;
|
|
637
|
-
declare function createRigVersionForApi(deps: RigServices, grant: AccessGrant, rig: Rig, payload: RigDefinitionEditPayload): Promise<RigVersion>;
|
|
638
|
-
declare function activateRigVersionForApi(deps: RigServices, grant: AccessGrant, rig: Rig, versionId: string): Promise<RigVersion>;
|
|
639
|
-
declare function listRigVersionsForApi(deps: RigServices, workspaceId: string, rigId: string): Promise<RigVersion[]>;
|
|
640
|
-
declare function listRigChangesForApi(deps: RigServices, workspaceId: string, rigId: string, limit?: number): Promise<RigChange[]>;
|
|
641
|
-
|
|
642
|
-
declare const MARKETING_SOCIAL_PACK_ID = "marketing-social-daily-analysis";
|
|
643
|
-
declare function listCapabilityPacks(): CapabilityPack[];
|
|
644
|
-
declare function getCapabilityPack(packId: string): CapabilityPack | null;
|
|
645
|
-
declare function isBuiltInCapabilityPack(packId: string): boolean;
|
|
646
|
-
/**
|
|
647
|
-
* Built-in packs plus the manifests registered for this workspace. Stored
|
|
648
|
-
* manifests were validated at registration time; rows that no longer parse
|
|
649
|
-
* (for example after a contract tightening) are skipped instead of breaking
|
|
650
|
-
* the whole catalog.
|
|
651
|
-
*/
|
|
652
|
-
declare function listWorkspaceCapabilityPacks(db: Database, workspaceId: string): Promise<CapabilityPack[]>;
|
|
653
|
-
declare function resolveCapabilityPack(db: Database, workspaceId: string, packId: string): Promise<CapabilityPack | null>;
|
|
654
|
-
/**
|
|
655
|
-
* v1 pack-scoped runtime rule: at most one enabled pack per workspace may
|
|
656
|
-
* declare a `sandboxImage` — there is deliberately no image composition or
|
|
657
|
-
* layering. Enforced when a pack is enabled (both the packs endpoint and the
|
|
658
|
-
* generic capability enable path) and re-checked at session start by the
|
|
659
|
-
* worker, which also covers manifests re-registered after enablement.
|
|
660
|
-
*/
|
|
661
|
-
declare function assertPackSandboxImageCompatible(db: Database, workspaceId: string, pack: CapabilityPack): Promise<void>;
|
|
662
|
-
declare function buildMarketingDailyAnalysisAgentConfig(input: {
|
|
663
|
-
connections: SocialConnection[];
|
|
664
|
-
documentBaseIds: string[];
|
|
665
|
-
promptInstructions?: string;
|
|
666
|
-
}): ScheduledTaskAgentConfig;
|
|
667
|
-
|
|
668
|
-
declare function validateToolRefs(tools: ToolRef[], settings: McpSettings): ToolRef[];
|
|
669
|
-
type McpSettings = Pick<Settings, "mcpServers">;
|
|
670
|
-
declare function enabledCapabilityMcpToolRefs(settings: McpSettings, runtimeSettings: McpSettings): ToolRef[];
|
|
671
|
-
declare function withDefaultEnabledCapabilityMcpTools(tools: ToolRef[], settings: McpSettings, runtimeSettings: McpSettings): ToolRef[];
|
|
672
|
-
/** Drop stored refs that are no longer present in the current runtime registry. */
|
|
673
|
-
declare function availableToolRefs(tools: ToolRef[], settings: McpSettings): ToolRef[];
|
|
674
|
-
/** A child or fixed-policy follow-up may narrow its allow-list, never widen it. */
|
|
675
|
-
declare function assertToolRefsSubset(requested: ToolRef[], allowed: ToolRef[], message?: string): void;
|
|
676
|
-
/** Validate runtime availability and then enforce the durable policy fence. */
|
|
677
|
-
declare function validateToolRefsForSessionPolicy(input: {
|
|
678
|
-
requested: ToolRef[];
|
|
679
|
-
settings: McpSettings;
|
|
680
|
-
allowedTools: ToolRef[];
|
|
681
|
-
message: string;
|
|
682
|
-
}): ToolRef[];
|
|
683
|
-
declare function normalizeResources(resources: ResourceRef[]): ResourceRef[];
|
|
684
|
-
declare function mergeResourceRefs(existing: ResourceRef[], additions: ResourceRef[]): ResourceRef[];
|
|
685
|
-
declare function validateGitHubRepositorySelectionShapes(resources: ResourceRef[]): number[];
|
|
686
|
-
/** @deprecated Use validateGitHubRepositorySelectionShapes for multi-installation sessions. */
|
|
687
|
-
declare function validateGitHubRepositorySelectionShape(resources: ResourceRef[]): number | null;
|
|
688
|
-
declare function validateGitHubRepositorySelection(db: Database, workspaceId: string, resources: ResourceRef[]): Promise<void>;
|
|
689
|
-
/**
|
|
690
|
-
* A 422 from repository selection validation is an authoritative stale or
|
|
691
|
-
* revoked identity. Other failures (for example a database/catalog outage)
|
|
692
|
-
* leave the result unknown and must not cause draft hydration to delete it.
|
|
693
|
-
*/
|
|
694
|
-
declare function isAuthoritativeGitHubRepositorySelectionError(error: unknown): boolean;
|
|
695
|
-
declare function validateFileResources(db: Database, workspaceId: string, resources: ResourceRef[]): Promise<void>;
|
|
696
|
-
|
|
697
|
-
type ResolvedSessionToolPolicy = {
|
|
698
|
-
toolRefs: ToolRef[];
|
|
699
|
-
effectivePolicy: SessionEffectiveToolPolicy;
|
|
700
|
-
};
|
|
701
|
-
type SessionToolPolicyInput = {
|
|
702
|
-
toolPolicy: SessionToolPolicy;
|
|
703
|
-
sessionTools: ToolRef[];
|
|
704
|
-
availableMcpServerIds: Iterable<string>;
|
|
705
|
-
/** Current omitted-tools defaults, intentionally narrower than all servers. */
|
|
706
|
-
defaultMcpServerIds?: Iterable<string>;
|
|
707
|
-
};
|
|
708
|
-
/**
|
|
709
|
-
* Resolve the same ID-only policy used by API projections and worker turns.
|
|
710
|
-
* This function never receives endpoint URLs, credentials, schemas, or live
|
|
711
|
-
* probe results. `availableMcpServerIds` is the resolved runtime registry;
|
|
712
|
-
* `defaultMcpServerIds` is the capability-only omitted-tools set.
|
|
713
|
-
*/
|
|
714
|
-
declare function resolveSessionToolPolicy(input: SessionToolPolicyInput): ResolvedSessionToolPolicy;
|
|
715
|
-
/**
|
|
716
|
-
* Native provider tools that belong to the workspace-default capability set
|
|
717
|
-
* follow the same omission/narrowing fence as deferred MCP tools. A durable
|
|
718
|
-
* workspace-default policy receives them; fixed historical policies and an
|
|
719
|
-
* explicit per-turn replacement do not. Provider support remains a separate
|
|
720
|
-
* runtime gate and must also be true before a native tool is attached.
|
|
721
|
-
*/
|
|
722
|
-
declare function sessionToolPolicyAllowsDefaultNativeTools(policy: SessionEffectiveToolPolicy): boolean;
|
|
723
|
-
/** Current full runtime registry IDs, including configured static servers. */
|
|
724
|
-
declare function workspaceSessionToolPolicyServerIds(db: Database, workspaceId: string, settings: Settings): Promise<string[]>;
|
|
725
|
-
/** Current omitted-tools defaults; this preserves capability-first behavior. */
|
|
726
|
-
declare function workspaceSessionToolPolicyDefaultServerIds(db: Database, workspaceId: string, settings: Settings): Promise<string[]>;
|
|
727
|
-
/** Add a bounded, secret-safe effective projection to a session response. */
|
|
728
|
-
declare function sessionWithEffectiveToolPolicy(session: Session, workspaceServerIds: Iterable<string>, workspaceDefaultServerIds?: Iterable<string>): Session;
|
|
729
|
-
|
|
730
|
-
/**
|
|
731
|
-
* Whether a raw scheduled-task payload explicitly set agentConfig.tools.
|
|
732
|
-
* Zod's `.default([])` erases the distinction between "absent" and
|
|
733
|
-
* "explicitly empty", so callers detect it on the raw payload — the same
|
|
734
|
-
* contract sessions use: absent tools mean "give me the workspace defaults
|
|
735
|
-
* (enabled capability MCP servers)", an explicit list (even empty) is taken
|
|
736
|
-
* verbatim.
|
|
737
|
-
*/
|
|
738
|
-
declare function scheduledTaskToolsProvided(rawPayload: unknown): boolean;
|
|
739
|
-
declare function createValidatedScheduledTask(input: {
|
|
740
|
-
settings: Settings;
|
|
741
|
-
db: Database;
|
|
742
|
-
objectStorage: ObjectStorageDependency;
|
|
743
|
-
grant: AccessGrant;
|
|
744
|
-
payload: CreateScheduledTaskRequest;
|
|
745
|
-
toolsProvided?: boolean;
|
|
746
|
-
variableSetPreauthorized?: boolean;
|
|
747
|
-
}): Promise<ScheduledTask>;
|
|
748
|
-
declare function validatedScheduledTaskUpdate(input: {
|
|
749
|
-
settings: Settings;
|
|
750
|
-
db: Database;
|
|
751
|
-
objectStorage: ObjectStorageDependency;
|
|
752
|
-
grant: AccessGrant;
|
|
753
|
-
existing: ScheduledTask;
|
|
754
|
-
payload: UpdateScheduledTaskRequest;
|
|
755
|
-
/** See createValidatedScheduledTask; only consulted when agentConfig is updated. */
|
|
756
|
-
toolsProvided?: boolean;
|
|
757
|
-
}): Promise<UpdateScheduledTaskInput>;
|
|
758
|
-
declare function requireScheduledTaskForApi(db: Database, workspaceId: string, taskId: string): Promise<ScheduledTask>;
|
|
759
|
-
declare function restoreScheduledTask(db: Database, task: ScheduledTask): Promise<ScheduledTask>;
|
|
760
|
-
declare function syncCreatedScheduledTask(input: {
|
|
761
|
-
db: Database;
|
|
762
|
-
workflowClient: SessionWorkflowClient;
|
|
763
|
-
task: ScheduledTask;
|
|
764
|
-
}): Promise<void>;
|
|
765
|
-
declare function syncUpdatedScheduledTask(input: {
|
|
766
|
-
db: Database;
|
|
767
|
-
workflowClient: SessionWorkflowClient;
|
|
768
|
-
previous: ScheduledTask;
|
|
769
|
-
task: ScheduledTask;
|
|
770
|
-
}): Promise<void>;
|
|
771
|
-
declare function scheduledTaskTemporalScheduleId(taskId: string): string;
|
|
772
|
-
/**
|
|
773
|
-
* Stable token that identifies a single logical manual trigger. A client that
|
|
774
|
-
* retries a `/trigger` POST (network blip, lambda re-invocation) passes the
|
|
775
|
-
* SAME token so the retry is idempotent — one usage charge, one workflow run.
|
|
776
|
-
* When the client supplies nothing we mint one UUID PER REQUEST and reuse it
|
|
777
|
-
* for both the idempotency key and the workflowId, so a single request stays
|
|
778
|
-
* internally consistent while two genuinely-distinct manual triggers (no token,
|
|
779
|
-
* fired a second apart) still each get their own run. The token is sanitized to
|
|
780
|
-
* the Temporal workflow-id-safe charset so a client value cannot smuggle a
|
|
781
|
-
* collision into a different task's id space.
|
|
782
|
-
*/
|
|
783
|
-
declare function scheduledTaskTriggerToken(clientTriggerId?: string | null): string;
|
|
784
|
-
/**
|
|
785
|
-
* Deterministic Temporal workflow id for a manual trigger. Derived purely from
|
|
786
|
-
* the task id and the stable trigger token, so a retry with the same token maps
|
|
787
|
-
* to the same id and `workflowIdReusePolicy: "REJECT_DUPLICATE"` collapses the
|
|
788
|
-
* second start into a no-op instead of spawning a second run.
|
|
789
|
-
*/
|
|
790
|
-
declare function manualScheduledTaskTriggerWorkflowId(taskId: string, triggerToken: string): string;
|
|
791
|
-
/**
|
|
792
|
-
* Deterministic usage idempotency key for a manual trigger's agent_run.created
|
|
793
|
-
* charge. Shares the stable trigger token with the workflow id so the charge
|
|
794
|
-
* and the run dedupe together under retry.
|
|
795
|
-
*/
|
|
796
|
-
declare function manualScheduledTaskTriggerUsageKey(workspaceId: string, taskId: string, triggerToken: string): string;
|
|
797
|
-
|
|
798
|
-
/** Transport-neutral typed denial raised only after its audit row committed. */
|
|
799
|
-
declare class SessionSpawnDeniedError extends Error {
|
|
800
|
-
readonly denial: SessionSpawnDenial;
|
|
801
|
-
constructor(denial: SessionSpawnDenial);
|
|
802
|
-
}
|
|
803
|
-
/**
|
|
804
|
-
* Resolve per-session first-party tool visibility without consulting
|
|
805
|
-
* authorization. Top-level omission uses the minimal runtime default (stored
|
|
806
|
-
* as null); child omission snapshots the parent's exact effective selection.
|
|
807
|
-
* Explicit [] is authoritative and must never widen.
|
|
808
|
-
*/
|
|
809
|
-
declare function resolveFirstPartyMcpToolsForCreate(requested: FirstPartyMcpToolName[] | undefined, parentStored: FirstPartyMcpToolName[] | null | undefined): FirstPartyMcpToolName[];
|
|
810
|
-
declare function sessionSpawnDenialEnvelope(error: SessionSpawnDeniedError): {
|
|
811
|
-
readonly error: {
|
|
812
|
-
readonly code: "nested_agent_depth_exceeded" | "nested_agent_depth_override_forbidden";
|
|
813
|
-
readonly message: string;
|
|
814
|
-
readonly details: {
|
|
815
|
-
readonly denial: {
|
|
816
|
-
id: string;
|
|
817
|
-
accountId: string;
|
|
818
|
-
workspaceId: string;
|
|
819
|
-
parentSessionId: string | null;
|
|
820
|
-
rootSessionId: string | null;
|
|
821
|
-
currentDepth: number;
|
|
822
|
-
attemptedDepth: number;
|
|
823
|
-
effectiveMaxNestedAgentDepth: number;
|
|
824
|
-
requestedMaxNestedAgentDepthOverride: number | null;
|
|
825
|
-
policySource: "default" | "session" | "workspace" | "deployment";
|
|
826
|
-
policySessionId: string | null;
|
|
827
|
-
subjectId: string | null;
|
|
828
|
-
code: "nested_agent_depth_exceeded" | "nested_agent_depth_override_forbidden";
|
|
829
|
-
idempotencyKey: string | null;
|
|
830
|
-
createdAt: string;
|
|
831
|
-
};
|
|
832
|
-
};
|
|
833
|
-
};
|
|
834
|
-
};
|
|
835
|
-
declare function settingsWithSessionMcpServerMetadata(settings: Settings, servers: SessionMcpServerMetadata[]): Settings;
|
|
836
|
-
declare function createAndStartSession(input: {
|
|
837
|
-
requestedSessionId?: string;
|
|
838
|
-
db: Database;
|
|
839
|
-
bus: EventBus;
|
|
840
|
-
workflowClient: SessionWorkflowClient;
|
|
841
|
-
accountId: string;
|
|
842
|
-
workspaceId: string;
|
|
843
|
-
initialMessage: string;
|
|
844
|
-
turnInstructions?: string | null;
|
|
845
|
-
resources: ResourceRef[];
|
|
846
|
-
skills?: SessionSkill[];
|
|
847
|
-
tools: ToolRef[];
|
|
848
|
-
toolPolicy: SessionToolPolicy;
|
|
849
|
-
clientEventId?: string;
|
|
850
|
-
model: string;
|
|
851
|
-
reasoningEffort: Settings["openaiReasoningEffort"];
|
|
852
|
-
turnExecutionPolicy: TurnExecutionPolicyV1;
|
|
853
|
-
sandboxBackend: Settings["sandboxBackend"];
|
|
854
|
-
metadata: Record<string, unknown>;
|
|
855
|
-
createdBy?: TurnInitiator;
|
|
856
|
-
createdByContext?: TurnInitiatorContext;
|
|
857
|
-
createdByActor?: Extract<SessionCommandActor, {
|
|
858
|
-
type: "agent_attempt";
|
|
859
|
-
}> | null;
|
|
860
|
-
variableSet?: {
|
|
861
|
-
id: string;
|
|
862
|
-
name: string;
|
|
863
|
-
} | null;
|
|
864
|
-
rigId?: string | null;
|
|
865
|
-
rigVersionId?: string | null;
|
|
866
|
-
goal?: GoalSpec | null;
|
|
867
|
-
instructions?: string | null;
|
|
868
|
-
firstPartyMcpPermissions?: Permission[] | null;
|
|
869
|
-
firstPartyMcpTools: FirstPartyMcpToolName[];
|
|
870
|
-
mcpServers?: CreateSessionMcpServerInput[];
|
|
871
|
-
sessionMcpServers?: SessionMcpServerMetadata[];
|
|
872
|
-
parentSessionId?: string | null;
|
|
873
|
-
createIdempotencyKey?: string | null;
|
|
874
|
-
sandboxGroupId?: string | null;
|
|
875
|
-
sandboxOs?: Session["sandboxOs"];
|
|
876
|
-
seedTargetSandbox?: {
|
|
877
|
-
sandboxId: string;
|
|
878
|
-
settings: Settings;
|
|
879
|
-
workingDir?: string | null;
|
|
880
|
-
} | null;
|
|
881
|
-
consumeNewSessionDraft?: {
|
|
882
|
-
subjectId: string;
|
|
883
|
-
expectedRevision: number;
|
|
884
|
-
} | null;
|
|
885
|
-
maxNestedAgentDepthOverride?: number | null;
|
|
886
|
-
allowNestedAgentDepthIncrease?: boolean;
|
|
887
|
-
subjectId?: string | null;
|
|
888
|
-
}): Promise<CreateSessionResponse>;
|
|
889
|
-
declare function workflowIdForSession(sessionId: string): string;
|
|
890
|
-
/**
|
|
891
|
-
* Reject an explicit model that the host does not expose. The set of usable
|
|
892
|
-
* models is the union surfaced by `configuredAllowedModels` (the built-in
|
|
893
|
-
* provider's allow-list plus every registry provider's ids); a `model` outside
|
|
894
|
-
* it cannot be resolved to a provider at run time, so we fail the request at
|
|
895
|
-
* the API edge with 422 rather than enqueuing a turn the worker can't honor.
|
|
896
|
-
*
|
|
897
|
-
* `model` is the explicit, caller-supplied value (null/undefined when omitted).
|
|
898
|
-
* An omitted model defaults to `settings.openaiModel` downstream — which is
|
|
899
|
-
* always first in `configuredAllowedModels` — so only an explicit value is
|
|
900
|
-
* checked. Centralized here so every model-carrying choke point
|
|
901
|
-
* (create-session, user-message/turn-accept, queued-turn update, and
|
|
902
|
-
* scheduled-task agentConfig — a scheduled task is a session the worker runs
|
|
903
|
-
* later) and the MCP surfaces that share them validate identically and cannot
|
|
904
|
-
* drift.
|
|
905
|
-
*/
|
|
906
|
-
declare function canonicalConfiguredModel(settings: Settings, model: string | null | undefined): string | null | undefined;
|
|
907
|
-
declare function assertConfiguredModel(settings: Settings, model: string | null | undefined): void;
|
|
908
|
-
/**
|
|
909
|
-
* Reject a model the WORKSPACE's model policy blocks, at the same choke points
|
|
910
|
-
* as assertConfiguredModel — a 422 at the edge instead of a queued turn the
|
|
911
|
-
* worker's authoritative post-resolution gate would fail. `model` is the
|
|
912
|
-
* EFFECTIVE value the caller is about to persist: pass the explicit value at
|
|
913
|
-
* message/turn-update/scheduled-task edges (omitted inherits an
|
|
914
|
-
* already-validated stored default), but at session CREATION pass
|
|
915
|
-
* `payload.model ?? settings.openaiModel` — an omitted model stamps the
|
|
916
|
-
* deployment default onto the session, and under a restricted policy that
|
|
917
|
-
* default may be exactly the provider the policy exists to block.
|
|
918
|
-
*/
|
|
919
|
-
declare function assertWorkspaceModelPolicyAllows(db: Database, settings: Settings, workspaceId: string, model: string | null | undefined): Promise<void>;
|
|
920
|
-
declare function requireQueuedTurnForApi(db: Database, workspaceId: string, sessionId: string, turnId: string): Promise<SessionTurn>;
|
|
921
|
-
declare function reasoningEffortForSession(metadata: Record<string, unknown>, fallback: Settings["openaiReasoningEffort"]): Settings["openaiReasoningEffort"];
|
|
922
|
-
/**
|
|
923
|
-
* Appends a `user.message` to an existing session and enqueues the resulting
|
|
924
|
-
* turn, merging requested resources/tools into the session and waking the
|
|
925
|
-
* workflow. Shared by the public events route and the first-party MCP
|
|
926
|
-
* `session_send_message` tool so the two surfaces cannot drift. Callers own
|
|
927
|
-
* resource/tool validation and the per-message usage limit before calling.
|
|
928
|
-
*/
|
|
929
|
-
declare function postUserMessageTurn(input: {
|
|
930
|
-
db: Database;
|
|
931
|
-
bus: EventBus;
|
|
932
|
-
workflowClient: Pick<SessionWorkflowClient, "wakeSessionWorkflow">;
|
|
933
|
-
settings: Settings;
|
|
934
|
-
accountId: string;
|
|
935
|
-
workspaceId: string;
|
|
936
|
-
sessionId: string;
|
|
937
|
-
text: string;
|
|
938
|
-
turnInstructions?: string | null;
|
|
939
|
-
resources: ResourceRef[];
|
|
940
|
-
model?: string | null;
|
|
941
|
-
reasoningEffort?: Settings["openaiReasoningEffort"] | null;
|
|
942
|
-
clientEventId?: string;
|
|
943
|
-
mcpCredentialUpdates?: UpdateSessionMcpServerCredentialsInput[];
|
|
944
|
-
delivery?: "send" | "steer";
|
|
945
|
-
origin?: "human" | "operator";
|
|
946
|
-
actor?: string;
|
|
947
|
-
actorLabel?: string;
|
|
948
|
-
commandActor?: SessionCommandActor;
|
|
949
|
-
controlEtag?: string | null;
|
|
950
|
-
expectedDraftRevision?: number | null;
|
|
951
|
-
reasoningEffortFallback?: Settings["openaiReasoningEffort"];
|
|
952
|
-
turnExecutionPolicy: TurnExecutionPolicyV1;
|
|
953
|
-
}): Promise<{
|
|
954
|
-
accepted: SessionEvent;
|
|
955
|
-
turn: SessionTurn;
|
|
956
|
-
}>;
|
|
957
|
-
/**
|
|
958
|
-
* Full create-session flow shared by `POST /sessions` and the first-party MCP
|
|
959
|
-
* `session_create` tool: payload validation, resource/tool/variableSet
|
|
960
|
-
* checks, usage limits, session start, and usage recording. `rawPayload` is
|
|
961
|
-
* the unparsed request body so absent-vs-empty execution-context fields keep
|
|
962
|
-
* their meaning: a child inherits omitted resources/tools/mcpServers from its
|
|
963
|
-
* trusted immediate parent, while explicit arrays (including []) win. A
|
|
964
|
-
* top-level create with omitted tools applies workspace-default capability MCPs.
|
|
965
|
-
*/
|
|
966
|
-
declare function createSessionForRequest(deps: ApiRouteDeps, grant: AccessGrant, workspaceId: string, rawPayload: unknown): Promise<Session>;
|
|
967
|
-
/**
|
|
968
|
-
* Full accept-user-message flow shared by the `user.message` branch of
|
|
969
|
-
* `POST /sessions/:id/events` and the first-party MCP `session_send_message`
|
|
970
|
-
* tool: resource/tool validation, usage limits, the locked append + turn
|
|
971
|
-
* enqueue, and usage recording. `toolsProvided: false` durably preserves an
|
|
972
|
-
* Tool selection is durable session state and never rides a follow-up prompt.
|
|
973
|
-
*/
|
|
974
|
-
declare function acceptSessionUserMessage(deps: AcceptSessionUserMessageDependencies, grant: AccessGrant, workspaceId: string, sessionId: string, input: {
|
|
975
|
-
text: string;
|
|
976
|
-
turnInstructions?: string | null;
|
|
977
|
-
resources?: ResourceRef[];
|
|
978
|
-
model?: string | null;
|
|
979
|
-
reasoningEffort?: ReasoningEffort | null;
|
|
980
|
-
clientEventId?: string;
|
|
981
|
-
mcpCredentialUpdates?: SessionMcpCredentialUpdateInput[];
|
|
982
|
-
delivery?: "send" | "steer";
|
|
983
|
-
origin?: "human" | "operator";
|
|
984
|
-
controlEtag?: string | null;
|
|
985
|
-
expectedDraftRevision?: number | null;
|
|
986
|
-
}): Promise<{
|
|
987
|
-
accepted: SessionEvent;
|
|
988
|
-
turn: SessionTurn;
|
|
989
|
-
}>;
|
|
990
|
-
/**
|
|
991
|
-
* Shared title-write path for the manual rename route AND both MCP tools
|
|
992
|
-
* (set_session_title / set_other_session_title). The clobber guard lives in
|
|
993
|
-
* the db `updateSessionTitle` UPDATE: an agent write is skipped when a user
|
|
994
|
-
* title already pinned the session. On a real write we emit `session.title_set`
|
|
995
|
-
* exactly like goal mutations emit their events; when nothing changed (agent
|
|
996
|
-
* write blocked by the user lock) we emit nothing. Returns whether a write
|
|
997
|
-
* happened so callers can avoid double work.
|
|
998
|
-
*/
|
|
999
|
-
declare function updateSessionTitle(deps: {
|
|
1000
|
-
db: Database;
|
|
1001
|
-
bus: EventBus;
|
|
1002
|
-
sessionAuthorization?: SessionAuthorizationPort | null;
|
|
1003
|
-
}, grant: AccessGrant, sessionId: string, title: string, source: "user" | "agent"): Promise<{
|
|
1004
|
-
updated: boolean;
|
|
1005
|
-
title: string | null;
|
|
1006
|
-
relatedSessionAccess: "target" | "root";
|
|
1007
|
-
}>;
|
|
1008
|
-
/**
|
|
1009
|
-
* Update one existing session MCP server's approval policy. The database
|
|
1010
|
-
* serializes this write with attempt claim under the session lock: an already
|
|
1011
|
-
* claimed attempt retains its immutable snapshot, while the next claim captures
|
|
1012
|
-
* this value. No attempt is cancelled, restarted, or reinterpreted.
|
|
1013
|
-
*/
|
|
1014
|
-
declare function updateSessionMcpApprovalPolicy(deps: {
|
|
1015
|
-
db: Database;
|
|
1016
|
-
bus: EventBus;
|
|
1017
|
-
sessionAuthorization?: SessionAuthorizationPort | null;
|
|
1018
|
-
}, grant: AccessGrant, sessionId: string, serverId: string, requireApproval: SessionMcpApprovalPolicy): Promise<UpdateSessionMcpApprovalPolicyResponse>;
|
|
1019
|
-
/**
|
|
1020
|
-
* Replace the durable session tool policy. The target and its parent (when
|
|
1021
|
-
* present) are locked by the DB event-writer helper, and the update/event are
|
|
1022
|
-
* committed under one version-fenced transaction. An already claimed turn
|
|
1023
|
-
* keeps its immutable snapshot; the next attempt observes this policy.
|
|
1024
|
-
*/
|
|
1025
|
-
declare function updateSessionToolPolicy(deps: {
|
|
1026
|
-
db: Database;
|
|
1027
|
-
bus: EventBus;
|
|
1028
|
-
settings: Settings;
|
|
1029
|
-
sessionAuthorization?: SessionAuthorizationPort | null;
|
|
1030
|
-
}, grant: AccessGrant, sessionId: string, request: UpdateSessionToolPolicyRequest): Promise<Session>;
|
|
1031
|
-
declare function readSessionLineage(deps: Pick<ApiRouteDeps, "db" | "sessionAuthorization">, grant: AccessGrant, sessionId: string): Promise<_opengeni_db.SessionLineage>;
|
|
1032
|
-
|
|
1033
|
-
declare function openGeniSlackBotMetadata(metadata: Record<string, unknown>): OpenGeniSlackBotConnectionMetadata | null;
|
|
1034
|
-
declare function isOpenGeniSlackBotConnection(connection: ConnectionMetadata & Partial<Pick<ConnectionMetadataWithVerification, "verifiedInstallAt" | "verifiedInstallVersion">>): boolean;
|
|
1035
|
-
declare function hasReservedOpenGeniSlackBotMetadata(metadata: Record<string, unknown> | null | undefined): boolean;
|
|
1036
|
-
declare function hasReservedOpenGeniSlackBotSessionMetadata(metadata: Record<string, unknown> | null | undefined): boolean;
|
|
1037
|
-
/**
|
|
1038
|
-
* Internal, pre-authorized lookup used by the scheduler and Slack tool adapter.
|
|
1039
|
-
* Public callers must perform their permission check before calling this helper.
|
|
1040
|
-
*/
|
|
1041
|
-
declare function requireOpenGeniSlackBotConnection(db: Database, workspaceId: string, connectionId: string): Promise<ConnectionMetadata>;
|
|
1042
|
-
declare function validateOpenGeniSlackBotConnectionSelection(db: Database, grant: AccessGrant, workspaceId: string, connectionId: string): Promise<ConnectionMetadata>;
|
|
1043
|
-
declare function scheduledSlackBotConnectionId(metadata: Record<string, unknown> | null | undefined): string | null;
|
|
1044
|
-
/**
|
|
1045
|
-
* The scheduler writes the connection pointer together with immutable creator
|
|
1046
|
-
* provenance. Requiring both prevents ordinary session metadata from becoming
|
|
1047
|
-
* an authorization mechanism for a workspace-shared bot credential.
|
|
1048
|
-
*/
|
|
1049
|
-
declare function isTrustedScheduledSlackBotSession(session: Pick<Session, "createdBy" | "createdByContext" | "metadata">): boolean;
|
|
1050
|
-
|
|
1051
|
-
/** A member can manage other members (directly or via the admin wildcard). */
|
|
1052
|
-
declare function memberCanAdminister(member: Pick<WorkspaceMember, "permissions">): boolean;
|
|
1053
|
-
/** Only `user:` subjects are people; `api_key:` subjects belong to API keys. */
|
|
1054
|
-
declare function isUserMember(member: Pick<WorkspaceMember, "subjectId">): boolean;
|
|
1055
|
-
/**
|
|
1056
|
-
* Turn an email lookup result into the membership subject id. A null id means
|
|
1057
|
-
* no registered user matched the email — email invites for not-yet-registered
|
|
1058
|
-
* users are deferred, so that is a 404 (not a 400) at the API surface.
|
|
1059
|
-
*/
|
|
1060
|
-
declare function resolveMemberSubjectId(userId: string | null): string;
|
|
1061
|
-
/**
|
|
1062
|
-
* Guard the member-remove path. Refuses (409) to remove the caller's own
|
|
1063
|
-
* membership and refuses to remove the last member that still holds an admin
|
|
1064
|
-
* permission, so a workspace can never be orphaned with no one able to manage
|
|
1065
|
-
* it. `members` is the full roster (every subject, including api_key ones —
|
|
1066
|
-
* an api_key with workspace:admin still counts as an administering subject).
|
|
1067
|
-
*/
|
|
1068
|
-
declare function assertWorkspaceMemberRemovable(input: {
|
|
1069
|
-
members: WorkspaceMember[];
|
|
1070
|
-
subjectId: string;
|
|
1071
|
-
callerSubjectId: string;
|
|
1072
|
-
}): void;
|
|
1073
|
-
/**
|
|
1074
|
-
* Guard the workspace-delete path before any external/DB mutation. Refuses
|
|
1075
|
-
* (409) to delete the account's last workspace, and refuses while any session
|
|
1076
|
-
* could still be running in Temporal (there is no clean per-session terminate
|
|
1077
|
-
* to call first, so we will not orphan a workflow — the operator must stop the
|
|
1078
|
-
* sessions first).
|
|
1079
|
-
*/
|
|
1080
|
-
declare function assertWorkspaceDeletable(input: {
|
|
1081
|
-
workspaceCountForAccount: number;
|
|
1082
|
-
activeSessionCount: number;
|
|
1083
|
-
}): void;
|
|
1084
|
-
|
|
1085
|
-
type NewSessionDraftDependencies = Pick<AppDependencies, "settings" | "db" | "objectStorage">;
|
|
1086
|
-
/** Read the authenticated actor's server-authoritative pre-session composer state. */
|
|
1087
|
-
declare function getActorNewSessionDraft(deps: Pick<NewSessionDraftDependencies, "settings" | "db">, grant: AccessGrant, workspaceId: string): Promise<NewSessionDraft>;
|
|
1088
|
-
/**
|
|
1089
|
-
* Validate and save one exact actor-private draft revision. Create-time-only
|
|
1090
|
-
* checks (live machine target, rig/variable-set state, and permission
|
|
1091
|
-
* delegation) intentionally remain in createSessionForRequest: a recoverable
|
|
1092
|
-
* draft may represent incomplete options, while no invalid option can become a
|
|
1093
|
-
* session without passing that single canonical create boundary.
|
|
1094
|
-
*/
|
|
1095
|
-
declare function saveActorNewSessionDraft(deps: NewSessionDraftDependencies, grant: AccessGrant, workspaceId: string, rawInput: unknown): Promise<NewSessionDraft>;
|
|
1096
|
-
|
|
1097
|
-
type HumanSessionCommandContext = {
|
|
1098
|
-
accountId: string;
|
|
1099
|
-
workspaceId: string;
|
|
1100
|
-
sessionId: string;
|
|
1101
|
-
subjectId: string;
|
|
1102
|
-
/** See AgentSessionCommandContext.authorizationSurface. */
|
|
1103
|
-
authorizationSurface?: SessionAuthorizationSurface;
|
|
1104
|
-
};
|
|
1105
|
-
type AgentSessionCommandContext = {
|
|
1106
|
-
accountId: string;
|
|
1107
|
-
workspaceId: string;
|
|
1108
|
-
subjectId: string;
|
|
1109
|
-
callerSessionId: string;
|
|
1110
|
-
callerTurnId: string;
|
|
1111
|
-
callerAttemptId: string;
|
|
1112
|
-
callerExecutionGeneration: number;
|
|
1113
|
-
/**
|
|
1114
|
-
* The trusted adapter surface that owns this command's one authorization
|
|
1115
|
-
* decision. Direct core callers omit it and retain the canonical `core`
|
|
1116
|
-
* surface; adapters that delegate the complete command set it explicitly so
|
|
1117
|
-
* they do not authorize once at the edge and then repeat the host call here.
|
|
1118
|
-
*/
|
|
1119
|
-
authorizationSurface?: SessionAuthorizationSurface;
|
|
1120
|
-
};
|
|
1121
|
-
type SessionAuthorizationCommandDeps = {
|
|
1122
|
-
db: Database;
|
|
1123
|
-
sessionAuthorization?: SessionAuthorizationPort | null;
|
|
1124
|
-
};
|
|
1125
|
-
declare function sendAgentSessionMessage(deps: {
|
|
1126
|
-
db: Database;
|
|
1127
|
-
bus: EventBus;
|
|
1128
|
-
workflowClient: Pick<SessionWorkflowClient, "wakeSessionWorkflow">;
|
|
1129
|
-
sessionAuthorization?: SessionAuthorizationPort | null;
|
|
1130
|
-
}, context: AgentSessionCommandContext, input: {
|
|
1131
|
-
targetSessionId: string;
|
|
1132
|
-
text: string;
|
|
1133
|
-
idempotencyKey: string;
|
|
1134
|
-
}): Promise<_opengeni_db.AgentInternalUpdateCommandResult>;
|
|
1135
|
-
declare function steerAgentSession(deps: {
|
|
1136
|
-
db: Database;
|
|
1137
|
-
bus: EventBus;
|
|
1138
|
-
workflowClient: Pick<SessionWorkflowClient, "wakeSessionWorkflow">;
|
|
1139
|
-
sessionAuthorization?: SessionAuthorizationPort | null;
|
|
1140
|
-
}, context: AgentSessionCommandContext, input: {
|
|
1141
|
-
targetSessionId: string;
|
|
1142
|
-
instruction: string;
|
|
1143
|
-
idempotencyKey: string;
|
|
1144
|
-
}): Promise<_opengeni_db.AgentInternalUpdateCommandResult>;
|
|
1145
|
-
declare function controlAgentSessionWorkstream(deps: {
|
|
1146
|
-
db: Database;
|
|
1147
|
-
bus: EventBus;
|
|
1148
|
-
workflowClient: Pick<SessionWorkflowClient, "requestSessionWorkflowWakeDispatch">;
|
|
1149
|
-
sessionAuthorization?: SessionAuthorizationPort | null;
|
|
1150
|
-
}, context: AgentSessionCommandContext, input: {
|
|
1151
|
-
targetSessionId: string;
|
|
1152
|
-
action: "pause" | "resume";
|
|
1153
|
-
idempotencyKey: string;
|
|
1154
|
-
reason?: string | null;
|
|
1155
|
-
}): Promise<{
|
|
1156
|
-
authorization: ResolvedSessionAuthorization | null;
|
|
1157
|
-
receipt: SessionCommandReceiptRow;
|
|
1158
|
-
control: _opengeni_db.EffectiveSessionControl;
|
|
1159
|
-
sessionControlEventId: string;
|
|
1160
|
-
workspaceControlEventId: string;
|
|
1161
|
-
interruptionCount: number;
|
|
1162
|
-
wakeCount: number;
|
|
1163
|
-
replay: boolean;
|
|
1164
|
-
}>;
|
|
1165
|
-
declare function moveHumanQueuePrompt(deps: {
|
|
1166
|
-
db: Database;
|
|
1167
|
-
bus: EventBus;
|
|
1168
|
-
sessionAuthorization?: SessionAuthorizationPort | null;
|
|
1169
|
-
}, context: HumanSessionCommandContext, turnId: string, input: MoveSessionQueueItemRequest): Promise<SessionQueueMutationResponse>;
|
|
1170
|
-
declare function deleteHumanQueuePrompt(deps: {
|
|
1171
|
-
db: Database;
|
|
1172
|
-
bus: EventBus;
|
|
1173
|
-
sessionAuthorization?: SessionAuthorizationPort | null;
|
|
1174
|
-
}, context: HumanSessionCommandContext, turnId: string, input: DeleteSessionQueueItemRequest): Promise<SessionQueueMutationResponse>;
|
|
1175
|
-
declare function editHumanQueuePrompt(deps: {
|
|
1176
|
-
db: Database;
|
|
1177
|
-
bus: EventBus;
|
|
1178
|
-
sessionAuthorization?: SessionAuthorizationPort | null;
|
|
1179
|
-
}, context: HumanSessionCommandContext, turnId: string, input: EditSessionQueueItemRequest): Promise<SessionQueueMutationResponse>;
|
|
1180
|
-
declare function steerHumanQueuePrompt(deps: {
|
|
1181
|
-
db: Database;
|
|
1182
|
-
bus: EventBus;
|
|
1183
|
-
sessionAuthorization?: SessionAuthorizationPort | null;
|
|
1184
|
-
}, context: HumanSessionCommandContext, turnId: string, input: SteerSessionQueueItemRequest): Promise<SessionQueueMutationResponse>;
|
|
1185
|
-
declare function controlHumanSessionWorkstream(deps: {
|
|
1186
|
-
db: Database;
|
|
1187
|
-
bus: EventBus;
|
|
1188
|
-
workflowClient: Pick<SessionWorkflowClient, "requestSessionWorkflowWakeDispatch">;
|
|
1189
|
-
sessionAuthorization?: SessionAuthorizationPort | null;
|
|
1190
|
-
}, context: HumanSessionCommandContext, input: SessionControlRequest): Promise<SessionControlResponse>;
|
|
1191
|
-
declare function controlHumanWorkspace(deps: {
|
|
1192
|
-
db: Database;
|
|
1193
|
-
bus: EventBus;
|
|
1194
|
-
workflowClient: Pick<SessionWorkflowClient, "requestSessionWorkflowWakeDispatch">;
|
|
1195
|
-
}, context: Omit<HumanSessionCommandContext, "sessionId">, input: WorkspaceInferenceControlRequest): Promise<WorkspaceInferenceControlResponse>;
|
|
1196
|
-
declare function getHumanComposerDraft(deps: SessionAuthorizationCommandDeps, context: HumanSessionCommandContext): Promise<ComposerDraft>;
|
|
1197
|
-
declare function saveHumanComposerDraft(deps: SessionAuthorizationCommandDeps, context: HumanSessionCommandContext, input: SaveComposerDraftRequest): Promise<ComposerDraft>;
|
|
1198
|
-
|
|
1199
|
-
export { type AcceptSessionUserMessageDependencies, type AccessDeps, type AgentSessionCommandContext, type ApiRouteDeps, type ApiSandboxClient, type ApiSandboxSession, type AppDependencies, type ChannelARoutingServices, type DocumentIndexClient, type FleetContext, type FleetListResult, type FleetLiveness, type FleetReadinessHold, type FleetSandboxEntry, type FleetServices, type FleetSwapResult, type HumanSessionCommandContext, type LimitCheckInput, type LimitDependencies, MARKETING_SOCIAL_PACK_ID, MAX_CHECKS_PER_RIG, MAX_CREDENTIAL_HOOKS_PER_RIG, MAX_DEFAULT_VARIABLE_SETS_PER_RIG, MAX_ENVIRONMENTS_PER_WORKSPACE, MAX_RIGS_PER_WORKSPACE, MAX_VARIABLES_PER_ENVIRONMENT, type ManagedAuth, type McpCapabilityProbe, type McpCapabilityProbeInput, type McpCapabilityProbeResult, type ObjectStorageDependency, type ProvisionResult, type ResolvedSessionAuthorization, type ResolvedSessionToolPolicy, type ResumeBoxByIdInput, type ResumedSandboxSession, type RigServices, type RigVerificationClassification, type RunOnOp, type RunOnResult, SESSION_AUTHORIZATION_DEFAULT_REAUTHORIZE_MS, SESSION_WORKFLOW_WAKE_DISPATCHER_PERIOD_MS, SESSION_WORKFLOW_WAKE_DISPATCHER_SCHEDULE_ID, SESSION_WORKFLOW_WAKE_DISPATCHER_WORKFLOW_TYPE, SessionAuthorizationDeniedError, type SessionAuthorizationDependencies, SessionAuthorizationUnavailableError, SessionSpawnDeniedError, type SessionToolPolicyInput, type SessionWorkflowClient, acceptSessionUserMessage, activateRigVersionForApi, appendRigSetupCommand, applyCapabilityEnablement, assertAllowedEnvironmentVariableName, assertAllowedVariableSetVariableName, assertConfiguredModel, assertPackSandboxImageCompatible, assertToolRefsSubset, assertWorkspaceDeletable, assertWorkspaceMemberRemovable, assertWorkspaceModelPolicyAllows, availableToolRefs, buildCapabilityCatalog, buildFleetContextForSession, buildMarketingDailyAnalysisAgentConfig, canonicalConfiguredModel, checkLimit, classifyRigVerificationOutcome, controlAgentSessionWorkstream, controlHumanSessionWorkstream, controlHumanWorkspace, createAndStartSession, createCatalogItem, createRigForApi, createRigVersionForApi, createSessionForRequest, createValidatedScheduledTask, deleteHumanQueuePrompt, deleteRigForApi, disableCapability, discoverMcpRegistryCapabilities, editHumanQueuePrompt, enableCapability, enabledCapabilityMcpToolRefs, getActorNewSessionDraft, getCapabilityPack, getHumanComposerDraft, hasPermission, hasReservedOpenGeniSlackBotMetadata, hasReservedOpenGeniSlackBotSessionMetadata, isAuthoritativeGitHubRepositorySelectionError, isBuiltInCapabilityPack, isOpenGeniSlackBotConnection, isTrustedScheduledSlackBotSession, isUserMember, listCapabilityPacks, listFleet, listRigChangesForApi, listRigVersionsForApi, listWorkspaceCapabilityPacks, manualScheduledTaskTriggerUsageKey, manualScheduledTaskTriggerWorkflowId, memberCanAdminister, mergeResourceRefs, moveHumanQueuePrompt, normalizeResources, officialMcpRegistryUrl, openGeniSlackBotMetadata, postUserMessageTurn, promoteSetupAppendChange, promoteVerifiedDefinitionEditChangeForApi, proposeRigChangeForApi, provisionSandbox, readSessionLineage, reasoningEffortForSession, recordRigAuditEvent, recordVariableSetAuditEvent, recordWorkspaceUsage, relayConfigFromSettings, relayDialBaseFromSettings, requireAccessContext, requireAccessGrant, requireEnvironmentEncryption, requireLimit, requireOpenGeniSlackBotConnection, requirePermission, requireQueuedTurnForApi, requireRigChangeForApi, requireRigForApi, requireScheduledTaskForApi, requireSessionAuthorization, requireSessionAuthorizationListScope, requireVariableSetEncryption, requireVariableSetForApi, resolveCapabilityPack, resolveFirstPartyMcpToolsForCreate, resolveMemberSubjectId, resolveSessionToolPolicy, restoreScheduledTask, rigActorForGrant, routingEnabled, runOnSandbox, saveActorNewSessionDraft, saveHumanComposerDraft, scheduledSlackBotConnectionId, scheduledTaskTemporalScheduleId, scheduledTaskToolsProvided, scheduledTaskTriggerToken, sendAgentSessionMessage, sessionSpawnDenialEnvelope, sessionToolPolicyAllowsDefaultNativeTools, sessionWithEffectiveToolPolicy, settingsWithCodexAppsMcpServer, settingsWithEnabledCapabilityMcpServers, settingsWithMcpCapabilityServers, settingsWithSessionMcpServerMetadata, steerAgentSession, steerHumanQueuePrompt, swapActiveSandbox, syncCreatedScheduledTask, syncUpdatedScheduledTask, updateRigForApi, updateSessionMcpApprovalPolicy, updateSessionTitle, updateSessionToolPolicy, validateFileResources, validateGitHubRepositorySelection, validateGitHubRepositorySelectionShape, validateGitHubRepositorySelectionShapes, validateMcpCapabilityConnection, validateOpenGeniSlackBotConnectionSelection, validateToolRefs, validateToolRefsForSessionPolicy, validateVariableSetAttachment, validatedScheduledTaskUpdate, withDefaultEnabledCapabilityMcpTools, workflowIdForSession, workspaceSessionToolPolicyDefaultServerIds, workspaceSessionToolPolicyServerIds, wrapChannelABoxWithRouting };
|
|
1
|
+
export * from "./dependencies";
|
|
2
|
+
export * from "./workflow-wake-contract";
|
|
3
|
+
export * from "./sandbox-types";
|
|
4
|
+
export * from "./managed-auth-type";
|
|
5
|
+
export * from "./transcription";
|
|
6
|
+
export * from "./sandbox/fleet";
|
|
7
|
+
export * from "./sandbox/routing";
|
|
8
|
+
export * from "./access";
|
|
9
|
+
export * from "./session-authorization";
|
|
10
|
+
export * from "./billing/limits";
|
|
11
|
+
export * from "./domain/capabilities";
|
|
12
|
+
export * from "./domain/environments";
|
|
13
|
+
export * from "./rigs";
|
|
14
|
+
export * from "./domain/packs";
|
|
15
|
+
export * from "./domain/resources";
|
|
16
|
+
export * from "./domain/session-tool-policy";
|
|
17
|
+
export * from "./domain/scheduled-tasks";
|
|
18
|
+
export * from "./domain/sessions";
|
|
19
|
+
export * from "./domain/insights";
|
|
20
|
+
export * from "./domain/slack-bot";
|
|
21
|
+
export * from "./domain/workspace-members";
|
|
22
|
+
export * from "./application/new-session-drafts";
|
|
23
|
+
export * from "./application/session-commands";
|