@anhlp/alp-client 0.0.1-beta.6 → 0.0.1-beta.7
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/README.md +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +22 -46
- package/dist/rpc/registry.d.ts +9 -0
- package/dist/rpc/registry.js +5 -0
- package/dist/service.d.ts +1 -1
- package/dist/service.js +2 -2
- package/dist/setup.js +2 -1
- package/package.json +3 -3
- package/src/index.js +28 -58
- package/src/rpc/registry.js +5 -0
- package/src/service.js +5 -4
- package/src/setup.js +3 -2
package/README.md
CHANGED
|
@@ -32,6 +32,7 @@ Public imports use the package root and its explicitly exported subpaths. See [a
|
|
|
32
32
|
`session.fork`, `session.rewind`, `session.reload`, `session.resumeCommand` and
|
|
33
33
|
`session.configure.live`; docs/protocol/alp-json-rpc-v1.md §12.7–§12.9): `fork`, `rewind`, `reload`,
|
|
34
34
|
`resumeCommand`, `configure` and `configurePreview`. They change only the conversation, never a file.
|
|
35
|
+
`commands` (capability `session.commands`, §12.12) lists the slash commands and skills a composer offers after "/".
|
|
35
36
|
Each mutation is sent once: keep its `requestId` and `ifGeneration` (the generation `session.history`
|
|
36
37
|
answered) and send the identical request again only after a lost answer, which alpd answers with the
|
|
37
38
|
first result and `duplicate: true`. After a rewind, attached clients get `history.reset`: drop the
|
package/dist/index.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export function findDaemonEntry({ home, env, candidates }?: {
|
|
|
20
20
|
home?: string | undefined;
|
|
21
21
|
env?: NodeJS.ProcessEnv | undefined;
|
|
22
22
|
candidates?: (string | undefined)[] | undefined;
|
|
23
|
-
}): Promise<
|
|
23
|
+
}): Promise<any>;
|
|
24
24
|
/**
|
|
25
25
|
* Integration names are single lowercase path segments: they name `<home>/integrations/<name>.lock`,
|
|
26
26
|
* its guard and `<home>/<name>.json`. Returns the name, or throws a TypeError.
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import net from "node:net";
|
|
|
8
8
|
import os from "node:os";
|
|
9
9
|
import path from "node:path";
|
|
10
10
|
import { scrubText } from "@anhlp/alp-core/log";
|
|
11
|
-
import {
|
|
11
|
+
import { entryCommand } from "@anhlp/alp-core/packaged";
|
|
12
12
|
import { createSocketTransport } from "./ipc.js";
|
|
13
13
|
import { AlpRpcClient } from "./rpc/client.js";
|
|
14
14
|
import { hello } from "./rpc/handshake.js";
|
|
@@ -79,43 +79,25 @@ async function assertPrivateSocket(socketPath) {
|
|
|
79
79
|
return info;
|
|
80
80
|
}
|
|
81
81
|
var isFile = (file) => stat(file).then((info) => info.isFile(), () => false);
|
|
82
|
-
async function isAlpExecutable(file) {
|
|
83
|
-
if (isScript(file) || !isExecutableName(file) || !await isFile(file)) return false;
|
|
84
|
-
const handle = await open(file, "r").catch(() => void 0);
|
|
85
|
-
if (!handle) return false;
|
|
86
|
-
try {
|
|
87
|
-
const { buffer, bytesRead } = await handle.read(Buffer.alloc(4), 0, 4, 0);
|
|
88
|
-
if (bytesRead < 4) return false;
|
|
89
|
-
const magic = buffer.readUInt32BE(0);
|
|
90
|
-
const native = buffer.toString("latin1") === "\x7FELF" || buffer.subarray(0, 2).toString("latin1") === "MZ" || [4277009102, 4277009103, 3472551422, 3489328638, 3405691582].includes(magic);
|
|
91
|
-
if (!native) return false;
|
|
92
|
-
const marker = Buffer.from(EXECUTABLE_MARKER, "latin1");
|
|
93
|
-
const chunk = Buffer.alloc(1 << 20);
|
|
94
|
-
let tail2 = Buffer.alloc(0);
|
|
95
|
-
for (let position = 0; ; ) {
|
|
96
|
-
const { bytesRead: read } = await handle.read(chunk, 0, chunk.length, position);
|
|
97
|
-
if (!read) return false;
|
|
98
|
-
const window = Buffer.concat([tail2, chunk.subarray(0, read)]);
|
|
99
|
-
if (window.includes(marker)) return true;
|
|
100
|
-
tail2 = window.subarray(Math.max(0, window.length - marker.length + 1));
|
|
101
|
-
position += read;
|
|
102
|
-
}
|
|
103
|
-
} finally {
|
|
104
|
-
await handle.close();
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
82
|
var BIN_DIRECTORIES = [path.join(os.homedir(), ".alp", "bin"), path.join(os.homedir(), ".npm-global", "bin"), path.join(os.homedir(), ".local", "bin"), "/opt/homebrew/bin", "/usr/local/bin"];
|
|
108
83
|
var CLI_PACKAGES = ["@anhlp/alp", "@anhlp/alp-cli"];
|
|
109
|
-
async function
|
|
110
|
-
|
|
111
|
-
const root = path.resolve(path.dirname(
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
84
|
+
async function cliDaemonEntry(cli) {
|
|
85
|
+
const base = path.basename(cli).toLowerCase();
|
|
86
|
+
const root = path.resolve(path.dirname(cli), "..");
|
|
87
|
+
const alpd = (directory) => path.join(directory, "dist", "alpd.js");
|
|
88
|
+
const named = async (directory) => readFile(path.join(directory, "package.json"), "utf8").then((text) => JSON.parse(text)?.name).catch(() => void 0);
|
|
89
|
+
let candidates = [];
|
|
90
|
+
if (base === "alp" || base === "alp.cmd") {
|
|
91
|
+
if (!await isFile(path.join(root, "alp-bundle.json"))) return void 0;
|
|
92
|
+
const current = path.join(path.dirname(root), "current");
|
|
93
|
+
const viaCurrent = await realpath(current).then((real) => real === root, () => false);
|
|
94
|
+
candidates = [alpd(path.join(viaCurrent ? current : root, "lib", "node_modules", "@anhlp", "alp-cli"))];
|
|
95
|
+
} else if (base === "cli.js" && CLI_PACKAGES.includes(await named(root))) {
|
|
96
|
+
candidates = [alpd(root)];
|
|
97
|
+
} else if (base === "alp.js" && await named(root) === "@anhlp/alp") {
|
|
98
|
+
candidates = [alpd(path.join(root, "node_modules", "@anhlp", "alp-cli")), alpd(path.join(root, "..", "alp-cli"))];
|
|
118
99
|
}
|
|
100
|
+
for (const candidate of candidates) if (await isFile(candidate)) return candidate;
|
|
119
101
|
return void 0;
|
|
120
102
|
}
|
|
121
103
|
async function findDaemonEntry({ home = alpHome(), env = process.env, candidates = (
|
|
@@ -123,23 +105,17 @@ async function findDaemonEntry({ home = alpHome(), env = process.env, candidates
|
|
|
123
105
|
[]
|
|
124
106
|
) } = {}) {
|
|
125
107
|
for (const candidate of candidates) if (candidate && await isFile(candidate)) return candidate;
|
|
126
|
-
const own = executablePath();
|
|
127
|
-
if (own) return own;
|
|
128
108
|
try {
|
|
129
109
|
const { entry } = JSON.parse(await readFile(daemonPaths(home).install, "utf8"));
|
|
130
110
|
if (typeof entry === "string" && await isFile(entry)) return entry;
|
|
131
111
|
} catch {
|
|
132
112
|
}
|
|
133
113
|
for (const directory of [...(env.PATH ?? "").split(path.delimiter).filter(Boolean), ...BIN_DIRECTORIES]) {
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
const root = path.resolve(path.dirname(cli), "..");
|
|
140
|
-
const name = await readFile(path.join(root, "package.json"), "utf8").then((text) => JSON.parse(text)?.name).catch(() => void 0);
|
|
141
|
-
const entry = path.join(root, "dist", "alpd.js");
|
|
142
|
-
if (CLI_PACKAGES.includes(name) && await isFile(entry)) return entry;
|
|
114
|
+
for (const name of process.platform === "win32" ? ["alp.cmd", "alp"] : ["alp"]) {
|
|
115
|
+
const cli = await realpath(path.join(directory, name)).catch(() => void 0);
|
|
116
|
+
const entry = cli && await cliDaemonEntry(cli);
|
|
117
|
+
if (entry) return entry;
|
|
118
|
+
}
|
|
143
119
|
}
|
|
144
120
|
return void 0;
|
|
145
121
|
}
|
package/dist/rpc/registry.d.ts
CHANGED
|
@@ -178,6 +178,15 @@ export function conversation(client: {
|
|
|
178
178
|
resumeCommand: (params: {
|
|
179
179
|
sessionId: string;
|
|
180
180
|
}) => Promise<import("@anhlp/alp-protocol").ResumeCommand>;
|
|
181
|
+
/**
|
|
182
|
+
* The slash commands and skills the session's composer offers after "/" (capability `session.commands`, §12.12).
|
|
183
|
+
* @param {Map['session.commands']['params']} params @returns {Promise<Map['session.commands']['result']>}
|
|
184
|
+
*/
|
|
185
|
+
commands: (params: {
|
|
186
|
+
sessionId: string;
|
|
187
|
+
}) => Promise<{
|
|
188
|
+
commands: import("@anhlp/alp-protocol").SessionCommand[];
|
|
189
|
+
}>;
|
|
181
190
|
/**
|
|
182
191
|
* Changes a live root's model, effort or team (capability `session.configure.live`, §12.9) at the
|
|
183
192
|
* idle barrier, through a restart of its native process on the same conversation; `configured` says
|
package/dist/rpc/registry.js
CHANGED
|
@@ -193,6 +193,11 @@ function conversation(client) {
|
|
|
193
193
|
* @param {Map['session.resumeCommand']['params']} params @returns {Promise<Map['session.resumeCommand']['result']>}
|
|
194
194
|
*/
|
|
195
195
|
resumeCommand: (params) => client.request("session.resumeCommand", params),
|
|
196
|
+
/**
|
|
197
|
+
* The slash commands and skills the session's composer offers after "/" (capability `session.commands`, §12.12).
|
|
198
|
+
* @param {Map['session.commands']['params']} params @returns {Promise<Map['session.commands']['result']>}
|
|
199
|
+
*/
|
|
200
|
+
commands: (params) => client.request("session.commands", params),
|
|
196
201
|
/**
|
|
197
202
|
* Changes a live root's model, effort or team (capability `session.configure.live`, §12.9) at the
|
|
198
203
|
* idle barrier, through a restart of its native process on the same conversation; `configured` says
|
package/dist/service.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export function serviceFor({ home, env, platform, uid }: {
|
|
|
32
32
|
ignore: boolean;
|
|
33
33
|
})[][];
|
|
34
34
|
} | undefined;
|
|
35
|
-
/** The service definition that runs `entry` (alpd.js with `execPath`, or
|
|
35
|
+
/** The service definition that runs `entry` (alpd.js with `execPath`, or an `alp` command) for `home`. */
|
|
36
36
|
export function serviceDefinition(service: any, { home, entry, execPath, env }: {
|
|
37
37
|
home: any;
|
|
38
38
|
entry: any;
|
package/dist/service.js
CHANGED
|
@@ -4,7 +4,7 @@ import { mkdir, readFile, unlink, writeFile } from "node:fs/promises";
|
|
|
4
4
|
import os from "node:os";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { runCommand } from "./command.js";
|
|
7
|
-
import { entryCommand } from "@anhlp/alp-core/packaged";
|
|
7
|
+
import { entryCommand, stablePath } from "@anhlp/alp-core/packaged";
|
|
8
8
|
var CARRIED = ["ALP_RUN_LOG_DIR", "ALP_CODEX_BIN", "ALP_CLAUDE_BIN", "ALP_ANTIGRAVITY_BIN", "ALP_GH_BIN"];
|
|
9
9
|
var escapeXml = (value) => value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
10
10
|
var quoteUnit = (value) => `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
@@ -45,7 +45,7 @@ function serviceFor({ home, env = process.env, platform = process.platform, uid
|
|
|
45
45
|
function serviceDefinition(service, { home, entry, execPath = process.execPath, env = process.env }) {
|
|
46
46
|
const variables = { ALP_HOME: path.resolve(home), PATH: env.PATH ?? "" };
|
|
47
47
|
for (const name of CARRIED) if (env[name]) variables[name] = env[name];
|
|
48
|
-
const launch = entryCommand(entry, "daemon", ["--service"], execPath);
|
|
48
|
+
const launch = entryCommand(stablePath(entry), "daemon", ["--service"], stablePath(execPath));
|
|
49
49
|
const program = [launch.command, ...launch.args];
|
|
50
50
|
const fatal = path.join(path.resolve(home), "logs", "alpd.service.log");
|
|
51
51
|
if (service.kind === "launchd") {
|
package/dist/setup.js
CHANGED
|
@@ -126,7 +126,8 @@ async function profiles(root, home, seats, peers, settings) {
|
|
|
126
126
|
const team = await resolveTeam(root, id, { library: home });
|
|
127
127
|
const agents = {};
|
|
128
128
|
const seat = (name, choices) => {
|
|
129
|
-
|
|
129
|
+
const old = (settings?.team ?? settings?.profile)?.[id]?.[name];
|
|
130
|
+
agents[name] = { profiles: choices.map((choice) => typeof choice === "string" ? choice : describe(choice)), autocompact: old?.autocompact ?? "auto", ...old?.commands ? { commands: old.commands } : {} };
|
|
130
131
|
};
|
|
131
132
|
for (const [name, member] of Object.entries(team.members)) {
|
|
132
133
|
if (name !== "oracle") seat(name, name === team.main ? seats.main : member.role === "peer" ? peers : seats.worker);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anhlp/alp-client",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "ALP client: portable JSON-RPC SDK, WebSocket and Node IPC transports, daemon discovery and setup",
|
|
6
6
|
"files": [
|
|
@@ -150,8 +150,8 @@
|
|
|
150
150
|
"node": ">=22.12"
|
|
151
151
|
},
|
|
152
152
|
"dependencies": {
|
|
153
|
-
"@anhlp/alp-core": "0.0.1-beta.
|
|
154
|
-
"@anhlp/alp-protocol": "0.0.1-beta.
|
|
153
|
+
"@anhlp/alp-core": "0.0.1-beta.7",
|
|
154
|
+
"@anhlp/alp-protocol": "0.0.1-beta.7"
|
|
155
155
|
},
|
|
156
156
|
"scripts": {
|
|
157
157
|
"build": "node ../../scripts/build-workspace.mjs client",
|
package/src/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import os from 'node:os';
|
|
|
8
8
|
import path from 'node:path';
|
|
9
9
|
|
|
10
10
|
import { scrubText } from '@anhlp/alp-core/log';
|
|
11
|
-
import {
|
|
11
|
+
import { entryCommand } from '@anhlp/alp-core/packaged';
|
|
12
12
|
import { createSocketTransport } from './ipc.js';
|
|
13
13
|
import { AlpRpcClient } from './rpc/client.js';
|
|
14
14
|
import { hello } from './rpc/handshake.js';
|
|
@@ -89,37 +89,6 @@ export async function assertPrivateSocket(socketPath) {
|
|
|
89
89
|
|
|
90
90
|
const isFile = file => stat(file).then(info => info.isFile(), () => false);
|
|
91
91
|
|
|
92
|
-
/**
|
|
93
|
-
* Whether `file` is the self-contained ALP executable (t-1e02) rather than a script or a shell
|
|
94
|
-
* wrapper: a native image (Mach-O, ELF or PE) named alp that carries ALP's executable marker.
|
|
95
|
-
* @param {string} file
|
|
96
|
-
*/
|
|
97
|
-
async function isAlpExecutable(file) {
|
|
98
|
-
if (isScript(file) || !isExecutableName(file) || !await isFile(file)) return false;
|
|
99
|
-
const handle = await open(file, 'r').catch(() => undefined);
|
|
100
|
-
if (!handle) return false;
|
|
101
|
-
try {
|
|
102
|
-
const { buffer, bytesRead } = await handle.read(Buffer.alloc(4), 0, 4, 0);
|
|
103
|
-
if (bytesRead < 4) return false;
|
|
104
|
-
const magic = buffer.readUInt32BE(0);
|
|
105
|
-
const native = buffer.toString('latin1') === '\x7fELF' || buffer.subarray(0, 2).toString('latin1') === 'MZ'
|
|
106
|
-
|| [0xfeedface, 0xfeedfacf, 0xcefaedfe, 0xcffaedfe, 0xcafebabe].includes(magic);
|
|
107
|
-
if (!native) return false;
|
|
108
|
-
// Identity without running it: ALP's generated entry embeds EXECUTABLE_MARKER (an unrelated `alp` does not).
|
|
109
|
-
const marker = Buffer.from(EXECUTABLE_MARKER, 'latin1');
|
|
110
|
-
const chunk = Buffer.alloc(1 << 20);
|
|
111
|
-
let tail = Buffer.alloc(0);
|
|
112
|
-
for (let position = 0; ;) {
|
|
113
|
-
const { bytesRead: read } = await handle.read(chunk, 0, chunk.length, position);
|
|
114
|
-
if (!read) return false;
|
|
115
|
-
const window = Buffer.concat([tail, chunk.subarray(0, read)]);
|
|
116
|
-
if (window.includes(marker)) return true;
|
|
117
|
-
tail = window.subarray(Math.max(0, window.length - marker.length + 1));
|
|
118
|
-
position += read;
|
|
119
|
-
}
|
|
120
|
-
} finally { await handle.close(); }
|
|
121
|
-
}
|
|
122
|
-
|
|
123
92
|
/** Global bin directories that a GUI app's PATH may lack. */
|
|
124
93
|
const BIN_DIRECTORIES = [path.join(os.homedir(), '.alp', 'bin'), path.join(os.homedir(), '.npm-global', 'bin'), path.join(os.homedir(), '.local', 'bin'), '/opt/homebrew/bin', '/usr/local/bin'];
|
|
125
94
|
|
|
@@ -127,21 +96,29 @@ const BIN_DIRECTORIES = [path.join(os.homedir(), '.alp', 'bin'), path.join(os.ho
|
|
|
127
96
|
const CLI_PACKAGES = ['@anhlp/alp', '@anhlp/alp-cli'];
|
|
128
97
|
|
|
129
98
|
/**
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
* @param {string}
|
|
99
|
+
* alpd.js behind an `alp` found on PATH (its real path), or undefined: the ALP bundle's launcher
|
|
100
|
+
* (<bundle>/bin/alp or alp.cmd, t-1807), npm's @anhlp/alp-cli (dist/cli.js) or the @anhlp/alp wrapper (bin/alp.js),
|
|
101
|
+
* which depends on @anhlp/alp-cli (installed beside it, or in its own node_modules).
|
|
102
|
+
* @param {string} cli
|
|
134
103
|
*/
|
|
135
|
-
async function
|
|
136
|
-
|
|
137
|
-
const root = path.resolve(path.dirname(
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
if (await
|
|
104
|
+
async function cliDaemonEntry(cli) {
|
|
105
|
+
const base = path.basename(cli).toLowerCase();
|
|
106
|
+
const root = path.resolve(path.dirname(cli), '..');
|
|
107
|
+
const alpd = directory => path.join(directory, 'dist', 'alpd.js');
|
|
108
|
+
const named = async directory => readFile(path.join(directory, 'package.json'), 'utf8').then(text => JSON.parse(text)?.name).catch(() => undefined);
|
|
109
|
+
let candidates = [];
|
|
110
|
+
if (base === 'alp' || base === 'alp.cmd') {
|
|
111
|
+
// A bundle: bin/ beside alp-bundle.json; name alpd through app/current when that is this bundle.
|
|
112
|
+
if (!await isFile(path.join(root, 'alp-bundle.json'))) return undefined;
|
|
113
|
+
const current = path.join(path.dirname(root), 'current');
|
|
114
|
+
const viaCurrent = await realpath(current).then(real => real === root, () => false);
|
|
115
|
+
candidates = [alpd(path.join(viaCurrent ? current : root, 'lib', 'node_modules', '@anhlp', 'alp-cli'))];
|
|
116
|
+
} else if (base === 'cli.js' && CLI_PACKAGES.includes(await named(root))) {
|
|
117
|
+
candidates = [alpd(root)];
|
|
118
|
+
} else if (base === 'alp.js' && await named(root) === '@anhlp/alp') {
|
|
119
|
+
candidates = [alpd(path.join(root, 'node_modules', '@anhlp', 'alp-cli')), alpd(path.join(root, '..', 'alp-cli'))];
|
|
144
120
|
}
|
|
121
|
+
for (const candidate of candidates) if (await isFile(candidate)) return candidate;
|
|
145
122
|
return undefined;
|
|
146
123
|
}
|
|
147
124
|
|
|
@@ -152,23 +129,16 @@ async function npmWrapperExecutable(launcher, platform = process.platform, arch
|
|
|
152
129
|
*/
|
|
153
130
|
export async function findDaemonEntry({ home = alpHome(), env = process.env, candidates = /** @type {Array<string | undefined>} */ ([]) } = {}) {
|
|
154
131
|
for (const candidate of candidates) if (candidate && await isFile(candidate)) return candidate;
|
|
155
|
-
// The ALP executable carries alpd itself (`alp daemon run`).
|
|
156
|
-
const own = executablePath();
|
|
157
|
-
if (own) return own;
|
|
158
132
|
try {
|
|
159
133
|
const { entry } = JSON.parse(await readFile(daemonPaths(home).install, 'utf8'));
|
|
160
134
|
if (typeof entry === 'string' && await isFile(entry)) return entry;
|
|
161
135
|
} catch {}
|
|
162
136
|
for (const directory of [...(env.PATH ?? '').split(path.delimiter).filter(Boolean), ...BIN_DIRECTORIES]) {
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const root = path.resolve(path.dirname(cli), '..');
|
|
169
|
-
const name = await readFile(path.join(root, 'package.json'), 'utf8').then(text => JSON.parse(text)?.name).catch(() => undefined);
|
|
170
|
-
const entry = path.join(root, 'dist', 'alpd.js');
|
|
171
|
-
if (CLI_PACKAGES.includes(name) && await isFile(entry)) return entry;
|
|
137
|
+
for (const name of process.platform === 'win32' ? ['alp.cmd', 'alp'] : ['alp']) {
|
|
138
|
+
const cli = await realpath(path.join(directory, name)).catch(() => undefined);
|
|
139
|
+
const entry = cli && await cliDaemonEntry(cli);
|
|
140
|
+
if (entry) return entry;
|
|
141
|
+
}
|
|
172
142
|
}
|
|
173
143
|
return undefined;
|
|
174
144
|
}
|
|
@@ -754,7 +724,7 @@ export async function startIntegration(nameOrOptions = 'web') {
|
|
|
754
724
|
// The child is detached with its stdio ignored, so it cannot rely on the parent's console. `--service`
|
|
755
725
|
// is the generic contract: the entry writes its own log (the path its error messages advertise) and
|
|
756
726
|
// keeps the process alive as a service. `--register` still prints to stdout and is not passed here.
|
|
757
|
-
// alp-web may be
|
|
727
|
+
// alp-web may be an `alp` command (`alp web serve`); other integrations are scripts.
|
|
758
728
|
const launch = name === 'web' ? entryCommand(entry, 'web', ['--service', ...args]) : entryCommand(entry, 'web', ['--service', ...args], undefined, { scriptOnly: true });
|
|
759
729
|
const child = spawn(launch.command, launch.args, { stdio: 'ignore', detached: true, env: { ...process.env, ALP_HOME: home } });
|
|
760
730
|
let spawnError = null;
|
package/src/rpc/registry.js
CHANGED
|
@@ -206,6 +206,11 @@ export function conversation(client) {
|
|
|
206
206
|
* @param {Map['session.resumeCommand']['params']} params @returns {Promise<Map['session.resumeCommand']['result']>}
|
|
207
207
|
*/
|
|
208
208
|
resumeCommand: params => client.request('session.resumeCommand', params),
|
|
209
|
+
/**
|
|
210
|
+
* The slash commands and skills the session's composer offers after "/" (capability `session.commands`, §12.12).
|
|
211
|
+
* @param {Map['session.commands']['params']} params @returns {Promise<Map['session.commands']['result']>}
|
|
212
|
+
*/
|
|
213
|
+
commands: params => client.request('session.commands', params),
|
|
209
214
|
/**
|
|
210
215
|
* Changes a live root's model, effort or team (capability `session.configure.live`, §12.9) at the
|
|
211
216
|
* idle barrier, through a restart of its native process on the same conversation; `configured` says
|
package/src/service.js
CHANGED
|
@@ -3,7 +3,7 @@ import { mkdir, readFile, unlink, writeFile } from 'node:fs/promises';
|
|
|
3
3
|
import os from 'node:os';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { runCommand } from './command.js';
|
|
6
|
-
import { entryCommand } from '@anhlp/alp-core/packaged';
|
|
6
|
+
import { entryCommand, stablePath } from '@anhlp/alp-core/packaged';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* alpd as a user service (ALPD §37): a LaunchAgent on macOS, a systemd user unit on
|
|
@@ -54,12 +54,13 @@ export function serviceFor({ home, env = process.env, platform = process.platfor
|
|
|
54
54
|
return undefined;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
/** The service definition that runs `entry` (alpd.js with `execPath`, or
|
|
57
|
+
/** The service definition that runs `entry` (alpd.js with `execPath`, or an `alp` command) for `home`. */
|
|
58
58
|
export function serviceDefinition(service, { home, entry, execPath = process.execPath, env = process.env }) {
|
|
59
59
|
const variables = { ALP_HOME: path.resolve(home), PATH: env.PATH ?? '' };
|
|
60
60
|
for (const name of CARRIED) if (env[name]) variables[name] = env[name];
|
|
61
|
-
// A script entry runs under execPath;
|
|
62
|
-
|
|
61
|
+
// A script entry runs under execPath; an `alp` command runs `alp daemon run --service`. Inside the
|
|
62
|
+
// ALP bundle both name it through app/current, so `alp update` never leaves the service on a removed version.
|
|
63
|
+
const launch = entryCommand(stablePath(entry), 'daemon', ['--service'], stablePath(execPath));
|
|
63
64
|
const program = [launch.command, ...launch.args];
|
|
64
65
|
const fatal = path.join(path.resolve(home), 'logs', 'alpd.service.log');
|
|
65
66
|
if (service.kind === 'launchd') {
|
package/src/setup.js
CHANGED
|
@@ -125,14 +125,15 @@ async function change(seats, home) {
|
|
|
125
125
|
seats[seat][at] = { provider: current.provider, model, ...(effort ? { effort } : {}) };
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
/** Every Phở and Cafe agent's profiles, keeping each agent's own compaction setting. */
|
|
128
|
+
/** Every Phở and Cafe agent's profiles, keeping each agent's own compaction setting and "/" commands (t-efa3). */
|
|
129
129
|
async function profiles(root, home, seats, peers, settings) {
|
|
130
130
|
const profile = {};
|
|
131
131
|
for (const id of ['pho', 'cafe']) {
|
|
132
132
|
const team = await resolveTeam(root, id, { library: home });
|
|
133
133
|
const agents = {};
|
|
134
134
|
const seat = (name, choices) => {
|
|
135
|
-
|
|
135
|
+
const old = (settings?.team ?? settings?.profile)?.[id]?.[name];
|
|
136
|
+
agents[name] = { profiles: choices.map(choice => typeof choice === 'string' ? choice : describe(choice)), autocompact: old?.autocompact ?? 'auto', ...(old?.commands ? { commands: old.commands } : {}) };
|
|
136
137
|
};
|
|
137
138
|
for (const [name, member] of Object.entries(team.members)) {
|
|
138
139
|
if (name !== 'oracle') seat(name, name === team.main ? seats.main : member.role === 'peer' ? peers : seats.worker);
|