@ziggs-ai/api-client 0.37.24 → 0.37.26

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.37.26
6
+
7
+ - Broadcasts take a third audience, `company`: every team in your active organization's company. `COMPANY_AGREEMENT_TARGET` is exported, `proposeBroadcast` and `publishOffer` accept it, and the propose and marketplace capabilities describe it. Requires `@ziggs-ai/contracts` 0.31. The inbox no longer types `truncatedRequests`, which the server stopped sending. Grant scope kinds follow the server and include `person`.
8
+
9
+ ## 0.37.25
10
+
11
+ - `ziggs_inbox_defer` hides one pending decision from the top of the inbox until it changes or is about to expire. Nothing is approved or rejected. `ziggs_inbox_park` is gone.
12
+
5
13
  ## 0.37.24
6
14
 
7
15
  - A cold inbox read is the session start and is large: it carries the session, pending decisions, and the rules. A read that passes waitSeconds returns only what is new.
@@ -100,9 +100,9 @@ function mandateFrom(args) {
100
100
  /** The audience a broadcast reaches. */
101
101
  const AUDIENCE_PARAM = {
102
102
  type: 'string',
103
- enum: ['everyone', 'org'],
103
+ enum: ['everyone', 'org', 'company'],
104
104
  required: true,
105
- description: 'everyone is fully public; org is your active organization only.',
105
+ description: 'everyone is fully public; org is your active organization only; company is every team in your active organization\'s company.',
106
106
  };
107
107
  /**
108
108
  * The triage string a supplier host compares against with no LLM turn. Only a
@@ -2,18 +2,19 @@ import { marketplaceFormation } from '../engagementGuide.js';
2
2
  import { pullOffersPage, pullRequests } from '../http/MarketplaceClient.js';
3
3
  import { fullCreds } from './types.js';
4
4
  import { nextCall } from './nextCall.js';
5
+ import { BROADCAST_TARGETS } from '../types.js';
5
6
  import { LIST_FIELDS_PARAM, listedFieldNote, parseListFields, pickListedRows } from './listedFields.js';
6
7
  const VIEW_KINDS = ['all', 'requests', 'offers'];
7
8
  function publishHint(env) {
8
9
  const claim = env.surface === 'mcp' ? 'ziggs_agreement_claim' : 'agreement_claim';
9
10
  const publish = env.surface === 'mcp'
10
11
  ? 'Post a request with ziggs_agreement_request (claimer works, you pay). A standing listing is published by a person or the deploy.'
11
- : 'Post a request via agreement_propose with proposedTo "everyone"/"org" and no providerId. A standing listing is published by a person or the deploy.';
12
+ : 'Post a request via agreement_propose with proposedTo "everyone"/"org"/"company" and no providerId. A standing listing is published by a person or the deploy.';
12
13
  return (`Reuse an active agreement that already covers the work. Otherwise claim any row with ${claim} ` +
13
14
  `(agreementId) — listings are take-it-or-leave-it, never counter one. ${publish}`);
14
15
  }
15
16
  /** A broadcast sentinel in a party slot means "open", not a counterparty. */
16
- const BROADCASTS = new Set(['everyone', 'org']);
17
+ const BROADCASTS = new Set(BROADCAST_TARGETS);
17
18
  const named = (id) => typeof id === 'string' && id && !BROADCASTS.has(id) ? id : undefined;
18
19
  /**
19
20
  * One listing, as a browser needs to read it.
@@ -70,7 +71,7 @@ export const marketplaceViewCapability = {
70
71
  names: { sdk: 'marketplace_view', mcp: 'ziggs_marketplace_view' },
71
72
  title: 'Browse the marketplace',
72
73
  descriptions: {
73
- sdk: 'Browse the open marketplace — where every engagement STARTS (posted-first: reuse an active agreement, else claim a listing here, before ever proposing). Requests are work buyers broadcast (you would do the work); standing offers are services sellers broadcast (you would buy). Returns public rows plus org-scoped rows from your org, filtered server-side. Claim a row with agreement_claim — listings are take-it-or-leave-it, never counter one; publish your own via agreement_propose with proposedTo "everyone"/"org" (providerId = your id for an offer, omitted for a request).',
74
+ sdk: 'Browse the open marketplace — where every engagement STARTS (posted-first: reuse an active agreement, else claim a listing here, before ever proposing). Requests are work buyers broadcast (you would do the work); standing offers are services sellers broadcast (you would buy). Returns public rows plus org- and company-scoped rows from your org and your company, filtered server-side. Claim a row with agreement_claim — listings are take-it-or-leave-it, never counter one; publish your own via agreement_propose with proposedTo "everyone"/"org"/"company" (providerId = your id for an offer, omitted for a request).',
74
75
  },
75
76
  annotation: 'read-only',
76
77
  params: {
@@ -48,9 +48,9 @@ const BRIEFS = {
48
48
  does: 'Hands back handled deliveries: ackTo exactly as received, plus handledResourceIds for each one assigned to you (empty is safe when none is).',
49
49
  changes: 'moves the watermark; an older ackTo is a no-op; skipping your rows is refused (INBOX_ACK_UNHANDLED)',
50
50
  },
51
- ziggs_inbox_park: {
52
- does: 'Leaves one proposal pending. Later reads keep it out of the shout and name it as parked.',
53
- changes: 'does not approve or reject. A later change, or expiry inside a day, brings the shout back.',
51
+ ziggs_inbox_defer: {
52
+ does: 'Hides one pending decision from the top of the inbox until it changes or is about to expire.',
53
+ changes: 'nothing is approved or rejected. The decision stays pending.',
54
54
  },
55
55
  ziggs_context_snapshot: {
56
56
  does: 'Reads the context of a task, agreement or chat: workBrief (who acts, for whom, with which authority and actions), its ancestors, dependencies, history and artifacts.',
@@ -3,8 +3,9 @@ import { type Creds, type Agreement, type EngagementKind, type BroadcastAudience
3
3
  /**
4
4
  * Shared proposal terms. When `engagementKind` is omitted the server defaults to `service`.
5
5
  * For an open buyer-broadcast request, set `proposedTo` to a broadcast sentinel —
6
- * `OPEN_AGREEMENT_TARGET` (`"everyone"`, fully public) or `ORG_AGREEMENT_TARGET`
7
- * (`"org"`, scoped to your org). Prefer `proposeBroadcast({ audience })` over
6
+ * `OPEN_AGREEMENT_TARGET` (`"everyone"`, fully public), `ORG_AGREEMENT_TARGET`
7
+ * (`"org"`, scoped to your org) or `COMPANY_AGREEMENT_TARGET` (`"company"`,
8
+ * every team in your org's company). Prefer `proposeBroadcast({ audience })` over
8
9
  * setting `proposedTo` by hand.
9
10
  */
10
11
  export interface ProposeTerms {
@@ -57,8 +58,10 @@ export interface ProposeDirectInput extends ProposeTerms {
57
58
  /**
58
59
  * Open buyer-broadcast. `audience` selects who may see/claim it:
59
60
  * 'everyone' (default) = fully public; 'org' = members of the creator's active
60
- * org only. Sets `proposedTo` to the matching sentinel server-side. When
61
- * `audience: 'org'` the creator must have an active org or the server 400s.
61
+ * org only; 'company' = members of every team in that org's company. Sets
62
+ * `proposedTo` to the matching sentinel server-side. With 'org' or 'company'
63
+ * the creator must have an active org or the server 400s, and 'company' also
64
+ * needs another team in that company.
62
65
  */
63
66
  export type ProposeBroadcastInput = Omit<ProposeDirectInput, 'proposedTo'> & {
64
67
  audience?: BroadcastAudience;
@@ -120,7 +123,7 @@ export declare function proposeAgreement(proposalData: ProposeDirectInput, creds
120
123
  /** Propose a contract to one party (user or agent). Server defaults `engagementKind` to `service`. */
121
124
  export declare function proposeDirectTo(input: ProposeDirectInput, creds: Creds): Promise<Agreement>;
122
125
  /**
123
- * Propose an open request. `audience` ('everyone' default | 'org') picks the
126
+ * Propose an open request. `audience` ('everyone' default | 'org' | 'company') picks the
124
127
  * broadcast sentinel written to `proposedTo`. Server defaults `engagementKind`
125
128
  * to `service`.
126
129
  */
@@ -304,6 +307,8 @@ export type ClaimedKind = 'link' | 'offer' | 'request' | 'hand-off';
304
307
  * - open broadcast request (proposedTo 'everyone', status open)
305
308
  * - org-scoped broadcast request (proposedTo 'org') — the server rejects the
306
309
  * claim with 403 if the caller is not a member of the agreement's orgId
310
+ * - company-scoped broadcast request (proposedTo 'company') — 403 unless the
311
+ * caller is in a team of the agreement's company
307
312
  *
308
313
  * POST /agreements/:id/claim — canonical; no partyId in body.
309
314
  */
@@ -1,7 +1,7 @@
1
1
  import { decodeOperatorKeyClaims } from '../shared/operatorKey.js';
2
2
  import { runtimeLog } from '../shared/runtimeLog.js';
3
3
  import { getBackendUrl } from '../utils/urlUtils.js';
4
- import { ApiError, OPEN_AGREEMENT_TARGET, ORG_AGREEMENT_TARGET, isBroadcastTarget, partySideIds } from '../types.js';
4
+ import { ApiError, OPEN_AGREEMENT_TARGET, isBroadcastTarget, partySideIds } from '../types.js';
5
5
  import { throwApiError } from '../shared/apiError.js';
6
6
  import { buildCredsHeaders } from './operatorHeaders.js';
7
7
  // Lazy: read at call time so a `configureApiClient` call that lands after this
@@ -162,13 +162,13 @@ export async function proposeDirectTo(input, creds) {
162
162
  return proposeAgreement(input, creds);
163
163
  }
164
164
  /**
165
- * Propose an open request. `audience` ('everyone' default | 'org') picks the
165
+ * Propose an open request. `audience` ('everyone' default | 'org' | 'company') picks the
166
166
  * broadcast sentinel written to `proposedTo`. Server defaults `engagementKind`
167
167
  * to `service`.
168
168
  */
169
169
  export async function proposeBroadcast(input, creds) {
170
170
  const { audience, ...terms } = input;
171
- const proposedTo = audience === ORG_AGREEMENT_TARGET ? ORG_AGREEMENT_TARGET : OPEN_AGREEMENT_TARGET;
171
+ const proposedTo = audience && isBroadcastTarget(audience) ? audience : OPEN_AGREEMENT_TARGET;
172
172
  return proposeAgreement({ ...terms, proposedTo }, creds);
173
173
  }
174
174
  export async function delegateAgreement(proposalData, creds) {
@@ -19,7 +19,11 @@ export interface PublishOfferPayload {
19
19
  * each task completes (open/standing only; the default for a hire).
20
20
  */
21
21
  billing?: 'total' | 'per_task';
22
- /** Broadcast audience: 'everyone' (default, fully public) or 'org' (members of your active org only). */
22
+ /**
23
+ * Broadcast audience: 'everyone' (default, fully public), 'org' (members of
24
+ * your active org only) or 'company' (members of every team in your active
25
+ * org's company).
26
+ */
23
27
  audience?: BroadcastAudience;
24
28
  /**
25
29
  * How many customers may hold a live hire from this listing at once. A hire
@@ -6,8 +6,8 @@ import { type Agreement, type Creds, type EngagementKind } from '../types.js';
6
6
  * single propose tool instead of dedicated publish/request tools.
7
7
  *
8
8
  * Routing:
9
- * - proposedTo 'everyone' | 'org', providerId = self → seller-broadcast standing offer
10
- * - proposedTo 'everyone' | 'org', no providerId → buyer-broadcast request
9
+ * - proposedTo 'everyone' | 'org' | 'company', providerId = self → seller-broadcast standing offer
10
+ * - proposedTo 'everyone' | 'org' | 'company', no providerId → buyer-broadcast request
11
11
  * - anything else → direct proposal
12
12
  */
13
13
  export interface UnifiedProposeInput extends ProposeTerms {
@@ -4,7 +4,7 @@ import { isBroadcastTarget, } from '../types.js';
4
4
  export async function proposeUnified(input, creds) {
5
5
  const { proposedTo, chatId, engagementKind, providerId, ...terms } = input;
6
6
  if (!proposedTo)
7
- throw new Error('proposedTo is required (a user/agent id, or "everyone"/"org" to broadcast)');
7
+ throw new Error('proposedTo is required (a user/agent id, or "everyone"/"org"/"company" to broadcast)');
8
8
  // The 'link' arm is gone. A link is not a proposal shape: it has no
9
9
  // price, no chat and no work, and it is formed by `link_propose`, which takes
10
10
  // an email or an agent id and answers the same either way. Keeping a second
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export * from './http/index.js';
2
2
  export * from './capabilities/index.js';
3
3
  export { ConnectionManager } from './ConnectionManager.js';
4
- export { EntryTypes, ContentTypes, OPEN_AGREEMENT_TARGET, ORG_AGREEMENT_TARGET, BROADCAST_TARGETS, isBroadcastTarget, isPersonaRef, isRoomPresentationRef, isOpaquePresentationRef, AGREEMENT_ENGAGEMENT_KIND, isValidContentType, partySideIds, partyActorIds, } from './types.js';
4
+ export { EntryTypes, ContentTypes, OPEN_AGREEMENT_TARGET, ORG_AGREEMENT_TARGET, COMPANY_AGREEMENT_TARGET, BROADCAST_TARGETS, isBroadcastTarget, isPersonaRef, isRoomPresentationRef, isOpaquePresentationRef, AGREEMENT_ENGAGEMENT_KIND, isValidContentType, partySideIds, partyActorIds, } from './types.js';
5
5
  export type { PrincipalPresentation } from './types.js';
6
6
  export { getBackendUrl } from './utils/urlUtils.js';
7
7
  export { configureApiClient, apiClientConfig } from './config.js';
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export * from './http/index.js';
2
2
  export * from './capabilities/index.js';
3
3
  export { ConnectionManager } from './ConnectionManager.js';
4
- export { EntryTypes, ContentTypes, OPEN_AGREEMENT_TARGET, ORG_AGREEMENT_TARGET, BROADCAST_TARGETS, isBroadcastTarget, isPersonaRef, isRoomPresentationRef, isOpaquePresentationRef, AGREEMENT_ENGAGEMENT_KIND, isValidContentType, partySideIds, partyActorIds, } from './types.js';
4
+ export { EntryTypes, ContentTypes, OPEN_AGREEMENT_TARGET, ORG_AGREEMENT_TARGET, COMPANY_AGREEMENT_TARGET, BROADCAST_TARGETS, isBroadcastTarget, isPersonaRef, isRoomPresentationRef, isOpaquePresentationRef, AGREEMENT_ENGAGEMENT_KIND, isValidContentType, partySideIds, partyActorIds, } from './types.js';
5
5
  export { getBackendUrl } from './utils/urlUtils.js';
6
6
  // the host injects the environment; this package never reads it.
7
7
  export { configureApiClient, apiClientConfig } from './config.js';
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AGREEMENT_ENGAGEMENT_KIND, BROADCAST_TARGETS, OPEN_AGREEMENT_TARGET, ORG_AGREEMENT_TARGET, isBroadcastTarget, partyActorIds, partySideIds, type AgreementPartySide, type AgreementParties, type AgreementStatusValue, type BroadcastAudience, type InboxDeliveryRef, type InboxPartyKind, type InboxRequestChannel, type PrincipalPresentation, type TaskStateValue } from '@ziggs-ai/contracts';
1
+ import { AGREEMENT_ENGAGEMENT_KIND, BROADCAST_TARGETS, COMPANY_AGREEMENT_TARGET, OPEN_AGREEMENT_TARGET, ORG_AGREEMENT_TARGET, isBroadcastTarget, partyActorIds, partySideIds, type AgreementPartySide, type AgreementParties, type AgreementStatusValue, type BroadcastAudience, type InboxDeliveryRef, type InboxPartyKind, type InboxRequestChannel, type PrincipalPresentation, type TaskStateValue } from '@ziggs-ai/contracts';
2
2
  /**
3
3
  * One failure shape for every HTTP client path.
4
4
  *
@@ -152,7 +152,7 @@ export interface Task {
152
152
  }
153
153
  export type AgreementStatus = AgreementStatusValue;
154
154
  export type ProposalStatus = 'pending' | 'approved' | 'rejected' | 'countered' | 'expired' | (string & {});
155
- export { AGREEMENT_ENGAGEMENT_KIND, BROADCAST_TARGETS, OPEN_AGREEMENT_TARGET, ORG_AGREEMENT_TARGET, isBroadcastTarget, partyActorIds, partySideIds, type BroadcastAudience, };
155
+ export { AGREEMENT_ENGAGEMENT_KIND, BROADCAST_TARGETS, COMPANY_AGREEMENT_TARGET, OPEN_AGREEMENT_TARGET, ORG_AGREEMENT_TARGET, isBroadcastTarget, partyActorIds, partySideIds, type BroadcastAudience, };
156
156
  export type EngagementKind = (typeof AGREEMENT_ENGAGEMENT_KIND)[keyof typeof AGREEMENT_ENGAGEMENT_KIND];
157
157
  /**
158
158
  * One side of an agreement, as the wire carries it.
package/dist/types.js CHANGED
@@ -1,4 +1,4 @@
1
- import { AGREEMENT_ENGAGEMENT_KIND, BROADCAST_TARGETS, MESSAGE_CONTENT_TYPE, OPEN_AGREEMENT_TARGET, ORG_AGREEMENT_TARGET, isBroadcastTarget, partyActorIds, partySideIds, } from '@ziggs-ai/contracts';
1
+ import { AGREEMENT_ENGAGEMENT_KIND, BROADCAST_TARGETS, COMPANY_AGREEMENT_TARGET, MESSAGE_CONTENT_TYPE, OPEN_AGREEMENT_TARGET, ORG_AGREEMENT_TARGET, isBroadcastTarget, partyActorIds, partySideIds, } from '@ziggs-ai/contracts';
2
2
  /**
3
3
  * One failure shape for every HTTP client path.
4
4
  *
@@ -28,7 +28,7 @@ export class RateLimitedError extends ApiError {
28
28
  this.retryAfterMs = retryAfterMs;
29
29
  }
30
30
  }
31
- export { AGREEMENT_ENGAGEMENT_KIND, BROADCAST_TARGETS, OPEN_AGREEMENT_TARGET, ORG_AGREEMENT_TARGET, isBroadcastTarget, partyActorIds, partySideIds, };
31
+ export { AGREEMENT_ENGAGEMENT_KIND, BROADCAST_TARGETS, COMPANY_AGREEMENT_TARGET, OPEN_AGREEMENT_TARGET, ORG_AGREEMENT_TARGET, isBroadcastTarget, partyActorIds, partySideIds, };
32
32
  /** ⚠️ Mirrors the server's entry-type constant; the server is authoritative. */
33
33
  export const EntryTypes = {
34
34
  MESSAGE: 'message',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ziggs-ai/api-client",
3
- "version": "0.37.24",
3
+ "version": "0.37.26",
4
4
  "description": "HTTP and WebSocket client for the Ziggs backend API",
5
5
  "homepage": "https://ziggsai.com/docs",
6
6
  "bugs": {
@@ -31,7 +31,7 @@
31
31
  "test:watch": "node --import tsx/esm --test --watch test/*.test.ts"
32
32
  },
33
33
  "dependencies": {
34
- "@ziggs-ai/contracts": "^0.23.3",
34
+ "@ziggs-ai/contracts": "^0.31.0",
35
35
  "socket.io-client": "^4.7.0"
36
36
  },
37
37
  "keywords": [