@ziggs-ai/agent-sdk 0.46.6 → 0.47.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 (59) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +1 -1
  3. package/dist/Agent.d.ts +5 -7
  4. package/dist/Agent.js +29 -60
  5. package/dist/brain/ClaudeBrain.d.ts +3 -3
  6. package/dist/brain/ClaudeBrain.js +4 -5
  7. package/dist/brain/claudeCognition.js +2 -2
  8. package/dist/brain/claudeSdkProtocol.js +5 -5
  9. package/dist/brain/claudeSdkTools.d.ts +0 -1
  10. package/dist/brain/claudeSdkTools.js +6 -4
  11. package/dist/brain/wakeGate.d.ts +0 -3
  12. package/dist/brain/wakeGate.js +0 -6
  13. package/dist/ingress/normalizeIncoming.d.ts +0 -2
  14. package/dist/ingress/normalizeIncoming.js +0 -9
  15. package/dist/mcp/createMcpAgent.js +2 -2
  16. package/dist/memory/MemoryStore.d.ts +5 -5
  17. package/dist/memory/MemoryStore.js +4 -4
  18. package/dist/platform/OutboxBuffer.d.ts +2 -2
  19. package/dist/platform/OutboxBuffer.js +17 -17
  20. package/dist/platform/WakeLedger.d.ts +0 -2
  21. package/dist/platform/WakeLedger.js +0 -1
  22. package/dist/platform/ZiggsEffectHandler.d.ts +0 -1
  23. package/dist/platform/ZiggsEffectHandler.js +8 -12
  24. package/dist/platform/inboxLoop.js +1 -2
  25. package/dist/platform/polls/PollKind.d.ts +2 -2
  26. package/dist/platform/polls/PollKind.js +1 -1
  27. package/dist/platform/telemetryIngest.js +1 -4
  28. package/dist/platform/tools/tier1/protocolRunner.d.ts +3 -1
  29. package/dist/platform/tools/tier1/protocolRunner.js +10 -23
  30. package/dist/platform/tools/tier1/protocolTools.js +2 -2
  31. package/dist/platform/tools/tier1/wakeTools.d.ts +0 -1
  32. package/dist/platform/tools/tier2/listingTools.js +1 -1
  33. package/dist/platform/tools/tier2/mcpConnectionTools.js +1 -1
  34. package/dist/platform/tools/tier2/partyTools.js +2 -2
  35. package/dist/platform/tools/tier2/planTools.d.ts +2 -2
  36. package/dist/platform/tools/tier2/planTools.js +3 -3
  37. package/dist/runtime/AgentMachine.d.ts +1 -1
  38. package/dist/runtime/AgentMachine.js +1 -1
  39. package/dist/runtime/PromptBuilder.d.ts +1 -1
  40. package/dist/runtime/PromptBuilder.js +7 -9
  41. package/dist/runtime/agreementContext.d.ts +4 -4
  42. package/dist/runtime/agreementContext.js +4 -4
  43. package/dist/runtime/buildOutcome.d.ts +0 -1
  44. package/dist/runtime/deliveryWriteKeys.d.ts +1 -2
  45. package/dist/runtime/deliveryWriteKeys.js +1 -2
  46. package/dist/runtime/kickoff.d.ts +2 -2
  47. package/dist/runtime/kickoff.js +2 -2
  48. package/dist/runtime/messageCommand.d.ts +1 -1
  49. package/dist/runtime/messageCommand.js +1 -1
  50. package/dist/runtime/runTurn.js +5 -18
  51. package/dist/runtime/wakeEffects.d.ts +1 -1
  52. package/dist/runtime/wakeEffects.js +1 -1
  53. package/dist/runtime/wakeOutcome.js +0 -1
  54. package/dist/tools/recordReport.d.ts +3 -5
  55. package/dist/tools/recordReport.js +4 -11
  56. package/dist/tools/toolCreds.d.ts +4 -4
  57. package/dist/tools/toolCreds.js +5 -7
  58. package/dist/types.d.ts +7 -9
  59. package/package.json +2 -2
@@ -4,7 +4,7 @@ export declare const KICKOFF_STATE = "kickingOff";
4
4
  export declare function buildKickoffState(initial: string): ThinkingState;
