@ziggs-ai/api-client 0.42.9 → 0.42.10
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 +10 -0
- package/dist/capabilities/buckets.js +5 -0
- package/dist/capabilities/context.js +1 -0
- package/dist/capabilities/messaging.js +3 -1
- package/dist/http/BucketsClient.d.ts +4 -129
- package/dist/http/BucketsClient.js +2 -6
- package/dist/http/ContextOpenClient.d.ts +2 -0
- package/dist/http/ContextOpenClient.js +3 -0
- package/dist/http/MessageRecordsClient.d.ts +2 -6
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.42.10
|
|
6
|
+
|
|
7
|
+
- Message pages, bucket views/contents/items, and form command fields come from `@ziggs-ai/contracts` 0.50.8 instead of a second copy. `message_send` and `bucket_send` publish the `PageForm` / `FormEntry` shape.
|
|
8
|
+
|
|
9
|
+
- `open` now sends `html: true` (it was accepted but dropped). `forms` and `formEntry` on `message_send` and `bucket_send` describe their shape, and `bucket_send` passes `forms` without a page through so the server says why it is refused.
|
|
10
|
+
|
|
11
|
+
- `open` on an HTML page returns its text (words, labels and options, no style or script) with `textOf: 'html'`; `html: true` returns the HTML as written.
|
|
12
|
+
|
|
13
|
+
- `message_send` and `bucket_send` take `forms` (with a page: its forms, fields and choices) and `formEntry` (`{form, fields}`, replying to the page version filled). The server checks an entry against that version's forms and sends it to the page's poster as a request.
|
|
14
|
+
|
|
5
15
|
## 0.42.9
|
|
6
16
|
|
|
7
17
|
- `bucket_send` with `page` says that a page sent as a reply is the page's new version, and only the page's side may send one.
|
|
@@ -249,6 +249,8 @@ export const bucketSendCapability = {
|
|
|
249
249
|
description: "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).",
|
|
250
250
|
},
|
|
251
251
|
pageName: { type: 'string', description: 'Short, stable name of the page.' },
|
|
252
|
+
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' } } } } } } },
|
|
253
|
+
formEntry: { type: 'object', description: 'Reply to the page version filled; goes to its poster.', properties: { form: { type: 'string', required: true }, fields: { type: 'object' } } },
|
|
252
254
|
recipients: {
|
|
253
255
|
type: 'array',
|
|
254
256
|
items: { type: 'string' },
|
|
@@ -286,6 +288,9 @@ export const bucketSendCapability = {
|
|
|
286
288
|
// The message carries the page. Without replyTo it starts a thread of
|
|
287
289
|
// its own. Whoever reads the message opens the page: no share needed.
|
|
288
290
|
...(page ? { page } : {}),
|
|
291
|
+
// Passed as given: forms without a page is refused by the server, with why.
|
|
292
|
+
...(Array.isArray(args['forms']) ? { forms: args['forms'] } : {}),
|
|
293
|
+
...(args['formEntry'] && typeof args['formEntry'] === 'object' ? { formEntry: args['formEntry'] } : {}),
|
|
289
294
|
});
|
|
290
295
|
return page ? { ...sent, page: { artifactId: page.id, address: `/pages/${sent.message.rootMessageId}` } } : sent;
|
|
291
296
|
}),
|
|
@@ -354,6 +354,7 @@ export const openCapability = {
|
|
|
354
354
|
cursor: { type: 'string', description: 'Opaque cursor from a prior open page' },
|
|
355
355
|
after: { type: 'string', description: 'ISO timestamp for a forward-delta' },
|
|
356
356
|
limit: { type: 'number', description: 'Page size' },
|
|
357
|
+
html: { type: 'boolean', description: 'A page comes as its text; true for its HTML' },
|
|
357
358
|
},
|
|
358
359
|
needsAgentId: true,
|
|
359
360
|
handler: async (args, env) => {
|
|
@@ -17,7 +17,9 @@ export const MESSAGE_COMMAND_PARAM = { type: 'object', required: true, propertie
|
|
|
17
17
|
mandate: { type: 'object', properties: { agreementId: { type: 'string', required: true }, taskId: { type: 'string' } } },
|
|
18
18
|
relationships: { type: 'object', properties: { replyToMessageId: { type: 'string' }, taskIds: { type: 'array', items: { type: 'string' } }, artifacts: { type: 'array', items: { type: 'object' } } } },
|
|
19
19
|
sources: { type: 'array', items: { type: 'object' } },
|
|
20
|
-
page: { 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
|
+
formEntry: { type: 'object', description: 'Reply to the page version filled; goes to its poster.', properties: { form: { type: 'string', required: true }, fields: { type: 'object' } } },
|
|
21
23
|
} };
|
|
22
24
|
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) };
|
|
23
25
|
export const readRepliesCapability = { key: 'message_replies', names: { sdk: 'message_replies', mcp: 'ziggs_message_replies' }, title: 'Read replies', descriptions: { sdk: 'Read currently authorized causal replies; links never grant access. Continue using nextCursor as before.' }, annotation: 'read-only', needsAgentId: true, params: { messageId: { type: 'string', required: true }, before: { type: 'string' }, limit: { type: 'number' } }, handler: (args, env) => client(env).replies(String(args.messageId), { before: args.before, limit: args.limit }) };
|
|
@@ -1,149 +1,24 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* agreement is not an item: it decides who is in a bucket (a hire brings its
|
|
5
|
-
* other side in, or invites them until it starts), never what is in it.
|
|
6
|
-
*/
|
|
7
|
-
export declare const BUCKET_ITEM_KINDS: readonly ["message", "artifact", "task"];
|
|
8
|
-
export type BucketItemKind = (typeof BUCKET_ITEM_KINDS)[number];
|
|
9
|
-
export interface BucketItemRef {
|
|
10
|
-
kind: BucketItemKind;
|
|
11
|
-
id: string;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* An item that does not fit where it was asked to go, or no longer fits where
|
|
15
|
-
* it is. Other members are named only when the caller can read the item.
|
|
16
|
-
*/
|
|
17
|
-
export type BucketMisfit = {
|
|
18
|
-
item: BucketItemRef;
|
|
19
|
-
reason: 'you-cannot-read';
|
|
20
|
-
} | {
|
|
21
|
-
item: BucketItemRef;
|
|
22
|
-
reason: 'members-cannot-read';
|
|
23
|
-
memberIds: string[];
|
|
24
|
-
};
|
|
1
|
+
import { BUCKET_ITEM_KINDS, type BucketAddMembersResult, type BucketContents, type BucketInsertResult, type BucketItemKind, type BucketItemPage, type BucketItemRef, type BucketMisfit, type BucketShare, type BucketThread, type BucketView, type MessageCommand, type MessageCommandResult } from '@ziggs-ai/contracts';
|
|
2
|
+
export { BUCKET_ITEM_KINDS };
|
|
3
|
+
export type { BucketAddMembersResult, BucketContents, BucketInsertResult, BucketItemKind, BucketItemPage, BucketItemRef, BucketMisfit, BucketShare, BucketThread, BucketView, };
|
|
25
4
|
/**
|
|
26
5
|
* What to do when someone being added cannot read an item: share it with
|
|
27
6
|
* them, or split: start a narrower bucket with them and only what everyone
|
|
28
7
|
* can read, leaving this one as it is.
|
|
29
8
|
*/
|
|
30
9
|
export type BucketMisfitChoice = 'share' | 'split';
|
|
31
|
-
export interface BucketView {
|
|
32
|
-
bucketId: string;
|
|
33
|
-
name: string;
|
|
34
|
-
createdBy: string;
|
|
35
|
-
/** Who it is for, as given: people, agents, workspaces. */
|
|
36
|
-
audience: string[];
|
|
37
|
-
/** Goes up when an item leaves or the audience changes. */
|
|
38
|
-
revision: number;
|
|
39
|
-
/** Items held; whether each still fits is computed when the items are read. */
|
|
40
|
-
itemCount: number;
|
|
41
|
-
createdAt: string | null;
|
|
42
|
-
}
|
|
43
|
-
/** One share made because the caller chose to share. */
|
|
44
|
-
export interface BucketShare {
|
|
45
|
-
item: BucketItemRef;
|
|
46
|
-
holderId: string;
|
|
47
|
-
/** `pending` waits for the item owner's yes; the item stays out until then. */
|
|
48
|
-
outcome: 'shared' | 'pending' | 'refused';
|
|
49
|
-
}
|
|
50
|
-
export interface BucketInsertResult {
|
|
51
|
-
bucket: BucketView;
|
|
52
|
-
inserted: BucketItemRef[];
|
|
53
|
-
alreadyIn: BucketItemRef[];
|
|
54
|
-
misfits: BucketMisfit[];
|
|
55
|
-
shared: BucketShare[];
|
|
56
|
-
}
|
|
57
|
-
export interface BucketAddMembersResult {
|
|
58
|
-
bucket: BucketView;
|
|
59
|
-
added: string[];
|
|
60
|
-
shared: BucketShare[];
|
|
61
|
-
/** The narrower bucket a split started, and what it holds. This bucket is left as it was. */
|
|
62
|
-
split: {
|
|
63
|
-
bucket: BucketView;
|
|
64
|
-
items: BucketItemRef[];
|
|
65
|
-
} | null;
|
|
66
|
-
}
|
|
67
10
|
export interface BucketJoinResult {
|
|
68
11
|
bucket: BucketView;
|
|
69
12
|
added: string[];
|
|
70
13
|
joined: BucketItemRef[];
|
|
71
14
|
shared: BucketShare[];
|
|
72
15
|
}
|
|
73
|
-
/** One thread in a bucket, as the reader sees it. */
|
|
74
|
-
export interface BucketThread {
|
|
75
|
-
rootMessageId: string;
|
|
76
|
-
title: string;
|
|
77
|
-
messageCount: number;
|
|
78
|
-
lastAt: string | null;
|
|
79
|
-
/** The reader wrote in it or it was delivered to them. */
|
|
80
|
-
yours: boolean;
|
|
81
|
-
/** The thread holding the message asked about as `current`. */
|
|
82
|
-
current: boolean;
|
|
83
|
-
/** The reader's own threads, other than the current one, come with their latest messages. */
|
|
84
|
-
recent?: Array<{
|
|
85
|
-
messageId: string;
|
|
86
|
-
from: string;
|
|
87
|
-
text: string;
|
|
88
|
-
at: string;
|
|
89
|
-
}>;
|
|
90
|
-
}
|
|
91
|
-
/** What is in a bucket as the reader can read it now: what a run starts from. */
|
|
92
|
-
export interface BucketContents {
|
|
93
|
-
bucket: {
|
|
94
|
-
bucketId: string;
|
|
95
|
-
name: string;
|
|
96
|
-
audience: string[];
|
|
97
|
-
revision: number;
|
|
98
|
-
};
|
|
99
|
-
threads: BucketThread[];
|
|
100
|
-
artifacts: Array<{
|
|
101
|
-
artifactId: string;
|
|
102
|
-
name: string | null;
|
|
103
|
-
}>;
|
|
104
|
-
tasks: Array<{
|
|
105
|
-
taskId: string;
|
|
106
|
-
title: string;
|
|
107
|
-
state: string;
|
|
108
|
-
}>;
|
|
109
|
-
/** The agreements the work here is under, worked out from the work. A chat brought in comes without its agreement. */
|
|
110
|
-
agreements: Array<{
|
|
111
|
-
agreementId: string;
|
|
112
|
-
title: string;
|
|
113
|
-
status: string;
|
|
114
|
-
}>;
|
|
115
|
-
/** Hires waiting for a yes whose people come in here when they start. */
|
|
116
|
-
invites: Array<{
|
|
117
|
-
agreementId: string;
|
|
118
|
-
title: string | null;
|
|
119
|
-
waitingFor: string[];
|
|
120
|
-
}>;
|
|
121
|
-
/** Items held that the reader cannot read here, as they ask now. */
|
|
122
|
-
outOfReach: number;
|
|
123
|
-
}
|
|
124
16
|
/**
|
|
125
17
|
* A message sent inside a bucket: its readers are the bucket's people, and for
|
|
126
18
|
* a reply that names the message it answers, those who read that message and
|
|
127
19
|
* have it in a bucket of theirs. Work goes in only with its other side here.
|
|
128
|
-
* `page` is the HTML file it carries, by its exact version (contracts 0.49).
|
|
129
20
|
*/
|
|
130
|
-
export type BucketMessage = Omit<MessageCommand, 'audience'
|
|
131
|
-
page?: {
|
|
132
|
-
kind: 'artifact';
|
|
133
|
-
id: string;
|
|
134
|
-
sha256: string;
|
|
135
|
-
};
|
|
136
|
-
};
|
|
137
|
-
export interface BucketItemPage {
|
|
138
|
-
/** Items everyone it is for can read right now. */
|
|
139
|
-
items: Array<BucketItemRef & {
|
|
140
|
-
addedBy: string;
|
|
141
|
-
addedAt: string | null;
|
|
142
|
-
}>;
|
|
143
|
-
/** Items held that someone it is for can no longer read. */
|
|
144
|
-
outOfReach: BucketMisfit[];
|
|
145
|
-
nextCursor: string | null;
|
|
146
|
-
}
|
|
21
|
+
export type BucketMessage = Omit<MessageCommand, 'audience'>;
|
|
147
22
|
/**
|
|
148
23
|
* The bucket operations (`/buckets`). A bucket is pointers to items and to who
|
|
149
24
|
* it is for; it stores no permission. Whether everyone can read each item is
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
+
import { BUCKET_ITEM_KINDS, } from '@ziggs-ai/contracts';
|
|
1
2
|
import { getBackendUrl } from '../utils/urlUtils.js';
|
|
2
3
|
import { throwApiError } from '../shared/apiError.js';
|
|
3
4
|
import { buildOperatorHeaders, withoutExecution } from './operatorHeaders.js';
|
|
4
|
-
|
|
5
|
-
* What a bucket can hold: the work. Each item is a pointer, never a copy. An
|
|
6
|
-
* agreement is not an item: it decides who is in a bucket (a hire brings its
|
|
7
|
-
* other side in, or invites them until it starts), never what is in it.
|
|
8
|
-
*/
|
|
9
|
-
export const BUCKET_ITEM_KINDS = ['message', 'artifact', 'task'];
|
|
5
|
+
export { BUCKET_ITEM_KINDS };
|
|
10
6
|
/**
|
|
11
7
|
* The bucket operations (`/buckets`). A bucket is pointers to items and to who
|
|
12
8
|
* it is for; it stores no permission. Whether everyone can read each item is
|
|
@@ -14,6 +14,8 @@ export interface ContextOpenBody {
|
|
|
14
14
|
cursor?: string;
|
|
15
15
|
after?: string;
|
|
16
16
|
limit?: number;
|
|
17
|
+
/** An HTML page comes as its text; true returns the HTML as written. */
|
|
18
|
+
html?: boolean;
|
|
17
19
|
}
|
|
18
20
|
/** Backend-evaluated action, scoped to a resource. Never a permission token. */
|
|
19
21
|
export interface ResourceActionCall {
|
|
@@ -74,5 +74,8 @@ export function normalizeContextOpenBody(args) {
|
|
|
74
74
|
body.after = args['after'];
|
|
75
75
|
if (typeof args['limit'] === 'number')
|
|
76
76
|
body.limit = args['limit'];
|
|
77
|
+
// A page opens as its text; html: true asks for it as written.
|
|
78
|
+
if (args['html'] === true)
|
|
79
|
+
body.html = true;
|
|
77
80
|
return body;
|
|
78
81
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MessageCommand, MessageCommandResult, MessageRecord, MessagingControls } from '@ziggs-ai/contracts';
|
|
1
|
+
import type { MessageCommand, MessageCommandResult, MessagePage, MessageRecord, MessagingControls } from '@ziggs-ai/contracts';
|
|
2
2
|
export interface MessageQuery {
|
|
3
3
|
conversationOf?: string;
|
|
4
4
|
q?: string;
|
|
@@ -10,10 +10,6 @@ export interface MessageQuery {
|
|
|
10
10
|
before?: string;
|
|
11
11
|
limit?: number;
|
|
12
12
|
}
|
|
13
|
-
export interface MessagePage {
|
|
14
|
-
messages: MessageRecord[];
|
|
15
|
-
nextCursor: string | null;
|
|
16
|
-
}
|
|
17
13
|
/** One command and one representation, independent of navigation. */
|
|
18
14
|
export declare class MessageRecordsClient {
|
|
19
15
|
private readonly operatorKey;
|
|
@@ -30,4 +26,4 @@ export declare class MessageRecordsClient {
|
|
|
30
26
|
}): Promise<MessagePage>;
|
|
31
27
|
controls(agreementId: string, taskId?: string): Promise<MessagingControls>;
|
|
32
28
|
}
|
|
33
|
-
export type { MessageCommand, MessageCommandResult, MessageRecord } from '@ziggs-ai/contracts';
|
|
29
|
+
export type { MessageCommand, MessageCommandResult, MessagePage, MessageRecord, ThreadCurrentPage } from '@ziggs-ai/contracts';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ziggs-ai/api-client",
|
|
3
|
-
"version": "0.42.
|
|
3
|
+
"version": "0.42.10",
|
|
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.50.
|
|
34
|
+
"@ziggs-ai/contracts": "0.50.8",
|
|
35
35
|
"socket.io-client": "^4.7.0"
|
|
36
36
|
},
|
|
37
37
|
"keywords": [
|