@ziggs-ai/api-client 0.40.0 → 0.40.2
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/tasks.d.ts +8 -0
- package/dist/capabilities/tasks.js +10 -1
- package/dist/http/TaskClient.d.ts +14 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.40.2
|
|
6
|
+
|
|
7
|
+
- A task on an agreement priced at completion with no stated charge is free; the outcome's metering line says so. `charge` docs say the same.
|
|
8
|
+
|
|
9
|
+
## 0.40.1
|
|
10
|
+
|
|
11
|
+
- `updateTaskState` takes `charge: { amount, basis? }` with `completed`: what the task cost and what that rests on. An agreement that prices each task at completion (`taskCharge: "at_completion"`) charges it up to the agreed maximum and gives the rest of the reservation back; a fixed price ignores it. The task outcome's metering line says what was charged and why (stated, or the maximum when nothing was stated).
|
|
12
|
+
|
|
5
13
|
## 0.40.0
|
|
6
14
|
|
|
7
15
|
- Every message carries one flag, `intent: "fyi" | "request"`, in place of `effect`. 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, so `message_answers` and `message_answer_cancel` are gone and message records carry `intent` instead of `requestedAnswers`. Inbox envelopes no longer list `answersAwaitingMe`. Requires contracts 0.46.0.
|
|
@@ -32,6 +32,14 @@ export interface TaskOutcomeEffects {
|
|
|
32
32
|
reason?: string;
|
|
33
33
|
amount?: number;
|
|
34
34
|
transactionId?: string;
|
|
35
|
+
/** What the charge rests on: `fixed`, `stated` (with the provider's note) or `maximum`. */
|
|
36
|
+
charge?: {
|
|
37
|
+
amount?: number;
|
|
38
|
+
maximum?: number;
|
|
39
|
+
basis?: 'fixed' | 'stated' | 'none' | string;
|
|
40
|
+
note?: string;
|
|
41
|
+
capped?: boolean;
|
|
42
|
+
};
|
|
35
43
|
};
|
|
36
44
|
agreement?: {
|
|
37
45
|
agreementId: string;
|
|
@@ -149,7 +149,7 @@ export function presentTaskOutcome(confirm, env) {
|
|
|
149
149
|
const metering = !settlement
|
|
150
150
|
? undefined
|
|
151
151
|
: settlement.settled
|
|
152
|
-
? `Metered per completed task: this completion settled ${settlement.amount ?? 'the agreed rate'}${settlement.transactionId ? ` (tx ${settlement.transactionId})` : ''}. One execution, once — a retry of this same transition does not charge again.`
|
|
152
|
+
? `Metered per completed task: this completion settled ${settlement.amount ?? 'the agreed rate'}${settlement.transactionId ? ` (tx ${settlement.transactionId})` : ''}${chargeBasisLine(settlement.charge)}. One execution, once — a retry of this same transition does not charge again.`
|
|
153
153
|
: `No payment moved on this completion — ${SETTLEMENT_REASONS[settlement.reason ?? ''] ?? settlement.reason ?? 'settlement did not run'}. Do not report this task as paid.`;
|
|
154
154
|
const agreementFacts = effects?.agreement;
|
|
155
155
|
const agreement = !agreementFacts
|
|
@@ -216,3 +216,12 @@ export const TASK_CAPABILITIES = [
|
|
|
216
216
|
cancelTaskCapability,
|
|
217
217
|
delegateTaskCapability,
|
|
218
218
|
];
|
|
219
|
+
/** Why a settled amount is what it is, when the agreement priced the task at completion. */
|
|
220
|
+
function chargeBasisLine(charge) {
|
|
221
|
+
if (!charge || charge.basis === 'fixed' || charge.basis == null)
|
|
222
|
+
return '';
|
|
223
|
+
const max = charge.maximum != null ? ` of up to ${charge.maximum}` : '';
|
|
224
|
+
if (charge.basis === 'none')
|
|
225
|
+
return `${max}: free, because no charge was stated with the completion`;
|
|
226
|
+
return `${max}, as stated${charge.note ? ` (${charge.note})` : ''}${charge.capped ? ', capped at the maximum' : ''}`;
|
|
227
|
+
}
|
|
@@ -155,6 +155,20 @@ export interface UpdateTaskStateData {
|
|
|
155
155
|
idempotencyKey?: string;
|
|
156
156
|
/** What the result drew on. Recorded only when a result is written. */
|
|
157
157
|
sources?: WriteSource[];
|
|
158
|
+
/**
|
|
159
|
+
* What this task cost, stated with `completed`. Read only when the agreement
|
|
160
|
+
* prices each task at completion (`taskCharge: 'at_completion'`), where it is
|
|
161
|
+
* capped at the agreed maximum and the rest of the reservation goes back to
|
|
162
|
+
* the payer. Omitted there, the task is free.
|
|
163
|
+
*/
|
|
164
|
+
charge?: TaskChargeStatement;
|
|
165
|
+
}
|
|
166
|
+
/** What one completed task cost, and what that amount rests on. */
|
|
167
|
+
export interface TaskChargeStatement {
|
|
168
|
+
/** Points, a whole number, at least 0. */
|
|
169
|
+
amount: number;
|
|
170
|
+
/** A sentence the payer reads, e.g. "3 searches and a 2-page brief". */
|
|
171
|
+
basis?: string;
|
|
158
172
|
}
|
|
159
173
|
export declare function updateTaskState(taskId: string, state: TaskUpdateState, data: UpdateTaskStateData | undefined, creds: Creds): Promise<TaskWriteConfirm>;
|
|
160
174
|
export declare function getActiveTasksForAgent(agentId: string, creds: Creds): Promise<Task[]>;
|