@opengeni/db 0.19.0 → 0.22.1
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/{chunk-XOXEQ7HG.js → chunk-BNGEN5QZ.js} +85 -1
- package/dist/chunk-BNGEN5QZ.js.map +1 -0
- package/dist/{chunk-SZP6KRLC.js → chunk-CYGFLLMN.js} +2698 -1918
- package/dist/chunk-CYGFLLMN.js.map +1 -0
- package/dist/index.d.ts +108 -1
- package/dist/index.js +5940 -2907
- package/dist/index.js.map +1 -1
- package/dist/provision-roles.js +1 -1
- package/dist/runtime-posture.d.ts +4 -4
- package/dist/schema.d.ts +1147 -101
- package/dist/schema.js +37 -1
- package/dist/scoped-knowledge-schema.d.ts +5341 -0
- package/dist/scoped-knowledge.d.ts +208 -0
- package/dist/session-control.d.ts +1 -0
- package/dist/session-queue-commands.d.ts +2 -1
- package/drizzle/0153_mcp_personal_connection_delegations.sql +181 -0
- package/drizzle/0154_scoped_knowledge_foundation.sql +2292 -0
- package/drizzle/0155_connector_action_policies.sql +218 -0
- package/package.json +3 -3
- package/src/connection-token-resolver.ts +3 -0
- package/src/index.ts +1211 -7
- package/src/provision-roles.ts +48 -0
- package/src/runtime-posture.ts +36 -0
- package/src/schema.ts +228 -2
- package/src/scoped-knowledge-schema.ts +603 -0
- package/src/scoped-knowledge.ts +2891 -0
- package/src/session-control.ts +3 -0
- package/src/session-queue-commands.ts +48 -0
- package/dist/chunk-SZP6KRLC.js.map +0 -1
- package/dist/chunk-XOXEQ7HG.js.map +0 -1
package/src/session-control.ts
CHANGED
|
@@ -519,6 +519,7 @@ export async function registerSessionTurnAttemptClaim(
|
|
|
519
519
|
temporalActivityId: string;
|
|
520
520
|
verifiedControlRevision: number;
|
|
521
521
|
mcpApprovalPolicies: Record<string, SessionMcpApprovalPolicy>;
|
|
522
|
+
connectorActionPolicies: schema.ConnectorActionPolicySnapshotEntry[];
|
|
522
523
|
},
|
|
523
524
|
): Promise<typeof schema.sessionTurnAttempts.$inferSelect> {
|
|
524
525
|
const [inserted] = await db
|
|
@@ -554,6 +555,8 @@ export async function registerSessionTurnAttemptClaim(
|
|
|
554
555
|
existing.temporalWorkflowId !== input.temporalWorkflowId ||
|
|
555
556
|
existing.temporalWorkflowRunId !== input.temporalWorkflowRunId ||
|
|
556
557
|
existing.temporalActivityId !== input.temporalActivityId ||
|
|
558
|
+
JSON.stringify(existing.connectorActionPolicies) !==
|
|
559
|
+
JSON.stringify(input.connectorActionPolicies) ||
|
|
557
560
|
existing.state === "closed"
|
|
558
561
|
) {
|
|
559
562
|
throw new SessionControlInvariantError(
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
+
McpPersonalConnectionDelegations,
|
|
2
3
|
metadataWithTurnExecutionPolicyV1,
|
|
3
4
|
mergeResourceRefs,
|
|
4
5
|
ResourceRef,
|
|
5
6
|
resourceMountPath,
|
|
6
7
|
stableJson,
|
|
7
8
|
turnExecutionPolicyAuditMetadata,
|
|
9
|
+
type McpPersonalConnectionDelegation,
|
|
8
10
|
type LatencyMode,
|
|
9
11
|
type ReasoningEffort,
|
|
10
12
|
type TurnExecutionPolicyV1,
|
|
@@ -107,6 +109,36 @@ export type AgentInternalUpdateCommandResult = {
|
|
|
107
109
|
replay: boolean;
|
|
108
110
|
};
|
|
109
111
|
|
|
112
|
+
async function personalConnectionDelegationsForAgentActor(
|
|
113
|
+
db: Database,
|
|
114
|
+
workspaceId: string,
|
|
115
|
+
actor: Extract<SessionCommandActor, { type: "agent_attempt" }>,
|
|
116
|
+
): Promise<McpPersonalConnectionDelegation[]> {
|
|
117
|
+
const [row] = await db
|
|
118
|
+
.select({ delegations: schema.sessionTurns.personalConnectionDelegations })
|
|
119
|
+
.from(schema.sessionTurns)
|
|
120
|
+
.where(
|
|
121
|
+
and(
|
|
122
|
+
eq(schema.sessionTurns.workspaceId, workspaceId),
|
|
123
|
+
eq(schema.sessionTurns.sessionId, actor.sessionId),
|
|
124
|
+
eq(schema.sessionTurns.id, actor.turnId),
|
|
125
|
+
),
|
|
126
|
+
)
|
|
127
|
+
.limit(1);
|
|
128
|
+
if (!row) {
|
|
129
|
+
throw new SessionControlInvariantError(
|
|
130
|
+
`Agent authority turn not found: ${actor.sessionId}/${actor.turnId}`,
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
const parsed = McpPersonalConnectionDelegations.safeParse(row.delegations);
|
|
134
|
+
if (!parsed.success) {
|
|
135
|
+
throw new SessionControlInvariantError(
|
|
136
|
+
`Agent authority turn has malformed personal MCP delegation state: ${actor.sessionId}/${actor.turnId}`,
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
return parsed.data.map((delegation) => ({ ...delegation }));
|
|
140
|
+
}
|
|
141
|
+
|
|
110
142
|
async function lockSession(
|
|
111
143
|
db: Database,
|
|
112
144
|
workspaceId: string,
|
|
@@ -1154,6 +1186,7 @@ export async function submitHumanPromptInTransaction(
|
|
|
1154
1186
|
/** Trusted API/core admission snapshot. Omitted only by legacy low-level callers. */
|
|
1155
1187
|
turnExecutionPolicy?: TurnExecutionPolicyV1;
|
|
1156
1188
|
source: "user" | "api";
|
|
1189
|
+
personalConnectionDelegations?: McpPersonalConnectionDelegation[];
|
|
1157
1190
|
mcpCredentialUpdates?: Array<{
|
|
1158
1191
|
id: string;
|
|
1159
1192
|
headersEncrypted: Record<string, string>;
|
|
@@ -1452,6 +1485,9 @@ export async function submitHumanPromptInTransaction(
|
|
|
1452
1485
|
: {},
|
|
1453
1486
|
lineage: { actor: input.actor.type },
|
|
1454
1487
|
...initiatorColumns(frozenInitiator),
|
|
1488
|
+
personalConnectionDelegations: editedSourceTurn
|
|
1489
|
+
? editedSourceTurn.personalConnectionDelegations
|
|
1490
|
+
: (input.personalConnectionDelegations ?? []),
|
|
1455
1491
|
})
|
|
1456
1492
|
.returning();
|
|
1457
1493
|
if (!turn) throw new SessionControlInvariantError("Prompt turn was not inserted");
|
|
@@ -1720,6 +1756,11 @@ export async function sendAgentMessageInTransaction(
|
|
|
1720
1756
|
targetSessionId: input.targetSessionId,
|
|
1721
1757
|
action: "message",
|
|
1722
1758
|
});
|
|
1759
|
+
const personalConnectionDelegations = await personalConnectionDelegationsForAgentActor(
|
|
1760
|
+
db,
|
|
1761
|
+
input.workspaceId,
|
|
1762
|
+
input.actor,
|
|
1763
|
+
);
|
|
1723
1764
|
const session = await lockSession(db, input.workspaceId, input.targetSessionId);
|
|
1724
1765
|
if (session.status === "cancelled") {
|
|
1725
1766
|
throw new QueueCommandConflictError(
|
|
@@ -1754,6 +1795,7 @@ export async function sendAgentMessageInTransaction(
|
|
|
1754
1795
|
callerAttemptId: input.actor.attemptId,
|
|
1755
1796
|
callerExecutionGeneration: input.actor.executionGeneration,
|
|
1756
1797
|
},
|
|
1798
|
+
personalConnectionDelegations,
|
|
1757
1799
|
state: "pending",
|
|
1758
1800
|
})
|
|
1759
1801
|
.returning({ id: schema.sessionSystemUpdates.id });
|
|
@@ -1893,6 +1935,11 @@ export async function steerAgentSessionInTransaction(
|
|
|
1893
1935
|
targetSessionId: input.targetSessionId,
|
|
1894
1936
|
action: "steer",
|
|
1895
1937
|
});
|
|
1938
|
+
const personalConnectionDelegations = await personalConnectionDelegationsForAgentActor(
|
|
1939
|
+
db,
|
|
1940
|
+
input.workspaceId,
|
|
1941
|
+
input.actor,
|
|
1942
|
+
);
|
|
1896
1943
|
const resumed = await autoResumeSessionBranchInTransaction(db, {
|
|
1897
1944
|
workspaceId: input.workspaceId,
|
|
1898
1945
|
sessionId: input.targetSessionId,
|
|
@@ -1952,6 +1999,7 @@ export async function steerAgentSessionInTransaction(
|
|
|
1952
1999
|
callerAttemptId: input.actor.attemptId,
|
|
1953
2000
|
callerExecutionGeneration: input.actor.executionGeneration,
|
|
1954
2001
|
},
|
|
2002
|
+
personalConnectionDelegations,
|
|
1955
2003
|
state: "pending",
|
|
1956
2004
|
})
|
|
1957
2005
|
.returning({ id: schema.sessionSystemUpdates.id });
|