@opengeni/core 1.0.2 → 1.1.0
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/billing/agent-run-admission.d.ts +17 -0
- package/dist/dependencies.d.ts +3 -1
- package/dist/domain/knowledge-messages.d.ts +2 -2
- package/dist/goal-admission.d.ts +480 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +245 -34
- package/dist/index.js.map +1 -1
- package/package.json +12 -12
- package/src/application/session-tenancy.ts +4 -8
- package/src/application/user-resource-grants.ts +0 -13
- package/src/billing/agent-run-admission.ts +99 -0
- package/src/dependencies.ts +3 -0
- package/src/domain/session-tool-policy.ts +14 -5
- package/src/domain/sessions.ts +11 -6
- package/src/goal-admission.ts +187 -0
- package/src/index.ts +2 -0
package/dist/index.js
CHANGED
|
@@ -4856,6 +4856,7 @@ import {
|
|
|
4856
4856
|
OPENGENI_SLACK_BOT_SESSION_METADATA_KEY as OPENGENI_SLACK_BOT_SESSION_METADATA_KEY2,
|
|
4857
4857
|
SessionSkills,
|
|
4858
4858
|
resolveBundledSkillSelection,
|
|
4859
|
+
bundledSkillSelectionForAgentConfig as bundledSkillSelectionForAgentConfig2,
|
|
4859
4860
|
SessionSpawnDenial,
|
|
4860
4861
|
ServiceTurnInitiator,
|
|
4861
4862
|
ServiceTurnInitiatorContext as ServiceTurnInitiatorContext2,
|
|
@@ -4922,7 +4923,6 @@ import {
|
|
|
4922
4923
|
SessionToolPolicyVersionConflictError,
|
|
4923
4924
|
SessionCreateIdempotencyConflictError,
|
|
4924
4925
|
PersonalResourceAttachmentAcceptanceError,
|
|
4925
|
-
sessionTenancyProductActivated as sessionTenancyProductActivated2,
|
|
4926
4926
|
workspaceControlRequestLockTimeoutMs,
|
|
4927
4927
|
WorkspaceControlBusyError
|
|
4928
4928
|
} from "@opengeni/db";
|
|
@@ -7788,6 +7788,7 @@ import {
|
|
|
7788
7788
|
import {
|
|
7789
7789
|
AGENT_SKILL_MANAGE_TOOL_NAMES,
|
|
7790
7790
|
AUTOMATIC_SESSION_TITLE_FALLBACK,
|
|
7791
|
+
bundledSkillSelectionForAgentConfig,
|
|
7791
7792
|
DEFAULT_FIRST_PARTY_MCP_PERMISSIONS,
|
|
7792
7793
|
FIRST_PARTY_IN_PROCESS_TOOL_NAMES,
|
|
7793
7794
|
SESSION_EFFECTIVE_TOOL_POLICY_ID_LIMIT,
|
|
@@ -8023,13 +8024,17 @@ async function workspaceSessionEffectiveToolsContext(deps, workspaceId, subjectI
|
|
|
8023
8024
|
}
|
|
8024
8025
|
function sessionHasSkills(session, context) {
|
|
8025
8026
|
if (context.hasWorkspaceSkills || session.skills.length > 0) return true;
|
|
8026
|
-
|
|
8027
|
+
const bundledSkillIds = bundledSkillSelectionForAgentConfig(
|
|
8028
|
+
session.bundledSkillIds,
|
|
8029
|
+
session.agent
|
|
8030
|
+
);
|
|
8031
|
+
if (bundledSkillIds === void 0) return true;
|
|
8027
8032
|
const tools = new Set(
|
|
8028
8033
|
resolveAgentToolFamilies(session.agent).firstPartyTools(
|
|
8029
8034
|
allowedFirstPartyMcpToolsForSession2(context.settings, session.firstPartyMcpTools)
|
|
8030
8035
|
)
|
|
8031
8036
|
);
|
|
8032
|
-
return
|
|
8037
|
+
return bundledSkillIds.some((id) => {
|
|
8033
8038
|
if ([
|
|
8034
8039
|
"builtin:opengeni-documents",
|
|
8035
8040
|
"builtin:opengeni-spreadsheets",
|
|
@@ -8078,7 +8083,7 @@ function sessionEffectiveToolProjectionInput(session, toolRefs, context) {
|
|
|
8078
8083
|
) && session.sandboxOs !== "windows" ? ["code_search"] : []
|
|
8079
8084
|
] : [];
|
|
8080
8085
|
const needsTitle = session.titleSource !== "user" && (!session.title?.trim() || session.title.trim() === AUTOMATIC_SESSION_TITLE_FALLBACK);
|
|
8081
|
-
const firstPartyMcpTools = context && toolRefs.some((ref) => ref.id === "opengeni") ? resolveAgentToolFamilies(session.agent).firstPartyTools(
|
|
8086
|
+
const firstPartyMcpTools = context && toolRefs.some((ref) => ref.id === "opengeni") ? resolveAgentToolFamilies(session.agent, { sandboxAttached: sandboxAvailable }).firstPartyTools(
|
|
8082
8087
|
allowedFirstPartyMcpToolsForSession2(context.settings, session.firstPartyMcpTools)
|
|
8083
8088
|
).filter((name) => name !== "set_session_title" || !needsTitle) : [];
|
|
8084
8089
|
const interactionNames = new Set(FIRST_PARTY_IN_PROCESS_TOOL_NAMES);
|
|
@@ -8101,7 +8106,9 @@ function sessionEffectiveToolProjectionInput(session, toolRefs, context) {
|
|
|
8101
8106
|
].includes(name);
|
|
8102
8107
|
if (permissionAllowed(readOnly ? "sessions:read" : "sessions:control") && (name !== "browser_download_save" || permissionAllowed("files:upload"))) {
|
|
8103
8108
|
firstPartyModelNames.set(name, `interaction__${name}`);
|
|
8104
|
-
if (!firstPartyMcpTools.includes(name) && resolveAgentToolFamilies(session.agent
|
|
8109
|
+
if (!firstPartyMcpTools.includes(name) && resolveAgentToolFamilies(session.agent, {
|
|
8110
|
+
sandboxAttached: sandboxAvailable
|
|
8111
|
+
}).allowsFirstPartyTool(name) && session.firstPartyMcpTools.includes(name))
|
|
8105
8112
|
firstPartyMcpTools.push(name);
|
|
8106
8113
|
}
|
|
8107
8114
|
}
|
|
@@ -8132,7 +8139,8 @@ function sessionEffectiveToolProjectionInput(session, toolRefs, context) {
|
|
|
8132
8139
|
webSearch: hostedToolNames.includes("web_search"),
|
|
8133
8140
|
humanInput: context?.humanInputEnabled ?? false,
|
|
8134
8141
|
media: media.toolsKnown ? media.hosted.length + media.runtime.length > 0 : void 0,
|
|
8135
|
-
routerInHistory: context?.routerInHistory === true || context?.routerHistorySessionIds?.has(session.id) === true
|
|
8142
|
+
routerInHistory: context?.routerInHistory === true || context?.routerHistorySessionIds?.has(session.id) === true,
|
|
8143
|
+
...context ? { sandboxAttached: sandboxAvailable } : {}
|
|
8136
8144
|
};
|
|
8137
8145
|
const families = resolveAgentToolFamilies(session.agent, environment);
|
|
8138
8146
|
environment.hasDeferredTools = toolRefs.some(
|
|
@@ -8538,10 +8546,8 @@ import {
|
|
|
8538
8546
|
isRetryableDatabaseTransportFailure,
|
|
8539
8547
|
nestedPostgresSqlState as nestedPostgresSqlState3,
|
|
8540
8548
|
replayAppliedSessionFork,
|
|
8541
|
-
sessionTenancyProductActivated,
|
|
8542
8549
|
SessionTenancyAccessError,
|
|
8543
8550
|
SessionTenancyInvalidRequestError,
|
|
8544
|
-
SessionTenancyNotActivatedError,
|
|
8545
8551
|
transitionSessionVisibility
|
|
8546
8552
|
} from "@opengeni/db";
|
|
8547
8553
|
import { publishDurableSessionEvents } from "@opengeni/events";
|
|
@@ -8605,9 +8611,6 @@ async function requireManagedHumanPrivateSessionCreate(deps, authorization, work
|
|
|
8605
8611
|
async function requireSessionTenancyMutationGate(deps, authorization, workspaceId, permissions) {
|
|
8606
8612
|
requireVerifiedOwningUser(authorization, workspaceId);
|
|
8607
8613
|
for (const permission of permissions) requirePermission(authorization.grant, permission);
|
|
8608
|
-
if (!await sessionTenancyProductActivated(deps.db, workspaceId)) {
|
|
8609
|
-
throw new SessionTenancyNotActivatedError();
|
|
8610
|
-
}
|
|
8611
8614
|
}
|
|
8612
8615
|
async function publishExactCommittedEvent(deps, input) {
|
|
8613
8616
|
if (input.eventId === null && input.eventSequence === null) return;
|
|
@@ -8879,11 +8882,6 @@ async function requireAtomicPersonalResourceAttachment(deps, authorization, work
|
|
|
8879
8882
|
cause: error
|
|
8880
8883
|
});
|
|
8881
8884
|
}
|
|
8882
|
-
if (!await sessionTenancyProductActivated2(deps.db, workspaceId)) {
|
|
8883
|
-
throw new HTTPException17(409, {
|
|
8884
|
-
message: "Session tenancy is not activated for this organization."
|
|
8885
|
-
});
|
|
8886
|
-
}
|
|
8887
8885
|
if (existingSession && intent.expectedAuthorityEpoch === void 0) {
|
|
8888
8886
|
throw new HTTPException17(422, {
|
|
8889
8887
|
message: "Personal-resource attachment requires expectedAuthorityEpoch."
|
|
@@ -9248,6 +9246,13 @@ function automaticTitleForAgentChildCreate(presentation, goal, initialMessage) {
|
|
|
9248
9246
|
return null;
|
|
9249
9247
|
}
|
|
9250
9248
|
async function createAndStartSessionWithOutcome(input) {
|
|
9249
|
+
const frozenBundledSkillIds = bundledSkillSelectionForAgentConfig2(
|
|
9250
|
+
input.bundledSkillIds,
|
|
9251
|
+
input.agentConfig
|
|
9252
|
+
);
|
|
9253
|
+
if (frozenBundledSkillIds !== input.bundledSkillIds) {
|
|
9254
|
+
input = { ...input, bundledSkillIds: frozenBundledSkillIds };
|
|
9255
|
+
}
|
|
9251
9256
|
const sessionMetadata = metadataWithTurnExecutionPolicyV1(
|
|
9252
9257
|
{
|
|
9253
9258
|
...input.metadata,
|
|
@@ -10253,6 +10258,7 @@ async function createSessionForRequestInFileScope(unresolvedDeps, grant, workspa
|
|
|
10253
10258
|
if (agentResolution.instructions !== void 0) {
|
|
10254
10259
|
payload.instructions = agentResolution.instructions;
|
|
10255
10260
|
}
|
|
10261
|
+
bundledSkillIds = bundledSkillSelectionForAgentConfig2(bundledSkillIds, agentConfig);
|
|
10256
10262
|
const parentCallingTurn = parentSession && creationInitiator.actor ? await getSessionTurnForAttempt3(
|
|
10257
10263
|
db,
|
|
10258
10264
|
workspaceId,
|
|
@@ -12751,6 +12757,213 @@ function filenameForMimeType(mimeType) {
|
|
|
12751
12757
|
}
|
|
12752
12758
|
}
|
|
12753
12759
|
|
|
12760
|
+
// src/goal-admission.ts
|
|
12761
|
+
import {
|
|
12762
|
+
isModelAvailableForNewSelection as isModelAvailableForNewSelection2,
|
|
12763
|
+
policyProviderIdForModel as policyProviderIdForModel2,
|
|
12764
|
+
resolveModelProvider,
|
|
12765
|
+
runnableLatencyModesForModel,
|
|
12766
|
+
withCodexCatalogProvider as withCodexCatalogProvider4,
|
|
12767
|
+
withXaiSubscriptionCatalogProvider as withXaiSubscriptionCatalogProvider2
|
|
12768
|
+
} from "@opengeni/config";
|
|
12769
|
+
import {
|
|
12770
|
+
evaluateWorkspaceModelPolicy as evaluateWorkspaceModelPolicy3
|
|
12771
|
+
} from "@opengeni/contracts";
|
|
12772
|
+
import { isCodexBilledModel as isCodexBilledModel2 } from "@opengeni/codex";
|
|
12773
|
+
import { getWorkspaceModelPolicy as getWorkspaceModelPolicy3 } from "@opengeni/db";
|
|
12774
|
+
|
|
12775
|
+
// src/billing/agent-run-admission.ts
|
|
12776
|
+
import { configuredStaticUsageLimits as configuredStaticUsageLimits2 } from "@opengeni/config";
|
|
12777
|
+
import {
|
|
12778
|
+
checkWorkspaceAllowance as checkWorkspaceAllowance3,
|
|
12779
|
+
getBillingBalance as getBillingBalance3,
|
|
12780
|
+
isCodexBilledTurn as isCodexBilledTurn2,
|
|
12781
|
+
sumUsageQuantity as sumUsageQuantity3
|
|
12782
|
+
} from "@opengeni/db";
|
|
12783
|
+
async function agentRunAdmissionDenial(services, input) {
|
|
12784
|
+
const codexBilled = await isCodexBilledTurn2({
|
|
12785
|
+
db: services.db,
|
|
12786
|
+
settings: services.settings,
|
|
12787
|
+
workspaceId: input.workspaceId,
|
|
12788
|
+
model: input.model
|
|
12789
|
+
});
|
|
12790
|
+
const externallyBilled = modelFundingForAdmission(
|
|
12791
|
+
services.settings,
|
|
12792
|
+
input.model,
|
|
12793
|
+
codexBilled
|
|
12794
|
+
).fundedWithoutCredits;
|
|
12795
|
+
if (!externallyBilled && (services.settings.billingMode === "stripe" || services.settings.usageLimitsMode === "managed")) {
|
|
12796
|
+
if (services.entitlements) {
|
|
12797
|
+
const decision = await services.entitlements.admitRun({
|
|
12798
|
+
accountId: input.accountId,
|
|
12799
|
+
workspaceId: input.workspaceId,
|
|
12800
|
+
action: "agent_run:create",
|
|
12801
|
+
quantity: input.requestedAgentRuns
|
|
12802
|
+
});
|
|
12803
|
+
if (!decision.allowed) return "insufficient_credits";
|
|
12804
|
+
} else {
|
|
12805
|
+
const balance = await getBillingBalance3(services.db, input.accountId);
|
|
12806
|
+
if (balance.balanceMicros <= 0) return "insufficient_credits";
|
|
12807
|
+
}
|
|
12808
|
+
}
|
|
12809
|
+
if (!externallyBilled) {
|
|
12810
|
+
const refusal = await checkWorkspaceAllowance3(services.db, {
|
|
12811
|
+
accountId: input.accountId,
|
|
12812
|
+
workspaceId: input.workspaceId,
|
|
12813
|
+
subjectId: input.initiatingHumanSubjectId ?? null
|
|
12814
|
+
});
|
|
12815
|
+
if (refusal) return refusal.code;
|
|
12816
|
+
}
|
|
12817
|
+
if (services.settings.usageLimitsMode !== "static" && services.settings.usageLimitsMode !== "managed") {
|
|
12818
|
+
return null;
|
|
12819
|
+
}
|
|
12820
|
+
const limits = configuredStaticUsageLimits2(services.settings);
|
|
12821
|
+
if (!externallyBilled && limits.maxMonthlyCostMicrosPerAccount) {
|
|
12822
|
+
const used = await sumUsageQuantity3(services.db, {
|
|
12823
|
+
accountId: input.accountId,
|
|
12824
|
+
eventType: "model.cost",
|
|
12825
|
+
since: startOfUtcMonth2()
|
|
12826
|
+
});
|
|
12827
|
+
if (used >= limits.maxMonthlyCostMicrosPerAccount) {
|
|
12828
|
+
return "monthly_model_cost_limit";
|
|
12829
|
+
}
|
|
12830
|
+
}
|
|
12831
|
+
if (limits.maxMonthlyAgentRunsPerWorkspace) {
|
|
12832
|
+
const used = await sumUsageQuantity3(services.db, {
|
|
12833
|
+
workspaceId: input.workspaceId,
|
|
12834
|
+
eventType: "agent_run.created",
|
|
12835
|
+
since: startOfUtcMonth2()
|
|
12836
|
+
});
|
|
12837
|
+
if (used + input.requestedAgentRuns > limits.maxMonthlyAgentRunsPerWorkspace) {
|
|
12838
|
+
return "monthly_agent_run_limit";
|
|
12839
|
+
}
|
|
12840
|
+
}
|
|
12841
|
+
return null;
|
|
12842
|
+
}
|
|
12843
|
+
function startOfUtcMonth2() {
|
|
12844
|
+
const now = /* @__PURE__ */ new Date();
|
|
12845
|
+
return new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), 1));
|
|
12846
|
+
}
|
|
12847
|
+
|
|
12848
|
+
// src/goal-admission.ts
|
|
12849
|
+
function goalContinuationModelDecision(input) {
|
|
12850
|
+
const catalogSettings = input.settings.supergrokSubscriptionEnabled ? withXaiSubscriptionCatalogProvider2(
|
|
12851
|
+
input.settings.codexSubscriptionEnabled ? withCodexCatalogProvider4(input.settings) : input.settings
|
|
12852
|
+
) : input.settings.codexSubscriptionEnabled ? withCodexCatalogProvider4(input.settings) : input.settings;
|
|
12853
|
+
const model = input.inheritedModel;
|
|
12854
|
+
if (!resolveModelProvider(catalogSettings, model)) {
|
|
12855
|
+
return {
|
|
12856
|
+
model,
|
|
12857
|
+
blocked: "The selected model is unavailable. Choose an available model before resuming.",
|
|
12858
|
+
pausedReason: "model_unavailable"
|
|
12859
|
+
};
|
|
12860
|
+
}
|
|
12861
|
+
if (!isModelAvailableForNewSelection2(catalogSettings, model)) {
|
|
12862
|
+
return {
|
|
12863
|
+
model,
|
|
12864
|
+
blocked: "The selected model has been retired. Choose an available model before resuming.",
|
|
12865
|
+
pausedReason: "model_unavailable"
|
|
12866
|
+
};
|
|
12867
|
+
}
|
|
12868
|
+
if (input.workspaceModelPolicy !== null && !evaluateWorkspaceModelPolicy3(input.workspaceModelPolicy, {
|
|
12869
|
+
providerId: policyProviderIdForModel2(catalogSettings, model),
|
|
12870
|
+
modelId: model
|
|
12871
|
+
}).allowed) {
|
|
12872
|
+
return {
|
|
12873
|
+
model,
|
|
12874
|
+
blocked: "Workspace policy blocks the selected model. Choose an allowed model before resuming.",
|
|
12875
|
+
pausedReason: "model_policy"
|
|
12876
|
+
};
|
|
12877
|
+
}
|
|
12878
|
+
if (input.codexCompactionMode === "remote_v2" && !isCodexBilledModel2(model)) {
|
|
12879
|
+
return {
|
|
12880
|
+
model,
|
|
12881
|
+
blocked: "This conversation requires a Codex model. Choose a Codex model before resuming.",
|
|
12882
|
+
pausedReason: "model_policy"
|
|
12883
|
+
};
|
|
12884
|
+
}
|
|
12885
|
+
if (!runnableLatencyModesForModel(catalogSettings, model).includes(input.latencyMode ?? "standard")) {
|
|
12886
|
+
return {
|
|
12887
|
+
model,
|
|
12888
|
+
blocked: "The selected model does not support this conversation's latency mode. Choose a supported mode or model before resuming.",
|
|
12889
|
+
pausedReason: "model_policy"
|
|
12890
|
+
};
|
|
12891
|
+
}
|
|
12892
|
+
return { model, blocked: null };
|
|
12893
|
+
}
|
|
12894
|
+
async function resolveGoalModelAdmission(db, settings, input) {
|
|
12895
|
+
const catalog = await resolveWorkspaceCatalogSettings(db, settings, {
|
|
12896
|
+
accountId: input.accountId,
|
|
12897
|
+
workspaceId: input.workspaceId,
|
|
12898
|
+
retainedProductModelId: input.model
|
|
12899
|
+
});
|
|
12900
|
+
const workspaceModelPolicy = await getWorkspaceModelPolicy3(db, input.workspaceId);
|
|
12901
|
+
return {
|
|
12902
|
+
settings: catalog.settings,
|
|
12903
|
+
...goalContinuationModelDecision({
|
|
12904
|
+
settings: catalog.settings,
|
|
12905
|
+
workspaceModelPolicy,
|
|
12906
|
+
inheritedModel: input.model,
|
|
12907
|
+
...input.codexCompactionMode ? { codexCompactionMode: input.codexCompactionMode } : {},
|
|
12908
|
+
...input.latencyMode ? { latencyMode: input.latencyMode } : {}
|
|
12909
|
+
})
|
|
12910
|
+
};
|
|
12911
|
+
}
|
|
12912
|
+
async function goalRunBudgetBlocked(services, input) {
|
|
12913
|
+
const denial = await agentRunAdmissionDenial(services, { ...input, requestedAgentRuns: 1 });
|
|
12914
|
+
if (denial === null) return null;
|
|
12915
|
+
const blocks = {
|
|
12916
|
+
insufficient_credits: services.entitlements ? {
|
|
12917
|
+
pausedReason: "usage_policy",
|
|
12918
|
+
message: "The application's usage policy blocks another run. Resume when it allows."
|
|
12919
|
+
} : {
|
|
12920
|
+
pausedReason: "credits",
|
|
12921
|
+
message: "Insufficient Opengeni credits. Add credits before resuming."
|
|
12922
|
+
},
|
|
12923
|
+
allowance_exhausted: {
|
|
12924
|
+
pausedReason: "allowance",
|
|
12925
|
+
message: "Opengeni usage allowance exhausted. Resume when your allowance is available."
|
|
12926
|
+
},
|
|
12927
|
+
monthly_model_cost_limit: {
|
|
12928
|
+
pausedReason: "budget",
|
|
12929
|
+
message: "Monthly model spending limit reached. Resume when the spending limit allows."
|
|
12930
|
+
},
|
|
12931
|
+
monthly_agent_run_limit: {
|
|
12932
|
+
pausedReason: "usage_limit",
|
|
12933
|
+
message: "Monthly agent run limit reached. Resume when the run limit allows."
|
|
12934
|
+
}
|
|
12935
|
+
};
|
|
12936
|
+
return blocks[denial];
|
|
12937
|
+
}
|
|
12938
|
+
var GoalResumeBlockedError = class extends Error {
|
|
12939
|
+
constructor(pausedReason, message) {
|
|
12940
|
+
super(message);
|
|
12941
|
+
this.pausedReason = pausedReason;
|
|
12942
|
+
this.name = "GoalResumeBlockedError";
|
|
12943
|
+
}
|
|
12944
|
+
};
|
|
12945
|
+
async function assertGoalResumeAllowed(services, session, causalTurn) {
|
|
12946
|
+
const decision = await resolveGoalModelAdmission(
|
|
12947
|
+
services.db,
|
|
12948
|
+
services.catalogSourceSettings ?? services.settings,
|
|
12949
|
+
session
|
|
12950
|
+
);
|
|
12951
|
+
if (decision.blocked) {
|
|
12952
|
+
throw new GoalResumeBlockedError(decision.pausedReason, decision.blocked);
|
|
12953
|
+
}
|
|
12954
|
+
const block = await goalRunBudgetBlocked(
|
|
12955
|
+
{ ...services, settings: decision.settings },
|
|
12956
|
+
{
|
|
12957
|
+
accountId: session.accountId,
|
|
12958
|
+
workspaceId: session.workspaceId,
|
|
12959
|
+
model: decision.model,
|
|
12960
|
+
// Resuming does not lend the clicking user's allowance or credentials.
|
|
12961
|
+
initiatingHumanSubjectId: causalTurn?.initiatingHumanSubjectId ?? null
|
|
12962
|
+
}
|
|
12963
|
+
);
|
|
12964
|
+
if (block) throw new GoalResumeBlockedError(block.pausedReason, block.message);
|
|
12965
|
+
}
|
|
12966
|
+
|
|
12754
12967
|
// src/application/external-workspace-members.ts
|
|
12755
12968
|
import { HTTPException as HTTPException18 } from "hono/http-exception";
|
|
12756
12969
|
import {
|
|
@@ -17695,7 +17908,7 @@ function orderScheduledTaskAccessAttention(items) {
|
|
|
17695
17908
|
}
|
|
17696
17909
|
|
|
17697
17910
|
// src/domain/insights.ts
|
|
17698
|
-
import { configuredStaticUsageLimits as
|
|
17911
|
+
import { configuredStaticUsageLimits as configuredStaticUsageLimits3 } from "@opengeni/config";
|
|
17699
17912
|
import {
|
|
17700
17913
|
WorkspaceInsightsSnapshot
|
|
17701
17914
|
} from "@opengeni/contracts";
|
|
@@ -17826,7 +18039,7 @@ function cacheHitPct(cached2, input) {
|
|
|
17826
18039
|
function startOfUtcDay(date) {
|
|
17827
18040
|
return new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()));
|
|
17828
18041
|
}
|
|
17829
|
-
function
|
|
18042
|
+
function startOfUtcMonth3(date) {
|
|
17830
18043
|
return new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), 1));
|
|
17831
18044
|
}
|
|
17832
18045
|
function startOfUtcYear(date) {
|
|
@@ -17855,7 +18068,7 @@ function resolveRangeWindow(range, now) {
|
|
|
17855
18068
|
cacheSeriesLabel = "Cache hit % / UTC day";
|
|
17856
18069
|
break;
|
|
17857
18070
|
case "month":
|
|
17858
|
-
since =
|
|
18071
|
+
since = startOfUtcMonth3(now);
|
|
17859
18072
|
rangeLabel = "This month (UTC)";
|
|
17860
18073
|
priorLabel = "Prior equal window";
|
|
17861
18074
|
seriesLabel = "Credit $ / UTC day";
|
|
@@ -17986,7 +18199,7 @@ async function getWorkspaceInsights(db, settings, input, observePhase) {
|
|
|
17986
18199
|
until: window.until,
|
|
17987
18200
|
priorSince: window.priorSince,
|
|
17988
18201
|
priorUntil: window.priorUntil,
|
|
17989
|
-
monthSince:
|
|
18202
|
+
monthSince: startOfUtcMonth3(now),
|
|
17990
18203
|
granularity: input.range === "today" ? "hour" : "day",
|
|
17991
18204
|
warmGroupLimit: 24
|
|
17992
18205
|
})
|
|
@@ -18229,7 +18442,7 @@ async function getWorkspaceInsights(db, settings, input, observePhase) {
|
|
|
18229
18442
|
billing: fact ? billingPathOf(fact.billingPath) : null
|
|
18230
18443
|
};
|
|
18231
18444
|
});
|
|
18232
|
-
const limits =
|
|
18445
|
+
const limits = configuredStaticUsageLimits3(settings);
|
|
18233
18446
|
const floor = floorRows.filter((row) => {
|
|
18234
18447
|
if (!model) return true;
|
|
18235
18448
|
return row.model === model;
|
|
@@ -20477,7 +20690,7 @@ async function submitComposerDraftForRequest(deps, grant, workspaceId, sessionId
|
|
|
20477
20690
|
import { DraftTimelineAnnotations as DraftTimelineAnnotations3 } from "@opengeni/contracts";
|
|
20478
20691
|
import { HTTPException as HTTPException30 } from "hono/http-exception";
|
|
20479
20692
|
import {
|
|
20480
|
-
checkWorkspaceAllowance as
|
|
20693
|
+
checkWorkspaceAllowance as checkWorkspaceAllowance4,
|
|
20481
20694
|
deleteSessionQueueItemInTransaction,
|
|
20482
20695
|
editQueuedTurnInTransaction,
|
|
20483
20696
|
getComposerDraftInTransaction as getComposerDraftInTransaction2,
|
|
@@ -20486,7 +20699,7 @@ import {
|
|
|
20486
20699
|
getWorkspaceControlEvent as getWorkspaceControlEvent2,
|
|
20487
20700
|
getSessionQueueSnapshot,
|
|
20488
20701
|
frozenInitiatorForCommandActor as frozenInitiatorForCommandActor2,
|
|
20489
|
-
isCodexBilledTurn as
|
|
20702
|
+
isCodexBilledTurn as isCodexBilledTurn3,
|
|
20490
20703
|
moveQueuedTurnInTransaction,
|
|
20491
20704
|
mutateSessionControlInTransaction,
|
|
20492
20705
|
mutateWorkspaceControlInTransaction,
|
|
@@ -20564,7 +20777,7 @@ async function assertFreshAgentCommandAllowance(tx, deps, context, targetSession
|
|
|
20564
20777
|
workspaceId: context.workspaceId,
|
|
20565
20778
|
retainedProductModelId: target.model
|
|
20566
20779
|
});
|
|
20567
|
-
const codexBilled = await
|
|
20780
|
+
const codexBilled = await isCodexBilledTurn3({
|
|
20568
20781
|
db: tx,
|
|
20569
20782
|
settings,
|
|
20570
20783
|
workspaceId: context.workspaceId,
|
|
@@ -20575,7 +20788,7 @@ async function assertFreshAgentCommandAllowance(tx, deps, context, targetSession
|
|
|
20575
20788
|
}
|
|
20576
20789
|
}
|
|
20577
20790
|
const frozen = await frozenInitiatorForCommandActor2(tx, context.workspaceId, agentActor(context));
|
|
20578
|
-
const refusal = await
|
|
20791
|
+
const refusal = await checkWorkspaceAllowance4(tx, {
|
|
20579
20792
|
accountId: target.accountId,
|
|
20580
20793
|
workspaceId: context.workspaceId,
|
|
20581
20794
|
subjectId: initiatingHumanForAllowance(frozen)
|
|
@@ -21432,9 +21645,7 @@ async function consentManagedHumanSandboxRecovery(deps, authorization, workspace
|
|
|
21432
21645
|
import {
|
|
21433
21646
|
issueSelfUserResourceGrant,
|
|
21434
21647
|
listSelfUserResourceAuthorities,
|
|
21435
|
-
revokeSelfUserResourceGrant
|
|
21436
|
-
sessionTenancyProductActivated as sessionTenancyProductActivated3,
|
|
21437
|
-
SessionTenancyNotActivatedError as SessionTenancyNotActivatedError2
|
|
21648
|
+
revokeSelfUserResourceGrant
|
|
21438
21649
|
} from "@opengeni/db";
|
|
21439
21650
|
var LIST_PERMISSIONS = {
|
|
21440
21651
|
connection: ["connections:read"],
|
|
@@ -21452,9 +21663,6 @@ var ISSUE_PERMISSIONS = {
|
|
|
21452
21663
|
};
|
|
21453
21664
|
async function requireOwnerProductGate(deps, authorization, workspaceId, permissions) {
|
|
21454
21665
|
requireOwnerAuthority(authorization, workspaceId, permissions);
|
|
21455
|
-
if (!await sessionTenancyProductActivated3(deps.db, workspaceId)) {
|
|
21456
|
-
throw new SessionTenancyNotActivatedError2();
|
|
21457
|
-
}
|
|
21458
21666
|
}
|
|
21459
21667
|
function requireOwnerAuthority(authorization, workspaceId, permissions) {
|
|
21460
21668
|
if (!authorization.canonicalLocalHumanSession) {
|
|
@@ -21466,9 +21674,6 @@ function requireOwnerAuthority(authorization, workspaceId, permissions) {
|
|
|
21466
21674
|
}
|
|
21467
21675
|
async function listManagedHumanUserResourceAuthorities(deps, authorization, workspaceId, input) {
|
|
21468
21676
|
requireOwnerAuthority(authorization, workspaceId, LIST_PERMISSIONS[input.resourceKind]);
|
|
21469
|
-
if (!await sessionTenancyProductActivated3(deps.db, workspaceId)) {
|
|
21470
|
-
return { authorities: [], nextCursor: null };
|
|
21471
|
-
}
|
|
21472
21677
|
return await listSelfUserResourceAuthorities(deps.db, {
|
|
21473
21678
|
accountId: authorization.grant.accountId,
|
|
21474
21679
|
workspaceId,
|
|
@@ -22195,6 +22400,7 @@ export {
|
|
|
22195
22400
|
EditableArtifactStaleBaseError,
|
|
22196
22401
|
EditableArtifactUndoTargetError,
|
|
22197
22402
|
GITHUB_ACTION_POLICY_GROUP_TOOL_NAMES,
|
|
22403
|
+
GoalResumeBlockedError,
|
|
22198
22404
|
InMemoryEditableArtifactLiveTicketStore,
|
|
22199
22405
|
InMemoryEditableArtifactStableIdFactory,
|
|
22200
22406
|
InMemoryEditableArtifactStore,
|
|
@@ -22266,6 +22472,7 @@ export {
|
|
|
22266
22472
|
agentAccessListScopeForViewer,
|
|
22267
22473
|
agentAccessPermitsCrossTreeAccess,
|
|
22268
22474
|
agentConfigParentFor,
|
|
22475
|
+
agentRunAdmissionDenial,
|
|
22269
22476
|
apiIntegrationsMatchingDelegations,
|
|
22270
22477
|
appendArchivedSessionEventsForRequest,
|
|
22271
22478
|
appendRigSetupCommand,
|
|
@@ -22285,6 +22492,7 @@ export {
|
|
|
22285
22492
|
assertConversationDeliveryOutcome,
|
|
22286
22493
|
assertConversationInboundEnvelope,
|
|
22287
22494
|
assertConversationProviderReceipt,
|
|
22495
|
+
assertGoalResumeAllowed,
|
|
22288
22496
|
assertIsoTimestamp,
|
|
22289
22497
|
assertKnownVideoGenerationModelIds,
|
|
22290
22498
|
assertManagedUserAdmission,
|
|
@@ -22438,6 +22646,8 @@ export {
|
|
|
22438
22646
|
getManagedSession,
|
|
22439
22647
|
getWorkspaceInsights,
|
|
22440
22648
|
githubAppActionPolicyActor,
|
|
22649
|
+
goalContinuationModelDecision,
|
|
22650
|
+
goalRunBudgetBlocked,
|
|
22441
22651
|
googleDrivePublicationDelegationFromVisibleConnections,
|
|
22442
22652
|
governedLearningEvidenceIsSlackDerived,
|
|
22443
22653
|
governedLearningSlackImportance,
|
|
@@ -22642,6 +22852,7 @@ export {
|
|
|
22642
22852
|
resolveFikenDefaultCompanySlug,
|
|
22643
22853
|
resolveFirstPartyMcpToolsForCreate,
|
|
22644
22854
|
resolveGitHubRepositoryBindings,
|
|
22855
|
+
resolveGoalModelAdmission,
|
|
22645
22856
|
resolveMemberSubjectId,
|
|
22646
22857
|
resolveRigProviderImageForRun,
|
|
22647
22858
|
resolveRigProviderImageSelection,
|