@ziggs-ai/api-client 0.42.6 → 0.42.8
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 +8 -0
- package/dist/capabilities/buckets.js +1 -1
- package/dist/capabilities/index.d.ts +1 -1
- package/dist/capabilities/index.js +1 -1
- package/dist/capabilities/mcpBriefs.js +4 -0
- package/dist/capabilities/tasks.d.ts +9 -0
- package/dist/capabilities/tasks.js +40 -1
- package/dist/http/BucketsClient.d.ts +3 -3
- package/dist/http/TaskClient.d.ts +26 -4
- package/dist/http/TaskClient.js +37 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.42.8
|
|
6
|
+
|
|
7
|
+
- `bucket_send` with `replyTo`: the reply is read by the bucket's people and by those who read the message it answers and have it in a bucket of theirs. Someone with no bucket for the chat is no longer written to from a bucket they are not in; telling them is refused (409 `NOT_IN_THIS_BUCKET`, with who), and adding them to the bucket is how. Work under an agreement goes into a bucket only with the agreement's other side in it (409 `WORK_SIDE_NOT_IN_BUCKET`, with who to add). `BucketContents.agreements` no longer carries `missing`.
|
|
8
|
+
|
|
9
|
+
## 0.42.7
|
|
10
|
+
|
|
11
|
+
- `passTaskOn(taskId, assigneeId)` and the `task_pass_on` capability pass live work on (`PUT /tasks/:taskId/assignee`): someone else becomes the assignee, so only they can finish it. Whoever works the task, or whoever opened it, may pass it on; the new assignee must be able to work under the task's agreement. The agreement stays the same.
|
|
12
|
+
|
|
5
13
|
## 0.42.6
|
|
6
14
|
|
|
7
15
|
- Messaging accepts first messages and replies without a bucket; SDK and MCP guidance keep readers and delivery independent from optional filing.
|
|
@@ -237,7 +237,7 @@ export const bucketSendCapability = {
|
|
|
237
237
|
names: { sdk: 'bucket_send', mcp: 'ziggs_bucket_send' },
|
|
238
238
|
title: 'Send in a bucket',
|
|
239
239
|
descriptions: {
|
|
240
|
-
sdk: "Send a message inside a bucket. Its readers are the bucket's people; with replyTo, also
|
|
240
|
+
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. 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.",
|
|
241
241
|
},
|
|
242
242
|
annotation: 'destructive',
|
|
243
243
|
needsAgentId: true,
|
|
@@ -9,7 +9,7 @@ export { LINK_CAPABILITIES, listLinksCapability, proposeLinkCapability, linkIsRe
|
|
|
9
9
|
export { INTRODUCTION_CAPABILITIES, mintIntroductionCapability, redeemIntroductionCapability, listIntroductionsCapability, revokeIntroductionCapability, } from './introductions.js';
|
|
10
10
|
export { AGREEMENT_CAPABILITIES, agreementClaimCapability, presentClaimResult, } from './agreements.js';
|
|
11
11
|
export { LIST_FIELDS_PARAM, parseListFields, pickListedRow, pickListedRows, listedFieldNote, } from './listedFields.js';
|
|
12
|
-
export { TASK_CAPABILITIES, listTasksCapability, cancelTaskCapability, delegateTaskCapability, presentTaskOutcome, type TaskOutcomeEffects, type TaskOutcomePresentation, } from './tasks.js';
|
|
12
|
+
export { TASK_CAPABILITIES, listTasksCapability, cancelTaskCapability, passTaskOnCapability, delegateTaskCapability, presentTaskOutcome, type TaskOutcomeEffects, type TaskOutcomePresentation, } from './tasks.js';
|
|
13
13
|
export { AGREEMENT_PROPOSE_PROVIDER_ID_DESCRIPTION } from './proposeProviderId.js';
|
|
14
14
|
export { MARKETPLACE_CAPABILITIES, marketplaceViewCapability } from './marketplace.js';
|
|
15
15
|
export { GRANTS_CAPABILITIES, listGrantsCapability } from './grants.js';
|
|
@@ -9,7 +9,7 @@ export { LINK_CAPABILITIES, listLinksCapability, proposeLinkCapability, linkIsRe
|
|
|
9
9
|
export { INTRODUCTION_CAPABILITIES, mintIntroductionCapability, redeemIntroductionCapability, listIntroductionsCapability, revokeIntroductionCapability, } from './introductions.js';
|
|
10
10
|
export { AGREEMENT_CAPABILITIES, agreementClaimCapability, presentClaimResult, } from './agreements.js';
|
|
11
11
|
export { LIST_FIELDS_PARAM, parseListFields, pickListedRow, pickListedRows, listedFieldNote, } from './listedFields.js';
|
|
12
|
-
export { TASK_CAPABILITIES, listTasksCapability, cancelTaskCapability, delegateTaskCapability, presentTaskOutcome, } from './tasks.js';
|
|
12
|
+
export { TASK_CAPABILITIES, listTasksCapability, cancelTaskCapability, passTaskOnCapability, delegateTaskCapability, presentTaskOutcome, } from './tasks.js';
|
|
13
13
|
export { AGREEMENT_PROPOSE_PROVIDER_ID_DESCRIPTION } from './proposeProviderId.js';
|
|
14
14
|
export { MARKETPLACE_CAPABILITIES, marketplaceViewCapability } from './marketplace.js';
|
|
15
15
|
export { GRANTS_CAPABILITIES, listGrantsCapability } from './grants.js';
|
|
@@ -210,6 +210,10 @@ const BRIEFS = {
|
|
|
210
210
|
ziggs_task_list: {
|
|
211
211
|
does: 'Lists tasks you can reach. assignedToMe and createdByMe filter them.',
|
|
212
212
|
},
|
|
213
|
+
ziggs_task_pass_on: {
|
|
214
|
+
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.',
|
|
215
|
+
changes: 'the assignee; the previous one loses write on the task',
|
|
216
|
+
},
|
|
213
217
|
ziggs_task_update_steps: {
|
|
214
218
|
does: 'Updates the status of named plan steps. waitingOn shows who you are waiting on until your next progress.',
|
|
215
219
|
changes: 'only the steps named',
|
|
@@ -13,6 +13,15 @@ export declare const listTasksCapability: CapabilityDefinition;
|
|
|
13
13
|
* Catalog, not native: this is the pointer AX-07 names, not a new protocol verb.
|
|
14
14
|
*/
|
|
15
15
|
export declare const cancelTaskCapability: CapabilityDefinition;
|
|
16
|
+
/**
|
|
17
|
+
* Pass live work on by making someone else its assignee.
|
|
18
|
+
*
|
|
19
|
+
* Example: an agent asked a store's coordinator to approve a repair and the
|
|
20
|
+
* coordinator has not answered in time; the agent makes the operations
|
|
21
|
+
* director the assignee, and from then on only the director can finish it.
|
|
22
|
+
* The agreement stays, so the side that owes the work stays responsible.
|
|
23
|
+
*/
|
|
24
|
+
export declare const passTaskOnCapability: CapabilityDefinition;
|
|
16
25
|
/**
|
|
17
26
|
* What a terminal transition actually did, as the server reported it.
|
|
18
27
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { delegateTask, returnTaskResult, refreshTaskReadiness, cancelTask, listTasks } from '../http/TaskClient.js';
|
|
1
|
+
import { delegateTask, returnTaskResult, refreshTaskReadiness, cancelTask, listTasks, passTaskOn } from '../http/TaskClient.js';
|
|
2
2
|
import { fullCreds, rethrowWithContext, } from './types.js';
|
|
3
3
|
import { LIST_FIELDS_PARAM, listedFieldNote, parseListFields, pickListedRows } from './listedFields.js';
|
|
4
4
|
import { nextCall, workContextFromEnv, } from './nextCall.js';
|
|
@@ -96,6 +96,44 @@ export const cancelTaskCapability = {
|
|
|
96
96
|
}
|
|
97
97
|
},
|
|
98
98
|
};
|
|
99
|
+
/**
|
|
100
|
+
* Pass live work on by making someone else its assignee.
|
|
101
|
+
*
|
|
102
|
+
* Example: an agent asked a store's coordinator to approve a repair and the
|
|
103
|
+
* coordinator has not answered in time; the agent makes the operations
|
|
104
|
+
* director the assignee, and from then on only the director can finish it.
|
|
105
|
+
* The agreement stays, so the side that owes the work stays responsible.
|
|
106
|
+
*/
|
|
107
|
+
export const passTaskOnCapability = {
|
|
108
|
+
key: 'task_pass_on',
|
|
109
|
+
names: { sdk: 'task_pass_on', mcp: 'ziggs_task_pass_on' },
|
|
110
|
+
title: 'Pass a task on',
|
|
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.",
|
|
113
|
+
},
|
|
114
|
+
annotation: 'destructive',
|
|
115
|
+
needsAgentId: true,
|
|
116
|
+
params: {
|
|
117
|
+
taskId: {
|
|
118
|
+
type: 'string',
|
|
119
|
+
required: true,
|
|
120
|
+
description: 'The live task to pass on: one you work or one you opened',
|
|
121
|
+
},
|
|
122
|
+
assigneeId: {
|
|
123
|
+
type: 'string',
|
|
124
|
+
required: true,
|
|
125
|
+
description: "Who works it from now on: a person or agent who can work under the task's agreement",
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
handler: async (args, env) => {
|
|
129
|
+
try {
|
|
130
|
+
return await passTaskOn(args['taskId'], args['assigneeId'], fullCreds(env));
|
|
131
|
+
}
|
|
132
|
+
catch (e) {
|
|
133
|
+
rethrowWithContext(e, 'task_pass_on');
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
};
|
|
99
137
|
/** Why a metered settlement moved nothing, in words rather than a code. */
|
|
100
138
|
const SETTLEMENT_REASONS = {
|
|
101
139
|
not_metered: 'this agreement does not bill per completed task',
|
|
@@ -214,6 +252,7 @@ export const delegateTaskCapability = {
|
|
|
214
252
|
export const TASK_CAPABILITIES = [
|
|
215
253
|
listTasksCapability,
|
|
216
254
|
cancelTaskCapability,
|
|
255
|
+
passTaskOnCapability,
|
|
217
256
|
delegateTaskCapability,
|
|
218
257
|
];
|
|
219
258
|
/** Why a settled amount is what it is, when the agreement priced the task at completion. */
|
|
@@ -106,12 +106,11 @@ export interface BucketContents {
|
|
|
106
106
|
title: string;
|
|
107
107
|
state: string;
|
|
108
108
|
}>;
|
|
109
|
-
/** The agreements the work here is under, worked out from the work
|
|
109
|
+
/** The agreements the work here is under, worked out from the work. A chat brought in comes without its agreement. */
|
|
110
110
|
agreements: Array<{
|
|
111
111
|
agreementId: string;
|
|
112
112
|
title: string;
|
|
113
113
|
status: string;
|
|
114
|
-
missing: string[];
|
|
115
114
|
}>;
|
|
116
115
|
/** Hires waiting for a yes whose people come in here when they start. */
|
|
117
116
|
invites: Array<{
|
|
@@ -124,7 +123,8 @@ export interface BucketContents {
|
|
|
124
123
|
}
|
|
125
124
|
/**
|
|
126
125
|
* A message sent inside a bucket: its readers are the bucket's people, and for
|
|
127
|
-
* a reply that names the message it answers,
|
|
126
|
+
* a reply that names the message it answers, those who read that message and
|
|
127
|
+
* have it in a bucket of theirs. Work goes in only with its other side here.
|
|
128
128
|
* `page` is the HTML file it carries, by its exact version (contracts 0.49).
|
|
129
129
|
*/
|
|
130
130
|
export type BucketMessage = Omit<MessageCommand, 'audience'> & {
|
|
@@ -138,9 +138,23 @@ export interface CreateTaskCheckBackData {
|
|
|
138
138
|
/** Total reminders allowed per person asked, after the first ask. */
|
|
139
139
|
maxReminders: number;
|
|
140
140
|
}
|
|
141
|
-
|
|
141
|
+
/**
|
|
142
|
+
* A task the backend kept waiting instead of making: asked from a
|
|
143
|
+
* run that cannot reach the agreement it names, it waits on the asking
|
|
144
|
+
* agent's owner, and the server makes it when they say yes. Nothing to retry.
|
|
145
|
+
*/
|
|
146
|
+
export interface HeldTaskCreate {
|
|
147
|
+
status: 'pending_approval';
|
|
148
|
+
handOver: {
|
|
149
|
+
agreementId: string;
|
|
150
|
+
approverId: string;
|
|
151
|
+
};
|
|
152
|
+
message: string;
|
|
153
|
+
}
|
|
154
|
+
export declare function isHeldTaskCreate(value: unknown): value is HeldTaskCreate;
|
|
155
|
+
export declare function createTask(taskData: CreateTaskData, creds: Creds): Promise<(Task & {
|
|
142
156
|
children?: CreatedTaskChild[];
|
|
143
|
-
}>;
|
|
157
|
+
}) | HeldTaskCreate>;
|
|
144
158
|
export declare function getTask(taskId: string, creds: Creds): Promise<Task>;
|
|
145
159
|
export interface UpdateTaskStateData {
|
|
146
160
|
result?: unknown;
|
|
@@ -173,6 +187,13 @@ export interface TaskChargeStatement {
|
|
|
173
187
|
export declare function updateTaskState(taskId: string, state: TaskUpdateState, data: UpdateTaskStateData | undefined, creds: Creds): Promise<TaskWriteConfirm>;
|
|
174
188
|
export declare function getActiveTasksForAgent(agentId: string, creds: Creds): Promise<Task[]>;
|
|
175
189
|
export declare function cancelTask(taskId: string, creds: Creds): Promise<TaskWriteConfirm>;
|
|
190
|
+
/**
|
|
191
|
+
* Pass live work on: make someone else the task's assignee, so only they can
|
|
192
|
+
* finish it. The agreement stays, so the side that owes the work stays
|
|
193
|
+
* responsible. Whoever works the task, or whoever opened it, may pass it on;
|
|
194
|
+
* the new assignee must be able to work under the task's agreement.
|
|
195
|
+
*/
|
|
196
|
+
export declare function passTaskOn(taskId: string, assigneeId: string, creds: Creds): Promise<TaskWriteConfirm>;
|
|
176
197
|
export declare function getSubtasks(parentTaskId: string, creds: Creds): Promise<Task[]>;
|
|
177
198
|
export interface PlanReplaceStep {
|
|
178
199
|
/** Omit to let the server mint `step-<n>`. */
|
|
@@ -254,13 +275,14 @@ export declare class TaskClient {
|
|
|
254
275
|
constructor(operatorKey: string, agentId?: string);
|
|
255
276
|
requestControl(taskId: string, request: Parameters<typeof requestTaskControl>[1]): Promise<TaskWriteConfirm>;
|
|
256
277
|
acknowledgeControl(taskId: string, requestId: string, supported?: boolean): Promise<TaskWriteConfirm>;
|
|
257
|
-
createTask(data: CreateTaskData): Promise<Task & {
|
|
278
|
+
createTask(data: CreateTaskData): Promise<HeldTaskCreate | (Task & {
|
|
258
279
|
children?: CreatedTaskChild[];
|
|
259
|
-
}>;
|
|
280
|
+
})>;
|
|
260
281
|
getTask(taskId: string): Promise<Task>;
|
|
261
282
|
updateTaskState(taskId: string, state: TaskUpdateState, data?: UpdateTaskStateData): Promise<TaskWriteConfirm>;
|
|
262
283
|
getActiveTasksForAgent(agentId: string): Promise<Task[]>;
|
|
263
284
|
cancelTask(taskId: string): Promise<TaskWriteConfirm>;
|
|
285
|
+
passTaskOn(taskId: string, assigneeId: string): Promise<TaskWriteConfirm>;
|
|
264
286
|
getSubtasks(parentTaskId: string): Promise<Task[]>;
|
|
265
287
|
replaceTaskPlan(taskId: string, steps: PlanReplaceStep[]): Promise<TaskWriteConfirm>;
|
|
266
288
|
updateTaskPlanStep(taskId: string, stepId: string, status: string, result?: unknown): Promise<TaskWriteConfirm>;
|
package/dist/http/TaskClient.js
CHANGED
|
@@ -96,6 +96,12 @@ function extractWriteConfirm(data) {
|
|
|
96
96
|
...(typeof d['status'] === 'string' ? { status: d['status'] } : {}),
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
|
+
export function isHeldTaskCreate(value) {
|
|
100
|
+
return (!!value &&
|
|
101
|
+
typeof value === 'object' &&
|
|
102
|
+
value.status === 'pending_approval' &&
|
|
103
|
+
!!value.handOver);
|
|
104
|
+
}
|
|
99
105
|
export async function createTask(taskData, creds) {
|
|
100
106
|
if (!taskData)
|
|
101
107
|
throw new Error('Task data is required for task creation');
|
|
@@ -114,6 +120,8 @@ export async function createTask(taskData, creds) {
|
|
|
114
120
|
throwApiError(res, body, `Task creation failed: ${res.status} ${res.statusText}`);
|
|
115
121
|
}
|
|
116
122
|
const data = await res.json().catch(() => null);
|
|
123
|
+
if (isHeldTaskCreate(data))
|
|
124
|
+
return data;
|
|
117
125
|
const task = extractTask(data);
|
|
118
126
|
if (!task)
|
|
119
127
|
throw new Error('Invalid response: task data not found');
|
|
@@ -243,6 +251,34 @@ export async function cancelTask(taskId, creds) {
|
|
|
243
251
|
throw new Error('Invalid response: task write confirm not found');
|
|
244
252
|
return confirm;
|
|
245
253
|
}
|
|
254
|
+
/**
|
|
255
|
+
* Pass live work on: make someone else the task's assignee, so only they can
|
|
256
|
+
* finish it. The agreement stays, so the side that owes the work stays
|
|
257
|
+
* responsible. Whoever works the task, or whoever opened it, may pass it on;
|
|
258
|
+
* the new assignee must be able to work under the task's agreement.
|
|
259
|
+
*/
|
|
260
|
+
export async function passTaskOn(taskId, assigneeId, creds) {
|
|
261
|
+
if (!taskId)
|
|
262
|
+
throw new Error('passTaskOn: taskId is required');
|
|
263
|
+
if (!assigneeId)
|
|
264
|
+
throw new Error('passTaskOn: assigneeId is required');
|
|
265
|
+
assertCreds(creds, 'passing a task on');
|
|
266
|
+
const res = await fetch(`${getTaskBaseUrl()}/${encodeURIComponent(taskId)}/assignee`, {
|
|
267
|
+
method: 'PUT',
|
|
268
|
+
headers: buildHeaders(creds),
|
|
269
|
+
body: JSON.stringify({ assigneeId }),
|
|
270
|
+
});
|
|
271
|
+
if (!res.ok) {
|
|
272
|
+
const body = await res.text().catch(() => '');
|
|
273
|
+
throwApiError(res, body, `Task pass-on failed: ${res.status} ${res.statusText}`);
|
|
274
|
+
}
|
|
275
|
+
const result = await res.json().catch(() => null);
|
|
276
|
+
const confirm = extractWriteConfirm(result);
|
|
277
|
+
if (!confirm)
|
|
278
|
+
throw new Error('Invalid response: task write confirm not found');
|
|
279
|
+
const assignee = result?.['assigneeId'];
|
|
280
|
+
return { ...confirm, assigneeId: typeof assignee === 'string' ? assignee : assigneeId };
|
|
281
|
+
}
|
|
246
282
|
export async function getSubtasks(parentTaskId, creds) {
|
|
247
283
|
if (!parentTaskId)
|
|
248
284
|
throw new Error('getSubtasks: parentTaskId is required');
|
|
@@ -468,6 +504,7 @@ export class TaskClient {
|
|
|
468
504
|
updateTaskState(taskId, state, data) { return updateTaskState(taskId, state, data ?? {}, this.creds); }
|
|
469
505
|
getActiveTasksForAgent(agentId) { return getActiveTasksForAgent(agentId, this.creds); }
|
|
470
506
|
cancelTask(taskId) { return cancelTask(taskId, this.creds); }
|
|
507
|
+
passTaskOn(taskId, assigneeId) { return passTaskOn(taskId, assigneeId, this.creds); }
|
|
471
508
|
getSubtasks(parentTaskId) { return getSubtasks(parentTaskId, this.creds); }
|
|
472
509
|
replaceTaskPlan(taskId, steps) { return replaceTaskPlan(taskId, steps, this.creds); }
|
|
473
510
|
updateTaskPlanStep(taskId, stepId, status, result) { return updateTaskPlanStep(taskId, stepId, status, result, this.creds); }
|
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.8",
|
|
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.2",
|
|
35
35
|
"socket.io-client": "^4.7.0"
|
|
36
36
|
},
|
|
37
37
|
"keywords": [
|