@agentconnect.md/daemon 1.0.0-rc.296 → 1.0.0-rc.298
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/dist/{acp-host-03mQVw2Q.js → acp-host-DezWSmEG.js} +2 -2
- package/dist/{acp-host-03mQVw2Q.js.map → acp-host-DezWSmEG.js.map} +1 -1
- package/dist/{agent-list-DHFLd9ux.js → agent-list-Da9Osn4O.js} +2 -2
- package/dist/{agent-list-DHFLd9ux.js.map → agent-list-Da9Osn4O.js.map} +1 -1
- package/dist/{chat-IRJd4_lj.js → chat-D8QIIHor.js} +3 -3
- package/dist/{chat-IRJd4_lj.js.map → chat-D8QIIHor.js.map} +1 -1
- package/dist/{load-agents-8AzZXdVx.js → dist-Cq1Kimg_.js} +18 -399
- package/dist/dist-Cq1Kimg_.js.map +1 -0
- package/dist/gh-token-BfPlYQav.js +97 -0
- package/dist/gh-token-BfPlYQav.js.map +1 -0
- package/dist/{git-credential-DLRF9bOx.js → git-credential-DhWn1IBJ.js} +26 -8
- package/dist/git-credential-DhWn1IBJ.js.map +1 -0
- package/dist/{gitcred-server-Dhp-tyEI.js → gitcred-server-KXxLyYxc.js} +107 -55
- package/dist/gitcred-server-KXxLyYxc.js.map +1 -0
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/dist/load-agents-gTqVkOwl.js +401 -0
- package/dist/load-agents-gTqVkOwl.js.map +1 -0
- package/dist/{login-vU_lQeMG.js → login-ycknK_Ag.js} +4 -3
- package/dist/{login-vU_lQeMG.js.map → login-ycknK_Ag.js.map} +1 -1
- package/dist/run-foreground-B5Uw1HWo.js +2 -0
- package/dist/{run-foreground-DasVEmdw.js → run-foreground-qa22G1Nt.js} +172 -20
- package/dist/{run-foreground-DasVEmdw.js.map → run-foreground-qa22G1Nt.js.map} +1 -1
- package/package.json +1 -1
- package/dist/git-credential-DLRF9bOx.js.map +0 -1
- package/dist/gitcred-server-Dhp-tyEI.js.map +0 -1
- package/dist/load-agents-8AzZXdVx.js.map +0 -1
- package/dist/run-foreground-K-ATxgOm.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as loadConfig, t as discoverAgents } from "./load-agents-
|
|
1
|
+
import { o as loadConfig, t as discoverAgents } from "./load-agents-gTqVkOwl.js";
|
|
2
2
|
//#region src/cli/agent-list.ts
|
|
3
3
|
async function runAgentList(opts) {
|
|
4
4
|
const out = opts.out ?? process.stdout;
|
|
@@ -18,4 +18,4 @@ async function runAgentList(opts) {
|
|
|
18
18
|
//#endregion
|
|
19
19
|
export { runAgentList };
|
|
20
20
|
|
|
21
|
-
//# sourceMappingURL=agent-list-
|
|
21
|
+
//# sourceMappingURL=agent-list-Da9Osn4O.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-list-
|
|
1
|
+
{"version":3,"file":"agent-list-Da9Osn4O.js","names":[],"sources":["../src/cli/agent-list.ts"],"sourcesContent":["import { loadConfig } from '../config/load-config.js'\nimport { discoverAgents } from '../agents/load-agents.js'\n\nexport interface RunAgentListOpts {\n agentsDir?: string\n configPath?: string\n root?: string\n out?: NodeJS.WritableStream\n}\n\n// Read-only view of the local agent directory. Mutating agents (add/remove/\n// enable/disable) is intentionally not a CLI command — agent business config is\n// owned by the Control Plane (agent/upsert + register/ok roster, see\n// cp/cp-agent-registry.ts) or by hand-editing agent.json; the daemon only\n// reconciles what it finds on disk. This lists what that discovery sees.\nexport async function runAgentList(opts: RunAgentListOpts): Promise<void> {\n const out = opts.out ?? process.stdout\n const cfg = loadConfig({\n root: opts.root,\n configPath: opts.configPath,\n optional: true,\n overrides: { agentsDir: opts.agentsDir }\n })\n const agentsDir = cfg.agentsDir!\n const discovered = discoverAgents(agentsDir)\n if (discovered.length === 0) {\n out.write(`no agents found under ${agentsDir}\\n`)\n return\n }\n for (const { agent, dir } of discovered) {\n out.write(`${agent.id}\\t${agent.status}\\t${agent.runtime}\\t${agent.name}\\t${dir}\\n`)\n }\n}\n"],"mappings":";;AAeA,eAAsB,aAAa,MAAuC;CACxE,MAAM,MAAM,KAAK,OAAO,QAAQ;CAOhC,MAAM,YANM,WAAW;EACrB,MAAM,KAAK;EACX,YAAY,KAAK;EACjB,UAAU;EACV,WAAW,EAAE,WAAW,KAAK,UAAU;CACzC,CACoB,CAAC,CAAC;CACtB,MAAM,aAAa,eAAe,SAAS;CAC3C,IAAI,WAAW,WAAW,GAAG;EAC3B,IAAI,MAAM,yBAAyB,UAAU,GAAG;EAChD;CACF;CACA,KAAK,MAAM,EAAE,OAAO,SAAS,YAC3B,IAAI,MAAM,GAAG,MAAM,GAAG,IAAI,MAAM,OAAO,IAAI,MAAM,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,GAAG;AAEvF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as agentChildEnv, i as selectAgent, o as loadConfig } from "./load-agents-
|
|
1
|
+
import { a as agentChildEnv, i as selectAgent, o as loadConfig } from "./load-agents-gTqVkOwl.js";
|
|
2
2
|
import { l as resolveRoot } from "./paths-DEcUO8lC.js";
|
|
3
|
-
import { S as resolveRuntimes, d as memoryProviderFor, i as prepareWorkspace, t as AcpHost } from "./acp-host-
|
|
3
|
+
import { S as resolveRuntimes, d as memoryProviderFor, i as prepareWorkspace, t as AcpHost } from "./acp-host-DezWSmEG.js";
|
|
4
4
|
import { createInterface } from "node:readline";
|
|
5
5
|
//#region src/cli/chat.ts
|
|
6
6
|
function renderUpdate(out) {
|
|
@@ -84,4 +84,4 @@ async function runChat(opts) {
|
|
|
84
84
|
//#endregion
|
|
85
85
|
export { renderUpdate, runChat };
|
|
86
86
|
|
|
87
|
-
//# sourceMappingURL=chat-
|
|
87
|
+
//# sourceMappingURL=chat-D8QIIHor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-
|
|
1
|
+
{"version":3,"file":"chat-D8QIIHor.js","names":[],"sources":["../src/cli/chat.ts"],"sourcesContent":["import { createInterface } from 'node:readline'\nimport type { ContentBlock, SessionUpdate } from '@agentclientprotocol/sdk'\nimport { loadConfig } from '../config/load-config.js'\nimport { resolveRuntimes } from '../runtimes/registry.js'\nimport { selectAgent } from '../agents/load-agents.js'\nimport { agentChildEnv } from '../agents/agent-env.js'\nimport { memoryProviderFor } from '../agents/memory-provider.js'\nimport { prepareWorkspace } from '../workspace/workspace-manager.js'\nimport { AcpHost } from '../acp/acp-host.js'\nimport { resolveRoot } from '../paths.js'\n\nexport function renderUpdate(out: NodeJS.WritableStream) {\n return (_sessionId: string, update: SessionUpdate): void => {\n if (update.sessionUpdate === 'agent_message_chunk' && update.content.type === 'text') {\n out.write(update.content.text)\n } else if (update.sessionUpdate === 'tool_call') {\n const title = ('title' in update && update.title) || update.toolCallId || 'tool'\n out.write(`\\n[tool] ${title}\\n`)\n }\n }\n}\n\nexport interface RunChatOpts {\n agentsDir?: string\n agentName?: string\n message?: string\n configPath?: string\n root?: string\n out?: NodeJS.WritableStream\n input?: NodeJS.ReadableStream\n}\n\nexport async function runChat(opts: RunChatOpts): Promise<void> {\n const out = opts.out ?? process.stdout\n const root = resolveRoot(opts.root)\n const cfg = loadConfig({\n root: opts.root,\n configPath: opts.configPath,\n optional: true,\n overrides: { agentsDir: opts.agentsDir }\n })\n const agent = selectAgent(cfg.agentsDir!, opts.agentName)\n\n const runtimes = await resolveRuntimes(cfg, root, { neededRuntimes: [agent.runtime], mode: 'cache-first' })\n const runtime = runtimes[agent.runtime]\n if (!runtime) {\n const available = Object.keys(runtimes).sort().join(', ') || '(none)'\n throw new Error(`runtime \"${agent.runtime}\" not found. Available: ${available}`)\n }\n\n const host = new AcpHost(runtime, {\n onUpdate: renderUpdate(out),\n // Memory-backend env for parity with the daemon (managed disables the runtime's\n // own memory; native redirects it under the agent root).\n env: { ...agentChildEnv(agent), ...memoryProviderFor(agent, runtime).runtimeEnv() },\n configPrefs: {\n model: agent.runtimeOverrides?.model,\n permissionMode: agent.permissionMode,\n reasoningEffort: agent.reasoningEffort,\n fastMode: agent.fastMode\n }\n })\n // The adapter child runs in its own process group (see AcpHost.start), so a\n // terminal Ctrl-C no longer kills it as a side effect — Node's default SIGINT\n // exit would skip the finally below and leak it. Stop the host, then re-exit.\n // Registered BEFORE start(): a first-run `npx -y` runtime download takes long\n // enough that Ctrl-C mid-start is common, and the spawn happens early in start().\n const onSigint = () => {\n void host.stop().finally(() => process.exit(130))\n }\n process.once('SIGINT', onSigint)\n try {\n await host.start()\n const cwd = await prepareWorkspace(agent)\n const sessionId = await host.newSession(cwd)\n\n const send = async (text: string) => {\n const blocks: ContentBlock[] = [{ type: 'text', text }]\n await host.prompt(sessionId, blocks)\n out.write('\\n')\n }\n\n if (typeof opts.message === 'string' && opts.message.length > 0) {\n await send(opts.message)\n return\n }\n\n const rl = createInterface({ input: opts.input ?? process.stdin })\n out.write(`Chatting with ${agent.name} (${agent.id}). Type .exit to quit.\\n> `)\n try {\n for await (const line of rl) {\n const text = line.trim()\n if (text === '.exit' || text === '.quit') break\n if (text.length > 0) await send(text)\n out.write('> ')\n }\n } finally {\n rl.close()\n }\n } finally {\n process.removeListener('SIGINT', onSigint)\n await host.stop()\n }\n}\n"],"mappings":";;;;;AAWA,SAAgB,aAAa,KAA4B;CACvD,QAAQ,YAAoB,WAAgC;EAC1D,IAAI,OAAO,kBAAkB,yBAAyB,OAAO,QAAQ,SAAS,QAC5E,IAAI,MAAM,OAAO,QAAQ,IAAI;OACxB,IAAI,OAAO,kBAAkB,aAAa;GAC/C,MAAM,QAAS,WAAW,UAAU,OAAO,SAAU,OAAO,cAAc;GAC1E,IAAI,MAAM,YAAY,MAAM,GAAG;EACjC;CACF;AACF;AAYA,eAAsB,QAAQ,MAAkC;CAC9D,MAAM,MAAM,KAAK,OAAO,QAAQ;CAChC,MAAM,OAAO,YAAY,KAAK,IAAI;CAClC,MAAM,MAAM,WAAW;EACrB,MAAM,KAAK;EACX,YAAY,KAAK;EACjB,UAAU;EACV,WAAW,EAAE,WAAW,KAAK,UAAU;CACzC,CAAC;CACD,MAAM,QAAQ,YAAY,IAAI,WAAY,KAAK,SAAS;CAExD,MAAM,WAAW,MAAM,gBAAgB,KAAK,MAAM;EAAE,gBAAgB,CAAC,MAAM,OAAO;EAAG,MAAM;CAAc,CAAC;CAC1G,MAAM,UAAU,SAAS,MAAM;CAC/B,IAAI,CAAC,SAAS;EACZ,MAAM,YAAY,OAAO,KAAK,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI,KAAK;EAC7D,MAAM,IAAI,MAAM,YAAY,MAAM,QAAQ,0BAA0B,WAAW;CACjF;CAEA,MAAM,OAAO,IAAI,QAAQ,SAAS;EAChC,UAAU,aAAa,GAAG;EAG1B,KAAK;GAAE,GAAG,cAAc,KAAK;GAAG,GAAG,kBAAkB,OAAO,OAAO,CAAC,CAAC,WAAW;EAAE;EAClF,aAAa;GACX,OAAO,MAAM,kBAAkB;GAC/B,gBAAgB,MAAM;GACtB,iBAAiB,MAAM;GACvB,UAAU,MAAM;EAClB;CACF,CAAC;CAMD,MAAM,iBAAiB;EACrB,KAAU,KAAK,CAAC,CAAC,cAAc,QAAQ,KAAK,GAAG,CAAC;CAClD;CACA,QAAQ,KAAK,UAAU,QAAQ;CAC/B,IAAI;EACF,MAAM,KAAK,MAAM;EACjB,MAAM,MAAM,MAAM,iBAAiB,KAAK;EACxC,MAAM,YAAY,MAAM,KAAK,WAAW,GAAG;EAE3C,MAAM,OAAO,OAAO,SAAiB;GACnC,MAAM,SAAyB,CAAC;IAAE,MAAM;IAAQ;GAAK,CAAC;GACtD,MAAM,KAAK,OAAO,WAAW,MAAM;GACnC,IAAI,MAAM,IAAI;EAChB;EAEA,IAAI,OAAO,KAAK,YAAY,YAAY,KAAK,QAAQ,SAAS,GAAG;GAC/D,MAAM,KAAK,KAAK,OAAO;GACvB;EACF;EAEA,MAAM,KAAK,gBAAgB,EAAE,OAAO,KAAK,SAAS,QAAQ,MAAM,CAAC;EACjE,IAAI,MAAM,iBAAiB,MAAM,KAAK,IAAI,MAAM,GAAG,2BAA2B;EAC9E,IAAI;GACF,WAAW,MAAM,QAAQ,IAAI;IAC3B,MAAM,OAAO,KAAK,KAAK;IACvB,IAAI,SAAS,WAAW,SAAS,SAAS;IAC1C,IAAI,KAAK,SAAS,GAAG,MAAM,KAAK,IAAI;IACpC,IAAI,MAAM,IAAI;GAChB;EACF,UAAU;GACR,GAAG,MAAM;EACX;CACF,UAAU;EACR,QAAQ,eAAe,UAAU,QAAQ;EACzC,MAAM,KAAK,KAAK;CAClB;AACF"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { _ as record, a as array, b as unknown, c as discriminatedUnion, d as literal, m as object, n as _enum, o as boolean, p as number, v as string, y as union } from "./schemas-CQkO9hC5.js";
|
|
2
|
-
import { l as resolveRoot, r as defaultAgentsDir, t as configPath } from "./paths-DEcUO8lC.js";
|
|
3
|
-
import { dirname, isAbsolute, join, resolve } from "node:path";
|
|
4
|
-
import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
|
5
2
|
import { randomUUID } from "node:crypto";
|
|
6
3
|
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/compat.js
|
|
7
4
|
/** @deprecated Use the raw string literal codes instead, e.g. "invalid_type". */
|
|
@@ -747,7 +744,7 @@ const GitCredRequest = object({
|
|
|
747
744
|
"helper"
|
|
748
745
|
]).optional(),
|
|
749
746
|
capabilities: array(GitCredCapability).nonempty().optional(),
|
|
750
|
-
|
|
747
|
+
repoFullName: string().optional()
|
|
751
748
|
});
|
|
752
749
|
const GitCredGrant = object({
|
|
753
750
|
username: literal("x-access-token"),
|
|
@@ -2093,6 +2090,21 @@ function normalizeGitUrl(input) {
|
|
|
2093
2090
|
if (segments.length === 2 && segments.every((p) => p.length > 0)) return `https://github.com/${s}`;
|
|
2094
2091
|
return s;
|
|
2095
2092
|
}
|
|
2093
|
+
/**
|
|
2094
|
+
* Shorten a stored git address to the `org/repo` display form.
|
|
2095
|
+
* `https://github.com/acme/infra.git` / `git@github.com:acme/infra` → `acme/infra`.
|
|
2096
|
+
* Unrecognized inputs come back unchanged (minus a trailing `.git`).
|
|
2097
|
+
*/
|
|
2098
|
+
function gitRepoLabel(gitRepo) {
|
|
2099
|
+
const s = gitRepo.trim().replace(/\/+$/, "").replace(/\.git$/, "");
|
|
2100
|
+
const scp = SCP_RE.exec(s);
|
|
2101
|
+
if (scp) return scp[1].replace(/^\/+/, "");
|
|
2102
|
+
const url = /^[a-z][a-z0-9+.-]*:\/\/[^/]+\/(.+)$/i.exec(s);
|
|
2103
|
+
if (url) return url[1];
|
|
2104
|
+
const segments = s.split("/");
|
|
2105
|
+
if (segments.length >= 3 && segments[0].includes(".")) return segments.slice(1).join("/");
|
|
2106
|
+
return s;
|
|
2107
|
+
}
|
|
2096
2108
|
//#endregion
|
|
2097
2109
|
//#region ../protocol/dist/index.js
|
|
2098
2110
|
/**
|
|
@@ -2103,399 +2115,6 @@ function isFrame(type) {
|
|
|
2103
2115
|
return (frame) => frame.type === type;
|
|
2104
2116
|
}
|
|
2105
2117
|
//#endregion
|
|
2106
|
-
|
|
2107
|
-
/** The `{name, value}[]` shape shared by runtime env, MCP env, and MCP headers. */
|
|
2108
|
-
const NameValueList = array(object({
|
|
2109
|
-
name: string(),
|
|
2110
|
-
value: string()
|
|
2111
|
-
})).default([]);
|
|
2112
|
-
const RuntimeDefSchema = object({
|
|
2113
|
-
command: string(),
|
|
2114
|
-
args: array(string()).default([]),
|
|
2115
|
-
env: NameValueList
|
|
2116
|
-
});
|
|
2117
|
-
const McpServerDefSchema = object({
|
|
2118
|
-
transport: _enum([
|
|
2119
|
-
"stdio",
|
|
2120
|
-
"http",
|
|
2121
|
-
"sse"
|
|
2122
|
-
]).default("stdio"),
|
|
2123
|
-
command: string().optional(),
|
|
2124
|
-
args: array(string()).default([]),
|
|
2125
|
-
env: NameValueList,
|
|
2126
|
-
url: string().optional(),
|
|
2127
|
-
headers: NameValueList
|
|
2128
|
-
}).superRefine((def, ctx) => {
|
|
2129
|
-
if (def.transport === "stdio" && !def.command) ctx.addIssue({
|
|
2130
|
-
code: "custom",
|
|
2131
|
-
path: ["command"],
|
|
2132
|
-
message: "a stdio MCP server requires \"command\""
|
|
2133
|
-
});
|
|
2134
|
-
if (def.transport !== "stdio" && !def.url) ctx.addIssue({
|
|
2135
|
-
code: "custom",
|
|
2136
|
-
path: ["url"],
|
|
2137
|
-
message: `a ${def.transport} MCP server requires "url"`
|
|
2138
|
-
});
|
|
2139
|
-
});
|
|
2140
|
-
const ConfigSchema = object({
|
|
2141
|
-
version: literal(1),
|
|
2142
|
-
daemonId: string().optional(),
|
|
2143
|
-
webAppUrl: string().optional(),
|
|
2144
|
-
controlPlane: object({
|
|
2145
|
-
enabled: boolean().default(true),
|
|
2146
|
-
url: string().optional(),
|
|
2147
|
-
key: string().optional(),
|
|
2148
|
-
heartbeatMs: number().int().default(15e3)
|
|
2149
|
-
}).default({
|
|
2150
|
-
enabled: false,
|
|
2151
|
-
heartbeatMs: 15e3
|
|
2152
|
-
}),
|
|
2153
|
-
agentsDir: string().optional(),
|
|
2154
|
-
runtimes: record(string(), RuntimeDefSchema).optional(),
|
|
2155
|
-
mcpServers: record(string(), McpServerDefSchema).optional(),
|
|
2156
|
-
relays: array(RelayRosterEntry).default([]),
|
|
2157
|
-
logging: object({ level: _enum([
|
|
2158
|
-
"trace",
|
|
2159
|
-
"debug",
|
|
2160
|
-
"info",
|
|
2161
|
-
"warn",
|
|
2162
|
-
"error"
|
|
2163
|
-
]).default("info") }).default({ level: "info" }),
|
|
2164
|
-
limits: object({
|
|
2165
|
-
maxAgents: number().int().default(8),
|
|
2166
|
-
maxConcurrentSessions: number().int().default(32),
|
|
2167
|
-
agentIdleTimeoutMs: number().int().default(9e5),
|
|
2168
|
-
idleSweepMs: number().int().default(6e4),
|
|
2169
|
-
shutdownDrainMs: number().int().default(25e3),
|
|
2170
|
-
cancelBackstopMs: number().int().default(3e4),
|
|
2171
|
-
agentStartAttempts: number().int().min(1).default(3),
|
|
2172
|
-
agentStartBackoffMs: number().int().min(0).default(500),
|
|
2173
|
-
maxAttachmentBytes: number().int().default(8 * 1024 * 1024)
|
|
2174
|
-
}).default({
|
|
2175
|
-
maxAgents: 8,
|
|
2176
|
-
maxConcurrentSessions: 32,
|
|
2177
|
-
agentIdleTimeoutMs: 9e5,
|
|
2178
|
-
idleSweepMs: 6e4,
|
|
2179
|
-
shutdownDrainMs: 25e3,
|
|
2180
|
-
cancelBackstopMs: 3e4,
|
|
2181
|
-
agentStartAttempts: 3,
|
|
2182
|
-
agentStartBackoffMs: 500,
|
|
2183
|
-
maxAttachmentBytes: 8 * 1024 * 1024
|
|
2184
|
-
})
|
|
2185
|
-
});
|
|
2186
|
-
//#endregion
|
|
2187
|
-
//#region src/config/load-config.ts
|
|
2188
|
-
function loadConfig(opts = {}) {
|
|
2189
|
-
const root = resolveRoot(opts.root);
|
|
2190
|
-
const file = opts.configPath ?? configPath(root);
|
|
2191
|
-
let raw;
|
|
2192
|
-
if (existsSync(file)) raw = JSON.parse(readFileSync(file, "utf8"));
|
|
2193
|
-
else if (opts.autoCreate) {
|
|
2194
|
-
raw = { version: 1 };
|
|
2195
|
-
mkdirSync(dirname(file), { recursive: true });
|
|
2196
|
-
writeFileSync(file, JSON.stringify(raw, null, 2) + "\n");
|
|
2197
|
-
} else if (opts.optional) raw = { version: 1 };
|
|
2198
|
-
else throw new Error(`config not found: ${file} (create it, pass --config, or run \`agentconnect login\`)`);
|
|
2199
|
-
const cfg = ConfigSchema.parse(raw);
|
|
2200
|
-
const o = opts.overrides ?? {};
|
|
2201
|
-
if (o.daemonId) cfg.daemonId = o.daemonId;
|
|
2202
|
-
if (o.logLevel) cfg.logging.level = o.logLevel;
|
|
2203
|
-
if (o.maxAgents !== void 0) cfg.limits.maxAgents = o.maxAgents;
|
|
2204
|
-
if (o.cpUrl) cfg.controlPlane.url = o.cpUrl;
|
|
2205
|
-
if (o.cpKey) cfg.controlPlane.key = o.cpKey;
|
|
2206
|
-
if (o.cpUrl || o.cpKey) cfg.controlPlane.enabled = true;
|
|
2207
|
-
if (o.noCp) cfg.controlPlane.enabled = false;
|
|
2208
|
-
cfg.agentsDir = o.agentsDir ?? cfg.agentsDir ?? defaultAgentsDir(root);
|
|
2209
|
-
return cfg;
|
|
2210
|
-
}
|
|
2211
|
-
/**
|
|
2212
|
-
* Persist a (freshly-minted) `daemonId` back into config.json so it is stable
|
|
2213
|
-
* per install. Best-effort: a write failure is swallowed (the daemon still runs
|
|
2214
|
-
* with the in-memory id this session).
|
|
2215
|
-
*/
|
|
2216
|
-
function persistDaemonId(root, daemonId) {
|
|
2217
|
-
try {
|
|
2218
|
-
const file = configPath(resolveRoot(root));
|
|
2219
|
-
const raw = existsSync(file) ? JSON.parse(readFileSync(file, "utf8")) : { version: 1 };
|
|
2220
|
-
raw.daemonId = daemonId;
|
|
2221
|
-
mkdirSync(dirname(file), { recursive: true });
|
|
2222
|
-
writeFileSync(file, JSON.stringify(raw, null, 2) + "\n");
|
|
2223
|
-
} catch {}
|
|
2224
|
-
}
|
|
2225
|
-
/**
|
|
2226
|
-
* Persist the CP-published relay roster back into config.json so the daemon can
|
|
2227
|
-
* re-dial its relays at boot while the CP is unreachable (graceful degradation).
|
|
2228
|
-
* Whole-set (CP-owned): overwrites any prior value, so a swept relay is cleared.
|
|
2229
|
-
* Best-effort — a write failure is swallowed (the in-memory roster still drives
|
|
2230
|
-
* this session's dials).
|
|
2231
|
-
*/
|
|
2232
|
-
function persistRelays(root, relays) {
|
|
2233
|
-
try {
|
|
2234
|
-
const file = configPath(resolveRoot(root));
|
|
2235
|
-
const raw = existsSync(file) ? JSON.parse(readFileSync(file, "utf8")) : { version: 1 };
|
|
2236
|
-
raw.relays = relays;
|
|
2237
|
-
mkdirSync(dirname(file), { recursive: true });
|
|
2238
|
-
writeFileSync(file, JSON.stringify(raw, null, 2) + "\n");
|
|
2239
|
-
} catch {}
|
|
2240
|
-
}
|
|
2241
|
-
//#endregion
|
|
2242
|
-
//#region src/agents/agent-schema.ts
|
|
2243
|
-
const BindMatchSchema = discriminatedUnion("kind", [
|
|
2244
|
-
object({ kind: literal("mention") }),
|
|
2245
|
-
object({ kind: literal("dm") }),
|
|
2246
|
-
object({
|
|
2247
|
-
kind: literal("keyword"),
|
|
2248
|
-
value: string()
|
|
2249
|
-
}),
|
|
2250
|
-
object({ kind: literal("auto") })
|
|
2251
|
-
]);
|
|
2252
|
-
const BindRuleConfigSchema = object({
|
|
2253
|
-
channel: string().optional(),
|
|
2254
|
-
thread: string().optional(),
|
|
2255
|
-
match: BindMatchSchema
|
|
2256
|
-
});
|
|
2257
|
-
const SlackConfigSchema = object({
|
|
2258
|
-
mode: _enum(["direct", "shared"]).default("direct"),
|
|
2259
|
-
botToken: string(),
|
|
2260
|
-
appToken: string().optional(),
|
|
2261
|
-
signingSecret: string().optional(),
|
|
2262
|
-
botUserId: string().optional(),
|
|
2263
|
-
allowedUserIds: array(string()).default([]),
|
|
2264
|
-
bindRules: array(BindRuleConfigSchema).default([])
|
|
2265
|
-
});
|
|
2266
|
-
const TelegramConfigSchema = object({
|
|
2267
|
-
botToken: string(),
|
|
2268
|
-
botUserId: string().optional(),
|
|
2269
|
-
botUsername: string().optional(),
|
|
2270
|
-
allowedUserIds: array(string()).default([]),
|
|
2271
|
-
bindRules: array(BindRuleConfigSchema).default([])
|
|
2272
|
-
});
|
|
2273
|
-
const DiscordConfigSchema = object({
|
|
2274
|
-
botToken: string(),
|
|
2275
|
-
applicationId: string().optional(),
|
|
2276
|
-
botUserId: string().optional(),
|
|
2277
|
-
allowedUserIds: array(string()).default([]),
|
|
2278
|
-
bindRules: array(BindRuleConfigSchema).default([])
|
|
2279
|
-
});
|
|
2280
|
-
const IntegrationSchema = discriminatedUnion("platform", [
|
|
2281
|
-
object({
|
|
2282
|
-
id: string(),
|
|
2283
|
-
platform: literal("slack"),
|
|
2284
|
-
slack: SlackConfigSchema
|
|
2285
|
-
}),
|
|
2286
|
-
object({
|
|
2287
|
-
id: string(),
|
|
2288
|
-
platform: literal("telegram"),
|
|
2289
|
-
telegram: TelegramConfigSchema
|
|
2290
|
-
}),
|
|
2291
|
-
object({
|
|
2292
|
-
id: string(),
|
|
2293
|
-
platform: literal("discord"),
|
|
2294
|
-
discord: DiscordConfigSchema
|
|
2295
|
-
})
|
|
2296
|
-
]);
|
|
2297
|
-
/** A scheduled trigger for THIS agent: every `schedule` tick, prompt the agent
|
|
2298
|
-
* with `trigger`. `target` is optional output routing — when present the daemon
|
|
2299
|
-
* posts the trigger into that channel and the session replies in its thread;
|
|
2300
|
-
* absent ⇒ headless fire (no platform output). `origin:"cp"` marks CP-pushed
|
|
2301
|
-
* entries (written by cron/upsert, pruned by drop.crons); hand-authored entries
|
|
2302
|
-
* have no origin and are never touched by the CP. */
|
|
2303
|
-
const CronDefSchema = object({
|
|
2304
|
-
id: string(),
|
|
2305
|
-
schedule: string(),
|
|
2306
|
-
target: object({
|
|
2307
|
-
platform: _enum([
|
|
2308
|
-
"slack",
|
|
2309
|
-
"telegram",
|
|
2310
|
-
"discord"
|
|
2311
|
-
]),
|
|
2312
|
-
channel: string(),
|
|
2313
|
-
integrationId: string().optional()
|
|
2314
|
-
}).optional(),
|
|
2315
|
-
trigger: string(),
|
|
2316
|
-
enabled: boolean().default(true),
|
|
2317
|
-
origin: literal("cp").optional()
|
|
2318
|
-
});
|
|
2319
|
-
const AgentSchema = object({
|
|
2320
|
-
id: string(),
|
|
2321
|
-
name: string(),
|
|
2322
|
-
status: _enum([
|
|
2323
|
-
"active",
|
|
2324
|
-
"inactive",
|
|
2325
|
-
"paused"
|
|
2326
|
-
]).default("active"),
|
|
2327
|
-
pause: boolean().default(false),
|
|
2328
|
-
runtime: string(),
|
|
2329
|
-
description: string().optional(),
|
|
2330
|
-
reasoningEffort: string().optional(),
|
|
2331
|
-
executionMode: string().optional(),
|
|
2332
|
-
fastMode: boolean().optional(),
|
|
2333
|
-
permissionMode: string().default("default"),
|
|
2334
|
-
runtimeOverrides: object({
|
|
2335
|
-
model: string().optional(),
|
|
2336
|
-
env: array(object({
|
|
2337
|
-
name: string(),
|
|
2338
|
-
value: string()
|
|
2339
|
-
})).default([])
|
|
2340
|
-
}).optional(),
|
|
2341
|
-
mcpServers: array(string()).default([]),
|
|
2342
|
-
callPolicy: _enum(["all", "selected"]).default("all"),
|
|
2343
|
-
allowedCallerAgentIds: array(string()).default([]),
|
|
2344
|
-
memory: object({ provider: _enum([
|
|
2345
|
-
"native",
|
|
2346
|
-
"managed",
|
|
2347
|
-
"external"
|
|
2348
|
-
]).default("managed") }).optional(),
|
|
2349
|
-
workspace: object({
|
|
2350
|
-
mode: _enum(["git-repo", "from-scratch"]),
|
|
2351
|
-
path: string(),
|
|
2352
|
-
gitRepo: string().optional(),
|
|
2353
|
-
gitBranch: string().default("main"),
|
|
2354
|
-
gitCredential: _enum(["github-app"]).optional(),
|
|
2355
|
-
pullOnNewSession: boolean().default(true),
|
|
2356
|
-
skills: array(string()).default([])
|
|
2357
|
-
}),
|
|
2358
|
-
integrations: array(IntegrationSchema).default([]),
|
|
2359
|
-
output: object({ mode: _enum([
|
|
2360
|
-
"low",
|
|
2361
|
-
"medium",
|
|
2362
|
-
"high"
|
|
2363
|
-
]).default("low") }).default({ mode: "low" }),
|
|
2364
|
-
permissions: object({
|
|
2365
|
-
policy: _enum(["ask", "auto"]).default("ask"),
|
|
2366
|
-
autoApprove: array(string()).default([])
|
|
2367
|
-
}).default({
|
|
2368
|
-
policy: "ask",
|
|
2369
|
-
autoApprove: []
|
|
2370
|
-
}),
|
|
2371
|
-
crons: array(CronDefSchema).default([])
|
|
2372
|
-
});
|
|
2373
|
-
//#endregion
|
|
2374
|
-
//#region src/agents/agent-env.ts
|
|
2375
|
-
function parseDotenv(text) {
|
|
2376
|
-
const out = {};
|
|
2377
|
-
for (const rawLine of text.split("\n")) {
|
|
2378
|
-
const line = rawLine.replace(/\r$/, "").trim();
|
|
2379
|
-
if (!line || line.startsWith("#")) continue;
|
|
2380
|
-
const body = line.startsWith("export ") ? line.slice(7).trim() : line;
|
|
2381
|
-
const eq = body.indexOf("=");
|
|
2382
|
-
if (eq === -1) continue;
|
|
2383
|
-
const key = body.slice(0, eq).trim();
|
|
2384
|
-
if (!key) continue;
|
|
2385
|
-
let value = body.slice(eq + 1).trim();
|
|
2386
|
-
const q = value[0];
|
|
2387
|
-
if (value.length >= 2 && (q === "\"" || q === "'") && value.at(-1) === q) value = value.slice(1, -1);
|
|
2388
|
-
out[key] = value;
|
|
2389
|
-
}
|
|
2390
|
-
return out;
|
|
2391
|
-
}
|
|
2392
|
-
function loadDotenv(dir) {
|
|
2393
|
-
const file = join(dir, ".env");
|
|
2394
|
-
if (!existsSync(file)) return {};
|
|
2395
|
-
return parseDotenv(readFileSync(file, "utf8"));
|
|
2396
|
-
}
|
|
2397
|
-
const VAR_RE = /\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
|
|
2398
|
-
function interpolateString(value, source, path, ctx) {
|
|
2399
|
-
return value.replace(VAR_RE, (_m, name) => {
|
|
2400
|
-
const resolved = source[name];
|
|
2401
|
-
if (resolved === void 0) throw new Error(`agent "${ctx.id}": unresolved \${${name}} in ${path} (.env: ${ctx.envPath})`);
|
|
2402
|
-
return resolved;
|
|
2403
|
-
});
|
|
2404
|
-
}
|
|
2405
|
-
function walk(node, source, path, ctx) {
|
|
2406
|
-
if (typeof node === "string") return interpolateString(node, source, path, ctx);
|
|
2407
|
-
if (Array.isArray(node)) {
|
|
2408
|
-
for (let i = 0; i < node.length; i++) node[i] = walk(node[i], source, `${path}[${i}]`, ctx);
|
|
2409
|
-
return node;
|
|
2410
|
-
}
|
|
2411
|
-
if (node && typeof node === "object") {
|
|
2412
|
-
const obj = node;
|
|
2413
|
-
for (const key of Object.keys(obj)) obj[key] = walk(obj[key], source, path ? `${path}.${key}` : key, ctx);
|
|
2414
|
-
return node;
|
|
2415
|
-
}
|
|
2416
|
-
return node;
|
|
2417
|
-
}
|
|
2418
|
-
function interpolateAgent(agent, source, ctx) {
|
|
2419
|
-
walk(agent, source, "", ctx);
|
|
2420
|
-
}
|
|
2421
|
-
function agentChildEnv(agent) {
|
|
2422
|
-
return {
|
|
2423
|
-
...agent.env,
|
|
2424
|
-
...Object.fromEntries((agent.runtimeOverrides?.env ?? []).map((e) => [e.name, e.value]))
|
|
2425
|
-
};
|
|
2426
|
-
}
|
|
2427
|
-
//#endregion
|
|
2428
|
-
//#region src/agents/load-agents.ts
|
|
2429
|
-
const IGNORED_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git"]);
|
|
2430
|
-
const MAX_DEPTH = 4;
|
|
2431
|
-
function parseAgentFile(file) {
|
|
2432
|
-
const dir = dirname(file);
|
|
2433
|
-
const env = loadDotenv(dir);
|
|
2434
|
-
const agent = AgentSchema.parse(JSON.parse(readFileSync(file, "utf8")));
|
|
2435
|
-
interpolateAgent(agent, {
|
|
2436
|
-
...process.env,
|
|
2437
|
-
...env
|
|
2438
|
-
}, {
|
|
2439
|
-
id: agent.id,
|
|
2440
|
-
envPath: join(dir, ".env")
|
|
2441
|
-
});
|
|
2442
|
-
if (!isAbsolute(agent.workspace.path)) agent.workspace.path = resolve(dir, agent.workspace.path);
|
|
2443
|
-
return {
|
|
2444
|
-
...agent,
|
|
2445
|
-
dir,
|
|
2446
|
-
env
|
|
2447
|
-
};
|
|
2448
|
-
}
|
|
2449
|
-
function findAgentFiles(dir, depth = 0) {
|
|
2450
|
-
if (depth > MAX_DEPTH || !existsSync(dir)) return [];
|
|
2451
|
-
let entries;
|
|
2452
|
-
try {
|
|
2453
|
-
entries = readdirSync(dir, { withFileTypes: true });
|
|
2454
|
-
} catch {
|
|
2455
|
-
return [];
|
|
2456
|
-
}
|
|
2457
|
-
if (entries.some((e) => e.isFile() && e.name === "agent.json")) return [join(dir, "agent.json")];
|
|
2458
|
-
const out = [];
|
|
2459
|
-
for (const entry of entries) {
|
|
2460
|
-
if (!entry.isDirectory()) continue;
|
|
2461
|
-
if (IGNORED_DIRS.has(entry.name) || entry.name.startsWith(".")) continue;
|
|
2462
|
-
out.push(...findAgentFiles(join(dir, entry.name), depth + 1));
|
|
2463
|
-
}
|
|
2464
|
-
return out;
|
|
2465
|
-
}
|
|
2466
|
-
function discoverAgents(agentsDir) {
|
|
2467
|
-
return findAgentFiles(agentsDir).map((file) => {
|
|
2468
|
-
try {
|
|
2469
|
-
return {
|
|
2470
|
-
agent: parseAgentFile(file),
|
|
2471
|
-
dir: dirname(file)
|
|
2472
|
-
};
|
|
2473
|
-
} catch (err) {
|
|
2474
|
-
throw new Error(`invalid agent.json at ${file}: ${err.message}`);
|
|
2475
|
-
}
|
|
2476
|
-
});
|
|
2477
|
-
}
|
|
2478
|
-
function loadAgents(agentsDir) {
|
|
2479
|
-
return discoverAgents(agentsDir).map((d) => d.agent).filter((a) => a.status === "active");
|
|
2480
|
-
}
|
|
2481
|
-
function selectAgent(agentsDir, name) {
|
|
2482
|
-
const agents = discoverAgents(agentsDir).map((d) => d.agent);
|
|
2483
|
-
if (name) {
|
|
2484
|
-
const match = agents.find((a) => a.id === name);
|
|
2485
|
-
if (!match) {
|
|
2486
|
-
const available = agents.map((a) => a.id).sort().join(", ") || "(none)";
|
|
2487
|
-
throw new Error(`agent "${name}" not found in ${agentsDir}. Available: ${available}`);
|
|
2488
|
-
}
|
|
2489
|
-
return match;
|
|
2490
|
-
}
|
|
2491
|
-
if (agents.length === 0) throw new Error(`no agent.json found in ${agentsDir}`);
|
|
2492
|
-
if (agents.length > 1) {
|
|
2493
|
-
const ids = agents.map((a) => a.id).sort().join(", ");
|
|
2494
|
-
throw new Error(`multiple agents found in ${agentsDir}: ${ids}; use --agent <name> to specify one`);
|
|
2495
|
-
}
|
|
2496
|
-
return agents[0];
|
|
2497
|
-
}
|
|
2498
|
-
//#endregion
|
|
2499
|
-
export { ZodIssueCode as C, RESERVED_MCP_SERVER_NAME as S, buildEnvelope as _, agentChildEnv as a, MAX_FRAME_BYTES as b, persistRelays as c, normalizeGitUrl as d, RELAY_DAEMON_SUBPROTOCOL as f, SHARED_CONFIG_ACTION_ID as g, decodeRelayDaemonFrame as h, selectAgent as i, ConfigSchema as l, buildRelayDaemonFrame as m, findAgentFiles as n, loadConfig as o, RELAY_DAEMON_WS_PATH as p, loadAgents as r, persistDaemonId as s, discoverAgents as t, isFrame as u, decodeEnvelope as v, MEMORY_INDEX as x, encode as y };
|
|
2118
|
+
export { RELAY_DAEMON_WS_PATH as a, SHARED_CONFIG_ACTION_ID as c, encode as d, MAX_FRAME_BYTES as f, ZodIssueCode as g, RESERVED_MCP_SERVER_NAME as h, RELAY_DAEMON_SUBPROTOCOL as i, buildEnvelope as l, RelayRosterEntry as m, gitRepoLabel as n, buildRelayDaemonFrame as o, MEMORY_INDEX as p, normalizeGitUrl as r, decodeRelayDaemonFrame as s, isFrame as t, decodeEnvelope as u };
|
|
2500
2119
|
|
|
2501
|
-
//# sourceMappingURL=
|
|
2120
|
+
//# sourceMappingURL=dist-Cq1Kimg_.js.map
|