replicas-engine 0.1.1184 → 0.1.1186

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-CPHIDGPB.js";
12
- import "./chunk-OKE4RCRY.js";
13
- import "./chunk-2YHCBP6R.js";
14
- import "./chunk-2AG3DWDX.js";
11
+ } from "./chunk-KLHDCQAK.js";
12
+ import "./chunk-VXPWAQR2.js";
13
+ import "./chunk-WIEXE5ZC.js";
14
+ import "./chunk-R6I3LT27.js";
15
15
  import "./chunk-UZSNFLDQ.js";
16
- import "./chunk-AGNQDFJU.js";
16
+ import "./chunk-4T2K6OBK.js";
17
17
  import "./chunk-VEQXQN22.js";
18
18
  export {
19
19
  CODEX_ULTRAFAST_SERVICE_TIER,
@@ -4211,7 +4211,7 @@ var LINEAR_ABILITY = {
4211
4211
 
4212
4212
  // ../shared/src/default-skills/replicas-agent/abilities/media.ts
4213
4213
  var SECTION8 = `### Media
4214
- Deliver screenshots, GIFs, screen recordings, generated diagrams, audio clips, and self-contained HTML pages to the Replicas dashboard and, when applicable, inline in the destination workflow.
4214
+ Deliver screenshots, GIFs, screen recordings, generated diagrams, and audio clips to the Replicas dashboard and, when applicable, inline in the destination workflow.
4215
4215
 
4216
4216
  **Reference:** \`references/MEDIA.md\`
4217
4217
 
@@ -4219,16 +4219,15 @@ Use this when:
4219
4219
  - You are about to run \`replicas media upload\`; this reference owns the complete Replicas-first, destination-second workflow
4220
4220
  - You produce a screenshot, recording, generated image, or audio clip the user should see
4221
4221
  - You need to show motion or an interaction (an animation, a popup that moves, a flow) in a PR or message: make a short looping GIF with \`replicas media gif\`, never a grid of frames
4222
- - You produce a self-contained HTML report that should be linked from a pull request
4223
4222
  - You record video output (browser automation, screen capture) \u2014 including the recommended aspect ratio and FPS
4224
4223
  - You need to embed media in a Slack/Linear/GitHub/GitLab message AND keep a referenceable copy in the Replicas dashboard`;
4225
- var REFERENCE8 = `# Media (Screenshots, GIFs, Recordings, Audio, HTML)
4224
+ var REFERENCE8 = `# Media (Screenshots, GIFs, Recordings, Audio)
4226
4225
 
4227
- This is the single source of truth for delivering screenshots, GIFs, screen recordings, generated diagrams, audio clips, and self-contained HTML pages through Replicas and external surfaces (Slack, Linear, GitHub, GitLab).
4226
+ This is the single source of truth for delivering screenshots, GIFs, screen recordings, generated diagrams, and audio clips through Replicas and external surfaces (Slack, Linear, GitHub, GitLab). HTML pages are visuals: publish them with \`replicas visualize\` (see \`replicas visualize --help\`), not \`media upload\`.
4228
4227
 
4229
4228
  ## Always
4230
4229
 
4231
- - Every picture, GIF, recording, or HTML page you mention in your reply to the user shows up in that reply: paste its printed \`![\u2026](\u2026)\` or \`HTML page\` line on its own line. Do this even when you also posted it to a PR, Slack, Linear, or GitLab, and even when the task came from one of them.
4230
+ - Every picture, GIF, recording, or visual you mention in your reply to the user shows up in that reply: paste its printed \`![\u2026](\u2026)\` line on its own line. Do this even when you also posted it to a PR, Slack, Linear, or GitLab, and even when the task came from one of them.
4232
4231
  - Never send the user somewhere else to see it ("see the Canvas", "check the media tab"). Uploads also appear in the Canvas's media folder, so they stay there for later.
4233
4232
  - Keep the whole \`replicas media upload\` output. Don't pipe it through \`tail\`, \`grep\`, or \`head\`; you need every line it prints.
4234
4233
 
@@ -4280,8 +4279,8 @@ Make comparisons easy to see at a glance, whether it's before and after or optio
4280
4279
 
4281
4280
  Upload to Replicas in these cases \u2014 and **only** these cases:
4282
4281
 
4283
- 1. **Media you show the user.** A screenshot, screen recording, generated diagram, audio clip, or HTML page, once you decide to show it to the user or share it. Screenshots you take only to check your own work stay local. Upload before you delete the file or send it anywhere else. This applies even when you're also sending the file to Slack, Linear, GitHub, or GitLab.
4284
- 2. **Files the user explicitly asks you to upload.** If the user sends or points at a file (image, video, audio, HTML) and asks you to upload it, run \`replicas media upload\`. Otherwise leave it alone \u2014 files in the workspace the user did not ask about should not be auto-uploaded as media.
4282
+ 1. **Media you show the user.** A screenshot, screen recording, generated diagram, or audio clip, once you decide to show it to the user or share it. Screenshots you take only to check your own work stay local. Upload before you delete the file or send it anywhere else. This applies even when you're also sending the file to Slack, Linear, GitHub, or GitLab.
4283
+ 2. **Files the user explicitly asks you to upload.** If the user sends or points at a file (image, video, audio) and asks you to upload it, run \`replicas media upload\`. Otherwise leave it alone \u2014 files in the workspace the user did not ask about should not be auto-uploaded as media.
4285
4284
  3. **Anything you plan to share externally (Slack, Linear, GitHub, GitLab, etc.).** Upload to Replicas first, then follow the destination's delivery path below.
4286
4285
 
4287
4286
  If none of these apply, don't upload.
@@ -4291,7 +4290,7 @@ If none of these apply, don't upload.
4291
4290
  \`replicas media upload\` is always the first delivery action. When the current task has an external destination, every other delivery step follows only after that command succeeds. For every file:
4292
4291
 
4293
4292
  1. First, run \`replicas media upload\` with the original file. Do not begin any destination upload until the command succeeds. This creates the canonical dashboard copy and prints an embed plus a per-file dashboard link. Every image gets a public link, so its printed embed works in chat and on GitHub.
4294
- 2. Include the printed embed line in the Replicas chat reply. HTML uses its printed page link instead of an image embed.
4293
+ 2. Include the printed embed line in the Replicas chat reply.
4295
4294
  3. Identify every destination in the task and use its inline representation from the table below. Slack, Linear, and GitLab require an upload of the same original bytes; GitHub uses the image's printed public embed.
4296
4295
  4. On Slack and Linear, put the **View in Replicas** dashboard link next to the destination embed as a secondary link. GitHub and GitLab need only the embed.
4297
4296
  5. Check each destination response. If its upload or public link fails, say so explicitly and keep the dashboard link; never claim that a dashboard link is an inline embed.
@@ -4338,15 +4337,13 @@ For each media file, the CLI prints an embed line and a dashboard link:
4338
4337
 
4339
4338
  Match each "View in Replicas" line to the embed line directly above it \u2014 that's the deep link for that file.
4340
4339
 
4341
- HTML uploads print an \`HTML page\` Markdown link instead of an image embed. It previews the page inside Replicas chat only. They also print a \`Forge link (organization only)\` to use everywhere else: it opens a dedicated page, where signed-in organization members go straight to the report and signed-out members sign in first.
4342
-
4343
4340
  Video and audio stay private unless they must play without Replicas sign-in; then pass \`--access public\` (alias \`--share\`):
4344
4341
 
4345
4342
  \`\`\`bash
4346
4343
  replicas media upload demo.mp4 --name "Checkout demo" --access public
4347
4344
  \`\`\`
4348
4345
 
4349
- Public links are unguessable bearer URLs: anyone with the link can view the file until it is rotated or revoked. HTML pages only support organization access. Reuse the link printed at upload. \`replicas media share <media-id>\` issues a new link and breaks the old one everywhere it is embedded, and \`replicas media revoke <media-id>\` removes public access.
4346
+ Public links are unguessable bearer URLs: anyone with the link can view the file until it is rotated or revoked. Reuse the link printed at upload. \`replicas media share <media-id>\` issues a new link and breaks the old one everywhere it is embedded, and \`replicas media revoke <media-id>\` removes public access.
4350
4347
 
4351
4348
  Permanently delete an upload with \`replicas media delete <media-id>\`. The backend only permits deletion when the media belongs to the current workspace; media from another workspace returns not found.
4352
4349
 
@@ -4354,8 +4351,8 @@ Permanently delete an upload with \`replicas media delete <media-id>\`. The back
4354
4351
 
4355
4352
  | URL | What it is | Where it's allowed |
4356
4353
  |---|---|---|
4357
- | \`https://api.replicas.dev/v1/media/<id>\` (inside \`![\u2026](\u2026)\`) | Authenticated API redirect printed for private video, audio, and HTML \u2014 requires the Replicas chat session | **Only** in the Replicas chat reply. Nowhere else. |
4358
- | \`https://app.replicas.dev/organizations/<organization-id>/media/<media-id>\` | Organization-only page (\`Forge link\`) printed for every HTML upload, and for video or audio with \`--access organization\` | Pull requests and other places where every viewer belongs to the Replicas organization. |
4354
+ | \`https://api.replicas.dev/v1/media/<id>\` (inside \`![\u2026](\u2026)\`) | Authenticated API redirect printed for private video, audio, and visuals \u2014 requires the Replicas chat session | **Only** in the Replicas chat reply. Nowhere else. |
4355
+ | \`https://app.replicas.dev/organizations/<organization-id>/media/<media-id>\` | Organization-only page (\`Forge link\`) printed for every visual, and for video or audio with \`--access organization\` | Pull requests and other places where every viewer belongs to the Replicas organization. |
4359
4356
  | \`https://api.replicas.dev/v1/media/public/<id>/<token>\` | Public bearer URL printed for every image, and for video or audio with \`--access public\` | The Replicas chat reply and GitHub embeds. |
4360
4357
  | \`https://app.replicas.dev/workspaces/<workspace-id>?mode=media&media=<media-id>\` | Authenticated dashboard deep link that opens the media file in the workspace | Everywhere external: Slack, GitHub, GitLab, Linear, PR bodies, comments, emails. |
4361
4358
 
@@ -4373,7 +4370,7 @@ This rule has no exceptions:
4373
4370
 
4374
4371
  ### ALWAYS link a Replicas web URL \u2014 never the authenticated API URL \u2014 when referencing media externally
4375
4372
 
4376
- For an HTML page, use its printed \`Forge link\`. For other authenticated media references, use the dashboard form:
4373
+ For a visual, use its printed \`Forge link\`: it opens a dedicated page, where signed-in organization members go straight to it and signed-out members sign in first. For other authenticated media references, use the dashboard form:
4377
4374
 
4378
4375
  \`\`\`
4379
4376
  https://app.replicas.dev/workspaces/<workspace-id>?mode=media&media=<media-id>
@@ -4387,7 +4384,7 @@ Always render as a markdown / mrkdwn hyperlink labeled **View in Replicas** \u20
4387
4384
 
4388
4385
  ## In your Replicas chat reply
4389
4386
 
4390
- Include each markdown embed line **verbatim** where you want that file to render inline. The chat substitutes each one with an embedded image, video, or audio player. For HTML, use the printed \`HTML page\` link. Multiple embeds can appear in a single reply.
4387
+ Include each markdown embed line **verbatim** where you want that file to render inline. The chat substitutes each one with an embedded image, video, or audio player. Multiple embeds can appear in a single reply.
4391
4388
 
4392
4389
  Never reply with only dashboard links (for example a "Links:" list of \`?mode=media&media=\` URLs) in place of the embeds: a dashboard link renders as plain text, so the user sees nothing inline. This applies even when the task came from Slack, Linear, GitHub, or GitLab; the chat reply still gets the embeds.
4393
4390
 
@@ -4530,7 +4527,7 @@ GitHub does not play external videos inline, so show motion with a GIF (see *Mak
4530
4527
 
4531
4528
  Public links are unauthenticated bearer capabilities. Revoke with \`replicas media revoke <media-id>\` **only** when the user asks or the media should intentionally stop rendering; never as routine post-task cleanup, since revoking breaks every embed already posted on the PR.
4532
4529
 
4533
- For a self-contained HTML report, upload it and put the printed \`Forge link\` Markdown in the PR body or comment. GitHub cannot render the page inline, so use the normal link rather than image syntax. HTML pages cannot be shared publicly.
4530
+ For a self-contained HTML report, publish it with \`replicas visualize\` and put the printed \`Forge link\` Markdown in the PR body or comment. GitHub cannot render the page inline, so use the normal link rather than image syntax. Visuals cannot be shared publicly.
4534
4531
 
4535
4532
  Do **not** commit screenshots to the repo, use placeholder URLs, expose the authenticated \`/v1/media/<id>\` URL, or automate GitHub's undocumented browser upload flow.
4536
4533
 
@@ -4568,9 +4565,8 @@ Auto-detected from the filename extension:
4568
4565
  | \`png\`, \`jpg\`, \`jpeg\`, \`webp\`, \`gif\` | image |
4569
4566
  | \`mp4\`, \`webm\` | video |
4570
4567
  | \`mp3\`, \`wav\` | audio |
4571
- | \`html\`, \`htm\` | html |
4572
4568
 
4573
- For other extensions, pass \`--kind image|video|audio|html\` explicitly. The kind applies to every file in that invocation, so group files of the same kind together:
4569
+ For other extensions, pass \`--kind image|video|audio\` explicitly. The kind applies to every file in that invocation, so group files of the same kind together:
4574
4570
 
4575
4571
  \`\`\`bash
4576
4572
  replicas media upload diagram.svg --name "Architecture diagram" --kind image
@@ -4579,16 +4575,16 @@ replicas media upload chart-a.svg chart-b.svg --name "Latency chart" --name "Err
4579
4575
 
4580
4576
  ## Options
4581
4577
 
4582
- - \`--kind <image|video|audio|html>\` \u2014 override auto-detection
4578
+ - \`--kind <image|video|audio>\` \u2014 override auto-detection
4583
4579
  - \`--name <name>\`: required display name shown in the dashboard, one per file in order
4584
4580
  - \`--session-id <id>\` \u2014 associate the upload with a specific session
4585
- - \`--access organization|public\`: for video and audio, print an organization-only link or create a public bearer URL. Images are always public, and HTML always gets an organization-only link
4586
- - \`--share\`: alias for \`--access public\`; not supported for HTML
4581
+ - \`--access organization|public\`: for video and audio, print an organization-only link or create a public bearer URL. Images are always public
4582
+ - \`--share\`: alias for \`--access public\`
4587
4583
  `;
4588
4584
  var MEDIA_ABILITY = {
4589
4585
  label: "Media",
4590
4586
  description: "Deliver media to Replicas and destination workflows with inline uploads.",
4591
- bullet: "- Producing or showing the user any media \u2014 screenshots, screen recordings, generated images or diagrams, audio clips, or HTML recap pages \u2014 including in your Replicas chat reply, PR descriptions/comments, and other external platforms. Paste the printed `![\u2026](\u2026)` embeds in your chat reply, never only dashboard links, and upload the file itself to Slack, Linear, or GitLab. To show motion, turn the recording into a short GIF with `replicas media gif` instead of a grid of frames",
4587
+ bullet: "- Producing or showing the user any media \u2014 screenshots, screen recordings, generated images or diagrams, or audio clips \u2014 including in your Replicas chat reply, PR descriptions/comments, and other external platforms. Paste the printed `![\u2026](\u2026)` embeds in your chat reply, never only dashboard links, and upload the file itself to Slack, Linear, or GitLab. To show motion, turn the recording into a short GIF with `replicas media gif` instead of a grid of frames",
4592
4588
  section: SECTION8,
4593
4589
  referenceFile: { name: "MEDIA.md", content: REFERENCE8 }
4594
4590
  };
@@ -5407,6 +5403,130 @@ var SLACK_ABILITY = {
5407
5403
  referenceFile: { name: "SLACK.md", content: REFERENCE14 }
5408
5404
  };
5409
5405
 
5406
+ // ../shared/src/visuals.ts
5407
+ var VISUAL_COLUMN_WIDTH = 760;
5408
+ var VISUAL_PHONE_WIDTH = 390;
5409
+ var VISUAL_PAGE_RULES = `- Write one self-contained HTML file with inline <style> and <script>; a fragment without <html> or <head> is fine. Put data inline instead of fetching it. Libraries may load from public CDNs such as cdn.jsdelivr.net. Local images written as absolute paths (src="/abs/shot.png", url(/abs/bg.webp)) are inlined when you publish.
5410
+ - The page sits directly on the chat background, as wide as your reply (about ${VISUAL_COLUMN_WIDTH}px on desktop, ${VISUAL_PHONE_WIDTH - 30}px on phones), with its left edge aligned to your text. Leave html and body transparent, use a fluid width with no outer padding, and add no outer card, border, or title banner: the page is part of your reply.
5411
+ - Let content set the height. Never use 100vh, height:100%, or min-height:100vh on html, body, or the outer element; publishing refuses a page whose height follows the frame. Give charts fixed pixel heights.
5412
+ - Color everything with the theme variables so the page follows light and dark mode live: --foreground, --muted-foreground (secondary text), --background, --muted (subtle fills), --accent, --border, --primary and --primary-foreground (Replicas green), --destructive, --warning, --code-background, --code-foreground, and --chart-1 to --chart-6 for series (use them in order and label series directly). Never hardcode a light or dark palette. A canvas or chart library that needs literal colors can read them with getComputedStyle(document.documentElement) and redraw on matchMedia("(prefers-color-scheme: dark)") changes.
5413
+ - Text is 13px General Sans, like the chat; --font-sans and --font-mono are set. Keep Replicas' flat look: separate sections with 1px var(--border) lines or var(--muted) fills, without shadows or rounded cards. Use var(--radius) only on small controls.
5414
+ - Interaction is welcome: hover details, tabs, toggles, sliders. Links open in a new browser tab.
5415
+ - Keep the top-right corner (about 110\xD740px) free of anything essential: the chat shows the visual's actions there on hover.`;
5416
+ var THEME_FRAGMENT_KEY = "replicas-theme";
5417
+ var HOST_CONTEXT_CHANGED_METHOD = "ui/notifications/host-context-changed";
5418
+ var SIZE_CHANGED_METHOD = "ui/notifications/size-changed";
5419
+ var OPEN_LINK_METHOD = "ui/open-link";
5420
+ var VISUAL_CONTENT_HEIGHT_EXPRESSION = "(function(){var r=document.documentElement;return Math.ceil(r.scrollHeight>r.clientHeight?r.scrollHeight:r.getBoundingClientRect().height)})()";
5421
+ var BASE_CSS = "html{color:var(--foreground);font-family:var(--font-sans);font-size:13px;line-height:1.5;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-text-size-adjust:100%;scrollbar-width:none}html::-webkit-scrollbar{display:none}body{margin:0}:where(*,*::before,*::after){box-sizing:border-box}code,kbd,pre,samp{font-family:var(--font-mono)}:where(:focus-visible){outline:2px solid var(--ring);outline-offset:-2px}";
5422
+ var THEME_STYLE_ID = "replicas-visual-theme";
5423
+ var BOOTSTRAP_SCRIPT = `
5424
+ (() => {
5425
+ const style = document.getElementById('${THEME_STYLE_ID}');
5426
+ const nativeView = window.ReactNativeWebView;
5427
+ const framed = window.parent !== window;
5428
+ const post = (message) => nativeView ? nativeView.postMessage(JSON.stringify(message)) : window.parent.postMessage(message, '*');
5429
+ const applyTheme = (theme) => {
5430
+ const variables = Object.entries(theme.variables).map(([name, value]) => name + ':' + value + ';').join('');
5431
+ const font = theme.fontUrl ? '@font-face{font-family:"General Sans";src:url("' + theme.fontUrl + '") format("woff2");font-weight:200 700;font-display:swap}' : '';
5432
+ style.textContent = ':root{color-scheme:' + theme.appearance + ';' + variables + '}' + font + ${JSON.stringify(BASE_CSS)};
5433
+ };
5434
+ try {
5435
+ const fragment = /[#&]${THEME_FRAGMENT_KEY}=([^&]*)/.exec(location.hash);
5436
+ if (fragment) {
5437
+ applyTheme(JSON.parse(decodeURIComponent(fragment[1])));
5438
+ history.replaceState(history.state, '', location.pathname + location.search);
5439
+ }
5440
+ } catch {}
5441
+ if (!nativeView) {
5442
+ document.addEventListener('click', (event) => {
5443
+ const anchor = event.isTrusted && event.composedPath().find((target) => target instanceof Element && target.matches('a[href]'));
5444
+ if (!anchor) return;
5445
+ const url = new URL(anchor.getAttribute('href'), document.baseURI);
5446
+ if (!/^https?:$/.test(url.protocol) || url.href.split('#')[0] === location.href.split('#')[0]) return;
5447
+ if (framed) {
5448
+ event.preventDefault();
5449
+ post({ jsonrpc: '2.0', method: '${OPEN_LINK_METHOD}', params: { url: url.href } });
5450
+ } else {
5451
+ anchor.setAttribute('target', '_blank');
5452
+ anchor.setAttribute('rel', 'noopener');
5453
+ }
5454
+ }, true);
5455
+ }
5456
+ if (!framed && !nativeView) return;
5457
+ let reportedHeight;
5458
+ const reportHeight = () => {
5459
+ const height = ${VISUAL_CONTENT_HEIGHT_EXPRESSION};
5460
+ if (height === reportedHeight) return;
5461
+ reportedHeight = height;
5462
+ post({ jsonrpc: '2.0', method: '${SIZE_CHANGED_METHOD}', params: { height } });
5463
+ };
5464
+ window.addEventListener('message', (event) => {
5465
+ if (event.source !== window.parent || event.data?.method !== '${HOST_CONTEXT_CHANGED_METHOD}') return;
5466
+ const { theme, styles, fontUrl } = event.data.params;
5467
+ applyTheme({ appearance: theme, variables: styles.variables, fontUrl });
5468
+ reportedHeight = undefined;
5469
+ if (document.readyState !== 'loading') reportHeight();
5470
+ });
5471
+ const resizeObserver = new ResizeObserver(reportHeight);
5472
+ resizeObserver.observe(document.documentElement);
5473
+ document.addEventListener('DOMContentLoaded', () => {
5474
+ resizeObserver.observe(document.body);
5475
+ reportHeight();
5476
+ });
5477
+ window.addEventListener('load', reportHeight);
5478
+ })();
5479
+ `.trim().replace(/\s*\n\s*/g, " ");
5480
+
5481
+ // ../shared/src/default-skills/replicas-agent/abilities/visuals.ts
5482
+ var SECTION15 = `### Visuals
5483
+ Show a chart, diagram, comparison, timeline, or mockup inline in your Replicas chat reply, in the chat's own font and colors.
5484
+
5485
+ **Reference:** \`references/VISUALS.md\`
5486
+
5487
+ Use this when:
5488
+ - Seeing it would explain faster than reading it: numbers over time, a flow or architecture, a before and after, options side by side
5489
+ - The user asks to see, chart, plot, compare, or visualize something`;
5490
+ var REFERENCE15 = `# Visuals
5491
+
5492
+ A visual is a self-contained HTML page shown inline in your Replicas chat reply. It sits on the chat background in the chat's font and colors, grows to fit its content, and follows the user's light or dark theme live.
5493
+
5494
+ ## When to make one
5495
+
5496
+ Make one when seeing beats reading: how parts of a system connect, how a request or data flows, numbers or options compared, a timeline, a before and after, or a UI mockup. Make one when the user asks to see, chart, compare, sketch, or visualize something. Never draw these as ASCII art or text diagrams.
5497
+
5498
+ Don't make one when:
5499
+ - A short answer or list covers it.
5500
+ - It is a plain table: write a Markdown table.
5501
+ - It is screenshots, or a before and after of them: upload them as images, which readers can open full screen and zoom. See "Before and after" in \`references/MEDIA.md\`.
5502
+ - The user wants a page, site, or component in their project: build that in the repo.
5503
+
5504
+ ## Make it
5505
+
5506
+ 1. Write the page, for example \`/tmp/visuals/<name>.html\`, following the page rules below.
5507
+ 2. Run \`replicas visualize <page.html> --title "<short title>"\`. It checks the page in a headless browser, publishes it, and prints two screenshots (dark at desktop width, light at phone width) with any console errors and layout warnings.
5508
+ 3. Open both screenshots and look. If anything is wrong, fix the page and publish again, then use the newest line. While iterating, \`replicas visualize <page.html> --check\` renders without publishing.
5509
+ 4. Paste the printed \`![\u2026](\u2026)\` line on its own line where the visual belongs in your final reply.
5510
+
5511
+ ## Page rules
5512
+
5513
+ ${VISUAL_PAGE_RULES}
5514
+
5515
+ ## In your reply
5516
+
5517
+ - The user sees the visual itself. Don't introduce it ("Here's a chart", "Here's the diagram"), say where it is, or restate its data. Add only what it doesn't say, such as the takeaway or a caveat.
5518
+ - Paste the line in your final reply, not in a progress update. To change a visual, edit the page, publish it again, and paste the new line.
5519
+ - The line only renders in Replicas chat. When you post to pull requests, Slack, Linear, or anywhere else, link the printed Forge link instead. Leave the Forge link out of your chat reply.
5520
+ `;
5521
+ var VISUALS_ABILITY = {
5522
+ label: "Visuals",
5523
+ description: "Show charts, diagrams, comparisons, and mockups inline in chat replies.",
5524
+ // The visuals_instructions system prompt block is its trigger.
5525
+ bullet: "",
5526
+ section: SECTION15,
5527
+ referenceFile: { name: "VISUALS.md", content: REFERENCE15 }
5528
+ };
5529
+
5410
5530
  // ../shared/src/default-skills/replicas-agent/registry.ts
5411
5531
  var REPLICAS_AGENT_ABILITY_REGISTRY = {
5412
5532
  replicas: REPLICAS_ABILITY,
@@ -5422,7 +5542,8 @@ var REPLICAS_AGENT_ABILITY_REGISTRY = {
5422
5542
  plugins: PLUGINS_ABILITY,
5423
5543
  previews: PREVIEWS_ABILITY,
5424
5544
  sentry: SENTRY_ABILITY,
5425
- slack: SLACK_ABILITY
5545
+ slack: SLACK_ABILITY,
5546
+ visuals: VISUALS_ABILITY
5426
5547
  };
5427
5548
  var REPLICAS_AGENT_ABILITIES = Object.keys(
5428
5549
  REPLICAS_AGENT_ABILITY_REGISTRY
@@ -5465,6 +5586,7 @@ var DEFAULT_USER_PREFERENCES = {
5465
5586
  memory_enabled: null,
5466
5587
  subagent_mcp_enabled: null,
5467
5588
  default_fast_mode: false,
5589
+ auto_compact_tokens: null,
5468
5590
  agent_defaults: { ...EMPTY_AGENT_DEFAULT_SETTINGS },
5469
5591
  fallback_chains: null
5470
5592
  };
@@ -7944,6 +8066,7 @@ function buildCodexTokenUsageContextUsagePayload(usage) {
7944
8066
  rawMaxTokens: maxTokens,
7945
8067
  percentage: percentage(totalTokens, maxTokens),
7946
8068
  compactsAutomatically: true,
8069
+ ...autoCompactThresholdField(usage.autoCompactTokens && maxTokens && usage.autoCompactTokens < maxTokens ? percentage(usage.autoCompactTokens, maxTokens) : null),
7947
8070
  categories: compactCategories([
7948
8071
  {
7949
8072
  name: "Input context",
@@ -7959,16 +8082,6 @@ function buildCodexTokenUsageContextUsagePayload(usage) {
7959
8082
  updatedAt: usage.updatedAt
7960
8083
  };
7961
8084
  }
7962
- function resolveClaudeContextWindow(provider2, model2, reportedMaxTokens) {
7963
- if (provider2 !== "claude") {
7964
- return { maxTokens: reportedMaxTokens, usedKnownWindow: false };
7965
- }
7966
- const knownWindow = getClaudeModelContextWindow(model2);
7967
- return {
7968
- maxTokens: knownWindow ?? reportedMaxTokens,
7969
- usedKnownWindow: knownWindow !== null
7970
- };
7971
- }
7972
8085
  function coerceContextUsagePayload(payload, timestamp) {
7973
8086
  const provider2 = payload.provider;
7974
8087
  if (typeof provider2 !== "string" || !isValidAgentProvider(provider2)) return null;
@@ -7978,9 +8091,8 @@ function coerceContextUsagePayload(payload, timestamp) {
7978
8091
  return null;
7979
8092
  }
7980
8093
  const model2 = typeof payload.model === "string" ? payload.model : null;
7981
- const reportedMaxTokens = numberOrNull(payload.maxTokens);
7982
- const { maxTokens, usedKnownWindow } = resolveClaudeContextWindow(provider2, model2, reportedMaxTokens);
7983
- const rawMaxTokens = usedKnownWindow ? maxTokens : numberOrNull(payload.rawMaxTokens);
8094
+ const maxTokens = numberOrNull(payload.maxTokens);
8095
+ const rawMaxTokens = numberOrNull(payload.rawMaxTokens);
7984
8096
  const totalTokens = clampTokensToWindow(rawTotalTokens, maxTokens);
7985
8097
  const source = payload.source === "codex_token_count" || payload.source === "claude_usage" || payload.source === "provider_usage" ? payload.source : "claude_context";
7986
8098
  const categories = Array.isArray(payload.categories) ? compactCategories(payload.categories.map((item) => {
@@ -7993,7 +8105,7 @@ function coerceContextUsagePayload(payload, timestamp) {
7993
8105
  return {
7994
8106
  name,
7995
8107
  tokens,
7996
- percentage: usedKnownWindow ? percentage(tokens, maxTokens) : categoryPercentage
8108
+ percentage: categoryPercentage
7997
8109
  };
7998
8110
  })) : [];
7999
8111
  const compactsAutomatically = typeof payload.compactsAutomatically === "boolean" ? payload.compactsAutomatically : void 0;
@@ -8005,7 +8117,7 @@ function coerceContextUsagePayload(payload, timestamp) {
8005
8117
  totalTokens,
8006
8118
  maxTokens,
8007
8119
  rawMaxTokens,
8008
- percentage: usedKnownWindow ? percentage(totalTokens, maxTokens) : clampPercentage(percentageValue),
8120
+ percentage: clampPercentage(percentageValue),
8009
8121
  ...compactsAutomatically !== void 0 ? { compactsAutomatically } : {},
8010
8122
  ...autoCompactThreshold !== null ? { autoCompactThreshold } : {},
8011
8123
  categories,
@@ -8029,6 +8141,7 @@ function codexTokenCountToContextUsage(event) {
8029
8141
  totalTokens: numberOrNull(lastUsage.total_tokens) ?? inputTokens + outputTokens
8030
8142
  },
8031
8143
  modelContextWindow: maxTokens,
8144
+ autoCompactTokens: null,
8032
8145
  updatedAt: event.timestamp
8033
8146
  });
8034
8147
  }
@@ -10,15 +10,15 @@ import {
10
10
  resolveDiffBase,
11
11
  runGitCommand,
12
12
  setAgentCredentialSnapshot
13
- } from "./chunk-OKE4RCRY.js";
13
+ } from "./chunk-VXPWAQR2.js";
14
14
  import {
15
15
  AppServerProcess,
16
16
  buildCodexAgentEnv
17
- } from "./chunk-2YHCBP6R.js";
17
+ } from "./chunk-WIEXE5ZC.js";
18
18
  import {
19
19
  SUBPROCESS_MAX_BUFFER,
20
20
  execFileAsync
21
- } from "./chunk-2AG3DWDX.js";
21
+ } from "./chunk-R6I3LT27.js";
22
22
  import {
23
23
  isRecord
24
24
  } from "./chunk-UZSNFLDQ.js";
@@ -55,7 +55,7 @@ import {
55
55
  resolveOpenAICompatibleModelsUrl,
56
56
  splitMothershipInstructions,
57
57
  withTimeout
58
- } from "./chunk-AGNQDFJU.js";
58
+ } from "./chunk-4T2K6OBK.js";
59
59
 
60
60
  // src/managers/codex-token-manager.ts
61
61
  import { promises as fs } from "fs";
@@ -291,7 +291,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
291
291
  await this.applyCredentialUpdate(++this.credentialGeneration, async () => {
292
292
  await this.applyCredentialsResponse(data);
293
293
  setAgentCredentialSnapshot("codex", data);
294
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-PTEDR5TW.js");
294
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-J4AUGWDZ.js");
295
295
  await restartCodexAspHostIfRunning2();
296
296
  });
297
297
  await this.start(true);
@@ -313,7 +313,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
313
313
  const accountChanged = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.codex?.credentialId !== data.credentialId;
314
314
  await this.applyCredentialsResponse(data);
315
315
  if (restartOnChange && (accountChanged || CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index]))) {
316
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-PTEDR5TW.js");
316
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-J4AUGWDZ.js");
317
317
  await restartCodexAspHostIfRunning2();
318
318
  }
319
319
  setAgentCredentialSnapshot("codex", data);
@@ -1771,7 +1771,7 @@ function turnsToAspTranscript(threadId, updatedAt, sourceTurns) {
1771
1771
  });
