replicas-engine 0.1.887 → 0.1.889

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.
@@ -5,11 +5,11 @@ import {
5
5
  getCodexAspHost,
6
6
  restartCodexAspHost,
7
7
  restartCodexAspHostIfRunning
8
- } from "./chunk-UZC3FR6R.js";
9
- import "./chunk-N2DC3SCQ.js";
10
- import "./chunk-B7FBFPKL.js";
8
+ } from "./chunk-N7JSMN3R.js";
9
+ import "./chunk-RG6ZP2EU.js";
10
+ import "./chunk-F33TXACU.js";
11
11
  import "./chunk-UZSNFLDQ.js";
12
- import "./chunk-5RULOJKJ.js";
12
+ import "./chunk-45I2CJU6.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
  export {
15
15
  getCodexAspHost,
@@ -1802,6 +1802,56 @@ async function readSseStream(body, onEvent, shouldContinue = () => true) {
1802
1802
  }
1803
1803
  }
1804
1804
 
1805
+ // ../shared/src/workspace-identity.ts
1806
+ import { z as z5 } from "zod";
1807
+ var WORKSPACE_IDENTITY_AUDIENCE = "replicas:workspace";
1808
+ var WORKSPACE_TOKEN_TTL_SECONDS = 15 * 60;
1809
+ var WORKSPACE_TOKEN_FILE = `${SANDBOX_PATHS.REPLICAS_DIR}/credentials/tokens.json`;
1810
+ var IDENTITY_PROXY_PORT = 17323;
1811
+ var WORKSPACE_TOKEN_ENV = {
1812
+ TOKEN: "REPLICAS_WORKSPACE_TOKEN",
1813
+ TOKEN_FILE: "REPLICAS_WORKSPACE_TOKEN_FILE",
1814
+ AUDIENCE: "REPLICAS_WORKSPACE_TOKEN_AUDIENCE",
1815
+ ISSUER: "REPLICAS_WORKSPACE_IDENTITY_ISSUER"
1816
+ };
1817
+ var workspaceTokenClaimsSchema = z5.object({
1818
+ iss: z5.string(),
1819
+ sub: z5.string(),
1820
+ aud: z5.string(),
1821
+ iat: z5.number().int(),
1822
+ nbf: z5.number().int(),
1823
+ exp: z5.number().int(),
1824
+ jti: z5.string(),
1825
+ organization_id: z5.string().uuid(),
1826
+ workspace_id: z5.string().uuid(),
1827
+ environment_id: z5.string().uuid(),
1828
+ creator_id: z5.string().uuid().nullable()
1829
+ }).passthrough();
1830
+ var workspaceTokenBundleSchema = z5.strictObject({
1831
+ version: z5.literal(1),
1832
+ issuer: z5.string(),
1833
+ default_audience: z5.string(),
1834
+ tokens: z5.record(
1835
+ z5.string(),
1836
+ z5.strictObject({ token: z5.string(), expires_at: z5.string() })
1837
+ )
1838
+ });
1839
+ var workloadAudienceInput = z5.strictObject({
1840
+ name: z5.string().trim().min(1).max(64),
1841
+ audience: z5.string().min(1).max(255).regex(/^[\x21-\x7e]+$/, "Audience must be a single printable token without spaces").refine((value) => value !== WORKSPACE_IDENTITY_AUDIENCE, "Reserved audience"),
1842
+ enabled: z5.boolean(),
1843
+ is_default: z5.boolean()
1844
+ });
1845
+ var mcpWorkloadAuthSchema = z5.strictObject({
1846
+ type: z5.literal("workspace_identity"),
1847
+ audience: z5.string().min(1)
1848
+ });
1849
+ function currentWorkspaceToken(bundle, audience = bundle.default_audience, now = Date.now()) {
1850
+ const entry = bundle.tokens[audience];
1851
+ if (!entry || Date.parse(entry.expires_at) <= now) return null;
1852
+ return entry.token;
1853
+ }
1854
+
1805
1855
  // ../shared/src/json.ts
