@opengeni/core 2.2.0-canary.0 → 2.4.0-canary.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/application/session-tenancy.d.ts +1 -1
- package/dist/dependencies.d.ts +38 -0
- package/dist/domain/insights.d.ts +15 -0
- package/dist/domain/remember.d.ts +4 -1
- package/dist/domain/sessions.d.ts +4 -3
- package/dist/index.js +280 -239
- package/dist/index.js.map +1 -1
- package/dist/rigs/provider-images.d.ts +1 -1
- package/package.json +10 -10
- package/src/access/index.ts +1 -0
- package/src/application/new-session-drafts.ts +24 -10
- package/src/application/session-tenancy.ts +98 -5
- package/src/dependencies.ts +35 -0
- package/src/domain/insights.ts +112 -162
- package/src/domain/organization-membership-lifecycle.ts +2 -1
- package/src/domain/packs.ts +10 -8
- package/src/domain/remember.ts +37 -15
- package/src/domain/sessions.ts +49 -44
- package/src/rigs/index.ts +4 -5
- package/src/rigs/provider-images.ts +2 -3
- package/src/sandbox/runtime-settings.ts +11 -11
package/dist/index.js
CHANGED
|
@@ -1250,10 +1250,9 @@ function rigProviderImageSetupHash(definition) {
|
|
|
1250
1250
|
function rigProviderImageContentHash(input) {
|
|
1251
1251
|
return sha256(
|
|
1252
1252
|
stableJson({
|
|
1253
|
-
version:
|
|
1253
|
+
version: 2,
|
|
1254
1254
|
backend: input.backend,
|
|
1255
1255
|
sourceImage: input.sourceImage,
|
|
1256
|
-
image: input.definition.image,
|
|
1257
1256
|
setupScript: input.definition.setupScript,
|
|
1258
1257
|
checks: input.definition.checks,
|
|
1259
1258
|
credentialHooks: input.definition.credentialHooks,
|
|
@@ -1324,13 +1323,8 @@ function settingsWithPackSandboxImage(settings, sandboxImage, sandboxProviderIma
|
|
|
1324
1323
|
};
|
|
1325
1324
|
}
|
|
1326
1325
|
function settingsWithRigImage(settings, rigImage) {
|
|
1327
|
-
|
|
1328
|
-
return
|
|
1329
|
-
...settings,
|
|
1330
|
-
dockerImage: rigImage,
|
|
1331
|
-
modalImageRef: rigImage,
|
|
1332
|
-
modalImageId: void 0
|
|
1333
|
-
};
|
|
1326
|
+
void rigImage;
|
|
1327
|
+
return settings;
|
|
1334
1328
|
}
|
|
1335
1329
|
function rigProviderImageSourceImage(settings, backend) {
|
|
1336
1330
|
if (backend === "modal") return settings.modalImageId ?? settings.modalImageRef ?? null;
|
|
@@ -1434,10 +1428,7 @@ async function resolveSessionSandboxRuntime(db, settings, session) {
|
|
|
1434
1428
|
throw new Error(`Frozen rig version ${session.rigVersionId} is unavailable`);
|
|
1435
1429
|
}
|
|
1436
1430
|
const legacy = legacySandboxRuntimeFromPacks(packs2);
|
|
1437
|
-
const logicalSettings =
|
|
1438
|
-
settingsWithPackSandboxImage(settings, legacy.sandboxImage, legacy.sandboxProviderImages),
|
|
1439
|
-
rigVersion?.image ?? null
|
|
1440
|
-
);
|
|
1431
|
+
const logicalSettings = rigVersion ? settings : settingsWithPackSandboxImage(settings, legacy.sandboxImage, legacy.sandboxProviderImages);
|
|
1441
1432
|
return {
|
|
1442
1433
|
settings: {
|
|
1443
1434
|
...logicalSettings,
|
|
@@ -1650,7 +1641,8 @@ async function resolveAccessContext(c, deps) {
|
|
|
1650
1641
|
userId: session.user.id,
|
|
1651
1642
|
email: session.user.email,
|
|
1652
1643
|
name: session.user.name,
|
|
1653
|
-
emailVerified: session.user.emailVerified
|
|
1644
|
+
emailVerified: session.user.emailVerified,
|
|
1645
|
+
provisionFallbackOrganization: false
|
|
1654
1646
|
});
|
|
1655
1647
|
canonicalManagedCookieContexts.add(context);
|
|
1656
1648
|
return context;
|
|
@@ -3174,8 +3166,8 @@ async function resolvePackRig(db, workspaceId, pack, requestedRigId, storedRigId
|
|
|
3174
3166
|
image: null
|
|
3175
3167
|
};
|
|
3176
3168
|
}
|
|
3177
|
-
const image =
|
|
3178
|
-
const status = pack.sandboxImage
|
|
3169
|
+
const image = null;
|
|
3170
|
+
const status = pack.sandboxImage ? "mismatch" : pack.rig?.requireVerified && rig.activeVersionHealth?.checkHealth !== "passing" ? "unverified" : "ready";
|
|
3179
3171
|
return {
|
|
3180
3172
|
required,
|
|
3181
3173
|
status,
|
|
@@ -3194,7 +3186,7 @@ function packRigBlocker(rig, legacyImage) {
|
|
|
3194
3186
|
return "Verify the selected compute environment before installing this Pack";
|
|
3195
3187
|
}
|
|
3196
3188
|
if (legacyImage) {
|
|
3197
|
-
return `
|
|
3189
|
+
return `This Pack requires the retired explicit sandbox image ${legacyImage}; Rig-bound Packs currently must use the deployment-managed platform sandbox`;
|
|
3198
3190
|
}
|
|
3199
3191
|
return "The selected compute environment does not satisfy this Pack's requirement";
|
|
3200
3192
|
}
|
|
@@ -5206,7 +5198,7 @@ async function createRigForApi(deps, grant, payload, options = {}) {
|
|
|
5206
5198
|
description: payload.description ?? null,
|
|
5207
5199
|
createdBy,
|
|
5208
5200
|
initialVersion: {
|
|
5209
|
-
image:
|
|
5201
|
+
image: null,
|
|
5210
5202
|
setupScript: payload.setupScript ?? null,
|
|
5211
5203
|
checks: payload.checks,
|
|
5212
5204
|
credentialHooks: payload.credentialHooks,
|
|
@@ -5355,7 +5347,7 @@ async function promoteSetupAppendChange(deps, grant, rig, change) {
|
|
|
5355
5347
|
});
|
|
5356
5348
|
}
|
|
5357
5349
|
const nextDefinition = {
|
|
5358
|
-
image:
|
|
5350
|
+
image: null,
|
|
5359
5351
|
setupScript: appendRigSetupCommand(base.setupScript, payload.command),
|
|
5360
5352
|
checks: base.checks,
|
|
5361
5353
|
credentialHooks: base.credentialHooks,
|
|
@@ -5421,7 +5413,7 @@ async function promoteVerifiedDefinitionEditChangeForApi(deps, grant, rig, chang
|
|
|
5421
5413
|
}
|
|
5422
5414
|
const payload = change.payload;
|
|
5423
5415
|
const nextDefinition = {
|
|
5424
|
-
image:
|
|
5416
|
+
image: null,
|
|
5425
5417
|
setupScript: payload.setupScript === void 0 ? base.setupScript : payload.setupScript,
|
|
5426
5418
|
checks: Array.isArray(payload.checks) ? payload.checks : base.checks,
|
|
5427
5419
|
credentialHooks: Array.isArray(payload.credentialHooks) ? payload.credentialHooks : base.credentialHooks,
|
|
@@ -5479,7 +5471,7 @@ async function createRigVersionForApi(deps, grant, rig, payload) {
|
|
|
5479
5471
|
rig.workspaceId,
|
|
5480
5472
|
rig.id,
|
|
5481
5473
|
{
|
|
5482
|
-
image:
|
|
5474
|
+
image: null,
|
|
5483
5475
|
setupScript: payload.setupScript === void 0 ? base.setupScript : payload.setupScript,
|
|
5484
5476
|
checks: payload.checks ?? base.checks,
|
|
5485
5477
|
credentialHooks: payload.credentialHooks ?? base.credentialHooks,
|
|
@@ -6931,7 +6923,7 @@ import {
|
|
|
6931
6923
|
getConnectionMetadata as getConnectionMetadata4,
|
|
6932
6924
|
getKnowledgeSourceForSyncAuthority,
|
|
6933
6925
|
getNestedAgentDepthDeploymentPolicy,
|
|
6934
|
-
getRig as
|
|
6926
|
+
getRig as getRig5,
|
|
6935
6927
|
getScheduledTask,
|
|
6936
6928
|
getScheduledTaskIncludingDeletedForUpdate,
|
|
6937
6929
|
getScheduledTaskPersonalConnectionDelegations,
|
|
@@ -6981,9 +6973,9 @@ import {
|
|
|
6981
6973
|
getAnySessionInGroup,
|
|
6982
6974
|
getEnrollment as getEnrollment2,
|
|
6983
6975
|
getChannel,
|
|
6984
|
-
getRig as
|
|
6976
|
+
getRig as getRig4,
|
|
6985
6977
|
getWorkspaceDefaultRigId,
|
|
6986
|
-
|
|
6978
|
+
listDistinctVariableSetSelectionsInGroup,
|
|
6987
6979
|
listDistinctRigVersionIdsInGroup,
|
|
6988
6980
|
getSandbox as getSandbox3,
|
|
6989
6981
|
getSession as getSession2,
|
|
@@ -7005,7 +6997,7 @@ import {
|
|
|
7005
6997
|
requireSession as requireSession2,
|
|
7006
6998
|
submitHumanPromptInTransaction,
|
|
7007
6999
|
appendSessionEventsWithLockedSessionUpdate,
|
|
7008
|
-
|
|
7000
|
+
updateSessionTitleWithEvent,
|
|
7009
7001
|
withWorkspaceSubjectSessionActivityRls,
|
|
7010
7002
|
QueueCommandConflictError,
|
|
7011
7003
|
AgentCommandAuthorityError,
|
|
@@ -7020,7 +7012,6 @@ import {
|
|
|
7020
7012
|
WorkspaceControlBusyError
|
|
7021
7013
|
} from "@opengeni/db";
|
|
7022
7014
|
import {
|
|
7023
|
-
appendAndPublishEvents as appendAndPublishEvents2,
|
|
7024
7015
|
publishDurableSessionEvents as publishDurableSessionEvents2,
|
|
7025
7016
|
publishDurableWorkspaceControlEvent
|
|
7026
7017
|
} from "@opengeni/events";
|
|
@@ -7244,6 +7235,7 @@ import {
|
|
|
7244
7235
|
} from "@opengeni/contracts";
|
|
7245
7236
|
import {
|
|
7246
7237
|
forkSessionContent,
|
|
7238
|
+
getRig as getRig3,
|
|
7247
7239
|
getPrivateSessionCreatePolicy,
|
|
7248
7240
|
getSessionEventForSubject,
|
|
7249
7241
|
isRetryableDatabaseTransportFailure,
|
|
@@ -7251,6 +7243,7 @@ import {
|
|
|
7251
7243
|
replayAppliedSessionFork,
|
|
7252
7244
|
sessionTenancyProductActivated,
|
|
7253
7245
|
SessionTenancyAccessError,
|
|
7246
|
+
SessionTenancyInvalidRequestError,
|
|
7254
7247
|
SessionTenancyNotActivatedError,
|
|
7255
7248
|
transitionSessionVisibility
|
|
7256
7249
|
} from "@opengeni/db";
|
|
@@ -7430,12 +7423,75 @@ async function forkManagedHumanSession(deps, authorization, workspaceId, sourceS
|
|
|
7430
7423
|
destinationWorkspaceId: workspaceId,
|
|
7431
7424
|
destinationVisibility: request.visibility === "private" ? "user_private" : "workspace_shared",
|
|
7432
7425
|
workspaceSharedAcknowledged: request.workspaceSharedAcknowledged,
|
|
7433
|
-
operationKey: request.idempotencyKey
|
|
7426
|
+
operationKey: request.idempotencyKey,
|
|
7427
|
+
...request.rigId !== void 0 || request.variableSetIds !== void 0 ? {
|
|
7428
|
+
runtimeRequest: {
|
|
7429
|
+
rigId: request.rigId ?? null,
|
|
7430
|
+
variableSetIds: request.variableSetIds ?? []
|
|
7431
|
+
}
|
|
7432
|
+
} : {}
|
|
7434
7433
|
};
|
|
7435
7434
|
const recoverAppliedReceipt = async () => await runTenancyMutation(async () => await replayAppliedSessionFork(deps.db, forkInput));
|
|
7435
|
+
const runtimeSetupRequested = request.rigId !== void 0 || request.variableSetIds !== void 0;
|
|
7436
|
+
let runtimeConfigurationPromise = null;
|
|
7437
|
+
const resolveRuntimeConfiguration = async () => {
|
|
7438
|
+
if (runtimeConfigurationPromise) return await runtimeConfigurationPromise;
|
|
7439
|
+
runtimeConfigurationPromise = (async () => {
|
|
7440
|
+
const variableSets = [];
|
|
7441
|
+
for (const variableSetId of request.variableSetIds ?? []) {
|
|
7442
|
+
variableSets.push(
|
|
7443
|
+
await validateVariableSetAttachment(
|
|
7444
|
+
{ settings: deps.settings, db: deps.db },
|
|
7445
|
+
authorization.grant,
|
|
7446
|
+
workspaceId,
|
|
7447
|
+
variableSetId
|
|
7448
|
+
)
|
|
7449
|
+
);
|
|
7450
|
+
}
|
|
7451
|
+
let rigVersionId = null;
|
|
7452
|
+
if (request.rigId) {
|
|
7453
|
+
requirePermission(authorization.grant, "rigs:use");
|
|
7454
|
+
const rig = await getRig3(deps.db, authorization.grant, request.rigId);
|
|
7455
|
+
if (!rig?.activeVersion) {
|
|
7456
|
+
throw new SessionTenancyInvalidRequestError();
|
|
7457
|
+
}
|
|
7458
|
+
for (const defaultVariableSetId of new Set(rig.activeVersion.defaultVariableSetIds)) {
|
|
7459
|
+
await validateVariableSetAttachment(
|
|
7460
|
+
{ settings: deps.settings, db: deps.db },
|
|
7461
|
+
authorization.grant,
|
|
7462
|
+
workspaceId,
|
|
7463
|
+
defaultVariableSetId
|
|
7464
|
+
);
|
|
7465
|
+
}
|
|
7466
|
+
rigVersionId = rig.activeVersion.id;
|
|
7467
|
+
}
|
|
7468
|
+
return {
|
|
7469
|
+
variableSetIds: variableSets.map((variableSet) => variableSet.id),
|
|
7470
|
+
rigId: request.rigId ?? null,
|
|
7471
|
+
rigVersionId
|
|
7472
|
+
};
|
|
7473
|
+
})();
|
|
7474
|
+
return await runtimeConfigurationPromise;
|
|
7475
|
+
};
|
|
7476
|
+
const publishRuntimeConfiguration = async (result2) => {
|
|
7477
|
+
if (!result2.runtimeEventId || !result2.runtimeEventSequence) return;
|
|
7478
|
+
await publishExactCommittedEvent(deps, {
|
|
7479
|
+
workspaceId,
|
|
7480
|
+
sessionId: result2.sessionId,
|
|
7481
|
+
subjectId: authorization.grant.subjectId,
|
|
7482
|
+
eventId: result2.runtimeEventId,
|
|
7483
|
+
eventSequence: result2.runtimeEventSequence
|
|
7484
|
+
});
|
|
7485
|
+
};
|
|
7436
7486
|
const applied = await recoverAppliedReceipt();
|
|
7437
7487
|
if (applied) {
|
|
7438
|
-
|
|
7488
|
+
const response2 = await projectAndPublishSessionFork(
|
|
7489
|
+
deps,
|
|
7490
|
+
authorization.grant.subjectId,
|
|
7491
|
+
applied
|
|
7492
|
+
);
|
|
7493
|
+
await publishRuntimeConfiguration(applied);
|
|
7494
|
+
return response2;
|
|
7439
7495
|
}
|
|
7440
7496
|
try {
|
|
7441
7497
|
await requireSessionAuthorization(deps, authorization.grant, {
|
|
@@ -7446,12 +7502,26 @@ async function forkManagedHumanSession(deps, authorization, workspaceId, sourceS
|
|
|
7446
7502
|
} catch (authorizationError) {
|
|
7447
7503
|
const racedApplied = await recoverAppliedReceipt();
|
|
7448
7504
|
if (racedApplied) {
|
|
7449
|
-
|
|
7505
|
+
const response2 = await projectAndPublishSessionFork(
|
|
7506
|
+
deps,
|
|
7507
|
+
authorization.grant.subjectId,
|
|
7508
|
+
racedApplied
|
|
7509
|
+
);
|
|
7510
|
+
await publishRuntimeConfiguration(racedApplied);
|
|
7511
|
+
return response2;
|
|
7450
7512
|
}
|
|
7451
7513
|
throw authorizationError;
|
|
7452
7514
|
}
|
|
7453
|
-
const
|
|
7454
|
-
|
|
7515
|
+
const runtimeConfiguration = runtimeSetupRequested ? await resolveRuntimeConfiguration() : null;
|
|
7516
|
+
const result = await runTenancyMutation(
|
|
7517
|
+
async () => await forkSessionContent(deps.db, {
|
|
7518
|
+
...forkInput,
|
|
7519
|
+
...runtimeConfiguration ? { runtimeConfiguration } : {}
|
|
7520
|
+
})
|
|
7521
|
+
);
|
|
7522
|
+
const response = await projectAndPublishSessionFork(deps, authorization.grant.subjectId, result);
|
|
7523
|
+
await publishRuntimeConfiguration(result);
|
|
7524
|
+
return response;
|
|
7455
7525
|
}
|
|
7456
7526
|
|
|
7457
7527
|
// src/domain/sessions.ts
|
|
@@ -7819,7 +7889,8 @@ async function createAndStartSessionWithOutcome(input) {
|
|
|
7819
7889
|
reasoningEffort: input.reasoningEffort,
|
|
7820
7890
|
latencyMode: input.latencyMode ?? "standard",
|
|
7821
7891
|
sandboxBackend: input.sandboxBackend,
|
|
7822
|
-
|
|
7892
|
+
variableSetIds: input.variableSets?.map((variableSet) => variableSet.id) ?? [],
|
|
7893
|
+
variableSetId: input.variableSets?.at(-1)?.id ?? null,
|
|
7823
7894
|
rigId: input.rigId ?? null,
|
|
7824
7895
|
rigVersionId: input.rigVersionId ?? null,
|
|
7825
7896
|
channelId: input.channelId ?? null,
|
|
@@ -7887,7 +7958,8 @@ async function createAndStartSessionWithOutcome(input) {
|
|
|
7887
7958
|
reasoningEffort: input.reasoningEffort,
|
|
7888
7959
|
latencyMode: input.latencyMode ?? "standard",
|
|
7889
7960
|
sandboxBackend: input.sandboxBackend,
|
|
7890
|
-
|
|
7961
|
+
variableSetIds: input.variableSets?.map((variableSet) => variableSet.id) ?? [],
|
|
7962
|
+
variableSetId: input.variableSets?.at(-1)?.id ?? null,
|
|
7891
7963
|
rigId: input.rigId ?? null,
|
|
7892
7964
|
rigVersionId: input.rigVersionId ?? null,
|
|
7893
7965
|
channelId: input.channelId ?? null,
|
|
@@ -7968,9 +8040,12 @@ async function finishStartSession(input, session) {
|
|
|
7968
8040
|
turnExecutionPolicy: input.turnExecutionPolicy,
|
|
7969
8041
|
createdEventPayload: {
|
|
7970
8042
|
toolPolicy: input.toolPolicy,
|
|
7971
|
-
...input.
|
|
7972
|
-
|
|
7973
|
-
|
|
8043
|
+
...input.variableSets?.length ? {
|
|
8044
|
+
variableSetIds: input.variableSets.map((variableSet) => variableSet.id),
|
|
8045
|
+
variableSets: input.variableSets,
|
|
8046
|
+
// Legacy highest-precedence aliases.
|
|
8047
|
+
variableSetId: input.variableSets.at(-1).id,
|
|
8048
|
+
variableSetName: input.variableSets.at(-1).name
|
|
7974
8049
|
} : {},
|
|
7975
8050
|
...input.sessionMcpServers?.length ? { mcpServers: input.sessionMcpServers } : {}
|
|
7976
8051
|
},
|
|
@@ -8479,17 +8554,17 @@ async function createSessionForRequestWithOutcome(deps, grant, workspaceId, rawP
|
|
|
8479
8554
|
});
|
|
8480
8555
|
}
|
|
8481
8556
|
await validateFileResources(db, grant.accountId, workspaceId, grant.subjectId, resources);
|
|
8482
|
-
const
|
|
8483
|
-
|
|
8484
|
-
|
|
8485
|
-
|
|
8486
|
-
|
|
8487
|
-
|
|
8557
|
+
const variableSets = [];
|
|
8558
|
+
for (const variableSetId of payload.variableSetIds ?? []) {
|
|
8559
|
+
variableSets.push(
|
|
8560
|
+
await validateVariableSetAttachment({ settings, db }, grant, workspaceId, variableSetId)
|
|
8561
|
+
);
|
|
8562
|
+
}
|
|
8488
8563
|
const requestedRigId = payload.rigId === void 0 ? await getWorkspaceDefaultRigId(db, workspaceId) : payload.rigId;
|
|
8489
8564
|
let frozenRigId = null;
|
|
8490
8565
|
let frozenRigVersionId = null;
|
|
8491
8566
|
if (requestedRigId) {
|
|
8492
|
-
const rig = await
|
|
8567
|
+
const rig = await getRig4(db, grant, requestedRigId);
|
|
8493
8568
|
if (!rig || !rig.activeVersion) {
|
|
8494
8569
|
if (payload.rigId) {
|
|
8495
8570
|
throw new HTTPException11(422, {
|
|
@@ -8547,7 +8622,10 @@ async function createSessionForRequestWithOutcome(deps, grant, workspaceId, rawP
|
|
|
8547
8622
|
...payload.sandboxBackend ? { sandboxBackend: payload.sandboxBackend } : {},
|
|
8548
8623
|
...payload.targetSandboxId ? { targetSandboxId: payload.targetSandboxId } : {},
|
|
8549
8624
|
...payload.workingDir ? { workingDir: payload.workingDir } : {},
|
|
8550
|
-
...
|
|
8625
|
+
...variableSets.length ? {
|
|
8626
|
+
variableSetIds: variableSets.map((variableSet) => variableSet.id),
|
|
8627
|
+
variableSetId: variableSets.at(-1).id
|
|
8628
|
+
} : {},
|
|
8551
8629
|
...payload.rigId ? { rigId: payload.rigId } : {},
|
|
8552
8630
|
...payload.goal ? { goal: payload.goal } : {},
|
|
8553
8631
|
...payload.firstPartyMcpPermissions ? { firstPartyMcpPermissions: payload.firstPartyMcpPermissions } : {},
|
|
@@ -8640,8 +8718,8 @@ async function createSessionForRequestWithOutcome(deps, grant, workspaceId, rawP
|
|
|
8640
8718
|
const sandboxChoice = payload.sandbox ?? (payload.targetSandboxId ? "new" : parentSessionId ? "shared" : "new");
|
|
8641
8719
|
let sandboxGroupId = null;
|
|
8642
8720
|
let inheritedBackend;
|
|
8643
|
-
const
|
|
8644
|
-
const
|
|
8721
|
+
const requestedVariableSetIds = variableSets.map((variableSet) => variableSet.id);
|
|
8722
|
+
const variableSetsMatchGroup = (memberVariableSetIds) => stableJson4(memberVariableSetIds) === stableJson4(requestedVariableSetIds);
|
|
8645
8723
|
const rigVersionMatchesGroup = (memberRigVersionId) => memberRigVersionId === frozenRigVersionId;
|
|
8646
8724
|
if (sandboxChoice === "shared") {
|
|
8647
8725
|
if (!parentSessionId) {
|
|
@@ -8654,7 +8732,7 @@ async function createSessionForRequestWithOutcome(deps, grant, workspaceId, rawP
|
|
|
8654
8732
|
}
|
|
8655
8733
|
const parent = parentSession;
|
|
8656
8734
|
const parentBoxed = parent.sandboxBackend !== "none";
|
|
8657
|
-
const variableSetMismatch = parentBoxed && !
|
|
8735
|
+
const variableSetMismatch = parentBoxed && !variableSetsMatchGroup(parent.variableSetIds);
|
|
8658
8736
|
let rigMismatch = parentBoxed && !rigVersionMatchesGroup(parent.rigVersionId ?? null);
|
|
8659
8737
|
if (parentBoxed && !rigMismatch) {
|
|
8660
8738
|
const memberRigVersionIds = await listDistinctRigVersionIdsInGroup(
|
|
@@ -8684,13 +8762,13 @@ async function createSessionForRequestWithOutcome(deps, grant, workspaceId, rawP
|
|
|
8684
8762
|
});
|
|
8685
8763
|
}
|
|
8686
8764
|
if (member.sandboxBackend !== "none") {
|
|
8687
|
-
const
|
|
8765
|
+
const memberVariableSetSelections = await listDistinctVariableSetSelectionsInGroup(
|
|
8688
8766
|
db,
|
|
8689
8767
|
workspaceId,
|
|
8690
8768
|
sandboxChoice.groupId
|
|
8691
8769
|
);
|
|
8692
|
-
if (!
|
|
8693
|
-
(
|
|
8770
|
+
if (!memberVariableSetSelections.every(
|
|
8771
|
+
(memberVariableSetIds) => variableSetsMatchGroup(memberVariableSetIds)
|
|
8694
8772
|
)) {
|
|
8695
8773
|
throw new HTTPException11(422, {
|
|
8696
8774
|
message: `sandbox group ${sandboxChoice.groupId} runs a different variableSet / different environment (the box variable set/environment is fixed at creation); create with the group's variableSet/environment or omit sandbox for an own box.`
|
|
@@ -8784,7 +8862,11 @@ async function createSessionForRequestWithOutcome(deps, grant, workspaceId, rawP
|
|
|
8784
8862
|
...creationInitiator.initiator ? { createdBy: creationInitiator.initiator } : {},
|
|
8785
8863
|
...creationInitiator.context ? { createdByContext: creationInitiator.context } : {},
|
|
8786
8864
|
createdByActor: creationInitiator.actor ?? null,
|
|
8787
|
-
|
|
8865
|
+
variableSets: variableSets.map((variableSet) => ({
|
|
8866
|
+
id: variableSet.id,
|
|
8867
|
+
name: variableSet.name,
|
|
8868
|
+
scope: variableSet.scope
|
|
8869
|
+
})),
|
|
8788
8870
|
// Frozen rig binding (M3): both null for a rig-less session (today's path).
|
|
8789
8871
|
rigId: frozenRigId,
|
|
8790
8872
|
rigVersionId: frozenRigVersionId,
|
|
@@ -9057,25 +9139,18 @@ async function updateSessionTitle(deps, grant, sessionId, title, source) {
|
|
|
9057
9139
|
surface: "core"
|
|
9058
9140
|
});
|
|
9059
9141
|
const workspaceId = grant.workspaceId;
|
|
9060
|
-
const result = await
|
|
9142
|
+
const result = await updateSessionTitleWithEvent(db, {
|
|
9061
9143
|
workspaceId,
|
|
9062
9144
|
sessionId,
|
|
9063
9145
|
title,
|
|
9064
9146
|
source
|
|
9065
9147
|
});
|
|
9066
|
-
if (result.
|
|
9067
|
-
await
|
|
9068
|
-
{
|
|
9069
|
-
type: "session.title_set",
|
|
9070
|
-
payload: {
|
|
9071
|
-
title: result.title ?? title,
|
|
9072
|
-
source
|
|
9073
|
-
}
|
|
9074
|
-
}
|
|
9075
|
-
]);
|
|
9148
|
+
if (result.events.length > 0) {
|
|
9149
|
+
await publishDurableSessionEvents2(bus, workspaceId, sessionId, result.events);
|
|
9076
9150
|
}
|
|
9077
9151
|
return {
|
|
9078
|
-
|
|
9152
|
+
updated: result.updated,
|
|
9153
|
+
title: result.title,
|
|
9079
9154
|
relatedSessionAccess: authorization?.relatedSessionAccess ?? "root"
|
|
9080
9155
|
};
|
|
9081
9156
|
}
|
|
@@ -9614,7 +9689,7 @@ function scheduledTaskAuthorityUpdateForGrant(grant) {
|
|
|
9614
9689
|
};
|
|
9615
9690
|
}
|
|
9616
9691
|
async function requireScheduledTaskRig(db, access, rigId) {
|
|
9617
|
-
const rig = await
|
|
9692
|
+
const rig = await getRig5(db, access, rigId);
|
|
9618
9693
|
if (!rig) {
|
|
9619
9694
|
throw new HTTPException12(422, { message: `unknown rigId: ${rigId}` });
|
|
9620
9695
|
}
|
|
@@ -10190,14 +10265,7 @@ import {
|
|
|
10190
10265
|
WorkspaceInsightsSnapshot
|
|
10191
10266
|
} from "@opengeni/contracts";
|
|
10192
10267
|
import {
|
|
10193
|
-
aggregateModelCallFacts,
|
|
10194
|
-
aggregateModelCallFactsByDay,
|
|
10195
|
-
aggregateModelCallFactsByHour,
|
|
10196
|
-
aggregateModelContextContributions,
|
|
10197
|
-
aggregateRootSessionDrivers,
|
|
10198
|
-
aggregateScheduleFacts,
|
|
10199
10268
|
aggregateSessionDepth,
|
|
10200
|
-
aggregateWarmSecondsByGroup,
|
|
10201
10269
|
countOnlineMachines,
|
|
10202
10270
|
countScheduledTaskFires,
|
|
10203
10271
|
countSessionsAttachedToGroups,
|
|
@@ -10205,16 +10273,33 @@ import {
|
|
|
10205
10273
|
enumerateUtcHours,
|
|
10206
10274
|
listFloorSessions,
|
|
10207
10275
|
listLiveWarmLeases,
|
|
10208
|
-
listModelCallFacets,
|
|
10209
|
-
listRecentModelCalls,
|
|
10210
10276
|
listScheduledTasks,
|
|
10211
|
-
|
|
10212
|
-
|
|
10213
|
-
|
|
10214
|
-
sumUsageQuantityByHour,
|
|
10215
|
-
sumUsageQuantityInRange
|
|
10277
|
+
readWorkspaceInsightsModelBundle,
|
|
10278
|
+
readWorkspaceInsightsUsageBundle,
|
|
10279
|
+
requireWorkspace as requireWorkspace5
|
|
10216
10280
|
} from "@opengeni/db";
|
|
10217
10281
|
var MACHINE_HEARTBEAT_FRESH_MS = 12e4;
|
|
10282
|
+
var WORKSPACE_INSIGHTS_PROVIDER_FILTER_MAX_UTF8_BYTES = 256;
|
|
10283
|
+
var WORKSPACE_INSIGHTS_MODEL_FILTER_MAX_UTF8_BYTES = 512;
|
|
10284
|
+
var WorkspaceInsightsFilterValidationError = class extends Error {
|
|
10285
|
+
field;
|
|
10286
|
+
maxUtf8Bytes;
|
|
10287
|
+
constructor(field, maxUtf8Bytes) {
|
|
10288
|
+
super(`${field} must be at most ${maxUtf8Bytes} UTF-8 bytes`);
|
|
10289
|
+
this.name = "WorkspaceInsightsFilterValidationError";
|
|
10290
|
+
this.field = field;
|
|
10291
|
+
this.maxUtf8Bytes = maxUtf8Bytes;
|
|
10292
|
+
}
|
|
10293
|
+
};
|
|
10294
|
+
function normalizeWorkspaceInsightsFilter(value, field) {
|
|
10295
|
+
const normalized = value?.trim() || null;
|
|
10296
|
+
if (normalized === null || normalized === "all") return null;
|
|
10297
|
+
const maxUtf8Bytes = field === "provider" ? WORKSPACE_INSIGHTS_PROVIDER_FILTER_MAX_UTF8_BYTES : WORKSPACE_INSIGHTS_MODEL_FILTER_MAX_UTF8_BYTES;
|
|
10298
|
+
if (new TextEncoder().encode(normalized).byteLength > maxUtf8Bytes) {
|
|
10299
|
+
throw new WorkspaceInsightsFilterValidationError(field, maxUtf8Bytes);
|
|
10300
|
+
}
|
|
10301
|
+
return normalized;
|
|
10302
|
+
}
|
|
10218
10303
|
function microsToUsd(micros) {
|
|
10219
10304
|
return micros / 1e6;
|
|
10220
10305
|
}
|
|
@@ -10321,157 +10406,67 @@ function billingPathOf(value) {
|
|
|
10321
10406
|
function pricingSourceOf(value) {
|
|
10322
10407
|
return value === "configured_list_price" || value === "gateway_reported" ? value : null;
|
|
10323
10408
|
}
|
|
10409
|
+
function insightsSessionLabel(input) {
|
|
10410
|
+
const title = input.title?.trim();
|
|
10411
|
+
if (title) return title;
|
|
10412
|
+
return `${(input.depth ?? 0) > 0 ? "Agent" : "Session"} ${input.id.slice(0, 8)}`;
|
|
10413
|
+
}
|
|
10324
10414
|
async function getWorkspaceInsights(db, settings, input) {
|
|
10415
|
+
const provider = normalizeWorkspaceInsightsFilter(input.provider, "provider");
|
|
10416
|
+
const model = normalizeWorkspaceInsightsFilter(input.model, "model");
|
|
10325
10417
|
await requireWorkspace5(db, input.workspaceId);
|
|
10326
10418
|
const now = input.now ?? /* @__PURE__ */ new Date();
|
|
10327
10419
|
const window = resolveRangeWindow(input.range, now);
|
|
10328
|
-
const provider = input.provider?.trim() || null;
|
|
10329
|
-
const model = input.model?.trim() || null;
|
|
10330
10420
|
const modelFilterActive = Boolean(provider || model);
|
|
10331
10421
|
const filter = { provider, model };
|
|
10332
|
-
const
|
|
10333
|
-
|
|
10334
|
-
const [
|
|
10335
|
-
workspaceCreditMicros,
|
|
10336
|
-
priorWorkspaceCreditMicros,
|
|
10337
|
-
warmSeconds,
|
|
10338
|
-
priorWarmSeconds,
|
|
10339
|
-
modelRows,
|
|
10340
|
-
priorModelRows,
|
|
10341
|
-
factDays,
|
|
10342
|
-
warmDays,
|
|
10343
|
-
costDays,
|
|
10344
|
-
warmGroups,
|
|
10345
|
-
liveWarm,
|
|
10346
|
-
rootDrivers,
|
|
10347
|
-
scheduleFacts,
|
|
10348
|
-
tasks,
|
|
10349
|
-
depth,
|
|
10350
|
-
floorRows,
|
|
10351
|
-
machinesOnline,
|
|
10352
|
-
billableTokensUsed,
|
|
10353
|
-
agentRunsUsed,
|
|
10354
|
-
facets,
|
|
10355
|
-
recentCalls,
|
|
10356
|
-
promptContributions
|
|
10357
|
-
] = await Promise.all([
|
|
10358
|
-
sumUsageQuantityInRange(db, {
|
|
10359
|
-
workspaceId: input.workspaceId,
|
|
10360
|
-
eventType: "model.cost",
|
|
10361
|
-
since: window.since,
|
|
10362
|
-
until: window.until
|
|
10363
|
-
}),
|
|
10364
|
-
sumUsageQuantityInRange(db, {
|
|
10365
|
-
workspaceId: input.workspaceId,
|
|
10366
|
-
eventType: "model.cost",
|
|
10367
|
-
since: window.priorSince,
|
|
10368
|
-
until: window.priorUntil
|
|
10369
|
-
}),
|
|
10370
|
-
sumUsageQuantityInRange(db, {
|
|
10371
|
-
workspaceId: input.workspaceId,
|
|
10372
|
-
eventType: "sandbox.warm_seconds",
|
|
10373
|
-
since: window.since,
|
|
10374
|
-
until: window.until
|
|
10375
|
-
}),
|
|
10376
|
-
sumUsageQuantityInRange(db, {
|
|
10377
|
-
workspaceId: input.workspaceId,
|
|
10378
|
-
eventType: "sandbox.warm_seconds",
|
|
10379
|
-
since: window.priorSince,
|
|
10380
|
-
until: window.priorUntil
|
|
10381
|
-
}),
|
|
10382
|
-
aggregateModelCallFacts(db, {
|
|
10422
|
+
const [modelBundle, usageBundle, liveWarm, tasks, depth, floorRows, machinesOnline] = await Promise.all([
|
|
10423
|
+
readWorkspaceInsightsModelBundle(db, {
|
|
10383
10424
|
workspaceId: input.workspaceId,
|
|
10384
10425
|
since: window.since,
|
|
10385
10426
|
until: window.until,
|
|
10427
|
+
priorSince: window.priorSince,
|
|
10428
|
+
priorUntil: window.priorUntil,
|
|
10429
|
+
granularity: input.range === "today" ? "hour" : "day",
|
|
10386
10430
|
...filter
|
|
10387
10431
|
}),
|
|
10388
|
-
|
|
10389
|
-
workspaceId: input.workspaceId,
|
|
10390
|
-
since: window.priorSince,
|
|
10391
|
-
until: window.priorUntil,
|
|
10392
|
-
...filter
|
|
10393
|
-
}),
|
|
10394
|
-
aggregateFactsForSeries(db, {
|
|
10395
|
-
workspaceId: input.workspaceId,
|
|
10396
|
-
since: window.since,
|
|
10397
|
-
until: window.until,
|
|
10398
|
-
...filter
|
|
10399
|
-
}),
|
|
10400
|
-
sumUsageForSeries(db, {
|
|
10401
|
-
workspaceId: input.workspaceId,
|
|
10402
|
-
eventType: "sandbox.warm_seconds",
|
|
10403
|
-
since: window.since,
|
|
10404
|
-
until: window.until
|
|
10405
|
-
}),
|
|
10406
|
-
sumUsageForSeries(db, {
|
|
10407
|
-
workspaceId: input.workspaceId,
|
|
10408
|
-
eventType: "model.cost",
|
|
10409
|
-
since: window.since,
|
|
10410
|
-
until: window.until
|
|
10411
|
-
}),
|
|
10412
|
-
aggregateWarmSecondsByGroup(db, {
|
|
10432
|
+
readWorkspaceInsightsUsageBundle(db, {
|
|
10413
10433
|
workspaceId: input.workspaceId,
|
|
10414
10434
|
since: window.since,
|
|
10415
10435
|
until: window.until,
|
|
10416
|
-
|
|
10436
|
+
priorSince: window.priorSince,
|
|
10437
|
+
priorUntil: window.priorUntil,
|
|
10438
|
+
monthSince: startOfUtcMonth2(now),
|
|
10439
|
+
granularity: input.range === "today" ? "hour" : "day",
|
|
10440
|
+
warmGroupLimit: 24
|
|
10417
10441
|
}),
|
|
10418
10442
|
listLiveWarmLeases(db, input.workspaceId),
|
|
10419
|
-
aggregateRootSessionDrivers(db, {
|
|
10420
|
-
workspaceId: input.workspaceId,
|
|
10421
|
-
since: window.since,
|
|
10422
|
-
until: window.until,
|
|
10423
|
-
...filter,
|
|
10424
|
-
limit: 8
|
|
10425
|
-
}),
|
|
10426
|
-
aggregateScheduleFacts(db, {
|
|
10427
|
-
workspaceId: input.workspaceId,
|
|
10428
|
-
since: window.since,
|
|
10429
|
-
until: window.until,
|
|
10430
|
-
...filter
|
|
10431
|
-
}),
|
|
10432
10443
|
listScheduledTasks(db, input.workspaceId, 100),
|
|
10433
10444
|
aggregateSessionDepth(db, input.workspaceId),
|
|
10434
10445
|
listFloorSessions(db, input.workspaceId, 24),
|
|
10435
|
-
settings.sandboxSelfhostedEnabled ? countOnlineMachines(db, input.workspaceId, MACHINE_HEARTBEAT_FRESH_MS, now) : Promise.resolve(0)
|
|
10436
|
-
sumUsageQuantity2(db, {
|
|
10437
|
-
workspaceId: input.workspaceId,
|
|
10438
|
-
eventType: "model.tokens",
|
|
10439
|
-
since: startOfUtcMonth2(now)
|
|
10440
|
-
}),
|
|
10441
|
-
sumUsageQuantity2(db, {
|
|
10442
|
-
workspaceId: input.workspaceId,
|
|
10443
|
-
eventType: "agent_run.created",
|
|
10444
|
-
since: startOfUtcMonth2(now)
|
|
10445
|
-
}),
|
|
10446
|
-
listModelCallFacets(db, {
|
|
10447
|
-
workspaceId: input.workspaceId,
|
|
10448
|
-
since: window.since,
|
|
10449
|
-
until: window.until
|
|
10450
|
-
}),
|
|
10451
|
-
listRecentModelCalls(db, {
|
|
10452
|
-
workspaceId: input.workspaceId,
|
|
10453
|
-
since: window.since,
|
|
10454
|
-
until: window.until,
|
|
10455
|
-
...filter,
|
|
10456
|
-
limit: 50
|
|
10457
|
-
}),
|
|
10458
|
-
aggregateModelContextContributions(db, {
|
|
10459
|
-
workspaceId: input.workspaceId,
|
|
10460
|
-
since: window.since,
|
|
10461
|
-
until: window.until,
|
|
10462
|
-
...filter
|
|
10463
|
-
})
|
|
10446
|
+
settings.sandboxSelfhostedEnabled ? countOnlineMachines(db, input.workspaceId, MACHINE_HEARTBEAT_FRESH_MS, now) : Promise.resolve(0)
|
|
10464
10447
|
]);
|
|
10465
|
-
const
|
|
10466
|
-
|
|
10467
|
-
|
|
10468
|
-
|
|
10469
|
-
|
|
10470
|
-
|
|
10471
|
-
|
|
10472
|
-
|
|
10473
|
-
|
|
10474
|
-
|
|
10448
|
+
const {
|
|
10449
|
+
modelRows,
|
|
10450
|
+
priorModelRows,
|
|
10451
|
+
factBuckets: factDays,
|
|
10452
|
+
rootDrivers,
|
|
10453
|
+
priorRootDrivers,
|
|
10454
|
+
scheduleFacts,
|
|
10455
|
+
facets,
|
|
10456
|
+
recentCalls,
|
|
10457
|
+
promptContributions
|
|
10458
|
+
} = modelBundle;
|
|
10459
|
+
const {
|
|
10460
|
+
workspaceCreditMicros,
|
|
10461
|
+
priorWorkspaceCreditMicros,
|
|
10462
|
+
warmSeconds,
|
|
10463
|
+
priorWarmSeconds,
|
|
10464
|
+
buckets: usageBuckets,
|
|
10465
|
+
warmGroups,
|
|
10466
|
+
billableTokensUsed,
|
|
10467
|
+
agentRunsUsed
|
|
10468
|
+
} = usageBundle;
|
|
10469
|
+
const [attached, fireCounts] = await Promise.all([
|
|
10475
10470
|
countSessionsAttachedToGroups(
|
|
10476
10471
|
db,
|
|
10477
10472
|
input.workspaceId,
|
|
@@ -10546,13 +10541,13 @@ async function getWorkspaceInsights(db, settings, input) {
|
|
|
10546
10541
|
cacheKnownCalls: 0,
|
|
10547
10542
|
calls: 0
|
|
10548
10543
|
};
|
|
10549
|
-
const modelCostMicros = modelFilterActive ? facts.costMicros :
|
|
10544
|
+
const modelCostMicros = modelFilterActive ? facts.costMicros : usageBuckets.get(bucket)?.costMicros ?? facts.costMicros;
|
|
10550
10545
|
return {
|
|
10551
10546
|
label: input.range === "today" ? bucket.slice(11) : bucket.slice(5),
|
|
10552
10547
|
modelCostUsd: microsToUsd(modelCostMicros),
|
|
10553
10548
|
estimatedProviderUsd: microsToUsd(facts.estimatedProviderCostMicros),
|
|
10554
10549
|
estimatedProviderCostKnownCalls: facts.estimatedProviderCostKnownCalls,
|
|
10555
|
-
warmSeconds:
|
|
10550
|
+
warmSeconds: usageBuckets.get(bucket)?.warmSeconds ?? 0,
|
|
10556
10551
|
inputTokens: facts.inputTokens,
|
|
10557
10552
|
outputTokens: facts.outputTokens,
|
|
10558
10553
|
cachedTokens: facts.cachedTokens,
|
|
@@ -10579,7 +10574,7 @@ async function getWorkspaceInsights(db, settings, input) {
|
|
|
10579
10574
|
return {
|
|
10580
10575
|
id: `root:${row.rootSessionId}`,
|
|
10581
10576
|
groupBy: "root_session",
|
|
10582
|
-
label:
|
|
10577
|
+
label: insightsSessionLabel({ id: row.rootSessionId, title: row.title, depth: 0 }),
|
|
10583
10578
|
creditUsd,
|
|
10584
10579
|
estimatedProviderUsd: microsToUsd(row.estimatedProviderCostMicros),
|
|
10585
10580
|
estimatedProviderCostKnownCalls: row.estimatedProviderCostKnownCalls,
|
|
@@ -10611,7 +10606,11 @@ async function getWorkspaceInsights(db, settings, input) {
|
|
|
10611
10606
|
return row.model === model;
|
|
10612
10607
|
}).map((row) => ({
|
|
10613
10608
|
id: row.id,
|
|
10614
|
-
title:
|
|
10609
|
+
title: insightsSessionLabel({
|
|
10610
|
+
id: row.id,
|
|
10611
|
+
title: row.title,
|
|
10612
|
+
depth: row.nestedAgentDepth
|
|
10613
|
+
}),
|
|
10615
10614
|
state: floorState(row),
|
|
10616
10615
|
depth: row.nestedAgentDepth,
|
|
10617
10616
|
model: row.model,
|
|
@@ -10644,7 +10643,11 @@ async function getWorkspaceInsights(db, settings, input) {
|
|
|
10644
10643
|
occurredAt: row.occurredAt.toISOString(),
|
|
10645
10644
|
recordedAt: row.recordedAt.toISOString(),
|
|
10646
10645
|
sessionId: row.sessionId,
|
|
10647
|
-
sessionTitle:
|
|
10646
|
+
sessionTitle: insightsSessionLabel({
|
|
10647
|
+
id: row.sessionId,
|
|
10648
|
+
title: row.sessionTitle,
|
|
10649
|
+
depth: row.sessionDepth
|
|
10650
|
+
}),
|
|
10648
10651
|
turnId: row.turnId,
|
|
10649
10652
|
provider: row.provider,
|
|
10650
10653
|
providerApi: row.providerApi,
|
|
@@ -10701,7 +10704,11 @@ async function getWorkspaceInsights(db, settings, input) {
|
|
|
10701
10704
|
sessionsTouched: depth.sessionsTouched,
|
|
10702
10705
|
rootSessions: depth.rootSessions,
|
|
10703
10706
|
deepestDepth: depth.deepestDepth,
|
|
10704
|
-
deepestSessionTitle: depth.
|
|
10707
|
+
deepestSessionTitle: depth.deepestSessionId ? insightsSessionLabel({
|
|
10708
|
+
id: depth.deepestSessionId,
|
|
10709
|
+
title: depth.deepestSessionTitle,
|
|
10710
|
+
depth: depth.deepestDepth
|
|
10711
|
+
}) : "",
|
|
10705
10712
|
avgDepth: Math.round(depth.avgDepth * 10) / 10,
|
|
10706
10713
|
warmIdleNow: liveWarm.filter((lease) => lease.turnHolders === 0).length,
|
|
10707
10714
|
billableTokensUsed,
|
|
@@ -11640,6 +11647,7 @@ import {
|
|
|
11640
11647
|
getWorkspaceInstructionPolicyBaseline,
|
|
11641
11648
|
getWorkspaceKnowledgeChangeProposalSummary,
|
|
11642
11649
|
getWorkspaceKnowledgeClaimInitiatingHuman,
|
|
11650
|
+
materializeConfirmedRememberKnowledgeMemory,
|
|
11643
11651
|
nestedPostgresSqlState as nestedPostgresSqlState3,
|
|
11644
11652
|
rebaselineWorkspaceInstructionPolicyKnowledgeProposal
|
|
11645
11653
|
} from "@opengeni/db";
|
|
@@ -11783,6 +11791,7 @@ function createRememberRouter(options) {
|
|
|
11783
11791
|
const rebaselineProposal = options.rebaselineProposal ?? rebaselineWorkspaceInstructionPolicyKnowledgeProposal;
|
|
11784
11792
|
const activateHumanConfirmed = options.activateHumanConfirmed ?? activateHumanConfirmedLearningDecision;
|
|
11785
11793
|
const confirmKnowledgeClaim = options.confirmKnowledgeClaim ?? confirmRememberKnowledgeClaim;
|
|
11794
|
+
const materializeKnowledgeMemory = options.materializeKnowledgeMemory ?? materializeConfirmedRememberKnowledgeMemory;
|
|
11786
11795
|
const proposalSummary = options.proposalSummary ?? getWorkspaceKnowledgeChangeProposalSummary;
|
|
11787
11796
|
const claimInitiatingHuman = options.claimInitiatingHuman ?? getWorkspaceKnowledgeClaimInitiatingHuman;
|
|
11788
11797
|
const instructionPolicyBaseline = options.instructionPolicyBaseline ?? getWorkspaceInstructionPolicyBaseline;
|
|
@@ -11832,7 +11841,11 @@ function createRememberRouter(options) {
|
|
|
11832
11841
|
scope: request.scope
|
|
11833
11842
|
};
|
|
11834
11843
|
if (route.decision === "blocked" || route.write === null) {
|
|
11835
|
-
return RememberReceipt.parse({
|
|
11844
|
+
return RememberReceipt.parse({
|
|
11845
|
+
...base,
|
|
11846
|
+
status: "blocked",
|
|
11847
|
+
reason: "learning_policy_off"
|
|
11848
|
+
});
|
|
11836
11849
|
}
|
|
11837
11850
|
if (route.write.knowledgeChangeProposalId === null) {
|
|
11838
11851
|
return RememberReceipt.parse({
|
|
@@ -11888,19 +11901,27 @@ function createRememberRouter(options) {
|
|
|
11888
11901
|
if (!initiatingHuman) {
|
|
11889
11902
|
throw new RememberError("proposal_unavailable", "The remember claim is not available");
|
|
11890
11903
|
}
|
|
11891
|
-
const receipt2 = await
|
|
11892
|
-
|
|
11893
|
-
|
|
11894
|
-
|
|
11895
|
-
|
|
11896
|
-
|
|
11897
|
-
|
|
11898
|
-
|
|
11899
|
-
|
|
11900
|
-
|
|
11901
|
-
|
|
11902
|
-
|
|
11903
|
-
|
|
11904
|
+
const { receipt: receipt2, materialization } = await options.db.transaction(async (tx) => {
|
|
11905
|
+
const transaction = tx;
|
|
11906
|
+
const activationReceipt = await confirmKnowledgeClaim(transaction, {
|
|
11907
|
+
caller: {
|
|
11908
|
+
workspaceId: attempt.workspaceId,
|
|
11909
|
+
subjectId: initiatingHuman,
|
|
11910
|
+
sessionId: attempt.sessionId,
|
|
11911
|
+
turnId: attempt.turnId,
|
|
11912
|
+
executionGeneration: attempt.executionGeneration
|
|
11913
|
+
},
|
|
11914
|
+
request: {
|
|
11915
|
+
operationId: request.operationId,
|
|
11916
|
+
claimId: request.claimId,
|
|
11917
|
+
humanInputRequestId: request.humanInputRequestId
|
|
11918
|
+
}
|
|
11919
|
+
});
|
|
11920
|
+
const materializedMemory = await materializeKnowledgeMemory(
|
|
11921
|
+
transaction,
|
|
11922
|
+
activationReceipt
|
|
11923
|
+
);
|
|
11924
|
+
return { receipt: activationReceipt, materialization: materializedMemory };
|
|
11904
11925
|
});
|
|
11905
11926
|
return RememberConfirmReceipt.parse({
|
|
11906
11927
|
status: "activated",
|
|
@@ -11912,10 +11933,11 @@ function createRememberRouter(options) {
|
|
|
11912
11933
|
destination: "knowledge",
|
|
11913
11934
|
receiptId: receipt2.id,
|
|
11914
11935
|
claimId: receipt2.claimId,
|
|
11936
|
+
memoryId: materialization.memoryId,
|
|
11915
11937
|
approvalReviewId: receipt2.approvalReviewId,
|
|
11916
11938
|
effectiveAt: receipt2.createdAt,
|
|
11917
11939
|
authorityKind: "human_confirmed",
|
|
11918
|
-
undo: "
|
|
11940
|
+
undo: "memory_management"
|
|
11919
11941
|
}
|
|
11920
11942
|
});
|
|
11921
11943
|
}
|
|
@@ -13063,7 +13085,8 @@ function organizationMembershipHttpStatus(sqlState) {
|
|
|
13063
13085
|
if (sqlState === "22023" || sqlState === "23514") return 400;
|
|
13064
13086
|
if (sqlState === "42501") return 403;
|
|
13065
13087
|
if (sqlState === "P0002") return 404;
|
|
13066
|
-
if (sqlState === "23505" || sqlState === "40001" || sqlState === "55000"
|
|
13088
|
+
if (sqlState === "23505" || sqlState === "40001" || sqlState === "55000" || sqlState === "55P03")
|
|
13089
|
+
return 409;
|
|
13067
13090
|
return null;
|
|
13068
13091
|
}
|
|
13069
13092
|
|
|
@@ -13075,7 +13098,7 @@ import {
|
|
|
13075
13098
|
import {
|
|
13076
13099
|
getNewSessionDraftInTransaction,
|
|
13077
13100
|
getEnrollment as getEnrollment3,
|
|
13078
|
-
getRig as
|
|
13101
|
+
getRig as getRig6,
|
|
13079
13102
|
getSandbox as getSandbox4,
|
|
13080
13103
|
getVariableSet as getVariableSet4,
|
|
13081
13104
|
NewSessionDraftAccessError,
|
|
@@ -13142,17 +13165,30 @@ async function hydrateNewSessionDraft(deps, grant, workspaceId, row) {
|
|
|
13142
13165
|
}
|
|
13143
13166
|
}
|
|
13144
13167
|
const options = { ...mapped.options };
|
|
13145
|
-
|
|
13146
|
-
|
|
13147
|
-
|
|
13148
|
-
|
|
13149
|
-
|
|
13150
|
-
|
|
13168
|
+
const variableSetIds = options.variableSetIds ?? [];
|
|
13169
|
+
if (variableSetIds.length > 0) {
|
|
13170
|
+
const selectionsAuthorized = hasPermission(grant.permissions, "variable-sets:attach") && hasPermission(grant.permissions, "variable-sets:use") && (await Promise.all(
|
|
13171
|
+
variableSetIds.map(
|
|
13172
|
+
(variableSetId) => getVariableSet4(
|
|
13173
|
+
deps.db,
|
|
13174
|
+
{ accountId: grant.accountId, workspaceId, subjectId: grant.subjectId },
|
|
13175
|
+
variableSetId
|
|
13176
|
+
)
|
|
13177
|
+
)
|
|
13178
|
+
)).every(Boolean);
|
|
13179
|
+
if (selectionsAuthorized) {
|
|
13180
|
+
options.variableSetIds = variableSetIds;
|
|
13181
|
+
options.variableSetId = variableSetIds[variableSetIds.length - 1];
|
|
13182
|
+
} else {
|
|
13183
|
+
delete options.variableSetIds;
|
|
13151
13184
|
delete options.variableSetId;
|
|
13152
13185
|
}
|
|
13186
|
+
} else {
|
|
13187
|
+
delete options.variableSetIds;
|
|
13188
|
+
delete options.variableSetId;
|
|
13153
13189
|
}
|
|
13154
13190
|
if (options.rigId) {
|
|
13155
|
-
const rig = await
|
|
13191
|
+
const rig = await getRig6(deps.db, workspaceId, options.rigId);
|
|
13156
13192
|
if (!rig?.activeVersion) delete options.rigId;
|
|
13157
13193
|
}
|
|
13158
13194
|
if (options.targetSandboxId) {
|
|
@@ -14195,7 +14231,10 @@ export {
|
|
|
14195
14231
|
TranscriptionServiceError,
|
|
14196
14232
|
VIDEO_GENERATION_ADAPTER_VERSION,
|
|
14197
14233
|
VIDEO_GENERATION_MODEL_CATALOG,
|
|
14234
|
+
WORKSPACE_INSIGHTS_MODEL_FILTER_MAX_UTF8_BYTES,
|
|
14235
|
+
WORKSPACE_INSIGHTS_PROVIDER_FILTER_MAX_UTF8_BYTES,
|
|
14198
14236
|
WebCryptoEditableArtifactLiveTokens,
|
|
14237
|
+
WorkspaceInsightsFilterValidationError,
|
|
14199
14238
|
acceptSessionUserMessage,
|
|
14200
14239
|
acceptSessionUserMessageWithOutcome,
|
|
14201
14240
|
accessGrantAuthorizationFromContext,
|
|
@@ -14344,6 +14383,7 @@ export {
|
|
|
14344
14383
|
hashEditableArtifactCreateRequest,
|
|
14345
14384
|
hashEditableArtifactImportRequest,
|
|
14346
14385
|
inlinePackSkillInstall,
|
|
14386
|
+
insightsSessionLabel,
|
|
14347
14387
|
inspectEditableArtifactLiveWireEnvelope,
|
|
14348
14388
|
isAcceptedMimeType,
|
|
14349
14389
|
isAuthoritativeGitHubRepositorySelectionError,
|
|
@@ -14385,6 +14425,7 @@ export {
|
|
|
14385
14425
|
normalizePrReviewPullRequestEvent,
|
|
14386
14426
|
normalizeResources,
|
|
14387
14427
|
normalizeVideoGenerationRequest,
|
|
14428
|
+
normalizeWorkspaceInsightsFilter,
|
|
14388
14429
|
officialMcpRegistryUrl,
|
|
14389
14430
|
ogatxEditableArtifactMutationIntentCodec,
|
|
14390
14431
|
openGeniSlackBotMetadata,
|