5
5
  /**
6
6
  * Route a store-claim wake from this state to `to`. The SDK no longer greets
7
- * on a claim (a claim opens no room; the buyer writes first in the agreement's
7
+ * on a claim (a claim starts no conversation; the buyer writes first in the agreement's
8
8
  * conversation), so this is only for an author who wants to act on the claim
9
9
  * itself.
10
10
  *
@@ -25,7 +25,7 @@ export declare function handlesClaimWake(to: string): Transition;
25
25
  * Returns a NEW workflow; input states are not mutated.
26
26
  *
27
27
  * Counterparties never auto-kickoff, and neither does a store claim: a claim
28
- * opens no room, and the buyer's first message or task is what wakes the
28
+ * starts no conversation, and the buyer's first message or task is what wakes the
29
29
  * provider.
30
30
  */
31
31
  export declare function injectKickoffDefault(workflow: Workflow): Workflow;
@@ -83,7 +83,7 @@ export function buildKickoffState(initial) {
83
83
  }
84
84
  /**
85
85
  * Route a store-claim wake from this state to `to`. The SDK no longer greets
86
- * on a claim (a claim opens no room; the buyer writes first in the agreement's
86
+ * on a claim (a claim starts no conversation; the buyer writes first in the agreement's
87
87
  * conversation), so this is only for an author who wants to act on the claim
88
88
  * itself.
89
89
  *
@@ -109,7 +109,7 @@ export function handlesClaimWake(to) {
109
109
  * Returns a NEW workflow; input states are not mutated.
110
110
  *
111
111
  * Counterparties never auto-kickoff, and neither does a store claim: a claim
112
- * opens no room, and the buyer's first message or task is what wakes the
112
+ * starts no conversation, and the buyer's first message or task is what wakes the
113
113
  * provider.
114
114
  */
