@ziggs-ai/api-client 0.42.5 → 0.42.7
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 +2 -2
- package/dist/capabilities/context.js +1 -1
- package/dist/capabilities/discovery.js +1 -3
- package/dist/capabilities/everyday.d.ts +2 -4
- package/dist/capabilities/everyday.js +2 -4
- package/dist/capabilities/index.d.ts +1 -1
- package/dist/capabilities/index.js +1 -1
- package/dist/capabilities/links.js +2 -3
- package/dist/capabilities/mcpBriefs.js +6 -2
- package/dist/capabilities/messaging.js +1 -1
- package/dist/capabilities/tasks.d.ts +9 -0
- package/dist/capabilities/tasks.js +40 -1
- package/dist/http/BucketsClient.d.ts +3 -2
- package/dist/http/TaskClient.d.ts +26 -4
- package/dist/http/TaskClient.js +37 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.42.7
|
|
6
|
+
|
|
7
|
+
- `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.
|
|
8
|
+
|
|
9
|
+
## 0.42.6
|
|
10
|
+
|
|
11
|
+
- Messaging accepts first messages and replies without a bucket; SDK and MCP guidance keep readers and delivery independent from optional filing.
|
|
12
|
+
|
|
13
|
+
- `bucket_send` with `replyTo` (and `BucketsClient.sendMessage` with `relationships.replyToMessageId`): the reply is also read by everyone who read the message it answers, so a bucket never takes anyone out of a chat; from a run, only those the run may write to. A send that names nothing it answers is still read by the bucket's people only. The server also puts a reply into every other bucket that holds the message it answers and whose people all read it. `recipients` are picked among all of these readers.
|
|
14
|
+
|
|
5
15
|
## 0.42.5
|
|
6
16
|
|
|
7
17
|
## 0.42.4
|
|
@@ -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;
|
|
240
|
+
sdk: "Send a message inside a bucket. Its readers are the bucket's people; with replyTo, also everyone who read the message it answers. 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,
|
|
@@ -252,7 +252,7 @@ export const bucketSendCapability = {
|
|
|
252
252
|
recipients: {
|
|
253
253
|
type: 'array',
|
|
254
254
|
items: { type: 'string' },
|
|
255
|
-
description: 'Who is told, among the
|
|
255
|
+
description: 'Who is told, among the readers. Under work, name at least one person the work is with.',
|
|
256
256
|
},
|
|
257
257
|
intent: { type: 'string', enum: ['fyi', 'request'] },
|
|
258
258
|
replyTo: { type: 'string', description: 'The message this answers. Not for a new page.' },
|
|
@@ -272,7 +272,7 @@ const OPEN_REF_PARAMS = {
|
|
|
272
272
|
};
|
|
273
273
|
function resumeResource(kind, id, env) {
|
|
274
274
|
// After a send grant is approved there is nothing to read: send to the destination.
|
|
275
|
-
//
|
|
275
|
+
// Offer an optional shared bucket with the newly reachable destination.
|
|
276
276
|
if (kind === 'contact')
|
|
277
277
|
return { tool: env.surface === 'mcp' ? 'ziggs_bucket_create' : 'bucket_create', args: { name: 'Conversation', audience: [id] } };
|
|
278
278
|
const tool = kind === 'message' ? 'message_read' : 'open';
|
|
@@ -34,8 +34,6 @@ export const agentSearchCapability = {
|
|
|
34
34
|
throw new Error(result.error ?? result.message ?? 'search failed');
|
|
35
35
|
}
|
|
36
36
|
const send = env.surface === 'mcp' ? 'ziggs_message_send' : 'message_send';
|
|
37
|
-
const bucketCreate = env.surface === 'mcp' ? 'ziggs_bucket_create' : 'bucket_create';
|
|
38
|
-
const bucketSend = env.surface === 'mcp' ? 'ziggs_bucket_send' : 'bucket_send';
|
|
39
37
|
const linkList = env.surface === 'mcp' ? 'ziggs_link_list' : 'link_list';
|
|
40
38
|
const marketplace = env.surface === 'mcp' ? 'ziggs_marketplace_view' : 'marketplace_view';
|
|
41
39
|
const request = env.surface === 'mcp' ? 'ziggs_agreement_request' : 'agreement_request';
|
|
@@ -43,7 +41,7 @@ export const agentSearchCapability = {
|
|
|
43
41
|
const messageThem = people.length
|
|
44
42
|
? {
|
|
45
43
|
people,
|
|
46
|
-
peopleNote: `These are teammates whose name matched. To message the person,
|
|
44
|
+
peopleNote: `These are teammates whose name matched. To message the person, use ${send} with their userId in the command audience and deliveries; which of their agents answers is theirs to decide.`,
|
|
47
45
|
}
|
|
48
46
|
: {};
|
|
49
47
|
const hired = await hireNotes(result.agents ?? [], env);
|
|
@@ -16,10 +16,8 @@ export declare const EVERYDAY_MCP_TOOLS: readonly ["ziggs_inbox", "ziggs_inbox_p
|
|
|
16
16
|
/** Everyday MCP tools the hosted brain does not register. */
|
|
17
17
|
export declare const EVERYDAY_NO_SDK_TWIN: readonly ["ziggs_inbox", "ziggs_inbox_peek", "ziggs_inbox_ack", "ziggs_context_revoke_grant"];
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* with their schemas. The MCP door keeps its size: there they stay in the
|
|
22
|
-
* catalog.
|
|
19
|
+
* Optional organization tools loaded by the hosted brain. Plain messaging
|
|
20
|
+
* needs neither of them. The MCP door keeps these in the catalog.
|
|
23
21
|
*/
|
|
24
22
|
export declare const EVERYDAY_SDK_ONLY: readonly ["bucket_create", "bucket_send"];
|
|
25
23
|
/** SDK names of the everyday set: the MCP list's twins in its order, then the hosted-only ones. */
|
|
@@ -39,10 +39,8 @@ export const EVERYDAY_NO_SDK_TWIN = [
|
|
|
39
39
|
];
|
|
40
40
|
const noSdkTwin = new Set(EVERYDAY_NO_SDK_TWIN);
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* with their schemas. The MCP door keeps its size: there they stay in the
|
|
45
|
-
* catalog.
|
|
42
|
+
* Optional organization tools loaded by the hosted brain. Plain messaging
|
|
43
|
+
* needs neither of them. The MCP door keeps these in the catalog.
|
|
46
44
|
*/
|
|
47
45
|
export const EVERYDAY_SDK_ONLY = ['bucket_create', 'bucket_send'];
|
|
48
46
|
/** SDK names of the everyday set: the MCP list's twins in its order, then the hosted-only ones. */
|
|
@@ -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';
|
|
@@ -8,9 +8,8 @@ export function webAppOrigin(env) {
|
|
|
8
8
|
}
|
|
9
9
|
/** Reach and resource sharing are separate operations with independent consent. */
|
|
10
10
|
export function linkIsReachOnly(env) {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
return `A link is reach-only and shares no context. To talk, start a bucket with ${create} naming the returned peer.id in audience (never a display face in parties), then ${send} in it. Sharing an artifact or delegating a grant is a separate operation with its own consent.`;
|
|
11
|
+
const send = env.surface === 'mcp' ? 'ziggs_message_send' : 'message_send';
|
|
12
|
+
return `A link is reach-only and shares no context. To talk, use ${send} with the returned peer.id in the command audience and deliveries (never a display face in parties). A bucket is optional. Sharing an artifact or delegating a grant is a separate operation with its own consent.`;
|
|
14
13
|
}
|
|
15
14
|
const LINK_STATUSES = ['active', 'open', 'cancelled', 'all'];
|
|
16
15
|
/**
|
|
@@ -165,7 +165,7 @@ const BRIEFS = {
|
|
|
165
165
|
ziggs_artifact_find: {
|
|
166
166
|
does: 'Searches artifacts you can read by name, filename or body. coverage and notSearched say what was and was not searched.',
|
|
167
167
|
},
|
|
168
|
-
ziggs_message_send: { does: 'Sends
|
|
168
|
+
ziggs_message_send: { does: 'Sends the canonical command for first messages and replies with independent readers and recipients. No bucket is required; filing is optional.', changes: 'delivers a message and grants its readers access; a request wakes the agents it reaches' },
|
|
169
169
|
ziggs_message_replies: { does: 'Reads authorized causal replies by messageId; a reference grants no access and receipt expiry does not erase history.' },
|
|
170
170
|
ziggs_message_read: { does: 'Reads an exact message by messageId under current access and execution policy. Does not acknowledge its receipt.' },
|
|
171
171
|
ziggs_message_list: { does: 'Queries authorized messages by participants, agreement or task. Filters select history, not authority.' },
|
|
@@ -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',
|
|
@@ -319,7 +323,7 @@ const BRIEFS = {
|
|
|
319
323
|
changes: 'adds them',
|
|
320
324
|
},
|
|
321
325
|
ziggs_bucket_send: {
|
|
322
|
-
does: "Sends
|
|
326
|
+
does: "Sends inside a bucket, to its people and the readers of replyTo.",
|
|
323
327
|
changes: 'sends it',
|
|
324
328
|
},
|
|
325
329
|
ziggs_bucket_rename: {
|
|
@@ -19,7 +19,7 @@ export const MESSAGE_COMMAND_PARAM = { type: 'object', required: true, propertie
|
|
|
19
19
|
sources: { type: 'array', items: { type: 'object' } },
|
|
20
20
|
page: { type: 'object' },
|
|
21
21
|
} };
|
|
22
|
-
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.
|
|
22
|
+
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. 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
23
|
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 }) };
|
|
24
24
|
export const queryMessagesCapability = { key: 'message_list', names: { sdk: 'message_list', mcp: 'ziggs_message_list' }, title: 'Query messages', descriptions: { sdk: 'Query authorized messages. Use conversationOf with an exact message id to browse messages connected by readable reply relationships; use nextCursor as before for earlier turns. Select conversationOf independently of agreementId, taskId or participantIds. History never selects authority.' }, annotation: 'read-only', needsAgentId: true, params: { conversationOf: { type: 'string', description: 'Authorized anchor message; follows readable causal links, never a reader roster. Each result still requires read access and any execution input authorization.' }, q: { type: 'string' }, senderId: { type: 'string' }, recipientIds: { type: 'array', items: { type: 'string' } }, agreementId: { type: 'string' }, taskId: { type: 'string' }, participantIds: { type: 'array', items: { type: 'string' } }, before: { type: 'string' }, limit: { type: 'number' } }, handler: (args, env) => client(env).list(args) };
|
|
25
25
|
export const messageControlsCapability = { key: 'message_controls', names: { sdk: 'message_controls', mcp: 'ziggs_message_controls' }, title: 'Inspect message mandate', descriptions: { sdk: 'Discover recipients and current authority under an explicitly selected agreement/task without reading message history.' }, annotation: 'read-only', needsAgentId: true, params: { q: { type: 'string' }, senderId: { type: 'string' }, recipientIds: { type: 'array', items: { type: 'string' } }, agreementId: { type: 'string', required: true }, taskId: { type: 'string' } }, handler: (args, env) => client(env).controls(String(args.agreementId), args.taskId) };
|
|
@@ -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. */
|
|
@@ -123,8 +123,9 @@ export interface BucketContents {
|
|
|
123
123
|
outOfReach: number;
|
|
124
124
|
}
|
|
125
125
|
/**
|
|
126
|
-
* A message sent inside a bucket: its readers are the bucket's people
|
|
127
|
-
*
|
|
126
|
+
* A message sent inside a bucket: its readers are the bucket's people, and for
|
|
127
|
+
* a reply that names the message it answers, everyone who read that message.
|
|
128
|
+
* `page` is the HTML file it carries, by its exact version (contracts 0.49).
|
|
128
129
|
*/
|
|
129
130
|
export type BucketMessage = Omit<MessageCommand, 'audience'> & {
|
|
130
131
|
page?: {
|
|
@@ -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); }
|