sneakoscope 8.0.2 → 8.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -23
- package/config/skills-hash-ledger.v1.json +1 -1
- package/crates/sks-core/Cargo.lock +1 -1
- package/crates/sks-core/Cargo.toml +1 -1
- package/dist/bin/fast-inline.js +55 -13
- package/dist/bin/sks-dispatch.js +1 -1
- package/dist/cli/command-manifest-lite.js +4 -0
- package/dist/cli/command-registry.js +4 -0
- package/dist/cli/install-helpers-codex-lb-chain.js +187 -0
- package/dist/cli/install-helpers-codex-lb-config.js +74 -8
- package/dist/cli/install-helpers.js +89 -44
- package/dist/commands/codex-lb.js +117 -19
- package/dist/commands/doctor.js +697 -37
- package/dist/config/skills-manifest.json +3 -2
- package/dist/core/agents/agent-runner-codex-exec.js +5 -3
- package/dist/core/codex/codex-config-guard.js +238 -52
- package/dist/core/codex-adapter.js +5 -3
- package/dist/core/codex-app/menubar/constants.js +10 -1
- package/dist/core/codex-app/menubar/global-install.js +288 -0
- package/dist/core/codex-app/menubar/installer.js +79 -14
- package/dist/core/codex-app/menubar/launch-agent.js +267 -45
- package/dist/core/codex-app/menubar/paths.js +3 -0
- package/dist/core/codex-app/menubar/rollback.js +55 -7
- package/dist/core/codex-app/menubar/status.js +75 -4
- package/dist/core/codex-control/codex-0139-image-path-real-probe.js +3 -1
- package/dist/core/codex-control/codex-0139-web-search-probe.js +3 -1
- package/dist/core/codex-control/codex-app-server-runtime-env.js +13 -4
- package/dist/core/codex-control/codex-app-server-v2-client.js +3 -3
- package/dist/core/codex-exec-output-schema.js +4 -1
- package/dist/core/codex-lb/codex-lb-env.js +63 -72
- package/dist/core/codex-lb/codex-lb-setup.js +15 -2
- package/dist/core/codex-lb/desktop-center-credentials.js +517 -58
- package/dist/core/codex-lb/desktop-controller.js +153 -24
- package/dist/core/codex-lb/routing-truth.js +327 -0
- package/dist/core/codex-native/core-skill-manifest.js +1 -1
- package/dist/core/commands/basic-cli.js +7 -1
- package/dist/core/commands/qa-loop-command.js +3 -1
- package/dist/core/commands/telegram-command.js +241 -0
- package/dist/core/config-adopt/config-adopt-command.js +35 -0
- package/dist/core/config-adopt/config-adopt.js +346 -0
- package/dist/core/config-adopt/index.js +3 -0
- package/dist/core/doctor/command-alias-cleanup.js +4 -1
- package/dist/core/doctor/current-project-guidance-nested.js +37 -6
- package/dist/core/doctor/current-project-guidance.js +11 -6
- package/dist/core/doctor/doctor-readiness-matrix.js +14 -0
- package/dist/core/doctor/retired-managed-residue-private.js +1 -1
- package/dist/core/doctor/sks-menubar-doctor.js +4 -0
- package/dist/core/feature-fixtures.js +8 -0
- package/dist/core/hooks-runtime/hook-context.js +9 -0
- package/dist/core/hooks-runtime/managed-skill-admission.js +54 -4
- package/dist/core/hooks-runtime/official-subagent-lifecycle.js +69 -1
- package/dist/core/hooks-runtime/subagent-skill-availability-contract.js +2 -2
- package/dist/core/hooks-runtime/subagent-skill-availability-evidence.js +3 -3
- package/dist/core/hooks-runtime/subagent-skill-availability-guards.js +43 -5
- package/dist/core/hooks-runtime/subagent-skill-availability.js +64 -30
- package/dist/core/hooks-runtime/subagent-stop-hook.js +15 -2
- package/dist/core/hooks-runtime.js +148 -4
- package/dist/core/imagegen/imagegen-capability.js +46 -0
- package/dist/core/imagegen/require-imagegen.js +2 -2
- package/dist/core/init/skills.js +17 -3
- package/dist/core/install/installed-package-smoke.js +8 -2
- package/dist/core/naruto/hardware-capacity-probe.js +9 -3
- package/dist/core/naruto/naruto-concurrency-governor.js +68 -24
- package/dist/core/perf/import-graph-budget.js +0 -1
- package/dist/core/product-design-app-server.js +13 -1
- package/dist/core/release/package-size-budget.js +2 -2
- package/dist/core/release/release-pack-receipt.js +1 -2
- package/dist/core/routes/dollar-manifest-lite.js +1 -1
- package/dist/core/routes.js +1 -1
- package/dist/core/security/private-credential-file.js +209 -0
- package/dist/core/subagents/agent-catalog.js +17 -32
- package/dist/core/subagents/naruto-help-contract.js +5 -5
- package/dist/core/subagents/official-subagent-config.js +16 -6
- package/dist/core/subagents/official-subagent-preparation.js +34 -15
- package/dist/core/subagents/official-subagent-prompt.js +4 -4
- package/dist/core/subagents/official-subagent-runner.js +27 -4
- package/dist/core/subagents/thread-budget.js +19 -12
- package/dist/core/subagents/wave-lifecycle.js +18 -6
- package/dist/core/telegram/access.js +54 -0
- package/dist/core/telegram/client.js +144 -0
- package/dist/core/telegram/confirmation.js +37 -0
- package/dist/core/telegram/doctor.js +151 -0
- package/dist/core/telegram/index.js +9 -0
- package/dist/core/telegram/keychain.js +265 -0
- package/dist/core/telegram/liveness.js +109 -0
- package/dist/core/telegram/poller.js +90 -0
- package/dist/core/telegram/redaction.js +15 -0
- package/dist/core/telegram/types.js +1 -0
- package/dist/core/update/update-diagnostics.js +52 -0
- package/dist/core/update/update-migration-state.js +5 -1
- package/dist/core/update/update-operation.js +2 -1
- package/dist/core/update/update-stage-diagnostics.js +38 -0
- package/dist/core/update/update-status.js +2 -9
- package/dist/core/update-check.js +147 -31
- package/dist/core/version.js +1 -1
- package/dist/core/zellij/zellij-launcher.js +23 -4
- package/dist/native/sks-menubar/Sources/AppDelegate.swift +13 -0
- package/dist/native/sks-menubar/Sources/AppIdentity.swift +7 -0
- package/dist/native/sks-menubar/Sources/OperationCoordinator.swift +3 -2
- package/dist/native/sks-menubar/Sources/ProvidersConnectTest.swift +115 -0
- package/dist/native/sks-menubar/Sources/ProvidersFastMode.swift +17 -0
- package/dist/native/sks-menubar/Sources/ProvidersRoutingTruth.swift +190 -0
- package/dist/native/sks-menubar/Sources/ProvidersViewController.swift +100 -59
- package/dist/native/sks-menubar/Sources/SingletonInstanceGuard.swift +328 -0
- package/dist/native/sks-menubar/Sources/TelegramPrivateFileStore.swift +320 -0
- package/dist/native/sks-menubar/Sources/TelegramPrivateFileSupport.swift +303 -0
- package/dist/native/sks-menubar/Sources/TelegramProcessGateway.swift +238 -0
- package/dist/native/sks-menubar/Sources/TelegramRuntimeSupport.swift +56 -0
- package/dist/native/sks-menubar/Sources/TelegramSupport.swift +56 -0
- package/dist/native/sks-menubar/Sources/TelegramTransport.swift +474 -0
- package/dist/native/sks-menubar/Sources/main.swift +15 -1
- package/dist/native/sks-menubar/Tests/OperationCoordinatorTests.swift +4 -3
- package/dist/native/sks-menubar/Tests/ProvidersViewControllerTests.swift +129 -0
- package/dist/native/sks-menubar/Tests/SingletonInstanceGuardTests.swift +183 -0
- package/dist/native/sks-menubar/Tests/TelegramRuntimeSmokeTests.swift +267 -0
- package/dist/native/sks-menubar/Tests/TelegramRuntimeTests.swift +222 -0
- package/dist/scripts/codex-lb-fast-mode-truth-check.js +1 -1
- package/dist/scripts/codex-lb-fast-ui-preservation-check.js +1 -1
- package/dist/scripts/current-command-surface-check.js +2 -4
- package/dist/scripts/official-subagent-workflow-check.js +1 -1
- package/dist/scripts/packlist-performance-check.js +1 -2
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ import { nowIso, sha256 } from '../fsx.js';
|
|
|
3
3
|
import {} from '../codex-native/sks-skill-paths.js';
|
|
4
4
|
import { resolveManagedSkillSourcesForAdmission } from './managed-skill-admission.js';
|
|
5
5
|
import { ADMISSION_SCHEMA, MAX_LIFECYCLE_GUARD_BYTES, MAX_LIFECYCLE_THREADS, SUBAGENT_SKILL_AVAILABILITY_BLOCKER_FILENAME, SUBAGENT_SKILL_AVAILABILITY_BLOCKER_SCHEMA, SubagentSkillAvailabilityGuardError, validBlocker } from './subagent-skill-availability-contract.js';
|
|
6
|
-
import { admissionFingerprint, admissionGuardRoots, blockedRunAdmissions, boundedAgentThreadId, invalidGuard, officialSubagentThreadIdFromSessions, officialSubagentThreadIdFromTranscript, preToolBlockReason, readAdmissionPair, readBoundedConfinedJson, readConfinedJson, safeRemoveGuard, threadGuardPath, turnGuardPath, writeAdmissionPair } from './subagent-skill-availability-guards.js';
|
|
6
|
+
import { admissionFingerprint, admissionGuardRoots, admissionGuardRootsWithLegacyMirrors, blockedRunAdmissions, boundedAgentThreadId, invalidGuard, officialSubagentThreadIdFromSessions, officialSubagentThreadIdFromTranscript, preToolBlockReason, readAdmissionForThread, readAdmissionPair, readBoundedConfinedJson, readConfinedJson, safeRemoveGuard, threadGuardPath, turnGuardPath, writeAdmissionPair } from './subagent-skill-availability-guards.js';
|
|
7
7
|
import { clearMatchingBlockerEvidence, emergencyRunBlockers, matchingArtifactBlockers, persistBlockerEvidence } from './subagent-skill-availability-evidence.js';
|
|
8
8
|
export { SUBAGENT_SKILL_AVAILABILITY_BLOCKER_FILENAME, SUBAGENT_SKILL_AVAILABILITY_BLOCKER_SCHEMA } from './subagent-skill-availability-contract.js';
|
|
9
9
|
export function authoritativeSksSkillResolutionBlockers(resolution) {
|
|
@@ -46,7 +46,11 @@ export async function persistSubagentSkillAvailabilityBlocker(input) {
|
|
|
46
46
|
blockers,
|
|
47
47
|
recorded_at: nowIso()
|
|
48
48
|
};
|
|
49
|
-
const
|
|
49
|
+
const binding = {
|
|
50
|
+
missionId: admission.mission_id,
|
|
51
|
+
workflowRunId: admission.workflow_run_id
|
|
52
|
+
};
|
|
53
|
+
const { scoped: roots } = await admissionGuardRootsWithLegacyMirrors(input.root, input.artifactDir, binding);
|
|
50
54
|
const guardedAdmission = blockers.length
|
|
51
55
|
? admission
|
|
52
56
|
: {
|
|
@@ -136,16 +140,23 @@ export async function subagentSkillAvailabilityPreToolBlockReason(root, payload,
|
|
|
136
140
|
: null;
|
|
137
141
|
const admissions = [];
|
|
138
142
|
const errors = [];
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
143
|
+
const binding = { missionId: activeMissionId, workflowRunId: activeWorkflowRunId };
|
|
144
|
+
const { scoped, legacy } = await admissionGuardRootsWithLegacyMirrors(root, artifactDir, binding);
|
|
145
|
+
const readRoots = async (roots) => {
|
|
146
|
+
for (const guardRoot of roots) {
|
|
147
|
+
try {
|
|
148
|
+
const admission = await readAdmissionPair(guardRoot, threadHash, sessionHash, turnHash);
|
|
149
|
+
if (admission)
|
|
150
|
+
admissions.push(admission);
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
errors.push(error);
|
|
154
|
+
}
|
|
147
155
|
}
|
|
148
|
-
}
|
|
156
|
+
};
|
|
157
|
+
await readRoots(scoped);
|
|
158
|
+
if (!admissions.length && !errors.length)
|
|
159
|
+
await readRoots(legacy);
|
|
149
160
|
const invalidChildEvidence = errors.some((error) => (error instanceof SubagentSkillAvailabilityGuardError && error.childEvidence));
|
|
150
161
|
if (artifactEvidence) {
|
|
151
162
|
if (!activeMissionId
|
|
@@ -232,30 +243,53 @@ export async function recoverResumedOfficialSubagentSkillAvailabilityAdmission(i
|
|
|
232
243
|
});
|
|
233
244
|
return true;
|
|
234
245
|
}
|
|
235
|
-
export async function clearSubagentSkillAvailabilityGuards(root, payload, artifactDir) {
|
|
236
|
-
const threadId =
|
|
246
|
+
export async function clearSubagentSkillAvailabilityGuards(root, payload, artifactDir, activeBinding) {
|
|
247
|
+
const threadId = boundedAgentThreadId(payload?.agent_id);
|
|
237
248
|
const sessionScope = String(payload?.session_id || '').trim();
|
|
238
249
|
const turnId = String(payload?.turn_id || '').trim();
|
|
239
|
-
const
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
250
|
+
const missionId = String(activeBinding?.missionId || '').trim();
|
|
251
|
+
const workflowRunId = String(activeBinding?.workflowRunId || '').trim();
|
|
252
|
+
const payloadWorkflowRunId = String(payload?.workflow_run_id || payload?.run_id || '').trim();
|
|
253
|
+
if (!threadId || !missionId || !workflowRunId)
|
|
254
|
+
return;
|
|
255
|
+
if (payloadWorkflowRunId && payloadWorkflowRunId !== workflowRunId)
|
|
256
|
+
return;
|
|
257
|
+
const threadHash = sha256(threadId);
|
|
258
|
+
const sessionHash = sessionScope ? sha256(sessionScope) : null;
|
|
259
|
+
const turnHash = turnId ? sha256(turnId) : null;
|
|
260
|
+
const { scoped, legacy } = await admissionGuardRootsWithLegacyMirrors(root, artifactDir, {
|
|
261
|
+
missionId,
|
|
262
|
+
workflowRunId
|
|
263
|
+
});
|
|
264
|
+
await Promise.all([...scoped, ...legacy].map(async (guardRoot) => {
|
|
265
|
+
let admission;
|
|
266
|
+
try {
|
|
267
|
+
admission = await readAdmissionForThread(guardRoot, threadHash);
|
|
268
|
+
if (admission) {
|
|
269
|
+
admission = await readAdmissionPair(guardRoot, threadHash, admission.session_scope_hash, admission.turn_id_hash);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
catch {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
if (!admission
|
|
276
|
+
|| admission.mission_id !== missionId
|
|
277
|
+
|| admission.workflow_run_id !== workflowRunId
|
|
278
|
+
|| (sessionHash && admission.session_scope_hash !== sessionHash)
|
|
279
|
+
|| (turnHash && admission.turn_id_hash !== turnHash))
|
|
280
|
+
return;
|
|
281
|
+
await Promise.all([
|
|
282
|
+
safeRemoveGuard(threadGuardPath(guardRoot.root, threadHash), guardRoot.boundary),
|
|
283
|
+
safeRemoveGuard(turnGuardPath(guardRoot.root, admission.session_scope_hash, admission.turn_id_hash), guardRoot.boundary)
|
|
284
|
+
]);
|
|
285
|
+
}));
|
|
255
286
|
}
|
|
256
287
|
export async function subagentSkillAvailabilityRunBlockers(root, artifactDir, missionId, workflowRunId) {
|
|
257
288
|
const blockers = [];
|
|
258
|
-
for (const guardRoot of await admissionGuardRoots(root, artifactDir
|
|
289
|
+
for (const guardRoot of await admissionGuardRoots(root, artifactDir, {
|
|
290
|
+
missionId,
|
|
291
|
+
workflowRunId
|
|
292
|
+
})) {
|
|
259
293
|
blockers.push(...await blockedRunAdmissions(guardRoot, missionId, workflowRunId));
|
|
260
294
|
}
|
|
261
295
|
blockers.push(...await emergencyRunBlockers(root, artifactDir, missionId, workflowRunId));
|
|
@@ -3,13 +3,26 @@ import { clearSubagentSkillAvailabilityGuards } from './subagent-skill-availabil
|
|
|
3
3
|
export async function handleSubagentStop(root, state, payload = {}, sessionKey = null) {
|
|
4
4
|
const artifactDir = officialSubagentArtifactDir(root, state, sessionKey);
|
|
5
5
|
let lifecycleFailure = null;
|
|
6
|
+
let capturedEvent = null;
|
|
6
7
|
try {
|
|
7
|
-
await recordAndRefreshSubagentEvidence(root, state, payload, 'SubagentStop', sessionKey);
|
|
8
|
+
capturedEvent = await recordAndRefreshSubagentEvidence(root, state, payload, 'SubagentStop', sessionKey);
|
|
8
9
|
}
|
|
9
10
|
catch {
|
|
10
11
|
lifecycleFailure = await recordOfficialSubagentLifecycleCaptureFailure(artifactDir, state, payload, 'SubagentStop').catch(() => 'official_subagent_lifecycle_capture_failure_unpersisted');
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
+
const activeRunId = String(state?.official_subagent_run_id || '').trim();
|
|
14
|
+
const explicitRunId = String(payload?.workflow_run_id || payload?.run_id || '').trim();
|
|
15
|
+
const hasTurnBoundEvidence = Boolean(String(payload?.turn_id || '').trim());
|
|
16
|
+
const cleanupRunId = explicitRunId || (hasTurnBoundEvidence ? String(capturedEvent?.run_id || '').trim() : '');
|
|
17
|
+
if (activeRunId && cleanupRunId === activeRunId) {
|
|
18
|
+
await clearSubagentSkillAvailabilityGuards(root, {
|
|
19
|
+
...payload,
|
|
20
|
+
workflow_run_id: cleanupRunId
|
|
21
|
+
}, artifactDir, {
|
|
22
|
+
missionId: state?.mission_id,
|
|
23
|
+
workflowRunId: activeRunId
|
|
24
|
+
}).catch(() => null);
|
|
25
|
+
}
|
|
13
26
|
return lifecycleFailure
|
|
14
27
|
? {
|
|
15
28
|
continue: true,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import fsp from 'node:fs/promises';
|
|
1
2
|
import path from 'node:path';
|
|
2
|
-
import { projectRoot, readJson, writeJsonAtomic, appendJsonl, nowIso, sha256, packageRoot } from './fsx.js';
|
|
3
|
+
import { projectRoot, readJson, writeJsonAtomic, writeTextAtomic, appendJsonl, nowIso, sha256, packageRoot } from './fsx.js';
|
|
3
4
|
import { looksInteractiveCommand, interactiveCommandReason } from './no-question-guard.js';
|
|
4
5
|
import { loadStateForSession, missionDir, sessionStateKey, setCurrent, stateFileForSession } from './mission.js';
|
|
5
6
|
import { checkDbOperation, dbBlockReason, handleMadSksUserConfirmation } from './db-safety.js';
|
|
@@ -20,13 +21,14 @@ import { codePackFreshnessNote } from './hooks-runtime/code-pack-freshness-prefl
|
|
|
20
21
|
import { claimHookInvocation } from './hooks-runtime/hook-invocation-dedupe.js';
|
|
21
22
|
import { armLightTurnStopBypass, clearLightTurnStopBypass, consumeLightTurnStopBypass, hasMatchingLightTurnStopBypass } from './hooks-runtime/light-turn.js';
|
|
22
23
|
import { evaluateHookNarutoDecisionGate, looksLikeActiveContinuationPrompt } from './hooks-runtime/naruto-decision-gate.js';
|
|
23
|
-
import { ensureOfficialSubagentArtifactDirConfined, recordOfficialSubagentLifecycleCaptureFailure, officialSubagentArtifactDir, recordAndRefreshSubagentEvidence, refreshOfficialSubagentCompletionArtifacts } from './hooks-runtime/official-subagent-lifecycle.js';
|
|
24
|
+
import { ensureOfficialSubagentArtifactDirConfined, inspectActiveOfficialSubagentWorkflow, recordOfficialSubagentLifecycleCaptureFailure, officialSubagentArtifactDir, recordAndRefreshSubagentEvidence, refreshOfficialSubagentCompletionArtifacts } from './hooks-runtime/official-subagent-lifecycle.js';
|
|
24
25
|
import { finalizationRepeatDecision } from './hooks-runtime/stop-repeat-guard.js';
|
|
25
26
|
import { activeNarutoParentLaunchMissionId, claimStandaloneParentHostCapabilityRuntime } from './hooks-runtime/standalone-parent-host-capability.js';
|
|
26
27
|
import { classifyTaskProfile } from './runtime/task-profile.js';
|
|
27
28
|
import { resolveSubagentThreadBudget } from './subagents/thread-budget.js';
|
|
28
29
|
import { readOfficialSubagentConfig } from './subagents/official-subagent-config.js';
|
|
29
30
|
import { withFileLock } from './locks/file-lock.js';
|
|
31
|
+
import { ensureConfinedDirectory, inspectConfinedPath, removeManagedPathVerified } from './managed-path-safety.js';
|
|
30
32
|
import { buildBoundWaveParentGuidance, renderWaveParentGuidance } from './subagents/wave-parent-guidance.js';
|
|
31
33
|
import { renderAuthoritativeSksSkillContext } from './codex-native/sks-skill-paths.js';
|
|
32
34
|
import { resolveManagedSkillSourcesForAdmission } from './hooks-runtime/managed-skill-admission.js';
|
|
@@ -37,10 +39,14 @@ const LIGHT_ROUTE_STOP_ARTIFACT = 'light-route-stop.json';
|
|
|
37
39
|
const CODEX_GIT_ACTION_STOP_ARTIFACT = 'codex-git-action-stop-bypass.json';
|
|
38
40
|
const CODEX_GIT_ACTION_STOP_TTL_MS = 15 * 60 * 1000;
|
|
39
41
|
const UPDATE_CHECK_HOOK_INVOCATION_POLICY = 'function-only:no-runSksUpdateCheck-call-in-hooks';
|
|
42
|
+
const MAX_ACTIVE_WORKFLOW_QUEUE_ENTRIES = 256;
|
|
43
|
+
const MAX_ACTIVE_WORKFLOW_PROMPT_BYTES = 32 * 1024;
|
|
44
|
+
const MAX_ACTIVE_WORKFLOW_QUEUE_BYTES = MAX_ACTIVE_WORKFLOW_QUEUE_ENTRIES
|
|
45
|
+
* (MAX_ACTIVE_WORKFLOW_PROMPT_BYTES + 1024);
|
|
40
46
|
import { loadHookPayload, normalizeHookResult, visibleHookMessage } from './hooks-runtime/hook-io.js';
|
|
41
47
|
import { codexGitActionMetadataSignal, codexGitActionMetadataText, compactAnswerContext, conversationId, explicitConversationId, extractCommand, extractLastMessage, extractUserPrompt, hookTurnId, looksLikeCodexGitAction, looksLikeCodexGitActionStopCompletion, looksLikeCodexUiSettingsEvent, looksLikeMadSksConfirmationPrompt, observedParentModel, toolFailed } from './hooks-runtime/payload-signals.js';
|
|
42
48
|
import { interruptedToolOutputRecoveryBlockReason, missingToolOutputCallId, missingToolOutputCallIdFromPayload, quarantineMissingToolOutput, readToolOutputQuarantine } from './hooks-runtime/tool-output-quarantine.js';
|
|
43
|
-
import { activeAuthoritativeSksSkillRefresh, activeGoalOverlayContext, attachAuthoritativeSksSkillContext, attachOfficialSubagentSpawnCompatibilityContext, authoritativeSksSkillAdmission, hookActiveSkillContextRefresh, isBlockingClarificationAwaiting, looksLikeClarificationCancel, routeBypassesActiveContext, routeIsGitOnly, selectedSksSkillNamesForActiveState, shouldPrepareFreshRouteOnActivePrompt, standaloneParentManagedSkillNames } from './hooks-runtime/hook-context.js';
|
|
49
|
+
import { activeAuthoritativeSksSkillRefresh, activeGoalOverlayContext, attachAuthoritativeSksSkillContext, attachOfficialSubagentSpawnCompatibilityContext, authoritativeSksSkillAdmission, hookActiveSkillContextRefresh, isBlockingClarificationAwaiting, looksLikeExplicitActiveWorkflowReplacementPrompt, looksLikeClarificationCancel, routeBypassesActiveContext, routeIsGitOnly, selectedSksSkillNamesForActiveState, shouldPrepareFreshRouteOnActivePrompt, standaloneParentManagedSkillNames } from './hooks-runtime/hook-context.js';
|
|
44
50
|
import { sealedSubagentRoutingContext, subagentRouteContext } from './hooks-runtime/subagent-context.js';
|
|
45
51
|
export { loadHookPayload, normalizeHookResult };
|
|
46
52
|
export { refreshOfficialSubagentCompletionArtifacts };
|
|
@@ -142,7 +148,10 @@ async function hookSubagentStart(root, state, payload = {}, sessionKey = null) {
|
|
|
142
148
|
.catch(() => false);
|
|
143
149
|
if (!artifactDirSafe)
|
|
144
150
|
artifactDirBlockers.push('subagent_skill_availability_artifact_dir_unsafe');
|
|
145
|
-
await clearSubagentSkillAvailabilityGuards(root, payload, artifactDir
|
|
151
|
+
await clearSubagentSkillAvailabilityGuards(root, payload, artifactDir, {
|
|
152
|
+
missionId: state?.mission_id,
|
|
153
|
+
workflowRunId: state?.official_subagent_run_id
|
|
154
|
+
}).catch(() => null);
|
|
146
155
|
const config = await readOfficialSubagentConfig(root);
|
|
147
156
|
const budget = resolveSubagentThreadBudget({ configuredMaxThreads: config.maxThreads });
|
|
148
157
|
const active = subagentRouteContext(state);
|
|
@@ -362,6 +371,66 @@ async function hookUserPrompt(root, state, payload, noQuestion, sessionKey = nul
|
|
|
362
371
|
systemMessage: `SKS: ${route.command} git action bypassed pipeline route gates.`
|
|
363
372
|
};
|
|
364
373
|
}
|
|
374
|
+
const explicitActiveWorkflowReplacement = looksLikeExplicitActiveWorkflowReplacementPrompt(prompt);
|
|
375
|
+
const activeOfficialWorkflow = state?.mission_id
|
|
376
|
+
&& state?.route_closed !== true
|
|
377
|
+
&& state?.official_subagent_run_id
|
|
378
|
+
&& !activeGoalOverlayContext(state, route)
|
|
379
|
+
? await inspectActiveOfficialSubagentWorkflow(root, state, sessionKey)
|
|
380
|
+
: { status: 'inactive' };
|
|
381
|
+
if (activeOfficialWorkflow.status === 'invalid') {
|
|
382
|
+
return {
|
|
383
|
+
decision: 'block',
|
|
384
|
+
reason: `SKS refused to replace the active official-subagent workflow because its parent binding could not be verified (${activeOfficialWorkflow.reason}). Active mission=${activeOfficialWorkflow.missionId}, workflow_run_id=${activeOfficialWorkflow.workflowRunId}. The root parent must inspect and explicitly settle or cancel that exact run before preparing another workflow.`
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
if (activeOfficialWorkflow.status === 'active') {
|
|
388
|
+
if (explicitActiveWorkflowReplacement && activeOfficialWorkflow.openThreads > 0) {
|
|
389
|
+
return {
|
|
390
|
+
decision: 'block',
|
|
391
|
+
reason: `SKS refused to replace active official-subagent workflow ${activeOfficialWorkflow.workflowRunId}: ${activeOfficialWorkflow.openThreads} child thread(s) remain open in mission ${activeOfficialWorkflow.missionId}. The root parent must settle or explicitly cancel the old run before submitting the replacement.`
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
if (explicitActiveWorkflowReplacement) {
|
|
395
|
+
const consumed = await consumeActiveOfficialWorkflowQueue(root, activeOfficialWorkflow.missionId, activeOfficialWorkflow.workflowRunId);
|
|
396
|
+
if (!consumed) {
|
|
397
|
+
return {
|
|
398
|
+
decision: 'block',
|
|
399
|
+
reason: `SKS refused to replace settled workflow_run_id=${activeOfficialWorkflow.workflowRunId} because its bounded additive queue could not be consumed safely.`
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
if (!explicitActiveWorkflowReplacement) {
|
|
404
|
+
const activeSkillAdmission = await authoritativeSksSkillAdmission(root, selectedSksSkillNamesForActiveState(state));
|
|
405
|
+
if (activeSkillAdmission.blocked)
|
|
406
|
+
return activeSkillAdmission.blocked;
|
|
407
|
+
const queued = await queueActiveOfficialWorkflowPrompt({
|
|
408
|
+
root,
|
|
409
|
+
missionId: activeOfficialWorkflow.missionId,
|
|
410
|
+
workflowRunId: activeOfficialWorkflow.workflowRunId,
|
|
411
|
+
sessionKey,
|
|
412
|
+
prompt
|
|
413
|
+
});
|
|
414
|
+
if (!queued.ok) {
|
|
415
|
+
return {
|
|
416
|
+
decision: 'block',
|
|
417
|
+
reason: `SKS preserved active workflow_run_id=${activeOfficialWorkflow.workflowRunId} but could not queue this addition (${queued.reason}). Wait for the root parent to drain the bounded active-run queue, then retry.`
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
const activeContext = await activeRouteContext(root, state);
|
|
421
|
+
const skillContext = activeSkillAdmission.resolution
|
|
422
|
+
? renderAuthoritativeSksSkillContext(activeSkillAdmission.resolution)
|
|
423
|
+
: '';
|
|
424
|
+
const queueContext = `The latest user request was queued as an addition to active workflow_run_id=${activeOfficialWorkflow.workflowRunId}; preserve that run binding and let the root parent decompose the added scope. Open child threads: ${activeOfficialWorkflow.openThreads}. Do not prepare a replacement workflow from this prompt.`;
|
|
425
|
+
const additionalContext = [activeContext, skillContext, queueContext].filter(Boolean).join('\n\n');
|
|
426
|
+
return {
|
|
427
|
+
continue: true,
|
|
428
|
+
additionalContext,
|
|
429
|
+
systemMessage: visibleHookMessage('user-prompt-submit', additionalContext),
|
|
430
|
+
queued_active_workflow_run_id: activeOfficialWorkflow.workflowRunId
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
}
|
|
365
434
|
const skillAdmission = await authoritativeSksSkillAdmission(root, managedSkillNamesForPrompt(route, prompt));
|
|
366
435
|
if (skillAdmission.blocked)
|
|
367
436
|
return skillAdmission.blocked;
|
|
@@ -414,6 +483,81 @@ async function hookUserPrompt(root, state, payload, noQuestion, sessionKey = nul
|
|
|
414
483
|
reason: 'SKS no-question/no-interruption mode is active. User prompt has been queued until the run completes.'
|
|
415
484
|
};
|
|
416
485
|
}
|
|
486
|
+
async function queueActiveOfficialWorkflowPrompt(input) {
|
|
487
|
+
if (Buffer.byteLength(input.prompt, 'utf8') > MAX_ACTIVE_WORKFLOW_PROMPT_BYTES) {
|
|
488
|
+
return { ok: false, reason: 'active_workflow_prompt_too_large' };
|
|
489
|
+
}
|
|
490
|
+
const dir = missionDir(input.root, input.missionId);
|
|
491
|
+
const queueFile = activeOfficialWorkflowQueueFile(dir, input.missionId, input.workflowRunId);
|
|
492
|
+
try {
|
|
493
|
+
return await withFileLock({
|
|
494
|
+
lockPath: path.join(dir, '.active-workflow-user-queue.lock'),
|
|
495
|
+
timeoutMs: 5_000,
|
|
496
|
+
staleMs: 60_000
|
|
497
|
+
}, async () => {
|
|
498
|
+
await ensureConfinedDirectory(path.resolve(input.root), path.dirname(queueFile));
|
|
499
|
+
const stat = await fsp.stat(queueFile).catch((error) => {
|
|
500
|
+
if (error?.code === 'ENOENT')
|
|
501
|
+
return null;
|
|
502
|
+
throw error;
|
|
503
|
+
});
|
|
504
|
+
if (stat && (!stat.isFile() || stat.size > MAX_ACTIVE_WORKFLOW_QUEUE_BYTES)) {
|
|
505
|
+
return { ok: false, reason: 'active_workflow_queue_invalid_or_oversized' };
|
|
506
|
+
}
|
|
507
|
+
const current = stat ? await fsp.readFile(queueFile, 'utf8') : '';
|
|
508
|
+
const lines = current.split(/\r?\n/).filter(Boolean);
|
|
509
|
+
if (lines.length >= MAX_ACTIVE_WORKFLOW_QUEUE_ENTRIES) {
|
|
510
|
+
return { ok: false, reason: 'active_workflow_queue_full' };
|
|
511
|
+
}
|
|
512
|
+
for (const line of lines)
|
|
513
|
+
JSON.parse(line);
|
|
514
|
+
const row = {
|
|
515
|
+
schema: 'sks.active-official-subagent-request.v1',
|
|
516
|
+
ts: nowIso(),
|
|
517
|
+
disposition: 'queued_for_root_decomposition',
|
|
518
|
+
mission_id: input.missionId,
|
|
519
|
+
workflow_run_id: input.workflowRunId,
|
|
520
|
+
session_scope_hash: sha256(String(input.sessionKey || 'default')),
|
|
521
|
+
prompt: input.prompt
|
|
522
|
+
};
|
|
523
|
+
const next = `${current.replace(/\s*$/, current ? '\n' : '')}${JSON.stringify(row)}\n`;
|
|
524
|
+
if (Buffer.byteLength(next, 'utf8') > MAX_ACTIVE_WORKFLOW_QUEUE_BYTES) {
|
|
525
|
+
return { ok: false, reason: 'active_workflow_queue_full' };
|
|
526
|
+
}
|
|
527
|
+
await writeTextAtomic(queueFile, next);
|
|
528
|
+
return { ok: true };
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
catch {
|
|
532
|
+
return { ok: false, reason: 'active_workflow_queue_persistence_failed' };
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
function activeOfficialWorkflowQueueFile(dir, missionId, workflowRunId) {
|
|
536
|
+
const runKey = sha256(JSON.stringify([missionId, workflowRunId]));
|
|
537
|
+
return path.join(dir, 'active-workflow-user-queue', `run-${runKey}.jsonl`);
|
|
538
|
+
}
|
|
539
|
+
async function consumeActiveOfficialWorkflowQueue(root, missionId, workflowRunId) {
|
|
540
|
+
const dir = missionDir(root, missionId);
|
|
541
|
+
const queueFile = activeOfficialWorkflowQueueFile(dir, missionId, workflowRunId);
|
|
542
|
+
try {
|
|
543
|
+
return await withFileLock({
|
|
544
|
+
lockPath: path.join(dir, '.active-workflow-user-queue.lock'),
|
|
545
|
+
timeoutMs: 5_000,
|
|
546
|
+
staleMs: 60_000
|
|
547
|
+
}, async () => {
|
|
548
|
+
const inspected = await inspectConfinedPath(path.resolve(root), queueFile);
|
|
549
|
+
if (inspected.exists) {
|
|
550
|
+
if (inspected.leafSymlink || !inspected.stat?.isFile())
|
|
551
|
+
return false;
|
|
552
|
+
await removeManagedPathVerified(path.resolve(root), queueFile);
|
|
553
|
+
}
|
|
554
|
+
return true;
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
catch {
|
|
558
|
+
return false;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
417
561
|
async function hookPreTool(root, state, payload, noQuestion, sessionKey = null) {
|
|
418
562
|
const artifactDir = officialSubagentArtifactDir(root, state, sessionKey);
|
|
419
563
|
const activeBinding = {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import os from 'node:os';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { loadCodexLbEnv, parseShellEnvValue } from '../codex-lb/codex-lb-env.js';
|
|
4
|
+
import { CODEX_LB_ROUTING_TRUTH_RECEIPT, codexLbRoutingTruthIsActive, readCodexLbRoutingTruthReceipt } from '../codex-lb/routing-truth.js';
|
|
4
5
|
import { nowIso, readText, runProcess, which } from '../fsx.js';
|
|
5
6
|
import { redactSecrets, redactString } from '../secret-redaction.js';
|
|
6
7
|
import { evaluateImagegenAuthReadiness } from './imagegen-auth-readiness.js';
|
|
@@ -137,6 +138,17 @@ async function detectCodexLbImagegenAuth(opts = {}, env = process.env) {
|
|
|
137
138
|
apiKeyPresent,
|
|
138
139
|
cliContract
|
|
139
140
|
});
|
|
141
|
+
const routingTruthReceiptPath = opts.codexLbRoutingTruthReceiptPath
|
|
142
|
+
|| path.join(codexHome, CODEX_LB_ROUTING_TRUTH_RECEIPT);
|
|
143
|
+
const routingTruth = await readCodexLbRoutingTruthReceipt({
|
|
144
|
+
receiptPath: routingTruthReceiptPath
|
|
145
|
+
}).catch(() => null);
|
|
146
|
+
const configuredHost = publicUrlHost(baseUrl);
|
|
147
|
+
const routingTruthContextMatches = routingTruth?.selected === selected
|
|
148
|
+
&& routingTruth?.configured_host === configuredHost
|
|
149
|
+
&& routingTruth?.auth_transport === 'authorization-bearer';
|
|
150
|
+
const routingActive = routingTruthContextMatches
|
|
151
|
+
&& codexLbRoutingTruthIsActive(routingTruth);
|
|
140
152
|
return {
|
|
141
153
|
available: blocker === null,
|
|
142
154
|
selected,
|
|
@@ -152,9 +164,35 @@ async function detectCodexLbImagegenAuth(opts = {}, env = process.env) {
|
|
|
152
164
|
source: apiKeySource,
|
|
153
165
|
redacted: true
|
|
154
166
|
},
|
|
167
|
+
routing_active: routingActive,
|
|
168
|
+
routing_truth: routingTruth,
|
|
169
|
+
routing_truth_receipt_path: routingTruthReceiptPath,
|
|
170
|
+
routing_blocker: codexLbRoutingBlocker({
|
|
171
|
+
selected,
|
|
172
|
+
configuredHost,
|
|
173
|
+
routingTruth,
|
|
174
|
+
routingTruthContextMatches,
|
|
175
|
+
routingActive
|
|
176
|
+
}),
|
|
155
177
|
blocker
|
|
156
178
|
};
|
|
157
179
|
}
|
|
180
|
+
function codexLbRoutingBlocker(state) {
|
|
181
|
+
if (!state.selected)
|
|
182
|
+
return 'codex_lb_not_selected';
|
|
183
|
+
if (!state.routingTruth)
|
|
184
|
+
return 'codex_lb_routing_truth_receipt_missing';
|
|
185
|
+
if (state.routingTruth.selected !== true)
|
|
186
|
+
return 'codex_lb_routing_truth_selection_mismatch';
|
|
187
|
+
if (state.routingTruth.configured_host !== state.configuredHost)
|
|
188
|
+
return 'codex_lb_routing_truth_host_mismatch';
|
|
189
|
+
if (state.routingTruth.auth_transport !== 'authorization-bearer')
|
|
190
|
+
return 'codex_lb_routing_truth_auth_transport_mismatch';
|
|
191
|
+
if (!state.routingTruthContextMatches || !state.routingActive) {
|
|
192
|
+
return state.routingTruth.blockers?.[0] || 'codex_lb_routing_truth_unverified';
|
|
193
|
+
}
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
158
196
|
function codexLbAuthBlocker(state) {
|
|
159
197
|
if (!state.selected && !state.cliContract)
|
|
160
198
|
return 'codex_lb_not_selected';
|
|
@@ -280,6 +318,14 @@ function boolish(value) {
|
|
|
280
318
|
return false;
|
|
281
319
|
return null;
|
|
282
320
|
}
|
|
321
|
+
function publicUrlHost(value) {
|
|
322
|
+
try {
|
|
323
|
+
return typeof value === 'string' && value ? new URL(value).host : null;
|
|
324
|
+
}
|
|
325
|
+
catch {
|
|
326
|
+
return null;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
283
329
|
function topLevelTomlString(text = '', key = '') {
|
|
284
330
|
const topLevel = String(text || '').split(/\n\s*\[/)[0] || '';
|
|
285
331
|
return tomlString(topLevel, key);
|
|
@@ -100,8 +100,8 @@ function imagegenPreflightReady(capability) {
|
|
|
100
100
|
return capability?.core_ready === true || codexLbImagegenReady(capability);
|
|
101
101
|
}
|
|
102
102
|
function codexLbImagegenReady(capability) {
|
|
103
|
-
return
|
|
104
|
-
|
|
103
|
+
return capability?.codex_lb?.selected === true
|
|
104
|
+
&& capability?.codex_lb?.routing_active === true
|
|
105
105
|
&& capability?.codex_lb?.available === true
|
|
106
106
|
&& capability?.codex_lb?.blocker == null;
|
|
107
107
|
}
|
package/dist/core/init/skills.js
CHANGED
|
@@ -1353,9 +1353,23 @@ async function managedSkillDirectoryContainsOnlyOwnedFiles(root, dir) {
|
|
|
1353
1353
|
if (!agentsInspection.exists || agentsInspection.leafSymlink || !agentsInspection.stat?.isDirectory())
|
|
1354
1354
|
return false;
|
|
1355
1355
|
const agentEntries = await fsp.readdir(agentsDir, { withFileTypes: true });
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1356
|
+
if (agentEntries.length === 0)
|
|
1357
|
+
return true;
|
|
1358
|
+
if (agentEntries.length !== 1
|
|
1359
|
+
|| agentEntries[0]?.name !== 'openai.yaml'
|
|
1360
|
+
|| !agentEntries[0].isFile())
|
|
1361
|
+
return false;
|
|
1362
|
+
const skillContent = await fsp.readFile(path.join(dir, 'SKILL.md'), 'utf8');
|
|
1363
|
+
const name = canonicalSkillNameFromValue(/^name:\s*(.+)\s*$/m.exec(skillContent)?.[1]);
|
|
1364
|
+
const description = skillFrontmatterDescription(skillContent);
|
|
1365
|
+
if (!name || !description)
|
|
1366
|
+
return false;
|
|
1367
|
+
const expectedMetadata = renderSkillAgentMetadata({
|
|
1368
|
+
skillName: name,
|
|
1369
|
+
shortDescription: description
|
|
1370
|
+
});
|
|
1371
|
+
const actualMetadata = await fsp.readFile(path.join(agentsDir, 'openai.yaml'), 'utf8');
|
|
1372
|
+
return actualMetadata === expectedMetadata;
|
|
1359
1373
|
}
|
|
1360
1374
|
async function prepareReservedSkillManifestsForWrite(root) {
|
|
1361
1375
|
const skillRoot = path.join(root, '.agents', 'skills');
|
|
@@ -4,9 +4,9 @@ import os from 'node:os';
|
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { runProcess, writeJsonAtomic } from '../fsx.js';
|
|
6
6
|
import { LEGACY_DOLLAR_COMMAND_NAMES, LEGACY_DOLLAR_SKILL_NAMES } from '../routes.js';
|
|
7
|
-
export const INSTALLED_REQUIRED_COMMANDS = ['naruto', 'mcp', 'update', 'menubar'];
|
|
7
|
+
export const INSTALLED_REQUIRED_COMMANDS = ['naruto', 'mcp', 'update', 'menubar', 'config', 'telegram'];
|
|
8
8
|
export const INSTALLED_REQUIRED_DOLLAR_COMMANDS = ['$sks-naruto', '$sks-work'];
|
|
9
|
-
export const INSTALLED_REMOVED_COMMANDS = ['team', 'mad-db', 'tmux', 'xai', 'swarm', 'agent', 'ralph', 'ui'
|
|
9
|
+
export const INSTALLED_REMOVED_COMMANDS = ['team', 'mad-db', 'tmux', 'xai', 'swarm', 'agent', 'ralph', 'ui'];
|
|
10
10
|
export const INSTALLED_REMOVED_DOLLAR_COMMANDS = Array.from(new Set([
|
|
11
11
|
'$Agent', '$Team', '$MAD-DB', '$Swarm', '$ShadowClone', '$Kagebunshin', '$Ralph',
|
|
12
12
|
...LEGACY_DOLLAR_COMMAND_NAMES.filter((command) => command.toLowerCase() !== '$sks'),
|
|
@@ -189,6 +189,8 @@ export async function runInstalledPackageSmoke(root, options = {}) {
|
|
|
189
189
|
{ name: 'naruto', argv: [bin, 'naruto', '--help'], diagnostic: true },
|
|
190
190
|
{ name: 'mcp', argv: [bin, 'mcp', 'config', 'list', '--scope', 'effective', '--trusted-project', '--json'], diagnostic: true },
|
|
191
191
|
{ name: 'update', argv: [bin, 'update', 'status', '--json'], diagnostic: true },
|
|
192
|
+
{ name: 'config', argv: [bin, 'config', '--help'], diagnostic: true },
|
|
193
|
+
{ name: 'telegram', argv: [bin, 'telegram', '--help'], diagnostic: true },
|
|
192
194
|
...(process.platform === 'darwin'
|
|
193
195
|
? [{ name: 'menubar-install', argv: [bin, 'menubar', 'install', '--no-launch', '--json'] }]
|
|
194
196
|
: []),
|
|
@@ -529,6 +531,10 @@ function installedDiagnosticBlockers(name, result, platform) {
|
|
|
529
531
|
if (name === 'naruto')
|
|
530
532
|
return result.exit_code === 0 && /\$sks-naruto/.test(result.stdout)
|
|
531
533
|
? [] : ['installed_diagnostic_failed:naruto'];
|
|
534
|
+
if (name === 'config' || name === 'telegram') {
|
|
535
|
+
return result.exit_code === 0 && new RegExp(`Usage: sks ${name}`).test(result.stdout)
|
|
536
|
+
? [] : [`installed_diagnostic_failed:${name}`];
|
|
537
|
+
}
|
|
532
538
|
const expectedSchema = {
|
|
533
539
|
mcp: 'sks.mcp-inventory.v2',
|
|
534
540
|
update: 'sks.update-status.v3',
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import os from 'node:os';
|
|
2
2
|
export function probeHardwareCapacity(input = {}) {
|
|
3
3
|
const memory = process.memoryUsage();
|
|
4
|
+
const configuredRemoteBudget = Number(process.env.SKS_NARUTO_REMOTE_API_PARALLEL_BUDGET)
|
|
5
|
+
|| Number(process.env.SKS_REMOTE_API_PARALLEL_BUDGET);
|
|
6
|
+
const remoteBudgetSource = input.remoteApiRateLimitBudget !== undefined
|
|
7
|
+
? 'input'
|
|
8
|
+
: configuredRemoteBudget
|
|
9
|
+
? 'environment'
|
|
10
|
+
: 'default_unmeasured';
|
|
4
11
|
return {
|
|
5
12
|
schema: 'sks.naruto-hardware-capacity-probe.v1',
|
|
6
13
|
cpu_core_count: normalizePositiveInt(input.cores, os.cpus()?.length || 1),
|
|
@@ -15,9 +22,8 @@ export function probeHardwareCapacity(input = {}) {
|
|
|
15
22
|
terminal_columns: normalizePositiveInt(input.terminalColumns, process.stdout.columns || 120),
|
|
16
23
|
terminal_rows: normalizePositiveInt(input.terminalRows, process.stdout.rows || 40),
|
|
17
24
|
local_llm_max_parallel_requests: normalizePositiveInt(input.localLlmMaxParallelRequests, Number(process.env.SKS_LOCAL_LLM_MAX_PARALLEL_REQUESTS) || 4),
|
|
18
|
-
remote_api_rate_limit_budget: normalizePositiveInt(input.remoteApiRateLimitBudget,
|
|
19
|
-
|
|
20
|
-
|| 12),
|
|
25
|
+
remote_api_rate_limit_budget: normalizePositiveInt(input.remoteApiRateLimitBudget, configuredRemoteBudget || 12),
|
|
26
|
+
remote_api_rate_limit_budget_source: remoteBudgetSource,
|
|
21
27
|
gpu_available: input.gpuAvailable === true,
|
|
22
28
|
gpu_vram_mb: normalizeNonNegativeInt(input.gpuVramMb, 0),
|
|
23
29
|
disk_io_pressure: Math.max(0, Math.min(1, Number(input.diskIoPressure ?? 0)))
|