@cotal-ai/connector-claude-code 0.103.4 → 0.104.2

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/mcp.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAiKtD,yFAAyF;AACzF,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IACvB,KAAK,EAAE,QAAQ,CAAC;IAChB,MAAM,EAAE,QAAQ,CAAC;IACjB;uDACmD;IACnD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;gFAC4E;IAC5E,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb;uDACmD;IACnD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED;;+BAE+B;AAC/B,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,aAAa,CAAC,CAQ3F"}
1
+ {"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAsKtD,yFAAyF;AACzF,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IACvB,KAAK,EAAE,QAAQ,CAAC;IAChB,MAAM,EAAE,QAAQ,CAAC;IACjB;uDACmD;IACnD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;gFAC4E;IAC5E,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb;uDACmD;IACnD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED;;+BAE+B;AAC/B,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,aAAa,CAAC,CAQ3F"}
package/dist/monitor.cjs CHANGED
@@ -137,6 +137,30 @@ function hasIdentity(env = process.env) {
137
137
  // ../connector-core/dist/control.js
138
138
  var MAX_FRAME_BYTES = 1 << 20;
139
139
 
140
+ // src/approval-notice.ts
141
+ var APPROVAL_ID = /^[a-z2-7]{26}$/;
142
+ var STATUSES = /* @__PURE__ */ new Set(["approved", "denied", "expired"]);
143
+ function approvalFrame(frame) {
144
+ const approval = frame?.approval;
145
+ if (!approval || typeof approval !== "object") return void 0;
146
+ const { name, status, id } = approval;
147
+ if (typeof name !== "string" || !name || name.length > 128 || /[\r\n]/.test(name) || name !== name.trim()) return void 0;
148
+ if (typeof status !== "string" || !STATUSES.has(status)) return void 0;
149
+ if (typeof id !== "string" || !APPROVAL_ID.test(id)) return void 0;
150
+ return { name, status, id };
151
+ }
152
+ function approvalEvent(n) {
153
+ const name = JSON.stringify(n.name);
154
+ switch (n.status) {
155
+ case "approved":
156
+ return `Cotal: the person approved connection ${name}. Finish it: call cotal_connect with name ${name} and approval_id ${JSON.stringify(n.id)}.`;
157
+ case "denied":
158
+ return `Cotal: the person denied connection ${name}. Nothing was connected. Do not ask again unless the person asks you to.`;
159
+ case "expired":
160
+ return `Cotal: the approval for connection ${name} expired before the person decided. Nothing was connected. Call cotal_connect with name ${name} again to ask again.`;
161
+ }
162
+ }
163
+
140
164
  // src/wake-feed.ts
141
165
  var import_node_fs2 = require("node:fs");
142
166
  var import_node_os = require("node:os");
@@ -348,6 +372,12 @@ function main() {
348
372
  try {
349
373
  if (line.length > INLINE_FRAME_LIMIT) continue;
350
374
  const frame = JSON.parse(line);
375
+ const decided = approvalFrame(frame);
376
+ if (decided) {
377
+ process.stdout.write(`${approvalEvent(decided)}
378
+ `);
379
+ continue;
380
+ }
351
381
  if (isNativeInlineFrame(frame)) {
352
382
  if (frame.inline.session === session && frame.route === path)
353
383
  process.stdout.write(`Cotal inline delivery: ${JSON.stringify(frame)}
@@ -1,3 +1,4 @@
1
+ import type { ApprovalNotice } from "./app-host.js";
1
2
  import type { InlineDeliveryBatch, InlineDeliveryPayload, RenderedInboxPreview } from "@cotal-ai/connector-core";
2
3
  /** A connection id the feed carries. Gateway ids are UUIDs, so anything else is not one. */
3
4
  export declare const WAKE_ID: RegExp;
@@ -10,6 +11,8 @@ export declare function nativeSocketPath(feed: string): string;
10
11
  export interface WakeFeed {
11
12
  /** Write one bounded preview + `id` to every monitor reading the feed. False when none is. */
12
13
  send(id: string, preview: RenderedInboxPreview, session?: string): boolean;
14
+ /** Tell the monitors of one native session what the person decided about its pending request. */
15
+ notifyApproval(session: string, notice: ApprovalNotice): boolean;
13
16
  supportsInline(session: string): boolean;
14
17
  inlinePending(session: string): boolean;
15
18
  fitsInline(id: string, session: string, payload: InlineDeliveryPayload): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"wake-feed.d.ts","sourceRoot":"","sources":["../src/wake-feed.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAGjH,4FAA4F;AAC5F,eAAO,MAAM,OAAO,QAA2B,CAAC;AA6BhD,mFAAmF;AACnF,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,GAAE,MAAoB,GAAG,MAAM,CAGzF;AAED,uGAAuG;AACvG,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAMvD;AAED,sGAAsG;AACtG,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAErD;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,CAAC;IAC/B,KAAK,IAAI,IAAI,CAAC;CACf;AAED,yEAAyE;AACzE,wBAAsB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CA4GvE"}
@@ -1,6 +1,12 @@
1
1
  const WAKE = /^Cotal: a new message for connection_id ([A-Za-z0-9_-]{1,128})\. Read it with cotal_inbox\.$/;
2
2
  const PREVIEW = /^Cotal preview for connection_id ([A-Za-z0-9_-]{1,128}): (\{.*\})$/;
3
3
  const INLINE = /^Cotal: inline messages for connection_id ([A-Za-z0-9_-]{1,128})\.$/;
4
+ // The person's decision on this conversation's pending cotal_connect, in the server's exact shapes
5
+ // (src/approval-notice.ts). Names are JSON strings; nothing else about the line is free text.
6
+ const QUOTED = '"((?:[^"\\\\\\x00-\\x1f]|\\\\.){1,512})"';
7
+ const APPROVED = new RegExp(`^Cotal: the person approved connection ${QUOTED}\\. Finish it: call cotal_connect with name ${QUOTED} and approval_id "([a-z2-7]{26})"\\.$`);
8
+ const DENIED = new RegExp(`^Cotal: the person denied connection ${QUOTED}\\. Nothing was connected\\. Do not ask again unless the person asks you to\\.$`);
9
+ const EXPIRED = new RegExp(`^Cotal: the approval for connection ${QUOTED} expired before the person decided\\. Nothing was connected\\. Call cotal_connect with name ${QUOTED} again to ask again\\.$`);
4
10
  const ID = /^[A-Za-z0-9_-]{1,128}$/;
5
11
  const offers = new Map();
6
12
  const retries = new Map();
@@ -17,6 +23,17 @@ let reader;
17
23
  let readerSession;
18
24
  let nativeBinding;
19
25
 
26
+ function approvalLine(line) {
27
+ const match = APPROVED.exec(line) || DENIED.exec(line) || EXPIRED.exec(line);
28
+ if (!match) return false;
29
+ try {
30
+ const name = JSON.parse(`"${match[1]}"`);
31
+ if (typeof name !== 'string' || !name || name.length > 128 || name !== name.trim() || /[\r\n]/.test(name)) return false;
32
+ const again = match[2];
33
+ return again === undefined || JSON.parse(`"${again}"`) === name;
34
+ } catch { return false; }
35
+ }
36
+
20
37
  async function relayNative($, event) {
21
38
  if (await $.env.get('COTAL_NAME') || await $.env.get('COTAL_LINK') || await $.env.get('COTAL_AGENT_FILE')) return;
22
39
  const root = $.plugin.root;
@@ -205,7 +222,7 @@ async function listen($) {
205
222
  void submit($);
206
223
  }
207
224
  } catch {}
208
- } else if (WAKE.test(line)) {
225
+ } else if (WAKE.test(line) || approvalLine(line)) {
209
226
  pending.add(line);
210
227
  void submit($);
211
228
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cotal-ai/connector-claude-code",
3
3
  "description": "Cotal connector for Claude Code: an installed plugin that joins a session to the mesh.",
4
- "version": "0.103.4",
4
+ "version": "0.104.2",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",
@@ -25,8 +25,8 @@
25
25
  "@cotal-ai/core": ">=0.1.0"
26
26
  },
27
27
  "devDependencies": {
28
- "@cotal-ai/connector-core": "0.103.4",
29
- "@cotal-ai/core": "0.103.4",
28
+ "@cotal-ai/connector-core": "0.104.2",
29
+ "@cotal-ai/core": "0.104.2",
30
30
  "@cotal-ai/smoke-kit": "0.0.0",
31
31
  "@modelcontextprotocol/sdk": "^1.29.0",
32
32
  "@nats-io/transport-node": "^3.4.0",
@@ -45,7 +45,7 @@
45
45
  "access": "public"
46
46
  },
47
47
  "scripts": {
48
- "test": "tsx smoke/launch-env.smoke.ts && tsx smoke/app-approval.smoke.ts && tsx smoke/native-wake.smoke.ts && tsx smoke/native-binding-live.smoke.ts && tsx smoke/wake-preview-frame.smoke.ts && tsx smoke/native-inline-live.smoke.ts",
48
+ "test": "tsx smoke/launch-env.smoke.ts && tsx smoke/app-approval.smoke.ts && tsx smoke/app-approval-resume.smoke.ts && tsx smoke/native-wake.smoke.ts && tsx smoke/native-binding-live.smoke.ts && tsx smoke/wake-preview-frame.smoke.ts && tsx smoke/native-inline-live.smoke.ts",
49
49
  "test:desktop-setup": "tsx smoke/desktop-only-setup-live.smoke.ts",
50
50
  "test:upgrade": "tsx smoke/plugin-upgrade-live.smoke.ts",
51
51
  "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.smoke.json",