@opengeni/worker-bundle 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/activities/agent-run-admission.d.ts +1 -14
- package/dist/activities/agent-turn/errors.d.ts +3 -0
- package/dist/activities/agent-turn/provider-recovery-metrics.d.ts +18 -0
- package/dist/activities/agent-turn/turn-context.d.ts +5 -0
- package/dist/activities/goals.d.ts +1 -17
- package/dist/activities/types.d.ts +1 -1
- package/dist/{activities-control-BNPTRTOE.js → activities-control-XZAIMFQJ.js} +23 -7
- package/dist/activities-control-XZAIMFQJ.js.map +1 -0
- package/dist/{activities-turn-5LGZOSVU.js → activities-turn-4EEVNZCC.js} +97 -5
- package/dist/activities-turn-4EEVNZCC.js.map +1 -0
- package/dist/{chunk-LJX7Z2KP.js → chunk-OT64XARC.js} +38 -162
- package/dist/chunk-OT64XARC.js.map +1 -0
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/workflow-bundle.js +1 -1
- package/package.json +21 -21
- package/src/activities/agent-run-admission.ts +1 -98
- package/src/activities/agent-turn/claim.ts +11 -0
- package/src/activities/agent-turn/compaction-prep.ts +15 -0
- package/src/activities/agent-turn/errors.ts +30 -15
- package/src/activities/agent-turn/failure-settlement.ts +22 -0
- package/src/activities/agent-turn/provider-recovery-metrics.ts +64 -0
- package/src/activities/agent-turn/stream-attempt.ts +10 -0
- package/src/activities/agent-turn/tool-environment.ts +9 -2
- package/src/activities/agent-turn/turn-context.ts +4 -0
- package/src/activities/goals.ts +17 -113
- package/src/activities/scheduled-tasks.ts +18 -3
- package/src/activities/types.ts +1 -0
- package/src/index.ts +0 -2
- package/dist/activities-control-BNPTRTOE.js.map +0 -1
- package/dist/activities-turn-5LGZOSVU.js.map +0 -1
- package/dist/chunk-LJX7Z2KP.js.map +0 -1
|
@@ -1,14 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import type { ControlActivityServices } from "./types.js";
|
|
3
|
-
export type AgentRunAdmissionDenial = "insufficient_credits" | "allowance_exhausted" | "monthly_model_cost_limit" | "monthly_agent_run_limit";
|
|
4
|
-
/** One worker-side admission boundary for service-authored agent runs. */
|
|
5
|
-
export declare function agentRunAdmissionDenial(services: Pick<ControlActivityServices, "db" | "entitlements"> & {
|
|
6
|
-
settings: Settings;
|
|
7
|
-
}, input: {
|
|
8
|
-
accountId: string;
|
|
9
|
-
workspaceId: string;
|
|
10
|
-
model: string;
|
|
11
|
-
requestedAgentRuns: number;
|
|
12
|
-
/** The accepted work's causal human, not the scheduler/service caller. */
|
|
13
|
-
initiatingHumanSubjectId?: string | null;
|
|
14
|
-
}): Promise<AgentRunAdmissionDenial | null>;
|
|
1
|
+
export { agentRunAdmissionDenial, type AgentRunAdmissionDenial } from "@opengeni/core";
|
|
@@ -13,6 +13,8 @@ export declare const MAX_AUTOMATIC_PROVIDER_RECOVERIES: 5;
|
|
|
13
13
|
* alone would spend every automatic recovery before the window resets.
|
|
14
14
|
*/
|
|
15
15
|
export declare const PROVIDER_RATE_LIMIT_BACKOFF_MS: readonly [10000, 20000, 40000, 60000, 120000];
|
|
16
|
+
/** Positive-only spread: never shorten the provider's minimum delay. */
|
|
17
|
+
export declare function providerRecoveryJitterMs(delayMs: number, sample: number): number;
|
|
16
18
|
export declare const POST_COMPACTION_CONTINUATION_EMPTY_CODE = "post_compaction_continuation_empty";
|
|
17
19
|
export declare class PostCompactionContinuationEmptyError extends Error {
|
|
18
20
|
readonly code = "post_compaction_continuation_empty";
|
|
@@ -30,6 +32,7 @@ export declare function providerRecoveryResult(input: {
|
|
|
30
32
|
failureCode: string | undefined;
|
|
31
33
|
attemptNumber: number;
|
|
32
34
|
retryAfterMs?: number | null;
|
|
35
|
+
jitterSample?: number;
|
|
33
36
|
}): ProviderRecoveryResult;
|
|
34
37
|
export declare function providerRecoveryExhaustedFailure<T extends Record<string, unknown> & {
|
|
35
38
|
error: string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Observability } from "@opengeni/observability";
|
|
2
|
+
export type ProviderRecoveryObservation = {
|
|
3
|
+
startedAt: number;
|
|
4
|
+
cause: "rate_limited" | "unavailable" | "connectivity";
|
|
5
|
+
};
|
|
6
|
+
export declare function providerRecoveryCause(code: unknown): ProviderRecoveryObservation["cause"] | null;
|
|
7
|
+
export declare function readProviderRecoveryObservation(metadata: Record<string, unknown>): ProviderRecoveryObservation | undefined;
|
|
8
|
+
/** Operational observations only; never retry authority, billing or diagnostics. */
|
|
9
|
+
export declare function recordProviderRecoveryOutcome(observability: Observability, input: {
|
|
10
|
+
route?: {
|
|
11
|
+
provider: string;
|
|
12
|
+
model: string;
|
|
13
|
+
} | undefined;
|
|
14
|
+
cause: ProviderRecoveryObservation["cause"];
|
|
15
|
+
outcome: "scheduled" | "recovered" | "exhausted";
|
|
16
|
+
delayMs?: number;
|
|
17
|
+
elapsedMs?: number;
|
|
18
|
+
}): void;
|
|
@@ -43,6 +43,11 @@ export type AttemptIdentityState = {
|
|
|
43
43
|
triggerEventId: string | undefined;
|
|
44
44
|
executionGeneration: number;
|
|
45
45
|
providerRecoveryCount: number;
|
|
46
|
+
providerRecoveryObservation?: import("./provider-recovery-metrics.js").ProviderRecoveryObservation | undefined;
|
|
47
|
+
modelMetricRoute?: {
|
|
48
|
+
provider: string;
|
|
49
|
+
model: string;
|
|
50
|
+
};
|
|
46
51
|
claudeAuthRecovery?: {
|
|
47
52
|
credentialId: string;
|
|
48
53
|
credentialVersion: number;
|
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
import { type Settings } from "@opengeni/config";
|
|
2
2
|
import { type SessionGoal, type ToolRef } from "@opengeni/contracts";
|
|
3
|
-
import { getWorkspaceModelPolicy } from "@opengeni/db";
|
|
4
3
|
import type { ControlActivityServices, MaybeContinueGoalInput, MaybeContinueGoalResult } from "./types.js";
|
|
5
|
-
|
|
4
|
+
export { goalContinuationModelDecision, goalRunBudgetBlocked } from "@opengeni/core";
|
|
6
5
|
export declare function createGoalActivities(services: () => Promise<ControlActivityServices>): {
|
|
7
6
|
enqueueGoalRetryWake: (input: MaybeContinueGoalInput) => Promise<void>;
|
|
8
7
|
maybeContinueGoal: (input: MaybeContinueGoalInput) => Promise<MaybeContinueGoalResult>;
|
|
9
8
|
};
|
|
10
|
-
export declare function goalContinuationModelDecision(input: {
|
|
11
|
-
settings: Settings;
|
|
12
|
-
workspaceModelPolicy: Awaited<ReturnType<typeof getWorkspaceModelPolicy>>;
|
|
13
|
-
inheritedModel: string;
|
|
14
|
-
}): {
|
|
15
|
-
model: string;
|
|
16
|
-
blocked: string | null;
|
|
17
|
-
};
|
|
18
9
|
export declare function goalContinuationFundedWithoutCredits(settings: Settings, model: string, codexBilled: boolean): boolean;
|
|
19
10
|
export declare function goalContinuationPrompt(_goal: SessionGoal, _autoContinuation: number, _cap: number | null, options?: {
|
|
20
11
|
inputWaitAvailable?: boolean;
|
|
@@ -28,10 +19,3 @@ export declare function goalContinuationPrompt(_goal: SessionGoal, _autoContinua
|
|
|
28
19
|
* lists anywhere else in the pipeline. No-op when the server is not configured.
|
|
29
20
|
*/
|
|
30
21
|
export declare function withFirstPartyTools(settings: Settings, tools: ToolRef[]): ToolRef[];
|
|
31
|
-
/**
|
|
32
|
-
* Goals share scheduled admission and pause visibly without synthesizing work.
|
|
33
|
-
*/
|
|
34
|
-
export declare function goalRunBudgetBlocked(services: Parameters<typeof agentRunAdmissionDenial>[0], input: Omit<Parameters<typeof agentRunAdmissionDenial>[1], "requestedAgentRuns">): Promise<{
|
|
35
|
-
pausedReason: "limits" | "allowance";
|
|
36
|
-
message: string;
|
|
37
|
-
} | null>;
|
|
@@ -383,7 +383,7 @@ export type DispatchScheduledTaskRunResult = {
|
|
|
383
383
|
diagnostic?: import("@opengeni/contracts").ConnectionAccountSelectionDiagnostic;
|
|
384
384
|
/** Present when the occurrence was refused as a visible run receipt. */
|
|
385
385
|
refusal?: import("@opengeni/contracts").ScheduledTaskAdmissionRefusal;
|
|
386
|
-
reason: "insufficient_credits" | "allowance_exhausted" | "monthly_model_cost_limit" | "monthly_agent_run_limit" | "malformed_manual_trigger" | "scheduled_task_paused" | "scheduled_authority_exhausted" | "scheduled_run_terminal" | "scheduled_execution_unrepresentable" | "connection_account_unavailable" | "scheduled_authority_unavailable" | "machine_target_unavailable" | "machine_enrollment_inactive" | "variable_set_unavailable" | "rig_version_unavailable" | "knowledge_source_paused" | "legacy_source_schedule_requires_migration" | "atlassian_native_retired" | "incident_preflight_metadata_missing" | "incident_responder_under_capable" | "incident_data_source_unsuitable";
|
|
386
|
+
reason: "insufficient_credits" | "allowance_exhausted" | "monthly_model_cost_limit" | "monthly_agent_run_limit" | "malformed_manual_trigger" | "scheduled_task_paused" | "scheduled_authority_exhausted" | "scheduled_run_terminal" | "scheduled_execution_unrepresentable" | "connection_account_unavailable" | "scheduled_authority_unavailable" | "machine_target_unavailable" | "machine_enrollment_inactive" | "variable_set_unavailable" | "rig_version_unavailable" | "scheduled_model_unavailable" | "knowledge_source_paused" | "legacy_source_schedule_requires_migration" | "atlassian_native_retired" | "incident_preflight_metadata_missing" | "incident_responder_under_capable" | "incident_data_source_unsuitable";
|
|
387
387
|
} | {
|
|
388
388
|
action: "start" | "signal";
|
|
389
389
|
accountId: string;
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
INCIDENT_TELEMETRY_AUTHORITY_FENCE_LINEAGE_KEY,
|
|
10
10
|
MAX_AUTOMATIC_PROVIDER_RECOVERIES,
|
|
11
|
-
agentRunAdmissionDenial,
|
|
12
11
|
assertReusableSessionRevivable,
|
|
13
12
|
captureConnectedCommandOutput,
|
|
14
13
|
createCodexCapacityActivities,
|
|
@@ -35,7 +34,7 @@ import {
|
|
|
35
34
|
warnDrainSnapshotFailure,
|
|
36
35
|
withFirstPartyTools,
|
|
37
36
|
workflowIdForSession
|
|
38
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-OT64XARC.js";
|
|
39
38
|
import {
|
|
40
39
|
inspectOpenSandboxKubernetesInventory,
|
|
41
40
|
recordActiveUserGauges,
|
|
@@ -732,6 +731,11 @@ import {
|
|
|
732
731
|
requireWorkspace
|
|
733
732
|
} from "@opengeni/db";
|
|
734
733
|
import { SessionSkills } from "@opengeni/contracts";
|
|
734
|
+
|
|
735
|
+
// src/activities/agent-run-admission.ts
|
|
736
|
+
import { agentRunAdmissionDenial } from "@opengeni/core";
|
|
737
|
+
|
|
738
|
+
// src/activities/automations.ts
|
|
735
739
|
function createAutomationActivities(services, options = {}) {
|
|
736
740
|
const claim = options.claim ?? claimAutomationRun;
|
|
737
741
|
const settle = options.settle ?? settleAutomationRun;
|
|
@@ -5586,7 +5590,8 @@ import { publishDurableSessionEvents as publishDurableSessionEvents2 } from "@op
|
|
|
5586
5590
|
import {
|
|
5587
5591
|
allowedFirstPartyMcpToolsForSession,
|
|
5588
5592
|
resolveFirstPartyMcpToolPolicy,
|
|
5589
|
-
resolveTurnExecutionPolicyV1 as resolveTurnExecutionPolicyV12
|
|
5593
|
+
resolveTurnExecutionPolicyV1 as resolveTurnExecutionPolicyV12,
|
|
5594
|
+
TurnExecutionPolicyModelUnavailableError
|
|
5590
5595
|
} from "@opengeni/config";
|
|
5591
5596
|
import { Context as Context3 } from "@temporalio/activity";
|
|
5592
5597
|
import { createHash as createHash3 } from "crypto";
|
|
@@ -6354,8 +6359,9 @@ function createScheduledTaskActivities(services) {
|
|
|
6354
6359
|
);
|
|
6355
6360
|
}
|
|
6356
6361
|
} : void 0;
|
|
6357
|
-
|
|
6358
|
-
|
|
6362
|
+
let acceptedTurnExecutionPolicy;
|
|
6363
|
+
try {
|
|
6364
|
+
acceptedTurnExecutionPolicy = resolveTurnExecutionPolicyV12(settings, {
|
|
6359
6365
|
modelId: acceptedModel,
|
|
6360
6366
|
requestedModelId: generatedTarget && task.agentConfig.model ? task.agentConfig.model : null,
|
|
6361
6367
|
modelSource: generatedTarget ? task.agentConfig.model ? "explicit" : "deployment" : "session",
|
|
@@ -6363,7 +6369,17 @@ function createScheduledTaskActivities(services) {
|
|
|
6363
6369
|
reasoningSource: generatedTarget ? task.agentConfig.reasoningEffort ? "explicit" : "deployment" : "session",
|
|
6364
6370
|
latencyMode: acceptedLatencyMode,
|
|
6365
6371
|
latencyModeSource: generatedTarget ? "deployment" : "session"
|
|
6366
|
-
})
|
|
6372
|
+
});
|
|
6373
|
+
} catch (error) {
|
|
6374
|
+
if (!(error instanceof TurnExecutionPolicyModelUnavailableError)) throw error;
|
|
6375
|
+
return await refuseAdmission(
|
|
6376
|
+
"scheduled_model_unavailable",
|
|
6377
|
+
false,
|
|
6378
|
+
`${error.message}: ${acceptedModel}`
|
|
6379
|
+
);
|
|
6380
|
+
}
|
|
6381
|
+
const turnExecutionPolicy = scheduledTaskRunExecutionPolicy(
|
|
6382
|
+
acceptedTurnExecutionPolicy,
|
|
6367
6383
|
input,
|
|
6368
6384
|
creatorPolicy?.credentialRestriction
|
|
6369
6385
|
);
|
|
@@ -8797,4 +8813,4 @@ export {
|
|
|
8797
8813
|
createControlActivities,
|
|
8798
8814
|
createControlActivitiesFromServices
|
|
8799
8815
|
};
|
|
8800
|
-
//# sourceMappingURL=activities-control-
|
|
8816
|
+
//# sourceMappingURL=activities-control-XZAIMFQJ.js.map
|