@opengeni/api-router 0.12.7 → 0.14.3
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/app.d.ts +18 -38
- package/dist/app.js +3 -1
- package/dist/auth/managed-auth.d.ts +35 -0
- package/dist/{chunk-SD5GJTZ4.js → chunk-36PW33ND.js} +3744 -638
- package/dist/chunk-36PW33ND.js.map +1 -0
- package/dist/codex-redemption-security.d.ts +15 -0
- package/dist/github-access.d.ts +12 -0
- package/dist/github-browser-flow.d.ts +14 -0
- package/dist/http/auth.d.ts +3 -0
- package/dist/http/common.d.ts +3 -0
- package/dist/http/sse.d.ts +70 -0
- package/dist/index.d.ts +11 -13
- package/dist/index.js +1 -1
- package/dist/integrations/google-drive.d.ts +76 -0
- package/dist/integrations/oauth-client.d.ts +42 -0
- package/dist/integrations/provider-domain.d.ts +7 -0
- package/dist/integrations/slack-bot.d.ts +343 -0
- package/dist/mcp/documents.d.ts +8 -0
- package/dist/mcp/files.d.ts +5 -0
- package/dist/mcp/server.d.ts +107 -0
- package/dist/mcp/session-view.d.ts +191 -0
- package/dist/mcp/toolspace.d.ts +61 -0
- package/dist/model-catalog.d.ts +39 -0
- package/dist/observability.d.ts +3 -0
- package/dist/routes/api-keys.d.ts +3 -0
- package/dist/routes/billing.d.ts +16 -0
- package/dist/routes/capabilities.d.ts +3 -0
- package/dist/routes/catalog-assets.d.ts +5 -0
- package/dist/routes/codex.d.ts +10 -0
- package/dist/routes/connections.d.ts +3 -0
- package/dist/routes/documents.d.ts +3 -0
- package/dist/routes/enrollments.d.ts +3 -0
- package/dist/routes/environments.d.ts +5 -0
- package/dist/routes/files.d.ts +4 -0
- package/dist/routes/github.d.ts +3 -0
- package/dist/routes/insights.d.ts +3 -0
- package/dist/routes/install.d.ts +5 -0
- package/dist/routes/machines.d.ts +3 -0
- package/dist/routes/packs.d.ts +3 -0
- package/dist/routes/preference-registry.d.ts +5 -0
- package/dist/routes/rigs.d.ts +3 -0
- package/dist/routes/scheduled-tasks.d.ts +3 -0
- package/dist/routes/sessions.d.ts +15 -0
- package/dist/routes/social.d.ts +3 -0
- package/dist/routes/transcriptions.d.ts +3 -0
- package/dist/routes/workspace-capture.d.ts +59 -0
- package/dist/routes/workspace-instruction-policies.d.ts +3 -0
- package/dist/routes/workspace-state.d.ts +3 -0
- package/dist/routes/workspaces.d.ts +5 -0
- package/dist/sandbox/access.d.ts +21 -0
- package/dist/sandbox/auth-callout.d.ts +30 -0
- package/dist/sandbox/channel-a.d.ts +37 -0
- package/dist/sandbox/enrollment.d.ts +120 -0
- package/dist/sandbox/machines.d.ts +29 -0
- package/dist/sandbox/metrics-ingestion.d.ts +128 -0
- package/dist/sandbox/rematerialize.d.ts +24 -0
- package/dist/sandbox/viewer.d.ts +251 -0
- package/dist/transcription/providers/azure-openai.d.ts +9 -0
- package/dist/transcription/providers/codex-subscription.d.ts +9 -0
- package/dist/transcription/providers/openai.d.ts +9 -0
- package/dist/transcription/service.d.ts +10 -0
- package/dist/workspace-state-projection.d.ts +16 -0
- package/package.json +13 -13
- package/src/app.ts +75 -5
- package/src/github-access.ts +1 -0
- package/src/integrations/google-drive.ts +869 -0
- package/src/integrations/oauth-client.ts +41 -6
- package/src/integrations/slack-bot.ts +756 -26
- package/src/mcp/server.ts +226 -42
- package/src/mcp/session-view.ts +1 -0
- package/src/mcp/toolspace.ts +17 -9
- package/src/routes/connections.ts +137 -7
- package/src/routes/documents.ts +13 -2
- package/src/routes/github.ts +327 -20
- package/src/routes/insights.ts +30 -0
- package/src/routes/preference-registry.ts +482 -0
- package/src/routes/sessions.ts +22 -23
- package/src/routes/transcriptions.ts +155 -0
- package/src/routes/workspace-capture.ts +108 -8
- package/src/routes/workspace-state.ts +61 -0
- package/src/sandbox/channel-a.ts +2 -0
- package/src/sandbox/rematerialize.ts +111 -4
- package/src/sandbox/viewer.ts +29 -12
- package/src/transcription/providers/azure-openai.ts +45 -0
- package/src/transcription/providers/codex-subscription.ts +100 -0
- package/src/transcription/providers/openai.ts +93 -0
- package/src/transcription/service.ts +121 -0
- package/src/workspace-state-projection.ts +244 -0
- package/dist/chunk-SD5GJTZ4.js.map +0 -1
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { type AccessGrant } from "@opengeni/contracts";
|
|
2
|
+
import { listSessionDiscoverySummaries, type SessionDiscoveryCursor, type SessionDiscoveryOrderBy } from "@opengeni/db";
|
|
3
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
|
+
import type { ApiRouteDeps } from "@opengeni/core";
|
|
5
|
+
import type { ToolspaceMcpSurface } from "./toolspace";
|
|
6
|
+
export type McpServerOptions = {
|
|
7
|
+
requestOrigin?: string | null;
|
|
8
|
+
toolspace?: ToolspaceMcpSurface | null;
|
|
9
|
+
workspaceMemoryEnabled?: boolean | undefined;
|
|
10
|
+
};
|
|
11
|
+
export declare function buildOpenGeniMcpServer(deps: ApiRouteDeps, grant: AccessGrant, options?: McpServerOptions): McpServer;
|
|
12
|
+
/** Only a prompt explicitly supplied through the human/API channel may redirect a user-paused goal. */
|
|
13
|
+
export declare function isHumanDirectedTurn(turn: {
|
|
14
|
+
source: string;
|
|
15
|
+
}): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Sacred user pause: a goal a human paused (pausedReason 'user_pause') must
|
|
18
|
+
* never be resurrected by a MACHINE turn. Child-completion notification turns
|
|
19
|
+
* carry a "resume it now" nudge; without this guard the agent processing one of
|
|
20
|
+
* them would call goal_set and re-arm the exact autonomous loop the user just
|
|
21
|
+
* paused (the runaway that made Pause feel broken). A genuine user message
|
|
22
|
+
* still redirects freely (it is not a child-notification turn), and the
|
|
23
|
+
* human-driven API resume path (PATCH /goal) is unaffected.
|
|
24
|
+
*
|
|
25
|
+
* Classification is by CALLER IDENTITY — `callerTurnId` is the turn that minted
|
|
26
|
+
* this MCP token (signed into it by the worker at turn setup). We deliberately
|
|
27
|
+
* do NOT read the session's live `active_turn_id`: that pointer can flip to a
|
|
28
|
+
* different turn between reads (a machine turn ends and a human turn becomes
|
|
29
|
+
* active mid-check), which would misclassify the caller and, worst case, refuse
|
|
30
|
+
* a legitimate human `goal_set` — inverting the guard against the very human
|
|
31
|
+
* power it must preserve. A caller turn's source/metadata are immutable, so this
|
|
32
|
+
* read is race-free. No caller identity ⇒ fail OPEN (only a positively
|
|
33
|
+
* identified machine child-notification caller is refused).
|
|
34
|
+
*/
|
|
35
|
+
export declare function assertGoalReactivationAllowed(deps: ApiRouteDeps, workspaceId: string, sessionId: string, callerTurnId: string | null): Promise<void>;
|
|
36
|
+
export declare function encodeSessionDiscoveryCursor(cursor: SessionDiscoveryCursor): string;
|
|
37
|
+
export declare function decodeSessionDiscoveryCursor(value: string): SessionDiscoveryCursor;
|
|
38
|
+
export declare function capSessionDiscoveryPage(page: Awaited<ReturnType<typeof listSessionDiscoverySummaries>>, includeLastMessage: boolean): {
|
|
39
|
+
sessions: {
|
|
40
|
+
id: string;
|
|
41
|
+
title: string | null;
|
|
42
|
+
titleTruncated: boolean;
|
|
43
|
+
parentSessionId: string | null;
|
|
44
|
+
isRoot: boolean;
|
|
45
|
+
status: "cancelled" | "failed" | "idle" | "queued" | "recovering" | "requires_action" | "running" | "waiting_capacity";
|
|
46
|
+
pause: {
|
|
47
|
+
state: import("@opengeni/db").EffectiveControlState;
|
|
48
|
+
additionalBlockerCount: number;
|
|
49
|
+
source: {
|
|
50
|
+
kind: "session" | "workspace";
|
|
51
|
+
sessionId?: string;
|
|
52
|
+
displayName: string | null;
|
|
53
|
+
displayNameTruncated: boolean;
|
|
54
|
+
} | null;
|
|
55
|
+
};
|
|
56
|
+
goal: {
|
|
57
|
+
status: "active" | "completed" | "paused";
|
|
58
|
+
summary: string | null;
|
|
59
|
+
summaryTruncated: boolean;
|
|
60
|
+
} | null;
|
|
61
|
+
queuedPromptCount: number;
|
|
62
|
+
children: {
|
|
63
|
+
directChildren: number;
|
|
64
|
+
totalDescendants: number;
|
|
65
|
+
runningDescendants: number;
|
|
66
|
+
queuedDescendants: number;
|
|
67
|
+
attentionDescendants: number;
|
|
68
|
+
pausedDescendants: number;
|
|
69
|
+
failedDescendants: number;
|
|
70
|
+
truncated: boolean;
|
|
71
|
+
};
|
|
72
|
+
latestMessage?: {
|
|
73
|
+
type: "agent.message.completed" | "agent.message.delta" | "agent.model.request" | "agent.model.usage" | "agent.reasoning.delta" | "agent.toolCall.created" | "agent.toolCall.output" | "agent.updated" | "artifact.created" | "codex.account.switched" | "codex.capacity.resumed" | "codex.capacity.superseded" | "codex.capacity.waiting" | "codex.credential.selected" | "codex.fleet.decision" | "credential.auth_needed" | "fs.changed" | "git.changed" | "goal.cleared" | "goal.completed" | "goal.continuation" | "goal.paused" | "goal.resumed" | "goal.set" | "goal.updated" | "machine.link.lost" | "machine.link.restored" | "machine.op.failed" | "machine.op.recovered" | "machine.runner.restarted" | "memory.corrected" | "memory.saved" | "recording.available" | "recording.failed" | "recording.started" | "rig.setup.completed" | "rig.setup.failed" | "rig.setup.skipped" | "rig.setup.started" | "sandbox.box.created" | "sandbox.box.lost" | "sandbox.box.snapshot" | "sandbox.box.terminated" | "sandbox.command.output.delta" | "sandbox.env.drift" | "sandbox.operation.completed" | "sandbox.operation.failed" | "sandbox.operation.started" | "session.context.cleared" | "session.context.compacted" | "session.context.compaction.requested" | "session.context.compaction.skipped" | "session.context.compaction.started" | "session.control.paused" | "session.control.resumed" | "session.control.steer_requested" | "session.created" | "session.event.envelope_omitted" | "session.humanInput.requested" | "session.mcp.approval_policy.updated" | "session.queue.changed" | "session.queue.history" | "session.queue.prompt.cancelled" | "session.requiresAction" | "session.route.reconciled" | "session.status.changed" | "session.title_set" | "session.tool_policy.updated" | "stream.closed" | "stream.opened" | "stream.revoked" | "stream.url.rotated" | "system.update.cancelled" | "system.update.delivered" | "system.update.pending" | "system.update.settled" | "system.update.superseded" | "terminal.pty.exited" | "terminal.pty.output.delta" | "terminal.pty.started" | "tool.auth_needed" | "turn.cancelled" | "turn.capacity_waiting" | "turn.completed" | "turn.event.rejected_late" | "turn.failed" | "turn.queued" | "turn.recovery.requested" | "turn.started" | "turn.superseded" | "user.approvalDecision" | "user.humanInputResponse" | "user.message" | "user.pause" | "workspace.inference.paused" | "workspace.inference.resumed" | "workspace.revision.captured" | "workspace.revision.degraded";
|
|
74
|
+
preview: string | null;
|
|
75
|
+
previewTruncated: boolean;
|
|
76
|
+
} | null;
|
|
77
|
+
createdAt: string;
|
|
78
|
+
updatedAt: string;
|
|
79
|
+
}[];
|
|
80
|
+
total: number;
|
|
81
|
+
hasMore: boolean;
|
|
82
|
+
nextCursor: string | null;
|
|
83
|
+
orderBy: SessionDiscoveryOrderBy;
|
|
84
|
+
snapshotAt: string;
|
|
85
|
+
snapshotRevision: string;
|
|
86
|
+
updatedAfter: string | null;
|
|
87
|
+
updatedThrough: string | null;
|
|
88
|
+
latestMessagePreviewBudget?: {
|
|
89
|
+
bytes: number;
|
|
90
|
+
maxBytes: number;
|
|
91
|
+
omittedCount: number;
|
|
92
|
+
truncated: boolean;
|
|
93
|
+
omissionReason: "aggregatePreviewBudget" | null;
|
|
94
|
+
drillDownTool: "session_events";
|
|
95
|
+
drillDownInput: {
|
|
96
|
+
direction: "before";
|
|
97
|
+
limit: 1;
|
|
98
|
+
mode: "monitoring";
|
|
99
|
+
payloadMode: "summary";
|
|
100
|
+
includeTypes: readonly ["user.message", "agent.message.completed"];
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
responseTruncated: boolean;
|
|
104
|
+
truncationReason?: string;
|
|
105
|
+
bytes: number;
|
|
106
|
+
maxBytes: number;
|
|
107
|
+
};
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model-facing projections for cross-session monitoring tools.
|
|
3
|
+
*
|
|
4
|
+
* `session_events` reads are selected tail/forward and filtered in PostgreSQL;
|
|
5
|
+
* this module is the independent final guard before JSON enters a manager
|
|
6
|
+
* model's context. It measures the exact pretty-printed MCP text, trims fat
|
|
7
|
+
* payload fields, and—only if still required—removes rows from the pagination
|
|
8
|
+
* edge while preserving a usable cursor. It never manufactures an event or
|
|
9
|
+
* advances across an event it did not return.
|
|
10
|
+
*/
|
|
11
|
+
import type { Rig, Session, SessionEvent, SessionEventCompactResult, SessionEventPayloadMode, SessionEventReadDirection, SessionEventReadMode } from "@opengeni/contracts";
|
|
12
|
+
export declare const SESSION_EVENT_MCP_MAX_BYTES: number;
|
|
13
|
+
export declare const SESSION_EVENT_MCP_FIELD_MAX_CHARS = 4000;
|
|
14
|
+
export declare const DEFAULT_SESSION_DETAIL_CHARS = 6000;
|
|
15
|
+
export declare const SESSION_DETAIL_MCP_MAX_BYTES: number;
|
|
16
|
+
export declare const RIG_DETAIL_MCP_MAX_BYTES: number;
|
|
17
|
+
/**
|
|
18
|
+
* Keep the single-result MCP response below the same pretty-JSON envelope as
|
|
19
|
+
* event pages. The contracts projection bounds each value independently for
|
|
20
|
+
* HTTP/SDK use; this second boundary accounts for the result identity,
|
|
21
|
+
* failure/truncation metadata, and MCP's pretty-printing overhead.
|
|
22
|
+
*/
|
|
23
|
+
export declare function boundSessionEventCompactResult(result: SessionEventCompactResult, maxBytes?: number): SessionEventCompactResult;
|
|
24
|
+
/** Recursively clamp fat leaves and collapse pathological containers. */
|
|
25
|
+
export declare function capPayloadValue(value: unknown, perFieldChars: number, depth?: number): unknown;
|
|
26
|
+
export declare function capEventPayload(event: SessionEvent, perFieldChars: number): SessionEvent;
|
|
27
|
+
export type SessionEventMcpPageInput = {
|
|
28
|
+
events: readonly SessionEvent[];
|
|
29
|
+
mode: SessionEventReadMode;
|
|
30
|
+
payloadMode: SessionEventPayloadMode;
|
|
31
|
+
direction: SessionEventReadDirection;
|
|
32
|
+
sourceHasMore: boolean;
|
|
33
|
+
sourceTruncatedBy: "count" | "bytes" | null;
|
|
34
|
+
after: number;
|
|
35
|
+
before: number | null;
|
|
36
|
+
maxBytes?: number | undefined;
|
|
37
|
+
};
|
|
38
|
+
export type SessionEventMcpPage = {
|
|
39
|
+
mode: SessionEventReadMode;
|
|
40
|
+
payloadMode: SessionEventPayloadMode;
|
|
41
|
+
direction: SessionEventReadDirection;
|
|
42
|
+
events: SessionEvent[];
|
|
43
|
+
coveredSequence: {
|
|
44
|
+
first: number;
|
|
45
|
+
last: number;
|
|
46
|
+
} | null;
|
|
47
|
+
nextAfter: number | null;
|
|
48
|
+
nextBefore: number | null;
|
|
49
|
+
hasMore: boolean;
|
|
50
|
+
truncated: boolean;
|
|
51
|
+
truncation?: {
|
|
52
|
+
reasons: Array<"source_count" | "source_bytes" | "model_payload" | "model_bytes">;
|
|
53
|
+
omittedSide: "before" | "after";
|
|
54
|
+
resumeCursor: number | null;
|
|
55
|
+
};
|
|
56
|
+
bytes: number;
|
|
57
|
+
maxBytes: number;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Build the exact model-visible page. Returned `bytes` includes all metadata
|
|
61
|
+
* and pretty-printing used by the MCP JSON adapter.
|
|
62
|
+
*/
|
|
63
|
+
export declare function boundSessionEventMcpPage(input: SessionEventMcpPageInput): SessionEventMcpPage;
|
|
64
|
+
type SessionDetailFieldFact = {
|
|
65
|
+
truncated: boolean;
|
|
66
|
+
originalBytes: number | null;
|
|
67
|
+
deliveredBytes: number;
|
|
68
|
+
originalCount?: number;
|
|
69
|
+
deliveredCount?: number;
|
|
70
|
+
measurementBounded?: boolean;
|
|
71
|
+
};
|
|
72
|
+
/** Purpose-built, flat, model-facing detail projection for `session_get`. */
|
|
73
|
+
export declare function boundSessionDetailMcp(session: Session, effectiveControl?: unknown, maxBytes?: number): {
|
|
74
|
+
id: string;
|
|
75
|
+
workspaceId: string;
|
|
76
|
+
accountId: string;
|
|
77
|
+
status: "cancelled" | "failed" | "idle" | "queued" | "recovering" | "requires_action" | "running" | "waiting_capacity";
|
|
78
|
+
title: string | null;
|
|
79
|
+
titleSource: "agent" | "user" | null;
|
|
80
|
+
initialMessage: string;
|
|
81
|
+
instructions: string | null;
|
|
82
|
+
resources: unknown;
|
|
83
|
+
tools: unknown;
|
|
84
|
+
metadata: unknown;
|
|
85
|
+
model: string;
|
|
86
|
+
sandboxBackend: string;
|
|
87
|
+
sandboxOs: "linux" | "macos" | "windows";
|
|
88
|
+
sandboxGroupId: string;
|
|
89
|
+
activeSandboxId: string | null;
|
|
90
|
+
activeEpoch: number;
|
|
91
|
+
variableSetId: string | null;
|
|
92
|
+
environmentId: string | null;
|
|
93
|
+
rigId: string | null;
|
|
94
|
+
rigVersionId: string | null;
|
|
95
|
+
firstPartyMcpPermissions: unknown;
|
|
96
|
+
mcpServers: unknown;
|
|
97
|
+
parentSessionId: string | null;
|
|
98
|
+
createIdempotencyKey: string | null;
|
|
99
|
+
temporalWorkflowId: string | null;
|
|
100
|
+
activeTurnId: string | null;
|
|
101
|
+
lastInputTokens: number | null;
|
|
102
|
+
queueVersion: number;
|
|
103
|
+
queueHeadPosition: number;
|
|
104
|
+
queueTailPosition: number;
|
|
105
|
+
effectiveControl: unknown;
|
|
106
|
+
lastSequence: number;
|
|
107
|
+
codexPinnedCredentialId: string | null;
|
|
108
|
+
codexLastCredentialId: string | null;
|
|
109
|
+
codexCompactionMode: "portable" | "remote_v2";
|
|
110
|
+
pinned: boolean;
|
|
111
|
+
pinnedAt: string | null;
|
|
112
|
+
pinVersion: number;
|
|
113
|
+
treeStats?: {
|
|
114
|
+
directChildren: number;
|
|
115
|
+
totalDescendants: number;
|
|
116
|
+
runningDescendants: number;
|
|
117
|
+
queuedDescendants: number;
|
|
118
|
+
attentionDescendants: number;
|
|
119
|
+
pausedDescendants: number;
|
|
120
|
+
failedDescendants: number;
|
|
121
|
+
truncated: boolean;
|
|
122
|
+
};
|
|
123
|
+
createdAt: string;
|
|
124
|
+
updatedAt: string;
|
|
125
|
+
projection: {
|
|
126
|
+
truncated: boolean;
|
|
127
|
+
fields: Record<string, SessionDetailFieldFact>;
|
|
128
|
+
details: string[];
|
|
129
|
+
bytes: number;
|
|
130
|
+
maxBytes: number;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
/** @deprecated use boundSessionDetailMcp for the actual MCP response. */
|
|
134
|
+
export declare function capSessionDetail<T extends {
|
|
135
|
+
metadata?: unknown;
|
|
136
|
+
initialMessage?: unknown;
|
|
137
|
+
}>(session: T, perFieldChars?: number): T;
|
|
138
|
+
/** Bounded current definition plus compact-by-query historical rig summaries. */
|
|
139
|
+
export declare function boundRigDetailMcp(rig: Rig, versionsPage: {
|
|
140
|
+
versions: unknown[];
|
|
141
|
+
total: number;
|
|
142
|
+
hasMore: boolean;
|
|
143
|
+
}, changesPage: {
|
|
144
|
+
changes: unknown[];
|
|
145
|
+
total: number;
|
|
146
|
+
hasMore: boolean;
|
|
147
|
+
}, maxBytes?: number): {
|
|
148
|
+
rig: {
|
|
149
|
+
id: string;
|
|
150
|
+
accountId: string;
|
|
151
|
+
workspaceId: string;
|
|
152
|
+
name: string;
|
|
153
|
+
description: string | null;
|
|
154
|
+
createdBy: string | null;
|
|
155
|
+
activeVersion: {
|
|
156
|
+
id: string;
|
|
157
|
+
rigId: string;
|
|
158
|
+
version: number;
|
|
159
|
+
image: string | null;
|
|
160
|
+
setupScript: string | null;
|
|
161
|
+
checks: unknown;
|
|
162
|
+
credentialHooks: unknown;
|
|
163
|
+
defaultVariableSetIds: unknown;
|
|
164
|
+
changelog: string | null;
|
|
165
|
+
createdBy: string | null;
|
|
166
|
+
active: boolean;
|
|
167
|
+
createdAt: string;
|
|
168
|
+
} | null;
|
|
169
|
+
activeVersionHealth: {
|
|
170
|
+
checkHealth: "failing" | "passing" | "unknown";
|
|
171
|
+
lastVerifiedAt: string | null;
|
|
172
|
+
} | null;
|
|
173
|
+
versionCount: number;
|
|
174
|
+
createdAt: string;
|
|
175
|
+
updatedAt: string;
|
|
176
|
+
};
|
|
177
|
+
versions: unknown;
|
|
178
|
+
versionsTotal: number;
|
|
179
|
+
versionsTruncated: boolean;
|
|
180
|
+
changes: unknown;
|
|
181
|
+
changesTotal: number;
|
|
182
|
+
changesTruncated: boolean;
|
|
183
|
+
projection: {
|
|
184
|
+
truncated: boolean;
|
|
185
|
+
fields: Record<string, SessionDetailFieldFact>;
|
|
186
|
+
details: string[];
|
|
187
|
+
bytes: number;
|
|
188
|
+
maxBytes: number;
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
import { type McpServerConfig } from "@opengeni/config";
|
|
3
|
+
import { type AccessGrant, type SessionTurn } from "@opengeni/contracts";
|
|
4
|
+
import { type ApiRouteDeps } from "@opengeni/core";
|
|
5
|
+
import { type FetchLike } from "@opengeni/network";
|
|
6
|
+
export type ToolspaceCallResult = CallToolResult;
|
|
7
|
+
export type ToolspaceRegisteredTool = {
|
|
8
|
+
name: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
inputSchema?: Record<string, unknown>;
|
|
11
|
+
call: (args: Record<string, unknown>) => Promise<ToolspaceCallResult>;
|
|
12
|
+
};
|
|
13
|
+
export type ToolspaceMcpSurface = {
|
|
14
|
+
sessionId: string;
|
|
15
|
+
subjectId: string;
|
|
16
|
+
tools: ToolspaceRegisteredTool[];
|
|
17
|
+
close: () => Promise<void>;
|
|
18
|
+
};
|
|
19
|
+
type McpTool = {
|
|
20
|
+
name: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
inputSchema?: Record<string, unknown>;
|
|
23
|
+
};
|
|
24
|
+
export type ToolListingEntry = {
|
|
25
|
+
serverId: string;
|
|
26
|
+
tool: McpTool;
|
|
27
|
+
requireApproval: McpServerConfig["requireApproval"];
|
|
28
|
+
};
|
|
29
|
+
/** Deterministic LRU bounded by both key count and serialized retained bytes. */
|
|
30
|
+
export declare class ToolspaceToolListCache {
|
|
31
|
+
private readonly maxEntries;
|
|
32
|
+
private readonly maxBytes;
|
|
33
|
+
private readonly ttlMs;
|
|
34
|
+
private readonly values;
|
|
35
|
+
private retainedBytes;
|
|
36
|
+
constructor(maxEntries?: number, maxBytes?: number, ttlMs?: number);
|
|
37
|
+
read(key: string, now?: number): ToolListingEntry[] | null;
|
|
38
|
+
write(key: string, entries: ToolListingEntry[], now?: number): boolean;
|
|
39
|
+
clear(): void;
|
|
40
|
+
snapshot(): {
|
|
41
|
+
entries: number;
|
|
42
|
+
bytes: number;
|
|
43
|
+
keys: string[];
|
|
44
|
+
};
|
|
45
|
+
private delete;
|
|
46
|
+
}
|
|
47
|
+
export declare function isToolspaceGrant(settings: ApiRouteDeps["settings"], grant: AccessGrant): boolean;
|
|
48
|
+
export declare function prepareToolspaceMcpSurface(input: {
|
|
49
|
+
deps: ApiRouteDeps;
|
|
50
|
+
grant: AccessGrant;
|
|
51
|
+
}): Promise<ToolspaceMcpSurface | null>;
|
|
52
|
+
export declare function toolspaceCanProxyServerId(serverId: string): boolean;
|
|
53
|
+
export declare function connectionBrokerFetch(baseFetch: FetchLike, input: {
|
|
54
|
+
deps: ApiRouteDeps;
|
|
55
|
+
grant: AccessGrant;
|
|
56
|
+
config: McpServerConfig;
|
|
57
|
+
sessionId: string;
|
|
58
|
+
rootSessionId: string;
|
|
59
|
+
turn: SessionTurn;
|
|
60
|
+
}): FetchLike;
|
|
61
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type ConfiguredModel, type Settings } from "@opengeni/config";
|
|
2
|
+
import { ClientModel, type WorkspaceModelCatalogResponse as WorkspaceModelCatalogResponseType, type WorkspaceModelPolicyContract } from "@opengeni/contracts";
|
|
3
|
+
export type ModelAvailabilityObservation = {
|
|
4
|
+
status: "available" | "degraded" | "unavailable";
|
|
5
|
+
reason: "not_entitled" | "provider_unhealthy" | null;
|
|
6
|
+
checkedAt: string;
|
|
7
|
+
};
|
|
8
|
+
export type ModelCredentialReadinessObservation = {
|
|
9
|
+
status: "ready";
|
|
10
|
+
checkedAt: string;
|
|
11
|
+
} | {
|
|
12
|
+
status: "not_ready";
|
|
13
|
+
reason: "prerequisites_missing" | "needs_reauth";
|
|
14
|
+
checkedAt: string;
|
|
15
|
+
} | {
|
|
16
|
+
status: "error";
|
|
17
|
+
reason: "resolver_error";
|
|
18
|
+
checkedAt: string;
|
|
19
|
+
};
|
|
20
|
+
export declare const MODEL_CREDENTIAL_READINESS_OBSERVATION_MAX_AGE_MS: number;
|
|
21
|
+
/** Static, client-safe definition projection. No provider secret is reachable. */
|
|
22
|
+
export declare function projectClientModel(model: ConfiguredModel): ClientModel;
|
|
23
|
+
/**
|
|
24
|
+
* Authenticated workspace catalog. Codex definitions are included only when
|
|
25
|
+
* the deployment enables that connection type; concrete readiness is supplied
|
|
26
|
+
* by the existing metadata-only DB seam. API-key presence establishes only
|
|
27
|
+
* local configuration readiness. Federated/token credentials require a fresh,
|
|
28
|
+
* successful typed resolver observation; credential health and provider health
|
|
29
|
+
* are separate inputs and neither is fabricated.
|
|
30
|
+
*/
|
|
31
|
+
export declare function buildWorkspaceModelCatalog(input: {
|
|
32
|
+
settings: Settings;
|
|
33
|
+
policy: WorkspaceModelPolicyContract | null;
|
|
34
|
+
codexSubscriptionActive: boolean;
|
|
35
|
+
credentialReadinessObservations?: Readonly<Record<string, ModelCredentialReadinessObservation>> | undefined;
|
|
36
|
+
observations?: Readonly<Record<string, ModelAvailabilityObservation>> | undefined;
|
|
37
|
+
now?: Date | undefined;
|
|
38
|
+
credentialReadinessMaxAgeMs?: number | undefined;
|
|
39
|
+
}): WorkspaceModelCatalogResponseType;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Hono } from "hono";
|
|
2
|
+
import Stripe from "stripe";
|
|
3
|
+
import type { ApiRouteDeps } from "@opengeni/core";
|
|
4
|
+
export declare function registerBillingRoutes(app: Hono, deps: ApiRouteDeps): void;
|
|
5
|
+
export declare function stripeCheckoutSessionCreateParams(input: {
|
|
6
|
+
accountId: string;
|
|
7
|
+
customerId: string;
|
|
8
|
+
amountCents: number;
|
|
9
|
+
amountMicros: number;
|
|
10
|
+
creditsProductId?: string | undefined;
|
|
11
|
+
publicBaseUrl?: string | undefined;
|
|
12
|
+
successUrl?: string | undefined;
|
|
13
|
+
cancelUrl?: string | undefined;
|
|
14
|
+
idempotencyKey: string;
|
|
15
|
+
}): Stripe.Checkout.SessionCreateParams;
|
|
16
|
+
export declare function stripeCustomerProvider(input: ApiRouteDeps | Stripe.Event): "stripe:live" | "stripe:test";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Hono } from "hono";
|
|
2
|
+
import type { ApiRouteDeps } from "@opengeni/core";
|
|
3
|
+
export declare function registerCatalogAssetRoutes(app: Hono, deps: ApiRouteDeps): void;
|
|
4
|
+
/** Decoded, validated storage key from a `/v1/catalog-assets/...` request path, or null if malformed/unsafe. */
|
|
5
|
+
export declare function catalogAssetKeyFromPath(pathname: string): string | null;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function codexModelsForPicker(liveSlugs: readonly string[]): Array<{
|
|
2
|
+
id: string;
|
|
3
|
+
label: string;
|
|
4
|
+
provider: string;
|
|
5
|
+
providerLabel: string;
|
|
6
|
+
api: "responses";
|
|
7
|
+
}>;
|
|
8
|
+
import { type ApiRouteDeps } from "@opengeni/core";
|
|
9
|
+
import type { Hono } from "hono";
|
|
10
|
+
export declare function registerCodexRoutes(app: Hono, deps: ApiRouteDeps): void;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Hono } from "hono";
|
|
2
|
+
import type { ApiRouteDeps } from "@opengeni/core";
|
|
3
|
+
export declare function registerVariableSetRoutes(app: Hono, deps: ApiRouteDeps): void;
|
|
4
|
+
/** @deprecated use registerVariableSetRoutes */
|
|
5
|
+
export declare const registerEnvironmentRoutes: typeof registerVariableSetRoutes;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Hono } from "hono";
|
|
2
|
+
import type { ApiRouteDeps } from "@opengeni/core";
|
|
3
|
+
export declare function registerInstallRoutes(app: Hono, deps: ApiRouteDeps): void;
|
|
4
|
+
export declare const installExactPaths: ReadonlySet<string>;
|
|
5
|
+
export declare function isInstallRedirectPath(path: string): boolean;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type PreferenceRegistryScope } from "@opengeni/contracts";
|
|
2
|
+
import { type AccessGrantAuthorization, type ApiRouteDeps } from "@opengeni/core";
|
|
3
|
+
import type { Hono } from "hono";
|
|
4
|
+
export declare function authorizePreferenceRegistryScopeMutation(access: AccessGrantAuthorization, scope: PreferenceRegistryScope): void;
|
|
5
|
+
export declare function registerPreferenceRegistryRoutes(app: Hono, deps: ApiRouteDeps): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type SessionAuthorizationOperation } from "@opengeni/contracts";
|
|
2
|
+
import type { Context, Hono } from "hono";
|
|
3
|
+
import type { ApiRouteDeps } from "@opengeni/core";
|
|
4
|
+
import { type ViewerServices } from "../sandbox/viewer";
|
|
5
|
+
type SessionRouteDeps = ApiRouteDeps & Pick<ViewerServices, "establishSandboxSession">;
|
|
6
|
+
export declare function registerSessionRoutes(app: Hono, deps: SessionRouteDeps): void;
|
|
7
|
+
/**
|
|
8
|
+
* Map every mounted session-addressed HTTP path to the host-neutral operation
|
|
9
|
+
* the embedding port authorizes. Returning null is deliberately fail-closed in
|
|
10
|
+
* host-managed mode; standalone deployments never consult this classifier.
|
|
11
|
+
*/
|
|
12
|
+
export declare function sessionAuthorizationOperationForHttp(method: string, pathname: string, sessionId: string): SessionAuthorizationOperation | null;
|
|
13
|
+
/** Stable, value-free JSON errors for only the create-session boundary. */
|
|
14
|
+
export declare function sessionCreateErrorResponse(c: Context, error: unknown): Response;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { GetWorkspaceCaptureFileResponse, GetWorkspaceCaptureResponse, WorkspaceCaptureManifest, WorkspaceCaptureStats } from "@opengeni/contracts";
|
|
2
|
+
import type { WorkspaceCaptureRow } from "@opengeni/db";
|
|
3
|
+
export declare const CAPTURE_INLINE_MANIFEST_MAX_BYTES: number;
|
|
4
|
+
export declare const CAPTURE_INLINE_FILE_MAX_BYTES: number;
|
|
5
|
+
export declare const CAPTURE_SIGNED_URL_TTL_SECONDS = 300;
|
|
6
|
+
export type CaptureStoragePort = {
|
|
7
|
+
getObjectBytes: (key: string) => Promise<{
|
|
8
|
+
bytes: Uint8Array;
|
|
9
|
+
} | null>;
|
|
10
|
+
createGetUrl: (args: {
|
|
11
|
+
key: string;
|
|
12
|
+
expiresInSeconds?: number;
|
|
13
|
+
}) => Promise<{
|
|
14
|
+
url: string;
|
|
15
|
+
expiresAt: Date;
|
|
16
|
+
}>;
|
|
17
|
+
};
|
|
18
|
+
type LoadedManifest = {
|
|
19
|
+
manifest: WorkspaceCaptureManifest;
|
|
20
|
+
byteLength: number;
|
|
21
|
+
stats: WorkspaceCaptureStats;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Process-local cache for immutable capture manifests. Capture rows point at a
|
|
25
|
+
* revision-specific object key, so a successfully validated blob is safe to
|
|
26
|
+
* reuse as long as the row identity still matches. Both entry count and bytes
|
|
27
|
+
* are bounded; large signed-manifest responses bypass the cache.
|
|
28
|
+
*/
|
|
29
|
+
export declare class WorkspaceCaptureManifestCache {
|
|
30
|
+
#private;
|
|
31
|
+
readonly maxEntries: number;
|
|
32
|
+
readonly maxBytes: number;
|
|
33
|
+
constructor(maxEntries?: number, maxBytes?: number);
|
|
34
|
+
get(row: WorkspaceCaptureRow): LoadedManifest | null;
|
|
35
|
+
getInlineResponse(row: WorkspaceCaptureRow): Extract<GetWorkspaceCaptureResponse, {
|
|
36
|
+
available: true;
|
|
37
|
+
}> | null;
|
|
38
|
+
setInlineResponse(row: WorkspaceCaptureRow, response: Extract<GetWorkspaceCaptureResponse, {
|
|
39
|
+
available: true;
|
|
40
|
+
}>): void;
|
|
41
|
+
set(row: WorkspaceCaptureRow, loaded: LoadedManifest): void;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Shape the GET …/workspace/capture response from a loaded row. `{available:false}`
|
|
45
|
+
* when there is no capture yet, the row is not in the `available` state, or its
|
|
46
|
+
* manifest blob has been GC'd (all graceful cold-fallback states — never errors).
|
|
47
|
+
* Inline manifest for ≤2MB, signed URL above.
|
|
48
|
+
*/
|
|
49
|
+
export declare function serveWorkspaceCapture(row: WorkspaceCaptureRow | null, storage: CaptureStoragePort, cache?: WorkspaceCaptureManifestCache): Promise<GetWorkspaceCaptureResponse>;
|
|
50
|
+
/**
|
|
51
|
+
* Shape the GET …/workspace/capture/file response from a loaded row (the row
|
|
52
|
+
* already resolved to the requested revision, or the latest). Throws
|
|
53
|
+
* HTTPException(404) when there is no capture, the path is not in the manifest,
|
|
54
|
+
* or the file was deleted. Returns a metadata-only marker for a tooLarge file (or
|
|
55
|
+
* a captured file whose after-image blob is missing). Inline content for ≤256KB,
|
|
56
|
+
* signed URL above.
|
|
57
|
+
*/
|
|
58
|
+
export declare function serveWorkspaceCaptureFile(row: WorkspaceCaptureRow | null, path: string, storage: CaptureStoragePort): Promise<GetWorkspaceCaptureFileResponse>;
|
|
59
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Hono } from "hono";
|
|
2
|
+
import type { ApiRouteDeps } from "@opengeni/core";
|
|
3
|
+
import { type Settings } from "@opengeni/config";
|
|
4
|
+
export declare function canonicalWorkspacePolicyModelIds(settings: Settings, modelIds: string[] | null | undefined): string[] | null;
|
|
5
|
+
export declare function registerWorkspaceRoutes(app: Hono, deps: ApiRouteDeps): void;
|