agl 43.12.0 → 43.14.0
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 +17 -0
- package/dist_serve/bundle.js +188 -188
- package/dist_serve/bundle.js.map +2 -2
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/classes.mcpcallerregistry.d.ts +11 -9
- package/dist_ts/classes.mcpcallerregistry.js +10 -8
- package/dist_ts/classes.mcpclient.js +4 -3
- package/dist_ts/classes.mcpcontrollerhost.js +3 -2
- package/dist_ts/classes.opencodesupervisor.d.ts +1 -0
- package/dist_ts/classes.opencodesupervisor.js +5 -1
- package/dist_ts/classes.subtreecallers.d.ts +3 -2
- package/dist_ts/classes.subtreecallers.js +6 -5
- package/dist_ts/classes.terminalmanager.d.ts +8 -1
- package/dist_ts/classes.terminalmanager.js +8 -4
- package/dist_ts/classes.ticketstore.d.ts +5 -3
- package/dist_ts/classes.ticketstore.js +7 -2
- package/dist_ts/classes.workercallers.js +7 -6
- package/dist_ts/functions.deviceapi.js +5 -3
- package/dist_ts/functions.workerprocessproof.d.ts +12 -1
- package/dist_ts/functions.workerprocessproof.js +19 -7
- package/dist_ts/interfaces.opencode.d.ts +6 -0
- package/dist_ts_interfaces/tickets.d.ts +9 -1
- package/dist_ts_interfaces/tickets.js +11 -2
- package/package.json +1 -1
- package/readme.md +1 -1
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/classes.mcpcallerregistry.ts +16 -11
- package/ts/classes.mcpclient.ts +3 -2
- package/ts/classes.mcpcontrollerhost.ts +2 -1
- package/ts/classes.opencodesupervisor.ts +3 -0
- package/ts/classes.subtreecallers.ts +7 -6
- package/ts/classes.terminalmanager.ts +12 -3
- package/ts/classes.ticketstore.ts +11 -4
- package/ts/classes.workercallers.ts +5 -4
- package/ts/functions.deviceapi.ts +4 -2
- package/ts/functions.workerprocessproof.ts +24 -7
- package/ts/interfaces.opencode.ts +6 -0
- package/ts_interfaces/tickets.ts +12 -2
- package/ts_web/00_commitinfo_data.ts +1 -1
|
@@ -118,6 +118,15 @@ export const ticketPageErrorMessages = {
|
|
|
118
118
|
ticket_cursor_invalid: 'The cursor is not the nextCursor of a ticket page; list again without cursor.',
|
|
119
119
|
ticket_cursor_mismatch: 'The cursor pages other filters, another sort or another view; repeat those or list again without cursor.',
|
|
120
120
|
};
|
|
121
|
-
|
|
121
|
+
/**
|
|
122
|
+
* A ticket transaction that reached its deadline before its commit: the board stayed busy, nothing was changed, and the
|
|
123
|
+
* request may be made again. Kept apart from `ticketErrorMessages`, which the device contract lists code by code: a
|
|
124
|
+
* device reads it as `operation_limit`.
|
|
125
|
+
*/
|
|
126
|
+
export const ticketBusyErrorMessages = {
|
|
127
|
+
ticket_busy: 'The ticket board was too busy to carry out this request in time, and nothing was changed: read the ticket, then try again.',
|
|
128
|
+
};
|
|
129
|
+
export const ticketClientErrorMessages = Object.fromEntries(Object.entries({ ...ticketErrorMessages, ...ticketPageErrorMessages,
|
|
130
|
+
...ticketBusyErrorMessages })
|
|
122
131
|
.map(([codeArg, messageArg]) => [codeArg.toUpperCase(), messageArg]));
|
|
123
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
132
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGlja2V0cy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3RzX2ludGVyZmFjZXMvdGlja2V0cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxtRkFBbUY7QUFDbkYsTUFBTSxDQUFDLE1BQU0sYUFBYSxHQUFHO0lBQzNCLFNBQVMsRUFBRSxPQUFPLEVBQUUsYUFBYSxFQUFFLGFBQWEsRUFBRSxRQUFRLEVBQUUsUUFBUSxFQUFFLFVBQVUsRUFBRSxRQUFRO0NBQ2xGLENBQUM7QUFFWCwwREFBMEQ7QUFDMUQsTUFBTSxDQUFDLE1BQU0saUJBQWl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0lBQy9PLHFCQUFxQixFQUFFLCtHQUErRztJQUN0SSxvQkFBb0IsRUFBRSw4R0FBOEc7SUFDcEksb0JBQW9CLEVBQUUsK0VBQStFO0lBQ3JHLHVCQUF1QixFQUFFLDJEQUEyRDtJQUNwRix5QkFBeUIsRUFBRSx1REFBdUQ7SUFDbEYsd0JBQXdCLEVBQUUsc0RBQXNEO0lBQ2hGLHdCQUF3QixFQUFFLHNHQUFzRztJQUNoSSxxQkFBcUIsRUFBRSxxSEFBcUg7Q0FDcEksQ0FBQztBQUNYOzs7R0FHRztBQUNILE1BQU0sQ0FBQyxNQUFNLHVCQUF1QixHQUFHO0lBQ3JDLHFCQUFxQixFQUFFLCtFQUErRTtJQUN0RyxzQkFBc0IsRUFBRSwwR0FBMEc7Q0FDMUgsQ0FBQztBQUNYOzs7O0dBSUc7QUFDSCxNQUFNLENBQUMsTUFBTSx1QkFBdUIsR0FBRztJQUNyQyxXQUFXLEVBQUUsNEhBQTRIO0NBQ2pJLENBQUM7QUFHWCxNQUFNLENBQUMsTUFBTSx5QkFBeUIsR0FBRyxNQUFNLENBQUMsV0FBVyxDQUFDLE1BQU0sQ0FBQyxPQUFPLENBQUMsRUFBRSxHQUFHLG1CQUFtQixFQUFFLEdBQUcsdUJBQXVCO0lBQzdILEdBQUcsdUJBQXVCLEVBQUUsQ0FBQztLQUM1QixHQUFHLENBQUMsQ0FBQyxDQUFDLE9BQU8sRUFBRSxVQUFVLENBQUMsRUFBRSxFQUFFLENBQUMsQ0FBQyxPQUFPLENBQUMsV0FBVyxFQUFFLEVBQUUsVUFBVSxDQUFDLENBQUMsQ0FBMkMsQ0FBQyJ9
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -1210,7 +1210,7 @@ Some state lives only in the MCP process, and a re-exec would lose it. While the
|
|
|
1210
1210
|
|
|
1211
1211
|
Every MCP call carries the identity of the chat it serves, and the controller authorizes on that identity instead of on a task id supplied in the request. When AGL starts a chat it mints a per-start caller credential and writes it into that process's environment as `AGL_MCP_CALLER_CREDENTIAL`; the `agl mcp` server the chat launches reads it from the environment and presents it on the private endpoint. The credential is never an argument, never forwarded through any other environment AGL builds, never persisted, never logged, and never echoed in a response. It dies with the chat: a terminal exit, a task losing its exact managed identity, an OpenCode restart, or controller shutdown all revoke it, and the next start mints a new one.
|
|
1212
1212
|
|
|
1213
|
-
Inside a terminal, and under the OpenCode server, every process inherits the credential: the `agl mcp` servers OpenCode starts, the commands its tasks run, and a daemon started from either that outlives its parent as well (Claude Code's background-job daemon, for one). So a terminal's or the OpenCode runtime's credential is honoured only for a process that still runs inside the process tree it was written into: the start records that tree's root process (the terminal's PTY child, the OpenCode server) by its process ID and start time; before each call the `agl mcp` server names its own process ID to the controller (the process enrollment fleet workers use, see [Fleet workers and watch](#fleet-workers-and-watch)); and a call carries the credential's identity only when that process holds the call's own loopback connection and the recorded root process, still the same one, is among its ancestors, read from the kernel at that call. A daemon that left the tree (whose parent is now init), a process that never ran in it, a process naming another process's ID, and every process once the root process is gone call without an identity, exactly as with an unknown credential; an OpenCode restart records the new server with a new credential. A Claude Code background job started from a terminal or by an OpenCode task therefore calls as the fleet worker that binds it, if any, and otherwise anonymously.
|
|
1213
|
+
Inside a terminal, and under the OpenCode server, every process inherits the credential: the `agl mcp` servers OpenCode starts, the commands its tasks run, and a daemon started from either that outlives its parent as well (Claude Code's background-job daemon, for one). So a terminal's or the OpenCode runtime's credential, like every caller credential AGL writes into an environment, is honoured only for a process that still runs inside the process tree it was written into: the start records that tree's root process (the terminal's PTY child, the OpenCode server) by its process ID and start time; before each call the `agl mcp` server names its own process ID to the controller (the process enrollment fleet workers use, see [Fleet workers and watch](#fleet-workers-and-watch)); and a call carries the credential's identity only when that process holds the call's own loopback connection and the recorded root process, still the same one, is among its ancestors, read from the kernel at that call. A daemon that left the tree (whose parent is now init), a process that never ran in it, a process naming another process's ID, and every process once the root process is gone call without an identity, exactly as with an unknown credential; an OpenCode restart records the new server with a new credential. When a start cannot record its terminal's or server's process, the controller logs one line saying so, because every call through that credential is then anonymous until the next start. A Claude Code background job started from a terminal or by an OpenCode task therefore calls as the fleet worker that binds it, if any, and otherwise anonymously.
|
|
1214
1214
|
|
|
1215
1215
|
A caller is one of three subjects:
|
|
1216
1216
|
|
package/ts/00_commitinfo_data.ts
CHANGED
|
@@ -11,10 +11,11 @@ import {
|
|
|
11
11
|
* process is a controller child — terminals, the OpenCode server — so no credential can outlive
|
|
12
12
|
* the controller generation that minted it, and nothing here belongs in persistence.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
* records the process
|
|
16
|
-
* inherits the credential, a daemon that leaves its
|
|
17
|
-
* process that still descends from
|
|
14
|
+
* Every credential `mint` makes is bound to a process subtree: the spawn that carries it in its
|
|
15
|
+
* environment (a terminal's, the OpenCode runtime's) records the process it started once it runs
|
|
16
|
+
* (`bindProcess`), every process started under it inherits the credential, a daemon that leaves its
|
|
17
|
+
* tree as well, and admission honours it only for a process that still descends from that record
|
|
18
|
+
* (AGL-1891, AGL-1972, AGL-1976). Only a fleet worker's credential (`mintWorker`) is proved otherwise.
|
|
18
19
|
*
|
|
19
20
|
* A credential is secret material. It never reaches audit records, error text, responses or logs:
|
|
20
21
|
* only the derived {@link IControllerMcpCaller.auditPeerId} does, and that is a one-way digest.
|
|
@@ -62,13 +63,16 @@ export interface IControllerMcpCallerProcess {
|
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
/**
|
|
65
|
-
* The subjects
|
|
66
|
-
*
|
|
66
|
+
* The subjects a credential is bound to a process subtree for: every subject but the anonymous caller and a fleet
|
|
67
|
+
* worker, whose launch is proved against its own job. AGL writes such a credential into the environment of a process it
|
|
68
|
+
* spawns (today a terminal's PTY child and the OpenCode server), every process started under it inherits it, so it is
|
|
69
|
+
* honoured only inside that process's tree. A subject kind added later is bound so too unless it is excluded here
|
|
70
|
+
* (AGL-1976).
|
|
67
71
|
*/
|
|
68
|
-
export type TControllerMcpSubtreeSubject =
|
|
72
|
+
export type TControllerMcpSubtreeSubject = Exclude<TControllerMcpSubject, { kind: 'anonymous' | 'worker_launch' }>;
|
|
69
73
|
|
|
70
74
|
export const isControllerMcpSubtreeSubject = (subjectArg: TControllerMcpSubject): subjectArg is TControllerMcpSubtreeSubject => (
|
|
71
|
-
subjectArg.kind
|
|
75
|
+
subjectArg.kind !== 'anonymous' && subjectArg.kind !== 'worker_launch'
|
|
72
76
|
);
|
|
73
77
|
|
|
74
78
|
interface ICallerEntry {
|
|
@@ -81,7 +85,8 @@ interface ICallerEntry {
|
|
|
81
85
|
export class ControllerMcpCallerRegistry {
|
|
82
86
|
private readonly callersByCredentialKey = new Map<string, ICallerEntry>();
|
|
83
87
|
|
|
84
|
-
|
|
88
|
+
/** A credential honoured only inside the process subtree its spawn records with `bindProcess`, and for no process until then. */
|
|
89
|
+
public mint(subjectArg: TControllerMcpSubtreeSubject): string {
|
|
85
90
|
return this.store(subjectArg);
|
|
86
91
|
}
|
|
87
92
|
|
|
@@ -110,7 +115,7 @@ export class ControllerMcpCallerRegistry {
|
|
|
110
115
|
/**
|
|
111
116
|
* Records the process a spawn started with `credentialArg` in its environment (a terminal's PTY child, the OpenCode
|
|
112
117
|
* server) as the root of the tree that credential is honoured inside (AGL-1891, AGL-1972). Until it is made, the
|
|
113
|
-
* credential is honoured for no process; a revoked credential, or
|
|
118
|
+
* credential is honoured for no process; a revoked credential, or a fleet worker's, records nothing.
|
|
114
119
|
*/
|
|
115
120
|
public bindProcess(credentialArg: string, processArg: IControllerMcpCallerProcess): void {
|
|
116
121
|
const entry = this.callersByCredentialKey.get(credentialKey(credentialArg));
|
|
@@ -118,7 +123,7 @@ export class ControllerMcpCallerRegistry {
|
|
|
118
123
|
entry.process = Object.freeze({ pid: processArg.pid, startTicks: processArg.startTicks });
|
|
119
124
|
}
|
|
120
125
|
|
|
121
|
-
/** The root process a subtree subject's credential is honoured inside, once its spawn recorded it; nothing for
|
|
126
|
+
/** The root process a subtree subject's credential is honoured inside, once its spawn recorded it; nothing for a fleet worker's or a revoked one. */
|
|
122
127
|
public boundProcess(credentialArg: string): IControllerMcpCallerProcess | undefined {
|
|
123
128
|
const entry = this.callersByCredentialKey.get(credentialKey(credentialArg));
|
|
124
129
|
return entry && isControllerMcpSubtreeSubject(entry.caller.subject) ? entry.process : undefined;
|
package/ts/classes.mcpclient.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { TWorkerCallerEnrollment, IWorkerCallerEnrollmentResponse } from '.
|
|
|
6
6
|
import type { IControllerMcpWireCaller } from '../ts_interfaces/mcprequests.js';
|
|
7
7
|
import type { TFleetOperation, TFleetRequest, TFleetResult, IFleetOperation } from '../ts_interfaces/fleet.js';
|
|
8
8
|
import { assertFleetOperation, assertFleetWireRequest } from './fleet/functions.validation.js';
|
|
9
|
-
import { readTicketRevisionConflict, ticketErrorMessages, ticketPageErrorMessages, type TTicketClientErrorCode, type TTicketOperation, type TTicketRequest, type TTicketResponse } from '../ts_interfaces/tickets.js';
|
|
9
|
+
import { readTicketRevisionConflict, ticketBusyErrorMessages, ticketErrorMessages, ticketPageErrorMessages, type TTicketClientErrorCode, type TTicketOperation, type TTicketRequest, type TTicketResponse } from '../ts_interfaces/tickets.js';
|
|
10
10
|
import { assertMcpTicketRequest, assertTicketResponse } from './functions.ticketvalidation.js';
|
|
11
11
|
import { assertSessionFeedWireRequest, assertSessionFeedWireResponse } from './functions.sessionfeedvalidation.js';
|
|
12
12
|
import { assertFleetDeployResponse, assertFleetDeployWireRequest } from './fleet/functions.deployvalidation.js';
|
|
@@ -1022,7 +1022,8 @@ export class ControllerMcpClient {
|
|
|
1022
1022
|
const conflict = readTicketRevisionConflict(decoded.error.data);
|
|
1023
1023
|
if (serverCode === 'ticket_revision_conflict' && !conflict) throw new Error('Invalid conflict metadata.');
|
|
1024
1024
|
currentRevision = conflict?.currentRevision;
|
|
1025
|
-
if (typeof serverCode === 'string' && (Object.hasOwn(ticketErrorMessages, serverCode) || Object.hasOwn(ticketPageErrorMessages, serverCode)
|
|
1025
|
+
if (typeof serverCode === 'string' && (Object.hasOwn(ticketErrorMessages, serverCode) || Object.hasOwn(ticketPageErrorMessages, serverCode)
|
|
1026
|
+
|| Object.hasOwn(ticketBusyErrorMessages, serverCode))) code = serverCode.toUpperCase() as TTicketClientErrorCode;
|
|
1026
1027
|
if (serverCode === 'controller_unavailable') code = 'CONTROLLER_UNAVAILABLE';
|
|
1027
1028
|
if (serverCode === 'authentication_failed') code = 'AUTHENTICATION_FAILED';
|
|
1028
1029
|
if (serverCode === 'response_limit') code = 'RESPONSE_LIMIT';
|
|
@@ -34,7 +34,7 @@ import { controllerMcpDeployMethods, type TControllerMcpDeployMethod, type TCont
|
|
|
34
34
|
import { controllerMcpPushMethods, pushErrorCodes, type TControllerMcpPushMethod, type TControllerMcpPushTypedRequest } from '../ts_interfaces/push.js';
|
|
35
35
|
import { redactPushRequest } from './functions.pushwire.js';
|
|
36
36
|
import { deployErrorCodes } from './fleet/classes.deploymonitor.js';
|
|
37
|
-
import { readTicketRevisionConflict, ticketErrorMessages, ticketPageErrorMessages, type TTicketOperation, type TTicketRequest, type TTicketResponse } from '../ts_interfaces/tickets.js';
|
|
37
|
+
import { readTicketRevisionConflict, ticketBusyErrorMessages, ticketErrorMessages, ticketPageErrorMessages, type TTicketOperation, type TTicketRequest, type TTicketResponse } from '../ts_interfaces/tickets.js';
|
|
38
38
|
import { ticketOperation } from './functions.ticketvalidation.js';
|
|
39
39
|
import { controllerFailureJournal } from './classes.failurejournal.js';
|
|
40
40
|
import { configurationErrorCodes } from './configuration/classes.configurationerror.js';
|
|
@@ -324,6 +324,7 @@ const safeTypedResponseError = (
|
|
|
324
324
|
const messages: Record<string, string> = {
|
|
325
325
|
...ticketErrorMessages,
|
|
326
326
|
...ticketPageErrorMessages,
|
|
327
|
+
...ticketBusyErrorMessages,
|
|
327
328
|
controller_unavailable: 'The controller is not ready to accept this operation.',
|
|
328
329
|
operation_limit: 'The controller is busy. Try again after current operations settle.',
|
|
329
330
|
rate_limited: 'The authenticated operation rate limit was reached.',
|
|
@@ -610,6 +610,7 @@ export class OpenCodeSupervisor {
|
|
|
610
610
|
private readonly onChildExitObserved?: () => void;
|
|
611
611
|
private readonly mintCallerCredential?: () => string | undefined;
|
|
612
612
|
private readonly recordCallerProcess?: IOpenCodeSupervisorOptions['recordCallerProcess'];
|
|
613
|
+
private readonly log: (lineArg: string) => void;
|
|
613
614
|
private readonly onChildExit?: () => void;
|
|
614
615
|
|
|
615
616
|
private state: IOpenCodeSupervisorStatus['state'] = 'stopped';
|
|
@@ -709,6 +710,7 @@ export class OpenCodeSupervisor {
|
|
|
709
710
|
this.onChildExitObserved = options.onChildExitObserved;
|
|
710
711
|
this.mintCallerCredential = options.mintCallerCredential;
|
|
711
712
|
this.recordCallerProcess = options.recordCallerProcess;
|
|
713
|
+
this.log = options.log ?? ((lineArg) => console.warn(lineArg));
|
|
712
714
|
this.onChildExit = options.onChildExit;
|
|
713
715
|
this.password = plugins.crypto.randomBytes(32).toString('base64url');
|
|
714
716
|
this.executablePath = this.resolveExecutablePath();
|
|
@@ -924,6 +926,7 @@ export class OpenCodeSupervisor {
|
|
|
924
926
|
// Read right after the spawn, only as this controller's own child; a server that already exited records nothing.
|
|
925
927
|
const server = await readControllerChildProcess(child.pid);
|
|
926
928
|
if (server) this.recordCallerProcess({ credential: callerCredential, process: server });
|
|
929
|
+
else this.log(`The OpenCode server (PID ${child.pid}) could not be recorded as this controller's own child: its MCP calls are anonymous until its next start.`);
|
|
927
930
|
}
|
|
928
931
|
|
|
929
932
|
const deadline = Date.now() + this.startupTimeoutMs;
|
|
@@ -2,8 +2,8 @@ import {
|
|
|
2
2
|
anonymousControllerMcpCaller, type ControllerMcpCallerRegistry, type IControllerMcpCallerProcess,
|
|
3
3
|
} from './classes.mcpcallerregistry.js';
|
|
4
4
|
import {
|
|
5
|
-
isWorkerCallerProofRefusal,
|
|
6
|
-
type IWorkerProcessSnapshot,
|
|
5
|
+
isWorkerCallerProofRefusal, readWorkerProcessIdentity, type proveConnectionProcessAncestry, type IWorkerCallerConnection,
|
|
6
|
+
type IWorkerProcessIdentity, type IWorkerProcessSnapshot,
|
|
7
7
|
} from './functions.workerprocessproof.js';
|
|
8
8
|
import type { IControllerMcpCaller } from '../ts_interfaces/index.js';
|
|
9
9
|
|
|
@@ -20,12 +20,13 @@ const sameProcess = (leftArg: IControllerMcpCallerProcess, rightArg: IController
|
|
|
20
20
|
/**
|
|
21
21
|
* The process a spawn whose environment carries a caller credential just started, read from the kernel right after the
|
|
22
22
|
* spawn, only while it is this controller's own child: the root of the tree that credential is honoured inside
|
|
23
|
-
* (AGL-1891, AGL-1972).
|
|
24
|
-
*
|
|
23
|
+
* (AGL-1891, AGL-1972). It is read by what `exec` leaves unchanged (PID, parent, start), never by its arguments or
|
|
24
|
+
* executable, which a PTY child may still be replacing when it is read (AGL-1995). Nothing for a child that already
|
|
25
|
+
* exited, or for a process another one started. Only an unexpected failure to read it throws.
|
|
25
26
|
*/
|
|
26
27
|
export const readControllerChildProcess = async (pidArg: number): Promise<IControllerMcpCallerProcess | undefined> => {
|
|
27
|
-
let child:
|
|
28
|
-
try { child = await
|
|
28
|
+
let child: IWorkerProcessIdentity;
|
|
29
|
+
try { child = await readWorkerProcessIdentity(pidArg); } catch (errorArg) {
|
|
29
30
|
if (isWorkerCallerProofRefusal(errorArg)) return undefined;
|
|
30
31
|
throw errorArg;
|
|
31
32
|
}
|
|
@@ -143,6 +143,12 @@ export interface IControllerTerminalManagerOptions {
|
|
|
143
143
|
credential: string;
|
|
144
144
|
process: IControllerMcpCallerProcess;
|
|
145
145
|
}) => void;
|
|
146
|
+
/**
|
|
147
|
+
* Takes the manager's own diagnostic lines (never terminal output): one when a start minted a caller credential but
|
|
148
|
+
* could not record its PTY child, so every MCP call through that credential is anonymous until the terminal starts
|
|
149
|
+
* again (AGL-1976). `console.warn` by default.
|
|
150
|
+
*/
|
|
151
|
+
log?: (lineArg: string) => void;
|
|
146
152
|
/**
|
|
147
153
|
* Starts a Claude chat's use of the provider pool it runs on (`IControllerTerminalAgentMetadata.provider`) through
|
|
148
154
|
* AGL's inference proxy. Without it, a chat on a pool does not start.
|
|
@@ -442,6 +448,7 @@ export class ControllerTerminalManager {
|
|
|
442
448
|
private readonly ptySpawner: IControllerPtySpawner;
|
|
443
449
|
private readonly resolveShell: () => Promise<IControllerTerminalShell>;
|
|
444
450
|
private readonly cleanupTimeoutMs: number;
|
|
451
|
+
private readonly log: (lineArg: string) => void;
|
|
445
452
|
private readonly outputRetryBackoffMs: readonly number[];
|
|
446
453
|
private readonly entries = new Map<string, ITerminalEntry>();
|
|
447
454
|
private readonly projectStates = new Map<string, IProjectAdmissionState>();
|
|
@@ -462,6 +469,7 @@ export class ControllerTerminalManager {
|
|
|
462
469
|
});
|
|
463
470
|
this.resolveShell = options.resolveShell ?? (() => resolveControllerTerminalShell());
|
|
464
471
|
this.cleanupTimeoutMs = options.cleanupTimeoutMs ?? defaultCleanupTimeoutMs;
|
|
472
|
+
this.log = options.log ?? ((lineArg) => console.warn(lineArg));
|
|
465
473
|
if (
|
|
466
474
|
!Number.isSafeInteger(this.cleanupTimeoutMs)
|
|
467
475
|
|| this.cleanupTimeoutMs < 1
|
|
@@ -835,7 +843,7 @@ export class ControllerTerminalManager {
|
|
|
835
843
|
}
|
|
836
844
|
if (callerCredential !== undefined) {
|
|
837
845
|
try {
|
|
838
|
-
await this.recordCallerProcess(callerCredential, execution.ptyProcess.pid);
|
|
846
|
+
await this.recordCallerProcess(callerCredential, execution.ptyProcess.pid, inputArg.terminalNativeId);
|
|
839
847
|
} catch (errorArg) {
|
|
840
848
|
await this.closeEntry(createdEntry, Date.now() + this.cleanupTimeoutMs);
|
|
841
849
|
throw errorArg;
|
|
@@ -848,12 +856,13 @@ export class ControllerTerminalManager {
|
|
|
848
856
|
/**
|
|
849
857
|
* Records this start's PTY child as the process its caller credential `credentialArg` is honoured inside (AGL-1891):
|
|
850
858
|
* read once from the kernel right after the spawn, and only while it is this controller's own child. A child that
|
|
851
|
-
* already exited is not recorded, which leaves the credential honoured for no process.
|
|
859
|
+
* already exited is not recorded, which leaves the credential honoured for no process, and says so in one line.
|
|
852
860
|
*/
|
|
853
|
-
private async recordCallerProcess(credentialArg: string, pidArg: number): Promise<void> {
|
|
861
|
+
private async recordCallerProcess(credentialArg: string, pidArg: number, terminalNativeIdArg: string): Promise<void> {
|
|
854
862
|
if (!this.options.recordCallerProcess) return;
|
|
855
863
|
const child = await readControllerChildProcess(pidArg);
|
|
856
864
|
if (child) this.options.recordCallerProcess({ credential: credentialArg, process: child });
|
|
865
|
+
else this.log(`The PTY child (PID ${pidArg}) of terminal ${terminalNativeIdArg} could not be recorded as this controller's own child: its MCP calls are anonymous until the terminal starts again.`);
|
|
857
866
|
}
|
|
858
867
|
|
|
859
868
|
/** OSC titles are untrusted display metadata: bounded, coalesced and never persisted. */
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
type TTicketLink, type TTicketOperation, type TTicketRequest, type TTicketResponse,
|
|
6
6
|
type TTicketFleetEvent, type ITicketFleetEventResult, type ITicketComment, type TTicketData, type ITicketOpenQuestion, type TTicketAutoLabel,
|
|
7
7
|
type ITicketDetail, type ITicketGet, type ITicketAsk, type ITicketMaintenanceWindow, ticketHistoryPage,
|
|
8
|
-
type ITicketOverviewRequest, type ITicketPageRequest, ticketPageErrorMessages,
|
|
8
|
+
type ITicketOverviewRequest, type ITicketPageRequest, ticketPageErrorMessages, ticketBusyErrorMessages,
|
|
9
9
|
} from '../ts_interfaces/tickets.js';
|
|
10
10
|
import { TicketCursorError, ticketOverview, ticketPage } from './functions.ticketlisting.js';
|
|
11
11
|
import {
|
|
@@ -71,10 +71,12 @@ interface ITicketTrack {
|
|
|
71
71
|
/**
|
|
72
72
|
* Every code a `TicketError` carries: a refusal `ticketErrorMessages` explains, a concurrent change the transaction
|
|
73
73
|
* lost (`concurrent_change`, nothing written), a transaction whose commit outcome is unknown (`outcome_unknown`), a
|
|
74
|
-
* fleet event key that names another request, and an owner capability the controller could not verify.
|
|
74
|
+
* fleet event key that names another request, and an owner capability the controller could not verify. A transaction
|
|
75
|
+
* that reached its deadline before its commit is `ticket_busy` (`ticketBusyErrorMessages`): nothing was written, and the
|
|
76
|
+
* request may be made again.
|
|
75
77
|
*/
|
|
76
|
-
export type TTicketErrorCode = keyof typeof ticketErrorMessages | keyof typeof ticketPageErrorMessages
|
|
77
|
-
| 'ticket_fleet_event_conflict' | 'unauthorized';
|
|
78
|
+
export type TTicketErrorCode = keyof typeof ticketErrorMessages | keyof typeof ticketPageErrorMessages
|
|
79
|
+
| keyof typeof ticketBusyErrorMessages | 'concurrent_change' | 'outcome_unknown' | 'ticket_fleet_event_conflict' | 'unauthorized';
|
|
78
80
|
|
|
79
81
|
export class TicketError extends Error {
|
|
80
82
|
constructor(public readonly code: TTicketErrorCode, messageArg: string, public readonly currentRevision?: number) {
|
|
@@ -481,6 +483,11 @@ export class TicketStore {
|
|
|
481
483
|
if (plugins.nosqldb.SmartdataSession.getCommitOutcome(errorArg) !== 'not_committed') {
|
|
482
484
|
throw new TicketError('outcome_unknown', 'The ticket transaction outcome is unknown; read the board before retrying.');
|
|
483
485
|
}
|
|
486
|
+
// The deadline expired before the commit: the board stayed busy (lost write conflicts or a slow database) and
|
|
487
|
+
// nothing was written, so the request may be made again. A cancellation and a store shutdown keep their errors.
|
|
488
|
+
if (errorArg instanceof plugins.nosqldb.SmartdataPersistenceError && errorArg.code === 'timeout') {
|
|
489
|
+
throw new TicketError('ticket_busy', ticketBusyErrorMessages.ticket_busy);
|
|
490
|
+
}
|
|
484
491
|
if (errorArg instanceof TicketError && errorArg.code === 'ticket_revision_conflict' && track?.refusal) {
|
|
485
492
|
this.observe({ changes: [track.refusal] });
|
|
486
493
|
}
|
|
@@ -390,13 +390,14 @@ export class ControllerWorkerCallers implements IFleetWorkerCallerHooks {
|
|
|
390
390
|
public async admit(wireArg: IControllerMcpWireCaller | undefined, connectionArg?: IWorkerCallerConnection): Promise<IWorkerCallerLease> {
|
|
391
391
|
const caller = this.options.registry.resolve(wireArg?.credential);
|
|
392
392
|
const release = () => undefined;
|
|
393
|
-
|
|
394
|
-
//
|
|
395
|
-
//
|
|
393
|
+
if (caller.subject.kind === 'anonymous') return { caller: anonymousControllerMcpCaller, release };
|
|
394
|
+
// Every credential but a fleet worker's (a terminal's, the OpenCode runtime's, any kind added later) is inherited by
|
|
395
|
+
// every process started under the process its spawn started, daemons that leave that tree too: it is honoured only for
|
|
396
|
+
// a bridge that runs inside the tree, proved for this call, and never on the credential alone (AGL-1891, AGL-1972,
|
|
397
|
+
// AGL-1976).
|
|
396
398
|
if (isControllerMcpSubtreeSubject(caller.subject)) {
|
|
397
399
|
return { caller: wireArg ? await this.subtrees.admit(wireArg.credential, caller, connectionArg) : anonymousControllerMcpCaller, release };
|
|
398
400
|
}
|
|
399
|
-
if (caller.subject.kind !== 'worker_launch') return { caller, release };
|
|
400
401
|
const subject = caller.subject;
|
|
401
402
|
const record = this.launches.get(subject.launchId);
|
|
402
403
|
const registered = record && [...record.credentials.values()].find(value => value.credential === wireArg?.credential);
|
|
@@ -447,12 +447,14 @@ export const deviceDirectReportJobRefusal = (jobArg: IFleetWorkerJob): plugins.t
|
|
|
447
447
|
/**
|
|
448
448
|
* How the ticket store's refusals outside `ticketErrorMessages` reach a device: a concurrent change the transaction lost
|
|
449
449
|
* wrote nothing and reads as the board having changed meanwhile; a commit whose outcome is unknown may have happened,
|
|
450
|
-
* which a client never resends but reads the ticket again to learn; a
|
|
451
|
-
* controller
|
|
450
|
+
* which a client never resends but reads the ticket again to learn; a transaction that reached its deadline before its
|
|
451
|
+
* commit (`ticket_busy`) changed nothing and reads as the controller being busy, to be tried again; a fleet event's
|
|
452
|
+
* conflict and an owner capability the controller could not verify answer no device request.
|
|
452
453
|
*/
|
|
453
454
|
const deviceTicketStoreRefusals: Readonly<Record<Exclude<TTicketErrorCode, keyof typeof ticketErrorMessages>, TDeviceRefusalCode>> = {
|
|
454
455
|
concurrent_change: 'ticket_revision_conflict',
|
|
455
456
|
outcome_unknown: 'outcome_unknown',
|
|
457
|
+
ticket_busy: 'operation_limit',
|
|
456
458
|
ticket_fleet_event_conflict: 'invalid_request',
|
|
457
459
|
unauthorized: 'invalid_request',
|
|
458
460
|
ticket_cursor_invalid: 'invalid_request',
|
|
@@ -19,10 +19,14 @@ export interface IWorkerCallerConnection {
|
|
|
19
19
|
encrypted: boolean;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
/** A process as `exec` leaves it: its PID, its parent and its start time in clock ticks. */
|
|
23
|
+
export interface IWorkerProcessIdentity {
|
|
23
24
|
pid: number;
|
|
24
25
|
parentPid: number;
|
|
25
26
|
startTicks: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface IWorkerProcessSnapshot extends IWorkerProcessIdentity {
|
|
26
30
|
executable: string;
|
|
27
31
|
arguments: string[];
|
|
28
32
|
}
|
|
@@ -33,7 +37,14 @@ export interface IWorkerBridgeCommand {
|
|
|
33
37
|
arguments: string[];
|
|
34
38
|
}
|
|
35
39
|
|
|
36
|
-
|
|
40
|
+
/**
|
|
41
|
+
* A live process of the controller user, by what stays the same across `exec`: its PID, parent and start. Unlike
|
|
42
|
+
* {@link readWorkerProcessSnapshot} it reads no arguments, so it answers for a process in the middle of an `exec` too: from
|
|
43
|
+
* the moment the kernel installs the new program's memory until it has laid out that program's arguments,
|
|
44
|
+
* `/proc/<pid>/cmdline` reads empty. A child `forkpty` just started is often in exactly that window, because its parent
|
|
45
|
+
* returns without waiting for the `exec` (`child_process.spawn` waits for it) (AGL-1995).
|
|
46
|
+
*/
|
|
47
|
+
export const readWorkerProcessIdentity = async (pidArg: number): Promise<IWorkerProcessIdentity> => {
|
|
37
48
|
if (process.platform !== 'linux' || !Number.isSafeInteger(pidArg) || pidArg < 1) {
|
|
38
49
|
throw new WorkerCallerProofError('Worker process attestation requires a live Linux process.');
|
|
39
50
|
}
|
|
@@ -43,16 +54,22 @@ export const readWorkerProcessSnapshot = async (pidArg: number): Promise<IWorker
|
|
|
43
54
|
if (['Z', 'X', 'x'].includes(fields[0]) || !/^\d+$/u.test(fields[19] ?? '')) {
|
|
44
55
|
throw new WorkerCallerProofError('Worker process attestation failed.');
|
|
45
56
|
}
|
|
46
|
-
const argumentsBuffer = await plugins.fs.promises.readFile(`${root}/cmdline`);
|
|
47
|
-
if (argumentsBuffer.length === 0 || argumentsBuffer.length > 256 * 1024) {
|
|
48
|
-
throw new WorkerCallerProofError('Worker process arguments are unavailable.');
|
|
49
|
-
}
|
|
50
57
|
const status = await plugins.fs.promises.readFile(`${root}/status`, 'utf8');
|
|
51
58
|
const user = /^Uid:\s+(\d+)\s+(\d+)/mu.exec(status);
|
|
52
59
|
if (!user || Number(user[1]) !== process.getuid?.() || Number(user[2]) !== process.getuid?.()) {
|
|
53
60
|
throw new WorkerCallerProofError('Worker process does not belong to the controller user.');
|
|
54
61
|
}
|
|
55
|
-
return { pid: pidArg, parentPid: Number(fields[1]), startTicks: fields[19]
|
|
62
|
+
return { pid: pidArg, parentPid: Number(fields[1]), startTicks: fields[19] };
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const readWorkerProcessSnapshot = async (pidArg: number): Promise<IWorkerProcessSnapshot> => {
|
|
66
|
+
const identity = await readWorkerProcessIdentity(pidArg);
|
|
67
|
+
const root = `/proc/${pidArg}`;
|
|
68
|
+
const argumentsBuffer = await plugins.fs.promises.readFile(`${root}/cmdline`);
|
|
69
|
+
if (argumentsBuffer.length === 0 || argumentsBuffer.length > 256 * 1024) {
|
|
70
|
+
throw new WorkerCallerProofError('Worker process arguments are unavailable.');
|
|
71
|
+
}
|
|
72
|
+
return { ...identity,
|
|
56
73
|
executable: await plugins.fs.promises.readlink(`${root}/exe`),
|
|
57
74
|
arguments: argumentsBuffer.toString('utf8').split('\0').filter(Boolean) };
|
|
58
75
|
};
|
|
@@ -89,6 +89,12 @@ export interface IOpenCodeSupervisorOptions {
|
|
|
89
89
|
credential: string;
|
|
90
90
|
process: IControllerMcpCallerProcess;
|
|
91
91
|
}) => void;
|
|
92
|
+
/**
|
|
93
|
+
* Takes the supervisor's own diagnostic lines (never the server's output, which `getLogSnapshot` keeps): one when a start
|
|
94
|
+
* minted a caller credential but could not record its server, so every MCP call through that credential is anonymous
|
|
95
|
+
* until the next start (AGL-1976). `console.warn` by default.
|
|
96
|
+
*/
|
|
97
|
+
log?: (lineArg: string) => void;
|
|
92
98
|
}
|
|
93
99
|
|
|
94
100
|
export type TOpenCodeSdkClient = ReturnType<typeof plugins.opencodeSdk.createOpencodeClient>;
|
package/ts_interfaces/tickets.ts
CHANGED
|
@@ -503,6 +503,16 @@ export const ticketPageErrorMessages = {
|
|
|
503
503
|
ticket_cursor_invalid: 'The cursor is not the nextCursor of a ticket page; list again without cursor.',
|
|
504
504
|
ticket_cursor_mismatch: 'The cursor pages other filters, another sort or another view; repeat those or list again without cursor.',
|
|
505
505
|
} as const;
|
|
506
|
-
|
|
507
|
-
|
|
506
|
+
/**
|
|
507
|
+
* A ticket transaction that reached its deadline before its commit: the board stayed busy, nothing was changed, and the
|
|
508
|
+
* request may be made again. Kept apart from `ticketErrorMessages`, which the device contract lists code by code: a
|
|
509
|
+
* device reads it as `operation_limit`.
|
|
510
|
+
*/
|
|
511
|
+
export const ticketBusyErrorMessages = {
|
|
512
|
+
ticket_busy: 'The ticket board was too busy to carry out this request in time, and nothing was changed: read the ticket, then try again.',
|
|
513
|
+
} as const;
|
|
514
|
+
export type TTicketClientErrorCode = Uppercase<keyof typeof ticketErrorMessages | keyof typeof ticketPageErrorMessages
|
|
515
|
+
| keyof typeof ticketBusyErrorMessages>;
|
|
516
|
+
export const ticketClientErrorMessages = Object.fromEntries(Object.entries({ ...ticketErrorMessages, ...ticketPageErrorMessages,
|
|
517
|
+
...ticketBusyErrorMessages })
|
|
508
518
|
.map(([codeArg, messageArg]) => [codeArg.toUpperCase(), messageArg])) as Record<TTicketClientErrorCode, string>;
|