@agentchatme/openclaw 0.6.9 → 0.6.11
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/CHANGELOG.md +77 -948
- package/README.md +69 -11
- package/RUNBOOK.md +1 -1
- package/SECURITY.md +39 -31
- package/dist/binding/agents-anchor.cjs +134 -0
- package/dist/binding/agents-anchor.cjs.map +1 -0
- package/dist/binding/agents-anchor.js +108 -0
- package/dist/binding/agents-anchor.js.map +1 -0
- package/dist/configured-state.cjs.map +1 -1
- package/dist/configured-state.js.map +1 -1
- package/dist/credentials/read-env.cjs.map +1 -1
- package/dist/credentials/read-env.js.map +1 -1
- package/dist/index.cjs +17 -142
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -118
- package/dist/index.js.map +1 -1
- package/dist/setup-entry.cjs +17 -142
- package/dist/setup-entry.cjs.map +1 -1
- package/dist/setup-entry.js +14 -118
- package/dist/setup-entry.js.map +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/dist/configured-state.d.cts +0 -20
- package/dist/configured-state.d.ts +0 -20
- package/dist/credentials/read-env.d.cts +0 -47
- package/dist/credentials/read-env.d.ts +0 -47
- package/dist/index.d.cts +0 -759
- package/dist/index.d.ts +0 -759
- package/dist/setup-entry-Dtj6vwDY.d.cts +0 -104
- package/dist/setup-entry-Dtj6vwDY.d.ts +0 -104
- package/dist/setup-entry.d.cts +0 -3
- package/dist/setup-entry.d.ts +0 -3
package/dist/index.cjs
CHANGED
|
@@ -4,10 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var channelCore = require('openclaw/plugin-sdk/channel-core');
|
|
6
6
|
var setup = require('openclaw/plugin-sdk/setup');
|
|
7
|
-
var readEnv_js = require('./credentials/read-env.
|
|
8
|
-
var
|
|
9
|
-
var os = require('os');
|
|
10
|
-
var path = require('path');
|
|
7
|
+
var readEnv_js = require('./credentials/read-env.js');
|
|
8
|
+
var agentsAnchor_js = require('./binding/agents-anchor.js');
|
|
11
9
|
var zod = require('zod');
|
|
12
10
|
var pino = require('pino');
|
|
13
11
|
var ws = require('ws');
|
|
@@ -16,27 +14,6 @@ var typebox = require('@sinclair/typebox');
|
|
|
16
14
|
|
|
17
15
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
16
|
|
|
19
|
-
function _interopNamespace(e) {
|
|
20
|
-
if (e && e.__esModule) return e;
|
|
21
|
-
var n = Object.create(null);
|
|
22
|
-
if (e) {
|
|
23
|
-
Object.keys(e).forEach(function (k) {
|
|
24
|
-
if (k !== 'default') {
|
|
25
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
26
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
27
|
-
enumerable: true,
|
|
28
|
-
get: function () { return e[k]; }
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
n.default = e;
|
|
34
|
-
return Object.freeze(n);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
38
|
-
var os__namespace = /*#__PURE__*/_interopNamespace(os);
|
|
39
|
-
var path__namespace = /*#__PURE__*/_interopNamespace(path);
|
|
40
17
|
var pino__default = /*#__PURE__*/_interopDefault(pino);
|
|
41
18
|
|
|
42
19
|
// src/channel.ts
|
|
@@ -290,9 +267,9 @@ async function registerAgentVerify(input, opts = {}) {
|
|
|
290
267
|
}
|
|
291
268
|
return { ok: false, reason: "server-error", status: res.status, message };
|
|
292
269
|
}
|
|
293
|
-
async function post(
|
|
270
|
+
async function post(path, body, opts) {
|
|
294
271
|
const base = (opts.apiBase ?? DEFAULT_API_BASE).replace(/\/+$/, "");
|
|
295
|
-
const url = `${base}${
|
|
272
|
+
const url = `${base}${path}`;
|
|
296
273
|
const controller = new AbortController();
|
|
297
274
|
const fetchImpl = opts.fetch ?? fetch;
|
|
298
275
|
const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
@@ -328,106 +305,6 @@ async function assertApiKeyValid(apiKey, opts = {}) {
|
|
|
328
305
|
statusCode: result.status
|
|
329
306
|
});
|
|
330
307
|
}
|
|
331
|
-
var ANCHOR_START = "<!-- agentchat:start -->";
|
|
332
|
-
var ANCHOR_END = "<!-- agentchat:end -->";
|
|
333
|
-
var LEGACY_ANCHOR_START = "<!-- agentchat-skill:start -->";
|
|
334
|
-
var LEGACY_ANCHOR_END = "<!-- agentchat-skill:end -->";
|
|
335
|
-
function resolveWorkspaceDir(cfg) {
|
|
336
|
-
const configured = cfg?.agents?.defaults?.workspace;
|
|
337
|
-
if (typeof configured === "string" && configured.trim().length > 0) {
|
|
338
|
-
return path__namespace.resolve(configured);
|
|
339
|
-
}
|
|
340
|
-
const profile = readEnv_js.readOpenClawProfileFromEnv();
|
|
341
|
-
if (profile) {
|
|
342
|
-
return path__namespace.join(os__namespace.homedir(), ".openclaw", `workspace-${profile}`);
|
|
343
|
-
}
|
|
344
|
-
return path__namespace.join(os__namespace.homedir(), ".openclaw", "workspace");
|
|
345
|
-
}
|
|
346
|
-
function agentsFilePath(workspaceDir) {
|
|
347
|
-
return path__namespace.join(workspaceDir, "AGENTS.md");
|
|
348
|
-
}
|
|
349
|
-
function renderAnchorBlock(handle) {
|
|
350
|
-
return [
|
|
351
|
-
ANCHOR_START,
|
|
352
|
-
"## On AgentChat",
|
|
353
|
-
"",
|
|
354
|
-
`You are **@${handle}** on AgentChat \u2014 a peer-to-peer messaging network for AI agents. Your handle is your address here, like a phone number, except the other end is always another agent.`,
|
|
355
|
-
"",
|
|
356
|
-
"- Other agents can DM you. You can DM them \u2014 any time, for anything that fits your context.",
|
|
357
|
-
`- Share \`@${handle}\` freely. Whenever and wherever you think you should share. It's how peers reach you.`,
|
|
358
|
-
"- When you need to send, search, or handle an error, your AgentChat skill has the full reference.",
|
|
359
|
-
"",
|
|
360
|
-
"This is an identity, not a tool you reach for occasionally.",
|
|
361
|
-
ANCHOR_END
|
|
362
|
-
].join("\n");
|
|
363
|
-
}
|
|
364
|
-
function writeAgentsAnchor(params) {
|
|
365
|
-
const trimmedHandle = params.handle?.trim();
|
|
366
|
-
if (!trimmedHandle) {
|
|
367
|
-
throw new Error("writeAgentsAnchor: handle is empty");
|
|
368
|
-
}
|
|
369
|
-
const workspaceDir = resolveWorkspaceDir(params.cfg);
|
|
370
|
-
const filePath = agentsFilePath(workspaceDir);
|
|
371
|
-
fs__namespace.mkdirSync(workspaceDir, { recursive: true });
|
|
372
|
-
const existing = fs__namespace.existsSync(filePath) ? fs__namespace.readFileSync(filePath, "utf-8") : "";
|
|
373
|
-
const block = renderAnchorBlock(trimmedHandle);
|
|
374
|
-
const next = upsertAnchorBlock(existing, block);
|
|
375
|
-
fs__namespace.writeFileSync(filePath, next, "utf-8");
|
|
376
|
-
const verify = fs__namespace.readFileSync(filePath, "utf-8");
|
|
377
|
-
if (!verify.includes(`@${trimmedHandle}`)) {
|
|
378
|
-
throw new Error(
|
|
379
|
-
`writeAgentsAnchor: handle @${trimmedHandle} did not land in AGENTS.md \u2014 block is broken, please remove the agentchat anchor manually and re-run.`
|
|
380
|
-
);
|
|
381
|
-
}
|
|
382
|
-
return { path: filePath };
|
|
383
|
-
}
|
|
384
|
-
function removeAgentsAnchor(params) {
|
|
385
|
-
const workspaceDir = resolveWorkspaceDir(params.cfg);
|
|
386
|
-
const filePath = agentsFilePath(workspaceDir);
|
|
387
|
-
if (!fs__namespace.existsSync(filePath)) {
|
|
388
|
-
return { removed: false, path: filePath };
|
|
389
|
-
}
|
|
390
|
-
const existing = fs__namespace.readFileSync(filePath, "utf-8");
|
|
391
|
-
const next = stripAnchorBlock(existing);
|
|
392
|
-
if (next === existing) {
|
|
393
|
-
return { removed: false, path: filePath };
|
|
394
|
-
}
|
|
395
|
-
fs__namespace.writeFileSync(filePath, next, "utf-8");
|
|
396
|
-
return { removed: true, path: filePath };
|
|
397
|
-
}
|
|
398
|
-
function upsertAnchorBlock(existing, block) {
|
|
399
|
-
const cleaned = stripBlockBetween(existing, LEGACY_ANCHOR_START, LEGACY_ANCHOR_END);
|
|
400
|
-
const startIdx = cleaned.indexOf(ANCHOR_START);
|
|
401
|
-
const endIdx = cleaned.indexOf(ANCHOR_END);
|
|
402
|
-
if (startIdx >= 0 && endIdx >= 0 && endIdx > startIdx) {
|
|
403
|
-
const before = cleaned.slice(0, startIdx).replace(/\n+$/, "");
|
|
404
|
-
const after = cleaned.slice(endIdx + ANCHOR_END.length).replace(/^\n+/, "");
|
|
405
|
-
const parts = [before, block, after].filter((s) => s.length > 0);
|
|
406
|
-
return parts.join("\n\n") + "\n";
|
|
407
|
-
}
|
|
408
|
-
const trimmed = cleaned.replace(/\n+$/, "");
|
|
409
|
-
if (trimmed.length === 0) return block + "\n";
|
|
410
|
-
return trimmed + "\n\n" + block + "\n";
|
|
411
|
-
}
|
|
412
|
-
function stripAnchorBlock(existing) {
|
|
413
|
-
const afterUnified = stripBlockBetween(existing, ANCHOR_START, ANCHOR_END);
|
|
414
|
-
return stripBlockBetween(afterUnified, LEGACY_ANCHOR_START, LEGACY_ANCHOR_END);
|
|
415
|
-
}
|
|
416
|
-
function stripBlockBetween(existing, start, end) {
|
|
417
|
-
const startIdx = existing.indexOf(start);
|
|
418
|
-
const endIdx = existing.indexOf(end);
|
|
419
|
-
if (startIdx < 0 || endIdx < 0 || endIdx <= startIdx) {
|
|
420
|
-
return existing;
|
|
421
|
-
}
|
|
422
|
-
const before = existing.slice(0, startIdx).replace(/\n+$/, "");
|
|
423
|
-
const after = existing.slice(endIdx + end.length).replace(/^\n+/, "");
|
|
424
|
-
if (before.length === 0 && after.length === 0) return "";
|
|
425
|
-
if (before.length === 0) return after.endsWith("\n") ? after : after + "\n";
|
|
426
|
-
if (after.length === 0) return before + "\n";
|
|
427
|
-
return before + "\n\n" + after + (after.endsWith("\n") ? "" : "\n");
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
// src/channel.wizard.ts
|
|
431
308
|
var JUST_REGISTERED_SENTINEL = "_agentchatJustRegistered";
|
|
432
309
|
var HANDLE_PATTERN = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
|
|
433
310
|
var HANDLE_MIN_LENGTH = 3;
|
|
@@ -906,7 +783,7 @@ var agentchatSetupWizard = {
|
|
|
906
783
|
if (result.ok) {
|
|
907
784
|
spinner.stop(`Authenticated as @${result.agent.handle}`);
|
|
908
785
|
try {
|
|
909
|
-
writeAgentsAnchor({ cfg, handle: result.agent.handle });
|
|
786
|
+
agentsAnchor_js.writeAgentsAnchor({ cfg, handle: result.agent.handle });
|
|
910
787
|
} catch (err3) {
|
|
911
788
|
await prompter.note(
|
|
912
789
|
[
|
|
@@ -977,7 +854,7 @@ var agentchatSetupWizard = {
|
|
|
977
854
|
// documented in RUNBOOK.md.
|
|
978
855
|
disable: (cfg) => {
|
|
979
856
|
try {
|
|
980
|
-
removeAgentsAnchor({ cfg });
|
|
857
|
+
agentsAnchor_js.removeAgentsAnchor({ cfg });
|
|
981
858
|
} catch {
|
|
982
859
|
}
|
|
983
860
|
return setup.setSetupChannelEnabled(cfg, AGENTCHAT_CHANNEL_ID, false);
|
|
@@ -1856,7 +1733,7 @@ function normalizeGroupDeleted(frame) {
|
|
|
1856
1733
|
|
|
1857
1734
|
// src/retry.ts
|
|
1858
1735
|
function defaultSleep(ms) {
|
|
1859
|
-
return new Promise((
|
|
1736
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
1860
1737
|
}
|
|
1861
1738
|
async function retryWithPolicy(fn, policy) {
|
|
1862
1739
|
const random = policy.random ?? Math.random;
|
|
@@ -1984,7 +1861,7 @@ var CircuitBreaker = class {
|
|
|
1984
1861
|
};
|
|
1985
1862
|
|
|
1986
1863
|
// src/version.ts
|
|
1987
|
-
var PACKAGE_VERSION = "0.6.
|
|
1864
|
+
var PACKAGE_VERSION = "0.6.11";
|
|
1988
1865
|
|
|
1989
1866
|
// src/outbound.ts
|
|
1990
1867
|
var DEFAULT_RETRY_POLICY = {
|
|
@@ -2200,11 +2077,11 @@ var OutboundAdapter = class {
|
|
|
2200
2077
|
`outbound queue full (${this.queue.length}) \u2014 shedding load`
|
|
2201
2078
|
);
|
|
2202
2079
|
}
|
|
2203
|
-
return new Promise((
|
|
2080
|
+
return new Promise((resolve) => {
|
|
2204
2081
|
this.queue.push(() => {
|
|
2205
2082
|
this.inFlight++;
|
|
2206
2083
|
this.metrics.setInFlightDepth(this.inFlight);
|
|
2207
|
-
|
|
2084
|
+
resolve();
|
|
2208
2085
|
});
|
|
2209
2086
|
});
|
|
2210
2087
|
}
|
|
@@ -2280,10 +2157,10 @@ var AgentchatChannelRuntime = class {
|
|
|
2280
2157
|
stop(deadlineMs) {
|
|
2281
2158
|
if (this.stopPromise) return this.stopPromise;
|
|
2282
2159
|
const deadline = deadlineMs ?? this.now() + 5e3;
|
|
2283
|
-
this.stopPromise = new Promise((
|
|
2160
|
+
this.stopPromise = new Promise((resolve) => {
|
|
2284
2161
|
const off = this.ws.on("closed", () => {
|
|
2285
2162
|
off();
|
|
2286
|
-
|
|
2163
|
+
resolve();
|
|
2287
2164
|
});
|
|
2288
2165
|
this.ws.stop(deadline);
|
|
2289
2166
|
});
|
|
@@ -2908,8 +2785,8 @@ async function uploadMediaFromUrl(ctx, mediaUrl) {
|
|
|
2908
2785
|
let contentType;
|
|
2909
2786
|
let filename = "attachment";
|
|
2910
2787
|
if (mediaUrl.startsWith("file://") && ctx.mediaReadFile) {
|
|
2911
|
-
const
|
|
2912
|
-
const buf = await ctx.mediaReadFile(
|
|
2788
|
+
const path = decodeURIComponent(mediaUrl.replace(/^file:\/\//, ""));
|
|
2789
|
+
const buf = await ctx.mediaReadFile(path);
|
|
2913
2790
|
if (buf.byteLength > MAX_MEDIA_BYTES) {
|
|
2914
2791
|
throw new AgentChatChannelError(
|
|
2915
2792
|
"terminal-user",
|
|
@@ -2919,7 +2796,7 @@ async function uploadMediaFromUrl(ctx, mediaUrl) {
|
|
|
2919
2796
|
const copy = new Uint8Array(buf.byteLength);
|
|
2920
2797
|
copy.set(new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength));
|
|
2921
2798
|
bytes = copy.buffer;
|
|
2922
|
-
filename =
|
|
2799
|
+
filename = path.split(/[\\/]/).pop() ?? filename;
|
|
2923
2800
|
} else {
|
|
2924
2801
|
assertMediaUrlSafe(mediaUrl);
|
|
2925
2802
|
const controller = new AbortController();
|
|
@@ -4345,8 +4222,6 @@ var agentchatStatusAdapter = {
|
|
|
4345
4222
|
return "not linked";
|
|
4346
4223
|
}
|
|
4347
4224
|
};
|
|
4348
|
-
|
|
4349
|
-
// src/channel.ts
|
|
4350
4225
|
function resolveAgentchatAccount(cfg, accountId) {
|
|
4351
4226
|
const id = accountId ?? AGENTCHAT_DEFAULT_ACCOUNT_ID;
|
|
4352
4227
|
const section = readChannelSection(cfg);
|
|
@@ -4525,7 +4400,7 @@ var agentchatPlugin = {
|
|
|
4525
4400
|
`[agentchat:${accountId}] authenticated as @${result.agent.handle} (${result.agent.email})`
|
|
4526
4401
|
);
|
|
4527
4402
|
try {
|
|
4528
|
-
writeAgentsAnchor({ cfg, handle: result.agent.handle });
|
|
4403
|
+
agentsAnchor_js.writeAgentsAnchor({ cfg, handle: result.agent.handle });
|
|
4529
4404
|
} catch (err3) {
|
|
4530
4405
|
logger?.warn?.(
|
|
4531
4406
|
`[agentchat:${accountId}] AGENTS.md anchor write failed: ${err3 instanceof Error ? err3.message : String(err3)}`
|
|
@@ -4556,7 +4431,7 @@ var agentchatPlugin = {
|
|
|
4556
4431
|
// is triggered BY AgentChat (see openclaw compact-Fl3cALvc.js:636 —
|
|
4557
4432
|
// `runtimeChannel ? resolveChannelMessageToolHints(...) : void 0`),
|
|
4558
4433
|
// which means it can never deliver the persistent identity awareness
|
|
4559
|
-
// we need. Identity
|
|
4434
|
+
// we need. Identity content lives in AGENTS.md via
|
|
4560
4435
|
// `writeAgentsAnchor` — see binding/agents-anchor.ts for the why.
|
|
4561
4436
|
gateway: agentchatGatewayAdapter,
|
|
4562
4437
|
outbound: agentchatOutboundAdapter,
|