@agentchatme/openclaw 0.6.8 → 0.6.10
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 +84 -0
- package/README.md +19 -11
- 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.d.cts +104 -0
- package/dist/binding/agents-anchor.d.ts +104 -0
- package/dist/binding/agents-anchor.js +108 -0
- package/dist/binding/agents-anchor.js.map +1 -0
- package/dist/credentials/read-env.cjs +7 -0
- package/dist/credentials/read-env.cjs.map +1 -1
- package/dist/credentials/read-env.d.cts +27 -9
- package/dist/credentials/read-env.d.ts +27 -9
- package/dist/credentials/read-env.js +7 -1
- package/dist/credentials/read-env.js.map +1 -1
- package/dist/index.cjs +15 -140
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -116
- package/dist/index.js.map +1 -1
- package/dist/setup-entry.cjs +15 -140
- package/dist/setup-entry.cjs.map +1 -1
- package/dist/setup-entry.js +12 -116
- package/dist/setup-entry.js.map +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +13 -1
- package/skills/agentchat/SKILL.md +2 -2
package/dist/setup-entry.cjs
CHANGED
|
@@ -5,9 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var channelCore = require('openclaw/plugin-sdk/channel-core');
|
|
6
6
|
var setup = require('openclaw/plugin-sdk/setup');
|
|
7
7
|
var readEnv_js = require('./credentials/read-env.cjs');
|
|
8
|
-
var
|
|
9
|
-
var os = require('os');
|
|
10
|
-
var path = require('path');
|
|
8
|
+
var agentsAnchor_js = require('./binding/agents-anchor.cjs');
|
|
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.setup.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;
|
|
@@ -320,106 +297,6 @@ async function post(path2, body, opts) {
|
|
|
320
297
|
clearTimeout(timer);
|
|
321
298
|
}
|
|
322
299
|
}
|
|
323
|
-
var ANCHOR_START = "<!-- agentchat:start -->";
|
|
324
|
-
var ANCHOR_END = "<!-- agentchat:end -->";
|
|
325
|
-
var LEGACY_ANCHOR_START = "<!-- agentchat-skill:start -->";
|
|
326
|
-
var LEGACY_ANCHOR_END = "<!-- agentchat-skill:end -->";
|
|
327
|
-
function resolveWorkspaceDir(cfg) {
|
|
328
|
-
const configured = cfg?.agents?.defaults?.workspace;
|
|
329
|
-
if (typeof configured === "string" && configured.trim().length > 0) {
|
|
330
|
-
return path__namespace.resolve(configured);
|
|
331
|
-
}
|
|
332
|
-
const profile = process.env["OPENCLAW_PROFILE"]?.trim();
|
|
333
|
-
if (profile && profile.toLowerCase() !== "default") {
|
|
334
|
-
return path__namespace.join(os__namespace.homedir(), ".openclaw", `workspace-${profile}`);
|
|
335
|
-
}
|
|
336
|
-
return path__namespace.join(os__namespace.homedir(), ".openclaw", "workspace");
|
|
337
|
-
}
|
|
338
|
-
function agentsFilePath(workspaceDir) {
|
|
339
|
-
return path__namespace.join(workspaceDir, "AGENTS.md");
|
|
340
|
-
}
|
|
341
|
-
function renderAnchorBlock(handle) {
|
|
342
|
-
return [
|
|
343
|
-
ANCHOR_START,
|
|
344
|
-
"## On AgentChat",
|
|
345
|
-
"",
|
|
346
|
-
`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.`,
|
|
347
|
-
"",
|
|
348
|
-
"- Other agents can DM you. You can DM them \u2014 any time, for anything that fits your context.",
|
|
349
|
-
`- Share \`@${handle}\` freely. Whenever and wherever you think you should share. It's how peers reach you.`,
|
|
350
|
-
"- When you need to send, search, or handle an error, your AgentChat skill has the full reference.",
|
|
351
|
-
"",
|
|
352
|
-
"This is an identity, not a tool you reach for occasionally.",
|
|
353
|
-
ANCHOR_END
|
|
354
|
-
].join("\n");
|
|
355
|
-
}
|
|
356
|
-
function writeAgentsAnchor(params) {
|
|
357
|
-
const trimmedHandle = params.handle?.trim();
|
|
358
|
-
if (!trimmedHandle) {
|
|
359
|
-
throw new Error("writeAgentsAnchor: handle is empty");
|
|
360
|
-
}
|
|
361
|
-
const workspaceDir = resolveWorkspaceDir(params.cfg);
|
|
362
|
-
const filePath = agentsFilePath(workspaceDir);
|
|
363
|
-
fs__namespace.mkdirSync(workspaceDir, { recursive: true });
|
|
364
|
-
const existing = fs__namespace.existsSync(filePath) ? fs__namespace.readFileSync(filePath, "utf-8") : "";
|
|
365
|
-
const block = renderAnchorBlock(trimmedHandle);
|
|
366
|
-
const next = upsertAnchorBlock(existing, block);
|
|
367
|
-
fs__namespace.writeFileSync(filePath, next, "utf-8");
|
|
368
|
-
const verify = fs__namespace.readFileSync(filePath, "utf-8");
|
|
369
|
-
if (!verify.includes(`@${trimmedHandle}`)) {
|
|
370
|
-
throw new Error(
|
|
371
|
-
`writeAgentsAnchor: handle @${trimmedHandle} did not land in AGENTS.md \u2014 block is broken, please remove the agentchat anchor manually and re-run.`
|
|
372
|
-
);
|
|
373
|
-
}
|
|
374
|
-
return { path: filePath };
|
|
375
|
-
}
|
|
376
|
-
function removeAgentsAnchor(params) {
|
|
377
|
-
const workspaceDir = resolveWorkspaceDir(params.cfg);
|
|
378
|
-
const filePath = agentsFilePath(workspaceDir);
|
|
379
|
-
if (!fs__namespace.existsSync(filePath)) {
|
|
380
|
-
return { removed: false, path: filePath };
|
|
381
|
-
}
|
|
382
|
-
const existing = fs__namespace.readFileSync(filePath, "utf-8");
|
|
383
|
-
const next = stripAnchorBlock(existing);
|
|
384
|
-
if (next === existing) {
|
|
385
|
-
return { removed: false, path: filePath };
|
|
386
|
-
}
|
|
387
|
-
fs__namespace.writeFileSync(filePath, next, "utf-8");
|
|
388
|
-
return { removed: true, path: filePath };
|
|
389
|
-
}
|
|
390
|
-
function upsertAnchorBlock(existing, block) {
|
|
391
|
-
const cleaned = stripBlockBetween(existing, LEGACY_ANCHOR_START, LEGACY_ANCHOR_END);
|
|
392
|
-
const startIdx = cleaned.indexOf(ANCHOR_START);
|
|
393
|
-
const endIdx = cleaned.indexOf(ANCHOR_END);
|
|
394
|
-
if (startIdx >= 0 && endIdx >= 0 && endIdx > startIdx) {
|
|
395
|
-
const before = cleaned.slice(0, startIdx).replace(/\n+$/, "");
|
|
396
|
-
const after = cleaned.slice(endIdx + ANCHOR_END.length).replace(/^\n+/, "");
|
|
397
|
-
const parts = [before, block, after].filter((s) => s.length > 0);
|
|
398
|
-
return parts.join("\n\n") + "\n";
|
|
399
|
-
}
|
|
400
|
-
const trimmed = cleaned.replace(/\n+$/, "");
|
|
401
|
-
if (trimmed.length === 0) return block + "\n";
|
|
402
|
-
return trimmed + "\n\n" + block + "\n";
|
|
403
|
-
}
|
|
404
|
-
function stripAnchorBlock(existing) {
|
|
405
|
-
const afterUnified = stripBlockBetween(existing, ANCHOR_START, ANCHOR_END);
|
|
406
|
-
return stripBlockBetween(afterUnified, LEGACY_ANCHOR_START, LEGACY_ANCHOR_END);
|
|
407
|
-
}
|
|
408
|
-
function stripBlockBetween(existing, start, end) {
|
|
409
|
-
const startIdx = existing.indexOf(start);
|
|
410
|
-
const endIdx = existing.indexOf(end);
|
|
411
|
-
if (startIdx < 0 || endIdx < 0 || endIdx <= startIdx) {
|
|
412
|
-
return existing;
|
|
413
|
-
}
|
|
414
|
-
const before = existing.slice(0, startIdx).replace(/\n+$/, "");
|
|
415
|
-
const after = existing.slice(endIdx + end.length).replace(/^\n+/, "");
|
|
416
|
-
if (before.length === 0 && after.length === 0) return "";
|
|
417
|
-
if (before.length === 0) return after.endsWith("\n") ? after : after + "\n";
|
|
418
|
-
if (after.length === 0) return before + "\n";
|
|
419
|
-
return before + "\n\n" + after + (after.endsWith("\n") ? "" : "\n");
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
// src/channel.wizard.ts
|
|
423
300
|
var JUST_REGISTERED_SENTINEL = "_agentchatJustRegistered";
|
|
424
301
|
var HANDLE_PATTERN = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
|
|
425
302
|
var HANDLE_MIN_LENGTH = 3;
|
|
@@ -898,7 +775,7 @@ var agentchatSetupWizard = {
|
|
|
898
775
|
if (result.ok) {
|
|
899
776
|
spinner.stop(`Authenticated as @${result.agent.handle}`);
|
|
900
777
|
try {
|
|
901
|
-
writeAgentsAnchor({ cfg, handle: result.agent.handle });
|
|
778
|
+
agentsAnchor_js.writeAgentsAnchor({ cfg, handle: result.agent.handle });
|
|
902
779
|
} catch (err3) {
|
|
903
780
|
await prompter.note(
|
|
904
781
|
[
|
|
@@ -969,7 +846,7 @@ var agentchatSetupWizard = {
|
|
|
969
846
|
// documented in RUNBOOK.md.
|
|
970
847
|
disable: (cfg) => {
|
|
971
848
|
try {
|
|
972
|
-
removeAgentsAnchor({ cfg });
|
|
849
|
+
agentsAnchor_js.removeAgentsAnchor({ cfg });
|
|
973
850
|
} catch {
|
|
974
851
|
}
|
|
975
852
|
return setup.setSetupChannelEnabled(cfg, AGENTCHAT_CHANNEL_ID, false);
|
|
@@ -1848,7 +1725,7 @@ function normalizeGroupDeleted(frame) {
|
|
|
1848
1725
|
|
|
1849
1726
|
// src/retry.ts
|
|
1850
1727
|
function defaultSleep(ms) {
|
|
1851
|
-
return new Promise((
|
|
1728
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
1852
1729
|
}
|
|
1853
1730
|
async function retryWithPolicy(fn, policy) {
|
|
1854
1731
|
const random = policy.random ?? Math.random;
|
|
@@ -1976,7 +1853,7 @@ var CircuitBreaker = class {
|
|
|
1976
1853
|
};
|
|
1977
1854
|
|
|
1978
1855
|
// src/version.ts
|
|
1979
|
-
var PACKAGE_VERSION = "0.6.
|
|
1856
|
+
var PACKAGE_VERSION = "0.6.10";
|
|
1980
1857
|
|
|
1981
1858
|
// src/outbound.ts
|
|
1982
1859
|
var DEFAULT_RETRY_POLICY = {
|
|
@@ -2192,11 +2069,11 @@ var OutboundAdapter = class {
|
|
|
2192
2069
|
`outbound queue full (${this.queue.length}) \u2014 shedding load`
|
|
2193
2070
|
);
|
|
2194
2071
|
}
|
|
2195
|
-
return new Promise((
|
|
2072
|
+
return new Promise((resolve) => {
|
|
2196
2073
|
this.queue.push(() => {
|
|
2197
2074
|
this.inFlight++;
|
|
2198
2075
|
this.metrics.setInFlightDepth(this.inFlight);
|
|
2199
|
-
|
|
2076
|
+
resolve();
|
|
2200
2077
|
});
|
|
2201
2078
|
});
|
|
2202
2079
|
}
|
|
@@ -2272,10 +2149,10 @@ var AgentchatChannelRuntime = class {
|
|
|
2272
2149
|
stop(deadlineMs) {
|
|
2273
2150
|
if (this.stopPromise) return this.stopPromise;
|
|
2274
2151
|
const deadline = deadlineMs ?? this.now() + 5e3;
|
|
2275
|
-
this.stopPromise = new Promise((
|
|
2152
|
+
this.stopPromise = new Promise((resolve) => {
|
|
2276
2153
|
const off = this.ws.on("closed", () => {
|
|
2277
2154
|
off();
|
|
2278
|
-
|
|
2155
|
+
resolve();
|
|
2279
2156
|
});
|
|
2280
2157
|
this.ws.stop(deadline);
|
|
2281
2158
|
});
|
|
@@ -2900,8 +2777,8 @@ async function uploadMediaFromUrl(ctx, mediaUrl) {
|
|
|
2900
2777
|
let contentType;
|
|
2901
2778
|
let filename = "attachment";
|
|
2902
2779
|
if (mediaUrl.startsWith("file://") && ctx.mediaReadFile) {
|
|
2903
|
-
const
|
|
2904
|
-
const buf = await ctx.mediaReadFile(
|
|
2780
|
+
const path = decodeURIComponent(mediaUrl.replace(/^file:\/\//, ""));
|
|
2781
|
+
const buf = await ctx.mediaReadFile(path);
|
|
2905
2782
|
if (buf.byteLength > MAX_MEDIA_BYTES) {
|
|
2906
2783
|
throw new AgentChatChannelError(
|
|
2907
2784
|
"terminal-user",
|
|
@@ -2911,7 +2788,7 @@ async function uploadMediaFromUrl(ctx, mediaUrl) {
|
|
|
2911
2788
|
const copy = new Uint8Array(buf.byteLength);
|
|
2912
2789
|
copy.set(new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength));
|
|
2913
2790
|
bytes = copy.buffer;
|
|
2914
|
-
filename =
|
|
2791
|
+
filename = path.split(/[\\/]/).pop() ?? filename;
|
|
2915
2792
|
} else {
|
|
2916
2793
|
assertMediaUrlSafe(mediaUrl);
|
|
2917
2794
|
const controller = new AbortController();
|
|
@@ -4337,8 +4214,6 @@ var agentchatStatusAdapter = {
|
|
|
4337
4214
|
return "not linked";
|
|
4338
4215
|
}
|
|
4339
4216
|
};
|
|
4340
|
-
|
|
4341
|
-
// src/channel.ts
|
|
4342
4217
|
function resolveAgentchatAccount(cfg, accountId) {
|
|
4343
4218
|
const id = accountId ?? AGENTCHAT_DEFAULT_ACCOUNT_ID;
|
|
4344
4219
|
const section = readChannelSection(cfg);
|
|
@@ -4517,7 +4392,7 @@ var agentchatPlugin = {
|
|
|
4517
4392
|
`[agentchat:${accountId}] authenticated as @${result.agent.handle} (${result.agent.email})`
|
|
4518
4393
|
);
|
|
4519
4394
|
try {
|
|
4520
|
-
writeAgentsAnchor({ cfg, handle: result.agent.handle });
|
|
4395
|
+
agentsAnchor_js.writeAgentsAnchor({ cfg, handle: result.agent.handle });
|
|
4521
4396
|
} catch (err3) {
|
|
4522
4397
|
logger?.warn?.(
|
|
4523
4398
|
`[agentchat:${accountId}] AGENTS.md anchor write failed: ${err3 instanceof Error ? err3.message : String(err3)}`
|