granttap-mcp 0.8.157 → 0.8.158

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.
@@ -24,13 +24,13 @@ An uncertain or crashed dispatch is not replayed. A native receipt produces no
24
24
  synthetic assistant reply or completed-run digest; the existing transcript carries
25
25
  the actual work. Pause sends the user's stop request to the same owner. Document
26
26
  attachments remain in private staging for up to a day after admission; the monitor
27
- removes expired stages. Image-only stages are removed once native admission has
28
- consumed them. Tests exercise native delivery, framing, socket trust, durable
27
+ removes expired stages. Image-only stages have the same retention because
28
+ admission precedes attachment consumption. Tests exercise framing, socket trust, durable
29
29
  deduplication, and refusal without launching the CLI.
30
30
 
31
31
  License: GrantTap Commercial Source License in the repository-root `LICENSE`.
32
32
 
33
- Document staging for a native-only question keeps the file note inside its
33
+ Document staging for a correlated question keeps the file note inside its
34
34
  original answer envelope. The host's native question and all paired controllers
35
35
  therefore observe the same question item as answered; document paths remain
36
36
  available to the admitted turn. Ordinary chat text is unchanged.
@@ -39,3 +39,9 @@ The bounded native admission deadline leaves time for the installed router’s
39
39
  ten-second owner discovery window. A five-second client cap otherwise reports
40
40
  healthy CLI conversations unavailable before discovery can finish. Missing-owner
41
41
  confirmation preserves CLI continuation; uncertain dispatch remains unreplayed.
42
+
43
+ `continueCodexQuestion`, exported through `index.ts`, reserves the same durable
44
+ question identity for an ownerless CLI continuation. Its caller must first
45
+ obtain a definitive absent-owner result inside the existing per-chat queue.
46
+ The original native envelope is preserved, and another controller cannot retry
47
+ an uncertain dispatch or replace an already accepted answer.
@@ -8,6 +8,8 @@ import { DesktopConnection } from './connection';
8
8
  import { DesktopReceipt } from './receipts';
9
9
  import { desktopSocketPath } from './socket-path';
10
10
  export { interruptCodexDesktop } from './controls';
11
+ export { continueCodexQuestion } from './question-continuation';
12
+ export { nativeQuestionAttachmentEnvelope } from './question-attachment-envelope';
11
13
 
12
14
  const UNAVAILABLE = 'Codex desktop is not ready to receive this message. Keep the original chat open and try again.';
13
15
  const UNCERTAIN = 'Codex has not confirmed this message. Check the original chat before sending it again.';
@@ -73,7 +75,8 @@ function turnRequest(input: { session: SessionInfo; text: string; images: string
73
75
  networkAccess: false, excludeTmpdirEnvVar: false, excludeSlashTmp: false }
74
76
  : access === 'full' ? { type: 'dangerFullAccess' } : undefined;
75
77
  return { threadId: session.sessionId, clientUserMessageId: options.messageId ?? randomUUID(),
76
- input: [{ type: 'text', text: options.nativeOnly ? nativeQuestionAttachmentEnvelope(text) : text, text_elements: [] }, ...images.map(path => ({ type: 'localImage', path }))],
78
+ input: [{ type: 'text', text: options.nativeOnly || options.questionReply
79
+ ? nativeQuestionAttachmentEnvelope(text) : text, text_elements: [] }, ...images.map(path => ({ type: 'localImage', path }))],
77
80
  ...(options.model ? { model: options.model } : {}), ...(effort ? { effort } : {}),
78
81
  ...(sandboxPolicy ? { sandboxPolicy } : {}) };
79
82
  }
