@ziggs-ai/agent-sdk 0.48.24 → 0.48.25
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 +5 -0
- package/dist/brain/claudeCognition.js +3 -0
- package/dist/platform/tasks/TaskService.d.ts +2 -0
- package/dist/platform/tasks/TaskService.js +15 -0
- package/dist/platform/tools/tier1/protocolRunner.js +45 -35
- package/dist/runtime/PromptBuilder.js +4 -0
- package/dist/runtime/taskAgreementLine.d.ts +13 -0
- package/dist/runtime/taskAgreementLine.js +13 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.48.25
|
|
6
|
+
|
|
7
|
+
- `task_create` with no `agreementId` reaches the server, which decides what the task carries; it used to return nothing.
|
|
8
|
+
- A task given with no agreement now says so in the wake: it costs nothing, and no agreement's connections apply to it.
|
|
9
|
+
|
|
5
10
|
## 0.48.24
|
|
6
11
|
|
|
7
12
|
## 0.48.23
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SERVER_EVENTS } from '@ziggs-ai/contracts';
|
|
2
2
|
import { SYSTEM_PROMPT_DYNAMIC_BOUNDARY, } from '@anthropic-ai/claude-agent-sdk';
|
|
3
3
|
import { decisionWords } from '@ziggs-ai/api-client';
|
|
4
|
+
import { NO_AGREEMENT_TASK_LINE, taskHasNoAgreement } from '../runtime/taskAgreementLine.js';
|
|
4
5
|
import { getBatchEvents } from '../context/batch.js';
|
|
5
6
|
import { DEFAULT_MODEL } from '../shared/fleetModel.js';
|
|
6
7
|
/**
|
|
@@ -404,6 +405,8 @@ function renderEventLines(event, lines, now) {
|
|
|
404
405
|
renderDelegationLines(result.inputs, result.delegations, lines);
|
|
405
406
|
if (typeof result.agreementId === 'string')
|
|
406
407
|
lines.push(`Agreement: ${result.agreementId}`);
|
|
408
|
+
else if (typeof result.taskId === 'string' && taskHasNoAgreement(result))
|
|
409
|
+
lines.push(NO_AGREEMENT_TASK_LINE);
|
|
407
410
|
if (typeof result.state === 'string')
|
|
408
411
|
lines.push(`Task state: ${result.state}`);
|
|
409
412
|
// The deadline and the reminder budget the creator set on this task.
|
|
@@ -17,6 +17,8 @@ export declare class TaskService {
|
|
|
17
17
|
getTask(taskId: string): Promise<Task>;
|
|
18
18
|
getActiveTasksForAgent(agentId: string): Promise<Task[]>;
|
|
19
19
|
getSubtasks(parentTaskId: string): Promise<Task[]>;
|
|
20
|
+
/** A task given with no agreement: the server decides what it carries from the caller's right to give the assignee work. */
|
|
21
|
+
spawnWithoutAgreement(taskData: Omit<CreateTaskData, 'agreementId'>): Promise<Task | HeldTaskCreate>;
|
|
20
22
|
spawnUnderAgreement(agreementId: string, taskData: Omit<CreateTaskData, 'agreementId'>): Promise<Task | HeldTaskCreate>;
|
|
21
23
|
updateState(taskId: string, state: TaskUpdateState, result?: unknown, idempotencyKey?: string, sources?: WriteSource[], charge?: TaskChargeStatement): Promise<{
|
|
22
24
|
ok: true;
|
|
@@ -68,6 +68,21 @@ export class TaskService {
|
|
|
68
68
|
async getSubtasks(parentTaskId) {
|
|
69
69
|
return getSubtasks(parentTaskId, this.creds);
|
|
70
70
|
}
|
|
71
|
+
/** A task given with no agreement: the server decides what it carries from the caller's right to give the assignee work. */
|
|
72
|
+
async spawnWithoutAgreement(taskData) {
|
|
73
|
+
try {
|
|
74
|
+
const result = await createTask({ ...taskData }, this.creds);
|
|
75
|
+
runtimeLog.info('TaskService', 'handOver' in result
|
|
76
|
+
? 'Task with no agreement named waits on approval'
|
|
77
|
+
: `Task given with no agreement named: ${result?.taskId || 'unknown'}`);
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
const e = error;
|
|
82
|
+
runtimeLog.error('TaskService', `Task spawn failed (no agreement, assignee ${taskData.assigneeId ?? '-'}): status=${e.status ?? '?'} ${e.message}${e.body ? ` | body=${e.body}` : ''}`);
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
71
86
|
async spawnUnderAgreement(agreementId, taskData) {
|
|
72
87
|
if (!agreementId)
|
|
73
88
|
throw new Error('TaskService.spawnUnderAgreement: agreementId is required');
|
|
@@ -128,8 +128,51 @@ cachedAgreements) {
|
|
|
128
128
|
return null;
|
|
129
129
|
return await agreementService.fulfill(payload.agreementId);
|
|
130
130
|
case 'task-spawn': {
|
|
131
|
-
|
|
131
|
+
const description = payload.description;
|
|
132
|
+
if (!description)
|
|
132
133
|
return null;
|
|
134
|
+
const spawnData = (agreementKey) => {
|
|
135
|
+
const planReviewTiming = normalizePlanInPlace(payload);
|
|
136
|
+
return {
|
|
137
|
+
description,
|
|
138
|
+
parentTaskId: payload.parentTaskId,
|
|
139
|
+
plan: payload.plan,
|
|
140
|
+
planReviewTiming,
|
|
141
|
+
requireMidWorkPlanAck: payload.requireMidWorkPlanAck,
|
|
142
|
+
assigneeId: payload.assigneeId,
|
|
143
|
+
inputArtifactIds: Array.isArray(payload.inputArtifactIds)
|
|
144
|
+
? payload.inputArtifactIds
|
|
145
|
+
: undefined,
|
|
146
|
+
// The chase pair, passed through as given. Shape is the
|
|
147
|
+
// backend's business (it refuses a cadence with no budget and a
|
|
148
|
+
// deadline already past); the runner's job is not to silently drop
|
|
149
|
+
// what the caller set, which is what omitting them here would do.
|
|
150
|
+
...(typeof payload.dueAt === 'string' && payload.dueAt
|
|
151
|
+
? { dueAt: payload.dueAt }
|
|
152
|
+
: {}),
|
|
153
|
+
...(payload.checkBack && typeof payload.checkBack === 'object'
|
|
154
|
+
? { checkBack: payload.checkBack }
|
|
155
|
+
: {}),
|
|
156
|
+
...sourcesOf(payload),
|
|
157
|
+
// Wake-derived idempotency key (delivery law): a crash-replay re-issuing
|
|
158
|
+
// this spawn resolves to the already-created task server-side instead of
|
|
159
|
+
// creating a duplicate. Keyed on what is actually written (the resolved
|
|
160
|
+
// agreement, not the LLM-cited one), so multiple spawns in one wake stay
|
|
161
|
+
// distinct.
|
|
162
|
+
idempotencyKey: writeKeys?.taskSpawnKey({
|
|
163
|
+
agreementId: agreementKey,
|
|
164
|
+
description,
|
|
165
|
+
assigneeId: payload.assigneeId,
|
|
166
|
+
parentTaskId: payload.parentTaskId,
|
|
167
|
+
}),
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
// A task names an agreement only when the work is done under one. With
|
|
171
|
+
// none named, the server decides from the caller's right to give the
|
|
172
|
+
// assignee work: none for a teammate or an agent the owner runs, the
|
|
173
|
+
// one agreement that allows it, or a refusal listing several.
|
|
174
|
+
if (!payload.agreementId)
|
|
175
|
+
return taskService.spawnWithoutAgreement(spawnData(''));
|
|
133
176
|
let spawnAgreementId = payload.agreementId;
|
|
134
177
|
const ags = await agreementsForWork(services, payload.agreementId, cachedAgreements);
|
|
135
178
|
// b2: if the assignee is not a party on the cited agreement,
|
|
@@ -182,40 +225,7 @@ cachedAgreements) {
|
|
|
182
225
|
agreementId: spawnAgreementId,
|
|
183
226
|
};
|
|
184
227
|
}
|
|
185
|
-
|
|
186
|
-
return taskService.spawnUnderAgreement(spawnAgreementId, {
|
|
187
|
-
description: payload.description,
|
|
188
|
-
parentTaskId: payload.parentTaskId,
|
|
189
|
-
plan: payload.plan,
|
|
190
|
-
planReviewTiming,
|
|
191
|
-
requireMidWorkPlanAck: payload.requireMidWorkPlanAck,
|
|
192
|
-
assigneeId: payload.assigneeId,
|
|
193
|
-
inputArtifactIds: Array.isArray(payload.inputArtifactIds)
|
|
194
|
-
? payload.inputArtifactIds
|
|
195
|
-
: undefined,
|
|
196
|
-
// The chase pair, passed through as given. Shape is the
|
|
197
|
-
// backend's business (it refuses a cadence with no budget and a
|
|
198
|
-
// deadline already past); the runner's job is not to silently drop
|
|
199
|
-
// what the caller set, which is what omitting them here would do.
|
|
200
|
-
...(typeof payload.dueAt === 'string' && payload.dueAt
|
|
201
|
-
? { dueAt: payload.dueAt }
|
|
202
|
-
: {}),
|
|
203
|
-
...(payload.checkBack && typeof payload.checkBack === 'object'
|
|
204
|
-
? { checkBack: payload.checkBack }
|
|
205
|
-
: {}),
|
|
206
|
-
...sourcesOf(payload),
|
|
207
|
-
// Wake-derived idempotency key (delivery law): a crash-replay re-issuing
|
|
208
|
-
// this spawn resolves to the already-created task server-side instead of
|
|
209
|
-
// creating a duplicate. Keyed on what is actually written (the resolved
|
|
210
|
-
// agreement, not the LLM-cited one), so multiple spawns in one wake stay
|
|
211
|
-
// distinct.
|
|
212
|
-
idempotencyKey: writeKeys?.taskSpawnKey({
|
|
213
|
-
agreementId: spawnAgreementId,
|
|
214
|
-
description: payload.description,
|
|
215
|
-
assigneeId: payload.assigneeId,
|
|
216
|
-
parentTaskId: payload.parentTaskId,
|
|
217
|
-
}),
|
|
218
|
-
});
|
|
228
|
+
return taskService.spawnUnderAgreement(spawnAgreementId, spawnData(spawnAgreementId));
|
|
219
229
|
}
|
|
220
230
|
case 'task-update': {
|
|
221
231
|
// `state` only — legacy `status` alias removed. Fleet prompts
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { INBOUND_DISCOVERY_POLICY } from '../inboundDiscoveryPolicy.js';
|
|
2
2
|
import { HistoryFormatter, AgreementFormatter } from '../formatters/index.js';
|
|
3
3
|
import { validateContext } from '../cognition/validateContext.js';
|
|
4
|
+
import { NO_AGREEMENT_TASK_LINE, taskHasNoAgreement } from './taskAgreementLine.js';
|
|
4
5
|
import { isBroadcastTarget, isOpaquePresentationRef, partySideIds } from '@ziggs-ai/api-client';
|
|
5
6
|
import { LANE_BOOK_KEY, allCollectedResults, allDelegatedAgreementIds, allPendingSubtasks, } from './taskBookkeeping.js';
|
|
6
7
|
/** Rough chars-per-token ratio for budgeting (English/JSON averages ~4). */
|
|
@@ -218,6 +219,9 @@ ${this._renderDecisionSchemaFromActions(actions, senderMeta, ctxObj, omitMessage
|
|
|
218
219
|
lines.push(` Price: ${money.price} hundredths of a point (${money.paymentStatus})`);
|
|
219
220
|
}
|
|
220
221
|
}
|
|
222
|
+
else if (taskHasNoAgreement(task)) {
|
|
223
|
+
lines.push(NO_AGREEMENT_TASK_LINE);
|
|
224
|
+
}
|
|
221
225
|
lines.push('');
|
|
222
226
|
lines.push(`Task: ${task.taskId}`);
|
|
223
227
|
lines.push(` Description: ${task.description}`);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a task given with no agreement means for the agent working it.
|
|
3
|
+
*
|
|
4
|
+
* A task names an agreement only when the work is done under one. Without
|
|
5
|
+
* the line below the prompt is silent, and an agent cannot tell "no
|
|
6
|
+
* agreement" from "agreement not shown": it may look for a price to report
|
|
7
|
+
* or reach for a connection the hire would have given.
|
|
8
|
+
*/
|
|
9
|
+
export declare const NO_AGREEMENT_TASK_LINE = "Agreement: none. This task is not done under a deal: it costs nothing, and no agreement's connections apply to it.";
|
|
10
|
+
/** True only when the task row says it carries no agreement (an explicit null). */
|
|
11
|
+
export declare function taskHasNoAgreement(task: {
|
|
12
|
+
agreementId?: unknown;
|
|
13
|
+
} | null | undefined): boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a task given with no agreement means for the agent working it.
|
|
3
|
+
*
|
|
4
|
+
* A task names an agreement only when the work is done under one. Without
|
|
5
|
+
* the line below the prompt is silent, and an agent cannot tell "no
|
|
6
|
+
* agreement" from "agreement not shown": it may look for a price to report
|
|
7
|
+
* or reach for a connection the hire would have given.
|
|
8
|
+
*/
|
|
9
|
+
export const NO_AGREEMENT_TASK_LINE = 'Agreement: none. This task is not done under a deal: it costs nothing, and no agreement\'s connections apply to it.';
|
|
10
|
+
/** True only when the task row says it carries no agreement (an explicit null). */
|
|
11
|
+
export function taskHasNoAgreement(task) {
|
|
12
|
+
return !!task && 'agreementId' in task && task.agreementId === null;
|
|
13
|
+
}
|
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.25",
|
|
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,7 +30,7 @@
|
|
|
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.
|
|
33
|
+
"@ziggs-ai/api-client": "0.42.24",
|
|
34
34
|
"@ziggs-ai/contracts": "0.55.0",
|
|
35
35
|
"ajv": "^8.17.1",
|
|
36
36
|
"dotenv": "^17.2.3",
|