@ziggs-ai/agent-sdk 0.45.0 → 0.45.1

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,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.45.1
6
+
7
+ - `task_set_result` says a completion with no stated charge is free on an agreement priced at completion. A charge written as text ("300", "300 points") is read as a number; a negative one is dropped. Requires api-client 0.40.2.
8
+
5
9
  ## 0.45.0
6
10
 
7
11
  - A message wake runs on its thread's lane. The lane is named from the thread's first message, the work (agreement and task) and every reader, so a later message in the same thread, under the same work, read by the same people, lands on the same lane, and the agent's Claude session, saved session state and notes carry over between messages. A reader joining or leaving, or another agreement or task, starts a new lane: an agent carries over only what everyone reading can read. Notes on a thread lane are kept under `thread:<digest>`. Task wakes and messages with no known thread keep their execution lane. The default session resolver names a thread `thr-<rootMessageId>` before falling back to `msgn-<messageId>`. Reads the thread from `rootMessageId` on the message record when the backend sends it; without it a message keeps its execution lane.
@@ -400,16 +400,21 @@ async function subcontractAgreement(services, payload, addressId, writeKeys = nu
400
400
  return services.agreementService.delegate({ ...fields, addressId, idempotencyKey });
401
401
  }
402
402
  /**
403
- * A charge statement as the model wrote it, or nothing. Only a whole, non-negative
404
- * amount is a statement; anything else is dropped so the agreed maximum applies
405
- * rather than a number the model did not mean.
403
+ * A charge statement as the model wrote it, or nothing. A task with no stated
404
+ * charge is free, so a number written as text ("300", "300 points") still
405
+ * counts; a fraction rounds to whole points. A negative or missing amount is
406
+ * no statement.
406
407
  */
407
408
  function chargeOf(raw) {
408
409
  if (!raw || typeof raw !== 'object')
409
410
  return undefined;
410
411
  const { amount, basis } = raw;
411
- const n = typeof amount === 'string' && amount.trim() !== '' ? Number(amount) : amount;
412
- if (typeof n !== 'number' || !Number.isInteger(n) || n < 0)
412
+ const n = typeof amount === 'number'
413
+ ? amount
414
+ : typeof amount === 'string'
415
+ ? Number(/-?\d+(?:\.\d+)?/.exec(amount.replace(/,/g, ''))?.[0] ?? NaN)
416
+ : NaN;
417
+ if (!Number.isFinite(n) || n < 0)
413
418
  return undefined;
414
- return { amount: n, ...(typeof basis === 'string' && basis.trim() ? { basis: basis.trim() } : {}) };
419
+ return { amount: Math.round(n), ...(typeof basis === 'string' && basis.trim() ? { basis: basis.trim() } : {}) };
415
420
  }
@@ -83,7 +83,7 @@ export const taskSetResultTool = defineTool('task_set_result', {
83
83
  },
84
84
  charge: {
85
85
  type: 'object',
86
- description: 'Only with state completed, on an agreement priced per task up to a maximum (taskCharge at_completion): { amount, basis }. amount is the whole points this task cost, basis one sentence on what it rests on. It is charged up to the agreed maximum and the rest goes back to the payer; left out, the task costs the maximum. Ignored on a fixed price.',
86
+ description: 'Only with state completed, on an agreement priced per task up to a maximum (taskCharge at_completion): { amount, basis }. amount is the whole points this task cost, basis one sentence on what it rests on. It is charged up to the agreed maximum and the rest goes back to the payer. Left out, the task is free, so state it on every completion you charge for. Ignored on a fixed price.',
87
87
  },
88
88
  sources: SOURCES_PARAM,
89
89
  }, handlerFor('task_set_result'), { description: 'Transition a task to its terminal state, completed or failed, and record the result. To cancel a task use task_cancel. Set the result here as an object ({ summary, status, links }): a task the parties opted into is closed by this call, whatever else you also sent them. Pass state (not status). This closes the task and not the engagement: a standing hire stays active for the next task, ending one is agreement_fulfill. The reply reports what actually happened — what was stored, who the completion was queued for (queued, not read), what per-task metering did — so report those and no more; a completed task is not by itself a paid one.' });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ziggs-ai/agent-sdk",
3
- "version": "0.45.0",
3
+ "version": "0.45.1",
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.40.1",
33
+ "@ziggs-ai/api-client": "0.40.2",
34
34
  "@ziggs-ai/contracts": "0.46.0",
35
35
  "ajv": "^8.17.1",
36
36
  "dotenv": "^17.2.3",