@mycadet/cli 0.13.0-dev.202611131045.a556a8a → 0.13.0-dev.202611140220.fac72d3
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/node_modules/@mycadet/assistant-api/node_modules/@mycadet/service-contracts/package.json +1 -1
- package/node_modules/@mycadet/avatar-manifest/package.json +1 -1
- package/node_modules/@mycadet/environments/package.json +1 -1
- package/node_modules/@mycadet/ipc-server-utils/package.json +1 -1
- package/node_modules/@mycadet/local-mode/node_modules/@mycadet/avatar-manifest/package.json +1 -1
- package/node_modules/@mycadet/local-mode/node_modules/@mycadet/environments/package.json +1 -1
- package/node_modules/@mycadet/local-mode/node_modules/@mycadet/ipc-server-utils/package.json +1 -1
- package/node_modules/@mycadet/local-mode/node_modules/@mycadet/service-contracts/package.json +1 -1
- package/node_modules/@mycadet/local-mode/node_modules/@mycadet/shared/package.json +1 -1
- package/node_modules/@mycadet/local-mode/package.json +1 -1
- package/node_modules/@mycadet/local-mode/src/__tests__/hatch-config.test.ts +110 -99
- package/node_modules/@mycadet/local-mode/src/__tests__/{hatch-local-overlay.test.ts → hatch-local-config-api.test.ts} +60 -50
- package/node_modules/@mycadet/local-mode/src/__tests__/local-exec-invocation.test.ts +15 -5
- package/node_modules/@mycadet/local-mode/src/__tests__/teleport-init.test.ts +1 -8
- package/node_modules/@mycadet/local-mode/src/index.ts +3 -9
- package/node_modules/@mycadet/local-mode/src/remotes/docker/hatch.ts +15 -48
- package/node_modules/@mycadet/local-mode/src/remotes/local/common.ts +82 -40
- package/node_modules/@mycadet/local-mode/src/remotes/local/exec.ts +8 -61
- package/node_modules/@mycadet/local-mode/src/remotes/local/hatch-config.ts +71 -44
- package/node_modules/@mycadet/local-mode/src/remotes/local/hatch.ts +15 -8
- package/node_modules/@mycadet/local-mode/src/remotes/local/teleport.ts +5 -13
- package/node_modules/@mycadet/local-mode/src/remotes/local/wake.ts +10 -38
- package/node_modules/@mycadet/service-contracts/package.json +1 -1
- package/node_modules/@mycadet/shared/package.json +1 -1
- package/package.json +1 -1
|
@@ -1,25 +1,12 @@
|
|
|
1
|
-
import { readFileSync, rmSync } from "fs";
|
|
2
1
|
import { describe, expect, test } from "bun:test";
|
|
3
2
|
|
|
4
3
|
import {
|
|
4
|
+
applyHatchConfig,
|
|
5
5
|
buildHatchConfigValues,
|
|
6
6
|
buildNestedConfig,
|
|
7
|
-
writeInitialConfig,
|
|
8
7
|
} from "../remotes/local/hatch-config";
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
configValues: Record<string, string>,
|
|
12
|
-
): Record<string, unknown> {
|
|
13
|
-
const path = writeInitialConfig(configValues);
|
|
14
|
-
expect(path).toBeDefined();
|
|
15
|
-
try {
|
|
16
|
-
return JSON.parse(readFileSync(path!, "utf-8")) as Record<string, unknown>;
|
|
17
|
-
} finally {
|
|
18
|
-
if (path !== undefined) rmSync(path, { force: true });
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
describe("config-utils", () => {
|
|
9
|
+
describe("hatch-config", () => {
|
|
23
10
|
test("buildNestedConfig only converts dot-notation values", () => {
|
|
24
11
|
expect(
|
|
25
12
|
buildNestedConfig({
|
|
@@ -36,51 +23,9 @@ describe("config-utils", () => {
|
|
|
36
23
|
});
|
|
37
24
|
});
|
|
38
25
|
|
|
39
|
-
test("
|
|
40
|
-
expect(buildHatchConfigValues({}, "anthropic")).toEqual({
|
|
41
|
-
"llm.default.provider": "anthropic",
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
test("buildHatchConfigValues preserves explicit provider config", () => {
|
|
46
|
-
expect(
|
|
47
|
-
buildHatchConfigValues(
|
|
48
|
-
{
|
|
49
|
-
"llm.default.provider": "openai",
|
|
50
|
-
"llm.default.model": "gpt-5.4",
|
|
51
|
-
},
|
|
52
|
-
"anthropic",
|
|
53
|
-
),
|
|
54
|
-
).toEqual({
|
|
55
|
-
"llm.default.provider": "openai",
|
|
56
|
-
"llm.default.model": "gpt-5.4",
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
test("buildHatchConfigValues skips internal hatches without provider setup", () => {
|
|
61
|
-
expect(buildHatchConfigValues({}, undefined)).toEqual({});
|
|
62
|
-
expect(buildHatchConfigValues({}, null)).toEqual({});
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
test("writeInitialConfig does not add a mainAgent callSite for Anthropic defaults", () => {
|
|
66
|
-
expect(
|
|
67
|
-
readInitialConfig({
|
|
68
|
-
"llm.default.provider": "anthropic",
|
|
69
|
-
"llm.default.model": "claude-opus-4-7",
|
|
70
|
-
}),
|
|
71
|
-
).toEqual({
|
|
72
|
-
llm: {
|
|
73
|
-
default: {
|
|
74
|
-
provider: "anthropic",
|
|
75
|
-
model: "claude-opus-4-7",
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
test("writeInitialConfig preserves profile-based Anthropic model selection", () => {
|
|
26
|
+
test("buildNestedConfig preserves nested fragments like profile overrides", () => {
|
|
82
27
|
expect(
|
|
83
|
-
|
|
28
|
+
buildNestedConfig({
|
|
84
29
|
"llm.activeProfile": "quality-optimized",
|
|
85
30
|
"llm.profiles.quality-optimized.provider": "anthropic",
|
|
86
31
|
"llm.profiles.quality-optimized.model": "claude-opus-4-7",
|
|
@@ -100,9 +45,9 @@ describe("config-utils", () => {
|
|
|
100
45
|
});
|
|
101
46
|
});
|
|
102
47
|
|
|
103
|
-
test("
|
|
48
|
+
test("buildNestedConfig does not invent a mainAgent callSite for Anthropic defaults", () => {
|
|
104
49
|
expect(
|
|
105
|
-
|
|
50
|
+
buildNestedConfig({
|
|
106
51
|
"llm.default.provider": "anthropic",
|
|
107
52
|
"llm.default.model": "claude-opus-4-7",
|
|
108
53
|
"llm.callSites.mainAgent.model": "claude-haiku-4-5-20251001",
|
|
@@ -122,55 +67,121 @@ describe("config-utils", () => {
|
|
|
122
67
|
});
|
|
123
68
|
});
|
|
124
69
|
|
|
125
|
-
test("
|
|
126
|
-
expect(
|
|
127
|
-
|
|
128
|
-
"llm.default.provider": "anthropic",
|
|
129
|
-
"llm.default.model": "claude-haiku-4-5-20251001",
|
|
130
|
-
}),
|
|
131
|
-
).toEqual({
|
|
132
|
-
llm: {
|
|
133
|
-
default: {
|
|
134
|
-
provider: "anthropic",
|
|
135
|
-
model: "claude-haiku-4-5-20251001",
|
|
136
|
-
},
|
|
137
|
-
},
|
|
70
|
+
test("buildHatchConfigValues adds the default hatch provider when no config exists", () => {
|
|
71
|
+
expect(buildHatchConfigValues({}, "anthropic")).toEqual({
|
|
72
|
+
"llm.default.provider": "anthropic",
|
|
138
73
|
});
|
|
139
74
|
});
|
|
140
75
|
|
|
141
|
-
test("
|
|
76
|
+
test("buildHatchConfigValues preserves explicit provider config", () => {
|
|
142
77
|
expect(
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}),
|
|
148
|
-
).toEqual({
|
|
149
|
-
llm: {
|
|
150
|
-
activeProfile: "fast",
|
|
151
|
-
profiles: {
|
|
152
|
-
fast: {
|
|
153
|
-
provider: "openai",
|
|
154
|
-
model: "gpt-5.5",
|
|
155
|
-
},
|
|
78
|
+
buildHatchConfigValues(
|
|
79
|
+
{
|
|
80
|
+
"llm.default.provider": "openai",
|
|
81
|
+
"llm.default.model": "gpt-5.4",
|
|
156
82
|
},
|
|
83
|
+
"anthropic",
|
|
84
|
+
),
|
|
85
|
+
).toEqual({
|
|
86
|
+
"llm.default.provider": "openai",
|
|
87
|
+
"llm.default.model": "gpt-5.4",
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test("buildHatchConfigValues skips internal hatches without provider setup", () => {
|
|
92
|
+
expect(buildHatchConfigValues({}, undefined)).toEqual({});
|
|
93
|
+
expect(buildHatchConfigValues({}, null)).toEqual({});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test("applyHatchConfig sets each dotted path through the config API", async () => {
|
|
97
|
+
const calls: { url: string; body: unknown; auth?: string }[] = [];
|
|
98
|
+
const response = new Response(JSON.stringify({ ok: true }), {
|
|
99
|
+
status: 200,
|
|
100
|
+
});
|
|
101
|
+
await applyHatchConfig({
|
|
102
|
+
gatewayUrl: "http://localhost:4444/",
|
|
103
|
+
bearerToken: "test-token",
|
|
104
|
+
configValues: {
|
|
105
|
+
"llm.default.model": "claude-opus-4-7",
|
|
106
|
+
"llm.default.provider": "anthropic",
|
|
157
107
|
},
|
|
108
|
+
fetchImpl: (async (url, init) => {
|
|
109
|
+
calls.push({
|
|
110
|
+
url: String(url),
|
|
111
|
+
body: JSON.parse(String(init?.body)),
|
|
112
|
+
auth: new Headers(init?.headers).get("Authorization") ?? undefined,
|
|
113
|
+
});
|
|
114
|
+
return response;
|
|
115
|
+
}) as typeof fetch,
|
|
158
116
|
});
|
|
117
|
+
|
|
118
|
+
expect(calls.map((c) => c.url)).toEqual([
|
|
119
|
+
"http://localhost:4444/v1/config/set",
|
|
120
|
+
"http://localhost:4444/v1/config/set",
|
|
121
|
+
]);
|
|
122
|
+
expect(calls.map((c) => c.body)).toEqual([
|
|
123
|
+
{ path: "llm.default.model", value: "claude-opus-4-7" },
|
|
124
|
+
{ path: "llm.default.provider", value: "anthropic" },
|
|
125
|
+
]);
|
|
126
|
+
for (const call of calls) {
|
|
127
|
+
expect(call.auth).toBe("Bearer test-token");
|
|
128
|
+
}
|
|
159
129
|
});
|
|
160
130
|
|
|
161
|
-
test("
|
|
162
|
-
|
|
163
|
-
|
|
131
|
+
test("applyHatchConfig is a no-op without values", async () => {
|
|
132
|
+
let fetched = false;
|
|
133
|
+
await applyHatchConfig({
|
|
134
|
+
gatewayUrl: "http://localhost:4444",
|
|
135
|
+
bearerToken: "test-token",
|
|
136
|
+
configValues: {},
|
|
137
|
+
fetchImpl: (async (..._args: unknown[]) => {
|
|
138
|
+
fetched = true;
|
|
139
|
+
return new Response("{}", { status: 200 });
|
|
140
|
+
}) as typeof fetch,
|
|
141
|
+
});
|
|
142
|
+
expect(fetched).toBe(false);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
test("applyHatchConfig skips with a warning when no token was leased", async () => {
|
|
146
|
+
const warnings: string[] = [];
|
|
147
|
+
let fetched = false;
|
|
148
|
+
await applyHatchConfig({
|
|
149
|
+
gatewayUrl: "http://localhost:4444",
|
|
150
|
+
configValues: { "llm.default.provider": "anthropic" },
|
|
151
|
+
fetchImpl: (async (..._args: unknown[]) => {
|
|
152
|
+
fetched = true;
|
|
153
|
+
return new Response("{}", { status: 200 });
|
|
154
|
+
}) as typeof fetch,
|
|
155
|
+
log: (m) => warnings.push(m),
|
|
156
|
+
});
|
|
157
|
+
expect(fetched).toBe(false);
|
|
158
|
+
expect(warnings.join("\n")).toContain("assistant config set");
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
test("applyHatchConfig keeps applying the remaining keys when one fails", async () => {
|
|
162
|
+
const paths: string[] = [];
|
|
163
|
+
const warnings: string[] = [];
|
|
164
|
+
await applyHatchConfig({
|
|
165
|
+
gatewayUrl: "http://localhost:4444",
|
|
166
|
+
bearerToken: "test-token",
|
|
167
|
+
configValues: {
|
|
168
|
+
"llm.default.model": "gpt-5.4",
|
|
164
169
|
"llm.default.provider": "openai",
|
|
165
|
-
"llm.default.model": "gpt-5.5",
|
|
166
|
-
}),
|
|
167
|
-
).toEqual({
|
|
168
|
-
llm: {
|
|
169
|
-
default: {
|
|
170
|
-
provider: "openai",
|
|
171
|
-
model: "gpt-5.5",
|
|
172
|
-
},
|
|
173
170
|
},
|
|
171
|
+
fetchImpl: (async (...args: Parameters<typeof fetch>) => {
|
|
172
|
+
const body = JSON.parse(String(args[1]?.body)) as { path: string };
|
|
173
|
+
paths.push(body.path);
|
|
174
|
+
if (body.path === "llm.default.model") {
|
|
175
|
+
return new Response("boom", { status: 500 });
|
|
176
|
+
}
|
|
177
|
+
return new Response("{}", { status: 200 });
|
|
178
|
+
}) as typeof fetch,
|
|
179
|
+
log: (m) => warnings.push(m),
|
|
174
180
|
});
|
|
181
|
+
|
|
182
|
+
// Both keys attempted; the failure warns and names a re-apply path.
|
|
183
|
+
expect(paths).toEqual(["llm.default.model", "llm.default.provider"]);
|
|
184
|
+
expect(warnings.join("\n")).toContain("llm.default.model");
|
|
185
|
+
expect(warnings.join("\n")).toContain("assistant config set");
|
|
175
186
|
});
|
|
176
187
|
});
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Pins the local hatch leg's
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
2
|
+
* Pins the local hatch leg's config handoff: the provider the caller picked
|
|
3
|
+
* reaches the assistant's public config API (`POST /v1/config/set`) after
|
|
4
|
+
* wake — the same route the docker leg, the web client, and
|
|
5
|
+
* `assistant config set` use. When this leg skipped the pick the daemon
|
|
6
|
+
* booted on the schema's anthropic fallback and every send died 422 for a
|
|
7
|
+
* connection the user never picked ("anthropic-personal has no API key
|
|
8
|
+
* stored") while the fireworks key they did store sat unused.
|
|
8
9
|
*/
|
|
9
10
|
|
|
10
11
|
import {
|
|
@@ -16,29 +17,39 @@ import {
|
|
|
16
17
|
test,
|
|
17
18
|
mock,
|
|
18
19
|
} from "bun:test";
|
|
19
|
-
import { mkdtempSync,
|
|
20
|
+
import { mkdtempSync, rmSync } from "node:fs";
|
|
20
21
|
import os from "node:os";
|
|
21
22
|
import path from "node:path";
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
interface CapturedApply {
|
|
25
|
+
gatewayUrl: string;
|
|
26
|
+
bearerToken?: string;
|
|
27
|
+
configValues: Record<string, string>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
let capturedApply: CapturedApply | undefined;
|
|
24
31
|
|
|
25
32
|
// Spread the actual module under the override — mocking without the spread
|
|
26
33
|
// replaces the whole module record for every file that runs later in the
|
|
27
34
|
// same bun test process.
|
|
28
35
|
const actualLocalWake = await import("../remotes/local/wake");
|
|
29
|
-
const wakeMock = mock
|
|
30
|
-
(
|
|
31
|
-
ok: true
|
|
32
|
-
|
|
33
|
-
>(async (_entry, opts) => {
|
|
34
|
-
capturedOverlayPath = opts?.defaultWorkspaceConfigPath;
|
|
35
|
-
return { ok: true };
|
|
36
|
-
});
|
|
36
|
+
const wakeMock = mock(
|
|
37
|
+
async (_entry: unknown, _opts?: { watch?: boolean }) =>
|
|
38
|
+
({ ok: true }) as never,
|
|
39
|
+
);
|
|
37
40
|
mock.module("../remotes/local/wake", () => ({
|
|
38
41
|
...actualLocalWake,
|
|
39
42
|
wakeLocal: wakeMock,
|
|
40
43
|
}));
|
|
41
44
|
|
|
45
|
+
const actualHatchConfig = await import("../remotes/local/hatch-config");
|
|
46
|
+
mock.module("../remotes/local/hatch-config", () => ({
|
|
47
|
+
...actualHatchConfig,
|
|
48
|
+
applyHatchConfig: async (options: CapturedApply) => {
|
|
49
|
+
capturedApply = options;
|
|
50
|
+
},
|
|
51
|
+
}));
|
|
52
|
+
|
|
42
53
|
// Spread the actual modules under the overrides — other modules in the
|
|
43
54
|
// import graph need the exports this test doesn't touch.
|
|
44
55
|
const actualGuardianToken = await import("../guardian-token");
|
|
@@ -46,7 +57,7 @@ mock.module("../guardian-token", () => ({
|
|
|
46
57
|
...actualGuardianToken,
|
|
47
58
|
// A valid-shaped token: the lease succeeding keeps the leg's post-hatch
|
|
48
59
|
// steps instant (a failing lease retries with sleeps), and this test is
|
|
49
|
-
// about the
|
|
60
|
+
// about the config handoff, not the lease.
|
|
50
61
|
leaseGuardianToken: async () => ({
|
|
51
62
|
guardianPrincipalId: "principal-test",
|
|
52
63
|
accessToken: "test-token",
|
|
@@ -60,13 +71,13 @@ mock.module("../guardian-token", () => ({
|
|
|
60
71
|
}));
|
|
61
72
|
|
|
62
73
|
const actualProviderCredentials = await import("../provider-credentials");
|
|
63
|
-
mock.module("
|
|
74
|
+
mock.module("../provider-credentials", () => ({
|
|
64
75
|
...actualProviderCredentials,
|
|
65
76
|
configureHatchProviderApiKey: async () => {},
|
|
66
77
|
}));
|
|
67
78
|
|
|
68
79
|
const actualCloudAuth = await import("../cloud-auth");
|
|
69
|
-
mock.module("
|
|
80
|
+
mock.module("../cloud-auth", () => ({
|
|
70
81
|
...actualCloudAuth,
|
|
71
82
|
readCloudToken: () => null,
|
|
72
83
|
}));
|
|
@@ -75,9 +86,10 @@ const { hatchLocal } = await import("../remotes/local/hatch");
|
|
|
75
86
|
|
|
76
87
|
afterAll(() => {
|
|
77
88
|
mock.module("../remotes/local/wake", () => actualLocalWake);
|
|
89
|
+
mock.module("../remotes/local/hatch-config", () => actualHatchConfig);
|
|
78
90
|
mock.module("../guardian-token", () => actualGuardianToken);
|
|
79
|
-
mock.module("
|
|
80
|
-
mock.module("
|
|
91
|
+
mock.module("../provider-credentials", () => actualProviderCredentials);
|
|
92
|
+
mock.module("../cloud-auth", () => actualCloudAuth);
|
|
81
93
|
});
|
|
82
94
|
|
|
83
95
|
let home: string;
|
|
@@ -85,7 +97,7 @@ const ENV_KEYS = ["XDG_CONFIG_HOME", "XDG_DATA_HOME"] as const;
|
|
|
85
97
|
const saved = new Map<string, string | undefined>();
|
|
86
98
|
|
|
87
99
|
beforeEach(() => {
|
|
88
|
-
home = mkdtempSync(path.join(os.tmpdir(), "hatch-local-
|
|
100
|
+
home = mkdtempSync(path.join(os.tmpdir(), "hatch-local-config-api-"));
|
|
89
101
|
for (const key of ENV_KEYS) {
|
|
90
102
|
saved.set(key, process.env[key]);
|
|
91
103
|
process.env[key] = path.join(home, key.toLowerCase());
|
|
@@ -100,45 +112,43 @@ afterEach(() => {
|
|
|
100
112
|
rmSync(home, { recursive: true, force: true });
|
|
101
113
|
});
|
|
102
114
|
|
|
103
|
-
describe("hatchLocal's
|
|
104
|
-
test("the picked provider rides the
|
|
115
|
+
describe("hatchLocal's config API handoff", () => {
|
|
116
|
+
test("the picked provider rides the config API as llm.default.provider", async () => {
|
|
105
117
|
const result = await hatchLocal({
|
|
106
|
-
name: "
|
|
118
|
+
name: "config-api-probe",
|
|
107
119
|
provider: "fireworks",
|
|
108
|
-
reporter: {
|
|
120
|
+
reporter: {
|
|
121
|
+
progress: () => {},
|
|
122
|
+
log: () => {},
|
|
123
|
+
warn: () => {},
|
|
124
|
+
error: () => {},
|
|
125
|
+
},
|
|
109
126
|
});
|
|
110
127
|
expect(result.ok).toBe(true);
|
|
111
|
-
expect(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
llm: { default: { provider: "fireworks" } },
|
|
118
|
-
});
|
|
119
|
-
} finally {
|
|
120
|
-
if (capturedOverlayPath) rmSync(capturedOverlayPath, { force: true });
|
|
121
|
-
}
|
|
128
|
+
expect(capturedApply).toBeDefined();
|
|
129
|
+
expect(capturedApply?.bearerToken).toBe("test-token");
|
|
130
|
+
expect(capturedApply?.gatewayUrl).toMatch(/^http:\/\/127\.0\.0\.1:\d+$/);
|
|
131
|
+
expect(capturedApply?.configValues).toMatchObject({
|
|
132
|
+
"llm.default.provider": "fireworks",
|
|
133
|
+
});
|
|
122
134
|
});
|
|
123
135
|
|
|
124
136
|
test("explicit config wins over the pick", async () => {
|
|
125
137
|
const result = await hatchLocal({
|
|
126
|
-
name: "
|
|
138
|
+
name: "config-api-probe-2",
|
|
127
139
|
provider: "fireworks",
|
|
128
140
|
configValues: { "llm.default.provider": "openai" },
|
|
129
|
-
reporter: {
|
|
141
|
+
reporter: {
|
|
142
|
+
progress: () => {},
|
|
143
|
+
log: () => {},
|
|
144
|
+
warn: () => {},
|
|
145
|
+
error: () => {},
|
|
146
|
+
},
|
|
130
147
|
});
|
|
131
148
|
expect(result.ok).toBe(true);
|
|
132
|
-
expect(
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
) as Record<string, unknown>;
|
|
137
|
-
expect(overlay).toMatchObject({
|
|
138
|
-
llm: { default: { provider: "openai" } },
|
|
139
|
-
});
|
|
140
|
-
} finally {
|
|
141
|
-
if (capturedOverlayPath) rmSync(capturedOverlayPath, { force: true });
|
|
142
|
-
}
|
|
149
|
+
expect(capturedApply).toBeDefined();
|
|
150
|
+
expect(capturedApply?.configValues).toMatchObject({
|
|
151
|
+
"llm.default.provider": "openai",
|
|
152
|
+
});
|
|
143
153
|
});
|
|
144
154
|
});
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
chmodSync,
|
|
3
|
+
mkdirSync,
|
|
4
|
+
readFileSync,
|
|
5
|
+
rmSync,
|
|
6
|
+
statSync,
|
|
7
|
+
writeFileSync,
|
|
8
|
+
} from "node:fs";
|
|
2
9
|
import { tmpdir } from "node:os";
|
|
3
10
|
import { join } from "node:path";
|
|
4
11
|
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
|
|
5
|
-
import { ensureLocalBinShims } from "../remotes/local/
|
|
12
|
+
import { ensureLocalBinShims } from "../remotes/local/common";
|
|
6
13
|
|
|
7
14
|
// The bin/ folder is the contract: exec prepends it to the child's PATH, so
|
|
8
15
|
// EVERY invocation shape — argv, compound commands, pipes, shell scripts —
|
|
@@ -90,9 +97,12 @@ describe("ensureLocalBinShims", () => {
|
|
|
90
97
|
"src",
|
|
91
98
|
"index.ts",
|
|
92
99
|
);
|
|
93
|
-
mkdirSync(
|
|
94
|
-
|
|
95
|
-
|
|
100
|
+
mkdirSync(
|
|
101
|
+
join(runtimeDir, "node_modules", "@mycadet", "assistant", "src"),
|
|
102
|
+
{
|
|
103
|
+
recursive: true,
|
|
104
|
+
},
|
|
105
|
+
);
|
|
96
106
|
writeFileSync(fakeIndex, "export {};\n");
|
|
97
107
|
chmodSync(fakeIndex, 0o644);
|
|
98
108
|
ensureLocalBinShims(entry());
|
|
@@ -6,7 +6,6 @@ import * as lockfile from "../lockfile";
|
|
|
6
6
|
import * as lookup from "../operations/lookup";
|
|
7
7
|
import * as hatchLock from "../remotes/local/hatch-lock";
|
|
8
8
|
import * as localHatch from "../remotes/local/hatch";
|
|
9
|
-
import * as hatchConfig from "../remotes/local/hatch-config";
|
|
10
9
|
import { initializeDockerTeleportTarget } from "../remotes/docker/teleport";
|
|
11
10
|
import { initializeLocalTeleportTarget } from "../remotes/local/teleport";
|
|
12
11
|
|
|
@@ -86,7 +85,7 @@ test("a fresh docker target initializes the volumes without creating containers"
|
|
|
86
85
|
).toBe(true);
|
|
87
86
|
});
|
|
88
87
|
|
|
89
|
-
test("a fresh local target
|
|
88
|
+
test("a fresh local target installs the archive, then persists", async () => {
|
|
90
89
|
const withLock = spyOn(hatchLock, "withLocalHatchLock").mockImplementation(
|
|
91
90
|
async (action) => action(),
|
|
92
91
|
);
|
|
@@ -99,10 +98,6 @@ test("a fresh local target writes config, installs the archive, then persists",
|
|
|
99
98
|
daemonPort: 7831,
|
|
100
99
|
cesPort: 7832,
|
|
101
100
|
} as never);
|
|
102
|
-
const writeConfig = spyOn(
|
|
103
|
-
hatchConfig,
|
|
104
|
-
"writeInitialConfig",
|
|
105
|
-
).mockImplementation(() => "/config-path");
|
|
106
101
|
let saved: { assistantId: string; hatchedAt?: string } | undefined;
|
|
107
102
|
const findEntry = spyOn(lookup, "findAssistantByName").mockImplementation(
|
|
108
103
|
() => (saved ?? null) as never,
|
|
@@ -126,7 +121,6 @@ test("a fresh local target writes config, installs the archive, then persists",
|
|
|
126
121
|
expect(result.assistantId).toBe("fresh-local");
|
|
127
122
|
expect(result.hatchedAt).toBeDefined();
|
|
128
123
|
expect(withLock).toHaveBeenCalledTimes(1);
|
|
129
|
-
expect(writeConfig).toHaveBeenCalledTimes(1);
|
|
130
124
|
expect(localArchive).toHaveBeenCalledWith(
|
|
131
125
|
expect.objectContaining({ assistantId: "fresh-local" }),
|
|
132
126
|
"/backups/source-pre-teleport.tar.gz",
|
|
@@ -140,7 +134,6 @@ test("a fresh local target writes config, installs the archive, then persists",
|
|
|
140
134
|
for (const spy of [
|
|
141
135
|
withLock,
|
|
142
136
|
placement,
|
|
143
|
-
writeConfig,
|
|
144
137
|
findEntry,
|
|
145
138
|
localArchive,
|
|
146
139
|
localSave,
|
|
@@ -23,11 +23,8 @@ export {
|
|
|
23
23
|
export { stageBasetenBuildContext } from "./remotes/baseten/context";
|
|
24
24
|
export { execBasetenSandbox } from "./remotes/baseten/exec";
|
|
25
25
|
export { localExecDirForService } from "./remotes/local/exec";
|
|
26
|
-
export { ensureLocalBinShims } from "./remotes/local/
|
|
27
|
-
export {
|
|
28
|
-
DEFAULT_EXEC_TIMEOUT,
|
|
29
|
-
execCommand,
|
|
30
|
-
} from "./operations/exec";
|
|
26
|
+
export { ensureLocalBinShims } from "./remotes/local/common";
|
|
27
|
+
export { DEFAULT_EXEC_TIMEOUT, execCommand } from "./operations/exec";
|
|
31
28
|
export {
|
|
32
29
|
appleContainerPair,
|
|
33
30
|
execAppleContainer,
|
|
@@ -51,10 +48,7 @@ export type {
|
|
|
51
48
|
ResolvedManagedAssistant,
|
|
52
49
|
} from "./remotes/cloud/exec";
|
|
53
50
|
export { RemoteExecTimeoutError } from "./remotes/cloud/exec";
|
|
54
|
-
export type {
|
|
55
|
-
ExecCommandOptions,
|
|
56
|
-
ExecCommandResult,
|
|
57
|
-
} from "./operations/exec";
|
|
51
|
+
export type { ExecCommandOptions, ExecCommandResult } from "./operations/exec";
|
|
58
52
|
export { createBackup, formatSize } from "./backup-ops";
|
|
59
53
|
|
|
60
54
|
export { type ManagedProcessEntry } from "./daemon-readiness";
|