@@ -0,0 +1,10 @@
1
+ # Ownerless question continuation
2
+
3
+ `continueCodexQuestion`, exported by the parent `index.ts`, reserves the original
4
+ question's durable admission identity before a serialized CLI continuation.
5
+ Call only after native owner discovery returns definitive absence. Pending or
6
+ uncertain admissions are never retried, including from another controller.
7
+ Public delivery integration tests live in
8
+ `../../codex-questions/continuation/tests/cli-delivery.test.ts`.
9
+
10
+ License: [GrantTap Commercial Source License](../../../../../LICENSE).
@@ -0,0 +1,28 @@
1
+ import type { DeliveryOptions, ReplyResult } from '../../reply/payload/types';
2
+ import { DesktopReceipt } from '../receipts';
3
+
4
+ /** Called inside the chat queue only after desktop discovery proves no owner exists. */
5
+ export async function continueCodexQuestion(sessionId: string, options: DeliveryOptions,
6
+ run: () => Promise<ReplyResult>): Promise<ReplyResult> {
7
+ if (!options.messageId || !options.intentDigest) {
8
+ return { ok: false, error: 'The question answer has no stable delivery identity.' };
9
+ }
10
+ try {
11
+ // Share the native admission journal: neither a second controller nor a
12
+ // later desktop owner may submit another answer for this question.
13
+ const receipt = new DesktopReceipt(sessionId, options.messageId, options.intentDigest);
14
+ const state = receipt.begin();
15
+ if (state === 'accepted') return { ok: true, text: '', sessionId, delivery: 'native' };
16
+ if (state === 'conflict') return { ok: false, error: 'This message ID belongs to a different Codex delivery.' };
17
+ if (state !== 'new') return uncertain();
18
+ const result = await run();
19
+ if (!result.ok) return { ...result, delivery: 'native' };
20
+ receipt.accept('cli:' + sessionId);
21
+ return result;
22
+ } catch { return uncertain(); }
23
+ }
24
+
25
+ function uncertain(): ReplyResult {
26
+ return { ok: false, delivery: 'native',
27
+ error: 'Codex has not confirmed this answer. Check the original chat before sending it again.' };
28
+ }
@@ -17,9 +17,15 @@ Replies use the original host question item ID and normal scoped phone delivery,
17
17
  including current provider, pause and Task policy. Native admission uses one
18
18
  stable delivery ID per question, so concurrent controllers cannot submit two
19
19
  different answers. The phone's own message ID still receives its receipts.
20
- If the desktop owner is unavailable, question replies do not launch a separate
21
- CLI writer. An uncertain admission is not replayed or described as a confirmed
22
- native answer. Native transcript files are read without modification.
20
+ When discovery confirms there is no desktop owner, an answer resumes the same
21
+ CLI conversation through the existing per-chat queue. It waits for a running
22
+ delivery, preserves the original question envelope and attachments, and shares
23
+ the durable native admission identity across controllers. An uncertain native
24
+ or CLI dispatch is never replayed. Native transcript files remain read-only.
25
+
26
+ The public `presentation/index.ts` boundary extracts human answers for run journals
27
+ and Task progress before truncation. Unknown or truncated question envelopes
28
+ show a neutral reply label; ordinary messages and quoted examples stay intact.
23
29
 
24
30
  Tests under `tests/` cover publication, reconnect replay, native acknowledgement,
25
31
  scope rejection, expiry and delivery through an isolated native IPC fixture.
@@ -108,7 +108,7 @@ export async function handleCodexQuestionReply(client: RelayClient, message: Use
108
108
  return deliver(client, { ...message, requestId: undefined,
109
109
  messageId: message.messageId ?? 'codex-answer-' + record.requestId,
110
110
  text: nativeAnswerEnvelope(record, message.text) }, publish, peerPublicKey,
111
- { messageId: record.requestId, nativeOnly: true });
111
+ { messageId: record.requestId, questionReply: true });
112
112
  }
113
113
 
