@machina.ai/cell-harness 0.1.5-alpha.1.c1

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DeepSeek
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,6 @@
1
+ # Bilingual-pair consistency record (docs/i18n/README.md): the git blob hash of each
2
+ # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
+ # after editing either side, bring the other along and re-record with:
4
+ # pnpm run verify-translation-pairing --write apps/cell-harness/README.md
5
+ README.md: f2f70eb90cfbec120b2822eac17ca344c476b332
6
+ README.zh.md: c75737db2178fe821c16977bed1fa4f77b2ce002
package/README.md ADDED
@@ -0,0 +1,20 @@
1
+ # @machina.ai/cell-harness
2
+
3
+ English | [中文](README.zh.md)
4
+
5
+ Cell Harness CLI executable by Nova Solutions.
6
+
7
+ ## Overview
8
+ Provides the `cell-harness` command-line binary and launcher for DeepSeek Harness runtime, pre-configured with Nova Solutions branding and profiles without altering the upstream `dsh` CLI.
9
+
10
+ ## Installing it from npm
11
+ `npm install -g @machina.ai/cell-harness` installs the `cell-harness` and `ch` executables, and `npx @machina.ai/cell-harness web` (or `--profile web`) runs the same binary without a global install. The ten `@machina.ai/ch-*` plugins the profiles mount are runtime dependencies, so the package manager installs them beside the application; a release publishes them before the application, because the application's published ranges name their versions.
12
+
13
+ Every `@deepseek-ai/*` dependency is pinned to the harness generation this repository builds and tests, so an installed application always runs the configuration the source launch runs. The install must keep optional dependencies: `npm install --omit=optional` breaks the headless profile, whose attachment plugin loads `sharp`.
14
+
15
+ ## Running it
16
+ From the repository root, `pnpm cell-harness <args...>` (or `pnpm ch <args...>`) runs the TypeScript entry through tsx and forwards every argument, exactly as `pnpm dsh` does for the upstream CLI. The published `bin` is `lib/bin.js`, which runs under plain Node; `pnpm run build` produces it, including `lib/profile-boot.js`, the bundled copy of the upstream CLI's profile boot that a built launcher imports instead of upstream TypeScript.
17
+
18
+ Both planes are covered by `apps/cell-harness/tests/launcher.spec.ts`, and a built binary that is missing `lib/profile-boot.js` fails with the rebuild command instead of importing TypeScript.
19
+
20
+ The `web` profile overwrites the built `@deepseek-ai/dsh-web-frontend` favicon, HTML title, and PWA manifest name at boot (`src/web-branding.ts`): the favicon becomes the Nova Solutions Systems mark, and both the tab title and the `manifest.webmanifest` `name`/`short_name` (the PWA window title `web-runtime`'s `openBrowser` uses for its `display: "fullscreen"` window) become "Cell". This patches the built `dist/favicon.svg`, `dist/index.html`, and `dist/manifest.webmanifest` artifacts only; the upstream package's source tree (`apps/web/public/favicon.svg`, `apps/web/public/manifest.webmanifest`, `apps/web/index.html`, `apps/web/vite.config.ts`) is never touched.
package/README.zh.md ADDED
@@ -0,0 +1,20 @@
1
+ # @machina.ai/cell-harness
2
+
3
+ [English](README.md) | 中文
4
+
5
+ Nova Solutions 出品的 Cell Harness CLI 可执行程序。
6
+
7
+ ## 概述
8
+ 提供 `cell-harness` 命令行二进制与 DeepSeek Harness 运行时的启动器,预置了 Nova Solutions 的品牌与 profile,且不改动上游的 `dsh` CLI。
9
+
10
+ ## 从 npm 安装
11
+ `npm install -g @machina.ai/cell-harness` 会安装 `cell-harness` 与 `ch` 两个可执行文件,`npx @machina.ai/cell-harness web`(或 `--profile web`)无需全局安装即可运行同一个二进制。profile 所挂载的十个 `@machina.ai/ch-*` 插件是运行时依赖,包管理器会把它们装在应用旁边;一次发布必须先发布插件、再发布应用,因为应用已发布的范围点名了它们的版本。
12
+
13
+ 所有 `@deepseek-ai/*` 依赖都固定在仓库构建并测试过的 harness 世代,因此安装后的应用始终运行源码启动所运行的那套组合。安装必须保留可选依赖:`npm install --omit=optional` 会破坏 headless profile,它的 attachment 插件要加载 `sharp`。
14
+
15
+ ## 运行方式
16
+ 在仓库根目录下,`pnpm cell-harness <args...>`(或 `pnpm ch <args...>`)通过 tsx 运行 TypeScript 入口并转发每一个参数,与 `pnpm dsh` 对上游 CLI 的行为完全一致。发布的 `bin` 是 `lib/bin.js`,在普通 Node 下运行;`pnpm run build` 负责产出它,其中还包括 `lib/profile-boot.js`,即上游 CLI profile boot 的打包副本,构建后的启动器导入它,而不是导入上游 TypeScript。
17
+
18
+ 源码平面与产物平面都由 `apps/cell-harness/tests/launcher.spec.ts` 覆盖;构建产物若缺少 `lib/profile-boot.js`,会直接失败并给出重新构建命令,而不是去导入 TypeScript。
19
+
20
+ `web` profile 会在启动时覆盖已构建的 `@deepseek-ai/dsh-web-frontend` favicon、HTML 标题与 PWA manifest 名称(`src/web-branding.ts`):favicon 变为 Nova Solutions Systems 标记,标签页标题与 `manifest.webmanifest` 的 `name`/`short_name`(即 `web-runtime` 的 `openBrowser` 为其 `display: "fullscreen"` 窗口所使用的 PWA 窗口标题)都变为 "Cell"。这只修补构建后的 `dist/favicon.svg`、`dist/index.html` 与 `dist/manifest.webmanifest` 产物;上游包的源码树(`apps/web/public/favicon.svg`、`apps/web/public/manifest.webmanifest`、`apps/web/index.html`、`apps/web/vite.config.ts`)绝不被触碰。
@@ -0,0 +1,73 @@
1
+ # Cell Harness (Nova Solutions Systems) runtime patch overlay
2
+ - insert:
3
+ - id: auth-reboot-sso
4
+ name: '@machina.ai/ch-auth-reboot-sso'
5
+
6
+ - id: llm-reboot
7
+ name: '@machina.ai/ch-llm-reboot'
8
+
9
+ - id: ch-image-gemini-reboot
10
+ name: '@machina.ai/ch-image-gemini-reboot'
11
+
12
+ - id: ch-tool-image
13
+ name: '@machina.ai/ch-tool-image'
14
+
15
+ - id: client-locale-es-mx
16
+ name: '@machina.ai/ch-client-locale-es-mx'
17
+
18
+ - id: client-ui-brand-nova
19
+ name: '@machina.ai/ch-client-ui-brand-nova'
20
+
21
+ - id: client-ui-settings-cell-models
22
+ name: '@machina.ai/ch-client-ui-settings-cell-models'
23
+
24
+ - id: web-search-gemini
25
+ name: '@machina.ai/ch-web-search-gemini'
26
+
27
+ - id: skill-conductor
28
+ name: '@machina.ai/ch-skill-conductor'
29
+
30
+ # Gemini Google Search grounding through the Reboot AI Gateway (Zero API
31
+ # Keys), replacing DeepSeek's API-key-based native search as the active
32
+ # ctx.web search provider for Cell Harness. The whole config is restated
33
+ # (a patch replaces it, not merges it), so fetchProvider is carried forward
34
+ # unchanged from the base entry.
35
+ - id: web
36
+ config:
37
+ searchProvider: gemini-grounding
38
+ fetchProvider: http
39
+
40
+ # Replaced by web-search-gemini for Cell Harness; the package itself, its
41
+ # tests, and its documentation are untouched, and base dsh profiles keep it
42
+ # as their default (mirrors the llm-deepseek: disabled: true rationale above).
43
+ - id: web-search-deepseek
44
+ disabled: true
45
+
46
+ # llm-reboot registers one route per provider family (reboot-gemini,
47
+ # reboot-anthropic, reboot-openai, reboot-xai) so the chat composer's model
48
+ # selector groups by family; the default model lives on the Gemini route.
49
+ - id: agent-default-model
50
+ config:
51
+ provider: reboot-gemini
52
+ model: auto-gemini-3.8
53
+
54
+ # Deployment identity: replaces the fixed "You are an AI agent powered by
55
+ # DeepSeek Harness." line with the Cell Harness / Nova Solutions Systems
56
+ # persona, so "who are you" answers name this deployment instead of upstream.
57
+ - id: system-prompt
58
+ config:
59
+ includeHarnessIdentity: false
60
+ personaPrefix: >-
61
+ You are Cell Harness, an advanced coding and automation agent developed by Nova Solutions Systems powered by {{model}}.
62
+ personaSuffix: Your working directory is {{cwd}}.
63
+
64
+ # Replaced by client-ui-settings-cell-models: the Cell Models settings screen
65
+ # shows Reboot Zero-API-Key models and the Local OpenAI-compatible provider
66
+ # instead of DeepSeek's official API-key onboarding.
67
+ - id: ui-settings-models
68
+ disabled: true
69
+
70
+ # Replaced by llm-reboot (Zero-API-Key multi-model routing); disabling removes
71
+ # the DeepSeek official-key welcome/onboarding modal from the Cell Harness UX.
72
+ - id: llm-deepseek
73
+ disabled: true
package/lib/bin.js ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ import { p as runCellHarnessCli } from "./launcher-BIcBXlwF.js";
3
+ //#region lib/types/bin.js
4
+ /**
5
+ * Command-line entry for cell-harness executable.
6
+ * @module @machina.ai/cell-harness/bin
7
+ */
8
+ /* v8 ignore file -- built-bin acceptance exercises this self-executing dispatch. */
9
+ if (import.meta.main) await runCellHarnessCli();
10
+ //#endregion
11
+ export {};
package/lib/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import { a as ensureCellHarnessDshHome, c as installConsoleRebrand, d as resolveCellHarnessSessionPath, f as resolveProfileBootUrl, i as ensureAuthenticatedSession, l as parseCellHarnessArgs, n as PROFILE_BOOT_ARTIFACT_URL, o as findEAddrInUseError, p as runCellHarnessCli, r as PROFILE_BOOT_SOURCE_URL, s as getBrandBanner, t as CELL_HARNESS_PATCH, u as resolveCellHarnessDshHome } from "./launcher-BIcBXlwF.js";
2
+ export { CELL_HARNESS_PATCH, PROFILE_BOOT_ARTIFACT_URL, PROFILE_BOOT_SOURCE_URL, ensureAuthenticatedSession, ensureCellHarnessDshHome, findEAddrInUseError, getBrandBanner, installConsoleRebrand, parseCellHarnessArgs, resolveCellHarnessDshHome, resolveCellHarnessSessionPath, resolveProfileBootUrl, runCellHarnessCli };
@@ -0,0 +1,463 @@
1
+ import { existsSync, readFileSync, writeFileSync } from "node:fs";
2
+ import { homedir } from "node:os";
3
+ import { dirname, join, resolve } from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ import { Context } from "@deepseek-ai/cordis";
6
+ import { loadLayeredEnv } from "@deepseek-ai/dsh-app-boot";
7
+ import { DSH_HOME_ENV } from "@deepseek-ai/dsh-home-paths";
8
+ import { RebootAuthService, RebootSessionStore, decodeJwtPayload, ensureCellHarnessConfigFile, loadCellHarnessConfig, loadCellHarnessConfigSync } from "@machina.ai/ch-auth-reboot-sso";
9
+ //#region lib/types/web-branding.js
10
+ /**
11
+ * Best-effort browser-tab / PWA-window branding overlay for Cell Harness's own
12
+ * `web` profile. Overwrites the built, shared `dsh-web-frontend` dist artifacts
13
+ * (favicon, HTML title, PWA manifest name) that both `dsh` and `cell-harness`
14
+ * boot from, so Cell Harness never shows the upstream DeepSeek favicon or
15
+ * "DeepSeek Harness" name. Applies to the built dist artifacts only — the
16
+ * upstream package's source tree (`apps/web/public/favicon.svg`,
17
+ * `apps/web/public/manifest.webmanifest`, `apps/web/index.html`,
18
+ * `apps/web/vite.config.ts`) is never touched, so it stays mergeable with
19
+ * upstream.
20
+ * @module @machina.ai/cell-harness/web-branding
21
+ */
22
+ /**
23
+ * Nova Solutions Systems isotype, the same path geometry as
24
+ * packages/client/ui-brand-nova/src/client/Brand.tsx's `NovaBrandMark` and
25
+ * apps/cell-harness-desktop/build/icon-source.svg, sized for a browser tab.
26
+ */
27
+ const NOVA_FAVICON_SVG = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 277.11 320" role="img" aria-label="Nova Solutions Systems">
28
+ <path fill="#47bfe0" d="m129.91 115.03 8.66 5V0L34.62 60.02l8.66 5L129.91 15v100.03zm-77.96 84.98v10.01l52-30.04-8.66-5-43.34 25.03zM259.81 70.03 155.86 10v10l95.29 55.03 8.66-5zm-34.65 39.95-52 30.04 8.67 5 43.33-25.03v-10.01zM147.2 305V204.97l-8.66-5V320l103.95-60.02-8.66-5L147.2 305zM25.96 244.97l-8.66 5L121.25 310v-10l-95.29-55.03z"/>
29
+ <path fill="#0070bf" d="m0 240.01 34.67-20V119.99L0 99.98v140.03Z"/>
30
+ <path fill="#30a0d0" d="m277.11 79.99-34.67 20V200l34.67 20V79.98Z"/>
31
+ <path fill="#2090d0" d="M0 59.99v40.03l34.67 20.01V80L0 59.99z"/>
32
+ <path fill="#2090d0" d="M34.63 79.99v40l207.85 120.02v-40L34.63 79.99z"/>
33
+ <path fill="#30a0d0" d="m277.11 219.98-34.66-20.01V240l34.66 20.01v-40.03z"/>
34
+ </svg>
35
+ `;
36
+ /** Browser tab / PWA window title for every Cell Harness `web` profile session. */
37
+ const CELL_HARNESS_WEB_TITLE = "Cell";
38
+ /** Matches the built index.html's single `<title>` element, whatever text it currently carries. */
39
+ const TITLE_TAG_PATTERN = /<title>[^<]*<\/title>/;
40
+ /**
41
+ * Matches `manifest.webmanifest`'s `"name"`/`"short_name"` string values, whatever text they
42
+ * currently carry. `web-runtime`'s `openBrowser` opens the `web` profile in a `display:
43
+ * "fullscreen"` PWA window, whose OS-level window/dock title comes from these manifest fields —
44
+ * not `document.title` — so they need the same overlay as the favicon and the HTML title.
45
+ */
46
+ const MANIFEST_NAME_PATTERN = /"(name|short_name)": "[^"]*"/g;
47
+ /**
48
+ * Resolve the installed `dsh-web-frontend` dist directory, without importing
49
+ * any of its runtime code.
50
+ * @param resolve - specifier resolver; defaults to `import.meta.resolve`, overridden in tests.
51
+ * @returns absolute path to the built dist directory, or undefined when the package cannot be
52
+ * resolved (every non-`web` profile never loads it).
53
+ */
54
+ function resolveDshWebFrontendDistDir(resolve = (specifier) => import.meta.resolve(specifier)) {
55
+ let packageJsonUrl;
56
+ try {
57
+ packageJsonUrl = resolve("@deepseek-ai/dsh-web-frontend/package.json");
58
+ } catch {
59
+ return;
60
+ }
61
+ return join(dirname(fileURLToPath(packageJsonUrl)), "dist");
62
+ }
63
+ /**
64
+ * Resolve the built favicon path inside the installed `dsh-web-frontend` dist.
65
+ * @param resolve - specifier resolver override, used by tests.
66
+ * @returns absolute path to the built favicon, or undefined when unresolvable.
67
+ */
68
+ function resolveDshWebFrontendFaviconPath(resolve) {
69
+ const distDir = resolveDshWebFrontendDistDir(resolve);
70
+ return distDir === void 0 ? void 0 : join(distDir, "favicon.svg");
71
+ }
72
+ /**
73
+ * Resolve the built index.html path inside the installed `dsh-web-frontend` dist.
74
+ * @param resolve - specifier resolver override, used by tests.
75
+ * @returns absolute path to the built index.html, or undefined when unresolvable.
76
+ */
77
+ function resolveDshWebFrontendIndexHtmlPath(resolve) {
78
+ const distDir = resolveDshWebFrontendDistDir(resolve);
79
+ return distDir === void 0 ? void 0 : join(distDir, "index.html");
80
+ }
81
+ /**
82
+ * Resolve the built manifest.webmanifest path inside the installed `dsh-web-frontend` dist.
83
+ * @param resolve - specifier resolver override, used by tests.
84
+ * @returns absolute path to the built manifest, or undefined when unresolvable.
85
+ */
86
+ function resolveDshWebFrontendManifestPath(resolve) {
87
+ const distDir = resolveDshWebFrontendDistDir(resolve);
88
+ return distDir === void 0 ? void 0 : join(distDir, "manifest.webmanifest");
89
+ }
90
+ /**
91
+ * Overwrite the built `dsh-web-frontend` favicon with the Nova Solutions
92
+ * Systems mark, so the Cell Harness `web` profile never serves the upstream
93
+ * DeepSeek favicon.
94
+ * @param resolve - specifier resolver override, used by tests.
95
+ */
96
+ function ensureCellHarnessWebFavicon(resolve) {
97
+ const faviconPath = resolveDshWebFrontendFaviconPath(resolve);
98
+ if (faviconPath === void 0 || !existsSync(faviconPath)) return;
99
+ try {
100
+ if (readFileSync(faviconPath, "utf8") === NOVA_FAVICON_SVG) return;
101
+ writeFileSync(faviconPath, NOVA_FAVICON_SVG);
102
+ } catch {}
103
+ }
104
+ /**
105
+ * Overwrite the built `dsh-web-frontend` index.html's `<title>` with "Cell",
106
+ * regardless of what build profile (official "DeepSeek Harness", source-launch
107
+ * "Cell Local Build", …) baked the current text in.
108
+ * @param resolve - specifier resolver override, used by tests.
109
+ */
110
+ function ensureCellHarnessWebTitle(resolve) {
111
+ const indexHtmlPath = resolveDshWebFrontendIndexHtmlPath(resolve);
112
+ if (indexHtmlPath === void 0 || !existsSync(indexHtmlPath)) return;
113
+ try {
114
+ const html = readFileSync(indexHtmlPath, "utf8");
115
+ const branded = html.replace(TITLE_TAG_PATTERN, `<title>${CELL_HARNESS_WEB_TITLE}</title>`);
116
+ if (branded === html) return;
117
+ writeFileSync(indexHtmlPath, branded);
118
+ } catch {}
119
+ }
120
+ /**
121
+ * Overwrite the built `dsh-web-frontend` manifest.webmanifest's `name`/`short_name` with "Cell",
122
+ * so the PWA window Cell Harness's `web` profile opens never carries the upstream "DeepSeek
123
+ * Harness" / "DSH" name.
124
+ * @param resolve - specifier resolver override, used by tests.
125
+ */
126
+ function ensureCellHarnessWebManifestName(resolve) {
127
+ const manifestPath = resolveDshWebFrontendManifestPath(resolve);
128
+ if (manifestPath === void 0 || !existsSync(manifestPath)) return;
129
+ try {
130
+ const manifest = readFileSync(manifestPath, "utf8");
131
+ const branded = manifest.replace(MANIFEST_NAME_PATTERN, `"$1": "${CELL_HARNESS_WEB_TITLE}"`);
132
+ if (branded === manifest) return;
133
+ writeFileSync(manifestPath, branded);
134
+ } catch {}
135
+ }
136
+ /**
137
+ * Apply every Cell Harness `web` profile branding overlay (favicon, HTML title, PWA manifest name).
138
+ * @param resolve - specifier resolver override, used by tests.
139
+ */
140
+ function ensureCellHarnessWebBranding(resolve) {
141
+ ensureCellHarnessWebFavicon(resolve);
142
+ ensureCellHarnessWebTitle(resolve);
143
+ ensureCellHarnessWebManifestName(resolve);
144
+ }
145
+ //#endregion
146
+ //#region lib/types/launcher.js
147
+ /**
148
+ * Launcher and branding logic for Cell Harness (Nova Solutions Systems).
149
+ * @module @machina.ai/cell-harness/launcher
150
+ */
151
+ var __rewriteRelativeImportExtension = function(path, preserveJsx) {
152
+ if (typeof path === "string" && /^\.\.?\//.test(path)) return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function(m, tsx, d, ext, cm) {
153
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : d + ext + "." + cm.toLowerCase() + "js";
154
+ });
155
+ return path;
156
+ };
157
+ /** Path to the canonical Cell Harness Cordis patch overlay */
158
+ const CELL_HARNESS_PATCH = fileURLToPath(new URL("../config/cell-harness.cordis.patch.yml", import.meta.url));
159
+ /** Bundled upstream profile boot emitted beside the built launcher chunk in this app's `lib`. */
160
+ const PROFILE_BOOT_ARTIFACT_URL = new URL("./profile-boot.js", import.meta.url);
161
+ /** Upstream CLI profile boot that the tsx source launch reads directly. */
162
+ const PROFILE_BOOT_SOURCE_URL = new URL("../../cli/src/profile-boot.ts", import.meta.url);
163
+ /** Whether this launcher module itself runs from TypeScript source under tsx. */
164
+ const IS_SOURCE_LAUNCH = import.meta.url.endsWith(".ts");
165
+ /**
166
+ * Resolves the upstream profile boot for the plane this launcher runs in: the tsx
167
+ * source launch reads the CLI's TypeScript, a built launcher reads its own bundled
168
+ * chunk because plain Node cannot import the `.ts` source.
169
+ * @param sourceLaunch - whether this launcher runs from source; defaults to the running module.
170
+ * @param exists - artifact probe; defaults to the filesystem.
171
+ * @returns URL of the profile boot module to import.
172
+ * @throws Error when a built launcher has no bundled profile boot beside it.
173
+ */
174
+ function resolveProfileBootUrl(sourceLaunch = IS_SOURCE_LAUNCH, exists = existsSync) {
175
+ if (sourceLaunch) return PROFILE_BOOT_SOURCE_URL;
176
+ if (exists(PROFILE_BOOT_ARTIFACT_URL)) return PROFILE_BOOT_ARTIFACT_URL;
177
+ throw new Error(`Cell Harness profile boot artifact is missing: ${fileURLToPath(PROFILE_BOOT_ARTIFACT_URL)}. Rebuild it with \`pnpm --filter @machina.ai/cell-harness run bundle\`.`);
178
+ }
179
+ /**
180
+ * Resolves Cell Harness's own DeepSeek Harness home (`~/.cell-harness`),
181
+ * distinct from the upstream default (`~/.dsh`). `homedir()` already resolves
182
+ * the correct per-OS user home (including Windows), so no separate Windows
183
+ * branch is needed.
184
+ * @returns absolute default path for Cell Harness's `$DSH_HOME`.
185
+ */
186
+ function resolveCellHarnessDshHome() {
187
+ return join(homedir(), ".cell-harness");
188
+ }
189
+ /**
190
+ * Points `$DSH_HOME` at Cell Harness's own home directory before anything
191
+ * resolves it — the user-global `AGENTS.md` (`$DSH_HOME/AGENTS.md`),
192
+ * `.credentials.yaml`, `settings.yaml`, and layered `.env` files all live
193
+ * there instead of the generic `~/.dsh`, so Cell Harness never mixes user
194
+ * data with an unrelated `dsh`-based install on the same machine. An
195
+ * operator who has explicitly set `DSH_HOME` keeps their own value.
196
+ */
197
+ function ensureCellHarnessDshHome() {
198
+ const current = process.env[DSH_HOME_ENV];
199
+ if (current === void 0 || current.trim().length === 0) process.env[DSH_HOME_ENV] = resolveCellHarnessDshHome();
200
+ }
201
+ /**
202
+ * Resolves the canonical path to the Cell Harness session file (~/.cell-harness/session.json).
203
+ * @returns absolute path to session.json.
204
+ */
205
+ function resolveCellHarnessSessionPath() {
206
+ const envPath = process.env.CELL_HARNESS_SESSION_PATH;
207
+ if (envPath) return resolve(envPath.replace(/^~(?=$|\/|\\)/u, homedir()));
208
+ return join(homedir(), ".cell-harness", "session.json");
209
+ }
210
+ /**
211
+ * Ensures an active, unexpired session exists before loading the UI.
212
+ * If missing or expired:
213
+ * - purges expired session file
214
+ * - executes RFC 8628 Keycloak Device Flow via RebootAuthService
215
+ * - displays prompt/QR in terminal and opens browser to verify
216
+ * - saves new session into ~/.cell-harness/session.json
217
+ * If valid and not expired:
218
+ * - continues transparently.
219
+ *
220
+ * @param options - optional configuration overrides.
221
+ */
222
+ async function ensureAuthenticatedSession(options) {
223
+ if (process.env.DSH_CELL_HARNESS_SKIP_PREAUTH === "true") return;
224
+ const cellConfig = await loadCellHarnessConfig(await ensureCellHarnessConfigFile(options?.configPath));
225
+ const sessionPath = options?.sessionPath ?? (cellConfig.auth.session_path ? resolve(cellConfig.auth.session_path.replace(/^~(?=$|\/|\\)/u, homedir())) : resolveCellHarnessSessionPath());
226
+ const isSpanish = (options?.locale || cellConfig.locale.default || process.env.LANG || "").toLowerCase().startsWith("es");
227
+ const store = new RebootSessionStore({ sessionPath });
228
+ const currentSession = await store.load();
229
+ const now = Date.now();
230
+ let isExpired = false;
231
+ if (currentSession) {
232
+ if (currentSession.expires_at !== void 0) isExpired = currentSession.expires_at <= now;
233
+ else if (currentSession.access_token) {
234
+ const payload = decodeJwtPayload(currentSession.access_token);
235
+ if (typeof payload?.exp === "number") isExpired = payload.exp * 1e3 <= now;
236
+ }
237
+ }
238
+ if (currentSession && !isExpired) return;
239
+ if (currentSession && isExpired) {
240
+ if (isSpanish) process.stdout.write(`\n[Cell Harness] La sesión previa en ${sessionPath} ha expirado. Purgando credenciales obsoletas...\n`);
241
+ else process.stdout.write(`\n[Cell Harness] Previous session at ${sessionPath} has expired. Clearing obsolete credentials...\n`);
242
+ await store.clear();
243
+ }
244
+ if (isSpanish) {
245
+ process.stdout.write("\n[Cell Harness] Se requiere autenticación corporativa SSO de Nova Solutions Systems.\n");
246
+ process.stdout.write("[Cell Harness] Iniciando flujo de autorización de dispositivo...\n\n");
247
+ } else {
248
+ process.stdout.write("\n[Cell Harness] Nova Solutions Systems corporate SSO authentication is required.\n");
249
+ process.stdout.write("[Cell Harness] Starting device authorization flow...\n\n");
250
+ }
251
+ const cordisCtx = new Context();
252
+ await (options?.authServiceFactory ? await options.authServiceFactory() : new RebootAuthService(cordisCtx, {
253
+ auth: {
254
+ keycloak_url: cellConfig.auth.keycloak_url,
255
+ keycloak_client_id: cellConfig.auth.keycloak_client_id,
256
+ keycloak_client_secret: cellConfig.auth.keycloak_client_secret,
257
+ oidc_scope: cellConfig.auth.oidc_scope,
258
+ session_path: sessionPath
259
+ },
260
+ agent: {
261
+ agent_api_url: cellConfig.agent.agent_api_url,
262
+ timeout_seconds: cellConfig.agent.timeout_seconds
263
+ },
264
+ velocity_client_id: cellConfig.agent.velocity_client_id
265
+ }, { sessionStoreOptions: { sessionPath } })).deviceFlow({}, (banner) => {
266
+ process.stdout.write(banner + "\n");
267
+ });
268
+ if (isSpanish) process.stdout.write("\n✔ Autenticación exitosa. Continuando con la carga de Cell Harness...\n\n");
269
+ else process.stdout.write("\n✔ Authentication successful. Continuing to load Cell Harness...\n\n");
270
+ }
271
+ /**
272
+ * Returns the formatted Nova Solutions Systems / Cell Harness ASCII branding banner.
273
+ * @param locale - Optional locale identifier (defaults to process.env.LANG or 'en').
274
+ * @returns ASCII art banner string.
275
+ */
276
+ function getBrandBanner(locale = process.env.LANG || "en") {
277
+ if (locale.toLowerCase().startsWith("es")) return [
278
+ "======================================================",
279
+ " Cell Harness — Nova Solutions Systems",
280
+ " Impulsado por Microkernel Cordis & Zero-Touch Core",
281
+ "======================================================"
282
+ ].join("\n");
283
+ return [
284
+ "======================================================",
285
+ " Cell Harness — Nova Solutions Systems",
286
+ " Powered by Cordis Microkernel & Zero-Touch Core",
287
+ "======================================================"
288
+ ].join("\n");
289
+ }
290
+ /**
291
+ * Inspects an error or rejection to determine if it was caused by an EADDRINUSE condition.
292
+ * Traverses nested error cause chains and string messages when wrapped by Cordis/Loader.
293
+ * @param error - The error or exception to inspect.
294
+ * @returns Details containing port and address if EADDRINUSE is found, or null otherwise.
295
+ */
296
+ function findEAddrInUseError(error) {
297
+ let current = error;
298
+ while (current && typeof current === "object") {
299
+ const errObj = current;
300
+ if (errObj.code === "EADDRINUSE") return {
301
+ port: typeof errObj.port === "number" ? errObj.port : typeof errObj.port === "string" && /^\d+$/.test(errObj.port) ? Number(errObj.port) : void 0,
302
+ address: typeof errObj.address === "string" ? errObj.address : void 0
303
+ };
304
+ if (typeof errObj.message === "string" && (errObj.message.includes("EADDRINUSE") || errObj.message.includes("address already in use"))) {
305
+ const match = errObj.message.match(/address already in use\s+([^:\s]+)?:?(\d+)/i) || errObj.message.match(/EADDRINUSE.*?(\d{1,3}(?:\.\d{1,3}){3}|localhost|\[::1\])?:?(\d+)/i) || errObj.message.match(/:(\d{2,5})\b/);
306
+ return {
307
+ port: match ? Number(match[2] ?? match[1]) : typeof errObj.port === "number" ? errObj.port : void 0,
308
+ address: match && match[2] && match[1] ? match[1] : typeof errObj.address === "string" ? errObj.address : void 0
309
+ };
310
+ }
311
+ current = errObj.cause;
312
+ }
313
+ return null;
314
+ }
315
+ /**
316
+ * Parses raw CLI arguments for cell-harness.
317
+ * @param argv - Argument array (without node and script path).
318
+ * @returns Parsed invocation details.
319
+ */
320
+ function parseCellHarnessArgs(argv) {
321
+ let locale;
322
+ if (argv.includes("--version") || argv.includes("-v")) return {
323
+ mode: "version",
324
+ profile: "web",
325
+ patches: [],
326
+ args: []
327
+ };
328
+ let mode = "profile";
329
+ if (argv.includes("--help") || argv.includes("-h")) mode = "help";
330
+ let explicitProfile;
331
+ let fromDefaultProfile;
332
+ const patches = [];
333
+ const args = [];
334
+ for (let i = 0; i < argv.length; i++) {
335
+ const current = argv[i];
336
+ if (current === void 0) continue;
337
+ const next = argv[i + 1];
338
+ if (current === "--profile" && next !== void 0) {
339
+ explicitProfile = next;
340
+ i++;
341
+ } else if (current === "web" && args.length === 0 && explicitProfile === void 0) explicitProfile = "web";
342
+ else if (current === "--from-default-profile" && next !== void 0) {
343
+ fromDefaultProfile = next;
344
+ i++;
345
+ } else if (current === "--patch" && next !== void 0) {
346
+ patches.push(next);
347
+ i++;
348
+ } else if (current === "--locale" && next !== void 0) {
349
+ locale = next;
350
+ i++;
351
+ } else if (current !== "--help" && current !== "-h") args.push(current);
352
+ }
353
+ const hasPositionalTask = args.some((arg, idx) => {
354
+ if (arg.startsWith("-")) return false;
355
+ const prev = args[idx - 1];
356
+ if (prev === "--port" || prev === "--host" || prev === "--trusted-host") return false;
357
+ return true;
358
+ });
359
+ return {
360
+ mode,
361
+ profile: explicitProfile ?? (hasPositionalTask ? "headless" : "web"),
362
+ locale,
363
+ patches,
364
+ fromDefaultProfile,
365
+ args
366
+ };
367
+ }
368
+ /**
369
+ * Intercepts console logging to replace upstream `dsh web:` console output
370
+ * with `cell-harness web:`, preserving Zero-Touch Core principles.
371
+ */
372
+ function installConsoleRebrand() {
373
+ const originalLog = console.log;
374
+ const originalError = console.error;
375
+ console.log = (...args) => {
376
+ if (typeof args[0] === "string" && args[0].startsWith("dsh web:")) {
377
+ const rest = args.slice(1);
378
+ originalLog.call(console, args[0].replace(/^dsh web:/, "cell-harness web:"), ...rest);
379
+ return;
380
+ }
381
+ originalLog.apply(console, args);
382
+ };
383
+ console.error = (...args) => {
384
+ if (typeof args[0] === "string" && args[0].includes("dsh web")) {
385
+ const rest = args.slice(1);
386
+ originalError.call(console, args[0].replace(/\bdsh web\b/g, "cell-harness web"), ...rest);
387
+ return;
388
+ }
389
+ originalError.apply(console, args);
390
+ };
391
+ return () => {
392
+ console.log = originalLog;
393
+ console.error = originalError;
394
+ };
395
+ }
396
+ /**
397
+ * Executes the Cell Harness CLI interface.
398
+ * @param argv - Arguments to execute.
399
+ */
400
+ async function runCellHarnessCli(argv = process.argv.slice(2)) {
401
+ ensureCellHarnessDshHome();
402
+ const invocation = parseCellHarnessArgs(argv);
403
+ if (process.env.DSH_CELL_HARNESS_SKIP_PREAUTH !== "true") await ensureCellHarnessConfigFile();
404
+ const cellConfig = loadCellHarnessConfigSync();
405
+ const envLang = process.env.LANG && process.env.LANG !== "C" && process.env.LANG !== "POSIX" && process.env.LANG !== "C.UTF-8" ? process.env.LANG : void 0;
406
+ const resolvedLocale = invocation.locale || cellConfig.locale.default || envLang || "es-MX";
407
+ const isSpanish = resolvedLocale.toLowerCase().startsWith("es");
408
+ if (invocation.mode === "version") {
409
+ process.stdout.write("Cell Harness (Nova Solutions Systems) v0.1.5-alpha.1.c1\n");
410
+ return;
411
+ }
412
+ if (invocation.mode === "help") {
413
+ process.stdout.write(getBrandBanner(resolvedLocale) + "\n\n");
414
+ if (isSpanish) {
415
+ process.stdout.write("Uso: cell-harness [web] [--profile <perfil>] [--locale <idioma>] [--port <puerto>] [opciones] [tarea]\n");
416
+ process.stdout.write("Perfiles: web, headless, acp, sdk\n");
417
+ } else {
418
+ process.stdout.write("Usage: cell-harness [web] [--profile <profile>] [--locale <locale>] [--port <port>] [options] [task]\n");
419
+ process.stdout.write("Profiles: web, headless, acp, sdk\n");
420
+ }
421
+ return;
422
+ }
423
+ process.stdout.write(getBrandBanner(resolvedLocale) + "\n");
424
+ installConsoleRebrand();
425
+ if (invocation.profile === "web") ensureCellHarnessWebBranding();
426
+ await ensureAuthenticatedSession({ locale: resolvedLocale });
427
+ if (process.env.DSH_CELL_HARNESS_NO_BOOT !== "true") {
428
+ const profileBootUrl = resolveProfileBootUrl().href;
429
+ const profileModule = await import(__rewriteRelativeImportExtension(
430
+ /* @vite-ignore */
431
+ profileBootUrl
432
+ ));
433
+ const effectiveArgs = [...invocation.args];
434
+ if (invocation.profile === "web") {
435
+ if (!effectiveArgs.some((arg) => arg === "--port" || arg.startsWith("--port=")) && cellConfig.web.port) effectiveArgs.push("--port", String(cellConfig.web.port));
436
+ }
437
+ try {
438
+ await profileModule.runProfile({
439
+ environment: loadLayeredEnv("cell-harness"),
440
+ profile: invocation.profile,
441
+ fromDefaultProfile: invocation.fromDefaultProfile,
442
+ patchFiles: [CELL_HARNESS_PATCH, ...invocation.patches],
443
+ args: effectiveArgs
444
+ });
445
+ } catch (error) {
446
+ const inUse = findEAddrInUseError(error);
447
+ if (inUse !== null) {
448
+ const port = inUse.port ?? cellConfig.web.port;
449
+ if (isSpanish) process.stderr.write(`\n[Cell Harness] Error: El puerto ${port} ya está en uso por otro proceso.\nPuede configurar un puerto diferente en ~/.cell-harness/config.yaml (sección web.port) o mediante el parámetro --port <puerto>.
450
+
451
+ `);
452
+ else process.stderr.write(`\n[Cell Harness] Error: Port ${port} is already in use by another process.\nYou can configure a different port in ~/.cell-harness/config.yaml (under web.port) or via the --port <port> option.
453
+
454
+ `);
455
+ process.exitCode = 1;
456
+ return;
457
+ }
458
+ throw error;
459
+ }
460
+ }
461
+ }
462
+ //#endregion
463
+ export { ensureCellHarnessDshHome as a, installConsoleRebrand as c, resolveCellHarnessSessionPath as d, resolveProfileBootUrl as f, ensureAuthenticatedSession as i, parseCellHarnessArgs as l, PROFILE_BOOT_ARTIFACT_URL as n, findEAddrInUseError as o, runCellHarnessCli as p, PROFILE_BOOT_SOURCE_URL as r, getBrandBanner as s, CELL_HARNESS_PATCH as t, resolveCellHarnessDshHome as u };
@@ -0,0 +1,349 @@
1
+ import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
2
+ import { dirname, join, resolve } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { PROFILE_PATCH_FILENAME, PROFILE_TEMPLATES, boot, composeEntries, healProfilesModuleFallback, initProfile, installFailLoud, loadOptionalPatches, loadOverlayPatches, loadProfile, resolveProfileDir, watchUserPatches } from "@deepseek-ai/dsh-app-boot";
5
+ import { resolveDshHome } from "@deepseek-ai/dsh-home-paths";
6
+ import { installProxyFromEnvironment } from "@deepseek-ai/dsh-http-proxy";
7
+ import { DSH_LAUNCH_ENVIRONMENT_KEY } from "@deepseek-ai/dsh-launch-environment";
8
+ import { provideCmdline } from "@deepseek-ai/dsh-cmdline";
9
+ //#region ../cli/lib/types/process-shutdown.js
10
+ /** Bounded, escalating process shutdown for the long-lived CLI surfaces. */
11
+ /** Maximum grace allowed for the application tree to dispose before process exit. */
12
+ const PROCESS_SHUTDOWN_TIMEOUT_MS = 5e3;
13
+ /**
14
+ * Create one process-exit controller around an application disposer.
15
+ * @param dispose - Whole-application teardown that resolves at quiescence.
16
+ * @param forceExit - Function that exits the process immediately, replaceable by tests.
17
+ * @param complete - Function that records the natural completion code, replaceable by tests.
18
+ * @param timeoutMs - Grace before forced exit, replaceable by tests.
19
+ * @returns A controller whose normal calls coalesce and whose repeated signal call escalates.
20
+ */
21
+ function createProcessShutdown(dispose, forceExit = (code) => {
22
+ process.exit(code);
23
+ }, complete = (code) => {
24
+ process.exitCode = code;
25
+ }, timeoutMs = PROCESS_SHUTDOWN_TIMEOUT_MS) {
26
+ let pending;
27
+ let timeout;
28
+ let completed = false;
29
+ let forceExited = false;
30
+ const clearExitTimeout = () => {
31
+ /* v8 ignore else -- shutdown() arms the timer before any asynchronous exit path can run. */
32
+ if (timeout !== void 0) clearTimeout(timeout);
33
+ };
34
+ const forceExitOnce = (code) => {
35
+ if (forceExited) return;
36
+ forceExited = true;
37
+ clearExitTimeout();
38
+ forceExit(code);
39
+ };
40
+ const completeOnce = (code) => {
41
+ if (completed || forceExited) return;
42
+ completed = true;
43
+ clearExitTimeout();
44
+ complete(code);
45
+ };
46
+ const start = (code, forceAfterDispose) => {
47
+ if (pending !== void 0) return pending;
48
+ timeout = setTimeout(() => {
49
+ forceExitOnce(code);
50
+ }, timeoutMs);
51
+ pending = Promise.resolve().then(dispose).then(() => {
52
+ if (forceAfterDispose) forceExitOnce(code);
53
+ else completeOnce(code);
54
+ }, () => {
55
+ forceExitOnce(code);
56
+ });
57
+ return pending;
58
+ };
59
+ return {
60
+ shutdown(code) {
61
+ return start(code, false);
62
+ },
63
+ interrupt(code) {
64
+ if (pending !== void 0) {
65
+ forceExitOnce(code);
66
+ return;
67
+ }
68
+ start(code, true);
69
+ }
70
+ };
71
+ }
72
+ //#endregion
73
+ //#region ../cli/lib/types/profile-boot.js
74
+ /**
75
+ * Shared profile boot for every `dsh` surface: resolve the profile, stack its
76
+ * patch layers (bundle layers in `dsh.profile.bundles` order, the profile's
77
+ * own `cordis.patch.yml`, `--patch` overlays, the telemetry switch), mount the
78
+ * tree over the profile's empty root config, apply its selected patch-reload
79
+ * lifecycle, and wire fail-loud plus bounded shutdown.
80
+ *
81
+ * App flags are not the launcher's business: the invocation's inner arguments
82
+ * are provided to the tree through `ctx.cmdlineArgs`, where any injected app
83
+ * plugin may read the same immutable snapshot.
84
+ * @module @deepseek-ai/dsh/profile-boot
85
+ */
86
+ const NAME = "dsh";
87
+ /** Launcher-owned readiness signal committed only after boot and host setup succeed. */
88
+ function createAppReady() {
89
+ let ready = false;
90
+ const listeners = /* @__PURE__ */ new Set();
91
+ return {
92
+ service: { onReady(listener) {
93
+ if (ready) {
94
+ listener();
95
+ return () => {};
96
+ }
97
+ listeners.add(listener);
98
+ return () => {
99
+ listeners.delete(listener);
100
+ };
101
+ } },
102
+ commit() {
103
+ if (ready) return;
104
+ ready = true;
105
+ for (const listener of [...listeners]) listener();
106
+ listeners.clear();
107
+ }
108
+ };
109
+ }
110
+ /**
111
+ * The home-level user patch layer (`$DSH_HOME/cordis.patch.yml`), applied
112
+ * over every profile's own layer. Resolved per call, not at module load:
113
+ * `$DSH_HOME` may be set by the test or launcher after import.
114
+ * @returns the absolute patch-file path.
115
+ */
116
+ function homePatchPath() {
117
+ return join(resolveDshHome(), PROFILE_PATCH_FILENAME);
118
+ }
119
+ /** Absolute path of this dsh installation's package.json (both anchors: src/ and lib/ sit one level under apps/cli). */
120
+ const INSTALL_ANCHOR = fileURLToPath(new URL("../package.json", import.meta.url));
121
+ /** The session-telemetry row id the DSH_TELEMETRY_DISABLED switch targets. */
122
+ const TELEMETRY_ROW_ID = "session-telemetry-otel";
123
+ /** The empty root entry list every profile tree patches over. */
124
+ const PROFILE_ROOT_CONFIG = `# dsh profile root — an empty entry list. The tree is composed as patches:
125
+ # each bundle in package.json's dsh.profile.bundles, then cordis.patch.yml, then any
126
+ # --patch overlays. Edit cordis.patch.yml, not this file.
127
+ []
128
+ `;
129
+ /** Root config filename inside a profile directory. */
130
+ const PROFILE_ROOT_FILENAME = "cordis.yml";
131
+ /**
132
+ * Initialize a missing profile from one shipped template. This copies only
133
+ * the template's bundle list and patch-reload policy; local state from the
134
+ * same-named shipped profile is not read, and no inheritance metadata is
135
+ * persisted. Shipped profile names are reserved, and the target directory is
136
+ * claimed exclusively so existing or concurrent state is never reused.
137
+ * @param name - the new profile name.
138
+ * @param fromDefaultProfile - shipped profile template to copy.
139
+ * @param home - Harness home containing the profile directory.
140
+ * @throws when the template is unknown, the target name is shipped, or the target directory exists.
141
+ */
142
+ function initializeProfileFromDefault(name, fromDefaultProfile, home = resolveDshHome()) {
143
+ const dir = resolveProfileDir(name, home);
144
+ const template = Object.hasOwn(PROFILE_TEMPLATES, fromDefaultProfile) ? PROFILE_TEMPLATES[fromDefaultProfile] : void 0;
145
+ if (template === void 0) {
146
+ const expected = Object.keys(PROFILE_TEMPLATES).sort().map((value) => JSON.stringify(value)).join(", ");
147
+ throw new Error(`${NAME}: unknown default profile ${JSON.stringify(fromDefaultProfile)}; expected one of ${expected}`);
148
+ }
149
+ if (Object.hasOwn(PROFILE_TEMPLATES, name)) throw new Error(`${NAME}: profile ${JSON.stringify(name)} is shipped and cannot be a custom profile target; omit --from-default-profile to use it`);
150
+ mkdirSync(dirname(dir), { recursive: true });
151
+ try {
152
+ mkdirSync(dir);
153
+ } catch (error) {
154
+ if (error.code !== "EEXIST") throw error;
155
+ const manifestPath = join(dir, "package.json");
156
+ if (existsSync(manifestPath)) throw new Error(`${NAME}: profile ${JSON.stringify(name)} already exists at ${manifestPath}; omit --from-default-profile to use it`);
157
+ throw new Error(`${NAME}: profile directory ${dir} already exists; choose an unused profile name`);
158
+ }
159
+ try {
160
+ initProfile(dir, template.bundles, template.patchReload);
161
+ } catch (error) {
162
+ try {
163
+ rmSync(dir, {
164
+ recursive: true,
165
+ force: true
166
+ });
167
+ } catch (cleanupError) {
168
+ throw new AggregateError([error, cleanupError], `${NAME}: profile initialization failed and ${dir} could not be removed`);
169
+ }
170
+ throw error;
171
+ }
172
+ }
173
+ /**
174
+ * Resolve the telemetry opt-out switch into its boot patch. ANY non-empty
175
+ * value (including `'0'`/`'false'`) disables: a privacy switch prefers
176
+ * off-by-mistake over on-by-mistake. A composition without the telemetry row
177
+ * exports nothing, so the switch is then trivially satisfied and no patch is
178
+ * generated — custom profiles need not mount telemetry to run with the
179
+ * switch set.
180
+ * @param disabledEnv - the raw `DSH_TELEMETRY_DISABLED` value (`undefined` when unset).
181
+ * @param hasRow - whether the composition carries the telemetry row.
182
+ * @returns the disable patch, or `undefined` when no hard-disable patch is required.
183
+ */
184
+ function resolveTelemetryPatch(disabledEnv, hasRow) {
185
+ if ((disabledEnv ?? "") === "" || !hasRow) return void 0;
186
+ return {
187
+ id: TELEMETRY_ROW_ID,
188
+ disabled: true
189
+ };
190
+ }
191
+ /**
192
+ * Load a resolved profile for `name` and (re)write the empty root config. The
193
+ * root is always rewritten: the whole composition is patch layers, and the
194
+ * vendored Loader's tree write-back (a plugin self-disposing persists the
195
+ * current tree) can bake composed rows into this file — which would duplicate
196
+ * every bundle insert on the next boot. The file exists on disk only because
197
+ * the Loader needs a real include root to anchor `baseUrl` at the profile
198
+ * directory (the config dump anchors on the same file, so both compose over
199
+ * the identical base).
200
+ * @param name - the profile name.
201
+ * @param userLayer - `false` skips parsing `cordis.patch.yml` (the default dump).
202
+ * @param fromDefaultProfile - shipped template used once to initialize a missing profile.
203
+ * @returns the loaded profile.
204
+ * @throws when explicit initialization names an unknown template or an existing profile.
205
+ */
206
+ function prepareProfile(name, userLayer = true, fromDefaultProfile) {
207
+ if (fromDefaultProfile !== void 0) initializeProfileFromDefault(name, fromDefaultProfile);
208
+ const profile = loadProfile(NAME, name, INSTALL_ANCHOR, void 0, { userLayer });
209
+ writeFileSync(join(profile.dir, PROFILE_ROOT_FILENAME), PROFILE_ROOT_CONFIG);
210
+ return profile;
211
+ }
212
+ /** The full patch stack of one composed profile, in application order. */
213
+ function allPatches(composed) {
214
+ return [
215
+ ...composed.bundlePatches,
216
+ ...composed.profile.patches,
217
+ ...composed.homePatches,
218
+ ...composed.overlays
219
+ ];
220
+ }
221
+ /**
222
+ * Load `name` and compose its effective patch stack: bundle layers in
223
+ * `dsh.profile.bundles` order (a base-backed profile gets the base bundle's
224
+ * platform-gated shell rows), the profile's user layer, the home-level user
225
+ * layer (`$DSH_HOME/cordis.patch.yml` — machine-local preferences that apply
226
+ * to every profile, so it outranks the per-profile layer), `--patch` overlays,
227
+ * then the telemetry switch.
228
+ * @param name - the profile name.
229
+ * @param patchFiles - `--patch` overlay paths, in argv order.
230
+ * @returns the profile and its patch layers.
231
+ */
232
+ async function composeProfile(name, patchFiles, fromDefaultProfile) {
233
+ const profile = prepareProfile(name, true, fromDefaultProfile);
234
+ await healProfilesModuleFallback({
235
+ installAnchor: INSTALL_ANCHOR,
236
+ profile
237
+ });
238
+ const homePatches = loadOptionalPatches(NAME, homePatchPath()) ?? [];
239
+ const overlays = patchFiles.flatMap((file) => loadOverlayPatches(NAME, resolve(file)));
240
+ const bundlePatches = profile.layers.flatMap((layer) => layer.patches);
241
+ const rows = /* @__PURE__ */ new Map();
242
+ for (const row of composeEntries([
243
+ bundlePatches,
244
+ profile.patches,
245
+ homePatches,
246
+ overlays
247
+ ])) if (typeof row.id === "string") rows.set(row.id, row);
248
+ const composedOverlays = [...overlays];
249
+ const telemetryPatch = resolveTelemetryPatch(process.env.DSH_TELEMETRY_DISABLED, rows.has(TELEMETRY_ROW_ID));
250
+ if (telemetryPatch !== void 0) composedOverlays.push(telemetryPatch);
251
+ return {
252
+ profile,
253
+ bundlePatches,
254
+ homePatches,
255
+ overlays: composedOverlays
256
+ };
257
+ }
258
+ /**
259
+ * Re-throw a watcher-setup failure unless a shutdown already owns the tree:
260
+ * a signal aborted this invocation, or an app requested exit (`ctx.appExit`
261
+ * from a fast one-shot) and the root's disposal rejected the in-flight setup
262
+ * await. Either way the failure describes a tree that is exiting as asked,
263
+ * not a broken watch.
264
+ * @param ctx - the booted root context.
265
+ * @param signal - this invocation's signal-shutdown fact.
266
+ * @param error - the setup failure.
267
+ */
268
+ function suppressShutdownError(ctx, signal, error) {
269
+ if (signal.aborted) return;
270
+ if (ctx.fiber.state !== 2 || ctx.get("loader") === void 0) return;
271
+ throw error;
272
+ }
273
+ /**
274
+ * Boot one profile invocation end to end and leave process lifetime to the
275
+ * mounted plugins (or to a one-shot runner the composition mounts).
276
+ * @param options - environment snapshot, profile name, overlays, and the booted app's own arguments.
277
+ * @returns the settled root context and the shutdown controller.
278
+ */
279
+ async function runProfile(options) {
280
+ const disposeProxy = await installProxyFromEnvironment(options.environment, (message) => {
281
+ process.stderr.write(`${NAME}: ${message}\n`);
282
+ });
283
+ const composed = await composeProfile(options.profile, options.patchFiles, options.fromDefaultProfile);
284
+ const app = {};
285
+ const appReady = createAppReady();
286
+ const shutdown = createProcessShutdown(async () => {
287
+ await app.current?.fiber.dispose();
288
+ await disposeProxy();
289
+ });
290
+ const signalShutdown = new AbortController();
291
+ const interrupt = (code) => {
292
+ signalShutdown.abort();
293
+ shutdown.interrupt(code);
294
+ };
295
+ process.on("SIGTERM", () => {
296
+ interrupt(0);
297
+ });
298
+ process.on("SIGINT", () => {
299
+ interrupt(130);
300
+ });
301
+ installFailLoud(NAME, process, async () => {
302
+ await app.current?.fiber.dispose();
303
+ });
304
+ const rootConfig = join(composed.profile.dir, PROFILE_ROOT_FILENAME);
305
+ const composeLive = () => structuredClone([
306
+ ...composed.bundlePatches,
307
+ ...loadOptionalPatches(NAME, composed.profile.patchPath) ?? [],
308
+ ...loadOptionalPatches(NAME, homePatchPath()) ?? [],
309
+ ...composed.overlays
310
+ ]);
311
+ const ctx = await boot(NAME, rootConfig, structuredClone(allPatches(composed)), (hostCtx) => {
312
+ app.current = hostCtx;
313
+ hostCtx.provide(DSH_LAUNCH_ENVIRONMENT_KEY, options.environment);
314
+ provideCmdline(hostCtx, {
315
+ args: options.args,
316
+ exit: (code) => void shutdown.shutdown(code),
317
+ ready: appReady.service
318
+ });
319
+ });
320
+ app.current = ctx;
321
+ if (composed.profile.patchReload === "live" && !signalShutdown.signal.aborted && ctx.fiber.state === 2 && ctx.get("loader") !== void 0) try {
322
+ if (ctx.get("hmr") === void 0) {
323
+ if (ctx.get("timer") === void 0) await ctx.loader.create({ name: "@deepseek-ai/cordis-plugin-timer" });
324
+ await ctx.loader.create({
325
+ name: "@deepseek-ai/cordis-plugin-hmr",
326
+ config: { root: [] }
327
+ });
328
+ }
329
+ await watchUserPatches(ctx, {
330
+ binName: NAME,
331
+ filename: composed.profile.patchPath,
332
+ compose: composeLive
333
+ });
334
+ await watchUserPatches(ctx, {
335
+ binName: NAME,
336
+ filename: homePatchPath(),
337
+ compose: composeLive
338
+ });
339
+ } catch (error) {
340
+ suppressShutdownError(ctx, signalShutdown.signal, error);
341
+ }
342
+ if (!signalShutdown.signal.aborted && ctx.fiber.state === 2 && ctx.get("loader") !== void 0) appReady.commit();
343
+ return {
344
+ ctx,
345
+ shutdown
346
+ };
347
+ }
348
+ //#endregion
349
+ export { INSTALL_ANCHOR, PROFILE_ROOT_FILENAME, homePatchPath, initializeProfileFromDefault, prepareProfile, resolveTelemetryPatch, runProfile };
package/package.json ADDED
@@ -0,0 +1,119 @@
1
+ {
2
+ "name": "@machina.ai/cell-harness",
3
+ "description": "Cell Harness CLI: Nova Solutions",
4
+ "version": "0.1.5-alpha.1.c1",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/deepseek-ai/deepseek-harness.git",
11
+ "directory": "apps/cell-harness"
12
+ },
13
+ "type": "module",
14
+ "bin": {
15
+ "cell-harness": "lib/bin.js",
16
+ "ch": "lib/bin.js"
17
+ },
18
+ "files": [
19
+ "lib/*.js",
20
+ "config/cell-harness.cordis.patch.yml",
21
+ "presets/cell-harness"
22
+ ],
23
+ "license": "MIT",
24
+ "dependencies": {
25
+ "commander": "^15.0.0",
26
+ "js-yaml": "^4.2.0",
27
+ "node-addon-require-builtin": "^0.1.4",
28
+ "@deepseek-ai/cordis-plugin-hmr": "1.0.17",
29
+ "@deepseek-ai/cordis-plugin-group": "1.0.2",
30
+ "@deepseek-ai/cordis-plugin-include": "1.0.7",
31
+ "@deepseek-ai/cordis-plugin-timer": "1.1.4",
32
+ "@deepseek-ai/cordis": "4.0.2",
33
+ "@deepseek-ai/cordis-plugin-loader": "1.0.3",
34
+ "@deepseek-ai/dsh-agent-instructions": "0.1.5-alpha.1",
35
+ "@deepseek-ai/dsh-app-boot": "0.1.5-alpha.1",
36
+ "@deepseek-ai/dsh-agent-tool-presentation": "0.1.5-alpha.1",
37
+ "@deepseek-ai/dsh-acp-app": "0.1.5-alpha.1",
38
+ "@deepseek-ai/dsh-base": "0.1.5-alpha.1",
39
+ "@deepseek-ai/dsh-client-ui-agent-preset": "0.1.5-alpha.1",
40
+ "@deepseek-ai/dsh-client-ui-cordis": "0.1.5-alpha.1",
41
+ "@deepseek-ai/dsh-command-goal": "0.1.5-alpha.1",
42
+ "@deepseek-ai/dsh-compaction-basic": "0.1.5-alpha.1",
43
+ "@deepseek-ai/dsh-cmdline": "0.1.5-alpha.1",
44
+ "@deepseek-ai/dsh-compaction-tool-result-pruner": "0.1.5-alpha.1",
45
+ "@deepseek-ai/dsh-command-compact": "0.1.5-alpha.1",
46
+ "@deepseek-ai/dsh-cordis-client-runner": "0.1.5-alpha.1",
47
+ "@deepseek-ai/dsh-fs-local": "0.1.5-alpha.1",
48
+ "@deepseek-ai/dsh-goal-round-driver": "0.1.5-alpha.1",
49
+ "@deepseek-ai/dsh-goal": "0.1.5-alpha.1",
50
+ "@deepseek-ai/dsh-headless": "0.1.5-alpha.1",
51
+ "@deepseek-ai/dsh-hooks-claude-code": "0.1.5-alpha.1",
52
+ "@deepseek-ai/dsh-home-paths": "0.1.5-alpha.1",
53
+ "@deepseek-ai/dsh-hooks-codex": "0.1.5-alpha.1",
54
+ "@deepseek-ai/dsh-http-proxy": "0.1.5-alpha.1",
55
+ "@deepseek-ai/dsh-mcp-client": "0.1.5-alpha.1",
56
+ "@deepseek-ai/dsh-jobs-local": "0.1.5-alpha.1",
57
+ "@deepseek-ai/dsh-persona": "0.1.5-alpha.1",
58
+ "@deepseek-ai/dsh-launch-environment": "0.1.5-alpha.1",
59
+ "@deepseek-ai/dsh-plan-mode": "0.1.5-alpha.1",
60
+ "@deepseek-ai/dsh-pwsh-local": "0.1.5-alpha.1",
61
+ "@deepseek-ai/dsh-pwsh-sandbox": "0.1.5-alpha.1",
62
+ "@deepseek-ai/dsh-schedule": "0.1.5-alpha.1",
63
+ "@deepseek-ai/dsh-sdk-app": "0.1.5-alpha.1",
64
+ "@deepseek-ai/dsh-sdk-minimal": "0.1.5-alpha.1",
65
+ "@deepseek-ai/dsh-session-projection": "0.1.5-alpha.1",
66
+ "@deepseek-ai/dsh-session-reference": "0.1.5-alpha.1",
67
+ "@deepseek-ai/dsh-skill": "0.1.5-alpha.1",
68
+ "@deepseek-ai/dsh-skill-filesystem": "0.1.5-alpha.1",
69
+ "@deepseek-ai/dsh-terminal": "0.1.5-alpha.1",
70
+ "@deepseek-ai/dsh-tmux-context": "0.1.5-alpha.1",
71
+ "@deepseek-ai/dsh-time-context": "0.1.5-alpha.1",
72
+ "@deepseek-ai/dsh-token-meter": "0.1.5-alpha.1",
73
+ "@deepseek-ai/dsh-terminal-bash": "0.1.5-alpha.1",
74
+ "@deepseek-ai/dsh-tool-ask-user": "0.1.5-alpha.1",
75
+ "@deepseek-ai/dsh-tool-cordis": "0.1.5-alpha.1",
76
+ "@deepseek-ai/dsh-tool-bash": "0.1.5-alpha.1",
77
+ "@deepseek-ai/dsh-tool-bash-persistent": "0.1.5-alpha.1",
78
+ "@deepseek-ai/dsh-tool-fs": "0.1.5-alpha.1",
79
+ "@deepseek-ai/dsh-tool-goal": "0.1.5-alpha.1",
80
+ "@deepseek-ai/dsh-tool-fs-search": "0.1.5-alpha.1",
81
+ "@deepseek-ai/dsh-tool-jobs": "0.1.5-alpha.1",
82
+ "@deepseek-ai/dsh-tool-pwsh": "0.1.5-alpha.1",
83
+ "@deepseek-ai/dsh-tool-pwsh-persistent": "0.1.5-alpha.1",
84
+ "@deepseek-ai/dsh-tool-ralph": "0.1.5-alpha.1",
85
+ "@deepseek-ai/dsh-tool-skill": "0.1.5-alpha.1",
86
+ "@deepseek-ai/dsh-tool-str-replace-editor": "0.1.5-alpha.1",
87
+ "@deepseek-ai/dsh-tool-subagent": "0.1.5-alpha.1",
88
+ "@deepseek-ai/dsh-tool-todo": "0.1.5-alpha.1",
89
+ "@deepseek-ai/dsh-tool-subagent-control": "0.1.5-alpha.1",
90
+ "@deepseek-ai/dsh-tool-web": "0.1.5-alpha.1",
91
+ "@deepseek-ai/dsh-tool-workflow": "0.1.5-alpha.1",
92
+ "@deepseek-ai/dsh-web-app": "0.1.5-alpha.1",
93
+ "@deepseek-ai/dsh-web-frontend": "0.1.5-alpha.1",
94
+ "@deepseek-ai/dsh-webhook-github": "0.1.5-alpha.1",
95
+ "@deepseek-ai/dsh-webhook": "0.1.5-alpha.1",
96
+ "@deepseek-ai/schemastery": "3.18.2",
97
+ "@machina.ai/ch-auth-reboot-sso": "^0.1.5-alpha.1.c1",
98
+ "@machina.ai/ch-client-locale-es-mx": "^0.1.5-alpha.1.c1",
99
+ "@deepseek-ai/dsh-workflow-worker-thread": "0.1.5-alpha.1",
100
+ "@machina.ai/ch-client-ui-brand-nova": "^0.1.5-alpha.1.c1",
101
+ "@machina.ai/ch-client-ui-settings-cell-models": "^0.1.5-alpha.1.c1",
102
+ "@machina.ai/ch-image": "^0.1.5-alpha.1.c1",
103
+ "@machina.ai/ch-image-gemini-reboot": "^0.1.5-alpha.1.c1",
104
+ "@machina.ai/ch-llm-reboot": "^0.1.5-alpha.1.c1",
105
+ "@machina.ai/ch-skill-conductor": "^0.1.5-alpha.1.c1",
106
+ "@machina.ai/ch-tool-image": "^0.1.5-alpha.1.c1",
107
+ "@machina.ai/ch-web-search-gemini": "^0.1.5-alpha.1.c1"
108
+ },
109
+ "devDependencies": {
110
+ "@types/js-yaml": "^4.0.9",
111
+ "@types/node": "^22.0.0",
112
+ "js-yaml": "^4.1.0",
113
+ "@deepseek-ai/cordis-plugin-include": "^1.0.7"
114
+ },
115
+ "scripts": {
116
+ "bundle": "tsdown",
117
+ "watch": "tsdown --watch"
118
+ }
119
+ }
@@ -0,0 +1,48 @@
1
+ # Cell Harness (Nova Solutions Systems) agent preset
2
+ - id: persona
3
+ name: '@deepseek-ai/dsh-persona'
4
+ config:
5
+ suffix: Your working directory is {{cwd}}.
6
+ prefix: >-
7
+ You are Cell Harness, an advanced coding and automation agent developed by Nova Solutions Systems powered by {{model}}.
8
+
9
+ - id: agent-instructions
10
+ name: '@deepseek-ai/dsh-agent-instructions'
11
+ config:
12
+ maxBytes: 65536
13
+
14
+ - id: tool-bash
15
+ name: '@deepseek-ai/dsh-tool-bash'
16
+ disabled: !!js process.platform === 'win32'
17
+
18
+ - id: tool-pwsh
19
+ name: '@deepseek-ai/dsh-tool-pwsh'
20
+
21
+ - id: tool-fs
22
+ name: '@deepseek-ai/dsh-tool-fs'
23
+
24
+ - id: tool-fs-search
25
+ name: '@deepseek-ai/dsh-tool-fs-search'
26
+
27
+ - id: tool-str-replace-editor
28
+ name: '@deepseek-ai/dsh-tool-str-replace-editor'
29
+
30
+ - id: tool-web
31
+ name: '@deepseek-ai/dsh-tool-web'
32
+ config:
33
+ fetch: true
34
+
35
+ - id: tool-skill
36
+ name: '@deepseek-ai/dsh-tool-skill'
37
+
38
+ - id: tool-subagent
39
+ name: '@deepseek-ai/dsh-tool-subagent'
40
+
41
+ - id: tool-todo
42
+ name: '@deepseek-ai/dsh-tool-todo'
43
+
44
+ - id: plan-mode
45
+ name: '@deepseek-ai/dsh-plan-mode'
46
+
47
+ - id: goal
48
+ name: '@deepseek-ai/dsh-goal'
@@ -0,0 +1,3 @@
1
+ name: Cell Harness (Nova Solutions Systems)
2
+ description: Full-featured coding Agent preset with Nova Solutions Systems branding and extended tool capabilities.
3
+ order: 1