@ziggs-ai/ziggs-mcp 0.36.1 → 0.36.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.
package/dist/config.d.ts CHANGED
@@ -30,6 +30,17 @@ declare const envSchema: z.ZodObject<{
30
30
  * its process is its host.
31
31
  */
32
32
  ZIGGS_INSTANCE_ID: z.ZodOptional<z.ZodString>;
33
+ /**
34
+ * Workspaces this window reads, comma-separated org ids. Sent as
35
+ * `X-Ziggs-Workspaces`. Unset reads everything the assistant may read.
36
+ * A hosted connection sets the header on the MCP request instead; this
37
+ * process serves every window, so it must not take the list from the env.
38
+ */
39
+ ZIGGS_WORKSPACES: z.ZodOptional<z.ZodString>;
40
+ /** Label on the assistant page, such as "Claude Code". */
41
+ ZIGGS_APP: z.ZodOptional<z.ZodString>;
42
+ /** Person-readable window name. Unset becomes the app plus the time. */
43
+ ZIGGS_SESSION_NAME: z.ZodOptional<z.ZodString>;
33
44
  /** Set to 1/true/yes to register internal/debug-only MCP tools. */
34
45
  ZIGGS_MCP_DEBUG: z.ZodOptional<z.ZodString>;
35
46
  /**
@@ -47,6 +58,9 @@ declare const envSchema: z.ZodObject<{
47
58
  ZIGGS_OWNER_USER_ID?: string | undefined;
48
59
  ZIGGS_LANE_ID?: string | undefined;
49
60
  ZIGGS_INSTANCE_ID?: string | undefined;
61
+ ZIGGS_WORKSPACES?: string | undefined;
62
+ ZIGGS_APP?: string | undefined;
63
+ ZIGGS_SESSION_NAME?: string | undefined;
50
64
  ZIGGS_MCP_DEBUG?: string | undefined;
51
65
  ZIGGS_MCP_CORE_ONLY?: string | undefined;
52
66
  }, {
@@ -58,6 +72,9 @@ declare const envSchema: z.ZodObject<{
58
72
  ZIGGS_OWNER_USER_ID?: string | undefined;
59
73
  ZIGGS_LANE_ID?: string | undefined;
60
74
  ZIGGS_INSTANCE_ID?: string | undefined;
75
+ ZIGGS_WORKSPACES?: string | undefined;
76
+ ZIGGS_APP?: string | undefined;
77
+ ZIGGS_SESSION_NAME?: string | undefined;
61
78
  ZIGGS_MCP_DEBUG?: string | undefined;
62
79
  ZIGGS_MCP_CORE_ONLY?: string | undefined;
63
80
  }>;
package/dist/config.js CHANGED
@@ -32,6 +32,17 @@ const envSchema = z.object({
32
32
  * its process is its host.
33
33
  */
34
34
  ZIGGS_INSTANCE_ID: z.string().optional(),
35
+ /**
36
+ * Workspaces this window reads, comma-separated org ids. Sent as
37
+ * `X-Ziggs-Workspaces`. Unset reads everything the assistant may read.
38
+ * A hosted connection sets the header on the MCP request instead; this
39
+ * process serves every window, so it must not take the list from the env.
40
+ */
41
+ ZIGGS_WORKSPACES: z.string().optional(),
42
+ /** Label on the assistant page, such as "Claude Code". */
43
+ ZIGGS_APP: z.string().optional(),
44
+ /** Person-readable window name. Unset becomes the app plus the time. */
45
+ ZIGGS_SESSION_NAME: z.string().optional(),
35
46
  /** Set to 1/true/yes to register internal/debug-only MCP tools. */
36
47
  ZIGGS_MCP_DEBUG: z.string().optional(),
37
48
  /**
@@ -59,6 +70,9 @@ export function loadConfig() {
59
70
  ZIGGS_OWNER_USER_ID: process.env.ZIGGS_OWNER_USER_ID,
60
71
  ZIGGS_LANE_ID: process.env.ZIGGS_LANE_ID,
61
72
  ZIGGS_INSTANCE_ID: process.env.ZIGGS_INSTANCE_ID,
73
+ ZIGGS_WORKSPACES: process.env.ZIGGS_WORKSPACES,
74
+ ZIGGS_APP: process.env.ZIGGS_APP,
75
+ ZIGGS_SESSION_NAME: process.env.ZIGGS_SESSION_NAME,
62
76
  ZIGGS_MCP_DEBUG: process.env.ZIGGS_MCP_DEBUG,
63
77
  ZIGGS_MCP_CORE_ONLY: process.env.ZIGGS_MCP_CORE_ONLY,
64
78
  };
@@ -10,7 +10,12 @@ export declare function parseBearerAuthorization(header: string | string[] | und
10
10
  * a person who pasted their key, wrong for a delegate holding grants its
11
11
  * customer gave.
12
12
  */
13
- export declare function connectionFromBearer(bearer: string, httpBaseUrl: string, ownerUserId?: string, laneId?: string): {
13
+ export declare function connectionFromBearer(bearer: string, httpBaseUrl: string, ownerUserId?: string, laneId?: string, session?: {
14
+ clientSessionId?: string;
15
+ workspaceIds?: string;
16
+ app?: string;
17
+ sessionName?: string;
18
+ }): {
14
19
  creds: Creds;
15
20
  cfg: ZiggsMcpConfig;
16
21
  };
@@ -20,7 +20,7 @@ export function parseBearerAuthorization(header) {
20
20
  * a person who pasted their key, wrong for a delegate holding grants its
21
21
  * customer gave.
22
22
  */
23
- export function connectionFromBearer(bearer, httpBaseUrl, ownerUserId, laneId) {
23
+ export function connectionFromBearer(bearer, httpBaseUrl, ownerUserId, laneId, session) {
24
24
  const resolvedAgentId = resolveDelegateAgentId(bearer, undefined);
25
25
  if (httpBaseUrl) {
26
26
  process.env.HTTP_URL = httpBaseUrl;
@@ -61,6 +61,10 @@ export function connectionFromBearer(bearer, httpBaseUrl, ownerUserId, laneId) {
61
61
  agentId: resolvedAgentId,
62
62
  ...(laneId ? { laneId } : {}),
63
63
  ...(instanceId ? { instanceId } : {}),
64
+ ...(session?.clientSessionId ? { clientSessionId: session.clientSessionId } : {}),
65
+ ...(session?.workspaceIds ? { workspaceIds: session.workspaceIds } : {}),
66
+ ...(session?.app ? { app: session.app } : {}),
67
+ ...(session?.sessionName ? { sessionName: session.sessionName } : {}),
64
68
  },
65
69
  cfg,
66
70
  };
package/dist/creds.js CHANGED
@@ -10,5 +10,8 @@ export function credsFromConfig(cfg) {
10
10
  // stays up and wrong for one a scheduler respawns per run — that one pins
11
11
  // ZIGGS_INSTANCE_ID so every run is the same host.
12
12
  ...(cfg.ZIGGS_INSTANCE_ID ? { instanceId: cfg.ZIGGS_INSTANCE_ID } : {}),
13
+ ...(cfg.ZIGGS_WORKSPACES ? { workspaceIds: cfg.ZIGGS_WORKSPACES } : {}),
14
+ ...(cfg.ZIGGS_APP ? { app: cfg.ZIGGS_APP } : {}),
15
+ ...(cfg.ZIGGS_SESSION_NAME ? { sessionName: cfg.ZIGGS_SESSION_NAME } : {}),
13
16
  };
14
17
  }
@@ -17,7 +17,10 @@
17
17
  * which `ziggs_auth_status` returns in full;
18
18
  * - a read step's `why` that only restates its tool and args, and the ack
19
19
  * step's long one, whose ids are the step's own args;
20
- * - an `outOfReach` entry's scope and remedy, which its delivery row carries.
20
+ * - an `outOfReach` entry's scope and remedy, which its delivery row carries;
21
+ * - `sessionCardHint` ("the card is not in this response") when the card is.
22
+ * Both doors assemble the session start from the long-poll result plus the
23
+ * card, and the long-poll half's hint said the opposite of what followed.
21
24
  *
22
25
  * Acknowledgement stays exact: every `ackTo` — the envelope's, each row's and
23
26
  * the ack step's — is passed through byte for byte.
@@ -17,7 +17,10 @@
17
17
  * which `ziggs_auth_status` returns in full;
18
18
  * - a read step's `why` that only restates its tool and args, and the ack
19
19
  * step's long one, whose ids are the step's own args;
20
- * - an `outOfReach` entry's scope and remedy, which its delivery row carries.
20
+ * - an `outOfReach` entry's scope and remedy, which its delivery row carries;
21
+ * - `sessionCardHint` ("the card is not in this response") when the card is.
22
+ * Both doors assemble the session start from the long-poll result plus the
23
+ * card, and the long-poll half's hint said the opposite of what followed.
21
24
  *
22
25
  * Acknowledgement stays exact: every `ackTo` — the envelope's, each row's and
23
26
  * the ack step's — is passed through byte for byte.
@@ -92,6 +95,8 @@ export function compactInboxResult(result) {
92
95
  if (isRecord(s))
93
96
  kindOfParty.set(String(s.partyId), s.partyKind);
94
97
  const out = { ...result };
98
+ if (typeof result.sessionChatCard === 'string' && result.sessionChatCard)
99
+ delete out.sessionCardHint;
95
100
  if (Array.isArray(result.deliveries)) {
96
101
  const usual = usualPartyOf(result.deliveries);
97
102
  if (usual !== undefined)
@@ -149,13 +154,16 @@ export function windowNote(deliveries, selfAgentIds, outOfReach) {
149
154
  const mine = rows.filter((d) => selfAgentIds.includes(String(d.assigneeId))).length;
150
155
  const person = rows.filter((d) => !d.assigneeId && d.needsHuman === true).length;
151
156
  const others = rows.filter((d) => d.assigneeId && !selfAgentIds.includes(String(d.assigneeId))).length;
157
+ // Rows nobody is asked to handle (no assignee, not the person's) are context.
158
+ const context = rows.length - mine - person - others;
152
159
  const n = (k, one, many) => `${k} ${k === 1 ? one : many}`;
153
160
  const parts = [n(mine, 'is assigned to you', 'are assigned to you')];
154
161
  if (person)
155
162
  parts.push(`${person} ${person === 1 ? 'needs' : 'need'} your person`);
156
163
  if (others)
157
164
  parts.push(`${others} ${others === 1 ? 'is' : 'are'} for other assistants`);
158
- if (outOfReach)
159
- parts.push(`${outOfReach} out of reach`);
160
- return `Those counts are decisions and tasks, not messages. This window has ${n(rows.length, 'delivery', 'deliveries')}: ${parts.join(', ')}.`;
165
+ if (context)
166
+ parts.push(`${context} ${context === 1 ? 'is' : 'are'} context`);
167
+ const reach = outOfReach ? ` ${outOfReach} of them ${outOfReach === 1 ? 'is' : 'are'} out of reach.` : '';
168
+ return `Those counts are decisions and tasks, not messages. This window has ${n(rows.length, 'delivery', 'deliveries')}: ${parts.join(', ')}.${reach}`;
161
169
  }
@@ -18,4 +18,10 @@
18
18
  * .cursorrules, which a client loads when it chooses to.
19
19
  */
20
20
  export type ConnectDoor = 'directory' | 'compact';
21
+ /**
22
+ * The rules a directory client must see even when it never shows the model
23
+ * the server's instructions (claude.ai does not). Carried on the session-start
24
+ * inbox read, the first call an agent makes, in the same words as above.
25
+ */
26
+ export declare function sessionRules(door: ConnectDoor): string[];
21
27
  export declare function renderConnectText(door: ConnectDoor): string;
@@ -32,6 +32,14 @@ const RULES = [
32
32
  'A send refused with WORK_SELECTION_REQUIRED lists choices: set conversationAgreementId to one of them; never guess.',
33
33
  'Agreement and task writes can reserve or settle points. After an uncertain write, read the record, then retry with the same idempotencyKey.',
34
34
  ];
35
+ /**
36
+ * The rules a directory client must see even when it never shows the model
37
+ * the server's instructions (claude.ai does not). Carried on the session-start
38
+ * inbox read, the first call an agent makes, in the same words as above.
39
+ */
40
+ export function sessionRules(door) {
41
+ return [DATA, INBOX[door]];
42
+ }
35
43
  const CATALOG = 'Only the everyday tools are loaded. ziggs_tools lists the rest; call them through ziggs_tool_read or ziggs_tool_write.';
36
44
  export function renderConnectText(door) {
37
45
  return [
@@ -13,6 +13,8 @@ import type { TitledAnnotations } from './toolAnnotations.js';
13
13
  * against. So every tool schema is built strict, and the rejection names both
14
14
  * the offending key and the params the tool actually accepts.
15
15
  */
16
+ /** The workspace parameter the router adds to a tool that acts in one. */
17
+ export declare const WORKSPACE_PARAM = "Workspace orgId, when more than one fits.";
16
18
  export type StrictShape<S extends ZodRawShape> = ZodObject<S, 'strict', z.ZodTypeAny>;
17
19
  export declare function strictParams<S extends ZodRawShape>(toolName: string, shape: S): StrictShape<S>;
18
20
  /**
@@ -4,6 +4,20 @@ import { workspaceRouter } from './workspaceRouting.js';
4
4
  import { mcpDescription } from '@ziggs-ai/api-client';
5
5
  import { z } from 'zod';
6
6
  import { recordCatalogEntry } from './toolCatalog.js';
7
+ /**
8
+ * registering a tool with a plain `ZodRawShape` lets the MCP SDK
9
+ * wrap it in a default `z.object()`, which *strips* unknown keys instead of
10
+ * rejecting them. A misspelled param (`nweChat` for `newChat`) was therefore
11
+ * dropped and the call ran anyway, reporting success for the opposite of what
12
+ * the caller asked for.
13
+ *
14
+ * A human typing that into a form gets a red field; an agent got silence, and
15
+ * silence reads as confirmation — there was no feedback loop to self-correct
16
+ * against. So every tool schema is built strict, and the rejection names both
17
+ * the offending key and the params the tool actually accepts.
18
+ */
19
+ /** The workspace parameter the router adds to a tool that acts in one. */
20
+ export const WORKSPACE_PARAM = 'Workspace orgId, when more than one fits.';
7
21
  export function strictParams(toolName, shape) {
8
22
  const accepted = Object.keys(shape);
9
23
  return z
@@ -58,8 +72,11 @@ export function registerStrictTool(server, name, shape, annotations, cb) {
58
72
  const router = workspaceRouter(server);
59
73
  const nativeOrgId = !!shape.orgId;
60
74
  if (router) {
75
+ // Said once per tool and kept short: it rides on most of the surface. Which
76
+ // workspace to use is taught where it matters — the refusal for a call that
77
+ // needs one lists the choices and says to ask the person.
61
78
  if (router.acceptsWorkspace(name))
62
- shape = { ...shape, orgId: shape.orgId?.optional() ?? z.string().optional().describe('Workspace named by your human. Required for new actions when more than one workspace fits.') };
79
+ shape = { ...shape, orgId: shape.orgId?.optional() ?? z.string().optional().describe(WORKSPACE_PARAM) };
63
80
  cb = router.wrap(name, annotations.readOnlyHint === true, cb, nativeOrgId);
64
81
  }
65
82
  const routed = cb;
package/dist/tools.js CHANGED
@@ -7,6 +7,7 @@ import { registerTrustTools } from './trustTools.js';
7
7
  import { registerPaymentTools } from './paymentTools.js';
8
8
  import { formatInboxToolResult, buildReadContextReadPlan, } from './inboxToolResult.js';
9
9
  import { compactTextResult, windowNote } from './inboxCompact.js';
10
+ import { sessionRules } from './protocol/connectText.js';
10
11
  import { agreementAppUrl, filterTasksForDelegate, formatPendingDecisionsPayload, resolveWebAppOrigin, } from './pendingDecisions.js';
11
12
  import { resolveMcpConnectionTarget, withMcpGatewayClient, } from './mcpConnectionTools.js';
12
13
  import { readOnly, write, destructive } from './toolAnnotations.js';
@@ -236,6 +237,14 @@ function registerConnectionTools(server, creds, cfg) {
236
237
  });
237
238
  registerCapability(server, requestConnectionCapability, creds);
238
239
  }
240
+ function inboxFor(creds) {
241
+ return new InboxClient(creds.operatorKey, creds.agentId, undefined, creds.instanceId, {
242
+ clientSessionId: creds.clientSessionId,
243
+ workspaceIds: creds.workspaceIds,
244
+ app: creds.app,
245
+ sessionName: creds.sessionName,
246
+ });
247
+ }
239
248
  export function registerZiggsTools(server, creds, cfg) {
240
249
  // A binding check and nothing else. This used to also report the
241
250
  // pending/active counts and point at a separate decisions tool for the card,
@@ -547,7 +556,7 @@ export function registerZiggsTools(server, creds, cfg) {
547
556
  .describe('Hold up to this many seconds (the server clamps a hold at about 110) and return as soon as assigned mail exists. Omit for an immediate count. Still does not take the lease. To wait for a reply your person asked about, call ziggs_inbox with waitSeconds: 55 instead, since only the full read returns the mail.'),
548
557
  }, readOnly('Peek inbox count without taking the mailbox'), async ({ waitSeconds }) => {
549
558
  try {
550
- const client = new InboxClient(creds.operatorKey, creds.agentId, undefined, creds.instanceId);
559
+ const client = inboxFor(creds);
551
560
  const [bindingSettled, readsSettled, peekSettled] = await Promise.allSettled([
552
561
  loadSessionBinding(creds, cfg),
553
562
  loadSessionReads(creds),
@@ -608,7 +617,7 @@ export function registerZiggsTools(server, creds, cfg) {
608
617
  try {
609
618
  // Unset on stdio: that process IS the host, and a scheduler that
610
619
  // respawns it per run pins ZIGGS_INSTANCE_ID instead.
611
- const client = new InboxClient(creds.operatorKey, creds.agentId, undefined, creds.instanceId);
620
+ const client = inboxFor(creds);
612
621
  // A cold call is the session start, and its extra reads — the binding
613
622
  // and the active-task rows — take nothing from the envelope. Started
614
623
  // here, they ride the same wave as the inbox fetch
@@ -676,6 +685,9 @@ export function registerZiggsTools(server, creds, cfg) {
676
685
  ...news,
677
686
  session,
678
687
  ...actions,
688
+ // A directory host may never show the model the server's
689
+ // instructions; the session-start read is the one place it looks.
690
+ ...(isDirectorySurface(server) ? { rules: sessionRules('directory') } : {}),
679
691
  ...(note && typeof actions.notice === 'string'
680
692
  ? { notice: `${actions.notice} ${note}` }
681
693
  : {}),
@@ -703,7 +715,7 @@ export function registerZiggsTools(server, creds, cfg) {
703
715
  if (isDirectorySurface(server)) {
704
716
  registerStrictTool(server, 'ziggs_inbox_claim', {}, destructive('Claim the inbox for this worker'), async () => {
705
717
  try {
706
- const client = new InboxClient(creds.operatorKey, creds.agentId, undefined, creds.instanceId);
718
+ const client = inboxFor(creds);
707
719
  return compactTextResult(await client.getInbox());
708
720
  }
709
721
  catch (e) {
@@ -728,7 +740,7 @@ export function registerZiggsTools(server, creds, cfg) {
728
740
  try {
729
741
  // Same host identity as the read: acking renews an owner, and only a
730
742
  // read acquires one.
731
- const client = new InboxClient(creds.operatorKey, creds.agentId, undefined, creds.instanceId);
743
+ const client = inboxFor(creds);
732
744
  const acked = await client.ackOrTakeHost(ack, {
733
745
  handledResourceIds: handledResourceIds ?? [],
734
746
  });
@@ -3,6 +3,7 @@ import { AsyncLocalStorage } from 'node:async_hooks';
3
3
  import { AssistantConnectionClient, withAssistantRequest, decodeOperatorKeyClaims, } from '@ziggs-ai/api-client';
4
4
  import { formatInboxToolResult } from './inboxToolResult.js';
5
5
  import { compactTextResult, windowNote } from './inboxCompact.js';
6
+ import { sessionRules } from './protocol/connectText.js';
6
7
  import { formatPendingDecisionsPayload, resolveWebAppOrigin } from './pendingDecisions.js';
7
8
  const routers = new WeakMap();
8
9
  /** The catalog and its dispatchers: they reach other tools, which route themselves. */
@@ -207,6 +208,7 @@ export class WorkspaceRouter {
207
208
  return compactTextResult({
208
209
  ...news,
209
210
  ...pending,
211
+ ...(name === 'ziggs_inbox' && args.waitSeconds == null ? { rules: sessionRules('directory') } : {}),
210
212
  ...(note && typeof pending.notice === 'string' ? { notice: `${pending.notice} ${note}` } : {}),
211
213
  session: { workspaces },
212
214
  instruction: `Assigned to any of agentIds is your work. ${ASK_YOUR_HUMAN}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ziggs-ai/ziggs-mcp",
3
- "version": "0.36.1",
3
+ "version": "0.36.3",
4
4
  "description": "MCP server for Claude Code, Cursor, and other MCP hosts — act as your Ziggs delegate agent",
5
5
  "type": "module",
6
6
  "bin": {
@@ -27,6 +27,7 @@
27
27
  },
28
28
  "scripts": {
29
29
  "build": "tsc -p tsconfig.json && chmod +x dist/index.js",
30
+ "typecheck": "tsc -p tsconfig.json --noEmit",
30
31
  "prepack": "rm -rf dist && npm run build",
31
32
  "start": "node dist/index.js",
32
33
  "dev": "tsx src/index.ts",
@@ -39,7 +40,7 @@
39
40
  },
40
41
  "dependencies": {
41
42
  "@modelcontextprotocol/sdk": "^1.29.0",
42
- "@ziggs-ai/api-client": "0.36.0",
43
+ "@ziggs-ai/api-client": "0.36.1",
43
44
  "dotenv": "^16.6.1",
44
45
  "zod": "^3.24.2",
45
46
  "zod-to-json-schema": "^3.25.1"