replicas-engine 0.1.888 → 0.1.891

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-2JFHMLKJ.js";
9
- import "./chunk-N2DC3SCQ.js";
10
- import "./chunk-ADX5FHF6.js";
8
+ } from "./chunk-TDLEF5FU.js";
9
+ import "./chunk-DG4VIQXA.js";
10
+ import "./chunk-EDLDRUYW.js";
11
11
  import "./chunk-UZSNFLDQ.js";
12
- import "./chunk-5RULOJKJ.js";
12
+ import "./chunk-OBAGPETY.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
  export {
15
15
  getCodexAspHost,
@@ -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-DG4VIQXA.js";
7
7
  import {
8
8
  extractCommandProtectionCommandText,
9
9
  findGitCommitSignals,
10
10
  findPrMergeSignals
11
- } from "./chunk-5RULOJKJ.js";
11
+ } from "./chunk-OBAGPETY.js";
12
12
 
13
13
  // src/services/command-protection-service.ts
14
14
  var DEFAULT_COMMAND_PROTECTION_BLOCK_MESSAGE = "Blocked by Replicas command protection.";
@@ -15,7 +15,7 @@ import {
15
15
  isValidRelayBaseProvider,
16
16
  parsePosixEnvFile,
17
17
  readReplicasRuntimeEnv
18
- } from "./chunk-5RULOJKJ.js";
18
+ } from "./chunk-OBAGPETY.js";
19
19
 
20
20
  // src/engine-env.ts
21
21
  import { readFileSync as readFileSync2 } from "fs";
@@ -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-OBAGPETY.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.888";
248
+ var ENGINE_PACKAGE_VERSION = "0.1.891";
249
249
  var INITIALIZE_METHOD = "initialize";
250
250
  var INITIALIZED_NOTIFICATION = "initialized";
251
251
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -1,19 +1,24 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
+ import {
5
+ publishedPullRequestUrls
6
+ } from "./chunk-U2T2QCYP.js";
4
7
  import {
5
8
  shouldRefreshPullRequests
6
- } from "./chunk-5RULOJKJ.js";
9
+ } from "./chunk-OBAGPETY.js";
7
10
 
8
11
  // src/services/post-tool-pr-notifier.ts
