@ziggs-ai/agent-sdk 0.43.9 → 0.44.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.44.0
6
+
7
+ - Every message carries one flag, `intent: "fyi" | "request"`, in place of `effect`. The host wakes an agent only for a request it was assigned; an fyi lands in the inbox with no assignee and never wakes anyone. Nothing records whether a request was answered, so the pending-answer recovery loop is gone and a wake is deduplicated on its receipt alone.
8
+ - `responseCommand(eff, sessionId, text, { operationId?, intent?, recipientId? })` replaces the answer-slot form. A reply from a wake names nobody: the server links it to the message that woke the agent and delivers it to that message's readers and sender. Pass `recipientId` for a send outside a wake, or to someone other than the trigger's sender.
9
+ - The Claude protocol tells an agent to reply with text and flag it a request only when the other side's agent must act. `message_send` takes `intent` instead of `effect`. Requires contracts 0.46.0.
10
+
11
+ - Uses api-client 0.40.0 and contracts 0.46.0.
12
+
13
+ ## 0.43.10
14
+
15
+ - Uses api-client 0.39.5 (message_send names the send-grant path when a reader has no contact basis).
16
+
5
17
  ## 0.43.9
6
18
 
7
19
  ## 0.43.8
@@ -309,15 +309,15 @@ export class ClaudeBrain {
309
309
  };
310
310
  }
311
311
  }
312
- // An answer explicitly assigned by the server is work, even if its text
313
- // sounds like a greeting or FYI. The classifier cannot cancel that action.
314
- // Use the host's current execution, never message prose or a lane name.
312
+ // A request the server assigned to this agent is work, even if its text
313
+ // sounds like a greeting or FYI: only a request wakes an agent, so the
314
+ // classifier cannot cancel that action. Use the host's current execution,
315
+ // never message prose or a lane name.
315
316
  const execution = currentWorkExecution();
316
- const assignedAnswer = execution?.actorId === this.agentId &&
317
- execution.action?.kind === 'message' && execution.action.slot === 'answer';
317
+ const assignedRequest = execution?.actorId === this.agentId && execution.action?.kind === 'message';
318
318
  // Before the breaker counts this wake: a skipped turn costs
319
319
  // nothing, so it must not bring the breaker closer.
320
- const gateMessages = this.askWakeGate && !assignedAnswer
320
+ const gateMessages = this.askWakeGate && !assignedRequest
321
321
  ? gateableMessages(rawEvent)
322
322
  : null;
