@ziggs-ai/api-client 0.40.2 → 0.40.4
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/CHANGELOG.md +8 -0
- package/dist/http/InboxClient.d.ts +13 -0
- package/dist/http/InboxClient.js +13 -1
- package/dist/types.d.ts +15 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.40.4
|
|
6
|
+
|
|
7
|
+
- `InboxEnvelope.bellAt`: the latest delivery a read answered. `getInbox({ seen })` passes it back so a held read answers only mail delivered after it.
|
|
8
|
+
|
|
9
|
+
## 0.40.3
|
|
10
|
+
|
|
11
|
+
- `InboxClient` takes `sharedHost` in its session options: it sends `X-Ziggs-Inbox-Hosts: shared`, so several processes can host one agent at once, and `getInbox({ capacity })` says how many more threads this host can start. `InboxEnvelope.host` reports whether this host leads.
|
|
12
|
+
|
|
5
13
|
## 0.40.2
|
|
6
14
|
|
|
7
15
|
- A task on an agreement priced at completion with no stated charge is free; the outcome's metering line says so. `charge` docs say the same.
|
|
@@ -4,6 +4,10 @@ import type { InboxAckResult, InboxEnvelope, InboxPeek, InboxReadOptions, InboxC
|
|
|
4
4
|
* since its last ack — never content. Flow: inbox → read → act → ack
|
|
5
5
|
*. Wraps `GET /inbox` and `POST /inbox/ack`.
|
|
6
6
|
*/
|
|
7
|
+
/** Several processes host this agent at once (value `shared`). */
|
|
8
|
+
export declare const INBOX_HOSTS_HEADER = "X-Ziggs-Inbox-Hosts";
|
|
9
|
+
/** With shared hosts: how many more threads this host can start now. */
|
|
10
|
+
export declare const INBOX_CAPACITY_HEADER = "X-Ziggs-Inbox-Capacity";
|
|
7
11
|
export declare class InboxClient {
|
|
8
12
|
private readonly operatorKey;
|
|
9
13
|
private readonly agentId?;
|
|
@@ -23,6 +27,13 @@ export declare class InboxClient {
|
|
|
23
27
|
workspaceIds?: string;
|
|
24
28
|
app?: string;
|
|
25
29
|
sessionName?: string;
|
|
30
|
+
/**
|
|
31
|
+
* This process is one of several hosting the agent at once. The server
|
|
32
|
+
* then treats a second host as a member rather than a conflict: each
|
|
33
|
+
* host takes its own threads, and the one holding the inbox lease
|
|
34
|
+
* (`envelope.host.leader`) gets the standing lists.
|
|
35
|
+
*/
|
|
36
|
+
sharedHost?: boolean;
|
|
26
37
|
});
|
|
27
38
|
private headers;
|
|
28
39
|
private inboxUrl;
|
|
@@ -35,6 +46,8 @@ export declare class InboxClient {
|
|
|
35
46
|
}): Promise<InboxEnvelope>;
|
|
36
47
|
getInbox(opts?: InboxReadOptions & {
|
|
37
48
|
signal?: AbortSignal;
|
|
49
|
+
/** Shared hosts: how many more threads this host can start now. */
|
|
50
|
+
capacity?: number;
|
|
38
51
|
}): Promise<InboxEnvelope>;
|
|
39
52
|
/**
|
|
40
53
|
* Wait for assigned mail without taking the host lease.
|
package/dist/http/InboxClient.js
CHANGED
|
@@ -7,6 +7,10 @@ import { INBOX_HOST_CLAIMANT_HEADER, hostIdentity, } from '../instanceIdentity.j
|
|
|
7
7
|
* since its last ack — never content. Flow: inbox → read → act → ack
|
|
8
8
|
*. Wraps `GET /inbox` and `POST /inbox/ack`.
|
|
9
9
|
*/
|
|
10
|
+
/** Several processes host this agent at once (value `shared`). */
|
|
11
|
+
export const INBOX_HOSTS_HEADER = 'X-Ziggs-Inbox-Hosts';
|
|
12
|
+
/** With shared hosts: how many more threads this host can start now. */
|
|
13
|
+
export const INBOX_CAPACITY_HEADER = 'X-Ziggs-Inbox-Capacity';
|
|
10
14
|
export class InboxClient {
|
|
11
15
|
operatorKey;
|
|
12
16
|
agentId;
|
|
@@ -48,6 +52,8 @@ export class InboxClient {
|
|
|
48
52
|
headers['X-Ziggs-App'] = this.session.app;
|
|
49
53
|
if (this.session?.sessionName)
|
|
50
54
|
headers['X-Ziggs-Session-Name'] = this.session.sessionName;
|
|
55
|
+
if (this.session?.sharedHost)
|
|
56
|
+
headers[INBOX_HOSTS_HEADER] = 'shared';
|
|
51
57
|
return headers;
|
|
52
58
|
}
|
|
53
59
|
inboxUrl(path, opts) {
|
|
@@ -55,6 +61,8 @@ export class InboxClient {
|
|
|
55
61
|
if (opts.waitSeconds != null && opts.waitSeconds > 0) {
|
|
56
62
|
url.searchParams.set('wait', String(opts.waitSeconds));
|
|
57
63
|
}
|
|
64
|
+
if (opts.seen)
|
|
65
|
+
url.searchParams.set('seen', opts.seen);
|
|
58
66
|
return url.toString();
|
|
59
67
|
}
|
|
60
68
|
/** At most 25 retained references per page. Keep cursor for subsequent waits;
|
|
@@ -80,8 +88,12 @@ export class InboxClient {
|
|
|
80
88
|
return JSON.parse(body);
|
|
81
89
|
}
|
|
82
90
|
async getInbox(opts = {}) {
|
|
91
|
+
const headers = this.headers();
|
|
92
|
+
if (this.session?.sharedHost && opts.capacity !== undefined) {
|
|
93
|
+
headers[INBOX_CAPACITY_HEADER] = String(Math.max(0, Math.floor(opts.capacity)));
|
|
94
|
+
}
|
|
83
95
|
const res = await fetch(this.inboxUrl('/inbox', opts), {
|
|
84
|
-
headers
|
|
96
|
+
headers,
|
|
85
97
|
...(opts.signal ? { signal: opts.signal } : {}),
|
|
86
98
|
});
|
|
87
99
|
const body = await res.text().catch(() => '');
|
package/dist/types.d.ts
CHANGED
|
@@ -413,7 +413,18 @@ export type { InboxPlanAckRef } from '@ziggs-ai/contracts';
|
|
|
413
413
|
* read them as empty.
|
|
414
414
|
*/
|
|
415
415
|
export interface InboxEnvelope extends InboxRequestChannel, Partial<InboxPlanAckChannel> {
|
|
416
|
+
/**
|
|
417
|
+
* Present when this read was made as one of several hosts of the agent
|
|
418
|
+
* (`sharedHost`). `leader` is the host holding the inbox lease: it gets the
|
|
419
|
+
* standing lists and runs the agent's polls and timers.
|
|
420
|
+
*/
|
|
421
|
+
host?: {
|
|
422
|
+
shared: true;
|
|
423
|
+
leader: boolean;
|
|
424
|
+
};
|
|
416
425
|
asOf: string;
|
|
426
|
+
/** The latest delivery this read answered; pass it back as `seen`. */
|
|
427
|
+
bellAt?: string | null;
|
|
417
428
|
/**
|
|
418
429
|
* The mailboxes this reader's view merges — its owner's, plus whatever
|
|
419
430
|
* inbox grants add. Absent on older servers.
|
|
@@ -488,6 +499,10 @@ export interface InboxAckResult {
|
|
|
488
499
|
*/
|
|
489
500
|
export interface InboxReadOptions {
|
|
490
501
|
waitSeconds?: number;
|
|
502
|
+
/** The `bellAt` of the last envelope this host read. A held read then answers
|
|
503
|
+
* only mail delivered after it, so a host still working on those rows waits
|
|
504
|
+
* for new mail instead of being handed them again. */
|
|
505
|
+
seen?: string;
|
|
491
506
|
}
|
|
492
507
|
/** Count-only peek. Does not take the inbox host lease. */
|
|
493
508
|
export interface InboxPeek {
|