@agentchatme/agent-core 0.1.0 → 0.2.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 +54 -36
- package/dist/{chunk-I4U4A7HO.js → chunk-GXAX47O6.js} +385 -148
- package/dist/chunk-GXAX47O6.js.map +1 -0
- package/dist/daemon-entry.d.ts +165 -140
- package/dist/daemon-entry.js +534 -442
- package/dist/daemon-entry.js.map +1 -1
- package/dist/index.d.ts +62 -80
- package/dist/index.js +186 -184
- package/dist/index.js.map +1 -1
- package/dist/prompts-B0UL03Hu.d.ts +336 -0
- package/package.json +3 -3
- package/dist/chunk-I4U4A7HO.js.map +0 -1
- package/dist/status-D8qOP4kM.d.ts +0 -260
package/dist/daemon-entry.d.ts
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import { R as RunRunner,
|
|
2
|
-
export {
|
|
1
|
+
import { R as RunRunner, I as IntegrationClient, a as RunProfile, S as SocketState, T as TextsStore, b as IntegrationStatus, c as RunPrompts, d as TimerHandle, e as IntegrationLastRun, f as RunOutcome } from './prompts-B0UL03Hu.js';
|
|
2
|
+
export { D as DEFAULT_WAKE_DEBOUNCE_MS, g as RunKind, h as RunOutcomeState, i as RunPreflight, j as RunRequest, W as WakeCoalescer, k as WakeCoalescerOptions } from './prompts-B0UL03Hu.js';
|
|
3
|
+
import { BlockedInfo, RealtimeState, AgentChatClient } from 'agentchatme';
|
|
3
4
|
import { EventEmitter } from 'node:events';
|
|
4
|
-
import 'zod';
|
|
5
5
|
|
|
6
|
-
interface
|
|
6
|
+
interface RunIntegrationOpts {
|
|
7
7
|
/** THE identity home for the agent this daemon serves. */
|
|
8
8
|
home: string;
|
|
9
9
|
/** How to start one headless run of this integration's coding agent. */
|
|
10
10
|
runner: RunRunner;
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
|
|
11
|
+
/** How this integration names itself to the server: the texts runtime and its own version. */
|
|
12
|
+
client: IntegrationClient;
|
|
13
|
+
/** The one pointer line a run prompt ends with: how THIS runtime reaches its copy of the manual (`manualPointer(...)`). */
|
|
14
|
+
manualPointer: string;
|
|
15
|
+
/** Scratch dir for runs. The integration decides where; this package never derives one. */
|
|
16
|
+
workdir: string;
|
|
15
17
|
/** Defaults to `AGENTCHAT_RUN_PROFILE`, then `answer`. */
|
|
16
18
|
profile?: RunProfile;
|
|
17
19
|
/** Defaults to `AGENTCHAT_RUN_BUDGET_MS`, then 10 minutes. */
|
|
@@ -23,145 +25,160 @@ interface RunDoorbellOpts {
|
|
|
23
25
|
exit?: (code: number) => void;
|
|
24
26
|
}
|
|
25
27
|
/**
|
|
26
|
-
* Run the
|
|
28
|
+
* Run the integration daemon. Returns only on a condition that makes running
|
|
27
29
|
* pointless — another daemon already holding this home's lock — or when
|
|
28
30
|
* `signal` aborts (tests).
|
|
29
31
|
*/
|
|
30
|
-
declare function
|
|
32
|
+
declare function runIntegration(opts: RunIntegrationOpts): Promise<number>;
|
|
31
33
|
|
|
32
34
|
interface DaemonConfig {
|
|
33
35
|
apiKey: string;
|
|
34
36
|
handle: string;
|
|
35
37
|
apiBase: string;
|
|
36
|
-
|
|
38
|
+
/** `wss://api.agentchat.me` — the SDK's socket base; it appends `/v1/ws`. */
|
|
39
|
+
wsBase: string;
|
|
37
40
|
/** The identity home. Credentials, leader lock, and heartbeat all live here. */
|
|
38
41
|
home: string;
|
|
39
|
-
/** Scratch dir for the
|
|
42
|
+
/** Scratch dir for runs (the headless run's cwd). */
|
|
40
43
|
workdir: string;
|
|
41
44
|
}
|
|
42
|
-
/** `https://api.agentchat.me` → `wss://api.agentchat.me
|
|
45
|
+
/** `https://api.agentchat.me` → `wss://api.agentchat.me`. */
|
|
46
|
+
declare function wsBaseFor(apiBase: string): string;
|
|
47
|
+
/** `https://api.agentchat.me` → `wss://api.agentchat.me/v1/ws`, for logs and checks. */
|
|
43
48
|
declare function wsUrlFor(apiBase: string): string;
|
|
44
49
|
interface ResolveDaemonOpts {
|
|
45
50
|
/** THE identity home. Required — this module never derives one. */
|
|
46
51
|
home: string;
|
|
47
|
-
workdir
|
|
52
|
+
/** The run workdir. Required — this module never derives one either. */
|
|
53
|
+
workdir: string;
|
|
54
|
+
/** How to identify to the server when the handle has to be asked for. */
|
|
55
|
+
client: IntegrationClient;
|
|
48
56
|
}
|
|
49
57
|
/**
|
|
50
58
|
* Resolve the identity the daemon runs as.
|
|
51
59
|
*
|
|
52
60
|
* Async because the handle is load-bearing at runtime — it filters this agent's
|
|
53
|
-
* own outbound echoed back by server fan-out
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* blind and replying to ourselves.
|
|
61
|
+
* own outbound echoed back by server fan-out. An env-only identity
|
|
62
|
+
* (`AGENTCHAT_API_KEY`, no credentials file) has no handle on disk, so we ask
|
|
63
|
+
* the server rather than starting up blind and waking on ourselves.
|
|
57
64
|
*/
|
|
58
65
|
declare function resolveDaemonConfig(opts: ResolveDaemonOpts): Promise<DaemonConfig>;
|
|
59
66
|
|
|
60
|
-
interface
|
|
67
|
+
interface MessageWake {
|
|
61
68
|
readonly source: 'message';
|
|
62
69
|
readonly sender: string | null;
|
|
63
70
|
readonly conversationId: string | null;
|
|
64
71
|
readonly messageId: string | null;
|
|
65
72
|
}
|
|
66
|
-
|
|
67
|
-
interface
|
|
73
|
+
/** A `wake` frame: a deferred conversation's reminder came due. */
|
|
74
|
+
interface ReminderWake {
|
|
75
|
+
readonly source: 'reminder';
|
|
76
|
+
readonly conversationId: string;
|
|
77
|
+
readonly anchorMessageId: string;
|
|
78
|
+
readonly step: number;
|
|
79
|
+
}
|
|
80
|
+
type Wake = MessageWake | ReminderWake;
|
|
81
|
+
interface InviteWake {
|
|
68
82
|
readonly inviteId: string;
|
|
69
83
|
readonly groupId: string | null;
|
|
70
84
|
readonly groupName: string | null;
|
|
71
85
|
readonly inviterHandle: string | null;
|
|
72
86
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
*/
|
|
78
|
-
type TerminalReason = 'auth' | 'cap';
|
|
79
|
-
interface DoorbellSocketEvents {
|
|
80
|
-
knock: (knock: Knock) => void;
|
|
81
|
-
invite: (invite: InviteKnock) => void;
|
|
82
|
-
/** This agent's own outbound, echoed back by server fan-out. Not a knock. */
|
|
87
|
+
interface IntegrationConnectionEvents {
|
|
88
|
+
wake: (wake: Wake) => void;
|
|
89
|
+
invite: (invite: InviteWake) => void;
|
|
90
|
+
/** This agent's own outbound, echoed back by server fan-out. Not a wake. */
|
|
83
91
|
echo: () => void;
|
|
84
92
|
state: (state: SocketState, previous: SocketState) => void;
|
|
93
|
+
/** `hello.ok` arrived: the connection is live. Once per (re)connection, after `state` → `ready`. */
|
|
94
|
+
ready: () => void;
|
|
85
95
|
/**
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
96
|
+
* The server refused the credential on the hello (the SDK is `blocked`,
|
|
97
|
+
* and so is `state`). Once per rejected attempt — the first one in a
|
|
98
|
+
* run and every 10–15 minutes after it, until a hello is accepted and
|
|
99
|
+
* `state` → `ready` lifts it. `detail` is the line `status` shows as the
|
|
100
|
+
* last error.
|
|
89
101
|
*/
|
|
90
|
-
|
|
91
|
-
/** The server answered the capability negotiation. */
|
|
92
|
-
ack: (negotiated: boolean) => void;
|
|
93
|
-
/** The socket gave up and stays stopped. The holder decides what happens next. */
|
|
94
|
-
terminal: (reason: TerminalReason, detail: string) => void;
|
|
102
|
+
blocked: (detail: string, info: BlockedInfo) => void;
|
|
95
103
|
}
|
|
96
|
-
interface
|
|
97
|
-
readonly url: string;
|
|
104
|
+
interface IntegrationConnectionOptions {
|
|
98
105
|
readonly apiKey: string;
|
|
106
|
+
/** `wss://api.agentchat.me` — the SDK appends `/v1/ws`. */
|
|
107
|
+
readonly wsBase: string;
|
|
99
108
|
/** This agent's handle, to recognise its own echo. Bare, any case. */
|
|
100
109
|
readonly selfHandle: string;
|
|
110
|
+
readonly client: IntegrationClient;
|
|
111
|
+
/** Test seams for the SDK's backoff; its defaults (500 ms → 30 s) otherwise. */
|
|
112
|
+
readonly reconnectIntervalMs?: number;
|
|
113
|
+
readonly maxReconnectIntervalMs?: number;
|
|
101
114
|
}
|
|
102
|
-
|
|
115
|
+
/**
|
|
116
|
+
* The SDK's connection state in the status file's vocabulary. Pure. `previous`
|
|
117
|
+
* is the status word in effect, which decides two things the SDK's state alone
|
|
118
|
+
* does not say: a `connecting` after a close is `reconnecting`, and the slow
|
|
119
|
+
* retry out of `blocked` (`connecting` again) stays `blocked` — only an
|
|
120
|
+
* accepted hello (`ready`) lifts it. `stopped` is `closed` from any state; a
|
|
121
|
+
* refusal stays visible as the last error, not as the socket word.
|
|
122
|
+
*/
|
|
123
|
+
declare function socketStateOf(next: RealtimeState, previous: SocketState): SocketState;
|
|
124
|
+
declare class IntegrationConnection extends EventEmitter {
|
|
103
125
|
private readonly options;
|
|
104
|
-
private
|
|
126
|
+
private rt;
|
|
105
127
|
private _state;
|
|
106
|
-
private attempt;
|
|
107
|
-
private reconnectTimer;
|
|
108
|
-
private livenessTimer;
|
|
109
128
|
private stopped;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
private helloOk;
|
|
129
|
+
/** Rejected hellos since the last accepted one: the first is an error line, the rest are info. */
|
|
130
|
+
private refusals;
|
|
113
131
|
private readonly selfHandle;
|
|
114
|
-
constructor(options:
|
|
132
|
+
constructor(options: IntegrationConnectionOptions);
|
|
115
133
|
get state(): SocketState;
|
|
116
134
|
/** True only while the socket is live — `hello.ok` received, not merely open. */
|
|
117
135
|
get connected(): boolean;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
on<E extends keyof DoorbellSocketEvents>(event: E, listener: DoorbellSocketEvents[E]): this;
|
|
136
|
+
on<E extends keyof IntegrationConnectionEvents>(event: E, listener: IntegrationConnectionEvents[E]): this;
|
|
137
|
+
/** Open the SDK's client. Once: it lives until `stop()`, reconnecting on its own. */
|
|
121
138
|
start(): void;
|
|
139
|
+
/** End the SDK's client. Final: a stopped connection is not restarted. */
|
|
122
140
|
stop(): void;
|
|
123
141
|
private setState;
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
private onHelloOk;
|
|
142
|
+
/** The SDK is `blocked`: the server refused the credential on the hello. Fires per rejected attempt. */
|
|
143
|
+
private onBlocked;
|
|
127
144
|
/**
|
|
128
145
|
* A `message.new` frame. Only the sender (echo filter) and the ids (log
|
|
129
|
-
* line) are read. `content`, `metadata`, previews — never touched.
|
|
146
|
+
* line) are read. `content`, `metadata`, previews — never touched. The SDK
|
|
147
|
+
* acked it before this ran.
|
|
130
148
|
*/
|
|
131
149
|
private onMessageFrame;
|
|
150
|
+
/** A `wake` frame, validated by the SDK. No message, nothing to ack. */
|
|
151
|
+
private onWakeFrame;
|
|
132
152
|
private onInviteFrame;
|
|
133
|
-
/** Give up. The socket stays stopped; the holder decides what happens next. */
|
|
134
|
-
private enterTerminal;
|
|
135
|
-
private scheduleReconnect;
|
|
136
|
-
private armLiveness;
|
|
137
|
-
private clearTimers;
|
|
138
153
|
}
|
|
139
154
|
|
|
140
|
-
interface
|
|
155
|
+
interface IntegrationOptions {
|
|
141
156
|
readonly cfg: DaemonConfig;
|
|
142
157
|
readonly runner: RunRunner;
|
|
143
|
-
|
|
158
|
+
/** How this integration names itself to the server (texts runtime + its version). */
|
|
159
|
+
readonly client: IntegrationClient;
|
|
160
|
+
/** The one pointer line a run prompt ends with (`manualPointer(...)`). */
|
|
161
|
+
readonly manualPointer: string;
|
|
144
162
|
readonly profile: RunProfile;
|
|
145
163
|
readonly budgetMs: number;
|
|
146
|
-
/** Injectable for tests; defaults to a real socket. */
|
|
147
|
-
readonly
|
|
148
|
-
/**
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
* class does not end the process.
|
|
153
|
-
*/
|
|
154
|
-
readonly onTerminal?: (reason: TerminalReason, detail: string) => void;
|
|
164
|
+
/** Injectable for tests; defaults to a real connection on the SDK socket. */
|
|
165
|
+
readonly connection?: IntegrationConnection;
|
|
166
|
+
/** Injectable for tests; defaults to an SDK client for `cfg`. */
|
|
167
|
+
readonly api?: AgentChatClient;
|
|
168
|
+
/** Injectable for tests; defaults to a store on `api` and the identity home. */
|
|
169
|
+
readonly texts?: TextsStore;
|
|
155
170
|
}
|
|
156
|
-
declare class
|
|
171
|
+
declare class Integration {
|
|
157
172
|
private readonly options;
|
|
158
|
-
private readonly
|
|
173
|
+
private readonly api;
|
|
174
|
+
private readonly connection;
|
|
175
|
+
private readonly texts;
|
|
159
176
|
private readonly invoker;
|
|
160
177
|
private heartbeatTimer;
|
|
161
178
|
private statusTimer;
|
|
162
179
|
private lastError;
|
|
163
180
|
private stopping;
|
|
164
|
-
constructor(options:
|
|
181
|
+
constructor(options: IntegrationOptions);
|
|
165
182
|
start(): Promise<void>;
|
|
166
183
|
/**
|
|
167
184
|
* Stop holding the socket and interrupt a run in flight (its process group
|
|
@@ -178,78 +195,64 @@ declare class Doorbell {
|
|
|
178
195
|
stopAndWait(graceMs: number): Promise<boolean>;
|
|
179
196
|
/** A run in flight finishes on its own; this resolves when it has. */
|
|
180
197
|
settled(): Promise<void>;
|
|
181
|
-
snapshot():
|
|
198
|
+
snapshot(): IntegrationStatus;
|
|
199
|
+
/** The served texts plus the pointer line, or null while no text is in hand. */
|
|
200
|
+
private runPrompts;
|
|
182
201
|
/**
|
|
183
|
-
* The connect-time catch-up: one
|
|
202
|
+
* The connect-time catch-up: one wake (the invoker counts the tray before
|
|
184
203
|
* any run, so an empty tray costs a count, not a run) and the pending invites.
|
|
185
204
|
*/
|
|
186
205
|
private catchUp;
|
|
187
206
|
private writeStatus;
|
|
188
207
|
}
|
|
189
208
|
|
|
190
|
-
declare const
|
|
191
|
-
|
|
192
|
-
interface
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
|
|
197
|
-
readonly setTimeout?: (fn: () => void, ms: number) => TimerHandle;
|
|
198
|
-
readonly clearTimeout?: (handle: TimerHandle) => void;
|
|
209
|
+
declare const OFFERED_INVITES_FILE = "invites.offered.json";
|
|
210
|
+
/** The seam the invoker uses; `OfferedInvites` is the on-disk implementation. */
|
|
211
|
+
interface OfferedInviteStore {
|
|
212
|
+
has(inviteId: string): boolean;
|
|
213
|
+
add(inviteId: string): void;
|
|
214
|
+
/** Forget an offer: the run recorded at start turned out never to have got going. */
|
|
215
|
+
remove(inviteId: string): void;
|
|
199
216
|
}
|
|
200
|
-
declare
|
|
201
|
-
|
|
202
|
-
private readonly
|
|
217
|
+
declare function offeredInvitesPath(home: string): string;
|
|
218
|
+
declare class OfferedInvites implements OfferedInviteStore {
|
|
219
|
+
private readonly home;
|
|
203
220
|
private readonly now;
|
|
204
|
-
private readonly
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
get delayedPending(): boolean;
|
|
218
|
-
/** Epoch ms of the pending retry knock, or null. */
|
|
219
|
-
get delayedDue(): number | null;
|
|
220
|
-
/** A knock: arm the timer if none is armed; otherwise absorb. */
|
|
221
|
-
knock(): void;
|
|
222
|
-
/** A delayed knock (retry ladder). The sooner pending deadline is kept. */
|
|
223
|
-
knockAfter(delayMs: number): void;
|
|
224
|
-
/**
|
|
225
|
-
* Drop a pending retry knock, if there is one; returns whether there was.
|
|
226
|
-
* The debounce timer and later knocks are unaffected. For when nothing is
|
|
227
|
-
* owed any more — a run read the whole tray, or the tray was found empty —
|
|
228
|
-
* so the retry would only ring for a backlog that is already handled.
|
|
229
|
-
*/
|
|
230
|
-
cancelDelayed(): boolean;
|
|
231
|
-
/** Cancel everything; later knocks are ignored. */
|
|
232
|
-
stop(): void;
|
|
233
|
-
private fire;
|
|
221
|
+
private readonly entries;
|
|
222
|
+
/** `home === null` keeps the set in memory only (tests). */
|
|
223
|
+
constructor(home: string | null, entries?: Array<{
|
|
224
|
+
id: string;
|
|
225
|
+
at: string;
|
|
226
|
+
}>, now?: () => Date);
|
|
227
|
+
/** Read the set from the identity home; a missing or malformed file is an empty set. */
|
|
228
|
+
static load(home: string, now?: () => Date): OfferedInvites;
|
|
229
|
+
get size(): number;
|
|
230
|
+
has(inviteId: string): boolean;
|
|
231
|
+
add(inviteId: string): void;
|
|
232
|
+
remove(inviteId: string): void;
|
|
233
|
+
private persist;
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
declare const RETRY_LADDER_MS: readonly number[];
|
|
237
237
|
/** After the ladder is exhausted: how often the runtime is asked whether it is usable again. */
|
|
238
238
|
declare const PREFLIGHT_WATCH_MS: number;
|
|
239
|
-
interface
|
|
239
|
+
interface IntegrationInvokerOptions {
|
|
240
240
|
readonly runner: RunRunner;
|
|
241
|
-
|
|
241
|
+
/** The run prompts, resolved per run; null when the served texts are not available yet. */
|
|
242
|
+
readonly prompts: () => Promise<RunPrompts | null>;
|
|
242
243
|
/** A run is killed past this and counts as failed. */
|
|
243
244
|
readonly budgetMs: number;
|
|
244
245
|
readonly debounceMs?: number;
|
|
245
246
|
readonly retryLadderMs?: readonly number[];
|
|
246
247
|
readonly preflightWatchMs?: number;
|
|
247
248
|
/**
|
|
248
|
-
* Is anything waiting on the tray? Asked before every
|
|
249
|
+
* Is anything waiting on the tray? Asked before every wake run (never
|
|
249
250
|
* before an invite run). Resolves the answer; rejects when the count could
|
|
250
|
-
* not be read, and then the run starts anyway. Absent: every
|
|
251
|
+
* not be read, and then the run starts anyway. Absent: every wake runs.
|
|
251
252
|
*/
|
|
252
253
|
readonly trayHasWaiting?: () => Promise<boolean>;
|
|
254
|
+
/** Invites already offered to a run from this machine. Defaults to an in-memory set. */
|
|
255
|
+
readonly offeredInvites?: OfferedInviteStore;
|
|
253
256
|
/** Called after every state change (a status writer hangs off this). */
|
|
254
257
|
readonly onChange?: () => void;
|
|
255
258
|
readonly now?: () => number;
|
|
@@ -258,7 +261,7 @@ interface DoorbellInvokerOptions {
|
|
|
258
261
|
readonly runId?: () => string;
|
|
259
262
|
}
|
|
260
263
|
interface InvokerCounters {
|
|
261
|
-
readonly
|
|
264
|
+
readonly wakes: number;
|
|
262
265
|
readonly absorbed: number;
|
|
263
266
|
readonly invites: number;
|
|
264
267
|
readonly runsStarted: number;
|
|
@@ -266,14 +269,14 @@ interface InvokerCounters {
|
|
|
266
269
|
readonly runsFailed: number;
|
|
267
270
|
readonly runsTimedOut: number;
|
|
268
271
|
readonly runsNotStarted: number;
|
|
269
|
-
/**
|
|
272
|
+
/** Wake cycles that found the tray empty and started no run. */
|
|
270
273
|
readonly runsSkippedEmpty: number;
|
|
271
274
|
readonly retryRung: number;
|
|
272
275
|
readonly retryDueAt: number | null;
|
|
273
|
-
readonly lastRun:
|
|
276
|
+
readonly lastRun: IntegrationLastRun | null;
|
|
274
277
|
readonly running: boolean;
|
|
275
278
|
}
|
|
276
|
-
declare class
|
|
279
|
+
declare class IntegrationInvoker {
|
|
277
280
|
private readonly runner;
|
|
278
281
|
private readonly prompts;
|
|
279
282
|
private readonly budgetMs;
|
|
@@ -285,13 +288,23 @@ declare class DoorbellInvoker {
|
|
|
285
288
|
private readonly onChange;
|
|
286
289
|
private readonly newRunId;
|
|
287
290
|
private readonly trayHasWaiting;
|
|
291
|
+
private readonly offered;
|
|
288
292
|
private readonly coalescer;
|
|
289
293
|
private cycleDue;
|
|
290
294
|
private running;
|
|
291
295
|
private inFlight;
|
|
292
296
|
private stopped;
|
|
297
|
+
/** Invites queued for a run, in arrival order. */
|
|
293
298
|
private readonly invites;
|
|
294
|
-
|
|
299
|
+
/** Invites whose run did not start; offered again on the next wake. */
|
|
300
|
+
private readonly invitesAwaitingRetry;
|
|
301
|
+
/**
|
|
302
|
+
* Invite ids this process has taken, offered or not. The on-disk store says
|
|
303
|
+
* what was OFFERED; this says what is already in hand here — queued, in
|
|
304
|
+
* flight, or awaiting its retry — so the connect-time listing and a live
|
|
305
|
+
* frame for the same invite cannot queue it twice.
|
|
306
|
+
*/
|
|
307
|
+
private readonly taken;
|
|
295
308
|
private retryRung;
|
|
296
309
|
private preflightWatch;
|
|
297
310
|
private preflightWasDown;
|
|
@@ -303,14 +316,15 @@ declare class DoorbellInvoker {
|
|
|
303
316
|
private runsNotStarted;
|
|
304
317
|
private runsSkippedEmpty;
|
|
305
318
|
private lastRun;
|
|
306
|
-
constructor(options:
|
|
307
|
-
/** A
|
|
308
|
-
|
|
319
|
+
constructor(options: IntegrationInvokerOptions);
|
|
320
|
+
/** A wake from the socket (a frame), the connect-time catch-up, or any other source. Coalesced, then run. */
|
|
321
|
+
wake(source: string): void;
|
|
309
322
|
/**
|
|
310
|
-
* The second
|
|
311
|
-
*
|
|
323
|
+
* The second wake kind. Offered once per machine: an invite already offered
|
|
324
|
+
* to a run, already queued, or awaiting its retry is not queued again.
|
|
325
|
+
* Returns true when newly queued.
|
|
312
326
|
*/
|
|
313
|
-
invite(invite:
|
|
327
|
+
invite(invite: InviteWake): boolean;
|
|
314
328
|
/**
|
|
315
329
|
* Cancel timers and interrupt a run in flight (its signal aborts; the
|
|
316
330
|
* runner SIGTERMs the run's process group). `settled()` resolves when the
|
|
@@ -320,23 +334,32 @@ declare class DoorbellInvoker {
|
|
|
320
334
|
/** The promise of the work currently running, for tests and graceful stops. */
|
|
321
335
|
settled(): Promise<void>;
|
|
322
336
|
counters(): InvokerCounters;
|
|
323
|
-
private
|
|
337
|
+
private onWakeFired;
|
|
324
338
|
/** Run the worker if idle. One run at a time; work that lands mid-run runs afterwards. */
|
|
325
339
|
private schedule;
|
|
326
340
|
private drain;
|
|
327
341
|
/**
|
|
328
|
-
* The count before a
|
|
342
|
+
* The count before a wake run. True: start the run (something waits, or
|
|
329
343
|
* the count could not be read). False: the tray is empty — no run, nothing
|
|
330
344
|
* owed — or the invoker stopped while counting.
|
|
331
345
|
*/
|
|
332
346
|
private trayOwesRun;
|
|
333
347
|
/**
|
|
334
|
-
* Nothing is owed any more — a
|
|
335
|
-
* found it empty: back to the first rung, drop a pending re-
|
|
348
|
+
* Nothing is owed any more — a wake run read the whole tray, or a count
|
|
349
|
+
* found it empty: back to the first rung, drop a pending re-wake (it would
|
|
336
350
|
* only ring for a backlog that is already handled), end the preflight watch.
|
|
337
351
|
*/
|
|
338
352
|
private settleLadder;
|
|
339
353
|
private run;
|
|
354
|
+
/**
|
|
355
|
+
* An invite counts as offered once its run has started (recorded at
|
|
356
|
+
* `onStarted`; a runner that never signals it is recorded here, when the
|
|
357
|
+
* run ends): the agent had its chance, and the invite stays reachable
|
|
358
|
+
* through the hosted invite tools in any later run — including a run this
|
|
359
|
+
* integration interrupted. A run that never got going is no offer: the
|
|
360
|
+
* record is taken back and the invite is held for the next wake.
|
|
361
|
+
*/
|
|
362
|
+
private settleInvite;
|
|
340
363
|
private scheduleRetry;
|
|
341
364
|
private armPreflightWatch;
|
|
342
365
|
private clearPreflightWatch;
|
|
@@ -359,10 +382,12 @@ interface SpawnRunSpec {
|
|
|
359
382
|
* the outcome is `failed` with an "interrupted" detail.
|
|
360
383
|
*/
|
|
361
384
|
readonly signal?: AbortSignal;
|
|
385
|
+
/** Called once when the child process has been spawned (`RunRequest.onStarted`). */
|
|
386
|
+
readonly onStarted?: () => void;
|
|
362
387
|
}
|
|
363
388
|
/** Strip anything key-shaped or terminal-styled from a diagnostic, and bound it. */
|
|
364
389
|
declare function redactDiagnostic(value: string, max?: number): string;
|
|
365
390
|
/** Start the command, wait for it, classify. Never throws. */
|
|
366
391
|
declare function spawnRun(spec: SpawnRunSpec): Promise<RunOutcome>;
|
|
367
392
|
|
|
368
|
-
export {
|
|
393
|
+
export { type DaemonConfig, Integration, IntegrationConnection, type IntegrationConnectionEvents, type IntegrationConnectionOptions, IntegrationInvoker, type IntegrationInvokerOptions, type IntegrationOptions, type InviteWake, type InvokerCounters, type MessageWake, OFFERED_INVITES_FILE, type OfferedInviteStore, OfferedInvites, PREFLIGHT_WATCH_MS, RETRY_LADDER_MS, type ReminderWake, type ResolveDaemonOpts, type RunIntegrationOpts, RunOutcome, RunRunner, type SpawnRunSpec, type Wake, offeredInvitesPath, redactDiagnostic, resolveDaemonConfig, runIntegration, socketStateOf, spawnRun, wsBaseFor, wsUrlFor };
|