@akagilnc/pi-workflow-roles 0.1.4745 → 0.1.4759
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/acp-host/production-host.js +51 -162
- package/dist/headless-host/production-host.js +51 -162
- package/dist/public-cli/main.js +52 -164
- package/dist/public-cli/post-admission.js +69 -130
- package/package.json +1 -1
- package/src/public-cli/cli.ts +0 -5
- package/src/public-cli/config.ts +0 -1
- package/src/public-cli/countersign-run.ts +1 -1
- package/src/public-cli/diarist-run.ts +1 -1
- package/src/public-cli/post-admission.ts +88 -187
- package/dist/public-cli/public-run-credentials.js +0 -49
- package/src/public-cli/public-run-credentials.ts +0 -71
|
@@ -18263,42 +18263,6 @@ var init_host_transition_prior_native = __esm({
|
|
|
18263
18263
|
}
|
|
18264
18264
|
});
|
|
18265
18265
|
|
|
18266
|
-
// src/public-cli/public-run-credentials.ts
|
|
18267
|
-
function knownFailureForMissingProviderCredential(model, credentials) {
|
|
18268
|
-
if (model === void 0 || credentials === void 0) return void 0;
|
|
18269
|
-
if (model.provider !== "openai-codex" && model.provider !== "xai") return void 0;
|
|
18270
|
-
if (!missingPublicProviderCredential(model.provider, credentials)) {
|
|
18271
|
-
return void 0;
|
|
18272
|
-
}
|
|
18273
|
-
return {
|
|
18274
|
-
cause: "provider",
|
|
18275
|
-
identity: {
|
|
18276
|
-
name: "MissingProviderCredential",
|
|
18277
|
-
code: model.provider
|
|
18278
|
-
}
|
|
18279
|
-
};
|
|
18280
|
-
}
|
|
18281
|
-
function missingCredentialPreDispatchFailure(model, credentials) {
|
|
18282
|
-
const knownFailure = knownFailureForMissingProviderCredential(model, credentials);
|
|
18283
|
-
if (knownFailure === void 0) return void 0;
|
|
18284
|
-
return {
|
|
18285
|
-
timedOut: false,
|
|
18286
|
-
code: 1,
|
|
18287
|
-
stderr: `Missing credential for provider ${String(knownFailure.identity?.code ?? "unknown")}`,
|
|
18288
|
-
knownFailure
|
|
18289
|
-
};
|
|
18290
|
-
}
|
|
18291
|
-
function postRunMissingCredentialFailure(result, model, credentials) {
|
|
18292
|
-
if (!(result.timedOut || result.code !== 0)) return void 0;
|
|
18293
|
-
return knownFailureForMissingProviderCredential(model, credentials);
|
|
18294
|
-
}
|
|
18295
|
-
var init_public_run_credentials = __esm({
|
|
18296
|
-
"src/public-cli/public-run-credentials.ts"() {
|
|
18297
|
-
"use strict";
|
|
18298
|
-
init_config();
|
|
18299
|
-
}
|
|
18300
|
-
});
|
|
18301
|
-
|
|
18302
18266
|
// src/public-cli/process-cancel.ts
|
|
18303
18267
|
function processCancelSignalName(signal) {
|
|
18304
18268
|
if (signal === void 0 || signal.aborted !== true) return void 0;
|
|
@@ -18791,8 +18755,8 @@ function withOnceSuccessfulBeforeDispatch(adapters) {
|
|
|
18791
18755
|
};
|
|
18792
18756
|
}
|
|
18793
18757
|
async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic, io) {
|
|
18794
|
-
io.stderr(formatCliDiagnostic(diagnostic));
|
|
18795
18758
|
const payload = { diagnostic, recordedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
18759
|
+
let retentionFailure;
|
|
18796
18760
|
try {
|
|
18797
18761
|
await env.sessionAppender(
|
|
18798
18762
|
env.principalAuthority,
|
|
@@ -18800,7 +18764,6 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
18800
18764
|
POST_ADMISSION_CLEANUP_DIAGNOSTIC_ENTRY_TYPE,
|
|
18801
18765
|
payload
|
|
18802
18766
|
);
|
|
18803
|
-
return;
|
|
18804
18767
|
} catch (appendError) {
|
|
18805
18768
|
try {
|
|
18806
18769
|
const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
|
|
@@ -18811,13 +18774,16 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
18811
18774
|
{ encoding: "utf8", flag: "wx" }
|
|
18812
18775
|
);
|
|
18813
18776
|
} catch (artifactError) {
|
|
18814
|
-
|
|
18815
|
-
formatCliDiagnostic(
|
|
18816
|
-
`post-dispatch diagnostic durable retention failed on both channels (best-effort continue): dossier=${describeErrorIdentity(appendError)}; artifact=${describeErrorIdentity(artifactError)}`
|
|
18817
|
-
)
|
|
18818
|
-
);
|
|
18777
|
+
retentionFailure = `post-dispatch diagnostic durable retention failed on both channels (best-effort continue): dossier=${describeErrorIdentity(appendError)}; artifact=${describeErrorIdentity(artifactError)}`;
|
|
18819
18778
|
}
|
|
18820
18779
|
}
|
|
18780
|
+
try {
|
|
18781
|
+
io.stderr(formatCliDiagnostic(diagnostic));
|
|
18782
|
+
if (retentionFailure !== void 0) {
|
|
18783
|
+
io.stderr(formatCliDiagnostic(retentionFailure));
|
|
18784
|
+
}
|
|
18785
|
+
} catch {
|
|
18786
|
+
}
|
|
18821
18787
|
}
|
|
18822
18788
|
async function resolveResumeMethodMaterialAdapters(input) {
|
|
18823
18789
|
if (input.shouldLoad === false) {
|
|
@@ -18980,12 +18946,11 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
18980
18946
|
if (adapters.afterDispatch !== void 0) await adapters.afterDispatch(admitted, lease);
|
|
18981
18947
|
return result;
|
|
18982
18948
|
} catch (error) {
|
|
18983
|
-
|
|
18984
|
-
if (primaryFailure) {
|
|
18949
|
+
if (result.terminal !== void 0) {
|
|
18985
18950
|
await recordBestEffortPostDispatchDiagnostic(
|
|
18986
18951
|
admitted,
|
|
18987
18952
|
env,
|
|
18988
|
-
`afterDispatch failed beside
|
|
18953
|
+
`afterDispatch failed beside host terminal (best-effort continue): ${describeErrorIdentity(error)}`,
|
|
18989
18954
|
io
|
|
18990
18955
|
);
|
|
18991
18956
|
return result;
|
|
@@ -19011,23 +18976,6 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
19011
18976
|
}
|
|
19012
18977
|
};
|
|
19013
18978
|
try {
|
|
19014
|
-
const missingCredential = missingCredentialPreDispatchFailure(
|
|
19015
|
-
env.model,
|
|
19016
|
-
env.credentials
|
|
19017
|
-
);
|
|
19018
|
-
if (missingCredential !== void 0) {
|
|
19019
|
-
return {
|
|
19020
|
-
...await presentControlledFailure2(
|
|
19021
|
-
admitted,
|
|
19022
|
-
withEngineDetourInvocationScope(missingCredential, request.invocationScopeId),
|
|
19023
|
-
adapters,
|
|
19024
|
-
env.principalAuthority,
|
|
19025
|
-
io,
|
|
19026
|
-
persistRunState
|
|
19027
|
-
),
|
|
19028
|
-
...deferredPersist
|
|
19029
|
-
};
|
|
19030
|
-
}
|
|
19031
18979
|
let previousHost;
|
|
19032
18980
|
const liveHost = env.host;
|
|
19033
18981
|
const principalCoordinates = admitted.principal === void 0 ? void 0 : env.principalAuthority.decode(admitted.principal);
|
|
@@ -19160,19 +19108,14 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
19160
19108
|
try {
|
|
19161
19109
|
const sessionFile = admitted.principal !== void 0 ? env.principalAuthority.decode(admitted.principal).sessionFile : "";
|
|
19162
19110
|
const runnerKnownFailure = adapters.resolveRunnerKnownFailure !== void 0 && sessionFile !== "" ? await adapters.resolveRunnerKnownFailure({ result, sessionFile }) : result.knownFailure;
|
|
19163
|
-
const credentialFailure = postRunMissingCredentialFailure(
|
|
19164
|
-
result,
|
|
19165
|
-
env.model,
|
|
19166
|
-
env.credentials
|
|
19167
|
-
);
|
|
19168
19111
|
resolution = await resolveAuditedRunnerFailureResolution({
|
|
19169
19112
|
runner: runnerKnownFailure,
|
|
19170
19113
|
sessionFile,
|
|
19171
|
-
credential:
|
|
19114
|
+
credential: void 0,
|
|
19172
19115
|
runDirectory: admitted.runDirectory
|
|
19173
19116
|
});
|
|
19174
19117
|
const processCancelName = processCancelSignalName(env.signal);
|
|
19175
|
-
const directHostFailureSignal = result.timedOut || result.knownFailure !== void 0 || runnerKnownFailure !== void 0 ||
|
|
19118
|
+
const directHostFailureSignal = result.timedOut || result.knownFailure !== void 0 || runnerKnownFailure !== void 0 || processCancelName !== void 0;
|
|
19176
19119
|
hostSignalFailed = directHostFailureSignal || result.code !== null && result.code !== 0 || resolution.knownFailure !== void 0;
|
|
19177
19120
|
settled = await adapters.trySettle(admitted, env.principalAuthority, courtScope);
|
|
19178
19121
|
if (settled !== void 0) {
|
|
@@ -19238,25 +19181,11 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
19238
19181
|
try {
|
|
19239
19182
|
await persistReturnedRunState(admitted, env.principalAuthority, { lawful: true });
|
|
19240
19183
|
} catch (error) {
|
|
19241
|
-
|
|
19184
|
+
await recordBestEffortPostDispatchDiagnostic(
|
|
19242
19185
|
admitted,
|
|
19243
|
-
|
|
19244
|
-
|
|
19245
|
-
|
|
19246
|
-
stderr: "",
|
|
19247
|
-
thrown: error,
|
|
19248
|
-
skipRunStateWrite: true
|
|
19249
|
-
}, request.invocationScopeId),
|
|
19250
|
-
adapters,
|
|
19251
|
-
env.principalAuthority,
|
|
19252
|
-
io,
|
|
19253
|
-
persistRunState
|
|
19254
|
-
);
|
|
19255
|
-
return await finishAfterTurn(
|
|
19256
|
-
withProcessCancelSkipAutoResume(
|
|
19257
|
-
{ ...failed, turnDispatched: true, ...deferredPersist },
|
|
19258
|
-
env.signal
|
|
19259
|
-
)
|
|
19186
|
+
env,
|
|
19187
|
+
`run-state persistence failed beside host terminal (best-effort continue): ${describeErrorIdentity(error)}`,
|
|
19188
|
+
io
|
|
19260
19189
|
);
|
|
19261
19190
|
}
|
|
19262
19191
|
}
|
|
@@ -19337,25 +19266,11 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
19337
19266
|
try {
|
|
19338
19267
|
await persistReturnedRunState(admitted, env.principalAuthority, { lawful: true });
|
|
19339
19268
|
} catch (error) {
|
|
19340
|
-
|
|
19269
|
+
await recordBestEffortPostDispatchDiagnostic(
|
|
19341
19270
|
admitted,
|
|
19342
|
-
|
|
19343
|
-
|
|
19344
|
-
|
|
19345
|
-
stderr: "",
|
|
19346
|
-
thrown: error,
|
|
19347
|
-
skipRunStateWrite: true
|
|
19348
|
-
}, request.invocationScopeId),
|
|
19349
|
-
adapters,
|
|
19350
|
-
env.principalAuthority,
|
|
19351
|
-
io,
|
|
19352
|
-
persistRunState
|
|
19353
|
-
);
|
|
19354
|
-
return await finishAfterTurn(
|
|
19355
|
-
withProcessCancelSkipAutoResume(
|
|
19356
|
-
{ ...failed, turnDispatched: true, ...deferredPersist },
|
|
19357
|
-
env.signal
|
|
19358
|
-
)
|
|
19271
|
+
env,
|
|
19272
|
+
`run-state persistence failed beside host terminal (best-effort continue): ${describeErrorIdentity(error)}`,
|
|
19273
|
+
io
|
|
19359
19274
|
);
|
|
19360
19275
|
}
|
|
19361
19276
|
}
|
|
@@ -19367,14 +19282,16 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
19367
19282
|
...deferredPersist
|
|
19368
19283
|
});
|
|
19369
19284
|
} finally {
|
|
19370
|
-
|
|
19371
|
-
|
|
19372
|
-
|
|
19373
|
-
|
|
19374
|
-
|
|
19375
|
-
|
|
19376
|
-
|
|
19377
|
-
|
|
19285
|
+
if (lease !== void 0) {
|
|
19286
|
+
try {
|
|
19287
|
+
await lease.release();
|
|
19288
|
+
} catch (error) {
|
|
19289
|
+
io.stderr(
|
|
19290
|
+
formatCliDiagnostic(
|
|
19291
|
+
`writer lease release failed unexpectedly (best-effort continue): ${describeErrorIdentity(error)}`
|
|
19292
|
+
)
|
|
19293
|
+
);
|
|
19294
|
+
}
|
|
19378
19295
|
}
|
|
19379
19296
|
}
|
|
19380
19297
|
}
|
|
@@ -19689,53 +19606,29 @@ async function runPostAdmissionManualResume(input) {
|
|
|
19689
19606
|
} = input;
|
|
19690
19607
|
let request = input.request;
|
|
19691
19608
|
const effectiveModel = env.model;
|
|
19692
|
-
let lease;
|
|
19693
|
-
let staleWriterLeaseReclaimed;
|
|
19694
|
-
try {
|
|
19695
|
-
lease = await acquireRunWriterLease(admitted.runDirectory, (diagnostic, kind) => {
|
|
19696
|
-
if (kind === "stale-reclaimed") staleWriterLeaseReclaimed = true;
|
|
19697
|
-
io.stderr(diagnostic);
|
|
19698
|
-
});
|
|
19699
|
-
} catch (error) {
|
|
19700
|
-
if (error instanceof RunWriterLeaseHeldError) {
|
|
19701
|
-
io.stderr(formatCliDiagnostic(error.message));
|
|
19702
|
-
return {
|
|
19703
|
-
exitCode: 1,
|
|
19704
|
-
...staleWriterLeaseReclaimed === true ? { staleWriterLeaseReclaimed: true } : {}
|
|
19705
|
-
};
|
|
19706
|
-
}
|
|
19707
|
-
throw error;
|
|
19708
|
-
}
|
|
19709
19609
|
const invocationScopeId = mintEngineDetourInvocationScope({
|
|
19710
19610
|
...effectiveEngine === void 0 ? {} : { effectiveEngine }
|
|
19711
19611
|
});
|
|
19712
|
-
|
|
19713
|
-
|
|
19714
|
-
|
|
19715
|
-
|
|
19716
|
-
|
|
19717
|
-
|
|
19718
|
-
|
|
19719
|
-
|
|
19720
|
-
|
|
19721
|
-
|
|
19722
|
-
|
|
19723
|
-
|
|
19724
|
-
|
|
19612
|
+
if (request === void 0) {
|
|
19613
|
+
if (buildRequestAfterLease === void 0) {
|
|
19614
|
+
throw new Error(
|
|
19615
|
+
"runPostAdmissionManualResume requires request or buildRequestAfterLease"
|
|
19616
|
+
);
|
|
19617
|
+
}
|
|
19618
|
+
request = await buildRequestAfterLease();
|
|
19619
|
+
}
|
|
19620
|
+
request = withEngineDetourInvocationScope(request, invocationScopeId);
|
|
19621
|
+
const result = await dispatchPostAdmissionTurn({
|
|
19622
|
+
admitted,
|
|
19623
|
+
env: {
|
|
19624
|
+
...env,
|
|
19625
|
+
...effectiveModel === void 0 ? {} : { model: effectiveModel },
|
|
19626
|
+
...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
|
|
19725
19627
|
},
|
|
19726
|
-
|
|
19727
|
-
|
|
19728
|
-
|
|
19729
|
-
|
|
19730
|
-
...effectiveModel === void 0 ? {} : { model: effectiveModel },
|
|
19731
|
-
...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
|
|
19732
|
-
},
|
|
19733
|
-
io,
|
|
19734
|
-
request: turnRequest,
|
|
19735
|
-
lease,
|
|
19736
|
-
adapters,
|
|
19737
|
-
...effectiveEngine === void 0 ? {} : { effectiveEngine }
|
|
19738
|
-
})
|
|
19628
|
+
io,
|
|
19629
|
+
request,
|
|
19630
|
+
adapters,
|
|
19631
|
+
...effectiveEngine === void 0 ? {} : { effectiveEngine }
|
|
19739
19632
|
});
|
|
19740
19633
|
if (result.terminal !== void 0 && isLawfulTypedTerminalOutcome(result.terminal.roleOutcome)) {
|
|
19741
19634
|
io.stdout(formatTerminalResult(result.terminal));
|
|
@@ -19743,10 +19636,7 @@ async function runPostAdmissionManualResume(input) {
|
|
|
19743
19636
|
if (result.terminal !== void 0) {
|
|
19744
19637
|
result.terminal.autoResumeCount = 0;
|
|
19745
19638
|
}
|
|
19746
|
-
return
|
|
19747
|
-
...result,
|
|
19748
|
-
...staleWriterLeaseReclaimed === true ? { staleWriterLeaseReclaimed: true } : {}
|
|
19749
|
-
};
|
|
19639
|
+
return result;
|
|
19750
19640
|
}
|
|
19751
19641
|
var StationChildExhaustedError, POST_ADMISSION_CLEANUP_DIAGNOSTIC_ENTRY_TYPE;
|
|
19752
19642
|
var init_post_admission = __esm({
|
|
@@ -19763,7 +19653,6 @@ var init_post_admission = __esm({
|
|
|
19763
19653
|
init_case_dossier_delivery();
|
|
19764
19654
|
init_engine_detour_usage();
|
|
19765
19655
|
init_host_transition_prior_native();
|
|
19766
|
-
init_public_run_credentials();
|
|
19767
19656
|
init_run_lifecycle();
|
|
19768
19657
|
init_process_cancel();
|
|
19769
19658
|
init_activation_ledger_topology();
|
|
@@ -17726,42 +17726,6 @@ var init_host_transition_prior_native = __esm({
|
|
|
17726
17726
|
}
|
|
17727
17727
|
});
|
|
17728
17728
|
|
|
17729
|
-
// src/public-cli/public-run-credentials.ts
|
|
17730
|
-
function knownFailureForMissingProviderCredential(model, credentials) {
|
|
17731
|
-
if (model === void 0 || credentials === void 0) return void 0;
|
|
17732
|
-
if (model.provider !== "openai-codex" && model.provider !== "xai") return void 0;
|
|
17733
|
-
if (!missingPublicProviderCredential(model.provider, credentials)) {
|
|
17734
|
-
return void 0;
|
|
17735
|
-
}
|
|
17736
|
-
return {
|
|
17737
|
-
cause: "provider",
|
|
17738
|
-
identity: {
|
|
17739
|
-
name: "MissingProviderCredential",
|
|
17740
|
-
code: model.provider
|
|
17741
|
-
}
|
|
17742
|
-
};
|
|
17743
|
-
}
|
|
17744
|
-
function missingCredentialPreDispatchFailure(model, credentials) {
|
|
17745
|
-
const knownFailure = knownFailureForMissingProviderCredential(model, credentials);
|
|
17746
|
-
if (knownFailure === void 0) return void 0;
|
|
17747
|
-
return {
|
|
17748
|
-
timedOut: false,
|
|
17749
|
-
code: 1,
|
|
17750
|
-
stderr: `Missing credential for provider ${String(knownFailure.identity?.code ?? "unknown")}`,
|
|
17751
|
-
knownFailure
|
|
17752
|
-
};
|
|
17753
|
-
}
|
|
17754
|
-
function postRunMissingCredentialFailure(result, model, credentials) {
|
|
17755
|
-
if (!(result.timedOut || result.code !== 0)) return void 0;
|
|
17756
|
-
return knownFailureForMissingProviderCredential(model, credentials);
|
|
17757
|
-
}
|
|
17758
|
-
var init_public_run_credentials = __esm({
|
|
17759
|
-
"src/public-cli/public-run-credentials.ts"() {
|
|
17760
|
-
"use strict";
|
|
17761
|
-
init_config();
|
|
17762
|
-
}
|
|
17763
|
-
});
|
|
17764
|
-
|
|
17765
17729
|
// src/public-cli/process-cancel.ts
|
|
17766
17730
|
function processCancelSignalName(signal) {
|
|
17767
17731
|
if (signal === void 0 || signal.aborted !== true) return void 0;
|
|
@@ -18254,8 +18218,8 @@ function withOnceSuccessfulBeforeDispatch(adapters) {
|
|
|
18254
18218
|
};
|
|
18255
18219
|
}
|
|
18256
18220
|
async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic, io) {
|
|
18257
|
-
io.stderr(formatCliDiagnostic(diagnostic));
|
|
18258
18221
|
const payload = { diagnostic, recordedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
18222
|
+
let retentionFailure;
|
|
18259
18223
|
try {
|
|
18260
18224
|
await env.sessionAppender(
|
|
18261
18225
|
env.principalAuthority,
|
|
@@ -18263,7 +18227,6 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
18263
18227
|
POST_ADMISSION_CLEANUP_DIAGNOSTIC_ENTRY_TYPE,
|
|
18264
18228
|
payload
|
|
18265
18229
|
);
|
|
18266
|
-
return;
|
|
18267
18230
|
} catch (appendError) {
|
|
18268
18231
|
try {
|
|
18269
18232
|
const artifactsDir = await ensureRealArtifactsDirectory(admitted.runDirectory);
|
|
@@ -18274,13 +18237,16 @@ async function recordBestEffortPostDispatchDiagnostic(admitted, env, diagnostic,
|
|
|
18274
18237
|
{ encoding: "utf8", flag: "wx" }
|
|
18275
18238
|
);
|
|
18276
18239
|
} catch (artifactError) {
|
|
18277
|
-
|
|
18278
|
-
formatCliDiagnostic(
|
|
18279
|
-
`post-dispatch diagnostic durable retention failed on both channels (best-effort continue): dossier=${describeErrorIdentity(appendError)}; artifact=${describeErrorIdentity(artifactError)}`
|
|
18280
|
-
)
|
|
18281
|
-
);
|
|
18240
|
+
retentionFailure = `post-dispatch diagnostic durable retention failed on both channels (best-effort continue): dossier=${describeErrorIdentity(appendError)}; artifact=${describeErrorIdentity(artifactError)}`;
|
|
18282
18241
|
}
|
|
18283
18242
|
}
|
|
18243
|
+
try {
|
|
18244
|
+
io.stderr(formatCliDiagnostic(diagnostic));
|
|
18245
|
+
if (retentionFailure !== void 0) {
|
|
18246
|
+
io.stderr(formatCliDiagnostic(retentionFailure));
|
|
18247
|
+
}
|
|
18248
|
+
} catch {
|
|
18249
|
+
}
|
|
18284
18250
|
}
|
|
18285
18251
|
async function resolveResumeMethodMaterialAdapters(input) {
|
|
18286
18252
|
if (input.shouldLoad === false) {
|
|
@@ -18443,12 +18409,11 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
18443
18409
|
if (adapters.afterDispatch !== void 0) await adapters.afterDispatch(admitted, lease);
|
|
18444
18410
|
return result;
|
|
18445
18411
|
} catch (error) {
|
|
18446
|
-
|
|
18447
|
-
if (primaryFailure) {
|
|
18412
|
+
if (result.terminal !== void 0) {
|
|
18448
18413
|
await recordBestEffortPostDispatchDiagnostic(
|
|
18449
18414
|
admitted,
|
|
18450
18415
|
env,
|
|
18451
|
-
`afterDispatch failed beside
|
|
18416
|
+
`afterDispatch failed beside host terminal (best-effort continue): ${describeErrorIdentity(error)}`,
|
|
18452
18417
|
io
|
|
18453
18418
|
);
|
|
18454
18419
|
return result;
|
|
@@ -18474,23 +18439,6 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
18474
18439
|
}
|
|
18475
18440
|
};
|
|
18476
18441
|
try {
|
|
18477
|
-
const missingCredential = missingCredentialPreDispatchFailure(
|
|
18478
|
-
env.model,
|
|
18479
|
-
env.credentials
|
|
18480
|
-
);
|
|
18481
|
-
if (missingCredential !== void 0) {
|
|
18482
|
-
return {
|
|
18483
|
-
...await presentControlledFailure2(
|
|
18484
|
-
admitted,
|
|
18485
|
-
withEngineDetourInvocationScope(missingCredential, request.invocationScopeId),
|
|
18486
|
-
adapters,
|
|
18487
|
-
env.principalAuthority,
|
|
18488
|
-
io,
|
|
18489
|
-
persistRunState
|
|
18490
|
-
),
|
|
18491
|
-
...deferredPersist
|
|
18492
|
-
};
|
|
18493
|
-
}
|
|
18494
18442
|
let previousHost;
|
|
18495
18443
|
const liveHost = env.host;
|
|
18496
18444
|
const principalCoordinates = admitted.principal === void 0 ? void 0 : env.principalAuthority.decode(admitted.principal);
|
|
@@ -18623,19 +18571,14 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
18623
18571
|
try {
|
|
18624
18572
|
const sessionFile = admitted.principal !== void 0 ? env.principalAuthority.decode(admitted.principal).sessionFile : "";
|
|
18625
18573
|
const runnerKnownFailure = adapters.resolveRunnerKnownFailure !== void 0 && sessionFile !== "" ? await adapters.resolveRunnerKnownFailure({ result, sessionFile }) : result.knownFailure;
|
|
18626
|
-
const credentialFailure = postRunMissingCredentialFailure(
|
|
18627
|
-
result,
|
|
18628
|
-
env.model,
|
|
18629
|
-
env.credentials
|
|
18630
|
-
);
|
|
18631
18574
|
resolution = await resolveAuditedRunnerFailureResolution({
|
|
18632
18575
|
runner: runnerKnownFailure,
|
|
18633
18576
|
sessionFile,
|
|
18634
|
-
credential:
|
|
18577
|
+
credential: void 0,
|
|
18635
18578
|
runDirectory: admitted.runDirectory
|
|
18636
18579
|
});
|
|
18637
18580
|
const processCancelName = processCancelSignalName(env.signal);
|
|
18638
|
-
const directHostFailureSignal = result.timedOut || result.knownFailure !== void 0 || runnerKnownFailure !== void 0 ||
|
|
18581
|
+
const directHostFailureSignal = result.timedOut || result.knownFailure !== void 0 || runnerKnownFailure !== void 0 || processCancelName !== void 0;
|
|
18639
18582
|
hostSignalFailed = directHostFailureSignal || result.code !== null && result.code !== 0 || resolution.knownFailure !== void 0;
|
|
18640
18583
|
settled = await adapters.trySettle(admitted, env.principalAuthority, courtScope);
|
|
18641
18584
|
if (settled !== void 0) {
|
|
@@ -18701,25 +18644,11 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
18701
18644
|
try {
|
|
18702
18645
|
await persistReturnedRunState(admitted, env.principalAuthority, { lawful: true });
|
|
18703
18646
|
} catch (error) {
|
|
18704
|
-
|
|
18647
|
+
await recordBestEffortPostDispatchDiagnostic(
|
|
18705
18648
|
admitted,
|
|
18706
|
-
|
|
18707
|
-
|
|
18708
|
-
|
|
18709
|
-
stderr: "",
|
|
18710
|
-
thrown: error,
|
|
18711
|
-
skipRunStateWrite: true
|
|
18712
|
-
}, request.invocationScopeId),
|
|
18713
|
-
adapters,
|
|
18714
|
-
env.principalAuthority,
|
|
18715
|
-
io,
|
|
18716
|
-
persistRunState
|
|
18717
|
-
);
|
|
18718
|
-
return await finishAfterTurn(
|
|
18719
|
-
withProcessCancelSkipAutoResume(
|
|
18720
|
-
{ ...failed, turnDispatched: true, ...deferredPersist },
|
|
18721
|
-
env.signal
|
|
18722
|
-
)
|
|
18649
|
+
env,
|
|
18650
|
+
`run-state persistence failed beside host terminal (best-effort continue): ${describeErrorIdentity(error)}`,
|
|
18651
|
+
io
|
|
18723
18652
|
);
|
|
18724
18653
|
}
|
|
18725
18654
|
}
|
|
@@ -18800,25 +18729,11 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
18800
18729
|
try {
|
|
18801
18730
|
await persistReturnedRunState(admitted, env.principalAuthority, { lawful: true });
|
|
18802
18731
|
} catch (error) {
|
|
18803
|
-
|
|
18732
|
+
await recordBestEffortPostDispatchDiagnostic(
|
|
18804
18733
|
admitted,
|
|
18805
|
-
|
|
18806
|
-
|
|
18807
|
-
|
|
18808
|
-
stderr: "",
|
|
18809
|
-
thrown: error,
|
|
18810
|
-
skipRunStateWrite: true
|
|
18811
|
-
}, request.invocationScopeId),
|
|
18812
|
-
adapters,
|
|
18813
|
-
env.principalAuthority,
|
|
18814
|
-
io,
|
|
18815
|
-
persistRunState
|
|
18816
|
-
);
|
|
18817
|
-
return await finishAfterTurn(
|
|
18818
|
-
withProcessCancelSkipAutoResume(
|
|
18819
|
-
{ ...failed, turnDispatched: true, ...deferredPersist },
|
|
18820
|
-
env.signal
|
|
18821
|
-
)
|
|
18734
|
+
env,
|
|
18735
|
+
`run-state persistence failed beside host terminal (best-effort continue): ${describeErrorIdentity(error)}`,
|
|
18736
|
+
io
|
|
18822
18737
|
);
|
|
18823
18738
|
}
|
|
18824
18739
|
}
|
|
@@ -18830,14 +18745,16 @@ async function dispatchPostAdmissionTurn(input) {
|
|
|
18830
18745
|
...deferredPersist
|
|
18831
18746
|
});
|
|
18832
18747
|
} finally {
|
|
18833
|
-
|
|
18834
|
-
|
|
18835
|
-
|
|
18836
|
-
|
|
18837
|
-
|
|
18838
|
-
|
|
18839
|
-
|
|
18840
|
-
|
|
18748
|
+
if (lease !== void 0) {
|
|
18749
|
+
try {
|
|
18750
|
+
await lease.release();
|
|
18751
|
+
} catch (error) {
|
|
18752
|
+
io.stderr(
|
|
18753
|
+
formatCliDiagnostic(
|
|
18754
|
+
`writer lease release failed unexpectedly (best-effort continue): ${describeErrorIdentity(error)}`
|
|
18755
|
+
)
|
|
18756
|
+
);
|
|
18757
|
+
}
|
|
18841
18758
|
}
|
|
18842
18759
|
}
|
|
18843
18760
|
}
|
|
@@ -19152,53 +19069,29 @@ async function runPostAdmissionManualResume(input) {
|
|
|
19152
19069
|
} = input;
|
|
19153
19070
|
let request = input.request;
|
|
19154
19071
|
const effectiveModel = env.model;
|
|
19155
|
-
let lease;
|
|
19156
|
-
let staleWriterLeaseReclaimed;
|
|
19157
|
-
try {
|
|
19158
|
-
lease = await acquireRunWriterLease(admitted.runDirectory, (diagnostic, kind) => {
|
|
19159
|
-
if (kind === "stale-reclaimed") staleWriterLeaseReclaimed = true;
|
|
19160
|
-
io.stderr(diagnostic);
|
|
19161
|
-
});
|
|
19162
|
-
} catch (error) {
|
|
19163
|
-
if (error instanceof RunWriterLeaseHeldError) {
|
|
19164
|
-
io.stderr(formatCliDiagnostic(error.message));
|
|
19165
|
-
return {
|
|
19166
|
-
exitCode: 1,
|
|
19167
|
-
...staleWriterLeaseReclaimed === true ? { staleWriterLeaseReclaimed: true } : {}
|
|
19168
|
-
};
|
|
19169
|
-
}
|
|
19170
|
-
throw error;
|
|
19171
|
-
}
|
|
19172
19072
|
const invocationScopeId = mintEngineDetourInvocationScope({
|
|
19173
19073
|
...effectiveEngine === void 0 ? {} : { effectiveEngine }
|
|
19174
19074
|
});
|
|
19175
|
-
|
|
19176
|
-
|
|
19177
|
-
|
|
19178
|
-
|
|
19179
|
-
|
|
19180
|
-
|
|
19181
|
-
|
|
19182
|
-
|
|
19183
|
-
|
|
19184
|
-
|
|
19185
|
-
|
|
19186
|
-
|
|
19187
|
-
|
|
19075
|
+
if (request === void 0) {
|
|
19076
|
+
if (buildRequestAfterLease === void 0) {
|
|
19077
|
+
throw new Error(
|
|
19078
|
+
"runPostAdmissionManualResume requires request or buildRequestAfterLease"
|
|
19079
|
+
);
|
|
19080
|
+
}
|
|
19081
|
+
request = await buildRequestAfterLease();
|
|
19082
|
+
}
|
|
19083
|
+
request = withEngineDetourInvocationScope(request, invocationScopeId);
|
|
19084
|
+
const result = await dispatchPostAdmissionTurn({
|
|
19085
|
+
admitted,
|
|
19086
|
+
env: {
|
|
19087
|
+
...env,
|
|
19088
|
+
...effectiveModel === void 0 ? {} : { model: effectiveModel },
|
|
19089
|
+
...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
|
|
19188
19090
|
},
|
|
19189
|
-
|
|
19190
|
-
|
|
19191
|
-
|
|
19192
|
-
|
|
19193
|
-
...effectiveModel === void 0 ? {} : { model: effectiveModel },
|
|
19194
|
-
...admitted.correlationId === void 0 ? {} : { correlationId: admitted.correlationId }
|
|
19195
|
-
},
|
|
19196
|
-
io,
|
|
19197
|
-
request: turnRequest,
|
|
19198
|
-
lease,
|
|
19199
|
-
adapters,
|
|
19200
|
-
...effectiveEngine === void 0 ? {} : { effectiveEngine }
|
|
19201
|
-
})
|
|
19091
|
+
io,
|
|
19092
|
+
request,
|
|
19093
|
+
adapters,
|
|
19094
|
+
...effectiveEngine === void 0 ? {} : { effectiveEngine }
|
|
19202
19095
|
});
|
|
19203
19096
|
if (result.terminal !== void 0 && isLawfulTypedTerminalOutcome(result.terminal.roleOutcome)) {
|
|
19204
19097
|
io.stdout(formatTerminalResult(result.terminal));
|
|
@@ -19206,10 +19099,7 @@ async function runPostAdmissionManualResume(input) {
|
|
|
19206
19099
|
if (result.terminal !== void 0) {
|
|
19207
19100
|
result.terminal.autoResumeCount = 0;
|
|
19208
19101
|
}
|
|
19209
|
-
return
|
|
19210
|
-
...result,
|
|
19211
|
-
...staleWriterLeaseReclaimed === true ? { staleWriterLeaseReclaimed: true } : {}
|
|
19212
|
-
};
|
|
19102
|
+
return result;
|
|
19213
19103
|
}
|
|
19214
19104
|
var StationChildExhaustedError, POST_ADMISSION_CLEANUP_DIAGNOSTIC_ENTRY_TYPE;
|
|
19215
19105
|
var init_post_admission = __esm({
|
|
@@ -19226,7 +19116,6 @@ var init_post_admission = __esm({
|
|
|
19226
19116
|
init_case_dossier_delivery();
|
|
19227
19117
|
init_engine_detour_usage();
|
|
19228
19118
|
init_host_transition_prior_native();
|
|
19229
|
-
init_public_run_credentials();
|
|
19230
19119
|
init_run_lifecycle();
|
|
19231
19120
|
init_process_cancel();
|
|
19232
19121
|
init_activation_ledger_topology();
|