Skip to content

chore: sync upstream orchestration V2 and rebuild the embedded runtime - #6

Merged
onmax merged 1244 commits into
mainfrom
sync/orchestration-v2
Oct 3, 2026
Merged

onmax merged 1244 commits into
mainfrom
sync/orchestration-v2

Conversation

@onmax

@onmax onmax commented Oct 3, 2026

Copy link
Copy Markdown
Member

Summary

The daily upstream sync has failed since 2026-09-25 because upstream merged orchestration V2 (pingdotgg#2829), which deleted the V1 ClaudeAdapter, CodexAdapter, and ProviderAdapter modules the embedded @t3tools/provider-runtime wrapped. This PR merges upstream/main (1238 commits) and rebuilds the runtime on the V2 adapters while keeping the host contract stable.

  • Merge: upstream main through fix(server): runs no longer get stuck (#15048). Fork-owned workflows, the publishable @t3tools/contracts manifest, and the Claude SDK staging rules are preserved; the fork's edits to the deleted V1 adapters are dropped.
  • Runtime: createProviderRuntime creates ClaudeAdapterV2 / CodexAdapterV2 instances. startSession opens a V2 session and thread, sendTurn starts a run or steers the active one, interruptTurn waits for the provider turn id. The new legacy-events.ts translates ProviderAdapterV2Event into the flat ProviderRuntimeEvent stream hosts consume (item.*, content.delta, request.*, user-input.*, turn.completed, turn.aborted, thread.token-usage.updated, task.*). The resume cursor is now the encoded OrchestrationV2ProviderThread; older cursors start a fresh thread.
  • Fork adaptations moved to V2: ClaudeAdapterV2 loads the Claude SDK on first use (Codex-only hosts do not install it), guarded by ClaudeAdapterV2.lazy.test.ts. OrchestrationV2RpcSchemas and WsRpcGroup get explicit type annotations because their inferred types exceed the declaration serialization limit (TS7056); two Codex interfaces are exported so the bundle's declarations can name them.
  • Includes fix(provider-runtime): import bundled Node builtins through ESM #5 (ESM Node builtins) as a cherry-pick so the published artifact works in Workers.
  • The pack hooks remove the .d.ts files the TypeScript 7 generator writes beside server sources.
  • sync-upstream.yml verifies the V2 lazy test instead of the deleted adapter tests; docs/internals/embedded-provider-runtime.md describes the V2 mapping.

Validation

  • vp run --filter @t3tools/contracts build and typecheck
  • vp run --filter @t3tools/provider-runtime build (bundle externals: effect/*, node:*, @t3tools/contracts; no __require("process"|"buffer"); no stray declarations)
  • tsc --noEmit in packages/provider-runtime
  • vp test run packages/provider-runtime/src apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.lazy.test.ts (21 tests, including the packed-artifact consumer test)
  • vp test run apps/server/src/provider/Layers/ProviderRegistry.test.ts apps/server/src/provider/Layers/codexUsageLimits.test.ts apps/server/src/provider/Layers/claudeUsageLimits.test.ts scripts/lib/cli-external-packages.test.ts (103 tests)
  • vp lint and vp fmt --check on the changed files

Not verified: a live Claude or Codex turn through the new runtime. The vitehub consumer bump will exercise it.

juliusmarminge and others added 30 commits September 24, 2026 13:35
…dotgg#13389)

Co-authored-by: javiergusart <42075376+javiergusart@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…otgg#13480)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…gg#13481)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ingdotgg#13506)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ngdotgg#13504)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: t3-code[bot] <269035359+t3-code[bot]@users.noreply.github.com>
Co-authored-by: Utkarsh Patil <73941998+UtkarshUsername@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…dotgg#12006)

Desktop updates deleted the managed tunnel at shutdown, so remote clients spent about two minutes reconnecting after an 11 second restart. The desktop app now writes a restart marker before it stops its backends for any install, local or remote. The server keeps the tunnel when it finds a fresh marker at shutdown and consumes it. Failed or interrupted installs delete the marker.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Co-authored-by: Julius Marminge <51714798+juliusmarminge@users.noreply.github.com>
… showcase (pingdotgg#13522)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…13523)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…dotgg#13474)

Co-authored-by: Julius Marminge <julius0216@outlook.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Pin each terminal status pulse to the document timeline when it starts, so running-terminal icons in both sidebars and the command palette share one cycle. Terminal pulses now respect prefers-reduced-motion.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…mits (pingdotgg#12799)

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
…ss environments (pingdotgg#12588)

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: macroscopeapp[bot] <170038800+macroscopeapp[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…tgg#13548)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…scroll (pingdotgg#13555)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…eads (pingdotgg#13551)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…gdotgg#13547)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…3534)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…gdotgg#13558)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…in (pingdotgg#13553)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…gg#13554)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
t3dotgg and others added 18 commits October 2, 2026 22:16
…retries back off (pingdotgg#15034)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…otgg#15041)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… path (pingdotgg#15021)

Co-authored-by: maria-rcks <254055478+maria-rcks@users.noreply.github.com>
pingdotgg#15005)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ngdotgg#15055)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…thread (pingdotgg#15050)

Co-authored-by: maria-rcks <254055478+maria-rcks@users.noreply.github.com>
…gdotgg#15059)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…gg#15101)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…waiting (pingdotgg#15114)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…dotgg#15060)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…tgg#15108)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Merge pingdotgg/t3code main. Upstream replaced the V1 provider adapters with
orchestration-v2 adapters, so the fork's Claude and Codex adapter patches are
dropped with the deleted files. Fork-owned workflows, the publishable contracts
manifest, and the Claude SDK staging rules are preserved. The embedded
provider-runtime is rebuilt on the V2 adapters in the next commit.
… V2 adapters

Upstream deleted the V1 Claude and Codex adapters the embedded runtime wrapped.
The runtime now creates ClaudeAdapterV2 and CodexAdapterV2 instances and keeps
the host contract: startSession opens a V2 session and thread, sendTurn starts a
run or steers the active one, and interruptTurn waits for the provider turn id.
A new legacy-events module translates ProviderAdapterV2Event into the flat
ProviderRuntimeEvent stream hosts consume. The resume cursor is the encoded
OrchestrationV2ProviderThread; older cursors start a fresh thread.

Fork adaptations move with upstream: ClaudeAdapterV2 loads the Claude SDK on
first use so Codex-only hosts do not install it, and a lazy-load test guards the
import graph. The contracts package keeps publishing declaration files with
explicit annotations for OrchestrationV2RpcSchemas and WsRpcGroup (TS7056), and
two Codex interfaces are exported so the runtime bundle can name them. The sync
workflow verifies the V2 lazy test instead of the deleted adapter tests.
The TypeScript 7 declaration generator writes a .d.ts next to every server
source the runtime bundle visits, and the pack options cannot redirect it.
The pack hooks record the declaration files that exist before a build and
delete the ones the build added.
@vite-hub

vite-hub Bot commented Oct 3, 2026

Copy link
Copy Markdown

Waiting to start.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-03T10:30:46.247718Z cb8ae81 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added the vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. label Oct 3, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

💡 Codex Review

const runtimePolicy: ProviderAdapterV2RuntimePolicy = {
runtimeMode: runtimeMode ?? "full-access",
interactionMode: "default",
cwd: sessionInput.cwd ?? cwd,
...(sessionInput.approvalPolicy === undefined
? {}
: { approvalPolicy: sessionInput.approvalPolicy }),

P1 Badge Preserve explicit sandbox restrictions

When an existing host passes sandboxMode: "read-only" or "workspace-write", the value remains in sessionInput but is never translated into runtimePolicy.sandboxPolicy; the replacement API also removes it from ProviderRuntimeStartInput. Consequently the default runtimeMode selects full access, so previously sandboxed embedded sessions can now write files and execute unrestricted commands. Map the legacy sandbox mode into the V2 policy rather than silently discarding it.


if (resumeThread === undefined || resumeThread.id !== providerThread.id) {
try {
await options.sessionStore?.set(threadId, resumeCursorFor(session));

P2 Badge Persist explicitly supplied resume cursors

When a host seeds a configured sessionStore with an explicit valid resumeCursor, a successful resume normally returns the same provider-thread ID, making this condition false and leaving the store empty. After the runtime is restarted without passing the cursor again, startSession cannot recover it and creates a fresh provider thread, losing the conversation that the store was intended to preserve. The current cursor should still be written when it originated from the call rather than the store.


const run = this.#runsByProviderTurnId.get(event.providerTurnId) ?? this.activeRun;
if (run === undefined || run.terminal) return [];
run.terminal = true;
if (this.#activeRun === run) this.#activeRun = undefined;

P2 Badge Release completed-turn translation state

For a long-lived embedded session, every completed turn remains in all three run maps, while its nodes, items, requests, and completed subagents likewise remain in their registries; terminalization only flips a flag and clears #activeRun. Repeated turns and tool calls therefore make memory usage grow for the lifetime of the session. Remove state that can no longer receive updates, while retaining only genuinely active background-task state.

AGENTS.md reference: AGENTS.md:L15-L17

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

pnpm pack cannot resolve a workspace dependency on the private shared
package, which failed the preview publish. The runtime imports the host
environment reference through the repository path instead.
@chatgpt-codex-connector

Copy link
Copy Markdown

💡 Codex Review


P1 Badge Preserve turn ordinals when resuming a session

When a host recreates the runtime from a resumeCursor or sessionStore, this resets the ordinal to zero, so the next sendTurn derives the same runId/turnId as the thread's original first turn. Besides colliding with IDs already persisted by the host, Claude receives providerTurnOrdinal: 1; ClaudeAdapterV2 uses an ordinal greater than one to recognize a persisted session, so a normal restart can try to create the existing fixed session ID instead of resuming it and fail with a session-already-in-use error. The resume cursor needs to preserve the next ordinal or the runtime must otherwise initialize resumed sessions past their prior turns.


return legacySession(session);

P1 Badge Emit lifecycle events when starting embedded sessions

For both providers, a successful startSession now returns without enqueueing the session.started and thread.started events that the removed V1 adapters emitted as part of the published ProviderRuntimeEvent contract. LegacyEventTranslator cannot synthesize either event from the initial session/thread rows, so external hosts that wait for these lifecycle events to mark the session ready or record the provider thread ID will wait indefinitely even though startSession succeeded.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@pkg-pr-new

pkg-pr-new Bot commented Oct 3, 2026

Copy link
Copy Markdown

Open in StackBlitz

pnpm add https://pkg.pr.new/vite-hub/t3code/@t3tools/contracts@6
pnpm add https://pkg.pr.new/vite-hub/t3code/@t3tools/provider-runtime@6

commit: cb8ae81

The Claude V2 adapter resumes a native session only when the provider turn
ordinal is above one. A resumed embedded session started counting at zero, so
the first turn after a restart opened a new session with the stored session id
and failed. The run ordinal now continues from the resumed thread, and the
cursor returned by sendTurn records the started run so hosts that persist it
before the turn settles can resume. Verified with live Codex and Claude turns:
reply, restart, resume with memory, and interrupt.
@onmax
onmax merged commit 610d58f into main Oct 3, 2026
1 check passed
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

This branch was successfully deployed

No deployments
production — 610d58f5 Deployed Oct 3, 2026 by onmax via Deploy production relay #18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.