amalgm 0.1.60 → 0.1.62

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.
@@ -133,7 +133,8 @@ function listPsProcesses() {
133
133
  }
134
134
 
135
135
  function listProcesses() {
136
- const processes = listProcProcesses() || listPsProcesses();
136
+ const psProcesses = listPsProcesses();
137
+ const processes = psProcesses.length > 0 ? psProcesses : (listProcProcesses() || []);
137
138
  const commandByPid = new Map(processes.map((item) => [item.pid, item.command]));
138
139
  return processes.map((item) => ({
139
140
  ...item,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amalgm",
3
- "version": "0.1.60",
3
+ "version": "0.1.62",
4
4
  "description": "Amalgm local computer runtime: login, MCP, chat, events, previews, and tunnels.",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,
@@ -338,12 +338,16 @@ function buildCodexConfig(contract, existingConfig, syncInfo) {
338
338
  ].filter(Boolean).join('\n\n') + '\n';
339
339
  }
340
340
 
341
+ function baseNativeConfigForContract(contract, syncInfo) {
342
+ return readTextFile(syncInfo?.sourceConfigPath);
343
+ }
344
+
341
345
  function writeConfig(contract) {
342
346
  const home = contract.auth.runtimeHome;
343
347
  if (!home) return;
344
348
  fs.mkdirSync(home, { recursive: true });
345
349
  const syncInfo = syncCodexNativeConfig(home);
346
- const nativeHookTrust = hookTrustToml(readTextFile(syncInfo?.sourceConfigPath));
350
+ const nativeConfig = baseNativeConfigForContract(contract, syncInfo);
347
351
  const configPath = path.join(home, 'config.toml');
348
352
  if (contract.authMethod === 'provider_auth') {
349
353
  const sourceAuth = path.join(syncInfo?.sourceDir || path.join(os.homedir(), '.codex'), 'auth.json');
@@ -352,10 +356,10 @@ function writeConfig(contract) {
352
356
  fs.copyFileSync(sourceAuth, targetAuth);
353
357
  fs.chmodSync(targetAuth, 0o600);
354
358
  }
355
- fs.writeFileSync(configPath, buildCodexConfig(contract, nativeHookTrust, syncInfo), { mode: 0o600 });
359
+ fs.writeFileSync(configPath, buildCodexConfig(contract, nativeConfig, syncInfo), { mode: 0o600 });
356
360
  return;
357
361
  }
358
- fs.writeFileSync(configPath, buildCodexConfig(contract, nativeHookTrust, syncInfo), { mode: 0o600 });
362
+ fs.writeFileSync(configPath, buildCodexConfig(contract, nativeConfig, syncInfo), { mode: 0o600 });
359
363
  fs.writeFileSync(path.join(home, 'auth.json'), JSON.stringify({
360
364
  auth_mode: 'apikey',
361
365
  OPENAI_API_KEY: contract.auth.tokenRef,
@@ -37,6 +37,8 @@ test('codex native sync copies hook support without bulk runtime state', () => {
37
37
  fs.mkdirSync(path.join(source, 'worktrees'), { recursive: true });
38
38
  fs.mkdirSync(path.join(source, 'plugins'), { recursive: true });
39
39
  fs.mkdirSync(path.join(source, 'supermemory'), { recursive: true });
40
+ fs.writeFileSync(path.join(source, 'config.toml'), 'model = "gpt-5.5"');
41
+ fs.writeFileSync(path.join(source, 'preferences.json'), '{"theme":"dark"}');
40
42
  fs.writeFileSync(path.join(source, 'hooks.json'), '{"hooks":{}}');
41
43
  fs.writeFileSync(path.join(source, 'supermemory.json'), '{"projectContainerTag":"test"}');
42
44
  fs.writeFileSync(path.join(source, 'supermemory', 'recall.js'), 'console.log("recall")');
@@ -51,6 +53,8 @@ test('codex native sync copies hook support without bulk runtime state', () => {
51
53
  const result = syncCodexNativeConfig(runtimeHome);
52
54
 
53
55
  assert.equal(result.sourceDir, source);
56
+ assert.equal(fs.existsSync(path.join(runtimeHome, 'config.toml')), true);
57
+ assert.equal(fs.existsSync(path.join(runtimeHome, 'preferences.json')), true);
54
58
  assert.equal(fs.existsSync(path.join(runtimeHome, 'hooks.json')), true);
55
59
  assert.equal(fs.existsSync(path.join(runtimeHome, 'supermemory.json')), true);
56
60
  assert.equal(fs.existsSync(path.join(runtimeHome, 'supermemory', 'recall.js')), true);
@@ -61,7 +65,7 @@ test('codex native sync copies hook support without bulk runtime state', () => {
61
65
  });
62
66
  });
63
67
 
64
- test('codex provider config keeps hooks but drops native model and mcp config', () => {
68
+ test('codex provider config keeps native mcp config and overrides managed model provider', () => {
65
69
  withNativeHome((home) => {
66
70
  const source = path.join(home, '.codex');
67
71
  fs.mkdirSync(source, { recursive: true });
@@ -72,7 +76,10 @@ test('codex provider config keeps hooks but drops native model and mcp config',
72
76
  'model_provider = "native-provider"',
73
77
  '',
74
78
  '[mcp_servers.native]',
75
- 'command = "native-mcp"',
79
+ 'url = "https://example.com/mcp"',
80
+ '',
81
+ '[mcp_servers.native.http_headers]',
82
+ 'Authorization = "Bearer test"',
76
83
  '',
77
84
  `[hooks.state.${JSON.stringify(`${hooksPath}:UserPromptSubmit:0`)}]`,
78
85
  'trusted = true',
@@ -90,7 +97,47 @@ test('codex provider config keeps hooks but drops native model and mcp config',
90
97
  assert.match(config, /model_provider = "openai"/);
91
98
  assert.match(config, /codex_hooks = true/);
92
99
  assert.doesNotMatch(config, /native-provider/);
93
- assert.doesNotMatch(config, /mcp_servers\.native/);
100
+ assert.match(config, /\[mcp_servers\.native\]/);
101
+ assert.match(config, /\[mcp_servers\.native\.http_headers\]/);
102
+ assert.match(config, /Authorization = "Bearer test"/);
103
+ assert.equal(config.includes(path.join(runtimeHome, 'hooks.json')), true);
104
+ });
105
+ });
106
+
107
+ test('codex amalgm config keeps native mcp config and overrides managed model provider', () => {
108
+ withNativeHome((home) => {
109
+ const source = path.join(home, '.codex');
110
+ fs.mkdirSync(source, { recursive: true });
111
+ const hooksPath = path.join(source, 'hooks.json');
112
+ fs.writeFileSync(hooksPath, '{"hooks":{"UserPromptSubmit":[]}}');
113
+ fs.writeFileSync(path.join(source, 'config.toml'), [
114
+ 'model_provider = "native-provider"',
115
+ '',
116
+ '[mcp_servers.native]',
117
+ 'url = "https://example.com/mcp"',
118
+ '',
119
+ '[mcp_servers.native.http_headers]',
120
+ 'Authorization = "Bearer test"',
121
+ '',
122
+ `[hooks.state.${JSON.stringify(`${hooksPath}:UserPromptSubmit:0`)}]`,
123
+ 'trusted = true',
124
+ '',
125
+ ].join('\n'));
126
+
127
+ const runtimeHome = path.join(home, 'runtime-home');
128
+ codexPrivate.writeConfig({
129
+ authMethod: 'amalgm',
130
+ auth: { runtimeHome, baseUrl: 'https://amalgm.example/v1', tokenRef: 'test-token' },
131
+ mcpServers: [],
132
+ });
133
+
134
+ const config = fs.readFileSync(path.join(runtimeHome, 'config.toml'), 'utf8');
135
+ assert.match(config, /model_provider = "amalgm"/);
136
+ assert.match(config, /codex_hooks = true/);
137
+ assert.doesNotMatch(config, /native-provider/);
138
+ assert.match(config, /\[mcp_servers\.native\]/);
139
+ assert.match(config, /\[mcp_servers\.native\.http_headers\]/);
140
+ assert.match(config, /Authorization = "Bearer test"/);
94
141
  assert.equal(config.includes(path.join(runtimeHome, 'hooks.json')), true);
95
142
  });
96
143
  });
@@ -179,7 +179,10 @@ function syncCodexNativeConfig(runtimeHome) {
179
179
  if (!exists(sourceDir)) return null;
180
180
 
181
181
  pruneLegacyCodexRuntimeHome(runtimeHome);
182
+ const nativeConfig = copyDirBounded(sourceDir, runtimeHome);
182
183
  const copiedFiles = [
184
+ copyFileIfPresent(path.join(sourceDir, 'config.toml'), path.join(runtimeHome, 'config.toml')),
185
+ copyFileIfPresent(path.join(sourceDir, 'auth.json'), path.join(runtimeHome, 'auth.json')),
183
186
  copyFileIfPresent(path.join(sourceDir, 'hooks.json'), path.join(runtimeHome, 'hooks.json')),
184
187
  copyFileIfPresent(path.join(sourceDir, 'supermemory.json'), path.join(runtimeHome, 'supermemory.json')),
185
188
  ].filter(Boolean).length;
@@ -191,8 +194,8 @@ function syncCodexNativeConfig(runtimeHome) {
191
194
  sourceDir,
192
195
  runtimeHome,
193
196
  sourceConfigPath: path.join(sourceDir, 'config.toml'),
194
- copied: copiedFiles + (supermemory.copied ? 1 : 0) > 0,
195
- truncated: supermemory.truncated,
197
+ copied: nativeConfig.copied || copiedFiles + (supermemory.copied ? 1 : 0) > 0,
198
+ truncated: nativeConfig.truncated || supermemory.truncated,
196
199
  };
197
200
  }
198
201