@linzumi/cli 0.0.20-beta → 0.0.23-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,80 +0,0 @@
1
- /*
2
- - Date: 2026-04-26
3
- Spec: plans/2026-04-26-local-codex-driver-worldclass-spec.md
4
- Relationship: Defines the pure local Codex app-server runtime option mapping
5
- for model, reasoning effort, fast tier, approval policy, and sandbox mode so
6
- session settings are testable outside the channel-session orchestrator.
7
- */
8
- import type { JsonObject } from "./protocol";
9
-
10
- export type CodexRuntimeOptions = {
11
- readonly cwd: string;
12
- readonly fast?: boolean | undefined;
13
- readonly channelSession: {
14
- readonly model?: string | undefined;
15
- readonly reasoningEffort?: string | undefined;
16
- readonly approvalPolicy?: string | undefined;
17
- readonly sandbox?: string | undefined;
18
- };
19
- };
20
-
21
- export function codexThreadRuntimeOverrides(
22
- options: CodexRuntimeOptions,
23
- ): JsonObject {
24
- const session = options.channelSession;
25
-
26
- return {
27
- ...(session.model === undefined ? {} : { model: session.model }),
28
- ...(session.reasoningEffort === undefined
29
- ? {}
30
- : { reasoningEffort: session.reasoningEffort }),
31
- ...(options.fast === true ? { serviceTier: "fast" } : {}),
32
- ...(session.approvalPolicy === undefined
33
- ? {}
34
- : { approvalPolicy: session.approvalPolicy }),
35
- ...(session.sandbox === undefined ? {} : { sandbox: session.sandbox }),
36
- };
37
- }
38
-
39
- export function codexTurnRuntimeOverrides(options: CodexRuntimeOptions): JsonObject {
40
- const session = options.channelSession;
41
-
42
- return {
43
- cwd: options.cwd,
44
- ...(session.model === undefined ? {} : { model: session.model }),
45
- ...(session.reasoningEffort === undefined
46
- ? {}
47
- : { effort: session.reasoningEffort }),
48
- ...(options.fast === true ? { serviceTier: "fast" } : {}),
49
- ...(session.approvalPolicy === undefined
50
- ? {}
51
- : { approvalPolicy: session.approvalPolicy }),
52
- ...(session.sandbox === undefined
53
- ? {}
54
- : { sandboxPolicy: codexSandboxPolicy(session.sandbox, options.cwd) }),
55
- };
56
- }
57
-
58
- function codexSandboxPolicy(sandbox: string, cwd: string): JsonObject {
59
- switch (sandbox) {
60
- case "danger-full-access":
61
- return { type: "dangerFullAccess" };
62
- case "read-only":
63
- return {
64
- type: "readOnly",
65
- access: { type: "fullAccess" },
66
- networkAccess: false,
67
- };
68
- case "workspace-write":
69
- return {
70
- type: "workspaceWrite",
71
- writableRoots: [cwd],
72
- readOnlyAccess: { type: "fullAccess" },
73
- networkAccess: false,
74
- excludeTmpdirEnvVar: false,
75
- excludeSlashTmp: false,
76
- };
77
- default:
78
- throw new Error(`unsupported Codex sandbox mode: ${sandbox}`);
79
- }
80
- }
@@ -1,198 +0,0 @@
1
- /*
2
- - Date: 2026-04-28
3
- Spec: plans/2026-04-28-npm-first-local-runner-onboarding.md
4
- Relationship: Probes local runner dependencies before first-run onboarding
5
- claims that Codex sessions and editor previews are ready from Kandan.
6
- */
7
- import { spawn } from "node:child_process";
8
- import {
9
- editorRuntimeStatusPayload,
10
- type EditorRuntimeStatus,
11
- } from "./localEditorRuntime";
12
- import { type JsonObject } from "./protocol";
13
-
14
- export type ToolDependencyStatus = {
15
- readonly command: string;
16
- readonly available: boolean;
17
- readonly version?: string | undefined;
18
- readonly reason?:
19
- | "not_configured"
20
- | "editor_runtime_unavailable"
21
- | "custom_runtime"
22
- | undefined;
23
- };
24
-
25
- export type RunnerDependencyStatus = {
26
- readonly bun: ToolDependencyStatus;
27
- readonly codex: ToolDependencyStatus;
28
- readonly codeServer: ToolDependencyStatus;
29
- readonly editorRuntime?: EditorRuntimeStatus | undefined;
30
- };
31
-
32
- export function probeTool(command: string, cwd: string): Promise<ToolDependencyStatus> {
33
- return new Promise((resolve) => {
34
- const child = spawn(command, ["--version"], {
35
- cwd,
36
- stdio: ["ignore", "pipe", "pipe"],
37
- });
38
-
39
- let stdout = "";
40
- let stderr = "";
41
- let resolved = false;
42
-
43
- const finish = (status: ToolDependencyStatus): void => {
44
- if (resolved) {
45
- return;
46
- }
47
-
48
- resolved = true;
49
- clearTimeout(timeout);
50
- resolve(status);
51
- };
52
-
53
- const timeout = setTimeout(() => {
54
- child.kill("SIGKILL");
55
- finish({ command, available: false });
56
- }, 1_000);
57
-
58
- child.stdout?.on("data", (chunk) => {
59
- stdout += chunk.toString();
60
- });
61
- child.stderr?.on("data", (chunk) => {
62
- stderr += chunk.toString();
63
- });
64
- child.on("error", () => {
65
- finish({ command, available: false });
66
- });
67
- child.on("exit", (code) => {
68
- if (code !== 0) {
69
- finish({ command, available: false });
70
- return;
71
- }
72
-
73
- const version = firstNonBlank(stdout, stderr);
74
-
75
- finish(
76
- version === undefined
77
- ? { command, available: true }
78
- : { command, available: true, version },
79
- );
80
- });
81
- });
82
- }
83
-
84
- export async function buildRunnerDependencyStatus(args: {
85
- readonly cwd: string;
86
- readonly codexBin: string;
87
- readonly codeServerBin?: string | undefined;
88
- readonly editorRuntime?: EditorRuntimeStatus | undefined;
89
- }): Promise<RunnerDependencyStatus> {
90
- const [bun, codex, codeServer] = await Promise.all([
91
- probeTool(process.execPath, args.cwd),
92
- probeTool(args.codexBin, args.cwd),
93
- codeServerDependencyStatus(args),
94
- ]);
95
-
96
- return {
97
- bun,
98
- codex,
99
- codeServer,
100
- editorRuntime: args.editorRuntime,
101
- };
102
- }
103
-
104
- function codeServerDependencyStatus(args: {
105
- readonly cwd: string;
106
- readonly codeServerBin?: string | undefined;
107
- readonly editorRuntime?: EditorRuntimeStatus | undefined;
108
- }): Promise<ToolDependencyStatus> {
109
- switch (args.editorRuntime?.status) {
110
- case "ready":
111
- return Promise.resolve({
112
- command: args.codeServerBin ?? args.editorRuntime.codeServerBin,
113
- available: true,
114
- version: args.editorRuntime.codeServerVersion,
115
- });
116
- case "unavailable":
117
- return Promise.resolve({
118
- command: args.codeServerBin ?? "code-server",
119
- available: false,
120
- reason: "editor_runtime_unavailable",
121
- });
122
- case "custom":
123
- case undefined:
124
- break;
125
- }
126
-
127
- return args.codeServerBin === undefined
128
- ? Promise.resolve({
129
- command: "code-server",
130
- available: false,
131
- reason: "not_configured" as const,
132
- })
133
- : probeTool(args.codeServerBin, args.cwd);
134
- }
135
-
136
- export function assertStartDependencies(status: RunnerDependencyStatus): void {
137
- if (!status.bun.available) {
138
- throw new Error("Bun is not available. Install Bun, then rerun linzumi start.");
139
- }
140
-
141
- if (!status.codex.available) {
142
- throw new Error(
143
- `Codex is not available at ${status.codex.command}. Install Codex or pass --codex-bin <path>.`,
144
- );
145
- }
146
-
147
- if (
148
- status.editorRuntime?.status === "unavailable" ||
149
- (status.codeServer?.available === false && status.codeServer.reason !== "not_configured")
150
- ) {
151
- throw new Error(
152
- "The Kandan editor runtime is not available. Reconnect when the runtime update finishes or pass --code-server-bin <path> for a custom development runtime.",
153
- );
154
- }
155
- }
156
-
157
- export function dependencyStatusPayload(status: RunnerDependencyStatus): JsonObject {
158
- const codeServer = status.codeServer ?? disabledCodeServerStatus();
159
-
160
- return {
161
- bun: toolPayload(status.bun),
162
- codex: toolPayload(status.codex),
163
- codeServer: toolPayload(codeServer),
164
- editorRuntime:
165
- status.editorRuntime === undefined
166
- ? null
167
- : editorRuntimeStatusPayload(status.editorRuntime),
168
- };
169
- }
170
-
171
- function disabledCodeServerStatus(): ToolDependencyStatus {
172
- return {
173
- command: "code-server",
174
- available: false,
175
- reason: "not_configured",
176
- };
177
- }
178
-
179
- function toolPayload(status: ToolDependencyStatus): JsonObject {
180
- return {
181
- command: status.command,
182
- available: status.available,
183
- version: status.version ?? null,
184
- reason: status.reason ?? null,
185
- };
186
- }
187
-
188
- function firstNonBlank(...values: readonly (string | undefined)[]): string | undefined {
189
- for (const value of values) {
190
- const trimmed = value?.trim();
191
-
192
- if (trimmed !== undefined && trimmed !== "") {
193
- return trimmed;
194
- }
195
- }
196
-
197
- return undefined;
198
- }