@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
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Settings } from "@opengeni/config";
|
|
2
|
+
import { type AccountGrant, type AccessContext, type AccessGrant, type Permission } from "@opengeni/contracts";
|
|
3
|
+
import { type Database } from "@opengeni/db";
|
|
4
|
+
import type { Context } from "hono";
|
|
5
|
+
import type { ManagedAuth } from "../managed-auth-type";
|
|
6
|
+
export type AccessDeps = {
|
|
7
|
+
db: Database;
|
|
8
|
+
settings: Settings;
|
|
9
|
+
managedAuth?: ManagedAuth | null;
|
|
10
|
+
};
|
|
11
|
+
export declare function requireAccessContext(c: Context, deps: AccessDeps): Promise<AccessContext>;
|
|
12
|
+
export declare function requireAccessGrant(c: Context, deps: AccessDeps, workspaceId: string, permission?: Permission): Promise<AccessGrant>;
|
|
13
|
+
export type AccessGrantAuthorization = {
|
|
14
|
+
grant: AccessGrant;
|
|
15
|
+
accountGrant: AccountGrant | null;
|
|
16
|
+
authenticatedSubjectId: string;
|
|
17
|
+
contextIntegrity: boolean;
|
|
18
|
+
};
|
|
19
|
+
export declare function accessGrantAuthorizationFromContext(context: AccessContext, grant: AccessGrant): AccessGrantAuthorization;
|
|
20
|
+
export declare function requireAccessGrantAuthorization(c: Context, deps: AccessDeps, workspaceId: string, permission?: Permission): Promise<AccessGrantAuthorization>;
|
|
21
|
+
export declare function requirePermission(grant: AccessGrant, permission: Permission): void;
|
|
22
|
+
export declare function hasPermission(permissions: Permission[], permission: Permission): boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type AccessGrant, type NewSessionDraft as NewSessionDraftValue } from "@opengeni/contracts";
|
|
2
|
+
import type { AppDependencies } from "../dependencies";
|
|
3
|
+
type NewSessionDraftDependencies = Pick<AppDependencies, "settings" | "db" | "objectStorage">;
|
|
4
|
+
/** Read the authenticated actor's server-authoritative pre-session composer state. */
|
|
5
|
+
export declare function getActorNewSessionDraft(deps: Pick<NewSessionDraftDependencies, "settings" | "db">, grant: AccessGrant, workspaceId: string): Promise<NewSessionDraftValue>;
|
|
6
|
+
/**
|
|
7
|
+
* Validate and save one exact actor-private draft revision. Create-time-only
|
|
8
|
+
* checks (live machine target, rig/variable-set state, and permission
|
|
9
|
+
* delegation) intentionally remain in createSessionForRequest: a recoverable
|
|
10
|
+
* draft may represent incomplete options, while no invalid option can become a
|
|
11
|
+
* session without passing that single canonical create boundary.
|
|
12
|
+
*/
|
|
13
|
+
export declare function saveActorNewSessionDraft(deps: NewSessionDraftDependencies, grant: AccessGrant, workspaceId: string, rawInput: unknown): Promise<NewSessionDraftValue>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { ComposerDraft, DeleteSessionQueueItemRequest, EditSessionQueueItemRequest, MoveSessionQueueItemRequest, SaveComposerDraftRequest, SessionAuthorizationPort, SessionAuthorizationSurface, SessionControlRequest, SessionControlResponse, SessionQueueMutationResponse, SteerSessionQueueItemRequest, WorkspaceInferenceControlRequest, WorkspaceInferenceControlResponse } from "@opengeni/contracts";
|
|
2
|
+
import { type Database, type SessionCommandReceiptRow } from "@opengeni/db";
|
|
3
|
+
import { type EventBus } from "@opengeni/events";
|
|
4
|
+
import type { SessionWorkflowClient } from "../dependencies";
|
|
5
|
+
import { type ResolvedSessionAuthorization } from "../session-authorization";
|
|
6
|
+
export type HumanSessionCommandContext = {
|
|
7
|
+
accountId: string;
|
|
8
|
+
workspaceId: string;
|
|
9
|
+
sessionId: string;
|
|
10
|
+
subjectId: string;
|
|
11
|
+
/** See AgentSessionCommandContext.authorizationSurface. */
|
|
12
|
+
authorizationSurface?: SessionAuthorizationSurface;
|
|
13
|
+
};
|
|
14
|
+
export type AgentSessionCommandContext = {
|
|
15
|
+
accountId: string;
|
|
16
|
+
workspaceId: string;
|
|
17
|
+
subjectId: string;
|
|
18
|
+
callerSessionId: string;
|
|
19
|
+
callerTurnId: string;
|
|
20
|
+
callerAttemptId: string;
|
|
21
|
+
callerExecutionGeneration: number;
|
|
22
|
+
/**
|
|
23
|
+
* The trusted adapter surface that owns this command's one authorization
|
|
24
|
+
* decision. Direct core callers omit it and retain the canonical `core`
|
|
25
|
+
* surface; adapters that delegate the complete command set it explicitly so
|
|
26
|
+
* they do not authorize once at the edge and then repeat the host call here.
|
|
27
|
+
*/
|
|
28
|
+
authorizationSurface?: SessionAuthorizationSurface;
|
|
29
|
+
};
|
|
30
|
+
type SessionAuthorizationCommandDeps = {
|
|
31
|
+
db: Database;
|
|
32
|
+
sessionAuthorization?: SessionAuthorizationPort | null;
|
|
33
|
+
};
|
|
34
|
+
export declare function sendAgentSessionMessage(deps: {
|
|
35
|
+
db: Database;
|
|
36
|
+
bus: EventBus;
|
|
37
|
+
workflowClient: Pick<SessionWorkflowClient, "wakeSessionWorkflow">;
|
|
38
|
+
sessionAuthorization?: SessionAuthorizationPort | null;
|
|
39
|
+
}, context: AgentSessionCommandContext, input: {
|
|
40
|
+
targetSessionId: string;
|
|
41
|
+
text: string;
|
|
42
|
+
idempotencyKey: string;
|
|
43
|
+
}): Promise<import("@opengeni/db").AgentInternalUpdateCommandResult>;
|
|
44
|
+
export declare function steerAgentSession(deps: {
|
|
45
|
+
db: Database;
|
|
46
|
+
bus: EventBus;
|
|
47
|
+
workflowClient: Pick<SessionWorkflowClient, "wakeSessionWorkflow">;
|
|
48
|
+
sessionAuthorization?: SessionAuthorizationPort | null;
|
|
49
|
+
}, context: AgentSessionCommandContext, input: {
|
|
50
|
+
targetSessionId: string;
|
|
51
|
+
instruction: string;
|
|
52
|
+
idempotencyKey: string;
|
|
53
|
+
}): Promise<import("@opengeni/db").AgentInternalUpdateCommandResult>;
|
|
54
|
+
export declare function controlAgentSessionWorkstream(deps: {
|
|
55
|
+
db: Database;
|
|
56
|
+
bus: EventBus;
|
|
57
|
+
workflowClient: Pick<SessionWorkflowClient, "requestSessionWorkflowWakeDispatch">;
|
|
58
|
+
sessionAuthorization?: SessionAuthorizationPort | null;
|
|
59
|
+
}, context: AgentSessionCommandContext, input: {
|
|
60
|
+
targetSessionId: string;
|
|
61
|
+
action: "pause" | "resume";
|
|
62
|
+
idempotencyKey: string;
|
|
63
|
+
reason?: string | null;
|
|
64
|
+
}): Promise<{
|
|
65
|
+
receipt: SessionCommandReceiptRow;
|
|
66
|
+
control: import("@opengeni/db").EffectiveSessionControl;
|
|
67
|
+
sessionControlEventId: string;
|
|
68
|
+
workspaceControlEventId: string;
|
|
69
|
+
interruptionCount: number;
|
|
70
|
+
wakeCount: number;
|
|
71
|
+
replay: boolean;
|
|
72
|
+
authorization: ResolvedSessionAuthorization | null;
|
|
73
|
+
}>;
|
|
74
|
+
export declare function moveHumanQueuePrompt(deps: {
|
|
75
|
+
db: Database;
|
|
76
|
+
bus: EventBus;
|
|
77
|
+
sessionAuthorization?: SessionAuthorizationPort | null;
|
|
78
|
+
}, context: HumanSessionCommandContext, turnId: string, input: MoveSessionQueueItemRequest): Promise<SessionQueueMutationResponse>;
|
|
79
|
+
export declare function deleteHumanQueuePrompt(deps: {
|
|
80
|
+
db: Database;
|
|
81
|
+
bus: EventBus;
|
|
82
|
+
sessionAuthorization?: SessionAuthorizationPort | null;
|
|
83
|
+
}, context: HumanSessionCommandContext, turnId: string, input: DeleteSessionQueueItemRequest): Promise<SessionQueueMutationResponse>;
|
|
84
|
+
export declare function editHumanQueuePrompt(deps: {
|
|
85
|
+
db: Database;
|
|
86
|
+
bus: EventBus;
|
|
87
|
+
sessionAuthorization?: SessionAuthorizationPort | null;
|
|
88
|
+
}, context: HumanSessionCommandContext, turnId: string, input: EditSessionQueueItemRequest): Promise<SessionQueueMutationResponse>;
|
|
89
|
+
export declare function steerHumanQueuePrompt(deps: {
|
|
90
|
+
db: Database;
|
|
91
|
+
bus: EventBus;
|
|
92
|
+
sessionAuthorization?: SessionAuthorizationPort | null;
|
|
93
|
+
}, context: HumanSessionCommandContext, turnId: string, input: SteerSessionQueueItemRequest): Promise<SessionQueueMutationResponse>;
|
|
94
|
+
export declare function controlHumanSessionWorkstream(deps: {
|
|
95
|
+
db: Database;
|
|
96
|
+
bus: EventBus;
|
|
97
|
+
workflowClient: Pick<SessionWorkflowClient, "requestSessionWorkflowWakeDispatch">;
|
|
98
|
+
sessionAuthorization?: SessionAuthorizationPort | null;
|
|
99
|
+
}, context: HumanSessionCommandContext, input: SessionControlRequest): Promise<SessionControlResponse>;
|
|
100
|
+
export declare function controlHumanWorkspace(deps: {
|
|
101
|
+
db: Database;
|
|
102
|
+
bus: EventBus;
|
|
103
|
+
workflowClient: Pick<SessionWorkflowClient, "requestSessionWorkflowWakeDispatch">;
|
|
104
|
+
}, context: Omit<HumanSessionCommandContext, "sessionId">, input: WorkspaceInferenceControlRequest): Promise<WorkspaceInferenceControlResponse>;
|
|
105
|
+
export declare function getHumanComposerDraft(deps: SessionAuthorizationCommandDeps, context: HumanSessionCommandContext): Promise<ComposerDraft>;
|
|
106
|
+
export declare function saveHumanComposerDraft(deps: SessionAuthorizationCommandDeps, context: HumanSessionCommandContext, input: SaveComposerDraftRequest): Promise<ComposerDraft>;
|
|
107
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { LimitAction, LimitDecision, SessionTurnSource, TurnInitiator, TurnInitiatorContext } from "@opengeni/contracts";
|
|
2
|
+
import type { ApiRouteDeps } from "../dependencies";
|
|
3
|
+
export type LimitDependencies = Pick<ApiRouteDeps, "db" | "settings">;
|
|
4
|
+
export type LimitCheckInput = {
|
|
5
|
+
accountId: string;
|
|
6
|
+
workspaceId?: string;
|
|
7
|
+
action: LimitAction;
|
|
8
|
+
quantity?: number;
|
|
9
|
+
model?: string | null;
|
|
10
|
+
};
|
|
11
|
+
export declare function requireLimit(deps: LimitDependencies, input: LimitCheckInput): Promise<void>;
|
|
12
|
+
export declare function checkLimit(deps: LimitDependencies, input: LimitCheckInput): Promise<LimitDecision>;
|
|
13
|
+
export declare function recordWorkspaceUsage(deps: LimitDependencies, input: {
|
|
14
|
+
accountId: string;
|
|
15
|
+
workspaceId: string;
|
|
16
|
+
subjectId?: string | null;
|
|
17
|
+
eventType: "agent_run.created" | "file.uploaded" | "document.indexed" | "scheduled_task.fired";
|
|
18
|
+
quantity: number;
|
|
19
|
+
unit: string;
|
|
20
|
+
sourceResourceType: string;
|
|
21
|
+
sourceResourceId: string;
|
|
22
|
+
sessionId?: string | null;
|
|
23
|
+
turnId?: string | null;
|
|
24
|
+
turnAttemptId?: string | null;
|
|
25
|
+
initiator?: TurnInitiator | null;
|
|
26
|
+
initiatorContext?: TurnInitiatorContext;
|
|
27
|
+
origin?: SessionTurnSource | null;
|
|
28
|
+
idempotencyKey: string;
|
|
29
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import type { Settings } from "@opengeni/config";
|
|
2
|
+
import type { ConnectionCredentialsPort, Document, GitHubAppApiPort, ScheduledTask, SessionAuthorizationPort, TurnInitiator } from "@opengeni/contracts";
|
|
3
|
+
import type { Database } from "@opengeni/db";
|
|
4
|
+
import type { DocumentServices } from "@opengeni/documents";
|
|
5
|
+
import type { EventBus } from "@opengeni/events";
|
|
6
|
+
import type { Observability } from "@opengeni/observability";
|
|
7
|
+
import type { createObjectStorage } from "@opengeni/storage";
|
|
8
|
+
import type { ManagedAuth } from "./managed-auth-type";
|
|
9
|
+
import type { ApiSandboxClient, ResumeBoxByIdInput, ResumedSandboxSession } from "./sandbox-types";
|
|
10
|
+
import type { TranscriptionService } from "./transcription";
|
|
11
|
+
export type SessionWorkflowClient = {
|
|
12
|
+
signalUserMessage: (input: {
|
|
13
|
+
sessionId: string;
|
|
14
|
+
eventId: string;
|
|
15
|
+
workflowId: string;
|
|
16
|
+
}) => Promise<void>;
|
|
17
|
+
wakeSessionWorkflow: (input: {
|
|
18
|
+
accountId: string;
|
|
19
|
+
workspaceId: string;
|
|
20
|
+
sessionId: string;
|
|
21
|
+
workflowId: string;
|
|
22
|
+
wakeRevision: number;
|
|
23
|
+
interruptionRequested?: boolean;
|
|
24
|
+
}) => Promise<void>;
|
|
25
|
+
/** Trigger one bounded drain of already-committed workflow-wake revisions. */
|
|
26
|
+
requestSessionWorkflowWakeDispatch: () => Promise<void>;
|
|
27
|
+
signalCodexCapacity?: (input: {
|
|
28
|
+
accountId: string;
|
|
29
|
+
workspaceId: string;
|
|
30
|
+
sessionId: string;
|
|
31
|
+
workflowId: string;
|
|
32
|
+
wakeRevision: number;
|
|
33
|
+
workflowWakeRevision: number;
|
|
34
|
+
}) => Promise<void>;
|
|
35
|
+
signalApprovalDecision: (input: {
|
|
36
|
+
accountId: string;
|
|
37
|
+
workspaceId: string;
|
|
38
|
+
sessionId: string;
|
|
39
|
+
eventId: string;
|
|
40
|
+
workflowId: string;
|
|
41
|
+
workflowWakeRevision: number;
|
|
42
|
+
}) => Promise<void>;
|
|
43
|
+
syncScheduledTask: (input: {
|
|
44
|
+
task: ScheduledTask;
|
|
45
|
+
}) => Promise<void>;
|
|
46
|
+
deleteScheduledTaskSchedule: (input: {
|
|
47
|
+
temporalScheduleId: string;
|
|
48
|
+
}) => Promise<void>;
|
|
49
|
+
triggerScheduledTask: (input: {
|
|
50
|
+
task: ScheduledTask;
|
|
51
|
+
agentRunUsageIdempotencyKey: string;
|
|
52
|
+
triggerWorkflowId: string;
|
|
53
|
+
initiator: TurnInitiator;
|
|
54
|
+
}) => Promise<void>;
|
|
55
|
+
startRigVerification: (input: {
|
|
56
|
+
workspaceId: string;
|
|
57
|
+
changeId?: string;
|
|
58
|
+
versionId?: string;
|
|
59
|
+
workflowId?: string;
|
|
60
|
+
}) => Promise<void>;
|
|
61
|
+
check?: () => Promise<void>;
|
|
62
|
+
};
|
|
63
|
+
export type DocumentIndexClient = {
|
|
64
|
+
indexDocument: (input: {
|
|
65
|
+
accountId: string;
|
|
66
|
+
workspaceId: string;
|
|
67
|
+
documentId: string;
|
|
68
|
+
}) => Promise<Document | void>;
|
|
69
|
+
};
|
|
70
|
+
export type AppDependencies = {
|
|
71
|
+
settings: Settings;
|
|
72
|
+
db: Database;
|
|
73
|
+
bus: EventBus;
|
|
74
|
+
workflowClient: SessionWorkflowClient;
|
|
75
|
+
/** Optional provider override for deterministic API/object-storage tests. */
|
|
76
|
+
objectStorage?: ObjectStorageDependency;
|
|
77
|
+
documentIndexer?: DocumentIndexClient;
|
|
78
|
+
documentServices?: DocumentServices;
|
|
79
|
+
observability?: Observability;
|
|
80
|
+
readinessChecks?: Partial<Record<"db" | "nats" | "temporal", () => Promise<void> | void>>;
|
|
81
|
+
githubStateSecret?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Optional host-provided GitHub App API seam. Embedded hosts can authorize
|
|
84
|
+
* users, inspect installations, and list repositories with their own GitHub
|
|
85
|
+
* App credentials; standalone deployments fall back to @opengeni/github.
|
|
86
|
+
*/
|
|
87
|
+
githubAppApi?: GitHubAppApiPort;
|
|
88
|
+
/**
|
|
89
|
+
* Optional host-owned connection credential seam. API-side consumers use
|
|
90
|
+
* the MCP leg for Toolspace/Code Mode; worker consumers bind the same port
|
|
91
|
+
* for model MCP, Git, and sandbox-secret resolution.
|
|
92
|
+
*/
|
|
93
|
+
connectionCredentials?: ConnectionCredentialsPort | null;
|
|
94
|
+
/**
|
|
95
|
+
* Optional embedding-host session ACL. Unset preserves standalone workspace
|
|
96
|
+
* authorization; once bound, every session-addressed surface fails closed on
|
|
97
|
+
* an unavailable or invalid host decision.
|
|
98
|
+
*/
|
|
99
|
+
sessionAuthorization?: SessionAuthorizationPort | null;
|
|
100
|
+
managedAuth?: ManagedAuth | null;
|
|
101
|
+
/** Injectable Codex HTTP transport for deterministic API/provider tests. */
|
|
102
|
+
codexFetch?: typeof fetch;
|
|
103
|
+
/** Injectable Slack Web API transport for deterministic bot-connection tests. */
|
|
104
|
+
slackFetch?: typeof fetch;
|
|
105
|
+
/** Injectable Google OAuth/Drive transport for deterministic connector tests. */
|
|
106
|
+
googleDriveFetch?: typeof fetch;
|
|
107
|
+
/** Optional host-owned voice-input transcription service. */
|
|
108
|
+
transcription?: TranscriptionService | null;
|
|
109
|
+
sandboxClient?: ApiSandboxClient;
|
|
110
|
+
/**
|
|
111
|
+
* Resume a box by id from a serialized resume_state envelope (the lease's
|
|
112
|
+
* `resume_state` + `resume_backend_id` from P1.1) and return a live session
|
|
113
|
+
* for a single in-process op. resume → use → drop; the lease owns lifecycle,
|
|
114
|
+
* the returned handle does NOT own the box. Throws SandboxResumeError on a
|
|
115
|
+
* backend mismatch or a resume failure.
|
|
116
|
+
*/
|
|
117
|
+
resumeBoxById?: (input: ResumeBoxByIdInput) => Promise<ResumedSandboxSession>;
|
|
118
|
+
};
|
|
119
|
+
export type ObjectStorageDependency = ReturnType<typeof createObjectStorage>;
|
|
120
|
+
export type ApiRouteDeps = AppDependencies & {
|
|
121
|
+
objectStorage: ObjectStorageDependency;
|
|
122
|
+
githubStateSecret: string;
|
|
123
|
+
documentIndexer: DocumentIndexClient;
|
|
124
|
+
getDocumentServices: () => DocumentServices;
|
|
125
|
+
resumeBoxById: (input: ResumeBoxByIdInput) => Promise<ResumedSandboxSession>;
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* The exact dependency slice used by `acceptSessionUserMessage`.
|
|
129
|
+
*
|
|
130
|
+
* Keeping this narrower than `ApiRouteDeps` lets control-plane callers reuse
|
|
131
|
+
* the canonical admission path without constructing unrelated HTTP, document,
|
|
132
|
+
* or sandbox services. The public API still passes its `ApiRouteDeps` superset.
|
|
133
|
+
*/
|
|
134
|
+
export type AcceptSessionUserMessageDependencies = Pick<AppDependencies, "settings" | "db" | "bus" | "sessionAuthorization"> & {
|
|
135
|
+
workflowClient: Pick<SessionWorkflowClient, "wakeSessionWorkflow">;
|
|
136
|
+
objectStorage: ObjectStorageDependency;
|
|
137
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type Settings } from "@opengeni/config";
|
|
2
|
+
import { CapabilityCatalogItem, type AccessGrant, type CapabilityCatalogResponse, type CapabilityInstallation, type CreateCapabilityCatalogItemRequest, type EnableCapabilityRequest } from "@opengeni/contracts";
|
|
3
|
+
import { type Database, type EnabledMcpCapabilityServer } from "@opengeni/db";
|
|
4
|
+
declare const officialMcpRegistryUrl = "https://registry.modelcontextprotocol.io";
|
|
5
|
+
export declare function buildCapabilityCatalog(input: {
|
|
6
|
+
db: Database;
|
|
7
|
+
workspaceId: string;
|
|
8
|
+
settings: Settings;
|
|
9
|
+
}): Promise<CapabilityCatalogResponse>;
|
|
10
|
+
export declare function createCatalogItem(input: {
|
|
11
|
+
db: Database;
|
|
12
|
+
accountId: string;
|
|
13
|
+
workspaceId: string;
|
|
14
|
+
payload: CreateCapabilityCatalogItemRequest;
|
|
15
|
+
}): Promise<CapabilityCatalogItem>;
|
|
16
|
+
export declare function enableCapability(input: {
|
|
17
|
+
db: Database;
|
|
18
|
+
grant: AccessGrant;
|
|
19
|
+
accountId: string;
|
|
20
|
+
workspaceId: string;
|
|
21
|
+
settings: Settings;
|
|
22
|
+
capabilityId: string;
|
|
23
|
+
payload: EnableCapabilityRequest;
|
|
24
|
+
probeMcpServer?: McpCapabilityProbe;
|
|
25
|
+
}): Promise<CapabilityInstallation>;
|
|
26
|
+
export type McpCapabilityProbeInput = {
|
|
27
|
+
id: string;
|
|
28
|
+
name: string;
|
|
29
|
+
url: string;
|
|
30
|
+
timeoutMs: number;
|
|
31
|
+
headers?: Record<string, string>;
|
|
32
|
+
};
|
|
33
|
+
export type McpCapabilityProbeResult = {
|
|
34
|
+
toolCount: number;
|
|
35
|
+
};
|
|
36
|
+
export type McpCapabilityProbe = (input: McpCapabilityProbeInput) => Promise<McpCapabilityProbeResult>;
|
|
37
|
+
export declare function validateMcpCapabilityConnection(item: CapabilityCatalogItem, probe?: McpCapabilityProbe, headers?: Record<string, string>): Promise<Record<string, unknown>>;
|
|
38
|
+
export declare function disableCapability(input: {
|
|
39
|
+
db: Database;
|
|
40
|
+
accountId: string;
|
|
41
|
+
workspaceId: string;
|
|
42
|
+
settings: Settings;
|
|
43
|
+
capabilityId: string;
|
|
44
|
+
}): Promise<CapabilityInstallation>;
|
|
45
|
+
export declare function settingsWithEnabledCapabilityMcpServers(db: Database, workspaceId: string, settings: Settings): Promise<Settings>;
|
|
46
|
+
/**
|
|
47
|
+
* Register Codex Apps as an optional runtime MCP when the deployment enables
|
|
48
|
+
* it. Registration only makes the server selectable; the session tool policy
|
|
49
|
+
* decides whether the model sees it, and Codex credential resolution
|
|
50
|
+
* independently decides whether calls can authenticate.
|
|
51
|
+
*/
|
|
52
|
+
export declare function settingsWithCodexAppsMcpServer(settings: Settings): Settings;
|
|
53
|
+
export declare function settingsWithMcpCapabilityServers(settings: Settings, enabled: EnabledMcpCapabilityServer[]): Settings;
|
|
54
|
+
export declare function discoverMcpRegistryCapabilities(input: {
|
|
55
|
+
query?: string;
|
|
56
|
+
limit?: number;
|
|
57
|
+
fetchImpl?: McpRegistryFetch;
|
|
58
|
+
timeoutMs?: number;
|
|
59
|
+
}): Promise<CapabilityCatalogItem[]>;
|
|
60
|
+
export { officialMcpRegistryUrl };
|
|
61
|
+
type McpRegistryFetch = (input: URL, init?: RequestInit) => Promise<Response>;
|
|
62
|
+
export declare function applyCapabilityEnablement(item: CapabilityCatalogItem, installation: CapabilityInstallation | undefined, activePackIds: Set<string>): CapabilityCatalogItem;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type Settings } from "@opengeni/config";
|
|
2
|
+
import type { AccessGrant, VariableSet } from "@opengeni/contracts";
|
|
3
|
+
import { type Database } from "@opengeni/db";
|
|
4
|
+
export declare const MAX_ENVIRONMENTS_PER_WORKSPACE = 25;
|
|
5
|
+
export declare const MAX_VARIABLES_PER_ENVIRONMENT = 100;
|
|
6
|
+
export declare function assertAllowedVariableSetVariableName(name: string): void;
|
|
7
|
+
/** @deprecated use assertAllowedVariableSetVariableName */
|
|
8
|
+
export declare const assertAllowedEnvironmentVariableName: typeof assertAllowedVariableSetVariableName;
|
|
9
|
+
export declare function requireVariableSetEncryption(settings: Settings): Uint8Array;
|
|
10
|
+
/** @deprecated use requireVariableSetEncryption */
|
|
11
|
+
export declare const requireEnvironmentEncryption: typeof requireVariableSetEncryption;
|
|
12
|
+
export declare function requireVariableSetForApi(db: Database, workspaceId: string, variableSetId: string): Promise<VariableSet>;
|
|
13
|
+
/**
|
|
14
|
+
* Validates an variableSet attachment supplied in a request payload (session
|
|
15
|
+
* create, scheduled task create/update, pack enable). Requires the
|
|
16
|
+
* `variable-sets:use` permission unless the attachment was already authorized
|
|
17
|
+
* (pack-installation-inherited attachments), and maps a missing or
|
|
18
|
+
* cross-variable set to 422 because the id is payload, not the route
|
|
19
|
+
* target. RLS plus the workspace_id clause make cross-workspace ids
|
|
20
|
+
* indistinguishable from missing ones.
|
|
21
|
+
*/
|
|
22
|
+
export declare function validateVariableSetAttachment(deps: {
|
|
23
|
+
settings: Settings;
|
|
24
|
+
db: Database;
|
|
25
|
+
}, grant: AccessGrant, workspaceId: string, variableSetId: string, options?: {
|
|
26
|
+
preauthorized?: boolean;
|
|
27
|
+
}): Promise<VariableSet>;
|
|
28
|
+
export declare function recordVariableSetAuditEvent(db: Database, input: {
|
|
29
|
+
grant: AccessGrant;
|
|
30
|
+
action: "variable_set.created" | "variable_set.updated" | "variable_set.deleted" | "variable_set.variable.set" | "variable_set.variable.deleted";
|
|
31
|
+
variableSetId: string;
|
|
32
|
+
variableName?: string;
|
|
33
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Settings } from "@opengeni/config";
|
|
2
|
+
import { type InsightsRange, type WorkspaceInsightsResponse } from "@opengeni/contracts";
|
|
3
|
+
import { type Database } from "@opengeni/db";
|
|
4
|
+
export type GetWorkspaceInsightsInput = {
|
|
5
|
+
workspaceId: string;
|
|
6
|
+
range: InsightsRange;
|
|
7
|
+
provider?: string | null;
|
|
8
|
+
model?: string | null;
|
|
9
|
+
now?: Date;
|
|
10
|
+
};
|
|
11
|
+
export declare function getWorkspaceInsights(db: Database, settings: Settings, input: GetWorkspaceInsightsInput): Promise<WorkspaceInsightsResponse>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CapabilityPack, type ScheduledTaskAgentConfig, type SocialConnection } from "@opengeni/contracts";
|
|
2
|
+
import { type Database } from "@opengeni/db";
|
|
3
|
+
export declare const MARKETING_SOCIAL_PACK_ID = "marketing-social-daily-analysis";
|
|
4
|
+
export declare function listCapabilityPacks(): CapabilityPack[];
|
|
5
|
+
export declare function getCapabilityPack(packId: string): CapabilityPack | null;
|
|
6
|
+
export declare function isBuiltInCapabilityPack(packId: string): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Built-in packs plus the manifests registered for this workspace. Stored
|
|
9
|
+
* manifests were validated at registration time; rows that no longer parse
|
|
10
|
+
* (for example after a contract tightening) are skipped instead of breaking
|
|
11
|
+
* the whole catalog.
|
|
12
|
+
*/
|
|
13
|
+
export declare function listWorkspaceCapabilityPacks(db: Database, workspaceId: string): Promise<CapabilityPack[]>;
|
|
14
|
+
export declare function resolveCapabilityPack(db: Database, workspaceId: string, packId: string): Promise<CapabilityPack | null>;
|
|
15
|
+
/**
|
|
16
|
+
* v1 pack-scoped runtime rule: at most one enabled pack per workspace may
|
|
17
|
+
* declare a `sandboxImage` — there is deliberately no image composition or
|
|
18
|
+
* layering. Enforced when a pack is enabled (both the packs endpoint and the
|
|
19
|
+
* generic capability enable path) and re-checked at session start by the
|
|
20
|
+
* worker, which also covers manifests re-registered after enablement.
|
|
21
|
+
*/
|
|
22
|
+
export declare function assertPackSandboxImageCompatible(db: Database, workspaceId: string, pack: CapabilityPack): Promise<void>;
|
|
23
|
+
export declare function buildMarketingDailyAnalysisAgentConfig(input: {
|
|
24
|
+
connections: SocialConnection[];
|
|
25
|
+
documentBaseIds: string[];
|
|
26
|
+
promptInstructions?: string;
|
|
27
|
+
}): ScheduledTaskAgentConfig;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Settings } from "@opengeni/config";
|
|
2
|
+
import { mergeToolRefs, stableJson, type ResourceRef, type ToolRef } from "@opengeni/contracts";
|
|
3
|
+
import { type Database } from "@opengeni/db";
|
|
4
|
+
export declare function validateToolRefs(tools: ToolRef[], settings: McpSettings): ToolRef[];
|
|
5
|
+
type McpSettings = Pick<Settings, "mcpServers">;
|
|
6
|
+
export declare function enabledCapabilityMcpToolRefs(settings: McpSettings, runtimeSettings: McpSettings): ToolRef[];
|
|
7
|
+
export declare function withDefaultEnabledCapabilityMcpTools(tools: ToolRef[], settings: McpSettings, runtimeSettings: McpSettings): ToolRef[];
|
|
8
|
+
/** Drop stored refs that are no longer present in the current runtime registry. */
|
|
9
|
+
export declare function availableToolRefs(tools: ToolRef[], settings: McpSettings): ToolRef[];
|
|
10
|
+
/** A child or fixed-policy follow-up may narrow its allow-list, never widen it. */
|
|
11
|
+
export declare function assertToolRefsSubset(requested: ToolRef[], allowed: ToolRef[], message?: string): void;
|
|
12
|
+
/** Validate runtime availability and then enforce the durable policy fence. */
|
|
13
|
+
export declare function validateToolRefsForSessionPolicy(input: {
|
|
14
|
+
requested: ToolRef[];
|
|
15
|
+
settings: McpSettings;
|
|
16
|
+
allowedTools: ToolRef[];
|
|
17
|
+
message: string;
|
|
18
|
+
}): ToolRef[];
|
|
19
|
+
export declare function normalizeResources(resources: ResourceRef[]): ResourceRef[];
|
|
20
|
+
export declare function mergeResourceRefs(existing: ResourceRef[], additions: ResourceRef[]): ResourceRef[];
|
|
21
|
+
export declare function validateGitHubRepositorySelectionShapes(resources: ResourceRef[]): number[];
|
|
22
|
+
/** @deprecated Use validateGitHubRepositorySelectionShapes for multi-installation sessions. */
|
|
23
|
+
export declare function validateGitHubRepositorySelectionShape(resources: ResourceRef[]): number | null;
|
|
24
|
+
export declare function validateGitHubRepositorySelection(db: Database, workspaceId: string, resources: ResourceRef[]): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* A 422 from repository selection validation is an authoritative stale or
|
|
27
|
+
* revoked identity. Other failures (for example a database/catalog outage)
|
|
28
|
+
* leave the result unknown and must not cause draft hydration to delete it.
|
|
29
|
+
*/
|
|
30
|
+
export declare function isAuthoritativeGitHubRepositorySelectionError(error: unknown): boolean;
|
|
31
|
+
export declare function validateFileResources(db: Database, workspaceId: string, resources: ResourceRef[]): Promise<void>;
|
|
32
|
+
export { mergeToolRefs, stableJson };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { Settings } from "@opengeni/config";
|
|
2
|
+
import type { AccessGrant, ScheduledTask, CreateScheduledTaskRequest as CreateScheduledTaskPayload, UpdateScheduledTaskRequest as UpdateScheduledTaskPayload } from "@opengeni/contracts";
|
|
3
|
+
import { type Database, type UpdateScheduledTaskInput } from "@opengeni/db";
|
|
4
|
+
import type { SessionWorkflowClient } from "../dependencies";
|
|
5
|
+
import type { ObjectStorageDependency } from "../dependencies";
|
|
6
|
+
/**
|
|
7
|
+
* Whether a raw scheduled-task payload explicitly set agentConfig.tools.
|
|
8
|
+
* Zod's `.default([])` erases the distinction between "absent" and
|
|
9
|
+
* "explicitly empty", so callers detect it on the raw payload — the same
|
|
10
|
+
* contract sessions use: absent tools mean "give me the workspace defaults
|
|
11
|
+
* (enabled capability MCP servers)", an explicit list (even empty) is taken
|
|
12
|
+
* verbatim.
|
|
13
|
+
*/
|
|
14
|
+
export declare function scheduledTaskToolsProvided(rawPayload: unknown): boolean;
|
|
15
|
+
export declare function createValidatedScheduledTask(input: {
|
|
16
|
+
settings: Settings;
|
|
17
|
+
db: Database;
|
|
18
|
+
objectStorage: ObjectStorageDependency;
|
|
19
|
+
grant: AccessGrant;
|
|
20
|
+
payload: CreateScheduledTaskPayload;
|
|
21
|
+
toolsProvided?: boolean;
|
|
22
|
+
variableSetPreauthorized?: boolean;
|
|
23
|
+
}): Promise<ScheduledTask>;
|
|
24
|
+
export declare function validatedScheduledTaskUpdate(input: {
|
|
25
|
+
settings: Settings;
|
|
26
|
+
db: Database;
|
|
27
|
+
objectStorage: ObjectStorageDependency;
|
|
28
|
+
grant: AccessGrant;
|
|
29
|
+
existing: ScheduledTask;
|
|
30
|
+
payload: UpdateScheduledTaskPayload;
|
|
31
|
+
/** See createValidatedScheduledTask; only consulted when agentConfig is updated. */
|
|
32
|
+
toolsProvided?: boolean;
|
|
33
|
+
}): Promise<UpdateScheduledTaskInput>;
|
|
34
|
+
export declare function requireScheduledTaskForApi(db: Database, workspaceId: string, taskId: string): Promise<ScheduledTask>;
|
|
35
|
+
export declare function restoreScheduledTask(db: Database, task: ScheduledTask): Promise<ScheduledTask>;
|
|
36
|
+
export declare function syncCreatedScheduledTask(input: {
|
|
37
|
+
db: Database;
|
|
38
|
+
workflowClient: SessionWorkflowClient;
|
|
39
|
+
task: ScheduledTask;
|
|
40
|
+
}): Promise<void>;
|
|
41
|
+
export declare function syncUpdatedScheduledTask(input: {
|
|
42
|
+
db: Database;
|
|
43
|
+
workflowClient: SessionWorkflowClient;
|
|
44
|
+
previous: ScheduledTask;
|
|
45
|
+
task: ScheduledTask;
|
|
46
|
+
}): Promise<void>;
|
|
47
|
+
export declare function scheduledTaskTemporalScheduleId(taskId: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* Stable token that identifies a single logical manual trigger. A client that
|
|
50
|
+
* retries a `/trigger` POST (network blip, lambda re-invocation) passes the
|
|
51
|
+
* SAME token so the retry is idempotent — one usage charge, one workflow run.
|
|
52
|
+
* When the client supplies nothing we mint one UUID PER REQUEST and reuse it
|
|
53
|
+
* for both the idempotency key and the workflowId, so a single request stays
|
|
54
|
+
* internally consistent while two genuinely-distinct manual triggers (no token,
|
|
55
|
+
* fired a second apart) still each get their own run. The token is sanitized to
|
|
56
|
+
* the Temporal workflow-id-safe charset so a client value cannot smuggle a
|
|
57
|
+
* collision into a different task's id space.
|
|
58
|
+
*/
|
|
59
|
+
export declare function scheduledTaskTriggerToken(clientTriggerId?: string | null): string;
|
|
60
|
+
/**
|
|
61
|
+
* Deterministic Temporal workflow id for a manual trigger. Derived purely from
|
|
62
|
+
* the task id and the stable trigger token, so a retry with the same token maps
|
|
63
|
+
* to the same id and `workflowIdReusePolicy: "REJECT_DUPLICATE"` collapses the
|
|
64
|
+
* second start into a no-op instead of spawning a second run.
|
|
65
|
+
*/
|
|
66
|
+
export declare function manualScheduledTaskTriggerWorkflowId(taskId: string, triggerToken: string): string;
|
|
67
|
+
/**
|
|
68
|
+
* Deterministic usage idempotency key for a manual trigger's agent_run.created
|
|
69
|
+
* charge. Shares the stable trigger token with the workflow id so the charge
|
|
70
|
+
* and the run dedupe together under retry.
|
|
71
|
+
*/
|
|
72
|
+
export declare function manualScheduledTaskTriggerUsageKey(workspaceId: string, taskId: string, triggerToken: string): string;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Settings } from "@opengeni/config";
|
|
2
|
+
import { type Session, type SessionEffectiveToolPolicy, type SessionToolPolicy, type ToolRef } from "@opengeni/contracts";
|
|
3
|
+
import type { Database } from "@opengeni/db";
|
|
4
|
+
export type ResolvedSessionToolPolicy = {
|
|
5
|
+
toolRefs: ToolRef[];
|
|
6
|
+
effectivePolicy: SessionEffectiveToolPolicy;
|
|
7
|
+
};
|
|
8
|
+
export type SessionToolPolicyInput = {
|
|
9
|
+
toolPolicy: SessionToolPolicy;
|
|
10
|
+
sessionTools: ToolRef[];
|
|
11
|
+
availableMcpServerIds: Iterable<string>;
|
|
12
|
+
/** Current omitted-tools defaults, intentionally narrower than all servers. */
|
|
13
|
+
defaultMcpServerIds?: Iterable<string>;
|
|
14
|
+
};
|
|
15
|
+
/** Every configured runtime MCP defaults on; mandatory carrier IDs are separate. */
|
|
16
|
+
export declare function defaultSessionMcpServerIds(servers: Iterable<{
|
|
17
|
+
id: string;
|
|
18
|
+
}>): string[];
|
|
19
|
+
/**
|
|
20
|
+
* Resolve the same ID-only policy used by API projections and worker turns.
|
|
21
|
+
* This function never receives endpoint URLs, credentials, schemas, or live
|
|
22
|
+
* probe results. `availableMcpServerIds` is the resolved runtime registry;
|
|
23
|
+
* `defaultMcpServerIds` is the current configured omitted-tools default.
|
|
24
|
+
*/
|
|
25
|
+
export declare function resolveSessionToolPolicy(input: SessionToolPolicyInput): ResolvedSessionToolPolicy;
|
|
26
|
+
/** Current full runtime registry IDs, including configured static servers. */
|
|
27
|
+
export declare function workspaceSessionToolPolicyServerIds(db: Database, workspaceId: string, settings: Settings): Promise<string[]>;
|
|
28
|
+
/** Current omitted-tools defaults: every configured runtime MCP is on. */
|
|
29
|
+
export declare function workspaceSessionToolPolicyDefaultServerIds(db: Database, workspaceId: string, settings: Settings): Promise<string[]>;
|
|
30
|
+
/** Add a bounded, secret-safe effective projection to a session response. */
|
|
31
|
+
export declare function sessionWithEffectiveToolPolicy(session: Session, workspaceServerIds: Iterable<string>, workspaceDefaultServerIds?: Iterable<string>): Session;
|