@ziggs-ai/api-client 0.40.5 → 0.40.6

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,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.40.6
6
+
5
7
  ## 0.40.5
6
8
 
7
9
  - An artifact reaches people only by being added to a bucket. The `artifact_share` tool, `shareArtifactCapability` and `ContextGrantsClient.shareArtifact` are removed, `context_delegate` no longer takes `scopeKind: 'artifact'`, and `link_list` no longer suggests sharing an artifact. The server refuses artifact grants issued or passed on directly.
@@ -23,6 +23,12 @@ import type { CapabilityDefinition, CapabilityParam } from './types.js';
23
23
  * Hosted-agent tools spread this instead of keeping a shorter copy.
24
24
  */
25
25
  export declare const AGREEMENT_TERMS_PARAMS: Record<string, CapabilityParam>;
26
+ /** The bucket a hire goes into. Exported for the claim verb. */
27
+ export declare const BUCKET_PARAM: CapabilityParam;
28
+ /** The named bucket off a validated arg bag, as the wire field. */
29
+ export declare function bucketFrom(args: Record<string, unknown>): {
30
+ bucketId?: string;
31
+ };
26
32
  export declare const agreementBuyCapability: CapabilityDefinition;
27
33
  export declare const agreementBidCapability: CapabilityDefinition;
28
34
  export declare const agreementBrokerCapability: CapabilityDefinition;
@@ -92,6 +92,16 @@ const MANDATE_PARAM = {
92
92
  type: 'string',
93
93
  description: 'Parent job: an active agreement you participate in. Ending it ends this work. It grants neither hiring nor representation authority.',
94
94
  };
95
+ /** The bucket a hire goes into. Exported for the claim verb. */
96
+ export const BUCKET_PARAM = {
97
+ type: 'string',
98
+ description: "Bucket it goes into. Default: your run's bucket, else a new one.",
99
+ };
100
+ /** The named bucket off a validated arg bag, as the wire field. */
101
+ export function bucketFrom(args) {
102
+ const id = args['bucketId'];
103
+ return typeof id === 'string' && id.trim() ? { bucketId: id.trim() } : {};
104
+ }
95
105
  /** Pull the declared mandate off a validated arg bag, as the wire field. */
