@ziggs-ai/agent-sdk 0.20.0 → 0.21.0

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.
Files changed (51) hide show
  1. package/dist/Agent.d.ts +28 -7
  2. package/dist/Agent.js +176 -71
  3. package/dist/brain/ClaudeBrain.d.ts +11 -1
  4. package/dist/brain/ClaudeBrain.js +71 -18
  5. package/dist/brain/ZiggsBrain.d.ts +2 -0
  6. package/dist/brain/ZiggsBrain.js +1 -0
  7. package/dist/brain/claudeCognition.d.ts +1 -1
  8. package/dist/brain/claudeCognition.js +47 -7
  9. package/dist/brain/claudeSdkProtocol.d.ts +1 -1
  10. package/dist/brain/claudeSdkProtocol.js +1 -1
  11. package/dist/brain/claudeSdkTools.d.ts +3 -0
  12. package/dist/brain/claudeSdkTools.js +4 -2
  13. package/dist/brain/hireActivationNotice.d.ts +19 -0
  14. package/dist/brain/hireActivationNotice.js +79 -0
  15. package/dist/brain/standingOfferNotice.d.ts +15 -0
  16. package/dist/brain/standingOfferNotice.js +89 -0
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.js +1 -1
  19. package/dist/ingress/normalizeIncoming.d.ts +3 -0
  20. package/dist/ingress/normalizeIncoming.js +8 -0
  21. package/dist/mcp/createMcpAgent.d.ts +1 -1
  22. package/dist/mcp/createMcpAgent.js +1 -1
  23. package/dist/memory/MemoryStore.d.ts +18 -4
  24. package/dist/memory/MemoryStore.js +52 -12
  25. package/dist/platform/ConnectionPool.d.ts +9 -4
  26. package/dist/platform/ConnectionPool.js +16 -6
  27. package/dist/platform/StateTimers.d.ts +12 -6
  28. package/dist/platform/StateTimers.js +26 -6
  29. package/dist/platform/ZiggsEffectHandler.js +5 -1
  30. package/dist/platform/inboxLoop.d.ts +5 -7
  31. package/dist/platform/inboxLoop.js +36 -80
  32. package/dist/platform/polls/declaredPollRunner.d.ts +7 -1
  33. package/dist/platform/polls/declaredPollRunner.js +7 -9
  34. package/dist/platform/tools/index.d.ts +1 -0
  35. package/dist/platform/tools/index.js +1 -0
  36. package/dist/platform/tools/tier2/contextTools.d.ts +2 -0
  37. package/dist/platform/tools/tier2/contextTools.js +3 -1
  38. package/dist/platform/tools/tier2/planTools.d.ts +20 -0
  39. package/dist/platform/tools/tier2/planTools.js +64 -0
  40. package/dist/pricing/fleetDefaults.js +4 -9
  41. package/dist/pricing/fleetTierByAgentId.gen.d.ts +1 -1
  42. package/dist/pricing/fleetTierByAgentId.gen.js +2 -752
  43. package/dist/runtime/AgentMachine.d.ts +3 -0
  44. package/dist/runtime/AgentMachine.js +6 -1
  45. package/dist/runtime/runTurn.d.ts +1 -0
  46. package/dist/runtime/runTurn.js +19 -15
  47. package/dist/runtime/wakeEffects.d.ts +35 -0
  48. package/dist/runtime/wakeEffects.js +121 -0
  49. package/package.json +2 -2
  50. package/dist/pricing/fleetFreeTierA.gen.d.ts +0 -6
  51. package/dist/pricing/fleetFreeTierA.gen.js +0 -11
