@agentchatme/agent-core 0.2.0 → 0.3.0

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.
@@ -1,7 +1,8 @@
1
- import { R as RunRunner, I as IntegrationClient, a as RunProfile, S as SocketState, T as TextsStore, b as IntegrationStatus, c as RunPrompts, d as TimerHandle, e as IntegrationLastRun, f as RunOutcome } from './prompts-B0UL03Hu.js';
2
- export { D as DEFAULT_WAKE_DEBOUNCE_MS, g as RunKind, h as RunOutcomeState, i as RunPreflight, j as RunRequest, W as WakeCoalescer, k as WakeCoalescerOptions } from './prompts-B0UL03Hu.js';
1
+ import { R as RunRunner, I as IntegrationClient, a as RunProfile, S as SocketState, M as ManualFetch, T as TextsStore, b as IntegrationStatus, c as RunPrompts, d as TimerHandle, e as IntegrationLastRun, f as RunOutcome } from './prompts-BUfpwUT7.js';
2
+ export { D as DEFAULT_WAKE_DEBOUNCE_MS, g as RunKind, h as RunOutcomeState, i as RunPreflight, j as RunRequest, W as WakeCoalescer, k as WakeCoalescerOptions } from './prompts-BUfpwUT7.js';
3
3
  import { BlockedInfo, RealtimeState, AgentChatClient } from 'agentchatme';
4
4
  import { EventEmitter } from 'node:events';
5
+ import 'zod';
5
6
 
6
7
  interface RunIntegrationOpts {
7
8
  /** THE identity home for the agent this daemon serves. */
@@ -12,6 +13,13 @@ interface RunIntegrationOpts {
12
13
  client: IntegrationClient;
13
14
  /** The one pointer line a run prompt ends with: how THIS runtime reaches its copy of the manual (`manualPointer(...)`). */
14
15
  manualPointer: string;
16
+ /**
17
+ * The skill file that follows the served manual (`<skills dir>/agentchat/SKILL.md`):
18
+ * whenever the texts in hand announce a version the file does not carry, the
19
+ * announced manual is downloaded, checked and written over it. Absent, the
20
+ * daemon leaves the manual to the CLI's install and `doctor --fix`.
21
+ */
22
+ manualPath?: string;
15
23
  /** Scratch dir for runs. The integration decides where; this package never derives one. */
16
24
  workdir: string;
17
25
  /** Defaults to `AGENTCHAT_RUN_PROFILE`, then `answer`. */
@@ -159,6 +167,10 @@ interface IntegrationOptions {
159
167
  readonly client: IntegrationClient;
160
168
  /** The one pointer line a run prompt ends with (`manualPointer(...)`). */
161
169
  readonly manualPointer: string;
170
+ /** The skill file that follows the served manual (`<skills dir>/agentchat/SKILL.md`); absent, the daemon leaves the manual to the CLI. */
171
+ readonly manualPath?: string;
172
+ /** Injectable for tests; the manual download's `fetch`. */
173
+ readonly manualFetch?: ManualFetch;
162
174
  readonly profile: RunProfile;
163
175
  readonly budgetMs: number;
164
176
  /** Injectable for tests; defaults to a real connection on the SDK socket. */
@@ -173,6 +185,7 @@ declare class Integration {
173
185
  private readonly api;
174
186
  private readonly connection;
175
187
  private readonly texts;
188
+ private readonly manual;
176
189
  private readonly invoker;
177
190
  private heartbeatTimer;
178
191
  private statusTimer;
@@ -196,6 +209,12 @@ declare class Integration {
196
209
  /** A run in flight finishes on its own; this resolves when it has. */
197
210
  settled(): Promise<void>;
198
211
  snapshot(): IntegrationStatus;
212
+ /**
213
+ * After every change in the texts in hand: the status file, and the skill
214
+ * file brought to the manual they announce. Exposed for an injected store's
215
+ * `onChange` (tests); the store this class builds calls it itself.
216
+ */
217
+ textsChanged(): void;
199
218
  /** The served texts plus the pointer line, or null while no text is in hand. */
200
219
  private runPrompts;
201
220
  /**
@@ -1,4 +1,5 @@
1
1
  import {
2
+ ManualFollower,
2
3
  TextsStore,
3
4
  acquireLeaderLock,
4
5
  atomicWriteFile,
@@ -19,7 +20,7 @@ import {
19
20
  spawnCommandSync,
20
21
  trayHasWaiting,
21
22
  writeIntegrationStatus
22
- } from "./chunk-GXAX47O6.js";
23
+ } from "./chunk-KUZZ3MW2.js";
23
24
 
24
25
  // src/integration/run.ts
25
26
  import * as path3 from "path";
@@ -786,7 +787,8 @@ var Integration = class {
786
787
  timeoutMs: HTTP_TIMEOUT_MS,
787
788
  retry: { maxRetries: 0, baseDelayMs: 0, maxDelayMs: 0 }
788
789
  });
789
- this.texts = options.texts ?? new TextsStore({ home: cfg.home, runtime: client.runtime, client: this.api, onChange: () => this.writeStatus() });
790
+ this.manual = options.manualPath === void 0 ? null : new ManualFollower({ path: options.manualPath, apiBase: cfg.apiBase, ...options.manualFetch !== void 0 ? { fetch: options.manualFetch } : {} });
791
+ this.texts = options.texts ?? new TextsStore({ home: cfg.home, runtime: client.runtime, client: this.api, onChange: () => this.textsChanged() });
790
792
  this.invoker = new IntegrationInvoker({
791
793
  runner: options.runner,
792
794
  prompts: () => this.runPrompts(),
@@ -821,6 +823,7 @@ var Integration = class {
821
823
  api;
822
824
  connection;
823
825
  texts;
826
+ manual;
824
827
  invoker;
825
828
  heartbeatTimer = null;
826
829
  statusTimer = null;
@@ -857,6 +860,7 @@ var Integration = class {
857
860
  if (this.statusTimer) clearInterval(this.statusTimer);
858
861
  this.invoker.stop();
859
862
  this.texts.stop();
863
+ this.manual?.stop();
860
864
  this.connection.stop();
861
865
  idle(this.options.cfg.home);
862
866
  this.writeStatus();
@@ -918,6 +922,15 @@ var Integration = class {
918
922
  }
919
923
  };
920
924
  }
925
+ /**
926
+ * After every change in the texts in hand: the status file, and the skill
927
+ * file brought to the manual they announce. Exposed for an injected store's
928
+ * `onChange` (tests); the store this class builds calls it itself.
929
+ */
930
+ textsChanged() {
931
+ this.writeStatus();
932
+ if (this.manual !== null && !this.stopping) void this.manual.follow(this.texts.current()?.manual ?? null);
933
+ }
921
934
  /** The served texts plus the pointer line, or null while no text is in hand. */
922
935
  async runPrompts() {
923
936
  const texts = await this.texts.ensure();
@@ -1088,6 +1101,7 @@ async function runIntegration(opts) {
1088
1101
  runner: opts.runner,
1089
1102
  client: opts.client,
1090
1103
  manualPointer: opts.manualPointer,
1104
+ ...opts.manualPath !== void 0 ? { manualPath: opts.manualPath } : {},
1091
1105
  profile,
1092
1106
  budgetMs
1093
1107
  });