@openagents-org/agent-launcher 0.2.207 → 0.2.209

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.
@@ -101,7 +101,7 @@ class ClaudeAdapter extends BaseAdapter {
101
101
  this._channelProcesses = {}; // channel → child process
102
102
  this._stoppingChannels = new Set();
103
103
  this._persistentProcs = {}; // channel → { proc, lineBuffer, pendingLines, idleTimer, messageResolve }
104
- // Knowledge pinning (decision log + glossary) lives in BaseAdapter; this
104
+ // Knowledge pinning (glossary) lives in BaseAdapter; this
105
105
  // adapter fetches directly in _handleMessage because the result also
106
106
  // drives the persistent-process staleness check.
107
107
  this._IDLE_TIMEOUT_MS = 60 * 60 * 1000; // 1 hour
@@ -458,7 +458,7 @@ class ClaudeAdapter extends BaseAdapter {
458
458
  return null;
459
459
  }
460
460
 
461
- _buildClaudeCmd(prompt, channelName, { skipResume = false, browserEnabled = false, decisionLog = null, glossary = null } = {}) {
461
+ _buildClaudeCmd(prompt, channelName, { skipResume = false, browserEnabled = false, glossary = null } = {}) {
462
462
  const claudeBin = this._findClaudeBinary();
463
463
  if (!claudeBin) {
464
464
  throw new Error('claude CLI not found. Install with: curl -fsSL https://claude.ai/install.sh | bash');
@@ -475,7 +475,6 @@ class ClaudeAdapter extends BaseAdapter {
475
475
  model: this.modelLabel(),
476
476
  browserEnabled,
477
477
  toolMode: this.toolMode,
478
- decisionLog,
479
478
  glossary,
480
479
  });
481
480
 
@@ -526,14 +525,17 @@ class ClaudeAdapter extends BaseAdapter {
526
525
  // process.cwd() as the fallback — on a packaged Windows daemon that is
527
526
  // C:\WINDOWS\system32 and mkdir there throws EPERM.
528
527
  const workDir = this.workingDir || defaultAgentWorkdir(this.agentName);
529
- const skillDir = path.join(workDir, '.claude', 'skills');
530
- fs.mkdirSync(skillDir, { recursive: true });
531
- // Per-agent filename: agents sharing a working directory used to clobber
528
+ const skillsRoot = path.join(workDir, '.claude', 'skills');
529
+ const skillDir = path.join(skillsRoot, workspaceSkillName(this.agentName));
530
+ fs.mkdirSync(skillDir, { recursive: true, mode: 0o700 });
531
+ // Per-agent directory: Claude discovers <name>/SKILL.md, not flat .md files.
532
+ // Agents sharing a working directory used to clobber
532
533
  // one shared openagents-workspace.md, so uploads carried the identity of
533
534
  // whichever agent wrote the file last. Drop that legacy file so a stale
534
535
  // copy (with another agent's embedded identity) can never be read again.
535
- const skillFile = path.join(skillDir, `${workspaceSkillName(this.agentName)}.md`);
536
- try { fs.unlinkSync(path.join(skillDir, 'openagents-workspace.md')); } catch {}
536
+ const skillFile = path.join(skillDir, 'SKILL.md');
537
+ try { fs.unlinkSync(path.join(skillsRoot, 'openagents-workspace.md')); } catch {}
538
+ try { fs.unlinkSync(path.join(skillsRoot, `${workspaceSkillName(this.agentName)}.md`)); } catch {}
537
539
 
538
540
  const skillContent = buildClaudeSkillMd({
539
541
  endpoint: this.endpoint,
@@ -544,7 +546,8 @@ class ClaudeAdapter extends BaseAdapter {
544
546
  disabledModules: this.disabledModules,
545
547
  browserEnabled: this._browserEnabledCache === true,
546
548
  });
547
- fs.writeFileSync(skillFile, skillContent, 'utf-8');
549
+ fs.writeFileSync(skillFile, skillContent, { encoding: 'utf-8', mode: 0o600 });
550
+ fs.chmodSync(skillFile, 0o600);
548
551
  this._log(`Wrote workspace skill to ${skillFile}`);
549
552
 
550
553
  return { cmd, skillFile };
@@ -572,7 +575,7 @@ class ClaudeAdapter extends BaseAdapter {
572
575
  mcpWriteTools.push(`${pfx}workspace_image_save`);
573
576
  }
574
577
  if (!this.disabledModules.has('knowledge')) {
575
- // The decision-log/glossary protocol instructs these by name — they
578
+ // The glossary protocol instructs these by name — they
576
579
  // must be callable or the pinned knowledge silently stops updating.
577
580
  mcpTools.push(`${pfx}workspace_list_knowledge`, `${pfx}workspace_read_knowledge`);
578
581
  mcpWriteTools.push(`${pfx}workspace_write_knowledge`);
@@ -1134,7 +1137,7 @@ class ClaudeAdapter extends BaseAdapter {
1134
1137
  try {
1135
1138
  await this.sendStatus(
1136
1139
  msgChannel,
1137
- 'Claude context reached its limit. Starting a fresh session from the channel recap and pinned decisions.'
1140
+ 'Claude context reached its limit. Starting a fresh session from the channel recap.'
1138
1141
  );
1139
1142
  } catch {}
1140
1143
  }
@@ -1218,16 +1221,15 @@ class ClaudeAdapter extends BaseAdapter {
1218
1221
  }
1219
1222
 
1220
1223
  /**
1221
- * The pinned decision log / glossary, rendered exactly as in the system
1224
+ * The pinned glossary, rendered exactly as in the system
1222
1225
  * prompt, framed as replacing the copy the running session started with.
1223
1226
  * Returns '' when nothing is pinned.
1224
1227
  */
1225
- _pinnedUpdatePreamble(msgChannel, decisionLog, glossary) {
1228
+ _pinnedUpdatePreamble(msgChannel, glossary) {
1226
1229
  const sections = buildPinnedSections({
1227
1230
  toolMode: this.toolMode,
1228
1231
  channelName: msgChannel,
1229
1232
  mode: this._mode,
1230
- decisionLog,
1231
1233
  glossary,
1232
1234
  }).join('').trim();
1233
1235
  if (!sections) return '';
@@ -1309,23 +1311,18 @@ class ClaudeAdapter extends BaseAdapter {
1309
1311
 
1310
1312
  await this.sendStatus(msgChannel, 'thinking...');
1311
1313
 
1312
- // Read the channel's pinned knowledge (decision log + glossary) up front
1313
- // — the fast-path staleness check and any (re)spawn below both need it.
1314
- const decisions = await this._fetchDecisionLog(msgChannel);
1314
+ // Read the channel's pinned knowledge (glossary) up front — the
1315
+ // fast-path staleness check and any (re)spawn below both need it.
1315
1316
  const glossary = await this._fetchGlossary(msgChannel);
1316
1317
  // null fingerprint = a fetch failed, current state unknown; never treat
1317
1318
  // that as a change (it would churn respawns on every workspace hiccup).
1318
1319
  // The fingerprint covers entry ids AND content — both are pinned into
1319
1320
  // the prompt, and a recreated entry can change id without changing content.
1320
- const pinnedHash = (decisions.error || glossary.error)
1321
+ const pinnedHash = glossary.error
1321
1322
  ? null
1322
1323
  : pinnedFingerprint([
1323
- { entryId: decisions.entryId, content: decisions.content },
1324
1324
  { entryId: glossary.entryId, content: glossary.content },
1325
1325
  ]);
1326
- const decisionLogOpt = decisions.available
1327
- ? { enabled: true, state: decisions.state, entryId: decisions.entryId, content: decisions.error ? '' : (decisions.content || '') }
1328
- : null;
1329
1326
  const glossaryOpt = (glossary.available && glossary.state === 'found' && glossary.content)
1330
1327
  ? { enabled: true, entryId: glossary.entryId, content: glossary.content, scope: glossary.scope || 'channel' }
1331
1328
  : null;
@@ -1353,15 +1350,14 @@ class ClaudeAdapter extends BaseAdapter {
1353
1350
  : `Model changed to ${this.workspaceModel || '(default)'} for ${msgChannel} — respawning with resume`);
1354
1351
  await this._killPersistentProc(msgChannel);
1355
1352
  } else {
1356
- // A pinned-knowledge change no longer restarts the process. Agents
1357
- // edit the decision log themselves on nearly every decision, and the
1353
+ // A pinned-knowledge change no longer restarts the process. The
1358
1354
  // restart killed whatever they had running in the background (a
1359
1355
  // sub-agent mid-build) and replayed into a false "agent hit an error".
1360
1356
  // The new version rides in with this message instead and supersedes
1361
1357
  // the copy baked into the system prompt.
1362
1358
  let turnContent = content;
1363
1359
  if (pinnedStale) {
1364
- const update = this._pinnedUpdatePreamble(msgChannel, decisionLogOpt, glossaryOpt);
1360
+ const update = this._pinnedUpdatePreamble(msgChannel, glossaryOpt);
1365
1361
  if (update) turnContent = `${update}\n\n---\n\n${content}`;
1366
1362
  existingPP.pinnedHash = pinnedHash;
1367
1363
  this._log(`Pinned knowledge changed for ${msgChannel} — passing the update to the running session`);
@@ -1431,7 +1427,6 @@ class ClaudeAdapter extends BaseAdapter {
1431
1427
  const built = this._buildClaudeCmd(effectiveContent, msgChannel, {
1432
1428
  skipResume: attempt > 0,
1433
1429
  browserEnabled,
1434
- decisionLog: decisionLogOpt,
1435
1430
  glossary: glossaryOpt,
1436
1431
  });
1437
1432
  cmd = built.cmd;
@@ -1450,7 +1445,6 @@ class ClaudeAdapter extends BaseAdapter {
1450
1445
  // When the fetch errored (pinnedHash null) hash what was actually
1451
1446
  // pinned, so the next successful fetch triggers a re-pin.
1452
1447
  pp.pinnedHash = pinnedHash !== null ? pinnedHash : pinnedFingerprint([
1453
- { entryId: decisionLogOpt && decisionLogOpt.entryId, content: decisionLogOpt && decisionLogOpt.content },
1454
1448
  { entryId: glossaryOpt && glossaryOpt.entryId, content: glossaryOpt && glossaryOpt.content },
1455
1449
  ]);
1456
1450
  pp.spawnMode = this._mode;
@@ -1486,7 +1480,7 @@ class ClaudeAdapter extends BaseAdapter {
1486
1480
  try {
1487
1481
  await this.sendStatus(
1488
1482
  msgChannel,
1489
- 'Claude session could not be resumed. Rebuilding context from the channel recap and pinned decisions.'
1483
+ 'Claude session could not be resumed. Rebuilding context from the channel recap.'
1490
1484
  );
1491
1485
  } catch {}
1492
1486
  continue;
@@ -50,7 +50,7 @@ class CodexAdapter extends BaseAdapter {
50
50
  constructor(opts) {
51
51
  super(opts);
52
52
  this.disabledModules = opts.disabledModules || new Set();
53
- // Pin the channel's decision log + glossary into the system prompt.
53
+ // Pin the channel's glossary into the system prompt.
54
54
  this._usesPinnedContext = true;
55
55
 
56
56
  const env = this.agentEnv || process.env;
@@ -87,7 +87,7 @@ class CopilotAdapter extends BaseAdapter {
87
87
  constructor(opts) {
88
88
  super(opts);
89
89
  this.disabledModules = opts.disabledModules || new Set();
90
- // Pin the channel's decision log + glossary into the system prompt.
90
+ // Pin the channel's glossary into the system prompt.
91
91
  this._usesPinnedContext = true;
92
92
 
93
93
  const env = this.agentEnv || process.env;
@@ -1,12 +1,11 @@
1
1
  /**
2
2
  * Pure helpers for knowledge pinning ("constraint pinning").
3
3
  *
4
- * Two kinds of knowledge entries get pinned into agent prompts:
5
- * - The decision log: a per-channel entry recording every decision the user
6
- * has confirmed.
7
- * - The glossary: a per-channel (or workspace-wide) entry defining shared
8
- * terms and fields, so agents collaborating on the same spec cannot drift
9
- * into different readings of the same name.
4
+ * The glossary — a per-channel (or workspace-wide) entry defining shared
5
+ * terms and fields — is pinned into agent prompts, so agents collaborating
6
+ * on the same spec cannot drift into different readings of the same name.
7
+ * (Agents used to keep a per-channel "Decisions for channel …" log too; that
8
+ * was removed because it created a knowledge page for nearly every thread.)
10
9
  *
11
10
  * Adapters re-read the pinned entries on every message and inject them into
12
11
  * the prompt — the only position that survives both auto-compaction and a
@@ -25,18 +24,10 @@ const RECAP_LINE_MAX_CHARS = 2000;
25
24
  const PINNED_DECISIONS_MAX_CHARS = 4000;
26
25
 
27
26
  /**
28
- * Canonical knowledge-entry title for a channel's decision log. The slug the
27
+ * Canonical knowledge-entry title for a channel's glossary. The slug the
29
28
  * backend derives from it is NOT stable (collisions get a numeric suffix), so
30
29
  * lookups must match on this exact title, never on the slug.
31
30
  */
32
- function decisionLogTitle(channelName) {
33
- return `Decisions for channel ${channelName}`;
34
- }
35
-
36
- /**
37
- * Canonical knowledge-entry title for a channel's glossary. Same exact-title
38
- * matching rules as the decision log.
39
- */
40
31
  function glossaryTitle(channelName) {
41
32
  return `Glossary for channel ${channelName}`;
42
33
  }
@@ -101,11 +92,6 @@ function pickEntryByTitle(entries, title) {
101
92
  return { entry: sorted[0], duplicates: matches.length - 1 };
102
93
  }
103
94
 
104
- /** Back-compat wrapper: pick a channel's decision-log entry by its title. */
105
- function pickDecisionEntry(entries, channelName) {
106
- return pickEntryByTitle(entries, decisionLogTitle(channelName));
107
- }
108
-
109
95
  /**
110
96
  * Fit the decision log into a character budget without ever cutting a line
111
97
  * in half. Over budget, whole lines are kept from the head (earliest
@@ -209,12 +195,10 @@ module.exports = {
209
195
  PINNED_DECISIONS_MAX_CHARS,
210
196
  RECAP_LINE_MAX_CHARS,
211
197
  WORKSPACE_GLOSSARY_TITLE,
212
- decisionLogTitle,
213
198
  glossaryTitle,
214
199
  hashDecisions,
215
200
  decisionFingerprint,
216
201
  pinnedFingerprint,
217
- pickDecisionEntry,
218
202
  pickEntryByTitle,
219
203
  renderPinnedDecisions,
220
204
  isRecapEligible,
@@ -66,10 +66,20 @@ const NODE_MIN_22 = [22, 19, 0];
66
66
  const ROW = {
67
67
  AGENT_DEFAULT_MODEL: 'agent-default-model',
68
68
  APPROVAL: 'approval',
69
+ LLM_PI_AI: 'llm-pi-ai',
69
70
  PERMISSION: 'permission',
70
71
  USER_QUESTIONS: 'user-questions',
71
72
  };
72
73
 
74
+ /** The pi-ai route an OpenAI-compatible gateway is served through. */
75
+ const GATEWAY_PROVIDER = 'openai-gateway';
76
+
77
+ /** The model a gateway route runs when none is configured. */
78
+ const DEFAULT_GATEWAY_MODEL = 'deepseek-v4-flash';
79
+
80
+ /** Where DeepSeek's own model list is read (its OpenAI-style root). */
81
+ const DEEPSEEK_MODELS_BASE = 'https://api.deepseek.com/v1';
82
+
73
83
  /** Permission modes dsh's `permission-presets` row declares. */
74
84
  const PERMISSION_MODES = ['read-only', 'workspace-write', 'danger-full-access'];
75
85
 
@@ -380,12 +390,14 @@ function yamlScalar(value) {
380
390
  * `never` is what gives non-interactive execution that is still confined to
381
391
  * the workspace for writes. (Reads are not confined in any mode.)
382
392
  * 3. The model/provider override, since `agent-default-model` is a composition
383
- * row rather than an environment variable.
393
+ * row rather than an environment variable. For an OpenAI-compatible
394
+ * gateway (`gatewayBaseUrl`) that is a pi-ai chat-completions route plus
395
+ * the default model pointing at it — see classifyDshEndpoint.
384
396
  *
385
397
  * A patch REPLACES the targeted row's whole `config`, so each row below is
386
398
  * written out complete rather than as a partial merge.
387
399
  */
388
- function buildPrivatePatch({ model, provider, permissionMode } = {}) {
400
+ function buildPrivatePatch({ model, provider, permissionMode, gatewayBaseUrl } = {}) {
389
401
  const mode = normalizePermissionMode(permissionMode) || 'workspace-write';
390
402
  const sandboxFor = (m) => (m === 'read-only' ? 'read-only' : m === 'danger-full-access' ? 'danger-full-access' : 'workspace-write');
391
403
 
@@ -412,7 +424,28 @@ function buildPrivatePatch({ model, provider, permissionMode } = {}) {
412
424
  lines.push(' approval: never');
413
425
  }
414
426
 
415
- if (model || provider) {
427
+ if (gatewayBaseUrl) {
428
+ // An OpenAI-compatible gateway has no Messages API for dsh's DeepSeek
429
+ // provider to call, so the run goes through dsh's pi-ai provider instead,
430
+ // as a chat-completions route of its own. pi-ai needs the model listed
431
+ // on the route, so the model is never left to the harness default here.
432
+ const gatewayModel = model || DEFAULT_GATEWAY_MODEL;
433
+ lines.push('');
434
+ lines.push(`- id: ${ROW.LLM_PI_AI}`);
435
+ lines.push(' config:');
436
+ lines.push(' providers:');
437
+ lines.push(` ${GATEWAY_PROVIDER}:`);
438
+ lines.push(' api: openai-completions');
439
+ lines.push(` baseURL: ${yamlScalar(gatewayBaseUrl)}`);
440
+ lines.push(' apiKeyEnv: DEEPSEEK_API_KEY');
441
+ lines.push(' models:');
442
+ lines.push(` - id: ${yamlScalar(gatewayModel)}`);
443
+ lines.push('');
444
+ lines.push(`- id: ${ROW.AGENT_DEFAULT_MODEL}`);
445
+ lines.push(' config:');
446
+ lines.push(` provider: ${GATEWAY_PROVIDER}`);
447
+ lines.push(` model: ${yamlScalar(gatewayModel)}`);
448
+ } else if (model || provider) {
416
449
  lines.push('');
417
450
  lines.push(`- id: ${ROW.AGENT_DEFAULT_MODEL}`);
418
451
  lines.push(' config:');
@@ -445,6 +478,40 @@ function isOfficialDeepseekRoot(url) {
445
478
  return p === '' || p === '/v1';
446
479
  }
447
480
 
481
+ /**
482
+ * Which API dsh should use for a configured base URL.
483
+ *
484
+ * - `native`: blank, or one of DeepSeek's own OpenAI-style roots. dsh uses
485
+ * its default, `https://api.deepseek.com/anthropic`.
486
+ * - `openai`: an OpenAI-compatible gateway — a base ending in a version
487
+ * segment (`…/v1`), which is how OpenAI-style relays (OpenAgents credits
488
+ * included) are written. These serve chat completions and no Messages
489
+ * API, so dsh's DeepSeek provider got a 404 from every one of them.
490
+ * - `anthropic`: anything else, used as given for the Messages API.
491
+ */
492
+ function classifyDshEndpoint(url) {
493
+ const raw = String(url || '').trim();
494
+ if (!raw || isOfficialDeepseekRoot(raw)) return 'native';
495
+ let parsed;
496
+ try { parsed = new URL(raw); } catch { return 'anthropic'; }
497
+ const p = parsed.pathname.replace(/\/+$/, '').toLowerCase();
498
+ return /\/v\d+$/.test(p) ? 'openai' : 'anthropic';
499
+ }
500
+
501
+ /**
502
+ * Where to list the models a DeepSeek Harness agent can run, and over which
503
+ * protocol. DeepSeek's own host serves its list on the OpenAI-style root
504
+ * whichever form of its URL was configured, a blank base included (the
505
+ * agent always holds a DeepSeek key).
506
+ */
507
+ function dshModelsEndpoint(url) {
508
+ const raw = String(url || '').trim();
509
+ let host = '';
510
+ try { host = new URL(raw).hostname.toLowerCase(); } catch {}
511
+ if (!raw || host === 'api.deepseek.com') return { baseUrl: DEEPSEEK_MODELS_BASE, protocol: 'openai' };
512
+ return { baseUrl: raw, protocol: classifyDshEndpoint(raw) === 'openai' ? 'openai' : 'anthropic' };
513
+ }
514
+
448
515
  // ---------------------------------------------------------------------------
449
516
  // Permission mode
450
517
  // ---------------------------------------------------------------------------
@@ -638,6 +705,9 @@ module.exports = {
638
705
  buildPrivatePatch,
639
706
 
640
707
  isOfficialDeepseekRoot,
708
+ classifyDshEndpoint,
709
+ dshModelsEndpoint,
710
+ GATEWAY_PROVIDER,
641
711
 
642
712
  normalizePermissionMode,
643
713
  resolvePermissionMode,
@@ -75,6 +75,7 @@ const {
75
75
  cleanStdout,
76
76
  defaultInstallCommand,
77
77
  isOfficialDeepseekRoot,
78
+ classifyDshEndpoint,
78
79
  nodeRequirementText,
79
80
  resolvePermissionMode,
80
81
  safeDshHomeName,
@@ -405,6 +406,12 @@ class DeepSeekAdapter extends BaseAdapter {
405
406
  return isOfficialDeepseekRoot(base) ? '' : base;
406
407
  }
407
408
 
409
+ /** The configured base when it is an OpenAI-compatible gateway, else ''. */
410
+ _gatewayBaseUrl() {
411
+ const base = this._baseUrl();
412
+ return classifyDshEndpoint(base) === 'openai' ? base : '';
413
+ }
414
+
408
415
  _model() {
409
416
  return String(this.agentEnv.DEEPSEEK_MODEL || this.agentEnv.LLM_MODEL || '').trim();
410
417
  }
@@ -538,7 +545,7 @@ class DeepSeekAdapter extends BaseAdapter {
538
545
  * starts mid-write can never read a half-file.
539
546
  */
540
547
  _writePrivatePatch() {
541
- const { text } = buildPrivatePatch({ model: this._model() });
548
+ const { text } = buildPrivatePatch({ model: this._model(), gatewayBaseUrl: this._gatewayBaseUrl() });
542
549
  const tmp = `${this._patchFile}.${process.pid}.tmp`;
543
550
  fs.writeFileSync(tmp, text, { encoding: 'utf-8', mode: 0o600 });
544
551
  fs.renameSync(tmp, this._patchFile);
@@ -570,8 +577,9 @@ class DeepSeekAdapter extends BaseAdapter {
570
577
  const key = this._apiKey();
571
578
  if (key) env.DEEPSEEK_API_KEY = key;
572
579
  // Set or cleared, never inherited: env already carries the raw agent value,
573
- // and _baseUrl() drops DeepSeek's own OpenAI-style roots.
574
- const base = this._baseUrl();
580
+ // and _baseUrl() drops DeepSeek's own OpenAI-style roots. A gateway is
581
+ // reached through the patch's pi-ai route, not dsh's DeepSeek provider.
582
+ const base = this._gatewayBaseUrl() ? '' : this._baseUrl();
575
583
  if (base) env.DEEPSEEK_BASE_URL = base;
576
584
  else delete env.DEEPSEEK_BASE_URL;
577
585
 
@@ -39,7 +39,7 @@ class GeminiAdapter extends BaseAdapter {
39
39
  constructor(opts) {
40
40
  super(opts);
41
41
  this.disabledModules = opts.disabledModules || new Set();
42
- // Pin the channel's decision log + glossary into the prompt (read-only:
42
+ // Pin the channel's glossary into the prompt (read-only:
43
43
  // Gemini has no MCP server and no workspace skill, so it cannot write
44
44
  // the knowledge entries — it only needs to SEE them).
45
45
  this._usesPinnedContext = true;
@@ -226,7 +226,6 @@ class GeminiAdapter extends BaseAdapter {
226
226
  channelName,
227
227
  mode: this._mode,
228
228
  model: this.modelLabel(),
229
- decisionLog: pinned.decisionLog ? { ...pinned.decisionLog, writeAccess: false } : null,
230
229
  glossary: pinned.glossary ? { ...pinned.glossary, writeAccess: false } : null,
231
230
  });
232
231
 
@@ -143,7 +143,7 @@ class GooseAdapter extends BaseAdapter {
143
143
  constructor(opts) {
144
144
  super(opts);
145
145
  this.disabledModules = opts.disabledModules || new Set();
146
- // Pin the channel's decision log + glossary into the per-turn --system
146
+ // Pin the channel's glossary into the per-turn --system
147
147
  // prompt (read-only: Goose gets no workspace API commands, so it can
148
148
  // only SEE the pinned knowledge, not update it).
149
149
  this._usesPinnedContext = true;
@@ -258,7 +258,6 @@ class GooseAdapter extends BaseAdapter {
258
258
  + buildPinnedSections({
259
259
  channelName,
260
260
  mode: this._mode,
261
- decisionLog: pinned.decisionLog ? { ...pinned.decisionLog, writeAccess: false } : null,
262
261
  glossary: pinned.glossary ? { ...pinned.glossary, writeAccess: false } : null,
263
262
  }).join('\n');
264
263
  if (this.workingDir) {
@@ -46,6 +46,10 @@ const HERMES_INSTALL_HINT = IS_WINDOWS
46
46
  : 'curl -fsSL https://raw.githubusercontent.com/NousResearch/hermes-agent/main/scripts/install.sh | bash';
47
47
  const SESSION_ID_RE = /session_id:\s*(\S+)/;
48
48
  const SESSION_LINE_RE = /^session_id:\s*\S+$/;
49
+ // Hermes validates the toolsets in its own config.yaml before the turn starts
50
+ // and prints this to stdout, ahead of the reply, when one is unknown to the
51
+ // installed version (e.g. `messaging` left over in `platform_toolsets.cli`).
52
+ const TOOLSET_WARNING_RE = /^Warning: Unknown toolsets:/;
49
53
  // What Hermes prints, in place of a session_id, when `--resume` names a
50
54
  // session it no longer has. Upstream localises that line
51
55
  // (t("cli.resume.session_not_found")), so this only matches the English text;
@@ -120,7 +124,7 @@ class HermesAdapter extends BaseAdapter {
120
124
  constructor(opts) {
121
125
  super(opts);
122
126
  this.disabledModules = opts.disabledModules || new Set();
123
- // Pin the channel's decision log + glossary into the context prefix.
127
+ // Pin the channel's glossary into the context prefix.
124
128
  this._usesPinnedContext = true;
125
129
  this.hermesProfile = this._resolveProfile(opts.hermesProfile, this.agentName);
126
130
  this.hermesSource = opts.hermesSource || 'tool';
@@ -509,6 +513,11 @@ class HermesAdapter extends BaseAdapter {
509
513
  const stripped = line.trim();
510
514
  if (!stripped) continue;
511
515
  if (stripped.startsWith('↻ Resumed session ')) continue;
516
+ // Only before the reply begins: the reply itself may quote the line.
517
+ if (!lines.length && TOOLSET_WARNING_RE.test(stripped)) {
518
+ this._log?.(`Hermes config: ${stripped} (check toolsets in ~/.hermes/config.yaml)`, 'warn');
519
+ continue;
520
+ }
512
521
  lines.push(line);
513
522
  }
514
523
  return { text: lines.join('\n').trim(), sessionId };
@@ -58,7 +58,7 @@ class LlmDirectAdapter extends BaseAdapter {
58
58
  constructor(opts) {
59
59
  super(opts);
60
60
  this.disabledModules = opts.disabledModules || new Set();
61
- // Pin the channel's decision log + glossary into the system prompt.
61
+ // Pin the channel's glossary into the system prompt.
62
62
  this._usesPinnedContext = true;
63
63
  this._adapterLabel = opts.adapterLabel || 'LLM';
64
64
  this._modelEnvVar = opts.modelEnvVar || '';
@@ -98,7 +98,7 @@ class OpenCodeAdapter extends BaseAdapter {
98
98
  constructor(opts) {
99
99
  super(opts);
100
100
  this.disabledModules = opts.disabledModules || new Set();
101
- // Pin the channel's decision log + glossary into the system prompt.
101
+ // Pin the channel's glossary into the system prompt.
102
102
  this._usesPinnedContext = true;
103
103
 
104
104
  // Agent home directory: ~/.openagents/agents/{agentName}/ — scratch storage
@@ -0,0 +1,91 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const os = require('os');
6
+ const { createHash, randomUUID } = require('crypto');
7
+ const { isTransientNetworkError, isLogPoint } = require('./failure-streak');
8
+
9
+ /** Final answers are saved before delivery; neither tokens nor session IDs are saved. */
10
+ class ResponseOutbox {
11
+ constructor({ endpoint, workspaceId, agentName, directory, prepare, send, log, onRevoked }) {
12
+ const scope = createHash('sha256').update(JSON.stringify([endpoint, workspaceId, agentName])).digest('hex');
13
+ this.directory = directory || path.join(os.homedir(), '.openagents', 'response-outbox', scope);
14
+ this.prepare = prepare;
15
+ this.send = send;
16
+ this.log = log;
17
+ this.onRevoked = onRevoked;
18
+ this.flight = null;
19
+ }
20
+
21
+ save(entry) {
22
+ fs.mkdirSync(this.directory, { recursive: true, mode: 0o700 });
23
+ const file = path.join(this.directory, `${entry.id}.json`);
24
+ const temp = `${file}.${randomUUID()}.tmp`;
25
+ fs.writeFileSync(temp, JSON.stringify(entry), { mode: 0o600 });
26
+ fs.renameSync(temp, file);
27
+ }
28
+
29
+ async enqueue(reply) {
30
+ const createdAt = this.readEntries().reduce((latest, entry) => Math.max(latest, entry.createdAt + 1), Date.now());
31
+ this.save({ ...reply, id: randomUUID(), createdAt, attempts: 0 });
32
+ // A new reply arriving during a drain must not be left waiting for a heartbeat.
33
+ if (this.flight) await this.flight;
34
+ await this.flush();
35
+ }
36
+
37
+ flush() {
38
+ if (this.flight) return this.flight;
39
+ this.flight = this.drain().finally(() => { this.flight = null; });
40
+ return this.flight;
41
+ }
42
+
43
+ readEntries() {
44
+ let files;
45
+ try { files = fs.readdirSync(this.directory).filter(f => /^[\da-f-]+\.json$/.test(f)); }
46
+ catch (e) { if (e.code === 'ENOENT') return []; throw e; }
47
+ return files.map(file => {
48
+ try { return JSON.parse(fs.readFileSync(path.join(this.directory, file), 'utf8')); }
49
+ catch { this.log('Unreadable saved reply in response outbox; retained for recovery.', 'error'); return null; }
50
+ }).filter(Boolean).sort((a, b) => a.createdAt - b.createdAt);
51
+ }
52
+
53
+ async drain() {
54
+ const entries = this.readEntries();
55
+ const waitingChannels = new Set();
56
+ for (const entry of entries) {
57
+ if (waitingChannels.has(entry.channel)) continue;
58
+ if (entry.blocked || entry.nextAttemptAt > Date.now()) {
59
+ waitingChannels.add(entry.channel);
60
+ continue;
61
+ }
62
+ try {
63
+ if (!entry.prepared) {
64
+ Object.assign(entry, await this.prepare(entry), { prepared: true });
65
+ this.save(entry);
66
+ }
67
+ await this.send(entry);
68
+ fs.unlinkSync(path.join(this.directory, `${entry.id}.json`));
69
+ if (entry.attempts) this.log(`Delivered saved reply ${entry.id} after recovery.`);
70
+ } catch (e) {
71
+ waitingChannels.add(entry.channel);
72
+ entry.attempts++;
73
+ // A replaced session stops this adapter. Its successor can deliver the
74
+ // saved reply with a fresh session and the SAME idempotency key.
75
+ if (e.name === 'SessionRevokedError') {
76
+ this.onRevoked();
77
+ return;
78
+ }
79
+ const retry = isTransientNetworkError(e) && (!entry.prepared || entry.safeRetry);
80
+ entry.blocked = !retry;
81
+ entry.nextAttemptAt = Date.now() + Math.min(300000, 1000 * 2 ** Math.min(entry.attempts, 8));
82
+ this.save(entry);
83
+ if (isLogPoint(entry.attempts)) {
84
+ this.log(`Reply ${entry.id} saved locally: ${retry ? 'delivery will retry' : 'delivery needs attention; automatic retries paused'}${e.status ? ` (HTTP ${e.status})` : ''}.`, retry ? 'warn' : 'error');
85
+ }
86
+ }
87
+ }
88
+ }
89
+ }
90
+
91
+ module.exports = { ResponseOutbox };