amalgm 0.1.65 → 0.1.67

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amalgm",
3
- "version": "0.1.65",
3
+ "version": "0.1.67",
4
4
  "description": "Amalgm local computer runtime: login, MCP, chat, events, previews, and tunnels.",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,
@@ -72,7 +72,7 @@ function sanitizeRunModelSettings(settings, harness) {
72
72
  : new Set();
73
73
  return {
74
74
  ...(effort && allowedEfforts.has(effort) ? { effort } : {}),
75
- ...(harness === 'claude_code' && settings.fastMode === true ? { fastMode: true } : {}),
75
+ ...((harness === 'claude_code' || harness === 'codex') && settings.fastMode === true ? { fastMode: true } : {}),
76
76
  };
77
77
  }
78
78
 
@@ -173,6 +173,10 @@ function modelWindowConfigLines(contract) {
173
173
  ];
174
174
  }
175
175
 
176
+ function serviceTierForContract(contract) {
177
+ return contract.fastMode ? 'fast' : null;
178
+ }
179
+
176
180
  function isCompactCommand(text) {
177
181
  return String(text || '').trim().toLowerCase() === '/compact';
178
182
  }
@@ -378,6 +382,7 @@ class CodexAdapter {
378
382
  approvalPolicy: 'never',
379
383
  sandbox: 'danger-full-access',
380
384
  modelProvider: contract.authMethod === 'amalgm' ? 'amalgm' : 'openai',
385
+ serviceTier: serviceTierForContract(contract),
381
386
  developerInstructions: composeSystemPrompt(contract) || null,
382
387
  persistExtendedHistory: true,
383
388
  };
@@ -460,6 +465,7 @@ class CodexAdapter {
460
465
  cwd: contract.cwd,
461
466
  model: contract.cliModel.replace(/\/(?:low|medium|high|xhigh)$/i, ''),
462
467
  effort: contract.reasoningEffort || undefined,
468
+ serviceTier: serviceTierForContract(contract),
463
469
  approvalPolicy: 'never',
464
470
  });
