ai4ai 0.0.3 → 0.0.5
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/README.md +6 -0
- package/README.zh-CN.md +6 -0
- package/claude-plugin/.claude-plugin/plugin.json +1 -1
- package/claude-plugin/dist/adapters/claude/adapter.d.ts +10 -1
- package/claude-plugin/dist/adapters/claude/adapter.js +35 -10
- package/claude-plugin/dist/adapters/claude/journal.d.ts +8 -0
- package/claude-plugin/dist/adapters/claude/journal.js +4 -1
- package/claude-plugin/dist/adapters/claude/plugin.js +198 -91
- package/claude-plugin/dist/adapters/claude/worker.js +30 -8
- package/claude-plugin/dist/adapters/codex/adapter.d.ts +26 -19
- package/claude-plugin/dist/adapters/codex/adapter.js +283 -187
- package/claude-plugin/dist/adapters/codex/app-server.js +1 -1
- package/claude-plugin/dist/adapters/codex/control.d.ts +36 -1
- package/claude-plugin/dist/adapters/codex/control.js +74 -4
- package/claude-plugin/dist/adapters/codex/native-handoff.d.ts +60 -0
- package/claude-plugin/dist/adapters/codex/native-handoff.js +138 -0
- package/claude-plugin/dist/adapters/codex/runner.js +35 -32
- package/claude-plugin/dist/adapters/codex/tui-daemon-watch.js +60 -49
- package/claude-plugin/dist/adapters/declarations.d.ts +0 -1
- package/claude-plugin/dist/adapters/declarations.js +0 -1
- package/claude-plugin/dist/adapters/dsh/adapter.d.ts +39 -2
- package/claude-plugin/dist/adapters/dsh/adapter.js +164 -37
- package/claude-plugin/dist/adapters/dsh/plugin.d.ts +3 -1
- package/claude-plugin/dist/adapters/dsh/plugin.js +33 -22
- package/claude-plugin/dist/adapters/executors.d.ts +25 -2
- package/claude-plugin/dist/adapters/executors.js +58 -4
- package/claude-plugin/dist/adapters/external.d.ts +21 -0
- package/claude-plugin/dist/adapters/external.js +128 -18
- package/claude-plugin/dist/adapters/opencode/adapter.d.ts +13 -2
- package/claude-plugin/dist/adapters/opencode/adapter.js +53 -10
- package/claude-plugin/dist/adapters/opencode/journal.d.ts +2 -0
- package/claude-plugin/dist/adapters/opencode/journal.js +8 -3
- package/claude-plugin/dist/adapters/opencode/plugin.js +2 -2
- package/claude-plugin/dist/adapters/supervisor.js +64 -20
- package/claude-plugin/dist/adapters/types.d.ts +7 -0
- package/claude-plugin/dist/contract/schema.d.ts +8 -17
- package/claude-plugin/dist/contract/schema.js +3 -4
- package/claude-plugin/dist/contract/states.d.ts +11 -0
- package/claude-plugin/dist/contract/states.js +9 -0
- package/claude-plugin/dist/contract/types.d.ts +3 -3
- package/claude-plugin/dist/contract/validate.js +24 -14
- package/claude-plugin/dist/contract/version.d.ts +1 -1
- package/claude-plugin/dist/contract/version.js +1 -1
- package/claude-plugin/dist/core/dsh-selection.d.ts +43 -0
- package/claude-plugin/dist/core/dsh-selection.js +78 -0
- package/claude-plugin/dist/core/handoff.d.ts +42 -0
- package/claude-plugin/dist/core/handoff.js +63 -0
- package/claude-plugin/dist/core/index.d.ts +2 -0
- package/claude-plugin/dist/core/index.js +1 -0
- package/claude-plugin/dist/core/operations.js +33 -1
- package/claude-plugin/dist/core/session-probe.js +11 -22
- package/claude-plugin/dist/core/store.d.ts +8 -3
- package/claude-plugin/dist/core/store.js +17 -3
- package/claude-plugin/request-schema.json +1 -2
- package/dist/adapters/claude/adapter.d.ts +10 -1
- package/dist/adapters/claude/adapter.js +35 -10
- package/dist/adapters/claude/journal.d.ts +8 -0
- package/dist/adapters/claude/journal.js +4 -1
- package/dist/adapters/claude/plugin.js +198 -91
- package/dist/adapters/claude/worker.js +30 -8
- package/dist/adapters/codex/adapter.d.ts +26 -19
- package/dist/adapters/codex/adapter.js +283 -187
- package/dist/adapters/codex/app-server.js +1 -1
- package/dist/adapters/codex/control.d.ts +36 -1
- package/dist/adapters/codex/control.js +74 -4
- package/dist/adapters/codex/native-handoff.d.ts +60 -0
- package/dist/adapters/codex/native-handoff.js +138 -0
- package/dist/adapters/codex/runner.js +35 -32
- package/dist/adapters/codex/tui-daemon-watch.js +60 -49
- package/dist/adapters/declarations.d.ts +0 -1
- package/dist/adapters/declarations.js +0 -1
- package/dist/adapters/dsh/adapter.d.ts +39 -2
- package/dist/adapters/dsh/adapter.js +164 -37
- package/dist/adapters/dsh/plugin.d.ts +3 -1
- package/dist/adapters/dsh/plugin.js +33 -22
- package/dist/adapters/executors.d.ts +25 -2
- package/dist/adapters/executors.js +58 -4
- package/dist/adapters/external.d.ts +21 -0
- package/dist/adapters/external.js +128 -18
- package/dist/adapters/opencode/adapter.d.ts +13 -2
- package/dist/adapters/opencode/adapter.js +53 -10
- package/dist/adapters/opencode/journal.d.ts +2 -0
- package/dist/adapters/opencode/journal.js +8 -3
- package/dist/adapters/opencode/plugin.js +2 -2
- package/dist/adapters/supervisor.js +64 -20
- package/dist/adapters/types.d.ts +7 -0
- package/dist/contract/schema.d.ts +8 -17
- package/dist/contract/schema.js +3 -4
- package/dist/contract/states.d.ts +11 -0
- package/dist/contract/states.js +9 -0
- package/dist/contract/types.d.ts +3 -3
- package/dist/contract/validate.js +24 -14
- package/dist/contract/version.d.ts +1 -1
- package/dist/contract/version.js +1 -1
- package/dist/core/dsh-selection.d.ts +43 -0
- package/dist/core/dsh-selection.js +78 -0
- package/dist/core/handoff.d.ts +42 -0
- package/dist/core/handoff.js +63 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +1 -0
- package/dist/core/operations.js +33 -1
- package/dist/core/session-probe.js +11 -22
- package/dist/core/store.d.ts +8 -3
- package/dist/core/store.js +17 -3
- package/docs/contract.md +25 -15
- package/opencode-plugin/dist/adapters/claude/adapter.d.ts +10 -1
- package/opencode-plugin/dist/adapters/claude/adapter.js +35 -10
- package/opencode-plugin/dist/adapters/claude/journal.d.ts +8 -0
- package/opencode-plugin/dist/adapters/claude/journal.js +4 -1
- package/opencode-plugin/dist/adapters/claude/plugin.js +198 -91
- package/opencode-plugin/dist/adapters/claude/worker.js +30 -8
- package/opencode-plugin/dist/adapters/codex/adapter.d.ts +26 -19
- package/opencode-plugin/dist/adapters/codex/adapter.js +283 -187
- package/opencode-plugin/dist/adapters/codex/app-server.js +1 -1
- package/opencode-plugin/dist/adapters/codex/control.d.ts +36 -1
- package/opencode-plugin/dist/adapters/codex/control.js +74 -4
- package/opencode-plugin/dist/adapters/codex/native-handoff.d.ts +60 -0
- package/opencode-plugin/dist/adapters/codex/native-handoff.js +138 -0
- package/opencode-plugin/dist/adapters/codex/runner.js +35 -32
- package/opencode-plugin/dist/adapters/codex/tui-daemon-watch.js +60 -49
- package/opencode-plugin/dist/adapters/declarations.d.ts +0 -1
- package/opencode-plugin/dist/adapters/declarations.js +0 -1
- package/opencode-plugin/dist/adapters/dsh/adapter.d.ts +39 -2
- package/opencode-plugin/dist/adapters/dsh/adapter.js +164 -37
- package/opencode-plugin/dist/adapters/dsh/plugin.d.ts +3 -1
- package/opencode-plugin/dist/adapters/dsh/plugin.js +33 -22
- package/opencode-plugin/dist/adapters/executors.d.ts +25 -2
- package/opencode-plugin/dist/adapters/executors.js +58 -4
- package/opencode-plugin/dist/adapters/external.d.ts +21 -0
- package/opencode-plugin/dist/adapters/external.js +128 -18
- package/opencode-plugin/dist/adapters/opencode/adapter.d.ts +13 -2
- package/opencode-plugin/dist/adapters/opencode/adapter.js +53 -10
- package/opencode-plugin/dist/adapters/opencode/journal.d.ts +2 -0
- package/opencode-plugin/dist/adapters/opencode/journal.js +8 -3
- package/opencode-plugin/dist/adapters/opencode/plugin.js +2 -2
- package/opencode-plugin/dist/adapters/supervisor.js +64 -20
- package/opencode-plugin/dist/adapters/types.d.ts +7 -0
- package/opencode-plugin/dist/contract/schema.d.ts +8 -17
- package/opencode-plugin/dist/contract/schema.js +3 -4
- package/opencode-plugin/dist/contract/states.d.ts +11 -0
- package/opencode-plugin/dist/contract/states.js +9 -0
- package/opencode-plugin/dist/contract/types.d.ts +3 -3
- package/opencode-plugin/dist/contract/validate.js +24 -14
- package/opencode-plugin/dist/contract/version.d.ts +1 -1
- package/opencode-plugin/dist/contract/version.js +1 -1
- package/opencode-plugin/dist/core/dsh-selection.d.ts +43 -0
- package/opencode-plugin/dist/core/dsh-selection.js +78 -0
- package/opencode-plugin/dist/core/handoff.d.ts +42 -0
- package/opencode-plugin/dist/core/handoff.js +63 -0
- package/opencode-plugin/dist/core/index.d.ts +2 -0
- package/opencode-plugin/dist/core/index.js +1 -0
- package/opencode-plugin/dist/core/operations.js +33 -1
- package/opencode-plugin/dist/core/session-probe.js +11 -22
- package/opencode-plugin/dist/core/store.d.ts +8 -3
- package/opencode-plugin/dist/core/store.js +17 -3
- package/opencode-plugin/package.json +1 -1
- package/package.json +1 -1
- package/claude-plugin/dist/adapters/codex/tui-restart-watch.d.ts +0 -2
- package/claude-plugin/dist/adapters/codex/tui-restart-watch.js +0 -330
- package/claude-plugin/dist/tmux/backend.d.ts +0 -55
- package/claude-plugin/dist/tmux/backend.js +0 -161
- package/dist/adapters/codex/tui-restart-watch.d.ts +0 -2
- package/dist/adapters/codex/tui-restart-watch.js +0 -330
- package/dist/tmux/backend.d.ts +0 -55
- package/dist/tmux/backend.js +0 -161
- package/opencode-plugin/dist/adapters/codex/tui-restart-watch.d.ts +0 -2
- package/opencode-plugin/dist/adapters/codex/tui-restart-watch.js +0 -330
- package/opencode-plugin/dist/tmux/backend.d.ts +0 -55
- package/opencode-plugin/dist/tmux/backend.js +0 -161
|
@@ -12,7 +12,7 @@ import { handoffMode, handoffOutcome } from '../../contract/states.js';
|
|
|
12
12
|
import { fingerprint } from '../../core/fingerprint.js';
|
|
13
13
|
import { activeRecord } from '../../core/journal.js';
|
|
14
14
|
import { Ai4aiStore } from '../../core/store.js';
|
|
15
|
-
import { execute } from '../../core/operations.js';
|
|
15
|
+
import { currentOs, execute } from '../../core/operations.js';
|
|
16
16
|
import { ClaudeJournal, response } from './journal.js';
|
|
17
17
|
import { ClaudeAdapter } from './adapter.js';
|
|
18
18
|
import { resolveClaudeStatus } from './status.js';
|
|
@@ -99,12 +99,19 @@ if (command.action === 'transition') {
|
|
|
99
99
|
const to = command.phase ?? 'unknown';
|
|
100
100
|
if (!allowed[to]?.includes(latest.phase))
|
|
101
101
|
throw new Error(`Unexpected transition ${latest.phase} -> ${to}; no replay`);
|
|
102
|
+
const successor = command.successor ?? { ...latest.source, generation: latest.marker };
|
|
103
|
+
// A handoff never changes the native session identity; the plugin asserts
|
|
104
|
+
// this too, and the journal refuses a mismatched record rather than storing
|
|
105
|
+
// a false success.
|
|
106
|
+
if (successor.session !== latest.source.session)
|
|
107
|
+
throw new Error('Handoff successor changed the native session id; no transition recorded');
|
|
102
108
|
const next = {
|
|
103
109
|
...latest, phase: to, reason: command.reason ?? to,
|
|
104
110
|
...(to === 'applied'
|
|
105
111
|
? {
|
|
106
|
-
successor
|
|
107
|
-
mechanism: command.mechanism ?? latest.mechanism ?? '
|
|
112
|
+
successor,
|
|
113
|
+
mechanism: command.mechanism ?? latest.mechanism ?? 'restart',
|
|
114
|
+
proofMechanism: command.proofMechanism ?? latest.proofMechanism ?? 'surface-replacement',
|
|
108
115
|
}
|
|
109
116
|
: {}),
|
|
110
117
|
};
|
|
@@ -131,9 +138,12 @@ if (request.operation === 'status' && (request.target === undefined || request.t
|
|
|
131
138
|
});
|
|
132
139
|
const pointer = await sessionPointer('claude-code', caller.workspace, caller.session).catch(() => null);
|
|
133
140
|
const activity = await sessionActivity(pointer?.path ?? null);
|
|
141
|
+
const compactionDisabled = !!process.env.DISABLE_COMPACT && process.env.DISABLE_COMPACT !== '0';
|
|
134
142
|
console.log(JSON.stringify({
|
|
135
143
|
result: result(request, 'completed', 'Native session status', {
|
|
136
144
|
durable: true,
|
|
145
|
+
// A session-level limit, reported honestly without blocking status.
|
|
146
|
+
...(compactionDisabled ? { notices: [{ code: 'claude-compaction-disabled', impact: 'none', action_required: false, message: 'Compaction is switched off in this session (DISABLE_COMPACT); the in-place restart handoff is unsupported here.' }] } : {}),
|
|
137
147
|
// The session is alive while it serves this call; handoff progress is
|
|
138
148
|
// reported separately, and quiescence is inferred from lastActivityAt.
|
|
139
149
|
state: 'running',
|
|
@@ -155,7 +165,7 @@ if (request.operation === 'status' && (request.target === undefined || request.t
|
|
|
155
165
|
process.exit(0);
|
|
156
166
|
}
|
|
157
167
|
if (request.operation === 'capabilities') {
|
|
158
|
-
console.log(JSON.stringify({ result: result(request, 'completed', 'Claude adapter capabilities are declared by the installed plugin', { durable: false }) }));
|
|
168
|
+
console.log(JSON.stringify({ result: result(request, 'completed', 'Claude adapter capabilities are declared by the installed plugin', { durable: false, capabilities: new ClaudeAdapter().capabilities(currentOs()) }) }));
|
|
159
169
|
process.exit(0);
|
|
160
170
|
}
|
|
161
171
|
if (request.operation === 'cancel' || request.operation === 'stop') {
|
|
@@ -183,8 +193,21 @@ if (request.operation === 'handoff' && request.target === 'self') {
|
|
|
183
193
|
console.log(JSON.stringify({ result: result(request, 'failed', 'Another handoff is unresolved; reconcile it before requesting a transition') }));
|
|
184
194
|
process.exit(0);
|
|
185
195
|
}
|
|
196
|
+
// Compaction can be switched off per session; the restart path needs it, so
|
|
197
|
+
// report the limitation up front instead of failing midway.
|
|
198
|
+
if (process.env.DISABLE_COMPACT && process.env.DISABLE_COMPACT !== '0') {
|
|
199
|
+
console.log(JSON.stringify({ result: result(request, 'unsupported', 'Compaction is switched off in this session (DISABLE_COMPACT); the in-place restart handoff needs it', { unavailable: ['handoff.restart'], error: { code: 'claude-compaction-disabled', message: 'DISABLE_COMPACT is set for this session' } }) }));
|
|
200
|
+
process.exit(0);
|
|
201
|
+
}
|
|
202
|
+
// This version declares restart only. `compact` means a native summary,
|
|
203
|
+
// which Claude does not implement here; refuse it instead of silently
|
|
204
|
+
// running the zero-summary replacement under a compact label.
|
|
205
|
+
if (request.mode === 'compact') {
|
|
206
|
+
console.log(JSON.stringify({ result: result(request, 'unsupported', 'Claude Code handoff implements restart only in this version; native compaction plus task delivery is not available', { unavailable: ['handoff.compact'] }) }));
|
|
207
|
+
process.exit(0);
|
|
208
|
+
}
|
|
186
209
|
const mechanism = handoffMode(request.mode);
|
|
187
|
-
if (
|
|
210
|
+
if (!request.task) {
|
|
188
211
|
console.log(JSON.stringify({ result: result(request, 'unsupported', 'A restart handoff needs task material: the new context contains only that material', { unavailable: ['handoff.task'] }) }));
|
|
189
212
|
process.exit(0);
|
|
190
213
|
}
|
|
@@ -192,9 +215,8 @@ if (request.operation === 'handoff' && request.target === 'self') {
|
|
|
192
215
|
const record = {
|
|
193
216
|
format: 2, operationId: request.operationId, fingerprint: fingerprint(request), request, source: caller, marker, phase: 'pending',
|
|
194
217
|
mechanism,
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
: 'Finish this turn; the native safe point will replace the context with the caller task material',
|
|
218
|
+
proofMechanism: 'surface-replacement',
|
|
219
|
+
reason: 'Finish this turn; the native compact hook replaces this context in place with the caller task material (no summary model is called)',
|
|
198
220
|
};
|
|
199
221
|
await journal.transaction(caller, async (_rows, commit) => commit(record));
|
|
200
222
|
console.log(JSON.stringify({ result: response(record), record }));
|
|
@@ -1,41 +1,48 @@
|
|
|
1
1
|
import type { AdapterContext, CarrierCommand, StatusDetails, NativeOutcome } from '../external.js';
|
|
2
2
|
import { ExternalExecutorAdapter } from '../external.js';
|
|
3
|
-
import type { CapabilityDeclaration } from '../../contract/types.js';
|
|
4
|
-
import type { Request } from '../../contract/types.js';
|
|
3
|
+
import type { CapabilityDeclaration, Request } from '../../contract/types.js';
|
|
5
4
|
import type { HarnessId, Os } from '../../contract/states.js';
|
|
6
5
|
import type { ExecutorRecord } from '../../core/store.js';
|
|
7
6
|
import { type LogLine, type ExecutorStatus } from '../executors.js';
|
|
8
7
|
export declare class CodexAdapter extends ExternalExecutorAdapter {
|
|
9
8
|
readonly harness: HarnessId;
|
|
10
9
|
capabilities(os: Os): CapabilityDeclaration[];
|
|
10
|
+
/**
|
|
11
|
+
* A detached Codex executor inherits the profile model and reasoning effort:
|
|
12
|
+
* the runner starts a thread without per-request overrides. Refuse them
|
|
13
|
+
* loudly instead of accepting values that would never reach the harness.
|
|
14
|
+
*/
|
|
15
|
+
spawn(request: Request, ctx: AdapterContext): Promise<NativeOutcome>;
|
|
11
16
|
protected carrier(request: Parameters<ExternalExecutorAdapter['spawn']>[0], ctx: AdapterContext, _executorId: string, resumeSessionId?: string): Promise<CarrierCommand>;
|
|
12
17
|
/**
|
|
13
18
|
* Same-window handoff through the local app-server daemon.
|
|
14
19
|
*
|
|
15
|
-
* The daemon owns the TUI's live thread.
|
|
16
|
-
*
|
|
17
|
-
* window: a
|
|
18
|
-
* When no daemon or live thread is reachable, the
|
|
19
|
-
* is
|
|
20
|
+
* The daemon owns the TUI's live thread. Reverting it and starting the
|
|
21
|
+
* material turn through the daemon changes what the user sees in the same
|
|
22
|
+
* window: a reset history followed by the handoff task as the next turn.
|
|
23
|
+
* When no daemon or live thread is reachable, the call fails as the
|
|
24
|
+
* structured `codex-no-daemon` host boundary; no new thread is created.
|
|
20
25
|
*/
|
|
21
26
|
handoff(request: Request, ctx: AdapterContext): Promise<NativeOutcome>;
|
|
22
27
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
* Re-query a pending handoff written by the headless runner or the detached
|
|
29
|
+
* TUI watcher. Without this, the same operationId would return the original
|
|
30
|
+
* pending result forever even after the native side completed.
|
|
31
|
+
*/
|
|
32
|
+
reconcileHandoff(request: Request, ctx: AdapterContext): Promise<NativeOutcome | undefined>;
|
|
33
|
+
/**
|
|
34
|
+
* Native TUI restart. The TUI's shared app-server daemon owns the live
|
|
35
|
+
* thread; a detached watcher waits for the safe point, archives best-effort,
|
|
36
|
+
* reverts the thread to its start and starts the material turn in the same
|
|
37
|
+
* thread. No tmux, no `/new`, no new thread.
|
|
29
38
|
*/
|
|
30
39
|
private tuiRestart;
|
|
31
40
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* watcher starts the material turn once the reset is observed. Same thread,
|
|
36
|
-
* same process, no tmux and no process replacement.
|
|
41
|
+
* Explicit compact opt-in for the TUI: the harness's native compaction runs
|
|
42
|
+
* (and may spend summary tokens), then the material is the next turn in the
|
|
43
|
+
* same thread. Proof uses the native thread id for both source and successor.
|
|
37
44
|
*/
|
|
38
|
-
private
|
|
45
|
+
private tuiCompact;
|
|
39
46
|
protected statusDetails(record: ExecutorRecord, status: ExecutorStatus, _log: LogLine[], ctx: AdapterContext): Promise<StatusDetails>;
|
|
40
47
|
}
|
|
41
48
|
export declare const codexAdapter: CodexAdapter;
|