aicodeman 1.28.2 → 1.29.0

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.
Files changed (183) hide show
  1. package/README.md +1 -1
  2. package/dist/attachment-registry.d.ts +20 -0
  3. package/dist/attachment-registry.d.ts.map +1 -1
  4. package/dist/attachment-registry.js +75 -10
  5. package/dist/attachment-registry.js.map +1 -1
  6. package/dist/config/cli-registry/schema.d.ts +25 -0
  7. package/dist/config/cli-registry/schema.d.ts.map +1 -1
  8. package/dist/config/cli-registry/schema.js +43 -0
  9. package/dist/config/cli-registry/schema.js.map +1 -1
  10. package/dist/config/cli-registry/stock.d.ts.map +1 -1
  11. package/dist/config/cli-registry/stock.js +157 -2
  12. package/dist/config/cli-registry/stock.js.map +1 -1
  13. package/dist/config/cli-registry/types.d.ts +60 -0
  14. package/dist/config/cli-registry/types.d.ts.map +1 -1
  15. package/dist/custom-model-hosts.d.ts +39 -0
  16. package/dist/custom-model-hosts.d.ts.map +1 -0
  17. package/dist/custom-model-hosts.js +35 -0
  18. package/dist/custom-model-hosts.js.map +1 -0
  19. package/dist/custom-model-injection-apply.d.ts +49 -0
  20. package/dist/custom-model-injection-apply.d.ts.map +1 -0
  21. package/dist/custom-model-injection-apply.js +77 -0
  22. package/dist/custom-model-injection-apply.js.map +1 -0
  23. package/dist/custom-model-injection.d.ts +79 -0
  24. package/dist/custom-model-injection.d.ts.map +1 -0
  25. package/dist/custom-model-injection.js +169 -0
  26. package/dist/custom-model-injection.js.map +1 -0
  27. package/dist/docker-hosts.d.ts +42 -0
  28. package/dist/docker-hosts.d.ts.map +1 -1
  29. package/dist/docker-hosts.js +18 -0
  30. package/dist/docker-hosts.js.map +1 -1
  31. package/dist/generated-artifact-attachments.d.ts +3 -0
  32. package/dist/generated-artifact-attachments.d.ts.map +1 -1
  33. package/dist/generated-artifact-attachments.js +18 -8
  34. package/dist/generated-artifact-attachments.js.map +1 -1
  35. package/dist/mux-interface.d.ts +7 -0
  36. package/dist/mux-interface.d.ts.map +1 -1
  37. package/dist/remote-files.d.ts +145 -0
  38. package/dist/remote-files.d.ts.map +1 -0
  39. package/dist/remote-files.js +347 -0
  40. package/dist/remote-files.js.map +1 -0
  41. package/dist/remote-hosts.d.ts +12 -0
  42. package/dist/remote-hosts.d.ts.map +1 -1
  43. package/dist/remote-hosts.js +7 -1
  44. package/dist/remote-hosts.js.map +1 -1
  45. package/dist/remote-ssh-limiter.d.ts +42 -0
  46. package/dist/remote-ssh-limiter.d.ts.map +1 -0
  47. package/dist/remote-ssh-limiter.js +84 -0
  48. package/dist/remote-ssh-limiter.js.map +1 -0
  49. package/dist/session-manager.d.ts.map +1 -1
  50. package/dist/session-manager.js +8 -1
  51. package/dist/session-manager.js.map +1 -1
  52. package/dist/session.d.ts +79 -2
  53. package/dist/session.d.ts.map +1 -1
  54. package/dist/session.js +163 -2
  55. package/dist/session.js.map +1 -1
  56. package/dist/tmux-manager.d.ts.map +1 -1
  57. package/dist/tmux-manager.js +27 -13
  58. package/dist/tmux-manager.js.map +1 -1
  59. package/dist/types/api.d.ts +6 -0
  60. package/dist/types/api.d.ts.map +1 -1
  61. package/dist/types/api.js.map +1 -1
  62. package/dist/types/session.d.ts +30 -0
  63. package/dist/types/session.d.ts.map +1 -1
  64. package/dist/types/session.js.map +1 -1
  65. package/dist/web/middleware/auth.d.ts +11 -1
  66. package/dist/web/middleware/auth.d.ts.map +1 -1
  67. package/dist/web/middleware/auth.js +69 -1
  68. package/dist/web/middleware/auth.js.map +1 -1
  69. package/dist/web/public/admin-ui.js.gz +0 -0
  70. package/dist/web/public/api-client.c9b1cddc.js.gz +0 -0
  71. package/dist/web/public/{app.78bf0bf8.js → app.556be563.js} +7 -7
  72. package/dist/web/public/app.556be563.js.br +0 -0
  73. package/dist/web/public/app.556be563.js.gz +0 -0
  74. package/dist/web/public/approvals-ui.js.gz +0 -0
  75. package/dist/web/public/constants.258b140f.js.gz +0 -0
  76. package/dist/web/public/cron-ui.js.gz +0 -0
  77. package/dist/web/public/entrance-animations.js.gz +0 -0
  78. package/dist/web/public/home-sessions.js.gz +0 -0
  79. package/dist/web/public/i18n.561ca09c.js.gz +0 -0
  80. package/dist/web/public/image-input.cd4b97c4.js.gz +0 -0
  81. package/dist/web/public/index.html +14 -7
  82. package/dist/web/public/index.html.br +0 -0
  83. package/dist/web/public/index.html.gz +0 -0
  84. package/dist/web/public/input-cjk.8bc46081.js +1 -0
  85. package/dist/web/public/input-cjk.8bc46081.js.br +0 -0
  86. package/dist/web/public/input-cjk.8bc46081.js.gz +0 -0
  87. package/dist/web/public/{keyboard-accessory.1d0dda9b.js → keyboard-accessory.2cf04f17.js} +38 -3
  88. package/dist/web/public/keyboard-accessory.2cf04f17.js.br +0 -0
  89. package/dist/web/public/keyboard-accessory.2cf04f17.js.gz +0 -0
  90. package/dist/web/public/mobile-handlers.6f354a87.js.gz +0 -0
  91. package/dist/web/public/mobile-overview.js.gz +0 -0
  92. package/dist/web/public/mobile.e9d0b53e.css.gz +0 -0
  93. package/dist/web/public/notification-manager.36ea4624.js.gz +0 -0
  94. package/dist/web/public/orchestrator-panel.js.gz +0 -0
  95. package/dist/web/public/panels-ui.5b07ad14.js.gz +0 -0
  96. package/dist/web/public/ralph-panel.6de2d0f8.js.gz +0 -0
  97. package/dist/web/public/ralph-wizard.13a1831e.js.gz +0 -0
  98. package/dist/web/public/readmymind-ui.js.gz +0 -0
  99. package/dist/web/public/respawn-ui.ff0dae4c.js.gz +0 -0
  100. package/dist/web/public/sanitize-html.bc7078d6.js.gz +0 -0
  101. package/dist/web/public/session-lineage.js.gz +0 -0
  102. package/dist/web/public/{session-ui.5d0a7b15.js → session-ui.42b81477.js} +13 -13
  103. package/dist/web/public/session-ui.42b81477.js.br +0 -0
  104. package/dist/web/public/session-ui.42b81477.js.gz +0 -0
  105. package/dist/web/public/settings-ui.e0c7f6b4.js.gz +0 -0
  106. package/dist/web/public/{styles.5d36726d.css → styles.6add175d.css} +1 -1
  107. package/dist/web/public/styles.6add175d.css.br +0 -0
  108. package/dist/web/public/{styles.5d36726d.css.gz → styles.6add175d.css.gz} +0 -0
  109. package/dist/web/public/subagent-windows.e6ca799f.js.gz +0 -0
  110. package/dist/web/public/sw.js.gz +0 -0
  111. package/dist/web/public/tab-rail-resize.42c24949.js.gz +0 -0
  112. package/dist/web/public/terminal-keycode229-recovery.6ea8fe37.js.gz +0 -0
  113. package/dist/web/public/terminal-ui.38c49244.js +2 -0
  114. package/dist/web/public/terminal-ui.38c49244.js.br +0 -0
  115. package/dist/web/public/terminal-ui.38c49244.js.gz +0 -0
  116. package/dist/web/public/ultracode-panel.js.gz +0 -0
  117. package/dist/web/public/ultracode-windows.js.gz +0 -0
  118. package/dist/web/public/upload.html.gz +0 -0
  119. package/dist/web/public/vendor/dompurify.min.js.gz +0 -0
  120. package/dist/web/public/vendor/marked.min.js.gz +0 -0
  121. package/dist/web/public/vendor/xterm-addon-fit.min.js.gz +0 -0
  122. package/dist/web/public/vendor/xterm-addon-serialize.min.js.gz +0 -0
  123. package/dist/web/public/vendor/xterm-addon-unicode11.min.js.gz +0 -0
  124. package/dist/web/public/vendor/xterm-addon-webgl.min.js.gz +0 -0
  125. package/dist/web/public/vendor/xterm-predictive-echo.bd6882b8.js.gz +0 -0
  126. package/dist/web/public/vendor/xterm-zerolag-input.6fee72f2.js.gz +0 -0
  127. package/dist/web/public/vendor/xterm.css.gz +0 -0
  128. package/dist/web/public/vendor/xterm.min.js.gz +0 -0
  129. package/dist/web/public/voice-input.c4b51eb6.js.gz +0 -0
  130. package/dist/web/public/voice-pcm-worklet.js.gz +0 -0
  131. package/dist/web/public/webview-tabs.js +56 -4
  132. package/dist/web/public/webview-tabs.js.br +0 -0
  133. package/dist/web/public/webview-tabs.js.gz +0 -0
  134. package/dist/web/route-helpers.d.ts +20 -0
  135. package/dist/web/route-helpers.d.ts.map +1 -1
  136. package/dist/web/route-helpers.js +29 -2
  137. package/dist/web/route-helpers.js.map +1 -1
  138. package/dist/web/routes/case-routes.d.ts.map +1 -1
  139. package/dist/web/routes/case-routes.js +23 -6
  140. package/dist/web/routes/case-routes.js.map +1 -1
  141. package/dist/web/routes/custom-model-routes.d.ts +18 -0
  142. package/dist/web/routes/custom-model-routes.d.ts.map +1 -0
  143. package/dist/web/routes/custom-model-routes.js +136 -0
  144. package/dist/web/routes/custom-model-routes.js.map +1 -0
  145. package/dist/web/routes/file-routes.d.ts.map +1 -1
  146. package/dist/web/routes/file-routes.js +484 -100
  147. package/dist/web/routes/file-routes.js.map +1 -1
  148. package/dist/web/routes/index.d.ts +1 -0
  149. package/dist/web/routes/index.d.ts.map +1 -1
  150. package/dist/web/routes/index.js +1 -0
  151. package/dist/web/routes/index.js.map +1 -1
  152. package/dist/web/routes/session-routes.d.ts.map +1 -1
  153. package/dist/web/routes/session-routes.js +81 -1
  154. package/dist/web/routes/session-routes.js.map +1 -1
  155. package/dist/web/routes/ws-routes.d.ts.map +1 -1
  156. package/dist/web/routes/ws-routes.js +26 -2
  157. package/dist/web/routes/ws-routes.js.map +1 -1
  158. package/dist/web/schemas.d.ts +20 -0
  159. package/dist/web/schemas.d.ts.map +1 -1
  160. package/dist/web/schemas.js +31 -0
  161. package/dist/web/schemas.js.map +1 -1
  162. package/dist/web/server.d.ts +8 -0
  163. package/dist/web/server.d.ts.map +1 -1
  164. package/dist/web/server.js +65 -3
  165. package/dist/web/server.js.map +1 -1
  166. package/dist/web/webview-proxy.d.ts +41 -0
  167. package/dist/web/webview-proxy.d.ts.map +1 -1
  168. package/dist/web/webview-proxy.js +102 -1
  169. package/dist/web/webview-proxy.js.map +1 -1
  170. package/package.json +2 -2
  171. package/dist/web/public/app.78bf0bf8.js.br +0 -0
  172. package/dist/web/public/app.78bf0bf8.js.gz +0 -0
  173. package/dist/web/public/input-cjk.87f14251.js +0 -1
  174. package/dist/web/public/input-cjk.87f14251.js.br +0 -0
  175. package/dist/web/public/input-cjk.87f14251.js.gz +0 -0
  176. package/dist/web/public/keyboard-accessory.1d0dda9b.js.br +0 -0
  177. package/dist/web/public/keyboard-accessory.1d0dda9b.js.gz +0 -0
  178. package/dist/web/public/session-ui.5d0a7b15.js.br +0 -0
  179. package/dist/web/public/session-ui.5d0a7b15.js.gz +0 -0
  180. package/dist/web/public/styles.5d36726d.css.br +0 -0
  181. package/dist/web/public/terminal-ui.0cbe8637.js +0 -2
  182. package/dist/web/public/terminal-ui.0cbe8637.js.br +0 -0
  183. package/dist/web/public/terminal-ui.0cbe8637.js.gz +0 -0
