agl 43.0.2 → 43.0.4
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 +749 -749
- package/dist_serve/bundle.js.map +2 -2
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/aglapi/aglapisurface.document.js +37 -2
- package/dist_ts/classes.claudeharness.js +19 -6
- package/dist_ts/classes.codexclientadapter.d.ts +2 -1
- package/dist_ts/classes.codexclientadapter.js +11 -6
- package/dist_ts/classes.codexprojection.d.ts +8 -1
- package/dist_ts/classes.codexprojection.js +22 -2
- package/dist_ts/classes.flexframedtransport.d.ts +16 -0
- package/dist_ts/classes.flexframedtransport.js +35 -20
- package/dist_ts/classes.flexservice.d.ts +7 -1
- package/dist_ts/classes.flexservice.js +26 -22
- package/dist_ts/classes.flexstore.js +4 -1
- package/dist_ts/classes.flexsupervisor.d.ts +10 -0
- package/dist_ts/classes.flexsupervisor.js +22 -2
- package/dist_ts/classes.sessionfeed.d.ts +20 -2
- package/dist_ts/classes.sessionfeed.js +63 -24
- package/dist_ts/fleet/classes.claudeworkers.d.ts +4 -1
- package/dist_ts/fleet/classes.claudeworkers.js +52 -6
- package/dist_ts/fleet/classes.codexworkers.d.ts +2 -1
- package/dist_ts/fleet/classes.codexworkers.js +34 -9
- package/dist_ts/fleet/classes.workers.js +9 -5
- package/dist_ts/fleet/functions.workervalidation.js +4 -2
- package/dist_ts/fleet/interfaces.workers.d.ts +27 -2
- package/dist_ts/fleet/interfaces.workers.js +7 -1
- package/dist_ts_interfaces/fleetworkers.d.ts +17 -1
- package/dist_ts_interfaces/interfaces.d.ts +20 -0
- package/dist_ts_interfaces/interfaces.js +2 -1
- package/dist_ts_interfaces/requests.fleetworkers.d.ts +11 -2
- package/dist_ts_interfaces/sessionfeed.d.ts +12 -2
- package/dist_ts_interfaces/sessionfeed.js +1 -1
- package/dist_ts_migration/classes.flexpostharnessmigrationrunner.d.ts +9 -0
- package/dist_ts_migration/classes.flexpostharnessmigrationrunner.js +24 -5
- package/dist_ts_migration/index.d.ts +1 -0
- package/dist_ts_migration/index.js +2 -1
- package/dist_ts_migration/v19_flexprojectmanagement.d.ts +3 -0
- package/dist_ts_migration/v19_flexprojectmanagement.js +3 -1
- package/dist_ts_migration/v43_flexpostharnessmigrationmarkers.d.ts +44 -0
- package/dist_ts_migration/v43_flexpostharnessmigrationmarkers.js +146 -0
- package/package.json +2 -2
- package/readme.md +1 -1
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/aglapi/aglapisurface.document.ts +36 -1
- package/ts/classes.claudeharness.ts +19 -3
- package/ts/classes.codexclientadapter.ts +9 -6
- package/ts/classes.codexprojection.ts +23 -2
- package/ts/classes.flexframedtransport.ts +42 -17
- package/ts/classes.flexservice.ts +36 -27
- package/ts/classes.flexstore.ts +6 -0
- package/ts/classes.flexsupervisor.ts +28 -1
- package/ts/classes.sessionfeed.ts +77 -29
- package/ts/fleet/classes.claudeworkers.ts +57 -9
- package/ts/fleet/classes.codexworkers.ts +35 -11
- package/ts/fleet/classes.workers.ts +8 -4
- package/ts/fleet/functions.workervalidation.ts +3 -1
- package/ts/fleet/interfaces.workers.ts +25 -2
- package/ts_interfaces/fleetworkers.ts +17 -1
- package/ts_interfaces/interfaces.ts +22 -0
- package/ts_interfaces/requests.fleetworkers.ts +11 -2
- package/ts_interfaces/sessionfeed.ts +12 -2
- package/ts_migration/classes.flexpostharnessmigrationrunner.ts +37 -5
- package/ts_migration/index.ts +1 -0
- package/ts_migration/v19_flexprojectmanagement.ts +4 -0
- package/ts_migration/v43_flexpostharnessmigrationmarkers.ts +109 -0
- package/ts_web/00_commitinfo_data.ts +1 -1
- package/ts_web/classes.controllersocketclient.ts +10 -2
|
@@ -2915,6 +2915,23 @@ export const AGL_API_SURFACE: plugins.flexTypedRequest.IFlexTypedRequestSurface
|
|
|
2915
2915
|
},
|
|
2916
2916
|
"declaration": "/**\n * A usage or rate limit a model provider reported. `usage_limit` means the account's quota is\n * spent until it resets; `rate_limit` is a throttle. `usage_reserve` is AGL's own: the account\n * reached its usage threshold (`maxUsagePercent`), so the rest of its quota is kept for use\n * outside AGL until the window resets. Times are Unix milliseconds.\n */\ninterface IControllerModelLimit {\n kind: TControllerModelLimitKind;\n /** The provider that reported the limit, for example `openai`. */\n provider: string;\n resetsAt?: number;\n /** The delay the provider asked for before the next request, in milliseconds. */\n retryAfterMs?: number;\n planType?: string;\n /** The exhausted limit window, for example `5h` or `7d`. */\n window?: string;\n}"
|
|
2917
2917
|
},
|
|
2918
|
+
{
|
|
2919
|
+
"name": "IControllerNativeWait",
|
|
2920
|
+
"schema": {
|
|
2921
|
+
"type": "object",
|
|
2922
|
+
"properties": {
|
|
2923
|
+
"reason": {
|
|
2924
|
+
"$ref": "#/$defs/TControllerNativeWaitReason"
|
|
2925
|
+
}
|
|
2926
|
+
},
|
|
2927
|
+
"required": [
|
|
2928
|
+
"reason"
|
|
2929
|
+
],
|
|
2930
|
+
"additionalProperties": false,
|
|
2931
|
+
"description": "A wait the harness signals, projected only: it carries no request id, so nothing in AGL can answer it. Whether AGL holds a request it can answer is `attention`."
|
|
2932
|
+
},
|
|
2933
|
+
"declaration": "/**\n * A wait the harness signals, projected only: it carries no request id, so nothing in AGL can answer it. Whether AGL\n * holds a request it can answer is `attention`.\n */\ninterface IControllerNativeWait {\n reason: TControllerNativeWaitReason;\n}"
|
|
2934
|
+
},
|
|
2918
2935
|
{
|
|
2919
2936
|
"name": "IControllerOpenCodeModelChoice",
|
|
2920
2937
|
"schema": {
|
|
@@ -3586,6 +3603,10 @@ export const AGL_API_SURFACE: plugins.flexTypedRequest.IFlexTypedRequestSurface
|
|
|
3586
3603
|
"type": "boolean",
|
|
3587
3604
|
"description": "True while OpenCode has a pending permission or question for this session."
|
|
3588
3605
|
},
|
|
3606
|
+
"nativeWait": {
|
|
3607
|
+
"$ref": "#/$defs/IControllerNativeWait",
|
|
3608
|
+
"description": "Set while the harness signals that the session waits for a person in its own client (Codex, Claude Code), which it does only while the session is busy. Absent is no proof that nothing waits: a harness does not signal every wait."
|
|
3609
|
+
},
|
|
3589
3610
|
"error": {
|
|
3590
3611
|
"$ref": "#/$defs/IControllerSessionError",
|
|
3591
3612
|
"description": "Why the last run failed, while the session reports that failure (Flex)."
|
|
@@ -3612,7 +3633,7 @@ export const AGL_API_SURFACE: plugins.flexTypedRequest.IFlexTypedRequestSurface
|
|
|
3612
3633
|
],
|
|
3613
3634
|
"additionalProperties": false
|
|
3614
3635
|
},
|
|
3615
|
-
"declaration": "interface IControllerSession {\n id: IControllerRuntimeId;\n title: string;\n parentId?: IControllerRuntimeId;\n createdAt: number;\n updatedAt: number;\n /** Unix milliseconds when the session was archived in OpenCode; absent for active sessions. */\n archivedAt?: number;\n status: TControllerSessionStatus;\n /** Bounded native writer state for Codex sidebar rows. */\n codexActivity?: IControllerCodexActivitySummary;\n /** True while OpenCode has a pending permission or question for this session. */\n attention?: boolean;\n /** Why the last run failed, while the session reports that failure (Flex). */\n error?: IControllerSessionError;\n /** Set while the running prompt waits to call the model again (Flex). */\n retrying?: IControllerSessionRetrying;\n /** Set while a provider limit holds the session's queued prompts (Flex). */\n promptQueueHold?: IControllerPromptQueueHold;\n /** Present only on the controller-owned driver session, which no session list shows. */\n role?: TControllerSessionRole;\n}"
|
|
3636
|
+
"declaration": "interface IControllerSession {\n id: IControllerRuntimeId;\n title: string;\n parentId?: IControllerRuntimeId;\n createdAt: number;\n updatedAt: number;\n /** Unix milliseconds when the session was archived in OpenCode; absent for active sessions. */\n archivedAt?: number;\n status: TControllerSessionStatus;\n /** Bounded native writer state for Codex sidebar rows. */\n codexActivity?: IControllerCodexActivitySummary;\n /** True while OpenCode has a pending permission or question for this session. */\n attention?: boolean;\n /**\n * Set while the harness signals that the session waits for a person in its own client (Codex, Claude Code), which\n * it does only while the session is busy. Absent is no proof that nothing waits: a harness does not signal every wait.\n */\n nativeWait?: IControllerNativeWait;\n /** Why the last run failed, while the session reports that failure (Flex). */\n error?: IControllerSessionError;\n /** Set while the running prompt waits to call the model again (Flex). */\n retrying?: IControllerSessionRetrying;\n /** Set while a provider limit holds the session's queued prompts (Flex). */\n promptQueueHold?: IControllerPromptQueueHold;\n /** Present only on the controller-owned driver session, which no session list shows. */\n role?: TControllerSessionRole;\n}"
|
|
3616
3637
|
},
|
|
3617
3638
|
{
|
|
3618
3639
|
"name": "IControllerSessionDetail",
|
|
@@ -5680,6 +5701,20 @@ export const AGL_API_SURFACE: plugins.flexTypedRequest.IFlexTypedRequestSurface
|
|
|
5680
5701
|
},
|
|
5681
5702
|
"declaration": "type TControllerModelRetryReason = 'rate_limit' | 'overloaded' | 'unavailable';"
|
|
5682
5703
|
},
|
|
5704
|
+
{
|
|
5705
|
+
"name": "TControllerNativeWaitReason",
|
|
5706
|
+
"schema": {
|
|
5707
|
+
"type": "string",
|
|
5708
|
+
"enum": [
|
|
5709
|
+
"approval",
|
|
5710
|
+
"user_input",
|
|
5711
|
+
"native_prompt",
|
|
5712
|
+
"unrecognized"
|
|
5713
|
+
],
|
|
5714
|
+
"description": "Why a harness says its session waits for a person in the harness's own client: `approval` and `user_input`, Codex's thread flags `waitingOnApproval` and `waitingOnUserInput`; `native_prompt`, Claude Code's `requires_action`, or a Claude Code job whose process its inventory lists as waiting without the job having failed; `unrecognized`, a wait signal AGL does not know."
|
|
5715
|
+
},
|
|
5716
|
+
"declaration": "/**\n * Why a harness says its session waits for a person in the harness's own client: `approval` and `user_input`, Codex's\n * thread flags `waitingOnApproval` and `waitingOnUserInput`; `native_prompt`, Claude Code's `requires_action`, or a\n * Claude Code job whose process its inventory lists as waiting without the job having failed; `unrecognized`, a wait\n * signal AGL does not know.\n */\ntype TControllerNativeWaitReason = 'approval' | 'user_input' | 'native_prompt' | 'unrecognized';"
|
|
5717
|
+
},
|
|
5683
5718
|
{
|
|
5684
5719
|
"name": "TControllerPendingPromptState",
|
|
5685
5720
|
"schema": {
|
|
@@ -208,6 +208,11 @@ interface IClaudeSessionState {
|
|
|
208
208
|
turn?: IClaudeCommand;
|
|
209
209
|
/** Claude Code runs a turn, AGL's or one it started itself (a background task's notification). */
|
|
210
210
|
cliRunning: boolean;
|
|
211
|
+
/**
|
|
212
|
+
* Claude Code's last session state was `requires_action`: it holds a prompt for a person, which reaches AGL only
|
|
213
|
+
* through `canUseTool`. `running`, `idle` and the end of its process clear it.
|
|
214
|
+
*/
|
|
215
|
+
requiresAction?: true;
|
|
211
216
|
/** The uuids the running turn has taken in so far. */
|
|
212
217
|
consumed: Set<string>;
|
|
213
218
|
currentApiId?: string;
|
|
@@ -291,7 +296,9 @@ export class ClaudeHarness {
|
|
|
291
296
|
...(document.archivedAt === undefined ? {} : { archivedAt: document.archivedAt.getTime() }),
|
|
292
297
|
// A turn that failed leaves the conversation in error until the next one starts, as a failed Codex turn does.
|
|
293
298
|
status: busy ? (state.retrying ? 'retry' : 'busy') : state.error ? 'error' : 'idle',
|
|
294
|
-
...(this.requests(nativeIdArg).length > 0 ? { attention: true }
|
|
299
|
+
...(this.requests(nativeIdArg).length > 0 ? { attention: true }
|
|
300
|
+
// A prompt Claude Code holds without handing it to AGL, such as one inherited from an earlier process of the session.
|
|
301
|
+
: state.requiresAction ? { nativeWait: { reason: 'native_prompt' as const } } : {}),
|
|
295
302
|
...(state.error ? { error: structuredClone(state.error) } : {}),
|
|
296
303
|
...(busy && state.retrying ? { retrying: { ...state.retrying } } : {}),
|
|
297
304
|
};
|
|
@@ -829,6 +836,7 @@ export class ClaudeHarness {
|
|
|
829
836
|
state.error = { message: claudeErrorText(`Claude Code stopped${runtimeArg.closing ? '' : ' unexpectedly'}${cause ? `: ${cause}` : '.'}`) };
|
|
830
837
|
}
|
|
831
838
|
state.cliRunning = false;
|
|
839
|
+
delete state.requiresAction;
|
|
832
840
|
state.consumed.clear();
|
|
833
841
|
state.retrying = undefined;
|
|
834
842
|
for (const command of [...state.commands.values()]) {
|
|
@@ -876,8 +884,16 @@ export class ClaudeHarness {
|
|
|
876
884
|
this.changed(state, 'session.changed');
|
|
877
885
|
}
|
|
878
886
|
} else if (message.subtype === 'session_state_changed') {
|
|
879
|
-
|
|
880
|
-
|
|
887
|
+
const sessionState = message.state;
|
|
888
|
+
if (sessionState !== 'running' && sessionState !== 'requires_action' && sessionState !== 'idle') return;
|
|
889
|
+
const busy = this.busy(state), waited = state.requiresAction === true;
|
|
890
|
+
this.transition(state, () => {
|
|
891
|
+
state.cliRunning = sessionState !== 'idle';
|
|
892
|
+
if (sessionState === 'requires_action') state.requiresAction = true;
|
|
893
|
+
else delete state.requiresAction;
|
|
894
|
+
});
|
|
895
|
+
// A wait that comes or goes while the turn runs on changes the session too, though not its status.
|
|
896
|
+
if (waited !== (sessionState === 'requires_action') && busy === this.busy(state)) this.changed(state, 'session.changed');
|
|
881
897
|
}
|
|
882
898
|
return;
|
|
883
899
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as plugins from './plugins.js';
|
|
2
|
-
import type { IControllerUsage, IControllerCodexActivity, IControllerCodexActivitySummary, IControllerCodexCollaborationMode, IControllerCodexModelChoice, IControllerCodexModelOption, IControllerEvent, IControllerMessagePage, IControllerMessageBundle, IControllerPermission, IControllerQuestion, IControllerSession, IControllerSessionError, TControllerCodexCollaborationMode, TControllerCodexCollaborationModeAuthority, TControllerSessionStatus } from '../ts_interfaces/index.js';
|
|
2
|
+
import type { IControllerUsage, IControllerCodexActivity, IControllerCodexActivitySummary, IControllerCodexCollaborationMode, IControllerCodexModelChoice, IControllerCodexModelOption, IControllerEvent, IControllerMessagePage, IControllerMessageBundle, IControllerNativeWait, IControllerPermission, IControllerQuestion, IControllerSession, IControllerSessionError, TControllerCodexCollaborationMode, TControllerCodexCollaborationModeAuthority, TControllerSessionStatus } from '../ts_interfaces/index.js';
|
|
3
3
|
import { controllerMaxToolEventBytes } from '../ts_interfaces/index.js';
|
|
4
4
|
import { CodexSupervisor } from './classes.codexsupervisor.js';
|
|
5
|
-
import { codexArray, codexBoundedText, codexNonnegativeInteger, codexItemBundle, codexRecord, codexRuntimeId, codexSession, codexSessionId, codexString, codexText, codexThreadId, codexTurnError, codexTurnErrorBundle, codexTurnUsage, codexUsageTotal, isCodexTerminalItemStatus, type ICodexUsageTotal, type TCodexAnswerMeta, type TCodexTerminalTurnStatus } from './classes.codexprojection.js';
|
|
5
|
+
import { codexArray, codexBoundedText, codexNativeWait, codexNonnegativeInteger, codexItemBundle, codexRecord, codexRuntimeId, codexSession, codexSessionId, codexString, codexText, codexThreadId, codexTurnError, codexTurnErrorBundle, codexTurnUsage, codexUsageTotal, isCodexTerminalItemStatus, type ICodexUsageTotal, type TCodexAnswerMeta, type TCodexTerminalTurnStatus } from './classes.codexprojection.js';
|
|
6
6
|
import { codexPublicThreadId, codexQualifiedIdentity } from './functions.codexidentity.js';
|
|
7
7
|
import { maxCodexTurnPartialReplyBytes, maxCodexTurnRecordsPerSession, maxCodexTurnStopAnchors, type ICodexTurnRecord, type ICodexTurnRecordStore, type ICodexTurnStop } from './classes.codexturnstore.js';
|
|
8
8
|
|
|
@@ -495,12 +495,15 @@ export class CodexClientAdapter {
|
|
|
495
495
|
|
|
496
496
|
/**
|
|
497
497
|
* The one place a live status changes. The failure a status reported goes with it: only a failed
|
|
498
|
-
* turn states why, with the error Codex recorded on it.
|
|
498
|
+
* turn states why, with the error Codex recorded on it. So does a wait: only a thread status Codex
|
|
499
|
+
* sends with its active flags states one (`codexNativeWait`).
|
|
499
500
|
*/
|
|
500
|
-
private setSessionStatus(scopeArg: ICodexSessionScope, statusArg: TControllerSessionStatus, errorArg?: IControllerSessionError): void {
|
|
501
|
+
private setSessionStatus(scopeArg: ICodexSessionScope, statusArg: TControllerSessionStatus, errorArg?: IControllerSessionError, nativeWaitArg?: IControllerNativeWait): void {
|
|
501
502
|
scopeArg.session.status = statusArg;
|
|
502
503
|
if (errorArg) scopeArg.session.error = errorArg;
|
|
503
504
|
else delete scopeArg.session.error;
|
|
505
|
+
if (nativeWaitArg) scopeArg.session.nativeWait = nativeWaitArg;
|
|
506
|
+
else delete scopeArg.session.nativeWait;
|
|
504
507
|
}
|
|
505
508
|
|
|
506
509
|
private scope(threadIdArg: string): ICodexSessionScope {
|
|
@@ -1760,9 +1763,9 @@ export class CodexClientAdapter {
|
|
|
1760
1763
|
}
|
|
1761
1764
|
const scope = this.scope(threadId);
|
|
1762
1765
|
if (method === 'thread/status/changed') {
|
|
1763
|
-
const
|
|
1766
|
+
const threadStatus = codexRecord(params.status), status = codexString(threadStatus.type);
|
|
1764
1767
|
if (!['active', 'idle', 'notLoaded', 'systemError'].includes(status)) throw new Error('Invalid native thread status.');
|
|
1765
|
-
this.setSessionStatus(scope, status === 'active' ? 'busy' : status === 'systemError' ? 'error' : 'idle');
|
|
1768
|
+
this.setSessionStatus(scope, status === 'active' ? 'busy' : status === 'systemError' ? 'error' : 'idle', undefined, codexNativeWait(threadStatus));
|
|
1766
1769
|
scope.session.updatedAt = Date.now();
|
|
1767
1770
|
scope.revision += 1;
|
|
1768
1771
|
scope.statusRevision += 1;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as plugins from './plugins.js';
|
|
2
|
-
import type { IControllerMessage, IControllerMessageBundle, IControllerSession, IControllerSessionError, IControllerRuntimeId, IControllerUsage, TControllerModelLimitKind, TControllerToolStatus } from '../ts_interfaces/index.js';
|
|
2
|
+
import type { IControllerMessage, IControllerMessageBundle, IControllerNativeWait, IControllerSession, IControllerSessionError, IControllerRuntimeId, IControllerUsage, TControllerModelLimitKind, TControllerNativeWaitReason, TControllerToolStatus } from '../ts_interfaces/index.js';
|
|
3
3
|
import { isCodexThreadId, isCodexSessionId } from './functions.codexidentity.js';
|
|
4
4
|
|
|
5
5
|
export type TCodexTerminalTurnStatus = 'completed' | 'interrupted' | 'failed';
|
|
@@ -147,16 +147,37 @@ export const codexCommandTitle = (valueArg: unknown): string => {
|
|
|
147
147
|
return unique.length === 0 ? '' : codexText(unique.join(' · '), maxCodexTitleBytes).split('\n')[0]!;
|
|
148
148
|
};
|
|
149
149
|
|
|
150
|
+
/** Codex's `ThreadActiveFlag`s in the controller's words. */
|
|
151
|
+
const codexWaitReasons: ReadonlyMap<unknown, TControllerNativeWaitReason> = new Map([
|
|
152
|
+
['waitingOnApproval', 'approval'],
|
|
153
|
+
['waitingOnUserInput', 'user_input'],
|
|
154
|
+
]);
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Why an active Codex thread waits for a person, from its `ThreadStatus`; the one reading of Codex's `activeFlags`. An
|
|
158
|
+
* active thread without flags works, and so does one whose status carries no flag list, as Codex's did before it had
|
|
159
|
+
* flags. Any other flag, or a list that is not one, is a wait AGL does not know (`unrecognized`): still a wait, never
|
|
160
|
+
* work or idleness. Of several flags the first AGL knows names the reason.
|
|
161
|
+
*/
|
|
162
|
+
export const codexNativeWait = (statusArg: Record<string, unknown>): IControllerNativeWait | undefined => {
|
|
163
|
+
const flags = statusArg.activeFlags;
|
|
164
|
+
if (statusArg.type !== 'active' || flags === undefined || Array.isArray(flags) && flags.length === 0) return undefined;
|
|
165
|
+
const known = Array.isArray(flags) ? flags.slice(0, 16).map((flag) => codexWaitReasons.get(flag)).find((reason) => reason !== undefined) : undefined;
|
|
166
|
+
return { reason: known ?? 'unrecognized' };
|
|
167
|
+
};
|
|
168
|
+
|
|
150
169
|
export const codexSession = (valueArg: unknown, directoryArg: string): IControllerSession => {
|
|
151
170
|
const thread = codexRecord(valueArg);
|
|
152
171
|
if (codexString(thread.cwd) !== directoryArg) throw new Error('Codex thread belongs to another project directory.');
|
|
153
|
-
const
|
|
172
|
+
const threadStatus = codexRecord(thread.status), status = codexString(threadStatus.type);
|
|
154
173
|
if (!['active', 'idle', 'notLoaded', 'systemError'].includes(status)) throw new Error('Unknown Codex thread status.');
|
|
174
|
+
const nativeWait = codexNativeWait(threadStatus);
|
|
155
175
|
return {
|
|
156
176
|
id: codexRuntimeId(codexSessionId(thread.id)),
|
|
157
177
|
title: codexText(thread.name || thread.preview, 8192) || 'New Codex conversation',
|
|
158
178
|
createdAt: codexTimestamp(thread.createdAt), updatedAt: codexTimestamp(thread.updatedAt),
|
|
159
179
|
status: status === 'active' ? 'busy' : status === 'systemError' ? 'error' : 'idle',
|
|
180
|
+
...(nativeWait ? { nativeWait } : {}),
|
|
160
181
|
...(typeof thread.parentThreadId === 'string' ? { parentId: codexRuntimeId(codexSessionId(thread.parentThreadId)) } : {}),
|
|
161
182
|
};
|
|
162
183
|
};
|
|
@@ -16,6 +16,14 @@ type TCloseListener = () => void;
|
|
|
16
16
|
export const flexIpcMaximumQueuedFrames = 128;
|
|
17
17
|
export const flexIpcMaximumQueuedFrameBytes = 64 * 1024 * 1024;
|
|
18
18
|
const flexIpcCloseDrainTimeoutMs = 2_000;
|
|
19
|
+
const flexIpcMaximumIgnoredStreamErrors = 16;
|
|
20
|
+
|
|
21
|
+
/** A stream error that reached the transport after it closed or failed: recorded, never acted on. */
|
|
22
|
+
export interface IFlexIgnoredStreamError {
|
|
23
|
+
stream: 'readable' | 'writable';
|
|
24
|
+
code?: string;
|
|
25
|
+
timestamp: number;
|
|
26
|
+
}
|
|
19
27
|
|
|
20
28
|
const normalizeMaximumFrameBytes = (valueArg: number | undefined): number => {
|
|
21
29
|
const selected = valueArg ?? flexIpcMaximumFrameBytes;
|
|
@@ -90,6 +98,11 @@ export const encodeFlexFrame = (
|
|
|
90
98
|
/**
|
|
91
99
|
* A single-reader/single-writer JSON transport. The body buffer is allocated
|
|
92
100
|
* only after the fixed header has passed the configured length limit.
|
|
101
|
+
*
|
|
102
|
+
* Each stream keeps an 'error' listener from construction for as long as it exists: an 'error' event
|
|
103
|
+
* without a listener throws, and a stream outlives the transport's close (a pipe socket keeps reading
|
|
104
|
+
* until its peer is gone, and a peer killed with unread frames resets it). Before close or failure
|
|
105
|
+
* a stream error fails the transport; after it, the listener records the error and ignores it.
|
|
93
106
|
*/
|
|
94
107
|
export class FlexFramedTransport<TIncoming, TOutgoing> {
|
|
95
108
|
private readonly readable: plugins.stream.Readable;
|
|
@@ -110,6 +123,7 @@ export class FlexFramedTransport<TIncoming, TOutgoing> {
|
|
|
110
123
|
private failed = false;
|
|
111
124
|
private closed = false;
|
|
112
125
|
private closePromise?: Promise<void>;
|
|
126
|
+
private readonly ignoredStreamErrors: IFlexIgnoredStreamError[] = [];
|
|
113
127
|
|
|
114
128
|
constructor(optionsArg: IFlexFramedTransportOptions<TIncoming, TOutgoing>) {
|
|
115
129
|
this.readable = optionsArg.readable;
|
|
@@ -118,10 +132,10 @@ export class FlexFramedTransport<TIncoming, TOutgoing> {
|
|
|
118
132
|
this.validateOutgoing = optionsArg.validateOutgoing;
|
|
119
133
|
this.maximumFrameBytes = normalizeMaximumFrameBytes(optionsArg.maximumFrameBytes);
|
|
120
134
|
this.readable.on('data', this.onData);
|
|
121
|
-
this.readable.
|
|
135
|
+
this.readable.on('error', this.onReadError);
|
|
122
136
|
this.readable.once('end', this.onReadableClosed);
|
|
123
137
|
this.readable.once('close', this.onReadableClosed);
|
|
124
|
-
this.writable.
|
|
138
|
+
this.writable.on('error', this.onWriteError);
|
|
125
139
|
this.writable.once('finish', this.onWritableClosed);
|
|
126
140
|
this.writable.once('close', this.onWritableClosed);
|
|
127
141
|
}
|
|
@@ -141,6 +155,11 @@ export class FlexFramedTransport<TIncoming, TOutgoing> {
|
|
|
141
155
|
return () => this.closeListeners.delete(listenerArg);
|
|
142
156
|
}
|
|
143
157
|
|
|
158
|
+
/** The stream errors that arrived after the transport closed or failed, oldest first, the last 16. */
|
|
159
|
+
public getIgnoredStreamErrors(): IFlexIgnoredStreamError[] {
|
|
160
|
+
return this.ignoredStreamErrors.map((entryArg) => ({ ...entryArg }));
|
|
161
|
+
}
|
|
162
|
+
|
|
144
163
|
/**
|
|
145
164
|
* Writes one frame after the frames before it. Every refusal before the frame's first byte reaches
|
|
146
165
|
* the stream throws `FlexIpcNotSentError`; a failure of the write itself may come after bytes went
|
|
@@ -189,9 +208,11 @@ export class FlexFramedTransport<TIncoming, TOutgoing> {
|
|
|
189
208
|
private async closeTransport(): Promise<void> {
|
|
190
209
|
this.closed = true;
|
|
191
210
|
this.detachStreams();
|
|
211
|
+
// Inbound frames are discarded once closed, so the reader goes at once; only the writer drains.
|
|
212
|
+
if (!this.readable.destroyed) this.readable.destroy();
|
|
192
213
|
let drainTimer: ReturnType<typeof setTimeout> | undefined;
|
|
193
|
-
const drainTimeout = new Promise<
|
|
194
|
-
drainTimer = setTimeout(
|
|
214
|
+
const drainTimeout = new Promise<void>((resolve) => {
|
|
215
|
+
drainTimer = setTimeout(resolve, flexIpcCloseDrainTimeoutMs);
|
|
195
216
|
drainTimer.unref?.();
|
|
196
217
|
});
|
|
197
218
|
const gracefulClose = this.writeTail.then(async () => {
|
|
@@ -200,20 +221,14 @@ export class FlexFramedTransport<TIncoming, TOutgoing> {
|
|
|
200
221
|
this.writable.end(resolve);
|
|
201
222
|
});
|
|
202
223
|
}
|
|
203
|
-
return 'drained' as const;
|
|
204
224
|
});
|
|
205
|
-
|
|
225
|
+
await Promise.race([
|
|
206
226
|
gracefulClose,
|
|
207
227
|
drainTimeout,
|
|
208
228
|
]);
|
|
209
229
|
if (drainTimer) clearTimeout(drainTimer);
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
if (!this.readable.destroyed) this.readable.destroy();
|
|
213
|
-
this.emitClose();
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
if (!this.readable.destroyed) this.readable.destroy();
|
|
230
|
+
// Drained or not, the writer goes too: a pipe socket ended for writing still reads from its peer.
|
|
231
|
+
if (!this.writable.destroyed) this.writable.destroy();
|
|
217
232
|
this.emitClose();
|
|
218
233
|
}
|
|
219
234
|
|
|
@@ -292,8 +307,19 @@ export class FlexFramedTransport<TIncoming, TOutgoing> {
|
|
|
292
307
|
});
|
|
293
308
|
}
|
|
294
309
|
|
|
295
|
-
private readonly onReadError = (errorArg: Error): void => this.
|
|
296
|
-
private readonly onWriteError = (errorArg: Error): void => this.
|
|
310
|
+
private readonly onReadError = (errorArg: Error): void => this.handleStreamError('readable', errorArg);
|
|
311
|
+
private readonly onWriteError = (errorArg: Error): void => this.handleStreamError('writable', errorArg);
|
|
312
|
+
|
|
313
|
+
private handleStreamError(streamArg: IFlexIgnoredStreamError['stream'], errorArg: Error): void {
|
|
314
|
+
if (!this.closed && !this.failed) {
|
|
315
|
+
this.fail(errorArg);
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
const code = 'code' in errorArg && typeof errorArg.code === 'string' ? errorArg.code : undefined;
|
|
319
|
+
this.ignoredStreamErrors.push({ stream: streamArg, ...(code ? { code } : {}), timestamp: Date.now() });
|
|
320
|
+
if (this.ignoredStreamErrors.length > flexIpcMaximumIgnoredStreamErrors) this.ignoredStreamErrors.shift();
|
|
321
|
+
}
|
|
322
|
+
|
|
297
323
|
private readonly onReadableClosed = (): void => {
|
|
298
324
|
if (this.closed) return;
|
|
299
325
|
if (this.headerOffset !== 0 || this.body) {
|
|
@@ -326,12 +352,11 @@ export class FlexFramedTransport<TIncoming, TOutgoing> {
|
|
|
326
352
|
this.emitClose();
|
|
327
353
|
}
|
|
328
354
|
|
|
355
|
+
/** Removes every stream listener but the error listeners, which stay for as long as the streams exist. */
|
|
329
356
|
private detachStreams(): void {
|
|
330
357
|
this.readable.removeListener('data', this.onData);
|
|
331
|
-
this.readable.removeListener('error', this.onReadError);
|
|
332
358
|
this.readable.removeListener('end', this.onReadableClosed);
|
|
333
359
|
this.readable.removeListener('close', this.onReadableClosed);
|
|
334
|
-
this.writable.removeListener('error', this.onWriteError);
|
|
335
360
|
this.writable.removeListener('finish', this.onWritableClosed);
|
|
336
361
|
this.writable.removeListener('close', this.onWritableClosed);
|
|
337
362
|
}
|
|
@@ -8,6 +8,10 @@ import {
|
|
|
8
8
|
import { FlexStore, type IFlexProjectManagementHost } from './classes.flexstore.js';
|
|
9
9
|
import { FlexPersistenceMigrationRunner } from '../ts_migration/classes.flexmigrationrunner.js';
|
|
10
10
|
import { FlexPostHarnessMigrationRunner } from '../ts_migration/classes.flexpostharnessmigrationrunner.js';
|
|
11
|
+
import {
|
|
12
|
+
FlexPostHarnessMigrationMarkers,
|
|
13
|
+
type IFlexPostHarnessMigrationMarkers,
|
|
14
|
+
} from '../ts_migration/v43_flexpostharnessmigrationmarkers.js';
|
|
11
15
|
import {
|
|
12
16
|
assertCanonicalDirectory,
|
|
13
17
|
CanonicalDirectoryError,
|
|
@@ -718,7 +722,8 @@ export class FlexService {
|
|
|
718
722
|
(errorArg, contextArg) => this.projectRunFailure(errorArg, contextArg),
|
|
719
723
|
);
|
|
720
724
|
private readonly pendingProjectRegistrations = new Set<string>();
|
|
721
|
-
|
|
725
|
+
/** Which projects' post-harness migrations completed, read by every child generation. */
|
|
726
|
+
private postHarnessMigrationMarkers?: IFlexPostHarnessMigrationMarkers;
|
|
722
727
|
private readonly pendingProjectRetirements = new Set<string>();
|
|
723
728
|
private readonly pendingProjectRemovals = new Map<string, IFlexPendingProjectRemoval>();
|
|
724
729
|
private readonly projectRegistrationMigrationContext =
|
|
@@ -958,6 +963,7 @@ export class FlexService {
|
|
|
958
963
|
});
|
|
959
964
|
this.store = store;
|
|
960
965
|
await store.init();
|
|
966
|
+
this.postHarnessMigrationMarkers = new FlexPostHarnessMigrationMarkers(initArg.controllerId);
|
|
961
967
|
const activeProjectIds = new Set(this.projects.keys());
|
|
962
968
|
await new FlexPersistenceMigrationRunner({
|
|
963
969
|
store,
|
|
@@ -5414,16 +5420,7 @@ export class FlexService {
|
|
|
5414
5420
|
const current = this.projects.get(projectId);
|
|
5415
5421
|
if (current) {
|
|
5416
5422
|
if (!flexProjectDirectoriesEqual(current, projectArg)) throw new FlexServiceError('CONFLICT');
|
|
5417
|
-
|
|
5418
|
-
await this.projectRegistrationMigrationContext.run(
|
|
5419
|
-
{ projectId, registrationOperationId: registrationOperationIdArg },
|
|
5420
|
-
() => new FlexPostHarnessMigrationRunner({
|
|
5421
|
-
harness: harnessArg,
|
|
5422
|
-
scopeIds: [projectId],
|
|
5423
|
-
}).run(signalArg),
|
|
5424
|
-
);
|
|
5425
|
-
this.postHarnessMigratedProjects.add(projectId);
|
|
5426
|
-
}
|
|
5423
|
+
await this.runPostHarnessMigrations(projectId, registrationOperationIdArg, harnessArg, signalArg);
|
|
5427
5424
|
return false;
|
|
5428
5425
|
}
|
|
5429
5426
|
// Registrations of other projects run concurrently, so a pending one holds its place in the
|
|
@@ -5433,7 +5430,7 @@ export class FlexService {
|
|
|
5433
5430
|
if (this.projects.size + pendingAdditions >= controllerProjectLimit) {
|
|
5434
5431
|
throw new FlexServiceError('LIMIT_EXCEEDED');
|
|
5435
5432
|
}
|
|
5436
|
-
if (!this.store) throw new FlexServiceError('NOT_READY');
|
|
5433
|
+
if (!this.store || !this.postHarnessMigrationMarkers) throw new FlexServiceError('NOT_READY');
|
|
5437
5434
|
|
|
5438
5435
|
this.pendingProjectRegistrations.add(projectId);
|
|
5439
5436
|
const project = structuredClone(projectArg);
|
|
@@ -5446,19 +5443,10 @@ export class FlexService {
|
|
|
5446
5443
|
signalArg.throwIfAborted();
|
|
5447
5444
|
this.projects.set(projectId, project);
|
|
5448
5445
|
temporarilyVisible = true;
|
|
5449
|
-
|
|
5450
|
-
|
|
5451
|
-
|
|
5452
|
-
|
|
5453
|
-
scopeIds: [projectId],
|
|
5454
|
-
}).run(signalArg),
|
|
5455
|
-
);
|
|
5456
|
-
this.postHarnessMigratedProjects.add(projectId);
|
|
5457
|
-
const sessions = await harnessArg.listSessions(projectId);
|
|
5458
|
-
for (const session of sessions) {
|
|
5459
|
-
signalArg.throwIfAborted();
|
|
5460
|
-
await harnessArg.getSessionReversionInfo(projectId, session.sessionId);
|
|
5461
|
-
}
|
|
5446
|
+
// FlexHarness recovers every session's reversion state when it loads the project's namespace,
|
|
5447
|
+
// on the project's first request; reading it adds only a check, which runs when a session is
|
|
5448
|
+
// opened (`session.reversion.info`, sent by `controller.slash.list`). Registration walks none.
|
|
5449
|
+
await this.runPostHarnessMigrations(projectId, registrationOperationIdArg, harnessArg, signalArg);
|
|
5462
5450
|
signalArg.throwIfAborted();
|
|
5463
5451
|
return true;
|
|
5464
5452
|
} catch (errorArg) {
|
|
@@ -5471,6 +5459,28 @@ export class FlexService {
|
|
|
5471
5459
|
}
|
|
5472
5460
|
}
|
|
5473
5461
|
|
|
5462
|
+
/**
|
|
5463
|
+
* The project's post-harness migrations, each walked only until it completed once for the
|
|
5464
|
+
* project: its persisted marker spares every later child generation the per-session walk.
|
|
5465
|
+
*/
|
|
5466
|
+
private async runPostHarnessMigrations(
|
|
5467
|
+
projectIdArg: string,
|
|
5468
|
+
registrationOperationIdArg: string,
|
|
5469
|
+
harnessArg: TFlexHarness<IFlexProjectScope>,
|
|
5470
|
+
signalArg: AbortSignal,
|
|
5471
|
+
): Promise<void> {
|
|
5472
|
+
const markers = this.postHarnessMigrationMarkers;
|
|
5473
|
+
if (!markers) throw new FlexServiceError('NOT_READY');
|
|
5474
|
+
await this.projectRegistrationMigrationContext.run(
|
|
5475
|
+
{ projectId: projectIdArg, registrationOperationId: registrationOperationIdArg },
|
|
5476
|
+
() => new FlexPostHarnessMigrationRunner({
|
|
5477
|
+
harness: harnessArg,
|
|
5478
|
+
markers,
|
|
5479
|
+
scopeIds: [projectIdArg],
|
|
5480
|
+
}).run(signalArg),
|
|
5481
|
+
);
|
|
5482
|
+
}
|
|
5483
|
+
|
|
5474
5484
|
private async removeProject(
|
|
5475
5485
|
projectArg: IFlexIdentityBoundProjectRecord,
|
|
5476
5486
|
removalOperationIdArg: string,
|
|
@@ -5524,7 +5534,6 @@ export class FlexService {
|
|
|
5524
5534
|
signalArg.throwIfAborted();
|
|
5525
5535
|
await this.deleteModelChoiceForScope(projectId);
|
|
5526
5536
|
this.projects.delete(projectId);
|
|
5527
|
-
this.postHarnessMigratedProjects.delete(projectId);
|
|
5528
5537
|
this.deleteProjectUploadGrants(projectId);
|
|
5529
5538
|
for (const key of this.promptStages.keys()) if (key.startsWith(`${projectId}\0`)) this.promptStages.delete(key);
|
|
5530
5539
|
for (const [key, event] of this.sessionChangeQueue.entries()) {
|
|
@@ -5684,7 +5693,7 @@ export class FlexService {
|
|
|
5684
5693
|
this.pendingProjectRegistrations.clear();
|
|
5685
5694
|
this.pendingProjectRetirements.clear();
|
|
5686
5695
|
this.pendingProjectRemovals.clear();
|
|
5687
|
-
this.
|
|
5696
|
+
this.postHarnessMigrationMarkers = undefined;
|
|
5688
5697
|
this.catalogCache.clear();
|
|
5689
5698
|
this.claudePoolCatalog = undefined;
|
|
5690
5699
|
this.jobs.clear();
|
package/ts/classes.flexstore.ts
CHANGED
|
@@ -2,6 +2,10 @@ import * as plugins from './plugins.js';
|
|
|
2
2
|
import { FlexOrphanIndexV33Migration } from '../ts_migration/v33_flexorphanindexes.js';
|
|
3
3
|
import { FlexLegacyPublicationV38Migration } from '../ts_migration/v38_flextranscripts.js';
|
|
4
4
|
import { FlexPublicHeadPointerV39Migration } from '../ts_migration/v39_flexpublicheadpointers.js';
|
|
5
|
+
import {
|
|
6
|
+
initFlexPostHarnessMigrationMarkerModel,
|
|
7
|
+
registerFlexPostHarnessMigrationMarkerModel,
|
|
8
|
+
} from '../ts_migration/v43_flexpostharnessmigrationmarkers.js';
|
|
5
9
|
import {
|
|
6
10
|
FlexDomainHeadModel,
|
|
7
11
|
FlexHeadModel,
|
|
@@ -1288,6 +1292,7 @@ export class FlexStore implements plugins.flexharness.IFlexHarnessStores {
|
|
|
1288
1292
|
this.manager = { db: this.database };
|
|
1289
1293
|
registerFlexPrivateModels(this.manager);
|
|
1290
1294
|
registerFlexPublicModels(this.manager);
|
|
1295
|
+
registerFlexPostHarnessMigrationMarkerModel(this.manager);
|
|
1291
1296
|
|
|
1292
1297
|
this.scopes = {
|
|
1293
1298
|
load: (storageKey) => this.loadScope(storageKey),
|
|
@@ -1366,6 +1371,7 @@ export class FlexStore implements plugins.flexharness.IFlexHarnessStores {
|
|
|
1366
1371
|
await new FlexPublicHeadPointerV39Migration(this.database, this.controllerId).run();
|
|
1367
1372
|
await initFlexPrivateModels();
|
|
1368
1373
|
await initFlexPublicModels();
|
|
1374
|
+
await initFlexPostHarnessMigrationMarkerModel();
|
|
1369
1375
|
this.initialized = true;
|
|
1370
1376
|
this.queueOrphanMaintenance();
|
|
1371
1377
|
})();
|
|
@@ -70,6 +70,13 @@ export interface IFlexSupervisorLogEntry {
|
|
|
70
70
|
truncated: boolean;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
/** An error of a child's log pipe, or of a started child process, the supervisor recorded and ignored. */
|
|
74
|
+
export interface IFlexSupervisorIgnoredError {
|
|
75
|
+
source: 'stdout' | 'stderr' | 'process';
|
|
76
|
+
code?: string;
|
|
77
|
+
timestamp: number;
|
|
78
|
+
}
|
|
79
|
+
|
|
73
80
|
export interface IFlexSupervisorOptions {
|
|
74
81
|
onChildExitObserved?: (exitArg: IFlexSupervisorExit) => void;
|
|
75
82
|
onChildExit?: (exitArg: IFlexSupervisorExit) => void;
|
|
@@ -152,6 +159,7 @@ interface ILogAccumulator {
|
|
|
152
159
|
}
|
|
153
160
|
|
|
154
161
|
const supervisorLogEntries = 200;
|
|
162
|
+
const supervisorIgnoredErrorEntries = 16;
|
|
155
163
|
const supervisorLogLineBytes = 8 * 1024;
|
|
156
164
|
const supervisorTermTimeoutMs = 5_000;
|
|
157
165
|
const supervisorKillTimeoutMs = 2_000;
|
|
@@ -317,6 +325,7 @@ export class FlexSupervisor {
|
|
|
317
325
|
private readonly settledHostRequestIds = new Set<string>();
|
|
318
326
|
private readonly eventListeners = new Set<(eventArg: TFlexChildEvent) => void>();
|
|
319
327
|
private readonly logs: IFlexSupervisorLogEntry[] = [];
|
|
328
|
+
private readonly ignoredChildErrors: IFlexSupervisorIgnoredError[] = [];
|
|
320
329
|
private readonly stdoutAccumulator: ILogAccumulator = {
|
|
321
330
|
decoder: new TextDecoder(), partial: '', dropping: false,
|
|
322
331
|
};
|
|
@@ -355,6 +364,11 @@ export class FlexSupervisor {
|
|
|
355
364
|
return this.logs.map((entry) => ({ ...entry }));
|
|
356
365
|
}
|
|
357
366
|
|
|
367
|
+
/** The child log-pipe and started-process errors the supervisor ignored, oldest first, the last 16. */
|
|
368
|
+
public getIgnoredChildErrors(): IFlexSupervisorIgnoredError[] {
|
|
369
|
+
return this.ignoredChildErrors.map((entry) => ({ ...entry }));
|
|
370
|
+
}
|
|
371
|
+
|
|
358
372
|
public ownsChildPeer(peerIdArg: string): boolean {
|
|
359
373
|
return this.browserPeerId !== ''
|
|
360
374
|
&& this.browserPeerId === peerIdArg
|
|
@@ -1365,8 +1379,12 @@ export class FlexSupervisor {
|
|
|
1365
1379
|
}
|
|
1366
1380
|
|
|
1367
1381
|
private observeChild(childArg: plugins.childProcess.ChildProcess): Promise<IFlexChildLifecycle> {
|
|
1382
|
+
// The log pipes and the process keep their error listeners for as long as they exist: an error
|
|
1383
|
+
// event without a listener throws, and the child's lifecycle never depends on its log pipes.
|
|
1368
1384
|
childArg.stdout?.on('data', (chunk) => this.consumeLog('stdout', chunk, this.stdoutAccumulator));
|
|
1385
|
+
childArg.stdout?.on('error', (errorArg) => this.recordIgnoredChildError('stdout', errorArg));
|
|
1369
1386
|
childArg.stderr?.on('data', (chunk) => this.consumeLog('stderr', chunk, this.stderrAccumulator));
|
|
1387
|
+
childArg.stderr?.on('error', (errorArg) => this.recordIgnoredChildError('stderr', errorArg));
|
|
1370
1388
|
return new Promise((resolve) => {
|
|
1371
1389
|
let settled = false;
|
|
1372
1390
|
const finish = (outcomeArg: IFlexChildLifecycle): void => {
|
|
@@ -1415,12 +1433,21 @@ export class FlexSupervisor {
|
|
|
1415
1433
|
resolve(outcomeArg);
|
|
1416
1434
|
};
|
|
1417
1435
|
childArg.once('exit', (code, signal) => finish({ type: 'exit', code, signal }));
|
|
1418
|
-
childArg.
|
|
1436
|
+
childArg.on('error', (error) => {
|
|
1437
|
+
// A child without a process ID never started, and its error is its outcome; a started
|
|
1438
|
+
// child's error (a failed signal) leaves its lifecycle to its exit.
|
|
1419
1439
|
if (!childArg.pid) finish({ type: 'error', error });
|
|
1440
|
+
else this.recordIgnoredChildError('process', error);
|
|
1420
1441
|
});
|
|
1421
1442
|
});
|
|
1422
1443
|
}
|
|
1423
1444
|
|
|
1445
|
+
private recordIgnoredChildError(sourceArg: IFlexSupervisorIgnoredError['source'], errorArg: Error): void {
|
|
1446
|
+
const code = 'code' in errorArg && typeof errorArg.code === 'string' ? errorArg.code : undefined;
|
|
1447
|
+
this.ignoredChildErrors.push({ source: sourceArg, ...(code ? { code } : {}), timestamp: Date.now() });
|
|
1448
|
+
if (this.ignoredChildErrors.length > supervisorIgnoredErrorEntries) this.ignoredChildErrors.shift();
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1424
1451
|
private async reapOrphanedGroup(processGroupIdArg: number): Promise<void> {
|
|
1425
1452
|
if (!isProcessGroupAlive(processGroupIdArg)) return;
|
|
1426
1453
|
signalProcessGroup(processGroupIdArg, 'SIGTERM');
|