@agentchatme/agent-core 0.7.1 → 0.7.3
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 +23 -3
- package/dist/{chunk-4PCDVXAR.js → chunk-7TTV2CQX.js} +2 -2
- package/dist/{chunk-4PCDVXAR.js.map → chunk-7TTV2CQX.js.map} +1 -1
- package/dist/{chunk-AQTRC7G4.js → chunk-FPAOQGMV.js} +514 -76
- package/dist/chunk-FPAOQGMV.js.map +1 -0
- package/dist/daemon-entry.d.ts +54 -5
- package/dist/daemon-entry.js +76 -6
- package/dist/daemon-entry.js.map +1 -1
- package/dist/index.d.ts +141 -49
- package/dist/index.js +162 -303
- package/dist/index.js.map +1 -1
- package/dist/presets.js +1 -1
- package/dist/{served-manual-Bg-y_MEy.d.ts → served-manual-CwxBzpwQ.d.ts} +181 -3
- package/package.json +2 -2
- package/dist/chunk-AQTRC7G4.js.map +0 -1
package/README.md
CHANGED
|
@@ -150,11 +150,15 @@ await runIntegration({
|
|
|
150
150
|
workdir: `${runtimeHome()}/agentchat-workdir`,
|
|
151
151
|
runner,
|
|
152
152
|
client: { runtime: 'generic', version: VERSION },
|
|
153
|
-
|
|
153
|
+
// Called per run with the manual's address as the texts in hand announce it.
|
|
154
|
+
manualPointer: (url) => manualPointer('at <skills dir>/agentchat/SKILL.md', url),
|
|
154
155
|
manualPath: '<skills dir>/agentchat/SKILL.md', // the skill file follows the served manual
|
|
156
|
+
anchorPath: `${runtimeHome()}/AGENTS.md`, // this agent's identity block follows the served identity line
|
|
155
157
|
})
|
|
156
158
|
```
|
|
157
159
|
|
|
160
|
+
The pointer line names the manual where the served texts say it is (`texts.manual.url`, through `servedManualUrl`); `MANUAL_URL` is used only when no texts are in hand. A plain string is still accepted and used as it is.
|
|
161
|
+
|
|
158
162
|
A runner whose runs must be told which agent they act as passes a `RunnerFactory` (`{ name, create(identity) }`) instead: the supervisor builds a runner for each identity it serves. A known coding agent's runner comes from `@agentchatme/agent-core/presets` (`ClaudeRunner`, `CodexRunner`, or `PRESETS[name].runner(...)`).
|
|
159
163
|
|
|
160
164
|
A preset run built for a listener names its runtime to the hosted tools: `X-AgentChat-Client: claude-code` or `codex`, and `X-AgentChat-Client-Version` set to the version of the front door that placed it (`PresetContext.clientVersion`; this engine's by default). The hosted tool server names a client only from these headers, so with them a listener-woken run is shown no wake-webhook tools (the listener already wakes it) and the tool names spelled for its runtime. Claude Code gets them in the `--mcp-config` file; Codex as `-c mcp_servers.agentchat.http_headers={…}`.
|
|
@@ -165,9 +169,25 @@ A run is bounded twice over: `spawnRun` kills it past its budget (SIGTERM to its
|
|
|
165
169
|
|
|
166
170
|
### The identity block
|
|
167
171
|
|
|
168
|
-
The block in the instruction file is the SDK kit's (`integration.anchor` in `agentchatme`), the same shape every AgentChat integration writes: the `<!-- agentchat:start -->` / `<!-- agentchat:end -->` fences, a handle line (`<!-- agentchat:handle <handle> -->`), then the served identity line. `renderAnchorBlock(identityLine, handle)` renders it and refuses a line that does not name the handle.
|
|
172
|
+
The block in the instruction file is the SDK kit's (`integration.anchor` in `agentchatme`), the same shape every AgentChat integration writes: the `<!-- agentchat:start -->` / `<!-- agentchat:end -->` fences, a handle line (`<!-- agentchat:handle <handle> -->`), then the served identity line. `renderAnchorBlock(identityLine, handle)` renders it and refuses a line that does not name the handle. Placing it follows one policy, the same in every integration: **a person's words are only replaced once they delete the block themselves.** `placeAnchorAt(file, { handle, identityLine, template, mode })` reads the file with the kit's `decide` (its strict `owner`). With no block or the setup offer, it places the identity block. This agent's block, current or stale, it updates in place. A block edited by hand, or more than one block, it leaves, with the remedy: "…edited by hand, so it is left; to have the served line, delete that block, then run `doctor --fix`". Another agent's block depends on the mode. In `setup` (install, register, login, recover) it is replaced, and the step says so: "replaced @y's identity line … with @x's". In `repair` (`doctor --fix`) it is refused: "fix the key, or remove that block". The daemon only ever updates this agent's block, and removal (logout, uninstall) only removes it (below). `writeAnchor` itself never writes over a block that is not this agent's or the setup offer (`kept`). The user's own text around the block stays where it was, as it was (the blank lines next to the block become exactly one; a CRLF file stays CRLF, the block included; whether the file ends with a line break is kept). `readAnchorHandleAt(file, template)` reads the handle a block is AgentChat's for, strictly (the kit's `owner`): its handle line's, or, with none, the handle its whole text is exactly a served text for. A sentence of the user's that mentions a handle names none. `anchorIsCurrentAt(file, identityLine, handle)` is true only when writing that block again would change nothing (exactly that block, in the kit's place, and no other AgentChat block). These three read functions throw when the file exists but cannot be read — permissions, a symlink loop, not UTF-8 — so a caller can tell that from "no block"; `status`, `doctor` and `logout` report it instead of stopping.
|
|
173
|
+
|
|
174
|
+
**The daemon keeps the block current** (`anchorPath`, `followIdentityAnchor`, on the kit's `integration.anchor.follow`: the rule below is the kit's, one copy for every integration). Install, `register` / `login` / `recover` and `doctor --fix` place the block. From then on, whenever the daemon's served texts change, the block follows the served identity line with no reinstall. That covers the copy kept in the identity home at every daemon start, then every served copy that differs (they are fetched at start and daily). The block is replaced only when all of these hold, and is otherwise left exactly as it is:
|
|
175
|
+
|
|
176
|
+
1. it is the only AgentChat block in the file (a write keeps one, so it would remove the other);
|
|
177
|
+
2. it is not the setup offer or its declined variant;
|
|
178
|
+
3. it is AgentChat's: it carries a handle line, or, without one, its whole text is **exactly** a text AgentChat served (line endings and surrounding space aside): the served identity line, the served template filled in for a handle, or one of the identity lines served before (the kit's `EARLIER_IDENTITY_LINES`);
|
|
179
|
+
4. that handle is this agent's;
|
|
180
|
+
5. it is not already the served block: its text (line endings and surrounding space aside) differs from the served line, or it is the served text in an older shape (no handle line, or the legacy fences), which is rewritten once into the current shape.
|
|
181
|
+
|
|
182
|
+
A block that fails 3 counts as edited by hand: it has no handle line, and its text is not one AgentChat served, word for word. It belongs to the user and is left as it is, by the daemon and by every other path; to have the served line, they delete that block, then run `doctor --fix`. A background process never deletes a person's words on a loose match: a sentence of the user's that happens to say `I am @<handle>` is theirs. (The kit's `anchor.find` reads a handle from the template's first words anywhere in the block, for display only; every decision to write uses `owner`.) A block that keeps this agent's handle line belongs to AgentChat and follows the served line, whatever its text says, at the next daemon start or texts change. A block is never created where there is none, and neither is the file; that is the CLI's to place.
|
|
183
|
+
|
|
184
|
+
The decision is made on one read. The new text is then written and flushed to a temp file beside the user's, and the file is read again right before the rename. If it changed or is gone, nothing is written and the decision is made again on what is there now, up to three attempts. An edit saved in the instant between that last read and the rename is the one thing this cannot see; no file lock that editors honour exists.
|
|
185
|
+
|
|
186
|
+
The outcome is logged (`other_agent` at error level) and kept in the status file as `identity_line`. `status` and `doctor` read the file with the same rules (`identityBlockState`, on the kit's `decide`, and its `owner` when no texts are in hand), so all three give one verdict: `status` prints it once (`Identity line: …`), and adds the daemon's own line only for what the file cannot show (a write that failed, a file that kept changing). A host whose runtime reads another file in the instruction file's place gives `anchorLoadNote(handle, served)`. It judges that other file's block against the served line and says which file the runtime loads, and whether the identity line there is the served one (`ok`). `status`, `doctor` and the daemon's follow all say the note. When it is not ok (no identity line there, or an older one), it is a WARN, never a PASS. Nothing writes that other file. The outcomes are `updated`, `unchanged`, `absent`, `setup_offer`, `hand_edited`, `other_agent`, `several_blocks`, `edited_meanwhile` and `failed`. The daemon follows only while it serves the agent: one on standby for another listener, or whose runtime does not pass its preflight, does not.
|
|
187
|
+
|
|
188
|
+
**Removing AgentChat removes only what AgentChat placed for this agent** (`removeAnchorAt(file, { handle, identityLine, template })`, used by logout and by the integrations' uninstall). It takes out this agent's identity block, by the kit's strict `owner` (its handle line, or a whole text that is exactly a served one), or the setup offer or its declined variant. A block a person wrote inside the markers, another agent's block, or a file with more than one AgentChat block is left exactly as it is, and the step says so: "left your edited AgentChat block in …; remove it by hand if you no longer want it". The offer a logout writes afterwards (`writeOfferAt`) never goes over a block that is not itself an offer.
|
|
169
189
|
|
|
170
|
-
The file is never left half-written: the new text goes to a temp file beside it, is flushed, and is renamed over it, so a crash or a full disk leaves the old file byte for byte. A symlinked instruction file stays a symlink (the file it points to is replaced), its permission bits are kept, a file the user made read-only is refused rather than replaced, a file that is not UTF-8 is not touched, and a leading byte-order mark is kept.
|
|
190
|
+
The file is never left half-written: the new text goes to a temp file beside it, is flushed, and is renamed over it, so a crash or a full disk leaves the old file byte for byte. A symlinked instruction file stays a symlink (the file it points to is replaced), its permission bits are kept, a file the user made read-only is refused rather than replaced, a file that is not UTF-8 is not touched, and a leading byte-order mark is kept. For install and `doctor --fix` (`writeAnchor`), a writable file that the temp file or the rename cannot replace (a directory that takes no new file, a single-file bind mount, a file held open on Windows) is written in place, as before; a full disk or an I/O error is not, and leaves the old file intact. The daemon's follow never writes in place: such a file is a `failed` follow, said in the log and status, and `doctor --fix` writes it. The other names of a hard-linked file, and extended attributes or ACLs on the file, are not kept.
|
|
171
191
|
|
|
172
192
|
### Invites
|
|
173
193
|
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from "./chunk-5KMQ23O6.js";
|
|
6
6
|
|
|
7
7
|
// src/version.ts
|
|
8
|
-
var VERSION = "0.7.
|
|
8
|
+
var VERSION = "0.7.3";
|
|
9
9
|
|
|
10
10
|
// src/integration/mcp-probe.ts
|
|
11
11
|
import { integration as kit } from "agentchatme";
|
|
@@ -94,4 +94,4 @@ export {
|
|
|
94
94
|
PROBE_KILL_WAIT_MS,
|
|
95
95
|
runProbe
|
|
96
96
|
};
|
|
97
|
-
//# sourceMappingURL=chunk-
|
|
97
|
+
//# sourceMappingURL=chunk-7TTV2CQX.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/version.ts","../src/integration/mcp-probe.ts","../src/util/probe.ts"],"sourcesContent":["/** Published package version, kept in lockstep with package.json by tests. */\nexport const VERSION = '0.7.
|
|
1
|
+
{"version":3,"sources":["../src/version.ts","../src/integration/mcp-probe.ts","../src/util/probe.ts"],"sourcesContent":["/** Published package version, kept in lockstep with package.json by tests. */\nexport const VERSION = '0.7.3'\n","import { integration as kit } from 'agentchatme'\nimport { clientIdentityOf, type IntegrationClient } from '../client-identity.js'\n\n// ─── Can this key reach the hosted tools? ───────────────────────────────────\n//\n// `status` and `doctor` ask the SDK kit's `probeHostedTools`: one MCP\n// `initialize` over Streamable HTTP with the bearer key — the same first\n// request a runtime makes on connect — then `tools/list`, which must show the\n// tools a run needs (`agentchat_inbox`, `agentchat_decide`). A 401 means the\n// key does not authenticate; a transport error means the endpoint is not\n// reachable from here. No tool is called.\n\nexport const HOSTED_MCP_PATH = kit.HOSTED_MCP_PATH\n\nexport function hostedMcpUrl(apiBase: string): string {\n return kit.hostedMcpUrl(apiBase)\n}\n\nexport interface McpProbeResult {\n readonly ok: boolean\n readonly status?: number\n readonly serverName?: string\n readonly serverVersion?: string\n readonly protocolVersion?: string\n /** Every tool the server listed for this key. */\n readonly tools?: readonly string[]\n /** Tools a run needs that were not listed. */\n readonly missing?: readonly string[]\n readonly error?: string\n}\n\nexport async function probeHostedMcp(params: {\n apiKey: string\n apiBase: string\n /** How this integration identifies to the server. */\n client: IntegrationClient\n /**\n * Accepted for compatibility and ignored: the probe identifies as `client`\n * (headers and `clientInfo` alike), so the server's analytics see the\n * integration, never a free-text name it would file as unknown.\n */\n clientName?: string\n /** Accepted for compatibility and ignored (see `clientName`). */\n clientVersion?: string\n timeoutMs?: number\n fetch?: typeof fetch\n}): Promise<McpProbeResult> {\n return kit.probeHostedTools({\n apiBase: params.apiBase,\n apiKey: params.apiKey,\n clientIdentity: clientIdentityOf(params.client),\n ...(params.timeoutMs !== undefined ? { timeoutMs: params.timeoutMs } : {}),\n ...(params.fetch !== undefined ? { fetch: params.fetch } : {}),\n })\n}\n","import { killProcessTree } from '../integration/spawn-run.js'\nimport { spawnCommand } from './spawn.js'\n\n// ─── A short command whose answer we need (`--version`, a sign-in check) ────\n//\n// Was `spawnSync` with a timeout, which on timeout kills only the direct child:\n// on Windows the npm `.cmd` shim (the real process under it keeps running), and\n// the npm launcher of a runtime that starts its native binary as a child. A sync\n// spawn then also waits for those survivors to close the output pipes it reads —\n// blocking the whole daemon, socket included. A probe is therefore async: on\n// timeout the whole tree is killed (its process group on POSIX, `taskkill /T /F`\n// on Windows), its exit is waited for, and a tree that will not die is given up\n// on after a bound — the probe always answers.\n\nexport interface ProbeResult {\n /** Why it did not answer: it could not be started, or it timed out. */\n readonly error?: Error\n readonly status: number | null\n readonly stdout: string\n readonly stderr: string\n readonly timedOut: boolean\n}\n\nexport interface ProbeOptions {\n readonly env?: NodeJS.ProcessEnv\n readonly timeoutMs: number\n readonly cwd?: string\n /** Aborting it stops the probe as a timeout would (its tree killed, its exit waited for). */\n readonly signal?: AbortSignal\n}\n\n/** After a probe is killed: how long its exit is waited for before it is given up on. */\nexport const PROBE_KILL_WAIT_MS = 5_000\nconst MAX_OUTPUT = 64 * 1024\n\nexport function runProbe(command: string, args: readonly string[], options: ProbeOptions): Promise<ProbeResult> {\n return new Promise((resolve) => {\n let child: ReturnType<typeof spawnCommand>\n try {\n child = spawnCommand(command, [...args], {\n ...(options.env !== undefined ? { env: options.env } : {}),\n ...(options.cwd !== undefined ? { cwd: options.cwd } : {}),\n stdio: ['ignore', 'pipe', 'pipe'],\n // Its own process group on POSIX, so the whole tree can be killed.\n detached: process.platform !== 'win32',\n windowsHide: true,\n })\n } catch (err) {\n resolve({ error: err instanceof Error ? err : new Error(String(err)), status: null, stdout: '', stderr: '', timedOut: false })\n return\n }\n const proc = child\n let stdout = ''\n let stderr = ''\n let timedOut = false\n let stopped = false\n let finished = false\n let giveUp: NodeJS.Timeout | null = null\n const finish = (result: ProbeResult): void => {\n if (finished) return\n finished = true\n clearTimeout(timer)\n if (giveUp !== null) clearTimeout(giveUp)\n resolve(result)\n }\n proc.stdout?.on('data', (chunk: Buffer) => {\n if (stdout.length < MAX_OUTPUT) stdout += chunk.toString('utf-8')\n })\n proc.stderr?.on('data', (chunk: Buffer) => {\n if (stderr.length < MAX_OUTPUT) stderr += chunk.toString('utf-8')\n })\n const stop = (error: Error, byTimeout: boolean): void => {\n if (timedOut || finished) return\n timedOut = byTimeout\n stopped = true\n killProcessTree(proc, 'SIGKILL')\n // Its exit (every pipe closed) is the answer; a tree that will not die is given up on.\n giveUp = setTimeout(() => {\n proc.stdout?.destroy()\n proc.stderr?.destroy()\n finish({ error, status: null, stdout, stderr, timedOut })\n }, PROBE_KILL_WAIT_MS)\n proc.once('close', () => finish({ error, status: null, stdout, stderr, timedOut }))\n }\n const timer = setTimeout(() => stop(new Error(`${command} ${args.join(' ')} did not answer within ${Math.round(options.timeoutMs / 1000)} s`), true), options.timeoutMs)\n const onAbort = (): void => stop(new Error(`${command} ${args.join(' ')} was stopped`), false)\n if (options.signal?.aborted) onAbort()\n else options.signal?.addEventListener('abort', onAbort, { once: true })\n proc.on('error', (err) => finish({ error: err, status: null, stdout, stderr, timedOut }))\n proc.on('close', (code) => {\n options.signal?.removeEventListener('abort', onAbort)\n if (!stopped) finish({ status: code, stdout, stderr, timedOut })\n })\n })\n}\n"],"mappings":";;;;;;;AACO,IAAM,UAAU;;;ACDvB,SAAS,eAAe,WAAW;AAY5B,IAAM,kBAAkB,IAAI;AAE5B,SAAS,aAAa,SAAyB;AACpD,SAAO,IAAI,aAAa,OAAO;AACjC;AAeA,eAAsB,eAAe,QAeT;AAC1B,SAAO,IAAI,iBAAiB;AAAA,IAC1B,SAAS,OAAO;AAAA,IAChB,QAAQ,OAAO;AAAA,IACf,gBAAgB,iBAAiB,OAAO,MAAM;AAAA,IAC9C,GAAI,OAAO,cAAc,SAAY,EAAE,WAAW,OAAO,UAAU,IAAI,CAAC;AAAA,IACxE,GAAI,OAAO,UAAU,SAAY,EAAE,OAAO,OAAO,MAAM,IAAI,CAAC;AAAA,EAC9D,CAAC;AACH;;;ACtBO,IAAM,qBAAqB;AAClC,IAAM,aAAa,KAAK;AAEjB,SAAS,SAAS,SAAiB,MAAyB,SAA6C;AAC9G,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,QAAI;AACJ,QAAI;AACF,cAAQ,aAAa,SAAS,CAAC,GAAG,IAAI,GAAG;AAAA,QACvC,GAAI,QAAQ,QAAQ,SAAY,EAAE,KAA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