@ziggs-ai/agent-sdk 0.48.9 → 0.48.11
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,16 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.48.11
|
|
6
|
+
|
|
7
|
+
- `task_create` that hands work and files from a parent task to another hire now waits on the same cards as `task_delegate` when that hire cannot read the files yet. `HeldTaskCreate.handOver` can be the card list.
|
|
8
|
+
|
|
9
|
+
- A delegation the hire cannot read yet waits instead of failing. `task_delegate` create can answer `pending_approval`: the server sent one card to each person who must say yes, and makes the child after the last yes. The task-wake work signal now says to wait for it instead of filing access requests.
|
|
10
|
+
|
|
11
|
+
## 0.48.10
|
|
12
|
+
|
|
13
|
+
- A task wake says which of its own proposals were answered. The inbox loop passes each input's `reason` to the task executor (`TaskInputRef.reason`), and the Claude prompt turns an approved or declined proposal made from the task into a work signal: give the hire its first task with `task_delegate` (`task_create` on the hire is refused from inside the task), or report a decline.
|
|
14
|
+
|
|
5
15
|
## 0.48.9
|
|
6
16
|
|
|
7
17
|
## 0.48.8
|
|
@@ -208,6 +208,44 @@ export function taskChaseLines(task, now = new Date()) {
|
|
|
208
208
|
return lines;
|
|
209
209
|
}
|
|
210
210
|
/** Render ONE event's fields into prompt lines (shared by single and batch frames). */
|
|
211
|
+
const PROPOSAL_OUTCOMES = new Set(['proposal_approved', 'proposal_approved_execute', 'proposal_rejected']);
|
|
212
|
+
/** What the outcome of the agent's own proposal asks of it, in one line. */
|
|
213
|
+
function proposalOutcomeLine(reason, agreementId) {
|
|
214
|
+
const on = agreementId ? ` on agreement ${agreementId}` : '';
|
|
215
|
+
return reason === 'proposal_rejected'
|
|
216
|
+
? `Work signal: your proposal${on} was declined. Tell the person you made it for, and ask what to change. Do not send the same proposal again.`
|
|
217
|
+
: `Work signal: your proposal${on} was approved, and you are working under it now. Do the next step you promised: ` +
|
|
218
|
+
'if it is a hire for someone, create the first task under it (task_create) with their request. ' +
|
|
219
|
+
'This wake does not carry the conversation that led to it; read that request (message_list) if you need it. ' +
|
|
220
|
+
'Do not greet the provider or open a new conversation.';
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* What arrived for this task since its last wake. A proposal made inside the
|
|
224
|
+
* task reports its outcome here, on the task, where the work it is for can be
|
|
225
|
+
* read; it is the reason for the wake, so it is said in words.
|
|
226
|
+
*/
|
|
227
|
+
function renderTaskInputLines(inputs, taskId, lines) {
|
|
228
|
+
if (!Array.isArray(inputs))
|
|
229
|
+
return;
|
|
230
|
+
for (const input of inputs) {
|
|
231
|
+
if (typeof input?.reason !== 'string' || !PROPOSAL_OUTCOMES.has(input.reason))
|
|
232
|
+
continue;
|
|
233
|
+
const agreementId = input.kind === 'agreement' && typeof input.id === 'string' ? input.id : undefined;
|
|
234
|
+
const on = agreementId ? ` on agreement ${agreementId}` : '';
|
|
235
|
+
if (input.reason === 'proposal_rejected') {
|
|
236
|
+
lines.push(proposalOutcomeLine(input.reason, agreementId));
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
// From inside the task, the hire is another party's work: task_create
|
|
240
|
+
// there is refused, and task_delegate is the door made for it.
|
|
241
|
+
lines.push(`Work signal: your proposal${on}, made from this task, was approved. ` +
|
|
242
|
+
`Give the hire its first task from this task with task_delegate (action "create", taskId ${taskId ?? 'this task'}` +
|
|
243
|
+
(agreementId ? `, agreementId ${agreementId}` : '') +
|
|
244
|
+
', the hire\'s provider agent as assigneeId, and an instruction artifact you record). ' +
|
|
245
|
+
'task_create on the hire is refused from here. If the hire cannot read a file yet, the delegation answers pending_approval: ' +
|
|
246
|
+
'cards went to the people who must say yes, and the task is given after the last yes. Do not call again or file access requests for it.');
|
|
247
|
+
}
|
|
248
|
+
}
|
|
211
249
|
function renderEventLines(event, lines, now) {
|
|
212
250
|
if (event?.type)
|
|
213
251
|
lines.push(`Event type: ${event.type}`);
|
|
@@ -313,13 +351,7 @@ function renderEventLines(event, lines, now) {
|
|
|
313
351
|
typeof resource.resourceId === 'string' &&
|
|
314
352
|
resource.resourceId) ||
|
|
315
353
|
'';
|
|
316
|
-
|
|
317
|
-
lines.push(reason === 'proposal_rejected'
|
|
318
|
-
? `Work signal: your proposal${on} was declined. Tell the person you made it for, and ask what to change. Do not send the same proposal again.`
|
|
319
|
-
: `Work signal: your proposal${on} was approved, and you are working under it now. Do the next step you promised: ` +
|
|
320
|
-
'if it is a hire for someone, create the first task under it (task_create) with their request. ' +
|
|
321
|
-
'This wake does not carry the conversation that led to it; read that request (message_list) if you need it. ' +
|
|
322
|
-
'Do not greet the provider or open a new conversation.');
|
|
354
|
+
lines.push(proposalOutcomeLine(reason, agreementId || undefined));
|
|
323
355
|
// Prefer nested resource agreementId when the outer event omitted it.
|
|
324
356
|
if (agreementId && !(typeof event.agreementId === 'string' && event.agreementId)) {
|
|
325
357
|
lines.push(`Agreement: ${agreementId}`);
|
|
@@ -341,6 +373,7 @@ function renderEventLines(event, lines, now) {
|
|
|
341
373
|
if (result && typeof result === 'object') {
|
|
342
374
|
if (typeof result.taskId === 'string')
|
|
343
375
|
lines.push(`Task: ${result.taskId}`);
|
|
376
|
+
renderTaskInputLines(result.inputs, typeof result.taskId === 'string' ? result.taskId : undefined, lines);
|
|
344
377
|
if (typeof result.agreementId === 'string')
|
|
345
378
|
lines.push(`Agreement: ${result.agreementId}`);
|
|
346
379
|
if (typeof result.state === 'string')
|
|
@@ -517,7 +517,10 @@ export async function pollInboxOnce(deps, waitSeconds = 0, opts = {}) {
|
|
|
517
517
|
const handled = await attempt(`task ${task.taskId}`, async () => {
|
|
518
518
|
const executionContext = await prepareWorkExecution({ kind: 'task', id: task.taskId }, deps.creds.operatorKey, deps.ownAgentId, deps.baseUrl);
|
|
519
519
|
const bucket = bucketOfRows(receipts);
|
|
520
|
-
return withWorkExecution(executionContext, () => deps.onTask({ ...task, executionContext }, receipts.map(receipt => ({
|
|
520
|
+
return withWorkExecution(executionContext, () => deps.onTask({ ...task, executionContext }, receipts.map(receipt => ({
|
|
521
|
+
kind: receipt.kind, id: receipt.resourceId, eventId: receipt.eventId ?? receipt.receiptId,
|
|
522
|
+
...(typeof receipt.reason === 'string' && receipt.reason ? { reason: receipt.reason } : {}),
|
|
523
|
+
})), bucket ? { bucket } : undefined));
|
|
521
524
|
});
|
|
522
525
|
if (handled) {
|
|
523
526
|
deps.seen.mark(key);
|
|
@@ -49,7 +49,9 @@ export class TaskService {
|
|
|
49
49
|
try {
|
|
50
50
|
const result = await createTask({ ...taskData, agreementId }, this.creds);
|
|
51
51
|
runtimeLog.info('TaskService', 'handOver' in result
|
|
52
|
-
? `Task under agreement ${agreementId} waits on
|
|
52
|
+
? `Task under agreement ${agreementId} waits on ${'cards' in result.handOver
|
|
53
|
+
? `${result.handOver.cards.length} approval card(s)`
|
|
54
|
+
: `approval card ${result.handOver.agreementId}`}`
|
|
53
55
|
: `Task spawned under agreement ${agreementId}: ${result?.taskId || 'unknown'}`);
|
|
54
56
|
return result;
|
|
55
57
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ export interface TaskInputRef {
|
|
|
24
24
|
kind: import('@ziggs-ai/contracts').ResourceKind;
|
|
25
25
|
id: string;
|
|
26
26
|
eventId: string;
|
|
27
|
+
/** Why it arrived, when the server said (e.g. the outcome of a proposal made in the task). */
|
|
28
|
+
reason?: string;
|
|
27
29
|
}
|
|
28
30
|
export interface TaskRef {
|
|
29
31
|
inputs?: TaskInputRef[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ziggs-ai/agent-sdk",
|
|
3
|
-
"version": "0.48.
|
|
3
|
+
"version": "0.48.11",
|
|
4
4
|
"description": "Agent framework SDK for building autonomous agents on the Ziggs platform",
|
|
5
5
|
"homepage": "https://ziggsai.com/docs",
|
|
6
6
|
"bugs": {
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"@anthropic-ai/claude-agent-sdk": "^0.3.284",
|
|
31
31
|
"@anthropic-ai/sdk": "^0.110.0",
|
|
32
32
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
33
|
-
"@ziggs-ai/api-client": "0.42.
|
|
34
|
-
"@ziggs-ai/contracts": "0.50.
|
|
33
|
+
"@ziggs-ai/api-client": "0.42.9",
|
|
34
|
+
"@ziggs-ai/contracts": "0.50.4",
|
|
35
35
|
"ajv": "^8.17.1",
|
|
36
36
|
"dotenv": "^17.2.3",
|
|
37
37
|
"openai": "^4.0.0",
|