@scotthuang/agent-knock-knock 0.13.11 → 0.13.13
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/CHANGELOG.md +23 -0
- package/README.md +8 -9
- package/dist/src/codex-app-server-interaction-client.d.ts +72 -0
- package/dist/src/codex-app-server-interaction-client.js +311 -0
- package/dist/src/codex-app-server-interaction-client.js.map +1 -0
- package/dist/src/codex-app-server-questionnaire.d.ts +73 -0
- package/dist/src/codex-app-server-questionnaire.js +366 -0
- package/dist/src/codex-app-server-questionnaire.js.map +1 -0
- package/dist/src/codex-app-server-read-client.d.ts +118 -0
- package/dist/src/codex-app-server-read-client.js +300 -0
- package/dist/src/codex-app-server-read-client.js.map +1 -0
- package/dist/src/codex-app-server-transport.d.ts +11 -0
- package/dist/src/codex-app-server-transport.js +47 -0
- package/dist/src/codex-app-server-transport.js.map +1 -0
- package/dist/src/codex-async-question-adapter.d.ts +5 -0
- package/dist/src/codex-async-question-adapter.js +61 -17
- package/dist/src/codex-async-question-adapter.js.map +1 -1
- package/dist/src/codex-fullscreen-composer-proof.d.ts +23 -0
- package/dist/src/codex-fullscreen-composer-proof.js +125 -0
- package/dist/src/codex-fullscreen-composer-proof.js.map +1 -0
- package/dist/src/codex-lifecycle-compatibility.d.ts +5 -0
- package/dist/src/codex-lifecycle-compatibility.js +13 -1
- package/dist/src/codex-lifecycle-compatibility.js.map +1 -1
- package/dist/src/codex-paginated-answer-proof.d.ts +25 -0
- package/dist/src/codex-paginated-answer-proof.js +189 -0
- package/dist/src/codex-paginated-answer-proof.js.map +1 -0
- package/dist/src/codex-paginated-async-answer.d.ts +36 -0
- package/dist/src/codex-paginated-async-answer.js +322 -0
- package/dist/src/codex-paginated-async-answer.js.map +1 -0
- package/dist/src/codex-paginated-async-response.d.ts +21 -0
- package/dist/src/codex-paginated-async-response.js +118 -0
- package/dist/src/codex-paginated-async-response.js.map +1 -0
- package/dist/src/codex-paginated-observation.d.ts +30 -0
- package/dist/src/codex-paginated-observation.js +139 -0
- package/dist/src/codex-paginated-observation.js.map +1 -0
- package/dist/src/codex-paginated-questionnaire-runtime.d.ts +33 -0
- package/dist/src/codex-paginated-questionnaire-runtime.js +157 -0
- package/dist/src/codex-paginated-questionnaire-runtime.js.map +1 -0
- package/dist/src/codex-paginated-task.d.ts +78 -0
- package/dist/src/codex-paginated-task.js +441 -0
- package/dist/src/codex-paginated-task.js.map +1 -0
- package/dist/src/codex-paginated-thread-binding.d.ts +18 -0
- package/dist/src/codex-paginated-thread-binding.js +56 -0
- package/dist/src/codex-paginated-thread-binding.js.map +1 -0
- package/dist/src/codex-paginated-thread-facts.d.ts +11 -0
- package/dist/src/codex-paginated-thread-facts.js +2 -0
- package/dist/src/codex-paginated-thread-facts.js.map +1 -0
- package/dist/src/codex-paginated-watch.d.ts +29 -0
- package/dist/src/codex-paginated-watch.js +107 -0
- package/dist/src/codex-paginated-watch.js.map +1 -0
- package/dist/src/codex-terminal-agent-adapter.js +127 -7
- package/dist/src/codex-terminal-agent-adapter.js.map +1 -1
- package/dist/src/store.d.ts +1 -1
- package/dist/src/store.js +2 -2
- package/dist/src/store.js.map +1 -1
- package/dist/src/terminal-agent-adapter.d.ts +3 -0
- package/dist/src/terminal-agent-adapter.js.map +1 -1
- package/dist/src/terminal-agent-bridge.d.ts +13 -5
- package/dist/src/terminal-agent-bridge.js +28 -103
- package/dist/src/terminal-agent-bridge.js.map +1 -1
- package/dist/src/terminal-approval-fingerprint.d.ts +7 -0
- package/dist/src/terminal-approval-fingerprint.js +107 -0
- package/dist/src/terminal-approval-fingerprint.js.map +1 -0
- package/dist/src/terminal-command-cli-ports.d.ts +1 -0
- package/dist/src/terminal-composer-classifier.js +39 -1
- package/dist/src/terminal-composer-classifier.js.map +1 -1
- package/dist/src/terminal-control-provider.d.ts +6 -2
- package/dist/src/terminal-control-provider.js +4 -4
- package/dist/src/terminal-control-provider.js.map +1 -1
- package/dist/src/terminal-human-explicit-send-cli-adapter.js +22 -15
- package/dist/src/terminal-human-explicit-send-cli-adapter.js.map +1 -1
- package/dist/src/terminal-interaction-core.js +3 -1
- package/dist/src/terminal-interaction-core.js.map +1 -1
- package/dist/src/terminal-interaction-response-bridge.d.ts +21 -1
- package/dist/src/terminal-interaction-response-bridge.js +148 -3
- package/dist/src/terminal-interaction-response-bridge.js.map +1 -1
- package/dist/src/terminal-list-cli-adapter.js +4 -4
- package/dist/src/terminal-list-cli-adapter.js.map +1 -1
- package/dist/src/terminal-list-facts.d.ts +1 -1
- package/dist/src/terminal-list-facts.js +1 -1
- package/dist/src/terminal-list-facts.js.map +1 -1
- package/dist/src/terminal-managed-send-cli-adapter.d.ts +1 -1
- package/dist/src/terminal-managed-send-cli-adapter.js +27 -0
- package/dist/src/terminal-managed-send-cli-adapter.js.map +1 -1
- package/dist/src/terminal-model-control-bridge.d.ts +1 -1
- package/dist/src/terminal-model-control-bridge.js +1 -1
- package/dist/src/terminal-model-control-bridge.js.map +1 -1
- package/dist/src/terminal-model-control-profile.d.ts +3 -1
- package/dist/src/terminal-model-control-profile.js +47 -1
- package/dist/src/terminal-model-control-profile.js.map +1 -1
- package/dist/src/terminal-model-control.js +63 -21
- package/dist/src/terminal-model-control.js.map +1 -1
- package/dist/src/terminal-monitor-decision-policy.d.ts +1 -1
- package/dist/src/terminal-native-inspection-bridge.d.ts +6 -1
- package/dist/src/terminal-native-inspection-bridge.js +126 -79
- package/dist/src/terminal-native-inspection-bridge.js.map +1 -1
- package/dist/src/terminal-questionnaire-adapter.js +20 -16
- package/dist/src/terminal-questionnaire-adapter.js.map +1 -1
- package/dist/src/terminal-runtime-cli-adapter.js +17 -0
- package/dist/src/terminal-runtime-cli-adapter.js.map +1 -1
- package/dist/src/terminal-send-watch-policy.d.ts +38 -0
- package/dist/src/terminal-send-watch-policy.js +79 -0
- package/dist/src/terminal-send-watch-policy.js.map +1 -0
- package/dist/src/terminal-submission-facts.d.ts +1 -1
- package/dist/src/terminal-submission-facts.js +11 -9
- package/dist/src/terminal-submission-facts.js.map +1 -1
- package/dist/src/terminal-watch-cli-adapter.d.ts +9 -1
- package/dist/src/terminal-watch-cli-adapter.js +199 -210
- package/dist/src/terminal-watch-cli-adapter.js.map +1 -1
- package/dist/src/terminal-watch-codec.js +23 -1
- package/dist/src/terminal-watch-codec.js.map +1 -1
- package/dist/src/terminal-watch-interaction-runtime.js +27 -6
- package/dist/src/terminal-watch-interaction-runtime.js.map +1 -1
- package/dist/src/terminal-watch-presentation.d.ts +4 -0
- package/dist/src/terminal-watch-presentation.js +153 -0
- package/dist/src/terminal-watch-presentation.js.map +1 -0
- package/dist/src/terminal-watch-record.d.ts +4 -2
- package/dist/src/terminal-watch-record.js +15 -10
- package/dist/src/terminal-watch-record.js.map +1 -1
- package/dist/src/terminal-watch-service.js +13 -1
- package/dist/src/terminal-watch-service.js.map +1 -1
- package/docs/codex-0.158.0-compatibility.md +129 -0
- package/docs/codex-0.159.0-compatibility.md +150 -0
- package/docs/quickstart-herdr.md +3 -3
- package/docs/quickstart-tmux.md +5 -5
- package/package.json +7 -3
- package/templates/openclaw-skills/agent-knock-knock/SKILL.md +14 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.13.13 - 2026-09-30
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- Extend the paginated task adapter to Codex 0.159.0 for physical Send, exact task Watch, native questions and answer receipts, and completion callbacks.
|
|
8
|
+
- Preserve existing string-cursor pagination while accepting 0.159.0 as an independently checked client/backend version.
|
|
9
|
+
- Keep the existing 0.158.0 support and the documented 0.157.x limitations. Store writer protocol remains 8 and Terminal Watch schema remains 3.
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- Parse Codex 0.159.0 borderless native status output and wrapped fields while retaining exact fresh-card, session, and Composer checks. Separate native activity (including Thinking, Waiting, Compacting, and dynamic headers) and queued-question regions from the status card so active Watch binding and question-answer identity checks can complete. Display text remains outside task identity evidence.
|
|
14
|
+
|
|
15
|
+
## 0.13.12 - 2026-09-29
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- Track Codex 0.158.0 ordinary terminal Send and active-task Watch through exact foreground thread binding and native paginated history, including completion after terminal exit and callback retries.
|
|
20
|
+
- Preserve native Plan-mode result text in completion callbacks and verify the real styled Composer before answering async questions.
|
|
21
|
+
- Recognize current async question identities and submit answers only to the expected active native turn, confirming the exact durable reply. Handle blocking native question requests and private multi-question drafts through the server's single-response protocol.
|
|
22
|
+
- Route paginated Send away from the legacy future-rollout monitor before task input. Keep callback receipts explicit about exact versus activity-only observation.
|
|
23
|
+
- Use native bracketed paste for Codex 0.158.0 tmux physical Send so a long single-line request cannot leave its Enter inside the native character-paste burst.
|
|
24
|
+
- Adapt 0.158.0 fullscreen status, Composer, command menus, async navigation, and model/effort selection. Bump store writer protocol to 8 so older writers cannot overwrite new task and questionnaire state.
|
|
25
|
+
|
|
3
26
|
## 0.13.11 - 2026-09-29
|
|
4
27
|
|
|
5
28
|
### Fixed
|
package/README.md
CHANGED
|
@@ -76,13 +76,12 @@ Open a Web conversation and enter `/akk list`. The connector gives every convers
|
|
|
76
76
|
|
|
77
77
|
Suppose several Codex or Claude Code jobs are already running in tmux or Herdr:
|
|
78
78
|
|
|
79
|
-
Codex CLI 0.
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
the [compatibility review](docs/codex-0.157.1-compatibility.md).
|
|
79
|
+
Codex CLI 0.158.0/0.159.0 supports exact paginated task Watches for ordinary terminal
|
|
80
|
+
Send, native question responses, and durable completion callbacks. The adapter
|
|
81
|
+
checks the foreground thread and server version before attaching; uncertain
|
|
82
|
+
answers are never automatically replayed. See the [0.158.0/0.159.0 compatibility
|
|
83
|
+
review](docs/codex-0.159.0-compatibility.md) for managed-session and already-open
|
|
84
|
+
question boundaries. Codex 0.157.x retains its [partial compatibility](docs/codex-0.157.1-compatibility.md).
|
|
86
85
|
|
|
87
86
|
- **Watch without babysitting.** `/akk watch <terminal>` observes work already in progress and sends a callback when it finishes, needs approval, or becomes blocked. You can leave the terminal and continue from your phone or another chat client.
|
|
88
87
|
- **Send without typing in a tiny remote console.** `/akk <selector>: <message>` sends your natural-language instruction to the selected live coding-agent terminal. An explicit user Send has priority over stale AKK management state.
|
|
@@ -129,7 +128,7 @@ OpenClaw / Pi / DeepSeek Harness
|
|
|
129
128
|
Codex / Claude Code
|
|
130
129
|
```
|
|
131
130
|
|
|
132
|
-
For a managed Send, AKK verifies the selected terminal and coding-agent process, writes one user request, monitors that exact Turn, and returns completion or attention callbacks to the initiating Host session. If stale AKK bookkeeping blocks an explicit Codex Send before terminal input, AKK can fall back to a verified one-time physical Send and attach a
|
|
131
|
+
For a managed Send, AKK verifies the selected terminal and coding-agent process, writes one user request, monitors that exact Turn, and returns completion or attention callbacks to the initiating Host session. If stale AKK bookkeeping blocks an explicit Codex Send before terminal input, AKK can fall back to a verified one-time physical Send and attach a task Watch for callback and Status recovery.
|
|
133
132
|
|
|
134
133
|
Native Pi and DeepSeek Harness connectors accept the shared catalog through a
|
|
135
134
|
versioned, secretless Host Adapter capability handshake. Startup verifies the
|
|
@@ -138,7 +137,7 @@ Skill SHA-256 digests; an older, missing, or drifted handshake fails closed
|
|
|
138
137
|
instead of mounting a partial tool surface. Connector package versions remain
|
|
139
138
|
independent of one another.
|
|
140
139
|
|
|
141
|
-
In the current OpenClaw plugin and core Host Adapter, an idle Codex pane with ambiguous foreground rollout identity may advertise `identify_foreground`. That action issues one closed `/status` command to the exact pane. It does not mutate the AKK Store, but it does type into the visible terminal. Its 30-second result is diagnostic only and grants no later authority. The separate `identify_and_send` action keeps one terminal lock across the probe and one requested task, then relies on exact request acceptance—not the status card—for durable Session and Turn identity.
|
|
140
|
+
In the current OpenClaw plugin and core Host Adapter, an idle Codex pane with ambiguous foreground rollout identity may advertise `identify_foreground`. That action issues one closed `/status` command to the exact pane. It does not mutate the AKK Store, but it does type into the visible terminal. Its 30-second result is diagnostic only and grants no later authority. The separate `identify_and_send` action keeps one terminal lock across the probe and one requested task, then relies on exact request acceptance—not the status card—for durable Session and Turn identity. List and Status never run this probe. Codex 0.158.0/0.159.0 exact Send and active-task Watch use a separate closed `/status` transaction to bind the foreground paginated thread; subsequent observation is read-only.
|
|
142
141
|
|
|
143
142
|
AKK is local-first: there is no hosted control plane or telemetry. It stores only the local state needed for routing, lifecycle recovery, callback delivery, and idempotency.
|
|
144
143
|
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { type CodexAppServerMetadata, type CodexAppServerReadTransport } from "./codex-app-server-read-client.js";
|
|
2
|
+
import type { CodexPaginatedThreadBinding } from "./codex-paginated-thread-facts.js";
|
|
3
|
+
import { captureCodexPaginatedAnswerProof, readCodexPaginatedAnswerProof } from "./codex-paginated-answer-proof.js";
|
|
4
|
+
export interface CodexAppServerInputQuestion {
|
|
5
|
+
id: string;
|
|
6
|
+
header: string;
|
|
7
|
+
question: string;
|
|
8
|
+
isOther: boolean;
|
|
9
|
+
isSecret: boolean;
|
|
10
|
+
options: {
|
|
11
|
+
label: string;
|
|
12
|
+
description: string;
|
|
13
|
+
}[] | null;
|
|
14
|
+
}
|
|
15
|
+
export interface CodexAppServerPendingQuestion {
|
|
16
|
+
requestId: string | number;
|
|
17
|
+
threadId: string;
|
|
18
|
+
turnId: string;
|
|
19
|
+
itemId: string;
|
|
20
|
+
questions: CodexAppServerInputQuestion[];
|
|
21
|
+
isBlocking: boolean;
|
|
22
|
+
}
|
|
23
|
+
export type CodexAppServerQuestionAnswers = Record<string, {
|
|
24
|
+
answers: string[];
|
|
25
|
+
}>;
|
|
26
|
+
export interface CodexAppServerAnswerResult {
|
|
27
|
+
status: "confirmed" | "response_uncertain";
|
|
28
|
+
requestId: string | number;
|
|
29
|
+
itemId: string;
|
|
30
|
+
reason?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface CodexAppServerInteractionOptions {
|
|
33
|
+
binding: CodexPaginatedThreadBinding;
|
|
34
|
+
nativeTurnId: string;
|
|
35
|
+
timeoutMs?: number;
|
|
36
|
+
transportFactory?: (options: {
|
|
37
|
+
socketPath: string;
|
|
38
|
+
timeoutMs: number;
|
|
39
|
+
}) => Promise<CodexAppServerReadTransport>;
|
|
40
|
+
sleep?: (milliseconds: number) => Promise<void>;
|
|
41
|
+
captureAnswerProof?: typeof captureCodexPaginatedAnswerProof;
|
|
42
|
+
readAnswerProof?: typeof readCodexPaginatedAnswerProof;
|
|
43
|
+
}
|
|
44
|
+
/** Scoped question handling. This client cannot start, steer, stop, or configure turns. */
|
|
45
|
+
export declare class CodexAppServerInteractionClient {
|
|
46
|
+
private readonly transport;
|
|
47
|
+
private readonly options;
|
|
48
|
+
private readonly timeoutMs;
|
|
49
|
+
readonly metadata: CodexAppServerMetadata;
|
|
50
|
+
private readonly requests;
|
|
51
|
+
private readonly questions;
|
|
52
|
+
private readonly sentAnswers;
|
|
53
|
+
private readonly resolvedRequests;
|
|
54
|
+
private readonly unsubscribe;
|
|
55
|
+
private nextId;
|
|
56
|
+
private closed;
|
|
57
|
+
private attached;
|
|
58
|
+
private rolloutPath?;
|
|
59
|
+
private constructor();
|
|
60
|
+
static connect(options: CodexAppServerInteractionOptions): Promise<CodexAppServerInteractionClient>;
|
|
61
|
+
listPendingQuestions(): readonly CodexAppServerPendingQuestion[];
|
|
62
|
+
answer(requestId: string | number, answers: CodexAppServerQuestionAnswers): Promise<CodexAppServerAnswerResult>;
|
|
63
|
+
close(): Promise<void>;
|
|
64
|
+
private verifyActiveQuestionTurn;
|
|
65
|
+
private assertNativeThread;
|
|
66
|
+
private confirmAnswer;
|
|
67
|
+
private request;
|
|
68
|
+
private receive;
|
|
69
|
+
private captureQuestion;
|
|
70
|
+
private finish;
|
|
71
|
+
}
|
|
72
|
+
export declare const connectCodexAppServerInteractionClient: typeof CodexAppServerInteractionClient.connect;
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { isCodexPaginatedVersion } from "./codex-lifecycle-compatibility.js";
|
|
3
|
+
import { CodexAppServerReadError, parseCodexAppServerMetadata } from "./codex-app-server-read-client.js";
|
|
4
|
+
import { connectCodexUnixWebSocket } from "./codex-app-server-transport.js";
|
|
5
|
+
import { captureCodexPaginatedAnswerProof, readCodexPaginatedAnswerProof, CodexPaginatedAnswerProofInvalidatedError } from "./codex-paginated-answer-proof.js";
|
|
6
|
+
/** Scoped question handling. This client cannot start, steer, stop, or configure turns. */
|
|
7
|
+
export class CodexAppServerInteractionClient {
|
|
8
|
+
transport;
|
|
9
|
+
options;
|
|
10
|
+
timeoutMs;
|
|
11
|
+
metadata;
|
|
12
|
+
requests = new Map();
|
|
13
|
+
questions = new Map();
|
|
14
|
+
sentAnswers = new Set();
|
|
15
|
+
resolvedRequests = new Set();
|
|
16
|
+
unsubscribe;
|
|
17
|
+
nextId = 1;
|
|
18
|
+
closed = false;
|
|
19
|
+
attached = false;
|
|
20
|
+
rolloutPath;
|
|
21
|
+
constructor(transport, options, timeoutMs, metadata) {
|
|
22
|
+
this.transport = transport;
|
|
23
|
+
this.options = options;
|
|
24
|
+
this.timeoutMs = timeoutMs;
|
|
25
|
+
this.metadata = metadata;
|
|
26
|
+
this.unsubscribe = [
|
|
27
|
+
transport.onMessage((text) => this.receive(text)),
|
|
28
|
+
transport.onDisconnect((error) => this.finish(error))
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
static async connect(options) {
|
|
32
|
+
if (!isCodexPaginatedVersion(options.binding.serverVersion) || !path.isAbsolute(options.binding.codexHome))
|
|
33
|
+
throw new Error("Native Codex question binding is unsupported");
|
|
34
|
+
identifier(options.binding.threadId);
|
|
35
|
+
identifier(options.nativeTurnId);
|
|
36
|
+
const timeoutMs = options.timeoutMs ?? 5_000;
|
|
37
|
+
if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > 30_000)
|
|
38
|
+
throw new Error("Codex question timeout is invalid");
|
|
39
|
+
const socketPath = path.join(options.binding.codexHome, "app-server-control", "app-server-control.sock");
|
|
40
|
+
const transport = await (options.transportFactory ?? connectCodexUnixWebSocket)({ socketPath, timeoutMs });
|
|
41
|
+
const metadata = { socketPath, codexHome: "", serverVersion: "", platformFamily: "", platformOs: "" };
|
|
42
|
+
const client = new CodexAppServerInteractionClient(transport, options, timeoutMs, metadata);
|
|
43
|
+
try {
|
|
44
|
+
// Resume updates future client identity. Preserve the native TUI identity so hooks,
|
|
45
|
+
// plugin prompts and MCP policy retain their existing Codex terminal behavior.
|
|
46
|
+
const initialized = await client.request("initialize", {
|
|
47
|
+
clientInfo: { name: "codex-tui", title: "AKK native question bridge", version: options.binding.serverVersion },
|
|
48
|
+
capabilities: { experimentalApi: true }
|
|
49
|
+
});
|
|
50
|
+
Object.assign(metadata, parseCodexAppServerMetadata(initialized, {
|
|
51
|
+
codexHome: options.binding.codexHome, expectedServerVersion: options.binding.serverVersion
|
|
52
|
+
}, socketPath));
|
|
53
|
+
transport.send(JSON.stringify({ method: "initialized" }));
|
|
54
|
+
await client.verifyActiveQuestionTurn();
|
|
55
|
+
const resumed = object(await client.request("thread/resume", {
|
|
56
|
+
threadId: options.binding.threadId, excludeTurns: true
|
|
57
|
+
}));
|
|
58
|
+
client.assertNativeThread(resumed.thread, true);
|
|
59
|
+
client.attached = true;
|
|
60
|
+
// Serialized metadata read is a barrier after resume's pending-request replay.
|
|
61
|
+
await client.verifyActiveQuestionTurn();
|
|
62
|
+
return client;
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
await client.close();
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
listPendingQuestions() {
|
|
70
|
+
return [...this.questions.values()].filter((question) => !this.sentAnswers.has(question.requestId))
|
|
71
|
+
.map((question) => structuredClone(question));
|
|
72
|
+
}
|
|
73
|
+
async answer(requestId, answers) {
|
|
74
|
+
if (this.sentAnswers.has(requestId))
|
|
75
|
+
throw new Error("Codex question response was already sent; it cannot be retried");
|
|
76
|
+
const question = this.questions.get(requestId);
|
|
77
|
+
if (!question || this.closed)
|
|
78
|
+
throw new Error("The exact Codex question is no longer pending");
|
|
79
|
+
const exactAnswers = structuredClone(answers);
|
|
80
|
+
validateAnswers(question, exactAnswers);
|
|
81
|
+
await this.verifyActiveQuestionTurn();
|
|
82
|
+
if (this.sentAnswers.has(requestId))
|
|
83
|
+
throw new Error("Codex question response was already sent; it cannot be retried");
|
|
84
|
+
if (this.questions.get(requestId) !== question || this.resolvedRequests.has(requestId))
|
|
85
|
+
throw new Error("The exact Codex question was resolved before answering");
|
|
86
|
+
let proof;
|
|
87
|
+
try {
|
|
88
|
+
if (this.rolloutPath)
|
|
89
|
+
proof = (this.options.captureAnswerProof ?? captureCodexPaginatedAnswerProof)({
|
|
90
|
+
codexHome: this.metadata.codexHome, rolloutPath: this.rolloutPath,
|
|
91
|
+
threadId: question.threadId, turnId: question.turnId, itemId: question.itemId
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
if (error instanceof CodexPaginatedAnswerProofInvalidatedError)
|
|
96
|
+
throw error;
|
|
97
|
+
// Inaccessible proof can only yield uncertain delivery after a single response write.
|
|
98
|
+
}
|
|
99
|
+
this.sentAnswers.add(requestId);
|
|
100
|
+
try {
|
|
101
|
+
// This is the only response write. Mark it sent before transport delivery is attempted.
|
|
102
|
+
this.transport.send(JSON.stringify({ id: requestId, result: { answers: exactAnswers } }));
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
return { status: "response_uncertain", requestId, itemId: question.itemId, reason: "question_response_delivery_uncertain" };
|
|
106
|
+
}
|
|
107
|
+
return this.confirmAnswer(question, exactAnswers, proof);
|
|
108
|
+
}
|
|
109
|
+
async close() {
|
|
110
|
+
try {
|
|
111
|
+
if (this.attached && !this.closed)
|
|
112
|
+
await this.request("thread/unsubscribe", { threadId: this.options.binding.threadId });
|
|
113
|
+
}
|
|
114
|
+
catch { /* Disconnect still removes only this client's subscription. */ }
|
|
115
|
+
this.finish(new Error("Codex question connection closed"));
|
|
116
|
+
this.transport.close();
|
|
117
|
+
}
|
|
118
|
+
async verifyActiveQuestionTurn() {
|
|
119
|
+
const read = object(await this.request("thread/read", { threadId: this.options.binding.threadId, includeTurns: false }));
|
|
120
|
+
this.assertNativeThread(read.thread, true);
|
|
121
|
+
const page = object(await this.request("thread/turns/list", {
|
|
122
|
+
threadId: this.options.binding.threadId, limit: 2, sortDirection: "desc", itemsView: "notLoaded"
|
|
123
|
+
}));
|
|
124
|
+
if (!Array.isArray(page.data) || page.data.length === 0)
|
|
125
|
+
throw new Error("Codex question's current turn is unavailable");
|
|
126
|
+
const latest = object(page.data[0]);
|
|
127
|
+
if (latest.id !== this.options.nativeTurnId || latest.status !== "inProgress" ||
|
|
128
|
+
page.data.slice(1).some((turn) => object(turn).status === "inProgress"))
|
|
129
|
+
throw new Error("Codex question's exact active turn changed");
|
|
130
|
+
}
|
|
131
|
+
assertNativeThread(value, requireWaiting) {
|
|
132
|
+
const thread = object(value);
|
|
133
|
+
const status = object(thread.status);
|
|
134
|
+
if (thread.id !== this.options.binding.threadId || thread.historyMode !== "paginated" || thread.originator !== "codex-tui")
|
|
135
|
+
throw new Error("Codex question's native thread identity changed");
|
|
136
|
+
if (status.type !== "active" || (requireWaiting && (!Array.isArray(status.activeFlags) || !status.activeFlags.includes("waitingOnUserInput"))))
|
|
137
|
+
throw new Error("Codex question's thread is not loaded and waiting on user input");
|
|
138
|
+
this.rolloutPath = typeof thread.path === "string" ? thread.path : undefined;
|
|
139
|
+
}
|
|
140
|
+
async confirmAnswer(question, answers, proof) {
|
|
141
|
+
const result = { requestId: question.requestId, itemId: question.itemId };
|
|
142
|
+
if (!proof)
|
|
143
|
+
return { ...result, status: "response_uncertain", reason: "canonical_question_answer_evidence_unavailable" };
|
|
144
|
+
const sleep = this.options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
145
|
+
const deadline = Date.now() + this.timeoutMs;
|
|
146
|
+
do {
|
|
147
|
+
try {
|
|
148
|
+
const observed = (this.options.readAnswerProof ?? readCodexPaginatedAnswerProof)(proof, answers);
|
|
149
|
+
if (observed === "matched")
|
|
150
|
+
return { ...result, status: "confirmed" };
|
|
151
|
+
if (observed === "different")
|
|
152
|
+
return { ...result, status: "response_uncertain", reason: "another_question_answer_won" };
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
return { ...result, status: "response_uncertain", reason: "canonical_question_answer_evidence_changed" };
|
|
156
|
+
}
|
|
157
|
+
if (this.closed)
|
|
158
|
+
break;
|
|
159
|
+
await sleep(100);
|
|
160
|
+
} while (Date.now() < deadline);
|
|
161
|
+
return { ...result, status: "response_uncertain", reason: "canonical_question_answer_evidence_pending" };
|
|
162
|
+
}
|
|
163
|
+
request(method, params) {
|
|
164
|
+
if (this.closed)
|
|
165
|
+
return Promise.reject(new Error("Codex question connection is closed"));
|
|
166
|
+
if (this.requests.size >= 16)
|
|
167
|
+
return Promise.reject(new Error("Too many scoped Codex question operations"));
|
|
168
|
+
const id = `akk-question-${this.nextId++}`;
|
|
169
|
+
return new Promise((resolve, reject) => {
|
|
170
|
+
const timer = setTimeout(() => {
|
|
171
|
+
this.requests.delete(id);
|
|
172
|
+
reject(new CodexAppServerReadError("timeout", `Codex question ${method} timed out`));
|
|
173
|
+
}, this.timeoutMs);
|
|
174
|
+
this.requests.set(id, { resolve, reject, timer });
|
|
175
|
+
try {
|
|
176
|
+
this.transport.send(JSON.stringify({ id, method, params }));
|
|
177
|
+
}
|
|
178
|
+
catch (error) {
|
|
179
|
+
this.requests.delete(id);
|
|
180
|
+
clearTimeout(timer);
|
|
181
|
+
reject(error);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
receive(text) {
|
|
186
|
+
try {
|
|
187
|
+
if (Buffer.byteLength(text) > 8 * 1024 * 1024)
|
|
188
|
+
throw new Error("Codex question message exceeded its bound");
|
|
189
|
+
const message = object(JSON.parse(text));
|
|
190
|
+
if (message.method === "item/tool/requestUserInput") {
|
|
191
|
+
this.captureQuestion(message);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
if (message.method === "serverRequest/resolved") {
|
|
195
|
+
const params = object(message.params);
|
|
196
|
+
if (params.threadId === this.options.binding.threadId && validRequestId(params.requestId)) {
|
|
197
|
+
this.questions.delete(params.requestId);
|
|
198
|
+
this.resolvedRequests.add(params.requestId);
|
|
199
|
+
if (this.resolvedRequests.size > 128)
|
|
200
|
+
throw new Error("Too many Codex question resolution notifications");
|
|
201
|
+
}
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
if (message.method !== undefined || typeof message.id !== "string")
|
|
205
|
+
return;
|
|
206
|
+
const pending = this.requests.get(message.id);
|
|
207
|
+
if (!pending)
|
|
208
|
+
return;
|
|
209
|
+
this.requests.delete(message.id);
|
|
210
|
+
clearTimeout(pending.timer);
|
|
211
|
+
if (message.error !== undefined) {
|
|
212
|
+
const error = object(message.error);
|
|
213
|
+
pending.reject(new CodexAppServerReadError("rpc_error", "Scoped Codex question operation was rejected", typeof error.code === "number" ? error.code : undefined));
|
|
214
|
+
}
|
|
215
|
+
else if (Object.hasOwn(message, "result"))
|
|
216
|
+
pending.resolve(message.result);
|
|
217
|
+
else
|
|
218
|
+
pending.reject(new Error("Codex question operation omitted its result"));
|
|
219
|
+
}
|
|
220
|
+
catch (error) {
|
|
221
|
+
this.finish(error instanceof Error ? error : new Error("Invalid Codex question message"));
|
|
222
|
+
this.transport.close();
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
captureQuestion(message) {
|
|
226
|
+
const params = object(message.params);
|
|
227
|
+
if (params.threadId !== this.options.binding.threadId || params.turnId !== this.options.nativeTurnId)
|
|
228
|
+
return;
|
|
229
|
+
if (!validRequestId(message.id) || this.resolvedRequests.has(message.id))
|
|
230
|
+
return;
|
|
231
|
+
if (this.questions.size >= 16 && !this.questions.has(message.id))
|
|
232
|
+
throw new Error("Too many pending Codex questions");
|
|
233
|
+
identifier(params.itemId);
|
|
234
|
+
if (!Array.isArray(params.questions) || params.questions.length === 0 || params.questions.length > 16)
|
|
235
|
+
throw new Error("Codex question batch is invalid");
|
|
236
|
+
const questions = params.questions.map(parseQuestion);
|
|
237
|
+
if (new Set(questions.map((question) => question.id)).size !== questions.length)
|
|
238
|
+
throw new Error("Codex question IDs are duplicated");
|
|
239
|
+
if (params.isBlocking !== undefined && typeof params.isBlocking !== "boolean")
|
|
240
|
+
throw new Error("Codex question blocking flag is invalid");
|
|
241
|
+
const question = {
|
|
242
|
+
requestId: message.id, threadId: params.threadId, turnId: params.turnId,
|
|
243
|
+
itemId: params.itemId, questions, isBlocking: params.isBlocking === undefined ? true : params.isBlocking
|
|
244
|
+
};
|
|
245
|
+
const previous = this.questions.get(message.id);
|
|
246
|
+
if (previous && JSON.stringify(previous) !== JSON.stringify(question))
|
|
247
|
+
throw new Error("Codex pending question changed under the same request ID");
|
|
248
|
+
if (!previous)
|
|
249
|
+
this.questions.set(message.id, question);
|
|
250
|
+
}
|
|
251
|
+
finish(error) {
|
|
252
|
+
this.closed = true;
|
|
253
|
+
for (const pending of this.requests.values()) {
|
|
254
|
+
clearTimeout(pending.timer);
|
|
255
|
+
pending.reject(error);
|
|
256
|
+
}
|
|
257
|
+
this.requests.clear();
|
|
258
|
+
this.questions.clear();
|
|
259
|
+
this.unsubscribe.forEach((unsubscribe) => unsubscribe());
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
export const connectCodexAppServerInteractionClient = CodexAppServerInteractionClient.connect;
|
|
263
|
+
function parseQuestion(value) {
|
|
264
|
+
const question = object(value);
|
|
265
|
+
identifier(question.id);
|
|
266
|
+
for (const field of ["header", "question"])
|
|
267
|
+
if (typeof question[field] !== "string" || question[field].length > 64 * 1024)
|
|
268
|
+
throw new Error("Codex native question text is invalid");
|
|
269
|
+
for (const field of ["isOther", "isSecret"])
|
|
270
|
+
if (question[field] !== undefined && typeof question[field] !== "boolean")
|
|
271
|
+
throw new Error("Codex native question flag is invalid");
|
|
272
|
+
const options = question.options == null ? null : question.options;
|
|
273
|
+
if (options !== null && (!Array.isArray(options) || options.length > 32))
|
|
274
|
+
throw new Error("Codex question options exceeded their bound");
|
|
275
|
+
return {
|
|
276
|
+
id: question.id, header: question.header, question: question.question,
|
|
277
|
+
isOther: question.isOther === true, isSecret: question.isSecret === true,
|
|
278
|
+
options: options === null ? null : options.map((value) => {
|
|
279
|
+
const option = object(value);
|
|
280
|
+
if (typeof option.label !== "string" || typeof option.description !== "string" || option.label.length > 512 || option.description.length > 64 * 1024)
|
|
281
|
+
throw new Error("Codex question option is invalid");
|
|
282
|
+
return { label: option.label, description: option.description };
|
|
283
|
+
})
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
function validateAnswers(question, value) {
|
|
287
|
+
const answers = object(value);
|
|
288
|
+
const ids = question.questions.map((question) => question.id).sort();
|
|
289
|
+
if (JSON.stringify(Object.keys(answers).sort()) !== JSON.stringify(ids))
|
|
290
|
+
throw new Error("Codex response must answer the exact full question batch");
|
|
291
|
+
for (const id of ids) {
|
|
292
|
+
const answer = object(answers[id]);
|
|
293
|
+
if (Object.keys(answer).length !== 1 || !Array.isArray(answer.answers) || answer.answers.length === 0 || answer.answers.length > 32 ||
|
|
294
|
+
answer.answers.some((value) => typeof value !== "string" || value.length === 0 || value.length > 64 * 1024))
|
|
295
|
+
throw new Error("Codex question answer is invalid");
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
function identifier(value) {
|
|
299
|
+
if (typeof value !== "string" || value.length === 0 || value.length > 512 || /[\u0000-\u001f\u007f]/u.test(value))
|
|
300
|
+
throw new Error("Codex question identity is invalid");
|
|
301
|
+
return value;
|
|
302
|
+
}
|
|
303
|
+
function validRequestId(value) {
|
|
304
|
+
return typeof value === "string" ? value.length > 0 && value.length <= 512 && !/[\u0000-\u001f\u007f]/u.test(value) : Number.isSafeInteger(value) && Number(value) >= 0;
|
|
305
|
+
}
|
|
306
|
+
function object(value) {
|
|
307
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
308
|
+
throw new Error("Invalid Codex question protocol object");
|
|
309
|
+
return value;
|
|
310
|
+
}
|
|
311
|
+
//# sourceMappingURL=codex-app-server-interaction-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-app-server-interaction-client.js","sourceRoot":"","sources":["../../src/codex-app-server-interaction-client.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EACL,uBAAuB,EACvB,2BAA2B,EAG5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAE5E,OAAO,EACL,gCAAgC,EAChC,6BAA6B,EAC7B,yCAAyC,EAE1C,MAAM,mCAAmC,CAAC;AAqC3C,2FAA2F;AAC3F,MAAM,OAAO,+BAA+B;IAavB,SAAS;IACT,OAAO;IACP,SAAS;IAdnB,QAAQ,CAAyB;IACzB,QAAQ,GAAG,IAAI,GAAG,EAAsB,CAAC;IACzC,SAAS,GAAG,IAAI,GAAG,EAAkD,CAAC;IACtE,WAAW,GAAG,IAAI,GAAG,EAAmB,CAAC;IACzC,gBAAgB,GAAG,IAAI,GAAG,EAAmB,CAAC;IAC9C,WAAW,CAAiB;IACrC,MAAM,GAAG,CAAC,CAAC;IACX,MAAM,GAAG,KAAK,CAAC;IACf,QAAQ,GAAG,KAAK,CAAC;IACjB,WAAW,CAAU;IAE7B,YACmB,SAAsC,EACtC,OAAyC,EACzC,SAAiB,EAClC,QAAgC;yBAHf,SAAS;uBACT,OAAO;yBACP,SAAS;QAG1B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,WAAW,G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,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC3H,OAAO,KAAgC,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { CodexAppServerPendingQuestion, CodexAppServerQuestionAnswers } from "./codex-app-server-interaction-client.js";
|
|
2
|
+
import { type TerminalInteractionSubject, type TerminalInteractionSubjectProjection } from "./terminal-interaction-protocol.js";
|
|
3
|
+
/** Owner-private: store only in the protected Watch checkpoint, never callbacks. */
|
|
4
|
+
export interface CodexBlockingQuestionDraft {
|
|
5
|
+
threadId: string;
|
|
6
|
+
turnId: string;
|
|
7
|
+
itemId: string;
|
|
8
|
+
requestId: string | number;
|
|
9
|
+
stablePayloadFingerprint: string;
|
|
10
|
+
answers: CodexAppServerQuestionAnswers;
|
|
11
|
+
nextQuestionIndex: number;
|
|
12
|
+
}
|
|
13
|
+
/** Only projection is public; native identifiers and draft material stay private. */
|
|
14
|
+
export interface CodexAppServerQuestionnaireOffer {
|
|
15
|
+
projection: TerminalInteractionSubjectProjection;
|
|
16
|
+
promptFingerprint: string;
|
|
17
|
+
surfaceId: string;
|
|
18
|
+
payloadFingerprint: string;
|
|
19
|
+
questionIndex: number;
|
|
20
|
+
nativeQuestionId: string;
|
|
21
|
+
}
|
|
22
|
+
export interface BuildCodexAppServerQuestionnaireOfferInput {
|
|
23
|
+
pending: CodexAppServerPendingQuestion;
|
|
24
|
+
subject: TerminalInteractionSubject;
|
|
25
|
+
canonicalEndpointIdentity: unknown;
|
|
26
|
+
draft?: CodexBlockingQuestionDraft;
|
|
27
|
+
now: Date;
|
|
28
|
+
ttlMs?: number;
|
|
29
|
+
expiresAt?: string;
|
|
30
|
+
responseUncertain?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export type CodexAppServerQuestionnaireOfferResult = {
|
|
33
|
+
status: "ready";
|
|
34
|
+
offer: CodexAppServerQuestionnaireOffer;
|
|
35
|
+
} | {
|
|
36
|
+
status: "manual_required";
|
|
37
|
+
offer: CodexAppServerQuestionnaireOffer;
|
|
38
|
+
reason: string;
|
|
39
|
+
} | {
|
|
40
|
+
status: "invalidated";
|
|
41
|
+
reason: string;
|
|
42
|
+
};
|
|
43
|
+
export type CodexAppServerQuestionnaireAnswerResult = {
|
|
44
|
+
status: "advance";
|
|
45
|
+
draft: CodexBlockingQuestionDraft;
|
|
46
|
+
} | {
|
|
47
|
+
status: "ready";
|
|
48
|
+
requestId: string | number;
|
|
49
|
+
answers: CodexAppServerQuestionAnswers;
|
|
50
|
+
} | {
|
|
51
|
+
status: "invalidated";
|
|
52
|
+
reason: string;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Build from the real native RPC payload. No terminal keys, screen coordinates,
|
|
56
|
+
* or synthetic UI action plans are produced by this adapter.
|
|
57
|
+
*/
|
|
58
|
+
export declare function buildCodexAppServerQuestionnaireOffer(input: BuildCodexAppServerQuestionnaireOfferInput): CodexAppServerQuestionnaireOfferResult;
|
|
59
|
+
/**
|
|
60
|
+
* Advance only private state until every native question has an answer. The
|
|
61
|
+
* caller reserves the displayed offer, persists an advance, then consumes it.
|
|
62
|
+
* Only a ready result may be passed to the native client's single RPC write.
|
|
63
|
+
*/
|
|
64
|
+
export declare function accumulateCodexAppServerQuestionnaireAnswer(input: {
|
|
65
|
+
pending: CodexAppServerPendingQuestion;
|
|
66
|
+
offer: CodexAppServerQuestionnaireOffer;
|
|
67
|
+
canonicalEndpointIdentity: unknown;
|
|
68
|
+
response: unknown;
|
|
69
|
+
draft?: CodexBlockingQuestionDraft;
|
|
70
|
+
now: Date;
|
|
71
|
+
}): CodexAppServerQuestionnaireAnswerResult;
|
|
72
|
+
/** Shape-only durable validation; an offer also rebinds it to the live payload. */
|
|
73
|
+
export declare function validateCodexBlockingQuestionDraft(value: unknown): CodexBlockingQuestionDraft;
|