aiterm-mcp 0.61.19 → 0.61.21
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 +38 -1
- package/README.ja.md +36 -4
- package/README.md +38 -5
- package/dist/agent-goal-native-result.js +172 -0
- package/dist/agent-goal-ui.js +50 -0
- package/dist/agent-goal.js +221 -0
- package/dist/codex-goal-connection.js +23 -0
- package/dist/codex-relay-client.js +3 -2
- package/dist/core.js +311 -10
- package/dist/execution-contract.js +1 -1
- package/dist/execution-dispatch.js +4 -1
- package/dist/execution-immediate-stop.js +77 -24
- package/dist/execution-native-server.js +9 -5
- package/dist/harnesses/claude-goal.js +243 -0
- package/dist/harnesses/codex-goal-editor.js +134 -0
- package/dist/harnesses/codex-goal.js +94 -0
- package/dist/harnesses/cursor.js +27 -0
- package/dist/harnesses/grok-goal.js +261 -0
- package/dist/harnesses/grok.js +25 -2
- package/dist/index.js +22 -0
- package/dist/process-runtime.js +18 -0
- package/dist/process-start.js +35 -0
- package/dist/runtime-error-os.js +2 -32
- package/docs/DESIGN.md +44 -2
- package/package.json +1 -1
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { AgentGoalNotIssuedError } from '../agent-goal.js';
|
|
3
|
+
import { grokPaneObservation } from './grok.js';
|
|
4
|
+
import stringWidth from 'string-width';
|
|
5
|
+
// Grok 1.0.70 owns this registry. A stale PID or another current session is
|
|
6
|
+
// never repaired by choosing a newer directory or by loading a conversation.
|
|
7
|
+
const activeSessionSchema = z.array(z.object({ session_id: z.string().uuid(), pid: z.number().int().positive(),
|
|
8
|
+
pid_start: z.number().int().nonnegative().safe(), cwd: z.string() }));
|
|
9
|
+
export function grokCurrentSessionOwner(record, expected) {
|
|
10
|
+
const parsed = activeSessionSchema.safeParse(record);
|
|
11
|
+
if (!parsed.success)
|
|
12
|
+
return 'unavailable';
|
|
13
|
+
const rows = parsed.data.filter(row => row.pid === expected.pid);
|
|
14
|
+
if (rows.length !== 1 || String(rows[0].pid_start) !== expected.procStart || rows[0].cwd !== expected.cwd)
|
|
15
|
+
return 'unavailable';
|
|
16
|
+
return rows[0].session_id === expected.sessionId ? 'match' : 'mismatch';
|
|
17
|
+
}
|
|
18
|
+
export const grokNativeGoalStateSchema = z.object({
|
|
19
|
+
goal_id: z.string().uuid(), objective: z.string().min(1), status: z.enum(['active', 'user_paused']), phase: z.enum(['Idle', 'Planning', 'Executing']),
|
|
20
|
+
token_budget: z.number().int().positive(), elapsed_ms: z.number().int().nonnegative(), created_at: z.string().datetime({ offset: true }),
|
|
21
|
+
current_subagent_id: z.string().nullable(), current_subagent_role: z.string().nullable(),
|
|
22
|
+
total_worker_rounds: z.number().int().nonnegative(), total_verify_rounds: z.number().int().nonnegative(),
|
|
23
|
+
token_baseline: z.number().int().nonnegative(), tokens_used_high_water: z.number().int().nonnegative(), parent_tokens_spent: z.number().int().nonnegative(), last_session_tokens_seen: z.number().int().nonnegative(),
|
|
24
|
+
history: z.array(z.object({ timestamp: z.string().datetime({ offset: true }), event: z.string(), detail: z.string().optional() }).strict()),
|
|
25
|
+
evaluator_blocked_streak: z.number().int().nonnegative(), verifier_id: z.string().min(1), classifier_runs_attempted: z.number().int().nonnegative(), rounds_since_verify: z.number().int().nonnegative(), classifier_stall_count: z.number().int().nonnegative(), consecutive_not_achieved: z.number().int().nonnegative(), last_strategist_fired_at: z.number().int().nonnegative(), strategist_cap_bonus: z.number().int().nonnegative(),
|
|
26
|
+
}).strict();
|
|
27
|
+
const elapsedDisplay = z.string().max(64).regex(/^(?:\d+s|\d+m[0-5]\ds|\d+h[0-5]\dm)$/u);
|
|
28
|
+
export const grokCurrentStatusSchema = z.discriminatedUnion('source', [z.object({
|
|
29
|
+
source: z.literal('/goal status'), status: z.enum(['Active', 'UserPaused']), phase: z.enum(['Idle', 'Planning', 'Executing']),
|
|
30
|
+
tokens_used: z.number().int().nonnegative().safe(), elapsed_display: elapsedDisplay,
|
|
31
|
+
}).strict(), z.object({
|
|
32
|
+
source: z.literal('goal detail'), status: z.enum(['Active', 'Paused']), phase: z.null(), tokens_used: z.null(),
|
|
33
|
+
status_display: z.string().min(1).max(128), phase_display: z.string().min(1).max(64).nullable(),
|
|
34
|
+
budget_display: z.string().min(1).max(128), elapsed_display: elapsedDisplay,
|
|
35
|
+
}).strict()]);
|
|
36
|
+
// Keep the persisted native snapshot distinct from the current worker's
|
|
37
|
+
// fresh status. Resuming a worker can reset its in-memory phase without
|
|
38
|
+
// rewriting that snapshot; never present the stored phase as current.
|
|
39
|
+
export const grokCurrentGoalSchema = z.object({ kind: z.literal('grok-cli'), native: grokNativeGoalStateSchema, current_status: grokCurrentStatusSchema }).strict();
|
|
40
|
+
export function grokGoalFromFreshStatus(text, before, after) {
|
|
41
|
+
const first = grokNativeGoalStateSchema.parse(before), native = grokNativeGoalStateSchema.parse(after);
|
|
42
|
+
if (first.goal_id !== native.goal_id || first.objective !== native.objective)
|
|
43
|
+
throw Error('native_goal_identity_changed');
|
|
44
|
+
const prefix = `Goal: ${native.objective}\nStatus: `;
|
|
45
|
+
if (!text.startsWith(prefix))
|
|
46
|
+
throw Error('native_goal_status_mismatch');
|
|
47
|
+
const match = text.slice(prefix.length).match(/^(Active|UserPaused) \| Phase: (Idle|Planning|Executing)\nGoal tokens used: (\d+)\nElapsed: ([^\r\n]+)$/u);
|
|
48
|
+
if (!match)
|
|
49
|
+
throw Error('native_goal_active_status_unverified');
|
|
50
|
+
return grokCurrentGoalSchema.parse({ kind: 'grok-cli', native, current_status: { source: '/goal status', status: match[1], phase: match[2], tokens_used: Number(match[3]), elapsed_display: match[4] } });
|
|
51
|
+
}
|
|
52
|
+
function composer(screen, command = '/goal status') {
|
|
53
|
+
const plain = screen.replace(/\x1b\[[0-?]*[ -/]*[@-~]/gu, '');
|
|
54
|
+
const lines = plain.split('\n');
|
|
55
|
+
let anchor = -1;
|
|
56
|
+
for (let i = lines.length - 1; i >= 0; i--)
|
|
57
|
+
if (/^minimal\s+·\s/u.test(lines[i])) {
|
|
58
|
+
anchor = i;
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
// Completion rows also have ❯. The composer belongs to its current layout
|
|
62
|
+
// anchor, never to the last cursor anywhere in the viewport.
|
|
63
|
+
const row = anchor >= 0 ? lines[anchor + 1] : lines.filter(line => /^\s*│\s*[❯>]/u.test(line)).at(-1);
|
|
64
|
+
if (row === undefined || !/^\s*(?:│\s*)?[❯>]/u.test(row))
|
|
65
|
+
return null;
|
|
66
|
+
const tail = anchor >= 0 ? lines.slice(anchor + 2) : [];
|
|
67
|
+
const value = row.replace(/^\s*(?:│\s*)?[❯>]\s?/u, '').replace(/\s*│\s*$/u, '').trimEnd();
|
|
68
|
+
const menu = tail.some(line => line.includes('↑/↓ navigate'));
|
|
69
|
+
const expected = command === '/goal status' ? '❯ status Show the goal' : '❯ clear Clear the goal';
|
|
70
|
+
const knownMenu = menu && tail.filter(line => /^❯/u.test(line)).map(line => line.trimEnd()).join('\n') === expected
|
|
71
|
+
&& /^\s*↑\/↓ navigate · enter confirm · esc cancel\s*$/u.test(tail.filter(line => line.trim()).at(-1) ?? '');
|
|
72
|
+
if (menu && !knownMenu)
|
|
73
|
+
return null;
|
|
74
|
+
const observation = grokPaneObservation(plain);
|
|
75
|
+
// Minimal completion replaces the model footer. Only this exact command's
|
|
76
|
+
// current anchored menu establishes input readiness when that footer is gone.
|
|
77
|
+
if (observation.state !== 'idle' && !(observation.state === 'unknown' && anchor >= 0 && knownMenu && value === command))
|
|
78
|
+
return null;
|
|
79
|
+
return value;
|
|
80
|
+
}
|
|
81
|
+
const plainScreen = (screen) => screen.replace(/\x1b\[[0-?]*[ -/]*[@-~]/gu, '');
|
|
82
|
+
function fullHeader(screen) {
|
|
83
|
+
const raw = screen.split('\n'), lines = plainScreen(screen).split('\n');
|
|
84
|
+
const at = lines.slice(0, 2).findIndex(line => /^\s+.*\[[^\]\r\n]*Goal: [^\]\r\n]+\].*\[Dashboard\]\s*$/u.test(line));
|
|
85
|
+
if (at < 0)
|
|
86
|
+
return null;
|
|
87
|
+
const start = lines[at].indexOf('Goal: ');
|
|
88
|
+
return { column: stringWidth(lines[at].slice(0, start)) + 2, row: at + 1, text: raw[at] };
|
|
89
|
+
}
|
|
90
|
+
function emptyFullComposer(screen) {
|
|
91
|
+
const text = plainScreen(screen);
|
|
92
|
+
const modalCaption = text.split('\n').some(line => {
|
|
93
|
+
const match = line.match(/^\s*[┌╭](.*)$/u);
|
|
94
|
+
return !!match && /[^─\s╮┐]/u.test(match[1]);
|
|
95
|
+
});
|
|
96
|
+
return !modalCaption && /^\s*│\s*❯\s*│\s*$/mu.test(text) && /Ctrl\+x:shortcuts/u.test(text);
|
|
97
|
+
}
|
|
98
|
+
function detailFrame(screen) {
|
|
99
|
+
const raw = screen.split('\n'), lines = plainScreen(screen).split('\n');
|
|
100
|
+
const tops = lines.flatMap((line, i) => /^\s*┌─ Goal ─+ \[✗\] ─┐\s*$/u.test(line) ? [i] : []);
|
|
101
|
+
if (tops.length !== 1)
|
|
102
|
+
return null;
|
|
103
|
+
const top = tops[0], header = lines[top], left = stringWidth(header.slice(0, header.indexOf('┌'))), right = stringWidth(header.slice(0, header.lastIndexOf('┐')));
|
|
104
|
+
const body = [];
|
|
105
|
+
for (let i = top + 1; i < lines.length; i++) {
|
|
106
|
+
const line = lines[i];
|
|
107
|
+
if (line.includes('└') && stringWidth(line.slice(0, line.indexOf('└'))) === left && line.includes('┘'))
|
|
108
|
+
return { row: top + 1, text: raw[top], body };
|
|
109
|
+
const bars = Array.from(line.matchAll(/│/gu), match => ({ index: match.index, column: stringWidth(line.slice(0, match.index)) }));
|
|
110
|
+
const a = bars.find(bar => bar.column === left), b = bars.find(bar => bar.column === right);
|
|
111
|
+
if (!a || !b)
|
|
112
|
+
return null;
|
|
113
|
+
body.push(line.slice(a.index + 1, b.index).trim());
|
|
114
|
+
}
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
export function grokGoalFromDetail(screen, before, after) {
|
|
118
|
+
const first = grokNativeGoalStateSchema.parse(before), native = grokNativeGoalStateSchema.parse(after), frame = detailFrame(screen);
|
|
119
|
+
if (first.goal_id !== native.goal_id || first.objective !== native.objective)
|
|
120
|
+
throw Error('native_goal_identity_changed');
|
|
121
|
+
if (!frame || frame.body[0] !== native.objective)
|
|
122
|
+
throw Error('native_goal_detail_mismatch');
|
|
123
|
+
const field = (prefix) => { const rows = frame.body.filter(line => line.startsWith(prefix)); if (rows.length !== 1)
|
|
124
|
+
throw Error('native_goal_detail_unverified'); return rows[0].slice(prefix.length); };
|
|
125
|
+
const statuses = frame.body.filter(line => /^Status: (?:Active(?:\s.*)?|Paused)$/u.test(line));
|
|
126
|
+
if (statuses.length !== 1)
|
|
127
|
+
throw Error('native_goal_detail_unverified');
|
|
128
|
+
const display = statuses[0].slice('Status: '.length), phase = display.indexOf(' · ');
|
|
129
|
+
return grokCurrentGoalSchema.parse({ kind: 'grok-cli', native, current_status: { source: 'goal detail', status: display.startsWith('Active') ? 'Active' : 'Paused', phase: null, tokens_used: null,
|
|
130
|
+
status_display: display, phase_display: phase < 0 ? null : display.slice(phase + 3), budget_display: field('Budget: '), elapsed_display: field('Elapsed: ') } });
|
|
131
|
+
}
|
|
132
|
+
async function readGrokGoalDetail(port, before, initial) {
|
|
133
|
+
const state = grokNativeGoalStateSchema.parse(before), header = fullHeader(initial);
|
|
134
|
+
if (!header || !port.ui.click || !emptyFullComposer(initial) || detailFrame(initial) || /[\r\n\x00-\x1f\x7f]/u.test(state.objective) || state.objective.trim() !== state.objective)
|
|
135
|
+
throw new AgentGoalNotIssuedError('native_goal_status_input_unconfirmed');
|
|
136
|
+
const now = port.ui.now ?? (() => performance.now());
|
|
137
|
+
let opened = null;
|
|
138
|
+
await port.ui.click(header.column, header.row, screen => {
|
|
139
|
+
const fresh = fullHeader(screen);
|
|
140
|
+
return fresh?.column === header.column && fresh.row === header.row && emptyFullComposer(screen) && !detailFrame(screen);
|
|
141
|
+
});
|
|
142
|
+
try {
|
|
143
|
+
for (const until = now() + 2000; now() < until; await port.ui.pause(30)) {
|
|
144
|
+
const screen = port.ui.read();
|
|
145
|
+
opened = detailFrame(screen);
|
|
146
|
+
if (opened)
|
|
147
|
+
return { current: grokGoalFromDetail(screen, state, port.state()) };
|
|
148
|
+
}
|
|
149
|
+
throw Error('native_goal_detail_unavailable');
|
|
150
|
+
}
|
|
151
|
+
finally {
|
|
152
|
+
if (opened) {
|
|
153
|
+
const current = detailFrame(port.ui.read());
|
|
154
|
+
if (!current)
|
|
155
|
+
throw Error('native_goal_detail_changed');
|
|
156
|
+
await port.ui.keys(['g'], { row: current.row, text: current.text });
|
|
157
|
+
let closed = false;
|
|
158
|
+
for (const until = now() + 2000; now() < until; await port.ui.pause(30)) {
|
|
159
|
+
const screen = port.ui.read();
|
|
160
|
+
if (!detailFrame(screen) && emptyFullComposer(screen)) {
|
|
161
|
+
closed = true;
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (!closed)
|
|
166
|
+
throw Error('native_goal_detail_close_unconfirmed');
|
|
167
|
+
const after = grokNativeGoalStateSchema.parse(port.state());
|
|
168
|
+
if (after.goal_id !== state.goal_id || after.objective !== state.objective)
|
|
169
|
+
throw Error('native_goal_identity_changed');
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
async function localGoalCommand(sessionId, port, command, guard) {
|
|
174
|
+
const before = port.rows();
|
|
175
|
+
const beforeState = port.state();
|
|
176
|
+
const initial = port.ui.read();
|
|
177
|
+
if (composer(initial) !== '')
|
|
178
|
+
throw new AgentGoalNotIssuedError('native_goal_status_input_unconfirmed');
|
|
179
|
+
guard?.();
|
|
180
|
+
await port.ui.paste(command);
|
|
181
|
+
const now = port.ui.now ?? (() => performance.now());
|
|
182
|
+
let pasted = false;
|
|
183
|
+
for (const until = now() + 2000; now() < until; await port.ui.pause(30)) {
|
|
184
|
+
if (composer(port.ui.read(), command) === command) {
|
|
185
|
+
pasted = true;
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if (!pasted)
|
|
190
|
+
throw new AgentGoalNotIssuedError('native_goal_status_input_unconfirmed');
|
|
191
|
+
guard?.();
|
|
192
|
+
await port.ui.keys(['Enter'], undefined, screen => { guard?.(); return composer(screen, command) === command; });
|
|
193
|
+
for (const until = now() + 2000; now() < until; await port.ui.pause(30)) {
|
|
194
|
+
port.ui.read(); // current native session and foreground ownership guard
|
|
195
|
+
const rows = port.rows();
|
|
196
|
+
if (rows.length < before.length || before.some((row, i) => JSON.stringify(row) !== JSON.stringify(rows[i])))
|
|
197
|
+
throw Error('native_goal_transcript_replaced');
|
|
198
|
+
const tail = rows.slice(before.length);
|
|
199
|
+
const query = tail.flatMap((row, i) => row?.method === 'session/update' && row.params?.sessionId === sessionId
|
|
200
|
+
&& row.params.update?.sessionUpdate === 'user_message_chunk' && row.params.update?._meta?.hostTurn === true
|
|
201
|
+
&& row.params.update.content?.type === 'text' && row.params.update.content?.text === command ? [i] : []);
|
|
202
|
+
if (query.length > 1)
|
|
203
|
+
throw Error('native_goal_status_ambiguous');
|
|
204
|
+
if (query.length !== 1)
|
|
205
|
+
continue;
|
|
206
|
+
const replies = tail.slice(query[0] + 1).filter(row => row?.method === 'session/update' && row.params?.sessionId === sessionId
|
|
207
|
+
&& row.params.update?.sessionUpdate === 'agent_message_chunk' && row.params.update?._meta?.hostTurn === true
|
|
208
|
+
&& row.params.update.content?.type === 'text');
|
|
209
|
+
if (replies.length > 1)
|
|
210
|
+
throw Error('native_goal_status_ambiguous');
|
|
211
|
+
if (replies.length !== 1)
|
|
212
|
+
continue;
|
|
213
|
+
const text = replies[0].params.update.content.text;
|
|
214
|
+
const state = port.state();
|
|
215
|
+
return { text, before: beforeState, after: state };
|
|
216
|
+
}
|
|
217
|
+
throw Error('native_goal_fresh_status_unavailable');
|
|
218
|
+
}
|
|
219
|
+
export async function readFreshGrokGoal(sessionId, port) {
|
|
220
|
+
const initial = port.ui.read();
|
|
221
|
+
if (fullHeader(initial))
|
|
222
|
+
return readGrokGoalDetail(port, port.state(), initial);
|
|
223
|
+
const observed = await localGoalCommand(sessionId, port, '/goal status');
|
|
224
|
+
if (observed.text === 'No goal is currently set. Use /goal <objective> to start one.') {
|
|
225
|
+
if (observed.after !== null)
|
|
226
|
+
throw Error('native_goal_status_mismatch');
|
|
227
|
+
return { current: null };
|
|
228
|
+
}
|
|
229
|
+
return { current: grokGoalFromFreshStatus(observed.text, observed.before, observed.after) };
|
|
230
|
+
}
|
|
231
|
+
export function grokGoalClearReady(ui) { return composer(ui.read()) === ''; }
|
|
232
|
+
export async function clearGrokGoal(sessionId, expected, port) {
|
|
233
|
+
const status = expected.current_status;
|
|
234
|
+
if (expected.native.status !== 'user_paused' || status.source !== '/goal status' || status.status !== 'UserPaused' || status.phase !== 'Idle')
|
|
235
|
+
throw new AgentGoalNotIssuedError('native_goal_clear_input_unconfirmed');
|
|
236
|
+
let enterAttempted = false;
|
|
237
|
+
const guard = () => {
|
|
238
|
+
const current = grokNativeGoalStateSchema.safeParse(port.state());
|
|
239
|
+
if (!current.success || current.data.status !== 'user_paused' || current.data.goal_id !== expected.native.goal_id || current.data.objective !== expected.native.objective)
|
|
240
|
+
throw new AgentGoalNotIssuedError('native_goal_changed_before_clear');
|
|
241
|
+
};
|
|
242
|
+
const ui = { ...port.ui, keys: async (keys, row, confirm) => { enterAttempted = true; await port.ui.keys(keys, row, confirm); } };
|
|
243
|
+
let observed;
|
|
244
|
+
try {
|
|
245
|
+
observed = await localGoalCommand(sessionId, { ...port, ui }, '/goal clear', guard);
|
|
246
|
+
}
|
|
247
|
+
catch (error) {
|
|
248
|
+
if (!enterAttempted && !(error instanceof AgentGoalNotIssuedError))
|
|
249
|
+
throw new AgentGoalNotIssuedError('native_goal_clear_input_unconfirmed');
|
|
250
|
+
throw error;
|
|
251
|
+
}
|
|
252
|
+
if (observed.text !== 'Goal cleared.' || observed.after !== null)
|
|
253
|
+
throw Error('native_goal_clear_unconfirmed');
|
|
254
|
+
const now = port.ui.now ?? (() => performance.now());
|
|
255
|
+
for (const until = now() + 2000; now() < until; await port.ui.pause(30)) {
|
|
256
|
+
const screen = port.ui.read();
|
|
257
|
+
if (!fullHeader(screen) && composer(screen) === '')
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
throw Error('native_goal_clear_ui_unconfirmed');
|
|
261
|
+
}
|
package/dist/harnesses/grok.js
CHANGED
|
@@ -284,6 +284,7 @@ export async function observeGrokDone(meta, timeout, requestedCursor, detectRate
|
|
|
284
284
|
let initializedBoundary = false;
|
|
285
285
|
let turnStarted = false;
|
|
286
286
|
let unacceptedSeen = 0;
|
|
287
|
+
let pendingError = null;
|
|
287
288
|
const deadline = performance.now() + timeout * 1000;
|
|
288
289
|
const rateLimitDue = pollGate(AGENT_RATE_LIMIT_POLL_MS);
|
|
289
290
|
const observation = (outcome, ev = null, rateLimit = null, error = null) => ({
|
|
@@ -339,13 +340,18 @@ export async function observeGrokDone(meta, timeout, requestedCursor, detectRate
|
|
|
339
340
|
}
|
|
340
341
|
try {
|
|
341
342
|
const record = JSON.parse(line);
|
|
342
|
-
if (record?.type === "turn_started")
|
|
343
|
+
if (record?.type === "turn_started") {
|
|
343
344
|
turnStarted = true;
|
|
345
|
+
pendingError = null;
|
|
346
|
+
}
|
|
344
347
|
const done = grokCompletionEvent(meta, record);
|
|
345
348
|
if (done) {
|
|
346
349
|
const limited = done.done_status === "turn_error"
|
|
347
350
|
? detectRateLimit(meta.kind, meta.aiterm_session) : null;
|
|
348
|
-
|
|
351
|
+
if (done.done_status === "turn_error" && !limited && timeout > 0 && performance.now() < deadline)
|
|
352
|
+
pendingError = { event: done, until: Math.min(deadline, performance.now() + AGENT_DONE_POLL_MS) };
|
|
353
|
+
else
|
|
354
|
+
return observation(limited ? "rate_limited" : done.done_status === "turn_error" ? "error" : "done", done, limited);
|
|
349
355
|
}
|
|
350
356
|
}
|
|
351
357
|
catch {
|
|
@@ -354,6 +360,23 @@ export async function observeGrokDone(meta, timeout, requestedCursor, detectRate
|
|
|
354
360
|
}
|
|
355
361
|
}
|
|
356
362
|
}
|
|
363
|
+
if (pendingError) {
|
|
364
|
+
const remaining = pendingError.until - performance.now();
|
|
365
|
+
// shortcut: settle one existing poll after the error event; extend only with evidence of a longer native redraw.
|
|
366
|
+
if (remaining > 0) {
|
|
367
|
+
await sleep(remaining);
|
|
368
|
+
continue;
|
|
369
|
+
}
|
|
370
|
+
const limited = detectRateLimit(meta.kind, meta.aiterm_session);
|
|
371
|
+
if (!fs.existsSync(metadataFile))
|
|
372
|
+
return observation("closed");
|
|
373
|
+
if (safeStatSize(transcript) !== cursor) {
|
|
374
|
+
if (performance.now() >= deadline)
|
|
375
|
+
return observation("timeout");
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
378
|
+
return observation(limited ? "rate_limited" : "error", pendingError.event, limited);
|
|
379
|
+
}
|
|
357
380
|
// 質問カードの確認は画面を読む(tmuxを起動する)。完了の見回りより間隔を空け、最初の周回では必ず見る。
|
|
358
381
|
if (rateLimitDue()) {
|
|
359
382
|
const limited = detectRateLimit(meta.kind, meta.aiterm_session);
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,8 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
16
16
|
import { CallToolRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
17
17
|
import { z } from "zod";
|
|
18
18
|
import { agentModelsResult } from "./model-catalog.js";
|
|
19
|
+
import { agentGoalWireResultSchema, agentGoalOutputSchema } from "./agent-goal-native-result.js";
|
|
20
|
+
import { agentGoalInputSchema, goalOriginFromHost } from "./agent-goal.js";
|
|
19
21
|
import * as core from "./core.js";
|
|
20
22
|
import { runtimeErrorStoreDiagnostic } from "./runtime-error-store.js";
|
|
21
23
|
import { triggerRuntimeErrorReport } from "./runtime-error-report.js";
|
|
@@ -44,6 +46,9 @@ const pkg = createRequire(import.meta.url)("../package.json");
|
|
|
44
46
|
*/
|
|
45
47
|
export function createAitermServer(options = {}) {
|
|
46
48
|
const server = new McpServer({ name: "aiterm", version: pkg.version });
|
|
49
|
+
const goalOrigin = options.goalOrigin;
|
|
50
|
+
if (goalOrigin !== undefined && typeof goalOrigin !== "function")
|
|
51
|
+
throw new Error("Invalid trusted goal provenance adapter");
|
|
47
52
|
const supplied = options.execution?.(server);
|
|
48
53
|
if (options.execution && (!supplied || typeof supplied.dispatcher?.dispatch !== "function"
|
|
49
54
|
|| typeof supplied.parentExecution?.bind !== "function" || typeof supplied.parentExecution?.submit !== "function"
|
|
@@ -941,6 +946,23 @@ export function createAitermServer(options = {}) {
|
|
|
941
946
|
"(fastに対応していないmodelでもfalseは受ける)。切り替えは席だけに留め、harnessが利用者の既定へ書いた分は切り替えの直前の値へ戻す。" +
|
|
942
947
|
"断りは文の先頭の符号で分かる: FAST_MODE_NOT_SUPPORTED(そのmodelは対応していない)、FAST_MODE_UNAVAILABLE(アカウントや契約で使えない)、" +
|
|
943
948
|
"FAST_MODE_MODEL_CONFLICT(modelへfast版のIDを書いてfalseを渡した)、FAST_MODE_UNCONFIRMED(切り替えた後の状態を確かめられない)。";
|
|
949
|
+
server.registerTool("agent_goal", {
|
|
950
|
+
description: "Read or manage the CLI's real goal for an exact session/launch. clear removes the goal without stopping its turn; resume requires a paused goal. Editing objective resets native usage accounting. User mutations require trusted host provenance. No goal store or worker is created.",
|
|
951
|
+
inputSchema: agentGoalInputSchema,
|
|
952
|
+
outputSchema: agentGoalOutputSchema,
|
|
953
|
+
}, async (args, extra) => {
|
|
954
|
+
try {
|
|
955
|
+
const origin = goalOrigin ? goalOrigin(extra) : goalOriginFromHost(server.server.getClientVersion()?.name, extra._meta);
|
|
956
|
+
if (origin !== "user" && origin !== "automatic")
|
|
957
|
+
throw new Error("Invalid trusted goal provenance");
|
|
958
|
+
const result = agentGoalWireResultSchema.parse(await core.agentGoal(agentGoalInputSchema.parse(args), origin));
|
|
959
|
+
return { content: [{ type: "text", text: JSON.stringify(result) }], structuredContent: { ...result },
|
|
960
|
+
...(["rejected", "outcome_unknown", "unavailable", "unsupported"].includes(result.outcome) ? { isError: true } : {}) };
|
|
961
|
+
}
|
|
962
|
+
catch (error) {
|
|
963
|
+
return fail(error);
|
|
964
|
+
}
|
|
965
|
+
});
|
|
944
966
|
registerRemoteAwareTool("agent_configure", {
|
|
945
967
|
description: "起動済みのClaude/Codex/Grok/Cursor agent sessionを再起動せず、会話contextを保ったままmodel/reasoning effort/fastを変更する。" +
|
|
946
968
|
"各harnessのCLI標準model操作を使う。Cursorのreasoning_effort変更はmodelと同時指定する。" +
|
package/dist/process-runtime.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import { processStartIdentity } from "./process-start.js";
|
|
1
3
|
// OSのprocess表とnative PIDの所有者。argvは相関にだけ使い、公開identityにはdigestだけを載せる。
|
|
2
4
|
import { spawnSync } from "node:child_process";
|
|
3
5
|
import { createHash } from "node:crypto";
|
|
@@ -294,3 +296,19 @@ export function backgroundProcesses(rows, root) {
|
|
|
294
296
|
return started - rootStart >= 60_000;
|
|
295
297
|
});
|
|
296
298
|
}
|
|
299
|
+
/** Official native registries use Linux boot ticks and a PID namespace.
|
|
300
|
+
* Other OS registry birth formats require their own accepted adapter. */
|
|
301
|
+
export function readLinuxProcessRegistrationIdentity(pid) {
|
|
302
|
+
if (process.platform !== "linux")
|
|
303
|
+
return null;
|
|
304
|
+
try {
|
|
305
|
+
const start = processStartIdentity(pid, "linux");
|
|
306
|
+
const domain = fs.readlinkSync(`/proc/${pid}/ns/pid`);
|
|
307
|
+
if (!start?.startsWith("linux:") || !/^pid:\[\d+\]$/u.test(domain))
|
|
308
|
+
return null;
|
|
309
|
+
return { procStart: start.slice(6), pidDomain: `linux::${domain}` };
|
|
310
|
+
}
|
|
311
|
+
catch {
|
|
312
|
+
return null;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// OS process birth identity, shared by native ownership and runtime store.
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
import { resolveWindowsPowerShell7 } from "./windows-powershell.js";
|
|
5
|
+
export function processStartIdentity(pid, platform, timeoutMs = 1000) {
|
|
6
|
+
if (!Number.isInteger(pid) || pid < 1)
|
|
7
|
+
return null;
|
|
8
|
+
if (platform === "linux") {
|
|
9
|
+
try {
|
|
10
|
+
const stat = fs.readFileSync(`/proc/${pid}/stat`, "utf8");
|
|
11
|
+
const close = stat.lastIndexOf(")");
|
|
12
|
+
const fields = stat.slice(close + 2).split(" ");
|
|
13
|
+
return fields[19] ? `linux:${fields[19]}` : null;
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
if (platform === "win32") {
|
|
20
|
+
const script = "$p=Get-Process -Id $env:AITERMMCP_PROCESS_ID -ErrorAction Stop; $p.StartTime.ToUniversalTime().Ticks";
|
|
21
|
+
const result = spawnSync(resolveWindowsPowerShell7(), ["-NoLogo", "-NoProfile", "-NonInteractive", "-Command", script], {
|
|
22
|
+
encoding: "utf8", timeout: timeoutMs, maxBuffer: 4096, windowsHide: true,
|
|
23
|
+
env: { ...process.env, AITERMMCP_PROCESS_ID: String(pid) },
|
|
24
|
+
});
|
|
25
|
+
const value = result.status === 0 ? (result.stdout ?? "").trim() : "";
|
|
26
|
+
return /^\d+$/.test(value) ? `win32:${value}` : null;
|
|
27
|
+
}
|
|
28
|
+
// lstart の日付書式は LC_TIME で変わり、locale の違う観測者間で identity が割れる
|
|
29
|
+
// (caveat: ps-locale-lstart-lc-time-ascii-argv-lc-ctype-digest。Lattice 0.63.4 と同じ固定)
|
|
30
|
+
const result = spawnSync("ps", ["-o", "lstart=", "-p", String(pid)], {
|
|
31
|
+
encoding: "utf8", timeout: 1000, maxBuffer: 4096, env: { ...process.env, LC_ALL: "C" },
|
|
32
|
+
});
|
|
33
|
+
const value = result.status === 0 ? (result.stdout ?? "").trim() : "";
|
|
34
|
+
return value ? `${platform}:${value}` : null;
|
|
35
|
+
}
|
package/dist/runtime-error-os.js
CHANGED
|
@@ -5,7 +5,7 @@ import { spawn, spawnSync } from "node:child_process";
|
|
|
5
5
|
import * as fs from "node:fs";
|
|
6
6
|
import * as os from "node:os";
|
|
7
7
|
import * as path from "node:path";
|
|
8
|
-
import {
|
|
8
|
+
import { windowsPowerShell7Command } from "./windows-powershell.js";
|
|
9
9
|
export function defaultRuntimeErrorPaths(options = {}) {
|
|
10
10
|
const platform = options.platform ?? process.platform;
|
|
11
11
|
const home = options.home ?? os.homedir();
|
|
@@ -159,37 +159,7 @@ export function readBoundedFile(file, maxBytes, platform, requirePrivate) {
|
|
|
159
159
|
fs.closeSync(fd);
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
-
export
|
|
163
|
-
if (!Number.isInteger(pid) || pid < 1)
|
|
164
|
-
return null;
|
|
165
|
-
if (platform === "linux") {
|
|
166
|
-
try {
|
|
167
|
-
const stat = fs.readFileSync(`/proc/${pid}/stat`, "utf8");
|
|
168
|
-
const close = stat.lastIndexOf(")");
|
|
169
|
-
const fields = stat.slice(close + 2).split(" ");
|
|
170
|
-
return fields[19] ? `linux:${fields[19]}` : null;
|
|
171
|
-
}
|
|
172
|
-
catch {
|
|
173
|
-
return null;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
if (platform === "win32") {
|
|
177
|
-
const script = "$p=Get-Process -Id $env:AITERMMCP_PROCESS_ID -ErrorAction Stop; $p.StartTime.ToUniversalTime().Ticks";
|
|
178
|
-
const result = spawnSync(resolveWindowsPowerShell7(), ["-NoLogo", "-NoProfile", "-NonInteractive", "-Command", script], {
|
|
179
|
-
encoding: "utf8", timeout: timeoutMs, maxBuffer: 4096, windowsHide: true,
|
|
180
|
-
env: { ...process.env, AITERMMCP_PROCESS_ID: String(pid) },
|
|
181
|
-
});
|
|
182
|
-
const value = result.status === 0 ? (result.stdout ?? "").trim() : "";
|
|
183
|
-
return /^\d+$/.test(value) ? `win32:${value}` : null;
|
|
184
|
-
}
|
|
185
|
-
// lstart の日付書式は LC_TIME で変わり、locale の違う観測者間で identity が割れる
|
|
186
|
-
// (caveat: ps-locale-lstart-lc-time-ascii-argv-lc-ctype-digest。Lattice 0.63.4 と同じ固定)
|
|
187
|
-
const result = spawnSync("ps", ["-o", "lstart=", "-p", String(pid)], {
|
|
188
|
-
encoding: "utf8", timeout: 1000, maxBuffer: 4096, env: { ...process.env, LC_ALL: "C" },
|
|
189
|
-
});
|
|
190
|
-
const value = result.status === 0 ? (result.stdout ?? "").trim() : "";
|
|
191
|
-
return value ? `${platform}:${value}` : null;
|
|
192
|
-
}
|
|
162
|
+
export { processStartIdentity } from "./process-start.js";
|
|
193
163
|
export function forceKill(child) {
|
|
194
164
|
if (!Number.isSafeInteger(child.pid) || !child.pid)
|
|
195
165
|
return;
|
package/docs/DESIGN.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## 通常配送と停止
|
|
4
4
|
|
|
5
|
-
通常MCPの
|
|
5
|
+
通常MCPの19 toolsは既存のterminal/harnessへ直接渡す。execution graphへの登録、participant宣言、
|
|
6
6
|
shared writer lockの取得・待機を配送条件にしない。記録の欠測や旧lock fileで本文を拒否しない。
|
|
7
7
|
旧execution-native-serverのMCP互換入口も標準の配送handlerを使い、agent_stopだけを追加する。
|
|
8
8
|
agent_executionとagent_execution_rootsをこの入口へ登録しない。本体は旧ExecutionBridgeの先行登録を要求しない。
|
|
@@ -440,6 +440,7 @@ Codexが書いた種類は`error_kind`で返す。失敗を空の回答の完了
|
|
|
440
440
|
Cursorは、誤りで終わったturnを、記録の`turn_ended`へ`status: "error"`と文で書く。完了待ちは、利用上限の文を`rate_limited`、
|
|
441
441
|
席で止めたturn(`User aborted request`)を今までどおり`done`、ほかを`error`で返す。`error`は1行の文、文の頭の角括弧の名前は
|
|
442
442
|
`error_kind`で返す(ADR 0106)。判定と文の整え方は`src/harnesses/cursor.ts`が所有する。
|
|
443
|
+
Cursorの現在Error表示も同じharnessで解析し、完全なJSONの`error.code`が`prepaid_balance_exhausted`ならuser記録を待たずerrorへ進める。説明文のcodeや壊れたJSON、後続composer/busyを持つ旧表示は採用しない。stopの非busy保全は変更しない。
|
|
443
444
|
|
|
444
445
|
Grokのread-only sandbox起動拒否は、`src/harnesses/grok.ts`の
|
|
445
446
|
`assertGrokSandboxNotRejected`がCLIのエラー表示から検出する。`src/core.ts`の共通入力受付待機は
|
|
@@ -466,6 +467,7 @@ Grokの終了済みerrorターンにweekly-limit質問カードが残る場合
|
|
|
466
467
|
`grokRateLimitDialog`が見出しと操作footerの組を所有し、過去logや後続UIのあるカードは採用しない。
|
|
467
468
|
privacy案内は現在の枠付きcomposerとmodel footerが見える場合だけ入力受付を妨げない。
|
|
468
469
|
完了観測は成功eventを優先し、今回のerror eventと現在のカードが揃えばturn情報付きの`rate_limited`を返す。
|
|
470
|
+
Grokのerror eventが先に見え、上限panelがまだ無い場合、待機呼出しは既存の見回り一回分だけ後に現在panelを再確認する。上限が無ければ元のerrorを保ち、途中の次turn開始や元launch消失を再検査する。timeout=0の即時照会は待たない。遅い全描画の成功を保証せず、入力・provider要求を再送しない。
|
|
469
471
|
完了の見回りは100msで、画面を読む確認(利用上限の知らせ、Cursorのhook拒否の表示)は別の間隔で行う。画面を読むたびにtmuxを1回起動するため。
|
|
470
472
|
Claude・Grokは2秒、Cursorは1秒に1回で、待ちに入った最初の周回では必ず読む(ADR 0085)。
|
|
471
473
|
新turnの完了前に古いlogだけで上限を返さない。購入・再認証・過去prompt再送・定期再試行は行わない。
|
|
@@ -497,7 +499,7 @@ transcript、path、credentialを保存・公開しない。
|
|
|
497
499
|
旧設計draftは[`archive/01_design-plan.md`](https://github.com/kitepon/aiterm-mcp/blob/main/docs/archive/01_design-plan.md)に保存する。
|
|
498
500
|
|
|
499
501
|
|
|
500
|
-
Claude authentication URL receipts recognize the official claude.com/cai/oauth/authorize PKCE authorization request and its nonsecret code=true display flag. Callback authorization codes and tokens remain excluded; the common URL credential filter is unchanged.
|
|
502
|
+
Claude authentication URL receipts recognize the official claude.com/cai/oauth/authorize PKCE authorization request and its nonsecret code=true display flag. Callback authorization codes and tokens remain excluded; the common URL credential filter is unchanged.
|
|
501
503
|
|
|
502
504
|
|
|
503
505
|
### 認証画面と専用応答
|
|
@@ -510,3 +512,43 @@ respondは既session send lock内で現在の空欄/段階と世代を再検証
|
|
|
510
512
|
|
|
511
513
|
|
|
512
514
|
Claude authのcurrent menuはharnessの単一parseがphase/rows/selected/入力占有を所有する。古いthemeと新loginが同viewportに残っても最後の現在phaseだけを採り、coreはそのselected_idでnavigateする。code欄が現在phaseならoccupied状態から古いmenu UIへ戻さない。cursor欠測/複数cursor/未知row/後続の未知promptは入力前拒否。Native内部の入力観測は公開auth_uiへ直接返さず、公開schemaを拡張しない。
|
|
515
|
+
|
|
516
|
+
Authorization-code readback observes the same metadata generation for up to three seconds after one submission. A later redraw may establish a waiting or other recognized stage; it does not establish authenticated status by itself. An unchanged code prompt, replaced metadata generation or failed readback retains unknown without another input.
|
|
517
|
+
|
|
518
|
+
Authentication process exit observation reads the native exit status and signal independently of PTY EOF. If EOF is visible before either terminal field is ready, the same metadata generation is observed for a three-second window; missing status at the deadline remains unconfirmed failure. Signals and nonzero exits stay failures. Exit0 still requires the official authentication status, with a generation recheck after that call. A disappeared or replaced session, including a pane returning live after EOF, is not adopted. Observation never restarts login or repeats input.
|
|
519
|
+
|
|
520
|
+
## CLI-owned goal adapter
|
|
521
|
+
|
|
522
|
+
`agent-goal.ts` owns typed I/O, operation preconditions, host provenance, and result/readback distinctions. `harnesses/codex-goal.ts` maps these operations to the official goal protocol and verifies the loaded thread. `codex-goal-connection.ts` owns the POSIX native rendezvous alias checks; `codex-relay-client.ts` supplies the existing WebSocket request transport with explicit experimental opt-in. `core.agentGoal` binds the original session/launch/harness process and shares existing send admission. No goal state or continuation loop is stored by Aiterm.
|
|
523
|
+
|
|
524
|
+
The ordinary and native delivery server mount the same `agent_goal` tool. Host Owner authentication precedes the metadata `aiterm/goal: {origin:user}` on its existing local BellTeam connection; the marker only carries the host classification. The default model channel cannot mutate. The historical execution dispatcher recognizes the same action and retains its existing generation/effect gate without a separate ID or queue.
|
|
525
|
+
|
|
526
|
+
The initial operational scope is a live original launch bound to its native thread. No cold Bot launch, native thread resume, arbitrary thread selection, or manual conversation-switch inference is performed. Missing current binding remains unavailable. Host global pause must control native continuation separately from denying incoming HTTP actions.
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
The embedded CLI transport exposes inspect/pause/resume/clear plus budget-only editing. Optional field capabilities distinguish objective support from budget support; unsupported objective/mixed edits stop before any effect. A strict budget-only user request uses the official goal service, whose canonical budget is enforced by the original CLI worker. Objective/status mutations never fall through to a competing rollout writer. Native readback compares every requested field, including create's active status. The explicit whole-application stop plan shares one job per selected target and awaits only earlier descendants from its existing snapshot. Independent roots proceed concurrently; selected descendants complete pause and one key before parents. No extra goal ledger, queue, timeout reduction, or replay is introduced.
|
|
530
|
+
|
|
531
|
+
|
|
532
|
+
`harnesses/codex-goal-editor.ts` owns the native goal prompt state machine and styled-placeholder observations; core supplies only the existing PTY/read/key/admission ports. Native command preparation rejects an existing draft. Editor preparation confirms a cleared textarea, literal paste, then one Enter. A trusted no-submission error is used only before goal submission or after positively confirmed cancellation, and the goal manager refreshes native readback instead of restoring an earlier snapshot. Objective-only and budget-only fields are independent capabilities; combined updates remain disabled in the embedded transport.
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
Ordinary creation is a separate owner callback from objective editing. It sends bounded literal paste events below the official composer's attachment threshold, on the same guarded input channel. A native viewport can hide earlier rows; ordered input and current tail reflection establish readiness, while the full canonical objective and requested active status still determine success. Unsupported reserved objectives and budget-bearing creates never issue a placeholder goal or split an operation.
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
Goal input ownership is a read-only native precondition, separate from the ordinary prompt sender's optional foreground/termios recovery. The original PID/process group must be foreground and unstopped on the pinned pane TTY, with explicitly observed raw/no-echo flags. `paneTtyInputOwnerReady` shares existing TTY process classification; the goal UI ports and internal `beforePtyWrite` callback repeat this proof before input boundaries. Known refusal before input refreshes readback as not issued; ownership loss after input starts stays unknown. The goal path never sends fg, changes termios or erases another draft to satisfy the precondition.
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
Claude native goal inspection owns its TUI state machine and native attachment parsing in harnesses/claude-goal.ts. agent-goal-ui.ts supplies only the core-owned input ports; both native managers share exact original binding comparison. A fresh TUI dialog is authoritative; the stream CLI's local-command transcript is a separate native contract and is never presumed to exist in a TUI. Historical attachments alone cannot establish current null. The v2 branch carries the harness's native data; v1 Codex remains compatible. The MCP output has an object root and validates the tagged branch, retaining structured errors. Unsupported Claude pause/resume never query or mutate the TUI. No separate goal record or identifier is stored.
|
|
542
|
+
|
|
543
|
+
Claude's authorization-request code=true exception is vendor-owned and requires the official authorization path, response_type=code and S256 PKCE challenge. The common credential filter continues rejecting code parameters and tokens.
|
|
544
|
+
|
|
545
|
+
Claude clear uses the same host provenance and original binding comparison as Codex, with no delegated token or replacement worker. The harness owns one native command submission and composer readiness; the manager owns single-attempt mutation, fresh canonical dialog plus matching clear event, and unknown outcomes. The existing turn interruption path is not called by clear. Global stop continues reporting unsupported native Claude pause separately from the one existing stop-key receipt.
|
|
546
|
+
|
|
547
|
+
Claude objective changes reuse the native /goal setter after checking the current goal and trusted host origin. They do not emulate Codex pause/resume or numeric accounting. Representation checks bound the objective to a completely visible composer/dialog and reject reserved clear and ambiguous whitespace before submission. The shared native cell decoder preserves dim/inverse styling, letting each harness distinguish its own placeholders; Claude input interpretation and native state remain harness-owned. The same literal queued-input hint as a real draft is never considered empty solely by text.
|
|
548
|
+
|
|
549
|
+
|
|
550
|
+
Native Claude goal input also verifies the official per-PID current-session registration, including native session ID, process birth ticks and PID namespace before each input boundary. A switched conversation is refused before goal input; ownership loss after input remains unknown. No conversation is switched back automatically. This registration birth format is currently verified on Linux; unverified OS/registry data remains unavailable.
|
|
551
|
+
|
|
552
|
+
Grok 1.0.70 inspection verifies active_sessions.json against the original TUI PID, Linux birth ticks, cwd and vendor session. A fresh local /goal status update on that same session establishes null only with an absent state file, or an existing goal whose ID and exact objective remain stable across the query. The native persisted snapshot remains in goal.native; goal.current_status carries the separately parsed current status, phase, safe integer token count and original elapsed display. Resuming can leave persisted phase different from the live worker. Neither an old reply nor the snapshot supplies current values. A busy TUI queues the local slash command. The adapter does not send it on busy minimal views. An already fullscreen root view with a known Goal header and empty boxed composer instead permits native Goal-detail inspection. Core validates pane coordinates and the harness-provided current viewport predicate immediately before the bounded SGR pointer press/release, under the existing generation, PID-birth, current-session, TTY foreground/raw and native-admission checks. The harness uses string-width 7.2.0 display cells, requires the exact untruncated objective and stable native goal ID across the observation, then closes only its recognized modal with a current-row-checked key and confirms the empty composer. It neither switches modes nor stops a turn. The UI has rounded budget text and a phase label rather than an exact native phase/counter: the goal-detail current_status variant preserves those display strings while phase and tokens_used are null. Unknown views, existing drafts, moved hit targets and unavailable native ownership never trigger another input or a query through another leader. No leader, worker or conversation is created or resumed by product inspection.
|
|
553
|
+
|
|
554
|
+
Grok clear uses the existing host-origin contract and only a fresh UserPaused/Idle status and empty composer on the same original worker. The native manager advertises clear only with a freshly observed existing goal and confirmed input readiness. The harness verifies the same goal ID/objective before paste and immediately before Enter, and accepts only the current anchored completion menu for the exact command when minimal mode hides its model footer. Core repeats current viewport and native ownership checks under input admission. A single /goal clear requires a fresh same-session host-turn reply of Goal cleared. plus absent native state; the manager then reads a separate fresh no-goal status. A known pre-Enter refusal remains not_issued; uncertain input or missing/replaced readback removes the goal and capabilities and reports outcome_unknown. It never retries, restores a goal, interrupts a turn or routes to another worker. Other Grok mutations remain unsupported.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aiterm-mcp",
|
|
3
|
-
"version": "0.61.
|
|
3
|
+
"version": "0.61.21",
|
|
4
4
|
"mcpName": "io.github.kitepon/aiterm-mcp",
|
|
5
5
|
"description": "Persistent terminal MCP with one harness-based launcher for Claude Code, Codex CLI, Grok CLI, and Cursor Agent CLI, plus durable PTYs for SSH, containers, and REPLs.",
|
|
6
6
|
"keywords": [
|