114
114
  function resolveQuestion(client: RelayClient, record: QuestionRecord, peerPublicKey?: string, expired = false) {
@@ -0,0 +1,9 @@
1
+ # Question answer presentation
2
+
3
+ Public entry: `questionAnswerPresentation` in `index.ts`. Run journals and Task
4
+ progress show human answers before storage limits truncate them. Presentation
5
+ does not alter the native envelope used for delivery or transcript confirmation.
6
+ Malformed or truncated envelopes use a neutral label. Tests cover normal text,
7
+ quoted examples, multiple answers, document staging notes, and invalid envelopes.
8
+
9
+ License: [GrantTap Commercial Source License](../../../../../LICENSE).
@@ -0,0 +1,22 @@
1
+ import { stripAttachmentNote } from '../../sessions/support/activity-helpers';
2
+
3
+ /** Public presentation boundary; never changes the original native delivery payload. */
4
+ export function questionAnswerPresentation(text: string): string {
5
+ const opening = '<send_user_message_question_reply>';
6
+ const closing = '</send_user_message_question_reply>';
7
+ const wrapped = text.trim();
8
+ if (!wrapped.startsWith(opening)) return text;
9
+ if (!wrapped.endsWith(closing)) return 'Question reply';
10
+ try {
11
+ const rows = JSON.parse(wrapped.slice(opening.length, -closing.length));
12
+ if (!Array.isArray(rows) || !rows.length || rows.length > 4) return 'Question reply';
13
+ const answers = rows.map(row => {
14
+ const id = JSON.parse(row.questionItemId);
15
+ if (!Array.isArray(id) || id.length !== 3 || id[0] !== 'request_user_input_async'
16
+ || typeof id[1] !== 'string' || !/^[a-zA-Z0-9_-]{1,180}$/.test(id[1])
17
+ || !Number.isInteger(id[2]) || id[2] < 0 || id[2] > 3 || typeof row.answer !== 'string') throw Error('Invalid reply');
18
+ return stripAttachmentNote(row.answer).trim();
19
+ });
20
+ return answers.filter(Boolean).join('; ') || 'Question reply';
21
+ } catch { return 'Question reply'; }
22
+ }
@@ -12,6 +12,7 @@
12
12
  import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
13
13
  import { join } from "node:path";
14
14
  import { configDir } from "../../config/runtime/paths";
15
+ import { questionAnswerPresentation } from '../../codex-questions/presentation';
15
16
 
16
17
  export type RunRecord = {
17
18
  /** Stable id for this run. Start time is not a confirmation key. */
@@ -87,7 +88,7 @@ export function recordRun(sessionId: string, record: RunRecord): void {
87
88
  const bounded: RunRecord = {
88
89
  ...record,
89
90
  runId: record.runId || `run:${record.at}`,
90
- prompt: compactText(record.prompt, MAX_PROMPT_CHARS),
91
+ prompt: compactText(questionAnswerPresentation(record.prompt), MAX_PROMPT_CHARS),
91
92
  outcome: compactText(record.outcome, MAX_OUTCOME_CHARS),
92
93
  files: record.files.slice(0, MAX_FILES),
93
94
  };
@@ -141,7 +142,7 @@ export type RunDescriptionLimits = { files?: number; outcome?: number };
141
142
  /** One line a person or a model can read: what was asked, what happened, what it touched. */
142
143
  export function describeRun(record: RunRecord, limits: RunDescriptionLimits = {}): string {
143
144
  const outcome = limits.outcome == null ? record.outcome : compactText(record.outcome, limits.outcome);
144
- const parts = [`«${record.prompt}» → ${record.ok ? "" : "failed: "}${outcome}`];
145
+ const parts = [`«${questionAnswerPresentation(record.prompt)}» → ${record.ok ? "" : "failed: "}${outcome}`];
145
146
  const files = limits.files ?? 6;
146
147
  if (record.files.length > 0 && files > 0) {
147
148
  const shown = record.files.slice(0, files).join(", ");
@@ -123,7 +123,7 @@ export async function handleUserMessage(
123
123
  message: UserMessage,
124
124
  onProcessing?: () => Promise<void>,
125
125
  peerPublicKey?: string,
126
- native?: { messageId: string; nativeOnly: true },
126
+ native?: { messageId: string; questionReply: true },
127
127
  onRefusal?: (error: string) => Promise<void>,
128
128
  ): Promise<"accepted" | "rejected"> {
129
129
  const say = (text: string, sessionId?: string, wake = false, kind: "status" | "response" = "response") => {
@@ -176,7 +176,7 @@ export async function handleUserMessage(
176
176
  const startedAt = Date.now();
177
177
  const run = deliverToSession(target, message.text, PHONE_RUN_LIMIT_MS, attachments, {
178
178
  messageId: native?.messageId ?? message.messageId,
179
- nativeOnly: native?.nativeOnly,
179
+ questionReply: native?.questionReply,
180
180
  onAgentActivity: () => reportMessageAgentActivity(client, message, peerPublicKey),
181
181
  preferredMcp: message.preferredMcp,
182
182
  skill: message.skill,
@@ -11,7 +11,7 @@ export async function handleInboundUserMessage(
11
11
  client: RelayClient, payload: Extract<Payload, { type: "user.message" }>,
12
12
  publish: (forceHistory?: boolean) => Promise<void>,
13
13
  peerPublicKey?: string,
14
- native?: { messageId: string; nativeOnly: true },
14
+ native?: { messageId: string; questionReply: true },
15
15
  ): Promise<boolean> {
16
16
  if (payload.requestId) return false;
17
17
  let deliveryStarted = false;
@@ -9,6 +9,8 @@ export type DeliveryOptions = {
9
9
  messageId?: string;
10
10
  /** Native host questions must never fall back to a second CLI conversation. */
11
11
  nativeOnly?: boolean;
12
+ /** Correlated question answer; use serialized resume only when no desktop owner exists. */
13
+ questionReply?: boolean;
12
14
  /** Computer-generated identity before temporary attachment paths are inserted. */
13
15
  intentDigest?: string;
14
16
  preferredMcp?: string;
@@ -4,7 +4,7 @@ import { resolveCodexBinary } from "../../providers/codex-bin";
4
4
  import { runProcess } from ".";
5
5
  import { providerEffortArgs } from "./provider-effort";
6
6
  import type { DeliveryOptions, ReplyResult } from "../payload/types";
7
- import { deliverToCodexDesktop } from '../../codex-desktop';
7
+ import { continueCodexQuestion, deliverToCodexDesktop, nativeQuestionAttachmentEnvelope } from '../../codex-desktop';
8
8
 
9
9
  function parseCodexJsonl(stdout: string, fallbackSessionId?: string): ReplyResult {
10
10
  let lastMessage = "";
@@ -55,6 +55,13 @@ export async function runCodex(
55
55
  const native = await deliverToCodexDesktop({ session, text, images, options, timeoutMs });
56
56
  if (native) return native;
57
57
  if (options.nativeOnly) return { ok: false, error: 'Open this conversation in Codex to answer its question.' };
58
+ if (options.questionReply) return continueCodexQuestion(session.sessionId, options,
59
+ () => resumeCodex(session, nativeQuestionAttachmentEnvelope(text), timeoutMs, images, options));
60
+ return resumeCodex(session, text, timeoutMs, images, options);
61
+ }
62
+
63
+ async function resumeCodex(session: SessionInfo, text: string, timeoutMs: number,
64
+ images: string[], options: DeliveryOptions): Promise<ReplyResult> {
58
65
  const configured = loadRuntimeConfig().sessionAccess[session.sessionId];
59
66
  const disabledMcp = loadRuntimeConfig().sessionMcpDisabled[session.sessionId] ?? [];
60
67
  const sandbox = configured === "read-only"
@@ -10,7 +10,7 @@ keeps each phone response tied to the exact originating chat and prompt.
10
10
  Install the supported CLI on this computer, then run:
11
11
 
12
12
  ```bash
13
- npm install -g granttap-mcp@0.8.157
13
+ npm install -g granttap-mcp@0.8.158
14
14
  granttap setup
15
15
  granttap status
16
16
  ```
@@ -4,7 +4,7 @@
4
4
  "command": "node",
5
5
  "args": [
6
6
  "-e",
7
- "\"use strict\";\n\n// Cursor may start this MCP from any cwd. Execute JavaScript entry points with\n// Node itself: Windows batch shims require shell quoting that differs by host.\nconst { spawn } = require(\"node:child_process\");\nconst { existsSync } = require(\"node:fs\");\nconst { delimiter, dirname, join } = require(\"node:path\");\n\nconst PACKAGE = \"granttap-mcp@0.8.157\";\nconst dryRun = process.env.GRANTTAP_BOOTSTRAP_DRY_RUN === \"1\";\nconst platform = dryRun && process.env.GRANTTAP_BOOTSTRAP_PLATFORM\n ? process.env.GRANTTAP_BOOTSTRAP_PLATFORM : process.platform;\nconst nodeRoot = dryRun && process.env.GRANTTAP_BOOTSTRAP_NODE_ROOT\n ? process.env.GRANTTAP_BOOTSTRAP_NODE_ROOT : dirname(process.execPath);\nconst pathRoots = (process.env.PATH || \"\").split(delimiter).filter(Boolean);\nconst appData = process.env.APPDATA;\nconst roots = [nodeRoot, ...pathRoots, ...(appData ? [join(appData, \"npm\")] : [])];\nconst first = (paths) => paths.find((path) => existsSync(path));\n\nfunction launch() {\n if (platform !== \"win32\") {\n const installed = first(roots.map((root) => join(root, \"granttap-mcp\")));\n if (installed) return { command: installed, args: [] };\n const npx = first(roots.map((root) => join(root, \"npx\"))) || \"npx\";\n return { command: npx, args: [\"-y\", PACKAGE] };\n }\n const installed = first(roots.map((root) =>\n join(root, \"node_modules\", \"granttap-mcp\", \"bin\", \"granttap-mcp.mjs\")));\n if (installed) return { command: process.execPath, args: [installed] };\n const npx = first(roots.map((root) =>\n join(root, \"node_modules\", \"npm\", \"bin\", \"npx-cli.js\")));\n if (npx) return { command: process.execPath, args: [npx, \"-y\", PACKAGE] };\n throw new Error(\"Node.js/npm 22.13.0+ is required on this Windows device. Install npm and retry GrantTap.\");\n}\n\nlet target;\ntry { target = launch(); }\ncatch (error) {\n process.stderr.write(`[granttap] ${error.message}\\n`);\n process.exit(1);\n}\n\nif (dryRun) {\n process.stdout.write(JSON.stringify(target));\n process.exit(0);\n}\n\nconst child = spawn(target.command, target.args, { stdio: \"inherit\", windowsHide: true });\nchild.on(\"error\", (error) => {\n process.stderr.write(`[granttap] ${error.message}\\n`);\n process.exit(1);\n});\nchild.on(\"exit\", (code, signal) => {\n if (signal && platform !== \"win32\") {\n try { process.kill(process.pid, signal); } catch { process.exit(code ?? 1); }\n return;\n }\n process.exit(code ?? 1);\n});\n"
7
+ "\"use strict\";\n\n// Cursor may start this MCP from any cwd. Execute JavaScript entry points with\n// Node itself: Windows batch shims require shell quoting that differs by host.\nconst { spawn } = require(\"node:child_process\");\nconst { existsSync } = require(\"node:fs\");\nconst { delimiter, dirname, join } = require(\"node:path\");\n\nconst PACKAGE = \"granttap-mcp@0.8.158\";\nconst dryRun = process.env.GRANTTAP_BOOTSTRAP_DRY_RUN === \"1\";\nconst platform = dryRun && process.env.GRANTTAP_BOOTSTRAP_PLATFORM\n ? process.env.GRANTTAP_BOOTSTRAP_PLATFORM : process.platform;\nconst nodeRoot = dryRun && process.env.GRANTTAP_BOOTSTRAP_NODE_ROOT\n ? process.env.GRANTTAP_BOOTSTRAP_NODE_ROOT : dirname(process.execPath);\nconst pathRoots = (process.env.PATH || \"\").split(delimiter).filter(Boolean);\nconst appData = process.env.APPDATA;\nconst roots = [nodeRoot, ...pathRoots, ...(appData ? [join(appData, \"npm\")] : [])];\nconst first = (paths) => paths.find((path) => existsSync(path));\n\nfunction launch() {\n if (platform !== \"win32\") {\n const installed = first(roots.map((root) => join(root, \"granttap-mcp\")));\n if (installed) return { command: installed, args: [] };\n const npx = first(roots.map((root) => join(root, \"npx\"))) || \"npx\";\n return { command: npx, args: [\"-y\", PACKAGE] };\n }\n const installed = first(roots.map((root) =>\n join(root, \"node_modules\", \"granttap-mcp\", \"bin\", \"granttap-mcp.mjs\")));\n if (installed) return { command: process.execPath, args: [installed] };\n const npx = first(roots.map((root) =>\n join(root, \"node_modules\", \"npm\", \"bin\", \"npx-cli.js\")));\n if (npx) return { command: process.execPath, args: [npx, \"-y\", PACKAGE] };\n throw new Error(\"Node.js/npm 22.13.0+ is required on this Windows device. Install npm and retry GrantTap.\");\n}\n\nlet target;\ntry { target = launch(); }\ncatch (error) {\n process.stderr.write(`[granttap] ${error.message}\\n`);\n process.exit(1);\n}\n\nif (dryRun) {\n process.stdout.write(JSON.stringify(target));\n process.exit(0);\n}\n\nconst child = spawn(target.command, target.args, { stdio: \"inherit\", windowsHide: true });\nchild.on(\"error\", (error) => {\n process.stderr.write(`[granttap] ${error.message}\\n`);\n process.exit(1);\n});\nchild.on(\"exit\", (code, signal) => {\n if (signal && platform !== \"win32\") {\n try { process.kill(process.pid, signal); } catch { process.exit(code ?? 1); }\n return;\n }\n process.exit(code ?? 1);\n});\n"
8
8
  ]
9
9
  }
10
10
  }
@@ -7,7 +7,7 @@ const { spawn } = require("node:child_process");
7
7
  const { existsSync } = require("node:fs");
8
8
  const { delimiter, dirname, join } = require("node:path");
9
9
 
10
- const PACKAGE = "granttap-mcp@0.8.157";
10
+ const PACKAGE = "granttap-mcp@0.8.158";
11
11
  const dryRun = process.env.GRANTTAP_BOOTSTRAP_DRY_RUN === "1";
12
12
  const platform = dryRun && process.env.GRANTTAP_BOOTSTRAP_PLATFORM
13
13
  ? process.env.GRANTTAP_BOOTSTRAP_PLATFORM : process.platform;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "granttap-mcp",
3
- "version": "0.8.157",
3
+ "version": "0.8.158",
4
4
  "description": "Commercial computer runtime connecting local coding agents to GrantTap on Mac, iPhone, iPad and Apple Watch.",
5
5
  "type": "module",
6
6
  "bin": {