@agentchatme/agent-core 0.0.131 → 0.0.1312

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 CHANGED
@@ -93,6 +93,11 @@ import { runDaemon } from '@agentchatme/agent-core/daemon'
93
93
  await runDaemon({ home: profile.home(), adapter: new MyRuntimeAdapter(...) })
94
94
  ```
95
95
 
96
+ The daemon gives each incoming message its own runtime turn. Turns are ordered
97
+ within a conversation and may run concurrently across different conversations.
98
+ A message is acknowledged only after its turn succeeds; a failure stays pending
99
+ and retries with capped exponential backoff instead of being dropped.
100
+
96
101
  ## Development
97
102
 
98
103
  ```
@@ -24,6 +24,19 @@ var log = {
24
24
  debug: (msg) => emit("debug", msg)
25
25
  };
26
26
 
27
+ // src/version.ts
28
+ var VERSION = "0.0.1312";
29
+
30
+ // src/client-identity.ts
31
+ var CODING_AGENTS_CLIENT_IDENTITY = {
32
+ name: "coding_agents",
33
+ version: VERSION
34
+ };
35
+ var CODING_AGENTS_CLIENT_HEADERS = {
36
+ "X-AgentChat-Client": CODING_AGENTS_CLIENT_IDENTITY.name,
37
+ "X-AgentChat-Client-Version": CODING_AGENTS_CLIENT_IDENTITY.version
38
+ };
39
+
27
40
  // src/daemon/leader-lock.ts
28
41
  import * as fs from "fs";
29
42
  import * as path from "path";
@@ -95,6 +108,23 @@ function atomicWriteFile(filePath, data, mode) {
95
108
  fs2.chmodSync(filePath, mode);
96
109
  }
97
110
  }
111
+ function atomicCopyFile(source, destination, mode = 493) {
112
+ const dir = path2.dirname(destination);
113
+ fs2.mkdirSync(dir, { recursive: true, mode: 448 });
114
+ const tmp = path2.join(dir, `.${path2.basename(destination)}.${process.pid}.tmp`);
115
+ try {
116
+ fs2.copyFileSync(source, tmp);
117
+ fs2.chmodSync(tmp, mode);
118
+ fs2.renameSync(tmp, destination);
119
+ fs2.chmodSync(destination, mode);
120
+ } catch (err) {
121
+ try {
122
+ fs2.rmSync(tmp, { force: true });
123
+ } catch {
124
+ }
125
+ throw err;
126
+ }
127
+ }
98
128
  function readJsonFile(filePath) {
99
129
  try {
100
130
  const raw = fs2.readFileSync(filePath, "utf-8");
@@ -4275,6 +4305,7 @@ async function request(cfg, method, pathname, body) {
4275
4305
  const res = await fetch(url, {
4276
4306
  method,
4277
4307
  headers: {
4308
+ ...CODING_AGENTS_CLIENT_HEADERS,
4278
4309
  authorization: `Bearer ${cfg.apiKey}`,
4279
4310
  ...body !== void 0 ? { "content-type": "application/json" } : {}
4280
4311
  },
@@ -4369,6 +4400,7 @@ function lastDeliveryId(rows) {
4369
4400
  import * as fs4 from "fs";
4370
4401
  import * as path4 from "path";
4371
4402
  var ALWAYS_ON_WANTED = "always-on.wanted";
4403
+ var ALWAYS_ON_INSTALLED_VERSION = "always-on.installed-version";
4372
4404
  var HEARTBEAT_FILE = "daemon.heartbeat";
4373
4405
  var HEARTBEAT_STALE_MS = 3 * 6e4;
4374
4406
  function markAlwaysOnWanted(home) {
@@ -4387,6 +4419,24 @@ function clearAlwaysOnWanted(home) {
4387
4419
  function alwaysOnWanted(home) {
4388
4420
  return fs4.existsSync(path4.join(home, ALWAYS_ON_WANTED));
4389
4421
  }
4422
+ function readAlwaysOnInstalledVersion(home) {
4423
+ try {
4424
+ const version = fs4.readFileSync(path4.join(home, ALWAYS_ON_INSTALLED_VERSION), "utf-8").trim();
4425
+ return version.length > 0 ? version : null;
4426
+ } catch {
4427
+ return null;
4428
+ }
4429
+ }
4430
+ function markAlwaysOnInstalledVersion(home, version) {
4431
+ atomicWriteFile(path4.join(home, ALWAYS_ON_INSTALLED_VERSION), `${version}
4432
+ `, 384);
4433
+ }
4434
+ function clearAlwaysOnInstalledVersion(home) {
4435
+ try {
4436
+ fs4.rmSync(path4.join(home, ALWAYS_ON_INSTALLED_VERSION), { force: true });
4437
+ } catch {
4438
+ }
4439
+ }
4390
4440
  var ALWAYS_ON_OPTOUT = "always-on.optout";
4391
4441
  function markAlwaysOnOptOut(home) {
4392
4442
  try {
@@ -4444,8 +4494,12 @@ function alwaysOnHealth(home) {
4444
4494
  export {
4445
4495
  log,
4446
4496
  external_exports,
4497
+ VERSION,
4498
+ CODING_AGENTS_CLIENT_IDENTITY,
4499
+ CODING_AGENTS_CLIENT_HEADERS,
4447
4500
  acquireLeaderLock,
4448
4501
  atomicWriteFile,
4502
+ atomicCopyFile,
4449
4503
  readJsonFile,
4450
4504
  DEFAULT_API_BASE,
4451
4505
  credentialsPath,
@@ -4471,6 +4525,9 @@ export {
4471
4525
  markAlwaysOnWanted,
4472
4526
  clearAlwaysOnWanted,
4473
4527
  alwaysOnWanted,
4528
+ readAlwaysOnInstalledVersion,
4529
+ markAlwaysOnInstalledVersion,
4530
+ clearAlwaysOnInstalledVersion,
4474
4531
  markAlwaysOnOptOut,
4475
4532
  clearAlwaysOnOptOut,
4476
4533
  alwaysOnOptedOut,
@@ -4479,4 +4536,4 @@ export {
4479
4536
  alwaysOnState,
4480
4537
  alwaysOnHealth
4481
4538
  };
4482
- //# sourceMappingURL=chunk-XLRPNQ7G.js.map
4539
+ //# sourceMappingURL=chunk-AGDJ4A6R.js.map