9
- async function notifyPostToolUse(toolName, toolInput) {
10
- if (!shouldRefreshPullRequests(toolName, toolInput)) return false;
12
+ async function notifyPostToolUse(toolName, toolInput, result) {
13
+ const publication = result ? { toolName, toolInput, ...result } : void 0;
14
+ if (!shouldRefreshPullRequests(toolName, toolInput) && (!publication || publishedPullRequestUrls(publication).length === 0)) return false;
11
15
  const port = process.env.REPLICAS_ENGINE_PORT;
12
16
  const secret = process.env.REPLICAS_ENGINE_SECRET;
13
17
  if (!port || !secret) throw new Error("Replicas engine connection is unavailable.");
14
18
  const response = await fetch(`http://127.0.0.1:${port}/pull-requests/check`, {
15
19
  method: "POST",
16
- headers: { "X-Replicas-Engine-Secret": secret },
20
+ headers: { "X-Replicas-Engine-Secret": secret, ...publication ? { "Content-Type": "application/json" } : {} },
21
+ ...publication ? { body: JSON.stringify(publication) } : {},
17
22
  signal: AbortSignal.timeout(3e4)
18
23
  });
19
24
  if (!response.ok) throw new Error(`Replicas pull request check failed (${response.status}).`);
@@ -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) {
@@ -2291,6 +2341,53 @@ var LEGACY_WEB_APP_PATHS = {
2291
2341
  home: "/home",
2292
2342
  dashboardWorkspaces: `${DASHBOARD_PATH}/workspaces`
2293
2343
  };
2344
+ var PR_URL_REGEX = /github\.com\/([^/]+)\/([^/]+)\/pull\/(\d+)/;
2345
+ function parsePrUrl(url) {
2346
+ const match = url.match(PR_URL_REGEX);
2347
+ if (!match) return null;
2348
+ const [, owner, repo, numberStr] = match;
2349
+ const number = Number.parseInt(numberStr, 10);
2350
+ if (!Number.isFinite(number)) return null;
2351
+ return { owner, repo, number };
2352
+ }
2353
+ function parseCodeHostPrUrl(url) {
2354
+ const github = parsePrUrl(url);
2355
+ if (github) {
2356
+ return {
2357
+ ...github,
2358
+ provider: "github",
2359
+ host: "github.com",
2360
+ repositoryPath: `${github.owner}/${github.repo}`,
2361
+ repoUrl: `https://github.com/${github.owner}/${github.repo}`
2362
+ };
2363
+ }
2364
+ let parsed;
2365
+ try {
2366
+ parsed = new URL(url);
2367
+ } catch {
2368
+ return null;
2369
+ }
2370
+ if (parsed.protocol !== "https:" && parsed.protocol !== "http:") return null;
2371
+ const segments = parsed.pathname.split("/").filter(Boolean);
2372
+ const separatorIndex = segments.indexOf("-");
2373
+ if (separatorIndex <= 0 || segments[separatorIndex + 1] !== "merge_requests") return null;
2374
+ const number = Number.parseInt(segments[separatorIndex + 2] ?? "", 10);
2375
+ if (!Number.isFinite(number)) return null;
2376
+ const repositorySegments = decodePathSegments(segments.slice(0, separatorIndex));
2377
+ const repo = repositorySegments[repositorySegments.length - 1];
2378
+ const owner = repositorySegments[0];
2379
+ if (!owner || !repo) return null;
2380
+ const repositoryPath = repositorySegments.join("/");
2381
+ return {
2382
+ provider: "gitlab",
2383
+ host: parsed.host.toLowerCase(),
2384
+ owner,
2385
+ repo,
2386
+ number,
2387
+ repositoryPath,
2388
+ repoUrl: `${parsed.origin}/${repositoryPath}`
2389
+ };
2390
+ }
2294
2391
  function decodePathSegments(segments) {
2295
2392
  return segments.map((segment) => {
2296
2393
  try {
@@ -2300,6 +2397,13 @@ function decodePathSegments(segments) {
2300
2397
  }
2301
2398
  });
2302
2399
  }
2400
+ function buildCodeHostPrUrl(repoUrl, provider, prNumber) {
2401
+ const normalizedRepoUrl = repoUrl.replace(/\.git$/, "");
2402
+ if (provider === "gitlab") {
2403
+ return `${normalizedRepoUrl}/-/merge_requests/${prNumber}`;
2404
+ }
2405
+ return `${normalizedRepoUrl}/pull/${prNumber}`;
2406
+ }
2303
2407
 
2304
2408
  // ../shared/src/default-skills/replicas-agent/abilities/computer.ts
2305
2409
  var SECTION = `### Computer use (Linux desktop control)
@@ -3223,32 +3327,32 @@ var MEDIA_ABILITY = {
3223
3327
  };
3224
3328
 
3225
3329
  // ../shared/src/memory.ts
3226
- import { z as z8 } from "zod";
3330
+ import { z as z9 } from "zod";
3227
3331
  var MEMORY_ROOT = `${SANDBOX_PATHS.REPLICAS_DIR}/memories`;
3228
3332
  var MEMORY_INDEX_FILENAME = "MEMORY.md";
3229
3333
  var MEMORY_BUNDLE_FILENAME = "memory.tar.gz";
3230
3334
  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()
3335
+ var memoryExtractionResultSchema = z9.object({
3336
+ seatSummary: z9.string().nullable(),
3337
+ organizationSummary: z9.string().nullable()
3234
3338
  });
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()
3339
+ var { $schema: _, ...MEMORY_EXTRACTION_SCHEMA } = z9.toJSONSchema(memoryExtractionResultSchema);
3340
+ var memoryGenerationManifestSchema = z9.object({
3341
+ domainId: z9.string(),
3342
+ generation: z9.number().int().nonnegative(),
3343
+ previousManifestKey: z9.string().nullable(),
3344
+ createdAt: z9.string(),
3345
+ promptVersion: z9.string(),
3346
+ harness: z9.enum(["claude", "codex", "none"]),
3347
+ model: z9.string(),
3348
+ bundle: z9.object({
3349
+ path: z9.literal(MEMORY_BUNDLE_FILENAME),
3350
+ sha256: z9.string().regex(/^[a-f0-9]{64}$/),
3351
+ sizeBytes: z9.number().int().positive()
3248
3352
  }).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()
3353
+ files: z9.record(z9.string(), z9.string()),
3354
+ rollouts: z9.record(z9.string(), z9.string()),
3355
+ rolloutSources: z9.record(z9.string(), z9.string()).optional()
3252
3356
  });
3253
3357
 
3254
3358
  // ../shared/src/default-skills/replicas-agent/abilities/memory.ts
@@ -3615,6 +3719,10 @@ In agent mode the CLI hides commands that don't make sense for in-workspace agen
3615
3719
  | Command | What it does |
3616
3720
  | --- | --- |
3617
3721
  | \`replicas whoami\` | Print the workspace + org identity |
3722
+ | \`replicas identity token [--audience <aud>]\` | Print the current short-lived workspace identity token for an audience |
3723
+ | \`replicas identity token --format gcp --audience <aud>\` | Supply a current token to Google's executable credential source |
3724
+ | \`replicas identity aws-credentials --role-arn <arn> [--region <region>]\` | Exchange the current token for AWS credential_process JSON (requires AWS CLI) |
3725
+ | \`replicas identity exec [--audience <aud>] -- <command>\` | Run a command with the current token and audience in its environment |
3618
3726
  | \`replicas init\` | Create a \`replicas.json\` / \`replicas.yaml\` in the current directory |
3619
3727
  | \`replicas connect <name>\` | SSH into another workspace (requires user creds \u2014 usually only useful when scripting locally) |
3620
3728
  | \`replicas repos\` | List repos connected to the org |
@@ -7342,38 +7450,38 @@ function shouldRefreshPullRequests(toolName, toolInput) {
7342
7450
  }
7343
7451
 
7344
7452
  // ../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()
7453
+ import { z as z10 } from "zod";
7454
+ var linearSessionMetadataSchema = z10.object({
7455
+ via_mothership: z10.boolean().optional(),
7456
+ issue_id: z10.string(),
7457
+ issue_identifier: z10.string(),
7458
+ issue_title: z10.string(),
7459
+ issue_description: z10.string(),
7460
+ issue_url: z10.string(),
7461
+ comment_id: z10.string(),
7462
+ comment_body: z10.string(),
7463
+ triggered_by_id: z10.string().optional(),
7464
+ triggered_by_name: z10.string().optional(),
7465
+ triggered_by_email: z10.string().optional(),
7466
+ linear_workspace_id: z10.string().optional(),
7467
+ creator_id: z10.string().optional(),
7468
+ creator_name: z10.string().optional(),
7469
+ creator_email: z10.string().optional(),
7470
+ assignee_id: z10.string().optional(),
7471
+ assignee_name: z10.string().optional(),
7472
+ assignee_email: z10.string().optional(),
7473
+ issue_state: z10.string().optional(),
7474
+ parent_issue: z10.object({
7475
+ id: z10.string(),
7476
+ identifier: z10.string(),
7477
+ title: z10.string(),
7478
+ description: z10.string().nullable()
7371
7479
  }).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()
7480
+ workspace: z10.object({
7481
+ id: z10.string(),
7482
+ coding_agent: z10.custom((value) => typeof value === "string" && isValidAgentProvider(value)),
7483
+ task_description: z10.string(),
7484
+ created_at: z10.string()
7377
7485
  }).optional()
7378
7486
  });
7379
7487
 
@@ -7708,46 +7816,46 @@ var DEFAULT_WORKSPACE_FILTERS = {
7708
7816
  var ONE_DAY_MS = 24 * 60 * 60 * 1e3;
7709
7817
 
7710
7818
  // ../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()
7819
+ import { z as z11 } from "zod";
7820
+ var workspaceChangedEventSchema = z11.discriminatedUnion("type", [
7821
+ z11.object({
7822
+ type: z11.literal("workspace.changed"),
7823
+ workspaceId: z11.string(),
7824
+ completion: z11.object({
7825
+ workspaceName: z11.string(),
7826
+ completedAt: z11.string(),
7827
+ processing: z11.boolean().optional()
7720
7828
  }).optional(),
7721
- ts: z10.string()
7829
+ ts: z11.string()
7722
7830
  }),
7723
- z10.object({
7724
- type: z10.literal("workspace.chat.changed"),
7725
- workspaceId: z10.string(),
7726
- chatId: z10.string(),
7727
- ts: z10.string()
7831
+ z11.object({
7832
+ type: z11.literal("workspace.chat.changed"),
7833
+ workspaceId: z11.string(),
7834
+ chatId: z11.string(),
7835
+ ts: z11.string()
7728
7836
  }),
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()
7837
+ z11.object({ type: z11.literal("presence.changed"), ts: z11.string() }),
7838
+ z11.object({
7839
+ type: z11.literal("mobile-testing.changed"),
7840
+ workspaceId: z11.string(),
7841
+ ts: z11.string()
7734
7842
  })
7735
7843
  ]);
7736
7844
 
7737
7845
  // ../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()
7846
+ import { z as z12 } from "zod";
7847
+ var presenceStatusSchema = z12.enum(["online", "typing"]);
7848
+ var presenceLocationSchema = z12.object({
7849
+ environmentId: z12.string().optional(),
7850
+ workspaceId: z12.string().optional()
7743
7851
  });
7744
- var presenceEntrySchema = z11.object({
7745
- userId: z11.string(),
7852
+ var presenceEntrySchema = z12.object({
7853
+ userId: z12.string(),
7746
7854
  status: presenceStatusSchema,
7747
7855
  location: presenceLocationSchema,
7748
- ts: z11.string()
7856
+ ts: z12.string()
7749
7857
  });
7750
- var updatePresenceRequestSchema = z11.object({
7858
+ var updatePresenceRequestSchema = z12.object({
7751
7859
  status: presenceStatusSchema,
7752
7860
  location: presenceLocationSchema.optional()
7753
7861
  });
@@ -8209,7 +8317,9 @@ export {
8209
8317
  paginateChatHistory,
8210
8318
  coerceBackgroundTaskPayload,
8211
8319
  isGitHubUrl,
8320
+ parseCodeHostPrUrl,
8212
8321
  decodePathSegments,
8322
+ buildCodeHostPrUrl,
8213
8323
  SANDBOX_PATHS,
8214
8324
  MEMORY_ROOT,
8215
8325
  MEMORY_INDEX_FILENAME,
@@ -8304,5 +8414,8 @@ export {
8304
8414
  parseChatTranscriptArtifact,
8305
8415
  readSseStream,
8306
8416
  parseFrontmatter,
8307
- isSkillRegistryManifest
8417
+ isSkillRegistryManifest,
8418
+ IDENTITY_PROXY_PORT,
8419
+ WORKSPACE_TOKEN_ENV,
8420
+ currentWorkspaceToken
8308
8421
  };
@@ -5,13 +5,13 @@ import {
5
5
  ENGINE_ENV,
6
6
  monolithRequest,
7
7
  setAgentCredentialSnapshot
8
- } from "./chunk-N2DC3SCQ.js";
8
+ } from "./chunk-DG4VIQXA.js";
9
9
  import {
10
10
  AppServerProcess,
11
11
  SUBPROCESS_MAX_BUFFER,
12
12
  buildCodexAgentEnv,
13
13
  execFileAsync
14
- } from "./chunk-ADX5FHF6.js";
14
+ } from "./chunk-EDLDRUYW.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-OBAGPETY.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-BGOXGPHG.js");
258
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-RKLHLTPR.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-BGOXGPHG.js");
278
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-RKLHLTPR.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,