1772
1772
  return { threadId, updatedAt, turns };
1773
1773
  }
1774
- async function buildThreadStartParams(workingDirectory, request, developerInstructions, serviceTier, subagentMcpParentChatId) {
1774
+ async function buildThreadStartParams(workingDirectory, request, developerInstructions, serviceTier, subagentMcpParentChatId, autoCompactTokens = null) {
1775
1775
  const additionalDirectories = await getAgentAdditionalDirectories();
1776
1776
  return {
1777
1777
  model: request.model ?? DEFAULT_MODEL,
@@ -1784,6 +1784,7 @@ async function buildThreadStartParams(workingDirectory, request, developerInstru
1784
1784
  config: {
1785
1785
  web_search: ENGINE_ENV.REPLICAS_CODEX_AUTH_METHOD === "ollama" ? "disabled" : "live",
1786
1786
  model_reasoning_summary: "auto",
1787
+ ...autoCompactTokens ? { model_auto_compact_token_limit: autoCompactTokens } : {},
1787
1788
  ...subagentMcpParentChatId ? {
1788
1789
  // Codex gates its native collaboration tools on `agents.enabled`; `features.multi_agent` is now a no-op.
1789
1790
  "agents.enabled": false,
@@ -1793,7 +1794,7 @@ async function buildThreadStartParams(workingDirectory, request, developerInstru
1793
1794
  experimentalRawEvents: false
1794
1795
  };
1795
1796
  }
1796
- async function buildThreadResumeParams(workingDirectory, threadId, request, developerInstructions, serviceTier, subagentMcpParentChatId) {
1797
+ async function buildThreadResumeParams(workingDirectory, threadId, request, developerInstructions, serviceTier, subagentMcpParentChatId, autoCompactTokens = null) {
1797
1798
  const additionalDirectories = await getAgentAdditionalDirectories();
1798
1799
  return {
1799
1800
  threadId,
@@ -1807,6 +1808,7 @@ async function buildThreadResumeParams(workingDirectory, threadId, request, deve
1807
1808
  config: {
1808
1809
  web_search: ENGINE_ENV.REPLICAS_CODEX_AUTH_METHOD === "ollama" ? "disabled" : "live",
1809
1810
  model_reasoning_summary: "auto",
1811
+ ...autoCompactTokens ? { model_auto_compact_token_limit: autoCompactTokens } : {},
1810
1812
  ...subagentMcpParentChatId ? {
1811
1813
  // Codex gates its native collaboration tools on `agents.enabled`; `features.multi_agent` is now a no-op.
1812
1814
  "agents.enabled": false,
@@ -5,7 +5,7 @@ import {
5
5
  extractCommandProtectionCommandText,
6
6
  isRecord,
7
7
  parseCodeHostPrUrl
8
- } from "./chunk-AGNQDFJU.js";
8
+ } from "./chunk-4T2K6OBK.js";
9
9
 
10
10
  // src/services/published-pull-request-urls.ts
11
11
  function publishedPullRequestUrls(result) {
@@ -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-2YHCBP6R.js";
6
+ } from "./chunk-WIEXE5ZC.js";
7
7
  import {
8
8
  ASTER_BASE_URL,
9
9
  ASTER_PROVIDER,
@@ -11,7 +11,7 @@ import {
11
11
  codexReasoningEffortForThinkingLevel,
12
12
  isRecord,
13
13
  readOllamaAuthEnv
14
- } from "./chunk-AGNQDFJU.js";
14
+ } from "./chunk-4T2K6OBK.js";
15
15
 
16
16
  // src/managers/codex-asp/notification-dispatch.ts
17
17
  var TURN_STARTED_METHOD = "turn/started";
@@ -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-AGNQDFJU.js";
6
+ } from "./chunk-4T2K6OBK.js";
7
7
 
8
8
  // src/utils/exec.ts
9
9
  import { exec, execFile } from "child_process";
@@ -5,14 +5,14 @@ import {
5
5
  getOriginDefaultBranch,
6
6
  monolithRequest,
7
7
  runGitCommand
8
- } from "./chunk-OKE4RCRY.js";
8
+ } from "./chunk-VXPWAQR2.js";
9
9
  import {
10
10
  extractCommandProtectionCommandText,
11
11
  findCommandProtectionGitLookups,
12
12
  findGitCommitSignals,
13
13
  findPrMergeSignals,
14
14
  parseCommandProtectionRequest
15
- } from "./chunk-AGNQDFJU.js";
15
+ } from "./chunk-4T2K6OBK.js";
16
16
 
17
17
  // src/services/command-protection-service.ts
18
18
  import { readFile, stat } from "fs/promises";
@@ -4,7 +4,7 @@ const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  SUBPROCESS_MAX_BUFFER,
6
6
  execFileAsync
7
- } from "./chunk-2AG3DWDX.js";
7
+ } from "./chunk-R6I3LT27.js";
8
8
  import {
9
9
  isRecord as isRecord2
10
10
  } from "./chunk-UZSNFLDQ.js";
@@ -18,7 +18,7 @@ import {
18
18
  isValidAgentProvider,
19
19
  parsePosixEnvFile,
20
20
  readReplicasRuntimeEnv
21
- } from "./chunk-AGNQDFJU.js";
21
+ } from "./chunk-4T2K6OBK.js";
22
22
 
23
23
  // src/runtime-env-loader.ts
24
24
  import { readFileSync } from "fs";
@@ -274,29 +274,22 @@ async function monolithRequest(path, init = {}) {
274
274
  });
275
275
  }
276
276
  var MonolithService = class {
277
- async getSubagentMcpConfig() {
277
+ async getJson(path, parse, signal) {
278
278
  try {
279
- const response = await monolithRequest("/v1/engine/subagent-mcp", { method: "GET", signal: AbortSignal.timeout(1e4) });
280
- if (!response.ok) {
281
- return null;
282
- }
283
- const body = await response.json();
284
- return isRecord(body) && typeof body.enabled === "boolean" && Array.isArray(body.providers) && body.providers.every((provider) => typeof provider === "string" && isValidAgentProvider(provider)) ? { enabled: body.enabled, providers: body.providers } : null;
279
+ const response = await monolithRequest(path, { method: "GET", signal });
280
+ return response.ok ? parse(await response.json()) : null;
285
281
  } catch {
286
282
  return null;
287
283
  }
288
284
  }
289
- async getOpenRouterModels() {
290
- try {
291
- const response = await monolithRequest("/v1/engine/openrouter-models", { method: "GET" });
292
- if (!response.ok) {
293
- return null;
294
- }
295
- const body = await response.json();
296
- return isRecord(body) && Array.isArray(body.models) && body.models.every((model) => typeof model === "string") ? body.models : null;
297
- } catch {
298
- return null;
299
- }
285
+ getSubagentMcpConfig() {
286
+ return this.getJson("/v1/engine/subagent-mcp", (body) => isRecord(body) && typeof body.enabled === "boolean" && Array.isArray(body.providers) && body.providers.every((provider) => typeof provider === "string" && isValidAgentProvider(provider)) ? { enabled: body.enabled, providers: body.providers } : null, AbortSignal.timeout(1e4));
287
+ }
288
+ getAutoCompactConfig() {
289
+ return this.getJson("/v1/engine/auto-compact", (body) => isRecord(body) && (body.tokens === null || typeof body.tokens === "number") ? { tokens: body.tokens } : null, AbortSignal.timeout(1e4));
290
+ }
291
+ getOpenRouterModels() {
292
+ return this.getJson("/v1/engine/openrouter-models", (body) => isRecord(body) && Array.isArray(body.models) && body.models.every((model) => typeof model === "string") ? body.models : null);
300
293
  }
301
294
  /** `unsupported` means an older monolith; `unavailable` means this one could not be read. */
302
295
  async getFallbackPlan(params) {
@@ -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-2AG3DWDX.js";
6
+ } from "./chunk-R6I3LT27.js";
7
7
  import {
8
8
  isVersionBelow
9
- } from "./chunk-AGNQDFJU.js";
9
+ } from "./chunk-4T2K6OBK.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.1184";
243
+ var ENGINE_PACKAGE_VERSION = "0.1.1186";
244
244
  var INITIALIZE_METHOD = "initialize";
245
245
  var INITIALIZED_NOTIFICATION = "initialized";
246
246
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -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-XG6BQ3DQ.js";
7
- import "./chunk-OKE4RCRY.js";
8
- import "./chunk-2AG3DWDX.js";
6
+ } from "./chunk-TUZLVYYH.js";
7
+ import "./chunk-VXPWAQR2.js";
8
+ import "./chunk-R6I3LT27.js";
9
9
  import {
10
10
  isRecord
11
11
  } from "./chunk-UZSNFLDQ.js";
12
- import "./chunk-AGNQDFJU.js";
12
+ import "./chunk-4T2K6OBK.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
 
15
15
  // src/command-protection-hook.ts
@@ -13,12 +13,12 @@ import {
13
13
  recoverCompletedTurn,
14
14
  spawnMuseMsp,
15
15
  startMuseSession
16
- } from "./chunk-PNIWI4J6.js";
16
+ } from "./chunk-NQOV2YOZ.js";
17
17
  import {
18
18
  AppServerProcess,
19
19
  buildCodexAgentEnv
20
- } from "./chunk-2YHCBP6R.js";
21
- import "./chunk-2AG3DWDX.js";
20
+ } from "./chunk-WIEXE5ZC.js";
21
+ import "./chunk-R6I3LT27.js";
22
22
  import {
23
23
  AGENT,
24
24
  OPENCODE_GO_PROVIDER,
@@ -28,7 +28,7 @@ import {
28
28
  headlessAgentUsagePath,
29
29
  isRecord,
30
30
  withTimeout
31
- } from "./chunk-AGNQDFJU.js";
31
+ } from "./chunk-4T2K6OBK.js";
32
32
  import "./chunk-VEQXQN22.js";
33
33
 
34
34
  // 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-XG6BQ3DQ.js";
30
+ } from "./chunk-TUZLVYYH.js";
31
31
  import {
32
32
  ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
33
33
  AGENT_MESSAGE_DELTA_METHOD,
@@ -64,10 +64,10 @@ import {
64
64
  spawnMuseMsp,
65
65
  startMuseSession,
66
66
  uuidV7
67
- } from "./chunk-PNIWI4J6.js";
67
+ } from "./chunk-NQOV2YOZ.js";
68
68
  import {
69
69
  publishedPullRequestUrls
70
- } from "./chunk-E5HOEAHV.js";
70
+ } from "./chunk-NIT22CZW.js";
71
71
  import {
72
72
  ACCOUNT_RATE_LIMITS_READ_METHOD,
73
73
  AsyncLock,
@@ -139,7 +139,7 @@ import {
139
139
  timestampFromSeconds,
140
140
  upsertCredentialFileLines,
141
141
  writeSecureCredentialFile
142
- } from "./chunk-CPHIDGPB.js";
142
+ } from "./chunk-KLHDCQAK.js";
143
143
  import {
144
144
  ENGINE_ENV,
145
145
  monolithRequest,
@@ -148,15 +148,15 @@ import {
148
148
  reloadEngineEnv,
149
149
  resolveDiffBase,
150
150
  setAgentCredentialSnapshot
151
- } from "./chunk-OKE4RCRY.js";
151
+ } from "./chunk-VXPWAQR2.js";
152
152
  import {
153
153
  getCodexModelProvider
154
- } from "./chunk-2YHCBP6R.js";
154
+ } from "./chunk-WIEXE5ZC.js";
155
155
  import {
156
156
  SUBPROCESS_MAX_BUFFER,
157
157
  execAsync,
158
158
  execFileAsync
159
- } from "./chunk-2AG3DWDX.js";
159
+ } from "./chunk-R6I3LT27.js";
160
160
  import {
161
161
  isRecord as isRecord2
162
162
  } from "./chunk-UZSNFLDQ.js";
