@ziggs-ai/api-client 0.42.20 → 0.42.22

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,19 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.42.22
6
+
7
+ - `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.
8
+
9
+ ## 0.42.21
10
+
11
+ - `page` posts a page: a live view, tracker or form, in a bucket (`bucketId`) or to the people it is for (`to`); `replaces` posts a new version. `page_guide` stays the read-only how-to.
12
+ - `bucket_send` and `message_send` no longer take `page`, `pageName` or `forms`. Post a page with `page`. `formEntry` (answering a page's form) stays on both.
13
+ - `task_create` children take `agreementId` as optional, like the task itself. The tool text says who can be given a task without one.
14
+ - `task_pass_on` says a task under no agreement goes to a teammate or an agent you run.
15
+ - `AssistantConnectionClient.roster()` returns the connection's workspaces and the person it is for.
16
+ - `people` finds teammates by name, with the id a task or a message needs.
17
+
5
18
  ## 0.42.20
6
19
 
7
20
  - `access_request` takes its `scopeKind` list from `@ziggs-ai/contracts` `ACCESS_REQUEST_SCOPE_KINDS`, and passes `connectionTools` (a connection) and `spendingMaxAmount` (a wallet, hundredths of a point) through.
@@ -8,6 +8,13 @@ export declare const bucketDuplicateCapability: CapabilityDefinition;
8
8
  export declare const bucketAddMembersCapability: CapabilityDefinition;
9
9
  export declare const bucketJoinCapability: CapabilityDefinition;
10
10
  export declare const bucketSendCapability: CapabilityDefinition;
11
+ /**
12
+ * A page: a thread shown as HTML instead of messages. Its own tool, so an
13
+ * agent asked for a view, a tracker or a form finds it by name. How to write
14
+ * one is the read-only page_guide; this posts it, in a bucket or straight to
15
+ * the people it is for, and posts its new versions.
16
+ */
17
+ export declare const pageCapability: CapabilityDefinition;
11
18
  export declare const bucketRemoveMemberCapability: CapabilityDefinition;
12
19
  export declare const bucketRenameCapability: CapabilityDefinition;
13
20
  export declare const bucketDeleteCapability: CapabilityDefinition;
@@ -1,5 +1,6 @@
1
1
  import { BucketsClient, BUCKET_ITEM_KINDS, } from '../http/BucketsClient.js';
2
2
  import { ArtifactsClient } from '../http/ArtifactsClient.js';
3
+ import { MessageRecordsClient } from '../http/MessageRecordsClient.js';
3
4
  import { fullCreds, rethrowWithContext } from './types.js';
4
5
  import { pageGuideCapability } from './pageGuide.js';
5
6
  /**
@@ -32,6 +33,7 @@ const SHARE = {
32
33
  type: 'boolean',
33
34
  description: 'Share misfits first.',
34
35
  };
36
+ const FORMS = { type: 'array', description: 'The page\'s forms, fields and choices.', items: { type: 'object', required: ['name', 'fields'], properties: { name: { type: 'string' }, fields: { type: 'array', items: { type: 'object', properties: { name: { type: 'string' }, label: { type: 'string' }, choices: { type: 'array', items: { type: 'string' } }, freeText: { type: 'boolean' } } } } } } };
35
37
  const AUDIENCE = {
36
38
  type: 'array',
37
39
  description: 'Other person, agent or workspace ids.',
@@ -75,12 +77,19 @@ async function run(label, work) {
75
77
  rethrowWithContext(e, label);
76
78
  }
77
79
  }
80
+ /** Put who can read it first in the answer, as a fact. */
81
+ function hoistReaders(result) {
82
+ if (!result || typeof result !== 'object' || !('readers' in result))
83
+ return result;
84
+ const { readers, ...rest } = result;
85
+ return { readers, ...rest };
86
+ }
78
87
  export const bucketCreateCapability = {
79
88
  key: 'bucket_create',
80
89
  names: { sdk: 'bucket_create', mcp: 'ziggs_bucket_create' },
81
90
  title: 'Create a bucket',
82
91
  descriptions: {
83
- sdk: 'Create a bucket: a working set whose whole audience can read every item in it. You are always in it. Items given here go in exactly as bucket_insert puts them.',
92
+ sdk: 'Create a bucket: a working set whose whole audience can read every item in it. You are always in it. The answer names who can read it. A workspace id is everyone in that workspace. With no audience, only you can see it. Items given here go in exactly as bucket_insert puts them.',
84
93
  },
85
94
  annotation: 'write',
86
95
  needsAgentId: true,
@@ -90,12 +99,12 @@ export const bucketCreateCapability = {
90
99
  items: { ...ITEMS, required: false },
91
100
  share: SHARE,
92
101
  },
93
- handler: (args, env) => run('bucket_create', () => client(env).create({
102
+ handler: (args, env) => run('bucket_create', async () => hoistReaders(await client(env).create({
94
103
  name: String(args['name'] ?? ''),
95
104
  ...(args['audience'] !== undefined ? { audience: principals(args['audience'], 'audience') } : {}),
96
105
  ...(args['items'] !== undefined ? { items: items(args) } : {}),
97
106
  ...(args['share'] === true ? { share: true } : {}),
98
- })),
107
+ }))),
99
108
  };
100
109
  export const bucketListCapability = {
101
110
  key: 'bucket_list',
@@ -238,19 +247,13 @@ export const bucketSendCapability = {
238
247
  names: { sdk: 'bucket_send', mcp: 'ziggs_bucket_send' },
239
248
  title: 'Send in a bucket',
240
249
  descriptions: {
241
- sdk: "Send a message inside a bucket. Its readers are the bucket's people; with replyTo, also readers of the answered message who have it in a bucket. A reply that reaches someone new to its thread also shares the earlier messages your side wrote there with them, and asks each other writer to share theirs. Name recipients among the readers. To reach anyone else, add them with bucket_add_members first. A request wakes the agents it is delivered to. With page, the message carries an HTML page: its thread shows as that page.",
250
+ sdk: "Send a message inside a bucket. Its readers are the bucket's people; with replyTo, also readers of the answered message who have it in a bucket. The answer names who can read it. A reply that reaches someone new to its thread also shares the earlier messages your side wrote there with them, and asks each other writer to share theirs. Name recipients among the readers. To reach anyone else, add them with bucket_add_members first. A request wakes the agents it is delivered to. A page is made with page.",
242
251
  },
243
252
  annotation: 'destructive',
244
253
  needsAgentId: true,
245
254
  params: {
246
255
  bucketId: BUCKET_ID,
247
256
  text: { type: 'string', required: true },
248
- page: {
249
- type: 'string',
250
- description: "Read page_guide (MCP: ziggs_page_guide) before writing a page. A full HTML document (<!DOCTYPE html>), saved as a file that goes with the message. Without replyTo it starts a thread of its own, shown as the page; with replyTo that page's first message, it is its new version (the page's side only).",
251
- },
252
- pageName: { type: 'string', description: 'Short, stable name of the page.' },
253
- forms: { type: 'array', description: 'With page: the page\'s forms, fields and choices.', items: { type: 'object', required: ['name', 'fields'], properties: { name: { type: 'string' }, fields: { type: 'array', items: { type: 'object', properties: { name: { type: 'string' }, label: { type: 'string' }, choices: { type: 'array', items: { type: 'string' } }, freeText: { type: 'boolean' } } } } } } },
254
257
  formEntry: { type: 'object', description: 'Reply to the page version filled; goes to its poster.', properties: { form: { type: 'string', required: true }, fields: { type: 'object' } } },
255
258
  recipients: {
256
259
  type: 'array',
@@ -258,7 +261,7 @@ export const bucketSendCapability = {
258
261
  description: 'Who is told, among the readers. Under work, name at least one person the work is with.',
259
262
  },
260
263
  intent: { type: 'string', enum: ['fyi', 'request'] },
261
- replyTo: { type: 'string', description: 'The message this answers. Not for a new page.' },
264
+ replyTo: { type: 'string', description: 'The message this answers.' },
262
265
  operationId: { type: 'string', description: 'Reuse on retry.' },
263
266
  agreementId: {
264
267
  type: 'string',
@@ -278,22 +281,74 @@ export const bucketSendCapability = {
278
281
  throw new Error('replyTo is a message id');
279
282
  const named = args['operationId'];
280
283
  const operationId = typeof named === 'string' && named.trim() ? named.trim() : `bucket-send-${globalThis.crypto.randomUUID()}`;
281
- const page = await pageOf(args, env, operationId);
282
- const sent = await client(env).sendMessage(bucketId(args), {
284
+ return hoistReaders(await client(env).sendMessage(bucketId(args), {
283
285
  operationId,
284
286
  content: { text },
285
287
  deliveries: { kind: 'explicit', principalIds: principals(args['recipients'], 'recipients') ?? [] },
286
288
  intent,
287
289
  ...(typeof replyTo === 'string' ? { relationships: { replyToMessageId: replyTo.trim() } } : {}),
288
290
  ...mandateOf(args, env),
289
- // The message carries the page. Without replyTo it starts a thread of
290
- // its own. Whoever reads the message opens the page: no share needed.
291
- ...(page ? { page } : {}),
292
- // Passed as given: forms without a page is refused by the server, with why.
293
- ...(Array.isArray(args['forms']) ? { forms: args['forms'] } : {}),
294
291
  ...(args['formEntry'] && typeof args['formEntry'] === 'object' ? { formEntry: args['formEntry'] } : {}),
295
- });
296
- return page ? { ...sent, page: { artifactId: page.id, address: `/pages/${sent.message.rootMessageId}` } } : sent;
292
+ }));
293
+ }),
294
+ };
295
+ /**
296
+ * A page: a thread shown as HTML instead of messages. Its own tool, so an
297
+ * agent asked for a view, a tracker or a form finds it by name. How to write
298
+ * one is the read-only page_guide; this posts it, in a bucket or straight to
299
+ * the people it is for, and posts its new versions.
300
+ */
301
+ export const pageCapability = {
302
+ key: 'page',
303
+ names: { sdk: 'page', mcp: 'ziggs_page' },
304
+ title: 'Post a page',
305
+ descriptions: {
306
+ sdk: 'Post a page: a live view, tracker or form people open in Ziggs. Read page_guide first. It goes in a bucket (bucketId) or to the people it is for (to). replaces posts a new version of your page.',
307
+ },
308
+ annotation: 'destructive',
309
+ needsAgentId: true,
310
+ params: {
311
+ html: { type: 'string', required: true, description: 'A full HTML document (<!DOCTYPE html>), written as page_guide says.' },
312
+ name: { type: 'string', required: true, description: 'Short, stable name of the page.' },
313
+ text: { type: 'string', description: 'One line saying what the page is. Defaults to its name.' },
314
+ bucketId: { type: 'string', description: 'The bucket it goes in; everyone in it can open it.' },
315
+ to: { type: 'array', items: { type: 'string' }, description: 'Who it is for: they can open it and are told. In a bucket, among its people.' },
316
+ replaces: { type: 'string', description: 'The first message of a page you posted: this is its new version.' },
317
+ forms: FORMS,
318
+ operationId: { type: 'string', description: 'Reuse on retry.' },
319
+ },
320
+ // Work under an agreement keeps its mandate: the one the wake is under.
321
+ handler: (args, env) => run('page', async () => {
322
+ const named = args['operationId'];
323
+ const operationId = typeof named === 'string' && named.trim() ? named.trim() : `page-send-${globalThis.crypto.randomUUID()}`;
324
+ const page = await pageOf(args['html'], args['name'], env, operationId);
325
+ const name = String(args['name']).trim();
326
+ const said = args['text'];
327
+ const text = typeof said === 'string' && said.trim() ? said.trim() : name;
328
+ const to = principals(args['to'], 'to') ?? [];
329
+ const replaces = args['replaces'];
330
+ if (replaces !== undefined && (typeof replaces !== 'string' || !replaces.trim()))
331
+ throw new Error('replaces is the first message of your page');
332
+ const inThread = typeof replaces === 'string' ? { relationships: { replyToMessageId: replaces.trim() } } : {};
333
+ const forms = Array.isArray(args['forms']) ? { forms: args['forms'] } : {};
334
+ const inBucket = typeof args['bucketId'] === 'string' && args['bucketId'].trim();
335
+ if (!inBucket && !to.length)
336
+ throw new Error('Name where the page goes: bucketId, or to with who it is for');
337
+ let sent;
338
+ if (inBucket) {
339
+ sent = await client(env).sendMessage(bucketId(args), {
340
+ operationId, content: { text }, deliveries: { kind: 'explicit', principalIds: to }, intent: 'fyi',
341
+ ...inThread, ...mandateOf(args, env), page, ...forms,
342
+ });
343
+ }
344
+ else {
345
+ const creds = fullCreds(env);
346
+ sent = await new MessageRecordsClient(creds.operatorKey, creds.agentId, env.baseUrl).send({
347
+ operationId, content: { text }, audience: { kind: 'explicit', principalIds: to }, deliveries: { kind: 'explicit', principalIds: to }, intent: 'fyi',
348
+ ...inThread, ...mandateOf(args, env), page, ...forms,
349
+ });
350
+ }
351
+ return { ...sent, page: { artifactId: page.id, address: `/pages/${sent.message.rootMessageId}` } };
297
352
  }),
298
353
  };
299
354
  /**
@@ -301,16 +356,13 @@ export const bucketSendCapability = {
301
356
  * exact version. The file is saved under the same retry identity as the
302
357
  * message, so a retry links the same file.
303
358
  */
304
- async function pageOf(args, env, operationId) {
305
- const html = args['page'];
306
- if (html === undefined)
307
- return null;
359
+ async function pageOf(html, pageName, env, operationId) {
308
360
  if (typeof html !== 'string' || !/^\s*(?:<!doctype\s+html|<html)(?:\s|>)/i.test(html)) {
309
- throw new Error('page is a full HTML document starting with <!DOCTYPE html>');
361
+ throw new Error('html is a full HTML document starting with <!DOCTYPE html>');
310
362
  }
311
- const name = typeof args['pageName'] === 'string' ? args['pageName'].trim() : '';
363
+ const name = typeof pageName === 'string' ? pageName.trim() : '';
312
364
  if (!name)
313
- throw new Error('pageName is required with page');
365
+ throw new Error('name is required');
314
366
  const creds = fullCreds(env);
315
367
  // The stored text is trimmed; the link names exactly what is stored.
316
368
  const text = html.trim();
@@ -387,6 +439,7 @@ export const bucketDeleteCapability = {
387
439
  };
388
440
  export const BUCKET_CAPABILITIES = [
389
441
  pageGuideCapability,
442
+ pageCapability,
390
443
  bucketCreateCapability,
391
444
  bucketListCapability,
392
445
  bucketReadCapability,
@@ -1,4 +1,11 @@
1
1
  import { type CapabilityDefinition } from './types.js';
2
2
  export declare const agentSearchCapability: CapabilityDefinition;
3
3
  export declare const agentGetCapability: CapabilityDefinition;
4
+ /**
5
+ * Teammates by name. A person asks for "Ana", never for an id; without this
6
+ * an assistant had no way from the name to the id a task or a message needs,
7
+ * and asked its person for the id instead. The same match agent_search makes
8
+ * for teammates, on its own tool so it is found by what it does.
9
+ */
10
+ export declare const peopleCapability: CapabilityDefinition;
4
11
  export declare const DISCOVERY_CAPABILITIES: CapabilityDefinition[];
@@ -111,9 +111,40 @@ export const agentGetCapability = {
111
111
  return { agent };
112
112
  },
113
113
  };
114
+ /**
115
+ * Teammates by name. A person asks for "Ana", never for an id; without this
116
+ * an assistant had no way from the name to the id a task or a message needs,
117
+ * and asked its person for the id instead. The same match agent_search makes
118
+ * for teammates, on its own tool so it is found by what it does.
119
+ */
120
+ export const peopleCapability = {
121
+ key: 'people',
122
+ names: { sdk: 'people', mcp: 'ziggs_people' },
123
+ title: 'Find people',
124
+ descriptions: {
125
+ sdk: 'Finds teammates in your workspace by name, with the id a task or a message needs. Your own person is not listed: the session read names them.',
126
+ },
127
+ annotation: 'read-only',
128
+ params: {
129
+ name: { type: 'string', required: true, description: 'All or part of their name.' },
130
+ },
131
+ needsAgentId: true,
132
+ handler: async (args, env) => {
133
+ const name = typeof args['name'] === 'string' ? args['name'].trim() : '';
134
+ if (!name)
135
+ throw new Error('name is required');
136
+ const creds = fullCreds(env);
137
+ const result = await new AgentSearchClient(creds.operatorKey, creds.agentId).searchAgents(name, { limit: 1 });
138
+ if (!result.success)
139
+ throw new Error(result.error ?? result.message ?? 'search failed');
140
+ const people = (result.people ?? []).map((p) => ({ id: p.userId, name: p.displayName }));
141
+ return people.length ? { people } : { people, note: `No teammate's name matches "${name}".` };
142
+ },
143
+ };
114
144
  export const DISCOVERY_CAPABILITIES = [
115
145
  agentSearchCapability,
116
146
  agentGetCapability,
147
+ peopleCapability,
117
148
  ];
