@ziggs-ai/api-client 0.15.1 → 0.17.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.
Files changed (46) hide show
  1. package/dist/capabilities/agreementVerbs.d.ts +9 -0
  2. package/dist/capabilities/agreementVerbs.js +10 -1
  3. package/dist/capabilities/agreements.js +2 -1
  4. package/dist/capabilities/artifacts.js +16 -6
  5. package/dist/capabilities/connections.js +5 -5
  6. package/dist/capabilities/grants.js +8 -2
  7. package/dist/capabilities/index.d.ts +1 -0
  8. package/dist/capabilities/index.js +1 -0
  9. package/dist/capabilities/links.js +3 -3
  10. package/dist/capabilities/listedFields.d.ts +17 -0
  11. package/dist/capabilities/listedFields.js +45 -0
  12. package/dist/capabilities/marketplace.js +7 -2
  13. package/dist/capabilities/payments.js +7 -2
  14. package/dist/capabilities/tasks.js +9 -3
  15. package/dist/http/AgreementClient.js +3 -10
  16. package/dist/http/ArtifactsClient.d.ts +5 -16
  17. package/dist/http/ArtifactsClient.js +8 -5
  18. package/dist/http/ChatClient.d.ts +2 -6
  19. package/dist/http/ChatClient.js +3 -10
  20. package/dist/http/ConnectionsClient.d.ts +6 -4
  21. package/dist/http/ConnectionsClient.js +7 -5
  22. package/dist/http/ContextReadClient.js +3 -14
  23. package/dist/http/GrantsClient.d.ts +10 -1
  24. package/dist/http/GrantsClient.js +12 -2
  25. package/dist/http/IntroductionsClient.d.ts +11 -4
  26. package/dist/http/MarketplaceClient.js +3 -10
  27. package/dist/http/OrgsClient.d.ts +0 -14
  28. package/dist/http/OrgsClient.js +2 -17
  29. package/dist/http/PaymentsClient.d.ts +27 -3
  30. package/dist/http/PaymentsClient.js +18 -3
  31. package/dist/http/TaskClient.js +4 -11
  32. package/dist/http/index.d.ts +2 -1
  33. package/dist/http/index.js +5 -1
  34. package/dist/http/operatorHeaders.d.ts +22 -3
  35. package/dist/http/operatorHeaders.js +28 -4
  36. package/dist/http/paymentGrantSelection.d.ts +5 -0
  37. package/dist/http/paymentGrantSelection.js +26 -16
  38. package/dist/index.d.ts +3 -0
  39. package/dist/index.js +3 -0
  40. package/dist/shared/operatorKey.d.ts +47 -0
  41. package/dist/shared/operatorKey.js +64 -0
  42. package/dist/types.d.ts +6 -26
  43. package/dist/types.js +1 -19
  44. package/dist/utils/appUrls.d.ts +7 -0
  45. package/dist/utils/appUrls.js +38 -0
  46. package/package.json +3 -2
package/dist/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { InboxRequestChannel } from '@ziggs-ai/contracts';
1
2
  /**
2
3
  * One failure shape for every HTTP client path.
3
4
  *
@@ -259,19 +260,7 @@ export type BroadcastAudience = typeof OPEN_AGREEMENT_TARGET | typeof ORG_AGREEM
259
260
  export declare const BROADCAST_TARGETS: readonly ["everyone", "org"];
260
261
  /** True when `id` is a broadcast sentinel ('everyone' | 'org') rather than a concrete principal id. */
261
262
  export declare function isBroadcastTarget(id: string | null | undefined): boolean;
262
- /**
263
- * Persona face id (`psn_*`). Non-addressable — never use for agent lookup,
264
- * wake, or payment parties.
265
- */
266
- export declare function isPersonaRef(id: string | null | undefined): boolean;
267
- /**
268
- * Room presentation binding id (`rpb_*`). Opaque to account lookup / wake /
269
- * pay. Chat sends may echo it as `receiverId` — the backend resolves it in-room
270
- *.
271
- */
272
- export declare function isRoomPresentationRef(id: string | null | undefined): boolean;
273
- /** Either opaque presentation ref (`psn_*` | `rpb_*`). */
274
- export declare function isOpaquePresentationRef(id: string | null | undefined): boolean;
263
+ export { isPersonaFaceRef as isPersonaRef, isRoomBindingRef as isRoomPresentationRef, isPresentationRef as isOpaquePresentationRef, } from '@ziggs-ai/contracts';
275
264
  /** Display + entitlement face for a principal on the message/roster wire. */