1806
1856
  function safeJsonParse(str, fallback) {
1807
1857
  try {
@@ -1880,12 +1930,12 @@ function describeAuthFallback(payload) {
1880
1930
  }
1881
1931
 
1882
1932
  // ../shared/src/workspace-credentials.ts
1883
- import { z as z5 } from "zod";
1933
+ import { z as z6 } from "zod";
1884
1934
  var WORKSPACE_CREDENTIAL_PROVIDERS = ["claude", "codex"];
1885
- var workspaceCredentialProviderSchema = z5.enum(WORKSPACE_CREDENTIAL_PROVIDERS);
1935
+ var workspaceCredentialProviderSchema = z6.enum(WORKSPACE_CREDENTIAL_PROVIDERS);
1886
1936
  var workspaceCredentialSelectionSchema = agentCredentialSnapshotSchema.omit({ revision: true });
1887
1937
  var createWorkspaceCredentialSchema = workspaceCredentialSelectionSchema.extend({
1888
- provider: z5.enum(VALID_CODING_AGENT_PROVIDERS)
1938
+ provider: z6.enum(VALID_CODING_AGENT_PROVIDERS)
1889
1939
  }).refine(({ provider, method }) => agentCredentialMethods(provider).includes(method), {
1890
1940
  message: "This inference provider is not supported by this agent"
1891
1941
  });
@@ -1896,57 +1946,57 @@ var switchWorkspaceCredentialSchema = workspaceCredentialSelectionSchema.extend(
1896
1946
  });
1897
1947
 
1898
1948
  // ../shared/src/chat-fork.ts
1899
- import { z as z7 } from "zod";
1949
+ import { z as z8 } from "zod";
1900
1950
 
1901
1951
  // ../shared/src/fallback-chains.ts
1902
- import { z as z6 } from "zod";
1903
- var fallbackHarnessStepSchema = z6.object({
1904
- kind: z6.literal("harness"),
1905
- provider: z6.enum(VALID_AGENT_PROVIDERS),
1906
- relayBaseProvider: z6.enum(VALID_RELAY_BASE_PROVIDERS).optional(),
1907
- model: z6.string().min(1),
1908
- thinkingLevel: z6.enum(VALID_THINKING_LEVELS).optional()
1952
+ import { z as z7 } from "zod";
1953
+ var fallbackHarnessStepSchema = z7.object({
1954
+ kind: z7.literal("harness"),
1955
+ provider: z7.enum(VALID_AGENT_PROVIDERS),
1956
+ relayBaseProvider: z7.enum(VALID_RELAY_BASE_PROVIDERS).optional(),
1957
+ model: z7.string().min(1),
1958
+ thinkingLevel: z7.enum(VALID_THINKING_LEVELS).optional()
1909
1959
  });
1910
- var fallbackPlanStepSchema = z6.discriminatedUnion("kind", [
1911
- z6.object({ kind: z6.literal("credentials"), methods: z6.array(z6.custom(isAuthMethod)).min(1) }),
1960
+ var fallbackPlanStepSchema = z7.discriminatedUnion("kind", [
1961
+ z7.object({ kind: z7.literal("credentials"), methods: z7.array(z7.custom(isAuthMethod)).min(1) }),
1912
1962
  fallbackHarnessStepSchema
1913
1963
  ]);
1914
- var fallbackPlanResponseSchema = z6.object({ steps: z6.array(fallbackPlanStepSchema) });
1964
+ var fallbackPlanResponseSchema = z7.object({ steps: z7.array(fallbackPlanStepSchema) });
1915
1965
 
1916
1966
  // ../shared/src/chat-fork.ts
1917
- var quotaLimitKindSchema = z7.enum(["rate_limit", "out_of_credits"]);
1918
- var chatForkInfoSchema = z7.object({
1919
- source: z7.object({
1920
- chatId: z7.string().min(1),
1921
- provider: z7.enum(VALID_AGENT_PROVIDERS),
1922
- title: z7.string()
1967
+ var quotaLimitKindSchema = z8.enum(["rate_limit", "out_of_credits"]);
1968
+ var chatForkInfoSchema = z8.object({
1969
+ source: z8.object({
1970
+ chatId: z8.string().min(1),
1971
+ provider: z8.enum(VALID_AGENT_PROVIDERS),
1972
+ title: z8.string()
1923
1973
  }),
1924
- trigger: z7.enum(["manual", "auto"]),
1974
+ trigger: z8.enum(["manual", "auto"]),
1925
1975
  reason: quotaLimitKindSchema.optional(),
1926
- state: z7.enum(["preparing", "ready", "failed"]),
1927
- error: z7.string().optional(),
1928
- startedAt: z7.string(),
1929
- completedAt: z7.string().optional()
1976
+ state: z8.enum(["preparing", "ready", "failed"]),
1977
+ error: z8.string().optional(),
1978
+ startedAt: z8.string(),
1979
+ completedAt: z8.string().optional()
1930
1980
  });
1931
1981
  function coerceChatForkInfo(value) {
1932
1982
  const parsed = chatForkInfoSchema.safeParse(value);
1933
1983
  return parsed.success ? parsed.data : null;
1934
1984
  }
1935
- var forkChatRequestSchema = z7.object({
1936
- provider: z7.enum(VALID_AGENT_PROVIDERS),
1937
- relayBaseProvider: z7.enum(VALID_RELAY_BASE_PROVIDERS).optional(),
1938
- model: z7.string().min(1).optional(),
1939
- thinkingLevel: z7.enum(VALID_THINKING_LEVELS).optional(),
1940
- title: z7.string().min(1).max(200).optional(),
1941
- message: z7.string().trim().optional(),
1942
- id: z7.string().uuid().optional(),
1943
- clientRequestId: z7.string().min(1).max(128).optional(),
1944
- enableInteractiveTools: z7.boolean().optional(),
1985
+ var forkChatRequestSchema = z8.object({
1986
+ provider: z8.enum(VALID_AGENT_PROVIDERS),
1987
+ relayBaseProvider: z8.enum(VALID_RELAY_BASE_PROVIDERS).optional(),
1988
+ model: z8.string().min(1).optional(),
1989
+ thinkingLevel: z8.enum(VALID_THINKING_LEVELS).optional(),
1990
+ title: z8.string().min(1).max(200).optional(),
1991
+ message: z8.string().trim().optional(),
1992
+ id: z8.string().uuid().optional(),
1993
+ clientRequestId: z8.string().min(1).max(128).optional(),
1994
+ enableInteractiveTools: z8.boolean().optional(),
1945
1995
  // Server-injected by the monolith from the authenticated request; never trusted from clients.
1946
- senderUserId: z7.string().optional(),
1947
- senderEmail: z7.string().optional(),
1948
- senderDisplayName: z7.string().optional(),
1949
- senderAvatarUrl: z7.string().optional()
1996
+ senderUserId: z8.string().optional(),
1997
+ senderEmail: z8.string().optional(),
1998
+ senderDisplayName: z8.string().optional(),
1999
+ senderAvatarUrl: z8.string().optional()
1950
2000
  });
1951
2001
  function describeQuotaLimit(reason) {
1952
2002
  return reason === "out_of_credits" ? "ran out of credits" : "hit its usage limit";
@@ -1955,10 +2005,10 @@ function describeChatForkReason(reason, provider) {
1955
2005
  return reason ? `${getProviderDisplayName(provider)} ${describeQuotaLimit(reason)}` : null;
1956
2006
  }
1957
2007
  var AGENT_QUOTA_EXHAUSTED_EVENT_TYPE = "agent-quota-exhausted";
1958
- var agentQuotaExhaustedPayloadSchema = z7.object({
1959
- provider: z7.enum(VALID_CODING_AGENT_PROVIDERS),
2008
+ var agentQuotaExhaustedPayloadSchema = z8.object({
2009
+ provider: z8.enum(VALID_CODING_AGENT_PROVIDERS),
1960
2010
  reason: quotaLimitKindSchema,
1961
- detail: z7.string().optional(),
2011
+ detail: z8.string().optional(),
1962
2012
  forkTo: fallbackHarnessStepSchema.optional()
1963
2013
  });
1964
2014
  function defaultForkChatTitle(source, provider) {
@@ -3223,32 +3273,32 @@ var MEDIA_ABILITY = {
3223
3273
  };
3224
3274
 
3225
3275
  // ../shared/src/memory.ts
3226
- import { z as z8 } from "zod";
3276
+ import { z as z9 } from "zod";
3227
3277
  var MEMORY_ROOT = `${SANDBOX_PATHS.REPLICAS_DIR}/memories`;
3228
3278
  var MEMORY_INDEX_FILENAME = "MEMORY.md";
3229
3279
  var MEMORY_BUNDLE_FILENAME = "memory.tar.gz";
3230
3280
  var MEMORY_MARKER_GUIDANCE = `When you decide that a preference, correction, decision, procedure, or lesson is worth remembering for future sessions, say so in your response casually, like a coworker: "Ah, I'll remember that for next time" or "I'll keep that in mind." Keep it natural and never mention the memory feature, memory pipeline, markers, persistence, or that you are saving or adding something to memory. These phrases signal intent to remember; they do not mean anything has already been saved, so do not claim persistence is complete.`;
3231
- var memoryExtractionResultSchema = z8.object({
3232
- seatSummary: z8.string().nullable(),
3233
- organizationSummary: z8.string().nullable()
3281
+ var memoryExtractionResultSchema = z9.object({
3282
+ seatSummary: z9.string().nullable(),
3283
+ organizationSummary: z9.string().nullable()
3234
3284
  });
3235
- var { $schema: _, ...MEMORY_EXTRACTION_SCHEMA } = z8.toJSONSchema(memoryExtractionResultSchema);
3236
- var memoryGenerationManifestSchema = z8.object({
3237
- domainId: z8.string(),
3238
- generation: z8.number().int().nonnegative(),
3239
- previousManifestKey: z8.string().nullable(),
3240
- createdAt: z8.string(),
3241
- promptVersion: z8.string(),
3242
- harness: z8.enum(["claude", "codex", "none"]),
3243
- model: z8.string(),
3244
- bundle: z8.object({
3245
- path: z8.literal(MEMORY_BUNDLE_FILENAME),
3246
- sha256: z8.string().regex(/^[a-f0-9]{64}$/),
3247
- sizeBytes: z8.number().int().positive()
3285
+ var { $schema: _, ...MEMORY_EXTRACTION_SCHEMA } = z9.toJSONSchema(memoryExtractionResultSchema);
3286
+ var memoryGenerationManifestSchema = z9.object({
3287
+ domainId: z9.string(),
3288
+ generation: z9.number().int().nonnegative(),
3289
+ previousManifestKey: z9.string().nullable(),
3290
+ createdAt: z9.string(),
3291
+ promptVersion: z9.string(),
3292
+ harness: z9.enum(["claude", "codex", "none"]),
3293
+ model: z9.string(),
3294
+ bundle: z9.object({
3295
+ path: z9.literal(MEMORY_BUNDLE_FILENAME),
3296
+ sha256: z9.string().regex(/^[a-f0-9]{64}$/),
3297
+ sizeBytes: z9.number().int().positive()
3248
3298
  }).nullable(),
3249
- files: z8.record(z8.string(), z8.string()),
3250
- rollouts: z8.record(z8.string(), z8.string()),
3251
- rolloutSources: z8.record(z8.string(), z8.string()).optional()
3299
+ files: z9.record(z9.string(), z9.string()),
3300
+ rollouts: z9.record(z9.string(), z9.string()),
3301
+ rolloutSources: z9.record(z9.string(), z9.string()).optional()
3252
3302
  });
3253
3303
 
3254
3304
  // ../shared/src/default-skills/replicas-agent/abilities/memory.ts
@@ -3615,6 +3665,10 @@ In agent mode the CLI hides commands that don't make sense for in-workspace agen
3615
3665
  | Command | What it does |
3616
3666
  | --- | --- |
3617
3667
  | \`replicas whoami\` | Print the workspace + org identity |
3668
+ | \`replicas identity token [--audience <aud>]\` | Print the current short-lived workspace identity token for an audience |
3669
+ | \`replicas identity token --format gcp --audience <aud>\` | Supply a current token to Google's executable credential source |
3670
+ | \`replicas identity aws-credentials --role-arn <arn> [--region <region>]\` | Exchange the current token for AWS credential_process JSON (requires AWS CLI) |
3671
+ | \`replicas identity exec [--audience <aud>] -- <command>\` | Run a command with the current token and audience in its environment |
3618
3672
  | \`replicas init\` | Create a \`replicas.json\` / \`replicas.yaml\` in the current directory |
3619
3673
  | \`replicas connect <name>\` | SSH into another workspace (requires user creds \u2014 usually only useful when scripting locally) |
3620
3674
  | \`replicas repos\` | List repos connected to the org |
@@ -7342,38 +7396,38 @@ function shouldRefreshPullRequests(toolName, toolInput) {
7342
7396
  }
7343
7397
 
7344
7398
  // ../shared/src/routes/linear.ts
7345
- import { z as z9 } from "zod";
7346
- var linearSessionMetadataSchema = z9.object({
7347
- via_mothership: z9.boolean().optional(),
7348
- issue_id: z9.string(),
7349
- issue_identifier: z9.string(),
7350
- issue_title: z9.string(),
7351
- issue_description: z9.string(),
7352
- issue_url: z9.string(),
7353
- comment_id: z9.string(),
7354
- comment_body: z9.string(),
7355
- triggered_by_id: z9.string().optional(),
7356
- triggered_by_name: z9.string().optional(),
7357
- triggered_by_email: z9.string().optional(),
7358
- linear_workspace_id: z9.string().optional(),
7359
- creator_id: z9.string().optional(),
7360
- creator_name: z9.string().optional(),
7361
- creator_email: z9.string().optional(),
7362
- assignee_id: z9.string().optional(),
7363
- assignee_name: z9.string().optional(),
7364
- assignee_email: z9.string().optional(),
7365
- issue_state: z9.string().optional(),
7366
- parent_issue: z9.object({
7367
- id: z9.string(),
7368
- identifier: z9.string(),
7369
- title: z9.string(),
7370
- description: z9.string().nullable()
7399
+ import { z as z10 } from "zod";
7400
+ var linearSessionMetadataSchema = z10.object({
7401
+ via_mothership: z10.boolean().optional(),
7402
+ issue_id: z10.string(),
7403
+ issue_identifier: z10.string(),
7404
+ issue_title: z10.string(),
7405
+ issue_description: z10.string(),
7406
+ issue_url: z10.string(),
7407
+ comment_id: z10.string(),
7408
+ comment_body: z10.string(),
7409
+ triggered_by_id: z10.string().optional(),
7410
+ triggered_by_name: z10.string().optional(),
7411
+ triggered_by_email: z10.string().optional(),
7412
+ linear_workspace_id: z10.string().optional(),
7413
+ creator_id: z10.string().optional(),
7414
+ creator_name: z10.string().optional(),
7415
+ creator_email: z10.string().optional(),
7416
+ assignee_id: z10.string().optional(),
7417
+ assignee_name: z10.string().optional(),
7418
+ assignee_email: z10.string().optional(),
7419
+ issue_state: z10.string().optional(),
7420
+ parent_issue: z10.object({
7421
+ id: z10.string(),
7422
+ identifier: z10.string(),
7423
+ title: z10.string(),
7424
+ description: z10.string().nullable()
7371
7425
  }).optional(),
7372
- workspace: z9.object({
7373
- id: z9.string(),
7374
- coding_agent: z9.custom((value) => typeof value === "string" && isValidAgentProvider(value)),
7375
- task_description: z9.string(),
7376
- created_at: z9.string()
7426
+ workspace: z10.object({
7427
+ id: z10.string(),
7428
+ coding_agent: z10.custom((value) => typeof value === "string" && isValidAgentProvider(value)),
7429
+ task_description: z10.string(),
7430
+ created_at: z10.string()
7377
7431
  }).optional()
7378
7432
  });
7379
7433
 
@@ -7708,46 +7762,46 @@ var DEFAULT_WORKSPACE_FILTERS = {
7708
7762
  var ONE_DAY_MS = 24 * 60 * 60 * 1e3;
7709
7763
 
7710
7764
  // ../shared/src/routes/workspace-events.ts
7711
- import { z as z10 } from "zod";
7712
- var workspaceChangedEventSchema = z10.discriminatedUnion("type", [
7713
- z10.object({
7714
- type: z10.literal("workspace.changed"),
7715
- workspaceId: z10.string(),
7716
- completion: z10.object({
7717
- workspaceName: z10.string(),
7718
- completedAt: z10.string(),
7719
- processing: z10.boolean().optional()
7765
+ import { z as z11 } from "zod";
7766
+ var workspaceChangedEventSchema = z11.discriminatedUnion("type", [
7767
+ z11.object({
7768
+ type: z11.literal("workspace.changed"),
7769
+ workspaceId: z11.string(),
7770
+ completion: z11.object({
7771
+ workspaceName: z11.string(),
7772
+ completedAt: z11.string(),
7773
+ processing: z11.boolean().optional()
7720
7774
  }).optional(),
7721
- ts: z10.string()
7775
+ ts: z11.string()
7722
7776
  }),
7723
- z10.object({
7724
- type: z10.literal("workspace.chat.changed"),
7725
- workspaceId: z10.string(),
7726
- chatId: z10.string(),
7727
- ts: z10.string()
7777
+ z11.object({
7778
+ type: z11.literal("workspace.chat.changed"),
7779
+ workspaceId: z11.string(),
7780
+ chatId: z11.string(),
7781
+ ts: z11.string()
7728
7782
  }),
7729
- z10.object({ type: z10.literal("presence.changed"), ts: z10.string() }),
7730
- z10.object({
7731
- type: z10.literal("mobile-testing.changed"),
7732
- workspaceId: z10.string(),
7733
- ts: z10.string()
7783
+ z11.object({ type: z11.literal("presence.changed"), ts: z11.string() }),
7784
+ z11.object({
7785
+ type: z11.literal("mobile-testing.changed"),
7786
+ workspaceId: z11.string(),
7787
+ ts: z11.string()
7734
7788
  })
7735
7789
  ]);
7736
7790
 
7737
7791
  // ../shared/src/routes/presence.ts
7738
- import { z as z11 } from "zod";
7739
- var presenceStatusSchema = z11.enum(["online", "typing"]);
7740
- var presenceLocationSchema = z11.object({
7741
- environmentId: z11.string().optional(),
7742
- workspaceId: z11.string().optional()
7792
+ import { z as z12 } from "zod";
7793
+ var presenceStatusSchema = z12.enum(["online", "typing"]);
7794
+ var presenceLocationSchema = z12.object({
7795
+ environmentId: z12.string().optional(),
7796
+ workspaceId: z12.string().optional()
7743
7797
  });
7744
- var presenceEntrySchema = z11.object({
7745
- userId: z11.string(),
7798
+ var presenceEntrySchema = z12.object({
7799
+ userId: z12.string(),
7746
7800
  status: presenceStatusSchema,
7747
7801
  location: presenceLocationSchema,
7748
- ts: z11.string()
7802
+ ts: z12.string()
7749
7803
  });
7750
- var updatePresenceRequestSchema = z11.object({
7804
+ var updatePresenceRequestSchema = z12.object({
7751
7805
  status: presenceStatusSchema,
7752
7806
  location: presenceLocationSchema.optional()
7753
7807
  });
@@ -8304,5 +8358,8 @@ export {
8304
8358
  parseChatTranscriptArtifact,
8305
8359
  readSseStream,
8306
8360
  parseFrontmatter,
8307
- isSkillRegistryManifest
8361
+ isSkillRegistryManifest,
8362
+ IDENTITY_PROXY_PORT,
8363
+ WORKSPACE_TOKEN_ENV,
8364
+ currentWorkspaceToken
8308
8365
  };
@@ -4,7 +4,7 @@ const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  HOOK_EXEC_MAX_BUFFER_BYTES,
6
6
  isVersionBelow
7
- } from "./chunk-5RULOJKJ.js";
7
+ } from "./chunk-45I2CJU6.js";
8
8
 
9
9
  // src/utils/codex-agent-env.ts
10
10
  function buildCodexAgentEnv(source = process.env) {
@@ -245,7 +245,7 @@ function getCodexModelProvider(method) {
245
245
  if (method === "foundry") return "azure";
246
246
  return method === "ollama" || method === "openai-compatible" ? "replicas_openai_compatible" : "openai";
247
247
  }
248
- var ENGINE_PACKAGE_VERSION = "0.1.887";
248
+ var ENGINE_PACKAGE_VERSION = "0.1.889";
249
249
  var INITIALIZE_METHOD = "initialize";
250
250
  var INITIALIZED_NOTIFICATION = "initialized";
251
251
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -3,7 +3,7 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  shouldRefreshPullRequests
6
- } from "./chunk-5RULOJKJ.js";
6
+ } from "./chunk-45I2CJU6.js";
7
7
 
8
8
  // src/services/post-tool-pr-notifier.ts
9
9
  async function notifyPostToolUse(toolName, toolInput) {
@@ -5,13 +5,13 @@ import {
5
5
  ENGINE_ENV,
6
6
  monolithRequest,
7
7
  setAgentCredentialSnapshot
8
- } from "./chunk-N2DC3SCQ.js";
8
+ } from "./chunk-RG6ZP2EU.js";
9
9
  import {
10
10
  AppServerProcess,
11
11
  SUBPROCESS_MAX_BUFFER,
12
12
  buildCodexAgentEnv,
13
13
  execFileAsync
14
- } from "./chunk-B7FBFPKL.js";
14
+ } from "./chunk-F33TXACU.js";
15
15
  import {
16
16
  isRecord
17
17
  } from "./chunk-UZSNFLDQ.js";
@@ -25,7 +25,7 @@ import {
25
25
  listOpenAICompatibleModels,
26
26
  readOllamaAuthEnv,
27
27
  resolveOpenAICompatibleModelsUrl
28
- } from "./chunk-5RULOJKJ.js";
28
+ } from "./chunk-45I2CJU6.js";
29
29
 
30
30
  // src/managers/codex-token-manager.ts
31
31
  import { promises as fs } from "fs";
@@ -80,6 +80,10 @@ function recordExhaustedCredential(provider, credential) {
80
80
  }
81
81
 
82
82
  // src/managers/base-refresh-manager.ts
83
+ function refreshDelayMs(expiresAtMs, maxMs = 5 * 60 * 1e3) {
84
+ const ttlMs = expiresAtMs - Date.now();
85
+ return Number.isFinite(ttlMs) ? Math.max(1e3, Math.min(maxMs, Math.floor(ttlMs * 0.8))) : maxMs;
86
+ }
83
87
  var BaseRefreshManager = class {
84
88
  constructor(managerName, intervalMs = 15 * 60 * 1e3) {
85
89
  this.managerName = managerName;
@@ -251,7 +255,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
251
255
  await this.applyCredentialUpdate(++this.credentialGeneration, async () => {
252
256
  await this.applyCredentialsResponse(data);
253
257
  if (data.scope) setAgentCredentialSnapshot("codex", { method: data.type, scope: data.scope, revision: data.revision });
254
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-BMYDTN33.js");
258
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-7TTLBO5M.js");
255
259
  await restartCodexAspHostIfRunning2();
256
260
  });
257
261
  await this.start(true);
@@ -271,7 +275,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
271
275
  await this.applyCredentialUpdate(generation, async () => {
272
276
  await this.applyCredentialsResponse(data);
273
277
  if (restartOnChange && CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index])) {
274
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-BMYDTN33.js");
278
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-7TTLBO5M.js");
275
279
  await restartCodexAspHostIfRunning2();
276
280
  }
277
281
  if (data.scope) {
@@ -512,6 +516,7 @@ export {
512
516
  listCredentialFallbacks,
513
517
  routineRefreshExclusions,
514
518
  recordExhaustedCredential,
519
+ refreshDelayMs,
515
520
  BaseRefreshManager,
516
521
  applyAuthEnvTransition,
517
522
  getCodexAspHost,
@@ -15,7 +15,7 @@ import {
15
15
  isValidRelayBaseProvider,
16
16
  parsePosixEnvFile,
17
17
  readReplicasRuntimeEnv
18
- } from "./chunk-5RULOJKJ.js";
18
+ } from "./chunk-45I2CJU6.js";
19
19
 
20
20
  // src/engine-env.ts
21
21
  import { readFileSync as readFileSync2 } from "fs";
@@ -3,12 +3,12 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  monolithRequest
6
- } from "./chunk-N2DC3SCQ.js";
6
+ } from "./chunk-RG6ZP2EU.js";
7
7
  import {
8
8
  extractCommandProtectionCommandText,
9
9
  findGitCommitSignals,
10
10
  findPrMergeSignals
11
- } from "./chunk-5RULOJKJ.js";
11
+ } from "./chunk-45I2CJU6.js";
12
12
 
13
13
  // src/services/command-protection-service.ts
14
14
  var DEFAULT_COMMAND_PROTECTION_BLOCK_MESSAGE = "Blocked by Replicas command protection.";
@@ -3,12 +3,12 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  evaluateCommandProtection
6
- } from "./chunk-P7AHODJ6.js";
7
- import "./chunk-N2DC3SCQ.js";
6
+ } from "./chunk-WMRZEQIH.js";
7
+ import "./chunk-RG6ZP2EU.js";
8
8
  import {
9
9
  isRecord
10
10
  } from "./chunk-UZSNFLDQ.js";
11
- import "./chunk-5RULOJKJ.js";
11
+ import "./chunk-45I2CJU6.js";
12
12
  import "./chunk-VEQXQN22.js";
13
13
 
14
14
  // src/command-protection-hook.ts
@@ -3,13 +3,13 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  evaluateCommandProtection
6
- } from "./chunk-P7AHODJ6.js";
6
+ } from "./chunk-WMRZEQIH.js";
7
7
  import {
8
8
  notifyPostToolUse
9
- } from "./chunk-4DGHCMBQ.js";
10
- import "./chunk-N2DC3SCQ.js";
9
+ } from "./chunk-ISNWC7OA.js";
10
+ import "./chunk-RG6ZP2EU.js";
11
11
  import "./chunk-UZSNFLDQ.js";
12
- import "./chunk-5RULOJKJ.js";
12
+ import "./chunk-45I2CJU6.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
 
15
15
  // src/deepseek-command-protection-plugin.ts
@@ -8,12 +8,12 @@ import {
8
8
  import {
9
9
  AppServerProcess,
10
10
  buildCodexAgentEnv
11
- } from "./chunk-B7FBFPKL.js";
11
+ } from "./chunk-F33TXACU.js";
12
12
  import {
13
13
  AGENT,
14
14
  getMemoryOutputSafetyViolation,
15
15
  headlessAgentRequestSchema
16
- } from "./chunk-5RULOJKJ.js";
16
+ } from "./chunk-45I2CJU6.js";
17
17
  import "./chunk-VEQXQN22.js";
18
18
 
19
19
  // src/headless-agent.ts