323
323
  if (gateMessages && this.askWakeGate) {
@@ -18,16 +18,16 @@ Each wake hands you ONE event (or a small batch). Read workBrief for current wor
18
18
 
19
19
  Ziggs tools loaded with their full schemas are ${loadedByName}, plus any tools that belong to you specifically. Every other Ziggs tool exists too and is called by its own name; its schema loads when you look it up with ToolSearch, by name or by what you need done. When the lines below name \`context_snapshot\`, \`wake_at\`, \`task_list\`, \`task_update_plan_step\`, \`grant_list\`, or an agreement verb, look it up that way and call it.
20
20
 
21
- Your prose and final summary are private host notes, not messages to the people or agents you work with. To answer an incoming question, use the reply action in workBrief. All private, group and work communication uses \`message_send\` with one \`command\`: stable operationId, content:{text}, audience:{kind:"explicit",principalIds:[...]}, deliveries:{kind:"explicit",principalIds:[...]}, and effect. effect:{kind:"none"} requests no action; request-answers names each requestId and responsiblePrincipalId. To resolve a requested answer, use effect:{kind:"answer",action:{kind:"message",id,slot:"answer",requestId},artifacts:[]}. An FYI, causal relationships.replyToMessageId, or inbox ACK does not resolve it. Keep an explicitly selected mandate:{agreementId,taskId?}. Reuse the exact command after an uncertain response. Never treat a 409 as success. Reading the answer and writing it in your final summary does not deliver it. Do not finish a question wake until the reply tool confirms delivery, or you have surfaced a concrete blocker through the appropriate channel.
21
+ Your prose and final summary are private host notes, not messages to the people or agents you work with. To reply, use the reply action in workBrief: it sends your text, and the host links it to the message that woke you and delivers it to that message's readers and sender. All private, group and work communication uses \`message_send\` with one \`command\`: stable operationId, content:{text}, audience:{kind:"explicit",principalIds:[...]}, deliveries:{kind:"explicit",principalIds:[...]}, and intent. Every message carries one flag: intent:"request" wakes the agents it is delivered to; intent:"fyi" is delivered and filed and never wakes anyone. You are woken only for requests; an fyi reaches your inbox without waking you. Flag your own message a request only when you need the other side's agent to act on it; a reply to a person is an fyi. Nothing records whether a request was answered: a reply is a message whose relationships.replyToMessageId names what it answers. Keep an explicitly selected mandate:{agreementId,taskId?}. Reuse the exact command after an uncertain response. Never treat a 409 as success. Reading the question and writing the answer in your final summary does not deliver it: send it.
22
22
 
23
- - The event identifies the assigned action. Use \`context_snapshot\` with its exact message, task, agreement or artifact reference. Readers, delivery recipients and the actor who owes a reply are separate. A notify message creates no new obligation; a task input advances its existing task. Use \`message_replies\` for authorized causal replies; history does not come from inbox receipts.
23
+ - The event identifies the assigned action. Use \`context_snapshot\` with its exact message, task, agreement or artifact reference. Readers, delivery recipients and the agents a request wakes are separate. An fyi creates no obligation; a message linked to a task (relationships.taskIds or a task mandate) is that task's input and advances it. Use \`message_replies\` for authorized causal replies; history does not come from inbox receipts.
24
24
  - For factual answers, read relevant source artifacts before concluding information is missing. The snapshot's artifact list is a bounded inventory, not document contents; use \`context_read\` on the room's artifacts and follow pagination, or search artifacts when that tool is available. An empty direct \`grant_list\` is not evidence that room documents are unavailable. Report dated information with its date and distinguish it from a fresh confirmation. Check shared sources before repeating another agent's unsupported "no data" conclusion.
25
25
  - Work is a task under an agreement (the ticket). Post progress with \`task_update_plan_step\`. Your own tools run only under a task you hold: name it as \`taskId\` on your first work call in each wake, from the task in your event or one you opened with \`task_create\`; without one, talk, agree, or open the task first.
26
26
  - Deliver finished work where the parties agreed it goes: in chat, as a task result, or as an artifact. When the work rides a task, close it with \`task_set_result\` (state completed + result object) too: an agent picking the work up from its own inbox reads that result and not the conversation. Record a heavy deliverable as a task-bound result artifact rather than pasting it into a message. When your counterparty is the HUMAN who set the goal, send them the deliverable in chat as well so they can read it where they asked.
27
27
  - Closing a task closes the TASK, and only the task. It stores your result where the next agent reads it, queues a wake for whoever the platform addresses, and on an agreement that bills per completed task it meters that one execution. It does not end the hire — a standing agreement stays active for the next task — it does not prove anyone has read you, and it does not prove you were paid. The reply tells you which of those actually happened: report that and nothing beyond it. A completion whose reply you never saw is recovered by READING the task back, never by completing it a second time; your retry carries the same write key, so a redelivered completion no-ops instead of doubling the result, the wake and the charge.
28
28
  - Enumerate open work with \`task_list\` (use assignedToMe for your own active tasks).
29
29
  - Chat is where you talk to whoever you are working with, and where a human reads what you delivered — sending it to them there is delivery, not duplication. It is not where another AGENT collects a deliverable: that one reads the task result, so a chat message never stands in for closing the task. Deliver into the working conversation the hire already has; do not repeat it into every room you can reach.
30
- - For replies and follow-ups, preserve the exact request reference and explicitly select readers and delivery recipients. Use the evaluated reply action. Missing access is a reason to request scoped permission; a causal reference never grants access or moves the reply into another work agreement. A saved address is optional.
30
+ - A reply from a wake reaches the readers of the message that woke you: leave audience and deliveries empty to answer all of them, or name a subset of those readers. You can never add a reader this way. Use the evaluated reply action. Missing access is a reason to request scoped permission; a causal reference never grants access or moves the reply into another work agreement. A saved address is optional.
31
31
  - When a store listing of yours is claimed (\`resource_changed\` with reason \`proposal_approved\`), do nothing yet: a claim opens no room, so do not open a conversation or greet. The buyer writes first in the agreement's conversation or assigns a task; serve the agreement terms when that arrives, through tasks for a task-only agreement.
32
32
  - When a task you hold carries a deadline or a reminder rule, they are part of the job, not decoration. Never remind the same person sooner than the stated interval or more times than the budget; use \`wake_at\` to come back rather than waiting in place, and re-arm it each time you wake. When the budget is spent, stop asking and say what you have. At the deadline, post what you got and where you are stuck to the task’s authorized recipients, close the task, and stop — whether or not you got the answer. Nothing stops you from breaking this, which is exactly why it is on you: over-reminding is a breach of the task, not diligence, and every reminder costs a wake.
33
33
  - Hand off by completing your task — the platform notifies the next agent.
@@ -35,7 +35,7 @@ Your prose and final summary are private host notes, not messages to the people
35
35
  You are headless — there is no human to prompt during a wake:
36
36
  - For proposals and connection requests, read the agreement’s approvalAction. Use existing covering authority when available; otherwise ask the accountable party to decide. Slot ownership alone is not authority. Do not add a confirmation when an existing mandate covers the decision.
37
37
  - When you ask somebody and stop, SAY SO ON THE TASK: \`task_update_plan_step\` with \`waitingOn\` ({ kind, id }), with the step you are ticking or on its own when the ask is all that happened. Until you do, your person sees a task that is running, and a job waiting on them is indistinguishable from one that has stalled. It clears itself when you next post progress without it, so you never have to remember to take it back.
38
- - When work needs a business detail, decision or missing access, ask the accountable person through the evaluated reply or permission-request action. Use \`message_send\` with explicit audience and deliveries; request answers from named responsible recipients, or answer the exact requested action. Keep any selected work mandate explicit. Say what you need, record the dependency on the task where applicable, and stop. A masked persona is not an address; use returned endpoint references.
38
+ - When work needs a business detail, decision or missing access, ask the accountable person through the evaluated reply or permission-request action. Use \`message_send\` (empty audience and deliveries answer the message that woke you), and intent request when an agent on the other side must act on it. Keep any selected work mandate explicit. Say what you need, record the dependency on the task where applicable, and stop. A masked persona is not an address; use returned endpoint references.
39
39
  - If contact or sharing is refused, ask the person you work for to authorize the contact and exact information needed. You inherit neither their contacts nor their private records. An introduction, hire, message grant and work assignment have separate effects; never create a room or a hire merely to bypass a refusal.
40
40
 
41
41
  Security:
@@ -56,12 +56,12 @@ export const contextSnapshotTool = defineTool('context_snapshot', {
56
56
  },
57
57
  });
58
58
  }, { description: 'Read the current wake or an explicit message, artifact, task or agreement, including governing constraints, dependencies and permitted artifact inventory. Optional message history is bounded by maxMessages. Artifact bodies are not included: follow the returned exact artifact or work readPlan with context_read. Snapshot and history reads preserve selected-work authority; an unrelated session or conversation grants no access.' });
59
- export const messageSendTool = defineTool('message_send', { command: { type: 'object', required: true, description: 'Canonical MessageCommand: operationId, content, audience, deliveries, effect and optional mandate, relationships and exact sources.' } }, async (args, ctx) => {
59
+ export const messageSendTool = defineTool('message_send', { command: { type: 'object', required: true, description: 'Canonical MessageCommand: operationId, content, audience, deliveries, intent (fyi or request) and optional mandate, relationships and exact sources.' } }, async (args, ctx) => {
60
60
  const c = ctx;
61
61
  if (!c.eff || !c.sessionId)
62
62
  throw new Error('message_send requires the current host context');
63
63
  return c.eff({ kind: 'send-message', sessionId: c.sessionId, command: parseMessageCommand(args.command) });
64
- }, { description: 'Send one canonical message. Readers, deliveries and answer effects are explicit. A reply link alone does not complete an answer request. Use the exact answer action to answer; task results remain task operations. No room required.' });
64
+ }, { description: 'Send one canonical message. Readers, deliveries and intent are explicit. intent request wakes the agents it reaches; intent fyi is filed and never wakes anyone. A reply is a message with relationships.replyToMessageId; nothing records whether a request was answered; task results remain task operations. No room required.' });
65
65
  // Inbox read/ack are deliberately NOT here: the host owns the pull/ack cycle
66
66
  // (its per-agent inbox long-poll loop). A brain-side ack would race the host's,
67
67
  // and a per-turn inbox poll fed the tool-operation echo loop.
package/dist/index.d.ts CHANGED
@@ -91,4 +91,4 @@ export { runAgents } from './launcher/runAgents.js';
91
91
  export type { RunnerOptions, SingleAgentRun, FleetRun } from './launcher/runAgents.js';
92
92
  export { createHealthServer, inboxHealth } from './launcher/createHealthServer.js';
93
93
  export type { AgentLiveness, HealthRequest, HealthRequestHandler } from './launcher/createHealthServer.js';
94
- export { responseCommand } from './runtime/messageCommand.js';
94
+ export { responseCommand, type ResponseCommandOptions } from './runtime/messageCommand.js';
@@ -1,4 +1,5 @@
1
1
  import type { AgreementParties } from '@ziggs-ai/api-client';
2
+ import type { MessageIntent } from '@ziggs-ai/contracts';
2
3
  export interface NormalizedEvent {
3
4
  addressId: string | null;
4
5
  event: {
@@ -21,6 +22,8 @@ export interface NormalizedEvent {
21
22
  type: 'task_result' | 'message' | 'agreement_lifecycle' | 'notification';
22
23
  /** Wire `entryType` when present (kept so brains can tell notice vs speech). */
23
24
  entryType?: string;
25
+ /** The message's own flag. Only a request wakes an agent; an fyi never reaches a wake. */
26
+ intent?: MessageIntent;
24
27
  operation?: string;
25
28
  agreementId?: string;
26
29
  taskId?: string;
@@ -62,6 +65,7 @@ interface WireMetadata {
62
65
  /** Inbox rewrite: assigned mail is this agent's even when the chat row names a human. */
63
66
  receiverId?: string;
64
67
  assigneeId?: string;
68
+ intent?: MessageIntent;
65
69
  task?: WireTask;
66
70
  service?: {
67
71
  workAgreementId?: string;
@@ -117,6 +117,7 @@ export function normalizeIncomingEvent({ text, metadata = {} }) {
117
117
  messageId: typeof metadata.messageId === 'string' && metadata.messageId ? metadata.messageId : undefined,
118
118
  timestamp: Date.now(),
119
119
  ...(entryType ? { entryType } : {}),
120
+ ...(metadata.intent === 'fyi' || metadata.intent === 'request' ? { intent: metadata.intent } : {}),
120
121
  ...(metadata.taskId ? { taskId: metadata.taskId } : {}),
121
122
  ...(wakeAgreementId ? { agreementId: wakeAgreementId } : {}),
122
123
  ...(formedBy ? { formedBy } : {}),
@@ -39,16 +39,13 @@ function proposalIsMine(proposal, ownAgentId) {
39
39
  return (proposal.pendingApprovalPartyIds?.includes(ownAgentId) === true ||
40
40
  proposal.proposedTo === ownAgentId);
41
41
  }
42
- /** Read exact assigned records. Historical lookup is optional context, never handoff. */
42
+ /** Read the exact request this agent was assigned and hand it to the host.
43
+ * Historical lookup is optional context, never handoff. A request's wake is
44
+ * its receipt: one receipt, one wake. */
43
45
  async function deliverAssignedMessage(deps, ref, reader, attempt, handledIds) {
44
- // A pending answer comes from its message owner, not from a delivery, so it
45
- // has no receipt to settle. Its eventId still names that exact slot, which
46
- // is enough to avoid a second wake for it.
47
- const receiptId = ref.receiptId ? deliveryHandlingId(ref) : undefined;
48
- const key = receiptId ?? ref.eventId;
49
- if (deps.seen.has(key)) {
50
- if (receiptId)
51
- handledIds.add(receiptId);
46
+ const receiptId = deliveryHandlingId(ref);
47
+ if (deps.seen.has(receiptId)) {
48
+ handledIds.add(receiptId);
52
49
  return false;
53
50
  }
54
51
  const handled = await attempt(`message ${ref.resourceId}`, () => (async () => {
@@ -59,9 +56,9 @@ async function deliverAssignedMessage(deps, ref, reader, attempt, handledIds) {
59
56
  const row = await reader.get(ref.resourceId);
60
57
  const metadata = { messageId: row.messageId, ...(row.mandate ?? {}),
61
58
  sender: { id: row.sender.ref, type: row.sender.kind }, receiver: { id: deps.ownAgentId, type: 'agent' },
62
- entryType: 'message', timestamp: row.timestamp, roomless: true };
59
+ entryType: 'message', intent: row.intent, timestamp: row.timestamp, roomless: true };
63
60
  await deps.onMessage(row.content.text, {
64
- ...metadata, assigneeId: deps.ownAgentId, ...(receiptId ? { receiptId } : {}),
61
+ ...metadata, assigneeId: deps.ownAgentId, receiptId,
65
62
  executionContext: execution,
66
63
  ...(ref.agreementId ? { agreementId: ref.agreementId } : {}),
67
64
  ...(ref.taskId ? { taskId: ref.taskId } : {}),
@@ -69,9 +66,8 @@ async function deliverAssignedMessage(deps, ref, reader, attempt, handledIds) {
69
66
  });
70
67
  })());
71
68
  if (handled) {
72
- deps.seen.mark(key);
73
- if (receiptId)
74
- handledIds.add(receiptId);
69
+ deps.seen.mark(receiptId);
70
+ handledIds.add(receiptId);
75
71
  }
76
72
  return handled;
77
73
  }
@@ -176,7 +172,8 @@ export async function pollInboxOnce(deps, waitSeconds = 0, opts = {}) {
176
172
  }
177
173
  }
178
174
  // A receipt with no owner action is transport-only: acknowledge observation
179
- // without creating model work from an FYI.
175
+ // without creating model work. An FYI never carries this agent's stamp, so
176
+ // it is not even here: the watermark moves past it and nothing wakes.
180
177
  const handledSoFar = new Set(envelope.deliveries.filter(d => mine(d) && d.kind !== 'request' && (!d.action || d.actionState === 'settled') && !d.outOfReach && !d.executionBlocked).map(deliveryHandlingId));
181
178
  const acknowledged = new Set();
182
179
  // A handled id the server would not settle (it lost access mid-wake) stays
@@ -209,9 +206,12 @@ export async function pollInboxOnce(deps, waitSeconds = 0, opts = {}) {
209
206
  warn(label, `mid-pass ack did not land: ${err?.message ?? err}`);
210
207
  }
211
208
  };
212
- // Every assigned message is fetched by resource identity. Navigation is optional.
209
+ // A request is the one message that wakes: the server stamps it with this
210
+ // agent and a message action. A message that is a task's input carries the
211
+ // task action instead and reaches the task executor below. Every assigned
212
+ // request is fetched by resource identity; navigation is optional.
213
213
  const assigned = envelope.deliveries
214
- .filter(d => d.kind === 'message' && !!d.action && d.action.kind !== 'task' && d.actionState !== 'settled' && d.actionState !== 'waiting' && mine(d) && !d.outOfReach && !d.executionBlocked)
214
+ .filter(d => d.kind === 'message' && d.action?.kind === 'message' && d.actionState !== 'settled' && d.actionState !== 'waiting' && mine(d) && !d.outOfReach && !d.executionBlocked)
215
215
  .sort((a, b) => b.ts.localeCompare(a.ts));
216
216
  const records = new MessageRecordsClient(deps.creds.operatorKey, deps.creds.agentId, deps.baseUrl);
217
217
  for (const delivery of assigned) {
@@ -219,14 +219,6 @@ export async function pollInboxOnce(deps, waitSeconds = 0, opts = {}) {
219
219
  messagesDelivered++;
220
220
  await ackWhatIsFinished();
221
221
  }
222
- // Recover owner actions even after their transport receipt was acknowledged.
223
- const deliveredAnswerKeys = new Set(assigned.map(delivery => JSON.stringify(delivery.action)));
224
- for (const answer of envelope.answersAwaitingMe ?? []) {
225
- if (!answer.action || answer.executionBlocked || answer.outOfReach || deliveredAnswerKeys.has(JSON.stringify(answer.action)))
226
- continue;
227
- if (await deliverAssignedMessage(deps, answer, records, attempt, new Set()))
228
- messagesDelivered++;
229
- }
230
222
  // Everything that is not chat text is handed over as a resource event, from
231
223
  // the delivery itself — the reference already carries the ids the host needs,
232
224
  // so nothing has to be re-derived to name what changed.
@@ -1,9 +1,22 @@
1
- import type { MessageCommand } from '@ziggs-ai/contracts';
1
+ import type { MessageCommand, MessageIntent } from '@ziggs-ai/contracts';
2
2
  import type { EffectHandler } from '../types.js';
3
- /** Compose an FSM response from a fresh, exact trigger. A session locates the
4
- * wake context; it is never a room, principal or authority identifier. */
5
- export declare function responseCommand(eff: EffectHandler, sessionId: string, text: string, options?: {
3
+ export interface ResponseCommandOptions {
4
+ /** Stable write key for a retry; a fresh UUID when absent. */
6
5
  operationId?: string;
6
+ /** A request wakes the agents it reaches; an fyi is filed. Default fyi. */
7
+ intent?: MessageIntent;
8
+ /**
9
+ * Who to send to when there is no wake to reply to, or when the message
10
+ * goes to someone other than the trigger's sender. Readers and recipients
11
+ * are both this one principal.
12
+ */
7
13
  recipientId?: string;
8
- answer?: boolean;
9
- }): Promise<MessageCommand>;
14
+ }
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.
17
+ *
18
+ * A reply from a wake names nobody: the backend links it to the trigger and
19
+ * fills readers and recipients from the trigger's own readers and sender. An
20
+ * explicit recipient is the form for a send outside a wake, or to a party the
21
+ * trigger did not come from. */
22
+ export declare function responseCommand(eff: EffectHandler, sessionId: string, text: string, options?: ResponseCommandOptions): Promise<MessageCommand>;
@@ -1,23 +1,26 @@
1
1
  import { randomUUID } from 'node:crypto';
2
- /** Compose an FSM response from a fresh, exact trigger. A session locates the
3
- * wake context; it is never a room, principal or authority identifier. */
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.
4
+ *
5
+ * A reply from a wake names nobody: the backend links it to the trigger and
6
+ * fills readers and recipients from the trigger's own readers and sender. An
7
+ * explicit recipient is the form for a send outside a wake, or to a party the
8
+ * trigger did not come from. */
4
9
  export async function responseCommand(eff, sessionId, text, options = {}) {
5
10
  const snapshot = await eff({ kind: 'read-context', sessionId, opts: { includeHistory: false } });
6
11
  if (snapshot.unavailable)
7
12
  throw new Error('Required response context is unavailable');
8
13
  const parent = snapshot.messageRecord;
9
- const recipient = options.recipientId ?? (parent && !parent.sender.isSelf ? parent.sender.ref : undefined);
10
- if (!recipient)
14
+ const trigger = parent && !parent.sender.isSelf ? parent : undefined;
15
+ const explicit = options.recipientId && options.recipientId !== trigger?.sender.ref ? options.recipientId : undefined;
16
+ if (!trigger && !explicit)
11
17
  throw new Error('Name an explicit recipient or read an exact message before replying');
12
- const slots = parent?.requestedAnswers.filter(r => r.responsible.isSelf) ?? [];
13
- if (options.answer && slots.length > 1)
14
- throw new Error('Select the exact requested-answer slot with message_send');
15
- const answer = options.answer && slots.length === 1 && recipient === parent?.sender.ref ? slots[0].action : undefined;
18
+ const principalIds = explicit ? [explicit] : [];
16
19
  return {
17
20
  operationId: options.operationId ?? randomUUID(), content: { text },
18
- audience: { kind: 'explicit', principalIds: [recipient] }, deliveries: { kind: 'explicit', principalIds: [recipient] },
19
- effect: answer ? { kind: 'answer', action: answer, artifacts: [] } : { kind: 'none' },
21
+ audience: { kind: 'explicit', principalIds }, deliveries: { kind: 'explicit', principalIds },
22
+ intent: options.intent ?? 'fyi',
20
23
  ...(snapshot.messageMandate ? { mandate: snapshot.messageMandate } : {}),
21
- ...(parent ? { relationships: { replyToMessageId: parent.messageId } } : {}),
24
+ ...(explicit && trigger ? { relationships: { replyToMessageId: trigger.messageId } } : {}),
22
25
  };
23
26
  }
@@ -374,7 +374,7 @@ export async function runTurn(input) {
374
374
  sessionId,
375
375
  receiverId: decision.receiverId,
376
376
  }) ?? chunkMessageId;
377
- await eff({ kind: 'send-message', sessionId, command: await responseCommand(eff, sessionId, safeText, { recipientId: decision.receiverId, operationId: persistMessageId, answer: true }) });
377
+ await eff({ kind: 'send-message', sessionId, command: await responseCommand(eff, sessionId, safeText, { recipientId: decision.receiverId, operationId: persistMessageId }) });
378
378
  allEmittedEvents.push({ type: 'message_sent', receiverId: decision.receiverId, addressId: sessionId, message: safeText, senderId: 'system' });
379
379
  lastAction = chosenAction;
380
380
  lastActionDef = actionDef;
@@ -689,7 +689,7 @@ async function executeSendMessage(decision, eff, sessionId) {
689
689
  const receiverId = decision.receiverId || undefined;
690
690
  await eff({
691
691
  kind: 'send-message', sessionId,
692
- command: await responseCommand(eff, sessionId, safeMessage, { recipientId: receiverId, answer: true }),
692
+ command: await responseCommand(eff, sessionId, safeMessage, { recipientId: receiverId }),
693
693
  });
694
694
  const events = [{ type: 'message_sent', ...(receiverId ? { receiverId } : {}), addressId: targetSessionId, message: safeMessage, senderId: 'system' }];
695
695
  if (targetSessionId !== sessionId)
@@ -724,7 +724,7 @@ async function executeSendMessages(decision, eff, sessionId) {
724
724
  try {
725
725
  await eff({
726
726
  kind: 'send-message',
727
- sessionId, command: await responseCommand(eff, sessionId, safeMessage, { recipientId: msg.receiverId, answer: true }),
727
+ sessionId, command: await responseCommand(eff, sessionId, safeMessage, { recipientId: msg.receiverId }),
728
728
  });
729
729
  }
730
730
  catch (err) {
@@ -36,10 +36,11 @@ export interface WakeOutcome {
36
36
  /**
37
37
  * Was this wake somebody asking this agent something?
38
38
  *
39
- * A counterparty `message` frame is the one shape that earns a reply. Task
40
- * results, agreement lifecycle and notifications are news, and the ticket is
41
- * explicit that they still finish without sending. The agent's own message
42
- * never counts: a self-addressed frame is an echo, not a question.
39
+ * A counterparty message flagged as a request is the one shape that earns a
40
+ * reply: it is the only message that wakes an agent at all. Task results,
41
+ * agreement lifecycle and notifications are news, and they finish without
42
+ * sending. The agent's own message never counts: a self-addressed frame is an
43
+ * echo, not a question.
43
44
  */
44
45
  export declare function wakeWasAsked(event: unknown, ownAgentId?: string): boolean;
45
46
  export declare function classifyWakeOutcome(input: {
@@ -12,17 +12,18 @@ const record = (value) => value && typeof value === 'object' && !Array.isArray(v
12
12
  /**
13
13
  * Was this wake somebody asking this agent something?
14
14
  *
15
- * A counterparty `message` frame is the one shape that earns a reply. Task
16
- * results, agreement lifecycle and notifications are news, and the ticket is
17
- * explicit that they still finish without sending. The agent's own message
18
- * never counts: a self-addressed frame is an echo, not a question.
15
+ * A counterparty message flagged as a request is the one shape that earns a
16
+ * reply: it is the only message that wakes an agent at all. Task results,
17
+ * agreement lifecycle and notifications are news, and they finish without
18
+ * sending. The agent's own message never counts: a self-addressed frame is an
19
+ * echo, not a question.
19
20
  */
20
21
  export function wakeWasAsked(event, ownAgentId) {
21
22
  const frame = record(event);
22
23
  if (frame.type === 'batch' && Array.isArray(frame.events)) {
23
24
  return frame.events.some((item) => wakeWasAsked(item, ownAgentId));
24
25
  }
25
- if (frame.type !== 'message')
26
+ if (frame.type !== 'message' || frame.intent !== 'request')
26
27
  return false;
27
28
  const senderId = typeof frame.senderId === 'string' ? frame.senderId : '';
28
29
  if (!senderId)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ziggs-ai/agent-sdk",
3
- "version": "0.43.9",
3
+ "version": "0.44.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,8 +30,8 @@
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.39.4",
34
- "@ziggs-ai/contracts": "0.45.0",
33
+ "@ziggs-ai/api-client": "0.40.0",
34
+ "@ziggs-ai/contracts": "0.46.0",
35
35
  "ajv": "^8.17.1",
36
36
  "dotenv": "^17.2.3",
37
37
  "openai": "^4.0.0",