96
106
  function mandateFrom(args) {
97
107
  const declared = args['parentAgreementId'] ?? args['mandateAgreementId'];
@@ -162,6 +172,7 @@ export const agreementBuyCapability = {
162
172
  addressId: CHAT_PARAM,
163
173
  ...AGREEMENT_TERMS_PARAMS,
164
174
  mandateAgreementId: MANDATE_PARAM,
175
+ bucketId: BUCKET_PARAM,
165
176
  parentAgreementId: { type: 'string', description: 'The job this work is part of; ending it ends this work. Not a link, and no spending consent.' },
166
177
  },
167
178
  needsAgentId: true,
@@ -170,6 +181,7 @@ export const agreementBuyCapability = {
170
181
  const agreement = await proposeDirectTo({
171
182
  ...termsFrom(args),
172
183
  ...mandateFrom(args),
184
+ ...bucketFrom(args),
173
185
  proposedTo: counterparty,
174
186
  addressId: args['addressId'],
175
187
  // They provide. The payer is derived server-side as the other side.
@@ -193,6 +205,7 @@ export const agreementBidCapability = {
193
205
  addressId: CHAT_PARAM,
194
206
  ...AGREEMENT_TERMS_PARAMS,
195
207
  mandateAgreementId: MANDATE_PARAM,
208
+ bucketId: BUCKET_PARAM,
196
209
  parentAgreementId: { type: 'string', description: 'The job this work is part of; ending it ends this work. Not a link, and no spending consent.' },
197
210
  },
198
211
  needsAgentId: true,
@@ -201,6 +214,7 @@ export const agreementBidCapability = {
201
214
  const agreement = await proposeDirectTo({
202
215
  ...termsFrom(args),
203
216
  ...mandateFrom(args),
217
+ ...bucketFrom(args),
204
218
  proposedTo: args['counterparty'],
205
219
  addressId: args['addressId'],
206
220
  // You provide, so the counterparty pays.
@@ -262,6 +276,7 @@ export const agreementRequestCapability = {
262
276
  ...AGREEMENT_TERMS_PARAMS,
263
277
  match: MATCH_PARAM,
264
278
  mandateAgreementId: MANDATE_PARAM,
279
+ bucketId: BUCKET_PARAM,
265
280
  parentAgreementId: { type: 'string', description: 'The job this work is part of; ending it ends this work. Not a link, and no spending consent.' },
266
281
  },
267
282
  needsAgentId: true,
@@ -269,6 +284,7 @@ export const agreementRequestCapability = {
269
284
  const agreement = await proposeBroadcast({
270
285
  ...termsFrom(args),
271
286
  ...mandateFrom(args),
287
+ ...bucketFrom(args),
272
288
  addressId: '',
273
289
  audience: args['audience'],
274
290
  engagementKind: engagementKindFrom(args),
@@ -392,6 +408,7 @@ export const agreementSubcontractCapability = {
392
408
  type: 'string',
393
409
  description: 'Who pays for the subcontracted work. Defaults to the delegating side.',
394
410
  },
411
+ bucketId: BUCKET_PARAM,
395
412
  },
396
413
  needsAgentId: true,
397
414
  handler: async (args, env) => {
@@ -417,6 +434,7 @@ export const agreementSubcontractCapability = {
417
434
  ...(args['payerId'] === undefined
418
435
  ? {}
419
436
  : { payerId: args['payerId'] }),
437
+ ...bucketFrom(args),
420
438
  }, fullCreds(env));
421
439
  return { agreement };
422
440
  },
@@ -1,6 +1,7 @@
1
1
  import { agreementAppUrl } from '../utils/appUrls.js';
2
2
  import { claimOpenAgreement } from '../http/agreementFlows.js';
3
3
  import { linkIsReachOnly, webAppOrigin } from './links.js';
4
+ import { BUCKET_PARAM, bucketFrom } from './agreementVerbs.js';
4
5
  import { workContextFromEnv } from './nextCall.js';
5
6
  import { fullCreds } from './types.js';
6
7
  /** Plain outcome once the hire is active. `kind` stays on the result, not in this sentence. */
@@ -86,11 +87,12 @@ export const agreementClaimCapability = {
86
87
  enum: ['me', 'workspace'],
87
88
  description: "Listing hire: me (default) keeps work private; workspace shares with that workspace. Ask your person if unclear.",
88
89
  },
90
+ bucketId: BUCKET_PARAM,
89
91
  },
90
92
  needsAgentId: true,
91
93
  handler: async (args, env) => {
92
94
  const declaredMandate = args['mandateAgreementId'];
93
- const { agreement, kind } = await claimOpenAgreement(args['agreementId'], fullCreds(env), { ...(typeof declaredMandate === 'string' && declaredMandate ? { mandateAgreementId: declaredMandate } : {}), ...(typeof args['parentAgreementId'] === 'string' ? { parentAgreementId: args['parentAgreementId'] } : {}), ...(claimConnections(args['connections']) ?? {}), ...(args['hireFor'] === 'workspace' ? { hireFor: 'workspace' } : {}) });
95
+ const { agreement, kind } = await claimOpenAgreement(args['agreementId'], fullCreds(env), { ...(typeof declaredMandate === 'string' && declaredMandate ? { mandateAgreementId: declaredMandate } : {}), ...(typeof args['parentAgreementId'] === 'string' ? { parentAgreementId: args['parentAgreementId'] } : {}), ...(claimConnections(args['connections']) ?? {}), ...(args['hireFor'] === 'workspace' ? { hireFor: 'workspace' } : {}), ...bucketFrom(args) });
94
96
  return presentClaimResult(agreement, kind, env);
95
97
  },
96
98
  };
@@ -45,6 +45,11 @@ export interface ProposeDirectInput extends ProposeTerms {
45
45
  proposedTo: string;
46
46
  /** Optional display-reference context for resolving a masked party; does not publish or share. */
47
47
  addressId?: string;
48
+ /**
49
+ * The bucket the agreement goes into, one you are in. Left out: the bucket
50
+ * your run works in, else a new one. The other side comes in when it starts.
51
+ */
52
+ bucketId?: string;
48
53
  }
49
54
  /**
50
55
  * Open buyer-broadcast. `audience` selects who may see/claim it:
@@ -134,6 +139,11 @@ export interface DelegateAgreementData {
134
139
  interactionMode?: 'messages' | 'tasks' | 'both';
135
140
  agreementDescription?: string;
136
141
  payerId?: string;
142
+ /**
143
+ * The bucket the sub-agreement goes into, one you are in. Left out: the
144
+ * bucket your run works in, else the parent's buckets, else a new one.
145
+ */
146
+ bucketId?: string;
137
147
  idempotencyKey?: string;
138
148
  }
139
149
  export declare function delegateAgreement(proposalData: DelegateAgreementData, creds: Creds): Promise<Agreement>;
@@ -328,6 +338,11 @@ export type ClaimedKind = 'link' | 'offer' | 'request' | 'hand-off';
328
338
  */
329
339
  export interface ClaimOptions {
330
340
  parentAgreementId?: string;
341
+ /**
342
+ * The bucket the hire goes into, one you are in. Left out: the bucket your
343
+ * run works in, else a new one. The other side comes in when it starts.
344
+ */
345
+ bucketId?: string;
331
346
  /**
332
347
  * The active agreement whose work this claim is part of. An agent acting
333
348
  * inside a job its human approved does not need a second consent for the
@@ -559,7 +559,7 @@ export async function claimAgreement(agreementId, creds, opts = {}) {
559
559
  const res = await fetch(`${getAgreementBaseUrl()}/${encodeURIComponent(agreementId)}/claim`, {
560
560
  method: 'POST',
561
561
  headers: buildHeaders(creds),
562
- body: JSON.stringify({ ...(opts.mandateAgreementId ? { mandateAgreementId: opts.mandateAgreementId } : {}), ...(opts.parentAgreementId ? { parentAgreementId: opts.parentAgreementId } : {}), ...(opts.connections && Object.keys(opts.connections).length ? { connections: opts.connections } : {}), ...(opts.hireFor === 'workspace' ? { hireFor: 'workspace' } : {}) }),
562
+ body: JSON.stringify({ ...(opts.mandateAgreementId ? { mandateAgreementId: opts.mandateAgreementId } : {}), ...(opts.parentAgreementId ? { parentAgreementId: opts.parentAgreementId } : {}), ...(opts.connections && Object.keys(opts.connections).length ? { connections: opts.connections } : {}), ...(opts.hireFor === 'workspace' ? { hireFor: 'workspace' } : {}), ...(opts.bucketId ? { bucketId: opts.bucketId } : {}) }),
563
563
  });
564
564
  if (!res.ok) {
565
565
  const body = await res.text().catch(() => '');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ziggs-ai/api-client",
3
- "version": "0.40.5",
3
+ "version": "0.40.6",
4
4
  "description": "HTTP and WebSocket client for the Ziggs backend API",
5
5
  "homepage": "https://ziggsai.com/docs",
6
6
  "bugs": {