@agentchatme/agent-core 0.7.3 → 0.8.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.
- package/README.md +73 -3
- package/dist/{chunk-FPAOQGMV.js → chunk-6GMYBMID.js} +869 -197
- package/dist/chunk-6GMYBMID.js.map +1 -0
- package/dist/{chunk-5KMQ23O6.js → chunk-LPTOKVEE.js} +17 -2
- package/dist/chunk-LPTOKVEE.js.map +1 -0
- package/dist/{chunk-7TTV2CQX.js → chunk-WYBLSTYB.js} +3 -3
- package/dist/{chunk-7TTV2CQX.js.map → chunk-WYBLSTYB.js.map} +1 -1
- package/dist/daemon-entry.d.ts +28 -2
- package/dist/daemon-entry.js +121 -39
- package/dist/daemon-entry.js.map +1 -1
- package/dist/index.d.ts +297 -10
- package/dist/index.js +451 -124
- package/dist/index.js.map +1 -1
- package/dist/{served-manual-CwxBzpwQ.d.ts → listener-report-V3oMkCj2.d.ts} +622 -397
- package/dist/presets.js +3 -3
- package/dist/presets.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-5KMQ23O6.js.map +0 -1
- package/dist/chunk-FPAOQGMV.js.map +0 -1
|
@@ -95,6 +95,16 @@ interface IntegrationClient {
|
|
|
95
95
|
* names itself here, and `runtime` stays what the texts are rendered for.
|
|
96
96
|
*/
|
|
97
97
|
readonly name?: string;
|
|
98
|
+
/**
|
|
99
|
+
* The runtime this integration runs inside and its version, as
|
|
100
|
+
* `<runtime>/<version>` (`claude-code/2.1.332`; `hostIdentityOf`): `host`
|
|
101
|
+
* in X-AgentChat-Platform. Absent when it could not be read.
|
|
102
|
+
*/
|
|
103
|
+
readonly host?: string;
|
|
104
|
+
/** This identity home's install id (`ensureInstallId`): `install` in X-AgentChat-Platform. */
|
|
105
|
+
readonly installId?: string;
|
|
106
|
+
/** How this integration was installed, only when known for sure (`installMethodOf`): `method`. */
|
|
107
|
+
readonly installMethod?: string;
|
|
98
108
|
}
|
|
99
109
|
/** The name this client identifies as: its own `name`, else its runtime. */
|
|
100
110
|
declare function clientNameOf(client: IntegrationClient): string;
|
|
@@ -104,7 +114,26 @@ declare function clientNameOf(client: IntegrationClient): string;
|
|
|
104
114
|
* runtime name is passed through as-is; the union widens on the SDK side.
|
|
105
115
|
*/
|
|
106
116
|
declare function clientIdentityOf(client: IntegrationClient): AgentChatClientIdentity;
|
|
107
|
-
/**
|
|
117
|
+
/**
|
|
118
|
+
* `<runtime>/<version>` from a runtime's own version output (`claude
|
|
119
|
+
* --version` → `2.1.332 (Claude Code)`, `codex --version` → `codex-cli
|
|
120
|
+
* 0.154.0`): the first `x.y.z` in it. Null when it holds none.
|
|
121
|
+
*/
|
|
122
|
+
declare function hostIdentityOf(runtime: string, versionOutput: string): string | null;
|
|
123
|
+
/**
|
|
124
|
+
* How the code at `modulePath` was installed, only when that is certain from
|
|
125
|
+
* where it runs: `npx` for npm's exec cache (`…/_npx/<hash>/node_modules/…`).
|
|
126
|
+
* Null otherwise (a global install, a checkout, a copy the service runs):
|
|
127
|
+
* the method is left out rather than guessed.
|
|
128
|
+
*/
|
|
129
|
+
declare function installMethodOf(modulePath: string): string | null;
|
|
130
|
+
/**
|
|
131
|
+
* The client headers placed in a runtime's own tool configuration (the MCP
|
|
132
|
+
* entries a run reads), where they stay until the next placement. They name
|
|
133
|
+
* the integration and its version only: X-AgentChat-Platform is per request
|
|
134
|
+
* (the SDK sends it on every call it makes, the hosted-tools probe included),
|
|
135
|
+
* and a platform written into a config file would go stale there.
|
|
136
|
+
*/
|
|
108
137
|
declare function clientHeadersOf(client: IntegrationClient): Record<string, string>;
|
|
109
138
|
|
|
110
139
|
/**
|
|
@@ -255,353 +284,173 @@ declare function identityBlockState(filePath: string, options: IdentityBlockStat
|
|
|
255
284
|
*/
|
|
256
285
|
declare function describeIdentityBlock(state: IdentityBlockState, fix: string): string;
|
|
257
286
|
|
|
258
|
-
declare const
|
|
259
|
-
|
|
260
|
-
|
|
287
|
+
declare const DEFAULT_API_BASE = "https://api.agentchat.me";
|
|
288
|
+
declare const CredentialsSchema: z.ZodObject<{
|
|
289
|
+
api_key: z.ZodString;
|
|
290
|
+
handle: z.ZodString;
|
|
291
|
+
api_base: z.ZodOptional<z.ZodString>;
|
|
292
|
+
created_at: z.ZodOptional<z.ZodString>;
|
|
293
|
+
}, "strip", z.ZodTypeAny, {
|
|
294
|
+
api_key: string;
|
|
295
|
+
handle: string;
|
|
296
|
+
api_base?: string | undefined;
|
|
297
|
+
created_at?: string | undefined;
|
|
298
|
+
}, {
|
|
299
|
+
api_key: string;
|
|
300
|
+
handle: string;
|
|
301
|
+
api_base?: string | undefined;
|
|
302
|
+
created_at?: string | undefined;
|
|
303
|
+
}>;
|
|
304
|
+
type Credentials = z.infer<typeof CredentialsSchema>;
|
|
305
|
+
interface ResolvedIdentity {
|
|
306
|
+
apiKey: string;
|
|
307
|
+
apiBase: string;
|
|
308
|
+
/** Handle is only known when it came from the credentials file. */
|
|
309
|
+
handle: string | null;
|
|
310
|
+
source: 'env' | 'file';
|
|
311
|
+
}
|
|
312
|
+
declare function credentialsPath(home: string): string;
|
|
313
|
+
declare function pendingPath(home: string): string;
|
|
314
|
+
declare function statePath(home: string): string;
|
|
315
|
+
/** Read the credential stored in `home`, or null when absent/malformed. */
|
|
316
|
+
declare function readCredentials(home: string): Credentials | null;
|
|
261
317
|
/**
|
|
262
|
-
* The
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
318
|
+
* The identity an integration should act as, for one specific home: the
|
|
319
|
+
* home's `credentials`, else `AGENTCHAT_API_KEY` when the home holds no key.
|
|
320
|
+
* `AGENTCHAT_API_BASE` overrides the base URL. Neither is host-specific, so
|
|
321
|
+
* both are read from the environment.
|
|
266
322
|
*/
|
|
267
|
-
|
|
268
|
-
type SocketState = (typeof SOCKET_STATES)[number];
|
|
269
|
-
type TextsSource = 'server' | 'cache' | 'none';
|
|
270
|
-
interface TextsStatus {
|
|
271
|
-
/** Where the texts a run starts with came from. */
|
|
272
|
-
source: TextsSource;
|
|
273
|
-
fetched_at: string | null;
|
|
274
|
-
/** The served text set's version. */
|
|
275
|
-
version: string | null;
|
|
276
|
-
manual_version: string | null;
|
|
277
|
-
}
|
|
278
|
-
interface IntegrationLastRun {
|
|
323
|
+
interface ResolveIdentityOptions {
|
|
279
324
|
/**
|
|
280
|
-
* `
|
|
281
|
-
*
|
|
282
|
-
*
|
|
325
|
+
* Whether `AGENTCHAT_API_KEY` may stand in for a home that holds no key
|
|
326
|
+
* (default true). It never overrides a key the home holds. A resident
|
|
327
|
+
* listener passes false: the agent it serves is the one its home holds,
|
|
328
|
+
* whatever happens to be exported in the shell that started it.
|
|
283
329
|
*/
|
|
284
|
-
|
|
285
|
-
/** What the run was for: `conversation`, `invite`, or `wake` (one run for the tray). Absent in a file an older daemon wrote. */
|
|
286
|
-
run_kind?: 'wake' | 'invite' | 'conversation' | null;
|
|
287
|
-
/** A `conversation` run's conversation; null otherwise (absent in a file an older daemon wrote). */
|
|
288
|
-
conversation_id?: string | null;
|
|
289
|
-
started_at: string;
|
|
290
|
-
ended_at: string;
|
|
291
|
-
state: 'ok' | 'failed' | 'timed_out' | 'not_started';
|
|
292
|
-
exit_code: number | null;
|
|
293
|
-
duration_ms: number;
|
|
294
|
-
detail: string | null;
|
|
330
|
+
readonly envKey?: boolean;
|
|
295
331
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
/**
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
332
|
+
/** `AGENTCHAT_API_KEY` from the environment when it is set and well-formed, else null. */
|
|
333
|
+
declare function envApiKey(env?: NodeJS.ProcessEnv): string | null;
|
|
334
|
+
declare function resolveIdentity(home: string, options?: ResolveIdentityOptions): ResolvedIdentity | null;
|
|
335
|
+
/**
|
|
336
|
+
* One sentence when an exported `AGENTCHAT_API_KEY` is not the key `home`
|
|
337
|
+
* holds, else null (none exported, the same key, or a home with no key, where
|
|
338
|
+
* the exported one stands in). Never contains either key. The caller adds
|
|
339
|
+
* what to do in its own words.
|
|
340
|
+
*/
|
|
341
|
+
declare function envKeyConflict(home: string, env?: NodeJS.ProcessEnv): string | null;
|
|
342
|
+
declare function writeCredentials(home: string, creds: Credentials): void;
|
|
343
|
+
declare const INSTALL_ID_FILE = "install-id";
|
|
344
|
+
declare function installIdPath(home: string): string;
|
|
345
|
+
/** The home's install id, or null when there is none (or the file holds something else). Never creates one. */
|
|
346
|
+
declare function readInstallId(home: string): string | null;
|
|
347
|
+
/** A new install id: `ins_` and 22 base64url characters from 16 random bytes. */
|
|
348
|
+
declare function newInstallId(): string;
|
|
349
|
+
/**
|
|
350
|
+
* The home's install id, made once: created with an exclusive open, so two
|
|
351
|
+
* commands starting at the same moment agree on one (the second reads the
|
|
352
|
+
* first's). A file that holds something else is replaced. Null when the home
|
|
353
|
+
* cannot be written; never throws.
|
|
354
|
+
*/
|
|
355
|
+
declare function ensureInstallId(home: string): string | null;
|
|
356
|
+
declare const HOST_FILE = "runtime-host";
|
|
357
|
+
/** The host a command last read here, or null. */
|
|
358
|
+
declare function readRememberedHost(home: string): string | null;
|
|
359
|
+
/** Keep the host a command read (when it changed). Never throws. */
|
|
360
|
+
declare function rememberHost(home: string, host: string): void;
|
|
361
|
+
/** Remove the home's install id (uninstall). True when there was one. */
|
|
362
|
+
declare function clearInstallId(home: string): boolean;
|
|
363
|
+
/** Delete the credential and any half-finished registration in `home`.
|
|
364
|
+
* Touches nothing outside `home` — that is the caller's whole agent.
|
|
365
|
+
* The install id stays: the same install may sign in again. */
|
|
366
|
+
declare function clearCredentials(home: string): boolean;
|
|
367
|
+
interface PendingSignup {
|
|
368
|
+
kind: 'register' | 'recover';
|
|
369
|
+
/** The server's flow object, as its last answer gave it. */
|
|
370
|
+
flow: SignupFlow;
|
|
371
|
+
/** When that answer arrived (ISO-8601): `expires_in_s` and `resend_after_s` count from here. */
|
|
372
|
+
received_at: string;
|
|
373
|
+
/** What the start call sent. */
|
|
374
|
+
email: string;
|
|
375
|
+
handle?: string;
|
|
376
|
+
display_name?: string;
|
|
377
|
+
description?: string;
|
|
378
|
+
/** The API base the start call went to, when not the default. */
|
|
379
|
+
api_base?: string;
|
|
380
|
+
}
|
|
381
|
+
/** @deprecated Renamed to {@link PendingSignup}; kept so existing imports keep compiling. */
|
|
382
|
+
type PendingRegistration = PendingSignup;
|
|
383
|
+
declare function readPending(home: string): PendingSignup | null;
|
|
384
|
+
declare function writePending(home: string, pending: PendingSignup): void;
|
|
385
|
+
declare function clearPending(home: string): void;
|
|
386
|
+
|
|
387
|
+
/** What the served texts announce: `Texts['manual']`, with the optional integrity hash. */
|
|
388
|
+
type ServedManual = integration.ServedManual;
|
|
389
|
+
declare const MANUAL_MAX_BYTES: number;
|
|
390
|
+
declare const MANUAL_FETCH_TIMEOUT_MS: 10000;
|
|
391
|
+
declare const MANUAL_MAX_REDIRECTS: 3;
|
|
392
|
+
/** `fetch`'s shape, injectable for tests. Defaults to the platform's own; called with `redirect: 'manual'`. */
|
|
393
|
+
type ManualFetch = integration.ManualFetch;
|
|
394
|
+
/**
|
|
395
|
+
* - `current` — the file already is the announced manual (version, and hash when announced); nothing fetched.
|
|
396
|
+
* - `updated` — the announced manual was written (downloaded, or the bundled copy when it is that manual).
|
|
397
|
+
* - `kept` — the existing file was left as it was: nothing announced to compare with, or no verified copy could be had.
|
|
398
|
+
* - `fallback` — no file existed and nothing verified could be had: the bundled copy was written.
|
|
399
|
+
* - `failed` — no file existed and none could be written.
|
|
400
|
+
*/
|
|
401
|
+
type ManualSyncState = integration.ManualSyncState;
|
|
402
|
+
interface ManualSyncResult extends Omit<integration.ManualSyncResult, 'source'> {
|
|
403
|
+
/** Where the written bytes came from, when some were written. */
|
|
404
|
+
readonly source: 'download' | 'bundled' | null;
|
|
405
|
+
}
|
|
406
|
+
interface SyncManualOptions {
|
|
407
|
+
/** The skill file, e.g. `<skills dir>/agentchat/SKILL.md`. The integration knows where; this package never derives it. */
|
|
408
|
+
readonly path: string;
|
|
409
|
+
/** `texts.manual` from the served texts (or their identity-home cache); null when none are in hand. */
|
|
410
|
+
readonly served: ServedManual | null;
|
|
365
411
|
/**
|
|
366
|
-
*
|
|
367
|
-
*
|
|
368
|
-
*
|
|
369
|
-
* before the first texts, or from an older daemon.
|
|
412
|
+
* The API base the texts were fetched from (the identity's `api_base`). It
|
|
413
|
+
* decides where a download may go; null (unknown) or a plain-HTTP base off
|
|
414
|
+
* loopback means no download at all.
|
|
370
415
|
*/
|
|
371
|
-
|
|
416
|
+
readonly apiBase: string | null;
|
|
417
|
+
readonly fetch?: ManualFetch;
|
|
418
|
+
readonly timeoutMs?: number;
|
|
419
|
+
readonly maxBytes?: number;
|
|
420
|
+
readonly signal?: AbortSignal;
|
|
372
421
|
}
|
|
373
|
-
/** The
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
422
|
+
/** The version the file at `file` carries, or null when it is missing or names none. */
|
|
423
|
+
declare function readManualVersion(file: string): string | null;
|
|
424
|
+
/** A kit result in this package's words (the fallback is the bundled copy). */
|
|
425
|
+
declare function fromKitResult(result: integration.ManualSyncResult): ManualSyncResult;
|
|
426
|
+
/**
|
|
427
|
+
* Bring the skill file at `path` to the announced manual (the kit's
|
|
428
|
+
* `syncManual`, the bundled copy as fallback). Never throws.
|
|
429
|
+
*/
|
|
430
|
+
declare function syncManual(options: SyncManualOptions): Promise<ManualSyncResult>;
|
|
431
|
+
declare function describeManualSync(result: ManualSyncResult): string;
|
|
432
|
+
type ManualCheckState = 'current' | 'stale' | 'unchecked' | 'missing';
|
|
433
|
+
interface ManualCheck {
|
|
434
|
+
readonly state: ManualCheckState;
|
|
378
435
|
readonly path: string;
|
|
379
|
-
|
|
380
|
-
readonly
|
|
381
|
-
/**
|
|
382
|
-
readonly
|
|
383
|
-
/**
|
|
436
|
+
readonly version: string | null;
|
|
437
|
+
readonly served: string | null;
|
|
438
|
+
/** current → PASS; stale or unchecked → WARN (the agent still has a manual); missing → FAIL. */
|
|
439
|
+
readonly verdict: Verdict;
|
|
440
|
+
/** `current (2.2.1)`, `stale (have 2.1.2, served 2.2.1)`, `unchecked (have 2.2.1; …)`, `missing`. */
|
|
441
|
+
readonly summary: string;
|
|
442
|
+
/** The summary and the file. */
|
|
384
443
|
readonly detail: string;
|
|
385
|
-
/** Why the runtime does not load the file now (a file it reads in its place), or null; absent from a file an older daemon wrote. */
|
|
386
|
-
readonly not_loaded?: string | null;
|
|
387
444
|
}
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
readonly at: string;
|
|
395
|
-
}
|
|
396
|
-
/**
|
|
397
|
-
* Could not process (the SDK kit's `status().processingFailures`, since the
|
|
398
|
-
* daemon started, and the paused conversations this machine was told about).
|
|
399
|
-
*/
|
|
400
|
-
interface IntegrationCouldNotProcess {
|
|
401
|
-
/**
|
|
402
|
-
* Whether the runtime has its own check (`RunRunner.checkRuntime`: a
|
|
403
|
-
* minimal model call). Without one, a failed conversation run is reported
|
|
404
|
-
* only after another run completes.
|
|
405
|
-
*/
|
|
406
|
-
readonly runtime_check: boolean;
|
|
407
|
-
/** Reports the server answered, and its answers. */
|
|
408
|
-
readonly reported: number;
|
|
409
|
-
readonly retry: number;
|
|
410
|
-
readonly hidden: number;
|
|
411
|
-
readonly paused: number;
|
|
412
|
-
readonly none: number;
|
|
413
|
-
/** Reports that failed (network, server); nothing more was done for them. */
|
|
414
|
-
readonly report_errors: number;
|
|
415
|
-
/** Runs started again on a `retry` or `hidden` answer. */
|
|
416
|
-
readonly reruns: number;
|
|
417
|
-
readonly reruns_capped: number;
|
|
418
|
-
/** Failures waiting for another run to complete (the evidence a report needs), now. */
|
|
419
|
-
readonly awaiting_evidence: number;
|
|
420
|
-
readonly runtime_checks_ok: number;
|
|
421
|
-
readonly runtime_checks_failed: number;
|
|
422
|
-
readonly last_runtime_check: {
|
|
423
|
-
readonly at: string;
|
|
424
|
-
readonly ok: boolean;
|
|
425
|
-
readonly detail: string | null;
|
|
426
|
-
} | null;
|
|
427
|
-
/** Conversations paused for this agent now, newest first. */
|
|
428
|
-
readonly paused_conversations: IntegrationPausedConversation[];
|
|
429
|
-
}
|
|
430
|
-
interface IntegrationUnservable {
|
|
431
|
-
/** `key_refused`: the server refuses this home's key. `runs_failing`: the runtime's own check fails. */
|
|
432
|
-
readonly reason: 'key_refused' | 'runs_failing';
|
|
433
|
-
/** What was said: the refusal, or the runtime check's words. */
|
|
434
|
-
readonly detail: string;
|
|
435
|
-
/** When this home gave the agent up. */
|
|
436
|
-
readonly since: string;
|
|
437
|
-
/** When it checks again (the runtime first, for `runs_failing`). */
|
|
438
|
-
readonly retry_at: string;
|
|
439
|
-
}
|
|
440
|
-
interface IntegrationStandby {
|
|
441
|
-
/** The identity home of the daemon that serves the agent, as its lock says. */
|
|
442
|
-
readonly home: string | null;
|
|
443
|
-
readonly pid: number | null;
|
|
444
|
-
readonly since: string | null;
|
|
445
|
-
}
|
|
446
|
-
interface IntegrationRunsFailing {
|
|
447
|
-
/** The runtime's own check (preflight), in its words. */
|
|
448
|
-
readonly reason: string;
|
|
449
|
-
/** When the first of the failing runs ended. */
|
|
450
|
-
readonly since: string;
|
|
451
|
-
/** Runs that did not get done since then (each one a wake cycle that started a run). */
|
|
452
|
-
readonly runs_missed: number;
|
|
453
|
-
/** When the runtime was last checked. */
|
|
454
|
-
readonly checked_at: string;
|
|
455
|
-
}
|
|
456
|
-
/** One wake cycle as the status file keeps it: what it found and how it ended. Counts and outcomes only. */
|
|
457
|
-
interface IntegrationCycle {
|
|
458
|
-
at: string;
|
|
459
|
-
/** The kit's cycle outcome: `empty`, `nothing_owed`, `run_completed`, `run_failed`, `abandoned`, … */
|
|
460
|
-
outcome: string;
|
|
461
|
-
cards: number;
|
|
462
|
-
invites: number;
|
|
463
|
-
/** Why it did not finish, bounded; null when it did. */
|
|
464
|
-
failure: string | null;
|
|
465
|
-
}
|
|
466
|
-
/** Cycle outcomes that mean a wake was owed something and it did not get done. */
|
|
467
|
-
declare const FAILED_CYCLE_OUTCOMES: ReadonlySet<string>;
|
|
468
|
-
/** How many of the newest cycles in a row did not get done, with the newest failure; null when the newest cycle did. */
|
|
469
|
-
declare function failedCyclesInARow(status: Pick<IntegrationStatus, 'recent_cycles'> | null): {
|
|
470
|
-
count: number;
|
|
471
|
-
latest: IntegrationCycle;
|
|
472
|
-
} | null;
|
|
473
|
-
/** This many failed cycles in a row is a warning in `status` and `doctor`: one is a hiccup, three is a pattern. */
|
|
474
|
-
declare const REPEATED_FAILED_CYCLES = 3;
|
|
475
|
-
declare function integrationStatusPath(home: string): string;
|
|
476
|
-
/** Best effort: the status file is diagnostics, never a dependency of waking. */
|
|
477
|
-
declare function writeIntegrationStatus(home: string, status: IntegrationStatus): void;
|
|
478
|
-
/** The current file, or — when a daemon from before the rename is the one running — the file it writes. */
|
|
479
|
-
declare function readIntegrationStatus(home: string): IntegrationStatus | null;
|
|
480
|
-
/**
|
|
481
|
-
* Remove what the daemon keeps for `status` in the identity home: both
|
|
482
|
-
* spellings of the status file (a stale legacy file must not outlive the
|
|
483
|
-
* daemon that wrote it) and the could-not-process ledger
|
|
484
|
-
* (`could-not-process.json`). For uninstall: nothing of it is left behind.
|
|
485
|
-
*/
|
|
486
|
-
declare function clearIntegrationStatus(home: string): void;
|
|
487
|
-
/** Age of the status file, in ms, or null when absent. */
|
|
488
|
-
declare function integrationStatusAge(status: IntegrationStatus | null, now?: number): number | null;
|
|
489
|
-
/**
|
|
490
|
-
* Past this age the status file is not the daemon's current word: a running
|
|
491
|
-
* integration rewrites it every 30 s, connected or not (the heartbeat file
|
|
492
|
-
* beats only while connected), so the daemon may be down.
|
|
493
|
-
*/
|
|
494
|
-
declare const INTEGRATION_STATUS_STALE_MS: number;
|
|
495
|
-
/** Whether the status file was written within `INTEGRATION_STATUS_STALE_MS`: the daemon that wrote it is taken to be running. */
|
|
496
|
-
declare function integrationStatusFresh(status: IntegrationStatus | null, now?: number): boolean;
|
|
497
|
-
/**
|
|
498
|
-
* How long the status file has gone unwritten, in words (`2 hour(s)`, `12
|
|
499
|
-
* minutes`), for a line that says the daemon may be down; `an unknown time`
|
|
500
|
-
* when its time cannot be read.
|
|
501
|
-
*/
|
|
502
|
-
declare function integrationStatusStaleFor(status: IntegrationStatus | null, now?: number): string;
|
|
503
|
-
/**
|
|
504
|
-
* The conversations paused for this agent, in one plain line (no indent), or
|
|
505
|
-
* null when none is paused now: which ones, until when, and why.
|
|
506
|
-
*/
|
|
507
|
-
declare function describePausedConversations(paused: readonly IntegrationPausedConversation[], now?: number): string | null;
|
|
508
|
-
/**
|
|
509
|
-
* The could-not-process counts in one plain line (no indent), or null when
|
|
510
|
-
* nothing has happened: what was reported and answered, what waits, and the
|
|
511
|
-
* runtime check.
|
|
512
|
-
*/
|
|
513
|
-
declare function describeCouldNotProcessCounts(c: IntegrationCouldNotProcess, now?: number): string | null;
|
|
514
|
-
/**
|
|
515
|
-
* Whether the last runtime check failed and nothing has got done since: a run
|
|
516
|
-
* that completed after the check says the runtime works again, and the failed
|
|
517
|
-
* check is history (the counts say it). It does not look at the file's age:
|
|
518
|
-
* a caller that warns about it does so only while the status file is fresh
|
|
519
|
-
* (`integrationStatusFresh`), since a check from before the daemon went
|
|
520
|
-
* quiet says nothing about now.
|
|
521
|
-
*/
|
|
522
|
-
declare function runtimeCheckFailingNow(status: Pick<IntegrationStatus, 'could_not_process' | 'last_ok_run_at'> | null): boolean;
|
|
523
|
-
/** Runs in a row that did not get done, when that is a pattern (`REPEATED_FAILED_CYCLES` or more) and no runtime reason explains it; null otherwise. */
|
|
524
|
-
declare function repeatedFailedRuns(status: Pick<IntegrationStatus, 'failed_runs_in_a_row' | 'runs_failing' | 'unservable'> | null): number | null;
|
|
525
|
-
declare function formatIntegrationStatus(status: IntegrationStatus | null, now?: number): string[];
|
|
526
|
-
|
|
527
|
-
declare const DEFAULT_API_BASE = "https://api.agentchat.me";
|
|
528
|
-
declare const CredentialsSchema: z.ZodObject<{
|
|
529
|
-
api_key: z.ZodString;
|
|
530
|
-
handle: z.ZodString;
|
|
531
|
-
api_base: z.ZodOptional<z.ZodString>;
|
|
532
|
-
created_at: z.ZodOptional<z.ZodString>;
|
|
533
|
-
}, "strip", z.ZodTypeAny, {
|
|
534
|
-
api_key: string;
|
|
535
|
-
handle: string;
|
|
536
|
-
api_base?: string | undefined;
|
|
537
|
-
created_at?: string | undefined;
|
|
538
|
-
}, {
|
|
539
|
-
api_key: string;
|
|
540
|
-
handle: string;
|
|
541
|
-
api_base?: string | undefined;
|
|
542
|
-
created_at?: string | undefined;
|
|
543
|
-
}>;
|
|
544
|
-
type Credentials = z.infer<typeof CredentialsSchema>;
|
|
545
|
-
interface ResolvedIdentity {
|
|
546
|
-
apiKey: string;
|
|
547
|
-
apiBase: string;
|
|
548
|
-
/** Handle is only known when it came from the credentials file. */
|
|
549
|
-
handle: string | null;
|
|
550
|
-
source: 'env' | 'file';
|
|
551
|
-
}
|
|
552
|
-
declare function credentialsPath(home: string): string;
|
|
553
|
-
declare function pendingPath(home: string): string;
|
|
554
|
-
declare function statePath(home: string): string;
|
|
555
|
-
/** Read the credential stored in `home`, or null when absent/malformed. */
|
|
556
|
-
declare function readCredentials(home: string): Credentials | null;
|
|
557
|
-
/**
|
|
558
|
-
* The identity an integration should act as, for one specific home: the
|
|
559
|
-
* home's `credentials`, else `AGENTCHAT_API_KEY` when the home holds no key.
|
|
560
|
-
* `AGENTCHAT_API_BASE` overrides the base URL. Neither is host-specific, so
|
|
561
|
-
* both are read from the environment.
|
|
562
|
-
*/
|
|
563
|
-
interface ResolveIdentityOptions {
|
|
564
|
-
/**
|
|
565
|
-
* Whether `AGENTCHAT_API_KEY` may stand in for a home that holds no key
|
|
566
|
-
* (default true). It never overrides a key the home holds. A resident
|
|
567
|
-
* listener passes false: the agent it serves is the one its home holds,
|
|
568
|
-
* whatever happens to be exported in the shell that started it.
|
|
569
|
-
*/
|
|
570
|
-
readonly envKey?: boolean;
|
|
571
|
-
}
|
|
572
|
-
/** `AGENTCHAT_API_KEY` from the environment when it is set and well-formed, else null. */
|
|
573
|
-
declare function envApiKey(env?: NodeJS.ProcessEnv): string | null;
|
|
574
|
-
declare function resolveIdentity(home: string, options?: ResolveIdentityOptions): ResolvedIdentity | null;
|
|
575
|
-
/**
|
|
576
|
-
* One sentence when an exported `AGENTCHAT_API_KEY` is not the key `home`
|
|
577
|
-
* holds, else null (none exported, the same key, or a home with no key, where
|
|
578
|
-
* the exported one stands in). Never contains either key. The caller adds
|
|
579
|
-
* what to do in its own words.
|
|
580
|
-
*/
|
|
581
|
-
declare function envKeyConflict(home: string, env?: NodeJS.ProcessEnv): string | null;
|
|
582
|
-
declare function writeCredentials(home: string, creds: Credentials): void;
|
|
583
|
-
/** Delete the credential and any half-finished registration in `home`.
|
|
584
|
-
* Touches nothing outside `home` — that is the caller's whole agent. */
|
|
585
|
-
declare function clearCredentials(home: string): boolean;
|
|
586
|
-
interface PendingSignup {
|
|
587
|
-
kind: 'register' | 'recover';
|
|
588
|
-
/** The server's flow object, as its last answer gave it. */
|
|
589
|
-
flow: SignupFlow;
|
|
590
|
-
/** When that answer arrived (ISO-8601): `expires_in_s` and `resend_after_s` count from here. */
|
|
591
|
-
received_at: string;
|
|
592
|
-
/** What the start call sent. */
|
|
593
|
-
email: string;
|
|
594
|
-
handle?: string;
|
|
595
|
-
display_name?: string;
|
|
596
|
-
description?: string;
|
|
597
|
-
/** The API base the start call went to, when not the default. */
|
|
598
|
-
api_base?: string;
|
|
445
|
+
interface CheckManualOptions {
|
|
446
|
+
readonly path: string;
|
|
447
|
+
/** What the served texts announce; null when none are in hand. */
|
|
448
|
+
readonly served: ServedManual | null;
|
|
449
|
+
/** The API base the texts came from; a base no download would be made from is named in the summary. */
|
|
450
|
+
readonly apiBase: string | null;
|
|
599
451
|
}
|
|
600
|
-
/**
|
|
601
|
-
|
|
602
|
-
declare function readPending(home: string): PendingSignup | null;
|
|
603
|
-
declare function writePending(home: string, pending: PendingSignup): void;
|
|
604
|
-
declare function clearPending(home: string): void;
|
|
452
|
+
/** Compare the skill file with the announced manual. Reads one file; no network. */
|
|
453
|
+
declare function checkManual(options: CheckManualOptions): ManualCheck;
|
|
605
454
|
|
|
606
455
|
type Verdict = 'PASS' | 'WARN' | 'FAIL';
|
|
607
456
|
interface DoctorCheck {
|
|
@@ -631,6 +480,46 @@ interface DoctorContext {
|
|
|
631
480
|
/** The manual the served texts announce, or null when none are in hand (`--fix` syncs the skill file to it). */
|
|
632
481
|
manual: ServedManual | null;
|
|
633
482
|
}
|
|
483
|
+
/**
|
|
484
|
+
* A placement problem that keeps the agent's runs from having the AgentChat
|
|
485
|
+
* tools: the hosted tool server could not be registered, or a registration
|
|
486
|
+
* this integration did not write stands in its place. The setup verdict says
|
|
487
|
+
* it as `tools_missing`, in the host's words.
|
|
488
|
+
*/
|
|
489
|
+
interface PlacementProblem {
|
|
490
|
+
/** What is wrong and what to do, in plain words that name the exact command, or what to ask the person. */
|
|
491
|
+
readonly text: string;
|
|
492
|
+
/** The command to run next; absent: `doctor --fix` (or none, when only the person can resolve it). */
|
|
493
|
+
readonly command?: string;
|
|
494
|
+
/** Only the person can resolve it (their own registration stands in the way: ask before touching it). */
|
|
495
|
+
readonly needsPerson?: boolean;
|
|
496
|
+
/** What to ask the person, when `needsPerson`. */
|
|
497
|
+
readonly ask?: string;
|
|
498
|
+
/** The facts, as found. */
|
|
499
|
+
readonly detail?: string;
|
|
500
|
+
}
|
|
501
|
+
/** What `place` (and `extraStatus`) may return instead of bare lines: the lines, and the problem that blocks the tools, or null. */
|
|
502
|
+
interface PlacementReport {
|
|
503
|
+
readonly lines: string[];
|
|
504
|
+
readonly problem: PlacementProblem | null;
|
|
505
|
+
}
|
|
506
|
+
/** Lines, or lines with a placement problem: a host that returns bare lines reports no problem. */
|
|
507
|
+
type PlacementOutput = string[] | PlacementReport;
|
|
508
|
+
/** A host's lines and problem, whichever shape it returned. */
|
|
509
|
+
declare function placementReportOf(output: PlacementOutput): PlacementReport;
|
|
510
|
+
/**
|
|
511
|
+
* What `ensureListener` did.
|
|
512
|
+
*
|
|
513
|
+
* installed registered now (it was missing, stale, or another release's);
|
|
514
|
+
* current already registered and current: nothing was done;
|
|
515
|
+
* opted_out the person switched it off (`daemon disable`, `uninstall`): nothing was done;
|
|
516
|
+
* failed it could not be registered (`detail` says why).
|
|
517
|
+
*/
|
|
518
|
+
interface ListenerEnsure {
|
|
519
|
+
readonly outcome: 'installed' | 'current' | 'opted_out' | 'failed';
|
|
520
|
+
/** The service's name for `installed` / `current` (e.g. `agentchatd-claude-code`); why, for `failed`; null otherwise. */
|
|
521
|
+
readonly detail: string | null;
|
|
522
|
+
}
|
|
634
523
|
/**
|
|
635
524
|
* Everything the shared identity commands need to know about ONE coding agent.
|
|
636
525
|
*
|
|
@@ -701,9 +590,31 @@ interface HostProfile {
|
|
|
701
590
|
* or the cached one), or null when neither could be had — the host then
|
|
702
591
|
* leaves the anchor for `doctor --fix` and says so. `manual` is what the
|
|
703
592
|
* same texts announce (`syncManual` brings the skill file to it), or null.
|
|
704
|
-
* Returns report lines
|
|
593
|
+
* Returns report lines, or the lines with the placement problem that keeps
|
|
594
|
+
* runs from having the AgentChat tools (`PlacementReport`): with a problem,
|
|
595
|
+
* the listener is not registered and the setup verdict is `tools_missing`.
|
|
596
|
+
* When absent, only the anchor is written.
|
|
597
|
+
*/
|
|
598
|
+
place?(handle: string, apiKey: string, identityLine: string | null, manual: ServedManual | null): PlacementOutput | Promise<PlacementOutput>;
|
|
599
|
+
/**
|
|
600
|
+
* Have this host's listener service — the resident daemon that holds the
|
|
601
|
+
* socket and starts a run when a peer writes — registered and current,
|
|
602
|
+
* unless the person switched it off. Never throws. Called by the shared
|
|
603
|
+
* flow after `place`: register and recover on their code leg, login, and
|
|
604
|
+
* doctor --fix. A host that has it turns its listener on with
|
|
605
|
+
* `<invocation> daemon install`; the shared commands then wait for the
|
|
606
|
+
* listener to connect and say the setup verdict (`Setup: <state> — …`).
|
|
607
|
+
* Absent (a front door with no service of its own to place, such as the
|
|
608
|
+
* `agentchat` CLI): no listener is placed, waited for or judged.
|
|
609
|
+
*/
|
|
610
|
+
ensureListener?(): ListenerEnsure | Promise<ListenerEnsure>;
|
|
611
|
+
/**
|
|
612
|
+
* The runtime this integration runs inside and its version,
|
|
613
|
+
* `<runtime>/<version>` (`hostIdentityOf(runtime, <its --version output>)`),
|
|
614
|
+
* or null when it cannot be read. Asked once per command (bounded); it is
|
|
615
|
+
* the `host` member of X-AgentChat-Platform and nothing else.
|
|
705
616
|
*/
|
|
706
|
-
|
|
617
|
+
host?(): string | null | Promise<string | null>;
|
|
707
618
|
/**
|
|
708
619
|
* Undo `place` for the identity being signed out: remove the key from the
|
|
709
620
|
* tool server registration and anything else that would still authenticate
|
|
@@ -722,81 +633,395 @@ interface HostProfile {
|
|
|
722
633
|
/**
|
|
723
634
|
* Host-specific `status` lines (placement, probes), printed after the shared
|
|
724
635
|
* ones in text mode. The served identity line and manual come along so the
|
|
725
|
-
* host does not fetch `/v1/texts` a second time.
|
|
636
|
+
* host does not fetch `/v1/texts` a second time. May return the lines with
|
|
637
|
+
* the placement problem its checks found (`PlacementReport`), which the
|
|
638
|
+
* setup verdict says as `tools_missing`.
|
|
726
639
|
*/
|
|
727
|
-
extraStatus?(context: StatusContext):
|
|
640
|
+
extraStatus?(context: StatusContext): PlacementOutput | Promise<PlacementOutput>;
|
|
728
641
|
/** Extra lines printed after a successful logout. */
|
|
729
642
|
logoutHints?(): string[];
|
|
730
643
|
}
|
|
731
644
|
/** The label to use for this host's anchor in user-facing output. */
|
|
732
645
|
declare function anchorLabelOf(profile: HostProfile): string;
|
|
733
646
|
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
declare const
|
|
737
|
-
declare const MANUAL_FETCH_TIMEOUT_MS: 10000;
|
|
738
|
-
declare const MANUAL_MAX_REDIRECTS: 3;
|
|
739
|
-
/** `fetch`'s shape, injectable for tests. Defaults to the platform's own; called with `redirect: 'manual'`. */
|
|
740
|
-
type ManualFetch = integration.ManualFetch;
|
|
647
|
+
declare const INTEGRATION_STATUS_FILE = "integration.status.json";
|
|
648
|
+
/** The file a daemon before the rename writes; read when the current one is absent. */
|
|
649
|
+
declare const LEGACY_STATUS_FILE = "doorbell.status.json";
|
|
741
650
|
/**
|
|
742
|
-
*
|
|
743
|
-
*
|
|
744
|
-
*
|
|
745
|
-
*
|
|
746
|
-
* - `failed` — no file existed and none could be written.
|
|
651
|
+
* The socket word. `blocked` is the SDK's own word for it (`RealtimeState`):
|
|
652
|
+
* the server refused the credential on the hello and a fresh hello is tried
|
|
653
|
+
* every 10–15 min until one is accepted — not an end state. Daemons before
|
|
654
|
+
* this release wrote `terminal` for it; readers map that on the way in.
|
|
747
655
|
*/
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
656
|
+
declare const SOCKET_STATES: readonly ["off", "idle", "connecting", "ready", "reconnecting", "blocked", "closed"];
|
|
657
|
+
type SocketState = (typeof SOCKET_STATES)[number];
|
|
658
|
+
type TextsSource = 'server' | 'cache' | 'none';
|
|
659
|
+
interface TextsStatus {
|
|
660
|
+
/** Where the texts a run starts with came from. */
|
|
661
|
+
source: TextsSource;
|
|
662
|
+
fetched_at: string | null;
|
|
663
|
+
/** The served text set's version. */
|
|
664
|
+
version: string | null;
|
|
665
|
+
manual_version: string | null;
|
|
752
666
|
}
|
|
753
|
-
interface
|
|
754
|
-
/** The skill file, e.g. `<skills dir>/agentchat/SKILL.md`. The integration knows where; this package never derives it. */
|
|
755
|
-
readonly path: string;
|
|
756
|
-
/** `texts.manual` from the served texts (or their identity-home cache); null when none are in hand. */
|
|
757
|
-
readonly served: ServedManual | null;
|
|
667
|
+
interface IntegrationLastRun {
|
|
758
668
|
/**
|
|
759
|
-
*
|
|
760
|
-
*
|
|
761
|
-
*
|
|
669
|
+
* `invite`: a run for the pending invites; `wake` otherwise — a conversation
|
|
670
|
+
* run included, so a reader from before conversation runs still reads the
|
|
671
|
+
* file. `run_kind` says which.
|
|
762
672
|
*/
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
673
|
+
kind: 'wake' | 'invite';
|
|
674
|
+
/** What the run was for: `conversation`, `invite`, or `wake` (one run for the tray). Absent in a file an older daemon wrote. */
|
|
675
|
+
run_kind?: 'wake' | 'invite' | 'conversation' | null;
|
|
676
|
+
/** A `conversation` run's conversation; null otherwise (absent in a file an older daemon wrote). */
|
|
677
|
+
conversation_id?: string | null;
|
|
678
|
+
started_at: string;
|
|
679
|
+
ended_at: string;
|
|
680
|
+
state: 'ok' | 'failed' | 'timed_out' | 'not_started';
|
|
681
|
+
exit_code: number | null;
|
|
682
|
+
duration_ms: number;
|
|
683
|
+
detail: string | null;
|
|
684
|
+
}
|
|
685
|
+
interface IntegrationStatus {
|
|
686
|
+
version: 2;
|
|
687
|
+
updated_at: string;
|
|
688
|
+
pid: number;
|
|
689
|
+
runtime: string | null;
|
|
690
|
+
/** The runtime's name for people (`RunRunner.label`), as `status` says it; absent in a file an older daemon wrote. */
|
|
691
|
+
runtime_label?: string | null;
|
|
692
|
+
handle: string | null;
|
|
693
|
+
profile: string;
|
|
694
|
+
/** The run workdir the daemon was given (absent in a file an older daemon wrote). */
|
|
695
|
+
workdir?: string;
|
|
696
|
+
socket: SocketState;
|
|
697
|
+
wakes: number;
|
|
698
|
+
wakes_absorbed: number;
|
|
699
|
+
invites: number;
|
|
700
|
+
runs_started: number;
|
|
701
|
+
runs_ok: number;
|
|
702
|
+
runs_failed: number;
|
|
703
|
+
runs_timed_out: number;
|
|
704
|
+
runs_not_started: number;
|
|
705
|
+
/** Wakes whose tray count came back empty, so no run started. */
|
|
706
|
+
runs_skipped_empty: number;
|
|
707
|
+
last_run: IntegrationLastRun | null;
|
|
708
|
+
retry_rung: number;
|
|
709
|
+
retry_due_at: string | null;
|
|
710
|
+
last_error: string | null;
|
|
711
|
+
texts: TextsStatus | null;
|
|
712
|
+
/** The socket capabilities the server accepted (`ack`, `heartbeat`, `rewake`); null before a hello, or from an older daemon. */
|
|
713
|
+
capabilities?: string[] | null;
|
|
714
|
+
/** The receive loop's most recent wake cycles, oldest first (the kit's `status().recentCycles`, reduced); null from an older daemon. */
|
|
715
|
+
recent_cycles?: IntegrationCycle[] | null;
|
|
716
|
+
/** The socket's backpressure: true while it refuses new messages because handlers are behind (the kit's `intakePaused`); null from an older daemon. */
|
|
717
|
+
intake_paused?: boolean | null;
|
|
718
|
+
/**
|
|
719
|
+
* Another daemon serves this agent (one agent, one listener): its identity
|
|
720
|
+
* home and pid. This one holds no socket and starts no run until it stops.
|
|
721
|
+
* Null or absent when this one serves it (or an older daemon wrote the file).
|
|
722
|
+
*/
|
|
723
|
+
standby?: IntegrationStandby | null;
|
|
724
|
+
/**
|
|
725
|
+
* Runs keep failing and the runtime's own check says why (signed out, binary
|
|
726
|
+
* gone, a flag the installed version rejects): the check's words, since when,
|
|
727
|
+
* how many runs did not get done, when it was last checked. Cleared when a
|
|
728
|
+
* run succeeds. Null or absent when runs are fine (or an older daemon wrote the file).
|
|
729
|
+
*/
|
|
730
|
+
runs_failing?: IntegrationRunsFailing | null;
|
|
731
|
+
/**
|
|
732
|
+
* This home gave its agent up because it cannot serve it — the server
|
|
733
|
+
* refuses its key, or its runs fail for a runtime reason while a healthy
|
|
734
|
+
* listener for the agent waits — and holds no socket until a recheck passes.
|
|
735
|
+
* Null or absent when it serves (or stands by for another).
|
|
736
|
+
*/
|
|
737
|
+
unservable?: IntegrationUnservable | null;
|
|
738
|
+
/** Lock renewals that failed (the lock folder gone, a full disk, permissions), and the last message; null or absent when none did. */
|
|
739
|
+
lease_errors?: {
|
|
740
|
+
readonly count: number;
|
|
741
|
+
readonly last: string | null;
|
|
742
|
+
} | null;
|
|
743
|
+
/**
|
|
744
|
+
* Runs in a row that did not get done (failed, timed out, did not start)
|
|
745
|
+
* since the last one that did; 0 after a good run. With conversation runs a
|
|
746
|
+
* cycle only starts runs, so this, not the cycles, says when every run
|
|
747
|
+
* fails. Null or absent from an older daemon.
|
|
748
|
+
*/
|
|
749
|
+
failed_runs_in_a_row?: number | null;
|
|
750
|
+
/** When the last run that got done ended; null before one, or absent from an older daemon. */
|
|
751
|
+
last_ok_run_at?: string | null;
|
|
752
|
+
/** Could not process: the kit's reports and the server's answers, and the conversations paused for this agent. Null or absent from an older daemon. */
|
|
753
|
+
could_not_process?: IntegrationCouldNotProcess | null;
|
|
754
|
+
/**
|
|
755
|
+
* What the daemon last did with the identity block in the host's
|
|
756
|
+
* instruction file when the served texts changed (`followIdentityAnchor`).
|
|
757
|
+
* Null or absent when the daemon is not given one (the CLI places none),
|
|
758
|
+
* before the first texts, or from an older daemon.
|
|
759
|
+
*/
|
|
760
|
+
identity_line?: IntegrationIdentityLine | null;
|
|
761
|
+
/**
|
|
762
|
+
* The listener report (contract v1 §3.13): what this listener tells
|
|
763
|
+
* AgentChat about itself, and whether AgentChat holds it. Null or absent
|
|
764
|
+
* while it reports nothing (a standby, a home that gave the agent up,
|
|
765
|
+
* switched off, signed out) or from an older daemon.
|
|
766
|
+
*/
|
|
767
|
+
listener_report?: IntegrationListenerReport | null;
|
|
768
|
+
}
|
|
769
|
+
/** The listener report as the status file keeps it (the kit reporter's `status()`). */
|
|
770
|
+
interface IntegrationListenerReport {
|
|
771
|
+
/** This install's id (`<home>/listener-id`). */
|
|
772
|
+
readonly instance_id: string;
|
|
773
|
+
/** What the listener says now: `ok`, `runs_failing`, `not_ready`; null before it has said anything. */
|
|
774
|
+
readonly state: string | null;
|
|
775
|
+
/** Its reason, for `runs_failing` and `not_ready`; null otherwise. */
|
|
776
|
+
readonly reason_kind: string | null;
|
|
777
|
+
/** The last report AgentChat accepted, and when (this machine's clock); null before one. */
|
|
778
|
+
readonly reported: {
|
|
779
|
+
readonly state: string;
|
|
780
|
+
readonly reason_kind: string | null;
|
|
781
|
+
readonly at: string;
|
|
782
|
+
} | null;
|
|
783
|
+
/** True while AgentChat does not hold `state` yet. */
|
|
784
|
+
readonly pending: boolean;
|
|
785
|
+
/** Attempts that failed since the last accepted report, and the last failure. */
|
|
786
|
+
readonly failures: number;
|
|
787
|
+
readonly last_error: string | null;
|
|
788
|
+
/** When the next attempt is due, or null when none is. */
|
|
789
|
+
readonly next_attempt_at: string | null;
|
|
790
|
+
}
|
|
791
|
+
/** The identity block's last follow of the served identity line. */
|
|
792
|
+
interface IntegrationIdentityLine {
|
|
793
|
+
/** `updated`, `unchanged`, `absent`, `setup_offer`, `hand_edited`, `other_agent`, `several_blocks`, `edited_meanwhile` or `failed` (`IdentityAnchorOutcome`). */
|
|
794
|
+
readonly outcome: string;
|
|
795
|
+
/** The instruction file. */
|
|
796
|
+
readonly path: string;
|
|
797
|
+
/** When it was done. */
|
|
798
|
+
readonly at: string;
|
|
799
|
+
/** The served text set's version it followed. */
|
|
800
|
+
readonly texts_version: string;
|
|
801
|
+
/** What happened, in words. */
|
|
802
|
+
readonly detail: string;
|
|
803
|
+
/** Why the runtime does not load the file now (a file it reads in its place), or null; absent from a file an older daemon wrote. */
|
|
804
|
+
readonly not_loaded?: string | null;
|
|
805
|
+
}
|
|
806
|
+
/** A conversation paused for this agent (the server's 24 h mute, source `could_not_process`). */
|
|
807
|
+
interface IntegrationPausedConversation {
|
|
808
|
+
readonly conversation_id: string;
|
|
809
|
+
/** When the pause ends, as the server answered. */
|
|
810
|
+
readonly paused_until: string;
|
|
811
|
+
/** When the server answered `paused`. */
|
|
812
|
+
readonly at: string;
|
|
768
813
|
}
|
|
769
|
-
/** The version the file at `file` carries, or null when it is missing or names none. */
|
|
770
|
-
declare function readManualVersion(file: string): string | null;
|
|
771
|
-
/** A kit result in this package's words (the fallback is the bundled copy). */
|
|
772
|
-
declare function fromKitResult(result: integration.ManualSyncResult): ManualSyncResult;
|
|
773
814
|
/**
|
|
774
|
-
*
|
|
775
|
-
*
|
|
815
|
+
* Could not process (the SDK kit's `status().processingFailures`, since the
|
|
816
|
+
* daemon started, and the paused conversations this machine was told about).
|
|
776
817
|
*/
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
readonly
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
readonly
|
|
787
|
-
|
|
788
|
-
readonly
|
|
789
|
-
|
|
818
|
+
interface IntegrationCouldNotProcess {
|
|
819
|
+
/**
|
|
820
|
+
* Whether the runtime has its own check (`RunRunner.checkRuntime`: a
|
|
821
|
+
* minimal model call). Without one, a failed conversation run is reported
|
|
822
|
+
* only after another run completes.
|
|
823
|
+
*/
|
|
824
|
+
readonly runtime_check: boolean;
|
|
825
|
+
/** Reports the server answered, and its answers. */
|
|
826
|
+
readonly reported: number;
|
|
827
|
+
readonly retry: number;
|
|
828
|
+
readonly hidden: number;
|
|
829
|
+
readonly paused: number;
|
|
830
|
+
readonly none: number;
|
|
831
|
+
/** Reports that failed (network, server); nothing more was done for them. */
|
|
832
|
+
readonly report_errors: number;
|
|
833
|
+
/** Runs started again on a `retry` or `hidden` answer. */
|
|
834
|
+
readonly reruns: number;
|
|
835
|
+
readonly reruns_capped: number;
|
|
836
|
+
/** Failures waiting for another run to complete (the evidence a report needs), now. */
|
|
837
|
+
readonly awaiting_evidence: number;
|
|
838
|
+
readonly runtime_checks_ok: number;
|
|
839
|
+
readonly runtime_checks_failed: number;
|
|
840
|
+
readonly last_runtime_check: {
|
|
841
|
+
readonly at: string;
|
|
842
|
+
readonly ok: boolean;
|
|
843
|
+
readonly detail: string | null;
|
|
844
|
+
} | null;
|
|
845
|
+
/** Conversations paused for this agent now, newest first. */
|
|
846
|
+
readonly paused_conversations: IntegrationPausedConversation[];
|
|
847
|
+
}
|
|
848
|
+
interface IntegrationUnservable {
|
|
849
|
+
/** `key_refused`: the server refuses this home's key. `runs_failing`: the runtime's own check fails. */
|
|
850
|
+
readonly reason: 'key_refused' | 'runs_failing';
|
|
851
|
+
/** What was said: the refusal, or the runtime check's words. */
|
|
790
852
|
readonly detail: string;
|
|
853
|
+
/** When this home gave the agent up. */
|
|
854
|
+
readonly since: string;
|
|
855
|
+
/** When it checks again (the runtime first, for `runs_failing`). */
|
|
856
|
+
readonly retry_at: string;
|
|
791
857
|
}
|
|
792
|
-
interface
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
readonly
|
|
796
|
-
|
|
797
|
-
readonly apiBase: string | null;
|
|
858
|
+
interface IntegrationStandby {
|
|
859
|
+
/** The identity home of the daemon that serves the agent, as its lock says. */
|
|
860
|
+
readonly home: string | null;
|
|
861
|
+
readonly pid: number | null;
|
|
862
|
+
readonly since: string | null;
|
|
798
863
|
}
|
|
799
|
-
|
|
800
|
-
|
|
864
|
+
interface IntegrationRunsFailing {
|
|
865
|
+
/** The runtime's own check (preflight), in its words. */
|
|
866
|
+
readonly reason: string;
|
|
867
|
+
/** When the first of the failing runs ended. */
|
|
868
|
+
readonly since: string;
|
|
869
|
+
/** Runs that did not get done since then (each one a wake cycle that started a run). */
|
|
870
|
+
readonly runs_missed: number;
|
|
871
|
+
/** When the runtime was last checked. */
|
|
872
|
+
readonly checked_at: string;
|
|
873
|
+
}
|
|
874
|
+
/** One wake cycle as the status file keeps it: what it found and how it ended. Counts and outcomes only. */
|
|
875
|
+
interface IntegrationCycle {
|
|
876
|
+
at: string;
|
|
877
|
+
/** The kit's cycle outcome: `empty`, `nothing_owed`, `run_completed`, `run_failed`, `abandoned`, … */
|
|
878
|
+
outcome: string;
|
|
879
|
+
cards: number;
|
|
880
|
+
invites: number;
|
|
881
|
+
/** Why it did not finish, bounded; null when it did. */
|
|
882
|
+
failure: string | null;
|
|
883
|
+
}
|
|
884
|
+
/** Cycle outcomes that mean a wake was owed something and it did not get done. */
|
|
885
|
+
declare const FAILED_CYCLE_OUTCOMES: ReadonlySet<string>;
|
|
886
|
+
/** How many of the newest cycles in a row did not get done, with the newest failure; null when the newest cycle did. */
|
|
887
|
+
declare function failedCyclesInARow(status: Pick<IntegrationStatus, 'recent_cycles'> | null): {
|
|
888
|
+
count: number;
|
|
889
|
+
latest: IntegrationCycle;
|
|
890
|
+
} | null;
|
|
891
|
+
/** This many failed cycles in a row is a warning in `status` and `doctor`: one is a hiccup, three is a pattern. */
|
|
892
|
+
declare const REPEATED_FAILED_CYCLES = 3;
|
|
893
|
+
declare function integrationStatusPath(home: string): string;
|
|
894
|
+
/** Best effort: the status file is diagnostics, never a dependency of waking. */
|
|
895
|
+
declare function writeIntegrationStatus(home: string, status: IntegrationStatus): void;
|
|
896
|
+
/** The current file, or — when a daemon from before the rename is the one running — the file it writes. */
|
|
897
|
+
declare function readIntegrationStatus(home: string): IntegrationStatus | null;
|
|
898
|
+
/**
|
|
899
|
+
* Remove what the daemon keeps for `status` in the identity home: both
|
|
900
|
+
* spellings of the status file (a stale legacy file must not outlive the
|
|
901
|
+
* daemon that wrote it) and the could-not-process ledger
|
|
902
|
+
* (`could-not-process.json`). For uninstall: nothing of it is left behind.
|
|
903
|
+
*/
|
|
904
|
+
declare function clearIntegrationStatus(home: string): void;
|
|
905
|
+
/** Age of the status file, in ms, or null when absent. */
|
|
906
|
+
declare function integrationStatusAge(status: IntegrationStatus | null, now?: number): number | null;
|
|
907
|
+
/**
|
|
908
|
+
* Past this age the status file is not the daemon's current word: a running
|
|
909
|
+
* integration rewrites it every 30 s, connected or not (the heartbeat file
|
|
910
|
+
* beats only while connected), so the daemon may be down.
|
|
911
|
+
*/
|
|
912
|
+
declare const INTEGRATION_STATUS_STALE_MS: number;
|
|
913
|
+
/** Whether the status file was written within `INTEGRATION_STATUS_STALE_MS`: the daemon that wrote it is taken to be running. */
|
|
914
|
+
declare function integrationStatusFresh(status: IntegrationStatus | null, now?: number): boolean;
|
|
915
|
+
/**
|
|
916
|
+
* How long the status file has gone unwritten, in words (`2 hour(s)`, `12
|
|
917
|
+
* minutes`), for a line that says the daemon may be down; `an unknown time`
|
|
918
|
+
* when its time cannot be read.
|
|
919
|
+
*/
|
|
920
|
+
declare function integrationStatusStaleFor(status: IntegrationStatus | null, now?: number): string;
|
|
921
|
+
/**
|
|
922
|
+
* The conversations paused for this agent, in one plain line (no indent), or
|
|
923
|
+
* null when none is paused now: which ones, until when, and why.
|
|
924
|
+
*/
|
|
925
|
+
declare function describePausedConversations(paused: readonly IntegrationPausedConversation[], now?: number): string | null;
|
|
926
|
+
/**
|
|
927
|
+
* The could-not-process counts in one plain line (no indent), or null when
|
|
928
|
+
* nothing has happened: what was reported and answered, what waits, and the
|
|
929
|
+
* runtime check.
|
|
930
|
+
*/
|
|
931
|
+
declare function describeCouldNotProcessCounts(c: IntegrationCouldNotProcess, now?: number): string | null;
|
|
932
|
+
/**
|
|
933
|
+
* Whether the last runtime check failed and nothing has got done since: a run
|
|
934
|
+
* that completed after the check says the runtime works again, and the failed
|
|
935
|
+
* check is history (the counts say it). It does not look at the file's age:
|
|
936
|
+
* a caller that warns about it does so only while the status file is fresh
|
|
937
|
+
* (`integrationStatusFresh`), since a check from before the daemon went
|
|
938
|
+
* quiet says nothing about now.
|
|
939
|
+
*/
|
|
940
|
+
declare function runtimeCheckFailingNow(status: Pick<IntegrationStatus, 'could_not_process' | 'last_ok_run_at'> | null): boolean;
|
|
941
|
+
/** Runs in a row that did not get done, when that is a pattern (`REPEATED_FAILED_CYCLES` or more) and no runtime reason explains it; null otherwise. */
|
|
942
|
+
declare function repeatedFailedRuns(status: Pick<IntegrationStatus, 'failed_runs_in_a_row' | 'runs_failing' | 'unservable'> | null): number | null;
|
|
943
|
+
declare function formatIntegrationStatus(status: IntegrationStatus | null, now?: number): string[];
|
|
944
|
+
|
|
945
|
+
/** The file in the identity home that keeps this install's listener id. */
|
|
946
|
+
declare const LISTENER_ID_FILE = "listener-id";
|
|
947
|
+
/** `<home>/listener-id`. */
|
|
948
|
+
declare function listenerIdPath(home: string): string;
|
|
949
|
+
/**
|
|
950
|
+
* The home's listener id, made once and reused (the kit's
|
|
951
|
+
* `listenerInstanceId`), or null when the home can keep none (said at warn):
|
|
952
|
+
* the listener then serves without reporting.
|
|
953
|
+
*/
|
|
954
|
+
declare function ensureListenerInstanceId(home: string): Promise<string | null>;
|
|
955
|
+
/** The home's listener id when a listener made one; null otherwise. Never creates one. */
|
|
956
|
+
declare function readListenerInstanceId(home: string): string | null;
|
|
957
|
+
/** What the integration tells AgentChat through: the kit's `ListenerReporter` (a fake in tests). */
|
|
958
|
+
type ListenerReportSink = Pick<integration.ListenerReporter, 'set' | 'status'>;
|
|
959
|
+
/** The kit reporter's timing (test seams; a listener uses the kit's defaults). */
|
|
960
|
+
type ListenerReportTiming = Pick<integration.ListenerReporterOptions, 'coalesceMs' | 'minIntervalMs' | 'retryMs' | 'retryMaxMs' | 'resendMs'>;
|
|
961
|
+
/** What a command waits for its `stopped` report, at most. */
|
|
962
|
+
declare const STOPPED_REPORT_TIMEOUT_MS = 5000;
|
|
963
|
+
interface KeyedIdentity {
|
|
964
|
+
readonly apiKey: string;
|
|
965
|
+
readonly apiBase: string;
|
|
966
|
+
}
|
|
967
|
+
interface CreateListenerReporterOptions extends KeyedIdentity {
|
|
968
|
+
readonly client: IntegrationClient;
|
|
969
|
+
readonly instanceId: string;
|
|
970
|
+
/** Test seam: what sends the reports (default: a client for this identity). */
|
|
971
|
+
readonly api?: integration.ListenerReportClient;
|
|
972
|
+
readonly timing?: ListenerReportTiming;
|
|
973
|
+
}
|
|
974
|
+
/** The daemon's reporter for one identity: a failure is said at warn, once per new failure, and retried by the kit. */
|
|
975
|
+
declare function createListenerReporter(options: CreateListenerReporterOptions): integration.ListenerReporter;
|
|
976
|
+
interface ReportListenerStoppedOptions {
|
|
977
|
+
/** The identity home whose listener stops. */
|
|
978
|
+
readonly home: string;
|
|
979
|
+
/** How the integration names itself to the server. */
|
|
980
|
+
readonly client: IntegrationClient;
|
|
981
|
+
/**
|
|
982
|
+
* The agent that home's listener serves (its key, base and handle, as
|
|
983
|
+
* `resolveIdentity` gives it); null: nothing to report. Only a key the home
|
|
984
|
+
* holds counts (`source: 'file'`): an exported key is not what the home's
|
|
985
|
+
* listener serves (a service never carries one).
|
|
986
|
+
*/
|
|
987
|
+
readonly identity: (KeyedIdentity & {
|
|
988
|
+
readonly handle: string | null;
|
|
989
|
+
readonly source?: 'file' | 'env';
|
|
990
|
+
}) | null;
|
|
991
|
+
/** The one attempt's bound (default `STOPPED_REPORT_TIMEOUT_MS`). */
|
|
992
|
+
readonly timeoutMs?: number;
|
|
993
|
+
/** Test seam: what sends the report. */
|
|
994
|
+
readonly api?: integration.ListenerReportClient;
|
|
995
|
+
}
|
|
996
|
+
/**
|
|
997
|
+
* What came of a `stopped` report: `reported` (AgentChat holds it),
|
|
998
|
+
* `failed` (it does not: `detail` says why; it then reads the listener as
|
|
999
|
+
* offline once its socket is gone), or `skipped`: `no_identity` (no key
|
|
1000
|
+
* the home holds),
|
|
1001
|
+
* `no_listener` (no listener of this home ever reported: there is nothing
|
|
1002
|
+
* to stop), `standby` (another home's listener serves this agent: a
|
|
1003
|
+
* standby reports nothing).
|
|
1004
|
+
*/
|
|
1005
|
+
type ListenerStoppedResult = {
|
|
1006
|
+
readonly outcome: 'reported';
|
|
1007
|
+
} | {
|
|
1008
|
+
readonly outcome: 'failed';
|
|
1009
|
+
readonly detail: string;
|
|
1010
|
+
} | {
|
|
1011
|
+
readonly outcome: 'skipped';
|
|
1012
|
+
readonly reason: 'no_identity' | 'no_listener' | 'standby';
|
|
1013
|
+
};
|
|
1014
|
+
/**
|
|
1015
|
+
* Tell AgentChat this home's listener stops on purpose (`stopped`, contract
|
|
1016
|
+
* v1 §3.13), so the agent reads as switched off rather than as a computer
|
|
1017
|
+
* that is off. For the commands that end it — `logout`, `uninstall`, `daemon
|
|
1018
|
+
* disable` — and called BEFORE the key or the service goes: the report needs
|
|
1019
|
+
* the key, and it must come before the listener closes its socket. One
|
|
1020
|
+
* attempt, bounded by `timeoutMs`; never throws (the command goes on either
|
|
1021
|
+
* way).
|
|
1022
|
+
*/
|
|
1023
|
+
declare function reportListenerStopped(options: ReportListenerStoppedOptions): Promise<ListenerStoppedResult>;
|
|
1024
|
+
/** The line a command prints for a `stopped` report (no indent), or null when there was nothing to report. */
|
|
1025
|
+
declare function describeListenerStopped(result: ListenerStoppedResult): string | null;
|
|
801
1026
|
|
|
802
|
-
export {
|
|
1027
|
+
export { MANUAL_FILENAME as $, type AnchorServedLine as A, type IdentityBlockStateName as B, type CreateListenerReporterOptions as C, DEFAULT_API_BASE as D, type IdentityBlockStateOptions as E, FAILED_CYCLE_OUTCOMES as F, type IntegrationCouldNotProcess as G, type HostProfile as H, type IntegrationClient as I, type IntegrationCycle as J, type IntegrationIdentityLine as K, type LeaseOptions as L, type ManualPointer as M, type IntegrationLastRun as N, type IntegrationListenerReport as O, type PendingSignup as P, type IntegrationPausedConversation as Q, type IntegrationStandby as R, type SocketState as S, type IntegrationUnservable as T, LEASE_RENEW_MS as U, LEASE_STALE_MS as V, LEGACY_STATUS_FILE as W, LISTENER_ID_FILE as X, type ListenerStoppedResult as Y, MANUAL as Z, MANUAL_FETCH_TIMEOUT_MS as _, type AnchorLoadNote as a, pidAlive as a$, MANUAL_MAX_BYTES as a0, MANUAL_MAX_REDIRECTS as a1, MANUAL_SKILL_NAME as a2, MANUAL_URL as a3, type ManualCheck as a4, type ManualCheckState as a5, type ManualSyncResult as a6, type ManualSyncState as a7, type PendingRegistration as a8, type PlacementOutput as a9, describeListenerStopped as aA, describeManualSync as aB, describePausedConversations as aC, ensureInstallId as aD, envApiKey as aE, envKeyConflict as aF, failedCyclesInARow as aG, followIdentityAnchor as aH, formatIntegrationStatus as aI, fromKitResult as aJ, holderLive as aK, hostIdentityOf as aL, identityBlockState as aM, installIdPath as aN, installMethodOf as aO, integrationStatusAge as aP, integrationStatusFresh as aQ, integrationStatusPath as aR, integrationStatusStaleFor as aS, leaseHolder as aT, listenerIdPath as aU, manualFrontMatter as aV, manualPointer as aW, manualVersion as aX, newInstallId as aY, parseLease as aZ, pendingPath as a_, type PlacementReport as aa, REPEATED_FAILED_CYCLES as ab, type ReportListenerStoppedOptions as ac, type ResolveIdentityOptions as ad, type ResolvedIdentity as ae, SOCKET_STATES as af, STOPPED_REPORT_TIMEOUT_MS as ag, type ServedManual as ah, type StatusContext as ai, type SyncManualOptions as aj, type TextsStatus as ak, type Verdict as al, acquireLease as am, anchorLabelOf as an, bootedAt as ao, checkManual as ap, clearCredentials as aq, clearInstallId as ar, clearIntegrationStatus as as, clearPending as at, clientHeadersOf as au, clientIdentityOf as av, clientNameOf as aw, credentialsPath as ax, describeCouldNotProcessCounts as ay, describeIdentityBlock as az, type ListenerReportTiming as b, placementReportOf as b0, readCredentials as b1, readInstallId as b2, readIntegrationStatus as b3, readListenerInstanceId as b4, readManualVersion as b5, readPending as b6, readRememberedHost as b7, rememberHost as b8, repeatedFailedRuns as b9, reportListenerStopped as ba, resetLeaseObservations as bb, resolveIdentity as bc, resolveManualPointer as bd, runtimeCheckFailingNow as be, servedManualUrl as bf, statePath as bg, syncManual as bh, writeCredentials as bi, writeIntegrationStatus as bj, writePending as bk, type ManualFetch as c, type IntegrationStatus as d, type ListenerReportSink as e, type IntegrationRunsFailing as f, createListenerReporter as g, ensureListenerInstanceId as h, type ListenerEnsure as i, type PlacementProblem as j, type Lease as k, type LeaseAttempt as l, type LeaseHolder as m, type CheckManualOptions as n, type Credentials as o, type DoctorCheck as p, type DoctorContext as q, type FollowIdentityAnchorOptions as r, HOST_FILE as s, IDENTITY_ANCHOR_ATTEMPTS as t, INSTALL_ID_FILE as u, INTEGRATION_STATUS_FILE as v, INTEGRATION_STATUS_STALE_MS as w, type IdentityAnchorOutcome as x, type IdentityAnchorResult as y, type IdentityBlockState as z };
|