Skip to content

Commit 791bd71

Browse files
committed
Merge remote-tracking branch 'github/main' into feat/schedule-task-mcp-target
# Conflicts: # apps/server/src/mcp/OrchestratorMcpService.ts # apps/server/src/provider/agentContextBudget.json # evals/mcp-tool-use/cases/orchestration.ndjson # packages/contracts/src/orchestratorMcp.ts
2 parents c334e78 + 268e581 commit 791bd71

709 files changed

Lines changed: 22322 additions & 27350 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.pnpmfile.cjs‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,6 @@
22
// Keep other platforms native; release scripts set their own architectures.
33
module.exports = {
44
hooks: {
5-
// `typescript` is @tsc-rs/typescript (the catalog entry). Its npm version (0.8.x) is outside
6-
// vite-plus-core's typescript peer range, so pnpm gave the vite-plus that @effect/vitest
7-
// imports apps/marketing's [email protected] instead, and tests loaded a second vitest.
8-
readPackage(pkg) {
9-
if (pkg.name === "@voidzero-dev/vite-plus-core" && pkg.peerDependencies?.typescript) {
10-
pkg.peerDependencies.typescript = "*";
11-
}
12-
return pkg;
13-
},
145
updateConfig(config) {
156
// oxlint-disable-next-line t3code/no-global-process-runtime -- pnpm loads this file before any Effect runtime exists.
167
if (process.platform !== "win32") return config;

‎.vscode/extensions.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"recommendations": ["oxc.oxc-vscode"]
2+
"recommendations": ["oxc.oxc-vscode", "TypeScriptTeam.native-preview"]
33
}

‎.vscode/settings.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"source.fixAll.oxc": "always"
66
},
77
"oxc.unusedDisableDirectives": "warn",
8-
"js/ts.tsdk.path": "node_modules/typescript/lib",
8+
"js/ts.experimental.useTsgo": true,
9+
"js/ts.tsdk.path": ".vscode/tsdk",
910
"typescript.preferences.autoImportFileExcludePatterns": [".repos/**"],
1011
"javascript.preferences.autoImportFileExcludePatterns": [".repos/**"],
1112
"files.watcherExclude": {

‎.vscode/tsdk/tsgo‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
# VS Code's TypeScript 7 extension starts `<tsdk>/tsgo --lsp --stdio`. Exec Effect's patched tsrs
3+
# directly: through the effect-tsgo Node launcher, the LSP's stdin read intermittently fails (EAGAIN).
4+
exec "$(cd "$(dirname "$0")/../.." && node -e '
5+
const { createRequire } = require("node:module");
6+
const fs = require("node:fs");
7+
const path = require("node:path");
8+
const platform = `@effect/tsgo-${process.platform}-${process.arch}/package.json`;
9+
const dir = path.join(path.dirname(createRequire(require.resolve("@effect/tsgo/package.json")).resolve(platform)), "artifacts/tsrs");
10+
process.stdout.write(path.join(dir, fs.readdirSync(dir).sort().at(-1), "tsrs"));
11+
')" "$@"

‎AGENTS.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ An empty database is a bad test. Seed your worktree's `.t3` with a copy of real
100100

101101
- Before you push, run `vp run check:changed`. It runs CI's fast checks for changed files: format, lint, knip, typecheck of affected packages and dependents, tests beside changes, and the cross-file checks those miss. CI still runs the full test suites.
102102
- While you iterate, run `vp test run <files>`. For big files, add `-t "<name>"`.
103-
- Use `vp run typecheck`, not `npx tsc`; it caches per package. Both run tsc-rs (`typescript` is the `@tsc-rs/typescript` drop-in).
103+
- Use `vp run typecheck`; it caches per package. Each package runs `effect-tsgo tsrs --noEmit`, the Rust TypeScript 7 checker with Effect's diagnostics built in. There is no `typescript` package to run.
104104
- Run `node -e` snippets from `apps/server` or the owning package. `effect` does not resolve from the repo root.
105105
- Test behavior that can break, such as orchestration and event-sourcing, provider protocol translation, auth and permission guards, persistence and migrations, external-format parsing, race fixes, and the logic a bug fix changed. Leave out tests for what types already guarantee, trivial logic, copy text, smoke runs, mock-call mirrors, callback wiring, and props rendered to static markup.
106106
- Extend before you add. When an existing test or table covers the behavior, add a row or an assertion there. Write a new `it` only when no case fits.

‎apps/desktop/src/app/DesktopApp.ts‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as Cause from "effect/Cause";
2+
import * as Config from "effect/Config";
23
import * as Duration from "effect/Duration";
34
import * as Effect from "effect/Effect";
45
import * as Option from "effect/Option";
@@ -42,6 +43,11 @@ const DEFAULT_DESKTOP_BACKEND_PORT = 3773;
4243
const MAX_TCP_PORT = 65_535;
4344
const DESKTOP_BACKEND_PORT_PROBE_HOSTS = ["127.0.0.1", "0.0.0.0", "::"] as const;
4445

46+
const LinuxDesktopSessionConfig = Config.all({
47+
current: Config.String("XDG_CURRENT_DESKTOP").pipe(Config.option),
48+
session: Config.String("XDG_SESSION_DESKTOP").pipe(Config.option),
49+
});
50+
4551
const makeDesktopRunId = SecureRandom.SecureRandom.pipe(
4652
Effect.flatMap((random) => random.uuidV4()),
4753
Effect.map((value) => value.replaceAll("-", "").slice(0, 12)),
@@ -307,12 +313,13 @@ const startup = Effect.gen(function* () {
307313
yield* desktopSettings.load;
308314

309315
if (linuxElectronOptions !== null) {
316+
const xdgDesktop = yield* LinuxDesktopSessionConfig;
310317
yield* logStartupInfo("linux password store configured", {
311318
passwordStore: hasCommandLinePasswordStore
312319
? "command-line"
313320
: (linuxElectronOptions.passwordStore ?? "electron-default"),
314-
xdgCurrentDesktop: process.env.XDG_CURRENT_DESKTOP ?? null,
315-
xdgSessionDesktop: process.env.XDG_SESSION_DESKTOP ?? null,
321+
xdgCurrentDesktop: Option.getOrNull(xdgDesktop.current),
322+
xdgSessionDesktop: Option.getOrNull(xdgDesktop.session),
316323
});
317324
}
318325

‎apps/desktop/src/app/DesktopCliCommand.test.ts‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as NodeServices from "@effect/platform-node/NodeServices";
2-
import { afterEach, beforeEach, expect, it } from "@effect/vitest";
2+
import { expect, it } from "@effect/vitest";
33
import * as HostProcess from "@t3tools/shared/HostProcess";
44
import * as Effect from "effect/Effect";
55
import * as FileSystem from "effect/FileSystem";
@@ -29,7 +29,13 @@ const environmentFor = (
2929
} as unknown as DesktopEnvironment.DesktopEnvironment["Service"]);
3030

3131
const commandIn = (
32-
input: { home: string; baseDir?: string; platform?: NodeJS.Platform; isPackaged?: boolean },
32+
input: {
33+
home: string;
34+
baseDir?: string;
35+
platform?: NodeJS.Platform;
36+
isPackaged?: boolean;
37+
env?: NodeJS.ProcessEnv;
38+
},
3339
spawner?: ChildProcessSpawner.ChildProcessSpawner["Service"],
3440
) =>
3541
Effect.gen(function* () {
@@ -42,6 +48,7 @@ const commandIn = (
4248
DesktopEnvironment.DesktopEnvironment,
4349
environmentFor(path, { ...input, baseDir }),
4450
),
51+
Effect.provideService(HostProcess.Environment, input.env ?? { PATH: "" }),
4552
);
4653
return yield* spawner
4754
? make.pipe(Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner))
@@ -84,14 +91,6 @@ const fakePowerShell = (initial: string) => {
8491
return { registry, spawner };
8592
};
8693

87-
const machinePath = process.env.PATH;
88-
beforeEach(() => {
89-
process.env.PATH = "";
90-
});
91-
afterEach(() => {
92-
process.env.PATH = machinePath;
93-
});
94-
9594
it.layer(NodeServices.layer)("DesktopCliCommand", (it) => {
9695
it.effect("links the launcher onto PATH and removes only that link", () =>
9796
Effect.gen(function* () {
@@ -124,7 +123,8 @@ it.layer(NodeServices.layer)("DesktopCliCommand", (it) => {
124123
const fs = yield* FileSystem.FileSystem;
125124
const path = yield* Path.Path;
126125
const home = yield* fs.makeTempDirectoryScoped();
127-
const command = yield* commandIn({ home });
126+
const env: NodeJS.ProcessEnv = { PATH: "" };
127+
const command = yield* commandIn({ home, env });
128128
const theirs = path.join(home, ".local", "bin", "t3");
129129
yield* fs.makeDirectory(path.dirname(theirs), { recursive: true });
130130
yield* fs.writeFileString(theirs, "npm's t3\n");
@@ -139,7 +139,7 @@ it.layer(NodeServices.layer)("DesktopCliCommand", (it) => {
139139

140140
const launcher = path.join(home, ".t3", "bin", "t3");
141141
yield* fs.writeFileString(launcher, "npm's t3\n");
142-
process.env.PATH = path.dirname(launcher);
142+
env.PATH = path.dirname(launcher);
143143
expect(yield* command.state).toMatchObject({ onPath: false, shadowedBy: launcher });
144144
expect((yield* Effect.flip(command.install)).message).toContain("Could not set up");
145145
yield* command.uninstall;
@@ -173,9 +173,9 @@ it.layer(NodeServices.layer)("DesktopCliCommand", (it) => {
173173
const shadow = path.join(home, "shadow");
174174
yield* fs.makeDirectory(shadow);
175175
yield* fs.writeFileString(path.join(shadow, "t3"), "#!/bin/sh\n", { mode: 0o755 });
176-
process.env.PATH = [shadow, path.join(home, ".local", "bin")].join(":");
176+
const env = { PATH: [shadow, path.join(home, ".local", "bin")].join(":") };
177177

178-
const command = yield* commandIn({ home });
178+
const command = yield* commandIn({ home, env });
179179
const theirs = path.join(shadow, "t3");
180180
expect((yield* command.state).shadowedBy).toBe(theirs);
181181
const error = yield* Effect.flip(command.install);
@@ -209,9 +209,9 @@ it.layer(NodeServices.layer)("DesktopCliCommand", (it) => {
209209
yield* fs.chmod(path.join(plain, "t3"), process.getuid?.() === 0 ? 0o600 : 0o601);
210210
yield* fs.makeDirectory(shadow);
211211
yield* fs.writeFileString(path.join(shadow, "t3"), "#!/bin/sh\n", { mode: 0o755 });
212-
process.env.PATH = [folder, plain, shadow, path.join(home, ".local", "bin")].join(":");
212+
const env = { PATH: [folder, plain, shadow, path.join(home, ".local", "bin")].join(":") };
213213

214-
const command = yield* commandIn({ home });
214+
const command = yield* commandIn({ home, env });
215215
expect((yield* command.state).shadowedBy).toBe(path.join(shadow, "t3"));
216216

217217
const error = yield* Effect.flip(command.install);
@@ -231,9 +231,9 @@ it.layer(NodeServices.layer)("DesktopCliCommand", (it) => {
231231
const path = yield* Path.Path;
232232
const home = yield* fs.makeTempDirectoryScoped();
233233
const launcher = path.join(home, ".t3", "bin", "t3");
234-
process.env.PATH = [path.dirname(launcher), path.join(home, ".local", "bin")].join(":");
234+
const env = { PATH: [path.dirname(launcher), path.join(home, ".local", "bin")].join(":") };
235235

236-
const command = yield* commandIn({ home });
236+
const command = yield* commandIn({ home, env });
237237
const installed = yield* command.install;
238238

239239
expect(yield* fs.exists(launcher)).toBe(true);

‎apps/desktop/src/app/DesktopCliCommand.ts‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import * as NodeFSP from "node:fs/promises";
33

44
import type { DesktopCliCommandState } from "@t3tools/contracts";
5+
import * as HostProcess from "@t3tools/shared/HostProcess";
56
import * as Context from "effect/Context";
67
import * as Effect from "effect/Effect";
78
import * as FileSystem from "effect/FileSystem";
@@ -61,11 +62,13 @@ export class DesktopCliCommand extends Context.Service<
6162
}
6263
>()("@t3tools/desktop/app/DesktopCliCommand") {}
6364

64-
/** @public */
6565
export const make = Effect.gen(function* () {
6666
const environment = yield* DesktopEnvironment.DesktopEnvironment;
6767
const fs = yield* FileSystem.FileSystem;
6868
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
69+
// Read the live env: shell discovery patches PATH after startup, and Windows variable
70+
// names are case-insensitive only on process.env, not on Config's copy of it.
71+
const env = yield* HostProcess.Environment;
6972
const path = environment.path;
7073
const windows = environment.platform === "win32";
7174
const launcher = DesktopCliShim.launcherPath(environment);
@@ -105,15 +108,15 @@ export const make = Effect.gen(function* () {
105108
Effect.orElseSucceed(() => false),
106109
);
107110

108-
const powershell = (env: Record<string, string>) =>
111+
const powershell = (overrides: Record<string, string>) =>
109112
Effect.scoped(
110113
Effect.gen(function* () {
111-
const root = process.env.SystemRoot ?? process.env.WINDIR;
114+
const root = env.SystemRoot ?? env.WINDIR;
112115
const handle = yield* spawner.spawn(
113116
ChildProcess.make(
114117
root ? `${root}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe` : "powershell.exe",
115118
["-NoLogo", "-NoProfile", "-NonInteractive", "-Command", WINDOWS_USER_PATH_SCRIPT],
116-
{ stdin: "ignore", stderr: "ignore", env, extendEnv: true },
119+
{ stdin: "ignore", stderr: "ignore", env: overrides, extendEnv: true },
117120
),
118121
);
119122
const [stdout, exitCode] = yield* Effect.all(
@@ -137,14 +140,17 @@ export const make = Effect.gen(function* () {
137140
const isExecutableFile = Effect.fn("DesktopCliCommand.isExecutableFile")(
138141
function* (target: string) {
139142
if ((yield* fs.stat(target)).type !== "File") return false;
140-
yield* Effect.tryPromise(() => NodeFSP.access(target, NodeFSP.constants.X_OK));
143+
yield* Effect.tryPromise({
144+
try: () => NodeFSP.access(target, NodeFSP.constants.X_OK),
145+
catch: () => fail(`${target} is not executable.`),
146+
});
141147
return true;
142148
},
143149
Effect.orElseSucceed(() => false),
144150
);
145151

146152
const firstOnPath = Effect.gen(function* () {
147-
for (const directory of pathEntries(process.env.PATH, ":")) {
153+
for (const directory of pathEntries(env.PATH, ":")) {
148154
const candidate = path.join(directory, "t3");
149155
if (yield* isExecutableFile(candidate)) return Option.some(candidate);
150156
}
@@ -239,7 +245,7 @@ export const make = Effect.gen(function* () {
239245
`Another t3 at ${shadowedBy.value} runs first in a new terminal. Remove it, or run the launcher directly at ${launcher}.`,
240246
);
241247
}
242-
const onPath = pathEntries(process.env.PATH, ":");
248+
const onPath = pathEntries(env.PATH, ":");
243249
const candidates = unixCandidates(environment.homeDirectory, environment.platform);
244250
for (const directory of [
245251
...candidates.filter((candidate) => onPath.includes(candidate)),

‎apps/desktop/src/app/DesktopConfig.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const trimNonEmptyOption = (value: string): Option.Option<string> => {
88
return trimmed.length > 0 ? Option.some(trimmed) : Option.none();
99
};
1010

11-
const trimmedString = (name: string) =>
11+
export const trimmedString = (name: string) =>
1212
Config.String(name).pipe(Config.option, Config.map(Option.flatMap(trimNonEmptyOption)));
1313

1414
const optionalBoolean = (name: string) =>

‎apps/desktop/src/app/DesktopManagedPolicy.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ export const layerTest = (policy?: ManagedPolicyDocument | ManagedPolicyFileErro
5656
DesktopManagedPolicy.of({
5757
read:
5858
policy === undefined
59-
? // @effect-diagnostics-next-line effectSucceedWithVoid:off - No policy is undefined, not void.
60-
Effect.succeed(undefined)
59+
? Effect.undefined
6160
: isManagedPolicyFileError(policy)
6261
? Effect.fail(policy)
6362
: Effect.succeed({ source: "/test/policy.json", document: policy }),

0 commit comments

Comments
 (0)