autodev-cli 1.4.192 → 1.4.194

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.
Files changed (36) hide show
  1. package/out/cli.js +4 -0
  2. package/out/cli.js.map +1 -1
  3. package/out/commands/grokKeepalive.d.ts +10 -0
  4. package/out/commands/grokKeepalive.js +27 -0
  5. package/out/commands/grokKeepalive.js.map +1 -0
  6. package/out/commands/leaderStop.d.ts +10 -0
  7. package/out/commands/leaderStop.js +63 -0
  8. package/out/commands/leaderStop.js.map +1 -0
  9. package/out/messageBuilder.js +5 -3
  10. package/out/messageBuilder.js.map +1 -1
  11. package/out/profileBuilder.js +1 -0
  12. package/out/profileBuilder.js.map +1 -1
  13. package/out/providers/acp/AcpSession.d.ts +30 -0
  14. package/out/providers/acp/AcpSession.js +86 -1
  15. package/out/providers/acp/AcpSession.js.map +1 -1
  16. package/out/providers/grok/GrokAcpSession.d.ts +14 -1
  17. package/out/providers/grok/GrokAcpSession.js +29 -2
  18. package/out/providers/grok/GrokAcpSession.js.map +1 -1
  19. package/out/providers/grok/keepalive.d.ts +15 -0
  20. package/out/providers/grok/keepalive.js +141 -0
  21. package/out/providers/grok/keepalive.js.map +1 -0
  22. package/out/providers/grok/keepaliveMain.d.ts +1 -0
  23. package/out/providers/grok/keepaliveMain.js +22 -0
  24. package/out/providers/grok/keepaliveMain.js.map +1 -0
  25. package/out/providers/grok/leader.d.ts +66 -0
  26. package/out/providers/grok/leader.js +390 -0
  27. package/out/providers/grok/leader.js.map +1 -0
  28. package/out/providers/grok/tui.js +130 -29
  29. package/out/providers/grok/tui.js.map +1 -1
  30. package/out/providers/opencode/sdk.d.ts +11 -0
  31. package/out/providers/opencode/sdk.js +110 -10
  32. package/out/providers/opencode/sdk.js.map +1 -1
  33. package/out/taskLoop.d.ts +64 -0
  34. package/out/taskLoop.js +270 -9
  35. package/out/taskLoop.js.map +1 -1
  36. package/package.json +2 -2
@@ -5,9 +5,20 @@ export type { AcpHostHooks, AcpTurnResult, AcpUpdate, AcpLaunchSpec } from '../a
5
5
  export declare const decodeAcpUpdate: typeof decodeAcpUpdateStandard;
6
6
  /** grok's ACP launch spec — the only provider-specific behaviour. */
7
7
  export declare const GROK_ACP_SPEC: AcpLaunchSpec;
8
+ /**
9
+ * LEADER-CLIENT spec (Layer B, 1.4.193): a thin `grok agent … --leader
10
+ * --leader-socket <sock> … stdio` client that connects to a shared leader daemon
11
+ * instead of starting its own backend (replaces `--no-leader` with the leader
12
+ * connect flags). The leader + a detached keepalive keep the session warm so this
13
+ * client attaches WITHOUT session/load. Everything else (decoder, narration) is
14
+ * identical to GROK_ACP_SPEC.
15
+ */
16
+ export declare function grokLeaderClientSpec(socket: string): AcpLaunchSpec;
8
17
  /**
9
18
  * One persistent `grok agent stdio` process for a workspace root. Thin subclass
10
- * that injects GROK_ACP_SPEC — all behaviour is in the shared AcpSession.
19
+ * that injects GROK_ACP_SPEC — all behaviour is in the shared AcpSession. When
20
+ * `leaderSocket` is given it uses the LEADER-CLIENT spec + attach-without-load
21
+ * (Layer B); otherwise the non-leader spec, byte-for-byte unchanged.
11
22
  */
