replicas-engine 0.1.1393 → 0.1.1394

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.
@@ -8,12 +8,12 @@ import {
8
8
  listRunningCodexModels,
9
9
  restartCodexAspHost,
10
10
  restartCodexAspHostIfRunning
11
- } from "./chunk-GNWA725S.js";
12
- import "./chunk-JXEKJXH7.js";
13
- import "./chunk-BIUGCLX3.js";
14
- import "./chunk-INAQRTYM.js";
11
+ } from "./chunk-JLSCYTGB.js";
12
+ import "./chunk-KZ4OLD3N.js";
13
+ import "./chunk-AOLTWJRQ.js";
14
+ import "./chunk-NZS7CK2A.js";
15
15
  import "./chunk-UZSNFLDQ.js";
16
- import "./chunk-CKRLVTRB.js";
16
+ import "./chunk-5VOV6MCE.js";
17
17
  import "./chunk-VEQXQN22.js";
18
18
  export {
19
19
  CODEX_ULTRAFAST_SERVICE_TIER,
@@ -11203,44 +11203,88 @@ var engineMcpOAuthTokenResponseSchema = z6.object({
11203
11203
  expires_at: z6.string().nullable()
11204
11204
  });
11205
11205
 
11206
+ // ../shared/src/routes/environment.ts
11207
+ import { z as z7 } from "zod";
11208
+ var ENVIRONMENT_MCP_TRANSPORTS = ["stdio", "http", "sse"];
11209
+ var stringMap = z7.record(z7.string(), z7.string());
11210
+ var createEnvironmentMcpRequestSchema = z7.object({
11211
+ name: z7.string(),
11212
+ transport: z7.enum(ENVIRONMENT_MCP_TRANSPORTS),
11213
+ config: z7.union([
11214
+ z7.object({ command: z7.string().min(1), args: z7.array(z7.string()).optional(), env: stringMap.optional() }),
11215
+ z7.object({ url: z7.url(), headers: stringMap.optional(), auth: mcpAuthSchema.optional() })
11216
+ ]).describe("stdio: `{ command, args, env }`. http/sse: `{ url, headers }`.")
11217
+ });
11218
+ var updateEnvironmentMcpRequestSchema = createEnvironmentMcpRequestSchema.partial();
11219
+ var screenPasswordSchema = z7.string().min(1, "Enter the screen password").max(256).describe('Screen Sharing password, for `replicas computer screen`. On a Mac, the "VNC viewers may control screen with password" password. Never returned.');
11220
+ var hostSchema = z7.string().max(253).regex(/^(?:[A-Za-z0-9](?:[A-Za-z0-9.-]*[A-Za-z0-9])?|[0-9A-Fa-f:]+)$/, "Enter a hostname or IP address");
11221
+ var createEnvironmentDeviceRequestSchema = z7.object({
11222
+ name: z7.string().regex(/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/, "Use lowercase letters, numbers and dashes").describe("SSH alias in workspaces, e.g. `mac-mini` for `ssh mac-mini`."),
11223
+ host: hostSchema.optional().describe("Hostname or IP, such as a Tailscale MagicDNS name (`mac-mini`) or a public address. Leave it out when the device connects to Replicas itself with `replicas device connect`."),
11224
+ port: z7.number().int().min(1).max(65535).optional().describe("SSH port on the device. Defaults to 22."),
11225
+ username: z7.string().regex(/^[A-Za-z0-9_][A-Za-z0-9._-]{0,63}$/, "Enter the account name on the device").describe("Account the agent signs in as."),
11226
+ screen_password: screenPasswordSchema.optional()
11227
+ });
11228
+ var updateEnvironmentDeviceRequestSchema = createEnvironmentDeviceRequestSchema.partial().extend({
11229
+ host: z7.union([hostSchema, z7.literal("")]).optional().describe("New hostname or IP, or an empty string for a device that connects to Replicas itself."),
11230
+ screen_password: z7.union([screenPasswordSchema, z7.literal("")]).optional().describe("New Screen Sharing password, or an empty string to remove it.")
11231
+ });
11232
+ var deviceConnectionResponseSchema = z7.object({
11233
+ name: z7.string(),
11234
+ port: z7.number(),
11235
+ workspace_ids: z7.array(z7.string())
11236
+ });
11237
+ var deviceHostKeysRequestSchema = z7.object({
11238
+ host_keys: z7.array(z7.string().max(2048).regex(/^[a-z0-9@.-]+ [A-Za-z0-9+/]+={0,3}$/, "Each host key must be `<type> <base64>`")).min(1).max(8).transform((keys) => [...new Set(keys)].sort())
11239
+ });
11240
+ var DEVICE_HOST_KEYS_HEADER = "x-replicas-device-host-keys";
11241
+ var provisionedDeviceSchema = z7.object({
11242
+ name: z7.string(),
11243
+ host: z7.string().nullable(),
11244
+ port: z7.number(),
11245
+ username: z7.string(),
11246
+ private_key: z7.string(),
11247
+ screen_password: z7.string().optional()
11248
+ });
11249
+
11206
11250
  // ../shared/src/routes/mothership.ts
11207
- import { z as z8 } from "zod";
11251
+ import { z as z9 } from "zod";
11208
11252
 
11209
11253
  // ../shared/src/routes/pull-requests.ts
11210
- import { z as z7 } from "zod";
11254
+ import { z as z8 } from "zod";
11211
11255
  var PULL_REQUEST_MERGE_METHODS = ["merge", "squash", "rebase"];
11212
11256
  var DEPLOY_START_WINDOW_MS = 30 * 6e4;
11213
- var mergePullRequestRequestSchema = z7.object({
11214
- mergeMethod: z7.enum(PULL_REQUEST_MERGE_METHODS).optional(),
11215
- bypassRules: z7.boolean().optional()
11257
+ var mergePullRequestRequestSchema = z8.object({
11258
+ mergeMethod: z8.enum(PULL_REQUEST_MERGE_METHODS).optional(),
11259
+ bypassRules: z8.boolean().optional()
11216
11260
  });
11217
11261
 
11218
11262
  // ../shared/src/routes/mothership.ts
11219
- var linearRuleFields = z8.object({
11220
- team_id: z8.string().min(1),
11221
- current_cycle: z8.boolean().optional(),
11222
- label_ids: z8.array(z8.string().min(1)).min(1).optional(),
11223
- project_id: z8.string().min(1).optional(),
11224
- assignee_id: z8.string().min(1).optional()
11263
+ var linearRuleFields = z9.object({
11264
+ team_id: z9.string().min(1),
11265
+ current_cycle: z9.boolean().optional(),
11266
+ label_ids: z9.array(z9.string().min(1)).min(1).optional(),
11267
+ project_id: z9.string().min(1).optional(),
11268
+ assignee_id: z9.string().min(1).optional()
11225
11269
  }).strict();
11226
11270
  var withLabelIds = (value) => {
11227
11271
  if (!isRecord(value) || typeof value.label_id !== "string") return value;
11228
11272
  const { label_id, ...rest } = value;
11229
11273
  return { ...rest, label_ids: [label_id] };
11230
11274
  };
11231
- var mothershipLinearRuleSchema = z8.preprocess(withLabelIds, linearRuleFields);
11232
- var storedMothershipLinearRuleSchema = z8.preprocess(withLabelIds, linearRuleFields.extend({ linked_at: z8.string() }));
11275
+ var mothershipLinearRuleSchema = z9.preprocess(withLabelIds, linearRuleFields);
11276
+ var storedMothershipLinearRuleSchema = z9.preprocess(withLabelIds, linearRuleFields.extend({ linked_at: z9.string() }));
11233
11277
  var SUBAGENT_SERVICE_TIERS = ["default", "fast", "ultrafast"];
11234
11278
  function serviceTierRequestFields(tier) {
11235
11279
  return { fastMode: tier !== "default", ...tier === "ultrafast" ? { ultrafastMode: true } : {} };
11236
11280
  }
11237
- var mothershipSubagentSettingsSchema = z8.object({
11238
- coding_agent: z8.enum(VALID_AGENT_PROVIDERS),
11239
- model: z8.string().nullable(),
11240
- thinking_level: z8.enum(VALID_THINKING_LEVELS).nullable(),
11241
- service_tier: z8.enum(SUBAGENT_SERVICE_TIERS),
11242
- goal_mode: z8.boolean(),
11243
- plan_mode: z8.boolean()
11281
+ var mothershipSubagentSettingsSchema = z9.object({
11282
+ coding_agent: z9.enum(VALID_AGENT_PROVIDERS),
11283
+ model: z9.string().nullable(),
11284
+ thinking_level: z9.enum(VALID_THINKING_LEVELS).nullable(),
11285
+ service_tier: z9.enum(SUBAGENT_SERVICE_TIERS),
11286
+ goal_mode: z9.boolean(),
11287
+ plan_mode: z9.boolean()
11244
11288
  });
11245
11289
  var QUEUE_SECTIONS = [
11246
11290
  { label: "Open PRs", groups: ["needs_you", "ready_to_merge", "ready_to_review"] },
@@ -11469,19 +11513,19 @@ function gitIdentityConfigCommands(identity, scope = "global") {
11469
11513
  }
11470
11514
 
11471
11515
  // ../shared/src/headless-agent.ts
11472
- import { z as z9 } from "zod";
11473
- var headlessAgentRequestSchema = z9.object({
11474
- mode: z9.literal("structured"),
11475
- agent: z9.custom(
11516
+ import { z as z10 } from "zod";
11517
+ var headlessAgentRequestSchema = z10.object({
11518
+ mode: z10.literal("structured"),
11519
+ agent: z10.custom(
11476
11520
  (value) => typeof value === "string" && isValidAgentProvider(value)
11477
11521
  ),
11478
- model: z9.string().min(1),
11479
- prompt: z9.string(),
11480
- workingDirectory: z9.string().min(1),
11481
- timeoutSeconds: z9.number().int().min(1).max(1800).default(300),
11482
- thinkingLevel: z9.enum(STANDARD_THINKING_LEVELS).optional(),
11483
- codexOauthTokens: z9.object({ accessToken: z9.string(), accountId: z9.string() }).optional(),
11484
- outputSchema: z9.record(z9.string(), z9.json())
11522
+ model: z10.string().min(1),
11523
+ prompt: z10.string(),
11524
+ workingDirectory: z10.string().min(1),
11525
+ timeoutSeconds: z10.number().int().min(1).max(1800).default(300),
11526
+ thinkingLevel: z10.enum(STANDARD_THINKING_LEVELS).optional(),
11527
+ codexOauthTokens: z10.object({ accessToken: z10.string(), accountId: z10.string() }).optional(),
11528
+ outputSchema: z10.record(z10.string(), z10.json())
11485
11529
  });
11486
11530
  var headlessAgentUsagePath = (outputPath) => `${outputPath}.usage`;
11487
11531
 
@@ -11560,12 +11604,12 @@ function describeAuthFallback(payload) {
11560
11604
  }
11561
11605
 
11562
11606
  // ../shared/src/workspace-credentials.ts
11563
- import { z as z10 } from "zod";
11607
+ import { z as z11 } from "zod";
11564
11608
  var WORKSPACE_CREDENTIAL_PROVIDERS = ["claude", "codex"];
11565
- var workspaceCredentialProviderSchema = z10.enum(WORKSPACE_CREDENTIAL_PROVIDERS);
11609
+ var workspaceCredentialProviderSchema = z11.enum(WORKSPACE_CREDENTIAL_PROVIDERS);
11566
11610
  var workspaceCredentialSelectionSchema = agentCredentialSnapshotSchema.omit({ revision: true, account: true, credentialId: true });
11567
11611
  var createWorkspaceCredentialSchema = workspaceCredentialSelectionSchema.extend({
11568
- provider: z10.enum(VALID_AGENT_PROVIDERS)
11612
+ provider: z11.enum(VALID_AGENT_PROVIDERS)
11569
11613
  }).refine(({ provider: provider2, method }) => agentCredentialMethods(provider2).includes(method), {
11570
11614
  message: "This inference provider is not supported by this agent"
11571
11615
  });
@@ -11576,62 +11620,62 @@ var switchWorkspaceCredentialSchema = workspaceCredentialSelectionSchema.extend(
11576
11620
  });
11577
11621
 
11578
11622
  // ../shared/src/chat-fork.ts
11579
- import { z as z12 } from "zod";
11623
+ import { z as z13 } from "zod";
11580
11624
 
11581
11625
  // ../shared/src/fallback-chains.ts
11582
- import { z as z11 } from "zod";
11583
- var fallbackHarnessStepSchema = z11.object({
11584
- kind: z11.literal("harness"),
11585
- provider: z11.enum(VALID_AGENT_PROVIDERS),
11586
- model: z11.string().min(1),
11587
- thinkingLevel: z11.enum(VALID_THINKING_LEVELS).optional().catch(void 0)
11626
+ import { z as z12 } from "zod";
11627
+ var fallbackHarnessStepSchema = z12.object({
11628
+ kind: z12.literal("harness"),
11629
+ provider: z12.enum(VALID_AGENT_PROVIDERS),
11630
+ model: z12.string().min(1),
11631
+ thinkingLevel: z12.enum(VALID_THINKING_LEVELS).optional().catch(void 0)
11588
11632
  });
11589
- var fallbackPlanStepSchema = z11.discriminatedUnion("kind", [
11590
- z11.object({
11591
- kind: z11.literal("credentials"),
11633
+ var fallbackPlanStepSchema = z12.discriminatedUnion("kind", [
11634
+ z12.object({
11635
+ kind: z12.literal("credentials"),
11592
11636
  // An empty list would allow every method.
11593
- methods: z11.array(z11.unknown()).transform((methods) => methods.filter(isAuthMethod)).refine((methods) => methods.length > 0),
11594
- models: z11.record(z11.string(), z11.string().min(1)).optional()
11637
+ methods: z12.array(z12.unknown()).transform((methods) => methods.filter(isAuthMethod)).refine((methods) => methods.length > 0),
11638
+ models: z12.record(z12.string(), z12.string().min(1)).optional()
11595
11639
  }),
11596
11640
  fallbackHarnessStepSchema
11597
11641
  ]);
11598
- var fallbackPlanResponseSchema = z11.object({
11599
- steps: z11.array(z11.unknown()).transform((steps) => steps.flatMap((step) => fallbackPlanStepSchema.safeParse(step).data ?? []))
11642
+ var fallbackPlanResponseSchema = z12.object({
11643
+ steps: z12.array(z12.unknown()).transform((steps) => steps.flatMap((step) => fallbackPlanStepSchema.safeParse(step).data ?? []))
11600
11644
  });
11601
11645
 
11602
11646
  // ../shared/src/chat-fork.ts
11603
- var fallbackReasonSchema = z12.enum(AGENT_FALLBACK_REASONS);
11604
- var chatForkInfoSchema = z12.object({
11605
- source: z12.object({
11606
- chatId: z12.string().min(1),
11607
- provider: z12.enum(VALID_AGENT_PROVIDERS),
11608
- title: z12.string()
11647
+ var fallbackReasonSchema = z13.enum(AGENT_FALLBACK_REASONS);
11648
+ var chatForkInfoSchema = z13.object({
11649
+ source: z13.object({
11650
+ chatId: z13.string().min(1),
11651
+ provider: z13.enum(VALID_AGENT_PROVIDERS),
11652
+ title: z13.string()
11609
11653
  }),
11610
- trigger: z12.enum(["manual", "auto", "side", "switch"]),
11654
+ trigger: z13.enum(["manual", "auto", "side", "switch"]),
11611
11655
  reason: fallbackReasonSchema.optional(),
11612
- state: z12.enum(["preparing", "ready", "failed"]),
11613
- error: z12.string().optional(),
11614
- startedAt: z12.string(),
11615
- completedAt: z12.string().optional()
11656
+ state: z13.enum(["preparing", "ready", "failed"]),
11657
+ error: z13.string().optional(),
11658
+ startedAt: z13.string(),
11659
+ completedAt: z13.string().optional()
11616
11660
  });
11617
11661
  function coerceChatForkInfo(value) {
11618
11662
  const parsed = chatForkInfoSchema.safeParse(value);
11619
11663
  return parsed.success ? parsed.data : null;
11620
11664
  }
11621
- var forkChatRequestSchema = z12.object({
11622
- provider: z12.enum(VALID_AGENT_PROVIDERS),
11623
- model: z12.string().min(1).optional(),
11624
- thinkingLevel: z12.enum(VALID_THINKING_LEVELS).optional(),
11625
- title: z12.string().min(1).max(200).optional(),
11626
- message: z12.string().trim().optional(),
11627
- id: z12.string().uuid().optional(),
11628
- clientRequestId: z12.string().min(1).max(128).optional(),
11629
- enableInteractiveTools: z12.boolean().optional(),
11665
+ var forkChatRequestSchema = z13.object({
11666
+ provider: z13.enum(VALID_AGENT_PROVIDERS),
11667
+ model: z13.string().min(1).optional(),
11668
+ thinkingLevel: z13.enum(VALID_THINKING_LEVELS).optional(),
11669
+ title: z13.string().min(1).max(200).optional(),
11670
+ message: z13.string().trim().optional(),
11671
+ id: z13.string().uuid().optional(),
11672
+ clientRequestId: z13.string().min(1).max(128).optional(),
11673
+ enableInteractiveTools: z13.boolean().optional(),
11630
11674
  // Server-injected by the monolith from the authenticated request; never trusted from clients.
11631
- senderUserId: z12.string().optional(),
11632
- senderEmail: z12.string().optional(),
11633
- senderDisplayName: z12.string().optional(),
11634
- senderAvatarUrl: z12.string().optional()
11675
+ senderUserId: z13.string().optional(),
11676
+ senderEmail: z13.string().optional(),
11677
+ senderDisplayName: z13.string().optional(),
11678
+ senderAvatarUrl: z13.string().optional()
11635
11679
  });
11636
11680
  function describeQuotaLimit(reason) {
11637
11681
  if (reason === "auth_failed") return "could not authenticate";
@@ -11643,10 +11687,10 @@ function describeChatForkReason(reason, provider2) {
11643
11687
  return reason ? `${getProviderDisplayName(provider2)} ${describeQuotaLimit(reason)}` : null;
11644
11688
  }
11645
11689
  var AGENT_QUOTA_EXHAUSTED_EVENT_TYPE = "agent-quota-exhausted";
11646
- var agentQuotaExhaustedPayloadSchema = z12.object({
11647
- provider: z12.enum(VALID_AGENT_PROVIDERS),
11690
+ var agentQuotaExhaustedPayloadSchema = z13.object({
11691
+ provider: z13.enum(VALID_AGENT_PROVIDERS),
11648
11692
  reason: fallbackReasonSchema,
11649
- detail: z12.string().optional(),
11693
+ detail: z13.string().optional(),
11650
11694
  forkTo: fallbackHarnessStepSchema.optional()
11651
11695
  });
11652
11696
  function defaultForkChatTitle(source, provider2) {
@@ -11678,17 +11722,17 @@ function getChatThreadSources(chats, chat) {
11678
11722
  }
11679
11723
 
11680
11724
  // ../shared/src/credential-refresh.ts
11681
- import { z as z13 } from "zod";
11682
- var engineCredentialRefreshFailureSchema = z13.object({
11683
- code: z13.string(),
11725
+ import { z as z14 } from "zod";
11726
+ var engineCredentialRefreshFailureSchema = z14.object({
11727
+ code: z14.string(),
11684
11728
  credential: workspaceCredentialSelectionSchema.optional()
11685
11729
  });
11686
11730
 
11687
11731
  // ../shared/src/credential-pool.ts
11688
- import { z as z14 } from "zod";
11732
+ import { z as z15 } from "zod";
11689
11733
  var MAX_CREDENTIAL_POOL_ACCOUNTS = 10;
11690
- var reorderCredentialPoolSchema = z14.object({
11691
- credential_ids: z14.array(z14.string().uuid()).min(1).max(MAX_CREDENTIAL_POOL_ACCOUNTS)
11734
+ var reorderCredentialPoolSchema = z15.object({
11735
+ credential_ids: z15.array(z15.string().uuid()).min(1).max(MAX_CREDENTIAL_POOL_ACCOUNTS)
11692
11736
  });
11693
11737
 
11694
11738
  // ../shared/src/mothership-events.ts
@@ -11698,39 +11742,39 @@ import { z as z23 } from "zod";
11698
11742
  import { z as z19 } from "zod";
11699
11743
 
11700
11744
  // ../shared/src/routes/linear.ts
11701
- import { z as z15 } from "zod";
11702
- var linearSessionMetadataSchema = z15.object({
11703
- via_mothership: z15.boolean().optional(),
11704
- attached: z15.boolean().optional(),
11705
- issue_id: z15.string(),
11706
- issue_identifier: z15.string(),
11707
- issue_title: z15.string(),
11708
- issue_description: z15.string(),
11709
- issue_url: z15.string(),
11710
- comment_id: z15.string(),
11711
- comment_body: z15.string(),
11712
- triggered_by_id: z15.string().optional(),
11713
- triggered_by_name: z15.string().optional(),
11714
- triggered_by_email: z15.string().optional(),
11715
- linear_workspace_id: z15.string().optional(),
11716
- creator_id: z15.string().optional(),
11717
- creator_name: z15.string().optional(),
11718
- creator_email: z15.string().optional(),
11719
- assignee_id: z15.string().optional(),
11720
- assignee_name: z15.string().optional(),
11721
- assignee_email: z15.string().optional(),
11722
- issue_state: z15.string().optional(),
11723
- parent_issue: z15.object({
11724
- id: z15.string(),
11725
- identifier: z15.string(),
11726
- title: z15.string(),
11727
- description: z15.string().nullable()
11745
+ import { z as z16 } from "zod";
11746
+ var linearSessionMetadataSchema = z16.object({
11747
+ via_mothership: z16.boolean().optional(),
11748
+ attached: z16.boolean().optional(),
11749
+ issue_id: z16.string(),
11750
+ issue_identifier: z16.string(),
11751
+ issue_title: z16.string(),
11752
+ issue_description: z16.string(),
11753
+ issue_url: z16.string(),
11754
+ comment_id: z16.string(),
11755
+ comment_body: z16.string(),
11756
+ triggered_by_id: z16.string().optional(),
11757
+ triggered_by_name: z16.string().optional(),
11758
+ triggered_by_email: z16.string().optional(),
11759
+ linear_workspace_id: z16.string().optional(),
11760
+ creator_id: z16.string().optional(),
11761
+ creator_name: z16.string().optional(),
11762
+ creator_email: z16.string().optional(),
11763
+ assignee_id: z16.string().optional(),
11764
+ assignee_name: z16.string().optional(),
11765
+ assignee_email: z16.string().optional(),
11766
+ issue_state: z16.string().optional(),
11767
+ parent_issue: z16.object({
11768
+ id: z16.string(),
11769
+ identifier: z16.string(),
11770
+ title: z16.string(),
11771
+ description: z16.string().nullable()
11728
11772
  }).optional(),
11729
- workspace: z15.object({
11730
- id: z15.string(),
11731
- coding_agent: z15.custom((value) => typeof value === "string" && isValidAgentProvider(value)),
11732
- task_description: z15.string(),
11733
- created_at: z15.string()
11773
+ workspace: z16.object({
11774
+ id: z16.string(),
11775
+ coding_agent: z16.custom((value) => typeof value === "string" && isValidAgentProvider(value)),
11776
+ task_description: z16.string(),
11777
+ created_at: z16.string()
11734
11778
  }).optional()
11735
11779
  });
11736
11780
  var LINEAR_WORKFLOW_STATE_TYPES = ["triage", "backlog", "unstarted", "started", "completed", "canceled", "duplicate"];
@@ -11740,7 +11784,7 @@ var LINEAR_ISSUE_STATE_CHANGED_EVENT = "issue.state_changed";
11740
11784
  var LINEAR_STATE_TYPES = LINEAR_WORKFLOW_STATE_TYPES.filter((type) => type !== "duplicate");
11741
11785
 
11742
11786
  // ../shared/src/automations/trigger-schemas.ts
11743
- import { z as z16 } from "zod";
11787
+ import { z as z17 } from "zod";
11744
11788
 
11745
11789
  // ../shared/src/uuid.ts
11746
11790
  function createUuidFromHex(value) {
@@ -11757,31 +11801,31 @@ function getReviewerLoginsError(event, logins) {
11757
11801
  if (isReviewRequested === !!logins?.some((login) => login.trim().replace(/^@+/, ""))) return null;
11758
11802
  return isReviewRequested ? "The PR review requested trigger needs at least one GitHub username" : "Requested reviewers only apply to the PR review requested trigger";
11759
11803
  }
11760
- var repositoryTriggerConfigSchema = z16.object({
11761
- event: z16.string(),
11762
- repository_ids: z16.array(z16.string().regex(UUID_RE, "must be a repository id")).optional(),
11763
- group_pr_events: z16.boolean().optional(),
11764
- excluded_actors: z16.array(z16.string()).optional(),
11765
- reviewer_logins: z16.array(z16.string()).optional()
11804
+ var repositoryTriggerConfigSchema = z17.object({
11805
+ event: z17.string(),
11806
+ repository_ids: z17.array(z17.string().regex(UUID_RE, "must be a repository id")).optional(),
11807
+ group_pr_events: z17.boolean().optional(),
11808
+ excluded_actors: z17.array(z17.string()).optional(),
11809
+ reviewer_logins: z17.array(z17.string()).optional()
11766
11810
  });
11767
- var cronTriggerSchema = z16.object({ type: z16.literal("cron"), config: z16.object({ schedule: z16.string(), timezone: z16.string().optional() }) });
11768
- var githubTriggerSchema = z16.object({
11769
- type: z16.literal("github"),
11811
+ var cronTriggerSchema = z17.object({ type: z17.literal("cron"), config: z17.object({ schedule: z17.string(), timezone: z17.string().optional() }) });
11812
+ var githubTriggerSchema = z17.object({
11813
+ type: z17.literal("github"),
11770
11814
  config: repositoryTriggerConfigSchema.superRefine((config, ctx) => {
11771
11815
  const message2 = getReviewerLoginsError(config.event, config.reviewer_logins);
11772
11816
  if (message2) ctx.addIssue({ code: "custom", message: message2, path: ["reviewer_logins"] });
11773
11817
  })
11774
11818
  });
11775
- var gitlabTriggerSchema = z16.object({ type: z16.literal("gitlab"), config: repositoryTriggerConfigSchema });
11776
- var linearTriggerConfigSchema = z16.object({ event: z16.string(), team_ids: z16.array(z16.string()).optional(), state_types: z16.array(z16.enum(LINEAR_STATE_TYPES)).optional() });
11777
- var automationTriggerSchema = z16.discriminatedUnion("type", [
11819
+ var gitlabTriggerSchema = z17.object({ type: z17.literal("gitlab"), config: repositoryTriggerConfigSchema });
11820
+ var linearTriggerConfigSchema = z17.object({ event: z17.string(), team_ids: z17.array(z17.string()).optional(), state_types: z17.array(z17.enum(LINEAR_STATE_TYPES)).optional() });
11821
+ var automationTriggerSchema = z17.discriminatedUnion("type", [
11778
11822
  cronTriggerSchema,
11779
11823
  githubTriggerSchema,
11780
11824
  gitlabTriggerSchema,
11781
- z16.object({ type: z16.literal("slack"), config: z16.object({ event: z16.string(), channel_ids: z16.array(z16.string()).optional(), group_thread_replies: z16.boolean().optional() }) }),
11782
- z16.object({ type: z16.literal("sentry"), config: z16.object({ event: z16.string(), project_slugs: z16.array(z16.string()).optional(), min_level: z16.string().optional() }) }),
11783
- z16.object({ type: z16.literal("linear"), config: linearTriggerConfigSchema }),
11784
- z16.object({ type: z16.literal("custom"), config: z16.object({}) })
11825
+ z17.object({ type: z17.literal("slack"), config: z17.object({ event: z17.string(), channel_ids: z17.array(z17.string()).optional(), group_thread_replies: z17.boolean().optional() }) }),
11826
+ z17.object({ type: z17.literal("sentry"), config: z17.object({ event: z17.string(), project_slugs: z17.array(z17.string()).optional(), min_level: z17.string().optional() }) }),
11827
+ z17.object({ type: z17.literal("linear"), config: linearTriggerConfigSchema }),
11828
+ z17.object({ type: z17.literal("custom"), config: z17.object({}) })
11785
11829
  ]);
11786
11830
 
11787
11831
  // ../shared/src/automations/types.ts
@@ -11790,39 +11834,6 @@ var AUTOMATION_LIFECYCLE_POLICIES = ["default", "archive_when_done", "sleep_when
11790
11834
  var AUTOMATION_AUTO_PAUSE_DAYS = 7;
11791
11835
  var AUTOMATION_AUTO_PAUSE_LABEL = `Paused after failing every run for ${AUTOMATION_AUTO_PAUSE_DAYS} days`;
11792
11836
 
11793
- // ../shared/src/routes/environment.ts
11794
- import { z as z17 } from "zod";
11795
- var ENVIRONMENT_MCP_TRANSPORTS = ["stdio", "http", "sse"];
11796
- var stringMap = z17.record(z17.string(), z17.string());
11797
- var createEnvironmentMcpRequestSchema = z17.object({
11798
- name: z17.string(),
11799
- transport: z17.enum(ENVIRONMENT_MCP_TRANSPORTS),
11800
- config: z17.union([
11801
- z17.object({ command: z17.string().min(1), args: z17.array(z17.string()).optional(), env: stringMap.optional() }),
11802
- z17.object({ url: z17.url(), headers: stringMap.optional(), auth: mcpAuthSchema.optional() })
11803
- ]).describe("stdio: `{ command, args, env }`. http/sse: `{ url, headers }`.")
11804
- });
11805
- var updateEnvironmentMcpRequestSchema = createEnvironmentMcpRequestSchema.partial();
11806
- var screenPasswordSchema = z17.string().min(1, "Enter the screen password").max(256).describe('Screen Sharing password, for `replicas computer screen`. On a Mac, the "VNC viewers may control screen with password" password. Never returned.');
11807
- var createEnvironmentDeviceRequestSchema = z17.object({
11808
- name: z17.string().regex(/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/, "Use lowercase letters, numbers and dashes").describe("SSH alias in workspaces, e.g. `mac-mini` for `ssh mac-mini`."),
11809
- host: z17.string().max(253).regex(/^(?:[A-Za-z0-9](?:[A-Za-z0-9.-]*[A-Za-z0-9])?|[0-9A-Fa-f:]+)$/, "Enter a hostname or IP address").describe("Hostname or IP, such as a Tailscale MagicDNS name (`mac-mini`) or a public address."),
11810
- port: z17.number().int().min(1).max(65535).optional().describe("SSH port. Defaults to 22."),
11811
- username: z17.string().regex(/^[A-Za-z0-9_][A-Za-z0-9._-]{0,63}$/, "Enter the account name on the device").describe("Account the agent signs in as."),
11812
- screen_password: screenPasswordSchema.optional()
11813
- });
11814
- var updateEnvironmentDeviceRequestSchema = createEnvironmentDeviceRequestSchema.partial().extend({
11815
- screen_password: z17.union([screenPasswordSchema, z17.literal("")]).optional().describe("New Screen Sharing password, or an empty string to remove it.")
11816
- });
11817
- var provisionedDeviceSchema = z17.object({
11818
- name: z17.string(),
11819
- host: z17.string(),
11820
- port: z17.number(),
11821
- username: z17.string(),
11822
- private_key: z17.string(),
11823
- screen_password: z17.string().optional()
11824
- });
11825
-
11826
11837
  // ../shared/src/routes/workspaces.ts
11827
11838
  import { z as z18 } from "zod";
11828
11839
  var WORKSPACE_STATUSES = ["active", "sleeping", "archived", "preparing", "error"];
@@ -20785,6 +20796,7 @@ export {
20785
20796
  workspaceTokenResponseSchema,
20786
20797
  legacyWorkspaceTokenBundleSchema,
20787
20798
  engineMcpOAuthTokenResponseSchema,
20799
+ DEVICE_HOST_KEYS_HEADER,
20788
20800
  provisionedDeviceSchema,
20789
20801
  SUBAGENT_SERVICE_TIERS,
20790
20802
  serviceTierRequestFields,
@@ -3,10 +3,10 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  execFileAsync
6
- } from "./chunk-INAQRTYM.js";
6
+ } from "./chunk-NZS7CK2A.js";
7
7
  import {
8
8
  isVersionBelow
9
- } from "./chunk-CKRLVTRB.js";
9
+ } from "./chunk-5VOV6MCE.js";
10
10
 
11
11
  // src/utils/codex-agent-env.ts
12
12
  function buildCodexAgentEnv(source = process.env) {
@@ -240,7 +240,7 @@ function getCodexModelProvider(method) {
240
240
  if (method === "foundry") return "azure";
241
241
  return method === "ollama" || method === "openai-compatible" ? "replicas_openai_compatible" : "openai";
242
242
  }
243
- var ENGINE_PACKAGE_VERSION = "0.1.1393";
243
+ var ENGINE_PACKAGE_VERSION = "0.1.1394";
244
244
  var INITIALIZE_METHOD = "initialize";
245
245
  var INITIALIZED_NOTIFICATION = "initialized";
246
246
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -5,7 +5,7 @@ import {
5
5
  extractCommandProtectionCommandText,
6
6
  isRecord,
7
7
  parseCodeHostPrUrl
8
- } from "./chunk-CKRLVTRB.js";
8
+ } from "./chunk-5VOV6MCE.js";
9
9
 
10
10
  // src/services/published-pull-request-urls.ts
11
11
  function publishedPullRequestUrls(result) {
@@ -10,15 +10,15 @@ import {
10
10
  resolveDiffBase,
11
11
  runGitCommand,
12
12
  setAgentCredentialSnapshot
13
- } from "./chunk-JXEKJXH7.js";
13
+ } from "./chunk-KZ4OLD3N.js";
14
14
  import {
15
15
  AppServerProcess,
16
16
  buildCodexAgentEnv
17
- } from "./chunk-BIUGCLX3.js";
17
+ } from "./chunk-AOLTWJRQ.js";
18
18
  import {
19
19
  SUBPROCESS_MAX_BUFFER,
20
20
  execFileAsync
21
- } from "./chunk-INAQRTYM.js";
21
+ } from "./chunk-NZS7CK2A.js";
22
22
  import {
23
23
  isRecord
24
24
  } from "./chunk-UZSNFLDQ.js";
@@ -56,7 +56,7 @@ import {
56
56
  resolveOpenAICompatibleModelsUrl,
57
57
  splitMothershipInstructions,
58
58
  withTimeout
59
- } from "./chunk-CKRLVTRB.js";
59
+ } from "./chunk-5VOV6MCE.js";
60
60
 
61
61
  // src/managers/codex-token-manager.ts
62
62
  import { promises as fs } from "fs";
@@ -319,7 +319,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
319
319
  await this.applyCredentialUpdate(++this.credentialGeneration, async () => {
320
320
  await this.applyCredentialsResponse(data);
321
321
  setAgentCredentialSnapshot("codex", data);
322
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-UFTJU76Y.js");
322
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-4W4DPMOT.js");
323
323
  await restartCodexAspHostIfRunning2();
324
324
  });
325
325
  await this.start(true);
@@ -341,7 +341,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
341
341
  const accountChanged = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.codex?.credentialId !== data.credentialId;
342
342
  await this.applyCredentialsResponse(data);
343
343
  if (restartOnChange && (accountChanged || CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index]))) {
344
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-UFTJU76Y.js");
344
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-4W4DPMOT.js");
345
345
  await restartCodexAspHostIfRunning2();
346
346
  }
347
347
  setAgentCredentialSnapshot("codex", data);
@@ -4,7 +4,7 @@ const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  SUBPROCESS_MAX_BUFFER,
6
6
  execFileAsync
7
- } from "./chunk-INAQRTYM.js";
7
+ } from "./chunk-NZS7CK2A.js";
8
8
  import {
9
9
  isRecord as isRecord2
10
10
  } from "./chunk-UZSNFLDQ.js";
@@ -21,7 +21,7 @@ import {
21
21
  provisionedDeviceSchema,
22
22
  readReplicasRuntimeEnv,
23
23
  serializePosixEnvFile
24
- } from "./chunk-CKRLVTRB.js";
24
+ } from "./chunk-5VOV6MCE.js";
25
25
 
26
26
  // src/runtime-env-loader.ts
27
27
  import { readFileSync } from "fs";
@@ -3,7 +3,7 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  HOOK_EXEC_MAX_BUFFER_BYTES
6
- } from "./chunk-CKRLVTRB.js";
6
+ } from "./chunk-5VOV6MCE.js";
7
7
 
8
8
  // src/utils/exec.ts
9
9
  import { exec, execFile } from "child_process";
@@ -6,7 +6,7 @@ import {
6
6
  getOriginDefaultBranch,
7
7
  monolithRequest,
8
8
  runGitCommand
9
- } from "./chunk-JXEKJXH7.js";
9
+ } from "./chunk-KZ4OLD3N.js";
10
10
  import {
11
11
  extractCommandProtectionCommandText,
12
12
  findCommandProtectionGitLookups,
@@ -14,7 +14,7 @@ import {
14
14
  findPrMergeSignals,
15
15
  findScoutRepoWriteSignals,
16
16
  parseCommandProtectionRequest
17
- } from "./chunk-CKRLVTRB.js";
17
+ } from "./chunk-5VOV6MCE.js";
18
18
 
19
19
  // src/services/command-protection-service.ts
20
20
  import { readFile, stat } from "fs/promises";
@@ -3,7 +3,7 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  AspClient
6
- } from "./chunk-BIUGCLX3.js";
6
+ } from "./chunk-AOLTWJRQ.js";
7
7
  import {
8
8
  ASTER_BASE_URL,
9
9
  ASTER_PROVIDER,
@@ -15,7 +15,7 @@ import {
15
15
  isRecord,
16
16
  readOllamaAuthEnv,
17
17
  readOpenAICompatibleAuthEnv
18
- } from "./chunk-CKRLVTRB.js";
18
+ } from "./chunk-5VOV6MCE.js";
19
19
 
20
20
  // src/managers/codex-asp/notification-dispatch.ts
21
21
  var TURN_STARTED_METHOD = "turn/started";
@@ -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-OSK2BFVR.js";
7
- import "./chunk-JXEKJXH7.js";
8
- import "./chunk-INAQRTYM.js";
6
+ } from "./chunk-PZATU5IM.js";
7
+ import "./chunk-KZ4OLD3N.js";
8
+ import "./chunk-NZS7CK2A.js";
9
9
  import {
10
10
  isRecord
11
11
  } from "./chunk-UZSNFLDQ.js";
12
- import "./chunk-CKRLVTRB.js";
12
+ import "./chunk-5VOV6MCE.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
 
15
15
  // src/command-protection-hook.ts
@@ -14,12 +14,12 @@ import {
14
14
  recoverCompletedTurn,
15
15
  spawnMuseMsp,
16
16
  startMuseSession
17
- } from "./chunk-TFUIT7CU.js";
17
+ } from "./chunk-QCSHVK7X.js";
18
18
  import {
19
19
  AppServerProcess,
20
20
  buildCodexAgentEnv
21
- } from "./chunk-BIUGCLX3.js";
22
- import "./chunk-INAQRTYM.js";
21
+ } from "./chunk-AOLTWJRQ.js";
22
+ import "./chunk-NZS7CK2A.js";
23
23
  import {
24
24
  AGENT,
25
25
  OPENCODE_GO_PROVIDER,
@@ -29,7 +29,7 @@ import {
29
29
  headlessAgentUsagePath,
30
30
  isRecord,
31
31
  withTimeout
32
- } from "./chunk-CKRLVTRB.js";
32
+ } from "./chunk-5VOV6MCE.js";
33
33
  import "./chunk-VEQXQN22.js";
34
34
 
35
35
  // src/headless-agent.ts
package/dist/src/index.js CHANGED
@@ -27,7 +27,7 @@ import {
27
27
  evaluateCommandProtection,
28
28
  extractToolCommand,
29
29
  reportCommandProtectionBlock
30
- } from "./chunk-OSK2BFVR.js";
30
+ } from "./chunk-PZATU5IM.js";
31
31
  import {
32
32
  ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
33
33
  AGENT_MESSAGE_DELTA_METHOD,
@@ -65,10 +65,10 @@ import {
65
65
  spawnMuseMsp,
66
66
  startMuseSession,
67
67
  uuidV7
68
- } from "./chunk-TFUIT7CU.js";
68
+ } from "./chunk-QCSHVK7X.js";
69
69
  import {
70
70
  publishedPullRequestUrls
71
- } from "./chunk-ZUCNXOOK.js";
71
+ } from "./chunk-ATJV5TGT.js";
72
72
  import {
73
73
  ACCOUNT_RATE_LIMITS_READ_METHOD,
74
74
  AsyncLock,
@@ -143,7 +143,7 @@ import {
143
143
  timestampFromSeconds,
144
144
  upsertCredentialFileLines,
145
145
  writeSecureCredentialFile
146
- } from "./chunk-GNWA725S.js";
146
+ } from "./chunk-JLSCYTGB.js";
147
147
  import {
148
148
  ENGINE_ENV,
149
149
  monolithRequest,
@@ -153,15 +153,15 @@ import {
153
153
  resolveDiffBase,
154
154
  setAgentCredentialSnapshot,
155
155
  setLinearSessionId
156
- } from "./chunk-JXEKJXH7.js";
156
+ } from "./chunk-KZ4OLD3N.js";
157
157
  import {
158
158
  getCodexModelProvider
159
- } from "./chunk-BIUGCLX3.js";
159
+ } from "./chunk-AOLTWJRQ.js";
160
160
  import {
161
161
  SUBPROCESS_MAX_BUFFER,
162
162
  execAsync,
163
163
  execFileAsync
164
- } from "./chunk-INAQRTYM.js";
164
+ } from "./chunk-NZS7CK2A.js";
165
165
  import {
166
166
  isRecord as isRecord2
167
167
  } from "./chunk-UZSNFLDQ.js";
@@ -213,6 +213,7 @@ import {
213
213
  DEFAULT_WEB_APP_URL,
214
214
  DESKTOP_STREAM_PORT,
215
215
  DEVICES_DIR,
216
+ DEVICE_HOST_KEYS_HEADER,
216
217
  DEVICE_SCREEN_FILE_SUFFIX,
217
218
  ENGINE_ACTIVATE_PATH,
218
219
  ENGINE_HEALTH_MAX_WAIT_MS,
@@ -426,7 +427,7 @@ import {
426
427
  workspaceTokenRequestSchema,
427
428
  workspaceTokenResponseSchema,
428
429
  wrapInTag
429
- } from "./chunk-CKRLVTRB.js";
430
+ } from "./chunk-5VOV6MCE.js";
430
431
  import {
431
432
  cloneMcpConfig,
432
433
  ensureCompatibilityImports,
@@ -10568,23 +10569,102 @@ async function registerDesktopPreview(signal) {
10568
10569
  );
10569
10570
  }
10570
10571
 
10572
+ // src/services/device-relay.ts
10573
+ import { createServer } from "net";
10574
+ import { writeFileSync as writeFileSync2 } from "fs";
10575
+ import { rm as rm2 } from "fs/promises";
10576
+ import { createWebSocketStream } from "ws";
10577
+ var DEVICE_WAIT_MS = 2e4;
10578
+ var relays = /* @__PURE__ */ new Map();
10579
+ function pipe(local, device) {
10580
+ device.send("open");
10581
+ const stream = createWebSocketStream(device);
10582
+ const close = () => {
10583
+ local.destroy();
10584
+ stream.destroy();
10585
+ };
10586
+ local.on("error", close).on("close", close);
10587
+ stream.on("error", close).on("close", close);
10588
+ local.pipe(stream).pipe(local);
10589
+ }
10590
+ function remove(list, item) {
10591
+ const index = list.indexOf(item);
10592
+ if (index !== -1) list.splice(index, 1);
10593
+ }
10594
+ function attach(relay, local) {
10595
+ const device = relay.waiting.pop();
10596
+ if (device) return pipe(local, device);
10597
+ const timer = setTimeout(() => local.destroy(), DEVICE_WAIT_MS);
10598
+ const take = (next) => {
10599
+ clearTimeout(timer);
10600
+ pipe(local, next);
10601
+ };
10602
+ relay.pending.push(take);
10603
+ local.once("close", () => {
10604
+ clearTimeout(timer);
10605
+ remove(relay.pending, take);
10606
+ });
10607
+ }
10608
+ function acceptDeviceConnection(name, device, hostKeys) {
10609
+ const relay = relays.get(name);
10610
+ if (!relay) return device.close(4404, "This workspace has no such device connecting from itself");
10611
+ const knownHosts = hostKeys.map((key) => `${name} ${key}
10612
+ `).join("");
10613
+ if (knownHosts !== relay.knownHosts) {
10614
+ writeFileSync2(relay.knownHostsPath, knownHosts, { mode: 384 });
10615
+ relay.knownHosts = knownHosts;
10616
+ }
10617
+ const take = relay.pending.shift();
10618
+ if (take) return take(device);
10619
+ relay.waiting.push(device);
10620
+ device.once("close", () => remove(relay.waiting, device));
10621
+ }
10622
+ function stopDeviceRelays() {
10623
+ for (const relay of relays.values()) {
10624
+ relay.server.close();
10625
+ relay.waiting.forEach((device) => device.terminate());
10626
+ }
10627
+ relays.clear();
10628
+ }
10629
+ async function startDeviceRelays(names, paths, signal) {
10630
+ stopDeviceRelays();
10631
+ signal.addEventListener("abort", stopDeviceRelays, { once: true });
10632
+ await Promise.all(names.map(async (name) => {
10633
+ await rm2(paths.socket(name), { force: true });
10634
+ const relay = { server: createServer((local) => attach(relay, local)), knownHostsPath: paths.knownHosts(name), waiting: [], pending: [] };
10635
+ relays.set(name, relay);
10636
+ await new Promise((resolve7, reject) => relay.server.once("error", reject).listen(paths.socket(name), resolve7));
10637
+ }));
10638
+ }
10639
+
10571
10640
  // src/services/device-service.ts
10572
- import { mkdir as mkdir7, rm as rm2, writeFile as writeFile4 } from "fs/promises";
10641
+ import { mkdir as mkdir7, rm as rm3, writeFile as writeFile4 } from "fs/promises";
10573
10642
  import { join as join8 } from "path";
10574
10643
  var DEVICES_DIR2 = join8(ENGINE_ENV.HOME_DIR, DEVICES_DIR);
10575
10644
  var TAILSCALED_UNIT = "replicas-tailscaled";
10645
+ var relayPaths = {
10646
+ socket: (name) => join8(DEVICES_DIR2, `${name}.sock`),
10647
+ knownHosts: (name) => join8(DEVICES_DIR2, `${name}.known_hosts`)
10648
+ };
10576
10649
  function sshConfig(devices, tailnet) {
10577
10650
  return devices.map((device) => [
10578
10651
  `Host ${device.name}`,
10579
- ` HostName ${device.host}`,
10580
- ` Port ${device.port}`,
10581
10652
  ` User ${device.username}`,
10582
10653
  ` IdentityFile ${join8(DEVICES_DIR2, device.name)}`,
10583
10654
  " IdentitiesOnly yes",
10584
- " StrictHostKeyChecking accept-new",
10585
10655
  " ServerAliveInterval 30",
10586
- // Userspace networking leaves the sandbox's routes and DNS alone, so tailnet names resolve through tailscaled.
10587
- ...tailnet ? [" ProxyCommand tailscale nc %h %p"] : []
10656
+ ...device.host === null ? [
10657
+ ` ProxyCommand websocat -b - unix:${relayPaths.socket(device.name)}`,
10658
+ // Anyone holding the device's token could answer through the relay, so only the identity the device pinned is trusted.
10659
+ ` UserKnownHostsFile ${relayPaths.knownHosts(device.name)}`,
10660
+ " StrictHostKeyChecking yes"
10661
+ ] : [
10662
+ ` HostName ${device.host}`,
10663
+ ` Port ${device.port}`,
10664
+ " StrictHostKeyChecking accept-new",
10665
+ // Userspace networking leaves the sandbox's routes and DNS alone, so tailnet names resolve through tailscaled.
10666
+ ...tailnet ? [" ProxyCommand tailscale nc %h %p"] : []
10667
+ ]
10588
10668
  ].join("\n")).join("\n\n") + "\n";
10589
10669
  }
10590
10670
  async function joinTailnet(authKey, workspaceId, signal) {
@@ -10613,11 +10693,10 @@ async function joinTailnet(authKey, workspaceId, signal) {
10613
10693
  }
10614
10694
  async function connectDevices(signal) {
10615
10695
  const { REPLICAS_ENV_DEVICES: devices, TS_AUTHKEY: authKey, REPLICAS_WORKSPACE_ID: workspaceId } = ENGINE_ENV;
10616
- await rm2(DEVICES_DIR2, { recursive: true, force: true });
10617
- if (devices.length === 0) {
10618
- await execFileAsync("sudo", ["systemctl", "stop", TAILSCALED_UNIT], { signal }).catch(() => void 0);
10619
- return;
10620
- }
10696
+ await rm3(DEVICES_DIR2, { recursive: true, force: true });
10697
+ const tailnetKey = devices.some((device) => device.host !== null) ? authKey : void 0;
10698
+ if (!tailnetKey) await execFileAsync("sudo", ["systemctl", "stop", TAILSCALED_UNIT], { signal }).catch(() => void 0);
10699
+ if (devices.length === 0) return;
10621
10700
  await mkdir7(DEVICES_DIR2, { recursive: true, mode: 448 });
10622
10701
  await Promise.all(devices.flatMap((device) => [
10623
10702
  writeFile4(join8(DEVICES_DIR2, device.name), device.private_key, { mode: 384 }),
@@ -10627,24 +10706,27 @@ async function connectDevices(signal) {
10627
10706
  { mode: 384 }
10628
10707
  )]
10629
10708
  ]));
10630
- await writeFile4(join8(DEVICES_DIR2, "devices.conf"), sshConfig(devices, authKey !== void 0), { mode: 384 });
10631
- if (authKey && workspaceId) await joinTailnet(authKey, workspaceId, signal);
10709
+ await writeFile4(join8(DEVICES_DIR2, "devices.conf"), sshConfig(devices, tailnetKey !== void 0), { mode: 384 });
10710
+ await startDeviceRelays(devices.flatMap((device) => device.host === null ? [device.name] : []), relayPaths, signal);
10711
+ if (tailnetKey && workspaceId) await joinTailnet(tailnetKey, workspaceId, signal);
10632
10712
  }
10633
10713
  function devicesInstruction() {
10634
10714
  const devices = ENGINE_ENV.REPLICAS_ENV_DEVICES;
10635
10715
  if (devices.length === 0) return void 0;
10636
- const list = devices.map((device) => `\`${device.name}\` (${device.username}@${device.host})`).join(", ");
10716
+ const list = devices.map((device) => `\`${device.name}\` (${device.username}@${device.host ?? device.name})`).join(", ");
10637
10717
  const screens = devices.filter((device) => device.screen_password !== void 0).map((device) => `\`${device.name}\``);
10718
+ const relayed = devices.filter((device) => device.host === null).map((device) => `\`${device.name}\``);
10638
10719
  return [
10639
10720
  `The user's own computers are reachable over SSH by name: ${list}. Use \`ssh <name>\`, \`scp\` and \`rsync\` as usual, and \`ssh -L\` to reach a service running on one.`,
10640
10721
  "They are personal machines with the user's files and accounts: change only what the task needs, and ask before anything destructive or hard to undo.",
10641
- ...ENGINE_ENV.TS_AUTHKEY ? ["They are reached through the user's tailnet. If a connection fails, `tailscale status` shows whether this workspace joined it."] : [],
10722
+ ...ENGINE_ENV.TS_AUTHKEY && relayed.length < devices.length ? ["They are reached through the user's tailnet. If a connection fails, `tailscale status` shows whether this workspace joined it."] : [],
10723
+ ...relayed.length > 0 ? [`${relayed.join(", ")} connect to this workspace from the device itself, while \`replicas device connect\` runs there. If \`ssh\` to one closes before it signs in, ask the user to start that command on it again. If it fails host key verification, something other than that device answered: never bypass the check, and tell the user.`] : [],
10642
10724
  ...screens.length > 0 ? [`To see and control the screen of ${screens.join(", ")}, run \`replicas computer screen <name>\`: it shows on this desktop, where the other \`replicas computer\` commands drive it. Prefer \`ssh\` when a command does the job.`] : []
10643
10725
  ].join(" ");
10644
10726
  }
10645
10727
 
10646
10728
  // src/services/chat/chat-service.ts
10647
- import { appendFile as appendFile5, copyFile as copyFile2, mkdir as mkdir18, readFile as readFile17, rename as rename3, rm as rm5, stat as stat6 } from "fs/promises";
10729
+ import { appendFile as appendFile5, copyFile as copyFile2, mkdir as mkdir18, readFile as readFile17, rename as rename3, rm as rm6, stat as stat6 } from "fs/promises";
10648
10730
  import { join as join29 } from "path";
10649
10731
  import { randomUUID as randomUUID9 } from "crypto";
10650
10732
  import { z as z3 } from "zod";
@@ -17045,7 +17127,7 @@ ${pending}
17045
17127
 
17046
17128
  // src/managers/opencode-manager.ts
17047
17129
  import { existsSync as existsSync8 } from "fs";
17048
- import { copyFile, mkdir as mkdir13, readFile as readFile10, rm as rm3 } from "fs/promises";
17130
+ import { copyFile, mkdir as mkdir13, readFile as readFile10, rm as rm4 } from "fs/promises";
17049
17131
  import { delimiter, dirname as dirname7, join as join15 } from "path";
17050
17132
  import { randomBytes as randomBytes2 } from "crypto";
17051
17133
  import { fileURLToPath as fileURLToPath2 } from "url";
@@ -17337,7 +17419,7 @@ var OpencodeManager = class extends CodingAgentManager {
17337
17419
  }
17338
17420
  await mkdir13(dirname7(OPENCODE_COMMAND_PROTECTION_PLUGIN_PATH), { recursive: true });
17339
17421
  await copyFile(OPENCODE_COMMAND_PROTECTION_PLUGIN_SOURCE, OPENCODE_COMMAND_PROTECTION_PLUGIN_PATH);
17340
- await rm3(OPENCODE_LEGACY_COMMAND_PROTECTION_PLUGIN_PATH, { force: true });
17422
+ await rm4(OPENCODE_LEGACY_COMMAND_PROTECTION_PLUGIN_PATH, { force: true });
17341
17423
  process.env.REPLICAS_COMMAND_PROTECTION_HOOK_PATH = getCommandProtectionHookPath();
17342
17424
  process.env.REPLICAS_POST_TOOL_PR_HOOK_PATH = getPostToolPrHookPath();
17343
17425
  process.env.REPLICAS_COMMAND_PROTECTION_RUNTIME_PATH = process.execPath;
@@ -40221,7 +40303,7 @@ async function probeMcpEndpoint(url3) {
40221
40303
  }
40222
40304
 
40223
40305
  // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/npx-resolver.ts
40224
- import { existsSync as existsSync9, readFileSync as readFileSync2, realpathSync, readdirSync, statSync as statSync2, writeFileSync as writeFileSync2, renameSync, mkdirSync as mkdirSync2, openSync, readSync, closeSync, unlinkSync } from "fs";
40306
+ import { existsSync as existsSync9, readFileSync as readFileSync2, realpathSync, readdirSync, statSync as statSync2, writeFileSync as writeFileSync3, renameSync, mkdirSync as mkdirSync2, openSync, readSync, closeSync, unlinkSync } from "fs";
40225
40307
  import { join as join16, dirname as dirname8, extname as extname2, resolve as resolve2, sep } from "path";
40226
40308
 
40227
40309
  // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/abort.ts
@@ -40636,7 +40718,7 @@ function clearLegacyCache() {
40636
40718
  unlinkSync(cachePath);
40637
40719
  } catch {
40638
40720
  try {
40639
- writeFileSync2(cachePath, "", "utf-8");
40721
+ writeFileSync3(cachePath, "", "utf-8");
40640
40722
  } catch {
40641
40723
  }
40642
40724
  }
@@ -40658,7 +40740,7 @@ function saveCacheEntry(key, entry) {
40658
40740
  const merged = { version: CACHE_VERSION, entries };
40659
40741
  merged.entries[key] = entry;
40660
40742
  const tmpPath = `${cachePath}.${process.pid}.tmp`;
40661
- writeFileSync2(tmpPath, JSON.stringify(merged, null, 2), "utf-8");
40743
+ writeFileSync3(tmpPath, JSON.stringify(merged, null, 2), "utf-8");
40662
40744
  renameSync(tmpPath, cachePath);
40663
40745
  } catch {
40664
40746
  }
@@ -42445,7 +42527,7 @@ defineLazyProperty(apps, "browserPrivate", () => "browserPrivate");
42445
42527
  var open_default = open2;
42446
42528
 
42447
42529
  // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/mcp-callback-server.ts
42448
- import { createServer } from "http";
42530
+ import { createServer as createServer2 } from "http";
42449
42531
  var PAGE_STYLE = `
42450
42532
  :root { color-scheme: light dark; }
42451
42533
  * { box-sizing: border-box; }
@@ -42695,7 +42777,7 @@ async function ensureCallbackServerLocked(options = {}) {
42695
42777
  );
42696
42778
  }
42697
42779
  }
42698
- const candidateServer = createServer(handleRequest);
42780
+ const candidateServer = createServer2(handleRequest);
42699
42781
  const listenPort = strictPort ? requiredPort : 0;
42700
42782
  try {
42701
42783
  await new Promise((resolve7, reject) => {
@@ -47524,7 +47606,7 @@ function getEffectiveIdleTimeoutMinutes(state, serverName) {
47524
47606
  }
47525
47607
 
47526
47608
  // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/onboarding-state.ts
47527
- import { existsSync as existsSync12, mkdirSync as mkdirSync4, readFileSync as readFileSync4, writeFileSync as writeFileSync3, renameSync as renameSync2 } from "fs";
47609
+ import { existsSync as existsSync12, mkdirSync as mkdirSync4, readFileSync as readFileSync4, writeFileSync as writeFileSync4, renameSync as renameSync2 } from "fs";
47528
47610
  import { dirname as dirname12 } from "path";
47529
47611
  var DEFAULT_STATE = {
47530
47612
  version: 1,
@@ -47554,7 +47636,7 @@ function saveOnboardingState(state) {
47554
47636
  const path7 = getOnboardingStatePath();
47555
47637
  mkdirSync4(dirname12(path7), { recursive: true });
47556
47638
  const tmpPath = `${path7}.${process.pid}.tmp`;
47557
- writeFileSync3(tmpPath, `${JSON.stringify(state, null, 2)}
47639
+ writeFileSync4(tmpPath, `${JSON.stringify(state, null, 2)}
47558
47640
  `, "utf-8");
47559
47641
  renameSync2(tmpPath, path7);
47560
47642
  }
@@ -48177,7 +48259,7 @@ async function openMcpAuthPanel(state, pi, ctx, configOverridePath) {
48177
48259
  }
48178
48260
 
48179
48261
  // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/tool-registrar.ts
48180
- import { mkdtempSync, rmSync as rmSync3, writeFileSync as writeFileSync4 } from "fs";
48262
+ import { mkdtempSync, rmSync as rmSync3, writeFileSync as writeFileSync5 } from "fs";
48181
48263
  import { tmpdir } from "os";
48182
48264
  import { join as join19 } from "path";
48183
48265
  var MAX_BINARY_RESOURCE_BYTES = 10 * 1024 * 1024;
@@ -48294,7 +48376,7 @@ function materializeBinaryResource(resource, scope) {
48294
48376
  session.bytes += decodedBytes;
48295
48377
  session.files += 1;
48296
48378
  try {
48297
- writeFileSync4(filePath, Buffer.from(resource.blob, "base64"), { flag: "wx", mode: 384 });
48379
+ writeFileSync5(filePath, Buffer.from(resource.blob, "base64"), { flag: "wx", mode: 384 });
48298
48380
  } catch {
48299
48381
  try {
48300
48382
  rmSync3(filePath, { force: true });
@@ -48381,7 +48463,7 @@ function stringifyStructuredContent(value) {
48381
48463
 
48382
48464
  // ../node_modules/.bun/pi-mcp-adapter@2.32.1+04b0d7b0bc944965/node_modules/pi-mcp-adapter/mcp-output-guard.ts
48383
48465
  import { randomBytes as randomBytes3 } from "crypto";
48384
- import { mkdtemp, rm as rm4, writeFile as writeFile8 } from "fs/promises";
48466
+ import { mkdtemp, rm as rm5, writeFile as writeFile8 } from "fs/promises";
48385
48467
  import { tmpdir as tmpdir2 } from "os";
48386
48468
  import { dirname as dirname13, join as join20 } from "path";
48387
48469
  var DEFAULT_MCP_OUTPUT_MAX_BYTES = 50 * 1024;
@@ -48701,7 +48783,7 @@ async function saveArtifact(kind, text) {
48701
48783
  }
48702
48784
  async function discardArtifact(path7) {
48703
48785
  try {
48704
- await rm4(dirname13(path7), { recursive: true, force: true });
48786
+ await rm5(dirname13(path7), { recursive: true, force: true });
48705
48787
  } catch {
48706
48788
  }
48707
48789
  }
@@ -57351,13 +57433,13 @@ function installMcpAdapter(pi, options) {
57351
57433
  const unregisterTool = pi.unregisterTool;
57352
57434
  const unregistered = toolNames.filter((toolName) => unregisterTool?.(toolName) === true);
57353
57435
  const fallbackNames = toolNames.filter((toolName) => !unregistered.includes(toolName));
57354
- const remove = new Set(toolNames);
57436
+ const remove2 = new Set(toolNames);
57355
57437
  const activeTools = getActiveToolsIfReady();
57356
57438
  if (!activeTools || activeTools.length === 0) {
57357
57439
  for (const toolName of fallbackNames) fallbackDeactivatedTools.add(toolName);
57358
57440
  return unregistered;
57359
57441
  }
57360
- const nextActiveTools = activeTools.filter((name) => !remove.has(name));
57442
+ const nextActiveTools = activeTools.filter((name) => !remove2.has(name));
57361
57443
  if (nextActiveTools.length !== activeTools.length) {
57362
57444
  for (const toolName of fallbackNames) fallbackDeactivatedTools.add(toolName);
57363
57445
  pi.setActiveTools(nextActiveTools);
@@ -61183,9 +61265,9 @@ ${decisions}` };
61183
61265
  historyPath,
61184
61266
  `${historyPath}.pages.jsonl`,
61185
61267
  `${historyPath}.pages.index.json`
61186
- ].map((path7) => rm5(path7, { force: true })));
61187
- await rm5(chatMessageSendersFilePath(persisted.id), { force: true });
61188
- await rm5(join29(FORKS_DIR, persisted.id), { recursive: true, force: true });
61268
+ ].map((path7) => rm6(path7, { force: true })));
61269
+ await rm6(chatMessageSendersFilePath(persisted.id), { force: true });
61270
+ await rm6(join29(FORKS_DIR, persisted.id), { recursive: true, force: true });
61189
61271
  }
61190
61272
  switchHarness(source, request) {
61191
61273
  const switching = (async () => {
@@ -64572,8 +64654,8 @@ async function installWorkspaceSdk() {
64572
64654
  }
64573
64655
 
64574
64656
  // src/services/git-push-tracker.ts
64575
- import { mkdir as mkdir21, rm as rm6 } from "fs/promises";
64576
- import { createServer as createServer2 } from "net";
64657
+ import { mkdir as mkdir21, rm as rm7 } from "fs/promises";
64658
+ import { createServer as createServer3 } from "net";
64577
64659
  import { join as join35 } from "path";
64578
64660
  var SOCKET_PATH = join35(ENGINE_DIR, "git-trace2.sock");
64579
64661
  var MAX_LINE_LENGTH = 1024 * 1024;
@@ -64586,8 +64668,8 @@ function startGitPushTracker() {
64586
64668
  }
64587
64669
  async function listen() {
64588
64670
  await mkdir21(ENGINE_DIR, { recursive: true });
64589
- await rm6(SOCKET_PATH, { force: true });
64590
- const server3 = createServer2((socket) => {
64671
+ await rm7(SOCKET_PATH, { force: true });
64672
+ const server3 = createServer3((socket) => {
64591
64673
  let buffered = "";
64592
64674
  let ignored = false;
64593
64675
  let push = false;
@@ -65020,8 +65102,9 @@ async function sleep3() {
65020
65102
  await engineLogger.flush();
65021
65103
  return createSuccessResult({ state: lifecycle.state, workspaceId: lifecycle.workspaceId });
65022
65104
  }
65023
- var terminalSockets = new WebSocketServer({ noServer: true });
65105
+ var webSockets = new WebSocketServer({ noServer: true });
65024
65106
  var TERMINAL_SOCKET_PATH = /^\/terminal\/sessions\/([^/]+)\/ws$/;
65107
+ var DEVICE_SOCKET_PATH = /^\/devices\/([^/]+)\/ws$/;
65025
65108
  var server2 = serve(
65026
65109
  {
65027
65110
  fetch: app.fetch,
@@ -65043,15 +65126,20 @@ var server2 = serve(
65043
65126
  );
65044
65127
  server2.on("connection", recordProxyConnection);
65045
65128
  server2.on("upgrade", (req, socket, head) => {
65046
- const sessionId = TERMINAL_SOCKET_PATH.exec(new URL(req.url ?? "/", "http://engine").pathname)?.[1];
65047
- if (!sessionId || req.headers["x-replicas-engine-secret"] !== ENGINE_ENV.REPLICAS_ENGINE_SECRET || !lifecycle.active) {
65048
- socket.end(`HTTP/1.1 ${sessionId ? "401 Unauthorized" : "404 Not Found"}\r
65129
+ const path7 = new URL(req.url ?? "/", "http://engine").pathname;
65130
+ const sessionId = TERMINAL_SOCKET_PATH.exec(path7)?.[1];
65131
+ const device = DEVICE_SOCKET_PATH.exec(path7)?.[1];
65132
+ if (!(sessionId || device) || req.headers["x-replicas-engine-secret"] !== ENGINE_ENV.REPLICAS_ENGINE_SECRET || !lifecycle.active) {
65133
+ socket.end(`HTTP/1.1 ${sessionId || device ? "401 Unauthorized" : "404 Not Found"}\r
65049
65134
  Connection: close\r
65050
65135
  \r
65051
65136
  `);
65052
65137
  return;
65053
65138
  }
65054
- terminalSockets.handleUpgrade(req, socket, head, (ws) => attachTerminalSocket(decodeURIComponent(sessionId), ws));
65139
+ webSockets.handleUpgrade(req, socket, head, (ws) => {
65140
+ if (sessionId) attachTerminalSocket(decodeURIComponent(sessionId), ws);
65141
+ else if (device) acceptDeviceConnection(decodeURIComponent(device), ws, String(req.headers[DEVICE_HOST_KEYS_HEADER] ?? "").split(",").filter(Boolean));
65142
+ });
65055
65143
  });
65056
65144
  /*! Bundled license information:
65057
65145
 
@@ -3,13 +3,13 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  publishedPullRequestUrls
6
- } from "./chunk-ZUCNXOOK.js";
6
+ } from "./chunk-ATJV5TGT.js";
7
7
  import {
8
8
  isRecord
9
9
  } from "./chunk-UZSNFLDQ.js";
10
10
  import {
11
11
  shouldRefreshPullRequests
12
- } from "./chunk-CKRLVTRB.js";
12
+ } from "./chunk-5VOV6MCE.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
 
15
15
  // src/services/post-tool-pr-notifier.ts
@@ -11,7 +11,7 @@ import {
11
11
  spawnSubagentRequestSchema,
12
12
  subagentResponseSchema,
13
13
  waitSubagentRequestSchema
14
- } from "./chunk-CKRLVTRB.js";
14
+ } from "./chunk-5VOV6MCE.js";
15
15
  import "./chunk-VEQXQN22.js";
16
16
 
17
17
  // src/subagent-mcp.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.1393",
3
+ "version": "0.1.1394",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",