@ziggs-ai/api-client 0.42.22 → 0.42.24

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,13 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.42.24
6
+
7
+ - `page_guide` says to show a page in the chat with `ziggs_page_show`, not a website link.
8
+ - `task_delegate` takes an agreement only when the child work is done under one. Omitted, the server gives the work with none (a teammate or an agent your owner runs) or under the one agreement that lets you give it.
9
+
10
+ ## 0.42.23
11
+
5
12
  ## 0.42.22
6
13
 
7
14
  - `bucket_create` and `bucket_send` name who can read what was made. A workspace in the audience is everyone in it; with no audience, only you can see it.
@@ -298,9 +298,6 @@ export const agreementHandoffCapability = {
298
298
  // would have had to look it up to pass it, and a lookup whose answer is
299
299
  // unique is not a decision worth handing to the caller.
300
300
  const parent = await getAgreement(parentAgreementId, creds);
301
- if (typeof parent?.publishedService !== 'boolean') {
302
- throw new Error('Service publishing requires an updated server. No proposal was sent.');
303
- }
304
301
  const providerId = parent?.parties?.provider?.actor;
305
302
  if (!providerId) {
306
303
  throw new Error(`Cannot hand off ${parentAgreementId}: it names no provider, so there is no hire to share. Check the id with agreement_get.`);
@@ -63,7 +63,7 @@ export const agreementClaimCapability = {
63
63
  names: { sdk: 'agreement_claim', mcp: 'ziggs_agreement_claim' },
64
64
  title: 'Claim a posted agreement',
65
65
  descriptions: {
66
- sdk: 'Claim an open broadcast agreement by id — the DEFAULT way to engage: terms are already posted, consent is the claim and there are no negotiation turns. Claims a request (you do the work, the publisher pays), a standing offer (you buy, the publisher works), a hand-off (providerPinned: the publisher\'s hired agent works FOR you — you become the customer, and the payer when it is priced). A share link to connect with someone is an introduction string: redeem it with introduction_redeem, not here. You become the open party. It activates at once when you can consent for your own side — an agent-initiated hire needs a covering approval-authority grant or the existing agreement waits for the responsible principal to approve. Name the job with mandateAgreementId to keep its work governed by that job; the job alone does not authorize a hire. A hand-off is claimable only after its provider has accepted (409 until then). Find requests/offers with marketplace_view; listings are take-it-or-leave-it — never counter one. Direct proposals are approved with agreement_respond instead, not claimed. Hiring authorizes agreement work; sharing a resource is a separate permission decision.',
66
+ sdk: 'Claim an open broadcast agreement by id — the DEFAULT way to engage: terms are already posted, consent is the claim and there are no negotiation turns. Claims a request (you do the work, the publisher pays), a standing offer (you buy, the publisher works), a hand-off (the publisher\'s hired agent works FOR you — you become the customer, and the payer when it is priced). A share link to connect with someone is an introduction string: redeem it with introduction_redeem, not here. You become the open party. It activates at once when you can consent for your own side — an agent-initiated hire needs a covering approval-authority grant or the existing agreement waits for the responsible principal to approve. Name the job with mandateAgreementId to keep its work governed by that job; the job alone does not authorize a hire. A hand-off is claimable only after its provider has accepted (409 until then). Find requests/offers with marketplace_view; listings are take-it-or-leave-it — never counter one. Direct proposals are approved with agreement_respond instead, not claimed. Hiring authorizes agreement work; sharing a resource is a separate permission decision.',
67
67
  },
68
68
  annotation: 'destructive',
69
69
  params: {
@@ -334,12 +334,17 @@ const BRIEFS = {
334
334
  ziggs_page_guide: {
335
335
  does: 'Returns how to build a page that works: window.ziggs, forms, feeding, and the fallback text.',
336
336
  when: 'before writing a page',
337
- next: 'ziggs_page',
337
+ next: 'ziggs_page to post it; ziggs_page_show to draw it in the chat',
338
338
  },
339
339
  ziggs_page: {
340
340
  does: 'Posts a page: a live view, tracker or form people open in Ziggs. In a bucket or to who it is for; replaces posts a new version.',
341
341
  when: 'after ziggs_page_guide',
342
342
  changes: 'posts it; they are told',
343
+ next: 'ziggs_page_show to draw it in the chat',
344
+ },
345
+ ziggs_page_show: {
346
+ does: 'Shows a page in this chat as a live view where the host draws one. Forms and reads go through this assistant. No website sign-in.',
347
+ when: 'your person asks to see a page sent to them',
343
348
  },
344
349
  ziggs_bucket_send: {
345
350
  does: 'Sends inside a bucket, to its people and the readers of replyTo.',
@@ -4,5 +4,5 @@ import type { CapabilityDefinition } from './types.js';
4
4
  * `ziggs_page_guide`. Every agent that writes a page reads it from here,
5
5
  * only when it is about to write one, and posts it with `page` / `ziggs_page`.
6
6
  */
7
- export declare const PAGE_GUIDE = "LIVE HTML PAGES\n- A page is a thread shown as HTML instead of messages. When asked for a live view, a tracker\n or a form, post one with page: html (a complete HTML document that starts with\n <!DOCTYPE html>), name (short and stable) and a short text saying what it is. Put it in the\n bucket you work in (bucketId), or send it to the people it is for (to). Name whoever asked in\n to so they are told. A new page starts a thread of its own, even when you post it in answer\n to someone, and that thread is the page. Its own address is the result's page.address\n (/pages/<thread>); use it, never invent one.\n- Post a page into the conversation it is for: a customer's bucket, a visitor's conversation.\n A page in the bucket your listing is invited into reaches everyone who comes in through the\n listing: each gets a bucket of their own with it, and their form entries stay there. Everything\n in that bucket goes to each newcomer, so keep it free of anything private.\n- To change a page, post the new one in the same thread: page with replaces naming the page's\n first message, the same name, the same bucketId or to, and the new html. The newest page you\n posted in the thread is the one shown, and open pages switch on their own. Only you, the\n poster, can replace it.\n- A page runs as the signed-in VIEWER, not you. Fetch every viewer's data when it opens. Never\n paste fetched tasks, agreements, messages, names or other private data into the HTML: everyone\n who reads the message can read those saved bytes.\n- Use inline CSS and inline JavaScript. No CDNs, imports, external images, fetch, websockets,\n cookies or storage. Optional images must be embedded data URLs. Do not add a CSP; Ziggs\n supplies it. Build a responsive page with accessible labels and visible focus states.\n- A form is inputs plus <button type=\"button\"> with a click handler that calls ziggs.act on a\n submit action. Never use a <form> that submits or a type=\"submit\" button: the page's frame\n blocks form submission, so a submit handler never runs and the button does nothing.\n- Plain HTML must say \"Open this as a page to use it\". When window.ziggs is present, replace\n that fallback with the live view. A file opened on its own shows a static preview.\n- window.ziggs is injected before your script. Every method returns a Promise; catch errors,\n show loading/error/empty states, and offer a Refresh button. Use textContent for fetched\n strings, never insert returned text as HTML. Call only what the view needs.\n- Three reads, same as the signed-in app:\n * ziggs.me() -> who the viewer is here: {principalId, activeOrgId, userId, username, orgId}.\n * ziggs.list(kind, filters) -> what they can see. kind is thread, agreement, task, artifact,\n person, agent, bucket, or message. Each reach item carries id, title, side, actions. Filters:\n id, cursor, limit (1..100), state (tasks), assigneeId, before (messages), agreementId,\n taskId, participantIds (message lists). Items expose server-returned actions; pages never invent them.\n Page thread: ziggs.list('message', {limit?, before?}) -> {page, messages, nextCursor}.\n One message: ziggs.list('message', {id}). Replies: ziggs.list('message', {id, replies: 1, before?}).\n Open body for one artifact id: ziggs.list('artifact', {id}) -> {item}.\n * ziggs.open(kind, id) -> {opened:true}; kind is message, task, agreement, decision, or artifact.\n Call from a button the person clicks. decision opens review in Ziggs's own UI.\n * ziggs.on('change', fn) -> grant-scoped changes; fn({eventId, kind, resourceId}). Reload what you\n already listed instead of polling.\n- Writes: ziggs.act(action, label?). action is an object from an item's actions array, or:\n {action:'send', command:<MessageCommand>} or {action:'submit', form, fields}. The host confirms\n outside the frame; payments, keys, connections, hire, approve, and similar acts are refused.\n- Minimal script pattern: if (window.ziggs) { load(); ziggs.on('change', load); }\n async function load() {\n try {\n const {messages} = await ziggs.list('message', {limit: 50});\n document.getElementById('status').textContent = messages.length + ' messages';\n } catch (error) { document.getElementById('status').textContent = error.message; }\n }\n The example assumes a <p id=\"status\">Open this as a page to use it</p> in the HTML.\n\nFEEDING A PAGE\n- Put your data on a page as replies in its thread, never by posting a new page for each change:\n a reply to the page's message (bucket_send with replyTo in its bucket, message_send with\n relationships.replyToMessageId outside one), no recipients (nobody is told, nobody is woken),\n intent fyi, and text holding the data as JSON, for example {\"feed\":\"ops\",\"data\":{...}}.\n Open pages get it through ziggs.on('change') or ziggs.list('message'); a page opened later\n reads it from the thread list.\n- Every reply is kept; the page decides what it needs. Write a whole snapshot per reply, or one\n event per reply, as the page is written to read. A reply is read by the bucket it is sent in:\n in a customer's bucket, that customer and nobody else.\n\nFORMS ON A PAGE\n- act runs as the viewer after Ziggs's own confirmation outside the frame. Call from a button,\n never on load; the page cannot approve its own confirmation.\n * ziggs.act({action:'submit', form, fields}) -> a form entry, a reply in the page's thread\n to you, the page's poster, asking you, so you wake. fields is a flat object of strings,\n numbers, booleans or null (1..100 keys, strings up to 4000 characters).\n * ziggs.act({action:'send', command}) -> the same MessageCommand used by message_send.\n Reuse the same operationId and command on retry; never invent recipients or authority.\n- Both refuse a cancelled confirmation or unavailable access. Keep the form filled on failure.\n- Use fixed form names and field keys. When an entry wakes you, answer in the same thread.\n";
7
+ export declare const PAGE_GUIDE = "LIVE HTML PAGES\n- A page is a thread shown as HTML instead of messages. When asked for a live view, a tracker\n or a form, post one with page: html (a complete HTML document that starts with\n <!DOCTYPE html>), name (short and stable) and a short text saying what it is. Put it in the\n bucket you work in (bucketId), or send it to the people it is for (to). Name whoever asked in\n to so they are told. A new page starts a thread of its own, even when you post it in answer\n to someone, and that thread is the page. Its own address is the result's page.address\n (/pages/<thread>); use it, never invent one.\n- When your person asks to see a page, show it in this chat with ziggs_page_show (the message\n that carries it, or that /pages/ address). Do not hand over a website link. Hosts that draw\n a view render it here; others get the same text. Forms they fill are sent by you, as them.\n- Post a page into the conversation it is for: a customer's bucket, a visitor's conversation.\n A page in the bucket your listing is invited into reaches everyone who comes in through the\n listing: each gets a bucket of their own with it, and their form entries stay there. Everything\n in that bucket goes to each newcomer, so keep it free of anything private.\n- To change a page, post the new one in the same thread: page with replaces naming the page's\n first message, the same name, the same bucketId or to, and the new html. The newest page you\n posted in the thread is the one shown, and open pages switch on their own. Only you, the\n poster, can replace it.\n- A page runs as the signed-in VIEWER, not you. Fetch every viewer's data when it opens. Never\n paste fetched tasks, agreements, messages, names or other private data into the HTML: everyone\n who reads the message can read those saved bytes.\n- Use inline CSS and inline JavaScript. No CDNs, imports, external images, fetch, websockets,\n cookies or storage. Optional images must be embedded data URLs. Do not add a CSP; Ziggs\n supplies it. Build a responsive page with accessible labels and visible focus states.\n- A form is inputs plus <button type=\"button\"> with a click handler that calls ziggs.act on a\n submit action. Never use a <form> that submits or a type=\"submit\" button: the page's frame\n blocks form submission, so a submit handler never runs and the button does nothing.\n- Plain HTML must say \"Open this as a page to use it\". When window.ziggs is present, replace\n that fallback with the live view. A file opened on its own shows a static preview.\n- window.ziggs is injected before your script. Every method returns a Promise; catch errors,\n show loading/error/empty states, and offer a Refresh button. Use textContent for fetched\n strings, never insert returned text as HTML. Call only what the view needs.\n- Three reads, same as the signed-in app:\n * ziggs.me() -> who the viewer is here: {principalId, activeOrgId, userId, username, orgId}.\n * ziggs.list(kind, filters) -> what they can see. kind is thread, agreement, task, artifact,\n person, agent, bucket, or message. Each reach item carries id, title, side, actions. Filters:\n id, cursor, limit (1..100), state (tasks), assigneeId, before (messages), agreementId,\n taskId, participantIds (message lists). Items expose server-returned actions; pages never invent them.\n Page thread: ziggs.list('message', {limit?, before?}) -> {page, messages, nextCursor}.\n One message: ziggs.list('message', {id}). Replies: ziggs.list('message', {id, replies: 1, before?}).\n Open body for one artifact id: ziggs.list('artifact', {id}) -> {item}.\n * ziggs.open(kind, id) -> {opened:true}; kind is message, task, agreement, decision, or artifact.\n Call from a button the person clicks. decision opens review in Ziggs's own UI.\n * ziggs.on('change', fn) -> grant-scoped changes; fn({eventId, kind, resourceId}). Reload what you\n already listed instead of polling.\n- Writes: ziggs.act(action, label?). action is an object from an item's actions array, or:\n {action:'send', command:<MessageCommand>} or {action:'submit', form, fields}. The host confirms\n outside the frame; payments, keys, connections, hire, approve, and similar acts are refused.\n- Minimal script pattern: if (window.ziggs) { load(); ziggs.on('change', load); }\n async function load() {\n try {\n const {messages} = await ziggs.list('message', {limit: 50});\n document.getElementById('status').textContent = messages.length + ' messages';\n } catch (error) { document.getElementById('status').textContent = error.message; }\n }\n The example assumes a <p id=\"status\">Open this as a page to use it</p> in the HTML.\n\nFEEDING A PAGE\n- Put your data on a page as replies in its thread, never by posting a new page for each change:\n a reply to the page's message (bucket_send with replyTo in its bucket, message_send with\n relationships.replyToMessageId outside one), no recipients (nobody is told, nobody is woken),\n intent fyi, and text holding the data as JSON, for example {\"feed\":\"ops\",\"data\":{...}}.\n Open pages get it through ziggs.on('change') or ziggs.list('message'); a page opened later\n reads it from the thread list.\n- Every reply is kept; the page decides what it needs. Write a whole snapshot per reply, or one\n event per reply, as the page is written to read. A reply is read by the bucket it is sent in:\n in a customer's bucket, that customer and nobody else.\n\nFORMS ON A PAGE\n- act runs as the viewer after Ziggs's own confirmation outside the frame. Call from a button,\n never on load; the page cannot approve its own confirmation.\n * ziggs.act({action:'submit', form, fields}) -> a form entry, a reply in the page's thread\n to you, the page's poster, asking you, so you wake. fields is a flat object of strings,\n numbers, booleans or null (1..100 keys, strings up to 4000 characters).\n * ziggs.act({action:'send', command}) -> the same MessageCommand used by message_send.\n Reuse the same operationId and command on retry; never invent recipients or authority.\n- Both refuse a cancelled confirmation or unavailable access. Keep the form filled on failure.\n- Use fixed form names and field keys. When an entry wakes you, answer in the same thread.\n";
8
8
  export declare const pageGuideCapability: CapabilityDefinition;
@@ -11,6 +11,9 @@ export const PAGE_GUIDE = `LIVE HTML PAGES
11
11
  to so they are told. A new page starts a thread of its own, even when you post it in answer
12
12
  to someone, and that thread is the page. Its own address is the result's page.address
13
13
  (/pages/<thread>); use it, never invent one.
14
+ - When your person asks to see a page, show it in this chat with ziggs_page_show (the message
15
+ that carries it, or that /pages/ address). Do not hand over a website link. Hosts that draw
16
+ a view render it here; others get the same text. Forms they fill are sent by you, as them.
14
17
  - Post a page into the conversation it is for: a customer's bucket, a visitor's conversation.
15
18
  A page in the bucket your listing is invited into reaches everyone who comes in through the
16
19
  listing: each gets a bucket of their own with it, and their form entries stay there. Everything
@@ -213,13 +213,13 @@ export const delegateTaskCapability = {
213
213
  key: 'task_delegate',
214
214
  names: { sdk: 'task_delegate', mcp: 'ziggs_task_delegate' },
215
215
  title: 'Delegate work',
216
- descriptions: { sdk: 'Create an isolated child from approved instruction and input artifacts; return a completed child output after consent for the parent; or recheck readiness after approval. Keep the source execution selected. Child completion does not deliver its private result or model state. On create, if the destination cannot read a file yet, the call answers pending_approval: the server sent one card to each person who must say yes, and makes the child after the last yes. Do not call again or file access requests for those files. Recurses through ordinary tasks.' },
216
+ descriptions: { sdk: 'Create an isolated child from approved instruction and input artifacts; return a completed child output after consent for the parent; or recheck readiness after approval. Keep the source execution selected. Child completion does not deliver its private result or model state. On create, if the destination cannot read a file yet, the call answers pending_approval: the server sent one card to each person who must say yes, and makes the child after the last yes. Do not call again or file access requests for those files. Omit agreementId for a teammate or your owner\'s agent. Recurses through ordinary tasks.' },
217
217
  annotation: 'destructive',
218
218
  needsAgentId: true,
219
219
  params: {
220
220
  action: { type: 'string', required: true, enum: ['create', 'return', 'readiness'], description: 'Which step' },
221
221
  taskId: { type: 'string', required: true, description: 'Parent (create), child (return) or task (readiness)' },
222
- agreementId: { type: 'string', description: 'Child agreement (create)' },
222
+ agreementId: { type: 'string', description: 'Child agreement (create), if any' },
223
223
  assigneeId: { type: 'string', description: 'Child executor (create)' },
224
224
  instructionArtifactId: { type: 'string', description: 'Instructions (create)' },
225
225
  inputArtifactIds: { type: 'array', items: { type: 'string' }, description: 'Approved inputs (create)' },
@@ -242,7 +242,8 @@ export const delegateTaskCapability = {
242
242
  if (args.action !== 'create')
243
243
  throw new Error('action must be create, return or readiness');
244
244
  return delegateTask(taskId, {
245
- agreementId: required('agreementId'), assigneeId: required('assigneeId'),
245
+ ...(typeof args.agreementId === 'string' && args.agreementId.trim() ? { agreementId: args.agreementId } : {}),
246
+ assigneeId: required('assigneeId'),
246
247
  instructionArtifactId: required('instructionArtifactId'),
247
248
  inputArtifactIds: args.inputArtifactIds,
248
249
  idempotencyKey: args.idempotencyKey,
@@ -322,14 +322,15 @@ export interface HeldDelegation {
322
322
  message: string;
323
323
  }
324
324
  export declare function delegateTask(taskId: string, body: {
325
- agreementId: string;
325
+ /** The agreement the child work is done under; omit it for a teammate or an agent you run. */
326
+ agreementId?: string;
326
327
  assigneeId: string;
327
328
  instructionArtifactId: string;
328
329
  inputArtifactIds?: string[];
329
330
  idempotencyKey?: string;
330
331
  }, creds: Creds): Promise<{
331
332
  taskId: string;
332
- agreementId: string;
333
+ agreementId: string | null;
333
334
  parentTaskId: string;
334
335
  } | HeldDelegation>;
335
336
  export declare function returnTaskResult(taskId: string, artifactId: string, creds: Creds): Promise<{
package/dist/types.d.ts CHANGED
@@ -182,7 +182,6 @@ export interface AgreementApprovalEntry {
182
182
  heldReason?: string | null;
183
183
  }
184
184
  export interface Agreement {
185
- publishedService?: boolean;
186
185
  approvalAction?: {
187
186
  state: 'available' | 'needs_decision' | 'unavailable';
188
187
  partyId?: string;
@@ -262,12 +261,6 @@ export interface Agreement {
262
261
  * resumed, and hires already sold from it keep running.
263
262
  */
264
263
  listingPausedAt?: string | null;
265
- /**
266
- * the provider slot is FIXED (a hand-off): claiming or
267
- * approving this makes you the party the work is done FOR, not the worker —
268
- * and, when priced, the payer.
269
- */
270
- providerPinned?: boolean;
271
264
  metadata?: Record<string, unknown>;
272
265
  createdAt?: string;
273
266
  updatedAt?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ziggs-ai/api-client",
3
- "version": "0.42.22",
3
+ "version": "0.42.24",
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.53.5",
34
+ "@ziggs-ai/contracts": "0.55.0",
35
35
  "socket.io-client": "^4.7.0"
36
36
  },
37
37
  "keywords": [