@ziggs-ai/api-client 0.6.1 → 0.6.3

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.
@@ -7,7 +7,16 @@ import { type CapabilityDefinition, type CapabilityEnv } from './types.js';
7
7
  * return it too (they used to leak the raw agreement doc).
8
8
  */
9
9
  export declare function linkSummary(a: Agreement): Record<string, unknown>;
10
- /** A link is reach-only — the follow-up move differs by surface tool names. */
10
+ /**
11
+ * A link is reach-only — the follow-up move differs by surface tool names.
12
+ *
13
+ * Opening a chat is itself the admission: the backend issues a standing from-now
14
+ * chat grant to every agent member as it creates the room, so both delegates can
15
+ * read and post immediately. Do NOT tell agents to follow chat_open with an
16
+ * issue_grant on that same new chat — that only mints a duplicate grant carrying
17
+ * the default 30-day expiry. issue_grant / context_delegate are for scopes that
18
+ * already exist (an older chat, an agreement, an org).
19
+ */
11
20
  export declare function linkIsReachOnly(env: CapabilityEnv): string;
12
21
  export declare const createLinkInviteCapability: CapabilityDefinition;
13
22
  export declare const listLinksCapability: CapabilityDefinition;
@@ -11,11 +11,34 @@ function webAppOrigin(env) {
11
11
  * own assistant, which then connects itself and claims the invite. The claim
12
12
  * URL alone only helps someone who already has Ziggs and an assistant wired
13
13
  * up, so hand the caller both and let it pick per recipient.
14
+ *
15
+ * The account question comes FIRST, and the answer is always the claim URL —
16
+ * never 'Create account' on the MCP consent screen. Signup is invite-gated and
17
+ * only the claim URL carries the invite that waives it; the consent screen's
18
+ * signup button carries nothing, and nothing in an MCP OAuth handshake can
19
+ * carry it for them (the client builds its authorize request from RFC 8414/9728
20
+ * discovery, so a query param on the pasted server URL never reaches us). So a
21
+ * recipient new to Ziggs who lets their assistant lead used to hit a hard 403
22
+ * with no way back. Ordering is the whole fix: the URL both signs them up AND
23
+ * claims, leaving the assistant less to do, not more.
24
+ *
25
+ * Keep in step with the web app's copy of this text (frontend
26
+ * src/lib/links/inviteShare.ts) — same instructions, two surfaces.
14
27
  */
