@opengeni/core 0.4.6 → 0.4.8
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/index.d.ts +293 -32
- package/dist/index.js +1750 -472
- package/dist/index.js.map +1 -1
- package/package.json +17 -17
- package/src/access/index.ts +136 -57
- package/src/application/session-commands.ts +527 -0
- package/src/billing/limits.ts +76 -34
- package/src/dependencies.ts +67 -14
- package/src/domain/capabilities.ts +380 -181
- package/src/domain/environments.ts +58 -38
- package/src/domain/packs.ts +49 -16
- package/src/domain/resources.ts +71 -28
- package/src/domain/scheduled-tasks.ts +107 -41
- package/src/domain/sessions.ts +531 -255
- package/src/domain/workspace-members.ts +6 -2
- package/src/index.ts +3 -0
- package/src/rigs/index.ts +540 -0
- package/src/sandbox/fleet.ts +97 -18
- package/src/sandbox/routing.ts +6 -1
- package/src/sandbox-types.ts +17 -5
- package/src/workflow-wake-contract.ts +6 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Settings } from '@opengeni/config';
|
|
2
|
-
import { ScheduledTask, Document, Permission, AccessContext, AccessGrant, LimitAction, LimitDecision, CapabilityCatalogItem, CapabilityInstallation, CapabilityCatalogResponse, CreateCapabilityCatalogItemRequest, EnableCapabilityRequest,
|
|
2
|
+
import { ScheduledTask, Document, Permission, AccessContext, AccessGrant, LimitAction, LimitDecision, CapabilityCatalogItem, CapabilityInstallation, CapabilityCatalogResponse, CreateCapabilityCatalogItemRequest, EnableCapabilityRequest, VariableSet, Rig, RigVersion, CreateRigRequest, RigDefinitionEditPayload, RigChange, ProposeRigChangeRequest, UpdateRigRequest, CapabilityPack, SocialConnection, ScheduledTaskAgentConfig, ToolRef, ResourceRef, CreateScheduledTaskRequest, UpdateScheduledTaskRequest, ReasoningEffort, SessionMcpCredentialUpdateInput, SessionEvent, SessionTurn, GoalSpec, SessionMcpServerMetadata, Session, WorkspaceMember, SessionControlRequest, SessionControlResponse, WorkspaceInferenceControlRequest, WorkspaceInferenceControlResponse, DeleteSessionQueueItemRequest, SessionQueueMutationResponse, EditSessionQueueItemRequest, ComposerDraft, MoveSessionQueueItemRequest, SaveComposerDraftRequest, SteerSessionQueueItemRequest } from '@opengeni/contracts';
|
|
3
3
|
export { mergeToolRefs, stableJson } from '@opengeni/contracts';
|
|
4
|
+
import * as _opengeni_db from '@opengeni/db';
|
|
4
5
|
import { Database, SandboxRecord, EnabledMcpCapabilityServer, UpdateScheduledTaskInput, CreateSessionMcpServerInput, UpdateSessionMcpServerCredentialsInput } from '@opengeni/db';
|
|
5
6
|
import { DocumentServices } from '@opengeni/documents';
|
|
6
7
|
import { EventBus } from '@opengeni/events';
|
|
7
8
|
import { Observability } from '@opengeni/observability';
|
|
8
9
|
import { createObjectStorage } from '@opengeni/storage';
|
|
9
10
|
import { Auth } from 'better-auth';
|
|
10
|
-
import { SelfhostedRelayConfig, EstablishedSandboxSession } from '@opengeni/runtime/sandbox';
|
|
11
|
+
import { BackendUnresolvableCode, SelfhostedRelayConfig, EstablishedSandboxSession } from '@opengeni/runtime/sandbox';
|
|
11
12
|
import { Context } from 'hono';
|
|
12
13
|
|
|
13
14
|
type ManagedAuth = Auth<any>;
|
|
@@ -37,9 +38,9 @@ type ApiSandboxSession = {
|
|
|
37
38
|
};
|
|
38
39
|
type ApiSandboxClient = {
|
|
39
40
|
backendId: string;
|
|
40
|
-
deserializeSessionState?(state: Record<string, unknown>): Promise<unknown
|
|
41
|
-
resume?(state:
|
|
42
|
-
delete?(state: unknown): Promise<void>;
|
|
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>;
|
|
43
44
|
};
|
|
44
45
|
type ResumeBoxByIdInput = {
|
|
45
46
|
/**
|
|
@@ -76,18 +77,26 @@ type SessionWorkflowClient = {
|
|
|
76
77
|
workspaceId: string;
|
|
77
78
|
sessionId: string;
|
|
78
79
|
workflowId: string;
|
|
80
|
+
wakeRevision: number;
|
|
81
|
+
interruptionRequested?: boolean;
|
|
79
82
|
}) => Promise<void>;
|
|
80
|
-
|
|
83
|
+
/** Trigger one bounded drain of already-committed workflow-wake revisions. */
|
|
84
|
+
requestSessionWorkflowWakeDispatch: () => Promise<void>;
|
|
85
|
+
signalCodexCapacity?: (input: {
|
|
86
|
+
accountId: string;
|
|
87
|
+
workspaceId: string;
|
|
81
88
|
sessionId: string;
|
|
82
|
-
eventId: string;
|
|
83
89
|
workflowId: string;
|
|
90
|
+
wakeRevision: number;
|
|
91
|
+
workflowWakeRevision: number;
|
|
84
92
|
}) => Promise<void>;
|
|
85
|
-
|
|
93
|
+
signalApprovalDecision: (input: {
|
|
86
94
|
accountId: string;
|
|
87
95
|
workspaceId: string;
|
|
88
96
|
sessionId: string;
|
|
89
97
|
eventId: string;
|
|
90
98
|
workflowId: string;
|
|
99
|
+
workflowWakeRevision: number;
|
|
91
100
|
}) => Promise<void>;
|
|
92
101
|
syncScheduledTask: (input: {
|
|
93
102
|
task: ScheduledTask;
|
|
@@ -100,6 +109,12 @@ type SessionWorkflowClient = {
|
|
|
100
109
|
agentRunUsageIdempotencyKey?: string;
|
|
101
110
|
triggerWorkflowId?: string;
|
|
102
111
|
}) => Promise<void>;
|
|
112
|
+
startRigVerification: (input: {
|
|
113
|
+
workspaceId: string;
|
|
114
|
+
changeId?: string;
|
|
115
|
+
versionId?: string;
|
|
116
|
+
workflowId?: string;
|
|
117
|
+
}) => Promise<void>;
|
|
103
118
|
check?: () => Promise<void>;
|
|
104
119
|
};
|
|
105
120
|
type DocumentIndexClient = {
|
|
@@ -114,6 +129,8 @@ type AppDependencies = {
|
|
|
114
129
|
db: Database;
|
|
115
130
|
bus: EventBus;
|
|
116
131
|
workflowClient: SessionWorkflowClient;
|
|
132
|
+
/** Optional provider override for deterministic API/object-storage tests. */
|
|
133
|
+
objectStorage?: ObjectStorageDependency;
|
|
117
134
|
documentIndexer?: DocumentIndexClient;
|
|
118
135
|
documentServices?: DocumentServices;
|
|
119
136
|
observability?: Observability;
|
|
@@ -138,6 +155,22 @@ type ApiRouteDeps = AppDependencies & {
|
|
|
138
155
|
getDocumentServices: () => DocumentServices;
|
|
139
156
|
resumeBoxById: (input: ResumeBoxByIdInput) => Promise<ResumedSandboxSession>;
|
|
140
157
|
};
|
|
158
|
+
/**
|
|
159
|
+
* The exact dependency slice used by `acceptSessionUserMessage`.
|
|
160
|
+
*
|
|
161
|
+
* Keeping this narrower than `ApiRouteDeps` lets control-plane callers reuse
|
|
162
|
+
* the canonical admission path without constructing unrelated HTTP, document,
|
|
163
|
+
* or sandbox services. The public API still passes its `ApiRouteDeps` superset.
|
|
164
|
+
*/
|
|
165
|
+
type AcceptSessionUserMessageDependencies = Pick<AppDependencies, "settings" | "db" | "bus"> & {
|
|
166
|
+
workflowClient: Pick<SessionWorkflowClient, "wakeSessionWorkflow">;
|
|
167
|
+
objectStorage: ObjectStorageDependency;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
/** One global Temporal Schedule owns bounded delivery of committed session wakes. */
|
|
171
|
+
declare const SESSION_WORKFLOW_WAKE_DISPATCHER_SCHEDULE_ID = "opengeni-session-workflow-wake-dispatcher";
|
|
172
|
+
declare const SESSION_WORKFLOW_WAKE_DISPATCHER_WORKFLOW_TYPE = "sessionWorkflowWakeDispatcherWorkflow";
|
|
173
|
+
declare const SESSION_WORKFLOW_WAKE_DISPATCHER_PERIOD_MS = 10000;
|
|
141
174
|
|
|
142
175
|
type FleetServices = {
|
|
143
176
|
db: Database;
|
|
@@ -206,12 +239,14 @@ type FleetListResult = {
|
|
|
206
239
|
activeEpoch: number;
|
|
207
240
|
sandboxes: FleetSandboxEntry[];
|
|
208
241
|
};
|
|
209
|
-
/** A swap/attach outcome the tool returns.
|
|
242
|
+
/** A swap/attach outcome the tool returns. On a rejection, `code` carries the
|
|
243
|
+
* typed reason (issue #341 typed diagnostics) alongside the human `reason`. */
|
|
210
244
|
type FleetSwapResult = {
|
|
211
245
|
swapped: boolean;
|
|
212
246
|
activeSandboxId: string | null;
|
|
213
247
|
activeEpoch: number;
|
|
214
248
|
reason?: string;
|
|
249
|
+
code?: BackendUnresolvableCode | "concurrent_swap";
|
|
215
250
|
};
|
|
216
251
|
/**
|
|
217
252
|
* List the fleet: the session's own Modal group box (a synthetic entry) + the
|
|
@@ -332,6 +367,7 @@ declare function requireAccessGrant(c: Context, deps: AccessDeps, workspaceId: s
|
|
|
332
367
|
declare function requirePermission(grant: AccessGrant, permission: Permission): void;
|
|
333
368
|
declare function hasPermission(permissions: Permission[], permission: Permission): boolean;
|
|
334
369
|
|
|
370
|
+
type LimitDependencies = Pick<ApiRouteDeps, "db" | "settings">;
|
|
335
371
|
type LimitCheckInput = {
|
|
336
372
|
accountId: string;
|
|
337
373
|
workspaceId?: string;
|
|
@@ -339,9 +375,9 @@ type LimitCheckInput = {
|
|
|
339
375
|
quantity?: number;
|
|
340
376
|
model?: string | null;
|
|
341
377
|
};
|
|
342
|
-
declare function requireLimit(deps:
|
|
343
|
-
declare function checkLimit(deps:
|
|
344
|
-
declare function recordWorkspaceUsage(deps:
|
|
378
|
+
declare function requireLimit(deps: LimitDependencies, input: LimitCheckInput): Promise<void>;
|
|
379
|
+
declare function checkLimit(deps: LimitDependencies, input: LimitCheckInput): Promise<LimitDecision>;
|
|
380
|
+
declare function recordWorkspaceUsage(deps: LimitDependencies, input: {
|
|
345
381
|
accountId: string;
|
|
346
382
|
workspaceId: string;
|
|
347
383
|
subjectId?: string | null;
|
|
@@ -408,31 +444,90 @@ declare function applyCapabilityEnablement(item: CapabilityCatalogItem, installa
|
|
|
408
444
|
|
|
409
445
|
declare const MAX_ENVIRONMENTS_PER_WORKSPACE = 25;
|
|
410
446
|
declare const MAX_VARIABLES_PER_ENVIRONMENT = 100;
|
|
411
|
-
declare function
|
|
412
|
-
|
|
413
|
-
declare
|
|
447
|
+
declare function assertAllowedVariableSetVariableName(name: string): void;
|
|
448
|
+
/** @deprecated use assertAllowedVariableSetVariableName */
|
|
449
|
+
declare const assertAllowedEnvironmentVariableName: typeof assertAllowedVariableSetVariableName;
|
|
450
|
+
declare function requireVariableSetEncryption(settings: Settings): Uint8Array;
|
|
451
|
+
/** @deprecated use requireVariableSetEncryption */
|
|
452
|
+
declare const requireEnvironmentEncryption: typeof requireVariableSetEncryption;
|
|
453
|
+
declare function requireVariableSetForApi(db: Database, workspaceId: string, variableSetId: string): Promise<VariableSet>;
|
|
414
454
|
/**
|
|
415
|
-
* Validates an
|
|
455
|
+
* Validates an variableSet attachment supplied in a request payload (session
|
|
416
456
|
* create, scheduled task create/update, pack enable). Requires the
|
|
417
|
-
* `
|
|
457
|
+
* `variable-sets:use` permission unless the attachment was already authorized
|
|
418
458
|
* (pack-installation-inherited attachments), and maps a missing or
|
|
419
|
-
* cross-
|
|
459
|
+
* cross-variable set to 422 because the id is payload, not the route
|
|
420
460
|
* target. RLS plus the workspace_id clause make cross-workspace ids
|
|
421
461
|
* indistinguishable from missing ones.
|
|
422
462
|
*/
|
|
423
|
-
declare function
|
|
463
|
+
declare function validateVariableSetAttachment(deps: {
|
|
424
464
|
settings: Settings;
|
|
425
465
|
db: Database;
|
|
426
|
-
}, grant: AccessGrant, workspaceId: string,
|
|
466
|
+
}, grant: AccessGrant, workspaceId: string, variableSetId: string, options?: {
|
|
427
467
|
preauthorized?: boolean;
|
|
428
|
-
}): Promise<
|
|
429
|
-
declare function
|
|
468
|
+
}): Promise<VariableSet>;
|
|
469
|
+
declare function recordVariableSetAuditEvent(db: Database, input: {
|
|
430
470
|
grant: AccessGrant;
|
|
431
|
-
action: "
|
|
432
|
-
|
|
471
|
+
action: "variable_set.created" | "variable_set.updated" | "variable_set.deleted" | "variable_set.variable.set" | "variable_set.variable.deleted";
|
|
472
|
+
variableSetId: string;
|
|
433
473
|
variableName?: string;
|
|
434
474
|
}): Promise<void>;
|
|
435
475
|
|
|
476
|
+
declare const MAX_RIGS_PER_WORKSPACE = 50;
|
|
477
|
+
declare const MAX_CHECKS_PER_RIG = 100;
|
|
478
|
+
declare const MAX_CREDENTIAL_HOOKS_PER_RIG = 50;
|
|
479
|
+
declare const MAX_DEFAULT_VARIABLE_SETS_PER_RIG = 25;
|
|
480
|
+
type RigServices = {
|
|
481
|
+
db: Database;
|
|
482
|
+
};
|
|
483
|
+
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";
|
|
484
|
+
declare function recordRigAuditEvent(db: Database, input: {
|
|
485
|
+
grant: AccessGrant;
|
|
486
|
+
action: RigAuditAction;
|
|
487
|
+
rigId: string;
|
|
488
|
+
metadata?: Record<string, unknown>;
|
|
489
|
+
}): Promise<void>;
|
|
490
|
+
declare function rigActorForGrant(grant: AccessGrant): string;
|
|
491
|
+
declare function requireRigForApi(db: Database, workspaceId: string, rigId: string): Promise<Rig>;
|
|
492
|
+
declare function requireRigChangeForApi(db: Database, workspaceId: string, rigId: string, changeId: string): Promise<RigChange>;
|
|
493
|
+
declare function createRigForApi(deps: RigServices, grant: AccessGrant, payload: CreateRigRequest): Promise<Rig>;
|
|
494
|
+
declare function updateRigForApi(deps: RigServices, grant: AccessGrant, rig: Rig, payload: UpdateRigRequest): Promise<Rig>;
|
|
495
|
+
declare function deleteRigForApi(deps: RigServices, grant: AccessGrant, rig: Rig): Promise<void>;
|
|
496
|
+
declare function proposeRigChangeForApi(deps: RigServices, grant: AccessGrant, rig: Rig, request: ProposeRigChangeRequest, options?: {
|
|
497
|
+
proposedBy?: string;
|
|
498
|
+
}): Promise<RigChange>;
|
|
499
|
+
type RigVerificationClassification = {
|
|
500
|
+
status: "merged";
|
|
501
|
+
action: "auto_promote";
|
|
502
|
+
} | {
|
|
503
|
+
status: "proposed";
|
|
504
|
+
action: "await_manage_promote";
|
|
505
|
+
} | {
|
|
506
|
+
status: "rejected";
|
|
507
|
+
action: "reject";
|
|
508
|
+
} | {
|
|
509
|
+
status: "failed";
|
|
510
|
+
action: "retryable_failure";
|
|
511
|
+
};
|
|
512
|
+
declare function classifyRigVerificationOutcome(input: {
|
|
513
|
+
kind: "setup_append" | "definition_edit";
|
|
514
|
+
passed: boolean;
|
|
515
|
+
infraError?: boolean;
|
|
516
|
+
}): RigVerificationClassification;
|
|
517
|
+
declare function appendRigSetupCommand(baseSetupScript: string | null | undefined, command: string): string;
|
|
518
|
+
declare function promoteSetupAppendChange(deps: RigServices, grant: AccessGrant, rig: Rig, change: RigChange): Promise<{
|
|
519
|
+
change: RigChange;
|
|
520
|
+
version: RigVersion;
|
|
521
|
+
}>;
|
|
522
|
+
declare function promoteVerifiedDefinitionEditChangeForApi(deps: RigServices, grant: AccessGrant, rig: Rig, change: RigChange): Promise<{
|
|
523
|
+
change: RigChange;
|
|
524
|
+
version: RigVersion;
|
|
525
|
+
}>;
|
|
526
|
+
declare function createRigVersionForApi(deps: RigServices, grant: AccessGrant, rig: Rig, payload: RigDefinitionEditPayload): Promise<RigVersion>;
|
|
527
|
+
declare function activateRigVersionForApi(deps: RigServices, grant: AccessGrant, rig: Rig, versionId: string): Promise<RigVersion>;
|
|
528
|
+
declare function listRigVersionsForApi(deps: RigServices, workspaceId: string, rigId: string): Promise<RigVersion[]>;
|
|
529
|
+
declare function listRigChangesForApi(deps: RigServices, workspaceId: string, rigId: string, limit?: number): Promise<RigChange[]>;
|
|
530
|
+
|
|
436
531
|
declare const MARKETING_SOCIAL_PACK_ID = "marketing-social-daily-analysis";
|
|
437
532
|
declare function listCapabilityPacks(): CapabilityPack[];
|
|
438
533
|
declare function getCapabilityPack(packId: string): CapabilityPack | null;
|
|
@@ -485,7 +580,7 @@ declare function createValidatedScheduledTask(input: {
|
|
|
485
580
|
grant: AccessGrant;
|
|
486
581
|
payload: CreateScheduledTaskRequest;
|
|
487
582
|
toolsProvided?: boolean;
|
|
488
|
-
|
|
583
|
+
variableSetPreauthorized?: boolean;
|
|
489
584
|
}): Promise<ScheduledTask>;
|
|
490
585
|
declare function validatedScheduledTaskUpdate(input: {
|
|
491
586
|
settings: Settings;
|
|
@@ -552,10 +647,12 @@ declare function createAndStartSession(input: {
|
|
|
552
647
|
reasoningEffort: Settings["openaiReasoningEffort"];
|
|
553
648
|
sandboxBackend: Settings["sandboxBackend"];
|
|
554
649
|
metadata: Record<string, unknown>;
|
|
555
|
-
|
|
650
|
+
variableSet?: {
|
|
556
651
|
id: string;
|
|
557
652
|
name: string;
|
|
558
653
|
} | null;
|
|
654
|
+
rigId?: string | null;
|
|
655
|
+
rigVersionId?: string | null;
|
|
559
656
|
goal?: GoalSpec | null;
|
|
560
657
|
instructions?: string | null;
|
|
561
658
|
firstPartyMcpPermissions?: Permission[] | null;
|
|
@@ -574,7 +671,7 @@ declare function createAndStartSession(input: {
|
|
|
574
671
|
id: string;
|
|
575
672
|
workspaceId: string;
|
|
576
673
|
accountId: string;
|
|
577
|
-
status: "queued" | "running" | "idle" | "requires_action" | "failed" | "cancelled";
|
|
674
|
+
status: "queued" | "running" | "idle" | "requires_action" | "recovering" | "waiting_capacity" | "failed" | "cancelled";
|
|
578
675
|
initialMessage: string;
|
|
579
676
|
title: string | null;
|
|
580
677
|
titleSource: "user" | "agent" | null;
|
|
@@ -585,6 +682,11 @@ declare function createAndStartSession(input: {
|
|
|
585
682
|
ref: string;
|
|
586
683
|
mountPath?: string | undefined;
|
|
587
684
|
subpath?: string | undefined;
|
|
685
|
+
provider?: "github" | "gitlab" | "azure_devops" | undefined;
|
|
686
|
+
repositoryId?: string | number | undefined;
|
|
687
|
+
installationId?: string | number | undefined;
|
|
688
|
+
projectId?: string | number | undefined;
|
|
689
|
+
connectionId?: string | undefined;
|
|
588
690
|
githubInstallationId?: number | undefined;
|
|
589
691
|
githubRepositoryId?: number | undefined;
|
|
590
692
|
} | {
|
|
@@ -604,8 +706,11 @@ declare function createAndStartSession(input: {
|
|
|
604
706
|
sandboxGroupId: string;
|
|
605
707
|
activeSandboxId: string | null;
|
|
606
708
|
activeEpoch: number;
|
|
709
|
+
variableSetId: string | null;
|
|
607
710
|
environmentId: string | null;
|
|
608
|
-
|
|
711
|
+
rigId: string | null;
|
|
712
|
+
rigVersionId: string | null;
|
|
713
|
+
firstPartyMcpPermissions: ("account:read" | "account:admin" | "members:manage" | "workspace:create" | "billing:read" | "billing:manage" | "workspace:read" | "workspace:admin" | "sessions:create" | "sessions:read" | "sessions:control" | "stream:view" | "stream:control" | "stream:acknowledge" | "files:upload" | "files:read" | "files:write" | "terminal:attach" | "documents:manage" | "documents:search" | "scheduled_tasks:manage" | "scheduled_tasks:run" | "github:manage" | "github:use" | "api_keys:manage" | "connections:read" | "connections:write" | "environments:manage" | "environments:use" | "variable-sets:manage" | "variable-sets:use" | "mcp_servers:attach" | "toolspace:call" | "goals:manage" | "enrollments:read" | "enrollments:manage" | "rigs:use" | "rigs:manage")[] | null;
|
|
609
714
|
mcpServers: {
|
|
610
715
|
id: string;
|
|
611
716
|
name: string | null;
|
|
@@ -618,11 +723,74 @@ declare function createAndStartSession(input: {
|
|
|
618
723
|
temporalWorkflowId: string | null;
|
|
619
724
|
activeTurnId: string | null;
|
|
620
725
|
lastInputTokens: number | null;
|
|
726
|
+
queueVersion: number;
|
|
727
|
+
queueHeadPosition: number;
|
|
728
|
+
queueTailPosition: number;
|
|
729
|
+
effectiveControl: {
|
|
730
|
+
state: "active" | "paused";
|
|
731
|
+
controlVersion: number;
|
|
732
|
+
controlEtag: string;
|
|
733
|
+
directState: "active" | "paused";
|
|
734
|
+
primaryBlocker: {
|
|
735
|
+
kind: "workspace" | "session";
|
|
736
|
+
displayName: string;
|
|
737
|
+
actor: string | null;
|
|
738
|
+
reason: string | null;
|
|
739
|
+
changedAt: string | null;
|
|
740
|
+
revision: number;
|
|
741
|
+
sessionId?: string | undefined;
|
|
742
|
+
} | null;
|
|
743
|
+
additionalBlockerCount: number;
|
|
744
|
+
blockers: {
|
|
745
|
+
kind: "workspace" | "session";
|
|
746
|
+
displayName: string;
|
|
747
|
+
actor: string | null;
|
|
748
|
+
reason: string | null;
|
|
749
|
+
changedAt: string | null;
|
|
750
|
+
revision: number;
|
|
751
|
+
sessionId?: string | undefined;
|
|
752
|
+
}[];
|
|
753
|
+
resumeOptions: {
|
|
754
|
+
scope: "workspace" | "session" | "selected";
|
|
755
|
+
selectedStateAfter: "active" | "paused";
|
|
756
|
+
impactCopy: string;
|
|
757
|
+
targetId?: string | undefined;
|
|
758
|
+
remainingPrimaryBlocker?: {
|
|
759
|
+
kind: "workspace" | "session";
|
|
760
|
+
displayName: string;
|
|
761
|
+
actor: string | null;
|
|
762
|
+
reason: string | null;
|
|
763
|
+
changedAt: string | null;
|
|
764
|
+
revision: number;
|
|
765
|
+
sessionId?: string | undefined;
|
|
766
|
+
} | undefined;
|
|
767
|
+
}[];
|
|
768
|
+
override: {
|
|
769
|
+
rootSessionId: string;
|
|
770
|
+
revision: number;
|
|
771
|
+
} | null;
|
|
772
|
+
settlement: {
|
|
773
|
+
state: "stopping";
|
|
774
|
+
attemptCount: number;
|
|
775
|
+
} | null;
|
|
776
|
+
};
|
|
621
777
|
lastSequence: number;
|
|
622
778
|
codexPinnedCredentialId: string | null;
|
|
623
779
|
codexLastCredentialId: string | null;
|
|
780
|
+
pinned: boolean;
|
|
781
|
+
pinnedAt: string | null;
|
|
782
|
+
pinVersion: number;
|
|
624
783
|
createdAt: string;
|
|
625
784
|
updatedAt: string;
|
|
785
|
+
treeStats?: {
|
|
786
|
+
directChildren: number;
|
|
787
|
+
totalDescendants: number;
|
|
788
|
+
runningDescendants: number;
|
|
789
|
+
queuedDescendants: number;
|
|
790
|
+
attentionDescendants: number;
|
|
791
|
+
pausedDescendants: number;
|
|
792
|
+
failedDescendants: number;
|
|
793
|
+
} | undefined;
|
|
626
794
|
}>;
|
|
627
795
|
declare function workflowIdForSession(sessionId: string): string;
|
|
628
796
|
/**
|
|
@@ -642,6 +810,18 @@ declare function workflowIdForSession(sessionId: string): string;
|
|
|
642
810
|
* drift.
|
|
643
811
|
*/
|
|
644
812
|
declare function assertConfiguredModel(settings: Settings, model: string | null | undefined): void;
|
|
813
|
+
/**
|
|
814
|
+
* Reject a model the WORKSPACE's model policy blocks, at the same choke points
|
|
815
|
+
* as assertConfiguredModel — a 422 at the edge instead of a queued turn the
|
|
816
|
+
* worker's authoritative post-resolution gate would fail. `model` is the
|
|
817
|
+
* EFFECTIVE value the caller is about to persist: pass the explicit value at
|
|
818
|
+
* message/turn-update/scheduled-task edges (omitted inherits an
|
|
819
|
+
* already-validated stored default), but at session CREATION pass
|
|
820
|
+
* `payload.model ?? settings.openaiModel` — an omitted model stamps the
|
|
821
|
+
* deployment default onto the session, and under a restricted policy that
|
|
822
|
+
* default may be exactly the provider the policy exists to block.
|
|
823
|
+
*/
|
|
824
|
+
declare function assertWorkspaceModelPolicyAllows(db: Database, settings: Settings, workspaceId: string, model: string | null | undefined): Promise<void>;
|
|
645
825
|
declare function requireQueuedTurnForApi(db: Database, workspaceId: string, sessionId: string, turnId: string): Promise<SessionTurn>;
|
|
646
826
|
declare function reasoningEffortForSession(metadata: Record<string, unknown>, fallback: Settings["openaiReasoningEffort"]): Settings["openaiReasoningEffort"];
|
|
647
827
|
/**
|
|
@@ -654,7 +834,7 @@ declare function reasoningEffortForSession(metadata: Record<string, unknown>, fa
|
|
|
654
834
|
declare function postUserMessageTurn(input: {
|
|
655
835
|
db: Database;
|
|
656
836
|
bus: EventBus;
|
|
657
|
-
workflowClient: SessionWorkflowClient
|
|
837
|
+
workflowClient: Pick<SessionWorkflowClient, "wakeSessionWorkflow">;
|
|
658
838
|
settings: Settings;
|
|
659
839
|
accountId: string;
|
|
660
840
|
workspaceId: string;
|
|
@@ -666,13 +846,18 @@ declare function postUserMessageTurn(input: {
|
|
|
666
846
|
reasoningEffort?: Settings["openaiReasoningEffort"] | null;
|
|
667
847
|
clientEventId?: string;
|
|
668
848
|
mcpCredentialUpdates?: UpdateSessionMcpServerCredentialsInput[];
|
|
849
|
+
delivery?: "send" | "steer";
|
|
850
|
+
origin?: "human" | "operator";
|
|
851
|
+
actor?: string;
|
|
852
|
+
controlEtag?: string | null;
|
|
853
|
+
expectedDraftRevision?: number | null;
|
|
669
854
|
}): Promise<{
|
|
670
855
|
accepted: SessionEvent;
|
|
671
856
|
turn: SessionTurn;
|
|
672
857
|
}>;
|
|
673
858
|
/**
|
|
674
859
|
* Full create-session flow shared by `POST /sessions` and the first-party MCP
|
|
675
|
-
* `session_create` tool: payload validation, resource/tool/
|
|
860
|
+
* `session_create` tool: payload validation, resource/tool/variableSet
|
|
676
861
|
* checks, usage limits, session start, and usage recording. `rawPayload` is
|
|
677
862
|
* the unparsed request body so absent-vs-empty `tools` keeps its meaning
|
|
678
863
|
* (absent applies the workspace's default capability MCP tools).
|
|
@@ -685,7 +870,7 @@ declare function createSessionForRequest(deps: ApiRouteDeps, grant: AccessGrant,
|
|
|
685
870
|
* enqueue, and usage recording. `toolsProvided: false` applies the
|
|
686
871
|
* workspace's default capability MCP tools, matching an absent `tools` key.
|
|
687
872
|
*/
|
|
688
|
-
declare function acceptSessionUserMessage(deps:
|
|
873
|
+
declare function acceptSessionUserMessage(deps: AcceptSessionUserMessageDependencies, grant: AccessGrant, workspaceId: string, sessionId: string, input: {
|
|
689
874
|
text: string;
|
|
690
875
|
resources?: ResourceRef[];
|
|
691
876
|
tools?: ToolRef[];
|
|
@@ -694,6 +879,10 @@ declare function acceptSessionUserMessage(deps: ApiRouteDeps, grant: AccessGrant
|
|
|
694
879
|
reasoningEffort?: ReasoningEffort | null;
|
|
695
880
|
clientEventId?: string;
|
|
696
881
|
mcpCredentialUpdates?: SessionMcpCredentialUpdateInput[];
|
|
882
|
+
delivery?: "send" | "steer";
|
|
883
|
+
origin?: "human" | "operator";
|
|
884
|
+
controlEtag?: string | null;
|
|
885
|
+
expectedDraftRevision?: number | null;
|
|
697
886
|
}): Promise<{
|
|
698
887
|
accepted: SessionEvent;
|
|
699
888
|
turn: SessionTurn;
|
|
@@ -714,6 +903,7 @@ declare function updateSessionTitle(deps: {
|
|
|
714
903
|
updated: boolean;
|
|
715
904
|
title: string | null;
|
|
716
905
|
}>;
|
|
906
|
+
declare function readSessionLineage(db: Database, workspaceId: string, sessionId: string): Promise<_opengeni_db.SessionLineage>;
|
|
717
907
|
|
|
718
908
|
/** A member can manage other members (directly or via the admin wildcard). */
|
|
719
909
|
declare function memberCanAdminister(member: Pick<WorkspaceMember, "permissions">): boolean;
|
|
@@ -749,4 +939,75 @@ declare function assertWorkspaceDeletable(input: {
|
|
|
749
939
|
activeSessionCount: number;
|
|
750
940
|
}): void;
|
|
751
941
|
|
|
752
|
-
|
|
942
|
+
type HumanSessionCommandContext = {
|
|
943
|
+
accountId: string;
|
|
944
|
+
workspaceId: string;
|
|
945
|
+
sessionId: string;
|
|
946
|
+
subjectId: string;
|
|
947
|
+
};
|
|
948
|
+
type AgentSessionCommandContext = {
|
|
949
|
+
accountId: string;
|
|
950
|
+
workspaceId: string;
|
|
951
|
+
callerSessionId: string;
|
|
952
|
+
callerTurnId: string;
|
|
953
|
+
callerAttemptId: string;
|
|
954
|
+
callerExecutionGeneration: number;
|
|
955
|
+
};
|
|
956
|
+
declare function sendAgentSessionMessage(deps: {
|
|
957
|
+
db: Database;
|
|
958
|
+
bus: EventBus;
|
|
959
|
+
workflowClient: Pick<SessionWorkflowClient, "wakeSessionWorkflow">;
|
|
960
|
+
}, context: AgentSessionCommandContext, input: {
|
|
961
|
+
targetSessionId: string;
|
|
962
|
+
text: string;
|
|
963
|
+
idempotencyKey: string;
|
|
964
|
+
}): Promise<_opengeni_db.AgentInternalUpdateCommandResult>;
|
|
965
|
+
declare function steerAgentSession(deps: {
|
|
966
|
+
db: Database;
|
|
967
|
+
bus: EventBus;
|
|
968
|
+
workflowClient: Pick<SessionWorkflowClient, "wakeSessionWorkflow">;
|
|
969
|
+
}, context: AgentSessionCommandContext, input: {
|
|
970
|
+
targetSessionId: string;
|
|
971
|
+
instruction: string;
|
|
972
|
+
idempotencyKey: string;
|
|
973
|
+
}): Promise<_opengeni_db.AgentInternalUpdateCommandResult>;
|
|
974
|
+
declare function controlAgentSessionWorkstream(deps: {
|
|
975
|
+
db: Database;
|
|
976
|
+
bus: EventBus;
|
|
977
|
+
workflowClient: Pick<SessionWorkflowClient, "requestSessionWorkflowWakeDispatch">;
|
|
978
|
+
}, context: AgentSessionCommandContext, input: {
|
|
979
|
+
targetSessionId: string;
|
|
980
|
+
action: "pause" | "resume";
|
|
981
|
+
idempotencyKey: string;
|
|
982
|
+
reason?: string | null;
|
|
983
|
+
}): Promise<_opengeni_db.SessionControlMutationResult>;
|
|
984
|
+
declare function moveHumanQueuePrompt(deps: {
|
|
985
|
+
db: Database;
|
|
986
|
+
bus: EventBus;
|
|
987
|
+
}, context: HumanSessionCommandContext, turnId: string, input: MoveSessionQueueItemRequest): Promise<SessionQueueMutationResponse>;
|
|
988
|
+
declare function deleteHumanQueuePrompt(deps: {
|
|
989
|
+
db: Database;
|
|
990
|
+
bus: EventBus;
|
|
991
|
+
}, context: HumanSessionCommandContext, turnId: string, input: DeleteSessionQueueItemRequest): Promise<SessionQueueMutationResponse>;
|
|
992
|
+
declare function editHumanQueuePrompt(deps: {
|
|
993
|
+
db: Database;
|
|
994
|
+
bus: EventBus;
|
|
995
|
+
}, context: HumanSessionCommandContext, turnId: string, input: EditSessionQueueItemRequest): Promise<SessionQueueMutationResponse>;
|
|
996
|
+
declare function steerHumanQueuePrompt(deps: {
|
|
997
|
+
db: Database;
|
|
998
|
+
bus: EventBus;
|
|
999
|
+
}, context: HumanSessionCommandContext, turnId: string, input: SteerSessionQueueItemRequest): Promise<SessionQueueMutationResponse>;
|
|
1000
|
+
declare function controlHumanSessionWorkstream(deps: {
|
|
1001
|
+
db: Database;
|
|
1002
|
+
bus: EventBus;
|
|
1003
|
+
workflowClient: Pick<SessionWorkflowClient, "requestSessionWorkflowWakeDispatch">;
|
|
1004
|
+
}, context: HumanSessionCommandContext, input: SessionControlRequest): Promise<SessionControlResponse>;
|
|
1005
|
+
declare function controlHumanWorkspace(deps: {
|
|
1006
|
+
db: Database;
|
|
1007
|
+
bus: EventBus;
|
|
1008
|
+
workflowClient: Pick<SessionWorkflowClient, "requestSessionWorkflowWakeDispatch">;
|
|
1009
|
+
}, context: Omit<HumanSessionCommandContext, "sessionId">, input: WorkspaceInferenceControlRequest): Promise<WorkspaceInferenceControlResponse>;
|
|
1010
|
+
declare function getHumanComposerDraft(db: Database, context: HumanSessionCommandContext): Promise<ComposerDraft>;
|
|
1011
|
+
declare function saveHumanComposerDraft(db: Database, context: HumanSessionCommandContext, input: SaveComposerDraftRequest): Promise<ComposerDraft>;
|
|
1012
|
+
|
|
1013
|
+
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 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 ResumeBoxByIdInput, type ResumedSandboxSession, type RigServices, type RigVerificationClassification, type RunOnOp, type RunOnResult, SESSION_WORKFLOW_WAKE_DISPATCHER_PERIOD_MS, SESSION_WORKFLOW_WAKE_DISPATCHER_SCHEDULE_ID, SESSION_WORKFLOW_WAKE_DISPATCHER_WORKFLOW_TYPE, type SessionWorkflowClient, acceptSessionUserMessage, activateRigVersionForApi, appendRigSetupCommand, applyCapabilityEnablement, assertAllowedEnvironmentVariableName, assertAllowedVariableSetVariableName, assertConfiguredModel, assertPackSandboxImageCompatible, assertWorkspaceDeletable, assertWorkspaceMemberRemovable, assertWorkspaceModelPolicyAllows, buildCapabilityCatalog, buildFleetContextForSession, buildMarketingDailyAnalysisAgentConfig, checkLimit, classifyRigVerificationOutcome, controlAgentSessionWorkstream, controlHumanSessionWorkstream, controlHumanWorkspace, createAndStartSession, createCatalogItem, createRigForApi, createRigVersionForApi, createSessionForRequest, createValidatedScheduledTask, deleteHumanQueuePrompt, deleteRigForApi, disableCapability, discoverMcpRegistryCapabilities, editHumanQueuePrompt, enableCapability, enabledCapabilityMcpToolRefs, getCapabilityPack, getHumanComposerDraft, hasPermission, isBuiltInCapabilityPack, isUserMember, listCapabilityPacks, listFleet, listRigChangesForApi, listRigVersionsForApi, listWorkspaceCapabilityPacks, manualScheduledTaskTriggerUsageKey, manualScheduledTaskTriggerWorkflowId, memberCanAdminister, mergeResourceRefs, moveHumanQueuePrompt, normalizeResources, officialMcpRegistryUrl, postUserMessageTurn, promoteSetupAppendChange, promoteVerifiedDefinitionEditChangeForApi, proposeRigChangeForApi, provisionSandbox, readSessionLineage, reasoningEffortForSession, recordRigAuditEvent, recordVariableSetAuditEvent, recordWorkspaceUsage, relayConfigFromSettings, relayDialBaseFromSettings, requireAccessContext, requireAccessGrant, requireEnvironmentEncryption, requireLimit, requirePermission, requireQueuedTurnForApi, requireRigChangeForApi, requireRigForApi, requireScheduledTaskForApi, requireVariableSetEncryption, requireVariableSetForApi, resolveCapabilityPack, resolveMemberSubjectId, restoreScheduledTask, rigActorForGrant, routingEnabled, runOnSandbox, saveHumanComposerDraft, scheduledTaskTemporalScheduleId, scheduledTaskToolsProvided, scheduledTaskTriggerToken, sendAgentSessionMessage, settingsWithEnabledCapabilityMcpServers, settingsWithMcpCapabilityServers, settingsWithSessionMcpServerMetadata, steerAgentSession, steerHumanQueuePrompt, swapActiveSandbox, syncCreatedScheduledTask, syncUpdatedScheduledTask, updateRigForApi, updateSessionTitle, validateFileResources, validateGitHubRepositorySelection, validateGitHubRepositorySelectionShape, validateMcpCapabilityConnection, validateToolRefs, validateVariableSetAttachment, validatedScheduledTaskUpdate, withDefaultEnabledCapabilityMcpTools, workflowIdForSession, wrapChannelABoxWithRouting };
|