@opengeni/core 0.21.10 → 0.24.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/access/index.d.ts +1 -1
- package/dist/application/new-session-drafts.d.ts +1 -1
- package/dist/application/session-commands.d.ts +2 -2
- package/dist/billing/limits.d.ts +1 -1
- package/dist/chunk-6WKPWE5S.js +2380 -0
- package/dist/chunk-6WKPWE5S.js.map +1 -0
- package/dist/chunk-JJU6I5XD.js +2713 -0
- package/dist/chunk-JJU6I5XD.js.map +1 -0
- package/dist/chunk-NYPMQ7NO.js +2270 -0
- package/dist/chunk-NYPMQ7NO.js.map +1 -0
- package/dist/dependencies.d.ts +26 -6
- package/dist/domain/capabilities.d.ts +28 -3
- package/dist/domain/company-profile-durable-learning-adapter.d.ts +39 -0
- package/dist/domain/durable-learning-slack-publication.d.ts +72 -0
- package/dist/domain/editable-artifacts/agent-application.d.ts +192 -0
- package/dist/domain/editable-artifacts/durable-export-postgres.d.ts +4 -0
- package/dist/domain/editable-artifacts/durable-export.d.ts +212 -0
- package/dist/domain/editable-artifacts/errors.d.ts +47 -0
- package/dist/domain/editable-artifacts/hash.d.ts +11 -0
- package/dist/domain/editable-artifacts/in-memory.d.ts +99 -0
- package/dist/domain/editable-artifacts/index.d.ts +14 -0
- package/dist/domain/editable-artifacts/ports.d.ts +341 -0
- package/dist/domain/editable-artifacts/postgres-adapters.d.ts +13 -0
- package/dist/domain/editable-artifacts/service.d.ts +105 -0
- package/dist/domain/editable-artifacts/snapshot-compaction.d.ts +44 -0
- package/dist/domain/editable-artifacts/snapshot-verifier-genesis.d.ts +50 -0
- package/dist/domain/editable-artifacts/snapshot-verifier-materialization.d.ts +21 -0
- package/dist/domain/editable-artifacts/snapshot-verifier.d.ts +118 -0
- package/dist/domain/editable-artifacts/types.d.ts +410 -0
- package/dist/domain/memory-slack-delivery.d.ts +19 -0
- package/dist/domain/packs.d.ts +29 -1
- package/dist/domain/personal-connection-delegations.d.ts +9 -1
- package/dist/domain/scheduled-tasks.d.ts +2 -2
- package/dist/domain/session-tool-policy.d.ts +2 -2
- package/dist/domain/sessions.d.ts +14 -6
- package/dist/domain/skill-imports.d.ts +32 -0
- package/dist/domain/slack-publication-secret-safety.d.ts +8 -0
- package/dist/domain/timeline-annotations.d.ts +5 -0
- package/dist/domain/video-generation-capabilities.d.ts +9 -0
- package/dist/domain/video-generation.d.ts +47 -0
- package/dist/editable-artifact-live/application.d.ts +69 -0
- package/dist/editable-artifact-live/errors.d.ts +1 -0
- package/dist/editable-artifact-live/index.d.ts +8 -0
- package/dist/editable-artifact-live/outbox-dispatcher.d.ts +162 -0
- package/dist/editable-artifact-live/ports.d.ts +100 -0
- package/dist/editable-artifact-live/server.d.ts +71 -0
- package/dist/editable-artifact-live/ticket.d.ts +40 -0
- package/dist/editable-artifact-live/types.d.ts +213 -0
- package/dist/editable-artifact-live/wire.d.ts +34 -0
- package/dist/editable-artifact-live.d.ts +2 -0
- package/dist/editable-artifact-live.js +58 -0
- package/dist/editable-artifact-live.js.map +1 -0
- package/dist/editable-artifacts.d.ts +2 -0
- package/dist/editable-artifacts.js +179 -0
- package/dist/editable-artifacts.js.map +1 -0
- package/dist/index.d.ts +35 -26
- package/dist/index.js +2792 -609
- package/dist/index.js.map +1 -1
- package/dist/managed-session.d.ts +1 -1
- package/dist/rigs/index.d.ts +1 -1
- package/dist/rigs/provider-images.d.ts +31 -0
- package/dist/sandbox/routing.d.ts +1 -0
- package/dist/session-authorization.d.ts +1 -1
- package/dist/workflow-wake-contract.d.ts +7 -0
- package/package.json +18 -10
- package/src/application/new-session-drafts.ts +2 -0
- package/src/application/session-commands.ts +188 -107
- package/src/dependencies.ts +30 -2
- package/src/domain/capabilities.ts +604 -220
- package/src/domain/company-profile-durable-learning-adapter.ts +221 -0
- package/src/domain/durable-learning-slack-publication.ts +202 -0
- package/src/domain/editable-artifacts/agent-application.ts +687 -0
- package/src/domain/editable-artifacts/durable-export-postgres.ts +139 -0
- package/src/domain/editable-artifacts/durable-export.ts +734 -0
- package/src/domain/editable-artifacts/errors.ts +115 -0
- package/src/domain/editable-artifacts/hash.ts +131 -0
- package/src/domain/editable-artifacts/in-memory.ts +1662 -0
- package/src/domain/editable-artifacts/index.ts +14 -0
- package/src/domain/editable-artifacts/ports.ts +462 -0
- package/src/domain/editable-artifacts/postgres-adapters.ts +49 -0
- package/src/domain/editable-artifacts/service.ts +2402 -0
- package/src/domain/editable-artifacts/snapshot-compaction.ts +246 -0
- package/src/domain/editable-artifacts/snapshot-verifier-genesis.ts +235 -0
- package/src/domain/editable-artifacts/snapshot-verifier-materialization.ts +74 -0
- package/src/domain/editable-artifacts/snapshot-verifier.ts +687 -0
- package/src/domain/editable-artifacts/types.ts +835 -0
- package/src/domain/insights.ts +136 -33
- package/src/domain/memory-slack-delivery.ts +204 -0
- package/src/domain/memory-slack-publication.ts +5 -2
- package/src/domain/packs.ts +266 -5
- package/src/domain/personal-connection-delegations.ts +97 -6
- package/src/domain/scheduled-tasks.ts +155 -29
- package/src/domain/session-tool-policy.ts +8 -2
- package/src/domain/sessions.ts +274 -131
- package/src/domain/skill-imports.ts +350 -0
- package/src/domain/slack-publication-secret-safety.ts +42 -0
- package/src/domain/timeline-annotations.ts +204 -0
- package/src/domain/video-generation-capabilities.ts +69 -0
- package/src/domain/video-generation.ts +249 -0
- package/src/editable-artifact-live/application.ts +182 -0
- package/src/editable-artifact-live/errors.ts +4 -0
- package/src/editable-artifact-live/index.ts +8 -0
- package/src/editable-artifact-live/outbox-dispatcher.ts +916 -0
- package/src/editable-artifact-live/ports.ts +139 -0
- package/src/editable-artifact-live/server.ts +1707 -0
- package/src/editable-artifact-live/ticket.ts +217 -0
- package/src/editable-artifact-live/types.ts +286 -0
- package/src/editable-artifact-live/wire.ts +95 -0
- package/src/editable-artifact-live.ts +2 -0
- package/src/editable-artifacts.ts +2 -0
- package/src/index.ts +13 -0
- package/src/rigs/index.ts +26 -19
- package/src/rigs/provider-images.ts +110 -0
- package/src/sandbox/routing.ts +6 -3
- package/src/session-authorization.ts +3 -0
- package/src/workflow-wake-contract.ts +8 -0
|
@@ -2,6 +2,7 @@ import type { Settings } from "@opengeni/config";
|
|
|
2
2
|
import type {
|
|
3
3
|
AccessGrant,
|
|
4
4
|
McpPersonalConnectionDelegation,
|
|
5
|
+
KnowledgeSourceSyncAction,
|
|
5
6
|
ScheduledTask,
|
|
6
7
|
ScheduledTaskAgentConfig,
|
|
7
8
|
Session,
|
|
@@ -14,12 +15,15 @@ import { OPENGENI_SLACK_BOT_SESSION_METADATA_KEY } from "@opengeni/contracts";
|
|
|
14
15
|
import {
|
|
15
16
|
createScheduledTask,
|
|
16
17
|
deleteScheduledTask,
|
|
18
|
+
getConnectionMetadata,
|
|
19
|
+
getKnowledgeSourceForSyncAuthority,
|
|
17
20
|
getNestedAgentDepthDeploymentPolicy,
|
|
18
21
|
getRig,
|
|
19
22
|
getScheduledTask,
|
|
20
23
|
getScheduledTaskPersonalConnectionDelegations,
|
|
21
24
|
getSession,
|
|
22
25
|
requireWorkspace,
|
|
26
|
+
scopedKnowledgeScopeKey,
|
|
23
27
|
updateScheduledTask,
|
|
24
28
|
type Database,
|
|
25
29
|
type UpdateScheduledTaskInput,
|
|
@@ -94,24 +98,39 @@ export async function createValidatedScheduledTask(input: {
|
|
|
94
98
|
sessionAuthorization?: SessionAuthorizationPort | null | undefined;
|
|
95
99
|
authorizationSurface?: SessionAuthorizationSurface | undefined;
|
|
96
100
|
}): Promise<ScheduledTask> {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
+
// API parsing fills this default, but pack installers and older internal
|
|
102
|
+
// callers can still invoke the shared validator with the pre-action shape.
|
|
103
|
+
const action = input.payload.action ?? ({ kind: "agent_turn" } as const);
|
|
104
|
+
const knowledgeAction = action.kind === "knowledge_source_sync" ? action : null;
|
|
105
|
+
if (knowledgeAction) {
|
|
106
|
+
await validateKnowledgeSourceSyncAction({
|
|
107
|
+
db: input.db,
|
|
108
|
+
grant: input.grant,
|
|
109
|
+
action: knowledgeAction,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
const agentConfig = knowledgeAction
|
|
113
|
+
? input.payload.agentConfig
|
|
114
|
+
: await validateScheduledTaskAgentConfig({
|
|
115
|
+
...input,
|
|
116
|
+
workspaceId: input.grant.workspaceId,
|
|
117
|
+
});
|
|
101
118
|
const id = crypto.randomUUID();
|
|
102
119
|
validateScheduledTaskSchedule(input.payload.schedule);
|
|
103
|
-
const target =
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
120
|
+
const target = knowledgeAction
|
|
121
|
+
? null
|
|
122
|
+
: await validateScheduledTaskTarget({
|
|
123
|
+
db: input.db,
|
|
124
|
+
sessionAuthorization: input.sessionAuthorization,
|
|
125
|
+
authorizationSurface: input.authorizationSurface,
|
|
126
|
+
grant: input.grant,
|
|
127
|
+
targetSessionId: input.payload.targetSessionId,
|
|
128
|
+
runMode: input.payload.runMode,
|
|
129
|
+
variableSetId: input.payload.variableSetId,
|
|
130
|
+
rigId: input.payload.rigId,
|
|
131
|
+
agentConfig,
|
|
132
|
+
});
|
|
133
|
+
if (!knowledgeAction && input.payload.variableSetId) {
|
|
115
134
|
await validateVariableSetAttachment(
|
|
116
135
|
{ settings: input.settings, db: input.db },
|
|
117
136
|
input.grant,
|
|
@@ -124,21 +143,23 @@ export async function createValidatedScheduledTask(input: {
|
|
|
124
143
|
// (at dispatch), so validate only that the id names a rig in the workspace —
|
|
125
144
|
// NOT that it has an active version now (that is a fire-time concern). RLS
|
|
126
145
|
// makes a cross-workspace id indistinguishable from missing → both 422.
|
|
127
|
-
if (input.payload.rigId) {
|
|
146
|
+
if (!knowledgeAction && input.payload.rigId) {
|
|
128
147
|
await requireScheduledTaskRig(input.db, input.grant.workspaceId, input.payload.rigId);
|
|
129
148
|
}
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
149
|
+
const personalConnectionDelegations = knowledgeAction
|
|
150
|
+
? []
|
|
151
|
+
: await freezePersonalConnectionDelegations({
|
|
152
|
+
db: input.db,
|
|
153
|
+
workspaceId: input.grant.workspaceId,
|
|
154
|
+
settings: await settingsWithEnabledCapabilityMcpServers(
|
|
155
|
+
input.db,
|
|
156
|
+
input.grant.workspaceId,
|
|
157
|
+
input.settings,
|
|
158
|
+
{ subjectId: input.grant.subjectId },
|
|
159
|
+
),
|
|
160
|
+
tools: [...agentConfig.tools, { kind: "mcp", id: "opengeni" }],
|
|
161
|
+
source: personalConnectionDelegationSourceForGrant(input.grant),
|
|
162
|
+
});
|
|
142
163
|
const creationInitiator = creationInitiatorForGrant(input.grant);
|
|
143
164
|
return await createScheduledTask(input.db, {
|
|
144
165
|
id,
|
|
@@ -150,6 +171,7 @@ export async function createValidatedScheduledTask(input: {
|
|
|
150
171
|
temporalScheduleId: scheduledTaskTemporalScheduleId(id),
|
|
151
172
|
runMode: input.payload.runMode,
|
|
152
173
|
overlapPolicy: input.payload.overlapPolicy,
|
|
174
|
+
action,
|
|
153
175
|
agentConfig,
|
|
154
176
|
...(creationInitiator.initiator ? { createdBy: creationInitiator.initiator } : {}),
|
|
155
177
|
...(creationInitiator.context ? { createdByContext: creationInitiator.context } : {}),
|
|
@@ -301,6 +323,50 @@ export async function validatedScheduledTaskUpdate(input: {
|
|
|
301
323
|
authorizationSurface?: SessionAuthorizationSurface | undefined;
|
|
302
324
|
}): Promise<UpdateScheduledTaskInput> {
|
|
303
325
|
const update: UpdateScheduledTaskInput = {};
|
|
326
|
+
const existingKnowledge = input.existing.action.kind === "knowledge_source_sync";
|
|
327
|
+
if (input.payload.action && input.payload.action.kind !== input.existing.action.kind) {
|
|
328
|
+
throw new HTTPException(409, {
|
|
329
|
+
message: "scheduled task action kind is immutable; create a new schedule",
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
if (existingKnowledge) {
|
|
333
|
+
if (
|
|
334
|
+
input.payload.agentConfig !== undefined ||
|
|
335
|
+
input.payload.runMode !== undefined ||
|
|
336
|
+
input.payload.targetSessionId !== undefined ||
|
|
337
|
+
input.payload.variableSetId !== undefined ||
|
|
338
|
+
input.payload.rigId !== undefined
|
|
339
|
+
) {
|
|
340
|
+
throw new HTTPException(422, {
|
|
341
|
+
message: "knowledge source schedules do not accept agent/session configuration",
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
if (input.payload.overlapPolicy === "allow_concurrent") {
|
|
345
|
+
throw new HTTPException(422, {
|
|
346
|
+
message: "knowledge source schedules require skip or buffer_one overlap",
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
if (input.payload.action?.kind === "knowledge_source_sync") {
|
|
350
|
+
await validateKnowledgeSourceSyncAction({
|
|
351
|
+
db: input.db,
|
|
352
|
+
grant: input.grant,
|
|
353
|
+
action: input.payload.action,
|
|
354
|
+
});
|
|
355
|
+
update.action = input.payload.action;
|
|
356
|
+
}
|
|
357
|
+
if (input.payload.name !== undefined)
|
|
358
|
+
update.name = trimmedScheduledTaskName(input.payload.name);
|
|
359
|
+
if (input.payload.status !== undefined) update.status = input.payload.status;
|
|
360
|
+
if (input.payload.schedule !== undefined) {
|
|
361
|
+
validateScheduledTaskSchedule(input.payload.schedule);
|
|
362
|
+
update.schedule = input.payload.schedule;
|
|
363
|
+
}
|
|
364
|
+
if (input.payload.overlapPolicy !== undefined) {
|
|
365
|
+
update.overlapPolicy = input.payload.overlapPolicy;
|
|
366
|
+
}
|
|
367
|
+
if (input.payload.metadata !== undefined) update.metadata = input.payload.metadata;
|
|
368
|
+
return update;
|
|
369
|
+
}
|
|
304
370
|
const existingTarget = input.existing.targetSessionId;
|
|
305
371
|
const nextRunMode = input.payload.runMode ?? input.existing.runMode;
|
|
306
372
|
const nextTargetSessionId =
|
|
@@ -412,6 +478,7 @@ export async function validatedScheduledTaskUpdate(input: {
|
|
|
412
478
|
input.db,
|
|
413
479
|
input.existing.workspaceId,
|
|
414
480
|
input.settings,
|
|
481
|
+
{ subjectId: input.grant.subjectId },
|
|
415
482
|
);
|
|
416
483
|
const personalConnectionDelegations = await freezePersonalConnectionDelegations({
|
|
417
484
|
db: input.db,
|
|
@@ -517,6 +584,7 @@ export async function restoreScheduledTask(
|
|
|
517
584
|
schedule: task.schedule,
|
|
518
585
|
runMode: task.runMode,
|
|
519
586
|
overlapPolicy: task.overlapPolicy,
|
|
587
|
+
action: task.action,
|
|
520
588
|
agentConfig: task.agentConfig,
|
|
521
589
|
personalConnectionDelegations: previous.personalConnectionDelegations,
|
|
522
590
|
...(task.runMode === "existing_session"
|
|
@@ -528,6 +596,63 @@ export async function restoreScheduledTask(
|
|
|
528
596
|
});
|
|
529
597
|
}
|
|
530
598
|
|
|
599
|
+
async function validateKnowledgeSourceSyncAction(input: {
|
|
600
|
+
db: Database;
|
|
601
|
+
grant: AccessGrant;
|
|
602
|
+
action: KnowledgeSourceSyncAction;
|
|
603
|
+
}): Promise<void> {
|
|
604
|
+
if (input.action.initiatingSubjectId !== input.grant.subjectId) {
|
|
605
|
+
throw new HTTPException(403, {
|
|
606
|
+
message: "knowledge source sync must preserve the exact initiating subject",
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
if (input.action.connection.ownerSubjectId !== input.grant.subjectId) {
|
|
610
|
+
throw new HTTPException(403, {
|
|
611
|
+
message: "knowledge source connection must belong to the initiating subject",
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
const resolved = await getKnowledgeSourceForSyncAuthority(input.db, {
|
|
615
|
+
accountId: input.grant.accountId,
|
|
616
|
+
workspaceId: input.grant.workspaceId,
|
|
617
|
+
sourceId: input.action.sourceId,
|
|
618
|
+
initiatingSubjectId: input.grant.subjectId,
|
|
619
|
+
});
|
|
620
|
+
if (!resolved || resolved.source.lifecycleState !== "active") {
|
|
621
|
+
throw new HTTPException(404, { message: "knowledge source not found" });
|
|
622
|
+
}
|
|
623
|
+
if (
|
|
624
|
+
resolved.source.syncGeneration !== input.action.sourceGeneration ||
|
|
625
|
+
resolved.source.lifecycleGeneration !== input.action.sourceLifecycleGeneration ||
|
|
626
|
+
scopedKnowledgeScopeKey(resolved.source.scope) !==
|
|
627
|
+
scopedKnowledgeScopeKey(input.action.destination)
|
|
628
|
+
) {
|
|
629
|
+
throw new HTTPException(409, {
|
|
630
|
+
message: "knowledge source authority or generation changed",
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
const connection = await getConnectionMetadata(
|
|
634
|
+
input.db,
|
|
635
|
+
input.grant.workspaceId,
|
|
636
|
+
input.action.connection.connectionId,
|
|
637
|
+
input.grant.subjectId,
|
|
638
|
+
);
|
|
639
|
+
if (
|
|
640
|
+
!connection ||
|
|
641
|
+
connection.accountId !== input.grant.accountId ||
|
|
642
|
+
connection.workspaceId !== input.grant.workspaceId ||
|
|
643
|
+
connection.subjectId !== input.action.connection.ownerSubjectId ||
|
|
644
|
+
connection.version !== input.action.connection.connectionVersion ||
|
|
645
|
+
connection.providerDomain.toLowerCase() !==
|
|
646
|
+
input.action.connection.providerDomain.toLowerCase() ||
|
|
647
|
+
connection.kind !== input.action.connection.kind ||
|
|
648
|
+
connection.status !== "active"
|
|
649
|
+
) {
|
|
650
|
+
throw new HTTPException(409, {
|
|
651
|
+
message: "knowledge source connection authority changed or requires reconnect",
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
|
|
531
656
|
export class ScheduledTaskSyncError extends Error {
|
|
532
657
|
readonly persistenceRestored: boolean;
|
|
533
658
|
|
|
@@ -647,6 +772,7 @@ async function validateScheduledTaskAgentConfig(input: {
|
|
|
647
772
|
input.db,
|
|
648
773
|
input.workspaceId,
|
|
649
774
|
input.settings,
|
|
775
|
+
{ subjectId: input.grant.subjectId },
|
|
650
776
|
);
|
|
651
777
|
const requestedTools = validateToolRefs(input.payload.agentConfig.tools ?? [], runtimeSettings);
|
|
652
778
|
// A task whose creator did not choose tools gets the workspace's enabled
|
|
@@ -169,8 +169,11 @@ export async function workspaceSessionToolPolicyServerIds(
|
|
|
169
169
|
db: Database,
|
|
170
170
|
workspaceId: string,
|
|
171
171
|
settings: Settings,
|
|
172
|
+
subjectId?: string,
|
|
172
173
|
): Promise<string[]> {
|
|
173
|
-
const runtimeSettings = await settingsWithEnabledCapabilityMcpServers(db, workspaceId, settings
|
|
174
|
+
const runtimeSettings = await settingsWithEnabledCapabilityMcpServers(db, workspaceId, settings, {
|
|
175
|
+
...(subjectId ? { subjectId } : {}),
|
|
176
|
+
});
|
|
174
177
|
return sortedIds(runtimeSettings.mcpServers.map((server) => server.id));
|
|
175
178
|
}
|
|
176
179
|
|
|
@@ -179,8 +182,11 @@ export async function workspaceSessionToolPolicyDefaultServerIds(
|
|
|
179
182
|
db: Database,
|
|
180
183
|
workspaceId: string,
|
|
181
184
|
settings: Settings,
|
|
185
|
+
subjectId?: string,
|
|
182
186
|
): Promise<string[]> {
|
|
183
|
-
const runtimeSettings = await settingsWithEnabledCapabilityMcpServers(db, workspaceId, settings
|
|
187
|
+
const runtimeSettings = await settingsWithEnabledCapabilityMcpServers(db, workspaceId, settings, {
|
|
188
|
+
...(subjectId ? { subjectId } : {}),
|
|
189
|
+
});
|
|
184
190
|
return defaultSessionMcpServerIds(runtimeSettings.mcpServers);
|
|
185
191
|
}
|
|
186
192
|
|