@opengeni/worker-bundle 1.0.0-canary.0 → 1.0.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/activities/agent-run-admission.d.ts +3 -1
- package/dist/activities/agent-turn/admission.d.ts +24 -3
- package/dist/activities/agent-turn/agent-build.d.ts +4 -0
- package/dist/activities/agent-turn/claude-usage-observer.d.ts +58 -0
- package/dist/activities/agent-turn/code-search.d.ts +60 -0
- package/dist/activities/agent-turn/codex-capacity.d.ts +13 -0
- package/dist/activities/agent-turn/codex-plan-entitlement.d.ts +105 -0
- package/dist/activities/agent-turn/codex.d.ts +3 -2
- package/dist/activities/agent-turn/compaction-prep.d.ts +21 -5
- package/dist/activities/agent-turn/credential-leases.d.ts +19 -33
- package/dist/activities/agent-turn/credential-restriction.d.ts +3 -0
- package/dist/activities/agent-turn/errors.d.ts +82 -11
- package/dist/activities/agent-turn/failure-settlement.d.ts +6 -3
- package/dist/activities/agent-turn/final-reply.d.ts +18 -0
- package/dist/activities/agent-turn/finalization-monitor.d.ts +17 -0
- package/dist/activities/agent-turn/finalization.d.ts +4 -2
- package/dist/activities/agent-turn/github-repository-bindings.d.ts +2 -0
- package/dist/activities/agent-turn/governance-model.d.ts +9 -2
- package/dist/activities/agent-turn/history-sink.d.ts +2 -0
- package/dist/activities/agent-turn/history.d.ts +2 -0
- package/dist/activities/agent-turn/input-wait-reply.d.ts +41 -0
- package/dist/activities/agent-turn/media-artifacts.d.ts +5 -3
- package/dist/activities/agent-turn/model-call-admission.d.ts +15 -0
- package/dist/activities/agent-turn/model-usage.d.ts +6 -0
- package/dist/activities/agent-turn/model-wire-dispatch.d.ts +15 -0
- package/dist/activities/agent-turn/optional-repositories.d.ts +59 -0
- package/dist/activities/agent-turn/provider-dispatch-barrier.d.ts +12 -1
- package/dist/activities/agent-turn/quiescence.d.ts +7 -7
- package/dist/activities/agent-turn/recovery-warning.d.ts +9 -0
- package/dist/activities/agent-turn/refresh-credentials.d.ts +6 -0
- package/dist/activities/agent-turn/run-credentials.d.ts +8 -3
- package/dist/activities/agent-turn/sandbox-establish.d.ts +2 -1
- package/dist/activities/agent-turn/sandbox-provision.d.ts +3 -1
- package/dist/activities/agent-turn/sandbox-route.d.ts +3 -20
- package/dist/activities/agent-turn/sandbox-runtime.d.ts +2 -2
- package/dist/activities/agent-turn/session-title.d.ts +34 -2
- package/dist/activities/agent-turn/skill-checkout.d.ts +25 -6
- package/dist/activities/agent-turn/skill-read.d.ts +70 -2
- package/dist/activities/agent-turn/skill-remove.d.ts +14 -0
- package/dist/activities/agent-turn/skill-search.d.ts +3 -1
- package/dist/activities/agent-turn/skill-tools.d.ts +15 -2
- package/dist/activities/agent-turn/skill-transfer.d.ts +18 -6
- package/dist/activities/agent-turn/stream-attempt.d.ts +7 -3
- package/dist/activities/agent-turn/subscription-lease.d.ts +38 -0
- package/dist/activities/agent-turn/tool-environment.d.ts +56 -6
- package/dist/activities/agent-turn/tool-policy.d.ts +43 -0
- package/dist/activities/agent-turn/turn-context.d.ts +29 -0
- package/dist/activities/agent-turn/turn-sandbox-access.d.ts +3 -0
- package/dist/activities/agent-turn/xai-capacity.d.ts +2 -1
- package/dist/activities/automations.d.ts +3 -1
- package/dist/activities/browser-deadline-checkpoint.d.ts +29 -0
- package/dist/activities/codemode-dispatcher.d.ts +9 -2
- package/dist/activities/codex-capacity.d.ts +18 -2
- package/dist/activities/codex-rotation.d.ts +7 -1
- package/dist/activities/context-compaction.d.ts +16 -2
- package/dist/activities/gmail-files.d.ts +32 -0
- package/dist/activities/goals.d.ts +8 -0
- package/dist/activities/knowledge-indexing.d.ts +19 -0
- package/dist/activities/mcp-account-routes.d.ts +3 -0
- package/dist/activities/mcp-credentials.d.ts +12 -13
- package/dist/activities/mcp-operation-authority.d.ts +0 -5
- package/dist/activities/model-call-fact-reconciler.d.ts +34 -0
- package/dist/activities/open-suffix-resume.d.ts +13 -0
- package/dist/activities/parent-wake.d.ts +6 -12
- package/dist/activities/retained-screenshots.d.ts +7 -2
- package/dist/activities/rig-verification.d.ts +2 -3
- package/dist/activities/run-credential-renewal.d.ts +1 -0
- package/dist/activities/run-credentials.d.ts +15 -3
- package/dist/activities/sandbox-images.d.ts +1 -1
- package/dist/activities/sandbox-lease.d.ts +47 -9
- package/dist/activities/scheduled-tasks.d.ts +4 -35
- package/dist/activities/session-state.d.ts +70 -3
- package/dist/activities/types.d.ts +55 -6
- package/dist/activities/workspace-capture.d.ts +2 -0
- package/dist/activities/workspace-credential-provider.d.ts +46 -0
- package/dist/{activities-control-HMFGSKC5.js → activities-control-BNPTRTOE.js} +1896 -418
- package/dist/activities-control-BNPTRTOE.js.map +1 -0
- package/dist/activities-control.d.ts +182 -4
- package/dist/{activities-turn-AP67JADS.js → activities-turn-5LGZOSVU.js} +4476 -1327
- package/dist/activities-turn-5LGZOSVU.js.map +1 -0
- package/dist/activities.d.ts +182 -4
- package/dist/artifact-materializer-entry.js +5 -2
- package/dist/artifact-materializer-entry.js.map +1 -1
- package/dist/artifact-outbox-entry.js +5 -2
- package/dist/artifact-outbox-entry.js.map +1 -1
- package/dist/browser-deadline-checkpoint-contract.d.ts +2 -0
- package/dist/{chunk-A4XQWVZK.js → chunk-3ZTRWDMN.js} +307 -4
- package/dist/chunk-3ZTRWDMN.js.map +1 -0
- package/dist/{chunk-RAMNYSAW.js → chunk-4ER3YXOT.js} +22 -4
- package/dist/chunk-4ER3YXOT.js.map +1 -0
- package/dist/{chunk-CYITU5UH.js → chunk-LJX7Z2KP.js} +1445 -343
- package/dist/chunk-LJX7Z2KP.js.map +1 -0
- package/dist/editable-artifact-materializer-service.d.ts +2 -2
- package/dist/editable-artifact-outbox-service.d.ts +2 -2
- package/dist/host-export-pump.d.ts +3 -1
- package/dist/host-export.d.ts +1 -1
- package/dist/host-export.js +1 -1
- package/dist/http.d.ts +1 -1
- package/dist/index.d.ts +95 -3
- package/dist/index.js +137 -43
- package/dist/index.js.map +1 -1
- package/dist/observability-metrics.d.ts +118 -8
- package/dist/retained-process-diagnostics.d.ts +4 -0
- package/dist/retained-process-retry.d.ts +7 -0
- package/dist/sandbox-resume.d.ts +55 -13
- package/dist/sandbox-routing.d.ts +5 -3
- package/dist/sandbox-snapshot-diagnostics.d.ts +20 -0
- package/dist/session-event-fanout.d.ts +6 -0
- package/dist/warm-capture-holder.d.ts +3 -0
- package/dist/worker-service-lifecycle.d.ts +12 -0
- package/dist/workflow-bundle.js +273 -41
- package/dist/workflows/activities.d.ts +1 -1
- package/dist/workflows/browser-deadline-checkpoint.d.ts +9 -0
- package/dist/workflows/scheduled-tasks.d.ts +4 -0
- package/dist/workflows/session.d.ts +36 -0
- package/dist/workflows.d.ts +1 -0
- package/package.json +21 -19
- package/src/activities/agent-run-admission.ts +17 -1
- package/src/activities/agent-turn/admission.ts +66 -3
- package/src/activities/agent-turn/agent-build.ts +84 -10
- package/src/activities/agent-turn/claim.ts +186 -43
- package/src/activities/agent-turn/claude-usage-observer.ts +221 -0
- package/src/activities/agent-turn/code-search.ts +275 -0
- package/src/activities/agent-turn/codex-capacity.ts +172 -8
- package/src/activities/agent-turn/codex-plan-entitlement.ts +254 -0
- package/src/activities/agent-turn/codex.ts +13 -5
- package/src/activities/agent-turn/compaction-prep.ts +170 -102
- package/src/activities/agent-turn/credential-leases.ts +122 -216
- package/src/activities/agent-turn/credential-restriction.ts +14 -0
- package/src/activities/agent-turn/errors.ts +647 -48
- package/src/activities/agent-turn/failure-settlement.ts +682 -130
- package/src/activities/agent-turn/final-reply.ts +46 -0
- package/src/activities/agent-turn/finalization-monitor.ts +120 -0
- package/src/activities/agent-turn/finalization.ts +146 -43
- package/src/activities/agent-turn/github-repository-bindings.ts +3 -1
- package/src/activities/agent-turn/governance-model.ts +69 -28
- package/src/activities/agent-turn/history-sink.ts +16 -2
- package/src/activities/agent-turn/history.ts +38 -11
- package/src/activities/agent-turn/input-wait-reply.ts +103 -0
- package/src/activities/agent-turn/knowledge-source-tools.ts +2 -0
- package/src/activities/agent-turn/media-artifacts.ts +2 -1
- package/src/activities/agent-turn/model-call-admission.ts +94 -0
- package/src/activities/agent-turn/model-usage.ts +64 -3
- package/src/activities/agent-turn/model-wire-dispatch.ts +27 -0
- package/src/activities/agent-turn/optional-repositories.ts +224 -0
- package/src/activities/agent-turn/provider-dispatch-barrier.ts +22 -0
- package/src/activities/agent-turn/quiescence.ts +10 -7
- package/src/activities/agent-turn/recovery-warning.ts +16 -0
- package/src/activities/agent-turn/refresh-credentials.ts +44 -0
- package/src/activities/agent-turn/run-credentials.ts +116 -55
- package/src/activities/agent-turn/run.ts +320 -93
- package/src/activities/agent-turn/sandbox-establish.ts +84 -8
- package/src/activities/agent-turn/sandbox-provision.ts +3 -1
- package/src/activities/agent-turn/sandbox-route.ts +4 -21
- package/src/activities/agent-turn/sandbox-runtime.ts +343 -18
- package/src/activities/agent-turn/session-title.ts +81 -5
- package/src/activities/agent-turn/skill-checkout.ts +111 -24
- package/src/activities/agent-turn/skill-install.ts +1 -1
- package/src/activities/agent-turn/skill-read.ts +374 -28
- package/src/activities/agent-turn/skill-remove.ts +46 -0
- package/src/activities/agent-turn/skill-save.ts +1 -1
- package/src/activities/agent-turn/skill-search.ts +10 -1
- package/src/activities/agent-turn/skill-selection.ts +4 -0
- package/src/activities/agent-turn/skill-tools.ts +112 -18
- package/src/activities/agent-turn/skill-transfer.ts +68 -23
- package/src/activities/agent-turn/stream-attempt.ts +313 -77
- package/src/activities/agent-turn/subscription-lease.ts +115 -0
- package/src/activities/agent-turn/tool-environment.ts +316 -167
- package/src/activities/agent-turn/tool-policy.ts +80 -1
- package/src/activities/agent-turn/turn-context.ts +35 -0
- package/src/activities/agent-turn/turn-sandbox-access.ts +7 -1
- package/src/activities/agent-turn/xai-capacity.ts +94 -51
- package/src/activities/automations.ts +76 -4
- package/src/activities/browser-deadline-checkpoint.ts +279 -0
- package/src/activities/capabilities.ts +108 -11
- package/src/activities/codemode-dispatcher.ts +36 -8
- package/src/activities/codex-capacity.ts +60 -25
- package/src/activities/codex-rotation.ts +39 -17
- package/src/activities/context-compaction.ts +75 -18
- package/src/activities/gmail-files.ts +88 -0
- package/src/activities/goals.ts +116 -121
- package/src/activities/google-drive-publication.ts +1 -3
- package/src/activities/image-generation-operation.ts +1 -1
- package/src/activities/knowledge-indexing.ts +269 -15
- package/src/activities/knowledge-source-sync.ts +10 -0
- package/src/activities/mcp-account-routes.ts +17 -0
- package/src/activities/mcp-credentials.ts +83 -194
- package/src/activities/mcp-operation-authority.ts +16 -41
- package/src/activities/model-call-fact-reconciler.ts +112 -0
- package/src/activities/open-suffix-resume.ts +15 -2
- package/src/activities/parent-wake.ts +46 -21
- package/src/activities/retained-screenshots.ts +82 -11
- package/src/activities/rig-verification.ts +38 -37
- package/src/activities/run-credential-renewal.ts +13 -1
- package/src/activities/run-credentials.ts +59 -17
- package/src/activities/run-input.ts +25 -16
- package/src/activities/sandbox-images.ts +0 -1
- package/src/activities/sandbox-lease.ts +798 -82
- package/src/activities/scheduled-tasks.ts +550 -178
- package/src/activities/session-state.ts +245 -6
- package/src/activities/site-auth-maintenance.ts +3 -0
- package/src/activities/types.ts +72 -5
- package/src/activities/workflow-wake.ts +2 -17
- package/src/activities/workspace-capture.ts +13 -2
- package/src/activities/workspace-credential-provider.ts +283 -0
- package/src/activities-control.ts +4 -0
- package/src/activities-turn.ts +5 -0
- package/src/activities.ts +13 -0
- package/src/activity-services.ts +16 -4
- package/src/browser-deadline-checkpoint-contract.ts +5 -0
- package/src/editable-artifact-hint-broker.ts +3 -0
- package/src/editable-artifact-materializer-service.ts +7 -3
- package/src/editable-artifact-outbox-service.ts +4 -4
- package/src/github-rest-mcp.ts +1 -2
- package/src/host-export-pump.ts +26 -4
- package/src/host-export.ts +3 -0
- package/src/http.ts +4 -2
- package/src/index.ts +99 -37
- package/src/observability-metrics.ts +510 -5
- package/src/personal-github-git-credentials.ts +2 -1
- package/src/pr-review-credentials.ts +1 -3
- package/src/retained-process-diagnostics.ts +50 -0
- package/src/retained-process-retry.ts +36 -0
- package/src/sandbox-resume.ts +388 -101
- package/src/sandbox-routing.ts +150 -25
- package/src/sandbox-snapshot-diagnostics.ts +112 -0
- package/src/session-event-fanout.ts +23 -0
- package/src/warm-capture-holder.ts +15 -0
- package/src/worker-service-lifecycle.ts +53 -0
- package/src/workflows/activities.ts +16 -1
- package/src/workflows/browser-deadline-checkpoint.ts +50 -0
- package/src/workflows/file-upload-reaper.ts +2 -0
- package/src/workflows/scheduled-tasks.ts +26 -13
- package/src/workflows/session.ts +242 -22
- package/src/workflows.ts +4 -0
- package/dist/activities/agent-turn/knowledge-sources.d.ts +0 -20
- package/dist/activities/packs.d.ts +0 -55
- package/dist/activities-control-HMFGSKC5.js.map +0 -1
- package/dist/activities-turn-AP67JADS.js.map +0 -1
- package/dist/chunk-A4XQWVZK.js.map +0 -1
- package/dist/chunk-CYITU5UH.js.map +0 -1
- package/dist/chunk-RAMNYSAW.js.map +0 -1
- package/src/activities/agent-turn/knowledge-sources.ts +0 -86
- package/src/activities/packs.ts +0 -166
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Settings } from "@opengeni/config";
|
|
2
|
+
import { type CodexPlanEntitlementFailurePayload } from "./codex-plan-entitlement.js";
|
|
2
3
|
import type { TurnActivityServices as ActivityServices, RunAgentTurnInput, RunAgentTurnResult } from "../types.js";
|
|
3
4
|
import { createTurnCredentialLeases } from "./credential-leases.js";
|
|
4
5
|
import { createTurnHistorySink } from "./history-sink.js";
|
|
6
|
+
import { type CodexCredentialFailure } from "./errors.js";
|
|
5
7
|
import type { AttemptIdentityState, BillingState, EventingState, ProviderTurnState, TurnControlState } from "./turn-context.js";
|
|
6
8
|
export type TurnFailureDeps = {
|
|
7
9
|
error: unknown;
|
|
@@ -44,7 +46,7 @@ type CodexCapacityWaitFailurePayload = {
|
|
|
44
46
|
* recover the same durable turn immediately.
|
|
45
47
|
*/
|
|
46
48
|
export declare function codexDefinitiveFailureDisposition(input: {
|
|
47
|
-
failureKind: "
|
|
49
|
+
failureKind: CodexCredentialFailure["kind"];
|
|
48
50
|
rotationEnabled: boolean;
|
|
49
51
|
pinDisposition: "manual" | "sharded" | "clearStale" | "unpinned";
|
|
50
52
|
decisionKind: "active" | "allCapped" | "none";
|
|
@@ -63,13 +65,14 @@ export declare function codexCredentialFailoverLimit(accounts: ReadonlyArray<{
|
|
|
63
65
|
}>, servingCredentialId: string): number;
|
|
64
66
|
/** Build the durable waiter payload without collapsing quota refusals into 403. */
|
|
65
67
|
export declare function codexCapacityWaitFailurePayload(input: {
|
|
66
|
-
failureKind: "
|
|
68
|
+
failureKind: CodexCredentialFailure["kind"];
|
|
67
69
|
usageLimit: {
|
|
68
70
|
resetsInSeconds: number | null;
|
|
69
71
|
} | null;
|
|
70
72
|
cooldownSeconds: number | null;
|
|
71
73
|
detail: string;
|
|
72
74
|
allAccounts: boolean;
|
|
75
|
+
planEntitlement?: CodexPlanEntitlementFailurePayload | null;
|
|
73
76
|
}): CodexCapacityWaitFailurePayload;
|
|
74
77
|
export declare function settleTurnFailure(deps: TurnFailureDeps): Promise<RunAgentTurnResult>;
|
|
75
78
|
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** One durable, same-logical-turn handoff, not a retry of model/tool effects. */
|
|
2
|
+
export declare function finalReplyNudge(turnId: string): {
|
|
3
|
+
type: "message";
|
|
4
|
+
role: "developer";
|
|
5
|
+
content: {
|
|
6
|
+
type: "input_text";
|
|
7
|
+
text: string;
|
|
8
|
+
}[];
|
|
9
|
+
};
|
|
10
|
+
export declare function hasFinalReplyNudge(history: readonly unknown[], turnId: string): boolean;
|
|
11
|
+
export declare function needsFinalReply(input: {
|
|
12
|
+
output: unknown;
|
|
13
|
+
inputWaitYielded: boolean;
|
|
14
|
+
interrupted: boolean;
|
|
15
|
+
maintenance: boolean;
|
|
16
|
+
toolsExecuted: boolean;
|
|
17
|
+
completedGoal: boolean;
|
|
18
|
+
}): boolean;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Observability } from "@opengeni/observability";
|
|
2
|
+
import type { TurnHeartbeatDetails } from "../../op-journal.js";
|
|
3
|
+
export declare const TURN_FINALIZATION_STAGES: readonly ["tool_writers", "credential_renewals", "credential_cleanup", "quiescence_receipt", "event_flush", "provider_leases", "workspace_capture", "tool_close", "sandbox_provisioning", "sandbox_rotation", "workspace_snapshot", "sandbox_release"];
|
|
4
|
+
export type TurnFinalizationStage = (typeof TURN_FINALIZATION_STAGES)[number];
|
|
5
|
+
/** Starts only after agent execution ends. A cleanup-stage deadline never caps
|
|
6
|
+
* agent work and never detaches a physical writer to manufacture quiescence. */
|
|
7
|
+
export declare function startTurnFinalizationMonitor(input: {
|
|
8
|
+
observability: Observability;
|
|
9
|
+
details: TurnHeartbeatDetails;
|
|
10
|
+
heartbeat: (details: TurnHeartbeatDetails) => void;
|
|
11
|
+
requestWorkerDrain: () => void;
|
|
12
|
+
timeoutMs?: number;
|
|
13
|
+
slowAfterMs?: number;
|
|
14
|
+
}): {
|
|
15
|
+
enter(next: TurnFinalizationStage): void;
|
|
16
|
+
stop(): void;
|
|
17
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type
|
|
1
|
+
import { type Settings } from "@opengeni/config";
|
|
2
|
+
import { type currentActivityContext } from "../streaming.js";
|
|
3
3
|
import type { RunAgentTurnInput, TurnActivityServices as ActivityServices } from "../types.js";
|
|
4
4
|
import { createModelCheckpointMemoryCollector } from "../../model-checkpoint-memory-collector.js";
|
|
5
5
|
import { makeMachineOpObserver } from "../../observability-metrics.js";
|
|
@@ -16,6 +16,8 @@ export type TurnFinalizationDeps = {
|
|
|
16
16
|
wakeSessionWorkflow: ActivityServices["wakeSessionWorkflow"];
|
|
17
17
|
signalSessionAttemptQuiesced: ActivityServices["signalSessionAttemptQuiesced"];
|
|
18
18
|
signalCodexCapacityWorkflow: ActivityServices["signalCodexCapacityWorkflow"];
|
|
19
|
+
requestWorkerDrain: ActivityServices["requestWorkerDrain"];
|
|
20
|
+
turnFinalizationTimeoutMs: ActivityServices["turnFinalizationTimeoutMs"];
|
|
19
21
|
cancellationSignal: AbortSignal | undefined;
|
|
20
22
|
sandboxResumeController: AbortController;
|
|
21
23
|
activityContext: ReturnType<typeof currentActivityContext>;
|
|
@@ -76,6 +76,8 @@ export type ApplyTurnGitHubRepositoryBindingsInput = {
|
|
|
76
76
|
workspaceId: string;
|
|
77
77
|
sessionId: string;
|
|
78
78
|
activeSandboxBackend: Settings["sandboxBackend"] | undefined;
|
|
79
|
+
/** Product-owned credentials take precedence over inferred platform bindings. */
|
|
80
|
+
hasCredentialProvider?: boolean;
|
|
79
81
|
claimedTurnResources: readonly ResourceRef[];
|
|
80
82
|
claimedRuntimeResources: readonly ResourceRef[];
|
|
81
83
|
/** Publishes one attempt-fenced session event batch. */
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { materializeRigVersionForAttempt } from "@opengeni/db";
|
|
2
2
|
import { renderWorkspaceGovernanceContext, type OpenGeniRuntime } from "@opengeni/runtime";
|
|
3
3
|
import { type Settings } from "@opengeni/config";
|
|
4
|
-
import { resolveWorkspacePackRuntime } from "../packs.js";
|
|
5
4
|
import { createModelHistoryAttachmentProjector } from "../run-input.js";
|
|
6
5
|
import type { TurnActivityServices as ActivityServices, RunAgentTurnInput, RunAgentTurnResult } from "../types.js";
|
|
7
6
|
import { buildCompanyBrainContributionReceipt } from "../../model-context-contributions.js";
|
|
@@ -12,6 +11,7 @@ import type { EventingState, WorkspaceRefState } from "./turn-context.js";
|
|
|
12
11
|
export type GovernanceModelDeps = {
|
|
13
12
|
input: RunAgentTurnInput;
|
|
14
13
|
db: ActivityServices["db"];
|
|
14
|
+
observability: ActivityServices["observability"];
|
|
15
15
|
runtime: ActivityServices["runtime"];
|
|
16
16
|
objectStorage: ActivityServices["objectStorage"];
|
|
17
17
|
eventing: EventingState;
|
|
@@ -35,11 +35,18 @@ export type GovernanceModelDeps = {
|
|
|
35
35
|
};
|
|
36
36
|
export type GovernanceModelOk = {
|
|
37
37
|
runtimePreparationStartedAt: number;
|
|
38
|
-
packRuntime: Awaited<ReturnType<typeof resolveWorkspacePackRuntime>>;
|
|
39
38
|
rigVersion: NonNullable<Awaited<ReturnType<typeof materializeRigVersionForAttempt>>>["version"] | null;
|
|
40
39
|
rigName: string | null;
|
|
41
40
|
agentHumanInputEnabled: boolean;
|
|
41
|
+
/** Deployment and workspace allow the Jev-backed code_search tool. */
|
|
42
|
+
codeSearchEnabled: boolean;
|
|
42
43
|
workspaceAgentInstructions: string | null | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Modular composer identity tier: the explicit workspace default identity,
|
|
46
|
+
* else the frozen legacy persona without `{{core}}`. Never dropped by
|
|
47
|
+
* instruction policies (only read for sessions with an agent configuration).
|
|
48
|
+
*/
|
|
49
|
+
workspaceAgentIdentity: string | null;
|
|
43
50
|
workspaceGovernance: ReturnType<typeof renderWorkspaceGovernanceContext>;
|
|
44
51
|
structuredWorkspacePolicyActive: boolean;
|
|
45
52
|
workspaceMemory: string | null | undefined;
|
|
@@ -41,6 +41,7 @@ export type TurnHistorySinkDeps = {
|
|
|
41
41
|
export declare class TurnHistorySink {
|
|
42
42
|
private readonly deps;
|
|
43
43
|
private readonly prefix;
|
|
44
|
+
private checkpointTail;
|
|
44
45
|
seedHistory(input: string | readonly unknown[] | {
|
|
45
46
|
readonly history: unknown[];
|
|
46
47
|
}, count: number): void;
|
|
@@ -52,5 +53,6 @@ export declare class TurnHistorySink {
|
|
|
52
53
|
skipInputOnlyRows?: boolean;
|
|
53
54
|
requireDurable?: boolean;
|
|
54
55
|
}) => Promise<void>;
|
|
56
|
+
private reconcile;
|
|
55
57
|
}
|
|
56
58
|
export declare function createTurnHistorySink(deps: TurnHistorySinkDeps): TurnHistorySink;
|
|
@@ -49,6 +49,8 @@ export declare function pendingToolCallFromSdkEvent(event: unknown): {
|
|
|
49
49
|
} | null;
|
|
50
50
|
/** Tools whose intentional visual result must survive inline-media sanitization. */
|
|
51
51
|
export declare function toolCallProducesRetainableSessionImage(name: string | null): boolean;
|
|
52
|
+
/** Browser interactions can carry an image block, including opt-in observe frames. */
|
|
53
|
+
export declare function retainableBrowserScreenshotToolCall(name: string | null): boolean;
|
|
52
54
|
export declare function completedToolCallFromSdkEvent(event: unknown): {
|
|
53
55
|
callId: string;
|
|
54
56
|
resultItem: Record<string, unknown>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type Database } from "@opengeni/db";
|
|
2
|
+
import type { TurnInitiator, TurnInitiatorContext } from "@opengeni/contracts";
|
|
3
|
+
type ReplyTurn = {
|
|
4
|
+
source?: string | undefined;
|
|
5
|
+
initiator: TurnInitiator;
|
|
6
|
+
initiatorContext: TurnInitiatorContext;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* The reply `turn.completed` records when a turn ends through `wait_for_input`
|
|
10
|
+
* (read back with `turnCompletedReply` in `@opengeni/contracts`).
|
|
11
|
+
*
|
|
12
|
+
* Such a turn settles with an empty `output`: the wait, not an answer, ended
|
|
13
|
+
* it. When the turn answers a person's message, its latest assistant message
|
|
14
|
+
* is still that message's answer, for example a status reply given before
|
|
15
|
+
* waiting again on work in flight. That message shares its model response with
|
|
16
|
+
* the wait call, so it streams as commentary, which is activity everywhere
|
|
17
|
+
* else. Recording it lets unread attention and Slack treat it as the answer
|
|
18
|
+
* without relabelling the provider's phase in stored history. Turns that
|
|
19
|
+
* machine input, an agent or a worker-owned producer started only narrate
|
|
20
|
+
* progress and record nothing.
|
|
21
|
+
*
|
|
22
|
+
* The message this activity completed last is the newest. An activity that
|
|
23
|
+
* resumed the turn (after an approval, a human-input answer or a recovery) and
|
|
24
|
+
* completed none reads the turn's latest durable message instead.
|
|
25
|
+
*/
|
|
26
|
+
export declare function inputWaitReply(input: {
|
|
27
|
+
inputWaitYielded: boolean;
|
|
28
|
+
turn: ReplyTurn;
|
|
29
|
+
latestAssistantMessageText: string | null;
|
|
30
|
+
readLatestDurableTurnMessage: () => Promise<string | null>;
|
|
31
|
+
}): Promise<string | null>;
|
|
32
|
+
/**
|
|
33
|
+
* Text of the newest current `agent.message.completed` this turn persisted,
|
|
34
|
+
* or null when the session's newest completion belongs to another turn.
|
|
35
|
+
*/
|
|
36
|
+
export declare function latestDurableTurnMessageText(db: Database, input: {
|
|
37
|
+
workspaceId: string;
|
|
38
|
+
sessionId: string;
|
|
39
|
+
turnId: string;
|
|
40
|
+
}): Promise<string | null>;
|
|
41
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type CodemodeTokenWriterSession, type RetainableSessionImageOutputHook, type TurnToolCancellationFence } from "@opengeni/runtime";
|
|
2
2
|
import type { Settings } from "@opengeni/config";
|
|
3
|
+
import type { RetainedSessionScreenshotKind } from "@opengeni/contracts";
|
|
3
4
|
import type { ResumedTurnSandbox } from "../../sandbox-resume.js";
|
|
4
5
|
import type { SharedActivityServices } from "../types.js";
|
|
5
6
|
import { type GeneratedImageOutput, type GeneratedImageReceipt } from "../generated-images.js";
|
|
@@ -35,7 +36,7 @@ export declare class TurnMediaArtifacts {
|
|
|
35
36
|
readonly retainedScreenshotReceiptsByCallId: Map<string, {
|
|
36
37
|
available: true;
|
|
37
38
|
artifactId: string;
|
|
38
|
-
kind: "assistant_completion" | "computer_screenshot" | "event_media" | "file" | "generated_image" | "generated_video" | "internal_update" | "tool_result";
|
|
39
|
+
kind: "assistant_completion" | "browser_screenshot" | "computer_screenshot" | "event_media" | "file" | "generated_image" | "generated_video" | "internal_update" | "tool_result";
|
|
39
40
|
contentType: string;
|
|
40
41
|
originalBytes: number;
|
|
41
42
|
sha256: string;
|
|
@@ -68,7 +69,7 @@ export declare class TurnMediaArtifacts {
|
|
|
68
69
|
artifact: {
|
|
69
70
|
available: true;
|
|
70
71
|
artifactId: string;
|
|
71
|
-
kind: "assistant_completion" | "computer_screenshot" | "event_media" | "file" | "generated_image" | "generated_video" | "internal_update" | "tool_result";
|
|
72
|
+
kind: "assistant_completion" | "browser_screenshot" | "computer_screenshot" | "event_media" | "file" | "generated_image" | "generated_video" | "internal_update" | "tool_result";
|
|
72
73
|
contentType: string;
|
|
73
74
|
originalBytes: number;
|
|
74
75
|
sha256: string;
|
|
@@ -98,7 +99,7 @@ export declare class TurnMediaArtifacts {
|
|
|
98
99
|
artifact: {
|
|
99
100
|
available: true;
|
|
100
101
|
artifactId: string;
|
|
101
|
-
kind: "assistant_completion" | "computer_screenshot" | "event_media" | "file" | "generated_image" | "generated_video" | "internal_update" | "tool_result";
|
|
102
|
+
kind: "assistant_completion" | "browser_screenshot" | "computer_screenshot" | "event_media" | "file" | "generated_image" | "generated_video" | "internal_update" | "tool_result";
|
|
102
103
|
contentType: string;
|
|
103
104
|
originalBytes: number;
|
|
104
105
|
sha256: string;
|
|
@@ -128,6 +129,7 @@ export declare class TurnMediaArtifacts {
|
|
|
128
129
|
sandboxFileDownloadBackend: Settings["sandboxBackend"];
|
|
129
130
|
nativeImageGenerationRetention: NativeImageGenerationRetention | null;
|
|
130
131
|
readonly retainedSessionImageCallIds: Set<string>;
|
|
132
|
+
readonly retainedSessionImageKindsByCallId: Map<string, RetainedSessionScreenshotKind>;
|
|
131
133
|
constructor(deps: TurnMediaArtifactDeps);
|
|
132
134
|
rememberGeneratedImageCreatedThisTurn: (receipt: GeneratedImageReceipt) => void;
|
|
133
135
|
private prepareGeneratedImageDownload;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { StreamEvent } from "@openai/agents";
|
|
2
|
+
/** SDK producer/consumer rendezvous. Usage stays on the sole consumer writer. */
|
|
3
|
+
export declare function createModelCallAdmission(input: {
|
|
4
|
+
signal: AbortSignal;
|
|
5
|
+
admit: () => Promise<void>;
|
|
6
|
+
}): {
|
|
7
|
+
beforeModelRequest: () => Promise<void>;
|
|
8
|
+
onModelResponse: (event: StreamEvent) => Promise<void>;
|
|
9
|
+
settle: (event: {
|
|
10
|
+
type: string;
|
|
11
|
+
data?: unknown;
|
|
12
|
+
}) => void;
|
|
13
|
+
fail: (error: unknown) => void;
|
|
14
|
+
close: () => void;
|
|
15
|
+
};
|
|
@@ -3,6 +3,7 @@ import { modelResponseServiceTierFromSdkEvent, modelTerminalResponseFromSdkEvent
|
|
|
3
3
|
import { type ModelUsageInput, type ModelProviderApi, type Settings } from "@opengeni/config";
|
|
4
4
|
import type { TurnActivityServices as ActivityServices } from "../types.js";
|
|
5
5
|
import { type LatencyMode, type ModelContextContributionSummary, type SessionEvent } from "@opengeni/contracts";
|
|
6
|
+
import type { InsightsUsageClassMicros } from "@opengeni/contracts/insights-usage";
|
|
6
7
|
export declare function modelUsageSourceKey(input: {
|
|
7
8
|
responseId?: string | null | undefined;
|
|
8
9
|
dispatchId: string | null;
|
|
@@ -171,6 +172,8 @@ export declare function emitModelCallUsage(input: {
|
|
|
171
172
|
normalizedUsage?: ModelCallUsageNormalization;
|
|
172
173
|
/** Accepted billing authority persisted for Insights repair after a soft fact-write failure. */
|
|
173
174
|
billingPath?: ModelUsageBillingRecord["billingPath"];
|
|
175
|
+
/** Accepted comparisons are frozen with the event, not repriced during fact repair. */
|
|
176
|
+
billingSnapshot?: Pick<ModelUsageBillingRecord, "pricedCostMicros" | "estimatedProviderCostMicros" | "equivalentCreditCostMicros" | "pricingSource" | "listByClassMicros" | "listByClassApprox">;
|
|
174
177
|
/** Validated Gateway endpoint provider persisted for exact Insights repair. */
|
|
175
178
|
upstreamProvider?: string;
|
|
176
179
|
servingAccountHash?: string;
|
|
@@ -192,6 +195,9 @@ export type ModelUsageBillingRecord = {
|
|
|
192
195
|
/** Hypothetical OpenGeni credit price at the captured rate; never a debit. */
|
|
193
196
|
equivalentCreditCostMicros: number | null;
|
|
194
197
|
pricingSource: "configured_list_price" | "gateway_reported" | null;
|
|
198
|
+
/** Forward-only provider list class snapshot; older facts/events stay unknown. */
|
|
199
|
+
listByClassMicros?: InsightsUsageClassMicros | null;
|
|
200
|
+
listByClassApprox?: boolean;
|
|
195
201
|
normalizedUsage: ModelCallUsageNormalization;
|
|
196
202
|
upstreamProvider?: string;
|
|
197
203
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ModelTransportDispatchClock } from "@opengeni/runtime";
|
|
2
|
+
type DispatchIdentity = {
|
|
3
|
+
provider: string;
|
|
4
|
+
dispatchId: string;
|
|
5
|
+
};
|
|
6
|
+
/** One immutable physical fetch-entry observation per worker attempt. Generic
|
|
7
|
+
* fallback events already carry that attempt's dispatch/execution identity. */
|
|
8
|
+
export declare class InitialModelWireDispatchClock {
|
|
9
|
+
private initial;
|
|
10
|
+
record(identity: DispatchIdentity, clock: ModelTransportDispatchClock): void;
|
|
11
|
+
payload(identity: DispatchIdentity): {
|
|
12
|
+
initialWireDispatchedAt?: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { Settings } from "@opengeni/config";
|
|
2
|
+
import { type ResourceRef } from "@opengeni/contracts";
|
|
3
|
+
import { type Database } from "@opengeni/db";
|
|
4
|
+
/**
|
|
5
|
+
* Turn-time access check for automatically attached (`optional: true`) GitHub
|
|
6
|
+
* App repositories.
|
|
7
|
+
*
|
|
8
|
+
* A Slack-started session attaches the caller's recently used repositories as
|
|
9
|
+
* optional resources. The per-turn workspace-allowlist recheck and the
|
|
10
|
+
* installation-token mint both cover every GitHub repository of the session in
|
|
11
|
+
* one request, so one optional repository that loses access after the session
|
|
12
|
+
* started (an admin removes it from the allowlist, or it is deleted or removed
|
|
13
|
+
* from the App on GitHub) would fail every later turn. Before those checks, this
|
|
14
|
+
* drops each optional repository that is no longer allowlisted or no longer
|
|
15
|
+
* reachable through its installation, for this turn only, and reports it the
|
|
16
|
+
* same way a skipped optional clone is reported. It only ever removes
|
|
17
|
+
* repositories: a remaining repository still passes the unchanged strict
|
|
18
|
+
* allowlist recheck and mint, and an explicitly attached repository is never
|
|
19
|
+
* dropped, so it keeps failing the turn when its access is gone.
|
|
20
|
+
*/
|
|
21
|
+
export declare const OPTIONAL_REPOSITORY_ACCESS_OPERATION = "optional-repository-access";
|
|
22
|
+
export type OptionalRepositoryDropReason = "not_allowlisted" | "inaccessible" | "unverified";
|
|
23
|
+
export type DropUnavailableOptionalRepositoriesInput = {
|
|
24
|
+
db: Database;
|
|
25
|
+
settings: Settings;
|
|
26
|
+
workspaceId: string;
|
|
27
|
+
activeSandboxBackend: Settings["sandboxBackend"] | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* True when a host `gitCredentials` port mints the Git tokens: the host may
|
|
30
|
+
* use another GitHub App, so this deployment's App is not asked.
|
|
31
|
+
*/
|
|
32
|
+
hostMintsGitCredentials: boolean;
|
|
33
|
+
turnResources: readonly ResourceRef[];
|
|
34
|
+
runtimeResources: readonly ResourceRef[];
|
|
35
|
+
/** Publishes one attempt-fenced session event batch. */
|
|
36
|
+
publish: (events: Array<{
|
|
37
|
+
type: "sandbox.operation.completed";
|
|
38
|
+
payload: {
|
|
39
|
+
name: typeof OPTIONAL_REPOSITORY_ACCESS_OPERATION;
|
|
40
|
+
repositoryCount: number;
|
|
41
|
+
skippedOptionalRepositories: string[];
|
|
42
|
+
};
|
|
43
|
+
}>) => Promise<void>;
|
|
44
|
+
/** Operational log line; counts only, never repository names. */
|
|
45
|
+
warn: (message: string, fields: Record<string, string>) => void;
|
|
46
|
+
/** Test seam; defaults to the workspace allowlist under RLS. */
|
|
47
|
+
isAllowlisted?: (installationId: number, repositoryId: number) => Promise<boolean>;
|
|
48
|
+
/** Test seam; defaults to a live GitHub App token-mint probe. */
|
|
49
|
+
findInaccessible?: (installationId: number, repositoryIds: number[]) => Promise<number[]>;
|
|
50
|
+
};
|
|
51
|
+
export declare function dropUnavailableOptionalRepositories(input: DropUnavailableOptionalRepositoriesInput): Promise<{
|
|
52
|
+
turnResources: ResourceRef[];
|
|
53
|
+
runtimeResources: ResourceRef[];
|
|
54
|
+
/**
|
|
55
|
+
* The same decision for another view of this turn's resources (the GitHub
|
|
56
|
+
* REST tool surface is built from the unbound session resources).
|
|
57
|
+
*/
|
|
58
|
+
retainsResource: (resource: ResourceRef) => boolean;
|
|
59
|
+
}>;
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import type { TurnHistorySink } from "./history-sink.js";
|
|
2
|
+
import type { Settings } from "@opengeni/config";
|
|
3
|
+
export declare class SandboxCapabilitiesChangedError extends Error {
|
|
4
|
+
readonly code = "native_capabilities_changed_this_attempt";
|
|
5
|
+
constructor();
|
|
6
|
+
}
|
|
2
7
|
/**
|
|
3
8
|
* Persist the SDK's complete prior model/tool history before another provider
|
|
4
9
|
* request can start. The first request has no prior model/tool rows to append.
|
|
5
10
|
* Follow-up requests run only after the preceding complete call/result batch is
|
|
6
11
|
* replay-safe.
|
|
7
12
|
*/
|
|
8
|
-
export declare function checkpointHistoryBeforeProviderDispatch(historySink: Pick<TurnHistorySink, "reconcileConversationTruth"
|
|
13
|
+
export declare function checkpointHistoryBeforeProviderDispatch(historySink: Pick<TurnHistorySink, "reconcileConversationTruth">, route?: {
|
|
14
|
+
effectiveSandboxBackend: Settings["sandboxBackend"];
|
|
15
|
+
routingEnabled: boolean;
|
|
16
|
+
readActiveSandbox: () => Promise<{
|
|
17
|
+
activeSandboxId: string | null;
|
|
18
|
+
} | null>;
|
|
19
|
+
}): Promise<void>;
|
|
@@ -49,10 +49,9 @@ export declare const QUIESCENCE_PROOF_SIGNAL_INITIAL_RETRY_MS = 250;
|
|
|
49
49
|
export declare const QUIESCENCE_PROOF_SIGNAL_MAX_RETRY_MS = 5000;
|
|
50
50
|
export declare const TURN_QUIESCENCE_WATCHDOG_MS: number;
|
|
51
51
|
export declare const TURN_FINALIZER_STEP_TIMEOUT_MS = 30000;
|
|
52
|
-
/** A fenced activity must never heartbeat forever while
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* then commits the exact quiescence receipt. */
|
|
52
|
+
/** A fenced activity must never heartbeat forever while physical cleanup is
|
|
53
|
+
* stuck. The callback requests host-owned containment, which drains peer turns
|
|
54
|
+
* before applying its final exit policy. A timeout is never quiescence proof. */
|
|
56
55
|
export declare function armTurnQuiescenceWatchdog(input: {
|
|
57
56
|
enabled: boolean;
|
|
58
57
|
timeoutMs?: number;
|
|
@@ -88,6 +87,7 @@ export declare function drainAttemptOwnedSandboxWriters(input: {
|
|
|
88
87
|
gitCredentialRenewals: readonly Pick<GitCredentialRenewalController, "stop">[];
|
|
89
88
|
codemodeTokenRenewal: Pick<CodemodeTokenRenewalController, "stop"> | null;
|
|
90
89
|
runCredentialRenewal: Pick<RunCredentialRenewalController, "stop"> | null;
|
|
90
|
+
onStage?: (stage: "tool_writers" | "credential_renewals") => void;
|
|
91
91
|
}): Promise<void>;
|
|
92
92
|
/** Persist the exact turn's second-stage release only after the caller has
|
|
93
93
|
* crossed the physical writer boundary. This wait is intentionally independent
|
|
@@ -175,7 +175,7 @@ export declare class MandatoryHistoryPersistenceError extends Error {
|
|
|
175
175
|
}
|
|
176
176
|
export declare function runMandatoryHistoryPersistenceStep<T>(stage: MandatoryHistoryPersistenceStage, operation: () => Promise<T>): Promise<T>;
|
|
177
177
|
export type OpStreamFinalizer = {
|
|
178
|
-
finalizeOpStreamOps(): Promise<void>;
|
|
178
|
+
finalizeOpStreamOps(toolCallIds?: readonly string[]): Promise<void>;
|
|
179
179
|
};
|
|
180
|
-
/** Release
|
|
181
|
-
export declare function finalizeDurableTurnOpStreams(sessions: readonly unknown[], fallback: OpStreamFinalizer | null): Promise<void>;
|
|
180
|
+
/** Release only durably recorded tool results, or the complete durable turn. */
|
|
181
|
+
export declare function finalizeDurableTurnOpStreams(sessions: readonly unknown[], fallback: OpStreamFinalizer | null, toolCallIds?: readonly string[]): Promise<void>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { getSandboxRecoveryDiscontinuity, type Database } from "@opengeni/db";
|
|
2
|
+
/** v2 also recognizes system-selected checkpoint fallback receipts, and v3
|
|
3
|
+
* the empty-workspace continuation receipts. A worker below the version a
|
|
4
|
+
* session's receipts require cannot claim it (migrations 0526 and 0548). */
|
|
5
|
+
export declare const FILESYSTEM_DISCONTINUITY_PROTOCOL: 3;
|
|
6
|
+
export declare function recoveryAwareSessionInstructions(db: Database, workspaceId: string, session: {
|
|
7
|
+
id: string;
|
|
8
|
+
instructions?: string | null;
|
|
9
|
+
}, readDiscontinuity?: typeof getSandboxRecoveryDiscontinuity): Promise<string>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AttemptToolDefinition } from "@opengeni/codemode";
|
|
2
|
+
export declare const REFRESH_CREDENTIALS_TOOL_NAME = "refresh_credentials";
|
|
3
|
+
export declare const REFRESH_CREDENTIALS_TOOL_DESCRIPTION = "Fetch fresh host-managed credentials for this sandbox now. Use it when a command fails because a token or credential file provided by the workspace has expired or been revoked. The environment variables and credential files that the host manages are replaced for the next command; commands that are already running keep what they started with.";
|
|
4
|
+
export declare function createRefreshCredentialsAttemptToolDefinition(input: {
|
|
5
|
+
refresh: () => Promise<"completed" | "auth_needed" | "error" | "not_provisioned">;
|
|
6
|
+
}): AttemptToolDefinition;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { type GitCredentialTokenWriterSession, type NormalizedRunCredentialMaterial, type RunCredentialCommandSession, type CodemodeTokenWriterSession } from "@opengeni/runtime";
|
|
1
|
+
import { type GitCredentialTokenWriterSession, type NormalizedRunCredentialMaterial, type RunCredentialCommandSession, type CodemodeTokenWriterSession, RunMcpCredentials } from "@opengeni/runtime";
|
|
2
2
|
import { type Settings } from "@opengeni/config";
|
|
3
3
|
import { type GitHubTokenMintAuthorization, type MintedRunGitCredentials, type loadWorkspaceEnvironmentForRunWithCredentials } from "../environment.js";
|
|
4
4
|
import type { mergeResourceRefs } from "../common.js";
|
|
5
|
+
import type { withFirstPartyTools } from "../goals.js";
|
|
5
6
|
import type { TurnActivityServices as ActivityServices, RunAgentTurnInput } from "../types.js";
|
|
6
7
|
import { type ResumedTurnSandbox } from "../../sandbox-resume.js";
|
|
7
8
|
import type { ClaimTurnOk } from "./claim.js";
|
|
@@ -9,6 +10,8 @@ import type { GovernanceModelOk } from "./governance-model.js";
|
|
|
9
10
|
import type { SandboxTurnRuntime } from "./sandbox-runtime.js";
|
|
10
11
|
import type { AttemptIdentityState, EventingState, RenewalState, SandboxRuntimeState } from "./turn-context.js";
|
|
11
12
|
export type PrepareRunCredentialsDeps = {
|
|
13
|
+
localMcpServerIds?: readonly string[];
|
|
14
|
+
turnTools: ReturnType<typeof withFirstPartyTools>;
|
|
12
15
|
input: RunAgentTurnInput;
|
|
13
16
|
settings: Settings;
|
|
14
17
|
db: ActivityServices["db"];
|
|
@@ -23,6 +26,7 @@ export type PrepareRunCredentialsDeps = {
|
|
|
23
26
|
sandboxRuntime: SandboxTurnRuntime;
|
|
24
27
|
turn: ClaimTurnOk["turn"];
|
|
25
28
|
session: ClaimTurnOk["session"];
|
|
29
|
+
turnExecutionPolicy: ClaimTurnOk["turnExecutionPolicy"];
|
|
26
30
|
fileAuthoritySubjectId: ClaimTurnOk["fileAuthoritySubjectId"];
|
|
27
31
|
runSettings: GovernanceModelOk["runSettings"];
|
|
28
32
|
workspaceVariableSet: Awaited<ReturnType<typeof loadWorkspaceEnvironmentForRunWithCredentials>>;
|
|
@@ -49,18 +53,19 @@ export type PrepareRunCredentialsDeps = {
|
|
|
49
53
|
runWorkspaceMutationForSandbox: SandboxTurnRuntime["runWorkspaceMutationForSandbox"];
|
|
50
54
|
};
|
|
51
55
|
export declare function prepareRunCredentials(deps: PrepareRunCredentialsDeps): Promise<{
|
|
56
|
+
runMcpCredentials: RunMcpCredentials;
|
|
52
57
|
runCredentialResolver: import("../run-credentials.js").BoundRunCredentialResolver | null;
|
|
53
58
|
establishPolicy: "eager" | "on-demand";
|
|
54
59
|
initialRunCredentialMaterial: NormalizedRunCredentialMaterial | null;
|
|
55
60
|
runCredentialsNote: string | undefined;
|
|
56
61
|
authorizeGitHubTokenMint: GitHubTokenMintAuthorization;
|
|
57
|
-
hostCredentialRootSessionId: string | null;
|
|
58
62
|
gitCredentialAuthority: import("../environment.js").GitCredentialAuthority | undefined;
|
|
59
63
|
codemodeAuthority: {
|
|
60
64
|
sessionId: string;
|
|
61
65
|
turnId: string;
|
|
62
66
|
attemptId: string;
|
|
63
67
|
executionGeneration: number;
|
|
68
|
+
credentialRestriction?: "developer_setup";
|
|
64
69
|
};
|
|
65
70
|
sandboxArtifactRuntime: Readonly<{
|
|
66
71
|
available: boolean;
|
|
@@ -79,6 +84,6 @@ export declare function prepareRunCredentials(deps: PrepareRunCredentialsDeps):
|
|
|
79
84
|
startRunGitCredentialsMint: () => Promise<MintedRunGitCredentials | undefined>;
|
|
80
85
|
attachGitCredentialRenewal: (tokenSession: GitCredentialTokenWriterSession, initial: MintedRunGitCredentials | undefined, initialSandbox?: ResumedTurnSandbox) => Promise<void>;
|
|
81
86
|
attachCodemodeTokenRenewal: (tokenSession?: CodemodeTokenWriterSession, initialExpiresAt?: Date | undefined, initialSandbox?: ResumedTurnSandbox) => Promise<void>;
|
|
82
|
-
attachRunCredentialRenewal: (credentialSession: RunCredentialCommandSession, initialMaterial: NormalizedRunCredentialMaterial | null, initialSandbox?: ResumedTurnSandbox) => Promise<void>;
|
|
87
|
+
attachRunCredentialRenewal: (credentialSession: RunCredentialCommandSession | undefined, initialMaterial: NormalizedRunCredentialMaterial | null, initialSandbox?: ResumedTurnSandbox) => Promise<void>;
|
|
83
88
|
}>;
|
|
84
89
|
export type PrepareRunCredentialsOk = Awaited<ReturnType<typeof prepareRunCredentials>>;
|
|
@@ -4,7 +4,7 @@ import { type GitCredentialTokenWriterSession, type NormalizedRunCredentialMater
|
|
|
4
4
|
import { type Settings } from "@opengeni/config";
|
|
5
5
|
import { mergeResourceRefs } from "../common.js";
|
|
6
6
|
import { type MintedRunGitCredentials, type SandboxCodemodeAuthority } from "../environment.js";
|
|
7
|
-
import { rigProviderImageSourceImage } from "../
|
|
7
|
+
import { rigProviderImageSourceImage } from "../sandbox-images.js";
|
|
8
8
|
import type { TurnActivityServices as ActivityServices, RunAgentTurnInput } from "../types.js";
|
|
9
9
|
import type { currentActivityContext } from "../streaming.js";
|
|
10
10
|
import { type ResumedTurnSandbox } from "../../sandbox-resume.js";
|
|
@@ -35,6 +35,7 @@ export type SandboxRouteOk = {
|
|
|
35
35
|
machinePrimary: boolean;
|
|
36
36
|
groupBoxBackend: Settings["sandboxBackend"];
|
|
37
37
|
groupBoxImage: ReturnType<typeof rigProviderImageSourceImage>;
|
|
38
|
+
groupBoxImagePolicy: "new_creates_only";
|
|
38
39
|
sandboxCreationBackend: Settings["sandboxBackend"];
|
|
39
40
|
effectiveRunCredentialBackend: Settings["sandboxBackend"];
|
|
40
41
|
};
|
|
@@ -81,8 +81,10 @@ export declare function createTurnSandboxProvisioner<T>(establish: () => Promise
|
|
|
81
81
|
* - legacy/built-in OpenAI or Azure Responses fallback (resolvedModel null);
|
|
82
82
|
* - resolved built-in OpenAI/Azure providers;
|
|
83
83
|
* - ChatGPT/Codex subscription backend (its strict allowlist permits the field).
|
|
84
|
+
* - native Anthropic Messages (maps the internal key to Claude session identity;
|
|
85
|
+
* the OpenAI field is never sent on that wire).
|
|
84
86
|
*
|
|
85
|
-
*
|
|
87
|
+
* Other registry API-key providers are intentionally excluded. Fireworks' prompt-cache
|
|
86
88
|
* docs prescribe `user` or `x-session-affinity`, not `prompt_cache_key`; Z.AI/GLM
|
|
87
89
|
* documents automatic context caching plus `user_id`. Sending OpenAI-only fields
|
|
88
90
|
* to unknown OpenAI-compatible providers risks unsupported-parameter 400s.
|
|
@@ -60,6 +60,9 @@ export declare function shouldPrefetchManagedSandbox(input: {
|
|
|
60
60
|
machinePrimary: boolean;
|
|
61
61
|
groupBoxBackend: Settings["sandboxBackend"];
|
|
62
62
|
hasRepositoryResources: boolean;
|
|
63
|
+
/** A committed automatic post-loss recovery decision still awaits its box.
|
|
64
|
+
* Rematerialize now instead of leaving the group pinned until a tool call. */
|
|
65
|
+
automaticRecoveryPending?: boolean;
|
|
63
66
|
}): boolean;
|
|
64
67
|
/**
|
|
65
68
|
* Classify a persisted active-sandbox pointer for TURN-START RECONCILE (issue #341
|
|
@@ -109,15 +112,6 @@ export declare function reconcileActiveSandboxPointer(db: ActivityServices["db"]
|
|
|
109
112
|
type: SessionEventType;
|
|
110
113
|
payload: unknown;
|
|
111
114
|
}>) => Promise<void> | void): Promise<LoadedActivePointer>;
|
|
112
|
-
/**
|
|
113
|
-
* Warm the Modal private-registry image for the image ref this turn actually
|
|
114
|
-
* resolved, not only the deployment-global OPENGENI_MODAL_IMAGE_REF warmed at
|
|
115
|
-
* worker boot. A provider-native modalImageId bypasses registry import and is
|
|
116
|
-
* resolved by ModalImageSelector.fromId during create. Otherwise packs can
|
|
117
|
-
* override `modalImageRef` per workspace/turn, so a private pack image must be
|
|
118
|
-
* resolved before sandbox creation or Modal falls back to the unauthenticated
|
|
119
|
-
* `fromTag` path.
|
|
120
|
-
*/
|
|
121
115
|
export declare function ensureTurnModalRegistryImage(runSettings: Settings, sandboxCreationBackend: Settings["sandboxBackend"] | undefined, ensureRegistryImage?: (settings: Settings) => Promise<void>): Promise<void>;
|
|
122
116
|
export declare const SANDBOX_ARTIFACT_RUNTIME_MANIFEST = "/opt/opengeni/artifact-runtime/installation.json";
|
|
123
117
|
export declare const SANDBOX_ARTIFACT_TOOL_ENTRY = "/opt/opengeni/artifact-runtime/skill-facade-entry.mjs";
|
|
@@ -125,17 +119,6 @@ export type SandboxArtifactRuntimeAdmission = Readonly<{
|
|
|
125
119
|
available: boolean;
|
|
126
120
|
environment: Readonly<Record<string, string>>;
|
|
127
121
|
}>;
|
|
128
|
-
/**
|
|
129
|
-
* Admit the optional native standalone-file runtime only for the deployment's
|
|
130
|
-
* exact base sandbox image contract. A pack/rig image override is an
|
|
131
|
-
* independent filesystem and therefore fails closed even when the deployment
|
|
132
|
-
* base image is capable. Collaborative artifact skills are admitted separately
|
|
133
|
-
* from the frozen canonical tool catalog.
|
|
134
|
-
*
|
|
135
|
-
* This keeps lazy provisioning intact: CI/release proves the image closure,
|
|
136
|
-
* while a before-agent-start doctor verifies the actual box before any model
|
|
137
|
-
* call. No speculative sandbox is created merely to populate the skill index.
|
|
138
|
-
*/
|
|
139
122
|
export declare function sandboxArtifactRuntimeAdmission(deploymentSettings: Settings, runSettings: Settings, backend: Settings["sandboxBackend"] | undefined, options?: Readonly<{
|
|
140
123
|
production?: boolean;
|
|
141
124
|
}>): SandboxArtifactRuntimeAdmission;
|
|
@@ -36,11 +36,11 @@ export declare function preemptSandboxTurnForDeadlineRotation(input: {
|
|
|
36
36
|
export declare function createSandboxTurnRuntime(deps: SandboxTurnRuntimeDeps): {
|
|
37
37
|
releaseLateSandbox: (sandbox: ResumedTurnSandbox) => Promise<void>;
|
|
38
38
|
requireResolvedSandboxForMutation: (message: string) => ResumedTurnSandbox;
|
|
39
|
-
finalizeTurnOpStreamOps: () => Promise<void>;
|
|
39
|
+
finalizeTurnOpStreamOps: (toolCallIds?: readonly string[]) => Promise<void>;
|
|
40
40
|
onHomeSandboxRebound: (rebound: {
|
|
41
41
|
established: EstablishedSandboxSession;
|
|
42
42
|
leaseEpoch: number;
|
|
43
|
-
}) => void
|
|
43
|
+
}) => Promise<void>;
|
|
44
44
|
runWorkspaceMutationForSandbox: <T>(sandbox: ResumedTurnSandbox, operation: string, mutation: () => Promise<T>, observePhase?: (measurement: {
|
|
45
45
|
phase: "admission" | "provider" | "settlement" | "snapshot_wait";
|
|
46
46
|
outcome: "completed" | "failed";
|