@agentchatme/agent-core 0.0.1311 → 0.0.1313
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 +16 -1
- package/dist/{chunk-ER4AFPH7.js → chunk-27XDHOL3.js} +103 -2
- package/dist/chunk-27XDHOL3.js.map +1 -0
- package/dist/daemon-entry.d.ts +96 -6
- package/dist/daemon-entry.js +507 -69
- package/dist/daemon-entry.js.map +1 -1
- package/dist/index.d.ts +36 -6
- package/dist/index.js +193 -87
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-ER4AFPH7.js.map +0 -1
package/dist/daemon-entry.d.ts
CHANGED
|
@@ -7,8 +7,11 @@ declare const SyncRowSchema: z.ZodObject<{
|
|
|
7
7
|
delivery_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
8
8
|
sender: z.ZodOptional<z.ZodString>;
|
|
9
9
|
sender_handle: z.ZodOptional<z.ZodString>;
|
|
10
|
+
seq: z.ZodOptional<z.ZodNumber>;
|
|
10
11
|
type: z.ZodOptional<z.ZodString>;
|
|
11
12
|
content: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
13
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
14
|
+
status: z.ZodOptional<z.ZodString>;
|
|
12
15
|
created_at: z.ZodOptional<z.ZodString>;
|
|
13
16
|
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
14
17
|
id: z.ZodString;
|
|
@@ -16,8 +19,11 @@ declare const SyncRowSchema: z.ZodObject<{
|
|
|
16
19
|
delivery_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
17
20
|
sender: z.ZodOptional<z.ZodString>;
|
|
18
21
|
sender_handle: z.ZodOptional<z.ZodString>;
|
|
22
|
+
seq: z.ZodOptional<z.ZodNumber>;
|
|
19
23
|
type: z.ZodOptional<z.ZodString>;
|
|
20
24
|
content: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
25
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
26
|
+
status: z.ZodOptional<z.ZodString>;
|
|
21
27
|
created_at: z.ZodOptional<z.ZodString>;
|
|
22
28
|
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
23
29
|
id: z.ZodString;
|
|
@@ -25,8 +31,11 @@ declare const SyncRowSchema: z.ZodObject<{
|
|
|
25
31
|
delivery_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
26
32
|
sender: z.ZodOptional<z.ZodString>;
|
|
27
33
|
sender_handle: z.ZodOptional<z.ZodString>;
|
|
34
|
+
seq: z.ZodOptional<z.ZodNumber>;
|
|
28
35
|
type: z.ZodOptional<z.ZodString>;
|
|
29
36
|
content: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
37
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
38
|
+
status: z.ZodOptional<z.ZodString>;
|
|
30
39
|
created_at: z.ZodOptional<z.ZodString>;
|
|
31
40
|
}, z.ZodTypeAny, "passthrough">>;
|
|
32
41
|
type SyncRow = z.infer<typeof SyncRowSchema>;
|
|
@@ -47,8 +56,12 @@ declare class AgentWsClient extends EventEmitter {
|
|
|
47
56
|
private attempt;
|
|
48
57
|
private reconnectTimer;
|
|
49
58
|
private livenessTimer;
|
|
59
|
+
private ackRetryTimer;
|
|
50
60
|
private stopped;
|
|
51
61
|
private ackMode;
|
|
62
|
+
private inboundPaused;
|
|
63
|
+
private readonly pendingAcks;
|
|
64
|
+
private readonly acksInFlight;
|
|
52
65
|
constructor(url: string, apiKey: string);
|
|
53
66
|
/** True only while the socket is live and ready. The heartbeat writer keys
|
|
54
67
|
* off this, so a reconnecting/terminal daemon lets its heartbeat go stale
|
|
@@ -56,6 +69,14 @@ declare class AgentWsClient extends EventEmitter {
|
|
|
56
69
|
get connected(): boolean;
|
|
57
70
|
start(): void;
|
|
58
71
|
stop(): void;
|
|
72
|
+
/**
|
|
73
|
+
* Apply TCP backpressure while the model-turn queue is saturated. `ws`
|
|
74
|
+
* delegates this to the underlying socket; no delivered frame is discarded.
|
|
75
|
+
* A server heartbeat may close a very long pause, which is safe because all
|
|
76
|
+
* unacked messages re-drain after reconnect.
|
|
77
|
+
*/
|
|
78
|
+
pauseInbound(): void;
|
|
79
|
+
resumeInbound(): void;
|
|
59
80
|
getState(): State;
|
|
60
81
|
/**
|
|
61
82
|
* Confirm a message as handled: `{"type":"ack","message_id":"msg_..."}`.
|
|
@@ -65,6 +86,8 @@ declare class AgentWsClient extends EventEmitter {
|
|
|
65
86
|
* real-time push — which carries no delivery_id — be acked at all.
|
|
66
87
|
*/
|
|
67
88
|
ack(messageId: string): void;
|
|
89
|
+
private flushAcks;
|
|
90
|
+
private scheduleAckRetry;
|
|
68
91
|
private open;
|
|
69
92
|
private scheduleReconnect;
|
|
70
93
|
private armLiveness;
|
|
@@ -91,9 +114,43 @@ declare class ReplyCoord {
|
|
|
91
114
|
* → TRUE (reply anyway rather than drop).
|
|
92
115
|
*/
|
|
93
116
|
claim(messageId: string): Promise<boolean>;
|
|
117
|
+
/**
|
|
118
|
+
* Claim the contiguous oldest-first prefix of one conversation batch.
|
|
119
|
+
* Falls back to ordered single-message claims against an older API server;
|
|
120
|
+
* all other coordination failures remain fail-open.
|
|
121
|
+
*/
|
|
122
|
+
claimBatch(messageIds: string[]): Promise<number>;
|
|
94
123
|
}
|
|
95
124
|
|
|
125
|
+
interface TurnMentionContext {
|
|
126
|
+
messageId: string;
|
|
127
|
+
messageSeq?: number | undefined;
|
|
128
|
+
sender: string;
|
|
129
|
+
senderDisplayName?: string | null | undefined;
|
|
130
|
+
senderKind?: 'agent' | 'system' | undefined;
|
|
131
|
+
createdAt?: string | undefined;
|
|
132
|
+
replyToMessageId?: string | null | undefined;
|
|
133
|
+
/** Bounded notification preview. Full content comes from the anchored
|
|
134
|
+
* conversation read requested by the turn prompt. */
|
|
135
|
+
textPreview: string;
|
|
136
|
+
}
|
|
137
|
+
interface TurnBatchContext {
|
|
138
|
+
/** Number of durable deliveries represented by this one runtime turn. */
|
|
139
|
+
count: number;
|
|
140
|
+
/** Exact oldest-first delivery ids in the frozen batch. */
|
|
141
|
+
messageIds: string[];
|
|
142
|
+
oldestMessageId: string;
|
|
143
|
+
oldestMessageSeq?: number | undefined;
|
|
144
|
+
newestMessageId: string;
|
|
145
|
+
newestMessageSeq?: number | undefined;
|
|
146
|
+
/** Group messages in this batch that explicitly @mentioned this agent. */
|
|
147
|
+
mentionedMessages: TurnMentionContext[];
|
|
148
|
+
}
|
|
96
149
|
interface TurnContext {
|
|
150
|
+
/** Trusted server message id that caused this autonomous turn. */
|
|
151
|
+
messageId?: string | undefined;
|
|
152
|
+
/** Monotonic sequence number inside the AgentChat conversation. */
|
|
153
|
+
messageSeq?: number | undefined;
|
|
97
154
|
/** The AgentChat conversation the message belongs to. */
|
|
98
155
|
conversationId: string;
|
|
99
156
|
/** @handle of the sender. */
|
|
@@ -114,10 +171,19 @@ interface TurnContext {
|
|
|
114
171
|
senderKind?: 'agent' | 'system' | undefined;
|
|
115
172
|
/** Group's human-readable name (null for DMs / when the server omitted it). */
|
|
116
173
|
groupName?: string | null | undefined;
|
|
174
|
+
/** Current group size when the delivery carried it. */
|
|
175
|
+
memberCount?: number | null | undefined;
|
|
176
|
+
/** Sender-authored reply-parent id, when this message is a threaded reply. */
|
|
177
|
+
replyToMessageId?: string | null | undefined;
|
|
178
|
+
/** Recipient-scoped delivery/read state from the server envelope. */
|
|
179
|
+
deliveryStatus?: string | undefined;
|
|
117
180
|
/** True when THIS agent's handle is in the server-parsed mention list. The
|
|
118
181
|
* daemon computes membership (it knows its own handle) so the adapter just
|
|
119
182
|
* renders the positive fact. */
|
|
120
183
|
mentioned?: boolean | undefined;
|
|
184
|
+
/** Frozen same-conversation backlog represented by this turn. The ordinary
|
|
185
|
+
* top-level message fields always describe its newest/focus message. */
|
|
186
|
+
pendingBatch?: TurnBatchContext | undefined;
|
|
121
187
|
}
|
|
122
188
|
interface TurnResult {
|
|
123
189
|
ok: boolean;
|
|
@@ -127,6 +193,13 @@ interface TurnResult {
|
|
|
127
193
|
}
|
|
128
194
|
interface RuntimeAdapter {
|
|
129
195
|
readonly name: string;
|
|
196
|
+
/**
|
|
197
|
+
* Reset conversation continuity when the authenticated AgentChat identity
|
|
198
|
+
* changes. `identityNamespace` contains no credential material; callers use
|
|
199
|
+
* the authenticated API base + handle. Adapters that persist host sessions
|
|
200
|
+
* must include it in their session key, not merely clear an in-memory map.
|
|
201
|
+
*/
|
|
202
|
+
reset?(identityNamespace: string): void;
|
|
130
203
|
/** Verify the runtime is usable (binary present, logged in). */
|
|
131
204
|
preflight(): Promise<{
|
|
132
205
|
ok: boolean;
|
|
@@ -143,6 +216,10 @@ declare function describeConversation(ctx: TurnContext): string;
|
|
|
143
216
|
/** Resolved sender identity: "Display Name (@handle)" or "@handle", flagging a
|
|
144
217
|
* system agent so the model weights its words as platform-authored. */
|
|
145
218
|
declare function describeSender(ctx: TurnContext): string;
|
|
219
|
+
/** One canonical unattended-delivery prompt for every coding-agent host.
|
|
220
|
+
* Host adapters only decide how to launch/resume their runtime; AgentChat's
|
|
221
|
+
* message framing and agent-facing context contract must not drift. */
|
|
222
|
+
declare function buildAgentChatTurnPrompt(ctx: TurnContext): string;
|
|
146
223
|
|
|
147
224
|
interface RunDaemonOpts {
|
|
148
225
|
/** THE identity home for the agent this daemon serves. */
|
|
@@ -186,6 +263,10 @@ interface ResolveDaemonOpts {
|
|
|
186
263
|
*/
|
|
187
264
|
declare function resolveDaemonConfig(opts: ResolveDaemonOpts): Promise<DaemonConfig>;
|
|
188
265
|
|
|
266
|
+
interface DaemonFailure {
|
|
267
|
+
kind: 'socket-auth' | 'runtime';
|
|
268
|
+
reason: string;
|
|
269
|
+
}
|
|
189
270
|
declare class Daemon {
|
|
190
271
|
private readonly cfg;
|
|
191
272
|
private readonly adapter;
|
|
@@ -195,7 +276,9 @@ declare class Daemon {
|
|
|
195
276
|
private readonly ws;
|
|
196
277
|
private readonly coord;
|
|
197
278
|
private readonly seen;
|
|
198
|
-
private readonly
|
|
279
|
+
private readonly convQueues;
|
|
280
|
+
private readonly convWorkers;
|
|
281
|
+
private pending;
|
|
199
282
|
private inFlight;
|
|
200
283
|
private readonly waiters;
|
|
201
284
|
private stopping;
|
|
@@ -203,15 +286,22 @@ declare class Daemon {
|
|
|
203
286
|
constructor(cfg: DaemonConfig, adapter: RuntimeAdapter, ws?: AgentWsClient, // injectable for tests; defaults to a real socket
|
|
204
287
|
/** Called when the socket gives up for good (auth refused). The supervisor
|
|
205
288
|
* above decides what happens next — this class does not end the process. */
|
|
206
|
-
onTerminal?: ((
|
|
289
|
+
onTerminal?: ((failure: DaemonFailure) => void) | undefined);
|
|
207
290
|
start(): Promise<void>;
|
|
208
291
|
stop(): void;
|
|
209
292
|
private onInbound;
|
|
210
|
-
/**
|
|
211
|
-
private
|
|
212
|
-
|
|
293
|
+
/** Queue one already-tracked row and ensure exactly one worker for its conversation. */
|
|
294
|
+
private enqueueExisting;
|
|
295
|
+
/** Process bounded backlog snapshots, in arrival order within a conversation. */
|
|
296
|
+
private drainConversation;
|
|
297
|
+
private handleNextBatch;
|
|
298
|
+
private turnContext;
|
|
299
|
+
private markHandled;
|
|
300
|
+
private markNoLongerPending;
|
|
301
|
+
/** Bound reconnect-dedup memory without ever evicting unfinished work. */
|
|
302
|
+
private pruneSeen;
|
|
213
303
|
private acquireSlot;
|
|
214
304
|
private releaseSlot;
|
|
215
305
|
}
|
|
216
306
|
|
|
217
|
-
export { AgentWsClient, type CoordConfig, Daemon, type DaemonConfig, ReplyCoord, type ResolveDaemonOpts, type RunDaemonOpts, type RuntimeAdapter, type TurnContext, type TurnResult, type WsClientEvents, describeConversation, describeSender, parseInbound, resolveDaemonConfig, runDaemon, senderOf, wsUrlFor };
|
|
307
|
+
export { AgentWsClient, type CoordConfig, Daemon, type DaemonConfig, ReplyCoord, type ResolveDaemonOpts, type RunDaemonOpts, type RuntimeAdapter, type TurnBatchContext, type TurnContext, type TurnMentionContext, type TurnResult, type WsClientEvents, buildAgentChatTurnPrompt, describeConversation, describeSender, parseInbound, resolveDaemonConfig, runDaemon, senderOf, wsUrlFor };
|