@agentchatme/agent-core 0.3.1 → 0.4.1

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/dist/index.d.ts CHANGED
@@ -1,11 +1,12 @@
1
- import { I as IntegrationClient, H as HostProfile } from './prompts-BUfpwUT7.js';
2
- export { C as CachedTexts, l as CheckManualOptions, m as Credentials, n as DEFAULT_API_BASE, o as DEFAULT_RUN_BUDGET_MS, p as DEFAULT_RUN_PROFILE, q as DoctorCheck, r as DoctorContext, F as FetchIdentityLineOptions, s as FetchServedTextsOptions, t as INTEGRATION_ENV, u as INTEGRATION_ENV_LEGACY, v as INTEGRATION_STATUS_FILE, e as IntegrationLastRun, b as IntegrationStatus, L as LEGACY_STATUS_FILE, w as LoadTextsOptions, x as LoadedTexts, y as MANUAL_FETCH_TIMEOUT_MS, z as MANUAL_MAX_BYTES, A as MANUAL_MAX_REDIRECTS, B as ManualCheck, E as ManualCheckState, M as ManualFetch, G as ManualFollower, J as ManualFollowerOptions, K as ManualSyncResult, N as ManualSyncState, P as PendingRegistration, O as RUN_BUDGET_ENV, Q as RUN_PROFILES, U as RUN_PROFILE_ENV, V as ResolvedIdentity, g as RunKind, f as RunOutcome, h as RunOutcomeState, i as RunPreflight, a as RunProfile, c as RunPrompts, j as RunRequest, R as RunRunner, X as SOCKET_STATES, Y as ServedManual, S as SocketState, Z as StatusContext, _ as SyncManualOptions, $ as TEXTS_CACHE_FILE, a0 as TEXTS_REFRESH_MS, a1 as TEXTS_RETRY_MS, a2 as TextsClient, a3 as TextsSource, a4 as TextsStatus, T as TextsStore, a5 as TextsStoreOptions, a6 as Verdict, a7 as anchorLabelOf, a8 as buildRunPrompts, a9 as checkManual, aa as clearCredentials, ab as clearIntegrationStatus, ac as clearPending, ad as clientHeadersOf, ae as clientIdentityOf, af as credentialsPath, ag as describeManualSync, ah as fetchIdentityLine, ai as fetchServedTexts, aj as formatIntegrationStatus, ak as integrationDisabled, al as integrationDisabledBy, am as integrationStatusAge, an as integrationStatusPath, ao as isRunProfile, ap as loadTexts, aq as pendingPath, ar as readCachedTexts, as as readCredentials, at as readIntegrationStatus, au as readManualVersion, av as readPending, aw as resolveIdentity, ax as resolveRunBudgetMs, ay as resolveRunProfile, az as statePath, aA as syncManual, aB as textsCachePath, aC as writeCachedTexts, aD as writeCredentials, aE as writeIntegrationStatus, aF as writePending } from './prompts-BUfpwUT7.js';
3
- import { AgentChatClient, Texts } from 'agentchatme';
1
+ import { I as IntegrationClient, H as HostProfile } from './served-manual-99vEOjJS.js';
2
+ export { C as CheckManualOptions, b as Credentials, D as DEFAULT_API_BASE, c as DoctorCheck, d as DoctorContext, F as FAILED_CYCLE_OUTCOMES, e as INTEGRATION_STATUS_FILE, f as IntegrationCycle, g as IntegrationLastRun, a as IntegrationStatus, L as LEGACY_STATUS_FILE, h as MANUAL_FETCH_TIMEOUT_MS, i as MANUAL_MAX_BYTES, j as MANUAL_MAX_REDIRECTS, k as ManualCheck, l as ManualCheckState, M as ManualFetch, m as ManualSyncResult, n as ManualSyncState, P as PendingRegistration, R as REPEATED_FAILED_CYCLES, o as ResolveIdentityOptions, p as ResolvedIdentity, q as SOCKET_STATES, r as ServedManual, S as SocketState, s as StatusContext, t as SyncManualOptions, T as TextsStatus, V as Verdict, u as anchorLabelOf, v as checkManual, w as clearCredentials, x as clearIntegrationStatus, y as clearPending, z as clientHeadersOf, A as clientIdentityOf, B as clientNameOf, E as credentialsPath, G as describeManualSync, J as envApiKey, K as failedCyclesInARow, N as formatIntegrationStatus, O as fromKitResult, Q as integrationStatusAge, U as integrationStatusPath, W as pendingPath, X as readCredentials, Y as readIntegrationStatus, Z as readManualVersion, _ as readPending, $ as resolveIdentity, a0 as statePath, a1 as syncManual, a2 as writeCredentials, a3 as writeIntegrationStatus, a4 as writePending } from './served-manual-99vEOjJS.js';
3
+ import { AgentChatClient, Texts, TextsRuntime, integration } from 'agentchatme';
4
4
  import { z } from 'zod';
