@ziggs-ai/agent-sdk 0.43.6 → 0.43.8

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,14 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.43.8
6
+
7
+ - Uses api-client 0.39.4: agents can ask for a send grant (`access_request` with `scopeKind: "contact"`).
8
+
9
+ ## 0.43.7
10
+
11
+ - Message wakes retain the backend's authorized causal predecessors by default, so explicitly linked follow-ups can refer to earlier messages without a quoted reply in the interface. Explicit minimal reads still use only the trigger, and history never changes the selected task or agreement.
12
+
5
13
  ## 0.43.6
6
14
 
7
15
  - Completing a delegated task now returns its result to the work that delegated it. A delegated result only reaches the delegator as a returned output artifact, and an agent that closed its task with `task_set_result` returned nothing, so the delegator was never woken and never saw the result. Before completing a delegated task, the SDK records the result as the task's output artifact. After completing it, the SDK returns that artifact. If either step fails, the failure is logged and the completion still stands.
@@ -21,7 +21,7 @@ export const contextSnapshotTool = defineTool('context_snapshot', {
21
21
  taskId: { type: 'string', description: 'Read this explicit task.' },
22
22
  messageId: { type: 'string', description: 'Read this exact message without a saved address or work agreement.' },
23
23
  artifactId: { type: 'string', description: 'Read this exact artifact context.' },
24
- includeHistory: { type: 'boolean', description: 'Include optional work message history. Task/work context does not require it; the exact triggering message is read independently.' },
24
+ includeHistory: { type: 'boolean', description: 'Message wakes include bounded conversation context by default. Set false to read only the trigger. Set true to include optional message history for a task or agreement without a message trigger.' },
25
25
  maxMessages: { type: 'number', description: `Message history cap (default ${DEFAULT_SNAPSHOT_MAX_MESSAGES}). Pass a larger value when you need deeper history.` },
26
26
  }, async (args, ctx) => {
27
27
  const c = ctx;
@@ -44,7 +44,7 @@ export const contextSnapshotTool = defineTool('context_snapshot', {
44
44
  kind: 'read-context',
45
45
  sessionId,
46
46
  opts: {
47
- includeHistory: args.includeHistory === true,
47
+ ...(typeof args.includeHistory === 'boolean' ? { includeHistory: args.includeHistory } : {}),
48
48
  maxMessages: args.maxMessages != null ? Number(args.maxMessages) : DEFAULT_SNAPSHOT_MAX_MESSAGES,
49
49
  ...(messageId || artifactId ? {
50
50
  via: messageId ? `message:${messageId}` : `artifact:${artifactId}`,
@@ -30,7 +30,7 @@ async function buildSnapshot(deps, agentId, opts = {}) {
30
30
  // Select the work independently of its triggering message. A message is
31
31
  // the snapshot entry only when it is the selected resource itself.
32
32
  const snap = await deps.contextReadClient.snapshot({
33
- via, maxMessages: opts.limit,
33
+ via, maxMessages: opts.includeHistory === false && via.startsWith('message:') ? 1 : opts.limit,
34
34
  ...(agreementId ? { agreementId } : {}),
35
35
  ...(scope?.artifactId ? { artifactId: scope.artifactId } : {}),
36
36
  });
@@ -44,10 +44,31 @@ async function buildSnapshot(deps, agentId, opts = {}) {
44
44
  const present = (m) => ({ messageId: m.messageId, text: m.content.text, entryType: 'message', timestamp: Date.parse(m.timestamp), sender: { id: m.sender.isSelf ? agentId : m.sender.ref, type: m.sender.kind }, receiver: { id: m.recipients[0]?.ref } });
45
45
  const required = trigger ? [present(trigger)] : [];
46
46
  const context = { ...snap, messageRecord: trigger, messageMandate: agreementId ? { agreementId, ...(opts.workScope?.taskId ? { taskId: opts.workScope.taskId } : {}) } : trigger?.mandate ?? undefined };
47
+ if (trigger && opts.includeHistory !== false) {
48
+ try {
49
+ // An ordinary follow-up needs the preceding conversation, even when it
50
+ // does not explicitly quote a message. The server matches the exact
51
+ // stored audience and mandate and authorizes every history record.
52
+ // Keep selected work separate: context never selects execution authority.
53
+ const conversation = via === `message:${trigger.messageId}`
54
+ ? snap
55
+ : await deps.contextReadClient.snapshot({ via: `message:${trigger.messageId}`, maxMessages: opts.limit ?? 12 });
56
+ assertRequiredContext(conversation);
57
+ const history = new Map(conversation.history.map(m => [m.messageId, present(m)]));
58
+ history.set(trigger.messageId, present(trigger));
59
+ return { ...context, history: [...history.values()].sort((a, b) => Number(a.timestamp) - Number(b.timestamp)) };
60
+ }
61
+ catch (error) {
62
+ const refusal = error;
63
+ if (refusal.status === 401 || refusal.code?.startsWith('EXECUTION_'))
64
+ throw error;
65
+ return { ...context, history: required, historyUnavailable: true };
66
+ }
67
+ }
47
68
  if (trigger || agreementId) {
48
69
  if (opts.includeHistory === true) {
49
70
  try {
50
- const page = agreementId ? await messages.list({ agreementId, taskId: opts.workScope?.taskId, limit: Math.min(opts.limit ?? 12, 30) }) : await messages.replies(trigger.messageId, { limit: Math.min(opts.limit ?? 12, 30) });
71
+ const page = await messages.list({ agreementId, taskId: opts.workScope?.taskId, limit: Math.min(opts.limit ?? 12, 30) });
51
72
  const history = page.messages.map(present);
52
73
  if (trigger && !page.messages.some(m => m.messageId === trigger.messageId))
53
74
  history.unshift(present(trigger));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ziggs-ai/agent-sdk",
3
- "version": "0.43.6",
3
+ "version": "0.43.8",
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.2",
34
- "@ziggs-ai/contracts": "0.43.0",
33
+ "@ziggs-ai/api-client": "0.39.4",
34
+ "@ziggs-ai/contracts": "0.45.0",
35
35
  "ajv": "^8.17.1",
36
36
  "dotenv": "^17.2.3",
37
37
  "openai": "^4.0.0",