@ornexus/neocortex 4.60.68 → 4.60.69
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/dist/release-source.json +1 -1
- package/dist/sbom.cdx.json +1194 -1194
- package/install.ps1 +1 -1
- package/install.sh +1 -1
- package/package.json +2 -2
- package/packages/client/dist/adapters/adapter-registry.js +1 -108
- package/packages/client/dist/adapters/antigravity-adapter.js +2 -77
- package/packages/client/dist/adapters/claude-code-adapter.js +3 -79
- package/packages/client/dist/adapters/codex-adapter.js +2 -80
- package/packages/client/dist/adapters/cursor-adapter.js +4 -115
- package/packages/client/dist/adapters/gemini-adapter.js +2 -71
- package/packages/client/dist/adapters/grok-adapter.js +2 -42
- package/packages/client/dist/adapters/index.js +1 -22
- package/packages/client/dist/adapters/platform-detector.js +1 -212
- package/packages/client/dist/adapters/target-adapter.js +0 -12
- package/packages/client/dist/adapters/vscode-adapter.js +2 -72
- package/packages/client/dist/agent/refresh-stubs.js +2 -417
- package/packages/client/dist/agent/update-agent-yaml.js +1 -102
- package/packages/client/dist/agent/update-description.js +1 -251
- package/packages/client/dist/cache/crypto-utils.js +1 -78
- package/packages/client/dist/cache/encrypted-cache.js +1 -108
- package/packages/client/dist/cache/in-memory-asset-cache.js +1 -73
- package/packages/client/dist/cache/index.js +1 -13
- package/packages/client/dist/cache/protected-pi-boundary.js +1 -44
- package/packages/client/dist/checkpoint/checkpoint-client-reader.js +2 -127
- package/packages/client/dist/checkpoint/index.js +1 -11
- package/packages/client/dist/checkpoint/shared-checkpoint-types.js +1 -32
- package/packages/client/dist/cli.js +3 -290
- package/packages/client/dist/commands/activate.js +8 -394
- package/packages/client/dist/commands/architecture-answers.js +7 -274
- package/packages/client/dist/commands/architecture-memory-terminal.js +4 -253
- package/packages/client/dist/commands/architecture-non-ui-continuation.js +1 -100
- package/packages/client/dist/commands/architecture-root-binding.js +1 -51
- package/packages/client/dist/commands/cache-status.js +2 -112
- package/packages/client/dist/commands/config.js +1 -88
- package/packages/client/dist/commands/doctor.js +2 -635
- package/packages/client/dist/commands/invoke.d.ts +6 -0
- package/packages/client/dist/commands/invoke.js +142 -7140
- package/packages/client/dist/commands/legacy-epic-terminal.js +1 -71
- package/packages/client/dist/commands/legacy-story-branch.js +1 -96
- package/packages/client/dist/commands/legacy-story-pr.js +1 -276
- package/packages/client/dist/commands/mutation-qa-checkpoint.js +5 -285
- package/packages/client/dist/commands/mutation-qa-gate.js +1 -54
- package/packages/client/dist/commands/mutation-qa-git.js +1 -41
- package/packages/client/dist/commands/mutation-qa-policy.js +1 -102
- package/packages/client/dist/commands/mutation-qa-run.js +3 -219
- package/packages/client/dist/commands/mutation-qa-verdict.js +1 -149
- package/packages/client/dist/commands/mutation-qa.js +1 -220
- package/packages/client/dist/commands/native-agent.js +2 -136
- package/packages/client/dist/commands/planning-diagnosis.js +1 -43
- package/packages/client/dist/commands/planning-generation.js +1 -53
- package/packages/client/dist/commands/planning-memory.js +1 -40
- package/packages/client/dist/commands/planning-research.js +1 -42
- package/packages/client/dist/commands/private-session.js +1 -75
- package/packages/client/dist/commands/property-qa.js +1 -139
- package/packages/client/dist/commands/qa-control.js +1 -16
- package/packages/client/dist/commands/qa-scan-browser-launch.js +1 -55
- package/packages/client/dist/commands/qa-scan-browser-route.js +1 -28
- package/packages/client/dist/commands/qa-scan-capture.js +5 -663
- package/packages/client/dist/commands/qa-scan-discovery.js +3 -376
- package/packages/client/dist/commands/qa-scan-review.js +5 -826
- package/packages/client/dist/commands/qa-synthetic-backend-capture.js +1 -266
- package/packages/client/dist/commands/qa-synthetic-backend-review.js +1 -297
- package/packages/client/dist/commands/qa-synthetic-backend.js +2 -340
- package/packages/client/dist/commands/qa-synthetic-broker-port.js +1 -85
- package/packages/client/dist/commands/qa-synthetic-browser.js +1 -39
- package/packages/client/dist/commands/refactor-characterization.js +21 -671
- package/packages/client/dist/commands/refactor-commit.js +13 -399
- package/packages/client/dist/commands/refactor-control.js +3 -142
- package/packages/client/dist/commands/refactor-cpp-assertions.js +3 -93
- package/packages/client/dist/commands/refactor-review.js +5 -283
- package/packages/client/dist/commands/refactor-root.js +7 -588
- package/packages/client/dist/commands/refresh-memory.js +3 -156
- package/packages/client/dist/commands/shared-architecture-non-ui.js +1 -24
- package/packages/client/dist/commands/story-checkpoint.js +1 -171
- package/packages/client/dist/config/profile-directory.js +1 -13
- package/packages/client/dist/config/resolver-selection.js +1 -278
- package/packages/client/dist/config/secure-config.js +12 -281
- package/packages/client/dist/config.js +2 -223
- package/packages/client/dist/constants.js +1 -25
- package/packages/client/dist/context/context-collector.js +2 -222
- package/packages/client/dist/context/context-sanitizer.js +1 -145
- package/packages/client/dist/continuity/autonomous-governance.js +1 -285
- package/packages/client/dist/continuity/continuity-client-state-store.js +1 -1587
- package/packages/client/dist/continuity/invoke-hooks.js +1 -129
- package/packages/client/dist/continuity/migrations/001-initial-schema.js +2 -12
- package/packages/client/dist/continuity/migrations/002-processing-output-summary-indexes.js +2 -12
- package/packages/client/dist/continuity/migrations/003-headless-execution-attempts.js +2 -12
- package/packages/client/dist/continuity/migrations/004-outbox-delivery-state.js +2 -12
- package/packages/client/dist/continuity/migrations/005-bounded-headless-queue.js +2 -12
- package/packages/client/dist/continuity/migrations/006-native-agent-dispatches.js +2 -10
- package/packages/client/dist/continuity/native-agent-store.js +1 -69
- package/packages/client/dist/continuity/native-agent-types.js +1 -90
- package/packages/client/dist/continuity/outbox.js +1 -117
- package/packages/client/dist/continuity/runner-bootstrap-policy.js +1 -172
- package/packages/client/dist/continuity/sqlite-store.js +81 -2536
- package/packages/client/dist/effects/invoke-effect-gateways.js +1 -62
- package/packages/client/dist/errors/error-messages.js +2 -228
- package/packages/client/dist/errors/frontmatter-diagnostics.js +1 -125
- package/packages/client/dist/evidence/collector.js +1 -347
- package/packages/client/dist/evidence/index.js +1 -1
- package/packages/client/dist/evidence/types.js +0 -2
- package/packages/client/dist/fs/atomic-state-replace.js +1 -152
- package/packages/client/dist/generated/command-registry.generated.js +1 -4076
- package/packages/client/dist/generated/public-projections.generated.js +1 -149
- package/packages/client/dist/git/direct-yolo-c01-retry.js +4 -138
- package/packages/client/dist/git/direct-yolo-checkpoint.js +4 -1234
- package/packages/client/dist/git/git-lifecycle-step-ids.js +1 -14
- package/packages/client/dist/git/git-lifecycle-store.js +9 -1938
- package/packages/client/dist/git/legacy-story-branch-checkpoint.js +9 -259
- package/packages/client/dist/git/legacy-story-branch-setup.js +4 -348
- package/packages/client/dist/git/legacy-story-pr.js +70 -3538
- package/packages/client/dist/git/secure-filesystem-boundary.js +5 -182
- package/packages/client/dist/graph-retrieval/pre-command-hook.js +1 -284
- package/packages/client/dist/graph-retrieval/shared-graph-retrieval-contract.js +1 -237
- package/packages/client/dist/i18n/first-run.js +2 -60
- package/packages/client/dist/index.js +1 -47
- package/packages/client/dist/invocation/invoke-input.js +1 -24
- package/packages/client/dist/license/index.js +1 -5
- package/packages/client/dist/license/license-client.js +1 -304
- package/packages/client/dist/machine/fingerprint.js +2 -163
- package/packages/client/dist/machine/index.js +1 -5
- package/packages/client/dist/memory/project-memory-path-scope.js +1 -62
- package/packages/client/dist/memory/project-memory-writer.js +40 -1007
- package/packages/client/dist/memory/shared-project-memory-types.js +2 -253
- package/packages/client/dist/migrations/project-identity-capability.js +1 -50
- package/packages/client/dist/migrations/project-identity.js +7 -493
- package/packages/client/dist/migrations/state-json.js +4 -344
- package/packages/client/dist/policy/architecture-policy.js +2 -184
- package/packages/client/dist/policy/index.js +1 -7
- package/packages/client/dist/policy/shared-policy-types.js +0 -38
- package/packages/client/dist/policy/subagent-approval-policy.js +1 -55
- package/packages/client/dist/private-execution/clean-baseline.js +2 -279
- package/packages/client/dist/private-execution/codex-executor.js +4 -574
- package/packages/client/dist/private-execution/codex-host-runtime.js +1 -137
- package/packages/client/dist/private-execution/codex-lifecycle-guard.js +1 -97
- package/packages/client/dist/private-execution/codex-scoped-permissions.js +1 -128
- package/packages/client/dist/private-execution/delivery.js +13 -410
- package/packages/client/dist/private-execution/diagnosis-root-review.js +2 -294
- package/packages/client/dist/private-execution/frozen-handoff.js +6 -19
- package/packages/client/dist/private-execution/implementation-validation.js +2 -106
- package/packages/client/dist/private-execution/isolated-admission.js +23 -1432
- package/packages/client/dist/private-execution/isolated-session.js +5 -725
- package/packages/client/dist/private-execution/isolated-workspace.js +1 -122
- package/packages/client/dist/private-execution/pact-consumer-runtime.js +3 -409
- package/packages/client/dist/private-execution/pact-test-source.js +1 -258
- package/packages/client/dist/private-execution/pact-toolchain.js +3 -290
- package/packages/client/dist/private-execution/pact-write-set.js +1 -172
- package/packages/client/dist/private-execution/planning-diagnosis-checkpoint.js +5 -406
- package/packages/client/dist/private-execution/planning-generation-checkpoint.js +5 -462
- package/packages/client/dist/private-execution/planning-memory-checkpoint.js +3 -139
- package/packages/client/dist/private-execution/planning-research-checkpoint.js +4 -325
- package/packages/client/dist/private-execution/private-report-store.js +1 -42
- package/packages/client/dist/private-execution/property-test-candidate.js +1 -103
- package/packages/client/dist/private-execution/property-test-choices.js +3 -147
- package/packages/client/dist/private-execution/property-test-plan.js +7 -271
- package/packages/client/dist/private-execution/property-test-review.js +4 -258
- package/packages/client/dist/private-execution/property-test-runtime.js +9 -372
- package/packages/client/dist/private-execution/property-test-source.js +1 -139
- package/packages/client/dist/private-execution/root-checkpoint.js +1 -80
- package/packages/client/dist/private-execution/root-memory-git-evidence.js +3 -135
- package/packages/client/dist/private-execution/root-memory-recovery.js +1 -93
- package/packages/client/dist/private-execution/root-memory-request.js +1 -29
- package/packages/client/dist/private-execution/root-memory-scope.js +1 -178
- package/packages/client/dist/private-execution/root-memory-writer.js +1 -102
- package/packages/client/dist/private-execution/session-lease.js +1 -63
- package/packages/client/dist/private-execution/shared-private-admission-types.js +1 -50
- package/packages/client/dist/private-execution/shared-project-validation.js +1 -66
- package/packages/client/dist/private-execution/shared-root-memory-types.js +1 -61
- package/packages/client/dist/private-execution/ux-source-validation.js +1 -372
- package/packages/client/dist/private-execution/ux-write-set.js +2 -191
- package/packages/client/dist/resilience/circuit-breaker.js +1 -170
- package/packages/client/dist/resilience/degradation-manager.js +1 -164
- package/packages/client/dist/resilience/freshness-indicator.js +1 -100
- package/packages/client/dist/resilience/index.js +1 -8
- package/packages/client/dist/resilience/recovery-detector.js +1 -74
- package/packages/client/dist/resolvers/asset-resolver.js +0 -13
- package/packages/client/dist/resolvers/local-resolver.js +8 -255
- package/packages/client/dist/resolvers/remote-resolver.js +1 -233
- package/packages/client/dist/runner/binary.js +1 -404
- package/packages/client/dist/runner/cli.js +17 -1571
- package/packages/client/dist/runner/headless/adapters.js +1 -49
- package/packages/client/dist/runner/headless/claude-code-adapter.js +1 -79
- package/packages/client/dist/runner/headless/continuous-story-workspace.js +11 -1628
- package/packages/client/dist/runner/headless/epic-git-reconciliation-inventory.js +1 -69
- package/packages/client/dist/runner/headless/epic-merge-candidate-qa.js +2 -110
- package/packages/client/dist/runner/headless/epic-terminal-git-cli-adapter.js +8 -1236
- package/packages/client/dist/runner/headless/epic-terminal-git-runner.js +2 -318
- package/packages/client/dist/runner/headless/fake-adapter.js +1 -62
- package/packages/client/dist/runner/headless/managed-profile.js +1 -132
- package/packages/client/dist/runner/headless/opencode-adapter.js +2 -145
- package/packages/client/dist/runner/headless/prepared-story-bundle.js +1 -43
- package/packages/client/dist/runner/headless/resolver.js +1 -231
- package/packages/client/dist/runner/headless/run-yolo.js +1 -885
- package/packages/client/dist/runner/headless/run-yoloop.js +2 -2574
- package/packages/client/dist/runner/headless/types.js +2 -574
- package/packages/client/dist/runner/local-console.js +13 -396
- package/packages/client/dist/runner/portal-sync-worker.js +1 -1487
- package/packages/client/dist/runner/project-identity.js +1 -106
- package/packages/client/dist/runner/scheduler.js +7 -995
- package/packages/client/dist/runner-cli.js +2 -18
- package/packages/client/dist/state/invocation-shape.js +1 -13
- package/packages/client/dist/state/project-state-snapshot.js +1 -1677
- package/packages/client/dist/state/state-json-repair.js +3 -785
- package/packages/client/dist/state/structural-dag-projection.js +1 -118
- package/packages/client/dist/telemetry/index.js +1 -5
- package/packages/client/dist/telemetry/offline-queue.js +1 -131
- package/packages/client/dist/tier/index.js +1 -5
- package/packages/client/dist/tier/tier-aware-client.js +1 -405
- package/packages/client/dist/types/index.js +1 -38
- package/packages/client/dist/version.js +1 -27
- package/packages/client/dist/yolo/change-evidence-collector.js +1 -126
- package/packages/client/dist/yolo/invoke-envelope-capability.js +1 -62
- package/packages/client/dist/yolo/spec-envelope-collector.js +5 -185
- package/packages/client/dist/yoloop/discovery-hook.js +2 -300
- package/packages/client/dist/yoloop/index.js +1 -8
- package/packages/client/dist/yoloop/invoke-hooks.js +12 -669
- package/packages/client/dist/yoloop/shared-discover-epics.js +1 -1007
- package/packages/client/dist/yoloop/shared-yoloop-types.js +1 -33
- package/packages/client/dist/yoloop/target-normalization.js +1 -180
- package/packages/client/dist/yoloop/yoloop-client-state-store.js +1 -1723
- package/targets-stubs/antigravity/gemini.md +1 -1
- package/targets-stubs/antigravity/skill/SKILL.md +1 -1
- package/targets-stubs/claude-code/neocortex-root.agent.yaml +1 -1
- package/targets-stubs/claude-code/neocortex-root.md +2 -2
- package/targets-stubs/claude-code/neocortex.agent.yaml +1 -1
- package/targets-stubs/claude-code/neocortex.md +2 -2
- package/targets-stubs/codex/AGENTS.md +1 -1
- package/targets-stubs/cursor/agent.md +2 -2
- package/targets-stubs/gemini-cli/agent.md +2 -2
- package/targets-stubs/opencode/neocortex-root.md +1 -1
- package/targets-stubs/vscode/neocortex.agent.md +2 -2
|
@@ -1,396 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import { createConnection, createServer } from 'node:net';
|
|
15
|
-
import { tmpdir } from 'node:os';
|
|
16
|
-
import { dirname, join, resolve } from 'node:path';
|
|
17
|
-
import { createInterface } from 'node:readline';
|
|
18
|
-
export const LOCAL_JOBS_CONSOLE_REASON_CODES = Object.freeze({
|
|
19
|
-
OK: 'continuity-ok',
|
|
20
|
-
ATTACHED: 'jobs-console-attached',
|
|
21
|
-
NOT_ATTACHED: 'jobs-console-not-attached',
|
|
22
|
-
INVALID_SELECTOR: 'jobs-console-invalid-selector',
|
|
23
|
-
IPC_UNAVAILABLE: 'jobs-console-ipc-unavailable',
|
|
24
|
-
STDIN_CONFIRMATION_REQUIRED: 'jobs-console-stdin-confirmation-required',
|
|
25
|
-
STDIN_DISCARDED: 'jobs-console-stdin-discarded',
|
|
26
|
-
LOCAL_CONTROL_APPLIED: 'jobs-console-local-control-applied',
|
|
27
|
-
LOCAL_CONTROL_FAILED: 'jobs-console-local-control-failed',
|
|
28
|
-
});
|
|
29
|
-
const JOB_SELECTOR_PATTERN = /^@?(job-J\d{3,})$/i;
|
|
30
|
-
const SAFE_JOB_ID_PATTERN = /^job-J\d{3,}$/i;
|
|
31
|
-
const DEFAULT_CONSOLE_CONNECT_TIMEOUT_MS = 250;
|
|
32
|
-
export function isLocalJobsConsoleArgs(args) {
|
|
33
|
-
return parseLocalJobsConsoleArgs(args).kind !== 'not-console';
|
|
34
|
-
}
|
|
35
|
-
export function parseLocalJobsConsoleArgs(args) {
|
|
36
|
-
const tokens = args.trim().split(/\s+/).filter(Boolean);
|
|
37
|
-
if (tokens.length < 2)
|
|
38
|
-
return { kind: 'not-console' };
|
|
39
|
-
const command = tokens[0]?.replace(/^\*/, '').toLowerCase();
|
|
40
|
-
const operation = tokens[1]?.toLowerCase();
|
|
41
|
-
if (command !== 'jobs' || operation !== 'console')
|
|
42
|
-
return { kind: 'not-console' };
|
|
43
|
-
if (tokens.length !== 3)
|
|
44
|
-
return { kind: 'invalid', reasonCode: LOCAL_JOBS_CONSOLE_REASON_CODES.INVALID_SELECTOR };
|
|
45
|
-
const match = tokens[2]?.match(JOB_SELECTOR_PATTERN);
|
|
46
|
-
if (!match)
|
|
47
|
-
return { kind: 'invalid', reasonCode: LOCAL_JOBS_CONSOLE_REASON_CODES.INVALID_SELECTOR };
|
|
48
|
-
return { kind: 'valid', jobId: canonicalJobId(match[1]) };
|
|
49
|
-
}
|
|
50
|
-
export function localJobConsoleSocketPath(projectRoot, jobId) {
|
|
51
|
-
const root = resolve(projectRoot && projectRoot.trim().length > 0 ? projectRoot : process.cwd());
|
|
52
|
-
const rootHash = createHash('sha256').update(root).digest('hex').slice(0, 24);
|
|
53
|
-
const safeJobId = sanitizeSocketToken(canonicalJobId(jobId));
|
|
54
|
-
if (process.platform === 'win32')
|
|
55
|
-
return `\\\\.\\pipe\\neocortex-job-console-${rootHash}-${safeJobId}`;
|
|
56
|
-
return join(tmpdir(), 'neocortex-job-console', rootHash, `${safeJobId}.sock`);
|
|
57
|
-
}
|
|
58
|
-
export function createLocalJobConsoleServer(options) {
|
|
59
|
-
const jobId = canonicalJobId(options.jobId);
|
|
60
|
-
const socketPath = options.socketPath ?? localJobConsoleSocketPath(options.projectRoot, jobId);
|
|
61
|
-
const sockets = new Set();
|
|
62
|
-
let server;
|
|
63
|
-
let started = false;
|
|
64
|
-
const writeFrame = (socket, frame) => {
|
|
65
|
-
if (socket.destroyed)
|
|
66
|
-
return;
|
|
67
|
-
socket.write(`${JSON.stringify(frame)}\n`);
|
|
68
|
-
};
|
|
69
|
-
const broadcast = (frame) => {
|
|
70
|
-
for (const socket of sockets)
|
|
71
|
-
writeFrame(socket, frame);
|
|
72
|
-
};
|
|
73
|
-
const handleClientFrame = (socket, frame) => {
|
|
74
|
-
if (frame.type === 'close') {
|
|
75
|
-
socket.end();
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
if (frame.type === 'stdin') {
|
|
79
|
-
const chunk = decodeBase64Frame(frame.data);
|
|
80
|
-
if (!chunk) {
|
|
81
|
-
writeFrame(socket, { type: 'stdin_ack', ok: false, reasonCode: LOCAL_JOBS_CONSOLE_REASON_CODES.IPC_UNAVAILABLE, publicSafe: true });
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
try {
|
|
85
|
-
options.writeStdin?.(chunk);
|
|
86
|
-
writeFrame(socket, { type: 'stdin_ack', ok: true, reasonCode: LOCAL_JOBS_CONSOLE_REASON_CODES.OK, publicSafe: true });
|
|
87
|
-
}
|
|
88
|
-
catch {
|
|
89
|
-
writeFrame(socket, { type: 'stdin_ack', ok: false, reasonCode: LOCAL_JOBS_CONSOLE_REASON_CODES.IPC_UNAVAILABLE, publicSafe: true });
|
|
90
|
-
}
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
if (frame.type === 'control') {
|
|
94
|
-
const signal = signalForControl(frame.action);
|
|
95
|
-
let ok = false;
|
|
96
|
-
try {
|
|
97
|
-
ok = Boolean(signal && options.signalProcess?.(signal));
|
|
98
|
-
}
|
|
99
|
-
catch {
|
|
100
|
-
ok = false;
|
|
101
|
-
}
|
|
102
|
-
writeFrame(socket, {
|
|
103
|
-
type: 'control_ack',
|
|
104
|
-
action: frame.action,
|
|
105
|
-
ok,
|
|
106
|
-
reasonCode: ok
|
|
107
|
-
? LOCAL_JOBS_CONSOLE_REASON_CODES.LOCAL_CONTROL_APPLIED
|
|
108
|
-
: LOCAL_JOBS_CONSOLE_REASON_CODES.LOCAL_CONTROL_FAILED,
|
|
109
|
-
publicSafe: true,
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
return {
|
|
114
|
-
jobId,
|
|
115
|
-
socketPath,
|
|
116
|
-
async start() {
|
|
117
|
-
if (started)
|
|
118
|
-
return { ok: true, reasonCode: LOCAL_JOBS_CONSOLE_REASON_CODES.OK, publicSafe: true };
|
|
119
|
-
if (!SAFE_JOB_ID_PATTERN.test(jobId)) {
|
|
120
|
-
return { ok: false, reasonCode: LOCAL_JOBS_CONSOLE_REASON_CODES.INVALID_SELECTOR, publicSafe: true };
|
|
121
|
-
}
|
|
122
|
-
try {
|
|
123
|
-
if (process.platform !== 'win32') {
|
|
124
|
-
mkdirSync(dirname(socketPath), { recursive: true, mode: 0o700 });
|
|
125
|
-
if (existsSync(socketPath))
|
|
126
|
-
rmSync(socketPath, { force: true });
|
|
127
|
-
}
|
|
128
|
-
server = createServer((socket) => {
|
|
129
|
-
sockets.add(socket);
|
|
130
|
-
socket.setEncoding('utf8');
|
|
131
|
-
writeFrame(socket, {
|
|
132
|
-
type: 'attached',
|
|
133
|
-
jobId,
|
|
134
|
-
...(options.attemptId ? { attemptId: options.attemptId } : {}),
|
|
135
|
-
...(options.executionId ? { executionId: options.executionId } : {}),
|
|
136
|
-
serverHeldStream: false,
|
|
137
|
-
publicSafe: true,
|
|
138
|
-
});
|
|
139
|
-
let buffer = '';
|
|
140
|
-
socket.on('data', (chunk) => {
|
|
141
|
-
buffer += chunk;
|
|
142
|
-
const lines = buffer.split('\n');
|
|
143
|
-
buffer = lines.pop() ?? '';
|
|
144
|
-
for (const line of lines) {
|
|
145
|
-
const parsed = parseClientFrame(line);
|
|
146
|
-
if (parsed)
|
|
147
|
-
handleClientFrame(socket, parsed);
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
socket.on('close', () => sockets.delete(socket));
|
|
151
|
-
socket.on('error', () => sockets.delete(socket));
|
|
152
|
-
});
|
|
153
|
-
await new Promise((resolvePromise, rejectPromise) => {
|
|
154
|
-
server?.once('error', rejectPromise);
|
|
155
|
-
server?.listen(socketPath, () => resolvePromise());
|
|
156
|
-
});
|
|
157
|
-
started = true;
|
|
158
|
-
return { ok: true, reasonCode: LOCAL_JOBS_CONSOLE_REASON_CODES.OK, publicSafe: true };
|
|
159
|
-
}
|
|
160
|
-
catch {
|
|
161
|
-
return { ok: false, reasonCode: LOCAL_JOBS_CONSOLE_REASON_CODES.IPC_UNAVAILABLE, publicSafe: true };
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
broadcastStdout(chunk) {
|
|
165
|
-
broadcast(rawChunkFrame('stdout', chunk));
|
|
166
|
-
},
|
|
167
|
-
broadcastStderr(chunk) {
|
|
168
|
-
broadcast(rawChunkFrame('stderr', chunk));
|
|
169
|
-
},
|
|
170
|
-
close(exit = {}) {
|
|
171
|
-
broadcast({ type: 'exit', exitCode: exit.exitCode ?? null, signal: exit.signal ?? null, publicSafe: true });
|
|
172
|
-
for (const socket of sockets)
|
|
173
|
-
socket.end();
|
|
174
|
-
sockets.clear();
|
|
175
|
-
try {
|
|
176
|
-
server?.close();
|
|
177
|
-
}
|
|
178
|
-
catch {
|
|
179
|
-
// best effort cleanup only
|
|
180
|
-
}
|
|
181
|
-
if (process.platform !== 'win32') {
|
|
182
|
-
try {
|
|
183
|
-
rmSync(socketPath, { force: true });
|
|
184
|
-
}
|
|
185
|
-
catch { /* best effort */ }
|
|
186
|
-
}
|
|
187
|
-
started = false;
|
|
188
|
-
},
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
export async function runLocalJobsConsoleCommand(options) {
|
|
192
|
-
const stdout = options.stdout ?? process.stdout;
|
|
193
|
-
const stderr = options.stderr ?? process.stderr;
|
|
194
|
-
const input = options.stdin ?? process.stdin;
|
|
195
|
-
const parsed = parseLocalJobsConsoleArgs(options.args);
|
|
196
|
-
if (parsed.kind === 'not-console') {
|
|
197
|
-
return publicConsoleResult('invalid', 1, undefined, [LOCAL_JOBS_CONSOLE_REASON_CODES.INVALID_SELECTOR]);
|
|
198
|
-
}
|
|
199
|
-
if (parsed.kind === 'invalid') {
|
|
200
|
-
const result = publicConsoleResult('invalid', 1, undefined, [parsed.reasonCode]);
|
|
201
|
-
writeConsoleStatus(stdout, result, options.format);
|
|
202
|
-
return result;
|
|
203
|
-
}
|
|
204
|
-
const socketPath = localJobConsoleSocketPath(options.projectRoot, parsed.jobId);
|
|
205
|
-
const connectTimeoutMs = Math.max(10, Math.min(5_000, Math.floor(options.connectTimeoutMs ?? DEFAULT_CONSOLE_CONNECT_TIMEOUT_MS)));
|
|
206
|
-
return await new Promise((resolvePromise) => {
|
|
207
|
-
const socket = createConnection(socketPath);
|
|
208
|
-
let attached = false;
|
|
209
|
-
let settled = false;
|
|
210
|
-
let buffer = '';
|
|
211
|
-
let pendingStdin;
|
|
212
|
-
const reasonCodes = new Set();
|
|
213
|
-
let cleanupInput = () => { };
|
|
214
|
-
const timer = setTimeout(() => {
|
|
215
|
-
if (attached || settled)
|
|
216
|
-
return;
|
|
217
|
-
settled = true;
|
|
218
|
-
socket.destroy();
|
|
219
|
-
const result = publicConsoleResult('not-attached', 0, parsed.jobId, [LOCAL_JOBS_CONSOLE_REASON_CODES.NOT_ATTACHED]);
|
|
220
|
-
writeConsoleStatus(stdout, result, options.format);
|
|
221
|
-
resolvePromise(result);
|
|
222
|
-
}, connectTimeoutMs);
|
|
223
|
-
const finish = (status, exitCode = 0) => {
|
|
224
|
-
if (settled)
|
|
225
|
-
return;
|
|
226
|
-
settled = true;
|
|
227
|
-
clearTimeout(timer);
|
|
228
|
-
cleanupInput();
|
|
229
|
-
socket.end();
|
|
230
|
-
resolvePromise(publicConsoleResult(status, exitCode, parsed.jobId, Array.from(reasonCodes)));
|
|
231
|
-
};
|
|
232
|
-
const sendFrame = (frame) => {
|
|
233
|
-
if (!socket.destroyed)
|
|
234
|
-
socket.write(`${JSON.stringify(frame)}\n`);
|
|
235
|
-
};
|
|
236
|
-
const sendControl = (action) => {
|
|
237
|
-
sendFrame({ type: 'control', action });
|
|
238
|
-
};
|
|
239
|
-
const readline = createInterface({ input, terminal: false });
|
|
240
|
-
const onLine = (line) => {
|
|
241
|
-
if (!attached)
|
|
242
|
-
return;
|
|
243
|
-
const trimmed = line.trim();
|
|
244
|
-
if (pendingStdin !== undefined) {
|
|
245
|
-
if (trimmed === 'yes') {
|
|
246
|
-
sendFrame({ type: 'stdin', data: Buffer.from(`${pendingStdin}\n`, 'utf8').toString('base64'), encoding: 'base64' });
|
|
247
|
-
}
|
|
248
|
-
else {
|
|
249
|
-
reasonCodes.add(LOCAL_JOBS_CONSOLE_REASON_CODES.STDIN_DISCARDED);
|
|
250
|
-
stdout.write('[jobs-console] stdin discarded; explicit confirmation was not provided.\n');
|
|
251
|
-
}
|
|
252
|
-
pendingStdin = undefined;
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
if (trimmed === '/quit') {
|
|
256
|
-
sendFrame({ type: 'close' });
|
|
257
|
-
finish('attached', 0);
|
|
258
|
-
return;
|
|
259
|
-
}
|
|
260
|
-
if (trimmed === '/pause' || trimmed === '/resume' || trimmed === '/cancel') {
|
|
261
|
-
sendControl(trimmed.slice(1));
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
pendingStdin = line;
|
|
265
|
-
reasonCodes.add(LOCAL_JOBS_CONSOLE_REASON_CODES.STDIN_CONFIRMATION_REQUIRED);
|
|
266
|
-
stdout.write('[jobs-console] confirm stdin: type yes to send this line to the local process; anything else discards it.\n');
|
|
267
|
-
};
|
|
268
|
-
cleanupInput = () => {
|
|
269
|
-
readline.removeListener('line', onLine);
|
|
270
|
-
readline.close();
|
|
271
|
-
};
|
|
272
|
-
readline.on('line', onLine);
|
|
273
|
-
socket.on('connect', () => {
|
|
274
|
-
attached = true;
|
|
275
|
-
clearTimeout(timer);
|
|
276
|
-
reasonCodes.add(LOCAL_JOBS_CONSOLE_REASON_CODES.ATTACHED);
|
|
277
|
-
stdout.write(`[jobs-console] attached job=${parsed.jobId} serverHeldStream=false serverAccessToLocalhost=false controls=/pause,/resume,/cancel,/quit\n`);
|
|
278
|
-
});
|
|
279
|
-
socket.on('data', (chunk) => {
|
|
280
|
-
buffer += chunk.toString('utf8');
|
|
281
|
-
const lines = buffer.split('\n');
|
|
282
|
-
buffer = lines.pop() ?? '';
|
|
283
|
-
for (const line of lines) {
|
|
284
|
-
const frame = parseServerFrame(line);
|
|
285
|
-
if (!frame)
|
|
286
|
-
continue;
|
|
287
|
-
if (frame.type === 'stdout')
|
|
288
|
-
stdout.write(decodeBase64Frame(frame.data) ?? Buffer.alloc(0));
|
|
289
|
-
else if (frame.type === 'stderr')
|
|
290
|
-
stderr.write(decodeBase64Frame(frame.data) ?? Buffer.alloc(0));
|
|
291
|
-
else if (frame.type === 'control_ack') {
|
|
292
|
-
reasonCodes.add(frame.reasonCode);
|
|
293
|
-
stdout.write(`[jobs-console] control ${frame.action} ${frame.ok ? 'applied' : 'failed'} reason=${frame.reasonCode}\n`);
|
|
294
|
-
}
|
|
295
|
-
else if (frame.type === 'stdin_ack') {
|
|
296
|
-
reasonCodes.add(frame.reasonCode);
|
|
297
|
-
stdout.write(`[jobs-console] stdin ${frame.ok ? 'sent' : 'failed'} reason=${frame.reasonCode}\n`);
|
|
298
|
-
}
|
|
299
|
-
else if (frame.type === 'exit') {
|
|
300
|
-
finish('attached', 0);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
});
|
|
304
|
-
socket.on('error', () => {
|
|
305
|
-
if (attached || settled) {
|
|
306
|
-
reasonCodes.add(LOCAL_JOBS_CONSOLE_REASON_CODES.IPC_UNAVAILABLE);
|
|
307
|
-
finish('error', 1);
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
310
|
-
settled = true;
|
|
311
|
-
clearTimeout(timer);
|
|
312
|
-
cleanupInput();
|
|
313
|
-
const result = publicConsoleResult('not-attached', 0, parsed.jobId, [LOCAL_JOBS_CONSOLE_REASON_CODES.NOT_ATTACHED]);
|
|
314
|
-
writeConsoleStatus(stdout, result, options.format);
|
|
315
|
-
resolvePromise(result);
|
|
316
|
-
});
|
|
317
|
-
socket.on('close', () => {
|
|
318
|
-
if (!settled && attached)
|
|
319
|
-
finish('attached', 0);
|
|
320
|
-
});
|
|
321
|
-
});
|
|
322
|
-
}
|
|
323
|
-
function canonicalJobId(value) {
|
|
324
|
-
const raw = value.replace(/^@/, '');
|
|
325
|
-
const match = raw.match(/^job-J(\d{3,})$/i);
|
|
326
|
-
return match ? `job-J${match[1]}` : raw;
|
|
327
|
-
}
|
|
328
|
-
function sanitizeSocketToken(value) {
|
|
329
|
-
return value.replace(/[^A-Za-z0-9._-]+/g, '-').slice(0, 80) || 'job';
|
|
330
|
-
}
|
|
331
|
-
function rawChunkFrame(type, chunk) {
|
|
332
|
-
return { type, data: Buffer.from(chunk).toString('base64'), encoding: 'base64' };
|
|
333
|
-
}
|
|
334
|
-
function parseClientFrame(line) {
|
|
335
|
-
const frame = parseJsonRecord(line);
|
|
336
|
-
if (!frame)
|
|
337
|
-
return undefined;
|
|
338
|
-
if (frame.type === 'stdin' && typeof frame.data === 'string' && frame.encoding === 'base64')
|
|
339
|
-
return frame;
|
|
340
|
-
if (frame.type === 'control' && (frame.action === 'pause' || frame.action === 'resume' || frame.action === 'cancel'))
|
|
341
|
-
return frame;
|
|
342
|
-
if (frame.type === 'close')
|
|
343
|
-
return { type: 'close' };
|
|
344
|
-
return undefined;
|
|
345
|
-
}
|
|
346
|
-
function parseServerFrame(line) {
|
|
347
|
-
const frame = parseJsonRecord(line);
|
|
348
|
-
if (!frame || typeof frame.type !== 'string')
|
|
349
|
-
return undefined;
|
|
350
|
-
return frame;
|
|
351
|
-
}
|
|
352
|
-
function parseJsonRecord(line) {
|
|
353
|
-
if (!line.trim())
|
|
354
|
-
return undefined;
|
|
355
|
-
try {
|
|
356
|
-
const parsed = JSON.parse(line);
|
|
357
|
-
return typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed) ? parsed : undefined;
|
|
358
|
-
}
|
|
359
|
-
catch {
|
|
360
|
-
return undefined;
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
function decodeBase64Frame(value) {
|
|
364
|
-
try {
|
|
365
|
-
return Buffer.from(value, 'base64');
|
|
366
|
-
}
|
|
367
|
-
catch {
|
|
368
|
-
return undefined;
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
function signalForControl(action) {
|
|
372
|
-
if (action === 'pause')
|
|
373
|
-
return process.platform === 'win32' ? undefined : 'SIGSTOP';
|
|
374
|
-
if (action === 'resume')
|
|
375
|
-
return process.platform === 'win32' ? undefined : 'SIGCONT';
|
|
376
|
-
return 'SIGTERM';
|
|
377
|
-
}
|
|
378
|
-
function publicConsoleResult(status, exitCode, jobId, reasonCodes) {
|
|
379
|
-
return {
|
|
380
|
-
status,
|
|
381
|
-
exitCode,
|
|
382
|
-
...(jobId ? { jobId } : {}),
|
|
383
|
-
reasonCodes: reasonCodes.length > 0 ? Array.from(new Set(reasonCodes)) : [LOCAL_JOBS_CONSOLE_REASON_CODES.OK],
|
|
384
|
-
serverHeldStream: false,
|
|
385
|
-
serverAccessToLocalhost: false,
|
|
386
|
-
publicSafe: true,
|
|
387
|
-
};
|
|
388
|
-
}
|
|
389
|
-
function writeConsoleStatus(stdout, result, format = 'plain') {
|
|
390
|
-
if (format === 'json') {
|
|
391
|
-
stdout.write(`${JSON.stringify({ type: 'jobs_console_status', ...result })}\n`);
|
|
392
|
-
return;
|
|
393
|
-
}
|
|
394
|
-
const job = result.jobId ? ` job=${result.jobId}` : '';
|
|
395
|
-
stdout.write(`[jobs-console] status=${result.status}${job} serverHeldStream=false serverAccessToLocalhost=false reasons=${result.reasonCodes.join(',')}\n`);
|
|
396
|
-
}
|
|
1
|
+
import{createHash as $}from"node:crypto";import{existsSync as J,mkdirSync as x,rmSync as N}from"node:fs";import{createConnection as P,createServer as B}from"node:net";import{tmpdir as F}from"node:os";import{dirname as H,join as M,resolve as V}from"node:path";import{createInterface as U}from"node:readline";const a=Object.freeze({OK:"continuity-ok",ATTACHED:"jobs-console-attached",NOT_ATTACHED:"jobs-console-not-attached",INVALID_SELECTOR:"jobs-console-invalid-selector",IPC_UNAVAILABLE:"jobs-console-ipc-unavailable",STDIN_CONFIRMATION_REQUIRED:"jobs-console-stdin-confirmation-required",STDIN_DISCARDED:"jobs-console-stdin-discarded",LOCAL_CONTROL_APPLIED:"jobs-console-local-control-applied",LOCAL_CONTROL_FAILED:"jobs-console-local-control-failed"}),K=/^@?(job-J\d{3,})$/i,q=/^job-J\d{3,}$/i,z=250;function re(t){return w(t).kind!=="not-console"}function w(t){const e=t.trim().split(/\s+/).filter(Boolean);if(e.length<2)return{kind:"not-console"};const r=e[0]?.replace(/^\*/,"").toLowerCase(),c=e[1]?.toLowerCase();if(r!=="jobs"||c!=="console")return{kind:"not-console"};if(e.length!==3)return{kind:"invalid",reasonCode:a.INVALID_SELECTOR};const s=e[2]?.match(K);return s?{kind:"valid",jobId:O(s[1])}:{kind:"invalid",reasonCode:a.INVALID_SELECTOR}}function D(t,e){const r=V(t&&t.trim().length>0?t:process.cwd()),c=$("sha256").update(r).digest("hex").slice(0,24),s=G(O(e));return process.platform==="win32"?`\\\\.\\pipe\\neocortex-job-console-${c}-${s}`:M(F(),"neocortex-job-console",c,`${s}.sock`)}function se(t){const e=O(t.jobId),r=t.socketPath??D(t.projectRoot,e),c=new Set;let s,I=!1;const b=(o,n)=>{o.destroyed||o.write(`${JSON.stringify(n)}
|
|
2
|
+
`)},p=o=>{for(const n of c)b(n,o)},m=(o,n)=>{if(n.type==="close"){o.end();return}if(n.type==="stdin"){const f=h(n.data);if(!f){b(o,{type:"stdin_ack",ok:!1,reasonCode:a.IPC_UNAVAILABLE,publicSafe:!0});return}try{t.writeStdin?.(f),b(o,{type:"stdin_ack",ok:!0,reasonCode:a.OK,publicSafe:!0})}catch{b(o,{type:"stdin_ack",ok:!1,reasonCode:a.IPC_UNAVAILABLE,publicSafe:!0})}return}if(n.type==="control"){const f=W(n.action);let l=!1;try{l=!!(f&&t.signalProcess?.(f))}catch{l=!1}b(o,{type:"control_ack",action:n.action,ok:l,reasonCode:l?a.LOCAL_CONTROL_APPLIED:a.LOCAL_CONTROL_FAILED,publicSafe:!0})}};return{jobId:e,socketPath:r,async start(){if(I)return{ok:!0,reasonCode:a.OK,publicSafe:!0};if(!q.test(e))return{ok:!1,reasonCode:a.INVALID_SELECTOR,publicSafe:!0};try{return process.platform!=="win32"&&(x(H(r),{recursive:!0,mode:448}),J(r)&&N(r,{force:!0})),s=B(o=>{c.add(o),o.setEncoding("utf8"),b(o,{type:"attached",jobId:e,...t.attemptId?{attemptId:t.attemptId}:{},...t.executionId?{executionId:t.executionId}:{},serverHeldStream:!1,publicSafe:!0});let n="";o.on("data",f=>{n+=f;const l=n.split(`
|
|
3
|
+
`);n=l.pop()??"";for(const C of l){const S=Q(C);S&&m(o,S)}}),o.on("close",()=>c.delete(o)),o.on("error",()=>c.delete(o))}),await new Promise((o,n)=>{s?.once("error",n),s?.listen(r,()=>o())}),I=!0,{ok:!0,reasonCode:a.OK,publicSafe:!0}}catch{return{ok:!1,reasonCode:a.IPC_UNAVAILABLE,publicSafe:!0}}},broadcastStdout(o){p(g("stdout",o))},broadcastStderr(o){p(g("stderr",o))},close(o={}){p({type:"exit",exitCode:o.exitCode??null,signal:o.signal??null,publicSafe:!0});for(const n of c)n.end();c.clear();try{s?.close()}catch{}if(process.platform!=="win32")try{N(r,{force:!0})}catch{}I=!1}}}async function ae(t){const e=t.stdout??process.stdout,r=t.stderr??process.stderr,c=t.stdin??process.stdin,s=w(t.args);if(s.kind==="not-console")return A("invalid",1,void 0,[a.INVALID_SELECTOR]);if(s.kind==="invalid"){const p=A("invalid",1,void 0,[s.reasonCode]);return E(e,p,t.format),p}const I=D(t.projectRoot,s.jobId),b=Math.max(10,Math.min(5e3,Math.floor(t.connectTimeoutMs??z)));return await new Promise(p=>{const m=P(I);let o=!1,n=!1,f="",l;const C=new Set;let S=()=>{};const L=setTimeout(()=>{if(o||n)return;n=!0,m.destroy();const i=A("not-attached",0,s.jobId,[a.NOT_ATTACHED]);E(e,i,t.format),p(i)},b),y=(i,u=0)=>{n||(n=!0,clearTimeout(L),S(),m.end(),p(A(i,u,s.jobId,Array.from(C))))},T=i=>{m.destroyed||m.write(`${JSON.stringify(i)}
|
|
4
|
+
`)},R=i=>{T({type:"control",action:i})},_=U({input:c,terminal:!1}),j=i=>{if(!o)return;const u=i.trim();if(l!==void 0){u==="yes"?T({type:"stdin",data:Buffer.from(`${l}
|
|
5
|
+
`,"utf8").toString("base64"),encoding:"base64"}):(C.add(a.STDIN_DISCARDED),e.write(`[jobs-console] stdin discarded; explicit confirmation was not provided.
|
|
6
|
+
`)),l=void 0;return}if(u==="/quit"){T({type:"close"}),y("attached",0);return}if(u==="/pause"||u==="/resume"||u==="/cancel"){R(u.slice(1));return}l=i,C.add(a.STDIN_CONFIRMATION_REQUIRED),e.write(`[jobs-console] confirm stdin: type yes to send this line to the local process; anything else discards it.
|
|
7
|
+
`)};S=()=>{_.removeListener("line",j),_.close()},_.on("line",j),m.on("connect",()=>{o=!0,clearTimeout(L),C.add(a.ATTACHED),e.write(`[jobs-console] attached job=${s.jobId} serverHeldStream=false serverAccessToLocalhost=false controls=/pause,/resume,/cancel,/quit
|
|
8
|
+
`)}),m.on("data",i=>{f+=i.toString("utf8");const u=f.split(`
|
|
9
|
+
`);f=u.pop()??"";for(const v of u){const d=Z(v);d&&(d.type==="stdout"?e.write(h(d.data)??Buffer.alloc(0)):d.type==="stderr"?r.write(h(d.data)??Buffer.alloc(0)):d.type==="control_ack"?(C.add(d.reasonCode),e.write(`[jobs-console] control ${d.action} ${d.ok?"applied":"failed"} reason=${d.reasonCode}
|
|
10
|
+
`)):d.type==="stdin_ack"?(C.add(d.reasonCode),e.write(`[jobs-console] stdin ${d.ok?"sent":"failed"} reason=${d.reasonCode}
|
|
11
|
+
`)):d.type==="exit"&&y("attached",0))}}),m.on("error",()=>{if(o||n){C.add(a.IPC_UNAVAILABLE),y("error",1);return}n=!0,clearTimeout(L),S();const i=A("not-attached",0,s.jobId,[a.NOT_ATTACHED]);E(e,i,t.format),p(i)}),m.on("close",()=>{!n&&o&&y("attached",0)})})}function O(t){const e=t.replace(/^@/,""),r=e.match(/^job-J(\d{3,})$/i);return r?`job-J${r[1]}`:e}function G(t){return t.replace(/[^A-Za-z0-9._-]+/g,"-").slice(0,80)||"job"}function g(t,e){return{type:t,data:Buffer.from(e).toString("base64"),encoding:"base64"}}function Q(t){const e=k(t);if(e){if(e.type==="stdin"&&typeof e.data=="string"&&e.encoding==="base64"||e.type==="control"&&(e.action==="pause"||e.action==="resume"||e.action==="cancel"))return e;if(e.type==="close")return{type:"close"}}}function Z(t){const e=k(t);if(!(!e||typeof e.type!="string"))return e}function k(t){if(t.trim())try{const e=JSON.parse(t);return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0}catch{return}}function h(t){try{return Buffer.from(t,"base64")}catch{return}}function W(t){return t==="pause"?process.platform==="win32"?void 0:"SIGSTOP":t==="resume"?process.platform==="win32"?void 0:"SIGCONT":"SIGTERM"}function A(t,e,r,c){return{status:t,exitCode:e,...r?{jobId:r}:{},reasonCodes:c.length>0?Array.from(new Set(c)):[a.OK],serverHeldStream:!1,serverAccessToLocalhost:!1,publicSafe:!0}}function E(t,e,r="plain"){if(r==="json"){t.write(`${JSON.stringify({type:"jobs_console_status",...e})}
|
|
12
|
+
`);return}const c=e.jobId?` job=${e.jobId}`:"";t.write(`[jobs-console] status=${e.status}${c} serverHeldStream=false serverAccessToLocalhost=false reasons=${e.reasonCodes.join(",")}
|
|
13
|
+
`)}export{a as LOCAL_JOBS_CONSOLE_REASON_CODES,se as createLocalJobConsoleServer,re as isLocalJobsConsoleArgs,D as localJobConsoleSocketPath,w as parseLocalJobsConsoleArgs,ae as runLocalJobsConsoleCommand};
|