@ziggs-ai/contracts 0.50.12 → 0.50.20

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.
@@ -109,11 +109,17 @@ export type AgreementRead = {
109
109
  publishedService?: boolean;
110
110
  claimSeats: AgreementClaimSeats | null;
111
111
  listingPausedAt?: string | null;
112
- metadata: Record<string, unknown>;
112
+ isSelfHire?: boolean;
113
+ isAssistantHire?: boolean;
114
+ ownedAgentSelfHire?: boolean;
115
+ counterOfAgreementId?: string;
116
+ counterDepth?: number;
117
+ identityMigration?: string;
113
118
  connectionRequest?: AgreementConnectionRequest;
114
119
  grantRequest?: {
115
- primitive?: "context";
116
- kind?: "access-request" | "author-share";
120
+ primitive?: "context" | "connection" | "task";
121
+ kind?: "access-request" | "author-share" | "re-delegate" | "task-delegation" | "task-hand-over";
122
+ parentGrantId?: string;
117
123
  contributionTo?: {
118
124
  kind: "message" | "agreement";
119
125
  id: string;
@@ -141,6 +147,18 @@ export type AgreementRead = {
141
147
  durationHours?: number;
142
148
  reason?: string;
143
149
  expiresAt?: string | null;
150
+ delegation?: {
151
+ parentTaskId: string | null;
152
+ agreementId: string;
153
+ assigneeId: string;
154
+ title: string | null;
155
+ description: string | null;
156
+ };
157
+ files?: Array<{
158
+ artifactId: string;
159
+ readers: Array<string>;
160
+ }>;
161
+ taskId?: string | null;
144
162
  };
145
163
  createdAt: string;
146
164
  updatedAt: string;
@@ -3,7 +3,7 @@
3
3
  * Family: grants. Regenerate: backend 'pnpm docs:generate' then this script.
4
4
  */
5
5
  export type GrantScopeView = {
6
- kind: "message" | "address" | "agreement" | "org" | "artifact" | "task" | "person" | "contact" | "connection" | "wallet" | "consent" | "inbox";
6
+ kind: "message" | "address" | "agreement" | "org" | "artifact" | "task" | "person" | "contact" | "thread" | "agent" | "workspace" | "connection" | "wallet" | "platform" | "consent" | "inbox";
7
7
  id: string;
8
8
  label?: string;
9
9
  };
@@ -26,7 +26,7 @@ export type GrantView = {
26
26
  revoked: boolean;
27
27
  expiresAt: string | null;
28
28
  createdAt: string;
29
- health: "active" | "expired" | "revoked";
29
+ health: "active" | "expired" | "revoked" | "inactive";
30
30
  holderKind?: "user" | "chatter" | "org" | "agent";
31
31
  access?: "list" | "read" | "write" | "admit";
32
32
  basis?: GrantBasis;
@@ -65,16 +65,21 @@ export declare const ARTIFACT_FILE_FORMATS: readonly ArtifactFileFormat[];
65
65
  export declare const AGREEMENT_PARTY_SIDES: readonly ["payer", "provider", "proposedTo", "creator"];
66
66
  export type AgreementPartySideName = (typeof AGREEMENT_PARTY_SIDES)[number];
67
67
  /**
68
- * A party slot that is a broadcast, not a person.
69
- * `everyone` is public. `org` is the agreement's own team only. `company` is
70
- * every team in the publisher's company: teams that point at one parent team,
71
- * and that parent (ZIG-1748).
68
+ * @deprecated ZIG-2491 — an offer's open side is empty now (`isOpenSide`,
69
+ * `offerOpenSide`), and who may take it is a grant. Kept only until the web
70
+ * app and the SDK stop reading these; the backend never compares a party to
71
+ * them (agreements/no-placeholder-party.spec.ts).
72
72
  */
73
73
  export declare const OPEN_AGREEMENT_TARGET = "everyone";
74
+ /** @deprecated ZIG-2491 — see OPEN_AGREEMENT_TARGET. */
74
75
  export declare const ORG_AGREEMENT_TARGET = "org";
76
+ /** @deprecated ZIG-2491 — see OPEN_AGREEMENT_TARGET. */
75
77
  export declare const COMPANY_AGREEMENT_TARGET = "company";
78
+ /** @deprecated ZIG-2491 — see OPEN_AGREEMENT_TARGET. */
76
79
  export declare const BROADCAST_TARGETS: readonly ["everyone", "org", "company"];
80
+ /** @deprecated ZIG-2491 — see OPEN_AGREEMENT_TARGET. */
77
81
  export type BroadcastAudience = (typeof BROADCAST_TARGETS)[number];
82
+ /** @deprecated ZIG-2491 — use `isOpenSide` on the side. */
78
83
  export declare function isBroadcastTarget(id: string | null | undefined): id is BroadcastAudience;
79
84
  /** One side, as ids only. Callers may pass the stored row. */
80
85
  export interface PartySideRef {
@@ -83,6 +88,28 @@ export interface PartySideRef {
83
88
  }
84
89
  /** Both ids on a side, principal then actor, blanks dropped. */
85
90
  export declare function partySideIds(side: PartySideRef | null | undefined): string[];
91
+ /**
92
+ * ZIG-2491 — an offer leaves one side empty: no principal and no actor. The
93
+ * paying side when it sells, the proposed-to side when it asks for work. Who may take it is a grant on the offer, never a word in
94
+ * the empty side.
95
+ */
96
+ export declare function isOpenSide(side: PartySideRef | null | undefined): boolean;
97
+ /** Which side of an offer is empty, or null for a deal or a link. */
98
+ export type OfferOpenSide = 'payer' | 'provider';
99
+ /**
100
+ * An offer is a template others take: it carries `claimSeats` (how many may
101
+ * hold an agreement made from it). An empty side alone does not make one: a
102
+ * link has no payer, and other agreements leave sides unwritten.
103
+ */
104
+ export declare function isOfferRow(row: {
105
+ engagementKind?: string | null;
106
+ claimSeats?: unknown;
107
+ } | null | undefined): boolean;
108
+ export declare function offerOpenSide(row: {
109
+ engagementKind?: string | null;
110
+ claimSeats?: unknown;
111
+ parties?: Partial<Record<AgreementPartySideName, PartySideRef | null>> | null;
112
+ } | null | undefined): OfferOpenSide | null;
86
113
  /** The agents that acted on any side, deduped. */
87
114
  export declare function partyActorIds(parties: Partial<Record<AgreementPartySideName, PartySideRef | null>> | null | undefined): string[];
88
115
  /**
@@ -98,17 +125,10 @@ export declare const AGREEMENT_ENGAGEMENT_KIND: {
98
125
  };
99
126
  export type AgreementEngagementKind = (typeof AGREEMENT_ENGAGEMENT_KIND)[keyof typeof AGREEMENT_ENGAGEMENT_KIND];
100
127
  /**
101
- * A seller's standing offer: the payer slot is a broadcast, and the paper
102
- * is not a reach link. Any status — a paused listing is still a listing.
128
+ * A seller's standing offer: the paying side is empty, and the paper is not a
129
+ * reach link. Any status — a paused listing is still a listing.
103
130
  */
104
- export declare function isSellerListing(row: {
105
- engagementKind?: string | null;
106
- parties?: {
107
- payer?: {
108
- principal?: string | null;
109
- } | null;
110
- } | null;
111
- } | null | undefined): boolean;
131
+ export declare function isSellerListing(row: Parameters<typeof offerOpenSide>[0]): boolean;
112
132
  /** A task is born active. Negotiation lives on the agreement, not here. */
113
133
  export declare const TASK_STATE: {
114
134
  readonly ACTIVE: "active";
@@ -139,8 +159,8 @@ export declare const AGREEMENT_TERMINAL_STATES: readonly AgreementStatusValue[];
139
159
  * Context-rail scopes, then the other rails a grant can name.
140
160
  * Order is the order the grants read and the OpenAPI enum publish.
141
161
  */
142
- export declare const CONTEXT_GRANT_SCOPE_KINDS: readonly ["message", "address", "agreement", "org", "artifact", "task", "person", "contact"];
143
- export declare const GRANT_SCOPE_KINDS: readonly ["message", "address", "agreement", "org", "artifact", "task", "person", "contact", "connection", "wallet", "consent", "inbox"];
162
+ export declare const CONTEXT_GRANT_SCOPE_KINDS: readonly ["message", "address", "agreement", "org", "artifact", "task", "person", "contact", "thread", "agent", "workspace", "connection", "wallet", "platform"];
163
+ export declare const GRANT_SCOPE_KINDS: readonly ["message", "address", "agreement", "org", "artifact", "task", "person", "contact", "thread", "agent", "workspace", "connection", "wallet", "platform", "consent", "inbox"];
144
164
  export type GrantScopeKind = (typeof GRANT_SCOPE_KINDS)[number];
145
165
  export type ContextGrantScopeKind = (typeof CONTEXT_GRANT_SCOPE_KINDS)[number];
146
166
  /** What an access request may name. Always one resource. */
@@ -10,6 +10,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.PARTY_KINDS = exports.MESSAGE_CONTENT_TYPES = exports.MESSAGE_CONTENT_TYPE = exports.MAX_ACCESS_REQUEST_HOLDERS = exports.ACCESS_REQUEST_HOLDER_KINDS = exports.ACCESS_REQUEST_SCOPE_KINDS = exports.GRANT_SCOPE_KINDS = exports.CONTEXT_GRANT_SCOPE_KINDS = exports.AGREEMENT_TERMINAL_STATES = exports.AGREEMENT_STATUSES = exports.AGREEMENT_STATUS = exports.TERMINAL_TASK_STATES = exports.TASK_UPDATE_STATES = exports.TASK_STATES = exports.TASK_STATE = exports.AGREEMENT_ENGAGEMENT_KIND = exports.BROADCAST_TARGETS = exports.COMPANY_AGREEMENT_TARGET = exports.ORG_AGREEMENT_TARGET = exports.OPEN_AGREEMENT_TARGET = exports.AGREEMENT_PARTY_SIDES = exports.ARTIFACT_FILE_FORMATS = exports.ARTIFACT_FILE_FORMAT = exports.RESOURCE_KINDS = exports.GRANT_ACCESS_KINDS = void 0;
11
11
  exports.isBroadcastTarget = isBroadcastTarget;
12
12
  exports.partySideIds = partySideIds;
13
+ exports.isOpenSide = isOpenSide;
14
+ exports.isOfferRow = isOfferRow;
15
+ exports.offerOpenSide = offerOpenSide;
13
16
  exports.partyActorIds = partyActorIds;
14
17
  exports.isSellerListing = isSellerListing;
15
18
  exports.isTerminalTaskState = isTerminalTaskState;
@@ -64,19 +67,23 @@ exports.AGREEMENT_PARTY_SIDES = [
64
67
  'creator',
65
68
  ];
66
69
  /**
67
- * A party slot that is a broadcast, not a person.
68
- * `everyone` is public. `org` is the agreement's own team only. `company` is
69
- * every team in the publisher's company: teams that point at one parent team,
70
- * and that parent (ZIG-1748).
70
+ * @deprecated ZIG-2491 — an offer's open side is empty now (`isOpenSide`,
71
+ * `offerOpenSide`), and who may take it is a grant. Kept only until the web
72
+ * app and the SDK stop reading these; the backend never compares a party to
73
+ * them (agreements/no-placeholder-party.spec.ts).
71
74
  */
72
75
  exports.OPEN_AGREEMENT_TARGET = 'everyone';
76
+ /** @deprecated ZIG-2491 — see OPEN_AGREEMENT_TARGET. */
73
77
  exports.ORG_AGREEMENT_TARGET = 'org';
78
+ /** @deprecated ZIG-2491 — see OPEN_AGREEMENT_TARGET. */
74
79
  exports.COMPANY_AGREEMENT_TARGET = 'company';
80
+ /** @deprecated ZIG-2491 — see OPEN_AGREEMENT_TARGET. */
75
81
  exports.BROADCAST_TARGETS = [
76
82
  exports.OPEN_AGREEMENT_TARGET,
77
83
  exports.ORG_AGREEMENT_TARGET,
78
84
  exports.COMPANY_AGREEMENT_TARGET,
79
85
  ];
86
+ /** @deprecated ZIG-2491 — use `isOpenSide` on the side. */
80
87
  function isBroadcastTarget(id) {
81
88
  return exports.BROADCAST_TARGETS.includes(id ?? '');
82
89
  }
@@ -84,6 +91,37 @@ function isBroadcastTarget(id) {
84
91
  function partySideIds(side) {
85
92
  return [side?.principal, side?.actor].filter((id) => typeof id === 'string' && id.length > 0);
86
93
  }
94
+ /**
95
+ * ZIG-2491 — an offer leaves one side empty: no principal and no actor. The
96
+ * paying side when it sells, the proposed-to side when it asks for work. Who may take it is a grant on the offer, never a word in
97
+ * the empty side.
98
+ */
99
+ function isOpenSide(side) {
100
+ // A side that is not written at all says nothing: an offer writes its open
101
+ // side as `{ principal: null, actor: null }`.
102
+ return !!side && partySideIds(side).length === 0;
103
+ }
104
+ /**
105
+ * An offer is a template others take: it carries `claimSeats` (how many may
106
+ * hold an agreement made from it). An empty side alone does not make one: a
107
+ * link has no payer, and other agreements leave sides unwritten.
108
+ */
109
+ function isOfferRow(row) {
110
+ return (!!row &&
111
+ row.claimSeats != null &&
112
+ row.engagementKind !== exports.AGREEMENT_ENGAGEMENT_KIND.LINK);
113
+ }
114
+ function offerOpenSide(row) {
115
+ if (!row?.parties || !isOfferRow(row))
116
+ return null;
117
+ if (isOpenSide(row.parties.payer))
118
+ return 'payer';
119
+ // Asking for work: nobody is named to do it yet. The provider may still
120
+ // carry who the work is for (a hire request names the agent to be hired).
121
+ if (isOpenSide(row.parties.proposedTo))
122
+ return 'provider';
123
+ return null;
124
+ }
87
125
  /** The agents that acted on any side, deduped. */
88
126
  function partyActorIds(parties) {
89
127
  const p = parties ?? {};
@@ -103,12 +141,11 @@ exports.AGREEMENT_ENGAGEMENT_KIND = {
103
141
  MEMBERSHIP: 'membership',
104
142
  };
105
143
  /**
106
- * A seller's standing offer: the payer slot is a broadcast, and the paper
107
- * is not a reach link. Any status — a paused listing is still a listing.
144
+ * A seller's standing offer: the paying side is empty, and the paper is not a
145
+ * reach link. Any status — a paused listing is still a listing.
108
146
  */
109
147
  function isSellerListing(row) {
110
- return (isBroadcastTarget(row?.parties?.payer?.principal) &&
111
- row?.engagementKind !== exports.AGREEMENT_ENGAGEMENT_KIND.LINK);
148
+ return offerOpenSide(row) === 'payer';
112
149
  }
113
150
  /** A task is born active. Negotiation lives on the agreement, not here. */
114
151
  exports.TASK_STATE = {
@@ -164,11 +201,24 @@ exports.CONTEXT_GRANT_SCOPE_KINDS = [
164
201
  // principal (scope id). Held at write only, never delegated, and minted only
165
202
  // by an approved access request.
166
203
  'contact',
204
+ // ZIG-2471 — every message of one thread, from the grant's watermark on.
205
+ // The scope id is the thread's access id (`Message.accessThreadId`).
206
+ 'thread',
207
+ // ZIG-2471 — an agent. Its root holds an `admit` grant on it: running it.
208
+ 'agent',
209
+ // ZIG-2471 — membership of a workspace; the grant's side is the role.
210
+ 'workspace',
211
+ // ZIG-2471 — owning a wallet (its workspace) or a connection (whoever
212
+ // connected it): an `admit` grant on it. Spending and using grants stay in
213
+ // their own collections, under the same kinds.
214
+ 'connection',
215
+ 'wallet',
216
+ // ZIG-2471 — platform staff: side `admin` or `developer`, kept from the
217
+ // user row. Never issued or passed on.
218
+ 'platform',
167
219
  ];
168
220
  exports.GRANT_SCOPE_KINDS = [
169
221
  ...exports.CONTEXT_GRANT_SCOPE_KINDS,
170
- 'connection',
171
- 'wallet',
172
222
  'consent',
173
223
  'inbox',
174
224
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ziggs-ai/contracts",
3
- "version": "0.50.12",
3
+ "version": "0.50.20",
4
4
  "description": "Wire contracts for the Ziggs API — response shapes, error body, and socket events, shared by every client.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",