115
115
  export function injectKickoffDefault(workflow) {
@@ -13,7 +13,7 @@ export interface ResponseCommandOptions {
13
13
  recipientId?: string;
14
14
  }
15
15
  /** Compose an FSM message from the current wake. A session locates the wake
16
- * context; it is never a room, principal or authority identifier.
16
+ * context; it is never a destination, principal or authority identifier.
17
17
  *
18
18
  * A reply from a wake names nobody: the backend links it to the trigger and
19
19
  * fills readers and recipients from the trigger's own readers and sender. An
@@ -1,6 +1,6 @@
1
1
  import { randomUUID } from 'node:crypto';
2
2
  /** Compose an FSM message from the current wake. A session locates the wake
3
- * context; it is never a room, principal or authority identifier.
3
+ * context; it is never a destination, principal or authority identifier.
4
4
  *
5
5
  * A reply from a wake names nobody: the backend links it to the trigger and
6
6
  * fills readers and recipients from the trigger's own readers and sender. An
@@ -118,7 +118,7 @@ export async function runTurn(input) {
118
118
  statePrompt, actions,
119
119
  serverContext: { context: ctxObj, tools: tools },
120
120
  incomingEvent, definition,
121
- addressId: sessionId, stateId, ctx,
121
+ sessionId, stateId, ctx,
122
122
  omitMessageFromRespond: streamRespondActions,
123
123
  });
124
124
  const systemContent = tools.length > 0
@@ -375,7 +375,7 @@ export async function runTurn(input) {
375
375
  receiverId: decision.receiverId,
376
376
  }) ?? chunkMessageId;
377
377
  await eff({ kind: 'send-message', sessionId, command: await responseCommand(eff, sessionId, safeText, { recipientId: decision.receiverId, operationId: persistMessageId }) });
378
- allEmittedEvents.push({ type: 'message_sent', receiverId: decision.receiverId, addressId: sessionId, message: safeText, senderId: 'system' });
378
+ allEmittedEvents.push({ type: 'message_sent', receiverId: decision.receiverId, message: safeText, senderId: 'system' });
379
379
  lastAction = chosenAction;
380
380
  lastActionDef = actionDef;
381
381
  }
@@ -682,19 +682,13 @@ function truncateMsg(msg) {
682
682
  return msg.slice(0, MAX_MSG_CHARS) + `\n\n[truncated to ${MAX_MSG_CHARS} of ${msg.length} chars]`;
683
683
  }
684
684
  async function executeSendMessage(decision, eff, sessionId) {
685
- if (decision.addressId && decision.addressId !== sessionId)
686
- throw new Error('A response cannot route through a room. Use message_send with explicit recipients and mandate.');
687
- const targetSessionId = sessionId;
688
685
  const safeMessage = truncateMsg(decision.message);
689
686
  const receiverId = decision.receiverId || undefined;
690
687
  await eff({
691
688
  kind: 'send-message', sessionId,
692
689
  command: await responseCommand(eff, sessionId, safeMessage, { recipientId: receiverId }),
693
690
  });
694
- const events = [{ type: 'message_sent', ...(receiverId ? { receiverId } : {}), addressId: targetSessionId, message: safeMessage, senderId: 'system' }];
695
- if (targetSessionId !== sessionId)
696
- events.push({ type: 'report_sent', message: 'Reported to owner.', senderId: 'system' });
697
- return events;
691
+ return [{ type: 'message_sent', ...(receiverId ? { receiverId } : {}), message: safeMessage, senderId: 'system' }];
698
692
  }
699
693
  /**
700
694
  * Multi-message send. `message_sent` is emitted ONLY for sends that actually
@@ -714,11 +708,6 @@ async function executeSendMessages(decision, eff, sessionId) {
714
708
  failures.push({ receiverId: msg.receiverId || '<missing>', error: 'missing message' });
715
709
  continue;
716
710
  }
717
- if (msg.addressId && msg.addressId !== sessionId) {
718
- failures.push({ receiverId: msg.receiverId, error: 'Use message_send with explicit recipients and mandate for a separate destination' });
719
- continue;
720
- }
721
- const targetSessionId = sessionId;
722
711
  const safeMessage = truncateMsg(msg.message);
723
712
  attempted++;
724
713
  try {
@@ -733,9 +722,7 @@ async function executeSendMessages(decision, eff, sessionId) {
733
722
  failures.push({ receiverId: msg.receiverId, error: err.message });
734
723
  continue;
735
724
  }
736
- events.push({ type: 'message_sent', receiverId: msg.receiverId, addressId: targetSessionId, message: safeMessage, senderId: 'system' });
737
- if (targetSessionId !== sessionId)
738
- events.push({ type: 'report_sent', message: 'Reported to owner.', senderId: 'system' });
725
+ events.push({ type: 'message_sent', receiverId: msg.receiverId, message: safeMessage, senderId: 'system' });
739
726
  }
740
727
  if (attempted === 0)
741
728
  return null; // every entry malformed — LLM output defect, caller reprompts
@@ -824,7 +811,7 @@ async function echoOptInToolSummaryIfNeeded({ allEmittedEvents, eff, sessionId,
824
811
  catch {
825
812
  return;
826
813
  }
827
- const event = { type: 'message_sent', receiverId, addressId: sessionId, message: safe, senderId: 'system' };
814
+ const event = { type: 'message_sent', receiverId, message: safe, senderId: 'system' };
828
815
  if (wasTruncated) {
829
816
  event['truncated'] = true;
830
817
  event['originalLength'] = summary.length;
@@ -12,7 +12,7 @@ export declare function contextScopesFromWake(event: unknown, sessionId: string)
12
12
  messageId?: string;
13
13
  artifactId?: string;
14
14
  }>;
15
- /** Per-wake observation, including effects nested inside tools and cross-room sends. */
15
+ /** Per-wake observation, including effects nested inside tools and sends to other conversations. */
16
16
  export declare class WakeEffects {
17
17
  private readonly initialScope;
18
18
  private readonly inferScope;
@@ -42,7 +42,7 @@ export function contextScopesFromWake(event, sessionId) {
42
42
  ? [{ ...scope, ...(messageId ? { messageId } : {}), ...(artifactId ? { artifactId } : {}) }] : [];
43
43
  }
44
44
  const TASK_WRITES = new Set(['task_create', 'task_set_result', 'task_update_plan_step', 'task_replace_plan']);
45
- /** Per-wake observation, including effects nested inside tools and cross-room sends. */
45
+ /** Per-wake observation, including effects nested inside tools and sends to other conversations. */
46
46
  export class WakeEffects {
47
47
  initialScope;
48
48
  inferScope;
@@ -72,7 +72,6 @@ export function classifyWakeOutcome(input) {
72
72
  export function buildWakeOutcomePayload(input) {
73
73
  return {
74
74
  source: 'agent',
75
- addressId: input.sessionId,
76
75
  sessionId: input.sessionId,
77
76
  execution: {
78
77
  llmCallsTotal: input.llmCalls ?? 0,
@@ -13,12 +13,10 @@ export interface RecordReportInput {
13
13
  taskId: string;
14
14
  report: TaskReport;
15
15
  /**
16
- * Optional container for the deliverable artifact (it used to be
17
- * required). The task binding is what makes the deliverable retrievable and
18
- * readable by the task's parties; a chat or agreement only widens where it also
19
- * shows up. Pass at most one; when both arrive, agreementId wins.
16
+ * Optional agreement for the deliverable artifact. The task binding is what
17
+ * makes the deliverable retrievable and readable by the task's parties; an
18
+ * agreement only widens where it also shows up.
20
19
  */
21
- addressId?: string;
22
20
  agreementId?: string;
23
21
  /**
24
22
  * Heavy deliverable text (document, diff, data).
@@ -14,18 +14,11 @@ import { ArtifactsClient, updateTaskState, } from '@ziggs-ai/api-client';
14
14
  * Implements the B1 convention (Agents/REPORTING.md).
15
15
  */
16
16
  export async function recordReport(input) {
17
- const { creds, taskId, report, addressId, agreementId, deliverable } = input;
18
- // no container needed. The deliverable is bound to its task, which
17
+ const { creds, taskId, report, agreementId, deliverable } = input;
18
+ // No container needed. The deliverable is bound to its task, which
19
19
  // is what makes it retrievable as `via=task:<taskId>` and readable by the
20
- // task's parties — a chat or agreement was never what made that work.
21
- //
22
- // the agreement still wins here, and this is now the ONE place that
23
- // resolves rather than refuses — deliberately, because the caller is not a
24
- // model choosing arguments. `recordReport` is handed both ids by the runtime
25
- // (the task's agreement and the chat it is running in), so there is no
26
- // mistake to surface and nobody to retry: refusing would fail a finished
27
- // task's delivery over a pair of ids it did not choose.
28
- const scope = agreementId ? { agreementId } : addressId ? { addressId } : {};
20
+ // task's parties.
21
+ const scope = agreementId ? { agreementId } : {};
29
22
  // Deliverable FIRST, then close the task.
30
23
  //
31
24
  // The old order completed the task and then wrote the artifact with the
@@ -4,7 +4,7 @@
4
4
  * A custom tool builds `{ operatorKey, agentId }` by hand and stops there, so
5
5
  * every call it makes runs on the narrowest reach fence there is: the agent's
6
6
  * own org. `Agent` already threads the wake's lane into the tool context
7
- * (as `addressId` / `sessionId`, which is what the capability adapter reads), and
7
+ * (as `sessionId`, which is what the capability adapter reads), and
8
8
  * the backend's fence is "own org ∪ the orgs of the parties to this lane" — so
9
9
  * a tool that does not pass it loses reach it is entitled to, and loses it
10
10
  * SILENTLY: enumerations come back short rather than refused.
@@ -23,14 +23,14 @@ import { type Creds } from '@ziggs-ai/api-client';
23
23
  /** The loose bag `defineTool` hands a handler. */
24
24
  type ToolContext = Record<string, unknown> | undefined | null;
25
25
  /**
26
- * The wake's lane, as the backend's `X-Ziggs-Lane` expects it: a chat id, or
26
+ * The wake's lane, as the backend's `X-Ziggs-Lane` expects it: for example
27
27
  * `agrn-<agreementId>` for an agreement lane. Undefined when the tool is
28
28
  * running outside any lane (a bootstrap sweep, a test), which the fence reads
29
29
  * as "own org only".
30
30
  *
31
- * A room wake that handles mail under an agreement (`wakeAgreementId`, taken
31
+ * A wake that handles mail under an agreement (`wakeAgreementId`, taken
32
32
  * from the delivery itself) names it too, so the backend scopes the wake to
33
- * that agreement rather than inferring it from the room's mail.
33
+ * that agreement rather than inferring it from the mail.
34
34
  */
35
35
  export declare function laneFromToolContext(ctx: ToolContext): string | undefined;
36
36
  /**
@@ -4,7 +4,7 @@
4
4
  * A custom tool builds `{ operatorKey, agentId }` by hand and stops there, so
5
5
  * every call it makes runs on the narrowest reach fence there is: the agent's
6
6
  * own org. `Agent` already threads the wake's lane into the tool context
7
- * (as `addressId` / `sessionId`, which is what the capability adapter reads), and
7
+ * (as `sessionId`, which is what the capability adapter reads), and
8
8
  * the backend's fence is "own org ∪ the orgs of the parties to this lane" — so
9
9
  * a tool that does not pass it loses reach it is entitled to, and loses it
10
10
  * SILENTLY: enumerations come back short rather than refused.
@@ -25,19 +25,17 @@ const str = (ctx, key) => {
25
25
  return typeof value === 'string' && value.trim() ? value : undefined;
26
26
  };
27
27
  /**
28
- * The wake's lane, as the backend's `X-Ziggs-Lane` expects it: a chat id, or
28
+ * The wake's lane, as the backend's `X-Ziggs-Lane` expects it: for example
29
29
  * `agrn-<agreementId>` for an agreement lane. Undefined when the tool is
30
30
  * running outside any lane (a bootstrap sweep, a test), which the fence reads
31
31
  * as "own org only".
32
32
  *
33
- * A room wake that handles mail under an agreement (`wakeAgreementId`, taken
33
+ * A wake that handles mail under an agreement (`wakeAgreementId`, taken
34
34
  * from the delivery itself) names it too, so the backend scopes the wake to
35
- * that agreement rather than inferring it from the room's mail.
35
+ * that agreement rather than inferring it from the mail.
36
36
  */
37
37
  export function laneFromToolContext(ctx) {
38
- // The executor names the lane `sessionId`; `addressId` is only the wake's
39
- // explicit conversation, so it is the lane only where nothing else is.
40
- const lane = str(ctx, 'sessionId') ?? str(ctx, 'addressId');
38
+ const lane = str(ctx, 'sessionId');
41
39
  return lane ? laneUnderAgreement(lane, str(ctx, 'wakeAgreementId')) : undefined;
42
40
  }
43
41
  /**
package/dist/types.d.ts CHANGED
@@ -137,9 +137,9 @@ export type Outcome = {
137
137
  * `{ sessionId, ctx, queue, parked }`. `Identity` is the Agent's view of
138
138
  * which session this tick belongs to. `sessionId` is opaque to the Agent —
139
139
  * it's a string the Server uses to route inbound events and outbound
140
- * effects. (Today, the Ziggs transport derives sessionId from `addressId` at
141
- * the wire boundary; non-chat surfaces will produce sessionIds of other
142
- * shapes.)
140
+ * effects. (Today, the Ziggs transport derives sessionId from the wake's
141
+ * agreement, bucket or message at the wire boundary; other surfaces will
142
+ * produce sessionIds of other shapes.)
143
143
  */
144
144
  export interface Identity {
145
145
  agentId: string;
@@ -443,7 +443,7 @@ export interface DeliveryWriteKeys {
443
443
  taskStateKey(taskId: string, state: string): string | undefined;
444
444
  /**
445
445
  * Default messageId for a chat-message send of this wake — the backend dedups
446
- * on (addressId, messageId). Derived from the emission's content (text + chat +
446
+ * on messageId. Derived from the emission's content (text + chat +
447
447
  * receiver), not a per-wake ordinal: a wake that says two things
448
448
  * gets two keys, and a redelivered wake that re-says the same text reuses the
449
449
  * same key, while a re-think with different text does not collide and drop.
@@ -524,10 +524,8 @@ export type Effect = {
524
524
  checkout?: import('./checkout/tools.js').CheckoutSession;
525
525
  }
526
526
  /**
527
- * `receiverId` is optional: in a room with one other participant the backend
528
- * resolves the recipient from the room itself, which is the only answer
529
- * available when the wake's sender belongs to a DIFFERENT room.
530
- * Name a receiver whenever the room holds more than two parties.
527
+ * `receiverId` is optional: without one, a reply goes to the sender of the
528
+ * message it answers. Name a receiver whenever you mean someone else.
531
529
  */
532
530
  | {
533
531
  kind: 'send-message';
@@ -556,7 +554,7 @@ export interface EffectResultMap {
556
554
  /**
557
555
  * `{ ok: true }` said the call did not throw, and a brain reading it had no
558
556
  * way to tell a message that woke the agent it meant to from one the server
559
- * widened to the room's humans. The send's own report rides along when the
557
+ * widened to other people. The send's own report rides along when the
560
558
  * backend makes one: where it went. Routing is separate from acceptance.
561
559
  */
562
560
  'send-message': MessageCommandResult & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ziggs-ai/agent-sdk",
3
- "version": "0.46.6",
3
+ "version": "0.47.0",
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.7",
33
+ "@ziggs-ai/api-client": "0.41.0",
34
34
  "@ziggs-ai/contracts": "0.48.1",
35
35
  "ajv": "^8.17.1",
36
36
  "dotenv": "^17.2.3",