@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/dist/daemon-entry.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as IntegrationClient, L as LeaseOptions,
|
|
1
|
+
import { I as IntegrationClient, M as ManualPointer, A as AnchorServedLine, a as AnchorLoadNote, L as LeaseOptions, b as ManualFetch, c as IntegrationStatus, d as IntegrationRunsFailing, S as SocketState } from './served-manual-CwxBzpwQ.js';
|
|
2
2
|
import { R as RunnerSource, a as RunProfile, b as RunRunner, c as RunOutcome } from './runner-BLvFalN4.js';
|
|
3
3
|
export { d as RunKind, e as RunOutcomeState, f as RunPreflight, g as RunRequest, h as RunWake, i as RunnerFactory, j as RunnerIdentity } from './runner-BLvFalN4.js';
|
|
4
4
|
import { AgentChatClient, RealtimeClient, BlockedInfo, RealtimeState } from 'agentchatme';
|
|
@@ -11,8 +11,14 @@ interface RunIntegrationOpts {
|
|
|
11
11
|
runner: RunnerSource;
|
|
12
12
|
/** How this integration names itself to the server: the texts runtime and its own version. */
|
|
13
13
|
client: IntegrationClient;
|
|
14
|
-
/**
|
|
15
|
-
|
|
14
|
+
/**
|
|
15
|
+
* The one pointer line a run prompt ends with: how THIS runtime reaches its
|
|
16
|
+
* copy of the manual. A function of the manual's address
|
|
17
|
+
* (`(url) => manualPointer(location, url)`) is called for each run with the
|
|
18
|
+
* address the served texts announce, so the line follows them; a plain
|
|
19
|
+
* string is used as it is.
|
|
20
|
+
*/
|
|
21
|
+
manualPointer: ManualPointer;
|
|
16
22
|
/**
|
|
17
23
|
* The skill file that follows the served manual (`<skills dir>/agentchat/SKILL.md`):
|
|
18
24
|
* whenever the texts in hand announce a version the file does not carry, the
|
|
@@ -20,6 +26,17 @@ interface RunIntegrationOpts {
|
|
|
20
26
|
* daemon leaves the manual to the CLI's install and `doctor --fix`.
|
|
21
27
|
*/
|
|
22
28
|
manualPath?: string;
|
|
29
|
+
/**
|
|
30
|
+
* The host's always-loaded instruction file (the one install places the
|
|
31
|
+
* identity line in): whenever the served texts change, this agent's own
|
|
32
|
+
* identity block there is brought to the served line — never created where
|
|
33
|
+
* there is none, never one that is another agent's, the setup offer, or
|
|
34
|
+
* edited by hand (`followIdentityAnchor`). Absent, the block is left to the
|
|
35
|
+
* CLI's install and `doctor --fix`.
|
|
36
|
+
*/
|
|
37
|
+
anchorPath?: string;
|
|
38
|
+
/** Which file the runtime loads in `anchorPath`'s place, and whether its identity line is the served one, or null (see `IntegrationOptions.anchorLoadNote`). */
|
|
39
|
+
anchorLoadNote?: (handle: string, served: AnchorServedLine) => AnchorLoadNote | null;
|
|
23
40
|
/** Scratch dir for runs. The integration decides where; this package never derives one. */
|
|
24
41
|
workdir: string;
|
|
25
42
|
/** Defaults to `AGENTCHAT_RUN_PROFILE` (`resolveRunProfile`: unset is `own`, a value that names no profile is `answer`). */
|
|
@@ -123,8 +140,27 @@ interface IntegrationOptions {
|
|
|
123
140
|
readonly runner: RunRunner;
|
|
124
141
|
/** How this integration names itself to the server (texts runtime + its version). */
|
|
125
142
|
readonly client: IntegrationClient;
|
|
126
|
-
/**
|
|
127
|
-
|
|
143
|
+
/**
|
|
144
|
+
* The one pointer line a run prompt ends with: a function of the manual's
|
|
145
|
+
* address (`(url) => manualPointer(location, url)`), called with the address
|
|
146
|
+
* the texts in hand announce; a plain string is used as it is.
|
|
147
|
+
*/
|
|
148
|
+
readonly manualPointer: ManualPointer;
|
|
149
|
+
/**
|
|
150
|
+
* The host's always-loaded instruction file, whose AgentChat identity block
|
|
151
|
+
* follows the served identity line from then on (`followIdentityAnchor`).
|
|
152
|
+
* Absent, the block is left to the CLI's install and `doctor --fix`.
|
|
153
|
+
*/
|
|
154
|
+
readonly anchorPath?: string;
|
|
155
|
+
/**
|
|
156
|
+
* For a runtime that reads another file in `anchorPath`'s place when that
|
|
157
|
+
* one exists: which file it loads, and whether the identity line there is
|
|
158
|
+
* the served one (judged against the texts being followed), or null when
|
|
159
|
+
* it loads `anchorPath` (`HostProfile.anchorLoadNote`). Said with every
|
|
160
|
+
* follow; when `ok` is false, at warn and as the status file's
|
|
161
|
+
* `identity_line.not_loaded`. Nothing is written into that other file.
|
|
162
|
+
*/
|
|
163
|
+
readonly anchorLoadNote?: (handle: string, served: AnchorServedLine) => AnchorLoadNote | null;
|
|
128
164
|
/** The skill file that follows the served manual (`<skills dir>/agentchat/SKILL.md`); absent, the manual is left to the CLI. */
|
|
129
165
|
readonly manualPath?: string;
|
|
130
166
|
/** Injectable for tests; the manual download's `fetch`. */
|
|
@@ -171,6 +207,8 @@ interface IntegrationOptions {
|
|
|
171
207
|
readonly conversationRuns?: boolean;
|
|
172
208
|
/** Injectable for tests; `RUNTIME_CHECK_DEADLINE_MS`. */
|
|
173
209
|
readonly runtimeCheckDeadlineMs?: number;
|
|
210
|
+
/** Injectable for tests: how soon the served texts are fetched again after a fetch (the kit's 24 h). */
|
|
211
|
+
readonly textsRefreshMs?: number;
|
|
174
212
|
}
|
|
175
213
|
declare class Integration {
|
|
176
214
|
private readonly options;
|
|
@@ -213,6 +251,10 @@ declare class Integration {
|
|
|
213
251
|
private readonly paused;
|
|
214
252
|
/** The runner's runtime check in flight: concurrent asks share it. */
|
|
215
253
|
private runtimeCheckInFlight;
|
|
254
|
+
/** What the identity block's last follow did (status `identity_line`); null without `anchorPath`, or before the first texts. */
|
|
255
|
+
private identityLine;
|
|
256
|
+
/** The follows of the identity line, one after another (each texts change queues one; a stop waits for the one in flight). */
|
|
257
|
+
private follows;
|
|
216
258
|
constructor(options: IntegrationOptions);
|
|
217
259
|
start(): Promise<void>;
|
|
218
260
|
/**
|
|
@@ -270,6 +312,13 @@ declare class Integration {
|
|
|
270
312
|
* pause ends; any other answer for that conversation ends what was kept.
|
|
271
313
|
*/
|
|
272
314
|
private onProcessingFailure;
|
|
315
|
+
/**
|
|
316
|
+
* The identity block follows the served identity line: on each texts
|
|
317
|
+
* change, this agent's own block in the host's instruction file is brought
|
|
318
|
+
* to the line served now (`followIdentityAnchor`, under its rules). Said in
|
|
319
|
+
* the log and the status file (`identity_line`); never throws.
|
|
320
|
+
*/
|
|
321
|
+
private followIdentityLine;
|
|
273
322
|
private writeStatus;
|
|
274
323
|
}
|
|
275
324
|
|
package/dist/daemon-entry.js
CHANGED
|
@@ -10,14 +10,16 @@ import {
|
|
|
10
10
|
credentialsPath,
|
|
11
11
|
describeManualSync,
|
|
12
12
|
envKeyConflict,
|
|
13
|
+
followIdentityAnchor,
|
|
13
14
|
idle,
|
|
14
15
|
isRunnerFactory,
|
|
15
16
|
markStandby,
|
|
16
17
|
resolveIdentity,
|
|
18
|
+
resolveManualPointer,
|
|
17
19
|
standbyWaiting,
|
|
18
20
|
textsCachePath,
|
|
19
21
|
writeIntegrationStatus
|
|
20
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-FPAOQGMV.js";
|
|
21
23
|
import {
|
|
22
24
|
INTEGRATION_ENV,
|
|
23
25
|
INTEGRATION_ENV_LEGACY,
|
|
@@ -180,10 +182,12 @@ var Integration = class {
|
|
|
180
182
|
client: this.api,
|
|
181
183
|
runtime: client.runtime,
|
|
182
184
|
filePath: textsCachePath(cfg.home),
|
|
183
|
-
onError: (err) => log.warn(err.message)
|
|
185
|
+
onError: (err) => log.warn(err.message),
|
|
186
|
+
...options.textsRefreshMs !== void 0 ? { refreshMs: options.textsRefreshMs } : {}
|
|
184
187
|
});
|
|
185
188
|
this.texts.onChange((texts, source) => {
|
|
186
189
|
log.info(`texts ${source === "server" ? "fetched" : "read from the cache"} for ${client.runtime} (texts v${texts.version}, manual ${texts.manual.version})`);
|
|
190
|
+
this.follows = this.follows.then(() => this.followIdentityLine(texts));
|
|
187
191
|
this.writeStatus();
|
|
188
192
|
});
|
|
189
193
|
this.manual = options.manualPath === void 0 ? null : new kit.ManualSync({
|
|
@@ -290,6 +294,10 @@ var Integration = class {
|
|
|
290
294
|
paused;
|
|
291
295
|
/** The runner's runtime check in flight: concurrent asks share it. */
|
|
292
296
|
runtimeCheckInFlight = null;
|
|
297
|
+
/** What the identity block's last follow did (status `identity_line`); null without `anchorPath`, or before the first texts. */
|
|
298
|
+
identityLine = null;
|
|
299
|
+
/** The follows of the identity line, one after another (each texts change queues one; a stop waits for the one in flight). */
|
|
300
|
+
follows = Promise.resolve();
|
|
293
301
|
async start() {
|
|
294
302
|
const pre = await withDeadline(this.options.runner.preflight(), PREFLIGHT_DEADLINE_MS, () => ({
|
|
295
303
|
ok: false,
|
|
@@ -300,6 +308,7 @@ var Integration = class {
|
|
|
300
308
|
`integration up as @${this.options.cfg.handle} via ${this.options.runner.name} (${this.options.client.runtime} ${this.options.client.version}), profile ${this.options.profile}; fetching the served texts, then holding the socket`
|
|
301
309
|
);
|
|
302
310
|
await this.texts.start();
|
|
311
|
+
await this.follows;
|
|
303
312
|
if (this.stopping) return;
|
|
304
313
|
void this.manual?.start();
|
|
305
314
|
await this.loop.start();
|
|
@@ -322,7 +331,7 @@ var Integration = class {
|
|
|
322
331
|
if (this.heartbeatTimer) clearInterval(this.heartbeatTimer);
|
|
323
332
|
if (this.statusTimer) clearInterval(this.statusTimer);
|
|
324
333
|
this.recheckAbort.abort();
|
|
325
|
-
this.stopped = Promise.all([this.loop.stop(), this.recheckInFlight ?? Promise.resolve()]).then(() => void 0);
|
|
334
|
+
this.stopped = Promise.all([this.loop.stop(), this.recheckInFlight ?? Promise.resolve(), this.follows]).then(() => void 0);
|
|
326
335
|
this.texts.stop();
|
|
327
336
|
this.manual?.stop();
|
|
328
337
|
this.socket = "closed";
|
|
@@ -392,6 +401,7 @@ var Integration = class {
|
|
|
392
401
|
version: texts?.version ?? null,
|
|
393
402
|
manual_version: texts?.manual.version ?? null
|
|
394
403
|
},
|
|
404
|
+
identity_line: this.identityLine,
|
|
395
405
|
capabilities: status.socket === null ? null : status.socket.capabilities,
|
|
396
406
|
intake_paused: status.socket === null ? null : status.socket.intakePaused,
|
|
397
407
|
recent_cycles: status.recentCycles.map((cycle) => ({
|
|
@@ -423,7 +433,14 @@ var Integration = class {
|
|
|
423
433
|
const onAbort = () => controller.abort();
|
|
424
434
|
if (request.signal.aborted) controller.abort();
|
|
425
435
|
else request.signal.addEventListener("abort", onAbort, { once: true });
|
|
426
|
-
const
|
|
436
|
+
const texts = this.texts.current();
|
|
437
|
+
const identityLine = texts?.identity_line;
|
|
438
|
+
let pointer = "";
|
|
439
|
+
try {
|
|
440
|
+
pointer = resolveManualPointer(this.options.manualPointer, texts);
|
|
441
|
+
} catch (err) {
|
|
442
|
+
log.warn(`run pointer: the integration's pointer function threw (${err instanceof Error ? err.message : String(err)}); the run starts without the line`);
|
|
443
|
+
}
|
|
427
444
|
let outcome;
|
|
428
445
|
try {
|
|
429
446
|
outcome = await withDeadline(
|
|
@@ -432,9 +449,9 @@ var Integration = class {
|
|
|
432
449
|
...conversationId !== void 0 ? { conversationId } : {},
|
|
433
450
|
wake,
|
|
434
451
|
// No pointer, no trailing blank lines.
|
|
435
|
-
prompt:
|
|
452
|
+
prompt: pointer.trim().length > 0 ? `${request.prompt}
|
|
436
453
|
|
|
437
|
-
${
|
|
454
|
+
${pointer}` : request.prompt,
|
|
438
455
|
runId,
|
|
439
456
|
...identityLine !== void 0 && identityLine.trim().length > 0 ? { identityLine } : {},
|
|
440
457
|
budgetMs,
|
|
@@ -681,6 +698,57 @@ ${this.options.manualPointer}` : request.prompt,
|
|
|
681
698
|
}
|
|
682
699
|
this.writeStatus();
|
|
683
700
|
}
|
|
701
|
+
/**
|
|
702
|
+
* The identity block follows the served identity line: on each texts
|
|
703
|
+
* change, this agent's own block in the host's instruction file is brought
|
|
704
|
+
* to the line served now (`followIdentityAnchor`, under its rules). Said in
|
|
705
|
+
* the log and the status file (`identity_line`); never throws.
|
|
706
|
+
*/
|
|
707
|
+
async followIdentityLine(texts) {
|
|
708
|
+
const filePath = this.options.anchorPath;
|
|
709
|
+
if (filePath === void 0 || this.stopping) return;
|
|
710
|
+
let result;
|
|
711
|
+
try {
|
|
712
|
+
result = await followIdentityAnchor({
|
|
713
|
+
filePath,
|
|
714
|
+
handle: this.options.cfg.handle,
|
|
715
|
+
identityLine: texts.identity_line,
|
|
716
|
+
template: texts.identity_line_template
|
|
717
|
+
});
|
|
718
|
+
} catch (err) {
|
|
719
|
+
result = { outcome: "failed", path: filePath, claimed: null, detail: `could not follow the identity line in ${filePath}: ${err instanceof Error ? err.message : String(err)}` };
|
|
720
|
+
}
|
|
721
|
+
let loadNote = null;
|
|
722
|
+
try {
|
|
723
|
+
loadNote = this.options.anchorLoadNote?.(this.options.cfg.handle, { identityLine: texts.identity_line, template: texts.identity_line_template }) ?? null;
|
|
724
|
+
} catch {
|
|
725
|
+
loadNote = null;
|
|
726
|
+
}
|
|
727
|
+
const notLoaded = loadNote !== null && !loadNote.ok ? loadNote.note : null;
|
|
728
|
+
const detail = loadNote === null ? result.detail : `${result.detail}; ${loadNote.note}`;
|
|
729
|
+
this.identityLine = { outcome: result.outcome, path: result.path, at: (/* @__PURE__ */ new Date()).toISOString(), texts_version: texts.version, detail, not_loaded: notLoaded };
|
|
730
|
+
const line = `identity line: ${result.outcome} \u2014 ${detail}`;
|
|
731
|
+
this.writeStatus();
|
|
732
|
+
if (notLoaded !== null && result.outcome !== "other_agent") {
|
|
733
|
+
log.warn(line);
|
|
734
|
+
return;
|
|
735
|
+
}
|
|
736
|
+
switch (result.outcome) {
|
|
737
|
+
case "updated":
|
|
738
|
+
case "absent":
|
|
739
|
+
case "hand_edited":
|
|
740
|
+
log.info(line);
|
|
741
|
+
break;
|
|
742
|
+
case "unchanged":
|
|
743
|
+
log.debug(line);
|
|
744
|
+
break;
|
|
745
|
+
case "other_agent":
|
|
746
|
+
log.error(line);
|
|
747
|
+
break;
|
|
748
|
+
default:
|
|
749
|
+
log.warn(line);
|
|
750
|
+
}
|
|
751
|
+
}
|
|
684
752
|
writeStatus() {
|
|
685
753
|
writeIntegrationStatus(this.options.cfg.home, this.snapshot());
|
|
686
754
|
}
|
|
@@ -974,6 +1042,8 @@ async function runIntegration(opts) {
|
|
|
974
1042
|
client: opts.client,
|
|
975
1043
|
manualPointer: opts.manualPointer,
|
|
976
1044
|
...opts.manualPath !== void 0 ? { manualPath: opts.manualPath } : {},
|
|
1045
|
+
...opts.anchorPath !== void 0 ? { anchorPath: opts.anchorPath } : {},
|
|
1046
|
+
...opts.anchorLoadNote !== void 0 ? { anchorLoadNote: opts.anchorLoadNote } : {},
|
|
977
1047
|
profile,
|
|
978
1048
|
budgetMs,
|
|
979
1049
|
...opts.dismissIgnoredInvites !== void 0 ? { dismissIgnoredInvites: opts.dismissIgnoredInvites } : {},
|