15
28
  function invitePasteText(agreementId, claimUrl) {
16
29
  return [
17
30
  'Connect me to Ziggs and accept this agent link invite.',
18
31
  '',
32
+ 'First ask me: do I already have a Ziggs account?',
33
+ '',
34
+ ` If no, or I am not sure — open this in a browser: ${claimUrl}`,
35
+ ' That creates my account and accepts the link in one step, and needs no',
36
+ " invite code. Do NOT send me to 'Create account' on the Ziggs consent",
37
+ ' screen instead — signup there is gated and will reject me. Once I am',
38
+ ' back, continue from step 1 to connect yourself; step 2 is already done.',
39
+ '',
40
+ ' If yes — start at step 1.',
41
+ '',
19
42
  `1. Add this MCP server: ${ZIGGS_MCP_URL}`,
20
43
  ' It speaks Streamable HTTP and uses OAuth — pasting the URL is enough,',
21
44
  ' but I may need to approve a consent screen in my browser.',
@@ -24,8 +47,6 @@ function invitePasteText(agreementId, claimUrl) {
24
47
  '',
25
48
  'If you cannot add MCP servers yourself, tell me exactly where to paste that',
26
49
  "URL in my assistant's settings, then continue from step 2.",
27
- '',
28
- `Invite link (if you need it in a browser instead): ${claimUrl}`,
29
50
  ].join('\n');
30
51
  }
31
52
  /**
@@ -49,11 +70,20 @@ export function linkSummary(a) {
49
70
  createdAt: a.createdAt,
50
71
  };
51
72
  }
52
- /** A link is reach-only — the follow-up move differs by surface tool names. */
73
+ /**
74
+ * A link is reach-only — the follow-up move differs by surface tool names.
75
+ *
76
+ * Opening a chat is itself the admission: the backend issues a standing from-now
77
+ * chat grant to every agent member as it creates the room, so both delegates can
78
+ * read and post immediately. Do NOT tell agents to follow chat_open with an
79
+ * issue_grant on that same new chat — that only mints a duplicate grant carrying
80
+ * the default 30-day expiry. issue_grant / context_delegate are for scopes that
81
+ * already exist (an older chat, an agreement, an org).
82
+ */
53
83
  export function linkIsReachOnly(env) {
54
84
  return env.surface === 'mcp'
55
- ? 'A link is reach-only. Open a chat with the peer (ziggs_chat_open, participantId = peer agent id) and grant it chat access with ziggs_context_issue_grant, or share a slice of a grant you hold with ziggs_context_delegate, before reading context.'
56
- : 'A link is reach-only: it does not grant context. Share a slice of a grant you hold with context_delegate, or ask the peer owner to issue one, before reading.';
85
+ ? 'A link is reach-only — it shares no context on its own. Open a chat with the peer (ziggs_chat_open, participantId = peer agent id): that admits both delegates to read and post from then on. To share context that already exists, issue a grant on it with ziggs_context_issue_grant or share a slice of one you hold with ziggs_context_delegate.'
86
+ : 'A link is reach-only — it shares no context on its own. Opening a chat with the peer admits both delegates to it from then on. To share context that already exists, share a slice of a grant you hold with context_delegate, or ask the peer owner to issue one.';
57
87
  }
58
88
  const LINK_STATUSES = ['active', 'open', 'cancelled', 'all'];
59
89
  /**
@@ -106,8 +136,8 @@ export const createLinkInviteCapability = {
106
136
  seatsRemaining: seats - (agreement.linkInvite?.claimsUsed ?? 0),
107
137
  pasteText: invitePasteText(agreement.agreementId, claimUrl),
108
138
  message: env.surface === 'mcp'
109
- ? `Open link invite created, ${seatNote}. Give the human BOTH forms and say which is which: claimUrl for a recipient who already uses Ziggs, pasteText for one who has an AI assistant but no Ziggs account — pasting it makes their assistant connect and claim the invite itself. A recipient with no Ziggs account can sign up straight from the link; no beta code needed. No agent id needed on either side.`
110
- : `Open link invite created, ${seatNote}. Share claimUrl with a counterparty who already uses Ziggs, or pasteText with one who has an assistant but no Ziggs account yet — their assistant connects and claims it. A recipient with no Ziggs account can sign up straight from the link; no beta code needed. No agent id needed on either side. Revoke with agreement_revoke to disable.`,
139
+ ? `Open link invite created, ${seatNote}. Give the human BOTH forms and say which is which: claimUrl is the one that always works — a recipient with no Ziggs account signs up straight from it, no beta code needed, and it accepts the link in the same step. pasteText is for a recipient who would rather their own assistant do the wiring; it starts by sending them to claimUrl if they have no account yet, since signup on the MCP consent screen is gated and would reject them. Either way the recipient needs their own assistant connected before the link carries anything. No agent id needed on either side.`
140
+ : `Open link invite created, ${seatNote}. claimUrl is the one that always works — a recipient with no Ziggs account signs up straight from it, no beta code needed, and it accepts the link in the same step. pasteText is for a recipient whose own assistant does the wiring; it sends them to claimUrl first if they have no account, since signup on the consent screen is gated. Either way they need an assistant connected before the link carries anything. No agent id needed on either side. Revoke with agreement_revoke to disable.`,
111
141
  agreement: linkSummary(agreement),
112
142
  };
113
143
  },
@@ -28,6 +28,10 @@ export interface InboxProposalRef {
28
28
  export interface InboxConnectionRequestRef {
29
29
  requestId: string;
30
30
  requesterAgentId: string;
31
+ /** ZIG-1039 — human-readable name for consent cards. */
32
+ requesterDisplayName?: string | null;
33
+ /** ZIG-1039 — org label for consent cards. */
34
+ requesterOrgName?: string | null;
31
35
  message: string | null;
32
36
  requestedAt: string | null;
33
37
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ziggs-ai/api-client",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "description": "HTTP and WebSocket client for the Ziggs backend API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",