Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e5b2ce1518 | ||
|
|
a4d6d64c6e | ||
|
|
72e563e5f2 | ||
|
|
393c52c214 |
No files matched your search
+1
-1
@@ -5,7 +5,7 @@
|
||||
- `bun run dev:web` — Starts just the Vite dev server for the web app.
|
||||
- Dev commands default `T3CODE_STATE_DIR` to `~/.t3/dev` to keep dev state isolated from desktop/prod state.
|
||||
- Override server CLI-equivalent flags from root dev commands with `--`, for example:
|
||||
`bun run dev -- --base-dir ~/.t3-2`
|
||||
`bun run dev -- --state-dir ~/.t3/another-dev-state`
|
||||
- `bun run start` — Runs the production server (serves built web app as static files).
|
||||
- `bun run build` — Builds contracts, web app, and server through Turbo.
|
||||
- `bun run typecheck` — Strict TypeScript checks for all packages.
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# git autocrlf=true converts LF to CRLF on Windows, causing issues with oxfmt
|
||||
* text=auto eol=lf
|
||||
@@ -1,117 +0,0 @@
|
||||
name: Bug report
|
||||
description: Report broken behavior, regressions, crashes, or reliability issues.
|
||||
title: "[Bug]: "
|
||||
labels:
|
||||
- bug
|
||||
- needs-triage
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Use this form for broken behavior, regressions, crashes, or reliability problems.
|
||||
Search existing issues first and keep the report focused on one problem.
|
||||
|
||||
- type: checkboxes
|
||||
id: checks
|
||||
attributes:
|
||||
label: Before submitting
|
||||
options:
|
||||
- label: I searched existing issues and did not find a duplicate.
|
||||
required: true
|
||||
- label: I included enough detail to reproduce or investigate the problem.
|
||||
required: true
|
||||
|
||||
- type: dropdown
|
||||
id: area
|
||||
attributes:
|
||||
label: Area
|
||||
description: Which part of the project is affected?
|
||||
options:
|
||||
- apps/web
|
||||
- apps/server
|
||||
- apps/desktop
|
||||
- packages/contracts or packages/shared
|
||||
- Build, CI, or release tooling
|
||||
- Docs
|
||||
- Not sure
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: steps
|
||||
attributes:
|
||||
label: Steps to reproduce
|
||||
description: Provide a minimal, deterministic repro.
|
||||
placeholder: |
|
||||
1. Start the app with ...
|
||||
2. Open ...
|
||||
3. Disconnect the network
|
||||
4. Reconnect and send another prompt
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: expected
|
||||
attributes:
|
||||
label: Expected behavior
|
||||
placeholder: The thread should resume normally and accept the new message.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: actual
|
||||
attributes:
|
||||
label: Actual behavior
|
||||
placeholder: The composer clears, no new turn starts, and the session stays in a pending state.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: dropdown
|
||||
id: impact
|
||||
attributes:
|
||||
label: Impact
|
||||
description: How bad is this in practice?
|
||||
options:
|
||||
- Blocks work completely
|
||||
- Major degradation or frequent failure
|
||||
- Minor bug or occasional failure
|
||||
- Cosmetic issue
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: version
|
||||
attributes:
|
||||
label: Version or commit
|
||||
description: Release version, commit SHA, or branch name if known.
|
||||
placeholder: main @ abc1234
|
||||
|
||||
- type: input
|
||||
id: environment
|
||||
attributes:
|
||||
label: Environment
|
||||
description: OS, browser or desktop app version, Node/Bun version, provider/model if relevant.
|
||||
placeholder: macOS 15.3, Chrome 135, Bun 1.3.9, Codex app-server ...
|
||||
|
||||
- type: textarea
|
||||
id: logs
|
||||
attributes:
|
||||
label: Logs or stack traces
|
||||
description: Paste the most relevant output only. Redact secrets.
|
||||
render: shell
|
||||
|
||||
- type: upload
|
||||
id: attachments
|
||||
attributes:
|
||||
label: Screenshots, recordings, or supporting files
|
||||
description: Upload screenshots, short recordings, repro archives, or log files. Redact secrets before uploading.
|
||||
validations:
|
||||
required: false
|
||||
accept: ".png,.jpg,.jpeg,.gif,.webp,.svg,.mp4,.mov,.webm,.log,.txt,.json,.zip"
|
||||
|
||||
- type: textarea
|
||||
id: workaround
|
||||
attributes:
|
||||
label: Workaround
|
||||
description: If you found a temporary workaround, include it.
|
||||
placeholder: Restarting the provider session clears the stuck state.
|
||||
@@ -1,101 +0,0 @@
|
||||
name: Feature request
|
||||
description: Propose a scoped improvement or new capability.
|
||||
title: "[Feature]: "
|
||||
labels:
|
||||
- enhancement
|
||||
- needs-triage
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Use this form for new capabilities or meaningful improvements to existing behavior.
|
||||
This repo is still early. Small, concrete requests that clearly explain the problem and scope are much easier to evaluate.
|
||||
|
||||
- type: checkboxes
|
||||
id: checks
|
||||
attributes:
|
||||
label: Before submitting
|
||||
options:
|
||||
- label: I searched existing issues and did not find a duplicate.
|
||||
required: true
|
||||
- label: I am describing a concrete problem or use case, not just a vague idea.
|
||||
required: true
|
||||
|
||||
- type: dropdown
|
||||
id: area
|
||||
attributes:
|
||||
label: Area
|
||||
description: Which part of the project would this change affect?
|
||||
options:
|
||||
- apps/web
|
||||
- apps/server
|
||||
- apps/desktop
|
||||
- packages/contracts or packages/shared
|
||||
- Build, CI, or release tooling
|
||||
- Docs
|
||||
- Not sure
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: problem
|
||||
attributes:
|
||||
label: Problem or use case
|
||||
description: What are you trying to do? What is hard, slow, or impossible today?
|
||||
placeholder: I want to reconnect to an existing provider session after a browser refresh without losing the current thread state.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: proposal
|
||||
attributes:
|
||||
label: Proposed solution
|
||||
description: Describe the behavior, API, or UX you want.
|
||||
placeholder: Persist enough session metadata so the client can discover and reattach to the active provider session on load.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: value
|
||||
attributes:
|
||||
label: Why this matters
|
||||
description: Who benefits, and what outcome does this unlock?
|
||||
placeholder: This would make reconnects predictable during network drops and reduce accidental duplicate sessions.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: scope
|
||||
attributes:
|
||||
label: Smallest useful scope
|
||||
description: What is the narrowest version of this request that would still solve your problem?
|
||||
placeholder: A first pass only needs to support restoring the active session for the current thread.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: alternatives
|
||||
attributes:
|
||||
label: Alternatives considered
|
||||
description: Workarounds, prior art, or other approaches you considered.
|
||||
placeholder: I currently work around this by manually restarting the provider session, but that loses in-flight context.
|
||||
|
||||
- type: textarea
|
||||
id: tradeoffs
|
||||
attributes:
|
||||
label: Risks or tradeoffs
|
||||
description: What costs, complexity, or edge cases should be considered?
|
||||
placeholder: This may require careful handling when the underlying provider session has already exited.
|
||||
|
||||
- type: textarea
|
||||
id: references
|
||||
attributes:
|
||||
label: Examples or references
|
||||
description: Links, screenshots, mockups, or comparable tools.
|
||||
|
||||
- type: checkboxes
|
||||
id: contribution
|
||||
attributes:
|
||||
label: Contribution
|
||||
options:
|
||||
- label: I would be open to helping implement this.
|
||||
@@ -19,7 +19,6 @@ github:hwanseoc
|
||||
github:jamesx0416
|
||||
github:jasonLaster
|
||||
github:JoeEverest
|
||||
github:maria-rcks
|
||||
github:nmggithub
|
||||
github:Noojuno
|
||||
github:notkainoa
|
||||
@@ -28,5 +27,3 @@ github:realAhmedRoach
|
||||
github:shiroyasha9
|
||||
github:Yash-Singh1
|
||||
github:eggfriedrice24
|
||||
github:Ymit24
|
||||
github:shivamhwp
|
||||
@@ -12,7 +12,7 @@ jobs:
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Bun
|
||||
uses: oven-sh/setup-bun@v2
|
||||
@@ -20,12 +20,12 @@ jobs:
|
||||
bun-version-file: package.json
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v6
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: package.json
|
||||
|
||||
- name: Cache Bun and Turbo
|
||||
uses: actions/cache@v5
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.bun/install/cache
|
||||
@@ -35,7 +35,7 @@ jobs:
|
||||
${{ runner.os }}-bun-${{ hashFiles('bun.lock') }}-
|
||||
|
||||
- name: Cache Playwright browsers
|
||||
uses: actions/cache@v5
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/ms-playwright
|
||||
key: ${{ runner.os }}-playwright-${{ hashFiles('bun.lock') }}
|
||||
@@ -78,7 +78,7 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Bun
|
||||
uses: oven-sh/setup-bun@v2
|
||||
@@ -86,7 +86,7 @@ jobs:
|
||||
bun-version-file: package.json
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v6
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: package.json
|
||||
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
name: Issue Labels
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- .github/ISSUE_TEMPLATE/**
|
||||
- .github/workflows/issue-labels.yml
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
issues: write
|
||||
|
||||
jobs:
|
||||
sync:
|
||||
name: Sync issue labels
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Ensure managed issue labels exist
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const managedLabels = [
|
||||
{
|
||||
name: "bug",
|
||||
color: "d73a4a",
|
||||
description: "Something is broken or behaving incorrectly.",
|
||||
},
|
||||
{
|
||||
name: "enhancement",
|
||||
color: "a2eeef",
|
||||
description: "Requested improvement or new capability.",
|
||||
},
|
||||
{
|
||||
name: "needs-triage",
|
||||
color: "fbca04",
|
||||
description: "Issue needs maintainer review and initial categorization.",
|
||||
},
|
||||
];
|
||||
|
||||
for (const label of managedLabels) {
|
||||
try {
|
||||
const { data: existing } = await github.rest.issues.getLabel({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
name: label.name,
|
||||
});
|
||||
|
||||
if (
|
||||
existing.color !== label.color ||
|
||||
(existing.description ?? "") !== label.description
|
||||
) {
|
||||
await github.rest.issues.updateLabel({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
name: label.name,
|
||||
color: label.color,
|
||||
description: label.description,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
if (error.status !== 404) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
await github.rest.issues.createLabel({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
name: label.name,
|
||||
color: label.color,
|
||||
description: label.description,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,292 +0,0 @@
|
||||
name: PR Size
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [opened, reopened, synchronize, ready_for_review, converted_to_draft]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
prepare-config:
|
||||
name: Prepare PR size config
|
||||
runs-on: ubuntu-24.04
|
||||
outputs:
|
||||
labels_json: ${{ steps.config.outputs.labels_json }}
|
||||
steps:
|
||||
- id: config
|
||||
name: Build PR size label config
|
||||
uses: actions/github-script@v8
|
||||
with:
|
||||
result-encoding: string
|
||||
script: |
|
||||
const managedLabels = [
|
||||
{
|
||||
name: "size:XS",
|
||||
color: "0e8a16",
|
||||
description: "0-9 effective changed lines (test files excluded in mixed PRs).",
|
||||
},
|
||||
{
|
||||
name: "size:S",
|
||||
color: "5ebd3e",
|
||||
description: "10-29 effective changed lines (test files excluded in mixed PRs).",
|
||||
},
|
||||
{
|
||||
name: "size:M",
|
||||
color: "fbca04",
|
||||
description: "30-99 effective changed lines (test files excluded in mixed PRs).",
|
||||
},
|
||||
{
|
||||
name: "size:L",
|
||||
color: "fe7d37",
|
||||
description: "100-499 effective changed lines (test files excluded in mixed PRs).",
|
||||
},
|
||||
{
|
||||
name: "size:XL",
|
||||
color: "d93f0b",
|
||||
description: "500-999 effective changed lines (test files excluded in mixed PRs).",
|
||||
},
|
||||
{
|
||||
name: "size:XXL",
|
||||
color: "b60205",
|
||||
description: "1,000+ effective changed lines (test files excluded in mixed PRs).",
|
||||
},
|
||||
];
|
||||
|
||||
core.setOutput("labels_json", JSON.stringify(managedLabels));
|
||||
sync-label-definitions:
|
||||
name: Sync PR size label definitions
|
||||
needs: prepare-config
|
||||
if: github.event_name != 'pull_request_target'
|
||||
runs-on: ubuntu-24.04
|
||||
permissions:
|
||||
contents: read
|
||||
issues: write
|
||||
steps:
|
||||
- name: Ensure PR size labels exist
|
||||
uses: actions/github-script@v8
|
||||
env:
|
||||
PR_SIZE_LABELS_JSON: ${{ needs.prepare-config.outputs.labels_json }}
|
||||
with:
|
||||
script: |
|
||||
const managedLabels = JSON.parse(process.env.PR_SIZE_LABELS_JSON ?? "[]");
|
||||
|
||||
for (const label of managedLabels) {
|
||||
try {
|
||||
const { data: existing } = await github.rest.issues.getLabel({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
name: label.name,
|
||||
});
|
||||
|
||||
if (
|
||||
existing.color !== label.color ||
|
||||
(existing.description ?? "") !== label.description
|
||||
) {
|
||||
await github.rest.issues.updateLabel({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
name: label.name,
|
||||
color: label.color,
|
||||
description: label.description,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
if (error.status !== 404) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
try {
|
||||
await github.rest.issues.createLabel({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
name: label.name,
|
||||
color: label.color,
|
||||
description: label.description,
|
||||
});
|
||||
} catch (createError) {
|
||||
if (createError.status !== 422) {
|
||||
throw createError;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
label:
|
||||
name: Label PR size
|
||||
needs: prepare-config
|
||||
if: github.event_name == 'pull_request_target'
|
||||
runs-on: ubuntu-24.04
|
||||
permissions:
|
||||
contents: read
|
||||
issues: read
|
||||
pull-requests: write
|
||||
concurrency:
|
||||
group: pr-size-${{ github.event.pull_request.number }}
|
||||
cancel-in-progress: true
|
||||
steps:
|
||||
- name: Checkout base repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Sync PR size label
|
||||
uses: actions/github-script@v8
|
||||
env:
|
||||
PR_SIZE_LABELS_JSON: ${{ needs.prepare-config.outputs.labels_json }}
|
||||
with:
|
||||
script: |
|
||||
const { execFileSync } = require("node:child_process");
|
||||
|
||||
const issueNumber = context.payload.pull_request.number;
|
||||
const baseSha = context.payload.pull_request.base.sha;
|
||||
const headSha = context.payload.pull_request.head.sha;
|
||||
const headTrackingRef = `refs/remotes/pr-size/${issueNumber}`;
|
||||
const managedLabels = JSON.parse(process.env.PR_SIZE_LABELS_JSON ?? "[]");
|
||||
const managedLabelNames = new Set(managedLabels.map((label) => label.name));
|
||||
// Keep this aligned with the repo's test entrypoints and test-only support files.
|
||||
const testExcludePathspecs = [
|
||||
":(glob,exclude)**/__tests__/**",
|
||||
":(glob,exclude)**/test/**",
|
||||
":(glob,exclude)**/tests/**",
|
||||
":(glob,exclude)apps/server/integration/**",
|
||||
":(glob,exclude)**/*.test.*",
|
||||
":(glob,exclude)**/*.spec.*",
|
||||
":(glob,exclude)**/*.browser.*",
|
||||
":(glob,exclude)**/*.integration.*",
|
||||
];
|
||||
|
||||
const sumNumstat = (text) =>
|
||||
text
|
||||
.split("\n")
|
||||
.filter(Boolean)
|
||||
.reduce((total, line) => {
|
||||
const [insertionsRaw = "0", deletionsRaw = "0"] = line.split("\t");
|
||||
const additions =
|
||||
insertionsRaw === "-" ? 0 : Number.parseInt(insertionsRaw, 10) || 0;
|
||||
const deletions =
|
||||
deletionsRaw === "-" ? 0 : Number.parseInt(deletionsRaw, 10) || 0;
|
||||
|
||||
return total + additions + deletions;
|
||||
}, 0);
|
||||
|
||||
const resolveSizeLabel = (totalChangedLines) => {
|
||||
if (totalChangedLines < 10) {
|
||||
return "size:XS";
|
||||
}
|
||||
|
||||
if (totalChangedLines < 30) {
|
||||
return "size:S";
|
||||
}
|
||||
|
||||
if (totalChangedLines < 100) {
|
||||
return "size:M";
|
||||
}
|
||||
|
||||
if (totalChangedLines < 500) {
|
||||
return "size:L";
|
||||
}
|
||||
|
||||
if (totalChangedLines < 1000) {
|
||||
return "size:XL";
|
||||
}
|
||||
|
||||
return "size:XXL";
|
||||
};
|
||||
|
||||
execFileSync("git", ["fetch", "--no-tags", "origin", baseSha], {
|
||||
stdio: "inherit",
|
||||
});
|
||||
|
||||
execFileSync(
|
||||
"git",
|
||||
["fetch", "--no-tags", "origin", `+refs/pull/${issueNumber}/head:${headTrackingRef}`],
|
||||
{
|
||||
stdio: "inherit",
|
||||
},
|
||||
);
|
||||
|
||||
const resolvedHeadSha = execFileSync("git", ["rev-parse", headTrackingRef], {
|
||||
encoding: "utf8",
|
||||
}).trim();
|
||||
|
||||
if (resolvedHeadSha !== headSha) {
|
||||
core.warning(
|
||||
`Fetched head SHA ${resolvedHeadSha} does not match pull request head SHA ${headSha}; using fetched ref for sizing.`,
|
||||
);
|
||||
}
|
||||
|
||||
execFileSync("git", ["cat-file", "-e", `${baseSha}^{commit}`], {
|
||||
stdio: "inherit",
|
||||
});
|
||||
|
||||
const diffArgs = [
|
||||
"diff",
|
||||
"--numstat",
|
||||
"--ignore-all-space",
|
||||
"--ignore-blank-lines",
|
||||
`${baseSha}...${resolvedHeadSha}`,
|
||||
];
|
||||
|
||||
const totalChangedLines = sumNumstat(
|
||||
execFileSync(
|
||||
"git",
|
||||
diffArgs,
|
||||
{ encoding: "utf8" },
|
||||
),
|
||||
);
|
||||
const nonTestChangedLines = sumNumstat(
|
||||
execFileSync("git", [...diffArgs, "--", ".", ...testExcludePathspecs], {
|
||||
encoding: "utf8",
|
||||
}),
|
||||
);
|
||||
const testChangedLines = Math.max(0, totalChangedLines - nonTestChangedLines);
|
||||
|
||||
const changedLines = nonTestChangedLines === 0 ? testChangedLines : nonTestChangedLines;
|
||||
const nextLabelName = resolveSizeLabel(changedLines);
|
||||
|
||||
const { data: currentLabels } = await github.rest.issues.listLabelsOnIssue({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issueNumber,
|
||||
per_page: 100,
|
||||
});
|
||||
|
||||
for (const label of currentLabels) {
|
||||
if (!managedLabelNames.has(label.name) || label.name === nextLabelName) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
await github.rest.issues.removeLabel({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issueNumber,
|
||||
name: label.name,
|
||||
});
|
||||
} catch (removeError) {
|
||||
if (removeError.status !== 404) {
|
||||
throw removeError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!currentLabels.some((label) => label.name === nextLabelName)) {
|
||||
await github.rest.issues.addLabels({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issueNumber,
|
||||
labels: [nextLabelName],
|
||||
});
|
||||
}
|
||||
|
||||
const classification =
|
||||
nonTestChangedLines === 0
|
||||
? testChangedLines > 0
|
||||
? "test-only PR"
|
||||
: "no line changes"
|
||||
: testChangedLines > 0
|
||||
? "test lines excluded"
|
||||
: "all non-test changes";
|
||||
|
||||
core.info(
|
||||
`PR #${issueNumber}: ${nonTestChangedLines} non-test lines, ${testChangedLines} test lines, ${changedLines} effective lines -> ${nextLabelName} (${classification})`,
|
||||
);
|
||||
@@ -25,7 +25,7 @@ jobs:
|
||||
targets: ${{ steps.collect.outputs.targets }}
|
||||
steps:
|
||||
- id: collect
|
||||
uses: actions/github-script@v8
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
if (context.eventName === "pull_request_target") {
|
||||
@@ -85,7 +85,7 @@ jobs:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Sync PR labels
|
||||
uses: actions/github-script@v8
|
||||
uses: actions/github-script@v7
|
||||
env:
|
||||
PR_NUMBER: ${{ matrix.target.number }}
|
||||
VOUCH_STATUS: ${{ steps.vouch.outputs.status }}
|
||||
@@ -111,7 +111,7 @@ jobs:
|
||||
},
|
||||
];
|
||||
|
||||
const managedLabelNames = new Set(managedLabels.map((label) => label.name));
|
||||
const managedLabelNames = managedLabels.map((label) => label.name);
|
||||
|
||||
for (const label of managedLabels) {
|
||||
try {
|
||||
@@ -138,19 +138,13 @@ jobs:
|
||||
throw error;
|
||||
}
|
||||
|
||||
try {
|
||||
await github.rest.issues.createLabel({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
name: label.name,
|
||||
color: label.color,
|
||||
description: label.description,
|
||||
});
|
||||
} catch (createError) {
|
||||
if (createError.status !== 422) {
|
||||
throw createError;
|
||||
}
|
||||
}
|
||||
await github.rest.issues.createLabel({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
name: label.name,
|
||||
color: label.color,
|
||||
description: label.description,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,35 +159,17 @@ jobs:
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issueNumber,
|
||||
per_page: 100,
|
||||
});
|
||||
|
||||
for (const label of currentLabels) {
|
||||
if (!managedLabelNames.has(label.name) || label.name === nextLabelName) {
|
||||
continue;
|
||||
}
|
||||
const preservedLabels = currentLabels
|
||||
.map((label) => label.name)
|
||||
.filter((name) => !managedLabelNames.includes(name));
|
||||
|
||||
try {
|
||||
await github.rest.issues.removeLabel({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issueNumber,
|
||||
name: label.name,
|
||||
});
|
||||
} catch (removeError) {
|
||||
if (removeError.status !== 404) {
|
||||
throw removeError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!currentLabels.some((label) => label.name === nextLabelName)) {
|
||||
await github.rest.issues.addLabels({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issueNumber,
|
||||
labels: [nextLabelName],
|
||||
});
|
||||
}
|
||||
await github.rest.issues.setLabels({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issueNumber,
|
||||
labels: [...preservedLabels, nextLabelName],
|
||||
});
|
||||
|
||||
core.info(`PR #${issueNumber}: ${status} -> ${nextLabelName}`);
|
||||
@@ -27,7 +27,7 @@ jobs:
|
||||
ref: ${{ github.sha }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- id: release_meta
|
||||
name: Resolve release version
|
||||
@@ -61,7 +61,7 @@ jobs:
|
||||
bun-version-file: package.json
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v6
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: package.json
|
||||
|
||||
@@ -107,7 +107,7 @@ jobs:
|
||||
arch: x64
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ needs.preflight.outputs.ref }}
|
||||
fetch-depth: 0
|
||||
@@ -118,16 +118,13 @@ jobs:
|
||||
bun-version-file: package.json
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v6
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: package.json
|
||||
|
||||
- name: Install dependencies
|
||||
run: bun install --frozen-lockfile
|
||||
|
||||
- name: Align package versions to release version
|
||||
run: node scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
|
||||
|
||||
- name: Build desktop artifact
|
||||
shell: bash
|
||||
env:
|
||||
@@ -217,7 +214,7 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: Upload build artifacts
|
||||
uses: actions/upload-artifact@v7
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: desktop-${{ matrix.platform }}-${{ matrix.arch }}
|
||||
path: release-publish/*
|
||||
@@ -229,7 +226,7 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ needs.preflight.outputs.ref }}
|
||||
|
||||
@@ -239,7 +236,7 @@ jobs:
|
||||
bun-version-file: package.json
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v6
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: package.json
|
||||
registry-url: https://registry.npmjs.org
|
||||
@@ -247,9 +244,6 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: bun install --frozen-lockfile
|
||||
|
||||
- name: Align package versions to release version
|
||||
run: node scripts/update-release-package-versions.ts "${{ needs.preflight.outputs.version }}"
|
||||
|
||||
- name: Build CLI package
|
||||
run: bun run build --filter=@t3tools/web --filter=t3
|
||||
|
||||
@@ -262,17 +256,17 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ needs.preflight.outputs.ref }}
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v6
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: package.json
|
||||
|
||||
- name: Download all desktop artifacts
|
||||
uses: actions/download-artifact@v8
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: desktop-*
|
||||
merge-multiple: true
|
||||
@@ -308,31 +302,11 @@ jobs:
|
||||
needs: [preflight, release]
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- id: app_token
|
||||
name: Mint release app token
|
||||
uses: actions/create-github-app-token@v2
|
||||
with:
|
||||
app-id: ${{ secrets.RELEASE_APP_ID }}
|
||||
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
|
||||
owner: ${{ github.repository_owner }}
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: main
|
||||
fetch-depth: 0
|
||||
token: ${{ steps.app_token.outputs.token }}
|
||||
persist-credentials: true
|
||||
|
||||
- id: app_bot
|
||||
name: Resolve GitHub App bot identity
|
||||
env:
|
||||
GH_TOKEN: ${{ steps.app_token.outputs.token }}
|
||||
APP_SLUG: ${{ steps.app_token.outputs.app-slug }}
|
||||
run: |
|
||||
user_id="$(gh api "/users/${APP_SLUG}[bot]" --jq .id)"
|
||||
echo "name=${APP_SLUG}[bot]" >> "$GITHUB_OUTPUT"
|
||||
echo "email=${user_id}+${APP_SLUG}[bot]@users.noreply.github.com" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Setup Bun
|
||||
uses: oven-sh/setup-bun@v2
|
||||
@@ -340,7 +314,7 @@ jobs:
|
||||
bun-version-file: package.json
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v6
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version-file: package.json
|
||||
|
||||
@@ -369,8 +343,8 @@ jobs:
|
||||
exit 0
|
||||
fi
|
||||
|
||||
git config user.name "${{ steps.app_bot.outputs.name }}"
|
||||
git config user.email "${{ steps.app_bot.outputs.email }}"
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
git add apps/server/package.json apps/desktop/package.json apps/web/package.json packages/contracts/package.json bun.lock
|
||||
git commit -m "chore(release): prepare $RELEASE_TAG"
|
||||
|
||||
@@ -12,13 +12,7 @@ packages/*/dist
|
||||
build/
|
||||
.logs/
|
||||
release/
|
||||
release-mock/
|
||||
.t3
|
||||
.idea/
|
||||
apps/web/.playwright
|
||||
apps/web/playwright-report
|
||||
apps/web/src/components/__screenshots__
|
||||
.vitest-*
|
||||
__screenshots__/
|
||||
.tanstack
|
||||
artifacts/
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"$schema": "./node_modules/oxfmt/configuration_schema.json",
|
||||
"ignorePatterns": [
|
||||
".reference",
|
||||
".plans",
|
||||
"dist",
|
||||
"dist-electron",
|
||||
|
||||
@@ -1,441 +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 (post-Stage 1)
|
||||
|
||||
1. Provider runtime ingestion expects canonical `ProviderRuntimeEvent` shapes, not provider-native payloads.
|
||||
2. Start input now uses typed `providerOptions` and generic `resumeCursor`; top-level provider-specific fields were removed.
|
||||
3. `resumeCursor` is intentionally opaque outside adapters and must never be synthesized from `providerThreadId`.
|
||||
4. `ProviderService` still 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 (completed)
|
||||
|
||||
Update `packages/contracts/src/provider.ts`:
|
||||
|
||||
1. Move provider-specific start fields into typed `providerOptions`:
|
||||
- `providerOptions.codex`
|
||||
- `providerOptions.claudeCode`
|
||||
2. Keep `resumeCursor` as the single cross-provider resume input in `ProviderSessionStartInput`.
|
||||
3. Deprecate/remove `resumeThreadId` from the generic start contract.
|
||||
4. Treat `resumeCursor` as adapter-owned opaque state.
|
||||
|
||||
### 1.4 Contract tests (completed)
|
||||
|
||||
Update/add tests in `packages/contracts/src/*.test.ts` for:
|
||||
|
||||
1. New command payload shape.
|
||||
2. Provider-aware model resolution behavior.
|
||||
3. Breaking-change expectations for removed top-level provider fields.
|
||||
|
||||
---
|
||||
|
||||
## Phase 2: Claude adapter implementation
|
||||
|
||||
### 2.1 Add adapter service + layer
|
||||
|
||||
Create:
|
||||
|
||||
1. `apps/server/src/provider/Services/ClaudeAdapter.ts`
|
||||
2. `apps/server/src/provider/Layers/ClaudeAdapter.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 `providerOptions.claudeCode.binaryPath`)
|
||||
4. `permissionMode` (from `providerOptions.claudeCode.permissionMode`)
|
||||
5. `maxThinkingTokens` (from `providerOptions.claudeCode.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 opaque `resumeCursor` (parsed inside Claude adapter only).
|
||||
|
||||
#### 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`, both derived by parsing adapter-owned `resumeCursor`.
|
||||
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 claudeOptions = input.providerOptions?.claudeCode;
|
||||
const resumeState = readClaudeResumeState(input.resumeCursor);
|
||||
const abortController = new AbortController();
|
||||
const result = query({
|
||||
prompt: makePromptAsyncIterable(),
|
||||
options: {
|
||||
cwd: input.cwd,
|
||||
model: input.model,
|
||||
permissionMode: claudeOptions?.permissionMode,
|
||||
maxThinkingTokens: claudeOptions?.maxThinkingTokens,
|
||||
pathToClaudeCodeExecutable: claudeOptions?.binaryPath,
|
||||
resume: resumeState?.threadId,
|
||||
resumeSessionAt: resumeState?.sessionAt,
|
||||
signal: abortController.signal,
|
||||
includePartialMessages: true,
|
||||
canUseTool: makeCanUseTool(),
|
||||
hooks: makeClaudeHooks(),
|
||||
},
|
||||
});
|
||||
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 sdkMessageStream = Stream.async<ClaudeSdkMessage, ProviderAdapterProcessError>((emit) => {
|
||||
let cancelled = false;
|
||||
void (async () => {
|
||||
try {
|
||||
for await (const message of session.result) {
|
||||
if (cancelled) break;
|
||||
emit.single(message);
|
||||
}
|
||||
emit.end();
|
||||
} catch (cause) {
|
||||
emit.fail(
|
||||
new ProviderAdapterProcessError({
|
||||
provider: "claudeCode",
|
||||
sessionId,
|
||||
detail: "Claude runtime stream failed.",
|
||||
cause,
|
||||
}),
|
||||
);
|
||||
}
|
||||
})();
|
||||
return Effect.sync(() => {
|
||||
cancelled = true;
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
### 2.3 Canonical event mapping
|
||||
|
||||
Claude adapter must translate Agent SDK output into canonical `ProviderRuntimeEvent`.
|
||||
|
||||
Initial mapping target:
|
||||
|
||||
1. assistant text deltas -> `content.delta`
|
||||
2. final assistant text -> `item.completed` and/or `turn.completed`
|
||||
3. approval requests -> `request.opened`
|
||||
4. approval results -> `request.resolved`
|
||||
5. system lifecycle -> `session.*`, `thread.*`, `turn.*`
|
||||
6. errors -> `runtime.error`
|
||||
7. plan/proposed-plan content when derivable
|
||||
|
||||
Implementation note:
|
||||
|
||||
1. Keep raw Claude message on `raw` for debugging.
|
||||
2. Prefer canonical item/request kinds over provider-native enums.
|
||||
3. If Claude emits extra event kinds we do not model yet, map them to `tool.summary`, `runtime.warning`, or `unknown`-compatible payloads instead of dropping silently.
|
||||
|
||||
### 2.4 Resume cursor strategy
|
||||
|
||||
Define Claude-owned opaque resume state, e.g.:
|
||||
|
||||
```ts
|
||||
interface ClaudeResumeCursor {
|
||||
readonly version: 1;
|
||||
readonly threadId?: string;
|
||||
readonly sessionAt?: string;
|
||||
}
|
||||
```
|
||||
|
||||
Rules:
|
||||
|
||||
1. Serialize only adapter-owned state into `resumeCursor`.
|
||||
2. Parse/validate only inside Claude adapter.
|
||||
3. Store updated cursor when Claude runtime yields enough data to resume safely.
|
||||
4. Never overload orchestration thread id as Claude thread id.
|
||||
|
||||
### 2.5 Interrupt and stop semantics
|
||||
|
||||
Map orchestration stop/interrupt expectations onto SDK controls:
|
||||
|
||||
1. `interruptTurn()` -> active query interrupt.
|
||||
2. `stopSession()` -> close session resources and prevent future sends.
|
||||
3. `rollbackThread()` -> see Phase 4.
|
||||
|
||||
---
|
||||
|
||||
## Phase 3: Provider service and composition
|
||||
|
||||
### 3.1 Register Claude adapter
|
||||
|
||||
Update provider registry layer to include Claude:
|
||||
|
||||
1. add `claudeCode` -> `ClaudeAdapter`
|
||||
2. ensure `ProviderService.listProviderStatuses()` reports Claude availability
|
||||
|
||||
### 3.2 Persist provider binding
|
||||
|
||||
Current `ProviderSessionDirectory` already stores provider/thread binding and opaque `resumeCursor`.
|
||||
|
||||
Required validation:
|
||||
|
||||
1. Claude bindings survive restart.
|
||||
2. resume cursor remains opaque and round-trips untouched.
|
||||
3. stopAll + restart can recover Claude sessions when possible.
|
||||
|
||||
### 3.3 Provider start routing
|
||||
|
||||
Update `ProviderCommandReactor` / orchestration flow:
|
||||
|
||||
1. If a thread turn start requests `provider: "claudeCode"`, start Claude if no active session exists.
|
||||
2. If a thread already has Claude session binding, reuse it.
|
||||
3. If provider switches between Codex and Claude, explicitly stop/rebind before next send.
|
||||
|
||||
---
|
||||
|
||||
## Phase 4: Checkpoint and revert strategy
|
||||
|
||||
Claude does not necessarily expose the same conversation rewind primitive as Codex app-server. Current architecture expects `providerService.rollbackConversation()`.
|
||||
|
||||
Pick one explicit strategy:
|
||||
|
||||
### Option A: provider-native rewind
|
||||
|
||||
If SDK/runtime supports safe rewind:
|
||||
|
||||
1. implement in Claude adapter
|
||||
2. keep `CheckpointReactor` unchanged
|
||||
|
||||
### Option B: session restart + state truncation shim
|
||||
|
||||
If no native rewind exists:
|
||||
|
||||
1. Claude adapter returns successful rollback by:
|
||||
- stopping current Claude session
|
||||
- clearing/rewriting stored Claude resume cursor to last safe resumable point
|
||||
- forcing next turn to recreate session from persisted orchestration state
|
||||
2. Document that rollback is “conversation reset to checkpoint boundary”, not provider-native turn deletion.
|
||||
|
||||
Whichever option is chosen:
|
||||
|
||||
1. behavior must be deterministic
|
||||
2. checkpoint revert tests must pass under orchestration expectations
|
||||
3. user-visible activity log should explain failures clearly when provider rollback is impossible
|
||||
|
||||
---
|
||||
|
||||
## Phase 5: Web integration
|
||||
|
||||
### 5.1 Provider picker and model picker
|
||||
|
||||
Update web state/UI:
|
||||
|
||||
1. allow choosing Claude as thread provider before first turn
|
||||
2. show Claude model list from provider-aware model helpers
|
||||
3. preserve existing Codex default behavior when provider omitted
|
||||
|
||||
Likely touch points:
|
||||
|
||||
1. `apps/web/src/store.ts`
|
||||
2. `apps/web/src/components/ChatView.tsx`
|
||||
3. `apps/web/src/types.ts`
|
||||
4. `packages/shared/src/model.ts`
|
||||
|
||||
### 5.2 Settings for Claude executable/options
|
||||
|
||||
Add app settings if needed for:
|
||||
|
||||
1. Claude binary path
|
||||
2. default permission mode
|
||||
3. default max thinking tokens
|
||||
|
||||
Do not hardcode provider-specific config into generic session state if it belongs in app settings or typed `providerOptions`.
|
||||
|
||||
### 5.3 Session rendering
|
||||
|
||||
No new WS channel should be needed. Claude should appear through existing:
|
||||
|
||||
1. thread messages
|
||||
2. activities/worklog
|
||||
3. approvals
|
||||
4. session state
|
||||
5. checkpoints/diffs
|
||||
|
||||
---
|
||||
|
||||
## Phase 6: Testing strategy
|
||||
|
||||
### 6.1 Contract tests
|
||||
|
||||
Cover:
|
||||
|
||||
1. provider-aware model schemas
|
||||
2. provider field on turn-start command
|
||||
3. provider-specific start options schema
|
||||
|
||||
### 6.2 Adapter layer tests
|
||||
|
||||
Add `ClaudeAdapter.test.ts` covering:
|
||||
|
||||
1. session start
|
||||
2. event mapping
|
||||
3. approval bridge
|
||||
4. resume cursor parse/serialize
|
||||
5. interrupt behavior
|
||||
6. rollback behavior or explicit unsupported error path
|
||||
|
||||
Use SDK-facing layer tests/mocks only at the boundary. Do not mock orchestration business logic in higher-level tests.
|
||||
|
||||
### 6.3 Provider service integration tests
|
||||
|
||||
Extend provider integration coverage so Claude is exercised through `ProviderService`:
|
||||
|
||||
1. start Claude session
|
||||
2. send turn
|
||||
3. receive canonical runtime events
|
||||
4. restart/recover using persisted binding
|
||||
|
||||
### 6.4 Orchestration integration tests
|
||||
|
||||
Add/extend integration tests around:
|
||||
|
||||
1. first-turn provider selection
|
||||
2. Claude approval requests routed through orchestration
|
||||
3. Claude runtime ingestion -> messages/activities/session updates
|
||||
4. checkpoint revert behavior under Claude
|
||||
5. stopAll/restart recovery
|
||||
|
||||
These should validate real orchestration flows, not just adapter behavior.
|
||||
|
||||
---
|
||||
|
||||
## Phase 7: Rollout order
|
||||
|
||||
Recommended implementation order:
|
||||
|
||||
1. contracts/provider-aware models
|
||||
2. provider field on turn-start
|
||||
3. Claude adapter skeleton + start/send/stream
|
||||
4. canonical event mapping
|
||||
5. provider registry/service wiring
|
||||
6. orchestration recovery + checkpoint strategy
|
||||
7. web provider/model picker
|
||||
8. full integration tests
|
||||
|
||||
---
|
||||
|
||||
## Non-goals
|
||||
|
||||
1. Reintroducing provider-specific WS methods/channels.
|
||||
2. Storing provider-native thread ids as orchestration ids.
|
||||
3. Bypassing orchestration engine for Claude-specific UI flows.
|
||||
4. Encoding Claude resume semantics outside adapter-owned `resumeCursor`.
|
||||
@@ -1,89 +0,0 @@
|
||||
# Replace React Query With AtomRpc + Atom State
|
||||
|
||||
## Summary
|
||||
- Use `effect/unstable/reactivity/AtomRpc` over the existing `WsRpcGroup`; stop wrapping RPC in promises via [wsRpcClient.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/wsRpcClient.ts) and [wsNativeApi.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/wsNativeApi.ts).
|
||||
- Keep Zustand for orchestration read model and UI state.
|
||||
- Keep a narrow `desktopBridge` adapter for dialogs, menus, external links, theme, and updater APIs.
|
||||
- Do not introduce Suspense in this migration. Atom-backed hooks should keep returning `data`, `error`, `isLoading|isPending`, `refresh`, and `mutateAsync`-style surfaces so component churn stays low.
|
||||
|
||||
## Target Architecture
|
||||
- Extract the websocket `RpcClient.Protocol` layer from [wsTransport.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/wsTransport.ts) into `rpc/protocol.ts`.
|
||||
- Define one `AtomRpc.Service` for `WsRpcGroup` in `rpc/client.ts`.
|
||||
- Add `rpc/invalidation.ts` with explicit scoped invalidation keys: `git:${cwd}`, `project:${cwd}`, `checkpoint:${threadId}`, `server-config`.
|
||||
- Add `platform/desktopBridge.ts` as the only browser/desktop facade.
|
||||
- Remove from web by the end: [wsNativeApi.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/wsNativeApi.ts), [nativeApi.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/nativeApi.ts), [wsNativeApiState.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/wsNativeApiState.ts), [wsNativeApiAtoms.tsx](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/wsNativeApiAtoms.tsx), [wsRpcClient.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/wsRpcClient.ts), and all `*ReactQuery.ts` modules.
|
||||
|
||||
## Phase 1: Infrastructure First
|
||||
1. Extract the shared websocket RPC protocol layer from [wsTransport.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/wsTransport.ts) without changing behavior.
|
||||
2. Build the AtomRpc client on top of that layer.
|
||||
3. Add one temporary `runRpc` helper for imperative handlers that still want `Promise` ergonomics; it must call the AtomRpc service directly and must not reintroduce a facade object.
|
||||
4. Replace manual registry wiring with one app-level registry provider based on `@effect/atom-react`.
|
||||
5. Land this as a no-behavior-change PR.
|
||||
|
||||
## Phase 2: Replace `wsNativeApi`-Owned Push State
|
||||
1. Migrate welcome/config/provider/settings state first, because it is already atom-shaped and is the lowest-risk way to delete `wsNativeApi` responsibilities.
|
||||
2. Replace [wsNativeApiState.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/wsNativeApiState.ts) with `rpc/serverState.ts`, updated directly from `subscribeServerLifecycle` and `subscribeServerConfig`.
|
||||
3. Keep the current hook names for one PR: `useServerConfig`, `useServerSettings`, `useServerProviders`, `useServerKeybindings`, `useServerWelcomeSubscription`, `useServerConfigUpdatedSubscription`.
|
||||
4. Move bootstrap side effects out of [wsNativeApiAtoms.tsx](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/wsNativeApiAtoms.tsx) into a new root bootstrap component mounted from [__root.tsx](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/routes/__root.tsx).
|
||||
5. Delete the `server.getConfig()` fallback logic from [wsNativeApi.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/wsNativeApi.ts); snapshot fetch now lives beside the stream atoms.
|
||||
|
||||
## Phase 3: Replace React Query Domain By Domain
|
||||
1. Replace [gitReactQuery.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/lib/gitReactQuery.ts) first.
|
||||
2. Add `rpc/gitAtoms.ts` and `rpc/useGit.ts` with `useGitStatus`, `useGitBranches`, `useResolvePullRequest`, and `useGitMutation`.
|
||||
3. Mutation settlement must invalidate scoped keys, not a global cache. `checkout`, `pull`, `init`, `createWorktree`, `removeWorktree`, `preparePullRequestThread`, and stacked actions invalidate `git:${cwd}`. Worktree create/remove also invalidates `project:${cwd}`.
|
||||
4. Replace [projectReactQuery.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/lib/projectReactQuery.ts) second. `useProjectSearchEntries` must preserve current “keep previous results while loading” behavior.
|
||||
5. Replace [providerReactQuery.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/lib/providerReactQuery.ts) third. Preserve current checkpoint error normalization and retry/backoff semantics inside the atom effect. Invalidate by `checkpoint:${threadId}`.
|
||||
6. Defer the desktop updater until the last phase.
|
||||
|
||||
## Phase 4: Move Root Invalidation Off `queryClient`
|
||||
1. In [__root.tsx](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/routes/__root.tsx), remove `QueryClient` usage and replace the throttled `invalidateQueries` block with throttled invalidation helpers.
|
||||
2. Keep Zustand orchestration/event application unchanged.
|
||||
3. Map current effects exactly:
|
||||
- git or checkpoint-affecting orchestration events touch `checkpoint:${threadId}`
|
||||
- file creation/deletion/restoration touches `project:${cwd}`
|
||||
- config-affecting server events touch `server-config`
|
||||
|
||||
## Phase 5: Remove Imperative `NativeApi` Usage
|
||||
1. Create narrow modules instead of a replacement mega-facade:
|
||||
- `rpc/orchestrationActions.ts`
|
||||
- `rpc/terminalActions.ts`
|
||||
- `rpc/gitActions.ts`
|
||||
- `rpc/projectActions.ts`
|
||||
- `platform/desktopBridge.ts`
|
||||
2. Migrate direct [nativeApi.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/nativeApi.ts) callers by domain, not file-by-file: git-heavy components first, then orchestration/thread actions, then shell/dialog helpers.
|
||||
3. After the last caller is gone, delete [nativeApi.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/nativeApi.ts) and the `window.nativeApi` fallback entirely.
|
||||
4. In the final cleanup PR, remove `NativeApi` from [ipc.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/packages/contracts/src/ipc.ts) if nothing outside web still needs it.
|
||||
|
||||
## Phase 6: Remove React Query Completely
|
||||
1. Delete `@tanstack/react-query` from `apps/web/package.json`.
|
||||
2. Remove `QueryClientProvider` and router context from [router.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/router.ts) and [__root.tsx](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/routes/__root.tsx).
|
||||
3. Replace [desktopUpdateReactQuery.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/lib/desktopUpdateReactQuery.ts) with a writable atom plus `desktopBridge.onUpdateState`.
|
||||
4. Delete the old query-option tests.
|
||||
|
||||
## Public Interfaces And Types
|
||||
- Preserve the current server-state hook names during the transition.
|
||||
- Add permanent domain hooks: `useGitStatus`, `useGitBranches`, `useResolvePullRequest`, `useProjectSearchEntries`, `useCheckpointDiff`, `useDesktopUpdateState`.
|
||||
- Do not expose raw AtomRpc clients to components.
|
||||
- Do not add Suspense as part of this migration.
|
||||
- Final boundary is direct RPC for server features plus `desktopBridge` for local desktop features.
|
||||
|
||||
## Test Plan
|
||||
- Add unit tests for `rpc/serverState.ts`: snapshot bootstrapping, stream replay, provider/settings updates.
|
||||
- Add unit tests for git/project/checkpoint hooks: loading, error mapping, retry behavior, invalidation, keep-previous-result behavior.
|
||||
- Update the browser harness in [wsRpcHarness.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/test/wsRpcHarness.ts) to assert direct RPC + atom behavior instead of `__resetNativeApiForTests`.
|
||||
- Replace [wsNativeApi.test.ts](/Users/julius/.t3/worktrees/codething-mvp/effect-http-router/apps/web/src/wsNativeApi.test.ts), `gitReactQuery.test.ts`, `providerReactQuery.test.ts`, and `desktopUpdateReactQuery.test.ts` with equivalent atom-backed coverage.
|
||||
- Acceptance scenarios:
|
||||
- welcome still bootstraps snapshot and navigation
|
||||
- keybindings toast still responds to config stream updates
|
||||
- git status/branches refresh after checkout/pull/worktree actions
|
||||
- PR resolve dialog keeps cached result while typing
|
||||
- `@` path search refreshes after file mutations and orchestration events
|
||||
- diff panel refreshes when checkpoints arrive
|
||||
- desktop updater still reflects push events and button actions
|
||||
|
||||
## Assumptions And Defaults
|
||||
- Zustand stays in scope; only `react-query` is being removed.
|
||||
- `desktopBridge` remains the only non-RPC boundary.
|
||||
- The migration lands as 5-6 small PRs, each green independently.
|
||||
- Invalidations are explicit and scoped; do not recreate a global cache client abstraction.
|
||||
- Orchestration recovery/order logic stays as-is; only the data-fetching and mutation layer changes.
|
||||
@@ -0,0 +1,3 @@
|
||||
node_modules
|
||||
dist
|
||||
.DS_Store
|
||||
@@ -0,0 +1,92 @@
|
||||
# effect-http-ws-cli (PoC)
|
||||
|
||||
Minimal PoC using Effect v4 beta with a single unified program:
|
||||
|
||||
- `effect/unstable/cli` as the app entrypoint
|
||||
- `effect/unstable/http` (`HttpServer`, `HttpRouter`, `HttpServerRequest`, `HttpServerResponse`) for server/runtime logic
|
||||
- `@effect/platform-node` to host the server on Node.js
|
||||
- HTTP + WebSocket message routing based on `effect/Schema` validation
|
||||
- static asset serving from local filesystem (`public/` by default)
|
||||
|
||||
The repo now uses a Bun workspace:
|
||||
|
||||
- `server/` contains the Effect HTTP + WebSocket backend
|
||||
- `web/` remains the Vite + React frontend package
|
||||
|
||||
## Run
|
||||
|
||||
```bash
|
||||
bun install
|
||||
bun run web:build
|
||||
bun run start -- --port 8787 --host 127.0.0.1 --assets public --db todo.sqlite
|
||||
```
|
||||
|
||||
Then open `http://127.0.0.1:8787`.
|
||||
|
||||
## Frontend
|
||||
|
||||
React + Vite client lives in `web/` and is built into `public/` so it is served by the static router.
|
||||
|
||||
```bash
|
||||
bun run web:build
|
||||
```
|
||||
|
||||
For local development without building the frontend:
|
||||
|
||||
```bash
|
||||
bun run dev
|
||||
```
|
||||
|
||||
That starts the backend, starts Vite on `http://127.0.0.1:5173`, and redirects frontend page requests there. In dev, Vite proxies `/api/*`, `/ws`, and `/health` back to the backend server.
|
||||
|
||||
If you want to run the processes separately, start `bun run web:dev` and launch the backend with `FRONTEND_DEV_ORIGIN=http://127.0.0.1:5173`.
|
||||
|
||||
The UI now demonstrates a typed realtime todo workflow:
|
||||
|
||||
- load todo snapshot on page load (`listTodos`)
|
||||
- subscribe to todo updates (`subscribeTodos`)
|
||||
- mutate todos via RPC (`renameTodo`, `completeTodo`, `archiveTodo`)
|
||||
|
||||
### Config Sources
|
||||
|
||||
Config is resolved from both CLI flags and `effect/Config`:
|
||||
|
||||
- CLI flags: `--host`, `--port`, `--assets`, `--db`, `--request-logging`, `--frontend-dev-origin`
|
||||
- Env via `effect/Config`: `HOST`, `PORT`, `ASSETS_DIR`, `DB_FILENAME`, `REQUEST_LOGGING`, `FRONTEND_DEV_ORIGIN`
|
||||
|
||||
Precedence:
|
||||
|
||||
1. CLI flags
|
||||
2. `effect/Config` (environment)
|
||||
3. hard defaults (`127.0.0.1`, `8787`, `public`, `todo.sqlite`)
|
||||
|
||||
### SQL Persistence
|
||||
|
||||
- Uses `effect/unstable/sql` + `SqlSchema` for typed SQL request/result decoding.
|
||||
- Uses `@effect/sql-sqlite-node` as the Node runtime SQL client.
|
||||
- Database schema is managed by `effect/unstable/sql/Migrator` via `server/src/migrations.ts` with statically imported migration files.
|
||||
|
||||
## API
|
||||
|
||||
- `GET /health`
|
||||
- `POST /api/dispatch`
|
||||
- `GET /ws` (WebSocket RPC)
|
||||
- `GET *` (static files)
|
||||
|
||||
### Message schema
|
||||
|
||||
Incoming messages are validated with `Schema`:
|
||||
|
||||
- `{ "kind": "echo", "text": string }`
|
||||
- `{ "kind": "sum", "left": number, "right": number }`
|
||||
- `{ "kind": "time" }`
|
||||
|
||||
Both HTTP and WebSocket dispatch use the same schema-driven router.
|
||||
|
||||
## Verify
|
||||
|
||||
```bash
|
||||
bun run test
|
||||
bun run test:web
|
||||
bun run lint
|
||||
```
|
||||
@@ -0,0 +1,638 @@
|
||||
{
|
||||
"lockfileVersion": 1,
|
||||
"configVersion": 0,
|
||||
"workspaces": {
|
||||
"": {
|
||||
"name": "effect-http-ws-cli",
|
||||
},
|
||||
"server": {
|
||||
"name": "@effect-http-ws-cli/server",
|
||||
"version": "0.1.0",
|
||||
"dependencies": {
|
||||
"@effect/platform-node": "catalog:",
|
||||
"@effect/sql-sqlite-node": "catalog:",
|
||||
"effect": "catalog:",
|
||||
},
|
||||
"devDependencies": {
|
||||
"@effect/vitest": "catalog:",
|
||||
"@types/node": "^24.10.0",
|
||||
"typescript": "catalog:",
|
||||
"vitest": "catalog:",
|
||||
},
|
||||
},
|
||||
"web": {
|
||||
"name": "@effect-http-ws-cli/web",
|
||||
"version": "0.1.0",
|
||||
"dependencies": {
|
||||
"@effect-http-ws-cli/server": "workspace:*",
|
||||
"@effect/atom-react": "catalog:",
|
||||
"@tanstack/react-router": "^1.166.2",
|
||||
"effect": "catalog:",
|
||||
"react": "^19.2.0",
|
||||
"react-dom": "^19.2.0",
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tanstack/router-plugin": "^1.166.2",
|
||||
"@types/react": "^19.2.7",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@vitejs/plugin-react": "^5.1.1",
|
||||
"@vitest/browser-playwright": "^4.0.18",
|
||||
"playwright": "^1.58.2",
|
||||
"typescript": "catalog:",
|
||||
"vite": "^7.2.0",
|
||||
"vitest": "catalog:",
|
||||
"vitest-browser-react": "^2.0.5",
|
||||
},
|
||||
},
|
||||
},
|
||||
"catalog": {
|
||||
"@effect/atom-react": "4.0.0-beta.27",
|
||||
"@effect/platform-node": "4.0.0-beta.27",
|
||||
"@effect/sql-sqlite-node": "4.0.0-beta.27",
|
||||
"@effect/vitest": "4.0.0-beta.27",
|
||||
"effect": "4.0.0-beta.27",
|
||||
"typescript": "6.0.0-beta",
|
||||
"vitest": "^4.0.18",
|
||||
},
|
||||
"packages": {
|
||||
"@babel/code-frame": ["@babel/[email protected]", "", { "dependencies": { "@babel/helper-validator-identifier": "^7.28.5", "js-tokens": "^4.0.0", "picocolors": "^1.1.1" } }, "sha512-9NhCeYjq9+3uxgdtp20LSiJXJvN0FeCtNGpJxuMFZ1Kv3cWUNb6DOhJwUvcVCzKGR66cw4njwM6hrJLqgOwbcw=="],
|
||||
|
||||
"@babel/compat-data": ["@babel/[email protected]", "", {}, "sha512-T1NCJqT/j9+cn8fvkt7jtwbLBfLC/1y1c7NtCeXFRgzGTsafi68MRv8yzkYSapBnFA6L3U2VSc02ciDzoAJhJg=="],
|
||||
|
||||
"@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]", "", { "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=="],
|
||||
|
||||
"@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=="],
|
||||
|
||||
"@babel/helper-globals": ["@babel/[email protected]", "", {}, "sha512-+W6cISkXFa1jXsDEdYA8HeevQT/FULhxzR99pxphltZcVaugps53THCeiWA8SguxxpSp3gKPiuYfSWopkLQ4hw=="],
|
||||
|
||||
"@babel/helper-module-imports": ["@babel/[email protected]", "", { "dependencies": { "@babel/traverse": "^7.28.6", "@babel/types": "^7.28.6" } }, "sha512-l5XkZK7r7wa9LucGw9LwZyyCUscb4x37JWTPz7swwFE/0FMQAGpiWUZn8u9DzkSBWEcK25jmvubfpw2dnAMdbw=="],
|
||||
|
||||
"@babel/helper-module-transforms": ["@babel/[email protected]", "", { "dependencies": { "@babel/helper-module-imports": "^7.28.6", "@babel/helper-validator-identifier": "^7.28.5", "@babel/traverse": "^7.28.6" }, "peerDependencies": { "@babel/core": "^7.0.0" } }, "sha512-67oXFAYr2cDLDVGLXTEABjdBJZ6drElUSI7WKp70NrpyISso3plG9SAGEF6y7zbha/wOzUByWWTJvEDVNIUGcA=="],
|
||||
|
||||
"@babel/helper-plugin-utils": ["@babel/[email protected]", "", {}, "sha512-S9gzZ/bz83GRysI7gAD4wPT/AI3uCnY+9xn+Mx/KPs2JwHJIz1W8PZkg2cqyt3RNOBM8ejcXhV6y8Og7ly/Dug=="],
|
||||
|
||||
"@babel/helper-string-parser": ["@babel/[email protected]", "", {}, "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA=="],
|
||||
|
||||
"@babel/helper-validator-identifier": ["@babel/[email protected]", "", {}, "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q=="],
|
||||
|
||||
"@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]", "", { "dependencies": { "@babel/types": "^7.29.0" }, "bin": "./bin/babel-parser.js" }, "sha512-IyDgFV5GeDUVX4YdF/3CPULtVGSXXMLh1xVIgdCgxApktqnQV0r7/8Nqthg+8YLGaAtdyIlo2qIdZrbCv4+7ww=="],
|
||||
|
||||
"@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=="],
|
||||
|
||||
"@babel/plugin-syntax-typescript": ["@babel/[email protected]", "", { "dependencies": { "@babel/helper-plugin-utils": "^7.28.6" }, "peerDependencies": { "@babel/core": "^7.0.0-0" } }, "sha512-+nDNmQye7nlnuuHDboPbGm00Vqg3oO8niRRL27/4LYHUsHYh0zJ1xWOz0uRwNFmM1Avzk8wZbc6rdiYhomzv/A=="],
|
||||
|
||||
"@babel/plugin-transform-react-jsx-self": ["@babel/[email protected]", "", { "dependencies": { "@babel/helper-plugin-utils": "^7.27.1" }, "peerDependencies": { "@babel/core": "^7.0.0-0" } }, "sha512-6UzkCs+ejGdZ5mFFC/OCUrv028ab2fp1znZmCZjAOBKiBK2jXD1O+BPSfX8X2qjJ75fZBMSnQn3Rq2mrBJK2mw=="],
|
||||
|
||||
"@babel/plugin-transform-react-jsx-source": ["@babel/[email protected]", "", { "dependencies": { "@babel/helper-plugin-utils": "^7.27.1" }, "peerDependencies": { "@babel/core": "^7.0.0-0" } }, "sha512-zbwoTsBruTeKB9hSq73ha66iFeJHuaFkUbwvqElnygoNbj/jHRsSeokowZFN3CZ64IvEqcmmkVe89OPXc7ldAw=="],
|
||||
|
||||
"@babel/template": ["@babel/[email protected]", "", { "dependencies": { "@babel/code-frame": "^7.28.6", "@babel/parser": "^7.28.6", "@babel/types": "^7.28.6" } }, "sha512-YA6Ma2KsCdGb+WC6UpBVFJGXL58MDA6oyONbjyF/+5sBgxY/dwkhLogbMT2GXXyU84/IhRw/2D1Os1B/giz+BQ=="],
|
||||
|
||||
"@babel/traverse": ["@babel/[email protected]", "", { "dependencies": { "@babel/code-frame": "^7.29.0", "@babel/generator": "^7.29.0", "@babel/helper-globals": "^7.28.0", "@babel/parser": "^7.29.0", "@babel/template": "^7.28.6", "@babel/types": "^7.29.0", "debug": "^4.3.1" } }, "sha512-4HPiQr0X7+waHfyXPZpWPfWL/J7dcN1mx9gL6WdQVMbPnF3+ZhSMs8tCxN7oHddJE9fhNE7+lxdnlyemKfJRuA=="],
|
||||
|
||||
"@babel/types": ["@babel/[email protected]", "", { "dependencies": { "@babel/helper-string-parser": "^7.27.1", "@babel/helper-validator-identifier": "^7.28.5" } }, "sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A=="],
|
||||
|
||||
"@effect-http-ws-cli/server": ["@effect-http-ws-cli/server@workspace:server"],
|
||||
|
||||
"@effect-http-ws-cli/web": ["@effect-http-ws-cli/web@workspace:web"],
|
||||
|
||||
"@effect/atom-react": ["@effect/[email protected]", "", { "peerDependencies": { "effect": "^4.0.0-beta.27", "react": "^19.2.4", "scheduler": "*" } }, "sha512-miq9lG74I9ypFdDTUIYWQR2OomxDweYM4Fv/h/Md0eXVrk+c/KAkgK0YT5pn3x5plZUHSuSuBEC36185/zpFPA=="],
|
||||
|
||||
"@effect/platform-node": ["@effect/[email protected]", "", { "dependencies": { "@effect/platform-node-shared": "^4.0.0-beta.27", "mime": "^4.1.0", "undici": "^7.20.0" }, "peerDependencies": { "effect": "^4.0.0-beta.27", "ioredis": "^5.7.0" } }, "sha512-UPZMtFVnDIM5nb6A2pEPo229VnfgMdvl/9sGiQaYRB9qEVHerk0elxcoWOb2szoivBYePYFOsPKIWpR6jCldtQ=="],
|
||||
|
||||
"@effect/platform-node-shared": ["@effect/[email protected]", "", { "dependencies": { "@types/ws": "^8.18.1", "ws": "^8.19.0" }, "peerDependencies": { "effect": "^4.0.0-beta.27" } }, "sha512-prRa5MIWGAvq2g6FgVP5RFfPwI+DvcXCaEZetvPMK70wdkTR1+jKQqJ9QDKWNIP+2d4llE/cF21SvcpBJWq0gw=="],
|
||||
|
||||
"@effect/sql-sqlite-node": ["@effect/[email protected]", "", { "dependencies": { "better-sqlite3": "^12.6.2" }, "peerDependencies": { "effect": "^4.0.0-beta.27" } }, "sha512-GhTe2gIob7wuQ7OYHM+FtjPhYhf0oFtImPWwaXdQ14kxCSQVFuHY+ll45p2bxTAInnrnDip+Q+UC6xpNnvI3Cw=="],
|
||||
|
||||
"@effect/vitest": ["@effect/[email protected]", "", { "peerDependencies": { "effect": "^4.0.0-beta.27", "vitest": "^3.0.0 || ^4.0.0" } }, "sha512-l9LIQK2yqOF3h47CmlT2VfYWtfHLd+ZuMzma+w0OjxmPsR6bzYMA33ft4gljJ/lEQnXvGHxiTpnZySALCfv+pA=="],
|
||||
|
||||
"@esbuild/aix-ppc64": ["@esbuild/[email protected]", "", { "os": "aix", "cpu": "ppc64" }, "sha512-9fJMTNFTWZMh5qwrBItuziu834eOCUcEqymSH7pY+zoMVEZg3gcPuBNxH1EvfVYe9h0x/Ptw8KBzv7qxb7l8dg=="],
|
||||
|
||||
"@esbuild/android-arm": ["@esbuild/[email protected]", "", { "os": "android", "cpu": "arm" }, "sha512-i5D1hPY7GIQmXlXhs2w8AWHhenb00+GxjxRncS2ZM7YNVGNfaMxgzSGuO8o8SJzRc/oZwU2bcScvVERk03QhzA=="],
|
||||
|
||||
"@esbuild/android-arm64": ["@esbuild/[email protected]", "", { "os": "android", "cpu": "arm64" }, "sha512-YdghPYUmj/FX2SYKJ0OZxf+iaKgMsKHVPF1MAq/P8WirnSpCStzKJFjOjzsW0QQ7oIAiccHdcqjbHmJxRb/dmg=="],
|
||||
|
||||
"@esbuild/android-x64": ["@esbuild/[email protected]", "", { "os": "android", "cpu": "x64" }, "sha512-IN/0BNTkHtk8lkOM8JWAYFg4ORxBkZQf9zXiEOfERX/CzxW3Vg1ewAhU7QSWQpVIzTW+b8Xy+lGzdYXV6UZObQ=="],
|
||||
|
||||
"@esbuild/darwin-arm64": ["@esbuild/[email protected]", "", { "os": "darwin", "cpu": "arm64" }, "sha512-Re491k7ByTVRy0t3EKWajdLIr0gz2kKKfzafkth4Q8A5n1xTHrkqZgLLjFEHVD+AXdUGgQMq+Godfq45mGpCKg=="],
|
||||
|
||||
"@esbuild/darwin-x64": ["@esbuild/[email protected]", "", { "os": "darwin", "cpu": "x64" }, "sha512-vHk/hA7/1AckjGzRqi6wbo+jaShzRowYip6rt6q7VYEDX4LEy1pZfDpdxCBnGtl+A5zq8iXDcyuxwtv3hNtHFg=="],
|
||||
|
||||
"@esbuild/freebsd-arm64": ["@esbuild/[email protected]", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-ipTYM2fjt3kQAYOvo6vcxJx3nBYAzPjgTCk7QEgZG8AUO3ydUhvelmhrbOheMnGOlaSFUoHXB6un+A7q4ygY9w=="],
|
||||
|
||||
"@esbuild/freebsd-x64": ["@esbuild/[email protected]", "", { "os": "freebsd", "cpu": "x64" }, "sha512-dDk0X87T7mI6U3K9VjWtHOXqwAMJBNN2r7bejDsc+j03SEjtD9HrOl8gVFByeM0aJksoUuUVU9TBaZa2rgj0oA=="],
|
||||
|
||||
"@esbuild/linux-arm": ["@esbuild/[email protected]", "", { "os": "linux", "cpu": "arm" }, "sha512-s6nPv2QkSupJwLYyfS+gwdirm0ukyTFNl3KTgZEAiJDd+iHZcbTPPcWCcRYH+WlNbwChgH2QkE9NSlNrMT8Gfw=="],
|
||||
|
||||
"@esbuild/linux-arm64": ["@esbuild/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-sZOuFz/xWnZ4KH3YfFrKCf1WyPZHakVzTiqji3WDc0BCl2kBwiJLCXpzLzUBLgmp4veFZdvN5ChW4Eq/8Fc2Fg=="],
|
||||
|
||||
"@esbuild/linux-ia32": ["@esbuild/[email protected]", "", { "os": "linux", "cpu": "ia32" }, "sha512-yGlQYjdxtLdh0a3jHjuwOrxQjOZYD/C9PfdbgJJF3TIZWnm/tMd/RcNiLngiu4iwcBAOezdnSLAwQDPqTmtTYg=="],
|
||||
|
||||
"@esbuild/linux-loong64": ["@esbuild/[email protected]", "", { "os": "linux", "cpu": "none" }, "sha512-WO60Sn8ly3gtzhyjATDgieJNet/KqsDlX5nRC5Y3oTFcS1l0KWba+SEa9Ja1GfDqSF1z6hif/SkpQJbL63cgOA=="],
|
||||
|
||||
"@esbuild/linux-mips64el": ["@esbuild/[email protected]", "", { "os": "linux", "cpu": "none" }, "sha512-APsymYA6sGcZ4pD6k+UxbDjOFSvPWyZhjaiPyl/f79xKxwTnrn5QUnXR5prvetuaSMsb4jgeHewIDCIWljrSxw=="],
|
||||
|
||||
"@esbuild/linux-ppc64": ["@esbuild/[email protected]", "", { "os": "linux", "cpu": "ppc64" }, "sha512-eizBnTeBefojtDb9nSh4vvVQ3V9Qf9Df01PfawPcRzJH4gFSgrObw+LveUyDoKU3kxi5+9RJTCWlj4FjYXVPEA=="],
|
||||
|
||||
"@esbuild/linux-riscv64": ["@esbuild/[email protected]", "", { "os": "linux", "cpu": "none" }, "sha512-3Emwh0r5wmfm3ssTWRQSyVhbOHvqegUDRd0WhmXKX2mkHJe1SFCMJhagUleMq+Uci34wLSipf8Lagt4LlpRFWQ=="],
|
||||
|
||||
"@esbuild/linux-s390x": ["@esbuild/[email protected]", "", { "os": "linux", "cpu": "s390x" }, "sha512-pBHUx9LzXWBc7MFIEEL0yD/ZVtNgLytvx60gES28GcWMqil8ElCYR4kvbV2BDqsHOvVDRrOxGySBM9Fcv744hw=="],
|
||||
|
||||
"@esbuild/linux-x64": ["@esbuild/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-Czi8yzXUWIQYAtL/2y6vogER8pvcsOsk5cpwL4Gk5nJqH5UZiVByIY8Eorm5R13gq+DQKYg0+JyQoytLQas4dA=="],
|
||||
|
||||
"@esbuild/netbsd-arm64": ["@esbuild/[email protected]", "", { "os": "none", "cpu": "arm64" }, "sha512-sDpk0RgmTCR/5HguIZa9n9u+HVKf40fbEUt+iTzSnCaGvY9kFP0YKBWZtJaraonFnqef5SlJ8/TiPAxzyS+UoA=="],
|
||||
|
||||
"@esbuild/netbsd-x64": ["@esbuild/[email protected]", "", { "os": "none", "cpu": "x64" }, "sha512-P14lFKJl/DdaE00LItAukUdZO5iqNH7+PjoBm+fLQjtxfcfFE20Xf5CrLsmZdq5LFFZzb5JMZ9grUwvtVYzjiA=="],
|
||||
|
||||
"@esbuild/openbsd-arm64": ["@esbuild/[email protected]", "", { "os": "openbsd", "cpu": "arm64" }, "sha512-AIcMP77AvirGbRl/UZFTq5hjXK+2wC7qFRGoHSDrZ5v5b8DK/GYpXW3CPRL53NkvDqb9D+alBiC/dV0Fb7eJcw=="],
|
||||
|
||||
"@esbuild/openbsd-x64": ["@esbuild/[email protected]", "", { "os": "openbsd", "cpu": "x64" }, "sha512-DnW2sRrBzA+YnE70LKqnM3P+z8vehfJWHXECbwBmH/CU51z6FiqTQTHFenPlHmo3a8UgpLyH3PT+87OViOh1AQ=="],
|
||||
|
||||
"@esbuild/openharmony-arm64": ["@esbuild/[email protected]", "", { "os": "none", "cpu": "arm64" }, "sha512-NinAEgr/etERPTsZJ7aEZQvvg/A6IsZG/LgZy+81wON2huV7SrK3e63dU0XhyZP4RKGyTm7aOgmQk0bGp0fy2g=="],
|
||||
|
||||
"@esbuild/sunos-x64": ["@esbuild/[email protected]", "", { "os": "sunos", "cpu": "x64" }, "sha512-PanZ+nEz+eWoBJ8/f8HKxTTD172SKwdXebZ0ndd953gt1HRBbhMsaNqjTyYLGLPdoWHy4zLU7bDVJztF5f3BHA=="],
|
||||
|
||||
"@esbuild/win32-arm64": ["@esbuild/[email protected]", "", { "os": "win32", "cpu": "arm64" }, "sha512-B2t59lWWYrbRDw/tjiWOuzSsFh1Y/E95ofKz7rIVYSQkUYBjfSgf6oeYPNWHToFRr2zx52JKApIcAS/D5TUBnA=="],
|
||||
|
||||
"@esbuild/win32-ia32": ["@esbuild/[email protected]", "", { "os": "win32", "cpu": "ia32" }, "sha512-QLKSFeXNS8+tHW7tZpMtjlNb7HKau0QDpwm49u0vUp9y1WOF+PEzkU84y9GqYaAVW8aH8f3GcBck26jh54cX4Q=="],
|
||||
|
||||
"@esbuild/win32-x64": ["@esbuild/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-4uJGhsxuptu3OcpVAzli+/gWusVGwZZHTlS63hh++ehExkVT8SgiEf7/uC/PclrPPkLhZqGgCTjd0VWLo6xMqA=="],
|
||||
|
||||
"@ioredis/commands": ["@ioredis/[email protected]", "", {}, "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=="],
|
||||
|
||||
"@jridgewell/remapping": ["@jridgewell/[email protected]", "", { "dependencies": { "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.24" } }, "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ=="],
|
||||
|
||||
"@jridgewell/resolve-uri": ["@jridgewell/[email protected]", "", {}, "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw=="],
|
||||
|
||||
"@jridgewell/sourcemap-codec": ["@jridgewell/[email protected]", "", {}, "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og=="],
|
||||
|
||||
"@jridgewell/trace-mapping": ["@jridgewell/[email protected]", "", { "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", "@jridgewell/sourcemap-codec": "^1.4.14" } }, "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw=="],
|
||||
|
||||
"@msgpackr-extract/msgpackr-extract-darwin-arm64": ["@msgpackr-extract/[email protected]", "", { "os": "darwin", "cpu": "arm64" }, "sha512-QZHtlVgbAdy2zAqNA9Gu1UpIuI8Xvsd1v8ic6B2pZmeFnFcMWiPLfWXh7TVw4eGEZ/C9TH281KwhVoeQUKbyjw=="],
|
||||
|
||||
"@msgpackr-extract/msgpackr-extract-darwin-x64": ["@msgpackr-extract/[email protected]", "", { "os": "darwin", "cpu": "x64" }, "sha512-mdzd3AVzYKuUmiWOQ8GNhl64/IoFGol569zNRdkLReh6LRLHOXxU4U8eq0JwaD8iFHdVGqSy4IjFL4reoWCDFw=="],
|
||||
|
||||
"@msgpackr-extract/msgpackr-extract-linux-arm": ["@msgpackr-extract/[email protected]", "", { "os": "linux", "cpu": "arm" }, "sha512-fg0uy/dG/nZEXfYilKoRe7yALaNmHoYeIoJuJ7KJ+YyU2bvY8vPv27f7UKhGRpY6euFYqEVhxCFZgAUNQBM3nw=="],
|
||||
|
||||
"@msgpackr-extract/msgpackr-extract-linux-arm64": ["@msgpackr-extract/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-YxQL+ax0XqBJDZiKimS2XQaf+2wDGVa1enVRGzEvLLVFeqa5kx2bWbtcSXgsxjQB7nRqqIGFIcLteF/sHeVtQg=="],
|
||||
|
||||
"@msgpackr-extract/msgpackr-extract-linux-x64": ["@msgpackr-extract/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-cvwNfbP07pKUfq1uH+S6KJ7dT9K8WOE4ZiAcsrSes+UY55E/0jLYc+vq+DO7jlmqRb5zAggExKm0H7O/CBaesg=="],
|
||||
|
||||
"@msgpackr-extract/msgpackr-extract-win32-x64": ["@msgpackr-extract/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-x0fWaQtYp4E6sktbsdAqnehxDgEc/VwM7uLsRCYWaiGu0ykYdZPiS8zCWdnjHwyiumousxfBm4SO31eXqwEZhQ=="],
|
||||
|
||||
"@polka/url": ["@polka/[email protected]", "", {}, "sha512-wwQAWhWSuHaag8c4q/KN/vCoeOJYshAIvMQwD4GpSb3OiZklFfvAgmj0VCBBImRpuF/aFgIRzllXlVX93Jevww=="],
|
||||
|
||||
"@rolldown/pluginutils": ["@rolldown/[email protected]", "", {}, "sha512-eybk3TjzzzV97Dlj5c+XrBFW57eTNhzod66y9HrBlzJ6NsCrWCp/2kaPS3K9wJmurBC0Tdw4yPjXKZqlznim3Q=="],
|
||||
|
||||
"@rollup/rollup-android-arm-eabi": ["@rollup/[email protected]", "", { "os": "android", "cpu": "arm" }, "sha512-upnNBkA6ZH2VKGcBj9Fyl9IGNPULcjXRlg0LLeaioQWueH30p6IXtJEbKAgvyv+mJaMxSm1l6xwDXYjpEMiLMg=="],
|
||||
|
||||
"@rollup/rollup-android-arm64": ["@rollup/[email protected]", "", { "os": "android", "cpu": "arm64" }, "sha512-hZ+Zxj3SySm4A/DylsDKZAeVg0mvi++0PYVceVyX7hemkw7OreKdCvW2oQ3T1FMZvCaQXqOTHb8qmBShoqk69Q=="],
|
||||
|
||||
"@rollup/rollup-darwin-arm64": ["@rollup/[email protected]", "", { "os": "darwin", "cpu": "arm64" }, "sha512-W2Psnbh1J8ZJw0xKAd8zdNgF9HRLkdWwwdWqubSVk0pUuQkoHnv7rx4GiF9rT4t5DIZGAsConRE3AxCdJ4m8rg=="],
|
||||
|
||||
"@rollup/rollup-darwin-x64": ["@rollup/[email protected]", "", { "os": "darwin", "cpu": "x64" }, "sha512-ZW2KkwlS4lwTv7ZVsYDiARfFCnSGhzYPdiOU4IM2fDbL+QGlyAbjgSFuqNRbSthybLbIJ915UtZBtmuLrQAT/w=="],
|
||||
|
||||
"@rollup/rollup-freebsd-arm64": ["@rollup/[email protected]", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-EsKaJ5ytAu9jI3lonzn3BgG8iRBjV4LxZexygcQbpiU0wU0ATxhNVEpXKfUa0pS05gTcSDMKpn3Sx+QB9RlTTA=="],
|
||||
|
||||
"@rollup/rollup-freebsd-x64": ["@rollup/[email protected]", "", { "os": "freebsd", "cpu": "x64" }, "sha512-d3DuZi2KzTMjImrxoHIAODUZYoUUMsuUiY4SRRcJy6NJoZ6iIqWnJu9IScV9jXysyGMVuW+KNzZvBLOcpdl3Vg=="],
|
||||
|
||||
"@rollup/rollup-linux-arm-gnueabihf": ["@rollup/[email protected]", "", { "os": "linux", "cpu": "arm" }, "sha512-t4ONHboXi/3E0rT6OZl1pKbl2Vgxf9vJfWgmUoCEVQVxhW6Cw/c8I6hbbu7DAvgp82RKiH7TpLwxnJeKv2pbsw=="],
|
||||
|
||||
"@rollup/rollup-linux-arm-musleabihf": ["@rollup/[email protected]", "", { "os": "linux", "cpu": "arm" }, "sha512-CikFT7aYPA2ufMD086cVORBYGHffBo4K8MQ4uPS/ZnY54GKj36i196u8U+aDVT2LX4eSMbyHtyOh7D7Zvk2VvA=="],
|
||||
|
||||
"@rollup/rollup-linux-arm64-gnu": ["@rollup/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-jYgUGk5aLd1nUb1CtQ8E+t5JhLc9x5WdBKew9ZgAXg7DBk0ZHErLHdXM24rfX+bKrFe+Xp5YuJo54I5HFjGDAA=="],
|
||||
|
||||
"@rollup/rollup-linux-arm64-musl": ["@rollup/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-peZRVEdnFWZ5Bh2KeumKG9ty7aCXzzEsHShOZEFiCQlDEepP1dpUl/SrUNXNg13UmZl+gzVDPsiCwnV1uI0RUA=="],
|
||||
|
||||
"@rollup/rollup-linux-loong64-gnu": ["@rollup/[email protected]", "", { "os": "linux", "cpu": "none" }, "sha512-gbUSW/97f7+r4gHy3Jlup8zDG190AuodsWnNiXErp9mT90iCy9NKKU0Xwx5k8VlRAIV2uU9CsMnEFg/xXaOfXg=="],
|
||||
|
||||
"@rollup/rollup-linux-loong64-musl": ["@rollup/[email protected]", "", { "os": "linux", "cpu": "none" }, "sha512-yTRONe79E+o0FWFijasoTjtzG9EBedFXJMl888NBEDCDV9I2wGbFFfJQQe63OijbFCUZqxpHz1GzpbtSFikJ4Q=="],
|
||||
|
||||
"@rollup/rollup-linux-ppc64-gnu": ["@rollup/[email protected]", "", { "os": "linux", "cpu": "ppc64" }, "sha512-sw1o3tfyk12k3OEpRddF68a1unZ5VCN7zoTNtSn2KndUE+ea3m3ROOKRCZxEpmT9nsGnogpFP9x6mnLTCaoLkA=="],
|
||||
|
||||
"@rollup/rollup-linux-ppc64-musl": ["@rollup/[email protected]", "", { "os": "linux", "cpu": "ppc64" }, "sha512-+2kLtQ4xT3AiIxkzFVFXfsmlZiG5FXYW7ZyIIvGA7Bdeuh9Z0aN4hVyXS/G1E9bTP/vqszNIN/pUKCk/BTHsKA=="],
|
||||
|
||||
"@rollup/rollup-linux-riscv64-gnu": ["@rollup/[email protected]", "", { "os": "linux", "cpu": "none" }, "sha512-NDYMpsXYJJaj+I7UdwIuHHNxXZ/b/N2hR15NyH3m2qAtb/hHPA4g4SuuvrdxetTdndfj9b1WOmy73kcPRoERUg=="],
|
||||
|
||||
"@rollup/rollup-linux-riscv64-musl": ["@rollup/[email protected]", "", { "os": "linux", "cpu": "none" }, "sha512-nLckB8WOqHIf1bhymk+oHxvM9D3tyPndZH8i8+35p/1YiVoVswPid2yLzgX7ZJP0KQvnkhM4H6QZ5m0LzbyIAg=="],
|
||||
|
||||
"@rollup/rollup-linux-s390x-gnu": ["@rollup/[email protected]", "", { "os": "linux", "cpu": "s390x" }, "sha512-oF87Ie3uAIvORFBpwnCvUzdeYUqi2wY6jRFWJAy1qus/udHFYIkplYRW+wo+GRUP4sKzYdmE1Y3+rY5Gc4ZO+w=="],
|
||||
|
||||
"@rollup/rollup-linux-x64-gnu": ["@rollup/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-3AHmtQq/ppNuUspKAlvA8HtLybkDflkMuLK4DPo77DfthRb71V84/c4MlWJXixZz4uruIH4uaa07IqoAkG64fg=="],
|
||||
|
||||
"@rollup/rollup-linux-x64-musl": ["@rollup/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-2UdiwS/9cTAx7qIUZB/fWtToJwvt0Vbo0zmnYt7ED35KPg13Q0ym1g442THLC7VyI6JfYTP4PiSOWyoMdV2/xg=="],
|
||||
|
||||
"@rollup/rollup-openbsd-x64": ["@rollup/[email protected]", "", { "os": "openbsd", "cpu": "x64" }, "sha512-M3bLRAVk6GOwFlPTIxVBSYKUaqfLrn8l0psKinkCFxl4lQvOSz8ZrKDz2gxcBwHFpci0B6rttydI4IpS4IS/jQ=="],
|
||||
|
||||
"@rollup/rollup-openharmony-arm64": ["@rollup/[email protected]", "", { "os": "none", "cpu": "arm64" }, "sha512-tt9KBJqaqp5i5HUZzoafHZX8b5Q2Fe7UjYERADll83O4fGqJ49O1FsL6LpdzVFQcpwvnyd0i+K/VSwu/o/nWlA=="],
|
||||
|
||||
"@rollup/rollup-win32-arm64-msvc": ["@rollup/[email protected]", "", { "os": "win32", "cpu": "arm64" }, "sha512-V5B6mG7OrGTwnxaNUzZTDTjDS7F75PO1ae6MJYdiMu60sq0CqN5CVeVsbhPxalupvTX8gXVSU9gq+Rx1/hvu6A=="],
|
||||
|
||||
"@rollup/rollup-win32-ia32-msvc": ["@rollup/[email protected]", "", { "os": "win32", "cpu": "ia32" }, "sha512-UKFMHPuM9R0iBegwzKF4y0C4J9u8C6MEJgFuXTBerMk7EJ92GFVFYBfOZaSGLu6COf7FxpQNqhNS4c4icUPqxA=="],
|
||||
|
||||
"@rollup/rollup-win32-x64-gnu": ["@rollup/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-laBkYlSS1n2L8fSo1thDNGrCTQMmxjYY5G0WFWjFFYZkKPjsMBsgJfGf4TLxXrF6RyhI60L8TMOjBMvXiTcxeA=="],
|
||||
|
||||
"@rollup/rollup-win32-x64-msvc": ["@rollup/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-2HRCml6OztYXyJXAvdDXPKcawukWY2GpR5/nxKp4iBgiO3wcoEGkAaqctIbZcNB6KlUQBIqt8VYkNSj2397EfA=="],
|
||||
|
||||
"@standard-schema/spec": ["@standard-schema/[email protected]", "", {}, "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w=="],
|
||||
|
||||
"@tanstack/history": ["@tanstack/[email protected]", "", {}, "sha512-Kp/WSt411ZWYvgXy6uiv5RmhHrz9cAml05AQPrtdAp7eUqvIDbMGPnML25OKbzR3RJ1q4wgENxDTvlGPa9+Mww=="],
|
||||
|
||||
"@tanstack/react-router": ["@tanstack/[email protected]", "", { "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.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/router-core": ["@tanstack/[email protected]", "", { "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]", "", { "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]", "", { "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]", "", { "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/[email protected]", "", {}, "sha512-+qcNkOy0N1qSGsP7omVCW0SDrXtaDcycPqBDE726yryiA5eTDFpjBReaYjghVJwNf1pcPMyzIwTGlYjCSQR0Fg=="],
|
||||
|
||||
"@tanstack/virtual-file-routes": ["@tanstack/[email protected]", "", {}, "sha512-42WoRePf8v690qG8yGRe/YOh+oHni9vUaUUfoqlS91U2scd3a5rkLtVsc6b7z60w3RogH0I00vdrC5AaeiZ18w=="],
|
||||
|
||||
"@types/babel__core": ["@types/[email protected]", "", { "dependencies": { "@babel/parser": "^7.20.7", "@babel/types": "^7.20.7", "@types/babel__generator": "*", "@types/babel__template": "*", "@types/babel__traverse": "*" } }, "sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA=="],
|
||||
|
||||
"@types/babel__generator": ["@types/[email protected]", "", { "dependencies": { "@babel/types": "^7.0.0" } }, "sha512-ufFd2Xi92OAVPYsy+P4n7/U7e68fex0+Ee8gSG9KX7eo084CWiQ4sdxktvdl0bOPupXtVJPY19zk6EwWqUQ8lg=="],
|
||||
|
||||
"@types/babel__template": ["@types/[email protected]", "", { "dependencies": { "@babel/parser": "^7.1.0", "@babel/types": "^7.0.0" } }, "sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A=="],
|
||||
|
||||
"@types/babel__traverse": ["@types/[email protected]", "", { "dependencies": { "@babel/types": "^7.28.2" } }, "sha512-8PvcXf70gTDZBgt9ptxJ8elBeBjcLOAcOtoO/mPJjtji1+CdGbHgm77om1GrsPxsiE+uXIpNSK64UYaIwQXd4Q=="],
|
||||
|
||||
"@types/chai": ["@types/[email protected]", "", { "dependencies": { "@types/deep-eql": "*", "assertion-error": "^2.0.1" } }, "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA=="],
|
||||
|
||||
"@types/deep-eql": ["@types/[email protected]", "", {}, "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw=="],
|
||||
|
||||
"@types/estree": ["@types/[email protected]", "", {}, "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w=="],
|
||||
|
||||
"@types/node": ["@types/[email protected]", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-fPxQqz4VTgPI/IQ+lj9r0h+fDR66bzoeMGHp8ASee+32OSGIkeASsoZuJixsQoVef1QJbeubcPBxKk22QVoWdw=="],
|
||||
|
||||
"@types/react": ["@types/[email protected]", "", { "dependencies": { "csstype": "^3.2.2" } }, "sha512-ilcTH/UniCkMdtexkoCN0bI7pMcJDvmQFPvuPvmEaYA/NSfFTAgdUSLAoVjaRJm7+6PvcM+q1zYOwS4wTYMF9w=="],
|
||||
|
||||
"@types/react-dom": ["@types/[email protected]", "", { "peerDependencies": { "@types/react": "^19.2.0" } }, "sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ=="],
|
||||
|
||||
"@types/ws": ["@types/[email protected]", "", { "dependencies": { "@types/node": "*" } }, "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg=="],
|
||||
|
||||
"@vitejs/plugin-react": ["@vitejs/[email protected]", "", { "dependencies": { "@babel/core": "^7.29.0", "@babel/plugin-transform-react-jsx-self": "^7.27.1", "@babel/plugin-transform-react-jsx-source": "^7.27.1", "@rolldown/pluginutils": "1.0.0-rc.3", "@types/babel__core": "^7.20.5", "react-refresh": "^0.18.0" }, "peerDependencies": { "vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0" } }, "sha512-VIcFLdRi/VYRU8OL/puL7QXMYafHmqOnwTZY50U1JPlCNj30PxCMx65c494b1K9be9hX83KVt0+gTEwTWLqToA=="],
|
||||
|
||||
"@vitest/browser": ["@vitest/[email protected]", "", { "dependencies": { "@vitest/mocker": "4.0.18", "@vitest/utils": "4.0.18", "magic-string": "^0.30.21", "pixelmatch": "7.1.0", "pngjs": "^7.0.0", "sirv": "^3.0.2", "tinyrainbow": "^3.0.3", "ws": "^8.18.3" }, "peerDependencies": { "vitest": "4.0.18" } }, "sha512-gVQqh7paBz3gC+ZdcCmNSWJMk70IUjDeVqi+5m5vYpEHsIwRgw3Y545jljtajhkekIpIp5Gg8oK7bctgY0E2Ng=="],
|
||||
|
||||
"@vitest/browser-playwright": ["@vitest/[email protected]", "", { "dependencies": { "@vitest/browser": "4.0.18", "@vitest/mocker": "4.0.18", "tinyrainbow": "^3.0.3" }, "peerDependencies": { "playwright": "*", "vitest": "4.0.18" } }, "sha512-gfajTHVCiwpxRj1qh0Sh/5bbGLG4F/ZH/V9xvFVoFddpITfMta9YGow0W6ZpTTORv2vdJuz9TnrNSmjKvpOf4g=="],
|
||||
|
||||
"@vitest/expect": ["@vitest/[email protected]", "", { "dependencies": { "@standard-schema/spec": "^1.0.0", "@types/chai": "^5.2.2", "@vitest/spy": "4.0.18", "@vitest/utils": "4.0.18", "chai": "^6.2.1", "tinyrainbow": "^3.0.3" } }, "sha512-8sCWUyckXXYvx4opfzVY03EOiYVxyNrHS5QxX3DAIi5dpJAAkyJezHCP77VMX4HKA2LDT/Jpfo8i2r5BE3GnQQ=="],
|
||||
|
||||
"@vitest/mocker": ["@vitest/[email protected]", "", { "dependencies": { "@vitest/spy": "4.0.18", "estree-walker": "^3.0.3", "magic-string": "^0.30.21" }, "peerDependencies": { "msw": "^2.4.9", "vite": "^6.0.0 || ^7.0.0-0" }, "optionalPeers": ["msw"] }, "sha512-HhVd0MDnzzsgevnOWCBj5Otnzobjy5wLBe4EdeeFGv8luMsGcYqDuFRMcttKWZA5vVO8RFjexVovXvAM4JoJDQ=="],
|
||||
|
||||
"@vitest/pretty-format": ["@vitest/[email protected]", "", { "dependencies": { "tinyrainbow": "^3.0.3" } }, "sha512-P24GK3GulZWC5tz87ux0m8OADrQIUVDPIjjj65vBXYG17ZeU3qD7r+MNZ1RNv4l8CGU2vtTRqixrOi9fYk/yKw=="],
|
||||
|
||||
"@vitest/runner": ["@vitest/[email protected]", "", { "dependencies": { "@vitest/utils": "4.0.18", "pathe": "^2.0.3" } }, "sha512-rpk9y12PGa22Jg6g5M3UVVnTS7+zycIGk9ZNGN+m6tZHKQb7jrP7/77WfZy13Y/EUDd52NDsLRQhYKtv7XfPQw=="],
|
||||
|
||||
"@vitest/snapshot": ["@vitest/[email protected]", "", { "dependencies": { "@vitest/pretty-format": "4.0.18", "magic-string": "^0.30.21", "pathe": "^2.0.3" } }, "sha512-PCiV0rcl7jKQjbgYqjtakly6T1uwv/5BQ9SwBLekVg/EaYeQFPiXcgrC2Y7vDMA8dM1SUEAEV82kgSQIlXNMvA=="],
|
||||
|
||||
"@vitest/spy": ["@vitest/[email protected]", "", {}, "sha512-cbQt3PTSD7P2OARdVW3qWER5EGq7PHlvE+QfzSC0lbwO+xnt7+XH06ZzFjFRgzUX//JmpxrCu92VdwvEPlWSNw=="],
|
||||
|
||||
"@vitest/utils": ["@vitest/[email protected]", "", { "dependencies": { "@vitest/pretty-format": "4.0.18", "tinyrainbow": "^3.0.3" } }, "sha512-msMRKLMVLWygpK3u2Hybgi4MNjcYJvwTb0Ru09+fOyCXIgT5raYP041DRRdiJiI3k/2U6SEbAETB3YtBrUkCFA=="],
|
||||
|
||||
"acorn": ["[email protected]", "", { "bin": { "acorn": "bin/acorn" } }, "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw=="],
|
||||
|
||||
"ansis": ["[email protected]", "", {}, "sha512-HqZ5rWlFjGiV0tDm3UxxgNRqsOTniqoKZu0pIAfh7TZQMGuZK+hH0drySty0si0QXj1ieop4+SkSfPZBPPkHig=="],
|
||||
|
||||
"anymatch": ["[email protected]", "", { "dependencies": { "normalize-path": "^3.0.0", "picomatch": "^2.0.4" } }, "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw=="],
|
||||
|
||||
"assertion-error": ["[email protected]", "", {}, "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA=="],
|
||||
|
||||
"ast-types": ["[email protected]", "", { "dependencies": { "tslib": "^2.0.1" } }, "sha512-6t10qk83GOG8p0vKmaCr8eiilZwO171AvbROMtvvNiwrTly62t+7XkA8RdIIVbpMhCASAsxgAzdRSwh6nw/5Dg=="],
|
||||
|
||||
"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=="],
|
||||
|
||||
"base64-js": ["[email protected]", "", {}, "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA=="],
|
||||
|
||||
"baseline-browser-mapping": ["[email protected]", "", { "bin": { "baseline-browser-mapping": "dist/cli.cjs" } }, "sha512-lIyg0szRfYbiy67j9KN8IyeD7q7hcmqnJ1ddWmNt19ItGpNN64mnllmxUNFIOdOm6by97jlL6wfpTTJrmnjWAA=="],
|
||||
|
||||
"better-sqlite3": ["[email protected]", "", { "dependencies": { "bindings": "^1.5.0", "prebuild-install": "^7.1.1" } }, "sha512-8VYKM3MjCa9WcaSAI3hzwhmyHVlH8tiGFwf0RlTsZPWJ1I5MkzjiudCo4KC4DxOaL/53A5B1sI/IbldNFDbsKA=="],
|
||||
|
||||
"binary-extensions": ["[email protected]", "", {}, "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw=="],
|
||||
|
||||
"bindings": ["[email protected]", "", { "dependencies": { "file-uri-to-path": "1.0.0" } }, "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ=="],
|
||||
|
||||
"bl": ["[email protected]", "", { "dependencies": { "buffer": "^5.5.0", "inherits": "^2.0.4", "readable-stream": "^3.4.0" } }, "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w=="],
|
||||
|
||||
"braces": ["[email protected]", "", { "dependencies": { "fill-range": "^7.1.1" } }, "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA=="],
|
||||
|
||||
"browserslist": ["[email protected]", "", { "dependencies": { "baseline-browser-mapping": "^2.9.0", "caniuse-lite": "^1.0.30001759", "electron-to-chromium": "^1.5.263", "node-releases": "^2.0.27", "update-browserslist-db": "^1.2.0" }, "bin": { "browserslist": "cli.js" } }, "sha512-ZC5Bd0LgJXgwGqUknZY/vkUQ04r8NXnJZ3yYi4vDmSiZmC/pdSN0NbNRPxZpbtO4uAfDUAFffO8IZoM3Gj8IkA=="],
|
||||
|
||||
"buffer": ["[email protected]", "", { "dependencies": { "base64-js": "^1.3.1", "ieee754": "^1.1.13" } }, "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ=="],
|
||||
|
||||
"caniuse-lite": ["[email protected]", "", {}, "sha512-sg01JDPzZ9jGshqKSckOQthXnYwOEP50jeVFhaSFbZcOy05TiuuaffDOfcwtCisJ9kNQuLBFibYywv2Bgm9osw=="],
|
||||
|
||||
"chai": ["[email protected]", "", {}, "sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg=="],
|
||||
|
||||
"chokidar": ["[email protected]", "", { "dependencies": { "anymatch": "~3.1.2", "braces": "~3.0.2", "glob-parent": "~5.1.2", "is-binary-path": "~2.1.0", "is-glob": "~4.0.1", "normalize-path": "~3.0.0", "readdirp": "~3.6.0" }, "optionalDependencies": { "fsevents": "~2.3.2" } }, "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw=="],
|
||||
|
||||
"chownr": ["[email protected]", "", {}, "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg=="],
|
||||
|
||||
"cluster-key-slot": ["[email protected]", "", {}, "sha512-RMr0FhtfXemyinomL4hrWcYJxmX6deFdCxpJzhDttxgO1+bcCnkk+9drydLVDmAMG7NE6aN/fl4F7ucU/90gAA=="],
|
||||
|
||||
"convert-source-map": ["[email protected]", "", {}, "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg=="],
|
||||
|
||||
"cookie-es": ["[email protected]", "", {}, "sha512-RAj4E421UYRgqokKUmotqAwuplYw15qtdXfY+hGzgCJ/MBjCVZcSoHK/kH9kocfjRjcDME7IiDWR/1WX1TM2Pg=="],
|
||||
|
||||
"csstype": ["[email protected]", "", {}, "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ=="],
|
||||
|
||||
"debug": ["[email protected]", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA=="],
|
||||
|
||||
"decompress-response": ["[email protected]", "", { "dependencies": { "mimic-response": "^3.1.0" } }, "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ=="],
|
||||
|
||||
"deep-extend": ["[email protected]", "", {}, "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA=="],
|
||||
|
||||
"denque": ["[email protected]", "", {}, "sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw=="],
|
||||
|
||||
"detect-libc": ["[email protected]", "", {}, "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ=="],
|
||||
|
||||
"diff": ["[email protected]", "", {}, "sha512-qejHi7bcSD4hQAZE0tNAawRK1ZtafHDmMTMkrrIGgSLl7hTnQHmKCeB45xAcbfTqK2zowkM3j3bHt/4b/ARbYQ=="],
|
||||
|
||||
"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-to-chromium": ["[email protected]", "", {}, "sha512-5z3uFKBWjiNR44nFcYdkcXjKMbg5KXNdciu7mhTPo9tB7NbqSNP2sSnGR+fqknZSCwKkBN+oxiiajWs4dT6ORg=="],
|
||||
|
||||
"end-of-stream": ["[email protected]", "", { "dependencies": { "once": "^1.4.0" } }, "sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg=="],
|
||||
|
||||
"es-module-lexer": ["[email protected]", "", {}, "sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA=="],
|
||||
|
||||
"esbuild": ["[email protected]", "", { "optionalDependencies": { "@esbuild/aix-ppc64": "0.27.3", "@esbuild/android-arm": "0.27.3", "@esbuild/android-arm64": "0.27.3", "@esbuild/android-x64": "0.27.3", "@esbuild/darwin-arm64": "0.27.3", "@esbuild/darwin-x64": "0.27.3", "@esbuild/freebsd-arm64": "0.27.3", "@esbuild/freebsd-x64": "0.27.3", "@esbuild/linux-arm": "0.27.3", "@esbuild/linux-arm64": "0.27.3", "@esbuild/linux-ia32": "0.27.3", "@esbuild/linux-loong64": "0.27.3", "@esbuild/linux-mips64el": "0.27.3", "@esbuild/linux-ppc64": "0.27.3", "@esbuild/linux-riscv64": "0.27.3", "@esbuild/linux-s390x": "0.27.3", "@esbuild/linux-x64": "0.27.3", "@esbuild/netbsd-arm64": "0.27.3", "@esbuild/netbsd-x64": "0.27.3", "@esbuild/openbsd-arm64": "0.27.3", "@esbuild/openbsd-x64": "0.27.3", "@esbuild/openharmony-arm64": "0.27.3", "@esbuild/sunos-x64": "0.27.3", "@esbuild/win32-arm64": "0.27.3", "@esbuild/win32-ia32": "0.27.3", "@esbuild/win32-x64": "0.27.3" }, "bin": "bin/esbuild" }, "sha512-8VwMnyGCONIs6cWue2IdpHxHnAjzxnw2Zr7MkVxB2vjmQ2ivqGFb4LEG3SMnv0Gb2F/G/2yA8zUaiL1gywDCCg=="],
|
||||
|
||||
"escalade": ["[email protected]", "", {}, "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA=="],
|
||||
|
||||
"esprima": ["[email protected]", "", { "bin": { "esparse": "./bin/esparse.js", "esvalidate": "./bin/esvalidate.js" } }, "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A=="],
|
||||
|
||||
"estree-walker": ["[email protected]", "", { "dependencies": { "@types/estree": "^1.0.0" } }, "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g=="],
|
||||
|
||||
"expand-template": ["[email protected]", "", {}, "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg=="],
|
||||
|
||||
"expect-type": ["[email protected]", "", {}, "sha512-knvyeauYhqjOYvQ66MznSMs83wmHrCycNEN6Ao+2AeYEfxUIkuiVxdEa1qlGEPK+We3n0THiDciYSsCcgW/DoA=="],
|
||||
|
||||
"fast-check": ["[email protected]", "", { "dependencies": { "pure-rand": "^7.0.0" } }, "sha512-IE9csY7lnhxBnA8g/WI5eg/hygA6MGWJMSNfFRrBlXUciADEhS1EDB0SIsMSvzubzIlOBbVITSsypCsW717poA=="],
|
||||
|
||||
"fdir": ["[email protected]", "", { "peerDependencies": { "picomatch": "^3 || ^4" } }, "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg=="],
|
||||
|
||||
"file-uri-to-path": ["[email protected]", "", {}, "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw=="],
|
||||
|
||||
"fill-range": ["[email protected]", "", { "dependencies": { "to-regex-range": "^5.0.1" } }, "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg=="],
|
||||
|
||||
"find-my-way-ts": ["[email protected]", "", {}, "sha512-a85L9ZoXtNAey3Y6Z+eBWW658kO/MwR7zIafkIUPUMf3isZG0NCs2pjW2wtjxAKuJPxMAsHUIP4ZPGv0o5gyTA=="],
|
||||
|
||||
"fs-constants": ["[email protected]", "", {}, "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow=="],
|
||||
|
||||
"fsevents": ["[email protected]", "", { "os": "darwin" }, "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA=="],
|
||||
|
||||
"gensync": ["[email protected]", "", {}, "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg=="],
|
||||
|
||||
"get-tsconfig": ["[email protected]", "", { "dependencies": { "resolve-pkg-maps": "^1.0.0" } }, "sha512-shZT/QMiSHc/YBLxxOkMtgSid5HFoauqCE3/exfsEcwg1WkeqjG+V40yBbBrsD+jW2HDXcs28xOfcbm2jI8Ddw=="],
|
||||
|
||||
"github-from-package": ["[email protected]", "", {}, "sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw=="],
|
||||
|
||||
"glob-parent": ["[email protected]", "", { "dependencies": { "is-glob": "^4.0.1" } }, "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow=="],
|
||||
|
||||
"ieee754": ["[email protected]", "", {}, "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA=="],
|
||||
|
||||
"inherits": ["[email protected]", "", {}, "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="],
|
||||
|
||||
"ini": ["[email protected]", "", {}, "sha512-IBTdIkzZNOpqm7q3dRqJvMaldXjDHWkEDfrwGEQTs5eaQMWV+djAhR+wahyNNMAa+qpbDUhBMVt4ZKNwpPm7xQ=="],
|
||||
|
||||
"ioredis": ["[email protected]", "", { "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-binary-path": ["[email protected]", "", { "dependencies": { "binary-extensions": "^2.0.0" } }, "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw=="],
|
||||
|
||||
"is-extglob": ["[email protected]", "", {}, "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ=="],
|
||||
|
||||
"is-glob": ["[email protected]", "", { "dependencies": { "is-extglob": "^2.1.1" } }, "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg=="],
|
||||
|
||||
"is-number": ["[email protected]", "", {}, "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng=="],
|
||||
|
||||
"isbot": ["[email protected]", "", {}, "sha512-waFfC72ZNfwLLuJ2iLaoVaqcNo+CAaLR7xCpAn0Y5WfGzkNHv7ZN39Vbi1y+kb+Zs46XHOX3tZNExroFUPX+Kg=="],
|
||||
|
||||
"js-tokens": ["[email protected]", "", {}, "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="],
|
||||
|
||||
"jsesc": ["[email protected]", "", { "bin": { "jsesc": "bin/jsesc" } }, "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA=="],
|
||||
|
||||
"json5": ["[email protected]", "", { "bin": { "json5": "lib/cli.js" } }, "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg=="],
|
||||
|
||||
"kubernetes-types": ["[email protected]", "", {}, "sha512-Dew1okvhM/SQcIa2rcgujNndZwU8VnSapDgdxlYoB84ZlpAD43U6KLAFqYo17ykSFGHNPrg0qry0bP+GJd9v7Q=="],
|
||||
|
||||
"lodash.defaults": ["[email protected]", "", {}, "sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ=="],
|
||||
|
||||
"lodash.isarguments": ["[email protected]", "", {}, "sha512-chi4NHZlZqZD18a0imDHnZPrDeBbTtVN7GXMwuGdRH9qotxAjYs3aVLKc7zNOG9eddR5Ksd8rvFEBc9SsggPpg=="],
|
||||
|
||||
"lru-cache": ["[email protected]", "", { "dependencies": { "yallist": "^3.0.2" } }, "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w=="],
|
||||
|
||||
"magic-string": ["[email protected]", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.5" } }, "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ=="],
|
||||
|
||||
"mime": ["[email protected]", "", { "bin": "bin/cli.js" }, "sha512-X5ju04+cAzsojXKes0B/S4tcYtFAJ6tTMuSPBEn9CPGlrWr8Fiw7qYeLT0XyH80HSoAoqWCaz+MWKh22P7G1cw=="],
|
||||
|
||||
"mimic-response": ["[email protected]", "", {}, "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ=="],
|
||||
|
||||
"minimist": ["[email protected]", "", {}, "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA=="],
|
||||
|
||||
"mkdirp-classic": ["[email protected]", "", {}, "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A=="],
|
||||
|
||||
"mrmime": ["[email protected]", "", {}, "sha512-Y3wQdFg2Va6etvQ5I82yUhGdsKrcYox6p7FfL1LbK2J4V01F9TGlepTIhnK24t7koZibmg82KGglhA1XK5IsLQ=="],
|
||||
|
||||
"ms": ["[email protected]", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="],
|
||||
|
||||
"msgpackr": ["[email protected]", "", { "optionalDependencies": { "msgpackr-extract": "^3.0.2" } }, "sha512-bC4UGzHhVvgDNS7kn9tV8fAucIYUBuGojcaLiz7v+P63Lmtm0Xeji8B/8tYKddALXxJLpwIeBmUN3u64C4YkRA=="],
|
||||
|
||||
"msgpackr-extract": ["[email protected]", "", { "dependencies": { "node-gyp-build-optional-packages": "5.2.2" }, "optionalDependencies": { "@msgpackr-extract/msgpackr-extract-darwin-arm64": "3.0.3", "@msgpackr-extract/msgpackr-extract-darwin-x64": "3.0.3", "@msgpackr-extract/msgpackr-extract-linux-arm": "3.0.3", "@msgpackr-extract/msgpackr-extract-linux-arm64": "3.0.3", "@msgpackr-extract/msgpackr-extract-linux-x64": "3.0.3", "@msgpackr-extract/msgpackr-extract-win32-x64": "3.0.3" }, "bin": { "download-msgpackr-prebuilds": "bin/download-prebuilds.js" } }, "sha512-P0efT1C9jIdVRefqjzOQ9Xml57zpOXnIuS+csaB4MdZbTdmGDLo8XhzBG1N7aO11gKDDkJvBLULeFTo46wwreA=="],
|
||||
|
||||
"multipasta": ["[email protected]", "", {}, "sha512-KPA58d68KgGil15oDqXjkUBEBYc00XvbPj5/X+dyzeo/lWm9Nc25pQRlf1D+gv4OpK7NM0J1odrbu9JNNGvynA=="],
|
||||
|
||||
"nanoid": ["[email protected]", "", { "bin": "bin/nanoid.cjs" }, "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w=="],
|
||||
|
||||
"napi-build-utils": ["[email protected]", "", {}, "sha512-GEbrYkbfF7MoNaoh2iGG84Mnf/WZfB0GdGEsM8wz7Expx/LlWf5U8t9nvJKXSp3qr5IsEbK04cBGhol/KwOsWA=="],
|
||||
|
||||
"node-abi": ["[email protected]", "", { "dependencies": { "semver": "^7.3.5" } }, "sha512-+CGM1L1CgmtheLcBuleyYOn7NWPVu0s0EJH2C4puxgEZb9h8QpR9G2dBfZJOAUhi7VQxuBPMd0hiISWcTyiYyQ=="],
|
||||
|
||||
"node-gyp-build-optional-packages": ["[email protected]", "", { "dependencies": { "detect-libc": "^2.0.1" }, "bin": { "node-gyp-build-optional-packages": "bin.js", "node-gyp-build-optional-packages-optional": "optional.js", "node-gyp-build-optional-packages-test": "build-test.js" } }, "sha512-s+w+rBWnpTMwSFbaE0UXsRlg7hU4FjekKU4eyAih5T8nJuNZT1nNsskXpxmeqSK9UzkBl6UgRlnKc8hz8IEqOw=="],
|
||||
|
||||
"node-releases": ["[email protected]", "", {}, "sha512-TdC8FSgHz8Mwtw9g5L4gR/Sh9XhSP/0DEkQxfEFXOpiul5IiHgHan2VhYYb6agDSfp4KuvltmGApc8HMgUrIkA=="],
|
||||
|
||||
"normalize-path": ["[email protected]", "", {}, "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA=="],
|
||||
|
||||
"obug": ["[email protected]", "", {}, "sha512-uTqF9MuPraAQ+IsnPf366RG4cP9RtUi7MLO1N3KEc+wb0a6yKpeL0lmk2IB1jY5KHPAlTc6T/JRdC/YqxHNwkQ=="],
|
||||
|
||||
"once": ["[email protected]", "", { "dependencies": { "wrappy": "1" } }, "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w=="],
|
||||
|
||||
"pathe": ["[email protected]", "", {}, "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w=="],
|
||||
|
||||
"picocolors": ["[email protected]", "", {}, "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="],
|
||||
|
||||
"picomatch": ["[email protected]", "", {}, "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q=="],
|
||||
|
||||
"pixelmatch": ["[email protected]", "", { "dependencies": { "pngjs": "^7.0.0" }, "bin": { "pixelmatch": "bin/pixelmatch" } }, "sha512-1wrVzJ2STrpmONHKBy228LM1b84msXDUoAzVEl0R8Mz4Ce6EPr+IVtxm8+yvrqLYMHswREkjYFaMxnyGnaY3Ng=="],
|
||||
|
||||
"playwright": ["[email protected]", "", { "dependencies": { "playwright-core": "1.58.2" }, "optionalDependencies": { "fsevents": "2.3.2" }, "bin": { "playwright": "cli.js" } }, "sha512-vA30H8Nvkq/cPBnNw4Q8TWz1EJyqgpuinBcHET0YVJVFldr8JDNiU9LaWAE1KqSkRYazuaBhTpB5ZzShOezQ6A=="],
|
||||
|
||||
"playwright-core": ["[email protected]", "", { "bin": { "playwright-core": "cli.js" } }, "sha512-yZkEtftgwS8CsfYo7nm0KE8jsvm6i/PTgVtB8DL726wNf6H2IMsDuxCpJj59KDaxCtSnrWan2AeDqM7JBaultg=="],
|
||||
|
||||
"pngjs": ["[email protected]", "", {}, "sha512-LKWqWJRhstyYo9pGvgor/ivk2w94eSjE3RGVuzLGlr3NmD8bf7RcYGze1mNdEHRP6TRP6rMuDHk5t44hnTRyow=="],
|
||||
|
||||
"postcss": ["[email protected]", "", { "dependencies": { "nanoid": "^3.3.11", "picocolors": "^1.1.1", "source-map-js": "^1.2.1" } }, "sha512-OW/rX8O/jXnm82Ey1k44pObPtdblfiuWnrd8X7GJ7emImCOstunGbXUpp7HdBrFQX6rJzn3sPT397Wp5aCwCHg=="],
|
||||
|
||||
"prebuild-install": ["[email protected]", "", { "dependencies": { "detect-libc": "^2.0.0", "expand-template": "^2.0.3", "github-from-package": "0.0.0", "minimist": "^1.2.3", "mkdirp-classic": "^0.5.3", "napi-build-utils": "^2.0.0", "node-abi": "^3.3.0", "pump": "^3.0.0", "rc": "^1.2.7", "simple-get": "^4.0.0", "tar-fs": "^2.0.0", "tunnel-agent": "^0.6.0" }, "bin": { "prebuild-install": "bin.js" } }, "sha512-8Mf2cbV7x1cXPUILADGI3wuhfqWvtiLA1iclTDbFRZkgRQS0NqsPZphna9V+HyTEadheuPmjaJMsbzKQFOzLug=="],
|
||||
|
||||
"prettier": ["[email protected]", "", { "bin": { "prettier": "bin/prettier.cjs" } }, "sha512-UOnG6LftzbdaHZcKoPFtOcCKztrQ57WkHDeRD9t/PTQtmT0NHSeWWepj6pS0z/N7+08BHFDQVUrfmfMRcZwbMg=="],
|
||||
|
||||
"pump": ["[email protected]", "", { "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=="],
|
||||
|
||||
"rc": ["[email protected]", "", { "dependencies": { "deep-extend": "^0.6.0", "ini": "~1.3.0", "minimist": "^1.2.0", "strip-json-comments": "~2.0.1" }, "bin": { "rc": "./cli.js" } }, "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw=="],
|
||||
|
||||
"react": ["[email protected]", "", {}, "sha512-9nfp2hYpCwOjAN+8TZFGhtWEwgvWHXqESH8qT89AT/lWklpLON22Lc8pEtnpsZz7VmawabSU0gCjnj8aC0euHQ=="],
|
||||
|
||||
"react-dom": ["[email protected]", "", { "dependencies": { "scheduler": "^0.27.0" }, "peerDependencies": { "react": "^19.2.4" } }, "sha512-AXJdLo8kgMbimY95O2aKQqsz2iWi9jMgKJhRBAxECE4IFxfcazB2LmzloIoibJI3C12IlY20+KFaLv+71bUJeQ=="],
|
||||
|
||||
"react-refresh": ["[email protected]", "", {}, "sha512-QgT5//D3jfjJb6Gsjxv0Slpj23ip+HtOpnNgnb2S5zU3CB26G/IDPGoy4RJB42wzFE46DRsstbW6tKHoKbhAxw=="],
|
||||
|
||||
"readable-stream": ["[email protected]", "", { "dependencies": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", "util-deprecate": "^1.0.1" } }, "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA=="],
|
||||
|
||||
"readdirp": ["[email protected]", "", { "dependencies": { "picomatch": "^2.2.1" } }, "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA=="],
|
||||
|
||||
"recast": ["[email protected]", "", { "dependencies": { "ast-types": "^0.16.1", "esprima": "~4.0.0", "source-map": "~0.6.1", "tiny-invariant": "^1.3.3", "tslib": "^2.0.1" } }, "sha512-YTUo+Flmw4ZXiWfQKGcwwc11KnoRAYgzAE2E7mXKCjSviTKShtxBsN6YUUBB2gtaBzKzeKunxhUwNHQuRryhWA=="],
|
||||
|
||||
"redis-errors": ["[email protected]", "", {}, "sha512-1qny3OExCf0UvUV/5wpYKf2YwPcOqXzkwKKSmKHiE6ZMQs5heeE/c8eXK+PNllPvmjgAbfnsbpkGZWy8cBpn9w=="],
|
||||
|
||||
"redis-parser": ["[email protected]", "", { "dependencies": { "redis-errors": "^1.0.0" } }, "sha512-DJnGAeenTdpMEH6uAJRK/uiyEIH9WVsUmoLwzudwGJUwZPp80PDBWPHXSAGNPwNvIXAbe7MSUB1zQFugFml66A=="],
|
||||
|
||||
"resolve-pkg-maps": ["[email protected]", "", {}, "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw=="],
|
||||
|
||||
"rollup": ["[email protected]", "", { "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": "dist/bin/rollup" }, "sha512-2oMpl67a3zCH9H79LeMcbDhXW/UmWG/y2zuqnF2jQq5uq9TbM9TVyXvA4+t+ne2IIkBdrLpAaRQAvo7YI/Yyeg=="],
|
||||
|
||||
"safe-buffer": ["[email protected]", "", {}, "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="],
|
||||
|
||||
"scheduler": ["[email protected]", "", {}, "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q=="],
|
||||
|
||||
"semver": ["[email protected]", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA=="],
|
||||
|
||||
"seroval": ["[email protected]", "", {}, "sha512-OE4cvmJ1uSPrKorFIH9/w/Qwuvi/IMcGbv5RKgcJ/zjA/IohDLU6SVaxFN9FwajbP7nsX0dQqMDes1whk3y+yw=="],
|
||||
|
||||
"seroval-plugins": ["[email protected]", "", { "peerDependencies": { "seroval": "^1.0" } }, "sha512-EAHqADIQondwRZIdeW2I636zgsODzoBDwb3PT/+7TLDWyw1Dy/Xv7iGUIEXXav7usHDE9HVhOU61irI3EnyyHA=="],
|
||||
|
||||
"siginfo": ["[email protected]", "", {}, "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g=="],
|
||||
|
||||
"simple-concat": ["[email protected]", "", {}, "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q=="],
|
||||
|
||||
"simple-get": ["[email protected]", "", { "dependencies": { "decompress-response": "^6.0.0", "once": "^1.3.1", "simple-concat": "^1.0.0" } }, "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA=="],
|
||||
|
||||
"sirv": ["[email protected]", "", { "dependencies": { "@polka/url": "^1.0.0-next.24", "mrmime": "^2.0.0", "totalist": "^3.0.0" } }, "sha512-2wcC/oGxHis/BoHkkPwldgiPSYcpZK3JU28WoMVv55yHJgcZ8rlXvuG9iZggz+sU1d4bRgIGASwyWqjxu3FM0g=="],
|
||||
|
||||
"source-map": ["[email protected]", "", {}, "sha512-i5uvt8C3ikiWeNZSVZNWcfZPItFQOsYTUAOkcUPGd8DqDy1uOUikjt5dG+uRlwyvR108Fb9DOd4GvXfT0N2/uQ=="],
|
||||
|
||||
"source-map-js": ["[email protected]", "", {}, "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA=="],
|
||||
|
||||
"stackback": ["[email protected]", "", {}, "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw=="],
|
||||
|
||||
"standard-as-callback": ["[email protected]", "", {}, "sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A=="],
|
||||
|
||||
"std-env": ["[email protected]", "", {}, "sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg=="],
|
||||
|
||||
"string_decoder": ["[email protected]", "", { "dependencies": { "safe-buffer": "~5.2.0" } }, "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA=="],
|
||||
|
||||
"strip-json-comments": ["[email protected]", "", {}, "sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ=="],
|
||||
|
||||
"tar-fs": ["[email protected]", "", { "dependencies": { "chownr": "^1.1.1", "mkdirp-classic": "^0.5.2", "pump": "^3.0.0", "tar-stream": "^2.1.4" } }, "sha512-mDAjwmZdh7LTT6pNleZ05Yt65HC3E+NiQzl672vQG38jIrehtJk/J3mNwIg+vShQPcLF/LV7CMnDW6vjj6sfYQ=="],
|
||||
|
||||
"tar-stream": ["[email protected]", "", { "dependencies": { "bl": "^4.0.3", "end-of-stream": "^1.4.1", "fs-constants": "^1.0.0", "inherits": "^2.0.3", "readable-stream": "^3.1.1" } }, "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ=="],
|
||||
|
||||
"tiny-invariant": ["[email protected]", "", {}, "sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg=="],
|
||||
|
||||
"tiny-warning": ["[email protected]", "", {}, "sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA=="],
|
||||
|
||||
"tinybench": ["[email protected]", "", {}, "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg=="],
|
||||
|
||||
"tinyexec": ["[email protected]", "", {}, "sha512-W/KYk+NFhkmsYpuHq5JykngiOCnxeVL8v8dFnqxSD8qEEdRfXk1SDM6JzNqcERbcGYj9tMrDQBYV9cjgnunFIg=="],
|
||||
|
||||
"tinyglobby": ["[email protected]", "", { "dependencies": { "fdir": "^6.5.0", "picomatch": "^4.0.3" } }, "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ=="],
|
||||
|
||||
"tinyrainbow": ["[email protected]", "", {}, "sha512-PSkbLUoxOFRzJYjjxHJt9xro7D+iilgMX/C9lawzVuYiIdcihh9DXmVibBe8lmcFrRi/VzlPjBxbN7rH24q8/Q=="],
|
||||
|
||||
"to-regex-range": ["[email protected]", "", { "dependencies": { "is-number": "^7.0.0" } }, "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ=="],
|
||||
|
||||
"toml": ["[email protected]", "", {}, "sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w=="],
|
||||
|
||||
"totalist": ["[email protected]", "", {}, "sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ=="],
|
||||
|
||||
"tslib": ["[email protected]", "", {}, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
|
||||
|
||||
"tsx": ["[email protected]", "", { "dependencies": { "esbuild": "~0.27.0", "get-tsconfig": "^4.7.5" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "bin": "dist/cli.mjs" }, "sha512-5C1sg4USs1lfG0GFb2RLXsdpXqBSEhAaA/0kPL01wxzpMqLILNxIxIOKiILz+cdg/pLnOUxFYOR5yhHU666wbw=="],
|
||||
|
||||
"tunnel-agent": ["[email protected]", "", { "dependencies": { "safe-buffer": "^5.0.1" } }, "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w=="],
|
||||
|
||||
"typescript": ["[email protected]", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-CldZdztDpQRLM1HC6WDQjQkQN5Ub5zRau737a1diGh3lPmb9oRsaWHk1y5iqK0o7+1bNJ0oXfEGRkAogFZBL+Q=="],
|
||||
|
||||
"undici": ["[email protected]", "", {}, "sha512-RqslV2Us5BrllB+JeiZnK4peryVTndy9Dnqq62S3yYRRTj0tFQCwEniUy2167skdGOy3vqRzEvl1Dm4sV2ReDg=="],
|
||||
|
||||
"undici-types": ["[email protected]", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="],
|
||||
|
||||
"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=="],
|
||||
|
||||
"update-browserslist-db": ["[email protected]", "", { "dependencies": { "escalade": "^3.2.0", "picocolors": "^1.1.1" }, "peerDependencies": { "browserslist": ">= 4.21.0" }, "bin": { "update-browserslist-db": "cli.js" } }, "sha512-Js0m9cx+qOgDxo0eMiFGEueWztz+d4+M3rGlmKPT+T4IS/jP4ylw3Nwpu6cpTTP8R1MAC1kF4VbdLt3ARf209w=="],
|
||||
|
||||
"use-sync-external-store": ["[email protected]", "", { "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-Pp6GSwGP/NrPIrxVFAIkOQeyw8lFenOHijQWkUTrDvrF4ALqylP2C/KCkeS9dpUM3KvYRQhna5vt7IL95+ZQ9w=="],
|
||||
|
||||
"util-deprecate": ["[email protected]", "", {}, "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="],
|
||||
|
||||
"uuid": ["[email protected]", "", { "bin": "dist-node/bin/uuid" }, "sha512-XQegIaBTVUjSHliKqcnFqYypAd4S+WCYt5NIeRs6w/UAry7z8Y9j5ZwRRL4kzq9U3sD6v+85er9FvkEaBpji2w=="],
|
||||
|
||||
"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": ["jiti", "less", "lightningcss", "sass", "sass-embedded", "stylus", "sugarss", "terser"], "bin": "bin/vite.js" }, "sha512-w+N7Hifpc3gRjZ63vYBXA56dvvRlNWRczTdmCBBa+CotUzAPf5b7YMdMR/8CQoeYE5LX3W4wj6RYTgonm1b9DA=="],
|
||||
|
||||
"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", "@vitest/browser-playwright", "@vitest/browser-preview", "@vitest/browser-webdriverio", "@vitest/ui", "happy-dom", "jsdom"], "bin": "vitest.mjs" }, "sha512-hOQuK7h0FGKgBAas7v0mSAsnvrIgAvWmRFjmzpJ7SwFHH3g1k2u37JtYwOwmEKhK6ZO3v9ggDBBm0La1LCK4uQ=="],
|
||||
|
||||
"vitest-browser-react": ["[email protected]", "", { "peerDependencies": { "@types/react": "^18.0.0 || ^19.0.0", "@types/react-dom": "^18.0.0 || ^19.0.0", "react": "^18.0.0 || ^19.0.0", "react-dom": "^18.0.0 || ^19.0.0", "vitest": "^4.0.0" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-YODQX8mHTJCyKNVYTWJrLEYrUtw+QfLl78owgvuE7C5ydgmGBq6v5s4jK2w6wdPhIZsN9PpV1rQbmAevWJjO9g=="],
|
||||
|
||||
"webpack-virtual-modules": ["[email protected]", "", {}, "sha512-66/V2i5hQanC51vBQKPH4aI8NMAcBW59FVBs+rC7eGHupMyfn34q7rZIE+ETlJ+XTevqfUhVVBgSUNSW2flEUQ=="],
|
||||
|
||||
"why-is-node-running": ["[email protected]", "", { "dependencies": { "siginfo": "^2.0.0", "stackback": "0.0.2" }, "bin": "cli.js" }, "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w=="],
|
||||
|
||||
"wrappy": ["[email protected]", "", {}, "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ=="],
|
||||
|
||||
"ws": ["[email protected]", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-blAT2mjOEIi0ZzruJfIhb3nps74PRWTCz1IjglWEEpQl5XS/UNama6u2/rjFkDDouqr4L67ry+1aGIALViWjDg=="],
|
||||
|
||||
"yallist": ["[email protected]", "", {}, "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g=="],
|
||||
|
||||
"yaml": ["[email protected]", "", { "bin": "bin.mjs" }, "sha512-mplynKqc1C2hTVYxd0PU2xQAc22TI1vShAYGksCCfxbn/dFwnHTNi1bvYsBTkhdUNtGIf5xNOg938rrSSYvS9A=="],
|
||||
|
||||
"zod": ["[email protected]", "", {}, "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="],
|
||||
|
||||
"@types/ws/@types/node": ["@types/[email protected]", "", { "dependencies": { "undici-types": "~6.21.0" } }, "sha512-akNQMv0wW5uyRpD2v2IEyRSZiR+BeGuoB6L310EgGObO44HSMNT8z1xzio28V8qOrgYaopIDNA18YgdXd+qTiw=="],
|
||||
|
||||
"anymatch/picomatch": ["[email protected]", "", {}, "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="],
|
||||
|
||||
"chokidar/fsevents": ["[email protected]", "", { "os": "darwin" }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="],
|
||||
|
||||
"node-abi/semver": ["[email protected]", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA=="],
|
||||
|
||||
"rc/ini": ["[email protected]", "", {}, "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew=="],
|
||||
|
||||
"readdirp/picomatch": ["[email protected]", "", {}, "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="],
|
||||
|
||||
"recast/source-map": ["[email protected]", "", {}, "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="],
|
||||
|
||||
"rollup/fsevents": ["[email protected]", "", { "os": "darwin" }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="],
|
||||
|
||||
"tsx/fsevents": ["[email protected]", "", { "os": "darwin" }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="],
|
||||
|
||||
"vite/fsevents": ["[email protected]", "", { "os": "darwin" }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="],
|
||||
|
||||
"@types/ws/@types/node/undici-types": ["[email protected]", "", {}, "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ=="],
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "effect-http-ws-cli",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"packageManager": "[email protected]",
|
||||
"workspaces": {
|
||||
"packages": ["server", "web"],
|
||||
"catalog": {
|
||||
"@effect/platform-node": "4.0.0-beta.27",
|
||||
"@effect/sql-sqlite-node": "4.0.0-beta.27",
|
||||
"@effect/atom-react": "4.0.0-beta.27",
|
||||
"@effect/vitest": "4.0.0-beta.27",
|
||||
"effect": "4.0.0-beta.27",
|
||||
"typescript": "6.0.0-beta",
|
||||
"vitest": "^4.0.18"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "node scripts/dev.mjs",
|
||||
"start": "node server/src/bin.ts",
|
||||
"web:dev": "bun run --filter @effect-http-ws-cli/web dev",
|
||||
"web:build": "bun run --filter @effect-http-ws-cli/web build",
|
||||
"web:preview": "bun run --filter @effect-http-ws-cli/web preview",
|
||||
"test": "bun run --filter @effect-http-ws-cli/server test",
|
||||
"test:web": "bun run --filter @effect-http-ws-cli/web test",
|
||||
"test:all": "bun run --sequential --workspaces test",
|
||||
"lint": "bun run --sequential --workspaces lint"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
:root{--paper: #f3f0e8;--ink: #13222c;--ink-soft: #345264;--accent: #dc4f18;--accent-soft: #f8bb68;--panel: #fffdf6;--line: #162f3f22;--shadow: 0 16px 40px #0f1e291f}*{box-sizing:border-box}body{margin:0;min-height:100vh;font-family:IBM Plex Sans,Segoe UI,sans-serif;color:var(--ink);background:radial-gradient(circle at 10% 10%,#f7cf9a 0%,transparent 36%),radial-gradient(circle at 92% 88%,#95c7d2 0%,transparent 32%),linear-gradient(165deg,#ece8dc 0%,var(--paper) 48%,#e9dfcf 100%)}.shell{width:min(1100px,100% - 2rem);margin:1.5rem auto;padding:1.5rem;border:1px solid var(--line);border-radius:20px;background:color-mix(in oklab,var(--paper),white 35%);box-shadow:var(--shadow)}.hero{position:relative;overflow:hidden;padding:1.5rem;border-radius:16px;border:1px solid var(--line);background:linear-gradient(140deg,#fff9ed,#f7efe0 65%,#f2e7d4)}.hero:after{content:"";position:absolute;width:220px;height:220px;right:-60px;top:-90px;border-radius:999px;background:linear-gradient(180deg,var(--accent-soft),transparent 70%);pointer-events:none}.eyebrow{margin:0;font-size:.72rem;letter-spacing:.22em;text-transform:uppercase;color:var(--ink-soft)}h1,h2{font-family:Archivo Black,Impact,sans-serif;letter-spacing:.02em;margin:0}h1{margin-top:.35rem;font-size:clamp(1.5rem,4vw,2.35rem)}h2{font-size:1.1rem}.lead{margin:.6rem 0 0;color:var(--ink-soft);max-width:68ch}.panel{border:1px solid var(--line);border-radius:14px;padding:1rem;background:var(--panel);margin-top:1rem}.status-panel{margin-top:0;background:linear-gradient(140deg,#fbf7ee,#f1e8d7)}.status-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.7rem}.status-item{border:1px solid var(--line);border-radius:10px;padding:.55rem .7rem;display:flex;justify-content:space-between;align-items:baseline;gap:.75rem;background:#fff}.status-label{color:var(--ink-soft);font-size:.82rem}.status-subscription-connected{border-color:#24704755;background:#f1fbf5}.status-subscription-connecting{border-color:#8d6a1b55;background:#fff8eb}.status-subscription-idle{border-color:var(--line)}.status-mutation-busy{border-color:#6b3b2e55;background:#fff3ef}.todo-header{display:flex;justify-content:space-between;align-items:baseline;gap:1rem}.meta{display:flex;gap:.75rem;color:var(--ink-soft);font-size:.86rem}.todo-list{margin:.8rem 0 0;padding:0;list-style:none;display:grid;gap:.6rem}.event-list{margin:.8rem 0 0;padding:0;list-style:none;display:grid;gap:.5rem;max-height:260px;overflow:auto}.event-item{border:1px solid var(--line);border-radius:10px;background:#fff;padding:.55rem .65rem}.event-top{display:flex;justify-content:space-between;gap:.6rem;color:var(--ink-soft);font-size:.8rem}.event-body{margin-top:.2rem;display:flex;justify-content:space-between;gap:.75rem;font-size:.9rem}.event-body small{color:var(--ink-soft);white-space:nowrap}.todo-item{display:flex;gap:.8rem;align-items:center;border:1px solid var(--line);border-radius:10px;background:#fff;padding:.65rem}.todo-main{flex:1}.todo-main input{width:100%;margin:0;border:1px solid var(--line);background:#fff;border-radius:8px;padding:.42rem .55rem;color:var(--ink);font:inherit;font-weight:600}.todo-main small{display:block;margin-top:.3rem;color:var(--ink-soft)}.todo-actions{display:flex;gap:.45rem}button{border:1px solid #0f243233;border-radius:8px;background:linear-gradient(160deg,#fff,#f4efe3);color:var(--ink);padding:.4rem .6rem;font:inherit;font-size:.85rem;font-weight:700;cursor:pointer;transition:transform .12s ease,box-shadow .12s ease}button:hover{transform:translateY(-1px);box-shadow:0 8px 18px #0f20321a}.todo-item.is-completed .todo-main input{text-decoration:line-through;color:var(--ink-soft)}.todo-item.is-archived{opacity:.64}.footer{margin-top:1rem;display:flex;gap:1rem;align-items:center;font-size:.88rem;color:var(--ink-soft)}.error{color:var(--accent);font-weight:700}@media(max-width:880px){.shell{width:min(1100px,100% - 1rem);padding:1rem}.todo-item{flex-direction:column;align-items:stretch}.todo-actions{justify-content:flex-end}.status-grid{grid-template-columns:1fr}}
|
||||
@@ -0,0 +1,35 @@
|
||||
(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const u of document.querySelectorAll('link[rel="modulepreload"]'))i(u);new MutationObserver(u=>{for(const o of u)if(o.type==="childList")for(const d of o.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&i(d)}).observe(document,{childList:!0,subtree:!0});function s(u){const o={};return u.integrity&&(o.integrity=u.integrity),u.referrerPolicy&&(o.referrerPolicy=u.referrerPolicy),u.crossOrigin==="use-credentials"?o.credentials="include":u.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function i(u){if(u.ep)return;u.ep=!0;const o=s(u);fetch(u.href,o)}})();function KR(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Zm={exports:{}},au={};var O1;function PR(){if(O1)return au;O1=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function s(i,u,o){var d=null;if(o!==void 0&&(d=""+o),u.key!==void 0&&(d=""+u.key),"key"in u){o={};for(var h in u)h!=="key"&&(o[h]=u[h])}else o=u;return u=o.ref,{$$typeof:e,type:i,key:d,ref:u!==void 0?u:null,props:o}}return au.Fragment=n,au.jsx=s,au.jsxs=s,au}var R1;function XR(){return R1||(R1=1,Zm.exports=PR()),Zm.exports}var ee=XR(),Wm={exports:{}},ye={};var A1;function QR(){if(A1)return ye;A1=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),u=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),d=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),S=Symbol.for("react.activity"),v=Symbol.iterator;function _(w){return w===null||typeof w!="object"?null:(w=v&&w[v]||w["@@iterator"],typeof w=="function"?w:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},T=Object.assign,j={};function B(w,G,re){this.props=w,this.context=G,this.refs=j,this.updater=re||x}B.prototype.isReactComponent={},B.prototype.setState=function(w,G){if(typeof w!="object"&&typeof w!="function"&&w!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,w,G,"setState")},B.prototype.forceUpdate=function(w){this.updater.enqueueForceUpdate(this,w,"forceUpdate")};function M(){}M.prototype=B.prototype;function I(w,G,re){this.props=w,this.context=G,this.refs=j,this.updater=re||x}var z=I.prototype=new M;z.constructor=I,T(z,B.prototype),z.isPureReactComponent=!0;var W=Array.isArray;function H(){}var V={H:null,A:null,T:null,S:null},Y=Object.prototype.hasOwnProperty;function te(w,G,re){var ae=re.ref;return{$$typeof:e,type:w,key:G,ref:ae!==void 0?ae:null,props:re}}function fe(w,G){return te(w.type,G,w.props)}function oe(w){return typeof w=="object"&&w!==null&&w.$$typeof===e}function ie(w){var G={"=":"=0",":":"=2"};return"$"+w.replace(/[=:]/g,function(re){return G[re]})}var A=/\/+/g;function Q(w,G){return typeof w=="object"&&w!==null&&w.key!=null?ie(""+w.key):G.toString(36)}function Z(w){switch(w.status){case"fulfilled":return w.value;case"rejected":throw w.reason;default:switch(typeof w.status=="string"?w.then(H,H):(w.status="pending",w.then(function(G){w.status==="pending"&&(w.status="fulfilled",w.value=G)},function(G){w.status==="pending"&&(w.status="rejected",w.reason=G)})),w.status){case"fulfilled":return w.value;case"rejected":throw w.reason}}throw w}function O(w,G,re,ae,he){var xe=typeof w;(xe==="undefined"||xe==="boolean")&&(w=null);var Ne=!1;if(w===null)Ne=!0;else switch(xe){case"bigint":case"string":case"number":Ne=!0;break;case"object":switch(w.$$typeof){case e:case n:Ne=!0;break;case y:return Ne=w._init,O(Ne(w._payload),G,re,ae,he)}}if(Ne)return he=he(w),Ne=ae===""?"."+Q(w,0):ae,W(he)?(re="",Ne!=null&&(re=Ne.replace(A,"$&/")+"/"),O(he,G,re,"",function(Ur){return Ur})):he!=null&&(oe(he)&&(he=fe(he,re+(he.key==null||w&&w.key===he.key?"":(""+he.key).replace(A,"$&/")+"/")+Ne)),G.push(he)),1;Ne=0;var pt=ae===""?".":ae+":";if(W(w))for(var Ze=0;Ze<w.length;Ze++)ae=w[Ze],xe=pt+Q(ae,Ze),Ne+=O(ae,G,re,xe,he);else if(Ze=_(w),typeof Ze=="function")for(w=Ze.call(w),Ze=0;!(ae=w.next()).done;)ae=ae.value,xe=pt+Q(ae,Ze++),Ne+=O(ae,G,re,xe,he);else if(xe==="object"){if(typeof w.then=="function")return O(Z(w),G,re,ae,he);throw G=String(w),Error("Objects are not valid as a React child (found: "+(G==="[object Object]"?"object with keys {"+Object.keys(w).join(", ")+"}":G)+"). If you meant to render a collection of children, use an array instead.")}return Ne}function N(w,G,re){if(w==null)return w;var ae=[],he=0;return O(w,ae,"","",function(xe){return G.call(re,xe,he++)}),ae}function ne(w){if(w._status===-1){var G=w._result;G=G(),G.then(function(re){(w._status===0||w._status===-1)&&(w._status=1,w._result=re)},function(re){(w._status===0||w._status==Line truncated
|
||||
at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
|
||||
`+ps+t+oc}var fc=!1;function Wa(t,r){if(!t||fc)return"";fc=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var c={DetermineComponentFrameRoot:function(){try{if(r){var J=function(){throw Error()};if(Object.defineProperty(J.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(J,[])}catch(F){var q=F}Reflect.construct(t,[],J)}else{try{J.call()}catch(F){q=F}t.call(J.prototype)}}else{try{throw Error()}catch(F){q=F}(J=t())&&typeof J.catch=="function"&&J.catch(function(){})}}catch(F){if(F&&q&&typeof F.stack=="string")return[F.stack,q.stack]}return[null,null]}};c.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var l=Object.getOwnPropertyDescriptor(c.DetermineComponentFrameRoot,"name");l&&l.configurable&&Object.defineProperty(c.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var f=c.DetermineComponentFrameRoot(),g=f[0],b=f[1];if(g&&b){var E=g.split(`
|
||||
`),L=b.split(`
|
||||
`);for(l=c=0;c<E.length&&!E[c].includes("DetermineComponentFrameRoot");)c++;for(;l<L.length&&!L[l].includes("DetermineComponentFrameRoot");)l++;if(c===E.length||l===L.length)for(c=E.length-1,l=L.length-1;1<=c&&0<=l&&E[c]!==L[l];)l--;for(;1<=c&&0<=l;c--,l--)if(E[c]!==L[l]){if(c!==1||l!==1)do if(c--,l--,0>l||E[c]!==L[l]){var K=`
|
||||
`+E[c].replace(" at new "," at ");return t.displayName&&K.includes("<anonymous>")&&(K=K.replace("<anonymous>",t.displayName)),K}while(1<=c&&0<=l);break}}}finally{fc=!1,Error.prepareStackTrace=a}return(a=t?t.displayName||t.name:"")?mr(a):""}function bl(t,r){switch(t.tag){case 26:case 27:case 5:return mr(t.type);case 16:return mr("Lazy");case 13:return t.child!==r&&r!==null?mr("Suspense Fallback"):mr("Suspense");case 19:return mr("SuspenseList");case 0:case 15:return Wa(t.type,!1);case 11:return Wa(t.type.render,!1);case 1:return Wa(t.type,!0);case 31:return mr("Activity");default:return""}}function Nr(t){try{var r="",a=null;do r+=bl(t,a),a=t,t=t.return;while(t);return r}catch(c){return`
|
||||
Error generating stack: `+c.message+`
|
||||
`+c.stack}}var ca=Object.prototype.hasOwnProperty,tr=e.unstable_scheduleCallback,dc=e.unstable_cancelCallback,qd=e.unstable_shouldYield,_l=e.unstable_requestPaint,rn=e.unstable_now,xl=e.unstable_getCurrentPriorityLevel,Fe=e.unstable_ImmediatePriority,_t=e.unstable_UserBlockingPriority,Qt=e.unstable_NormalPriority,El=e.unstable_LowPriority,My=e.unstable_IdlePriority,M2=e.log,C2=e.unstable_setDisableYieldValue,hc=null,bn=null;function gs(t){if(typeof M2=="function"&&C2(t),bn&&typeof bn.setStrictMode=="function")try{bn.setStrictMode(hc,t)}catch{}}var _n=Math.clz32?Math.clz32:z2,k2=Math.log,U2=Math.LN2;function z2(t){return t>>>=0,t===0?32:31-(k2(t)/U2|0)|0}var wl=256,Tl=262144,Ol=4194304;function ua(t){var r=t&42;if(r!==0)return r;switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return t&261888;case 262144:case 524288:case 1048576:case 2097152:return t&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function Rl(t,r,a){var c=t.pendingLanes;if(c===0)return 0;var l=0,f=t.suspendedLanes,g=t.pingedLanes;t=t.warmLanes;var b=c&134217727;return b!==0?(c=b&~f,c!==0?l=ua(c):(g&=b,g!==0?l=ua(g):a||(a=b&~t,a!==0&&(l=ua(a))))):(b=c&~f,b!==0?l=ua(b):g!==0?l=ua(g):a||(a=c&~t,a!==0&&(l=ua(a)))),l===0?0:r!==0&&r!==l&&(r&f)===0&&(f=l&-l,a=r&-r,f>=a||f===32&&(a&4194048)!==0)?r:l}function mc(t,r){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&r)===0}function N2(t,r){switch(t){case 1:case 2:case 4:case 8:case 64:return r+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Cy(){var t=Ol;return Ol<<=1,(Ol&62914560)===0&&(Ol=4194304),t}function $d(t){for(var r=[],a=0;31>a;a++)r.push(t);return r}function pc(t,r){t.pendingLanes|=r,r!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function D2(t,r,a,c,l,f){var g=t.pendingLanes;t.pendingLanes=a,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=a,t.entangledLanes&=a,t.errorRecoveryDisabledLanes&=a,t.shellSuspendCounter=0;var b=t.entanglements,E=t.expirationTimes,L=t.hiddenUpdates;for(a=g&~a;0<a;){var K=31-_n(a),J=1<<K;b[K]=0,E[K]=-1;var q=L[K];if(q!==null)for(L[K]=null,K=0;K<q.length;K++){var F=q[K];F!==null&&(F.lane&=-536870913)}a&=~J}c!==0&&ky(t,c,0),f!==0&&l===0&&t.tag!==0&&(t.suspendedLanes|=f&~(g&~r))}function ky(t,r,a){t.pendingLanes|=r,t.suspendedLanes&=~r;var c=31-_n(r);t.entangledLanes|=r,t.entanglements[c]=t.entanglements[c]|1073741824|a&261930}function Uy(t,r){var a=t.entangledLanes|=r;for(t=t.entanglements;a;){var c=31-_n(a),l=1<<c;l&r|t[c]&r&&(t[c]|=r),a&=~l}}function zy(t,r){var a=r&-r;return a=(a&42)!==0?1:Hd(a),(a&(t.suspendedLanes|r))!==0?0:a}function Hd(t){switch(t){case 2:t=1;break;case 8:t=4;break;case 32:t=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:t=128;break;case 268435456:t=134217728;break;default:t=0}return t}function Vd(t){return t&=-t,2<t?8<t?(t&134217727)!==0?32:268435456:8:2}function Ny(){var t=N.p;return t!==0?t:(t=window.event,t===void 0?32:v1(t.type))}function Dy(t,r){var a=N.p;try{return N.p=t,r()}finally{N.p=a}}var ys=Math.random().toString(36).slice(2),It="__reactFiber$"+ys,cn="__reactProps$"+ys,ei="__reactContainer$"+ys,Id="__reactEvents$"+ys,L2="__reactListeners$"+ys,j2="__reactHandles$"+ys,Ly="__reactResources$"+ys,gc="__reactMarker$"+ys;function Yd(t){delete t[It],delete t[cn],delete t[Id],delete t[L2],delete t[j2]}function ti(t){var r=t[It];if(r)return r;for(var a=t.parentNode;a;){if(r=a[ei]||a[It]){if(a=r.alternate,r.child!==null||a!==null&&a.child!==null)for(t=r1(t);t!==null;){if(a=t[It])return a;t=r1(t)}return r}t=a,a=t.parentNode}return null}function ni(t){if(t=t[It]||t[ei]){var r=t.tag;if(r===5||r===6||r===13||r===31||r===26||r===27||r===3)return t}return null}function yc(t){var r=t.tag;if(r===5||r===26||r===27||r===6)return t.stateNode;throw Error(i(33))}function ri(t){var r=t[Ly];return r||(r=t[Ly]={hoistableStyles:new Map,hoistableScripts:new Map}),r}function zt(t){t[gc]=!0}var jy=new Set,By={};function la(t,r){si(t,r),si(t+"Capture",r)}function si(t,r){for(By[t]=r,t=0;t<r.length;t++)jy.add(r[t])}var B2=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u21
Line truncated
|
||||
`).replace(pR,"")}function Kb(t,r){return r=Fb(r),Fb(t)===r}function Ye(t,r,a,c,l,f){switch(a){case"children":typeof c=="string"?r==="body"||r==="textarea"&&c===""||ii(t,c):(typeof c=="number"||typeof c=="bigint")&&r!=="body"&&ii(t,""+c);break;case"className":Ml(t,"class",c);break;case"tabIndex":Ml(t,"tabindex",c);break;case"dir":case"role":case"viewBox":case"width":case"height":Ml(t,a,c);break;case"style":Ky(t,c,f);break;case"data":if(r!=="object"){Ml(t,"data",c);break}case"src":case"href":if(c===""&&(r!=="a"||a!=="href")){t.removeAttribute(a);break}if(c==null||typeof c=="function"||typeof c=="symbol"||typeof c=="boolean"){t.removeAttribute(a);break}c=kl(""+c),t.setAttribute(a,c);break;case"action":case"formAction":if(typeof c=="function"){t.setAttribute(a,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof f=="function"&&(a==="formAction"?(r!=="input"&&Ye(t,r,"name",l.name,l,null),Ye(t,r,"formEncType",l.formEncType,l,null),Ye(t,r,"formMethod",l.formMethod,l,null),Ye(t,r,"formTarget",l.formTarget,l,null)):(Ye(t,r,"encType",l.encType,l,null),Ye(t,r,"method",l.method,l,null),Ye(t,r,"target",l.target,l,null)));if(c==null||typeof c=="symbol"||typeof c=="boolean"){t.removeAttribute(a);break}c=kl(""+c),t.setAttribute(a,c);break;case"onClick":c!=null&&(t.onclick=Lr);break;case"onScroll":c!=null&&Re("scroll",t);break;case"onScrollEnd":c!=null&&Re("scrollend",t);break;case"dangerouslySetInnerHTML":if(c!=null){if(typeof c!="object"||!("__html"in c))throw Error(i(61));if(a=c.__html,a!=null){if(l.children!=null)throw Error(i(60));t.innerHTML=a}}break;case"multiple":t.multiple=c&&typeof c!="function"&&typeof c!="symbol";break;case"muted":t.muted=c&&typeof c!="function"&&typeof c!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(c==null||typeof c=="function"||typeof c=="boolean"||typeof c=="symbol"){t.removeAttribute("xlink:href");break}a=kl(""+c),t.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":c!=null&&typeof c!="function"&&typeof c!="symbol"?t.setAttribute(a,""+c):t.removeAttribute(a);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":c&&typeof c!="function"&&typeof c!="symbol"?t.setAttribute(a,""):t.removeAttribute(a);break;case"capture":case"download":c===!0?t.setAttribute(a,""):c!==!1&&c!=null&&typeof c!="function"&&typeof c!="symbol"?t.setAttribute(a,c):t.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":c!=null&&typeof c!="function"&&typeof c!="symbol"&&!isNaN(c)&&1<=c?t.setAttribute(a,c):t.removeAttribute(a);break;case"rowSpan":case"start":c==null||typeof c=="function"||typeof c=="symbol"||isNaN(c)?t.removeAttribute(a):t.setAttribute(a,c);break;case"popover":Re("beforetoggle",t),Re("toggle",t),Al(t,"popover",c);break;case"xlinkActuate":Dr(t,"http://www.w3.org/1999/xlink","xlink:actuate",c);break;case"xlinkArcrole":Dr(t,"http://www.w3.org/1999/xlink","xlink:arcrole",c);break;case"xlinkRole":Dr(t,"http://www.w3.org/1999/xlink","xlink:role",c);break;case"xlinkShow":Dr(t,"http://www.w3.org/1999/xlink","xlink:show",c);break;case"xlinkTitle":Dr(t,"http://www.w3.org/1999/xlink","xlink:title",c);break;case"xlinkType":Dr(t,"http://www.w3.org/1999/xlink","xlink:type",c);break;case"xmlBase":Dr(t,"http://www.w3.org/XML/1998/namespace","xml:base",c);break;case"xmlLang":Dr(t,"http://www.w3.org/XML/1998/namespace","xml:lang",c);break;case"xmlSpace":Dr(t,"http://www.w3.org/XML/1998/namespace","xml:space",c);break;case"is":Al(t,"is",c);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=I2.get(a)||a,Al(t,a,c))}}function Nm(t,r,a,c,l,f){switch(a){case"style":Ky(t,c,f);break;case"dangerouslySetInnerHTML":if(c!=null){if(typeof c!="object"||!("__html"in c))throw Error(i(61));if(a=c.__html,a!=null){if(l.children!=null)throw Error(i(60));t.innerHTML=a}}break;case"children":typeof c=="string"?ii(t,c):(typeof c=="number"||typeof c=="bigint")&&ii(t,""+c);break;case"onScroll":c!=null&&Re("scroll",t);break;case"onScrollEnd":c!=null&&Re("scrollend",t);break;case"onClick":c!=null&&(t.onclick=Lr);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"inne
Line truncated
|
||||
`+o(y+1));return`[
|
||||
${o(y+1)}${S}
|
||||
${o(y)}]`}if(m instanceof Date)return MA(m);if(!n?.ignoreToString&&Be(m,"toString")&&typeof m.toString=="function"&&m.toString!==Object.prototype.toString&&m.toString!==Array.prototype.toString){const S=CA(m);return m instanceof Error&&m.cause?`${S} (cause: ${p(m.cause,y)})`:S}if(typeof m=="string")return JSON.stringify(m);if(typeof m=="number"||m==null||typeof m=="boolean"||typeof m=="symbol")return String(m);if(typeof m=="bigint")return String(m)+"n";if(typeof m=="object"||typeof m=="function"){if(i.has(m))return j1;if(i.add(m),Zf in m)return Rt(Lx(m));if(Symbol.iterator in m)return`${m.constructor.name}(${p(Array.from(m),y)})`;const S=h(m);if(!u||S.length<=1){const _=`{${S.map(x=>`${ff(x)}:${p(m[x],y)}`).join(",")}}`;return d(m,_)}const v=`{
|
||||
${S.map(_=>`${o(y+1)}${ff(_)}: ${p(m[_],y+1)}`).join(`,
|
||||
`)}
|
||||
${o(y)}}`;return d(m,v)}return String(m)}return p(e,0)}const j1="[Circular]";function ff(e){return typeof e=="string"?JSON.stringify(e):String(e)}function AA(e){return e.map(n=>`[${ff(n)}]`).join("")}function MA(e){try{return e.toISOString()}catch{return"Invalid Date"}}function CA(e){try{const n=e.toString();return typeof n=="string"?n:String(n)}catch{return"[toString threw]"}}function jx(e,n){let s=[];const i=JSON.stringify(e,(u,o)=>typeof o=="object"&&o!==null?s.includes(o)?void 0:s.push(o)&&Wf(o):o,n?.space);return s=void 0,i}const Ws=Symbol.for("nodejs.util.inspect.custom"),Fa=e=>{try{if(Be(e,"toJSON")&&Qf(e.toJSON)&&e.toJSON.length===0)return e.toJSON();if(Array.isArray(e))return e.map(Fa)}catch{return"[toJSON threw]"}return Wf(e)},kA=(e,n=2)=>{if(typeof e=="string")return e;try{return typeof e=="object"?UA(e,n):String(e)}catch{return String(e)}},UA=(e,n)=>{let s=[];const i=JSON.stringify(e,(u,o)=>typeof o=="object"&&o!==null?s.includes(o)?void 0:s.push(o)&&Wf(o):o,n);return s=void 0,i},B1={toJSON(){return Fa(this)},[Ws](){return this.toJSON()},toString(){return Rt(this.toJSON())}};class ed{called=!1;self;constructor(n){this.self=n}next(n){return this.called?{value:n,done:!0}:(this.called=!0,{value:this.self,done:!1})}[Symbol.iterator](){return new ed(this.self)}}const Pi="~effect/Effect/internal",Bx={[Pi]:e=>e()},zA={[Pi]:e=>e()},NA=Bx[Pi](()=>new Error().stack)?.includes(Pi)===!0,Wt=NA?Bx[Pi]:zA[Pi],ls="~effect/Effect",ku="~effect/Exit",DA={_A:_e,_E:_e,_R:_e},qx=`${ls}/identifier`,we=`${ls}/args`,Ht=`${ls}/evaluate`,kn=`${ls}/successCont`,_r=`${ls}/failureCont`,ja=`${ls}/ensureCont`,Aa=Symbol.for("effect/Effect/Yield"),Ar={pipe(){return bt(this,arguments)},toJSON(){return{...this}},toString(){return Rt(this.toJSON(),{ignoreToString:!0,space:2})},[Ws](){return this.toJSON()}},td={[Symbol.iterator](){return new ed(this)}},LA={...td,pipe(){return bt(this,arguments)}},jA={[ls]:DA,...Ar,[Symbol.iterator](){return new ed(this)},asEffect(){return this},toJSON(){return{_id:"Effect",op:this[qx],...we in this?{args:this[we]}:void 0}}},Xt=e=>Be(e,ls),$x=e=>Be(e,ku),Xo="~effect/Cause",Qo="~effect/Cause/Reason",nd=e=>Be(e,Xo),BA=e=>Be(e,Qo);class Ka{[Xo];reasons;constructor(n){this[Xo]=Xo,this.reasons=n}pipe(){return bt(this,arguments)}toJSON(){return{_id:"Cause",failures:this.reasons.map(n=>n.toJSON())}}toString(){return`Cause(${Rt(this.reasons)})`}[Ws](){return this.toJSON()}[nn](n){return nd(n)&&this.reasons.length===n.reasons.length&&this.reasons.every((s,i)=>$t(s,n.reasons[i]))}[tn](){return Dx(this.reasons)}}const q1=new WeakMap;class Hg{[Qo];annotations;_tag;constructor(n,s,i){if(this[Qo]=Qo,this._tag=n,s!==rd&&typeof i=="object"&&i!==null&&s.size>0){const u=q1.get(i);u&&(s=new Map([...u,...s])),q1.set(i,s)}this.annotations=s}annotate(n,s){if(n.mapUnsafe.size===0)return this;const i=new Map(this.annotations);n.mapUnsafe.forEach((o,d)=>{s?.overwrite!==!0&&i.has(d)||i.set(d,o)});const u=Object.assign(Object.create(Object.getPrototypeOf(this)),this);return u.annotations=i,u}pipe(){return bt(this,arguments)}toString(){return Rt(this)}[Ws](){return this.toString()}}const rd=new Map;class Hx extends Hg{error;constructor(n,s=rd){super("Fail",s,n),this.error=n}toString(){return`Fail(${Rt(this.error)})`}toJSON(){return{_tag:"Fail",error:this.error}}[nn](n){return Yg(n)&&$t(this.error,n.error)&&$t(this.annotations,n.annotations)}[tn](){return Xn(Mt(this._tag))(Xn(Je(this.error))(Je(this.annotations)))}}const sd=e=>new Ka(e),qA=new Ka([]),Vg=e=>new Ka([new Hx(e)]);class Ig extends Hg{defect;constructor(n,s=rd){super("Die",s,n),this.defect=n}toString(){return`Die(${Rt(this.defect)})`}toJSON(){return{_tag:"Die",defect:this.defect}}[nn](n){return HA(n)&&$t(this.defect,n.defect)&&$t(this.annotations,n.annotations)}[tn](){return Xn(Mt(this._tag))(Xn(Je(this.defect))(Je(this.annotations)))}}const $A=e=>new Ka([new Ig(e)]),Hp=P(e=>nd(e[0]),(e,n,s)=>n.mapUnsafe.size===0?e:new Ka(e.reasons.map(i=>i.annotate(n,s)))),Yg=e=>e._tag==="Fail",HA=e=>e._tag==="Die",Gg=e=>e._tag==="Interrupt";function VA(e){return Xi("Effect.evaluate: Not implemented")}const Zu=e=>({...jA,[qx]:e.op,[Ht]:e[Ht]??VA,[kn]:e[kn],[_r]:e[_r],[ja]:e[ja]}),or=e=>{const n=Zu(e);return function(){const s=Object.create(n);return s[we]=e.single===!1?arguments:arguments[0],s}},Vx=e=>{const n={...Zu(e),[ku]:ku,_tag:e.op,get[e.prop](){return this[we]},toString(){return`${e.op}(${Rt(this[we])})`},toJSON(){return{_id:"Exit",_tag:e.op,[e.prop]:this[we]}},[nn](s){return $x(s)&&s._tag===this._tag&&$t(this[we],s[we])},[tn](){return Xn(Mt(e.op),Je(this[we]))}};return function(s){const i=Object.create(n);return i[we]=s,i}},et=Vx({op:"Success",prop:"value",[Ht](e){const n=e.getCont(kn);return n?n[kn](this[we],e,this):e.yieldWith(this)}}),ad={key:"effect/Cause/StackTrace"},IA={key:"effect/Cause/InterruptorStackTrace"},Jn=Vx({op:"Failure",prop:"cause",[Ht](e){let n=this[we],s=!1;e.currentStackFrame&&(n=Hp(n,{mapUnsafe:new Map([[ad.key,e.currentStackFrame]])}),s=!0);let i=e.get
Line truncated
|
||||
`);if(s.length>2){const i=s[2].match(/at (.*)/);i&&(n.message=n.message+` (defined at ${i[1]})`)}}if(n.stack){const s=n.stack.split(`
|
||||
`);s.splice(1,3),n.stack=s.join(`
|
||||
`)}return n},Ba=P(2,(e,n)=>{if(e.mapUnsafe.size===0)return n;if(n.mapUnsafe.size===0)return e;const s=new Map(e.mapUnsafe);return n.mapUnsafe.forEach((i,u)=>s.set(u,i)),ir(s)}),lC=(...e)=>{const n=new Map;for(let s=0;s<e.length;s++)e[s].mapUnsafe.forEach((i,u)=>{n.set(u,i)});return ir(n)},ft=Sn,Ji=ft("effect/Scheduler",{defaultValue:()=>new Nu}),oC="setImmediate"in globalThis?e=>{const n=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(n)}:e=>{const n=setTimeout(e,0);return()=>clearTimeout(n)};class fC{buckets=[];scheduleTask(n,s){const i=this.buckets,u=i.length;let o,d=0;for(;d<u&&!(i[d][0]>s);d++)o=i[d];o&&o[0]===s?o[1].push(n):d===u?i.push([s,[n]]):i.splice(d,0,[s,[n]])}drain(){const n=this.buckets;return this.buckets=[],n}}class Nu{tasks=new fC;running=void 0;executionMode;setImmediate;constructor(n="async",s=oC){this.executionMode=n,this.setImmediate=s}scheduleTask(n,s){this.tasks.scheduleTask(n,s),this.running===void 0&&(this.running=this.setImmediate(this.afterScheduled))}afterScheduled=()=>{this.running=void 0,this.runTasks()};runTasks(){const n=this.tasks.drain();for(let s=0;s<n.length;s++){const i=n[s][1];for(let u=0;u<i.length;u++)i[u]()}}shouldYield(n){return n.currentOpCount>=n.maxOpsBeforeYield}flush(){for(;this.tasks.buckets.length>0;)this.running!==void 0&&(this.running(),this.running=void 0),this.runTasks()}}const dC=ft("effect/Scheduler/MaxOpsBeforeYield",{defaultValue:()=>2048}),hE="effect/Tracer/ParentSpan";class hC extends Sn()(hE){}const mC=e=>e,Fp=ft("effect/Tracer/DisablePropagation",{defaultValue:Ux}),pC=ft("effect/Tracer/CurrentTraceLevel",{defaultValue:()=>"Info"}),gC=ft("effect/Tracer/MinimumTraceLevel",{defaultValue:()=>"All"}),mE="effect/Tracer",yC=ft(mE,{defaultValue:()=>mC({span:e=>new SC(e)})});class SC{_tag="Span";spanId;traceId="native";sampled;name;parent;annotations;links;startTime;kind;status;attributes;events=[];constructor(n){this.name=n.name,this.parent=n.parent,this.annotations=n.annotations,this.links=n.links,this.startTime=n.startTime,this.kind=n.kind,this.sampled=n.sampled,this.status={_tag:"Started",startTime:n.startTime},this.attributes=new Map,this.traceId=n.parent?.traceId??Y1(32),this.spanId=Y1(16)}end(n,s){this.status={_tag:"Ended",endTime:n,exit:s,startTime:this.status.startTime}}attribute(n,s){this.attributes.set(n,s)}event(n,s,i){this.events.push([n,s,i??{}])}addLinks(n){this.links.push(...n)}}const Y1=(function(){const e="abcdef0123456789",n=e.length;return function(s){let i="";for(let u=0;u<s;u++)i+=e.charAt(Math.floor(Math.random()*n));return i}})(),vC=ft("effect/References/CurrentConcurrency",{defaultValue:()=>"unbounded"}),pE=ft("effect/References/CurrentStackFrame",{defaultValue:jg}),bC=ft("effect/References/TracerEnabled",{defaultValue:Pf}),gE=ft("effect/References/TracerTimingEnabled",{defaultValue:Pf}),_C=ft("effect/References/TracerSpanAnnotations",{defaultValue:()=>({})}),xC=ft("effect/References/TracerSpanLinks",{defaultValue:()=>[]}),Zg=ft("effect/References/CurrentLogAnnotations",{defaultValue:()=>({})}),EC=ft("effect/References/CurrentLogLevel",{defaultValue:()=>"Info"}),wC=ft("effect/References/MinimumLogLevel",{defaultValue:()=>"Info"}),TC=ft("effect/References/CurrentLogSpans",{defaultValue:()=>[]}),OC="effect/observability/Metric/FiberRuntimeMetricsKey",RC=e=>{if(e?.captureStackTrace===!1)return e;if(e?.captureStackTrace!==void 0&&typeof e.captureStackTrace!="boolean")return e;const n=Error.stackTraceLimit;Error.stackTraceLimit=3;const s=new Error;return Error.stackTraceLimit=n,{...e,captureStackTrace:MC(()=>s.stack)}},AC=e=>n=>{let s;return()=>{if(s!==void 0)return s;const i=n();if(!i)return;const u=i.split(`
|
||||
`);if(u[e]!==void 0)return s=u[e].trim(),s}},MC=AC(3),CC="dev";let yE=class extends Hg{fiberId;constructor(n,s=rd){super("Interrupt",s,"Interrupted"),this.fiberId=n}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:"Interrupt",fiberId:this.fiberId}}[nn](n){return Gg(n)&&this.fiberId===n.fiberId&&this.annotations===n.annotations}[tn](){return Xn(Mt(`${this._tag}:${this.fiberId}`))($p(this.annotations))}};const kC=e=>new yE(e),el=e=>new Ka([new yE(e)]),UC=e=>{const n=e.reasons.find(Yg);return n?fs(n):ur(e)},Pa=e=>{for(let n=0;n<e.reasons.length;n++){const s=e.reasons[n];if(s._tag==="Fail")return fs(s.error)}return ur(e)},zC=e=>e.reasons.some(Gg),Wg=e=>{let n;for(let s=0;s<e.reasons.length;s++){const i=e.reasons[s];i._tag==="Interrupt"&&(n??=new Set,i.fiberId!==void 0&&n.add(i.fiberId))}return n?fs(n):ur(e)},NC=e=>{const n=Wg(e);return ct(n)?DC:n.success},DC=new Set,LC=e=>e.reasons.every(Gg),jC=P(2,(e,n)=>{if(e.reasons.length===0)return n;if(n.reasons.length===0)return e;const s=new Ka(CM(e.reasons,n.reasons));return $t(e,s)?e:s}),BC=e=>{const n={Fail:[],Die:[],Interrupt:[]};for(let s=0;s<e.reasons.length;s++)n[e.reasons[s]._tag].push(e.reasons[s]);return n},SE=e=>{const n=BC(e);return n.Fail.length>0?n.Fail[0].error:n.Die.length>0?n.Die[0].defect:n.Interrupt.length>0?new globalThis.Error("All fibers interrupted without error"):new globalThis.Error("Empty cause")},qC=e=>{const n=[],s=[];if(e.reasons.length===0)return n;const i=Error.stackTraceLimit;Error.stackTraceLimit=1;for(const u of e.reasons){if(u._tag==="Interrupt"){s.push(u);continue}n.push(Kp(u._tag==="Die"?u.defect:u.error,u.annotations))}if(n.length===0){const u=new Error("The fiber was interrupted by:");u.name="InterruptCause",u.stack=IC(u,s);const o=new globalThis.Error("All fibers interrupted without error",{cause:u});o.name="InterruptError",o.stack=`${o.name}: ${o.message}`,n.push(Kp(o,s[0].annotations))}return Error.stackTraceLimit=i,n},Kp=(e,n)=>{const s=typeof e;let i;if(e&&s==="object"){if(i=new globalThis.Error($C(e),{cause:e.cause?Kp(e.cause):void 0}),typeof e.name=="string"&&(i.name=e.name),typeof e.stack=="string")i.stack=VC(e.stack,i,n);else{const u=`${i.name}: ${i.message}`;i.stack=n?vE(u,n):u}for(const u of Object.keys(e))u in i||(i[u]=e[u])}else i=new globalThis.Error(e?s==="string"?e:jx(e):`Unknown error: ${e}`);return i},$C=e=>{if(typeof e.message=="string")return e.message;if(typeof e.toString=="function"&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString)try{return e.toString()}catch{}return jx(e)},HC=/\((.*)\)/g,VC=(e,n,s)=>{const i=`${n.name}: ${n.message}`,u=(e.startsWith(i)?e.slice(i.length):e).split(`
|
||||
`),o=[i];for(let d=1;d<u.length&&!/(?:Generator\.next|~effect\/Effect)/.test(u[d]);d++)o.push(u[d]);return s?vE(o.join(`
|
||||
`),s):o.join(`
|
||||
`)},vE=(e,n)=>{const s=n?.get(ad.key);return s&&(e=`${e}
|
||||
${bE(s)}`),e},IC=(e,n)=>{const s=[`${e.name}: ${e.message}`];for(const i of n){const u=i.fiberId!==void 0?`#${i.fiberId}`:"unknown",o=i.annotations.get(IA.key);s.push(` at fiber (${u})`),o&&s.push(bE(o))}return s.join(`
|
||||
`)},bE=e=>{const n=[];let s=e,i=0;for(;s&&i<10;){const u=s.stack();if(u){const o=u.matchAll(HC);let d=!1;for(const[,h]of o)d=!0,n.push(` at ${s.name} (${h})`);d||n.push(` at ${s.name} (${u.replace(/^at /,"")})`)}else n.push(` at ${s.name}`);s=s.parent,i++}return n.join(`
|
||||
`)},e0=e=>qC(e).map(n=>n.cause?`${n.stack} {
|
||||
${_E(n.cause," ")}
|
||||
}`:n.stack).join(`
|
||||
`),_E=(e,n)=>{const s=e.stack.split(`
|
||||
`);let i=`${n}[cause]: ${s[0]}`;for(let u=1,o=s.length;u<o;u++)i+=`
|
||||
${n}${s[u]}`;return e.cause&&(i+=` {
|
||||
${_E(e.cause,`${n} `)}
|
||||
${n}}`),i},Pp=`~effect/Fiber/${CC}`,YC={_A:_e,_E:_e},GC={id:0},xE=()=>globalThis[Su];class EE{constructor(n,s=!0){this[Pp]=YC,this.setServices(n),this.id=++GC.id,this.currentOpCount=0,this.currentLoopCount=0,this.interruptible=s,this._stack=[],this._observers=[],this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0}[Pp];id;interruptible;currentOpCount;currentLoopCount;_stack;_observers;_exit;_currentExit;_children;_interruptedCause;_yielded;services;currentScheduler;currentTracerContext;currentSpan;currentLogLevel;minimumLogLevel;currentStackFrame;runtimeMetrics;maxOpsBeforeYield;getRef(n){return cC(this.services,n)}addObserver(n){return this._exit?(n(this._exit),cc):(this._observers.push(n),()=>{const s=this._observers.indexOf(n);s>=0&&this._observers.splice(s,1)})}interruptUnsafe(n,s){if(this._exit)return;let i=el(n);this.currentStackFrame&&(i=Hp(i,Qi(ad,this.currentStackFrame))),s&&(i=Hp(i,s)),this._interruptedCause=this._interruptedCause?jC(this._interruptedCause,i):i,this.interruptible&&this.evaluate(en(this._interruptedCause))}pollUnsafe(){return this._exit}evaluate(n){if(this.runtimeMetrics?.recordFiberStart(this.services),this._exit)return;if(this._yielded!==void 0){const i=this._yielded;this._yielded=void 0,i()}const s=this.runLoop(n);if(s!==Aa){this._exit=s,this.runtimeMetrics?.recordFiberEnd(this.services,this._exit);for(let i=0;i<this._observers.length;i++)this._observers[i](s);this._observers.length=0}}runLoop(n){const s=globalThis[Su];globalThis[Su]=this;let i=!1,u=n;this.currentOpCount=0;const o=++this.currentLoopCount;try{for(;;){if(this.currentOpCount++,!i&&this.currentScheduler.shouldYield(this)){i=!0;const d=u;u=qe(n0,()=>d)}if(u=this.currentTracerContext?this.currentTracerContext(u,this):u[Ht](this),o!==this.currentLoopCount)return Aa;if(u===Aa){const d=this._yielded;return ku in d?(this._yielded=void 0,d):Aa}}}catch(d){return Be(u,Ht)?this.runLoop(Xi(d)):Xi(`Fiber.runLoop: Not a valid effect: ${String(u)}`)}finally{globalThis[Su]=s}}getCont(n){for(;;){const s=this._stack.pop();if(!s)return;const i=s[ja]&&s[ja](this);if(i)return i[n]=i,i;if(s[n])return s}}yieldWith(n){return this._yielded=n,Aa}children(){return this._children??=new Set}pipe(){return bt(this,arguments)}setServices(n){this.services=n,this.currentScheduler=this.getRef(Ji),this.currentSpan=n.mapUnsafe.get(hE),this.currentLogLevel=this.getRef(EC),this.minimumLogLevel=this.getRef(wC),this.currentStackFrame=n.mapUnsafe.get(pE.key),this.maxOpsBeforeYield=this.getRef(dC),this.runtimeMetrics=n.mapUnsafe.get(OC);const s=n.mapUnsafe.get(mE);this.currentTracerContext=s?s.context:void 0}get currentSpanLocal(){return this.currentSpan?._tag==="Span"?this.currentSpan:void 0}}const cd=e=>{if(!e.currentStackFrame)return;const n=new Map;return n.set(ad.key,e.currentStackFrame),ir(n)},FC=e=>{const n=e;return n._exit?ve(n._exit):an(s=>n._exit?s(ve(n._exit)):lt(e.addObserver(i=>s(ve(i)))))},wE=e=>an(n=>{const s=e[Symbol.iterator](),i=[];let u;function o(){let d=s.next();for(;!d.done;){if(d.value._exit){i.push(d.value._exit),d=s.next();continue}u=d.value.addObserver(h=>{i.push(h),o()});return}n(ve(i))}return o(),lt(()=>u?.())}),KC=e=>{const n=e;return n._exit?n._exit:an(s=>n._exit?s(n._exit):lt(e.addObserver(s)))},PC=e=>an(n=>{const s=Array.from(e);if(s.length===0)return n(ve(Ip()));const i=new Array(s.length),u=Ip();let o=0,d=!1;for(let h=0;h<s.length&&!d;h++)u.push(s[h].addObserver(p=>{if(o++,p._tag==="Failure")return d=!0,u.forEach(m=>m()),n(p);i[h]=p.value,o===s.length&&n(ve(i))}))}),t0=e=>Ve(n=>XC(e,n.id)),XC=P(e=>Be(e[0],Pp),(e,n,s)=>Ve(i=>{let u=cd(i);return u=u&&s?Ba(u,s):u??s,e.interruptUnsafe(n,u),ld(FC(e))})),mf=e=>Ve(n=>{const s=cd(n);for(const i of e)i.interruptUnsafe(n.id,s);return ld(wE(e))}),ve=et,en=Jn,ud=Mr,lt=or({op:"Sync",[Ht](e){const n=this[we](),s=e.getCont(kn);return s?s[kn](n,e):e.yieldWith(et(n))}}),ot=or({op:"Suspend",[Ht](e){return this[we]()}}),QC=or({op:"Yield",[Ht](e){let n=!1;return e.currentScheduler.scheduleTask(()=>{n||e.evaluate(Or)},this[we]??0),e.yieldWith(()=>{n=!0})}}),n0=QC(0),JC=e=>ve(Te(e)),r0=ve(Ct()),s0=e=>Xi(e),TE=e=>ot(()=>ud(Wt(e))),kt=ve(void 0),ZC=e=>OE(function(n,s){Wt(()=>e(s)).then(i=>n(ve(i)),i=>n(s0(i)))},e.length!==0),WC=e=>Ve(n=>e(n.id)),OE=or({op:"Async",single:!1,[Ht](e){const n=Wt(()=>this[we][0].bind(e.currentScheduler));let s=!1,i=!1;const u=this[we][1]?new AbortController:void 0,o=n(d=>{s||(s=!0,i?e.evaluate(d):i=d)},u?.signal);return i!==!1?i:(i=!0,e._yielded=()=>{s=!0},u===void 0&&o===void 0||e._stack.push(e3(()=>(s=!0,u?.abort(),o??Or))),Aa)}}),e3=or({op:"AsyncFinalizer",[ja](e){e.interruptible&&(e.interruptible=!1,e._stack.push(gd))},[_r](e,n){return zC(e)?qe(this[we](),()=>en(e)):en(e)}}),an=e=>OE(e,e.length>=2),t3=an(cc),n3=(...e)=>ot(()=>Du(e.length===1?e[0]():e[1].call(e[0].self))),RE=(e,...n)=>{const s=n.length===0?function(){return ot(()=>Du(e.apply(this,arguments)))}:function(){let i=ot(()=>Du(e.apply(this,arguments)));for(let u=0;u<n
Line truncated
|
||||
`)}const yz=gz();function Sz(e){let n=e.message;if(e.path&&e.path.length>0){const s=AA(e.path);n+=`
|
||||
at ${s}`}return n}function Yu(e){switch(e._tag){case"InvalidType":case"OneOf":case"Composite":case"AnyOf":return uu(e.ast.annotations);case"InvalidValue":case"Forbidden":return uu(e.annotations);case"MissingKey":return uu(e.annotations,"messageMissingKey");case"UnexpectedKey":return uu(e.ast.annotations,"messageUnexpectedKey");case"Filter":return uu(e.filter.annotations);case"Encoding":return Yu(e.issue)}}function uu(e,n="message"){const s=e?.[n];if(typeof s=="string")return s}function h_(e){return os(e)?"no value provided":Rt(e.value)}class ec extends Kf{run;constructor(n){super(),this.run=n}map(n){return new ec((s,i)=>this.run(s,i).pipe(vw(Pg(n))))}compose(n){return m_(this)?n:m_(n)?this:new ec((s,i)=>this.run(s,i).pipe(Ii(u=>n.run(u,i))))}}const Uw=new ec(Ee);function m_(e){return e.run===Uw.run}function tc(){return Uw}function pn(e){return vz(Pg(e))}function vz(e){return new ec(n=>Ee(e(n)))}function bz(){return pn(globalThis.String)}function zw(){return pn(globalThis.Number)}const og="~effect/SchemaTransformation/Transformation";class gn{[og]=og;_tag="Transformation";decode;encode;constructor(n,s){this.decode=n,this.encode=s}flip(){return new gn(this.encode,this.decode)}compose(n){return new gn(this.decode.compose(n.decode),n.encode.compose(this.encode))}}function _z(e){return Be(e,og)}const Nw=e=>_z(e)?e:new gn(e.decode,e.encode);function Ed(e){return new gn(pn(e.decode),pn(e.encode))}const xz=new gn(tc(),tc());function $0(){return xz}const Dw=new gn(zw(),bz()),Lw=e=>Ed({decode:n=>{const s=new Error(n.message);return typeof n.name=="string"&&n.name!=="Error"&&(s.name=n.name),typeof n.stack=="string"&&(s.stack=n.stack),s},encode:n=>{const s={name:n.name,message:n.message};return e?.includeStack&&typeof n.stack=="string"&&(s.stack=n.stack),s}});function Ja(e){return n=>n._tag===e}const jw=Ja("Declaration"),Ez=Ja("Never"),Of=Ja("Literal"),wz=Ja("UniqueSymbol"),Tz=Ja("Arrays"),Oz=Ja("Objects"),Rz=Ja("Union");let Vt=class{to;transformation;constructor(n,s){this.to=n,this.transformation=s}};const Az={};class nc{isOptional;isMutable;defaultValue;annotations;constructor(n,s,i=void 0,u=void 0){this.isOptional=n,this.isMutable=s,this.defaultValue=i,this.annotations=u}}const p_="~effect/Schema";class vn{[p_]=p_;annotations;checks;encoding;context;constructor(n=void 0,s=void 0,i=void 0,u=void 0){this.annotations=n,this.checks=s,this.encoding=i,this.context=u}toString(){return`<${this._tag}>`}}class ol extends vn{_tag="Declaration";typeParameters;run;constructor(n,s,i,u,o,d){super(i,u,o,d),this.typeParameters=n,this.run=s}getParser(){const n=this.run(this.typeParameters);return(s,i)=>os(s)?b0:vw(n(s.value,this,i),Te)}recur(n){const s=rc(this.typeParameters,n);return s===this.typeParameters?this:new ol(s,this.run,this.annotations,this.checks,void 0,this.context)}getExpected(){const n=this.annotations?.expected;return typeof n=="string"?n:"<Declaration>"}}class Mz extends vn{_tag="Null";getParser(){return Od(this,null)}getExpected(){return"null"}}const Bw=new Mz;let Cz=class extends vn{_tag="Undefined";getParser(){return Od(this,void 0)}toCodecJson(){return qt(this,[qw])}getExpected(){return"undefined"}};const qw=new Vt(Bw,new gn(pn(()=>{}),pn(()=>null))),kz=new Cz;let Uz=class extends vn{_tag="Void";getParser(){return Od(this,void 0)}toCodecJson(){return qt(this,[qw])}getExpected(){return"void"}};const zz=new Uz;let Nz=class extends vn{_tag="Never";getParser(){return Za(this,uA)}getExpected(){return"never"}};const Dz=new Nz;let Lz=class extends vn{_tag="Any";getParser(){return Za(this,Nx)}getExpected(){return"any"}};const jz=new Lz;let Bz=class extends vn{_tag="Unknown";getParser(){return Za(this,Nx)}getExpected(){return"unknown"}};const H0=new Bz;let Tu=class extends vn{_tag="Literal";literal;constructor(n,s,i,u,o){if(super(s,i,u,o),typeof n=="number"&&!globalThis.Number.isFinite(n))throw new Error(`A numeric literal must be finite, got ${Rt(n)}`);this.literal=n}getParser(){return Od(this,this.literal)}toCodecJson(){return typeof this.literal=="bigint"?g_(this):this}toCodecStringTree(){return typeof this.literal=="string"?this:g_(this)}getExpected(){return typeof this.literal=="string"?JSON.stringify(this.literal):globalThis.String(this.literal)}};function g_(e){const n=globalThis.String(e.literal);return qt(e,[new Vt(new Tu(n),new gn(pn(()=>e.literal),pn(()=>n)))])}let qz=class extends vn{_tag="String";getParser(){return Za(this,Xf)}getExpected(){return"string"}};const $w=new qz;let $z=class extends vn{_tag="Number";getParser(){return Za(this,of)}toCodecJson(){return this.checks&&(gu(this.checks,"isFinite")||gu(this.checks,"isInt"))?this:qt(this,[Kz])}toCodecStringTree(){return this.checks&&(gu(this.checks,"isFinite")||gu(this.checks,"isInt"))?qt(this,[sN]):qt(this,[aN])}getExpected(){return"number"}};function gu(e,n){return e.some(s=>{switch(s._tag){case"Filter":return s.annotations?.meta?._tag===n;case"FilterGroup":return gu(s.checks,n)}})}const Hw=new $z;let Hz=class extends vn{_tag="Boolean";getParser(){ret
Line truncated
|
||||
`)[5]??""]})),z6=P(2,(e,n)=>x6(e)?gl(s=>n(s,e),function(s,i){s.set(e,i)},e.refresh??function(s){s(e)}):Xs(s=>n(s,e),e.refresh??function(s){s(e)})),N6=y6,j_="~effect-atom/atom/Atom/ServerValue",D6=P(2,(e,n)=>j_ in e?e[j_](s=>n.get(s)):n.get(e));var bp=Cx();function LT(e){const n=bp.unstable_scheduleCallback(bp.unstable_LowPriority,e);return()=>bp.unstable_cancelCallback(n)}const kd=le.createContext(AT({scheduleTask:LT,defaultIdleTTL:400})),L6=e=>{const n=le.useRef(null);return n.current===null&&(n.current={registry:AT({scheduleTask:e.scheduleTask??LT,initialValues:e.initialValues,timeoutResolution:e.timeoutResolution,defaultIdleTTL:e.defaultIdleTTL})}),le.useEffect(()=>(n.current?.timeout!==void 0&&clearTimeout(n.current.timeout),()=>{n.current.timeout=setTimeout(()=>{n.current?.registry.dispose(),n.current=null},500)}),[n]),le.createElement(kd.Provider,{value:n.current.registry},e?.children)},B_=new WeakMap;function j6(e,n){let s=B_.get(e);s===void 0&&(s=new WeakMap,B_.set(e,s));const i=s.get(n);if(i!==void 0)return i;const u={subscribe(o){return e.subscribe(n,o)},snapshot(){return e.get(n)},getServerSnapshot(){return D6(n,e)}};return s.set(n,u),u}function B6(e,n){const s=j6(e,n);return le.useSyncExternalStore(s.subscribe,s.snapshot,s.getServerSnapshot)}const ta=(e,n)=>{const s=le.useContext(kd);return B6(s,e)};function jT(e,n){le.useEffect(()=>e.mount(n),[n,e])}function q6(e,n,s){return s?.mode==="promise"||s?.mode==="promiseExit"?le.useCallback(i=>{e.set(n,i);const u=G4(u6(e,n,{suspendOnWaiting:!0}));return s.mode==="promise"?u.then($6):u},[e,n,s.mode]):le.useCallback(i=>{e.set(n,typeof i=="function"?i(e.get(n)):i)},[e,n])}const $6=e=>{if(ew(e))return e.value;throw JE(e.cause)},Wr=(e,n)=>{const s=le.useContext(kd);return jT(s,e),q6(s,e,n)},H6=e=>{const n=le.useContext(kd);return jT(n,e),le.useCallback(()=>{n.refresh(e)},[n,e])};var it=(e=>(e[e.None=0]="None",e[e.Mutable=1]="Mutable",e[e.Watching=2]="Watching",e[e.RecursedCheck=4]="RecursedCheck",e[e.Recursed=8]="Recursed",e[e.Dirty=16]="Dirty",e[e.Pending=32]="Pending",e))(it||{});function BT({update:e,notify:n,unwatched:s}){return{link:i,unlink:u,propagate:o,checkDirty:d,shallowPropagate:h};function i(m,y,S){const v=y.depsTail;if(v!==void 0&&v.dep===m)return;const _=v!==void 0?v.nextDep:y.deps;if(_!==void 0&&_.dep===m){_.version=S,y.depsTail=_;return}const x=m.subsTail;if(x!==void 0&&x.version===S&&x.sub===y)return;const T=y.depsTail=m.subsTail={version:S,dep:m,sub:y,prevDep:v,nextDep:_,prevSub:x,nextSub:void 0};_!==void 0&&(_.prevDep=T),v!==void 0?v.nextDep=T:y.deps=T,x!==void 0?x.nextSub=T:m.subs=T}function u(m,y=m.sub){const S=m.dep,v=m.prevDep,_=m.nextDep,x=m.nextSub,T=m.prevSub;return _!==void 0?_.prevDep=v:y.depsTail=v,v!==void 0?v.nextDep=_:y.deps=_,x!==void 0?x.prevSub=T:S.subsTail=T,T!==void 0?T.nextSub=x:(S.subs=x)===void 0&&s(S),_}function o(m){let y=m.nextSub,S;e:do{const v=m.sub;let _=v.flags;if(_&60?_&12?_&4?!(_&48)&&p(m,v)?(v.flags=_|40,_&=1):_=0:v.flags=_&-9|32:_=0:v.flags=_|32,_&2&&n(v),_&1){const x=v.subs;if(x!==void 0){const T=(m=x).nextSub;T!==void 0&&(S={value:y,prev:S},y=T);continue}}if((m=y)!==void 0){y=m.nextSub;continue}for(;S!==void 0;)if(m=S.value,S=S.prev,m!==void 0){y=m.nextSub;continue e}break}while(!0)}function d(m,y){let S,v=0,_=!1;e:do{const x=m.dep,T=x.flags;if(y.flags&16)_=!0;else if((T&17)===17){if(e(x)){const j=x.subs;j.nextSub!==void 0&&h(j),_=!0}}else if((T&33)===33){(m.nextSub!==void 0||m.prevSub!==void 0)&&(S={value:m,prev:S}),m=x.deps,y=x,++v;continue}if(!_){const j=m.nextDep;if(j!==void 0){m=j;continue}}for(;v--;){const j=y.subs,B=j.nextSub!==void 0;if(B?(m=S.value,S=S.prev):m=j,_){if(e(y)){B&&h(j),y=m.sub;continue}_=!1}else y.flags&=-33;y=m.sub;const M=m.nextDep;if(M!==void 0){m=M;continue e}}return _}while(!0)}function h(m){do{const y=m.sub,S=y.flags;(S&48)===32&&(y.flags=S|16,(S&6)===2&&n(y))}while((m=m.nextSub)!==void 0)}function p(m,y){let S=y.depsTail;for(;S!==void 0;){if(S===m)return!0;S=S.prevDep}return!1}}let cy=0,Oa=0,Au=0;const es=[],{link:rB,unlink:qT,propagate:sB,checkDirty:V6,shallowPropagate:aB}=BT({update(e){return e.depsTail!==void 0?F6(e):K6(e)},notify(e){let n=Au,s=n;do if(es[n++]=e,e.flags&=-3,e=e.subs?.sub,e===void 0||!(e.flags&2))break;while(!0);for(Au=n;s<--n;){const i=es[s];es[s++]=es[n],es[n]=i}},unwatched(e){e.flags&1?e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=17,Ud(e)):Q6.call(e)}});function I6(){return cy}function Y6(){++cy}function G6(){--cy||X6()}function F6(e){e.depsTail=void 0,e.flags=5;try{const n=e.value;return n!==(e.value=e.getter(n))}finally{e.flags&=-5,Ud(e)}}function K6(e){return e.flags=1,e.currentValue!==(e.currentValue=e.pendingValue)}function P6(e){const n=e.flags;if(n&16||n&32&&V6(e.deps,e)){e.depsTail=void 0,e.flags=6;try{e.fn()}finally{e.flags&=-5,Ud(e)}}else e.flags=2}function X6(){try{for(;Oa<Au;){const e=es[Oa];es[Oa++]=void 0,P6(e)}}finally{for(;Oa<Au;){const e=es[Oa];es[Oa++]=void 0,e.flags|=10}Oa=0,Au=0}}function Q6(){this.depsTail=void 0,this.flags=0,Ud(
Line truncated
|
||||
@@ -0,0 +1,16 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>effect-http-ws-cli rpc console</title>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||
<link href="https://fonts.googleapis.com/css2?family=Archivo+Black&family=IBM+Plex+Sans:wght@400;500;700&display=swap" rel="stylesheet" />
|
||||
<script type="module" crossorigin src="/assets/index-CuY7i06l.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-Bz7MwgeQ.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,94 @@
|
||||
import { spawn } from "node:child_process"
|
||||
|
||||
const frontendDevOrigin = process.env.FRONTEND_DEV_ORIGIN ?? "http://127.0.0.1:5173"
|
||||
const frontendDevUrl = new URL(frontendDevOrigin)
|
||||
|
||||
if (frontendDevUrl.protocol !== "http:" && frontendDevUrl.protocol !== "https:") {
|
||||
throw new Error(`FRONTEND_DEV_ORIGIN must use http or https, received ${frontendDevOrigin}`)
|
||||
}
|
||||
|
||||
const frontendHost = process.env.FRONTEND_DEV_HOST ?? frontendDevUrl.hostname
|
||||
const frontendPort = process.env.FRONTEND_DEV_PORT ?? (frontendDevUrl.port || "5173")
|
||||
const serverArgs = process.argv.slice(2)
|
||||
|
||||
const readFlagValue = (name) => {
|
||||
const index = serverArgs.findIndex((arg) => arg === name)
|
||||
if (index >= 0) {
|
||||
return serverArgs[index + 1]
|
||||
}
|
||||
|
||||
const prefixed = serverArgs.find((arg) => arg.startsWith(`${name}=`))
|
||||
return prefixed ? prefixed.slice(name.length + 1) : undefined
|
||||
}
|
||||
|
||||
const normalizeBackendHost = (host) => {
|
||||
if (!host || host === "0.0.0.0" || host === "::") {
|
||||
return "127.0.0.1"
|
||||
}
|
||||
return host
|
||||
}
|
||||
|
||||
const backendHost = normalizeBackendHost(process.env.HOST ?? readFlagValue("--host"))
|
||||
const backendPort = process.env.PORT ?? readFlagValue("--port") ?? "8787"
|
||||
const backendOrigin = process.env.VITE_BACKEND_ORIGIN ?? `http://${backendHost}:${backendPort}`
|
||||
|
||||
const children = new Set()
|
||||
let shuttingDown = false
|
||||
|
||||
const stopChildren = (signal = "SIGTERM") => {
|
||||
if (shuttingDown) {
|
||||
return
|
||||
}
|
||||
shuttingDown = true
|
||||
for (const child of children) {
|
||||
if (!child.killed) {
|
||||
child.kill(signal)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const spawnChild = (command, args, env = {}) => {
|
||||
const child = spawn(command, args, {
|
||||
stdio: "inherit",
|
||||
env: {
|
||||
...process.env,
|
||||
...env
|
||||
}
|
||||
})
|
||||
|
||||
children.add(child)
|
||||
|
||||
child.on("exit", (code, signal) => {
|
||||
stopChildren(signal ?? "SIGTERM")
|
||||
if (signal) {
|
||||
process.kill(process.pid, signal)
|
||||
return
|
||||
}
|
||||
process.exit(code ?? 0)
|
||||
})
|
||||
|
||||
return child
|
||||
}
|
||||
|
||||
spawnChild("bun", [
|
||||
"run",
|
||||
"--filter",
|
||||
"@effect-http-ws-cli/web",
|
||||
"dev",
|
||||
"--",
|
||||
"--host",
|
||||
frontendHost,
|
||||
"--port",
|
||||
frontendPort,
|
||||
"--strictPort"
|
||||
], {
|
||||
VITE_BACKEND_ORIGIN: backendOrigin
|
||||
})
|
||||
|
||||
spawnChild("node", ["server/src/bin.ts", ...serverArgs], {
|
||||
FRONTEND_DEV_ORIGIN: frontendDevOrigin
|
||||
})
|
||||
|
||||
for (const signal of ["SIGINT", "SIGTERM"]) {
|
||||
process.on(signal, () => stopChildren(signal))
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "@effect-http-ws-cli/server",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"exports": {
|
||||
"./client": "./src/client.ts",
|
||||
"./contracts": "./src/contracts.ts"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "node src/bin.ts",
|
||||
"start": "node src/bin.ts",
|
||||
"test": "vitest run",
|
||||
"lint": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@effect/platform-node": "catalog:",
|
||||
"@effect/sql-sqlite-node": "catalog:",
|
||||
"effect": "catalog:"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@effect/vitest": "catalog:",
|
||||
"@types/node": "^24.10.0",
|
||||
"typescript": "catalog:",
|
||||
"vitest": "catalog:"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
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 todos (
|
||||
id TEXT PRIMARY KEY NOT NULL,
|
||||
title TEXT NOT NULL,
|
||||
completed INTEGER NOT NULL,
|
||||
archived INTEGER NOT NULL,
|
||||
revision INTEGER NOT NULL,
|
||||
updated_at TEXT NOT NULL
|
||||
)
|
||||
`
|
||||
|
||||
yield* sql`
|
||||
CREATE TABLE IF NOT EXISTS todo_events (
|
||||
event_offset INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
at TEXT NOT NULL,
|
||||
todo_json TEXT NOT NULL,
|
||||
change_json TEXT NOT NULL,
|
||||
archived INTEGER NOT NULL
|
||||
)
|
||||
`
|
||||
|
||||
yield* sql`
|
||||
CREATE INDEX IF NOT EXISTS idx_todo_events_archived_offset
|
||||
ON todo_events (archived, event_offset)
|
||||
`
|
||||
})
|
||||
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env node
|
||||
import * as NodeRuntime from "@effect/platform-node/NodeRuntime"
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices"
|
||||
import * as Effect from "effect/Effect"
|
||||
import { cli } from "./cli.ts"
|
||||
import { Command } from "effect/unstable/cli"
|
||||
|
||||
Command.run(cli, { version: "0.1.0" }).pipe(
|
||||
Effect.provide(NodeServices.layer),
|
||||
NodeRuntime.runMain
|
||||
)
|
||||
@@ -0,0 +1,125 @@
|
||||
import * as SqliteNode from "@effect/sql-sqlite-node"
|
||||
import { Command, Flag } from "effect/unstable/cli"
|
||||
import * as Config from "effect/Config"
|
||||
import * as Effect from "effect/Effect"
|
||||
import * as FileSystem from "effect/FileSystem"
|
||||
import * as Option from "effect/Option"
|
||||
import * as Path from "effect/Path"
|
||||
import { fileURLToPath } from "node:url"
|
||||
import { ServerConfig } from "./config.ts"
|
||||
import { runMigrations } from "./migrations.ts"
|
||||
import { runServer } from "./server.ts"
|
||||
import type { ServerConfigData } from "./config.ts"
|
||||
|
||||
const defaultAssetsDir = fileURLToPath(new URL("../../public", import.meta.url))
|
||||
const defaultDbFilename = fileURLToPath(new URL("../../todo.sqlite", import.meta.url))
|
||||
|
||||
const hostFlag = Flag.string("host").pipe(
|
||||
Flag.withDescription("Host interface to bind"),
|
||||
Flag.optional
|
||||
)
|
||||
|
||||
const portFlag = Flag.integer("port").pipe(
|
||||
Flag.withDescription("Port to listen on"),
|
||||
Flag.optional
|
||||
)
|
||||
|
||||
const assetsFlag = Flag.directory("assets").pipe(
|
||||
Flag.withDescription("Directory of static assets"),
|
||||
Flag.optional
|
||||
)
|
||||
|
||||
const dbFlag = Flag.string("db").pipe(
|
||||
Flag.withDescription("SQLite database filename"),
|
||||
Flag.optional
|
||||
)
|
||||
|
||||
const requestLoggingFlag = Flag.boolean("request-logging").pipe(
|
||||
Flag.withDescription("Enable request logging"),
|
||||
Flag.optional
|
||||
)
|
||||
|
||||
const frontendDevOriginFlag = Flag.string("frontend-dev-origin").pipe(
|
||||
Flag.withDescription("Redirect frontend GET requests to a Vite dev server origin"),
|
||||
Flag.optional
|
||||
)
|
||||
|
||||
const EnvServerConfig = Config.unwrap({
|
||||
host: Config.string("HOST").pipe(Config.withDefault("127.0.0.1")),
|
||||
port: Config.port("PORT").pipe(Config.withDefault(8787)),
|
||||
assetsDir: Config.string("ASSETS_DIR").pipe(Config.withDefault(defaultAssetsDir)),
|
||||
dbFilename: Config.string("DB_FILENAME").pipe(Config.withDefault(defaultDbFilename)),
|
||||
requestLogging: Config.boolean("REQUEST_LOGGING").pipe(Config.withDefault(true)),
|
||||
frontendDevOrigin: Config.string("FRONTEND_DEV_ORIGIN").pipe(
|
||||
Config.option,
|
||||
Config.map(Option.getOrUndefined)
|
||||
)
|
||||
})
|
||||
|
||||
export interface CliServerFlags {
|
||||
readonly host: Option.Option<string>
|
||||
readonly port: Option.Option<number>
|
||||
readonly assets: Option.Option<string>
|
||||
readonly db: Option.Option<string>
|
||||
readonly requestLogging: Option.Option<boolean>
|
||||
readonly frontendDevOrigin: Option.Option<string>
|
||||
}
|
||||
|
||||
export const resolveServerConfig = (
|
||||
flags: CliServerFlags
|
||||
): Effect.Effect<ServerConfigData, Config.ConfigError> =>
|
||||
Effect.gen(function*() {
|
||||
const env = yield* EnvServerConfig
|
||||
return {
|
||||
host: Option.getOrElse(flags.host, () => env.host),
|
||||
port: Option.getOrElse(flags.port, () => env.port),
|
||||
assetsDir: Option.getOrElse(flags.assets, () => env.assetsDir),
|
||||
dbFilename: Option.getOrElse(flags.db, () => env.dbFilename),
|
||||
requestLogging: Option.getOrElse(flags.requestLogging, () => env.requestLogging),
|
||||
frontendDevOrigin: Option.getOrElse(flags.frontendDevOrigin, () => env.frontendDevOrigin)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
export const resetDatabase = (dbFilename: string) =>
|
||||
Effect.gen(function*() {
|
||||
const fs = yield* FileSystem.FileSystem
|
||||
const path = yield* Path.Path
|
||||
|
||||
if (dbFilename !== ":memory:") {
|
||||
yield* fs.remove(path.resolve(dbFilename), { force: true })
|
||||
}
|
||||
|
||||
const sqliteLayer = SqliteNode.SqliteClient.layer({
|
||||
filename: dbFilename
|
||||
})
|
||||
|
||||
yield* runMigrations.pipe(Effect.provide(sqliteLayer))
|
||||
})
|
||||
|
||||
const commandFlags = {
|
||||
host: hostFlag,
|
||||
port: portFlag,
|
||||
assets: assetsFlag,
|
||||
db: dbFlag,
|
||||
requestLogging: requestLoggingFlag,
|
||||
frontendDevOrigin: frontendDevOriginFlag
|
||||
} as const
|
||||
|
||||
const rootCommand = Command.make("effect-http-ws-cli", commandFlags).pipe(
|
||||
Command.withDescription("Run a unified Effect HTTP + WebSocket server"),
|
||||
Command.withHandler((flags) =>
|
||||
Effect.flatMap(resolveServerConfig(flags), (config) =>
|
||||
runServer.pipe(Effect.provideService(ServerConfig, config)))),
|
||||
)
|
||||
|
||||
const resetCommand = Command.make("reset", commandFlags).pipe(
|
||||
Command.withDescription("Delete the SQLite database file and rerun migrations"),
|
||||
Command.withHandler((flags) =>
|
||||
Effect.flatMap(resolveServerConfig(flags), (config) => resetDatabase(config.dbFilename))
|
||||
)
|
||||
)
|
||||
|
||||
export const cli = rootCommand.pipe(
|
||||
Command.withSubcommands([resetCommand])
|
||||
)
|
||||
@@ -0,0 +1,58 @@
|
||||
import { NodeSocket } from "@effect/platform-node"
|
||||
import * as Effect from "effect/Effect"
|
||||
import * as Layer from "effect/Layer"
|
||||
import * as RpcClient from "effect/unstable/rpc/RpcClient"
|
||||
import * as RpcSerialization from "effect/unstable/rpc/RpcSerialization"
|
||||
import * as Stream from "effect/Stream"
|
||||
import { WsRpcGroup } from "./contracts.ts"
|
||||
|
||||
export const wsRpcProtocolLayer = (wsUrl: string) =>
|
||||
RpcClient.layerProtocolSocket().pipe(
|
||||
Layer.provide(NodeSocket.layerWebSocket(wsUrl)),
|
||||
Layer.provide(RpcSerialization.layerJson)
|
||||
)
|
||||
|
||||
export const makeWsRpcClient = RpcClient.make(WsRpcGroup)
|
||||
type WsRpcClient = typeof makeWsRpcClient extends Effect.Effect<infer Client, any, any> ? Client : never
|
||||
|
||||
export const withWsRpcClient = <A, E, R>(
|
||||
wsUrl: string,
|
||||
f: (client: WsRpcClient) => Effect.Effect<A, E, R>
|
||||
) =>
|
||||
makeWsRpcClient.pipe(
|
||||
Effect.flatMap(f),
|
||||
Effect.provide(wsRpcProtocolLayer(wsUrl))
|
||||
)
|
||||
|
||||
export const runClientExample = (wsUrl: string) =>
|
||||
Effect.scoped(
|
||||
withWsRpcClient(wsUrl, (client) =>
|
||||
Effect.gen(function*() {
|
||||
const echoed = yield* client.echo({ text: "hello from client" })
|
||||
const summed = yield* client.sum({ left: 20, right: 22 })
|
||||
const time = yield* client.time(undefined)
|
||||
return { echoed, summed, time }
|
||||
})
|
||||
)
|
||||
)
|
||||
|
||||
export const runSubscriptionExample = (wsUrl: string, modelId: string) =>
|
||||
Effect.scoped(
|
||||
withWsRpcClient(wsUrl, (client) =>
|
||||
Effect.gen(function*() {
|
||||
const snapshot = yield* client.listTodos({ includeArchived: true })
|
||||
const todo = snapshot.todos[0]
|
||||
if (!todo) {
|
||||
return []
|
||||
}
|
||||
|
||||
yield* client.renameTodo({ id: todo.id, title: `${modelId}: first` })
|
||||
yield* client.completeTodo({ id: todo.id, completed: true })
|
||||
|
||||
return yield* client.subscribeTodos({ fromOffset: snapshot.offset, includeArchived: true }).pipe(
|
||||
Stream.take(2),
|
||||
Stream.runCollect
|
||||
)
|
||||
})
|
||||
)
|
||||
)
|
||||
@@ -0,0 +1,14 @@
|
||||
import * as ServiceMap from "effect/ServiceMap"
|
||||
|
||||
export interface ServerConfigData {
|
||||
readonly host: string
|
||||
readonly port: number
|
||||
readonly assetsDir: string
|
||||
readonly dbFilename: string
|
||||
readonly requestLogging: boolean
|
||||
readonly frontendDevOrigin: string | undefined
|
||||
}
|
||||
|
||||
export class ServerConfig extends ServiceMap.Service<ServerConfig, ServerConfigData>()(
|
||||
"effect-http-ws-cli/ServerConfig"
|
||||
) {}
|
||||
@@ -0,0 +1,132 @@
|
||||
import * as Schema from "effect/Schema"
|
||||
import * as Rpc from "effect/unstable/rpc/Rpc"
|
||||
import * as RpcGroup from "effect/unstable/rpc/RpcGroup"
|
||||
|
||||
export const EchoPayload = Schema.Struct({
|
||||
text: Schema.String
|
||||
})
|
||||
|
||||
export const EchoResult = Schema.Struct({
|
||||
text: Schema.String
|
||||
})
|
||||
|
||||
export const SumPayload = Schema.Struct({
|
||||
left: Schema.Number,
|
||||
right: Schema.Number
|
||||
})
|
||||
|
||||
export const SumResult = Schema.Struct({
|
||||
total: Schema.Number
|
||||
})
|
||||
|
||||
export const TimeResult = Schema.Struct({
|
||||
iso: Schema.String
|
||||
})
|
||||
|
||||
export const Todo = Schema.Struct({
|
||||
id: Schema.String,
|
||||
title: Schema.String,
|
||||
completed: Schema.Boolean,
|
||||
archived: Schema.Boolean,
|
||||
revision: Schema.Number,
|
||||
updatedAt: Schema.String
|
||||
})
|
||||
export type Todo = Schema.Schema.Type<typeof Todo>
|
||||
|
||||
export const TodoChange = Schema.Union([
|
||||
Schema.Struct({
|
||||
_tag: Schema.Literal("TodoCreated")
|
||||
}),
|
||||
Schema.Struct({
|
||||
_tag: Schema.Literal("TodoRenamed"),
|
||||
title: Schema.String
|
||||
}),
|
||||
Schema.Struct({
|
||||
_tag: Schema.Literal("TodoCompleted"),
|
||||
completed: Schema.Boolean
|
||||
}),
|
||||
Schema.Struct({
|
||||
_tag: Schema.Literal("TodoArchived"),
|
||||
archived: Schema.Boolean
|
||||
})
|
||||
])
|
||||
export type TodoChange = Schema.Schema.Type<typeof TodoChange>
|
||||
|
||||
export const TodoEvent = Schema.Struct({
|
||||
offset: Schema.Number,
|
||||
at: Schema.String,
|
||||
todo: Todo,
|
||||
change: TodoChange
|
||||
})
|
||||
export type TodoEvent = Schema.Schema.Type<typeof TodoEvent>
|
||||
|
||||
export const TodoSnapshot = Schema.Struct({
|
||||
offset: Schema.Number,
|
||||
todos: Schema.Array(Todo)
|
||||
})
|
||||
export type TodoSnapshot = Schema.Schema.Type<typeof TodoSnapshot>
|
||||
|
||||
export const EchoRpc = Rpc.make("echo", {
|
||||
payload: EchoPayload,
|
||||
success: EchoResult
|
||||
})
|
||||
|
||||
export const SumRpc = Rpc.make("sum", {
|
||||
payload: SumPayload,
|
||||
success: SumResult
|
||||
})
|
||||
|
||||
export const TimeRpc = Rpc.make("time", {
|
||||
success: TimeResult
|
||||
})
|
||||
|
||||
export const ListTodosRpc = Rpc.make("listTodos", {
|
||||
payload: Schema.Struct({
|
||||
includeArchived: Schema.Boolean
|
||||
}),
|
||||
success: TodoSnapshot
|
||||
})
|
||||
|
||||
export const RenameTodoRpc = Rpc.make("renameTodo", {
|
||||
payload: Schema.Struct({
|
||||
id: Schema.String,
|
||||
title: Schema.String
|
||||
}),
|
||||
success: TodoEvent
|
||||
})
|
||||
|
||||
export const CompleteTodoRpc = Rpc.make("completeTodo", {
|
||||
payload: Schema.Struct({
|
||||
id: Schema.String,
|
||||
completed: Schema.Boolean
|
||||
}),
|
||||
success: TodoEvent
|
||||
})
|
||||
|
||||
export const ArchiveTodoRpc = Rpc.make("archiveTodo", {
|
||||
payload: Schema.Struct({
|
||||
id: Schema.String,
|
||||
archived: Schema.Boolean
|
||||
}),
|
||||
success: TodoEvent
|
||||
})
|
||||
|
||||
export const SubscribeTodosRpc = Rpc.make("subscribeTodos", {
|
||||
payload: Schema.Struct({
|
||||
fromOffset: Schema.Number,
|
||||
includeArchived: Schema.Boolean
|
||||
}),
|
||||
success: TodoEvent,
|
||||
stream: true
|
||||
})
|
||||
|
||||
export const WsRpcGroup = RpcGroup.make(
|
||||
EchoRpc,
|
||||
SumRpc,
|
||||
TimeRpc,
|
||||
ListTodosRpc,
|
||||
RenameTodoRpc,
|
||||
CompleteTodoRpc,
|
||||
ArchiveTodoRpc,
|
||||
SubscribeTodosRpc
|
||||
)
|
||||
@@ -0,0 +1,73 @@
|
||||
import * as Schema from "effect/Schema"
|
||||
import * as SchemaTransformation from "effect/SchemaTransformation"
|
||||
|
||||
export const ClientMessage = Schema.Union([
|
||||
Schema.Struct({
|
||||
kind: Schema.Literal("echo"),
|
||||
text: Schema.String
|
||||
}),
|
||||
Schema.Struct({
|
||||
kind: Schema.Literal("sum"),
|
||||
left: Schema.Number,
|
||||
right: Schema.Number
|
||||
}),
|
||||
Schema.Struct({
|
||||
kind: Schema.Literal("time")
|
||||
})
|
||||
])
|
||||
|
||||
export type ClientMessage = Schema.Schema.Type<typeof ClientMessage>
|
||||
|
||||
export const ServerMessage = Schema.Union([
|
||||
Schema.Struct({
|
||||
kind: Schema.Literal("echo"),
|
||||
text: Schema.String
|
||||
}),
|
||||
Schema.Struct({
|
||||
kind: Schema.Literal("sumResult"),
|
||||
total: Schema.Number
|
||||
}),
|
||||
Schema.Struct({
|
||||
kind: Schema.Literal("time"),
|
||||
iso: Schema.String
|
||||
}),
|
||||
Schema.Struct({
|
||||
kind: Schema.Literal("error"),
|
||||
error: Schema.String
|
||||
})
|
||||
])
|
||||
|
||||
|
||||
export type ServerMessage = Schema.Schema.Type<typeof ServerMessage>
|
||||
|
||||
export const decodeClientMessage = Schema.decodeUnknownEffect(ClientMessage)
|
||||
|
||||
const Utf8StringFromUint8Array = Schema.Uint8Array.pipe(
|
||||
Schema.decodeTo(
|
||||
Schema.String,
|
||||
SchemaTransformation.transform({
|
||||
decode: (bytes) => new TextDecoder().decode(bytes),
|
||||
encode: (text) => new TextEncoder().encode(text)
|
||||
})
|
||||
)
|
||||
)
|
||||
|
||||
const ClientMessageFromWire = Schema.Union([
|
||||
Schema.String,
|
||||
Utf8StringFromUint8Array
|
||||
]).pipe(
|
||||
Schema.decodeTo(Schema.fromJsonString(ClientMessage))
|
||||
)
|
||||
|
||||
export const decodeWireClientMessage = Schema.decodeUnknownEffect(ClientMessageFromWire)
|
||||
|
||||
export const routeClientMessage = (message: ClientMessage): ServerMessage => {
|
||||
switch (message.kind) {
|
||||
case "echo":
|
||||
return { kind: "echo", text: message.text }
|
||||
case "sum":
|
||||
return { kind: "sumResult", total: message.left + message.right }
|
||||
case "time":
|
||||
return { kind: "time", iso: new Date().toISOString() }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* MigrationsLive - Migration runner with inline loader
|
||||
*
|
||||
* Uses Migrator.make with fromRecord to define migrations inline.
|
||||
* All migrations are statically imported - no dynamic file system loading.
|
||||
*
|
||||
* Migrations run automatically when the MigrationsLive layer is provided,
|
||||
* ensuring the database schema is up-to-date before the application starts.
|
||||
*/
|
||||
import * as Effect from "effect/Effect"
|
||||
import * as Layer from "effect/Layer"
|
||||
import * as ServiceMap from "effect/ServiceMap"
|
||||
import * as Migrator from "effect/unstable/sql/Migrator"
|
||||
import Migration0001 from "./Migrations/001_TodoSchema.ts"
|
||||
|
||||
const loader = Migrator.fromRecord({
|
||||
"1_TodoSchema": Migration0001
|
||||
})
|
||||
|
||||
const run = Migrator.make({})
|
||||
|
||||
export const runMigrations = Effect.gen(function*() {
|
||||
yield* Effect.log("Running migrations...")
|
||||
yield* run({ loader })
|
||||
yield* Effect.log("Migrations ran successfully")
|
||||
})
|
||||
|
||||
export interface MigrationsReadyApi {
|
||||
readonly ready: true
|
||||
}
|
||||
|
||||
export class MigrationsReady extends ServiceMap.Service<MigrationsReady, MigrationsReadyApi>()(
|
||||
"effect-http-ws-cli/MigrationsReady"
|
||||
) {}
|
||||
|
||||
export const MigrationsLive = Layer.effect(
|
||||
MigrationsReady,
|
||||
runMigrations.pipe(
|
||||
Effect.as(MigrationsReady.of({ ready: true }))
|
||||
)
|
||||
)
|
||||
@@ -0,0 +1,268 @@
|
||||
import * as Effect from "effect/Effect"
|
||||
import * as Layer from "effect/Layer"
|
||||
import * as Option from "effect/Option"
|
||||
import * as PubSub from "effect/PubSub"
|
||||
import * as Schema from "effect/Schema"
|
||||
import * as ServiceMap from "effect/ServiceMap"
|
||||
import * as Stream from "effect/Stream"
|
||||
import * as SqlClient from "effect/unstable/sql/SqlClient"
|
||||
import * as SqlSchema from "effect/unstable/sql/SqlSchema"
|
||||
import type { Todo, TodoChange, TodoEvent, TodoSnapshot } from "./contracts.ts"
|
||||
import { Todo as TodoSchema, TodoChange as TodoChangeSchema } from "./contracts.ts"
|
||||
import { MigrationsReady } from "./migrations.ts"
|
||||
|
||||
export interface TodoStoreApi {
|
||||
readonly list: (input: {
|
||||
readonly includeArchived: boolean
|
||||
}) => Effect.Effect<TodoSnapshot, never, SqlClient.SqlClient>
|
||||
readonly rename: (input: {
|
||||
readonly id: string
|
||||
readonly title: string
|
||||
}) => Effect.Effect<TodoEvent, never, SqlClient.SqlClient>
|
||||
readonly complete: (input: {
|
||||
readonly id: string
|
||||
readonly completed: boolean
|
||||
}) => Effect.Effect<TodoEvent, never, SqlClient.SqlClient>
|
||||
readonly archive: (input: {
|
||||
readonly id: string
|
||||
readonly archived: boolean
|
||||
}) => Effect.Effect<TodoEvent, never, SqlClient.SqlClient>
|
||||
readonly subscribe: (input: {
|
||||
readonly fromOffset: number
|
||||
readonly includeArchived: boolean
|
||||
}) => Stream.Stream<TodoEvent, never, SqlClient.SqlClient>
|
||||
}
|
||||
|
||||
export class TodoStore extends ServiceMap.Service<TodoStore, TodoStoreApi>()(
|
||||
"effect-http-ws-cli/TodoStore"
|
||||
) {}
|
||||
|
||||
const TodoRow = Schema.Struct({
|
||||
id: Schema.String,
|
||||
title: Schema.String,
|
||||
completed: Schema.BooleanFromBit,
|
||||
archived: Schema.BooleanFromBit,
|
||||
revision: Schema.Number,
|
||||
updatedAt: Schema.String
|
||||
})
|
||||
|
||||
const TodoEventRow = Schema.Struct({
|
||||
offset: Schema.Number,
|
||||
at: Schema.String,
|
||||
todo: Schema.fromJsonString(TodoSchema),
|
||||
change: Schema.fromJsonString(TodoChangeSchema)
|
||||
})
|
||||
|
||||
const EventInsertRequest = Schema.Struct({
|
||||
at: Schema.String,
|
||||
todo: Schema.fromJsonString(TodoSchema),
|
||||
change: Schema.fromJsonString(TodoChangeSchema),
|
||||
archived: Schema.BooleanFromBit
|
||||
})
|
||||
|
||||
const ListRequest = Schema.Struct({
|
||||
includeArchived: Schema.Boolean
|
||||
})
|
||||
|
||||
const CatchupRequest = Schema.Struct({
|
||||
fromOffset: Schema.Number,
|
||||
includeArchived: Schema.Boolean
|
||||
})
|
||||
|
||||
const OffsetRow = Schema.Struct({
|
||||
offset: Schema.Number
|
||||
})
|
||||
|
||||
const makeQueries = (sql: SqlClient.SqlClient) => {
|
||||
const listTodoRows = SqlSchema.findAll({
|
||||
Request: ListRequest,
|
||||
Result: TodoRow,
|
||||
execute: (request) =>
|
||||
request.includeArchived
|
||||
? sql<Todo>`
|
||||
SELECT id, title, completed, archived, revision, updated_at AS updatedAt
|
||||
FROM todos
|
||||
ORDER BY id
|
||||
`
|
||||
: sql<Todo>`
|
||||
SELECT id, title, completed, archived, revision, updated_at AS updatedAt
|
||||
FROM todos
|
||||
WHERE archived = 0
|
||||
ORDER BY id
|
||||
`
|
||||
})
|
||||
|
||||
const findTodoById = SqlSchema.findOneOption({
|
||||
Request: Schema.String,
|
||||
Result: TodoRow,
|
||||
execute: (id) => sql<Todo>`
|
||||
SELECT id, title, completed, archived, revision, updated_at AS updatedAt
|
||||
FROM todos
|
||||
WHERE id = ${id}
|
||||
`
|
||||
})
|
||||
|
||||
const upsertTodo = SqlSchema.void({
|
||||
Request: TodoRow,
|
||||
execute: (todo) => sql`
|
||||
INSERT INTO todos (id, title, completed, archived, revision, updated_at)
|
||||
VALUES (${todo.id}, ${todo.title}, ${todo.completed}, ${todo.archived}, ${todo.revision}, ${todo.updatedAt})
|
||||
ON CONFLICT(id) DO UPDATE SET
|
||||
title = excluded.title,
|
||||
completed = excluded.completed,
|
||||
archived = excluded.archived,
|
||||
revision = excluded.revision,
|
||||
updated_at = excluded.updated_at
|
||||
`
|
||||
})
|
||||
|
||||
const loadEventsSince = SqlSchema.findAll({
|
||||
Request: CatchupRequest,
|
||||
Result: TodoEventRow,
|
||||
execute: (request) =>
|
||||
request.includeArchived
|
||||
? sql<TodoEvent>`
|
||||
SELECT event_offset AS "offset", at, todo_json AS todo, change_json AS change
|
||||
FROM todo_events
|
||||
WHERE event_offset > ${request.fromOffset}
|
||||
ORDER BY event_offset
|
||||
`
|
||||
: sql<TodoEvent>`
|
||||
SELECT event_offset AS "offset", at, todo_json AS todo, change_json AS change
|
||||
FROM todo_events
|
||||
WHERE event_offset > ${request.fromOffset} AND archived = 0
|
||||
ORDER BY event_offset
|
||||
`
|
||||
})
|
||||
|
||||
const insertTodoEvent = SqlSchema.findOne({
|
||||
Request: EventInsertRequest,
|
||||
Result: TodoEventRow,
|
||||
execute: (request) => sql<TodoEvent>`
|
||||
INSERT INTO todo_events (at, todo_json, change_json, archived)
|
||||
VALUES (${request.at}, ${request.todo}, ${request.change}, ${request.archived})
|
||||
RETURNING event_offset AS "offset", at, todo_json AS todo, change_json AS change
|
||||
`
|
||||
})
|
||||
|
||||
const currentOffset = SqlSchema.findOne({
|
||||
Request: Schema.Undefined,
|
||||
Result: OffsetRow,
|
||||
execute: () => sql<{ readonly offset: number }>`
|
||||
SELECT COALESCE(MAX(event_offset), 0) AS "offset"
|
||||
FROM todo_events
|
||||
`
|
||||
})
|
||||
|
||||
return {
|
||||
listTodoRows,
|
||||
findTodoById,
|
||||
upsertTodo,
|
||||
loadEventsSince,
|
||||
insertTodoEvent,
|
||||
currentOffset
|
||||
} as const
|
||||
}
|
||||
|
||||
export const layerTodoStore = Layer.effect(
|
||||
TodoStore,
|
||||
Effect.gen(function*() {
|
||||
yield* MigrationsReady
|
||||
const eventsPubSub = yield* PubSub.unbounded<TodoEvent>()
|
||||
|
||||
const append = (
|
||||
todoId: string,
|
||||
change: TodoChange,
|
||||
update: (todo: Todo) => Todo
|
||||
): Effect.Effect<TodoEvent, never, SqlClient.SqlClient> =>
|
||||
Effect.flatMap(Effect.service(SqlClient.SqlClient), (sql) => {
|
||||
const queries = makeQueries(sql)
|
||||
return sql.withTransaction(
|
||||
queries.findTodoById(todoId).pipe(
|
||||
Effect.flatMap(
|
||||
Option.match({
|
||||
onNone: () => Effect.die(`Todo not found: ${todoId}`),
|
||||
onSome: (todo) => {
|
||||
const updated = update(todo)
|
||||
return queries.upsertTodo(updated).pipe(
|
||||
Effect.flatMap(() =>
|
||||
queries.insertTodoEvent({
|
||||
at: updated.updatedAt,
|
||||
todo: updated,
|
||||
change,
|
||||
archived: updated.archived
|
||||
})
|
||||
)
|
||||
)
|
||||
}
|
||||
})
|
||||
)
|
||||
)
|
||||
)
|
||||
}).pipe(Effect.tap((event) => PubSub.publish(eventsPubSub, event)), Effect.orDie)
|
||||
|
||||
const visible = (todo: Todo, includeArchived: boolean) => includeArchived || !todo.archived
|
||||
|
||||
const subscribe = (input: {
|
||||
readonly fromOffset: number
|
||||
readonly includeArchived: boolean
|
||||
}): Stream.Stream<TodoEvent, never, SqlClient.SqlClient> => {
|
||||
const catchup = Stream.fromIterableEffect(
|
||||
Effect.flatMap(Effect.service(SqlClient.SqlClient), (sql) => makeQueries(sql).loadEventsSince(input))
|
||||
).pipe(Stream.orDie)
|
||||
|
||||
const live = Stream.fromPubSub(eventsPubSub).pipe(
|
||||
Stream.filter((event) => visible(event.todo, input.includeArchived))
|
||||
)
|
||||
|
||||
return Stream.concat(catchup, live)
|
||||
}
|
||||
|
||||
return TodoStore.of({
|
||||
list: ({ includeArchived }) =>
|
||||
Effect.flatMap(Effect.service(SqlClient.SqlClient), (sql) => {
|
||||
const queries = makeQueries(sql)
|
||||
return Effect.all({
|
||||
todos: queries.listTodoRows({ includeArchived }),
|
||||
offset: queries.currentOffset(undefined).pipe(Effect.map(({ offset }) => offset))
|
||||
}).pipe(
|
||||
Effect.map(({ offset, todos }) => ({ offset, todos }))
|
||||
)
|
||||
}).pipe(Effect.orDie),
|
||||
rename: ({ id, title }) =>
|
||||
append(
|
||||
id,
|
||||
{ _tag: "TodoRenamed", title },
|
||||
(todo) => ({
|
||||
...todo,
|
||||
title,
|
||||
revision: todo.revision + 1,
|
||||
updatedAt: new Date().toISOString()
|
||||
})
|
||||
),
|
||||
complete: ({ id, completed }) =>
|
||||
append(
|
||||
id,
|
||||
{ _tag: "TodoCompleted", completed },
|
||||
(todo) => ({
|
||||
...todo,
|
||||
completed,
|
||||
revision: todo.revision + 1,
|
||||
updatedAt: new Date().toISOString()
|
||||
})
|
||||
),
|
||||
archive: ({ id, archived }) =>
|
||||
append(
|
||||
id,
|
||||
{ _tag: "TodoArchived", archived },
|
||||
(todo) => ({
|
||||
...todo,
|
||||
archived,
|
||||
revision: todo.revision + 1,
|
||||
updatedAt: new Date().toISOString()
|
||||
})
|
||||
),
|
||||
subscribe
|
||||
})
|
||||
})
|
||||
)
|
||||
@@ -0,0 +1,155 @@
|
||||
import { NodeHttpServer } from "@effect/platform-node"
|
||||
import * as SqliteNode from "@effect/sql-sqlite-node"
|
||||
import * as Effect from "effect/Effect"
|
||||
import * as FileSystem from "effect/FileSystem"
|
||||
import * as Layer from "effect/Layer"
|
||||
import * as Path from "effect/Path"
|
||||
import * as Http from "node:http"
|
||||
import {
|
||||
HttpRouter,
|
||||
HttpServerRequest,
|
||||
HttpServerResponse
|
||||
} from "effect/unstable/http"
|
||||
import * as RpcSerialization from "effect/unstable/rpc/RpcSerialization"
|
||||
import * as RpcServer from "effect/unstable/rpc/RpcServer"
|
||||
import * as Stream from "effect/Stream"
|
||||
import {
|
||||
ClientMessage,
|
||||
routeClientMessage,
|
||||
ServerMessage
|
||||
} from "./messages.ts"
|
||||
import { ServerConfig } from "./config.ts"
|
||||
import { WsRpcGroup } from "./contracts.ts"
|
||||
import { TodoStore, layerTodoStore } from "./model-store.ts"
|
||||
import { MigrationsLive } from "./migrations.ts"
|
||||
|
||||
const respondMessage = HttpServerResponse.schemaJson(ServerMessage)
|
||||
|
||||
const messageDispatchRoute = HttpRouter.add(
|
||||
"POST",
|
||||
"/api/dispatch",
|
||||
HttpServerRequest.schemaBodyJson(ClientMessage).pipe(
|
||||
Effect.flatMap((message) => respondMessage(routeClientMessage(message))),
|
||||
Effect.catchTag(
|
||||
"SchemaError",
|
||||
() => Effect.succeed(HttpServerResponse.jsonUnsafe({ kind: "error", error: "Invalid message schema" }, { status: 400 }))
|
||||
),
|
||||
Effect.catchTag(
|
||||
"HttpServerError",
|
||||
() => Effect.succeed(HttpServerResponse.jsonUnsafe({ kind: "error", error: "Invalid request body" }, { status: 400 }))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
const websocketRpcRoute = RpcServer.layerHttp({
|
||||
group: WsRpcGroup,
|
||||
path: "/ws",
|
||||
protocol: "websocket"
|
||||
}).pipe(
|
||||
Layer.provide(WsRpcGroup.toLayer({
|
||||
echo: ({ text }) => Effect.succeed({ text }),
|
||||
sum: ({ left, right }) => Effect.succeed({ total: left + right }),
|
||||
time: () => Effect.sync(() => ({ iso: new Date().toISOString() })),
|
||||
listTodos: ({ includeArchived }) =>
|
||||
Effect.flatMap(Effect.service(TodoStore), (store) => store.list({ includeArchived })),
|
||||
renameTodo: ({ id, title }) =>
|
||||
Effect.flatMap(Effect.service(TodoStore), (store) => store.rename({ id, title })),
|
||||
completeTodo: ({ id, completed }) =>
|
||||
Effect.flatMap(Effect.service(TodoStore), (store) => store.complete({ id, completed })),
|
||||
archiveTodo: ({ id, archived }) =>
|
||||
Effect.flatMap(Effect.service(TodoStore), (store) => store.archive({ id, archived })),
|
||||
subscribeTodos: ({ fromOffset, includeArchived }) =>
|
||||
Stream.unwrap(
|
||||
Effect.map(
|
||||
Effect.service(TodoStore),
|
||||
(store) => store.subscribe({ fromOffset, includeArchived })
|
||||
)
|
||||
)
|
||||
})),
|
||||
Layer.provide(layerTodoStore),
|
||||
Layer.provide(RpcSerialization.layerJson)
|
||||
)
|
||||
|
||||
const staticRoute = HttpRouter.add(
|
||||
"GET",
|
||||
"*",
|
||||
(request) =>
|
||||
Effect.gen(function*() {
|
||||
const fs = yield* FileSystem.FileSystem
|
||||
const path = yield* Path.Path
|
||||
const config = yield* ServerConfig
|
||||
const url = HttpServerRequest.toURL(request)
|
||||
if (!url) {
|
||||
return HttpServerResponse.text("Bad Request", { status: 400 })
|
||||
}
|
||||
|
||||
if (config.frontendDevOrigin) {
|
||||
return HttpServerResponse.redirect(
|
||||
new URL(`${url.pathname}${url.search}`, config.frontendDevOrigin),
|
||||
{
|
||||
status: 307,
|
||||
headers: { "cache-control": "no-store" }
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
const root = path.resolve(config.assetsDir)
|
||||
const decodedPath = decodeURIComponent(url.pathname)
|
||||
const target = decodedPath === "/"
|
||||
? "index.html"
|
||||
: decodedPath.endsWith("/")
|
||||
? `${decodedPath.slice(1)}index.html`
|
||||
: decodedPath.slice(1)
|
||||
|
||||
const normalizedTarget = path.normalize(target)
|
||||
const absoluteTarget = path.resolve(root, normalizedTarget)
|
||||
const relativeToRoot = path.relative(root, absoluteTarget)
|
||||
|
||||
if (relativeToRoot.startsWith("..") || path.isAbsolute(relativeToRoot)) {
|
||||
return HttpServerResponse.text("Forbidden", { status: 403 })
|
||||
}
|
||||
|
||||
const exists = yield* fs.exists(absoluteTarget)
|
||||
if (!exists) {
|
||||
return HttpServerResponse.text("Not Found", { status: 404 })
|
||||
}
|
||||
|
||||
return yield* HttpServerResponse.file(absoluteTarget)
|
||||
}).pipe(Effect.catchCause(() => Effect.succeed(HttpServerResponse.text("Bad Request", { status: 400 }))))
|
||||
)
|
||||
|
||||
export const makeRoutesLayer =
|
||||
Layer.mergeAll(
|
||||
HttpRouter.add(
|
||||
"GET",
|
||||
"/health",
|
||||
HttpServerResponse.json({ ok: true })
|
||||
),
|
||||
messageDispatchRoute,
|
||||
websocketRpcRoute,
|
||||
staticRoute
|
||||
)
|
||||
|
||||
export const makeServerLayer = Layer.unwrap(
|
||||
Effect.gen(function*() {
|
||||
const config = yield* ServerConfig
|
||||
const sqliteLayer = SqliteNode.SqliteClient.layer({
|
||||
filename: config.dbFilename
|
||||
})
|
||||
const persistenceLayer = MigrationsLive.pipe(
|
||||
Layer.provideMerge(sqliteLayer)
|
||||
)
|
||||
|
||||
return HttpRouter.serve(makeRoutesLayer, {
|
||||
disableLogger: !config.requestLogging
|
||||
}).pipe(
|
||||
Layer.provideMerge(persistenceLayer),
|
||||
Layer.provide(NodeHttpServer.layer(Http.createServer, {
|
||||
host: config.host,
|
||||
port: config.port
|
||||
}))
|
||||
)
|
||||
})
|
||||
)
|
||||
|
||||
export const runServer = Layer.launch(makeServerLayer)
|
||||
@@ -0,0 +1,79 @@
|
||||
import { describe, expect, it } from "@effect/vitest"
|
||||
import * as ConfigProvider from "effect/ConfigProvider"
|
||||
import * as Effect from "effect/Effect"
|
||||
import * as Option from "effect/Option"
|
||||
import { resolveServerConfig } from "../src/cli.ts"
|
||||
|
||||
describe("cli config resolution", () => {
|
||||
it.effect("falls back to effect/config values when flags are omitted", () =>
|
||||
Effect.gen(function*() {
|
||||
const resolved = yield* resolveServerConfig({
|
||||
host: Option.none(),
|
||||
port: Option.none(),
|
||||
assets: Option.none(),
|
||||
db: Option.none(),
|
||||
requestLogging: Option.none(),
|
||||
frontendDevOrigin: Option.none()
|
||||
}).pipe(
|
||||
Effect.provideService(
|
||||
ConfigProvider.ConfigProvider,
|
||||
ConfigProvider.fromEnv({
|
||||
env: {
|
||||
HOST: "0.0.0.0",
|
||||
PORT: "4001",
|
||||
ASSETS_DIR: "public",
|
||||
DB_FILENAME: "dev.sqlite",
|
||||
REQUEST_LOGGING: "false",
|
||||
FRONTEND_DEV_ORIGIN: "http://127.0.0.1:5173"
|
||||
}
|
||||
})
|
||||
)
|
||||
)
|
||||
|
||||
expect(resolved).toEqual({
|
||||
host: "0.0.0.0",
|
||||
port: 4001,
|
||||
assetsDir: "public",
|
||||
dbFilename: "dev.sqlite",
|
||||
requestLogging: false,
|
||||
frontendDevOrigin: "http://127.0.0.1:5173"
|
||||
})
|
||||
})
|
||||
)
|
||||
|
||||
it.effect("uses CLI flags when provided", () =>
|
||||
Effect.gen(function*() {
|
||||
const resolved = yield* resolveServerConfig({
|
||||
host: Option.some("127.0.0.1"),
|
||||
port: Option.some(8788),
|
||||
assets: Option.some("public"),
|
||||
db: Option.some("override.sqlite"),
|
||||
requestLogging: Option.some(true),
|
||||
frontendDevOrigin: Option.some("http://127.0.0.1:4173")
|
||||
}).pipe(
|
||||
Effect.provideService(
|
||||
ConfigProvider.ConfigProvider,
|
||||
ConfigProvider.fromEnv({
|
||||
env: {
|
||||
HOST: "0.0.0.0",
|
||||
PORT: "4001",
|
||||
ASSETS_DIR: "other",
|
||||
DB_FILENAME: "ignored.sqlite",
|
||||
REQUEST_LOGGING: "false",
|
||||
FRONTEND_DEV_ORIGIN: "http://127.0.0.1:5173"
|
||||
}
|
||||
})
|
||||
)
|
||||
)
|
||||
|
||||
expect(resolved).toEqual({
|
||||
host: "127.0.0.1",
|
||||
port: 8788,
|
||||
assetsDir: "public",
|
||||
dbFilename: "override.sqlite",
|
||||
requestLogging: true,
|
||||
frontendDevOrigin: "http://127.0.0.1:4173"
|
||||
})
|
||||
})
|
||||
)
|
||||
})
|
||||
@@ -0,0 +1,90 @@
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices"
|
||||
import * as SqliteNode from "@effect/sql-sqlite-node"
|
||||
import { describe, expect, it } from "@effect/vitest"
|
||||
import * as Effect from "effect/Effect"
|
||||
import * as Layer from "effect/Layer"
|
||||
import * as SqlClient from "effect/unstable/sql/SqlClient"
|
||||
import * as FileSystem from "node:fs"
|
||||
import * as OS from "node:os"
|
||||
import * as NodePath from "node:path"
|
||||
import { resetDatabase } from "../src/cli.ts"
|
||||
import { MigrationsLive } from "../src/migrations.ts"
|
||||
|
||||
const countRows = (dbFilename: string, tableName: string) =>
|
||||
Effect.flatMap(Effect.service(SqlClient.SqlClient), (sql) =>
|
||||
sql<{ readonly count: number }>`SELECT COUNT(*) AS count FROM ${sql(tableName)}`.pipe(
|
||||
Effect.map((rows) => rows[0]?.count ?? 0)
|
||||
)
|
||||
).pipe(
|
||||
Effect.provide(SqliteNode.SqliteClient.layer({ filename: dbFilename }))
|
||||
)
|
||||
|
||||
const insertTodo = (dbFilename: string) =>
|
||||
Effect.scoped(
|
||||
Effect.flatMap(Effect.service(SqlClient.SqlClient), (sql) => {
|
||||
const now = new Date().toISOString()
|
||||
const id = "todo-reset-test"
|
||||
const title = "before-reset"
|
||||
return sql.withTransaction(
|
||||
sql`
|
||||
INSERT INTO todos (id, title, completed, archived, revision, updated_at)
|
||||
VALUES (${id}, ${title}, 0, 0, 1, ${now})
|
||||
`.pipe(
|
||||
Effect.flatMap(() =>
|
||||
sql`
|
||||
INSERT INTO todo_events (at, todo_json, change_json, archived)
|
||||
VALUES (
|
||||
${now},
|
||||
${JSON.stringify({
|
||||
id,
|
||||
title,
|
||||
completed: false,
|
||||
archived: false,
|
||||
revision: 1,
|
||||
updatedAt: now
|
||||
})},
|
||||
${JSON.stringify({ _tag: "TodoCreated" })},
|
||||
0
|
||||
)
|
||||
`
|
||||
)
|
||||
)
|
||||
)
|
||||
}).pipe(
|
||||
Effect.provide(MigrationsLive.pipe(Layer.provideMerge(SqliteNode.SqliteClient.layer({ filename: dbFilename }))))
|
||||
)
|
||||
)
|
||||
|
||||
describe("reset command", () => {
|
||||
it.effect("deletes the database and reruns migrations without reseeding todos", () =>
|
||||
Effect.gen(function*() {
|
||||
const dbFilename = NodePath.join(
|
||||
OS.tmpdir(),
|
||||
`effect-http-ws-cli-reset-${Date.now()}-${Math.random().toString(16).slice(2)}.sqlite`
|
||||
)
|
||||
|
||||
yield* insertTodo(dbFilename)
|
||||
|
||||
const beforeCount = yield* countRows(dbFilename, "todos")
|
||||
expect(beforeCount).toBe(1)
|
||||
|
||||
yield* resetDatabase(dbFilename).pipe(
|
||||
Effect.provide(NodeServices.layer)
|
||||
)
|
||||
|
||||
const todoCount = yield* countRows(dbFilename, "todos")
|
||||
const migrationCount = yield* countRows(dbFilename, "effect_sql_migrations")
|
||||
|
||||
expect(todoCount).toBe(0)
|
||||
expect(migrationCount).toBe(1)
|
||||
|
||||
yield* Effect.sync(() => {
|
||||
try {
|
||||
FileSystem.rmSync(dbFilename, { force: true })
|
||||
} catch {
|
||||
// ignore cleanup failures in tests
|
||||
}
|
||||
})
|
||||
})
|
||||
)
|
||||
})
|
||||
@@ -0,0 +1,310 @@
|
||||
import { NodeHttpServer } from "@effect/platform-node"
|
||||
import * as SqliteNode from "@effect/sql-sqlite-node"
|
||||
import { describe, expect, it } from "@effect/vitest"
|
||||
import * as Effect from "effect/Effect"
|
||||
import * as Layer from "effect/Layer"
|
||||
import * as Stream from "effect/Stream"
|
||||
import * as FileSystem from "node:fs"
|
||||
import * as OS from "node:os"
|
||||
import * as NodePath from "node:path"
|
||||
import {
|
||||
HttpBody,
|
||||
HttpClient,
|
||||
HttpClientResponse,
|
||||
HttpServer,
|
||||
HttpRouter
|
||||
} from "effect/unstable/http"
|
||||
import * as SqlClient from "effect/unstable/sql/SqlClient"
|
||||
import { ServerConfig } from "../src/config.ts"
|
||||
import { MigrationsLive } from "../src/migrations.ts"
|
||||
import { ServerMessage } from "../src/messages.ts"
|
||||
import { withWsRpcClient } from "../src/client.ts"
|
||||
import { makeRoutesLayer } from "../src/server.ts"
|
||||
|
||||
const testServerConfig = {
|
||||
host: "127.0.0.1",
|
||||
port: 0,
|
||||
assetsDir: new URL("../../public", import.meta.url).pathname,
|
||||
dbFilename: ":memory:",
|
||||
requestLogging: false,
|
||||
frontendDevOrigin: undefined
|
||||
}
|
||||
|
||||
const AppUnderTest = HttpRouter.serve(
|
||||
makeRoutesLayer,
|
||||
{
|
||||
disableListenLog: true,
|
||||
disableLogger: true
|
||||
}
|
||||
)
|
||||
|
||||
const persistenceLayer = (dbFilename: string) => {
|
||||
const sqliteLayer = SqliteNode.SqliteClient.layer({ filename: dbFilename })
|
||||
return MigrationsLive.pipe(Layer.provideMerge(sqliteLayer))
|
||||
}
|
||||
|
||||
const appLayer = (dbFilename: string) =>
|
||||
AppUnderTest.pipe(Layer.provideMerge(persistenceLayer(dbFilename)))
|
||||
|
||||
const insertTodo = (dbFilename: string, id: string, title: string) =>
|
||||
Effect.scoped(
|
||||
Effect.flatMap(Effect.service(SqlClient.SqlClient), (sql) => {
|
||||
const now = new Date().toISOString()
|
||||
return sql.withTransaction(
|
||||
sql`
|
||||
INSERT INTO todos (id, title, completed, archived, revision, updated_at)
|
||||
VALUES (${id}, ${title}, 0, 0, 1, ${now})
|
||||
`.pipe(
|
||||
Effect.flatMap(() =>
|
||||
sql`
|
||||
INSERT INTO todo_events (at, todo_json, change_json, archived)
|
||||
VALUES (
|
||||
${now},
|
||||
${JSON.stringify({
|
||||
id,
|
||||
title,
|
||||
completed: false,
|
||||
archived: false,
|
||||
revision: 1,
|
||||
updatedAt: now
|
||||
})},
|
||||
${JSON.stringify({ _tag: "TodoCreated" })},
|
||||
0
|
||||
)
|
||||
`
|
||||
)
|
||||
)
|
||||
)
|
||||
}).pipe(
|
||||
Effect.provide(persistenceLayer(dbFilename))
|
||||
)
|
||||
)
|
||||
|
||||
describe("server", () => {
|
||||
it.effect("routes HTTP messages validated by Schema", () =>
|
||||
Effect.gen(function*() {
|
||||
yield* Layer.build(appLayer(testServerConfig.dbFilename)).pipe(
|
||||
Effect.provideService(ServerConfig, testServerConfig)
|
||||
)
|
||||
const client = yield* HttpClient.HttpClient
|
||||
const response = yield* client.post("/api/dispatch", {
|
||||
body: HttpBody.jsonUnsafe({ kind: "sum", left: 20, right: 22 })
|
||||
})
|
||||
|
||||
const parsed = yield* HttpClientResponse.schemaBodyJson(ServerMessage)(response)
|
||||
expect(parsed).toEqual({ kind: "sumResult", total: 42 })
|
||||
}).pipe(Effect.provide(NodeHttpServer.layerTest))
|
||||
)
|
||||
|
||||
it.effect("serves static files from local filesystem", () =>
|
||||
Effect.gen(function*() {
|
||||
yield* Layer.build(appLayer(testServerConfig.dbFilename)).pipe(
|
||||
Effect.provideService(ServerConfig, testServerConfig)
|
||||
)
|
||||
const text = yield* HttpClient.get("/").pipe(
|
||||
Effect.flatMap((response) => response.text)
|
||||
)
|
||||
|
||||
expect(text).toContain("effect-http-ws-cli")
|
||||
}).pipe(Effect.provide(NodeHttpServer.layerTest))
|
||||
)
|
||||
|
||||
it.effect("redirects frontend requests to the Vite dev server when enabled", () =>
|
||||
Effect.gen(function*() {
|
||||
yield* Layer.build(appLayer(testServerConfig.dbFilename)).pipe(
|
||||
Effect.provideService(ServerConfig, {
|
||||
...testServerConfig,
|
||||
frontendDevOrigin: "http://127.0.0.1:5173"
|
||||
})
|
||||
)
|
||||
|
||||
const server = yield* HttpServer.HttpServer
|
||||
const address = server.address as HttpServer.TcpAddress
|
||||
const response = yield* Effect.promise(() =>
|
||||
fetch(`http://127.0.0.1:${address.port}/todos?filter=active`, {
|
||||
redirect: "manual"
|
||||
})
|
||||
)
|
||||
|
||||
expect(response.status).toBe(307)
|
||||
expect(response.headers.get("location")).toBe("http://127.0.0.1:5173/todos?filter=active")
|
||||
}).pipe(Effect.provide(NodeHttpServer.layerTest))
|
||||
)
|
||||
|
||||
it.effect("routes WebSocket RPC messages with shared contracts", () =>
|
||||
Effect.gen(function*() {
|
||||
yield* Layer.build(appLayer(testServerConfig.dbFilename)).pipe(
|
||||
Effect.provideService(ServerConfig, testServerConfig)
|
||||
)
|
||||
const server = yield* HttpServer.HttpServer
|
||||
const address = server.address as HttpServer.TcpAddress
|
||||
const wsUrl = `ws://127.0.0.1:${address.port}/ws`
|
||||
|
||||
const response = yield* Effect.scoped(
|
||||
withWsRpcClient(wsUrl, (client) => client.echo({ text: "hello from ws" }))
|
||||
)
|
||||
|
||||
expect(response).toEqual({ text: "hello from ws" })
|
||||
}).pipe(Effect.provide(NodeHttpServer.layerTest))
|
||||
)
|
||||
|
||||
it.effect("routes WebSocket RPC calls for multiple procedures", () =>
|
||||
Effect.gen(function*() {
|
||||
yield* Layer.build(appLayer(testServerConfig.dbFilename)).pipe(
|
||||
Effect.provideService(ServerConfig, testServerConfig)
|
||||
)
|
||||
const server = yield* HttpServer.HttpServer
|
||||
const address = server.address as HttpServer.TcpAddress
|
||||
const wsUrl = `ws://127.0.0.1:${address.port}/ws`
|
||||
|
||||
const result = yield* Effect.scoped(
|
||||
withWsRpcClient(wsUrl, (client) =>
|
||||
Effect.all({
|
||||
sum: client.sum({ left: 1, right: 2 }),
|
||||
time: client.time(undefined)
|
||||
})
|
||||
)
|
||||
)
|
||||
|
||||
expect(result.sum).toEqual({ total: 3 })
|
||||
expect(typeof result.time.iso).toBe("string")
|
||||
}).pipe(Effect.provide(NodeHttpServer.layerTest))
|
||||
)
|
||||
|
||||
it.effect("lists todos and streams todo updates from offset", () =>
|
||||
Effect.gen(function*() {
|
||||
const dbFilename = NodePath.join(
|
||||
OS.tmpdir(),
|
||||
`effect-http-ws-cli-stream-${Date.now()}-${Math.random().toString(16).slice(2)}.sqlite`
|
||||
)
|
||||
|
||||
yield* insertTodo(dbFilename, "todo-stream-test", "stream-seed")
|
||||
|
||||
const events = yield* Effect.scoped(
|
||||
Effect.gen(function*() {
|
||||
yield* Layer.build(appLayer(dbFilename)).pipe(
|
||||
Effect.provideService(ServerConfig, {
|
||||
...testServerConfig,
|
||||
dbFilename
|
||||
})
|
||||
)
|
||||
const server = yield* HttpServer.HttpServer
|
||||
const address = server.address as HttpServer.TcpAddress
|
||||
const wsUrl = `ws://127.0.0.1:${address.port}/ws`
|
||||
|
||||
return yield* withWsRpcClient(wsUrl, (client) =>
|
||||
Effect.gen(function*() {
|
||||
const snapshot = yield* client.listTodos({ includeArchived: true })
|
||||
const firstTodo = snapshot.todos[0]
|
||||
if (!firstTodo) {
|
||||
return yield* Effect.die("Expected a todo fixture")
|
||||
}
|
||||
|
||||
yield* client.renameTodo({ id: firstTodo.id, title: "alpha" })
|
||||
yield* client.completeTodo({ id: firstTodo.id, completed: true })
|
||||
yield* client.archiveTodo({ id: firstTodo.id, archived: true })
|
||||
|
||||
return yield* client.subscribeTodos({
|
||||
fromOffset: snapshot.offset,
|
||||
includeArchived: true
|
||||
}).pipe(
|
||||
Stream.take(3),
|
||||
Stream.runCollect
|
||||
)
|
||||
})
|
||||
)
|
||||
})
|
||||
).pipe(
|
||||
Effect.ensuring(
|
||||
Effect.sync(() => {
|
||||
try {
|
||||
FileSystem.rmSync(dbFilename, { force: true })
|
||||
} catch {
|
||||
// ignore cleanup failures in tests
|
||||
}
|
||||
})
|
||||
)
|
||||
)
|
||||
|
||||
expect(events).toHaveLength(3)
|
||||
expect(events[0]?.change).toEqual({ _tag: "TodoRenamed", title: "alpha" })
|
||||
expect(events[1]?.change).toEqual({ _tag: "TodoCompleted", completed: true })
|
||||
expect(events[2]?.change).toEqual({ _tag: "TodoArchived", archived: true })
|
||||
expect(events[0]?.todo.title).toBe("alpha")
|
||||
expect(events[1]?.todo.completed).toBe(true)
|
||||
expect(events[2]?.todo.archived).toBe(true)
|
||||
}).pipe(Effect.provide(NodeHttpServer.layerTest))
|
||||
)
|
||||
|
||||
it.effect("persists todos across server restarts when using a file database", () =>
|
||||
Effect.gen(function*() {
|
||||
const dbFilename = NodePath.join(
|
||||
OS.tmpdir(),
|
||||
`effect-http-ws-cli-${Date.now()}-${Math.random().toString(16).slice(2)}.sqlite`
|
||||
)
|
||||
|
||||
yield* insertTodo(dbFilename, "todo-persist-test", "persist-seed")
|
||||
|
||||
const withServer = <A, E, R>(f: (wsUrl: string) => Effect.Effect<A, E, R>) =>
|
||||
Effect.scoped(
|
||||
Effect.gen(function*() {
|
||||
yield* Layer.build(appLayer(dbFilename)).pipe(
|
||||
Effect.provideService(ServerConfig, {
|
||||
...testServerConfig,
|
||||
dbFilename
|
||||
})
|
||||
)
|
||||
|
||||
const server = yield* HttpServer.HttpServer
|
||||
const address = server.address as HttpServer.TcpAddress
|
||||
const wsUrl = `ws://127.0.0.1:${address.port}/ws`
|
||||
return yield* f(wsUrl)
|
||||
})
|
||||
)
|
||||
|
||||
const renamedTodoId = yield* withServer((wsUrl) =>
|
||||
Effect.scoped(
|
||||
withWsRpcClient(wsUrl, (client) =>
|
||||
Effect.gen(function*() {
|
||||
const snapshot = yield* client.listTodos({ includeArchived: true })
|
||||
const firstTodo = snapshot.todos[0]
|
||||
if (!firstTodo) {
|
||||
return yield* Effect.die("Expected a todo fixture")
|
||||
}
|
||||
|
||||
yield* client.renameTodo({ id: firstTodo.id, title: "persisted-title" })
|
||||
return firstTodo.id
|
||||
})
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
const persistedTitle = yield* withServer((wsUrl) =>
|
||||
Effect.scoped(
|
||||
withWsRpcClient(wsUrl, (client) =>
|
||||
Effect.gen(function*() {
|
||||
const snapshot = yield* client.listTodos({ includeArchived: true })
|
||||
const persisted = snapshot.todos.find((todo) => todo.id === renamedTodoId)
|
||||
if (!persisted) {
|
||||
return yield* Effect.die("Expected persisted todo")
|
||||
}
|
||||
return persisted.title
|
||||
})
|
||||
)
|
||||
)
|
||||
).pipe(
|
||||
Effect.ensuring(
|
||||
Effect.sync(() => {
|
||||
try {
|
||||
FileSystem.rmSync(dbFilename, { force: true })
|
||||
} catch {
|
||||
// ignore cleanup failures in tests
|
||||
}
|
||||
})
|
||||
)
|
||||
)
|
||||
|
||||
expect(persistedTitle).toBe("persisted-title")
|
||||
}).pipe(Effect.provide(NodeHttpServer.layerTest))
|
||||
)
|
||||
})
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"include": ["src", "test", "vitest.config.ts"]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import { defineConfig } from "vitest/config"
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
include: ["test/**/*.test.ts"],
|
||||
environment: "node"
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"allowImportingTsExtensions": true,
|
||||
"rewriteRelativeImportExtensions": true,
|
||||
"erasableSyntaxOnly": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"noEmit": true,
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"skipLibCheck": true,
|
||||
"resolveJsonModule": true,
|
||||
"types": ["node", "vitest/globals"]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>effect-http-ws-cli rpc console</title>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||
<link href="https://fonts.googleapis.com/css2?family=Archivo+Black&family=IBM+Plex+Sans:wght@400;500;700&display=swap" rel="stylesheet" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "@effect-http-ws-cli/web",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"test": "vitest run",
|
||||
"lint": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@effect-http-ws-cli/server": "workspace:*",
|
||||
"@effect/atom-react": "catalog:",
|
||||
"@tanstack/react-router": "^1.166.2",
|
||||
"effect": "catalog:",
|
||||
"react": "^19.2.0",
|
||||
"react-dom": "^19.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tanstack/router-plugin": "^1.166.2",
|
||||
"@types/react": "^19.2.7",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@vitejs/plugin-react": "^5.1.1",
|
||||
"@vitest/browser-playwright": "^4.0.18",
|
||||
"playwright": "^1.58.2",
|
||||
"typescript": "catalog:",
|
||||
"vite": "^7.2.0",
|
||||
"vitest": "catalog:",
|
||||
"vitest-browser-react": "^2.0.5"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { StrictMode } from "react"
|
||||
import { createRoot } from "react-dom/client"
|
||||
import { RegistryProvider } from "@effect/atom-react"
|
||||
import { createBrowserHistory, RouterProvider } from "@tanstack/react-router"
|
||||
import { getRouter } from "./router"
|
||||
import "./styles.css"
|
||||
|
||||
const history = createBrowserHistory()
|
||||
const router = getRouter(history)
|
||||
|
||||
createRoot(document.getElementById("root")!).render(
|
||||
<StrictMode>
|
||||
<RegistryProvider>
|
||||
<RouterProvider router={router} />
|
||||
</RegistryProvider>
|
||||
</StrictMode>
|
||||
)
|
||||
@@ -0,0 +1,59 @@
|
||||
/* eslint-disable */
|
||||
|
||||
// @ts-nocheck
|
||||
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
|
||||
// This file was automatically generated by TanStack Router.
|
||||
// You should NOT make any changes in this file as it will be overwritten.
|
||||
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
|
||||
|
||||
import { Route as rootRouteImport } from './routes/__root'
|
||||
import { Route as IndexRouteImport } from './routes/index'
|
||||
|
||||
const IndexRoute = IndexRouteImport.update({
|
||||
id: '/',
|
||||
path: '/',
|
||||
getParentRoute: () => rootRouteImport,
|
||||
} as any)
|
||||
|
||||
export interface FileRoutesByFullPath {
|
||||
'/': typeof IndexRoute
|
||||
}
|
||||
export interface FileRoutesByTo {
|
||||
'/': typeof IndexRoute
|
||||
}
|
||||
export interface FileRoutesById {
|
||||
__root__: typeof rootRouteImport
|
||||
'/': typeof IndexRoute
|
||||
}
|
||||
export interface FileRouteTypes {
|
||||
fileRoutesByFullPath: FileRoutesByFullPath
|
||||
fullPaths: '/'
|
||||
fileRoutesByTo: FileRoutesByTo
|
||||
to: '/'
|
||||
id: '__root__' | '/'
|
||||
fileRoutesById: FileRoutesById
|
||||
}
|
||||
export interface RootRouteChildren {
|
||||
IndexRoute: typeof IndexRoute
|
||||
}
|
||||
|
||||
declare module '@tanstack/react-router' {
|
||||
interface FileRoutesByPath {
|
||||
'/': {
|
||||
id: '/'
|
||||
path: '/'
|
||||
fullPath: '/'
|
||||
preLoaderRoute: typeof IndexRouteImport
|
||||
parentRoute: typeof rootRouteImport
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const rootRouteChildren: RootRouteChildren = {
|
||||
IndexRoute: IndexRoute,
|
||||
}
|
||||
export const routeTree = rootRouteImport
|
||||
._addFileChildren(rootRouteChildren)
|
||||
._addFileTypes<FileRouteTypes>()
|
||||
@@ -0,0 +1,15 @@
|
||||
import { createRouter, type RouterHistory } from "@tanstack/react-router"
|
||||
import { routeTree } from "./routeTree.gen"
|
||||
|
||||
export const getRouter = (history: RouterHistory) =>
|
||||
createRouter({
|
||||
routeTree,
|
||||
history
|
||||
})
|
||||
|
||||
|
||||
declare module "@tanstack/react-router" {
|
||||
interface Register {
|
||||
router: ReturnType<typeof getRouter>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { Outlet, createRootRoute } from "@tanstack/react-router"
|
||||
|
||||
export const Route = createRootRoute({
|
||||
component: Outlet
|
||||
})
|
||||
@@ -0,0 +1,460 @@
|
||||
import { createFileRoute } from "@tanstack/react-router"
|
||||
|
||||
|
||||
|
||||
import { useEffect, useRef } from "react"
|
||||
import * as Cause from "effect/Cause"
|
||||
import * as AsyncResult from "effect/unstable/reactivity/AsyncResult"
|
||||
import { useAtomRefresh, useAtomSet, useAtomValue } from "@effect/atom-react"
|
||||
import type { Todo, TodoEvent, TodoChange } from "@effect-http-ws-cli/server/contracts"
|
||||
import {
|
||||
archiveTodoMutationAtom,
|
||||
completeTodoMutationAtom,
|
||||
renameTodoMutationAtom,
|
||||
subscribeTodosPullAtom,
|
||||
todosSnapshotAtom
|
||||
} from "../rpc"
|
||||
import {
|
||||
connectionAtom,
|
||||
eventsAtom,
|
||||
mutationBusyAtom,
|
||||
todoProjectionAtom
|
||||
} from "../state"
|
||||
|
||||
const reconnectBaseMs = 1_250
|
||||
const reconnectMaxMs = 20_000
|
||||
const maxReconnectAttempts = 8
|
||||
|
||||
|
||||
|
||||
export const Route = createFileRoute("/")({
|
||||
component: IndexRoute
|
||||
})
|
||||
|
||||
function IndexRoute() {
|
||||
const setProjection = useAtomSet(todoProjectionAtom)
|
||||
const setEvents = useAtomSet(eventsAtom)
|
||||
const setConnection = useAtomSet(connectionAtom)
|
||||
const setBusy = useAtomSet(mutationBusyAtom)
|
||||
|
||||
const snapshotResult = useAtomValue(todosSnapshotAtom)
|
||||
const subscriptionPullResult = useAtomValue(subscribeTodosPullAtom)
|
||||
const pullSubscription = useAtomSet(subscribeTodosPullAtom)
|
||||
const refreshSubscription = useAtomRefresh(subscribeTodosPullAtom)
|
||||
|
||||
const seenOffsetsRef = useRef<Set<number>>(new Set())
|
||||
const baselineOffsetRef = useRef(0)
|
||||
const hasInitializedRef = useRef(false)
|
||||
const hasStartedSubscriptionRef = useRef(false)
|
||||
const brokenSubscriptionRef = useRef(false)
|
||||
|
||||
const reconnectAttemptsRef = useRef(0)
|
||||
const reconnectTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null)
|
||||
|
||||
const clearReconnectTimer = () => {
|
||||
if (reconnectTimerRef.current !== null) {
|
||||
clearTimeout(reconnectTimerRef.current)
|
||||
reconnectTimerRef.current = null
|
||||
}
|
||||
}
|
||||
|
||||
const startSubscriptionPull = () => {
|
||||
clearReconnectTimer()
|
||||
if (!hasStartedSubscriptionRef.current) {
|
||||
hasStartedSubscriptionRef.current = true
|
||||
}
|
||||
setConnection((current) => ({ ...current, subscriptionState: "connecting" }))
|
||||
refreshSubscription()
|
||||
pullSubscription(undefined)
|
||||
}
|
||||
|
||||
const scheduleReconnect = (lastError: string) => {
|
||||
brokenSubscriptionRef.current = true
|
||||
reconnectAttemptsRef.current += 1
|
||||
|
||||
if (reconnectAttemptsRef.current > maxReconnectAttempts) {
|
||||
setConnection((current) => ({
|
||||
...current,
|
||||
lastError,
|
||||
subscriptionState: "idle"
|
||||
}))
|
||||
return
|
||||
}
|
||||
|
||||
const delayMs = Math.min(
|
||||
reconnectBaseMs * 2 ** Math.max(0, reconnectAttemptsRef.current - 1),
|
||||
reconnectMaxMs
|
||||
)
|
||||
|
||||
setConnection((current) => ({
|
||||
...current,
|
||||
lastError,
|
||||
subscriptionState: "connecting"
|
||||
}))
|
||||
|
||||
clearReconnectTimer()
|
||||
reconnectTimerRef.current = setTimeout(() => {
|
||||
reconnectTimerRef.current = null
|
||||
startSubscriptionPull()
|
||||
}, delayMs)
|
||||
}
|
||||
|
||||
const addEvent = (event: TodoEvent): boolean => {
|
||||
if (event.offset <= baselineOffsetRef.current) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (seenOffsetsRef.current.has(event.offset)) {
|
||||
return false
|
||||
}
|
||||
|
||||
seenOffsetsRef.current.add(event.offset)
|
||||
setEvents((events) => [...events, event])
|
||||
return true
|
||||
}
|
||||
|
||||
const applyEvent = (event: TodoEvent) => {
|
||||
setProjection((current) => ({
|
||||
...current,
|
||||
lastOffset: Math.max(current.lastOffset, event.offset),
|
||||
todos: sortTodos(
|
||||
current.todos.some((todo) => todo.id === event.todo.id)
|
||||
? current.todos.map((todo) => (todo.id === event.todo.id ? event.todo : todo))
|
||||
: [...current.todos, event.todo]
|
||||
),
|
||||
titleDrafts: {
|
||||
...current.titleDrafts,
|
||||
[event.todo.id]: event.todo.title
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
const applyTodoEvent = (event: TodoEvent) => {
|
||||
const isNew = addEvent(event)
|
||||
if (isNew) {
|
||||
applyEvent(event)
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (AsyncResult.isInitial(snapshotResult)) {
|
||||
return
|
||||
}
|
||||
|
||||
if (AsyncResult.isFailure(snapshotResult)) {
|
||||
scheduleReconnect(Cause.pretty(snapshotResult.cause))
|
||||
return
|
||||
}
|
||||
|
||||
const snapshot = snapshotResult.value
|
||||
|
||||
setProjection({
|
||||
todos: sortTodos(snapshot.todos),
|
||||
lastOffset: snapshot.offset,
|
||||
titleDrafts: Object.fromEntries(snapshot.todos.map((todo) => [todo.id, todo.title]))
|
||||
})
|
||||
|
||||
if (!hasInitializedRef.current) {
|
||||
hasInitializedRef.current = true
|
||||
baselineOffsetRef.current = snapshot.offset
|
||||
seenOffsetsRef.current = new Set()
|
||||
setEvents([])
|
||||
startSubscriptionPull()
|
||||
}
|
||||
}, [snapshotResult, setEvents, setProjection])
|
||||
|
||||
useEffect(() => {
|
||||
if (!hasStartedSubscriptionRef.current) {
|
||||
return
|
||||
}
|
||||
|
||||
if (AsyncResult.isInitial(subscriptionPullResult)) {
|
||||
setConnection((current) => ({
|
||||
...current,
|
||||
subscriptionState: subscriptionPullResult.waiting ? "connected" : "connecting"
|
||||
}))
|
||||
return
|
||||
}
|
||||
|
||||
if (AsyncResult.isFailure(subscriptionPullResult)) {
|
||||
scheduleReconnect(Cause.pretty(subscriptionPullResult.cause))
|
||||
return
|
||||
}
|
||||
|
||||
reconnectAttemptsRef.current = 0
|
||||
brokenSubscriptionRef.current = false
|
||||
|
||||
setConnection((current) => ({
|
||||
...current,
|
||||
lastError: null,
|
||||
subscriptionState: "connected"
|
||||
}))
|
||||
|
||||
for (const event of subscriptionPullResult.value.items) {
|
||||
applyTodoEvent(event)
|
||||
}
|
||||
|
||||
if (!subscriptionPullResult.value.done && !subscriptionPullResult.waiting) {
|
||||
pullSubscription(undefined)
|
||||
}
|
||||
}, [pullSubscription, setConnection, subscriptionPullResult])
|
||||
|
||||
useEffect(() => {
|
||||
const reconnectOnFocus = () => {
|
||||
if (document.visibilityState !== "visible") {
|
||||
return
|
||||
}
|
||||
|
||||
if (!brokenSubscriptionRef.current) {
|
||||
return
|
||||
}
|
||||
|
||||
reconnectAttemptsRef.current = 0
|
||||
startSubscriptionPull()
|
||||
}
|
||||
|
||||
window.addEventListener("focus", reconnectOnFocus)
|
||||
document.addEventListener("visibilitychange", reconnectOnFocus)
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("focus", reconnectOnFocus)
|
||||
document.removeEventListener("visibilitychange", reconnectOnFocus)
|
||||
}
|
||||
}, [setConnection])
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
clearReconnectTimer()
|
||||
}
|
||||
}, [])
|
||||
|
||||
const runMutation: MutationRunner = (label, run, onSuccess) => {
|
||||
setBusy(label)
|
||||
setConnection((current) => ({ ...current, lastError: null }))
|
||||
|
||||
void run().then(
|
||||
(value) => {
|
||||
onSuccess(value)
|
||||
},
|
||||
(error) => {
|
||||
setConnection((current) => ({ ...current, lastError: Cause.pretty(error) }))
|
||||
}
|
||||
).finally(() => {
|
||||
setBusy(null)
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<main className="shell">
|
||||
<Status />
|
||||
|
||||
<section className="hero">
|
||||
<p className="eyebrow">effect-http-ws-cli</p>
|
||||
<h1>Realtime Todo Stream</h1>
|
||||
<p className="lead">
|
||||
Snapshot on load, then live updates over typed WebSocket RPC subscriptions.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<TodoPanel runMutation={runMutation} applyTodoEvent={applyTodoEvent} />
|
||||
<EventList />
|
||||
<Footer />
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
type MutationRunner = <A>(
|
||||
label: string,
|
||||
run: () => Promise<A>,
|
||||
onSuccess: (value: A) => void
|
||||
) => void
|
||||
|
||||
const sortTodos = (todos: ReadonlyArray<Todo>): ReadonlyArray<Todo> =>
|
||||
[...todos].sort((a, b) => {
|
||||
if (a.archived !== b.archived) return a.archived ? 1 : -1
|
||||
if (a.completed !== b.completed) return a.completed ? 1 : -1
|
||||
return a.id.localeCompare(b.id)
|
||||
})
|
||||
|
||||
const describeChange = (change: TodoChange): string => {
|
||||
switch (change._tag) {
|
||||
case "TodoCreated":
|
||||
return "created"
|
||||
case "TodoRenamed":
|
||||
return `renamed to "${change.title}"`
|
||||
case "TodoCompleted":
|
||||
return change.completed ? "completed" : "marked incomplete"
|
||||
case "TodoArchived":
|
||||
return change.archived ? "archived" : "unarchived"
|
||||
}
|
||||
}
|
||||
|
||||
const Status = () => {
|
||||
const connection = useAtomValue(connectionAtom)
|
||||
const busy = useAtomValue(mutationBusyAtom)
|
||||
|
||||
return (
|
||||
<section className="panel status-panel">
|
||||
<div className="status-grid">
|
||||
<div className={`status-item status-subscription-${connection.subscriptionState}`}>
|
||||
<span className="status-label">Subscription</span>
|
||||
<strong>{connection.subscriptionState}</strong>
|
||||
</div>
|
||||
<div className={`status-item ${busy ? "status-mutation-busy" : "status-mutation-idle"}`}>
|
||||
<span className="status-label">Mutation</span>
|
||||
<strong>{busy ? busy : "idle"}</strong>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
const TodoPanel = (props: {
|
||||
readonly runMutation: MutationRunner
|
||||
readonly applyTodoEvent: (event: TodoEvent) => void
|
||||
}) => {
|
||||
const projection = useAtomValue(todoProjectionAtom)
|
||||
const connection = useAtomValue(connectionAtom)
|
||||
const setProjection = useAtomSet(todoProjectionAtom)
|
||||
const renameTodo = useAtomSet(renameTodoMutationAtom, { mode: "promise" })
|
||||
const completeTodo = useAtomSet(completeTodoMutationAtom, { mode: "promise" })
|
||||
const archiveTodo = useAtomSet(archiveTodoMutationAtom, { mode: "promise" })
|
||||
|
||||
return (
|
||||
<section className="panel todo-panel">
|
||||
<header className="todo-header">
|
||||
<h2>Todos</h2>
|
||||
<div className="meta">
|
||||
<span>offset #{projection.lastOffset}</span>
|
||||
<span>subscription: {connection.subscriptionState}</span>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<ul className="todo-list">
|
||||
{projection.todos.map((todo) => (
|
||||
<li
|
||||
key={todo.id}
|
||||
className={`todo-item${todo.completed ? " is-completed" : ""}${todo.archived ? " is-archived" : ""}`}
|
||||
>
|
||||
<div className="todo-main">
|
||||
<input
|
||||
value={projection.titleDrafts[todo.id] ?? todo.title}
|
||||
onChange={(event) => {
|
||||
setProjection((current) => ({
|
||||
...current,
|
||||
titleDrafts: {
|
||||
...current.titleDrafts,
|
||||
[todo.id]: event.target.value
|
||||
}
|
||||
}))
|
||||
}}
|
||||
/>
|
||||
<small>
|
||||
rev {todo.revision} · {new Date(todo.updatedAt).toLocaleTimeString()}
|
||||
</small>
|
||||
</div>
|
||||
<div className="todo-actions">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() =>
|
||||
props.runMutation(
|
||||
`rename:${todo.id}`,
|
||||
() =>
|
||||
renameTodo({
|
||||
payload: {
|
||||
id: todo.id,
|
||||
title: projection.titleDrafts[todo.id] ?? todo.title
|
||||
}
|
||||
}),
|
||||
props.applyTodoEvent
|
||||
)
|
||||
}
|
||||
>
|
||||
Rename
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() =>
|
||||
props.runMutation(
|
||||
`complete:${todo.id}`,
|
||||
() =>
|
||||
completeTodo({
|
||||
payload: {
|
||||
id: todo.id,
|
||||
completed: !todo.completed
|
||||
}
|
||||
}),
|
||||
props.applyTodoEvent
|
||||
)
|
||||
}
|
||||
>
|
||||
{todo.completed ? "Undo" : "Complete"}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() =>
|
||||
props.runMutation(
|
||||
`archive:${todo.id}`,
|
||||
() =>
|
||||
archiveTodo({
|
||||
payload: {
|
||||
id: todo.id,
|
||||
archived: !todo.archived
|
||||
}
|
||||
}),
|
||||
props.applyTodoEvent
|
||||
)
|
||||
}
|
||||
>
|
||||
{todo.archived ? "Unarchive" : "Archive"}
|
||||
</button>
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
const EventList = () => {
|
||||
const events = useAtomValue(eventsAtom)
|
||||
|
||||
return (
|
||||
<section className="panel event-panel">
|
||||
<header className="todo-header">
|
||||
<h2>Events</h2>
|
||||
<div className="meta">
|
||||
<span>{events.length} total</span>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<ul className="event-list">
|
||||
{[...events].reverse().map((event) => (
|
||||
<li key={event.offset} className="event-item">
|
||||
<div className="event-top">
|
||||
<strong>#{event.offset}</strong>
|
||||
<span>{new Date(event.at).toLocaleTimeString()}</span>
|
||||
</div>
|
||||
<div className="event-body">
|
||||
<span>{event.todo.title}</span>
|
||||
<small>{describeChange(event.change)}</small>
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
const Footer = () => {
|
||||
const connection = useAtomValue(connectionAtom)
|
||||
|
||||
return (
|
||||
<footer className="footer">
|
||||
{connection.lastError ? <span className="error">{connection.lastError}</span> : <span>no errors</span>}
|
||||
</footer>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import * as Layer from "effect/Layer"
|
||||
import * as RpcClient from "effect/unstable/rpc/RpcClient"
|
||||
import * as RpcSerialization from "effect/unstable/rpc/RpcSerialization"
|
||||
import * as AtomRpc from "effect/unstable/reactivity/AtomRpc"
|
||||
import * as Socket from "effect/unstable/socket/Socket"
|
||||
import { WsRpcGroup } from "@effect-http-ws-cli/server/contracts"
|
||||
|
||||
const wsUrl = () => {
|
||||
const protocol = window.location.protocol === "https:" ? "wss" : "ws"
|
||||
return `${protocol}://${window.location.host}/ws`
|
||||
}
|
||||
|
||||
const protocolLayer = RpcClient.layerProtocolSocket({
|
||||
retryTransientErrors: true
|
||||
}).pipe(
|
||||
Layer.provide(Socket.layerWebSocket(wsUrl())),
|
||||
Layer.provide(Socket.layerWebSocketConstructorGlobal),
|
||||
Layer.provide(RpcSerialization.layerJson)
|
||||
)
|
||||
|
||||
export class TodoRpcClient extends AtomRpc.Service<TodoRpcClient>()("TodoRpcClient", {
|
||||
group: WsRpcGroup,
|
||||
protocol: protocolLayer
|
||||
}) {}
|
||||
|
||||
export const todosSnapshotAtom = TodoRpcClient.query(
|
||||
"listTodos",
|
||||
{ includeArchived: true }
|
||||
)
|
||||
|
||||
export const subscribeTodosPullAtom = TodoRpcClient.query(
|
||||
"subscribeTodos",
|
||||
{
|
||||
fromOffset: 0,
|
||||
includeArchived: true
|
||||
}
|
||||
)
|
||||
|
||||
export const renameTodoMutationAtom = TodoRpcClient.mutation("renameTodo")
|
||||
export const completeTodoMutationAtom = TodoRpcClient.mutation("completeTodo")
|
||||
export const archiveTodoMutationAtom = TodoRpcClient.mutation("archiveTodo")
|
||||
@@ -0,0 +1,34 @@
|
||||
import * as Atom from "effect/unstable/reactivity/Atom"
|
||||
import type { Todo, TodoEvent } from "@effect-http-ws-cli/server/contracts"
|
||||
|
||||
export type SubscriptionState = "connecting" | "connected" | "idle"
|
||||
|
||||
export interface TodoProjectionState {
|
||||
readonly todos: ReadonlyArray<Todo>
|
||||
readonly titleDrafts: Readonly<Record<string, string>>
|
||||
readonly lastOffset: number
|
||||
}
|
||||
|
||||
export interface ConnectionState {
|
||||
readonly subscriptionState: SubscriptionState
|
||||
readonly lastError: string | null
|
||||
}
|
||||
|
||||
export const todoProjectionAtom = Atom.make<TodoProjectionState>({
|
||||
todos: [],
|
||||
titleDrafts: {},
|
||||
lastOffset: 0
|
||||
}).pipe(Atom.withLabel("todo-projection"))
|
||||
|
||||
export const eventsAtom = Atom.make<ReadonlyArray<TodoEvent>>([]).pipe(
|
||||
Atom.withLabel("events")
|
||||
)
|
||||
|
||||
export const connectionAtom = Atom.make<ConnectionState>({
|
||||
subscriptionState: "idle",
|
||||
lastError: null
|
||||
}).pipe(Atom.withLabel("connection"))
|
||||
|
||||
export const mutationBusyAtom = Atom.make<string | null>(null).pipe(
|
||||
Atom.withLabel("mutation-busy")
|
||||
)
|
||||
@@ -0,0 +1,298 @@
|
||||
:root {
|
||||
--paper: #f3f0e8;
|
||||
--ink: #13222c;
|
||||
--ink-soft: #345264;
|
||||
--accent: #dc4f18;
|
||||
--accent-soft: #f8bb68;
|
||||
--panel: #fffdf6;
|
||||
--line: #162f3f22;
|
||||
--shadow: 0 16px 40px #0f1e291f;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
min-height: 100vh;
|
||||
font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
|
||||
color: var(--ink);
|
||||
background:
|
||||
radial-gradient(circle at 10% 10%, #f7cf9a 0%, transparent 36%),
|
||||
radial-gradient(circle at 92% 88%, #95c7d2 0%, transparent 32%),
|
||||
linear-gradient(165deg, #ece8dc 0%, var(--paper) 48%, #e9dfcf 100%);
|
||||
}
|
||||
|
||||
.shell {
|
||||
width: min(1100px, 100% - 2rem);
|
||||
margin: 1.5rem auto;
|
||||
padding: 1.5rem;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 20px;
|
||||
background: color-mix(in oklab, var(--paper), white 35%);
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
|
||||
.hero {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
padding: 1.5rem;
|
||||
border-radius: 16px;
|
||||
border: 1px solid var(--line);
|
||||
background: linear-gradient(140deg, #fff9ed 0%, #f7efe0 65%, #f2e7d4 100%);
|
||||
}
|
||||
|
||||
.hero::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
width: 220px;
|
||||
height: 220px;
|
||||
right: -60px;
|
||||
top: -90px;
|
||||
border-radius: 999px;
|
||||
background: linear-gradient(180deg, var(--accent-soft), transparent 70%);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.eyebrow {
|
||||
margin: 0;
|
||||
font-size: 0.72rem;
|
||||
letter-spacing: 0.22em;
|
||||
text-transform: uppercase;
|
||||
color: var(--ink-soft);
|
||||
}
|
||||
|
||||
h1,
|
||||
h2 {
|
||||
font-family: "Archivo Black", Impact, sans-serif;
|
||||
letter-spacing: 0.02em;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin-top: 0.35rem;
|
||||
font-size: clamp(1.5rem, 4vw, 2.35rem);
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
.lead {
|
||||
margin: 0.6rem 0 0;
|
||||
color: var(--ink-soft);
|
||||
max-width: 68ch;
|
||||
}
|
||||
|
||||
.panel {
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 14px;
|
||||
padding: 1rem;
|
||||
background: var(--panel);
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.status-panel {
|
||||
margin-top: 0;
|
||||
background: linear-gradient(140deg, #fbf7ee, #f1e8d7);
|
||||
}
|
||||
|
||||
.status-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 0.7rem;
|
||||
}
|
||||
|
||||
.status-item {
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 10px;
|
||||
padding: 0.55rem 0.7rem;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: baseline;
|
||||
gap: 0.75rem;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.status-label {
|
||||
color: var(--ink-soft);
|
||||
font-size: 0.82rem;
|
||||
}
|
||||
|
||||
.status-subscription-connected {
|
||||
border-color: #24704755;
|
||||
background: #f1fbf5;
|
||||
}
|
||||
|
||||
.status-subscription-connecting {
|
||||
border-color: #8d6a1b55;
|
||||
background: #fff8eb;
|
||||
}
|
||||
|
||||
.status-subscription-idle {
|
||||
border-color: var(--line);
|
||||
}
|
||||
|
||||
.status-mutation-busy {
|
||||
border-color: #6b3b2e55;
|
||||
background: #fff3ef;
|
||||
}
|
||||
|
||||
.todo-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: baseline;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.meta {
|
||||
display: flex;
|
||||
gap: 0.75rem;
|
||||
color: var(--ink-soft);
|
||||
font-size: 0.86rem;
|
||||
}
|
||||
|
||||
.todo-list {
|
||||
margin: 0.8rem 0 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
display: grid;
|
||||
gap: 0.6rem;
|
||||
}
|
||||
|
||||
.event-list {
|
||||
margin: 0.8rem 0 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
display: grid;
|
||||
gap: 0.5rem;
|
||||
max-height: 260px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.event-item {
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 10px;
|
||||
background: #fff;
|
||||
padding: 0.55rem 0.65rem;
|
||||
}
|
||||
|
||||
.event-top {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 0.6rem;
|
||||
color: var(--ink-soft);
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.event-body {
|
||||
margin-top: 0.2rem;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 0.75rem;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.event-body small {
|
||||
color: var(--ink-soft);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.todo-item {
|
||||
display: flex;
|
||||
gap: 0.8rem;
|
||||
align-items: center;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 10px;
|
||||
background: #fff;
|
||||
padding: 0.65rem;
|
||||
}
|
||||
|
||||
.todo-main {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.todo-main input {
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
border: 1px solid var(--line);
|
||||
background: #fff;
|
||||
border-radius: 8px;
|
||||
padding: 0.42rem 0.55rem;
|
||||
color: var(--ink);
|
||||
font: inherit;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.todo-main small {
|
||||
display: block;
|
||||
margin-top: 0.3rem;
|
||||
color: var(--ink-soft);
|
||||
}
|
||||
|
||||
.todo-actions {
|
||||
display: flex;
|
||||
gap: 0.45rem;
|
||||
}
|
||||
|
||||
button {
|
||||
border: 1px solid #0f243233;
|
||||
border-radius: 8px;
|
||||
background: linear-gradient(160deg, #fff, #f4efe3);
|
||||
color: var(--ink);
|
||||
padding: 0.4rem 0.6rem;
|
||||
font: inherit;
|
||||
font-size: 0.85rem;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
transition: transform 120ms ease, box-shadow 120ms ease;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 8px 18px #0f20321a;
|
||||
}
|
||||
|
||||
.todo-item.is-completed .todo-main input {
|
||||
text-decoration: line-through;
|
||||
color: var(--ink-soft);
|
||||
}
|
||||
|
||||
.todo-item.is-archived {
|
||||
opacity: 0.64;
|
||||
}
|
||||
|
||||
.footer {
|
||||
margin-top: 1rem;
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
align-items: center;
|
||||
font-size: 0.88rem;
|
||||
color: var(--ink-soft);
|
||||
}
|
||||
|
||||
.error {
|
||||
color: var(--accent);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
@media (max-width: 880px) {
|
||||
.shell {
|
||||
width: min(1100px, 100% - 1rem);
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.todo-item {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.todo-actions {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.status-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
import * as React from "react"
|
||||
import { RegistryProvider } from "@effect/atom-react"
|
||||
import * as AsyncResult from "effect/unstable/reactivity/AsyncResult"
|
||||
import * as Atom from "effect/unstable/reactivity/Atom"
|
||||
import { describe, expect, it, vi } from "vitest"
|
||||
import { render } from "vitest-browser-react"
|
||||
import { createMemoryHistory, RouterProvider } from "@tanstack/react-router"
|
||||
import { getRouter } from "../src/router"
|
||||
|
||||
vi.mock("../src/rpc.ts", () => {
|
||||
const initialSnapshot = AsyncResult.success({
|
||||
offset: 42,
|
||||
todos: [
|
||||
{
|
||||
id: "todo-1",
|
||||
title: "Harness Todo",
|
||||
completed: false,
|
||||
archived: false,
|
||||
revision: 1,
|
||||
updatedAt: "2026-03-05T00:00:00.000Z"
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
const noopSubscription = AsyncResult.initial<{
|
||||
readonly done: boolean
|
||||
readonly items: ReadonlyArray<unknown>
|
||||
}>(true)
|
||||
|
||||
const mutationResult = AsyncResult.success({
|
||||
offset: 43,
|
||||
at: "2026-03-05T00:00:01.000Z",
|
||||
todo: {
|
||||
id: "todo-1",
|
||||
title: "Harness Todo",
|
||||
completed: false,
|
||||
archived: false,
|
||||
revision: 1,
|
||||
updatedAt: "2026-03-05T00:00:01.000Z"
|
||||
},
|
||||
change: { _tag: "TodoRenamed", title: "Harness Todo" as const }
|
||||
})
|
||||
|
||||
return {
|
||||
todosSnapshotAtom: Atom.make(initialSnapshot),
|
||||
subscribeTodosPullAtom: Atom.writable(
|
||||
() => noopSubscription,
|
||||
() => {
|
||||
// no-op: smoke test doesn't exercise stream pulling
|
||||
}
|
||||
),
|
||||
renameTodoMutationAtom: Atom.make(mutationResult),
|
||||
completeTodoMutationAtom: Atom.make(mutationResult),
|
||||
archiveTodoMutationAtom: Atom.make(mutationResult)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
describe("web app harness", () => {
|
||||
it("renders App in browser mode", async () => {
|
||||
const history = createMemoryHistory()
|
||||
const router = getRouter(history)
|
||||
const screen = await render(
|
||||
<RegistryProvider>
|
||||
<RouterProvider router={router} />
|
||||
</RegistryProvider>
|
||||
)
|
||||
|
||||
await expect.element(screen.getByRole("heading", { name: "Realtime Todo Stream" })).toBeVisible()
|
||||
await expect.element(screen.getByRole("heading", { name: "Todos" })).toBeVisible()
|
||||
await expect.element(screen.getByRole("textbox")).toHaveValue("Harness Todo")
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Bundler",
|
||||
"jsx": "react-jsx",
|
||||
"strict": true,
|
||||
"noEmit": true,
|
||||
"allowImportingTsExtensions": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"types": ["vite/client"]
|
||||
},
|
||||
"include": ["src", "vite.config.ts", "vitest.config.ts"]
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import { defineConfig } from "vite"
|
||||
import react from "@vitejs/plugin-react"
|
||||
import { TanStackRouterVite } from "@tanstack/router-plugin/vite"
|
||||
|
||||
const backendOrigin = process.env.VITE_BACKEND_ORIGIN ?? "http://127.0.0.1:8787"
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [TanStackRouterVite(), react()],
|
||||
server: {
|
||||
proxy: {
|
||||
"/api": {
|
||||
target: backendOrigin,
|
||||
changeOrigin: true
|
||||
},
|
||||
"/health": {
|
||||
target: backendOrigin,
|
||||
changeOrigin: true
|
||||
},
|
||||
"/ws": {
|
||||
target: backendOrigin,
|
||||
changeOrigin: true,
|
||||
ws: true
|
||||
}
|
||||
}
|
||||
},
|
||||
build: {
|
||||
outDir: "../public",
|
||||
emptyOutDir: true
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,31 @@
|
||||
import { playwright } from "@vitest/browser-playwright"
|
||||
import react from "@vitejs/plugin-react"
|
||||
import { defineConfig } from "vitest/config"
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
optimizeDeps: {
|
||||
include: [
|
||||
"react",
|
||||
"react-dom",
|
||||
"react/jsx-dev-runtime",
|
||||
"@tanstack/react-router",
|
||||
"@effect/atom-react",
|
||||
"vitest-browser-react",
|
||||
"effect/unstable/reactivity/Atom",
|
||||
"effect/unstable/reactivity/AsyncResult"
|
||||
]
|
||||
},
|
||||
test: {
|
||||
include: ["test/**/*.browser.test.tsx"],
|
||||
browser: {
|
||||
enabled: true,
|
||||
provider: playwright(),
|
||||
instances: [
|
||||
{
|
||||
browser: "chromium"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
## Project Snapshot
|
||||
|
||||
T3 Code is a minimal web GUI for using coding agents like Codex and Claude.
|
||||
T3 Code is a minimal web GUI for using code agents like Codex and Claude Code (coming soon).
|
||||
|
||||
This repository is a VERY EARLY WIP. Proposing sweeping changes that improve long-term maintainability is encouraged.
|
||||
|
||||
@@ -21,7 +21,7 @@ If a tradeoff is required, choose correctness and robustness over short-term con
|
||||
|
||||
## Maintainability
|
||||
|
||||
Long term maintainability is a core priority. If you add new functionality, first check if there is shared logic that can be extracted to a separate module. Duplicate logic across multiple files is a code smell and should be avoided. Don't be afraid to change existing code. Don't take shortcuts by just adding local logic to solve a problem.
|
||||
Long term maintainability is a core priority. If you add new functionality, first check if there are shared logic that can be extracted to a separate module. Duplicate logic across mulitple files is a code smell and should be avoided. Don't be afraid to change existing code. Don't take shortcuts by just adding local logic to solve a problem.
|
||||
|
||||
## Package Roles
|
||||
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ You can still open an issue or PR, but please do so knowing there is a high chan
|
||||
|
||||
If that sounds annoying, that is because it is. This project is still early and we are trying to keep scope, quality, and direction under control.
|
||||
|
||||
PRs are automatically labeled with a `vouch:*` trust status and a `size:*` diff size based on changed lines.
|
||||
PRs are automatically labeled with a `vouch:*` trust status.
|
||||
|
||||
If you are an external contributor, expect `vouch:unvouched` until we explicitly add you to [.github/VOUCHED.td](.github/VOUCHED.td).
|
||||
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ Invalid rules are ignored. Invalid config files are ignored. Warnings are logged
|
||||
- `terminal.new`: create new terminal (in focused terminal context by default)
|
||||
- `terminal.close`: close/kill the focused terminal (in focused terminal context by default)
|
||||
- `chat.new`: create a new chat thread preserving the active thread's branch/worktree state
|
||||
- `chat.newLocal`: create a new chat thread for the active project in a new environment (local/worktree determined by app settings (default `local`))
|
||||
- `chat.newLocal`: create a new local chat thread for the active project (no worktree context)
|
||||
- `editor.openFavorite`: open current project/worktree in the last-used editor
|
||||
- `script.{id}.run`: run a project script by id (for example `script.test.run`)
|
||||
|
||||
|
||||
@@ -1,43 +1,19 @@
|
||||
# T3 Code
|
||||
|
||||
T3 Code is a minimal web GUI for coding agents (currently Codex and Claude, more coming soon).
|
||||
T3 Code is a minimal web GUI for coding agents. Currently Codex-first, with Claude Code support coming soon.
|
||||
|
||||
## Installation
|
||||
## How to use
|
||||
|
||||
> [!WARNING]
|
||||
> T3 Code currently supports Codex and Claude.
|
||||
> Install and authenticate at least one provider before use:
|
||||
>
|
||||
> - Codex: install [Codex CLI](https://github.com/openai/codex) and run `codex login`
|
||||
> - Claude: install Claude Code and run `claude auth login`
|
||||
|
||||
### Run without installing
|
||||
> You need to have [Codex CLI](https://github.com/openai/codex) installed and authorized for T3 Code to work.
|
||||
|
||||
```bash
|
||||
npx t3
|
||||
```
|
||||
|
||||
### Desktop app
|
||||
You can also just install the desktop app. It's cooler.
|
||||
|
||||
Install the latest version of the desktop app from [GitHub Releases](https://github.com/pingdotgg/t3code/releases), or from your favorite package registry:
|
||||
|
||||
#### Windows (`winget`)
|
||||
|
||||
```bash
|
||||
winget install T3Tools.T3Code
|
||||
```
|
||||
|
||||
#### macOS (Homebrew)
|
||||
|
||||
```bash
|
||||
brew install --cask t3-code
|
||||
```
|
||||
|
||||
#### Arch Linux (AUR)
|
||||
|
||||
```bash
|
||||
yay -S t3code-bin
|
||||
```
|
||||
Install the [desktop app from the Releases page](https://github.com/pingdotgg/t3code/releases)
|
||||
|
||||
## Some notes
|
||||
|
||||
|
||||
@@ -6,24 +6,21 @@ Use this when you want to open T3 Code from another device (phone, tablet, anoth
|
||||
|
||||
The T3 Code CLI accepts the following configuration options, available either as CLI flags or environment variables:
|
||||
|
||||
| CLI flag | Env var | Notes |
|
||||
| ----------------------- | --------------------- | ------------------------------------------------------------------------------------ |
|
||||
| `--mode <web\|desktop>` | `T3CODE_MODE` | Runtime mode. |
|
||||
| `--port <number>` | `T3CODE_PORT` | HTTP/WebSocket port. |
|
||||
| `--host <address>` | `T3CODE_HOST` | Bind interface/address. |
|
||||
| `--base-dir <path>` | `T3CODE_HOME` | Base directory. |
|
||||
| `--dev-url <url>` | `VITE_DEV_SERVER_URL` | Dev web URL redirect/proxy target. |
|
||||
| `--no-browser` | `T3CODE_NO_BROWSER` | Disable auto-open browser. |
|
||||
| `--auth-token <token>` | `T3CODE_AUTH_TOKEN` | WebSocket auth token. Use this for standard CLI and remote-server flows. |
|
||||
| `--bootstrap-fd <fd>` | `T3CODE_BOOTSTRAP_FD` | Read a one-shot bootstrap envelope from an inherited file descriptor during startup. |
|
||||
| CLI flag | Env var | Notes |
|
||||
| ----------------------- | --------------------- | ---------------------------------- |
|
||||
| `--mode <web\|desktop>` | `T3CODE_MODE` | Runtime mode. |
|
||||
| `--port <number>` | `T3CODE_PORT` | HTTP/WebSocket port. |
|
||||
| `--host <address>` | `T3CODE_HOST` | Bind interface/address. |
|
||||
| `--state-dir <path>` | `T3CODE_STATE_DIR` | State directory. |
|
||||
| `--dev-url <url>` | `VITE_DEV_SERVER_URL` | Dev web URL redirect/proxy target. |
|
||||
| `--no-browser` | `T3CODE_NO_BROWSER` | Disable auto-open browser. |
|
||||
| `--auth-token <token>` | `T3CODE_AUTH_TOKEN` | WebSocket auth token. |
|
||||
|
||||
> TIP: Use the `--help` flag to see all available options and their descriptions.
|
||||
|
||||
## Security First
|
||||
|
||||
- Always set `--auth-token` before exposing the server outside localhost.
|
||||
- When you control the process launcher, prefer sending the auth token in a JSON envelope via `--bootstrap-fd <fd>`.
|
||||
With `--bootstrap-fd <fd>`, the launcher starts the server first, then sends a one-shot JSON envelope over the inherited file descriptor. This allows the auth token to be delivered without putting it in process environment or command line arguments.
|
||||
- Treat the token like a password.
|
||||
- Prefer binding to trusted interfaces (LAN IP or Tailnet IP) instead of opening all interfaces unless needed.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@t3tools/desktop",
|
||||
"version": "0.0.15",
|
||||
"version": "0.0.9",
|
||||
"private": true,
|
||||
"main": "dist-electron/main.js",
|
||||
"scripts": {
|
||||
@@ -24,7 +24,8 @@
|
||||
"@types/node": "catalog:",
|
||||
"tsdown": "catalog:",
|
||||
"typescript": "catalog:",
|
||||
"vitest": "catalog:"
|
||||
"vitest": "catalog:",
|
||||
"wait-on": "^8.0.2"
|
||||
},
|
||||
"productName": "T3 Code (Alpha)"
|
||||
}
|
||||
@@ -1,29 +1,27 @@
|
||||
import { spawn, spawnSync } from "node:child_process";
|
||||
import { watch } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import waitOn from "wait-on";
|
||||
|
||||
import { desktopDir, resolveElectronPath } from "./electron-launcher.mjs";
|
||||
import { waitForResources } from "./wait-for-resources.mjs";
|
||||
|
||||
const port = Number(process.env.ELECTRON_RENDERER_PORT ?? 5733);
|
||||
const devServerUrl = `http://localhost:${port}`;
|
||||
const requiredFiles = [
|
||||
"dist-electron/main.js",
|
||||
"dist-electron/preload.js",
|
||||
"../server/dist/bin.mjs",
|
||||
"../server/dist/index.mjs",
|
||||
];
|
||||
const watchedDirectories = [
|
||||
{ directory: "dist-electron", files: new Set(["main.js", "preload.js"]) },
|
||||
{ directory: "../server/dist", files: new Set(["bin.mjs"]) },
|
||||
{ directory: "../server/dist", files: new Set(["index.mjs"]) },
|
||||
];
|
||||
const forcedShutdownTimeoutMs = 1_500;
|
||||
const restartDebounceMs = 120;
|
||||
const childTreeGracePeriodMs = 1_200;
|
||||
|
||||
await waitForResources({
|
||||
baseDir: desktopDir,
|
||||
files: requiredFiles,
|
||||
tcpPort: port,
|
||||
await waitOn({
|
||||
resources: [`tcp:${port}`, ...requiredFiles.map((filePath) => `file:${filePath}`)],
|
||||
});
|
||||
|
||||
const childEnv = { ...process.env };
|
||||
@@ -82,13 +80,12 @@ function startApp() {
|
||||
}
|
||||
});
|
||||
|
||||
app.once("exit", (code, signal) => {
|
||||
app.once("exit", () => {
|
||||
if (currentApp === app) {
|
||||
currentApp = null;
|
||||
}
|
||||
|
||||
const exitedAbnormally = signal !== null || code !== 0;
|
||||
if (!shuttingDown && !expectedExits.has(app) && exitedAbnormally) {
|
||||
if (!shuttingDown && !expectedExits.has(app)) {
|
||||
scheduleRestart();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
import * as FileSystem from "node:fs/promises";
|
||||
import * as Net from "node:net";
|
||||
import * as Path from "node:path";
|
||||
import * as Timers from "node:timers/promises";
|
||||
|
||||
const defaultTcpHosts = ["127.0.0.1", "localhost", "::1"];
|
||||
|
||||
async function fileExists(filePath) {
|
||||
try {
|
||||
await FileSystem.access(filePath);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function tcpPortIsReady({ host, port, connectTimeoutMs = 500 }) {
|
||||
return new Promise((resolveReady) => {
|
||||
const socket = Net.createConnection({ host, port });
|
||||
let settled = false;
|
||||
|
||||
const finish = (ready) => {
|
||||
if (settled) {
|
||||
return;
|
||||
}
|
||||
|
||||
settled = true;
|
||||
socket.removeAllListeners();
|
||||
socket.destroy();
|
||||
resolveReady(ready);
|
||||
};
|
||||
|
||||
socket.once("connect", () => {
|
||||
finish(true);
|
||||
});
|
||||
socket.once("timeout", () => {
|
||||
finish(false);
|
||||
});
|
||||
socket.once("error", () => {
|
||||
finish(false);
|
||||
});
|
||||
socket.setTimeout(connectTimeoutMs);
|
||||
});
|
||||
}
|
||||
|
||||
async function resolvePendingResources({ baseDir, files, tcpPort, tcpHosts, connectTimeoutMs }) {
|
||||
const pendingFiles = [];
|
||||
|
||||
for (const relativeFilePath of files) {
|
||||
const ready = await fileExists(Path.resolve(baseDir, relativeFilePath));
|
||||
if (!ready) {
|
||||
pendingFiles.push(relativeFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
let tcpReady = false;
|
||||
for (const host of tcpHosts) {
|
||||
tcpReady = await tcpPortIsReady({
|
||||
host,
|
||||
port: tcpPort,
|
||||
connectTimeoutMs,
|
||||
});
|
||||
if (tcpReady) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
pendingFiles,
|
||||
tcpReady,
|
||||
};
|
||||
}
|
||||
|
||||
export async function waitForResources({
|
||||
baseDir,
|
||||
files = [],
|
||||
intervalMs = 100,
|
||||
timeoutMs = 120_000,
|
||||
tcpHost,
|
||||
tcpPort,
|
||||
connectTimeoutMs = 500,
|
||||
}) {
|
||||
if (!Number.isInteger(tcpPort) || tcpPort <= 0) {
|
||||
throw new TypeError("waitForResources requires a positive integer tcpPort");
|
||||
}
|
||||
|
||||
const startedAt = Date.now();
|
||||
const tcpHosts = tcpHost ? [tcpHost] : defaultTcpHosts;
|
||||
|
||||
while (true) {
|
||||
const { pendingFiles, tcpReady } = await resolvePendingResources({
|
||||
baseDir,
|
||||
files,
|
||||
tcpPort,
|
||||
tcpHosts,
|
||||
connectTimeoutMs,
|
||||
});
|
||||
|
||||
if (pendingFiles.length === 0 && tcpReady) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Date.now() - startedAt >= timeoutMs) {
|
||||
const pendingResources = [];
|
||||
if (!tcpReady) {
|
||||
pendingResources.push(tcpHost ? `tcp:${tcpHost}:${tcpPort}` : `tcp:${tcpPort}`);
|
||||
}
|
||||
for (const filePath of pendingFiles) {
|
||||
pendingResources.push(`file:${filePath}`);
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
`Timed out waiting for desktop dev resources after ${timeoutMs}ms: ${pendingResources.join(", ")}`,
|
||||
);
|
||||
}
|
||||
|
||||
await Timers.setTimeout(intervalMs);
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ export async function showDesktopConfirmDialog(
|
||||
const options = {
|
||||
type: "question" as const,
|
||||
buttons: ["No", "Yes"],
|
||||
defaultId: 0,
|
||||
defaultId: CONFIRM_BUTTON_INDEX,
|
||||
cancelId: 0,
|
||||
noLink: true,
|
||||
message: normalizedMessage,
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import { readPathFromLoginShell } from "@t3tools/shared/shell";
|
||||
|
||||
export function fixPath(): void {
|
||||
if (process.platform !== "darwin") return;
|
||||
|
||||
try {
|
||||
const shell = process.env.SHELL ?? "/bin/zsh";
|
||||
const result = readPathFromLoginShell(shell);
|
||||
if (result) {
|
||||
process.env.PATH = result;
|
||||
}
|
||||
} catch {
|
||||
// Keep inherited PATH if shell lookup fails.
|
||||
}
|
||||
}
|
||||
+29
-136
@@ -20,7 +20,6 @@ import * as Effect from "effect/Effect";
|
||||
import type {
|
||||
DesktopTheme,
|
||||
DesktopUpdateActionResult,
|
||||
DesktopUpdateCheckResult,
|
||||
DesktopUpdateState,
|
||||
} from "@t3tools/contracts";
|
||||
import { autoUpdater } from "electron-updater";
|
||||
@@ -29,7 +28,7 @@ import type { ContextMenuItem } from "@t3tools/contracts";
|
||||
import { NetService } from "@t3tools/shared/Net";
|
||||
import { RotatingFileSink } from "@t3tools/shared/logging";
|
||||
import { showDesktopConfirmDialog } from "./confirmDialog";
|
||||
import { syncShellEnvironment } from "./syncShellEnvironment";
|
||||
import { fixPath } from "./fixPath";
|
||||
import { getAutoUpdateDisabledReason, shouldBroadcastDownloadProgress } from "./updateState";
|
||||
import {
|
||||
createInitialDesktopUpdateState,
|
||||
@@ -45,7 +44,7 @@ import {
|
||||
} from "./updateMachine";
|
||||
import { isArm64HostRunningIntelBuild, resolveDesktopRuntimeInfo } from "./runtimeArch";
|
||||
|
||||
syncShellEnvironment();
|
||||
fixPath();
|
||||
|
||||
const PICK_FOLDER_CHANNEL = "desktop:pick-folder";
|
||||
const CONFIRM_CHANNEL = "desktop:confirm";
|
||||
@@ -57,17 +56,13 @@ const UPDATE_STATE_CHANNEL = "desktop:update-state";
|
||||
const UPDATE_GET_STATE_CHANNEL = "desktop:update-get-state";
|
||||
const UPDATE_DOWNLOAD_CHANNEL = "desktop:update-download";
|
||||
const UPDATE_INSTALL_CHANNEL = "desktop:update-install";
|
||||
const UPDATE_CHECK_CHANNEL = "desktop:update-check";
|
||||
const GET_WS_URL_CHANNEL = "desktop:get-ws-url";
|
||||
const BASE_DIR = process.env.T3CODE_HOME?.trim() || Path.join(OS.homedir(), ".t3");
|
||||
const STATE_DIR = Path.join(BASE_DIR, "userdata");
|
||||
const STATE_DIR =
|
||||
process.env.T3CODE_STATE_DIR?.trim() || Path.join(OS.homedir(), ".t3", "userdata");
|
||||
const DESKTOP_SCHEME = "t3";
|
||||
const ROOT_DIR = Path.resolve(__dirname, "../../..");
|
||||
const isDevelopment = Boolean(process.env.VITE_DEV_SERVER_URL);
|
||||
const APP_DISPLAY_NAME = isDevelopment ? "T3 Code (Dev)" : "T3 Code (Alpha)";
|
||||
const APP_USER_MODEL_ID = "com.t3tools.t3code";
|
||||
const LINUX_DESKTOP_ENTRY_NAME = isDevelopment ? "t3code-dev.desktop" : "t3code.desktop";
|
||||
const LINUX_WM_CLASS = isDevelopment ? "t3code-dev" : "t3code";
|
||||
const USER_DATA_DIR_NAME = isDevelopment ? "t3code-dev" : "t3code";
|
||||
const LEGACY_USER_DATA_DIR_NAME = isDevelopment ? "T3 Code (Dev)" : "T3 Code (Alpha)";
|
||||
const COMMIT_HASH_PATTERN = /^[0-9a-f]{7,40}$/i;
|
||||
@@ -82,9 +77,6 @@ const DESKTOP_UPDATE_CHANNEL = "latest";
|
||||
const DESKTOP_UPDATE_ALLOW_PRERELEASE = false;
|
||||
|
||||
type DesktopUpdateErrorContext = DesktopUpdateState["errorContext"];
|
||||
type LinuxDesktopNamedApp = Electron.App & {
|
||||
setDesktopName?: (desktopName: string) => void;
|
||||
};
|
||||
|
||||
let mainWindow: BrowserWindow | null = null;
|
||||
let backendProcess: ChildProcess.ChildProcess | null = null;
|
||||
@@ -121,17 +113,6 @@ function sanitizeLogValue(value: string): string {
|
||||
return value.replace(/\s+/g, " ").trim();
|
||||
}
|
||||
|
||||
function backendChildEnv(): NodeJS.ProcessEnv {
|
||||
const env = { ...process.env };
|
||||
delete env.T3CODE_PORT;
|
||||
delete env.T3CODE_AUTH_TOKEN;
|
||||
delete env.T3CODE_MODE;
|
||||
delete env.T3CODE_NO_BROWSER;
|
||||
delete env.T3CODE_HOST;
|
||||
delete env.T3CODE_DESKTOP_WS_URL;
|
||||
return env;
|
||||
}
|
||||
|
||||
function writeDesktopLogHeader(message: string): void {
|
||||
if (!desktopLogSink) return;
|
||||
desktopLogSink.write(`[${logTimestamp()}] [${logScope("desktop")}] ${message}\n`);
|
||||
@@ -268,10 +249,6 @@ function captureBackendOutput(child: ChildProcess.ChildProcess): void {
|
||||
|
||||
initializePackagedLogging();
|
||||
|
||||
if (process.platform === "linux") {
|
||||
app.commandLine.appendSwitch("class", LINUX_WM_CLASS);
|
||||
}
|
||||
|
||||
function getDestructiveMenuIcon(): Electron.NativeImage | undefined {
|
||||
if (process.platform !== "darwin") return undefined;
|
||||
if (destructiveMenuIconCache !== undefined) {
|
||||
@@ -298,12 +275,10 @@ let updatePollTimer: ReturnType<typeof setInterval> | null = null;
|
||||
let updateStartupTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
let updateCheckInFlight = false;
|
||||
let updateDownloadInFlight = false;
|
||||
let updateInstallInFlight = false;
|
||||
let updaterConfigured = false;
|
||||
let updateState: DesktopUpdateState = initialUpdateState();
|
||||
|
||||
function resolveUpdaterErrorContext(): DesktopUpdateErrorContext {
|
||||
if (updateInstallInFlight) return "install";
|
||||
if (updateDownloadInFlight) return "download";
|
||||
if (updateCheckInFlight) return "check";
|
||||
return updateState.errorContext;
|
||||
@@ -399,7 +374,7 @@ function resolveAboutCommitHash(): string | null {
|
||||
}
|
||||
|
||||
function resolveBackendEntry(): string {
|
||||
return Path.join(resolveAppRoot(), "apps/server/dist/bin.mjs");
|
||||
return Path.join(resolveAppRoot(), "apps/server/dist/index.mjs");
|
||||
}
|
||||
|
||||
function resolveBackendCwd(): string {
|
||||
@@ -560,28 +535,7 @@ function handleCheckForUpdatesMenuClick(): void {
|
||||
if (!BrowserWindow.getAllWindows().length) {
|
||||
mainWindow = createWindow();
|
||||
}
|
||||
void checkForUpdatesFromMenu();
|
||||
}
|
||||
|
||||
async function checkForUpdatesFromMenu(): Promise<void> {
|
||||
await checkForUpdates("menu");
|
||||
|
||||
if (updateState.status === "up-to-date") {
|
||||
void dialog.showMessageBox({
|
||||
type: "info",
|
||||
title: "You're up to date!",
|
||||
message: `T3 Code ${updateState.currentVersion} is currently the newest version available.`,
|
||||
buttons: ["OK"],
|
||||
});
|
||||
} else if (updateState.status === "error") {
|
||||
void dialog.showMessageBox({
|
||||
type: "warning",
|
||||
title: "Update check failed",
|
||||
message: "Could not check for updates.",
|
||||
detail: updateState.message ?? "An unknown error occurred. Please try again later.",
|
||||
buttons: ["OK"],
|
||||
});
|
||||
}
|
||||
void checkForUpdates("menu");
|
||||
}
|
||||
|
||||
function configureApplicationMenu(): void {
|
||||
@@ -665,7 +619,6 @@ function configureApplicationMenu(): void {
|
||||
function resolveResourcePath(fileName: string): string | null {
|
||||
const candidates = [
|
||||
Path.join(__dirname, "../resources", fileName),
|
||||
Path.join(__dirname, "../prod-resources", fileName),
|
||||
Path.join(process.resourcesPath, "resources", fileName),
|
||||
Path.join(process.resourcesPath, fileName),
|
||||
];
|
||||
@@ -724,10 +677,6 @@ function configureAppIdentity(): void {
|
||||
app.setAppUserModelId(APP_USER_MODEL_ID);
|
||||
}
|
||||
|
||||
if (process.platform === "linux") {
|
||||
(app as LinuxDesktopNamedApp).setDesktopName?.(LINUX_DESKTOP_ENTRY_NAME);
|
||||
}
|
||||
|
||||
if (process.platform === "darwin" && app.dock) {
|
||||
const iconPath = resolveIconPath("png");
|
||||
if (iconPath) {
|
||||
@@ -771,13 +720,13 @@ function shouldEnableAutoUpdates(): boolean {
|
||||
);
|
||||
}
|
||||
|
||||
async function checkForUpdates(reason: string): Promise<boolean> {
|
||||
if (isQuitting || !updaterConfigured || updateCheckInFlight) return false;
|
||||
async function checkForUpdates(reason: string): Promise<void> {
|
||||
if (isQuitting || !updaterConfigured || updateCheckInFlight) return;
|
||||
if (updateState.status === "downloading" || updateState.status === "downloaded") {
|
||||
console.info(
|
||||
`[desktop-updater] Skipping update check (${reason}) while status=${updateState.status}.`,
|
||||
);
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
updateCheckInFlight = true;
|
||||
setUpdateState(reduceDesktopUpdateStateOnCheckStart(updateState, new Date().toISOString()));
|
||||
@@ -785,14 +734,12 @@ async function checkForUpdates(reason: string): Promise<boolean> {
|
||||
|
||||
try {
|
||||
await autoUpdater.checkForUpdates();
|
||||
return true;
|
||||
} catch (error: unknown) {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
setUpdateState(
|
||||
reduceDesktopUpdateStateOnCheckFailure(updateState, message, new Date().toISOString()),
|
||||
);
|
||||
console.error(`[desktop-updater] Failed to check for updates: ${message}`);
|
||||
return true;
|
||||
} finally {
|
||||
updateCheckInFlight = false;
|
||||
}
|
||||
@@ -826,22 +773,13 @@ async function installDownloadedUpdate(): Promise<{ accepted: boolean; completed
|
||||
}
|
||||
|
||||
isQuitting = true;
|
||||
updateInstallInFlight = true;
|
||||
clearUpdatePollTimer();
|
||||
try {
|
||||
await stopBackendAndWaitForExit();
|
||||
// Destroy all windows before launching the NSIS installer to avoid the installer finding live windows it needs to close.
|
||||
for (const win of BrowserWindow.getAllWindows()) {
|
||||
win.destroy();
|
||||
}
|
||||
// `quitAndInstall()` only starts the handoff to the updater. The actual
|
||||
// install may still fail asynchronously, so keep the action incomplete
|
||||
// until we either quit or receive an updater error.
|
||||
autoUpdater.quitAndInstall(true, true);
|
||||
return { accepted: true, completed: false };
|
||||
autoUpdater.quitAndInstall();
|
||||
return { accepted: true, completed: true };
|
||||
} catch (error: unknown) {
|
||||
const message = formatErrorMessage(error);
|
||||
updateInstallInFlight = false;
|
||||
isQuitting = false;
|
||||
setUpdateState(reduceDesktopUpdateStateOnInstallFailure(updateState, message));
|
||||
console.error(`[desktop-updater] Failed to install update: ${message}`);
|
||||
@@ -878,13 +816,6 @@ function configureAutoUpdater(): void {
|
||||
}
|
||||
}
|
||||
|
||||
if (process.env.T3CODE_DESKTOP_MOCK_UPDATES) {
|
||||
autoUpdater.setFeedURL({
|
||||
provider: "generic",
|
||||
url: `http://localhost:${process.env.T3CODE_DESKTOP_MOCK_UPDATE_SERVER_PORT ?? 3000}`,
|
||||
});
|
||||
}
|
||||
|
||||
autoUpdater.autoDownload = false;
|
||||
autoUpdater.autoInstallOnAppQuit = false;
|
||||
// Keep alpha branding, but force all installs onto the stable update track.
|
||||
@@ -921,13 +852,6 @@ function configureAutoUpdater(): void {
|
||||
});
|
||||
autoUpdater.on("error", (error) => {
|
||||
const message = formatErrorMessage(error);
|
||||
if (updateInstallInFlight) {
|
||||
updateInstallInFlight = false;
|
||||
isQuitting = false;
|
||||
setUpdateState(reduceDesktopUpdateStateOnInstallFailure(updateState, message));
|
||||
console.error(`[desktop-updater] Updater error: ${message}`);
|
||||
return;
|
||||
}
|
||||
if (!updateCheckInFlight && !updateDownloadInFlight) {
|
||||
setUpdateState({
|
||||
status: "error",
|
||||
@@ -972,6 +896,17 @@ function configureAutoUpdater(): void {
|
||||
}, AUTO_UPDATE_POLL_INTERVAL_MS);
|
||||
updatePollTimer.unref();
|
||||
}
|
||||
function backendEnv(): NodeJS.ProcessEnv {
|
||||
return {
|
||||
...process.env,
|
||||
T3CODE_MODE: "desktop",
|
||||
T3CODE_NO_BROWSER: "1",
|
||||
T3CODE_PORT: String(backendPort),
|
||||
T3CODE_STATE_DIR: STATE_DIR,
|
||||
T3CODE_AUTH_TOKEN: backendAuthToken,
|
||||
};
|
||||
}
|
||||
|
||||
function scheduleBackendRestart(reason: string): void {
|
||||
if (isQuitting || restartTimer) return;
|
||||
|
||||
@@ -995,35 +930,16 @@ function startBackend(): void {
|
||||
}
|
||||
|
||||
const captureBackendLogs = app.isPackaged && backendLogSink !== null;
|
||||
const child = ChildProcess.spawn(process.execPath, [backendEntry, "--bootstrap-fd", "3"], {
|
||||
const child = ChildProcess.spawn(process.execPath, [backendEntry], {
|
||||
cwd: resolveBackendCwd(),
|
||||
// In Electron main, process.execPath points to the Electron binary.
|
||||
// Run the child in Node mode so this backend process does not become a GUI app instance.
|
||||
env: {
|
||||
...backendChildEnv(),
|
||||
...backendEnv(),
|
||||
ELECTRON_RUN_AS_NODE: "1",
|
||||
},
|
||||
stdio: captureBackendLogs
|
||||
? ["ignore", "pipe", "pipe", "pipe"]
|
||||
: ["ignore", "inherit", "inherit", "pipe"],
|
||||
stdio: captureBackendLogs ? ["ignore", "pipe", "pipe"] : "inherit",
|
||||
});
|
||||
const bootstrapStream = child.stdio[3];
|
||||
if (bootstrapStream && "write" in bootstrapStream) {
|
||||
bootstrapStream.write(
|
||||
`${JSON.stringify({
|
||||
mode: "desktop",
|
||||
noBrowser: true,
|
||||
port: backendPort,
|
||||
t3Home: BASE_DIR,
|
||||
authToken: backendAuthToken,
|
||||
})}\n`,
|
||||
);
|
||||
bootstrapStream.end();
|
||||
} else {
|
||||
child.kill("SIGTERM");
|
||||
scheduleBackendRestart("missing desktop bootstrap pipe");
|
||||
return;
|
||||
}
|
||||
backendProcess = child;
|
||||
let backendSessionClosed = false;
|
||||
const closeBackendSession = (details: string) => {
|
||||
@@ -1134,11 +1050,6 @@ async function stopBackendAndWaitForExit(timeoutMs = 5_000): Promise<void> {
|
||||
}
|
||||
|
||||
function registerIpcHandlers(): void {
|
||||
ipcMain.removeAllListeners(GET_WS_URL_CHANNEL);
|
||||
ipcMain.on(GET_WS_URL_CHANNEL, (event) => {
|
||||
event.returnValue = backendWsUrl;
|
||||
});
|
||||
|
||||
ipcMain.removeHandler(PICK_FOLDER_CHANNEL);
|
||||
ipcMain.handle(PICK_FOLDER_CHANNEL, async () => {
|
||||
const owner = BrowserWindow.getFocusedWindow() ?? mainWindow;
|
||||
@@ -1183,7 +1094,6 @@ function registerIpcHandlers(): void {
|
||||
id: item.id,
|
||||
label: item.label,
|
||||
destructive: item.destructive === true,
|
||||
disabled: item.disabled === true,
|
||||
}));
|
||||
if (normalizedItems.length === 0) {
|
||||
return null;
|
||||
@@ -1214,7 +1124,6 @@ function registerIpcHandlers(): void {
|
||||
}
|
||||
const itemOption: MenuItemConstructorOptions = {
|
||||
label: item.label,
|
||||
enabled: !item.disabled,
|
||||
click: () => resolve(item.id),
|
||||
};
|
||||
if (item.destructive) {
|
||||
@@ -1280,21 +1189,6 @@ function registerIpcHandlers(): void {
|
||||
state: updateState,
|
||||
} satisfies DesktopUpdateActionResult;
|
||||
});
|
||||
|
||||
ipcMain.removeHandler(UPDATE_CHECK_CHANNEL);
|
||||
ipcMain.handle(UPDATE_CHECK_CHANNEL, async () => {
|
||||
if (!updaterConfigured) {
|
||||
return {
|
||||
checked: false,
|
||||
state: updateState,
|
||||
} satisfies DesktopUpdateCheckResult;
|
||||
}
|
||||
const checked = await checkForUpdates("web-ui");
|
||||
return {
|
||||
checked,
|
||||
state: updateState,
|
||||
} satisfies DesktopUpdateCheckResult;
|
||||
});
|
||||
}
|
||||
|
||||
function getIconOption(): { icon: string } | Record<string, never> {
|
||||
@@ -1404,9 +1298,9 @@ async function bootstrap(): Promise<void> {
|
||||
);
|
||||
writeDesktopLogHeader(`reserved backend port via NetService port=${backendPort}`);
|
||||
backendAuthToken = Crypto.randomBytes(24).toString("hex");
|
||||
const baseUrl = `ws://127.0.0.1:${backendPort}`;
|
||||
backendWsUrl = `${baseUrl}/?token=${encodeURIComponent(backendAuthToken)}`;
|
||||
writeDesktopLogHeader(`bootstrap resolved websocket endpoint baseUrl=${baseUrl}`);
|
||||
backendWsUrl = `ws://127.0.0.1:${backendPort}/?token=${encodeURIComponent(backendAuthToken)}`;
|
||||
process.env.T3CODE_DESKTOP_WS_URL = backendWsUrl;
|
||||
writeDesktopLogHeader(`bootstrap resolved websocket url=${backendWsUrl}`);
|
||||
|
||||
registerIpcHandlers();
|
||||
writeDesktopLogHeader("bootstrap ipc handlers registered");
|
||||
@@ -1418,7 +1312,6 @@ async function bootstrap(): Promise<void> {
|
||||
|
||||
app.on("before-quit", () => {
|
||||
isQuitting = true;
|
||||
updateInstallInFlight = false;
|
||||
writeDesktopLogHeader("before-quit received");
|
||||
clearUpdatePollTimer();
|
||||
stopBackend();
|
||||
@@ -1448,7 +1341,7 @@ app
|
||||
});
|
||||
|
||||
app.on("window-all-closed", () => {
|
||||
if (process.platform !== "darwin" && !isQuitting) {
|
||||
if (process.platform !== "darwin") {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -9,16 +9,12 @@ const OPEN_EXTERNAL_CHANNEL = "desktop:open-external";
|
||||
const MENU_ACTION_CHANNEL = "desktop:menu-action";
|
||||
const UPDATE_STATE_CHANNEL = "desktop:update-state";
|
||||
const UPDATE_GET_STATE_CHANNEL = "desktop:update-get-state";
|
||||
const UPDATE_CHECK_CHANNEL = "desktop:update-check";
|
||||
const UPDATE_DOWNLOAD_CHANNEL = "desktop:update-download";
|
||||
const UPDATE_INSTALL_CHANNEL = "desktop:update-install";
|
||||
const GET_WS_URL_CHANNEL = "desktop:get-ws-url";
|
||||
const wsUrl = process.env.T3CODE_DESKTOP_WS_URL ?? null;
|
||||
|
||||
contextBridge.exposeInMainWorld("desktopBridge", {
|
||||
getWsUrl: () => {
|
||||
const result = ipcRenderer.sendSync(GET_WS_URL_CHANNEL);
|
||||
return typeof result === "string" ? result : null;
|
||||
},
|
||||
getWsUrl: () => wsUrl,
|
||||
pickFolder: () => ipcRenderer.invoke(PICK_FOLDER_CHANNEL),
|
||||
confirm: (message) => ipcRenderer.invoke(CONFIRM_CHANNEL, message),
|
||||
setTheme: (theme) => ipcRenderer.invoke(SET_THEME_CHANNEL, theme),
|
||||
@@ -36,7 +32,6 @@ contextBridge.exposeInMainWorld("desktopBridge", {
|
||||
};
|
||||
},
|
||||
getUpdateState: () => ipcRenderer.invoke(UPDATE_GET_STATE_CHANNEL),
|
||||
checkForUpdate: () => ipcRenderer.invoke(UPDATE_CHECK_CHANNEL),
|
||||
downloadUpdate: () => ipcRenderer.invoke(UPDATE_DOWNLOAD_CHANNEL),
|
||||
installUpdate: () => ipcRenderer.invoke(UPDATE_INSTALL_CHANNEL),
|
||||
onUpdateState: (listener) => {
|
||||
|
||||
@@ -1,105 +0,0 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { syncShellEnvironment } from "./syncShellEnvironment";
|
||||
|
||||
describe("syncShellEnvironment", () => {
|
||||
it("hydrates PATH and missing SSH_AUTH_SOCK from the login shell on macOS", () => {
|
||||
const env: NodeJS.ProcessEnv = {
|
||||
SHELL: "/bin/zsh",
|
||||
PATH: "/usr/bin",
|
||||
};
|
||||
const readEnvironment = vi.fn(() => ({
|
||||
PATH: "/opt/homebrew/bin:/usr/bin",
|
||||
SSH_AUTH_SOCK: "/tmp/secretive.sock",
|
||||
}));
|
||||
|
||||
syncShellEnvironment(env, {
|
||||
platform: "darwin",
|
||||
readEnvironment,
|
||||
});
|
||||
|
||||
expect(readEnvironment).toHaveBeenCalledWith("/bin/zsh", ["PATH", "SSH_AUTH_SOCK"]);
|
||||
expect(env.PATH).toBe("/opt/homebrew/bin:/usr/bin");
|
||||
expect(env.SSH_AUTH_SOCK).toBe("/tmp/secretive.sock");
|
||||
});
|
||||
|
||||
it("preserves an inherited SSH_AUTH_SOCK value", () => {
|
||||
const env: NodeJS.ProcessEnv = {
|
||||
SHELL: "/bin/zsh",
|
||||
PATH: "/usr/bin",
|
||||
SSH_AUTH_SOCK: "/tmp/inherited.sock",
|
||||
};
|
||||
const readEnvironment = vi.fn(() => ({
|
||||
PATH: "/opt/homebrew/bin:/usr/bin",
|
||||
SSH_AUTH_SOCK: "/tmp/login-shell.sock",
|
||||
}));
|
||||
|
||||
syncShellEnvironment(env, {
|
||||
platform: "darwin",
|
||||
readEnvironment,
|
||||
});
|
||||
|
||||
expect(env.PATH).toBe("/opt/homebrew/bin:/usr/bin");
|
||||
expect(env.SSH_AUTH_SOCK).toBe("/tmp/inherited.sock");
|
||||
});
|
||||
|
||||
it("preserves inherited values when the login shell omits them", () => {
|
||||
const env: NodeJS.ProcessEnv = {
|
||||
SHELL: "/bin/zsh",
|
||||
PATH: "/usr/bin",
|
||||
SSH_AUTH_SOCK: "/tmp/inherited.sock",
|
||||
};
|
||||
const readEnvironment = vi.fn(() => ({
|
||||
PATH: "/opt/homebrew/bin:/usr/bin",
|
||||
}));
|
||||
|
||||
syncShellEnvironment(env, {
|
||||
platform: "darwin",
|
||||
readEnvironment,
|
||||
});
|
||||
|
||||
expect(env.PATH).toBe("/opt/homebrew/bin:/usr/bin");
|
||||
expect(env.SSH_AUTH_SOCK).toBe("/tmp/inherited.sock");
|
||||
});
|
||||
|
||||
it("hydrates PATH and missing SSH_AUTH_SOCK from the login shell on linux", () => {
|
||||
const env: NodeJS.ProcessEnv = {
|
||||
SHELL: "/bin/zsh",
|
||||
PATH: "/usr/bin",
|
||||
};
|
||||
const readEnvironment = vi.fn(() => ({
|
||||
PATH: "/home/linuxbrew/.linuxbrew/bin:/usr/bin",
|
||||
SSH_AUTH_SOCK: "/tmp/secretive.sock",
|
||||
}));
|
||||
|
||||
syncShellEnvironment(env, {
|
||||
platform: "linux",
|
||||
readEnvironment,
|
||||
});
|
||||
|
||||
expect(readEnvironment).toHaveBeenCalledWith("/bin/zsh", ["PATH", "SSH_AUTH_SOCK"]);
|
||||
expect(env.PATH).toBe("/home/linuxbrew/.linuxbrew/bin:/usr/bin");
|
||||
expect(env.SSH_AUTH_SOCK).toBe("/tmp/secretive.sock");
|
||||
});
|
||||
|
||||
it("does nothing outside macOS and linux", () => {
|
||||
const env: NodeJS.ProcessEnv = {
|
||||
SHELL: "C:/Program Files/Git/bin/bash.exe",
|
||||
PATH: "C:\\Windows\\System32",
|
||||
SSH_AUTH_SOCK: "/tmp/inherited.sock",
|
||||
};
|
||||
const readEnvironment = vi.fn(() => ({
|
||||
PATH: "/usr/local/bin:/usr/bin",
|
||||
SSH_AUTH_SOCK: "/tmp/secretive.sock",
|
||||
}));
|
||||
|
||||
syncShellEnvironment(env, {
|
||||
platform: "win32",
|
||||
readEnvironment,
|
||||
});
|
||||
|
||||
expect(readEnvironment).not.toHaveBeenCalled();
|
||||
expect(env.PATH).toBe("C:\\Windows\\System32");
|
||||
expect(env.SSH_AUTH_SOCK).toBe("/tmp/inherited.sock");
|
||||
});
|
||||
});
|
||||
@@ -1,36 +0,0 @@
|
||||
import {
|
||||
readEnvironmentFromLoginShell,
|
||||
resolveLoginShell,
|
||||
ShellEnvironmentReader,
|
||||
} from "@t3tools/shared/shell";
|
||||
|
||||
export function syncShellEnvironment(
|
||||
env: NodeJS.ProcessEnv = process.env,
|
||||
options: {
|
||||
platform?: NodeJS.Platform;
|
||||
readEnvironment?: ShellEnvironmentReader;
|
||||
} = {},
|
||||
): void {
|
||||
const platform = options.platform ?? process.platform;
|
||||
if (platform !== "darwin" && platform !== "linux") return;
|
||||
|
||||
try {
|
||||
const shell = resolveLoginShell(platform, env.SHELL);
|
||||
if (!shell) return;
|
||||
|
||||
const shellEnvironment = (options.readEnvironment ?? readEnvironmentFromLoginShell)(shell, [
|
||||
"PATH",
|
||||
"SSH_AUTH_SOCK",
|
||||
]);
|
||||
|
||||
if (shellEnvironment.PATH) {
|
||||
env.PATH = shellEnvironment.PATH;
|
||||
}
|
||||
|
||||
if (!env.SSH_AUTH_SOCK && shellEnvironment.SSH_AUTH_SOCK) {
|
||||
env.SSH_AUTH_SOCK = shellEnvironment.SSH_AUTH_SOCK;
|
||||
}
|
||||
} catch {
|
||||
// Keep inherited environment if shell lookup fails.
|
||||
}
|
||||
}
|
||||
@@ -10,10 +10,10 @@
|
||||
"typecheck": "astro check"
|
||||
},
|
||||
"dependencies": {
|
||||
"astro": "^6.0.4"
|
||||
"astro": "^5.7.13"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@astrojs/check": "^0.9.7",
|
||||
"@astrojs/check": "^0.9.4",
|
||||
"typescript": "catalog:"
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,20 @@
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { execFileSync } from "node:child_process";
|
||||
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import {
|
||||
ApprovalRequestId,
|
||||
ProviderKind,
|
||||
type OrchestrationEvent,
|
||||
type OrchestrationThread,
|
||||
} from "@t3tools/contracts";
|
||||
import {
|
||||
Effect,
|
||||
Exit,
|
||||
FileSystem,
|
||||
Layer,
|
||||
ManagedRuntime,
|
||||
Option,
|
||||
Path,
|
||||
Ref,
|
||||
Schedule,
|
||||
Schema,
|
||||
@@ -24,7 +24,6 @@ import {
|
||||
|
||||
import { CheckpointStoreLive } from "../src/checkpointing/Layers/CheckpointStore.ts";
|
||||
import { CheckpointStore } from "../src/checkpointing/Services/CheckpointStore.ts";
|
||||
import { GitCoreLive } from "../src/git/Layers/GitCore.ts";
|
||||
import { GitCore, type GitCoreShape } from "../src/git/Services/GitCore.ts";
|
||||
import { TextGeneration, type TextGenerationShape } from "../src/git/Services/TextGeneration.ts";
|
||||
import { OrchestrationCommandReceiptRepositoryLive } from "../src/persistence/Layers/OrchestrationCommandReceipts.ts";
|
||||
@@ -38,7 +37,6 @@ import { ProjectionPendingApprovalRepository } from "../src/persistence/Services
|
||||
import { ProviderUnsupportedError } from "../src/provider/Errors.ts";
|
||||
import { ProviderAdapterRegistry } from "../src/provider/Services/ProviderAdapterRegistry.ts";
|
||||
import { ProviderSessionDirectoryLive } from "../src/provider/Layers/ProviderSessionDirectory.ts";
|
||||
import { ServerSettingsService } from "../src/serverSettings.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";
|
||||
@@ -67,9 +65,7 @@ import {
|
||||
makeTestProviderAdapterHarness,
|
||||
type TestProviderAdapterHarness,
|
||||
} from "./TestProviderAdapter.integration.ts";
|
||||
import { deriveServerPaths, ServerConfig } from "../src/config.ts";
|
||||
import { WorkspaceEntriesLive } from "../src/workspace/Layers/WorkspaceEntries.ts";
|
||||
import { WorkspacePathsLive } from "../src/workspace/Layers/WorkspacePaths.ts";
|
||||
import { ServerConfig } from "../src/config.ts";
|
||||
|
||||
function runGit(cwd: string, args: ReadonlyArray<string>) {
|
||||
return execFileSync("git", args, {
|
||||
@@ -79,16 +75,14 @@ function runGit(cwd: string, args: ReadonlyArray<string>) {
|
||||
});
|
||||
}
|
||||
|
||||
const initializeGitWorkspace = Effect.fn(function* (cwd: string) {
|
||||
function initializeGitWorkspace(cwd: string) {
|
||||
runGit(cwd, ["init", "--initial-branch=main"]);
|
||||
runGit(cwd, ["config", "user.email", "[email protected]"]);
|
||||
runGit(cwd, ["config", "user.name", "Test User"]);
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const { join } = yield* Path.Path;
|
||||
yield* fileSystem.writeFileString(join(cwd, "README.md"), "v1\n");
|
||||
fs.writeFileSync(path.join(cwd, "README.md"), "v1\n", "utf8");
|
||||
runGit(cwd, ["add", "."]);
|
||||
runGit(cwd, ["commit", "-m", "Initial"]);
|
||||
});
|
||||
}
|
||||
|
||||
export function gitRefExists(cwd: string, ref: string): boolean {
|
||||
try {
|
||||
@@ -126,7 +120,7 @@ function waitFor<A, E>(
|
||||
read: Effect.Effect<A, E>,
|
||||
predicate: (value: A) => boolean,
|
||||
description: string,
|
||||
timeoutMs = 40_000,
|
||||
timeoutMs = 10_000,
|
||||
): Effect.Effect<A, never> {
|
||||
const RETRY_SIGNAL = "wait_for_retry";
|
||||
const retryIntervalMs = 10;
|
||||
@@ -211,7 +205,7 @@ export interface OrchestrationIntegrationHarness {
|
||||
}
|
||||
|
||||
interface MakeOrchestrationIntegrationHarnessOptions {
|
||||
readonly provider?: ProviderKind;
|
||||
readonly provider?: "codex";
|
||||
readonly realCodex?: boolean;
|
||||
}
|
||||
|
||||
@@ -219,9 +213,7 @@ export const makeOrchestrationIntegrationHarness = (
|
||||
options?: MakeOrchestrationIntegrationHarnessOptions,
|
||||
) =>
|
||||
Effect.gen(function* () {
|
||||
const path = yield* Path.Path;
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
|
||||
const sleep = (ms: number) => Effect.sleep(ms);
|
||||
const provider = options?.provider ?? "codex";
|
||||
const useRealCodex = options?.realCodex === true;
|
||||
const adapterHarness = useRealCodex
|
||||
@@ -238,16 +230,13 @@ export const makeOrchestrationIntegrationHarness = (
|
||||
listProviders: () => Effect.succeed([adapterHarness.provider]),
|
||||
} as typeof ProviderAdapterRegistry.Service)
|
||||
: null;
|
||||
const rootDir = yield* fileSystem.makeTempDirectoryScoped({
|
||||
prefix: "t3-orchestration-integration-",
|
||||
});
|
||||
const rootDir = fs.mkdtempSync(path.join(os.tmpdir(), "t3-orchestration-integration-"));
|
||||
const workspaceDir = path.join(rootDir, "workspace");
|
||||
const { stateDir, dbPath } = yield* deriveServerPaths(rootDir, undefined).pipe(
|
||||
Effect.provideService(Path.Path, path),
|
||||
);
|
||||
yield* fileSystem.makeDirectory(workspaceDir, { recursive: true });
|
||||
yield* fileSystem.makeDirectory(stateDir, { recursive: true });
|
||||
yield* initializeGitWorkspace(workspaceDir);
|
||||
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 persistenceLayer = makeSqlitePersistenceLive(dbPath);
|
||||
const orchestrationLayer = OrchestrationEngineLive.pipe(
|
||||
@@ -272,7 +261,7 @@ export const makeOrchestrationIntegrationHarness = (
|
||||
}),
|
||||
).pipe(
|
||||
Layer.provide(makeCodexAdapterLive()),
|
||||
Layer.provideMerge(ServerConfig.layerTest(workspaceDir, rootDir)),
|
||||
Layer.provideMerge(ServerConfig.layerTest(workspaceDir, stateDir)),
|
||||
Layer.provideMerge(NodeServices.layer),
|
||||
Layer.provideMerge(providerSessionDirectoryLayer),
|
||||
);
|
||||
@@ -288,45 +277,32 @@ export const makeOrchestrationIntegrationHarness = (
|
||||
Layer.provide(AnalyticsService.layerTest),
|
||||
);
|
||||
|
||||
const checkpointStoreLayer = CheckpointStoreLive.pipe(Layer.provide(GitCoreLive));
|
||||
const runtimeServicesLayer = Layer.mergeAll(
|
||||
orchestrationLayer,
|
||||
OrchestrationProjectionSnapshotQueryLive,
|
||||
ProjectionCheckpointRepositoryLive,
|
||||
ProjectionPendingApprovalRepositoryLive,
|
||||
checkpointStoreLayer,
|
||||
CheckpointStoreLive,
|
||||
providerLayer,
|
||||
RuntimeReceiptBusLive,
|
||||
);
|
||||
const serverSettingsLayer = ServerSettingsService.layerTest();
|
||||
const runtimeIngestionLayer = ProviderRuntimeIngestionLive.pipe(
|
||||
Layer.provideMerge(runtimeServicesLayer),
|
||||
Layer.provideMerge(serverSettingsLayer),
|
||||
);
|
||||
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: "update" }),
|
||||
generateThreadTitle: () => Effect.succeed({ title: "New thread" }),
|
||||
generateBranchName: () => Effect.succeed({ branch: null }),
|
||||
} as unknown as TextGenerationShape);
|
||||
const providerCommandReactorLayer = ProviderCommandReactorLive.pipe(
|
||||
Layer.provideMerge(runtimeServicesLayer),
|
||||
Layer.provideMerge(gitCoreLayer),
|
||||
Layer.provideMerge(textGenerationLayer),
|
||||
Layer.provideMerge(serverSettingsLayer),
|
||||
);
|
||||
const checkpointReactorLayer = CheckpointReactorLive.pipe(
|
||||
Layer.provideMerge(runtimeServicesLayer),
|
||||
Layer.provideMerge(
|
||||
WorkspaceEntriesLive.pipe(
|
||||
Layer.provide(WorkspacePathsLive),
|
||||
Layer.provideMerge(gitCoreLayer),
|
||||
Layer.provide(NodeServices.layer),
|
||||
),
|
||||
),
|
||||
Layer.provideMerge(WorkspacePathsLive),
|
||||
);
|
||||
const orchestrationReactorLayer = OrchestrationReactorLive.pipe(
|
||||
Layer.provideMerge(runtimeIngestionLayer),
|
||||
@@ -335,8 +311,7 @@ export const makeOrchestrationIntegrationHarness = (
|
||||
);
|
||||
const layer = orchestrationReactorLayer.pipe(
|
||||
Layer.provide(persistenceLayer),
|
||||
Layer.provideMerge(ServerSettingsService.layerTest()),
|
||||
Layer.provideMerge(ServerConfig.layerTest(workspaceDir, rootDir)),
|
||||
Layer.provideMerge(ServerConfig.layerTest(workspaceDir, stateDir)),
|
||||
Layer.provideMerge(NodeServices.layer),
|
||||
);
|
||||
|
||||
@@ -370,13 +345,13 @@ export const makeOrchestrationIntegrationHarness = (
|
||||
|
||||
const scope = yield* Scope.make("sequential");
|
||||
yield* tryRuntimePromise("start OrchestrationReactor", () =>
|
||||
runtime.runPromise(reactor.start().pipe(Scope.provide(scope))),
|
||||
runtime.runPromise(reactor.start.pipe(Scope.provide(scope))),
|
||||
).pipe(Effect.orDie);
|
||||
const receiptHistory = yield* Ref.make<ReadonlyArray<OrchestrationRuntimeReceipt>>([]);
|
||||
yield* Stream.runForEach(runtimeReceiptBus.stream, (receipt) =>
|
||||
Ref.update(receiptHistory, (history) => [...history, receipt]).pipe(Effect.asVoid),
|
||||
).pipe(Effect.forkIn(scope));
|
||||
yield* Effect.sleep(10);
|
||||
yield* sleep(10);
|
||||
|
||||
const waitForThread: OrchestrationIntegrationHarness["waitForThread"] = (
|
||||
threadId,
|
||||
@@ -493,7 +468,13 @@ export const makeOrchestrationIntegrationHarness = (
|
||||
}
|
||||
});
|
||||
|
||||
yield* shutdown;
|
||||
yield* shutdown.pipe(
|
||||
Effect.ensuring(
|
||||
Effect.sync(() => {
|
||||
fs.rmSync(rootDir, { recursive: true, force: true });
|
||||
}),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
return {
|
||||
|
||||
@@ -10,7 +10,6 @@ import {
|
||||
ProviderTurnStartResult,
|
||||
ThreadId,
|
||||
TurnId,
|
||||
ProviderKind,
|
||||
} from "@t3tools/contracts";
|
||||
import { Effect, Queue, Stream } from "effect";
|
||||
|
||||
@@ -36,7 +35,7 @@ export interface TestTurnResponse {
|
||||
export type FixtureProviderRuntimeEvent = {
|
||||
readonly type: string;
|
||||
readonly eventId: EventId;
|
||||
readonly provider: ProviderKind;
|
||||
readonly provider: "codex";
|
||||
readonly createdAt: string;
|
||||
readonly threadId: string;
|
||||
readonly turnId?: string | undefined;
|
||||
@@ -178,7 +177,7 @@ function normalizeFixtureEvent(rawEvent: Record<string, unknown>): ProviderRunti
|
||||
|
||||
export interface TestProviderAdapterHarness {
|
||||
readonly adapter: ProviderAdapterShape<ProviderAdapterError>;
|
||||
readonly provider: ProviderKind;
|
||||
readonly provider: "codex";
|
||||
readonly queueTurnResponse: (
|
||||
threadId: ThreadId,
|
||||
response: TestTurnResponse,
|
||||
@@ -198,7 +197,7 @@ export interface TestProviderAdapterHarness {
|
||||
}
|
||||
|
||||
interface MakeTestProviderAdapterHarnessOptions {
|
||||
readonly provider?: ProviderKind;
|
||||
readonly provider?: "codex";
|
||||
}
|
||||
|
||||
function nowIso(): string {
|
||||
@@ -206,7 +205,7 @@ function nowIso(): string {
|
||||
}
|
||||
|
||||
function sessionNotFound(
|
||||
provider: ProviderKind,
|
||||
provider: "codex",
|
||||
threadId: ThreadId,
|
||||
): ProviderAdapterSessionNotFoundError {
|
||||
return new ProviderAdapterSessionNotFoundError({
|
||||
@@ -216,7 +215,7 @@ function sessionNotFound(
|
||||
}
|
||||
|
||||
function missingSessionEffect(
|
||||
provider: ProviderKind,
|
||||
provider: "codex",
|
||||
threadId: ThreadId,
|
||||
): Effect.Effect<never, ProviderAdapterError> {
|
||||
return Effect.fail(sessionNotFound(provider, threadId));
|
||||
|
||||
@@ -73,7 +73,7 @@ export const codexTurnToolFixture = [
|
||||
turnId: TURN_ID,
|
||||
payload: {
|
||||
itemType: "command_execution",
|
||||
title: "Ran command",
|
||||
title: "Command run",
|
||||
detail: "echo integration",
|
||||
},
|
||||
},
|
||||
@@ -85,7 +85,7 @@ export const codexTurnToolFixture = [
|
||||
payload: {
|
||||
itemType: "command_execution",
|
||||
status: "completed",
|
||||
title: "Ran command",
|
||||
title: "Command run",
|
||||
detail: "echo integration",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -5,13 +5,10 @@ import {
|
||||
ApprovalRequestId,
|
||||
CommandId,
|
||||
DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
DEFAULT_MODEL_BY_PROVIDER,
|
||||
EventId,
|
||||
MessageId,
|
||||
ProjectId,
|
||||
ProviderKind,
|
||||
ThreadId,
|
||||
ModelSelection,
|
||||
} from "@t3tools/contracts";
|
||||
import { assert, it } from "@effect/vitest";
|
||||
import { Effect, Option, Schema } from "effect";
|
||||
@@ -28,7 +25,6 @@ import type {
|
||||
CheckpointDiffFinalizedReceipt,
|
||||
TurnProcessingQuiescedReceipt,
|
||||
} from "../src/orchestration/Services/RuntimeReceiptBus.ts";
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
|
||||
const asMessageId = (value: string): MessageId => MessageId.makeUnsafe(value);
|
||||
const asProjectId = (value: string): ProjectId => ProjectId.makeUnsafe(value);
|
||||
@@ -40,7 +36,7 @@ const PROJECT_ID = asProjectId("project-1");
|
||||
const THREAD_ID = ThreadId.makeUnsafe("thread-1");
|
||||
const FIXTURE_TURN_ID = "fixture-turn";
|
||||
const APPROVAL_REQUEST_ID = asApprovalRequestId("req-approval-1");
|
||||
type IntegrationProvider = ProviderKind;
|
||||
type IntegrationProvider = "codex";
|
||||
|
||||
function nowIso() {
|
||||
return new Date().toISOString();
|
||||
@@ -53,11 +49,13 @@ class IntegrationWaitTimeoutError extends Schema.TaggedErrorClass<IntegrationWai
|
||||
},
|
||||
) {}
|
||||
|
||||
const sleep = (ms: number) => Effect.sleep(ms);
|
||||
|
||||
function waitForSync<A>(
|
||||
read: () => A,
|
||||
predicate: (value: A) => boolean,
|
||||
description: string,
|
||||
timeoutMs = 10_000,
|
||||
timeoutMs = 3000,
|
||||
): Effect.Effect<A, never> {
|
||||
return Effect.gen(function* () {
|
||||
const deadline = Date.now() + timeoutMs;
|
||||
@@ -70,7 +68,7 @@ function waitForSync<A>(
|
||||
if (Date.now() >= deadline) {
|
||||
return yield* Effect.die(new IntegrationWaitTimeoutError({ description }));
|
||||
}
|
||||
yield* Effect.sleep(10);
|
||||
yield* sleep(10);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -91,7 +89,7 @@ function withHarness<A, E>(
|
||||
makeOrchestrationIntegrationHarness({ provider }),
|
||||
use,
|
||||
(harness) => harness.dispose,
|
||||
).pipe(Effect.provide(NodeServices.layer));
|
||||
);
|
||||
}
|
||||
|
||||
function withRealCodexHarness<A, E>(
|
||||
@@ -101,14 +99,12 @@ function withRealCodexHarness<A, E>(
|
||||
makeOrchestrationIntegrationHarness({ provider: "codex", realCodex: true }),
|
||||
use,
|
||||
(harness) => harness.dispose,
|
||||
).pipe(Effect.provide(NodeServices.layer));
|
||||
);
|
||||
}
|
||||
|
||||
const seedProjectAndThread = (harness: OrchestrationIntegrationHarness) =>
|
||||
Effect.gen(function* () {
|
||||
const createdAt = nowIso();
|
||||
const provider = harness.adapterHarness?.provider ?? "codex";
|
||||
const defaultModel = DEFAULT_MODEL_BY_PROVIDER[provider];
|
||||
|
||||
yield* harness.engine.dispatch({
|
||||
type: "project.create",
|
||||
@@ -116,10 +112,7 @@ const seedProjectAndThread = (harness: OrchestrationIntegrationHarness) =>
|
||||
projectId: PROJECT_ID,
|
||||
title: "Integration Project",
|
||||
workspaceRoot: harness.workspaceDir,
|
||||
defaultModelSelection: {
|
||||
provider,
|
||||
model: defaultModel,
|
||||
},
|
||||
defaultModel: "gpt-5-codex",
|
||||
createdAt,
|
||||
});
|
||||
|
||||
@@ -129,10 +122,7 @@ const seedProjectAndThread = (harness: OrchestrationIntegrationHarness) =>
|
||||
threadId: THREAD_ID,
|
||||
projectId: PROJECT_ID,
|
||||
title: "Integration Thread",
|
||||
modelSelection: {
|
||||
provider,
|
||||
model: defaultModel,
|
||||
},
|
||||
model: "gpt-5-codex",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
branch: null,
|
||||
@@ -146,7 +136,7 @@ const startTurn = (input: {
|
||||
readonly commandId: string;
|
||||
readonly messageId: string;
|
||||
readonly text: string;
|
||||
readonly modelSelection?: ModelSelection;
|
||||
readonly provider?: IntegrationProvider;
|
||||
}) =>
|
||||
input.harness.engine.dispatch({
|
||||
type: "thread.turn.start",
|
||||
@@ -158,11 +148,7 @@ const startTurn = (input: {
|
||||
text: input.text,
|
||||
attachments: [],
|
||||
},
|
||||
...(input.modelSelection !== undefined
|
||||
? {
|
||||
modelSelection: input.modelSelection,
|
||||
}
|
||||
: {}),
|
||||
...(input.provider !== undefined ? { provider: input.provider } : {}),
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "approval-required",
|
||||
createdAt: nowIso(),
|
||||
@@ -265,10 +251,7 @@ it.live.skipIf(!process.env.CODEX_BINARY_PATH)(
|
||||
projectId: PROJECT_ID,
|
||||
title: "Integration Project",
|
||||
workspaceRoot: harness.workspaceDir,
|
||||
defaultModelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5.3-codex",
|
||||
},
|
||||
defaultModel: "gpt-5.3-codex",
|
||||
createdAt,
|
||||
});
|
||||
|
||||
@@ -278,10 +261,7 @@ it.live.skipIf(!process.env.CODEX_BINARY_PATH)(
|
||||
threadId: THREAD_ID,
|
||||
projectId: PROJECT_ID,
|
||||
title: "Integration Thread",
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5.3-codex",
|
||||
},
|
||||
model: "gpt-5.3-codex",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "full-access",
|
||||
branch: null,
|
||||
@@ -902,435 +882,3 @@ it.live(
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
it.live("starts a claudeAgent 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", "claudeAgent"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
},
|
||||
{
|
||||
type: "message.delta",
|
||||
...runtimeBase("evt-claude-start-2", "2026-02-24T10:10:00.050Z", "claudeAgent"),
|
||||
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", "claudeAgent"),
|
||||
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",
|
||||
modelSelection: {
|
||||
provider: "claudeAgent",
|
||||
model: "claude-sonnet-4-6",
|
||||
},
|
||||
});
|
||||
|
||||
const thread = yield* harness.waitForThread(
|
||||
THREAD_ID,
|
||||
(entry) =>
|
||||
entry.session?.providerName === "claudeAgent" &&
|
||||
entry.session.status === "ready" &&
|
||||
entry.messages.some(
|
||||
(message) => message.role === "assistant" && message.text === "Claude first turn.\n",
|
||||
),
|
||||
);
|
||||
assert.equal(thread.session?.providerName, "claudeAgent");
|
||||
}),
|
||||
"claudeAgent",
|
||||
),
|
||||
);
|
||||
|
||||
it.live("recovers claudeAgent 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", "claudeAgent"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
},
|
||||
{
|
||||
type: "message.delta",
|
||||
...runtimeBase("evt-claude-recover-2", "2026-02-24T10:11:00.050Z", "claudeAgent"),
|
||||
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", "claudeAgent"),
|
||||
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",
|
||||
modelSelection: {
|
||||
provider: "claudeAgent",
|
||||
model: "claude-sonnet-4-6",
|
||||
},
|
||||
});
|
||||
|
||||
yield* harness.waitForThread(
|
||||
THREAD_ID,
|
||||
(entry) =>
|
||||
entry.latestTurn?.turnId === "turn-1" && entry.session?.threadId === "thread-1",
|
||||
);
|
||||
|
||||
yield* harness.adapterHarness!.adapter.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", "claudeAgent"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
},
|
||||
{
|
||||
type: "message.delta",
|
||||
...runtimeBase("evt-claude-recover-5", "2026-02-24T10:11:01.050Z", "claudeAgent"),
|
||||
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", "claudeAgent"),
|
||||
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 === "claudeAgent" &&
|
||||
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, "claudeAgent");
|
||||
assert.equal(recoveredThread.session?.threadId, "thread-1");
|
||||
}),
|
||||
"claudeAgent",
|
||||
),
|
||||
);
|
||||
|
||||
it.live("forwards claudeAgent 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", "claudeAgent"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
},
|
||||
{
|
||||
type: "approval.requested",
|
||||
...runtimeBase("evt-claude-approval-2", "2026-02-24T10:12:00.050Z", "claudeAgent"),
|
||||
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", "claudeAgent"),
|
||||
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",
|
||||
modelSelection: {
|
||||
provider: "claudeAgent",
|
||||
model: "claude-sonnet-4-6",
|
||||
},
|
||||
});
|
||||
|
||||
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");
|
||||
}),
|
||||
"claudeAgent",
|
||||
),
|
||||
);
|
||||
|
||||
it.live("forwards thread.turn.interrupt to claudeAgent 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", "claudeAgent"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
},
|
||||
{
|
||||
type: "message.delta",
|
||||
...runtimeBase("evt-claude-interrupt-2", "2026-02-24T10:13:00.050Z", "claudeAgent"),
|
||||
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", "claudeAgent"),
|
||||
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",
|
||||
modelSelection: {
|
||||
provider: "claudeAgent",
|
||||
model: "claude-sonnet-4-6",
|
||||
},
|
||||
});
|
||||
|
||||
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);
|
||||
}),
|
||||
"claudeAgent",
|
||||
),
|
||||
);
|
||||
|
||||
it.live("reverts claudeAgent 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", "claudeAgent"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
},
|
||||
{
|
||||
type: "message.delta",
|
||||
...runtimeBase("evt-claude-revert-2", "2026-02-24T10:14:00.050Z", "claudeAgent"),
|
||||
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", "claudeAgent"),
|
||||
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",
|
||||
modelSelection: {
|
||||
provider: "claudeAgent",
|
||||
model: "claude-sonnet-4-6",
|
||||
},
|
||||
});
|
||||
|
||||
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", "claudeAgent"),
|
||||
threadId: THREAD_ID,
|
||||
turnId: FIXTURE_TURN_ID,
|
||||
},
|
||||
{
|
||||
type: "message.delta",
|
||||
...runtimeBase("evt-claude-revert-5", "2026-02-24T10:14:01.050Z", "claudeAgent"),
|
||||
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", "claudeAgent"),
|
||||
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 === "claudeAgent",
|
||||
);
|
||||
|
||||
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]);
|
||||
}),
|
||||
"claudeAgent",
|
||||
),
|
||||
);
|
||||
@@ -1,43 +0,0 @@
|
||||
import { readFile, rm } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
|
||||
import { PERF_CATALOG_IDS } from "@t3tools/shared/perf/scenarioCatalog";
|
||||
import { seedPerfState } from "./seedPerfState.ts";
|
||||
|
||||
describe("seedPerfState", () => {
|
||||
const baseDirsToCleanup: string[] = [];
|
||||
|
||||
afterEach(async () => {
|
||||
await Promise.all(
|
||||
baseDirsToCleanup.splice(0).map((baseDir) => rm(baseDir, { recursive: true, force: true })),
|
||||
);
|
||||
});
|
||||
|
||||
it("seeds large thread fixtures through the real event store and projection pipeline", async () => {
|
||||
const seeded = await seedPerfState("large_threads");
|
||||
baseDirsToCleanup.push(seeded.baseDir);
|
||||
|
||||
expect(seeded.snapshot.projects).toHaveLength(1);
|
||||
expect(seeded.snapshot.threads).toHaveLength(12);
|
||||
|
||||
const heavyThread = seeded.snapshot.threads.find(
|
||||
(thread) => thread.id === PERF_CATALOG_IDS.largeThreads.heavyAThreadId,
|
||||
);
|
||||
expect(heavyThread?.messages).toHaveLength(2_000);
|
||||
expect((heavyThread?.activities.length ?? 0) > 0).toBe(true);
|
||||
expect((heavyThread?.proposedPlans.length ?? 0) > 0).toBe(true);
|
||||
expect((heavyThread?.checkpoints.length ?? 0) > 0).toBe(true);
|
||||
});
|
||||
|
||||
it("enables assistant streaming in the burst base seed for websocket perf runs", async () => {
|
||||
const seeded = await seedPerfState("burst_base");
|
||||
baseDirsToCleanup.push(seeded.baseDir);
|
||||
|
||||
const rawSettings = await readFile(join(seeded.baseDir, "userdata/settings.json"), "utf8");
|
||||
expect(JSON.parse(rawSettings)).toMatchObject({
|
||||
enableAssistantStreaming: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,448 +0,0 @@
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { cp, mkdir, mkdtemp, writeFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import {
|
||||
CheckpointRef,
|
||||
CommandId,
|
||||
EventId,
|
||||
type OrchestrationEvent,
|
||||
type OrchestrationReadModel,
|
||||
} from "@t3tools/contracts";
|
||||
import { Effect, Layer, ManagedRuntime } from "effect";
|
||||
|
||||
import {
|
||||
getPerfSeedScenario,
|
||||
perfEventId,
|
||||
perfMessageIdForThread,
|
||||
perfTurnIdForThread,
|
||||
type PerfSeedScenario,
|
||||
type PerfSeedScenarioId,
|
||||
type PerfSeedThreadScenario,
|
||||
} from "@t3tools/shared/perf/scenarioCatalog";
|
||||
import { ServerConfig } from "../../src/config.ts";
|
||||
import { OrchestrationProjectionPipelineLive } from "../../src/orchestration/Layers/ProjectionPipeline.ts";
|
||||
import { OrchestrationProjectionSnapshotQueryLive } from "../../src/orchestration/Layers/ProjectionSnapshotQuery.ts";
|
||||
import { OrchestrationProjectionPipeline } from "../../src/orchestration/Services/ProjectionPipeline.ts";
|
||||
import { ProjectionSnapshotQuery } from "../../src/orchestration/Services/ProjectionSnapshotQuery.ts";
|
||||
import { OrchestrationEventStoreLive } from "../../src/persistence/Layers/OrchestrationEventStore.ts";
|
||||
import { layerConfig as SqlitePersistenceLayerLive } from "../../src/persistence/Layers/Sqlite.ts";
|
||||
import { OrchestrationEventStore } from "../../src/persistence/Services/OrchestrationEventStore.ts";
|
||||
import { ServerSettingsService, ServerSettingsLive } from "../../src/serverSettings.ts";
|
||||
|
||||
export interface PerfSeededState {
|
||||
readonly scenarioId: PerfSeedScenarioId;
|
||||
readonly baseDir: string;
|
||||
readonly workspaceRoot: string;
|
||||
readonly snapshot: OrchestrationReadModel;
|
||||
}
|
||||
|
||||
const templateDirPromises = new Map<PerfSeedScenarioId, Promise<string>>();
|
||||
|
||||
function runGit(cwd: string, args: ReadonlyArray<string>) {
|
||||
execFileSync("git", args, {
|
||||
cwd,
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
encoding: "utf8",
|
||||
});
|
||||
}
|
||||
|
||||
async function initializeGitWorkspace(workspaceRoot: string): Promise<void> {
|
||||
await mkdir(workspaceRoot, { recursive: true });
|
||||
runGit(workspaceRoot, ["init", "--initial-branch=main"]);
|
||||
runGit(workspaceRoot, ["config", "user.email", "[email protected]"]);
|
||||
runGit(workspaceRoot, ["config", "user.name", "Perf Fixture"]);
|
||||
await writeFile(
|
||||
join(workspaceRoot, "README.md"),
|
||||
"# Performance Workspace\n\nSeeded fixture state for local perf regression tests.\n",
|
||||
"utf8",
|
||||
);
|
||||
runGit(workspaceRoot, ["add", "."]);
|
||||
runGit(workspaceRoot, ["commit", "-m", "Initial perf workspace"]);
|
||||
}
|
||||
|
||||
function plusMs(baseTimeMs: number, offsetMs: number): string {
|
||||
return new Date(baseTimeMs + offsetMs).toISOString();
|
||||
}
|
||||
|
||||
function makeCommandId(prefix: string, threadId: string, turnIndex: number): CommandId {
|
||||
return CommandId.makeUnsafe(`${prefix}:${threadId}:${turnIndex.toString().padStart(4, "0")}`);
|
||||
}
|
||||
|
||||
function buildProjectEvent(
|
||||
scenario: PerfSeedScenario,
|
||||
workspaceRoot: string,
|
||||
createdAt: string,
|
||||
): Omit<OrchestrationEvent, "sequence"> {
|
||||
return {
|
||||
type: "project.created",
|
||||
eventId: EventId.makeUnsafe(`perf-project-created:${String(scenario.project.id)}`),
|
||||
aggregateKind: "project",
|
||||
aggregateId: scenario.project.id,
|
||||
occurredAt: createdAt,
|
||||
commandId: CommandId.makeUnsafe(`perf-project-create:${String(scenario.project.id)}`),
|
||||
causationEventId: null,
|
||||
correlationId: CommandId.makeUnsafe(`perf-project-create:${String(scenario.project.id)}`),
|
||||
metadata: {},
|
||||
payload: {
|
||||
projectId: scenario.project.id,
|
||||
title: scenario.project.title,
|
||||
workspaceRoot,
|
||||
defaultModelSelection: scenario.project.defaultModelSelection,
|
||||
scripts: [],
|
||||
createdAt,
|
||||
updatedAt: createdAt,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function buildThreadCreatedEvent(
|
||||
thread: PerfSeedThreadScenario,
|
||||
scenario: PerfSeedScenario,
|
||||
createdAt: string,
|
||||
): Omit<OrchestrationEvent, "sequence"> {
|
||||
return {
|
||||
type: "thread.created",
|
||||
eventId: EventId.makeUnsafe(`perf-thread-created:${String(thread.id)}`),
|
||||
aggregateKind: "thread",
|
||||
aggregateId: thread.id,
|
||||
occurredAt: createdAt,
|
||||
commandId: CommandId.makeUnsafe(`perf-thread-create:${String(thread.id)}`),
|
||||
causationEventId: null,
|
||||
correlationId: CommandId.makeUnsafe(`perf-thread-create:${String(thread.id)}`),
|
||||
metadata: {},
|
||||
payload: {
|
||||
threadId: thread.id,
|
||||
projectId: scenario.project.id,
|
||||
title: thread.title,
|
||||
modelSelection: scenario.project.defaultModelSelection,
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: "default",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
createdAt,
|
||||
updatedAt: createdAt,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function buildUserMessageText(thread: PerfSeedThreadScenario, turnIndex: number): string {
|
||||
const base = `${thread.title} request ${turnIndex}: review the current workspace state and explain the next change.`;
|
||||
if (turnIndex % 11 === 0) {
|
||||
return `${base}\n\nFocus on virtualization, batching, and cross-thread navigation latency.`;
|
||||
}
|
||||
if (turnIndex % 7 === 0) {
|
||||
return `${base}\n\nSummarize CPU-sensitive paths and any websocket burst handling concerns.`;
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
function buildAssistantMessageText(thread: PerfSeedThreadScenario, turnIndex: number): string {
|
||||
const prefix = `${thread.title} response ${turnIndex}: `;
|
||||
const paragraphs = [
|
||||
"The render path stays stable when visible rows are capped and background work is batched.",
|
||||
"Navigation remains predictable when thread metadata, message slices, and work log grouping avoid unnecessary churn.",
|
||||
"Websocket-heavy turns should keep incremental UI updates small so the main thread is free for scrolling and input.",
|
||||
];
|
||||
const paragraphCount = turnIndex % 9 === 0 ? 3 : turnIndex % 4 === 0 ? 2 : 1;
|
||||
return `${prefix}${paragraphs.slice(0, paragraphCount).join(" ")}${
|
||||
turnIndex % 13 === 0
|
||||
? "\n\n- Keep virtual rows bounded\n- Avoid synchronous bursts\n- Preserve responsive thread switches"
|
||||
: ""
|
||||
}`;
|
||||
}
|
||||
|
||||
function buildProposedPlanMarkdown(thread: PerfSeedThreadScenario, turnIndex: number): string {
|
||||
return [
|
||||
`## ${thread.title} plan ${turnIndex}`,
|
||||
"",
|
||||
"1. Measure the current thread switch path against a stable local budget.",
|
||||
"2. Reduce avoidable render churn in the visible timeline window.",
|
||||
"3. Validate websocket burst handling with real runtime events before tightening thresholds.",
|
||||
].join("\n");
|
||||
}
|
||||
|
||||
function buildThreadTurnEvents(
|
||||
scenario: PerfSeedScenario,
|
||||
thread: PerfSeedThreadScenario,
|
||||
threadOrdinal: number,
|
||||
projectStartMs: number,
|
||||
): ReadonlyArray<Omit<OrchestrationEvent, "sequence">> {
|
||||
const events: Array<Omit<OrchestrationEvent, "sequence">> = [];
|
||||
const threadStartMs = projectStartMs + threadOrdinal * 60_000;
|
||||
|
||||
for (let turnIndex = 1; turnIndex <= thread.turnCount; turnIndex += 1) {
|
||||
const turnId = perfTurnIdForThread(thread, turnIndex);
|
||||
const userMessageId = perfMessageIdForThread(thread, "user", turnIndex);
|
||||
const assistantMessageId = perfMessageIdForThread(thread, "assistant", turnIndex);
|
||||
const turnBaseMs = threadStartMs + turnIndex * 1_000;
|
||||
const userOccurredAt = plusMs(turnBaseMs, 0);
|
||||
const assistantOccurredAt = plusMs(turnBaseMs, 320);
|
||||
|
||||
events.push({
|
||||
type: "thread.message-sent",
|
||||
eventId: perfEventId("perf-user-message", thread.id, turnIndex * 10),
|
||||
aggregateKind: "thread",
|
||||
aggregateId: thread.id,
|
||||
occurredAt: userOccurredAt,
|
||||
commandId: makeCommandId("perf-user-message", String(thread.id), turnIndex),
|
||||
causationEventId: null,
|
||||
correlationId: makeCommandId("perf-turn", String(thread.id), turnIndex),
|
||||
metadata: {},
|
||||
payload: {
|
||||
threadId: thread.id,
|
||||
messageId: userMessageId,
|
||||
role: "user",
|
||||
text: buildUserMessageText(thread, turnIndex),
|
||||
attachments: [],
|
||||
turnId,
|
||||
streaming: false,
|
||||
createdAt: userOccurredAt,
|
||||
updatedAt: userOccurredAt,
|
||||
},
|
||||
});
|
||||
|
||||
events.push({
|
||||
type: "thread.message-sent",
|
||||
eventId: perfEventId("perf-assistant-message", thread.id, turnIndex * 10 + 1),
|
||||
aggregateKind: "thread",
|
||||
aggregateId: thread.id,
|
||||
occurredAt: assistantOccurredAt,
|
||||
commandId: makeCommandId("perf-assistant-message", String(thread.id), turnIndex),
|
||||
causationEventId: null,
|
||||
correlationId: makeCommandId("perf-turn", String(thread.id), turnIndex),
|
||||
metadata: {},
|
||||
payload: {
|
||||
threadId: thread.id,
|
||||
messageId: assistantMessageId,
|
||||
role: "assistant",
|
||||
text: buildAssistantMessageText(thread, turnIndex),
|
||||
attachments: [],
|
||||
turnId,
|
||||
streaming: false,
|
||||
createdAt: assistantOccurredAt,
|
||||
updatedAt: assistantOccurredAt,
|
||||
},
|
||||
});
|
||||
|
||||
if (thread.activityStride !== null && turnIndex % thread.activityStride === 0) {
|
||||
const activityOccurredAt = plusMs(turnBaseMs, 520);
|
||||
events.push({
|
||||
type: "thread.activity-appended",
|
||||
eventId: perfEventId("perf-activity", thread.id, turnIndex * 10 + 2),
|
||||
aggregateKind: "thread",
|
||||
aggregateId: thread.id,
|
||||
occurredAt: activityOccurredAt,
|
||||
commandId: makeCommandId("perf-activity", String(thread.id), turnIndex),
|
||||
causationEventId: null,
|
||||
correlationId: makeCommandId("perf-turn", String(thread.id), turnIndex),
|
||||
metadata: {},
|
||||
payload: {
|
||||
threadId: thread.id,
|
||||
activity: {
|
||||
id: perfEventId("perf-activity-row", thread.id, turnIndex),
|
||||
tone: "tool",
|
||||
kind: "tool.completed",
|
||||
summary: `Synthetic command batch ${turnIndex}`,
|
||||
payload: {
|
||||
command: "perf-simulated",
|
||||
batch: turnIndex,
|
||||
threadCategory: thread.category,
|
||||
},
|
||||
turnId,
|
||||
createdAt: activityOccurredAt,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (thread.planStride !== null && turnIndex % thread.planStride === 0) {
|
||||
const planOccurredAt = plusMs(turnBaseMs, 640);
|
||||
events.push({
|
||||
type: "thread.proposed-plan-upserted",
|
||||
eventId: perfEventId("perf-plan", thread.id, turnIndex * 10 + 3),
|
||||
aggregateKind: "thread",
|
||||
aggregateId: thread.id,
|
||||
occurredAt: planOccurredAt,
|
||||
commandId: makeCommandId("perf-plan", String(thread.id), turnIndex),
|
||||
causationEventId: null,
|
||||
correlationId: makeCommandId("perf-turn", String(thread.id), turnIndex),
|
||||
metadata: {},
|
||||
payload: {
|
||||
threadId: thread.id,
|
||||
proposedPlan: {
|
||||
id: `perf-plan:${String(thread.id)}:${turnIndex.toString().padStart(4, "0")}`,
|
||||
turnId,
|
||||
planMarkdown: buildProposedPlanMarkdown(thread, turnIndex),
|
||||
implementedAt: null,
|
||||
implementationThreadId: null,
|
||||
createdAt: planOccurredAt,
|
||||
updatedAt: planOccurredAt,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (thread.diffStride !== null && turnIndex % thread.diffStride === 0) {
|
||||
const diffOccurredAt = plusMs(turnBaseMs, 760);
|
||||
events.push({
|
||||
type: "thread.turn-diff-completed",
|
||||
eventId: perfEventId("perf-diff", thread.id, turnIndex * 10 + 4),
|
||||
aggregateKind: "thread",
|
||||
aggregateId: thread.id,
|
||||
occurredAt: diffOccurredAt,
|
||||
commandId: makeCommandId("perf-diff", String(thread.id), turnIndex),
|
||||
causationEventId: null,
|
||||
correlationId: makeCommandId("perf-turn", String(thread.id), turnIndex),
|
||||
metadata: {},
|
||||
payload: {
|
||||
threadId: thread.id,
|
||||
turnId,
|
||||
checkpointTurnCount: turnIndex,
|
||||
checkpointRef: CheckpointRef.makeUnsafe(
|
||||
`refs/perf/${String(thread.id)}/${turnIndex.toString().padStart(4, "0")}`,
|
||||
),
|
||||
status: "ready",
|
||||
files: [
|
||||
{
|
||||
path: `src/thread-${threadOrdinal + 1}/perf-${turnIndex}.ts`,
|
||||
kind: "modified",
|
||||
additions: 4 + (turnIndex % 6),
|
||||
deletions: 1 + (turnIndex % 3),
|
||||
},
|
||||
{
|
||||
path: `src/thread-${threadOrdinal + 1}/metrics-${turnIndex}.json`,
|
||||
kind: "added",
|
||||
additions: 2 + (turnIndex % 4),
|
||||
deletions: 0,
|
||||
},
|
||||
],
|
||||
assistantMessageId,
|
||||
completedAt: diffOccurredAt,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return events;
|
||||
}
|
||||
|
||||
function buildScenarioEvents(
|
||||
scenario: PerfSeedScenario,
|
||||
workspaceRoot: string,
|
||||
): ReadonlyArray<Omit<OrchestrationEvent, "sequence">> {
|
||||
const projectStartMs = Date.parse("2026-03-01T12:00:00.000Z");
|
||||
const projectCreatedAt = plusMs(projectStartMs, 0);
|
||||
return [
|
||||
buildProjectEvent(scenario, workspaceRoot, projectCreatedAt),
|
||||
...scenario.threads.flatMap((thread, threadOrdinal) => {
|
||||
const threadCreatedAt = plusMs(projectStartMs, threadOrdinal * 60_000 + 50);
|
||||
return [
|
||||
buildThreadCreatedEvent(thread, scenario, threadCreatedAt),
|
||||
...buildThreadTurnEvents(scenario, thread, threadOrdinal, projectStartMs),
|
||||
];
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
async function createTemplateDir(scenarioId: PerfSeedScenarioId): Promise<string> {
|
||||
const scenario = getPerfSeedScenario(scenarioId);
|
||||
const baseDir = await mkdtemp(join(tmpdir(), `t3-perf-template-${scenarioId}-`));
|
||||
const workspaceRoot = join(baseDir, scenario.project.workspaceDirectoryName);
|
||||
await initializeGitWorkspace(workspaceRoot);
|
||||
|
||||
const seedLayer = Layer.empty.pipe(
|
||||
Layer.provideMerge(OrchestrationProjectionSnapshotQueryLive),
|
||||
Layer.provideMerge(OrchestrationProjectionPipelineLive),
|
||||
Layer.provideMerge(OrchestrationEventStoreLive),
|
||||
Layer.provideMerge(ServerSettingsLive),
|
||||
Layer.provideMerge(SqlitePersistenceLayerLive),
|
||||
Layer.provideMerge(ServerConfig.layerTest(workspaceRoot, baseDir)),
|
||||
Layer.provideMerge(NodeServices.layer),
|
||||
);
|
||||
const runtime = ManagedRuntime.make(seedLayer);
|
||||
|
||||
const snapshot = await runtime.runPromise(
|
||||
Effect.gen(function* () {
|
||||
const serverSettings = yield* ServerSettingsService;
|
||||
const eventStore = yield* OrchestrationEventStore;
|
||||
const projectionPipeline = yield* OrchestrationProjectionPipeline;
|
||||
const snapshotQuery = yield* ProjectionSnapshotQuery;
|
||||
|
||||
yield* serverSettings.updateSettings({
|
||||
enableAssistantStreaming: scenario.id === "burst_base",
|
||||
});
|
||||
|
||||
for (const event of buildScenarioEvents(scenario, workspaceRoot)) {
|
||||
const storedEvent = yield* eventStore.append(event);
|
||||
yield* projectionPipeline.projectEvent(storedEvent);
|
||||
}
|
||||
|
||||
return yield* snapshotQuery.getSnapshot();
|
||||
}),
|
||||
);
|
||||
|
||||
const manifestPath = join(baseDir, "perf-seed-manifest.json");
|
||||
await writeFile(
|
||||
manifestPath,
|
||||
`${JSON.stringify(
|
||||
{
|
||||
scenarioId,
|
||||
workspaceRoot,
|
||||
snapshotSequence: snapshot.snapshotSequence,
|
||||
projectCount: snapshot.projects.length,
|
||||
threadCount: snapshot.threads.length,
|
||||
},
|
||||
null,
|
||||
2,
|
||||
)}\n`,
|
||||
"utf8",
|
||||
);
|
||||
|
||||
await runtime.dispose();
|
||||
return baseDir;
|
||||
}
|
||||
|
||||
async function getTemplateDir(scenarioId: PerfSeedScenarioId): Promise<string> {
|
||||
const existing = templateDirPromises.get(scenarioId);
|
||||
if (existing) {
|
||||
return existing;
|
||||
}
|
||||
const created = createTemplateDir(scenarioId);
|
||||
templateDirPromises.set(scenarioId, created);
|
||||
return created;
|
||||
}
|
||||
|
||||
export async function seedPerfState(scenarioId: PerfSeedScenarioId): Promise<PerfSeededState> {
|
||||
const scenario = getPerfSeedScenario(scenarioId);
|
||||
const templateDir = await getTemplateDir(scenarioId);
|
||||
const runParentDir = await mkdtemp(join(tmpdir(), `t3-perf-run-${scenarioId}-`));
|
||||
const baseDir = join(runParentDir, "base");
|
||||
await cp(templateDir, baseDir, { recursive: true, force: true });
|
||||
const workspaceRoot = join(baseDir, scenario.project.workspaceDirectoryName);
|
||||
|
||||
const snapshotLayer = Layer.empty.pipe(
|
||||
Layer.provideMerge(OrchestrationProjectionSnapshotQueryLive),
|
||||
Layer.provideMerge(ServerSettingsLive),
|
||||
Layer.provideMerge(SqlitePersistenceLayerLive),
|
||||
Layer.provideMerge(ServerConfig.layerTest(workspaceRoot, baseDir)),
|
||||
Layer.provideMerge(NodeServices.layer),
|
||||
);
|
||||
const runtime = ManagedRuntime.make(snapshotLayer);
|
||||
const snapshot = await runtime.runPromise(
|
||||
Effect.gen(function* () {
|
||||
const snapshotQuery = yield* ProjectionSnapshotQuery;
|
||||
return yield* snapshotQuery.getSnapshot();
|
||||
}),
|
||||
);
|
||||
await runtime.dispose();
|
||||
|
||||
return {
|
||||
scenarioId,
|
||||
baseDir,
|
||||
workspaceRoot,
|
||||
snapshot,
|
||||
};
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
import type { ProviderRuntimeEvent } from "@t3tools/contracts";
|
||||
import { ThreadId } from "@t3tools/contracts";
|
||||
import { DEFAULT_SERVER_SETTINGS } from "@t3tools/contracts/settings";
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { it, assert } from "@effect/vitest";
|
||||
import { Effect, FileSystem, Layer, Path, Queue, Stream } from "effect";
|
||||
@@ -13,7 +12,6 @@ import {
|
||||
ProviderService,
|
||||
type ProviderServiceShape,
|
||||
} from "../src/provider/Services/ProviderService.ts";
|
||||
import { ServerSettingsService } from "../src/serverSettings.ts";
|
||||
import { AnalyticsService } from "../src/telemetry/Services/AnalyticsService.ts";
|
||||
import { SqlitePersistenceMemory } from "../src/persistence/Layers/Sqlite.ts";
|
||||
import { ProviderSessionRuntimeRepositoryLive } from "../src/persistence/Layers/ProviderSessionRuntime.ts";
|
||||
@@ -62,7 +60,6 @@ const makeIntegrationFixture = Effect.gen(function* () {
|
||||
const shared = Layer.mergeAll(
|
||||
directoryLayer,
|
||||
Layer.succeed(ProviderAdapterRegistry, registry),
|
||||
ServerSettingsService.layerTest(DEFAULT_SERVER_SETTINGS),
|
||||
AnalyticsService.layerTest,
|
||||
).pipe(Layer.provide(SqlitePersistenceMemory));
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"name": "t3",
|
||||
"version": "0.0.15",
|
||||
"license": "MIT",
|
||||
"version": "0.0.9",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pingdotgg/t3code",
|
||||
@@ -19,18 +18,17 @@
|
||||
"build": "node scripts/cli.ts build",
|
||||
"start": "node dist/bin.mjs",
|
||||
"prepare": "effect-language-service patch",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"typecheck": "node scripts/typecheck.mjs",
|
||||
"test": "vitest run"
|
||||
},
|
||||
"dependencies": {
|
||||
"@anthropic-ai/claude-agent-sdk": "^0.2.77",
|
||||
"@effect/platform-bun": "catalog:",
|
||||
"@effect/platform-node": "catalog:",
|
||||
"@effect/sql-sqlite-bun": "catalog:",
|
||||
"@pierre/diffs": "^1.1.0-beta.16",
|
||||
"effect": "catalog:",
|
||||
"node-pty": "^1.1.0",
|
||||
"open": "^10.1.0"
|
||||
"open": "^10.1.0",
|
||||
"ws": "^8.18.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@effect/language-service": "catalog:",
|
||||
@@ -40,11 +38,12 @@
|
||||
"@t3tools/web": "workspace:*",
|
||||
"@types/bun": "catalog:",
|
||||
"@types/node": "catalog:",
|
||||
"@types/ws": "^8.5.13",
|
||||
"tsdown": "catalog:",
|
||||
"typescript": "catalog:",
|
||||
"vitest": "catalog:"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^22.16 || ^23.11 || >=24.10"
|
||||
"node": "^22.13 || ^23.4 || >=24.10"
|
||||
}
|
||||
}
|
||||
@@ -121,6 +121,7 @@ const buildCmd = Command.make(
|
||||
"build",
|
||||
{
|
||||
verbose: Flag.boolean("verbose").pipe(Flag.withDefault(false)),
|
||||
format: Flag.choice("format", ["esm", "cjs"]).pipe(Flag.withDefault("esm")),
|
||||
},
|
||||
(config) =>
|
||||
Effect.gen(function* () {
|
||||
@@ -137,7 +138,7 @@ const buildCmd = Command.make(
|
||||
stderr: "inherit",
|
||||
// Windows needs shell mode to resolve .cmd shims (e.g. bun.cmd).
|
||||
shell: process.platform === "win32",
|
||||
})`bun tsdown`,
|
||||
})`bun tsdown --format ${config.format}`,
|
||||
);
|
||||
|
||||
const webDist = path.join(repoRoot, "apps/web/dist");
|
||||
@@ -177,7 +178,7 @@ const publishCmd = Command.make(
|
||||
const backupPath = `${packageJsonPath}.bak`;
|
||||
|
||||
// Assert build assets exist
|
||||
for (const relPath of ["dist/index.mjs", "dist/client/index.html"]) {
|
||||
for (const relPath of ["dist/bin.mjs", "dist/client/index.html"]) {
|
||||
const abs = path.join(serverDir, relPath);
|
||||
if (!(yield* fs.exists(abs))) {
|
||||
return yield* new CliError({
|
||||
@@ -195,8 +196,10 @@ const publishCmd = Command.make(
|
||||
const pkg = {
|
||||
name: serverPackageJson.name,
|
||||
repository: serverPackageJson.repository,
|
||||
bin: serverPackageJson.bin,
|
||||
type: serverPackageJson.type,
|
||||
bin: {
|
||||
t3: "./dist/bin.mjs",
|
||||
},
|
||||
version,
|
||||
engines: serverPackageJson.engines,
|
||||
files: serverPackageJson.files,
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
import { seedPerfState } from "../integration/perf/seedPerfState.ts";
|
||||
|
||||
const PERF_SEED_JSON_START = "__T3_PERF_SEED_JSON_START__";
|
||||
const PERF_SEED_JSON_END = "__T3_PERF_SEED_JSON_END__";
|
||||
const scenarioId = process.argv[2];
|
||||
|
||||
if (scenarioId !== "large_threads" && scenarioId !== "burst_base") {
|
||||
console.error(`Expected a perf seed scenario id, received '${scenarioId ?? "<missing>"}'.`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const seeded = await seedPerfState(scenarioId);
|
||||
const payload = JSON.stringify(
|
||||
{
|
||||
scenarioId: seeded.scenarioId,
|
||||
baseDir: seeded.baseDir,
|
||||
workspaceRoot: seeded.workspaceRoot,
|
||||
projectTitle: seeded.snapshot.projects[0]?.title ?? null,
|
||||
threadSummaries: seeded.snapshot.threads.map((thread) => ({
|
||||
id: thread.id,
|
||||
title: thread.title,
|
||||
messageCount: thread.messages.length,
|
||||
activityCount: thread.activities.length,
|
||||
proposedPlanCount: thread.proposedPlans.length,
|
||||
checkpointCount: thread.checkpoints.length,
|
||||
})),
|
||||
},
|
||||
null,
|
||||
2,
|
||||
);
|
||||
process.stdout.write(`${PERF_SEED_JSON_START}\n${payload}\n${PERF_SEED_JSON_END}\n`);
|
||||
@@ -0,0 +1,42 @@
|
||||
import { spawn } from "node:child_process";
|
||||
import { createRequire } from "node:module";
|
||||
import path from "node:path";
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const tscPath = require.resolve("typescript/bin/tsc");
|
||||
const cwd = path.resolve(import.meta.dirname, "..");
|
||||
|
||||
const child = spawn(process.execPath, [tscPath, "--noEmit"], {
|
||||
cwd,
|
||||
env: process.env,
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
});
|
||||
|
||||
let output = "";
|
||||
|
||||
child.stdout.on("data", (chunk) => {
|
||||
const text = chunk.toString();
|
||||
output += text;
|
||||
process.stdout.write(text);
|
||||
});
|
||||
|
||||
child.stderr.on("data", (chunk) => {
|
||||
const text = chunk.toString();
|
||||
output += text;
|
||||
process.stderr.write(text);
|
||||
});
|
||||
|
||||
child.on("exit", (code, signal) => {
|
||||
if (signal) {
|
||||
process.kill(process.pid, signal);
|
||||
return;
|
||||
}
|
||||
|
||||
if (code === 0) {
|
||||
process.exit(0);
|
||||
return;
|
||||
}
|
||||
|
||||
const hasTypeScriptErrors = /error TS\d+:/.test(output);
|
||||
process.exit(hasTypeScriptErrors ? (code ?? 1) : 0);
|
||||
});
|
||||
@@ -11,7 +11,7 @@ export function normalizeAttachmentRelativePath(rawRelativePath: string): string
|
||||
}
|
||||
|
||||
export function resolveAttachmentRelativePath(input: {
|
||||
readonly attachmentsDir: string;
|
||||
readonly stateDir: string;
|
||||
readonly relativePath: string;
|
||||
}): string | null {
|
||||
const normalizedRelativePath = normalizeAttachmentRelativePath(input.relativePath);
|
||||
@@ -19,7 +19,7 @@ export function resolveAttachmentRelativePath(input: {
|
||||
return null;
|
||||
}
|
||||
|
||||
const attachmentsRoot = path.resolve(input.attachmentsDir);
|
||||
const attachmentsRoot = path.resolve(path.join(input.stateDir, "attachments"));
|
||||
const filePath = path.resolve(path.join(attachmentsRoot, normalizedRelativePath));
|
||||
if (!filePath.startsWith(`${attachmentsRoot}${path.sep}`)) {
|
||||
return null;
|
||||
|
||||
@@ -44,32 +44,34 @@ describe("attachmentStore", () => {
|
||||
});
|
||||
|
||||
it("resolves attachment path by id using the extension that exists on disk", () => {
|
||||
const attachmentsDir = fs.mkdtempSync(path.join(os.tmpdir(), "t3code-attachment-store-"));
|
||||
const stateDir = fs.mkdtempSync(path.join(os.tmpdir(), "t3code-attachment-store-"));
|
||||
try {
|
||||
const attachmentId = "thread-1-attachment";
|
||||
const attachmentsDir = path.join(stateDir, "attachments");
|
||||
fs.mkdirSync(attachmentsDir, { recursive: true });
|
||||
const pngPath = path.join(attachmentsDir, `${attachmentId}.png`);
|
||||
fs.writeFileSync(pngPath, Buffer.from("hello"));
|
||||
|
||||
const resolved = resolveAttachmentPathById({
|
||||
attachmentsDir,
|
||||
stateDir,
|
||||
attachmentId,
|
||||
});
|
||||
expect(resolved).toBe(pngPath);
|
||||
} finally {
|
||||
fs.rmSync(attachmentsDir, { recursive: true, force: true });
|
||||
fs.rmSync(stateDir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
it("returns null when no attachment file exists for the id", () => {
|
||||
const attachmentsDir = fs.mkdtempSync(path.join(os.tmpdir(), "t3code-attachment-store-"));
|
||||
const stateDir = fs.mkdtempSync(path.join(os.tmpdir(), "t3code-attachment-store-"));
|
||||
try {
|
||||
const resolved = resolveAttachmentPathById({
|
||||
attachmentsDir,
|
||||
stateDir,
|
||||
attachmentId: "thread-1-missing",
|
||||
});
|
||||
expect(resolved).toBeNull();
|
||||
} finally {
|
||||
fs.rmSync(attachmentsDir, { recursive: true, force: true });
|
||||
fs.rmSync(stateDir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -66,17 +66,17 @@ export function attachmentRelativePath(attachment: ChatAttachment): string {
|
||||
}
|
||||
|
||||
export function resolveAttachmentPath(input: {
|
||||
readonly attachmentsDir: string;
|
||||
readonly stateDir: string;
|
||||
readonly attachment: ChatAttachment;
|
||||
}): string | null {
|
||||
return resolveAttachmentRelativePath({
|
||||
attachmentsDir: input.attachmentsDir,
|
||||
stateDir: input.stateDir,
|
||||
relativePath: attachmentRelativePath(input.attachment),
|
||||
});
|
||||
}
|
||||
|
||||
export function resolveAttachmentPathById(input: {
|
||||
readonly attachmentsDir: string;
|
||||
readonly stateDir: string;
|
||||
readonly attachmentId: string;
|
||||
}): string | null {
|
||||
const normalizedId = normalizeAttachmentRelativePath(input.attachmentId);
|
||||
@@ -85,7 +85,7 @@ export function resolveAttachmentPathById(input: {
|
||||
}
|
||||
for (const extension of ATTACHMENT_FILENAME_EXTENSIONS) {
|
||||
const maybePath = resolveAttachmentRelativePath({
|
||||
attachmentsDir: input.attachmentsDir,
|
||||
stateDir: input.stateDir,
|
||||
relativePath: `${normalizedId}${extension}`,
|
||||
});
|
||||
if (maybePath && existsSync(maybePath)) {
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Layer from "effect/Layer";
|
||||
import { Command } from "effect/unstable/cli";
|
||||
|
||||
import { NetService } from "@t3tools/shared/Net";
|
||||
import { cli } from "./cli";
|
||||
import { t3Cli } from "./cli";
|
||||
import { version } from "../package.json" with { type: "json" };
|
||||
|
||||
const CliRuntimeLayer = Layer.mergeAll(NodeServices.layer, NetService.layer);
|
||||
const main = Command.run(t3Cli, { version }).pipe(
|
||||
Effect.provide(NodeServices.layer),
|
||||
) as Effect.Effect<void, unknown, never>;
|
||||
|
||||
Command.run(cli, { version }).pipe(
|
||||
Effect.scoped,
|
||||
Effect.provide(CliRuntimeLayer),
|
||||
NodeRuntime.runMain,
|
||||
);
|
||||
NodeRuntime.runMain(main);
|
||||
@@ -1,149 +0,0 @@
|
||||
import * as NFS from "node:fs";
|
||||
import * as path from "node:path";
|
||||
import { execFileSync, spawn } from "node:child_process";
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { assert, it } from "@effect/vitest";
|
||||
import { FileSystem, Schema } from "effect";
|
||||
import * as Duration from "effect/Duration";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Fiber from "effect/Fiber";
|
||||
import { TestClock } from "effect/testing";
|
||||
import { vi } from "vitest";
|
||||
|
||||
import { readBootstrapEnvelope, resolveFdPath } from "./bootstrap";
|
||||
import { assertNone, assertSome } from "@effect/vitest/utils";
|
||||
|
||||
const openSyncInterceptor = vi.hoisted(() => ({ failPath: null as string | null }));
|
||||
|
||||
vi.mock("node:fs", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("node:fs")>();
|
||||
return {
|
||||
...actual,
|
||||
openSync: (...args: Parameters<typeof actual.openSync>) => {
|
||||
const [filePath, flags] = args;
|
||||
if (
|
||||
typeof filePath === "string" &&
|
||||
filePath === openSyncInterceptor.failPath &&
|
||||
flags === "r"
|
||||
) {
|
||||
const error = new Error("no such device or address");
|
||||
Object.assign(error, { code: "ENXIO" });
|
||||
throw error;
|
||||
}
|
||||
return (actual.openSync as (...a: typeof args) => number)(...args);
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
const TestEnvelopeSchema = Schema.Struct({ mode: Schema.String });
|
||||
|
||||
it.layer(NodeServices.layer)("readBootstrapEnvelope", (it) => {
|
||||
it.effect("uses platform-specific fd paths", () =>
|
||||
Effect.sync(() => {
|
||||
assert.equal(resolveFdPath(3, "linux"), "/proc/self/fd/3");
|
||||
assert.equal(resolveFdPath(3, "darwin"), "/dev/fd/3");
|
||||
assert.equal(resolveFdPath(3, "win32"), undefined);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("reads a bootstrap envelope from a provided fd", () =>
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const filePath = yield* fs.makeTempFileScoped({ prefix: "t3-bootstrap-", suffix: ".ndjson" });
|
||||
|
||||
yield* fs.writeFileString(
|
||||
filePath,
|
||||
`${yield* Schema.encodeEffect(Schema.fromJsonString(TestEnvelopeSchema))({
|
||||
mode: "desktop",
|
||||
})}\n`,
|
||||
);
|
||||
|
||||
const fd = yield* Effect.acquireRelease(
|
||||
Effect.sync(() => NFS.openSync(filePath, "r")),
|
||||
(fd) => Effect.sync(() => NFS.closeSync(fd)),
|
||||
);
|
||||
|
||||
const payload = yield* readBootstrapEnvelope(TestEnvelopeSchema, fd, { timeoutMs: 100 });
|
||||
assertSome(payload, {
|
||||
mode: "desktop",
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("falls back to reading the inherited fd when path duplication fails", () =>
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const filePath = yield* fs.makeTempFileScoped({ prefix: "t3-bootstrap-", suffix: ".ndjson" });
|
||||
|
||||
yield* fs.writeFileString(
|
||||
filePath,
|
||||
`${yield* Schema.encodeEffect(Schema.fromJsonString(TestEnvelopeSchema))({
|
||||
mode: "desktop",
|
||||
})}\n`,
|
||||
);
|
||||
|
||||
// Open without acquireRelease: the direct-stream fallback uses autoClose: true,
|
||||
// so the stream owns the fd lifecycle and closes it asynchronously on end.
|
||||
// Attempting to also close it synchronously in a finalizer races with the
|
||||
// stream's async close and produces an uncaught EBADF.
|
||||
const fd = NFS.openSync(filePath, "r");
|
||||
|
||||
openSyncInterceptor.failPath = `/proc/self/fd/${fd}`;
|
||||
try {
|
||||
const payload = yield* readBootstrapEnvelope(TestEnvelopeSchema, fd, { timeoutMs: 100 });
|
||||
assertSome(payload, {
|
||||
mode: "desktop",
|
||||
});
|
||||
} finally {
|
||||
openSyncInterceptor.failPath = null;
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("returns none when the fd is unavailable", () =>
|
||||
Effect.gen(function* () {
|
||||
const fd = NFS.openSync("/dev/null", "r");
|
||||
NFS.closeSync(fd);
|
||||
|
||||
const payload = yield* readBootstrapEnvelope(TestEnvelopeSchema, fd, { timeoutMs: 100 });
|
||||
assertNone(payload);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("returns none when the bootstrap read times out before any value arrives", () =>
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-bootstrap-" });
|
||||
const fifoPath = path.join(tempDir, "bootstrap.pipe");
|
||||
|
||||
yield* Effect.sync(() => execFileSync("mkfifo", [fifoPath]));
|
||||
|
||||
const _writer = yield* Effect.acquireRelease(
|
||||
Effect.sync(() =>
|
||||
spawn("sh", ["-c", 'exec 3>"$1"; sleep 60', "sh", fifoPath], {
|
||||
stdio: ["ignore", "ignore", "ignore"],
|
||||
}),
|
||||
),
|
||||
(writer) =>
|
||||
Effect.sync(() => {
|
||||
writer.kill("SIGKILL");
|
||||
}),
|
||||
);
|
||||
|
||||
const fd = yield* Effect.acquireRelease(
|
||||
Effect.sync(() => NFS.openSync(fifoPath, "r")),
|
||||
(fd) => Effect.sync(() => NFS.closeSync(fd)),
|
||||
);
|
||||
|
||||
const fiber = yield* readBootstrapEnvelope(TestEnvelopeSchema, fd, {
|
||||
timeoutMs: 100,
|
||||
}).pipe(Effect.forkScoped);
|
||||
|
||||
yield* Effect.yieldNow;
|
||||
yield* TestClock.adjust(Duration.millis(100));
|
||||
|
||||
const payload = yield* Fiber.join(fiber);
|
||||
assertNone(payload);
|
||||
}).pipe(Effect.provide(TestClock.layer())),
|
||||
);
|
||||
});
|
||||
@@ -1,173 +0,0 @@
|
||||
import * as NFS from "node:fs";
|
||||
import * as Net from "node:net";
|
||||
import * as readline from "node:readline";
|
||||
import type { Readable } from "node:stream";
|
||||
|
||||
import { Data, Effect, Option, Predicate, Result, Schema } from "effect";
|
||||
import { decodeJsonResult } from "@t3tools/shared/schemaJson";
|
||||
|
||||
class BootstrapError extends Data.TaggedError("BootstrapError")<{
|
||||
readonly message: string;
|
||||
readonly cause?: unknown;
|
||||
}> {}
|
||||
|
||||
export const readBootstrapEnvelope = Effect.fn("readBootstrapEnvelope")(function* <A, I>(
|
||||
schema: Schema.Codec<A, I>,
|
||||
fd: number,
|
||||
options?: {
|
||||
timeoutMs?: number;
|
||||
},
|
||||
): Effect.fn.Return<Option.Option<A>, BootstrapError> {
|
||||
const fdReady = yield* isFdReady(fd);
|
||||
if (!fdReady) return Option.none();
|
||||
|
||||
const stream = yield* makeBootstrapInputStream(fd);
|
||||
|
||||
const timeoutMs = options?.timeoutMs ?? 1000;
|
||||
|
||||
return yield* Effect.callback<Option.Option<A>, BootstrapError>((resume) => {
|
||||
const input = readline.createInterface({
|
||||
input: stream,
|
||||
crlfDelay: Infinity,
|
||||
});
|
||||
|
||||
const cleanup = () => {
|
||||
stream.removeListener("error", handleError);
|
||||
input.removeListener("line", handleLine);
|
||||
input.removeListener("close", handleClose);
|
||||
input.close();
|
||||
stream.destroy();
|
||||
};
|
||||
|
||||
const handleError = (error: Error) => {
|
||||
if (isUnavailableBootstrapFdError(error)) {
|
||||
resume(Effect.succeedNone);
|
||||
return;
|
||||
}
|
||||
resume(
|
||||
Effect.fail(
|
||||
new BootstrapError({
|
||||
message: "Failed to read bootstrap envelope.",
|
||||
cause: error,
|
||||
}),
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
const handleLine = (line: string) => {
|
||||
const parsed = decodeJsonResult(schema)(line);
|
||||
if (Result.isSuccess(parsed)) {
|
||||
resume(Effect.succeedSome(parsed.success));
|
||||
} else {
|
||||
resume(
|
||||
Effect.fail(
|
||||
new BootstrapError({
|
||||
message: "Failed to decode bootstrap envelope.",
|
||||
cause: parsed.failure,
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const handleClose = () => {
|
||||
resume(Effect.succeedNone);
|
||||
};
|
||||
|
||||
stream.once("error", handleError);
|
||||
input.once("line", handleLine);
|
||||
input.once("close", handleClose);
|
||||
|
||||
return Effect.sync(cleanup);
|
||||
}).pipe(Effect.timeoutOption(timeoutMs), Effect.map(Option.flatten));
|
||||
});
|
||||
|
||||
const isUnavailableBootstrapFdError = Predicate.compose(
|
||||
Predicate.hasProperty("code"),
|
||||
(_) => _.code === "EBADF" || _.code === "ENOENT",
|
||||
);
|
||||
|
||||
const isFdReady = (fd: number) =>
|
||||
Effect.try({
|
||||
try: () => NFS.fstatSync(fd),
|
||||
catch: (error) =>
|
||||
new BootstrapError({
|
||||
message: "Failed to stat bootstrap fd.",
|
||||
cause: error,
|
||||
}),
|
||||
}).pipe(
|
||||
Effect.as(true),
|
||||
Effect.catchIf(
|
||||
(error) => isUnavailableBootstrapFdError(error.cause),
|
||||
() => Effect.succeed(false),
|
||||
),
|
||||
);
|
||||
|
||||
const makeBootstrapInputStream = (fd: number) =>
|
||||
Effect.try<Readable, BootstrapError>({
|
||||
try: () => {
|
||||
const fdPath = resolveFdPath(fd);
|
||||
if (fdPath === undefined) {
|
||||
return makeDirectBootstrapStream(fd);
|
||||
}
|
||||
|
||||
let streamFd: number | undefined;
|
||||
try {
|
||||
streamFd = NFS.openSync(fdPath, "r");
|
||||
return NFS.createReadStream("", {
|
||||
fd: streamFd,
|
||||
encoding: "utf8",
|
||||
autoClose: true,
|
||||
});
|
||||
} catch (error) {
|
||||
if (isBootstrapFdPathDuplicationError(error)) {
|
||||
if (streamFd !== undefined) {
|
||||
NFS.closeSync(streamFd);
|
||||
}
|
||||
return makeDirectBootstrapStream(fd);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
catch: (error) =>
|
||||
new BootstrapError({
|
||||
message: "Failed to duplicate bootstrap fd.",
|
||||
cause: error,
|
||||
}),
|
||||
});
|
||||
|
||||
const makeDirectBootstrapStream = (fd: number): Readable => {
|
||||
try {
|
||||
return NFS.createReadStream("", {
|
||||
fd,
|
||||
encoding: "utf8",
|
||||
autoClose: true,
|
||||
});
|
||||
} catch {
|
||||
const stream = new Net.Socket({
|
||||
fd,
|
||||
readable: true,
|
||||
writable: false,
|
||||
});
|
||||
stream.setEncoding("utf8");
|
||||
return stream;
|
||||
}
|
||||
};
|
||||
|
||||
const isBootstrapFdPathDuplicationError = Predicate.compose(
|
||||
Predicate.hasProperty("code"),
|
||||
(_) => _.code === "ENXIO" || _.code === "EINVAL" || _.code === "EPERM",
|
||||
);
|
||||
|
||||
export function resolveFdPath(
|
||||
fd: number,
|
||||
platform: NodeJS.Platform = process.platform,
|
||||
): string | undefined {
|
||||
if (platform === "linux") {
|
||||
return `/proc/self/fd/${fd}`;
|
||||
}
|
||||
if (platform === "win32") {
|
||||
return undefined;
|
||||
}
|
||||
return `/dev/fd/${fd}`;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Schema } from "effect";
|
||||
import type { ProjectionRepositoryError } from "../persistence/Errors.ts";
|
||||
import { GitCommandError } from "@t3tools/contracts";
|
||||
import { GitCommandError } from "../git/Errors.ts";
|
||||
|
||||
/**
|
||||
* CheckpointUnavailableError - Expected checkpoint does not exist.
|
||||
|
||||
@@ -31,7 +31,7 @@ function makeSnapshot(input: {
|
||||
id: input.projectId,
|
||||
title: "Project",
|
||||
workspaceRoot: input.workspaceRoot,
|
||||
defaultModelSelection: null,
|
||||
defaultModel: null,
|
||||
scripts: [],
|
||||
createdAt: "2026-01-01T00:00:00.000Z",
|
||||
updatedAt: "2026-01-01T00:00:00.000Z",
|
||||
@@ -43,10 +43,7 @@ function makeSnapshot(input: {
|
||||
id: input.threadId,
|
||||
projectId: input.projectId,
|
||||
title: "Thread",
|
||||
modelSelection: {
|
||||
provider: "codex",
|
||||
model: "gpt-5-codex",
|
||||
},
|
||||
model: "gpt-5-codex",
|
||||
interactionMode: DEFAULT_PROVIDER_INTERACTION_MODE,
|
||||
runtimeMode: "full-access",
|
||||
branch: null,
|
||||
@@ -61,7 +58,6 @@ function makeSnapshot(input: {
|
||||
},
|
||||
createdAt: "2026-01-01T00:00:00.000Z",
|
||||
updatedAt: "2026-01-01T00:00:00.000Z",
|
||||
archivedAt: null,
|
||||
deletedAt: null,
|
||||
messages: [],
|
||||
activities: [],
|
||||
|
||||
@@ -21,8 +21,8 @@ const make = Effect.gen(function* () {
|
||||
const projectionSnapshotQuery = yield* ProjectionSnapshotQuery;
|
||||
const checkpointStore = yield* CheckpointStore;
|
||||
|
||||
const getTurnDiff: CheckpointDiffQueryShape["getTurnDiff"] = Effect.fn("getTurnDiff")(
|
||||
function* (input) {
|
||||
const getTurnDiff: CheckpointDiffQueryShape["getTurnDiff"] = (input) =>
|
||||
Effect.gen(function* () {
|
||||
const operation = "CheckpointDiffQuery.getTurnDiff";
|
||||
|
||||
if (input.fromTurnCount === input.toTurnCount) {
|
||||
@@ -149,8 +149,7 @@ const make = Effect.gen(function* () {
|
||||
}
|
||||
|
||||
return turnDiff;
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
const getFullThreadDiff: CheckpointDiffQueryShape["getFullThreadDiff"] = (
|
||||
input: OrchestrationGetFullThreadDiffInput,
|
||||
|
||||
@@ -1,122 +0,0 @@
|
||||
import path from "node:path";
|
||||
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { it } from "@effect/vitest";
|
||||
import { Effect, FileSystem, Layer, PlatformError, Scope } from "effect";
|
||||
import { describe, expect } from "vitest";
|
||||
|
||||
import { checkpointRefForThreadTurn } from "../Utils.ts";
|
||||
import { CheckpointStoreLive } from "./CheckpointStore.ts";
|
||||
import { CheckpointStore } from "../Services/CheckpointStore.ts";
|
||||
import { GitCoreLive } from "../../git/Layers/GitCore.ts";
|
||||
import { GitCore } from "../../git/Services/GitCore.ts";
|
||||
import { GitCommandError } from "@t3tools/contracts";
|
||||
import { ServerConfig } from "../../config.ts";
|
||||
import { ThreadId } from "@t3tools/contracts";
|
||||
|
||||
const ServerConfigLayer = ServerConfig.layerTest(process.cwd(), {
|
||||
prefix: "t3-checkpoint-store-test-",
|
||||
});
|
||||
const GitCoreTestLayer = GitCoreLive.pipe(
|
||||
Layer.provide(ServerConfigLayer),
|
||||
Layer.provide(NodeServices.layer),
|
||||
);
|
||||
const CheckpointStoreTestLayer = CheckpointStoreLive.pipe(
|
||||
Layer.provide(GitCoreTestLayer),
|
||||
Layer.provide(NodeServices.layer),
|
||||
);
|
||||
const TestLayer = Layer.mergeAll(NodeServices.layer, GitCoreTestLayer, CheckpointStoreTestLayer);
|
||||
|
||||
function makeTmpDir(
|
||||
prefix = "checkpoint-store-test-",
|
||||
): Effect.Effect<string, PlatformError.PlatformError, FileSystem.FileSystem | Scope.Scope> {
|
||||
return Effect.gen(function* () {
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
return yield* fileSystem.makeTempDirectoryScoped({ prefix });
|
||||
});
|
||||
}
|
||||
|
||||
function writeTextFile(
|
||||
filePath: string,
|
||||
contents: string,
|
||||
): Effect.Effect<void, PlatformError.PlatformError, FileSystem.FileSystem> {
|
||||
return Effect.gen(function* () {
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
yield* fileSystem.writeFileString(filePath, contents);
|
||||
});
|
||||
}
|
||||
|
||||
function git(
|
||||
cwd: string,
|
||||
args: ReadonlyArray<string>,
|
||||
): Effect.Effect<string, GitCommandError, GitCore> {
|
||||
return Effect.gen(function* () {
|
||||
const gitCore = yield* GitCore;
|
||||
const result = yield* gitCore.execute({
|
||||
operation: "CheckpointStore.test.git",
|
||||
cwd,
|
||||
args,
|
||||
timeoutMs: 10_000,
|
||||
});
|
||||
return result.stdout.trim();
|
||||
});
|
||||
}
|
||||
|
||||
function initRepoWithCommit(
|
||||
cwd: string,
|
||||
): Effect.Effect<
|
||||
void,
|
||||
GitCommandError | PlatformError.PlatformError,
|
||||
GitCore | FileSystem.FileSystem
|
||||
> {
|
||||
return Effect.gen(function* () {
|
||||
const core = yield* GitCore;
|
||||
yield* core.initRepo({ cwd });
|
||||
yield* git(cwd, ["config", "user.email", "[email protected]"]);
|
||||
yield* git(cwd, ["config", "user.name", "Test"]);
|
||||
yield* writeTextFile(path.join(cwd, "README.md"), "# test\n");
|
||||
yield* git(cwd, ["add", "."]);
|
||||
yield* git(cwd, ["commit", "-m", "initial commit"]);
|
||||
});
|
||||
}
|
||||
|
||||
function buildLargeText(lineCount = 20_000): string {
|
||||
return Array.from({ length: lineCount }, (_, index) => `line ${String(index).padStart(5, "0")}`)
|
||||
.join("\n")
|
||||
.concat("\n");
|
||||
}
|
||||
|
||||
it.layer(TestLayer)("CheckpointStoreLive", (it) => {
|
||||
describe("diffCheckpoints", () => {
|
||||
it.effect("returns full oversized checkpoint diffs without truncation", () =>
|
||||
Effect.gen(function* () {
|
||||
const tmp = yield* makeTmpDir();
|
||||
yield* initRepoWithCommit(tmp);
|
||||
const checkpointStore = yield* CheckpointStore;
|
||||
const threadId = ThreadId.makeUnsafe("thread-checkpoint-store");
|
||||
const fromCheckpointRef = checkpointRefForThreadTurn(threadId, 0);
|
||||
const toCheckpointRef = checkpointRefForThreadTurn(threadId, 1);
|
||||
|
||||
yield* checkpointStore.captureCheckpoint({
|
||||
cwd: tmp,
|
||||
checkpointRef: fromCheckpointRef,
|
||||
});
|
||||
yield* writeTextFile(path.join(tmp, "README.md"), buildLargeText());
|
||||
yield* checkpointStore.captureCheckpoint({
|
||||
cwd: tmp,
|
||||
checkpointRef: toCheckpointRef,
|
||||
});
|
||||
|
||||
const diff = yield* checkpointStore.diffCheckpoints({
|
||||
cwd: tmp,
|
||||
fromCheckpointRef,
|
||||
toCheckpointRef,
|
||||
});
|
||||
|
||||
expect(diff).toContain("diff --git");
|
||||
expect(diff).not.toContain("[truncated]");
|
||||
expect(diff).toContain("+line 19999");
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -14,15 +14,16 @@ import { randomUUID } from "node:crypto";
|
||||
import { Effect, Layer, FileSystem, Path } from "effect";
|
||||
|
||||
import { CheckpointInvariantError } from "../Errors.ts";
|
||||
import { GitCommandError } from "@t3tools/contracts";
|
||||
import { GitCore } from "../../git/Services/GitCore.ts";
|
||||
import { GitCommandError } from "../../git/Errors.ts";
|
||||
import { GitServiceLive } from "../../git/Layers/GitService.ts";
|
||||
import { GitService } from "../../git/Services/GitService.ts";
|
||||
import { CheckpointStore, type CheckpointStoreShape } from "../Services/CheckpointStore.ts";
|
||||
import { CheckpointRef } from "@t3tools/contracts";
|
||||
|
||||
const makeCheckpointStore = Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const git = yield* GitCore;
|
||||
const git = yield* GitService;
|
||||
|
||||
const resolveHeadCommit = (cwd: string): Effect.Effect<string | null, GitCommandError> =>
|
||||
git
|
||||
@@ -86,140 +87,139 @@ const makeCheckpointStore = Effect.gen(function* () {
|
||||
Effect.catch(() => Effect.succeed(false)),
|
||||
);
|
||||
|
||||
const captureCheckpoint: CheckpointStoreShape["captureCheckpoint"] = Effect.fn(
|
||||
"captureCheckpoint",
|
||||
)(function* (input) {
|
||||
const operation = "CheckpointStore.captureCheckpoint";
|
||||
const captureCheckpoint: CheckpointStoreShape["captureCheckpoint"] = (input) =>
|
||||
Effect.gen(function* () {
|
||||
const operation = "CheckpointStore.captureCheckpoint";
|
||||
|
||||
yield* Effect.acquireUseRelease(
|
||||
fs.makeTempDirectory({ prefix: "t3-fs-checkpoint-" }),
|
||||
Effect.fn("captureCheckpoint.withTempDirectory")(function* (tempDir) {
|
||||
const tempIndexPath = path.join(tempDir, `index-${randomUUID()}`);
|
||||
const commitEnv: NodeJS.ProcessEnv = {
|
||||
...process.env,
|
||||
GIT_INDEX_FILE: tempIndexPath,
|
||||
GIT_AUTHOR_NAME: "T3 Code",
|
||||
GIT_AUTHOR_EMAIL: "[email protected]",
|
||||
GIT_COMMITTER_NAME: "T3 Code",
|
||||
GIT_COMMITTER_EMAIL: "[email protected]",
|
||||
};
|
||||
yield* Effect.acquireUseRelease(
|
||||
fs.makeTempDirectory({ prefix: "t3-fs-checkpoint-" }),
|
||||
(tempDir) =>
|
||||
Effect.gen(function* () {
|
||||
const tempIndexPath = path.join(tempDir, `index-${randomUUID()}`);
|
||||
const commitEnv: NodeJS.ProcessEnv = {
|
||||
...process.env,
|
||||
GIT_INDEX_FILE: tempIndexPath,
|
||||
GIT_AUTHOR_NAME: "T3 Code",
|
||||
GIT_AUTHOR_EMAIL: "[email protected]",
|
||||
GIT_COMMITTER_NAME: "T3 Code",
|
||||
GIT_COMMITTER_EMAIL: "[email protected]",
|
||||
};
|
||||
|
||||
const headExists = yield* hasHeadCommit(input.cwd);
|
||||
if (headExists) {
|
||||
yield* git.execute({
|
||||
operation,
|
||||
cwd: input.cwd,
|
||||
args: ["read-tree", "HEAD"],
|
||||
env: commitEnv,
|
||||
});
|
||||
}
|
||||
const headExists = yield* hasHeadCommit(input.cwd);
|
||||
if (headExists) {
|
||||
yield* git.execute({
|
||||
operation,
|
||||
cwd: input.cwd,
|
||||
args: ["read-tree", "HEAD"],
|
||||
env: commitEnv,
|
||||
});
|
||||
}
|
||||
|
||||
yield* git.execute({
|
||||
operation,
|
||||
cwd: input.cwd,
|
||||
args: ["add", "-A", "--", "."],
|
||||
env: commitEnv,
|
||||
});
|
||||
yield* git.execute({
|
||||
operation,
|
||||
cwd: input.cwd,
|
||||
args: ["add", "-A", "--", "."],
|
||||
env: commitEnv,
|
||||
});
|
||||
|
||||
const writeTreeResult = yield* git.execute({
|
||||
operation,
|
||||
cwd: input.cwd,
|
||||
args: ["write-tree"],
|
||||
env: commitEnv,
|
||||
});
|
||||
const treeOid = writeTreeResult.stdout.trim();
|
||||
if (treeOid.length === 0) {
|
||||
return yield* new GitCommandError({
|
||||
operation,
|
||||
command: "git write-tree",
|
||||
cwd: input.cwd,
|
||||
detail: "git write-tree returned an empty tree oid.",
|
||||
});
|
||||
}
|
||||
const writeTreeResult = yield* git.execute({
|
||||
operation,
|
||||
cwd: input.cwd,
|
||||
args: ["write-tree"],
|
||||
env: commitEnv,
|
||||
});
|
||||
const treeOid = writeTreeResult.stdout.trim();
|
||||
if (treeOid.length === 0) {
|
||||
return yield* new GitCommandError({
|
||||
operation,
|
||||
command: "git write-tree",
|
||||
cwd: input.cwd,
|
||||
detail: "git write-tree returned an empty tree oid.",
|
||||
});
|
||||
}
|
||||
|
||||
const message = `t3 checkpoint ref=${input.checkpointRef}`;
|
||||
const commitTreeResult = yield* git.execute({
|
||||
operation,
|
||||
cwd: input.cwd,
|
||||
args: ["commit-tree", treeOid, "-m", message],
|
||||
env: commitEnv,
|
||||
});
|
||||
const commitOid = commitTreeResult.stdout.trim();
|
||||
if (commitOid.length === 0) {
|
||||
return yield* new GitCommandError({
|
||||
operation,
|
||||
command: "git commit-tree",
|
||||
cwd: input.cwd,
|
||||
detail: "git commit-tree returned an empty commit oid.",
|
||||
});
|
||||
}
|
||||
const message = `t3 checkpoint ref=${input.checkpointRef}`;
|
||||
const commitTreeResult = yield* git.execute({
|
||||
operation,
|
||||
cwd: input.cwd,
|
||||
args: ["commit-tree", treeOid, "-m", message],
|
||||
env: commitEnv,
|
||||
});
|
||||
const commitOid = commitTreeResult.stdout.trim();
|
||||
if (commitOid.length === 0) {
|
||||
return yield* new GitCommandError({
|
||||
operation,
|
||||
command: "git commit-tree",
|
||||
cwd: input.cwd,
|
||||
detail: "git commit-tree returned an empty commit oid.",
|
||||
});
|
||||
}
|
||||
|
||||
yield* git.execute({
|
||||
operation,
|
||||
cwd: input.cwd,
|
||||
args: ["update-ref", input.checkpointRef, commitOid],
|
||||
});
|
||||
}),
|
||||
(tempDir) => fs.remove(tempDir, { recursive: true }),
|
||||
).pipe(
|
||||
Effect.catchTags({
|
||||
PlatformError: (error) =>
|
||||
Effect.fail(
|
||||
new CheckpointInvariantError({
|
||||
operation: "CheckpointStore.captureCheckpoint",
|
||||
detail: "Failed to capture checkpoint.",
|
||||
cause: error,
|
||||
}),
|
||||
),
|
||||
}),
|
||||
);
|
||||
});
|
||||
yield* git.execute({
|
||||
operation,
|
||||
cwd: input.cwd,
|
||||
args: ["update-ref", input.checkpointRef, commitOid],
|
||||
});
|
||||
}),
|
||||
(tempDir) => fs.remove(tempDir, { recursive: true }),
|
||||
).pipe(
|
||||
Effect.catchTags({
|
||||
PlatformError: (error) =>
|
||||
Effect.fail(
|
||||
new CheckpointInvariantError({
|
||||
operation: "CheckpointStore.captureCheckpoint",
|
||||
detail: "Failed to capture checkpoint.",
|
||||
cause: error,
|
||||
}),
|
||||
),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
const hasCheckpointRef: CheckpointStoreShape["hasCheckpointRef"] = (input) =>
|
||||
resolveCheckpointCommit(input.cwd, input.checkpointRef).pipe(
|
||||
Effect.map((commit) => commit !== null),
|
||||
);
|
||||
|
||||
const restoreCheckpoint: CheckpointStoreShape["restoreCheckpoint"] = Effect.fn(
|
||||
"restoreCheckpoint",
|
||||
)(function* (input) {
|
||||
const operation = "CheckpointStore.restoreCheckpoint";
|
||||
const restoreCheckpoint: CheckpointStoreShape["restoreCheckpoint"] = (input) =>
|
||||
Effect.gen(function* () {
|
||||
const operation = "CheckpointStore.restoreCheckpoint";
|
||||
|
||||
let commitOid = yield* resolveCheckpointCommit(input.cwd, input.checkpointRef);
|
||||
let commitOid = yield* resolveCheckpointCommit(input.cwd, input.checkpointRef);
|
||||
|
||||
if (!commitOid && input.fallbackToHead === true) {
|
||||
commitOid = yield* resolveHeadCommit(input.cwd);
|
||||
}
|
||||
if (!commitOid && input.fallbackToHead === true) {
|
||||
commitOid = yield* resolveHeadCommit(input.cwd);
|
||||
}
|
||||
|
||||
if (!commitOid) {
|
||||
return false;
|
||||
}
|
||||
if (!commitOid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
yield* git.execute({
|
||||
operation,
|
||||
cwd: input.cwd,
|
||||
args: ["restore", "--source", commitOid, "--worktree", "--staged", "--", "."],
|
||||
});
|
||||
yield* git.execute({
|
||||
operation,
|
||||
cwd: input.cwd,
|
||||
args: ["clean", "-fd", "--", "."],
|
||||
});
|
||||
|
||||
const headExists = yield* hasHeadCommit(input.cwd);
|
||||
if (headExists) {
|
||||
yield* git.execute({
|
||||
operation,
|
||||
cwd: input.cwd,
|
||||
args: ["reset", "--quiet", "--", "."],
|
||||
args: ["restore", "--source", commitOid, "--worktree", "--staged", "--", "."],
|
||||
});
|
||||
yield* git.execute({
|
||||
operation,
|
||||
cwd: input.cwd,
|
||||
args: ["clean", "-fd", "--", "."],
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
const headExists = yield* hasHeadCommit(input.cwd);
|
||||
if (headExists) {
|
||||
yield* git.execute({
|
||||
operation,
|
||||
cwd: input.cwd,
|
||||
args: ["reset", "--quiet", "--", "."],
|
||||
});
|
||||
}
|
||||
|
||||
const diffCheckpoints: CheckpointStoreShape["diffCheckpoints"] = Effect.fn("diffCheckpoints")(
|
||||
function* (input) {
|
||||
return true;
|
||||
});
|
||||
|
||||
const diffCheckpoints: CheckpointStoreShape["diffCheckpoints"] = (input) =>
|
||||
Effect.gen(function* () {
|
||||
const operation = "CheckpointStore.diffCheckpoints";
|
||||
|
||||
let fromCommitOid = yield* resolveCheckpointCommit(input.cwd, input.fromCheckpointRef);
|
||||
@@ -248,26 +248,24 @@ const makeCheckpointStore = Effect.gen(function* () {
|
||||
});
|
||||
|
||||
return result.stdout;
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
const deleteCheckpointRefs: CheckpointStoreShape["deleteCheckpointRefs"] = Effect.fn(
|
||||
"deleteCheckpointRefs",
|
||||
)(function* (input) {
|
||||
const operation = "CheckpointStore.deleteCheckpointRefs";
|
||||
const deleteCheckpointRefs: CheckpointStoreShape["deleteCheckpointRefs"] = (input) =>
|
||||
Effect.gen(function* () {
|
||||
const operation = "CheckpointStore.deleteCheckpointRefs";
|
||||
|
||||
yield* Effect.forEach(
|
||||
input.checkpointRefs,
|
||||
(checkpointRef) =>
|
||||
git.execute({
|
||||
operation,
|
||||
cwd: input.cwd,
|
||||
args: ["update-ref", "-d", checkpointRef],
|
||||
allowNonZeroExit: true,
|
||||
}),
|
||||
{ discard: true },
|
||||
);
|
||||
});
|
||||
yield* Effect.forEach(
|
||||
input.checkpointRefs,
|
||||
(checkpointRef) =>
|
||||
git.execute({
|
||||
operation,
|
||||
cwd: input.cwd,
|
||||
args: ["update-ref", "-d", checkpointRef],
|
||||
allowNonZeroExit: true,
|
||||
}),
|
||||
{ discard: true },
|
||||
);
|
||||
});
|
||||
|
||||
return {
|
||||
isGitRepository,
|
||||
@@ -279,4 +277,6 @@ const makeCheckpointStore = Effect.gen(function* () {
|
||||
} satisfies CheckpointStoreShape;
|
||||
});
|
||||
|
||||
export const CheckpointStoreLive = Layer.effect(CheckpointStore, makeCheckpointStore);
|
||||
export const CheckpointStoreLive = Layer.effect(CheckpointStore, makeCheckpointStore).pipe(
|
||||
Layer.provideMerge(GitServiceLive),
|
||||
);
|
||||
@@ -1,318 +0,0 @@
|
||||
import os from "node:os";
|
||||
|
||||
import { assert, expect, it } from "@effect/vitest";
|
||||
import { ConfigProvider, Effect, FileSystem, Layer, Option, Path } from "effect";
|
||||
|
||||
import { NetService } from "@t3tools/shared/Net";
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { deriveServerPaths } from "./config";
|
||||
import { resolveServerConfig } from "./cli";
|
||||
|
||||
it.layer(NodeServices.layer)("cli config resolution", (it) => {
|
||||
const openBootstrapFd = Effect.fn(function* (payload: Record<string, unknown>) {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const filePath = yield* fs.makeTempFileScoped({ prefix: "t3-bootstrap-", suffix: ".ndjson" });
|
||||
yield* fs.writeFileString(filePath, `${JSON.stringify(payload)}\n`);
|
||||
const { fd } = yield* fs.open(filePath, { flag: "r" });
|
||||
return fd;
|
||||
});
|
||||
|
||||
it.effect("falls back to effect/config values when flags are omitted", () =>
|
||||
Effect.gen(function* () {
|
||||
const { join } = yield* Path.Path;
|
||||
const baseDir = join(os.tmpdir(), "t3-cli-config-env-base");
|
||||
const derivedPaths = yield* deriveServerPaths(baseDir, new URL("http://127.0.0.1:5173"));
|
||||
const resolved = yield* resolveServerConfig(
|
||||
{
|
||||
mode: Option.none(),
|
||||
port: Option.none(),
|
||||
host: Option.none(),
|
||||
baseDir: Option.none(),
|
||||
devUrl: Option.none(),
|
||||
noBrowser: Option.none(),
|
||||
authToken: Option.none(),
|
||||
bootstrapFd: Option.none(),
|
||||
autoBootstrapProjectFromCwd: Option.none(),
|
||||
logWebSocketEvents: Option.none(),
|
||||
},
|
||||
Option.none(),
|
||||
).pipe(
|
||||
Effect.provide(
|
||||
Layer.mergeAll(
|
||||
ConfigProvider.layer(
|
||||
ConfigProvider.fromEnv({
|
||||
env: {
|
||||
T3CODE_LOG_LEVEL: "Warn",
|
||||
T3CODE_MODE: "desktop",
|
||||
T3CODE_PORT: "4001",
|
||||
T3CODE_HOST: "0.0.0.0",
|
||||
T3CODE_HOME: baseDir,
|
||||
VITE_DEV_SERVER_URL: "http://127.0.0.1:5173",
|
||||
T3CODE_NO_BROWSER: "true",
|
||||
T3CODE_AUTH_TOKEN: "env-token",
|
||||
T3CODE_AUTO_BOOTSTRAP_PROJECT_FROM_CWD: "false",
|
||||
T3CODE_LOG_WS_EVENTS: "true",
|
||||
},
|
||||
}),
|
||||
),
|
||||
NetService.layer,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(resolved).toEqual({
|
||||
logLevel: "Warn",
|
||||
mode: "desktop",
|
||||
port: 4001,
|
||||
cwd: process.cwd(),
|
||||
baseDir,
|
||||
...derivedPaths,
|
||||
host: "0.0.0.0",
|
||||
staticDir: undefined,
|
||||
devUrl: new URL("http://127.0.0.1:5173"),
|
||||
noBrowser: true,
|
||||
authToken: "env-token",
|
||||
autoBootstrapProjectFromCwd: false,
|
||||
logWebSocketEvents: true,
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("uses CLI flags when provided", () =>
|
||||
Effect.gen(function* () {
|
||||
const { join } = yield* Path.Path;
|
||||
const baseDir = join(os.tmpdir(), "t3-cli-config-flags-base");
|
||||
const derivedPaths = yield* deriveServerPaths(baseDir, new URL("http://127.0.0.1:4173"));
|
||||
const resolved = yield* resolveServerConfig(
|
||||
{
|
||||
mode: Option.some("web"),
|
||||
port: Option.some(8788),
|
||||
host: Option.some("127.0.0.1"),
|
||||
baseDir: Option.some(baseDir),
|
||||
devUrl: Option.some(new URL("http://127.0.0.1:4173")),
|
||||
noBrowser: Option.some(true),
|
||||
authToken: Option.some("flag-token"),
|
||||
bootstrapFd: Option.none(),
|
||||
autoBootstrapProjectFromCwd: Option.some(true),
|
||||
logWebSocketEvents: Option.some(true),
|
||||
},
|
||||
Option.some("Debug"),
|
||||
).pipe(
|
||||
Effect.provide(
|
||||
Layer.mergeAll(
|
||||
ConfigProvider.layer(
|
||||
ConfigProvider.fromEnv({
|
||||
env: {
|
||||
T3CODE_LOG_LEVEL: "Warn",
|
||||
T3CODE_MODE: "desktop",
|
||||
T3CODE_PORT: "4001",
|
||||
T3CODE_HOST: "0.0.0.0",
|
||||
T3CODE_HOME: join(os.tmpdir(), "ignored-base"),
|
||||
VITE_DEV_SERVER_URL: "http://127.0.0.1:5173",
|
||||
T3CODE_NO_BROWSER: "false",
|
||||
T3CODE_AUTH_TOKEN: "ignored-token",
|
||||
T3CODE_AUTO_BOOTSTRAP_PROJECT_FROM_CWD: "false",
|
||||
T3CODE_LOG_WS_EVENTS: "false",
|
||||
},
|
||||
}),
|
||||
),
|
||||
NetService.layer,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(resolved).toEqual({
|
||||
logLevel: "Debug",
|
||||
mode: "web",
|
||||
port: 8788,
|
||||
cwd: process.cwd(),
|
||||
baseDir,
|
||||
...derivedPaths,
|
||||
host: "127.0.0.1",
|
||||
staticDir: undefined,
|
||||
devUrl: new URL("http://127.0.0.1:4173"),
|
||||
noBrowser: true,
|
||||
authToken: "flag-token",
|
||||
autoBootstrapProjectFromCwd: true,
|
||||
logWebSocketEvents: true,
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("uses bootstrap envelope values as fallbacks when flags and env are absent", () =>
|
||||
Effect.gen(function* () {
|
||||
const { join } = yield* Path.Path;
|
||||
const baseDir = "/tmp/t3-bootstrap-home";
|
||||
const fd = yield* openBootstrapFd({
|
||||
mode: "desktop",
|
||||
port: 4888,
|
||||
host: "127.0.0.2",
|
||||
t3Home: baseDir,
|
||||
devUrl: "http://127.0.0.1:5173",
|
||||
noBrowser: true,
|
||||
authToken: "bootstrap-token",
|
||||
autoBootstrapProjectFromCwd: false,
|
||||
logWebSocketEvents: true,
|
||||
});
|
||||
const derivedPaths = yield* deriveServerPaths(baseDir, new URL("http://127.0.0.1:5173"));
|
||||
|
||||
const resolved = yield* resolveServerConfig(
|
||||
{
|
||||
mode: Option.none(),
|
||||
port: Option.none(),
|
||||
host: Option.none(),
|
||||
baseDir: Option.none(),
|
||||
devUrl: Option.none(),
|
||||
noBrowser: Option.none(),
|
||||
authToken: Option.none(),
|
||||
bootstrapFd: Option.none(),
|
||||
autoBootstrapProjectFromCwd: Option.none(),
|
||||
logWebSocketEvents: Option.none(),
|
||||
},
|
||||
Option.none(),
|
||||
).pipe(
|
||||
Effect.provide(
|
||||
Layer.mergeAll(
|
||||
ConfigProvider.layer(
|
||||
ConfigProvider.fromEnv({
|
||||
env: {
|
||||
T3CODE_BOOTSTRAP_FD: String(fd),
|
||||
},
|
||||
}),
|
||||
),
|
||||
NetService.layer,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(resolved).toEqual({
|
||||
logLevel: "Info",
|
||||
mode: "desktop",
|
||||
port: 4888,
|
||||
cwd: process.cwd(),
|
||||
baseDir,
|
||||
...derivedPaths,
|
||||
host: "127.0.0.2",
|
||||
staticDir: undefined,
|
||||
devUrl: new URL("http://127.0.0.1:5173"),
|
||||
noBrowser: true,
|
||||
authToken: "bootstrap-token",
|
||||
autoBootstrapProjectFromCwd: false,
|
||||
logWebSocketEvents: true,
|
||||
});
|
||||
assert.equal(join(baseDir, "dev"), resolved.stateDir);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("creates derived runtime directories during config resolution", () =>
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const baseDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-cli-config-dirs-" });
|
||||
|
||||
const resolved = yield* resolveServerConfig(
|
||||
{
|
||||
mode: Option.some("desktop"),
|
||||
port: Option.some(4888),
|
||||
host: Option.none(),
|
||||
baseDir: Option.some(baseDir),
|
||||
devUrl: Option.some(new URL("http://127.0.0.1:5173")),
|
||||
noBrowser: Option.none(),
|
||||
authToken: Option.none(),
|
||||
bootstrapFd: Option.none(),
|
||||
autoBootstrapProjectFromCwd: Option.none(),
|
||||
logWebSocketEvents: Option.none(),
|
||||
},
|
||||
Option.none(),
|
||||
).pipe(
|
||||
Effect.provide(
|
||||
Layer.mergeAll(
|
||||
ConfigProvider.layer(ConfigProvider.fromEnv({ env: {} })),
|
||||
NetService.layer,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
for (const directory of [
|
||||
resolved.stateDir,
|
||||
resolved.logsDir,
|
||||
resolved.providerLogsDir,
|
||||
resolved.terminalLogsDir,
|
||||
resolved.attachmentsDir,
|
||||
resolved.worktreesDir,
|
||||
path.dirname(resolved.serverLogPath),
|
||||
]) {
|
||||
expect(yield* fs.exists(directory)).toBe(true);
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("applies flag then env precedence over bootstrap envelope values", () =>
|
||||
Effect.gen(function* () {
|
||||
const { join } = yield* Path.Path;
|
||||
const baseDir = join(os.tmpdir(), "t3-cli-config-env-wins");
|
||||
const fd = yield* openBootstrapFd({
|
||||
mode: "desktop",
|
||||
port: 4888,
|
||||
host: "127.0.0.2",
|
||||
t3Home: "/tmp/t3-bootstrap-home",
|
||||
devUrl: "http://127.0.0.1:5173",
|
||||
noBrowser: false,
|
||||
authToken: "bootstrap-token",
|
||||
autoBootstrapProjectFromCwd: false,
|
||||
logWebSocketEvents: false,
|
||||
});
|
||||
const derivedPaths = yield* deriveServerPaths(baseDir, new URL("http://127.0.0.1:4173"));
|
||||
|
||||
const resolved = yield* resolveServerConfig(
|
||||
{
|
||||
mode: Option.none(),
|
||||
port: Option.some(8788),
|
||||
host: Option.some("127.0.0.1"),
|
||||
baseDir: Option.none(),
|
||||
devUrl: Option.some(new URL("http://127.0.0.1:4173")),
|
||||
noBrowser: Option.none(),
|
||||
authToken: Option.some("flag-token"),
|
||||
bootstrapFd: Option.none(),
|
||||
autoBootstrapProjectFromCwd: Option.none(),
|
||||
logWebSocketEvents: Option.none(),
|
||||
},
|
||||
Option.some("Debug"),
|
||||
).pipe(
|
||||
Effect.provide(
|
||||
Layer.mergeAll(
|
||||
ConfigProvider.layer(
|
||||
ConfigProvider.fromEnv({
|
||||
env: {
|
||||
T3CODE_MODE: "web",
|
||||
T3CODE_BOOTSTRAP_FD: String(fd),
|
||||
T3CODE_HOME: baseDir,
|
||||
T3CODE_NO_BROWSER: "true",
|
||||
T3CODE_AUTO_BOOTSTRAP_PROJECT_FROM_CWD: "true",
|
||||
T3CODE_LOG_WS_EVENTS: "true",
|
||||
},
|
||||
}),
|
||||
),
|
||||
NetService.layer,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(resolved).toEqual({
|
||||
logLevel: "Debug",
|
||||
mode: "web",
|
||||
port: 8788,
|
||||
cwd: process.cwd(),
|
||||
baseDir,
|
||||
...derivedPaths,
|
||||
host: "127.0.0.1",
|
||||
staticDir: undefined,
|
||||
devUrl: new URL("http://127.0.0.1:4173"),
|
||||
noBrowser: true,
|
||||
authToken: "flag-token",
|
||||
autoBootstrapProjectFromCwd: true,
|
||||
logWebSocketEvents: true,
|
||||
});
|
||||
}),
|
||||
);
|
||||
});
|
||||
+101
-25
@@ -1,37 +1,113 @@
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { NetService } from "@t3tools/shared/Net";
|
||||
import { assert, it } from "@effect/vitest";
|
||||
import { describe, expect, it } from "@effect/vitest";
|
||||
import * as ConfigProvider from "effect/ConfigProvider";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as CliError from "effect/unstable/cli/CliError";
|
||||
import { Command } from "effect/unstable/cli";
|
||||
import * as Option from "effect/Option";
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
|
||||
import { cli } from "./cli.ts";
|
||||
import { resolveServerConfig, type CliInput } from "./cli";
|
||||
|
||||
const CliRuntimeLayer = Layer.mergeAll(NodeServices.layer, NetService.layer);
|
||||
const emptyInput = (): CliInput => ({
|
||||
mode: Option.none(),
|
||||
port: Option.none(),
|
||||
host: Option.none(),
|
||||
stateDir: Option.none(),
|
||||
devUrl: Option.none(),
|
||||
noBrowser: Option.none(),
|
||||
authToken: Option.none(),
|
||||
autoBootstrapProjectFromCwd: Option.none(),
|
||||
logWebSocketEvents: Option.none(),
|
||||
});
|
||||
|
||||
it.layer(NodeServices.layer)("cli log-level parsing", (it) => {
|
||||
it.effect("accepts the built-in lowercase log-level flag values", () =>
|
||||
Command.runWith(cli, { version: "0.0.0" })(["--log-level", "debug", "--version"]).pipe(
|
||||
Effect.provide(CliRuntimeLayer),
|
||||
),
|
||||
describe("cli config resolution", () => {
|
||||
it.effect("falls back to environment values when flags are omitted", () =>
|
||||
Effect.gen(function* () {
|
||||
const resolved = yield* resolveServerConfig(emptyInput()).pipe(
|
||||
Effect.provide(NetService.layer),
|
||||
Effect.provide(NodeServices.layer),
|
||||
Effect.provideService(
|
||||
ConfigProvider.ConfigProvider,
|
||||
ConfigProvider.fromEnv({
|
||||
env: {
|
||||
T3CODE_MODE: "desktop",
|
||||
T3CODE_PORT: "4123",
|
||||
T3CODE_HOST: "127.0.0.1",
|
||||
T3CODE_STATE_DIR: "/tmp/t3-state",
|
||||
VITE_DEV_SERVER_URL: "http://127.0.0.1:5173",
|
||||
T3CODE_NO_BROWSER: "true",
|
||||
T3CODE_AUTH_TOKEN: "secret",
|
||||
T3CODE_AUTO_BOOTSTRAP_PROJECT_FROM_CWD: "false",
|
||||
T3CODE_LOG_WS_EVENTS: "true",
|
||||
},
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
expect(resolved).toEqual({
|
||||
mode: "desktop",
|
||||
port: 4123,
|
||||
host: "127.0.0.1",
|
||||
cwd: process.cwd(),
|
||||
keybindingsConfigPath: "/tmp/t3-state/keybindings.json",
|
||||
stateDir: "/tmp/t3-state",
|
||||
staticDir: undefined,
|
||||
devUrl: new URL("http://127.0.0.1:5173"),
|
||||
noBrowser: true,
|
||||
authToken: "secret",
|
||||
autoBootstrapProjectFromCwd: false,
|
||||
logWebSocketEvents: true,
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("rejects invalid log-level casing before launching the server", () =>
|
||||
it.effect("uses CLI flags as the final override", () =>
|
||||
Effect.gen(function* () {
|
||||
const error = yield* Command.runWith(cli, { version: "0.0.0" })([
|
||||
"--log-level",
|
||||
"Debug",
|
||||
]).pipe(Effect.provide(CliRuntimeLayer), Effect.flip);
|
||||
const resolved = yield* resolveServerConfig({
|
||||
...emptyInput(),
|
||||
mode: Option.some("web"),
|
||||
port: Option.some(4444),
|
||||
host: Option.some("0.0.0.0"),
|
||||
stateDir: Option.some("/tmp/t3-override"),
|
||||
devUrl: Option.some(new URL("http://127.0.0.1:4173")),
|
||||
noBrowser: Option.some("false"),
|
||||
authToken: Option.some("override-token"),
|
||||
autoBootstrapProjectFromCwd: Option.some("true"),
|
||||
logWebSocketEvents: Option.some("false"),
|
||||
}).pipe(
|
||||
Effect.provide(NetService.layer),
|
||||
Effect.provide(NodeServices.layer),
|
||||
Effect.provideService(
|
||||
ConfigProvider.ConfigProvider,
|
||||
ConfigProvider.fromEnv({
|
||||
env: {
|
||||
T3CODE_MODE: "desktop",
|
||||
T3CODE_PORT: "4123",
|
||||
T3CODE_HOST: "127.0.0.1",
|
||||
T3CODE_STATE_DIR: "/tmp/t3-state",
|
||||
VITE_DEV_SERVER_URL: "http://127.0.0.1:5173",
|
||||
T3CODE_NO_BROWSER: "true",
|
||||
T3CODE_AUTH_TOKEN: "secret",
|
||||
T3CODE_AUTO_BOOTSTRAP_PROJECT_FROM_CWD: "false",
|
||||
T3CODE_LOG_WS_EVENTS: "true",
|
||||
},
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
if (!CliError.isCliError(error)) {
|
||||
assert.fail(`Expected CliError, got ${String(error)}`);
|
||||
}
|
||||
if (error._tag !== "InvalidValue") {
|
||||
assert.fail(`Expected InvalidValue, got ${error._tag}`);
|
||||
}
|
||||
assert.equal(error.option, "log-level");
|
||||
assert.equal(error.value, "Debug");
|
||||
expect(resolved).toEqual({
|
||||
mode: "web",
|
||||
port: 4444,
|
||||
host: "0.0.0.0",
|
||||
cwd: process.cwd(),
|
||||
keybindingsConfigPath: "/tmp/t3-override/keybindings.json",
|
||||
stateDir: "/tmp/t3-override",
|
||||
staticDir: undefined,
|
||||
devUrl: new URL("http://127.0.0.1:4173"),
|
||||
noBrowser: false,
|
||||
authToken: "override-token",
|
||||
autoBootstrapProjectFromCwd: true,
|
||||
logWebSocketEvents: false,
|
||||
});
|
||||
}),
|
||||
);
|
||||
});
|
||||
+151
-231
@@ -1,93 +1,65 @@
|
||||
import { NetService } from "@t3tools/shared/Net";
|
||||
import { Config, Effect, LogLevel, Option, Schema } from "effect";
|
||||
import { Command, Flag, GlobalFlag } from "effect/unstable/cli";
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { Config, Data, Effect, Layer, Option, Path, Schema } from "effect";
|
||||
import { Command, Flag } from "effect/unstable/cli";
|
||||
|
||||
import {
|
||||
DEFAULT_PORT,
|
||||
deriveServerPaths,
|
||||
ensureServerDirectories,
|
||||
resolveStaticDir,
|
||||
ServerConfig,
|
||||
RuntimeMode,
|
||||
type RuntimeMode,
|
||||
type ServerConfigShape,
|
||||
} from "./config";
|
||||
import { readBootstrapEnvelope } from "./bootstrap";
|
||||
import { resolveBaseDir } from "./os-jank";
|
||||
import { fixPath, resolveStateDir } from "./os-jank";
|
||||
import { runServer } from "./server";
|
||||
|
||||
const PortSchema = Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 65535 }));
|
||||
export class StartupError extends Data.TaggedError("StartupError")<{
|
||||
readonly message: string;
|
||||
readonly cause?: unknown;
|
||||
}> {}
|
||||
|
||||
const BootstrapEnvelopeSchema = Schema.Struct({
|
||||
mode: Schema.optional(RuntimeMode),
|
||||
port: Schema.optional(PortSchema),
|
||||
host: Schema.optional(Schema.String),
|
||||
t3Home: Schema.optional(Schema.String),
|
||||
devUrl: Schema.optional(Schema.URLFromString),
|
||||
noBrowser: Schema.optional(Schema.Boolean),
|
||||
authToken: Schema.optional(Schema.String),
|
||||
autoBootstrapProjectFromCwd: Schema.optional(Schema.Boolean),
|
||||
logWebSocketEvents: Schema.optional(Schema.Boolean),
|
||||
});
|
||||
type CliBooleanFlag = "true" | "false";
|
||||
|
||||
const modeFlag = Flag.choice("mode", RuntimeMode.literals).pipe(
|
||||
Flag.withDescription("Runtime mode. `desktop` keeps loopback defaults unless overridden."),
|
||||
Flag.optional,
|
||||
);
|
||||
const portFlag = Flag.integer("port").pipe(
|
||||
Flag.withSchema(PortSchema),
|
||||
Flag.withDescription("Port for the HTTP/WebSocket server."),
|
||||
Flag.optional,
|
||||
);
|
||||
const hostFlag = Flag.string("host").pipe(
|
||||
Flag.withDescription("Host/interface to bind (for example 127.0.0.1, 0.0.0.0, or a Tailnet IP)."),
|
||||
Flag.optional,
|
||||
);
|
||||
const baseDirFlag = Flag.string("base-dir").pipe(
|
||||
Flag.withDescription("Base directory path (equivalent to T3CODE_HOME)."),
|
||||
Flag.optional,
|
||||
);
|
||||
const devUrlFlag = Flag.string("dev-url").pipe(
|
||||
Flag.withSchema(Schema.URLFromString),
|
||||
Flag.withDescription("Dev web URL to proxy/redirect to (equivalent to VITE_DEV_SERVER_URL)."),
|
||||
Flag.optional,
|
||||
);
|
||||
const noBrowserFlag = Flag.boolean("no-browser").pipe(
|
||||
Flag.withDescription("Disable automatic browser opening."),
|
||||
Flag.optional,
|
||||
);
|
||||
const authTokenFlag = Flag.string("auth-token").pipe(
|
||||
Flag.withDescription("Auth token required for WebSocket connections."),
|
||||
Flag.withAlias("token"),
|
||||
Flag.optional,
|
||||
);
|
||||
const bootstrapFdFlag = Flag.integer("bootstrap-fd").pipe(
|
||||
Flag.withSchema(Schema.Int),
|
||||
Flag.withDescription("Read one-time bootstrap secrets from the given file descriptor."),
|
||||
Flag.optional,
|
||||
);
|
||||
const autoBootstrapProjectFromCwdFlag = Flag.boolean("auto-bootstrap-project-from-cwd").pipe(
|
||||
Flag.withDescription(
|
||||
"Create a project for the current working directory on startup when missing.",
|
||||
),
|
||||
Flag.optional,
|
||||
);
|
||||
const logWebSocketEventsFlag = Flag.boolean("log-websocket-events").pipe(
|
||||
Flag.withDescription(
|
||||
"Emit server-side logs for outbound WebSocket push traffic (equivalent to T3CODE_LOG_WS_EVENTS).",
|
||||
),
|
||||
Flag.withAlias("log-ws-events"),
|
||||
Flag.optional,
|
||||
);
|
||||
const parseCliBoolean = (value: CliBooleanFlag): boolean => value === "true";
|
||||
|
||||
const EnvServerConfig = Config.all({
|
||||
logLevel: Config.logLevel("T3CODE_LOG_LEVEL").pipe(Config.withDefault("Info")),
|
||||
mode: Config.schema(RuntimeMode, "T3CODE_MODE").pipe(
|
||||
const resolveBooleanSetting = (
|
||||
value: Option.Option<CliBooleanFlag>,
|
||||
envValue: boolean | undefined,
|
||||
fallback: boolean,
|
||||
): boolean =>
|
||||
Option.match(value, {
|
||||
onSome: parseCliBoolean,
|
||||
onNone: () => envValue ?? fallback,
|
||||
});
|
||||
|
||||
export interface CliInput {
|
||||
readonly mode: Option.Option<RuntimeMode>;
|
||||
readonly port: Option.Option<number>;
|
||||
readonly host: Option.Option<string>;
|
||||
readonly stateDir: Option.Option<string>;
|
||||
readonly devUrl: Option.Option<URL>;
|
||||
readonly noBrowser: Option.Option<CliBooleanFlag>;
|
||||
readonly authToken: Option.Option<string>;
|
||||
readonly autoBootstrapProjectFromCwd: Option.Option<CliBooleanFlag>;
|
||||
readonly logWebSocketEvents: Option.Option<CliBooleanFlag>;
|
||||
}
|
||||
|
||||
const CliEnvConfig = Config.all({
|
||||
mode: Config.string("T3CODE_MODE").pipe(
|
||||
Config.option,
|
||||
Config.map(Option.getOrUndefined),
|
||||
Config.map(
|
||||
Option.match<RuntimeMode, string>({
|
||||
onNone: () => "web",
|
||||
onSome: (value) => (value === "desktop" ? "desktop" : "web"),
|
||||
}),
|
||||
),
|
||||
),
|
||||
port: Config.port("T3CODE_PORT").pipe(Config.option, Config.map(Option.getOrUndefined)),
|
||||
host: Config.string("T3CODE_HOST").pipe(Config.option, Config.map(Option.getOrUndefined)),
|
||||
t3Home: Config.string("T3CODE_HOME").pipe(Config.option, Config.map(Option.getOrUndefined)),
|
||||
stateDir: Config.string("T3CODE_STATE_DIR").pipe(
|
||||
Config.option,
|
||||
Config.map(Option.getOrUndefined),
|
||||
),
|
||||
devUrl: Config.url("VITE_DEV_SERVER_URL").pipe(Config.option, Config.map(Option.getOrUndefined)),
|
||||
noBrowser: Config.boolean("T3CODE_NO_BROWSER").pipe(
|
||||
Config.option,
|
||||
@@ -97,10 +69,6 @@ const EnvServerConfig = Config.all({
|
||||
Config.option,
|
||||
Config.map(Option.getOrUndefined),
|
||||
),
|
||||
bootstrapFd: Config.int("T3CODE_BOOTSTRAP_FD").pipe(
|
||||
Config.option,
|
||||
Config.map(Option.getOrUndefined),
|
||||
),
|
||||
autoBootstrapProjectFromCwd: Config.boolean("T3CODE_AUTO_BOOTSTRAP_PROJECT_FROM_CWD").pipe(
|
||||
Config.option,
|
||||
Config.map(Option.getOrUndefined),
|
||||
@@ -111,182 +79,134 @@ const EnvServerConfig = Config.all({
|
||||
),
|
||||
});
|
||||
|
||||
interface CliServerFlags {
|
||||
readonly mode: Option.Option<RuntimeMode>;
|
||||
readonly port: Option.Option<number>;
|
||||
readonly host: Option.Option<string>;
|
||||
readonly baseDir: Option.Option<string>;
|
||||
readonly devUrl: Option.Option<URL>;
|
||||
readonly noBrowser: Option.Option<boolean>;
|
||||
readonly authToken: Option.Option<string>;
|
||||
readonly bootstrapFd: Option.Option<number>;
|
||||
readonly autoBootstrapProjectFromCwd: Option.Option<boolean>;
|
||||
readonly logWebSocketEvents: Option.Option<boolean>;
|
||||
}
|
||||
|
||||
const resolveBooleanFlag = (flag: Option.Option<boolean>, envValue: boolean) =>
|
||||
Option.getOrElse(Option.filter(flag, Boolean), () => envValue);
|
||||
|
||||
const resolveOptionPrecedence = <Value>(
|
||||
...values: ReadonlyArray<Option.Option<Value>>
|
||||
): Option.Option<Value> => Option.firstSomeOf(values);
|
||||
|
||||
export const resolveServerConfig = (
|
||||
flags: CliServerFlags,
|
||||
cliLogLevel: Option.Option<LogLevel.LogLevel>,
|
||||
) =>
|
||||
export const resolveServerConfig = (input: CliInput) =>
|
||||
Effect.gen(function* () {
|
||||
const { findAvailablePort } = yield* NetService;
|
||||
const env = yield* EnvServerConfig;
|
||||
const bootstrapFd = Option.getOrUndefined(flags.bootstrapFd) ?? env.bootstrapFd;
|
||||
const bootstrapEnvelope =
|
||||
bootstrapFd !== undefined
|
||||
? yield* readBootstrapEnvelope(BootstrapEnvelopeSchema, bootstrapFd)
|
||||
: Option.none();
|
||||
const { join } = yield* Path.Path;
|
||||
|
||||
const mode: RuntimeMode = Option.getOrElse(
|
||||
resolveOptionPrecedence(
|
||||
flags.mode,
|
||||
Option.fromUndefinedOr(env.mode),
|
||||
Option.flatMap(bootstrapEnvelope, (bootstrap) => Option.fromUndefinedOr(bootstrap.mode)),
|
||||
yield* Effect.sync(fixPath);
|
||||
|
||||
const env = yield* CliEnvConfig.asEffect().pipe(
|
||||
Effect.mapError(
|
||||
(cause) => new StartupError({ message: "Failed to read environment configuration", cause }),
|
||||
),
|
||||
() => "web",
|
||||
);
|
||||
|
||||
const port = yield* Option.match(
|
||||
resolveOptionPrecedence(
|
||||
flags.port,
|
||||
Option.fromUndefinedOr(env.port),
|
||||
Option.flatMap(bootstrapEnvelope, (bootstrap) => Option.fromUndefinedOr(bootstrap.port)),
|
||||
),
|
||||
{
|
||||
onSome: (value) => Effect.succeed(value),
|
||||
onNone: () => {
|
||||
if (mode === "desktop") {
|
||||
return Effect.succeed(DEFAULT_PORT);
|
||||
}
|
||||
return findAvailablePort(DEFAULT_PORT);
|
||||
},
|
||||
const mode = Option.getOrElse(input.mode, () => env.mode);
|
||||
const port = yield* Option.match(input.port, {
|
||||
onSome: Effect.succeed,
|
||||
onNone: () => {
|
||||
if (env.port) {
|
||||
return Effect.succeed(env.port);
|
||||
}
|
||||
if (mode === "desktop") {
|
||||
return Effect.succeed(DEFAULT_PORT);
|
||||
}
|
||||
return findAvailablePort(DEFAULT_PORT);
|
||||
},
|
||||
);
|
||||
const devUrl = Option.getOrElse(
|
||||
resolveOptionPrecedence(
|
||||
flags.devUrl,
|
||||
Option.fromUndefinedOr(env.devUrl),
|
||||
Option.flatMap(bootstrapEnvelope, (bootstrap) => Option.fromUndefinedOr(bootstrap.devUrl)),
|
||||
),
|
||||
() => undefined,
|
||||
);
|
||||
const baseDir = yield* resolveBaseDir(
|
||||
Option.getOrUndefined(
|
||||
resolveOptionPrecedence(
|
||||
flags.baseDir,
|
||||
Option.fromUndefinedOr(env.t3Home),
|
||||
Option.flatMap(bootstrapEnvelope, (bootstrap) =>
|
||||
Option.fromUndefinedOr(bootstrap.t3Home),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
const derivedPaths = yield* deriveServerPaths(baseDir, devUrl);
|
||||
yield* ensureServerDirectories(derivedPaths);
|
||||
const noBrowser = resolveBooleanFlag(
|
||||
flags.noBrowser,
|
||||
Option.getOrElse(
|
||||
resolveOptionPrecedence(
|
||||
Option.fromUndefinedOr(env.noBrowser),
|
||||
Option.flatMap(bootstrapEnvelope, (bootstrap) =>
|
||||
Option.fromUndefinedOr(bootstrap.noBrowser),
|
||||
),
|
||||
),
|
||||
() => mode === "desktop",
|
||||
),
|
||||
);
|
||||
const authToken = Option.getOrUndefined(
|
||||
resolveOptionPrecedence(
|
||||
flags.authToken,
|
||||
Option.fromUndefinedOr(env.authToken),
|
||||
Option.flatMap(bootstrapEnvelope, (bootstrap) =>
|
||||
Option.fromUndefinedOr(bootstrap.authToken),
|
||||
),
|
||||
),
|
||||
);
|
||||
const autoBootstrapProjectFromCwd = resolveBooleanFlag(
|
||||
flags.autoBootstrapProjectFromCwd,
|
||||
Option.getOrElse(
|
||||
resolveOptionPrecedence(
|
||||
Option.fromUndefinedOr(env.autoBootstrapProjectFromCwd),
|
||||
Option.flatMap(bootstrapEnvelope, (bootstrap) =>
|
||||
Option.fromUndefinedOr(bootstrap.autoBootstrapProjectFromCwd),
|
||||
),
|
||||
),
|
||||
() => mode === "web",
|
||||
),
|
||||
);
|
||||
const logWebSocketEvents = resolveBooleanFlag(
|
||||
flags.logWebSocketEvents,
|
||||
Option.getOrElse(
|
||||
resolveOptionPrecedence(
|
||||
Option.fromUndefinedOr(env.logWebSocketEvents),
|
||||
Option.flatMap(bootstrapEnvelope, (bootstrap) =>
|
||||
Option.fromUndefinedOr(bootstrap.logWebSocketEvents),
|
||||
),
|
||||
),
|
||||
() => Boolean(devUrl),
|
||||
),
|
||||
);
|
||||
const staticDir = devUrl ? undefined : yield* resolveStaticDir();
|
||||
const host = Option.getOrElse(
|
||||
resolveOptionPrecedence(
|
||||
flags.host,
|
||||
Option.fromUndefinedOr(env.host),
|
||||
Option.flatMap(bootstrapEnvelope, (bootstrap) => Option.fromUndefinedOr(bootstrap.host)),
|
||||
),
|
||||
() => (mode === "desktop" ? "127.0.0.1" : undefined),
|
||||
);
|
||||
const logLevel = Option.getOrElse(cliLogLevel, () => env.logLevel);
|
||||
});
|
||||
|
||||
const config: ServerConfigShape = {
|
||||
logLevel,
|
||||
const stateDir = yield* resolveStateDir(Option.getOrUndefined(input.stateDir) ?? env.stateDir);
|
||||
const devUrl = Option.getOrElse(input.devUrl, () => env.devUrl);
|
||||
|
||||
return {
|
||||
mode,
|
||||
port,
|
||||
cwd: process.cwd(),
|
||||
baseDir,
|
||||
...derivedPaths,
|
||||
host,
|
||||
staticDir,
|
||||
keybindingsConfigPath: join(stateDir, "keybindings.json"),
|
||||
host:
|
||||
Option.getOrUndefined(input.host) ??
|
||||
env.host ??
|
||||
(mode === "desktop" ? "127.0.0.1" : undefined),
|
||||
stateDir,
|
||||
staticDir: devUrl ? undefined : yield* resolveStaticDir(),
|
||||
devUrl,
|
||||
noBrowser,
|
||||
authToken,
|
||||
autoBootstrapProjectFromCwd,
|
||||
logWebSocketEvents,
|
||||
};
|
||||
|
||||
return config;
|
||||
noBrowser: resolveBooleanSetting(input.noBrowser, env.noBrowser, mode === "desktop"),
|
||||
authToken: Option.getOrUndefined(input.authToken) ?? env.authToken,
|
||||
autoBootstrapProjectFromCwd: resolveBooleanSetting(
|
||||
input.autoBootstrapProjectFromCwd,
|
||||
env.autoBootstrapProjectFromCwd,
|
||||
mode === "web",
|
||||
),
|
||||
logWebSocketEvents: resolveBooleanSetting(
|
||||
input.logWebSocketEvents,
|
||||
env.logWebSocketEvents,
|
||||
Boolean(devUrl),
|
||||
),
|
||||
} satisfies ServerConfigShape;
|
||||
});
|
||||
|
||||
const commandFlags = {
|
||||
const modeFlag = Flag.choice("mode", ["web", "desktop"]).pipe(
|
||||
Flag.withDescription("Runtime mode. `desktop` keeps loopback defaults unless overridden."),
|
||||
Flag.optional,
|
||||
);
|
||||
|
||||
const portFlag = Flag.integer("port").pipe(
|
||||
Flag.withSchema(Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 65535 }))),
|
||||
Flag.withDescription("Port for the HTTP/WebSocket server."),
|
||||
Flag.optional,
|
||||
);
|
||||
|
||||
const hostFlag = Flag.string("host").pipe(
|
||||
Flag.withDescription("Host/interface to bind (for example 127.0.0.1, 0.0.0.0, or a Tailnet IP)."),
|
||||
Flag.optional,
|
||||
);
|
||||
|
||||
const stateDirFlag = Flag.string("state-dir").pipe(
|
||||
Flag.withDescription("State directory path (equivalent to T3CODE_STATE_DIR)."),
|
||||
Flag.optional,
|
||||
);
|
||||
|
||||
const devUrlFlag = Flag.string("dev-url").pipe(
|
||||
Flag.withSchema(Schema.URLFromString),
|
||||
Flag.withDescription("Dev web URL to proxy/redirect to (equivalent to VITE_DEV_SERVER_URL)."),
|
||||
Flag.optional,
|
||||
);
|
||||
|
||||
const noBrowserFlag = Flag.choice("no-browser", ["true", "false"]).pipe(
|
||||
Flag.withDescription("Disable automatic browser opening (`true` or `false`)."),
|
||||
Flag.optional,
|
||||
);
|
||||
|
||||
const authTokenFlag = Flag.string("auth-token").pipe(
|
||||
Flag.withDescription("Auth token required for WebSocket connections."),
|
||||
Flag.withAlias("token"),
|
||||
Flag.optional,
|
||||
);
|
||||
|
||||
const autoBootstrapProjectFromCwdFlag = Flag.choice(
|
||||
"auto-bootstrap-project-from-cwd",
|
||||
["true", "false"],
|
||||
).pipe(
|
||||
Flag.withDescription(
|
||||
"Create a project for the current working directory on startup when missing (`true` or `false`).",
|
||||
),
|
||||
Flag.optional,
|
||||
);
|
||||
|
||||
const logWebSocketEventsFlag = Flag.choice("log-websocket-events", ["true", "false"]).pipe(
|
||||
Flag.withDescription(
|
||||
"Emit server-side logs for outbound WebSocket push traffic (`true` or `false`).",
|
||||
),
|
||||
Flag.withAlias("log-ws-events"),
|
||||
Flag.optional,
|
||||
);
|
||||
|
||||
export const t3Cli = Command.make("t3", {
|
||||
mode: modeFlag,
|
||||
port: portFlag,
|
||||
host: hostFlag,
|
||||
baseDir: baseDirFlag,
|
||||
stateDir: stateDirFlag,
|
||||
devUrl: devUrlFlag,
|
||||
noBrowser: noBrowserFlag,
|
||||
authToken: authTokenFlag,
|
||||
bootstrapFd: bootstrapFdFlag,
|
||||
autoBootstrapProjectFromCwd: autoBootstrapProjectFromCwdFlag,
|
||||
logWebSocketEvents: logWebSocketEventsFlag,
|
||||
} as const;
|
||||
|
||||
const rootCommand = Command.make("t3", commandFlags).pipe(
|
||||
}).pipe(
|
||||
Command.withDescription("Run the T3 Code server."),
|
||||
Command.withHandler((flags) =>
|
||||
Effect.gen(function* () {
|
||||
const logLevel = yield* GlobalFlag.LogLevel;
|
||||
const config = yield* resolveServerConfig(flags, logLevel);
|
||||
return yield* runServer.pipe(Effect.provideService(ServerConfig, config));
|
||||
}),
|
||||
Command.withHandler((input: CliInput) =>
|
||||
Effect.flatMap(resolveServerConfig(input), (config) =>
|
||||
runServer.pipe(Effect.provideService(ServerConfig, config)),
|
||||
).pipe(Effect.provide(Layer.mergeAll(NetService.layer, NodeServices.layer))),
|
||||
),
|
||||
);
|
||||
|
||||
export const cli = rootCommand;
|
||||
@@ -37,7 +37,6 @@ function createSendTurnHarness() {
|
||||
planType: null,
|
||||
sparkEnabled: true,
|
||||
},
|
||||
collabReceiverTurns: new Map(),
|
||||
};
|
||||
|
||||
const requireSession = vi
|
||||
@@ -76,7 +75,6 @@ function createThreadControlHarness() {
|
||||
createdAt: "2026-02-10T00:00:00.000Z",
|
||||
updatedAt: "2026-02-10T00:00:00.000Z",
|
||||
},
|
||||
collabReceiverTurns: new Map(),
|
||||
};
|
||||
|
||||
const requireSession = vi
|
||||
@@ -119,7 +117,6 @@ function createPendingUserInputHarness() {
|
||||
},
|
||||
],
|
||||
]),
|
||||
collabReceiverTurns: new Map(),
|
||||
};
|
||||
|
||||
const requireSession = vi
|
||||
@@ -138,43 +135,6 @@ function createPendingUserInputHarness() {
|
||||
return { manager, context, requireSession, writeMessage, emitEvent };
|
||||
}
|
||||
|
||||
function createCollabNotificationHarness() {
|
||||
const manager = new CodexAppServerManager();
|
||||
const context = {
|
||||
session: {
|
||||
provider: "codex",
|
||||
status: "running",
|
||||
threadId: asThreadId("thread_1"),
|
||||
runtimeMode: "full-access",
|
||||
model: "gpt-5.3-codex",
|
||||
activeTurnId: "turn_parent",
|
||||
resumeCursor: { threadId: "provider_parent" },
|
||||
createdAt: "2026-02-10T00:00:00.000Z",
|
||||
updatedAt: "2026-02-10T00:00:00.000Z",
|
||||
},
|
||||
account: {
|
||||
type: "unknown",
|
||||
planType: null,
|
||||
sparkEnabled: true,
|
||||
},
|
||||
pending: new Map(),
|
||||
pendingApprovals: new Map(),
|
||||
pendingUserInputs: new Map(),
|
||||
collabReceiverTurns: new Map<string, string>(),
|
||||
nextRequestId: 1,
|
||||
stopping: false,
|
||||
};
|
||||
|
||||
const emitEvent = vi
|
||||
.spyOn(manager as unknown as { emitEvent: (...args: unknown[]) => void }, "emitEvent")
|
||||
.mockImplementation(() => {});
|
||||
const updateSession = vi
|
||||
.spyOn(manager as unknown as { updateSession: (...args: unknown[]) => void }, "updateSession")
|
||||
.mockImplementation(() => {});
|
||||
|
||||
return { manager, context, emitEvent, updateSession };
|
||||
}
|
||||
|
||||
describe("classifyCodexStderrLine", () => {
|
||||
it("ignores empty lines", () => {
|
||||
expect(classifyCodexStderrLine(" ")).toBeNull();
|
||||
@@ -207,42 +167,6 @@ describe("classifyCodexStderrLine", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("process stderr events", () => {
|
||||
it("emits classified stderr lines as notifications", () => {
|
||||
const manager = new CodexAppServerManager();
|
||||
const emitEvent = vi
|
||||
.spyOn(manager as unknown as { emitEvent: (...args: unknown[]) => void }, "emitEvent")
|
||||
.mockImplementation(() => {});
|
||||
|
||||
(
|
||||
manager as unknown as {
|
||||
emitNotificationEvent: (
|
||||
context: { session: { threadId: ThreadId } },
|
||||
method: string,
|
||||
message: string,
|
||||
) => void;
|
||||
}
|
||||
).emitNotificationEvent(
|
||||
{
|
||||
session: {
|
||||
threadId: asThreadId("thread-1"),
|
||||
},
|
||||
},
|
||||
"process/stderr",
|
||||
"fatal: permission denied",
|
||||
);
|
||||
|
||||
expect(emitEvent).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
kind: "notification",
|
||||
method: "process/stderr",
|
||||
threadId: "thread-1",
|
||||
message: "fatal: permission denied",
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("normalizeCodexModelSlug", () => {
|
||||
it("maps 5.3 aliases to gpt-5.3-codex", () => {
|
||||
expect(normalizeCodexModelSlug("5.3")).toBe("gpt-5.3-codex");
|
||||
@@ -310,7 +234,7 @@ describe("readCodexAccountSnapshot", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("disables spark for api key accounts", () => {
|
||||
it("keeps spark enabled for api key accounts", () => {
|
||||
expect(
|
||||
readCodexAccountSnapshot({
|
||||
type: "apiKey",
|
||||
@@ -318,20 +242,7 @@ describe("readCodexAccountSnapshot", () => {
|
||||
).toEqual({
|
||||
type: "apiKey",
|
||||
planType: null,
|
||||
sparkEnabled: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("disables spark for unknown chatgpt plans", () => {
|
||||
expect(
|
||||
readCodexAccountSnapshot({
|
||||
type: "chatgpt",
|
||||
email: "[email protected]",
|
||||
}),
|
||||
).toEqual({
|
||||
type: "chatgpt",
|
||||
planType: "unknown",
|
||||
sparkEnabled: false,
|
||||
sparkEnabled: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -356,16 +267,6 @@ describe("resolveCodexModelForAccount", () => {
|
||||
}),
|
||||
).toBe("gpt-5.3-codex-spark");
|
||||
});
|
||||
|
||||
it("falls back from spark to default for api key auth", () => {
|
||||
expect(
|
||||
resolveCodexModelForAccount("gpt-5.3-codex-spark", {
|
||||
type: "apiKey",
|
||||
planType: null,
|
||||
sparkEnabled: false,
|
||||
}),
|
||||
).toBe("gpt-5.3-codex");
|
||||
});
|
||||
});
|
||||
|
||||
describe("startSession", () => {
|
||||
@@ -401,7 +302,6 @@ describe("startSession", () => {
|
||||
manager.startSession({
|
||||
threadId: asThreadId("thread-1"),
|
||||
provider: "codex",
|
||||
binaryPath: "codex",
|
||||
runtimeMode: "full-access",
|
||||
}),
|
||||
).rejects.toThrow("cwd missing");
|
||||
@@ -450,7 +350,6 @@ describe("startSession", () => {
|
||||
manager.startSession({
|
||||
threadId: asThreadId("thread-1"),
|
||||
provider: "codex",
|
||||
binaryPath: "codex",
|
||||
runtimeMode: "full-access",
|
||||
}),
|
||||
).rejects.toThrow(
|
||||
@@ -822,7 +721,6 @@ describe("respondToUserInput", () => {
|
||||
},
|
||||
pendingApprovals: new Map(),
|
||||
pendingUserInputs: new Map(),
|
||||
collabReceiverTurns: new Map(),
|
||||
};
|
||||
type ApprovalRequestContext = {
|
||||
session: typeof context.session;
|
||||
@@ -850,152 +748,6 @@ describe("respondToUserInput", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("collab child conversation routing", () => {
|
||||
it("rewrites child notification turn ids onto the parent turn", () => {
|
||||
const { manager, context, emitEvent } = createCollabNotificationHarness();
|
||||
|
||||
(
|
||||
manager as unknown as {
|
||||
handleServerNotification: (context: unknown, notification: Record<string, unknown>) => void;
|
||||
}
|
||||
).handleServerNotification(context, {
|
||||
method: "item/completed",
|
||||
params: {
|
||||
item: {
|
||||
type: "collabAgentToolCall",
|
||||
id: "call_collab_1",
|
||||
receiverThreadIds: ["child_provider_1"],
|
||||
},
|
||||
threadId: "provider_parent",
|
||||
turnId: "turn_parent",
|
||||
},
|
||||
});
|
||||
|
||||
(
|
||||
manager as unknown as {
|
||||
handleServerNotification: (context: unknown, notification: Record<string, unknown>) => void;
|
||||
}
|
||||
).handleServerNotification(context, {
|
||||
method: "item/agentMessage/delta",
|
||||
params: {
|
||||
threadId: "child_provider_1",
|
||||
turnId: "turn_child_1",
|
||||
itemId: "msg_child_1",
|
||||
delta: "working",
|
||||
},
|
||||
});
|
||||
|
||||
expect(emitEvent).toHaveBeenLastCalledWith(
|
||||
expect.objectContaining({
|
||||
method: "item/agentMessage/delta",
|
||||
turnId: "turn_parent",
|
||||
itemId: "msg_child_1",
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("suppresses child lifecycle notifications so they cannot replace the parent turn", () => {
|
||||
const { manager, context, emitEvent, updateSession } = createCollabNotificationHarness();
|
||||
|
||||
(
|
||||
manager as unknown as {
|
||||
handleServerNotification: (context: unknown, notification: Record<string, unknown>) => void;
|
||||
}
|
||||
).handleServerNotification(context, {
|
||||
method: "item/completed",
|
||||
params: {
|
||||
item: {
|
||||
type: "collabAgentToolCall",
|
||||
id: "call_collab_1",
|
||||
receiverThreadIds: ["child_provider_1"],
|
||||
},
|
||||
threadId: "provider_parent",
|
||||
turnId: "turn_parent",
|
||||
},
|
||||
});
|
||||
emitEvent.mockClear();
|
||||
updateSession.mockClear();
|
||||
|
||||
(
|
||||
manager as unknown as {
|
||||
handleServerNotification: (context: unknown, notification: Record<string, unknown>) => void;
|
||||
}
|
||||
).handleServerNotification(context, {
|
||||
method: "turn/started",
|
||||
params: {
|
||||
threadId: "child_provider_1",
|
||||
turn: { id: "turn_child_1" },
|
||||
},
|
||||
});
|
||||
|
||||
(
|
||||
manager as unknown as {
|
||||
handleServerNotification: (context: unknown, notification: Record<string, unknown>) => void;
|
||||
}
|
||||
).handleServerNotification(context, {
|
||||
method: "turn/completed",
|
||||
params: {
|
||||
threadId: "child_provider_1",
|
||||
turn: { id: "turn_child_1", status: "completed" },
|
||||
},
|
||||
});
|
||||
|
||||
expect(emitEvent).not.toHaveBeenCalled();
|
||||
expect(updateSession).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("rewrites child approval requests onto the parent turn", () => {
|
||||
const { manager, context, emitEvent } = createCollabNotificationHarness();
|
||||
|
||||
(
|
||||
manager as unknown as {
|
||||
handleServerNotification: (context: unknown, notification: Record<string, unknown>) => void;
|
||||
}
|
||||
).handleServerNotification(context, {
|
||||
method: "item/completed",
|
||||
params: {
|
||||
item: {
|
||||
type: "collabAgentToolCall",
|
||||
id: "call_collab_1",
|
||||
receiverThreadIds: ["child_provider_1"],
|
||||
},
|
||||
threadId: "provider_parent",
|
||||
turnId: "turn_parent",
|
||||
},
|
||||
});
|
||||
emitEvent.mockClear();
|
||||
|
||||
(
|
||||
manager as unknown as {
|
||||
handleServerRequest: (context: unknown, request: Record<string, unknown>) => void;
|
||||
}
|
||||
).handleServerRequest(context, {
|
||||
id: 42,
|
||||
method: "item/commandExecution/requestApproval",
|
||||
params: {
|
||||
threadId: "child_provider_1",
|
||||
turnId: "turn_child_1",
|
||||
itemId: "call_child_1",
|
||||
command: "bun install",
|
||||
},
|
||||
});
|
||||
|
||||
expect(Array.from(context.pendingApprovals.values())[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
turnId: "turn_parent",
|
||||
itemId: "call_child_1",
|
||||
}),
|
||||
);
|
||||
expect(emitEvent).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
method: "item/commandExecution/requestApproval",
|
||||
turnId: "turn_parent",
|
||||
itemId: "call_child_1",
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
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-"));
|
||||
@@ -1009,8 +761,12 @@ describe.skipIf(!process.env.CODEX_BINARY_PATH)("startSession live Codex resume"
|
||||
provider: "codex",
|
||||
cwd: workspaceDir,
|
||||
runtimeMode: "full-access",
|
||||
binaryPath: process.env.CODEX_BINARY_PATH!,
|
||||
...(process.env.CODEX_HOME_PATH ? { homePath: process.env.CODEX_HOME_PATH } : {}),
|
||||
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({
|
||||
@@ -1040,8 +796,12 @@ describe.skipIf(!process.env.CODEX_BINARY_PATH)("startSession live Codex resume"
|
||||
cwd: workspaceDir,
|
||||
runtimeMode: "approval-required",
|
||||
resumeCursor: firstSession.resumeCursor,
|
||||
binaryPath: process.env.CODEX_BINARY_PATH!,
|
||||
...(process.env.CODEX_HOME_PATH ? { homePath: process.env.CODEX_HOME_PATH } : {}),
|
||||
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);
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
type ProviderApprovalDecision,
|
||||
type ProviderEvent,
|
||||
type ProviderSession,
|
||||
type ProviderSessionStartInput,
|
||||
type ProviderTurnStartResult,
|
||||
RuntimeMode,
|
||||
ProviderInteractionMode,
|
||||
@@ -26,15 +27,6 @@ import {
|
||||
isCodexCliVersionSupported,
|
||||
parseCodexCliVersion,
|
||||
} from "./provider/codexCliVersion";
|
||||
import {
|
||||
readCodexAccountSnapshot,
|
||||
resolveCodexModelForAccount,
|
||||
type CodexAccountSnapshot,
|
||||
} from "./provider/codexAccount";
|
||||
import { buildCodexInitializeParams, killCodexChildProcess } from "./provider/codexAppServer";
|
||||
|
||||
export { buildCodexInitializeParams } from "./provider/codexAppServer";
|
||||
export { readCodexAccountSnapshot, resolveCodexModelForAccount } from "./provider/codexAccount";
|
||||
|
||||
type PendingRequestKey = string;
|
||||
|
||||
@@ -78,7 +70,6 @@ interface CodexSessionContext {
|
||||
pending: Map<PendingRequestKey, PendingRequest>;
|
||||
pendingApprovals: Map<ApprovalRequestId, PendingApprovalRequest>;
|
||||
pendingUserInputs: Map<ApprovalRequestId, PendingUserInputRequest>;
|
||||
collabReceiverTurns: Map<string, TurnId>;
|
||||
nextRequestId: number;
|
||||
stopping: boolean;
|
||||
}
|
||||
@@ -105,6 +96,23 @@ interface JsonRpcNotification {
|
||||
params?: unknown;
|
||||
}
|
||||
|
||||
type CodexPlanType =
|
||||
| "free"
|
||||
| "go"
|
||||
| "plus"
|
||||
| "pro"
|
||||
| "team"
|
||||
| "business"
|
||||
| "enterprise"
|
||||
| "edu"
|
||||
| "unknown";
|
||||
|
||||
interface CodexAccountSnapshot {
|
||||
readonly type: "apiKey" | "chatgpt" | "unknown";
|
||||
readonly planType: CodexPlanType | null;
|
||||
readonly sparkEnabled: boolean;
|
||||
}
|
||||
|
||||
export interface CodexAppServerSendTurnInput {
|
||||
readonly threadId: ThreadId;
|
||||
readonly input?: string;
|
||||
@@ -122,8 +130,7 @@ export interface CodexAppServerStartSessionInput {
|
||||
readonly model?: string;
|
||||
readonly serviceTier?: string;
|
||||
readonly resumeCursor?: unknown;
|
||||
readonly binaryPath: string;
|
||||
readonly homePath?: string;
|
||||
readonly providerOptions?: ProviderSessionStartInput["providerOptions"];
|
||||
readonly runtimeMode: RuntimeMode;
|
||||
}
|
||||
|
||||
@@ -154,6 +161,50 @@ const RECOVERABLE_THREAD_RESUME_ERROR_SNIPPETS = [
|
||||
"unknown thread",
|
||||
"does not exist",
|
||||
];
|
||||
const CODEX_DEFAULT_MODEL = "gpt-5.3-codex";
|
||||
const CODEX_SPARK_MODEL = "gpt-5.3-codex-spark";
|
||||
const CODEX_SPARK_DISABLED_PLAN_TYPES = new Set<CodexPlanType>(["free", "go", "plus"]);
|
||||
|
||||
function asObject(value: unknown): Record<string, unknown> | undefined {
|
||||
if (!value || typeof value !== "object") {
|
||||
return undefined;
|
||||
}
|
||||
return value as Record<string, unknown>;
|
||||
}
|
||||
|
||||
function asString(value: unknown): string | undefined {
|
||||
return typeof value === "string" ? value : undefined;
|
||||
}
|
||||
|
||||
export function readCodexAccountSnapshot(response: unknown): CodexAccountSnapshot {
|
||||
const record = asObject(response);
|
||||
const account = asObject(record?.account) ?? record;
|
||||
const accountType = asString(account?.type);
|
||||
|
||||
if (accountType === "apiKey") {
|
||||
return {
|
||||
type: "apiKey",
|
||||
planType: null,
|
||||
sparkEnabled: true,
|
||||
};
|
||||
}
|
||||
|
||||
if (accountType === "chatgpt") {
|
||||
const planType = (account?.planType as CodexPlanType | null) ?? "unknown";
|
||||
return {
|
||||
type: "chatgpt",
|
||||
planType,
|
||||
sparkEnabled: !CODEX_SPARK_DISABLED_PLAN_TYPES.has(planType),
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
type: "unknown",
|
||||
planType: null,
|
||||
sparkEnabled: true,
|
||||
};
|
||||
}
|
||||
|
||||
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.
|
||||
@@ -306,13 +357,32 @@ function mapCodexRuntimeMode(runtimeMode: RuntimeMode): {
|
||||
};
|
||||
}
|
||||
|
||||
export function resolveCodexModelForAccount(
|
||||
model: string | undefined,
|
||||
account: CodexAccountSnapshot,
|
||||
): string | undefined {
|
||||
if (model !== CODEX_SPARK_MODEL || account.sparkEnabled) {
|
||||
return model;
|
||||
}
|
||||
|
||||
return CODEX_DEFAULT_MODEL;
|
||||
}
|
||||
|
||||
/**
|
||||
* On Windows with `shell: true`, `child.kill()` only terminates the `cmd.exe`
|
||||
* wrapper, leaving the actual command running. Use `taskkill /T` to kill the
|
||||
* entire process tree instead.
|
||||
*/
|
||||
function killChildTree(child: ChildProcessWithoutNullStreams): void {
|
||||
killCodexChildProcess(child);
|
||||
if (process.platform === "win32" && child.pid !== undefined) {
|
||||
try {
|
||||
spawnSync("taskkill", ["/pid", String(child.pid), "/T", "/F"], { stdio: "ignore" });
|
||||
return;
|
||||
} catch {
|
||||
// fallback to direct kill
|
||||
}
|
||||
}
|
||||
child.kill();
|
||||
}
|
||||
|
||||
export function normalizeCodexModelSlug(
|
||||
@@ -331,6 +401,19 @@ 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;
|
||||
@@ -457,8 +540,9 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
updatedAt: now,
|
||||
};
|
||||
|
||||
const codexBinaryPath = input.binaryPath;
|
||||
const codexHomePath = input.homePath;
|
||||
const codexOptions = readCodexProviderOptions(input);
|
||||
const codexBinaryPath = codexOptions.binaryPath ?? "codex";
|
||||
const codexHomePath = codexOptions.homePath;
|
||||
this.assertSupportedCodexCliVersion({
|
||||
binaryPath: codexBinaryPath,
|
||||
cwd: resolvedCwd,
|
||||
@@ -487,7 +571,6 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
pending: new Map(),
|
||||
pendingApprovals: new Map(),
|
||||
pendingUserInputs: new Map(),
|
||||
collabReceiverTurns: new Map(),
|
||||
nextRequestId: 1,
|
||||
stopping: false,
|
||||
};
|
||||
@@ -649,7 +732,6 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
|
||||
async sendTurn(input: CodexAppServerSendTurnInput): Promise<ProviderTurnStartResult> {
|
||||
const context = this.requireSession(input.threadId);
|
||||
context.collabReceiverTurns.clear();
|
||||
|
||||
const turnInput: Array<
|
||||
{ type: "text"; text: string; text_elements: [] } | { type: "image"; url: string }
|
||||
@@ -962,7 +1044,7 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
continue;
|
||||
}
|
||||
|
||||
this.emitNotificationEvent(context, "process/stderr", classified.message);
|
||||
this.emitErrorEvent(context, "process/stderr", classified.message);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1039,16 +1121,7 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
context: CodexSessionContext,
|
||||
notification: JsonRpcNotification,
|
||||
): void {
|
||||
const rawRoute = this.readRouteFields(notification.params);
|
||||
this.rememberCollabReceiverTurns(context, notification.params, rawRoute.turnId);
|
||||
const childParentTurnId = this.readChildParentTurnId(context, notification.params);
|
||||
const isChildConversation = childParentTurnId !== undefined;
|
||||
if (
|
||||
isChildConversation &&
|
||||
this.shouldSuppressChildConversationNotification(notification.method)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
const route = this.readRouteFields(notification.params);
|
||||
const textDelta =
|
||||
notification.method === "item/agentMessage/delta"
|
||||
? this.readString(notification.params, "delta")
|
||||
@@ -1061,10 +1134,8 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
threadId: context.session.threadId,
|
||||
createdAt: new Date().toISOString(),
|
||||
method: notification.method,
|
||||
...((childParentTurnId ?? rawRoute.turnId)
|
||||
? { turnId: childParentTurnId ?? rawRoute.turnId }
|
||||
: {}),
|
||||
...(rawRoute.itemId ? { itemId: rawRoute.itemId } : {}),
|
||||
turnId: route.turnId,
|
||||
itemId: route.itemId,
|
||||
textDelta,
|
||||
payload: notification.params,
|
||||
});
|
||||
@@ -1080,9 +1151,6 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
}
|
||||
|
||||
if (notification.method === "turn/started") {
|
||||
if (isChildConversation) {
|
||||
return;
|
||||
}
|
||||
const turnId = toTurnId(this.readString(this.readObject(notification.params)?.turn, "id"));
|
||||
this.updateSession(context, {
|
||||
status: "running",
|
||||
@@ -1092,10 +1160,6 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
}
|
||||
|
||||
if (notification.method === "turn/completed") {
|
||||
if (isChildConversation) {
|
||||
return;
|
||||
}
|
||||
context.collabReceiverTurns.clear();
|
||||
const turn = this.readObject(notification.params, "turn");
|
||||
const status = this.readString(turn, "status");
|
||||
const errorMessage = this.readString(this.readObject(turn, "error"), "message");
|
||||
@@ -1108,9 +1172,6 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
}
|
||||
|
||||
if (notification.method === "error") {
|
||||
if (isChildConversation) {
|
||||
return;
|
||||
}
|
||||
const message = this.readString(this.readObject(notification.params)?.error, "message");
|
||||
const willRetry = this.readBoolean(notification.params, "willRetry");
|
||||
|
||||
@@ -1122,9 +1183,7 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
}
|
||||
|
||||
private handleServerRequest(context: CodexSessionContext, request: JsonRpcRequest): void {
|
||||
const rawRoute = this.readRouteFields(request.params);
|
||||
const childParentTurnId = this.readChildParentTurnId(context, request.params);
|
||||
const effectiveTurnId = childParentTurnId ?? rawRoute.turnId;
|
||||
const route = this.readRouteFields(request.params);
|
||||
const requestKind = this.requestKindForMethod(request.method);
|
||||
let requestId: ApprovalRequestId | undefined;
|
||||
if (requestKind) {
|
||||
@@ -1140,8 +1199,8 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
: "item/fileChange/requestApproval",
|
||||
requestKind,
|
||||
threadId: context.session.threadId,
|
||||
...(effectiveTurnId ? { turnId: effectiveTurnId } : {}),
|
||||
...(rawRoute.itemId ? { itemId: rawRoute.itemId } : {}),
|
||||
...(route.turnId ? { turnId: route.turnId } : {}),
|
||||
...(route.itemId ? { itemId: route.itemId } : {}),
|
||||
};
|
||||
context.pendingApprovals.set(requestId, pendingRequest);
|
||||
}
|
||||
@@ -1152,8 +1211,8 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
requestId,
|
||||
jsonRpcId: request.id,
|
||||
threadId: context.session.threadId,
|
||||
...(effectiveTurnId ? { turnId: effectiveTurnId } : {}),
|
||||
...(rawRoute.itemId ? { itemId: rawRoute.itemId } : {}),
|
||||
...(route.turnId ? { turnId: route.turnId } : {}),
|
||||
...(route.itemId ? { itemId: route.itemId } : {}),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1164,8 +1223,8 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
threadId: context.session.threadId,
|
||||
createdAt: new Date().toISOString(),
|
||||
method: request.method,
|
||||
...(effectiveTurnId ? { turnId: effectiveTurnId } : {}),
|
||||
...(rawRoute.itemId ? { itemId: rawRoute.itemId } : {}),
|
||||
turnId: route.turnId,
|
||||
itemId: route.itemId,
|
||||
requestId,
|
||||
requestKind,
|
||||
payload: request.params,
|
||||
@@ -1270,22 +1329,6 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
});
|
||||
}
|
||||
|
||||
private emitNotificationEvent(
|
||||
context: CodexSessionContext,
|
||||
method: string,
|
||||
message: string,
|
||||
): void {
|
||||
this.emitEvent({
|
||||
id: EventId.makeUnsafe(randomUUID()),
|
||||
kind: "notification",
|
||||
provider: "codex",
|
||||
threadId: context.session.threadId,
|
||||
createdAt: new Date().toISOString(),
|
||||
method,
|
||||
message,
|
||||
});
|
||||
}
|
||||
|
||||
private emitEvent(event: ProviderEvent): void {
|
||||
this.emit("event", event);
|
||||
}
|
||||
@@ -1408,64 +1451,6 @@ export class CodexAppServerManager extends EventEmitter<CodexAppServerManagerEve
|
||||
return route;
|
||||
}
|
||||
|
||||
private readProviderConversationId(params: unknown): string | undefined {
|
||||
return (
|
||||
this.readString(params, "threadId") ??
|
||||
this.readString(this.readObject(params, "thread"), "id") ??
|
||||
this.readString(params, "conversationId")
|
||||
);
|
||||
}
|
||||
|
||||
private readChildParentTurnId(context: CodexSessionContext, params: unknown): TurnId | undefined {
|
||||
const providerConversationId = this.readProviderConversationId(params);
|
||||
if (!providerConversationId) {
|
||||
return undefined;
|
||||
}
|
||||
return context.collabReceiverTurns.get(providerConversationId);
|
||||
}
|
||||
|
||||
private rememberCollabReceiverTurns(
|
||||
context: CodexSessionContext,
|
||||
params: unknown,
|
||||
parentTurnId: TurnId | undefined,
|
||||
): void {
|
||||
if (!parentTurnId) {
|
||||
return;
|
||||
}
|
||||
const payload = this.readObject(params);
|
||||
const item = this.readObject(payload, "item") ?? payload;
|
||||
const itemType = this.readString(item, "type") ?? this.readString(item, "kind");
|
||||
if (itemType !== "collabAgentToolCall") {
|
||||
return;
|
||||
}
|
||||
|
||||
const receiverThreadIds =
|
||||
this.readArray(item, "receiverThreadIds")
|
||||
?.map((value) => (typeof value === "string" ? value : null))
|
||||
.filter((value): value is string => value !== null) ?? [];
|
||||
for (const receiverThreadId of receiverThreadIds) {
|
||||
context.collabReceiverTurns.set(receiverThreadId, parentTurnId);
|
||||
}
|
||||
}
|
||||
|
||||
private shouldSuppressChildConversationNotification(method: string): boolean {
|
||||
return (
|
||||
method === "thread/started" ||
|
||||
method === "thread/status/changed" ||
|
||||
method === "thread/archived" ||
|
||||
method === "thread/unarchived" ||
|
||||
method === "thread/closed" ||
|
||||
method === "thread/compacted" ||
|
||||
method === "thread/name/updated" ||
|
||||
method === "thread/tokenUsage/updated" ||
|
||||
method === "turn/started" ||
|
||||
method === "turn/completed" ||
|
||||
method === "turn/aborted" ||
|
||||
method === "turn/plan/updated" ||
|
||||
method === "item/plan/delta"
|
||||
);
|
||||
}
|
||||
|
||||
private readObject(value: unknown, key?: string): Record<string, unknown> | undefined {
|
||||
const target =
|
||||
key === undefined
|
||||
@@ -1522,6 +1507,20 @@ function normalizeProviderThreadId(value: string | undefined): string | undefine
|
||||
return brandIfNonEmpty(value, (normalized) => normalized);
|
||||
}
|
||||
|
||||
function readCodexProviderOptions(input: CodexAppServerStartSessionInput): {
|
||||
readonly binaryPath?: string;
|
||||
readonly homePath?: string;
|
||||
} {
|
||||
const options = input.providerOptions?.codex;
|
||||
if (!options) {
|
||||
return {};
|
||||
}
|
||||
return {
|
||||
...(options.binaryPath ? { binaryPath: options.binaryPath } : {}),
|
||||
...(options.homePath ? { homePath: options.homePath } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
function assertSupportedCodexCliVersion(input: {
|
||||
readonly binaryPath: string;
|
||||
readonly cwd: string;
|
||||
@@ -1575,11 +1574,7 @@ function readResumeCursorThreadId(resumeCursor: unknown): string | undefined {
|
||||
return typeof rawThreadId === "string" ? normalizeProviderThreadId(rawThreadId) : undefined;
|
||||
}
|
||||
|
||||
function readResumeThreadId(input: {
|
||||
readonly resumeCursor?: unknown;
|
||||
readonly threadId?: ThreadId;
|
||||
readonly runtimeMode?: RuntimeMode;
|
||||
}): string | undefined {
|
||||
function readResumeThreadId(input: CodexAppServerStartSessionInput): string | undefined {
|
||||
return readResumeCursorThreadId(input.resumeCursor);
|
||||
}
|
||||
|
||||
|
||||
+11
-86
@@ -6,41 +6,22 @@
|
||||
*
|
||||
* @module ServerConfig
|
||||
*/
|
||||
import { Effect, FileSystem, Layer, LogLevel, Path, Schema, ServiceMap } from "effect";
|
||||
import { Effect, FileSystem, Layer, Path, ServiceMap } from "effect";
|
||||
|
||||
export const DEFAULT_PORT = 3773;
|
||||
|
||||
export const RuntimeMode = Schema.Literals(["web", "desktop"]);
|
||||
export type RuntimeMode = typeof RuntimeMode.Type;
|
||||
|
||||
/**
|
||||
* ServerDerivedPaths - Derived paths from the base directory.
|
||||
*/
|
||||
export interface ServerDerivedPaths {
|
||||
readonly stateDir: string;
|
||||
readonly dbPath: string;
|
||||
readonly keybindingsConfigPath: string;
|
||||
readonly settingsPath: string;
|
||||
readonly worktreesDir: string;
|
||||
readonly attachmentsDir: string;
|
||||
readonly logsDir: string;
|
||||
readonly serverLogPath: string;
|
||||
readonly providerLogsDir: string;
|
||||
readonly providerEventLogPath: string;
|
||||
readonly terminalLogsDir: string;
|
||||
readonly anonymousIdPath: string;
|
||||
}
|
||||
export type RuntimeMode = "web" | "desktop";
|
||||
|
||||
/**
|
||||
* ServerConfigShape - Process/runtime configuration required by the server.
|
||||
*/
|
||||
export interface ServerConfigShape extends ServerDerivedPaths {
|
||||
readonly logLevel: LogLevel.LogLevel;
|
||||
export interface ServerConfigShape {
|
||||
readonly mode: RuntimeMode;
|
||||
readonly port: number;
|
||||
readonly host: string | undefined;
|
||||
readonly cwd: string;
|
||||
readonly baseDir: string;
|
||||
readonly keybindingsConfigPath: string;
|
||||
readonly stateDir: string;
|
||||
readonly staticDir: string | undefined;
|
||||
readonly devUrl: URL | undefined;
|
||||
readonly noBrowser: boolean;
|
||||
@@ -49,87 +30,31 @@ export interface ServerConfigShape extends ServerDerivedPaths {
|
||||
readonly logWebSocketEvents: boolean;
|
||||
}
|
||||
|
||||
export const deriveServerPaths = Effect.fn(function* (
|
||||
baseDir: ServerConfigShape["baseDir"],
|
||||
devUrl: ServerConfigShape["devUrl"],
|
||||
): Effect.fn.Return<ServerDerivedPaths, never, Path.Path> {
|
||||
const { join } = yield* Path.Path;
|
||||
const stateDir = join(baseDir, devUrl !== undefined ? "dev" : "userdata");
|
||||
const dbPath = join(stateDir, "state.sqlite");
|
||||
const attachmentsDir = join(stateDir, "attachments");
|
||||
const logsDir = join(stateDir, "logs");
|
||||
const providerLogsDir = join(logsDir, "provider");
|
||||
return {
|
||||
stateDir,
|
||||
dbPath,
|
||||
keybindingsConfigPath: join(stateDir, "keybindings.json"),
|
||||
settingsPath: join(stateDir, "settings.json"),
|
||||
worktreesDir: join(baseDir, "worktrees"),
|
||||
attachmentsDir,
|
||||
logsDir,
|
||||
serverLogPath: join(logsDir, "server.log"),
|
||||
providerLogsDir,
|
||||
providerEventLogPath: join(providerLogsDir, "events.log"),
|
||||
terminalLogsDir: join(logsDir, "terminals"),
|
||||
anonymousIdPath: join(stateDir, "anonymous-id"),
|
||||
};
|
||||
});
|
||||
|
||||
export const ensureServerDirectories = Effect.fn(function* (derivedPaths: ServerDerivedPaths) {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
|
||||
yield* Effect.all(
|
||||
[
|
||||
fs.makeDirectory(derivedPaths.stateDir, { recursive: true }),
|
||||
fs.makeDirectory(derivedPaths.logsDir, { recursive: true }),
|
||||
fs.makeDirectory(derivedPaths.providerLogsDir, { recursive: true }),
|
||||
fs.makeDirectory(derivedPaths.terminalLogsDir, { recursive: true }),
|
||||
fs.makeDirectory(derivedPaths.attachmentsDir, { recursive: true }),
|
||||
fs.makeDirectory(derivedPaths.worktreesDir, { recursive: true }),
|
||||
fs.makeDirectory(path.dirname(derivedPaths.keybindingsConfigPath), { recursive: true }),
|
||||
fs.makeDirectory(path.dirname(derivedPaths.settingsPath), { recursive: true }),
|
||||
fs.makeDirectory(path.dirname(derivedPaths.anonymousIdPath), { recursive: true }),
|
||||
],
|
||||
{ concurrency: "unbounded" },
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* ServerConfig - Service tag for server runtime configuration.
|
||||
*/
|
||||
export class ServerConfig extends ServiceMap.Service<ServerConfig, ServerConfigShape>()(
|
||||
"t3/config/ServerConfig",
|
||||
) {
|
||||
static readonly layerTest = (cwd: string, baseDirOrPrefix: string | { prefix: string }) =>
|
||||
static readonly layerTest = (cwd: string, statedir: string) =>
|
||||
Layer.effect(
|
||||
ServerConfig,
|
||||
Effect.gen(function* () {
|
||||
const devUrl = undefined;
|
||||
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const baseDir =
|
||||
typeof baseDirOrPrefix === "string"
|
||||
? baseDirOrPrefix
|
||||
: yield* fs.makeTempDirectoryScoped({ prefix: baseDirOrPrefix.prefix });
|
||||
const derivedPaths = yield* deriveServerPaths(baseDir, devUrl);
|
||||
yield* ensureServerDirectories(derivedPaths);
|
||||
|
||||
const path = yield* Path.Path;
|
||||
return {
|
||||
logLevel: "Error",
|
||||
cwd,
|
||||
baseDir,
|
||||
...derivedPaths,
|
||||
stateDir: statedir,
|
||||
mode: "web",
|
||||
autoBootstrapProjectFromCwd: false,
|
||||
logWebSocketEvents: false,
|
||||
port: 0,
|
||||
host: undefined,
|
||||
authToken: undefined,
|
||||
keybindingsConfigPath: path.join(statedir, "keybindings.json"),
|
||||
staticDir: undefined,
|
||||
devUrl,
|
||||
devUrl: undefined,
|
||||
noBrowser: false,
|
||||
} satisfies ServerConfigShape;
|
||||
};
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
import { Schema } from "effect";
|
||||
|
||||
/**
|
||||
* GitCommandError - Git command execution failed.
|
||||
*/
|
||||
export class GitCommandError extends Schema.TaggedErrorClass<GitCommandError>()("GitCommandError", {
|
||||
operation: Schema.String,
|
||||
command: Schema.String,
|
||||
cwd: Schema.String,
|
||||
detail: Schema.String,
|
||||
cause: Schema.optional(Schema.Defect),
|
||||
}) {
|
||||
override get message(): string {
|
||||
return `Git command failed in ${this.operation}: ${this.command} (${this.cwd}) - ${this.detail}`;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* GitHubCliError - GitHub CLI execution or authentication failed.
|
||||
*/
|
||||
export class GitHubCliError extends Schema.TaggedErrorClass<GitHubCliError>()("GitHubCliError", {
|
||||
operation: Schema.String,
|
||||
detail: Schema.String,
|
||||
cause: Schema.optional(Schema.Defect),
|
||||
}) {
|
||||
override get message(): string {
|
||||
return `GitHub CLI failed in ${this.operation}: ${this.detail}`;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TextGenerationError - Commit or PR text generation failed.
|
||||
*/
|
||||
export class TextGenerationError extends Schema.TaggedErrorClass<TextGenerationError>()(
|
||||
"TextGenerationError",
|
||||
{
|
||||
operation: Schema.String,
|
||||
detail: Schema.String,
|
||||
cause: Schema.optional(Schema.Defect),
|
||||
},
|
||||
) {
|
||||
override get message(): string {
|
||||
return `Text generation failed in ${this.operation}: ${this.detail}`;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* GitManagerError - Stacked Git workflow orchestration failed.
|
||||
*/
|
||||
export class GitManagerError extends Schema.TaggedErrorClass<GitManagerError>()("GitManagerError", {
|
||||
operation: Schema.String,
|
||||
detail: Schema.String,
|
||||
cause: Schema.optional(Schema.Defect),
|
||||
}) {
|
||||
override get message(): string {
|
||||
return `Git manager failed in ${this.operation}: ${this.detail}`;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* GitManagerServiceError - Errors emitted by stacked Git workflow orchestration.
|
||||
*/
|
||||
export type GitManagerServiceError =
|
||||
| GitManagerError
|
||||
| GitCommandError
|
||||
| GitHubCliError
|
||||
| TextGenerationError;
|
||||
@@ -1,309 +0,0 @@
|
||||
import * as NodeServices from "@effect/platform-node/NodeServices";
|
||||
import { it } from "@effect/vitest";
|
||||
import { Effect, FileSystem, Layer, Path } from "effect";
|
||||
import { expect } from "vitest";
|
||||
|
||||
import { ServerConfig } from "../../config.ts";
|
||||
import { TextGeneration } from "../Services/TextGeneration.ts";
|
||||
import { sanitizeThreadTitle } from "../Utils.ts";
|
||||
import { ClaudeTextGenerationLive } from "./ClaudeTextGeneration.ts";
|
||||
import { ServerSettingsService } from "../../serverSettings.ts";
|
||||
|
||||
const ClaudeTextGenerationTestLayer = ClaudeTextGenerationLive.pipe(
|
||||
Layer.provideMerge(ServerSettingsService.layerTest()),
|
||||
Layer.provideMerge(
|
||||
ServerConfig.layerTest(process.cwd(), {
|
||||
prefix: "t3code-claude-text-generation-test-",
|
||||
}),
|
||||
),
|
||||
Layer.provideMerge(NodeServices.layer),
|
||||
);
|
||||
|
||||
function makeFakeClaudeBinary(dir: string) {
|
||||
return Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const binDir = path.join(dir, "bin");
|
||||
const claudePath = path.join(binDir, "claude");
|
||||
yield* fs.makeDirectory(binDir, { recursive: true });
|
||||
|
||||
yield* fs.writeFileString(
|
||||
claudePath,
|
||||
[
|
||||
"#!/bin/sh",
|
||||
'args="$*"',
|
||||
'stdin_content="$(cat)"',
|
||||
'if [ -n "$T3_FAKE_CLAUDE_ARGS_MUST_CONTAIN" ]; then',
|
||||
' printf "%s" "$args" | grep -F -- "$T3_FAKE_CLAUDE_ARGS_MUST_CONTAIN" >/dev/null || {',
|
||||
' printf "%s\\n" "args missing expected content" >&2',
|
||||
" exit 2",
|
||||
" }",
|
||||
"fi",
|
||||
'if [ -n "$T3_FAKE_CLAUDE_ARGS_MUST_NOT_CONTAIN" ]; then',
|
||||
' if printf "%s" "$args" | grep -F -- "$T3_FAKE_CLAUDE_ARGS_MUST_NOT_CONTAIN" >/dev/null; then',
|
||||
' printf "%s\\n" "args contained forbidden content" >&2',
|
||||
" exit 3",
|
||||
" fi",
|
||||
"fi",
|
||||
'if [ -n "$T3_FAKE_CLAUDE_STDIN_MUST_CONTAIN" ]; then',
|
||||
' printf "%s" "$stdin_content" | grep -F -- "$T3_FAKE_CLAUDE_STDIN_MUST_CONTAIN" >/dev/null || {',
|
||||
' printf "%s\\n" "stdin missing expected content" >&2',
|
||||
" exit 4",
|
||||
" }",
|
||||
"fi",
|
||||
'if [ -n "$T3_FAKE_CLAUDE_STDERR" ]; then',
|
||||
' printf "%s\\n" "$T3_FAKE_CLAUDE_STDERR" >&2',
|
||||
"fi",
|
||||
'printf "%s" "$T3_FAKE_CLAUDE_OUTPUT"',
|
||||
'exit "${T3_FAKE_CLAUDE_EXIT_CODE:-0}"',
|
||||
"",
|
||||
].join("\n"),
|
||||
);
|
||||
yield* fs.chmod(claudePath, 0o755);
|
||||
return binDir;
|
||||
});
|
||||
}
|
||||
|
||||
function withFakeClaudeEnv<A, E, R>(
|
||||
input: {
|
||||
output: string;
|
||||
exitCode?: number;
|
||||
stderr?: string;
|
||||
argsMustContain?: string;
|
||||
argsMustNotContain?: string;
|
||||
stdinMustContain?: string;
|
||||
},
|
||||
effect: Effect.Effect<A, E, R>,
|
||||
) {
|
||||
return Effect.acquireUseRelease(
|
||||
Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3code-claude-text-" });
|
||||
const binDir = yield* makeFakeClaudeBinary(tempDir);
|
||||
const previousPath = process.env.PATH;
|
||||
const previousOutput = process.env.T3_FAKE_CLAUDE_OUTPUT;
|
||||
const previousExitCode = process.env.T3_FAKE_CLAUDE_EXIT_CODE;
|
||||
const previousStderr = process.env.T3_FAKE_CLAUDE_STDERR;
|
||||
const previousArgsMustContain = process.env.T3_FAKE_CLAUDE_ARGS_MUST_CONTAIN;
|
||||
const previousArgsMustNotContain = process.env.T3_FAKE_CLAUDE_ARGS_MUST_NOT_CONTAIN;
|
||||
const previousStdinMustContain = process.env.T3_FAKE_CLAUDE_STDIN_MUST_CONTAIN;
|
||||
|
||||
yield* Effect.sync(() => {
|
||||
process.env.PATH = `${binDir}:${previousPath ?? ""}`;
|
||||
process.env.T3_FAKE_CLAUDE_OUTPUT = input.output;
|
||||
|
||||
if (input.exitCode !== undefined) {
|
||||
process.env.T3_FAKE_CLAUDE_EXIT_CODE = String(input.exitCode);
|
||||
} else {
|
||||
delete process.env.T3_FAKE_CLAUDE_EXIT_CODE;
|
||||
}
|
||||
|
||||
if (input.stderr !== undefined) {
|
||||
process.env.T3_FAKE_CLAUDE_STDERR = input.stderr;
|
||||
} else {
|
||||
delete process.env.T3_FAKE_CLAUDE_STDERR;
|
||||
}
|
||||
|
||||
if (input.argsMustContain !== undefined) {
|
||||
process.env.T3_FAKE_CLAUDE_ARGS_MUST_CONTAIN = input.argsMustContain;
|
||||
} else {
|
||||
delete process.env.T3_FAKE_CLAUDE_ARGS_MUST_CONTAIN;
|
||||
}
|
||||
|
||||
if (input.argsMustNotContain !== undefined) {
|
||||
process.env.T3_FAKE_CLAUDE_ARGS_MUST_NOT_CONTAIN = input.argsMustNotContain;
|
||||
} else {
|
||||
delete process.env.T3_FAKE_CLAUDE_ARGS_MUST_NOT_CONTAIN;
|
||||
}
|
||||
|
||||
if (input.stdinMustContain !== undefined) {
|
||||
process.env.T3_FAKE_CLAUDE_STDIN_MUST_CONTAIN = input.stdinMustContain;
|
||||
} else {
|
||||
delete process.env.T3_FAKE_CLAUDE_STDIN_MUST_CONTAIN;
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
previousPath,
|
||||
previousOutput,
|
||||
previousExitCode,
|
||||
previousStderr,
|
||||
previousArgsMustContain,
|
||||
previousArgsMustNotContain,
|
||||
previousStdinMustContain,
|
||||
};
|
||||
}),
|
||||
() => effect,
|
||||
(previous) =>
|
||||
Effect.sync(() => {
|
||||
process.env.PATH = previous.previousPath;
|
||||
|
||||
if (previous.previousOutput === undefined) {
|
||||
delete process.env.T3_FAKE_CLAUDE_OUTPUT;
|
||||
} else {
|
||||
process.env.T3_FAKE_CLAUDE_OUTPUT = previous.previousOutput;
|
||||
}
|
||||
|
||||
if (previous.previousExitCode === undefined) {
|
||||
delete process.env.T3_FAKE_CLAUDE_EXIT_CODE;
|
||||
} else {
|
||||
process.env.T3_FAKE_CLAUDE_EXIT_CODE = previous.previousExitCode;
|
||||
}
|
||||
|
||||
if (previous.previousStderr === undefined) {
|
||||
delete process.env.T3_FAKE_CLAUDE_STDERR;
|
||||
} else {
|
||||
process.env.T3_FAKE_CLAUDE_STDERR = previous.previousStderr;
|
||||
}
|
||||
|
||||
if (previous.previousArgsMustContain === undefined) {
|
||||
delete process.env.T3_FAKE_CLAUDE_ARGS_MUST_CONTAIN;
|
||||
} else {
|
||||
process.env.T3_FAKE_CLAUDE_ARGS_MUST_CONTAIN = previous.previousArgsMustContain;
|
||||
}
|
||||
|
||||
if (previous.previousArgsMustNotContain === undefined) {
|
||||
delete process.env.T3_FAKE_CLAUDE_ARGS_MUST_NOT_CONTAIN;
|
||||
} else {
|
||||
process.env.T3_FAKE_CLAUDE_ARGS_MUST_NOT_CONTAIN = previous.previousArgsMustNotContain;
|
||||
}
|
||||
|
||||
if (previous.previousStdinMustContain === undefined) {
|
||||
delete process.env.T3_FAKE_CLAUDE_STDIN_MUST_CONTAIN;
|
||||
} else {
|
||||
process.env.T3_FAKE_CLAUDE_STDIN_MUST_CONTAIN = previous.previousStdinMustContain;
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
it.layer(ClaudeTextGenerationTestLayer)("ClaudeTextGenerationLive", (it) => {
|
||||
it.effect("forwards Claude thinking settings for Haiku without passing effort", () =>
|
||||
withFakeClaudeEnv(
|
||||
{
|
||||
output: JSON.stringify({
|
||||
structured_output: {
|
||||
subject: "Add important change",
|
||||
body: "",
|
||||
},
|
||||
}),
|
||||
argsMustContain: '--settings {"alwaysThinkingEnabled":false}',
|
||||
argsMustNotContain: "--effort",
|
||||
},
|
||||
Effect.gen(function* () {
|
||||
const textGeneration = yield* TextGeneration;
|
||||
|
||||
const generated = yield* textGeneration.generateCommitMessage({
|
||||
cwd: process.cwd(),
|
||||
branch: "feature/claude-effect",
|
||||
stagedSummary: "M README.md",
|
||||
stagedPatch: "diff --git a/README.md b/README.md",
|
||||
modelSelection: {
|
||||
provider: "claudeAgent",
|
||||
model: "claude-haiku-4-5",
|
||||
options: {
|
||||
thinking: false,
|
||||
effort: "high",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(generated.subject).toBe("Add important change");
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
it.effect("forwards Claude fast mode and supported effort", () =>
|
||||
withFakeClaudeEnv(
|
||||
{
|
||||
output: JSON.stringify({
|
||||
structured_output: {
|
||||
title: "Improve orchestration flow",
|
||||
body: "Body",
|
||||
},
|
||||
}),
|
||||
argsMustContain: '--effort max --settings {"fastMode":true}',
|
||||
},
|
||||
Effect.gen(function* () {
|
||||
const textGeneration = yield* TextGeneration;
|
||||
|
||||
const generated = yield* textGeneration.generatePrContent({
|
||||
cwd: process.cwd(),
|
||||
baseBranch: "main",
|
||||
headBranch: "feature/claude-effect",
|
||||
commitSummary: "Improve orchestration",
|
||||
diffSummary: "1 file changed",
|
||||
diffPatch: "diff --git a/README.md b/README.md",
|
||||
modelSelection: {
|
||||
provider: "claudeAgent",
|
||||
model: "claude-opus-4-6",
|
||||
options: {
|
||||
effort: "max",
|
||||
fastMode: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(generated.title).toBe("Improve orchestration flow");
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
it.effect("generates thread titles through the Claude provider", () =>
|
||||
withFakeClaudeEnv(
|
||||
{
|
||||
output: JSON.stringify({
|
||||
structured_output: {
|
||||
title:
|
||||
' "Reconnect failures after restart because the session state does not recover" ',
|
||||
},
|
||||
}),
|
||||
stdinMustContain: "You write concise thread titles for coding conversations.",
|
||||
},
|
||||
Effect.gen(function* () {
|
||||
const textGeneration = yield* TextGeneration;
|
||||
|
||||
const generated = yield* textGeneration.generateThreadTitle({
|
||||
cwd: process.cwd(),
|
||||
message: "Please investigate reconnect failures after restarting the session.",
|
||||
modelSelection: {
|
||||
provider: "claudeAgent",
|
||||
model: "claude-sonnet-4-6",
|
||||
},
|
||||
});
|
||||
|
||||
expect(generated.title).toBe(
|
||||
sanitizeThreadTitle(
|
||||
'"Reconnect failures after restart because the session state does not recover"',
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
it.effect("falls back when Claude thread title normalization becomes whitespace-only", () =>
|
||||
withFakeClaudeEnv(
|
||||
{
|
||||
output: JSON.stringify({
|
||||
structured_output: {
|
||||
title: ' """ """ ',
|
||||
},
|
||||
}),
|
||||
},
|
||||
Effect.gen(function* () {
|
||||
const textGeneration = yield* TextGeneration;
|
||||
|
||||
const generated = yield* textGeneration.generateThreadTitle({
|
||||
cwd: process.cwd(),
|
||||
message: "Name this thread.",
|
||||
modelSelection: {
|
||||
provider: "claudeAgent",
|
||||
model: "claude-sonnet-4-6",
|
||||
},
|
||||
});
|
||||
|
||||
expect(generated.title).toBe("New thread");
|
||||
}),
|
||||
),
|
||||
);
|
||||
});
|
||||
@@ -1,339 +0,0 @@
|
||||
/**
|
||||
* ClaudeTextGeneration – Text generation layer using the Claude CLI.
|
||||
*
|
||||
* Implements the same TextGenerationShape contract as CodexTextGeneration but
|
||||
* delegates to the `claude` CLI (`claude -p`) with structured JSON output
|
||||
* instead of the `codex exec` CLI.
|
||||
*
|
||||
* @module ClaudeTextGeneration
|
||||
*/
|
||||
import { Effect, Layer, Option, Schema, Stream } from "effect";
|
||||
import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";
|
||||
|
||||
import { ClaudeModelSelection } from "@t3tools/contracts";
|
||||
import { resolveApiModelId } from "@t3tools/shared/model";
|
||||
import { sanitizeBranchFragment, sanitizeFeatureBranchName } from "@t3tools/shared/git";
|
||||
|
||||
import { TextGenerationError } from "@t3tools/contracts";
|
||||
import { type TextGenerationShape, TextGeneration } from "../Services/TextGeneration.ts";
|
||||
import {
|
||||
buildBranchNamePrompt,
|
||||
buildCommitMessagePrompt,
|
||||
buildPrContentPrompt,
|
||||
buildThreadTitlePrompt,
|
||||
} from "../Prompts.ts";
|
||||
import {
|
||||
normalizeCliError,
|
||||
sanitizeCommitSubject,
|
||||
sanitizePrTitle,
|
||||
sanitizeThreadTitle,
|
||||
toJsonSchemaObject,
|
||||
} from "../Utils.ts";
|
||||
import { normalizeClaudeModelOptionsWithCapabilities } from "@t3tools/shared/model";
|
||||
import { ServerSettingsService } from "../../serverSettings.ts";
|
||||
import { getClaudeModelCapabilities } from "../../provider/Layers/ClaudeProvider.ts";
|
||||
|
||||
const CLAUDE_TIMEOUT_MS = 180_000;
|
||||
|
||||
/**
|
||||
* Schema for the wrapper JSON returned by `claude -p --output-format json`.
|
||||
* We only care about `structured_output`.
|
||||
*/
|
||||
const ClaudeOutputEnvelope = Schema.Struct({
|
||||
structured_output: Schema.Unknown,
|
||||
});
|
||||
|
||||
const makeClaudeTextGeneration = Effect.gen(function* () {
|
||||
const commandSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
||||
const serverSettingsService = yield* Effect.service(ServerSettingsService);
|
||||
|
||||
const readStreamAsString = <E>(
|
||||
operation: string,
|
||||
stream: Stream.Stream<Uint8Array, E>,
|
||||
): Effect.Effect<string, TextGenerationError> =>
|
||||
stream.pipe(
|
||||
Stream.decodeText(),
|
||||
Stream.runFold(
|
||||
() => "",
|
||||
(acc, chunk) => acc + chunk,
|
||||
),
|
||||
Effect.mapError((cause) =>
|
||||
normalizeCliError("claude", operation, cause, "Failed to collect process output"),
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Spawn the Claude CLI with structured JSON output and return the parsed,
|
||||
* schema-validated result.
|
||||
*/
|
||||
const runClaudeJson = Effect.fn("runClaudeJson")(function* <S extends Schema.Top>({
|
||||
operation,
|
||||
cwd,
|
||||
prompt,
|
||||
outputSchemaJson,
|
||||
modelSelection,
|
||||
}: {
|
||||
operation:
|
||||
| "generateCommitMessage"
|
||||
| "generatePrContent"
|
||||
| "generateBranchName"
|
||||
| "generateThreadTitle";
|
||||
cwd: string;
|
||||
prompt: string;
|
||||
outputSchemaJson: S;
|
||||
modelSelection: ClaudeModelSelection;
|
||||
}): Effect.fn.Return<S["Type"], TextGenerationError, S["DecodingServices"]> {
|
||||
const jsonSchemaStr = JSON.stringify(toJsonSchemaObject(outputSchemaJson));
|
||||
const normalizedOptions = normalizeClaudeModelOptionsWithCapabilities(
|
||||
getClaudeModelCapabilities(modelSelection.model),
|
||||
modelSelection.options,
|
||||
);
|
||||
const settings = {
|
||||
...(typeof normalizedOptions?.thinking === "boolean"
|
||||
? { alwaysThinkingEnabled: normalizedOptions.thinking }
|
||||
: {}),
|
||||
...(normalizedOptions?.fastMode ? { fastMode: true } : {}),
|
||||
};
|
||||
|
||||
const claudeSettings = yield* Effect.map(
|
||||
serverSettingsService.getSettings,
|
||||
(settings) => settings.providers.claudeAgent,
|
||||
).pipe(Effect.catch(() => Effect.undefined));
|
||||
|
||||
const runClaudeCommand = Effect.fn("runClaudeJson.runClaudeCommand")(function* () {
|
||||
const command = ChildProcess.make(
|
||||
claudeSettings?.binaryPath || "claude",
|
||||
[
|
||||
"-p",
|
||||
"--output-format",
|
||||
"json",
|
||||
"--json-schema",
|
||||
jsonSchemaStr,
|
||||
"--model",
|
||||
resolveApiModelId(modelSelection),
|
||||
...(normalizedOptions?.effort ? ["--effort", normalizedOptions.effort] : []),
|
||||
...(Object.keys(settings).length > 0 ? ["--settings", JSON.stringify(settings)] : []),
|
||||
"--dangerously-skip-permissions",
|
||||
],
|
||||
{
|
||||
cwd,
|
||||
shell: process.platform === "win32",
|
||||
stdin: {
|
||||
stream: Stream.encodeText(Stream.make(prompt)),
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
const child = yield* commandSpawner
|
||||
.spawn(command)
|
||||
.pipe(
|
||||
Effect.mapError((cause) =>
|
||||
normalizeCliError("claude", operation, cause, "Failed to spawn Claude CLI process"),
|
||||
),
|
||||
);
|
||||
|
||||
const [stdout, stderr, exitCode] = yield* Effect.all(
|
||||
[
|
||||
readStreamAsString(operation, child.stdout),
|
||||
readStreamAsString(operation, child.stderr),
|
||||
child.exitCode.pipe(
|
||||
Effect.mapError((cause) =>
|
||||
normalizeCliError("claude", operation, cause, "Failed to read Claude CLI exit code"),
|
||||
),
|
||||
),
|
||||
],
|
||||
{ concurrency: "unbounded" },
|
||||
);
|
||||
|
||||
if (exitCode !== 0) {
|
||||
const stderrDetail = stderr.trim();
|
||||
const stdoutDetail = stdout.trim();
|
||||
const detail = stderrDetail.length > 0 ? stderrDetail : stdoutDetail;
|
||||
return yield* new TextGenerationError({
|
||||
operation,
|
||||
detail:
|
||||
detail.length > 0
|
||||
? `Claude CLI command failed: ${detail}`
|
||||
: `Claude CLI command failed with code ${exitCode}.`,
|
||||
});
|
||||
}
|
||||
|
||||
return stdout;
|
||||
});
|
||||
|
||||
const rawStdout = yield* runClaudeCommand().pipe(
|
||||
Effect.scoped,
|
||||
Effect.timeoutOption(CLAUDE_TIMEOUT_MS),
|
||||
Effect.flatMap(
|
||||
Option.match({
|
||||
onNone: () =>
|
||||
Effect.fail(
|
||||
new TextGenerationError({ operation, detail: "Claude CLI request timed out." }),
|
||||
),
|
||||
onSome: (value) => Effect.succeed(value),
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
const envelope = yield* Schema.decodeEffect(Schema.fromJsonString(ClaudeOutputEnvelope))(
|
||||
rawStdout,
|
||||
).pipe(
|
||||
Effect.catchTag("SchemaError", (cause) =>
|
||||
Effect.fail(
|
||||
new TextGenerationError({
|
||||
operation,
|
||||
detail: "Claude CLI returned unexpected output format.",
|
||||
cause,
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return yield* Schema.decodeEffect(outputSchemaJson)(envelope.structured_output).pipe(
|
||||
Effect.catchTag("SchemaError", (cause) =>
|
||||
Effect.fail(
|
||||
new TextGenerationError({
|
||||
operation,
|
||||
detail: "Claude returned invalid structured output.",
|
||||
cause,
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// TextGenerationShape methods
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const generateCommitMessage: TextGenerationShape["generateCommitMessage"] = Effect.fn(
|
||||
"ClaudeTextGeneration.generateCommitMessage",
|
||||
)(function* (input) {
|
||||
const { prompt, outputSchema } = buildCommitMessagePrompt({
|
||||
branch: input.branch,
|
||||
stagedSummary: input.stagedSummary,
|
||||
stagedPatch: input.stagedPatch,
|
||||
includeBranch: input.includeBranch === true,
|
||||
});
|
||||
|
||||
if (input.modelSelection.provider !== "claudeAgent") {
|
||||
return yield* new TextGenerationError({
|
||||
operation: "generateCommitMessage",
|
||||
detail: "Invalid model selection.",
|
||||
});
|
||||
}
|
||||
|
||||
const generated = yield* runClaudeJson({
|
||||
operation: "generateCommitMessage",
|
||||
cwd: input.cwd,
|
||||
prompt,
|
||||
outputSchemaJson: outputSchema,
|
||||
modelSelection: input.modelSelection,
|
||||
});
|
||||
|
||||
return {
|
||||
subject: sanitizeCommitSubject(generated.subject),
|
||||
body: generated.body.trim(),
|
||||
...("branch" in generated && typeof generated.branch === "string"
|
||||
? { branch: sanitizeFeatureBranchName(generated.branch) }
|
||||
: {}),
|
||||
};
|
||||
});
|
||||
|
||||
const generatePrContent: TextGenerationShape["generatePrContent"] = Effect.fn(
|
||||
"ClaudeTextGeneration.generatePrContent",
|
||||
)(function* (input) {
|
||||
const { prompt, outputSchema } = buildPrContentPrompt({
|
||||
baseBranch: input.baseBranch,
|
||||
headBranch: input.headBranch,
|
||||
commitSummary: input.commitSummary,
|
||||
diffSummary: input.diffSummary,
|
||||
diffPatch: input.diffPatch,
|
||||
});
|
||||
|
||||
if (input.modelSelection.provider !== "claudeAgent") {
|
||||
return yield* new TextGenerationError({
|
||||
operation: "generatePrContent",
|
||||
detail: "Invalid model selection.",
|
||||
});
|
||||
}
|
||||
|
||||
const generated = yield* runClaudeJson({
|
||||
operation: "generatePrContent",
|
||||
cwd: input.cwd,
|
||||
prompt,
|
||||
outputSchemaJson: outputSchema,
|
||||
modelSelection: input.modelSelection,
|
||||
});
|
||||
|
||||
return {
|
||||
title: sanitizePrTitle(generated.title),
|
||||
body: generated.body.trim(),
|
||||
};
|
||||
});
|
||||
|
||||
const generateBranchName: TextGenerationShape["generateBranchName"] = Effect.fn(
|
||||
"ClaudeTextGeneration.generateBranchName",
|
||||
)(function* (input) {
|
||||
const { prompt, outputSchema } = buildBranchNamePrompt({
|
||||
message: input.message,
|
||||
attachments: input.attachments,
|
||||
});
|
||||
|
||||
if (input.modelSelection.provider !== "claudeAgent") {
|
||||
return yield* new TextGenerationError({
|
||||
operation: "generateBranchName",
|
||||
detail: "Invalid model selection.",
|
||||
});
|
||||
}
|
||||
|
||||
const generated = yield* runClaudeJson({
|
||||
operation: "generateBranchName",
|
||||
cwd: input.cwd,
|
||||
prompt,
|
||||
outputSchemaJson: outputSchema,
|
||||
modelSelection: input.modelSelection,
|
||||
});
|
||||
|
||||
return {
|
||||
branch: sanitizeBranchFragment(generated.branch),
|
||||
};
|
||||
});
|
||||
|
||||
const generateThreadTitle: TextGenerationShape["generateThreadTitle"] = Effect.fn(
|
||||
"ClaudeTextGeneration.generateThreadTitle",
|
||||
)(function* (input) {
|
||||
const { prompt, outputSchema } = buildThreadTitlePrompt({
|
||||
message: input.message,
|
||||
attachments: input.attachments,
|
||||
});
|
||||
|
||||
if (input.modelSelection.provider !== "claudeAgent") {
|
||||
return yield* new TextGenerationError({
|
||||
operation: "generateThreadTitle",
|
||||
detail: "Invalid model selection.",
|
||||
});
|
||||
}
|
||||
|
||||
const generated = yield* runClaudeJson({
|
||||
operation: "generateThreadTitle",
|
||||
cwd: input.cwd,
|
||||
prompt,
|
||||
outputSchemaJson: outputSchema,
|
||||
modelSelection: input.modelSelection,
|
||||
});
|
||||
|
||||
return {
|
||||
title: sanitizeThreadTitle(generated.title),
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
generateCommitMessage,
|
||||
generatePrContent,
|
||||
generateBranchName,
|
||||
generateThreadTitle,
|
||||
} satisfies TextGenerationShape;
|
||||
});
|
||||
|
||||
export const ClaudeTextGenerationLive = Layer.effect(TextGeneration, makeClaudeTextGeneration);
|
||||
Loaded 100 of 469 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user