@ziggs-ai/api-client 0.40.1 → 0.40.3
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
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.40.3
|
|
6
|
+
|
|
7
|
+
- `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.
|
|
8
|
+
|
|
9
|
+
## 0.40.2
|
|
10
|
+
|
|
11
|
+
- 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.
|
|
12
|
+
|
|
5
13
|
## 0.40.1
|
|
6
14
|
|
|
7
15
|
- `updateTaskState` takes `charge: { amount, basis? }` with `completed`: what the task cost and what that rests on. An agreement that prices each task at completion (`taskCharge: "at_completion"`) charges it up to the agreed maximum and gives the rest of the reservation back; a fixed price ignores it. The task outcome's metering line says what was charged and why (stated, or the maximum when nothing was stated).
|
|
@@ -221,7 +221,7 @@ function chargeBasisLine(charge) {
|
|
|
221
221
|
if (!charge || charge.basis === 'fixed' || charge.basis == null)
|
|
222
222
|
return '';
|
|
223
223
|
const max = charge.maximum != null ? ` of up to ${charge.maximum}` : '';
|
|
224
|
-
if (charge.basis === '
|
|
225
|
-
return `${max}
|
|
224
|
+
if (charge.basis === 'none')
|
|
225
|
+
return `${max}: free, because no charge was stated with the completion`;
|
|
226
226
|
return `${max}, as stated${charge.note ? ` (${charge.note})` : ''}${charge.capped ? ', capped at the maximum' : ''}`;
|
|
227
227
|
}
|
|
@@ -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) {
|
|
@@ -80,8 +86,12 @@ export class InboxClient {
|
|
|
80
86
|
return JSON.parse(body);
|
|
81
87
|
}
|
|
82
88
|
async getInbox(opts = {}) {
|
|
89
|
+
const headers = this.headers();
|
|
90
|
+
if (this.session?.sharedHost && opts.capacity !== undefined) {
|
|
91
|
+
headers[INBOX_CAPACITY_HEADER] = String(Math.max(0, Math.floor(opts.capacity)));
|
|
92
|
+
}
|
|
83
93
|
const res = await fetch(this.inboxUrl('/inbox', opts), {
|
|
84
|
-
headers
|
|
94
|
+
headers,
|
|
85
95
|
...(opts.signal ? { signal: opts.signal } : {}),
|
|
86
96
|
});
|
|
87
97
|
const body = await res.text().catch(() => '');
|
|
@@ -159,7 +159,7 @@ export interface UpdateTaskStateData {
|
|
|
159
159
|
* What this task cost, stated with `completed`. Read only when the agreement
|
|
160
160
|
* prices each task at completion (`taskCharge: 'at_completion'`), where it is
|
|
161
161
|
* capped at the agreed maximum and the rest of the reservation goes back to
|
|
162
|
-
* the payer. Omitted there, the task
|
|
162
|
+
* the payer. Omitted there, the task is free.
|
|
163
163
|
*/
|
|
164
164
|
charge?: TaskChargeStatement;
|
|
165
165
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -413,6 +413,15 @@ 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;
|
|
417
426
|
/**
|
|
418
427
|
* The mailboxes this reader's view merges — its owner's, plus whatever
|