@agentchatme/agent-core 0.3.1 → 0.4.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 +34 -26
- package/dist/chunk-HOY2FERJ.js +26 -0
- package/dist/chunk-HOY2FERJ.js.map +1 -0
- package/dist/chunk-NCSF3CCV.js +139 -0
- package/dist/chunk-NCSF3CCV.js.map +1 -0
- package/dist/chunk-TH6XOVA3.js +283 -0
- package/dist/chunk-TH6XOVA3.js.map +1 -0
- package/dist/{chunk-4YF2K5ND.js → chunk-W3LYBKIV.js} +391 -888
- package/dist/chunk-W3LYBKIV.js.map +1 -0
- package/dist/daemon-entry.d.ts +127 -282
- package/dist/daemon-entry.js +308 -951
- package/dist/daemon-entry.js.map +1 -1
- package/dist/index.d.ts +63 -14
- package/dist/index.js +98 -137
- package/dist/index.js.map +1 -1
- package/dist/presets.d.ts +262 -0
- package/dist/presets.js +538 -0
- package/dist/presets.js.map +1 -0
- package/dist/runner-BzgsiS3V.d.ts +122 -0
- package/dist/served-manual-DZmEak4_.d.ts +368 -0
- package/package.json +8 -3
- package/dist/chunk-4YF2K5ND.js.map +0 -1
- package/dist/prompts-BUfpwUT7.d.ts +0 -630
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
declare const RUN_PROFILES: readonly ["answer", "work", "full"];
|
|
2
|
+
type RunProfile = (typeof RUN_PROFILES)[number];
|
|
3
|
+
declare const RUN_PROFILE_ENV = "AGENTCHAT_RUN_PROFILE";
|
|
4
|
+
declare const DEFAULT_RUN_PROFILE: RunProfile;
|
|
5
|
+
declare function isRunProfile(value: unknown): value is RunProfile;
|
|
6
|
+
/** `AGENTCHAT_RUN_PROFILE`, defaulting to `answer`; an unknown value is `answer` too. */
|
|
7
|
+
declare function resolveRunProfile(env?: NodeJS.ProcessEnv): RunProfile;
|
|
8
|
+
/** The one switch: `AGENTCHAT_INTEGRATION=off` holds no socket and starts no run. Tools and manual stay. */
|
|
9
|
+
declare const INTEGRATION_ENV = "AGENTCHAT_INTEGRATION";
|
|
10
|
+
/**
|
|
11
|
+
* The previous spelling of the switch. Honoured for one release: a service
|
|
12
|
+
* installed before the rename captured it into its unit file, and that unit
|
|
13
|
+
* must keep meaning what the operator set.
|
|
14
|
+
*/
|
|
15
|
+
declare const INTEGRATION_ENV_LEGACY = "AGENTCHAT_DOORBELL";
|
|
16
|
+
/** Which switch turned the integration off, or null when it is on. The new spelling wins when both are set. */
|
|
17
|
+
declare function integrationDisabledBy(env?: NodeJS.ProcessEnv): string | null;
|
|
18
|
+
declare function integrationDisabled(env?: NodeJS.ProcessEnv): boolean;
|
|
19
|
+
/** A run's time budget. Killed past it; that counts as a failed run. */
|
|
20
|
+
declare const RUN_BUDGET_ENV = "AGENTCHAT_RUN_BUDGET_MS";
|
|
21
|
+
declare const DEFAULT_RUN_BUDGET_MS: number;
|
|
22
|
+
declare function resolveRunBudgetMs(env?: NodeJS.ProcessEnv): number;
|
|
23
|
+
|
|
24
|
+
/** `invite` when the tray held only pending invites (the served invite prompt); `wake` otherwise. */
|
|
25
|
+
type RunKind = 'wake' | 'invite';
|
|
26
|
+
/**
|
|
27
|
+
* The wake that started a run, named as the webhook wake names it (contract
|
|
28
|
+
* v1): `messages`, `reminder`, `invite`, `unanswered` (with `step`, the
|
|
29
|
+
* re-wake rung) — or another reason a newer server sends. Facts about the
|
|
30
|
+
* signal only, never content.
|
|
31
|
+
*/
|
|
32
|
+
interface RunWake {
|
|
33
|
+
readonly reason: string;
|
|
34
|
+
readonly step?: number;
|
|
35
|
+
}
|
|
36
|
+
interface RunRequest {
|
|
37
|
+
readonly kind: RunKind;
|
|
38
|
+
/** The wake that started this run (the newest since the previous run started). */
|
|
39
|
+
readonly wake?: RunWake;
|
|
40
|
+
/** The prompt for this kind of run: the served text (the kit's receive loop picks it), then the manual pointer. */
|
|
41
|
+
readonly prompt: string;
|
|
42
|
+
/** Unique per run; for logs and for runtimes that want a session name. */
|
|
43
|
+
readonly runId: string;
|
|
44
|
+
/** The run is killed past this budget and counts as failed. */
|
|
45
|
+
readonly budgetMs: number;
|
|
46
|
+
/**
|
|
47
|
+
* Aborted when the integration is stopping (daemon shutdown, identity
|
|
48
|
+
* change). A runner passes it to `spawnRun`, which SIGTERMs the
|
|
49
|
+
* run's process group and SIGKILLs after a grace; the outcome is `failed`
|
|
50
|
+
* with an "interrupted" detail. Optional so a runner that cannot interrupt
|
|
51
|
+
* still satisfies the contract.
|
|
52
|
+
*/
|
|
53
|
+
readonly signal?: AbortSignal;
|
|
54
|
+
/**
|
|
55
|
+
* Called once, as soon as the runtime's process has been started. The
|
|
56
|
+
* engine no longer needs it (pending invites are on the tray, so nothing
|
|
57
|
+
* is recorded locally); kept so a caller can observe the start. A runner
|
|
58
|
+
* built on `spawnRun` passes it through.
|
|
59
|
+
*/
|
|
60
|
+
readonly onStarted?: () => void;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* `not_started` — the runtime never got going: binary missing, or a non-zero
|
|
64
|
+
* exit with NOTHING ON STDOUT (an auth gate, a bad flag, a missing config —
|
|
65
|
+
* all of which print their complaint on stderr and quit; stderr does not
|
|
66
|
+
* count as output). `failed` — it produced output and exited non-zero, or was
|
|
67
|
+
* interrupted. `timed_out` — it ran past its budget and was killed. `ok` —
|
|
68
|
+
* exit 0. Anything but `ok` leaves the cards on the tray: there is no local retry —
|
|
69
|
+
* the server re-wakes an agent for cards it has not answered (contract v1, D3).
|
|
70
|
+
*/
|
|
71
|
+
type RunOutcomeState = 'ok' | 'failed' | 'timed_out' | 'not_started';
|
|
72
|
+
interface RunOutcome {
|
|
73
|
+
readonly state: RunOutcomeState;
|
|
74
|
+
readonly exitCode: number | null;
|
|
75
|
+
readonly durationMs: number;
|
|
76
|
+
/** Bounded, credential-redacted diagnostic. Never message content. */
|
|
77
|
+
readonly detail?: string;
|
|
78
|
+
}
|
|
79
|
+
interface RunPreflight {
|
|
80
|
+
ok: boolean;
|
|
81
|
+
detail?: string;
|
|
82
|
+
}
|
|
83
|
+
interface RunRunner {
|
|
84
|
+
/** Short runtime name for logs and status, e.g. the CLI's binary name. */
|
|
85
|
+
readonly name: string;
|
|
86
|
+
/**
|
|
87
|
+
* Is the runtime usable right now (binary present, signed in)? Called
|
|
88
|
+
* before the socket is held: an integration whose runtime is not usable
|
|
89
|
+
* holds no socket, and the supervisor asks again with a backoff.
|
|
90
|
+
*/
|
|
91
|
+
preflight(): Promise<RunPreflight>;
|
|
92
|
+
/** Start one run and wait for it. Never throws — returns an outcome. */
|
|
93
|
+
start(request: RunRequest): Promise<RunOutcome>;
|
|
94
|
+
}
|
|
95
|
+
/** The agent a runner's runs act as: what a `RunnerFactory` is given for each identity the integration serves. */
|
|
96
|
+
interface RunnerIdentity {
|
|
97
|
+
/** The identity home. */
|
|
98
|
+
readonly home: string;
|
|
99
|
+
/** Bare handle. */
|
|
100
|
+
readonly handle: string;
|
|
101
|
+
/** The agent's key. A runner hands it to its runs only as a file or an environment variable, never on argv. */
|
|
102
|
+
readonly apiKey: string;
|
|
103
|
+
readonly apiBase: string;
|
|
104
|
+
/** The run's working directory. */
|
|
105
|
+
readonly workdir: string;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Builds the runner for one identity. For runners whose runs must be told
|
|
109
|
+
* which agent they act as (a listener's preset writes the agent's hosted tool
|
|
110
|
+
* config; a forwarder reads that agent's tray): the resident supervisor calls
|
|
111
|
+
* `create` again whenever the credential changes.
|
|
112
|
+
*/
|
|
113
|
+
interface RunnerFactory {
|
|
114
|
+
/** Short runtime name for logs and status, before any identity is known. */
|
|
115
|
+
readonly name: string;
|
|
116
|
+
create(identity: RunnerIdentity): RunRunner;
|
|
117
|
+
}
|
|
118
|
+
/** A runner, or a factory of one per identity. */
|
|
119
|
+
type RunnerSource = RunRunner | RunnerFactory;
|
|
120
|
+
declare function isRunnerFactory(source: RunnerSource): source is RunnerFactory;
|
|
121
|
+
|
|
122
|
+
export { DEFAULT_RUN_BUDGET_MS as D, INTEGRATION_ENV as I, type RunnerSource as R, type RunProfile as a, type RunRunner as b, type RunOutcome as c, type RunKind as d, type RunOutcomeState as e, type RunPreflight as f, type RunRequest as g, type RunWake as h, type RunnerFactory as i, type RunnerIdentity as j, DEFAULT_RUN_PROFILE as k, INTEGRATION_ENV_LEGACY as l, RUN_BUDGET_ENV as m, RUN_PROFILES as n, RUN_PROFILE_ENV as o, integrationDisabled as p, integrationDisabledBy as q, isRunProfile as r, isRunnerFactory as s, resolveRunBudgetMs as t, resolveRunProfile as u };
|
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import { TextsRuntime, AgentChatClientIdentity, integration } from 'agentchatme';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
interface IntegrationClient {
|
|
5
|
+
readonly runtime: TextsRuntime;
|
|
6
|
+
readonly version: string;
|
|
7
|
+
/**
|
|
8
|
+
* The client name sent to the server when it is not the runtime itself —
|
|
9
|
+
* a front door that serves several runtimes (the `agentchat` listener)
|
|
10
|
+
* names itself here, and `runtime` stays what the texts are rendered for.
|
|
11
|
+
*/
|
|
12
|
+
readonly name?: string;
|
|
13
|
+
}
|
|
14
|
+
/** The name this client identifies as: its own `name`, else its runtime. */
|
|
15
|
+
declare function clientNameOf(client: IntegrationClient): string;
|
|
16
|
+
/**
|
|
17
|
+
* The SDK's client identity for this integration. The SDK types client names
|
|
18
|
+
* as a closed union and the server normalises whatever arrives, so the
|
|
19
|
+
* runtime name is passed through as-is; the union widens on the SDK side.
|
|
20
|
+
*/
|
|
21
|
+
declare function clientIdentityOf(client: IntegrationClient): AgentChatClientIdentity;
|
|
22
|
+
/** The same identity as headers, for the one raw request this package still makes (the MCP probe). */
|
|
23
|
+
declare function clientHeadersOf(client: IntegrationClient): Record<string, string>;
|
|
24
|
+
|
|
25
|
+
declare const INTEGRATION_STATUS_FILE = "integration.status.json";
|
|
26
|
+
/** The file a daemon before the rename writes; read when the current one is absent. */
|
|
27
|
+
declare const LEGACY_STATUS_FILE = "doorbell.status.json";
|
|
28
|
+
/**
|
|
29
|
+
* The socket word. `blocked` is the SDK's own word for it (`RealtimeState`):
|
|
30
|
+
* the server refused the credential on the hello and a fresh hello is tried
|
|
31
|
+
* every 10–15 min until one is accepted — not an end state. Daemons before
|
|
32
|
+
* this release wrote `terminal` for it; readers map that on the way in.
|
|
33
|
+
*/
|
|
34
|
+
declare const SOCKET_STATES: readonly ["off", "idle", "connecting", "ready", "reconnecting", "blocked", "closed"];
|
|
35
|
+
type SocketState = (typeof SOCKET_STATES)[number];
|
|
36
|
+
type TextsSource = 'server' | 'cache' | 'none';
|
|
37
|
+
interface TextsStatus {
|
|
38
|
+
/** Where the texts a run starts with came from. */
|
|
39
|
+
source: TextsSource;
|
|
40
|
+
fetched_at: string | null;
|
|
41
|
+
/** The served text set's version. */
|
|
42
|
+
version: string | null;
|
|
43
|
+
manual_version: string | null;
|
|
44
|
+
}
|
|
45
|
+
interface IntegrationLastRun {
|
|
46
|
+
kind: 'wake' | 'invite';
|
|
47
|
+
started_at: string;
|
|
48
|
+
ended_at: string;
|
|
49
|
+
state: 'ok' | 'failed' | 'timed_out' | 'not_started';
|
|
50
|
+
exit_code: number | null;
|
|
51
|
+
duration_ms: number;
|
|
52
|
+
detail: string | null;
|
|
53
|
+
}
|
|
54
|
+
interface IntegrationStatus {
|
|
55
|
+
version: 2;
|
|
56
|
+
updated_at: string;
|
|
57
|
+
pid: number;
|
|
58
|
+
runtime: string | null;
|
|
59
|
+
handle: string | null;
|
|
60
|
+
profile: string;
|
|
61
|
+
socket: SocketState;
|
|
62
|
+
wakes: number;
|
|
63
|
+
wakes_absorbed: number;
|
|
64
|
+
invites: number;
|
|
65
|
+
runs_started: number;
|
|
66
|
+
runs_ok: number;
|
|
67
|
+
runs_failed: number;
|
|
68
|
+
runs_timed_out: number;
|
|
69
|
+
runs_not_started: number;
|
|
70
|
+
/** Wakes whose tray count came back empty, so no run started. */
|
|
71
|
+
runs_skipped_empty: number;
|
|
72
|
+
last_run: IntegrationLastRun | null;
|
|
73
|
+
retry_rung: number;
|
|
74
|
+
retry_due_at: string | null;
|
|
75
|
+
last_error: string | null;
|
|
76
|
+
texts: TextsStatus | null;
|
|
77
|
+
/** The socket capabilities the server accepted (`ack`, `heartbeat`, `rewake`); null before a hello, or from an older daemon. */
|
|
78
|
+
capabilities?: string[] | null;
|
|
79
|
+
/** The receive loop's most recent wake cycles, oldest first (the kit's `status().recentCycles`, reduced); null from an older daemon. */
|
|
80
|
+
recent_cycles?: IntegrationCycle[] | null;
|
|
81
|
+
/** The socket's backpressure: true while it refuses new messages because handlers are behind (the kit's `intakePaused`); null from an older daemon. */
|
|
82
|
+
intake_paused?: boolean | null;
|
|
83
|
+
}
|
|
84
|
+
/** One wake cycle as the status file keeps it: what it found and how it ended. Counts and outcomes only. */
|
|
85
|
+
interface IntegrationCycle {
|
|
86
|
+
at: string;
|
|
87
|
+
/** The kit's cycle outcome: `empty`, `nothing_owed`, `run_completed`, `run_failed`, `abandoned`, … */
|
|
88
|
+
outcome: string;
|
|
89
|
+
cards: number;
|
|
90
|
+
invites: number;
|
|
91
|
+
/** Why it did not finish, bounded; null when it did. */
|
|
92
|
+
failure: string | null;
|
|
93
|
+
}
|
|
94
|
+
/** Cycle outcomes that mean a wake was owed something and it did not get done. */
|
|
95
|
+
declare const FAILED_CYCLE_OUTCOMES: ReadonlySet<string>;
|
|
96
|
+
/** How many of the newest cycles in a row did not get done, with the newest failure; null when the newest cycle did. */
|
|
97
|
+
declare function failedCyclesInARow(status: Pick<IntegrationStatus, 'recent_cycles'> | null): {
|
|
98
|
+
count: number;
|
|
99
|
+
latest: IntegrationCycle;
|
|
100
|
+
} | null;
|
|
101
|
+
/** This many failed cycles in a row is a warning in `status` and `doctor`: one is a hiccup, three is a pattern. */
|
|
102
|
+
declare const REPEATED_FAILED_CYCLES = 3;
|
|
103
|
+
declare function integrationStatusPath(home: string): string;
|
|
104
|
+
/** Best effort: the status file is diagnostics, never a dependency of waking. */
|
|
105
|
+
declare function writeIntegrationStatus(home: string, status: IntegrationStatus): void;
|
|
106
|
+
/** The current file, or — when a daemon from before the rename is the one running — the file it writes. */
|
|
107
|
+
declare function readIntegrationStatus(home: string): IntegrationStatus | null;
|
|
108
|
+
/** Remove both spellings: a stale legacy file must not outlive the daemon that wrote it. */
|
|
109
|
+
declare function clearIntegrationStatus(home: string): void;
|
|
110
|
+
/** Age of the status file, in ms, or null when absent. */
|
|
111
|
+
declare function integrationStatusAge(status: IntegrationStatus | null, now?: number): number | null;
|
|
112
|
+
/** Human lines for `status`. Pure. */
|
|
113
|
+
declare function formatIntegrationStatus(status: IntegrationStatus | null, now?: number): string[];
|
|
114
|
+
|
|
115
|
+
declare const DEFAULT_API_BASE = "https://api.agentchat.me";
|
|
116
|
+
declare const CredentialsSchema: z.ZodObject<{
|
|
117
|
+
api_key: z.ZodString;
|
|
118
|
+
handle: z.ZodString;
|
|
119
|
+
api_base: z.ZodOptional<z.ZodString>;
|
|
120
|
+
created_at: z.ZodOptional<z.ZodString>;
|
|
121
|
+
}, "strip", z.ZodTypeAny, {
|
|
122
|
+
api_key: string;
|
|
123
|
+
handle: string;
|
|
124
|
+
api_base?: string | undefined;
|
|
125
|
+
created_at?: string | undefined;
|
|
126
|
+
}, {
|
|
127
|
+
api_key: string;
|
|
128
|
+
handle: string;
|
|
129
|
+
api_base?: string | undefined;
|
|
130
|
+
created_at?: string | undefined;
|
|
131
|
+
}>;
|
|
132
|
+
type Credentials = z.infer<typeof CredentialsSchema>;
|
|
133
|
+
interface ResolvedIdentity {
|
|
134
|
+
apiKey: string;
|
|
135
|
+
apiBase: string;
|
|
136
|
+
/** Handle is only known when it came from the credentials file. */
|
|
137
|
+
handle: string | null;
|
|
138
|
+
source: 'env' | 'file';
|
|
139
|
+
}
|
|
140
|
+
declare function credentialsPath(home: string): string;
|
|
141
|
+
declare function pendingPath(home: string): string;
|
|
142
|
+
declare function statePath(home: string): string;
|
|
143
|
+
/** Read the credential stored in `home`, or null when absent/malformed. */
|
|
144
|
+
declare function readCredentials(home: string): Credentials | null;
|
|
145
|
+
/**
|
|
146
|
+
* The identity an integration should act as, for one specific home.
|
|
147
|
+
* `AGENTCHAT_API_KEY` overrides the file; `AGENTCHAT_API_BASE` overrides the
|
|
148
|
+
* base URL. Neither is host-specific, so both are read from the environment.
|
|
149
|
+
*/
|
|
150
|
+
interface ResolveIdentityOptions {
|
|
151
|
+
/**
|
|
152
|
+
* Whether `AGENTCHAT_API_KEY` may override the home's credentials (default
|
|
153
|
+
* true). A resident listener passes false: the agent it serves is the one
|
|
154
|
+
* its home holds, whatever happens to be exported in the shell that
|
|
155
|
+
* started it.
|
|
156
|
+
*/
|
|
157
|
+
readonly envKey?: boolean;
|
|
158
|
+
}
|
|
159
|
+
/** `AGENTCHAT_API_KEY` from the environment when it is set and well-formed, else null. */
|
|
160
|
+
declare function envApiKey(env?: NodeJS.ProcessEnv): string | null;
|
|
161
|
+
declare function resolveIdentity(home: string, options?: ResolveIdentityOptions): ResolvedIdentity | null;
|
|
162
|
+
declare function writeCredentials(home: string, creds: Credentials): void;
|
|
163
|
+
/** Delete the credential and any half-finished registration in `home`.
|
|
164
|
+
* Touches nothing outside `home` — that is the caller's whole agent. */
|
|
165
|
+
declare function clearCredentials(home: string): boolean;
|
|
166
|
+
declare const PendingSchema: z.ZodObject<{
|
|
167
|
+
kind: z.ZodDefault<z.ZodEnum<["register", "recover"]>>;
|
|
168
|
+
pending_id: z.ZodString;
|
|
169
|
+
email: z.ZodString;
|
|
170
|
+
handle: z.ZodOptional<z.ZodString>;
|
|
171
|
+
api_base: z.ZodOptional<z.ZodString>;
|
|
172
|
+
created_at: z.ZodString;
|
|
173
|
+
}, "strip", z.ZodTypeAny, {
|
|
174
|
+
created_at: string;
|
|
175
|
+
kind: "register" | "recover";
|
|
176
|
+
pending_id: string;
|
|
177
|
+
email: string;
|
|
178
|
+
handle?: string | undefined;
|
|
179
|
+
api_base?: string | undefined;
|
|
180
|
+
}, {
|
|
181
|
+
created_at: string;
|
|
182
|
+
pending_id: string;
|
|
183
|
+
email: string;
|
|
184
|
+
handle?: string | undefined;
|
|
185
|
+
api_base?: string | undefined;
|
|
186
|
+
kind?: "register" | "recover" | undefined;
|
|
187
|
+
}>;
|
|
188
|
+
type PendingRegistration = z.infer<typeof PendingSchema>;
|
|
189
|
+
declare function readPending(home: string): PendingRegistration | null;
|
|
190
|
+
declare function writePending(home: string, pending: PendingRegistration): void;
|
|
191
|
+
declare function clearPending(home: string): void;
|
|
192
|
+
|
|
193
|
+
type Verdict = 'PASS' | 'WARN' | 'FAIL';
|
|
194
|
+
interface DoctorCheck {
|
|
195
|
+
name: string;
|
|
196
|
+
verdict: Verdict;
|
|
197
|
+
detail: string;
|
|
198
|
+
}
|
|
199
|
+
/** What the shared `status` hands a host's extra lines: what it already fetched from the served texts (one fetch per command). */
|
|
200
|
+
interface StatusContext {
|
|
201
|
+
identityLine: string | null;
|
|
202
|
+
/** The manual the served texts announce (`texts.manual`), or null when none are in hand — what `checkManual` compares the skill file with. */
|
|
203
|
+
manual: ServedManual | null;
|
|
204
|
+
}
|
|
205
|
+
/** What the shared doctor hands a host's extra checks. */
|
|
206
|
+
interface DoctorContext {
|
|
207
|
+
fix?: boolean;
|
|
208
|
+
/** The served identity line for this agent, or null when the server could not be reached and nothing is cached. */
|
|
209
|
+
identityLine: string | null;
|
|
210
|
+
/** The manual the served texts announce, or null when none are in hand (`--fix` syncs the skill file to it). */
|
|
211
|
+
manual: ServedManual | null;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Everything the shared identity commands need to know about ONE coding agent.
|
|
215
|
+
*
|
|
216
|
+
* This is the seam. The register / login / recover / status / logout / doctor
|
|
217
|
+
* flows are the same everywhere because they are a contract with the AgentChat
|
|
218
|
+
* server; what differs per host is only what is described here. An integration
|
|
219
|
+
* builds one of these and gets the commands back.
|
|
220
|
+
*
|
|
221
|
+
* Note what is NOT here: any way to name a *different* host. A profile
|
|
222
|
+
* describes the caller and nothing else, so a command built from it cannot
|
|
223
|
+
* reach another agent's files. That is the same property the per-repo split
|
|
224
|
+
* gives, kept intact while the flow itself is shared once.
|
|
225
|
+
*
|
|
226
|
+
* The path-ish fields are functions, not strings: `CODEX_HOME` and friends are
|
|
227
|
+
* read per call, and evaluating them at module load would freeze a value the
|
|
228
|
+
* user can still change.
|
|
229
|
+
*/
|
|
230
|
+
interface HostProfile {
|
|
231
|
+
/** Human name for output, e.g. `Claude Code`. */
|
|
232
|
+
label: string;
|
|
233
|
+
/** Stable machine identifier for `--json`, e.g. `claude-code`. */
|
|
234
|
+
id: string;
|
|
235
|
+
/** How this integration names itself to the server: the texts runtime and its own version. */
|
|
236
|
+
client: IntegrationClient;
|
|
237
|
+
/** THE identity home for this agent. */
|
|
238
|
+
home(): string;
|
|
239
|
+
/**
|
|
240
|
+
* This host's always-loaded instruction file. Absent for a front door whose
|
|
241
|
+
* runtime has none it can place a line in (the `agentchat` listener runs an
|
|
242
|
+
* owner's command): no identity line is placed, checked or removed.
|
|
243
|
+
*/
|
|
244
|
+
anchorFile?(): string;
|
|
245
|
+
/** Exactly what a user types to reach this integration. */
|
|
246
|
+
invocation(): string;
|
|
247
|
+
/** Render the anchor block body this host wants from the served identity line (normally `renderAnchorBlock`). */
|
|
248
|
+
renderAnchor(identityLine: string): string;
|
|
249
|
+
/**
|
|
250
|
+
* What to call the anchor in output. Defaults to the instruction file's own
|
|
251
|
+
* basename (`CLAUDE.md`, `AGENTS.md`), which is what a user actually looks
|
|
252
|
+
* for on disk.
|
|
253
|
+
*/
|
|
254
|
+
anchorLabel?: string;
|
|
255
|
+
/**
|
|
256
|
+
* Whether this host is wired up enough for an anchor to mean anything.
|
|
257
|
+
* An integration uses this so it never writes an identity block announcing
|
|
258
|
+
* a phone number before its own placement is actually in place.
|
|
259
|
+
*/
|
|
260
|
+
isWired?(): boolean;
|
|
261
|
+
/**
|
|
262
|
+
* Place the integration's texts for a freshly established identity: the
|
|
263
|
+
* identity line, the manual, the hosted tool server with the key, and
|
|
264
|
+
* whatever the key's home is on this runtime. Called after register, login
|
|
265
|
+
* and recover (every time the key changes), and by `doctor --fix`.
|
|
266
|
+
* `identityLine` is the served line for this agent (fetched just before,
|
|
267
|
+
* or the cached one), or null when neither could be had — the host then
|
|
268
|
+
* leaves the anchor for `doctor --fix` and says so. `manual` is what the
|
|
269
|
+
* same texts announce (`syncManual` brings the skill file to it), or null.
|
|
270
|
+
* Returns report lines. When absent, only the anchor is written.
|
|
271
|
+
*/
|
|
272
|
+
place?(handle: string, apiKey: string, identityLine: string | null, manual: ServedManual | null): string[] | Promise<string[]>;
|
|
273
|
+
/**
|
|
274
|
+
* Undo `place` for the identity being signed out: remove the key from the
|
|
275
|
+
* tool server registration and anything else that would still authenticate
|
|
276
|
+
* as the old identity. The anchor is removed by the shared flow. Returns
|
|
277
|
+
* report lines.
|
|
278
|
+
*
|
|
279
|
+
* `identity` is the identity AS IT WAS BEFORE the credential was cleared
|
|
280
|
+
* (its key and API base), or null when there was none: a host recognises
|
|
281
|
+
* its own registration by that key and that server, and guessing either
|
|
282
|
+
* after the fact left a non-default `api_base` entry classified as foreign
|
|
283
|
+
* and the key still registered.
|
|
284
|
+
*/
|
|
285
|
+
unplace?(identity: ResolvedIdentity | null): string[];
|
|
286
|
+
/** Host-specific doctor checks, appended after the shared ones. */
|
|
287
|
+
extraDoctorChecks?(context: DoctorContext): DoctorCheck[] | Promise<DoctorCheck[]>;
|
|
288
|
+
/**
|
|
289
|
+
* Host-specific `status` lines (placement, probes), printed after the shared
|
|
290
|
+
* ones in text mode. The served identity line and manual come along so the
|
|
291
|
+
* host does not fetch `/v1/texts` a second time.
|
|
292
|
+
*/
|
|
293
|
+
extraStatus?(context: StatusContext): string[] | Promise<string[]>;
|
|
294
|
+
/** Extra lines printed after a successful logout. */
|
|
295
|
+
logoutHints?(): string[];
|
|
296
|
+
}
|
|
297
|
+
/** The label to use for this host's anchor in user-facing output. */
|
|
298
|
+
declare function anchorLabelOf(profile: HostProfile): string;
|
|
299
|
+
|
|
300
|
+
/** What the served texts announce: `Texts['manual']`, with the optional integrity hash. */
|
|
301
|
+
type ServedManual = integration.ServedManual;
|
|
302
|
+
declare const MANUAL_MAX_BYTES: number;
|
|
303
|
+
declare const MANUAL_FETCH_TIMEOUT_MS: 10000;
|
|
304
|
+
declare const MANUAL_MAX_REDIRECTS: 3;
|
|
305
|
+
/** `fetch`'s shape, injectable for tests. Defaults to the platform's own; called with `redirect: 'manual'`. */
|
|
306
|
+
type ManualFetch = integration.ManualFetch;
|
|
307
|
+
/**
|
|
308
|
+
* - `current` — the file already is the announced manual (version, and hash when announced); nothing fetched.
|
|
309
|
+
* - `updated` — the announced manual was written (downloaded, or the bundled copy when it is that manual).
|
|
310
|
+
* - `kept` — the existing file was left as it was: nothing announced to compare with, or no verified copy could be had.
|
|
311
|
+
* - `fallback` — no file existed and nothing verified could be had: the bundled copy was written.
|
|
312
|
+
* - `failed` — no file existed and none could be written.
|
|
313
|
+
*/
|
|
314
|
+
type ManualSyncState = integration.ManualSyncState;
|
|
315
|
+
interface ManualSyncResult extends Omit<integration.ManualSyncResult, 'source'> {
|
|
316
|
+
/** Where the written bytes came from, when some were written. */
|
|
317
|
+
readonly source: 'download' | 'bundled' | null;
|
|
318
|
+
}
|
|
319
|
+
interface SyncManualOptions {
|
|
320
|
+
/** The skill file, e.g. `<skills dir>/agentchat/SKILL.md`. The integration knows where; this package never derives it. */
|
|
321
|
+
readonly path: string;
|
|
322
|
+
/** `texts.manual` from the served texts (or their identity-home cache); null when none are in hand. */
|
|
323
|
+
readonly served: ServedManual | null;
|
|
324
|
+
/**
|
|
325
|
+
* The API base the texts were fetched from (the identity's `api_base`). It
|
|
326
|
+
* decides where a download may go; null (unknown) or a plain-HTTP base off
|
|
327
|
+
* loopback means no download at all.
|
|
328
|
+
*/
|
|
329
|
+
readonly apiBase: string | null;
|
|
330
|
+
readonly fetch?: ManualFetch;
|
|
331
|
+
readonly timeoutMs?: number;
|
|
332
|
+
readonly maxBytes?: number;
|
|
333
|
+
readonly signal?: AbortSignal;
|
|
334
|
+
}
|
|
335
|
+
/** The version the file at `file` carries, or null when it is missing or names none. */
|
|
336
|
+
declare function readManualVersion(file: string): string | null;
|
|
337
|
+
/** A kit result in this package's words (the fallback is the bundled copy). */
|
|
338
|
+
declare function fromKitResult(result: integration.ManualSyncResult): ManualSyncResult;
|
|
339
|
+
/**
|
|
340
|
+
* Bring the skill file at `path` to the announced manual (the kit's
|
|
341
|
+
* `syncManual`, the bundled copy as fallback). Never throws.
|
|
342
|
+
*/
|
|
343
|
+
declare function syncManual(options: SyncManualOptions): Promise<ManualSyncResult>;
|
|
344
|
+
declare function describeManualSync(result: ManualSyncResult): string;
|
|
345
|
+
type ManualCheckState = 'current' | 'stale' | 'unchecked' | 'missing';
|
|
346
|
+
interface ManualCheck {
|
|
347
|
+
readonly state: ManualCheckState;
|
|
348
|
+
readonly path: string;
|
|
349
|
+
readonly version: string | null;
|
|
350
|
+
readonly served: string | null;
|
|
351
|
+
/** current → PASS; stale or unchecked → WARN (the agent still has a manual); missing → FAIL. */
|
|
352
|
+
readonly verdict: Verdict;
|
|
353
|
+
/** `current (2.2.1)`, `stale (have 2.1.2, served 2.2.1)`, `unchecked (have 2.2.1; …)`, `missing`. */
|
|
354
|
+
readonly summary: string;
|
|
355
|
+
/** The summary and the file. */
|
|
356
|
+
readonly detail: string;
|
|
357
|
+
}
|
|
358
|
+
interface CheckManualOptions {
|
|
359
|
+
readonly path: string;
|
|
360
|
+
/** What the served texts announce; null when none are in hand. */
|
|
361
|
+
readonly served: ServedManual | null;
|
|
362
|
+
/** The API base the texts came from; a base no download would be made from is named in the summary. */
|
|
363
|
+
readonly apiBase: string | null;
|
|
364
|
+
}
|
|
365
|
+
/** Compare the skill file with the announced manual. Reads one file; no network. */
|
|
366
|
+
declare function checkManual(options: CheckManualOptions): ManualCheck;
|
|
367
|
+
|
|
368
|
+
export { resolveIdentity as $, clientIdentityOf as A, clientNameOf as B, type CheckManualOptions as C, DEFAULT_API_BASE as D, credentialsPath as E, FAILED_CYCLE_OUTCOMES as F, describeManualSync as G, type HostProfile as H, type IntegrationClient as I, envApiKey as J, failedCyclesInARow as K, LEGACY_STATUS_FILE as L, type ManualFetch as M, formatIntegrationStatus as N, fromKitResult as O, type PendingRegistration as P, integrationStatusAge as Q, REPEATED_FAILED_CYCLES as R, type SocketState as S, type TextsStatus as T, integrationStatusPath as U, type Verdict as V, pendingPath as W, readCredentials as X, readIntegrationStatus as Y, readManualVersion as Z, readPending as _, type IntegrationStatus as a, statePath as a0, syncManual as a1, writeCredentials as a2, writeIntegrationStatus as a3, writePending as a4, type Credentials as b, type DoctorCheck as c, type DoctorContext as d, INTEGRATION_STATUS_FILE as e, type IntegrationCycle as f, type IntegrationLastRun as g, MANUAL_FETCH_TIMEOUT_MS as h, MANUAL_MAX_BYTES as i, MANUAL_MAX_REDIRECTS as j, type ManualCheck as k, type ManualCheckState as l, type ManualSyncResult as m, type ManualSyncState as n, type ResolveIdentityOptions as o, type ResolvedIdentity as p, SOCKET_STATES as q, type ServedManual as r, type StatusContext as s, type SyncManualOptions as t, anchorLabelOf as u, checkManual as v, clearCredentials as w, clearIntegrationStatus as x, clearPending as y, clientHeadersOf as z };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentchatme/agent-core",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Shared host-agnostic engine for AgentChat
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Shared host-agnostic engine for AgentChat integrations — the resident supervisor on the AgentChat SDK's integration kit (single-run mode: the socket acking on receipt, wakes, the tray before every run), the runner seam and spawnRun, the presets for known coding agents' headless runs, identity storage and flows, service plumbing. Runtime code only; every function takes an identity home, none resolves one.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -16,6 +16,11 @@
|
|
|
16
16
|
"import": "./dist/daemon-entry.js",
|
|
17
17
|
"default": "./dist/daemon-entry.js"
|
|
18
18
|
},
|
|
19
|
+
"./presets": {
|
|
20
|
+
"types": "./dist/presets.d.ts",
|
|
21
|
+
"import": "./dist/presets.js",
|
|
22
|
+
"default": "./dist/presets.js"
|
|
23
|
+
},
|
|
19
24
|
"./package.json": "./package.json"
|
|
20
25
|
},
|
|
21
26
|
"files": [
|
|
@@ -37,7 +42,7 @@
|
|
|
37
42
|
"prepare": "pnpm run build"
|
|
38
43
|
},
|
|
39
44
|
"dependencies": {
|
|
40
|
-
"agentchatme": "^1.
|
|
45
|
+
"agentchatme": "^1.3.0",
|
|
41
46
|
"cross-spawn": "^7.0.6",
|
|
42
47
|
"ws": "^8.18.0",
|
|
43
48
|
"zod": "^3.23.0"
|