@@ -0,0 +1,77 @@
1
+ /**
2
+ * @fileoverview The one IO wrapper around `custom-model-injection.ts`'s pure
3
+ * `ConfigDirInjection` output — deliberately split out so that file, the
4
+ * discovery routes, and `scripts/test-local-llm-harnesses.ts` (via tsx) can
5
+ * all share EXACTLY one "write these files, merge this env" implementation.
6
+ * Before this existed, the route and the standalone script each carried
7
+ * their own copy of this logic, which is exactly the kind of drift the CLI
8
+ * registry's "declare once, consume everywhere" design exists to prevent —
9
+ * see docs/custom-model-endpoints-plan.md and the "dynamic to support
10
+ * cli-registry changes" requirement it was written against.
11
+ */
12
+ import { chmodSync, mkdirSync, writeFileSync, rmSync } from 'node:fs';
13
+ import { join, dirname } from 'node:path';
14
+ import { dataPath } from './config/instance.js';
15
+ import { buildCustomModelInjection, } from './custom-model-injection.js';
16
+ /** Where a session's isolated `configDir`-kind files live: never the user's real CLI config path. */
17
+ export function customModelConfigDir(sessionId) {
18
+ return join(dataPath('custom-model-configs'), sessionId);
19
+ }
20
+ /**
21
+ * Writes a `ConfigDirInjection`'s files under `baseDir` and returns the full
22
+ * envOverrides object a caller should merge into the session/process env
23
+ * (the dir-redirect var plus any `extraEnv` the config file references by
24
+ * name). Never touches anything outside `baseDir` — the caller is
25
+ * responsible for choosing an isolated directory (never the user's real
26
+ * `~/.codex`, `~/.pi`, etc.).
27
+ *
28
+ * pi and omp embed the API key literally in the file, so the tree is written
29
+ * 0700/0600 like every other secret-bearing file under `~/.codeman`; the chmod
30
+ * covers a re-apply onto a file that already exists (`mode` only applies at
31
+ * creation).
32
+ */
33
+ export function applyConfigDirInjection(baseDir, injection) {
34
+ for (const file of injection.files) {
35
+ const filePath = join(baseDir, file.relPath);
36
+ mkdirSync(dirname(filePath), { recursive: true, mode: 0o700 });
37
+ writeFileSync(filePath, file.content, { encoding: 'utf8', mode: 0o600 });
38
+ chmodSync(filePath, 0o600);
39
+ }
40
+ return { [injection.dirEnvVar]: baseDir, ...injection.extraEnv };
41
+ }
42
+ /** Best-effort recursive removal of a previously-written configDir. Never throws. */
43
+ export function removeConfigDir(dir) {
44
+ if (!dir)
45
+ return;
46
+ try {
47
+ rmSync(dir, { recursive: true, force: true });
48
+ }
49
+ catch {
50
+ // best-effort cleanup only
51
+ }
52
+ }
53
+ /**
54
+ * Compute (and for the `configDir` kind, write) everything a session needs to run
55
+ * against `endpoint`/`modelId`. Returns undefined for a CLI with no mechanism.
56
+ *
57
+ * Idempotent on purpose: the boot-recovery path calls it again for a session that
58
+ * was already pointed at an endpoint, so the config files are rewritten in place
59
+ * (same content) and the env values, which are never persisted because they carry
60
+ * the API key, are re-derived from the endpoint store instead.
61
+ */
62
+ export function applyCustomModelInjection(entry, endpoint, modelId, sessionId) {
63
+ const injection = buildCustomModelInjection(entry, endpoint, modelId);
64
+ if (injection.kind === 'unsupported')
65
+ return undefined;
66
+ if (injection.kind === 'env') {
67
+ return {
68
+ envOverrides: injection.envOverrides,
69
+ envKeys: Object.keys(injection.envOverrides),
70
+ launchModel: injection.launchModel,
71
+ };
72
+ }
73
+ const configDir = customModelConfigDir(sessionId);
74
+ const envOverrides = applyConfigDirInjection(configDir, injection);
75
+ return { envOverrides, envKeys: Object.keys(envOverrides), configDir, launchModel: injection.launchModel };
76
+ }
77
+ //# sourceMappingURL=custom-model-injection-apply.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-model-injection-apply.js","sourceRoot":"","sources":["../src/custom-model-injection-apply.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OA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AC,MAAM,CAAC;QACP,2BAA2B;IAC7B,CAAC;AACH,CAAC;AAUD;;;;;;;;GAQG;AACH,MAAM,UAAU,yBAAyB,CACvC,KAAqC,EACrC,QAA6B,EAC7B,OAAe,EACf,SAAiB;IAEjB,MAAM,SAAS,GAAG,yBAAyB,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IACtE,IAAI,SAAS,CAAC,IAAI,KAAK,aAAa;QAAE,OAAO,SAAS,CAAC;IACvD,IAAI,SAAS,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;QAC7B,OAAO;YACL,YAAY,EAAE,SAAS,CAAC,YAAY;YACpC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC;YAC5C,WAAW,EAAE,SAAS,CAAC,WAAW;SACnC,CAAC;IACJ,CAAC;IACD,MAAM,SAAS,GAAG,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAClD,MAAM,YAAY,GAAG,uBAAuB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IACnE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,CAAC,WAAW,EAAE,CAAC;AAC7G,CAAC"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * @fileoverview Pure builder for the Custom Model Endpoint Profiles feature
3
+ * (docs/custom-model-endpoints-plan.md): turns a CLI registry entry's
4
+ * `capabilities.customModelInjection` declaration, a configured endpoint,
5
+ * and a chosen model id into the concrete env vars / config-file content
6
+ * that would redirect that CLI's session at the endpoint.
7
+ *
8
+ * No IO here on purpose (mirrors `session-cli-builder.ts`) — a caller
9
+ * writes `ConfigDirInjection.files` to disk under an isolated per-session
10
+ * directory and points `dirEnvVar` at it; this module only computes what
11
+ * those files/env vars should contain.
12
+ *
13
+ * Confidence: `claude` and `opencode` are verified end-to-end against a real
14
+ * llama-swap server (a real "hello world" reply came back). `codex`'s
15
+ * config.toml STRUCTURE is now verified (an earlier `[model].default` table
16
+ * shape was rejected by a real codex binary with "invalid type: map,
17
+ * expected a string" — caught by `scripts/test-local-llm-harnesses.ts`),
18
+ * but `wire_api = "responses"` is the only value codex still accepts
19
+ * (support for `"chat"` was dropped in Feb 2026), and a plain OpenAI
20
+ * Chat-Completions server (llama.cpp, llama-swap, most local setups) does
21
+ * NOT implement the Responses API — so codex may still fail at the
22
+ * PROTOCOL level even with a correctly-shaped config file. That gap is
23
+ * real and current, not a stale warning; see docs/custom-model-endpoints-plan.md. The rest
24
+ * (gemini/pi/grok/deepseek/omp) have their ONE-SHOT INVOCATION flags
25
+ * confirmed against real installed binaries' own `--help` output, but
26
+ * their custom-endpoint env/config conventions remain web-researched,
27
+ * unverified.
28
+ */
29
+ import type { CliEntry } from './config/cli-registry/types.js';
30
+ export interface CustomModelEndpoint {
31
+ id: string;
32
+ label: string;
33
+ /** Root URL, no trailing slash required — e.g. "http://192.168.1.50:8080" or an Azure AI Foundry URL. */
34
+ baseUrl: string;
35
+ /** Falls back to a harmless placeholder for endpoints (llama.cpp) that don't check it. */
36
+ apiKey?: string;
37
+ }
38
+ export interface EnvInjection {
39
+ kind: 'env';
40
+ /** Ready to merge into a session's envOverrides. */
41
+ envOverrides: Record<string, string>;
42
+ /** See {@link ConfigDirInjection.launchModel}. */
43
+ launchModel?: string;
44
+ }
45
+ export interface ConfigDirInjection {
46
+ kind: 'configDir';
47
+ /** Env var that must be set to the directory the caller writes `files` under. */
48
+ dirEnvVar: string;
49
+ files: Array<{
50
+ relPath: string;
51
+ content: string;
52
+ }>;
53
+ /**
54
+ * Env vars the written config file REFERENCES by name rather than embedding a
55
+ * literal value (codex's `env_key = "..."` convention: config.toml never carries
56
+ * the API key itself, only the name of an env var codex reads it from). Merge
57
+ * these into the session's envOverrides alongside `dirEnvVar` — never skip them,
58
+ * or the config points at a credential that was never actually set.
59
+ */
60
+ extraEnv?: Record<string, string>;
61
+ /**
62
+ * The value the CLI's `model` launch param must carry for it to SELECT the injected
63
+ * provider (pi/omp: `custom/<modelId>`; grok: the `[model.<name>]` block name). Absent
64
+ * when the config alone selects the model. Rendered from the registry entry's
65
+ * `customModelInjection.launchModel` template, never hand-built per CLI.
66
+ */
67
+ launchModel?: string;
68
+ }
69
+ export interface UnsupportedInjection {
70
+ kind: 'unsupported';
71
+ }
72
+ export type CustomModelInjectionResult = EnvInjection | ConfigDirInjection | UnsupportedInjection;
73
+ /** Normalizes a base URL to end in exactly one trailing `/v1`, for CLIs whose config expects the OpenAI-style suffix. */
74
+ export declare function withV1Suffix(baseUrl: string): string;
75
+ export declare function buildCustomModelInjection(entry: Pick<CliEntry, 'capabilities'>, endpoint: CustomModelEndpoint, modelId: string): CustomModelInjectionResult;
76
+ /** The `[model.<name>]` block name grok's config.toml uses for the injected model — also
77
+ * what `-m <name>` in the standalone script's ONE_SHOT argv must reference to select it. */
78
+ export declare const GROK_CUSTOM_MODEL_NAME = "codeman-custom";
79
+ //# sourceMappingURL=custom-model-injection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-model-injection.d.ts","sourceRoot":"","sources":["../src/custom-model-injection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAE/D,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,yGAAyG;IACzG,OAAO,EAAE,MAAM,CAAC;IAChB,0FAA0F;IAC1F,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,KAAK,CAAC;IACZ,oDAAoD;IACpD,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,kDAAkD;IAClD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,WAAW,CAAC;IAClB,iFAAiF;IACjF,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnD;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,MAAM,MAAM,0BAA0B,GAAG,YAAY,GAAG,kBAAkB,GAAG,oBAAoB,CAAC;AAIlG,yHAAyH;AACzH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGpD;AAOD,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,EACrC,QAAQ,EAAE,mBAAmB,EAC7B,OAAO,EAAE,MAAM,GACd,0BAA0B,CA+B5B;AAmCD;6FAC6F;AAC7F,eAAO,MAAM,sBAAsB,mBAAmB,CAAC"}
@@ -0,0 +1,169 @@
1
+ /**
2
+ * @fileoverview Pure builder for the Custom Model Endpoint Profiles feature
3
+ * (docs/custom-model-endpoints-plan.md): turns a CLI registry entry's
4
+ * `capabilities.customModelInjection` declaration, a configured endpoint,
5
+ * and a chosen model id into the concrete env vars / config-file content
6
+ * that would redirect that CLI's session at the endpoint.
7
+ *
8
+ * No IO here on purpose (mirrors `session-cli-builder.ts`) — a caller
9
+ * writes `ConfigDirInjection.files` to disk under an isolated per-session
10
+ * directory and points `dirEnvVar` at it; this module only computes what
11
+ * those files/env vars should contain.
12
+ *
13
+ * Confidence: `claude` and `opencode` are verified end-to-end against a real
14
+ * llama-swap server (a real "hello world" reply came back). `codex`'s
15
+ * config.toml STRUCTURE is now verified (an earlier `[model].default` table
16
+ * shape was rejected by a real codex binary with "invalid type: map,
17
+ * expected a string" — caught by `scripts/test-local-llm-harnesses.ts`),
18
+ * but `wire_api = "responses"` is the only value codex still accepts
19
+ * (support for `"chat"` was dropped in Feb 2026), and a plain OpenAI
20
+ * Chat-Completions server (llama.cpp, llama-swap, most local setups) does
21
+ * NOT implement the Responses API — so codex may still fail at the
22
+ * PROTOCOL level even with a correctly-shaped config file. That gap is
23
+ * real and current, not a stale warning; see docs/custom-model-endpoints-plan.md. The rest
24
+ * (gemini/pi/grok/deepseek/omp) have their ONE-SHOT INVOCATION flags
25
+ * confirmed against real installed binaries' own `--help` output, but
26
+ * their custom-endpoint env/config conventions remain web-researched,
27
+ * unverified.
28
+ */
29
+ const DEFAULT_API_KEY = 'local-dummy-key';
30
+ /** Normalizes a base URL to end in exactly one trailing `/v1`, for CLIs whose config expects the OpenAI-style suffix. */
31
+ export function withV1Suffix(baseUrl) {
32
+ const trimmed = baseUrl.replace(/\/+$/, '');
33
+ return /\/v1$/.test(trimmed) ? trimmed : `${trimmed}/v1`;
34
+ }
35
+ /** JSON-escapes a string for embedding in a TOML/YAML double-quoted scalar — a safe superset of both grammars' basic escapes. */
36
+ function quoted(value) {
37
+ return JSON.stringify(value);
38
+ }
39
+ export function buildCustomModelInjection(entry, endpoint, modelId) {
40
+ const cap = entry.capabilities.customModelInjection;
41
+ const apiKey = endpoint.apiKey?.trim() || DEFAULT_API_KEY;
42
+ switch (cap.kind) {
43
+ case 'env': {
44
+ const envOverrides = {
45
+ [cap.baseUrlVar]: endpoint.baseUrl,
46
+ [cap.apiKeyVar]: apiKey,
47
+ };
48
+ for (const modelVar of cap.modelVars)
49
+ envOverrides[modelVar] = modelId;
50
+ return withLaunchModel({ kind: 'env', envOverrides }, cap.launchModel, modelId);
51
+ }
52
+ case 'configContentEnv': {
53
+ const content = renderConfigContent(cap.template, endpoint, modelId, apiKey);
54
+ return withLaunchModel({ kind: 'env', envOverrides: { [cap.envVar]: content } }, cap.launchModel, modelId);
55
+ }
56
+ case 'configDir': {
57
+ const { content, extraEnv } = renderConfigFile(cap.template, endpoint, modelId, apiKey);
58
+ return withLaunchModel({ kind: 'configDir', dirEnvVar: cap.dirEnvVar, files: [{ relPath: cap.fileName, content }], extraEnv }, cap.launchModel, modelId);
59
+ }
60
+ case 'unsupported':
61
+ return { kind: 'unsupported' };
62
+ }
63
+ }
64
+ /** Render a `launchModel` template (`{modelId}` = the chosen id) onto an injection result. */
65
+ function withLaunchModel(result, template, modelId) {
66
+ if (!template)
67
+ return result;
68
+ return { ...result, launchModel: template.split('{modelId}').join(modelId) };
69
+ }
70
+ function renderConfigContent(template, endpoint, modelId, apiKey) {
71
+ switch (template) {
72
+ case 'opencode-json':
73
+ return JSON.stringify({
74
+ $schema: 'https://opencode.ai/config.json',
75
+ provider: {
76
+ custom: {
77
+ options: { baseURL: withV1Suffix(endpoint.baseUrl), apiKey },
78
+ models: { [modelId]: {} },
79
+ },
80
+ },
81
+ model: `custom/${modelId}`,
82
+ });
83
+ }
84
+ }
85
+ const CODEX_API_KEY_ENV_VAR = 'CODEMAN_CUSTOM_MODEL_API_KEY';
86
+ /** The `[model.<name>]` block name grok's config.toml uses for the injected model — also
87
+ * what `-m <name>` in the standalone script's ONE_SHOT argv must reference to select it. */
88
+ export const GROK_CUSTOM_MODEL_NAME = 'codeman-custom';
89
+ function renderConfigFile(template, endpoint, modelId, apiKey) {
90
+ const baseUrl = withV1Suffix(endpoint.baseUrl);
91
+ switch (template) {
92
+ case 'codex-toml': {
93
+ // Verified against real codex (>= Feb 2026): `model` is a top-level STRING, never
94
+ // a `[model].default` table — codex rejects that with "invalid type: map, expected
95
+ // a string" (caught by scripts/test-local-llm-harnesses.ts against a real llama-swap
96
+ // server). The API key is NEVER a literal TOML field: codex's schema only supports
97
+ // `env_key`, the NAME of an env var it reads the credential from at runtime, so the
98
+ // actual value must ride along as an extra env var, never embedded in the file.
99
+ // ⚠️ `wire_api = "responses"` is the only value codex still accepts (it dropped
100
+ // `"chat"` support in Feb 2026) — a plain OpenAI Chat-Completions server (llama.cpp,
101
+ // llama-swap, most local setups) does NOT implement the Responses API, so this
102
+ // recipe may still fail at the PROTOCOL level even though the file now parses
103
+ // correctly. That is a real, currently-unresolved compatibility gap, not a syntax
104
+ // bug — track it before calling codex support done.
105
+ const content = [
106
+ `model = ${quoted(modelId)}`,
107
+ `model_provider = "custom"`,
108
+ '',
109
+ '[model_providers.custom]',
110
+ `name = "Custom Endpoint"`,
111
+ `base_url = ${quoted(baseUrl)}`,
112
+ `env_key = ${quoted(CODEX_API_KEY_ENV_VAR)}`,
113
+ `wire_api = "responses"`,
114
+ '',
115
+ ].join('\n');
116
+ return { content, extraEnv: { [CODEX_API_KEY_ENV_VAR]: apiKey } };
117
+ }
118
+ case 'pi-models-json':
119
+ // Verified against pi's OWN bundled docs (models.md): `models` is an ARRAY of
120
+ // `{id: "..."}` objects, NOT an object keyed by model id — the earlier shape here
121
+ // silently loaded zero models ("No models available"), confirmed live. `authHeader:
122
+ // true` is required too: pi does not automatically send `Authorization: Bearer
123
+ // <apiKey>` just because `apiKey` is set (per the same doc) — without it, a real
124
+ // (non-llama.cpp) endpoint that actually checks the key would reject every request.
125
+ return {
126
+ content: JSON.stringify({
127
+ providers: {
128
+ custom: {
129
+ baseUrl,
130
+ apiKey,
131
+ api: 'openai-completions',
132
+ authHeader: true,
133
+ models: [{ id: modelId }],
134
+ },
135
+ },
136
+ }, null, 2),
137
+ };
138
+ case 'omp-models-yml':
139
+ // Mirrors the pi-models-json fix above (omp shares pi's config lineage per
140
+ // CLAUDE.md — it reads several of pi's own env vars): a flat list of bare model
141
+ // name strings under `models` is UNCONFIRMED against real omp docs (none are
142
+ // bundled with the binary) — this now matches pi's `{id: "..."}` object-list
143
+ // shape and adds `authHeader: true` on the same reasoning, but has not itself
144
+ // been live-tested the way pi's fix was. Verify before raising its confidence.
145
+ return {
146
+ content: `providers:\n custom:\n baseUrl: ${quoted(baseUrl)}\n apiKey: ${quoted(apiKey)}\n api: openai-completions\n authHeader: true\n models:\n - id: ${quoted(modelId)}\n`,
147
+ };
148
+ case 'grok-toml': {
149
+ // Verified against xAI's own docs (docs.x.ai/build/settings/reference): a
150
+ // `[model.<name>]` block, NOT plain env vars — an earlier `env`-kind recipe for
151
+ // grok was wrong, not just unverified (see the customModelInjection doc comment
152
+ // in cli-registry/types.ts). `api_backend = "chat_completions"` is explicitly
153
+ // supported (unlike codex, which dropped it after Feb 2026), so this one CAN
154
+ // talk to a plain OpenAI-compatible server directly. `env_key` reuses grok's own
155
+ // documented fallback var name (XAI_API_KEY) rather than inventing a new one.
156
+ const content = [
157
+ `[model.${GROK_CUSTOM_MODEL_NAME}]`,
158
+ `model = ${quoted(modelId)}`,
159
+ `base_url = ${quoted(baseUrl)}`,
160
+ `name = "Custom Endpoint"`,
161
+ `env_key = "XAI_API_KEY"`,
162
+ `api_backend = "chat_completions"`,
163
+ '',
164
+ ].join('\n');
165
+ return { content, extraEnv: { XAI_API_KEY: apiKey } };
166
+ }
167
+ }
168
+ }
169
+ //# sourceMappingURL=custom-model-injection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-model-injection.js","sourceRoot":"","sources":["../src/custom-model-injection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAiDH,MAAM,eAAe,GAAG,iBAAiB,CAAC;AAE1C,yHAAyH;AACzH,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC5C,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,KAAK,CAAC;AAC3D,CAAC;AAED,iIAAiI;AACjI,SAAS,MAAM,CAAC,KAAa;IAC3B,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AAED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AiB,MAAM,CAAC,MAAM,CAAC,iFAAiF,MAAM,CAAC,OAAO,CAAC,IAAI;aACnM,CAAC;QACJ,KAAK,WAAW,CAAC,CAAC,CAAC;YACjB,0EAA0E;YAC1E,gFAAgF;YAChF,gFAAgF;YAChF,8EAA8E;YAC9E,6EAA6E;YAC7E,iFAAiF;YACjF,8EAA8E;YAC9E,MAAM,OAAO,GAAG;gBACd,UAAU,sBAAsB,GAAG;gBACnC,WAAW,MAAM,CAAC,OAAO,CAAC,EAAE;gBAC5B,cAAc,MAAM,CAAC,OAAO,CAAC,EAAE;gBAC/B,0BAA0B;gBAC1B,yBAAyB;gBACzB,kCAAkC;gBAClC,EAAE;aACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACb,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,CAAC;QACxD,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -100,6 +100,48 @@ export declare function dockerConfigHash(docker: Pick<SessionDocker, 'engine' |
100
100
  * computed last over the resolved values.
101
101
  */
102
102
  export declare function toSessionDocker(host: DockerHost, dockerCase: DockerCase): SessionDocker;
103
+ /**
104
+ * Which existing case, if any, blocks adopting `container` at `containerWorkdir`.
105
+ *
106
+ * One container may back SEVERAL adopted cases, each pointing at a different
107
+ * directory inside it — that is the whole reason to adopt the same container
108
+ * twice, and it is safe because the in-container tmux session is named per
109
+ * SESSION (`dockerTmuxSessionName`, `codeman-dkr-<id8>`) and not per case, so a
110
+ * session teardown kills exactly one session and its siblings on the shared
111
+ * in-container tmux server are untouched. Nothing else reaches an adopted
112
+ * container's lifecycle either: stop/remove throw at the builder, recreate
113
+ * refuses `owned === false`, and the orphan reaper filters on the
114
+ * `codeman.managed=1` label that only Codeman-created containers carry.
115
+ *
116
+ * So the conflicts that remain are NOT about the tmux server:
117
+ * - `owned-case` the container backs a case Codeman CREATED, whose lifecycle
118
+ * it owns; a recreate or delete there would destroy the
119
+ * adopted case's container out from under it.
120
+ * - `other-owner` already adopted by a different user. Adoption hands out a
121
+ * shell inside someone else's container, so it stays scoped.
122
+ * - `duplicate` same container AND same directory: the second case would
123
+ * behave identically to the first, so name the first instead
124
+ * of silently creating a twin. A DIFFERENT directory is the
125
+ * supported case and returns null.
126
+ */
127
+ export type AdoptContainerConflict = {
128
+ kind: 'owned-case';
129
+ caseName: string;
130
+ } | {
131
+ kind: 'other-owner';
132
+ caseName: string;
133
+ } | {
134
+ kind: 'duplicate';
135
+ caseName: string;
136
+ } | null;
137
+ export declare function classifyAdoptContainerConflict(params: {
138
+ container: string;
139
+ /** Directory inside the container this adoption targets (already defaulted). */
140
+ containerWorkdir: string;
141
+ existing: ReadonlyArray<Pick<DockerCase, 'name' | 'container' | 'containerWorkdir' | 'hostWorkspacePath' | 'owned' | 'owner'>>;
142
+ /** Owner visibility test (canAccessOwned bound to the caller). */
143
+ canAccess: (owner?: string) => boolean;
144
+ }): AdoptContainerConflict;
103
145
  /**
104
146
  * An ADOPTED container is one the user built and runs themselves. Codeman may
105
147
  * only exec into it; it must never create, start, stop, restart or remove it.
@@ -1 +1 @@
1
- {"version":3,"file":"docker-hosts.d.ts","sourceRoot":"","sources":["../src/docker-hosts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAaH,OAAO,KAAK,EACV,UAAU,EACV,YAAY,EACZ,UAAU,EAEV,oBAAoB,EACpB,aAAa,EACb,WAAW,EACZ,MAAM,YAAY,CAAC;AAUpB,oEAAoE;AACpE,eAAO,MAAM,mBAAmB,uBAAuB,CAAC;AAExD,8FAA8F;AAC9F,eAAO,MAAM,cAAc,gBAAgB,CAAC;AAE5C;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,IAAI,WAAW,EAAE,CAErD;AAmBD,6DAA6D;AAC7D,eAAO,MAAM,wBAAwB,EAAE,oBAKtC,CAAC;AAIF,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED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,CAAC,CAkDnB;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ,GAAG,eAAe,GAAG,SAAS,GAAG,YAAY,CAAC,EAClF,IAAI,EAAE,WAAW,GAChB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAuB7B"}
@@ -244,6 +244,24 @@ export function toSessionDocker(host, dockerCase) {
244
244
  session.owned = false;
245
245
  return session;
246
246
  }
247
+ export function classifyAdoptContainerConflict(params) {
248
+ const { container, containerWorkdir, existing, canAccess } = params;
249
+ const sharing = existing.filter((item) => (item.container ?? dockerContainerName(item.name)) === container);
250
+ if (sharing.length === 0)
251
+ return null;
252
+ // `owned` is optional and an ABSENT flag means owned (legacy cases predate the
253
+ // field), so this must test `!== false` rather than truthiness.
254
+ const owned = sharing.find((item) => item.owned !== false);
255
+ if (owned)
256
+ return { kind: 'owned-case', caseName: owned.name };
257
+ const foreign = sharing.find((item) => !canAccess(item.owner));
258
+ if (foreign)
259
+ return { kind: 'other-owner', caseName: foreign.name };
260
+ const twin = sharing.find((item) => (item.containerWorkdir ?? item.hostWorkspacePath) === containerWorkdir);
261
+ if (twin)
262
+ return { kind: 'duplicate', caseName: twin.name };
263
+ return null;
264
+ }
247
265
  /**
248
266
  * An ADOPTED container is one the user built and runs themselves. Codeman may
249
267
  * only exec into it; it must never create, start, stop, restart or remove it.