@volter/supercode-orchestrator 0.4.10 → 0.4.12

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/activation.mjs CHANGED
@@ -6,6 +6,7 @@ import { join, relative, resolve } from 'node:path';
6
6
  import { homedir } from 'node:os';
7
7
  import { mkdirSync, readFileSync, readdirSync, lstatSync, rmSync, writeFileSync, existsSync } from 'node:fs';
8
8
  import { CLAUDE_BRIDGE, linkTo, skillSources } from './hermes-home.mjs';
9
+ import { ownLogin } from './worker-route.mjs';
9
10
 
10
11
  /** Which env var each harness reads its config home from (supercode registry evidence). */
11
12
  export const HOME_ENV = Object.freeze({
@@ -44,7 +45,8 @@ export function activationEnv({ root, profile, surfaceKey, vault }) {
44
45
  // `home: user` keeps the user's own harness home (their CLAUDE.md, skills, hooks, plugins, MCP servers and login);
45
46
  // the profile's persona and skills come in beside it through the launch (userHomeArguments).
46
47
  if (worker.home === 'user') env.HOME = homedir();
47
- else if (homeVar) env[homeVar] = join(profile.dir, worker.harness);
48
+ // a worker on its user's own login keeps that user's config home (worker-route.mjs `ownLogin`)
49
+ else if (homeVar && !ownLogin(profile)) env[homeVar] = join(profile.dir, worker.harness);
48
50
  for (const [k, v] of Object.entries(worker.env ?? {})) env[k] = resolveRef(v, vault);
49
51
  env[ORCH_ENV.root] = root;
50
52
  env[ORCH_ENV.profile] = profile.name;
@@ -131,10 +133,15 @@ export function materializeSkills(profile) {
131
133
  mkdirSync(join(profile.dir, worker.harness, '.claude-plugin'), { recursive: true });
132
134
  if (!existsSync(manifest) || readFileSync(manifest, 'utf8') !== text) writeFileSync(manifest, text);
133
135
  }
134
- for (const [name, from] of sources) linkTo(join(into, name), relative(into, from));
135
- for (const entry of readdirSync(into)) {
136
- const path = join(into, entry);
137
- if (lstatSync(path).isSymbolicLink() && !sources.has(entry) && !existsSync(path)) rmSync(path, { force: true });
136
+ // A worker on its user's own login reads them from the `--add-dir`ed Claude home's `.claude/skills` (worker-route.mjs
137
+ // `ownLogin`), linked beside `skills/`, which the orchestrator's own skill lookup still reads.
138
+ for (const folder of [into, ...(ownLogin(profile) ? [join(profile.dir, worker.harness, '.claude', 'skills')] : [])]) {
139
+ mkdirSync(folder, { recursive: true });
140
+ for (const [name, from] of sources) linkTo(join(folder, name), relative(folder, from));
141
+ for (const entry of readdirSync(folder)) {
142
+ const path = join(folder, entry);
143
+ if (lstatSync(path).isSymbolicLink() && !sources.has(entry) && !existsSync(path)) rmSync(path, { force: true });
144
+ }
138
145
  }
139
146
  return into;
140
147
  }
@@ -69,6 +69,9 @@ import * as events from '../events.mjs';
69
69
  import { httpJobExecutor } from '../hosted.mjs';
70
70
  import { SupercodeHarnessClient } from '@volter/supercode-harness-sdk';
71
71
 
72
+ /** How long a starting daemon waits for a stopping predecessor to release the home's lease. */
73
+ const LEASE_HANDOFF_MS = 20_000;
74
+
72
75
  /// Adapter selector -> constructor. A `platforms:` block picks its adapter by
73
76
  /// `extra.adapter` when it has one and by the block's own name otherwise, so
74
77
  /// `platforms.slack.extra.adapter: chat-sdk` and `platforms.api_server` both
@@ -596,6 +599,13 @@ async function main() {
596
599
  if (!args.once) {
597
600
  // Serialize lease replacement before loading state. An acquisition guard
598
601
  // left by a crash fails closed; inspect it before removing it manually.
602
+ // A service manager's restart starts this one while the last is still stopping (launchd's kickstart -k did, and
603
+ // this one exited 'already serving'): a live predecessor gets a moment to let go before it counts as serving.
604
+ for (let waited = 0; waited < LEASE_HANDOFF_MS; waited += 250) {
605
+ const previous = readLock(root);
606
+ if (!previous || previous.pid === process.pid || !leaseIsLive(previous)) break;
607
+ await new Promise((resolve) => setTimeout(resolve, 250));
608
+ }
599
609
  const guard = join(root, 'orchestrator.acquire');
600
610
  mkdirSync(guard);
601
611
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/supercode-orchestrator",
3
- "version": "0.4.10",
3
+ "version": "0.4.12",
4
4
  "type": "module",
5
5
  "description": "The orchestrator runtime over the Volter Harness ontology: one typed operational model whose folder is its serialization, read and written through the harness orchestration doors (docs/ORCHESTRATOR-IR.md)",
6
6
  "exports": {
package/worker-route.mjs CHANGED
@@ -91,9 +91,27 @@ export function workerRoute(profile, worker, vault) {
91
91
  return { model, args: ['-c', `model_provider=${JSON.stringify(id)}`], env };
92
92
  }
93
93
 
94
- /** Claude Code's route: its own environment and the endpoint's Messages wire. */
94
+ /**
95
+ * Whether a Claude Code worker runs on its user's own Claude login: `provider: anthropic` with no endpoint and no key,
96
+ * in the profile's home (a `home: user` worker is in that user's home already). The runhuman lobby managers run so.
97
+ * Claude Code finds its login through its config home, and a `CLAUDE_CONFIG_DIR` of the profile's own reports "Not
98
+ * logged in" (measured, claude 2.1.280), so the worker keeps its user's config home and the profile's reaches it by
99
+ * flag: `--add-dir` the profile's Claude home (its `CLAUDE.md`, read there under
100
+ * `CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD`, and its `.claude/skills`), `--setting-sources project,local` so that
101
+ * user's own settings, hooks and `CLAUDE.md` stay out, and `--strict-mcp-config` so only the MCP door's servers mount.
102
+ */
103
+ export function ownLogin(profile, worker = profile?.worker) {
104
+ const route = hermesModel(profile);
105
+ return worker?.harness === 'claude-code' && worker?.home !== 'user' && route?.provider === 'anthropic' && !route.base_url && !route.api_key;
106
+ }
107
+
108
+ /** Claude Code's route: its own environment, the endpoint's Messages wire, or its user's own login (`ownLogin`). */
95
109
  function claudeRoute(profile, route, model, vault) {
96
110
  if (!['custom', 'anthropic'].includes(route.provider)) throw new Error(`model.provider ${route.provider} has no Claude Code route in this orchestrator yet; refused rather than run on Claude Code's default`);
111
+ if (ownLogin(profile, { ...profile.worker, harness: 'claude-code' })) {
112
+ const env = { CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD: '1', ...(model ? { ANTHROPIC_MODEL: model } : {}) };
113
+ return { model, args: ['--add-dir', join(profile.dir, 'claude-code'), '--setting-sources', 'project,local', '--strict-mcp-config'], env };
114
+ }
97
115
  if (!route.base_url) throw new Error('Claude Code runs on a model with an endpoint (model.base_url); refused rather than run on Claude Code\'s default');
98
116
  const env = { CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: '1' };
99
117
  if (route.base_url) env.ANTHROPIC_BASE_URL = String(resolve(route.base_url, vault).value).replace(/\/v1\/?$/, '').replace(/\/$/, '');