@@ -0,0 +1,20 @@
1
+ import { type ToolDefinition } from '../../../tools/defineTool.js';
2
+ /**
3
+ * `task_replace_plan` — write the checklist of a task you hold.
4
+ *
5
+ * The hosted tool set could only UPDATE a step that already existed
6
+ * (`task_update_plan_step` takes a stepId), and a task created without a plan
7
+ * has none, so an agent had no way to record anything about its own work on
8
+ * the task row. That mattered the moment one agent served two customers: from
9
+ * the second customer's room it could not find the approval request it had
10
+ * sent under the first customer's hire, and told them it had never been sent
11
+ * (store-opening lab, 2026-09-15). The MCP surface has had
12
+ * `ziggs_task_replace_plan` all along; this is the same client call for the
13
+ * hosted brain.
14
+ *
15
+ * The plan is the agent's own notebook on the task: step results can carry
16
+ * ids (an approval agreement, an artifact), and `task_list` reads the plan back
17
+ * from any room the agent is woken in.
18
+ */
19
+ export declare const taskReplacePlanTool: ToolDefinition;
20
+ export declare const PLAN_TOOLS: ToolDefinition[];
@@ -0,0 +1,64 @@
1
+ import { replaceTaskPlan } from '@ziggs-ai/api-client';
2
+ import { defineTool } from '../../../tools/defineTool.js';
3
+ import { credsFromToolContext } from '../../../tools/toolCreds.js';
4
+ /**
5
+ * `task_replace_plan` — write the checklist of a task you hold.
6
+ *
7
+ * The hosted tool set could only UPDATE a step that already existed
8
+ * (`task_update_plan_step` takes a stepId), and a task created without a plan
9
+ * has none, so an agent had no way to record anything about its own work on
10
+ * the task row. That mattered the moment one agent served two customers: from
11
+ * the second customer's room it could not find the approval request it had
12
+ * sent under the first customer's hire, and told them it had never been sent
13
+ * (store-opening lab, 2026-09-15). The MCP surface has had
14
+ * `ziggs_task_replace_plan` all along; this is the same client call for the
15
+ * hosted brain.
16
+ *
17
+ * The plan is the agent's own notebook on the task: step results can carry
18
+ * ids (an approval agreement, an artifact), and `task_list` reads the plan back
19
+ * from any room the agent is woken in.
20
+ */
21
+ export const taskReplacePlanTool = defineTool('task_replace_plan', {
22
+ taskId: { type: 'string', required: true, minLength: 1, pattern: '\\S' },
23
+ steps: {
24
+ type: 'array',
25
+ required: true,
26
+ items: {
27
+ type: 'object',
28
+ properties: {
29
+ stepId: {
30
+ type: 'string',
31
+ description: 'Stable id for this step. Omit to let the server assign step-<n>.',
32
+ },
33
+ description: { type: 'string', minLength: 1, pattern: '\\S' },
34
+ order: {
35
+ type: 'integer',
36
+ description: 'Position in the plan. Omit to use the array index.',
37
+ },
38
+ status: {
39
+ type: 'string',
40
+ enum: ['pending', 'in_progress', 'completed', 'skipped'],
41
+ description: 'Step progress. Omit for pending.',
42
+ },
43
+ result: {
44
+ type: 'object',
45
+ description: 'What this step produced, as an object — e.g. { "agreementId": "agr_…" } for an approval you requested, or { "artifactId": "art_…" } for a pack you recorded. Stored with the step and read back by task_list.',
46
+ },
47
+ },
48
+ required: ['description'],
49
+ },
50
+ description: 'The FULL ordered step list. Existing steps are replaced wholesale, not appended to — read the current plan with task_list first and send it back with your changes.',
51
+ },
52
+ }, async (args, ctx) => {
53
+ const creds = credsFromToolContext(ctx, 'task_replace_plan');
54
+ const taskId = typeof args.taskId === 'string' ? args.taskId.trim() : '';
55
+ if (!taskId)
56
+ throw new Error('task_replace_plan: taskId is required');
57
+ const steps = args.steps;
58
+ if (!Array.isArray(steps))
59
+ throw new Error('task_replace_plan: steps must be an array');
60
+ return replaceTaskPlan(taskId, steps, creds);
61
+ }, {
62
+ description: 'Replace the plan of a task you hold with the full ordered step list. Use it to write your own checklist on a task that arrived without one, and to record what a step produced (an approval agreement id, an artifact id) so a later wake — in any room — can find it with task_list. Steps you do not send are removed; mark finished steps completed so closing the task does not rewrite them as skipped.',
63
+ });
64
+ export const PLAN_TOOLS = [taskReplacePlanTool];
@@ -3,7 +3,6 @@
3
3
  * Prices are in wallet cents (1 ZIG = 100 cents).
4
4
  */
5
5
  import { FLEET_TIER_BY_AGENT_ID } from './fleetTierByAgentId.gen.js';
6
- import { FREE_TIER_A_AGENT_IDS } from './fleetFreeTierA.gen.js';
7
6
  import { isEvalFreeExecutor } from './fleetEvalFree.js';
8
7
  export const ZIGGS_OPERATOR_CUT_BPS = 1000; // 10%
9
8
  export const TIER_PRICE_CENTS = {
@@ -13,7 +12,6 @@ export const TIER_PRICE_CENTS = {
13
12
  D: 100, // 1 ZIG / call (hand-written demo agents)
14
13
  };
15
14
  const PING_DESCRIPTION_PATTERN = /\b(ping|health\s*check|healthcheck|liveness|readiness|heartbeat)\b/i;
16
- const TRIVIAL_LOOKUP_DESCRIPTION_PATTERN = /\b(what\s+time|current\s+time|local\s+time|world\s+clock|timezone|time\s+zone|weather|forecast|temperature|uv\s+index)\b/i;
17
15
  export function resolveFleetTier(agentId) {
18
16
  if (!agentId || typeof agentId !== 'string')
19
17
  return null;
@@ -30,15 +28,12 @@ export function isFreeAllowlistedExecutor(executorId, description) {
30
28
  return false;
31
29
  if (isEvalFreeExecutor(executorId))
32
30
  return true;
33
- if (FREE_TIER_A_AGENT_IDS.has(executorId))
34
- return true;
31
+ // A health check does not bill, whatever tier the executor is in. This is
32
+ // the only description-based exemption left: an agent whose work should cost
33
+ // nothing says so with a posted price of 0 on its own listing, where the
34
+ // buyer can see it, rather than through a rule inferred here.
35
35
  if (description && PING_DESCRIPTION_PATTERN.test(description))
36
36
  return true;
37
- if (description &&
38
- TRIVIAL_LOOKUP_DESCRIPTION_PATTERN.test(description) &&
39
- FREE_TIER_A_AGENT_IDS.has(executorId)) {
40
- return true;
41
- }
42
37
  return false;
43
38
  }
44
39
  export function resolveDefaultPriceCentsForExecutor(executorId, description) {
@@ -4,4 +4,4 @@
4
4
  */
5
5
  export type FleetPricingTier = 'A' | 'B' | 'C' | 'D';
6
6
  export declare const FLEET_TIER_BY_AGENT_ID: Record<string, FleetPricingTier>;
7
- export declare const FLEET_TIER_MAP_SIZE = 767;
7
+ export declare const FLEET_TIER_MAP_SIZE = 17;