5
+ export { D as DEFAULT_RUN_BUDGET_MS, k as DEFAULT_RUN_PROFILE, I as INTEGRATION_ENV, l as INTEGRATION_ENV_LEGACY, m as INTEGRATION_ENV_LEGACY_REMOVAL, n as RUN_BUDGET_ENV, o as RUN_PROFILES, p as RUN_PROFILE_ENV, d as RunKind, c as RunOutcome, e as RunOutcomeState, f as RunPreflight, a as RunProfile, g as RunRequest, b as RunRunner, h as RunWake, i as RunnerFactory, j as RunnerIdentity, R as RunnerSource, q as integrationDisabled, r as integrationDisabledBy, s as isRunProfile, t as isRunnerFactory, u as resolveRunBudgetMs, v as resolveRunProfile } from './runner-B-ZZDAAm.js';
5
6
  import { spawn, spawnSync } from 'node:child_process';
6
7
 
7
8
  /** Published package version, kept in lockstep with package.json by tests. */
8
- declare const VERSION = "0.3.1";
9
+ declare const VERSION = "0.4.1";
9
10
 
10
11
  type TrayClient = Pick<AgentChatClient, 'inbox'>;
11
12
  interface TraySummary {
@@ -18,13 +19,53 @@ interface TraySummary {
18
19
  }
19
20
  /** How many conversations are waiting, for `status`. One tray page, counted. */
20
21
  declare function traySummary(client: TrayClient): Promise<TraySummary>;
22
+
23
+ declare const TEXTS_CACHE_FILE = "texts.json";
24
+ type TextsSource = 'server' | 'cache' | 'none';
25
+ interface CachedTexts {
26
+ readonly fetched_at: string;
27
+ readonly runtime: string;
28
+ readonly texts: Texts;
29
+ }
30
+ declare function textsCachePath(home: string): string;
31
+ /** The last copy kept for this runtime, or null. A copy for another runtime is not this one's. No network. */
32
+ declare function readCachedTexts(home: string, runtime: TextsRuntime): CachedTexts | null;
33
+ type TextsClient = integration.TextsClient;
34
+ interface LoadedTexts {
35
+ readonly texts: Texts;
36
+ readonly source: 'server' | 'cache';
37
+ readonly fetched_at: string;
38
+ }
39
+ interface LoadTextsOptions {
40
+ readonly home: string;
41
+ readonly runtime: TextsRuntime;
42
+ readonly client: TextsClient;
43
+ readonly timeoutMs?: number;
44
+ readonly now?: () => Date;
45
+ }
21
46
  /**
22
- * Is anything waiting on the tray? `GET /v1/inbox?limit=1` — a count, never a
23
- * card: the one card the server may return is not read. This is the question
24
- * asked before every wake run: "does this wake deserve a run at all?" — the
25
- * reason a reconnect with an empty tray starts no run.
47
+ * One fetch with the cached copy as fallback (the kit's `TextsCache`, started
48
+ * and stopped) — what a CLI command does before it places the identity line
49
+ * or checks it. Null only when the server could not be reached and nothing was
50
+ * ever kept for this runtime.
26
51
  */
27
- declare function trayHasWaiting(client: TrayClient): Promise<boolean>;
52
+ declare function loadTexts(options: LoadTextsOptions): Promise<LoadedTexts | null>;
53
+ interface FetchIdentityLineOptions {
54
+ readonly home: string;
55
+ readonly apiKey: string;
56
+ readonly apiBase: string;
57
+ readonly client: IntegrationClient;
58
+ readonly timeoutMs?: number;
59
+ }
60
+ type FetchServedTextsOptions = FetchIdentityLineOptions;
61
+ /**
62
+ * The served texts for this agent, for an integration's own install and
63
+ * placement paths: one fetch through an SDK client built here, the cached
64
+ * copy as fallback, null when neither answers.
65
+ */
66
+ declare function fetchServedTexts(options: FetchServedTextsOptions): Promise<LoadedTexts | null>;
67
+ /** `fetchServedTexts`, reduced to the identity line. */
68
+ declare function fetchIdentityLine(options: FetchIdentityLineOptions): Promise<string | null>;
28
69
 
29
70
  declare const StateSchema: z.ZodObject<{
30
71
  offer_declined_at: z.ZodOptional<z.ZodString>;
@@ -74,7 +115,7 @@ declare function manualPointer(location: string): string;
74
115
 
75
116
  /** The identity line, ready to place, from a served (or cached) texts response. */
76
117
  declare function identityLineOf(texts: Pick<Texts, 'identity_line'>): string;
77
- /** Handles are canonical lowercase on the wire; a leading `@` is display only. */
118
+ /** Handles are canonical lowercase on the wire; a leading `@` is display only. The kit's (`integration.anchor.normalizeHandle`). */
78
119
  declare function normalizeHandle(handle: string): string;
79
120
 
80
121
  /**
@@ -107,36 +148,70 @@ declare function renderUnregisteredBlock(copy: HostCopy): string;
107
148
  */
108
149
  declare function renderDeclinedBlock(copy: HostCopy): string;
109
150
 
110
- declare const ANCHOR_START = "<!-- agentchat:start -->";
111
- declare const ANCHOR_END = "<!-- agentchat:end -->";
112
- /** The identity block: the served identity line, as fetched for this agent, between the markers. */
113
- declare function renderAnchorBlock(identityLine: string): string;
151
+ declare const ANCHOR_START: string;
152
+ declare const ANCHOR_END: string;
153
+ /**
154
+ * The identity block for `handle`: the fences, the handle line and the served
155
+ * identity line. Throws when the handle is empty, when the line does not name
156
+ * `@handle` — a silently wrong identity is worse than a loud failure: the
157
+ * agent would hand peers an address that reaches someone else — or when a
158
+ * line of it is a marker. Nothing is written then.
159
+ */
160
+ declare function renderAnchorBlock(identityLine: string, handle: string): string;
114
161
  type AnchorAction = 'written' | 'removed' | 'noop';
115
162
  /**
116
- * Upsert `block` into the file at `filePath`, creating it if needed.
163
+ * Put `block` in the file at `filePath`, in place of the first AgentChat block
164
+ * of any known shape (every other one is removed), or after the file's own
165
+ * text when there is none. Creates the file if needed. The rest of the file is
166
+ * kept as it was, except that the blank lines next to the block become
167
+ * exactly one; the write is atomic (see `writeInstructionFile`).
117
168
  *
118
- * Throws if `expectHandle` is given and does not appear in what was written —
119
- * a silently-wrong identity block is worse than a loud failure, because the
120
- * agent would spend every session announcing an address that isn't its own.
169
+ * With `expectHandle`, throws — writing nothing — unless the block names that
170
+ * handle, and throws if the file does not read back as written.
121
171
  */
122
172
  declare function writeAnchor(filePath: string, block: string, expectHandle?: string): AnchorAction;
173
+ /** Remove every AgentChat block (current or legacy) from the file; the rest stays as it was. */
123
174
  declare function removeAnchorAt(filePath: string): AnchorAction;
175
+ /**
176
+ * Whether the file holds an AgentChat block of any known shape (the identity
177
+ * block, a legacy one, or the wizard's offer). Throws when the file exists but
178
+ * cannot be read (or is not UTF-8): that is not "no block".
179
+ */
124
180
  declare function hasAnchorAt(filePath: string): boolean;
125
- /** Whether the file's block is exactly the block for this served identity line. */
126
- declare function anchorIsCurrentAt(filePath: string, identityLine: string): boolean;
127
181
  /**
128
- * The handle a file's anchor block currently CLAIMS, or null if there is no
129
- * block. Lets an integration catch an anchor that disagrees with its own
130
- * credential — an agent told it is @a while authenticating as @b hands peers an
131
- * address that reaches someone else. Matched loosely precisely so a WRONG
132
- * value is still read back and reported rather than treated as "no anchor".
182
+ * Whether writing the block for this served identity line and handle would
183
+ * change nothing: the file holds exactly that block, in the kit's place, and
184
+ * no other AgentChat block. An older shape (no handle line, older words), a
185
+ * stale second block, or a block the kit would re-space is not current, so
186
+ * placement and `doctor --fix` rewrite it — after which it is current
187
+ * (`replace` is idempotent), so status and the doctor converge. Throws as
188
+ * `hasAnchorAt` does.
189
+ */
190
+ declare function anchorIsCurrentAt(filePath: string, identityLine: string, handle: string): boolean;
191
+ /**
192
+ * The handle a file's block currently CLAIMS, or null when there is no block
193
+ * or it names no handle that can be read (the wizard's offer, most
194
+ * hand-edited blocks). Lets an integration catch a block that disagrees with
195
+ * its own credential — an agent told it is @a while authenticating as @b
196
+ * hands peers an address that reaches someone else — so a WRONG handle is
197
+ * read back, not treated as "no anchor".
198
+ *
199
+ * `template` is the served `identity_line_template` (null when no texts are
200
+ * in hand): it recognises an unmarked block in whatever words the server
201
+ * serves today; without it, the handle line and the two wordings earlier
202
+ * releases wrote are still read. A hand-edited block whose words happen to
203
+ * follow one of those (`I am happy … on AgentChat`) reads as claiming that
204
+ * word: the kit's wording match does not require the `@`. Throws as
205
+ * `hasAnchorAt` does.
133
206
  */
134
- declare function readAnchorHandleAt(filePath: string): string | null;
135
- declare function readAnchorHandleFrom(text: string): string | null;
207
+ declare function readAnchorHandleAt(filePath: string, template: string | null): string | null;
208
+ declare function readAnchorHandleFrom(text: string, template: string | null): string | null;
209
+ /** `existing` with `block` in place of the first block (current or legacy) and every other block removed; `kit.anchor.replace`. */
136
210
  declare function upsertAnchorBlock(existing: string, block: string): string;
211
+ /** `existing` without any block (current or legacy); `kit.anchor.remove`. */
137
212
  declare function stripAnchorBlock(existing: string): string;
138
213
 
139
- declare const HOSTED_MCP_PATH = "/mcp";
214
+ declare const HOSTED_MCP_PATH: "/mcp";
140
215
  declare function hostedMcpUrl(apiBase: string): string;
141
216
  interface McpProbeResult {
142
217
  readonly ok: boolean;
@@ -144,16 +219,24 @@ interface McpProbeResult {
144
219
  readonly serverName?: string;
145
220
  readonly serverVersion?: string;
146
221
  readonly protocolVersion?: string;
222
+ /** Every tool the server listed for this key. */
223
+ readonly tools?: readonly string[];
224
+ /** Tools a run needs that were not listed. */
225
+ readonly missing?: readonly string[];
147
226
  readonly error?: string;
148
227
  }
149
228
  declare function probeHostedMcp(params: {
150
229
  apiKey: string;
151
230
  apiBase: string;
152
- /** How this integration identifies to the server (headers on the probe). */
231
+ /** How this integration identifies to the server. */
153
232
  client: IntegrationClient;
154
- /** MCP `clientInfo.name`; defaults to the runtime name. */
233
+ /**
234
+ * Accepted for compatibility and ignored: the probe identifies as `client`
235
+ * (headers and `clientInfo` alike), so the server's analytics see the
236
+ * integration, never a free-text name it would file as unknown.
237
+ */
155
238
  clientName?: string;
156
- /** MCP `clientInfo.version`; defaults to the integration's version. */
239
+ /** Accepted for compatibility and ignored (see `clientName`). */
157
240
  clientVersion?: string;
158
241
  timeoutMs?: number;
159
242
  fetch?: typeof fetch;
@@ -368,4 +451,4 @@ declare function readJsonFile<T>(filePath: string): T | null;
368
451
  declare const spawnCommand: typeof spawn;
369
452
  declare const spawnCommandSync: typeof spawnSync;
370
453
 
371
- export { ANCHOR_END, ANCHOR_START, type AlwaysOnState, type AnchorAction, type DoctorOpts, HEARTBEAT_FILE, HOSTED_MCP_PATH, type HostCopy, HostProfile, type IdentityCommands, type IdentityState, IntegrationClient, type LockHandle, MANUAL, MANUAL_FILENAME, MANUAL_SKILL_NAME, MANUAL_URL, type McpProbeResult, type Plan, type RecoverOpts, type RegisterOpts, type ServiceCommandRunner, type ServiceHostOs, type ServiceOpts, type ServiceRef, type TrayClient, type TraySummary, VERSION, acquireLeaderLock, alwaysOnHealth, alwaysOnOptedOut, alwaysOnState, alwaysOnWanted, anchorIsCurrentAt, atomicCopyFile, atomicWriteFile, beat, clearAlwaysOnInstalledVersion, clearAlwaysOnOptOut, clearAlwaysOnWanted, clearOfferDeclined, createIdentityCommands, hasAnchorAt, hostedMcpUrl, identityLineOf, idle, installService, launchdPlist, log, manualFrontMatter, manualPointer, manualVersion, markAlwaysOnInstalledVersion, markAlwaysOnOptOut, markAlwaysOnWanted, normalizeHandle, offerDeclined, parseServiceHome, planForTest, probeHostedMcp, readAlwaysOnInstalledVersion, readAnchorHandleAt, readAnchorHandleFrom, readJsonFile, readState, recordOfferDeclined, removeAnchorAt, renderAnchorBlock, renderDeclinedBlock, renderUnregisteredBlock, serviceDefinitionCurrent, serviceInstalled, serviceLabelFor, serviceStatus, setServiceCommandRunnerForTests, setServiceHostOsForTests, spawnCommand, spawnCommandSync, stripAnchorBlock, systemdQuote, systemdUnit, trayHasWaiting, traySummary, uninstallService, upsertAnchorBlock, writeAnchor, writeState, xmlEscape };
454
+ export { ANCHOR_END, ANCHOR_START, type AlwaysOnState, type AnchorAction, type CachedTexts, type DoctorOpts, type FetchIdentityLineOptions, type FetchServedTextsOptions, HEARTBEAT_FILE, HOSTED_MCP_PATH, type HostCopy, HostProfile, type IdentityCommands, type IdentityState, IntegrationClient, type LoadTextsOptions, type LoadedTexts, type LockHandle, MANUAL, MANUAL_FILENAME, MANUAL_SKILL_NAME, MANUAL_URL, type McpProbeResult, type Plan, type RecoverOpts, type RegisterOpts, type ServiceCommandRunner, type ServiceHostOs, type ServiceOpts, type ServiceRef, TEXTS_CACHE_FILE, type TextsClient, type TextsSource, type TrayClient, type TraySummary, VERSION, acquireLeaderLock, alwaysOnHealth, alwaysOnOptedOut, alwaysOnState, alwaysOnWanted, anchorIsCurrentAt, atomicCopyFile, atomicWriteFile, beat, clearAlwaysOnInstalledVersion, clearAlwaysOnOptOut, clearAlwaysOnWanted, clearOfferDeclined, createIdentityCommands, fetchIdentityLine, fetchServedTexts, hasAnchorAt, hostedMcpUrl, identityLineOf, idle, installService, launchdPlist, loadTexts, log, manualFrontMatter, manualPointer, manualVersion, markAlwaysOnInstalledVersion, markAlwaysOnOptOut, markAlwaysOnWanted, normalizeHandle, offerDeclined, parseServiceHome, planForTest, probeHostedMcp, readAlwaysOnInstalledVersion, readAnchorHandleAt, readAnchorHandleFrom, readCachedTexts, readJsonFile, readState, recordOfferDeclined, removeAnchorAt, renderAnchorBlock, renderDeclinedBlock, renderUnregisteredBlock, serviceDefinitionCurrent, serviceInstalled, serviceLabelFor, serviceStatus, setServiceCommandRunnerForTests, setServiceHostOsForTests, spawnCommand, spawnCommandSync, stripAnchorBlock, systemdQuote, systemdUnit, textsCachePath, traySummary, uninstallService, upsertAnchorBlock, writeAnchor, writeState, xmlEscape };