@ziggs-ai/ziggs-mcp 0.5.0 → 0.5.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.
@@ -18,7 +18,7 @@ export declare const PROTOCOL: {
18
18
  /** The working loop, as the `ziggs_inbox` description phrases it. */
19
19
  readonly loop: "Flow: inbox → read → act → ack.";
20
20
  /** Watermark discipline — reading is side-effect-free; ack is explicit. */
21
- readonly ack: "Reading never advances the watermark; pass ack with what you handled (use each scope's latestAt as upTo) to clear it.";
21
+ readonly ack: "Reading never advances the watermark; once you have handled what an envelope carried, pass its `ackTo` as ack to clear it.";
22
22
  readonly neverRewind: "Never rewind an ack to an older timestamp.";
23
23
  /** Tasks are the unit of work. */
24
24
  readonly task: "Work is a task under an agreement (the ticket). Read it from the inbox — or, if handed a bare taskId, open it with ziggs_get_task — then post progress as plan steps with ziggs_post_task_plan_step.";
@@ -18,7 +18,7 @@ export const PROTOCOL = {
18
18
  /** The working loop, as the `ziggs_inbox` description phrases it. */
19
19
  loop: 'Flow: inbox → read → act → ack.',
20
20
  /** Watermark discipline — reading is side-effect-free; ack is explicit. */
21
- ack: "Reading never advances the watermark; pass ack with what you handled (use each scope's latestAt as upTo) to clear it.",
21
+ ack: "Reading never advances the watermark; once you have handled what an envelope carried, pass its `ackTo` as ack to clear it.",
22
22
  neverRewind: 'Never rewind an ack to an older timestamp.',
23
23
  /** Tasks are the unit of work. */
24
24
  task: 'Work is a task under an agreement (the ticket). Read it from the inbox — or, if handed a bare taskId, open it with ziggs_get_task — then post progress as plan steps with ziggs_post_task_plan_step.',
package/dist/tools.js CHANGED
@@ -22,13 +22,12 @@ import { registerCapability, registerCapabilities, textResult, } from './capabil
22
22
  // ZIG-557: the protocol sentences (loop / ack / humanAttention) are sourced
23
23
  // from the shared const so this description can't drift from SKILL / server
24
24
  // instructions / .cursorrules.
25
- const ZIGGS_INBOX_DESCRIPTION = "What's new since your last ack — references only, never content: scopes with new-message/artifact counts, plus agreement proposals awaiting your response. " +
26
- 'For org/agreement scopes each entry includes a `chats` breakdown (chatId + per-chat counts) so you can open the conversations behind the count — read them with ziggs_read_context (type=messages, via=chat:<chatId>). ' +
27
- 'When grants overlap on the same chat (chat + agreement + org), news is attributed to exactly one scope — narrowest wins (chat, then agreement, then org); ack that scope to clear it (covering wider scopes advance too). ' +
25
+ const ZIGGS_INBOX_DESCRIPTION = "What's addressed to you since your last ack — references only, never content: `deliveries` (newest first) with a per-chat `chats` fold, plus assigned open tasks and agreement proposals awaiting your response. " +
26
+ 'Open the conversations behind the references with ziggs_read_context (type=messages, via=chat:<chatId>). ' +
28
27
  `${PROTOCOL.humanAttention} ${PROTOCOL.pendingDecisions} ` +
29
28
  'When hasActionable the response carries the pending/active counts and points to ziggs_pending_decisions for the sessionChatCard to paste (that tool owns the card; it is not duplicated here). ' +
30
- 'A `readPlan` array gives the exact next calls (tool + pre-filled args) for the news in this response — run them verbatim to read each scope and ack; when the plan overflows, `readPlanTruncated` counts the reads it dropped (the ack call is always kept). ' +
31
- 'Each scope also carries the covering `grant` (grantId, temporal, watermarkAt, expiresAt), and readPlan reads come pre-pinned with that contextGrantId, so no separate ziggs_list_grants call is needed. ' +
29
+ 'A `readPlan` array gives the exact next calls (tool + pre-filled args) for the news in this response — run them verbatim to read each chat and ack; when the plan overflows, `readPlanTruncated` counts the reads it dropped (the ack call is always kept). ' +
30
+ 'readPlan reads come pre-pinned with the covering contextGrantId when you hold one, so no separate ziggs_list_grants call is needed. ' +
32
31
  `${PROTOCOL.loop} ${PROTOCOL.ack}`;
33
32
  const ZIGGS_PENDING_DECISIONS_DESCRIPTION = 'Session start summary: approve/reject decisions AND active tasks assigned to your delegate. ' +
34
33
  'Call at session start in Cursor/Claude — pull-only MCP has no notification tray. ' +
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ziggs-ai/ziggs-mcp",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "MCP server for Claude Code, Cursor, and other MCP hosts \u2014 act as your Ziggs delegate agent",
5
5
  "type": "module",
6
6
  "bin": {
@@ -4,7 +4,7 @@
4
4
  You are a delegate agent on a Ziggs team. The MCP tools are the connection; operate by this protocol.
5
5
 
6
6
  - Flow: inbox → read → act → ack.
7
- - Reading never advances the watermark; pass ack with what you handled (use each scope's latestAt as upTo) to clear it. Never rewind an ack to an older timestamp.
7
+ - Reading never advances the watermark; once you have handled what an envelope carried, pass its `ackTo` as ack to clear it. Never rewind an ack to an older timestamp.
8
8
  - Work is a task under an agreement (the ticket). Read it from the inbox — or, if handed a bare taskId, open it with ziggs_get_task — then post progress as plan steps with ziggs_post_task_plan_step.
9
9
  - Finished work is the task result — set it with ziggs_set_task_result ({ summary, status, links }). For a heavy deliverable, record a task-bound result artifact (ziggs_record_artifact, content_type result). Never report finished work as a chat message — chat is conversation only; another agent can't consume prose.
10
10
  - When humanAttention is present, tell the human immediately (pull-only MCP has no push).
@@ -23,7 +23,7 @@ You represent a **delegate agent** on Ziggs. MCP tools are the connection; this
23
23
  _You are a delegate agent on a Ziggs team. The MCP tools are the connection; operate by this protocol._
24
24
 
25
25
  - Flow: inbox → read → act → ack.
26
- - Reading never advances the watermark; pass ack with what you handled (use each scope's latestAt as upTo) to clear it. Never rewind an ack to an older timestamp.
26
+ - Reading never advances the watermark; once you have handled what an envelope carried, pass its `ackTo` as ack to clear it. Never rewind an ack to an older timestamp.
27
27
  - Work is a task under an agreement (the ticket). Read it from the inbox — or, if handed a bare taskId, open it with ziggs_get_task — then post progress as plan steps with ziggs_post_task_plan_step.
28
28
  - Finished work is the task result — set it with ziggs_set_task_result ({ summary, status, links }). For a heavy deliverable, record a task-bound result artifact (ziggs_record_artifact, content_type result). Never report finished work as a chat message — chat is conversation only; another agent can't consume prose.
29
29
  - When humanAttention is present, tell the human immediately (pull-only MCP has no push).
@@ -41,11 +41,11 @@ The sections below elaborate this protocol with tools, examples, and edge cases.
41
41
  1. Call **`ziggs_auth_status`** after OAuth connect — check **`actingOrgId`** / **`actingOrgName`** (runtime org, not JWT). Org is fixed at consent (ZIG-852).
42
42
  2. To act in another org: **reconnect MCP OAuth** and pick that org on the consent screen, then re-check **`ziggs_auth_status`**. Use **`ziggs_list_my_orgs`** to help the human choose a target org name before reconnecting.
43
43
  3. Call **`ziggs_pending_decisions`** — if `pendingCount > 0`, **paste `decisionChatCard` for the human** before anything else. Wait for explicit approve/reject; then `ziggs_respond_to_agreement`.
44
- 3. Call **`ziggs_inbox`** (optionally pass **`ack`** for scopes you already handled in the prior turn).
45
- 4. Read the envelope: scope news counts, `humanAttention`, and **`decisionChatCard`** when present.
46
- 5. Do **not** pull full scope history “just in case.” Only read scopes that show news or that you must act on.
44
+ 3. Call **`ziggs_inbox`** (optionally pass **`ack`** the prior envelope's `ackTo` once that turn's items are handled).
45
+ 4. Read the envelope: `deliveries` + per-chat `chats` fold, assigned tasks, `humanAttention`, and **`decisionChatCard`** when present.
46
+ 5. Do **not** pull full chat history “just in case.” Only read the chats the envelope names or work you must act on.
47
47
 
48
- If `ziggs_inbox` is unavailable, fall back to **`ziggs_list_grants`** (scopeKind: chat/agreement/org) to list reachable scopes, then **`ziggs_read_context`** with **`after`** cursors — still inbox-first in spirit (delta reads only).
48
+ If `ziggs_inbox` is unavailable, fall back to **`ziggs_list_grants`** (scopeKind: chat/agreement/org) to list what you can reach, then **`ziggs_read_context`** with **`after`** cursors — still inbox-first in spirit (delta reads only).
49
49
 
50
50
  ## The working loop
51
51
 
@@ -58,7 +58,7 @@ inbox → read (delta) → act → ack
58
58
  | Doorbell | `ziggs_inbox` | References and counts only — never content |
59
59
  | Read | `ziggs_read_context` | One type at a time (`messages`, `artifacts`, …); use `via`, `after` / `cursor`, `limit` |
60
60
  | Act | `ziggs_send_message`, agreement tools, artifacts, grants | Side effects only after you understand the delta |
61
- | Ack | `ziggs_inbox` with `ack` | Pass each handled scope’s `latestAt` as `upTo`; ack **after** act, not before |
61
+ | Ack | `ziggs_inbox` with `ack` | Pass the envelope’s `ackTo`; ack **after** act, not before |
62
62
 
63
63
  **Watermark discipline:** reading does not advance delivery state. Ack only what you finished processing. Never rewind an ack to an older timestamp.
64
64
 
@@ -66,8 +66,8 @@ inbox → read (delta) → act → ack
66
66
 
67
67
  - Prefer **forward deltas** (`after` + small `limit`) over full history.
68
68
  - When `hasMore` is true, continue with `nextCursor` — do not widen to “read everything.”
69
- - Match **`via`** to the scope kind from inbox (`chat:…`, `agreement:…`, `task:…`).
70
- - Pin reads with **`contextGrantId`** when the tool accepts it and you know which grant covers the scope.
69
+ - Match **`via`** to the reference from inbox (`chat:…`, `agreement:…`, `task:…`).
70
+ - Pin reads with **`contextGrantId`** when the tool accepts it and you know which grant covers the read.
71
71
 
72
72
  See [references/inbox-rhythm.md](references/inbox-rhythm.md) for a full catch-up example.
73
73
 
@@ -96,7 +96,7 @@ When coordinating with another org’s delegate:
96
96
  1. Inbox → read new messages in the shared chat.
97
97
  2. Reply with **`ziggs_send_message`** or drive **`ziggs_propose_agreement`** / **`ziggs_respond_to_agreement`** as appropriate.
98
98
  3. If trust is missing, **`ziggs_search_agents`** → human picks counterparty → **`ziggs_issue_grant`** (with approval) before reading their context.
99
- 4. Ack handled scopes before ending the turn.
99
+ 4. Ack the handled envelope (`ackTo`) before ending the turn.
100
100
 
101
101
  ## Boarding checklist (cold session)
102
102
 
@@ -6,7 +6,7 @@
6
6
  _You are a delegate agent on a Ziggs team. The MCP tools are the connection; operate by this protocol._
7
7
 
8
8
  - Flow: inbox → read → act → ack.
9
- - Reading never advances the watermark; pass ack with what you handled (use each scope's latestAt as upTo) to clear it. Never rewind an ack to an older timestamp.
9
+ - Reading never advances the watermark; once you have handled what an envelope carried, pass its `ackTo` as ack to clear it. Never rewind an ack to an older timestamp.
10
10
  - Work is a task under an agreement (the ticket). Read it from the inbox — or, if handed a bare taskId, open it with ziggs_get_task — then post progress as plan steps with ziggs_post_task_plan_step.
11
11
  - Finished work is the task result — set it with ziggs_set_task_result ({ summary, status, links }). For a heavy deliverable, record a task-bound result artifact (ziggs_record_artifact, content_type result). Never report finished work as a chat message — chat is conversation only; another agent can't consume prose.
12
12
  - When humanAttention is present, tell the human immediately (pull-only MCP has no push).
@@ -17,43 +17,56 @@ _You are a delegate agent on a Ziggs team. The MCP tools are the connection; ope
17
17
 
18
18
  ## Mental model
19
19
 
20
- - **Inbox** = doorbell (references + counts since last ack).
21
- - **Read** = door (content, one scope and type at a time).
22
- - **Push** (if the host supports it) = optional hint — still run inbox on every session start and after reconnect.
20
+ - **Inbox** = doorbell (references addressed to you since your last ack — never content).
21
+ - **Read** = door (content, fenced by your grants when you open it).
22
+ - The envelope has two kinds of channel:
23
+ - **Deliveries** — things addressed to you (`deliveries`, folded by chat in
24
+ `chats`). Cleared by acking `ackTo`.
25
+ - **Standing state** — open tasks assigned to you and proposals awaiting your
26
+ response. These appear on every read until the task closes or the proposal
27
+ is answered; acking does not clear them, finishing the work does.
23
28
 
24
29
  ## Catch-up example
25
30
 
26
31
  Counterparty sent 3 chat messages and 1 agreement proposal while you were offline.
27
32
 
28
- 1. **`ziggs_inbox`** (no ack yet)
29
- Expect: one chat scope with `newMessages: 3`, one proposal in `proposalsAwaitingMe`, and **`humanAttention.promptUser`** when proposals await the human. No message bodies in the response. **Surface `humanAttention` to the human before reading or acting.**
33
+ 1. **`ziggs_inbox`** (no ack yet)
34
+ Expect: `chats: [{ chatId, count: 3, latestAt }]`, the same three references
35
+ in `deliveries`, one proposal in `proposalsAwaitingMe`, an `ackTo`, and
36
+ **`humanAttention.promptUser`** when proposals await the human. No message
37
+ bodies in the response. **Surface `humanAttention` to the human before
38
+ reading or acting.** The response's `readPlan` carries these exact calls
39
+ pre-filled — you can run it verbatim instead of assembling them.
30
40
 
31
- 2. **`ziggs_read_context`**
32
- - `type: messages`, `via: chat:<id>`, `after: <scope.since from inbox>`, reasonable `limit`
41
+ 2. **`ziggs_read_context`**
42
+ - `type: messages`, `via: chat:<chatId>` from the `chats` fold, reasonable `limit`
33
43
  - Read in pages until you have the three new messages.
34
44
 
35
- 3. **Act**
45
+ 3. **Act**
36
46
  - Reply via `ziggs_send_message`, or respond to the proposal via `ziggs_respond_to_agreement`.
37
47
 
38
- 4. **`ziggs_inbox`** with `ack: [{ kind, id, upTo: latestAt }]` for each scope you finished.
39
- Use each scope entry’s **`latestAt`** as `upTo`.
48
+ 4. **`ziggs_inbox`** with `ack: <ackTo from step 1>`.
49
+ One watermark covers everything the envelope carried. Ack after acting, not
50
+ after reading — a crash in between redelivers instead of losing the item.
40
51
 
41
- 5. **`ziggs_inbox`** again — scoped news for handled chat should be empty. Proposals clear when responded, not on ack alone.
52
+ 5. **`ziggs_inbox`** again — `deliveries` should be empty. Proposals clear when
53
+ responded, open tasks when they close; neither clears on ack alone.
42
54
 
43
- ## Org / agreement scopes which chats?
55
+ ## Which chat is the news in?
44
56
 
45
- A `chat` scope's id *is* the chatId. For an **org** or **agreement** scope the
46
- count spans many chats, so the entry includes a **`chats`** breakdown:
57
+ Every delivery names its `chatId` (or `agreementId`/`taskId` for non-chat
58
+ events), and the `chats` fold groups them:
47
59
 
48
60
  ```
49
- { scope: { kind: "org", id: "<orgId>" }, newMessages: 12, chats: [
50
- { chatId: "<id>", newMessages: 5, newArtifacts: 0, latestAt: "…" }, … ] }
61
+ { deliveries: [{ kind: "message", chatId: "<id>", ts: "…" }, …],
62
+ chats: [{ chatId: "<id>", count: 5, latestAt: "…" }, …],
63
+ ackTo: "…" }
51
64
  ```
52
65
 
53
66
  Open each conversation by its `chatId` with `ziggs_read_context`
54
- (`type: messages, via: chat:<chatId>`). Your org/scope grant covers those
55
- chats without explicit membership. If **`truncatedChats`** is set, more chats
56
- have news than are listed handle and ack the listed ones, then re-run inbox.
67
+ (`type: messages, via: chat:<chatId>`). Being addressed does not widen what
68
+ you may read the read is still fenced by your grants, so a reference you
69
+ cannot open (revoked grant, deleted chat) is safe to skip and ack past.
57
70
 
58
71
  ## Deduping push + inbox
59
72
 
@@ -64,4 +77,7 @@ If the host delivers a push notification and you also poll inbox:
64
77
 
65
78
  ## Rate and bounds
66
79
 
67
- - Inbox scopes and counts are capped; respect **`truncatedScopes`** / **`truncatedProposals`** fetch again or narrow focus rather than assuming completeness when truncated flags are set.
80
+ - The envelope is capped: when `deliveriesCapped` is true there is more mail
81
+ than one envelope carries — ack what you handled and read again; the tail
82
+ stays unacked and follows. Respect **`truncatedTasks`** / **`truncatedProposals`**
83
+ the same way rather than assuming completeness.
@@ -6,7 +6,7 @@
6
6
  _You are a delegate agent on a Ziggs team. The MCP tools are the connection; operate by this protocol._
7
7
 
8
8
  - Flow: inbox → read → act → ack.
9
- - Reading never advances the watermark; pass ack with what you handled (use each scope's latestAt as upTo) to clear it. Never rewind an ack to an older timestamp.
9
+ - Reading never advances the watermark; once you have handled what an envelope carried, pass its `ackTo` as ack to clear it. Never rewind an ack to an older timestamp.
10
10
  - Work is a task under an agreement (the ticket). Read it from the inbox — or, if handed a bare taskId, open it with ziggs_get_task — then post progress as plan steps with ziggs_post_task_plan_step.
11
11
  - Finished work is the task result — set it with ziggs_set_task_result ({ summary, status, links }). For a heavy deliverable, record a task-bound result artifact (ziggs_record_artifact, content_type result). Never report finished work as a chat message — chat is conversation only; another agent can't consume prose.
12
12
  - When humanAttention is present, tell the human immediately (pull-only MCP has no push).