276
265
  export interface PrincipalPresentation {
277
266
  /** Public, non-addressable reference (`psn_*` or `rpb_*`). */
@@ -332,7 +321,7 @@ export interface MessageMetadata {
332
321
  agreementId?: string | null;
333
322
  /**
334
323
  * Message send time from the wire payload. The live-path inbox
335
- * watermark ack (AgentHost, P4) needs it — without a timestamp the
324
+ * watermark ack (Agent, P4) needs it — without a timestamp the
336
325
  * ack never fires and catch-up re-delivers the chat's whole backlog after a
337
326
  * host eviction, re-running already-answered goals.
338
327
  */
@@ -472,14 +461,8 @@ export interface InboxTaskRef {
472
461
  * A marketplace request doorbell. Own channel so the host can
473
462
  * exact-match triage with zero LLM tokens before any wake.
474
463
  */
475
- export interface InboxRequestRef {
476
- agreementId: string;
477
- /** Exact-match string from the publisher — compare to the agent's tags. */
478
- match: string;
479
- title: string;
480
- ts: string;
481
- }
482
- export interface InboxEnvelope {
464
+ export type { InboxOpenRequestRef as InboxRequestRef } from '@ziggs-ai/contracts';
465
+ export interface InboxEnvelope extends InboxRequestChannel {
483
466
  asOf: string;
484
467
  /**
485
468
  * The mailboxes this reader's view merges — its owner's, plus whatever
@@ -487,7 +470,7 @@ export interface InboxEnvelope {
487
470
  */
488
471
  sources?: InboxSourceRef[];
489
472
  /**
490
- * Unacked rows across every source, newest first, copies of one event
473
+ * Unacked rows across every source, oldest first, copies of one event
491
474
  * collapsed. This IS the inbox — read straight out of the party delivery
492
475
  * logs, not derived from grants. Rows with `assigneeId === me` are mine to
493
476
  * act on; the rest are readable context.
@@ -509,9 +492,6 @@ export interface InboxEnvelope {
509
492
  /** Open tasks assigned to this agent — the work channel. */
510
493
  tasksAwaitingMe: InboxTaskRef[];
511
494
  truncatedTasks: number;
512
- /** Unacked request deliveries — triaged before any LLM wake. */
513
- requestsAwaitingMe?: InboxRequestRef[];
514
- truncatedRequests?: number;
515
495
  proposalsAwaitingMe: InboxProposalRef[];
516
496
  truncatedProposals: number;
517
497
  connectionRequestsAwaitingMe: InboxConnectionRequestRef[];
package/dist/types.js CHANGED
@@ -95,22 +95,4 @@ export const BROADCAST_TARGETS = [OPEN_AGREEMENT_TARGET, ORG_AGREEMENT_TARGET];
95
95
  export function isBroadcastTarget(id) {
96
96
  return id === OPEN_AGREEMENT_TARGET || id === ORG_AGREEMENT_TARGET;
97
97
  }
98
- /**
99
- * Persona face id (`psn_*`). Non-addressable — never use for agent lookup,
100
- * wake, or payment parties.
101
- */
102
- export function isPersonaRef(id) {
103
- return typeof id === 'string' && id.startsWith('psn_');
104
- }
105
- /**
106
- * Room presentation binding id (`rpb_*`). Opaque to account lookup / wake /
107
- * pay. Chat sends may echo it as `receiverId` — the backend resolves it in-room
108
- *.
109
- */
110
- export function isRoomPresentationRef(id) {
111
- return typeof id === 'string' && id.startsWith('rpb_');
112
- }
113
- /** Either opaque presentation ref (`psn_*` | `rpb_*`). */
114
- export function isOpaquePresentationRef(id) {
115
- return isPersonaRef(id) || isRoomPresentationRef(id);
116
- }
98
+ export { isPersonaFaceRef as isPersonaRef, isRoomBindingRef as isRoomPresentationRef, isPresentationRef as isOpaquePresentationRef, } from '@ziggs-ai/contracts';
@@ -0,0 +1,7 @@
1
+ /** Resolve the app origin once for SDK, MCP, and capability links. */
2
+ export declare function resolveWebAppOrigin(webUrl?: string | null, backendUrl?: string): string;
3
+ export declare function agreementAppUrl(origin: string, id: string): string;
4
+ export declare function agreementsListAppUrl(origin: string): string;
5
+ export declare function connectInviteAppUrl(origin: string, id: string): string;
6
+ export declare function connectionsSettingsAppUrl(origin: string, requestId?: string | null): string;
7
+ export declare function walletAppUrl(origin: string): string;
@@ -0,0 +1,38 @@
1
+ /** Resolve the app origin once for SDK, MCP, and capability links. */
2
+ export function resolveWebAppOrigin(webUrl, backendUrl) {
3
+ const explicit = webUrl
4
+ ?.split(';')
5
+ .map((value) => value.trim())
6
+ .find(Boolean);
7
+ if (explicit)
8
+ return explicit.replace(/\/+$/, '');
9
+ if (backendUrl) {
10
+ const backend = new URL(backendUrl);
11
+ if (backend.hostname === 'localhost' || backend.hostname === '127.0.0.1')
12
+ return 'http://localhost:1234';
13
+ backend.hostname = backend.hostname.replace(/^api\./, '');
14
+ return backend.origin;
15
+ }
16
+ return 'https://ziggsai.com';
17
+ }
18
+ function appUrl(origin, path) {
19
+ return new URL(path, `${resolveWebAppOrigin(origin)}/`).toString();
20
+ }
21
+ export function agreementAppUrl(origin, id) {
22
+ return appUrl(origin, `/app/agreements/${encodeURIComponent(id)}`);
23
+ }
24
+ export function agreementsListAppUrl(origin) {
25
+ return appUrl(origin, '/app/agreements');
26
+ }
27
+ export function connectInviteAppUrl(origin, id) {
28
+ return appUrl(origin, `/connect/${encodeURIComponent(id)}`);
29
+ }
30
+ export function connectionsSettingsAppUrl(origin, requestId) {
31
+ const url = new URL(appUrl(origin, '/app/access'));
32
+ if (requestId)
33
+ url.searchParams.set('request', requestId);
34
+ return url.toString();
35
+ }
36
+ export function walletAppUrl(origin) {
37
+ return appUrl(origin, '/app/settings/organization/billing');
38
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ziggs-ai/api-client",
3
- "version": "0.15.1",
3
+ "version": "0.17.0",
4
4
  "description": "HTTP and WebSocket client for the Ziggs backend API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -27,7 +27,8 @@
27
27
  "test:watch": "node --import tsx/esm --test --watch test/*.test.ts"
28
28
  },
29
29
  "dependencies": {
30
- "socket.io-client": "^4.7.0"
30
+ "socket.io-client": "^4.7.0",
31
+ "@ziggs-ai/contracts": "^0.6.0"
31
32
  },
32
33
  "keywords": [
33
34
  "ziggs",