@@ -383,7 +383,7 @@ import {
383
383
  workspaceTokenRequestSchema,
384
384
  workspaceTokenResponseSchema,
385
385
  wrapInTag
386
- } from "./chunk-AGNQDFJU.js";
386
+ } from "./chunk-4T2K6OBK.js";
387
387
  import {
388
388
  cloneMcpConfig,
389
389
  ensureCompatibilityImports,
@@ -11396,6 +11396,8 @@ var CodingAgentManager = class {
11396
11396
  authFallback;
11397
11397
  subagentMcpChatId;
11398
11398
  subagentMcpEnabledForTurn = false;
11399
+ usesAutoCompactTokens;
11400
+ autoCompactTokens = null;
11399
11401
  unreadSteers = /* @__PURE__ */ new Map();
11400
11402
  lastSenderKey;
11401
11403
  onLastSenderKeyChanged;
@@ -11410,6 +11412,7 @@ var CodingAgentManager = class {
11410
11412
  this.onUsageUpdate = options.onUsageUpdate ?? (() => {
11411
11413
  });
11412
11414
  this.subagentMcpChatId = options.parentChatId === null && options.provider && SUBAGENT_MCP_HARNESSES.includes(options.provider) ? options.chatId : void 0;
11415
+ this.usesAutoCompactTokens = options.provider === "claude" || options.provider === "codex";
11413
11416
  this.linearSessionId = options.linearSessionId;
11414
11417
  this.chatId = options.chatId;
11415
11418
  this.hostOnTurnComplete = options.onTurnComplete;
@@ -11485,7 +11488,7 @@ var CodingAgentManager = class {
11485
11488
  initializeManager(processMessage) {
11486
11489
  this.messageQueue = new MessageQueueService(
11487
11490
  async (request, signal) => {
11488
- await this.refreshSubagentMcp();
11491
+ await Promise.all([this.refreshSubagentMcp(), this.refreshAutoCompactTokens()]);
11489
11492
  if (signal.aborted) return;
11490
11493
  const { request: delivered, senderKey } = this.withSenderLine(request);
11491
11494
  await this.saveLastSenderKey(senderKey);
@@ -11523,6 +11526,11 @@ ${request.message}` }, senderKey };
11523
11526
  const config = await subagentMcpConfigRequest;
11524
11527
  if (config) this.subagentMcpEnabledForTurn = await this.subagentMcpForTurn(config.enabled);
11525
11528
  }
11529
+ async refreshAutoCompactTokens() {
11530
+ if (!this.usesAutoCompactTokens) return;
11531
+ const config = await monolithService.getAutoCompactConfig();
11532
+ if (config) this.autoCompactTokens = config.tokens;
11533
+ }
11526
11534
  /** Harnesses that fix their tool set per session override this to keep a session's original mode. */
11527
11535
  async subagentMcpForTurn(enabled) {
11528
11536
  return enabled;
@@ -13206,6 +13214,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13206
13214
  thinkingLevel,
13207
13215
  enableInteractiveTools: Boolean(enableInteractiveTools),
13208
13216
  fastMode: resolvedFastMode,
13217
+ autoCompactTokens: this.autoCompactTokens,
13209
13218
  permissionMode: resolvedPermissionMode,
13210
13219
  subagentMcpParentChatId: this.subagentMcpParentChatId()
13211
13220
  };
@@ -13307,7 +13316,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13307
13316
  });
13308
13317
  }
13309
13318
  sessionSignaturesMatch(a, b) {
13310
- return a.combinedInstructions === b.combinedInstructions && a.credential === b.credential && a.thinkingLevel === b.thinkingLevel && a.enableInteractiveTools === b.enableInteractiveTools && a.fastMode === b.fastMode && a.permissionMode === b.permissionMode && a.subagentMcpParentChatId === b.subagentMcpParentChatId;
13319
+ return a.combinedInstructions === b.combinedInstructions && a.credential === b.credential && a.thinkingLevel === b.thinkingLevel && a.enableInteractiveTools === b.enableInteractiveTools && a.fastMode === b.fastMode && a.autoCompactTokens === b.autoCompactTokens && a.permissionMode === b.permissionMode && a.subagentMcpParentChatId === b.subagentMcpParentChatId;
13311
13320
  }
13312
13321
  /** Query inputs shared by real sessions and slash-command discovery. */
13313
13322
  async buildSharedQueryOptions() {
@@ -13381,6 +13390,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13381
13390
  model: claudeCodeModel,
13382
13391
  settings: {
13383
13392
  fastMode: signature.fastMode,
13393
+ ...signature.autoCompactTokens ? { autoCompactWindow: signature.autoCompactTokens } : {},
13384
13394
  ...ultracode ? { enableWorkflows: true, ultracode: true } : {}
13385
13395
  },
13386
13396
  includePartialMessages: true,
@@ -14071,6 +14081,7 @@ var CodexAspManager = class extends CodingAgentManager {
14071
14081
  attachedClient = null;
14072
14082
  attachedModel = null;
14073
14083
  attachedDeveloperInstructions = null;
14084
+ attachedAutoCompactTokens = null;
14074
14085
  historyFile;
14075
14086
  liveTurn = null;
14076
14087
  codexSubagents = /* @__PURE__ */ new Map();
@@ -14479,16 +14490,18 @@ var CodexAspManager = class extends CodingAgentManager {
14479
14490
  if (existingThreadId) {
14480
14491
  if (this.attachedClient !== host.client || requestedModel !== this.attachedModel || (developerInstructions ?? null) !== this.attachedDeveloperInstructions) {
14481
14492
  const serviceTier2 = await this.resolveRequestedServiceTier(host, request);
14482
- const previous = this.attachedClient !== host.client ? await host.client.request(THREAD_READ_METHOD, { threadId: existingThreadId, includeTurns: true }).catch(() => null) : null;
14493
+ const coldResume = this.attachedClient !== host.client;
14494
+ const previous = coldResume ? await host.client.request(THREAD_READ_METHOD, { threadId: existingThreadId, includeTurns: true }).catch(() => null) : null;
14483
14495
  const response = previous?.thread.modelProvider && previous.thread.modelProvider !== getCodexModelProvider(ENGINE_ENV.REPLICAS_CODEX_AUTH_METHOD) ? await this.continueWithNewProvider(host, previous.thread, request, developerInstructions, serviceTier2) : await host.client.request(
14484
14496
  THREAD_RESUME_METHOD,
14485
- await buildThreadResumeParams(this.workingDirectory, existingThreadId, request, developerInstructions, serviceTier2, subagentMcpParentChatId)
14497
+ await buildThreadResumeParams(this.workingDirectory, existingThreadId, request, developerInstructions, serviceTier2, subagentMcpParentChatId, this.autoCompactTokens)
14486
14498
  );
14487
14499
  this.currentThreadId = response.thread.id;
14488
14500
  this.activeServiceTier = response.serviceTier;
14489
14501
  this.attachedClient = host.client;
14490
14502
  this.attachedModel = requestedModel;
14491
14503
  this.attachedDeveloperInstructions = developerInstructions ?? null;
14504
+ if (coldResume) this.attachedAutoCompactTokens = this.autoCompactTokens;
14492
14505
  await this.onSaveSessionId(this.currentThreadId);
14493
14506
  }
14494
14507
  return this.currentThreadId ?? existingThreadId;
@@ -14496,7 +14509,7 @@ var CodexAspManager = class extends CodingAgentManager {
14496
14509
  const serviceTier = await this.resolveRequestedServiceTier(host, request);
14497
14510
  const threadStartResponse = await host.client.request(
14498
14511
  THREAD_START_METHOD,
14499
- await buildThreadStartParams(this.workingDirectory, request, developerInstructions, serviceTier, subagentMcpParentChatId)
14512
+ await buildThreadStartParams(this.workingDirectory, request, developerInstructions, serviceTier, subagentMcpParentChatId, this.autoCompactTokens)
14500
14513
  );
14501
14514
  const threadId = threadStartResponse.thread.id;
14502
14515
  this.currentThreadId = threadId;
@@ -14504,6 +14517,7 @@ var CodexAspManager = class extends CodingAgentManager {
14504
14517
  this.attachedClient = host.client;
14505
14518
  this.attachedModel = requestedModel;
14506
14519
  this.attachedDeveloperInstructions = developerInstructions ?? null;
14520
+ this.attachedAutoCompactTokens = this.autoCompactTokens;
14507
14521
  if (subagentMcpParentChatId) await markSubagentMcpThread(threadId);
14508
14522
  await this.onSaveSessionId(this.currentThreadId);
14509
14523
  return threadId;
@@ -14517,7 +14531,7 @@ var CodexAspManager = class extends CodingAgentManager {
14517
14531
  await writeFile4(transcriptPath, text, "utf8");
14518
14532
  const response = await host.client.request(
14519
14533
  THREAD_START_METHOD,
14520
- await buildThreadStartParams(this.workingDirectory, request, developerInstructions, serviceTier, this.subagentMcpParentChatId())
14534
+ await buildThreadStartParams(this.workingDirectory, request, developerInstructions, serviceTier, this.subagentMcpParentChatId(), this.autoCompactTokens)
14521
14535
  );
14522
14536
  await host.client.request(THREAD_INJECT_ITEMS_METHOD, {
14523
14537
  threadId: response.thread.id,
@@ -15160,6 +15174,7 @@ ${text.slice(-24e3)}`
15160
15174
  const payload = buildCodexTokenUsageContextUsagePayload({
15161
15175
  model,
15162
15176
  modelContextWindow: tokenUsage.modelContextWindow,
15177
+ autoCompactTokens: this.attachedAutoCompactTokens,
15163
15178
  last: {
15164
15179
  inputTokens: tokenUsage.last.inputTokens,
15165
15180
  outputTokens: tokenUsage.last.outputTokens,
@@ -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-E5HOEAHV.js";
6
+ } from "./chunk-NIT22CZW.js";
7
7
  import {
8
8
  isRecord
9
9
  } from "./chunk-UZSNFLDQ.js";
10
10
  import {
11
11
  shouldRefreshPullRequests
12
- } from "./chunk-AGNQDFJU.js";
12
+ } from "./chunk-4T2K6OBK.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
 
15
15
  // src/services/post-tool-pr-notifier.ts
@@ -9,7 +9,7 @@ import {
9
9
  spawnSubagentRequestSchema,
10
10
  subagentResponseSchema,
11
11
  waitSubagentRequestSchema
12
- } from "./chunk-AGNQDFJU.js";
12
+ } from "./chunk-4T2K6OBK.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
 
15
15
  // src/subagent-mcp.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.1184",
3
+ "version": "0.1.1186",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",