118
149
  function withHire(agent, hired) {
119
150
  const hires = hired.byAgent.get(agent.agentId);
@@ -14,10 +14,10 @@ export { AGREEMENT_PROPOSE_PROVIDER_ID_DESCRIPTION } from './proposeProviderId.j
14
14
  export { MARKETPLACE_CAPABILITIES, marketplaceViewCapability } from './marketplace.js';
15
15
  export { GRANTS_CAPABILITIES, listGrantsCapability } from './grants.js';
16
16
  export { PAGE_GUIDE, pageGuideCapability } from './pageGuide.js';
17
- export { BUCKET_CAPABILITIES, bucketCreateCapability, bucketListCapability, bucketReadCapability, bucketInsertCapability, bucketRemoveCapability, bucketAddMembersCapability, bucketJoinCapability, bucketSendCapability, bucketRemoveMemberCapability, bucketDuplicateCapability, bucketRenameCapability, bucketDeleteCapability, } from './buckets.js';
17
+ export { BUCKET_CAPABILITIES, bucketCreateCapability, bucketListCapability, bucketReadCapability, bucketInsertCapability, bucketRemoveCapability, bucketAddMembersCapability, bucketJoinCapability, bucketSendCapability, pageCapability, bucketRemoveMemberCapability, bucketDuplicateCapability, bucketRenameCapability, bucketDeleteCapability, } from './buckets.js';
18
18
  export { CONTEXT_CAPABILITIES, contextCallersCapability, contextReadCapability, openCapability, accessExplainCapability, contextDelegateCapability, accessRequestCapability, contextExpandReachCapability, contextDiscoverGrantableCapability, contextBounds, resolveOrgScopeId, explainRefusedRead, RESOURCE_HIDDEN_MESSAGE, RESOURCE_UNREADABLE_MESSAGE, type RefusedRead, } from './context.js';
19
19
  export { CONNECTION_CAPABILITIES, connectionProxyCapability, requestConnectionCapability, } from './connections.js';
20
- export { DISCOVERY_CAPABILITIES, agentSearchCapability, agentGetCapability, } from './discovery.js';
20
+ export { DISCOVERY_CAPABILITIES, agentSearchCapability, agentGetCapability, peopleCapability, } from './discovery.js';
21
21
  export { ARTIFACT_CAPABILITIES, recordArtifactCapability, listArtifactsCapability, findArtifactsCapability, type UnsearchedContext, attachArtifactCapability, reviewArtifactContributionCapability, contributeArtifactCapability, uploadArtifactUrlCapability, completeArtifactFileCapability, downloadArtifactCapability, reextractArtifactCapability, } from './artifacts.js';
22
22
  export { EVERYDAY_MCP_TOOLS, EVERYDAY_NO_SDK_TWIN, EVERYDAY_SDK_ONLY, EVERYDAY_SDK_TOOLS, } from './everyday.js';
23
23
  export { annotationForSdkTool } from './toolLane.js';
@@ -14,10 +14,10 @@ export { AGREEMENT_PROPOSE_PROVIDER_ID_DESCRIPTION } from './proposeProviderId.j
14
14
  export { MARKETPLACE_CAPABILITIES, marketplaceViewCapability } from './marketplace.js';
15
15
  export { GRANTS_CAPABILITIES, listGrantsCapability } from './grants.js';
16
16
  export { PAGE_GUIDE, pageGuideCapability } from './pageGuide.js';
17
- export { BUCKET_CAPABILITIES, bucketCreateCapability, bucketListCapability, bucketReadCapability, bucketInsertCapability, bucketRemoveCapability, bucketAddMembersCapability, bucketJoinCapability, bucketSendCapability, bucketRemoveMemberCapability, bucketDuplicateCapability, bucketRenameCapability, bucketDeleteCapability, } from './buckets.js';
17
+ export { BUCKET_CAPABILITIES, bucketCreateCapability, bucketListCapability, bucketReadCapability, bucketInsertCapability, bucketRemoveCapability, bucketAddMembersCapability, bucketJoinCapability, bucketSendCapability, pageCapability, bucketRemoveMemberCapability, bucketDuplicateCapability, bucketRenameCapability, bucketDeleteCapability, } from './buckets.js';
18
18
  export { CONTEXT_CAPABILITIES, contextCallersCapability, contextReadCapability, openCapability, accessExplainCapability, contextDelegateCapability, accessRequestCapability, contextExpandReachCapability, contextDiscoverGrantableCapability, contextBounds, resolveOrgScopeId, explainRefusedRead, RESOURCE_HIDDEN_MESSAGE, RESOURCE_UNREADABLE_MESSAGE, } from './context.js';
19
19
  export { CONNECTION_CAPABILITIES, connectionProxyCapability, requestConnectionCapability, } from './connections.js';
20
- export { DISCOVERY_CAPABILITIES, agentSearchCapability, agentGetCapability, } from './discovery.js';
20
+ export { DISCOVERY_CAPABILITIES, agentSearchCapability, agentGetCapability, peopleCapability, } from './discovery.js';
21
21
  export { ARTIFACT_CAPABILITIES, recordArtifactCapability, listArtifactsCapability, findArtifactsCapability, attachArtifactCapability, reviewArtifactContributionCapability, contributeArtifactCapability, uploadArtifactUrlCapability, completeArtifactFileCapability, downloadArtifactCapability, reextractArtifactCapability, } from './artifacts.js';
22
22
  export { EVERYDAY_MCP_TOOLS, EVERYDAY_NO_SDK_TWIN, EVERYDAY_SDK_ONLY, EVERYDAY_SDK_TOOLS, } from './everyday.js';
23
23
  export { annotationForSdkTool } from './toolLane.js';
@@ -206,7 +206,7 @@ const BRIEFS = {
206
206
  },
207
207
  // Tasks
208
208
  ziggs_task_create: {
209
- does: 'Creates a task under an active agreement, or a job with its children in one call. plan sets its checklist.',
209
+ does: 'Gives someone a task: your person, a teammate, an agent you run, or anyone under an agreement. dueAt and checkBack set the chasing. Children make a job.',
210
210
  changes: 'creates the tasks and notifies their assignees',
211
211
  },
212
212
  ziggs_task_get: {
@@ -216,7 +216,7 @@ const BRIEFS = {
216
216
  does: 'Lists tasks you can reach. assignedToMe and createdByMe filter them.',
217
217
  },
218
218
  ziggs_task_pass_on: {
219
- does: 'Makes someone else the assignee of a live task you work or opened, so only they can finish it. They must be able to work under its agreement, which stays.',
219
+ does: 'Makes someone else the assignee of a live task you work or opened, so only they can finish it. Its agreement, if any, stays; with none, a teammate or an agent you run.',
220
220
  changes: 'the assignee; the previous one loses write on the task',
221
221
  },
222
222
  ziggs_task_update_steps: {
@@ -241,7 +241,10 @@ const BRIEFS = {
241
241
  },
242
242
  // Agents, links and introductions
243
243
  ziggs_agent_search: {
244
- does: 'Finds agents in the store, your workspaces and your own; teammates come back as people; people you are connected with are in ziggs_link_list. A row you hire says already hired and names that agreement and workspace.',
244
+ does: 'Finds agents in the store, your workspaces and your own. A row you hire says already hired and names that agreement and workspace. People are found with ziggs_people.',
245
+ },
246
+ ziggs_people: {
247
+ does: 'Finds teammates in your workspace by name, with the id a task or a message needs. ziggs_auth_status names your own person.',
245
248
  },
246
249
  ziggs_agent_get: {
247
250
  does: 'Reads one agent’s profile by exact id, with how to hire it: listingAgreementId to claim, acceptsProposals for a direct proposal.',
@@ -298,8 +301,9 @@ const BRIEFS = {
298
301
  },
299
302
  // Buckets: pointers to items and people; access is computed from the items' grants.
300
303
  ziggs_bucket_create: {
301
- does: 'Creates a bucket, with items if given.',
304
+ does: 'Creates a bucket: people or a workspace (everyone in it). Empty is only you.',
302
305
  changes: 'creates it with what fits',
306
+ returns: 'who can read it, by name',
303
307
  },
304
308
  ziggs_bucket_list: {
305
309
  does: 'Lists the buckets you are in.',
@@ -330,12 +334,17 @@ const BRIEFS = {
330
334
  ziggs_page_guide: {
331
335
  does: 'Returns how to build a page that works: window.ziggs, forms, feeding, and the fallback text.',
332
336
  when: 'before writing a page',
333
- next: 'ziggs_bucket_send with page',
337
+ next: 'ziggs_page',
338
+ },
339
+ ziggs_page: {
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
+ when: 'after ziggs_page_guide',
342
+ changes: 'posts it; they are told',
334
343
  },
335
344
  ziggs_bucket_send: {
336
- does: "Sends inside a bucket, to its people and the readers of replyTo.",
337
- when: 'a page, after ziggs_page_guide',
345
+ does: 'Sends inside a bucket, to its people and the readers of replyTo.',
338
346
  changes: 'sends it',
347
+ returns: 'who can read it, by name',
339
348
  },
340
349
  ziggs_bucket_rename: {
341
350
  does: 'Renames a bucket. Its creator does this.',
@@ -3,7 +3,8 @@ export declare const readMessageCapability: CapabilityDefinition;
3
3
  /**
4
4
  * The command's real shape, the same keys the server accepts (contracts
5
5
  * `parseMessageCommand`), so a caller sees it in the schema and a wrong key is
6
- * refused by name before it is sent.
6
+ * refused by name before it is sent. A page is posted with the page tool,
7
+ * which saves its HTML and links that version; it is not hand-built here.
7
8
  */
8
9
  export declare const MESSAGE_COMMAND_PARAM: CapabilityParam;
9
10
  export declare const sendMessageCapability: CapabilityDefinition;
@@ -6,7 +6,8 @@ const principals = { type: 'object', required: true, properties: { kind: { type:
6
6
  /**
7
7
  * The command's real shape, the same keys the server accepts (contracts
8
8
  * `parseMessageCommand`), so a caller sees it in the schema and a wrong key is
9
- * refused by name before it is sent.
9
+ * refused by name before it is sent. A page is posted with the page tool,
10
+ * which saves its HTML and links that version; it is not hand-built here.
10
11
  */
11
12
  export const MESSAGE_COMMAND_PARAM = { type: 'object', required: true, properties: {
12
13
  operationId: { type: 'string', required: true, description: 'Reuse on retry.' },
@@ -17,8 +18,6 @@ export const MESSAGE_COMMAND_PARAM = { type: 'object', required: true, propertie
17
18
  mandate: { type: 'object', properties: { agreementId: { type: 'string', required: true }, taskId: { type: 'string' } } },
18
19
  relationships: { type: 'object', properties: { replyToMessageId: { type: 'string' }, taskIds: { type: 'array', items: { type: 'string' } }, artifacts: { type: 'array', items: { type: 'object' } } } },
19
20
  sources: { type: 'array', items: { type: 'object' } },
20
- page: { type: 'object', properties: { kind: { type: 'string', enum: ['artifact'], required: true }, id: { type: 'string', required: true }, sha256: { type: 'string', required: true } } },
21
- forms: { type: 'array', description: 'With page: the page\'s forms, fields and choices.', items: { type: 'object', required: ['name', 'fields'], properties: { name: { type: 'string' }, fields: { type: 'array', items: { type: 'object', properties: { name: { type: 'string' }, label: { type: 'string' }, choices: { type: 'array', items: { type: 'string' } }, freeText: { type: 'boolean' } } } } } } },
22
21
  formEntry: { type: 'object', description: 'Reply to the page version filled; goes to its poster.', properties: { form: { type: 'string', required: true }, fields: { type: 'object' } } },
23
22
  } };
24
23
  export const sendMessageCapability = { key: 'message_send', names: { sdk: 'message_send', mcp: 'ziggs_message_send' }, title: 'Send message', descriptions: { sdk: 'Send the canonical command: operationId; content:{text}; audience:{kind:"explicit",principalIds:[...]}; deliveries:{kind:"explicit",principalIds:[...]}; intent:"fyi" or "request". A request wakes the agents it is delivered to; an fyi is delivered and filed, never woken on. Nothing records whether a request was answered: a reply is a message with relationships.replyToMessageId. Optional mandate:{agreementId,taskId}, relationships:{replyToMessageId,taskIds,artifacts}, exact sources. Send first messages and replies directly; no bucket is required. A reply that names a reader new to its thread also shares the earlier messages your side wrote there with them, and asks each other writer in it to share theirs; those stay closed to the new reader until that writer says yes. Buckets optionally organize messages and do not determine access on this route. Reuse operationId unchanged on retry. Refused with "Nothing authorizes giving … access to this message" means you have no contact basis for that reader (membership, a link, an agreement or a listing): ask its owner with access_request scopeKind=contact and scopeId=that reader, then send once they approve.' }, annotation: 'destructive', needsAgentId: true, params: { command: MESSAGE_COMMAND_PARAM }, handler: (args, env) => client(env).send(args.command) };
@@ -2,7 +2,7 @@ import type { CapabilityDefinition } from './types.js';
2
2
  /**
3
3
  * How to build a page that works. One text, returned by `page_guide` /
4
4
  * `ziggs_page_guide`. Every agent that writes a page reads it from here,
5
- * only when it is about to write one.
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 or a form,\n post one: bucket_send in the bucket you work in, with page (a complete HTML document that\n starts with <!DOCTYPE html>), pageName (short and stable) and a short text saying what it is,\n and no replyTo, even when you post it in answer to someone: a new page starts a thread of its\n own, and that thread is the page. Name whoever asked in recipients so they are told.\n Everyone in the bucket opens that thread as the page. Its own address is the result's\n page.address (/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: bucket_send with replyTo the page's first\n message, the same pageName and the new page. The newest page you posted in the thread is the\n one shown, and open pages switch on their own. Only you, the 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 bucket_send with replyTo the page's message, 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- 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;
@@ -1,23 +1,24 @@
1
1
  /**
2
2
  * How to build a page that works. One text, returned by `page_guide` /
3
3
  * `ziggs_page_guide`. Every agent that writes a page reads it from here,
4
- * only when it is about to write one.
4
+ * only when it is about to write one, and posts it with `page` / `ziggs_page`.
5
5
  */
6
6
  export const PAGE_GUIDE = `LIVE HTML PAGES
7
- - A page is a thread shown as HTML instead of messages. When asked for a live view or a form,
8
- post one: bucket_send in the bucket you work in, with page (a complete HTML document that
9
- starts with <!DOCTYPE html>), pageName (short and stable) and a short text saying what it is,
10
- and no replyTo, even when you post it in answer to someone: a new page starts a thread of its
11
- own, and that thread is the page. Name whoever asked in recipients so they are told.
12
- Everyone in the bucket opens that thread as the page. Its own address is the result's
13
- page.address (/pages/<thread>); use it, never invent one.
7
+ - A page is a thread shown as HTML instead of messages. When asked for a live view, a tracker
8
+ or a form, post one with page: html (a complete HTML document that starts with
9
+ <!DOCTYPE html>), name (short and stable) and a short text saying what it is. Put it in the
10
+ bucket you work in (bucketId), or send it to the people it is for (to). Name whoever asked in
11
+ to so they are told. A new page starts a thread of its own, even when you post it in answer
12
+ to someone, and that thread is the page. Its own address is the result's page.address
13
+ (/pages/<thread>); use it, never invent one.
14
14
  - Post a page into the conversation it is for: a customer's bucket, a visitor's conversation.
15
15
  A page in the bucket your listing is invited into reaches everyone who comes in through the
16
16
  listing: each gets a bucket of their own with it, and their form entries stay there. Everything
17
17
  in that bucket goes to each newcomer, so keep it free of anything private.
18
- - To change a page, post the new one in the same thread: bucket_send with replyTo the page's first
19
- message, the same pageName and the new page. The newest page you posted in the thread is the
20
- one shown, and open pages switch on their own. Only you, the poster, can replace it.
18
+ - To change a page, post the new one in the same thread: page with replaces naming the page's
19
+ first message, the same name, the same bucketId or to, and the new html. The newest page you
20
+ posted in the thread is the one shown, and open pages switch on their own. Only you, the
21
+ poster, can replace it.
21
22
  - A page runs as the signed-in VIEWER, not you. Fetch every viewer's data when it opens. Never
22
23
  paste fetched tasks, agreements, messages, names or other private data into the HTML: everyone
23
24
  who reads the message can read those saved bytes.
@@ -59,7 +60,8 @@ export const PAGE_GUIDE = `LIVE HTML PAGES
59
60
 
60
61
  FEEDING A PAGE
61
62
  - Put your data on a page as replies in its thread, never by posting a new page for each change:
62
- bucket_send with replyTo the page's message, no recipients (nobody is told, nobody is woken),
63
+ a reply to the page's message (bucket_send with replyTo in its bucket, message_send with
64
+ relationships.replyToMessageId outside one), no recipients (nobody is told, nobody is woken),
63
65
  intent fyi, and text holding the data as JSON, for example {"feed":"ops","data":{...}}.
64
66
  Open pages get it through ziggs.on('change') or ziggs.list('message'); a page opened later
65
67
  reads it from the thread list.
@@ -83,7 +85,7 @@ export const pageGuideCapability = {
83
85
  names: { sdk: 'page_guide', mcp: 'ziggs_page_guide' },
84
86
  title: 'How to build a page',
85
87
  descriptions: {
86
- sdk: 'How to build a page that works: window.ziggs, forms, feeding the thread, and the fallback text. Read this before writing a page for bucket_send.',
88
+ sdk: 'How to build a page that works: window.ziggs, forms, feeding the thread, and the fallback text. Read this before writing a page, then post it with page.',
87
89
  },
88
90
  annotation: 'read-only',
89
91
  params: {},
@@ -109,7 +109,7 @@ export const passTaskOnCapability = {
109
109
  names: { sdk: 'task_pass_on', mcp: 'ziggs_task_pass_on' },
110
110
  title: 'Pass a task on',
111
111
  descriptions: {
112
- sdk: "Make someone else the assignee of a live task (PUT /tasks/:id/assignee), so only they can finish it. You may pass on a task you work or one you opened. The new assignee must be able to work under the task's agreement, for example another member of the workspace for a teammate's task. The agreement stays the same, and the previous assignee loses their write on the task.",
112
+ sdk: "Make someone else the assignee of a live task (PUT /tasks/:id/assignee), so only they can finish it. You may pass on a task you work or one you opened. Under an agreement, the new assignee must be able to work under it, and it stays the same. A task under none goes to a teammate or an agent you run. The previous assignee loses their write on the task.",
113
113
  },
114
114
  annotation: 'destructive',
115
115
  needsAgentId: true,
@@ -122,7 +122,7 @@ export const passTaskOnCapability = {
122
122
  assigneeId: {
123
123
  type: 'string',
124
124
  required: true,
125
- description: "Who works it from now on: a person or agent who can work under the task's agreement",
125
+ description: "Who works it from now on: under the task's agreement, someone who can work under it; with none, a teammate or an agent you run",
126
126
  },
127
127
  },
128
128
  handler: async (args, env) => {
@@ -46,6 +46,13 @@ export declare class AssistantConnectionClient {
46
46
  request<T>(path: string, body?: unknown, signal?: AbortSignal): Promise<T>;
47
47
  /** Read existing enabled assistant hires. Provisioning is an explicit sync action. */
48
48
  workspaces(): Promise<AssistantWorkspace[]>;
49
+ /** The workspaces, and the person the connection's assistant is for (null from a server that does not say). */
50
+ roster(): Promise<{
51
+ person: {
52
+ id: string;
53
+ } | null;
54
+ workspaces: AssistantWorkspace[];
55
+ }>;
49
56
  /** Which of the connection's assistants is on an existing thing. */
50
57
  resolve(kind: string, id: string): Promise<{
51
58
  workspace: AssistantWorkspace | null;
@@ -38,8 +38,12 @@ export class AssistantConnectionClient {
38
38
  }
39
39
  /** Read existing enabled assistant hires. Provisioning is an explicit sync action. */
40
40
  async workspaces() {
41
- return (await this.request('workspaces'))
42
- .workspaces;
41
+ return (await this.roster()).workspaces;
42
+ }
43
+ /** The workspaces, and the person the connection's assistant is for (null from a server that does not say). */
44
+ async roster() {
45
+ const read = await this.request('workspaces');
46
+ return { person: read.person?.id ? { id: read.person.id } : null, workspaces: read.workspaces };
43
47
  }
44
48
  /** Which of the connection's assistants is on an existing thing. */
45
49
  resolve(kind, id) {
@@ -52,7 +52,8 @@ export type PlanReviewTiming = 'with_proposal' | 'before_execution';
52
52
  */
53
53
  export interface CreateTaskChildData {
54
54
  name: string;
55
- agreementId: string;
55
+ /** The agreement it is done under. Left out, it goes to `assigneeId` the way a single task with none does. */
56
+ agreementId?: string;
56
57
  description: string;
57
58
  title?: string;
58
59
  assigneeId?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ziggs-ai/api-client",
3
- "version": "0.42.20",
3
+ "version": "0.42.22",
4
4
  "description": "HTTP and WebSocket client for the Ziggs backend API",
5
5
  "homepage": "https://ziggsai.com/docs",
6
6
  "bugs": {