465
471
  startRequest.then((result) => {
@@ -504,6 +510,7 @@ module.exports = {
504
510
  modelWindowConfigLines,
505
511
  removeTomlSections,
506
512
  removeTopLevelKeys,
513
+ serviceTierForContract,
507
514
  writeConfig,
508
515
  },
509
516
  };
@@ -126,11 +126,6 @@ function runtimeHome({ amalgmDir, harness, authProfileId }) {
126
126
  return path.join(amalgmDir, 'cli-homes', safePathSegment(harness), safePathSegment(authProfileId));
127
127
  }
128
128
 
129
- function nativeProviderHome(harness) {
130
- if (harness === 'claude_code') return os.homedir();
131
- return null;
132
- }
133
-
134
129
  function pinnedRuntimeHome(amalgmDir, cliHomePath) {
135
130
  if (typeof cliHomePath !== 'string' || !cliHomePath.trim()) return null;
136
131
  const root = path.resolve(amalgmDir);
@@ -183,8 +178,7 @@ function authEnvelope({ harness, authMethod, sessionId, localBaseUrl, proxyToken
183
178
  tokenFingerprint,
184
179
  authProfileId: profileId,
185
180
  runtimeHome:
186
- nativeProviderHome(method === 'provider_auth' ? harness : null)
187
- || pinnedRuntimeHome(amalgmDir, cliHomePath)
181
+ pinnedRuntimeHome(amalgmDir, cliHomePath)
188
182
  || runtimeHome({ amalgmDir, harness, authProfileId: profileId }),
189
183
  };
190
184
  }
@@ -202,15 +196,6 @@ function runtimeEnv(contract, baseEnv = process.env) {
202
196
  for (const key of ['OPENAI_API_KEY', 'OPENAI_BASE_URL', 'ANTHROPIC_API_KEY', 'ANTHROPIC_BASE_URL', 'AI_GATEWAY_API_KEY', 'AI_GATEWAY_BASE_URL']) {
203
197
  delete env[key];
204
198
  }
205
- if (contract.harness === 'claude_code' && contract.authMethod === 'provider_auth') {
206
- env.HOME = os.homedir();
207
- delete env.CLAUDE_CONFIG_DIR;
208
- return {
209
- ...env,
210
- IS_SANDBOX: '1',
211
- ...(baseEnv.AMALGM_RUNTIME_TOKEN ? { AMALGM_RUNTIME_TOKEN: baseEnv.AMALGM_RUNTIME_TOKEN } : {}),
212
- };
213
- }
214
199
  if (contract.auth.runtimeHome) {
215
200
  fs.mkdirSync(contract.auth.runtimeHome, { recursive: true });
216
201
  env.HOME = contract.auth.runtimeHome;
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  const assert = require('node:assert/strict');
4
- const os = require('node:os');
5
4
  const test = require('node:test');
6
5
  const { authEnvelope, runtimeEnv } = require('../auth');
7
6
 
@@ -63,7 +62,7 @@ test('opencode amalgm auth uses a pinned CLI home across sessions and proxy toke
63
62
  assert.equal(env.OPENCODE_CONFIG_DIR, first.runtimeHome);
64
63
  });
65
64
 
66
- test('claude provider auth uses the native user home with CLAUDE_CONFIG_DIR unset', () => {
65
+ test('claude provider auth uses a pinned CLI home with native config copied separately', () => {
67
66
  const envelope = authEnvelope({
68
67
  harness: 'claude_code',
69
68
  authMethod: 'provider_auth',
@@ -71,7 +70,7 @@ test('claude provider auth uses the native user home with CLAUDE_CONFIG_DIR unse
71
70
  amalgmDir: '/tmp/amalgm-test',
72
71
  });
73
72
 
74
- assert.equal(envelope.runtimeHome, os.homedir());
73
+ assert.match(envelope.runtimeHome, /\/tmp\/amalgm-test\/cli-homes\/claude_code\/provider-[0-9a-f]{16}$/);
75
74
 
76
75
  const env = runtimeEnv({
77
76
  harness: 'claude_code',
@@ -84,8 +83,8 @@ test('claude provider auth uses the native user home with CLAUDE_CONFIG_DIR unse
84
83
  ANTHROPIC_API_KEY: 'should-not-leak',
85
84
  });
86
85
 
87
- assert.equal(env.HOME, os.homedir());
88
- assert.equal(env.CLAUDE_CONFIG_DIR, undefined);
86
+ assert.equal(env.HOME, envelope.runtimeHome);
87
+ assert.equal(env.CLAUDE_CONFIG_DIR, envelope.runtimeHome);
89
88
  assert.equal(env.ANTHROPIC_API_KEY, undefined);
90
89
  });
91
90
 
@@ -30,7 +30,7 @@ function withNativeHome(fn) {
30
30
  }
31
31
  }
32
32
 
33
- test('codex native sync copies hook support without bulk runtime state', () => {
33
+ test('codex native sync copies config without deleting existing runtime state', () => {
34
34
  withNativeHome((home) => {
35
35
  const source = path.join(home, '.codex');
36
36
  fs.mkdirSync(path.join(source, 'sessions'), { recursive: true });
@@ -58,7 +58,8 @@ test('codex native sync copies hook support without bulk runtime state', () => {
58
58
  assert.equal(fs.existsSync(path.join(runtimeHome, 'hooks.json')), true);
59
59
  assert.equal(fs.existsSync(path.join(runtimeHome, 'supermemory.json')), true);
60
60
  assert.equal(fs.existsSync(path.join(runtimeHome, 'supermemory', 'recall.js')), true);
61
- assert.equal(fs.existsSync(path.join(runtimeHome, 'sessions')), false);
61
+ assert.equal(fs.existsSync(path.join(runtimeHome, 'sessions', 'legacy.jsonl')), true);
62
+ assert.equal(fs.existsSync(path.join(runtimeHome, 'sessions', 'huge.jsonl')), false);
62
63
  assert.equal(fs.existsSync(path.join(runtimeHome, 'worktrees')), false);
63
64
  assert.equal(fs.existsSync(path.join(runtimeHome, 'plugins')), false);
64
65
  assert.equal(fs.existsSync(path.join(runtimeHome, '.codex', 'hooks.json')), true);
@@ -124,14 +124,6 @@ function nativeHome() {
124
124
  return process.env.AMALGM_NATIVE_HOME || os.homedir();
125
125
  }
126
126
 
127
- function pruneLegacyCodexRuntimeHome(runtimeHome) {
128
- for (const name of EXCLUDED_DIR_NAMES) {
129
- try {
130
- fs.rmSync(path.join(runtimeHome, name), { recursive: true, force: true });
131
- } catch {}
132
- }
133
- }
134
-
135
127
  function copyDirBounded(sourceDir, targetDir, options = {}) {
136
128
  if (!sourceDir || !targetDir || !exists(sourceDir)) return { copied: false, files: 0, bytes: 0, truncated: false };
137
129
  const maxFiles = Number(options.maxFiles || 200);
@@ -178,7 +170,6 @@ function syncCodexNativeConfig(runtimeHome) {
178
170
  fs.mkdirSync(runtimeHome, { recursive: true });
179
171
  if (!exists(sourceDir)) return null;
180
172
 
181
- pruneLegacyCodexRuntimeHome(runtimeHome);
182
173
  const nativeConfig = copyDirBounded(sourceDir, runtimeHome);
183
174
  const copiedFiles = [
184
175
  copyFileIfPresent(path.join(sourceDir, 'config.toml'), path.join(runtimeHome, 'config.toml')),