Compare commits
73
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
05f4cb216b | ||
|
|
e06782cb9f | ||
|
|
e3c98ba52a | ||
|
|
12d7a5c411 | ||
|
|
daf4b31fbf | ||
|
|
7d5b896962 | ||
|
|
a535aec704 | ||
|
|
ef976af7cd | ||
|
|
02132281da | ||
|
|
0789b38663 | ||
|
|
8d9bc7c2cf | ||
|
|
a2ee346b78 | ||
|
|
a01aaa305a | ||
|
|
6df3c425f0 | ||
|
|
d4f823f58d | ||
|
|
bf0712219e | ||
|
|
576dc73d5f | ||
|
|
7d2e2b381d | ||
|
|
0c4999b764 | ||
|
|
3f503ccaf0 | ||
|
|
da30070d9e | ||
|
|
ede96cebf0 | ||
|
|
8572ca2d05 | ||
|
|
1f9ea614d2 | ||
|
|
13c113fcbb | ||
|
|
9a115a8055 | ||
|
|
1d4ccdbe45 | ||
|
|
ed2c4bd856 | ||
|
|
b5d5b3905d | ||
|
|
b39480a3fb | ||
|
|
0ccc40a4b5 | ||
|
|
d715c3a03e | ||
|
|
7c5a543fff | ||
|
|
196f3312ba | ||
|
|
78e6125cfe | ||
|
|
d096cb85e1 | ||
|
|
43b64bf17d | ||
|
|
4f47f33ec5 | ||
|
|
fd65a358e6 | ||
|
|
e80564813e | ||
|
|
7c0ccb54ff | ||
|
|
cfae88fbc2 | ||
|
|
b3151013fc | ||
|
|
f3bbd398f7 | ||
|
|
0f9f0f241c | ||
|
|
222294d541 | ||
|
|
a5a5246426 | ||
|
|
13e7249b3b | ||
|
|
9bb6ab317a | ||
|
|
a4cc4d50b5 | ||
|
|
5b7e114d77 | ||
|
|
a32a7aea52 | ||
|
|
b51fd9496b | ||
|
|
f087c61980 | ||
|
|
94116dab62 | ||
|
|
86608b13b3 | ||
|
|
1d640270c9 | ||
|
|
290d098725 | ||
|
|
a0d86e42ed | ||
|
|
84892adf1d | ||
|
|
365dd15aad | ||
|
|
b2ef4795c3 | ||
|
|
d305e9839e | ||
|
|
78cf175145 | ||
|
|
28f933373d | ||
|
|
148b1da274 | ||
|
|
0b8e994325 | ||
|
|
8ed1217ef8 | ||
|
|
a17ea27d10 | ||
|
|
0382f4def9 | ||
|
|
2e06f7c8dc | ||
|
|
fa0dcca41f | ||
|
|
49a07aeed9 |
No files matched your search
@@ -1,546 +0,0 @@
|
||||
# Plan: Claude Code Integration (Orchestration Architecture)
|
||||
|
||||
## Why this plan was rewritten
|
||||
|
||||
The previous plan targeted a pre-orchestration architecture (`ProviderManager`, provider-native WS event methods, and direct provider UI wiring). The current app now routes everything through:
|
||||
|
||||
1. `orchestration.dispatchCommand` (client intent)
|
||||
2. `OrchestrationEngine` (decide + persist + publish domain events)
|
||||
3. `ProviderCommandReactor` (domain intent -> `ProviderService`)
|
||||
4. `ProviderService` (adapter routing + canonical runtime stream)
|
||||
5. `ProviderRuntimeIngestion` (provider runtime -> internal orchestration commands)
|
||||
6. `orchestration.domainEvent` (single push channel consumed by web)
|
||||
|
||||
Claude integration must plug into this path instead of reintroducing legacy provider-specific flows.
|
||||
|
||||
---
|
||||
|
||||
## Current constraints to design around
|
||||
|
||||
1. Provider runtime ingestion expects canonical `ProviderRuntimeEvent` shapes, not provider-native payloads.
|
||||
2. `ProviderService.startSession` currently defaults to `provider: "codex"` unless explicitly provided.
|
||||
3. `thread.turn.start` has no provider field today, so first-turn provider selection cannot be explicitly requested.
|
||||
4. `ProviderService` requires adapter `startSession()` to return a `ProviderSession` with `threadId`.
|
||||
5. Checkpoint revert currently calls `providerService.rollbackConversation()`, so Claude adapter needs a rollback strategy compatible with current reactor behavior.
|
||||
6. Web currently marks Claude as unavailable (`"Claude Code (soon)"`) and model picker is Codex-only.
|
||||
|
||||
---
|
||||
|
||||
## Architecture target
|
||||
|
||||
Add Claude as a first-class provider adapter that emits canonical runtime events and works with existing orchestration reactors without adding new WS channels or bypass paths.
|
||||
|
||||
Key decisions:
|
||||
|
||||
1. Keep orchestration provider-agnostic; adapt Claude inside adapter/layer boundaries.
|
||||
2. Use the existing canonical runtime stream (`ProviderRuntimeEvent`) as the only ingestion contract.
|
||||
3. Keep provider session routing in `ProviderService` and `ProviderSessionDirectory`.
|
||||
4. Add explicit provider selection to turn-start intent so first turn can start Claude session intentionally.
|
||||
|
||||
---
|
||||
|
||||
## Phase 1: Contracts and command shape updates
|
||||
|
||||
### 1.1 Provider-aware model contract
|
||||
|
||||
Update `packages/contracts/src/model.ts` so model resolution can be provider-aware instead of Codex-only.
|
||||
|
||||
Expected outcomes:
|
||||
|
||||
1. Introduce provider-scoped model lists (Codex + Claude).
|
||||
2. Add helpers that resolve model by provider.
|
||||
3. Preserve backwards compatibility for existing Codex defaults.
|
||||
|
||||
### 1.2 Turn-start provider intent
|
||||
|
||||
Update `packages/contracts/src/orchestration.ts`:
|
||||
|
||||
1. Add optional `provider: ProviderKind` to `ThreadTurnStartCommand`.
|
||||
2. Carry provider through `ThreadTurnStartRequestedPayload`.
|
||||
3. Keep existing command valid when provider is omitted.
|
||||
|
||||
This removes the implicit “Codex unless session already exists” behavior as the only path.
|
||||
|
||||
### 1.3 Provider session start input for Claude runtime knobs
|
||||
|
||||
Update `packages/contracts/src/provider.ts`:
|
||||
|
||||
1. Extend `ProviderSessionStartInput` with optional Claude-specific fields (for example `claudeBinaryPath`, `permissionMode`, `maxThinkingTokens`).
|
||||
2. Keep fields optional so current call sites remain valid.
|
||||
3. Continue using generic `resumeThreadId` + `resumeCursor` as the cross-provider recovery mechanism.
|
||||
|
||||
### 1.4 Contract tests
|
||||
|
||||
Update/add tests in `packages/contracts/src/*.test.ts` for:
|
||||
|
||||
1. New command payload shape.
|
||||
2. Provider-aware model resolution behavior.
|
||||
3. Backward compatibility of existing command/schema decoding.
|
||||
|
||||
---
|
||||
|
||||
## Phase 2: Claude adapter implementation
|
||||
|
||||
### 2.1 Add adapter service + layer
|
||||
|
||||
Create:
|
||||
|
||||
1. `apps/server/src/provider/Services/ClaudeCodeAdapter.ts`
|
||||
2. `apps/server/src/provider/Layers/ClaudeCodeAdapter.ts`
|
||||
|
||||
Adapter must implement `ProviderAdapterShape<ProviderAdapterError>`.
|
||||
|
||||
### 2.1.a SDK dependency and baseline config
|
||||
|
||||
Add server dependency:
|
||||
|
||||
1. `@anthropic-ai/claude-agent-sdk`
|
||||
|
||||
Baseline adapter options to support from day one:
|
||||
|
||||
1. `cwd`
|
||||
2. `model`
|
||||
3. `pathToClaudeCodeExecutable` (from `claudeBinaryPath`)
|
||||
4. `permissionMode`
|
||||
5. `maxThinkingTokens`
|
||||
6. `resume`
|
||||
7. `resumeSessionAt`
|
||||
8. `includePartialMessages`
|
||||
9. `canUseTool`
|
||||
10. `hooks`
|
||||
11. `env` and `additionalDirectories` (if needed for sandbox/workspace parity)
|
||||
|
||||
### 2.2 Claude runtime bridge
|
||||
|
||||
Implement a Claude runtime bridge (either directly in adapter layer or via dedicated manager file) that wraps Agent SDK query lifecycle.
|
||||
|
||||
Required capabilities:
|
||||
|
||||
1. Long-lived session context per adapter session.
|
||||
2. Multi-turn input queue.
|
||||
3. Interrupt support.
|
||||
4. Approval request/response bridge.
|
||||
5. Resume support via `resumeThreadId` / `resumeCursor`.
|
||||
|
||||
#### 2.2.a Agent SDK details to preserve
|
||||
|
||||
The adapter should explicitly rely on these SDK capabilities:
|
||||
|
||||
1. `query()` returns an async iterable message stream and control methods (`interrupt`, `setModel`, `setPermissionMode`, `setMaxThinkingTokens`, account/status helpers).
|
||||
2. Multi-turn input is supported via async-iterable prompt input.
|
||||
3. Tool approval decisions are provided via `canUseTool`.
|
||||
4. Resume support uses `resume` and optional `resumeSessionAt`.
|
||||
5. Hooks can be used for lifecycle signals (`Stop`, `PostToolUse`, etc.) when we need adapter-originated checkpoint/runtime events.
|
||||
|
||||
#### 2.2.b Effect-native session lifecycle skeleton
|
||||
|
||||
```ts
|
||||
import { query } from "@anthropic-ai/claude-agent-sdk";
|
||||
import { Effect } from "effect";
|
||||
|
||||
const acquireSession = (input: ProviderSessionStartInput) =>
|
||||
Effect.acquireRelease(
|
||||
Effect.tryPromise({
|
||||
try: async () => {
|
||||
const abortController = new AbortController();
|
||||
const result = query({
|
||||
prompt: makePromptAsyncIterable(input.sessionId),
|
||||
options: {
|
||||
cwd: input.cwd,
|
||||
model: input.model,
|
||||
permissionMode: input.permissionMode,
|
||||
maxThinkingTokens: input.maxThinkingTokens,
|
||||
pathToClaudeCodeExecutable: input.claudeBinaryPath,
|
||||
resume: input.resumeThreadId,
|
||||
resumeSessionAt: readResumeCursor(input.resumeCursor),
|
||||
signal: abortController.signal,
|
||||
includePartialMessages: true,
|
||||
canUseTool: makeCanUseTool(input.sessionId),
|
||||
hooks: makeClaudeHooks(input.sessionId),
|
||||
},
|
||||
});
|
||||
return { abortController, result };
|
||||
},
|
||||
catch: (cause) =>
|
||||
new ProviderAdapterProcessError({
|
||||
provider: "claudeCode",
|
||||
sessionId: "pending",
|
||||
detail: "Failed to start Claude runtime session.",
|
||||
cause,
|
||||
}),
|
||||
}),
|
||||
({ abortController }) => Effect.sync(() => abortController.abort()),
|
||||
);
|
||||
```
|
||||
|
||||
#### 2.2.c AsyncIterable -> Effect Stream integration
|
||||
|
||||
Preferred when available in the pinned Effect version:
|
||||
|
||||
```ts
|
||||
const sdkMessageStream = Stream.fromAsyncIterable(
|
||||
session.result,
|
||||
(cause) =>
|
||||
new ProviderAdapterProcessError({
|
||||
provider: "claudeCode",
|
||||
sessionId,
|
||||
detail: "Claude runtime stream failed.",
|
||||
cause,
|
||||
}),
|
||||
);
|
||||
```
|
||||
|
||||
Portable fallback (already aligned with current server patterns):
|
||||
|
||||
```ts
|
||||
const queue = yield* Queue.unbounded<ClaudeSdkMessage>();
|
||||
yield* Effect.forkScoped(
|
||||
Effect.tryPromise({
|
||||
try: async () => {
|
||||
for await (const message of session.result) {
|
||||
Queue.offerAllUnsafe(queue, [message]);
|
||||
}
|
||||
},
|
||||
catch: (cause) =>
|
||||
new ProviderAdapterProcessError({
|
||||
provider: "claudeCode",
|
||||
sessionId,
|
||||
detail: "Claude runtime stream pump failed.",
|
||||
cause,
|
||||
}),
|
||||
}),
|
||||
);
|
||||
const sdkMessageStream = Stream.fromQueue(queue);
|
||||
```
|
||||
|
||||
#### 2.2.d Multi-turn prompt queue pattern (Effect)
|
||||
|
||||
Use an Effect queue as the single input boundary:
|
||||
|
||||
```ts
|
||||
const promptQueue = yield* Queue.unbounded<ClaudePromptEnvelope>();
|
||||
|
||||
const prompt: AsyncIterable<ClaudePromptEnvelope> = {
|
||||
[Symbol.asyncIterator]() {
|
||||
return {
|
||||
next: async () => {
|
||||
const item = await Effect.runPromise(Queue.take(promptQueue));
|
||||
if (item.type === "terminate") {
|
||||
return { done: true, value: undefined };
|
||||
}
|
||||
return { done: false, value: item };
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
`sendTurn()` enqueues a user envelope, while `stopSession()` enqueues terminate and aborts.
|
||||
|
||||
#### 2.2.e Approval bridge with `canUseTool`
|
||||
|
||||
Map SDK approval checks to existing orchestration approval flows:
|
||||
|
||||
```ts
|
||||
const canUseTool = async (toolName: string, toolInput: Record<string, unknown>) => {
|
||||
if (approvalModeIsFullAccess(sessionId)) {
|
||||
return { behavior: "allow", updatedInput: toolInput };
|
||||
}
|
||||
|
||||
const requestId = ApprovalRequestId.makeUnsafe(crypto.randomUUID());
|
||||
emitRuntimeEvent({
|
||||
type: "approval.requested",
|
||||
provider: "claudeCode",
|
||||
sessionId,
|
||||
requestId,
|
||||
requestKind: classifyTool(toolName),
|
||||
detail: summarizeToolRequest(toolName, toolInput),
|
||||
// ... eventId/createdAt
|
||||
});
|
||||
|
||||
const decision = await waitForApprovalDecision(requestId);
|
||||
emitRuntimeEvent({
|
||||
type: "approval.resolved",
|
||||
provider: "claudeCode",
|
||||
sessionId,
|
||||
requestId,
|
||||
decision,
|
||||
// ... eventId/createdAt
|
||||
});
|
||||
|
||||
return decision === "accept" || decision === "acceptForSession"
|
||||
? { behavior: "allow", updatedInput: toolInput }
|
||||
: { behavior: "deny", message: "User declined tool execution." };
|
||||
};
|
||||
```
|
||||
|
||||
#### 2.2.f Hooks and checkpoint signals
|
||||
|
||||
If Claude hooks provide cleaner turn boundaries, convert them into canonical runtime events (`turn.completed` and optionally `checkpoint.captured`) so `CheckpointReactor` remains unchanged:
|
||||
|
||||
```ts
|
||||
hooks: {
|
||||
Stop: [
|
||||
{
|
||||
matcher: {},
|
||||
hooks: [
|
||||
async () => {
|
||||
emitRuntimeEvent({
|
||||
type: "checkpoint.captured",
|
||||
provider: "claudeCode",
|
||||
sessionId,
|
||||
threadId,
|
||||
turnId: activeTurnId,
|
||||
turnCount: nextTurnCount(),
|
||||
// ... eventId/createdAt
|
||||
});
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
```
|
||||
|
||||
#### 2.2.g Runtime control method wiring
|
||||
|
||||
Adapter should expose SDK controls through existing service methods and runtime payload updates:
|
||||
|
||||
1. `interruptTurn()` -> `result.interrupt()`
|
||||
2. Model override on send turn -> `result.setModel(model)` before enqueuing prompt
|
||||
3. Runtime mode changes -> `result.setPermissionMode(mode)` if we support live mode switching
|
||||
4. Thinking budget updates -> `result.setMaxThinkingTokens(tokens)` when configured
|
||||
|
||||
### 2.3 Canonical event mapping
|
||||
|
||||
Map Claude SDK events to `ProviderRuntimeEvent`:
|
||||
|
||||
1. `session.started` / `session.exited`
|
||||
2. `turn.started` / `turn.completed`
|
||||
3. `message.delta` / `message.completed`
|
||||
4. `tool.started` / `tool.completed`
|
||||
5. `approval.requested` / `approval.resolved`
|
||||
6. `runtime.error`
|
||||
|
||||
No provider-native event methods should leak beyond the adapter boundary.
|
||||
|
||||
Reference mapping table:
|
||||
|
||||
| Claude SDK message/callback | Canonical runtime event(s) | Notes |
|
||||
|---|---|---|
|
||||
| assistant partial text | `message.delta` | Emit deltas only (do not resend full content each chunk). |
|
||||
| assistant final message | `message.completed` | Must include stable `itemId` for dedupe/finalize behavior. |
|
||||
| result (success) | `turn.completed` (`status: "completed"`) | This is the main turn boundary for checkpointing. |
|
||||
| result (interrupted/cancelled) | `turn.completed` (`status: "interrupted"`/`"cancelled"`) | Preserve state semantics used by ingestion + UI. |
|
||||
| result (error) | `runtime.error` and `turn.completed` (`status: "failed"`) | Include concise error message. |
|
||||
| tool start | `tool.started` | Set `toolKind` using shared classifier (`command`, `file-change`, `other`). |
|
||||
| tool result | `tool.completed` | Include detail summary used by activity feed. |
|
||||
| canUseTool prompt | `approval.requested` | Source of request id shown in UI. |
|
||||
| approval decision returned | `approval.resolved` | Must correlate using same request id. |
|
||||
| session initialization | `session.started`, optional `thread.started` | Ensure `threadId` is emitted early and consistently. |
|
||||
| process exit/close | `session.exited` | Required for session status projection cleanup. |
|
||||
|
||||
### 2.4 Session/thread/resume identifiers
|
||||
|
||||
Define explicit adapter semantics:
|
||||
|
||||
1. `sessionId`: adapter-owned stable session id.
|
||||
2. `threadId`: Claude conversation/session identifier returned as `ProviderThreadId`.
|
||||
3. `resumeCursor`: provider-specific cursor (for example message id) needed for precise recovery/rollback.
|
||||
|
||||
### 2.5 Rollback/read strategy
|
||||
|
||||
Implement `readThread()` and `rollbackThread()` in a way compatible with `CheckpointReactor`.
|
||||
|
||||
Preferred:
|
||||
|
||||
1. Track per-turn resume cursors and reconstruct session state on rollback.
|
||||
2. Keep adapter `sessionId` stable across internal rehydration/restart.
|
||||
|
||||
Fallback (explicitly documented if chosen):
|
||||
|
||||
1. Filesystem revert succeeds even when conversation rewind is partial.
|
||||
2. Reactor behavior is updated to surface a clear warning activity instead of silent drift.
|
||||
|
||||
### 2.6 Adapter unit tests
|
||||
|
||||
Add tests mirroring Codex adapter coverage:
|
||||
|
||||
1. Provider validation (`provider === "claudeCode"`).
|
||||
2. Event mapping to canonical runtime events.
|
||||
3. Approval request lifecycle.
|
||||
4. Resume/recovery behavior.
|
||||
5. Rollback behavior.
|
||||
|
||||
---
|
||||
|
||||
## Phase 3: Register adapter in runtime composition
|
||||
|
||||
### 3.1 Adapter registry wiring
|
||||
|
||||
Update:
|
||||
|
||||
1. `apps/server/src/provider/Layers/ProviderAdapterRegistry.ts`
|
||||
|
||||
Register both Codex and Claude adapters.
|
||||
|
||||
### 3.2 Server layer composition
|
||||
|
||||
Update:
|
||||
|
||||
1. `apps/server/src/serverLayers.ts`
|
||||
|
||||
Provide `ClaudeCodeAdapterLive` alongside Codex in `makeServerProviderLayer()`.
|
||||
|
||||
### 3.3 Composition tests
|
||||
|
||||
Update integration tests to ensure:
|
||||
|
||||
1. Registry exposes Claude provider.
|
||||
2. Provider service can route Claude sessions.
|
||||
|
||||
---
|
||||
|
||||
## Phase 4: Orchestration command/reactor updates
|
||||
|
||||
### 4.1 Decider propagation
|
||||
|
||||
Update `apps/server/src/orchestration/decider.ts`:
|
||||
|
||||
1. Carry optional `provider` from `thread.turn.start` command into `thread.turn-start-requested` event payload.
|
||||
|
||||
### 4.2 ProviderCommandReactor provider selection
|
||||
|
||||
Update `apps/server/src/orchestration/Layers/ProviderCommandReactor.ts`:
|
||||
|
||||
1. Prefer provider from turn-start event payload when starting a new session.
|
||||
2. Fallback to existing thread session provider when payload omitted.
|
||||
3. Fallback to default provider only when neither is present.
|
||||
|
||||
Switch behavior policy (explicit in implementation):
|
||||
|
||||
1. If active session provider differs from requested provider, stop and recreate session before sending turn.
|
||||
2. Keep current provider when request omits provider.
|
||||
|
||||
### 4.3 Reactor/invariant tests
|
||||
|
||||
Update/add tests in:
|
||||
|
||||
1. `apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts`
|
||||
2. `apps/server/src/orchestration/*.test.ts` as needed
|
||||
|
||||
Validate first-turn provider choice, provider switching semantics, and backward compatibility when provider is omitted.
|
||||
|
||||
---
|
||||
|
||||
## Phase 5: Web provider UX enablement
|
||||
|
||||
### 5.1 Enable Claude option
|
||||
|
||||
Update `apps/web/src/session-logic.ts`:
|
||||
|
||||
1. Mark Claude provider option as available.
|
||||
|
||||
### 5.2 Provider selection in composer
|
||||
|
||||
Update `apps/web/src/components/ChatView.tsx`:
|
||||
|
||||
1. Add provider picker near model/runtime controls.
|
||||
2. Include selected provider in `thread.turn.start` command payload.
|
||||
3. Keep selected provider sticky per thread in client state (or derive from active session provider when present).
|
||||
|
||||
### 5.3 Provider-aware model picker
|
||||
|
||||
Update model picker usage so model options reflect selected provider.
|
||||
|
||||
### 5.4 Web tests
|
||||
|
||||
Update/add tests for:
|
||||
|
||||
1. Provider picker interactions.
|
||||
2. Turn-start command includes provider.
|
||||
3. Model list switches by provider.
|
||||
|
||||
---
|
||||
|
||||
## Phase 6: Checkpoint and revert compatibility
|
||||
|
||||
### 6.1 Validate checkpoint reactor expectations
|
||||
|
||||
Exercise `apps/server/src/orchestration/Layers/CheckpointReactor.ts` flows with Claude:
|
||||
|
||||
1. Turn baseline capture.
|
||||
2. Turn completion checkpoint capture.
|
||||
3. Revert + provider rollback coordination.
|
||||
|
||||
### 6.2 Policy for partial rollback support
|
||||
|
||||
If Claude cannot support full conversation rewind at parity with Codex:
|
||||
|
||||
1. Document behavior clearly.
|
||||
2. Emit explicit thread activity for degraded rollback behavior.
|
||||
3. Ensure filesystem state remains correct and predictable.
|
||||
|
||||
### 6.3 Checkpoint tests
|
||||
|
||||
Add/update tests in checkpoint + provider service integration suites for Claude revert behavior.
|
||||
|
||||
---
|
||||
|
||||
## Phase 7: End-to-end hardening and observability
|
||||
|
||||
### 7.1 Integration tests
|
||||
|
||||
Add integration coverage for:
|
||||
|
||||
1. `thread.turn.start` with `provider: "claudeCode"` from fresh thread.
|
||||
2. Session recovery after restart (provider session alias/recovery path).
|
||||
3. Approval request/respond flow.
|
||||
4. Interrupt behavior.
|
||||
5. Revert flow with rollback.
|
||||
|
||||
### 7.2 WS behavior regression check
|
||||
|
||||
Ensure no contract regressions:
|
||||
|
||||
1. Client still consumes only `orchestration.domainEvent`.
|
||||
2. No new provider-specific WS channels introduced.
|
||||
|
||||
### 7.3 Logging
|
||||
|
||||
Confirm both native and canonical provider logs remain useful with multi-adapter setup:
|
||||
|
||||
1. `provider-native.ndjson`
|
||||
2. `provider-canonical.ndjson`
|
||||
|
||||
---
|
||||
|
||||
## File checklist
|
||||
|
||||
Likely files to touch:
|
||||
|
||||
1. `packages/contracts/src/model.ts`
|
||||
2. `packages/contracts/src/orchestration.ts`
|
||||
3. `packages/contracts/src/provider.ts`
|
||||
4. `apps/server/src/provider/Services/ClaudeCodeAdapter.ts` (new)
|
||||
5. `apps/server/src/provider/Layers/ClaudeCodeAdapter.ts` (new)
|
||||
6. `apps/server/src/provider/Layers/ProviderAdapterRegistry.ts`
|
||||
7. `apps/server/src/serverLayers.ts`
|
||||
8. `apps/server/src/orchestration/decider.ts`
|
||||
9. `apps/server/src/orchestration/Layers/ProviderCommandReactor.ts`
|
||||
10. `apps/web/src/session-logic.ts`
|
||||
11. `apps/web/src/components/ChatView.tsx`
|
||||
12. Related tests under `packages/contracts/src`, `apps/server/src/provider/Layers`, `apps/server/src/orchestration/Layers`, `apps/server/integration`, and `apps/web/src`.
|
||||
|
||||
---
|
||||
|
||||
## Delivery order
|
||||
|
||||
1. Contracts for provider selection + models.
|
||||
2. Claude adapter + unit tests.
|
||||
3. Registry/layer wiring.
|
||||
4. Reactor updates for provider-aware session start.
|
||||
5. Web provider picker + provider-aware models.
|
||||
6. Checkpoint/revert compatibility.
|
||||
7. End-to-end integration tests and stabilization.
|
||||
|
||||
This order keeps risk isolated and maintains a working orchestrated path at each stage.
|
||||
@@ -0,0 +1,327 @@
|
||||
# Plan: Cursor ACP (`agent acp`) Provider Integration
|
||||
|
||||
## Goal
|
||||
|
||||
Add Cursor as a first-class provider in T3 Code using ACP (`agent acp`) over JSON-RPC 2.0 stdio, with robust session lifecycle handling and canonical `ProviderRuntimeEvent` projection.
|
||||
|
||||
---
|
||||
|
||||
## 1) Exploration Findings (from live ACP probes)
|
||||
|
||||
### 1.1 Core invocation and transport
|
||||
|
||||
1. Binary is `agent` on PATH (`2026.02.27-e7d2ef6` observed).
|
||||
2. ACP server command is `agent acp`.
|
||||
3. Transport is newline-delimited JSON-RPC 2.0 over stdio.
|
||||
4. Messages:
|
||||
- client -> server: requests and responses to server-initiated requests
|
||||
- server -> client: responses, notifications (`session/update`), and server requests (`session/request_permission`)
|
||||
|
||||
### 1.2 Handshake and session calls observed
|
||||
|
||||
1. `initialize` returns:
|
||||
- `protocolVersion`
|
||||
- `agentCapabilities` (`loadSession`, `mcpCapabilities`, `promptCapabilities`)
|
||||
- `authMethods` (includes `cursor_login`)
|
||||
2. `authenticate { methodId: "cursor_login" }` returns `{}` when logged in.
|
||||
3. `session/new` returns:
|
||||
- `sessionId`
|
||||
- `modes` (`agent`, `plan`, `ask`)
|
||||
4. `session/load` works and requires `sessionId`, `cwd`, `mcpServers`.
|
||||
5. `session/prompt` returns terminal response `{ stopReason: "end_turn" | "cancelled" }`.
|
||||
|
||||
Important sequence note:
|
||||
1. ACP currently allows `session/new` even without explicit `initialize`/`authenticate` when local auth already exists.
|
||||
2. For adapter consistency and forward compatibility, we should still send `initialize` and `authenticate` during startup.
|
||||
|
||||
### 1.3 `session/update` event families observed
|
||||
|
||||
Observed `params.update.sessionUpdate` values:
|
||||
|
||||
1. `available_commands_update`
|
||||
2. `agent_thought_chunk`
|
||||
3. `agent_message_chunk`
|
||||
4. `tool_call`
|
||||
5. `tool_call_update`
|
||||
|
||||
Observed payload behavior:
|
||||
|
||||
1. `agent_*_chunk` provides `content: { type: "text", text: string }`.
|
||||
2. `tool_call` may be emitted multiple times for same `toolCallId`:
|
||||
- initial generic form (`title: "Terminal"`, `rawInput: {}`)
|
||||
- enriched form (`title: "\`pwd\`"`, `rawInput: { command: "pwd" }`)
|
||||
3. `tool_call_update` statuses observed:
|
||||
- `in_progress`
|
||||
- `completed`
|
||||
4. `tool_call_update` on completion may include `rawOutput`:
|
||||
- terminal: `{ exitCode, stdout, stderr }`
|
||||
- search/find: `{ totalFiles, truncated }`
|
||||
|
||||
### 1.4 Permission flow observed
|
||||
|
||||
1. ACP server sends `session/request_permission` (JSON-RPC request with `id`).
|
||||
2. Request shape includes:
|
||||
- `params.sessionId`
|
||||
- `params.toolCall`
|
||||
- `params.options` (`allow-once`, `allow-always`, `reject-once`)
|
||||
3. Client must respond on same `id` with:
|
||||
- `{ outcome: { outcome: "selected", optionId: "<one-option-id>" } }`
|
||||
4. Reject path still results in tool lifecycle completion events (`tool_call_update status: completed`), typically without `rawOutput`.
|
||||
|
||||
### 1.5 Error and capability quirks
|
||||
|
||||
1. `session/cancel` currently returns:
|
||||
- JSON-RPC error `-32601` Method not found
|
||||
2. Error shape examples:
|
||||
- unknown auth method: `-32602`
|
||||
- `session/load` missing/invalid params: `-32602`
|
||||
- `session/prompt` unknown session: `-32603` with details
|
||||
3. Parallel prompts on same session are effectively single-flight:
|
||||
- second prompt can cause first to complete with `stopReason: "cancelled"`.
|
||||
4. `session/new` accepts a `model` field (no explicit echo in response).
|
||||
|
||||
Probe artifacts:
|
||||
1. `.tmp/acp-probe/*/transcript.ndjson`
|
||||
2. `.tmp/acp-probe/*/summary.json`
|
||||
3. `scripts/cursor-acp-probe.mjs`
|
||||
|
||||
---
|
||||
|
||||
## 2) Integration Constraints for T3
|
||||
|
||||
1. T3 adapter contract still requires:
|
||||
- `startSession`, `sendTurn`, `interruptTurn`, `respondToRequest`, `readThread`, `rollbackThread`, `stopSession`, `listSessions`, `hasSession`, `stopAll`, `streamEvents`.
|
||||
2. Orchestration consumes canonical `ProviderRuntimeEvent` only.
|
||||
3. `ProviderCommandReactor` provider precedence fix remains required (respect explicit provider on turn start).
|
||||
4. ACP now supports external permission decisions, so Cursor can participate in T3 approval UX via adapter-managed request/response plumbing.
|
||||
|
||||
---
|
||||
|
||||
## 3) Proposed Architecture
|
||||
|
||||
### 3.1 New server components
|
||||
|
||||
1. `apps/server/src/provider/Services/CursorAdapter.ts` (service contract/tag + ACP event schemas).
|
||||
2. `apps/server/src/provider/Layers/CursorAdapter.ts` (single implementation unit; owns ACP process lifecycle, JSON-RPC routing, runtime projection).
|
||||
3. No manager indirection; keep logic in layer implementation.
|
||||
|
||||
### 3.2 Session model
|
||||
|
||||
1. One long-lived ACP child process per T3 Cursor provider session.
|
||||
2. Track:
|
||||
- `providerSessionId` (T3 synthetic ID)
|
||||
- `acpSessionId` (from `session/new` or restored via `session/load`)
|
||||
- `cwd`, `model`, in-flight turn state
|
||||
- pending permission requests by JSON-RPC request id
|
||||
3. Resume support:
|
||||
- persist `acpSessionId` in provider resume metadata and call `session/load` on reattach.
|
||||
|
||||
### 3.3 Command strategy
|
||||
|
||||
1. `startSession`:
|
||||
- spawn `agent acp`
|
||||
- `initialize`
|
||||
- `authenticate(cursor_login)` (best-effort, typed failure handling)
|
||||
- `session/new` or `session/load`
|
||||
2. `sendTurn`:
|
||||
- send `session/prompt { sessionId, prompt: [...] }`
|
||||
- consume streaming `session/update` notifications until terminal prompt response
|
||||
3. `interruptTurn`:
|
||||
- no native `session/cancel` today; implement fallback:
|
||||
- terminate ACP process + restart + `session/load` for subsequent turns
|
||||
- mark in-flight turn as interrupted/failed in canonical events
|
||||
4. `respondToRequest`:
|
||||
- map T3 approval decision -> ACP `optionId`
|
||||
- reply to exact JSON-RPC request id from `session/request_permission`
|
||||
|
||||
### 3.4 Effect-first implementation style (required)
|
||||
|
||||
1. Keep logic inside `CursorAdapterLive`.
|
||||
2. Use Effect primitives:
|
||||
- `Queue` + `Stream.fromQueue` for event fan-out
|
||||
- `Ref` / `Ref.Synchronized` for session/process/request state
|
||||
- scoped fibers for stdout/stderr read loops
|
||||
3. Typed JSON decode at boundary:
|
||||
- request/response envelopes
|
||||
- `session/update` union schema
|
||||
- permission-request schema
|
||||
4. Keep adapter errors in typed error algebra with explicit mapping at process/protocol boundaries.
|
||||
|
||||
---
|
||||
|
||||
## 4) Canonical Event Mapping Plan (ACP -> ProviderRuntimeEvent)
|
||||
|
||||
1. `session/update: agent_message_chunk`
|
||||
- emit `message.delta` for assistant stream
|
||||
2. prompt terminal response (`session/prompt` result `stopReason: end_turn`)
|
||||
- emit `message.completed` + `turn.completed`
|
||||
3. `session/update: agent_thought_chunk`
|
||||
- initial mapping: emit thinking activity (or ignore if we keep current canonical surface minimal)
|
||||
4. `session/update: tool_call`
|
||||
- first-seen `toolCallId` emits `tool.started`
|
||||
- subsequent `tool_call` for same ID treated as metadata update (no duplicate started event)
|
||||
5. `session/update: tool_call_update`
|
||||
- `in_progress`: optional progress activity
|
||||
- `completed`: emit `tool.completed` with summarized `rawOutput` when present
|
||||
6. `session/request_permission`
|
||||
- emit `approval.requested` with mapped options
|
||||
- when client decision sent, emit `approval.resolved`
|
||||
7. protocol/process error
|
||||
- emit `runtime.error`
|
||||
- fail active turn/session as appropriate
|
||||
|
||||
Synthetic IDs:
|
||||
1. `turnId`: T3-generated UUID per `sendTurn`.
|
||||
2. `itemId`:
|
||||
- assistant stream: `${turnId}:assistant`
|
||||
- tools: `${turnId}:${toolCallId}`
|
||||
|
||||
---
|
||||
|
||||
## 5) Approval, Resume, and Rollback Behavior
|
||||
|
||||
### 5.1 Approvals
|
||||
|
||||
1. Cursor ACP permission requests are externally controllable; implement full `respondToRequest` path in v1.
|
||||
2. Decision mapping:
|
||||
- allow once -> `allow-once`
|
||||
- allow always -> `allow-always`
|
||||
- reject -> `reject-once`
|
||||
|
||||
### 5.2 Resume
|
||||
|
||||
1. `session/load` is available and should be first-class for adapter restart/reconnect.
|
||||
2. Must send required params: `sessionId`, `cwd`, `mcpServers`.
|
||||
|
||||
### 5.3 Rollback / thread read
|
||||
|
||||
1. ACP currently has no observed rollback API.
|
||||
2. Plan for v1:
|
||||
- `readThread`: adapter-maintained snapshot projection
|
||||
- `rollbackThread`: explicit unsupported error
|
||||
3. Product guard:
|
||||
- disable checkpoint revert for Cursor threads in UI until rollback exists.
|
||||
|
||||
---
|
||||
|
||||
## 6) Required Contract and Runtime Changes
|
||||
|
||||
### 6.1 Contracts
|
||||
|
||||
1. Add `cursor` to `ProviderKind`.
|
||||
2. Add Cursor provider start options (`providerOptions.cursor`), ACP-oriented:
|
||||
- optional `binaryPath`
|
||||
- optional auth/mode knobs if needed later
|
||||
3. Extend model options for Cursor list and traits mapping.
|
||||
4. Add schemas for ACP-native event union in Cursor adapter service file.
|
||||
|
||||
### 6.2 Server orchestration and registry
|
||||
|
||||
1. Register `CursorAdapter` in provider registry and server layer wiring.
|
||||
2. Update provider-kind persistence decoding for `cursor`.
|
||||
3. Fix `ProviderCommandReactor` precedence to honor explicit provider in turn-start command.
|
||||
|
||||
### 6.3 Web
|
||||
|
||||
1. Cursor in provider picker and model picker (already partially done).
|
||||
2. Trait controls map to concrete Cursor model identifiers.
|
||||
3. Surface unsupported rollback behavior in UX.
|
||||
|
||||
---
|
||||
|
||||
## 7) Implementation Phases
|
||||
|
||||
### Phase A: ACP process and protocol skeleton
|
||||
|
||||
1. Implement ACP process lifecycle in `CursorAdapterLive`.
|
||||
2. Implement JSON-RPC request/response multiplexer.
|
||||
3. Implement `initialize`/`authenticate`/`session/new|load` flow.
|
||||
4. Wire `streamEvents` from ACP notifications.
|
||||
|
||||
### Phase B: Runtime projection and approvals
|
||||
|
||||
1. Map `session/update` variants to canonical runtime events.
|
||||
2. Implement permission-request bridging to `respondToRequest`.
|
||||
3. Implement dedupe for repeated `tool_call` on same `toolCallId`.
|
||||
|
||||
### Phase C: Turn control and interruption
|
||||
|
||||
1. Implement single in-flight prompt protection per session.
|
||||
2. Implement interruption fallback (process restart + reload) because `session/cancel` unavailable.
|
||||
3. Ensure clean state recovery on ACP process crash.
|
||||
|
||||
### Phase D: Orchestration + UX polish
|
||||
|
||||
1. Provider routing precedence fix.
|
||||
2. Cursor-specific UX notes for unsupported rollback.
|
||||
3. End-to-end smoke and event log validation.
|
||||
|
||||
---
|
||||
|
||||
## 8) Test Plan
|
||||
|
||||
Follow project rule: backend external-service integrations tested via layered fakes, not by mocking core business logic.
|
||||
|
||||
### 8.1 Unit tests (`CursorAdapter`)
|
||||
|
||||
1. JSON-RPC envelope parsing:
|
||||
- response matching by id
|
||||
- server request handling (`session/request_permission`)
|
||||
- notification decode (`session/update`)
|
||||
2. Event projection:
|
||||
- `agent_message_chunk` / `agent_thought_chunk`
|
||||
- `tool_call` + `tool_call_update` dedupe/lifecycle
|
||||
- permission request -> approval events
|
||||
3. Error mapping:
|
||||
- unknown session
|
||||
- method-not-found (`session/cancel`)
|
||||
- invalid params
|
||||
|
||||
### 8.2 Provider service/routing tests
|
||||
|
||||
1. Registry resolves `cursor`.
|
||||
2. Session directory persistence reads/writes `cursor`.
|
||||
3. ProviderService fan-out ordering with Cursor ACP events.
|
||||
|
||||
### 8.3 Orchestration tests
|
||||
|
||||
1. `thread.turn.start` with `provider: cursor` routes to Cursor adapter.
|
||||
2. approval response command maps to ACP permission response.
|
||||
3. checkpoint revert on Cursor thread returns controlled unsupported failure.
|
||||
|
||||
### 8.4 Optional live smoke
|
||||
|
||||
1. Env-gated ACP smoke:
|
||||
- start session
|
||||
- run prompt
|
||||
- observe deltas + completion
|
||||
- exercise permission request path with one tool call
|
||||
|
||||
---
|
||||
|
||||
## 9) Operational Notes
|
||||
|
||||
1. Keep one in-flight turn per ACP session.
|
||||
2. Keep per-session ACP process logs/NDJSON artifacts for debugging.
|
||||
3. Treat `session/cancel` as unsupported until Cursor ships it; avoid relying on it.
|
||||
4. Preserve resume metadata (`acpSessionId`) for crash recovery.
|
||||
|
||||
---
|
||||
|
||||
## 10) Open Questions
|
||||
|
||||
1. Should we call `authenticate` always, or only after auth-required errors?
|
||||
2. Should model selection be passed at `session/new` only, or can/should we support model switching mid-session if ACP adds API?
|
||||
3. For interruption UX, do we expose “hard interrupt” semantics (process restart) explicitly?
|
||||
|
||||
---
|
||||
|
||||
## 11) Delivery Checklist
|
||||
|
||||
1. Plan/documentation switched from headless `agent -p` to ACP `agent acp`.
|
||||
2. Contracts updated (`ProviderKind`, Cursor options, model/trait mapping).
|
||||
3. Cursor ACP adapter layer implemented and registered.
|
||||
4. Provider precedence fixed in orchestration router.
|
||||
5. Approval response path wired through ACP permission requests.
|
||||
6. Tests added for protocol decode, projection, approval flow, and routing.
|
||||
7. Lint + tests green.
|
||||
@@ -1,64 +0,0 @@
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
|
||||
const FAVICON_CANDIDATES = [
|
||||
"favicon.svg", "favicon.ico", "favicon.png",
|
||||
"public/favicon.svg", "public/favicon.ico", "public/favicon.png",
|
||||
"app/favicon.ico", "app/favicon.png", "app/icon.svg", "app/icon.png", "app/icon.ico",
|
||||
"src/favicon.ico", "src/favicon.svg", "src/app/favicon.ico", "src/app/icon.svg", "src/app/icon.png",
|
||||
];
|
||||
|
||||
const ICON_SOURCE_FILES = [
|
||||
"index.html", "public/index.html",
|
||||
"app/routes/__root.tsx", "src/routes/__root.tsx",
|
||||
"app/root.tsx", "src/root.tsx", "src/index.html",
|
||||
];
|
||||
|
||||
const LINK_ICON_HTML_RE = /<link[^>]*rel=["'](?:icon|shortcut icon)["'][^>]*href=["']([^"'?]+)/i;
|
||||
const LINK_ICON_OBJ_RE = /rel:\s*["'](?:icon|shortcut icon)["'][^}]*href:\s*["']([^"'?]+)/i;
|
||||
|
||||
function test(projectCwd) {
|
||||
console.log("--- Testing:", projectCwd, "---");
|
||||
|
||||
for (const c of FAVICON_CANDIDATES) {
|
||||
const full = path.join(projectCwd, c);
|
||||
if (fs.existsSync(full) && fs.statSync(full).isFile()) {
|
||||
console.log(" Phase 1 FOUND:", c);
|
||||
return;
|
||||
}
|
||||
}
|
||||
console.log(" Phase 1: no match");
|
||||
|
||||
for (const sf of ICON_SOURCE_FILES) {
|
||||
const full = path.join(projectCwd, sf);
|
||||
if (!fs.existsSync(full)) continue;
|
||||
const content = fs.readFileSync(full, "utf8");
|
||||
const href = content.match(LINK_ICON_HTML_RE)?.[1] || content.match(LINK_ICON_OBJ_RE)?.[1];
|
||||
if (href) {
|
||||
const clean = href.replace(/^\//, "");
|
||||
const tryPaths = [path.join(projectCwd, "public", clean), path.join(projectCwd, clean)];
|
||||
for (const p of tryPaths) {
|
||||
if (fs.existsSync(p)) {
|
||||
console.log(" Phase 2 FOUND:", sf, "->", href, "->", p);
|
||||
return;
|
||||
}
|
||||
}
|
||||
console.log(" Phase 2 href found but file missing:", href);
|
||||
}
|
||||
}
|
||||
console.log(" Phase 2: no match");
|
||||
}
|
||||
|
||||
function getTestPaths() {
|
||||
const cliPaths = process.argv.slice(2).map((p) => p.trim()).filter(Boolean);
|
||||
if (cliPaths.length > 0) return cliPaths;
|
||||
|
||||
const envPaths = process.env.TEST_PATHS?.split(path.delimiter).map((p) => p.trim()).filter(Boolean);
|
||||
if (envPaths?.length) return envPaths;
|
||||
|
||||
return [process.cwd()];
|
||||
}
|
||||
|
||||
for (const p of getTestPaths()) {
|
||||
test(path.resolve(p));
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
# CLAUDE.md
|
||||
# AGENTS.md
|
||||
|
||||
## Task Completion Requirements
|
||||
|
||||
- Both `bun lint` and `bun typecheck` must pass before considering tasks completed.
|
||||
- NEVER run `bun test`. Always use `bun run test` (runs Vitest).
|
||||
|
||||
## Project Snapshot
|
||||
|
||||
|
||||
@@ -1,582 +0,0 @@
|
||||
# Orchestration Interface Spec (Required State)
|
||||
|
||||
Status: Required target architecture (not a description of current behavior).
|
||||
|
||||
## 1. Identifier Schema (Branded)
|
||||
|
||||
All identifiers are branded and never plain `string` in schema definitions.
|
||||
|
||||
```ts
|
||||
const ThreadId = Schema.String.pipe(Schema.brand("ThreadId"));
|
||||
const ProjectId = Schema.String.pipe(Schema.brand("ProjectId"));
|
||||
const CommandId = Schema.String.pipe(Schema.brand("CommandId"));
|
||||
const EventId = Schema.String.pipe(Schema.brand("EventId"));
|
||||
const MessageId = Schema.String.pipe(Schema.brand("MessageId"));
|
||||
const TurnId = Schema.String.pipe(Schema.brand("TurnId"));
|
||||
|
||||
const ProviderSessionId = Schema.String.pipe(Schema.brand("ProviderSessionId"));
|
||||
const ProviderThreadId = Schema.String.pipe(Schema.brand("ProviderThreadId"));
|
||||
const ProviderTurnId = Schema.String.pipe(Schema.brand("ProviderTurnId"));
|
||||
const ProviderItemId = Schema.String.pipe(Schema.brand("ProviderItemId"));
|
||||
const ApprovalRequestId = Schema.String.pipe(Schema.brand("ApprovalRequestId"));
|
||||
|
||||
const CheckpointRef = Schema.String.pipe(Schema.brand("CheckpointRef"));
|
||||
```
|
||||
|
||||
Rules:
|
||||
|
||||
- `ThreadId` is app/orchestration thread identity.
|
||||
- `ProviderThreadId` is provider runtime thread identity.
|
||||
- They are never assigned to each other.
|
||||
- `ProviderSessionId` is internal server/provider routing identity; clients do not send it.
|
||||
- use e.g. `ThreadId.make(randomUUID())` to create new entity ids at the source (e.g. client create thread id and send to server, provider adapter creates the provider thread id from the codex app server etc)
|
||||
|
||||
## 2. Client Commands (Domain Commands)
|
||||
|
||||
All commands are sent through one RPC: `orchestration.dispatchCommand`.
|
||||
|
||||
Output for every command: `DispatchResultSchema = { sequence: number }`.
|
||||
|
||||
### 2.1 Client-Dispatchable Commands
|
||||
|
||||
1. `project.create`
|
||||
|
||||
- Input:
|
||||
- `commandId: CommandId`
|
||||
- `projectId: ProjectId`
|
||||
- `title: string`
|
||||
- `workspaceRoot: string`
|
||||
- `defaultModel?: string`
|
||||
- `createdAt: IsoDateTime`
|
||||
- Output: `DispatchResult`
|
||||
|
||||
2. `project.meta.update`
|
||||
|
||||
- Input:
|
||||
- `commandId: CommandId`
|
||||
- `projectId: ProjectId`
|
||||
- optional `{ title, workspaceRoot, defaultModel, scripts }`
|
||||
- Output: `DispatchResult`
|
||||
|
||||
3. `project.delete`
|
||||
|
||||
- Input: `commandId`, `projectId`
|
||||
- Output: `DispatchResult`
|
||||
|
||||
4. `thread.create`
|
||||
|
||||
- Input:
|
||||
- `commandId: CommandId`
|
||||
- `threadId: ThreadId`
|
||||
- `projectId: ProjectId`
|
||||
- `title: string`
|
||||
- `model: string`
|
||||
- `branch: string | null`
|
||||
- `worktreePath: string | null`
|
||||
- `createdAt: IsoDateTime`
|
||||
- Output: `DispatchResult`
|
||||
|
||||
5. `thread.delete`
|
||||
|
||||
- Input: `commandId`, `threadId`
|
||||
- Output: `DispatchResult`
|
||||
|
||||
6. `thread.meta.update`
|
||||
|
||||
- Input: `commandId`, `threadId`, optional `{ title, model, branch, worktreePath }`
|
||||
- Output: `DispatchResult`
|
||||
|
||||
7. `thread.turn.start`
|
||||
|
||||
- Input:
|
||||
- `commandId`
|
||||
- `threadId`
|
||||
- `message`:
|
||||
- `messageId: MessageId`
|
||||
- `role: "user"`
|
||||
- `text: string`
|
||||
- `attachments: ChatAttachment[]` (schema-shared)
|
||||
- `model?: string`
|
||||
- `effort?: string`
|
||||
- `createdAt`
|
||||
- Output: `DispatchResult`
|
||||
|
||||
8. `thread.turn.interrupt`
|
||||
|
||||
- Input: `commandId`, `threadId`, optional `turnId: TurnId`, `createdAt`
|
||||
- Output: `DispatchResult`
|
||||
|
||||
9. `thread.approval.respond`
|
||||
|
||||
- Input:
|
||||
- `commandId`
|
||||
- `threadId`
|
||||
- `requestId: ApprovalRequestId`
|
||||
- `decision: "accept" | "acceptForSession" | "decline" | "cancel"`
|
||||
- `createdAt`
|
||||
- Output: `DispatchResult`
|
||||
|
||||
10. `thread.checkpoint.revert`
|
||||
|
||||
- Input: `commandId`, `threadId`, `turnCount: number`, `createdAt`
|
||||
- Output: `DispatchResult`
|
||||
|
||||
11. `thread.session.stop`
|
||||
|
||||
- Input: `commandId`, `threadId`, `createdAt`
|
||||
- Output: `DispatchResult`
|
||||
|
||||
### 2.2 Internal-Only Commands (Not Client Dispatchable)
|
||||
|
||||
1. `thread.session.set`
|
||||
|
||||
- Server-owned projection update for session lifecycle.
|
||||
|
||||
2. `thread.message.assistant.delta`
|
||||
|
||||
- Server-owned incremental assistant content append.
|
||||
|
||||
3. `thread.message.assistant.complete`
|
||||
|
||||
- Server-owned assistant message completion marker.
|
||||
|
||||
4. `thread.turn.diff.complete`
|
||||
|
||||
- Server-owned checkpoint diff summary write.
|
||||
|
||||
5. `thread.activity.append`
|
||||
|
||||
- Server-owned activity feed append.
|
||||
|
||||
## 3. Client RPC (Required)
|
||||
|
||||
These are the required client-facing RPC methods.
|
||||
|
||||
1. `orchestration.getSnapshot`
|
||||
|
||||
- Input: `{}`
|
||||
- Output: `OrchestrationReadModel`
|
||||
|
||||
2. `orchestration.dispatchCommand`
|
||||
|
||||
- Input: `ClientOrchestrationCommand` (`Schema.Union` of all client-dispatchable commands)
|
||||
- Output: `DispatchResult`
|
||||
|
||||
3. `orchestration.getTurnDiff`
|
||||
|
||||
- Input:
|
||||
- `threadId: ThreadId`
|
||||
- `fromTurnCount: number`
|
||||
- `toTurnCount: number`
|
||||
- Output:
|
||||
- `threadId: ThreadId`
|
||||
- `fromTurnCount: number`
|
||||
- `toTurnCount: number`
|
||||
- `diff: string`
|
||||
|
||||
4. `orchestration.replayEvents` (optional operational/debug API)
|
||||
|
||||
- Input: `{ fromSequenceExclusive: number }`
|
||||
- Output: `OrchestrationEvent[]`
|
||||
|
||||
### 3.1 RPC To Remove
|
||||
|
||||
Remove from client boundary:
|
||||
|
||||
- `providers.startSession`
|
||||
- `providers.sendTurn`
|
||||
- `providers.interruptTurn`
|
||||
- `providers.respondToRequest`
|
||||
- `providers.stopSession`
|
||||
- `providers.listCheckpoints`
|
||||
- `providers.getCheckpointDiff`
|
||||
- `providers.revertToCheckpoint`
|
||||
|
||||
Rationale:
|
||||
|
||||
- Session/turn/checkpoint control belongs to orchestrator command path.
|
||||
- Snapshot already includes checkpoint summaries (`checkpoints`); only full textual diff needs explicit query RPC.
|
||||
|
||||
## 4. Server Orchestrator Command <-> Event Schemas
|
||||
|
||||
Each command deterministically yields one or more domain events that are persisted to the event store.
|
||||
|
||||
1. `project.create` -> `project.created`
|
||||
2. `project.meta.update` -> `project.meta-updated`
|
||||
3. `project.delete` -> `project.deleted`
|
||||
4. `thread.create` -> `thread.created`
|
||||
5. `thread.delete` -> `thread.deleted`
|
||||
6. `thread.meta.update` -> `thread.meta-updated`
|
||||
7. `thread.turn.start` ->
|
||||
|
||||
- `thread.message-sent` (user message append)
|
||||
- `thread.turn-start-requested`
|
||||
- then (async side effect success) `thread.session-set` + provider-driven message/turn events
|
||||
|
||||
8. `thread.turn.interrupt` -> `thread.turn-interrupt-requested`
|
||||
9. `thread.approval.respond` -> `thread.approval-response-requested`
|
||||
10. `thread.checkpoint.revert` -> `thread.checkpoint-revert-requested` then `thread.reverted`
|
||||
11. `thread.session.stop` -> `thread.session-stop-requested` then `thread.session-set`
|
||||
|
||||
Internal command/event path:
|
||||
|
||||
- `thread.session.set` -> `thread.session-set`
|
||||
- `thread.message.assistant.delta` -> `thread.message-sent` (assistant streaming)
|
||||
- `thread.message.assistant.complete` -> `thread.message-sent` (streaming false)
|
||||
- `thread.turn.diff.complete` -> `thread.turn-diff-completed`
|
||||
- `thread.activity.append` -> `thread.activity-appended`
|
||||
|
||||
## 5. Orchestration Events <-> Generic Provider Events <-> Raw Provider Events
|
||||
|
||||
Required mapping pipeline:
|
||||
|
||||
`Raw Provider Event (adapter-specific)`
|
||||
-> `GenericProviderRuntimeEvent` (provider-agnostic schema)
|
||||
-> `Internal Orchestration Command`
|
||||
-> `Orchestration Domain Event`
|
||||
|
||||
### 5.1 Mapping Table for Codex Adapter
|
||||
|
||||
1. Raw `thread/started`
|
||||
|
||||
- Generic: `thread.started`
|
||||
- Internal command: `thread.session.set` (attach `ProviderThreadId`, status `ready|running`)
|
||||
- Domain event: `thread.session-set`
|
||||
|
||||
2. Raw `turn/started`
|
||||
|
||||
- Generic: `turn.started`
|
||||
- Internal command: `thread.session.set` (status `running`, active turn)
|
||||
- Domain event: `thread.session-set`
|
||||
|
||||
3. Raw `item/agentMessage/delta`
|
||||
|
||||
- Generic: `message.delta`
|
||||
- Internal command: `thread.message.assistant.delta`
|
||||
- Domain event: `thread.message-sent` (assistant, streaming)
|
||||
|
||||
4. Raw `item/completed` (agent message)
|
||||
|
||||
- Generic: `message.completed`
|
||||
- Internal command: `thread.message.assistant.complete`
|
||||
- Domain event: `thread.message-sent` (assistant, completed)
|
||||
|
||||
5. Raw `turn/completed`
|
||||
|
||||
- Generic: `turn.completed`
|
||||
- Internal commands:
|
||||
- `thread.session.set` (ready/error)
|
||||
- `thread.activity.append` (optional summary)
|
||||
- Domain events: `thread.session-set`, `thread.activity-appended`
|
||||
|
||||
6. Raw approval request
|
||||
|
||||
- Generic: `approval.requested`
|
||||
- Internal command: `thread.activity.append` (typed `requestId`, `requestKind`)
|
||||
- Domain event: `thread.activity-appended`
|
||||
|
||||
7. Raw approval decision ack
|
||||
|
||||
- Generic: `approval.resolved`
|
||||
- Internal command: `thread.activity.append`
|
||||
- Domain event: `thread.activity-appended`
|
||||
|
||||
8. Raw tool start/complete
|
||||
|
||||
- Generic: `tool.started` / `tool.completed`
|
||||
- Internal command: `thread.activity.append`
|
||||
- Domain event: `thread.activity-appended`
|
||||
|
||||
9. Checkpoint capture (server-produced)
|
||||
|
||||
- Generic: `checkpoint.captured`
|
||||
- Internal command: `thread.turn.diff.complete`
|
||||
- Domain event: `thread.turn-diff-completed`
|
||||
|
||||
10. Raw/runtime error
|
||||
|
||||
- Generic: `runtime.error`
|
||||
- Internal commands:
|
||||
- `thread.session.set` (status `error`)
|
||||
- `thread.activity.append` (`tone=error`)
|
||||
- Domain events: `thread.session-set`, `thread.activity-appended`
|
||||
|
||||
## 6. Schema Section (Boundary + Reuse)
|
||||
|
||||
### 6.1 Shared Schemas (contracts package)
|
||||
|
||||
Expose to both web and server:
|
||||
|
||||
- `OrchestrationReadModelSchema`
|
||||
- `ClientOrchestrationCommandSchema`
|
||||
- `OrchestrationEventSchema`
|
||||
- `OrchestrationRpcSchemas` (`getSnapshot`, `dispatchCommand`, `getTurnDiff`, optional replay)
|
||||
- `GenericProviderRuntimeEventSchema` (used for diagnostics/ingestion tests)
|
||||
- Shared message/activity/checkpoint summary schemas used in snapshot
|
||||
|
||||
### 6.2 Server-Internal Schemas
|
||||
|
||||
Not exposed to web:
|
||||
|
||||
- `InternalOrchestrationCommandSchema`
|
||||
- Adapter raw-event schemas and provider-specific payload schemas
|
||||
- Provider session directory records and persistence-only row schemas
|
||||
- Git service cache/query schemas (non-orchestration read model)
|
||||
|
||||
### 6.3 Reuse Requirements
|
||||
|
||||
- Snapshot checkpoint summary schema is source of truth for checkpoint list UI.
|
||||
- `getTurnDiff` response reuses `ThreadId`/turn count brands and textual `diff` only.
|
||||
- Activity schemas are reused for approval/tool/runtime annotations; no separate UI-only structure.
|
||||
- Session schema must include both `threadId: ThreadId` and optional `providerThreadId: ProviderThreadId` (explicitly distinct).
|
||||
|
||||
## 7. Persistence Model (Required)
|
||||
|
||||
This section defines required persisted tables, the canonical persisted event envelope, and required projected/read tables.
|
||||
|
||||
### 7.1 Write-Side Persisted Tables
|
||||
|
||||
1. `orchestration_events` (append-only event store)
|
||||
|
||||
- `sequence: number` (global monotonic sequence, primary key)
|
||||
- `eventId: EventId` (unique)
|
||||
- `aggregateKind: "project" | "thread"`
|
||||
- `streamId: ProjectId | ThreadId` (aggregate stream id)
|
||||
- `streamVersion: number` (per-aggregate monotonic version)
|
||||
- `eventType: OrchestrationEventType`
|
||||
- `occurredAt: IsoDateTime`
|
||||
- `commandId: CommandId | null`
|
||||
- `causationEventId: EventId | null`
|
||||
- `correlationId: CommandId | null`
|
||||
- `actorKind: "client" | "server" | "provider"`
|
||||
- `payload: OrchestrationEventPayload` (type-validated by `eventType`)
|
||||
- `metadata: OrchestrationEventMetadata`
|
||||
|
||||
2. `orchestration_command_receipts` (idempotency + ack replay)
|
||||
|
||||
- `commandId: CommandId` (primary key)
|
||||
- `aggregateKind: "project" | "thread"`
|
||||
- `aggregateId: ProjectId | ThreadId`
|
||||
- `acceptedAt: IsoDateTime`
|
||||
- `resultSequence: number`
|
||||
- `status: "accepted" | "rejected"`
|
||||
- `error: string | null`
|
||||
|
||||
3. `checkpoint_diff_blobs` (large plaintext diffs; separate from summaries)
|
||||
|
||||
- `threadId: ThreadId`
|
||||
- `fromTurnCount: number`
|
||||
- `toTurnCount: number`
|
||||
- `diff: string`
|
||||
- `createdAt: IsoDateTime`
|
||||
- unique key: `(threadId, fromTurnCount, toTurnCount)`
|
||||
|
||||
4. `provider_session_runtime` (server-internal adapter resume state)
|
||||
|
||||
- `providerSessionId: ProviderSessionId` (primary key)
|
||||
- `threadId: ThreadId`
|
||||
- `providerName: string`
|
||||
- `adapterKey: string`
|
||||
- `providerThreadId: ProviderThreadId | null`
|
||||
- `status: "starting" | "running" | "stopped" | "error"`
|
||||
- `lastSeenAt: IsoDateTime`
|
||||
- `resumeCursor: JsonValue | null` (adapter-specific opaque state)
|
||||
- `runtimePayload: JsonValue | null` (adapter-specific opaque state)
|
||||
|
||||
### 7.2 Canonical Persisted Event Schema
|
||||
|
||||
`OrchestrationPersistedEventSchema` (full envelope):
|
||||
|
||||
```ts
|
||||
type OrchestrationPersistedEvent = {
|
||||
sequence: number;
|
||||
eventId: EventId;
|
||||
aggregateKind: "project" | "thread";
|
||||
streamId: ProjectId | ThreadId;
|
||||
streamVersion: number;
|
||||
eventType: OrchestrationEventType;
|
||||
occurredAt: IsoDateTime;
|
||||
commandId: CommandId | null;
|
||||
causationEventId: EventId | null;
|
||||
correlationId: CommandId | null;
|
||||
actorKind: "client" | "server" | "provider";
|
||||
payload: OrchestrationEventPayload;
|
||||
metadata: {
|
||||
providerSessionId?: ProviderSessionId;
|
||||
providerThreadId?: ProviderThreadId;
|
||||
providerTurnId?: ProviderTurnId;
|
||||
providerItemId?: ProviderItemId;
|
||||
adapterKey?: string;
|
||||
requestId?: ApprovalRequestId;
|
||||
ingestedAt?: IsoDateTime;
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
Rules:
|
||||
|
||||
- `payload` must be schema-discriminated by `eventType`.
|
||||
- provider identifiers only appear in `metadata` and provider-specific payload sub-shapes; they do not replace `ThreadId`.
|
||||
- `streamVersion` is concurrency guard for aggregate writes.
|
||||
|
||||
### 7.3 Required Projected Tables (Read Models)
|
||||
|
||||
1. `projection_projects`
|
||||
|
||||
- `projectId: ProjectId` (primary key)
|
||||
- `title: string`
|
||||
- `workspaceRoot: string`
|
||||
- `defaultModel: string | null`
|
||||
- `scripts: ProjectScript[]`
|
||||
- `createdAt: IsoDateTime`
|
||||
- `updatedAt: IsoDateTime`
|
||||
- `deletedAt: IsoDateTime | null`
|
||||
|
||||
2. `projection_threads`
|
||||
|
||||
- `threadId: ThreadId` (primary key)
|
||||
- `projectId: ProjectId`
|
||||
- `title: string`
|
||||
- `model: string`
|
||||
- `branch: string | null`
|
||||
- `worktreePath: string | null`
|
||||
- `latestTurnId: TurnId | null`
|
||||
- `createdAt: IsoDateTime`
|
||||
- `updatedAt: IsoDateTime`
|
||||
- `deletedAt: IsoDateTime | null`
|
||||
|
||||
3. `projection_thread_messages`
|
||||
|
||||
- `messageId: MessageId` (primary key)
|
||||
- `threadId: ThreadId`
|
||||
- `turnId: TurnId | null`
|
||||
- `role: "user" | "assistant" | "system"`
|
||||
- `text: string`
|
||||
- `isStreaming: boolean`
|
||||
- `createdAt: IsoDateTime`
|
||||
- `updatedAt: IsoDateTime`
|
||||
|
||||
4. `projection_thread_activities`
|
||||
|
||||
- `activityId: EventId` (primary key; derived from source event)
|
||||
- `threadId: ThreadId`
|
||||
- `turnId: TurnId | null`
|
||||
- `tone: "info" | "tool" | "approval" | "error"`
|
||||
- `kind: string`
|
||||
- `summary: string`
|
||||
- `payload: JsonValue`
|
||||
- `createdAt: IsoDateTime`
|
||||
|
||||
5. `projection_thread_sessions`
|
||||
|
||||
- `threadId: ThreadId` (primary key)
|
||||
- `status: "idle" | "starting" | "running" | "ready" | "interrupted" | "stopped" | "error"`
|
||||
- `providerName: string | null`
|
||||
- `providerSessionId: ProviderSessionId | null`
|
||||
- `providerThreadId: ProviderThreadId | null`
|
||||
- `activeTurnId: TurnId | null`
|
||||
- `lastError: string | null`
|
||||
- `updatedAt: IsoDateTime`
|
||||
|
||||
6. `projection_thread_turns`
|
||||
|
||||
- `turnId: TurnId` (primary key)
|
||||
- `threadId: ThreadId`
|
||||
- `turnCount: number`
|
||||
- `status: "running" | "completed" | "interrupted" | "error"`
|
||||
- `userMessageId: MessageId | null`
|
||||
- `assistantMessageId: MessageId | null`
|
||||
- `startedAt: IsoDateTime`
|
||||
- `completedAt: IsoDateTime | null`
|
||||
|
||||
7. `projection_checkpoints`
|
||||
|
||||
- `threadId: ThreadId`
|
||||
- `turnId: TurnId`
|
||||
- `checkpointTurnCount: number`
|
||||
- `checkpointRef: CheckpointRef`
|
||||
- `status: "ready" | "missing" | "error"`
|
||||
- `files: JsonArray` (typed as file diff summary schema)
|
||||
- `assistantMessageId: MessageId | null`
|
||||
- `completedAt: IsoDateTime`
|
||||
- unique key: `(threadId, checkpointTurnCount)`
|
||||
|
||||
8. `projection_pending_approvals`
|
||||
|
||||
- `requestId: ApprovalRequestId` (primary key)
|
||||
- `threadId: ThreadId`
|
||||
- `turnId: TurnId | null`
|
||||
- `status: "pending" | "resolved"`
|
||||
- `decision: "accept" | "acceptForSession" | "decline" | "cancel" | null`
|
||||
- `createdAt: IsoDateTime`
|
||||
- `resolvedAt: IsoDateTime | null`
|
||||
|
||||
9. `projection_state`
|
||||
|
||||
- `projector: string` (primary key; e.g. `threads`, `messages`, `sessions`)
|
||||
- `lastAppliedSequence: number`
|
||||
- `updatedAt: IsoDateTime`
|
||||
|
||||
Projection consistency rules:
|
||||
|
||||
- Every projector applies read-model row updates and `projection_state.lastAppliedSequence` in the same database transaction.
|
||||
- Optional debug field on projection rows: `lastEventSequence: number` (not required for correctness).
|
||||
|
||||
### 7.4 Snapshot and RPC Requirements
|
||||
|
||||
1. `orchestration.getSnapshot` is fully served from projection tables and returns `snapshotSequence: number`.
|
||||
2. Snapshot must include `projects[]` from `projection_projects`.
|
||||
3. Thread snapshot must include `checkpoints[]` from `projection_checkpoints`:
|
||||
|
||||
- `turnId: TurnId`
|
||||
- `completedAt: IsoDateTime`
|
||||
- `status`
|
||||
- `files[]` (`path`, `kind`, `additions`, `deletions`)
|
||||
- `checkpointRef: CheckpointRef`
|
||||
- `assistantMessageId?: MessageId`
|
||||
- `checkpointTurnCount: number`
|
||||
|
||||
4. Client does not require `listCheckpoints` RPC:
|
||||
|
||||
- checkpoint list comes from snapshot projections
|
||||
- full diff text comes from `orchestration.getTurnDiff` backed by `checkpoint_diff_blobs`
|
||||
|
||||
5. Provider session identity is not a client routing key:
|
||||
|
||||
- client acts on `ThreadId`
|
||||
- server resolves provider session internally via `projection_thread_sessions`
|
||||
|
||||
6. `snapshotSequence` is derived from `projection_state`:
|
||||
|
||||
- if snapshot depends on multiple projectors, use the minimum `lastAppliedSequence` across those projectors.
|
||||
|
||||
7. Event subscription handoff contract:
|
||||
|
||||
- client performs `getSnapshot` and reads `snapshotSequence`
|
||||
- client subscribes/replays with `fromSequenceExclusive = snapshotSequence`
|
||||
- server guarantees no gap between snapshot visibility and subsequent event stream from that sequence.
|
||||
|
||||
### 7.5 External Derived State (Non-Orchestration)
|
||||
|
||||
1. Current git/worktree state is not projected from orchestration events.
|
||||
2. If persisted, it belongs in a separate git cache/read model (for example `git_state_cache`) owned by a git service.
|
||||
3. Orchestration may embed git metadata only when captured as a domain fact (for example checkpoint metadata at turn completion).
|
||||
4. Any RPC for current git status should be outside orchestration RPC (for example `git.getThreadState`).
|
||||
|
||||
### 7.6 Existing Repository Placement
|
||||
|
||||
1. `ProjectsRepository`
|
||||
|
||||
- Fits as projection/query access on top of `projection_projects` plus orchestration command dispatch for writes.
|
||||
- Must not bypass command->event append path for mutations.
|
||||
|
||||
2. `CheckpointsRepository`
|
||||
|
||||
- Fits as projection/query access on top of `projection_checkpoints` plus `checkpoint_diff_blobs` (or git-service on-demand diff implementation).
|
||||
- Represents the same concept as prior `turn_diff_summary`; canonical naming is `checkpoint`.
|
||||
- Must not be an independent source of truth outside orchestration events.
|
||||
|
||||
3. `ProviderSessionsRepository`
|
||||
|
||||
- Fits as server-internal runtime persistence on top of `provider_session_runtime`, with domain-visible state projected into `projection_thread_sessions`.
|
||||
- Not part of client RPC/domain aggregate boundary.
|
||||
@@ -37,6 +37,8 @@ import { ProviderUnsupportedError } from "../src/provider/Errors.ts";
|
||||
import { ProviderAdapterRegistry } from "../src/provider/Services/ProviderAdapterRegistry.ts";
|
||||
import { ProviderSessionDirectoryLive } from "../src/provider/Layers/ProviderSessionDirectory.ts";
|
||||
import { makeProviderServiceLive } from "../src/provider/Layers/ProviderService.ts";
|
||||
import { makeCodexAdapterLive } from "../src/provider/Layers/CodexAdapter.ts";
|
||||
import { CodexAdapter } from "../src/provider/Services/CodexAdapter.ts";
|
||||
import { ProviderService } from "../src/provider/Services/ProviderService.ts";
|
||||
import { CheckpointReactorLive } from "../src/orchestration/Layers/CheckpointReactor.ts";
|
||||
import { OrchestrationEngineLive } from "../src/orchestration/Layers/OrchestrationEngine.ts";
|
||||
@@ -185,229 +187,264 @@ export interface OrchestrationIntegrationHarness {
|
||||
readonly dispose: Effect.Effect<void, never>;
|
||||
}
|
||||
|
||||
export const makeOrchestrationIntegrationHarness = Effect.gen(function* () {
|
||||
const sleep = (ms: number) => Effect.sleep(ms);
|
||||
const adapterHarness = yield* makeTestProviderAdapterHarness;
|
||||
interface MakeOrchestrationIntegrationHarnessOptions {
|
||||
readonly provider?: "codex" | "claudeCode";
|
||||
readonly realCodex?: boolean;
|
||||
}
|
||||
|
||||
const rootDir = fs.mkdtempSync(path.join(os.tmpdir(), "t3-orchestration-integration-"));
|
||||
const workspaceDir = path.join(rootDir, "workspace");
|
||||
const stateDir = path.join(rootDir, "state");
|
||||
const dbPath = path.join(stateDir, "state.sqlite");
|
||||
fs.mkdirSync(workspaceDir, { recursive: true });
|
||||
fs.mkdirSync(stateDir, { recursive: true });
|
||||
initializeGitWorkspace(workspaceDir);
|
||||
export const makeOrchestrationIntegrationHarness = (
|
||||
options?: MakeOrchestrationIntegrationHarnessOptions,
|
||||
) =>
|
||||
Effect.gen(function* () {
|
||||
const sleep = (ms: number) => Effect.sleep(ms);
|
||||
const provider = options?.provider ?? "codex";
|
||||
const useRealCodex = options?.realCodex === true;
|
||||
const adapterHarness = useRealCodex
|
||||
? null
|
||||
: yield* makeTestProviderAdapterHarness({
|
||||
provider,
|
||||
});
|
||||
const fakeRegistry = adapterHarness
|
||||
? Layer.succeed(ProviderAdapterRegistry, {
|
||||
getByProvider: (resolvedProvider) =>
|
||||
resolvedProvider === adapterHarness.provider
|
||||
? Effect.succeed(adapterHarness.adapter)
|
||||
: Effect.fail(new ProviderUnsupportedError({ provider: resolvedProvider })),
|
||||
listProviders: () => Effect.succeed([adapterHarness.provider]),
|
||||
} as typeof ProviderAdapterRegistry.Service)
|
||||
: null;
|
||||
const rootDir = fs.mkdtempSync(path.join(os.tmpdir(), "t3-orchestration-integration-"));
|
||||
const workspaceDir = path.join(rootDir, "workspace");
|
||||
const stateDir = path.join(rootDir, "state");
|
||||
const dbPath = path.join(stateDir, "state.sqlite");
|
||||
fs.mkdirSync(workspaceDir, { recursive: true });
|
||||
fs.mkdirSync(stateDir, { recursive: true });
|
||||
initializeGitWorkspace(workspaceDir);
|
||||
|
||||
const registry: typeof ProviderAdapterRegistry.Service = {
|
||||
getByProvider: (provider) =>
|
||||
provider === "codex"
|
||||
? Effect.succeed(adapterHarness.adapter)
|
||||
: Effect.fail(new ProviderUnsupportedError({ provider })),
|
||||
listProviders: () => Effect.succeed(["codex"]),
|
||||
};
|
||||
const persistenceLayer = makeSqlitePersistenceLive(dbPath);
|
||||
const orchestrationLayer = OrchestrationEngineLive.pipe(
|
||||
Layer.provide(OrchestrationProjectionPipelineLive),
|
||||
Layer.provide(OrchestrationEventStoreLive),
|
||||
Layer.provide(OrchestrationCommandReceiptRepositoryLive),
|
||||
);
|
||||
const providerSessionDirectoryLayer = ProviderSessionDirectoryLive.pipe(
|
||||
Layer.provide(ProviderSessionRuntimeRepositoryLive),
|
||||
);
|
||||
const realCodexRegistry = Layer.effect(
|
||||
ProviderAdapterRegistry,
|
||||
Effect.gen(function* () {
|
||||
const codexAdapter = yield* CodexAdapter;
|
||||
return {
|
||||
getByProvider: (resolvedProvider) =>
|
||||
resolvedProvider === "codex"
|
||||
? Effect.succeed(codexAdapter)
|
||||
: Effect.fail(new ProviderUnsupportedError({ provider: resolvedProvider })),
|
||||
listProviders: () => Effect.succeed(["codex"] as const),
|
||||
} as typeof ProviderAdapterRegistry.Service;
|
||||
}),
|
||||
).pipe(
|
||||
Layer.provide(makeCodexAdapterLive()),
|
||||
Layer.provideMerge(ServerConfig.layerTest(workspaceDir, stateDir)),
|
||||
Layer.provideMerge(NodeServices.layer),
|
||||
Layer.provideMerge(providerSessionDirectoryLayer),
|
||||
);
|
||||
const providerLayer = useRealCodex
|
||||
? makeProviderServiceLive().pipe(
|
||||
Layer.provide(providerSessionDirectoryLayer),
|
||||
Layer.provide(realCodexRegistry),
|
||||
)
|
||||
: makeProviderServiceLive().pipe(
|
||||
Layer.provide(providerSessionDirectoryLayer),
|
||||
Layer.provide(fakeRegistry!),
|
||||
);
|
||||
|
||||
const persistenceLayer = makeSqlitePersistenceLive(dbPath);
|
||||
const orchestrationLayer = OrchestrationEngineLive.pipe(
|
||||
Layer.provide(OrchestrationProjectionPipelineLive),
|
||||
Layer.provide(OrchestrationEventStoreLive),
|
||||
Layer.provide(OrchestrationCommandReceiptRepositoryLive),
|
||||
);
|
||||
const providerSessionDirectoryLayer = ProviderSessionDirectoryLive.pipe(
|
||||
Layer.provide(ProviderSessionRuntimeRepositoryLive),
|
||||
);
|
||||
const providerLayer = makeProviderServiceLive().pipe(
|
||||
Layer.provide(providerSessionDirectoryLayer),
|
||||
Layer.provide(Layer.succeed(ProviderAdapterRegistry, registry)),
|
||||
);
|
||||
|
||||
const runtimeServicesLayer = Layer.mergeAll(
|
||||
orchestrationLayer,
|
||||
OrchestrationProjectionSnapshotQueryLive,
|
||||
ProjectionCheckpointRepositoryLive,
|
||||
ProjectionPendingApprovalRepositoryLive,
|
||||
CheckpointStoreLive,
|
||||
providerLayer,
|
||||
);
|
||||
const runtimeIngestionLayer = ProviderRuntimeIngestionLive.pipe(
|
||||
Layer.provideMerge(runtimeServicesLayer),
|
||||
);
|
||||
const gitCoreLayer = Layer.succeed(GitCore, {
|
||||
renameBranch: (input: Parameters<GitCoreShape["renameBranch"]>[0]) =>
|
||||
Effect.succeed({ branch: input.newBranch }),
|
||||
} as unknown as GitCoreShape);
|
||||
const textGenerationLayer = Layer.succeed(TextGeneration, {
|
||||
generateBranchName: () => Effect.succeed({ branch: null }),
|
||||
} as unknown as TextGenerationShape);
|
||||
const providerCommandReactorLayer = ProviderCommandReactorLive.pipe(
|
||||
Layer.provideMerge(runtimeServicesLayer),
|
||||
Layer.provideMerge(gitCoreLayer),
|
||||
Layer.provideMerge(textGenerationLayer),
|
||||
);
|
||||
const checkpointReactorLayer = CheckpointReactorLive.pipe(
|
||||
Layer.provideMerge(runtimeServicesLayer),
|
||||
);
|
||||
const orchestrationReactorLayer = OrchestrationReactorLive.pipe(
|
||||
Layer.provideMerge(runtimeIngestionLayer),
|
||||
Layer.provideMerge(providerCommandReactorLayer),
|
||||
Layer.provideMerge(checkpointReactorLayer),
|
||||
);
|
||||
const layer = orchestrationReactorLayer.pipe(
|
||||
Layer.provide(persistenceLayer),
|
||||
Layer.provideMerge(ServerConfig.layerTest(workspaceDir, stateDir)),
|
||||
Layer.provideMerge(NodeServices.layer),
|
||||
);
|
||||
|
||||
const runtime = ManagedRuntime.make(layer);
|
||||
const engine = yield* tryRuntimePromise("load OrchestrationEngine service", () =>
|
||||
runtime.runPromise(Effect.service(OrchestrationEngineService)),
|
||||
).pipe(Effect.orDie);
|
||||
const reactor = yield* tryRuntimePromise("load OrchestrationReactor service", () =>
|
||||
runtime.runPromise(Effect.service(OrchestrationReactor)),
|
||||
).pipe(Effect.orDie);
|
||||
const snapshotQuery = yield* tryRuntimePromise("load ProjectionSnapshotQuery service", () =>
|
||||
runtime.runPromise(Effect.service(ProjectionSnapshotQuery)),
|
||||
).pipe(Effect.orDie);
|
||||
const providerService = yield* tryRuntimePromise("load ProviderService service", () =>
|
||||
runtime.runPromise(Effect.service(ProviderService)),
|
||||
).pipe(Effect.orDie);
|
||||
const checkpointStore = yield* tryRuntimePromise("load CheckpointStore service", () =>
|
||||
runtime.runPromise(Effect.service(CheckpointStore)),
|
||||
).pipe(Effect.orDie);
|
||||
const checkpointRepository = yield* tryRuntimePromise(
|
||||
"load ProjectionCheckpointRepository service",
|
||||
() => runtime.runPromise(Effect.service(ProjectionCheckpointRepository)),
|
||||
).pipe(Effect.orDie);
|
||||
const pendingApprovalRepository = yield* tryRuntimePromise(
|
||||
"load ProjectionPendingApprovalRepository service",
|
||||
() => runtime.runPromise(Effect.service(ProjectionPendingApprovalRepository)),
|
||||
).pipe(Effect.orDie);
|
||||
|
||||
const scope = yield* Scope.make("sequential");
|
||||
yield* tryRuntimePromise("start OrchestrationReactor", () =>
|
||||
runtime.runPromise(reactor.start.pipe(Scope.provide(scope))),
|
||||
).pipe(Effect.orDie);
|
||||
yield* sleep(10);
|
||||
|
||||
const waitForThread: OrchestrationIntegrationHarness["waitForThread"] = (
|
||||
threadId,
|
||||
predicate,
|
||||
timeoutMs,
|
||||
) =>
|
||||
waitFor(
|
||||
snapshotQuery
|
||||
.getSnapshot()
|
||||
.pipe(
|
||||
Effect.map(
|
||||
(snapshot) => snapshot.threads.find((thread) => thread.id === threadId) ?? null,
|
||||
),
|
||||
),
|
||||
(thread): thread is OrchestrationThread => thread !== null && predicate(thread),
|
||||
`projected thread '${threadId}'`,
|
||||
timeoutMs,
|
||||
) as Effect.Effect<OrchestrationThread, never>;
|
||||
|
||||
const waitForDomainEvent: OrchestrationIntegrationHarness["waitForDomainEvent"] = (
|
||||
predicate,
|
||||
timeoutMs,
|
||||
) =>
|
||||
waitFor(
|
||||
Stream.runCollect(engine.readEvents(0)).pipe(
|
||||
Effect.map((chunk): ReadonlyArray<OrchestrationEvent> => Array.from(chunk)),
|
||||
),
|
||||
(events) => events.some(predicate),
|
||||
"domain event",
|
||||
timeoutMs,
|
||||
const runtimeServicesLayer = Layer.mergeAll(
|
||||
orchestrationLayer,
|
||||
OrchestrationProjectionSnapshotQueryLive,
|
||||
ProjectionCheckpointRepositoryLive,
|
||||
ProjectionPendingApprovalRepositoryLive,
|
||||
CheckpointStoreLive,
|
||||
providerLayer,
|
||||
);
|
||||
const runtimeIngestionLayer = ProviderRuntimeIngestionLive.pipe(
|
||||
Layer.provideMerge(runtimeServicesLayer),
|
||||
);
|
||||
const gitCoreLayer = Layer.succeed(GitCore, {
|
||||
renameBranch: (input: Parameters<GitCoreShape["renameBranch"]>[0]) =>
|
||||
Effect.succeed({ branch: input.newBranch }),
|
||||
} as unknown as GitCoreShape);
|
||||
const textGenerationLayer = Layer.succeed(TextGeneration, {
|
||||
generateBranchName: () => Effect.succeed({ branch: null }),
|
||||
} as unknown as TextGenerationShape);
|
||||
const providerCommandReactorLayer = ProviderCommandReactorLive.pipe(
|
||||
Layer.provideMerge(runtimeServicesLayer),
|
||||
Layer.provideMerge(gitCoreLayer),
|
||||
Layer.provideMerge(textGenerationLayer),
|
||||
);
|
||||
const checkpointReactorLayer = CheckpointReactorLive.pipe(
|
||||
Layer.provideMerge(runtimeServicesLayer),
|
||||
);
|
||||
const orchestrationReactorLayer = OrchestrationReactorLive.pipe(
|
||||
Layer.provideMerge(runtimeIngestionLayer),
|
||||
Layer.provideMerge(providerCommandReactorLayer),
|
||||
Layer.provideMerge(checkpointReactorLayer),
|
||||
);
|
||||
const layer = orchestrationReactorLayer.pipe(
|
||||
Layer.provide(persistenceLayer),
|
||||
Layer.provideMerge(ServerConfig.layerTest(workspaceDir, stateDir)),
|
||||
Layer.provideMerge(NodeServices.layer),
|
||||
);
|
||||
|
||||
const waitForPendingApproval: OrchestrationIntegrationHarness["waitForPendingApproval"] = (
|
||||
requestId,
|
||||
predicate,
|
||||
timeoutMs,
|
||||
) =>
|
||||
waitFor(
|
||||
pendingApprovalRepository
|
||||
.getByRequestId({ requestId: ApprovalRequestId.makeUnsafe(requestId) })
|
||||
.pipe(
|
||||
Effect.map((row) =>
|
||||
Option.match(row, {
|
||||
onNone: () => null,
|
||||
onSome: (value) => ({
|
||||
status: value.status,
|
||||
decision: value.decision,
|
||||
resolvedAt: value.resolvedAt,
|
||||
}),
|
||||
}),
|
||||
),
|
||||
),
|
||||
(
|
||||
row,
|
||||
): row is {
|
||||
readonly status: "pending" | "resolved";
|
||||
readonly decision: "accept" | "acceptForSession" | "decline" | "cancel" | null;
|
||||
readonly resolvedAt: string | null;
|
||||
} => row !== null && predicate(row),
|
||||
`pending approval '${requestId}'`,
|
||||
const runtime = ManagedRuntime.make(layer);
|
||||
const engine = yield* tryRuntimePromise("load OrchestrationEngine service", () =>
|
||||
runtime.runPromise(Effect.service(OrchestrationEngineService)),
|
||||
).pipe(Effect.orDie);
|
||||
const reactor = yield* tryRuntimePromise("load OrchestrationReactor service", () =>
|
||||
runtime.runPromise(Effect.service(OrchestrationReactor)),
|
||||
).pipe(Effect.orDie);
|
||||
const snapshotQuery = yield* tryRuntimePromise("load ProjectionSnapshotQuery service", () =>
|
||||
runtime.runPromise(Effect.service(ProjectionSnapshotQuery)),
|
||||
).pipe(Effect.orDie);
|
||||
const providerService = yield* tryRuntimePromise("load ProviderService service", () =>
|
||||
runtime.runPromise(Effect.service(ProviderService)),
|
||||
).pipe(Effect.orDie);
|
||||
const checkpointStore = yield* tryRuntimePromise("load CheckpointStore service", () =>
|
||||
runtime.runPromise(Effect.service(CheckpointStore)),
|
||||
).pipe(Effect.orDie);
|
||||
const checkpointRepository = yield* tryRuntimePromise(
|
||||
"load ProjectionCheckpointRepository service",
|
||||
() => runtime.runPromise(Effect.service(ProjectionCheckpointRepository)),
|
||||
).pipe(Effect.orDie);
|
||||
const pendingApprovalRepository = yield* tryRuntimePromise(
|
||||
"load ProjectionPendingApprovalRepository service",
|
||||
() => runtime.runPromise(Effect.service(ProjectionPendingApprovalRepository)),
|
||||
).pipe(Effect.orDie);
|
||||
|
||||
const scope = yield* Scope.make("sequential");
|
||||
yield* tryRuntimePromise("start OrchestrationReactor", () =>
|
||||
runtime.runPromise(reactor.start.pipe(Scope.provide(scope))),
|
||||
).pipe(Effect.orDie);
|
||||
yield* sleep(10);
|
||||
|
||||
const waitForThread: OrchestrationIntegrationHarness["waitForThread"] = (
|
||||
threadId,
|
||||
predicate,
|
||||
timeoutMs,
|
||||
) as Effect.Effect<
|
||||
{
|
||||
readonly status: "pending" | "resolved";
|
||||
readonly decision: "accept" | "acceptForSession" | "decline" | "cancel" | null;
|
||||
readonly resolvedAt: string | null;
|
||||
},
|
||||
never
|
||||
>;
|
||||
) =>
|
||||
waitFor(
|
||||
snapshotQuery
|
||||
.getSnapshot()
|
||||
.pipe(
|
||||
Effect.map(
|
||||
(snapshot) => snapshot.threads.find((thread) => thread.id === threadId) ?? null,
|
||||
),
|
||||
),
|
||||
(thread): thread is OrchestrationThread => thread !== null && predicate(thread),
|
||||
`projected thread '${threadId}'`,
|
||||
timeoutMs,
|
||||
) as Effect.Effect<OrchestrationThread, never>;
|
||||
|
||||
let disposed = false;
|
||||
const dispose = Effect.gen(function* () {
|
||||
if (disposed) {
|
||||
return;
|
||||
}
|
||||
disposed = true;
|
||||
|
||||
const shutdown = Effect.gen(function* () {
|
||||
const stopAllExit = yield* Effect.exit(
|
||||
Effect.promise(() => runtime.runPromise(providerService.stopAll())),
|
||||
const waitForDomainEvent: OrchestrationIntegrationHarness["waitForDomainEvent"] = (
|
||||
predicate,
|
||||
timeoutMs,
|
||||
) =>
|
||||
waitFor(
|
||||
Stream.runCollect(engine.readEvents(0)).pipe(
|
||||
Effect.map((chunk): ReadonlyArray<OrchestrationEvent> => Array.from(chunk)),
|
||||
),
|
||||
(events) => events.some(predicate),
|
||||
"domain event",
|
||||
timeoutMs,
|
||||
);
|
||||
const closeScopeExit = yield* Effect.exit(
|
||||
Effect.promise(() => Effect.runPromise(Scope.close(scope, Exit.void))),
|
||||
);
|
||||
const disposeRuntimeExit = yield* Effect.exit(Effect.promise(() => runtime.dispose()));
|
||||
|
||||
const failureCause = Exit.isFailure(stopAllExit)
|
||||
? stopAllExit.cause
|
||||
: Exit.isFailure(closeScopeExit)
|
||||
? closeScopeExit.cause
|
||||
: Exit.isFailure(disposeRuntimeExit)
|
||||
? disposeRuntimeExit.cause
|
||||
: null;
|
||||
const waitForPendingApproval: OrchestrationIntegrationHarness["waitForPendingApproval"] = (
|
||||
requestId,
|
||||
predicate,
|
||||
timeoutMs,
|
||||
) =>
|
||||
waitFor(
|
||||
pendingApprovalRepository
|
||||
.getByRequestId({ requestId: ApprovalRequestId.makeUnsafe(requestId) })
|
||||
.pipe(
|
||||
Effect.map((row) =>
|
||||
Option.match(row, {
|
||||
onNone: () => null,
|
||||
onSome: (value) => ({
|
||||
status: value.status,
|
||||
decision: value.decision,
|
||||
resolvedAt: value.resolvedAt,
|
||||
}),
|
||||
}),
|
||||
),
|
||||
),
|
||||
(
|
||||
row,
|
||||
): row is {
|
||||
readonly status: "pending" | "resolved";
|
||||
readonly decision: "accept" | "acceptForSession" | "decline" | "cancel" | null;
|
||||
readonly resolvedAt: string | null;
|
||||
} => row !== null && predicate(row),
|
||||
`pending approval '${requestId}'`,
|
||||
timeoutMs,
|
||||
) as Effect.Effect<
|
||||
{
|
||||
readonly status: "pending" | "resolved";
|
||||
readonly decision: "accept" | "acceptForSession" | "decline" | "cancel" | null;
|
||||
readonly resolvedAt: string | null;
|
||||
},
|
||||
never
|
||||
>;
|
||||
|
||||
if (failureCause) {
|
||||
return yield* Effect.failCause(failureCause);
|
||||
let disposed = false;
|
||||
const dispose = Effect.gen(function* () {
|
||||
if (disposed) {
|
||||
return;
|
||||
}
|
||||
disposed = true;
|
||||
|
||||
const shutdown = Effect.gen(function* () {
|
||||
const stopAllExit = yield* Effect.exit(
|
||||
Effect.promise(() => runtime.runPromise(providerService.stopAll())),
|
||||
);
|
||||
const closeScopeExit = yield* Effect.exit(Scope.close(scope, Exit.void));
|
||||
const disposeRuntimeExit = yield* Effect.exit(Effect.promise(() => runtime.dispose()));
|
||||
|
||||
const failureCause = Exit.isFailure(stopAllExit)
|
||||
? stopAllExit.cause
|
||||
: Exit.isFailure(closeScopeExit)
|
||||
? closeScopeExit.cause
|
||||
: Exit.isFailure(disposeRuntimeExit)
|
||||
? disposeRuntimeExit.cause
|
||||
: null;
|
||||
|
||||
if (failureCause) {
|
||||
return yield* Effect.failCause(failureCause);
|
||||
}
|
||||
});
|
||||
|
||||
yield* shutdown.pipe(
|
||||
Effect.ensuring(
|
||||
Effect.sync(() => {
|
||||
fs.rmSync(rootDir, { recursive: true, force: true });
|
||||
}),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
yield* shutdown.pipe(
|
||||
Effect.ensuring(
|
||||
Effect.sync(() => {
|
||||
fs.rmSync(rootDir, { recursive: true, force: true });
|
||||
}),
|
||||
),
|
||||
);
|
||||
return {
|
||||
rootDir,
|
||||
workspaceDir,
|
||||
dbPath,
|
||||
adapterHarness: adapterHarness as TestProviderAdapterHarness,
|
||||
engine,
|
||||
snapshotQuery,
|
||||
providerService,
|
||||
checkpointStore,
|
||||
checkpointRepository,
|
||||
pendingApprovalRepository,
|
||||
waitForThread,
|
||||
waitForDomainEvent,
|
||||
waitForPendingApproval,
|
||||
dispose,
|
||||
} satisfies OrchestrationIntegrationHarness;
|
||||
});
|
||||
|
||||
return {
|
||||
rootDir,
|
||||
workspaceDir,
|
||||
dbPath,
|
||||
adapterHarness,
|
||||
engine,
|
||||
snapshotQuery,
|
||||
providerService,
|
||||
checkpointStore,
|
||||
checkpointRepository,
|
||||
pendingApprovalRepository,
|
||||
waitForThread,
|
||||
waitForDomainEvent,
|
||||
waitForPendingApproval,
|
||||
dispose,
|
||||
} satisfies OrchestrationIntegrationHarness;
|
||||
});
|
||||
@@ -5,11 +5,11 @@ import {
|
||||
EventId,
|
||||
ProviderApprovalDecision,
|
||||
ProviderRuntimeEvent,
|
||||
RuntimeSessionId,
|
||||
ProviderSession,
|
||||
ProviderSessionId,
|
||||
ProviderThreadId,
|
||||
ProviderTurnId,
|
||||
ProviderTurnStartResult,
|
||||
ThreadId,
|
||||
TurnId,
|
||||
} from "@t3tools/contracts";
|
||||
import { Effect, Queue, Stream } from "effect";
|
||||
|
||||
@@ -25,13 +25,29 @@ import type {
|
||||
} from "../src/provider/Services/ProviderAdapter.ts";
|
||||
|
||||
export interface TestTurnResponse {
|
||||
readonly events: ReadonlyArray<ProviderRuntimeEvent>;
|
||||
readonly events: ReadonlyArray<FixtureProviderRuntimeEvent>;
|
||||
readonly mutateWorkspace?: (input: {
|
||||
readonly cwd: string;
|
||||
readonly turnCount: number;
|
||||
}) => Effect.Effect<void, never>;
|
||||
}
|
||||
|
||||
export type FixtureProviderRuntimeEvent = {
|
||||
readonly type: string;
|
||||
readonly eventId: EventId;
|
||||
readonly provider: "codex" | "claudeCode" | "cursor";
|
||||
readonly createdAt: string;
|
||||
readonly threadId: string;
|
||||
readonly turnId?: string | undefined;
|
||||
readonly itemId?: string | undefined;
|
||||
readonly requestId?: string | undefined;
|
||||
readonly payload?: unknown | undefined;
|
||||
readonly [key: string]: unknown;
|
||||
};
|
||||
|
||||
// Temporary alias while fixtures migrate to the new name.
|
||||
export type LegacyProviderRuntimeEvent = FixtureProviderRuntimeEvent;
|
||||
|
||||
interface SessionState {
|
||||
readonly session: ProviderSession;
|
||||
snapshot: ProviderThreadSnapshot;
|
||||
@@ -40,82 +56,217 @@ interface SessionState {
|
||||
readonly rollbackCalls: Array<number>;
|
||||
}
|
||||
|
||||
function isRecord(value: unknown): value is Record<string, unknown> {
|
||||
return typeof value === "object" && value !== null;
|
||||
}
|
||||
|
||||
function normalizeTurnState(value: unknown): "completed" | "failed" | "interrupted" | "cancelled" {
|
||||
if (
|
||||
value === "completed" ||
|
||||
value === "failed" ||
|
||||
value === "interrupted" ||
|
||||
value === "cancelled"
|
||||
) {
|
||||
return value;
|
||||
}
|
||||
return "completed";
|
||||
}
|
||||
|
||||
function mapRequestType(requestKind: unknown):
|
||||
| "command_execution_approval"
|
||||
| "file_change_approval"
|
||||
| "unknown" {
|
||||
if (requestKind === "command") {
|
||||
return "command_execution_approval";
|
||||
}
|
||||
if (requestKind === "file-change") {
|
||||
return "file_change_approval";
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
function mapItemType(toolKind: unknown): "command_execution" | "file_change" | "unknown" {
|
||||
if (toolKind === "command") {
|
||||
return "command_execution";
|
||||
}
|
||||
if (toolKind === "file-change") {
|
||||
return "file_change";
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
function normalizeFixtureEvent(rawEvent: Record<string, unknown>): ProviderRuntimeEvent {
|
||||
const type = typeof rawEvent.type === "string" ? rawEvent.type : "";
|
||||
switch (type) {
|
||||
case "turn.started":
|
||||
return {
|
||||
...rawEvent,
|
||||
type: "turn.started",
|
||||
payload: isRecord(rawEvent.payload) ? rawEvent.payload : {},
|
||||
} as ProviderRuntimeEvent;
|
||||
case "turn.completed":
|
||||
return {
|
||||
...rawEvent,
|
||||
type: "turn.completed",
|
||||
payload: isRecord(rawEvent.payload)
|
||||
? rawEvent.payload
|
||||
: {
|
||||
state: normalizeTurnState(rawEvent.status),
|
||||
},
|
||||
} as ProviderRuntimeEvent;
|
||||
case "message.delta":
|
||||
return {
|
||||
...rawEvent,
|
||||
type: "content.delta",
|
||||
payload: {
|
||||
streamKind: "assistant_text",
|
||||
delta: typeof rawEvent.delta === "string" ? rawEvent.delta : "",
|
||||
},
|
||||
} as ProviderRuntimeEvent;
|
||||
case "message.completed":
|
||||
return {
|
||||
...rawEvent,
|
||||
type: "item.completed",
|
||||
payload: {
|
||||
itemType: "assistant_message",
|
||||
...(typeof rawEvent.detail === "string" ? { detail: rawEvent.detail } : {}),
|
||||
},
|
||||
} as ProviderRuntimeEvent;
|
||||
case "tool.started":
|
||||
return {
|
||||
...rawEvent,
|
||||
type: "item.started",
|
||||
payload: {
|
||||
itemType: mapItemType(rawEvent.toolKind),
|
||||
...(typeof rawEvent.title === "string" ? { title: rawEvent.title } : {}),
|
||||
...(typeof rawEvent.detail === "string" ? { detail: rawEvent.detail } : {}),
|
||||
},
|
||||
} as ProviderRuntimeEvent;
|
||||
case "tool.completed":
|
||||
return {
|
||||
...rawEvent,
|
||||
type: "item.completed",
|
||||
payload: {
|
||||
itemType: mapItemType(rawEvent.toolKind),
|
||||
status: "completed",
|
||||
...(typeof rawEvent.title === "string" ? { title: rawEvent.title } : {}),
|
||||
...(typeof rawEvent.detail === "string" ? { detail: rawEvent.detail } : {}),
|
||||
},
|
||||
} as ProviderRuntimeEvent;
|
||||
case "approval.requested":
|
||||
return {
|
||||
...rawEvent,
|
||||
type: "request.opened",
|
||||
payload: {
|
||||
requestType: mapRequestType(rawEvent.requestKind),
|
||||
...(typeof rawEvent.detail === "string" ? { detail: rawEvent.detail } : {}),
|
||||
},
|
||||
} as ProviderRuntimeEvent;
|
||||
case "approval.resolved":
|
||||
return {
|
||||
...rawEvent,
|
||||
type: "request.resolved",
|
||||
payload: {
|
||||
requestType: mapRequestType(rawEvent.requestKind),
|
||||
...(typeof rawEvent.decision === "string" ? { decision: rawEvent.decision } : {}),
|
||||
},
|
||||
} as ProviderRuntimeEvent;
|
||||
default:
|
||||
return rawEvent as ProviderRuntimeEvent;
|
||||
}
|
||||
}
|
||||
|
||||
export interface TestProviderAdapterHarness {
|
||||
readonly adapter: ProviderAdapterShape<ProviderAdapterError>;
|
||||
readonly provider: "codex" | "claudeCode";
|
||||
readonly queueTurnResponse: (
|
||||
sessionId: string,
|
||||
threadId: ThreadId,
|
||||
response: TestTurnResponse,
|
||||
) => Effect.Effect<void, ProviderAdapterSessionNotFoundError>;
|
||||
readonly queueTurnResponseForNextSession: (
|
||||
response: TestTurnResponse,
|
||||
) => Effect.Effect<void, never>;
|
||||
readonly getRollbackCalls: (sessionId: string) => ReadonlyArray<number>;
|
||||
readonly getApprovalResponses: (sessionId: string) => ReadonlyArray<{
|
||||
readonly sessionId: ProviderSessionId;
|
||||
readonly getStartCount: () => number;
|
||||
readonly getRollbackCalls: (threadId: ThreadId) => ReadonlyArray<number>;
|
||||
readonly getInterruptCalls: (threadId: ThreadId) => ReadonlyArray<TurnId | undefined>;
|
||||
readonly listActiveSessionIds: () => ReadonlyArray<ThreadId>;
|
||||
readonly getApprovalResponses: (threadId: ThreadId) => ReadonlyArray<{
|
||||
readonly threadId: ThreadId;
|
||||
readonly requestId: ApprovalRequestId;
|
||||
readonly decision: ProviderApprovalDecision;
|
||||
}>;
|
||||
}
|
||||
|
||||
const PROVIDER = "codex" as const;
|
||||
interface MakeTestProviderAdapterHarnessOptions {
|
||||
readonly provider?: "codex" | "claudeCode";
|
||||
}
|
||||
|
||||
function nowIso(): string {
|
||||
return new Date().toISOString();
|
||||
}
|
||||
|
||||
function sessionNotFound(sessionId: string): ProviderAdapterSessionNotFoundError {
|
||||
function sessionNotFound(
|
||||
provider: "codex" | "claudeCode",
|
||||
threadId: ThreadId,
|
||||
): ProviderAdapterSessionNotFoundError {
|
||||
return new ProviderAdapterSessionNotFoundError({
|
||||
provider: PROVIDER,
|
||||
sessionId,
|
||||
provider,
|
||||
threadId: String(threadId),
|
||||
});
|
||||
}
|
||||
|
||||
function missingSessionEffect(sessionId: string): Effect.Effect<never, ProviderAdapterError> {
|
||||
return Effect.fail(sessionNotFound(sessionId));
|
||||
function missingSessionEffect(
|
||||
provider: "codex" | "claudeCode",
|
||||
threadId: ThreadId,
|
||||
): Effect.Effect<never, ProviderAdapterError> {
|
||||
return Effect.fail(sessionNotFound(provider, threadId));
|
||||
}
|
||||
|
||||
export const makeTestProviderAdapterHarness = Effect.gen(function* () {
|
||||
const runtimeEvents = yield* Queue.unbounded<ProviderRuntimeEvent>();
|
||||
let sessionCount = 0;
|
||||
const sessions = new Map<string, SessionState>();
|
||||
const queuedResponsesForNextSession: TestTurnResponse[] = [];
|
||||
const approvalResponsesBySession = new Map<
|
||||
string,
|
||||
Array<{
|
||||
readonly sessionId: ProviderSessionId;
|
||||
readonly requestId: ApprovalRequestId;
|
||||
readonly decision: ProviderApprovalDecision;
|
||||
}>
|
||||
>();
|
||||
export const makeTestProviderAdapterHarness = (options?: MakeTestProviderAdapterHarnessOptions) =>
|
||||
Effect.gen(function* () {
|
||||
const provider = options?.provider ?? "codex";
|
||||
const runtimeEvents = yield* Queue.unbounded<ProviderRuntimeEvent>();
|
||||
let sessionCount = 0;
|
||||
const sessions = new Map<ThreadId, SessionState>();
|
||||
const queuedResponsesForNextSession: TestTurnResponse[] = [];
|
||||
const interruptCallsBySession = new Map<ThreadId, Array<TurnId | undefined>>();
|
||||
const approvalResponsesBySession = new Map<
|
||||
ThreadId,
|
||||
Array<{
|
||||
readonly threadId: ThreadId;
|
||||
readonly requestId: ApprovalRequestId;
|
||||
readonly decision: ProviderApprovalDecision;
|
||||
}>
|
||||
>();
|
||||
|
||||
const emit = (event: ProviderRuntimeEvent) => Queue.offer(runtimeEvents, event);
|
||||
|
||||
const startSession: ProviderAdapterShape<ProviderAdapterError>["startSession"] = (input) =>
|
||||
Effect.gen(function* () {
|
||||
if (input.provider !== undefined && input.provider !== PROVIDER) {
|
||||
if (input.provider !== undefined && input.provider !== provider) {
|
||||
return yield* new ProviderAdapterValidationError({
|
||||
provider: PROVIDER,
|
||||
provider,
|
||||
operation: "startSession",
|
||||
issue: `Expected provider '${PROVIDER}' but received '${input.provider}'.`,
|
||||
issue: `Expected provider '${provider}' but received '${input.provider}'.`,
|
||||
});
|
||||
}
|
||||
|
||||
sessionCount += 1;
|
||||
const sessionId = ProviderSessionId.makeUnsafe(`test-session-${sessionCount}`);
|
||||
const threadId = ProviderThreadId.makeUnsafe(`test-thread-${sessionCount}`);
|
||||
const threadId = input.threadId;
|
||||
const createdAt = nowIso();
|
||||
|
||||
const session: ProviderSession = {
|
||||
sessionId,
|
||||
provider: PROVIDER,
|
||||
provider,
|
||||
status: "ready",
|
||||
runtimeMode: input.runtimeMode,
|
||||
threadId,
|
||||
cwd: input.cwd,
|
||||
resumeCursor: input.resumeCursor ?? { threadId: String(threadId), seed: sessionCount },
|
||||
createdAt,
|
||||
updatedAt: createdAt,
|
||||
};
|
||||
|
||||
sessions.set(sessionId, {
|
||||
sessions.set(threadId, {
|
||||
session,
|
||||
snapshot: {
|
||||
threadId,
|
||||
@@ -131,21 +282,21 @@ export const makeTestProviderAdapterHarness = Effect.gen(function* () {
|
||||
|
||||
const sendTurn: ProviderAdapterShape<ProviderAdapterError>["sendTurn"] = (input) =>
|
||||
Effect.gen(function* () {
|
||||
const state = sessions.get(input.sessionId);
|
||||
const state = sessions.get(input.threadId);
|
||||
if (!state) {
|
||||
return yield* missingSessionEffect(input.sessionId);
|
||||
return yield* missingSessionEffect(provider, input.threadId);
|
||||
}
|
||||
|
||||
state.turnCount += 1;
|
||||
const turnCount = state.turnCount;
|
||||
const turnId = ProviderTurnId.makeUnsafe(`turn-${turnCount}`);
|
||||
const turnId = TurnId.makeUnsafe(`turn-${turnCount}`);
|
||||
|
||||
const response = state.queuedResponses.shift();
|
||||
if (!response) {
|
||||
return yield* new ProviderAdapterValidationError({
|
||||
provider: PROVIDER,
|
||||
provider,
|
||||
operation: "sendTurn",
|
||||
issue: `No queued turn response for session ${input.sessionId}.`,
|
||||
issue: `No queued turn response for thread ${input.threadId}.`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -155,20 +306,27 @@ export const makeTestProviderAdapterHarness = Effect.gen(function* () {
|
||||
const rawEvent: Record<string, unknown> = {
|
||||
...(fixtureEvent as Record<string, unknown>),
|
||||
eventId: randomUUID(),
|
||||
provider: PROVIDER,
|
||||
sessionId: input.sessionId,
|
||||
provider,
|
||||
sessionId: RuntimeSessionId.makeUnsafe(String(input.threadId)),
|
||||
createdAt: nowIso(),
|
||||
};
|
||||
if (Object.hasOwn(rawEvent, "threadId")) {
|
||||
rawEvent.threadId = state.snapshot.threadId;
|
||||
}
|
||||
rawEvent.threadId = state.snapshot.threadId;
|
||||
if (Object.hasOwn(rawEvent, "turnId")) {
|
||||
rawEvent.turnId = turnId;
|
||||
}
|
||||
|
||||
const runtimeEvent = rawEvent as ProviderRuntimeEvent;
|
||||
if (runtimeEvent.type === "message.delta") {
|
||||
assistantDeltas.push(runtimeEvent.delta);
|
||||
const runtimeEvent = normalizeFixtureEvent(rawEvent);
|
||||
const runtimeType = (runtimeEvent as { type: string }).type;
|
||||
if (runtimeType === "content.delta") {
|
||||
const payload = runtimeEvent.payload as { delta?: unknown } | undefined;
|
||||
if (typeof payload?.delta === "string") {
|
||||
assistantDeltas.push(payload.delta);
|
||||
}
|
||||
} else if (runtimeType === "message.delta") {
|
||||
const legacyDelta = (runtimeEvent as { delta?: unknown }).delta;
|
||||
if (typeof legacyDelta === "string") {
|
||||
assistantDeltas.push(legacyDelta);
|
||||
}
|
||||
}
|
||||
if (runtimeEvent.type === "turn.completed") {
|
||||
deferredTurnCompletedEvents.push(runtimeEvent);
|
||||
@@ -206,12 +364,13 @@ export const makeTestProviderAdapterHarness = Effect.gen(function* () {
|
||||
yield* emit({
|
||||
type: "turn.completed",
|
||||
eventId: EventId.makeUnsafe(randomUUID()),
|
||||
provider: PROVIDER,
|
||||
sessionId: input.sessionId,
|
||||
provider,
|
||||
createdAt: nowIso(),
|
||||
threadId: state.snapshot.threadId,
|
||||
turnId,
|
||||
status: "completed",
|
||||
payload: {
|
||||
state: "completed",
|
||||
},
|
||||
});
|
||||
} else {
|
||||
for (const completedEvent of deferredTurnCompletedEvents) {
|
||||
@@ -226,58 +385,71 @@ export const makeTestProviderAdapterHarness = Effect.gen(function* () {
|
||||
});
|
||||
|
||||
const interruptTurn: ProviderAdapterShape<ProviderAdapterError>["interruptTurn"] = (
|
||||
sessionId,
|
||||
_turnId,
|
||||
) => (sessions.has(sessionId) ? Effect.void : missingSessionEffect(sessionId));
|
||||
threadId,
|
||||
turnId,
|
||||
) =>
|
||||
sessions.has(threadId)
|
||||
? Effect.sync(() => {
|
||||
const existing = interruptCallsBySession.get(threadId) ?? [];
|
||||
existing.push(turnId);
|
||||
interruptCallsBySession.set(threadId, existing);
|
||||
})
|
||||
: missingSessionEffect(provider, threadId);
|
||||
|
||||
const respondToRequest: ProviderAdapterShape<ProviderAdapterError>["respondToRequest"] = (
|
||||
sessionId,
|
||||
threadId,
|
||||
requestId,
|
||||
decision,
|
||||
) =>
|
||||
sessions.has(sessionId)
|
||||
sessions.has(threadId)
|
||||
? Effect.sync(() => {
|
||||
const existing = approvalResponsesBySession.get(sessionId) ?? [];
|
||||
const existing = approvalResponsesBySession.get(threadId) ?? [];
|
||||
existing.push({
|
||||
sessionId,
|
||||
threadId,
|
||||
requestId,
|
||||
decision,
|
||||
});
|
||||
approvalResponsesBySession.set(sessionId, existing);
|
||||
approvalResponsesBySession.set(threadId, existing);
|
||||
})
|
||||
: missingSessionEffect(sessionId);
|
||||
: missingSessionEffect(provider, threadId);
|
||||
|
||||
const stopSession: ProviderAdapterShape<ProviderAdapterError>["stopSession"] = (sessionId) =>
|
||||
const respondToUserInput: ProviderAdapterShape<ProviderAdapterError>["respondToUserInput"] = (
|
||||
threadId,
|
||||
_requestId,
|
||||
_answers,
|
||||
) => (sessions.has(threadId) ? Effect.void : missingSessionEffect(provider, threadId));
|
||||
|
||||
const stopSession: ProviderAdapterShape<ProviderAdapterError>["stopSession"] = (threadId) =>
|
||||
Effect.sync(() => {
|
||||
sessions.delete(sessionId);
|
||||
sessions.delete(threadId);
|
||||
});
|
||||
|
||||
const listSessions: ProviderAdapterShape<ProviderAdapterError>["listSessions"] = () =>
|
||||
Effect.sync(() => Array.from(sessions.values(), (state) => state.session));
|
||||
|
||||
const hasSession: ProviderAdapterShape<ProviderAdapterError>["hasSession"] = (sessionId) =>
|
||||
Effect.succeed(sessions.has(sessionId));
|
||||
const hasSession: ProviderAdapterShape<ProviderAdapterError>["hasSession"] = (threadId) =>
|
||||
Effect.succeed(sessions.has(threadId));
|
||||
|
||||
const readThread: ProviderAdapterShape<ProviderAdapterError>["readThread"] = (sessionId) => {
|
||||
const state = sessions.get(sessionId);
|
||||
const readThread: ProviderAdapterShape<ProviderAdapterError>["readThread"] = (threadId) => {
|
||||
const state = sessions.get(threadId);
|
||||
if (!state) {
|
||||
return missingSessionEffect(sessionId);
|
||||
return missingSessionEffect(provider, threadId);
|
||||
}
|
||||
return Effect.succeed(state.snapshot);
|
||||
};
|
||||
|
||||
const rollbackThread: ProviderAdapterShape<ProviderAdapterError>["rollbackThread"] = (
|
||||
sessionId,
|
||||
threadId,
|
||||
numTurns,
|
||||
) => {
|
||||
const state = sessions.get(sessionId);
|
||||
const state = sessions.get(threadId);
|
||||
if (!state) {
|
||||
return missingSessionEffect(sessionId);
|
||||
return missingSessionEffect(provider, threadId);
|
||||
}
|
||||
if (!Number.isInteger(numTurns) || numTurns < 0 || numTurns > state.snapshot.turns.length) {
|
||||
return Effect.fail(
|
||||
new ProviderAdapterValidationError({
|
||||
provider: PROVIDER,
|
||||
provider,
|
||||
operation: "rollbackThread",
|
||||
issue: "numTurns must be an integer between 0 and current turn count.",
|
||||
}),
|
||||
@@ -301,11 +473,15 @@ export const makeTestProviderAdapterHarness = Effect.gen(function* () {
|
||||
});
|
||||
|
||||
const adapter: ProviderAdapterShape<ProviderAdapterError> = {
|
||||
provider: PROVIDER,
|
||||
provider,
|
||||
capabilities: {
|
||||
sessionModelSwitch: "in-session",
|
||||
},
|
||||
startSession,
|
||||
sendTurn,
|
||||
interruptTurn,
|
||||
respondToRequest,
|
||||
respondToUserInput,
|
||||
stopSession,
|
||||
listSessions,
|
||||
hasSession,
|
||||
@@ -316,16 +492,16 @@ export const makeTestProviderAdapterHarness = Effect.gen(function* () {
|
||||
};
|
||||
|
||||
const queueTurnResponse = (
|
||||
sessionId: string,
|
||||
threadId: ThreadId,
|
||||
response: TestTurnResponse,
|
||||
): Effect.Effect<void, ProviderAdapterSessionNotFoundError> =>
|
||||
Effect.sync(() => sessions.get(sessionId)).pipe(
|
||||
Effect.sync(() => sessions.get(threadId)).pipe(
|
||||
Effect.flatMap((state) =>
|
||||
state
|
||||
? Effect.sync(() => {
|
||||
state.queuedResponses.push(response);
|
||||
})
|
||||
: Effect.fail(sessionNotFound(sessionId)),
|
||||
: Effect.fail(sessionNotFound(provider, threadId)),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -336,22 +512,35 @@ export const makeTestProviderAdapterHarness = Effect.gen(function* () {
|
||||
queuedResponsesForNextSession.push(response);
|
||||
});
|
||||
|
||||
const getRollbackCalls = (sessionId: string): ReadonlyArray<number> => {
|
||||
const state = sessions.get(sessionId);
|
||||
const getRollbackCalls = (threadId: ThreadId): ReadonlyArray<number> => {
|
||||
const state = sessions.get(threadId);
|
||||
if (!state) {
|
||||
return [];
|
||||
}
|
||||
return [...state.rollbackCalls];
|
||||
};
|
||||
|
||||
const getStartCount = (): number => sessionCount;
|
||||
|
||||
const getInterruptCalls = (threadId: ThreadId): ReadonlyArray<TurnId | undefined> => {
|
||||
const calls = interruptCallsBySession.get(threadId);
|
||||
if (!calls) {
|
||||
return [];
|
||||
}
|
||||
return [...calls];
|
||||
};
|
||||
|
||||
const listActiveSessionIds = (): ReadonlyArray<ThreadId> =>
|
||||
Array.from(sessions.values(), (state) => state.session.threadId);
|
||||
|
||||
const getApprovalResponses = (
|
||||
sessionId: string,
|
||||
threadId: ThreadId,
|
||||
): ReadonlyArray<{
|
||||
readonly sessionId: ProviderSessionId;
|
||||
readonly threadId: ThreadId;
|
||||
readonly requestId: ApprovalRequestId;
|
||||
readonly decision: ProviderApprovalDecision;
|
||||
}> => {
|
||||
const responses = approvalResponsesBySession.get(sessionId);
|
||||
const responses = approvalResponsesBySession.get(threadId);
|
||||
if (!responses) {
|
||||
return [];
|
||||
}
|
||||
@@ -360,9 +549,13 @@ export const makeTestProviderAdapterHarness = Effect.gen(function* () {
|
||||
|
||||
return {
|
||||
adapter,
|
||||
provider,
|
||||
queueTurnResponse,
|
||||
queueTurnResponseForNextSession,
|
||||
getStartCount,
|
||||
getRollbackCalls,
|
||||
getInterruptCalls,
|
||||
listActiveSessionIds,
|
||||
getApprovalResponses,
|
||||
} satisfies TestProviderAdapterHarness;
|
||||
});
|
||||
@@ -1,22 +1,16 @@
|
||||
import {
|
||||
ApprovalRequestId,
|
||||
EventId,
|
||||
ProviderSessionId,
|
||||
ProviderThreadId,
|
||||
ProviderTurnId,
|
||||
type ProviderRuntimeEvent,
|
||||
} from "@t3tools/contracts";
|
||||
import { EventId, RuntimeRequestId } from "@t3tools/contracts";
|
||||
import type { LegacyProviderRuntimeEvent } from "../TestProviderAdapter.integration.ts";
|
||||
|
||||
const PROVIDER = "codex" as const;
|
||||
const SESSION_ID = ProviderSessionId.makeUnsafe("fixture-session");
|
||||
const THREAD_ID = ProviderThreadId.makeUnsafe("fixture-thread");
|
||||
const TURN_ID = ProviderTurnId.makeUnsafe("fixture-turn");
|
||||
const REQUEST_ID = ApprovalRequestId.makeUnsafe("req-1");
|
||||
const SESSION_ID = "fixture-session";
|
||||
const THREAD_ID = "fixture-thread";
|
||||
const TURN_ID = "fixture-turn";
|
||||
const REQUEST_ID = RuntimeRequestId.makeUnsafe("req-1");
|
||||
|
||||
function baseEvent(
|
||||
eventId: string,
|
||||
createdAt: string,
|
||||
): Pick<ProviderRuntimeEvent, "eventId" | "provider" | "sessionId" | "createdAt"> {
|
||||
): Pick<LegacyProviderRuntimeEvent, "eventId" | "provider" | "sessionId" | "createdAt"> {
|
||||
return {
|
||||
eventId: EventId.makeUnsafe(eventId),
|
||||
provider: PROVIDER,
|
||||
@@ -31,29 +25,38 @@ export const codexTurnTextFixture = [
|
||||
...baseEvent("evt-1", "2026-02-23T00:00:00.000Z"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: TURN_ID,
|
||||
payload: {},
|
||||
},
|
||||
{
|
||||
type: "message.delta",
|
||||
type: "content.delta",
|
||||
...baseEvent("evt-2", "2026-02-23T00:00:00.100Z"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: TURN_ID,
|
||||
delta: "I will make a small update.\n",
|
||||
payload: {
|
||||
streamKind: "assistant_text",
|
||||
delta: "I will make a small update.\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "message.delta",
|
||||
type: "content.delta",
|
||||
...baseEvent("evt-3", "2026-02-23T00:00:00.200Z"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: TURN_ID,
|
||||
delta: "Done.\n",
|
||||
payload: {
|
||||
streamKind: "assistant_text",
|
||||
delta: "Done.\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "turn.completed",
|
||||
...baseEvent("evt-4", "2026-02-23T00:00:00.300Z"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: TURN_ID,
|
||||
status: "completed",
|
||||
payload: {
|
||||
state: "completed",
|
||||
},
|
||||
},
|
||||
] satisfies ReadonlyArray<ProviderRuntimeEvent>;
|
||||
] satisfies ReadonlyArray<LegacyProviderRuntimeEvent>;
|
||||
|
||||
export const codexTurnToolFixture = [
|
||||
{
|
||||
@@ -61,40 +64,51 @@ export const codexTurnToolFixture = [
|
||||
...baseEvent("evt-11", "2026-02-23T00:01:00.000Z"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: TURN_ID,
|
||||
payload: {},
|
||||
},
|
||||
{
|
||||
type: "tool.started",
|
||||
type: "item.started",
|
||||
...baseEvent("evt-12", "2026-02-23T00:01:00.100Z"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: TURN_ID,
|
||||
toolKind: "command",
|
||||
title: "Command run",
|
||||
detail: "echo integration",
|
||||
payload: {
|
||||
itemType: "command_execution",
|
||||
title: "Command run",
|
||||
detail: "echo integration",
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "tool.completed",
|
||||
type: "item.completed",
|
||||
...baseEvent("evt-13", "2026-02-23T00:01:00.200Z"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: TURN_ID,
|
||||
toolKind: "command",
|
||||
title: "Command run",
|
||||
detail: "echo integration",
|
||||
payload: {
|
||||
itemType: "command_execution",
|
||||
status: "completed",
|
||||
title: "Command run",
|
||||
detail: "echo integration",
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "message.delta",
|
||||
type: "content.delta",
|
||||
...baseEvent("evt-14", "2026-02-23T00:01:00.300Z"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: TURN_ID,
|
||||
delta: "Applied the requested edit.\n",
|
||||
payload: {
|
||||
streamKind: "assistant_text",
|
||||
delta: "Applied the requested edit.\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "turn.completed",
|
||||
...baseEvent("evt-15", "2026-02-23T00:01:00.400Z"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: TURN_ID,
|
||||
status: "completed",
|
||||
payload: {
|
||||
state: "completed",
|
||||
},
|
||||
},
|
||||
] satisfies ReadonlyArray<ProviderRuntimeEvent>;
|
||||
] satisfies ReadonlyArray<LegacyProviderRuntimeEvent>;
|
||||
|
||||
export const codexTurnApprovalFixture = [
|
||||
{
|
||||
@@ -102,37 +116,47 @@ export const codexTurnApprovalFixture = [
|
||||
...baseEvent("evt-21", "2026-02-23T00:02:00.000Z"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: TURN_ID,
|
||||
payload: {},
|
||||
},
|
||||
{
|
||||
type: "approval.requested",
|
||||
type: "request.opened",
|
||||
...baseEvent("evt-22", "2026-02-23T00:02:00.100Z"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: TURN_ID,
|
||||
requestId: REQUEST_ID,
|
||||
requestKind: "command",
|
||||
detail: "Please approve command",
|
||||
payload: {
|
||||
requestType: "command_execution_approval",
|
||||
detail: "Please approve command",
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "approval.resolved",
|
||||
type: "request.resolved",
|
||||
...baseEvent("evt-23", "2026-02-23T00:02:00.200Z"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: TURN_ID,
|
||||
requestId: REQUEST_ID,
|
||||
requestKind: "command",
|
||||
decision: "accept",
|
||||
payload: {
|
||||
requestType: "command_execution_approval",
|
||||
decision: "accept",
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "message.delta",
|
||||
type: "content.delta",
|
||||
...baseEvent("evt-24", "2026-02-23T00:02:00.300Z"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: TURN_ID,
|
||||
delta: "Approval received and command executed.\n",
|
||||
payload: {
|
||||
streamKind: "assistant_text",
|
||||
delta: "Approval received and command executed.\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "turn.completed",
|
||||
...baseEvent("evt-25", "2026-02-23T00:02:00.400Z"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: TURN_ID,
|
||||
status: "completed",
|
||||
payload: {
|
||||
state: "completed",
|
||||
},
|
||||
},
|
||||
] satisfies ReadonlyArray<ProviderRuntimeEvent>;
|
||||
] satisfies ReadonlyArray<LegacyProviderRuntimeEvent>;
|
||||
@@ -4,12 +4,10 @@ import path from "node:path";
|
||||
import {
|
||||
ApprovalRequestId,
|
||||
CommandId,
|
||||
DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
EventId,
|
||||
MessageId,
|
||||
ProjectId,
|
||||
ProviderSessionId,
|
||||
ProviderThreadId,
|
||||
ProviderTurnId,
|
||||
ThreadId,
|
||||
} from "@t3tools/contracts";
|
||||
import { assert, it } from "@effect/vitest";
|
||||
@@ -27,19 +25,14 @@ import { checkpointRefForThreadTurn } from "../src/checkpointing/Utils.ts";
|
||||
const asMessageId = (value: string): MessageId => MessageId.makeUnsafe(value);
|
||||
const asProjectId = (value: string): ProjectId => ProjectId.makeUnsafe(value);
|
||||
const asEventId = (value: string): EventId => EventId.makeUnsafe(value);
|
||||
const asProviderSessionId = (value: string): ProviderSessionId =>
|
||||
ProviderSessionId.makeUnsafe(value);
|
||||
const asProviderThreadId = (value: string): ProviderThreadId => ProviderThreadId.makeUnsafe(value);
|
||||
const asProviderTurnId = (value: string): ProviderTurnId => ProviderTurnId.makeUnsafe(value);
|
||||
const asApprovalRequestId = (value: string): ApprovalRequestId =>
|
||||
ApprovalRequestId.makeUnsafe(value);
|
||||
|
||||
const PROJECT_ID = asProjectId("project-1");
|
||||
const THREAD_ID = ThreadId.makeUnsafe("thread-1");
|
||||
const FIXTURE_SESSION_ID = asProviderSessionId("fixture-session");
|
||||
const FIXTURE_THREAD_ID = asProviderThreadId("fixture-thread");
|
||||
const FIXTURE_TURN_ID = asProviderTurnId("fixture-turn");
|
||||
const FIXTURE_TURN_ID = "fixture-turn";
|
||||
const APPROVAL_REQUEST_ID = asApprovalRequestId("req-approval-1");
|
||||
type IntegrationProvider = "codex" | "claudeCode";
|
||||
|
||||
function nowIso() {
|
||||
return new Date().toISOString();
|
||||
@@ -76,18 +69,30 @@ function waitForSync<A>(
|
||||
});
|
||||
}
|
||||
|
||||
function runtimeBase(eventId: string, createdAt: string) {
|
||||
function runtimeBase(eventId: string, createdAt: string, provider: IntegrationProvider = "codex") {
|
||||
return {
|
||||
eventId: asEventId(eventId),
|
||||
provider: "codex" as const,
|
||||
sessionId: FIXTURE_SESSION_ID,
|
||||
provider,
|
||||
createdAt,
|
||||
};
|
||||
}
|
||||
|
||||
function withHarness<A, E>(use: (harness: OrchestrationIntegrationHarness) => Effect.Effect<A, E>) {
|
||||
function withHarness<A, E>(
|
||||
use: (harness: OrchestrationIntegrationHarness) => Effect.Effect<A, E>,
|
||||
provider: IntegrationProvider = "codex",
|
||||
) {
|
||||
return Effect.acquireUseRelease(
|
||||
makeOrchestrationIntegrationHarness,
|
||||
makeOrchestrationIntegrationHarness({ provider }),
|
||||
use,
|
||||
(harness) => harness.dispose,
|
||||
);
|
||||
}
|
||||
|
||||
function withRealCodexHarness<A, E>(
|
||||
use: (harness: OrchestrationIntegrationHarness) => Effect.Effect<A, E>,
|
||||
) {
|
||||
return Effect.acquireUseRelease(
|
||||
makeOrchestrationIntegrationHarness({ provider: "codex", realCodex: true }),
|
||||
use,
|
||||
(harness) => harness.dispose,
|
||||
);
|
||||
@@ -114,6 +119,8 @@ const seedProjectAndThread = (harness: OrchestrationIntegrationHarness) =>
|
||||
projectId: PROJECT_ID,
|
||||
title: "Integration Thread",
|
||||
model: "gpt-5-codex",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
branch: null,
|
||||
worktreePath: harness.workspaceDir,
|
||||
createdAt,
|
||||
@@ -125,6 +132,7 @@ const startTurn = (input: {
|
||||
readonly commandId: string;
|
||||
readonly messageId: string;
|
||||
readonly text: string;
|
||||
readonly provider?: IntegrationProvider;
|
||||
}) =>
|
||||
input.harness.engine.dispatch({
|
||||
type: "thread.turn.start",
|
||||
@@ -136,8 +144,9 @@ const startTurn = (input: {
|
||||
text: input.text,
|
||||
attachments: [],
|
||||
},
|
||||
approvalPolicy: "on-request",
|
||||
sandboxMode: "workspace-write",
|
||||
...(input.provider !== undefined ? { provider: input.provider } : {}),
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
createdAt: nowIso(),
|
||||
});
|
||||
|
||||
@@ -151,20 +160,20 @@ it.live("runs a single turn end-to-end and persists checkpoint state in sqlite +
|
||||
{
|
||||
type: "turn.started",
|
||||
...runtimeBase("evt-single-1", "2026-02-24T10:00:00.000Z"),
|
||||
threadId: FIXTURE_THREAD_ID,
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
},
|
||||
{
|
||||
type: "message.delta",
|
||||
...runtimeBase("evt-single-2", "2026-02-24T10:00:00.100Z"),
|
||||
threadId: FIXTURE_THREAD_ID,
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
delta: "Single turn response.\n",
|
||||
},
|
||||
{
|
||||
type: "turn.completed",
|
||||
...runtimeBase("evt-single-3", "2026-02-24T10:00:00.200Z"),
|
||||
threadId: FIXTURE_THREAD_ID,
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
status: "completed",
|
||||
},
|
||||
@@ -211,6 +220,95 @@ it.live("runs a single turn end-to-end and persists checkpoint state in sqlite +
|
||||
),
|
||||
);
|
||||
|
||||
it.live.skipIf(!process.env.CODEX_BINARY_PATH)(
|
||||
"keeps the same Codex provider thread across runtime mode switches",
|
||||
() =>
|
||||
withRealCodexHarness((harness) =>
|
||||
Effect.gen(function* () {
|
||||
const createdAt = nowIso();
|
||||
|
||||
yield* harness.engine.dispatch({
|
||||
type: "project.create",
|
||||
commandId: CommandId.makeUnsafe("cmd-project-create-real-codex"),
|
||||
projectId: PROJECT_ID,
|
||||
title: "Integration Project",
|
||||
workspaceRoot: harness.workspaceDir,
|
||||
defaultModel: "gpt-5.3-codex",
|
||||
createdAt,
|
||||
});
|
||||
|
||||
yield* harness.engine.dispatch({
|
||||
type: "thread.create",
|
||||
commandId: CommandId.makeUnsafe("cmd-thread-create-real-codex"),
|
||||
threadId: THREAD_ID,
|
||||
projectId: PROJECT_ID,
|
||||
title: "Integration Thread",
|
||||
model: "gpt-5.3-codex",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "full-access",
|
||||
branch: null,
|
||||
worktreePath: harness.workspaceDir,
|
||||
createdAt,
|
||||
});
|
||||
|
||||
yield* harness.engine.dispatch({
|
||||
type: "thread.turn.start",
|
||||
commandId: CommandId.makeUnsafe("cmd-turn-start-real-codex-1"),
|
||||
threadId: THREAD_ID,
|
||||
message: {
|
||||
messageId: asMessageId("msg-real-codex-1"),
|
||||
role: "user",
|
||||
text: "Reply with exactly ALPHA.",
|
||||
attachments: [],
|
||||
},
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "full-access",
|
||||
createdAt: nowIso(),
|
||||
});
|
||||
|
||||
const firstThread = yield* harness.waitForThread(
|
||||
THREAD_ID,
|
||||
(entry) =>
|
||||
entry.session?.status === "ready" &&
|
||||
entry.session.providerName === "codex" &&
|
||||
entry.messages.some(
|
||||
(message) => message.role === "assistant" && message.streaming === false,
|
||||
),
|
||||
180_000,
|
||||
);
|
||||
assert.equal(firstThread.session?.threadId, "thread-1");
|
||||
|
||||
yield* harness.engine.dispatch({
|
||||
type: "thread.turn.start",
|
||||
commandId: CommandId.makeUnsafe("cmd-turn-start-real-codex-2"),
|
||||
threadId: THREAD_ID,
|
||||
message: {
|
||||
messageId: asMessageId("msg-real-codex-2"),
|
||||
role: "user",
|
||||
text: "Reply with exactly BETA.",
|
||||
attachments: [],
|
||||
},
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
createdAt: nowIso(),
|
||||
});
|
||||
|
||||
const secondThread = yield* harness.waitForThread(
|
||||
THREAD_ID,
|
||||
(entry) =>
|
||||
entry.session?.status === "ready" &&
|
||||
entry.session.providerName === "codex" &&
|
||||
entry.session.runtimeMode === "approval-required" &&
|
||||
entry.messages.some(
|
||||
(message) => message.role === "assistant" && message.text.includes("BETA"),
|
||||
),
|
||||
180_000,
|
||||
);
|
||||
assert.equal(secondThread.session?.threadId, "thread-1");
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
it.live("runs multi-turn file edits and persists checkpoint diffs", () =>
|
||||
withHarness((harness) =>
|
||||
Effect.gen(function* () {
|
||||
@@ -221,13 +319,13 @@ it.live("runs multi-turn file edits and persists checkpoint diffs", () =>
|
||||
{
|
||||
type: "turn.started",
|
||||
...runtimeBase("evt-multi-1", "2026-02-24T10:01:00.000Z"),
|
||||
threadId: FIXTURE_THREAD_ID,
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
},
|
||||
{
|
||||
type: "tool.started",
|
||||
...runtimeBase("evt-multi-2", "2026-02-24T10:01:00.100Z"),
|
||||
threadId: FIXTURE_THREAD_ID,
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
toolKind: "command",
|
||||
title: "Edit file",
|
||||
@@ -236,7 +334,7 @@ it.live("runs multi-turn file edits and persists checkpoint diffs", () =>
|
||||
{
|
||||
type: "tool.completed",
|
||||
...runtimeBase("evt-multi-3", "2026-02-24T10:01:00.200Z"),
|
||||
threadId: FIXTURE_THREAD_ID,
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
toolKind: "command",
|
||||
title: "Edit file",
|
||||
@@ -245,14 +343,14 @@ it.live("runs multi-turn file edits and persists checkpoint diffs", () =>
|
||||
{
|
||||
type: "message.delta",
|
||||
...runtimeBase("evt-multi-4", "2026-02-24T10:01:00.300Z"),
|
||||
threadId: FIXTURE_THREAD_ID,
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
delta: "Updated README to v2.\n",
|
||||
},
|
||||
{
|
||||
type: "turn.completed",
|
||||
...runtimeBase("evt-multi-5", "2026-02-24T10:01:00.400Z"),
|
||||
threadId: FIXTURE_THREAD_ID,
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
status: "completed",
|
||||
},
|
||||
@@ -270,35 +368,30 @@ it.live("runs multi-turn file edits and persists checkpoint diffs", () =>
|
||||
text: "Make first edit",
|
||||
});
|
||||
|
||||
const firstTurnThread = yield* harness.waitForThread(
|
||||
yield* harness.waitForThread(
|
||||
THREAD_ID,
|
||||
(entry) => entry.checkpoints.length === 1 && entry.session?.providerSessionId !== null,
|
||||
(entry) => entry.checkpoints.length === 1 && entry.session?.threadId === "thread-1",
|
||||
);
|
||||
const sessionId = firstTurnThread.session?.providerSessionId;
|
||||
assert.equal(sessionId !== null, true);
|
||||
if (!sessionId) {
|
||||
return;
|
||||
}
|
||||
|
||||
yield* harness.adapterHarness.queueTurnResponse(sessionId, {
|
||||
yield* harness.adapterHarness.queueTurnResponse(THREAD_ID, {
|
||||
events: [
|
||||
{
|
||||
type: "turn.started",
|
||||
...runtimeBase("evt-multi-6", "2026-02-24T10:02:00.000Z"),
|
||||
threadId: FIXTURE_THREAD_ID,
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
},
|
||||
{
|
||||
type: "message.delta",
|
||||
...runtimeBase("evt-multi-7", "2026-02-24T10:02:00.100Z"),
|
||||
threadId: FIXTURE_THREAD_ID,
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
delta: "Updated README to v3.\n",
|
||||
},
|
||||
{
|
||||
type: "turn.completed",
|
||||
...runtimeBase("evt-multi-8", "2026-02-24T10:02:00.200Z"),
|
||||
threadId: FIXTURE_THREAD_ID,
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
status: "completed",
|
||||
},
|
||||
@@ -385,13 +478,13 @@ it.live("tracks approval requests and resolves pending approvals on user respons
|
||||
{
|
||||
type: "turn.started",
|
||||
...runtimeBase("evt-approval-1", "2026-02-24T10:03:00.000Z"),
|
||||
threadId: FIXTURE_THREAD_ID,
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
},
|
||||
{
|
||||
type: "approval.requested",
|
||||
...runtimeBase("evt-approval-2", "2026-02-24T10:03:00.100Z"),
|
||||
threadId: FIXTURE_THREAD_ID,
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
requestId: APPROVAL_REQUEST_ID,
|
||||
requestKind: "command",
|
||||
@@ -400,7 +493,7 @@ it.live("tracks approval requests and resolves pending approvals on user respons
|
||||
{
|
||||
type: "turn.completed",
|
||||
...runtimeBase("evt-approval-3", "2026-02-24T10:03:00.200Z"),
|
||||
threadId: FIXTURE_THREAD_ID,
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
status: "completed",
|
||||
},
|
||||
@@ -444,9 +537,8 @@ it.live("tracks approval requests and resolves pending approvals on user respons
|
||||
assert.equal(resolvedRow.status, "resolved");
|
||||
assert.equal(resolvedRow.decision, "accept");
|
||||
|
||||
const providerSessionId = thread.session?.providerSessionId ?? "test-session-1";
|
||||
const approvalResponses = yield* waitForSync(
|
||||
() => harness.adapterHarness.getApprovalResponses(providerSessionId),
|
||||
() => harness.adapterHarness.getApprovalResponses(THREAD_ID),
|
||||
(responses) => responses.length === 1,
|
||||
"provider approval response",
|
||||
);
|
||||
@@ -467,30 +559,37 @@ it.live("records failed turn runtime state and checkpoint status as error", () =
|
||||
{
|
||||
type: "turn.started",
|
||||
...runtimeBase("evt-failure-1", "2026-02-24T10:04:00.000Z"),
|
||||
threadId: FIXTURE_THREAD_ID,
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
},
|
||||
{
|
||||
type: "message.delta",
|
||||
type: "content.delta",
|
||||
...runtimeBase("evt-failure-2", "2026-02-24T10:04:00.100Z"),
|
||||
threadId: FIXTURE_THREAD_ID,
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
delta: "Partial output before failure.\n",
|
||||
payload: {
|
||||
streamKind: "assistant_text",
|
||||
delta: "Partial output before failure.\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "runtime.error",
|
||||
...runtimeBase("evt-failure-3", "2026-02-24T10:04:00.200Z"),
|
||||
threadId: FIXTURE_THREAD_ID,
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
message: "Sandbox command failed.",
|
||||
payload: {
|
||||
message: "Sandbox command failed.",
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "turn.completed",
|
||||
...runtimeBase("evt-failure-4", "2026-02-24T10:04:00.300Z"),
|
||||
threadId: FIXTURE_THREAD_ID,
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
status: "failed",
|
||||
errorMessage: "Sandbox command failed.",
|
||||
payload: {
|
||||
state: "failed",
|
||||
errorMessage: "Sandbox command failed.",
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
@@ -539,13 +638,13 @@ it.live("reverts to an earlier checkpoint and trims checkpoint projections + git
|
||||
{
|
||||
type: "turn.started",
|
||||
...runtimeBase("evt-revert-1", "2026-02-24T10:05:00.000Z"),
|
||||
threadId: FIXTURE_THREAD_ID,
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
},
|
||||
{
|
||||
type: "tool.started",
|
||||
...runtimeBase("evt-revert-1-tool-started", "2026-02-24T10:05:00.025Z"),
|
||||
threadId: FIXTURE_THREAD_ID,
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
toolKind: "command",
|
||||
title: "Edit file",
|
||||
@@ -554,7 +653,7 @@ it.live("reverts to an earlier checkpoint and trims checkpoint projections + git
|
||||
{
|
||||
type: "tool.completed",
|
||||
...runtimeBase("evt-revert-1-tool-completed", "2026-02-24T10:05:00.035Z"),
|
||||
threadId: FIXTURE_THREAD_ID,
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
toolKind: "command",
|
||||
title: "Edit file",
|
||||
@@ -563,14 +662,14 @@ it.live("reverts to an earlier checkpoint and trims checkpoint projections + git
|
||||
{
|
||||
type: "message.delta",
|
||||
...runtimeBase("evt-revert-1a", "2026-02-24T10:05:00.050Z"),
|
||||
threadId: FIXTURE_THREAD_ID,
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
delta: "Updated README to v2.\n",
|
||||
},
|
||||
{
|
||||
type: "turn.completed",
|
||||
...runtimeBase("evt-revert-2", "2026-02-24T10:05:00.100Z"),
|
||||
threadId: FIXTURE_THREAD_ID,
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
status: "completed",
|
||||
},
|
||||
@@ -587,28 +686,23 @@ it.live("reverts to an earlier checkpoint and trims checkpoint projections + git
|
||||
text: "First edit",
|
||||
});
|
||||
|
||||
const firstTurnThread = yield* harness.waitForThread(
|
||||
yield* harness.waitForThread(
|
||||
THREAD_ID,
|
||||
(entry) => entry.session?.providerSessionId !== null && entry.checkpoints.length === 1,
|
||||
(entry) => entry.session?.threadId === "thread-1" && entry.checkpoints.length === 1,
|
||||
);
|
||||
const sessionId = firstTurnThread.session?.providerSessionId;
|
||||
assert.equal(sessionId !== null, true);
|
||||
if (!sessionId) {
|
||||
return;
|
||||
}
|
||||
|
||||
yield* harness.adapterHarness.queueTurnResponse(sessionId, {
|
||||
yield* harness.adapterHarness.queueTurnResponse(THREAD_ID, {
|
||||
events: [
|
||||
{
|
||||
type: "turn.started",
|
||||
...runtimeBase("evt-revert-3", "2026-02-24T10:05:01.000Z"),
|
||||
threadId: FIXTURE_THREAD_ID,
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
},
|
||||
{
|
||||
type: "tool.started",
|
||||
...runtimeBase("evt-revert-3-tool-started", "2026-02-24T10:05:01.025Z"),
|
||||
threadId: FIXTURE_THREAD_ID,
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
toolKind: "command",
|
||||
title: "Edit file",
|
||||
@@ -617,7 +711,7 @@ it.live("reverts to an earlier checkpoint and trims checkpoint projections + git
|
||||
{
|
||||
type: "tool.completed",
|
||||
...runtimeBase("evt-revert-3-tool-completed", "2026-02-24T10:05:01.035Z"),
|
||||
threadId: FIXTURE_THREAD_ID,
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
toolKind: "command",
|
||||
title: "Edit file",
|
||||
@@ -626,14 +720,14 @@ it.live("reverts to an earlier checkpoint and trims checkpoint projections + git
|
||||
{
|
||||
type: "message.delta",
|
||||
...runtimeBase("evt-revert-3a", "2026-02-24T10:05:01.050Z"),
|
||||
threadId: FIXTURE_THREAD_ID,
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
delta: "Updated README to v3.\n",
|
||||
},
|
||||
{
|
||||
type: "turn.completed",
|
||||
...runtimeBase("evt-revert-4", "2026-02-24T10:05:01.100Z"),
|
||||
threadId: FIXTURE_THREAD_ID,
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
status: "completed",
|
||||
},
|
||||
@@ -702,7 +796,7 @@ it.live("reverts to an earlier checkpoint and trims checkpoint projections + git
|
||||
gitRefExists(harness.workspaceDir, checkpointRefForThreadTurn(THREAD_ID, 2)),
|
||||
false,
|
||||
);
|
||||
assert.deepEqual(harness.adapterHarness.getRollbackCalls(sessionId), [1]);
|
||||
assert.deepEqual(harness.adapterHarness.getRollbackCalls(THREAD_ID), [1]);
|
||||
|
||||
const checkpointRows = yield* harness.checkpointRepository.listByThreadId({
|
||||
threadId: THREAD_ID,
|
||||
@@ -748,3 +842,416 @@ it.live(
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
it.live("starts a claudeCode session on first turn when provider is requested", () =>
|
||||
withHarness(
|
||||
(harness) =>
|
||||
Effect.gen(function* () {
|
||||
yield* seedProjectAndThread(harness);
|
||||
|
||||
yield* harness.adapterHarness.queueTurnResponseForNextSession({
|
||||
events: [
|
||||
{
|
||||
type: "turn.started",
|
||||
...runtimeBase("evt-claude-start-1", "2026-02-24T10:10:00.000Z", "claudeCode"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
},
|
||||
{
|
||||
type: "message.delta",
|
||||
...runtimeBase("evt-claude-start-2", "2026-02-24T10:10:00.050Z", "claudeCode"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
delta: "Claude first turn.\n",
|
||||
},
|
||||
{
|
||||
type: "turn.completed",
|
||||
...runtimeBase("evt-claude-start-3", "2026-02-24T10:10:00.100Z", "claudeCode"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
status: "completed",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
yield* startTurn({
|
||||
harness,
|
||||
commandId: "cmd-turn-start-claude-initial",
|
||||
messageId: "msg-user-claude-initial",
|
||||
text: "Use Claude",
|
||||
provider: "claudeCode",
|
||||
});
|
||||
|
||||
const thread = yield* harness.waitForThread(
|
||||
THREAD_ID,
|
||||
(entry) =>
|
||||
entry.session?.providerName === "claudeCode" &&
|
||||
entry.session.status === "ready" &&
|
||||
entry.messages.some(
|
||||
(message) => message.role === "assistant" && message.text === "Claude first turn.\n",
|
||||
),
|
||||
);
|
||||
assert.equal(thread.session?.providerName, "claudeCode");
|
||||
}),
|
||||
"claudeCode",
|
||||
),
|
||||
);
|
||||
|
||||
it.live("recovers claudeCode sessions after provider stopAll using persisted resume state", () =>
|
||||
withHarness(
|
||||
(harness) =>
|
||||
Effect.gen(function* () {
|
||||
yield* seedProjectAndThread(harness);
|
||||
|
||||
yield* harness.adapterHarness.queueTurnResponseForNextSession({
|
||||
events: [
|
||||
{
|
||||
type: "turn.started",
|
||||
...runtimeBase("evt-claude-recover-1", "2026-02-24T10:11:00.000Z", "claudeCode"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
},
|
||||
{
|
||||
type: "message.delta",
|
||||
...runtimeBase("evt-claude-recover-2", "2026-02-24T10:11:00.050Z", "claudeCode"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
delta: "Turn before restart.\n",
|
||||
},
|
||||
{
|
||||
type: "turn.completed",
|
||||
...runtimeBase("evt-claude-recover-3", "2026-02-24T10:11:00.100Z", "claudeCode"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
status: "completed",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
yield* startTurn({
|
||||
harness,
|
||||
commandId: "cmd-turn-start-claude-recover-1",
|
||||
messageId: "msg-user-claude-recover-1",
|
||||
text: "Before restart",
|
||||
provider: "claudeCode",
|
||||
});
|
||||
|
||||
yield* harness.waitForThread(
|
||||
THREAD_ID,
|
||||
(entry) => entry.latestTurn?.turnId === "turn-1" && entry.session?.threadId === "thread-1",
|
||||
);
|
||||
|
||||
yield* harness.providerService.stopAll();
|
||||
yield* waitForSync(
|
||||
() => harness.adapterHarness.listActiveSessionIds(),
|
||||
(sessionIds) => sessionIds.length === 0,
|
||||
"provider stopAll",
|
||||
);
|
||||
|
||||
yield* harness.adapterHarness.queueTurnResponseForNextSession({
|
||||
events: [
|
||||
{
|
||||
type: "turn.started",
|
||||
...runtimeBase("evt-claude-recover-4", "2026-02-24T10:11:01.000Z", "claudeCode"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
},
|
||||
{
|
||||
type: "message.delta",
|
||||
...runtimeBase("evt-claude-recover-5", "2026-02-24T10:11:01.050Z", "claudeCode"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
delta: "Turn after restart.\n",
|
||||
},
|
||||
{
|
||||
type: "turn.completed",
|
||||
...runtimeBase("evt-claude-recover-6", "2026-02-24T10:11:01.100Z", "claudeCode"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
status: "completed",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
yield* startTurn({
|
||||
harness,
|
||||
commandId: "cmd-turn-start-claude-recover-2",
|
||||
messageId: "msg-user-claude-recover-2",
|
||||
text: "After restart",
|
||||
});
|
||||
yield* waitForSync(
|
||||
() => harness.adapterHarness.getStartCount(),
|
||||
(count) => count === 2,
|
||||
"claude provider recovery start",
|
||||
);
|
||||
|
||||
const recoveredThread = yield* harness.waitForThread(
|
||||
THREAD_ID,
|
||||
(entry) =>
|
||||
entry.session?.providerName === "claudeCode" &&
|
||||
entry.messages.some(
|
||||
(message) => message.role === "user" && message.text === "After restart",
|
||||
) &&
|
||||
!entry.activities.some((activity) => activity.kind === "provider.turn.start.failed"),
|
||||
);
|
||||
assert.equal(recoveredThread.session?.providerName, "claudeCode");
|
||||
assert.equal(recoveredThread.session?.threadId, "thread-1");
|
||||
}),
|
||||
"claudeCode",
|
||||
),
|
||||
);
|
||||
|
||||
it.live("forwards claudeCode approval responses to the provider session", () =>
|
||||
withHarness(
|
||||
(harness) =>
|
||||
Effect.gen(function* () {
|
||||
yield* seedProjectAndThread(harness);
|
||||
|
||||
yield* harness.adapterHarness.queueTurnResponseForNextSession({
|
||||
events: [
|
||||
{
|
||||
type: "turn.started",
|
||||
...runtimeBase("evt-claude-approval-1", "2026-02-24T10:12:00.000Z", "claudeCode"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
},
|
||||
{
|
||||
type: "approval.requested",
|
||||
...runtimeBase("evt-claude-approval-2", "2026-02-24T10:12:00.050Z", "claudeCode"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
requestId: APPROVAL_REQUEST_ID,
|
||||
requestKind: "command",
|
||||
detail: "Approve Claude tool call",
|
||||
},
|
||||
{
|
||||
type: "turn.completed",
|
||||
...runtimeBase("evt-claude-approval-3", "2026-02-24T10:12:00.100Z", "claudeCode"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
status: "completed",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
yield* startTurn({
|
||||
harness,
|
||||
commandId: "cmd-turn-start-claude-approval",
|
||||
messageId: "msg-user-claude-approval",
|
||||
text: "Need approval",
|
||||
provider: "claudeCode",
|
||||
});
|
||||
|
||||
const thread = yield* harness.waitForThread(THREAD_ID, (entry) =>
|
||||
entry.activities.some((activity) => activity.kind === "approval.requested"),
|
||||
);
|
||||
assert.equal(thread.session?.threadId, "thread-1");
|
||||
|
||||
yield* harness.engine.dispatch({
|
||||
type: "thread.approval.respond",
|
||||
commandId: CommandId.makeUnsafe("cmd-claude-approval-respond"),
|
||||
threadId: THREAD_ID,
|
||||
requestId: APPROVAL_REQUEST_ID,
|
||||
decision: "accept",
|
||||
createdAt: nowIso(),
|
||||
});
|
||||
|
||||
yield* harness.waitForPendingApproval(
|
||||
"req-approval-1",
|
||||
(row) => row.status === "resolved" && row.decision === "accept",
|
||||
);
|
||||
|
||||
const approvalResponses = yield* waitForSync(
|
||||
() => harness.adapterHarness.getApprovalResponses(THREAD_ID),
|
||||
(responses) => responses.length === 1,
|
||||
"claude provider approval response",
|
||||
);
|
||||
assert.equal(approvalResponses[0]?.decision, "accept");
|
||||
}),
|
||||
"claudeCode",
|
||||
),
|
||||
);
|
||||
|
||||
it.live("forwards thread.turn.interrupt to claudeCode provider sessions", () =>
|
||||
withHarness(
|
||||
(harness) =>
|
||||
Effect.gen(function* () {
|
||||
yield* seedProjectAndThread(harness);
|
||||
|
||||
yield* harness.adapterHarness.queueTurnResponseForNextSession({
|
||||
events: [
|
||||
{
|
||||
type: "turn.started",
|
||||
...runtimeBase("evt-claude-interrupt-1", "2026-02-24T10:13:00.000Z", "claudeCode"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
},
|
||||
{
|
||||
type: "message.delta",
|
||||
...runtimeBase("evt-claude-interrupt-2", "2026-02-24T10:13:00.050Z", "claudeCode"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
delta: "Long running output.\n",
|
||||
},
|
||||
{
|
||||
type: "turn.completed",
|
||||
...runtimeBase("evt-claude-interrupt-3", "2026-02-24T10:13:00.100Z", "claudeCode"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
status: "completed",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
yield* startTurn({
|
||||
harness,
|
||||
commandId: "cmd-turn-start-claude-interrupt",
|
||||
messageId: "msg-user-claude-interrupt",
|
||||
text: "Start long turn",
|
||||
provider: "claudeCode",
|
||||
});
|
||||
|
||||
const thread = yield* harness.waitForThread(
|
||||
THREAD_ID,
|
||||
(entry) => entry.session?.threadId === "thread-1",
|
||||
);
|
||||
assert.equal(thread.session?.threadId, "thread-1");
|
||||
|
||||
yield* harness.engine.dispatch({
|
||||
type: "thread.turn.interrupt",
|
||||
commandId: CommandId.makeUnsafe("cmd-turn-interrupt-claude"),
|
||||
threadId: THREAD_ID,
|
||||
createdAt: nowIso(),
|
||||
});
|
||||
yield* harness.waitForDomainEvent((event) => event.type === "thread.turn-interrupt-requested");
|
||||
|
||||
const interruptCalls = yield* waitForSync(
|
||||
() => harness.adapterHarness.getInterruptCalls(THREAD_ID),
|
||||
(calls) => calls.length === 1,
|
||||
"claude provider interrupt call",
|
||||
);
|
||||
assert.equal(interruptCalls.length, 1);
|
||||
}),
|
||||
"claudeCode",
|
||||
),
|
||||
);
|
||||
|
||||
it.live("reverts claudeCode turns and rolls back provider conversation state", () =>
|
||||
withHarness(
|
||||
(harness) =>
|
||||
Effect.gen(function* () {
|
||||
yield* seedProjectAndThread(harness);
|
||||
|
||||
yield* harness.adapterHarness.queueTurnResponseForNextSession({
|
||||
events: [
|
||||
{
|
||||
type: "turn.started",
|
||||
...runtimeBase("evt-claude-revert-1", "2026-02-24T10:14:00.000Z", "claudeCode"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
},
|
||||
{
|
||||
type: "message.delta",
|
||||
...runtimeBase("evt-claude-revert-2", "2026-02-24T10:14:00.050Z", "claudeCode"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
delta: "README -> v2\n",
|
||||
},
|
||||
{
|
||||
type: "turn.completed",
|
||||
...runtimeBase("evt-claude-revert-3", "2026-02-24T10:14:00.100Z", "claudeCode"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
status: "completed",
|
||||
},
|
||||
],
|
||||
mutateWorkspace: ({ cwd }) =>
|
||||
Effect.sync(() => {
|
||||
fs.writeFileSync(path.join(cwd, "README.md"), "v2\n", "utf8");
|
||||
}),
|
||||
});
|
||||
|
||||
yield* startTurn({
|
||||
harness,
|
||||
commandId: "cmd-turn-start-claude-revert-1",
|
||||
messageId: "msg-user-claude-revert-1",
|
||||
text: "First Claude edit",
|
||||
provider: "claudeCode",
|
||||
});
|
||||
|
||||
yield* harness.waitForThread(
|
||||
THREAD_ID,
|
||||
(entry) => entry.latestTurn?.turnId === "turn-1" && entry.session?.threadId === "thread-1",
|
||||
);
|
||||
|
||||
yield* harness.adapterHarness.queueTurnResponse(THREAD_ID, {
|
||||
events: [
|
||||
{
|
||||
type: "turn.started",
|
||||
...runtimeBase("evt-claude-revert-4", "2026-02-24T10:14:01.000Z", "claudeCode"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
},
|
||||
{
|
||||
type: "message.delta",
|
||||
...runtimeBase("evt-claude-revert-5", "2026-02-24T10:14:01.050Z", "claudeCode"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
delta: "README -> v3\n",
|
||||
},
|
||||
{
|
||||
type: "turn.completed",
|
||||
...runtimeBase("evt-claude-revert-6", "2026-02-24T10:14:01.100Z", "claudeCode"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
status: "completed",
|
||||
},
|
||||
],
|
||||
mutateWorkspace: ({ cwd }) =>
|
||||
Effect.sync(() => {
|
||||
fs.writeFileSync(path.join(cwd, "README.md"), "v3\n", "utf8");
|
||||
}),
|
||||
});
|
||||
|
||||
yield* startTurn({
|
||||
harness,
|
||||
commandId: "cmd-turn-start-claude-revert-2",
|
||||
messageId: "msg-user-claude-revert-2",
|
||||
text: "Second Claude edit",
|
||||
});
|
||||
|
||||
yield* harness.waitForThread(
|
||||
THREAD_ID,
|
||||
(entry) =>
|
||||
entry.latestTurn?.turnId === "turn-2" &&
|
||||
entry.checkpoints.length === 2 &&
|
||||
entry.session?.providerName === "claudeCode",
|
||||
);
|
||||
|
||||
yield* harness.engine.dispatch({
|
||||
type: "thread.checkpoint.revert",
|
||||
commandId: CommandId.makeUnsafe("cmd-checkpoint-revert-claude"),
|
||||
threadId: THREAD_ID,
|
||||
turnCount: 1,
|
||||
createdAt: nowIso(),
|
||||
});
|
||||
|
||||
const revertedThread = yield* harness.waitForThread(
|
||||
THREAD_ID,
|
||||
(entry) =>
|
||||
entry.checkpoints.length === 1 && entry.checkpoints[0]?.checkpointTurnCount === 1,
|
||||
);
|
||||
assert.equal(revertedThread.checkpoints[0]?.checkpointTurnCount, 1);
|
||||
assert.equal(
|
||||
gitRefExists(harness.workspaceDir, checkpointRefForThreadTurn(THREAD_ID, 1)),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
gitRefExists(harness.workspaceDir, checkpointRefForThreadTurn(THREAD_ID, 2)),
|
||||
false,
|
||||
);
|
||||
assert.deepEqual(harness.adapterHarness.getRollbackCalls(THREAD_ID), [1]);
|
||||
}),
|
||||
"claudeCode",
|
||||
),
|
||||
);
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { ProviderRuntimeEvent, ProviderSessionId } from "@t3tools/contracts";
|
||||
import type { ProviderRuntimeEvent } from "@t3tools/contracts";
|
||||
import { ThreadId } from "@t3tools/contracts";
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { it, assert } from "@effect/vitest";
|
||||
@@ -42,7 +42,7 @@ interface IntegrationFixture {
|
||||
|
||||
const makeIntegrationFixture = Effect.gen(function* () {
|
||||
const cwd = yield* makeWorkspaceDirectory;
|
||||
const harness = yield* makeTestProviderAdapterHarness;
|
||||
const harness = yield* makeTestProviderAdapterHarness();
|
||||
|
||||
const registry: typeof ProviderAdapterRegistry.Service = {
|
||||
getByProvider: (provider) =>
|
||||
@@ -93,18 +93,18 @@ const collectEventsDuring = <A, E, R>(
|
||||
const runTurn = (input: {
|
||||
readonly provider: ProviderServiceShape;
|
||||
readonly harness: TestProviderAdapterHarness;
|
||||
readonly sessionId: ProviderSessionId;
|
||||
readonly threadId: ThreadId;
|
||||
readonly userText: string;
|
||||
readonly response: TestTurnResponse;
|
||||
}) =>
|
||||
Effect.gen(function* () {
|
||||
yield* input.harness.queueTurnResponse(input.sessionId, input.response);
|
||||
yield* input.harness.queueTurnResponse(input.threadId, input.response);
|
||||
|
||||
return yield* collectEventsDuring(
|
||||
input.provider.streamEvents,
|
||||
input.response.events.length,
|
||||
input.provider.sendTurn({
|
||||
sessionId: input.sessionId,
|
||||
threadId: input.threadId,
|
||||
input: input.userText,
|
||||
attachments: [],
|
||||
}),
|
||||
@@ -120,8 +120,10 @@ it.effect("replays typed runtime fixture events", () =>
|
||||
const session = yield* provider.startSession(
|
||||
ThreadId.makeUnsafe("thread-integration-typed"),
|
||||
{
|
||||
threadId: ThreadId.makeUnsafe("thread-integration-typed"),
|
||||
provider: "codex",
|
||||
cwd: fixture.cwd,
|
||||
runtimeMode: "full-access",
|
||||
},
|
||||
);
|
||||
assert.equal((session.threadId ?? "").length > 0, true);
|
||||
@@ -129,7 +131,7 @@ it.effect("replays typed runtime fixture events", () =>
|
||||
const observedEvents = yield* runTurn({
|
||||
provider,
|
||||
harness: fixture.harness,
|
||||
sessionId: session.sessionId,
|
||||
threadId: session.threadId,
|
||||
userText: "hello",
|
||||
response: { events: codexTurnTextFixture },
|
||||
});
|
||||
@@ -153,8 +155,10 @@ it.effect("replays file-changing fixture turn events", () =>
|
||||
const session = yield* provider.startSession(
|
||||
ThreadId.makeUnsafe("thread-integration-tools"),
|
||||
{
|
||||
threadId: ThreadId.makeUnsafe("thread-integration-tools"),
|
||||
provider: "codex",
|
||||
cwd: fixture.cwd,
|
||||
runtimeMode: "full-access",
|
||||
},
|
||||
);
|
||||
assert.equal((session.threadId ?? "").length > 0, true);
|
||||
@@ -162,7 +166,7 @@ it.effect("replays file-changing fixture turn events", () =>
|
||||
const observedEvents = yield* runTurn({
|
||||
provider,
|
||||
harness: fixture.harness,
|
||||
sessionId: session.sessionId,
|
||||
threadId: session.threadId,
|
||||
userText: "make a small change",
|
||||
response: {
|
||||
events: codexTurnToolFixture,
|
||||
@@ -190,8 +194,10 @@ it.effect("runs multi-turn tool/approval flow", () =>
|
||||
const session = yield* provider.startSession(
|
||||
ThreadId.makeUnsafe("thread-integration-multi"),
|
||||
{
|
||||
threadId: ThreadId.makeUnsafe("thread-integration-multi"),
|
||||
provider: "codex",
|
||||
cwd: fixture.cwd,
|
||||
runtimeMode: "full-access",
|
||||
},
|
||||
);
|
||||
assert.equal((session.threadId ?? "").length > 0, true);
|
||||
@@ -199,7 +205,7 @@ it.effect("runs multi-turn tool/approval flow", () =>
|
||||
const firstTurnEvents = yield* runTurn({
|
||||
provider,
|
||||
harness: fixture.harness,
|
||||
sessionId: session.sessionId,
|
||||
threadId: session.threadId,
|
||||
userText: "turn 1",
|
||||
response: {
|
||||
events: codexTurnToolFixture,
|
||||
@@ -215,7 +221,7 @@ it.effect("runs multi-turn tool/approval flow", () =>
|
||||
const secondTurnEvents = yield* runTurn({
|
||||
provider,
|
||||
harness: fixture.harness,
|
||||
sessionId: session.sessionId,
|
||||
threadId: session.threadId,
|
||||
userText: "turn 2 approval",
|
||||
response: {
|
||||
events: codexTurnApprovalFixture,
|
||||
@@ -242,8 +248,10 @@ it.effect("rolls back provider conversation state only", () =>
|
||||
const session = yield* provider.startSession(
|
||||
ThreadId.makeUnsafe("thread-integration-rollback"),
|
||||
{
|
||||
threadId: ThreadId.makeUnsafe("thread-integration-rollback"),
|
||||
provider: "codex",
|
||||
cwd: fixture.cwd,
|
||||
runtimeMode: "full-access",
|
||||
},
|
||||
);
|
||||
assert.equal((session.threadId ?? "").length > 0, true);
|
||||
@@ -251,7 +259,7 @@ it.effect("rolls back provider conversation state only", () =>
|
||||
yield* runTurn({
|
||||
provider,
|
||||
harness: fixture.harness,
|
||||
sessionId: session.sessionId,
|
||||
threadId: session.threadId,
|
||||
userText: "turn 1",
|
||||
response: {
|
||||
events: codexTurnToolFixture,
|
||||
@@ -263,7 +271,7 @@ it.effect("rolls back provider conversation state only", () =>
|
||||
yield* runTurn({
|
||||
provider,
|
||||
harness: fixture.harness,
|
||||
sessionId: session.sessionId,
|
||||
threadId: session.threadId,
|
||||
userText: "turn 2 approval",
|
||||
response: {
|
||||
events: codexTurnApprovalFixture,
|
||||
@@ -273,11 +281,11 @@ it.effect("rolls back provider conversation state only", () =>
|
||||
});
|
||||
|
||||
yield* provider.rollbackConversation({
|
||||
sessionId: session.sessionId,
|
||||
threadId: session.threadId,
|
||||
numTurns: 1,
|
||||
});
|
||||
|
||||
const rollbackCalls = fixture.harness.getRollbackCalls(session.sessionId);
|
||||
const rollbackCalls = fixture.harness.getRollbackCalls(session.threadId);
|
||||
assert.deepEqual(rollbackCalls, [1]);
|
||||
|
||||
const readme = yield* readFileString(join(fixture.cwd, "README.md"));
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import path from "node:path";
|
||||
|
||||
import { Effect, FileSystem, Layer, Logger, ServiceMap } from "effect";
|
||||
|
||||
import { makeEventNdjsonLogger } from "../src/provider/Layers/EventNdjsonLogger.ts";
|
||||
|
||||
class LogDir extends ServiceMap.Service<LogDir, string>()("t3/scripts/logger-scope-repro/LogDir") {}
|
||||
|
||||
const main = Effect.gen(function* () {
|
||||
const logdir = yield* LogDir;
|
||||
const providerLogPath = path.join(logdir, "provider");
|
||||
|
||||
yield* Effect.logInfo(`providerLogPath=${providerLogPath}`);
|
||||
|
||||
const providerLogger = yield* makeEventNdjsonLogger(providerLogPath, {
|
||||
stream: "native",
|
||||
batchWindowMs: 10,
|
||||
});
|
||||
|
||||
yield* Effect.logInfo("before provider write");
|
||||
|
||||
if (providerLogger) {
|
||||
yield* providerLogger.write(
|
||||
{
|
||||
kind: "probe",
|
||||
message: "provider-only event",
|
||||
},
|
||||
"thread-123" as never,
|
||||
);
|
||||
}
|
||||
|
||||
yield* Effect.logInfo("after provider write");
|
||||
yield* Effect.sleep("50 millis");
|
||||
|
||||
if (providerLogger) {
|
||||
yield* providerLogger.close();
|
||||
}
|
||||
yield* Effect.logInfo("after provider close");
|
||||
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const logContents = yield* fs
|
||||
.readDirectory(logdir, { recursive: true })
|
||||
.pipe(
|
||||
Effect.flatMap((entries) =>
|
||||
Effect.all(entries.map((entry) => fs.readFileString(path.join(logdir, entry)))),
|
||||
),
|
||||
);
|
||||
yield* Effect.logInfo(`logContents=${logContents}`);
|
||||
});
|
||||
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const logdir = path.join(process.cwd(), "logtest");
|
||||
yield* fs.makeDirectory(logdir);
|
||||
|
||||
const fileLogger = yield* Logger.formatSimple.pipe(
|
||||
Logger.toFile(path.join(logdir, "global.log")),
|
||||
);
|
||||
const dualLogger = Logger.layer([fileLogger, Logger.consolePretty()]);
|
||||
|
||||
const mainLayer = Layer.mergeAll(dualLogger, Layer.succeed(LogDir, logdir));
|
||||
|
||||
yield* main.pipe(Effect.provide(mainLayer));
|
||||
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer), NodeRuntime.runMain);
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
CheckpointRef,
|
||||
DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
ProjectId,
|
||||
ThreadId,
|
||||
TurnId,
|
||||
@@ -43,6 +44,8 @@ function makeSnapshot(input: {
|
||||
projectId: input.projectId,
|
||||
title: "Thread",
|
||||
model: "gpt-5-codex",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "full-access",
|
||||
branch: null,
|
||||
worktreePath: input.worktreePath,
|
||||
latestTurn: {
|
||||
@@ -58,6 +61,7 @@ function makeSnapshot(input: {
|
||||
deletedAt: null,
|
||||
messages: [],
|
||||
activities: [],
|
||||
proposedPlans: [],
|
||||
checkpoints: [
|
||||
{
|
||||
turnId: TurnId.makeUnsafe("turn-1"),
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { ProviderSessionId } from "@t3tools/contracts";
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { ApprovalRequestId, ThreadId } from "@t3tools/contracts";
|
||||
|
||||
import {
|
||||
buildCodexInitializeParams,
|
||||
CODEX_PLAN_MODE_DEVELOPER_INSTRUCTIONS,
|
||||
CodexAppServerManager,
|
||||
classifyCodexStderrLine,
|
||||
isRecoverableThreadResumeError,
|
||||
normalizeCodexModelSlug,
|
||||
} from "./codexAppServerManager";
|
||||
|
||||
const asSessionId = (value: string): ProviderSessionId => ProviderSessionId.makeUnsafe(value);
|
||||
const asThreadId = (value: string): ThreadId => ThreadId.makeUnsafe(value);
|
||||
|
||||
function createSendTurnHarness() {
|
||||
const manager = new CodexAppServerManager();
|
||||
@@ -18,6 +24,7 @@ function createSendTurnHarness() {
|
||||
provider: "codex",
|
||||
status: "ready",
|
||||
threadId: "thread_1",
|
||||
resumeCursor: { threadId: "thread_1" },
|
||||
createdAt: "2026-02-10T00:00:00.000Z",
|
||||
updatedAt: "2026-02-10T00:00:00.000Z",
|
||||
},
|
||||
@@ -54,6 +61,7 @@ function createThreadControlHarness() {
|
||||
provider: "codex",
|
||||
status: "ready",
|
||||
threadId: "thread_1",
|
||||
resumeCursor: { threadId: "thread_1" },
|
||||
createdAt: "2026-02-10T00:00:00.000Z",
|
||||
updatedAt: "2026-02-10T00:00:00.000Z",
|
||||
},
|
||||
@@ -76,6 +84,46 @@ function createThreadControlHarness() {
|
||||
return { manager, context, requireSession, sendRequest, updateSession };
|
||||
}
|
||||
|
||||
function createPendingUserInputHarness() {
|
||||
const manager = new CodexAppServerManager();
|
||||
const context = {
|
||||
session: {
|
||||
sessionId: "sess_1",
|
||||
provider: "codex",
|
||||
status: "ready",
|
||||
threadId: "thread_1",
|
||||
resumeCursor: { threadId: "thread_1" },
|
||||
createdAt: "2026-02-10T00:00:00.000Z",
|
||||
updatedAt: "2026-02-10T00:00:00.000Z",
|
||||
},
|
||||
pendingUserInputs: new Map([
|
||||
[
|
||||
ApprovalRequestId.makeUnsafe("req-user-input-1"),
|
||||
{
|
||||
requestId: ApprovalRequestId.makeUnsafe("req-user-input-1"),
|
||||
jsonRpcId: 42,
|
||||
threadId: asThreadId("thread_1"),
|
||||
},
|
||||
],
|
||||
]),
|
||||
};
|
||||
|
||||
const requireSession = vi
|
||||
.spyOn(
|
||||
manager as unknown as { requireSession: (sessionId: string) => unknown },
|
||||
"requireSession",
|
||||
)
|
||||
.mockReturnValue(context);
|
||||
const writeMessage = vi
|
||||
.spyOn(manager as unknown as { writeMessage: (...args: unknown[]) => void }, "writeMessage")
|
||||
.mockImplementation(() => {});
|
||||
const emitEvent = vi
|
||||
.spyOn(manager as unknown as { emitEvent: (...args: unknown[]) => void }, "emitEvent")
|
||||
.mockImplementation(() => {});
|
||||
|
||||
return { manager, context, requireSession, writeMessage, emitEvent };
|
||||
}
|
||||
|
||||
describe("classifyCodexStderrLine", () => {
|
||||
it("ignores empty lines", () => {
|
||||
expect(classifyCodexStderrLine(" ")).toBeNull();
|
||||
@@ -147,6 +195,19 @@ describe("isRecoverableThreadResumeError", () => {
|
||||
});
|
||||
|
||||
describe("startSession", () => {
|
||||
it("enables Codex experimental api capabilities during initialize", () => {
|
||||
expect(buildCodexInitializeParams()).toEqual({
|
||||
clientInfo: {
|
||||
name: "t3code_desktop",
|
||||
title: "T3 Code Desktop",
|
||||
version: "0.1.0",
|
||||
},
|
||||
capabilities: {
|
||||
experimentalApi: true,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("emits session/startFailed when resolving cwd throws before process launch", async () => {
|
||||
const manager = new CodexAppServerManager();
|
||||
const events: Array<{ method: string; kind: string; message?: string }> = [];
|
||||
@@ -164,7 +225,9 @@ describe("startSession", () => {
|
||||
try {
|
||||
await expect(
|
||||
manager.startSession({
|
||||
threadId: asThreadId("thread-1"),
|
||||
provider: "codex",
|
||||
runtimeMode: "full-access",
|
||||
}),
|
||||
).rejects.toThrow("cwd missing");
|
||||
expect(events).toHaveLength(1);
|
||||
@@ -186,7 +249,7 @@ describe("sendTurn", () => {
|
||||
createSendTurnHarness();
|
||||
|
||||
const result = await manager.sendTurn({
|
||||
sessionId: asSessionId("sess_1"),
|
||||
threadId: asThreadId("thread_1"),
|
||||
input: "Inspect this image",
|
||||
attachments: [
|
||||
{
|
||||
@@ -196,16 +259,15 @@ describe("sendTurn", () => {
|
||||
],
|
||||
model: "gpt-5.3",
|
||||
effort: "high",
|
||||
serviceTier: "fast",
|
||||
});
|
||||
|
||||
expect(result).toEqual({
|
||||
threadId: "thread_1",
|
||||
turnId: "turn_1",
|
||||
resumeCursor: {
|
||||
threadId: "thread_1",
|
||||
},
|
||||
resumeCursor: { threadId: "thread_1" },
|
||||
});
|
||||
expect(requireSession).toHaveBeenCalledWith("sess_1");
|
||||
expect(requireSession).toHaveBeenCalledWith("thread_1");
|
||||
expect(sendRequest).toHaveBeenCalledWith(context, "turn/start", {
|
||||
threadId: "thread_1",
|
||||
input: [
|
||||
@@ -221,13 +283,12 @@ describe("sendTurn", () => {
|
||||
],
|
||||
model: "gpt-5.3-codex",
|
||||
effort: "high",
|
||||
serviceTier: "fast",
|
||||
});
|
||||
expect(updateSession).toHaveBeenCalledWith(context, {
|
||||
status: "running",
|
||||
activeTurnId: "turn_1",
|
||||
resumeCursor: {
|
||||
threadId: "thread_1",
|
||||
},
|
||||
resumeCursor: { threadId: "thread_1" },
|
||||
});
|
||||
});
|
||||
|
||||
@@ -235,7 +296,7 @@ describe("sendTurn", () => {
|
||||
const { manager, context, sendRequest } = createSendTurnHarness();
|
||||
|
||||
await manager.sendTurn({
|
||||
sessionId: asSessionId("sess_1"),
|
||||
threadId: asThreadId("thread_1"),
|
||||
attachments: [
|
||||
{
|
||||
type: "image",
|
||||
@@ -255,12 +316,42 @@ describe("sendTurn", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("passes Codex plan mode as a collaboration preset on turn/start", async () => {
|
||||
const { manager, context, sendRequest } = createSendTurnHarness();
|
||||
|
||||
await manager.sendTurn({
|
||||
threadId: asThreadId("thread_1"),
|
||||
input: "Plan the work",
|
||||
interactionMode: "plan",
|
||||
});
|
||||
|
||||
expect(sendRequest).toHaveBeenCalledWith(context, "turn/start", {
|
||||
threadId: "thread_1",
|
||||
input: [
|
||||
{
|
||||
type: "text",
|
||||
text: "Plan the work",
|
||||
text_elements: [],
|
||||
},
|
||||
],
|
||||
model: "gpt-5.3-codex",
|
||||
collaborationMode: {
|
||||
mode: "plan",
|
||||
settings: {
|
||||
model: "gpt-5.3-codex",
|
||||
reasoning_effort: "medium",
|
||||
developer_instructions: CODEX_PLAN_MODE_DEVELOPER_INSTRUCTIONS,
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("rejects empty turn input", async () => {
|
||||
const { manager } = createSendTurnHarness();
|
||||
|
||||
await expect(
|
||||
manager.sendTurn({
|
||||
sessionId: asSessionId("sess_1"),
|
||||
threadId: asThreadId("thread_1"),
|
||||
}),
|
||||
).rejects.toThrow("Turn input must include text or attachments.");
|
||||
});
|
||||
@@ -281,9 +372,9 @@ describe("thread checkpoint control", () => {
|
||||
},
|
||||
});
|
||||
|
||||
const result = await manager.readThread(asSessionId("sess_1"));
|
||||
const result = await manager.readThread(asThreadId("thread_1"));
|
||||
|
||||
expect(requireSession).toHaveBeenCalledWith("sess_1");
|
||||
expect(requireSession).toHaveBeenCalledWith("thread_1");
|
||||
expect(sendRequest).toHaveBeenCalledWith(context, "thread/read", {
|
||||
threadId: "thread_1",
|
||||
includeTurns: true,
|
||||
@@ -311,7 +402,7 @@ describe("thread checkpoint control", () => {
|
||||
],
|
||||
});
|
||||
|
||||
const result = await manager.readThread(asSessionId("sess_1"));
|
||||
const result = await manager.readThread(asThreadId("thread_1"));
|
||||
|
||||
expect(sendRequest).toHaveBeenCalledWith(context, "thread/read", {
|
||||
threadId: "thread_1",
|
||||
@@ -337,7 +428,7 @@ describe("thread checkpoint control", () => {
|
||||
},
|
||||
});
|
||||
|
||||
const result = await manager.rollbackThread(asSessionId("sess_1"), 2);
|
||||
const result = await manager.rollbackThread(asThreadId("thread_1"), 2);
|
||||
|
||||
expect(sendRequest).toHaveBeenCalledWith(context, "thread/rollback", {
|
||||
threadId: "thread_1",
|
||||
@@ -353,3 +444,129 @@ describe("thread checkpoint control", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("respondToUserInput", () => {
|
||||
it("serializes canonical answers to Codex native answer objects", async () => {
|
||||
const { manager, context, requireSession, writeMessage, emitEvent } =
|
||||
createPendingUserInputHarness();
|
||||
|
||||
await manager.respondToUserInput(
|
||||
asThreadId("thread_1"),
|
||||
ApprovalRequestId.makeUnsafe("req-user-input-1"),
|
||||
{
|
||||
scope: "All request methods",
|
||||
compat: "Keep current envelope",
|
||||
},
|
||||
);
|
||||
|
||||
expect(requireSession).toHaveBeenCalledWith("thread_1");
|
||||
expect(writeMessage).toHaveBeenCalledWith(context, {
|
||||
id: 42,
|
||||
result: {
|
||||
answers: {
|
||||
scope: { answers: ["All request methods"] },
|
||||
compat: { answers: ["Keep current envelope"] },
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(emitEvent).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
method: "item/tool/requestUserInput/answered",
|
||||
payload: {
|
||||
requestId: "req-user-input-1",
|
||||
answers: {
|
||||
scope: { answers: ["All request methods"] },
|
||||
compat: { answers: ["Keep current envelope"] },
|
||||
},
|
||||
},
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe.skipIf(!process.env.CODEX_BINARY_PATH)("startSession live Codex resume", () => {
|
||||
it(
|
||||
"keeps prior thread history when resuming with a changed runtime mode",
|
||||
async () => {
|
||||
const workspaceDir = mkdtempSync(path.join(os.tmpdir(), "codex-live-resume-"));
|
||||
writeFileSync(path.join(workspaceDir, "README.md"), "hello\n", "utf8");
|
||||
|
||||
const manager = new CodexAppServerManager();
|
||||
|
||||
try {
|
||||
const firstSession = await manager.startSession({
|
||||
threadId: asThreadId("thread-live"),
|
||||
provider: "codex",
|
||||
cwd: workspaceDir,
|
||||
runtimeMode: "full-access",
|
||||
providerOptions: {
|
||||
codex: {
|
||||
...(process.env.CODEX_BINARY_PATH
|
||||
? { binaryPath: process.env.CODEX_BINARY_PATH }
|
||||
: {}),
|
||||
...(process.env.CODEX_HOME_PATH
|
||||
? { homePath: process.env.CODEX_HOME_PATH }
|
||||
: {}),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const firstTurn = await manager.sendTurn({
|
||||
threadId: firstSession.threadId,
|
||||
input: `Reply with exactly the word ALPHA ${randomUUID()}`,
|
||||
});
|
||||
|
||||
expect(firstTurn.threadId).toBe(firstSession.threadId);
|
||||
|
||||
await vi.waitFor(async () => {
|
||||
const snapshot = await manager.readThread(firstSession.threadId);
|
||||
expect(snapshot.turns.length).toBeGreaterThan(0);
|
||||
}, { timeout: 120_000, interval: 1_000 });
|
||||
|
||||
const firstSnapshot = await manager.readThread(firstSession.threadId);
|
||||
const originalThreadId = firstSnapshot.threadId;
|
||||
const originalTurnCount = firstSnapshot.turns.length;
|
||||
|
||||
manager.stopSession(firstSession.threadId);
|
||||
|
||||
const resumedSession = await manager.startSession({
|
||||
threadId: firstSession.threadId,
|
||||
provider: "codex",
|
||||
cwd: workspaceDir,
|
||||
runtimeMode: "approval-required",
|
||||
resumeCursor: firstSession.resumeCursor,
|
||||
providerOptions: {
|
||||
codex: {
|
||||
...(process.env.CODEX_BINARY_PATH
|
||||
? { binaryPath: process.env.CODEX_BINARY_PATH }
|
||||
: {}),
|
||||
...(process.env.CODEX_HOME_PATH
|
||||
? { homePath: process.env.CODEX_HOME_PATH }
|
||||
: {}),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(resumedSession.threadId).toBe(originalThreadId);
|
||||
|
||||
const resumedSnapshotBeforeTurn = await manager.readThread(resumedSession.threadId);
|
||||
expect(resumedSnapshotBeforeTurn.threadId).toBe(originalThreadId);
|
||||
expect(resumedSnapshotBeforeTurn.turns.length).toBeGreaterThanOrEqual(originalTurnCount);
|
||||
|
||||
await manager.sendTurn({
|
||||
threadId: resumedSession.threadId,
|
||||
input: `Reply with exactly the word BETA ${randomUUID()}`,
|
||||
});
|
||||
|
||||
await vi.waitFor(async () => {
|
||||
const snapshot = await manager.readThread(resumedSession.threadId);
|
||||
expect(snapshot.turns.length).toBeGreaterThan(originalTurnCount);
|
||||
}, { timeout: 120_000, interval: 1_000 });
|
||||
} finally {
|
||||
manager.stopAll();
|
||||
rmSync(workspaceDir, { recursive: true, force: true });
|
||||
}
|
||||
},
|
||||
180_000,
|
||||
);
|
||||
});
|
||||
@@ -8,16 +8,19 @@ import {
|
||||
EventId,
|
||||
ProviderItemId,
|
||||
ProviderRequestKind,
|
||||
ProviderSessionId,
|
||||
ProviderThreadId,
|
||||
ProviderTurnId,
|
||||
normalizeModelSlug,
|
||||
type ProviderUserInputAnswers,
|
||||
ThreadId,
|
||||
TurnId,
|
||||
type ProviderApprovalDecision,
|
||||
type ProviderEvent,
|
||||
type ProviderSession,
|
||||
type ProviderSessionStartInput,
|
||||
type ProviderTurnStartResult,
|
||||
RuntimeMode,
|
||||
ProviderInteractionMode,
|
||||
} from "@t3tools/contracts";
|
||||
import { normalizeModelSlug } from "@t3tools/shared/model";
|
||||
import { Effect, ServiceMap } from "effect";
|
||||
|
||||
type PendingRequestKey = string;
|
||||
|
||||
@@ -33,17 +36,30 @@ interface PendingApprovalRequest {
|
||||
jsonRpcId: string | number;
|
||||
method: "item/commandExecution/requestApproval" | "item/fileChange/requestApproval";
|
||||
requestKind: ProviderRequestKind;
|
||||
threadId?: ProviderThreadId;
|
||||
turnId?: ProviderTurnId;
|
||||
threadId: ThreadId;
|
||||
turnId?: TurnId;
|
||||
itemId?: ProviderItemId;
|
||||
}
|
||||
|
||||
interface PendingUserInputRequest {
|
||||
requestId: ApprovalRequestId;
|
||||
jsonRpcId: string | number;
|
||||
threadId: ThreadId;
|
||||
turnId?: TurnId;
|
||||
itemId?: ProviderItemId;
|
||||
}
|
||||
|
||||
interface CodexUserInputAnswer {
|
||||
answers: string[];
|
||||
}
|
||||
|
||||
interface CodexSessionContext {
|
||||
session: ProviderSession;
|
||||
child: ChildProcessWithoutNullStreams;
|
||||
output: readline.Interface;
|
||||
pending: Map<PendingRequestKey, PendingRequest>;
|
||||
pendingApprovals: Map<ApprovalRequestId, PendingApprovalRequest>;
|
||||
pendingUserInputs: Map<ApprovalRequestId, PendingUserInputRequest>;
|
||||
nextRequestId: number;
|
||||
stopping: boolean;
|
||||
}
|
||||
@@ -71,20 +87,33 @@ interface JsonRpcNotification {
|
||||
}
|
||||
|
||||
export interface CodexAppServerSendTurnInput {
|
||||
readonly sessionId: ProviderSessionId;
|
||||
readonly threadId: ThreadId;
|
||||
readonly input?: string;
|
||||
readonly attachments?: ReadonlyArray<{ type: "image"; url: string }>;
|
||||
readonly model?: string;
|
||||
readonly effort?: string;
|
||||
readonly serviceTier?: string;
|
||||
readonly interactionMode?: ProviderInteractionMode;
|
||||
}
|
||||
|
||||
export interface CodexAppServerStartSessionInput {
|
||||
readonly threadId: ThreadId;
|
||||
readonly provider?: "codex";
|
||||
readonly cwd?: string;
|
||||
readonly model?: string;
|
||||
readonly serviceTier?: string;
|
||||
readonly resumeCursor?: unknown;
|
||||
readonly providerOptions?: ProviderSessionStartInput["providerOptions"];
|
||||
readonly runtimeMode: RuntimeMode;
|
||||
}
|
||||
|
||||
export interface CodexThreadTurnSnapshot {
|
||||
id: ProviderTurnId;
|
||||
id: TurnId;
|
||||
items: unknown[];
|
||||
}
|
||||
|
||||
export interface CodexThreadSnapshot {
|
||||
threadId: ProviderThreadId;
|
||||
threadId: string;
|
||||
turns: CodexThreadTurnSnapshot[];
|
||||
}
|
||||
|
||||
@@ -103,6 +132,144 @@ const RECOVERABLE_THREAD_RESUME_ERROR_SNIPPETS = [
|
||||
"unknown thread",
|
||||
"does not exist",
|
||||
];
|
||||
export const CODEX_PLAN_MODE_DEVELOPER_INSTRUCTIONS = `<collaboration_mode># Plan Mode (Conversational)
|
||||
|
||||
You work in 3 phases, and you should *chat your way* to a great plan before finalizing it. A great plan is very detailed-intent- and implementation-wise-so that it can be handed to another engineer or agent to be implemented right away. It must be **decision complete**, where the implementer does not need to make any decisions.
|
||||
|
||||
## Mode rules (strict)
|
||||
|
||||
You are in **Plan Mode** until a developer message explicitly ends it.
|
||||
|
||||
Plan Mode is not changed by user intent, tone, or imperative language. If a user asks for execution while still in Plan Mode, treat it as a request to **plan the execution**, not perform it.
|
||||
|
||||
## Plan Mode vs update_plan tool
|
||||
|
||||
Plan Mode is a collaboration mode that can involve requesting user input and eventually issuing a \`<proposed_plan>\` block.
|
||||
|
||||
Separately, \`update_plan\` is a checklist/progress/TODOs tool; it does not enter or exit Plan Mode. Do not confuse it with Plan mode or try to use it while in Plan mode. If you try to use \`update_plan\` in Plan mode, it will return an error.
|
||||
|
||||
## Execution vs. mutation in Plan Mode
|
||||
|
||||
You may explore and execute **non-mutating** actions that improve the plan. You must not perform **mutating** actions.
|
||||
|
||||
### Allowed (non-mutating, plan-improving)
|
||||
|
||||
Actions that gather truth, reduce ambiguity, or validate feasibility without changing repo-tracked state. Examples:
|
||||
|
||||
* Reading or searching files, configs, schemas, types, manifests, and docs
|
||||
* Static analysis, inspection, and repo exploration
|
||||
* Dry-run style commands when they do not edit repo-tracked files
|
||||
* Tests, builds, or checks that may write to caches or build artifacts (for example, \`target/\`, \`.cache/\`, or snapshots) so long as they do not edit repo-tracked files
|
||||
|
||||
### Not allowed (mutating, plan-executing)
|
||||
|
||||
Actions that implement the plan or change repo-tracked state. Examples:
|
||||
|
||||
* Editing or writing files
|
||||
* Running formatters or linters that rewrite files
|
||||
* Applying patches, migrations, or codegen that updates repo-tracked files
|
||||
* Side-effectful commands whose purpose is to carry out the plan rather than refine it
|
||||
|
||||
When in doubt: if the action would reasonably be described as "doing the work" rather than "planning the work," do not do it.
|
||||
|
||||
## PHASE 1 - Ground in the environment (explore first, ask second)
|
||||
|
||||
Begin by grounding yourself in the actual environment. Eliminate unknowns in the prompt by discovering facts, not by asking the user. Resolve all questions that can be answered through exploration or inspection. Identify missing or ambiguous details only if they cannot be derived from the environment. Silent exploration between turns is allowed and encouraged.
|
||||
|
||||
Before asking the user any question, perform at least one targeted non-mutating exploration pass (for example: search relevant files, inspect likely entrypoints/configs, confirm current implementation shape), unless no local environment/repo is available.
|
||||
|
||||
Exception: you may ask clarifying questions about the user's prompt before exploring, ONLY if there are obvious ambiguities or contradictions in the prompt itself. However, if ambiguity might be resolved by exploring, always prefer exploring first.
|
||||
|
||||
Do not ask questions that can be answered from the repo or system (for example, "where is this struct?" or "which UI component should we use?" when exploration can make it clear). Only ask once you have exhausted reasonable non-mutating exploration.
|
||||
|
||||
## PHASE 2 - Intent chat (what they actually want)
|
||||
|
||||
* Keep asking until you can clearly state: goal + success criteria, audience, in/out of scope, constraints, current state, and the key preferences/tradeoffs.
|
||||
* Bias toward questions over guessing: if any high-impact ambiguity remains, do NOT plan yet-ask.
|
||||
|
||||
## PHASE 3 - Implementation chat (what/how we'll build)
|
||||
|
||||
* Once intent is stable, keep asking until the spec is decision complete: approach, interfaces (APIs/schemas/I/O), data flow, edge cases/failure modes, testing + acceptance criteria, rollout/monitoring, and any migrations/compat constraints.
|
||||
|
||||
## Asking questions
|
||||
|
||||
Critical rules:
|
||||
|
||||
* Strongly prefer using the \`request_user_input\` tool to ask any questions.
|
||||
* Offer only meaningful multiple-choice options; don't include filler choices that are obviously wrong or irrelevant.
|
||||
* In rare cases where an unavoidable, important question can't be expressed with reasonable multiple-choice options (due to extreme ambiguity), you may ask it directly without the tool.
|
||||
|
||||
You SHOULD ask many questions, but each question must:
|
||||
|
||||
* materially change the spec/plan, OR
|
||||
* confirm/lock an assumption, OR
|
||||
* choose between meaningful tradeoffs.
|
||||
* not be answerable by non-mutating commands.
|
||||
|
||||
Use the \`request_user_input\` tool only for decisions that materially change the plan, for confirming important assumptions, or for information that cannot be discovered via non-mutating exploration.
|
||||
|
||||
## Two kinds of unknowns (treat differently)
|
||||
|
||||
1. **Discoverable facts** (repo/system truth): explore first.
|
||||
|
||||
* Before asking, run targeted searches and check likely sources of truth (configs/manifests/entrypoints/schemas/types/constants).
|
||||
* Ask only if: multiple plausible candidates; nothing found but you need a missing identifier/context; or ambiguity is actually product intent.
|
||||
* If asking, present concrete candidates (paths/service names) + recommend one.
|
||||
* Never ask questions you can answer from your environment (e.g., "where is this struct").
|
||||
|
||||
2. **Preferences/tradeoffs** (not discoverable): ask early.
|
||||
|
||||
* These are intent or implementation preferences that cannot be derived from exploration.
|
||||
* Provide 2-4 mutually exclusive options + a recommended default.
|
||||
* If unanswered, proceed with the recommended option and record it as an assumption in the final plan.
|
||||
|
||||
## Finalization rule
|
||||
|
||||
Only output the final plan when it is decision complete and leaves no decisions to the implementer.
|
||||
|
||||
When you present the official plan, wrap it in a \`<proposed_plan>\` block so the client can render it specially:
|
||||
|
||||
1) The opening tag must be on its own line.
|
||||
2) Start the plan content on the next line (no text on the same line as the tag).
|
||||
3) The closing tag must be on its own line.
|
||||
4) Use Markdown inside the block.
|
||||
5) Keep the tags exactly as \`<proposed_plan>\` and \`</proposed_plan>\` (do not translate or rename them), even if the plan content is in another language.
|
||||
|
||||
Example:
|
||||
|
||||
<proposed_plan>
|
||||
plan content
|
||||
</proposed_plan>
|
||||
|
||||
plan content should be human and agent digestible. The final plan must be plan-only and include:
|
||||
|
||||
* A clear title
|
||||
* A brief summary section
|
||||
* Important changes or additions to public APIs/interfaces/types
|
||||
* Test cases and scenarios
|
||||
* Explicit assumptions and defaults chosen where needed
|
||||
|
||||
Do not ask "should I proceed?" in the final output. The user can easily switch out of Plan mode and request implementation if you have included a \`<proposed_plan>\` block in your response. Alternatively, they can decide to stay in Plan mode and continue refining the plan.
|
||||
|
||||
Only produce at most one \`<proposed_plan>\` block per turn, and only when you are presenting a complete spec.
|
||||
</collaboration_mode>`;
|
||||
|
||||
function mapCodexRuntimeMode(runtimeMode: RuntimeMode): {
|
||||
readonly approvalPolicy: "on-request" | "never";
|
||||
readonly sandbox: "workspace-write" | "danger-full-access";
|
||||
} {
|
||||
if (runtimeMode === "approval-required") {
|
||||
return {
|
||||
approvalPolicy: "on-request",
|
||||
sandbox: "workspace-write",
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
approvalPolicy: "never",
|
||||
sandbox: "danger-full-access",
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* On Windows with `shell: true`, `child.kill()` only terminates the `cmd.exe`
|
||||
@@ -137,6 +304,83 @@ export function normalizeCodexModelSlug(
|
||||
return normalized;
|
||||
}
|
||||
|
||||
export function buildCodexInitializeParams() {
|
||||
return {
|
||||
clientInfo: {
|
||||
name: "t3code_desktop",
|
||||
title: "T3 Code Desktop",
|
||||
version: "0.1.0",
|
||||
},
|
||||
capabilities: {
|
||||
experimentalApi: true,
|
||||
},
|
||||
} as const;
|
||||
}
|
||||
|
||||
function buildCodexCollaborationMode(input: {
|
||||
readonly interactionMode?: "default" | "plan";
|
||||
readonly model?: string;
|
||||
readonly effort?: string;
|
||||
}):
|
||||
| {
|
||||
mode: "plan";
|
||||
settings: {
|
||||
model: string;
|
||||
reasoning_effort: string;
|
||||
developer_instructions: string;
|
||||
};
|
||||
}
|
||||
| undefined {
|
||||
if (input.interactionMode !== "plan") {
|
||||
return undefined;
|
||||
}
|
||||
const model = normalizeCodexModelSlug(input.model) ?? "gpt-5.3-codex";
|
||||
return {
|
||||
mode: "plan",
|
||||
settings: {
|
||||
model,
|
||||
reasoning_effort: input.effort ?? "medium",
|
||||
developer_instructions: CODEX_PLAN_MODE_DEVELOPER_INSTRUCTIONS,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function toCodexUserInputAnswer(value: unknown): CodexUserInputAnswer {
|
||||
if (typeof value === "string") {
|
||||
return { answers: [value] };
|
||||
}
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
const answers = value.filter((entry): entry is string => typeof entry === "string");
|
||||
if (answers.length > 0) {
|
||||
return { answers };
|
||||
}
|
||||
}
|
||||
|
||||
if (value && typeof value === "object") {
|
||||
const maybeAnswers = (value as { answers?: unknown }).answers;
|
||||
if (Array.isArray(maybeAnswers)) {
|
||||
const answers = maybeAnswers.filter((entry): entry is string => typeof entry === "string");
|
||||
if (answers.length > 0) {
|
||||
return { answers };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error("User input answers must be strings or arrays of strings.");
|
||||
}
|
||||
|
||||
function toCodexUserInputAnswers(
|
||||
answers: ProviderUserInputAnswers,
|
||||
): Record<string, CodexUserInputAnswer> {
|
||||
return Object.fromEntries(
|
||||
Object.entries(answers).map(([questionId, value]) => [
|
||||
questionId,
|
||||
toCodexUserInputAnswer(value),
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
export function classifyCodexStderrLine(rawLine: string): { message: string } | null {
|
||||
const line = rawLine.replaceAll(ANSI_ESCAPE_REGEX, "").trim();
|
||||
if (!line) {
|
||||
@@ -173,10 +417,16 @@ export interface CodexAppServerManagerEvents {
|
||||
}
|
||||
|
||||
export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEvents> {
|
||||
private readonly sessions = new Map<ProviderSessionId, CodexSessionContext>();
|
||||
private readonly sessions = new Map<ThreadId, CodexSessionContext>();
|
||||
|
||||
async startSession(input: ProviderSessionStartInput): Promise<ProviderSession> {
|
||||
const sessionId = ProviderSessionId.makeUnsafe(randomUUID());
|
||||
private runPromise: (effect: Effect.Effect<unknown, never>) => Promise<unknown>;
|
||||
constructor(services?: ServiceMap.ServiceMap<never>) {
|
||||
super();
|
||||
this.runPromise = services ? Effect.runPromiseWith(services) : Effect.runPromise;
|
||||
}
|
||||
|
||||
async startSession(input: CodexAppServerStartSessionInput): Promise<ProviderSession> {
|
||||
const threadId = input.threadId;
|
||||
const now = new Date().toISOString();
|
||||
let context: CodexSessionContext | undefined;
|
||||
|
||||
@@ -184,17 +434,19 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
const resolvedCwd = input.cwd ?? process.cwd();
|
||||
|
||||
const session: ProviderSession = {
|
||||
sessionId,
|
||||
provider: "codex",
|
||||
status: "connecting",
|
||||
runtimeMode: input.runtimeMode,
|
||||
model: normalizeCodexModelSlug(input.model),
|
||||
cwd: resolvedCwd,
|
||||
threadId,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
};
|
||||
|
||||
const codexBinaryPath = input.codexBinaryPath ?? "codex";
|
||||
const codexHomePath = input.codexHomePath;
|
||||
const codexOptions = readCodexProviderOptions(input);
|
||||
const codexBinaryPath = codexOptions.binaryPath ?? "codex";
|
||||
const codexHomePath = codexOptions.homePath;
|
||||
const child = spawn(codexBinaryPath, ["app-server"], {
|
||||
cwd: resolvedCwd,
|
||||
env: {
|
||||
@@ -212,25 +464,17 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
output,
|
||||
pending: new Map(),
|
||||
pendingApprovals: new Map(),
|
||||
pendingUserInputs: new Map(),
|
||||
nextRequestId: 1,
|
||||
stopping: false,
|
||||
};
|
||||
|
||||
this.sessions.set(sessionId, context);
|
||||
this.sessions.set(threadId, context);
|
||||
this.attachProcessListeners(context);
|
||||
|
||||
this.emitLifecycleEvent(context, "session/connecting", "Starting codex app-server");
|
||||
|
||||
await this.sendRequest(context, "initialize", {
|
||||
clientInfo: {
|
||||
name: "t3code_desktop",
|
||||
title: "T3 Code Desktop",
|
||||
version: "0.1.0",
|
||||
},
|
||||
capabilities: {
|
||||
experimentalApi: false,
|
||||
},
|
||||
});
|
||||
await this.sendRequest(context, "initialize", buildCodexInitializeParams());
|
||||
|
||||
this.writeMessage(context, { method: "initialized" });
|
||||
|
||||
@@ -238,8 +482,8 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
const sessionOverrides = {
|
||||
model: normalizedModel ?? null,
|
||||
cwd: input.cwd ?? null,
|
||||
approvalPolicy: input.approvalPolicy,
|
||||
sandbox: input.sandboxMode,
|
||||
...(input.serviceTier !== undefined ? { serviceTier: input.serviceTier } : {}),
|
||||
...mapCodexRuntimeMode(input.runtimeMode ?? "full-access"),
|
||||
};
|
||||
|
||||
const threadStartParams = {
|
||||
@@ -247,6 +491,20 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
experimentalRawEvents: false,
|
||||
};
|
||||
const resumeThreadId = readResumeThreadId(input);
|
||||
this.emitLifecycleEvent(
|
||||
context,
|
||||
"session/threadOpenRequested",
|
||||
resumeThreadId
|
||||
? `Attempting to resume thread ${resumeThreadId}.`
|
||||
: "Starting a new Codex thread.",
|
||||
);
|
||||
await Effect.logInfo("codex app-server opening thread", {
|
||||
threadId,
|
||||
requestedRuntimeMode: input.runtimeMode,
|
||||
requestedModel: normalizedModel ?? null,
|
||||
requestedCwd: resolvedCwd,
|
||||
resumeThreadId: resumeThreadId ?? null,
|
||||
}).pipe(this.runPromise);
|
||||
|
||||
let threadOpenMethod: "thread/start" | "thread/resume" = "thread/start";
|
||||
let threadOpenResponse: unknown;
|
||||
@@ -259,6 +517,18 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
});
|
||||
} catch (error) {
|
||||
if (!isRecoverableThreadResumeError(error)) {
|
||||
this.emitErrorEvent(
|
||||
context,
|
||||
"session/threadResumeFailed",
|
||||
error instanceof Error ? error.message : "Codex thread resume failed.",
|
||||
);
|
||||
await Effect.logWarning("codex app-server thread resume failed", {
|
||||
threadId,
|
||||
requestedRuntimeMode: input.runtimeMode,
|
||||
resumeThreadId,
|
||||
recoverable: false,
|
||||
cause: error instanceof Error ? error.message : String(error),
|
||||
}).pipe(this.runPromise);
|
||||
throw error;
|
||||
}
|
||||
|
||||
@@ -268,6 +538,13 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
"session/threadResumeFallback",
|
||||
`Could not resume thread ${resumeThreadId}; started a new thread instead.`,
|
||||
);
|
||||
await Effect.logWarning("codex app-server thread resume fell back to fresh start", {
|
||||
threadId,
|
||||
requestedRuntimeMode: input.runtimeMode,
|
||||
resumeThreadId,
|
||||
recoverable: true,
|
||||
cause: error instanceof Error ? error.message : String(error),
|
||||
}).pipe(this.runPromise);
|
||||
threadOpenResponse = await this.sendRequest(context, "thread/start", threadStartParams);
|
||||
}
|
||||
} else {
|
||||
@@ -282,14 +559,25 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
if (!threadIdRaw) {
|
||||
throw new Error(`${threadOpenMethod} response did not include a thread id.`);
|
||||
}
|
||||
const threadId = ProviderThreadId.makeUnsafe(threadIdRaw);
|
||||
const providerThreadId = threadIdRaw;
|
||||
|
||||
this.updateSession(context, {
|
||||
status: "ready",
|
||||
threadId,
|
||||
resumeCursor: { threadId },
|
||||
resumeCursor: { threadId: providerThreadId },
|
||||
});
|
||||
this.emitLifecycleEvent(context, "session/ready", `Connected to thread ${threadId}`);
|
||||
this.emitLifecycleEvent(
|
||||
context,
|
||||
"session/threadOpenResolved",
|
||||
`Codex ${threadOpenMethod} resolved.`,
|
||||
);
|
||||
await Effect.logInfo("codex app-server thread open resolved", {
|
||||
threadId,
|
||||
threadOpenMethod,
|
||||
requestedResumeThreadId: resumeThreadId ?? null,
|
||||
resolvedThreadId: providerThreadId,
|
||||
requestedRuntimeMode: input.runtimeMode,
|
||||
}).pipe(this.runPromise);
|
||||
this.emitLifecycleEvent(context, "session/ready", `Connected to thread ${providerThreadId}`);
|
||||
return { ...context.session };
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : "Failed to start Codex session.";
|
||||
@@ -299,13 +587,13 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
lastError: message,
|
||||
});
|
||||
this.emitErrorEvent(context, "session/startFailed", message);
|
||||
this.stopSession(sessionId);
|
||||
this.stopSession(threadId);
|
||||
} else {
|
||||
this.emitEvent({
|
||||
id: EventId.makeUnsafe(randomUUID()),
|
||||
kind: "error",
|
||||
provider: "codex",
|
||||
sessionId,
|
||||
threadId,
|
||||
createdAt: new Date().toISOString(),
|
||||
method: "session/startFailed",
|
||||
message,
|
||||
@@ -316,10 +604,7 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
}
|
||||
|
||||
async sendTurn(input: CodexAppServerSendTurnInput): Promise<ProviderTurnStartResult> {
|
||||
const context = this.requireSession(input.sessionId);
|
||||
if (!context.session.threadId) {
|
||||
throw new Error("Session is missing a thread id.");
|
||||
}
|
||||
const context = this.requireSession(input.threadId);
|
||||
|
||||
const turnInput: Array<
|
||||
{ type: "text"; text: string; text_elements: [] } | { type: "image"; url: string }
|
||||
@@ -343,24 +628,55 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
throw new Error("Turn input must include text or attachments.");
|
||||
}
|
||||
|
||||
const providerThreadId = readResumeThreadId({
|
||||
threadId: context.session.threadId,
|
||||
runtimeMode: context.session.runtimeMode,
|
||||
resumeCursor: context.session.resumeCursor,
|
||||
});
|
||||
if (!providerThreadId) {
|
||||
throw new Error("Session is missing provider resume thread id.");
|
||||
}
|
||||
const turnStartParams: {
|
||||
threadId: ProviderThreadId;
|
||||
threadId: string;
|
||||
input: Array<
|
||||
{ type: "text"; text: string; text_elements: [] } | { type: "image"; url: string }
|
||||
>;
|
||||
model?: string;
|
||||
effort?: string;
|
||||
serviceTier?: string;
|
||||
collaborationMode?: {
|
||||
mode: "plan";
|
||||
settings: {
|
||||
model: string;
|
||||
reasoning_effort: string;
|
||||
developer_instructions: string;
|
||||
};
|
||||
};
|
||||
} = {
|
||||
threadId: context.session.threadId,
|
||||
threadId: providerThreadId,
|
||||
input: turnInput,
|
||||
};
|
||||
const normalizedModel = normalizeCodexModelSlug(input.model);
|
||||
const normalizedModel = normalizeCodexModelSlug(input.model ?? context.session.model);
|
||||
if (normalizedModel) {
|
||||
turnStartParams.model = normalizedModel;
|
||||
}
|
||||
if (input.effort) {
|
||||
turnStartParams.effort = input.effort;
|
||||
}
|
||||
if (input.serviceTier) {
|
||||
turnStartParams.serviceTier = input.serviceTier;
|
||||
}
|
||||
const collaborationMode = buildCodexCollaborationMode({
|
||||
...(input.interactionMode !== undefined ? { interactionMode: input.interactionMode } : {}),
|
||||
...(normalizedModel !== undefined ? { model: normalizedModel } : {}),
|
||||
...(input.effort !== undefined ? { effort: input.effort } : {}),
|
||||
});
|
||||
if (collaborationMode) {
|
||||
if (!turnStartParams.model) {
|
||||
turnStartParams.model = collaborationMode.settings.model;
|
||||
}
|
||||
turnStartParams.collaborationMode = collaborationMode;
|
||||
}
|
||||
|
||||
const response = await this.sendRequest(context, "turn/start", turnStartParams);
|
||||
|
||||
@@ -369,64 +685,78 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
if (!turnIdRaw) {
|
||||
throw new Error("turn/start response did not include a turn id.");
|
||||
}
|
||||
const turnId = ProviderTurnId.makeUnsafe(turnIdRaw);
|
||||
const turnId = TurnId.makeUnsafe(turnIdRaw);
|
||||
|
||||
this.updateSession(context, {
|
||||
status: "running",
|
||||
activeTurnId: turnId,
|
||||
resumeCursor: context.session.resumeCursor ?? { threadId: context.session.threadId },
|
||||
...(context.session.resumeCursor !== undefined
|
||||
? { resumeCursor: context.session.resumeCursor }
|
||||
: {}),
|
||||
});
|
||||
|
||||
return {
|
||||
threadId: context.session.threadId,
|
||||
turnId,
|
||||
resumeCursor: context.session.resumeCursor ?? { threadId: context.session.threadId },
|
||||
...(context.session.resumeCursor !== undefined
|
||||
? { resumeCursor: context.session.resumeCursor }
|
||||
: {}),
|
||||
};
|
||||
}
|
||||
|
||||
async interruptTurn(sessionId: ProviderSessionId, turnId?: ProviderTurnId): Promise<void> {
|
||||
const context = this.requireSession(sessionId);
|
||||
async interruptTurn(threadId: ThreadId, turnId?: TurnId): Promise<void> {
|
||||
const context = this.requireSession(threadId);
|
||||
const effectiveTurnId = turnId ?? context.session.activeTurnId;
|
||||
|
||||
if (!effectiveTurnId || !context.session.threadId) {
|
||||
const providerThreadId = readResumeThreadId({
|
||||
threadId: context.session.threadId,
|
||||
runtimeMode: context.session.runtimeMode,
|
||||
resumeCursor: context.session.resumeCursor,
|
||||
});
|
||||
if (!effectiveTurnId || !providerThreadId) {
|
||||
return;
|
||||
}
|
||||
|
||||
await this.sendRequest(context, "turn/interrupt", {
|
||||
threadId: context.session.threadId,
|
||||
threadId: providerThreadId,
|
||||
turnId: effectiveTurnId,
|
||||
});
|
||||
}
|
||||
|
||||
async readThread(sessionId: ProviderSessionId): Promise<CodexThreadSnapshot> {
|
||||
const context = this.requireSession(sessionId);
|
||||
const threadId = context.session.threadId;
|
||||
if (!threadId) {
|
||||
throw new Error("Session is missing a thread id.");
|
||||
async readThread(threadId: ThreadId): Promise<CodexThreadSnapshot> {
|
||||
const context = this.requireSession(threadId);
|
||||
const providerThreadId = readResumeThreadId({
|
||||
threadId: context.session.threadId,
|
||||
runtimeMode: context.session.runtimeMode,
|
||||
resumeCursor: context.session.resumeCursor,
|
||||
});
|
||||
if (!providerThreadId) {
|
||||
throw new Error("Session is missing a provider resume thread id.");
|
||||
}
|
||||
|
||||
const response = await this.sendRequest(context, "thread/read", {
|
||||
threadId,
|
||||
threadId: providerThreadId,
|
||||
includeTurns: true,
|
||||
});
|
||||
return this.parseThreadSnapshot("thread/read", response);
|
||||
}
|
||||
|
||||
async rollbackThread(
|
||||
sessionId: ProviderSessionId,
|
||||
numTurns: number,
|
||||
): Promise<CodexThreadSnapshot> {
|
||||
const context = this.requireSession(sessionId);
|
||||
const threadId = context.session.threadId;
|
||||
if (!threadId) {
|
||||
throw new Error("Session is missing a thread id.");
|
||||
async rollbackThread(threadId: ThreadId, numTurns: number): Promise<CodexThreadSnapshot> {
|
||||
const context = this.requireSession(threadId);
|
||||
const providerThreadId = readResumeThreadId({
|
||||
threadId: context.session.threadId,
|
||||
runtimeMode: context.session.runtimeMode,
|
||||
resumeCursor: context.session.resumeCursor,
|
||||
});
|
||||
if (!providerThreadId) {
|
||||
throw new Error("Session is missing a provider resume thread id.");
|
||||
}
|
||||
if (!Number.isInteger(numTurns) || numTurns < 1) {
|
||||
throw new Error("numTurns must be an integer >= 1.");
|
||||
}
|
||||
|
||||
const response = await this.sendRequest(context, "thread/rollback", {
|
||||
threadId,
|
||||
threadId: providerThreadId,
|
||||
numTurns,
|
||||
});
|
||||
this.updateSession(context, {
|
||||
@@ -437,11 +767,11 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
}
|
||||
|
||||
async respondToRequest(
|
||||
sessionId: ProviderSessionId,
|
||||
threadId: ThreadId,
|
||||
requestId: ApprovalRequestId,
|
||||
decision: ProviderApprovalDecision,
|
||||
): Promise<void> {
|
||||
const context = this.requireSession(sessionId);
|
||||
const context = this.requireSession(threadId);
|
||||
const pendingRequest = context.pendingApprovals.get(requestId);
|
||||
if (!pendingRequest) {
|
||||
throw new Error(`Unknown pending approval request: ${requestId}`);
|
||||
@@ -459,10 +789,9 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
id: EventId.makeUnsafe(randomUUID()),
|
||||
kind: "notification",
|
||||
provider: "codex",
|
||||
sessionId: context.session.sessionId,
|
||||
threadId: context.session.threadId,
|
||||
createdAt: new Date().toISOString(),
|
||||
method: "item/requestApproval/decision",
|
||||
threadId: pendingRequest.threadId,
|
||||
turnId: pendingRequest.turnId,
|
||||
itemId: pendingRequest.itemId,
|
||||
requestId: pendingRequest.requestId,
|
||||
@@ -475,8 +804,45 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
});
|
||||
}
|
||||
|
||||
stopSession(sessionId: ProviderSessionId): void {
|
||||
const context = this.sessions.get(sessionId);
|
||||
async respondToUserInput(
|
||||
threadId: ThreadId,
|
||||
requestId: ApprovalRequestId,
|
||||
answers: ProviderUserInputAnswers,
|
||||
): Promise<void> {
|
||||
const context = this.requireSession(threadId);
|
||||
const pendingRequest = context.pendingUserInputs.get(requestId);
|
||||
if (!pendingRequest) {
|
||||
throw new Error(`Unknown pending user input request: ${requestId}`);
|
||||
}
|
||||
|
||||
context.pendingUserInputs.delete(requestId);
|
||||
const codexAnswers = toCodexUserInputAnswers(answers);
|
||||
this.writeMessage(context, {
|
||||
id: pendingRequest.jsonRpcId,
|
||||
result: {
|
||||
answers: codexAnswers,
|
||||
},
|
||||
});
|
||||
|
||||
this.emitEvent({
|
||||
id: EventId.makeUnsafe(randomUUID()),
|
||||
kind: "notification",
|
||||
provider: "codex",
|
||||
threadId: context.session.threadId,
|
||||
createdAt: new Date().toISOString(),
|
||||
method: "item/tool/requestUserInput/answered",
|
||||
turnId: pendingRequest.turnId,
|
||||
itemId: pendingRequest.itemId,
|
||||
requestId: pendingRequest.requestId,
|
||||
payload: {
|
||||
requestId: pendingRequest.requestId,
|
||||
answers: codexAnswers,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
stopSession(threadId: ThreadId): void {
|
||||
const context = this.sessions.get(threadId);
|
||||
if (!context) {
|
||||
return;
|
||||
}
|
||||
@@ -489,6 +855,7 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
}
|
||||
context.pending.clear();
|
||||
context.pendingApprovals.clear();
|
||||
context.pendingUserInputs.clear();
|
||||
|
||||
context.output.close();
|
||||
|
||||
@@ -501,7 +868,7 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
activeTurnId: undefined,
|
||||
});
|
||||
this.emitLifecycleEvent(context, "session/closed", "Session stopped");
|
||||
this.sessions.delete(sessionId);
|
||||
this.sessions.delete(threadId);
|
||||
}
|
||||
|
||||
listSessions(): ProviderSession[] {
|
||||
@@ -510,24 +877,24 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
}));
|
||||
}
|
||||
|
||||
hasSession(sessionId: ProviderSessionId): boolean {
|
||||
return this.sessions.has(sessionId);
|
||||
hasSession(threadId: ThreadId): boolean {
|
||||
return this.sessions.has(threadId);
|
||||
}
|
||||
|
||||
stopAll(): void {
|
||||
for (const sessionId of this.sessions.keys()) {
|
||||
this.stopSession(sessionId);
|
||||
for (const threadId of this.sessions.keys()) {
|
||||
this.stopSession(threadId);
|
||||
}
|
||||
}
|
||||
|
||||
private requireSession(sessionId: ProviderSessionId): CodexSessionContext {
|
||||
const context = this.sessions.get(sessionId);
|
||||
private requireSession(threadId: ThreadId): CodexSessionContext {
|
||||
const context = this.sessions.get(threadId);
|
||||
if (!context) {
|
||||
throw new Error(`Unknown session: ${sessionId}`);
|
||||
throw new Error(`Unknown session for thread: ${threadId}`);
|
||||
}
|
||||
|
||||
if (context.session.status === "closed") {
|
||||
throw new Error(`Session is closed: ${sessionId}`);
|
||||
throw new Error(`Session is closed for thread: ${threadId}`);
|
||||
}
|
||||
|
||||
return context;
|
||||
@@ -572,7 +939,7 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
lastError: code === 0 ? context.session.lastError : message,
|
||||
});
|
||||
this.emitLifecycleEvent(context, "session/exited", message);
|
||||
this.sessions.delete(context.session.sessionId);
|
||||
this.sessions.delete(context.session.threadId);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -634,10 +1001,9 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
id: EventId.makeUnsafe(randomUUID()),
|
||||
kind: "notification",
|
||||
provider: "codex",
|
||||
sessionId: context.session.sessionId,
|
||||
threadId: context.session.threadId,
|
||||
createdAt: new Date().toISOString(),
|
||||
method: notification.method,
|
||||
threadId: route.threadId,
|
||||
turnId: route.turnId,
|
||||
itemId: route.itemId,
|
||||
textDelta,
|
||||
@@ -645,19 +1011,17 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
});
|
||||
|
||||
if (notification.method === "thread/started") {
|
||||
const threadId = toProviderThreadId(
|
||||
const providerThreadId = normalizeProviderThreadId(
|
||||
this.readString(this.readObject(notification.params)?.thread, "id"),
|
||||
);
|
||||
if (threadId) {
|
||||
this.updateSession(context, { threadId });
|
||||
if (providerThreadId) {
|
||||
this.updateSession(context, { resumeCursor: { threadId: providerThreadId } });
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (notification.method === "turn/started") {
|
||||
const turnId = toProviderTurnId(
|
||||
this.readString(this.readObject(notification.params)?.turn, "id"),
|
||||
);
|
||||
const turnId = toTurnId(this.readString(this.readObject(notification.params)?.turn, "id"));
|
||||
this.updateSession(context, {
|
||||
status: "running",
|
||||
activeTurnId: turnId,
|
||||
@@ -702,21 +1066,31 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
? "item/commandExecution/requestApproval"
|
||||
: "item/fileChange/requestApproval",
|
||||
requestKind,
|
||||
...(route.threadId ? { threadId: route.threadId } : {}),
|
||||
threadId: context.session.threadId,
|
||||
...(route.turnId ? { turnId: route.turnId } : {}),
|
||||
...(route.itemId ? { itemId: route.itemId } : {}),
|
||||
};
|
||||
context.pendingApprovals.set(requestId, pendingRequest);
|
||||
}
|
||||
|
||||
if (request.method === "item/tool/requestUserInput") {
|
||||
requestId = ApprovalRequestId.makeUnsafe(randomUUID());
|
||||
context.pendingUserInputs.set(requestId, {
|
||||
requestId,
|
||||
jsonRpcId: request.id,
|
||||
threadId: context.session.threadId,
|
||||
...(route.turnId ? { turnId: route.turnId } : {}),
|
||||
...(route.itemId ? { itemId: route.itemId } : {}),
|
||||
});
|
||||
}
|
||||
|
||||
this.emitEvent({
|
||||
id: EventId.makeUnsafe(randomUUID()),
|
||||
kind: "request",
|
||||
provider: "codex",
|
||||
sessionId: context.session.sessionId,
|
||||
threadId: context.session.threadId,
|
||||
createdAt: new Date().toISOString(),
|
||||
method: request.method,
|
||||
threadId: route.threadId,
|
||||
turnId: route.turnId,
|
||||
itemId: route.itemId,
|
||||
requestId,
|
||||
@@ -729,10 +1103,6 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
}
|
||||
|
||||
if (request.method === "item/tool/requestUserInput") {
|
||||
this.writeMessage(context, {
|
||||
id: request.id,
|
||||
result: { answers: {} },
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -808,7 +1178,7 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
id: EventId.makeUnsafe(randomUUID()),
|
||||
kind: "session",
|
||||
provider: "codex",
|
||||
sessionId: context.session.sessionId,
|
||||
threadId: context.session.threadId,
|
||||
createdAt: new Date().toISOString(),
|
||||
method,
|
||||
message,
|
||||
@@ -820,7 +1190,7 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
id: EventId.makeUnsafe(randomUUID()),
|
||||
kind: "error",
|
||||
provider: "codex",
|
||||
sessionId: context.session.sessionId,
|
||||
threadId: context.session.threadId,
|
||||
createdAt: new Date().toISOString(),
|
||||
method,
|
||||
message,
|
||||
@@ -844,6 +1214,10 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
return "command";
|
||||
}
|
||||
|
||||
if (method === "item/fileRead/requestApproval") {
|
||||
return "file-read";
|
||||
}
|
||||
|
||||
if (method === "item/fileChange/requestApproval") {
|
||||
return "file-change";
|
||||
}
|
||||
@@ -859,14 +1233,12 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
if (!threadIdRaw) {
|
||||
throw new Error(`${method} response did not include a thread id.`);
|
||||
}
|
||||
const threadId = ProviderThreadId.makeUnsafe(threadIdRaw);
|
||||
|
||||
const turnsRaw =
|
||||
this.readArray(thread, "turns") ?? this.readArray(responseRecord, "turns") ?? [];
|
||||
const turns = turnsRaw.map((turnValue, index) => {
|
||||
const turn = this.readObject(turnValue);
|
||||
const turnIdRaw = this.readString(turn, "id") ?? `${threadIdRaw}:turn:${index + 1}`;
|
||||
const turnId = ProviderTurnId.makeUnsafe(turnIdRaw);
|
||||
const turnId = TurnId.makeUnsafe(turnIdRaw);
|
||||
const items = this.readArray(turn, "items") ?? [];
|
||||
return {
|
||||
id: turnId,
|
||||
@@ -875,7 +1247,7 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
});
|
||||
|
||||
return {
|
||||
threadId,
|
||||
threadId: threadIdRaw,
|
||||
turns,
|
||||
};
|
||||
}
|
||||
@@ -913,31 +1285,21 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
}
|
||||
|
||||
private readRouteFields(params: unknown): {
|
||||
threadId?: ProviderThreadId;
|
||||
turnId?: ProviderTurnId;
|
||||
turnId?: TurnId;
|
||||
itemId?: ProviderItemId;
|
||||
} {
|
||||
const route: {
|
||||
threadId?: ProviderThreadId;
|
||||
turnId?: ProviderTurnId;
|
||||
turnId?: TurnId;
|
||||
itemId?: ProviderItemId;
|
||||
} = {};
|
||||
|
||||
const threadId = toProviderThreadId(
|
||||
this.readString(params, "threadId") ??
|
||||
this.readString(this.readObject(params, "thread"), "id"),
|
||||
);
|
||||
const turnId = toProviderTurnId(
|
||||
const turnId = toTurnId(
|
||||
this.readString(params, "turnId") ?? this.readString(this.readObject(params, "turn"), "id"),
|
||||
);
|
||||
const itemId = toProviderItemId(
|
||||
this.readString(params, "itemId") ?? this.readString(this.readObject(params, "item"), "id"),
|
||||
);
|
||||
|
||||
if (threadId) {
|
||||
route.threadId = threadId;
|
||||
}
|
||||
|
||||
if (turnId) {
|
||||
route.turnId = turnId;
|
||||
}
|
||||
@@ -1001,24 +1363,38 @@ function brandIfNonEmpty<T extends string>(
|
||||
return normalized?.length ? maker(normalized) : undefined;
|
||||
}
|
||||
|
||||
function toProviderThreadId(value: string | undefined): ProviderThreadId | undefined {
|
||||
return brandIfNonEmpty(value, ProviderThreadId.makeUnsafe);
|
||||
function normalizeProviderThreadId(value: string | undefined): string | undefined {
|
||||
return brandIfNonEmpty(value, (normalized) => normalized);
|
||||
}
|
||||
|
||||
function readResumeThreadId(input: ProviderSessionStartInput): ProviderThreadId | undefined {
|
||||
if (
|
||||
!input.resumeCursor ||
|
||||
typeof input.resumeCursor !== "object" ||
|
||||
Array.isArray(input.resumeCursor)
|
||||
) {
|
||||
return input.resumeThreadId;
|
||||
function readCodexProviderOptions(input: CodexAppServerStartSessionInput): {
|
||||
readonly binaryPath?: string;
|
||||
readonly homePath?: string;
|
||||
} {
|
||||
const options = input.providerOptions?.codex;
|
||||
if (!options) {
|
||||
return {};
|
||||
}
|
||||
const rawThreadId = (input.resumeCursor as Record<string, unknown>).threadId;
|
||||
return typeof rawThreadId === "string" ? toProviderThreadId(rawThreadId) : input.resumeThreadId;
|
||||
return {
|
||||
...(options.binaryPath ? { binaryPath: options.binaryPath } : {}),
|
||||
...(options.homePath ? { homePath: options.homePath } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
function toProviderTurnId(value: string | undefined): ProviderTurnId | undefined {
|
||||
return brandIfNonEmpty(value, ProviderTurnId.makeUnsafe);
|
||||
function readResumeCursorThreadId(resumeCursor: unknown): string | undefined {
|
||||
if (!resumeCursor || typeof resumeCursor !== "object" || Array.isArray(resumeCursor)) {
|
||||
return undefined;
|
||||
}
|
||||
const rawThreadId = (resumeCursor as Record<string, unknown>).threadId;
|
||||
return typeof rawThreadId === "string" ? normalizeProviderThreadId(rawThreadId) : undefined;
|
||||
}
|
||||
|
||||
function readResumeThreadId(input: CodexAppServerStartSessionInput): string | undefined {
|
||||
return readResumeCursorThreadId(input.resumeCursor);
|
||||
}
|
||||
|
||||
function toTurnId(value: string | undefined): TurnId | undefined {
|
||||
return brandIfNonEmpty(value, TurnId.makeUnsafe);
|
||||
}
|
||||
|
||||
function toProviderItemId(value: string | undefined): ProviderItemId | undefined {
|
||||
|
||||
@@ -77,7 +77,7 @@ beforeEach(() => {
|
||||
findAvailablePort.mockImplementation((preferred: number) => Effect.succeed(preferred));
|
||||
});
|
||||
|
||||
it.layer(testLayer)("server cli", (it) => {
|
||||
it.layer(testLayer)("server CLI command", (it) => {
|
||||
it.effect("parses all CLI flags and wires scoped start/stop", () =>
|
||||
Effect.gen(function* () {
|
||||
yield* runCli([
|
||||
|
||||
+22
-26
@@ -10,6 +10,7 @@ import { Config, Data, Effect, FileSystem, Layer, Option, Path, Schema, ServiceM
|
||||
import { Command, Flag } from "effect/unstable/cli";
|
||||
import { NetService } from "@t3tools/shared/Net";
|
||||
|
||||
// Dummy comment.
|
||||
import {
|
||||
DEFAULT_PORT,
|
||||
resolveStaticDir,
|
||||
@@ -23,6 +24,7 @@ import * as SqlitePersistence from "./persistence/Layers/Sqlite";
|
||||
import { makeServerProviderLayer, makeServerRuntimeServicesLayer } from "./serverLayers";
|
||||
import { ProviderHealthLive } from "./provider/Layers/ProviderHealth";
|
||||
import { Server } from "./wsServer";
|
||||
import { ServerLoggerLive } from "./serverLogger";
|
||||
|
||||
export class StartupError extends Data.TaggedError("StartupError")<{
|
||||
readonly message: string;
|
||||
@@ -119,6 +121,9 @@ const CliEnvConfig = Config.all({
|
||||
),
|
||||
});
|
||||
|
||||
const resolveBooleanFlag = (flag: Option.Option<boolean>, envValue: boolean) =>
|
||||
Option.getOrElse(Option.filter(flag, Boolean), () => envValue);
|
||||
|
||||
const ServerConfigLive = (input: CliInput) =>
|
||||
Layer.effect(
|
||||
ServerConfig,
|
||||
@@ -150,25 +155,16 @@ const ServerConfigLive = (input: CliInput) =>
|
||||
Option.getOrUndefined(input.stateDir) ?? env.stateDir,
|
||||
);
|
||||
const devUrl = Option.getOrElse(input.devUrl, () => env.devUrl);
|
||||
const noBrowser = Option.match(input.noBrowser, {
|
||||
// effect/cli boolean flags parse to `false` when absent; in that case
|
||||
// we still want env/mode fallbacks to apply.
|
||||
onSome: (value) => (value ? true : (env.noBrowser ?? mode === "desktop")),
|
||||
onNone: () => env.noBrowser ?? mode === "desktop",
|
||||
});
|
||||
const noBrowser = resolveBooleanFlag(input.noBrowser, env.noBrowser ?? mode === "desktop");
|
||||
const authToken = Option.getOrUndefined(input.authToken) ?? env.authToken;
|
||||
const autoBootstrapProjectFromCwd = Option.match(input.autoBootstrapProjectFromCwd, {
|
||||
// effect/cli boolean flags parse to `false` when absent; in that case
|
||||
// we still want env/mode fallbacks to apply.
|
||||
onSome: (value) => (value ? true : (env.autoBootstrapProjectFromCwd ?? mode === "web")),
|
||||
onNone: () => env.autoBootstrapProjectFromCwd ?? mode === "web",
|
||||
});
|
||||
const logWebSocketEvents = Option.match(input.logWebSocketEvents, {
|
||||
// effect/cli boolean flags parse to `false` when absent; in that case
|
||||
// we still want env/dev fallbacks to apply.
|
||||
onSome: (value) => (value ? true : (env.logWebSocketEvents ?? Boolean(devUrl))),
|
||||
onNone: () => env.logWebSocketEvents ?? Boolean(devUrl),
|
||||
});
|
||||
const autoBootstrapProjectFromCwd = resolveBooleanFlag(
|
||||
input.autoBootstrapProjectFromCwd,
|
||||
env.autoBootstrapProjectFromCwd ?? mode === "web",
|
||||
);
|
||||
const logWebSocketEvents = resolveBooleanFlag(
|
||||
input.logWebSocketEvents,
|
||||
env.logWebSocketEvents ?? Boolean(devUrl),
|
||||
);
|
||||
const staticDir = devUrl ? undefined : yield* cliConfig.resolveStaticDir;
|
||||
const { join } = yield* Path.Path;
|
||||
const keybindingsConfigPath = join(stateDir, "keybindings.json");
|
||||
@@ -177,7 +173,7 @@ const ServerConfigLive = (input: CliInput) =>
|
||||
env.host ??
|
||||
(mode === "desktop" ? "127.0.0.1" : undefined);
|
||||
|
||||
return {
|
||||
const config: ServerConfigShape = {
|
||||
mode,
|
||||
port,
|
||||
cwd: cliConfig.cwd,
|
||||
@@ -191,6 +187,8 @@ const ServerConfigLive = (input: CliInput) =>
|
||||
autoBootstrapProjectFromCwd,
|
||||
logWebSocketEvents,
|
||||
} satisfies ServerConfigShape;
|
||||
|
||||
return config;
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -200,6 +198,7 @@ const LayerLive = (input: CliInput) =>
|
||||
Layer.provideMerge(makeServerProviderLayer()),
|
||||
Layer.provideMerge(ProviderHealthLive),
|
||||
Layer.provideMerge(SqlitePersistence.layerConfig),
|
||||
Layer.provideMerge(ServerLoggerLive),
|
||||
Layer.provideMerge(ServerConfigLive(input)),
|
||||
);
|
||||
|
||||
@@ -234,14 +233,11 @@ const makeServerProgram = (input: CliInput) =>
|
||||
config.host && !isWildcardHost(config.host)
|
||||
? `http://${formatHostForUrl(config.host)}:${config.port}`
|
||||
: localUrl;
|
||||
const { authToken, devUrl, ...safeConfig } = config;
|
||||
yield* Effect.logInfo("T3 Code running", {
|
||||
url: bindUrl,
|
||||
localUrl,
|
||||
bindHost: config.host ?? "default",
|
||||
cwd: config.cwd,
|
||||
mode: config.mode,
|
||||
stateDir: config.stateDir,
|
||||
authEnabled: Boolean(config.authToken),
|
||||
...safeConfig,
|
||||
devUrl: devUrl?.toString(),
|
||||
authEnabled: Boolean(authToken),
|
||||
});
|
||||
|
||||
if (!config.noBrowser) {
|
||||
|
||||
@@ -6,12 +6,10 @@ import { execFileSync } from "node:child_process";
|
||||
import type { ProviderRuntimeEvent, ProviderSession } from "@t3tools/contracts";
|
||||
import {
|
||||
CommandId,
|
||||
DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
EventId,
|
||||
MessageId,
|
||||
ProjectId,
|
||||
ProviderSessionId,
|
||||
ProviderThreadId,
|
||||
ProviderTurnId,
|
||||
ThreadId,
|
||||
TurnId,
|
||||
} from "@t3tools/contracts";
|
||||
@@ -40,28 +38,43 @@ import { checkpointRefForThreadTurn } from "../../checkpointing/Utils.ts";
|
||||
import { ServerConfig } from "../../config.ts";
|
||||
|
||||
const asProjectId = (value: string): ProjectId => ProjectId.makeUnsafe(value);
|
||||
const asSessionId = (value: string): ProviderSessionId => ProviderSessionId.makeUnsafe(value);
|
||||
const asProviderThreadId = (value: string): ProviderThreadId => ProviderThreadId.makeUnsafe(value);
|
||||
const asProviderTurnId = (value: string): ProviderTurnId => ProviderTurnId.makeUnsafe(value);
|
||||
const asTurnId = (value: string): TurnId => TurnId.makeUnsafe(value);
|
||||
|
||||
function createProviderServiceHarness(cwd: string, hasSession = true, sessionCwd = cwd) {
|
||||
type LegacyProviderRuntimeEvent = {
|
||||
readonly type: string;
|
||||
readonly eventId: EventId;
|
||||
readonly provider: "codex" | "claudeCode" | "cursor";
|
||||
readonly createdAt: string;
|
||||
readonly threadId: ThreadId;
|
||||
readonly turnId?: string | undefined;
|
||||
readonly itemId?: string | undefined;
|
||||
readonly requestId?: string | undefined;
|
||||
readonly payload?: unknown | undefined;
|
||||
readonly [key: string]: unknown;
|
||||
};
|
||||
|
||||
function createProviderServiceHarness(
|
||||
cwd: string,
|
||||
hasSession = true,
|
||||
sessionCwd = cwd,
|
||||
providerName: "codex" | "claudeCode" = "codex",
|
||||
) {
|
||||
const now = new Date().toISOString();
|
||||
const runtimeEventPubSub = Effect.runSync(PubSub.unbounded<ProviderRuntimeEvent>());
|
||||
const rollbackConversation = vi.fn(
|
||||
(_input: { readonly sessionId: ProviderSessionId; readonly numTurns: number }) => Effect.void,
|
||||
(_input: { readonly threadId: ThreadId; readonly numTurns: number }) => Effect.void,
|
||||
);
|
||||
|
||||
const unsupported = <A>() =>
|
||||
Effect.die(new Error("Unsupported provider call in test")) as Effect.Effect<A, never>;
|
||||
const listSessions = () =>
|
||||
hasSession
|
||||
? Effect.succeed([
|
||||
? Effect.succeed([
|
||||
{
|
||||
sessionId: asSessionId("sess-1"),
|
||||
provider: "codex",
|
||||
provider: providerName,
|
||||
status: "ready",
|
||||
threadId: asProviderThreadId("provider-thread-1"),
|
||||
runtimeMode: "full-access",
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
cwd: sessionCwd,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
@@ -73,15 +86,17 @@ function createProviderServiceHarness(cwd: string, hasSession = true, sessionCwd
|
||||
sendTurn: () => unsupported(),
|
||||
interruptTurn: () => unsupported(),
|
||||
respondToRequest: () => unsupported(),
|
||||
respondToUserInput: () => unsupported(),
|
||||
stopSession: () => unsupported(),
|
||||
listSessions,
|
||||
getCapabilities: () => Effect.succeed({ sessionModelSwitch: "in-session" }),
|
||||
rollbackConversation,
|
||||
stopAll: () => Effect.void,
|
||||
streamEvents: Stream.fromPubSub(runtimeEventPubSub),
|
||||
};
|
||||
|
||||
const emit = (event: ProviderRuntimeEvent): void => {
|
||||
Effect.runSync(PubSub.publish(runtimeEventPubSub, event));
|
||||
const emit = (event: LegacyProviderRuntimeEvent): void => {
|
||||
Effect.runSync(PubSub.publish(runtimeEventPubSub, event as unknown as ProviderRuntimeEvent));
|
||||
};
|
||||
|
||||
return {
|
||||
@@ -220,6 +235,7 @@ describe("CheckpointReactor", () => {
|
||||
readonly projectWorkspaceRoot?: string;
|
||||
readonly threadWorktreePath?: string | null;
|
||||
readonly providerSessionCwd?: string;
|
||||
readonly providerName?: "codex" | "claudeCode";
|
||||
}) {
|
||||
const cwd = createGitRepository();
|
||||
tempDirs.push(cwd);
|
||||
@@ -227,6 +243,7 @@ describe("CheckpointReactor", () => {
|
||||
cwd,
|
||||
options?.hasSession ?? true,
|
||||
options?.providerSessionCwd ?? cwd,
|
||||
options?.providerName ?? "codex",
|
||||
);
|
||||
const orchestrationLayer = OrchestrationEngineLive.pipe(
|
||||
Layer.provide(OrchestrationProjectionPipelineLive),
|
||||
@@ -271,6 +288,8 @@ describe("CheckpointReactor", () => {
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Thread",
|
||||
model: "gpt-5-codex",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
branch: null,
|
||||
worktreePath: options?.threadWorktreePath ?? cwd,
|
||||
createdAt,
|
||||
@@ -320,10 +339,7 @@ describe("CheckpointReactor", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
status: "ready",
|
||||
providerName: "codex",
|
||||
providerSessionId: asSessionId("sess-1"),
|
||||
providerThreadId: ProviderThreadId.makeUnsafe("provider-thread-1"),
|
||||
approvalPolicy: "on-request",
|
||||
sandboxMode: "workspace-write",
|
||||
runtimeMode: "approval-required",
|
||||
activeTurnId: null,
|
||||
lastError: null,
|
||||
updatedAt: createdAt,
|
||||
@@ -336,10 +352,10 @@ describe("CheckpointReactor", () => {
|
||||
type: "turn.started",
|
||||
eventId: EventId.makeUnsafe("evt-turn-started-1"),
|
||||
provider: "codex",
|
||||
sessionId: asSessionId("sess-1"),
|
||||
|
||||
createdAt: new Date().toISOString(),
|
||||
threadId: ProviderThreadId.makeUnsafe("provider-thread-1"),
|
||||
turnId: asProviderTurnId("turn-1"),
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
turnId: asTurnId("turn-1"),
|
||||
});
|
||||
await waitForGitRefExists(
|
||||
harness.cwd,
|
||||
@@ -351,11 +367,11 @@ describe("CheckpointReactor", () => {
|
||||
type: "turn.completed",
|
||||
eventId: EventId.makeUnsafe("evt-turn-completed-1"),
|
||||
provider: "codex",
|
||||
sessionId: asSessionId("sess-1"),
|
||||
|
||||
createdAt: new Date().toISOString(),
|
||||
threadId: ProviderThreadId.makeUnsafe("provider-thread-1"),
|
||||
turnId: asProviderTurnId("turn-1"),
|
||||
status: "completed",
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
turnId: asTurnId("turn-1"),
|
||||
payload: { state: "completed" },
|
||||
});
|
||||
|
||||
await waitForEvent(harness.engine, (event) => event.type === "thread.turn-diff-completed");
|
||||
@@ -399,10 +415,7 @@ describe("CheckpointReactor", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
status: "running",
|
||||
providerName: "codex",
|
||||
providerSessionId: asSessionId("sess-1"),
|
||||
providerThreadId: ProviderThreadId.makeUnsafe("provider-thread-1"),
|
||||
approvalPolicy: "on-request",
|
||||
sandboxMode: "workspace-write",
|
||||
runtimeMode: "approval-required",
|
||||
activeTurnId: asTurnId("turn-main"),
|
||||
lastError: null,
|
||||
updatedAt: createdAt,
|
||||
@@ -415,10 +428,10 @@ describe("CheckpointReactor", () => {
|
||||
type: "turn.started",
|
||||
eventId: EventId.makeUnsafe("evt-turn-started-main"),
|
||||
provider: "codex",
|
||||
sessionId: asSessionId("sess-1"),
|
||||
|
||||
createdAt: new Date().toISOString(),
|
||||
threadId: ProviderThreadId.makeUnsafe("provider-thread-1"),
|
||||
turnId: asProviderTurnId("turn-main"),
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
turnId: asTurnId("turn-main"),
|
||||
});
|
||||
await waitForGitRefExists(
|
||||
harness.cwd,
|
||||
@@ -431,11 +444,11 @@ describe("CheckpointReactor", () => {
|
||||
type: "turn.completed",
|
||||
eventId: EventId.makeUnsafe("evt-turn-completed-aux"),
|
||||
provider: "codex",
|
||||
sessionId: asSessionId("sess-1"),
|
||||
|
||||
createdAt: new Date().toISOString(),
|
||||
threadId: ProviderThreadId.makeUnsafe("provider-thread-aux"),
|
||||
turnId: asProviderTurnId("turn-aux"),
|
||||
status: "completed",
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
turnId: asTurnId("turn-aux"),
|
||||
payload: { state: "completed" },
|
||||
});
|
||||
|
||||
await Effect.runPromise(Effect.sleep("40 millis"));
|
||||
@@ -449,11 +462,11 @@ describe("CheckpointReactor", () => {
|
||||
type: "turn.completed",
|
||||
eventId: EventId.makeUnsafe("evt-turn-completed-main"),
|
||||
provider: "codex",
|
||||
sessionId: asSessionId("sess-1"),
|
||||
|
||||
createdAt: new Date().toISOString(),
|
||||
threadId: ProviderThreadId.makeUnsafe("provider-thread-1"),
|
||||
turnId: asProviderTurnId("turn-main"),
|
||||
status: "completed",
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
turnId: asTurnId("turn-main"),
|
||||
payload: { state: "completed" },
|
||||
});
|
||||
|
||||
const thread = await waitForThread(
|
||||
@@ -463,6 +476,69 @@ describe("CheckpointReactor", () => {
|
||||
expect(thread.checkpoints[0]?.checkpointTurnCount).toBe(1);
|
||||
});
|
||||
|
||||
it("captures pre-turn and completion checkpoints for claudeCode runtime events", async () => {
|
||||
const harness = await createHarness({
|
||||
seedFilesystemCheckpoints: false,
|
||||
providerName: "claudeCode",
|
||||
});
|
||||
const createdAt = new Date().toISOString();
|
||||
|
||||
await Effect.runPromise(
|
||||
harness.engine.dispatch({
|
||||
type: "thread.session.set",
|
||||
commandId: CommandId.makeUnsafe("cmd-session-set-capture-claude"),
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
session: {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
status: "ready",
|
||||
providerName: "claudeCode",
|
||||
runtimeMode: "approval-required",
|
||||
activeTurnId: null,
|
||||
lastError: null,
|
||||
updatedAt: createdAt,
|
||||
},
|
||||
createdAt,
|
||||
}),
|
||||
);
|
||||
|
||||
harness.provider.emit({
|
||||
type: "turn.started",
|
||||
eventId: EventId.makeUnsafe("evt-turn-started-claude-1"),
|
||||
provider: "claudeCode",
|
||||
|
||||
createdAt: new Date().toISOString(),
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
turnId: asTurnId("turn-claude-1"),
|
||||
});
|
||||
await waitForGitRefExists(
|
||||
harness.cwd,
|
||||
checkpointRefForThreadTurn(ThreadId.makeUnsafe("thread-1"), 0),
|
||||
);
|
||||
|
||||
fs.writeFileSync(path.join(harness.cwd, "README.md"), "v2\n", "utf8");
|
||||
harness.provider.emit({
|
||||
type: "turn.completed",
|
||||
eventId: EventId.makeUnsafe("evt-turn-completed-claude-1"),
|
||||
provider: "claudeCode",
|
||||
|
||||
createdAt: new Date().toISOString(),
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
turnId: asTurnId("turn-claude-1"),
|
||||
payload: { state: "completed" },
|
||||
});
|
||||
|
||||
await waitForEvent(harness.engine, (event) => event.type === "thread.turn-diff-completed");
|
||||
const thread = await waitForThread(
|
||||
harness.engine,
|
||||
(entry) => entry.latestTurn?.turnId === "turn-claude-1" && entry.checkpoints.length === 1,
|
||||
);
|
||||
|
||||
expect(thread.checkpoints[0]?.checkpointTurnCount).toBe(1);
|
||||
expect(
|
||||
gitRefExists(harness.cwd, checkpointRefForThreadTurn(ThreadId.makeUnsafe("thread-1"), 1)),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("appends capture failure activity when turn diff summary cannot be derived", async () => {
|
||||
const harness = await createHarness({ seedFilesystemCheckpoints: false });
|
||||
const createdAt = new Date().toISOString();
|
||||
@@ -476,10 +552,7 @@ describe("CheckpointReactor", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
status: "ready",
|
||||
providerName: "codex",
|
||||
providerSessionId: asSessionId("sess-1"),
|
||||
providerThreadId: ProviderThreadId.makeUnsafe("provider-thread-1"),
|
||||
approvalPolicy: "on-request",
|
||||
sandboxMode: "workspace-write",
|
||||
runtimeMode: "approval-required",
|
||||
activeTurnId: null,
|
||||
lastError: null,
|
||||
updatedAt: createdAt,
|
||||
@@ -492,11 +565,11 @@ describe("CheckpointReactor", () => {
|
||||
type: "turn.completed",
|
||||
eventId: EventId.makeUnsafe("evt-turn-completed-missing-baseline"),
|
||||
provider: "codex",
|
||||
sessionId: asSessionId("sess-1"),
|
||||
|
||||
createdAt: new Date().toISOString(),
|
||||
threadId: ProviderThreadId.makeUnsafe("provider-thread-1"),
|
||||
turnId: asProviderTurnId("turn-missing-baseline"),
|
||||
status: "completed",
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
turnId: asTurnId("turn-missing-baseline"),
|
||||
payload: { state: "completed" },
|
||||
});
|
||||
|
||||
await waitForEvent(harness.engine, (event) => event.type === "thread.turn-diff-completed");
|
||||
@@ -531,8 +604,8 @@ describe("CheckpointReactor", () => {
|
||||
text: "start turn",
|
||||
attachments: [],
|
||||
},
|
||||
approvalPolicy: "on-request",
|
||||
sandboxMode: "workspace-write",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
createdAt: new Date().toISOString(),
|
||||
}),
|
||||
);
|
||||
@@ -567,10 +640,7 @@ describe("CheckpointReactor", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
status: "running",
|
||||
providerName: "codex",
|
||||
providerSessionId: asSessionId("sess-missing"),
|
||||
providerThreadId: ProviderThreadId.makeUnsafe("provider-thread-missing"),
|
||||
approvalPolicy: "on-request",
|
||||
sandboxMode: "workspace-write",
|
||||
runtimeMode: "approval-required",
|
||||
activeTurnId: asTurnId("turn-missing-cwd"),
|
||||
lastError: null,
|
||||
updatedAt: createdAt,
|
||||
@@ -584,11 +654,11 @@ describe("CheckpointReactor", () => {
|
||||
type: "turn.completed",
|
||||
eventId: EventId.makeUnsafe("evt-turn-completed-missing-provider-cwd"),
|
||||
provider: "codex",
|
||||
sessionId: asSessionId("sess-missing"),
|
||||
|
||||
createdAt: new Date().toISOString(),
|
||||
threadId: ProviderThreadId.makeUnsafe("provider-thread-missing"),
|
||||
turnId: asProviderTurnId("turn-missing-cwd"),
|
||||
status: "completed",
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
turnId: asTurnId("turn-missing-cwd"),
|
||||
payload: { state: "completed" },
|
||||
});
|
||||
|
||||
await waitForEvent(harness.engine, (event) => event.type === "thread.turn-diff-completed");
|
||||
@@ -604,7 +674,7 @@ describe("CheckpointReactor", () => {
|
||||
).toBe("v2\n");
|
||||
});
|
||||
|
||||
it("maps runtime checkpoint.captured into thread.turn.diff.complete when missing in read model", async () => {
|
||||
it("ignores non-v2 checkpoint.captured runtime events", async () => {
|
||||
const harness = await createHarness();
|
||||
const createdAt = new Date().toISOString();
|
||||
|
||||
@@ -617,10 +687,7 @@ describe("CheckpointReactor", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
status: "ready",
|
||||
providerName: "codex",
|
||||
providerSessionId: asSessionId("sess-1"),
|
||||
providerThreadId: ProviderThreadId.makeUnsafe("provider-thread-1"),
|
||||
approvalPolicy: "on-request",
|
||||
sandboxMode: "workspace-write",
|
||||
runtimeMode: "approval-required",
|
||||
activeTurnId: null,
|
||||
lastError: null,
|
||||
updatedAt: createdAt,
|
||||
@@ -633,19 +700,19 @@ describe("CheckpointReactor", () => {
|
||||
type: "checkpoint.captured",
|
||||
eventId: EventId.makeUnsafe("evt-checkpoint-captured-3"),
|
||||
provider: "codex",
|
||||
sessionId: asSessionId("sess-1"),
|
||||
|
||||
createdAt: new Date().toISOString(),
|
||||
threadId: ProviderThreadId.makeUnsafe("provider-thread-1"),
|
||||
turnId: asProviderTurnId("turn-3"),
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
turnId: asTurnId("turn-3"),
|
||||
turnCount: 3,
|
||||
status: "completed",
|
||||
});
|
||||
|
||||
const thread = await waitForThread(harness.engine, (entry) =>
|
||||
entry.checkpoints.some((checkpoint) => checkpoint.checkpointTurnCount === 3),
|
||||
);
|
||||
expect(thread.checkpoints.some((checkpoint) => checkpoint.checkpointTurnCount === 3)).toBe(
|
||||
true,
|
||||
await Effect.runPromise(Effect.sleep("40 millis"));
|
||||
const readModel = await Effect.runPromise(harness.engine.getReadModel());
|
||||
const thread = readModel.threads.find((entry) => entry.id === ThreadId.makeUnsafe("thread-1"));
|
||||
expect(thread?.checkpoints.some((checkpoint) => checkpoint.checkpointTurnCount === 3)).toBe(
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -670,10 +737,7 @@ describe("CheckpointReactor", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
status: "ready",
|
||||
providerName: "codex",
|
||||
providerSessionId: asSessionId("sess-1"),
|
||||
providerThreadId: ProviderThreadId.makeUnsafe("provider-thread-1"),
|
||||
approvalPolicy: "on-request",
|
||||
sandboxMode: "workspace-write",
|
||||
runtimeMode: "approval-required",
|
||||
activeTurnId: null,
|
||||
lastError: null,
|
||||
updatedAt: createdAt,
|
||||
@@ -683,25 +747,24 @@ describe("CheckpointReactor", () => {
|
||||
);
|
||||
|
||||
harness.provider.emit({
|
||||
type: "checkpoint.captured",
|
||||
type: "turn.completed",
|
||||
eventId: EventId.makeUnsafe("evt-runtime-capture-failure"),
|
||||
provider: "codex",
|
||||
sessionId: asSessionId("sess-1"),
|
||||
|
||||
createdAt: new Date().toISOString(),
|
||||
threadId: ProviderThreadId.makeUnsafe("provider-thread-1"),
|
||||
turnId: asProviderTurnId("turn-runtime-failure"),
|
||||
turnCount: 1,
|
||||
status: "completed",
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
turnId: asTurnId("turn-runtime-failure"),
|
||||
payload: { state: "completed" },
|
||||
});
|
||||
|
||||
harness.provider.emit({
|
||||
type: "turn.started",
|
||||
eventId: EventId.makeUnsafe("evt-turn-started-after-runtime-failure"),
|
||||
provider: "codex",
|
||||
sessionId: asSessionId("sess-1"),
|
||||
|
||||
createdAt: new Date().toISOString(),
|
||||
threadId: ProviderThreadId.makeUnsafe("provider-thread-1"),
|
||||
turnId: asProviderTurnId("turn-after-runtime-failure"),
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
turnId: asTurnId("turn-after-runtime-failure"),
|
||||
});
|
||||
|
||||
await waitForGitRefExists(
|
||||
@@ -726,10 +789,7 @@ describe("CheckpointReactor", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
status: "ready",
|
||||
providerName: "codex",
|
||||
providerSessionId: asSessionId("sess-1"),
|
||||
providerThreadId: ProviderThreadId.makeUnsafe("provider-thread-1"),
|
||||
approvalPolicy: "on-request",
|
||||
sandboxMode: "workspace-write",
|
||||
runtimeMode: "approval-required",
|
||||
activeTurnId: null,
|
||||
lastError: null,
|
||||
updatedAt: createdAt,
|
||||
@@ -785,7 +845,7 @@ describe("CheckpointReactor", () => {
|
||||
expect(thread.checkpoints[0]?.checkpointTurnCount).toBe(1);
|
||||
expect(harness.provider.rollbackConversation).toHaveBeenCalledTimes(1);
|
||||
expect(harness.provider.rollbackConversation).toHaveBeenCalledWith({
|
||||
sessionId: asSessionId("sess-1"),
|
||||
|
||||
numTurns: 1,
|
||||
});
|
||||
expect(fs.readFileSync(path.join(harness.cwd, "README.md"), "utf8")).toBe("v2\n");
|
||||
@@ -794,6 +854,75 @@ describe("CheckpointReactor", () => {
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("executes provider revert and emits thread.reverted for claudeCode sessions", async () => {
|
||||
const harness = await createHarness({ providerName: "claudeCode" });
|
||||
const createdAt = new Date().toISOString();
|
||||
|
||||
await Effect.runPromise(
|
||||
harness.engine.dispatch({
|
||||
type: "thread.session.set",
|
||||
commandId: CommandId.makeUnsafe("cmd-session-set-claude"),
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
session: {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
status: "ready",
|
||||
providerName: "claudeCode",
|
||||
runtimeMode: "approval-required",
|
||||
activeTurnId: null,
|
||||
lastError: null,
|
||||
updatedAt: createdAt,
|
||||
},
|
||||
createdAt,
|
||||
}),
|
||||
);
|
||||
|
||||
await Effect.runPromise(
|
||||
harness.engine.dispatch({
|
||||
type: "thread.turn.diff.complete",
|
||||
commandId: CommandId.makeUnsafe("cmd-diff-claude-1"),
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
turnId: asTurnId("turn-claude-1"),
|
||||
completedAt: createdAt,
|
||||
checkpointRef: checkpointRefForThreadTurn(ThreadId.makeUnsafe("thread-1"), 1),
|
||||
status: "ready",
|
||||
files: [],
|
||||
checkpointTurnCount: 1,
|
||||
createdAt,
|
||||
}),
|
||||
);
|
||||
await Effect.runPromise(
|
||||
harness.engine.dispatch({
|
||||
type: "thread.turn.diff.complete",
|
||||
commandId: CommandId.makeUnsafe("cmd-diff-claude-2"),
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
turnId: asTurnId("turn-claude-2"),
|
||||
completedAt: createdAt,
|
||||
checkpointRef: checkpointRefForThreadTurn(ThreadId.makeUnsafe("thread-1"), 2),
|
||||
status: "ready",
|
||||
files: [],
|
||||
checkpointTurnCount: 2,
|
||||
createdAt,
|
||||
}),
|
||||
);
|
||||
|
||||
await Effect.runPromise(
|
||||
harness.engine.dispatch({
|
||||
type: "thread.checkpoint.revert",
|
||||
commandId: CommandId.makeUnsafe("cmd-revert-request-claude"),
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
turnCount: 1,
|
||||
createdAt,
|
||||
}),
|
||||
);
|
||||
|
||||
await waitForEvent(harness.engine, (event) => event.type === "thread.reverted");
|
||||
expect(harness.provider.rollbackConversation).toHaveBeenCalledTimes(1);
|
||||
expect(harness.provider.rollbackConversation).toHaveBeenCalledWith({
|
||||
|
||||
numTurns: 1,
|
||||
});
|
||||
});
|
||||
|
||||
it("processes consecutive revert requests with deterministic rollback sequencing", async () => {
|
||||
const harness = await createHarness();
|
||||
const createdAt = new Date().toISOString();
|
||||
@@ -807,10 +936,7 @@ describe("CheckpointReactor", () => {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
status: "ready",
|
||||
providerName: "codex",
|
||||
providerSessionId: asSessionId("sess-1"),
|
||||
providerThreadId: ProviderThreadId.makeUnsafe("provider-thread-1"),
|
||||
approvalPolicy: "on-request",
|
||||
sandboxMode: "workspace-write",
|
||||
runtimeMode: "approval-required",
|
||||
activeTurnId: null,
|
||||
lastError: null,
|
||||
updatedAt: createdAt,
|
||||
@@ -882,11 +1008,11 @@ describe("CheckpointReactor", () => {
|
||||
|
||||
expect(harness.provider.rollbackConversation).toHaveBeenCalledTimes(2);
|
||||
expect(harness.provider.rollbackConversation.mock.calls[0]?.[0]).toEqual({
|
||||
sessionId: asSessionId("sess-1"),
|
||||
|
||||
numTurns: 1,
|
||||
});
|
||||
expect(harness.provider.rollbackConversation.mock.calls[1]?.[0]).toEqual({
|
||||
sessionId: asSessionId("sess-1"),
|
||||
|
||||
numTurns: 1,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,8 +2,6 @@ import {
|
||||
CommandId,
|
||||
EventId,
|
||||
MessageId,
|
||||
ProviderSessionId,
|
||||
ProviderThreadId,
|
||||
ThreadId,
|
||||
TurnId,
|
||||
type OrchestrationEvent,
|
||||
@@ -34,11 +32,7 @@ type ReactorInput =
|
||||
};
|
||||
|
||||
function toTurnId(value: string | undefined): TurnId | null {
|
||||
return value === undefined ? null : TurnId.makeUnsafe(value);
|
||||
}
|
||||
|
||||
function toProviderThreadId(value: string | undefined): ProviderThreadId | null {
|
||||
return value === undefined ? null : ProviderThreadId.makeUnsafe(value);
|
||||
return value === undefined ? null : TurnId.makeUnsafe(String(value));
|
||||
}
|
||||
|
||||
function sameId(left: string | null | undefined, right: string | null | undefined): boolean {
|
||||
@@ -95,77 +89,58 @@ const make = Effect.gen(function* () {
|
||||
});
|
||||
|
||||
const appendCaptureFailureActivity = (input: {
|
||||
readonly sessionId: ProviderSessionId;
|
||||
readonly threadId: ThreadId;
|
||||
readonly turnId: TurnId | null;
|
||||
readonly detail: string;
|
||||
readonly createdAt: string;
|
||||
}) =>
|
||||
Effect.gen(function* () {
|
||||
const readModel = yield* orchestrationEngine.getReadModel();
|
||||
const thread = readModel.threads.find(
|
||||
(entry) => entry.session?.providerSessionId === input.sessionId,
|
||||
);
|
||||
if (!thread) {
|
||||
return;
|
||||
}
|
||||
yield* orchestrationEngine.dispatch({
|
||||
type: "thread.activity.append",
|
||||
commandId: serverCommandId("checkpoint-capture-failure"),
|
||||
threadId: thread.id,
|
||||
activity: {
|
||||
id: EventId.makeUnsafe(crypto.randomUUID()),
|
||||
tone: "error",
|
||||
kind: "checkpoint.capture.failed",
|
||||
summary: "Checkpoint capture failed",
|
||||
payload: {
|
||||
detail: input.detail,
|
||||
},
|
||||
turnId: input.turnId,
|
||||
createdAt: input.createdAt,
|
||||
orchestrationEngine.dispatch({
|
||||
type: "thread.activity.append",
|
||||
commandId: serverCommandId("checkpoint-capture-failure"),
|
||||
threadId: input.threadId,
|
||||
activity: {
|
||||
id: EventId.makeUnsafe(crypto.randomUUID()),
|
||||
tone: "error",
|
||||
kind: "checkpoint.capture.failed",
|
||||
summary: "Checkpoint capture failed",
|
||||
payload: {
|
||||
detail: input.detail,
|
||||
},
|
||||
turnId: input.turnId,
|
||||
createdAt: input.createdAt,
|
||||
});
|
||||
},
|
||||
createdAt: input.createdAt,
|
||||
});
|
||||
|
||||
const resolveSessionRuntimeForThread = Effect.fnUntraced(function* (
|
||||
threadId: ThreadId,
|
||||
): Effect.fn.Return<
|
||||
Option.Option<{ readonly sessionId: ProviderSessionId; readonly cwd: string }>
|
||||
Option.Option<{ readonly threadId: ThreadId; readonly cwd: string }>
|
||||
> {
|
||||
const readModel = yield* orchestrationEngine.getReadModel();
|
||||
const thread = readModel.threads.find((entry) => entry.id === threadId);
|
||||
const projectedSessionId = thread?.session?.providerSessionId ?? null;
|
||||
const projectedProviderThreadId = thread?.session?.providerThreadId ?? undefined;
|
||||
|
||||
const sessions = yield* providerService.listSessions();
|
||||
|
||||
const findSessionWithCwd = (
|
||||
session: (typeof sessions)[number] | undefined,
|
||||
): Option.Option<{ readonly sessionId: ProviderSessionId; readonly cwd: string }> => {
|
||||
): Option.Option<{ readonly threadId: ThreadId; readonly cwd: string }> => {
|
||||
if (!session?.cwd) {
|
||||
return Option.none();
|
||||
}
|
||||
return Option.some({ sessionId: session.sessionId, cwd: session.cwd });
|
||||
return Option.some({ threadId: session.threadId, cwd: session.cwd });
|
||||
};
|
||||
|
||||
if (projectedSessionId !== null) {
|
||||
const projectedSession = sessions.find((session) => session.sessionId === projectedSessionId);
|
||||
if (thread) {
|
||||
const projectedSession = sessions.find(
|
||||
(session) => session.threadId === thread.id,
|
||||
);
|
||||
const fromProjected = findSessionWithCwd(projectedSession);
|
||||
if (Option.isSome(fromProjected)) {
|
||||
return fromProjected;
|
||||
}
|
||||
}
|
||||
|
||||
if (projectedProviderThreadId) {
|
||||
const matchedSession = sessions.find(
|
||||
(session) => session.threadId === projectedProviderThreadId,
|
||||
);
|
||||
const fromProviderThread = findSessionWithCwd(matchedSession);
|
||||
if (Option.isSome(fromProviderThread)) {
|
||||
return fromProviderThread;
|
||||
}
|
||||
}
|
||||
|
||||
return Option.none();
|
||||
});
|
||||
|
||||
@@ -178,23 +153,11 @@ const make = Effect.gen(function* () {
|
||||
}
|
||||
|
||||
const readModel = yield* orchestrationEngine.getReadModel();
|
||||
const thread = readModel.threads.find(
|
||||
(entry) => entry.session?.providerSessionId === event.sessionId,
|
||||
);
|
||||
const thread = readModel.threads.find((entry) => entry.id === event.threadId);
|
||||
if (!thread) {
|
||||
return;
|
||||
}
|
||||
|
||||
const projectedProviderThreadId = thread.session?.providerThreadId ?? null;
|
||||
const eventProviderThreadId = toProviderThreadId(event.threadId);
|
||||
if (
|
||||
projectedProviderThreadId !== null &&
|
||||
eventProviderThreadId !== null &&
|
||||
!sameId(projectedProviderThreadId, eventProviderThreadId)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
// When a primary turn is active, only that turn may produce completion checkpoints.
|
||||
if (thread.session?.activeTurnId && !sameId(thread.session.activeTurnId, turnId)) {
|
||||
return;
|
||||
@@ -266,7 +229,7 @@ const make = Effect.gen(function* () {
|
||||
),
|
||||
Effect.tapError((error) =>
|
||||
appendCaptureFailureActivity({
|
||||
sessionId: event.sessionId,
|
||||
threadId: thread.id,
|
||||
turnId,
|
||||
detail: `Checkpoint captured, but turn diff summary is unavailable: ${error.message}`,
|
||||
createdAt: event.createdAt,
|
||||
@@ -296,7 +259,7 @@ const make = Effect.gen(function* () {
|
||||
turnId,
|
||||
completedAt: now,
|
||||
checkpointRef: targetCheckpointRef,
|
||||
status: checkpointStatusFromRuntime(event.status),
|
||||
status: checkpointStatusFromRuntime(event.payload.state),
|
||||
files,
|
||||
assistantMessageId,
|
||||
checkpointTurnCount: nextTurnCount,
|
||||
@@ -314,7 +277,7 @@ const make = Effect.gen(function* () {
|
||||
summary: "Checkpoint captured",
|
||||
payload: {
|
||||
turnCount: nextTurnCount,
|
||||
...(event.status !== undefined ? { status: event.status } : {}),
|
||||
status: event.payload.state,
|
||||
},
|
||||
turnId,
|
||||
createdAt: now,
|
||||
@@ -333,7 +296,7 @@ const make = Effect.gen(function* () {
|
||||
|
||||
const readModel = yield* orchestrationEngine.getReadModel();
|
||||
const thread = readModel.threads.find(
|
||||
(entry) => entry.session?.providerSessionId === event.sessionId,
|
||||
(entry) => entry.id === event.threadId,
|
||||
);
|
||||
if (!thread) {
|
||||
return;
|
||||
@@ -513,7 +476,7 @@ const make = Effect.gen(function* () {
|
||||
const rolledBackTurns = Math.max(0, currentTurnCount - event.payload.turnCount);
|
||||
if (rolledBackTurns > 0) {
|
||||
yield* providerService.rollbackConversation({
|
||||
sessionId: sessionRuntime.value.sessionId,
|
||||
threadId: sessionRuntime.value.threadId,
|
||||
numTurns: rolledBackTurns,
|
||||
});
|
||||
}
|
||||
@@ -581,7 +544,7 @@ const make = Effect.gen(function* () {
|
||||
yield* captureCheckpointFromTurnCompletion(event).pipe(
|
||||
Effect.catch((error) =>
|
||||
appendCaptureFailureActivity({
|
||||
sessionId: event.sessionId,
|
||||
threadId: event.threadId,
|
||||
turnId,
|
||||
detail: error.message,
|
||||
createdAt: new Date().toISOString(),
|
||||
@@ -590,89 +553,6 @@ const make = Effect.gen(function* () {
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.type === "checkpoint.captured") {
|
||||
const turnId = toTurnId(event.turnId);
|
||||
if (!turnId) {
|
||||
return;
|
||||
}
|
||||
|
||||
const readModel = yield* orchestrationEngine.getReadModel();
|
||||
const thread = readModel.threads.find(
|
||||
(entry) => entry.session?.providerSessionId === event.sessionId,
|
||||
);
|
||||
if (!thread) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
thread.checkpoints.some(
|
||||
(checkpoint) =>
|
||||
checkpoint.turnId === turnId || checkpoint.checkpointTurnCount === event.turnCount,
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const sessionRuntime = yield* resolveSessionRuntimeForThread(thread.id);
|
||||
if (Option.isNone(sessionRuntime)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const fromTurnCount = Math.max(0, event.turnCount - 1);
|
||||
const fromCheckpointRef = checkpointRefForThreadTurn(thread.id, fromTurnCount);
|
||||
const targetCheckpointRef = checkpointRefForThreadTurn(thread.id, event.turnCount);
|
||||
|
||||
const targetExists = yield* checkpointStore.hasCheckpointRef({
|
||||
cwd: sessionRuntime.value.cwd,
|
||||
checkpointRef: targetCheckpointRef,
|
||||
});
|
||||
if (!targetExists) {
|
||||
yield* checkpointStore.captureCheckpoint({
|
||||
cwd: sessionRuntime.value.cwd,
|
||||
checkpointRef: targetCheckpointRef,
|
||||
});
|
||||
}
|
||||
|
||||
const files = yield* checkpointStore
|
||||
.diffCheckpoints({
|
||||
cwd: sessionRuntime.value.cwd,
|
||||
fromCheckpointRef,
|
||||
toCheckpointRef: targetCheckpointRef,
|
||||
fallbackFromToHead: false,
|
||||
})
|
||||
.pipe(
|
||||
Effect.map((diff) =>
|
||||
parseTurnDiffFilesFromUnifiedDiff(diff).map((file) => ({
|
||||
path: file.path,
|
||||
kind: "modified" as const,
|
||||
additions: file.additions,
|
||||
deletions: file.deletions,
|
||||
})),
|
||||
),
|
||||
Effect.catch(() => Effect.succeed([])),
|
||||
);
|
||||
|
||||
const assistantMessageId =
|
||||
thread.messages
|
||||
.toReversed()
|
||||
.find((entry) => entry.role === "assistant" && entry.turnId === turnId)?.id ??
|
||||
MessageId.makeUnsafe(`assistant:${turnId}`);
|
||||
|
||||
yield* orchestrationEngine.dispatch({
|
||||
type: "thread.turn.diff.complete",
|
||||
commandId: serverCommandId("checkpoint-runtime-captured-diff-complete"),
|
||||
threadId: thread.id,
|
||||
turnId,
|
||||
completedAt: event.createdAt,
|
||||
checkpointRef: targetCheckpointRef,
|
||||
status: checkpointStatusFromRuntime(event.status),
|
||||
files,
|
||||
assistantMessageId,
|
||||
checkpointTurnCount: event.turnCount,
|
||||
createdAt: event.createdAt,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
const processInput = (
|
||||
@@ -717,11 +597,7 @@ const make = Effect.gen(function* () {
|
||||
|
||||
yield* Effect.forkScoped(
|
||||
Stream.runForEach(providerService.streamEvents, (event) => {
|
||||
if (
|
||||
event.type !== "turn.started" &&
|
||||
event.type !== "turn.completed" &&
|
||||
event.type !== "checkpoint.captured"
|
||||
) {
|
||||
if (event.type !== "turn.started" && event.type !== "turn.completed") {
|
||||
return Effect.void;
|
||||
}
|
||||
return Queue.offer(queue, { source: "runtime", event }).pipe(Effect.asVoid);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
CheckpointRef,
|
||||
CommandId,
|
||||
DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
MessageId,
|
||||
ProjectId,
|
||||
ThreadId,
|
||||
@@ -80,6 +81,8 @@ describe("OrchestrationEngine", () => {
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Thread",
|
||||
model: "gpt-5-codex",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt,
|
||||
@@ -96,8 +99,8 @@ describe("OrchestrationEngine", () => {
|
||||
text: "hello",
|
||||
attachments: [],
|
||||
},
|
||||
approvalPolicy: "on-request",
|
||||
sandboxMode: "workspace-write",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
createdAt,
|
||||
}),
|
||||
);
|
||||
@@ -132,6 +135,8 @@ describe("OrchestrationEngine", () => {
|
||||
projectId: asProjectId("project-replay"),
|
||||
title: "replay",
|
||||
model: "gpt-5-codex",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt,
|
||||
@@ -192,6 +197,8 @@ describe("OrchestrationEngine", () => {
|
||||
projectId: asProjectId("project-stream"),
|
||||
title: "domain-stream",
|
||||
model: "gpt-5-codex",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt,
|
||||
@@ -235,6 +242,8 @@ describe("OrchestrationEngine", () => {
|
||||
projectId: asProjectId("project-turn-diff"),
|
||||
title: "Turn diff thread",
|
||||
model: "gpt-5-codex",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt,
|
||||
@@ -342,6 +351,8 @@ describe("OrchestrationEngine", () => {
|
||||
projectId: asProjectId("project-flaky"),
|
||||
title: "flaky-fail",
|
||||
model: "gpt-5-codex",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt,
|
||||
@@ -357,6 +368,8 @@ describe("OrchestrationEngine", () => {
|
||||
projectId: asProjectId("project-flaky"),
|
||||
title: "flaky-ok",
|
||||
model: "gpt-5-codex",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt,
|
||||
@@ -420,6 +433,8 @@ describe("OrchestrationEngine", () => {
|
||||
projectId: asProjectId("project-atomic"),
|
||||
title: "atomic",
|
||||
model: "gpt-5-codex",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt,
|
||||
@@ -436,8 +451,8 @@ describe("OrchestrationEngine", () => {
|
||||
text: "hello",
|
||||
attachments: [],
|
||||
},
|
||||
approvalPolicy: "on-request" as const,
|
||||
sandboxMode: "workspace-write" as const,
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required" as const,
|
||||
createdAt,
|
||||
};
|
||||
|
||||
@@ -553,6 +568,8 @@ describe("OrchestrationEngine", () => {
|
||||
projectId: asProjectId("project-sync"),
|
||||
title: "sync-before",
|
||||
model: "gpt-5-codex",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt,
|
||||
@@ -596,8 +613,8 @@ describe("OrchestrationEngine", () => {
|
||||
text: "hello",
|
||||
attachments: [],
|
||||
},
|
||||
approvalPolicy: "on-request",
|
||||
sandboxMode: "workspace-write",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
createdAt: now(),
|
||||
}),
|
||||
),
|
||||
@@ -631,6 +648,8 @@ describe("OrchestrationEngine", () => {
|
||||
projectId: asProjectId("project-duplicate"),
|
||||
title: "duplicate",
|
||||
model: "gpt-5-codex",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt,
|
||||
@@ -646,6 +665,8 @@ describe("OrchestrationEngine", () => {
|
||||
projectId: asProjectId("project-duplicate"),
|
||||
title: "duplicate",
|
||||
model: "gpt-5-codex",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt,
|
||||
|
||||
@@ -4,8 +4,6 @@ import {
|
||||
CorrelationId,
|
||||
EventId,
|
||||
MessageId,
|
||||
ProviderSessionId,
|
||||
ProviderThreadId,
|
||||
ProjectId,
|
||||
ThreadId,
|
||||
TurnId,
|
||||
@@ -104,6 +102,7 @@ projectionLayer("OrchestrationProjectionPipeline", (it) => {
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Thread 1",
|
||||
model: "gpt-5-codex",
|
||||
runtimeMode: "full-access",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt: now,
|
||||
@@ -374,6 +373,7 @@ projectionLayer("OrchestrationProjectionPipeline", (it) => {
|
||||
projectId: ProjectId.makeUnsafe("project-clear-attachments"),
|
||||
title: "Thread Clear Attachments",
|
||||
model: "gpt-5-codex",
|
||||
runtimeMode: "full-access",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt: now,
|
||||
@@ -500,6 +500,7 @@ projectionLayer("OrchestrationProjectionPipeline", (it) => {
|
||||
projectId: ProjectId.makeUnsafe("project-overwrite"),
|
||||
title: "Thread Overwrite",
|
||||
model: "gpt-5-codex",
|
||||
runtimeMode: "full-access",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt: now,
|
||||
@@ -650,6 +651,7 @@ projectionLayer("OrchestrationProjectionPipeline", (it) => {
|
||||
projectId: ProjectId.makeUnsafe("project-rollback"),
|
||||
title: "Thread Rollback",
|
||||
model: "gpt-5-codex",
|
||||
runtimeMode: "full-access",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt: now,
|
||||
@@ -780,6 +782,7 @@ projectionLayer("OrchestrationProjectionPipeline", (it) => {
|
||||
projectId: ProjectId.makeUnsafe("project-revert-files"),
|
||||
title: "Thread Revert Files",
|
||||
model: "gpt-5-codex",
|
||||
runtimeMode: "full-access",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt: now,
|
||||
@@ -994,6 +997,7 @@ projectionLayer("OrchestrationProjectionPipeline", (it) => {
|
||||
projectId: ProjectId.makeUnsafe("project-delete-files"),
|
||||
title: "Thread Delete Files",
|
||||
model: "gpt-5-codex",
|
||||
runtimeMode: "full-access",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt: now,
|
||||
@@ -1156,6 +1160,7 @@ projectionLayer("OrchestrationProjectionPipeline", (it) => {
|
||||
projectId: ProjectId.makeUnsafe("project-a"),
|
||||
title: "Thread A",
|
||||
model: "gpt-5-codex",
|
||||
runtimeMode: "full-access",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt: now,
|
||||
@@ -1279,6 +1284,7 @@ projectionLayer("OrchestrationProjectionPipeline", (it) => {
|
||||
projectId: ProjectId.makeUnsafe("project-empty"),
|
||||
title: "Thread Empty",
|
||||
model: "gpt-5-codex",
|
||||
runtimeMode: "full-access",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt: now,
|
||||
@@ -1415,6 +1421,7 @@ projectionLayer("OrchestrationProjectionPipeline", (it) => {
|
||||
projectId: ProjectId.makeUnsafe("project-conflict"),
|
||||
title: "Thread Conflict",
|
||||
model: "gpt-5-codex",
|
||||
runtimeMode: "full-access",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt: "2026-02-26T13:00:01.000Z",
|
||||
@@ -1555,6 +1562,7 @@ projectionLayer("OrchestrationProjectionPipeline", (it) => {
|
||||
projectId: ProjectId.makeUnsafe("project-revert"),
|
||||
title: "Thread Revert",
|
||||
model: "gpt-5-codex",
|
||||
runtimeMode: "full-access",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt: "2026-02-26T12:00:01.000Z",
|
||||
@@ -1749,8 +1757,7 @@ it.effect("restores pending turn-start metadata across projection pipeline resta
|
||||
payload: {
|
||||
threadId,
|
||||
messageId,
|
||||
approvalPolicy: "on-request",
|
||||
sandboxMode: "workspace-write",
|
||||
runtimeMode: "approval-required",
|
||||
createdAt: turnStartedAt,
|
||||
},
|
||||
});
|
||||
@@ -1772,20 +1779,14 @@ it.effect("restores pending turn-start metadata across projection pipeline resta
|
||||
commandId: CommandId.makeUnsafe("cmd-restart-2"),
|
||||
causationEventId: null,
|
||||
correlationId: CorrelationId.makeUnsafe("cmd-restart-2"),
|
||||
metadata: {
|
||||
providerSessionId: ProviderSessionId.makeUnsafe("provider-session-restart"),
|
||||
providerThreadId: ProviderThreadId.makeUnsafe("provider-thread-restart"),
|
||||
},
|
||||
metadata: {},
|
||||
payload: {
|
||||
threadId,
|
||||
session: {
|
||||
threadId,
|
||||
status: "running",
|
||||
providerName: "codex",
|
||||
providerSessionId: ProviderSessionId.makeUnsafe("provider-session-restart"),
|
||||
providerThreadId: ProviderThreadId.makeUnsafe("provider-thread-restart"),
|
||||
approvalPolicy: "on-request",
|
||||
sandboxMode: "workspace-write",
|
||||
runtimeMode: "approval-required",
|
||||
activeTurnId: turnId,
|
||||
lastError: null,
|
||||
updatedAt: sessionSetAt,
|
||||
|
||||
@@ -18,6 +18,10 @@ import {
|
||||
type ProjectionThreadMessage,
|
||||
ProjectionThreadMessageRepository,
|
||||
} from "../../persistence/Services/ProjectionThreadMessages.ts";
|
||||
import {
|
||||
type ProjectionThreadProposedPlan,
|
||||
ProjectionThreadProposedPlanRepository,
|
||||
} from "../../persistence/Services/ProjectionThreadProposedPlans.ts";
|
||||
import { ProjectionThreadSessionRepository } from "../../persistence/Services/ProjectionThreadSessions.ts";
|
||||
import {
|
||||
type ProjectionTurn,
|
||||
@@ -29,6 +33,7 @@ import { ProjectionProjectRepositoryLive } from "../../persistence/Layers/Projec
|
||||
import { ProjectionStateRepositoryLive } from "../../persistence/Layers/ProjectionState.ts";
|
||||
import { ProjectionThreadActivityRepositoryLive } from "../../persistence/Layers/ProjectionThreadActivities.ts";
|
||||
import { ProjectionThreadMessageRepositoryLive } from "../../persistence/Layers/ProjectionThreadMessages.ts";
|
||||
import { ProjectionThreadProposedPlanRepositoryLive } from "../../persistence/Layers/ProjectionThreadProposedPlans.ts";
|
||||
import { ProjectionThreadSessionRepositoryLive } from "../../persistence/Layers/ProjectionThreadSessions.ts";
|
||||
import { ProjectionTurnRepositoryLive } from "../../persistence/Layers/ProjectionTurns.ts";
|
||||
import { ProjectionThreadRepositoryLive } from "../../persistence/Layers/ProjectionThreads.ts";
|
||||
@@ -48,6 +53,7 @@ export const ORCHESTRATION_PROJECTOR_NAMES = {
|
||||
projects: "projection.projects",
|
||||
threads: "projection.threads",
|
||||
threadMessages: "projection.thread-messages",
|
||||
threadProposedPlans: "projection.thread-proposed-plans",
|
||||
threadActivities: "projection.thread-activities",
|
||||
threadSessions: "projection.thread-sessions",
|
||||
threadTurns: "projection.thread-turns",
|
||||
@@ -189,6 +195,26 @@ function retainProjectionActivitiesAfterRevert(
|
||||
);
|
||||
}
|
||||
|
||||
function retainProjectionProposedPlansAfterRevert(
|
||||
proposedPlans: ReadonlyArray<ProjectionThreadProposedPlan>,
|
||||
turns: ReadonlyArray<ProjectionTurn>,
|
||||
turnCount: number,
|
||||
): ReadonlyArray<ProjectionThreadProposedPlan> {
|
||||
const retainedTurnIds = new Set<string>(
|
||||
turns
|
||||
.filter(
|
||||
(turn) =>
|
||||
turn.turnId !== null &&
|
||||
turn.checkpointTurnCount !== null &&
|
||||
turn.checkpointTurnCount <= turnCount,
|
||||
)
|
||||
.flatMap((turn) => (turn.turnId === null ? [] : [turn.turnId])),
|
||||
);
|
||||
return proposedPlans.filter(
|
||||
(proposedPlan) => proposedPlan.turnId === null || retainedTurnIds.has(proposedPlan.turnId),
|
||||
);
|
||||
}
|
||||
|
||||
function collectThreadAttachmentRelativePaths(
|
||||
threadId: string,
|
||||
messages: ReadonlyArray<ProjectionThreadMessage>,
|
||||
@@ -320,6 +346,7 @@ const makeOrchestrationProjectionPipeline = Effect.gen(function* () {
|
||||
const projectionProjectRepository = yield* ProjectionProjectRepository;
|
||||
const projectionThreadRepository = yield* ProjectionThreadRepository;
|
||||
const projectionThreadMessageRepository = yield* ProjectionThreadMessageRepository;
|
||||
const projectionThreadProposedPlanRepository = yield* ProjectionThreadProposedPlanRepository;
|
||||
const projectionThreadActivityRepository = yield* ProjectionThreadActivityRepository;
|
||||
const projectionThreadSessionRepository = yield* ProjectionThreadSessionRepository;
|
||||
const projectionTurnRepository = yield* ProjectionTurnRepository;
|
||||
@@ -396,6 +423,8 @@ const makeOrchestrationProjectionPipeline = Effect.gen(function* () {
|
||||
projectId: event.payload.projectId,
|
||||
title: event.payload.title,
|
||||
model: event.payload.model,
|
||||
runtimeMode: event.payload.runtimeMode,
|
||||
interactionMode: event.payload.interactionMode,
|
||||
branch: event.payload.branch,
|
||||
worktreePath: event.payload.worktreePath,
|
||||
latestTurnId: null,
|
||||
@@ -425,6 +454,36 @@ const makeOrchestrationProjectionPipeline = Effect.gen(function* () {
|
||||
return;
|
||||
}
|
||||
|
||||
case "thread.runtime-mode-set": {
|
||||
const existingRow = yield* projectionThreadRepository.getById({
|
||||
threadId: event.payload.threadId,
|
||||
});
|
||||
if (Option.isNone(existingRow)) {
|
||||
return;
|
||||
}
|
||||
yield* projectionThreadRepository.upsert({
|
||||
...existingRow.value,
|
||||
runtimeMode: event.payload.runtimeMode,
|
||||
updatedAt: event.payload.updatedAt,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
case "thread.interaction-mode-set": {
|
||||
const existingRow = yield* projectionThreadRepository.getById({
|
||||
threadId: event.payload.threadId,
|
||||
});
|
||||
if (Option.isNone(existingRow)) {
|
||||
return;
|
||||
}
|
||||
yield* projectionThreadRepository.upsert({
|
||||
...existingRow.value,
|
||||
interactionMode: event.payload.interactionMode,
|
||||
updatedAt: event.payload.updatedAt,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
case "thread.deleted": {
|
||||
attachmentSideEffects.deletedThreadIds.add(event.payload.threadId);
|
||||
const existingRow = yield* projectionThreadRepository.getById({
|
||||
@@ -442,6 +501,7 @@ const makeOrchestrationProjectionPipeline = Effect.gen(function* () {
|
||||
}
|
||||
|
||||
case "thread.message-sent":
|
||||
case "thread.proposed-plan-upserted":
|
||||
case "thread.activity-appended": {
|
||||
const existingRow = yield* projectionThreadRepository.getById({
|
||||
threadId: event.payload.threadId,
|
||||
@@ -583,6 +643,57 @@ const makeOrchestrationProjectionPipeline = Effect.gen(function* () {
|
||||
}
|
||||
});
|
||||
|
||||
const applyThreadProposedPlansProjection: ProjectorDefinition["apply"] = (
|
||||
event,
|
||||
_attachmentSideEffects,
|
||||
) =>
|
||||
Effect.gen(function* () {
|
||||
switch (event.type) {
|
||||
case "thread.proposed-plan-upserted":
|
||||
yield* projectionThreadProposedPlanRepository.upsert({
|
||||
planId: event.payload.proposedPlan.id,
|
||||
threadId: event.payload.threadId,
|
||||
turnId: event.payload.proposedPlan.turnId,
|
||||
planMarkdown: event.payload.proposedPlan.planMarkdown,
|
||||
createdAt: event.payload.proposedPlan.createdAt,
|
||||
updatedAt: event.payload.proposedPlan.updatedAt,
|
||||
});
|
||||
return;
|
||||
|
||||
case "thread.reverted": {
|
||||
const existingRows = yield* projectionThreadProposedPlanRepository.listByThreadId({
|
||||
threadId: event.payload.threadId,
|
||||
});
|
||||
if (existingRows.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const existingTurns = yield* projectionTurnRepository.listByThreadId({
|
||||
threadId: event.payload.threadId,
|
||||
});
|
||||
const keptRows = retainProjectionProposedPlansAfterRevert(
|
||||
existingRows,
|
||||
existingTurns,
|
||||
event.payload.turnCount,
|
||||
);
|
||||
if (keptRows.length === existingRows.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
yield* projectionThreadProposedPlanRepository.deleteByThreadId({
|
||||
threadId: event.payload.threadId,
|
||||
});
|
||||
yield* Effect.forEach(keptRows, projectionThreadProposedPlanRepository.upsert, {
|
||||
concurrency: 1,
|
||||
}).pipe(Effect.asVoid);
|
||||
return;
|
||||
}
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
const applyThreadActivitiesProjection: ProjectorDefinition["apply"] = (
|
||||
event,
|
||||
_attachmentSideEffects,
|
||||
@@ -598,6 +709,9 @@ const makeOrchestrationProjectionPipeline = Effect.gen(function* () {
|
||||
kind: event.payload.activity.kind,
|
||||
summary: event.payload.activity.summary,
|
||||
payload: event.payload.activity.payload,
|
||||
...(event.payload.activity.sequence !== undefined
|
||||
? { sequence: event.payload.activity.sequence }
|
||||
: {}),
|
||||
createdAt: event.payload.activity.createdAt,
|
||||
});
|
||||
return;
|
||||
@@ -646,10 +760,7 @@ const makeOrchestrationProjectionPipeline = Effect.gen(function* () {
|
||||
threadId: event.payload.threadId,
|
||||
status: event.payload.session.status,
|
||||
providerName: event.payload.session.providerName,
|
||||
providerSessionId: event.payload.session.providerSessionId,
|
||||
providerThreadId: event.payload.session.providerThreadId,
|
||||
approvalPolicy: event.payload.session.approvalPolicy,
|
||||
sandboxMode: event.payload.session.sandboxMode,
|
||||
runtimeMode: event.payload.session.runtimeMode,
|
||||
activeTurnId: event.payload.session.activeTurnId,
|
||||
lastError: event.payload.session.lastError,
|
||||
updatedAt: event.payload.session.updatedAt,
|
||||
@@ -991,6 +1102,10 @@ const makeOrchestrationProjectionPipeline = Effect.gen(function* () {
|
||||
name: ORCHESTRATION_PROJECTOR_NAMES.threadMessages,
|
||||
apply: applyThreadMessagesProjection,
|
||||
},
|
||||
{
|
||||
name: ORCHESTRATION_PROJECTOR_NAMES.threadProposedPlans,
|
||||
apply: applyThreadProposedPlansProjection,
|
||||
},
|
||||
{
|
||||
name: ORCHESTRATION_PROJECTOR_NAMES.threadActivities,
|
||||
apply: applyThreadActivitiesProjection,
|
||||
@@ -1110,6 +1225,7 @@ export const OrchestrationProjectionPipelineLive = Layer.effect(
|
||||
Layer.provideMerge(ProjectionProjectRepositoryLive),
|
||||
Layer.provideMerge(ProjectionThreadRepositoryLive),
|
||||
Layer.provideMerge(ProjectionThreadMessageRepositoryLive),
|
||||
Layer.provideMerge(ProjectionThreadProposedPlanRepositoryLive),
|
||||
Layer.provideMerge(ProjectionThreadActivityRepositoryLive),
|
||||
Layer.provideMerge(ProjectionThreadSessionRepositoryLive),
|
||||
Layer.provideMerge(ProjectionTurnRepositoryLive),
|
||||
|
||||
@@ -3,8 +3,6 @@ import {
|
||||
EventId,
|
||||
MessageId,
|
||||
ProjectId,
|
||||
ProviderSessionId,
|
||||
ProviderThreadId,
|
||||
ThreadId,
|
||||
TurnId,
|
||||
} from "@t3tools/contracts";
|
||||
@@ -22,9 +20,6 @@ const asTurnId = (value: string): TurnId => TurnId.makeUnsafe(value);
|
||||
const asMessageId = (value: string): MessageId => MessageId.makeUnsafe(value);
|
||||
const asEventId = (value: string): EventId => EventId.makeUnsafe(value);
|
||||
const asCheckpointRef = (value: string): CheckpointRef => CheckpointRef.makeUnsafe(value);
|
||||
const asProviderSessionId = (value: string): ProviderSessionId =>
|
||||
ProviderSessionId.makeUnsafe(value);
|
||||
const asProviderThreadId = (value: string): ProviderThreadId => ProviderThreadId.makeUnsafe(value);
|
||||
|
||||
const projectionSnapshotLayer = it.layer(
|
||||
OrchestrationProjectionSnapshotQueryLive.pipe(Layer.provideMerge(SqlitePersistenceMemory)),
|
||||
@@ -143,8 +138,7 @@ projectionSnapshotLayer("ProjectionSnapshotQuery", (it) => {
|
||||
provider_name,
|
||||
provider_session_id,
|
||||
provider_thread_id,
|
||||
approval_policy,
|
||||
sandbox_mode,
|
||||
runtime_mode,
|
||||
active_turn_id,
|
||||
last_error,
|
||||
updated_at
|
||||
@@ -155,8 +149,7 @@ projectionSnapshotLayer("ProjectionSnapshotQuery", (it) => {
|
||||
'codex',
|
||||
'provider-session-1',
|
||||
'provider-thread-1',
|
||||
'on-request',
|
||||
'workspace-write',
|
||||
'approval-required',
|
||||
'turn-1',
|
||||
NULL,
|
||||
'2026-02-24T00:00:07.000Z'
|
||||
@@ -241,6 +234,8 @@ projectionSnapshotLayer("ProjectionSnapshotQuery", (it) => {
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Thread 1",
|
||||
model: "gpt-5-codex",
|
||||
interactionMode: "default",
|
||||
runtimeMode: "full-access",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
latestTurn: {
|
||||
@@ -265,6 +260,7 @@ projectionSnapshotLayer("ProjectionSnapshotQuery", (it) => {
|
||||
updatedAt: "2026-02-24T00:00:05.000Z",
|
||||
},
|
||||
],
|
||||
proposedPlans: [],
|
||||
activities: [
|
||||
{
|
||||
id: asEventId("activity-1"),
|
||||
@@ -291,10 +287,7 @@ projectionSnapshotLayer("ProjectionSnapshotQuery", (it) => {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
status: "running",
|
||||
providerName: "codex",
|
||||
providerSessionId: asProviderSessionId("provider-session-1"),
|
||||
providerThreadId: asProviderThreadId("provider-thread-1"),
|
||||
approvalPolicy: "on-request",
|
||||
sandboxMode: "workspace-write",
|
||||
runtimeMode: "approval-required",
|
||||
activeTurnId: asTurnId("turn-1"),
|
||||
lastError: null,
|
||||
updatedAt: "2026-02-24T00:00:07.000Z",
|
||||
|
||||
@@ -2,6 +2,7 @@ import {
|
||||
ChatAttachment,
|
||||
IsoDateTime,
|
||||
MessageId,
|
||||
NonNegativeInt,
|
||||
OrchestrationCheckpointFile,
|
||||
OrchestrationReadModel,
|
||||
ProjectScript,
|
||||
@@ -9,6 +10,7 @@ import {
|
||||
type OrchestrationCheckpointSummary,
|
||||
type OrchestrationLatestTurn,
|
||||
type OrchestrationMessage,
|
||||
type OrchestrationProposedPlan,
|
||||
type OrchestrationProject,
|
||||
type OrchestrationSession,
|
||||
type OrchestrationThread,
|
||||
@@ -29,6 +31,7 @@ import { ProjectionProject } from "../../persistence/Services/ProjectionProjects
|
||||
import { ProjectionState } from "../../persistence/Services/ProjectionState.ts";
|
||||
import { ProjectionThreadActivity } from "../../persistence/Services/ProjectionThreadActivities.ts";
|
||||
import { ProjectionThreadMessage } from "../../persistence/Services/ProjectionThreadMessages.ts";
|
||||
import { ProjectionThreadProposedPlan } from "../../persistence/Services/ProjectionThreadProposedPlans.ts";
|
||||
import { ProjectionThreadSession } from "../../persistence/Services/ProjectionThreadSessions.ts";
|
||||
import { ProjectionThread } from "../../persistence/Services/ProjectionThreads.ts";
|
||||
import { ORCHESTRATION_PROJECTOR_NAMES } from "./ProjectionPipeline.ts";
|
||||
@@ -49,10 +52,12 @@ const ProjectionThreadMessageDbRowSchema = ProjectionThreadMessage.mapFields(
|
||||
attachments: Schema.NullOr(Schema.fromJsonString(Schema.Array(ChatAttachment))),
|
||||
}),
|
||||
);
|
||||
const ProjectionThreadProposedPlanDbRowSchema = ProjectionThreadProposedPlan;
|
||||
const ProjectionThreadDbRowSchema = ProjectionThread;
|
||||
const ProjectionThreadActivityDbRowSchema = ProjectionThreadActivity.mapFields(
|
||||
Struct.assign({
|
||||
payload: Schema.fromJsonString(Schema.Unknown),
|
||||
sequence: Schema.NullOr(NonNegativeInt),
|
||||
}),
|
||||
);
|
||||
const ProjectionThreadSessionDbRowSchema = ProjectionThreadSession;
|
||||
@@ -76,6 +81,7 @@ const REQUIRED_SNAPSHOT_PROJECTORS = [
|
||||
ORCHESTRATION_PROJECTOR_NAMES.projects,
|
||||
ORCHESTRATION_PROJECTOR_NAMES.threads,
|
||||
ORCHESTRATION_PROJECTOR_NAMES.threadMessages,
|
||||
ORCHESTRATION_PROJECTOR_NAMES.threadProposedPlans,
|
||||
ORCHESTRATION_PROJECTOR_NAMES.threadActivities,
|
||||
ORCHESTRATION_PROJECTOR_NAMES.threadSessions,
|
||||
ORCHESTRATION_PROJECTOR_NAMES.checkpoints,
|
||||
@@ -151,6 +157,8 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
project_id AS "projectId",
|
||||
title,
|
||||
model,
|
||||
runtime_mode AS "runtimeMode",
|
||||
interaction_mode AS "interactionMode",
|
||||
branch,
|
||||
worktree_path AS "worktreePath",
|
||||
latest_turn_id AS "latestTurnId",
|
||||
@@ -182,6 +190,23 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
`,
|
||||
});
|
||||
|
||||
const listThreadProposedPlanRows = SqlSchema.findAll({
|
||||
Request: Schema.Void,
|
||||
Result: ProjectionThreadProposedPlanDbRowSchema,
|
||||
execute: () =>
|
||||
sql`
|
||||
SELECT
|
||||
plan_id AS "planId",
|
||||
thread_id AS "threadId",
|
||||
turn_id AS "turnId",
|
||||
plan_markdown AS "planMarkdown",
|
||||
created_at AS "createdAt",
|
||||
updated_at AS "updatedAt"
|
||||
FROM projection_thread_proposed_plans
|
||||
ORDER BY thread_id ASC, created_at ASC, plan_id ASC
|
||||
`,
|
||||
});
|
||||
|
||||
const listThreadActivityRows = SqlSchema.findAll({
|
||||
Request: Schema.Void,
|
||||
Result: ProjectionThreadActivityDbRowSchema,
|
||||
@@ -195,9 +220,15 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
kind,
|
||||
summary,
|
||||
payload_json AS "payload",
|
||||
sequence,
|
||||
created_at AS "createdAt"
|
||||
FROM projection_thread_activities
|
||||
ORDER BY thread_id ASC, created_at ASC, activity_id ASC
|
||||
ORDER BY
|
||||
thread_id ASC,
|
||||
CASE WHEN sequence IS NULL THEN 0 ELSE 1 END ASC,
|
||||
sequence ASC,
|
||||
created_at ASC,
|
||||
activity_id ASC
|
||||
`,
|
||||
});
|
||||
|
||||
@@ -212,8 +243,7 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
provider_name AS "providerName",
|
||||
provider_session_id AS "providerSessionId",
|
||||
provider_thread_id AS "providerThreadId",
|
||||
approval_policy AS "approvalPolicy",
|
||||
sandbox_mode AS "sandboxMode",
|
||||
runtime_mode AS "runtimeMode",
|
||||
active_turn_id AS "activeTurnId",
|
||||
last_error AS "lastError",
|
||||
updated_at AS "updatedAt"
|
||||
@@ -282,6 +312,7 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
projectRows,
|
||||
threadRows,
|
||||
messageRows,
|
||||
proposedPlanRows,
|
||||
activityRows,
|
||||
sessionRows,
|
||||
checkpointRows,
|
||||
@@ -312,6 +343,14 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
),
|
||||
),
|
||||
),
|
||||
listThreadProposedPlanRows(undefined).pipe(
|
||||
Effect.mapError(
|
||||
toPersistenceSqlOrDecodeError(
|
||||
"ProjectionSnapshotQuery.getSnapshot:listThreadProposedPlans:query",
|
||||
"ProjectionSnapshotQuery.getSnapshot:listThreadProposedPlans:decodeRows",
|
||||
),
|
||||
),
|
||||
),
|
||||
listThreadActivityRows(undefined).pipe(
|
||||
Effect.mapError(
|
||||
toPersistenceSqlOrDecodeError(
|
||||
@@ -355,6 +394,7 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
]);
|
||||
|
||||
const messagesByThread = new Map<string, Array<OrchestrationMessage>>();
|
||||
const proposedPlansByThread = new Map<string, Array<OrchestrationProposedPlan>>();
|
||||
const activitiesByThread = new Map<string, Array<OrchestrationThreadActivity>>();
|
||||
const checkpointsByThread = new Map<string, Array<OrchestrationCheckpointSummary>>();
|
||||
const sessionsByThread = new Map<string, OrchestrationSession>();
|
||||
@@ -388,6 +428,19 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
messagesByThread.set(row.threadId, threadMessages);
|
||||
}
|
||||
|
||||
for (const row of proposedPlanRows) {
|
||||
updatedAt = maxIso(updatedAt, row.updatedAt);
|
||||
const threadProposedPlans = proposedPlansByThread.get(row.threadId) ?? [];
|
||||
threadProposedPlans.push({
|
||||
id: row.planId,
|
||||
turnId: row.turnId,
|
||||
planMarkdown: row.planMarkdown,
|
||||
createdAt: row.createdAt,
|
||||
updatedAt: row.updatedAt,
|
||||
});
|
||||
proposedPlansByThread.set(row.threadId, threadProposedPlans);
|
||||
}
|
||||
|
||||
for (const row of activityRows) {
|
||||
updatedAt = maxIso(updatedAt, row.createdAt);
|
||||
const threadActivities = activitiesByThread.get(row.threadId) ?? [];
|
||||
@@ -398,6 +451,7 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
summary: row.summary,
|
||||
payload: row.payload,
|
||||
turnId: row.turnId,
|
||||
...(row.sequence !== null ? { sequence: row.sequence } : {}),
|
||||
createdAt: row.createdAt,
|
||||
});
|
||||
activitiesByThread.set(row.threadId, threadActivities);
|
||||
@@ -452,10 +506,7 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
threadId: row.threadId,
|
||||
status: row.status,
|
||||
providerName: row.providerName,
|
||||
providerSessionId: row.providerSessionId,
|
||||
providerThreadId: row.providerThreadId,
|
||||
approvalPolicy: row.approvalPolicy,
|
||||
sandboxMode: row.sandboxMode,
|
||||
runtimeMode: row.runtimeMode,
|
||||
activeTurnId: row.activeTurnId,
|
||||
lastError: row.lastError,
|
||||
updatedAt: row.updatedAt,
|
||||
@@ -478,6 +529,8 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
projectId: row.projectId,
|
||||
title: row.title,
|
||||
model: row.model,
|
||||
runtimeMode: row.runtimeMode,
|
||||
interactionMode: row.interactionMode,
|
||||
branch: row.branch,
|
||||
worktreePath: row.worktreePath,
|
||||
latestTurn: latestTurnByThread.get(row.threadId) ?? null,
|
||||
@@ -485,6 +538,7 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
|
||||
updatedAt: row.updatedAt,
|
||||
deletedAt: row.deletedAt,
|
||||
messages: messagesByThread.get(row.threadId) ?? [],
|
||||
proposedPlans: proposedPlansByThread.get(row.threadId) ?? [],
|
||||
activities: activitiesByThread.get(row.threadId) ?? [],
|
||||
checkpoints: checkpointsByThread.get(row.threadId) ?? [],
|
||||
session: sessionsByThread.get(row.threadId) ?? null,
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -3,19 +3,19 @@ import {
|
||||
CommandId,
|
||||
EventId,
|
||||
type OrchestrationEvent,
|
||||
type ProviderApprovalPolicy,
|
||||
type ProviderModelOptions,
|
||||
type ProviderKind,
|
||||
type ProviderSandboxMode,
|
||||
type OrchestrationSession,
|
||||
type ThreadId,
|
||||
ThreadId,
|
||||
type ProviderSession,
|
||||
type ProviderThreadId,
|
||||
type RuntimeMode,
|
||||
type TurnId,
|
||||
} from "@t3tools/contracts";
|
||||
import { Cache, Cause, Duration, Effect, Layer, Option, Queue, Stream } from "effect";
|
||||
import { Cache, Cause, Duration, Effect, Layer, Option, Queue, Schema, Stream } from "effect";
|
||||
|
||||
import { resolveThreadWorkspaceCwd } from "../../checkpointing/Utils.ts";
|
||||
import { GitCore } from "../../git/Services/GitCore.ts";
|
||||
import { ProviderAdapterRequestError } from "../../provider/Errors.ts";
|
||||
import { TextGeneration } from "../../git/Services/TextGeneration.ts";
|
||||
import { ProviderService } from "../../provider/Services/ProviderService.ts";
|
||||
import { OrchestrationEngineService } from "../Services/OrchestrationEngine.ts";
|
||||
@@ -28,9 +28,11 @@ type ProviderIntentEvent = Extract<
|
||||
OrchestrationEvent,
|
||||
{
|
||||
type:
|
||||
| "thread.runtime-mode-set"
|
||||
| "thread.turn-start-requested"
|
||||
| "thread.turn-interrupt-requested"
|
||||
| "thread.approval-response-requested"
|
||||
| "thread.user-input-response-requested"
|
||||
| "thread.session-stop-requested";
|
||||
}
|
||||
>;
|
||||
@@ -66,11 +68,36 @@ const serverCommandId = (tag: string): CommandId =>
|
||||
|
||||
const HANDLED_TURN_START_KEY_MAX = 10_000;
|
||||
const HANDLED_TURN_START_KEY_TTL = Duration.minutes(30);
|
||||
const DEFAULT_APPROVAL_POLICY: ProviderApprovalPolicy = "never";
|
||||
const DEFAULT_SANDBOX_MODE: ProviderSandboxMode = "workspace-write";
|
||||
const DEFAULT_RUNTIME_MODE: RuntimeMode = "full-access";
|
||||
const WORKTREE_BRANCH_PREFIX = "t3code";
|
||||
const TEMP_WORKTREE_BRANCH_PATTERN = new RegExp(`^${WORKTREE_BRANCH_PREFIX}\\/[0-9a-f]{8}$`);
|
||||
|
||||
function toErrorMessage(error: unknown): string {
|
||||
if (error instanceof Error && error.message.trim().length > 0) {
|
||||
return error.message;
|
||||
}
|
||||
try {
|
||||
return JSON.stringify(error);
|
||||
} catch {
|
||||
return String(error);
|
||||
}
|
||||
}
|
||||
|
||||
function isUnknownPendingApprovalRequestError(error: unknown): boolean {
|
||||
if (Schema.is(ProviderAdapterRequestError)(error)) {
|
||||
const detail = error.detail.toLowerCase();
|
||||
return (
|
||||
detail.includes("unknown pending approval request") ||
|
||||
detail.includes("unknown pending permission request")
|
||||
);
|
||||
}
|
||||
const message = toErrorMessage(error).toLowerCase();
|
||||
return (
|
||||
message.includes("unknown pending approval request") ||
|
||||
message.includes("unknown pending permission request")
|
||||
);
|
||||
}
|
||||
|
||||
function isTemporaryWorktreeBranch(branch: string): boolean {
|
||||
return TEMP_WORKTREE_BRANCH_PATTERN.test(branch.trim().toLowerCase());
|
||||
}
|
||||
@@ -122,11 +149,13 @@ const make = Effect.gen(function* () {
|
||||
| "provider.turn.start.failed"
|
||||
| "provider.turn.interrupt.failed"
|
||||
| "provider.approval.respond.failed"
|
||||
| "provider.user-input.respond.failed"
|
||||
| "provider.session.stop.failed";
|
||||
readonly summary: string;
|
||||
readonly detail: string;
|
||||
readonly turnId: TurnId | null;
|
||||
readonly createdAt: string;
|
||||
readonly requestId?: string;
|
||||
}) =>
|
||||
orchestrationEngine.dispatch({
|
||||
type: "thread.activity.append",
|
||||
@@ -139,6 +168,7 @@ const make = Effect.gen(function* () {
|
||||
summary: input.summary,
|
||||
payload: {
|
||||
detail: input.detail,
|
||||
...(input.requestId ? { requestId: input.requestId } : {}),
|
||||
},
|
||||
turnId: input.turnId,
|
||||
createdAt: input.createdAt,
|
||||
@@ -168,8 +198,9 @@ const make = Effect.gen(function* () {
|
||||
threadId: ThreadId,
|
||||
createdAt: string,
|
||||
options?: {
|
||||
readonly approvalPolicy?: ProviderApprovalPolicy;
|
||||
readonly sandboxMode?: ProviderSandboxMode;
|
||||
readonly provider?: ProviderKind;
|
||||
readonly model?: string;
|
||||
readonly modelOptions?: ProviderModelOptions;
|
||||
},
|
||||
) {
|
||||
const readModel = yield* orchestrationEngine.getReadModel();
|
||||
@@ -178,27 +209,39 @@ const make = Effect.gen(function* () {
|
||||
return yield* Effect.die(new Error(`Thread '${threadId}' was not found in read model.`));
|
||||
}
|
||||
|
||||
const desiredApprovalPolicy =
|
||||
options?.approvalPolicy ?? thread.session?.approvalPolicy ?? DEFAULT_APPROVAL_POLICY;
|
||||
const desiredSandboxMode =
|
||||
options?.sandboxMode ?? thread.session?.sandboxMode ?? DEFAULT_SANDBOX_MODE;
|
||||
const preferredProvider: ProviderKind | undefined =
|
||||
thread.session?.providerName === "codex" || thread.session?.providerName === "claudeCode"
|
||||
const desiredRuntimeMode = thread.runtimeMode;
|
||||
const currentProvider: ProviderKind | undefined =
|
||||
thread.session?.providerName === "codex" ||
|
||||
thread.session?.providerName === "claudeCode" ||
|
||||
thread.session?.providerName === "cursor"
|
||||
? thread.session.providerName
|
||||
: undefined;
|
||||
const preferredProvider: ProviderKind | undefined = options?.provider ?? currentProvider;
|
||||
const desiredModel = options?.model ?? thread.model;
|
||||
const effectiveCwd = resolveThreadWorkspaceCwd({
|
||||
thread,
|
||||
projects: readModel.projects,
|
||||
});
|
||||
|
||||
const startProviderSession = (resumeThreadId?: ProviderThreadId | null) =>
|
||||
const resolveActiveSession = (threadId: ThreadId) =>
|
||||
providerService.listSessions().pipe(
|
||||
Effect.map((sessions) => sessions.find((session) => session.threadId === threadId)),
|
||||
);
|
||||
|
||||
const startProviderSession = (input?: {
|
||||
readonly resumeCursor?: unknown;
|
||||
readonly provider?: ProviderKind;
|
||||
}) =>
|
||||
providerService.startSession(threadId, {
|
||||
...(preferredProvider ? { provider: preferredProvider } : {}),
|
||||
threadId,
|
||||
...(input?.provider ?? preferredProvider
|
||||
? { provider: input?.provider ?? preferredProvider }
|
||||
: {}),
|
||||
...(effectiveCwd ? { cwd: effectiveCwd } : {}),
|
||||
...(thread.model ? { model: thread.model } : {}),
|
||||
...(resumeThreadId ? { resumeThreadId } : {}),
|
||||
approvalPolicy: desiredApprovalPolicy,
|
||||
sandboxMode: desiredSandboxMode,
|
||||
...(desiredModel ? { model: desiredModel } : {}),
|
||||
...(options?.modelOptions !== undefined ? { modelOptions: options.modelOptions } : {}),
|
||||
...(input?.resumeCursor !== undefined ? { resumeCursor: input.resumeCursor } : {}),
|
||||
runtimeMode: desiredRuntimeMode,
|
||||
});
|
||||
|
||||
const bindSessionToThread = (session: ProviderSession) =>
|
||||
@@ -208,10 +251,7 @@ const make = Effect.gen(function* () {
|
||||
threadId,
|
||||
status: mapProviderSessionStatusToOrchestrationStatus(session.status),
|
||||
providerName: session.provider,
|
||||
providerSessionId: session.sessionId,
|
||||
providerThreadId: session.threadId ?? null,
|
||||
approvalPolicy: desiredApprovalPolicy,
|
||||
sandboxMode: desiredSandboxMode,
|
||||
runtimeMode: desiredRuntimeMode,
|
||||
// Provider turn ids are not orchestration turn ids.
|
||||
activeTurnId: null,
|
||||
lastError: session.lastError ?? null,
|
||||
@@ -220,66 +260,102 @@ const make = Effect.gen(function* () {
|
||||
createdAt,
|
||||
});
|
||||
|
||||
const existingSessionId = thread.session?.providerSessionId;
|
||||
if (existingSessionId) {
|
||||
const approvalPolicyChanged =
|
||||
options?.approvalPolicy !== undefined &&
|
||||
options.approvalPolicy !== thread.session?.approvalPolicy;
|
||||
const sandboxModeChanged =
|
||||
options?.sandboxMode !== undefined && options.sandboxMode !== thread.session?.sandboxMode;
|
||||
const existingSessionThreadId =
|
||||
thread.session && thread.session.status !== "stopped" ? thread.id : null;
|
||||
if (existingSessionThreadId) {
|
||||
const runtimeModeChanged = thread.runtimeMode !== thread.session?.runtimeMode;
|
||||
const providerChanged = options?.provider !== undefined && options.provider !== currentProvider;
|
||||
const activeSession = yield* resolveActiveSession(existingSessionThreadId);
|
||||
const sessionModelSwitch =
|
||||
currentProvider === undefined
|
||||
? "in-session"
|
||||
: (yield* providerService.getCapabilities(currentProvider)).sessionModelSwitch;
|
||||
const modelChanged =
|
||||
options?.model !== undefined && options.model !== activeSession?.model;
|
||||
const shouldRestartForModelChange =
|
||||
modelChanged && sessionModelSwitch === "restart-session";
|
||||
|
||||
if (!approvalPolicyChanged && !sandboxModeChanged) {
|
||||
return existingSessionId;
|
||||
if (!runtimeModeChanged && !providerChanged && !shouldRestartForModelChange) {
|
||||
return existingSessionThreadId;
|
||||
}
|
||||
|
||||
const restartedSession = yield* startProviderSession(
|
||||
thread.session?.providerThreadId ?? null,
|
||||
);
|
||||
const resumeCursor =
|
||||
providerChanged || shouldRestartForModelChange
|
||||
? undefined
|
||||
: (activeSession?.resumeCursor ?? undefined);
|
||||
yield* Effect.logInfo("provider command reactor restarting provider session", {
|
||||
threadId,
|
||||
existingSessionThreadId,
|
||||
currentProvider,
|
||||
desiredProvider: options?.provider ?? currentProvider,
|
||||
currentRuntimeMode: thread.session?.runtimeMode,
|
||||
desiredRuntimeMode: thread.runtimeMode,
|
||||
runtimeModeChanged,
|
||||
providerChanged,
|
||||
modelChanged,
|
||||
shouldRestartForModelChange,
|
||||
hasResumeCursor: resumeCursor !== undefined,
|
||||
});
|
||||
const restartedSession = yield* startProviderSession({
|
||||
...(resumeCursor !== undefined ? { resumeCursor } : {}),
|
||||
...(options?.provider !== undefined ? { provider: options.provider } : {}),
|
||||
});
|
||||
yield* Effect.logInfo("provider command reactor restarted provider session", {
|
||||
threadId,
|
||||
previousSessionId: existingSessionThreadId,
|
||||
restartedSessionThreadId: restartedSession.threadId,
|
||||
provider: restartedSession.provider,
|
||||
runtimeMode: restartedSession.runtimeMode,
|
||||
});
|
||||
yield* bindSessionToThread(restartedSession);
|
||||
yield* providerService.stopSession({ sessionId: existingSessionId }).pipe(
|
||||
Effect.catchCause((cause) =>
|
||||
Effect.logWarning("provider command reactor failed to stop superseded provider session", {
|
||||
threadId,
|
||||
sessionId: existingSessionId,
|
||||
cause: Cause.pretty(cause),
|
||||
}),
|
||||
),
|
||||
);
|
||||
return restartedSession.sessionId;
|
||||
return restartedSession.threadId;
|
||||
}
|
||||
|
||||
const startedSession = yield* startProviderSession();
|
||||
const startedSession = yield* startProviderSession(
|
||||
options?.provider !== undefined ? { provider: options.provider } : undefined,
|
||||
);
|
||||
yield* bindSessionToThread(startedSession);
|
||||
return startedSession.sessionId;
|
||||
return startedSession.threadId;
|
||||
});
|
||||
|
||||
const sendTurnForThread = Effect.fnUntraced(function* (input: {
|
||||
readonly threadId: ThreadId;
|
||||
readonly messageText: string;
|
||||
readonly attachments?: ReadonlyArray<ChatAttachment>;
|
||||
readonly provider?: ProviderKind;
|
||||
readonly model?: string;
|
||||
readonly effort?: string;
|
||||
readonly approvalPolicy: ProviderApprovalPolicy;
|
||||
readonly sandboxMode: ProviderSandboxMode;
|
||||
readonly modelOptions?: ProviderModelOptions;
|
||||
readonly interactionMode?: "default" | "plan";
|
||||
readonly createdAt: string;
|
||||
}) {
|
||||
const thread = yield* resolveThread(input.threadId);
|
||||
if (!thread) {
|
||||
return;
|
||||
}
|
||||
const sessionId = yield* ensureSessionForThread(input.threadId, input.createdAt, {
|
||||
approvalPolicy: input.approvalPolicy,
|
||||
sandboxMode: input.sandboxMode,
|
||||
yield* ensureSessionForThread(input.threadId, input.createdAt, {
|
||||
...(input.provider !== undefined ? { provider: input.provider } : {}),
|
||||
...(input.model !== undefined ? { model: input.model } : {}),
|
||||
...(input.modelOptions !== undefined ? { modelOptions: input.modelOptions } : {}),
|
||||
});
|
||||
const normalizedInput = toNonEmptyProviderInput(input.messageText);
|
||||
const normalizedAttachments = input.attachments ?? [];
|
||||
const activeSession = yield* providerService.listSessions().pipe(
|
||||
Effect.map((sessions) => sessions.find((session) => session.threadId === input.threadId)),
|
||||
);
|
||||
const sessionModelSwitch =
|
||||
activeSession === undefined
|
||||
? "in-session"
|
||||
: (yield* providerService.getCapabilities(activeSession.provider)).sessionModelSwitch;
|
||||
const modelForTurn =
|
||||
sessionModelSwitch === "unsupported" ? activeSession?.model : input.model;
|
||||
|
||||
yield* providerService.sendTurn({
|
||||
sessionId,
|
||||
threadId: input.threadId,
|
||||
...(normalizedInput ? { input: normalizedInput } : {}),
|
||||
...(normalizedAttachments.length > 0 ? { attachments: normalizedAttachments } : {}),
|
||||
...(input.model !== undefined ? { model: input.model } : {}),
|
||||
...(input.effort !== undefined ? { effort: input.effort } : {}),
|
||||
...(modelForTurn !== undefined ? { model: modelForTurn } : {}),
|
||||
...(input.modelOptions !== undefined ? { modelOptions: input.modelOptions } : {}),
|
||||
...(input.interactionMode !== undefined ? { interactionMode: input.interactionMode } : {}),
|
||||
});
|
||||
});
|
||||
|
||||
@@ -390,10 +466,10 @@ const make = Effect.gen(function* () {
|
||||
threadId: event.payload.threadId,
|
||||
messageText: message.text,
|
||||
...(message.attachments !== undefined ? { attachments: message.attachments } : {}),
|
||||
...(event.payload.provider !== undefined ? { provider: event.payload.provider } : {}),
|
||||
...(event.payload.model !== undefined ? { model: event.payload.model } : {}),
|
||||
...(event.payload.effort !== undefined ? { effort: event.payload.effort } : {}),
|
||||
approvalPolicy: event.payload.approvalPolicy,
|
||||
sandboxMode: event.payload.sandboxMode,
|
||||
...(event.payload.modelOptions !== undefined ? { modelOptions: event.payload.modelOptions } : {}),
|
||||
interactionMode: event.payload.interactionMode,
|
||||
createdAt: event.payload.createdAt,
|
||||
});
|
||||
});
|
||||
@@ -405,8 +481,8 @@ const make = Effect.gen(function* () {
|
||||
if (!thread) {
|
||||
return;
|
||||
}
|
||||
const sessionId = thread.session?.providerSessionId;
|
||||
if (!sessionId) {
|
||||
const hasSession = thread.session && thread.session.status !== "stopped";
|
||||
if (!hasSession) {
|
||||
return yield* appendProviderFailureActivity({
|
||||
threadId: event.payload.threadId,
|
||||
kind: "provider.turn.interrupt.failed",
|
||||
@@ -418,7 +494,7 @@ const make = Effect.gen(function* () {
|
||||
}
|
||||
|
||||
// Orchestration turn ids are not provider turn ids, so interrupt by session.
|
||||
yield* providerService.interruptTurn({ sessionId });
|
||||
yield* providerService.interruptTurn({ threadId: event.payload.threadId });
|
||||
});
|
||||
|
||||
const processApprovalResponseRequested = Effect.fnUntraced(function* (
|
||||
@@ -428,8 +504,8 @@ const make = Effect.gen(function* () {
|
||||
if (!thread) {
|
||||
return;
|
||||
}
|
||||
const sessionId = thread.session?.providerSessionId;
|
||||
if (!sessionId) {
|
||||
const hasSession = thread.session && thread.session.status !== "stopped";
|
||||
if (!hasSession) {
|
||||
return yield* appendProviderFailureActivity({
|
||||
threadId: event.payload.threadId,
|
||||
kind: "provider.approval.respond.failed",
|
||||
@@ -437,14 +513,79 @@ const make = Effect.gen(function* () {
|
||||
detail: "No active provider session is bound to this thread.",
|
||||
turnId: null,
|
||||
createdAt: event.payload.createdAt,
|
||||
requestId: event.payload.requestId,
|
||||
});
|
||||
}
|
||||
|
||||
yield* providerService.respondToRequest({
|
||||
sessionId,
|
||||
requestId: event.payload.requestId,
|
||||
decision: event.payload.decision,
|
||||
});
|
||||
yield* providerService
|
||||
.respondToRequest({
|
||||
threadId: event.payload.threadId,
|
||||
requestId: event.payload.requestId,
|
||||
decision: event.payload.decision,
|
||||
})
|
||||
.pipe(
|
||||
Effect.catchCause((cause) =>
|
||||
Effect.gen(function* () {
|
||||
const error = Cause.squash(cause);
|
||||
const detail = toErrorMessage(error);
|
||||
yield* appendProviderFailureActivity({
|
||||
threadId: event.payload.threadId,
|
||||
kind: "provider.approval.respond.failed",
|
||||
summary: "Provider approval response failed",
|
||||
detail,
|
||||
turnId: null,
|
||||
createdAt: event.payload.createdAt,
|
||||
requestId: event.payload.requestId,
|
||||
});
|
||||
|
||||
if (!isUnknownPendingApprovalRequestError(error)) return;
|
||||
}),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
const processUserInputResponseRequested = Effect.fnUntraced(function* (
|
||||
event: Extract<ProviderIntentEvent, { type: "thread.user-input-response-requested" }>,
|
||||
) {
|
||||
const thread = yield* resolveThread(event.payload.threadId);
|
||||
if (!thread) {
|
||||
return;
|
||||
}
|
||||
const hasSession = thread.session && thread.session.status !== "stopped";
|
||||
if (!hasSession) {
|
||||
return yield* appendProviderFailureActivity({
|
||||
threadId: event.payload.threadId,
|
||||
kind: "provider.user-input.respond.failed",
|
||||
summary: "Provider user input response failed",
|
||||
detail: "No active provider session is bound to this thread.",
|
||||
turnId: null,
|
||||
createdAt: event.payload.createdAt,
|
||||
requestId: event.payload.requestId,
|
||||
});
|
||||
}
|
||||
|
||||
yield* providerService
|
||||
.respondToUserInput({
|
||||
threadId: event.payload.threadId,
|
||||
requestId: event.payload.requestId,
|
||||
answers: event.payload.answers,
|
||||
})
|
||||
.pipe(
|
||||
Effect.catchCause((cause) =>
|
||||
Effect.gen(function* () {
|
||||
const error = Cause.squash(cause);
|
||||
yield* appendProviderFailureActivity({
|
||||
threadId: event.payload.threadId,
|
||||
kind: "provider.user-input.respond.failed",
|
||||
summary: "Provider user input response failed",
|
||||
detail: toErrorMessage(error),
|
||||
turnId: null,
|
||||
createdAt: event.payload.createdAt,
|
||||
requestId: event.payload.requestId,
|
||||
});
|
||||
}),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
const processSessionStopRequested = Effect.fnUntraced(function* (
|
||||
@@ -456,10 +597,8 @@ const make = Effect.gen(function* () {
|
||||
}
|
||||
|
||||
const now = event.payload.createdAt;
|
||||
const sessionId = thread.session?.providerSessionId;
|
||||
|
||||
if (sessionId) {
|
||||
yield* providerService.stopSession({ sessionId });
|
||||
if (thread.session && thread.session.status !== "stopped") {
|
||||
yield* providerService.stopSession({ threadId: thread.id });
|
||||
}
|
||||
|
||||
yield* setThreadSession({
|
||||
@@ -468,10 +607,7 @@ const make = Effect.gen(function* () {
|
||||
threadId: thread.id,
|
||||
status: "stopped",
|
||||
providerName: thread.session?.providerName ?? null,
|
||||
providerSessionId: null,
|
||||
providerThreadId: null,
|
||||
approvalPolicy: thread.session?.approvalPolicy ?? DEFAULT_APPROVAL_POLICY,
|
||||
sandboxMode: thread.session?.sandboxMode ?? DEFAULT_SANDBOX_MODE,
|
||||
runtimeMode: thread.session?.runtimeMode ?? DEFAULT_RUNTIME_MODE,
|
||||
activeTurnId: null,
|
||||
lastError: thread.session?.lastError ?? null,
|
||||
updatedAt: now,
|
||||
@@ -483,6 +619,14 @@ const make = Effect.gen(function* () {
|
||||
const processDomainEvent = (event: ProviderIntentEvent) =>
|
||||
Effect.gen(function* () {
|
||||
switch (event.type) {
|
||||
case "thread.runtime-mode-set": {
|
||||
const thread = yield* resolveThread(event.payload.threadId);
|
||||
if (!thread?.session || thread.session.status === "stopped") {
|
||||
return;
|
||||
}
|
||||
yield* ensureSessionForThread(event.payload.threadId, event.occurredAt);
|
||||
return;
|
||||
}
|
||||
case "thread.turn-start-requested":
|
||||
yield* processTurnStartRequested(event);
|
||||
return;
|
||||
@@ -492,6 +636,9 @@ const make = Effect.gen(function* () {
|
||||
case "thread.approval-response-requested":
|
||||
yield* processApprovalResponseRequested(event);
|
||||
return;
|
||||
case "thread.user-input-response-requested":
|
||||
yield* processUserInputResponseRequested(event);
|
||||
return;
|
||||
case "thread.session-stop-requested":
|
||||
yield* processSessionStopRequested(event);
|
||||
return;
|
||||
@@ -522,9 +669,11 @@ const make = Effect.gen(function* () {
|
||||
yield* Effect.forkScoped(
|
||||
Stream.runForEach(orchestrationEngine.streamDomainEvents, (event) => {
|
||||
if (
|
||||
event.type !== "thread.runtime-mode-set" &&
|
||||
event.type !== "thread.turn-start-requested" &&
|
||||
event.type !== "thread.turn-interrupt-requested" &&
|
||||
event.type !== "thread.approval-response-requested" &&
|
||||
event.type !== "thread.user-input-response-requested" &&
|
||||
event.type !== "thread.session-stop-requested"
|
||||
) {
|
||||
return Effect.void;
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -4,8 +4,11 @@ import {
|
||||
ProjectDeletedPayload as ContractsProjectDeletedPayloadSchema,
|
||||
ThreadCreatedPayload as ContractsThreadCreatedPayloadSchema,
|
||||
ThreadMetaUpdatedPayload as ContractsThreadMetaUpdatedPayloadSchema,
|
||||
ThreadRuntimeModeSetPayload as ContractsThreadRuntimeModeSetPayloadSchema,
|
||||
ThreadInteractionModeSetPayload as ContractsThreadInteractionModeSetPayloadSchema,
|
||||
ThreadDeletedPayload as ContractsThreadDeletedPayloadSchema,
|
||||
ThreadMessageSentPayload as ContractsThreadMessageSentPayloadSchema,
|
||||
ThreadProposedPlanUpsertedPayload as ContractsThreadProposedPlanUpsertedPayloadSchema,
|
||||
ThreadSessionSetPayload as ContractsThreadSessionSetPayloadSchema,
|
||||
ThreadTurnDiffCompletedPayload as ContractsThreadTurnDiffCompletedPayloadSchema,
|
||||
ThreadRevertedPayload as ContractsThreadRevertedPayloadSchema,
|
||||
@@ -24,9 +27,12 @@ export const ProjectDeletedPayload = ContractsProjectDeletedPayloadSchema;
|
||||
|
||||
export const ThreadCreatedPayload = ContractsThreadCreatedPayloadSchema;
|
||||
export const ThreadMetaUpdatedPayload = ContractsThreadMetaUpdatedPayloadSchema;
|
||||
export const ThreadRuntimeModeSetPayload = ContractsThreadRuntimeModeSetPayloadSchema;
|
||||
export const ThreadInteractionModeSetPayload = ContractsThreadInteractionModeSetPayloadSchema;
|
||||
export const ThreadDeletedPayload = ContractsThreadDeletedPayloadSchema;
|
||||
|
||||
export const MessageSentPayloadSchema = ContractsThreadMessageSentPayloadSchema;
|
||||
export const ThreadProposedPlanUpsertedPayload = ContractsThreadProposedPlanUpsertedPayloadSchema;
|
||||
export const ThreadSessionSetPayload = ContractsThreadSessionSetPayloadSchema;
|
||||
export const ThreadTurnDiffCompletedPayload = ContractsThreadTurnDiffCompletedPayloadSchema;
|
||||
export const ThreadRevertedPayload = ContractsThreadRevertedPayloadSchema;
|
||||
|
||||
@@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
MessageId,
|
||||
CommandId,
|
||||
DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
ProjectId,
|
||||
ThreadId,
|
||||
type OrchestrationCommand,
|
||||
@@ -50,6 +51,8 @@ const readModel: OrchestrationReadModel = {
|
||||
projectId: ProjectId.makeUnsafe("project-a"),
|
||||
title: "Thread A",
|
||||
model: "gpt-5-codex",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "full-access",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt: now,
|
||||
@@ -58,6 +61,7 @@ const readModel: OrchestrationReadModel = {
|
||||
messages: [],
|
||||
session: null,
|
||||
activities: [],
|
||||
proposedPlans: [],
|
||||
checkpoints: [],
|
||||
deletedAt: null,
|
||||
},
|
||||
@@ -66,6 +70,8 @@ const readModel: OrchestrationReadModel = {
|
||||
projectId: ProjectId.makeUnsafe("project-b"),
|
||||
title: "Thread B",
|
||||
model: "gpt-5-codex",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "full-access",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt: now,
|
||||
@@ -74,6 +80,7 @@ const readModel: OrchestrationReadModel = {
|
||||
messages: [],
|
||||
session: null,
|
||||
activities: [],
|
||||
proposedPlans: [],
|
||||
checkpoints: [],
|
||||
deletedAt: null,
|
||||
},
|
||||
@@ -90,8 +97,8 @@ const messageSendCommand: OrchestrationCommand = {
|
||||
text: "hello",
|
||||
attachments: [],
|
||||
},
|
||||
approvalPolicy: "on-request",
|
||||
sandboxMode: "workspace-write",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
createdAt: now,
|
||||
};
|
||||
|
||||
@@ -138,6 +145,8 @@ describe("commandInvariants", () => {
|
||||
projectId: ProjectId.makeUnsafe("project-a"),
|
||||
title: "new",
|
||||
model: "gpt-5-codex",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "full-access",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt: now,
|
||||
@@ -157,6 +166,8 @@ describe("commandInvariants", () => {
|
||||
projectId: ProjectId.makeUnsafe("project-a"),
|
||||
title: "dup",
|
||||
model: "gpt-5-codex",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "full-access",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt: now,
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
import { CommandId, EventId, MessageId, ProjectId, ThreadId } from "@t3tools/contracts";
|
||||
import {
|
||||
CommandId,
|
||||
DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
EventId,
|
||||
MessageId,
|
||||
ProjectId,
|
||||
ThreadId,
|
||||
} from "@t3tools/contracts";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { Effect } from "effect";
|
||||
|
||||
@@ -130,6 +137,8 @@ describe("decider project scripts", () => {
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Thread",
|
||||
model: "gpt-5-codex",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt: now,
|
||||
@@ -150,10 +159,16 @@ describe("decider project scripts", () => {
|
||||
text: "hello",
|
||||
attachments: [],
|
||||
},
|
||||
model: "gpt-5",
|
||||
effort: "high",
|
||||
approvalPolicy: "on-request",
|
||||
sandboxMode: "workspace-write",
|
||||
provider: "codex",
|
||||
model: "gpt-5.3-codex",
|
||||
modelOptions: {
|
||||
codex: {
|
||||
reasoningEffort: "high",
|
||||
fastMode: true,
|
||||
},
|
||||
},
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
createdAt: now,
|
||||
},
|
||||
readModel,
|
||||
@@ -174,10 +189,173 @@ describe("decider project scripts", () => {
|
||||
expect(turnStartEvent.payload).toMatchObject({
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
messageId: asMessageId("message-user-1"),
|
||||
model: "gpt-5",
|
||||
effort: "high",
|
||||
approvalPolicy: "on-request",
|
||||
sandboxMode: "workspace-write",
|
||||
provider: "codex",
|
||||
model: "gpt-5.3-codex",
|
||||
modelOptions: {
|
||||
codex: {
|
||||
reasoningEffort: "high",
|
||||
fastMode: true,
|
||||
},
|
||||
},
|
||||
runtimeMode: "approval-required",
|
||||
});
|
||||
});
|
||||
|
||||
it("emits thread.runtime-mode-set from thread.runtime-mode.set", async () => {
|
||||
const now = new Date().toISOString();
|
||||
const initial = createEmptyReadModel(now);
|
||||
const withProject = await Effect.runPromise(
|
||||
projectEvent(initial, {
|
||||
sequence: 1,
|
||||
eventId: asEventId("evt-project-create"),
|
||||
aggregateKind: "project",
|
||||
aggregateId: asProjectId("project-1"),
|
||||
type: "project.created",
|
||||
occurredAt: now,
|
||||
commandId: CommandId.makeUnsafe("cmd-project-create"),
|
||||
causationEventId: null,
|
||||
correlationId: CommandId.makeUnsafe("cmd-project-create"),
|
||||
metadata: {},
|
||||
payload: {
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Project",
|
||||
workspaceRoot: "/tmp/project",
|
||||
defaultModel: null,
|
||||
scripts: [],
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
},
|
||||
}),
|
||||
);
|
||||
const readModel = await Effect.runPromise(
|
||||
projectEvent(withProject, {
|
||||
sequence: 2,
|
||||
eventId: asEventId("evt-thread-create"),
|
||||
aggregateKind: "thread",
|
||||
aggregateId: ThreadId.makeUnsafe("thread-1"),
|
||||
type: "thread.created",
|
||||
occurredAt: now,
|
||||
commandId: CommandId.makeUnsafe("cmd-thread-create"),
|
||||
causationEventId: null,
|
||||
correlationId: CommandId.makeUnsafe("cmd-thread-create"),
|
||||
metadata: {},
|
||||
payload: {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Thread",
|
||||
model: "gpt-5-codex",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "full-access",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
const result = await Effect.runPromise(
|
||||
decideOrchestrationCommand({
|
||||
command: {
|
||||
type: "thread.runtime-mode.set",
|
||||
commandId: CommandId.makeUnsafe("cmd-runtime-mode-set"),
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
runtimeMode: "approval-required",
|
||||
createdAt: now,
|
||||
},
|
||||
readModel,
|
||||
}),
|
||||
);
|
||||
|
||||
const singleResult = Array.isArray(result) ? null : result;
|
||||
if (singleResult === null) {
|
||||
throw new Error("Expected a single runtime-mode-set event.");
|
||||
}
|
||||
expect(singleResult).toMatchObject({
|
||||
type: "thread.runtime-mode-set",
|
||||
payload: {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
runtimeMode: "approval-required",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("emits thread.interaction-mode-set from thread.interaction-mode.set", async () => {
|
||||
const now = new Date().toISOString();
|
||||
const initial = createEmptyReadModel(now);
|
||||
const withProject = await Effect.runPromise(
|
||||
projectEvent(initial, {
|
||||
sequence: 1,
|
||||
eventId: asEventId("evt-project-create"),
|
||||
aggregateKind: "project",
|
||||
aggregateId: asProjectId("project-1"),
|
||||
type: "project.created",
|
||||
occurredAt: now,
|
||||
commandId: CommandId.makeUnsafe("cmd-project-create"),
|
||||
causationEventId: null,
|
||||
correlationId: CommandId.makeUnsafe("cmd-project-create"),
|
||||
metadata: {},
|
||||
payload: {
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Project",
|
||||
workspaceRoot: "/tmp/project",
|
||||
defaultModel: null,
|
||||
scripts: [],
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
},
|
||||
}),
|
||||
);
|
||||
const readModel = await Effect.runPromise(
|
||||
projectEvent(withProject, {
|
||||
sequence: 2,
|
||||
eventId: asEventId("evt-thread-create"),
|
||||
aggregateKind: "thread",
|
||||
aggregateId: ThreadId.makeUnsafe("thread-1"),
|
||||
type: "thread.created",
|
||||
occurredAt: now,
|
||||
commandId: CommandId.makeUnsafe("cmd-thread-create"),
|
||||
causationEventId: null,
|
||||
correlationId: CommandId.makeUnsafe("cmd-thread-create"),
|
||||
metadata: {},
|
||||
payload: {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
projectId: asProjectId("project-1"),
|
||||
title: "Thread",
|
||||
model: "gpt-5-codex",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
const result = await Effect.runPromise(
|
||||
decideOrchestrationCommand({
|
||||
command: {
|
||||
type: "thread.interaction-mode.set",
|
||||
commandId: CommandId.makeUnsafe("cmd-interaction-mode-set"),
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
interactionMode: "plan",
|
||||
createdAt: now,
|
||||
},
|
||||
readModel,
|
||||
}),
|
||||
);
|
||||
|
||||
const singleResult = Array.isArray(result) ? null : result;
|
||||
if (singleResult === null) {
|
||||
throw new Error("Expected a single interaction-mode-set event.");
|
||||
}
|
||||
expect(singleResult).toMatchObject({
|
||||
type: "thread.interaction-mode-set",
|
||||
payload: {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
interactionMode: "plan",
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -157,6 +157,8 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
projectId: command.projectId,
|
||||
title: command.title,
|
||||
model: command.model,
|
||||
runtimeMode: command.runtimeMode,
|
||||
interactionMode: command.interactionMode,
|
||||
branch: command.branch,
|
||||
worktreePath: command.worktreePath,
|
||||
createdAt: command.createdAt,
|
||||
@@ -213,6 +215,52 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
};
|
||||
}
|
||||
|
||||
case "thread.runtime-mode.set": {
|
||||
yield* requireThread({
|
||||
readModel,
|
||||
command,
|
||||
threadId: command.threadId,
|
||||
});
|
||||
const occurredAt = nowIso();
|
||||
return {
|
||||
...withEventBase({
|
||||
aggregateKind: "thread",
|
||||
aggregateId: command.threadId,
|
||||
occurredAt,
|
||||
commandId: command.commandId,
|
||||
}),
|
||||
type: "thread.runtime-mode-set",
|
||||
payload: {
|
||||
threadId: command.threadId,
|
||||
runtimeMode: command.runtimeMode,
|
||||
updatedAt: occurredAt,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
case "thread.interaction-mode.set": {
|
||||
yield* requireThread({
|
||||
readModel,
|
||||
command,
|
||||
threadId: command.threadId,
|
||||
});
|
||||
const occurredAt = nowIso();
|
||||
return {
|
||||
...withEventBase({
|
||||
aggregateKind: "thread",
|
||||
aggregateId: command.threadId,
|
||||
occurredAt,
|
||||
commandId: command.commandId,
|
||||
}),
|
||||
type: "thread.interaction-mode-set",
|
||||
payload: {
|
||||
threadId: command.threadId,
|
||||
interactionMode: command.interactionMode,
|
||||
updatedAt: occurredAt,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
case "thread.turn.start": {
|
||||
yield* requireThread({
|
||||
readModel,
|
||||
@@ -251,11 +299,16 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
payload: {
|
||||
threadId: command.threadId,
|
||||
messageId: command.message.messageId,
|
||||
...(command.provider !== undefined ? { provider: command.provider } : {}),
|
||||
...(command.model !== undefined ? { model: command.model } : {}),
|
||||
...(command.effort !== undefined ? { effort: command.effort } : {}),
|
||||
...(command.modelOptions !== undefined ? { modelOptions: command.modelOptions } : {}),
|
||||
assistantDeliveryMode: command.assistantDeliveryMode ?? DEFAULT_ASSISTANT_DELIVERY_MODE,
|
||||
approvalPolicy: command.approvalPolicy,
|
||||
sandboxMode: command.sandboxMode,
|
||||
runtimeMode:
|
||||
readModel.threads.find((entry) => entry.id === command.threadId)?.runtimeMode ??
|
||||
command.runtimeMode,
|
||||
interactionMode:
|
||||
readModel.threads.find((entry) => entry.id === command.threadId)?.interactionMode ??
|
||||
command.interactionMode,
|
||||
createdAt: command.createdAt,
|
||||
},
|
||||
};
|
||||
@@ -310,6 +363,32 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
};
|
||||
}
|
||||
|
||||
case "thread.user-input.respond": {
|
||||
yield* requireThread({
|
||||
readModel,
|
||||
command,
|
||||
threadId: command.threadId,
|
||||
});
|
||||
return {
|
||||
...withEventBase({
|
||||
aggregateKind: "thread",
|
||||
aggregateId: command.threadId,
|
||||
occurredAt: command.createdAt,
|
||||
commandId: command.commandId,
|
||||
metadata: {
|
||||
requestId: command.requestId,
|
||||
},
|
||||
}),
|
||||
type: "thread.user-input-response-requested",
|
||||
payload: {
|
||||
threadId: command.threadId,
|
||||
requestId: command.requestId,
|
||||
answers: command.answers,
|
||||
createdAt: command.createdAt,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
case "thread.checkpoint.revert": {
|
||||
yield* requireThread({
|
||||
readModel,
|
||||
@@ -365,14 +444,7 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
aggregateId: command.threadId,
|
||||
occurredAt: command.createdAt,
|
||||
commandId: command.commandId,
|
||||
metadata: {
|
||||
...(command.session.providerSessionId !== null
|
||||
? { providerSessionId: command.session.providerSessionId }
|
||||
: {}),
|
||||
...(command.session.providerThreadId !== null
|
||||
? { providerThreadId: command.session.providerThreadId }
|
||||
: {}),
|
||||
},
|
||||
metadata: {},
|
||||
}),
|
||||
type: "thread.session-set",
|
||||
payload: {
|
||||
@@ -436,6 +508,27 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
|
||||
};
|
||||
}
|
||||
|
||||
case "thread.proposed-plan.upsert": {
|
||||
yield* requireThread({
|
||||
readModel,
|
||||
command,
|
||||
threadId: command.threadId,
|
||||
});
|
||||
return {
|
||||
...withEventBase({
|
||||
aggregateKind: "thread",
|
||||
aggregateId: command.threadId,
|
||||
occurredAt: command.createdAt,
|
||||
commandId: command.commandId,
|
||||
}),
|
||||
type: "thread.proposed-plan-upserted",
|
||||
payload: {
|
||||
threadId: command.threadId,
|
||||
proposedPlan: command.proposedPlan,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
case "thread.turn.diff.complete": {
|
||||
yield* requireThread({
|
||||
readModel,
|
||||
|
||||
@@ -57,6 +57,7 @@ describe("orchestration projector", () => {
|
||||
projectId: "project-1",
|
||||
title: "demo",
|
||||
model: "gpt-5-codex",
|
||||
runtimeMode: "full-access",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt: now,
|
||||
@@ -73,6 +74,8 @@ describe("orchestration projector", () => {
|
||||
projectId: "project-1",
|
||||
title: "demo",
|
||||
model: "gpt-5-codex",
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: "default",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
latestTurn: null,
|
||||
@@ -80,6 +83,7 @@ describe("orchestration projector", () => {
|
||||
updatedAt: now,
|
||||
deletedAt: null,
|
||||
messages: [],
|
||||
proposedPlans: [],
|
||||
activities: [],
|
||||
checkpoints: [],
|
||||
session: null,
|
||||
@@ -135,8 +139,7 @@ describe("orchestration projector", () => {
|
||||
payload: {
|
||||
threadId: "thread-1",
|
||||
messageId: "message-1",
|
||||
approvalPolicy: "on-request",
|
||||
sandboxMode: "workspace-write",
|
||||
runtimeMode: "approval-required",
|
||||
createdAt: "2026-01-01T00:00:00.000Z",
|
||||
},
|
||||
}),
|
||||
@@ -168,6 +171,7 @@ describe("orchestration projector", () => {
|
||||
projectId: "project-1",
|
||||
title: "demo",
|
||||
model: "gpt-5.3-codex",
|
||||
runtimeMode: "full-access",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt,
|
||||
@@ -195,8 +199,7 @@ describe("orchestration projector", () => {
|
||||
providerName: "codex",
|
||||
providerSessionId: "session-1",
|
||||
providerThreadId: "provider-thread-1",
|
||||
approvalPolicy: "on-request",
|
||||
sandboxMode: "workspace-write",
|
||||
runtimeMode: "approval-required",
|
||||
activeTurnId: "turn-1",
|
||||
lastError: null,
|
||||
updatedAt: startedAt,
|
||||
@@ -211,6 +214,59 @@ describe("orchestration projector", () => {
|
||||
expect(thread?.session?.status).toBe("running");
|
||||
});
|
||||
|
||||
it("updates canonical thread runtime mode from thread.runtime-mode-set", async () => {
|
||||
const createdAt = "2026-02-23T08:00:00.000Z";
|
||||
const updatedAt = "2026-02-23T08:00:05.000Z";
|
||||
const model = createEmptyReadModel(createdAt);
|
||||
|
||||
const afterCreate = await Effect.runPromise(
|
||||
projectEvent(
|
||||
model,
|
||||
makeEvent({
|
||||
sequence: 1,
|
||||
type: "thread.created",
|
||||
aggregateKind: "thread",
|
||||
aggregateId: "thread-1",
|
||||
occurredAt: createdAt,
|
||||
commandId: "cmd-create",
|
||||
payload: {
|
||||
threadId: "thread-1",
|
||||
projectId: "project-1",
|
||||
title: "demo",
|
||||
model: "gpt-5.3-codex",
|
||||
runtimeMode: "full-access",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt,
|
||||
updatedAt: createdAt,
|
||||
},
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
const afterUpdate = await Effect.runPromise(
|
||||
projectEvent(
|
||||
afterCreate,
|
||||
makeEvent({
|
||||
sequence: 2,
|
||||
type: "thread.runtime-mode-set",
|
||||
aggregateKind: "thread",
|
||||
aggregateId: "thread-1",
|
||||
occurredAt: updatedAt,
|
||||
commandId: "cmd-runtime-mode-set",
|
||||
payload: {
|
||||
threadId: "thread-1",
|
||||
runtimeMode: "approval-required",
|
||||
updatedAt,
|
||||
},
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
expect(afterUpdate.threads[0]?.runtimeMode).toBe("approval-required");
|
||||
expect(afterUpdate.threads[0]?.updatedAt).toBe(updatedAt);
|
||||
});
|
||||
|
||||
it("marks assistant messages completed with non-streaming updates", async () => {
|
||||
const createdAt = "2026-02-23T09:00:00.000Z";
|
||||
const deltaAt = "2026-02-23T09:00:01.000Z";
|
||||
@@ -232,6 +288,7 @@ describe("orchestration projector", () => {
|
||||
projectId: "project-1",
|
||||
title: "demo",
|
||||
model: "gpt-5.3-codex",
|
||||
runtimeMode: "full-access",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt,
|
||||
@@ -315,6 +372,7 @@ describe("orchestration projector", () => {
|
||||
projectId: "project-1",
|
||||
title: "demo",
|
||||
model: "gpt-5.3-codex",
|
||||
runtimeMode: "full-access",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt,
|
||||
@@ -526,6 +584,7 @@ describe("orchestration projector", () => {
|
||||
projectId: "project-1",
|
||||
title: "demo",
|
||||
model: "gpt-5.3-codex",
|
||||
runtimeMode: "full-access",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt,
|
||||
@@ -675,6 +734,7 @@ describe("orchestration projector", () => {
|
||||
projectId: "project-1",
|
||||
title: "capped",
|
||||
model: "gpt-5-codex",
|
||||
runtimeMode: "full-access",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt,
|
||||
|
||||
@@ -16,7 +16,10 @@ import {
|
||||
ThreadActivityAppendedPayload,
|
||||
ThreadCreatedPayload,
|
||||
ThreadDeletedPayload,
|
||||
ThreadInteractionModeSetPayload,
|
||||
ThreadMetaUpdatedPayload,
|
||||
ThreadProposedPlanUpsertedPayload,
|
||||
ThreadRuntimeModeSetPayload,
|
||||
ThreadRevertedPayload,
|
||||
ThreadSessionSetPayload,
|
||||
ThreadTurnDiffCompletedPayload,
|
||||
@@ -124,6 +127,32 @@ function retainThreadActivitiesAfterRevert(
|
||||
);
|
||||
}
|
||||
|
||||
function retainThreadProposedPlansAfterRevert(
|
||||
proposedPlans: ReadonlyArray<OrchestrationThread["proposedPlans"][number]>,
|
||||
retainedTurnIds: ReadonlySet<string>,
|
||||
): ReadonlyArray<OrchestrationThread["proposedPlans"][number]> {
|
||||
return proposedPlans.filter(
|
||||
(proposedPlan) => proposedPlan.turnId === null || retainedTurnIds.has(proposedPlan.turnId),
|
||||
);
|
||||
}
|
||||
|
||||
function compareThreadActivities(
|
||||
left: OrchestrationThread["activities"][number],
|
||||
right: OrchestrationThread["activities"][number],
|
||||
): number {
|
||||
if (left.sequence !== undefined && right.sequence !== undefined) {
|
||||
if (left.sequence !== right.sequence) {
|
||||
return left.sequence - right.sequence;
|
||||
}
|
||||
} else if (left.sequence !== undefined) {
|
||||
return 1;
|
||||
} else if (right.sequence !== undefined) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return left.createdAt.localeCompare(right.createdAt) || left.id.localeCompare(right.id);
|
||||
}
|
||||
|
||||
export function createEmptyReadModel(nowIso: string): OrchestrationReadModel {
|
||||
return {
|
||||
snapshotSequence: 0,
|
||||
@@ -224,6 +253,8 @@ export function projectEvent(
|
||||
projectId: payload.projectId,
|
||||
title: payload.title,
|
||||
model: payload.model,
|
||||
runtimeMode: payload.runtimeMode,
|
||||
interactionMode: payload.interactionMode,
|
||||
branch: payload.branch,
|
||||
worktreePath: payload.worktreePath,
|
||||
latestTurn: null,
|
||||
@@ -272,6 +303,38 @@ export function projectEvent(
|
||||
})),
|
||||
);
|
||||
|
||||
case "thread.runtime-mode-set":
|
||||
return decodeForEvent(
|
||||
ThreadRuntimeModeSetPayload,
|
||||
event.payload,
|
||||
event.type,
|
||||
"payload",
|
||||
).pipe(
|
||||
Effect.map((payload) => ({
|
||||
...nextBase,
|
||||
threads: updateThread(nextBase.threads, payload.threadId, {
|
||||
runtimeMode: payload.runtimeMode,
|
||||
updatedAt: payload.updatedAt,
|
||||
}),
|
||||
})),
|
||||
);
|
||||
|
||||
case "thread.interaction-mode-set":
|
||||
return decodeForEvent(
|
||||
ThreadInteractionModeSetPayload,
|
||||
event.payload,
|
||||
event.type,
|
||||
"payload",
|
||||
).pipe(
|
||||
Effect.map((payload) => ({
|
||||
...nextBase,
|
||||
threads: updateThread(nextBase.threads, payload.threadId, {
|
||||
interactionMode: payload.interactionMode,
|
||||
updatedAt: payload.updatedAt,
|
||||
}),
|
||||
})),
|
||||
);
|
||||
|
||||
case "thread.message-sent":
|
||||
return Effect.gen(function* () {
|
||||
const payload = yield* decodeForEvent(
|
||||
@@ -382,6 +445,38 @@ export function projectEvent(
|
||||
};
|
||||
});
|
||||
|
||||
case "thread.proposed-plan-upserted":
|
||||
return Effect.gen(function* () {
|
||||
const payload = yield* decodeForEvent(
|
||||
ThreadProposedPlanUpsertedPayload,
|
||||
event.payload,
|
||||
event.type,
|
||||
"payload",
|
||||
);
|
||||
const thread = nextBase.threads.find((entry) => entry.id === payload.threadId);
|
||||
if (!thread) {
|
||||
return nextBase;
|
||||
}
|
||||
|
||||
const proposedPlans = [
|
||||
...thread.proposedPlans.filter((entry) => entry.id !== payload.proposedPlan.id),
|
||||
payload.proposedPlan,
|
||||
]
|
||||
.toSorted(
|
||||
(left, right) =>
|
||||
left.createdAt.localeCompare(right.createdAt) || left.id.localeCompare(right.id),
|
||||
)
|
||||
.slice(-200);
|
||||
|
||||
return {
|
||||
...nextBase,
|
||||
threads: updateThread(nextBase.threads, payload.threadId, {
|
||||
proposedPlans,
|
||||
updatedAt: event.occurredAt,
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
case "thread.turn-diff-completed":
|
||||
return Effect.gen(function* () {
|
||||
const payload = yield* decodeForEvent(
|
||||
@@ -458,6 +553,10 @@ export function projectEvent(
|
||||
retainedTurnIds,
|
||||
payload.turnCount,
|
||||
).slice(-MAX_THREAD_MESSAGES);
|
||||
const proposedPlans = retainThreadProposedPlansAfterRevert(
|
||||
thread.proposedPlans,
|
||||
retainedTurnIds,
|
||||
).slice(-200);
|
||||
const activities = retainThreadActivitiesAfterRevert(thread.activities, retainedTurnIds);
|
||||
|
||||
const latestCheckpoint = checkpoints.at(-1) ?? null;
|
||||
@@ -478,6 +577,7 @@ export function projectEvent(
|
||||
threads: updateThread(nextBase.threads, payload.threadId, {
|
||||
checkpoints,
|
||||
messages,
|
||||
proposedPlans,
|
||||
activities,
|
||||
latestTurn,
|
||||
updatedAt: event.occurredAt,
|
||||
@@ -503,7 +603,7 @@ export function projectEvent(
|
||||
...thread.activities.filter((entry) => entry.id !== payload.activity.id),
|
||||
payload.activity,
|
||||
]
|
||||
.toSorted((left, right) => left.createdAt.localeCompare(right.createdAt))
|
||||
.toSorted(compareThreadActivities)
|
||||
.slice(-500);
|
||||
|
||||
return {
|
||||
|
||||
@@ -74,8 +74,6 @@ function inferActorKind(
|
||||
return "server";
|
||||
}
|
||||
if (
|
||||
event.metadata.providerSessionId !== undefined ||
|
||||
event.metadata.providerThreadId !== undefined ||
|
||||
event.metadata.providerTurnId !== undefined ||
|
||||
event.metadata.providerItemId !== undefined ||
|
||||
event.metadata.adapterKey !== undefined
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import * as SqlClient from "effect/unstable/sql/SqlClient";
|
||||
import * as SqlSchema from "effect/unstable/sql/SqlSchema";
|
||||
import { NonNegativeInt } from "@t3tools/contracts";
|
||||
import { Effect, Layer, Schema, Struct } from "effect";
|
||||
|
||||
import { toPersistenceDecodeError, toPersistenceSqlError } from "../Errors.ts";
|
||||
@@ -15,6 +16,7 @@ import {
|
||||
const ProjectionThreadActivityDbRowSchema = ProjectionThreadActivity.mapFields(
|
||||
Struct.assign({
|
||||
payload: Schema.fromJsonString(Schema.Unknown),
|
||||
sequence: Schema.NullOr(NonNegativeInt),
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -29,7 +31,7 @@ const makeProjectionThreadActivityRepository = Effect.gen(function* () {
|
||||
const sql = yield* SqlClient.SqlClient;
|
||||
|
||||
const upsertProjectionThreadActivityRow = SqlSchema.void({
|
||||
Request: ProjectionThreadActivityDbRowSchema,
|
||||
Request: ProjectionThreadActivity,
|
||||
execute: (row) =>
|
||||
sql`
|
||||
INSERT INTO projection_thread_activities (
|
||||
@@ -40,6 +42,7 @@ const makeProjectionThreadActivityRepository = Effect.gen(function* () {
|
||||
kind,
|
||||
summary,
|
||||
payload_json,
|
||||
sequence,
|
||||
created_at
|
||||
)
|
||||
VALUES (
|
||||
@@ -49,7 +52,8 @@ const makeProjectionThreadActivityRepository = Effect.gen(function* () {
|
||||
${row.tone},
|
||||
${row.kind},
|
||||
${row.summary},
|
||||
${row.payload},
|
||||
${JSON.stringify(row.payload)},
|
||||
${row.sequence ?? null},
|
||||
${row.createdAt}
|
||||
)
|
||||
ON CONFLICT (activity_id)
|
||||
@@ -60,6 +64,7 @@ const makeProjectionThreadActivityRepository = Effect.gen(function* () {
|
||||
kind = excluded.kind,
|
||||
summary = excluded.summary,
|
||||
payload_json = excluded.payload_json,
|
||||
sequence = excluded.sequence,
|
||||
created_at = excluded.created_at
|
||||
`,
|
||||
});
|
||||
@@ -77,10 +82,15 @@ const makeProjectionThreadActivityRepository = Effect.gen(function* () {
|
||||
kind,
|
||||
summary,
|
||||
payload_json AS "payload",
|
||||
sequence,
|
||||
created_at AS "createdAt"
|
||||
FROM projection_thread_activities
|
||||
WHERE thread_id = ${threadId}
|
||||
ORDER BY created_at ASC, activity_id ASC
|
||||
ORDER BY
|
||||
CASE WHEN sequence IS NULL THEN 0 ELSE 1 END ASC,
|
||||
sequence ASC,
|
||||
created_at ASC,
|
||||
activity_id ASC
|
||||
`,
|
||||
});
|
||||
|
||||
@@ -111,8 +121,18 @@ const makeProjectionThreadActivityRepository = Effect.gen(function* () {
|
||||
"ProjectionThreadActivityRepository.listByThreadId:decodeRows",
|
||||
),
|
||||
),
|
||||
Effect.map(
|
||||
(rows) => rows as ReadonlyArray<Schema.Schema.Type<typeof ProjectionThreadActivity>>,
|
||||
Effect.map((rows) =>
|
||||
rows.map((row) => ({
|
||||
activityId: row.activityId,
|
||||
threadId: row.threadId,
|
||||
turnId: row.turnId,
|
||||
tone: row.tone,
|
||||
kind: row.kind,
|
||||
summary: row.summary,
|
||||
payload: row.payload,
|
||||
...(row.sequence !== null ? { sequence: row.sequence } : {}),
|
||||
createdAt: row.createdAt,
|
||||
})),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
import { Effect, Layer } from "effect";
|
||||
import * as SqlClient from "effect/unstable/sql/SqlClient";
|
||||
import * as SqlSchema from "effect/unstable/sql/SqlSchema";
|
||||
|
||||
import { toPersistenceSqlError } from "../Errors.ts";
|
||||
import {
|
||||
DeleteProjectionThreadProposedPlansInput,
|
||||
ListProjectionThreadProposedPlansInput,
|
||||
ProjectionThreadProposedPlan,
|
||||
ProjectionThreadProposedPlanRepository,
|
||||
type ProjectionThreadProposedPlanRepositoryShape,
|
||||
} from "../Services/ProjectionThreadProposedPlans.ts";
|
||||
|
||||
const makeProjectionThreadProposedPlanRepository = Effect.gen(function* () {
|
||||
const sql = yield* SqlClient.SqlClient;
|
||||
|
||||
const upsertProjectionThreadProposedPlanRow = SqlSchema.void({
|
||||
Request: ProjectionThreadProposedPlan,
|
||||
execute: (row) => sql`
|
||||
INSERT INTO projection_thread_proposed_plans (
|
||||
plan_id,
|
||||
thread_id,
|
||||
turn_id,
|
||||
plan_markdown,
|
||||
created_at,
|
||||
updated_at
|
||||
)
|
||||
VALUES (
|
||||
${row.planId},
|
||||
${row.threadId},
|
||||
${row.turnId},
|
||||
${row.planMarkdown},
|
||||
${row.createdAt},
|
||||
${row.updatedAt}
|
||||
)
|
||||
ON CONFLICT (plan_id)
|
||||
DO UPDATE SET
|
||||
thread_id = excluded.thread_id,
|
||||
turn_id = excluded.turn_id,
|
||||
plan_markdown = excluded.plan_markdown,
|
||||
created_at = excluded.created_at,
|
||||
updated_at = excluded.updated_at
|
||||
`,
|
||||
});
|
||||
|
||||
const listProjectionThreadProposedPlanRows = SqlSchema.findAll({
|
||||
Request: ListProjectionThreadProposedPlansInput,
|
||||
Result: ProjectionThreadProposedPlan,
|
||||
execute: ({ threadId }) => sql`
|
||||
SELECT
|
||||
plan_id AS "planId",
|
||||
thread_id AS "threadId",
|
||||
turn_id AS "turnId",
|
||||
plan_markdown AS "planMarkdown",
|
||||
created_at AS "createdAt",
|
||||
updated_at AS "updatedAt"
|
||||
FROM projection_thread_proposed_plans
|
||||
WHERE thread_id = ${threadId}
|
||||
ORDER BY created_at ASC, plan_id ASC
|
||||
`,
|
||||
});
|
||||
|
||||
const deleteProjectionThreadProposedPlanRows = SqlSchema.void({
|
||||
Request: DeleteProjectionThreadProposedPlansInput,
|
||||
execute: ({ threadId }) => sql`
|
||||
DELETE FROM projection_thread_proposed_plans
|
||||
WHERE thread_id = ${threadId}
|
||||
`,
|
||||
});
|
||||
|
||||
const upsert: ProjectionThreadProposedPlanRepositoryShape["upsert"] = (row) =>
|
||||
upsertProjectionThreadProposedPlanRow(row).pipe(
|
||||
Effect.mapError(
|
||||
toPersistenceSqlError("ProjectionThreadProposedPlanRepository.upsert:query"),
|
||||
),
|
||||
);
|
||||
|
||||
const listByThreadId: ProjectionThreadProposedPlanRepositoryShape["listByThreadId"] = (input) =>
|
||||
listProjectionThreadProposedPlanRows(input).pipe(
|
||||
Effect.mapError(
|
||||
toPersistenceSqlError("ProjectionThreadProposedPlanRepository.listByThreadId:query"),
|
||||
),
|
||||
);
|
||||
|
||||
const deleteByThreadId: ProjectionThreadProposedPlanRepositoryShape["deleteByThreadId"] = (
|
||||
input,
|
||||
) =>
|
||||
deleteProjectionThreadProposedPlanRows(input).pipe(
|
||||
Effect.mapError(
|
||||
toPersistenceSqlError("ProjectionThreadProposedPlanRepository.deleteByThreadId:query"),
|
||||
),
|
||||
);
|
||||
|
||||
return {
|
||||
upsert,
|
||||
listByThreadId,
|
||||
deleteByThreadId,
|
||||
} satisfies ProjectionThreadProposedPlanRepositoryShape;
|
||||
});
|
||||
|
||||
export const ProjectionThreadProposedPlanRepositoryLive = Layer.effect(
|
||||
ProjectionThreadProposedPlanRepository,
|
||||
makeProjectionThreadProposedPlanRepository,
|
||||
);
|
||||
@@ -23,10 +23,7 @@ const makeProjectionThreadSessionRepository = Effect.gen(function* () {
|
||||
thread_id,
|
||||
status,
|
||||
provider_name,
|
||||
provider_session_id,
|
||||
provider_thread_id,
|
||||
approval_policy,
|
||||
sandbox_mode,
|
||||
runtime_mode,
|
||||
active_turn_id,
|
||||
last_error,
|
||||
updated_at
|
||||
@@ -35,10 +32,7 @@ const makeProjectionThreadSessionRepository = Effect.gen(function* () {
|
||||
${row.threadId},
|
||||
${row.status},
|
||||
${row.providerName},
|
||||
${row.providerSessionId},
|
||||
${row.providerThreadId},
|
||||
${row.approvalPolicy},
|
||||
${row.sandboxMode},
|
||||
${row.runtimeMode},
|
||||
${row.activeTurnId},
|
||||
${row.lastError},
|
||||
${row.updatedAt}
|
||||
@@ -47,10 +41,7 @@ const makeProjectionThreadSessionRepository = Effect.gen(function* () {
|
||||
DO UPDATE SET
|
||||
status = excluded.status,
|
||||
provider_name = excluded.provider_name,
|
||||
provider_session_id = excluded.provider_session_id,
|
||||
provider_thread_id = excluded.provider_thread_id,
|
||||
approval_policy = excluded.approval_policy,
|
||||
sandbox_mode = excluded.sandbox_mode,
|
||||
runtime_mode = excluded.runtime_mode,
|
||||
active_turn_id = excluded.active_turn_id,
|
||||
last_error = excluded.last_error,
|
||||
updated_at = excluded.updated_at
|
||||
@@ -66,10 +57,7 @@ const makeProjectionThreadSessionRepository = Effect.gen(function* () {
|
||||
thread_id AS "threadId",
|
||||
status,
|
||||
provider_name AS "providerName",
|
||||
provider_session_id AS "providerSessionId",
|
||||
provider_thread_id AS "providerThreadId",
|
||||
approval_policy AS "approvalPolicy",
|
||||
sandbox_mode AS "sandboxMode",
|
||||
runtime_mode AS "runtimeMode",
|
||||
active_turn_id AS "activeTurnId",
|
||||
last_error AS "lastError",
|
||||
updated_at AS "updatedAt"
|
||||
|
||||
@@ -24,6 +24,8 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
||||
project_id,
|
||||
title,
|
||||
model,
|
||||
runtime_mode,
|
||||
interaction_mode,
|
||||
branch,
|
||||
worktree_path,
|
||||
latest_turn_id,
|
||||
@@ -36,6 +38,8 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
||||
${row.projectId},
|
||||
${row.title},
|
||||
${row.model},
|
||||
${row.runtimeMode},
|
||||
${row.interactionMode},
|
||||
${row.branch},
|
||||
${row.worktreePath},
|
||||
${row.latestTurnId},
|
||||
@@ -48,6 +52,8 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
||||
project_id = excluded.project_id,
|
||||
title = excluded.title,
|
||||
model = excluded.model,
|
||||
runtime_mode = excluded.runtime_mode,
|
||||
interaction_mode = excluded.interaction_mode,
|
||||
branch = excluded.branch,
|
||||
worktree_path = excluded.worktree_path,
|
||||
latest_turn_id = excluded.latest_turn_id,
|
||||
@@ -67,6 +73,8 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
||||
project_id AS "projectId",
|
||||
title,
|
||||
model,
|
||||
runtime_mode AS "runtimeMode",
|
||||
interaction_mode AS "interactionMode",
|
||||
branch,
|
||||
worktree_path AS "worktreePath",
|
||||
latest_turn_id AS "latestTurnId",
|
||||
@@ -88,6 +96,8 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
|
||||
project_id AS "projectId",
|
||||
title,
|
||||
model,
|
||||
runtime_mode AS "runtimeMode",
|
||||
interaction_mode AS "interactionMode",
|
||||
branch,
|
||||
worktree_path AS "worktreePath",
|
||||
latest_turn_id AS "latestTurnId",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ProviderSessionId } from "@t3tools/contracts";
|
||||
import { ThreadId } from "@t3tools/contracts";
|
||||
import * as SqlClient from "effect/unstable/sql/SqlClient";
|
||||
import * as SqlSchema from "effect/unstable/sql/SqlSchema";
|
||||
import { Effect, Layer, Option, Schema, Struct } from "effect";
|
||||
@@ -24,7 +24,7 @@ const ProviderSessionRuntimeDbRowSchema = ProviderSessionRuntime.mapFields(
|
||||
const decodeRuntime = Schema.decodeUnknownEffect(ProviderSessionRuntime);
|
||||
|
||||
const GetRuntimeRequestSchema = Schema.Struct({
|
||||
providerSessionId: ProviderSessionId,
|
||||
threadId: ThreadId,
|
||||
});
|
||||
|
||||
const DeleteRuntimeRequestSchema = GetRuntimeRequestSchema;
|
||||
@@ -44,33 +44,30 @@ const makeProviderSessionRuntimeRepository = Effect.gen(function* () {
|
||||
execute: (runtime) =>
|
||||
sql`
|
||||
INSERT INTO provider_session_runtime (
|
||||
provider_session_id,
|
||||
thread_id,
|
||||
provider_name,
|
||||
adapter_key,
|
||||
provider_thread_id,
|
||||
runtime_mode,
|
||||
status,
|
||||
last_seen_at,
|
||||
resume_cursor_json,
|
||||
runtime_payload_json
|
||||
)
|
||||
VALUES (
|
||||
${runtime.providerSessionId},
|
||||
${runtime.threadId},
|
||||
${runtime.providerName},
|
||||
${runtime.adapterKey},
|
||||
${runtime.providerThreadId},
|
||||
${runtime.runtimeMode},
|
||||
${runtime.status},
|
||||
${runtime.lastSeenAt},
|
||||
${runtime.resumeCursor},
|
||||
${runtime.runtimePayload}
|
||||
)
|
||||
ON CONFLICT (provider_session_id)
|
||||
ON CONFLICT (thread_id)
|
||||
DO UPDATE SET
|
||||
thread_id = excluded.thread_id,
|
||||
provider_name = excluded.provider_name,
|
||||
adapter_key = excluded.adapter_key,
|
||||
provider_thread_id = excluded.provider_thread_id,
|
||||
runtime_mode = excluded.runtime_mode,
|
||||
status = excluded.status,
|
||||
last_seen_at = excluded.last_seen_at,
|
||||
resume_cursor_json = excluded.resume_cursor_json,
|
||||
@@ -78,23 +75,22 @@ const makeProviderSessionRuntimeRepository = Effect.gen(function* () {
|
||||
`,
|
||||
});
|
||||
|
||||
const getRuntimeRowBySessionId = SqlSchema.findOneOption({
|
||||
const getRuntimeRowByThreadId = SqlSchema.findOneOption({
|
||||
Request: GetRuntimeRequestSchema,
|
||||
Result: ProviderSessionRuntimeDbRowSchema,
|
||||
execute: ({ providerSessionId }) =>
|
||||
execute: ({ threadId }) =>
|
||||
sql`
|
||||
SELECT
|
||||
provider_session_id AS "providerSessionId",
|
||||
thread_id AS "threadId",
|
||||
provider_name AS "providerName",
|
||||
adapter_key AS "adapterKey",
|
||||
provider_thread_id AS "providerThreadId",
|
||||
runtime_mode AS "runtimeMode",
|
||||
status,
|
||||
last_seen_at AS "lastSeenAt",
|
||||
resume_cursor_json AS "resumeCursor",
|
||||
runtime_payload_json AS "runtimePayload"
|
||||
FROM provider_session_runtime
|
||||
WHERE provider_session_id = ${providerSessionId}
|
||||
WHERE thread_id = ${threadId}
|
||||
`,
|
||||
});
|
||||
|
||||
@@ -104,26 +100,25 @@ const makeProviderSessionRuntimeRepository = Effect.gen(function* () {
|
||||
execute: () =>
|
||||
sql`
|
||||
SELECT
|
||||
provider_session_id AS "providerSessionId",
|
||||
thread_id AS "threadId",
|
||||
provider_name AS "providerName",
|
||||
adapter_key AS "adapterKey",
|
||||
provider_thread_id AS "providerThreadId",
|
||||
runtime_mode AS "runtimeMode",
|
||||
status,
|
||||
last_seen_at AS "lastSeenAt",
|
||||
resume_cursor_json AS "resumeCursor",
|
||||
runtime_payload_json AS "runtimePayload"
|
||||
FROM provider_session_runtime
|
||||
ORDER BY last_seen_at ASC, provider_session_id ASC
|
||||
ORDER BY last_seen_at ASC, thread_id ASC
|
||||
`,
|
||||
});
|
||||
|
||||
const deleteRuntimeBySessionId = SqlSchema.void({
|
||||
const deleteRuntimeByThreadId = SqlSchema.void({
|
||||
Request: DeleteRuntimeRequestSchema,
|
||||
execute: ({ providerSessionId }) =>
|
||||
execute: ({ threadId }) =>
|
||||
sql`
|
||||
DELETE FROM provider_session_runtime
|
||||
WHERE provider_session_id = ${providerSessionId}
|
||||
WHERE thread_id = ${threadId}
|
||||
`,
|
||||
});
|
||||
|
||||
@@ -137,12 +132,12 @@ const makeProviderSessionRuntimeRepository = Effect.gen(function* () {
|
||||
),
|
||||
);
|
||||
|
||||
const getBySessionId: ProviderSessionRuntimeRepositoryShape["getBySessionId"] = (input) =>
|
||||
getRuntimeRowBySessionId(input).pipe(
|
||||
const getByThreadId: ProviderSessionRuntimeRepositoryShape["getByThreadId"] = (input) =>
|
||||
getRuntimeRowByThreadId(input).pipe(
|
||||
Effect.mapError(
|
||||
toPersistenceSqlOrDecodeError(
|
||||
"ProviderSessionRuntimeRepository.getBySessionId:query",
|
||||
"ProviderSessionRuntimeRepository.getBySessionId:decodeRow",
|
||||
"ProviderSessionRuntimeRepository.getByThreadId:query",
|
||||
"ProviderSessionRuntimeRepository.getByThreadId:decodeRow",
|
||||
),
|
||||
),
|
||||
Effect.flatMap((runtimeRowOption) =>
|
||||
@@ -152,7 +147,7 @@ const makeProviderSessionRuntimeRepository = Effect.gen(function* () {
|
||||
decodeRuntime(row).pipe(
|
||||
Effect.mapError(
|
||||
toPersistenceDecodeError(
|
||||
"ProviderSessionRuntimeRepository.getBySessionId:rowToRuntime",
|
||||
"ProviderSessionRuntimeRepository.getByThreadId:rowToRuntime",
|
||||
),
|
||||
),
|
||||
Effect.map((runtime) => Option.some(runtime)),
|
||||
@@ -183,18 +178,18 @@ const makeProviderSessionRuntimeRepository = Effect.gen(function* () {
|
||||
),
|
||||
);
|
||||
|
||||
const deleteBySessionId: ProviderSessionRuntimeRepositoryShape["deleteBySessionId"] = (input) =>
|
||||
deleteRuntimeBySessionId(input).pipe(
|
||||
const deleteByThreadId: ProviderSessionRuntimeRepositoryShape["deleteByThreadId"] = (input) =>
|
||||
deleteRuntimeByThreadId(input).pipe(
|
||||
Effect.mapError(
|
||||
toPersistenceSqlError("ProviderSessionRuntimeRepository.deleteBySessionId:query"),
|
||||
toPersistenceSqlError("ProviderSessionRuntimeRepository.deleteByThreadId:query"),
|
||||
),
|
||||
);
|
||||
|
||||
return {
|
||||
upsert,
|
||||
getBySessionId,
|
||||
getByThreadId,
|
||||
list,
|
||||
deleteBySessionId,
|
||||
deleteByThreadId,
|
||||
} satisfies ProviderSessionRuntimeRepositoryShape;
|
||||
});
|
||||
|
||||
|
||||
@@ -1,225 +0,0 @@
|
||||
import { ProviderSessionId, ThreadId } from "@t3tools/contracts";
|
||||
import * as SqlClient from "effect/unstable/sql/SqlClient";
|
||||
import * as SqlSchema from "effect/unstable/sql/SqlSchema";
|
||||
import { Effect, Layer, Option, Schema } from "effect";
|
||||
|
||||
import {
|
||||
ProviderSessionRepositoryPersistenceError,
|
||||
ProviderSessionRepositoryValidationError,
|
||||
} from "../Errors.ts";
|
||||
import {
|
||||
ProviderSessionRepository,
|
||||
type ProviderSessionEntry,
|
||||
type ProviderSessionRepositoryShape,
|
||||
} from "../Services/ProviderSessions.ts";
|
||||
|
||||
const ProviderKind = Schema.Literals(["codex", "claudeCode"]);
|
||||
|
||||
const ProviderSessionRowSchema = Schema.Struct({
|
||||
sessionId: ProviderSessionId,
|
||||
provider: ProviderKind,
|
||||
threadId: Schema.NullOr(ThreadId),
|
||||
createdAt: Schema.String,
|
||||
updatedAt: Schema.String,
|
||||
});
|
||||
|
||||
const SessionIdRequestSchema = Schema.Struct({
|
||||
sessionId: ProviderSessionId,
|
||||
});
|
||||
|
||||
const UpsertSessionRequestSchema = Schema.Struct({
|
||||
sessionId: ProviderSessionId,
|
||||
provider: ProviderKind,
|
||||
threadId: Schema.NullOr(ThreadId),
|
||||
});
|
||||
|
||||
function errorMessage(cause: unknown, fallback: string): string {
|
||||
if (cause instanceof Error && cause.message.length > 0) {
|
||||
return cause.message;
|
||||
}
|
||||
return fallback;
|
||||
}
|
||||
|
||||
function toValidationError(
|
||||
operation: string,
|
||||
cause: unknown,
|
||||
): ProviderSessionRepositoryValidationError {
|
||||
return new ProviderSessionRepositoryValidationError({
|
||||
operation,
|
||||
issue: errorMessage(cause, "Invalid provider session repository input."),
|
||||
cause,
|
||||
});
|
||||
}
|
||||
|
||||
function decodeInput<S extends Schema.Top>(schema: S, input: unknown, operation: string) {
|
||||
return Schema.decodeUnknownEffect(schema)(input).pipe(
|
||||
Effect.mapError((cause) => toValidationError(operation, cause)),
|
||||
);
|
||||
}
|
||||
|
||||
function toPersistenceError(
|
||||
operation: string,
|
||||
cause: unknown,
|
||||
): ProviderSessionRepositoryPersistenceError {
|
||||
return new ProviderSessionRepositoryPersistenceError({
|
||||
operation,
|
||||
detail: `Failed to execute ${operation}.`,
|
||||
cause,
|
||||
});
|
||||
}
|
||||
|
||||
function toEntry(row: Schema.Schema.Type<typeof ProviderSessionRowSchema>): ProviderSessionEntry {
|
||||
return {
|
||||
sessionId: row.sessionId,
|
||||
provider: row.provider,
|
||||
...(row.threadId !== null ? { threadId: row.threadId } : {}),
|
||||
createdAt: row.createdAt,
|
||||
updatedAt: row.updatedAt,
|
||||
};
|
||||
}
|
||||
|
||||
const makeProviderSessionRepository = Effect.gen(function* () {
|
||||
const sql = yield* SqlClient.SqlClient;
|
||||
|
||||
const upsertSessionRow = SqlSchema.findOne({
|
||||
Request: UpsertSessionRequestSchema,
|
||||
Result: ProviderSessionRowSchema,
|
||||
execute: (request) =>
|
||||
sql`
|
||||
INSERT INTO provider_sessions (
|
||||
session_id,
|
||||
provider,
|
||||
thread_id,
|
||||
created_at,
|
||||
updated_at
|
||||
)
|
||||
VALUES (
|
||||
${request.sessionId},
|
||||
${request.provider},
|
||||
${request.threadId},
|
||||
CURRENT_TIMESTAMP,
|
||||
CURRENT_TIMESTAMP
|
||||
)
|
||||
ON CONFLICT (session_id)
|
||||
DO UPDATE SET
|
||||
provider = excluded.provider,
|
||||
thread_id = excluded.thread_id,
|
||||
updated_at = CURRENT_TIMESTAMP
|
||||
RETURNING
|
||||
session_id AS "sessionId",
|
||||
provider,
|
||||
thread_id AS "threadId",
|
||||
created_at AS "createdAt",
|
||||
updated_at AS "updatedAt"
|
||||
`,
|
||||
});
|
||||
|
||||
const findSessionRow = SqlSchema.findOneOption({
|
||||
Request: SessionIdRequestSchema,
|
||||
Result: ProviderSessionRowSchema,
|
||||
execute: ({ sessionId }) =>
|
||||
sql`
|
||||
SELECT
|
||||
session_id AS "sessionId",
|
||||
provider,
|
||||
thread_id AS "threadId",
|
||||
created_at AS "createdAt",
|
||||
updated_at AS "updatedAt"
|
||||
FROM provider_sessions
|
||||
WHERE session_id = ${sessionId}
|
||||
`,
|
||||
});
|
||||
|
||||
const listSessionRows = SqlSchema.findAll({
|
||||
Request: Schema.Void,
|
||||
Result: ProviderSessionRowSchema,
|
||||
execute: () =>
|
||||
sql`
|
||||
SELECT
|
||||
session_id AS "sessionId",
|
||||
provider,
|
||||
thread_id AS "threadId",
|
||||
created_at AS "createdAt",
|
||||
updated_at AS "updatedAt"
|
||||
FROM provider_sessions
|
||||
ORDER BY created_at ASC, session_id ASC
|
||||
`,
|
||||
});
|
||||
|
||||
const deleteSessionRow = SqlSchema.void({
|
||||
Request: SessionIdRequestSchema,
|
||||
execute: ({ sessionId }) => sql`DELETE FROM provider_sessions WHERE session_id = ${sessionId}`,
|
||||
});
|
||||
|
||||
const upsertSession: ProviderSessionRepositoryShape["upsertSession"] = (input) =>
|
||||
Effect.gen(function* () {
|
||||
const parsed = yield* decodeInput(
|
||||
UpsertSessionRequestSchema,
|
||||
{
|
||||
sessionId: input.sessionId,
|
||||
provider: input.provider,
|
||||
threadId: input.threadId ?? null,
|
||||
},
|
||||
"ProviderSessionRepository.upsertSession",
|
||||
);
|
||||
|
||||
yield* upsertSessionRow(parsed).pipe(
|
||||
Effect.mapError((cause) =>
|
||||
toPersistenceError("ProviderSessionRepository.upsertSession:query", cause),
|
||||
),
|
||||
Effect.asVoid,
|
||||
);
|
||||
});
|
||||
|
||||
const getSession: ProviderSessionRepositoryShape["getSession"] = (input) =>
|
||||
Effect.gen(function* () {
|
||||
const parsed = yield* decodeInput(
|
||||
SessionIdRequestSchema,
|
||||
{ sessionId: input.sessionId },
|
||||
"ProviderSessionRepository.getSession",
|
||||
);
|
||||
|
||||
const row = yield* findSessionRow(parsed).pipe(
|
||||
Effect.mapError((cause) =>
|
||||
toPersistenceError("ProviderSessionRepository.getSession:query", cause),
|
||||
),
|
||||
);
|
||||
|
||||
return Option.map(row, toEntry);
|
||||
});
|
||||
|
||||
const listSessions: ProviderSessionRepositoryShape["listSessions"] = () =>
|
||||
listSessionRows(undefined).pipe(
|
||||
Effect.mapError((cause) =>
|
||||
toPersistenceError("ProviderSessionRepository.listSessions:query", cause),
|
||||
),
|
||||
Effect.map((rows) => rows.map(toEntry)),
|
||||
);
|
||||
|
||||
const deleteSession: ProviderSessionRepositoryShape["deleteSession"] = (input) =>
|
||||
Effect.gen(function* () {
|
||||
const parsed = yield* decodeInput(
|
||||
SessionIdRequestSchema,
|
||||
{ sessionId: input.sessionId },
|
||||
"ProviderSessionRepository.deleteSession",
|
||||
);
|
||||
|
||||
yield* deleteSessionRow(parsed).pipe(
|
||||
Effect.mapError((cause) =>
|
||||
toPersistenceError("ProviderSessionRepository.deleteSession:query", cause),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
return {
|
||||
upsertSession,
|
||||
getSession,
|
||||
listSessions,
|
||||
deleteSession,
|
||||
} satisfies ProviderSessionRepositoryShape;
|
||||
});
|
||||
|
||||
export const ProviderSessionRepositoryLive = Layer.effect(
|
||||
ProviderSessionRepository,
|
||||
makeProviderSessionRepository,
|
||||
);
|
||||
@@ -19,6 +19,13 @@ import Migration0004 from "./Migrations/004_ProviderSessionRuntime.ts";
|
||||
import Migration0005 from "./Migrations/005_Projections.ts";
|
||||
import Migration0006 from "./Migrations/006_ProjectionThreadSessionRuntimeModeColumns.ts";
|
||||
import Migration0007 from "./Migrations/007_ProjectionThreadMessageAttachments.ts";
|
||||
import Migration0008 from "./Migrations/008_ProjectionThreadActivitySequence.ts";
|
||||
import Migration0009 from "./Migrations/009_ProviderSessionRuntimeMode.ts";
|
||||
import Migration0010 from "./Migrations/010_ProjectionThreadsRuntimeMode.ts";
|
||||
import Migration0011 from "./Migrations/011_OrchestrationThreadCreatedRuntimeMode.ts";
|
||||
import Migration0012 from "./Migrations/012_ProjectionThreadsInteractionMode.ts";
|
||||
import Migration0013 from "./Migrations/013_ProjectionThreadProposedPlans.ts";
|
||||
import { Effect } from "effect";
|
||||
|
||||
/**
|
||||
* Migration loader with all migrations defined inline.
|
||||
@@ -38,6 +45,12 @@ const loader = Migrator.fromRecord({
|
||||
"5_Projections": Migration0005,
|
||||
"6_ProjectionThreadSessionRuntimeModeColumns": Migration0006,
|
||||
"7_ProjectionThreadMessageAttachments": Migration0007,
|
||||
"8_ProjectionThreadActivitySequence": Migration0008,
|
||||
"9_ProviderSessionRuntimeMode": Migration0009,
|
||||
"10_ProjectionThreadsRuntimeMode": Migration0010,
|
||||
"11_OrchestrationThreadCreatedRuntimeMode": Migration0011,
|
||||
"12_ProjectionThreadsInteractionMode": Migration0012,
|
||||
"13_ProjectionThreadProposedPlans": Migration0013,
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -56,7 +69,11 @@ const run = Migrator.make({});
|
||||
*
|
||||
* @returns Effect containing array of executed migrations
|
||||
*/
|
||||
export const runMigrations = run({ loader });
|
||||
export const runMigrations = Effect.gen(function* () {
|
||||
yield* Effect.log("Running migrations...");
|
||||
yield* run({ loader });
|
||||
yield* Effect.log("Migrations ran successfully");
|
||||
});
|
||||
|
||||
/**
|
||||
* Layer that runs migrations when the layer is built.
|
||||
|
||||
@@ -6,11 +6,10 @@ export default Effect.gen(function* () {
|
||||
|
||||
yield* sql`
|
||||
CREATE TABLE IF NOT EXISTS provider_session_runtime (
|
||||
provider_session_id TEXT PRIMARY KEY,
|
||||
thread_id TEXT NOT NULL,
|
||||
thread_id TEXT PRIMARY KEY,
|
||||
provider_name TEXT NOT NULL,
|
||||
adapter_key TEXT NOT NULL,
|
||||
provider_thread_id TEXT,
|
||||
runtime_mode TEXT NOT NULL DEFAULT 'full-access',
|
||||
status TEXT NOT NULL,
|
||||
last_seen_at TEXT NOT NULL,
|
||||
resume_cursor_json TEXT,
|
||||
@@ -18,11 +17,6 @@ export default Effect.gen(function* () {
|
||||
)
|
||||
`;
|
||||
|
||||
yield* sql`
|
||||
CREATE INDEX IF NOT EXISTS idx_provider_session_runtime_thread
|
||||
ON provider_session_runtime(thread_id)
|
||||
`;
|
||||
|
||||
yield* sql`
|
||||
CREATE INDEX IF NOT EXISTS idx_provider_session_runtime_status
|
||||
ON provider_session_runtime(status)
|
||||
|
||||
+4
-15
@@ -1,30 +1,19 @@
|
||||
import * as SqlClient from "effect/unstable/sql/SqlClient";
|
||||
import * as Effect from "effect/Effect";
|
||||
|
||||
const DEFAULT_APPROVAL_POLICY = "never";
|
||||
const DEFAULT_SANDBOX_MODE = "workspace-write";
|
||||
const DEFAULT_RUNTIME_MODE = "full-access";
|
||||
|
||||
export default Effect.gen(function* () {
|
||||
const sql = yield* SqlClient.SqlClient;
|
||||
|
||||
yield* sql`
|
||||
ALTER TABLE projection_thread_sessions
|
||||
ADD COLUMN approval_policy TEXT NOT NULL DEFAULT 'never'
|
||||
`;
|
||||
|
||||
yield* sql`
|
||||
ALTER TABLE projection_thread_sessions
|
||||
ADD COLUMN sandbox_mode TEXT NOT NULL DEFAULT 'workspace-write'
|
||||
ADD COLUMN runtime_mode TEXT NOT NULL DEFAULT 'full-access'
|
||||
`;
|
||||
|
||||
yield* sql`
|
||||
UPDATE projection_thread_sessions
|
||||
SET approval_policy = ${DEFAULT_APPROVAL_POLICY}
|
||||
WHERE approval_policy IS NULL
|
||||
`;
|
||||
yield* sql`
|
||||
UPDATE projection_thread_sessions
|
||||
SET sandbox_mode = ${DEFAULT_SANDBOX_MODE}
|
||||
WHERE sandbox_mode IS NULL
|
||||
SET runtime_mode = ${DEFAULT_RUNTIME_MODE}
|
||||
WHERE runtime_mode IS NULL
|
||||
`;
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as SqlClient from "effect/unstable/sql/SqlClient";
|
||||
|
||||
export default Effect.gen(function* () {
|
||||
const sql = yield* SqlClient.SqlClient;
|
||||
|
||||
yield* sql`
|
||||
ALTER TABLE projection_thread_activities
|
||||
ADD COLUMN sequence INTEGER
|
||||
`;
|
||||
|
||||
yield* sql`
|
||||
CREATE INDEX IF NOT EXISTS idx_projection_thread_activities_thread_sequence
|
||||
ON projection_thread_activities(thread_id, sequence)
|
||||
`;
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import * as SqlClient from "effect/unstable/sql/SqlClient";
|
||||
import * as Effect from "effect/Effect";
|
||||
|
||||
export default Effect.gen(function* () {
|
||||
yield* SqlClient.SqlClient;
|
||||
});
|
||||
@@ -0,0 +1,17 @@
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as SqlClient from "effect/unstable/sql/SqlClient";
|
||||
|
||||
export default Effect.gen(function* () {
|
||||
const sql = yield* SqlClient.SqlClient;
|
||||
|
||||
yield* sql`
|
||||
ALTER TABLE projection_threads
|
||||
ADD COLUMN runtime_mode TEXT NOT NULL DEFAULT 'full-access'
|
||||
`;
|
||||
|
||||
yield* sql`
|
||||
UPDATE projection_threads
|
||||
SET runtime_mode = 'full-access'
|
||||
WHERE runtime_mode IS NULL
|
||||
`;
|
||||
});
|
||||
@@ -0,0 +1,13 @@
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as SqlClient from "effect/unstable/sql/SqlClient";
|
||||
|
||||
export default Effect.gen(function* () {
|
||||
const sql = yield* SqlClient.SqlClient;
|
||||
|
||||
yield* sql`
|
||||
UPDATE orchestration_events
|
||||
SET payload_json = json_set(payload_json, '$.runtimeMode', 'full-access')
|
||||
WHERE event_type = 'thread.created'
|
||||
AND json_type(payload_json, '$.runtimeMode') IS NULL
|
||||
`;
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as SqlClient from "effect/unstable/sql/SqlClient";
|
||||
|
||||
export default Effect.gen(function* () {
|
||||
const sql = yield* SqlClient.SqlClient;
|
||||
|
||||
yield* sql`
|
||||
ALTER TABLE projection_threads
|
||||
ADD COLUMN interaction_mode TEXT NOT NULL DEFAULT 'default'
|
||||
`;
|
||||
});
|
||||
@@ -0,0 +1,22 @@
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as SqlClient from "effect/unstable/sql/SqlClient";
|
||||
|
||||
export default Effect.gen(function* () {
|
||||
const sql = yield* SqlClient.SqlClient;
|
||||
|
||||
yield* sql`
|
||||
CREATE TABLE IF NOT EXISTS projection_thread_proposed_plans (
|
||||
plan_id TEXT PRIMARY KEY,
|
||||
thread_id TEXT NOT NULL,
|
||||
turn_id TEXT,
|
||||
plan_markdown TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL,
|
||||
updated_at TEXT NOT NULL
|
||||
)
|
||||
`;
|
||||
|
||||
yield* sql`
|
||||
CREATE INDEX IF NOT EXISTS idx_projection_thread_proposed_plans_thread_created
|
||||
ON projection_thread_proposed_plans(thread_id, created_at)
|
||||
`;
|
||||
});
|
||||
@@ -9,6 +9,7 @@
|
||||
import {
|
||||
EventId,
|
||||
IsoDateTime,
|
||||
NonNegativeInt,
|
||||
OrchestrationThreadActivityTone,
|
||||
ThreadId,
|
||||
TurnId,
|
||||
@@ -26,6 +27,7 @@ export const ProjectionThreadActivity = Schema.Struct({
|
||||
kind: Schema.String,
|
||||
summary: Schema.String,
|
||||
payload: Schema.Unknown,
|
||||
sequence: Schema.optional(NonNegativeInt),
|
||||
createdAt: IsoDateTime,
|
||||
});
|
||||
export type ProjectionThreadActivity = typeof ProjectionThreadActivity.Type;
|
||||
@@ -57,7 +59,8 @@ export interface ProjectionThreadActivityRepositoryShape {
|
||||
/**
|
||||
* List projected thread activity rows for a thread.
|
||||
*
|
||||
* Returned in ascending creation order.
|
||||
* Returned in ascending runtime sequence order (or creation order when
|
||||
* sequence is unavailable).
|
||||
*/
|
||||
readonly listByThreadId: (
|
||||
input: ListProjectionThreadActivitiesInput,
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
import {
|
||||
IsoDateTime,
|
||||
OrchestrationProposedPlanId,
|
||||
ThreadId,
|
||||
TrimmedNonEmptyString,
|
||||
TurnId,
|
||||
} from "@t3tools/contracts";
|
||||
import { Schema, ServiceMap } from "effect";
|
||||
import type { Effect } from "effect";
|
||||
|
||||
import type { ProjectionRepositoryError } from "../Errors.ts";
|
||||
|
||||
export const ProjectionThreadProposedPlan = Schema.Struct({
|
||||
planId: OrchestrationProposedPlanId,
|
||||
threadId: ThreadId,
|
||||
turnId: Schema.NullOr(TurnId),
|
||||
planMarkdown: TrimmedNonEmptyString,
|
||||
createdAt: IsoDateTime,
|
||||
updatedAt: IsoDateTime,
|
||||
});
|
||||
export type ProjectionThreadProposedPlan = typeof ProjectionThreadProposedPlan.Type;
|
||||
|
||||
export const ListProjectionThreadProposedPlansInput = Schema.Struct({
|
||||
threadId: ThreadId,
|
||||
});
|
||||
export type ListProjectionThreadProposedPlansInput =
|
||||
typeof ListProjectionThreadProposedPlansInput.Type;
|
||||
|
||||
export const DeleteProjectionThreadProposedPlansInput = Schema.Struct({
|
||||
threadId: ThreadId,
|
||||
});
|
||||
export type DeleteProjectionThreadProposedPlansInput =
|
||||
typeof DeleteProjectionThreadProposedPlansInput.Type;
|
||||
|
||||
export interface ProjectionThreadProposedPlanRepositoryShape {
|
||||
readonly upsert: (
|
||||
proposedPlan: ProjectionThreadProposedPlan,
|
||||
) => Effect.Effect<void, ProjectionRepositoryError>;
|
||||
readonly listByThreadId: (
|
||||
input: ListProjectionThreadProposedPlansInput,
|
||||
) => Effect.Effect<ReadonlyArray<ProjectionThreadProposedPlan>, ProjectionRepositoryError>;
|
||||
readonly deleteByThreadId: (
|
||||
input: DeleteProjectionThreadProposedPlansInput,
|
||||
) => Effect.Effect<void, ProjectionRepositoryError>;
|
||||
}
|
||||
|
||||
export class ProjectionThreadProposedPlanRepository extends ServiceMap.Service<
|
||||
ProjectionThreadProposedPlanRepository,
|
||||
ProjectionThreadProposedPlanRepositoryShape
|
||||
>()(
|
||||
"t3/persistence/Services/ProjectionThreadProposedPlans/ProjectionThreadProposedPlanRepository",
|
||||
) {}
|
||||
@@ -7,12 +7,9 @@
|
||||
* @module ProjectionThreadSessionRepository
|
||||
*/
|
||||
import {
|
||||
RuntimeMode,
|
||||
IsoDateTime,
|
||||
OrchestrationSessionStatus,
|
||||
ProviderApprovalPolicy,
|
||||
ProviderSandboxMode,
|
||||
ProviderSessionId,
|
||||
ProviderThreadId,
|
||||
ThreadId,
|
||||
TurnId,
|
||||
} from "@t3tools/contracts";
|
||||
@@ -25,10 +22,7 @@ export const ProjectionThreadSession = Schema.Struct({
|
||||
threadId: ThreadId,
|
||||
status: OrchestrationSessionStatus,
|
||||
providerName: Schema.NullOr(Schema.String),
|
||||
providerSessionId: Schema.NullOr(ProviderSessionId),
|
||||
providerThreadId: Schema.NullOr(ProviderThreadId),
|
||||
approvalPolicy: ProviderApprovalPolicy,
|
||||
sandboxMode: ProviderSandboxMode,
|
||||
runtimeMode: RuntimeMode,
|
||||
activeTurnId: Schema.NullOr(TurnId),
|
||||
lastError: Schema.NullOr(Schema.String),
|
||||
updatedAt: IsoDateTime,
|
||||
|
||||
@@ -6,7 +6,14 @@
|
||||
*
|
||||
* @module ProjectionThreadRepository
|
||||
*/
|
||||
import { IsoDateTime, ProjectId, ThreadId, TurnId } from "@t3tools/contracts";
|
||||
import {
|
||||
IsoDateTime,
|
||||
ProjectId,
|
||||
ProviderInteractionMode,
|
||||
RuntimeMode,
|
||||
ThreadId,
|
||||
TurnId,
|
||||
} from "@t3tools/contracts";
|
||||
import { Option, Schema, ServiceMap } from "effect";
|
||||
import type { Effect } from "effect";
|
||||
|
||||
@@ -17,6 +24,8 @@ export const ProjectionThread = Schema.Struct({
|
||||
projectId: ProjectId,
|
||||
title: Schema.String,
|
||||
model: Schema.String,
|
||||
runtimeMode: RuntimeMode,
|
||||
interactionMode: ProviderInteractionMode,
|
||||
branch: Schema.NullOr(Schema.String),
|
||||
worktreePath: Schema.NullOr(Schema.String),
|
||||
latestTurnId: Schema.NullOr(TurnId),
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
*/
|
||||
import {
|
||||
IsoDateTime,
|
||||
ProviderSessionId,
|
||||
ProviderSessionRuntimeStatus,
|
||||
ProviderThreadId,
|
||||
RuntimeMode,
|
||||
ThreadId,
|
||||
} from "@t3tools/contracts";
|
||||
import { Option, Schema, ServiceMap } from "effect";
|
||||
@@ -18,11 +17,10 @@ import type { Effect } from "effect";
|
||||
import type { ProviderSessionRuntimeRepositoryError } from "../Errors.ts";
|
||||
|
||||
export const ProviderSessionRuntime = Schema.Struct({
|
||||
providerSessionId: ProviderSessionId,
|
||||
threadId: ThreadId,
|
||||
providerName: Schema.String,
|
||||
adapterKey: Schema.String,
|
||||
providerThreadId: Schema.NullOr(ProviderThreadId),
|
||||
runtimeMode: RuntimeMode,
|
||||
status: ProviderSessionRuntimeStatus,
|
||||
lastSeenAt: IsoDateTime,
|
||||
resumeCursor: Schema.NullOr(Schema.Unknown),
|
||||
@@ -30,14 +28,10 @@ export const ProviderSessionRuntime = Schema.Struct({
|
||||
});
|
||||
export type ProviderSessionRuntime = typeof ProviderSessionRuntime.Type;
|
||||
|
||||
export const GetProviderSessionRuntimeInput = Schema.Struct({
|
||||
providerSessionId: ProviderSessionId,
|
||||
});
|
||||
export const GetProviderSessionRuntimeInput = Schema.Struct({ threadId: ThreadId });
|
||||
export type GetProviderSessionRuntimeInput = typeof GetProviderSessionRuntimeInput.Type;
|
||||
|
||||
export const DeleteProviderSessionRuntimeInput = Schema.Struct({
|
||||
providerSessionId: ProviderSessionId,
|
||||
});
|
||||
export const DeleteProviderSessionRuntimeInput = Schema.Struct({ threadId: ThreadId });
|
||||
export type DeleteProviderSessionRuntimeInput = typeof DeleteProviderSessionRuntimeInput.Type;
|
||||
|
||||
/**
|
||||
@@ -47,16 +41,16 @@ export interface ProviderSessionRuntimeRepositoryShape {
|
||||
/**
|
||||
* Insert or replace a provider runtime row.
|
||||
*
|
||||
* Upserts by `providerSessionId`, including JSON payload/cursor fields.
|
||||
* Upserts by canonical `threadId`, including JSON payload/cursor fields.
|
||||
*/
|
||||
readonly upsert: (
|
||||
runtime: ProviderSessionRuntime,
|
||||
) => Effect.Effect<void, ProviderSessionRuntimeRepositoryError>;
|
||||
|
||||
/**
|
||||
* Read provider runtime state by provider session id.
|
||||
* Read provider runtime state by canonical thread id.
|
||||
*/
|
||||
readonly getBySessionId: (
|
||||
readonly getByThreadId: (
|
||||
input: GetProviderSessionRuntimeInput,
|
||||
) => Effect.Effect<Option.Option<ProviderSessionRuntime>, ProviderSessionRuntimeRepositoryError>;
|
||||
|
||||
@@ -71,9 +65,9 @@ export interface ProviderSessionRuntimeRepositoryShape {
|
||||
>;
|
||||
|
||||
/**
|
||||
* Delete provider runtime state by provider session id.
|
||||
* Delete provider runtime state by canonical thread id.
|
||||
*/
|
||||
readonly deleteBySessionId: (
|
||||
readonly deleteByThreadId: (
|
||||
input: DeleteProviderSessionRuntimeInput,
|
||||
) => Effect.Effect<void, ProviderSessionRuntimeRepositoryError>;
|
||||
}
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
/**
|
||||
* ProviderSessionRepository - Repository interface for provider session lookup.
|
||||
*
|
||||
* Owns persistence operations that map internal sessions to provider kinds and
|
||||
* optional thread ownership.
|
||||
*
|
||||
* @module ProviderSessionRepository
|
||||
*/
|
||||
import type { ProviderKind, ProviderSessionId, ThreadId } from "@t3tools/contracts";
|
||||
import { Option, ServiceMap } from "effect";
|
||||
import type { Effect } from "effect";
|
||||
|
||||
import type { ProviderSessionRepositoryError } from "../Errors.ts";
|
||||
|
||||
export interface ProviderSessionEntry {
|
||||
readonly sessionId: ProviderSessionId;
|
||||
readonly provider: ProviderKind;
|
||||
readonly threadId?: ThreadId;
|
||||
readonly createdAt: string;
|
||||
readonly updatedAt: string;
|
||||
}
|
||||
|
||||
export interface UpsertProviderSessionInput {
|
||||
readonly sessionId: ProviderSessionId;
|
||||
readonly provider: ProviderKind;
|
||||
readonly threadId?: ThreadId;
|
||||
}
|
||||
|
||||
export interface DeleteProviderSessionInput {
|
||||
readonly sessionId: ProviderSessionId;
|
||||
}
|
||||
|
||||
export interface GetProviderSessionInput {
|
||||
readonly sessionId: ProviderSessionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* ProviderSessionRepositoryShape - Service API for provider-session records.
|
||||
*/
|
||||
export interface ProviderSessionRepositoryShape {
|
||||
/**
|
||||
* Insert or replace a provider-session row.
|
||||
*
|
||||
* Upserts by `sessionId`.
|
||||
*/
|
||||
readonly upsertSession: (
|
||||
input: UpsertProviderSessionInput,
|
||||
) => Effect.Effect<void, ProviderSessionRepositoryError>;
|
||||
|
||||
/**
|
||||
* Read a provider-session row by session id.
|
||||
*/
|
||||
readonly getSession: (
|
||||
input: GetProviderSessionInput,
|
||||
) => Effect.Effect<Option.Option<ProviderSessionEntry>, ProviderSessionRepositoryError>;
|
||||
|
||||
/**
|
||||
* List all provider-session rows.
|
||||
*
|
||||
* Returned in deterministic creation order.
|
||||
*/
|
||||
readonly listSessions: () => Effect.Effect<
|
||||
ReadonlyArray<ProviderSessionEntry>,
|
||||
ProviderSessionRepositoryError
|
||||
>;
|
||||
|
||||
/**
|
||||
* Delete a provider-session row by session id.
|
||||
*/
|
||||
readonly deleteSession: (
|
||||
input: DeleteProviderSessionInput,
|
||||
) => Effect.Effect<void, ProviderSessionRepositoryError>;
|
||||
}
|
||||
|
||||
/**
|
||||
* ProviderSessionRepository - Service tag for provider-session persistence.
|
||||
*/
|
||||
export class ProviderSessionRepository extends ServiceMap.Service<
|
||||
ProviderSessionRepository,
|
||||
ProviderSessionRepositoryShape
|
||||
>()("t3/persistence/Services/ProviderSessions/ProviderSessionRepository") {}
|
||||
@@ -26,12 +26,12 @@ export class ProviderAdapterSessionNotFoundError extends Schema.TaggedErrorClass
|
||||
"ProviderAdapterSessionNotFoundError",
|
||||
{
|
||||
provider: Schema.String,
|
||||
sessionId: Schema.String,
|
||||
threadId: Schema.String,
|
||||
cause: Schema.optional(Schema.Defect),
|
||||
},
|
||||
) {
|
||||
override get message(): string {
|
||||
return `Unknown ${this.provider} adapter session: ${this.sessionId}`;
|
||||
return `Unknown ${this.provider} adapter thread: ${this.threadId}`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,12 +42,12 @@ export class ProviderAdapterSessionClosedError extends Schema.TaggedErrorClass<P
|
||||
"ProviderAdapterSessionClosedError",
|
||||
{
|
||||
provider: Schema.String,
|
||||
sessionId: Schema.String,
|
||||
threadId: Schema.String,
|
||||
cause: Schema.optional(Schema.Defect),
|
||||
},
|
||||
) {
|
||||
override get message(): string {
|
||||
return `${this.provider} adapter session is closed: ${this.sessionId}`;
|
||||
return `${this.provider} adapter thread is closed: ${this.threadId}`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,13 +75,13 @@ export class ProviderAdapterProcessError extends Schema.TaggedErrorClass<Provide
|
||||
"ProviderAdapterProcessError",
|
||||
{
|
||||
provider: Schema.String,
|
||||
sessionId: Schema.String,
|
||||
threadId: Schema.String,
|
||||
detail: Schema.String,
|
||||
cause: Schema.optional(Schema.Defect),
|
||||
},
|
||||
) {
|
||||
override get message(): string {
|
||||
return `Provider adapter process error (${this.provider}) for session ${this.sessionId}: ${this.detail}`;
|
||||
return `Provider adapter process error (${this.provider}) for thread ${this.threadId}: ${this.detail}`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,12 +122,12 @@ export class ProviderUnsupportedError extends Schema.TaggedErrorClass<ProviderUn
|
||||
export class ProviderSessionNotFoundError extends Schema.TaggedErrorClass<ProviderSessionNotFoundError>()(
|
||||
"ProviderSessionNotFoundError",
|
||||
{
|
||||
sessionId: Schema.String,
|
||||
threadId: Schema.String,
|
||||
cause: Schema.optional(Schema.Defect),
|
||||
},
|
||||
) {
|
||||
override get message(): string {
|
||||
return `Unknown provider session: ${this.sessionId}`;
|
||||
return `Unknown provider thread: ${this.threadId}`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
import assert from "node:assert/strict";
|
||||
import {
|
||||
ApprovalRequestId,
|
||||
EventId,
|
||||
ProviderItemId,
|
||||
type ProviderApprovalDecision,
|
||||
type ProviderEvent,
|
||||
ProviderSessionId,
|
||||
type ProviderSession,
|
||||
type ProviderSessionStartInput,
|
||||
ProviderThreadId,
|
||||
ProviderTurnId,
|
||||
type ProviderTurnStartResult,
|
||||
type ProviderUserInputAnswers,
|
||||
ThreadId,
|
||||
TurnId,
|
||||
} from "@t3tools/contracts";
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { afterAll, assert, it, vi } from "@effect/vitest";
|
||||
import { assertFailure } from "@effect/vitest/utils";
|
||||
import { afterAll, it, vi } from "@effect/vitest";
|
||||
|
||||
import { Effect, Fiber, Layer, Option, Stream } from "effect";
|
||||
|
||||
import {
|
||||
CodexAppServerManager,
|
||||
type CodexAppServerStartSessionInput,
|
||||
type CodexAppServerSendTurnInput,
|
||||
} from "../../codexAppServerManager.ts";
|
||||
import { ServerConfig } from "../../config.ts";
|
||||
@@ -27,20 +27,20 @@ import { CodexAdapter } from "../Services/CodexAdapter.ts";
|
||||
import { ProviderSessionDirectory } from "../Services/ProviderSessionDirectory.ts";
|
||||
import { makeCodexAdapterLive } from "./CodexAdapter.ts";
|
||||
|
||||
const asSessionId = (value: string): ProviderSessionId => ProviderSessionId.makeUnsafe(value);
|
||||
const asTurnId = (value: string): ProviderTurnId => ProviderTurnId.makeUnsafe(value);
|
||||
const asThreadId = (value: string): ThreadId => ThreadId.makeUnsafe(value);
|
||||
const asTurnId = (value: string): TurnId => TurnId.makeUnsafe(value);
|
||||
const asEventId = (value: string): EventId => EventId.makeUnsafe(value);
|
||||
const asItemId = (value: string): ProviderItemId => ProviderItemId.makeUnsafe(value);
|
||||
|
||||
class FakeCodexManager extends CodexAppServerManager {
|
||||
public startSessionImpl = vi.fn(
|
||||
async (input: ProviderSessionStartInput): Promise<ProviderSession> => {
|
||||
async (input: CodexAppServerStartSessionInput): Promise<ProviderSession> => {
|
||||
const now = new Date().toISOString();
|
||||
return {
|
||||
sessionId: asSessionId("sess-1"),
|
||||
provider: "codex",
|
||||
status: "ready",
|
||||
threadId: ProviderThreadId.makeUnsafe("thread-1"),
|
||||
runtimeMode: input.runtimeMode,
|
||||
threadId: input.threadId,
|
||||
cwd: input.cwd,
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
@@ -50,36 +50,44 @@ class FakeCodexManager extends CodexAppServerManager {
|
||||
|
||||
public sendTurnImpl = vi.fn(
|
||||
async (_input: CodexAppServerSendTurnInput): Promise<ProviderTurnStartResult> => ({
|
||||
threadId: ProviderThreadId.makeUnsafe("thread-1"),
|
||||
threadId: asThreadId("thread-1"),
|
||||
turnId: asTurnId("turn-1"),
|
||||
}),
|
||||
);
|
||||
|
||||
public interruptTurnImpl = vi.fn(
|
||||
async (_sessionId: ProviderSessionId, _turnId?: ProviderTurnId): Promise<void> => undefined,
|
||||
async (_threadId: ThreadId, _turnId?: TurnId): Promise<void> => undefined,
|
||||
);
|
||||
|
||||
public readThreadImpl = vi.fn(async (_sessionId: ProviderSessionId) => ({
|
||||
threadId: ProviderThreadId.makeUnsafe("thread-1"),
|
||||
public readThreadImpl = vi.fn(async (_threadId: ThreadId) => ({
|
||||
threadId: asThreadId("thread-1"),
|
||||
turns: [],
|
||||
}));
|
||||
|
||||
public rollbackThreadImpl = vi.fn(async (_sessionId: ProviderSessionId, _numTurns: number) => ({
|
||||
threadId: ProviderThreadId.makeUnsafe("thread-1"),
|
||||
public rollbackThreadImpl = vi.fn(async (_threadId: ThreadId, _numTurns: number) => ({
|
||||
threadId: asThreadId("thread-1"),
|
||||
turns: [],
|
||||
}));
|
||||
|
||||
public respondToRequestImpl = vi.fn(
|
||||
async (
|
||||
_sessionId: ProviderSessionId,
|
||||
_threadId: ThreadId,
|
||||
_requestId: ApprovalRequestId,
|
||||
_decision: ProviderApprovalDecision,
|
||||
): Promise<void> => undefined,
|
||||
);
|
||||
|
||||
public respondToUserInputImpl = vi.fn(
|
||||
async (
|
||||
_threadId: ThreadId,
|
||||
_requestId: ApprovalRequestId,
|
||||
_answers: ProviderUserInputAnswers,
|
||||
): Promise<void> => undefined,
|
||||
);
|
||||
|
||||
public stopAllImpl = vi.fn(() => undefined);
|
||||
|
||||
override startSession(input: ProviderSessionStartInput): Promise<ProviderSession> {
|
||||
override startSession(input: CodexAppServerStartSessionInput): Promise<ProviderSession> {
|
||||
return this.startSessionImpl(input);
|
||||
}
|
||||
|
||||
@@ -87,33 +95,41 @@ class FakeCodexManager extends CodexAppServerManager {
|
||||
return this.sendTurnImpl(input);
|
||||
}
|
||||
|
||||
override interruptTurn(sessionId: ProviderSessionId, turnId?: ProviderTurnId): Promise<void> {
|
||||
return this.interruptTurnImpl(sessionId, turnId);
|
||||
override interruptTurn(threadId: ThreadId, turnId?: TurnId): Promise<void> {
|
||||
return this.interruptTurnImpl(threadId, turnId);
|
||||
}
|
||||
|
||||
override readThread(sessionId: ProviderSessionId) {
|
||||
return this.readThreadImpl(sessionId);
|
||||
override readThread(threadId: ThreadId) {
|
||||
return this.readThreadImpl(threadId);
|
||||
}
|
||||
|
||||
override rollbackThread(sessionId: ProviderSessionId, numTurns: number) {
|
||||
return this.rollbackThreadImpl(sessionId, numTurns);
|
||||
override rollbackThread(threadId: ThreadId, numTurns: number) {
|
||||
return this.rollbackThreadImpl(threadId, numTurns);
|
||||
}
|
||||
|
||||
override respondToRequest(
|
||||
sessionId: ProviderSessionId,
|
||||
threadId: ThreadId,
|
||||
requestId: ApprovalRequestId,
|
||||
decision: ProviderApprovalDecision,
|
||||
): Promise<void> {
|
||||
return this.respondToRequestImpl(sessionId, requestId, decision);
|
||||
return this.respondToRequestImpl(threadId, requestId, decision);
|
||||
}
|
||||
|
||||
override stopSession(_sessionId: ProviderSessionId): void {}
|
||||
override respondToUserInput(
|
||||
threadId: ThreadId,
|
||||
requestId: ApprovalRequestId,
|
||||
answers: ProviderUserInputAnswers,
|
||||
): Promise<void> {
|
||||
return this.respondToUserInputImpl(threadId, requestId, answers);
|
||||
}
|
||||
|
||||
override stopSession(_threadId: ThreadId): void {}
|
||||
|
||||
override listSessions(): ProviderSession[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
override hasSession(_sessionId: ProviderSessionId): boolean {
|
||||
override hasSession(_threadId: ThreadId): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -127,9 +143,8 @@ const providerSessionDirectoryTestLayer = Layer.succeed(ProviderSessionDirectory
|
||||
getProvider: () =>
|
||||
Effect.die(new Error("ProviderSessionDirectory.getProvider is not used in test")),
|
||||
getBinding: () => Effect.succeed(Option.none()),
|
||||
getThreadId: () => Effect.succeed(Option.none()),
|
||||
remove: () => Effect.void,
|
||||
listSessionIds: () => Effect.succeed([]),
|
||||
listThreadIds: () => Effect.succeed([]),
|
||||
});
|
||||
|
||||
const validationManager = new FakeCodexManager();
|
||||
@@ -142,24 +157,30 @@ const validationLayer = it.layer(
|
||||
);
|
||||
|
||||
validationLayer("CodexAdapterLive validation", (it) => {
|
||||
it.effect("returns validation error for non-codex provider on startSession", () =>
|
||||
it.effect("maps codex model options before starting a session", () =>
|
||||
Effect.gen(function* () {
|
||||
validationManager.startSessionImpl.mockClear();
|
||||
const adapter = yield* CodexAdapter;
|
||||
const result = yield* adapter
|
||||
.startSession({
|
||||
provider: "claudeCode",
|
||||
})
|
||||
.pipe(Effect.result);
|
||||
|
||||
assertFailure(
|
||||
result,
|
||||
new ProviderAdapterValidationError({
|
||||
provider: "codex",
|
||||
operation: "startSession",
|
||||
issue: "Expected provider 'codex' but received 'claudeCode'.",
|
||||
}),
|
||||
);
|
||||
assert.equal(validationManager.startSessionImpl.mock.calls.length, 0);
|
||||
yield* adapter.startSession({
|
||||
provider: "codex",
|
||||
threadId: asThreadId("thread-1"),
|
||||
model: "gpt-5.3-codex",
|
||||
modelOptions: {
|
||||
codex: {
|
||||
fastMode: true,
|
||||
},
|
||||
},
|
||||
runtimeMode: "full-access",
|
||||
});
|
||||
|
||||
assert.deepStrictEqual(validationManager.startSessionImpl.mock.calls[0]?.[0], {
|
||||
provider: "codex",
|
||||
threadId: asThreadId("thread-1"),
|
||||
model: "gpt-5.3-codex",
|
||||
serviceTier: "fast",
|
||||
runtimeMode: "full-access",
|
||||
});
|
||||
}),
|
||||
);
|
||||
});
|
||||
@@ -182,7 +203,7 @@ sessionErrorLayer("CodexAdapterLive session errors", (it) => {
|
||||
const adapter = yield* CodexAdapter;
|
||||
const result = yield* adapter
|
||||
.sendTurn({
|
||||
sessionId: asSessionId("sess-missing"),
|
||||
threadId: asThreadId("sess-missing"),
|
||||
input: "hello",
|
||||
attachments: [],
|
||||
})
|
||||
@@ -198,8 +219,38 @@ sessionErrorLayer("CodexAdapterLive session errors", (it) => {
|
||||
return;
|
||||
}
|
||||
assert.equal(result.failure.provider, "codex");
|
||||
assert.equal(result.failure.sessionId, "sess-missing");
|
||||
assert.instanceOf(result.failure.cause, Error);
|
||||
assert.equal(result.failure.threadId, "sess-missing");
|
||||
assert.equal(result.failure.cause instanceof Error, true);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("maps codex model options before sending a turn", () =>
|
||||
Effect.gen(function* () {
|
||||
sessionErrorManager.sendTurnImpl.mockClear();
|
||||
const adapter = yield* CodexAdapter;
|
||||
|
||||
yield* Effect.ignore(
|
||||
adapter.sendTurn({
|
||||
threadId: asThreadId("sess-missing"),
|
||||
input: "hello",
|
||||
model: "gpt-5.3-codex",
|
||||
modelOptions: {
|
||||
codex: {
|
||||
reasoningEffort: "high",
|
||||
fastMode: true,
|
||||
},
|
||||
},
|
||||
attachments: [],
|
||||
}),
|
||||
);
|
||||
|
||||
assert.deepStrictEqual(sessionErrorManager.sendTurnImpl.mock.calls[0]?.[0], {
|
||||
threadId: asThreadId("sess-missing"),
|
||||
input: "hello",
|
||||
model: "gpt-5.3-codex",
|
||||
effort: "high",
|
||||
serviceTier: "fast",
|
||||
});
|
||||
}),
|
||||
);
|
||||
});
|
||||
@@ -214,7 +265,7 @@ const lifecycleLayer = it.layer(
|
||||
);
|
||||
|
||||
lifecycleLayer("CodexAdapterLive lifecycle", (it) => {
|
||||
it.effect("maps completed agent message items to canonical message.completed events", () =>
|
||||
it.effect("maps completed agent message items to canonical item.completed events", () =>
|
||||
Effect.gen(function* () {
|
||||
const adapter = yield* CodexAdapter;
|
||||
const firstEventFiber = yield* Stream.runHead(adapter.streamEvents).pipe(Effect.forkChild);
|
||||
@@ -223,10 +274,9 @@ lifecycleLayer("CodexAdapterLive lifecycle", (it) => {
|
||||
id: asEventId("evt-msg-complete"),
|
||||
kind: "notification",
|
||||
provider: "codex",
|
||||
sessionId: asSessionId("sess-1"),
|
||||
createdAt: new Date().toISOString(),
|
||||
method: "item/completed",
|
||||
threadId: ProviderThreadId.makeUnsafe("thread-1"),
|
||||
threadId: asThreadId("thread-1"),
|
||||
turnId: asTurnId("turn-1"),
|
||||
itemId: asItemId("msg_1"),
|
||||
payload: {
|
||||
@@ -244,12 +294,86 @@ lifecycleLayer("CodexAdapterLive lifecycle", (it) => {
|
||||
if (firstEvent._tag !== "Some") {
|
||||
return;
|
||||
}
|
||||
assert.equal(firstEvent.value.type, "message.completed");
|
||||
if (firstEvent.value.type !== "message.completed") {
|
||||
assert.equal(firstEvent.value.type, "item.completed");
|
||||
if (firstEvent.value.type !== "item.completed") {
|
||||
return;
|
||||
}
|
||||
assert.equal(firstEvent.value.itemId, "msg_1");
|
||||
assert.equal(firstEvent.value.turnId, "turn-1");
|
||||
assert.equal(firstEvent.value.payload.itemType, "assistant_message");
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("maps completed plan items to canonical proposed-plan completion events", () =>
|
||||
Effect.gen(function* () {
|
||||
const adapter = yield* CodexAdapter;
|
||||
const firstEventFiber = yield* Stream.runHead(adapter.streamEvents).pipe(Effect.forkChild);
|
||||
|
||||
const event: ProviderEvent = {
|
||||
id: asEventId("evt-plan-complete"),
|
||||
kind: "notification",
|
||||
provider: "codex",
|
||||
createdAt: new Date().toISOString(),
|
||||
method: "item/completed",
|
||||
threadId: asThreadId("thread-1"),
|
||||
turnId: asTurnId("turn-1"),
|
||||
itemId: asItemId("plan_1"),
|
||||
payload: {
|
||||
item: {
|
||||
type: "Plan",
|
||||
id: "plan_1",
|
||||
text: "## Final plan\n\n- one\n- two",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
lifecycleManager.emit("event", event);
|
||||
const firstEvent = yield* Fiber.join(firstEventFiber);
|
||||
|
||||
assert.equal(firstEvent._tag, "Some");
|
||||
if (firstEvent._tag !== "Some") {
|
||||
return;
|
||||
}
|
||||
assert.equal(firstEvent.value.type, "turn.proposed.completed");
|
||||
if (firstEvent.value.type !== "turn.proposed.completed") {
|
||||
return;
|
||||
}
|
||||
assert.equal(firstEvent.value.turnId, "turn-1");
|
||||
assert.equal(firstEvent.value.payload.planMarkdown, "## Final plan\n\n- one\n- two");
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("maps plan deltas to canonical proposed-plan delta events", () =>
|
||||
Effect.gen(function* () {
|
||||
const adapter = yield* CodexAdapter;
|
||||
const firstEventFiber = yield* Stream.runHead(adapter.streamEvents).pipe(Effect.forkChild);
|
||||
|
||||
lifecycleManager.emit("event", {
|
||||
id: asEventId("evt-plan-delta"),
|
||||
kind: "notification",
|
||||
provider: "codex",
|
||||
createdAt: new Date().toISOString(),
|
||||
method: "item/plan/delta",
|
||||
threadId: asThreadId("thread-1"),
|
||||
turnId: asTurnId("turn-1"),
|
||||
itemId: asItemId("plan_1"),
|
||||
payload: {
|
||||
delta: "## Final plan",
|
||||
},
|
||||
} satisfies ProviderEvent);
|
||||
|
||||
const firstEvent = yield* Fiber.join(firstEventFiber);
|
||||
|
||||
assert.equal(firstEvent._tag, "Some");
|
||||
if (firstEvent._tag !== "Some") {
|
||||
return;
|
||||
}
|
||||
assert.equal(firstEvent.value.type, "turn.proposed.delta");
|
||||
if (firstEvent.value.type !== "turn.proposed.delta") {
|
||||
return;
|
||||
}
|
||||
assert.equal(firstEvent.value.turnId, "turn-1");
|
||||
assert.equal(firstEvent.value.payload.delta, "## Final plan");
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -262,7 +386,7 @@ lifecycleLayer("CodexAdapterLive lifecycle", (it) => {
|
||||
id: asEventId("evt-session-closed"),
|
||||
kind: "session",
|
||||
provider: "codex",
|
||||
sessionId: asSessionId("sess-1"),
|
||||
threadId: asThreadId("thread-1"),
|
||||
createdAt: new Date().toISOString(),
|
||||
method: "session/closed",
|
||||
message: "Session stopped",
|
||||
@@ -279,12 +403,277 @@ lifecycleLayer("CodexAdapterLive lifecycle", (it) => {
|
||||
if (firstEvent.value.type !== "session.exited") {
|
||||
return;
|
||||
}
|
||||
assert.equal(firstEvent.value.sessionId, "sess-1");
|
||||
assert.equal(firstEvent.value.message, "Session stopped");
|
||||
assert.equal(firstEvent.value.threadId, "thread-1");
|
||||
assert.equal(firstEvent.value.payload.reason, "Session stopped");
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("preserves request type when mapping serverRequest/resolved", () =>
|
||||
Effect.gen(function* () {
|
||||
const adapter = yield* CodexAdapter;
|
||||
const firstEventFiber = yield* Stream.runHead(adapter.streamEvents).pipe(Effect.forkChild);
|
||||
|
||||
const event: ProviderEvent = {
|
||||
id: asEventId("evt-request-resolved"),
|
||||
kind: "notification",
|
||||
provider: "codex",
|
||||
threadId: asThreadId("thread-1"),
|
||||
createdAt: new Date().toISOString(),
|
||||
method: "serverRequest/resolved",
|
||||
requestId: ApprovalRequestId.makeUnsafe("req-1"),
|
||||
payload: {
|
||||
request: {
|
||||
method: "item/commandExecution/requestApproval",
|
||||
},
|
||||
decision: "accept",
|
||||
},
|
||||
};
|
||||
|
||||
lifecycleManager.emit("event", event);
|
||||
const firstEvent = yield* Fiber.join(firstEventFiber);
|
||||
|
||||
assert.equal(firstEvent._tag, "Some");
|
||||
if (firstEvent._tag !== "Some") {
|
||||
return;
|
||||
}
|
||||
assert.equal(firstEvent.value.type, "request.resolved");
|
||||
if (firstEvent.value.type !== "request.resolved") {
|
||||
return;
|
||||
}
|
||||
assert.equal(firstEvent.value.payload.requestType, "command_execution_approval");
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("maps windowsSandbox/setupCompleted to session state and warning on failure", () =>
|
||||
Effect.gen(function* () {
|
||||
const adapter = yield* CodexAdapter;
|
||||
const eventsFiber = yield* Stream.runCollect(Stream.take(adapter.streamEvents, 2)).pipe(
|
||||
Effect.forkChild,
|
||||
);
|
||||
|
||||
const event: ProviderEvent = {
|
||||
id: asEventId("evt-windows-sandbox-failed"),
|
||||
kind: "notification",
|
||||
provider: "codex",
|
||||
threadId: asThreadId("thread-1"),
|
||||
createdAt: new Date().toISOString(),
|
||||
method: "windowsSandbox/setupCompleted",
|
||||
message: "Sandbox setup failed",
|
||||
payload: {
|
||||
success: false,
|
||||
detail: "unsupported environment",
|
||||
},
|
||||
};
|
||||
|
||||
lifecycleManager.emit("event", event);
|
||||
const events = Array.from(yield* Fiber.join(eventsFiber));
|
||||
|
||||
assert.equal(events.length, 2);
|
||||
|
||||
const firstEvent = events[0];
|
||||
const secondEvent = events[1];
|
||||
|
||||
assert.equal(firstEvent?.type, "session.state.changed");
|
||||
if (firstEvent?.type === "session.state.changed") {
|
||||
assert.equal(firstEvent.payload.state, "error");
|
||||
assert.equal(firstEvent.payload.reason, "Sandbox setup failed");
|
||||
}
|
||||
|
||||
assert.equal(secondEvent?.type, "runtime.warning");
|
||||
if (secondEvent?.type === "runtime.warning") {
|
||||
assert.equal(secondEvent.payload.message, "Sandbox setup failed");
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect(
|
||||
"maps requestUserInput requests and answered notifications to canonical user-input events",
|
||||
() =>
|
||||
Effect.gen(function* () {
|
||||
const adapter = yield* CodexAdapter;
|
||||
const eventsFiber = yield* Stream.runCollect(Stream.take(adapter.streamEvents, 2)).pipe(
|
||||
Effect.forkChild,
|
||||
);
|
||||
|
||||
lifecycleManager.emit("event", {
|
||||
id: asEventId("evt-user-input-requested"),
|
||||
kind: "request",
|
||||
provider: "codex",
|
||||
threadId: asThreadId("thread-1"),
|
||||
createdAt: new Date().toISOString(),
|
||||
method: "item/tool/requestUserInput",
|
||||
requestId: ApprovalRequestId.makeUnsafe("req-user-input-1"),
|
||||
payload: {
|
||||
questions: [
|
||||
{
|
||||
id: "sandbox_mode",
|
||||
header: "Sandbox",
|
||||
question: "Which mode should be used?",
|
||||
options: [
|
||||
{
|
||||
label: "workspace-write",
|
||||
description: "Allow workspace writes only",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
} satisfies ProviderEvent);
|
||||
lifecycleManager.emit("event", {
|
||||
id: asEventId("evt-user-input-resolved"),
|
||||
kind: "notification",
|
||||
provider: "codex",
|
||||
threadId: asThreadId("thread-1"),
|
||||
createdAt: new Date().toISOString(),
|
||||
method: "item/tool/requestUserInput/answered",
|
||||
requestId: ApprovalRequestId.makeUnsafe("req-user-input-1"),
|
||||
payload: {
|
||||
answers: {
|
||||
sandbox_mode: {
|
||||
answers: ["workspace-write"],
|
||||
},
|
||||
},
|
||||
},
|
||||
} satisfies ProviderEvent);
|
||||
|
||||
const events = Array.from(yield* Fiber.join(eventsFiber));
|
||||
assert.equal(events[0]?.type, "user-input.requested");
|
||||
if (events[0]?.type === "user-input.requested") {
|
||||
assert.equal(events[0].requestId, "req-user-input-1");
|
||||
assert.equal(events[0].payload.questions[0]?.id, "sandbox_mode");
|
||||
}
|
||||
|
||||
assert.equal(events[1]?.type, "user-input.resolved");
|
||||
if (events[1]?.type === "user-input.resolved") {
|
||||
assert.equal(events[1].requestId, "req-user-input-1");
|
||||
assert.deepEqual(events[1].payload.answers, {
|
||||
sandbox_mode: "workspace-write",
|
||||
});
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("maps Codex task and reasoning event chunks into canonical runtime events", () =>
|
||||
Effect.gen(function* () {
|
||||
const adapter = yield* CodexAdapter;
|
||||
const eventsFiber = yield* Stream.runCollect(Stream.take(adapter.streamEvents, 5)).pipe(
|
||||
Effect.forkChild,
|
||||
);
|
||||
|
||||
lifecycleManager.emit("event", {
|
||||
id: asEventId("evt-codex-task-started"),
|
||||
kind: "notification",
|
||||
provider: "codex",
|
||||
threadId: asThreadId("thread-1"),
|
||||
createdAt: new Date().toISOString(),
|
||||
method: "codex/event/task_started",
|
||||
payload: {
|
||||
id: "turn-structured-1",
|
||||
msg: {
|
||||
type: "task_started",
|
||||
turn_id: "turn-structured-1",
|
||||
collaboration_mode_kind: "plan",
|
||||
},
|
||||
},
|
||||
} satisfies ProviderEvent);
|
||||
|
||||
lifecycleManager.emit("event", {
|
||||
id: asEventId("evt-codex-agent-reasoning"),
|
||||
kind: "notification",
|
||||
provider: "codex",
|
||||
threadId: asThreadId("thread-1"),
|
||||
createdAt: new Date().toISOString(),
|
||||
method: "codex/event/agent_reasoning",
|
||||
payload: {
|
||||
id: "turn-structured-1",
|
||||
msg: {
|
||||
type: "agent_reasoning",
|
||||
text: "Need to compare both transport layers before finalizing the plan.",
|
||||
},
|
||||
},
|
||||
} satisfies ProviderEvent);
|
||||
|
||||
lifecycleManager.emit("event", {
|
||||
id: asEventId("evt-codex-reasoning-delta"),
|
||||
kind: "notification",
|
||||
provider: "codex",
|
||||
threadId: asThreadId("thread-1"),
|
||||
createdAt: new Date().toISOString(),
|
||||
method: "codex/event/reasoning_content_delta",
|
||||
payload: {
|
||||
id: "turn-structured-1",
|
||||
msg: {
|
||||
type: "reasoning_content_delta",
|
||||
turn_id: "turn-structured-1",
|
||||
item_id: "rs_reasoning_1",
|
||||
delta: "**Compare** transport boundaries",
|
||||
summary_index: 0,
|
||||
},
|
||||
},
|
||||
} satisfies ProviderEvent);
|
||||
|
||||
lifecycleManager.emit("event", {
|
||||
id: asEventId("evt-codex-task-complete"),
|
||||
kind: "notification",
|
||||
provider: "codex",
|
||||
threadId: asThreadId("thread-1"),
|
||||
createdAt: new Date().toISOString(),
|
||||
method: "codex/event/task_complete",
|
||||
payload: {
|
||||
id: "turn-structured-1",
|
||||
msg: {
|
||||
type: "task_complete",
|
||||
turn_id: "turn-structured-1",
|
||||
last_agent_message: "<proposed_plan>\n# Ship it\n</proposed_plan>",
|
||||
},
|
||||
},
|
||||
} satisfies ProviderEvent);
|
||||
|
||||
const events = Array.from(yield* Fiber.join(eventsFiber));
|
||||
|
||||
assert.equal(events[0]?.type, "task.started");
|
||||
if (events[0]?.type === "task.started") {
|
||||
assert.equal(events[0].turnId, "turn-structured-1");
|
||||
assert.equal(events[0].payload.taskId, "turn-structured-1");
|
||||
assert.equal(events[0].payload.taskType, "plan");
|
||||
}
|
||||
|
||||
assert.equal(events[1]?.type, "task.progress");
|
||||
if (events[1]?.type === "task.progress") {
|
||||
assert.equal(events[1].payload.taskId, "turn-structured-1");
|
||||
assert.equal(
|
||||
events[1].payload.description,
|
||||
"Need to compare both transport layers before finalizing the plan.",
|
||||
);
|
||||
}
|
||||
|
||||
assert.equal(events[2]?.type, "content.delta");
|
||||
if (events[2]?.type === "content.delta") {
|
||||
assert.equal(events[2].turnId, "turn-structured-1");
|
||||
assert.equal(events[2].itemId, "rs_reasoning_1");
|
||||
assert.equal(events[2].payload.streamKind, "reasoning_summary_text");
|
||||
assert.equal(events[2].payload.summaryIndex, 0);
|
||||
}
|
||||
|
||||
assert.equal(events[3]?.type, "task.completed");
|
||||
if (events[3]?.type === "task.completed") {
|
||||
assert.equal(events[3].turnId, "turn-structured-1");
|
||||
assert.equal(events[3].payload.taskId, "turn-structured-1");
|
||||
assert.equal(events[3].payload.summary, "<proposed_plan>\n# Ship it\n</proposed_plan>");
|
||||
}
|
||||
|
||||
assert.equal(events[4]?.type, "turn.proposed.completed");
|
||||
if (events[4]?.type === "turn.proposed.completed") {
|
||||
assert.equal(events[4].turnId, "turn-structured-1");
|
||||
assert.equal(events[4].payload.planMarkdown, "# Ship it");
|
||||
}
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
assert.equal(lifecycleManager.stopAllImpl.mock.calls.length, 1);
|
||||
if (lifecycleManager.stopAllImpl.mock.calls.length === 0) {
|
||||
lifecycleManager.stopAll();
|
||||
}
|
||||
assert.ok(lifecycleManager.stopAllImpl.mock.calls.length >= 1);
|
||||
});
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,655 @@
|
||||
import { EventEmitter } from "node:events";
|
||||
import { PassThrough } from "node:stream";
|
||||
import readline from "node:readline";
|
||||
|
||||
import { ApprovalRequestId, ThreadId } from "@t3tools/contracts";
|
||||
import { assert, describe, it } from "@effect/vitest";
|
||||
import { Effect, Fiber, Stream } from "effect";
|
||||
|
||||
import { ProviderAdapterValidationError } from "../Errors.ts";
|
||||
import { CursorAdapter } from "../Services/CursorAdapter.ts";
|
||||
import { makeCursorAdapterLive } from "./CursorAdapter.ts";
|
||||
|
||||
const THREAD_ID = ThreadId.makeUnsafe("thread-cursor-1");
|
||||
const RESUME_THREAD_ID = ThreadId.makeUnsafe("thread-cursor-resume");
|
||||
const LEGACY_RESUME_THREAD_ID = ThreadId.makeUnsafe("thread-cursor-legacy");
|
||||
|
||||
class FakeCursorAcpProcess extends EventEmitter {
|
||||
readonly stdin = new PassThrough();
|
||||
readonly stdout = new PassThrough();
|
||||
readonly stderr = new PassThrough();
|
||||
readonly requests: Array<{ method: string; params: unknown }> = [];
|
||||
killed = false;
|
||||
|
||||
private readonly input = readline.createInterface({ input: this.stdin });
|
||||
private permissionRequestId = 700;
|
||||
lastPermissionSelection: string | undefined;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.input.on("line", (line) => {
|
||||
const message = JSON.parse(line) as Record<string, unknown>;
|
||||
if (typeof message.method === "string") {
|
||||
this.handleRequest(message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.id === this.permissionRequestId) {
|
||||
const optionId =
|
||||
(message.result as { outcome?: { optionId?: unknown } } | undefined)?.outcome?.optionId;
|
||||
if (typeof optionId === "string") {
|
||||
this.lastPermissionSelection = optionId;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
kill(): boolean {
|
||||
if (this.killed) {
|
||||
return true;
|
||||
}
|
||||
this.killed = true;
|
||||
this.emit("exit", 0, null);
|
||||
return true;
|
||||
}
|
||||
|
||||
emitPermissionRequest(): void {
|
||||
this.emitServerMessage({
|
||||
jsonrpc: "2.0",
|
||||
id: this.permissionRequestId,
|
||||
method: "session/request_permission",
|
||||
params: {
|
||||
sessionId: "acp-session-1",
|
||||
toolCall: {
|
||||
toolCallId: "tool-perm-1",
|
||||
kind: "execute",
|
||||
title: "`pwd`",
|
||||
},
|
||||
options: [
|
||||
{ optionId: "allow-once", kind: "allow_once" },
|
||||
{ optionId: "allow-always", kind: "allow_always" },
|
||||
{ optionId: "reject-once", kind: "reject_once" },
|
||||
],
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
private handleRequest(message: Record<string, unknown>): void {
|
||||
const method = message.method;
|
||||
const id = message.id;
|
||||
if (typeof method !== "string" || (typeof id !== "string" && typeof id !== "number")) {
|
||||
return;
|
||||
}
|
||||
this.requests.push({ method, params: message.params });
|
||||
|
||||
switch (method) {
|
||||
case "initialize": {
|
||||
const protocolVersion = (message.params as { protocolVersion?: unknown } | undefined)
|
||||
?.protocolVersion;
|
||||
if (typeof protocolVersion !== "number") {
|
||||
this.emitServerMessage({
|
||||
jsonrpc: "2.0",
|
||||
id,
|
||||
error: {
|
||||
code: -32602,
|
||||
message: "Invalid params",
|
||||
data: {
|
||||
_errors: [],
|
||||
protocolVersion: {
|
||||
_errors: ["Invalid input: expected number, received undefined"],
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.emitServerMessage({
|
||||
jsonrpc: "2.0",
|
||||
id,
|
||||
result: {
|
||||
protocolVersion: 1,
|
||||
agentCapabilities: {
|
||||
loadSession: true,
|
||||
},
|
||||
authMethods: [{ id: "cursor_login" }],
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
case "authenticate":
|
||||
this.emitServerMessage({
|
||||
jsonrpc: "2.0",
|
||||
id,
|
||||
result: {},
|
||||
});
|
||||
return;
|
||||
case "session/new":
|
||||
this.emitServerMessage({
|
||||
jsonrpc: "2.0",
|
||||
id,
|
||||
result: {
|
||||
sessionId: "acp-session-1",
|
||||
modes: {
|
||||
currentModeId: "agent",
|
||||
availableModes: [{ id: "agent" }],
|
||||
},
|
||||
},
|
||||
});
|
||||
return;
|
||||
case "session/load":
|
||||
this.emitServerMessage({
|
||||
jsonrpc: "2.0",
|
||||
id,
|
||||
result: {},
|
||||
});
|
||||
return;
|
||||
case "session/set_model":
|
||||
this.emitServerMessage({
|
||||
jsonrpc: "2.0",
|
||||
id,
|
||||
result: {},
|
||||
});
|
||||
return;
|
||||
case "session/prompt": {
|
||||
this.emitServerMessage({
|
||||
jsonrpc: "2.0",
|
||||
method: "session/update",
|
||||
params: {
|
||||
sessionId: "acp-session-1",
|
||||
update: {
|
||||
sessionUpdate: "agent_thought_chunk",
|
||||
content: {
|
||||
type: "text",
|
||||
text: "thinking",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
this.emitServerMessage({
|
||||
jsonrpc: "2.0",
|
||||
method: "session/update",
|
||||
params: {
|
||||
sessionId: "acp-session-1",
|
||||
update: {
|
||||
sessionUpdate: "agent_message_chunk",
|
||||
content: {
|
||||
type: "text",
|
||||
text: "hello",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
this.emitServerMessage({
|
||||
jsonrpc: "2.0",
|
||||
method: "session/update",
|
||||
params: {
|
||||
sessionId: "acp-session-1",
|
||||
update: {
|
||||
sessionUpdate: "tool_call",
|
||||
toolCallId: "tool-1",
|
||||
kind: "execute",
|
||||
title: "`pwd`",
|
||||
rawInput: { command: "pwd" },
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
this.emitServerMessage({
|
||||
jsonrpc: "2.0",
|
||||
method: "session/update",
|
||||
params: {
|
||||
sessionId: "acp-session-1",
|
||||
update: {
|
||||
sessionUpdate: "tool_call_update",
|
||||
toolCallId: "tool-1",
|
||||
status: "completed",
|
||||
rawOutput: {
|
||||
exitCode: 0,
|
||||
stdout: "/tmp/project",
|
||||
stderr: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
this.emitServerMessage({
|
||||
jsonrpc: "2.0",
|
||||
id,
|
||||
result: {
|
||||
stopReason: "end_turn",
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
case "session/cancel":
|
||||
this.emitServerMessage({
|
||||
jsonrpc: "2.0",
|
||||
id,
|
||||
error: {
|
||||
code: -32601,
|
||||
message: "Method not found",
|
||||
},
|
||||
});
|
||||
return;
|
||||
default:
|
||||
this.emitServerMessage({
|
||||
jsonrpc: "2.0",
|
||||
id,
|
||||
error: {
|
||||
code: -32601,
|
||||
message: `Unhandled method: ${method}`,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private emitServerMessage(message: unknown): void {
|
||||
this.stdout.write(`${JSON.stringify(message)}\n`);
|
||||
}
|
||||
}
|
||||
|
||||
describe("CursorAdapterLive", () => {
|
||||
it.effect("returns validation error for non-cursor provider on startSession", () => {
|
||||
const fake = new FakeCursorAcpProcess();
|
||||
const layer = makeCursorAdapterLive({
|
||||
createProcess: () => fake as never,
|
||||
});
|
||||
|
||||
return Effect.gen(function* () {
|
||||
const adapter = yield* CursorAdapter;
|
||||
const result = yield* adapter
|
||||
.startSession({
|
||||
provider: "codex",
|
||||
threadId: THREAD_ID,
|
||||
runtimeMode: "full-access",
|
||||
})
|
||||
.pipe(Effect.result);
|
||||
|
||||
assert.equal(result._tag, "Failure");
|
||||
if (result._tag !== "Failure") {
|
||||
return;
|
||||
}
|
||||
assert.deepEqual(
|
||||
result.failure,
|
||||
new ProviderAdapterValidationError({
|
||||
provider: "cursor",
|
||||
operation: "startSession",
|
||||
issue: "Expected provider 'cursor' but received 'codex'.",
|
||||
}),
|
||||
);
|
||||
}).pipe(Effect.provide(layer));
|
||||
});
|
||||
|
||||
it.effect("maps ACP prompt/update events into canonical runtime events", () => {
|
||||
const fake = new FakeCursorAcpProcess();
|
||||
const layer = makeCursorAdapterLive({
|
||||
createProcess: () => fake as never,
|
||||
});
|
||||
|
||||
return Effect.gen(function* () {
|
||||
const adapter = yield* CursorAdapter;
|
||||
|
||||
const eventsFiber = yield* Stream.take(adapter.streamEvents, 13).pipe(
|
||||
Stream.runCollect,
|
||||
Effect.forkChild,
|
||||
);
|
||||
|
||||
const session = yield* adapter.startSession({
|
||||
provider: "cursor",
|
||||
threadId: THREAD_ID,
|
||||
cwd: "/tmp/project",
|
||||
runtimeMode: "full-access",
|
||||
});
|
||||
|
||||
const turn = yield* adapter.sendTurn({
|
||||
threadId: session.threadId,
|
||||
input: "hello",
|
||||
attachments: [],
|
||||
});
|
||||
|
||||
const events = Array.from(yield* Fiber.join(eventsFiber));
|
||||
assert.deepEqual(
|
||||
events.map((event) => event.type),
|
||||
[
|
||||
"session.configured",
|
||||
"auth.status",
|
||||
"auth.status",
|
||||
"session.started",
|
||||
"thread.started",
|
||||
"session.state.changed",
|
||||
"turn.started",
|
||||
"content.delta",
|
||||
"content.delta",
|
||||
"item.started",
|
||||
"item.completed",
|
||||
"item.completed",
|
||||
"turn.completed",
|
||||
],
|
||||
);
|
||||
|
||||
const turnStarted = events[6];
|
||||
assert.equal(turnStarted?.type, "turn.started");
|
||||
if (turnStarted?.type === "turn.started") {
|
||||
assert.equal(String(turnStarted.turnId), String(turn.turnId));
|
||||
}
|
||||
|
||||
const completion = events[12];
|
||||
assert.equal(completion?.type, "turn.completed");
|
||||
if (completion?.type === "turn.completed") {
|
||||
assert.equal(completion.payload.state, "completed");
|
||||
}
|
||||
}).pipe(Effect.provide(layer));
|
||||
});
|
||||
|
||||
it.effect("passes requested model to ACP process startup", () => {
|
||||
const fake = new FakeCursorAcpProcess();
|
||||
let createProcessInput:
|
||||
| {
|
||||
readonly binaryPath: string;
|
||||
readonly cwd: string;
|
||||
readonly env: NodeJS.ProcessEnv;
|
||||
readonly model?: string;
|
||||
}
|
||||
| undefined;
|
||||
const layer = makeCursorAdapterLive({
|
||||
createProcess: (input) => {
|
||||
createProcessInput = input;
|
||||
return fake as never;
|
||||
},
|
||||
});
|
||||
|
||||
return Effect.gen(function* () {
|
||||
const adapter = yield* CursorAdapter;
|
||||
yield* adapter.startSession({
|
||||
provider: "cursor",
|
||||
threadId: THREAD_ID,
|
||||
model: "composer-1.5",
|
||||
runtimeMode: "full-access",
|
||||
});
|
||||
|
||||
assert.deepEqual(createProcessInput?.model, "composer-1.5");
|
||||
}).pipe(Effect.provide(layer));
|
||||
});
|
||||
|
||||
it.effect("writes provider-native observability records when enabled", () => {
|
||||
const nativeEvents: Array<{
|
||||
event?: {
|
||||
provider?: string;
|
||||
method?: string;
|
||||
threadId?: string;
|
||||
};
|
||||
}> = [];
|
||||
const fake = new FakeCursorAcpProcess();
|
||||
const layer = makeCursorAdapterLive({
|
||||
createProcess: () => fake as never,
|
||||
nativeEventLogger: {
|
||||
filePath: "memory://cursor-native-events",
|
||||
write: (event) => {
|
||||
nativeEvents.push(event as (typeof nativeEvents)[number]);
|
||||
return Effect.void;
|
||||
},
|
||||
close: () => Effect.void,
|
||||
},
|
||||
});
|
||||
|
||||
return Effect.gen(function* () {
|
||||
const adapter = yield* CursorAdapter;
|
||||
const session = yield* adapter.startSession({
|
||||
provider: "cursor",
|
||||
threadId: THREAD_ID,
|
||||
cwd: "/tmp/project",
|
||||
runtimeMode: "full-access",
|
||||
});
|
||||
|
||||
assert.equal(nativeEvents.length > 0, true);
|
||||
assert.equal(nativeEvents.some((record) => record.event?.provider === "cursor"), true);
|
||||
assert.equal(nativeEvents.some((record) => record.event?.threadId === session.threadId), true);
|
||||
assert.equal(nativeEvents.some((record) => record.event?.method === "cursor/acp/response"), true);
|
||||
}).pipe(Effect.provide(layer));
|
||||
});
|
||||
|
||||
it.effect("resumes ACP session using resumeCursor.acpSessionId", () => {
|
||||
const fake = new FakeCursorAcpProcess();
|
||||
const layer = makeCursorAdapterLive({
|
||||
createProcess: () => fake as never,
|
||||
});
|
||||
|
||||
return Effect.gen(function* () {
|
||||
const adapter = yield* CursorAdapter;
|
||||
const session = yield* adapter.startSession({
|
||||
provider: "cursor",
|
||||
threadId: RESUME_THREAD_ID,
|
||||
cwd: "/tmp/project",
|
||||
resumeCursor: {
|
||||
acpSessionId: "acp-session-resume",
|
||||
},
|
||||
runtimeMode: "full-access",
|
||||
});
|
||||
|
||||
const methods = new Set(fake.requests.map((request) => request.method));
|
||||
assert.equal(methods.has("session/load"), true);
|
||||
assert.equal(methods.has("session/new"), false);
|
||||
|
||||
const loadRequest = fake.requests.find((request) => request.method === "session/load");
|
||||
assert.deepEqual(loadRequest?.params, {
|
||||
sessionId: "acp-session-resume",
|
||||
cwd: "/tmp/project",
|
||||
mcpServers: [],
|
||||
});
|
||||
assert.equal(session.threadId, RESUME_THREAD_ID);
|
||||
assert.deepEqual(session.resumeCursor, {
|
||||
acpSessionId: "acp-session-resume",
|
||||
});
|
||||
}).pipe(Effect.provide(layer));
|
||||
});
|
||||
|
||||
it.effect("accepts legacy resumeCursor.sessionId for ACP session resume", () => {
|
||||
const fake = new FakeCursorAcpProcess();
|
||||
const layer = makeCursorAdapterLive({
|
||||
createProcess: () => fake as never,
|
||||
});
|
||||
|
||||
return Effect.gen(function* () {
|
||||
const adapter = yield* CursorAdapter;
|
||||
const session = yield* adapter.startSession({
|
||||
provider: "cursor",
|
||||
threadId: LEGACY_RESUME_THREAD_ID,
|
||||
cwd: "/tmp/project",
|
||||
resumeCursor: {
|
||||
sessionId: "acp-session-legacy",
|
||||
},
|
||||
runtimeMode: "full-access",
|
||||
});
|
||||
|
||||
const loadRequest = fake.requests.find((request) => request.method === "session/load");
|
||||
assert.deepEqual(loadRequest?.params, {
|
||||
sessionId: "acp-session-legacy",
|
||||
cwd: "/tmp/project",
|
||||
mcpServers: [],
|
||||
});
|
||||
assert.equal(session.threadId, LEGACY_RESUME_THREAD_ID);
|
||||
assert.deepEqual(session.resumeCursor, {
|
||||
acpSessionId: "acp-session-legacy",
|
||||
});
|
||||
}).pipe(Effect.provide(layer));
|
||||
});
|
||||
|
||||
it.effect("bridges permission requests to request.opened/request.resolved", () => {
|
||||
const fake = new FakeCursorAcpProcess();
|
||||
const layer = makeCursorAdapterLive({
|
||||
createProcess: () => fake as never,
|
||||
});
|
||||
|
||||
return Effect.gen(function* () {
|
||||
const adapter = yield* CursorAdapter;
|
||||
|
||||
const session = yield* adapter.startSession({
|
||||
provider: "cursor",
|
||||
threadId: THREAD_ID,
|
||||
runtimeMode: "approval-required",
|
||||
});
|
||||
|
||||
// consume startup events
|
||||
yield* Stream.take(adapter.streamEvents, 6).pipe(Stream.runDrain);
|
||||
|
||||
fake.emitPermissionRequest();
|
||||
|
||||
const opened = yield* Stream.runHead(adapter.streamEvents);
|
||||
assert.equal(opened._tag, "Some");
|
||||
if (opened._tag !== "Some") {
|
||||
return;
|
||||
}
|
||||
assert.equal(opened.value.type, "request.opened");
|
||||
if (opened.value.type !== "request.opened") {
|
||||
return;
|
||||
}
|
||||
const runtimeRequestId = opened.value.requestId;
|
||||
assert.equal(typeof runtimeRequestId, "string");
|
||||
if (runtimeRequestId === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
yield* adapter.respondToRequest(
|
||||
session.threadId,
|
||||
ApprovalRequestId.makeUnsafe(runtimeRequestId),
|
||||
"acceptForSession",
|
||||
);
|
||||
|
||||
const resolved = yield* Stream.runHead(adapter.streamEvents);
|
||||
assert.equal(resolved._tag, "Some");
|
||||
if (resolved._tag !== "Some") {
|
||||
return;
|
||||
}
|
||||
assert.equal(resolved.value.type, "request.resolved");
|
||||
if (resolved.value.type !== "request.resolved") {
|
||||
return;
|
||||
}
|
||||
assert.equal(resolved.value.payload.decision, "acceptForSession");
|
||||
assert.equal(fake.lastPermissionSelection, "allow-always");
|
||||
}).pipe(Effect.provide(layer));
|
||||
});
|
||||
|
||||
it.effect("auto-approves cursor permission requests when approval policy is never", () => {
|
||||
const fake = new FakeCursorAcpProcess();
|
||||
const layer = makeCursorAdapterLive({
|
||||
createProcess: () => fake as never,
|
||||
});
|
||||
|
||||
return Effect.gen(function* () {
|
||||
const adapter = yield* CursorAdapter;
|
||||
|
||||
yield* adapter.startSession({
|
||||
provider: "cursor",
|
||||
threadId: THREAD_ID,
|
||||
runtimeMode: "full-access",
|
||||
});
|
||||
|
||||
// consume startup events
|
||||
yield* Stream.take(adapter.streamEvents, 6).pipe(Stream.runDrain);
|
||||
|
||||
fake.emitPermissionRequest();
|
||||
|
||||
const resolved = yield* Stream.runHead(adapter.streamEvents);
|
||||
assert.equal(resolved._tag, "Some");
|
||||
if (resolved._tag !== "Some") {
|
||||
return;
|
||||
}
|
||||
|
||||
assert.equal(resolved.value.type, "request.resolved");
|
||||
if (resolved.value.type !== "request.resolved") {
|
||||
return;
|
||||
}
|
||||
|
||||
assert.equal(resolved.value.payload.decision, "acceptForSession");
|
||||
assert.equal(fake.lastPermissionSelection, "allow-always");
|
||||
}).pipe(Effect.provide(layer));
|
||||
});
|
||||
|
||||
it.effect("rejects empty prompt input before starting a turn", () => {
|
||||
const fake = new FakeCursorAcpProcess();
|
||||
const layer = makeCursorAdapterLive({
|
||||
createProcess: () => fake as never,
|
||||
});
|
||||
|
||||
return Effect.gen(function* () {
|
||||
const adapter = yield* CursorAdapter;
|
||||
const session = yield* adapter.startSession({
|
||||
provider: "cursor",
|
||||
threadId: THREAD_ID,
|
||||
runtimeMode: "full-access",
|
||||
});
|
||||
|
||||
yield* Stream.take(adapter.streamEvents, 6).pipe(Stream.runDrain);
|
||||
|
||||
const result = yield* adapter
|
||||
.sendTurn({
|
||||
threadId: session.threadId,
|
||||
input: " ",
|
||||
attachments: [],
|
||||
})
|
||||
.pipe(Effect.result);
|
||||
|
||||
assert.equal(result._tag, "Failure");
|
||||
if (result._tag !== "Failure") {
|
||||
return;
|
||||
}
|
||||
assert.deepEqual(
|
||||
result.failure,
|
||||
new ProviderAdapterValidationError({
|
||||
provider: "cursor",
|
||||
operation: "sendTurn",
|
||||
issue: "Turn input must be non-empty.",
|
||||
}),
|
||||
);
|
||||
|
||||
assert.equal(fake.requests.some((request) => request.method === "session/prompt"), false);
|
||||
}).pipe(Effect.provide(layer));
|
||||
});
|
||||
|
||||
it.effect("keeps tool_call item types consistent through tool_call_update", () => {
|
||||
const fake = new FakeCursorAcpProcess();
|
||||
const layer = makeCursorAdapterLive({
|
||||
createProcess: () => fake as never,
|
||||
});
|
||||
|
||||
return Effect.gen(function* () {
|
||||
const adapter = yield* CursorAdapter;
|
||||
|
||||
const eventsFiber = yield* Stream.take(adapter.streamEvents, 13).pipe(
|
||||
Stream.runCollect,
|
||||
Effect.forkChild,
|
||||
);
|
||||
|
||||
const session = yield* adapter.startSession({
|
||||
provider: "cursor",
|
||||
threadId: THREAD_ID,
|
||||
runtimeMode: "full-access",
|
||||
});
|
||||
|
||||
yield* adapter.sendTurn({
|
||||
threadId: session.threadId,
|
||||
input: "hello",
|
||||
attachments: [],
|
||||
});
|
||||
|
||||
const events = Array.from(yield* Fiber.join(eventsFiber));
|
||||
const started = events.find(
|
||||
(event) => event.type === "item.started" && String(event.itemId) === "tool-1",
|
||||
);
|
||||
const completed = events.find(
|
||||
(event) => event.type === "item.completed" && String(event.itemId) === "tool-1",
|
||||
);
|
||||
|
||||
assert.equal(started?.type, "item.started");
|
||||
assert.equal(completed?.type, "item.completed");
|
||||
if (started?.type !== "item.started" || completed?.type !== "item.completed") {
|
||||
return;
|
||||
}
|
||||
|
||||
assert.equal(started.payload.itemType, "command_execution");
|
||||
assert.equal(completed.payload.itemType, "command_execution");
|
||||
}).pipe(Effect.provide(layer));
|
||||
});
|
||||
});
|
||||
File diff suppressed because it is too large.
Load diff
@@ -5,6 +5,7 @@ import { assertFailure } from "@effect/vitest/utils";
|
||||
import { Effect, Layer, Stream } from "effect";
|
||||
|
||||
import { CodexAdapter, CodexAdapterShape } from "../Services/CodexAdapter.ts";
|
||||
import { CursorAdapter, CursorAdapterShape } from "../Services/CursorAdapter.ts";
|
||||
import { ProviderAdapterRegistry } from "../Services/ProviderAdapterRegistry.ts";
|
||||
import { ProviderAdapterRegistryLive } from "./ProviderAdapterRegistry.ts";
|
||||
import { ProviderUnsupportedError } from "../Errors.ts";
|
||||
@@ -12,10 +13,12 @@ import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
|
||||
const fakeCodexAdapter: CodexAdapterShape = {
|
||||
provider: "codex",
|
||||
capabilities: { sessionModelSwitch: "in-session" },
|
||||
startSession: vi.fn(),
|
||||
sendTurn: vi.fn(),
|
||||
interruptTurn: vi.fn(),
|
||||
respondToRequest: vi.fn(),
|
||||
respondToUserInput: vi.fn(),
|
||||
stopSession: vi.fn(),
|
||||
listSessions: vi.fn(),
|
||||
hasSession: vi.fn(),
|
||||
@@ -25,9 +28,31 @@ const fakeCodexAdapter: CodexAdapterShape = {
|
||||
streamEvents: Stream.empty,
|
||||
};
|
||||
|
||||
const fakeCursorAdapter: CursorAdapterShape = {
|
||||
provider: "cursor",
|
||||
capabilities: { sessionModelSwitch: "unsupported" },
|
||||
startSession: vi.fn(),
|
||||
sendTurn: vi.fn(),
|
||||
interruptTurn: vi.fn(),
|
||||
respondToRequest: vi.fn(),
|
||||
respondToUserInput: vi.fn(),
|
||||
stopSession: vi.fn(),
|
||||
listSessions: vi.fn(),
|
||||
hasSession: vi.fn(),
|
||||
readThread: vi.fn(),
|
||||
rollbackThread: vi.fn(),
|
||||
stopAll: vi.fn(),
|
||||
streamEvents: Stream.empty,
|
||||
};
|
||||
const layer = it.layer(
|
||||
Layer.mergeAll(
|
||||
Layer.provide(ProviderAdapterRegistryLive, Layer.succeed(CodexAdapter, fakeCodexAdapter)),
|
||||
Layer.provide(
|
||||
ProviderAdapterRegistryLive,
|
||||
Layer.mergeAll(
|
||||
Layer.succeed(CodexAdapter, fakeCodexAdapter),
|
||||
Layer.succeed(CursorAdapter, fakeCursorAdapter),
|
||||
),
|
||||
),
|
||||
NodeServices.layer,
|
||||
),
|
||||
);
|
||||
@@ -36,11 +61,13 @@ layer("ProviderAdapterRegistryLive", (it) => {
|
||||
it.effect("resolves a registered provider adapter", () =>
|
||||
Effect.gen(function* () {
|
||||
const registry = yield* ProviderAdapterRegistry;
|
||||
const adapter = yield* registry.getByProvider("codex");
|
||||
assert.equal(adapter, fakeCodexAdapter);
|
||||
const codex = yield* registry.getByProvider("codex");
|
||||
const cursor = yield* registry.getByProvider("cursor");
|
||||
assert.equal(codex, fakeCodexAdapter);
|
||||
assert.equal(cursor, fakeCursorAdapter);
|
||||
|
||||
const providers = yield* registry.listProviders();
|
||||
assert.deepEqual(providers, ["codex"]);
|
||||
assert.deepEqual(providers, ["codex", "cursor"]);
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* ProviderAdapterRegistryLive - In-memory provider adapter lookup layer.
|
||||
*
|
||||
* Binds provider kinds (codex/claudeCode/...) to concrete adapter services.
|
||||
* Binds provider kinds (codex/cursor/...) to concrete adapter services.
|
||||
* This layer only performs adapter lookup; it does not route session-scoped
|
||||
* calls or own provider lifecycle workflows.
|
||||
*
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
type ProviderAdapterRegistryShape,
|
||||
} from "../Services/ProviderAdapterRegistry.ts";
|
||||
import { CodexAdapter } from "../Services/CodexAdapter.ts";
|
||||
import { CursorAdapter } from "../Services/CursorAdapter.ts";
|
||||
|
||||
export interface ProviderAdapterRegistryLiveOptions {
|
||||
readonly adapters?: ReadonlyArray<ProviderAdapterShape<ProviderAdapterError>>;
|
||||
@@ -23,7 +24,10 @@ export interface ProviderAdapterRegistryLiveOptions {
|
||||
|
||||
const makeProviderAdapterRegistry = (options?: ProviderAdapterRegistryLiveOptions) =>
|
||||
Effect.gen(function* () {
|
||||
const adapters = options?.adapters !== undefined ? options.adapters : [yield* CodexAdapter];
|
||||
const adapters =
|
||||
options?.adapters !== undefined
|
||||
? options.adapters
|
||||
: [yield* CodexAdapter, yield* CursorAdapter];
|
||||
const byProvider = new Map(adapters.map((adapter) => [adapter.provider, adapter]));
|
||||
|
||||
const getByProvider: ProviderAdapterRegistryShape["getByProvider"] = (provider) => {
|
||||
|
||||
@@ -12,11 +12,10 @@ import type {
|
||||
import {
|
||||
ApprovalRequestId,
|
||||
EventId,
|
||||
type ProviderKind,
|
||||
ProviderSessionStartInput,
|
||||
ProviderSessionId,
|
||||
ProviderThreadId,
|
||||
ProviderTurnId,
|
||||
ThreadId,
|
||||
TurnId,
|
||||
} from "@t3tools/contracts";
|
||||
import { it, assert, vi } from "@effect/vitest";
|
||||
import { assertFailure } from "@effect/vitest/utils";
|
||||
@@ -26,9 +25,8 @@ import * as SqlClient from "effect/unstable/sql/SqlClient";
|
||||
|
||||
import {
|
||||
ProviderAdapterSessionNotFoundError,
|
||||
ProviderSessionNotFoundError,
|
||||
ProviderValidationError,
|
||||
ProviderUnsupportedError,
|
||||
ProviderValidationError,
|
||||
type ProviderAdapterError,
|
||||
} from "../Errors.ts";
|
||||
import type { ProviderAdapterShape } from "../Services/ProviderAdapter.ts";
|
||||
@@ -45,33 +43,42 @@ import {
|
||||
SqlitePersistenceMemory,
|
||||
} from "../../persistence/Layers/Sqlite.ts";
|
||||
|
||||
const asSessionId = (value: string): ProviderSessionId => ProviderSessionId.makeUnsafe(value);
|
||||
const asTurnId = (value: string): ProviderTurnId => ProviderTurnId.makeUnsafe(value);
|
||||
const asProviderThreadId = (value: string): ProviderThreadId => ProviderThreadId.makeUnsafe(value);
|
||||
const asRequestId = (value: string): ApprovalRequestId => ApprovalRequestId.makeUnsafe(value);
|
||||
const asEventId = (value: string): EventId => EventId.makeUnsafe(value);
|
||||
const asThreadId = (value: string): ThreadId => ThreadId.makeUnsafe(value);
|
||||
const asTurnId = (value: string): TurnId => TurnId.makeUnsafe(value);
|
||||
|
||||
function makeFakeCodexAdapter() {
|
||||
const sessions = new Map<ProviderSessionId, ProviderSession>();
|
||||
type LegacyProviderRuntimeEvent = {
|
||||
readonly type: string;
|
||||
readonly eventId: EventId;
|
||||
readonly provider: "codex" | "claudeCode" | "cursor";
|
||||
readonly createdAt: string;
|
||||
readonly threadId: ThreadId;
|
||||
readonly turnId?: string | undefined;
|
||||
readonly itemId?: string | undefined;
|
||||
readonly requestId?: string | undefined;
|
||||
readonly payload?: unknown | undefined;
|
||||
readonly [key: string]: unknown;
|
||||
};
|
||||
|
||||
function makeFakeCodexAdapter(provider: ProviderKind = "codex") {
|
||||
const sessions = new Map<ThreadId, ProviderSession>();
|
||||
const runtimeEventPubSub = Effect.runSync(PubSub.unbounded<ProviderRuntimeEvent>());
|
||||
let nextSession = 1;
|
||||
|
||||
const startSession = vi.fn((input: ProviderSessionStartInput) =>
|
||||
Effect.sync(() => {
|
||||
const now = new Date().toISOString();
|
||||
const next = nextSession;
|
||||
const session: ProviderSession = {
|
||||
sessionId: ProviderSessionId.makeUnsafe(`sess-${next}`),
|
||||
provider: "codex",
|
||||
provider,
|
||||
status: "ready",
|
||||
threadId: input.resumeThreadId ?? ProviderThreadId.makeUnsafe(`thread-${next}`),
|
||||
runtimeMode: input.runtimeMode,
|
||||
threadId: input.threadId,
|
||||
resumeCursor: input.resumeCursor ?? { opaque: `cursor-${String(input.threadId)}` },
|
||||
cwd: input.cwd ?? process.cwd(),
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
};
|
||||
nextSession += 1;
|
||||
sessions.set(session.sessionId, session);
|
||||
sessions.set(session.threadId, session);
|
||||
return session;
|
||||
}),
|
||||
);
|
||||
@@ -80,39 +87,47 @@ function makeFakeCodexAdapter() {
|
||||
(
|
||||
input: ProviderSendTurnInput,
|
||||
): Effect.Effect<ProviderTurnStartResult, ProviderAdapterError> => {
|
||||
if (!sessions.has(input.sessionId)) {
|
||||
if (!sessions.has(input.threadId)) {
|
||||
return Effect.fail(
|
||||
new ProviderAdapterSessionNotFoundError({
|
||||
provider: "codex",
|
||||
sessionId: input.sessionId,
|
||||
provider,
|
||||
threadId: input.threadId,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
return Effect.succeed({
|
||||
threadId: ProviderThreadId.makeUnsafe("thread-1"),
|
||||
turnId: ProviderTurnId.makeUnsafe("turn-1"),
|
||||
threadId: input.threadId,
|
||||
turnId: TurnId.makeUnsafe(`turn-${String(input.threadId)}`),
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
const interruptTurn = vi.fn(
|
||||
(_sessionId: string, _turnId?: string): Effect.Effect<void, ProviderAdapterError> =>
|
||||
(_threadId: ThreadId, _turnId?: TurnId): Effect.Effect<void, ProviderAdapterError> =>
|
||||
Effect.void,
|
||||
);
|
||||
|
||||
const respondToRequest = vi.fn(
|
||||
(
|
||||
_sessionId: string,
|
||||
_threadId: ThreadId,
|
||||
_requestId: string,
|
||||
_decision: ProviderApprovalDecision,
|
||||
): Effect.Effect<void, ProviderAdapterError> => Effect.void,
|
||||
);
|
||||
|
||||
const respondToUserInput = vi.fn(
|
||||
(
|
||||
_threadId: ThreadId,
|
||||
_requestId: string,
|
||||
_answers: Record<string, unknown>,
|
||||
): Effect.Effect<void, ProviderAdapterError> => Effect.void,
|
||||
);
|
||||
|
||||
const stopSession = vi.fn(
|
||||
(sessionId: string): Effect.Effect<void, ProviderAdapterError> =>
|
||||
(threadId: ThreadId): Effect.Effect<void, ProviderAdapterError> =>
|
||||
Effect.sync(() => {
|
||||
sessions.delete(ProviderSessionId.makeUnsafe(sessionId));
|
||||
sessions.delete(threadId);
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -122,32 +137,31 @@ function makeFakeCodexAdapter() {
|
||||
);
|
||||
|
||||
const hasSession = vi.fn(
|
||||
(sessionId: string): Effect.Effect<boolean> =>
|
||||
Effect.succeed(sessions.has(ProviderSessionId.makeUnsafe(sessionId))),
|
||||
(threadId: ThreadId): Effect.Effect<boolean> => Effect.succeed(sessions.has(threadId)),
|
||||
);
|
||||
|
||||
const readThread = vi.fn(
|
||||
(
|
||||
_sessionId: ProviderSessionId,
|
||||
threadId: ThreadId,
|
||||
): Effect.Effect<
|
||||
{
|
||||
threadId: ProviderThreadId;
|
||||
turns: ReadonlyArray<{ id: ProviderTurnId; items: readonly [] }>;
|
||||
threadId: ThreadId;
|
||||
turns: ReadonlyArray<{ id: TurnId; items: readonly [] }>;
|
||||
},
|
||||
ProviderAdapterError
|
||||
> =>
|
||||
Effect.succeed({
|
||||
threadId: ProviderThreadId.makeUnsafe("thread-1"),
|
||||
threadId,
|
||||
turns: [{ id: asTurnId("turn-1"), items: [] }],
|
||||
}),
|
||||
);
|
||||
|
||||
const rollbackThread = vi.fn(
|
||||
(
|
||||
_sessionId: ProviderSessionId,
|
||||
threadId: ThreadId,
|
||||
_numTurns: number,
|
||||
): Effect.Effect<{ threadId: ProviderThreadId; turns: readonly [] }, ProviderAdapterError> =>
|
||||
Effect.succeed({ threadId: ProviderThreadId.makeUnsafe("thread-1"), turns: [] }),
|
||||
): Effect.Effect<{ threadId: ThreadId; turns: readonly [] }, ProviderAdapterError> =>
|
||||
Effect.succeed({ threadId, turns: [] }),
|
||||
);
|
||||
|
||||
const stopAll = vi.fn(
|
||||
@@ -158,11 +172,15 @@ function makeFakeCodexAdapter() {
|
||||
);
|
||||
|
||||
const adapter: ProviderAdapterShape<ProviderAdapterError> = {
|
||||
provider: "codex",
|
||||
provider,
|
||||
capabilities: {
|
||||
sessionModelSwitch: "in-session",
|
||||
},
|
||||
startSession,
|
||||
sendTurn,
|
||||
interruptTurn,
|
||||
respondToRequest,
|
||||
respondToUserInput,
|
||||
stopSession,
|
||||
listSessions,
|
||||
hasSession,
|
||||
@@ -172,8 +190,8 @@ function makeFakeCodexAdapter() {
|
||||
streamEvents: Stream.fromPubSub(runtimeEventPubSub),
|
||||
};
|
||||
|
||||
const emit = (event: ProviderRuntimeEvent): void => {
|
||||
Effect.runSync(PubSub.publish(runtimeEventPubSub, event));
|
||||
const emit = (event: LegacyProviderRuntimeEvent): void => {
|
||||
Effect.runSync(PubSub.publish(runtimeEventPubSub, event as unknown as ProviderRuntimeEvent));
|
||||
};
|
||||
|
||||
return {
|
||||
@@ -183,6 +201,7 @@ function makeFakeCodexAdapter() {
|
||||
sendTurn,
|
||||
interruptTurn,
|
||||
respondToRequest,
|
||||
respondToUserInput,
|
||||
stopSession,
|
||||
listSessions,
|
||||
hasSession,
|
||||
@@ -197,12 +216,15 @@ const sleep = (ms: number) =>
|
||||
|
||||
function makeProviderServiceLayer() {
|
||||
const codex = makeFakeCodexAdapter();
|
||||
const claude = makeFakeCodexAdapter("claudeCode");
|
||||
const registry: typeof ProviderAdapterRegistry.Service = {
|
||||
getByProvider: (provider) =>
|
||||
provider === "codex"
|
||||
? Effect.succeed(codex.adapter)
|
||||
: Effect.fail(new ProviderUnsupportedError({ provider })),
|
||||
listProviders: () => Effect.succeed(["codex"]),
|
||||
: provider === "claudeCode"
|
||||
? Effect.succeed(claude.adapter)
|
||||
: Effect.fail(new ProviderUnsupportedError({ provider })),
|
||||
listProviders: () => Effect.succeed(["codex", "claudeCode"]),
|
||||
};
|
||||
|
||||
const providerAdapterLayer = Layer.succeed(ProviderAdapterRegistry, registry);
|
||||
@@ -225,6 +247,7 @@ function makeProviderServiceLayer() {
|
||||
|
||||
return {
|
||||
codex,
|
||||
claude,
|
||||
layer,
|
||||
};
|
||||
}
|
||||
@@ -253,7 +276,6 @@ it.effect("ProviderServiceLive keeps persisted resumable sessions on startup", (
|
||||
yield* Effect.gen(function* () {
|
||||
const directory = yield* ProviderSessionDirectory;
|
||||
yield* directory.upsert({
|
||||
sessionId: asSessionId("sess-stale"),
|
||||
provider: "codex",
|
||||
threadId: ThreadId.makeUnsafe("thread-stale"),
|
||||
});
|
||||
@@ -270,13 +292,13 @@ it.effect("ProviderServiceLive keeps persisted resumable sessions on startup", (
|
||||
|
||||
const persistedProvider = yield* Effect.gen(function* () {
|
||||
const directory = yield* ProviderSessionDirectory;
|
||||
return yield* directory.getProvider(asSessionId("sess-stale"));
|
||||
return yield* directory.getProvider(asThreadId("thread-stale"));
|
||||
}).pipe(Effect.provide(directoryLayer));
|
||||
assert.equal(persistedProvider, "codex");
|
||||
|
||||
const runtime = yield* Effect.gen(function* () {
|
||||
const repository = yield* ProviderSessionRuntimeRepository;
|
||||
return yield* repository.getBySessionId({ providerSessionId: asSessionId("sess-stale") });
|
||||
return yield* repository.getByThreadId({ threadId: asThreadId("thread-stale") });
|
||||
}).pipe(Effect.provide(runtimeRepositoryLayer));
|
||||
assert.equal(Option.isSome(runtime), true);
|
||||
|
||||
@@ -324,9 +346,12 @@ it.effect(
|
||||
|
||||
const startedSession = yield* Effect.gen(function* () {
|
||||
const provider = yield* ProviderService;
|
||||
return yield* provider.startSession(asThreadId("thread-1"), {
|
||||
const threadId = asThreadId("thread-1");
|
||||
return yield* provider.startSession(threadId, {
|
||||
provider: "codex",
|
||||
cwd: "/tmp/project",
|
||||
runtimeMode: "full-access",
|
||||
threadId,
|
||||
});
|
||||
}).pipe(Effect.provide(firstProviderLayer));
|
||||
|
||||
@@ -337,14 +362,12 @@ it.effect(
|
||||
|
||||
const persistedAfterStopAll = yield* Effect.gen(function* () {
|
||||
const repository = yield* ProviderSessionRuntimeRepository;
|
||||
return yield* repository.getBySessionId({
|
||||
providerSessionId: startedSession.sessionId,
|
||||
});
|
||||
return yield* repository.getByThreadId({ threadId: startedSession.threadId });
|
||||
}).pipe(Effect.provide(runtimeRepositoryLayer));
|
||||
assert.equal(Option.isSome(persistedAfterStopAll), true);
|
||||
if (Option.isSome(persistedAfterStopAll)) {
|
||||
assert.equal(persistedAfterStopAll.value.status, "stopped");
|
||||
assert.equal(persistedAfterStopAll.value.resumeCursor, null);
|
||||
assert.deepEqual(persistedAfterStopAll.value.resumeCursor, startedSession.resumeCursor);
|
||||
}
|
||||
|
||||
const secondCodex = makeFakeCodexAdapter();
|
||||
@@ -369,20 +392,26 @@ it.effect(
|
||||
yield* Effect.gen(function* () {
|
||||
const provider = yield* ProviderService;
|
||||
yield* provider.rollbackConversation({
|
||||
sessionId: startedSession.sessionId,
|
||||
threadId: startedSession.threadId,
|
||||
numTurns: 1,
|
||||
});
|
||||
}).pipe(Effect.provide(secondProviderLayer));
|
||||
|
||||
assert.deepEqual(secondCodex.startSession.mock.calls, [
|
||||
[
|
||||
{
|
||||
provider: "codex",
|
||||
cwd: "/tmp/project",
|
||||
resumeThreadId: startedSession.threadId,
|
||||
},
|
||||
],
|
||||
]);
|
||||
assert.equal(secondCodex.startSession.mock.calls.length, 1);
|
||||
const resumedStartInput = secondCodex.startSession.mock.calls[0]?.[0];
|
||||
assert.equal(typeof resumedStartInput === "object" && resumedStartInput !== null, true);
|
||||
if (resumedStartInput && typeof resumedStartInput === "object") {
|
||||
const startPayload = resumedStartInput as {
|
||||
provider?: string;
|
||||
cwd?: string;
|
||||
resumeCursor?: unknown;
|
||||
threadId?: string;
|
||||
};
|
||||
assert.equal(startPayload.provider, "codex");
|
||||
assert.equal(startPayload.cwd, "/tmp/project");
|
||||
assert.deepEqual(startPayload.resumeCursor, startedSession.resumeCursor);
|
||||
assert.equal(startPayload.threadId, startedSession.threadId);
|
||||
}
|
||||
assert.equal(secondCodex.rollbackThread.mock.calls.length, 1);
|
||||
const rollbackCall = secondCodex.rollbackThread.mock.calls[0];
|
||||
assert.equal(typeof rollbackCall?.[0], "string");
|
||||
@@ -399,7 +428,9 @@ routing.layer("ProviderServiceLive routing", (it) => {
|
||||
|
||||
const session = yield* provider.startSession(asThreadId("thread-1"), {
|
||||
provider: "codex",
|
||||
threadId: asThreadId("thread-1"),
|
||||
cwd: "/tmp/project",
|
||||
runtimeMode: "full-access",
|
||||
});
|
||||
assert.equal(session.provider, "codex");
|
||||
|
||||
@@ -407,70 +438,121 @@ routing.layer("ProviderServiceLive routing", (it) => {
|
||||
assert.equal(sessions.length, 1);
|
||||
|
||||
yield* provider.sendTurn({
|
||||
sessionId: session.sessionId,
|
||||
threadId: session.threadId,
|
||||
input: "hello",
|
||||
attachments: [],
|
||||
});
|
||||
assert.equal(routing.codex.sendTurn.mock.calls.length, 1);
|
||||
|
||||
yield* provider.interruptTurn({ sessionId: session.sessionId });
|
||||
assert.deepEqual(routing.codex.interruptTurn.mock.calls, [[session.sessionId, undefined]]);
|
||||
yield* provider.interruptTurn({ threadId: session.threadId });
|
||||
assert.deepEqual(routing.codex.interruptTurn.mock.calls, [[session.threadId, undefined]]);
|
||||
|
||||
yield* provider.respondToRequest({
|
||||
sessionId: session.sessionId,
|
||||
threadId: session.threadId,
|
||||
requestId: asRequestId("req-1"),
|
||||
decision: "accept",
|
||||
});
|
||||
assert.deepEqual(routing.codex.respondToRequest.mock.calls, [
|
||||
[session.sessionId, asRequestId("req-1"), "accept"],
|
||||
[session.threadId, asRequestId("req-1"), "accept"],
|
||||
]);
|
||||
|
||||
yield* provider.respondToUserInput({
|
||||
threadId: session.threadId,
|
||||
requestId: asRequestId("req-user-input-1"),
|
||||
answers: {
|
||||
sandbox_mode: "workspace-write",
|
||||
},
|
||||
});
|
||||
assert.deepEqual(routing.codex.respondToUserInput.mock.calls, [
|
||||
[
|
||||
session.threadId,
|
||||
asRequestId("req-user-input-1"),
|
||||
{
|
||||
sandbox_mode: "workspace-write",
|
||||
},
|
||||
],
|
||||
]);
|
||||
|
||||
yield* provider.rollbackConversation({
|
||||
sessionId: session.sessionId,
|
||||
threadId: session.threadId,
|
||||
numTurns: 0,
|
||||
});
|
||||
|
||||
yield* provider.stopSession({ sessionId: session.sessionId });
|
||||
yield* provider.stopSession({ threadId: session.threadId });
|
||||
const sendAfterStop = yield* Effect.result(
|
||||
provider.sendTurn({
|
||||
sessionId: session.sessionId,
|
||||
threadId: session.threadId,
|
||||
input: "after-stop",
|
||||
attachments: [],
|
||||
}),
|
||||
);
|
||||
assertFailure(
|
||||
sendAfterStop,
|
||||
new ProviderSessionNotFoundError({ sessionId: session.sessionId }),
|
||||
new ProviderValidationError({
|
||||
operation: "ProviderService.sendTurn",
|
||||
issue: `Cannot route thread '${session.threadId}' because no persisted provider binding exists.`,
|
||||
}),
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("routes explicit claudeCode provider session starts to the claude adapter", () =>
|
||||
Effect.gen(function* () {
|
||||
const provider = yield* ProviderService;
|
||||
|
||||
const session = yield* provider.startSession(asThreadId("thread-claude"), {
|
||||
provider: "claudeCode",
|
||||
threadId: asThreadId("thread-claude"),
|
||||
cwd: "/tmp/project-claude",
|
||||
runtimeMode: "full-access",
|
||||
});
|
||||
|
||||
assert.equal(session.provider, "claudeCode");
|
||||
assert.equal(routing.claude.startSession.mock.calls.length, 1);
|
||||
const startInput = routing.claude.startSession.mock.calls[0]?.[0];
|
||||
assert.equal(typeof startInput === "object" && startInput !== null, true);
|
||||
if (startInput && typeof startInput === "object") {
|
||||
const startPayload = startInput as { provider?: string; cwd?: string };
|
||||
assert.equal(startPayload.provider, "claudeCode");
|
||||
assert.equal(startPayload.cwd, "/tmp/project-claude");
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("recovers stale persisted sessions for rollback by resuming thread identity", () =>
|
||||
Effect.gen(function* () {
|
||||
const provider = yield* ProviderService;
|
||||
|
||||
const initial = yield* provider.startSession(asThreadId("thread-1"), {
|
||||
provider: "codex",
|
||||
threadId: asThreadId("thread-1"),
|
||||
cwd: "/tmp/project",
|
||||
runtimeMode: "full-access",
|
||||
});
|
||||
yield* routing.codex.stopSession(initial.sessionId);
|
||||
yield* routing.codex.stopSession(initial.threadId);
|
||||
routing.codex.startSession.mockClear();
|
||||
routing.codex.rollbackThread.mockClear();
|
||||
|
||||
yield* provider.rollbackConversation({
|
||||
sessionId: initial.sessionId,
|
||||
threadId: initial.threadId,
|
||||
numTurns: 1,
|
||||
});
|
||||
|
||||
assert.deepEqual(routing.codex.startSession.mock.calls, [
|
||||
[
|
||||
{
|
||||
provider: "codex",
|
||||
cwd: "/tmp/project",
|
||||
resumeThreadId: initial.threadId,
|
||||
},
|
||||
],
|
||||
]);
|
||||
assert.equal(routing.codex.startSession.mock.calls.length, 1);
|
||||
const resumedStartInput = routing.codex.startSession.mock.calls[0]?.[0];
|
||||
assert.equal(typeof resumedStartInput === "object" && resumedStartInput !== null, true);
|
||||
if (resumedStartInput && typeof resumedStartInput === "object") {
|
||||
const startPayload = resumedStartInput as {
|
||||
provider?: string;
|
||||
cwd?: string;
|
||||
resumeCursor?: unknown;
|
||||
threadId?: string;
|
||||
};
|
||||
assert.equal(startPayload.provider, "codex");
|
||||
assert.equal(startPayload.cwd, "/tmp/project");
|
||||
assert.deepEqual(startPayload.resumeCursor, initial.resumeCursor);
|
||||
assert.equal(startPayload.threadId, initial.threadId);
|
||||
}
|
||||
assert.equal(routing.codex.rollbackThread.mock.calls.length, 1);
|
||||
const rollbackCall = routing.codex.rollbackThread.mock.calls[0];
|
||||
assert.equal(rollbackCall?.[1], 1);
|
||||
@@ -483,7 +565,9 @@ routing.layer("ProviderServiceLive routing", (it) => {
|
||||
|
||||
const initial = yield* provider.startSession(asThreadId("thread-1"), {
|
||||
provider: "codex",
|
||||
threadId: asThreadId("thread-1"),
|
||||
cwd: "/tmp/project-send-turn",
|
||||
runtimeMode: "full-access",
|
||||
});
|
||||
|
||||
yield* provider.stopAll();
|
||||
@@ -491,20 +575,26 @@ routing.layer("ProviderServiceLive routing", (it) => {
|
||||
routing.codex.sendTurn.mockClear();
|
||||
|
||||
yield* provider.sendTurn({
|
||||
sessionId: initial.sessionId,
|
||||
threadId: initial.threadId,
|
||||
input: "resume",
|
||||
attachments: [],
|
||||
});
|
||||
|
||||
assert.deepEqual(routing.codex.startSession.mock.calls, [
|
||||
[
|
||||
{
|
||||
provider: "codex",
|
||||
cwd: "/tmp/project-send-turn",
|
||||
resumeThreadId: initial.threadId,
|
||||
},
|
||||
],
|
||||
]);
|
||||
assert.equal(routing.codex.startSession.mock.calls.length, 1);
|
||||
const resumedStartInput = routing.codex.startSession.mock.calls[0]?.[0];
|
||||
assert.equal(typeof resumedStartInput === "object" && resumedStartInput !== null, true);
|
||||
if (resumedStartInput && typeof resumedStartInput === "object") {
|
||||
const startPayload = resumedStartInput as {
|
||||
provider?: string;
|
||||
cwd?: string;
|
||||
resumeCursor?: unknown;
|
||||
threadId?: string;
|
||||
};
|
||||
assert.equal(startPayload.provider, "codex");
|
||||
assert.equal(startPayload.cwd, "/tmp/project-send-turn");
|
||||
assert.deepEqual(startPayload.resumeCursor, initial.resumeCursor);
|
||||
assert.equal(startPayload.threadId, initial.threadId);
|
||||
}
|
||||
assert.equal(routing.codex.sendTurn.mock.calls.length, 1);
|
||||
}),
|
||||
);
|
||||
@@ -515,9 +605,13 @@ routing.layer("ProviderServiceLive routing", (it) => {
|
||||
|
||||
yield* provider.startSession(asThreadId("thread-1"), {
|
||||
provider: "codex",
|
||||
threadId: asThreadId("thread-1"),
|
||||
runtimeMode: "full-access",
|
||||
});
|
||||
yield* provider.startSession(asThreadId("thread-2"), {
|
||||
provider: "codex",
|
||||
threadId: asThreadId("thread-2"),
|
||||
runtimeMode: "full-access",
|
||||
});
|
||||
|
||||
yield* provider.stopAll();
|
||||
@@ -534,20 +628,22 @@ routing.layer("ProviderServiceLive routing", (it) => {
|
||||
|
||||
const session = yield* provider.startSession(asThreadId("thread-1"), {
|
||||
provider: "codex",
|
||||
threadId: asThreadId("thread-1"),
|
||||
runtimeMode: "full-access",
|
||||
});
|
||||
yield* provider.sendTurn({
|
||||
sessionId: session.sessionId,
|
||||
threadId: session.threadId,
|
||||
input: "hello",
|
||||
attachments: [],
|
||||
});
|
||||
|
||||
const runningRuntime = yield* runtimeRepository.getBySessionId({
|
||||
providerSessionId: session.sessionId,
|
||||
const runningRuntime = yield* runtimeRepository.getByThreadId({
|
||||
threadId: session.threadId,
|
||||
});
|
||||
assert.equal(Option.isSome(runningRuntime), true);
|
||||
if (Option.isSome(runningRuntime)) {
|
||||
assert.equal(runningRuntime.value.status, "running");
|
||||
assert.equal(runningRuntime.value.resumeCursor, null);
|
||||
assert.deepEqual(runningRuntime.value.resumeCursor, session.resumeCursor);
|
||||
const payload = runningRuntime.value.runtimePayload;
|
||||
assert.equal(payload !== null && typeof payload === "object", true);
|
||||
if (payload !== null && typeof payload === "object" && !Array.isArray(payload)) {
|
||||
@@ -560,15 +656,15 @@ routing.layer("ProviderServiceLive routing", (it) => {
|
||||
};
|
||||
assert.equal(runtimePayload.cwd, process.cwd());
|
||||
assert.equal(runtimePayload.model, null);
|
||||
assert.equal(runtimePayload.activeTurnId, "turn-1");
|
||||
assert.equal(runtimePayload.activeTurnId, `turn-${String(session.threadId)}`);
|
||||
assert.equal(runtimePayload.lastError, null);
|
||||
assert.equal(runtimePayload.lastRuntimeEvent, "provider.sendTurn");
|
||||
}
|
||||
}
|
||||
|
||||
yield* provider.stopAll();
|
||||
const stoppedRuntime = yield* runtimeRepository.getBySessionId({
|
||||
providerSessionId: session.sessionId,
|
||||
const stoppedRuntime = yield* runtimeRepository.getByThreadId({
|
||||
threadId: session.threadId,
|
||||
});
|
||||
assert.equal(Option.isSome(stoppedRuntime), true);
|
||||
if (Option.isSome(stoppedRuntime)) {
|
||||
@@ -585,6 +681,8 @@ fanout.layer("ProviderServiceLive fanout", (it) => {
|
||||
const provider = yield* ProviderService;
|
||||
const session = yield* provider.startSession(asThreadId("thread-1"), {
|
||||
provider: "codex",
|
||||
threadId: asThreadId("thread-1"),
|
||||
runtimeMode: "full-access",
|
||||
});
|
||||
|
||||
const eventsRef = yield* Ref.make<Array<ProviderRuntimeEvent>>([]);
|
||||
@@ -593,13 +691,12 @@ fanout.layer("ProviderServiceLive fanout", (it) => {
|
||||
).pipe(Effect.forkChild);
|
||||
yield* sleep(20);
|
||||
|
||||
const completedEvent: ProviderRuntimeEvent = {
|
||||
const completedEvent: LegacyProviderRuntimeEvent = {
|
||||
type: "turn.completed",
|
||||
eventId: asEventId("evt-1"),
|
||||
provider: "codex",
|
||||
sessionId: session.sessionId,
|
||||
createdAt: new Date().toISOString(),
|
||||
threadId: asProviderThreadId("thread-1"),
|
||||
threadId: session.threadId,
|
||||
turnId: asTurnId("turn-1"),
|
||||
status: "completed",
|
||||
};
|
||||
@@ -617,11 +714,68 @@ fanout.layer("ProviderServiceLive fanout", (it) => {
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("fans out canonical runtime events in emission order", () =>
|
||||
Effect.gen(function* () {
|
||||
const provider = yield* ProviderService;
|
||||
const session = yield* provider.startSession(asThreadId("thread-seq"), {
|
||||
provider: "codex",
|
||||
threadId: asThreadId("thread-seq"),
|
||||
runtimeMode: "full-access",
|
||||
});
|
||||
|
||||
const receivedRef = yield* Ref.make<Array<ProviderRuntimeEvent>>([]);
|
||||
const consumer = yield* Stream.take(provider.streamEvents, 3).pipe(
|
||||
Stream.runForEach((event) => Ref.update(receivedRef, (current) => [...current, event])),
|
||||
Effect.forkChild,
|
||||
);
|
||||
yield* sleep(20);
|
||||
|
||||
fanout.codex.emit({
|
||||
type: "tool.started",
|
||||
eventId: asEventId("evt-seq-1"),
|
||||
provider: "codex",
|
||||
createdAt: new Date().toISOString(),
|
||||
threadId: session.threadId,
|
||||
turnId: asTurnId("turn-1"),
|
||||
toolKind: "command",
|
||||
title: "Command run",
|
||||
});
|
||||
fanout.codex.emit({
|
||||
type: "tool.completed",
|
||||
eventId: asEventId("evt-seq-2"),
|
||||
provider: "codex",
|
||||
createdAt: new Date().toISOString(),
|
||||
threadId: session.threadId,
|
||||
turnId: asTurnId("turn-1"),
|
||||
toolKind: "command",
|
||||
title: "Command run",
|
||||
});
|
||||
fanout.codex.emit({
|
||||
type: "turn.completed",
|
||||
eventId: asEventId("evt-seq-3"),
|
||||
provider: "codex",
|
||||
createdAt: new Date().toISOString(),
|
||||
threadId: session.threadId,
|
||||
turnId: asTurnId("turn-1"),
|
||||
status: "completed",
|
||||
});
|
||||
|
||||
yield* Fiber.join(consumer);
|
||||
const received = yield* Ref.get(receivedRef);
|
||||
assert.deepEqual(
|
||||
received.map((event) => event.eventId),
|
||||
[asEventId("evt-seq-1"), asEventId("evt-seq-2"), asEventId("evt-seq-3")],
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("keeps subscriber delivery ordered and isolates failing subscribers", () =>
|
||||
Effect.gen(function* () {
|
||||
const provider = yield* ProviderService;
|
||||
const session = yield* provider.startSession(asThreadId("thread-1"), {
|
||||
provider: "codex",
|
||||
threadId: asThreadId("thread-1"),
|
||||
runtimeMode: "full-access",
|
||||
});
|
||||
|
||||
const receivedByHealthy: string[] = [];
|
||||
@@ -640,14 +794,13 @@ fanout.layer("ProviderServiceLive fanout", (it) => {
|
||||
);
|
||||
yield* sleep(20);
|
||||
|
||||
const events: ReadonlyArray<ProviderRuntimeEvent> = [
|
||||
const events: ReadonlyArray<LegacyProviderRuntimeEvent> = [
|
||||
{
|
||||
type: "tool.completed",
|
||||
eventId: asEventId("evt-ordered-1"),
|
||||
provider: "codex",
|
||||
sessionId: session.sessionId,
|
||||
createdAt: new Date().toISOString(),
|
||||
threadId: asProviderThreadId("thread-1"),
|
||||
threadId: session.threadId,
|
||||
turnId: asTurnId("turn-1"),
|
||||
toolKind: "command",
|
||||
title: "Command run",
|
||||
@@ -657,9 +810,8 @@ fanout.layer("ProviderServiceLive fanout", (it) => {
|
||||
type: "message.delta",
|
||||
eventId: asEventId("evt-ordered-2"),
|
||||
provider: "codex",
|
||||
sessionId: session.sessionId,
|
||||
createdAt: new Date().toISOString(),
|
||||
threadId: asProviderThreadId("thread-1"),
|
||||
threadId: session.threadId,
|
||||
turnId: asTurnId("turn-1"),
|
||||
delta: "hello",
|
||||
},
|
||||
@@ -667,9 +819,8 @@ fanout.layer("ProviderServiceLive fanout", (it) => {
|
||||
type: "turn.completed",
|
||||
eventId: asEventId("evt-ordered-3"),
|
||||
provider: "codex",
|
||||
sessionId: session.sessionId,
|
||||
createdAt: new Date().toISOString(),
|
||||
threadId: asProviderThreadId("thread-1"),
|
||||
threadId: session.threadId,
|
||||
turnId: asTurnId("turn-1"),
|
||||
status: "completed",
|
||||
},
|
||||
@@ -698,7 +849,9 @@ validation.layer("ProviderServiceLive validation", (it) => {
|
||||
|
||||
const failure = yield* Effect.result(
|
||||
provider.startSession(asThreadId("thread-validation"), {
|
||||
threadId: asThreadId("thread-validation"),
|
||||
provider: "invalid-provider",
|
||||
runtimeMode: "full-access",
|
||||
} as never),
|
||||
);
|
||||
|
||||
@@ -715,17 +868,19 @@ validation.layer("ProviderServiceLive validation", (it) => {
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("fails startSession when adapter returns no threadId", () =>
|
||||
it.effect("accepts startSession when adapter has not emitted provider thread id yet", () =>
|
||||
Effect.gen(function* () {
|
||||
const provider = yield* ProviderService;
|
||||
const runtimeRepository = yield* ProviderSessionRuntimeRepository;
|
||||
|
||||
validation.codex.startSession.mockImplementationOnce((input: ProviderSessionStartInput) =>
|
||||
Effect.sync(() => {
|
||||
const now = new Date().toISOString();
|
||||
return {
|
||||
sessionId: asSessionId("sess-missing-thread"),
|
||||
provider: "codex",
|
||||
status: "ready",
|
||||
threadId: input.threadId,
|
||||
runtimeMode: input.runtimeMode,
|
||||
cwd: input.cwd ?? process.cwd(),
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
@@ -733,20 +888,22 @@ validation.layer("ProviderServiceLive validation", (it) => {
|
||||
}),
|
||||
);
|
||||
|
||||
const failure = yield* Effect.result(
|
||||
provider.startSession(asThreadId("thread-missing"), {
|
||||
provider: "codex",
|
||||
cwd: "/tmp/project",
|
||||
}),
|
||||
);
|
||||
const session = yield* provider.startSession(asThreadId("thread-missing"), {
|
||||
provider: "codex",
|
||||
threadId: asThreadId("thread-missing"),
|
||||
cwd: "/tmp/project",
|
||||
runtimeMode: "full-access",
|
||||
});
|
||||
|
||||
assertFailure(
|
||||
failure,
|
||||
new ProviderValidationError({
|
||||
operation: "ProviderService.startSession",
|
||||
issue: "Provider 'codex' returned a session without threadId.",
|
||||
}),
|
||||
);
|
||||
assert.equal(session.threadId, asThreadId("thread-missing"));
|
||||
|
||||
const runtime = yield* runtimeRepository.getByThreadId({
|
||||
threadId: session.threadId,
|
||||
});
|
||||
assert.equal(Option.isSome(runtime), true);
|
||||
if (Option.isSome(runtime)) {
|
||||
assert.equal(runtime.value.threadId, session.threadId);
|
||||
}
|
||||
}),
|
||||
);
|
||||
});
|
||||
@@ -11,24 +11,24 @@
|
||||
*/
|
||||
import {
|
||||
NonNegativeInt,
|
||||
ProviderSessionId,
|
||||
ThreadId,
|
||||
ProviderInterruptTurnInput,
|
||||
ProviderRespondToRequestInput,
|
||||
ProviderRespondToUserInputInput,
|
||||
ProviderSendTurnInput,
|
||||
ProviderSessionStartInput,
|
||||
ProviderStopSessionInput,
|
||||
type ProviderRuntimeEvent,
|
||||
type ProviderSession,
|
||||
} from "@t3tools/contracts";
|
||||
import { Effect, Layer, Option, PubSub, Queue, Ref, Schema, SchemaIssue, Stream } from "effect";
|
||||
import { Effect, Layer, Option, PubSub, Queue, Schema, SchemaIssue, Stream } from "effect";
|
||||
|
||||
import { ProviderSessionNotFoundError, ProviderValidationError } from "../Errors.ts";
|
||||
import { ProviderValidationError } from "../Errors.ts";
|
||||
import { ProviderAdapterRegistry } from "../Services/ProviderAdapterRegistry.ts";
|
||||
import { ProviderService, type ProviderServiceShape } from "../Services/ProviderService.ts";
|
||||
import {
|
||||
ProviderSessionDirectory,
|
||||
type ProviderSessionBinding,
|
||||
type ProviderRuntimeBinding,
|
||||
} from "../Services/ProviderSessionDirectory.ts";
|
||||
import { type EventNdjsonLogger, makeEventNdjsonLogger } from "./EventNdjsonLogger.ts";
|
||||
|
||||
@@ -38,7 +38,7 @@ export interface ProviderServiceLiveOptions {
|
||||
}
|
||||
|
||||
const ProviderRollbackConversationInput = Schema.Struct({
|
||||
sessionId: ProviderSessionId,
|
||||
threadId: ThreadId,
|
||||
numTurns: NonNegativeInt,
|
||||
});
|
||||
|
||||
@@ -95,7 +95,7 @@ function toRuntimePayloadFromSession(session: ProviderSession): Record<string, u
|
||||
}
|
||||
|
||||
function readPersistedCwd(
|
||||
runtimePayload: ProviderSessionBinding["runtimePayload"],
|
||||
runtimePayload: ProviderRuntimeBinding["runtimePayload"],
|
||||
): string | undefined {
|
||||
if (!runtimePayload || typeof runtimePayload !== "object" || Array.isArray(runtimePayload)) {
|
||||
return undefined;
|
||||
@@ -120,43 +120,12 @@ const makeProviderService = (options?: ProviderServiceLiveOptions) =>
|
||||
const directory = yield* ProviderSessionDirectory;
|
||||
const runtimeEventQueue = yield* Queue.unbounded<ProviderRuntimeEvent>();
|
||||
const runtimeEventPubSub = yield* PubSub.unbounded<ProviderRuntimeEvent>();
|
||||
const routedSessionAliasesRef = yield* Ref.make<Map<ProviderSessionId, ProviderSessionId>>(
|
||||
new Map(),
|
||||
);
|
||||
|
||||
const canonicalizeRuntimeEventSession = (
|
||||
event: ProviderRuntimeEvent,
|
||||
): Effect.Effect<ProviderRuntimeEvent> =>
|
||||
Ref.get(routedSessionAliasesRef).pipe(
|
||||
Effect.map((aliases) => {
|
||||
for (const [staleSessionId, liveSessionId] of aliases) {
|
||||
if (liveSessionId === event.sessionId) {
|
||||
return {
|
||||
...event,
|
||||
sessionId: staleSessionId,
|
||||
} satisfies ProviderRuntimeEvent;
|
||||
}
|
||||
}
|
||||
return event;
|
||||
}),
|
||||
);
|
||||
|
||||
const publishRuntimeEvent = (event: ProviderRuntimeEvent): Effect.Effect<void> =>
|
||||
canonicalizeRuntimeEventSession(event).pipe(
|
||||
Effect.succeed(event).pipe(
|
||||
Effect.tap((canonicalEvent) =>
|
||||
canonicalEventLogger
|
||||
? Effect.flatMap(
|
||||
Effect.catch(
|
||||
directory.getThreadId(canonicalEvent.sessionId).pipe(
|
||||
Effect.map((threadIdOption) =>
|
||||
Option.isSome(threadIdOption) ? threadIdOption.value : null,
|
||||
),
|
||||
),
|
||||
() => Effect.succeed<ThreadId | null>(null),
|
||||
),
|
||||
(orchestrationThreadId) =>
|
||||
canonicalEventLogger.write(canonicalEvent, orchestrationThreadId),
|
||||
)
|
||||
? canonicalEventLogger.write(canonicalEvent, null)
|
||||
: Effect.void,
|
||||
),
|
||||
Effect.flatMap((canonicalEvent) => PubSub.publish(runtimeEventPubSub, canonicalEvent)),
|
||||
@@ -165,64 +134,15 @@ const makeProviderService = (options?: ProviderServiceLiveOptions) =>
|
||||
|
||||
const upsertSessionBinding = (
|
||||
session: ProviderSession,
|
||||
operation: string,
|
||||
threadId: ThreadId,
|
||||
) =>
|
||||
Effect.gen(function* () {
|
||||
const providerThreadId = session.threadId;
|
||||
if (!providerThreadId) {
|
||||
return yield* toValidationError(
|
||||
operation,
|
||||
`Provider '${session.provider}' returned a session without threadId.`,
|
||||
);
|
||||
}
|
||||
|
||||
yield* directory.upsert({
|
||||
sessionId: session.sessionId,
|
||||
provider: session.provider,
|
||||
threadId,
|
||||
providerThreadId,
|
||||
status: toRuntimeStatus(session),
|
||||
...(session.resumeCursor !== undefined ? { resumeCursor: session.resumeCursor } : {}),
|
||||
runtimePayload: toRuntimePayloadFromSession(session),
|
||||
});
|
||||
|
||||
return providerThreadId;
|
||||
});
|
||||
|
||||
const clearAliasKey = (staleSessionId: ProviderSessionId) =>
|
||||
Ref.update(routedSessionAliasesRef, (current) => {
|
||||
if (!current.has(staleSessionId)) {
|
||||
return current;
|
||||
}
|
||||
const next = new Map(current);
|
||||
next.delete(staleSessionId);
|
||||
return next;
|
||||
});
|
||||
|
||||
const clearAliasesReferencing = (sessionId: ProviderSessionId) =>
|
||||
Ref.update(routedSessionAliasesRef, (current) => {
|
||||
let changed = false;
|
||||
const next = new Map<ProviderSessionId, ProviderSessionId>();
|
||||
for (const [key, value] of current) {
|
||||
if (key === sessionId || value === sessionId) {
|
||||
changed = true;
|
||||
continue;
|
||||
}
|
||||
next.set(key, value);
|
||||
}
|
||||
return changed ? next : current;
|
||||
});
|
||||
|
||||
const setAlias = (staleSessionId: ProviderSessionId, liveSessionId: ProviderSessionId) =>
|
||||
Ref.update(routedSessionAliasesRef, (current) => {
|
||||
const existing = current.get(staleSessionId);
|
||||
if (existing === liveSessionId) {
|
||||
return current;
|
||||
}
|
||||
const next = new Map(current);
|
||||
next.set(staleSessionId, liveSessionId);
|
||||
return next;
|
||||
directory.upsert({
|
||||
threadId,
|
||||
provider: session.provider,
|
||||
runtimeMode: session.runtimeMode,
|
||||
status: toRuntimeStatus(session),
|
||||
...(session.resumeCursor !== undefined ? { resumeCursor: session.resumeCursor } : {}),
|
||||
runtimePayload: toRuntimePayloadFromSession(session),
|
||||
});
|
||||
|
||||
const providers = yield* registry.listProviders();
|
||||
@@ -245,163 +165,77 @@ const makeProviderService = (options?: ProviderServiceLiveOptions) =>
|
||||
).pipe(Effect.asVoid);
|
||||
|
||||
const recoverSessionForThread = (input: {
|
||||
readonly staleSessionId: ProviderSessionId;
|
||||
readonly binding: ProviderSessionBinding & { readonly threadId: ThreadId };
|
||||
readonly binding: ProviderRuntimeBinding;
|
||||
readonly operation: string;
|
||||
}) =>
|
||||
Effect.gen(function* () {
|
||||
const adapter = yield* registry.getByProvider(input.binding.provider);
|
||||
const activeSessions = yield* adapter.listSessions();
|
||||
const resumeThreadId = input.binding.providerThreadId ?? undefined;
|
||||
const hasResumeCursor =
|
||||
input.binding.resumeCursor !== null && input.binding.resumeCursor !== undefined;
|
||||
const existing =
|
||||
resumeThreadId === undefined
|
||||
? undefined
|
||||
: activeSessions.find((session) => session.threadId === resumeThreadId);
|
||||
if (existing) {
|
||||
const existingProviderThreadId = yield* upsertSessionBinding(
|
||||
existing,
|
||||
`${input.operation}:upsertExistingSession`,
|
||||
input.binding.threadId,
|
||||
);
|
||||
yield* directory.upsert({
|
||||
sessionId: input.staleSessionId,
|
||||
provider: existing.provider,
|
||||
threadId: input.binding.threadId,
|
||||
providerThreadId: existingProviderThreadId,
|
||||
...(existing.resumeCursor !== undefined ? { resumeCursor: existing.resumeCursor } : {}),
|
||||
});
|
||||
if (existing.sessionId !== input.staleSessionId) {
|
||||
yield* setAlias(input.staleSessionId, existing.sessionId);
|
||||
} else {
|
||||
yield* clearAliasKey(input.staleSessionId);
|
||||
const hasActiveSession = yield* adapter.hasSession(input.binding.threadId);
|
||||
if (hasActiveSession) {
|
||||
const activeSessions = yield* adapter.listSessions();
|
||||
const existing = activeSessions.find((session) => session.threadId === input.binding.threadId);
|
||||
if (existing) {
|
||||
yield* upsertSessionBinding(existing, input.binding.threadId);
|
||||
return { adapter, session: existing } as const;
|
||||
}
|
||||
return {
|
||||
adapter,
|
||||
sessionId: existing.sessionId,
|
||||
} as const;
|
||||
}
|
||||
|
||||
if (!resumeThreadId && !hasResumeCursor) {
|
||||
if (!hasResumeCursor) {
|
||||
return yield* toValidationError(
|
||||
input.operation,
|
||||
`Cannot recover stale session '${input.staleSessionId}' because no provider resume state is persisted.`,
|
||||
`Cannot recover thread '${input.binding.threadId}' because no provider resume state is persisted.`,
|
||||
);
|
||||
}
|
||||
|
||||
const persistedCwd = readPersistedCwd(input.binding.runtimePayload);
|
||||
|
||||
const resumed = yield* adapter.startSession({
|
||||
threadId: input.binding.threadId,
|
||||
provider: input.binding.provider,
|
||||
...(persistedCwd ? { cwd: persistedCwd } : {}),
|
||||
...(resumeThreadId ? { resumeThreadId } : {}),
|
||||
...(hasResumeCursor ? { resumeCursor: input.binding.resumeCursor } : {}),
|
||||
runtimeMode: input.binding.runtimeMode ?? "full-access",
|
||||
});
|
||||
if (resumed.provider !== adapter.provider) {
|
||||
return yield* toValidationError(
|
||||
input.operation,
|
||||
`Adapter/provider mismatch while recovering stale session '${input.staleSessionId}'. Expected '${adapter.provider}', received '${resumed.provider}'.`,
|
||||
`Adapter/provider mismatch while recovering thread '${input.binding.threadId}'. Expected '${adapter.provider}', received '${resumed.provider}'.`,
|
||||
);
|
||||
}
|
||||
|
||||
const resumedProviderThreadId = yield* upsertSessionBinding(
|
||||
resumed,
|
||||
`${input.operation}:upsertRecoveredSession`,
|
||||
input.binding.threadId,
|
||||
);
|
||||
|
||||
yield* directory.upsert({
|
||||
sessionId: input.staleSessionId,
|
||||
provider: resumed.provider,
|
||||
threadId: input.binding.threadId,
|
||||
providerThreadId: resumedProviderThreadId,
|
||||
...(resumed.resumeCursor !== undefined ? { resumeCursor: resumed.resumeCursor } : {}),
|
||||
});
|
||||
|
||||
if (resumed.sessionId !== input.staleSessionId) {
|
||||
yield* setAlias(input.staleSessionId, resumed.sessionId);
|
||||
} else {
|
||||
yield* clearAliasKey(input.staleSessionId);
|
||||
}
|
||||
|
||||
return {
|
||||
adapter,
|
||||
sessionId: resumed.sessionId,
|
||||
} as const;
|
||||
yield* upsertSessionBinding(resumed, input.binding.threadId);
|
||||
return { adapter, session: resumed } as const;
|
||||
});
|
||||
|
||||
const resolveRoutableSession = (input: {
|
||||
readonly sessionId: ProviderSessionId;
|
||||
readonly threadId: ThreadId;
|
||||
readonly operation: string;
|
||||
readonly allowRecovery: boolean;
|
||||
}) =>
|
||||
Effect.gen(function* () {
|
||||
const bindingOption = yield* directory.getBinding(input.sessionId);
|
||||
const bindingOption = yield* directory.getBinding(input.threadId);
|
||||
const binding = Option.getOrUndefined(bindingOption);
|
||||
if (!binding) {
|
||||
return yield* new ProviderSessionNotFoundError({
|
||||
sessionId: input.sessionId,
|
||||
});
|
||||
}
|
||||
if (!binding.threadId) {
|
||||
return yield* toValidationError(
|
||||
input.operation,
|
||||
`Cannot route session '${input.sessionId}' because no orchestration thread id is persisted.`,
|
||||
`Cannot route thread '${input.threadId}' because no persisted provider binding exists.`,
|
||||
);
|
||||
}
|
||||
const bindingWithThreadId: ProviderSessionBinding & {
|
||||
readonly threadId: ThreadId;
|
||||
} = {
|
||||
...binding,
|
||||
threadId: binding.threadId,
|
||||
};
|
||||
const adapter = yield* registry.getByProvider(binding.provider);
|
||||
|
||||
const hasRequestedSession = yield* adapter.hasSession(input.sessionId);
|
||||
const hasRequestedSession = yield* adapter.hasSession(input.threadId);
|
||||
if (hasRequestedSession) {
|
||||
yield* clearAliasKey(input.sessionId);
|
||||
return {
|
||||
adapter,
|
||||
sessionId: input.sessionId,
|
||||
isActive: true,
|
||||
} as const;
|
||||
}
|
||||
|
||||
const alias = yield* Ref.get(routedSessionAliasesRef).pipe(
|
||||
Effect.map((aliases) => aliases.get(input.sessionId)),
|
||||
);
|
||||
if (alias) {
|
||||
const aliasIsActive = yield* adapter.hasSession(alias);
|
||||
if (aliasIsActive) {
|
||||
return {
|
||||
adapter,
|
||||
sessionId: alias,
|
||||
isActive: true,
|
||||
} as const;
|
||||
}
|
||||
yield* clearAliasKey(input.sessionId);
|
||||
return { adapter, threadId: input.threadId, isActive: true } as const;
|
||||
}
|
||||
|
||||
if (!input.allowRecovery) {
|
||||
return {
|
||||
adapter,
|
||||
sessionId: input.sessionId,
|
||||
isActive: false,
|
||||
} as const;
|
||||
return { adapter, threadId: input.threadId, isActive: false } as const;
|
||||
}
|
||||
|
||||
const recovered = yield* recoverSessionForThread({
|
||||
staleSessionId: input.sessionId,
|
||||
binding: bindingWithThreadId,
|
||||
operation: input.operation,
|
||||
});
|
||||
|
||||
return {
|
||||
adapter: recovered.adapter,
|
||||
sessionId: recovered.sessionId,
|
||||
isActive: true,
|
||||
} as const;
|
||||
const recovered = yield* recoverSessionForThread({ binding, operation: input.operation });
|
||||
return { adapter: recovered.adapter, threadId: input.threadId, isActive: true } as const;
|
||||
});
|
||||
|
||||
const startSession: ProviderServiceShape["startSession"] = (threadId, rawInput) =>
|
||||
@@ -414,9 +248,8 @@ const makeProviderService = (options?: ProviderServiceLiveOptions) =>
|
||||
|
||||
const input = {
|
||||
...parsed,
|
||||
threadId,
|
||||
provider: parsed.provider ?? "codex",
|
||||
approvalPolicy: parsed.approvalPolicy ?? "never",
|
||||
sandboxMode: parsed.sandboxMode ?? "workspace-write",
|
||||
};
|
||||
const adapter = yield* registry.getByProvider(input.provider);
|
||||
const session = yield* adapter.startSession(input);
|
||||
@@ -428,7 +261,7 @@ const makeProviderService = (options?: ProviderServiceLiveOptions) =>
|
||||
);
|
||||
}
|
||||
|
||||
yield* upsertSessionBinding(session, "ProviderService.startSession", threadId);
|
||||
yield* upsertSessionBinding(session, threadId);
|
||||
|
||||
return session;
|
||||
});
|
||||
@@ -452,28 +285,14 @@ const makeProviderService = (options?: ProviderServiceLiveOptions) =>
|
||||
);
|
||||
}
|
||||
const routed = yield* resolveRoutableSession({
|
||||
sessionId: input.sessionId,
|
||||
threadId: input.threadId,
|
||||
operation: "ProviderService.sendTurn",
|
||||
allowRecovery: true,
|
||||
});
|
||||
const turn = yield* routed.adapter.sendTurn({
|
||||
...input,
|
||||
sessionId: routed.sessionId,
|
||||
});
|
||||
const threadId = yield* directory
|
||||
.getThreadId(input.sessionId)
|
||||
.pipe(Effect.map(Option.getOrUndefined));
|
||||
if (!threadId) {
|
||||
return yield* toValidationError(
|
||||
"ProviderService.sendTurn",
|
||||
`No thread id is tracked for provider session '${input.sessionId}'.`,
|
||||
);
|
||||
}
|
||||
const turn = yield* routed.adapter.sendTurn(input);
|
||||
yield* directory.upsert({
|
||||
sessionId: input.sessionId,
|
||||
threadId: input.threadId,
|
||||
provider: routed.adapter.provider,
|
||||
threadId,
|
||||
providerThreadId: turn.threadId,
|
||||
status: "running",
|
||||
...(turn.resumeCursor !== undefined ? { resumeCursor: turn.resumeCursor } : {}),
|
||||
runtimePayload: {
|
||||
@@ -493,11 +312,11 @@ const makeProviderService = (options?: ProviderServiceLiveOptions) =>
|
||||
payload: rawInput,
|
||||
});
|
||||
const routed = yield* resolveRoutableSession({
|
||||
sessionId: input.sessionId,
|
||||
threadId: input.threadId,
|
||||
operation: "ProviderService.interruptTurn",
|
||||
allowRecovery: true,
|
||||
});
|
||||
yield* routed.adapter.interruptTurn(routed.sessionId, input.turnId);
|
||||
yield* routed.adapter.interruptTurn(routed.threadId, input.turnId);
|
||||
});
|
||||
|
||||
const respondToRequest: ProviderServiceShape["respondToRequest"] = (rawInput) =>
|
||||
@@ -508,11 +327,26 @@ const makeProviderService = (options?: ProviderServiceLiveOptions) =>
|
||||
payload: rawInput,
|
||||
});
|
||||
const routed = yield* resolveRoutableSession({
|
||||
sessionId: input.sessionId,
|
||||
threadId: input.threadId,
|
||||
operation: "ProviderService.respondToRequest",
|
||||
allowRecovery: true,
|
||||
});
|
||||
yield* routed.adapter.respondToRequest(routed.sessionId, input.requestId, input.decision);
|
||||
yield* routed.adapter.respondToRequest(routed.threadId, input.requestId, input.decision);
|
||||
});
|
||||
|
||||
const respondToUserInput: ProviderServiceShape["respondToUserInput"] = (rawInput) =>
|
||||
Effect.gen(function* () {
|
||||
const input = yield* decodeInputOrValidationError({
|
||||
operation: "ProviderService.respondToUserInput",
|
||||
schema: ProviderRespondToUserInputInput,
|
||||
payload: rawInput,
|
||||
});
|
||||
const routed = yield* resolveRoutableSession({
|
||||
threadId: input.threadId,
|
||||
operation: "ProviderService.respondToUserInput",
|
||||
allowRecovery: true,
|
||||
});
|
||||
yield* routed.adapter.respondToUserInput(routed.threadId, input.requestId, input.answers);
|
||||
});
|
||||
|
||||
const stopSession: ProviderServiceShape["stopSession"] = (rawInput) =>
|
||||
@@ -523,25 +357,61 @@ const makeProviderService = (options?: ProviderServiceLiveOptions) =>
|
||||
payload: rawInput,
|
||||
});
|
||||
const routed = yield* resolveRoutableSession({
|
||||
sessionId: input.sessionId,
|
||||
threadId: input.threadId,
|
||||
operation: "ProviderService.stopSession",
|
||||
allowRecovery: false,
|
||||
});
|
||||
if (routed.isActive) {
|
||||
yield* routed.adapter.stopSession(routed.sessionId);
|
||||
yield* routed.adapter.stopSession(routed.threadId);
|
||||
}
|
||||
if (routed.sessionId !== input.sessionId) {
|
||||
yield* directory.remove(routed.sessionId);
|
||||
yield* clearAliasesReferencing(routed.sessionId);
|
||||
}
|
||||
yield* directory.remove(input.sessionId);
|
||||
yield* clearAliasesReferencing(input.sessionId);
|
||||
yield* directory.remove(input.threadId);
|
||||
});
|
||||
|
||||
const listSessions: ProviderServiceShape["listSessions"] = () =>
|
||||
Effect.forEach(adapters, (adapter) => adapter.listSessions()).pipe(
|
||||
Effect.map((sessionsByProvider) => sessionsByProvider.flatMap((sessions) => sessions)),
|
||||
);
|
||||
Effect.gen(function* () {
|
||||
const sessionsByProvider = yield* Effect.forEach(adapters, (adapter) => adapter.listSessions());
|
||||
const activeSessions = sessionsByProvider.flatMap((sessions) => sessions);
|
||||
const persistedBindings = yield* directory
|
||||
.listThreadIds()
|
||||
.pipe(
|
||||
Effect.flatMap((threadIds) =>
|
||||
Effect.forEach(
|
||||
threadIds,
|
||||
(threadId) =>
|
||||
directory.getBinding(threadId).pipe(
|
||||
Effect.orElseSucceed(() => Option.none<ProviderRuntimeBinding>()),
|
||||
),
|
||||
{ concurrency: "unbounded" },
|
||||
),
|
||||
),
|
||||
Effect.orElseSucceed(() => [] as Array<Option.Option<ProviderRuntimeBinding>>),
|
||||
);
|
||||
const bindingsByThreadId = new Map<ThreadId, ProviderRuntimeBinding>();
|
||||
for (const bindingOption of persistedBindings) {
|
||||
const binding = Option.getOrUndefined(bindingOption);
|
||||
if (binding) {
|
||||
bindingsByThreadId.set(binding.threadId, binding);
|
||||
}
|
||||
}
|
||||
|
||||
return activeSessions.map((session) => {
|
||||
const binding = bindingsByThreadId.get(session.threadId);
|
||||
if (!binding) {
|
||||
return session;
|
||||
}
|
||||
|
||||
return {
|
||||
...session,
|
||||
...(session.resumeCursor === undefined && binding.resumeCursor !== undefined
|
||||
? { resumeCursor: binding.resumeCursor }
|
||||
: {}),
|
||||
...(binding.runtimeMode !== undefined ? { runtimeMode: binding.runtimeMode } : {}),
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
const getCapabilities: ProviderServiceShape["getCapabilities"] = (provider) =>
|
||||
registry.getByProvider(provider).pipe(Effect.map((adapter) => adapter.capabilities));
|
||||
|
||||
const rollbackConversation: ProviderServiceShape["rollbackConversation"] = (rawInput) =>
|
||||
Effect.gen(function* () {
|
||||
@@ -554,22 +424,22 @@ const makeProviderService = (options?: ProviderServiceLiveOptions) =>
|
||||
return;
|
||||
}
|
||||
const routed = yield* resolveRoutableSession({
|
||||
sessionId: input.sessionId,
|
||||
threadId: input.threadId,
|
||||
operation: "ProviderService.rollbackConversation",
|
||||
allowRecovery: true,
|
||||
});
|
||||
yield* routed.adapter.rollbackThread(routed.sessionId, input.numTurns);
|
||||
yield* routed.adapter.rollbackThread(routed.threadId, input.numTurns);
|
||||
});
|
||||
|
||||
const stopAll: ProviderServiceShape["stopAll"] = () =>
|
||||
Effect.gen(function* () {
|
||||
const sessionIds = yield* directory.listSessionIds();
|
||||
const threadIds = yield* directory.listThreadIds();
|
||||
yield* Effect.forEach(adapters, (adapter) => adapter.stopAll()).pipe(Effect.asVoid);
|
||||
yield* Effect.forEach(sessionIds, (sessionId) =>
|
||||
directory.getProvider(sessionId).pipe(
|
||||
yield* Effect.forEach(threadIds, (threadId) =>
|
||||
directory.getProvider(threadId).pipe(
|
||||
Effect.flatMap((provider) =>
|
||||
directory.upsert({
|
||||
sessionId,
|
||||
threadId,
|
||||
provider,
|
||||
status: "stopped",
|
||||
runtimePayload: {
|
||||
@@ -581,9 +451,6 @@ const makeProviderService = (options?: ProviderServiceLiveOptions) =>
|
||||
),
|
||||
),
|
||||
).pipe(Effect.asVoid);
|
||||
// Keep persisted session bindings so stale sessions can be resumed after
|
||||
// process restart via providerThreadId.
|
||||
yield* Ref.set(routedSessionAliasesRef, new Map());
|
||||
});
|
||||
|
||||
return {
|
||||
@@ -591,8 +458,10 @@ const makeProviderService = (options?: ProviderServiceLiveOptions) =>
|
||||
sendTurn,
|
||||
interruptTurn,
|
||||
respondToRequest,
|
||||
respondToUserInput,
|
||||
stopSession,
|
||||
listSessions,
|
||||
getCapabilities,
|
||||
rollbackConversation,
|
||||
stopAll,
|
||||
streamEvents: Stream.fromPubSub(runtimeEventPubSub),
|
||||
|
||||
@@ -3,7 +3,7 @@ import os from "node:os";
|
||||
import path from "node:path";
|
||||
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { ProviderSessionId, ProviderThreadId, ThreadId } from "@t3tools/contracts";
|
||||
import { ThreadId } from "@t3tools/contracts";
|
||||
import { it, assert } from "@effect/vitest";
|
||||
import { assertFailure, assertSome } from "@effect/vitest/utils";
|
||||
import { Effect, Layer, Option } from "effect";
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
} from "../../persistence/Layers/Sqlite.ts";
|
||||
import { ProviderSessionRuntimeRepositoryLive } from "../../persistence/Layers/ProviderSessionRuntime.ts";
|
||||
import { ProviderSessionRuntimeRepository } from "../../persistence/Services/ProviderSessionRuntime.ts";
|
||||
import { ProviderSessionNotFoundError, ProviderValidationError } from "../Errors.ts";
|
||||
import { ProviderSessionDirectoryPersistenceError } from "../Errors.ts";
|
||||
import { ProviderSessionDirectory } from "../Services/ProviderSessionDirectory.ts";
|
||||
import { ProviderSessionDirectoryLive } from "./ProviderSessionDirectory.ts";
|
||||
|
||||
@@ -31,74 +31,59 @@ function makeDirectoryLayer<E, R>(persistenceLayer: Layer.Layer<SqlClient.SqlCli
|
||||
}
|
||||
|
||||
it.layer(makeDirectoryLayer(SqlitePersistenceMemory))("ProviderSessionDirectoryLive", (it) => {
|
||||
it("upserts, reads, and removes session bindings", () =>
|
||||
it("upserts, reads, and removes thread bindings", () =>
|
||||
Effect.gen(function* () {
|
||||
const directory = yield* ProviderSessionDirectory;
|
||||
const runtimeRepository = yield* ProviderSessionRuntimeRepository;
|
||||
|
||||
const sessionId = ProviderSessionId.makeUnsafe("sess-1");
|
||||
const initialThreadId = ThreadId.makeUnsafe("thread-1");
|
||||
|
||||
yield* directory.upsert({
|
||||
sessionId,
|
||||
provider: "codex",
|
||||
threadId: initialThreadId,
|
||||
});
|
||||
|
||||
const provider = yield* directory.getProvider(sessionId);
|
||||
const provider = yield* directory.getProvider(initialThreadId);
|
||||
assert.equal(provider, "codex");
|
||||
const resolvedThreadId = yield* directory.getThreadId(sessionId);
|
||||
assertSome(resolvedThreadId, initialThreadId);
|
||||
const resolvedBinding = yield* directory.getBinding(initialThreadId);
|
||||
assertSome(resolvedBinding, {
|
||||
threadId: initialThreadId,
|
||||
provider: "codex",
|
||||
});
|
||||
if (Option.isSome(resolvedBinding)) {
|
||||
assert.equal(resolvedBinding.value.threadId, initialThreadId);
|
||||
}
|
||||
|
||||
const nextThreadId = ThreadId.makeUnsafe("thread-2");
|
||||
|
||||
yield* directory.upsert({
|
||||
sessionId: sessionId,
|
||||
provider: "codex",
|
||||
threadId: nextThreadId,
|
||||
});
|
||||
const updatedThreadId = yield* directory.getThreadId(sessionId);
|
||||
assertSome(updatedThreadId, nextThreadId);
|
||||
const updatedBinding = yield* directory.getBinding(sessionId);
|
||||
const updatedBinding = yield* directory.getBinding(nextThreadId);
|
||||
assert.equal(Option.isSome(updatedBinding), true);
|
||||
if (Option.isSome(updatedBinding)) {
|
||||
assert.equal(updatedBinding.value.threadId, nextThreadId);
|
||||
assert.equal(updatedBinding.value.providerThreadId, null);
|
||||
}
|
||||
|
||||
const runtime = yield* runtimeRepository.getBySessionId({
|
||||
providerSessionId: sessionId,
|
||||
});
|
||||
const runtime = yield* runtimeRepository.getByThreadId({ threadId: nextThreadId });
|
||||
assert.equal(Option.isSome(runtime), true);
|
||||
if (Option.isSome(runtime)) {
|
||||
assert.equal(runtime.value.threadId, nextThreadId);
|
||||
assert.equal(runtime.value.providerThreadId, null);
|
||||
assert.equal(runtime.value.status, "running");
|
||||
assert.equal(runtime.value.adapterKey, "codex");
|
||||
assert.equal(runtime.value.providerName, "codex");
|
||||
}
|
||||
|
||||
const sessionIds = yield* directory.listSessionIds();
|
||||
assert.deepEqual(sessionIds, [sessionId]);
|
||||
const threadIds = yield* directory.listThreadIds();
|
||||
assert.deepEqual(threadIds, [nextThreadId]);
|
||||
|
||||
yield* directory.remove(sessionId);
|
||||
const missingProvider = yield* directory.getProvider(sessionId).pipe(Effect.result);
|
||||
assertFailure(missingProvider, new ProviderSessionNotFoundError({ sessionId: "sess-1" }));
|
||||
}));
|
||||
|
||||
it("fails upsert when thread id is unavailable", () =>
|
||||
Effect.gen(function* () {
|
||||
const directory = yield* ProviderSessionDirectory;
|
||||
const result = yield* Effect.result(
|
||||
directory.upsert({
|
||||
sessionId: ProviderSessionId.makeUnsafe("sess-no-thread"),
|
||||
provider: "codex",
|
||||
}),
|
||||
);
|
||||
yield* directory.remove(nextThreadId);
|
||||
const missingProvider = yield* directory.getProvider(nextThreadId).pipe(Effect.result);
|
||||
assertFailure(
|
||||
result,
|
||||
new ProviderValidationError({
|
||||
operation: "ProviderSessionDirectory.upsert",
|
||||
issue: "threadId must be a non-empty string.",
|
||||
missingProvider,
|
||||
new ProviderSessionDirectoryPersistenceError({
|
||||
operation: "ProviderSessionDirectory.getProvider",
|
||||
detail: `No persisted provider binding found for thread '${nextThreadId}'.`,
|
||||
}),
|
||||
);
|
||||
}));
|
||||
@@ -108,18 +93,14 @@ it.layer(makeDirectoryLayer(SqlitePersistenceMemory))("ProviderSessionDirectoryL
|
||||
const directory = yield* ProviderSessionDirectory;
|
||||
const runtimeRepository = yield* ProviderSessionRuntimeRepository;
|
||||
|
||||
const sessionId = ProviderSessionId.makeUnsafe("sess-runtime");
|
||||
const threadId = ThreadId.makeUnsafe("thread-runtime");
|
||||
const providerThreadId = ProviderThreadId.makeUnsafe("provider-thread-runtime");
|
||||
|
||||
yield* directory.upsert({
|
||||
sessionId,
|
||||
provider: "codex",
|
||||
threadId,
|
||||
providerThreadId,
|
||||
status: "starting",
|
||||
resumeCursor: {
|
||||
resumeThreadId: "provider-thread-runtime",
|
||||
threadId: "provider-thread-runtime",
|
||||
},
|
||||
runtimePayload: {
|
||||
cwd: "/tmp/project",
|
||||
@@ -128,24 +109,21 @@ it.layer(makeDirectoryLayer(SqlitePersistenceMemory))("ProviderSessionDirectoryL
|
||||
});
|
||||
|
||||
yield* directory.upsert({
|
||||
sessionId,
|
||||
provider: "codex",
|
||||
threadId,
|
||||
status: "running",
|
||||
runtimePayload: {
|
||||
activeTurnId: "turn-1",
|
||||
},
|
||||
});
|
||||
|
||||
const runtime = yield* runtimeRepository.getBySessionId({
|
||||
providerSessionId: sessionId,
|
||||
});
|
||||
const runtime = yield* runtimeRepository.getByThreadId({ threadId });
|
||||
assert.equal(Option.isSome(runtime), true);
|
||||
if (Option.isSome(runtime)) {
|
||||
assert.equal(runtime.value.threadId, threadId);
|
||||
assert.equal(runtime.value.providerThreadId, providerThreadId);
|
||||
assert.equal(runtime.value.status, "running");
|
||||
assert.deepEqual(runtime.value.resumeCursor, {
|
||||
resumeThreadId: providerThreadId,
|
||||
threadId: "provider-thread-runtime",
|
||||
});
|
||||
assert.deepEqual(runtime.value.runtimePayload, {
|
||||
cwd: "/tmp/project",
|
||||
@@ -155,52 +133,17 @@ it.layer(makeDirectoryLayer(SqlitePersistenceMemory))("ProviderSessionDirectoryL
|
||||
}
|
||||
}));
|
||||
|
||||
it("clears providerThreadId when explicitly set to null", () =>
|
||||
Effect.gen(function* () {
|
||||
const directory = yield* ProviderSessionDirectory;
|
||||
const runtimeRepository = yield* ProviderSessionRuntimeRepository;
|
||||
|
||||
const sessionId = ProviderSessionId.makeUnsafe("sess-clear-provider-thread-id");
|
||||
const threadId = ThreadId.makeUnsafe("thread-clear-provider-thread-id");
|
||||
const providerThreadId = ProviderThreadId.makeUnsafe("provider-thread-to-clear");
|
||||
|
||||
yield* directory.upsert({
|
||||
sessionId,
|
||||
provider: "codex",
|
||||
threadId,
|
||||
adapterKey: "custom-adapter",
|
||||
providerThreadId,
|
||||
});
|
||||
|
||||
yield* directory.upsert({
|
||||
sessionId,
|
||||
provider: "codex",
|
||||
providerThreadId: null,
|
||||
});
|
||||
|
||||
const runtime = yield* runtimeRepository.getBySessionId({
|
||||
providerSessionId: sessionId,
|
||||
});
|
||||
assert.equal(Option.isSome(runtime), true);
|
||||
if (Option.isSome(runtime)) {
|
||||
assert.equal(runtime.value.providerThreadId, null);
|
||||
assert.equal(runtime.value.adapterKey, "custom-adapter");
|
||||
}
|
||||
}));
|
||||
|
||||
it("rehydrates persisted mappings across layer restart", () =>
|
||||
Effect.gen(function* () {
|
||||
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "t3-provider-directory-"));
|
||||
const dbPath = path.join(tempDir, "orchestration.sqlite");
|
||||
const directoryLayer = makeDirectoryLayer(makeSqlitePersistenceLive(dbPath));
|
||||
|
||||
const sessionId = ProviderSessionId.makeUnsafe("sess-restart");
|
||||
const threadId = ThreadId.makeUnsafe("thread-restart");
|
||||
|
||||
yield* Effect.gen(function* () {
|
||||
const directory = yield* ProviderSessionDirectory;
|
||||
yield* directory.upsert({
|
||||
sessionId,
|
||||
provider: "codex",
|
||||
threadId,
|
||||
});
|
||||
@@ -209,11 +152,17 @@ it.layer(makeDirectoryLayer(SqlitePersistenceMemory))("ProviderSessionDirectoryL
|
||||
yield* Effect.gen(function* () {
|
||||
const directory = yield* ProviderSessionDirectory;
|
||||
const sql = yield* SqlClient.SqlClient;
|
||||
const provider = yield* directory.getProvider(sessionId);
|
||||
const provider = yield* directory.getProvider(threadId);
|
||||
assert.equal(provider, "codex");
|
||||
|
||||
const resolvedThreadId = yield* directory.getThreadId(sessionId);
|
||||
assertSome(resolvedThreadId, threadId);
|
||||
const resolvedBinding = yield* directory.getBinding(threadId);
|
||||
assertSome(resolvedBinding, {
|
||||
threadId,
|
||||
provider: "codex",
|
||||
});
|
||||
if (Option.isSome(resolvedBinding)) {
|
||||
assert.equal(resolvedBinding.value.threadId, threadId);
|
||||
}
|
||||
|
||||
const legacyTableRows = yield* sql<{ readonly name: string }>`
|
||||
SELECT name
|
||||
@@ -225,4 +174,26 @@ it.layer(makeDirectoryLayer(SqlitePersistenceMemory))("ProviderSessionDirectoryL
|
||||
|
||||
fs.rmSync(tempDir, { recursive: true, force: true });
|
||||
}));
|
||||
|
||||
it("accepts cursor provider bindings", () =>
|
||||
Effect.gen(function* () {
|
||||
const directory = yield* ProviderSessionDirectory;
|
||||
const threadId = ThreadId.makeUnsafe("thread-cursor");
|
||||
|
||||
yield* directory.upsert({
|
||||
provider: "cursor",
|
||||
threadId,
|
||||
});
|
||||
|
||||
const provider = yield* directory.getProvider(threadId);
|
||||
assert.equal(provider, "cursor");
|
||||
const resolvedBinding = yield* directory.getBinding(threadId);
|
||||
assertSome(resolvedBinding, {
|
||||
threadId,
|
||||
provider: "cursor",
|
||||
});
|
||||
if (Option.isSome(resolvedBinding)) {
|
||||
assert.equal(resolvedBinding.value.threadId, threadId);
|
||||
}
|
||||
}));
|
||||
});
|
||||
@@ -1,15 +1,14 @@
|
||||
import { ProviderSessionId, type ProviderKind } from "@t3tools/contracts";
|
||||
import { type ProviderKind, type ThreadId } from "@t3tools/contracts";
|
||||
import { Effect, Layer, Option } from "effect";
|
||||
|
||||
import { ProviderSessionRuntimeRepository } from "../../persistence/Services/ProviderSessionRuntime.ts";
|
||||
import {
|
||||
ProviderSessionDirectoryPersistenceError,
|
||||
ProviderSessionNotFoundError,
|
||||
ProviderValidationError,
|
||||
} from "../Errors.ts";
|
||||
import {
|
||||
ProviderSessionDirectory,
|
||||
type ProviderSessionBinding,
|
||||
type ProviderRuntimeBinding,
|
||||
type ProviderSessionDirectoryShape,
|
||||
} from "../Services/ProviderSessionDirectory.ts";
|
||||
|
||||
@@ -26,7 +25,7 @@ function decodeProviderKind(
|
||||
providerName: string,
|
||||
operation: string,
|
||||
): Effect.Effect<ProviderKind, ProviderSessionDirectoryPersistenceError> {
|
||||
if (providerName === "codex" || providerName === "claudeCode") {
|
||||
if (providerName === "codex" || providerName === "claudeCode" || providerName === "cursor") {
|
||||
return Effect.succeed(providerName);
|
||||
}
|
||||
return Effect.fail(
|
||||
@@ -49,10 +48,7 @@ function mergeRuntimePayload(
|
||||
return existing ?? null;
|
||||
}
|
||||
if (isRecord(existing) && isRecord(next)) {
|
||||
return {
|
||||
...existing,
|
||||
...next,
|
||||
};
|
||||
return { ...existing, ...next };
|
||||
}
|
||||
return next;
|
||||
}
|
||||
@@ -60,21 +56,20 @@ function mergeRuntimePayload(
|
||||
const makeProviderSessionDirectory = Effect.gen(function* () {
|
||||
const repository = yield* ProviderSessionRuntimeRepository;
|
||||
|
||||
const getBinding = (sessionId: ProviderSessionId) =>
|
||||
repository.getBySessionId({ providerSessionId: sessionId }).pipe(
|
||||
Effect.mapError(toPersistenceError("ProviderSessionDirectory.getBinding:getBySessionId")),
|
||||
const getBinding = (threadId: ThreadId) =>
|
||||
repository.getByThreadId({ threadId }).pipe(
|
||||
Effect.mapError(toPersistenceError("ProviderSessionDirectory.getBinding:getByThreadId")),
|
||||
Effect.flatMap((runtime) =>
|
||||
Option.match(runtime, {
|
||||
onNone: () => Effect.succeed(Option.none<ProviderSessionBinding>()),
|
||||
onNone: () => Effect.succeed(Option.none<ProviderRuntimeBinding>()),
|
||||
onSome: (value) =>
|
||||
decodeProviderKind(value.providerName, "ProviderSessionDirectory.getBinding").pipe(
|
||||
Effect.map((provider) =>
|
||||
Option.some({
|
||||
sessionId: value.providerSessionId,
|
||||
provider,
|
||||
threadId: value.threadId,
|
||||
provider,
|
||||
adapterKey: value.adapterKey,
|
||||
providerThreadId: value.providerThreadId,
|
||||
runtimeMode: value.runtimeMode,
|
||||
status: value.status,
|
||||
resumeCursor: value.resumeCursor,
|
||||
runtimePayload: value.runtimePayload,
|
||||
@@ -87,10 +82,8 @@ const makeProviderSessionDirectory = Effect.gen(function* () {
|
||||
|
||||
const upsert: ProviderSessionDirectoryShape["upsert"] = Effect.fn(function* (binding) {
|
||||
const existing = yield* repository
|
||||
.getBySessionId({
|
||||
providerSessionId: binding.sessionId,
|
||||
})
|
||||
.pipe(Effect.mapError(toPersistenceError("ProviderSessionDirectory.upsert:getBySessionId")));
|
||||
.getByThreadId({ threadId: binding.threadId })
|
||||
.pipe(Effect.mapError(toPersistenceError("ProviderSessionDirectory.upsert:getByThreadId")));
|
||||
|
||||
const existingRuntime = Option.getOrUndefined(existing);
|
||||
const resolvedThreadId = binding.threadId ?? existingRuntime?.threadId;
|
||||
@@ -104,14 +97,10 @@ const makeProviderSessionDirectory = Effect.gen(function* () {
|
||||
const now = new Date().toISOString();
|
||||
yield* repository
|
||||
.upsert({
|
||||
providerSessionId: binding.sessionId,
|
||||
threadId: resolvedThreadId,
|
||||
providerName: binding.provider,
|
||||
adapterKey: binding.adapterKey ?? existingRuntime?.adapterKey ?? binding.provider,
|
||||
providerThreadId:
|
||||
binding.providerThreadId !== undefined
|
||||
? binding.providerThreadId
|
||||
: (existingRuntime?.providerThreadId ?? null),
|
||||
runtimeMode: binding.runtimeMode ?? existingRuntime?.runtimeMode ?? "full-access",
|
||||
status: binding.status ?? existingRuntime?.status ?? "running",
|
||||
lastSeenAt: now,
|
||||
resumeCursor:
|
||||
@@ -126,63 +115,39 @@ const makeProviderSessionDirectory = Effect.gen(function* () {
|
||||
.pipe(Effect.mapError(toPersistenceError("ProviderSessionDirectory.upsert:upsert")));
|
||||
});
|
||||
|
||||
const getProvider: ProviderSessionDirectoryShape["getProvider"] = (sessionId) =>
|
||||
getBinding(sessionId).pipe(
|
||||
const getProvider: ProviderSessionDirectoryShape["getProvider"] = (threadId) =>
|
||||
getBinding(threadId).pipe(
|
||||
Effect.flatMap((binding) =>
|
||||
Option.match(binding, {
|
||||
onSome: (value) => Effect.succeed(value.provider),
|
||||
onNone: () => Effect.fail(new ProviderSessionNotFoundError({ sessionId })),
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
const getBindingBySessionId: ProviderSessionDirectoryShape["getBinding"] = (sessionId) =>
|
||||
getBinding(sessionId);
|
||||
|
||||
const getThreadId: ProviderSessionDirectoryShape["getThreadId"] = (sessionId) =>
|
||||
getBinding(sessionId).pipe(
|
||||
Effect.flatMap((binding) =>
|
||||
Option.match(binding, {
|
||||
onSome: (value) => Effect.succeed(Option.fromNullishOr(value.threadId)),
|
||||
onNone: () => Effect.fail(new ProviderSessionNotFoundError({ sessionId })),
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
const remove: ProviderSessionDirectoryShape["remove"] = (sessionId) =>
|
||||
repository
|
||||
.deleteBySessionId({ providerSessionId: sessionId })
|
||||
.pipe(
|
||||
Effect.mapError(toPersistenceError("ProviderSessionDirectory.remove:deleteBySessionId")),
|
||||
);
|
||||
|
||||
const listSessionIds: ProviderSessionDirectoryShape["listSessionIds"] = () =>
|
||||
repository.list().pipe(
|
||||
Effect.mapError(toPersistenceError("ProviderSessionDirectory.listSessionIds:list")),
|
||||
Effect.flatMap((rows) =>
|
||||
Effect.forEach(
|
||||
rows,
|
||||
(row) =>
|
||||
decodeProviderKind(row.providerName, "ProviderSessionDirectory.listSessionIds").pipe(
|
||||
Effect.map((provider) => ({
|
||||
sessionId: row.providerSessionId,
|
||||
provider,
|
||||
threadId: row.threadId,
|
||||
})),
|
||||
onNone: () =>
|
||||
Effect.fail(
|
||||
new ProviderSessionDirectoryPersistenceError({
|
||||
operation: "ProviderSessionDirectory.getProvider",
|
||||
detail: `No persisted provider binding found for thread '${threadId}'.`,
|
||||
}),
|
||||
),
|
||||
{ concurrency: "unbounded" },
|
||||
),
|
||||
}),
|
||||
),
|
||||
Effect.map((bindings) => bindings.map((binding) => binding.sessionId)),
|
||||
);
|
||||
|
||||
const remove: ProviderSessionDirectoryShape["remove"] = (threadId) =>
|
||||
repository
|
||||
.deleteByThreadId({ threadId })
|
||||
.pipe(Effect.mapError(toPersistenceError("ProviderSessionDirectory.remove:deleteByThreadId")));
|
||||
|
||||
const listThreadIds: ProviderSessionDirectoryShape["listThreadIds"] = () =>
|
||||
repository.list().pipe(
|
||||
Effect.mapError(toPersistenceError("ProviderSessionDirectory.listThreadIds:list")),
|
||||
Effect.map((rows) => rows.map((row) => row.threadId)),
|
||||
);
|
||||
|
||||
return {
|
||||
upsert,
|
||||
getProvider,
|
||||
getBinding: getBindingBySessionId,
|
||||
getThreadId,
|
||||
getBinding,
|
||||
remove,
|
||||
listSessionIds,
|
||||
listThreadIds,
|
||||
} satisfies ProviderSessionDirectoryShape;
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
import { Schema } from "effect";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
CursorAcpPermissionRequest,
|
||||
CursorAcpSessionPromptResult,
|
||||
CursorAcpSessionUpdateNotification,
|
||||
} from "./CursorAdapter.ts";
|
||||
|
||||
describe("Cursor ACP schemas", () => {
|
||||
it("decodes session/update thought and message chunks", () => {
|
||||
const thought = Schema.decodeUnknownSync(CursorAcpSessionUpdateNotification)({
|
||||
jsonrpc: "2.0",
|
||||
method: "session/update",
|
||||
params: {
|
||||
sessionId: "sess-1",
|
||||
update: {
|
||||
sessionUpdate: "agent_thought_chunk",
|
||||
content: {
|
||||
type: "text",
|
||||
text: "thinking",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(thought.params.update.sessionUpdate).toBe("agent_thought_chunk");
|
||||
|
||||
const message = Schema.decodeUnknownSync(CursorAcpSessionUpdateNotification)({
|
||||
jsonrpc: "2.0",
|
||||
method: "session/update",
|
||||
params: {
|
||||
sessionId: "sess-1",
|
||||
update: {
|
||||
sessionUpdate: "agent_message_chunk",
|
||||
content: {
|
||||
type: "text",
|
||||
text: "hello",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(message.params.update.sessionUpdate).toBe("agent_message_chunk");
|
||||
});
|
||||
|
||||
it("decodes tool call lifecycle updates", () => {
|
||||
const started = Schema.decodeUnknownSync(CursorAcpSessionUpdateNotification)({
|
||||
jsonrpc: "2.0",
|
||||
method: "session/update",
|
||||
params: {
|
||||
sessionId: "sess-1",
|
||||
update: {
|
||||
sessionUpdate: "tool_call",
|
||||
toolCallId: "tool-1",
|
||||
title: "Terminal",
|
||||
kind: "execute",
|
||||
status: "pending",
|
||||
rawInput: { command: "pwd" },
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(started.params.update.sessionUpdate).toBe("tool_call");
|
||||
|
||||
const completed = Schema.decodeUnknownSync(CursorAcpSessionUpdateNotification)({
|
||||
jsonrpc: "2.0",
|
||||
method: "session/update",
|
||||
params: {
|
||||
sessionId: "sess-1",
|
||||
update: {
|
||||
sessionUpdate: "tool_call_update",
|
||||
toolCallId: "tool-1",
|
||||
status: "completed",
|
||||
rawOutput: {
|
||||
exitCode: 0,
|
||||
stdout: "ok",
|
||||
stderr: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(completed.params.update.sessionUpdate).toBe("tool_call_update");
|
||||
});
|
||||
|
||||
it("decodes permission requests", () => {
|
||||
const decoded = Schema.decodeUnknownSync(CursorAcpPermissionRequest)({
|
||||
jsonrpc: "2.0",
|
||||
id: 9,
|
||||
method: "session/request_permission",
|
||||
params: {
|
||||
sessionId: "sess-1",
|
||||
toolCall: {
|
||||
toolCallId: "tool-1",
|
||||
kind: "execute",
|
||||
},
|
||||
options: [
|
||||
{ optionId: "allow-once", name: "Allow once", kind: "allow_once" },
|
||||
{ optionId: "reject-once", name: "Reject", kind: "reject_once" },
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
expect(decoded.method).toBe("session/request_permission");
|
||||
expect(decoded.params.options).toHaveLength(2);
|
||||
});
|
||||
|
||||
it("decodes prompt completion result payload", () => {
|
||||
const decoded = Schema.decodeUnknownSync(CursorAcpSessionPromptResult)({
|
||||
stopReason: "end_turn",
|
||||
});
|
||||
|
||||
expect(decoded.stopReason).toBe("end_turn");
|
||||
});
|
||||
|
||||
it("rejects unsupported update types", () => {
|
||||
expect(() =>
|
||||
Schema.decodeUnknownSync(CursorAcpSessionUpdateNotification)({
|
||||
jsonrpc: "2.0",
|
||||
method: "session/update",
|
||||
params: {
|
||||
sessionId: "sess-1",
|
||||
update: {
|
||||
sessionUpdate: "unknown_update",
|
||||
},
|
||||
},
|
||||
}),
|
||||
).toThrow();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,110 @@
|
||||
/**
|
||||
* CursorAdapter - Cursor ACP implementation of the generic provider adapter contract.
|
||||
*
|
||||
* Defines ACP JSON-RPC schemas used by the Cursor adapter layer.
|
||||
*
|
||||
* @module CursorAdapter
|
||||
*/
|
||||
import { Schema, ServiceMap } from "effect";
|
||||
|
||||
import type { ProviderAdapterError } from "../Errors.ts";
|
||||
import type { ProviderAdapterShape } from "./ProviderAdapter.ts";
|
||||
|
||||
export const CursorAcpJsonRpcId = Schema.Union([Schema.String, Schema.Int]);
|
||||
export type CursorAcpJsonRpcId = typeof CursorAcpJsonRpcId.Type;
|
||||
|
||||
export const CursorAcpTextContent = Schema.Struct({
|
||||
type: Schema.Literal("text"),
|
||||
text: Schema.String,
|
||||
});
|
||||
export type CursorAcpTextContent = typeof CursorAcpTextContent.Type;
|
||||
|
||||
export const CursorAcpSessionUpdate = Schema.Union([
|
||||
Schema.Struct({
|
||||
sessionUpdate: Schema.Literal("available_commands_update"),
|
||||
availableCommands: Schema.Array(
|
||||
Schema.Struct({
|
||||
name: Schema.String,
|
||||
description: Schema.optional(Schema.String),
|
||||
}),
|
||||
),
|
||||
}),
|
||||
Schema.Struct({
|
||||
sessionUpdate: Schema.Literal("agent_thought_chunk"),
|
||||
content: CursorAcpTextContent,
|
||||
}),
|
||||
Schema.Struct({
|
||||
sessionUpdate: Schema.Literal("agent_message_chunk"),
|
||||
content: CursorAcpTextContent,
|
||||
}),
|
||||
Schema.Struct({
|
||||
sessionUpdate: Schema.Literal("tool_call"),
|
||||
toolCallId: Schema.String,
|
||||
title: Schema.optional(Schema.String),
|
||||
kind: Schema.optional(Schema.String),
|
||||
status: Schema.optional(Schema.String),
|
||||
rawInput: Schema.optional(Schema.Unknown),
|
||||
}),
|
||||
Schema.Struct({
|
||||
sessionUpdate: Schema.Literal("tool_call_update"),
|
||||
toolCallId: Schema.String,
|
||||
status: Schema.String,
|
||||
rawOutput: Schema.optional(Schema.Unknown),
|
||||
}),
|
||||
]);
|
||||
export type CursorAcpSessionUpdate = typeof CursorAcpSessionUpdate.Type;
|
||||
|
||||
export const CursorAcpSessionUpdateNotification = Schema.Struct({
|
||||
jsonrpc: Schema.optional(Schema.Literal("2.0")),
|
||||
method: Schema.Literal("session/update"),
|
||||
params: Schema.Struct({
|
||||
sessionId: Schema.String,
|
||||
update: CursorAcpSessionUpdate,
|
||||
}),
|
||||
});
|
||||
export type CursorAcpSessionUpdateNotification = typeof CursorAcpSessionUpdateNotification.Type;
|
||||
|
||||
export const CursorAcpPermissionOption = Schema.Struct({
|
||||
optionId: Schema.String,
|
||||
name: Schema.optional(Schema.String),
|
||||
kind: Schema.optional(Schema.String),
|
||||
});
|
||||
export type CursorAcpPermissionOption = typeof CursorAcpPermissionOption.Type;
|
||||
|
||||
export const CursorAcpPermissionRequest = Schema.Struct({
|
||||
jsonrpc: Schema.optional(Schema.Literal("2.0")),
|
||||
id: CursorAcpJsonRpcId,
|
||||
method: Schema.Literal("session/request_permission"),
|
||||
params: Schema.Struct({
|
||||
sessionId: Schema.String,
|
||||
toolCall: Schema.optional(Schema.Unknown),
|
||||
options: Schema.Array(CursorAcpPermissionOption),
|
||||
}),
|
||||
});
|
||||
export type CursorAcpPermissionRequest = typeof CursorAcpPermissionRequest.Type;
|
||||
|
||||
export const CursorAcpInitializeResult = Schema.Struct({
|
||||
protocolVersion: Schema.optional(Schema.Int),
|
||||
agentCapabilities: Schema.optional(Schema.Unknown),
|
||||
authMethods: Schema.optional(Schema.Array(Schema.Unknown)),
|
||||
});
|
||||
export type CursorAcpInitializeResult = typeof CursorAcpInitializeResult.Type;
|
||||
|
||||
export const CursorAcpSessionNewResult = Schema.Struct({
|
||||
sessionId: Schema.String,
|
||||
modes: Schema.optional(Schema.Unknown),
|
||||
});
|
||||
export type CursorAcpSessionNewResult = typeof CursorAcpSessionNewResult.Type;
|
||||
|
||||
export const CursorAcpSessionPromptResult = Schema.Struct({
|
||||
stopReason: Schema.optional(Schema.String),
|
||||
});
|
||||
export type CursorAcpSessionPromptResult = typeof CursorAcpSessionPromptResult.Type;
|
||||
|
||||
export interface CursorAdapterShape extends ProviderAdapterShape<ProviderAdapterError> {
|
||||
readonly provider: "cursor";
|
||||
}
|
||||
|
||||
export class CursorAdapter extends ServiceMap.Service<CursorAdapter, CursorAdapterShape>()(
|
||||
"t3/provider/Services/CursorAdapter",
|
||||
) {}
|
||||
@@ -11,25 +11,34 @@ import type {
|
||||
ApprovalRequestId,
|
||||
ProviderApprovalDecision,
|
||||
ProviderKind,
|
||||
ProviderUserInputAnswers,
|
||||
ProviderRuntimeEvent,
|
||||
ProviderSendTurnInput,
|
||||
ProviderSession,
|
||||
ProviderSessionId,
|
||||
ProviderSessionStartInput,
|
||||
ProviderThreadId,
|
||||
ProviderTurnId,
|
||||
ThreadId,
|
||||
ProviderTurnStartResult,
|
||||
TurnId,
|
||||
} from "@t3tools/contracts";
|
||||
import type { Effect } from "effect";
|
||||
import type { Stream } from "effect";
|
||||
|
||||
export type ProviderSessionModelSwitchMode = "in-session" | "restart-session" | "unsupported";
|
||||
|
||||
export interface ProviderAdapterCapabilities {
|
||||
/**
|
||||
* Declares whether changing the model on an existing session is supported.
|
||||
*/
|
||||
readonly sessionModelSwitch: ProviderSessionModelSwitchMode;
|
||||
}
|
||||
|
||||
export interface ProviderThreadTurnSnapshot {
|
||||
readonly id: ProviderTurnId;
|
||||
readonly id: TurnId;
|
||||
readonly items: ReadonlyArray<unknown>;
|
||||
}
|
||||
|
||||
export interface ProviderThreadSnapshot {
|
||||
readonly threadId: ProviderThreadId;
|
||||
readonly threadId: ThreadId;
|
||||
readonly turns: ReadonlyArray<ProviderThreadTurnSnapshot>;
|
||||
}
|
||||
|
||||
@@ -38,6 +47,7 @@ export interface ProviderAdapterShape<TError> {
|
||||
* Provider kind implemented by this adapter.
|
||||
*/
|
||||
readonly provider: ProviderKind;
|
||||
readonly capabilities: ProviderAdapterCapabilities;
|
||||
|
||||
/**
|
||||
* Start a provider-backed session.
|
||||
@@ -57,23 +67,32 @@ export interface ProviderAdapterShape<TError> {
|
||||
* Interrupt an active turn.
|
||||
*/
|
||||
readonly interruptTurn: (
|
||||
sessionId: ProviderSessionId,
|
||||
turnId?: ProviderTurnId,
|
||||
threadId: ThreadId,
|
||||
turnId?: TurnId,
|
||||
) => Effect.Effect<void, TError>;
|
||||
|
||||
/**
|
||||
* Respond to an interactive approval request.
|
||||
*/
|
||||
readonly respondToRequest: (
|
||||
sessionId: ProviderSessionId,
|
||||
threadId: ThreadId,
|
||||
requestId: ApprovalRequestId,
|
||||
decision: ProviderApprovalDecision,
|
||||
) => Effect.Effect<void, TError>;
|
||||
|
||||
/**
|
||||
* Respond to a structured user-input request.
|
||||
*/
|
||||
readonly respondToUserInput: (
|
||||
threadId: ThreadId,
|
||||
requestId: ApprovalRequestId,
|
||||
answers: ProviderUserInputAnswers,
|
||||
) => Effect.Effect<void, TError>;
|
||||
|
||||
/**
|
||||
* Stop one provider session.
|
||||
*/
|
||||
readonly stopSession: (sessionId: ProviderSessionId) => Effect.Effect<void, TError>;
|
||||
readonly stopSession: (threadId: ThreadId) => Effect.Effect<void, TError>;
|
||||
|
||||
/**
|
||||
* List currently active provider sessions for this adapter.
|
||||
@@ -83,20 +102,20 @@ export interface ProviderAdapterShape<TError> {
|
||||
/**
|
||||
* Check whether this adapter owns an active session id.
|
||||
*/
|
||||
readonly hasSession: (sessionId: ProviderSessionId) => Effect.Effect<boolean>;
|
||||
readonly hasSession: (threadId: ThreadId) => Effect.Effect<boolean>;
|
||||
|
||||
/**
|
||||
* Read a provider thread snapshot.
|
||||
*/
|
||||
readonly readThread: (
|
||||
sessionId: ProviderSessionId,
|
||||
threadId: ThreadId,
|
||||
) => Effect.Effect<ProviderThreadSnapshot, TError>;
|
||||
|
||||
/**
|
||||
* Roll back a provider thread by N turns.
|
||||
*/
|
||||
readonly rollbackThread: (
|
||||
sessionId: ProviderSessionId,
|
||||
threadId: ThreadId,
|
||||
numTurns: number,
|
||||
) => Effect.Effect<ProviderThreadSnapshot, TError>;
|
||||
|
||||
|
||||
@@ -13,11 +13,12 @@
|
||||
*/
|
||||
import type {
|
||||
ProviderInterruptTurnInput,
|
||||
ProviderKind,
|
||||
ProviderRespondToRequestInput,
|
||||
ProviderRespondToUserInputInput,
|
||||
ProviderRuntimeEvent,
|
||||
ProviderSendTurnInput,
|
||||
ProviderSession,
|
||||
ProviderSessionId,
|
||||
ProviderSessionStartInput,
|
||||
ProviderStopSessionInput,
|
||||
ThreadId,
|
||||
@@ -27,6 +28,7 @@ import { ServiceMap } from "effect";
|
||||
import type { Effect, Stream } from "effect";
|
||||
|
||||
import type { ProviderServiceError } from "../Errors.ts";
|
||||
import type { ProviderAdapterCapabilities } from "./ProviderAdapter.ts";
|
||||
|
||||
/**
|
||||
* ProviderServiceShape - Service API for provider session and turn orchestration.
|
||||
@@ -61,6 +63,13 @@ export interface ProviderServiceShape {
|
||||
input: ProviderRespondToRequestInput,
|
||||
) => Effect.Effect<void, ProviderServiceError>;
|
||||
|
||||
/**
|
||||
* Respond to a provider structured user-input request.
|
||||
*/
|
||||
readonly respondToUserInput: (
|
||||
input: ProviderRespondToUserInputInput,
|
||||
) => Effect.Effect<void, ProviderServiceError>;
|
||||
|
||||
/**
|
||||
* Stop a provider session.
|
||||
*/
|
||||
@@ -75,11 +84,18 @@ export interface ProviderServiceShape {
|
||||
*/
|
||||
readonly listSessions: () => Effect.Effect<ReadonlyArray<ProviderSession>>;
|
||||
|
||||
/**
|
||||
* Read static capabilities for a provider adapter.
|
||||
*/
|
||||
readonly getCapabilities: (
|
||||
provider: ProviderKind,
|
||||
) => Effect.Effect<ProviderAdapterCapabilities, ProviderServiceError>;
|
||||
|
||||
/**
|
||||
* Roll back provider conversation state by a number of turns.
|
||||
*/
|
||||
readonly rollbackConversation: (input: {
|
||||
readonly sessionId: ProviderSessionId;
|
||||
readonly threadId: ThreadId;
|
||||
readonly numTurns: number;
|
||||
}) => Effect.Effect<void, ProviderServiceError>;
|
||||
|
||||
|
||||
@@ -1,17 +1,7 @@
|
||||
/**
|
||||
* ProviderSessionDirectory - Session ownership index across provider adapters.
|
||||
*
|
||||
* Tracks which provider owns each `sessionId` so `ProviderService` can route
|
||||
* session-scoped calls to the correct adapter. It is metadata only and does not
|
||||
* perform provider RPC or checkpoint operations.
|
||||
*
|
||||
* @module ProviderSessionDirectory
|
||||
*/
|
||||
import type {
|
||||
ProviderKind,
|
||||
ProviderSessionId,
|
||||
ProviderSessionRuntimeStatus,
|
||||
ProviderThreadId,
|
||||
RuntimeMode,
|
||||
ThreadId,
|
||||
} from "@t3tools/contracts";
|
||||
import { Option, ServiceMap } from "effect";
|
||||
@@ -19,83 +9,48 @@ import type { Effect } from "effect";
|
||||
|
||||
import type {
|
||||
ProviderSessionDirectoryPersistenceError,
|
||||
ProviderSessionNotFoundError,
|
||||
ProviderValidationError,
|
||||
} from "../Errors.ts";
|
||||
|
||||
export interface ProviderSessionBinding {
|
||||
readonly sessionId: ProviderSessionId;
|
||||
export interface ProviderRuntimeBinding {
|
||||
readonly threadId: ThreadId;
|
||||
readonly provider: ProviderKind;
|
||||
readonly threadId?: ThreadId;
|
||||
readonly adapterKey?: string;
|
||||
readonly providerThreadId?: ProviderThreadId | null;
|
||||
readonly status?: ProviderSessionRuntimeStatus;
|
||||
readonly resumeCursor?: unknown | null;
|
||||
readonly runtimePayload?: unknown | null;
|
||||
readonly runtimeMode?: RuntimeMode;
|
||||
}
|
||||
|
||||
export type ProviderSessionDirectoryReadError =
|
||||
| ProviderSessionNotFoundError
|
||||
| ProviderSessionDirectoryPersistenceError;
|
||||
export type ProviderSessionDirectoryReadError = ProviderSessionDirectoryPersistenceError;
|
||||
|
||||
export type ProviderSessionDirectoryWriteError =
|
||||
| ProviderValidationError
|
||||
| ProviderSessionDirectoryPersistenceError;
|
||||
|
||||
/**
|
||||
* ProviderSessionDirectoryShape - Service API for provider session ownership metadata.
|
||||
*/
|
||||
export interface ProviderSessionDirectoryShape {
|
||||
/**
|
||||
* Record or update ownership for one provider session.
|
||||
*
|
||||
* Preserves existing persisted fields when omitted and shallow-merges
|
||||
* runtime payload objects.
|
||||
*/
|
||||
readonly upsert: (
|
||||
binding: ProviderSessionBinding,
|
||||
binding: ProviderRuntimeBinding,
|
||||
) => Effect.Effect<void, ProviderSessionDirectoryWriteError>;
|
||||
|
||||
/**
|
||||
* Resolve the provider owner for a session id.
|
||||
*/
|
||||
readonly getProvider: (
|
||||
sessionId: ProviderSessionId,
|
||||
threadId: ThreadId,
|
||||
) => Effect.Effect<ProviderKind, ProviderSessionDirectoryReadError>;
|
||||
|
||||
/**
|
||||
* Resolve the full tracked binding for a session id.
|
||||
*/
|
||||
readonly getBinding: (
|
||||
sessionId: ProviderSessionId,
|
||||
) => Effect.Effect<Option.Option<ProviderSessionBinding>, ProviderSessionDirectoryReadError>;
|
||||
threadId: ThreadId,
|
||||
) => Effect.Effect<Option.Option<ProviderRuntimeBinding>, ProviderSessionDirectoryReadError>;
|
||||
|
||||
/**
|
||||
* Resolve the tracked thread id for a session, if known.
|
||||
*/
|
||||
readonly getThreadId: (
|
||||
sessionId: ProviderSessionId,
|
||||
) => Effect.Effect<Option.Option<ThreadId>, ProviderSessionDirectoryReadError>;
|
||||
|
||||
/**
|
||||
* Remove a session binding.
|
||||
*/
|
||||
readonly remove: (
|
||||
sessionId: ProviderSessionId,
|
||||
threadId: ThreadId,
|
||||
) => Effect.Effect<void, ProviderSessionDirectoryPersistenceError>;
|
||||
|
||||
/**
|
||||
* List tracked session ids.
|
||||
*/
|
||||
readonly listSessionIds: () => Effect.Effect<
|
||||
ReadonlyArray<ProviderSessionId>,
|
||||
readonly listThreadIds: () => Effect.Effect<
|
||||
ReadonlyArray<ThreadId>,
|
||||
ProviderSessionDirectoryPersistenceError
|
||||
>;
|
||||
}
|
||||
|
||||
/**
|
||||
* ProviderSessionDirectory - Service tag for session ownership lookup.
|
||||
*/
|
||||
export class ProviderSessionDirectory extends ServiceMap.Service<
|
||||
ProviderSessionDirectory,
|
||||
ProviderSessionDirectoryShape
|
||||
|
||||
@@ -19,6 +19,7 @@ import { OrchestrationProjectionSnapshotQueryLive } from "./orchestration/Layers
|
||||
import { ProviderRuntimeIngestionLive } from "./orchestration/Layers/ProviderRuntimeIngestion";
|
||||
import { ProviderUnsupportedError } from "./provider/Errors";
|
||||
import { makeCodexAdapterLive } from "./provider/Layers/CodexAdapter";
|
||||
import { makeCursorAdapterLive } from "./provider/Layers/CursorAdapter";
|
||||
import { ProviderAdapterRegistryLive } from "./provider/Layers/ProviderAdapterRegistry";
|
||||
import { makeProviderServiceLive } from "./provider/Layers/ProviderService";
|
||||
import { ProviderSessionDirectoryLive } from "./provider/Layers/ProviderSessionDirectory";
|
||||
@@ -56,8 +57,12 @@ export function makeServerProviderLayer(): Layer.Layer<
|
||||
const codexAdapterLayer = makeCodexAdapterLive(
|
||||
nativeEventLogger ? { nativeEventLogger } : undefined,
|
||||
);
|
||||
const cursorAdapterLayer = makeCursorAdapterLive(
|
||||
nativeEventLogger ? { nativeEventLogger } : undefined,
|
||||
);
|
||||
const adapterRegistryLayer = ProviderAdapterRegistryLive.pipe(
|
||||
Layer.provide(codexAdapterLayer),
|
||||
Layer.provide(cursorAdapterLayer),
|
||||
Layer.provideMerge(providerSessionDirectoryLayer),
|
||||
);
|
||||
return makeProviderServiceLive(
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
import { Effect, Logger, Option } from "effect";
|
||||
import * as Layer from "effect/Layer";
|
||||
|
||||
import { ServerConfig } from "./config";
|
||||
|
||||
export const ServerLoggerLive = Effect.gen(function* () {
|
||||
const config = yield* Effect.serviceOption(ServerConfig);
|
||||
if (Option.isNone(config)) {
|
||||
return Logger.layer([Logger.defaultLogger]);
|
||||
}
|
||||
|
||||
const logDir = path.join(config.value.stateDir, "logs");
|
||||
const logPath = path.join(logDir, "server.log");
|
||||
|
||||
yield* Effect.sync(() => {
|
||||
fs.mkdirSync(logDir, { recursive: true });
|
||||
});
|
||||
|
||||
const fileLogger = Logger.formatSimple.pipe(Logger.toFile(logPath));
|
||||
|
||||
return Logger.layer([Logger.defaultLogger, fileLogger], {
|
||||
mergeWithExisting: false,
|
||||
});
|
||||
}).pipe(Layer.unwrap);
|
||||
@@ -18,9 +18,8 @@ import {
|
||||
ORCHESTRATION_WS_CHANNELS,
|
||||
ORCHESTRATION_WS_METHODS,
|
||||
ProviderItemId,
|
||||
ProviderSessionId,
|
||||
ProviderThreadId,
|
||||
ProviderTurnId,
|
||||
ThreadId,
|
||||
TurnId,
|
||||
WS_CHANNELS,
|
||||
WS_METHODS,
|
||||
type WebSocketResponse,
|
||||
@@ -60,11 +59,9 @@ interface PendingMessages {
|
||||
const pendingBySocket = new WeakMap<WebSocket, PendingMessages>();
|
||||
|
||||
const asEventId = (value: string): EventId => EventId.makeUnsafe(value);
|
||||
const asProviderSessionId = (value: string): ProviderSessionId =>
|
||||
ProviderSessionId.makeUnsafe(value);
|
||||
const asProviderThreadId = (value: string): ProviderThreadId => ProviderThreadId.makeUnsafe(value);
|
||||
const asProviderTurnId = (value: string): ProviderTurnId => ProviderTurnId.makeUnsafe(value);
|
||||
const asProviderItemId = (value: string): ProviderItemId => ProviderItemId.makeUnsafe(value);
|
||||
const asThreadId = (value: string): ThreadId => ThreadId.makeUnsafe(value);
|
||||
const asTurnId = (value: string): TurnId => TurnId.makeUnsafe(value);
|
||||
|
||||
const defaultOpenService: OpenShape = {
|
||||
openBrowser: () => Effect.void,
|
||||
@@ -1129,6 +1126,8 @@ describe("WebSocket Server", () => {
|
||||
projectId: "project-diff",
|
||||
title: "Diff Thread",
|
||||
model: "gpt-5-codex",
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: "default",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt,
|
||||
@@ -1146,30 +1145,31 @@ describe("WebSocket Server", () => {
|
||||
|
||||
it("keeps orchestration domain push behavior for provider runtime events", async () => {
|
||||
const runtimeEventPubSub = Effect.runSync(PubSub.unbounded<ProviderRuntimeEvent>());
|
||||
const sessionId = asProviderSessionId("sess-test");
|
||||
const emitRuntimeEvent = (event: ProviderRuntimeEvent) => {
|
||||
Effect.runSync(PubSub.publish(runtimeEventPubSub, event));
|
||||
};
|
||||
const unsupported = () => Effect.die(new Error("Unsupported provider call in test")) as never;
|
||||
const providerService: ProviderServiceShape = {
|
||||
startSession: () =>
|
||||
startSession: (threadId) =>
|
||||
Effect.succeed({
|
||||
sessionId,
|
||||
provider: "codex",
|
||||
status: "ready",
|
||||
threadId: asProviderThreadId("provider-thread-1"),
|
||||
runtimeMode: "full-access",
|
||||
threadId,
|
||||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
}),
|
||||
sendTurn: () =>
|
||||
sendTurn: ({ threadId }) =>
|
||||
Effect.succeed({
|
||||
threadId: asProviderThreadId("provider-thread-1"),
|
||||
turnId: asProviderTurnId("provider-turn-1"),
|
||||
threadId,
|
||||
turnId: asTurnId("provider-turn-1"),
|
||||
}),
|
||||
interruptTurn: () => unsupported(),
|
||||
respondToRequest: () => unsupported(),
|
||||
respondToUserInput: () => unsupported(),
|
||||
stopSession: () => unsupported(),
|
||||
listSessions: () => Effect.succeed([]),
|
||||
getCapabilities: () => Effect.succeed({ sessionModelSwitch: "in-session" }),
|
||||
rollbackConversation: () => unsupported(),
|
||||
stopAll: () => Effect.void,
|
||||
streamEvents: Stream.fromPubSub(runtimeEventPubSub),
|
||||
@@ -1205,6 +1205,8 @@ describe("WebSocket Server", () => {
|
||||
projectId: "project-1",
|
||||
title: "Thread 1",
|
||||
model: "gpt-5-codex",
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: "default",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt,
|
||||
@@ -1222,8 +1224,8 @@ describe("WebSocket Server", () => {
|
||||
attachments: [],
|
||||
},
|
||||
assistantDeliveryMode: "streaming",
|
||||
approvalPolicy: "on-request",
|
||||
sandboxMode: "workspace-write",
|
||||
runtimeMode: "approval-required",
|
||||
interactionMode: "default",
|
||||
createdAt,
|
||||
});
|
||||
expect(startTurnResponse.error).toBeUndefined();
|
||||
@@ -1233,16 +1235,21 @@ describe("WebSocket Server", () => {
|
||||
return event.type === "thread.session-set";
|
||||
});
|
||||
|
||||
emitRuntimeEvent({
|
||||
type: "message.delta",
|
||||
eventId: asEventId("evt-ws-runtime-message-delta"),
|
||||
provider: "codex",
|
||||
sessionId,
|
||||
createdAt: new Date().toISOString(),
|
||||
turnId: asProviderTurnId("turn-1"),
|
||||
itemId: asProviderItemId("item-1"),
|
||||
delta: "hello from runtime",
|
||||
});
|
||||
emitRuntimeEvent(
|
||||
{
|
||||
type: "content.delta",
|
||||
eventId: asEventId("evt-ws-runtime-message-delta"),
|
||||
provider: "codex",
|
||||
threadId: asThreadId("thread-1"),
|
||||
createdAt: new Date().toISOString(),
|
||||
turnId: asTurnId("turn-1"),
|
||||
itemId: asProviderItemId("item-1"),
|
||||
payload: {
|
||||
streamKind: "assistant_text",
|
||||
delta: "hello from runtime",
|
||||
},
|
||||
} as unknown as ProviderRuntimeEvent,
|
||||
);
|
||||
|
||||
const domainPush = await waitForPush(ws, ORCHESTRATION_WS_CHANNELS.domainEvent, (push) => {
|
||||
const event = push.data as { type?: string; payload?: { messageId?: string; text?: string } };
|
||||
@@ -1518,6 +1525,54 @@ describe("WebSocket Server", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("supports projects.writeFile within the workspace root", async () => {
|
||||
const workspace = makeTempDir("t3code-ws-write-file-");
|
||||
|
||||
server = await createTestServer({ cwd: "/test" });
|
||||
const addr = server.address();
|
||||
const port = typeof addr === "object" && addr !== null ? addr.port : 0;
|
||||
|
||||
const ws = await connectWs(port);
|
||||
connections.push(ws);
|
||||
await waitForMessage(ws);
|
||||
|
||||
const response = await sendRequest(ws, WS_METHODS.projectsWriteFile, {
|
||||
cwd: workspace,
|
||||
relativePath: "plans/effect-rpc.md",
|
||||
contents: "# Plan\n\n- step 1\n",
|
||||
});
|
||||
|
||||
expect(response.error).toBeUndefined();
|
||||
expect(response.result).toEqual({
|
||||
relativePath: "plans/effect-rpc.md",
|
||||
});
|
||||
expect(fs.readFileSync(path.join(workspace, "plans", "effect-rpc.md"), "utf8")).toBe(
|
||||
"# Plan\n\n- step 1\n",
|
||||
);
|
||||
});
|
||||
|
||||
it("rejects projects.writeFile paths outside the workspace root", async () => {
|
||||
const workspace = makeTempDir("t3code-ws-write-file-reject-");
|
||||
|
||||
server = await createTestServer({ cwd: "/test" });
|
||||
const addr = server.address();
|
||||
const port = typeof addr === "object" && addr !== null ? addr.port : 0;
|
||||
|
||||
const ws = await connectWs(port);
|
||||
connections.push(ws);
|
||||
await waitForMessage(ws);
|
||||
|
||||
const response = await sendRequest(ws, WS_METHODS.projectsWriteFile, {
|
||||
cwd: workspace,
|
||||
relativePath: "../escape.md",
|
||||
contents: "# no\n",
|
||||
});
|
||||
|
||||
expect(response.result).toBeUndefined();
|
||||
expect(response.error?.message).toContain("Workspace file path must stay within the project root.");
|
||||
expect(fs.existsSync(path.join(workspace, "..", "escape.md"))).toBe(false);
|
||||
});
|
||||
|
||||
it("routes git core methods over websocket", async () => {
|
||||
const listBranches = vi.fn(() =>
|
||||
Effect.succeed({
|
||||
|
||||
+103
-30
@@ -12,6 +12,7 @@ import type { Duplex } from "node:stream";
|
||||
import Mime from "@effect/platform-node/Mime";
|
||||
import {
|
||||
CommandId,
|
||||
DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
type ClientOrchestrationCommand,
|
||||
type OrchestrationCommand,
|
||||
ORCHESTRATION_WS_CHANNELS,
|
||||
@@ -146,6 +147,48 @@ function websocketRawToString(raw: unknown): string | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
function toPosixRelativePath(input: string): string {
|
||||
return input.replaceAll("\\", "/");
|
||||
}
|
||||
|
||||
function resolveWorkspaceWritePath(params: {
|
||||
workspaceRoot: string;
|
||||
relativePath: string;
|
||||
path: Path.Path;
|
||||
}): Effect.Effect<{ absolutePath: string; relativePath: string }, RouteRequestError> {
|
||||
const normalizedInputPath = params.relativePath.trim();
|
||||
if (params.path.isAbsolute(normalizedInputPath)) {
|
||||
return Effect.fail(
|
||||
new RouteRequestError({
|
||||
message: "Workspace file path must be relative to the project root.",
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
const absolutePath = params.path.resolve(params.workspaceRoot, normalizedInputPath);
|
||||
const relativeToRoot = toPosixRelativePath(
|
||||
params.path.relative(params.workspaceRoot, absolutePath),
|
||||
);
|
||||
if (
|
||||
relativeToRoot.length === 0 ||
|
||||
relativeToRoot === "." ||
|
||||
relativeToRoot.startsWith("../") ||
|
||||
relativeToRoot === ".." ||
|
||||
params.path.isAbsolute(relativeToRoot)
|
||||
) {
|
||||
return Effect.fail(
|
||||
new RouteRequestError({
|
||||
message: "Workspace file path must stay within the project root.",
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
return Effect.succeed({
|
||||
absolutePath,
|
||||
relativePath: relativeToRoot,
|
||||
});
|
||||
}
|
||||
|
||||
function stripRequestTag<T extends { _tag: string }>(body: T) {
|
||||
return Struct.omit(body, ["_tag"]);
|
||||
}
|
||||
@@ -595,6 +638,8 @@ export const createServer = Effect.fn(function* (): Effect.fn.Return<
|
||||
projectId: bootstrapProjectId,
|
||||
title: "New thread",
|
||||
model: bootstrapProjectDefaultModel,
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "full-access",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt,
|
||||
@@ -612,6 +657,33 @@ export const createServer = Effect.fn(function* (): Effect.fn.Return<
|
||||
);
|
||||
}
|
||||
|
||||
const runPromise = yield* Effect.map(Effect.services<never>(), Effect.runPromiseWith);
|
||||
yield* Effect.addFinalizer(() =>
|
||||
Effect.catch(liveProviderService.stopAll(), (cause) =>
|
||||
Effect.logWarning("failed to stop provider service", { cause }),
|
||||
),
|
||||
);
|
||||
|
||||
const unsubscribeTerminalEvents = yield* terminalManager.subscribe(
|
||||
(event) => void Effect.runPromise(onTerminalEvent(event)),
|
||||
);
|
||||
yield* Effect.addFinalizer(() => Effect.sync(() => unsubscribeTerminalEvents()));
|
||||
|
||||
yield* NodeHttpServer.make(() => httpServer, listenOptions).pipe(
|
||||
Effect.mapError((cause) => new ServerLifecycleError({ operation: "httpServerListen", cause })),
|
||||
);
|
||||
|
||||
yield* Effect.addFinalizer(() =>
|
||||
Effect.all([
|
||||
closeAllClients,
|
||||
closeWebSocketServer.pipe(
|
||||
Effect.catch((error) =>
|
||||
Effect.logWarning("failed to close web socket server", { cause: error }),
|
||||
),
|
||||
),
|
||||
]),
|
||||
);
|
||||
|
||||
const routeRequest = Effect.fnUntraced(function* (request: WebSocketRequest) {
|
||||
switch (request.body._tag) {
|
||||
case ORCHESTRATION_WS_METHODS.getSnapshot:
|
||||
@@ -656,6 +728,32 @@ export const createServer = Effect.fn(function* (): Effect.fn.Return<
|
||||
});
|
||||
}
|
||||
|
||||
case WS_METHODS.projectsWriteFile: {
|
||||
const body = stripRequestTag(request.body);
|
||||
const target = yield* resolveWorkspaceWritePath({
|
||||
workspaceRoot: body.cwd,
|
||||
relativePath: body.relativePath,
|
||||
path,
|
||||
});
|
||||
yield* fileSystem.makeDirectory(path.dirname(target.absolutePath), { recursive: true }).pipe(
|
||||
Effect.mapError(
|
||||
(cause) =>
|
||||
new RouteRequestError({
|
||||
message: `Failed to prepare workspace path: ${String(cause)}`,
|
||||
}),
|
||||
),
|
||||
);
|
||||
yield* fileSystem.writeFileString(target.absolutePath, body.contents).pipe(
|
||||
Effect.mapError(
|
||||
(cause) =>
|
||||
new RouteRequestError({
|
||||
message: `Failed to write workspace file: ${String(cause)}`,
|
||||
}),
|
||||
),
|
||||
);
|
||||
return { relativePath: target.relativePath };
|
||||
}
|
||||
|
||||
case WS_METHODS.shellOpenInEditor: {
|
||||
const body = stripRequestTag(request.body);
|
||||
return yield* openInEditor(body);
|
||||
@@ -799,6 +897,7 @@ export const createServer = Effect.fn(function* (): Effect.fn.Return<
|
||||
id: request.value.id,
|
||||
result: result.value,
|
||||
});
|
||||
|
||||
ws.send(response);
|
||||
});
|
||||
|
||||
@@ -827,7 +926,7 @@ export const createServer = Effect.fn(function* (): Effect.fn.Return<
|
||||
});
|
||||
|
||||
wss.on("connection", (ws) => {
|
||||
void Effect.runPromise(Ref.update(clients, (clients) => clients.add(ws)));
|
||||
void runPromise(Ref.update(clients, (clients) => clients.add(ws)));
|
||||
|
||||
const segments = cwd.split(/[/\\]/).filter(Boolean);
|
||||
const projectName = segments[segments.length - 1] ?? "project";
|
||||
@@ -846,7 +945,7 @@ export const createServer = Effect.fn(function* (): Effect.fn.Return<
|
||||
ws.send(JSON.stringify(welcome));
|
||||
|
||||
ws.on("message", (raw) => {
|
||||
void Effect.runPromise(
|
||||
void runPromise(
|
||||
handleMessage(ws, raw).pipe(
|
||||
Effect.catch((error) => Effect.logError("Error handling message", error)),
|
||||
),
|
||||
@@ -854,7 +953,7 @@ export const createServer = Effect.fn(function* (): Effect.fn.Return<
|
||||
});
|
||||
|
||||
ws.on("close", () => {
|
||||
void Effect.runPromise(
|
||||
void runPromise(
|
||||
Ref.update(clients, (clients) => {
|
||||
clients.delete(ws);
|
||||
return clients;
|
||||
@@ -863,7 +962,7 @@ export const createServer = Effect.fn(function* (): Effect.fn.Return<
|
||||
});
|
||||
|
||||
ws.on("error", () => {
|
||||
void Effect.runPromise(
|
||||
void runPromise(
|
||||
Ref.update(clients, (clients) => {
|
||||
clients.delete(ws);
|
||||
return clients;
|
||||
@@ -872,32 +971,6 @@ export const createServer = Effect.fn(function* (): Effect.fn.Return<
|
||||
});
|
||||
});
|
||||
|
||||
yield* Effect.addFinalizer(() =>
|
||||
Effect.catch(liveProviderService.stopAll(), (cause) =>
|
||||
Effect.logWarning("failed to stop provider service", { cause }),
|
||||
),
|
||||
);
|
||||
|
||||
const unsubscribeTerminalEvents = yield* terminalManager.subscribe(
|
||||
(event) => void Effect.runPromise(onTerminalEvent(event)),
|
||||
);
|
||||
yield* Effect.addFinalizer(() => Effect.sync(() => unsubscribeTerminalEvents()));
|
||||
|
||||
yield* NodeHttpServer.make(() => httpServer, listenOptions).pipe(
|
||||
Effect.mapError((cause) => new ServerLifecycleError({ operation: "httpServerListen", cause })),
|
||||
);
|
||||
|
||||
yield* Effect.addFinalizer(() =>
|
||||
Effect.all([
|
||||
closeAllClients,
|
||||
closeWebSocketServer.pipe(
|
||||
Effect.catch((error) =>
|
||||
Effect.logWarning("failed to close web socket server", { cause: error }),
|
||||
),
|
||||
),
|
||||
]),
|
||||
);
|
||||
|
||||
return httpServer;
|
||||
});
|
||||
|
||||
|
||||
@@ -15,13 +15,25 @@ describe("normalizeCustomModelSlugs", () => {
|
||||
]),
|
||||
).toEqual(["custom/internal-model"]);
|
||||
});
|
||||
|
||||
it("normalizes provider-specific aliases for claude and cursor", () => {
|
||||
expect(normalizeCustomModelSlugs(["sonnet"], "claudeCode")).toEqual([]);
|
||||
expect(normalizeCustomModelSlugs(["claude/custom-sonnet"], "claudeCode")).toEqual([
|
||||
"claude/custom-sonnet",
|
||||
]);
|
||||
expect(normalizeCustomModelSlugs(["composer"], "cursor")).toEqual([]);
|
||||
expect(normalizeCustomModelSlugs(["cursor/custom-model"], "cursor")).toEqual([
|
||||
"cursor/custom-model",
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getAppModelOptions", () => {
|
||||
it("appends saved custom models after the built-in options", () => {
|
||||
const options = getAppModelOptions(["custom/internal-model"]);
|
||||
const options = getAppModelOptions("codex", ["custom/internal-model"]);
|
||||
|
||||
expect(options.map((option) => option.slug)).toEqual([
|
||||
"gpt-5.4",
|
||||
"gpt-5.3-codex",
|
||||
"gpt-5.3-codex-spark",
|
||||
"gpt-5.2-codex",
|
||||
@@ -31,7 +43,7 @@ describe("getAppModelOptions", () => {
|
||||
});
|
||||
|
||||
it("keeps the currently selected custom model available even if it is no longer saved", () => {
|
||||
const options = getAppModelOptions([], "custom/selected-model");
|
||||
const options = getAppModelOptions("codex", [], "custom/selected-model");
|
||||
|
||||
expect(options.at(-1)).toEqual({
|
||||
slug: "custom/selected-model",
|
||||
@@ -39,18 +51,44 @@ describe("getAppModelOptions", () => {
|
||||
isCustom: true,
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps a saved custom provider model available as an exact slug option", () => {
|
||||
const options = getAppModelOptions("claudeCode", ["claude/custom-opus"], "claude/custom-opus");
|
||||
|
||||
expect(options.some((option) => option.slug === "claude/custom-opus" && option.isCustom)).toBe(
|
||||
true,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getSlashModelOptions", () => {
|
||||
it("includes saved custom model slugs for /model command suggestions", () => {
|
||||
const options = getSlashModelOptions(["custom/internal-model"], "", "gpt-5.3-codex");
|
||||
const options = getSlashModelOptions(
|
||||
"codex",
|
||||
["custom/internal-model"],
|
||||
"",
|
||||
"gpt-5.3-codex",
|
||||
);
|
||||
|
||||
expect(options.some((option) => option.slug === "custom/internal-model")).toBe(true);
|
||||
});
|
||||
|
||||
it("filters slash-model suggestions across built-in and custom model names", () => {
|
||||
const options = getSlashModelOptions(["openai/gpt-oss-120b"], "oss", "gpt-5.3-codex");
|
||||
const options = getSlashModelOptions(
|
||||
"codex",
|
||||
["openai/gpt-oss-120b"],
|
||||
"oss",
|
||||
"gpt-5.3-codex",
|
||||
);
|
||||
|
||||
expect(options.map((option) => option.slug)).toEqual(["openai/gpt-oss-120b"]);
|
||||
});
|
||||
|
||||
it("includes provider-specific custom slugs in non-codex model lists", () => {
|
||||
const claudeOptions = getAppModelOptions("claudeCode", ["claude/custom-opus"]);
|
||||
const cursorOptions = getAppModelOptions("cursor", ["cursor/custom-model"]);
|
||||
|
||||
expect(claudeOptions.some((option) => option.slug === "claude/custom-opus")).toBe(true);
|
||||
expect(cursorOptions.some((option) => option.slug === "cursor/custom-model")).toBe(true);
|
||||
});
|
||||
});
|
||||
+27
-10
@@ -1,11 +1,16 @@
|
||||
import { useCallback, useSyncExternalStore } from "react";
|
||||
import { Option, Schema } from "effect";
|
||||
import { MODEL_OPTIONS, normalizeModelSlug } from "@t3tools/contracts";
|
||||
import { type ProviderKind } from "@t3tools/contracts";
|
||||
import { getModelOptions, normalizeModelSlug } from "@t3tools/shared/model";
|
||||
|
||||
const APP_SETTINGS_STORAGE_KEY = "t3code:app-settings:v1";
|
||||
const MAX_CUSTOM_MODEL_COUNT = 32;
|
||||
export const MAX_CUSTOM_MODEL_LENGTH = 256;
|
||||
const BUILT_IN_MODEL_SLUGS = new Set<string>(MODEL_OPTIONS.map((option) => option.slug));
|
||||
const BUILT_IN_MODEL_SLUGS_BY_PROVIDER: Record<ProviderKind, ReadonlySet<string>> = {
|
||||
codex: new Set(getModelOptions("codex").map((option) => option.slug)),
|
||||
claudeCode: new Set(getModelOptions("claudeCode").map((option) => option.slug)),
|
||||
cursor: new Set(getModelOptions("cursor").map((option) => option.slug)),
|
||||
};
|
||||
|
||||
const AppSettingsSchema = Schema.Struct({
|
||||
codexBinaryPath: Schema.String.check(Schema.isMaxLength(4096)).pipe(
|
||||
@@ -21,6 +26,12 @@ const AppSettingsSchema = Schema.Struct({
|
||||
customCodexModels: Schema.Array(Schema.String).pipe(
|
||||
Schema.withConstructorDefault(() => Option.some([])),
|
||||
),
|
||||
customClaudeModels: Schema.Array(Schema.String).pipe(
|
||||
Schema.withConstructorDefault(() => Option.some([])),
|
||||
),
|
||||
customCursorModels: Schema.Array(Schema.String).pipe(
|
||||
Schema.withConstructorDefault(() => Option.some([])),
|
||||
),
|
||||
});
|
||||
export type AppSettings = typeof AppSettingsSchema.Type;
|
||||
export interface AppModelOption {
|
||||
@@ -37,16 +48,18 @@ let cachedSnapshot: AppSettings = DEFAULT_APP_SETTINGS;
|
||||
|
||||
export function normalizeCustomModelSlugs(
|
||||
models: Iterable<string | null | undefined>,
|
||||
): AppSettings["customCodexModels"] {
|
||||
provider: ProviderKind = "codex",
|
||||
): string[] {
|
||||
const normalizedModels: string[] = [];
|
||||
const seen = new Set<string>();
|
||||
const builtInModelSlugs = BUILT_IN_MODEL_SLUGS_BY_PROVIDER[provider];
|
||||
|
||||
for (const candidate of models) {
|
||||
const normalized = normalizeModelSlug(candidate);
|
||||
const normalized = normalizeModelSlug(candidate, provider);
|
||||
if (
|
||||
!normalized ||
|
||||
normalized.length > MAX_CUSTOM_MODEL_LENGTH ||
|
||||
BUILT_IN_MODEL_SLUGS.has(normalized) ||
|
||||
builtInModelSlugs.has(normalized) ||
|
||||
seen.has(normalized)
|
||||
) {
|
||||
continue;
|
||||
@@ -65,22 +78,25 @@ export function normalizeCustomModelSlugs(
|
||||
function normalizeAppSettings(settings: AppSettings): AppSettings {
|
||||
return {
|
||||
...settings,
|
||||
customCodexModels: normalizeCustomModelSlugs(settings.customCodexModels),
|
||||
customCodexModels: normalizeCustomModelSlugs(settings.customCodexModels, "codex"),
|
||||
customClaudeModels: normalizeCustomModelSlugs(settings.customClaudeModels, "claudeCode"),
|
||||
customCursorModels: normalizeCustomModelSlugs(settings.customCursorModels, "cursor"),
|
||||
};
|
||||
}
|
||||
|
||||
export function getAppModelOptions(
|
||||
provider: ProviderKind,
|
||||
customModels: readonly string[],
|
||||
selectedModel?: string | null,
|
||||
): AppModelOption[] {
|
||||
const options: AppModelOption[] = MODEL_OPTIONS.map(({ slug, name }) => ({
|
||||
const options: AppModelOption[] = getModelOptions(provider).map(({ slug, name }) => ({
|
||||
slug,
|
||||
name,
|
||||
isCustom: false,
|
||||
}));
|
||||
const seen = new Set(options.map((option) => option.slug));
|
||||
|
||||
for (const slug of normalizeCustomModelSlugs(customModels)) {
|
||||
for (const slug of normalizeCustomModelSlugs(customModels, provider)) {
|
||||
if (seen.has(slug)) {
|
||||
continue;
|
||||
}
|
||||
@@ -93,7 +109,7 @@ export function getAppModelOptions(
|
||||
});
|
||||
}
|
||||
|
||||
const normalizedSelectedModel = normalizeModelSlug(selectedModel);
|
||||
const normalizedSelectedModel = normalizeModelSlug(selectedModel, provider);
|
||||
if (normalizedSelectedModel && !seen.has(normalizedSelectedModel)) {
|
||||
options.push({
|
||||
slug: normalizedSelectedModel,
|
||||
@@ -106,12 +122,13 @@ export function getAppModelOptions(
|
||||
}
|
||||
|
||||
export function getSlashModelOptions(
|
||||
provider: ProviderKind,
|
||||
customModels: readonly string[],
|
||||
query: string,
|
||||
selectedModel?: string | null,
|
||||
): AppModelOption[] {
|
||||
const normalizedQuery = query.trim().toLowerCase();
|
||||
const options = getAppModelOptions(customModels, selectedModel);
|
||||
const options = getAppModelOptions(provider, customModels, selectedModel);
|
||||
if (!normalizedQuery) {
|
||||
return options;
|
||||
}
|
||||
|
||||
@@ -52,8 +52,7 @@ export default function BranchToolbar({
|
||||
const api = readNativeApi();
|
||||
// If the effective cwd is about to change, stop the running session so the
|
||||
// next message creates a new one with the correct cwd.
|
||||
const sessionId = serverThread?.session?.sessionId;
|
||||
if (sessionId && worktreePath !== activeWorktreePath && api) {
|
||||
if (serverThread?.session && worktreePath !== activeWorktreePath && api) {
|
||||
void api.orchestration
|
||||
.dispatchCommand({
|
||||
type: "thread.session.stop",
|
||||
@@ -89,7 +88,7 @@ export default function BranchToolbar({
|
||||
},
|
||||
[
|
||||
activeThreadId,
|
||||
serverThread?.session?.sessionId,
|
||||
serverThread?.session,
|
||||
activeWorktreePath,
|
||||
hasServerThread,
|
||||
setThreadBranchAction,
|
||||
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
type MessageId,
|
||||
type OrchestrationReadModel,
|
||||
type ProjectId,
|
||||
type ProviderSessionId,
|
||||
type ServerConfig,
|
||||
type ThreadId,
|
||||
type WsWelcomePayload,
|
||||
@@ -204,6 +203,8 @@ function createSnapshotForTargetUser(options: {
|
||||
projectId: PROJECT_ID,
|
||||
title: "Browser test thread",
|
||||
model: "gpt-5",
|
||||
interactionMode: "default",
|
||||
runtimeMode: "full-access",
|
||||
branch: "main",
|
||||
worktreePath: null,
|
||||
latestTurn: null,
|
||||
@@ -212,15 +213,13 @@ function createSnapshotForTargetUser(options: {
|
||||
deletedAt: null,
|
||||
messages,
|
||||
activities: [],
|
||||
proposedPlans: [],
|
||||
checkpoints: [],
|
||||
session: {
|
||||
threadId: THREAD_ID,
|
||||
status: "ready",
|
||||
providerName: "codex",
|
||||
providerSessionId: "session-1" as ProviderSessionId,
|
||||
providerThreadId: null,
|
||||
approvalPolicy: "on-failure",
|
||||
sandboxMode: "workspace-write",
|
||||
runtimeMode: "full-access",
|
||||
activeTurnId: null,
|
||||
lastError: null,
|
||||
updatedAt: NOW_ISO,
|
||||
@@ -552,7 +551,6 @@ describe("ChatView timeline estimator parity (full app)", () => {
|
||||
projects: [],
|
||||
threads: [],
|
||||
threadsHydrated: false,
|
||||
runtimeMode: "full-access",
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
+1988
-212
File diff suppressed because it is too large.
Load diff
@@ -142,3 +142,200 @@ export const Zed: Icon = (props) => {
|
||||
</svg>
|
||||
);
|
||||
};
|
||||
|
||||
export const OpenAI: Icon = (props) => (
|
||||
<svg {...props} preserveAspectRatio="xMidYMid" viewBox="0 0 256 260" fill="currentColor">
|
||||
<path d="M239.184 106.203a64.716 64.716 0 0 0-5.576-53.103C219.452 28.459 191 15.784 163.213 21.74A65.586 65.586 0 0 0 52.096 45.22a64.716 64.716 0 0 0-43.23 31.36c-14.31 24.602-11.061 55.634 8.033 76.74a64.665 64.665 0 0 0 5.525 53.102c14.174 24.65 42.644 37.324 70.446 31.36a64.72 64.72 0 0 0 48.754 21.744c28.481.025 53.714-18.361 62.414-45.481a64.767 64.767 0 0 0 43.229-31.36c14.137-24.558 10.875-55.423-8.083-76.483Zm-97.56 136.338a48.397 48.397 0 0 1-31.105-11.255l1.535-.87 51.67-29.825a8.595 8.595 0 0 0 4.247-7.367v-72.85l21.845 12.636c.218.111.37.32.409.563v60.367c-.056 26.818-21.783 48.545-48.601 48.601Zm-104.466-44.61a48.345 48.345 0 0 1-5.781-32.589l1.534.921 51.722 29.826a8.339 8.339 0 0 0 8.441 0l63.181-36.425v25.221a.87.87 0 0 1-.358.665l-52.335 30.184c-23.257 13.398-52.97 5.431-66.404-17.803ZM23.549 85.38a48.499 48.499 0 0 1 25.58-21.333v61.39a8.288 8.288 0 0 0 4.195 7.316l62.874 36.272-21.845 12.636a.819.819 0 0 1-.767 0L41.353 151.53c-23.211-13.454-31.171-43.144-17.804-66.405v.256Zm179.466 41.695-63.08-36.63L161.73 77.86a.819.819 0 0 1 .768 0l52.233 30.184a48.6 48.6 0 0 1-7.316 87.635v-61.391a8.544 8.544 0 0 0-4.4-7.213Zm21.742-32.69-1.535-.922-51.619-30.081a8.39 8.39 0 0 0-8.492 0L99.98 99.808V74.587a.716.716 0 0 1 .307-.665l52.233-30.133a48.652 48.652 0 0 1 72.236 50.391v.205ZM88.061 139.097l-21.845-12.585a.87.87 0 0 1-.41-.614V65.685a48.652 48.652 0 0 1 79.757-37.346l-1.535.87-51.67 29.825a8.595 8.595 0 0 0-4.246 7.367l-.051 72.697Zm11.868-25.58 28.138-16.217 28.188 16.218v32.434l-28.086 16.218-28.188-16.218-.052-32.434Z" />
|
||||
</svg>
|
||||
);
|
||||
|
||||
export const ClaudeAI: Icon = (props) => (
|
||||
<svg {...props} preserveAspectRatio="xMidYMid" viewBox="0 0 256 257">
|
||||
<path
|
||||
fill="#D97757"
|
||||
d="m50.228 170.321 50.357-28.257.843-2.463-.843-1.361h-2.462l-8.426-.518-28.775-.778-24.952-1.037-24.175-1.296-6.092-1.297L0 125.796l.583-3.759 5.12-3.434 7.324.648 16.202 1.101 24.304 1.685 17.629 1.037 26.118 2.722h4.148l.583-1.685-1.426-1.037-1.101-1.037-25.147-17.045-27.22-18.017-14.258-10.37-7.713-5.25-3.888-4.925-1.685-10.758 7-7.713 9.397.649 2.398.648 9.527 7.323 20.35 15.75L94.817 91.9l3.889 3.24 1.555-1.102.195-.777-1.75-2.917-14.453-26.118-15.425-26.572-6.87-11.018-1.814-6.61c-.648-2.723-1.102-4.991-1.102-7.778l7.972-10.823L71.42 0 82.05 1.426l4.472 3.888 6.61 15.101 10.694 23.786 16.591 32.34 4.861 9.592 2.592 8.879.973 2.722h1.685v-1.556l1.36-18.211 2.528-22.36 2.463-28.776.843-8.1 4.018-9.722 7.971-5.25 6.222 2.981 5.12 7.324-.713 4.73-3.046 19.768-5.962 30.98-3.889 20.739h2.268l2.593-2.593 10.499-13.934 17.628-22.036 7.778-8.749 9.073-9.657 5.833-4.601h11.018l8.1 12.055-3.628 12.443-11.342 14.388-9.398 12.184-13.48 18.147-8.426 14.518.778 1.166 2.01-.194 30.46-6.481 16.462-2.982 19.637-3.37 8.88 4.148.971 4.213-3.5 8.62-20.998 5.184-24.628 4.926-36.682 8.685-.454.324.519.648 16.526 1.555 7.065.389h17.304l32.21 2.398 8.426 5.574 5.055 6.805-.843 5.184-12.962 6.611-17.498-4.148-40.83-9.721-14-3.5h-1.944v1.167l11.666 11.406 21.387 19.314 26.767 24.887 1.36 6.157-3.434 4.86-3.63-.518-23.526-17.693-9.073-7.972-20.545-17.304h-1.36v1.814l4.73 6.935 25.017 37.59 1.296 11.536-1.814 3.76-6.481 2.268-7.13-1.297-14.647-20.544-15.1-23.138-12.185-20.739-1.49.843-7.194 77.448-3.37 3.953-7.778 2.981-6.48-4.925-3.436-7.972 3.435-15.749 4.148-20.544 3.37-16.333 3.046-20.285 1.815-6.74-.13-.454-1.49.194-15.295 20.999-23.267 31.433-18.406 19.702-4.407 1.75-7.648-3.954.713-7.064 4.277-6.286 25.47-32.405 15.36-20.092 9.917-11.6-.065-1.686h-.583L44.07 198.125l-12.055 1.555-5.185-4.86.648-7.972 2.463-2.593 20.35-13.999-.064.065Z"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
|
||||
export const Gemini: Icon = (props) => (
|
||||
<svg {...props} viewBox="0 0 296 298" fill="none">
|
||||
<mask
|
||||
id="gemini__a"
|
||||
width="296"
|
||||
height="298"
|
||||
x="0"
|
||||
y="0"
|
||||
maskUnits="userSpaceOnUse"
|
||||
style={{ maskType: "alpha" }}
|
||||
>
|
||||
<path
|
||||
fill="#3186FF"
|
||||
d="M141.201 4.886c2.282-6.17 11.042-6.071 13.184.148l5.985 17.37a184.004 184.004 0 0 0 111.257 113.049l19.304 6.997c6.143 2.227 6.156 10.91.02 13.155l-19.35 7.082a184.001 184.001 0 0 0-109.495 109.385l-7.573 20.629c-2.241 6.105-10.869 6.121-13.133.025l-7.908-21.296a184 184 0 0 0-109.02-108.658l-19.698-7.239c-6.102-2.243-6.118-10.867-.025-13.132l20.083-7.467A183.998 183.998 0 0 0 133.291 26.28l7.91-21.394Z"
|
||||
/>
|
||||
</mask>
|
||||
<g mask="url(#gemini__a)">
|
||||
<g filter="url(#gemini__b)">
|
||||
<ellipse cx="163" cy="149" fill="#3689FF" rx="196" ry="159" />
|
||||
</g>
|
||||
<g filter="url(#gemini__c)">
|
||||
<ellipse cx="33.5" cy="142.5" fill="#F6C013" rx="68.5" ry="72.5" />
|
||||
</g>
|
||||
<g filter="url(#gemini__d)">
|
||||
<ellipse cx="19.5" cy="148.5" fill="#F6C013" rx="68.5" ry="72.5" />
|
||||
</g>
|
||||
<g filter="url(#gemini__e)">
|
||||
<path
|
||||
fill="#FA4340"
|
||||
d="M194 10.5C172 82.5 65.5 134.333 22.5 135L144-66l50 76.5Z"
|
||||
/>
|
||||
</g>
|
||||
<g filter="url(#gemini__f)">
|
||||
<path
|
||||
fill="#FA4340"
|
||||
d="M190.5-12.5C168.5 59.5 62 111.333 19 112L140.5-89l50 76.5Z"
|
||||
/>
|
||||
</g>
|
||||
<g filter="url(#gemini__g)">
|
||||
<path
|
||||
fill="#14BB69"
|
||||
d="M194.5 279.5C172.5 207.5 66 155.667 23 155l121.5 201 50-76.5Z"
|
||||
/>
|
||||
</g>
|
||||
<g filter="url(#gemini__h)">
|
||||
<path
|
||||
fill="#14BB69"
|
||||
d="M196.5 320.5C174.5 248.5 68 196.667 25 196l121.5 201 50-76.5Z"
|
||||
/>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<filter
|
||||
id="gemini__b"
|
||||
width="464"
|
||||
height="390"
|
||||
x="-69"
|
||||
y="-46"
|
||||
colorInterpolationFilters="sRGB"
|
||||
filterUnits="userSpaceOnUse"
|
||||
>
|
||||
<feFlood floodOpacity="0" result="BackgroundImageFix" />
|
||||
<feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
|
||||
<feGaussianBlur
|
||||
result="effect1_foregroundBlur_69_17998"
|
||||
stdDeviation="18"
|
||||
/>
|
||||
</filter>
|
||||
<filter
|
||||
id="gemini__c"
|
||||
width="265"
|
||||
height="273"
|
||||
x="-99"
|
||||
y="6"
|
||||
colorInterpolationFilters="sRGB"
|
||||
filterUnits="userSpaceOnUse"
|
||||
>
|
||||
<feFlood floodOpacity="0" result="BackgroundImageFix" />
|
||||
<feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
|
||||
<feGaussianBlur
|
||||
result="effect1_foregroundBlur_69_17998"
|
||||
stdDeviation="32"
|
||||
/>
|
||||
</filter>
|
||||
<filter
|
||||
id="gemini__d"
|
||||
width="265"
|
||||
height="273"
|
||||
x="-113"
|
||||
y="12"
|
||||
colorInterpolationFilters="sRGB"
|
||||
filterUnits="userSpaceOnUse"
|
||||
>
|
||||
<feFlood floodOpacity="0" result="BackgroundImageFix" />
|
||||
<feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
|
||||
<feGaussianBlur
|
||||
result="effect1_foregroundBlur_69_17998"
|
||||
stdDeviation="32"
|
||||
/>
|
||||
</filter>
|
||||
<filter
|
||||
id="gemini__e"
|
||||
width="299.5"
|
||||
height="329"
|
||||
x="-41.5"
|
||||
y="-130"
|
||||
colorInterpolationFilters="sRGB"
|
||||
filterUnits="userSpaceOnUse"
|
||||
>
|
||||
<feFlood floodOpacity="0" result="BackgroundImageFix" />
|
||||
<feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
|
||||
<feGaussianBlur
|
||||
result="effect1_foregroundBlur_69_17998"
|
||||
stdDeviation="32"
|
||||
/>
|
||||
</filter>
|
||||
<filter
|
||||
id="gemini__f"
|
||||
width="299.5"
|
||||
height="329"
|
||||
x="-45"
|
||||
y="-153"
|
||||
colorInterpolationFilters="sRGB"
|
||||
filterUnits="userSpaceOnUse"
|
||||
>
|
||||
<feFlood floodOpacity="0" result="BackgroundImageFix" />
|
||||
<feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
|
||||
<feGaussianBlur
|
||||
result="effect1_foregroundBlur_69_17998"
|
||||
stdDeviation="32"
|
||||
/>
|
||||
</filter>
|
||||
<filter
|
||||
id="gemini__g"
|
||||
width="299.5"
|
||||
height="329"
|
||||
x="-41"
|
||||
y="91"
|
||||
colorInterpolationFilters="sRGB"
|
||||
filterUnits="userSpaceOnUse"
|
||||
>
|
||||
<feFlood floodOpacity="0" result="BackgroundImageFix" />
|
||||
<feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
|
||||
<feGaussianBlur
|
||||
result="effect1_foregroundBlur_69_17998"
|
||||
stdDeviation="32"
|
||||
/>
|
||||
</filter>
|
||||
<filter
|
||||
id="gemini__h"
|
||||
width="299.5"
|
||||
height="329"
|
||||
x="-39"
|
||||
y="132"
|
||||
colorInterpolationFilters="sRGB"
|
||||
filterUnits="userSpaceOnUse"
|
||||
>
|
||||
<feFlood floodOpacity="0" result="BackgroundImageFix" />
|
||||
<feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape" />
|
||||
<feGaussianBlur
|
||||
result="effect1_foregroundBlur_69_17998"
|
||||
stdDeviation="32"
|
||||
/>
|
||||
</filter>
|
||||
</defs>
|
||||
</svg>
|
||||
);
|
||||
|
||||
export const OpenCodeIcon: Icon = (props) => (
|
||||
<svg {...props} viewBox="0 0 32 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clipPath="url(#opencode__clip0_1311_94969)">
|
||||
<path d="M24 32H8V16H24V32Z" fill="#BCBBBB" />
|
||||
<path d="M24 8H8V32H24V8ZM32 40H0V0H32V40Z" fill="#211E1E" />
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="opencode__clip0_1311_94969">
|
||||
<rect width="32" height="40" fill="white" />
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
);
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
} from "lucide-react";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import {
|
||||
DEFAULT_RUNTIME_MODE,
|
||||
DEFAULT_MODEL,
|
||||
type DesktopUpdateState,
|
||||
ProjectId,
|
||||
@@ -435,6 +436,7 @@ export default function Sidebar() {
|
||||
branch: options?.branch ?? null,
|
||||
worktreePath: options?.worktreePath ?? null,
|
||||
envMode: options?.envMode ?? "local",
|
||||
runtimeMode: DEFAULT_RUNTIME_MODE,
|
||||
});
|
||||
|
||||
await navigate({
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
detectComposerTrigger,
|
||||
expandCollapsedComposerCursor,
|
||||
isCollapsedCursorAdjacentToMention,
|
||||
parseStandaloneComposerSlashCommand,
|
||||
replaceTextRange,
|
||||
} from "./composer-logic";
|
||||
|
||||
@@ -43,6 +44,18 @@ describe("detectComposerTrigger", () => {
|
||||
rangeEnd: text.length,
|
||||
});
|
||||
});
|
||||
|
||||
it("detects non-model slash commands while typing", () => {
|
||||
const text = "/pl";
|
||||
const trigger = detectComposerTrigger(text, text.length);
|
||||
|
||||
expect(trigger).toEqual({
|
||||
kind: "slash-command",
|
||||
query: "pl",
|
||||
rangeStart: 0,
|
||||
rangeEnd: text.length,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("replaceTextRange", () => {
|
||||
@@ -111,3 +124,17 @@ describe("isCollapsedCursorAdjacentToMention", () => {
|
||||
expect(isCollapsedCursorAdjacentToMention(text, mentionStart - 1, "right")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("parseStandaloneComposerSlashCommand", () => {
|
||||
it("parses standalone /plan command", () => {
|
||||
expect(parseStandaloneComposerSlashCommand(" /plan ")).toBe("plan");
|
||||
});
|
||||
|
||||
it("parses standalone /default command", () => {
|
||||
expect(parseStandaloneComposerSlashCommand("/default")).toBe("default");
|
||||
});
|
||||
|
||||
it("ignores slash commands with extra message text", () => {
|
||||
expect(parseStandaloneComposerSlashCommand("/plan explain this")).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -1,6 +1,7 @@
|
||||
import { splitPromptIntoComposerSegments } from "./composer-editor-mentions";
|
||||
|
||||
export type ComposerTriggerKind = "path" | "slash-command" | "slash-model";
|
||||
export type ComposerSlashCommand = "model" | "plan" | "default";
|
||||
|
||||
export interface ComposerTrigger {
|
||||
kind: ComposerTriggerKind;
|
||||
@@ -9,6 +10,8 @@ export interface ComposerTrigger {
|
||||
rangeEnd: number;
|
||||
}
|
||||
|
||||
const SLASH_COMMANDS: readonly ComposerSlashCommand[] = ["model", "plan", "default"];
|
||||
|
||||
function clampCursor(text: string, cursor: number): number {
|
||||
if (!Number.isFinite(cursor)) return text.length;
|
||||
return Math.max(0, Math.min(text.length, Math.floor(cursor)));
|
||||
@@ -121,7 +124,7 @@ export function detectComposerTrigger(text: string, cursorInput: number): Compos
|
||||
rangeEnd: cursor,
|
||||
};
|
||||
}
|
||||
if ("model".startsWith(commandQuery.toLowerCase())) {
|
||||
if (SLASH_COMMANDS.some((command) => command.startsWith(commandQuery.toLowerCase()))) {
|
||||
return {
|
||||
kind: "slash-command",
|
||||
query: commandQuery,
|
||||
@@ -157,6 +160,17 @@ export function detectComposerTrigger(text: string, cursorInput: number): Compos
|
||||
};
|
||||
}
|
||||
|
||||
export function parseStandaloneComposerSlashCommand(text: string): Exclude<
|
||||
ComposerSlashCommand,
|
||||
"model"
|
||||
> | null {
|
||||
const match = /^\/(plan|default)\s*$/i.exec(text.trim());
|
||||
if (!match) {
|
||||
return null;
|
||||
}
|
||||
return match[1]?.toLowerCase() === "plan" ? "plan" : "default";
|
||||
}
|
||||
|
||||
export function replaceTextRange(
|
||||
text: string,
|
||||
rangeStart: number,
|
||||
|
||||
@@ -184,6 +184,8 @@ describe("composerDraftStore project draft thread mapping", () => {
|
||||
branch: "feature/test",
|
||||
worktreePath: "/tmp/worktree-test",
|
||||
envMode: "worktree",
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: "default",
|
||||
createdAt: "2026-01-01T00:00:00.000Z",
|
||||
});
|
||||
expect(useComposerDraftStore.getState().getDraftThread(threadId)).toEqual({
|
||||
@@ -191,6 +193,8 @@ describe("composerDraftStore project draft thread mapping", () => {
|
||||
branch: "feature/test",
|
||||
worktreePath: "/tmp/worktree-test",
|
||||
envMode: "worktree",
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: "default",
|
||||
createdAt: "2026-01-01T00:00:00.000Z",
|
||||
});
|
||||
});
|
||||
@@ -329,6 +333,33 @@ describe("composerDraftStore project draft thread mapping", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("composerDraftStore codex fast mode", () => {
|
||||
const threadId = ThreadId.makeUnsafe("thread-service-tier");
|
||||
|
||||
beforeEach(() => {
|
||||
useComposerDraftStore.setState({
|
||||
draftsByThreadId: {},
|
||||
draftThreadsByThreadId: {},
|
||||
projectDraftThreadIdByProjectId: {},
|
||||
});
|
||||
});
|
||||
|
||||
it("stores codex fast mode in the draft", () => {
|
||||
const store = useComposerDraftStore.getState();
|
||||
store.setCodexFastMode(threadId, true);
|
||||
|
||||
expect(useComposerDraftStore.getState().draftsByThreadId[threadId]?.codexFastMode).toBe(true);
|
||||
});
|
||||
|
||||
it("clears codex fast mode when reset to the default", () => {
|
||||
const store = useComposerDraftStore.getState();
|
||||
store.setCodexFastMode(threadId, true);
|
||||
store.setCodexFastMode(threadId, false);
|
||||
|
||||
expect(useComposerDraftStore.getState().draftsByThreadId[threadId]).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("composerDraftStore setModel", () => {
|
||||
const threadId = ThreadId.makeUnsafe("thread-model");
|
||||
|
||||
@@ -348,3 +379,75 @@ describe("composerDraftStore setModel", () => {
|
||||
expect(useComposerDraftStore.getState().draftsByThreadId[threadId]?.model).toBe("gpt-5.3-codex");
|
||||
});
|
||||
});
|
||||
|
||||
describe("composerDraftStore setProvider", () => {
|
||||
const threadId = ThreadId.makeUnsafe("thread-provider");
|
||||
|
||||
beforeEach(() => {
|
||||
useComposerDraftStore.setState({
|
||||
draftsByThreadId: {},
|
||||
draftThreadsByThreadId: {},
|
||||
projectDraftThreadIdByProjectId: {},
|
||||
});
|
||||
});
|
||||
|
||||
it("persists provider-only selection even when prompt/model are empty", () => {
|
||||
const store = useComposerDraftStore.getState();
|
||||
|
||||
store.setProvider(threadId, "cursor");
|
||||
|
||||
expect(useComposerDraftStore.getState().draftsByThreadId[threadId]?.provider).toBe("cursor");
|
||||
});
|
||||
|
||||
it("removes empty provider-only draft when provider is reset", () => {
|
||||
const store = useComposerDraftStore.getState();
|
||||
|
||||
store.setProvider(threadId, "cursor");
|
||||
store.setProvider(threadId, null);
|
||||
|
||||
expect(useComposerDraftStore.getState().draftsByThreadId[threadId]).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("composerDraftStore runtime and interaction settings", () => {
|
||||
const threadId = ThreadId.makeUnsafe("thread-settings");
|
||||
|
||||
beforeEach(() => {
|
||||
useComposerDraftStore.setState({
|
||||
draftsByThreadId: {},
|
||||
draftThreadsByThreadId: {},
|
||||
projectDraftThreadIdByProjectId: {},
|
||||
});
|
||||
});
|
||||
|
||||
it("stores runtime mode overrides in the composer draft", () => {
|
||||
const store = useComposerDraftStore.getState();
|
||||
|
||||
store.setRuntimeMode(threadId, "approval-required");
|
||||
|
||||
expect(useComposerDraftStore.getState().draftsByThreadId[threadId]?.runtimeMode).toBe(
|
||||
"approval-required",
|
||||
);
|
||||
});
|
||||
|
||||
it("stores interaction mode overrides in the composer draft", () => {
|
||||
const store = useComposerDraftStore.getState();
|
||||
|
||||
store.setInteractionMode(threadId, "plan");
|
||||
|
||||
expect(useComposerDraftStore.getState().draftsByThreadId[threadId]?.interactionMode).toBe(
|
||||
"plan",
|
||||
);
|
||||
});
|
||||
|
||||
it("removes empty settings-only drafts when overrides are cleared", () => {
|
||||
const store = useComposerDraftStore.getState();
|
||||
|
||||
store.setRuntimeMode(threadId, "approval-required");
|
||||
store.setInteractionMode(threadId, "plan");
|
||||
store.setRuntimeMode(threadId, null);
|
||||
store.setInteractionMode(threadId, null);
|
||||
|
||||
expect(useComposerDraftStore.getState().draftsByThreadId[threadId]).toBeUndefined();
|
||||
});
|
||||
});
|
||||
@@ -1,12 +1,19 @@
|
||||
import {
|
||||
DEFAULT_REASONING,
|
||||
DEFAULT_REASONING_EFFORT_BY_PROVIDER,
|
||||
ProjectId,
|
||||
REASONING_OPTIONS,
|
||||
REASONING_EFFORT_OPTIONS_BY_PROVIDER,
|
||||
ThreadId,
|
||||
normalizeModelSlug,
|
||||
type ReasoningEffort,
|
||||
type CodexReasoningEffort,
|
||||
type ProviderKind,
|
||||
type ProviderInteractionMode,
|
||||
type RuntimeMode,
|
||||
} from "@t3tools/contracts";
|
||||
import type { ChatImageAttachment } from "./types";
|
||||
import { normalizeModelSlug } from "@t3tools/shared/model";
|
||||
import {
|
||||
DEFAULT_INTERACTION_MODE,
|
||||
DEFAULT_RUNTIME_MODE,
|
||||
type ChatImageAttachment,
|
||||
} from "./types";
|
||||
import { create } from "zustand";
|
||||
import { createJSONStorage, persist } from "zustand/middleware";
|
||||
|
||||
@@ -29,13 +36,20 @@ export interface ComposerImageAttachment extends Omit<ChatImageAttachment, "prev
|
||||
interface PersistedComposerThreadDraftState {
|
||||
prompt: string;
|
||||
attachments: PersistedComposerImageAttachment[];
|
||||
provider?: ProviderKind | null;
|
||||
model?: string | null;
|
||||
effort?: ReasoningEffort | null;
|
||||
runtimeMode?: RuntimeMode | null;
|
||||
interactionMode?: ProviderInteractionMode | null;
|
||||
effort?: CodexReasoningEffort | null;
|
||||
codexFastMode?: boolean | null;
|
||||
serviceTier?: string | null;
|
||||
}
|
||||
|
||||
interface PersistedDraftThreadState {
|
||||
projectId: ProjectId;
|
||||
createdAt: string;
|
||||
runtimeMode: RuntimeMode;
|
||||
interactionMode: ProviderInteractionMode;
|
||||
branch: string | null;
|
||||
worktreePath: string | null;
|
||||
envMode: DraftThreadEnvMode;
|
||||
@@ -52,13 +66,19 @@ interface ComposerThreadDraftState {
|
||||
images: ComposerImageAttachment[];
|
||||
nonPersistedImageIds: string[];
|
||||
persistedAttachments: PersistedComposerImageAttachment[];
|
||||
provider: ProviderKind | null;
|
||||
model: string | null;
|
||||
effort: ReasoningEffort | null;
|
||||
runtimeMode: RuntimeMode | null;
|
||||
interactionMode: ProviderInteractionMode | null;
|
||||
effort: CodexReasoningEffort | null;
|
||||
codexFastMode: boolean;
|
||||
}
|
||||
|
||||
export interface DraftThreadState {
|
||||
projectId: ProjectId;
|
||||
createdAt: string;
|
||||
runtimeMode: RuntimeMode;
|
||||
interactionMode: ProviderInteractionMode;
|
||||
branch: string | null;
|
||||
worktreePath: string | null;
|
||||
envMode: DraftThreadEnvMode;
|
||||
@@ -82,6 +102,8 @@ interface ComposerDraftStoreState {
|
||||
worktreePath?: string | null;
|
||||
createdAt?: string;
|
||||
envMode?: DraftThreadEnvMode;
|
||||
runtimeMode?: RuntimeMode;
|
||||
interactionMode?: ProviderInteractionMode;
|
||||
},
|
||||
) => void;
|
||||
setDraftThreadContext: (
|
||||
@@ -92,14 +114,23 @@ interface ComposerDraftStoreState {
|
||||
projectId?: ProjectId;
|
||||
createdAt?: string;
|
||||
envMode?: DraftThreadEnvMode;
|
||||
runtimeMode?: RuntimeMode;
|
||||
interactionMode?: ProviderInteractionMode;
|
||||
},
|
||||
) => void;
|
||||
clearProjectDraftThreadId: (projectId: ProjectId) => void;
|
||||
clearProjectDraftThreadById: (projectId: ProjectId, threadId: ThreadId) => void;
|
||||
clearDraftThread: (threadId: ThreadId) => void;
|
||||
setPrompt: (threadId: ThreadId, prompt: string) => void;
|
||||
setProvider: (threadId: ThreadId, provider: ProviderKind | null | undefined) => void;
|
||||
setModel: (threadId: ThreadId, model: string | null | undefined) => void;
|
||||
setEffort: (threadId: ThreadId, effort: ReasoningEffort | null | undefined) => void;
|
||||
setRuntimeMode: (threadId: ThreadId, runtimeMode: RuntimeMode | null | undefined) => void;
|
||||
setInteractionMode: (
|
||||
threadId: ThreadId,
|
||||
interactionMode: ProviderInteractionMode | null | undefined,
|
||||
) => void;
|
||||
setEffort: (threadId: ThreadId, effort: CodexReasoningEffort | null | undefined) => void;
|
||||
setCodexFastMode: (threadId: ThreadId, enabled: boolean | null | undefined) => void;
|
||||
addImage: (threadId: ThreadId, image: ComposerImageAttachment) => void;
|
||||
addImages: (threadId: ThreadId, images: ComposerImageAttachment[]) => void;
|
||||
removeImage: (threadId: ThreadId, imageId: string) => void;
|
||||
@@ -129,11 +160,17 @@ const EMPTY_THREAD_DRAFT = Object.freeze({
|
||||
images: EMPTY_IMAGES,
|
||||
nonPersistedImageIds: EMPTY_IDS,
|
||||
persistedAttachments: EMPTY_PERSISTED_ATTACHMENTS,
|
||||
provider: null,
|
||||
model: null,
|
||||
runtimeMode: null,
|
||||
interactionMode: null,
|
||||
effort: null,
|
||||
codexFastMode: false,
|
||||
}) as ComposerThreadDraftState;
|
||||
|
||||
const REASONING_EFFORT_VALUES = new Set<ReasoningEffort>(REASONING_OPTIONS);
|
||||
const REASONING_EFFORT_VALUES = new Set<CodexReasoningEffort>(
|
||||
REASONING_EFFORT_OPTIONS_BY_PROVIDER.codex,
|
||||
);
|
||||
|
||||
function createEmptyThreadDraft(): ComposerThreadDraftState {
|
||||
return {
|
||||
@@ -141,8 +178,12 @@ function createEmptyThreadDraft(): ComposerThreadDraftState {
|
||||
images: [],
|
||||
nonPersistedImageIds: [],
|
||||
persistedAttachments: [],
|
||||
provider: null,
|
||||
model: null,
|
||||
runtimeMode: null,
|
||||
interactionMode: null,
|
||||
effort: null,
|
||||
codexFastMode: false,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -157,11 +198,19 @@ function shouldRemoveDraft(draft: ComposerThreadDraftState): boolean {
|
||||
draft.prompt.length === 0 &&
|
||||
draft.images.length === 0 &&
|
||||
draft.persistedAttachments.length === 0 &&
|
||||
draft.provider === null &&
|
||||
draft.model === null &&
|
||||
draft.effort === null
|
||||
draft.runtimeMode === null &&
|
||||
draft.interactionMode === null &&
|
||||
draft.effort === null &&
|
||||
draft.codexFastMode === false
|
||||
);
|
||||
}
|
||||
|
||||
function normalizeProviderKind(value: unknown): ProviderKind | null {
|
||||
return value === "codex" || value === "claudeCode" || value === "cursor" ? value : null;
|
||||
}
|
||||
|
||||
function revokeObjectPreviewUrl(previewUrl: string): void {
|
||||
if (typeof URL === "undefined") {
|
||||
return;
|
||||
@@ -247,6 +296,16 @@ function normalizePersistedComposerDraftState(value: unknown): PersistedComposer
|
||||
typeof createdAt === "string" && createdAt.length > 0
|
||||
? createdAt
|
||||
: new Date().toISOString(),
|
||||
runtimeMode:
|
||||
candidateDraftThread.runtimeMode === "approval-required" ||
|
||||
candidateDraftThread.runtimeMode === "full-access"
|
||||
? candidateDraftThread.runtimeMode
|
||||
: DEFAULT_RUNTIME_MODE,
|
||||
interactionMode:
|
||||
candidateDraftThread.interactionMode === "plan" ||
|
||||
candidateDraftThread.interactionMode === "default"
|
||||
? candidateDraftThread.interactionMode
|
||||
: DEFAULT_INTERACTION_MODE,
|
||||
branch: typeof branch === "string" ? branch : null,
|
||||
worktreePath: normalizedWorktreePath,
|
||||
envMode: normalizeDraftThreadEnvMode(candidateDraftThread.envMode, normalizedWorktreePath),
|
||||
@@ -273,6 +332,8 @@ function normalizePersistedComposerDraftState(value: unknown): PersistedComposer
|
||||
draftThreadsByThreadId[threadId as ThreadId] = {
|
||||
projectId: projectId as ProjectId,
|
||||
createdAt: new Date().toISOString(),
|
||||
runtimeMode: DEFAULT_RUNTIME_MODE,
|
||||
interactionMode: DEFAULT_INTERACTION_MODE,
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
envMode: "local",
|
||||
@@ -305,22 +366,50 @@ function normalizePersistedComposerDraftState(value: unknown): PersistedComposer
|
||||
return normalized ? [normalized] : [];
|
||||
})
|
||||
: [];
|
||||
const provider = normalizeProviderKind(draftCandidate.provider);
|
||||
const model =
|
||||
typeof draftCandidate.model === "string" ? normalizeModelSlug(draftCandidate.model) : null;
|
||||
typeof draftCandidate.model === "string"
|
||||
? normalizeModelSlug(draftCandidate.model, provider ?? "codex")
|
||||
: null;
|
||||
const runtimeMode =
|
||||
draftCandidate.runtimeMode === "approval-required" ||
|
||||
draftCandidate.runtimeMode === "full-access"
|
||||
? draftCandidate.runtimeMode
|
||||
: null;
|
||||
const interactionMode =
|
||||
draftCandidate.interactionMode === "plan" || draftCandidate.interactionMode === "default"
|
||||
? draftCandidate.interactionMode
|
||||
: null;
|
||||
const effortCandidate =
|
||||
typeof draftCandidate.effort === "string" ? draftCandidate.effort : null;
|
||||
const effort =
|
||||
effortCandidate && REASONING_EFFORT_VALUES.has(effortCandidate as ReasoningEffort)
|
||||
? (effortCandidate as ReasoningEffort)
|
||||
effortCandidate && REASONING_EFFORT_VALUES.has(effortCandidate as CodexReasoningEffort)
|
||||
? (effortCandidate as CodexReasoningEffort)
|
||||
: null;
|
||||
if (prompt.length === 0 && attachments.length === 0 && !model && !effort) {
|
||||
const codexFastMode =
|
||||
draftCandidate.codexFastMode === true ||
|
||||
(typeof draftCandidate.serviceTier === "string" && draftCandidate.serviceTier === "fast");
|
||||
if (
|
||||
prompt.length === 0 &&
|
||||
attachments.length === 0 &&
|
||||
!provider &&
|
||||
!model &&
|
||||
!runtimeMode &&
|
||||
!interactionMode &&
|
||||
!effort &&
|
||||
!codexFastMode
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
nextDraftsByThreadId[threadId as ThreadId] = {
|
||||
prompt,
|
||||
attachments,
|
||||
...(provider ? { provider } : {}),
|
||||
...(model ? { model } : {}),
|
||||
...(runtimeMode ? { runtimeMode } : {}),
|
||||
...(interactionMode ? { interactionMode } : {}),
|
||||
...(effort ? { effort } : {}),
|
||||
...(codexFastMode ? { codexFastMode } : {}),
|
||||
};
|
||||
}
|
||||
return {
|
||||
@@ -422,8 +511,12 @@ function toHydratedThreadDraft(
|
||||
images: hydrateImagesFromPersisted(persistedDraft.attachments),
|
||||
nonPersistedImageIds: [],
|
||||
persistedAttachments: persistedDraft.attachments,
|
||||
provider: persistedDraft.provider ?? null,
|
||||
model: persistedDraft.model ?? null,
|
||||
runtimeMode: persistedDraft.runtimeMode ?? null,
|
||||
interactionMode: persistedDraft.interactionMode ?? null,
|
||||
effort: persistedDraft.effort ?? null,
|
||||
codexFastMode: persistedDraft.codexFastMode === true,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -470,6 +563,11 @@ export const useComposerDraftStore = create<ComposerDraftStoreState>()(
|
||||
const nextDraftThread: DraftThreadState = {
|
||||
projectId,
|
||||
createdAt: options?.createdAt ?? existingThread?.createdAt ?? new Date().toISOString(),
|
||||
runtimeMode: options?.runtimeMode ?? existingThread?.runtimeMode ?? DEFAULT_RUNTIME_MODE,
|
||||
interactionMode:
|
||||
options?.interactionMode ??
|
||||
existingThread?.interactionMode ??
|
||||
DEFAULT_INTERACTION_MODE,
|
||||
branch:
|
||||
options?.branch === undefined
|
||||
? (existingThread?.branch ?? null)
|
||||
@@ -484,6 +582,8 @@ export const useComposerDraftStore = create<ComposerDraftStoreState>()(
|
||||
existingThread &&
|
||||
existingThread.projectId === nextDraftThread.projectId &&
|
||||
existingThread.createdAt === nextDraftThread.createdAt &&
|
||||
existingThread.runtimeMode === nextDraftThread.runtimeMode &&
|
||||
existingThread.interactionMode === nextDraftThread.interactionMode &&
|
||||
existingThread.branch === nextDraftThread.branch &&
|
||||
existingThread.worktreePath === nextDraftThread.worktreePath &&
|
||||
existingThread.envMode === nextDraftThread.envMode;
|
||||
@@ -538,6 +638,8 @@ export const useComposerDraftStore = create<ComposerDraftStoreState>()(
|
||||
options.createdAt === undefined
|
||||
? existing.createdAt
|
||||
: options.createdAt || existing.createdAt,
|
||||
runtimeMode: options.runtimeMode ?? existing.runtimeMode,
|
||||
interactionMode: options.interactionMode ?? existing.interactionMode,
|
||||
branch: options.branch === undefined ? existing.branch : (options.branch ?? null),
|
||||
worktreePath: nextWorktreePath,
|
||||
envMode:
|
||||
@@ -547,6 +649,8 @@ export const useComposerDraftStore = create<ComposerDraftStoreState>()(
|
||||
const isUnchanged =
|
||||
nextDraftThread.projectId === existing.projectId &&
|
||||
nextDraftThread.createdAt === existing.createdAt &&
|
||||
nextDraftThread.runtimeMode === existing.runtimeMode &&
|
||||
nextDraftThread.interactionMode === existing.interactionMode &&
|
||||
nextDraftThread.branch === existing.branch &&
|
||||
nextDraftThread.worktreePath === existing.worktreePath &&
|
||||
nextDraftThread.envMode === existing.envMode;
|
||||
@@ -674,6 +778,33 @@ export const useComposerDraftStore = create<ComposerDraftStoreState>()(
|
||||
return { draftsByThreadId: nextDraftsByThreadId };
|
||||
});
|
||||
},
|
||||
setProvider: (threadId, provider) => {
|
||||
if (threadId.length === 0) {
|
||||
return;
|
||||
}
|
||||
const normalizedProvider = normalizeProviderKind(provider);
|
||||
set((state) => {
|
||||
const existing = state.draftsByThreadId[threadId];
|
||||
if (!existing && normalizedProvider === null) {
|
||||
return state;
|
||||
}
|
||||
const base = existing ?? createEmptyThreadDraft();
|
||||
if (base.provider === normalizedProvider) {
|
||||
return state;
|
||||
}
|
||||
const nextDraft: ComposerThreadDraftState = {
|
||||
...base,
|
||||
provider: normalizedProvider,
|
||||
};
|
||||
const nextDraftsByThreadId = { ...state.draftsByThreadId };
|
||||
if (shouldRemoveDraft(nextDraft)) {
|
||||
delete nextDraftsByThreadId[threadId];
|
||||
} else {
|
||||
nextDraftsByThreadId[threadId] = nextDraft;
|
||||
}
|
||||
return { draftsByThreadId: nextDraftsByThreadId };
|
||||
});
|
||||
},
|
||||
setModel: (threadId, model) => {
|
||||
if (threadId.length === 0) {
|
||||
return;
|
||||
@@ -701,12 +832,70 @@ export const useComposerDraftStore = create<ComposerDraftStoreState>()(
|
||||
return { draftsByThreadId: nextDraftsByThreadId };
|
||||
});
|
||||
},
|
||||
setRuntimeMode: (threadId, runtimeMode) => {
|
||||
if (threadId.length === 0) {
|
||||
return;
|
||||
}
|
||||
const nextRuntimeMode =
|
||||
runtimeMode === "approval-required" || runtimeMode === "full-access" ? runtimeMode : null;
|
||||
set((state) => {
|
||||
const existing = state.draftsByThreadId[threadId];
|
||||
if (!existing && nextRuntimeMode === null) {
|
||||
return state;
|
||||
}
|
||||
const base = existing ?? createEmptyThreadDraft();
|
||||
if (base.runtimeMode === nextRuntimeMode) {
|
||||
return state;
|
||||
}
|
||||
const nextDraft: ComposerThreadDraftState = {
|
||||
...base,
|
||||
runtimeMode: nextRuntimeMode,
|
||||
};
|
||||
const nextDraftsByThreadId = { ...state.draftsByThreadId };
|
||||
if (shouldRemoveDraft(nextDraft)) {
|
||||
delete nextDraftsByThreadId[threadId];
|
||||
} else {
|
||||
nextDraftsByThreadId[threadId] = nextDraft;
|
||||
}
|
||||
return { draftsByThreadId: nextDraftsByThreadId };
|
||||
});
|
||||
},
|
||||
setInteractionMode: (threadId, interactionMode) => {
|
||||
if (threadId.length === 0) {
|
||||
return;
|
||||
}
|
||||
const nextInteractionMode =
|
||||
interactionMode === "plan" || interactionMode === "default" ? interactionMode : null;
|
||||
set((state) => {
|
||||
const existing = state.draftsByThreadId[threadId];
|
||||
if (!existing && nextInteractionMode === null) {
|
||||
return state;
|
||||
}
|
||||
const base = existing ?? createEmptyThreadDraft();
|
||||
if (base.interactionMode === nextInteractionMode) {
|
||||
return state;
|
||||
}
|
||||
const nextDraft: ComposerThreadDraftState = {
|
||||
...base,
|
||||
interactionMode: nextInteractionMode,
|
||||
};
|
||||
const nextDraftsByThreadId = { ...state.draftsByThreadId };
|
||||
if (shouldRemoveDraft(nextDraft)) {
|
||||
delete nextDraftsByThreadId[threadId];
|
||||
} else {
|
||||
nextDraftsByThreadId[threadId] = nextDraft;
|
||||
}
|
||||
return { draftsByThreadId: nextDraftsByThreadId };
|
||||
});
|
||||
},
|
||||
setEffort: (threadId, effort) => {
|
||||
if (threadId.length === 0) {
|
||||
return;
|
||||
}
|
||||
const nextEffort =
|
||||
effort && REASONING_EFFORT_VALUES.has(effort) && effort !== DEFAULT_REASONING
|
||||
effort &&
|
||||
REASONING_EFFORT_VALUES.has(effort) &&
|
||||
effort !== DEFAULT_REASONING_EFFORT_BY_PROVIDER.codex
|
||||
? effort
|
||||
: null;
|
||||
set((state) => {
|
||||
@@ -731,6 +920,33 @@ export const useComposerDraftStore = create<ComposerDraftStoreState>()(
|
||||
return { draftsByThreadId: nextDraftsByThreadId };
|
||||
});
|
||||
},
|
||||
setCodexFastMode: (threadId, enabled) => {
|
||||
if (threadId.length === 0) {
|
||||
return;
|
||||
}
|
||||
const nextCodexFastMode = enabled === true;
|
||||
set((state) => {
|
||||
const existing = state.draftsByThreadId[threadId];
|
||||
if (!existing && nextCodexFastMode === false) {
|
||||
return state;
|
||||
}
|
||||
const base = existing ?? createEmptyThreadDraft();
|
||||
if (base.codexFastMode === nextCodexFastMode) {
|
||||
return state;
|
||||
}
|
||||
const nextDraft: ComposerThreadDraftState = {
|
||||
...base,
|
||||
codexFastMode: nextCodexFastMode,
|
||||
};
|
||||
const nextDraftsByThreadId = { ...state.draftsByThreadId };
|
||||
if (shouldRemoveDraft(nextDraft)) {
|
||||
delete nextDraftsByThreadId[threadId];
|
||||
} else {
|
||||
nextDraftsByThreadId[threadId] = nextDraft;
|
||||
}
|
||||
return { draftsByThreadId: nextDraftsByThreadId };
|
||||
});
|
||||
},
|
||||
addImage: (threadId, image) => {
|
||||
if (threadId.length === 0) {
|
||||
return;
|
||||
@@ -963,8 +1179,12 @@ export const useComposerDraftStore = create<ComposerDraftStoreState>()(
|
||||
if (
|
||||
draft.prompt.length === 0 &&
|
||||
draft.persistedAttachments.length === 0 &&
|
||||
draft.provider === null &&
|
||||
draft.model === null &&
|
||||
draft.effort === null
|
||||
draft.runtimeMode === null &&
|
||||
draft.interactionMode === null &&
|
||||
draft.effort === null &&
|
||||
draft.codexFastMode === false
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
@@ -975,9 +1195,21 @@ export const useComposerDraftStore = create<ComposerDraftStoreState>()(
|
||||
if (draft.model) {
|
||||
persistedDraft.model = draft.model;
|
||||
}
|
||||
if (draft.provider) {
|
||||
persistedDraft.provider = draft.provider;
|
||||
}
|
||||
if (draft.runtimeMode) {
|
||||
persistedDraft.runtimeMode = draft.runtimeMode;
|
||||
}
|
||||
if (draft.interactionMode) {
|
||||
persistedDraft.interactionMode = draft.interactionMode;
|
||||
}
|
||||
if (draft.effort) {
|
||||
persistedDraft.effort = draft.effort;
|
||||
}
|
||||
if (draft.codexFastMode) {
|
||||
persistedDraft.codexFastMode = true;
|
||||
}
|
||||
persistedDraftsByThreadId[threadId as ThreadId] = persistedDraft;
|
||||
}
|
||||
return {
|
||||
|
||||
@@ -0,0 +1,192 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
buildPendingUserInputAnswers,
|
||||
countAnsweredPendingUserInputQuestions,
|
||||
derivePendingUserInputProgress,
|
||||
findFirstUnansweredPendingUserInputQuestionIndex,
|
||||
resolvePendingUserInputAnswer,
|
||||
setPendingUserInputCustomAnswer,
|
||||
} from "./pendingUserInput";
|
||||
|
||||
describe("resolvePendingUserInputAnswer", () => {
|
||||
it("prefers a custom answer over a selected option", () => {
|
||||
expect(
|
||||
resolvePendingUserInputAnswer({
|
||||
selectedOptionLabel: "Keep current envelope",
|
||||
customAnswer: "Keep the existing envelope for one release",
|
||||
}),
|
||||
).toBe("Keep the existing envelope for one release");
|
||||
});
|
||||
|
||||
it("falls back to the selected option", () => {
|
||||
expect(
|
||||
resolvePendingUserInputAnswer({
|
||||
selectedOptionLabel: "Scaffold only",
|
||||
}),
|
||||
).toBe("Scaffold only");
|
||||
});
|
||||
|
||||
it("clears the preset selection when a custom answer is entered", () => {
|
||||
expect(
|
||||
setPendingUserInputCustomAnswer(
|
||||
{
|
||||
selectedOptionLabel: "Preserve existing tags",
|
||||
},
|
||||
"doesn't matter",
|
||||
),
|
||||
).toEqual({
|
||||
selectedOptionLabel: undefined,
|
||||
customAnswer: "doesn't matter",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildPendingUserInputAnswers", () => {
|
||||
it("returns a canonical answer map for complete prompts", () => {
|
||||
expect(
|
||||
buildPendingUserInputAnswers(
|
||||
[
|
||||
{
|
||||
id: "scope",
|
||||
header: "Scope",
|
||||
question: "What should the plan target first?",
|
||||
options: [
|
||||
{
|
||||
label: "Orchestration-first",
|
||||
description: "Focus on orchestration first",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "compat",
|
||||
header: "Compat",
|
||||
question: "How strict should compatibility be?",
|
||||
options: [
|
||||
{
|
||||
label: "Keep current envelope",
|
||||
description: "Preserve current wire format",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
{
|
||||
scope: {
|
||||
selectedOptionLabel: "Orchestration-first",
|
||||
},
|
||||
compat: {
|
||||
customAnswer: "Keep the current envelope for one release window",
|
||||
},
|
||||
},
|
||||
),
|
||||
).toEqual({
|
||||
scope: "Orchestration-first",
|
||||
compat: "Keep the current envelope for one release window",
|
||||
});
|
||||
});
|
||||
|
||||
it("returns null when any question is unanswered", () => {
|
||||
expect(
|
||||
buildPendingUserInputAnswers(
|
||||
[
|
||||
{
|
||||
id: "scope",
|
||||
header: "Scope",
|
||||
question: "What should the plan target first?",
|
||||
options: [
|
||||
{
|
||||
label: "Orchestration-first",
|
||||
description: "Focus on orchestration first",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
{},
|
||||
),
|
||||
).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("pending user input question progress", () => {
|
||||
const questions = [
|
||||
{
|
||||
id: "scope",
|
||||
header: "Scope",
|
||||
question: "What should the plan target first?",
|
||||
options: [
|
||||
{
|
||||
label: "Orchestration-first",
|
||||
description: "Focus on orchestration first",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "compat",
|
||||
header: "Compat",
|
||||
question: "How strict should compatibility be?",
|
||||
options: [
|
||||
{
|
||||
label: "Keep current envelope",
|
||||
description: "Preserve current wire format",
|
||||
},
|
||||
],
|
||||
},
|
||||
] as const;
|
||||
|
||||
it("counts only answered questions", () => {
|
||||
expect(
|
||||
countAnsweredPendingUserInputQuestions(questions, {
|
||||
scope: {
|
||||
selectedOptionLabel: "Orchestration-first",
|
||||
},
|
||||
}),
|
||||
).toBe(1);
|
||||
});
|
||||
|
||||
it("finds the first unanswered question", () => {
|
||||
expect(
|
||||
findFirstUnansweredPendingUserInputQuestionIndex(questions, {
|
||||
scope: {
|
||||
selectedOptionLabel: "Orchestration-first",
|
||||
},
|
||||
}),
|
||||
).toBe(1);
|
||||
});
|
||||
|
||||
it("returns the last question index when all answers are complete", () => {
|
||||
expect(
|
||||
findFirstUnansweredPendingUserInputQuestionIndex(questions, {
|
||||
scope: {
|
||||
selectedOptionLabel: "Orchestration-first",
|
||||
},
|
||||
compat: {
|
||||
customAnswer: "Keep it for one release window",
|
||||
},
|
||||
}),
|
||||
).toBe(1);
|
||||
});
|
||||
|
||||
it("derives the active question and advancement state", () => {
|
||||
expect(
|
||||
derivePendingUserInputProgress(
|
||||
questions,
|
||||
{
|
||||
scope: {
|
||||
selectedOptionLabel: "Orchestration-first",
|
||||
},
|
||||
},
|
||||
0,
|
||||
),
|
||||
).toMatchObject({
|
||||
questionIndex: 0,
|
||||
activeQuestion: questions[0],
|
||||
selectedOptionLabel: "Orchestration-first",
|
||||
customAnswer: "",
|
||||
resolvedAnswer: "Orchestration-first",
|
||||
answeredQuestionCount: 1,
|
||||
isLastQuestion: false,
|
||||
isComplete: false,
|
||||
canAdvance: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,122 @@
|
||||
import type { UserInputQuestion } from "@t3tools/contracts";
|
||||
|
||||
export interface PendingUserInputDraftAnswer {
|
||||
selectedOptionLabel?: string;
|
||||
customAnswer?: string;
|
||||
}
|
||||
|
||||
export interface PendingUserInputProgress {
|
||||
questionIndex: number;
|
||||
activeQuestion: UserInputQuestion | null;
|
||||
activeDraft: PendingUserInputDraftAnswer | undefined;
|
||||
selectedOptionLabel: string | undefined;
|
||||
customAnswer: string;
|
||||
resolvedAnswer: string | null;
|
||||
usingCustomAnswer: boolean;
|
||||
answeredQuestionCount: number;
|
||||
isLastQuestion: boolean;
|
||||
isComplete: boolean;
|
||||
canAdvance: boolean;
|
||||
}
|
||||
|
||||
function normalizeDraftAnswer(value: string | undefined): string | null {
|
||||
if (typeof value !== "string") {
|
||||
return null;
|
||||
}
|
||||
|
||||
const trimmed = value.trim();
|
||||
return trimmed.length > 0 ? trimmed : null;
|
||||
}
|
||||
|
||||
export function resolvePendingUserInputAnswer(
|
||||
draft: PendingUserInputDraftAnswer | undefined,
|
||||
): string | null {
|
||||
const customAnswer = normalizeDraftAnswer(draft?.customAnswer);
|
||||
if (customAnswer) {
|
||||
return customAnswer;
|
||||
}
|
||||
|
||||
return normalizeDraftAnswer(draft?.selectedOptionLabel);
|
||||
}
|
||||
|
||||
export function setPendingUserInputCustomAnswer(
|
||||
draft: PendingUserInputDraftAnswer | undefined,
|
||||
customAnswer: string,
|
||||
): PendingUserInputDraftAnswer {
|
||||
const selectedOptionLabel =
|
||||
customAnswer.trim().length > 0 ? undefined : draft?.selectedOptionLabel;
|
||||
|
||||
return {
|
||||
customAnswer,
|
||||
...(selectedOptionLabel ? { selectedOptionLabel } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
export function buildPendingUserInputAnswers(
|
||||
questions: ReadonlyArray<UserInputQuestion>,
|
||||
draftAnswers: Record<string, PendingUserInputDraftAnswer>,
|
||||
): Record<string, string> | null {
|
||||
const answers: Record<string, string> = {};
|
||||
|
||||
for (const question of questions) {
|
||||
const answer = resolvePendingUserInputAnswer(draftAnswers[question.id]);
|
||||
if (!answer) {
|
||||
return null;
|
||||
}
|
||||
answers[question.id] = answer;
|
||||
}
|
||||
|
||||
return answers;
|
||||
}
|
||||
|
||||
export function countAnsweredPendingUserInputQuestions(
|
||||
questions: ReadonlyArray<UserInputQuestion>,
|
||||
draftAnswers: Record<string, PendingUserInputDraftAnswer>,
|
||||
): number {
|
||||
return questions.reduce((count, question) => {
|
||||
return resolvePendingUserInputAnswer(draftAnswers[question.id]) ? count + 1 : count;
|
||||
}, 0);
|
||||
}
|
||||
|
||||
export function findFirstUnansweredPendingUserInputQuestionIndex(
|
||||
questions: ReadonlyArray<UserInputQuestion>,
|
||||
draftAnswers: Record<string, PendingUserInputDraftAnswer>,
|
||||
): number {
|
||||
const unansweredIndex = questions.findIndex(
|
||||
(question) => !resolvePendingUserInputAnswer(draftAnswers[question.id]),
|
||||
);
|
||||
|
||||
return unansweredIndex === -1 ? Math.max(questions.length - 1, 0) : unansweredIndex;
|
||||
}
|
||||
|
||||
export function derivePendingUserInputProgress(
|
||||
questions: ReadonlyArray<UserInputQuestion>,
|
||||
draftAnswers: Record<string, PendingUserInputDraftAnswer>,
|
||||
questionIndex: number,
|
||||
): PendingUserInputProgress {
|
||||
const normalizedQuestionIndex =
|
||||
questions.length === 0
|
||||
? 0
|
||||
: Math.max(0, Math.min(questionIndex, questions.length - 1));
|
||||
const activeQuestion = questions[normalizedQuestionIndex] ?? null;
|
||||
const activeDraft = activeQuestion ? draftAnswers[activeQuestion.id] : undefined;
|
||||
const resolvedAnswer = resolvePendingUserInputAnswer(activeDraft);
|
||||
const customAnswer = activeDraft?.customAnswer ?? "";
|
||||
const answeredQuestionCount = countAnsweredPendingUserInputQuestions(questions, draftAnswers);
|
||||
const isLastQuestion =
|
||||
questions.length === 0 ? true : normalizedQuestionIndex >= questions.length - 1;
|
||||
|
||||
return {
|
||||
questionIndex: normalizedQuestionIndex,
|
||||
activeQuestion,
|
||||
activeDraft,
|
||||
selectedOptionLabel: activeDraft?.selectedOptionLabel,
|
||||
customAnswer,
|
||||
resolvedAnswer,
|
||||
usingCustomAnswer: customAnswer.trim().length > 0,
|
||||
answeredQuestionCount,
|
||||
isLastQuestion,
|
||||
isComplete: buildPendingUserInputAnswers(questions, draftAnswers) !== null,
|
||||
canAdvance: Boolean(resolvedAnswer),
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
buildPlanImplementationThreadTitle,
|
||||
buildPlanImplementationPrompt,
|
||||
buildProposedPlanMarkdownFilename,
|
||||
proposedPlanTitle,
|
||||
} from "./proposedPlan";
|
||||
|
||||
describe("proposedPlanTitle", () => {
|
||||
it("reads the first markdown heading as the plan title", () => {
|
||||
expect(proposedPlanTitle("# Integrate RPC\n\nBody")).toBe("Integrate RPC");
|
||||
});
|
||||
|
||||
it("returns null when the plan has no heading", () => {
|
||||
expect(proposedPlanTitle("- step 1")).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildPlanImplementationPrompt", () => {
|
||||
it("formats the plan exactly like the Codex follow-up handoff prompt", () => {
|
||||
expect(buildPlanImplementationPrompt("## Ship it\n\n- step 1\n")).toBe(
|
||||
"PLEASE IMPLEMENT THIS PLAN:\n## Ship it\n\n- step 1",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildPlanImplementationThreadTitle", () => {
|
||||
it("uses the plan heading when building the implementation thread title", () => {
|
||||
expect(buildPlanImplementationThreadTitle("# Integrate RPC\n\nBody")).toBe(
|
||||
"Implement Integrate RPC",
|
||||
);
|
||||
});
|
||||
|
||||
it("falls back when the plan has no markdown heading", () => {
|
||||
expect(buildPlanImplementationThreadTitle("- step 1")).toBe("Implement plan");
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildProposedPlanMarkdownFilename", () => {
|
||||
it("derives a stable markdown filename from the plan heading", () => {
|
||||
expect(buildProposedPlanMarkdownFilename("# Integrate Effect RPC Into Server App")).toBe(
|
||||
"integrate-effect-rpc-into-server-app.md",
|
||||
);
|
||||
});
|
||||
|
||||
it("falls back to a generic filename when the plan has no heading", () => {
|
||||
expect(buildProposedPlanMarkdownFilename("- step 1")).toBe("plan.md");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,30 @@
|
||||
export function proposedPlanTitle(planMarkdown: string): string | null {
|
||||
const heading = planMarkdown.match(/^\s{0,3}#{1,6}\s+(.+)$/m)?.[1]?.trim();
|
||||
return heading && heading.length > 0 ? heading : null;
|
||||
}
|
||||
|
||||
function sanitizePlanFileSegment(input: string): string {
|
||||
const sanitized = input
|
||||
.toLowerCase()
|
||||
.replace(/[`'".,!?()[\]{}]+/g, "")
|
||||
.replace(/[^a-z0-9]+/g, "-")
|
||||
.replace(/^-+|-+$/g, "");
|
||||
return sanitized.length > 0 ? sanitized : "plan";
|
||||
}
|
||||
|
||||
export function buildPlanImplementationPrompt(planMarkdown: string): string {
|
||||
return `PLEASE IMPLEMENT THIS PLAN:\n${planMarkdown.trim()}`;
|
||||
}
|
||||
|
||||
export function buildPlanImplementationThreadTitle(planMarkdown: string): string {
|
||||
const title = proposedPlanTitle(planMarkdown);
|
||||
if (!title) {
|
||||
return "Implement plan";
|
||||
}
|
||||
return `Implement ${title}`;
|
||||
}
|
||||
|
||||
export function buildProposedPlanMarkdownFilename(planMarkdown: string): string {
|
||||
const title = proposedPlanTitle(planMarkdown);
|
||||
return `${sanitizePlanFileSegment(title ?? "plan")}.md`;
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useCallback, useState } from "react";
|
||||
import { MODEL_OPTIONS, normalizeModelSlug } from "@t3tools/contracts";
|
||||
import { type ProviderKind } from "@t3tools/contracts";
|
||||
import { getModelOptions, normalizeModelSlug } from "@t3tools/shared/model";
|
||||
|
||||
import { MAX_CUSTOM_MODEL_LENGTH, useAppSettings } from "../appSettings";
|
||||
import { isElectron } from "../env";
|
||||
import { useTheme } from "../hooks/useTheme";
|
||||
import { serverConfigQueryOptions } from "../lib/serverReactQuery";
|
||||
import { ensureNativeApi } from "../nativeApi";
|
||||
import { useStore } from "../store";
|
||||
import { preferredTerminalEditor } from "../terminal-links";
|
||||
import { Button } from "../components/ui/button";
|
||||
import { Input } from "../components/ui/input";
|
||||
@@ -33,33 +33,90 @@ const THEME_OPTIONS = [
|
||||
},
|
||||
] as const;
|
||||
|
||||
const RUNTIME_MODE_OPTIONS = [
|
||||
const MODEL_PROVIDER_SETTINGS: Array<{
|
||||
provider: ProviderKind;
|
||||
title: string;
|
||||
description: string;
|
||||
placeholder: string;
|
||||
example: string;
|
||||
}> = [
|
||||
{
|
||||
value: "full-access",
|
||||
label: "Full access",
|
||||
description: "Allow commands to run without confirmation prompts.",
|
||||
provider: "codex",
|
||||
title: "Codex",
|
||||
description: "Save additional Codex model slugs for the picker and `/model` command.",
|
||||
placeholder: "your-codex-model-slug",
|
||||
example: "gpt-6.7-codex-ultra-preview",
|
||||
},
|
||||
{
|
||||
value: "approval-required",
|
||||
label: "Supervised",
|
||||
description: "Require approval prompts before command execution.",
|
||||
provider: "cursor",
|
||||
title: "Cursor",
|
||||
description: "Save additional Cursor model slugs for the picker and `/model` command.",
|
||||
placeholder: "your-cursor-model-slug",
|
||||
example: "openai/gpt-oss-120b",
|
||||
},
|
||||
] as const;
|
||||
|
||||
function getCustomModelsForProvider(
|
||||
settings: ReturnType<typeof useAppSettings>["settings"],
|
||||
provider: ProviderKind,
|
||||
) {
|
||||
switch (provider) {
|
||||
case "claudeCode":
|
||||
return settings.customClaudeModels;
|
||||
case "cursor":
|
||||
return settings.customCursorModels;
|
||||
case "codex":
|
||||
default:
|
||||
return settings.customCodexModels;
|
||||
}
|
||||
}
|
||||
|
||||
function getDefaultCustomModelsForProvider(
|
||||
defaults: ReturnType<typeof useAppSettings>["defaults"],
|
||||
provider: ProviderKind,
|
||||
) {
|
||||
switch (provider) {
|
||||
case "claudeCode":
|
||||
return defaults.customClaudeModels;
|
||||
case "cursor":
|
||||
return defaults.customCursorModels;
|
||||
case "codex":
|
||||
default:
|
||||
return defaults.customCodexModels;
|
||||
}
|
||||
}
|
||||
|
||||
function patchCustomModels(provider: ProviderKind, models: string[]) {
|
||||
switch (provider) {
|
||||
case "claudeCode":
|
||||
return { customClaudeModels: models };
|
||||
case "cursor":
|
||||
return { customCursorModels: models };
|
||||
case "codex":
|
||||
default:
|
||||
return { customCodexModels: models };
|
||||
}
|
||||
}
|
||||
|
||||
function SettingsRouteView() {
|
||||
const { theme, setTheme, resolvedTheme } = useTheme();
|
||||
const runtimeMode = useStore((store) => store.runtimeMode);
|
||||
const setRuntimeMode = useStore((store) => store.setRuntimeMode);
|
||||
const { settings, defaults, updateSettings } = useAppSettings();
|
||||
const serverConfigQuery = useQuery(serverConfigQueryOptions());
|
||||
const [isOpeningKeybindings, setIsOpeningKeybindings] = useState(false);
|
||||
const [openKeybindingsError, setOpenKeybindingsError] = useState<string | null>(null);
|
||||
const [customModelInput, setCustomModelInput] = useState("");
|
||||
const [customModelError, setCustomModelError] = useState<string | null>(null);
|
||||
const [customModelInputByProvider, setCustomModelInputByProvider] = useState<
|
||||
Record<ProviderKind, string>
|
||||
>({
|
||||
codex: "",
|
||||
claudeCode: "",
|
||||
cursor: "",
|
||||
});
|
||||
const [customModelErrorByProvider, setCustomModelErrorByProvider] = useState<
|
||||
Partial<Record<ProviderKind, string | null>>
|
||||
>({});
|
||||
|
||||
const codexBinaryPath = settings.codexBinaryPath;
|
||||
const codexHomePath = settings.codexHomePath;
|
||||
const customCodexModels = settings.customCodexModels;
|
||||
const keybindingsConfigPath = serverConfigQuery.data?.keybindingsConfigPath ?? null;
|
||||
|
||||
const openKeybindingsFile = useCallback(() => {
|
||||
@@ -79,40 +136,60 @@ function SettingsRouteView() {
|
||||
});
|
||||
}, [keybindingsConfigPath]);
|
||||
|
||||
const addCustomModel = useCallback(() => {
|
||||
const normalized = normalizeModelSlug(customModelInput);
|
||||
const addCustomModel = useCallback((provider: ProviderKind) => {
|
||||
const customModelInput = customModelInputByProvider[provider];
|
||||
const customModels = getCustomModelsForProvider(settings, provider);
|
||||
const normalized = normalizeModelSlug(customModelInput, provider);
|
||||
if (!normalized) {
|
||||
setCustomModelError("Enter a model slug.");
|
||||
setCustomModelErrorByProvider((existing) => ({
|
||||
...existing,
|
||||
[provider]: "Enter a model slug.",
|
||||
}));
|
||||
return;
|
||||
}
|
||||
if (MODEL_OPTIONS.some((option) => option.slug === normalized)) {
|
||||
setCustomModelError("That model is already built in.");
|
||||
if (getModelOptions(provider).some((option) => option.slug === normalized)) {
|
||||
setCustomModelErrorByProvider((existing) => ({
|
||||
...existing,
|
||||
[provider]: "That model is already built in.",
|
||||
}));
|
||||
return;
|
||||
}
|
||||
if (normalized.length > MAX_CUSTOM_MODEL_LENGTH) {
|
||||
setCustomModelError(`Model slugs must be ${MAX_CUSTOM_MODEL_LENGTH} characters or less.`);
|
||||
setCustomModelErrorByProvider((existing) => ({
|
||||
...existing,
|
||||
[provider]: `Model slugs must be ${MAX_CUSTOM_MODEL_LENGTH} characters or less.`,
|
||||
}));
|
||||
return;
|
||||
}
|
||||
if (customCodexModels.includes(normalized)) {
|
||||
setCustomModelError("That custom model is already saved.");
|
||||
if (customModels.includes(normalized)) {
|
||||
setCustomModelErrorByProvider((existing) => ({
|
||||
...existing,
|
||||
[provider]: "That custom model is already saved.",
|
||||
}));
|
||||
return;
|
||||
}
|
||||
|
||||
updateSettings({
|
||||
customCodexModels: [...customCodexModels, normalized],
|
||||
});
|
||||
setCustomModelInput("");
|
||||
setCustomModelError(null);
|
||||
}, [customCodexModels, customModelInput, updateSettings]);
|
||||
updateSettings(patchCustomModels(provider, [...customModels, normalized]));
|
||||
setCustomModelInputByProvider((existing) => ({
|
||||
...existing,
|
||||
[provider]: "",
|
||||
}));
|
||||
setCustomModelErrorByProvider((existing) => ({
|
||||
...existing,
|
||||
[provider]: null,
|
||||
}));
|
||||
}, [customModelInputByProvider, settings, updateSettings]);
|
||||
|
||||
const removeCustomModel = useCallback(
|
||||
(slug: string) => {
|
||||
updateSettings({
|
||||
customCodexModels: customCodexModels.filter((model) => model !== slug),
|
||||
});
|
||||
setCustomModelError(null);
|
||||
(provider: ProviderKind, slug: string) => {
|
||||
const customModels = getCustomModelsForProvider(settings, provider);
|
||||
updateSettings(patchCustomModels(provider, customModels.filter((model) => model !== slug)));
|
||||
setCustomModelErrorByProvider((existing) => ({
|
||||
...existing,
|
||||
[provider]: null,
|
||||
}));
|
||||
},
|
||||
[customCodexModels, updateSettings],
|
||||
[settings, updateSettings],
|
||||
);
|
||||
|
||||
return (
|
||||
@@ -240,128 +317,131 @@ function SettingsRouteView() {
|
||||
<div className="mb-4">
|
||||
<h2 className="text-sm font-medium text-foreground">Models</h2>
|
||||
<p className="mt-1 text-xs text-muted-foreground">
|
||||
Save additional Codex model slugs so they appear in the chat model picker.
|
||||
Save additional provider model slugs so they appear in the chat model picker and
|
||||
`/model` command suggestions.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="space-y-4">
|
||||
<div className="flex flex-col gap-3 sm:flex-row sm:items-start">
|
||||
<label htmlFor="custom-model-slug" className="block flex-1 space-y-1">
|
||||
<span className="text-xs font-medium text-foreground">Custom model slug</span>
|
||||
<Input
|
||||
id="custom-model-slug"
|
||||
value={customModelInput}
|
||||
onChange={(event) => {
|
||||
setCustomModelInput(event.target.value);
|
||||
if (customModelError) {
|
||||
setCustomModelError(null);
|
||||
}
|
||||
}}
|
||||
onKeyDown={(event) => {
|
||||
if (event.key !== "Enter") return;
|
||||
event.preventDefault();
|
||||
addCustomModel();
|
||||
}}
|
||||
placeholder="your-model-slug"
|
||||
spellCheck={false}
|
||||
/>
|
||||
<span className="text-xs text-muted-foreground">
|
||||
Example: <code>gpt-6.7-codex-ultra-preview</code>
|
||||
</span>
|
||||
</label>
|
||||
<div className="space-y-5">
|
||||
{MODEL_PROVIDER_SETTINGS.map((providerSettings) => {
|
||||
const provider = providerSettings.provider;
|
||||
const customModels = getCustomModelsForProvider(settings, provider);
|
||||
const customModelInput = customModelInputByProvider[provider];
|
||||
const customModelError = customModelErrorByProvider[provider] ?? null;
|
||||
return (
|
||||
<div
|
||||
key={provider}
|
||||
className="rounded-xl border border-border bg-background/50 p-4"
|
||||
>
|
||||
<div className="mb-4">
|
||||
<h3 className="text-sm font-medium text-foreground">
|
||||
{providerSettings.title}
|
||||
</h3>
|
||||
<p className="mt-1 text-xs text-muted-foreground">
|
||||
{providerSettings.description}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<Button className="sm:mt-6" type="button" onClick={addCustomModel}>
|
||||
Add model
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{customModelError ? (
|
||||
<p className="text-xs text-destructive">{customModelError}</p>
|
||||
) : null}
|
||||
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center justify-between gap-2 text-xs text-muted-foreground">
|
||||
<p>Saved custom models: {customCodexModels.length}</p>
|
||||
{customCodexModels.length > 0 ? (
|
||||
<Button
|
||||
size="xs"
|
||||
variant="outline"
|
||||
onClick={() =>
|
||||
updateSettings({
|
||||
customCodexModels: defaults.customCodexModels,
|
||||
})
|
||||
}
|
||||
>
|
||||
Reset custom models
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
{customCodexModels.length > 0 ? (
|
||||
<div className="space-y-2">
|
||||
{customCodexModels.map((slug) => (
|
||||
<div
|
||||
key={slug}
|
||||
className="flex items-center justify-between gap-3 rounded-lg border border-border bg-background px-3 py-2"
|
||||
>
|
||||
<code className="min-w-0 flex-1 truncate text-xs text-foreground">
|
||||
{slug}
|
||||
</code>
|
||||
<Button
|
||||
size="xs"
|
||||
variant="ghost"
|
||||
onClick={() => removeCustomModel(slug)}
|
||||
<div className="space-y-4">
|
||||
<div className="flex flex-col gap-3 sm:flex-row sm:items-start">
|
||||
<label
|
||||
htmlFor={`custom-model-slug-${provider}`}
|
||||
className="block flex-1 space-y-1"
|
||||
>
|
||||
Remove
|
||||
<span className="text-xs font-medium text-foreground">
|
||||
Custom model slug
|
||||
</span>
|
||||
<Input
|
||||
id={`custom-model-slug-${provider}`}
|
||||
value={customModelInput}
|
||||
onChange={(event) => {
|
||||
const value = event.target.value;
|
||||
setCustomModelInputByProvider((existing) => ({
|
||||
...existing,
|
||||
[provider]: value,
|
||||
}));
|
||||
if (customModelError) {
|
||||
setCustomModelErrorByProvider((existing) => ({
|
||||
...existing,
|
||||
[provider]: null,
|
||||
}));
|
||||
}
|
||||
}}
|
||||
onKeyDown={(event) => {
|
||||
if (event.key !== "Enter") return;
|
||||
event.preventDefault();
|
||||
addCustomModel(provider);
|
||||
}}
|
||||
placeholder={providerSettings.placeholder}
|
||||
spellCheck={false}
|
||||
/>
|
||||
<span className="text-xs text-muted-foreground">
|
||||
Example: <code>{providerSettings.example}</code>
|
||||
</span>
|
||||
</label>
|
||||
|
||||
<Button
|
||||
className="sm:mt-6"
|
||||
type="button"
|
||||
onClick={() => addCustomModel(provider)}
|
||||
>
|
||||
Add model
|
||||
</Button>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<div className="rounded-lg border border-dashed border-border bg-background px-3 py-4 text-xs text-muted-foreground">
|
||||
No custom models saved yet.
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="rounded-2xl border border-border bg-card p-5">
|
||||
<div className="mb-4">
|
||||
<h2 className="text-sm font-medium text-foreground">Runtime Mode</h2>
|
||||
<p className="mt-1 text-xs text-muted-foreground">
|
||||
Select the default execution policy for this client.
|
||||
</p>
|
||||
</div>
|
||||
{customModelError ? (
|
||||
<p className="text-xs text-destructive">{customModelError}</p>
|
||||
) : null}
|
||||
|
||||
<div className="space-y-2" role="radiogroup" aria-label="Runtime mode preference">
|
||||
{RUNTIME_MODE_OPTIONS.map((option) => {
|
||||
const selected = runtimeMode === option.value;
|
||||
return (
|
||||
<button
|
||||
key={option.value}
|
||||
type="button"
|
||||
role="radio"
|
||||
aria-checked={selected}
|
||||
className={`flex w-full items-start justify-between rounded-lg border px-3 py-2 text-left transition-colors ${
|
||||
selected
|
||||
? "border-primary/60 bg-primary/8 text-foreground"
|
||||
: "border-border bg-background text-muted-foreground hover:bg-accent"
|
||||
}`}
|
||||
onClick={() => {
|
||||
setRuntimeMode(option.value);
|
||||
}}
|
||||
>
|
||||
<span className="flex flex-col">
|
||||
<span className="text-sm font-medium">{option.label}</span>
|
||||
<span className="text-xs">{option.description}</span>
|
||||
</span>
|
||||
{selected ? (
|
||||
<span className="rounded bg-primary/14 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-primary">
|
||||
Selected
|
||||
</span>
|
||||
) : null}
|
||||
</button>
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center justify-between gap-2 text-xs text-muted-foreground">
|
||||
<p>Saved custom models: {customModels.length}</p>
|
||||
{customModels.length > 0 ? (
|
||||
<Button
|
||||
size="xs"
|
||||
variant="outline"
|
||||
onClick={() =>
|
||||
updateSettings(
|
||||
patchCustomModels(
|
||||
provider,
|
||||
[...getDefaultCustomModelsForProvider(defaults, provider)],
|
||||
),
|
||||
)
|
||||
}
|
||||
>
|
||||
Reset custom models
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
{customModels.length > 0 ? (
|
||||
<div className="space-y-2">
|
||||
{customModels.map((slug) => (
|
||||
<div
|
||||
key={`${provider}:${slug}`}
|
||||
className="flex items-center justify-between gap-3 rounded-lg border border-border bg-background px-3 py-2"
|
||||
>
|
||||
<code className="min-w-0 flex-1 truncate text-xs text-foreground">
|
||||
{slug}
|
||||
</code>
|
||||
<Button
|
||||
size="xs"
|
||||
variant="ghost"
|
||||
onClick={() => removeCustomModel(provider, slug)}
|
||||
>
|
||||
Remove
|
||||
</Button>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<div className="rounded-lg border border-dashed border-border bg-background px-3 py-4 text-xs text-muted-foreground">
|
||||
No custom models saved yet.
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
import { EventId, TurnId, type OrchestrationThreadActivity } from "@t3tools/contracts";
|
||||
import { EventId, MessageId, TurnId, type OrchestrationThreadActivity } from "@t3tools/contracts";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
deriveActivePlanState,
|
||||
PROVIDER_OPTIONS,
|
||||
derivePendingApprovals,
|
||||
derivePendingUserInputs,
|
||||
deriveTimelineEntries,
|
||||
deriveWorkLogEntries,
|
||||
findLatestProposedPlan,
|
||||
hasToolActivityForTurn,
|
||||
isLatestTurnSettled,
|
||||
} from "./session-logic";
|
||||
@@ -16,6 +21,7 @@ function makeActivity(overrides: {
|
||||
tone?: OrchestrationThreadActivity["tone"];
|
||||
payload?: Record<string, unknown>;
|
||||
turnId?: string;
|
||||
sequence?: number;
|
||||
}): OrchestrationThreadActivity {
|
||||
const payload = overrides.payload ?? {};
|
||||
return {
|
||||
@@ -26,6 +32,7 @@ function makeActivity(overrides: {
|
||||
tone: overrides.tone ?? "tool",
|
||||
payload,
|
||||
turnId: overrides.turnId ? TurnId.makeUnsafe(overrides.turnId) : null,
|
||||
...(overrides.sequence !== undefined ? { sequence: overrides.sequence } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -71,6 +78,248 @@ describe("derivePendingApprovals", () => {
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("maps canonical requestType payloads into pending approvals", () => {
|
||||
const activities: OrchestrationThreadActivity[] = [
|
||||
makeActivity({
|
||||
id: "approval-open-request-type",
|
||||
createdAt: "2026-02-23T00:00:01.000Z",
|
||||
kind: "approval.requested",
|
||||
summary: "Command approval requested",
|
||||
tone: "approval",
|
||||
payload: {
|
||||
requestId: "req-request-type",
|
||||
requestType: "command_execution_approval",
|
||||
detail: "pwd",
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
expect(derivePendingApprovals(activities)).toEqual([
|
||||
{
|
||||
requestId: "req-request-type",
|
||||
requestKind: "command",
|
||||
createdAt: "2026-02-23T00:00:01.000Z",
|
||||
detail: "pwd",
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("clears stale pending approvals when provider reports unknown pending request", () => {
|
||||
const activities: OrchestrationThreadActivity[] = [
|
||||
makeActivity({
|
||||
id: "approval-open-stale",
|
||||
createdAt: "2026-02-23T00:00:01.000Z",
|
||||
kind: "approval.requested",
|
||||
summary: "Command approval requested",
|
||||
tone: "approval",
|
||||
payload: {
|
||||
requestId: "req-stale-1",
|
||||
requestKind: "command",
|
||||
},
|
||||
}),
|
||||
makeActivity({
|
||||
id: "approval-failed-stale",
|
||||
createdAt: "2026-02-23T00:00:02.000Z",
|
||||
kind: "provider.approval.respond.failed",
|
||||
summary: "Provider approval response failed",
|
||||
tone: "error",
|
||||
payload: {
|
||||
requestId: "req-stale-1",
|
||||
detail: "Unknown pending permission request: req-stale-1",
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
expect(derivePendingApprovals(activities)).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("derivePendingUserInputs", () => {
|
||||
it("tracks open structured prompts and removes resolved ones", () => {
|
||||
const activities: OrchestrationThreadActivity[] = [
|
||||
makeActivity({
|
||||
id: "user-input-open",
|
||||
createdAt: "2026-02-23T00:00:01.000Z",
|
||||
kind: "user-input.requested",
|
||||
summary: "User input requested",
|
||||
tone: "info",
|
||||
payload: {
|
||||
requestId: "req-user-input-1",
|
||||
questions: [
|
||||
{
|
||||
id: "sandbox_mode",
|
||||
header: "Sandbox",
|
||||
question: "Which mode should be used?",
|
||||
options: [
|
||||
{
|
||||
label: "workspace-write",
|
||||
description: "Allow workspace writes only",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
makeActivity({
|
||||
id: "user-input-resolved",
|
||||
createdAt: "2026-02-23T00:00:02.000Z",
|
||||
kind: "user-input.resolved",
|
||||
summary: "User input submitted",
|
||||
tone: "info",
|
||||
payload: {
|
||||
requestId: "req-user-input-2",
|
||||
answers: {
|
||||
sandbox_mode: "workspace-write",
|
||||
},
|
||||
},
|
||||
}),
|
||||
makeActivity({
|
||||
id: "user-input-open-2",
|
||||
createdAt: "2026-02-23T00:00:01.500Z",
|
||||
kind: "user-input.requested",
|
||||
summary: "User input requested",
|
||||
tone: "info",
|
||||
payload: {
|
||||
requestId: "req-user-input-2",
|
||||
questions: [
|
||||
{
|
||||
id: "approval",
|
||||
header: "Approval",
|
||||
question: "Continue?",
|
||||
options: [
|
||||
{
|
||||
label: "yes",
|
||||
description: "Continue execution",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
expect(derivePendingUserInputs(activities)).toEqual([
|
||||
{
|
||||
requestId: "req-user-input-1",
|
||||
createdAt: "2026-02-23T00:00:01.000Z",
|
||||
questions: [
|
||||
{
|
||||
id: "sandbox_mode",
|
||||
header: "Sandbox",
|
||||
question: "Which mode should be used?",
|
||||
options: [
|
||||
{
|
||||
label: "workspace-write",
|
||||
description: "Allow workspace writes only",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("deriveActivePlanState", () => {
|
||||
it("returns the latest plan update for the active turn", () => {
|
||||
const activities: OrchestrationThreadActivity[] = [
|
||||
makeActivity({
|
||||
id: "plan-old",
|
||||
createdAt: "2026-02-23T00:00:01.000Z",
|
||||
kind: "turn.plan.updated",
|
||||
summary: "Plan updated",
|
||||
tone: "info",
|
||||
turnId: "turn-1",
|
||||
payload: {
|
||||
explanation: "Initial plan",
|
||||
plan: [{ step: "Inspect code", status: "pending" }],
|
||||
},
|
||||
}),
|
||||
makeActivity({
|
||||
id: "plan-latest",
|
||||
createdAt: "2026-02-23T00:00:02.000Z",
|
||||
kind: "turn.plan.updated",
|
||||
summary: "Plan updated",
|
||||
tone: "info",
|
||||
turnId: "turn-1",
|
||||
payload: {
|
||||
explanation: "Refined plan",
|
||||
plan: [{ step: "Implement Codex user input", status: "inProgress" }],
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
expect(deriveActivePlanState(activities, TurnId.makeUnsafe("turn-1"))).toEqual({
|
||||
createdAt: "2026-02-23T00:00:02.000Z",
|
||||
turnId: "turn-1",
|
||||
explanation: "Refined plan",
|
||||
steps: [{ step: "Implement Codex user input", status: "inProgress" }],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("findLatestProposedPlan", () => {
|
||||
it("prefers the latest proposed plan for the active turn", () => {
|
||||
expect(
|
||||
findLatestProposedPlan(
|
||||
[
|
||||
{
|
||||
id: "plan:thread-1:turn:turn-1",
|
||||
turnId: TurnId.makeUnsafe("turn-1"),
|
||||
planMarkdown: "# Older",
|
||||
createdAt: "2026-02-23T00:00:01.000Z",
|
||||
updatedAt: "2026-02-23T00:00:01.000Z",
|
||||
},
|
||||
{
|
||||
id: "plan:thread-1:turn:turn-1",
|
||||
turnId: TurnId.makeUnsafe("turn-1"),
|
||||
planMarkdown: "# Latest",
|
||||
createdAt: "2026-02-23T00:00:01.000Z",
|
||||
updatedAt: "2026-02-23T00:00:02.000Z",
|
||||
},
|
||||
{
|
||||
id: "plan:thread-1:turn:turn-2",
|
||||
turnId: TurnId.makeUnsafe("turn-2"),
|
||||
planMarkdown: "# Different turn",
|
||||
createdAt: "2026-02-23T00:00:03.000Z",
|
||||
updatedAt: "2026-02-23T00:00:03.000Z",
|
||||
},
|
||||
],
|
||||
TurnId.makeUnsafe("turn-1"),
|
||||
),
|
||||
).toEqual({
|
||||
id: "plan:thread-1:turn:turn-1",
|
||||
turnId: "turn-1",
|
||||
planMarkdown: "# Latest",
|
||||
createdAt: "2026-02-23T00:00:01.000Z",
|
||||
updatedAt: "2026-02-23T00:00:02.000Z",
|
||||
});
|
||||
});
|
||||
|
||||
it("falls back to the most recently updated proposed plan", () => {
|
||||
const latestPlan = findLatestProposedPlan(
|
||||
[
|
||||
{
|
||||
id: "plan:thread-1:turn:turn-1",
|
||||
turnId: TurnId.makeUnsafe("turn-1"),
|
||||
planMarkdown: "# First",
|
||||
createdAt: "2026-02-23T00:00:01.000Z",
|
||||
updatedAt: "2026-02-23T00:00:01.000Z",
|
||||
},
|
||||
{
|
||||
id: "plan:thread-1:turn:turn-2",
|
||||
turnId: TurnId.makeUnsafe("turn-2"),
|
||||
planMarkdown: "# Latest",
|
||||
createdAt: "2026-02-23T00:00:02.000Z",
|
||||
updatedAt: "2026-02-23T00:00:03.000Z",
|
||||
},
|
||||
],
|
||||
null,
|
||||
);
|
||||
|
||||
expect(latestPlan?.planMarkdown).toBe("# Latest");
|
||||
});
|
||||
});
|
||||
|
||||
describe("deriveWorkLogEntries", () => {
|
||||
@@ -130,6 +379,69 @@ describe("deriveWorkLogEntries", () => {
|
||||
const entries = deriveWorkLogEntries(activities, undefined);
|
||||
expect(entries.map((entry) => entry.id)).toEqual(["tool-complete"]);
|
||||
});
|
||||
|
||||
it("orders work log by activity sequence when present", () => {
|
||||
const activities: OrchestrationThreadActivity[] = [
|
||||
makeActivity({
|
||||
id: "second",
|
||||
createdAt: "2026-02-23T00:00:03.000Z",
|
||||
sequence: 2,
|
||||
summary: "Tool call complete",
|
||||
kind: "tool.completed",
|
||||
}),
|
||||
makeActivity({
|
||||
id: "first",
|
||||
createdAt: "2026-02-23T00:00:04.000Z",
|
||||
sequence: 1,
|
||||
summary: "Tool call complete",
|
||||
kind: "tool.completed",
|
||||
}),
|
||||
];
|
||||
|
||||
const entries = deriveWorkLogEntries(activities, undefined);
|
||||
expect(entries.map((entry) => entry.id)).toEqual(["first", "second"]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("deriveTimelineEntries", () => {
|
||||
it("includes proposed plans alongside messages and work entries in chronological order", () => {
|
||||
const entries = deriveTimelineEntries(
|
||||
[
|
||||
{
|
||||
id: MessageId.makeUnsafe("message-1"),
|
||||
role: "assistant",
|
||||
text: "hello",
|
||||
createdAt: "2026-02-23T00:00:01.000Z",
|
||||
streaming: false,
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
id: "plan:thread-1:turn:turn-1",
|
||||
turnId: TurnId.makeUnsafe("turn-1"),
|
||||
planMarkdown: "# Ship it",
|
||||
createdAt: "2026-02-23T00:00:02.000Z",
|
||||
updatedAt: "2026-02-23T00:00:02.000Z",
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
id: "work-1",
|
||||
createdAt: "2026-02-23T00:00:03.000Z",
|
||||
label: "Ran tests",
|
||||
tone: "tool",
|
||||
},
|
||||
],
|
||||
);
|
||||
|
||||
expect(entries.map((entry) => entry.kind)).toEqual(["message", "proposed-plan", "work"]);
|
||||
expect(entries[1]).toMatchObject({
|
||||
kind: "proposed-plan",
|
||||
proposedPlan: {
|
||||
planMarkdown: "# Ship it",
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("hasToolActivityForTurn", () => {
|
||||
@@ -200,3 +512,20 @@ describe("isLatestTurnSettled", () => {
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("PROVIDER_OPTIONS", () => {
|
||||
it("advertises codex and cursor on the cursor branch while keeping Claude Code as coming soon", () => {
|
||||
const claude = PROVIDER_OPTIONS.find((option) => option.value === "claudeCode");
|
||||
const cursor = PROVIDER_OPTIONS.find((option) => option.value === "cursor");
|
||||
expect(claude).toEqual({
|
||||
value: "claudeCode",
|
||||
label: "Claude Code",
|
||||
available: false,
|
||||
});
|
||||
expect(cursor).toEqual({
|
||||
value: "cursor",
|
||||
label: "Cursor Agent",
|
||||
available: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
+293
-13
@@ -2,19 +2,24 @@ import {
|
||||
ApprovalRequestId,
|
||||
type OrchestrationLatestTurn,
|
||||
type OrchestrationThreadActivity,
|
||||
type OrchestrationProposedPlanId,
|
||||
type ProviderKind,
|
||||
type UserInputQuestion,
|
||||
type TurnId,
|
||||
} from "@t3tools/contracts";
|
||||
|
||||
import type { ChatMessage, SessionPhase, ThreadSession, TurnDiffSummary } from "./types";
|
||||
import type { ChatMessage, ProposedPlan, SessionPhase, ThreadSession, TurnDiffSummary } from "./types";
|
||||
|
||||
export type ProviderPickerKind = ProviderKind | "claudeCode" | "cursor";
|
||||
|
||||
export const PROVIDER_OPTIONS: Array<{
|
||||
value: ProviderKind;
|
||||
value: ProviderPickerKind;
|
||||
label: string;
|
||||
available: boolean;
|
||||
}> = [
|
||||
{ value: "codex", label: "Codex", available: true },
|
||||
{ value: "claudeCode", label: "Claude Code (soon)", available: false },
|
||||
{ value: "claudeCode", label: "Claude Code", available: false },
|
||||
{ value: "cursor", label: "Cursor Agent", available: true },
|
||||
];
|
||||
|
||||
export interface WorkLogEntry {
|
||||
@@ -27,11 +32,35 @@ export interface WorkLogEntry {
|
||||
|
||||
export interface PendingApproval {
|
||||
requestId: ApprovalRequestId;
|
||||
requestKind: "command" | "file-change";
|
||||
requestKind: "command" | "file-read" | "file-change";
|
||||
createdAt: string;
|
||||
detail?: string;
|
||||
}
|
||||
|
||||
export interface PendingUserInput {
|
||||
requestId: ApprovalRequestId;
|
||||
createdAt: string;
|
||||
questions: ReadonlyArray<UserInputQuestion>;
|
||||
}
|
||||
|
||||
export interface ActivePlanState {
|
||||
createdAt: string;
|
||||
turnId: TurnId | null;
|
||||
explanation?: string | null;
|
||||
steps: Array<{
|
||||
step: string;
|
||||
status: "pending" | "inProgress" | "completed";
|
||||
}>;
|
||||
}
|
||||
|
||||
export interface LatestProposedPlanState {
|
||||
id: OrchestrationProposedPlanId;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
turnId: TurnId | null;
|
||||
planMarkdown: string;
|
||||
}
|
||||
|
||||
export type TimelineEntry =
|
||||
| {
|
||||
id: string;
|
||||
@@ -39,6 +68,12 @@ export type TimelineEntry =
|
||||
createdAt: string;
|
||||
message: ChatMessage;
|
||||
}
|
||||
| {
|
||||
id: string;
|
||||
kind: "proposed-plan";
|
||||
createdAt: string;
|
||||
proposedPlan: ProposedPlan;
|
||||
}
|
||||
| {
|
||||
id: string;
|
||||
kind: "work";
|
||||
@@ -87,13 +122,28 @@ export function isLatestTurnSettled(
|
||||
return true;
|
||||
}
|
||||
|
||||
function requestKindFromRequestType(
|
||||
requestType: unknown,
|
||||
): PendingApproval["requestKind"] | null {
|
||||
switch (requestType) {
|
||||
case "command_execution_approval":
|
||||
case "exec_command_approval":
|
||||
return "command";
|
||||
case "file_read_approval":
|
||||
return "file-read";
|
||||
case "file_change_approval":
|
||||
case "apply_patch_approval":
|
||||
return "file-change";
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function derivePendingApprovals(
|
||||
activities: ReadonlyArray<OrchestrationThreadActivity>,
|
||||
): PendingApproval[] {
|
||||
const openByRequestId = new Map<ApprovalRequestId, PendingApproval>();
|
||||
const ordered = [...activities].toSorted((left, right) =>
|
||||
left.createdAt.localeCompare(right.createdAt),
|
||||
);
|
||||
const ordered = [...activities].toSorted(compareActivitiesByOrder);
|
||||
|
||||
for (const activity of ordered) {
|
||||
const payload =
|
||||
@@ -105,9 +155,14 @@ export function derivePendingApprovals(
|
||||
? ApprovalRequestId.makeUnsafe(payload.requestId)
|
||||
: null;
|
||||
const requestKind =
|
||||
payload && (payload.requestKind === "command" || payload.requestKind === "file-change")
|
||||
payload &&
|
||||
(payload.requestKind === "command" ||
|
||||
payload.requestKind === "file-read" ||
|
||||
payload.requestKind === "file-change")
|
||||
? payload.requestKind
|
||||
: null;
|
||||
: payload
|
||||
? requestKindFromRequestType(payload.requestType)
|
||||
: null;
|
||||
const detail = payload && typeof payload.detail === "string" ? payload.detail : undefined;
|
||||
|
||||
if (activity.kind === "approval.requested" && requestId && requestKind) {
|
||||
@@ -122,6 +177,16 @@ export function derivePendingApprovals(
|
||||
|
||||
if (activity.kind === "approval.resolved" && requestId) {
|
||||
openByRequestId.delete(requestId);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (
|
||||
activity.kind === "provider.approval.respond.failed" &&
|
||||
requestId &&
|
||||
detail?.includes("Unknown pending permission request")
|
||||
) {
|
||||
openByRequestId.delete(requestId);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,13 +195,202 @@ export function derivePendingApprovals(
|
||||
);
|
||||
}
|
||||
|
||||
function parseUserInputQuestions(
|
||||
payload: Record<string, unknown> | null,
|
||||
): ReadonlyArray<UserInputQuestion> | null {
|
||||
const questions = payload?.questions;
|
||||
if (!Array.isArray(questions)) {
|
||||
return null;
|
||||
}
|
||||
const parsed = questions
|
||||
.map<UserInputQuestion | null>((entry) => {
|
||||
if (!entry || typeof entry !== "object") return null;
|
||||
const question = entry as Record<string, unknown>;
|
||||
if (
|
||||
typeof question.id !== "string" ||
|
||||
typeof question.header !== "string" ||
|
||||
typeof question.question !== "string" ||
|
||||
!Array.isArray(question.options)
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
const options = question.options
|
||||
.map<UserInputQuestion["options"][number] | null>((option) => {
|
||||
if (!option || typeof option !== "object") return null;
|
||||
const optionRecord = option as Record<string, unknown>;
|
||||
if (
|
||||
typeof optionRecord.label !== "string" ||
|
||||
typeof optionRecord.description !== "string"
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
label: optionRecord.label,
|
||||
description: optionRecord.description,
|
||||
};
|
||||
})
|
||||
.filter((option): option is UserInputQuestion["options"][number] => option !== null);
|
||||
if (options.length === 0) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
id: question.id,
|
||||
header: question.header,
|
||||
question: question.question,
|
||||
options,
|
||||
};
|
||||
})
|
||||
.filter((question): question is UserInputQuestion => question !== null);
|
||||
return parsed.length > 0 ? parsed : null;
|
||||
}
|
||||
|
||||
export function derivePendingUserInputs(
|
||||
activities: ReadonlyArray<OrchestrationThreadActivity>,
|
||||
): PendingUserInput[] {
|
||||
const openByRequestId = new Map<ApprovalRequestId, PendingUserInput>();
|
||||
const ordered = [...activities].toSorted(compareActivitiesByOrder);
|
||||
|
||||
for (const activity of ordered) {
|
||||
const payload =
|
||||
activity.payload && typeof activity.payload === "object"
|
||||
? (activity.payload as Record<string, unknown>)
|
||||
: null;
|
||||
const requestId =
|
||||
payload && typeof payload.requestId === "string"
|
||||
? ApprovalRequestId.makeUnsafe(payload.requestId)
|
||||
: null;
|
||||
|
||||
if (activity.kind === "user-input.requested" && requestId) {
|
||||
const questions = parseUserInputQuestions(payload);
|
||||
if (!questions) {
|
||||
continue;
|
||||
}
|
||||
openByRequestId.set(requestId, {
|
||||
requestId,
|
||||
createdAt: activity.createdAt,
|
||||
questions,
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
if (activity.kind === "user-input.resolved" && requestId) {
|
||||
openByRequestId.delete(requestId);
|
||||
}
|
||||
}
|
||||
|
||||
return [...openByRequestId.values()].toSorted((left, right) =>
|
||||
left.createdAt.localeCompare(right.createdAt),
|
||||
);
|
||||
}
|
||||
|
||||
export function deriveActivePlanState(
|
||||
activities: ReadonlyArray<OrchestrationThreadActivity>,
|
||||
latestTurnId: TurnId | undefined,
|
||||
): ActivePlanState | null {
|
||||
const ordered = [...activities].toSorted(compareActivitiesByOrder);
|
||||
const candidates = ordered.filter((activity) => {
|
||||
if (activity.kind !== "turn.plan.updated") {
|
||||
return false;
|
||||
}
|
||||
if (!latestTurnId) {
|
||||
return true;
|
||||
}
|
||||
return activity.turnId === latestTurnId;
|
||||
});
|
||||
const latest = candidates.at(-1);
|
||||
if (!latest) {
|
||||
return null;
|
||||
}
|
||||
const payload =
|
||||
latest.payload && typeof latest.payload === "object"
|
||||
? (latest.payload as Record<string, unknown>)
|
||||
: null;
|
||||
const rawPlan = payload?.plan;
|
||||
if (!Array.isArray(rawPlan)) {
|
||||
return null;
|
||||
}
|
||||
const steps = rawPlan
|
||||
.map((entry) => {
|
||||
if (!entry || typeof entry !== "object") return null;
|
||||
const record = entry as Record<string, unknown>;
|
||||
if (typeof record.step !== "string") {
|
||||
return null;
|
||||
}
|
||||
const status =
|
||||
record.status === "completed" || record.status === "inProgress"
|
||||
? record.status
|
||||
: "pending";
|
||||
return {
|
||||
step: record.step,
|
||||
status,
|
||||
};
|
||||
})
|
||||
.filter(
|
||||
(
|
||||
step,
|
||||
): step is {
|
||||
step: string;
|
||||
status: "pending" | "inProgress" | "completed";
|
||||
} => step !== null,
|
||||
);
|
||||
if (steps.length === 0) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
createdAt: latest.createdAt,
|
||||
turnId: latest.turnId,
|
||||
...(payload && "explanation" in payload ? { explanation: payload.explanation as string | null } : {}),
|
||||
steps,
|
||||
};
|
||||
}
|
||||
|
||||
export function findLatestProposedPlan(
|
||||
proposedPlans: ReadonlyArray<ProposedPlan>,
|
||||
latestTurnId: TurnId | string | null | undefined,
|
||||
): LatestProposedPlanState | null {
|
||||
if (latestTurnId) {
|
||||
const matchingTurnPlan = [...proposedPlans]
|
||||
.filter((proposedPlan) => proposedPlan.turnId === latestTurnId)
|
||||
.toSorted(
|
||||
(left, right) =>
|
||||
left.updatedAt.localeCompare(right.updatedAt) || left.id.localeCompare(right.id),
|
||||
)
|
||||
.at(-1);
|
||||
if (matchingTurnPlan) {
|
||||
return {
|
||||
id: matchingTurnPlan.id,
|
||||
createdAt: matchingTurnPlan.createdAt,
|
||||
updatedAt: matchingTurnPlan.updatedAt,
|
||||
turnId: matchingTurnPlan.turnId,
|
||||
planMarkdown: matchingTurnPlan.planMarkdown,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const latestPlan = [...proposedPlans]
|
||||
.toSorted(
|
||||
(left, right) =>
|
||||
left.updatedAt.localeCompare(right.updatedAt) || left.id.localeCompare(right.id),
|
||||
)
|
||||
.at(-1);
|
||||
if (!latestPlan) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
id: latestPlan.id,
|
||||
createdAt: latestPlan.createdAt,
|
||||
updatedAt: latestPlan.updatedAt,
|
||||
turnId: latestPlan.turnId,
|
||||
planMarkdown: latestPlan.planMarkdown,
|
||||
};
|
||||
}
|
||||
|
||||
export function deriveWorkLogEntries(
|
||||
activities: ReadonlyArray<OrchestrationThreadActivity>,
|
||||
latestTurnId: TurnId | undefined,
|
||||
): WorkLogEntry[] {
|
||||
const ordered = [...activities].toSorted((left, right) =>
|
||||
left.createdAt.localeCompare(right.createdAt),
|
||||
);
|
||||
const ordered = [...activities].toSorted(compareActivitiesByOrder);
|
||||
return ordered
|
||||
.filter((activity) => (latestTurnId ? activity.turnId === latestTurnId : true))
|
||||
.filter((activity) => activity.kind !== "tool.started")
|
||||
@@ -159,6 +413,23 @@ export function deriveWorkLogEntries(
|
||||
});
|
||||
}
|
||||
|
||||
function compareActivitiesByOrder(
|
||||
left: OrchestrationThreadActivity,
|
||||
right: OrchestrationThreadActivity,
|
||||
): number {
|
||||
if (left.sequence !== undefined && right.sequence !== undefined) {
|
||||
if (left.sequence !== right.sequence) {
|
||||
return left.sequence - right.sequence;
|
||||
}
|
||||
} else if (left.sequence !== undefined) {
|
||||
return 1;
|
||||
} else if (right.sequence !== undefined) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return left.createdAt.localeCompare(right.createdAt) || left.id.localeCompare(right.id);
|
||||
}
|
||||
|
||||
export function hasToolActivityForTurn(
|
||||
activities: ReadonlyArray<OrchestrationThreadActivity>,
|
||||
turnId: TurnId | null | undefined,
|
||||
@@ -169,6 +440,7 @@ export function hasToolActivityForTurn(
|
||||
|
||||
export function deriveTimelineEntries(
|
||||
messages: ChatMessage[],
|
||||
proposedPlans: ProposedPlan[],
|
||||
workEntries: WorkLogEntry[],
|
||||
): TimelineEntry[] {
|
||||
const messageRows: TimelineEntry[] = messages.map((message) => ({
|
||||
@@ -177,13 +449,21 @@ export function deriveTimelineEntries(
|
||||
createdAt: message.createdAt,
|
||||
message,
|
||||
}));
|
||||
const proposedPlanRows: TimelineEntry[] = proposedPlans.map((proposedPlan) => ({
|
||||
id: proposedPlan.id,
|
||||
kind: "proposed-plan",
|
||||
createdAt: proposedPlan.createdAt,
|
||||
proposedPlan,
|
||||
}));
|
||||
const workRows: TimelineEntry[] = workEntries.map((entry) => ({
|
||||
id: entry.id,
|
||||
kind: "work",
|
||||
createdAt: entry.createdAt,
|
||||
entry,
|
||||
}));
|
||||
return [...messageRows, ...workRows].toSorted((a, b) => a.createdAt.localeCompare(b.createdAt));
|
||||
return [...messageRows, ...proposedPlanRows, ...workRows].toSorted((a, b) =>
|
||||
a.createdAt.localeCompare(b.createdAt),
|
||||
);
|
||||
}
|
||||
|
||||
export function inferCheckpointTurnCountByTurnId(
|
||||
|
||||
+109
-4
@@ -1,8 +1,8 @@
|
||||
import { ProjectId, ThreadId, TurnId } from "@t3tools/contracts";
|
||||
import { ProjectId, ThreadId, TurnId, type OrchestrationReadModel } from "@t3tools/contracts";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { markThreadUnread, type AppState } from "./store";
|
||||
import type { Thread } from "./types";
|
||||
import { markThreadUnread, syncServerReadModel, type AppState } from "./store";
|
||||
import { DEFAULT_INTERACTION_MODE, DEFAULT_RUNTIME_MODE, type Thread } from "./types";
|
||||
|
||||
function makeThread(overrides: Partial<Thread> = {}): Thread {
|
||||
return {
|
||||
@@ -11,10 +11,13 @@ function makeThread(overrides: Partial<Thread> = {}): Thread {
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Thread",
|
||||
model: "gpt-5-codex",
|
||||
runtimeMode: DEFAULT_RUNTIME_MODE,
|
||||
interactionMode: DEFAULT_INTERACTION_MODE,
|
||||
session: null,
|
||||
messages: [],
|
||||
turnDiffSummaries: [],
|
||||
activities: [],
|
||||
proposedPlans: [],
|
||||
error: null,
|
||||
createdAt: "2026-02-13T00:00:00.000Z",
|
||||
latestTurn: null,
|
||||
@@ -38,7 +41,49 @@ function makeState(thread: Thread): AppState {
|
||||
],
|
||||
threads: [thread],
|
||||
threadsHydrated: true,
|
||||
runtimeMode: "full-access",
|
||||
};
|
||||
}
|
||||
|
||||
function makeReadModelThread(overrides: Partial<OrchestrationReadModel["threads"][number]>) {
|
||||
return {
|
||||
id: ThreadId.makeUnsafe("thread-1"),
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Thread",
|
||||
model: "gpt-5.3-codex",
|
||||
runtimeMode: DEFAULT_RUNTIME_MODE,
|
||||
interactionMode: DEFAULT_INTERACTION_MODE,
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
latestTurn: null,
|
||||
createdAt: "2026-02-27T00:00:00.000Z",
|
||||
updatedAt: "2026-02-27T00:00:00.000Z",
|
||||
deletedAt: null,
|
||||
messages: [],
|
||||
activities: [],
|
||||
proposedPlans: [],
|
||||
checkpoints: [],
|
||||
session: null,
|
||||
...overrides,
|
||||
} satisfies OrchestrationReadModel["threads"][number];
|
||||
}
|
||||
|
||||
function makeReadModel(thread: OrchestrationReadModel["threads"][number]): OrchestrationReadModel {
|
||||
return {
|
||||
snapshotSequence: 1,
|
||||
updatedAt: "2026-02-27T00:00:00.000Z",
|
||||
projects: [
|
||||
{
|
||||
id: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Project",
|
||||
workspaceRoot: "/tmp/project",
|
||||
defaultModel: "gpt-5.3-codex",
|
||||
createdAt: "2026-02-27T00:00:00.000Z",
|
||||
updatedAt: "2026-02-27T00:00:00.000Z",
|
||||
deletedAt: null,
|
||||
scripts: [],
|
||||
},
|
||||
],
|
||||
threads: [thread],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -82,3 +127,63 @@ describe("store pure functions", () => {
|
||||
expect(next).toEqual(initialState);
|
||||
});
|
||||
});
|
||||
|
||||
describe("store read model sync", () => {
|
||||
it("preserves claude model slugs without an active session", () => {
|
||||
const initialState = makeState(makeThread());
|
||||
const readModel = makeReadModel(
|
||||
makeReadModelThread({
|
||||
model: "claude-opus-4-6",
|
||||
}),
|
||||
);
|
||||
|
||||
const next = syncServerReadModel(initialState, readModel);
|
||||
|
||||
expect(next.threads[0]?.model).toBe("claude-opus-4-6");
|
||||
});
|
||||
|
||||
it("resolves claude aliases when session provider is claudeCode", () => {
|
||||
const initialState = makeState(makeThread());
|
||||
const readModel = makeReadModel(
|
||||
makeReadModelThread({
|
||||
model: "sonnet",
|
||||
session: {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
status: "ready",
|
||||
providerName: "claudeCode",
|
||||
runtimeMode: "approval-required",
|
||||
activeTurnId: null,
|
||||
lastError: null,
|
||||
updatedAt: "2026-02-27T00:00:00.000Z",
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
const next = syncServerReadModel(initialState, readModel);
|
||||
|
||||
expect(next.threads[0]?.model).toBe("claude-sonnet-4-6");
|
||||
});
|
||||
|
||||
it("resolves cursor aliases when session provider is cursor", () => {
|
||||
const initialState = makeState(makeThread());
|
||||
const readModel = makeReadModel(
|
||||
makeReadModelThread({
|
||||
model: "composer",
|
||||
session: {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
status: "ready",
|
||||
providerName: "cursor",
|
||||
runtimeMode: "approval-required",
|
||||
activeTurnId: null,
|
||||
lastError: null,
|
||||
updatedAt: "2026-02-27T00:00:00.000Z",
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
const next = syncServerReadModel(initialState, readModel);
|
||||
|
||||
expect(next.threads[0]?.model).toBe("composer-1.5");
|
||||
expect(next.threads[0]?.session?.provider).toBe("cursor");
|
||||
});
|
||||
});
|
||||
+75
-36
@@ -1,18 +1,21 @@
|
||||
import { Fragment, type ReactNode, createElement, useEffect } from "react";
|
||||
import {
|
||||
DEFAULT_MODEL,
|
||||
ProviderSessionId,
|
||||
type ProviderKind,
|
||||
ThreadId,
|
||||
type OrchestrationReadModel,
|
||||
type OrchestrationSessionStatus,
|
||||
resolveModelSlug,
|
||||
} from "@t3tools/contracts";
|
||||
import {
|
||||
getModelOptions,
|
||||
normalizeModelSlug,
|
||||
resolveModelSlug,
|
||||
resolveModelSlugForProvider,
|
||||
} from "@t3tools/shared/model";
|
||||
import { create } from "zustand";
|
||||
import {
|
||||
DEFAULT_RUNTIME_MODE,
|
||||
type ChatMessage,
|
||||
type Project,
|
||||
type RuntimeMode,
|
||||
type Thread,
|
||||
} from "./types";
|
||||
|
||||
@@ -22,10 +25,9 @@ export interface AppState {
|
||||
projects: Project[];
|
||||
threads: Thread[];
|
||||
threadsHydrated: boolean;
|
||||
runtimeMode: RuntimeMode;
|
||||
}
|
||||
|
||||
const PERSISTED_STATE_KEY = "t3code:renderer-state:v7";
|
||||
const PERSISTED_STATE_KEY = "t3code:renderer-state:v8";
|
||||
const LEGACY_PERSISTED_STATE_KEYS = [
|
||||
"t3code:renderer-state:v6",
|
||||
"t3code:renderer-state:v5",
|
||||
@@ -41,7 +43,6 @@ const initialState: AppState = {
|
||||
projects: [],
|
||||
threads: [],
|
||||
threadsHydrated: false,
|
||||
runtimeMode: DEFAULT_RUNTIME_MODE,
|
||||
};
|
||||
const persistedExpandedProjectCwds = new Set<string>();
|
||||
|
||||
@@ -52,23 +53,14 @@ function readPersistedState(): AppState {
|
||||
try {
|
||||
const raw = window.localStorage.getItem(PERSISTED_STATE_KEY);
|
||||
if (!raw) return initialState;
|
||||
const parsed = JSON.parse(raw) as {
|
||||
runtimeMode?: RuntimeMode;
|
||||
expandedProjectCwds?: string[];
|
||||
};
|
||||
const parsed = JSON.parse(raw) as { expandedProjectCwds?: string[] };
|
||||
persistedExpandedProjectCwds.clear();
|
||||
for (const cwd of parsed.expandedProjectCwds ?? []) {
|
||||
if (typeof cwd === "string" && cwd.length > 0) {
|
||||
persistedExpandedProjectCwds.add(cwd);
|
||||
}
|
||||
}
|
||||
return {
|
||||
...initialState,
|
||||
runtimeMode:
|
||||
parsed.runtimeMode === "approval-required" || parsed.runtimeMode === "full-access"
|
||||
? parsed.runtimeMode
|
||||
: DEFAULT_RUNTIME_MODE,
|
||||
};
|
||||
return { ...initialState };
|
||||
} catch {
|
||||
return initialState;
|
||||
}
|
||||
@@ -80,7 +72,6 @@ function persistState(state: AppState): void {
|
||||
window.localStorage.setItem(
|
||||
PERSISTED_STATE_KEY,
|
||||
JSON.stringify({
|
||||
runtimeMode: state.runtimeMode,
|
||||
expandedProjectCwds: state.projects
|
||||
.filter((project) => project.expanded)
|
||||
.map((project) => project.cwd),
|
||||
@@ -153,8 +144,53 @@ function toLegacySessionStatus(
|
||||
}
|
||||
}
|
||||
|
||||
function toLegacyProvider(providerName: string | null): "codex" | "claudeCode" {
|
||||
return providerName === "claudeCode" ? "claudeCode" : "codex";
|
||||
function toLegacyProvider(providerName: string | null): ProviderKind {
|
||||
if (providerName === "codex" || providerName === "claudeCode" || providerName === "cursor") {
|
||||
return providerName;
|
||||
}
|
||||
return "codex";
|
||||
}
|
||||
|
||||
const CODEX_MODEL_SLUGS = new Set<string>(getModelOptions("codex").map((option) => option.slug));
|
||||
const CLAUDE_MODEL_SLUGS = new Set<string>(getModelOptions("claudeCode").map((option) => option.slug));
|
||||
const CURSOR_MODEL_SLUGS = new Set<string>(getModelOptions("cursor").map((option) => option.slug));
|
||||
const CURSOR_DISTINCT_MODEL_SLUGS = new Set(
|
||||
[...CURSOR_MODEL_SLUGS].filter(
|
||||
(slug) => !CODEX_MODEL_SLUGS.has(slug) && !CLAUDE_MODEL_SLUGS.has(slug),
|
||||
),
|
||||
);
|
||||
|
||||
function inferProviderForThreadModel(input: {
|
||||
readonly model: string;
|
||||
readonly sessionProviderName: string | null;
|
||||
}): ProviderKind {
|
||||
if (
|
||||
input.sessionProviderName === "codex" ||
|
||||
input.sessionProviderName === "claudeCode" ||
|
||||
input.sessionProviderName === "cursor"
|
||||
) {
|
||||
return input.sessionProviderName;
|
||||
}
|
||||
const normalizedCursor = normalizeModelSlug(input.model, "cursor");
|
||||
if (normalizedCursor && CURSOR_DISTINCT_MODEL_SLUGS.has(normalizedCursor)) {
|
||||
return "cursor";
|
||||
}
|
||||
const normalizedClaude = normalizeModelSlug(input.model, "claudeCode");
|
||||
if (normalizedClaude && CLAUDE_MODEL_SLUGS.has(normalizedClaude)) {
|
||||
return "claudeCode";
|
||||
}
|
||||
const normalizedCodex = normalizeModelSlug(input.model, "codex");
|
||||
if (normalizedCodex && CODEX_MODEL_SLUGS.has(normalizedCodex)) {
|
||||
return "codex";
|
||||
}
|
||||
if (
|
||||
input.model.trim().startsWith("composer-") ||
|
||||
input.model.trim().startsWith("gemini-") ||
|
||||
input.model.trim().endsWith("-thinking")
|
||||
) {
|
||||
return "cursor";
|
||||
}
|
||||
return input.model.trim().startsWith("claude-") ? "claudeCode" : "codex";
|
||||
}
|
||||
|
||||
function resolveWsHttpOrigin(): string {
|
||||
@@ -212,19 +248,23 @@ export function syncServerReadModel(
|
||||
const existing = existingThreadById.get(thread.id);
|
||||
return {
|
||||
id: thread.id,
|
||||
codexThreadId: thread.session?.providerThreadId ?? null,
|
||||
codexThreadId: null,
|
||||
projectId: thread.projectId,
|
||||
title: thread.title,
|
||||
model: resolveModelSlug(thread.model),
|
||||
model: resolveModelSlugForProvider(
|
||||
inferProviderForThreadModel({
|
||||
model: thread.model,
|
||||
sessionProviderName: thread.session?.providerName ?? null,
|
||||
}),
|
||||
thread.model,
|
||||
),
|
||||
runtimeMode: thread.runtimeMode,
|
||||
interactionMode: thread.interactionMode,
|
||||
session: thread.session
|
||||
? {
|
||||
sessionId:
|
||||
thread.session.providerSessionId ??
|
||||
ProviderSessionId.makeUnsafe(`thread:${thread.id}`),
|
||||
provider: toLegacyProvider(thread.session.providerName),
|
||||
status: toLegacySessionStatus(thread.session.status),
|
||||
orchestrationStatus: thread.session.status,
|
||||
threadId: thread.session.providerThreadId,
|
||||
activeTurnId: thread.session.activeTurnId ?? undefined,
|
||||
createdAt: thread.session.updatedAt,
|
||||
updatedAt: thread.session.updatedAt,
|
||||
@@ -251,6 +291,13 @@ export function syncServerReadModel(
|
||||
};
|
||||
return normalizedMessage;
|
||||
}),
|
||||
proposedPlans: thread.proposedPlans.map((proposedPlan) => ({
|
||||
id: proposedPlan.id,
|
||||
turnId: proposedPlan.turnId,
|
||||
planMarkdown: proposedPlan.planMarkdown,
|
||||
createdAt: proposedPlan.createdAt,
|
||||
updatedAt: proposedPlan.updatedAt,
|
||||
})),
|
||||
error: thread.session?.lastError ?? null,
|
||||
createdAt: thread.createdAt,
|
||||
latestTurn: thread.latestTurn,
|
||||
@@ -360,11 +407,6 @@ export function setThreadBranch(
|
||||
return threads === state.threads ? state : { ...state, threads };
|
||||
}
|
||||
|
||||
export function setRuntimeMode(state: AppState, mode: RuntimeMode): AppState {
|
||||
if (state.runtimeMode === mode) return state;
|
||||
return { ...state, runtimeMode: mode };
|
||||
}
|
||||
|
||||
// ── Zustand store ────────────────────────────────────────────────────
|
||||
|
||||
interface AppStore extends AppState {
|
||||
@@ -379,7 +421,6 @@ interface AppStore extends AppState {
|
||||
branch: string | null,
|
||||
worktreePath: string | null,
|
||||
) => void;
|
||||
setRuntimeMode: (mode: RuntimeMode) => void;
|
||||
}
|
||||
|
||||
export const useStore = create<AppStore>((set) => ({
|
||||
@@ -398,11 +439,9 @@ export const useStore = create<AppStore>((set) => ({
|
||||
set((state) => setError(state, threadId, error)),
|
||||
setThreadBranch: (threadId, branch, worktreePath) =>
|
||||
set((state) => setThreadBranch(state, threadId, branch, worktreePath)),
|
||||
setRuntimeMode: (mode) =>
|
||||
set((state) => setRuntimeMode(state, mode)),
|
||||
}));
|
||||
|
||||
// Persist on every state change (only runtimeMode + expandedProjectCwds)
|
||||
// Persist on every state change
|
||||
useStore.subscribe((state) => persistState(state));
|
||||
|
||||
export function StoreProvider({ children }: { children: ReactNode }) {
|
||||
|
||||
+17
-6
@@ -1,5 +1,6 @@
|
||||
import type {
|
||||
OrchestrationLatestTurn,
|
||||
OrchestrationProposedPlanId,
|
||||
OrchestrationSessionStatus,
|
||||
OrchestrationThreadActivity,
|
||||
ProjectScript as ContractProjectScript,
|
||||
@@ -8,14 +9,15 @@ import type {
|
||||
TurnId,
|
||||
MessageId,
|
||||
CheckpointRef,
|
||||
ProviderThreadId,
|
||||
ProviderSessionId,
|
||||
ProviderKind,
|
||||
ProviderInteractionMode,
|
||||
RuntimeMode,
|
||||
} from "@t3tools/contracts";
|
||||
|
||||
export type SessionPhase = "disconnected" | "connecting" | "ready" | "running";
|
||||
export type RuntimeMode = "approval-required" | "full-access";
|
||||
export const DEFAULT_RUNTIME_MODE: RuntimeMode = "full-access";
|
||||
|
||||
export const DEFAULT_INTERACTION_MODE: ProviderInteractionMode = "default";
|
||||
export const DEFAULT_THREAD_TERMINAL_HEIGHT = 280;
|
||||
export const DEFAULT_THREAD_TERMINAL_ID = "default";
|
||||
export const MAX_THREAD_TERMINAL_COUNT = 4;
|
||||
@@ -47,6 +49,14 @@ export interface ChatMessage {
|
||||
streaming: boolean;
|
||||
}
|
||||
|
||||
export interface ProposedPlan {
|
||||
id: OrchestrationProposedPlanId;
|
||||
turnId: TurnId | null;
|
||||
planMarkdown: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface TurnDiffFileChange {
|
||||
path: string;
|
||||
kind?: string | undefined;
|
||||
@@ -75,12 +85,15 @@ export interface Project {
|
||||
|
||||
export interface Thread {
|
||||
id: ThreadId;
|
||||
codexThreadId: ProviderThreadId | null;
|
||||
codexThreadId: string | null;
|
||||
projectId: ProjectId;
|
||||
title: string;
|
||||
model: string;
|
||||
runtimeMode: RuntimeMode;
|
||||
interactionMode: ProviderInteractionMode;
|
||||
session: ThreadSession | null;
|
||||
messages: ChatMessage[];
|
||||
proposedPlans: ProposedPlan[];
|
||||
error: string | null;
|
||||
createdAt: string;
|
||||
latestTurn: OrchestrationLatestTurn | null;
|
||||
@@ -92,10 +105,8 @@ export interface Thread {
|
||||
}
|
||||
|
||||
export interface ThreadSession {
|
||||
sessionId: ProviderSessionId;
|
||||
provider: ProviderKind;
|
||||
status: SessionPhase | "error" | "closed";
|
||||
threadId: ProviderThreadId | null;
|
||||
activeTurnId?: TurnId | undefined;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ProjectId, ThreadId } from "@t3tools/contracts";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import type { Thread } from "./types";
|
||||
import { DEFAULT_INTERACTION_MODE, DEFAULT_RUNTIME_MODE, type Thread } from "./types";
|
||||
import { formatWorktreePathForDisplay, getOrphanedWorktreePathForThread } from "./worktreeCleanup";
|
||||
|
||||
function makeThread(overrides: Partial<Thread> = {}): Thread {
|
||||
@@ -11,10 +11,13 @@ function makeThread(overrides: Partial<Thread> = {}): Thread {
|
||||
projectId: ProjectId.makeUnsafe("project-1"),
|
||||
title: "Thread",
|
||||
model: "gpt-5.3-codex",
|
||||
runtimeMode: DEFAULT_RUNTIME_MODE,
|
||||
interactionMode: DEFAULT_INTERACTION_MODE,
|
||||
session: null,
|
||||
messages: [],
|
||||
turnDiffSummaries: [],
|
||||
activities: [],
|
||||
proposedPlans: [],
|
||||
error: null,
|
||||
createdAt: "2026-02-13T00:00:00.000Z",
|
||||
latestTurn: null,
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
ProjectId,
|
||||
ThreadId,
|
||||
WS_CHANNELS,
|
||||
WS_METHODS,
|
||||
type ServerProviderStatus,
|
||||
} from "@t3tools/contracts";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
@@ -330,6 +331,24 @@ describe("wsNativeApi", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("forwards workspace file writes to the websocket project method", async () => {
|
||||
requestMock.mockResolvedValue({ relativePath: "plan.md" });
|
||||
const { createWsNativeApi } = await import("./wsNativeApi");
|
||||
|
||||
const api = createWsNativeApi();
|
||||
await api.projects.writeFile({
|
||||
cwd: "/tmp/project",
|
||||
relativePath: "plan.md",
|
||||
contents: "# Plan\n",
|
||||
});
|
||||
|
||||
expect(requestMock).toHaveBeenCalledWith(WS_METHODS.projectsWriteFile, {
|
||||
cwd: "/tmp/project",
|
||||
relativePath: "plan.md",
|
||||
contents: "# Plan\n",
|
||||
});
|
||||
});
|
||||
|
||||
it("forwards full-thread diff requests to the orchestration websocket method", async () => {
|
||||
requestMock.mockResolvedValue({ diff: "patch" });
|
||||
const { createWsNativeApi } = await import("./wsNativeApi");
|
||||
|
||||
@@ -141,6 +141,7 @@ export function createWsNativeApi(): NativeApi {
|
||||
},
|
||||
projects: {
|
||||
searchEntries: (input) => transport.request(WS_METHODS.projectsSearchEntries, input),
|
||||
writeFile: (input) => transport.request(WS_METHODS.projectsWriteFile, input),
|
||||
},
|
||||
shell: {
|
||||
openInEditor: (cwd, editor) =>
|
||||
|
||||
@@ -121,6 +121,7 @@
|
||||
"name": "@t3tools/shared",
|
||||
"version": "0.0.0-alpha.1",
|
||||
"dependencies": {
|
||||
"@t3tools/contracts": "workspace:*",
|
||||
"effect": "catalog:",
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -167,7 +168,7 @@
|
||||
|
||||
"@babel/core": ["@babel/[email protected]", "", { "dependencies": { "@babel/code-frame": "^7.29.0", "@babel/generator": "^7.29.0", "@babel/helper-compilation-targets": "^7.28.6", "@babel/helper-module-transforms": "^7.28.6", "@babel/helpers": "^7.28.6", "@babel/parser": "^7.29.0", "@babel/template": "^7.28.6", "@babel/traverse": "^7.29.0", "@babel/types": "^7.29.0", "@jridgewell/remapping": "^2.3.5", "convert-source-map": "^2.0.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", "json5": "^2.2.3", "semver": "^6.3.1" } }, "sha512-CGOfOJqWjg2qW/Mb6zNsDm+u5vFQ8DxXfbM09z69p5Z6+mE1ikP2jUXw+j42Pf1XTYED2Rni5f95npYeuwMDQA=="],
|
||||
|
||||
"@babel/generator": ["@babel/[email protected].1", "", { "dependencies": { "@babel/parser": "^8.0.0-rc.1", "@babel/types": "^8.0.0-rc.1", "@jridgewell/gen-mapping": "^0.3.12", "@jridgewell/trace-mapping": "^0.3.28", "@types/jsesc": "^2.5.0", "jsesc": "^3.0.2" } }, "sha512-3ypWOOiC4AYHKr8vYRVtWtWmyvcoItHtVqF8paFax+ydpmUdPsJpLBkBBs5ItmhdrwC3a0ZSqqFAdzls4ODP3w=="],
|
||||
"@babel/generator": ["@babel/[email protected].2", "", { "dependencies": { "@babel/parser": "^8.0.0-rc.2", "@babel/types": "^8.0.0-rc.2", "@jridgewell/gen-mapping": "^0.3.12", "@jridgewell/trace-mapping": "^0.3.28", "@types/jsesc": "^2.5.0", "jsesc": "^3.0.2" } }, "sha512-oCQ1IKPwkzCeJzAPb7Fv8rQ9k5+1sG8mf2uoHiMInPYvkRfrDJxbTIbH51U+jstlkghus0vAi3EBvkfvEsYNLQ=="],
|
||||
|
||||
"@babel/helper-compilation-targets": ["@babel/[email protected]", "", { "dependencies": { "@babel/compat-data": "^7.28.6", "@babel/helper-validator-option": "^7.27.1", "browserslist": "^4.24.0", "lru-cache": "^5.1.1", "semver": "^6.3.1" } }, "sha512-JYtls3hqi15fcx5GaSNL7SCTJ2MNmjrkHXg4FSpOA/grxK8KwyZ5bubHsCq8FXCkua6xhuaaBit+3b7+VZRfcA=="],
|
||||
|
||||
@@ -181,13 +182,13 @@
|
||||
|
||||
"@babel/helper-string-parser": ["@babel/[email protected]", "", {}, "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA=="],
|
||||
|
||||
"@babel/helper-validator-identifier": ["@babel/[email protected].1", "", {}, "sha512-I4YnARytXC2RzkLNVnf5qFNFMzp679qZpmtw/V3Jt2uGnWiIxyJtaukjG7R8pSx8nG2NamICpGfljQsogj+FbQ=="],
|
||||
"@babel/helper-validator-identifier": ["@babel/[email protected].2", "", {}, "sha512-xExUBkuXWJjVuIbO7z6q7/BA9bgfJDEhVL0ggrggLMbg0IzCUWGT1hZGE8qUH7Il7/RD/a6cZ3AAFrrlp1LF/A=="],
|
||||
|
||||
"@babel/helper-validator-option": ["@babel/[email protected]", "", {}, "sha512-YvjJow9FxbhFFKDSuFnVCe2WxXk1zWc22fFePVNEaWJEu8IrZVlda6N0uHwzZrUM1il7NC9Mlp4MaJYbYd9JSg=="],
|
||||
|
||||
"@babel/helpers": ["@babel/[email protected]", "", { "dependencies": { "@babel/template": "^7.28.6", "@babel/types": "^7.28.6" } }, "sha512-xOBvwq86HHdB7WUDTfKfT/Vuxh7gElQ+Sfti2Cy6yIWNW05P8iUslOVcZ4/sKbE+/jQaukQAdz/gf3724kYdqw=="],
|
||||
|
||||
"@babel/parser": ["@babel/[email protected].1", "", { "dependencies": { "@babel/types": "^8.0.0-rc.1" }, "bin": "./bin/babel-parser.js" }, "sha512-6HyyU5l1yK/7h9Ki52i5h6mDAx4qJdiLQO4FdCyJNoB/gy3T3GGJdhQzzbZgvgZCugYBvwtQiWRt94QKedHnkA=="],
|
||||
"@babel/parser": ["@babel/[email protected].2", "", { "dependencies": { "@babel/types": "^8.0.0-rc.2" }, "bin": "./bin/babel-parser.js" }, "sha512-29AhEtcq4x8Dp3T72qvUMZHx0OMXCj4Jy/TEReQa+KWLln524Cj1fWb3QFi0l/xSpptQBR6y9RNEXuxpFvwiUQ=="],
|
||||
|
||||
"@babel/plugin-syntax-jsx": ["@babel/[email protected]", "", { "dependencies": { "@babel/helper-plugin-utils": "^7.28.6" }, "peerDependencies": { "@babel/core": "^7.0.0-0" } }, "sha512-wgEmr06G6sIpqr8YDwA2dSRTE3bJ+V0IfpzfSY3Lfgd7YWOaAdlykvJi13ZKBt8cZHfgH1IXN+CL656W3uUa4w=="],
|
||||
|
||||
@@ -279,15 +280,15 @@
|
||||
|
||||
"@esbuild/win32-x64": ["@esbuild/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-4uJGhsxuptu3OcpVAzli+/gWusVGwZZHTlS63hh++ehExkVT8SgiEf7/uC/PclrPPkLhZqGgCTjd0VWLo6xMqA=="],
|
||||
|
||||
"@floating-ui/core": ["@floating-ui/[email protected].4", "", { "dependencies": { "@floating-ui/utils": "^0.2.10" } }, "sha512-C3HlIdsBxszvm5McXlB8PeOEWfBhcGBTZGkGlWc2U0KFY5IwG5OQEuQ8rq52DZmcHDlPLd+YFBK+cZcytwIFWg=="],
|
||||
"@floating-ui/core": ["@floating-ui/[email protected].5", "", { "dependencies": { "@floating-ui/utils": "^0.2.11" } }, "sha512-1Ih4WTWyw0+lKyFMcBHGbb5U5FtuHJuujoyyr5zTaWS5EYMeT6Jb2AuDeftsCsEuchO+mM2ij5+q9crhydzLhQ=="],
|
||||
|
||||
"@floating-ui/dom": ["@floating-ui/[email protected].5", "", { "dependencies": { "@floating-ui/core": "^1.7.4", "@floating-ui/utils": "^0.2.10" } }, "sha512-N0bD2kIPInNHUHehXhMke1rBGs1dwqvC9O9KYMyyjK7iXt7GAhnro7UlcuYcGdS/yYOlq0MAVgrow8IbWJwyqg=="],
|
||||
"@floating-ui/dom": ["@floating-ui/[email protected].6", "", { "dependencies": { "@floating-ui/core": "^1.7.5", "@floating-ui/utils": "^0.2.11" } }, "sha512-9gZSAI5XM36880PPMm//9dfiEngYoC6Am2izES1FF406YFsjvyBMmeJ2g4SAju3xWwtuynNRFL2s9hgxpLI5SQ=="],
|
||||
|
||||
"@floating-ui/react": ["@floating-ui/[email protected]8", "", { "dependencies": { "@floating-ui/react-dom": "^2.1.7", "@floating-ui/utils": "^0.2.10", "tabbable": "^6.0.0" }, "peerDependencies": { "react": ">=17.0.0", "react-dom": ">=17.0.0" } }, "sha512-xJWJxvmy3a05j643gQt+pRbht5XnTlGpsEsAPnMi5F5YTOEEJymA90uZKBD8OvIv5XvZ1qi4GcccSlqT3Bq44Q=="],
|
||||
"@floating-ui/react": ["@floating-ui/[email protected]9", "", { "dependencies": { "@floating-ui/react-dom": "^2.1.8", "@floating-ui/utils": "^0.2.11", "tabbable": "^6.0.0" }, "peerDependencies": { "react": ">=17.0.0", "react-dom": ">=17.0.0" } }, "sha512-31B8h5mm8YxotlE7/AU/PhNAl8eWxAmjL/v2QOxroDNkTFLk3Uu82u63N3b6TXa4EGJeeZLVcd/9AlNlVqzeog=="],
|
||||
|
||||
"@floating-ui/react-dom": ["@floating-ui/[email protected].7", "", { "dependencies": { "@floating-ui/dom": "^1.7.5" }, "peerDependencies": { "react": ">=16.8.0", "react-dom": ">=16.8.0" } }, "sha512-0tLRojf/1Go2JgEVm+3Frg9A3IW8bJgKgdO0BN5RkF//ufuz2joZM63Npau2ff3J6lUVYgDSNzNkR+aH3IVfjg=="],
|
||||
"@floating-ui/react-dom": ["@floating-ui/[email protected].8", "", { "dependencies": { "@floating-ui/dom": "^1.7.6" }, "peerDependencies": { "react": ">=16.8.0", "react-dom": ">=16.8.0" } }, "sha512-cC52bHwM/n/CxS87FH0yWdngEZrjdtLW/qVruo68qg+prK7ZQ4YGdut2GyDVpoGeAYe/h899rVeOVm6Oi40k2A=="],
|
||||
|
||||
"@floating-ui/utils": ["@floating-ui/[email protected]0", "", {}, "sha512-aGTxbpbg8/b5JfU1HXSrbH3wXZuLPJcNEcZQFMxLs3oSzgtVu6nFPkbbGGUvBcUjKV2YyB9Wxxabo+HEH9tcRQ=="],
|
||||
"@floating-ui/utils": ["@floating-ui/[email protected]1", "", {}, "sha512-RiB/yIh78pcIxl6lLMG0CgBXAZ2Y0eVHqMPYugu+9U0AeT6YBeiJpf7lbdJNIugFP5SIjwNRgo4DhR1Qxi26Gg=="],
|
||||
|
||||
"@hapi/address": ["@hapi/[email protected]", "", { "dependencies": { "@hapi/hoek": "^11.0.2" } }, "sha512-A+po2d/dVoY7cYajycYI43ZbYMXukuopIsqCjh5QzsBCipDtdofHntljDlpccMjIfTy6UOkg+5KPriwYch2bXA=="],
|
||||
|
||||
@@ -297,7 +298,7 @@
|
||||
|
||||
"@hapi/pinpoint": ["@hapi/[email protected]", "", {}, "sha512-EKQmr16tM8s16vTT3cA5L0kZZcTMU5DUOZTuvpnY738m+jyP3JIUj+Mm1xc1rsLkGBQ/gVnfKYPwOmPg1tUR4Q=="],
|
||||
|
||||
"@hapi/tlds": ["@hapi/[email protected].5", "", {}, "sha512-Vq/1gnIIsvFUpKlDdfrPd/ssHDpAyBP/baVukh3u2KSG2xoNjsnRNjQiPmuyPPGqsn1cqVWWhtZHfOBaLizFRQ=="],
|
||||
"@hapi/tlds": ["@hapi/[email protected].6", "", {}, "sha512-xdi7A/4NZokvV0ewovme3aUO5kQhW9pQ2YD1hRqZGhhSi5rBv4usHYidVocXSi9eihYsznZxLtAiEYYUL6VBGw=="],
|
||||
|
||||
"@hapi/topo": ["@hapi/[email protected]", "", { "dependencies": { "@hapi/hoek": "^11.0.2" } }, "sha512-KR3rD5inZbGMrHmgPxsJ9dbi6zEK+C3ZwUwTa+eMwWLz7oijWUTWD2pMSNNYJAU6Qq+65NkxXjqHr/7LM2Xkqg=="],
|
||||
|
||||
@@ -311,7 +312,7 @@
|
||||
|
||||
"@inquirer/type": ["@inquirer/[email protected]", "", { "peerDependencies": { "@types/node": ">=18" }, "optionalPeers": ["@types/node"] }, "sha512-BvziSRxfz5Ov8ch0z/n3oijRSEcEsHnhggm4xFZe93DHcUCTlutlq9Ox4SVENAfcRD22UQq7T/atg9Wr3k09eA=="],
|
||||
|
||||
"@ioredis/commands": ["@ioredis/[email protected].0", "", {}, "sha512-eUgLqrMf8nJkZxT24JvVRrQya1vZkQh8BBeYNwGDqa5I0VUi8ACx7uFvAaLxintokpTenkK6DASvo/bvNbBGow=="],
|
||||
"@ioredis/commands": ["@ioredis/[email protected].1", "", {}, "sha512-JH8ZL/ywcJyR9MmJ5BNqZllXNZQqQbnVZOqpPQqE1vHiFgAw4NHbvE0FOduNU8IX9babitBT46571OnPTT0Zcw=="],
|
||||
|
||||
"@jridgewell/gen-mapping": ["@jridgewell/[email protected]", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.0", "@jridgewell/trace-mapping": "^0.3.24" } }, "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA=="],
|
||||
|
||||
@@ -389,7 +390,7 @@
|
||||
|
||||
"@open-draft/until": ["@open-draft/[email protected]", "", {}, "sha512-U69T3ItWHvLwGg5eJ0n3I62nWuE6ilHlmz7zM0npLBRvPRd7e6NYmg54vvRtP5mZG7kZqZCFVdsTWo7BPtBujg=="],
|
||||
|
||||
"@oxc-project/runtime": ["@oxc-project/[email protected]2.0", "", {}, "sha512-4vYtWXMnXM6EaweCxbJ6bISAhkNHeN33SihvuX3wrpqaSJA4ZEoW35i9mSvE74+GDf1yTeVE+aEHA+WBpjDk/g=="],
|
||||
"@oxc-project/runtime": ["@oxc-project/[email protected]5.0", "", {}, "sha512-Rg8Wlt5dCbXhQnsXPrkOjL1DTSvXLgb2R/KYfnf1/K+R0k6UMLEmbQXPM+kwrWqSmWA2t0B1EtHy2/3zikQpvQ=="],
|
||||
|
||||
"@oxc-project/types": ["@oxc-project/[email protected]", "", {}, "sha512-m6RebKHIRsax2iCwVpYW2ErQwa4ywHJrE4sCK3/8JK8ZZAWOKXaRJFl/uP51gaVyyXlaS4+chU1nSCdzYf6QqQ=="],
|
||||
|
||||
@@ -431,45 +432,47 @@
|
||||
|
||||
"@oxfmt/binding-win32-x64-msvc": ["@oxfmt/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-WCDJjlS95NboR0ugI2BEwzt1tYvRDorDRM9Lvctls1SLyKYuNRCyrPwp1urUPFBnwgBNn9p2/gnmo7gFMySRoQ=="],
|
||||
|
||||
"@oxlint/binding-android-arm-eabi": ["@oxlint/[email protected]0.0", "", { "os": "android", "cpu": "arm" }, "sha512-G7MRGk/6NCe+L8ntonRdZP7IkBfEpiZ/he3buLK6JkLgMHgJShXZ+BeOwADmspXez7U7F7L1Anf4xLSkLHiGTg=="],
|
||||
"@oxlint/binding-android-arm-eabi": ["@oxlint/[email protected]1.0", "", { "os": "android", "cpu": "arm" }, "sha512-jJYIqbx4sX+suIxWstc4P7SzhEwb4ArWA2KVrmEuu9vH2i0qM6QIHz/ehmbGE4/2fZbpuMuBzTl7UkfNoqiSgw=="],
|
||||
|
||||
"@oxlint/binding-android-arm64": ["@oxlint/[email protected]0.0", "", { "os": "android", "cpu": "arm64" }, "sha512-GeSuMoJWCVpovJi/e3xDSNgjeR8WEZ6MCXL6EtPiCIM2NTzv7LbflARINTXTJy2oFBYyvdf/l2PwHzYo6EdXvg=="],
|
||||
"@oxlint/binding-android-arm64": ["@oxlint/[email protected]1.0", "", { "os": "android", "cpu": "arm64" }, "sha512-GtXyBCcH4ti98YdiMNCrpBNGitx87EjEWxevnyhcBK12k/Vu4EzSB45rzSC4fGFUD6sQgeaxItRCEEWeVwPafw=="],
|
||||
|
||||
"@oxlint/binding-darwin-arm64": ["@oxlint/[email protected]0.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-w3SY5YtxGnxCHPJ8Twl3KmS9oja1gERYk3AMoZ7Hv8P43ZtB6HVfs02TxvarxfL214Tm3uzvc2vn+DhtUNeKnw=="],
|
||||
"@oxlint/binding-darwin-arm64": ["@oxlint/[email protected]1.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-3QJbeYaMHn6Bh2XeBXuITSsbnIctyTjvHf5nRjKYrT9pPeErNIpp5VDEeAXC0CZSwSVTsc8WOSDwgrAI24JolQ=="],
|
||||
|
||||
"@oxlint/binding-darwin-x64": ["@oxlint/[email protected]0.0", "", { "os": "darwin", "cpu": "x64" }, "sha512-hNfogDqy7tvmllXKBSlHo6k5x7dhTUVOHbMSE15CCAcXzmqf5883aPvBYPOq9AE7DpDUQUZ1kVE22YbiGW+tuw=="],
|
||||
"@oxlint/binding-darwin-x64": ["@oxlint/[email protected]1.0", "", { "os": "darwin", "cpu": "x64" }, "sha512-NzErhMaTEN1cY0E8C5APy74lw5VwsNfJfVPBMWPVQLqAbO0k4FFLjvHURvkUL+Y18Wu+8Vs1kbqPh2hjXYA4pg=="],
|
||||
|
||||
"@oxlint/binding-freebsd-x64": ["@oxlint/[email protected]0.0", "", { "os": "freebsd", "cpu": "x64" }, "sha512-ykZevOWEyu0nsxolA911ucxpEv0ahw8jfEeGWOwwb/VPoE4xoexuTOAiPNlWZNJqANlJl7yp8OyzCtXTUAxotw=="],
|
||||
"@oxlint/binding-freebsd-x64": ["@oxlint/[email protected]1.0", "", { "os": "freebsd", "cpu": "x64" }, "sha512-msAIh3vPAoKoHlOE/oe6Q5C/n9umypv/k81lED82ibrJotn+3YG2Qp1kiR8o/Dg5iOEU97c6tl0utxcyFenpFw=="],
|
||||
|
||||
"@oxlint/binding-linux-arm-gnueabihf": ["@oxlint/[email protected]0.0", "", { "os": "linux", "cpu": "arm" }, "sha512-hif3iDk7vo5GGJ4OLCCZAf2vjnU9FztGw4L0MbQL0M2iY9LKFtDMMiQAHmkF0PQGQMVbTYtPdXCLKVgdkiqWXQ=="],
|
||||
"@oxlint/binding-linux-arm-gnueabihf": ["@oxlint/[email protected]1.0", "", { "os": "linux", "cpu": "arm" }, "sha512-CqQPcvqYyMe9ZBot2stjGogEzk1z8gGAngIX7srSzrzexmXixwVxBdFZyxTVM0CjGfDeV+Ru0w25/WNjlMM2Hw=="],
|
||||
|
||||
"@oxlint/binding-linux-arm-musleabihf": ["@oxlint/[email protected]0.0", "", { "os": "linux", "cpu": "arm" }, "sha512-dVp9iSssiGAnTNey2Ruf6xUaQhdnvcFOJyRWd/mu5o2jVbFK15E5fbWGeFRfmuobu5QXuROtFga44+7DOS3PLg=="],
|
||||
"@oxlint/binding-linux-arm-musleabihf": ["@oxlint/[email protected]1.0", "", { "os": "linux", "cpu": "arm" }, "sha512-dstrlYQgZMnyOssxSbolGCge/sDbko12N/35RBNuqLpoPbft2aeBidBAb0dvQlyBd9RJ6u8D4o4Eh8Un6iTgyQ=="],
|
||||
|
||||
"@oxlint/binding-linux-arm64-gnu": ["@oxlint/[email protected]0.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-1cT7yz2HA910CKA9NkH1ZJo50vTtmND2fkoW1oyiSb0j6WvNtJ0Wx2zoySfXWc/c+7HFoqRK5AbEoL41LOn9oA=="],
|
||||
"@oxlint/binding-linux-arm64-gnu": ["@oxlint/[email protected]1.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-QEjUpXO7d35rP1/raLGGbAsBLLGZIzV3ZbeSjqWlD3oRnxpRIZ6iL4o51XQHkconn3uKssc+1VKdtHJ81BBhDA=="],
|
||||
|
||||
"@oxlint/binding-linux-arm64-musl": ["@oxlint/[email protected]0.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-++B3k/HEPFVlj89cOz8kWfQccMZB/aWL9AhsW7jPIkG++63Mpwb2cE9XOEsd0PATbIan78k2Gky+09uWM1d/gQ=="],
|
||||
"@oxlint/binding-linux-arm64-musl": ["@oxlint/[email protected]1.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-YSJua5irtG4DoMAjUapDTPhkQLHhBIY0G9JqlZS6/SZPzqDkPku/1GdWs0D6h/wyx0Iz31lNCfIaWKBQhzP0wQ=="],
|
||||
|
||||
"@oxlint/binding-linux-ppc64-gnu": ["@oxlint/[email protected]0.0", "", { "os": "linux", "cpu": "ppc64" }, "sha512-Z9b/KpFMkx66w3gVBqjIC1AJBTZAGoI9+U+K5L4QM0CB/G0JSNC1es9b3Y0Vcrlvtdn8A+IQTkYjd/Q0uCSaZw=="],
|
||||
"@oxlint/binding-linux-ppc64-gnu": ["@oxlint/[email protected]1.0", "", { "os": "linux", "cpu": "ppc64" }, "sha512-7L4Wj2IEUNDETKssB9IDYt16T6WlF+X2jgC/hBq3diGHda9vJLpAgb09+D3quFq7TdkFtI7hwz/jmuQmQFPc1Q=="],
|
||||
|
||||
"@oxlint/binding-linux-riscv64-gnu": ["@oxlint/[email protected]0.0", "", { "os": "linux", "cpu": "none" }, "sha512-jvmuIw8wRSohsQlFNIST5uUwkEtEJmOQYr33bf/K2FrFPXHhM4KqGekI3ShYJemFS/gARVacQFgBzzJKCAyJjg=="],
|
||||
"@oxlint/binding-linux-riscv64-gnu": ["@oxlint/[email protected]1.0", "", { "os": "linux", "cpu": "none" }, "sha512-cBUHqtOXy76G41lOB401qpFoKx1xq17qYkhWrLSM7eEjiHM9sOtYqpr6ZdqCnN9s6ZpzudX4EkeHOFH2E9q0vA=="],
|
||||
|
||||
"@oxlint/binding-linux-riscv64-musl": ["@oxlint/[email protected]0.0", "", { "os": "linux", "cpu": "none" }, "sha512-x+UrN47oYNh90nmAAyql8eQaaRpHbDPu5guasDg10+OpszUQ3/1+1J6zFMmV4xfIEgTcUXG/oI5fxJhF4eWCNA=="],
|
||||
"@oxlint/binding-linux-riscv64-musl": ["@oxlint/[email protected]1.0", "", { "os": "linux", "cpu": "none" }, "sha512-WKbg8CysgZcHfZX0ixQFBRSBvFZUHa3SBnEjHY2FVYt2nbNJEjzTxA3ZR5wMU0NOCNKIAFUFvAh5/XJKPRJuJg=="],
|
||||
|
||||
"@oxlint/binding-linux-s390x-gnu": ["@oxlint/[email protected]0.0", "", { "os": "linux", "cpu": "s390x" }, "sha512-i/JLi2ljLUIVfekMj4ISmdt+Hn11wzYUdRRrkVUYsCWw7zAy5xV7X9iA+KMyM156LTFympa7s3oKBjuCLoTAUQ=="],
|
||||
"@oxlint/binding-linux-s390x-gnu": ["@oxlint/[email protected]1.0", "", { "os": "linux", "cpu": "s390x" }, "sha512-N1QRUvJTxqXNSu35YOufdjsAVmKVx5bkrggOWAhTWBc3J4qjcBwr1IfyLh/6YCg8sYRSR1GraldS9jUgJL/U4A=="],
|
||||
|
||||
"@oxlint/binding-linux-x64-gnu": ["@oxlint/[email protected]0.0", "", { "os": "linux", "cpu": "x64" }, "sha512-/C7brhn6c6UUPccgSPCcpLQXcp+xKIW/3sji/5VZ8/OItL3tQ2U7KalHz887UxxSQeEOmd1kY6lrpuwFnmNqOA=="],
|
||||
"@oxlint/binding-linux-x64-gnu": ["@oxlint/[email protected]1.0", "", { "os": "linux", "cpu": "x64" }, "sha512-e0Mz0DizsCoqNIjeOg6OUKe8JKJWZ5zZlwsd05Bmr51Jo3AOL4UJnPvwKumr4BBtBrDZkCmOLhCvDGm95nJM2g=="],
|
||||
|
||||
"@oxlint/binding-linux-x64-musl": ["@oxlint/[email protected]0.0", "", { "os": "linux", "cpu": "x64" }, "sha512-oDR1f+bGOYU8LfgtEW8XtotWGB63ghtcxk5Jm6IDTCk++rTA/IRMsjOid2iMd+1bW+nP9Mdsmcdc7VbPD3+iyQ=="],
|
||||
"@oxlint/binding-linux-x64-musl": ["@oxlint/[email protected]1.0", "", { "os": "linux", "cpu": "x64" }, "sha512-wD8HGTWhYBKXvRDvoBVB1y+fEYV01samhWQSy1Zkxq2vpezvMnjaFKRuiP6tBNITLGuffbNDEXOwcAhJ3gI5Ug=="],
|
||||
|
||||
"@oxlint/binding-openharmony-arm64": ["@oxlint/[email protected]0.0", "", { "os": "none", "cpu": "arm64" }, "sha512-4CmRGPp5UpvXyu4jjP9Tey/SrXDQLRvZXm4pb4vdZBxAzbFZkCyh0KyRy4txld/kZKTJlW4TO8N1JKrNEk+mWw=="],
|
||||
"@oxlint/binding-openharmony-arm64": ["@oxlint/[email protected]1.0", "", { "os": "none", "cpu": "arm64" }, "sha512-5NSwQ2hDEJ0GPXqikjWtwzgAQCsS7P9aLMNenjjKa+gknN3lTCwwwERsT6lKXSirfU3jLjexA2XQvQALh5h27w=="],
|
||||
|
||||
"@oxlint/binding-win32-arm64-msvc": ["@oxlint/[email protected]0.0", "", { "os": "win32", "cpu": "arm64" }, "sha512-Fq0M6vsGcFsSfeuWAACDhd5KJrO85ckbEfe1EGuBj+KPyJz7KeWte2fSFrFGmNKNXyhEMyx4tbgxiWRujBM2KQ=="],
|
||||
"@oxlint/binding-win32-arm64-msvc": ["@oxlint/[email protected]1.0", "", { "os": "win32", "cpu": "arm64" }, "sha512-JEZyah1M0RHMw8d+jjSSJmSmO8sABA1J1RtrHYujGPeCkYg1NeH0TGuClpe2h5QtioRTaF57y/TZfn/2IFV6fA=="],
|
||||
|
||||
"@oxlint/binding-win32-ia32-msvc": ["@oxlint/[email protected]0.0", "", { "os": "win32", "cpu": "ia32" }, "sha512-qTdWR9KwY/vxJGhHVIZG2eBOhidOQvOwzDxnX+jhW/zIVacal1nAhR8GLkiywW8BIFDkQKXo/zOfT+/DY+ns/w=="],
|
||||
"@oxlint/binding-win32-ia32-msvc": ["@oxlint/[email protected]1.0", "", { "os": "win32", "cpu": "ia32" }, "sha512-q3cEoKH6kwjz/WRyHwSf0nlD2F5Qw536kCXvmlSu+kaShzgrA0ojmh45CA81qL+7udfCaZL2SdKCZlLiGBVFlg=="],
|
||||
|
||||
"@oxlint/binding-win32-x64-msvc": ["@oxlint/[email protected]0.0", "", { "os": "win32", "cpu": "x64" }, "sha512-682t7npLC4G2Ca+iNlI9fhAKTcFPYYXJjwoa88H4q+u5HHHlsnL/gHULapX3iqp+A8FIJbgdylL5KMYo2LaluQ=="],
|
||||
"@oxlint/binding-win32-x64-msvc": ["@oxlint/[email protected]1.0", "", { "os": "win32", "cpu": "x64" }, "sha512-Q14+fOGb9T28nWF/0EUsYqERiRA7cl1oy4TJrGmLaqhm+aO2cV+JttboHI3CbdeMCAyDI1+NoSlrM7Melhp/cw=="],
|
||||
|
||||
"@pierre/diffs": ["@pierre/[email protected]6", "", { "dependencies": { "@shikijs/transformers": "^3.0.0", "diff": "8.0.3", "hast-util-to-html": "9.0.5", "lru_map": "0.4.1", "shiki": "^3.0.0" }, "peerDependencies": { "react": "^18.3.1 || ^19.0.0", "react-dom": "^18.3.1 || ^19.0.0" } }, "sha512-McjTuEPuacSIcXdoI2O9W6VSHIOs9ApEHnEUwONKZnKqIo2GGv1vNg9Pr8tgBOL7lgBWNEHX5ROJ5z1X74sENQ=="],
|
||||
"@pierre/diffs": ["@pierre/[email protected]8", "", { "dependencies": { "@pierre/theme": "0.0.22", "@shikijs/transformers": "^3.0.0", "diff": "8.0.3", "hast-util-to-html": "9.0.5", "lru_map": "0.4.1", "shiki": "^3.0.0" }, "peerDependencies": { "react": "^18.3.1 || ^19.0.0", "react-dom": "^18.3.1 || ^19.0.0" } }, "sha512-7ZF3YD9fxdbYsPnltz5cUqHacN7ztp8RX/fJLxwv8wIEORpP4+7dHz1h/qx3o4EW2xUrIhmbM8ImywLasB787Q=="],
|
||||
|
||||
"@pierre/theme": ["@pierre/[email protected]", "", {}, "sha512-ePUIdQRNGjrveELTU7fY89Xa7YGHHEy5Po5jQy/18lm32eRn96+tnYJEtFooGdffrx55KBUtOXfvVy/7LDFFhA=="],
|
||||
|
||||
"@polka/url": ["@polka/[email protected]", "", {}, "sha512-wwQAWhWSuHaag8c4q/KN/vCoeOJYshAIvMQwD4GpSb3OiZklFfvAgmj0VCBBImRpuF/aFgIRzllXlVX93Jevww=="],
|
||||
|
||||
@@ -491,6 +494,10 @@
|
||||
|
||||
"@rolldown/binding-linux-arm64-musl": ["@rolldown/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-Z03/wrqau9Bicfgb3Dbs6SYTHliELk2PM2LpG2nFd+cGupTMF5kanLEcj2vuuJLLhptNyS61rtk7SOZ+lPsTUA=="],
|
||||
|
||||
"@rolldown/binding-linux-ppc64-gnu": ["@rolldown/[email protected]", "", { "os": "linux", "cpu": "ppc64" }, "sha512-Y48ShVxGE2zUTt0A0PR3grCLNxW4DWtAfe5lxf6L3uYEQujwo/LGuRogMsAtOJeYLCPTJo2i714LOdnK34cHpw=="],
|
||||
|
||||
"@rolldown/binding-linux-s390x-gnu": ["@rolldown/[email protected]", "", { "os": "linux", "cpu": "s390x" }, "sha512-KU5DUYvX3qI8/TX6D3RA4awXi4Ge/1+M6Jqv7kRiUndpqoVGgD765xhV3Q6QvtABnYjLJenrWDl3S1B5U56ixA=="],
|
||||
|
||||
"@rolldown/binding-linux-x64-gnu": ["@rolldown/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-iSXXZsQp08CSilff/DCTFZHSVEpEwdicV3W8idHyrByrcsRDVh9sGC3sev6d8BygSGj3vt8GvUKBPCoyMA4tgQ=="],
|
||||
|
||||
"@rolldown/binding-linux-x64-musl": ["@rolldown/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-qaj+MFudtdCv9xZo9znFvkgoajLdc+vwf0Kz5N44g+LU5XMe+IsACgn3UG7uTRlCCvhMAGXm1XlpEA5bZBrOcw=="],
|
||||
@@ -505,69 +512,69 @@
|
||||
|
||||
"@rolldown/pluginutils": ["@rolldown/[email protected]", "", {}, "sha512-eybk3TjzzzV97Dlj5c+XrBFW57eTNhzod66y9HrBlzJ6NsCrWCp/2kaPS3K9wJmurBC0Tdw4yPjXKZqlznim3Q=="],
|
||||
|
||||
"@rollup/rollup-android-arm-eabi": ["@rollup/[email protected]7.1", "", { "os": "android", "cpu": "arm" }, "sha512-A6ehUVSiSaaliTxai040ZpZ2zTevHYbvu/lDoeAteHI8QnaosIzm4qwtezfRg1jOYaUmnzLX1AOD6Z+UJjtifg=="],
|
||||
"@rollup/rollup-android-arm-eabi": ["@rollup/[email protected]9.0", "", { "os": "android", "cpu": "arm" }, "sha512-upnNBkA6ZH2VKGcBj9Fyl9IGNPULcjXRlg0LLeaioQWueH30p6IXtJEbKAgvyv+mJaMxSm1l6xwDXYjpEMiLMg=="],
|
||||
|
||||
"@rollup/rollup-android-arm64": ["@rollup/[email protected]7.1", "", { "os": "android", "cpu": "arm64" }, "sha512-dQaAddCY9YgkFHZcFNS/606Exo8vcLHwArFZ7vxXq4rigo2bb494/xKMMwRRQW6ug7Js6yXmBZhSBRuBvCCQ3w=="],
|
||||
"@rollup/rollup-android-arm64": ["@rollup/[email protected]9.0", "", { "os": "android", "cpu": "arm64" }, "sha512-hZ+Zxj3SySm4A/DylsDKZAeVg0mvi++0PYVceVyX7hemkw7OreKdCvW2oQ3T1FMZvCaQXqOTHb8qmBShoqk69Q=="],
|
||||
|
||||
"@rollup/rollup-darwin-arm64": ["@rollup/[email protected]7.1", "", { "os": "darwin", "cpu": "arm64" }, "sha512-crNPrwJOrRxagUYeMn/DZwqN88SDmwaJ8Cvi/TN1HnWBU7GwknckyosC2gd0IqYRsHDEnXf328o9/HC6OkPgOg=="],
|
||||
"@rollup/rollup-darwin-arm64": ["@rollup/[email protected]9.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-W2Psnbh1J8ZJw0xKAd8zdNgF9HRLkdWwwdWqubSVk0pUuQkoHnv7rx4GiF9rT4t5DIZGAsConRE3AxCdJ4m8rg=="],
|
||||
|
||||
"@rollup/rollup-darwin-x64": ["@rollup/[email protected]7.1", "", { "os": "darwin", "cpu": "x64" }, "sha512-Ji8g8ChVbKrhFtig5QBV7iMaJrGtpHelkB3lsaKzadFBe58gmjfGXAOfI5FV0lYMH8wiqsxKQ1C9B0YTRXVy4w=="],
|
||||
"@rollup/rollup-darwin-x64": ["@rollup/[email protected]9.0", "", { "os": "darwin", "cpu": "x64" }, "sha512-ZW2KkwlS4lwTv7ZVsYDiARfFCnSGhzYPdiOU4IM2fDbL+QGlyAbjgSFuqNRbSthybLbIJ915UtZBtmuLrQAT/w=="],
|
||||
|
||||
"@rollup/rollup-freebsd-arm64": ["@rollup/[email protected]7.1", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-R+/WwhsjmwodAcz65guCGFRkMb4gKWTcIeLy60JJQbXrJ97BOXHxnkPFrP+YwFlaS0m+uWJTstrUA9o+UchFug=="],
|
||||
"@rollup/rollup-freebsd-arm64": ["@rollup/[email protected]9.0", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-EsKaJ5ytAu9jI3lonzn3BgG8iRBjV4LxZexygcQbpiU0wU0ATxhNVEpXKfUa0pS05gTcSDMKpn3Sx+QB9RlTTA=="],
|
||||
|
||||
"@rollup/rollup-freebsd-x64": ["@rollup/[email protected]7.1", "", { "os": "freebsd", "cpu": "x64" }, "sha512-IEQTCHeiTOnAUC3IDQdzRAGj3jOAYNr9kBguI7MQAAZK3caezRrg0GxAb6Hchg4lxdZEI5Oq3iov/w/hnFWY9Q=="],
|
||||
"@rollup/rollup-freebsd-x64": ["@rollup/[email protected]9.0", "", { "os": "freebsd", "cpu": "x64" }, "sha512-d3DuZi2KzTMjImrxoHIAODUZYoUUMsuUiY4SRRcJy6NJoZ6iIqWnJu9IScV9jXysyGMVuW+KNzZvBLOcpdl3Vg=="],
|
||||
|
||||
"@rollup/rollup-linux-arm-gnueabihf": ["@rollup/[email protected]7.1", "", { "os": "linux", "cpu": "arm" }, "sha512-F8sWbhZ7tyuEfsmOxwc2giKDQzN3+kuBLPwwZGyVkLlKGdV1nvnNwYD0fKQ8+XS6hp9nY7B+ZeK01EBUE7aHaw=="],
|
||||
"@rollup/rollup-linux-arm-gnueabihf": ["@rollup/[email protected]9.0", "", { "os": "linux", "cpu": "arm" }, "sha512-t4ONHboXi/3E0rT6OZl1pKbl2Vgxf9vJfWgmUoCEVQVxhW6Cw/c8I6hbbu7DAvgp82RKiH7TpLwxnJeKv2pbsw=="],
|
||||
|
||||
"@rollup/rollup-linux-arm-musleabihf": ["@rollup/[email protected]7.1", "", { "os": "linux", "cpu": "arm" }, "sha512-rGfNUfn0GIeXtBP1wL5MnzSj98+PZe/AXaGBCRmT0ts80lU5CATYGxXukeTX39XBKsxzFpEeK+Mrp9faXOlmrw=="],
|
||||
"@rollup/rollup-linux-arm-musleabihf": ["@rollup/[email protected]9.0", "", { "os": "linux", "cpu": "arm" }, "sha512-CikFT7aYPA2ufMD086cVORBYGHffBo4K8MQ4uPS/ZnY54GKj36i196u8U+aDVT2LX4eSMbyHtyOh7D7Zvk2VvA=="],
|
||||
|
||||
"@rollup/rollup-linux-arm64-gnu": ["@rollup/[email protected]7.1", "", { "os": "linux", "cpu": "arm64" }, "sha512-MMtej3YHWeg/0klK2Qodf3yrNzz6CGjo2UntLvk2RSPlhzgLvYEB3frRvbEF2wRKh1Z2fDIg9KRPe1fawv7C+g=="],
|
||||
"@rollup/rollup-linux-arm64-gnu": ["@rollup/[email protected]9.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-jYgUGk5aLd1nUb1CtQ8E+t5JhLc9x5WdBKew9ZgAXg7DBk0ZHErLHdXM24rfX+bKrFe+Xp5YuJo54I5HFjGDAA=="],
|
||||
|
||||
"@rollup/rollup-linux-arm64-musl": ["@rollup/[email protected]7.1", "", { "os": "linux", "cpu": "arm64" }, "sha512-1a/qhaaOXhqXGpMFMET9VqwZakkljWHLmZOX48R0I/YLbhdxr1m4gtG1Hq7++VhVUmf+L3sTAf9op4JlhQ5u1Q=="],
|
||||
"@rollup/rollup-linux-arm64-musl": ["@rollup/[email protected]9.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-peZRVEdnFWZ5Bh2KeumKG9ty7aCXzzEsHShOZEFiCQlDEepP1dpUl/SrUNXNg13UmZl+gzVDPsiCwnV1uI0RUA=="],
|
||||
|
||||
"@rollup/rollup-linux-loong64-gnu": ["@rollup/[email protected]7.1", "", { "os": "linux", "cpu": "none" }, "sha512-QWO6RQTZ/cqYtJMtxhkRkidoNGXc7ERPbZN7dVW5SdURuLeVU7lwKMpo18XdcmpWYd0qsP1bwKPf7DNSUinhvA=="],
|
||||
"@rollup/rollup-linux-loong64-gnu": ["@rollup/[email protected]9.0", "", { "os": "linux", "cpu": "none" }, "sha512-gbUSW/97f7+r4gHy3Jlup8zDG190AuodsWnNiXErp9mT90iCy9NKKU0Xwx5k8VlRAIV2uU9CsMnEFg/xXaOfXg=="],
|
||||
|
||||
"@rollup/rollup-linux-loong64-musl": ["@rollup/[email protected]7.1", "", { "os": "linux", "cpu": "none" }, "sha512-xpObYIf+8gprgWaPP32xiN5RVTi/s5FCR+XMXSKmhfoJjrpRAjCuuqQXyxUa/eJTdAE6eJ+KDKaoEqjZQxh3Gw=="],
|
||||
"@rollup/rollup-linux-loong64-musl": ["@rollup/[email protected]9.0", "", { "os": "linux", "cpu": "none" }, "sha512-yTRONe79E+o0FWFijasoTjtzG9EBedFXJMl888NBEDCDV9I2wGbFFfJQQe63OijbFCUZqxpHz1GzpbtSFikJ4Q=="],
|
||||
|
||||
"@rollup/rollup-linux-ppc64-gnu": ["@rollup/[email protected]7.1", "", { "os": "linux", "cpu": "ppc64" }, "sha512-4BrCgrpZo4hvzMDKRqEaW1zeecScDCR+2nZ86ATLhAoJ5FQ+lbHVD3ttKe74/c7tNT9c6F2viwB3ufwp01Oh2w=="],
|
||||
"@rollup/rollup-linux-ppc64-gnu": ["@rollup/[email protected]9.0", "", { "os": "linux", "cpu": "ppc64" }, "sha512-sw1o3tfyk12k3OEpRddF68a1unZ5VCN7zoTNtSn2KndUE+ea3m3ROOKRCZxEpmT9nsGnogpFP9x6mnLTCaoLkA=="],
|
||||
|
||||
"@rollup/rollup-linux-ppc64-musl": ["@rollup/[email protected]7.1", "", { "os": "linux", "cpu": "ppc64" }, "sha512-NOlUuzesGauESAyEYFSe3QTUguL+lvrN1HtwEEsU2rOwdUDeTMJdO5dUYl/2hKf9jWydJrO9OL/XSSf65R5+Xw=="],
|
||||
"@rollup/rollup-linux-ppc64-musl": ["@rollup/[email protected]9.0", "", { "os": "linux", "cpu": "ppc64" }, "sha512-+2kLtQ4xT3AiIxkzFVFXfsmlZiG5FXYW7ZyIIvGA7Bdeuh9Z0aN4hVyXS/G1E9bTP/vqszNIN/pUKCk/BTHsKA=="],
|
||||
|
||||
"@rollup/rollup-linux-riscv64-gnu": ["@rollup/[email protected]7.1", "", { "os": "linux", "cpu": "none" }, "sha512-ptA88htVp0AwUUqhVghwDIKlvJMD/fmL/wrQj99PRHFRAG6Z5nbWoWG4o81Nt9FT+IuqUQi+L31ZKAFeJ5Is+A=="],
|
||||
"@rollup/rollup-linux-riscv64-gnu": ["@rollup/[email protected]9.0", "", { "os": "linux", "cpu": "none" }, "sha512-NDYMpsXYJJaj+I7UdwIuHHNxXZ/b/N2hR15NyH3m2qAtb/hHPA4g4SuuvrdxetTdndfj9b1WOmy73kcPRoERUg=="],
|
||||
|
||||
"@rollup/rollup-linux-riscv64-musl": ["@rollup/[email protected]7.1", "", { "os": "linux", "cpu": "none" }, "sha512-S51t7aMMTNdmAMPpBg7OOsTdn4tySRQvklmL3RpDRyknk87+Sp3xaumlatU+ppQ+5raY7sSTcC2beGgvhENfuw=="],
|
||||
"@rollup/rollup-linux-riscv64-musl": ["@rollup/[email protected]9.0", "", { "os": "linux", "cpu": "none" }, "sha512-nLckB8WOqHIf1bhymk+oHxvM9D3tyPndZH8i8+35p/1YiVoVswPid2yLzgX7ZJP0KQvnkhM4H6QZ5m0LzbyIAg=="],
|
||||
|
||||
"@rollup/rollup-linux-s390x-gnu": ["@rollup/[email protected]7.1", "", { "os": "linux", "cpu": "s390x" }, "sha512-Bl00OFnVFkL82FHbEqy3k5CUCKH6OEJL54KCyx2oqsmZnFTR8IoNqBF+mjQVcRCT5sB6yOvK8A37LNm/kPJiZg=="],
|
||||
"@rollup/rollup-linux-s390x-gnu": ["@rollup/[email protected]9.0", "", { "os": "linux", "cpu": "s390x" }, "sha512-oF87Ie3uAIvORFBpwnCvUzdeYUqi2wY6jRFWJAy1qus/udHFYIkplYRW+wo+GRUP4sKzYdmE1Y3+rY5Gc4ZO+w=="],
|
||||
|
||||
"@rollup/rollup-linux-x64-gnu": ["@rollup/[email protected]7.1", "", { "os": "linux", "cpu": "x64" }, "sha512-ABca4ceT4N+Tv/GtotnWAeXZUZuM/9AQyCyKYyKnpk4yoA7QIAuBt6Hkgpw8kActYlew2mvckXkvx0FfoInnLg=="],
|
||||
"@rollup/rollup-linux-x64-gnu": ["@rollup/[email protected]9.0", "", { "os": "linux", "cpu": "x64" }, "sha512-3AHmtQq/ppNuUspKAlvA8HtLybkDflkMuLK4DPo77DfthRb71V84/c4MlWJXixZz4uruIH4uaa07IqoAkG64fg=="],
|
||||
|
||||
"@rollup/rollup-linux-x64-musl": ["@rollup/[email protected]7.1", "", { "os": "linux", "cpu": "x64" }, "sha512-HFps0JeGtuOR2convgRRkHCekD7j+gdAuXM+/i6kGzQtFhlCtQkpwtNzkNj6QhCDp7DRJ7+qC/1Vg2jt5iSOFw=="],
|
||||
"@rollup/rollup-linux-x64-musl": ["@rollup/[email protected]9.0", "", { "os": "linux", "cpu": "x64" }, "sha512-2UdiwS/9cTAx7qIUZB/fWtToJwvt0Vbo0zmnYt7ED35KPg13Q0ym1g442THLC7VyI6JfYTP4PiSOWyoMdV2/xg=="],
|
||||
|
||||
"@rollup/rollup-openbsd-x64": ["@rollup/[email protected]7.1", "", { "os": "openbsd", "cpu": "x64" }, "sha512-H+hXEv9gdVQuDTgnqD+SQffoWoc0Of59AStSzTEj/feWTBAnSfSD3+Dql1ZruJQxmykT/JVY0dE8Ka7z0DH1hw=="],
|
||||
"@rollup/rollup-openbsd-x64": ["@rollup/[email protected]9.0", "", { "os": "openbsd", "cpu": "x64" }, "sha512-M3bLRAVk6GOwFlPTIxVBSYKUaqfLrn8l0psKinkCFxl4lQvOSz8ZrKDz2gxcBwHFpci0B6rttydI4IpS4IS/jQ=="],
|
||||
|
||||
"@rollup/rollup-openharmony-arm64": ["@rollup/[email protected]7.1", "", { "os": "none", "cpu": "arm64" }, "sha512-4wYoDpNg6o/oPximyc/NG+mYUejZrCU2q+2w6YZqrAs2UcNUChIZXjtafAiiZSUc7On8v5NyNj34Kzj/Ltk6dQ=="],
|
||||
"@rollup/rollup-openharmony-arm64": ["@rollup/[email protected]9.0", "", { "os": "none", "cpu": "arm64" }, "sha512-tt9KBJqaqp5i5HUZzoafHZX8b5Q2Fe7UjYERADll83O4fGqJ49O1FsL6LpdzVFQcpwvnyd0i+K/VSwu/o/nWlA=="],
|
||||
|
||||
"@rollup/rollup-win32-arm64-msvc": ["@rollup/[email protected]7.1", "", { "os": "win32", "cpu": "arm64" }, "sha512-O54mtsV/6LW3P8qdTcamQmuC990HDfR71lo44oZMZlXU4tzLrbvTii87Ni9opq60ds0YzuAlEr/GNwuNluZyMQ=="],
|
||||
"@rollup/rollup-win32-arm64-msvc": ["@rollup/[email protected]9.0", "", { "os": "win32", "cpu": "arm64" }, "sha512-V5B6mG7OrGTwnxaNUzZTDTjDS7F75PO1ae6MJYdiMu60sq0CqN5CVeVsbhPxalupvTX8gXVSU9gq+Rx1/hvu6A=="],
|
||||
|
||||
"@rollup/rollup-win32-ia32-msvc": ["@rollup/[email protected]7.1", "", { "os": "win32", "cpu": "ia32" }, "sha512-P3dLS+IerxCT/7D2q2FYcRdWRl22dNbrbBEtxdWhXrfIMPP9lQhb5h4Du04mdl5Woq05jVCDPCMF7Ub0NAjIew=="],
|
||||
"@rollup/rollup-win32-ia32-msvc": ["@rollup/[email protected]9.0", "", { "os": "win32", "cpu": "ia32" }, "sha512-UKFMHPuM9R0iBegwzKF4y0C4J9u8C6MEJgFuXTBerMk7EJ92GFVFYBfOZaSGLu6COf7FxpQNqhNS4c4icUPqxA=="],
|
||||
|
||||
"@rollup/rollup-win32-x64-gnu": ["@rollup/[email protected]7.1", "", { "os": "win32", "cpu": "x64" }, "sha512-VMBH2eOOaKGtIJYleXsi2B8CPVADrh+TyNxJ4mWPnKfLB/DBUmzW+5m1xUrcwWoMfSLagIRpjUFeW5CO5hyciQ=="],
|
||||
"@rollup/rollup-win32-x64-gnu": ["@rollup/[email protected]9.0", "", { "os": "win32", "cpu": "x64" }, "sha512-laBkYlSS1n2L8fSo1thDNGrCTQMmxjYY5G0WFWjFFYZkKPjsMBsgJfGf4TLxXrF6RyhI60L8TMOjBMvXiTcxeA=="],
|
||||
|
||||
"@rollup/rollup-win32-x64-msvc": ["@rollup/[email protected]7.1", "", { "os": "win32", "cpu": "x64" }, "sha512-mxRFDdHIWRxg3UfIIAwCm6NzvxG0jDX/wBN6KsQFTvKFqqg9vTrWUE68qEjHt19A5wwx5X5aUi2zuZT7YR0jrA=="],
|
||||
"@rollup/rollup-win32-x64-msvc": ["@rollup/[email protected]9.0", "", { "os": "win32", "cpu": "x64" }, "sha512-2HRCml6OztYXyJXAvdDXPKcawukWY2GpR5/nxKp4iBgiO3wcoEGkAaqctIbZcNB6KlUQBIqt8VYkNSj2397EfA=="],
|
||||
|
||||
"@shikijs/core": ["@shikijs/[email protected]2.0", "", { "dependencies": { "@shikijs/types": "3.22.0", "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4", "hast-util-to-html": "^9.0.5" } }, "sha512-iAlTtSDDbJiRpvgL5ugKEATDtHdUVkqgHDm/gbD2ZS9c88mx7G1zSYjjOxp5Qa0eaW0MAQosFRmJSk354PRoQA=="],
|
||||
"@shikijs/core": ["@shikijs/[email protected]3.0", "", { "dependencies": { "@shikijs/types": "3.23.0", "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4", "hast-util-to-html": "^9.0.5" } }, "sha512-NSWQz0riNb67xthdm5br6lAkvpDJRTgB36fxlo37ZzM2yq0PQFFzbd8psqC2XMPgCzo1fW6cVi18+ArJ44wqgA=="],
|
||||
|
||||
"@shikijs/engine-javascript": ["@shikijs/[email protected]2.0", "", { "dependencies": { "@shikijs/types": "3.22.0", "@shikijs/vscode-textmate": "^10.0.2", "oniguruma-to-es": "^4.3.4" } }, "sha512-jdKhfgW9CRtj3Tor0L7+yPwdG3CgP7W+ZEqSsojrMzCjD1e0IxIbwUMDDpYlVBlC08TACg4puwFGkZfLS+56Tw=="],
|
||||
"@shikijs/engine-javascript": ["@shikijs/[email protected]3.0", "", { "dependencies": { "@shikijs/types": "3.23.0", "@shikijs/vscode-textmate": "^10.0.2", "oniguruma-to-es": "^4.3.4" } }, "sha512-aHt9eiGFobmWR5uqJUViySI1bHMqrAgamWE1TYSUoftkAeCCAiGawPMwM+VCadylQtF4V3VNOZ5LmfItH5f3yA=="],
|
||||
|
||||
"@shikijs/engine-oniguruma": ["@shikijs/[email protected]2.0", "", { "dependencies": { "@shikijs/types": "3.22.0", "@shikijs/vscode-textmate": "^10.0.2" } }, "sha512-DyXsOG0vGtNtl7ygvabHd7Mt5EY8gCNqR9Y7Lpbbd/PbJvgWrqaKzH1JW6H6qFkuUa8aCxoiYVv8/YfFljiQxA=="],
|
||||
"@shikijs/engine-oniguruma": ["@shikijs/[email protected]3.0", "", { "dependencies": { "@shikijs/types": "3.23.0", "@shikijs/vscode-textmate": "^10.0.2" } }, "sha512-1nWINwKXxKKLqPibT5f4pAFLej9oZzQTsby8942OTlsJzOBZ0MWKiwzMsd+jhzu8YPCHAswGnnN1YtQfirL35g=="],
|
||||
|
||||
"@shikijs/langs": ["@shikijs/[email protected]2.0", "", { "dependencies": { "@shikijs/types": "3.22.0" } }, "sha512-x/42TfhWmp6H00T6uwVrdTJGKgNdFbrEdhaDwSR5fd5zhQ1Q46bHq9EO61SCEWJR0HY7z2HNDMaBZp8JRmKiIA=="],
|
||||
"@shikijs/langs": ["@shikijs/[email protected]3.0", "", { "dependencies": { "@shikijs/types": "3.23.0" } }, "sha512-2Ep4W3Re5aB1/62RSYQInK9mM3HsLeB91cHqznAJMuylqjzNVAVCMnNWRHFtcNHXsoNRayP9z1qj4Sq3nMqYXg=="],
|
||||
|
||||
"@shikijs/themes": ["@shikijs/[email protected]2.0", "", { "dependencies": { "@shikijs/types": "3.22.0" } }, "sha512-o+tlOKqsr6FE4+mYJG08tfCFDS+3CG20HbldXeVoyP+cYSUxDhrFf3GPjE60U55iOkkjbpY2uC3It/eeja35/g=="],
|
||||
"@shikijs/themes": ["@shikijs/[email protected]3.0", "", { "dependencies": { "@shikijs/types": "3.23.0" } }, "sha512-5qySYa1ZgAT18HR/ypENL9cUSGOeI2x+4IvYJu4JgVJdizn6kG4ia5Q1jDEOi7gTbN4RbuYtmHh0W3eccOrjMA=="],
|
||||
|
||||
"@shikijs/transformers": ["@shikijs/[email protected]2.0", "", { "dependencies": { "@shikijs/core": "3.22.0", "@shikijs/types": "3.22.0" } }, "sha512-E7eRV7mwDBjueLF6852n2oYeJYxBq3NSsDk+uyruYAXONv4U8holGmIrT+mPRJQ1J1SNOH6L8G19KRzmBawrFw=="],
|
||||
"@shikijs/transformers": ["@shikijs/[email protected]3.0", "", { "dependencies": { "@shikijs/core": "3.23.0", "@shikijs/types": "3.23.0" } }, "sha512-F9msZVxdF+krQNSdQ4V+Ja5QemeAoTQ2jxt7nJCwhDsdF1JWS3KxIQXA3lQbyKwS3J61oHRUSv4jYWv3CkaKTQ=="],
|
||||
|
||||
"@shikijs/types": ["@shikijs/[email protected]2.0", "", { "dependencies": { "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4" } }, "sha512-491iAekgKDBFE67z70Ok5a8KBMsQ2IJwOWw3us/7ffQkIBCyOQfm/aNwVMBUriP02QshIfgHCBSIYAl3u2eWjg=="],
|
||||
"@shikijs/types": ["@shikijs/[email protected]3.0", "", { "dependencies": { "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4" } }, "sha512-3JZ5HXOZfYjsYSk0yPwBrkupyYSLpAE26Qc0HLghhZNGTZg/SKxXIIgoxOpmmeQP0RRSDJTk1/vPfw9tbw+jSQ=="],
|
||||
|
||||
"@shikijs/vscode-textmate": ["@shikijs/[email protected]", "", {}, "sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg=="],
|
||||
|
||||
@@ -587,39 +594,39 @@
|
||||
|
||||
"@t3tools/web": ["@t3tools/web@workspace:apps/web"],
|
||||
|
||||
"@tailwindcss/node": ["@tailwindcss/node@4.1.18", "", { "dependencies": { "@jridgewell/remapping": "^2.3.4", "enhanced-resolve": "^5.18.3", "jiti": "^2.6.1", "lightningcss": "1.30.2", "magic-string": "^0.30.21", "source-map-js": "^1.2.1", "tailwindcss": "4.1.18" } }, "sha512-DoR7U1P7iYhw16qJ49fgXUlry1t4CpXeErJHnQ44JgTSKMaZUdf17cfn5mHchfJ4KRBZRFA/Coo+MUF5+gOaCQ=="],
|
||||
"@tailwindcss/node": ["@tailwindcss/node@4.2.1", "", { "dependencies": { "@jridgewell/remapping": "^2.3.5", "enhanced-resolve": "^5.19.0", "jiti": "^2.6.1", "lightningcss": "1.31.1", "magic-string": "^0.30.21", "source-map-js": "^1.2.1", "tailwindcss": "4.2.1" } }, "sha512-jlx6sLk4EOwO6hHe1oCGm1Q4AN/s0rSrTTPBGPM0/RQ6Uylwq17FuU8IeJJKEjtc6K6O07zsvP+gDO6MMWo7pg=="],
|
||||
|
||||
"@tailwindcss/oxide": ["@tailwindcss/oxide@4.1.18", "", { "optionalDependencies": { "@tailwindcss/oxide-android-arm64": "4.1.18", "@tailwindcss/oxide-darwin-arm64": "4.1.18", "@tailwindcss/oxide-darwin-x64": "4.1.18", "@tailwindcss/oxide-freebsd-x64": "4.1.18", "@tailwindcss/oxide-linux-arm-gnueabihf": "4.1.18", "@tailwindcss/oxide-linux-arm64-gnu": "4.1.18", "@tailwindcss/oxide-linux-arm64-musl": "4.1.18", "@tailwindcss/oxide-linux-x64-gnu": "4.1.18", "@tailwindcss/oxide-linux-x64-musl": "4.1.18", "@tailwindcss/oxide-wasm32-wasi": "4.1.18", "@tailwindcss/oxide-win32-arm64-msvc": "4.1.18", "@tailwindcss/oxide-win32-x64-msvc": "4.1.18" } }, "sha512-EgCR5tTS5bUSKQgzeMClT6iCY3ToqE1y+ZB0AKldj809QXk1Y+3jB0upOYZrn9aGIzPtUsP7sX4QQ4XtjBB95A=="],
|
||||
"@tailwindcss/oxide": ["@tailwindcss/oxide@4.2.1", "", { "optionalDependencies": { "@tailwindcss/oxide-android-arm64": "4.2.1", "@tailwindcss/oxide-darwin-arm64": "4.2.1", "@tailwindcss/oxide-darwin-x64": "4.2.1", "@tailwindcss/oxide-freebsd-x64": "4.2.1", "@tailwindcss/oxide-linux-arm-gnueabihf": "4.2.1", "@tailwindcss/oxide-linux-arm64-gnu": "4.2.1", "@tailwindcss/oxide-linux-arm64-musl": "4.2.1", "@tailwindcss/oxide-linux-x64-gnu": "4.2.1", "@tailwindcss/oxide-linux-x64-musl": "4.2.1", "@tailwindcss/oxide-wasm32-wasi": "4.2.1", "@tailwindcss/oxide-win32-arm64-msvc": "4.2.1", "@tailwindcss/oxide-win32-x64-msvc": "4.2.1" } }, "sha512-yv9jeEFWnjKCI6/T3Oq50yQEOqmpmpfzG1hcZsAOaXFQPfzWprWrlHSdGPEF3WQTi8zu8ohC9Mh9J470nT5pUw=="],
|
||||
|
||||
"@tailwindcss/oxide-android-arm64": ["@tailwindcss/oxide-android-arm64@4.1.18", "", { "os": "android", "cpu": "arm64" }, "sha512-dJHz7+Ugr9U/diKJA0W6N/6/cjI+ZTAoxPf9Iz9BFRF2GzEX8IvXxFIi/dZBloVJX/MZGvRuFA9rqwdiIEZQ0Q=="],
|
||||
"@tailwindcss/oxide-android-arm64": ["@tailwindcss/oxide-android-arm64@4.2.1", "", { "os": "android", "cpu": "arm64" }, "sha512-eZ7G1Zm5EC8OOKaesIKuw77jw++QJ2lL9N+dDpdQiAB/c/B2wDh0QPFHbkBVrXnwNugvrbJFk1gK2SsVjwWReg=="],
|
||||
|
||||
"@tailwindcss/oxide-darwin-arm64": ["@tailwindcss/oxide-darwin-arm64@4.1.18", "", { "os": "darwin", "cpu": "arm64" }, "sha512-Gc2q4Qhs660bhjyBSKgq6BYvwDz4G+BuyJ5H1xfhmDR3D8HnHCmT/BSkvSL0vQLy/nkMLY20PQ2OoYMO15Jd0A=="],
|
||||
"@tailwindcss/oxide-darwin-arm64": ["@tailwindcss/oxide-darwin-arm64@4.2.1", "", { "os": "darwin", "cpu": "arm64" }, "sha512-q/LHkOstoJ7pI1J0q6djesLzRvQSIfEto148ppAd+BVQK0JYjQIFSK3JgYZJa+Yzi0DDa52ZsQx2rqytBnf8Hw=="],
|
||||
|
||||
"@tailwindcss/oxide-darwin-x64": ["@tailwindcss/oxide-darwin-x64@4.1.18", "", { "os": "darwin", "cpu": "x64" }, "sha512-FL5oxr2xQsFrc3X9o1fjHKBYBMD1QZNyc1Xzw/h5Qu4XnEBi3dZn96HcHm41c/euGV+GRiXFfh2hUCyKi/e+yw=="],
|
||||
"@tailwindcss/oxide-darwin-x64": ["@tailwindcss/oxide-darwin-x64@4.2.1", "", { "os": "darwin", "cpu": "x64" }, "sha512-/f/ozlaXGY6QLbpvd/kFTro2l18f7dHKpB+ieXz+Cijl4Mt9AI2rTrpq7V+t04nK+j9XBQHnSMdeQRhbGyt6fw=="],
|
||||
|
||||
"@tailwindcss/oxide-freebsd-x64": ["@tailwindcss/oxide-freebsd-x64@4.1.18", "", { "os": "freebsd", "cpu": "x64" }, "sha512-Fj+RHgu5bDodmV1dM9yAxlfJwkkWvLiRjbhuO2LEtwtlYlBgiAT4x/j5wQr1tC3SANAgD+0YcmWVrj8R9trVMA=="],
|
||||
"@tailwindcss/oxide-freebsd-x64": ["@tailwindcss/oxide-freebsd-x64@4.2.1", "", { "os": "freebsd", "cpu": "x64" }, "sha512-5e/AkgYJT/cpbkys/OU2Ei2jdETCLlifwm7ogMC7/hksI2fC3iiq6OcXwjibcIjPung0kRtR3TxEITkqgn0TcA=="],
|
||||
|
||||
"@tailwindcss/oxide-linux-arm-gnueabihf": ["@tailwindcss/oxide-linux-arm-gnueabihf@4.1.18", "", { "os": "linux", "cpu": "arm" }, "sha512-Fp+Wzk/Ws4dZn+LV2Nqx3IilnhH51YZoRaYHQsVq3RQvEl+71VGKFpkfHrLM/Li+kt5c0DJe/bHXK1eHgDmdiA=="],
|
||||
"@tailwindcss/oxide-linux-arm-gnueabihf": ["@tailwindcss/oxide-linux-arm-gnueabihf@4.2.1", "", { "os": "linux", "cpu": "arm" }, "sha512-Uny1EcVTTmerCKt/1ZuKTkb0x8ZaiuYucg2/kImO5A5Y/kBz41/+j0gxUZl+hTF3xkWpDmHX+TaWhOtba2Fyuw=="],
|
||||
|
||||
"@tailwindcss/oxide-linux-arm64-gnu": ["@tailwindcss/oxide-linux-arm64-gnu@4.1.18", "", { "os": "linux", "cpu": "arm64" }, "sha512-S0n3jboLysNbh55Vrt7pk9wgpyTTPD0fdQeh7wQfMqLPM/Hrxi+dVsLsPrycQjGKEQk85Kgbx+6+QnYNiHalnw=="],
|
||||
"@tailwindcss/oxide-linux-arm64-gnu": ["@tailwindcss/oxide-linux-arm64-gnu@4.2.1", "", { "os": "linux", "cpu": "arm64" }, "sha512-CTrwomI+c7n6aSSQlsPL0roRiNMDQ/YzMD9EjcR+H4f0I1SQ8QqIuPnsVp7QgMkC1Qi8rtkekLkOFjo7OlEFRQ=="],
|
||||
|
||||
"@tailwindcss/oxide-linux-arm64-musl": ["@tailwindcss/oxide-linux-arm64-musl@4.1.18", "", { "os": "linux", "cpu": "arm64" }, "sha512-1px92582HkPQlaaCkdRcio71p8bc8i/ap5807tPRDK/uw953cauQBT8c5tVGkOwrHMfc2Yh6UuxaH4vtTjGvHg=="],
|
||||
"@tailwindcss/oxide-linux-arm64-musl": ["@tailwindcss/oxide-linux-arm64-musl@4.2.1", "", { "os": "linux", "cpu": "arm64" }, "sha512-WZA0CHRL/SP1TRbA5mp9htsppSEkWuQ4KsSUumYQnyl8ZdT39ntwqmz4IUHGN6p4XdSlYfJwM4rRzZLShHsGAQ=="],
|
||||
|
||||
"@tailwindcss/oxide-linux-x64-gnu": ["@tailwindcss/oxide-linux-x64-gnu@4.1.18", "", { "os": "linux", "cpu": "x64" }, "sha512-v3gyT0ivkfBLoZGF9LyHmts0Isc8jHZyVcbzio6Wpzifg/+5ZJpDiRiUhDLkcr7f/r38SWNe7ucxmGW3j3Kb/g=="],
|
||||
"@tailwindcss/oxide-linux-x64-gnu": ["@tailwindcss/oxide-linux-x64-gnu@4.2.1", "", { "os": "linux", "cpu": "x64" }, "sha512-qMFzxI2YlBOLW5PhblzuSWlWfwLHaneBE0xHzLrBgNtqN6mWfs+qYbhryGSXQjFYB1Dzf5w+LN5qbUTPhW7Y5g=="],
|
||||
|
||||
"@tailwindcss/oxide-linux-x64-musl": ["@tailwindcss/oxide-linux-x64-musl@4.1.18", "", { "os": "linux", "cpu": "x64" }, "sha512-bhJ2y2OQNlcRwwgOAGMY0xTFStt4/wyU6pvI6LSuZpRgKQwxTec0/3Scu91O8ir7qCR3AuepQKLU/kX99FouqQ=="],
|
||||
"@tailwindcss/oxide-linux-x64-musl": ["@tailwindcss/oxide-linux-x64-musl@4.2.1", "", { "os": "linux", "cpu": "x64" }, "sha512-5r1X2FKnCMUPlXTWRYpHdPYUY6a1Ar/t7P24OuiEdEOmms5lyqjDRvVY1yy9Rmioh+AunQ0rWiOTPE8F9A3v5g=="],
|
||||
|
||||
"@tailwindcss/oxide-wasm32-wasi": ["@tailwindcss/oxide-wasm32-wasi@4.1.18", "", { "dependencies": { "@emnapi/core": "^1.7.1", "@emnapi/runtime": "^1.7.1", "@emnapi/wasi-threads": "^1.1.0", "@napi-rs/wasm-runtime": "^1.1.0", "@tybys/wasm-util": "^0.10.1", "tslib": "^2.4.0" }, "cpu": "none" }, "sha512-LffYTvPjODiP6PT16oNeUQJzNVyJl1cjIebq/rWWBF+3eDst5JGEFSc5cWxyRCJ0Mxl+KyIkqRxk1XPEs9x8TA=="],
|
||||
"@tailwindcss/oxide-wasm32-wasi": ["@tailwindcss/oxide-wasm32-wasi@4.2.1", "", { "dependencies": { "@emnapi/core": "^1.8.1", "@emnapi/runtime": "^1.8.1", "@emnapi/wasi-threads": "^1.1.0", "@napi-rs/wasm-runtime": "^1.1.1", "@tybys/wasm-util": "^0.10.1", "tslib": "^2.8.1" }, "cpu": "none" }, "sha512-MGFB5cVPvshR85MTJkEvqDUnuNoysrsRxd6vnk1Lf2tbiqNlXpHYZqkqOQalydienEWOHHFyyuTSYRsLfxFJ2Q=="],
|
||||
|
||||
"@tailwindcss/oxide-win32-arm64-msvc": ["@tailwindcss/oxide-win32-arm64-msvc@4.1.18", "", { "os": "win32", "cpu": "arm64" }, "sha512-HjSA7mr9HmC8fu6bdsZvZ+dhjyGCLdotjVOgLA2vEqxEBZaQo9YTX4kwgEvPCpRh8o4uWc4J/wEoFzhEmjvPbA=="],
|
||||
"@tailwindcss/oxide-win32-arm64-msvc": ["@tailwindcss/oxide-win32-arm64-msvc@4.2.1", "", { "os": "win32", "cpu": "arm64" }, "sha512-YlUEHRHBGnCMh4Nj4GnqQyBtsshUPdiNroZj8VPkvTZSoHsilRCwXcVKnG9kyi0ZFAS/3u+qKHBdDc81SADTRA=="],
|
||||
|
||||
"@tailwindcss/oxide-win32-x64-msvc": ["@tailwindcss/oxide-win32-x64-msvc@4.1.18", "", { "os": "win32", "cpu": "x64" }, "sha512-bJWbyYpUlqamC8dpR7pfjA0I7vdF6t5VpUGMWRkXVE3AXgIZjYUYAK7II1GNaxR8J1SSrSrppRar8G++JekE3Q=="],
|
||||
"@tailwindcss/oxide-win32-x64-msvc": ["@tailwindcss/oxide-win32-x64-msvc@4.2.1", "", { "os": "win32", "cpu": "x64" }, "sha512-rbO34G5sMWWyrN/idLeVxAZgAKWrn5LiR3/I90Q9MkA67s6T1oB0xtTe+0heoBvHSpbU9Mk7i6uwJnpo4u21XQ=="],
|
||||
|
||||
"@tailwindcss/vite": ["@tailwindcss/vite@4.1.18", "", { "dependencies": { "@tailwindcss/node": "4.1.18", "@tailwindcss/oxide": "4.1.18", "tailwindcss": "4.1.18" }, "peerDependencies": { "vite": "^5.2.0 || ^6 || ^7" } }, "sha512-jVA+/UpKL1vRLg6Hkao5jldawNmRo7mQYrZtNHMIVpLfLhDml5nMRUo/8MwoX2vNXvnaXNNMedrMfMugAVX1nA=="],
|
||||
"@tailwindcss/vite": ["@tailwindcss/vite@4.2.1", "", { "dependencies": { "@tailwindcss/node": "4.2.1", "@tailwindcss/oxide": "4.2.1", "tailwindcss": "4.2.1" }, "peerDependencies": { "vite": "^5.2.0 || ^6 || ^7" } }, "sha512-TBf2sJjYeb28jD2U/OhwdW0bbOsxkWPwQ7SrqGf9sVcoYwZj7rkXljroBO9wKBut9XnmQLXanuDUeqQK0lGg/w=="],
|
||||
|
||||
"@tanstack/devtools-event-client": ["@tanstack/[email protected].0", "", {}, "sha512-RPfGuk2bDZgcu9bAJodvO2lnZeHuz4/71HjZ0bGb/SPg8+lyTA+RLSKQvo7fSmPSi8/vcH3aKQ8EM9ywf1olaw=="],
|
||||
"@tanstack/devtools-event-client": ["@tanstack/[email protected].1", "", {}, "sha512-GRxmPw4OHZ2oZeIEUkEwt/NDvuEqzEYRAjzUVMs+I0pd4C7k1ySOiuJK2CqF+K/yEAR3YZNkW3ExrpDarh9Vwg=="],
|
||||
|
||||
"@tanstack/history": ["@tanstack/[email protected]54.14", "", {}, "sha512-xyIfof8eHBuub1CkBnbKNKQXeRZC4dClhmzePHVOEel4G7lk/dW+TQ16da7CFdeNLv6u6Owf5VoBQxoo6DFTSA=="],
|
||||
"@tanstack/history": ["@tanstack/[email protected]61.4", "", {}, "sha512-Kp/WSt411ZWYvgXy6uiv5RmhHrz9cAml05AQPrtdAp7eUqvIDbMGPnML25OKbzR3RJ1q4wgENxDTvlGPa9+Mww=="],
|
||||
|
||||
"@tanstack/pacer": ["@tanstack/[email protected]", "", { "dependencies": { "@tanstack/devtools-event-client": "^0.4.0", "@tanstack/store": "^0.8.0" } }, "sha512-qhCRSFei0hokQr3xYcQXqxsRD/LKlgHCxHXtKHrQoImp4x2Zu6tUOpUGVH4y2qexIrzSu3aibQBNNfC3Eay6Mg=="],
|
||||
|
||||
@@ -629,25 +636,25 @@
|
||||
|
||||
"@tanstack/react-query": ["@tanstack/[email protected]", "", { "dependencies": { "@tanstack/query-core": "5.90.20" }, "peerDependencies": { "react": "^18 || ^19" } }, "sha512-0Lu6y5t+tvlTJMTO7oh5NSpJfpg/5D41LlThfepTixPYkJ0sE2Jj0m0f6yYqujBwIXlId87e234+MxG3D3g7kg=="],
|
||||
|
||||
"@tanstack/react-router": ["@tanstack/[email protected]0.2", "", { "dependencies": { "@tanstack/history": "1.154.14", "@tanstack/react-store": "^0.8.0", "@tanstack/router-core": "1.160.0", "isbot": "^5.1.22", "tiny-invariant": "^1.3.3", "tiny-warning": "^1.0.3" }, "peerDependencies": { "react": ">=18.0.0 || >=19.0.0", "react-dom": ">=18.0.0 || >=19.0.0" } }, "sha512-EJWAMS4qCfWKNCzzYGy6ZuWTdBATYEEWieaQdmM7zUesyOQ01j7o6aKXdmCp9rWuSKjPHXagWubEnEo+Puhi3w=="],
|
||||
"@tanstack/react-router": ["@tanstack/[email protected]6.2", "", { "dependencies": { "@tanstack/history": "1.161.4", "@tanstack/react-store": "^0.9.1", "@tanstack/router-core": "1.166.2", "isbot": "^5.1.22", "tiny-invariant": "^1.3.3", "tiny-warning": "^1.0.3" }, "peerDependencies": { "react": ">=18.0.0 || >=19.0.0", "react-dom": ">=18.0.0 || >=19.0.0" } }, "sha512-pKhUtrvVLlhjWhsHkJSuIzh1J4LcP+8ErbIqRLORX9Js8dUFMKoT0+8oFpi+P8QRpuhm/7rzjYiWfcyTsqQZtA=="],
|
||||
|
||||
"@tanstack/react-store": ["@tanstack/[email protected]", "", { "dependencies": { "@tanstack/store": "0.8.1", "use-sync-external-store": "^1.6.0" }, "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-XItJt+rG8c5Wn/2L/bnxys85rBpm0BfMbhb4zmPVLXAKY9POrp1xd6IbU4PKoOI+jSEGc3vntPRfLGSgXfE2Ig=="],
|
||||
|
||||
"@tanstack/react-virtual": ["@tanstack/[email protected].18", "", { "dependencies": { "@tanstack/virtual-core": "3.13.18" }, "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-dZkhyfahpvlaV0rIKnvQiVoWPyURppl6w4m9IwMDpuIjcJ1sD9YGWrt0wISvgU7ewACXx2Ct46WPgI6qAD4v6A=="],
|
||||
"@tanstack/react-virtual": ["@tanstack/[email protected].20", "", { "dependencies": { "@tanstack/virtual-core": "3.13.20" }, "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-LkFkwMMKKJ0zcbN4s37hTbj+22sHCXpaqV6+kh2x74aFg59kKCfdeeKtvCETVw8vP8oqtoWo+v+3JWkuGLqF/A=="],
|
||||
|
||||
"@tanstack/router-core": ["@tanstack/[email protected]0.0", "", { "dependencies": { "@tanstack/history": "1.154.14", "@tanstack/store": "^0.8.0", "cookie-es": "^2.0.0", "seroval": "^1.4.2", "seroval-plugins": "^1.4.2", "tiny-invariant": "^1.3.3", "tiny-warning": "^1.0.3" } }, "sha512-vbh6OsE0MG+0c+SKh2uk5yEEZlWsxT96Ub2JaTs7ixOvZp3Wu9PTEIe2BA3cShNZhEsDI0Le4NqgY4XIaHLLvA=="],
|
||||
"@tanstack/router-core": ["@tanstack/[email protected]6.2", "", { "dependencies": { "@tanstack/history": "1.161.4", "@tanstack/store": "^0.9.1", "cookie-es": "^2.0.0", "seroval": "^1.4.2", "seroval-plugins": "^1.4.2", "tiny-invariant": "^1.3.3", "tiny-warning": "^1.0.3" } }, "sha512-zn3NhENOAX9ToQiX077UV2OH3aJKOvV2ZMNZZxZ3gDG3i3WqL8NfWfEgetEAfMN37/Mnt90PpotYgf7IyuoKqQ=="],
|
||||
|
||||
"@tanstack/router-generator": ["@tanstack/[email protected]0.1", "", { "dependencies": { "@tanstack/router-core": "1.160.0", "@tanstack/router-utils": "1.158.0", "@tanstack/virtual-file-routes": "1.154.7", "prettier": "^3.5.0", "recast": "^0.23.11", "source-map": "^0.7.4", "tsx": "^4.19.2", "zod": "^3.24.2" } }, "sha512-De6TicInwy3/9rQ++RZAyFOvB2oi5UV5T0iiIlxe3jgiOLFxMA4EKKVlT+alDxKnq6udTLam9xqhvGOVZ6a2hw=="],
|
||||
"@tanstack/router-generator": ["@tanstack/[email protected]6.2", "", { "dependencies": { "@tanstack/router-core": "1.166.2", "@tanstack/router-utils": "1.161.4", "@tanstack/virtual-file-routes": "1.161.4", "prettier": "^3.5.0", "recast": "^0.23.11", "source-map": "^0.7.4", "tsx": "^4.19.2", "zod": "^3.24.2" } }, "sha512-wbvdyP1PKKQKk4aVlGeK9S5uDy8zodTr3tEZ2gRKNavJLusXbEWqtoo42JxHFFNB6dtguehFMt8PyZPAtkgWwQ=="],
|
||||
|
||||
"@tanstack/router-plugin": ["@tanstack/[email protected]1.0", "", { "dependencies": { "@babel/core": "^7.28.5", "@babel/plugin-syntax-jsx": "^7.27.1", "@babel/plugin-syntax-typescript": "^7.27.1", "@babel/template": "^7.27.2", "@babel/traverse": "^7.28.5", "@babel/types": "^7.28.5", "@tanstack/router-core": "1.160.0", "@tanstack/router-generator": "1.160.1", "@tanstack/router-utils": "1.158.0", "@tanstack/virtual-file-routes": "1.154.7", "chokidar": "^3.6.0", "unplugin": "^2.1.2", "zod": "^3.24.2" }, "peerDependencies": { "@rsbuild/core": ">=1.0.2", "@tanstack/react-router": "^1.160.2", "vite": ">=5.0.0 || >=6.0.0 || >=7.0.0", "vite-plugin-solid": "^2.11.10", "webpack": ">=5.92.0" }, "optionalPeers": ["@rsbuild/core", "@tanstack/react-router", "vite", "vite-plugin-solid", "webpack"] }, "sha512-E0JGeMdKGYYMMjOEiM+330nIs0PG3nE/9KyU+7+SV54hDf4Xdt6BC3J9pDj1qA3oNqI5DwwTsG7GBA+7m47O4A=="],
|
||||
"@tanstack/router-plugin": ["@tanstack/[email protected]6.2", "", { "dependencies": { "@babel/core": "^7.28.5", "@babel/plugin-syntax-jsx": "^7.27.1", "@babel/plugin-syntax-typescript": "^7.27.1", "@babel/template": "^7.27.2", "@babel/traverse": "^7.28.5", "@babel/types": "^7.28.5", "@tanstack/router-core": "1.166.2", "@tanstack/router-generator": "1.166.2", "@tanstack/router-utils": "1.161.4", "@tanstack/virtual-file-routes": "1.161.4", "chokidar": "^3.6.0", "unplugin": "^2.1.2", "zod": "^3.24.2" }, "peerDependencies": { "@rsbuild/core": ">=1.0.2", "@tanstack/react-router": "^1.166.2", "vite": ">=5.0.0 || >=6.0.0 || >=7.0.0", "vite-plugin-solid": "^2.11.10", "webpack": ">=5.92.0" }, "optionalPeers": ["@rsbuild/core", "@tanstack/react-router", "vite", "vite-plugin-solid", "webpack"] }, "sha512-TnyV/7//Vp5fR49mmNbOWHGz9IJTm1lqVxzPdtpzg7D5PjkW2HFmLFLtWwpJgz2R7AJJWR4Ge5kIPmC+fVZ6eQ=="],
|
||||
|
||||
"@tanstack/router-utils": ["@tanstack/[email protected]58.0", "", { "dependencies": { "@babel/core": "^7.28.5", "@babel/generator": "^7.28.5", "@babel/parser": "^7.28.5", "@babel/types": "^7.28.5", "ansis": "^4.1.0", "babel-dead-code-elimination": "^1.0.12", "diff": "^8.0.2", "pathe": "^2.0.3", "tinyglobby": "^0.2.15" } }, "sha512-qZ76eaLKU6Ae9iI/mc5zizBX149DXXZkBVVO3/QRIll79uKLJZHQlMKR++2ba7JsciBWz1pgpIBcCJPE9S0LVg=="],
|
||||
"@tanstack/router-utils": ["@tanstack/[email protected]61.4", "", { "dependencies": { "@babel/core": "^7.28.5", "@babel/generator": "^7.28.5", "@babel/parser": "^7.28.5", "@babel/types": "^7.28.5", "ansis": "^4.1.0", "babel-dead-code-elimination": "^1.0.12", "diff": "^8.0.2", "pathe": "^2.0.3", "tinyglobby": "^0.2.15" } }, "sha512-r8TpjyIZoqrXXaf2DDyjd44gjGBoyE+/oEaaH68yLI9ySPO1gUWmQENZ1MZnmBnpUGN24NOZxdjDLc8npK0SAw=="],
|
||||
|
||||
"@tanstack/store": ["@tanstack/store@0.8.1", "", {}, "sha512-PtOisLjUZPz5VyPRSCGjNOlwTvabdTBQ2K80DpVL1chGVr35WRxfeavAPdNq6pm/t7F8GhoR2qtmkkqtCEtHYw=="],
|
||||
"@tanstack/store": ["@tanstack/store@0.9.1", "", {}, "sha512-+qcNkOy0N1qSGsP7omVCW0SDrXtaDcycPqBDE726yryiA5eTDFpjBReaYjghVJwNf1pcPMyzIwTGlYjCSQR0Fg=="],
|
||||
|
||||
"@tanstack/virtual-core": ["@tanstack/[email protected].18", "", {}, "sha512-Mx86Hqu1k39icq2Zusq+Ey2J6dDWTjDvEv43PJtRCoEYTLyfaPnxIQ6iy7YAOK0NV/qOEmZQ/uCufrppZxTgcg=="],
|
||||
"@tanstack/virtual-core": ["@tanstack/[email protected].20", "", {}, "sha512-Djnq7ujPWcRAKyDpwqL4JDe6ZTN9AWAqE2wLstBlsEu4OnO7Im0p8KsHzLU7TPIvLQgNKpkn9EmgBH6xs8yjfA=="],
|
||||
|
||||
"@tanstack/virtual-file-routes": ["@tanstack/[email protected]54.7", "", {}, "sha512-cHHDnewHozgjpI+MIVp9tcib6lYEQK5MyUr0ChHpHFGBl8Xei55rohFK0I0ve/GKoHeioaK42Smd8OixPp6CTg=="],
|
||||
"@tanstack/virtual-file-routes": ["@tanstack/[email protected]61.4", "", {}, "sha512-42WoRePf8v690qG8yGRe/YOh+oHni9vUaUUfoqlS91U2scd3a5rkLtVsc6b7z60w3RogH0I00vdrC5AaeiZ18w=="],
|
||||
|
||||
"@tybys/wasm-util": ["@tybys/[email protected]", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg=="],
|
||||
|
||||
@@ -659,7 +666,7 @@
|
||||
|
||||
"@types/babel__traverse": ["@types/[email protected]", "", { "dependencies": { "@babel/types": "^7.28.2" } }, "sha512-8PvcXf70gTDZBgt9ptxJ8elBeBjcLOAcOtoO/mPJjtji1+CdGbHgm77om1GrsPxsiE+uXIpNSK64UYaIwQXd4Q=="],
|
||||
|
||||
"@types/bun": ["@types/[email protected].9", "", { "dependencies": { "bun-types": "1.3.9" } }, "sha512-KQ571yULOdWJiMH+RIWIOZ7B2RXQGpL1YQrBtLIV3FqDcCu6FsbFUBwhdKUlCKUpS3PJDsHlJ1QKlpxoVR+xtw=="],
|
||||
"@types/bun": ["@types/[email protected].10", "", { "dependencies": { "bun-types": "1.3.10" } }, "sha512-0+rlrUrOrTSskibryHbvQkDOWRJwJZqZlxrUs1u4oOoTln8+WIXBPmAuCF35SWB2z4Zl3E84Nl/D0P7803nigQ=="],
|
||||
|
||||
"@types/cacheable-request": ["@types/[email protected]", "", { "dependencies": { "@types/http-cache-semantics": "*", "@types/keyv": "^3.1.4", "@types/node": "*", "@types/responselike": "^1.0.0" } }, "sha512-IQ3EbTzGxIigb1I3qPZc1rWJnH0BmSKv5QYTalEwweFvyBDLSAe24zP0le/hyi7ecGfZVlIVAg4BZqb8WBwKqw=="],
|
||||
|
||||
@@ -685,7 +692,7 @@
|
||||
|
||||
"@types/ms": ["@types/[email protected]", "", {}, "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA=="],
|
||||
|
||||
"@types/node": ["@types/[email protected]0.13", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-oH72nZRfDv9lADUBSo104Aq7gPHpQZc4BTx38r9xf9pg5LfP6EzSyH2n7qFmmxRQXh7YlUXODcYsg6PuTDSxGg=="],
|
||||
"@types/node": ["@types/[email protected]1.2", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-HTsxyfkxTNxOXBsEdgIOzbMgBjDGPvkTfw0B1m09j1LFPk8u3tSL8SNBRTSc381wXXX/Wp93qPi1kQXwnWuHgA=="],
|
||||
|
||||
"@types/react": ["@types/[email protected]", "", { "dependencies": { "csstype": "^3.2.2" } }, "sha512-ilcTH/UniCkMdtexkoCN0bI7pMcJDvmQFPvuPvmEaYA/NSfFTAgdUSLAoVjaRJm7+6PvcM+q1zYOwS4wTYMF9w=="],
|
||||
|
||||
@@ -727,7 +734,7 @@
|
||||
|
||||
"@xterm/xterm": ["@xterm/[email protected]", "", {}, "sha512-TQwDdQGtwwDt+2cgKDLn0IRaSxYu1tSUjgKarSDkUM0ZNiSRXFpjxEsvc/Zgc5kq5omJ+V0a8/kIM2WD3sMOYg=="],
|
||||
|
||||
"acorn": ["[email protected]5.0", "", { "bin": { "acorn": "bin/acorn" } }, "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg=="],
|
||||
"acorn": ["[email protected]6.0", "", { "bin": { "acorn": "bin/acorn" } }, "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw=="],
|
||||
|
||||
"ansi-regex": ["[email protected]", "", {}, "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ=="],
|
||||
|
||||
@@ -747,7 +754,7 @@
|
||||
|
||||
"asynckit": ["[email protected]", "", {}, "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="],
|
||||
|
||||
"axios": ["[email protected].5", "", { "dependencies": { "follow-redirects": "^1.15.11", "form-data": "^4.0.5", "proxy-from-env": "^1.1.0" } }, "sha512-cz4ur7Vb0xS4/KUN0tPWe44eqxrIu31me+fbang3ijiNscE129POzipJJA6zniq2C/Z6sJCjMimjS8Lc/GAs8Q=="],
|
||||
"axios": ["[email protected].6", "", { "dependencies": { "follow-redirects": "^1.15.11", "form-data": "^4.0.5", "proxy-from-env": "^1.1.0" } }, "sha512-ChTCHMouEe2kn713WHbQGcuYrr6fXTBiu460OTwWrWob16g1bXn4vtz07Ope7ewMozJAnEquLk5lWQWtBig9DQ=="],
|
||||
|
||||
"babel-dead-code-elimination": ["[email protected]", "", { "dependencies": { "@babel/core": "^7.23.7", "@babel/parser": "^7.23.6", "@babel/traverse": "^7.23.7", "@babel/types": "^7.23.6" } }, "sha512-GERT7L2TiYcYDtYk1IpD+ASAYXjKbLTDPhBtYj7X1NuRMDTMtAx9kyBenub1Ev41lo91OHCKdmP+egTDmfQ7Ig=="],
|
||||
|
||||
@@ -755,7 +762,7 @@
|
||||
|
||||
"bail": ["[email protected]", "", {}, "sha512-0xO6mYd7JB2YesxDKplafRpsiOzPt9V02ddPCLbY1xYGPOX24NTyN50qnUxgCPcSoYMhKpAuBTjQoRZCAkUDRw=="],
|
||||
|
||||
"baseline-browser-mapping": ["baseline-browser-mapping@2.9.19", "", { "bin": { "baseline-browser-mapping": "dist/cli.js" } }, "sha512-ipDqC8FrAl/76p2SSWKSI+H9tFwm7vYqXQrItCuiVPt26Km0jS+NzSsBWAaBusvSbQcfJG+JitdMm+wZAgTYqg=="],
|
||||
"baseline-browser-mapping": ["baseline-browser-mapping@2.10.0", "", { "bin": { "baseline-browser-mapping": "dist/cli.cjs" } }, "sha512-lIyg0szRfYbiy67j9KN8IyeD7q7hcmqnJ1ddWmNt19ItGpNN64mnllmxUNFIOdOm6by97jlL6wfpTTJrmnjWAA=="],
|
||||
|
||||
"binary-extensions": ["[email protected]", "", {}, "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw=="],
|
||||
|
||||
@@ -771,7 +778,7 @@
|
||||
|
||||
"builder-util-runtime": ["[email protected]", "", { "dependencies": { "debug": "^4.3.4", "sax": "^1.2.4" } }, "sha512-qt41tMfgHTllhResqM5DcnHyDIWNgzHvuY2jDcYP9iaGpkWxTUzV6GQjDeLnlR1/DtdlcsWQbA7sByMpmJFTLQ=="],
|
||||
|
||||
"bun-types": ["[email protected].9", "", { "dependencies": { "@types/node": "*" } }, "sha512-+UBWWOakIP4Tswh0Bt0QD0alpTY8cb5hvgiYeWCMet9YukHbzuruIEeXC2D7nMJPB12kbh8C7XJykSexEqGKJg=="],
|
||||
"bun-types": ["[email protected].10", "", { "dependencies": { "@types/node": "*" } }, "sha512-tcpfCCl6XWo6nCVnpcVrxQ+9AYN1iqMIzgrSKYMB/fjLtV2eyAVEg7AxQJuCq/26R6HpKWykQXuSOq/21RYcbg=="],
|
||||
|
||||
"bundle-name": ["[email protected]", "", { "dependencies": { "run-applescript": "^7.0.0" } }, "sha512-tjwM5exMg6BGRI+kNmTntNsvdZS1X8BFYS6tnJ2hdH0kVxM6/eVZ2xy+FqStSWvYmtfFMDLIxurorHwDKfDz5Q=="],
|
||||
|
||||
@@ -783,7 +790,7 @@
|
||||
|
||||
"call-bind-apply-helpers": ["[email protected]", "", { "dependencies": { "es-errors": "^1.3.0", "function-bind": "^1.1.2" } }, "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ=="],
|
||||
|
||||
"caniuse-lite": ["[email protected]9", "", {}, "sha512-BCfFL1sHijQlBGWBMuJyhZUhzo7wer5sVj9hqekB/7xn0Ypy+pER/edCYQm4exbXj4WiySGp40P8UuTh6w1srg=="],
|
||||
"caniuse-lite": ["[email protected]76", "", {}, "sha512-sg01JDPzZ9jGshqKSckOQthXnYwOEP50jeVFhaSFbZcOy05TiuuaffDOfcwtCisJ9kNQuLBFibYywv2Bgm9osw=="],
|
||||
|
||||
"ccount": ["[email protected]", "", {}, "sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg=="],
|
||||
|
||||
@@ -869,7 +876,7 @@
|
||||
|
||||
"electron": ["[email protected]", "", { "dependencies": { "@electron/get": "^2.0.0", "@types/node": "^24.9.0", "extract-zip": "^2.0.1" }, "bin": { "electron": "cli.js" } }, "sha512-ett8W+yOFGDuM0vhJMamYSkrbV3LoaffzJd9GfjI96zRAxyrNqUSKqBpf/WGbQCweDxX2pkUCUfrv4wwKpsFZA=="],
|
||||
|
||||
"electron-to-chromium": ["[email protected].286", "", {}, "sha512-9tfDXhJ4RKFNerfjdCcZfufu49vg620741MNs26a9+bhLThdB+plgMeou98CAaHu/WATj2iHOOHTp1hWtABj2A=="],
|
||||
"electron-to-chromium": ["[email protected].307", "", {}, "sha512-5z3uFKBWjiNR44nFcYdkcXjKMbg5KXNdciu7mhTPo9tB7NbqSNP2sSnGR+fqknZSCwKkBN+oxiiajWs4dT6ORg=="],
|
||||
|
||||
"electron-updater": ["[email protected]", "", { "dependencies": { "builder-util-runtime": "9.5.1", "fs-extra": "^10.1.0", "js-yaml": "^4.1.0", "lazy-val": "^1.0.5", "lodash.escaperegexp": "^4.1.2", "lodash.isequal": "^4.5.0", "semver": "~7.7.3", "tiny-typed-emitter": "^2.1.0" } }, "sha512-Z6sgw3jgbikWKXei1ENdqFOxBP0WlXg3TtKfz0rgw2vIZFJUyI4pD7ZN7jrkm7EoMK+tcm/qTnPUdqfZukBlBQ=="],
|
||||
|
||||
@@ -879,7 +886,7 @@
|
||||
|
||||
"end-of-stream": ["[email protected]", "", { "dependencies": { "once": "^1.4.0" } }, "sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg=="],
|
||||
|
||||
"enhanced-resolve": ["enhanced-resolve@5.19.0", "", { "dependencies": { "graceful-fs": "^4.2.4", "tapable": "^2.3.0" } }, "sha512-phv3E1Xl4tQOShqSte26C7Fl84EwUdZsyOuSSk9qtAGyyQs2s3jJzComh+Abf4g187lUUAvH+H26omrqia2aGg=="],
|
||||
"enhanced-resolve": ["enhanced-resolve@5.20.0", "", { "dependencies": { "graceful-fs": "^4.2.4", "tapable": "^2.3.0" } }, "sha512-/ce7+jQ1PQ6rVXwe+jKEg5hW5ciicHwIQUagZkp6IufBoY3YDgdTTY1azVs0qoRgVmvsNB+rbjLJxDAeHHtwsQ=="],
|
||||
|
||||
"env-paths": ["[email protected]", "", {}, "sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A=="],
|
||||
|
||||
@@ -957,7 +964,7 @@
|
||||
|
||||
"graceful-fs": ["[email protected]", "", {}, "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ=="],
|
||||
|
||||
"graphql": ["[email protected]2.0", "", {}, "sha512-DKKrynuQRne0PNpEbzuEdHlYOMksHSUI8Zc9Unei5gTsMNA2/vMpoMz/yKba50pejK56qj98qM0SjYxAKi13gQ=="],
|
||||
"graphql": ["[email protected]3.1", "", {}, "sha512-gGgrVCoDKlIZ8fIqXBBb0pPKqDgki0Z/FSKNiQzSGj2uEYHr1tq5wmBegGwJx6QB5S5cM0khSBpi/JFHMCvsmQ=="],
|
||||
|
||||
"has-property-descriptors": ["[email protected]", "", { "dependencies": { "es-define-property": "^1.0.0" } }, "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg=="],
|
||||
|
||||
@@ -991,7 +998,7 @@
|
||||
|
||||
"inline-style-parser": ["[email protected]", "", {}, "sha512-Nb2ctOyNR8DqQoR0OwRG95uNWIC0C1lCgf5Naz5H6Ji72KZ8OcFZLz2P5sNgwlyoJ8Yif11oMuYs5pBQa86csA=="],
|
||||
|
||||
"ioredis": ["ioredis@5.9.3", "", { "dependencies": { "@ioredis/commands": "1.5.0", "cluster-key-slot": "^1.1.0", "debug": "^4.3.4", "denque": "^2.1.0", "lodash.defaults": "^4.2.0", "lodash.isarguments": "^3.1.0", "redis-errors": "^1.2.0", "redis-parser": "^3.0.0", "standard-as-callback": "^2.1.0" } }, "sha512-VI5tMCdeoxZWU5vjHWsiE/Su76JGhBvWF1MJnV9ZtGltHk9BmD48oDq8Tj8haZ85aceXZMxLNDQZRVo5QKNgXA=="],
|
||||
"ioredis": ["ioredis@5.10.0", "", { "dependencies": { "@ioredis/commands": "1.5.1", "cluster-key-slot": "^1.1.0", "debug": "^4.3.4", "denque": "^2.1.0", "lodash.defaults": "^4.2.0", "lodash.isarguments": "^3.1.0", "redis-errors": "^1.2.0", "redis-parser": "^3.0.0", "standard-as-callback": "^2.1.0" } }, "sha512-HVBe9OFuqs+Z6n64q09PQvP1/R4Bm+30PAyyD4wIEqssh3v9L21QjCVk4kRLucMBcDokJTcLjsGeVRlq/nH6DA=="],
|
||||
|
||||
"is-alphabetical": ["[email protected]", "", {}, "sha512-FWyyY60MeTNyeSRpkM2Iry0G9hpr7/9kD40mD/cGQEuilcZYS4okz8SN2Q6rLCJ8gbCt6fN+rC+6tMGS99LaxQ=="],
|
||||
|
||||
@@ -1019,7 +1026,7 @@
|
||||
|
||||
"is-plain-obj": ["[email protected]", "", {}, "sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg=="],
|
||||
|
||||
"is-wsl": ["[email protected].0", "", { "dependencies": { "is-inside-container": "^1.0.0" } }, "sha512-UcVfVfaK4Sc4m7X3dUSoHoozQGBEFeDC+zVo06t98xe8CzHSZZBekNXH+tu0NalHolcJ/QAGqS46Hef7QXBIMw=="],
|
||||
"is-wsl": ["[email protected].1", "", { "dependencies": { "is-inside-container": "^1.0.0" } }, "sha512-e6rvdUCiQCAuumZslxRJWR/Doq4VpPR82kqclvcS0efgt430SlGIk05vdCN58+VrzgtIcfNODjozVielycD4Sw=="],
|
||||
|
||||
"isbot": ["[email protected]", "", {}, "sha512-waFfC72ZNfwLLuJ2iLaoVaqcNo+CAaLR7xCpAn0Y5WfGzkNHv7ZN39Vbi1y+kb+Zs46XHOX3tZNExroFUPX+Kg=="],
|
||||
|
||||
@@ -1107,7 +1114,7 @@
|
||||
|
||||
"mdast-util-find-and-replace": ["[email protected]", "", { "dependencies": { "@types/mdast": "^4.0.0", "escape-string-regexp": "^5.0.0", "unist-util-is": "^6.0.0", "unist-util-visit-parents": "^6.0.0" } }, "sha512-Tmd1Vg/m3Xz43afeNxDIhWRtFZgM2VLyaf4vSTYwudTyeuTneoL3qtWMA5jeLyz/O1vDJmmV4QuScFCA2tBPwg=="],
|
||||
|
||||
"mdast-util-from-markdown": ["[email protected].2", "", { "dependencies": { "@types/mdast": "^4.0.0", "@types/unist": "^3.0.0", "decode-named-character-reference": "^1.0.0", "devlop": "^1.0.0", "mdast-util-to-string": "^4.0.0", "micromark": "^4.0.0", "micromark-util-decode-numeric-character-reference": "^2.0.0", "micromark-util-decode-string": "^2.0.0", "micromark-util-normalize-identifier": "^2.0.0", "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0", "unist-util-stringify-position": "^4.0.0" } }, "sha512-uZhTV/8NBuw0WHkPTrCqDOl0zVe1BIng5ZtHoDk49ME1qqcjYmmLmOf0gELgcRMxN4w2iuIeVso5/6QymSrgmA=="],
|
||||
"mdast-util-from-markdown": ["[email protected].3", "", { "dependencies": { "@types/mdast": "^4.0.0", "@types/unist": "^3.0.0", "decode-named-character-reference": "^1.0.0", "devlop": "^1.0.0", "mdast-util-to-string": "^4.0.0", "micromark": "^4.0.0", "micromark-util-decode-numeric-character-reference": "^2.0.0", "micromark-util-decode-string": "^2.0.0", "micromark-util-normalize-identifier": "^2.0.0", "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0", "unist-util-stringify-position": "^4.0.0" } }, "sha512-W4mAWTvSlKvf8L6J+VN9yLSqQ9AOAAvHuoDAmPkz4dHf553m5gVj2ejadHJhoJmcmxEnOv6Pa8XJhpxE93kb8Q=="],
|
||||
|
||||
"mdast-util-gfm": ["[email protected]", "", { "dependencies": { "mdast-util-from-markdown": "^2.0.0", "mdast-util-gfm-autolink-literal": "^2.0.0", "mdast-util-gfm-footnote": "^2.0.0", "mdast-util-gfm-strikethrough": "^2.0.0", "mdast-util-gfm-table": "^2.0.0", "mdast-util-gfm-task-list-item": "^2.0.0", "mdast-util-to-markdown": "^2.0.0" } }, "sha512-0ulfdQOM3ysHhCJ1p06l0b0VKlhU0wuQs3thxZQagjcjPrlFRqY215uZGHHJan9GEAXd9MbfPjFJz+qMkVR6zQ=="],
|
||||
|
||||
@@ -1223,7 +1230,7 @@
|
||||
|
||||
"node-pty": ["[email protected]", "", { "dependencies": { "node-addon-api": "^7.1.0" } }, "sha512-20JqtutY6JPXTUnL0ij1uad7Qe1baT46lyolh2sSENDd4sTzKZ4nmAFkeAARDKwmlLjPx6XKRlwRUxwjOy+lUg=="],
|
||||
|
||||
"node-releases": ["[email protected].27", "", {}, "sha512-nmh3lCkYZ3grZvqcCH+fjmQ7X+H0OeZgP40OierEaAptX4XofMh5kwNbWh7lBduUzCcV/8kZ+NDLCwm2iorIlA=="],
|
||||
"node-releases": ["[email protected].36", "", {}, "sha512-TdC8FSgHz8Mwtw9g5L4gR/Sh9XhSP/0DEkQxfEFXOpiul5IiHgHan2VhYYb6agDSfp4KuvltmGApc8HMgUrIkA=="],
|
||||
|
||||
"normalize-path": ["[email protected]", "", {}, "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA=="],
|
||||
|
||||
@@ -1245,7 +1252,7 @@
|
||||
|
||||
"oxfmt": ["[email protected]", "", { "dependencies": { "tinypool": "2.1.0" }, "optionalDependencies": { "@oxfmt/binding-android-arm-eabi": "0.35.0", "@oxfmt/binding-android-arm64": "0.35.0", "@oxfmt/binding-darwin-arm64": "0.35.0", "@oxfmt/binding-darwin-x64": "0.35.0", "@oxfmt/binding-freebsd-x64": "0.35.0", "@oxfmt/binding-linux-arm-gnueabihf": "0.35.0", "@oxfmt/binding-linux-arm-musleabihf": "0.35.0", "@oxfmt/binding-linux-arm64-gnu": "0.35.0", "@oxfmt/binding-linux-arm64-musl": "0.35.0", "@oxfmt/binding-linux-ppc64-gnu": "0.35.0", "@oxfmt/binding-linux-riscv64-gnu": "0.35.0", "@oxfmt/binding-linux-riscv64-musl": "0.35.0", "@oxfmt/binding-linux-s390x-gnu": "0.35.0", "@oxfmt/binding-linux-x64-gnu": "0.35.0", "@oxfmt/binding-linux-x64-musl": "0.35.0", "@oxfmt/binding-openharmony-arm64": "0.35.0", "@oxfmt/binding-win32-arm64-msvc": "0.35.0", "@oxfmt/binding-win32-ia32-msvc": "0.35.0", "@oxfmt/binding-win32-x64-msvc": "0.35.0" }, "bin": { "oxfmt": "bin/oxfmt" } }, "sha512-QYeXWkP+aLt7utt5SLivNIk09glWx9QE235ODjgcEZ3sd1VMaUBSpLymh6ZRCA76gD2rMP4bXanUz/fx+nLM9Q=="],
|
||||
|
||||
"oxlint": ["[email protected]0.0", "", { "optionalDependencies": { "@oxlint/binding-android-arm-eabi": "1.50.0", "@oxlint/binding-android-arm64": "1.50.0", "@oxlint/binding-darwin-arm64": "1.50.0", "@oxlint/binding-darwin-x64": "1.50.0", "@oxlint/binding-freebsd-x64": "1.50.0", "@oxlint/binding-linux-arm-gnueabihf": "1.50.0", "@oxlint/binding-linux-arm-musleabihf": "1.50.0", "@oxlint/binding-linux-arm64-gnu": "1.50.0", "@oxlint/binding-linux-arm64-musl": "1.50.0", "@oxlint/binding-linux-ppc64-gnu": "1.50.0", "@oxlint/binding-linux-riscv64-gnu": "1.50.0", "@oxlint/binding-linux-riscv64-musl": "1.50.0", "@oxlint/binding-linux-s390x-gnu": "1.50.0", "@oxlint/binding-linux-x64-gnu": "1.50.0", "@oxlint/binding-linux-x64-musl": "1.50.0", "@oxlint/binding-openharmony-arm64": "1.50.0", "@oxlint/binding-win32-arm64-msvc": "1.50.0", "@oxlint/binding-win32-ia32-msvc": "1.50.0", "@oxlint/binding-win32-x64-msvc": "1.50.0" }, "peerDependencies": { "oxlint-tsgolint": ">=0.14.1" }, "optionalPeers": ["oxlint-tsgolint"], "bin": { "oxlint": "bin/oxlint" } }, "sha512-iSJ4IZEICBma8cZX7kxIIz9PzsYLF2FaLAYN6RKu7VwRVKdu7RIgpP99bTZaGl//Yao7fsaGZLSEo5xBrI5ReQ=="],
|
||||
"oxlint": ["[email protected]1.0", "", { "optionalDependencies": { "@oxlint/binding-android-arm-eabi": "1.51.0", "@oxlint/binding-android-arm64": "1.51.0", "@oxlint/binding-darwin-arm64": "1.51.0", "@oxlint/binding-darwin-x64": "1.51.0", "@oxlint/binding-freebsd-x64": "1.51.0", "@oxlint/binding-linux-arm-gnueabihf": "1.51.0", "@oxlint/binding-linux-arm-musleabihf": "1.51.0", "@oxlint/binding-linux-arm64-gnu": "1.51.0", "@oxlint/binding-linux-arm64-musl": "1.51.0", "@oxlint/binding-linux-ppc64-gnu": "1.51.0", "@oxlint/binding-linux-riscv64-gnu": "1.51.0", "@oxlint/binding-linux-riscv64-musl": "1.51.0", "@oxlint/binding-linux-s390x-gnu": "1.51.0", "@oxlint/binding-linux-x64-gnu": "1.51.0", "@oxlint/binding-linux-x64-musl": "1.51.0", "@oxlint/binding-openharmony-arm64": "1.51.0", "@oxlint/binding-win32-arm64-msvc": "1.51.0", "@oxlint/binding-win32-ia32-msvc": "1.51.0", "@oxlint/binding-win32-x64-msvc": "1.51.0" }, "peerDependencies": { "oxlint-tsgolint": ">=0.15.0" }, "optionalPeers": ["oxlint-tsgolint"], "bin": { "oxlint": "bin/oxlint" } }, "sha512-g6DNPaV9/WI9MoX2XllafxQuxwY1TV++j7hP8fTJByVBuCoVtm3dy9f/2vtH/HU40JztcgWF4G7ua+gkainklQ=="],
|
||||
|
||||
"p-cancelable": ["[email protected]", "", {}, "sha512-BZOr3nRQHOntUjTrH8+Lh54smKHoHyur8We1V8DSMVrl5A2malOOwuJRnKRDjSnkoeBh4at6BwEnb5I7Jl31wg=="],
|
||||
|
||||
@@ -1269,7 +1276,7 @@
|
||||
|
||||
"pngjs": ["[email protected]", "", {}, "sha512-LKWqWJRhstyYo9pGvgor/ivk2w94eSjE3RGVuzLGlr3NmD8bf7RcYGze1mNdEHRP6TRP6rMuDHk5t44hnTRyow=="],
|
||||
|
||||
"postcss": ["[email protected].6", "", { "dependencies": { "nanoid": "^3.3.11", "picocolors": "^1.1.1", "source-map-js": "^1.2.1" } }, "sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg=="],
|
||||
"postcss": ["[email protected].8", "", { "dependencies": { "nanoid": "^3.3.11", "picocolors": "^1.1.1", "source-map-js": "^1.2.1" } }, "sha512-OW/rX8O/jXnm82Ey1k44pObPtdblfiuWnrd8X7GJ7emImCOstunGbXUpp7HdBrFQX6rJzn3sPT397Wp5aCwCHg=="],
|
||||
|
||||
"prettier": ["[email protected]", "", { "bin": { "prettier": "bin/prettier.cjs" } }, "sha512-UOnG6LftzbdaHZcKoPFtOcCKztrQ57WkHDeRD9t/PTQtmT0NHSeWWepj6pS0z/N7+08BHFDQVUrfmfMRcZwbMg=="],
|
||||
|
||||
@@ -1281,7 +1288,7 @@
|
||||
|
||||
"proxy-from-env": ["[email protected]", "", {}, "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="],
|
||||
|
||||
"pump": ["[email protected].3", "", { "dependencies": { "end-of-stream": "^1.1.0", "once": "^1.3.1" } }, "sha512-todwxLMY7/heScKmntwQG8CXVkWUOdYxIvY2s0VWAAMh/nd8SoYiRaKjlr7+iCs984f2P8zvrfWcDDYVb73NfA=="],
|
||||
"pump": ["[email protected].4", "", { "dependencies": { "end-of-stream": "^1.1.0", "once": "^1.3.1" } }, "sha512-VS7sjc6KR7e1ukRFhQSY5LM2uBWAUPiOPa/A3mkKmiMwSmRFUITt0xuj+/lesgnCv+dPIEYlkzrcyXgquIHMcA=="],
|
||||
|
||||
"pure-rand": ["[email protected]", "", {}, "sha512-oTUZM/NAZS8p7ANR3SHh30kXB+zK2r2BPcEn/awJIbOvq82WoMN4p62AWWp3Hhw50G0xMsw1mhIBLqHw64EcNQ=="],
|
||||
|
||||
@@ -1337,9 +1344,9 @@
|
||||
|
||||
"rolldown": ["[email protected]", "", { "dependencies": { "@oxc-project/types": "=0.112.0", "@rolldown/pluginutils": "1.0.0-rc.3" }, "optionalDependencies": { "@rolldown/binding-android-arm64": "1.0.0-rc.3", "@rolldown/binding-darwin-arm64": "1.0.0-rc.3", "@rolldown/binding-darwin-x64": "1.0.0-rc.3", "@rolldown/binding-freebsd-x64": "1.0.0-rc.3", "@rolldown/binding-linux-arm-gnueabihf": "1.0.0-rc.3", "@rolldown/binding-linux-arm64-gnu": "1.0.0-rc.3", "@rolldown/binding-linux-arm64-musl": "1.0.0-rc.3", "@rolldown/binding-linux-x64-gnu": "1.0.0-rc.3", "@rolldown/binding-linux-x64-musl": "1.0.0-rc.3", "@rolldown/binding-openharmony-arm64": "1.0.0-rc.3", "@rolldown/binding-wasm32-wasi": "1.0.0-rc.3", "@rolldown/binding-win32-arm64-msvc": "1.0.0-rc.3", "@rolldown/binding-win32-x64-msvc": "1.0.0-rc.3" }, "bin": { "rolldown": "bin/cli.mjs" } }, "sha512-Po/YZECDOqVXjIXrtC5h++a5NLvKAQNrd9ggrIG3sbDfGO5BqTUsrI6l8zdniKRp3r5Tp/2JTrXqx4GIguFCMw=="],
|
||||
|
||||
"rolldown-plugin-dts": ["[email protected].1", "", { "dependencies": { "@babel/generator": "8.0.0-rc.1", "@babel/helper-validator-identifier": "8.0.0-rc.1", "@babel/parser": "8.0.0-rc.1", "@babel/types": "8.0.0-rc.1", "ast-kit": "^3.0.0-beta.1", "birpc": "^4.0.0", "dts-resolver": "^2.1.3", "get-tsconfig": "^4.13.1", "obug": "^2.1.1" }, "peerDependencies": { "@ts-macro/tsc": "^0.3.6", "@typescript/native-preview": ">=7.0.0-dev.20250601.1", "rolldown": "^1.0.0-rc.3", "typescript": "^5.0.0", "vue-tsc": "~3.2.0" }, "optionalPeers": ["@ts-macro/tsc", "@typescript/native-preview", "typescript", "vue-tsc"] }, "sha512-5E0AiM5RSQhU6cjtkDFWH6laW4IrMu0j1Mo8x04Xo1ALHmaRMs9/7zej7P3RrryVHW/DdZAp85MA7Be55p0iUw=="],
|
||||
"rolldown-plugin-dts": ["[email protected].3", "", { "dependencies": { "@babel/generator": "8.0.0-rc.2", "@babel/helper-validator-identifier": "8.0.0-rc.2", "@babel/parser": "8.0.0-rc.2", "@babel/types": "8.0.0-rc.2", "ast-kit": "^3.0.0-beta.1", "birpc": "^4.0.0", "dts-resolver": "^2.1.3", "get-tsconfig": "^4.13.6", "obug": "^2.1.1" }, "peerDependencies": { "@ts-macro/tsc": "^0.3.6", "@typescript/native-preview": ">=7.0.0-dev.20250601.1", "rolldown": "^1.0.0-rc.3", "typescript": "^5.0.0 || ^6.0.0-beta", "vue-tsc": "~3.2.0" }, "optionalPeers": ["@ts-macro/tsc", "@typescript/native-preview", "typescript", "vue-tsc"] }, "sha512-APIGZGChvLVu05f+7bMmgf+lpvhjIvELhkOsg7c/95IVdOgULVFOX9iciaHJLaBfZeTthIgp+gryGBjgyKNA1A=="],
|
||||
|
||||
"rollup": ["[email protected]7.1", "", { "dependencies": { "@types/estree": "1.0.8" }, "optionalDependencies": { "@rollup/rollup-android-arm-eabi": "4.57.1", "@rollup/rollup-android-arm64": "4.57.1", "@rollup/rollup-darwin-arm64": "4.57.1", "@rollup/rollup-darwin-x64": "4.57.1", "@rollup/rollup-freebsd-arm64": "4.57.1", "@rollup/rollup-freebsd-x64": "4.57.1", "@rollup/rollup-linux-arm-gnueabihf": "4.57.1", "@rollup/rollup-linux-arm-musleabihf": "4.57.1", "@rollup/rollup-linux-arm64-gnu": "4.57.1", "@rollup/rollup-linux-arm64-musl": "4.57.1", "@rollup/rollup-linux-loong64-gnu": "4.57.1", "@rollup/rollup-linux-loong64-musl": "4.57.1", "@rollup/rollup-linux-ppc64-gnu": "4.57.1", "@rollup/rollup-linux-ppc64-musl": "4.57.1", "@rollup/rollup-linux-riscv64-gnu": "4.57.1", "@rollup/rollup-linux-riscv64-musl": "4.57.1", "@rollup/rollup-linux-s390x-gnu": "4.57.1", "@rollup/rollup-linux-x64-gnu": "4.57.1", "@rollup/rollup-linux-x64-musl": "4.57.1", "@rollup/rollup-openbsd-x64": "4.57.1", "@rollup/rollup-openharmony-arm64": "4.57.1", "@rollup/rollup-win32-arm64-msvc": "4.57.1", "@rollup/rollup-win32-ia32-msvc": "4.57.1", "@rollup/rollup-win32-x64-gnu": "4.57.1", "@rollup/rollup-win32-x64-msvc": "4.57.1", "fsevents": "~2.3.2" }, "bin": { "rollup": "dist/bin/rollup" } }, "sha512-oQL6lgK3e2QZeQ7gcgIkS2YZPg5slw37hYufJ3edKlfQSGGm8ICoxswK15ntSzF/a8+h7ekRy7k7oWc3BQ7y8A=="],
|
||||
"rollup": ["[email protected]9.0", "", { "dependencies": { "@types/estree": "1.0.8" }, "optionalDependencies": { "@rollup/rollup-android-arm-eabi": "4.59.0", "@rollup/rollup-android-arm64": "4.59.0", "@rollup/rollup-darwin-arm64": "4.59.0", "@rollup/rollup-darwin-x64": "4.59.0", "@rollup/rollup-freebsd-arm64": "4.59.0", "@rollup/rollup-freebsd-x64": "4.59.0", "@rollup/rollup-linux-arm-gnueabihf": "4.59.0", "@rollup/rollup-linux-arm-musleabihf": "4.59.0", "@rollup/rollup-linux-arm64-gnu": "4.59.0", "@rollup/rollup-linux-arm64-musl": "4.59.0", "@rollup/rollup-linux-loong64-gnu": "4.59.0", "@rollup/rollup-linux-loong64-musl": "4.59.0", "@rollup/rollup-linux-ppc64-gnu": "4.59.0", "@rollup/rollup-linux-ppc64-musl": "4.59.0", "@rollup/rollup-linux-riscv64-gnu": "4.59.0", "@rollup/rollup-linux-riscv64-musl": "4.59.0", "@rollup/rollup-linux-s390x-gnu": "4.59.0", "@rollup/rollup-linux-x64-gnu": "4.59.0", "@rollup/rollup-linux-x64-musl": "4.59.0", "@rollup/rollup-openbsd-x64": "4.59.0", "@rollup/rollup-openharmony-arm64": "4.59.0", "@rollup/rollup-win32-arm64-msvc": "4.59.0", "@rollup/rollup-win32-ia32-msvc": "4.59.0", "@rollup/rollup-win32-x64-gnu": "4.59.0", "@rollup/rollup-win32-x64-msvc": "4.59.0", "fsevents": "~2.3.2" }, "bin": { "rollup": "dist/bin/rollup" } }, "sha512-2oMpl67a3zCH9H79LeMcbDhXW/UmWG/y2zuqnF2jQq5uq9TbM9TVyXvA4+t+ne2IIkBdrLpAaRQAvo7YI/Yyeg=="],
|
||||
|
||||
"run-applescript": ["[email protected]", "", {}, "sha512-DPe5pVFaAsinSaV6QjQ6gdiedWDcRCbUuiQfQa2wmWV7+xC9bGulGI8+TdRmoFkAPaBXk8CrAbnlY2ISniJ47Q=="],
|
||||
|
||||
@@ -1359,7 +1366,7 @@
|
||||
|
||||
"seroval-plugins": ["[email protected]", "", { "peerDependencies": { "seroval": "^1.0" } }, "sha512-EAHqADIQondwRZIdeW2I636zgsODzoBDwb3PT/+7TLDWyw1Dy/Xv7iGUIEXXav7usHDE9HVhOU61irI3EnyyHA=="],
|
||||
|
||||
"shiki": ["[email protected]2.0", "", { "dependencies": { "@shikijs/core": "3.22.0", "@shikijs/engine-javascript": "3.22.0", "@shikijs/engine-oniguruma": "3.22.0", "@shikijs/langs": "3.22.0", "@shikijs/themes": "3.22.0", "@shikijs/types": "3.22.0", "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4" } }, "sha512-LBnhsoYEe0Eou4e1VgJACes+O6S6QC0w71fCSp5Oya79inkwkm15gQ1UF6VtQ8j/taMDh79hAB49WUk8ALQW3g=="],
|
||||
"shiki": ["[email protected]3.0", "", { "dependencies": { "@shikijs/core": "3.23.0", "@shikijs/engine-javascript": "3.23.0", "@shikijs/engine-oniguruma": "3.23.0", "@shikijs/langs": "3.23.0", "@shikijs/themes": "3.23.0", "@shikijs/types": "3.23.0", "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4" } }, "sha512-55Dj73uq9ZXL5zyeRPzHQsK7Nbyt6Y10k5s7OjuFZGMhpp4r/rsLBH0o/0fstIzX1Lep9VxefWljK/SKCzygIA=="],
|
||||
|
||||
"siginfo": ["[email protected]", "", {}, "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g=="],
|
||||
|
||||
@@ -1403,9 +1410,9 @@
|
||||
|
||||
"tagged-tag": ["[email protected]", "", {}, "sha512-yEFYrVhod+hdNyx7g5Bnkkb0G6si8HJurOoOEgC8B/O0uXLHlaey/65KRv6cuWBNhBgHKAROVpc7QyYqE5gFng=="],
|
||||
|
||||
"tailwind-merge": ["tailwind-merge@3.4.0", "", {}, "sha512-uSaO4gnW+b3Y2aWoWfFpX62vn2sR3skfhbjsEnaBI81WD1wBLlHZe5sWf0AqjksNdYTbGBEd0UasQMT3SNV15g=="],
|
||||
"tailwind-merge": ["tailwind-merge@3.5.0", "", {}, "sha512-I8K9wewnVDkL1NTGoqWmVEIlUcB9gFriAEkXkfCjX5ib8ezGxtR3xD7iZIxrfArjEsH7F1CHD4RFUtxefdqV/A=="],
|
||||
|
||||
"tailwindcss": ["tailwindcss@4.1.18", "", {}, "sha512-4+Z+0yiYyEtUVCScyfHCxOYP06L5Ne+JiHhY2IjR2KWMIWhJOYZKLSGZaP5HkZ8+bY0cxfzwDE5uOmzFXyIwxw=="],
|
||||
"tailwindcss": ["tailwindcss@4.2.1", "", {}, "sha512-/tBrSQ36vCleJkAOsy9kbNTgaxvGbyOamC30PRePTQe/o1MFwEKHQk4Cn7BNGaPtjp+PuUrByJehM1hgxfq4sw=="],
|
||||
|
||||
"tapable": ["[email protected]", "", {}, "sha512-g9ljZiwki/LfxmQADO3dEY1CbpmXT5Hm2fJ+QaGKwSXUylMybePR7/67YW7jOrrvjEgL1Fmz5kzyAjWVWLlucg=="],
|
||||
|
||||
@@ -1425,9 +1432,9 @@
|
||||
|
||||
"tinyrainbow": ["[email protected]", "", {}, "sha512-PSkbLUoxOFRzJYjjxHJt9xro7D+iilgMX/C9lawzVuYiIdcihh9DXmVibBe8lmcFrRi/VzlPjBxbN7rH24q8/Q=="],
|
||||
|
||||
"tldts": ["[email protected]3", "", { "dependencies": { "tldts-core": "^7.0.23" }, "bin": { "tldts": "bin/cli.js" } }, "sha512-ASdhgQIBSay0R/eXggAkQ53G4nTJqTXqC2kbaBbdDwM7SkjyZyO0OaaN1/FH7U/yCeqOHDwFO5j8+Os/IS1dXw=="],
|
||||
"tldts": ["[email protected]4", "", { "dependencies": { "tldts-core": "^7.0.24" }, "bin": { "tldts": "bin/cli.js" } }, "sha512-1r6vQTTt1rUiJkI5vX7KG8PR342Ru/5Oh13kEQP2SMbRSZpOey9SrBe27IDxkoWulx8ShWu4K6C0BkctP8Z1bQ=="],
|
||||
|
||||
"tldts-core": ["[email protected]3", "", {}, "sha512-0g9vrtDQLrNIiCj22HSe9d4mLVG3g5ph5DZ8zCKBr4OtrspmNB6ss7hVyzArAeE88ceZocIEGkyW1Ime7fxPtQ=="],
|
||||
"tldts-core": ["[email protected]4", "", {}, "sha512-pj7yygNMoMRqG7ML2SDQ0xNIOfN3IBDUcPVM2Sg6hP96oFNN2nqnzHreT3z9xLq85IWJyNTvD38O002DdOrPMw=="],
|
||||
|
||||
"to-regex-range": ["[email protected]", "", { "dependencies": { "is-number": "^7.0.0" } }, "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ=="],
|
||||
|
||||
@@ -1449,25 +1456,25 @@
|
||||
|
||||
"tsx": ["[email protected]", "", { "dependencies": { "esbuild": "~0.27.0", "get-tsconfig": "^4.7.5" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "bin": { "tsx": "dist/cli.mjs" } }, "sha512-5C1sg4USs1lfG0GFb2RLXsdpXqBSEhAaA/0kPL01wxzpMqLILNxIxIOKiILz+cdg/pLnOUxFYOR5yhHU666wbw=="],
|
||||
|
||||
"turbo": ["[email protected].7", "", { "optionalDependencies": { "turbo-darwin-64": "2.8.7", "turbo-darwin-arm64": "2.8.7", "turbo-linux-64": "2.8.7", "turbo-linux-arm64": "2.8.7", "turbo-windows-64": "2.8.7", "turbo-windows-arm64": "2.8.7" }, "bin": { "turbo": "bin/turbo" } }, "sha512-RBLh5caMAu1kFdTK1jgH2gH/z+jFsvX5rGbhgJ9nlIAWXSvxlzwId05uDlBA1+pBd3wO/UaKYzaQZQBXDd7kcA=="],
|
||||
"turbo": ["[email protected].13", "", { "optionalDependencies": { "turbo-darwin-64": "2.8.13", "turbo-darwin-arm64": "2.8.13", "turbo-linux-64": "2.8.13", "turbo-linux-arm64": "2.8.13", "turbo-windows-64": "2.8.13", "turbo-windows-arm64": "2.8.13" }, "bin": { "turbo": "bin/turbo" } }, "sha512-nyM99hwFB9/DHaFyKEqatdayGjsMNYsQ/XBNO6MITc7roncZetKb97MpHxWf3uiU+LB9c9HUlU3Jp2Ixei2k1A=="],
|
||||
|
||||
"turbo-darwin-64": ["[email protected].7", "", { "os": "darwin", "cpu": "x64" }, "sha512-Xr4TO/oDDwoozbDtBvunb66g//WK8uHRygl72vUthuwzmiw48pil4IuoG/QbMHd9RE8aBnVmzC0WZEWk/WWt3A=="],
|
||||
"turbo-darwin-64": ["[email protected].13", "", { "os": "darwin", "cpu": "x64" }, "sha512-PmOvodQNiOj77+Zwoqku70vwVjKzL34RTNxxoARjp5RU5FOj/CGiC6vcDQhNtFPUOWSAaogHF5qIka9TBhX4XA=="],
|
||||
|
||||
"turbo-darwin-arm64": ["[email protected].7", "", { "os": "darwin", "cpu": "arm64" }, "sha512-p8Xbmb9kZEY/NoshQUcFmQdO80s2PCGoLYj5DbpxjZr3diknipXxzOK7pcmT7l2gNHaMCpFVWLkiFY9nO3EU5w=="],
|
||||
"turbo-darwin-arm64": ["[email protected].13", "", { "os": "darwin", "cpu": "arm64" }, "sha512-kI+anKcLIM4L8h+NsM7mtAUpElkCOxv5LgiQVQR8BASyDFfc8Efj5kCk3cqxuxOvIqx0sLfCX7atrHQ2kwuNJQ=="],
|
||||
|
||||
"turbo-linux-64": ["[email protected].7", "", { "os": "linux", "cpu": "x64" }, "sha512-nwfEPAH3m5y/nJeYly3j1YJNYU2EG5+2ysZUxvBNM+VBV2LjQaLxB9CsEIpIOKuWKCjnFHKIADTSDPZ3D12J5Q=="],
|
||||
"turbo-linux-64": ["[email protected].13", "", { "os": "linux", "cpu": "x64" }, "sha512-j29KnQhHyzdzgCykBFeBqUPS4Wj7lWMnZ8CHqytlYDap4Jy70l4RNG46pOL9+lGu6DepK2s1rE86zQfo0IOdPw=="],
|
||||
|
||||
"turbo-linux-arm64": ["[email protected].7", "", { "os": "linux", "cpu": "arm64" }, "sha512-mgA/M6xiJzyxtXV70TtWGDPh+I6acOKmeQGtOzbFQZYEf794pu5jax26bCk5skAp1gqZu3vacPr6jhYHoHU9IQ=="],
|
||||
"turbo-linux-arm64": ["[email protected].13", "", { "os": "linux", "cpu": "arm64" }, "sha512-OEl1YocXGZDRDh28doOUn49QwNe82kXljO1HXApjU0LapkDiGpfl3jkAlPKxEkGDSYWc8MH5Ll8S16Rf5tEBYg=="],
|
||||
|
||||
"turbo-windows-64": ["[email protected].7", "", { "os": "win32", "cpu": "x64" }, "sha512-sHTYMaXuCcyHnGUQgfUUt7S8407TWoP14zc/4N2tsM0wZNK6V9h4H2t5jQPtqKEb6Fg8313kygdDgEwuM4vsHg=="],
|
||||
"turbo-windows-64": ["[email protected].13", "", { "os": "win32", "cpu": "x64" }, "sha512-717bVk1+Pn2Jody7OmWludhEirEe0okoj1NpRbSm5kVZz/yNN/jfjbxWC6ilimXMz7xoMT3IDfQFJsFR3PMANA=="],
|
||||
|
||||
"turbo-windows-arm64": ["[email protected].7", "", { "os": "win32", "cpu": "arm64" }, "sha512-WyGiOI2Zp3AhuzVagzQN+T+iq0fWx0oGxDfAWT3ZiLEd4U0cDUkwUZDKVGb3rKqPjDL6lWnuxKKu73ge5xtovQ=="],
|
||||
"turbo-windows-arm64": ["[email protected].13", "", { "os": "win32", "cpu": "arm64" }, "sha512-R819HShLIT0Wj6zWVnIsYvSNtRNj1q9VIyaUz0P24SMcLCbQZIm1sV09F4SDbg+KCCumqD2lcaR2UViQ8SnUJA=="],
|
||||
|
||||
"type-fest": ["[email protected]", "", { "dependencies": { "tagged-tag": "^1.0.0" } }, "sha512-JnTrzGu+zPV3aXIUhnyWJj4z/wigMsdYajGLIYakqyOW1nPllzXEJee0QQbHj+CTIQtXGlAjuK0UY+2xTyjVAw=="],
|
||||
|
||||
"typescript": ["[email protected]", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
|
||||
|
||||
"unconfig-core": ["unconfig-core@7.4.2", "", { "dependencies": { "@quansync/fs": "^1.0.0", "quansync": "^1.0.0" } }, "sha512-VgPCvLWugINbXvMQDf8Jh0mlbvNjNC6eSUziHsBCMpxR05OPrNrvDnyatdMjRgcHaaNsCqz+wjNXxNw1kRLHUg=="],
|
||||
"unconfig-core": ["unconfig-core@7.5.0", "", { "dependencies": { "@quansync/fs": "^1.0.0", "quansync": "^1.0.0" } }, "sha512-Su3FauozOGP44ZmKdHy2oE6LPjk51M/TRRjHv2HNCWiDvfvCoxC2lno6jevMA91MYAdCdwP05QnWdWpSbncX/w=="],
|
||||
|
||||
"undici": ["[email protected]", "", {}, "sha512-RqslV2Us5BrllB+JeiZnK4peryVTndy9Dnqq62S3yYRRTj0tFQCwEniUy2167skdGOy3vqRzEvl1Dm4sV2ReDg=="],
|
||||
|
||||
@@ -1489,7 +1496,7 @@
|
||||
|
||||
"unplugin": ["[email protected]", "", { "dependencies": { "@jridgewell/remapping": "^2.3.5", "acorn": "^8.15.0", "picomatch": "^4.0.3", "webpack-virtual-modules": "^0.6.2" } }, "sha512-5uKD0nqiYVzlmCRs01Fhs2BdkEgBS3SAVP6ndrBsuK42iC2+JHyxM05Rm9G8+5mkmRtzMZGY8Ct5+mliZxU/Ww=="],
|
||||
|
||||
"unrun": ["[email protected].27", "", { "dependencies": { "rolldown": "1.0.0-rc.3" }, "peerDependencies": { "synckit": "^0.11.11" }, "optionalPeers": ["synckit"], "bin": { "unrun": "dist/cli.mjs" } }, "sha512-Mmur1UJpIbfxasLOhPRvox/QS4xBiDii71hMP7smfRthGcwFL2OAmYRgduLANOAU4LUkvVamuP+02U+c90jlrw=="],
|
||||
"unrun": ["[email protected].30", "", { "dependencies": { "rolldown": "1.0.0-rc.7" }, "peerDependencies": { "synckit": "^0.11.11" }, "optionalPeers": ["synckit"], "bin": { "unrun": "dist/cli.mjs" } }, "sha512-a4W1wDADI0gvDDr14T0ho1FgMhmfjq6M8Iz8q234EnlxgH/9cMHDueUSLwTl1fwSBs5+mHrLFYH+7B8ao36EBA=="],
|
||||
|
||||
"until-async": ["[email protected]", "", {}, "sha512-IiSk4HlzAMqTUseHHe3VhIGyuFmN90zMTpD3Z3y8jeQbzLIq500MVM7Jq2vUAnTKAFPJrqwkzr6PoTcPhGcOiw=="],
|
||||
|
||||
@@ -1503,7 +1510,7 @@
|
||||
|
||||
"vfile-message": ["[email protected]", "", { "dependencies": { "@types/unist": "^3.0.0", "unist-util-stringify-position": "^4.0.0" } }, "sha512-QTHzsGd1EhbZs4AsQ20JX1rC3cOlt/IWJruk893DfLRr57lcnOeMaWG4K0JrRta4mIJZKth2Au3mM3u03/JWKw=="],
|
||||
|
||||
"vite": ["[email protected]3", "", { "dependencies": { "@oxc-project/runtime": "0.112.0", "fdir": "^6.5.0", "lightningcss": "^1.31.1", "picomatch": "^4.0.3", "postcss": "^8.5.6", "rolldown": "1.0.0-rc.3", "tinyglobby": "^0.2.15" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^20.19.0 || >=22.12.0", "@vitejs/devtools": "^0.0.0-alpha.24", "esbuild": "^0.27.0", "jiti": ">=1.21.0", "less": "^4.0.0", "sass": "^1.70.0", "sass-embedded": "^1.70.0", "stylus": ">=0.54.8", "sugarss": "^5.0.0", "terser": "^5.16.0", "tsx": "^4.8.1", "yaml": "^2.4.2" }, "optionalPeers": ["@types/node", "@vitejs/devtools", "esbuild", "jiti", "less", "sass", "sass-embedded", "stylus", "sugarss", "terser", "tsx", "yaml"], "bin": { "vite": "bin/vite.js" } }, "sha512-7s/rfpYOAo7WUHh9irzaGjhhKb12hGv0BpDegAMV5A391wdyvM45WtX6VMV7hvEtZF2j/QtpDpR6ldXI3GgARQ=="],
|
||||
"vite": ["[email protected]6", "", { "dependencies": { "@oxc-project/runtime": "0.115.0", "lightningcss": "^1.31.1", "picomatch": "^4.0.3", "postcss": "^8.5.6", "rolldown": "1.0.0-rc.6", "tinyglobby": "^0.2.15" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^20.19.0 || >=22.12.0", "@vitejs/devtools": "^0.0.0-alpha.31", "esbuild": "^0.27.0", "jiti": ">=1.21.0", "less": "^4.0.0", "sass": "^1.70.0", "sass-embedded": "^1.70.0", "stylus": ">=0.54.8", "sugarss": "^5.0.0", "terser": "^5.16.0", "tsx": "^4.8.1", "yaml": "^2.4.2" }, "optionalPeers": ["@types/node", "@vitejs/devtools", "esbuild", "jiti", "less", "sass", "sass-embedded", "stylus", "sugarss", "terser", "tsx", "yaml"], "bin": { "vite": "bin/vite.js" } }, "sha512-c0t7hYkxsjws89HH+BUFh/sL3BpPNhNsL9CJrTpMxBmwKQBRSa5OJ5w4o9O0bQVI/H/vx7UpUUIevvXa37NS/Q=="],
|
||||
|
||||
"vitest": ["[email protected]", "", { "dependencies": { "@vitest/expect": "4.0.18", "@vitest/mocker": "4.0.18", "@vitest/pretty-format": "4.0.18", "@vitest/runner": "4.0.18", "@vitest/snapshot": "4.0.18", "@vitest/spy": "4.0.18", "@vitest/utils": "4.0.18", "es-module-lexer": "^1.7.0", "expect-type": "^1.2.2", "magic-string": "^0.30.21", "obug": "^2.1.1", "pathe": "^2.0.3", "picomatch": "^4.0.3", "std-env": "^3.10.0", "tinybench": "^2.9.0", "tinyexec": "^1.0.2", "tinyglobby": "^0.2.15", "tinyrainbow": "^3.0.3", "vite": "^6.0.0 || ^7.0.0", "why-is-node-running": "^2.3.0" }, "peerDependencies": { "@edge-runtime/vm": "*", "@opentelemetry/api": "^1.9.0", "@types/node": "^20.0.0 || ^22.0.0 || >=24.0.0", "@vitest/browser-playwright": "4.0.18", "@vitest/browser-preview": "4.0.18", "@vitest/browser-webdriverio": "4.0.18", "@vitest/ui": "4.0.18", "happy-dom": "*", "jsdom": "*" }, "optionalPeers": ["@edge-runtime/vm", "@opentelemetry/api", "@types/node", "@vitest/browser-playwright", "@vitest/browser-preview", "@vitest/browser-webdriverio", "@vitest/ui", "happy-dom", "jsdom"], "bin": { "vitest": "vitest.mjs" } }, "sha512-hOQuK7h0FGKgBAas7v0mSAsnvrIgAvWmRFjmzpJ7SwFHH3g1k2u37JtYwOwmEKhK6ZO3v9ggDBBm0La1LCK4uQ=="],
|
||||
|
||||
@@ -1553,13 +1560,13 @@
|
||||
|
||||
"@babel/core/semver": ["[email protected]", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA=="],
|
||||
|
||||
"@babel/generator/@babel/types": ["@babel/[email protected].1", "", { "dependencies": { "@babel/helper-string-parser": "^8.0.0-rc.1", "@babel/helper-validator-identifier": "^8.0.0-rc.1" } }, "sha512-ubmJ6TShyaD69VE9DQrlXcdkvJbmwWPB8qYj0H2kaJi29O7vJT9ajSdBd2W8CG34pwL9pYA74fi7RHC1qbLoVQ=="],
|
||||
"@babel/generator/@babel/types": ["@babel/[email protected].2", "", { "dependencies": { "@babel/helper-string-parser": "^8.0.0-rc.2", "@babel/helper-validator-identifier": "^8.0.0-rc.2" } }, "sha512-91gAaWRznDwSX4E2tZ1YjBuIfnQVOFDCQ2r0Toby0gu4XEbyF623kXLMA8d4ZbCu+fINcrudkmEcwSUHgDDkNw=="],
|
||||
|
||||
"@babel/helper-compilation-targets/semver": ["[email protected]", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA=="],
|
||||
|
||||
"@babel/helper-module-transforms/@babel/helper-validator-identifier": ["@babel/[email protected]", "", {}, "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q=="],
|
||||
|
||||
"@babel/parser/@babel/types": ["@babel/[email protected].1", "", { "dependencies": { "@babel/helper-string-parser": "^8.0.0-rc.1", "@babel/helper-validator-identifier": "^8.0.0-rc.1" } }, "sha512-ubmJ6TShyaD69VE9DQrlXcdkvJbmwWPB8qYj0H2kaJi29O7vJT9ajSdBd2W8CG34pwL9pYA74fi7RHC1qbLoVQ=="],
|
||||
"@babel/parser/@babel/types": ["@babel/[email protected].2", "", { "dependencies": { "@babel/helper-string-parser": "^8.0.0-rc.2", "@babel/helper-validator-identifier": "^8.0.0-rc.2" } }, "sha512-91gAaWRznDwSX4E2tZ1YjBuIfnQVOFDCQ2r0Toby0gu4XEbyF623kXLMA8d4ZbCu+fINcrudkmEcwSUHgDDkNw=="],
|
||||
|
||||
"@babel/template/@babel/parser": ["@babel/[email protected]", "", { "dependencies": { "@babel/types": "^7.29.0" }, "bin": "./bin/babel-parser.js" }, "sha512-IyDgFV5GeDUVX4YdF/3CPULtVGSXXMLh1xVIgdCgxApktqnQV0r7/8Nqthg+8YLGaAtdyIlo2qIdZrbCv4+7ww=="],
|
||||
|
||||
@@ -1569,12 +1576,18 @@
|
||||
|
||||
"@babel/types/@babel/helper-validator-identifier": ["@babel/[email protected]", "", {}, "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q=="],
|
||||
|
||||
"@effect/platform-node/effect": ["[email protected]", "", { "dependencies": { "@standard-schema/spec": "^1.1.0", "fast-check": "^4.5.3", "find-my-way-ts": "^0.1.6", "ini": "^6.0.0", "kubernetes-types": "^1.30.0", "msgpackr": "^1.11.8", "multipasta": "^0.2.7", "toml": "^3.0.0", "uuid": "^13.0.0", "yaml": "^2.8.2" } }, "sha512-bNQEF3vaVGF8jAJ+HW1A4DaxVNmujgEu89sO+VNW1AvUYtPGMtKPTBU15K9inu1rG+hkxNFFRlVvLAJsdaE2mg=="],
|
||||
|
||||
"@effect/platform-node-shared/effect": ["[email protected]", "", { "dependencies": { "@standard-schema/spec": "^1.1.0", "fast-check": "^4.5.3", "find-my-way-ts": "^0.1.6", "ini": "^6.0.0", "kubernetes-types": "^1.30.0", "msgpackr": "^1.11.8", "multipasta": "^0.2.7", "toml": "^3.0.0", "uuid": "^13.0.0", "yaml": "^2.8.2" } }, "sha512-bNQEF3vaVGF8jAJ+HW1A4DaxVNmujgEu89sO+VNW1AvUYtPGMtKPTBU15K9inu1rG+hkxNFFRlVvLAJsdaE2mg=="],
|
||||
|
||||
"@effect/sql-sqlite-bun/effect": ["[email protected]", "", { "dependencies": { "@standard-schema/spec": "^1.1.0", "fast-check": "^4.5.3", "find-my-way-ts": "^0.1.6", "ini": "^6.0.0", "kubernetes-types": "^1.30.0", "msgpackr": "^1.11.8", "multipasta": "^0.2.7", "toml": "^3.0.0", "uuid": "^13.0.0", "yaml": "^2.8.2" } }, "sha512-bNQEF3vaVGF8jAJ+HW1A4DaxVNmujgEu89sO+VNW1AvUYtPGMtKPTBU15K9inu1rG+hkxNFFRlVvLAJsdaE2mg=="],
|
||||
|
||||
"@effect/vitest/effect": ["[email protected]", "", { "dependencies": { "@standard-schema/spec": "^1.1.0", "fast-check": "^4.5.3", "find-my-way-ts": "^0.1.6", "ini": "^6.0.0", "kubernetes-types": "^1.30.0", "msgpackr": "^1.11.8", "multipasta": "^0.2.7", "toml": "^3.0.0", "uuid": "^13.0.0", "yaml": "^2.8.2" } }, "sha512-bNQEF3vaVGF8jAJ+HW1A4DaxVNmujgEu89sO+VNW1AvUYtPGMtKPTBU15K9inu1rG+hkxNFFRlVvLAJsdaE2mg=="],
|
||||
|
||||
"@electron/get/fs-extra": ["[email protected]", "", { "dependencies": { "graceful-fs": "^4.2.0", "jsonfile": "^4.0.0", "universalify": "^0.1.0" } }, "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g=="],
|
||||
|
||||
"@electron/get/semver": ["[email protected]", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA=="],
|
||||
|
||||
"@tailwindcss/node/lightningcss": ["[email protected]", "", { "dependencies": { "detect-libc": "^2.0.3" }, "optionalDependencies": { "lightningcss-android-arm64": "1.30.2", "lightningcss-darwin-arm64": "1.30.2", "lightningcss-darwin-x64": "1.30.2", "lightningcss-freebsd-x64": "1.30.2", "lightningcss-linux-arm-gnueabihf": "1.30.2", "lightningcss-linux-arm64-gnu": "1.30.2", "lightningcss-linux-arm64-musl": "1.30.2", "lightningcss-linux-x64-gnu": "1.30.2", "lightningcss-linux-x64-musl": "1.30.2", "lightningcss-win32-arm64-msvc": "1.30.2", "lightningcss-win32-x64-msvc": "1.30.2" } }, "sha512-utfs7Pr5uJyyvDETitgsaqSyjCb2qNRAtuqUeWIAKztsOYdcACf2KtARYXg2pSvhkt+9NfoaNY7fxjl6nuMjIQ=="],
|
||||
|
||||
"@tailwindcss/oxide-wasm32-wasi/@emnapi/core": ["@emnapi/[email protected]", "", { "dependencies": { "@emnapi/wasi-threads": "1.1.0", "tslib": "^2.4.0" }, "bundled": true }, "sha512-AvT9QFpxK0Zd8J0jopedNm+w/2fIzvtPKPjqyw9jwvBaReTTqPBk9Hixaz7KbjimP+QNz605/XnjFcDAL2pqBg=="],
|
||||
|
||||
"@tailwindcss/oxide-wasm32-wasi/@emnapi/runtime": ["@emnapi/[email protected]", "", { "dependencies": { "tslib": "^2.4.0" }, "bundled": true }, "sha512-mehfKSMWjjNol8659Z8KxEMrdSJDDot5SXMq00dM8BN4o+CLNXQ0xH2V7EchNHV4RmbZLmmPdEaXZc5H2FXmDg=="],
|
||||
@@ -1589,6 +1602,12 @@
|
||||
|
||||
"@tailwindcss/vite/vite": ["[email protected]", "", { "dependencies": { "esbuild": "^0.27.0", "fdir": "^6.5.0", "picomatch": "^4.0.3", "postcss": "^8.5.6", "rollup": "^4.43.0", "tinyglobby": "^0.2.15" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^20.19.0 || >=22.12.0", "jiti": ">=1.21.0", "less": "^4.0.0", "lightningcss": "^1.21.0", "sass": "^1.70.0", "sass-embedded": "^1.70.0", "stylus": ">=0.54.8", "sugarss": "^5.0.0", "terser": "^5.16.0", "tsx": "^4.8.1", "yaml": "^2.4.2" }, "optionalPeers": ["@types/node", "jiti", "less", "lightningcss", "sass", "sass-embedded", "stylus", "sugarss", "terser", "tsx", "yaml"], "bin": { "vite": "bin/vite.js" } }, "sha512-w+N7Hifpc3gRjZ63vYBXA56dvvRlNWRczTdmCBBa+CotUzAPf5b7YMdMR/8CQoeYE5LX3W4wj6RYTgonm1b9DA=="],
|
||||
|
||||
"@tanstack/pacer/@tanstack/store": ["@tanstack/[email protected]", "", {}, "sha512-PtOisLjUZPz5VyPRSCGjNOlwTvabdTBQ2K80DpVL1chGVr35WRxfeavAPdNq6pm/t7F8GhoR2qtmkkqtCEtHYw=="],
|
||||
|
||||
"@tanstack/react-router/@tanstack/react-store": ["@tanstack/[email protected]", "", { "dependencies": { "@tanstack/store": "0.9.1", "use-sync-external-store": "^1.6.0" }, "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-YzJLnRvy5lIEFTLWBAZmcOjK3+2AepnBv/sr6NZmiqJvq7zTQggyK99Gw8fqYdMdHPQWXjz0epFKJXC+9V2xDA=="],
|
||||
|
||||
"@tanstack/react-store/@tanstack/store": ["@tanstack/[email protected]", "", {}, "sha512-PtOisLjUZPz5VyPRSCGjNOlwTvabdTBQ2K80DpVL1chGVr35WRxfeavAPdNq6pm/t7F8GhoR2qtmkkqtCEtHYw=="],
|
||||
|
||||
"@tanstack/router-utils/@babel/generator": ["@babel/[email protected]", "", { "dependencies": { "@babel/parser": "^7.29.0", "@babel/types": "^7.29.0", "@jridgewell/gen-mapping": "^0.3.12", "@jridgewell/trace-mapping": "^0.3.28", "jsesc": "^3.0.2" } }, "sha512-qsaF+9Qcm2Qv8SRIMMscAvG4O3lJ0F1GuMo5HR/Bp02LopNgnZBC/EkbevHFeGs4ls/oPz9v+Bsmzbkbe+0dUw=="],
|
||||
|
||||
"@tanstack/router-utils/@babel/parser": ["@babel/[email protected]", "", { "dependencies": { "@babel/types": "^7.29.0" }, "bin": "./bin/babel-parser.js" }, "sha512-IyDgFV5GeDUVX4YdF/3CPULtVGSXXMLh1xVIgdCgxApktqnQV0r7/8Nqthg+8YLGaAtdyIlo2qIdZrbCv4+7ww=="],
|
||||
@@ -1597,16 +1616,6 @@
|
||||
|
||||
"@types/babel__template/@babel/parser": ["@babel/[email protected]", "", { "dependencies": { "@babel/types": "^7.29.0" }, "bin": "./bin/babel-parser.js" }, "sha512-IyDgFV5GeDUVX4YdF/3CPULtVGSXXMLh1xVIgdCgxApktqnQV0r7/8Nqthg+8YLGaAtdyIlo2qIdZrbCv4+7ww=="],
|
||||
|
||||
"@types/cacheable-request/@types/node": ["@types/[email protected]", "", { "dependencies": { "undici-types": "~6.21.0" } }, "sha512-BH7YwL6rA93ReqeQS1c4bsPpcfOmJasG+Fkr6Y59q83f9M1WcBRHR2vM+P9eOisYRcN3ujQoiZY8uk5W+1WL8w=="],
|
||||
|
||||
"@types/keyv/@types/node": ["@types/[email protected]", "", { "dependencies": { "undici-types": "~6.21.0" } }, "sha512-BH7YwL6rA93ReqeQS1c4bsPpcfOmJasG+Fkr6Y59q83f9M1WcBRHR2vM+P9eOisYRcN3ujQoiZY8uk5W+1WL8w=="],
|
||||
|
||||
"@types/responselike/@types/node": ["@types/[email protected]", "", { "dependencies": { "undici-types": "~6.21.0" } }, "sha512-BH7YwL6rA93ReqeQS1c4bsPpcfOmJasG+Fkr6Y59q83f9M1WcBRHR2vM+P9eOisYRcN3ujQoiZY8uk5W+1WL8w=="],
|
||||
|
||||
"@types/ws/@types/node": ["@types/[email protected]", "", { "dependencies": { "undici-types": "~6.21.0" } }, "sha512-BH7YwL6rA93ReqeQS1c4bsPpcfOmJasG+Fkr6Y59q83f9M1WcBRHR2vM+P9eOisYRcN3ujQoiZY8uk5W+1WL8w=="],
|
||||
|
||||
"@types/yauzl/@types/node": ["@types/[email protected]", "", { "dependencies": { "undici-types": "~6.21.0" } }, "sha512-BH7YwL6rA93ReqeQS1c4bsPpcfOmJasG+Fkr6Y59q83f9M1WcBRHR2vM+P9eOisYRcN3ujQoiZY8uk5W+1WL8w=="],
|
||||
|
||||
"@vitejs/plugin-react/vite": ["[email protected]", "", { "dependencies": { "esbuild": "^0.27.0", "fdir": "^6.5.0", "picomatch": "^4.0.3", "postcss": "^8.5.6", "rollup": "^4.43.0", "tinyglobby": "^0.2.15" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^20.19.0 || >=22.12.0", "jiti": ">=1.21.0", "less": "^4.0.0", "lightningcss": "^1.21.0", "sass": "^1.70.0", "sass-embedded": "^1.70.0", "stylus": ">=0.54.8", "sugarss": "^5.0.0", "terser": "^5.16.0", "tsx": "^4.8.1", "yaml": "^2.4.2" }, "optionalPeers": ["@types/node", "jiti", "less", "lightningcss", "sass", "sass-embedded", "stylus", "sugarss", "terser", "tsx", "yaml"], "bin": { "vite": "bin/vite.js" } }, "sha512-w+N7Hifpc3gRjZ63vYBXA56dvvRlNWRczTdmCBBa+CotUzAPf5b7YMdMR/8CQoeYE5LX3W4wj6RYTgonm1b9DA=="],
|
||||
|
||||
"anymatch/picomatch": ["[email protected]", "", {}, "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="],
|
||||
@@ -1627,7 +1636,7 @@
|
||||
|
||||
"recast/source-map": ["[email protected]", "", {}, "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="],
|
||||
|
||||
"rolldown-plugin-dts/@babel/types": ["@babel/[email protected].1", "", { "dependencies": { "@babel/helper-string-parser": "^8.0.0-rc.1", "@babel/helper-validator-identifier": "^8.0.0-rc.1" } }, "sha512-ubmJ6TShyaD69VE9DQrlXcdkvJbmwWPB8qYj0H2kaJi29O7vJT9ajSdBd2W8CG34pwL9pYA74fi7RHC1qbLoVQ=="],
|
||||
"rolldown-plugin-dts/@babel/types": ["@babel/[email protected].2", "", { "dependencies": { "@babel/helper-string-parser": "^8.0.0-rc.2", "@babel/helper-validator-identifier": "^8.0.0-rc.2" } }, "sha512-91gAaWRznDwSX4E2tZ1YjBuIfnQVOFDCQ2r0Toby0gu4XEbyF623kXLMA8d4ZbCu+fINcrudkmEcwSUHgDDkNw=="],
|
||||
|
||||
"rollup/fsevents": ["[email protected]", "", { "os": "darwin" }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="],
|
||||
|
||||
@@ -1635,55 +1644,87 @@
|
||||
|
||||
"tsx/fsevents": ["[email protected]", "", { "os": "darwin" }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="],
|
||||
|
||||
"unrun/rolldown": ["[email protected]", "", { "dependencies": { "@oxc-project/types": "=0.115.0", "@rolldown/pluginutils": "1.0.0-rc.7" }, "optionalDependencies": { "@rolldown/binding-android-arm64": "1.0.0-rc.7", "@rolldown/binding-darwin-arm64": "1.0.0-rc.7", "@rolldown/binding-darwin-x64": "1.0.0-rc.7", "@rolldown/binding-freebsd-x64": "1.0.0-rc.7", "@rolldown/binding-linux-arm-gnueabihf": "1.0.0-rc.7", "@rolldown/binding-linux-arm64-gnu": "1.0.0-rc.7", "@rolldown/binding-linux-arm64-musl": "1.0.0-rc.7", "@rolldown/binding-linux-ppc64-gnu": "1.0.0-rc.7", "@rolldown/binding-linux-s390x-gnu": "1.0.0-rc.7", "@rolldown/binding-linux-x64-gnu": "1.0.0-rc.7", "@rolldown/binding-linux-x64-musl": "1.0.0-rc.7", "@rolldown/binding-openharmony-arm64": "1.0.0-rc.7", "@rolldown/binding-wasm32-wasi": "1.0.0-rc.7", "@rolldown/binding-win32-arm64-msvc": "1.0.0-rc.7", "@rolldown/binding-win32-x64-msvc": "1.0.0-rc.7" }, "bin": { "rolldown": "bin/cli.mjs" } }, "sha512-5X0zEeQFzDpB3MqUWQZyO2TUQqP9VnT7CqXHF2laTFRy487+b6QZyotCazOySAuZLAvplCaOVsg1tVn/Zlmwfg=="],
|
||||
|
||||
"vite/fsevents": ["[email protected]", "", { "os": "darwin" }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="],
|
||||
|
||||
"vite/rolldown": ["[email protected]", "", { "dependencies": { "@oxc-project/types": "=0.115.0", "@rolldown/pluginutils": "1.0.0-rc.6" }, "optionalDependencies": { "@rolldown/binding-android-arm64": "1.0.0-rc.6", "@rolldown/binding-darwin-arm64": "1.0.0-rc.6", "@rolldown/binding-darwin-x64": "1.0.0-rc.6", "@rolldown/binding-freebsd-x64": "1.0.0-rc.6", "@rolldown/binding-linux-arm-gnueabihf": "1.0.0-rc.6", "@rolldown/binding-linux-arm64-gnu": "1.0.0-rc.6", "@rolldown/binding-linux-arm64-musl": "1.0.0-rc.6", "@rolldown/binding-linux-x64-gnu": "1.0.0-rc.6", "@rolldown/binding-linux-x64-musl": "1.0.0-rc.6", "@rolldown/binding-openharmony-arm64": "1.0.0-rc.6", "@rolldown/binding-wasm32-wasi": "1.0.0-rc.6", "@rolldown/binding-win32-arm64-msvc": "1.0.0-rc.6", "@rolldown/binding-win32-x64-msvc": "1.0.0-rc.6" }, "bin": { "rolldown": "bin/cli.mjs" } }, "sha512-B8vFPV1ADyegoYfhg+E7RAucYKv0xdVlwYYsIJgfPNeiSxZGWNxts9RqhyGzC11ULK/VaeXyKezGCwpMiH8Ktw=="],
|
||||
|
||||
"vitest/vite": ["[email protected]", "", { "dependencies": { "esbuild": "^0.27.0", "fdir": "^6.5.0", "picomatch": "^4.0.3", "postcss": "^8.5.6", "rollup": "^4.43.0", "tinyglobby": "^0.2.15" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^20.19.0 || >=22.12.0", "jiti": ">=1.21.0", "less": "^4.0.0", "lightningcss": "^1.21.0", "sass": "^1.70.0", "sass-embedded": "^1.70.0", "stylus": ">=0.54.8", "sugarss": "^5.0.0", "terser": "^5.16.0", "tsx": "^4.8.1", "yaml": "^2.4.2" }, "optionalPeers": ["@types/node", "jiti", "less", "lightningcss", "sass", "sass-embedded", "stylus", "sugarss", "terser", "tsx", "yaml"], "bin": { "vite": "bin/vite.js" } }, "sha512-w+N7Hifpc3gRjZ63vYBXA56dvvRlNWRczTdmCBBa+CotUzAPf5b7YMdMR/8CQoeYE5LX3W4wj6RYTgonm1b9DA=="],
|
||||
|
||||
"@babel/generator/@babel/types/@babel/helper-string-parser": ["@babel/[email protected].1", "", {}, "sha512-vi/pfmbrOtQmqgfboaBhaCU50G7mcySVu69VU8z+lYoPPB6WzI9VgV7WQfL908M4oeSH5fDkmoupIqoE0SdApw=="],
|
||||
"@babel/generator/@babel/types/@babel/helper-string-parser": ["@babel/[email protected].2", "", {}, "sha512-noLx87RwlBEMrTzncWd/FvTxoJ9+ycHNg0n8yyYydIoDsLZuxknKgWRJUqcrVkNrJ74uGyhWQzQaS3q8xfGAhQ=="],
|
||||
|
||||
"@babel/parser/@babel/types/@babel/helper-string-parser": ["@babel/[email protected].1", "", {}, "sha512-vi/pfmbrOtQmqgfboaBhaCU50G7mcySVu69VU8z+lYoPPB6WzI9VgV7WQfL908M4oeSH5fDkmoupIqoE0SdApw=="],
|
||||
"@babel/parser/@babel/types/@babel/helper-string-parser": ["@babel/[email protected].2", "", {}, "sha512-noLx87RwlBEMrTzncWd/FvTxoJ9+ycHNg0n8yyYydIoDsLZuxknKgWRJUqcrVkNrJ74uGyhWQzQaS3q8xfGAhQ=="],
|
||||
|
||||
"@electron/get/fs-extra/jsonfile": ["[email protected]", "", { "optionalDependencies": { "graceful-fs": "^4.1.6" } }, "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg=="],
|
||||
|
||||
"@electron/get/fs-extra/universalify": ["[email protected]", "", {}, "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg=="],
|
||||
|
||||
"@tailwindcss/node/lightningcss/lightningcss-android-arm64": ["[email protected]", "", { "os": "android", "cpu": "arm64" }, "sha512-BH9sEdOCahSgmkVhBLeU7Hc9DWeZ1Eb6wNS6Da8igvUwAe0sqROHddIlvU06q3WyXVEOYDZ6ykBZQnjTbmo4+A=="],
|
||||
|
||||
"@tailwindcss/node/lightningcss/lightningcss-darwin-arm64": ["[email protected]", "", { "os": "darwin", "cpu": "arm64" }, "sha512-ylTcDJBN3Hp21TdhRT5zBOIi73P6/W0qwvlFEk22fkdXchtNTOU4Qc37SkzV+EKYxLouZ6M4LG9NfZ1qkhhBWA=="],
|
||||
|
||||
"@tailwindcss/node/lightningcss/lightningcss-darwin-x64": ["[email protected]", "", { "os": "darwin", "cpu": "x64" }, "sha512-oBZgKchomuDYxr7ilwLcyms6BCyLn0z8J0+ZZmfpjwg9fRVZIR5/GMXd7r9RH94iDhld3UmSjBM6nXWM2TfZTQ=="],
|
||||
|
||||
"@tailwindcss/node/lightningcss/lightningcss-freebsd-x64": ["[email protected]", "", { "os": "freebsd", "cpu": "x64" }, "sha512-c2bH6xTrf4BDpK8MoGG4Bd6zAMZDAXS569UxCAGcA7IKbHNMlhGQ89eRmvpIUGfKWNVdbhSbkQaWhEoMGmGslA=="],
|
||||
|
||||
"@tailwindcss/node/lightningcss/lightningcss-linux-arm-gnueabihf": ["[email protected]", "", { "os": "linux", "cpu": "arm" }, "sha512-eVdpxh4wYcm0PofJIZVuYuLiqBIakQ9uFZmipf6LF/HRj5Bgm0eb3qL/mr1smyXIS1twwOxNWndd8z0E374hiA=="],
|
||||
|
||||
"@tailwindcss/node/lightningcss/lightningcss-linux-arm64-gnu": ["[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-UK65WJAbwIJbiBFXpxrbTNArtfuznvxAJw4Q2ZGlU8kPeDIWEX1dg3rn2veBVUylA2Ezg89ktszWbaQnxD/e3A=="],
|
||||
|
||||
"@tailwindcss/node/lightningcss/lightningcss-linux-arm64-musl": ["[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-5Vh9dGeblpTxWHpOx8iauV02popZDsCYMPIgiuw97OJ5uaDsL86cnqSFs5LZkG3ghHoX5isLgWzMs+eD1YzrnA=="],
|
||||
|
||||
"@tailwindcss/node/lightningcss/lightningcss-linux-x64-gnu": ["[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-Cfd46gdmj1vQ+lR6VRTTadNHu6ALuw2pKR9lYq4FnhvgBc4zWY1EtZcAc6EffShbb1MFrIPfLDXD6Xprbnni4w=="],
|
||||
|
||||
"@tailwindcss/node/lightningcss/lightningcss-linux-x64-musl": ["[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-XJaLUUFXb6/QG2lGIW6aIk6jKdtjtcffUT0NKvIqhSBY3hh9Ch+1LCeH80dR9q9LBjG3ewbDjnumefsLsP6aiA=="],
|
||||
|
||||
"@tailwindcss/node/lightningcss/lightningcss-win32-arm64-msvc": ["[email protected]", "", { "os": "win32", "cpu": "arm64" }, "sha512-FZn+vaj7zLv//D/192WFFVA0RgHawIcHqLX9xuWiQt7P0PtdFEVaxgF9rjM/IRYHQXNnk61/H/gb2Ei+kUQ4xQ=="],
|
||||
|
||||
"@tailwindcss/node/lightningcss/lightningcss-win32-x64-msvc": ["[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-5g1yc73p+iAkid5phb4oVFMB45417DkRevRbt/El/gKXJk4jid+vPFF/AXbxn05Aky8PapwzZrdJShv5C0avjw=="],
|
||||
|
||||
"@tailwindcss/vite/vite/fsevents": ["[email protected]", "", { "os": "darwin" }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="],
|
||||
|
||||
"@types/cacheable-request/@types/node/undici-types": ["[email protected]", "", {}, "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ=="],
|
||||
|
||||
"@types/keyv/@types/node/undici-types": ["[email protected]", "", {}, "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ=="],
|
||||
|
||||
"@types/responselike/@types/node/undici-types": ["[email protected]", "", {}, "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ=="],
|
||||
|
||||
"@types/ws/@types/node/undici-types": ["[email protected]", "", {}, "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ=="],
|
||||
|
||||
"@types/yauzl/@types/node/undici-types": ["[email protected]", "", {}, "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ=="],
|
||||
|
||||
"@vitejs/plugin-react/vite/fsevents": ["[email protected]", "", { "os": "darwin" }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="],
|
||||
|
||||
"rolldown-plugin-dts/@babel/types/@babel/helper-string-parser": ["@babel/[email protected].1", "", {}, "sha512-vi/pfmbrOtQmqgfboaBhaCU50G7mcySVu69VU8z+lYoPPB6WzI9VgV7WQfL908M4oeSH5fDkmoupIqoE0SdApw=="],
|
||||
"rolldown-plugin-dts/@babel/types/@babel/helper-string-parser": ["@babel/[email protected].2", "", {}, "sha512-noLx87RwlBEMrTzncWd/FvTxoJ9+ycHNg0n8yyYydIoDsLZuxknKgWRJUqcrVkNrJ74uGyhWQzQaS3q8xfGAhQ=="],
|
||||
|
||||
"unrun/rolldown/@oxc-project/types": ["@oxc-project/[email protected]", "", {}, "sha512-4n91DKnebUS4yjUHl2g3/b2T+IUdCfmoZGhmwsovZCDaJSs+QkVAM+0AqqTxHSsHfeiMuueT75cZaZcT/m0pSw=="],
|
||||
|
||||
"unrun/rolldown/@rolldown/binding-android-arm64": ["@rolldown/[email protected]", "", { "os": "android", "cpu": "arm64" }, "sha512-/uadfNUaMLFFBGvcIOiq8NnlhvTZTjOyybJaJnhGxD0n9k5vZRJfTaitH5GHnbwmc6T2PC+ZpS1FQH+vXyS/UA=="],
|
||||
|
||||
"unrun/rolldown/@rolldown/binding-darwin-arm64": ["@rolldown/[email protected]", "", { "os": "darwin", "cpu": "arm64" }, "sha512-zokYr1KgRn0hRA89dmgtPj/BmKp9DxgrfAJvOEFfXa8nfYWW2nmgiYIBGpSIAJrEg7Qc/Qznovy6xYwmKh0M8g=="],
|
||||
|
||||
"unrun/rolldown/@rolldown/binding-darwin-x64": ["@rolldown/[email protected]", "", { "os": "darwin", "cpu": "x64" }, "sha512-eZFjbmrapCBVgMmuLALH3pmQQQStHFuRhsFceJHk6KISW8CkI2e9OPLp9V4qXksrySQcD8XM8fpvGLs5l5C7LQ=="],
|
||||
|
||||
"unrun/rolldown/@rolldown/binding-freebsd-x64": ["@rolldown/[email protected]", "", { "os": "freebsd", "cpu": "x64" }, "sha512-xjMrh8Dmu2DNwdY6DZsrF6YPGeesc3PaTlkh8v9cqmkSCNeTxnhX3ErhVnuv1j3n8t2IuuhQIwM9eZDINNEt5Q=="],
|
||||
|
||||
"unrun/rolldown/@rolldown/binding-linux-arm-gnueabihf": ["@rolldown/[email protected]", "", { "os": "linux", "cpu": "arm" }, "sha512-mOvftrHiXg4/xFdxJY3T9Wl1/zDAOSlMN8z9an2bXsCwuvv3RdyhYbSMZDuDO52S04w9z7+cBd90lvQSPTAQtw=="],
|
||||
|
||||
"unrun/rolldown/@rolldown/binding-linux-arm64-gnu": ["@rolldown/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-TuUkeuEEPRyXMBbJ86NRhAiPNezxHW8merl3Om2HASA9Pl1rI+VZcTtsVQ6v/P0MDIFpSl0k0+tUUze9HIXyEw=="],
|
||||
|
||||
"unrun/rolldown/@rolldown/binding-linux-arm64-musl": ["@rolldown/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-G43ZElEvaby+YSOgrXfBgpeQv42LdS0ivFFYQufk2tBDWeBfzE/+ob5DmO8Izbyn4Y8k6GgLF11jFDYNnmU/3w=="],
|
||||
|
||||
"unrun/rolldown/@rolldown/binding-linux-x64-gnu": ["@rolldown/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-1THb6FdBkAEL12zvUue2bmK4W1+P+tz8Pgu5uEzq+xrtYa3iBzmmKNlyfUzCFNCqsPd8WJEQrYdLcw4iMW4AVw=="],
|
||||
|
||||
"unrun/rolldown/@rolldown/binding-linux-x64-musl": ["@rolldown/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-12o73atFNWDgYnLyA52QEUn9AH8pHIe12W28cmqjyHt4bIEYRzMICvYVCPa2IQm6DJBvCBrEhD9K+ct4wr2hwg=="],
|
||||
|
||||
"unrun/rolldown/@rolldown/binding-openharmony-arm64": ["@rolldown/[email protected]", "", { "os": "none", "cpu": "arm64" }, "sha512-+uUgGwvuUCXl894MTsmTS2J0BnCZccFsmzV7y1jFxW5pTSxkuwL5agyPuDvDOztPeS6RrdqWkn7sT0jRd0ECkg=="],
|
||||
|
||||
"unrun/rolldown/@rolldown/binding-wasm32-wasi": ["@rolldown/[email protected]", "", { "dependencies": { "@napi-rs/wasm-runtime": "^1.1.1" }, "cpu": "none" }, "sha512-53p2L/NSy21UiFOqUGlC11kJDZS2Nx2GJRz1QvbkXovypA3cOHbsyZHLkV72JsLSbiEQe+kg4tndUhSiC31UEA=="],
|
||||
|
||||
"unrun/rolldown/@rolldown/binding-win32-arm64-msvc": ["@rolldown/[email protected]", "", { "os": "win32", "cpu": "arm64" }, "sha512-K6svNRljO6QrL6VTKxwh4yThhlR9DT/tK0XpaFQMnJwwQKng+NYcVEtUkAM0WsoiZHw+Hnh3DGnn3taf/pNYGg=="],
|
||||
|
||||
"unrun/rolldown/@rolldown/binding-win32-x64-msvc": ["@rolldown/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-3ZJBT47VWLKVKIyvHhUSUgVwHzzZW761YAIkM3tOT+8ZTjFVp0acCM0Y2Z2j3jCl+XYi2d9y2uEWQ8H0PvvpPw=="],
|
||||
|
||||
"unrun/rolldown/@rolldown/pluginutils": ["@rolldown/[email protected]", "", {}, "sha512-qujRfC8sFVInYSPPMLQByRh7zhwkGFS4+tyMQ83srV1qrxL4g8E2tyxVVyxd0+8QeBM1mIk9KbWxkegRr76XzA=="],
|
||||
|
||||
"vite/rolldown/@oxc-project/types": ["@oxc-project/[email protected]", "", {}, "sha512-4n91DKnebUS4yjUHl2g3/b2T+IUdCfmoZGhmwsovZCDaJSs+QkVAM+0AqqTxHSsHfeiMuueT75cZaZcT/m0pSw=="],
|
||||
|
||||
"vite/rolldown/@rolldown/binding-android-arm64": ["@rolldown/[email protected]", "", { "os": "android", "cpu": "arm64" }, "sha512-kvjTSWGcrv+BaR2vge57rsKiYdVR8V8CoS0vgKrc570qRBfty4bT+1X0z3j2TaVV+kAYzA0PjeB9+mdZyqUZlg=="],
|
||||
|
||||
"vite/rolldown/@rolldown/binding-darwin-arm64": ["@rolldown/[email protected]", "", { "os": "darwin", "cpu": "arm64" }, "sha512-+tJhD21KvGNtUrpLXrZQlT+j5HZKiEwR2qtcZb3vNOUpvoT9QjEykr75ZW/Kr0W89gose/HVXU6351uVZD8Qvw=="],
|
||||
|
||||
"vite/rolldown/@rolldown/binding-darwin-x64": ["@rolldown/[email protected]", "", { "os": "darwin", "cpu": "x64" }, "sha512-DKNhjMk38FAWaHwUt1dFR3rA/qRAvn2NUvSG2UGvxvlMxSmN/qqww/j4ABAbXhNRXtGQNmrAINMXRuwHl16ZHg=="],
|
||||
|
||||
"vite/rolldown/@rolldown/binding-freebsd-x64": ["@rolldown/[email protected]", "", { "os": "freebsd", "cpu": "x64" }, "sha512-8TThsRkCPAnfyMBShxrGdtoOE6h36QepqRQI97iFaQSCRbHFWHcDHppcojZnzXoruuhPnjMEygzaykvPVJsMRg=="],
|
||||
|
||||
"vite/rolldown/@rolldown/binding-linux-arm-gnueabihf": ["@rolldown/[email protected]", "", { "os": "linux", "cpu": "arm" }, "sha512-ZfmFoOwPUZCWtGOVC9/qbQzfc0249FrRUOzV2XabSMUV60Crp211OWLQN1zmQAsRIVWRcEwhJ46Z1mXGo/L/nQ=="],
|
||||
|
||||
"vite/rolldown/@rolldown/binding-linux-arm64-gnu": ["@rolldown/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-ZsGzbNETxPodGlLTYHaCSGVhNN/rvkMDCJYHdT7PZr5jFJRmBfmDi2awhF64Dt2vxrJqY6VeeYSgOzEbHRsb7Q=="],
|
||||
|
||||
"vite/rolldown/@rolldown/binding-linux-arm64-musl": ["@rolldown/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-elPpdevtCdUOqziemR86C4CSCr/5sUxalzDrf/CJdMT+kZt2C556as++qHikNOz0vuFf52h+GJNXZM08eWgGPQ=="],
|
||||
|
||||
"vite/rolldown/@rolldown/binding-linux-x64-gnu": ["@rolldown/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-IBwXsf56o3xhzAyaZxdM1CX8UFiBEUFCjiVUgny67Q8vPIqkjzJj0YKhd3TbBHanuxThgBa59f6Pgutg2OGk5A=="],
|
||||
|
||||
"vite/rolldown/@rolldown/binding-linux-x64-musl": ["@rolldown/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-vOk7G8V9Zm+8a6PL6JTpCea61q491oYlGtO6CvnsbhNLlKdf0bbCPytFzGQhYmCKZDKkEbmnkcIprTEGCURnwg=="],
|
||||
|
||||
"vite/rolldown/@rolldown/binding-openharmony-arm64": ["@rolldown/[email protected]", "", { "os": "none", "cpu": "arm64" }, "sha512-ASjEDI4MRv7XCQb2JVaBzfEYO98JKCGrAgoW6M03fJzH/ilCnC43Mb3ptB9q/lzsaahoJyIBoAGKAYEjUvpyvQ=="],
|
||||
|
||||
"vite/rolldown/@rolldown/binding-wasm32-wasi": ["@rolldown/[email protected]", "", { "dependencies": { "@napi-rs/wasm-runtime": "^1.1.1" }, "cpu": "none" }, "sha512-mYa1+h2l6Zc0LvmwUh0oXKKYihnw/1WC73vTqw+IgtfEtv47A+rWzzcWwVDkW73+UDr0d/Ie/HRXoaOY22pQDw=="],
|
||||
|
||||
"vite/rolldown/@rolldown/binding-win32-arm64-msvc": ["@rolldown/[email protected]", "", { "os": "win32", "cpu": "arm64" }, "sha512-e2ABskbNH3MRUBMjgxaMjYIw11DSwjLJxBII3UgpF6WClGLIh8A20kamc+FKH5vIaFVnYQInmcLYSUVpqMPLow=="],
|
||||
|
||||
"vite/rolldown/@rolldown/binding-win32-x64-msvc": ["@rolldown/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-dJVc3ifhaRXxIEh1xowLohzFrlQXkJ66LepHm+CmSprTWgVrPa8Fx3OL57xwIqDEH9hufcKkDX2v65rS3NZyRA=="],
|
||||
|
||||
"vite/rolldown/@rolldown/pluginutils": ["@rolldown/[email protected]", "", {}, "sha512-Y0+JT8Mi1mmW08K6HieG315XNRu4L0rkfCpA364HtytjgiqYnMYRdFPcxRl+BQQqNXzecL2S9nii+RUpO93XIA=="],
|
||||
|
||||
"vitest/vite/fsevents": ["[email protected]", "", { "os": "darwin" }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="],
|
||||
}
|
||||
|
||||
Loaded 100 of 124 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user