12
23
  export declare class GrokAcpSession extends AcpSession {
13
24
  constructor(opts: {
@@ -17,5 +28,7 @@ export declare class GrokAcpSession extends AcpSession {
17
28
  hooks: import('../acp/AcpSession').AcpHostHooks;
18
29
  initialSessionId?: string;
19
30
  extraArgs?: string[];
31
+ leaderSocket?: string;
32
+ attachWithoutLoad?: boolean;
20
33
  });
21
34
  }
@@ -16,6 +16,7 @@
16
16
  // ---------------------------------------------------------------------------
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.GrokAcpSession = exports.GROK_ACP_SPEC = exports.decodeAcpUpdate = exports.AcpSession = exports.classifyAcpResult = exports.extractToolOutput = void 0;
19
+ exports.grokLeaderClientSpec = grokLeaderClientSpec;
19
20
  const AcpSession_1 = require("../acp/AcpSession");
20
21
  // Backward-compatible re-exports (tui.ts + test/grokAcpSession.smoke.mjs import
21
22
  // these from here). decodeAcpUpdate is the standard decoder — it already handles
@@ -40,13 +41,39 @@ exports.GROK_ACP_SPEC = {
40
41
  narrationTitle: 'grok',
41
42
  narrateReasoning: false,
42
43
  };
44
+ /**
45
+ * LEADER-CLIENT spec (Layer B, 1.4.193): a thin `grok agent … --leader
46
+ * --leader-socket <sock> … stdio` client that connects to a shared leader daemon
47
+ * instead of starting its own backend (replaces `--no-leader` with the leader
48
+ * connect flags). The leader + a detached keepalive keep the session warm so this
49
+ * client attaches WITHOUT session/load. Everything else (decoder, narration) is
50
+ * identical to GROK_ACP_SPEC.
51
+ */
52
+ function grokLeaderClientSpec(socket) {
53
+ return {
54
+ buildArgs(model, extraArgs) {
55
+ const args = ['agent', '--always-approve'];
56
+ if (model) {
57
+ args.push('-m', model);
58
+ }
59
+ args.push('--leader', '--leader-socket', socket, ...extraArgs, 'stdio');
60
+ return args;
61
+ },
62
+ decodeUpdate: AcpSession_1.decodeAcpUpdateStandard,
63
+ narrationTitle: 'grok',
64
+ narrateReasoning: false,
65
+ };
66
+ }
43
67
  /**
44
68
  * One persistent `grok agent stdio` process for a workspace root. Thin subclass
45
- * that injects GROK_ACP_SPEC — all behaviour is in the shared AcpSession.
69
+ * that injects GROK_ACP_SPEC — all behaviour is in the shared AcpSession. When
70
+ * `leaderSocket` is given it uses the LEADER-CLIENT spec + attach-without-load
71
+ * (Layer B); otherwise the non-leader spec, byte-for-byte unchanged.
46
72
  */
47
73
  class GrokAcpSession extends AcpSession_1.AcpSession {
48
74
  constructor(opts) {
49
- super({ ...opts, spec: exports.GROK_ACP_SPEC });
75
+ const spec = opts.leaderSocket ? grokLeaderClientSpec(opts.leaderSocket) : exports.GROK_ACP_SPEC;
76
+ super({ ...opts, spec, attachWithoutLoad: opts.attachWithoutLoad });
50
77
  }
51
78
  }
52
79
  exports.GrokAcpSession = GrokAcpSession;
@@ -1 +1 @@
1
- {"version":3,"file":"GrokAcpSession.js","sourceRoot":"","sources":["../../../src/providers/grok/GrokAcpSession.ts"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,+EAA+E;AAC/E,EAAE;AACF,+EAA+E;AAC/E,iFAAiF;AACjF,8EAA8E;AAC9E,gFAAgF;AAChF,2EAA2E;AAC3E,mEAAmE;AACnE,EAAE;AACF,+EAA+E;AAC/E,0EAA0E;AAC1E,iFAAiF;AACjF,wCAAwC;AACxC,8EAA8E;;;AAE9E,kDAAwE;AAGxE,gFAAgF;AAChF,iFAAiF;AACjF,yEAAyE;AACzE,aAAa;AACb,gDAAqF;AAA5E,+GAAA,iBAAiB,OAAA;AAAE,+GAAA,iBAAiB,OAAA;AAAE,wGAAA,UAAU,OAAA;AAE5C,QAAA,eAAe,GAAG,oCAAuB,CAAC;AAEvD,qEAAqE;AACxD,QAAA,aAAa,GAAkB;IAC1C,SAAS,CAAC,KAAyB,EAAE,SAAmB;QACtD,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;QAC3C,IAAI,KAAK,EAAE,CAAC;YAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAAC,CAAC;QACtC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,SAAS,EAAE,OAAO,CAAC,CAAC;QAChD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,YAAY,EAAE,oCAAuB;IACrC,cAAc,EAAE,MAAM;IACtB,gBAAgB,EAAE,KAAK;CACxB,CAAC;AAEF;;;GAGG;AACH,MAAa,cAAe,SAAQ,uBAAU;IAC5C,YAAY,IAIX;QACC,KAAK,CAAC,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,qBAAa,EAAE,CAAC,CAAC;IAC1C,CAAC;CACF;AARD,wCAQC"}
1
+ {"version":3,"file":"GrokAcpSession.js","sourceRoot":"","sources":["../../../src/providers/grok/GrokAcpSession.ts"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,+EAA+E;AAC/E,EAAE;AACF,+EAA+E;AAC/E,i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;QACD,YAAY,EAAE,oCAAuB;QACrC,cAAc,EAAE,MAAM;QACtB,gBAAgB,EAAE,KAAK;KACxB,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAa,cAAe,SAAQ,uBAAU;IAC5C,YAAY,IAKX;QACC,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,oBAAoB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,qBAAa,CAAC;QACzF,KAAK,CAAC,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC;IACtE,CAAC;CACF;AAVD,wCAUC"}
@@ -0,0 +1,15 @@
1
+ export interface RunKeepaliveOpts {
2
+ socket: string;
3
+ cwd: string;
4
+ sidFile: string;
5
+ bin: string;
6
+ seed?: string;
7
+ }
8
+ /**
9
+ * Connect to the leader as a client, establish ONE session (session/load the seed
10
+ * id if given, else session/new), write the session id to `sidFile`, then HOLD the
11
+ * connection open indefinitely so the leader never evicts the in-memory context.
12
+ * Exits when the leader dies (its stdout closes) so it never lingers as an orphan.
13
+ * The returned promise never resolves (the caller keeps the process alive).
14
+ */
15
+ export declare function runKeepalive(opts: RunKeepaliveOpts): Promise<void>;
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+ // ---------------------------------------------------------------------------
3
+ // grok leader KEEPALIVE client (Layer B, 1.4.193).
4
+ //
5
+ // A tiny leader-client that holds ONE session warm in the leader's memory forever
6
+ // so loop clients can attach-without-load across restarts (grok 1.0.41 evicts a
7
+ // session's in-memory context when its LAST client disconnects). Deliberately
8
+ // depends on ONLY node:fs + node:child_process — NO commander, NO provider graph —
9
+ // so the DETACHED process starts fast and can't fail to load a missing dep. Run via
10
+ // the minimal `keepaliveMain` entry, spawned detached by `ensureLeader`.
11
+ // ---------------------------------------------------------------------------
12
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ var desc = Object.getOwnPropertyDescriptor(m, k);
15
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
16
+ desc = { enumerable: true, get: function() { return m[k]; } };
17
+ }
18
+ Object.defineProperty(o, k2, desc);
19
+ }) : (function(o, m, k, k2) {
20
+ if (k2 === undefined) k2 = k;
21
+ o[k2] = m[k];
22
+ }));
23
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
24
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
25
+ }) : function(o, v) {
26
+ o["default"] = v;
27
+ });
28
+ var __importStar = (this && this.__importStar) || (function () {
29
+ var ownKeys = function(o) {
30
+ ownKeys = Object.getOwnPropertyNames || function (o) {
31
+ var ar = [];
32
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
33
+ return ar;
34
+ };
35
+ return ownKeys(o);
36
+ };
37
+ return function (mod) {
38
+ if (mod && mod.__esModule) return mod;
39
+ var result = {};
40
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
41
+ __setModuleDefault(result, mod);
42
+ return result;
43
+ };
44
+ })();
45
+ Object.defineProperty(exports, "__esModule", { value: true });
46
+ exports.runKeepalive = runKeepalive;
47
+ const fs = __importStar(require("fs"));
48
+ const child_process = __importStar(require("child_process"));
49
+ /**
50
+ * Connect to the leader as a client, establish ONE session (session/load the seed
51
+ * id if given, else session/new), write the session id to `sidFile`, then HOLD the
52
+ * connection open indefinitely so the leader never evicts the in-memory context.
53
+ * Exits when the leader dies (its stdout closes) so it never lingers as an orphan.
54
+ * The returned promise never resolves (the caller keeps the process alive).
55
+ */
56
+ async function runKeepalive(opts) {
57
+ const { socket, cwd, sidFile, bin, seed } = opts;
58
+ const child = child_process.spawn(bin, ['agent', '--always-approve', '--leader', '--leader-socket', socket, 'stdio'], {
59
+ cwd, stdio: ['pipe', 'pipe', 'ignore'],
60
+ env: { ...process.env, TERM: process.env['TERM'] || 'xterm-256color' },
61
+ });
62
+ let buf = '';
63
+ let nextId = 1;
64
+ const pending = new Map();
65
+ child.stdout?.setEncoding('utf8');
66
+ child.stdout?.on('data', (chunk) => {
67
+ buf += chunk;
68
+ let nl;
69
+ while ((nl = buf.indexOf('\n')) >= 0) {
70
+ const line = buf.slice(0, nl).trim();
71
+ buf = buf.slice(nl + 1);
72
+ if (!line) {
73
+ continue;
74
+ }
75
+ let m;
76
+ try {
77
+ m = JSON.parse(line);
78
+ }
79
+ catch {
80
+ continue;
81
+ }
82
+ const id = m['id'];
83
+ if (typeof id === 'number' && (m['result'] !== undefined || m['error'] !== undefined) && pending.has(id)) {
84
+ const r = pending.get(id);
85
+ pending.delete(id);
86
+ r(m);
87
+ }
88
+ else if (m['method'] && id !== undefined) {
89
+ // agent→client request: auto-allow so nothing wedges.
90
+ const params = m['params'];
91
+ const optsArr = params?.options ?? [];
92
+ const allow = optsArr.find((o) => /allow|once|always/i.test(o.optionId || o.kind || '')) || optsArr[0];
93
+ try {
94
+ child.stdin?.write(JSON.stringify({ jsonrpc: '2.0', id, result: { outcome: { outcome: 'selected', optionId: allow?.optionId } } }) + '\n');
95
+ }
96
+ catch { /* ignore */ }
97
+ }
98
+ }
99
+ });
100
+ const req = (method, params) => new Promise((resolve) => {
101
+ const id = nextId++;
102
+ pending.set(id, resolve);
103
+ try {
104
+ child.stdin?.write(JSON.stringify({ jsonrpc: '2.0', id, method, params }) + '\n');
105
+ }
106
+ catch {
107
+ pending.delete(id);
108
+ resolve({ error: { message: 'write failed' } });
109
+ }
110
+ });
111
+ // When the leader (or this client) dies, exit so no orphan lingers.
112
+ child.on('exit', () => { process.exit(0); });
113
+ const bye = () => { try {
114
+ child.kill('SIGKILL');
115
+ }
116
+ catch { /* ignore */ } process.exit(0); };
117
+ process.on('SIGTERM', bye);
118
+ process.on('SIGINT', bye);
119
+ await req('initialize', { protocolVersion: 1, clientCapabilities: {} });
120
+ let sid = seed;
121
+ if (sid) {
122
+ const r = await req('session/load', { sessionId: sid, cwd, mcpServers: [] });
123
+ if (r.error) {
124
+ sid = undefined;
125
+ } // stale disk id → session/new
126
+ }
127
+ if (!sid) {
128
+ const sn = await req('session/new', { cwd, mcpServers: [] });
129
+ sid = sn.result?.sessionId;
130
+ }
131
+ if (!sid) {
132
+ process.exit(1);
133
+ }
134
+ try {
135
+ fs.writeFileSync(sidFile, sid, 'utf8');
136
+ }
137
+ catch { /* ignore */ }
138
+ // Hold the connection open forever — the whole point.
139
+ await new Promise(() => { });
140
+ }
141
+ //# sourceMappingURL=keepalive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keepalive.js","sourceRoot":"","sources":["../../../src/providers/grok/keepalive.ts"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,mDAAmD;AACnD,EAAE;AACF,kFAAkF;AAClF,gFAAgF;AAChF,8EAA8E;AAC9E,mFAAmF;AACnF,oFAAoF;AACpF,yEAAyE;AACzE,8EAA8E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoB9E,oCAwDC;AA1ED,uCAAyB;AACzB,6DAA+C;AAU/C;;;;;;GAMG;AACI,KAAK,UAAU,YAAY,CAAC,IAAsB;IACvD,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;IACjD,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QACpH,GAAG,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC;QACtC,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,gBAAgB,EAAE;KACvE,CAAC,CAAC;IACH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ACrE,CAAC;IACD,IAAI,CAAC,GAAG,EAAE,CAAC;QAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAAC,CAAC;IAC9B,IAAI,CAAC;QAAC,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;IAAC,CAAC;IAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC;IACtE,sDAAsD;IACtD,MAAM,IAAI,OAAO,CAAO,GAAG,EAAE,GAAyD,CAAC,CAAC,CAAC;AAC3F,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // Minimal entry for the DETACHED grok leader keepalive (Layer B). Parses argv by
4
+ // hand and calls runKeepalive — NO commander / CLI graph, so the background holder
5
+ // loads instantly and can't die on a missing dependency. Spawned by ensureLeader
6
+ // as `node <this> --socket … --cwd … --sid-file … --bin … [--seed …]`.
7
+ const keepalive_1 = require("./keepalive");
8
+ function arg(name) {
9
+ const i = process.argv.indexOf(name);
10
+ return i >= 0 && i + 1 < process.argv.length ? process.argv[i + 1] : undefined;
11
+ }
12
+ const socket = arg('--socket');
13
+ const cwd = arg('--cwd');
14
+ const sidFile = arg('--sid-file');
15
+ const bin = arg('--bin');
16
+ const seed = arg('--seed');
17
+ if (!socket || !cwd || !sidFile || !bin) {
18
+ process.stderr.write('grok keepalive: missing required arg (--socket/--cwd/--sid-file/--bin)\n');
19
+ process.exit(2);
20
+ }
21
+ void (0, keepalive_1.runKeepalive)({ socket, cwd, sidFile, bin, seed });
22
+ //# sourceMappingURL=keepaliveMain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keepaliveMain.js","sourceRoot":"","sources":["../../../src/providers/grok/keepaliveMain.ts"],"names":[],"mappings":";;AAAA,iFAAiF;AACjF,mFAAmF;AACnF,iFAAiF;AACjF,uEAAuE;AACvE,2CAA2C;AAE3C,SAAS,GAAG,CAAC,IAAY;IACvB,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACjF,CAAC;AAED,MAAM,MAAM,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC;AAC/B,MAAM,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC;AACzB,MAAM,OAAO,GAAG,GAAG,CAAC,YAAY,CAAC,CAAC;AAClC,MAAM,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC;AACzB,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC3B,IAAI,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC;IACxC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,0EAA0E,CAAC,CAAC;IACjG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AACD,KAAK,IAAA,wBAAY,EAAC,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC"}
@@ -0,0 +1,66 @@
1
+ import type { ProviderId } from '../../providers';
2
+ export { runKeepalive } from './keepalive';
3
+ export type { RunKeepaliveOpts } from './keepalive';
4
+ /** Shape persisted to `.autodev/leader.json` (the app contract). `pid` is the
5
+ * LEADER daemon pid; `keepalivePid` the detached session-holder. Both are reaped
6
+ * by `autodev leader-stop <root>`. `sessionId` is the warm grok session. */
7
+ export interface LeaderInfo {
8
+ pid: number;
9
+ socket: string;
10
+ startedAt: string;
11
+ keepalivePid?: number;
12
+ sessionId?: string;
13
+ root?: string;
14
+ }
15
+ /** Env gate — leader mode is OPT-IN and DEFAULT OFF. Pure (env injectable). */
16
+ export declare function leaderModeEnabled(env?: NodeJS.ProcessEnv): boolean;
17
+ /** Per-agent AF_UNIX socket. Prefer `.autodev/grok-leader.sock`; fall back to a
18
+ * hashed path under tmp when the workspace path would blow the ~108-byte sun_path
19
+ * limit (a deterministic function of the root either way). */
20
+ export declare function leaderSocketPath(root: string): string;
21
+ export declare function leaderJsonPath(root: string): string;
22
+ export declare function leaderSidPath(root: string): string;
23
+ export declare function readLeaderInfo(root: string): LeaderInfo | null;
24
+ export declare function writeLeaderInfo(root: string, info: LeaderInfo): void;
25
+ export declare function removeLeaderInfo(root: string): void;
26
+ /** `process.kill(pid, 0)` liveness probe — true iff the pid exists (and is ours
27
+ * or EPERM, which still means alive). */
28
+ export declare function isPidAlive(pid: number | undefined): boolean;
29
+ /**
30
+ * PURE orphan-sweep decision. Given the persisted info and the observed liveness
31
+ * of its pieces, decide whether to reuse a still-live leader ('adopt'), reap a
32
+ * stale/dead one ('reap-stale'), or spawn fresh ('spawn'). Unit-tested.
33
+ */
34
+ export declare function decideLeaderAction(info: LeaderInfo | null, alive: {
35
+ leader: boolean;
36
+ keepalive: boolean;
37
+ socket: boolean;
38
+ }): 'spawn' | 'adopt' | 'reap-stale';
39
+ /** Is the persisted leader fully healthy right now (adoptable)? */
40
+ export declare function leaderHealthy(info: LeaderInfo | null): boolean;
41
+ /** Resolve the minimal keepalive entry (out/providers/grok/keepaliveMain.js) so a
42
+ * detached keepalive loads with NO commander/CLI graph. Overridable for odd
43
+ * packagings via AUTODEV_KEEPALIVE_ENTRY. */
44
+ export declare function keepaliveEntryPath(): string;
45
+ export interface EnsureLeaderOpts {
46
+ root: string;
47
+ bin: string;
48
+ providerId: ProviderId;
49
+ model?: string;
50
+ log: (msg: string) => void;
51
+ }
52
+ /**
53
+ * ORPHAN-SWEEP + ensure a live leader+keepalive for this root. Adopts a still-live
54
+ * one (no second leader), reaps a stale/dead one, else spawns both DETACHED so they
55
+ * survive the loop process exiting. Returns the LeaderInfo (with the warm session
56
+ * id) or null when the backend could not be established (caller falls back to the
57
+ * non-leader ACP path). Never throws.
58
+ */
59
+ export declare function ensureLeader(opts: EnsureLeaderOpts): Promise<LeaderInfo | null>;
60
+ /**
61
+ * `autodev leader-stop <root>` — kill the leader + keepalive pid-trees named in
62
+ * `.autodev/leader.json` and clean up the socket / sid / json. This is what the
63
+ * app calls on office stop / remove / quit. Best-effort; returns whether anything
64
+ * was reaped.
65
+ */
66
+ export declare function stopLeader(root: string, log: (msg: string) => void): boolean;