@oxagen/cli 5.5.1-271 → 5.5.1-278
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/oxagen.mjs +1790 -930
- package/package.json +1 -1
package/oxagen.mjs
CHANGED
|
@@ -5752,7 +5752,7 @@ function bundleSkillChars(skill) {
|
|
|
5752
5752
|
chars += file2.path.length + file2.content.length;
|
|
5753
5753
|
return chars;
|
|
5754
5754
|
}
|
|
5755
|
-
var protocolTimestampSchema, machineGroupSchema, TACHO_BATCH_SCHEMA, TACHO_BUNDLE_SCHEMA, TACHO_COMMANDS_SCHEMA, TACHO_ENROLLMENT_CLAIMS_SCHEMA, TACHO_ENROLLMENT_CERTIFICATE_DOMAIN, ENROLLMENT_KEY_SET_SCHEMA, ENROLLMENT_KEY_SET_DOMAIN, TACHO_ENFORCEMENT_TIER_ATTR, TACHO_GATEWAY_TIER, TACHO_GATEWAY_SESSION_HEADER, TACHO_GATEWAY_GENESIS_HEADER, TACHO_GATEWAY_HARNESS_HEADER, REFUSAL_META_KEY, DECISION_META_KEY, MCP_STREAMABLE_HTTP_ACCEPT, TACHO_METERING_ATTR, TACHO_METERING_OBSERVED, TACHO_SPAWNED_BY_ATTR, TACHO_MODEL_SESSION_HEADER, TACHO_CREDENTIAL_BASIS_ATTR, TACHO_CREDENTIAL_GATEWAY_BROKERED, TACHO_CREDENTIAL_HARNESS_HELD, TACHO_CREDENTIAL_BASES, TACHO_RUN_TOKEN_ATTR, BUNDLE_FEATURE_GATEWAY_TOOLS, BUNDLE_FEATURE_MODEL_PRICES, BUNDLE_FEATURE_MODEL_PRICES_LONG_CONTEXT, BUNDLE_FEATURE_MODEL_ALLOWLIST, BUNDLE_FEATURE_INDEPENDENT_MODELS, BUNDLE_FEATURE_HOOK_FAIL_OPEN, BUNDLE_FEATURE_STEERING_MANIFEST, BUNDLE_FEATURE_STEERING_INCOMPLETE, BUNDLE_FEATURE_STEERING_LOAD, BUNDLE_FEATURE_CONTAINMENT, BUNDLE_FEATURE_DAILY_BUDGET, BUNDLE_FEATURE_STEER_NEXT_STEP, BUNDLE_FEATURE_UNBOUND_REPO, BUNDLE_FEATURE_CEDAR, BUNDLE_FEATURE_CEDAR_TOOLBELT, BUNDLE_FEATURE_SKILLS, BUNDLE_FEATURE_CACHE_KEEP_ALIVE, BUNDLE_FEATURE_WORK_ORDERS, BUNDLE_FEATURE_WORK_ORDER_START, BUNDLE_FEATURE_WORK_ORDER_STAFFING, BUNDLE_FEATURE_CREDENTIAL_REAUTH, BUNDLE_FEATURE_MCP_RULE_SETS, BUNDLE_FEATURE_GATEWAY_POLICY, BUNDLE_FEATURE_TENANT_SCOPE, BUNDLE_FEATURE_MEMORY_SCOPE, MEMORY_SCOPE_DIGESTS_MAX, GATEWAY_MIN_TIERS, SENSITIVE_SCREEN_ACTIONS, PROMPT_REDACTION_PATTERNS_MAX, PROMPT_REDACTION_PATTERN_MAX, gatewayPolicySchema, BUNDLE_FEATURE_GATEWAY_HARNESS, TACHO_BUNDLE_FEATURES, bundleFeaturesSchema, hostEnrollmentIdSchema, MEMBER_PUBLIC_ID, tachoPlatformSchema, tachoHarnessSchema, TACHO_HARNESS_LABELS, TACHO_HARNESS_TIERS, WRAPPED_HARNESSES, CONNECTED_HARNESSES, HARNESS_BINARY, MODEL_HARNESS_ROUTES, MODEL_ROUTED_HARNESSES, BROKERABLE_HARNESSES, BROKERABLE_HARNESS_PROVIDER, TACHO_TIER_SUMMARY, CUSTOM_AGENT_NAME_PATTERN, RESERVED_AGENT_NAMES, tachoHostStatusSchema, tachoBundleModeSchema, tachoCommandSchema, tachoCommandStatusSchema, tachoCommandAckStatusSchema, tachoDeliveryModeSchema, denyGenerationSchema, deliveredCommandSchema, deliveredCommandResponseSchema, WORK_ORDER_ID_PATTERN, WORK_ORDER_TOKEN_PATTERN, WORK_ITEM_ID_PATTERN, workOrderCommandPayloadSchema, hostConnectionStateSchema, hostConnectionSchema, HOST_CONNECTION_PATH, hostConnectionRequestSchema, hostConnectionChangeResponseSchema, HOST_WORK_ORDERS_PATH, WORK_ORDER_CLAIM_PATH, CERTIFICATE_RENEW_PATH, ENROLLMENT_KEYS_PATH, WORK_ORDER_REJECT_PATH, HOST_MODEL_CREDENTIALS_PATH, HOST_MODEL_CREDENTIAL_STATE_PATH, VAULT_CREDENTIAL_ID_PATTERN, hostModelCredentialSchema, hostModelCredentialsResponseSchema, hostModelCredentialStateResponseSchema, reauthCommandPayloadSchema, connectWorkspaceCommandPayloadSchema, workspaceConnectionRedeemRequestSchema, workspaceConnectionRedeemResponseSchema, REAUTH_PROOF_DOMAIN, workOrderClaimResponseSchema, workOrderRejectResponseSchema, WORK_CRITERION_CLAIM_PATH, WORK_CRITERION_ID_PATTERN, WORK_HEAD_SHA_PATTERN, WORK_CRITERION_CLAIM_TEXT_MAX, WORK_CLAIM_EVIDENCE_MAX, WORK_CLAIM_COMMAND_MAX, WORK_CLAIM_OUTPUT_MAX, WORK_CLAIM_PATH_MAX, WORK_CLAIM_URL_MAX, WORK_CLAIM_CHECK_NAME_MAX, workCriterionClaimResponseSchema, WORK_ORDER_CHECKLIST_PATH, workOrderChecklistOrderSchema, workOrderChecklistResponseSchema, WORK_ORDER_PROGRESS_PATH, WORK_PROGRESS_TEXT_MAX, WORK_PROGRESS_STEP_MAX, workProgressResponseSchema, WORK_ORDER_ENV, WORK_ORDER_TOKEN_ENV, WORK_ORDER_TOKEN_HEADER, WORK_ORDER_ATTR, steeringForceSchema, steeringItemKindSchema, steeringCutReasonSchema, steeringHeldLoadSchema, steeringManifestItemSchema, STEERING_MANIFEST_SCHEMA, steeringManifestSchema, steeringManifestFrameSchema, workOrderSteeringReasonSchema, workOrderSteeringItemSchema, workOrderSteeringManifestSchema, cedarIdSchema, cedarPrincipalSchema, cedarToolSchema, cedarBundleSchema, BUNDLE_SKILLS_MAX, BUNDLE_SKILL_FILES_MAX, BUNDLE_SKILLS_CHARS_MAX, BASE64_PATTERN, bundleSkillFileSchema, bundleSkillSchema, policyBundleSchema, enrollmentClaimsSchema, ed25519SignatureSchema, enrollmentCertificateSchema, enrollmentKeySchema, enrollmentKeySetSchema, tachoEventWireSchema, TACHO_MAX_HELD_SESSIONS, daemonHealthSchema, TACHO_MAX_BATCH, TACHO_MAX_BODY_BYTES, TACHO_MAX_REQUEST_BYTES, TACHO_REQUEST_ENVELOPE_BYTES, SANDBOX_GIT_RELAY_PATH, SANDBOX_GITLAB_RELAY_PATH, SANDBOX_GIT_RELAY_MAX_REQUEST_BYTES, SANDBOX_GIT_RELAY_TIMEOUT_MS, tachoBodySchema, tachoBatchSchema, agentDaySpendSchema, controlEnvelopeSchema, ingestResponseSchema, bundleResponseSchema, commandAcknowledgementSchema, commandsResponseSchema, certificateRenewalResponseSchema, enrollmentKeysResponseSchema, enrollmentResponseSchema, tokenEnrollmentResponseSchema;
|
|
5755
|
+
var protocolTimestampSchema, machineGroupSchema, TACHO_BATCH_SCHEMA, TACHO_BUNDLE_SCHEMA, TACHO_COMMANDS_SCHEMA, TACHO_ENROLLMENT_CLAIMS_SCHEMA, TACHO_ENROLLMENT_CERTIFICATE_DOMAIN, ENROLLMENT_KEY_SET_SCHEMA, ENROLLMENT_KEY_SET_DOMAIN, TACHO_ENFORCEMENT_TIER_ATTR, TACHO_GATEWAY_TIER, TACHO_GATEWAY_SESSION_HEADER, TACHO_GATEWAY_GENESIS_HEADER, TACHO_GATEWAY_HARNESS_HEADER, REFUSAL_META_KEY, DECISION_META_KEY, MCP_STREAMABLE_HTTP_ACCEPT, TACHO_METERING_ATTR, TACHO_METERING_OBSERVED, TACHO_SPAWNED_BY_ATTR, TACHO_MODEL_SESSION_HEADER, TACHO_CREDENTIAL_BASIS_ATTR, TACHO_CREDENTIAL_GATEWAY_BROKERED, TACHO_CREDENTIAL_HARNESS_HELD, TACHO_CREDENTIAL_BASES, TACHO_RUN_TOKEN_ATTR, BUNDLE_FEATURE_GATEWAY_TOOLS, BUNDLE_FEATURE_MODEL_PRICES, BUNDLE_FEATURE_MODEL_PRICES_LONG_CONTEXT, BUNDLE_FEATURE_MODEL_ALLOWLIST, BUNDLE_FEATURE_INDEPENDENT_MODELS, BUNDLE_FEATURE_HOOK_FAIL_OPEN, BUNDLE_FEATURE_STEERING_MANIFEST, BUNDLE_FEATURE_STEERING_INCOMPLETE, BUNDLE_FEATURE_STEERING_LOAD, BUNDLE_FEATURE_CONTAINMENT, BUNDLE_FEATURE_DAILY_BUDGET, BUNDLE_FEATURE_STEER_NEXT_STEP, BUNDLE_FEATURE_UNBOUND_REPO, BUNDLE_FEATURE_CEDAR, BUNDLE_FEATURE_CEDAR_TOOLBELT, BUNDLE_FEATURE_SKILLS, BUNDLE_FEATURE_CACHE_KEEP_ALIVE, BUNDLE_FEATURE_WORK_ORDERS, BUNDLE_FEATURE_WORK_ORDER_START, BUNDLE_FEATURE_WORK_ORDER_STAFFING, BUNDLE_FEATURE_CREDENTIAL_REAUTH, BUNDLE_FEATURE_MCP_RULE_SETS, BUNDLE_FEATURE_GATEWAY_POLICY, BUNDLE_FEATURE_TENANT_SCOPE, BUNDLE_FEATURE_MEMORY_SCOPE, MEMORY_SCOPE_DIGESTS_MAX, GATEWAY_MIN_TIERS, SENSITIVE_SCREEN_ACTIONS, PROMPT_REDACTION_PATTERNS_MAX, PROMPT_REDACTION_PATTERN_MAX, gatewayPolicySchema, BUNDLE_FEATURE_GATEWAY_HARNESS, TACHO_BUNDLE_FEATURES, bundleFeaturesSchema, hostEnrollmentIdSchema, MEMBER_PUBLIC_ID, tachoPlatformSchema, tachoHarnessSchema, TACHO_HARNESS_LABELS, TACHO_HARNESS_TIERS, WRAPPED_HARNESSES, CONNECTED_HARNESSES, HARNESS_BINARY, MODEL_HARNESS_ROUTES, MODEL_ROUTED_HARNESSES, BROKERABLE_HARNESSES, BROKERABLE_HARNESS_PROVIDER, TACHO_TIER_SUMMARY, CUSTOM_AGENT_NAME_PATTERN, RESERVED_AGENT_NAMES, tachoHostStatusSchema, tachoBundleModeSchema, tachoCommandSchema, tachoCommandStatusSchema, tachoCommandAckStatusSchema, tachoDeliveryModeSchema, denyGenerationSchema, deliveredCommandSchema, deliveredCommandResponseSchema, WORK_ORDER_ID_PATTERN, WORK_ORDER_TOKEN_PATTERN, WORK_ITEM_ID_PATTERN, workOrderCommandPayloadSchema, hostConnectionStateSchema, hostConnectionSchema, HOST_CONNECTION_PATH, hostConnectionRequestSchema, hostConnectionChangeResponseSchema, HOST_WORK_ORDERS_PATH, WORK_ORDER_CLAIM_PATH, CERTIFICATE_RENEW_PATH, ENROLLMENT_KEYS_PATH, WORK_ORDER_REJECT_PATH, HOST_MODEL_CREDENTIALS_PATH, HOST_MODEL_CREDENTIAL_STATE_PATH, HOST_MODEL_CREDENTIAL_REFRESH_PATH, VAULT_CREDENTIAL_ID_PATTERN, hostModelCredentialSchema, hostModelCredentialsResponseSchema, hostModelCredentialStateResponseSchema, hostModelCredentialRefreshResponseSchema, reauthCommandPayloadSchema, connectWorkspaceCommandPayloadSchema, workspaceConnectionRedeemRequestSchema, workspaceConnectionRedeemResponseSchema, REAUTH_PROOF_DOMAIN, workOrderClaimResponseSchema, workOrderRejectResponseSchema, WORK_CRITERION_CLAIM_PATH, WORK_CRITERION_ID_PATTERN, WORK_HEAD_SHA_PATTERN, WORK_CRITERION_CLAIM_TEXT_MAX, WORK_CLAIM_EVIDENCE_MAX, WORK_CLAIM_COMMAND_MAX, WORK_CLAIM_OUTPUT_MAX, WORK_CLAIM_PATH_MAX, WORK_CLAIM_URL_MAX, WORK_CLAIM_CHECK_NAME_MAX, workCriterionClaimResponseSchema, WORK_ORDER_CHECKLIST_PATH, workOrderChecklistOrderSchema, workOrderChecklistResponseSchema, WORK_ORDER_PROGRESS_PATH, WORK_PROGRESS_TEXT_MAX, WORK_PROGRESS_STEP_MAX, workProgressResponseSchema, WORK_ORDER_ENV, WORK_ORDER_TOKEN_ENV, WORK_ORDER_TOKEN_HEADER, WORK_ORDER_ATTR, steeringForceSchema, steeringItemKindSchema, steeringCutReasonSchema, steeringHeldLoadSchema, steeringManifestItemSchema, STEERING_MANIFEST_SCHEMA, steeringManifestSchema, steeringManifestFrameSchema, workOrderSteeringReasonSchema, workOrderSteeringItemSchema, workOrderSteeringManifestSchema, cedarIdSchema, cedarPrincipalSchema, cedarToolSchema, cedarBundleSchema, BUNDLE_SKILLS_MAX, BUNDLE_SKILL_FILES_MAX, BUNDLE_SKILLS_CHARS_MAX, BASE64_PATTERN, bundleSkillFileSchema, bundleSkillSchema, policyBundleSchema, enrollmentClaimsSchema, ed25519SignatureSchema, enrollmentCertificateSchema, enrollmentKeySchema, enrollmentKeySetSchema, tachoEventWireSchema, TACHO_MAX_HELD_SESSIONS, daemonHealthSchema, TACHO_MAX_BATCH, TACHO_MAX_BODY_BYTES, TACHO_MAX_REQUEST_BYTES, TACHO_REQUEST_ENVELOPE_BYTES, SANDBOX_GIT_RELAY_PATH, SANDBOX_GITLAB_RELAY_PATH, SANDBOX_GIT_RELAY_MAX_REQUEST_BYTES, SANDBOX_GIT_RELAY_TIMEOUT_MS, tachoBodySchema, tachoBatchSchema, agentDaySpendSchema, controlEnvelopeSchema, ingestResponseSchema, bundleResponseSchema, commandAcknowledgementSchema, commandsResponseSchema, certificateRenewalResponseSchema, enrollmentKeysResponseSchema, enrollmentResponseSchema, tokenEnrollmentResponseSchema;
|
|
5756
5756
|
var init_wire = __esm({
|
|
5757
5757
|
"../../packages/tacho/src/wire.ts"() {
|
|
5758
5758
|
"use strict";
|
|
@@ -6067,6 +6067,7 @@ var init_wire = __esm({
|
|
|
6067
6067
|
WORK_ORDER_REJECT_PATH = `${HOST_WORK_ORDERS_PATH}/reject`;
|
|
6068
6068
|
HOST_MODEL_CREDENTIALS_PATH = "/v1/tacho/model-credentials";
|
|
6069
6069
|
HOST_MODEL_CREDENTIAL_STATE_PATH = `${HOST_MODEL_CREDENTIALS_PATH}/state`;
|
|
6070
|
+
HOST_MODEL_CREDENTIAL_REFRESH_PATH = `${HOST_MODEL_CREDENTIALS_PATH}/refresh`;
|
|
6070
6071
|
VAULT_CREDENTIAL_ID_PATTERN = /^vlt_[0-9a-z]+$/;
|
|
6071
6072
|
hostModelCredentialSchema = external_exports.object({
|
|
6072
6073
|
id: external_exports.string().regex(VAULT_CREDENTIAL_ID_PATTERN),
|
|
@@ -6086,6 +6087,12 @@ var init_wire = __esm({
|
|
|
6086
6087
|
credentials: external_exports.array(hostModelCredentialSchema)
|
|
6087
6088
|
}).passthrough();
|
|
6088
6089
|
hostModelCredentialStateResponseSchema = external_exports.object({ credential_id: external_exports.string(), recorded: external_exports.boolean() }).passthrough();
|
|
6090
|
+
hostModelCredentialRefreshResponseSchema = external_exports.object({
|
|
6091
|
+
credential_id: external_exports.string(),
|
|
6092
|
+
outcome: external_exports.string(),
|
|
6093
|
+
/** When the vault last changed the login, when it holds these tokens. */
|
|
6094
|
+
changed_at: external_exports.string().nullable()
|
|
6095
|
+
}).passthrough();
|
|
6089
6096
|
reauthCommandPayloadSchema = external_exports.object({
|
|
6090
6097
|
credential: external_exports.string().regex(VAULT_CREDENTIAL_ID_PATTERN),
|
|
6091
6098
|
scope: external_exports.enum(["mine", "workspace"]),
|
|
@@ -8539,14 +8546,144 @@ function splitCommandList(command2) {
|
|
|
8539
8546
|
return pieces;
|
|
8540
8547
|
}
|
|
8541
8548
|
function commitsIn(command2) {
|
|
8542
|
-
return
|
|
8543
|
-
(
|
|
8549
|
+
return simpleCommandsOf(command2).some(
|
|
8550
|
+
(stage) => classifySimpleEffect(stage) === "git_commit"
|
|
8544
8551
|
);
|
|
8545
8552
|
}
|
|
8553
|
+
function simpleCommandsOf(command2) {
|
|
8554
|
+
return splitCommandList(command2).flatMap(splitPipeline);
|
|
8555
|
+
}
|
|
8556
|
+
function splitPipeline(piece) {
|
|
8557
|
+
const stages = [];
|
|
8558
|
+
let current = "";
|
|
8559
|
+
let quote;
|
|
8560
|
+
let depth = 0;
|
|
8561
|
+
for (let i2 = 0; i2 < piece.length; i2 += 1) {
|
|
8562
|
+
const char = piece[i2];
|
|
8563
|
+
const next = piece[i2 + 1];
|
|
8564
|
+
if (quote !== void 0) {
|
|
8565
|
+
if (char === quote) quote = void 0;
|
|
8566
|
+
current += char;
|
|
8567
|
+
continue;
|
|
8568
|
+
}
|
|
8569
|
+
if (char === '"' || char === "'") {
|
|
8570
|
+
quote = char;
|
|
8571
|
+
current += char;
|
|
8572
|
+
continue;
|
|
8573
|
+
}
|
|
8574
|
+
if (char === "\\" && next !== void 0) {
|
|
8575
|
+
current += char + next;
|
|
8576
|
+
i2 += 1;
|
|
8577
|
+
continue;
|
|
8578
|
+
}
|
|
8579
|
+
if (char === "(") depth += 1;
|
|
8580
|
+
if (char === ")" && depth > 0) depth -= 1;
|
|
8581
|
+
if (char === "|" && depth === 0 && !current.endsWith(">")) {
|
|
8582
|
+
stages.push(current);
|
|
8583
|
+
current = "";
|
|
8584
|
+
if (next === "&") i2 += 1;
|
|
8585
|
+
continue;
|
|
8586
|
+
}
|
|
8587
|
+
current += char;
|
|
8588
|
+
}
|
|
8589
|
+
stages.push(current);
|
|
8590
|
+
return stages;
|
|
8591
|
+
}
|
|
8592
|
+
function withoutRedirections(command2) {
|
|
8593
|
+
let out = "";
|
|
8594
|
+
let quote;
|
|
8595
|
+
let i2 = 0;
|
|
8596
|
+
while (i2 < command2.length) {
|
|
8597
|
+
const char = command2[i2];
|
|
8598
|
+
if (quote !== void 0) {
|
|
8599
|
+
if (char === quote) quote = void 0;
|
|
8600
|
+
out += char;
|
|
8601
|
+
i2 += 1;
|
|
8602
|
+
continue;
|
|
8603
|
+
}
|
|
8604
|
+
if (char === '"' || char === "'") {
|
|
8605
|
+
quote = char;
|
|
8606
|
+
out += char;
|
|
8607
|
+
i2 += 1;
|
|
8608
|
+
continue;
|
|
8609
|
+
}
|
|
8610
|
+
if (char === "\\" && i2 + 1 < command2.length) {
|
|
8611
|
+
out += char + command2[i2 + 1];
|
|
8612
|
+
i2 += 2;
|
|
8613
|
+
continue;
|
|
8614
|
+
}
|
|
8615
|
+
if (i2 === 0 || /\s/.test(command2[i2 - 1])) {
|
|
8616
|
+
const rest = command2.slice(i2);
|
|
8617
|
+
const fd2 = /^\d*/.exec(rest)?.[0] ?? "";
|
|
8618
|
+
const after = rest.slice(fd2.length);
|
|
8619
|
+
const op = after.startsWith("<<") ? void 0 : REDIRECTION.exec(after)?.[0];
|
|
8620
|
+
if (op !== void 0 && !(fd2 !== "" && op.startsWith("&"))) {
|
|
8621
|
+
i2 += fd2.length + op.length;
|
|
8622
|
+
while (i2 < command2.length && /[ \t]/.test(command2[i2])) i2 += 1;
|
|
8623
|
+
const start = i2;
|
|
8624
|
+
let inner;
|
|
8625
|
+
for (; i2 < command2.length; i2 += 1) {
|
|
8626
|
+
const c = command2[i2];
|
|
8627
|
+
if (inner !== void 0) {
|
|
8628
|
+
if (c === inner) inner = void 0;
|
|
8629
|
+
continue;
|
|
8630
|
+
}
|
|
8631
|
+
if (c === '"' || c === "'") {
|
|
8632
|
+
inner = c;
|
|
8633
|
+
continue;
|
|
8634
|
+
}
|
|
8635
|
+
if (c === "\\") {
|
|
8636
|
+
i2 += 1;
|
|
8637
|
+
continue;
|
|
8638
|
+
}
|
|
8639
|
+
if (c === "$" && command2[i2 + 1] === "(") return void 0;
|
|
8640
|
+
if (TARGET_END.test(c)) break;
|
|
8641
|
+
}
|
|
8642
|
+
if (inner !== void 0 || i2 === start) return void 0;
|
|
8643
|
+
out += " ";
|
|
8644
|
+
continue;
|
|
8645
|
+
}
|
|
8646
|
+
}
|
|
8647
|
+
out += char;
|
|
8648
|
+
i2 += 1;
|
|
8649
|
+
}
|
|
8650
|
+
return out;
|
|
8651
|
+
}
|
|
8652
|
+
function commandWords(command2) {
|
|
8653
|
+
const bare = withoutRedirections(command2);
|
|
8654
|
+
return bare === void 0 ? void 0 : tokenizeSimpleCommand(bare);
|
|
8655
|
+
}
|
|
8656
|
+
function programWords(words3) {
|
|
8657
|
+
let i2 = 0;
|
|
8658
|
+
for (; ; ) {
|
|
8659
|
+
while (i2 < words3.length && ASSIGNMENT.test(words3[i2])) i2 += 1;
|
|
8660
|
+
const program2 = words3[i2]?.split("/").at(-1);
|
|
8661
|
+
if (program2 === "env") {
|
|
8662
|
+
i2 += 1;
|
|
8663
|
+
while (i2 < words3.length && words3[i2].startsWith("-")) {
|
|
8664
|
+
const word2 = words3[i2];
|
|
8665
|
+
const base2 = word2.split("=", 1)[0];
|
|
8666
|
+
if (ENV_FLAGS.has(word2)) i2 += 1;
|
|
8667
|
+
else if (word2.startsWith("--") && ENV_OPTIONS_WITH_VALUE.has(base2))
|
|
8668
|
+
i2 += word2.includes("=") ? 1 : 2;
|
|
8669
|
+
else if (ENV_OPTIONS_WITH_VALUE.has(word2)) i2 += 2;
|
|
8670
|
+
else if (/^-[uC]./.test(word2)) i2 += 1;
|
|
8671
|
+
else return void 0;
|
|
8672
|
+
}
|
|
8673
|
+
continue;
|
|
8674
|
+
}
|
|
8675
|
+
if (program2 === "command") {
|
|
8676
|
+
if (words3[i2 + 1]?.startsWith("-")) return void 0;
|
|
8677
|
+
i2 += 1;
|
|
8678
|
+
continue;
|
|
8679
|
+
}
|
|
8680
|
+
return words3.slice(i2);
|
|
8681
|
+
}
|
|
8682
|
+
}
|
|
8546
8683
|
function classifyShellEffect(command2) {
|
|
8547
8684
|
let found;
|
|
8548
|
-
for (const
|
|
8549
|
-
const effect = classifySimpleEffect(
|
|
8685
|
+
for (const stage of simpleCommandsOf(command2)) {
|
|
8686
|
+
const effect = classifySimpleEffect(stage);
|
|
8550
8687
|
if (effect !== void 0 && (found === void 0 || EFFECT_REACH.indexOf(effect) < EFFECT_REACH.indexOf(found))) {
|
|
8551
8688
|
found = effect;
|
|
8552
8689
|
}
|
|
@@ -8563,15 +8700,14 @@ function isGh(program2) {
|
|
|
8563
8700
|
return program2?.split("/").at(-1) === "gh";
|
|
8564
8701
|
}
|
|
8565
8702
|
function classifySimpleEffect(command2) {
|
|
8566
|
-
const words3 =
|
|
8703
|
+
const words3 = commandWords(command2);
|
|
8567
8704
|
if (words3 === void 0) {
|
|
8568
8705
|
return void 0;
|
|
8569
8706
|
}
|
|
8570
|
-
const
|
|
8571
|
-
if (
|
|
8707
|
+
const tokens = programWords(words3);
|
|
8708
|
+
if (tokens === void 0 || tokens.length === 0) {
|
|
8572
8709
|
return void 0;
|
|
8573
8710
|
}
|
|
8574
|
-
const tokens = words3.slice(start);
|
|
8575
8711
|
const program2 = tokens[0];
|
|
8576
8712
|
if (isGh(program2)) {
|
|
8577
8713
|
const at2 = ghSubcommandIndex(tokens);
|
|
@@ -8740,16 +8876,18 @@ function shellLineOf(input2) {
|
|
|
8740
8876
|
return command2.join(" ");
|
|
8741
8877
|
}
|
|
8742
8878
|
function pullRequestAttrs(response) {
|
|
8743
|
-
|
|
8744
|
-
|
|
8745
|
-
|
|
8746
|
-
|
|
8747
|
-
|
|
8748
|
-
|
|
8749
|
-
|
|
8750
|
-
|
|
8751
|
-
|
|
8752
|
-
|
|
8879
|
+
const text6 = responseUrl(response, {
|
|
8880
|
+
fields: ["html_url", "url"],
|
|
8881
|
+
pattern: PULL_REQUEST_URL,
|
|
8882
|
+
plainText: true
|
|
8883
|
+
});
|
|
8884
|
+
const match = text6 === void 0 ? null : PULL_REQUEST_URL.exec(text6);
|
|
8885
|
+
if (match === null) return {};
|
|
8886
|
+
return {
|
|
8887
|
+
"pr.url": match[0],
|
|
8888
|
+
"pr.number": match[3],
|
|
8889
|
+
"pr.repository": `${match[1]}/${match[2]}`
|
|
8890
|
+
};
|
|
8753
8891
|
}
|
|
8754
8892
|
function issueAttrs(toolName4, input2, response) {
|
|
8755
8893
|
const fields = typeof input2 === "object" && input2 !== null ? input2 : {};
|
|
@@ -8832,14 +8970,12 @@ function issueUrlIn(response) {
|
|
|
8832
8970
|
};
|
|
8833
8971
|
}
|
|
8834
8972
|
function createsIssue(command2) {
|
|
8835
|
-
for (const
|
|
8836
|
-
const
|
|
8837
|
-
|
|
8838
|
-
|
|
8839
|
-
while (i2 < tokens.length && ASSIGNMENT.test(tokens[i2] ?? "")) i2 += 1;
|
|
8840
|
-
if (!isGh(tokens[i2])) continue;
|
|
8973
|
+
for (const stage of simpleCommandsOf(command2)) {
|
|
8974
|
+
const read2 = commandWords(stage);
|
|
8975
|
+
const tokens = read2 === void 0 ? void 0 : programWords(read2);
|
|
8976
|
+
if (tokens === void 0 || !isGh(tokens[0])) continue;
|
|
8841
8977
|
const words3 = [];
|
|
8842
|
-
for (let j =
|
|
8978
|
+
for (let j = 1; j < tokens.length && words3.length < 2; j += 1) {
|
|
8843
8979
|
const token = tokens[j];
|
|
8844
8980
|
if (token === "-R" || token === "--repo") j += 1;
|
|
8845
8981
|
else if (!token.startsWith("-")) words3.push(token);
|
|
@@ -8864,7 +9000,7 @@ function mcpIssueAction(tool, input2) {
|
|
|
8864
9000
|
if (ends("update_issue") || ends("issue_update")) return bystate("edited");
|
|
8865
9001
|
return void 0;
|
|
8866
9002
|
}
|
|
8867
|
-
var TARGET_MAX, READ_TOOLS, SINGLE_FILE_READS, SKILL_FILE, WRITE_TOOLS, EDIT_TOOLS, NETWORK_TOOLS, READ_VERBS, WRITE_VERBS, READ_ONLY_BUILTINS, COMMAND_SEPARATORS, GIT_GLOBAL_OPTIONS_WITH_VALUE, GIT_GLOBAL_FLAGS, EFFECT_REACH, ASSIGNMENT, FILE_PRINTERS, SED_IN_PLACE, STDOUT_REDIRECT, SKILL_FILE_IN_LINE, ARGV_SHELLS, PULL_REQUEST_URL, ISSUE_URL, WHOLE_ISSUE_URL, REPO_SEGMENT;
|
|
9003
|
+
var TARGET_MAX, READ_TOOLS, SINGLE_FILE_READS, SKILL_FILE, WRITE_TOOLS, EDIT_TOOLS, NETWORK_TOOLS, READ_VERBS, WRITE_VERBS, READ_ONLY_BUILTINS, COMMAND_SEPARATORS, GIT_GLOBAL_OPTIONS_WITH_VALUE, GIT_GLOBAL_FLAGS, REDIRECTION, TARGET_END, ENV_OPTIONS_WITH_VALUE, ENV_FLAGS, EFFECT_REACH, ASSIGNMENT, FILE_PRINTERS, SED_IN_PLACE, STDOUT_REDIRECT, SKILL_FILE_IN_LINE, ARGV_SHELLS, PULL_REQUEST_URL, ISSUE_URL, WHOLE_ISSUE_URL, REPO_SEGMENT;
|
|
8868
9004
|
var init_tools = __esm({
|
|
8869
9005
|
"../../packages/tacho/src/claude-code/tools.ts"() {
|
|
8870
9006
|
"use strict";
|
|
@@ -8960,6 +9096,10 @@ var init_tools = __esm({
|
|
|
8960
9096
|
"--no-optional-locks",
|
|
8961
9097
|
"--no-lazy-fetch"
|
|
8962
9098
|
]);
|
|
9099
|
+
REDIRECTION = /^(?:&>>|&>|>>|>\||>&|>|<&|<>|<)/;
|
|
9100
|
+
TARGET_END = /[\s;&|()<>`]/;
|
|
9101
|
+
ENV_OPTIONS_WITH_VALUE = /* @__PURE__ */ new Set(["-u", "--unset", "-C", "--chdir"]);
|
|
9102
|
+
ENV_FLAGS = /* @__PURE__ */ new Set(["-", "-i", "--ignore-environment", "-v", "--debug"]);
|
|
8963
9103
|
EFFECT_REACH = [
|
|
8964
9104
|
"pr_open",
|
|
8965
9105
|
"git_push",
|
|
@@ -8995,15 +9135,14 @@ function ghCommands(command2) {
|
|
|
8995
9135
|
const commands = [];
|
|
8996
9136
|
const pieces = splitCommandList(command2);
|
|
8997
9137
|
pieces.forEach((piece, index) => {
|
|
8998
|
-
const
|
|
8999
|
-
|
|
9000
|
-
|
|
9001
|
-
i2 += 1;
|
|
9002
|
-
if (isGh(words3[i2]))
|
|
9138
|
+
for (const stage of splitPipeline(piece)) {
|
|
9139
|
+
const words3 = programWords(leadingWords(stage));
|
|
9140
|
+
if (words3 === void 0 || !isGh(words3[0])) continue;
|
|
9003
9141
|
commands.push({
|
|
9004
|
-
words: words3
|
|
9142
|
+
words: words3,
|
|
9005
9143
|
text: index === pieces.length - 1 ? commandText(command2, piece) : piece
|
|
9006
9144
|
});
|
|
9145
|
+
}
|
|
9007
9146
|
});
|
|
9008
9147
|
return commands;
|
|
9009
9148
|
}
|
|
@@ -29471,6 +29610,7 @@ function memberOf(entry2) {
|
|
|
29471
29610
|
...entry2.label !== void 0 ? { label: entry2.label } : {},
|
|
29472
29611
|
...entry2.refreshed_at !== void 0 ? { refreshed_at: entry2.refreshed_at } : {},
|
|
29473
29612
|
...entry2.refresh_refused !== void 0 ? { refresh_refused: entry2.refresh_refused } : {},
|
|
29613
|
+
...entry2.write_back === "refused" ? { write_back_refused: true } : {},
|
|
29474
29614
|
...entry2.failure !== void 0 ? { failure: { ...entry2.failure } } : {}
|
|
29475
29615
|
};
|
|
29476
29616
|
}
|
|
@@ -29480,6 +29620,45 @@ function refreshedSince(entry2, vaultChangedAt) {
|
|
|
29480
29620
|
const changed = Date.parse(vaultChangedAt);
|
|
29481
29621
|
return Number.isFinite(refreshed) && Number.isFinite(changed) && refreshed > changed;
|
|
29482
29622
|
}
|
|
29623
|
+
function owedOf(entry2) {
|
|
29624
|
+
if (entry2.kind !== "chatgpt") return void 0;
|
|
29625
|
+
const {
|
|
29626
|
+
credential_id: credentialId,
|
|
29627
|
+
vault_changed_at: vaultChangedAt,
|
|
29628
|
+
refreshed_at: refreshedAt
|
|
29629
|
+
} = entry2;
|
|
29630
|
+
if (credentialId === void 0 || vaultChangedAt === void 0 || refreshedAt === void 0)
|
|
29631
|
+
return void 0;
|
|
29632
|
+
const owed = entry2.write_back !== void 0 ? entry2.write_back === "owed" : refreshedSince(entry2, vaultChangedAt);
|
|
29633
|
+
if (!owed) return void 0;
|
|
29634
|
+
return {
|
|
29635
|
+
provider: entry2.provider,
|
|
29636
|
+
harness: harnessOf(entry2),
|
|
29637
|
+
id: memberIdOf(entry2),
|
|
29638
|
+
credential_id: credentialId,
|
|
29639
|
+
vault_changed_at: vaultChangedAt,
|
|
29640
|
+
refreshed_at: refreshedAt,
|
|
29641
|
+
...entry2.hint !== void 0 ? { hint: entry2.hint } : {},
|
|
29642
|
+
...entry2.label !== void 0 ? { label: entry2.label } : {}
|
|
29643
|
+
};
|
|
29644
|
+
}
|
|
29645
|
+
function keepsOwnTokens(entry2, changedAt) {
|
|
29646
|
+
if (entry2.write_back === "refused") return false;
|
|
29647
|
+
if (entry2.vault_changed_at === changedAt) return true;
|
|
29648
|
+
if (entry2.vault_changed_at !== void 0 && vaultTimeBefore(changedAt, entry2.vault_changed_at))
|
|
29649
|
+
return true;
|
|
29650
|
+
return entry2.write_back !== "stored" && refreshedSince(entry2, changedAt);
|
|
29651
|
+
}
|
|
29652
|
+
function vaultTimeBefore(a, b3) {
|
|
29653
|
+
const left = Date.parse(a);
|
|
29654
|
+
const right = Date.parse(b3);
|
|
29655
|
+
return Number.isFinite(left) && Number.isFinite(right) && left < right;
|
|
29656
|
+
}
|
|
29657
|
+
function servingEntries(entries2, provider, harness) {
|
|
29658
|
+
return slotEntries(entries2, provider, harness).filter(
|
|
29659
|
+
(e) => e.unlisted !== true
|
|
29660
|
+
);
|
|
29661
|
+
}
|
|
29483
29662
|
function prefixOf(kind, secret) {
|
|
29484
29663
|
return kind === "chatgpt" ? "login" : credentialPrefix(secret);
|
|
29485
29664
|
}
|
|
@@ -29572,11 +29751,13 @@ function openCredentialStore(paths) {
|
|
|
29572
29751
|
return {
|
|
29573
29752
|
has: (provider, harness) => {
|
|
29574
29753
|
const owner = ownerOf(provider, harness);
|
|
29575
|
-
return readAll()
|
|
29754
|
+
return servingEntries(readAll(), provider, owner).length > 0;
|
|
29576
29755
|
},
|
|
29577
29756
|
read: (provider, harness) => {
|
|
29578
29757
|
const owner = ownerOf(provider, harness);
|
|
29579
|
-
const entry2 = slotEntries(readAll(), provider, owner)
|
|
29758
|
+
const entry2 = slotEntries(readAll(), provider, owner).find(
|
|
29759
|
+
(e) => !isVaultCopy(e)
|
|
29760
|
+
);
|
|
29580
29761
|
return entry2 === void 0 ? void 0 : openEntry(entry2);
|
|
29581
29762
|
},
|
|
29582
29763
|
take: (provider, { kind, secret }, source, now, harness) => {
|
|
@@ -29596,22 +29777,41 @@ function openCredentialStore(paths) {
|
|
|
29596
29777
|
...hint !== void 0 ? { hint } : {}
|
|
29597
29778
|
};
|
|
29598
29779
|
const entries2 = readAll();
|
|
29599
|
-
const
|
|
29780
|
+
const slot = slotEntries(entries2, provider, owner);
|
|
29781
|
+
const copies = slot.filter(isVaultCopy);
|
|
29782
|
+
const previous = slot.find((e) => !isVaultCopy(e));
|
|
29783
|
+
const pending = [];
|
|
29784
|
+
if (previous !== void 0 && owedOf(previous) !== void 0 && !copies.some((c) => c.credential_id === previous.credential_id)) {
|
|
29785
|
+
const kept = openEntry(previous);
|
|
29786
|
+
if (identityOf(kept.kind, kept.secret) !== identityOf(kind, secret)) {
|
|
29787
|
+
const copy = {
|
|
29788
|
+
...previous,
|
|
29789
|
+
source: VAULT_POOL_SOURCE,
|
|
29790
|
+
unlisted: true
|
|
29791
|
+
};
|
|
29792
|
+
pending.push({
|
|
29793
|
+
...copy,
|
|
29794
|
+
sealed: seal(keyForWrite(), kept.secret, entryContext(copy))
|
|
29795
|
+
});
|
|
29796
|
+
}
|
|
29797
|
+
}
|
|
29600
29798
|
writeAll3([
|
|
29601
29799
|
...entries2.filter((e) => !matches(e, provider, owner)),
|
|
29602
29800
|
entry2,
|
|
29603
|
-
...copies
|
|
29801
|
+
...copies,
|
|
29802
|
+
...pending
|
|
29604
29803
|
]);
|
|
29605
29804
|
return custodyOf(entry2);
|
|
29606
29805
|
},
|
|
29607
|
-
release: (provider, harness) => {
|
|
29806
|
+
release: (provider, harness, options) => {
|
|
29608
29807
|
const owner = ownerOf(provider, harness);
|
|
29609
29808
|
const entries2 = readAll();
|
|
29610
29809
|
const slot = slotEntries(entries2, provider, owner);
|
|
29611
29810
|
if (slot.length === 0) return void 0;
|
|
29612
29811
|
const own2 = slot.find((e) => !isVaultCopy(e));
|
|
29613
29812
|
const held = own2 === void 0 ? void 0 : openEntry(own2);
|
|
29614
|
-
|
|
29813
|
+
const kept = options?.keepOwed === true ? slot.filter((e) => owedOf(e) !== void 0).map((e) => ({ ...e, unlisted: true })) : [];
|
|
29814
|
+
writeAll3(withSlot(entries2, provider, owner, kept));
|
|
29615
29815
|
return held;
|
|
29616
29816
|
},
|
|
29617
29817
|
status: () => {
|
|
@@ -29628,7 +29828,7 @@ function openCredentialStore(paths) {
|
|
|
29628
29828
|
}
|
|
29629
29829
|
return rows;
|
|
29630
29830
|
},
|
|
29631
|
-
pool: (provider, harness) =>
|
|
29831
|
+
pool: (provider, harness) => servingEntries(readAll(), provider, ownerOf(provider, harness)).map(
|
|
29632
29832
|
memberOf
|
|
29633
29833
|
),
|
|
29634
29834
|
open: (provider, harness, id2) => {
|
|
@@ -29638,7 +29838,7 @@ function openCredentialStore(paths) {
|
|
|
29638
29838
|
return entry2 === void 0 ? void 0 : openEntry(entry2);
|
|
29639
29839
|
},
|
|
29640
29840
|
nextUntried: (provider, harness, options) => {
|
|
29641
|
-
const eligible =
|
|
29841
|
+
const eligible = servingEntries(readAll(), provider, harness).map(memberOf).filter(
|
|
29642
29842
|
(member4) => !(options.tried?.has(member4.id) ?? false) && (options.loginsOnly !== true || isLoginKind(member4.kind)) && (options.fits?.(member4) ?? true)
|
|
29643
29843
|
);
|
|
29644
29844
|
const ready = eligible.find(
|
|
@@ -29679,7 +29879,12 @@ function openCredentialStore(paths) {
|
|
|
29679
29879
|
if (secret.trim().length === 0)
|
|
29680
29880
|
throw new Error("refusing to take an empty credential into custody");
|
|
29681
29881
|
return updateMember(provider, harness, id2, (entry2) => {
|
|
29682
|
-
const {
|
|
29882
|
+
const {
|
|
29883
|
+
failure: failure5,
|
|
29884
|
+
refresh_refused: _refused,
|
|
29885
|
+
write_back: _writeBack,
|
|
29886
|
+
...rest
|
|
29887
|
+
} = entry2;
|
|
29683
29888
|
const at2 = new Date(now).toISOString();
|
|
29684
29889
|
const next = {
|
|
29685
29890
|
...rest,
|
|
@@ -29690,6 +29895,10 @@ function openCredentialStore(paths) {
|
|
|
29690
29895
|
taken_at: at2,
|
|
29691
29896
|
refreshed_at: at2,
|
|
29692
29897
|
prefix: prefixOf(kind, secret),
|
|
29898
|
+
// New tokens for a login the vault holds too are owed to the vault
|
|
29899
|
+
// until Oxagen stores them: its copy now holds a spent refresh
|
|
29900
|
+
// token.
|
|
29901
|
+
...kind === "chatgpt" && entry2.credential_id !== void 0 ? { write_back: "owed" } : {},
|
|
29693
29902
|
...failure5 !== void 0 && !isTokenRefused(failure5.kind) ? { failure: failure5 } : {},
|
|
29694
29903
|
sealed: entry2.sealed
|
|
29695
29904
|
};
|
|
@@ -29727,7 +29936,7 @@ function openCredentialStore(paths) {
|
|
|
29727
29936
|
identities.add(identity);
|
|
29728
29937
|
const before = local.get(member4.credential_id);
|
|
29729
29938
|
const label = member4.label?.slice(0, 80);
|
|
29730
|
-
const unchanged = before !== void 0 && before.kind === member4.kind && (before
|
|
29939
|
+
const unchanged = before !== void 0 && before.kind === member4.kind && keepsOwnTokens(before, member4.changed_at);
|
|
29731
29940
|
if (before !== void 0) kept += 1;
|
|
29732
29941
|
else added += 1;
|
|
29733
29942
|
const base2 = unchanged ? { ...before } : {
|
|
@@ -29742,7 +29951,12 @@ function openCredentialStore(paths) {
|
|
|
29742
29951
|
// Replaced below, once the row's context is known.
|
|
29743
29952
|
sealed: own2.sealed
|
|
29744
29953
|
};
|
|
29745
|
-
const {
|
|
29954
|
+
const {
|
|
29955
|
+
label: _label,
|
|
29956
|
+
failure: _failure,
|
|
29957
|
+
unlisted: _unlisted,
|
|
29958
|
+
...rest
|
|
29959
|
+
} = base2;
|
|
29746
29960
|
const failure5 = mergedFailure(
|
|
29747
29961
|
unchanged ? before.failure : void 0,
|
|
29748
29962
|
member4.limited_until,
|
|
@@ -29761,31 +29975,109 @@ function openCredentialStore(paths) {
|
|
|
29761
29975
|
}
|
|
29762
29976
|
);
|
|
29763
29977
|
}
|
|
29764
|
-
const
|
|
29765
|
-
|
|
29766
|
-
|
|
29978
|
+
const carried = new Set(copies.map(memberIdOf));
|
|
29979
|
+
const parked = [];
|
|
29980
|
+
let removed = 0;
|
|
29981
|
+
for (const [id2, entry2] of local) {
|
|
29982
|
+
if (carried.has(id2)) continue;
|
|
29983
|
+
if (id2 !== ownCopy?.credential_id && owedOf(entry2) !== void 0) {
|
|
29984
|
+
parked.push({ ...entry2, unlisted: true });
|
|
29985
|
+
continue;
|
|
29986
|
+
}
|
|
29987
|
+
if (!members3.some((m) => m.credential_id === id2)) removed += 1;
|
|
29988
|
+
}
|
|
29767
29989
|
const {
|
|
29768
29990
|
credential_id: _id,
|
|
29769
29991
|
label: _ownLabel,
|
|
29770
29992
|
failure: _ownFailure,
|
|
29993
|
+
vault_changed_at: ownBase,
|
|
29994
|
+
write_back: ownWriteBack,
|
|
29771
29995
|
...ownBare
|
|
29772
29996
|
} = own2;
|
|
29773
29997
|
const ownLabel = ownCopy?.label?.slice(0, 80);
|
|
29998
|
+
const ownLogin = own2.kind === "chatgpt" && ownCopy?.kind === "chatgpt" ? ownCopy : void 0;
|
|
29999
|
+
const sameVaultLogin = own2.credential_id === ownLogin?.credential_id;
|
|
30000
|
+
const takesVaultTokens = ownLogin !== void 0 && sameVaultLogin && ownBase !== void 0 && !keepsOwnTokens(own2, ownLogin.changed_at);
|
|
29774
30001
|
const ownFailure = mergedFailure(
|
|
29775
|
-
|
|
30002
|
+
// New tokens cure a token the provider refused, as a refresh does.
|
|
30003
|
+
takesVaultTokens && own2.failure !== void 0 && isTokenRefused(own2.failure.kind) ? void 0 : own2.failure,
|
|
29776
30004
|
ownCopy?.limited_until,
|
|
29777
30005
|
now
|
|
29778
30006
|
);
|
|
29779
|
-
const
|
|
29780
|
-
...ownBare,
|
|
30007
|
+
const ownNamed = {
|
|
29781
30008
|
...ownCopy !== void 0 ? { credential_id: ownCopy.credential_id } : {},
|
|
29782
30009
|
...ownLabel !== void 0 && ownLabel.length > 0 ? { label: ownLabel } : {},
|
|
29783
30010
|
...own2.hint === void 0 && ownCopy !== void 0 ? { hint: ownCopy.hint.slice(-4) } : {},
|
|
29784
30011
|
...ownFailure !== void 0 ? { failure: ownFailure } : {}
|
|
29785
30012
|
};
|
|
29786
|
-
|
|
30013
|
+
let ownNext;
|
|
30014
|
+
if (ownLogin !== void 0 && takesVaultTokens) {
|
|
30015
|
+
const {
|
|
30016
|
+
refreshed_at: _refreshedAt,
|
|
30017
|
+
refresh_refused: _refreshRefused,
|
|
30018
|
+
...ownKept
|
|
30019
|
+
} = ownBare;
|
|
30020
|
+
ownNext = {
|
|
30021
|
+
...ownKept,
|
|
30022
|
+
...ownNamed,
|
|
30023
|
+
taken_at: new Date(now).toISOString(),
|
|
30024
|
+
prefix: prefixOf(ownLogin.kind, ownLogin.secret),
|
|
30025
|
+
vault_changed_at: ownLogin.changed_at,
|
|
30026
|
+
sealed: seal(
|
|
30027
|
+
keyForWrite(),
|
|
30028
|
+
ownLogin.secret,
|
|
30029
|
+
sealingContext(provider, harness)
|
|
30030
|
+
)
|
|
30031
|
+
};
|
|
30032
|
+
} else if (ownLogin !== void 0) {
|
|
30033
|
+
const writeBack = sameVaultLogin ? ownWriteBack : ownWriteBack === "owed" ? ownWriteBack : void 0;
|
|
30034
|
+
ownNext = {
|
|
30035
|
+
...ownBare,
|
|
30036
|
+
...ownNamed,
|
|
30037
|
+
vault_changed_at: sameVaultLogin && ownBase !== void 0 ? ownBase : ownLogin.changed_at,
|
|
30038
|
+
...writeBack !== void 0 ? { write_back: writeBack } : {}
|
|
30039
|
+
};
|
|
30040
|
+
} else if (ownCopy === void 0 && owedOf(own2) !== void 0) {
|
|
30041
|
+
ownNext = {
|
|
30042
|
+
...ownBare,
|
|
30043
|
+
...ownNamed,
|
|
30044
|
+
credential_id: own2.credential_id,
|
|
30045
|
+
...own2.label !== void 0 ? { label: own2.label } : {},
|
|
30046
|
+
...ownBase !== void 0 ? { vault_changed_at: ownBase } : {},
|
|
30047
|
+
...ownWriteBack !== void 0 ? { write_back: ownWriteBack } : {}
|
|
30048
|
+
};
|
|
30049
|
+
} else {
|
|
30050
|
+
ownNext = { ...ownBare, ...ownNamed };
|
|
30051
|
+
}
|
|
30052
|
+
writeAll3(
|
|
30053
|
+
withSlot(entries2, provider, harness, [ownNext, ...copies, ...parked])
|
|
30054
|
+
);
|
|
29787
30055
|
return { synced: true, added, kept, removed };
|
|
29788
30056
|
},
|
|
30057
|
+
owedLogins: () => {
|
|
30058
|
+
const owed = [];
|
|
30059
|
+
for (const entry2 of readAll()) {
|
|
30060
|
+
const login = owedOf(entry2);
|
|
30061
|
+
if (login !== void 0) owed.push(login);
|
|
30062
|
+
}
|
|
30063
|
+
return owed;
|
|
30064
|
+
},
|
|
30065
|
+
settleWriteBack: (provider, harness, id2, refreshedAt, settlement) => {
|
|
30066
|
+
let settled2 = false;
|
|
30067
|
+
updateMember(provider, harness, id2, (entry2) => {
|
|
30068
|
+
if (owedOf(entry2) === void 0) return void 0;
|
|
30069
|
+
if (entry2.refreshed_at !== refreshedAt) {
|
|
30070
|
+
return settlement.state === "stored" ? { ...entry2, vault_changed_at: settlement.changedAt } : void 0;
|
|
30071
|
+
}
|
|
30072
|
+
settled2 = true;
|
|
30073
|
+
return settlement.state === "stored" ? {
|
|
30074
|
+
...entry2,
|
|
30075
|
+
vault_changed_at: settlement.changedAt,
|
|
30076
|
+
write_back: "stored"
|
|
30077
|
+
} : { ...entry2, write_back: "refused" };
|
|
30078
|
+
});
|
|
30079
|
+
return settled2;
|
|
30080
|
+
},
|
|
29789
30081
|
shred: () => {
|
|
29790
30082
|
let overwrite;
|
|
29791
30083
|
try {
|
|
@@ -29804,7 +30096,7 @@ function openCredentialStore(paths) {
|
|
|
29804
30096
|
}
|
|
29805
30097
|
};
|
|
29806
30098
|
}
|
|
29807
|
-
var CREDENTIAL_STORE_SCHEMA, CREDENTIAL_SOURCES, VAULT_POOL_SOURCE, HELD_MEMBER_ID, CREDENTIAL_KINDS, CLAUDE_OAUTH_TOKEN_PREFIX, LOGIN_REFRESH_REFUSALS, sealedSchema, failureSchema, entrySchema, fileSchema, KEY_BYTES2;
|
|
30099
|
+
var CREDENTIAL_STORE_SCHEMA, CREDENTIAL_SOURCES, VAULT_POOL_SOURCE, HELD_MEMBER_ID, CREDENTIAL_KINDS, CLAUDE_OAUTH_TOKEN_PREFIX, LOGIN_REFRESH_REFUSALS, LOGIN_WRITE_BACK_STATES, sealedSchema, failureSchema, entrySchema, fileSchema, KEY_BYTES2;
|
|
29808
30100
|
var init_credential_store = __esm({
|
|
29809
30101
|
"../../packages/tacho/src/host/credential-store.ts"() {
|
|
29810
30102
|
"use strict";
|
|
@@ -29855,6 +30147,7 @@ var init_credential_store = __esm({
|
|
|
29855
30147
|
];
|
|
29856
30148
|
CLAUDE_OAUTH_TOKEN_PREFIX = "sk-ant-oat";
|
|
29857
30149
|
LOGIN_REFRESH_REFUSALS = ["rotated", "refused"];
|
|
30150
|
+
LOGIN_WRITE_BACK_STATES = ["owed", "stored", "refused"];
|
|
29858
30151
|
sealedSchema = external_exports.object({
|
|
29859
30152
|
/** AES-256-GCM: 12-byte nonce, ciphertext, 16-byte tag, all base64. */
|
|
29860
30153
|
nonce: external_exports.string().min(1),
|
|
@@ -29895,11 +30188,28 @@ var init_credential_store = __esm({
|
|
|
29895
30188
|
/** The name the person gave it in Oxagen, such as the account's email. */
|
|
29896
30189
|
label: external_exports.string().max(80).optional(),
|
|
29897
30190
|
/**
|
|
29898
|
-
* When the vault last changed the secret
|
|
29899
|
-
*
|
|
29900
|
-
*
|
|
30191
|
+
* When the vault last changed the secret this row's tokens came from:
|
|
30192
|
+
* every `vault:pool` member, and the machine's own ChatGPT login while
|
|
30193
|
+
* the vault holds a login for the same account. A write-back sends it,
|
|
30194
|
+
* and Oxagen stores the new tokens only while its row still carries this
|
|
30195
|
+
* time. A ChatGPT login this machine refreshed after that time keeps its
|
|
30196
|
+
* own, newer tokens on the next sync.
|
|
29901
30197
|
*/
|
|
29902
30198
|
vault_changed_at: external_exports.string().optional(),
|
|
30199
|
+
/**
|
|
30200
|
+
* Where this row's tokens stand with the vault (`LoginWriteBackState`).
|
|
30201
|
+
* Absent on a row never refreshed here, and on a row an earlier build
|
|
30202
|
+
* refreshed, which reads as owed when `refreshed_at` is after
|
|
30203
|
+
* `vault_changed_at`.
|
|
30204
|
+
*/
|
|
30205
|
+
write_back: external_exports.enum(LOGIN_WRITE_BACK_STATES).optional(),
|
|
30206
|
+
/**
|
|
30207
|
+
* The vault's last list left this copy out, and it is kept only because
|
|
30208
|
+
* it still owes the vault its tokens. The gateway spends no call on it
|
|
30209
|
+
* and never refreshes it. It goes at the first sync after Oxagen answers
|
|
30210
|
+
* the write-back.
|
|
30211
|
+
*/
|
|
30212
|
+
unlisted: external_exports.literal(true).optional(),
|
|
29903
30213
|
/** When this machine last refreshed the secret (`replaceSecret`), ISO-8601. */
|
|
29904
30214
|
refreshed_at: external_exports.string().optional(),
|
|
29905
30215
|
/**
|
|
@@ -30083,6 +30393,879 @@ var init_claude_setup_token = __esm({
|
|
|
30083
30393
|
}
|
|
30084
30394
|
});
|
|
30085
30395
|
|
|
30396
|
+
// ../../packages/tacho/src/arp/schema.ts
|
|
30397
|
+
function arpFail(message2) {
|
|
30398
|
+
throw new Error(`ARP: ${message2}`);
|
|
30399
|
+
}
|
|
30400
|
+
function zodIssues(error2) {
|
|
30401
|
+
return error2.issues.map((issue2) => `${issue2.path.join(".") || "(root)"}: ${issue2.message}`).join("; ");
|
|
30402
|
+
}
|
|
30403
|
+
function safeRelativePath(path2) {
|
|
30404
|
+
const unsafe = () => arpFail(
|
|
30405
|
+
`Path ${JSON.stringify(path2)} is unsafe on a supported destination filesystem.`
|
|
30406
|
+
);
|
|
30407
|
+
if (!path2 || path2.length > 4096 || /[\\:\x00-\x1f\x7f<>"|?*]/u.test(path2))
|
|
30408
|
+
unsafe();
|
|
30409
|
+
for (const part of path2.split("/")) {
|
|
30410
|
+
if (!part || part === "." || part === ".." || /[. ]$/u.test(part) || /^(?:\.git|\.arp)$/iu.test(part) || /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/iu.test(part) || part.normalize("NFC") !== part || /[\ud800-\udfff]/u.test(part))
|
|
30411
|
+
unsafe();
|
|
30412
|
+
}
|
|
30413
|
+
return path2;
|
|
30414
|
+
}
|
|
30415
|
+
var ARP_MAX_BLOB_BYTES, ARP_MAX_TOTAL_BYTES, ARP_MAX_FILES, text2, digestSchema, empty, extensions, path, blobRefSchema, arpFrameSchema, arpCheckpointSchema, arpWorkspaceSchema;
|
|
30416
|
+
var init_schema = __esm({
|
|
30417
|
+
"../../packages/tacho/src/arp/schema.ts"() {
|
|
30418
|
+
"use strict";
|
|
30419
|
+
init_zod();
|
|
30420
|
+
init_digest();
|
|
30421
|
+
ARP_MAX_BLOB_BYTES = 64 * 1024 * 1024;
|
|
30422
|
+
ARP_MAX_TOTAL_BYTES = 512 * 1024 * 1024;
|
|
30423
|
+
ARP_MAX_FILES = 1e4;
|
|
30424
|
+
text2 = external_exports.string().min(1).max(4096);
|
|
30425
|
+
digestSchema = external_exports.string().regex(SHA256_DIGEST_PATTERN);
|
|
30426
|
+
empty = external_exports.array(external_exports.never()).max(0);
|
|
30427
|
+
extensions = external_exports.object({}).strict();
|
|
30428
|
+
path = text2.refine((value) => {
|
|
30429
|
+
try {
|
|
30430
|
+
safeRelativePath(value);
|
|
30431
|
+
return true;
|
|
30432
|
+
} catch {
|
|
30433
|
+
return false;
|
|
30434
|
+
}
|
|
30435
|
+
}, "Unsafe ARP workspace path");
|
|
30436
|
+
blobRefSchema = external_exports.object({
|
|
30437
|
+
digest: digestSchema,
|
|
30438
|
+
bytes: external_exports.number().int().min(0).max(ARP_MAX_BLOB_BYTES),
|
|
30439
|
+
media_type: text2
|
|
30440
|
+
}).strict();
|
|
30441
|
+
arpFrameSchema = external_exports.object({
|
|
30442
|
+
format: external_exports.literal("tacho/1.0"),
|
|
30443
|
+
issuer: text2,
|
|
30444
|
+
stream_id: text2,
|
|
30445
|
+
seq: external_exports.string().regex(/^(0|[1-9][0-9]*)$/),
|
|
30446
|
+
digest: digestSchema
|
|
30447
|
+
}).strict();
|
|
30448
|
+
arpCheckpointSchema = external_exports.object({
|
|
30449
|
+
schema: external_exports.literal("arp.checkpoint/0.1"),
|
|
30450
|
+
checkpoint_id: text2,
|
|
30451
|
+
issuer: text2,
|
|
30452
|
+
profile: external_exports.literal("code-workspace/0.1"),
|
|
30453
|
+
created_at: external_exports.string().datetime({ offset: true }),
|
|
30454
|
+
source: external_exports.object({
|
|
30455
|
+
boundary: arpFrameSchema,
|
|
30456
|
+
position: external_exports.literal("after"),
|
|
30457
|
+
evidence_prefix: blobRefSchema
|
|
30458
|
+
}).strict(),
|
|
30459
|
+
capture: external_exports.object({
|
|
30460
|
+
boundary_kind: external_exports.literal("turn_completed"),
|
|
30461
|
+
quiescence: external_exports.enum(["client_attested", "runner_enforced"]),
|
|
30462
|
+
barrier_evidence: blobRefSchema,
|
|
30463
|
+
pending_operations: empty,
|
|
30464
|
+
active_children: empty
|
|
30465
|
+
}).strict(),
|
|
30466
|
+
task: blobRefSchema,
|
|
30467
|
+
context: blobRefSchema,
|
|
30468
|
+
workspace: blobRefSchema,
|
|
30469
|
+
environment: blobRefSchema,
|
|
30470
|
+
tools: blobRefSchema,
|
|
30471
|
+
authority: blobRefSchema,
|
|
30472
|
+
effects: external_exports.array(
|
|
30473
|
+
external_exports.object({
|
|
30474
|
+
operation_id: text2,
|
|
30475
|
+
status: external_exports.enum(["settled", "unknown"]),
|
|
30476
|
+
receipt: blobRefSchema.optional(),
|
|
30477
|
+
external_ids: external_exports.array(text2).max(ARP_MAX_FILES),
|
|
30478
|
+
idempotency_key: text2.optional()
|
|
30479
|
+
}).strict()
|
|
30480
|
+
).max(ARP_MAX_FILES),
|
|
30481
|
+
gaps: external_exports.array(
|
|
30482
|
+
external_exports.object({
|
|
30483
|
+
code: text2,
|
|
30484
|
+
dimension: external_exports.enum([
|
|
30485
|
+
"workspace",
|
|
30486
|
+
"environment",
|
|
30487
|
+
"context",
|
|
30488
|
+
"tools",
|
|
30489
|
+
"effects",
|
|
30490
|
+
"authority",
|
|
30491
|
+
"evidence"
|
|
30492
|
+
]),
|
|
30493
|
+
required: external_exports.boolean(),
|
|
30494
|
+
detail: text2,
|
|
30495
|
+
source: arpFrameSchema.optional()
|
|
30496
|
+
}).strict()
|
|
30497
|
+
).max(ARP_MAX_FILES),
|
|
30498
|
+
extensions,
|
|
30499
|
+
required_extensions: empty
|
|
30500
|
+
}).strict();
|
|
30501
|
+
arpWorkspaceSchema = external_exports.object({
|
|
30502
|
+
schema: external_exports.literal("arp.workspace/0.1"),
|
|
30503
|
+
complete_scope: external_exports.literal(true),
|
|
30504
|
+
repositories: external_exports.array(
|
|
30505
|
+
external_exports.object({
|
|
30506
|
+
root: external_exports.union([external_exports.literal("."), path]),
|
|
30507
|
+
provider_id: text2,
|
|
30508
|
+
base_object: text2
|
|
30509
|
+
}).strict()
|
|
30510
|
+
).max(ARP_MAX_FILES),
|
|
30511
|
+
entries: external_exports.array(
|
|
30512
|
+
external_exports.discriminatedUnion("kind", [
|
|
30513
|
+
external_exports.object({ path, kind: external_exports.literal("directory") }).strict(),
|
|
30514
|
+
external_exports.object({
|
|
30515
|
+
path,
|
|
30516
|
+
kind: external_exports.literal("file"),
|
|
30517
|
+
blob: blobRefSchema,
|
|
30518
|
+
executable: external_exports.boolean()
|
|
30519
|
+
}).strict()
|
|
30520
|
+
])
|
|
30521
|
+
).max(ARP_MAX_FILES),
|
|
30522
|
+
// Exclusions describe omitted paths, including reserved metadata directories.
|
|
30523
|
+
exclusions: external_exports.array(
|
|
30524
|
+
external_exports.object({ path: text2, reason: text2, required: external_exports.boolean() }).strict()
|
|
30525
|
+
).max(ARP_MAX_FILES),
|
|
30526
|
+
resources: empty,
|
|
30527
|
+
extensions,
|
|
30528
|
+
required_extensions: empty
|
|
30529
|
+
}).strict();
|
|
30530
|
+
}
|
|
30531
|
+
});
|
|
30532
|
+
|
|
30533
|
+
// ../../packages/tacho/src/host/device-key.ts
|
|
30534
|
+
import {
|
|
30535
|
+
createHash as createHash6,
|
|
30536
|
+
createPrivateKey,
|
|
30537
|
+
createPublicKey as createPublicKey3,
|
|
30538
|
+
generateKeyPairSync,
|
|
30539
|
+
sign as sign3,
|
|
30540
|
+
verify as verify3
|
|
30541
|
+
} from "node:crypto";
|
|
30542
|
+
import { readFileSync as readFileSync10 } from "node:fs";
|
|
30543
|
+
function encodePublicKey(privateKey) {
|
|
30544
|
+
const spki = createPublicKey3(privateKey).export({
|
|
30545
|
+
type: "spki",
|
|
30546
|
+
format: "der"
|
|
30547
|
+
});
|
|
30548
|
+
const raw = spki.subarray(SPKI_ED25519_PREFIX_BYTES);
|
|
30549
|
+
return `ed25519:${raw.toString("base64")}`;
|
|
30550
|
+
}
|
|
30551
|
+
function deviceKeyFingerprint(publicKey) {
|
|
30552
|
+
return createHash6("sha256").update(publicKey, "utf8").digest("hex").slice(0, 16);
|
|
30553
|
+
}
|
|
30554
|
+
function fromPrivateKey(privateKey) {
|
|
30555
|
+
if (privateKey.asymmetricKeyType !== "ed25519") {
|
|
30556
|
+
throw new Error(
|
|
30557
|
+
`device key must be ed25519, got ${privateKey.asymmetricKeyType ?? "unknown"}`
|
|
30558
|
+
);
|
|
30559
|
+
}
|
|
30560
|
+
const publicKey = encodePublicKey(privateKey);
|
|
30561
|
+
return {
|
|
30562
|
+
privateKey,
|
|
30563
|
+
publicKey,
|
|
30564
|
+
fingerprint: deviceKeyFingerprint(publicKey),
|
|
30565
|
+
sign: (message2) => sign3(null, Buffer.from(message2, "utf8"), privateKey).toString("base64")
|
|
30566
|
+
};
|
|
30567
|
+
}
|
|
30568
|
+
function generateDeviceKey() {
|
|
30569
|
+
return fromPrivateKey(generateKeyPairSync("ed25519").privateKey);
|
|
30570
|
+
}
|
|
30571
|
+
function deviceKeyFromPem(pem2) {
|
|
30572
|
+
return fromPrivateKey(createPrivateKey(pem2));
|
|
30573
|
+
}
|
|
30574
|
+
function deviceKeyPem(key) {
|
|
30575
|
+
return key.privateKey.export({ type: "pkcs8", format: "pem" }).toString();
|
|
30576
|
+
}
|
|
30577
|
+
function loadOrCreateDeviceKey(path2) {
|
|
30578
|
+
try {
|
|
30579
|
+
return {
|
|
30580
|
+
key: deviceKeyFromPem(readFileSync10(path2, "utf8")),
|
|
30581
|
+
created: false
|
|
30582
|
+
};
|
|
30583
|
+
} catch (error2) {
|
|
30584
|
+
if (error2.code !== "ENOENT") throw error2;
|
|
30585
|
+
}
|
|
30586
|
+
const key = generateDeviceKey();
|
|
30587
|
+
writeSensitiveFileAtomic(path2, deviceKeyPem(key));
|
|
30588
|
+
return { key, created: true };
|
|
30589
|
+
}
|
|
30590
|
+
function credentialDigest(credential) {
|
|
30591
|
+
return createHash6("sha256").update(credential, "utf8").digest("hex");
|
|
30592
|
+
}
|
|
30593
|
+
function deviceKeyProofMessage(claims2) {
|
|
30594
|
+
return JSON.stringify([
|
|
30595
|
+
DEVICE_KEY_PROOF_DOMAIN,
|
|
30596
|
+
claims2.credentialDigest,
|
|
30597
|
+
claims2.devicePublicKey,
|
|
30598
|
+
claims2.hostname,
|
|
30599
|
+
claims2.osUser,
|
|
30600
|
+
claims2.platform,
|
|
30601
|
+
[...claims2.harnesses],
|
|
30602
|
+
claims2.signedAtUnixS
|
|
30603
|
+
]);
|
|
30604
|
+
}
|
|
30605
|
+
function signDeviceKeyProof(key, claims2) {
|
|
30606
|
+
return {
|
|
30607
|
+
signedAtUnixS: claims2.signedAtUnixS,
|
|
30608
|
+
signature: key.sign(
|
|
30609
|
+
deviceKeyProofMessage({ ...claims2, devicePublicKey: key.publicKey })
|
|
30610
|
+
)
|
|
30611
|
+
};
|
|
30612
|
+
}
|
|
30613
|
+
function verifyDeviceSignature(publicKey, message2, signatureBase64) {
|
|
30614
|
+
if (!publicKey.startsWith("ed25519:")) return false;
|
|
30615
|
+
const raw = Buffer.from(publicKey.slice("ed25519:".length), "base64");
|
|
30616
|
+
if (raw.length !== 32) return false;
|
|
30617
|
+
const spki = Buffer.concat([
|
|
30618
|
+
Buffer.from("302a300506032b6570032100", "hex"),
|
|
30619
|
+
raw
|
|
30620
|
+
]);
|
|
30621
|
+
try {
|
|
30622
|
+
return verify3(
|
|
30623
|
+
null,
|
|
30624
|
+
Buffer.from(message2, "utf8"),
|
|
30625
|
+
createPublicKey3({ key: spki, format: "der", type: "spki" }),
|
|
30626
|
+
Buffer.from(signatureBase64, "base64")
|
|
30627
|
+
);
|
|
30628
|
+
} catch {
|
|
30629
|
+
return false;
|
|
30630
|
+
}
|
|
30631
|
+
}
|
|
30632
|
+
var SPKI_ED25519_PREFIX_BYTES, DEVICE_KEY_PROOF_DOMAIN;
|
|
30633
|
+
var init_device_key = __esm({
|
|
30634
|
+
"../../packages/tacho/src/host/device-key.ts"() {
|
|
30635
|
+
"use strict";
|
|
30636
|
+
init_fs();
|
|
30637
|
+
SPKI_ED25519_PREFIX_BYTES = 12;
|
|
30638
|
+
DEVICE_KEY_PROOF_DOMAIN = "oxagen.tacho.device-key-proof.v1";
|
|
30639
|
+
}
|
|
30640
|
+
});
|
|
30641
|
+
|
|
30642
|
+
// ../../packages/tacho/src/host/request-signature.ts
|
|
30643
|
+
import { createHash as createHash7 } from "node:crypto";
|
|
30644
|
+
function bodySha256(body2) {
|
|
30645
|
+
return createHash7("sha256").update(body2).digest("hex");
|
|
30646
|
+
}
|
|
30647
|
+
function requestSignatureMessage(input2) {
|
|
30648
|
+
return JSON.stringify([
|
|
30649
|
+
REQUEST_SIGNATURE_DOMAIN,
|
|
30650
|
+
input2.method.toUpperCase(),
|
|
30651
|
+
input2.path,
|
|
30652
|
+
input2.signedAtUnixS,
|
|
30653
|
+
input2.bodySha256
|
|
30654
|
+
]);
|
|
30655
|
+
}
|
|
30656
|
+
function signRequest(key, input2) {
|
|
30657
|
+
return `v1 ts=${input2.signedAtUnixS} sig=${key.sign(requestSignatureMessage(input2))}`;
|
|
30658
|
+
}
|
|
30659
|
+
function parseRequestSignature(header2) {
|
|
30660
|
+
if (!header2) return void 0;
|
|
30661
|
+
const match = HEADER_PATTERN.exec(header2.trim());
|
|
30662
|
+
if (!match) return void 0;
|
|
30663
|
+
return { signedAtUnixS: Number(match[1]), signature: match[2] };
|
|
30664
|
+
}
|
|
30665
|
+
function verifyRequestSignature(devicePublicKey, header2, request4, nowUnixS, maxSkewS = REQUEST_SIGNATURE_MAX_SKEW_S) {
|
|
30666
|
+
if (!header2) return "missing";
|
|
30667
|
+
const parsed2 = parseRequestSignature(header2);
|
|
30668
|
+
if (parsed2 === void 0) return "malformed";
|
|
30669
|
+
if (Math.abs(nowUnixS - parsed2.signedAtUnixS) > maxSkewS) return "stale";
|
|
30670
|
+
const message2 = requestSignatureMessage({
|
|
30671
|
+
...request4,
|
|
30672
|
+
signedAtUnixS: parsed2.signedAtUnixS
|
|
30673
|
+
});
|
|
30674
|
+
return verifyDeviceSignature(devicePublicKey, message2, parsed2.signature) ? void 0 : "invalid";
|
|
30675
|
+
}
|
|
30676
|
+
function signedPathOf(url2) {
|
|
30677
|
+
const parsed2 = new URL(url2);
|
|
30678
|
+
return `${parsed2.pathname}${parsed2.search}`;
|
|
30679
|
+
}
|
|
30680
|
+
function deviceSignatureHeader(key, method, url2, body2, nowMs = Date.now()) {
|
|
30681
|
+
return {
|
|
30682
|
+
[REQUEST_SIGNATURE_HEADER]: signRequest(key, {
|
|
30683
|
+
method,
|
|
30684
|
+
path: signedPathOf(url2),
|
|
30685
|
+
bodySha256: bodySha256(body2),
|
|
30686
|
+
signedAtUnixS: Math.floor(nowMs / 1e3)
|
|
30687
|
+
})
|
|
30688
|
+
};
|
|
30689
|
+
}
|
|
30690
|
+
var REQUEST_SIGNATURE_HEADER, REQUEST_SIGNATURE_DOMAIN, REQUEST_SIGNATURE_MAX_SKEW_S, HEADER_PATTERN;
|
|
30691
|
+
var init_request_signature = __esm({
|
|
30692
|
+
"../../packages/tacho/src/host/request-signature.ts"() {
|
|
30693
|
+
"use strict";
|
|
30694
|
+
init_device_key();
|
|
30695
|
+
REQUEST_SIGNATURE_HEADER = "x-oxagen-device-signature";
|
|
30696
|
+
REQUEST_SIGNATURE_DOMAIN = "oxagen.tacho.request-signature.v1";
|
|
30697
|
+
REQUEST_SIGNATURE_MAX_SKEW_S = 300;
|
|
30698
|
+
HEADER_PATTERN = /^v1 ts=(\d{1,12}) sig=([A-Za-z0-9+/]+={0,2})$/;
|
|
30699
|
+
}
|
|
30700
|
+
});
|
|
30701
|
+
|
|
30702
|
+
// ../../packages/tacho/src/host/control-client.ts
|
|
30703
|
+
function parseRetryAfter(value, nowMs) {
|
|
30704
|
+
if (!value) return void 0;
|
|
30705
|
+
const seconds = Number(value);
|
|
30706
|
+
if (Number.isFinite(seconds)) return Math.max(0, seconds * 1e3);
|
|
30707
|
+
const at2 = Date.parse(value);
|
|
30708
|
+
return Number.isNaN(at2) ? void 0 : Math.max(0, at2 - nowMs);
|
|
30709
|
+
}
|
|
30710
|
+
function headerNumber(value) {
|
|
30711
|
+
if (value === null || value.trim().length === 0) return void 0;
|
|
30712
|
+
const parsed2 = Number(value);
|
|
30713
|
+
return Number.isFinite(parsed2) ? parsed2 : void 0;
|
|
30714
|
+
}
|
|
30715
|
+
function readRateLimitHint(headers, nowMs) {
|
|
30716
|
+
if (!headers) return void 0;
|
|
30717
|
+
const hint = {};
|
|
30718
|
+
const remaining = headerNumber(headers.get("x-ratelimit-remaining"));
|
|
30719
|
+
if (remaining !== void 0) hint.remaining = remaining;
|
|
30720
|
+
const reset = headerNumber(headers.get("x-ratelimit-reset"));
|
|
30721
|
+
if (reset !== void 0 && reset > 0) hint.resetAtMs = reset * 1e3;
|
|
30722
|
+
const retryAfter = parseRetryAfter(headers.get("retry-after"), nowMs);
|
|
30723
|
+
if (retryAfter !== void 0) hint.retryAfterMs = retryAfter;
|
|
30724
|
+
return Object.keys(hint).length > 0 ? hint : void 0;
|
|
30725
|
+
}
|
|
30726
|
+
function workOrderEndpointsFor(apiUrl) {
|
|
30727
|
+
const base2 = apiUrl.replace(/\/+$/, "");
|
|
30728
|
+
return {
|
|
30729
|
+
workOrderClaim: `${base2}${WORK_ORDER_CLAIM_PATH}`,
|
|
30730
|
+
workOrderReject: `${base2}${WORK_ORDER_REJECT_PATH}`,
|
|
30731
|
+
workCriterionClaim: `${base2}${WORK_CRITERION_CLAIM_PATH}`,
|
|
30732
|
+
workOrderChecklist: `${base2}${WORK_ORDER_CHECKLIST_PATH}`,
|
|
30733
|
+
workOrderProgress: `${base2}${WORK_ORDER_PROGRESS_PATH}`,
|
|
30734
|
+
certificate: `${base2}${CERTIFICATE_RENEW_PATH}`,
|
|
30735
|
+
enrollmentKeys: `${base2}${ENROLLMENT_KEYS_PATH}`,
|
|
30736
|
+
hostConnection: `${base2}${HOST_CONNECTION_PATH}`,
|
|
30737
|
+
modelCredentials: `${base2}${HOST_MODEL_CREDENTIALS_PATH}`,
|
|
30738
|
+
modelCredentialState: `${base2}${HOST_MODEL_CREDENTIAL_STATE_PATH}`,
|
|
30739
|
+
modelCredentialRefresh: `${base2}${HOST_MODEL_CREDENTIAL_REFRESH_PATH}`
|
|
30740
|
+
};
|
|
30741
|
+
}
|
|
30742
|
+
function createControlClient(options) {
|
|
30743
|
+
const fetchImpl = options.fetch ?? ((input2, init) => fetch(input2, init));
|
|
30744
|
+
const timeoutMs = options.timeoutMs ?? 15e3;
|
|
30745
|
+
const ingestTimeoutMs = options.ingestTimeoutMs ?? TACHO_INGEST_TIMEOUT_MS;
|
|
30746
|
+
const nowMs = options.now ?? Date.now;
|
|
30747
|
+
async function post3(url2, body2, boundMs = timeoutMs, method = "POST", extraHeaders = {}) {
|
|
30748
|
+
const controller = new AbortController();
|
|
30749
|
+
const timer = setTimeout(() => controller.abort(), boundMs);
|
|
30750
|
+
const signal = options.signal === void 0 ? controller.signal : AbortSignal.any([controller.signal, options.signal]);
|
|
30751
|
+
let response;
|
|
30752
|
+
let text6;
|
|
30753
|
+
try {
|
|
30754
|
+
const payload = method === "GET" ? "" : JSON.stringify(body2);
|
|
30755
|
+
response = await fetchImpl(url2, {
|
|
30756
|
+
method,
|
|
30757
|
+
headers: {
|
|
30758
|
+
...method === "GET" ? {} : { Authorization: `Bearer ${options.apiKey}` },
|
|
30759
|
+
"Content-Type": "application/json",
|
|
30760
|
+
"User-Agent": options.userAgent ?? "tachod",
|
|
30761
|
+
...extraHeaders,
|
|
30762
|
+
...options.deviceKey !== void 0 && method !== "GET" ? deviceSignatureHeader(
|
|
30763
|
+
options.deviceKey,
|
|
30764
|
+
method,
|
|
30765
|
+
url2,
|
|
30766
|
+
payload,
|
|
30767
|
+
nowMs()
|
|
30768
|
+
) : {}
|
|
30769
|
+
},
|
|
30770
|
+
...method === "GET" ? {} : { body: payload },
|
|
30771
|
+
signal
|
|
30772
|
+
});
|
|
30773
|
+
text6 = await response.text();
|
|
30774
|
+
} catch (error2) {
|
|
30775
|
+
throw new ControlUnreachable(error2, url2);
|
|
30776
|
+
} finally {
|
|
30777
|
+
clearTimeout(timer);
|
|
30778
|
+
}
|
|
30779
|
+
const hint = readRateLimitHint(response.headers, nowMs());
|
|
30780
|
+
if (hint) options.onRateLimit?.(hint);
|
|
30781
|
+
if (!response.ok)
|
|
30782
|
+
throw new ControlError(response.status, text6, void 0, hint);
|
|
30783
|
+
try {
|
|
30784
|
+
return JSON.parse(text6);
|
|
30785
|
+
} catch {
|
|
30786
|
+
throw new ControlError(
|
|
30787
|
+
response.status,
|
|
30788
|
+
text6,
|
|
30789
|
+
"control plane answered non-JSON",
|
|
30790
|
+
hint
|
|
30791
|
+
);
|
|
30792
|
+
}
|
|
30793
|
+
}
|
|
30794
|
+
function endpoint(url2, name2) {
|
|
30795
|
+
if (url2 === void 0)
|
|
30796
|
+
throw new Error(`the control client has no ${name2} endpoint`);
|
|
30797
|
+
return url2;
|
|
30798
|
+
}
|
|
30799
|
+
async function call2(url2, schema, body2, boundMs, method = "POST", extraHeaders) {
|
|
30800
|
+
const parsed2 = schema.safeParse(
|
|
30801
|
+
await post3(url2, body2, boundMs, method, extraHeaders)
|
|
30802
|
+
);
|
|
30803
|
+
if (!parsed2.success)
|
|
30804
|
+
throw new ControlAnswerUnreadable(url2, zodIssues(parsed2.error));
|
|
30805
|
+
return parsed2.data;
|
|
30806
|
+
}
|
|
30807
|
+
return {
|
|
30808
|
+
ingest: (events, daemon, bodies) => call2(
|
|
30809
|
+
options.endpoints.ingest,
|
|
30810
|
+
ingestResponseSchema,
|
|
30811
|
+
{
|
|
30812
|
+
schema: TACHO_BATCH_SCHEMA,
|
|
30813
|
+
host_enrollment_id: options.hostEnrollmentId,
|
|
30814
|
+
events,
|
|
30815
|
+
...bodies !== void 0 && bodies.length > 0 ? { bodies } : {},
|
|
30816
|
+
...daemon !== void 0 ? { daemon } : {}
|
|
30817
|
+
},
|
|
30818
|
+
ingestTimeoutMs
|
|
30819
|
+
),
|
|
30820
|
+
bundle: (etag, run3) => call2(options.endpoints.bundle, bundleResponseSchema, {
|
|
30821
|
+
host_enrollment_id: options.hostEnrollmentId,
|
|
30822
|
+
...etag !== void 0 ? { etag } : {},
|
|
30823
|
+
...run3?.remote !== void 0 ? { remote: run3.remote } : {},
|
|
30824
|
+
...run3?.harness !== void 0 ? { harness: run3.harness } : {}
|
|
30825
|
+
}),
|
|
30826
|
+
commands: (acknowledgements = [], daemon) => call2(options.endpoints.commands, commandsResponseSchema, {
|
|
30827
|
+
schema: TACHO_COMMANDS_SCHEMA,
|
|
30828
|
+
host_enrollment_id: options.hostEnrollmentId,
|
|
30829
|
+
acknowledgements,
|
|
30830
|
+
...daemon !== void 0 ? { daemon } : {}
|
|
30831
|
+
}),
|
|
30832
|
+
claimWorkOrder: async (workOrderId) => call2(
|
|
30833
|
+
endpoint(options.endpoints.workOrderClaim, "work order claim"),
|
|
30834
|
+
workOrderClaimResponseSchema,
|
|
30835
|
+
{
|
|
30836
|
+
host_enrollment_id: options.hostEnrollmentId,
|
|
30837
|
+
work_order_id: workOrderId
|
|
30838
|
+
}
|
|
30839
|
+
),
|
|
30840
|
+
rejectWorkOrder: async (workOrderId, reason4) => call2(
|
|
30841
|
+
endpoint(options.endpoints.workOrderReject, "work order refusal"),
|
|
30842
|
+
workOrderRejectResponseSchema,
|
|
30843
|
+
{
|
|
30844
|
+
host_enrollment_id: options.hostEnrollmentId,
|
|
30845
|
+
work_order_id: workOrderId,
|
|
30846
|
+
reason: reason4
|
|
30847
|
+
}
|
|
30848
|
+
),
|
|
30849
|
+
// An empty body: the server reads the host from the key, and the device
|
|
30850
|
+
// signature over the request proves the machine holds the key the
|
|
30851
|
+
// certificate names.
|
|
30852
|
+
renewCertificate: async () => call2(
|
|
30853
|
+
endpoint(options.endpoints.certificate, "certificate renewal"),
|
|
30854
|
+
certificateRenewalResponseSchema,
|
|
30855
|
+
{}
|
|
30856
|
+
),
|
|
30857
|
+
enrollmentKeys: async () => call2(
|
|
30858
|
+
endpoint(options.endpoints.enrollmentKeys, "enrollment keys"),
|
|
30859
|
+
enrollmentKeysResponseSchema,
|
|
30860
|
+
void 0,
|
|
30861
|
+
void 0,
|
|
30862
|
+
"GET"
|
|
30863
|
+
),
|
|
30864
|
+
setConnection: async (state) => call2(
|
|
30865
|
+
endpoint(options.endpoints.hostConnection, "workspace connection"),
|
|
30866
|
+
hostConnectionChangeResponseSchema,
|
|
30867
|
+
{ host_enrollment_id: options.hostEnrollmentId, state }
|
|
30868
|
+
),
|
|
30869
|
+
modelCredentials: async (harness) => call2(
|
|
30870
|
+
endpoint(options.endpoints.modelCredentials, "model credentials"),
|
|
30871
|
+
hostModelCredentialsResponseSchema,
|
|
30872
|
+
{ host_enrollment_id: options.hostEnrollmentId, harness }
|
|
30873
|
+
),
|
|
30874
|
+
reportModelCredential: async (credentialId, report) => call2(
|
|
30875
|
+
endpoint(
|
|
30876
|
+
options.endpoints.modelCredentialState,
|
|
30877
|
+
"model credential report"
|
|
30878
|
+
),
|
|
30879
|
+
hostModelCredentialStateResponseSchema,
|
|
30880
|
+
{
|
|
30881
|
+
host_enrollment_id: options.hostEnrollmentId,
|
|
30882
|
+
credential_id: credentialId,
|
|
30883
|
+
report
|
|
30884
|
+
}
|
|
30885
|
+
),
|
|
30886
|
+
refreshModelCredential: async (credentialId, refresh) => call2(
|
|
30887
|
+
endpoint(
|
|
30888
|
+
options.endpoints.modelCredentialRefresh,
|
|
30889
|
+
"model credential refresh"
|
|
30890
|
+
),
|
|
30891
|
+
hostModelCredentialRefreshResponseSchema,
|
|
30892
|
+
{
|
|
30893
|
+
host_enrollment_id: options.hostEnrollmentId,
|
|
30894
|
+
credential_id: credentialId,
|
|
30895
|
+
vault_changed_at: refresh.vault_changed_at,
|
|
30896
|
+
secret: refresh.secret
|
|
30897
|
+
}
|
|
30898
|
+
),
|
|
30899
|
+
// The body names exactly the contract's fields. It carries no enrollment
|
|
30900
|
+
// id: the server reads the host from the key. The run's token goes in a
|
|
30901
|
+
// header, so it stays out of the input the kernel hashes and audits.
|
|
30902
|
+
claimWorkCriterion: async (claim2, token) => call2(
|
|
30903
|
+
endpoint(options.endpoints.workCriterionClaim, "criterion claim"),
|
|
30904
|
+
workCriterionClaimResponseSchema,
|
|
30905
|
+
{
|
|
30906
|
+
item_id: claim2.item_id,
|
|
30907
|
+
work_order_id: claim2.work_order_id,
|
|
30908
|
+
criterion_id: claim2.criterion_id,
|
|
30909
|
+
head_sha: claim2.head_sha,
|
|
30910
|
+
text: claim2.text,
|
|
30911
|
+
status: claim2.status,
|
|
30912
|
+
evidence: claim2.evidence
|
|
30913
|
+
},
|
|
30914
|
+
void 0,
|
|
30915
|
+
"POST",
|
|
30916
|
+
{ [WORK_ORDER_TOKEN_HEADER]: token }
|
|
30917
|
+
),
|
|
30918
|
+
readWorkOrderChecklist: async (workOrderId, token) => call2(
|
|
30919
|
+
endpoint(options.endpoints.workOrderChecklist, "work order checklist"),
|
|
30920
|
+
workOrderChecklistResponseSchema,
|
|
30921
|
+
{
|
|
30922
|
+
host_enrollment_id: options.hostEnrollmentId,
|
|
30923
|
+
work_order_id: workOrderId
|
|
30924
|
+
},
|
|
30925
|
+
void 0,
|
|
30926
|
+
"POST",
|
|
30927
|
+
{ [WORK_ORDER_TOKEN_HEADER]: token }
|
|
30928
|
+
),
|
|
30929
|
+
// The body names exactly the contract's fields, and `ask` only when the
|
|
30930
|
+
// agent asked something. The token goes in a header, as for a claim.
|
|
30931
|
+
postWorkProgress: async (progress, token) => call2(
|
|
30932
|
+
endpoint(options.endpoints.workOrderProgress, "progress update"),
|
|
30933
|
+
workProgressResponseSchema,
|
|
30934
|
+
{
|
|
30935
|
+
work_order_id: progress.work_order_id,
|
|
30936
|
+
step: { n: progress.step.n, of: progress.step.of },
|
|
30937
|
+
changed: progress.changed,
|
|
30938
|
+
passed: progress.passed,
|
|
30939
|
+
next: progress.next,
|
|
30940
|
+
...progress.ask !== void 0 ? { ask: progress.ask } : {}
|
|
30941
|
+
},
|
|
30942
|
+
void 0,
|
|
30943
|
+
"POST",
|
|
30944
|
+
{ [WORK_ORDER_TOKEN_HEADER]: token }
|
|
30945
|
+
)
|
|
30946
|
+
};
|
|
30947
|
+
}
|
|
30948
|
+
function controlErrorMessage(error2) {
|
|
30949
|
+
try {
|
|
30950
|
+
const body2 = JSON.parse(error2.body);
|
|
30951
|
+
if (typeof body2 === "object" && body2 !== null) {
|
|
30952
|
+
const inner = body2["error"];
|
|
30953
|
+
if (typeof inner === "object" && inner !== null) {
|
|
30954
|
+
const message3 = inner["message"];
|
|
30955
|
+
if (typeof message3 === "string" && message3.length > 0) return message3;
|
|
30956
|
+
}
|
|
30957
|
+
const message2 = body2["message"];
|
|
30958
|
+
if (typeof message2 === "string" && message2.length > 0) return message2;
|
|
30959
|
+
}
|
|
30960
|
+
} catch {
|
|
30961
|
+
}
|
|
30962
|
+
return `Oxagen answered ${error2.status}.`;
|
|
30963
|
+
}
|
|
30964
|
+
function controlErrorReason(error2) {
|
|
30965
|
+
try {
|
|
30966
|
+
const body2 = JSON.parse(error2.body);
|
|
30967
|
+
if (typeof body2 === "object" && body2 !== null) {
|
|
30968
|
+
const inner = body2["error"];
|
|
30969
|
+
if (typeof inner === "object" && inner !== null) {
|
|
30970
|
+
const reason4 = inner["reason"];
|
|
30971
|
+
if (typeof reason4 === "string" && reason4.length > 0) return reason4;
|
|
30972
|
+
}
|
|
30973
|
+
}
|
|
30974
|
+
} catch {
|
|
30975
|
+
}
|
|
30976
|
+
return void 0;
|
|
30977
|
+
}
|
|
30978
|
+
var TACHO_INGEST_TIMEOUT_MS, ControlError, ControlUnreachable, ControlAnswerUnreadable;
|
|
30979
|
+
var init_control_client = __esm({
|
|
30980
|
+
"../../packages/tacho/src/host/control-client.ts"() {
|
|
30981
|
+
"use strict";
|
|
30982
|
+
init_schema();
|
|
30983
|
+
init_request_signature();
|
|
30984
|
+
init_wire();
|
|
30985
|
+
TACHO_INGEST_TIMEOUT_MS = 6e4;
|
|
30986
|
+
ControlError = class extends Error {
|
|
30987
|
+
status;
|
|
30988
|
+
body;
|
|
30989
|
+
/**
|
|
30990
|
+
* What the server said about waiting, when it said anything. Carried on the
|
|
30991
|
+
* error so the Shipper can honour a 429's `Retry-After` instead of doubling
|
|
30992
|
+
* its own backoff past the window the server actually named.
|
|
30993
|
+
*/
|
|
30994
|
+
rateLimit;
|
|
30995
|
+
constructor(status2, body2, message2, rateLimit) {
|
|
30996
|
+
super(message2 ?? `control plane answered ${status2}: ${body2.slice(0, 256)}`);
|
|
30997
|
+
this.name = "ControlError";
|
|
30998
|
+
this.status = status2;
|
|
30999
|
+
this.body = body2;
|
|
31000
|
+
this.rateLimit = rateLimit;
|
|
31001
|
+
}
|
|
31002
|
+
};
|
|
31003
|
+
ControlUnreachable = class extends Error {
|
|
31004
|
+
/** The endpoint the request was for, when the caller named it. */
|
|
31005
|
+
url;
|
|
31006
|
+
constructor(cause, url2) {
|
|
31007
|
+
super(
|
|
31008
|
+
`control plane unreachable${url2 === void 0 ? "" : ` at ${url2}`}: ${cause instanceof Error ? cause.message : String(cause)}`,
|
|
31009
|
+
{ cause }
|
|
31010
|
+
);
|
|
31011
|
+
this.name = "ControlUnreachable";
|
|
31012
|
+
this.url = url2;
|
|
31013
|
+
}
|
|
31014
|
+
};
|
|
31015
|
+
ControlAnswerUnreadable = class extends Error {
|
|
31016
|
+
url;
|
|
31017
|
+
constructor(url2, issues) {
|
|
31018
|
+
super(
|
|
31019
|
+
`control plane answered ${url2} in a shape this host does not read: ${issues}`
|
|
31020
|
+
);
|
|
31021
|
+
this.name = "ControlAnswerUnreadable";
|
|
31022
|
+
this.url = url2;
|
|
31023
|
+
}
|
|
31024
|
+
};
|
|
31025
|
+
}
|
|
31026
|
+
});
|
|
31027
|
+
|
|
31028
|
+
// ../../packages/tacho/src/host/login-write-back.ts
|
|
31029
|
+
function statusRetryable(status2) {
|
|
31030
|
+
return status2 === 408 || status2 === 429 || status2 >= 500 || status2 < 400;
|
|
31031
|
+
}
|
|
31032
|
+
function nameOf(login) {
|
|
31033
|
+
return login.hint !== void 0 ? `\u2026${login.hint}` : login.credential_id;
|
|
31034
|
+
}
|
|
31035
|
+
function messageOf2(error2) {
|
|
31036
|
+
return error2 instanceof Error ? error2.message : String(error2);
|
|
31037
|
+
}
|
|
31038
|
+
function describeOwedLogin(left) {
|
|
31039
|
+
return `the saved ChatGPT login ${left.name} (${left.credential_id}): ${left.detail}`;
|
|
31040
|
+
}
|
|
31041
|
+
async function writeBackOwedLogins(deps, gate) {
|
|
31042
|
+
const report = { stored: [], superseded: [], owed: [] };
|
|
31043
|
+
let owed;
|
|
31044
|
+
try {
|
|
31045
|
+
owed = deps.store.owedLogins();
|
|
31046
|
+
} catch (error2) {
|
|
31047
|
+
report.unreadable = messageOf2(error2);
|
|
31048
|
+
return report;
|
|
31049
|
+
}
|
|
31050
|
+
for (const login of owed) {
|
|
31051
|
+
const left = (detail, retryable) => ({
|
|
31052
|
+
provider: login.provider,
|
|
31053
|
+
harness: login.harness,
|
|
31054
|
+
credential_id: login.credential_id,
|
|
31055
|
+
name: nameOf(login),
|
|
31056
|
+
detail,
|
|
31057
|
+
retryable
|
|
31058
|
+
});
|
|
31059
|
+
const waiting2 = gate?.waiting(login);
|
|
31060
|
+
if (waiting2 !== void 0) {
|
|
31061
|
+
report.owed.push(waiting2);
|
|
31062
|
+
continue;
|
|
31063
|
+
}
|
|
31064
|
+
const keep = (owedLeft) => {
|
|
31065
|
+
report.owed.push(owedLeft);
|
|
31066
|
+
gate?.sent(login, owedLeft);
|
|
31067
|
+
deps.log(
|
|
31068
|
+
`saved login write-back: Oxagen does not hold ${describeOwedLogin(owedLeft)}`
|
|
31069
|
+
);
|
|
31070
|
+
};
|
|
31071
|
+
let secret;
|
|
31072
|
+
try {
|
|
31073
|
+
const held = deps.store.open(login.provider, login.harness, login.id);
|
|
31074
|
+
if (held === void 0 || held.kind !== "chatgpt") continue;
|
|
31075
|
+
secret = held.secret;
|
|
31076
|
+
} catch (error2) {
|
|
31077
|
+
keep(left(`custody could not be read (${messageOf2(error2)})`, true));
|
|
31078
|
+
continue;
|
|
31079
|
+
}
|
|
31080
|
+
let outcome;
|
|
31081
|
+
let changedAt;
|
|
31082
|
+
try {
|
|
31083
|
+
const answer = await deps.client.refreshModelCredential(
|
|
31084
|
+
login.credential_id,
|
|
31085
|
+
{ vault_changed_at: login.vault_changed_at, secret }
|
|
31086
|
+
);
|
|
31087
|
+
outcome = answer.outcome;
|
|
31088
|
+
changedAt = answer.changed_at;
|
|
31089
|
+
} catch (error2) {
|
|
31090
|
+
if (error2 instanceof ControlError)
|
|
31091
|
+
keep(
|
|
31092
|
+
left(
|
|
31093
|
+
`Oxagen answered ${error2.status}: ${controlErrorMessage(error2)}`,
|
|
31094
|
+
statusRetryable(error2.status)
|
|
31095
|
+
)
|
|
31096
|
+
);
|
|
31097
|
+
else if (error2 instanceof ControlUnreachable)
|
|
31098
|
+
keep(left("Oxagen could not be reached", true));
|
|
31099
|
+
else if (error2 instanceof ControlAnswerUnreadable)
|
|
31100
|
+
keep(left("Oxagen answered in a shape this build does not read", true));
|
|
31101
|
+
else keep(left(`the request failed (${messageOf2(error2)})`, true));
|
|
31102
|
+
continue;
|
|
31103
|
+
}
|
|
31104
|
+
const refreshedAgain = () => deps.store.owedLogins().some(
|
|
31105
|
+
(o) => o.provider === login.provider && o.harness === login.harness && o.id === login.id && o.refreshed_at !== login.refreshed_at
|
|
31106
|
+
);
|
|
31107
|
+
const owedNewer = () => {
|
|
31108
|
+
const owedLeft = left(
|
|
31109
|
+
"it was refreshed again while the earlier tokens were sent, and the newer tokens go on the next pass",
|
|
31110
|
+
true
|
|
31111
|
+
);
|
|
31112
|
+
report.owed.push(owedLeft);
|
|
31113
|
+
gate?.sent(login, void 0);
|
|
31114
|
+
deps.log(
|
|
31115
|
+
`saved login write-back: Oxagen does not hold ${describeOwedLogin(owedLeft)}`
|
|
31116
|
+
);
|
|
31117
|
+
};
|
|
31118
|
+
try {
|
|
31119
|
+
if ((outcome === "stored" || outcome === "already_stored") && changedAt !== null) {
|
|
31120
|
+
const settled2 = deps.store.settleWriteBack(
|
|
31121
|
+
login.provider,
|
|
31122
|
+
login.harness,
|
|
31123
|
+
login.id,
|
|
31124
|
+
login.refreshed_at,
|
|
31125
|
+
{ state: "stored", changedAt }
|
|
31126
|
+
);
|
|
31127
|
+
if (!settled2 && refreshedAgain()) {
|
|
31128
|
+
owedNewer();
|
|
31129
|
+
continue;
|
|
31130
|
+
}
|
|
31131
|
+
report.stored.push(login.credential_id);
|
|
31132
|
+
gate?.sent(login, void 0);
|
|
31133
|
+
continue;
|
|
31134
|
+
}
|
|
31135
|
+
if (SUPERSEDED_OUTCOMES.has(outcome)) {
|
|
31136
|
+
const settled2 = deps.store.settleWriteBack(
|
|
31137
|
+
login.provider,
|
|
31138
|
+
login.harness,
|
|
31139
|
+
login.id,
|
|
31140
|
+
login.refreshed_at,
|
|
31141
|
+
{ state: "refused" }
|
|
31142
|
+
);
|
|
31143
|
+
if (!settled2 && refreshedAgain()) {
|
|
31144
|
+
owedNewer();
|
|
31145
|
+
continue;
|
|
31146
|
+
}
|
|
31147
|
+
report.superseded.push({
|
|
31148
|
+
credential_id: login.credential_id,
|
|
31149
|
+
outcome
|
|
31150
|
+
});
|
|
31151
|
+
gate?.sent(login, void 0);
|
|
31152
|
+
deps.log(
|
|
31153
|
+
`saved login write-back: Oxagen kept its own copy of the saved ChatGPT login ${nameOf(login)} (${login.credential_id}): ${outcome}. The next pool sync takes that copy`
|
|
31154
|
+
);
|
|
31155
|
+
continue;
|
|
31156
|
+
}
|
|
31157
|
+
} catch (error2) {
|
|
31158
|
+
keep(left(`custody could not be written (${messageOf2(error2)})`, true));
|
|
31159
|
+
continue;
|
|
31160
|
+
}
|
|
31161
|
+
keep(
|
|
31162
|
+
left(
|
|
31163
|
+
`Oxagen answered "${outcome.slice(0, 64)}", which this build does not read`,
|
|
31164
|
+
true
|
|
31165
|
+
)
|
|
31166
|
+
);
|
|
31167
|
+
}
|
|
31168
|
+
try {
|
|
31169
|
+
const listed = new Set(report.owed.map(slotKeyOf));
|
|
31170
|
+
for (const login of deps.store.owedLogins()) {
|
|
31171
|
+
if (listed.has(slotKeyOf(login))) continue;
|
|
31172
|
+
report.owed.push({
|
|
31173
|
+
provider: login.provider,
|
|
31174
|
+
harness: login.harness,
|
|
31175
|
+
credential_id: login.credential_id,
|
|
31176
|
+
name: nameOf(login),
|
|
31177
|
+
detail: "it was refreshed while this pass ran, and the next pass sends it",
|
|
31178
|
+
retryable: true
|
|
31179
|
+
});
|
|
31180
|
+
}
|
|
31181
|
+
} catch {
|
|
31182
|
+
}
|
|
31183
|
+
return report;
|
|
31184
|
+
}
|
|
31185
|
+
function slotKeyOf(login) {
|
|
31186
|
+
return `${login.provider}\0${login.harness}\0${login.credential_id}`;
|
|
31187
|
+
}
|
|
31188
|
+
function owedWithNoSender(store, detail, retryable = false) {
|
|
31189
|
+
const report = { stored: [], superseded: [], owed: [] };
|
|
31190
|
+
try {
|
|
31191
|
+
for (const login of store.owedLogins())
|
|
31192
|
+
report.owed.push({
|
|
31193
|
+
provider: login.provider,
|
|
31194
|
+
harness: login.harness,
|
|
31195
|
+
credential_id: login.credential_id,
|
|
31196
|
+
name: nameOf(login),
|
|
31197
|
+
detail,
|
|
31198
|
+
retryable
|
|
31199
|
+
});
|
|
31200
|
+
} catch (error2) {
|
|
31201
|
+
report.unreadable = messageOf2(error2);
|
|
31202
|
+
}
|
|
31203
|
+
return report;
|
|
31204
|
+
}
|
|
31205
|
+
function createLoginWriteBack(deps) {
|
|
31206
|
+
const failed5 = /* @__PURE__ */ new Map();
|
|
31207
|
+
const gate = {
|
|
31208
|
+
waiting: (login) => {
|
|
31209
|
+
const last = failed5.get(login.credential_id);
|
|
31210
|
+
if (last === void 0 || last.refreshedAt !== login.refreshed_at)
|
|
31211
|
+
return void 0;
|
|
31212
|
+
return deps.now() < last.nextAt ? last.left : void 0;
|
|
31213
|
+
},
|
|
31214
|
+
sent: (login, left) => {
|
|
31215
|
+
if (left === void 0) {
|
|
31216
|
+
failed5.delete(login.credential_id);
|
|
31217
|
+
return;
|
|
31218
|
+
}
|
|
31219
|
+
const last = failed5.get(login.credential_id);
|
|
31220
|
+
const count15 = last !== void 0 && last.refreshedAt === login.refreshed_at ? last.count + 1 : 1;
|
|
31221
|
+
failed5.set(login.credential_id, {
|
|
31222
|
+
refreshedAt: login.refreshed_at,
|
|
31223
|
+
count: count15,
|
|
31224
|
+
nextAt: deps.now() + Math.min(
|
|
31225
|
+
WRITE_BACK_RETRY_MS * 2 ** (count15 - 1),
|
|
31226
|
+
WRITE_BACK_RETRY_MAX_MS
|
|
31227
|
+
),
|
|
31228
|
+
left
|
|
31229
|
+
});
|
|
31230
|
+
}
|
|
31231
|
+
};
|
|
31232
|
+
let running;
|
|
31233
|
+
return {
|
|
31234
|
+
drain: () => {
|
|
31235
|
+
running ??= writeBackOwedLogins(deps, gate).catch(
|
|
31236
|
+
(error2) => ({
|
|
31237
|
+
stored: [],
|
|
31238
|
+
superseded: [],
|
|
31239
|
+
owed: [],
|
|
31240
|
+
unreadable: messageOf2(error2)
|
|
31241
|
+
})
|
|
31242
|
+
).finally(() => {
|
|
31243
|
+
running = void 0;
|
|
31244
|
+
});
|
|
31245
|
+
return running;
|
|
31246
|
+
}
|
|
31247
|
+
};
|
|
31248
|
+
}
|
|
31249
|
+
function owedIn(report, slot) {
|
|
31250
|
+
return slot === void 0 ? report.owed : report.owed.filter(
|
|
31251
|
+
(left) => left.provider === slot.provider && left.harness === slot.harness
|
|
31252
|
+
);
|
|
31253
|
+
}
|
|
31254
|
+
var SUPERSEDED_OUTCOMES, WRITE_BACK_RETRY_MS, WRITE_BACK_RETRY_MAX_MS;
|
|
31255
|
+
var init_login_write_back = __esm({
|
|
31256
|
+
"../../packages/tacho/src/host/login-write-back.ts"() {
|
|
31257
|
+
"use strict";
|
|
31258
|
+
init_control_client();
|
|
31259
|
+
SUPERSEDED_OUTCOMES = /* @__PURE__ */ new Set([
|
|
31260
|
+
"changed_elsewhere",
|
|
31261
|
+
"different_account",
|
|
31262
|
+
"not_found"
|
|
31263
|
+
]);
|
|
31264
|
+
WRITE_BACK_RETRY_MS = 6e4;
|
|
31265
|
+
WRITE_BACK_RETRY_MAX_MS = 15 * 6e4;
|
|
31266
|
+
}
|
|
31267
|
+
});
|
|
31268
|
+
|
|
30086
31269
|
// ../../packages/tacho/src/host/model-base-url-toml.ts
|
|
30087
31270
|
function splitLines(text6) {
|
|
30088
31271
|
const lines = [];
|
|
@@ -30208,7 +31391,7 @@ var init_model_base_url_toml = __esm({
|
|
|
30208
31391
|
});
|
|
30209
31392
|
|
|
30210
31393
|
// ../../packages/tacho/src/host/model-base-url.ts
|
|
30211
|
-
import { chmodSync as chmodSync3, existsSync as existsSync9, readFileSync as
|
|
31394
|
+
import { chmodSync as chmodSync3, existsSync as existsSync9, readFileSync as readFileSync11, unlinkSync as unlinkSync6 } from "node:fs";
|
|
30212
31395
|
import { basename as basename4, dirname as dirname12, join as join18 } from "node:path";
|
|
30213
31396
|
function claudeToolSearchEnabled(value) {
|
|
30214
31397
|
return typeof value === "string" && /^(true|auto(:\d+)?)$/i.test(value);
|
|
@@ -30586,7 +31769,7 @@ function describe3(harness, options, { changed, text: text6, sidecar, unreadable
|
|
|
30586
31769
|
}
|
|
30587
31770
|
function readBytesIfExists(path2) {
|
|
30588
31771
|
try {
|
|
30589
|
-
return
|
|
31772
|
+
return readFileSync11(path2);
|
|
30590
31773
|
} catch (error2) {
|
|
30591
31774
|
if (error2.code === "ENOENT") return void 0;
|
|
30592
31775
|
throw error2;
|
|
@@ -31751,6 +32934,41 @@ function harnessDirsOf(deps) {
|
|
|
31751
32934
|
stellaHome: dirname13(deps.paths.stellaToml)
|
|
31752
32935
|
};
|
|
31753
32936
|
}
|
|
32937
|
+
async function owedBeforeRelease(deps, slot) {
|
|
32938
|
+
const store = deps.credentialStore;
|
|
32939
|
+
if (store === void 0) return [];
|
|
32940
|
+
try {
|
|
32941
|
+
const owes = store.owedLogins().some(
|
|
32942
|
+
(login) => slot === void 0 || login.provider === slot.provider && login.harness === slot.harness
|
|
32943
|
+
);
|
|
32944
|
+
if (!owes) return [];
|
|
32945
|
+
} catch {
|
|
32946
|
+
return [];
|
|
32947
|
+
}
|
|
32948
|
+
let report;
|
|
32949
|
+
if (deps.writeBackLogins === void 0)
|
|
32950
|
+
report = owedWithNoSender(
|
|
32951
|
+
store,
|
|
32952
|
+
"this command has no way to send it to Oxagen"
|
|
32953
|
+
);
|
|
32954
|
+
else
|
|
32955
|
+
try {
|
|
32956
|
+
report = await deps.writeBackLogins();
|
|
32957
|
+
} catch (error2) {
|
|
32958
|
+
report = owedWithNoSender(
|
|
32959
|
+
store,
|
|
32960
|
+
`the write-back did not run (${error2 instanceof Error ? error2.message : String(error2)})`,
|
|
32961
|
+
true
|
|
32962
|
+
);
|
|
32963
|
+
}
|
|
32964
|
+
return owedIn(report, slot);
|
|
32965
|
+
}
|
|
32966
|
+
function lostLoginWarning(lost) {
|
|
32967
|
+
return `Oxagen does not hold ${describeOwedLogin(lost)}. This machine cannot send it, so the tokens it refreshed are deleted with the store. Sign in to that ChatGPT account again from the Oxagen app`;
|
|
32968
|
+
}
|
|
32969
|
+
function owedList(owed) {
|
|
32970
|
+
return owed.map(describeOwedLogin).join("; ");
|
|
32971
|
+
}
|
|
31754
32972
|
function parseCredentialMode(value) {
|
|
31755
32973
|
if (value === void 0 || value.length === 0) return "brokered";
|
|
31756
32974
|
if (CREDENTIAL_MODES.includes(value))
|
|
@@ -32013,6 +33231,7 @@ async function brokerCredentials(host, harnesses, deps) {
|
|
|
32013
33231
|
return { harnesses: [], taken: [], warnings };
|
|
32014
33232
|
const helperCommand = deps.runtime.credentialHelperCommand;
|
|
32015
33233
|
const dirs = harnessDirsOf(deps);
|
|
33234
|
+
await owedBeforeRelease(deps);
|
|
32016
33235
|
if (targets.includes("codex") && codexHoldsTakenChatGptLogin(deps.home, dirs)) {
|
|
32017
33236
|
let held;
|
|
32018
33237
|
try {
|
|
@@ -32032,10 +33251,20 @@ async function brokerCredentials(host, harnesses, deps) {
|
|
|
32032
33251
|
if (targets.includes("codex") && codexHoldsOwnChatGptLogin(deps.home, dirs)) {
|
|
32033
33252
|
try {
|
|
32034
33253
|
if (store.read("openai", "codex")?.kind === "chatgpt") {
|
|
32035
|
-
|
|
32036
|
-
|
|
32037
|
-
|
|
32038
|
-
);
|
|
33254
|
+
const owed = await owedBeforeRelease(deps, {
|
|
33255
|
+
provider: "openai",
|
|
33256
|
+
harness: "codex"
|
|
33257
|
+
});
|
|
33258
|
+
if (owed.length > 0) {
|
|
33259
|
+
warnings.push(
|
|
33260
|
+
`kept the gateway's copy of Codex's ChatGPT login, because dropping it would also drop the only working tokens of ${owedList(owed)}. The daemon sends them again and then drops the copy`
|
|
33261
|
+
);
|
|
33262
|
+
} else {
|
|
33263
|
+
store.release("openai", "codex");
|
|
33264
|
+
warnings.push(
|
|
33265
|
+
"dropped the gateway's copy of Codex's ChatGPT login; Codex keeps its own"
|
|
33266
|
+
);
|
|
33267
|
+
}
|
|
32039
33268
|
}
|
|
32040
33269
|
} catch (error2) {
|
|
32041
33270
|
warnings.push(
|
|
@@ -32126,9 +33355,22 @@ async function brokerCredentials(host, harnesses, deps) {
|
|
|
32126
33355
|
staticTokens
|
|
32127
33356
|
});
|
|
32128
33357
|
} catch (error2) {
|
|
32129
|
-
|
|
33358
|
+
const kept = [];
|
|
33359
|
+
for (const { provider, harness } of takenNow) {
|
|
33360
|
+
const owed = await owedBeforeRelease(deps, { provider, harness });
|
|
33361
|
+
if (owed.length > 0) {
|
|
33362
|
+
kept.push(
|
|
33363
|
+
`custody keeps ${TACHO_HARNESS_LABELS[harness]}'s ${provider} credential, because giving it up would also drop the only working tokens of ${owedList(owed)}`
|
|
33364
|
+
);
|
|
33365
|
+
continue;
|
|
33366
|
+
}
|
|
32130
33367
|
store.release(provider, harness);
|
|
32131
|
-
|
|
33368
|
+
}
|
|
33369
|
+
if (kept.length === 0) throw error2;
|
|
33370
|
+
throw new Error(
|
|
33371
|
+
`${error2 instanceof Error ? error2.message : String(error2)}; ${kept.join("; ")}. Run \`oxagen agent enroll\` again once Oxagen is reachable`,
|
|
33372
|
+
{ cause: error2 }
|
|
33373
|
+
);
|
|
32132
33374
|
}
|
|
32133
33375
|
for (const taken of state.taken) {
|
|
32134
33376
|
if (offered.has(taken.harness)) continue;
|
|
@@ -32165,6 +33407,13 @@ async function brokerCredentials(host, harnesses, deps) {
|
|
|
32165
33407
|
}
|
|
32166
33408
|
const at2 = takenNow.findIndex((t) => t.harness === harness);
|
|
32167
33409
|
if (at2 >= 0 && store.has(provider, harness)) {
|
|
33410
|
+
const owed = await owedBeforeRelease(deps, { provider, harness });
|
|
33411
|
+
if (owed.length > 0) {
|
|
33412
|
+
warnings.push(
|
|
33413
|
+
`${TACHO_HARNESS_LABELS[harness]} keeps its own credential (${entry2.reason ?? "not brokered"}), and custody keeps its copy, because giving it up would also drop the only working tokens of ${owedList(owed)}. Run \`oxagen agent enroll\` again once Oxagen is reachable`
|
|
33414
|
+
);
|
|
33415
|
+
continue;
|
|
33416
|
+
}
|
|
32168
33417
|
const released = store.release(provider, harness);
|
|
32169
33418
|
takenNow.splice(at2, 1);
|
|
32170
33419
|
const offer = offered.get(harness);
|
|
@@ -32192,10 +33441,27 @@ async function restoreCredentials(host, deps, mode = "unenroll", only) {
|
|
|
32192
33441
|
const failed5 = [];
|
|
32193
33442
|
const warnings = [];
|
|
32194
33443
|
let custodyUnreadable = false;
|
|
33444
|
+
const owed = [];
|
|
32195
33445
|
const contract = deps.modelCredentials;
|
|
32196
33446
|
const store = deps.credentialStore;
|
|
32197
33447
|
if (contract === void 0)
|
|
32198
|
-
return { restored, failed: failed5, warnings, custodyUnreadable };
|
|
33448
|
+
return { restored, failed: failed5, warnings, custodyUnreadable, owed };
|
|
33449
|
+
if (mode === "unenroll") {
|
|
33450
|
+
const left = await owedBeforeRelease(deps);
|
|
33451
|
+
const waiting2 = left.filter((login) => login.retryable);
|
|
33452
|
+
if (waiting2.length > 0)
|
|
33453
|
+
return {
|
|
33454
|
+
restored,
|
|
33455
|
+
failed: failed5,
|
|
33456
|
+
warnings,
|
|
33457
|
+
custodyUnreadable,
|
|
33458
|
+
owed: waiting2.map(describeOwedLogin)
|
|
33459
|
+
};
|
|
33460
|
+
for (const lost of left) warnings.push(lostLoginWarning(lost));
|
|
33461
|
+
}
|
|
33462
|
+
const releaseSlot = (provider, harness) => {
|
|
33463
|
+
store?.release(provider, harness, { keepOwed: mode === "unenroll" });
|
|
33464
|
+
};
|
|
32199
33465
|
const helperCommand = deps.runtime.credentialHelperCommand;
|
|
32200
33466
|
const heldElsewhere = harnessesHeldElsewhere(deps.paths, deps.paths.dir);
|
|
32201
33467
|
for (const harness of MODEL_CREDENTIAL_HARNESSES) {
|
|
@@ -32219,11 +33485,28 @@ async function restoreCredentials(host, deps, mode = "unenroll", only) {
|
|
|
32219
33485
|
fromLogin = store?.status().some(
|
|
32220
33486
|
(c) => c.provider === provider && c.harness === harness && c.source === "claude:setup-token"
|
|
32221
33487
|
) === true;
|
|
32222
|
-
if (fromLogin) store?.
|
|
32223
|
-
else released = store?.read(provider, harness);
|
|
33488
|
+
if (!fromLogin) released = store?.read(provider, harness);
|
|
32224
33489
|
} catch (error2) {
|
|
32225
33490
|
unreadable = error2 instanceof Error ? error2.message : String(error2);
|
|
32226
33491
|
}
|
|
33492
|
+
const givesLoginBack = released?.kind === "chatgpt";
|
|
33493
|
+
if (mode === "passthrough" && unreadable === void 0 && !givesLoginBack) {
|
|
33494
|
+
const left = await owedBeforeRelease(deps, { provider, harness });
|
|
33495
|
+
if (left.length > 0) {
|
|
33496
|
+
owed.push(...left.map(describeOwedLogin));
|
|
33497
|
+
failed5.push(
|
|
33498
|
+
`${label} keeps its run token, because giving its ${provider} credential back would also drop the only working tokens of ${owedList(left)}. Run the command again once Oxagen is reachable`
|
|
33499
|
+
);
|
|
33500
|
+
continue;
|
|
33501
|
+
}
|
|
33502
|
+
}
|
|
33503
|
+
if (fromLogin && unreadable === void 0) {
|
|
33504
|
+
try {
|
|
33505
|
+
store?.release(provider, harness);
|
|
33506
|
+
} catch (error2) {
|
|
33507
|
+
unreadable = error2 instanceof Error ? error2.message : String(error2);
|
|
33508
|
+
}
|
|
33509
|
+
}
|
|
32227
33510
|
if (unreadable !== void 0) {
|
|
32228
33511
|
custodyUnreadable = true;
|
|
32229
33512
|
if (mode === "passthrough") {
|
|
@@ -32249,11 +33532,21 @@ async function restoreCredentials(host, deps, mode = "unenroll", only) {
|
|
|
32249
33532
|
if (entry2.changed) restored.push(entry2.file);
|
|
32250
33533
|
if (released === void 0) continue;
|
|
32251
33534
|
if (entry2.secretRestored === true) {
|
|
32252
|
-
|
|
33535
|
+
if (mode === "passthrough") {
|
|
33536
|
+
const left = await owedBeforeRelease(deps, { provider, harness });
|
|
33537
|
+
if (left.length > 0) {
|
|
33538
|
+
owed.push(...left.map(describeOwedLogin));
|
|
33539
|
+
warnings.push(
|
|
33540
|
+
givesLoginBack ? `${entry2.file} holds Codex's ChatGPT login again, and custody keeps its copy, because dropping it would also drop the only working tokens of ${owedList(left)}. The daemon sends them again and then drops the copy` : `${entry2.file} holds ${label}'s ${provider} credential again, and custody keeps its slot, because dropping it would also drop the only working tokens of ${owedList(left)}. The daemon sends them again`
|
|
33541
|
+
);
|
|
33542
|
+
continue;
|
|
33543
|
+
}
|
|
33544
|
+
}
|
|
33545
|
+
releaseSlot(provider, harness);
|
|
32253
33546
|
continue;
|
|
32254
33547
|
}
|
|
32255
33548
|
if (mode === "unenroll") {
|
|
32256
|
-
|
|
33549
|
+
releaseSlot(provider, harness);
|
|
32257
33550
|
warnings.push(
|
|
32258
33551
|
`${entry2.file} already holds a ${provider} credential of its own, so the older one the gateway held was not written back and is discarded with the store`
|
|
32259
33552
|
);
|
|
@@ -32267,7 +33560,7 @@ async function restoreCredentials(host, deps, mode = "unenroll", only) {
|
|
|
32267
33560
|
failed5.push(error2 instanceof Error ? error2.message : String(error2));
|
|
32268
33561
|
}
|
|
32269
33562
|
}
|
|
32270
|
-
return { restored, failed: failed5, warnings, custodyUnreadable };
|
|
33563
|
+
return { restored, failed: failed5, warnings, custodyUnreadable, owed };
|
|
32271
33564
|
}
|
|
32272
33565
|
async function acquireSubscriptionToken(options, deps) {
|
|
32273
33566
|
const io = deps.subscriptionLogin;
|
|
@@ -32456,6 +33749,7 @@ var init_credential = __esm({
|
|
|
32456
33749
|
init_zod();
|
|
32457
33750
|
init_claude_setup_token();
|
|
32458
33751
|
init_credential_store();
|
|
33752
|
+
init_login_write_back();
|
|
32459
33753
|
init_host_file();
|
|
32460
33754
|
init_model_credential();
|
|
32461
33755
|
init_agents();
|
|
@@ -32731,7 +34025,7 @@ import { join as join20 } from "node:path";
|
|
|
32731
34025
|
import {
|
|
32732
34026
|
existsSync as existsSync12,
|
|
32733
34027
|
readdirSync as readdirSync7,
|
|
32734
|
-
readFileSync as
|
|
34028
|
+
readFileSync as readFileSync12,
|
|
32735
34029
|
rmdirSync as rmdirSync4,
|
|
32736
34030
|
unlinkSync as unlinkSync8
|
|
32737
34031
|
} from "node:fs";
|
|
@@ -32832,7 +34126,7 @@ function launchdManager(options) {
|
|
|
32832
34126
|
unitPath,
|
|
32833
34127
|
install: (spec) => {
|
|
32834
34128
|
const plist = renderLaunchdPlist(spec);
|
|
32835
|
-
const unchanged = existsSync12(unitPath) &&
|
|
34129
|
+
const unchanged = existsSync12(unitPath) && readFileSync12(unitPath, "utf8") === plist;
|
|
32836
34130
|
if (unchanged && loaded()) {
|
|
32837
34131
|
const kicked = options.exec("launchctl", ["kickstart", "-k", target]);
|
|
32838
34132
|
if (kicked.status === 0 && loaded()) return;
|
|
@@ -32882,7 +34176,7 @@ function noUserManager(result2) {
|
|
|
32882
34176
|
function stopByPidFile(options) {
|
|
32883
34177
|
const { pidPath } = options;
|
|
32884
34178
|
if (pidPath === void 0 || !existsSync12(pidPath)) return;
|
|
32885
|
-
const record2 = parseDaemonPid(
|
|
34179
|
+
const record2 = parseDaemonPid(readFileSync12(pidPath, "utf8"));
|
|
32886
34180
|
if (record2 === void 0) return;
|
|
32887
34181
|
const sleep3 = options.sleep ?? blockingSleep;
|
|
32888
34182
|
const processes = options.processes ?? {
|
|
@@ -32933,7 +34227,7 @@ function systemdManager(options) {
|
|
|
32933
34227
|
throw new Error(
|
|
32934
34228
|
`no systemd user manager is available (${probe2.stderr.trim().split("\n")[0] ?? ""}). Turn on systemd for your login (on WSL, set \`systemd=true\` under \`[boot]\` in /etc/wsl.conf and run \`wsl --shutdown\`), or run \`oxagen daemon\` yourself`
|
|
32935
34229
|
);
|
|
32936
|
-
const previous = existsSync12(unitPath) ?
|
|
34230
|
+
const previous = existsSync12(unitPath) ? readFileSync12(unitPath, "utf8") : void 0;
|
|
32937
34231
|
const createsWants = previous === void 0 ? !existsSync12(wants) : unitCreatedWants(previous);
|
|
32938
34232
|
ensureDir(dir, 493);
|
|
32939
34233
|
writeSensitiveFileAtomic(
|
|
@@ -32992,7 +34286,7 @@ function systemdManager(options) {
|
|
|
32992
34286
|
`systemctl could not remove tachod.service: ${disabled.stderr.trim() || active2.stderr.trim() || active2.stdout.trim() || "service state is unknown"}. Run \`systemctl --user disable --now tachod.service\`, then try again`
|
|
32993
34287
|
);
|
|
32994
34288
|
}
|
|
32995
|
-
const unit4 = existsSync12(unitPath) ?
|
|
34289
|
+
const unit4 = existsSync12(unitPath) ? readFileSync12(unitPath, "utf8") : void 0;
|
|
32996
34290
|
if (unit4 !== void 0) unlinkSync8(unitPath);
|
|
32997
34291
|
try {
|
|
32998
34292
|
const reload = options.exec("systemctl", ["--user", "daemon-reload"]);
|
|
@@ -33078,7 +34372,7 @@ function schtasksManager(options) {
|
|
|
33078
34372
|
const pidPath = options.pidPath ?? join20(launcher, "..", "tachod.pid");
|
|
33079
34373
|
const liveRecord = () => {
|
|
33080
34374
|
if (!existsSync12(pidPath)) return void 0;
|
|
33081
|
-
const record2 = parseDaemonPid(
|
|
34375
|
+
const record2 = parseDaemonPid(readFileSync12(pidPath, "utf8"));
|
|
33082
34376
|
if (record2 === void 0) return void 0;
|
|
33083
34377
|
const { pid } = record2;
|
|
33084
34378
|
const query = options.exec("tasklist", [
|
|
@@ -33249,15 +34543,15 @@ var init_service = __esm({
|
|
|
33249
34543
|
});
|
|
33250
34544
|
|
|
33251
34545
|
// ../../packages/tacho/src/version.ts
|
|
33252
|
-
import { readFileSync as
|
|
34546
|
+
import { readFileSync as readFileSync13 } from "node:fs";
|
|
33253
34547
|
import { dirname as dirname14, resolve as resolve3 } from "node:path";
|
|
33254
34548
|
import { fileURLToPath } from "node:url";
|
|
33255
34549
|
function readVersion() {
|
|
33256
|
-
if (true) return "5.5.1-
|
|
34550
|
+
if (true) return "5.5.1-278";
|
|
33257
34551
|
try {
|
|
33258
34552
|
const here = dirname14(fileURLToPath(import.meta.url));
|
|
33259
34553
|
const pkg = JSON.parse(
|
|
33260
|
-
|
|
34554
|
+
readFileSync13(resolve3(here, "..", "package.json"), "utf8")
|
|
33261
34555
|
);
|
|
33262
34556
|
return pkg.version ?? "0.0.0";
|
|
33263
34557
|
} catch {
|
|
@@ -33653,6 +34947,10 @@ function defaultCliDeps(overrides = {}, managed = {}) {
|
|
|
33653
34947
|
const credentialInternals = { managedSettingsFile: claudeManaged };
|
|
33654
34948
|
const paths = overrides.paths ?? defaultAgentPaths(tachoHome(env, home, platform2));
|
|
33655
34949
|
const harnessFiles = new HarnessFiles(paths.dir);
|
|
34950
|
+
const credentialStore = openCredentialStore({
|
|
34951
|
+
file: paths.credentials,
|
|
34952
|
+
key: paths.credentialsKey
|
|
34953
|
+
});
|
|
33656
34954
|
const harnessDirs = {
|
|
33657
34955
|
claudeConfigDir: dirname15(paths.claudeSettings),
|
|
33658
34956
|
codexHome: dirname15(paths.codexHooks),
|
|
@@ -33830,10 +35128,34 @@ function defaultCliDeps(overrides = {}, managed = {}) {
|
|
|
33830
35128
|
credentialInternals
|
|
33831
35129
|
)
|
|
33832
35130
|
},
|
|
33833
|
-
credentialStore
|
|
33834
|
-
|
|
33835
|
-
|
|
33836
|
-
|
|
35131
|
+
credentialStore,
|
|
35132
|
+
writeBackLogins: async () => {
|
|
35133
|
+
const custody = overrides.credentialStore ?? credentialStore;
|
|
35134
|
+
const host = readHostFileLenient(paths.hostFile).host;
|
|
35135
|
+
if (host === void 0)
|
|
35136
|
+
return owedWithNoSender(
|
|
35137
|
+
custody,
|
|
35138
|
+
"this machine has no enrollment to send it with"
|
|
35139
|
+
);
|
|
35140
|
+
return writeBackOwedLogins({
|
|
35141
|
+
store: custody,
|
|
35142
|
+
client: createControlClient({
|
|
35143
|
+
endpoints: {
|
|
35144
|
+
...host.endpoints,
|
|
35145
|
+
...workOrderEndpointsFor(host.api_url)
|
|
35146
|
+
},
|
|
35147
|
+
apiKey: host.api_key,
|
|
35148
|
+
hostEnrollmentId: host.host_enrollment_id,
|
|
35149
|
+
// Every request carries the device signature the control plane
|
|
35150
|
+
// checks (ADR-6604); the key is this agent's, beside its host.json.
|
|
35151
|
+
deviceKey: loadOrCreateDeviceKey(paths.deviceKey).key,
|
|
35152
|
+
userAgent: `oxagen/${host.wrapper_version}`
|
|
35153
|
+
}),
|
|
35154
|
+
// The command that asked prints what is left owed.
|
|
35155
|
+
log: () => {
|
|
35156
|
+
}
|
|
35157
|
+
});
|
|
35158
|
+
},
|
|
33837
35159
|
subscriptionLogin: realSubscriptionLogin(env, home),
|
|
33838
35160
|
daemonPost: async (path2, body2) => {
|
|
33839
35161
|
const host = readHostFile(paths.hostFile);
|
|
@@ -33930,7 +35252,10 @@ var init_deps = __esm({
|
|
|
33930
35252
|
init_hook_client();
|
|
33931
35253
|
init_claude_setup_token();
|
|
33932
35254
|
init_codex_app_server();
|
|
35255
|
+
init_control_client();
|
|
33933
35256
|
init_credential_store();
|
|
35257
|
+
init_device_key();
|
|
35258
|
+
init_login_write_back();
|
|
33934
35259
|
init_claude_config_lock();
|
|
33935
35260
|
init_fs();
|
|
33936
35261
|
init_harness_file();
|
|
@@ -34289,624 +35614,6 @@ var init_codex_hook_trust = __esm({
|
|
|
34289
35614
|
}
|
|
34290
35615
|
});
|
|
34291
35616
|
|
|
34292
|
-
// ../../packages/tacho/src/arp/schema.ts
|
|
34293
|
-
function arpFail(message2) {
|
|
34294
|
-
throw new Error(`ARP: ${message2}`);
|
|
34295
|
-
}
|
|
34296
|
-
function zodIssues(error2) {
|
|
34297
|
-
return error2.issues.map((issue2) => `${issue2.path.join(".") || "(root)"}: ${issue2.message}`).join("; ");
|
|
34298
|
-
}
|
|
34299
|
-
function safeRelativePath(path2) {
|
|
34300
|
-
const unsafe = () => arpFail(
|
|
34301
|
-
`Path ${JSON.stringify(path2)} is unsafe on a supported destination filesystem.`
|
|
34302
|
-
);
|
|
34303
|
-
if (!path2 || path2.length > 4096 || /[\\:\x00-\x1f\x7f<>"|?*]/u.test(path2))
|
|
34304
|
-
unsafe();
|
|
34305
|
-
for (const part of path2.split("/")) {
|
|
34306
|
-
if (!part || part === "." || part === ".." || /[. ]$/u.test(part) || /^(?:\.git|\.arp)$/iu.test(part) || /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/iu.test(part) || part.normalize("NFC") !== part || /[\ud800-\udfff]/u.test(part))
|
|
34307
|
-
unsafe();
|
|
34308
|
-
}
|
|
34309
|
-
return path2;
|
|
34310
|
-
}
|
|
34311
|
-
var ARP_MAX_BLOB_BYTES, ARP_MAX_TOTAL_BYTES, ARP_MAX_FILES, text2, digestSchema, empty, extensions, path, blobRefSchema, arpFrameSchema, arpCheckpointSchema, arpWorkspaceSchema;
|
|
34312
|
-
var init_schema = __esm({
|
|
34313
|
-
"../../packages/tacho/src/arp/schema.ts"() {
|
|
34314
|
-
"use strict";
|
|
34315
|
-
init_zod();
|
|
34316
|
-
init_digest();
|
|
34317
|
-
ARP_MAX_BLOB_BYTES = 64 * 1024 * 1024;
|
|
34318
|
-
ARP_MAX_TOTAL_BYTES = 512 * 1024 * 1024;
|
|
34319
|
-
ARP_MAX_FILES = 1e4;
|
|
34320
|
-
text2 = external_exports.string().min(1).max(4096);
|
|
34321
|
-
digestSchema = external_exports.string().regex(SHA256_DIGEST_PATTERN);
|
|
34322
|
-
empty = external_exports.array(external_exports.never()).max(0);
|
|
34323
|
-
extensions = external_exports.object({}).strict();
|
|
34324
|
-
path = text2.refine((value) => {
|
|
34325
|
-
try {
|
|
34326
|
-
safeRelativePath(value);
|
|
34327
|
-
return true;
|
|
34328
|
-
} catch {
|
|
34329
|
-
return false;
|
|
34330
|
-
}
|
|
34331
|
-
}, "Unsafe ARP workspace path");
|
|
34332
|
-
blobRefSchema = external_exports.object({
|
|
34333
|
-
digest: digestSchema,
|
|
34334
|
-
bytes: external_exports.number().int().min(0).max(ARP_MAX_BLOB_BYTES),
|
|
34335
|
-
media_type: text2
|
|
34336
|
-
}).strict();
|
|
34337
|
-
arpFrameSchema = external_exports.object({
|
|
34338
|
-
format: external_exports.literal("tacho/1.0"),
|
|
34339
|
-
issuer: text2,
|
|
34340
|
-
stream_id: text2,
|
|
34341
|
-
seq: external_exports.string().regex(/^(0|[1-9][0-9]*)$/),
|
|
34342
|
-
digest: digestSchema
|
|
34343
|
-
}).strict();
|
|
34344
|
-
arpCheckpointSchema = external_exports.object({
|
|
34345
|
-
schema: external_exports.literal("arp.checkpoint/0.1"),
|
|
34346
|
-
checkpoint_id: text2,
|
|
34347
|
-
issuer: text2,
|
|
34348
|
-
profile: external_exports.literal("code-workspace/0.1"),
|
|
34349
|
-
created_at: external_exports.string().datetime({ offset: true }),
|
|
34350
|
-
source: external_exports.object({
|
|
34351
|
-
boundary: arpFrameSchema,
|
|
34352
|
-
position: external_exports.literal("after"),
|
|
34353
|
-
evidence_prefix: blobRefSchema
|
|
34354
|
-
}).strict(),
|
|
34355
|
-
capture: external_exports.object({
|
|
34356
|
-
boundary_kind: external_exports.literal("turn_completed"),
|
|
34357
|
-
quiescence: external_exports.enum(["client_attested", "runner_enforced"]),
|
|
34358
|
-
barrier_evidence: blobRefSchema,
|
|
34359
|
-
pending_operations: empty,
|
|
34360
|
-
active_children: empty
|
|
34361
|
-
}).strict(),
|
|
34362
|
-
task: blobRefSchema,
|
|
34363
|
-
context: blobRefSchema,
|
|
34364
|
-
workspace: blobRefSchema,
|
|
34365
|
-
environment: blobRefSchema,
|
|
34366
|
-
tools: blobRefSchema,
|
|
34367
|
-
authority: blobRefSchema,
|
|
34368
|
-
effects: external_exports.array(
|
|
34369
|
-
external_exports.object({
|
|
34370
|
-
operation_id: text2,
|
|
34371
|
-
status: external_exports.enum(["settled", "unknown"]),
|
|
34372
|
-
receipt: blobRefSchema.optional(),
|
|
34373
|
-
external_ids: external_exports.array(text2).max(ARP_MAX_FILES),
|
|
34374
|
-
idempotency_key: text2.optional()
|
|
34375
|
-
}).strict()
|
|
34376
|
-
).max(ARP_MAX_FILES),
|
|
34377
|
-
gaps: external_exports.array(
|
|
34378
|
-
external_exports.object({
|
|
34379
|
-
code: text2,
|
|
34380
|
-
dimension: external_exports.enum([
|
|
34381
|
-
"workspace",
|
|
34382
|
-
"environment",
|
|
34383
|
-
"context",
|
|
34384
|
-
"tools",
|
|
34385
|
-
"effects",
|
|
34386
|
-
"authority",
|
|
34387
|
-
"evidence"
|
|
34388
|
-
]),
|
|
34389
|
-
required: external_exports.boolean(),
|
|
34390
|
-
detail: text2,
|
|
34391
|
-
source: arpFrameSchema.optional()
|
|
34392
|
-
}).strict()
|
|
34393
|
-
).max(ARP_MAX_FILES),
|
|
34394
|
-
extensions,
|
|
34395
|
-
required_extensions: empty
|
|
34396
|
-
}).strict();
|
|
34397
|
-
arpWorkspaceSchema = external_exports.object({
|
|
34398
|
-
schema: external_exports.literal("arp.workspace/0.1"),
|
|
34399
|
-
complete_scope: external_exports.literal(true),
|
|
34400
|
-
repositories: external_exports.array(
|
|
34401
|
-
external_exports.object({
|
|
34402
|
-
root: external_exports.union([external_exports.literal("."), path]),
|
|
34403
|
-
provider_id: text2,
|
|
34404
|
-
base_object: text2
|
|
34405
|
-
}).strict()
|
|
34406
|
-
).max(ARP_MAX_FILES),
|
|
34407
|
-
entries: external_exports.array(
|
|
34408
|
-
external_exports.discriminatedUnion("kind", [
|
|
34409
|
-
external_exports.object({ path, kind: external_exports.literal("directory") }).strict(),
|
|
34410
|
-
external_exports.object({
|
|
34411
|
-
path,
|
|
34412
|
-
kind: external_exports.literal("file"),
|
|
34413
|
-
blob: blobRefSchema,
|
|
34414
|
-
executable: external_exports.boolean()
|
|
34415
|
-
}).strict()
|
|
34416
|
-
])
|
|
34417
|
-
).max(ARP_MAX_FILES),
|
|
34418
|
-
// Exclusions describe omitted paths, including reserved metadata directories.
|
|
34419
|
-
exclusions: external_exports.array(
|
|
34420
|
-
external_exports.object({ path: text2, reason: text2, required: external_exports.boolean() }).strict()
|
|
34421
|
-
).max(ARP_MAX_FILES),
|
|
34422
|
-
resources: empty,
|
|
34423
|
-
extensions,
|
|
34424
|
-
required_extensions: empty
|
|
34425
|
-
}).strict();
|
|
34426
|
-
}
|
|
34427
|
-
});
|
|
34428
|
-
|
|
34429
|
-
// ../../packages/tacho/src/host/device-key.ts
|
|
34430
|
-
import {
|
|
34431
|
-
createHash as createHash6,
|
|
34432
|
-
createPrivateKey,
|
|
34433
|
-
createPublicKey as createPublicKey3,
|
|
34434
|
-
generateKeyPairSync,
|
|
34435
|
-
sign as sign3,
|
|
34436
|
-
verify as verify3
|
|
34437
|
-
} from "node:crypto";
|
|
34438
|
-
import { readFileSync as readFileSync13 } from "node:fs";
|
|
34439
|
-
function encodePublicKey(privateKey) {
|
|
34440
|
-
const spki = createPublicKey3(privateKey).export({
|
|
34441
|
-
type: "spki",
|
|
34442
|
-
format: "der"
|
|
34443
|
-
});
|
|
34444
|
-
const raw = spki.subarray(SPKI_ED25519_PREFIX_BYTES);
|
|
34445
|
-
return `ed25519:${raw.toString("base64")}`;
|
|
34446
|
-
}
|
|
34447
|
-
function deviceKeyFingerprint(publicKey) {
|
|
34448
|
-
return createHash6("sha256").update(publicKey, "utf8").digest("hex").slice(0, 16);
|
|
34449
|
-
}
|
|
34450
|
-
function fromPrivateKey(privateKey) {
|
|
34451
|
-
if (privateKey.asymmetricKeyType !== "ed25519") {
|
|
34452
|
-
throw new Error(
|
|
34453
|
-
`device key must be ed25519, got ${privateKey.asymmetricKeyType ?? "unknown"}`
|
|
34454
|
-
);
|
|
34455
|
-
}
|
|
34456
|
-
const publicKey = encodePublicKey(privateKey);
|
|
34457
|
-
return {
|
|
34458
|
-
privateKey,
|
|
34459
|
-
publicKey,
|
|
34460
|
-
fingerprint: deviceKeyFingerprint(publicKey),
|
|
34461
|
-
sign: (message2) => sign3(null, Buffer.from(message2, "utf8"), privateKey).toString("base64")
|
|
34462
|
-
};
|
|
34463
|
-
}
|
|
34464
|
-
function generateDeviceKey() {
|
|
34465
|
-
return fromPrivateKey(generateKeyPairSync("ed25519").privateKey);
|
|
34466
|
-
}
|
|
34467
|
-
function deviceKeyFromPem(pem2) {
|
|
34468
|
-
return fromPrivateKey(createPrivateKey(pem2));
|
|
34469
|
-
}
|
|
34470
|
-
function deviceKeyPem(key) {
|
|
34471
|
-
return key.privateKey.export({ type: "pkcs8", format: "pem" }).toString();
|
|
34472
|
-
}
|
|
34473
|
-
function loadOrCreateDeviceKey(path2) {
|
|
34474
|
-
try {
|
|
34475
|
-
return {
|
|
34476
|
-
key: deviceKeyFromPem(readFileSync13(path2, "utf8")),
|
|
34477
|
-
created: false
|
|
34478
|
-
};
|
|
34479
|
-
} catch (error2) {
|
|
34480
|
-
if (error2.code !== "ENOENT") throw error2;
|
|
34481
|
-
}
|
|
34482
|
-
const key = generateDeviceKey();
|
|
34483
|
-
writeSensitiveFileAtomic(path2, deviceKeyPem(key));
|
|
34484
|
-
return { key, created: true };
|
|
34485
|
-
}
|
|
34486
|
-
function credentialDigest(credential) {
|
|
34487
|
-
return createHash6("sha256").update(credential, "utf8").digest("hex");
|
|
34488
|
-
}
|
|
34489
|
-
function deviceKeyProofMessage(claims2) {
|
|
34490
|
-
return JSON.stringify([
|
|
34491
|
-
DEVICE_KEY_PROOF_DOMAIN,
|
|
34492
|
-
claims2.credentialDigest,
|
|
34493
|
-
claims2.devicePublicKey,
|
|
34494
|
-
claims2.hostname,
|
|
34495
|
-
claims2.osUser,
|
|
34496
|
-
claims2.platform,
|
|
34497
|
-
[...claims2.harnesses],
|
|
34498
|
-
claims2.signedAtUnixS
|
|
34499
|
-
]);
|
|
34500
|
-
}
|
|
34501
|
-
function signDeviceKeyProof(key, claims2) {
|
|
34502
|
-
return {
|
|
34503
|
-
signedAtUnixS: claims2.signedAtUnixS,
|
|
34504
|
-
signature: key.sign(
|
|
34505
|
-
deviceKeyProofMessage({ ...claims2, devicePublicKey: key.publicKey })
|
|
34506
|
-
)
|
|
34507
|
-
};
|
|
34508
|
-
}
|
|
34509
|
-
function verifyDeviceSignature(publicKey, message2, signatureBase64) {
|
|
34510
|
-
if (!publicKey.startsWith("ed25519:")) return false;
|
|
34511
|
-
const raw = Buffer.from(publicKey.slice("ed25519:".length), "base64");
|
|
34512
|
-
if (raw.length !== 32) return false;
|
|
34513
|
-
const spki = Buffer.concat([
|
|
34514
|
-
Buffer.from("302a300506032b6570032100", "hex"),
|
|
34515
|
-
raw
|
|
34516
|
-
]);
|
|
34517
|
-
try {
|
|
34518
|
-
return verify3(
|
|
34519
|
-
null,
|
|
34520
|
-
Buffer.from(message2, "utf8"),
|
|
34521
|
-
createPublicKey3({ key: spki, format: "der", type: "spki" }),
|
|
34522
|
-
Buffer.from(signatureBase64, "base64")
|
|
34523
|
-
);
|
|
34524
|
-
} catch {
|
|
34525
|
-
return false;
|
|
34526
|
-
}
|
|
34527
|
-
}
|
|
34528
|
-
var SPKI_ED25519_PREFIX_BYTES, DEVICE_KEY_PROOF_DOMAIN;
|
|
34529
|
-
var init_device_key = __esm({
|
|
34530
|
-
"../../packages/tacho/src/host/device-key.ts"() {
|
|
34531
|
-
"use strict";
|
|
34532
|
-
init_fs();
|
|
34533
|
-
SPKI_ED25519_PREFIX_BYTES = 12;
|
|
34534
|
-
DEVICE_KEY_PROOF_DOMAIN = "oxagen.tacho.device-key-proof.v1";
|
|
34535
|
-
}
|
|
34536
|
-
});
|
|
34537
|
-
|
|
34538
|
-
// ../../packages/tacho/src/host/request-signature.ts
|
|
34539
|
-
import { createHash as createHash7 } from "node:crypto";
|
|
34540
|
-
function bodySha256(body2) {
|
|
34541
|
-
return createHash7("sha256").update(body2).digest("hex");
|
|
34542
|
-
}
|
|
34543
|
-
function requestSignatureMessage(input2) {
|
|
34544
|
-
return JSON.stringify([
|
|
34545
|
-
REQUEST_SIGNATURE_DOMAIN,
|
|
34546
|
-
input2.method.toUpperCase(),
|
|
34547
|
-
input2.path,
|
|
34548
|
-
input2.signedAtUnixS,
|
|
34549
|
-
input2.bodySha256
|
|
34550
|
-
]);
|
|
34551
|
-
}
|
|
34552
|
-
function signRequest(key, input2) {
|
|
34553
|
-
return `v1 ts=${input2.signedAtUnixS} sig=${key.sign(requestSignatureMessage(input2))}`;
|
|
34554
|
-
}
|
|
34555
|
-
function parseRequestSignature(header2) {
|
|
34556
|
-
if (!header2) return void 0;
|
|
34557
|
-
const match = HEADER_PATTERN.exec(header2.trim());
|
|
34558
|
-
if (!match) return void 0;
|
|
34559
|
-
return { signedAtUnixS: Number(match[1]), signature: match[2] };
|
|
34560
|
-
}
|
|
34561
|
-
function verifyRequestSignature(devicePublicKey, header2, request4, nowUnixS, maxSkewS = REQUEST_SIGNATURE_MAX_SKEW_S) {
|
|
34562
|
-
if (!header2) return "missing";
|
|
34563
|
-
const parsed2 = parseRequestSignature(header2);
|
|
34564
|
-
if (parsed2 === void 0) return "malformed";
|
|
34565
|
-
if (Math.abs(nowUnixS - parsed2.signedAtUnixS) > maxSkewS) return "stale";
|
|
34566
|
-
const message2 = requestSignatureMessage({
|
|
34567
|
-
...request4,
|
|
34568
|
-
signedAtUnixS: parsed2.signedAtUnixS
|
|
34569
|
-
});
|
|
34570
|
-
return verifyDeviceSignature(devicePublicKey, message2, parsed2.signature) ? void 0 : "invalid";
|
|
34571
|
-
}
|
|
34572
|
-
function signedPathOf(url2) {
|
|
34573
|
-
const parsed2 = new URL(url2);
|
|
34574
|
-
return `${parsed2.pathname}${parsed2.search}`;
|
|
34575
|
-
}
|
|
34576
|
-
function deviceSignatureHeader(key, method, url2, body2, nowMs = Date.now()) {
|
|
34577
|
-
return {
|
|
34578
|
-
[REQUEST_SIGNATURE_HEADER]: signRequest(key, {
|
|
34579
|
-
method,
|
|
34580
|
-
path: signedPathOf(url2),
|
|
34581
|
-
bodySha256: bodySha256(body2),
|
|
34582
|
-
signedAtUnixS: Math.floor(nowMs / 1e3)
|
|
34583
|
-
})
|
|
34584
|
-
};
|
|
34585
|
-
}
|
|
34586
|
-
var REQUEST_SIGNATURE_HEADER, REQUEST_SIGNATURE_DOMAIN, REQUEST_SIGNATURE_MAX_SKEW_S, HEADER_PATTERN;
|
|
34587
|
-
var init_request_signature = __esm({
|
|
34588
|
-
"../../packages/tacho/src/host/request-signature.ts"() {
|
|
34589
|
-
"use strict";
|
|
34590
|
-
init_device_key();
|
|
34591
|
-
REQUEST_SIGNATURE_HEADER = "x-oxagen-device-signature";
|
|
34592
|
-
REQUEST_SIGNATURE_DOMAIN = "oxagen.tacho.request-signature.v1";
|
|
34593
|
-
REQUEST_SIGNATURE_MAX_SKEW_S = 300;
|
|
34594
|
-
HEADER_PATTERN = /^v1 ts=(\d{1,12}) sig=([A-Za-z0-9+/]+={0,2})$/;
|
|
34595
|
-
}
|
|
34596
|
-
});
|
|
34597
|
-
|
|
34598
|
-
// ../../packages/tacho/src/host/control-client.ts
|
|
34599
|
-
function parseRetryAfter(value, nowMs) {
|
|
34600
|
-
if (!value) return void 0;
|
|
34601
|
-
const seconds = Number(value);
|
|
34602
|
-
if (Number.isFinite(seconds)) return Math.max(0, seconds * 1e3);
|
|
34603
|
-
const at2 = Date.parse(value);
|
|
34604
|
-
return Number.isNaN(at2) ? void 0 : Math.max(0, at2 - nowMs);
|
|
34605
|
-
}
|
|
34606
|
-
function headerNumber(value) {
|
|
34607
|
-
if (value === null || value.trim().length === 0) return void 0;
|
|
34608
|
-
const parsed2 = Number(value);
|
|
34609
|
-
return Number.isFinite(parsed2) ? parsed2 : void 0;
|
|
34610
|
-
}
|
|
34611
|
-
function readRateLimitHint(headers, nowMs) {
|
|
34612
|
-
if (!headers) return void 0;
|
|
34613
|
-
const hint = {};
|
|
34614
|
-
const remaining = headerNumber(headers.get("x-ratelimit-remaining"));
|
|
34615
|
-
if (remaining !== void 0) hint.remaining = remaining;
|
|
34616
|
-
const reset = headerNumber(headers.get("x-ratelimit-reset"));
|
|
34617
|
-
if (reset !== void 0 && reset > 0) hint.resetAtMs = reset * 1e3;
|
|
34618
|
-
const retryAfter = parseRetryAfter(headers.get("retry-after"), nowMs);
|
|
34619
|
-
if (retryAfter !== void 0) hint.retryAfterMs = retryAfter;
|
|
34620
|
-
return Object.keys(hint).length > 0 ? hint : void 0;
|
|
34621
|
-
}
|
|
34622
|
-
function workOrderEndpointsFor(apiUrl) {
|
|
34623
|
-
const base2 = apiUrl.replace(/\/+$/, "");
|
|
34624
|
-
return {
|
|
34625
|
-
workOrderClaim: `${base2}${WORK_ORDER_CLAIM_PATH}`,
|
|
34626
|
-
workOrderReject: `${base2}${WORK_ORDER_REJECT_PATH}`,
|
|
34627
|
-
workCriterionClaim: `${base2}${WORK_CRITERION_CLAIM_PATH}`,
|
|
34628
|
-
workOrderChecklist: `${base2}${WORK_ORDER_CHECKLIST_PATH}`,
|
|
34629
|
-
workOrderProgress: `${base2}${WORK_ORDER_PROGRESS_PATH}`,
|
|
34630
|
-
certificate: `${base2}${CERTIFICATE_RENEW_PATH}`,
|
|
34631
|
-
enrollmentKeys: `${base2}${ENROLLMENT_KEYS_PATH}`,
|
|
34632
|
-
hostConnection: `${base2}${HOST_CONNECTION_PATH}`,
|
|
34633
|
-
modelCredentials: `${base2}${HOST_MODEL_CREDENTIALS_PATH}`,
|
|
34634
|
-
modelCredentialState: `${base2}${HOST_MODEL_CREDENTIAL_STATE_PATH}`
|
|
34635
|
-
};
|
|
34636
|
-
}
|
|
34637
|
-
function createControlClient(options) {
|
|
34638
|
-
const fetchImpl = options.fetch ?? ((input2, init) => fetch(input2, init));
|
|
34639
|
-
const timeoutMs = options.timeoutMs ?? 15e3;
|
|
34640
|
-
const ingestTimeoutMs = options.ingestTimeoutMs ?? TACHO_INGEST_TIMEOUT_MS;
|
|
34641
|
-
const nowMs = options.now ?? Date.now;
|
|
34642
|
-
async function post3(url2, body2, boundMs = timeoutMs, method = "POST", extraHeaders = {}) {
|
|
34643
|
-
const controller = new AbortController();
|
|
34644
|
-
const timer = setTimeout(() => controller.abort(), boundMs);
|
|
34645
|
-
const signal = options.signal === void 0 ? controller.signal : AbortSignal.any([controller.signal, options.signal]);
|
|
34646
|
-
let response;
|
|
34647
|
-
let text6;
|
|
34648
|
-
try {
|
|
34649
|
-
const payload = method === "GET" ? "" : JSON.stringify(body2);
|
|
34650
|
-
response = await fetchImpl(url2, {
|
|
34651
|
-
method,
|
|
34652
|
-
headers: {
|
|
34653
|
-
...method === "GET" ? {} : { Authorization: `Bearer ${options.apiKey}` },
|
|
34654
|
-
"Content-Type": "application/json",
|
|
34655
|
-
"User-Agent": options.userAgent ?? "tachod",
|
|
34656
|
-
...extraHeaders,
|
|
34657
|
-
...options.deviceKey !== void 0 && method !== "GET" ? deviceSignatureHeader(
|
|
34658
|
-
options.deviceKey,
|
|
34659
|
-
method,
|
|
34660
|
-
url2,
|
|
34661
|
-
payload,
|
|
34662
|
-
nowMs()
|
|
34663
|
-
) : {}
|
|
34664
|
-
},
|
|
34665
|
-
...method === "GET" ? {} : { body: payload },
|
|
34666
|
-
signal
|
|
34667
|
-
});
|
|
34668
|
-
text6 = await response.text();
|
|
34669
|
-
} catch (error2) {
|
|
34670
|
-
throw new ControlUnreachable(error2, url2);
|
|
34671
|
-
} finally {
|
|
34672
|
-
clearTimeout(timer);
|
|
34673
|
-
}
|
|
34674
|
-
const hint = readRateLimitHint(response.headers, nowMs());
|
|
34675
|
-
if (hint) options.onRateLimit?.(hint);
|
|
34676
|
-
if (!response.ok)
|
|
34677
|
-
throw new ControlError(response.status, text6, void 0, hint);
|
|
34678
|
-
try {
|
|
34679
|
-
return JSON.parse(text6);
|
|
34680
|
-
} catch {
|
|
34681
|
-
throw new ControlError(
|
|
34682
|
-
response.status,
|
|
34683
|
-
text6,
|
|
34684
|
-
"control plane answered non-JSON",
|
|
34685
|
-
hint
|
|
34686
|
-
);
|
|
34687
|
-
}
|
|
34688
|
-
}
|
|
34689
|
-
function endpoint(url2, name2) {
|
|
34690
|
-
if (url2 === void 0)
|
|
34691
|
-
throw new Error(`the control client has no ${name2} endpoint`);
|
|
34692
|
-
return url2;
|
|
34693
|
-
}
|
|
34694
|
-
async function call2(url2, schema, body2, boundMs, method = "POST", extraHeaders) {
|
|
34695
|
-
const parsed2 = schema.safeParse(
|
|
34696
|
-
await post3(url2, body2, boundMs, method, extraHeaders)
|
|
34697
|
-
);
|
|
34698
|
-
if (!parsed2.success)
|
|
34699
|
-
throw new ControlAnswerUnreadable(url2, zodIssues(parsed2.error));
|
|
34700
|
-
return parsed2.data;
|
|
34701
|
-
}
|
|
34702
|
-
return {
|
|
34703
|
-
ingest: (events, daemon, bodies) => call2(
|
|
34704
|
-
options.endpoints.ingest,
|
|
34705
|
-
ingestResponseSchema,
|
|
34706
|
-
{
|
|
34707
|
-
schema: TACHO_BATCH_SCHEMA,
|
|
34708
|
-
host_enrollment_id: options.hostEnrollmentId,
|
|
34709
|
-
events,
|
|
34710
|
-
...bodies !== void 0 && bodies.length > 0 ? { bodies } : {},
|
|
34711
|
-
...daemon !== void 0 ? { daemon } : {}
|
|
34712
|
-
},
|
|
34713
|
-
ingestTimeoutMs
|
|
34714
|
-
),
|
|
34715
|
-
bundle: (etag, run3) => call2(options.endpoints.bundle, bundleResponseSchema, {
|
|
34716
|
-
host_enrollment_id: options.hostEnrollmentId,
|
|
34717
|
-
...etag !== void 0 ? { etag } : {},
|
|
34718
|
-
...run3?.remote !== void 0 ? { remote: run3.remote } : {},
|
|
34719
|
-
...run3?.harness !== void 0 ? { harness: run3.harness } : {}
|
|
34720
|
-
}),
|
|
34721
|
-
commands: (acknowledgements = [], daemon) => call2(options.endpoints.commands, commandsResponseSchema, {
|
|
34722
|
-
schema: TACHO_COMMANDS_SCHEMA,
|
|
34723
|
-
host_enrollment_id: options.hostEnrollmentId,
|
|
34724
|
-
acknowledgements,
|
|
34725
|
-
...daemon !== void 0 ? { daemon } : {}
|
|
34726
|
-
}),
|
|
34727
|
-
claimWorkOrder: async (workOrderId) => call2(
|
|
34728
|
-
endpoint(options.endpoints.workOrderClaim, "work order claim"),
|
|
34729
|
-
workOrderClaimResponseSchema,
|
|
34730
|
-
{
|
|
34731
|
-
host_enrollment_id: options.hostEnrollmentId,
|
|
34732
|
-
work_order_id: workOrderId
|
|
34733
|
-
}
|
|
34734
|
-
),
|
|
34735
|
-
rejectWorkOrder: async (workOrderId, reason4) => call2(
|
|
34736
|
-
endpoint(options.endpoints.workOrderReject, "work order refusal"),
|
|
34737
|
-
workOrderRejectResponseSchema,
|
|
34738
|
-
{
|
|
34739
|
-
host_enrollment_id: options.hostEnrollmentId,
|
|
34740
|
-
work_order_id: workOrderId,
|
|
34741
|
-
reason: reason4
|
|
34742
|
-
}
|
|
34743
|
-
),
|
|
34744
|
-
// An empty body: the server reads the host from the key, and the device
|
|
34745
|
-
// signature over the request proves the machine holds the key the
|
|
34746
|
-
// certificate names.
|
|
34747
|
-
renewCertificate: async () => call2(
|
|
34748
|
-
endpoint(options.endpoints.certificate, "certificate renewal"),
|
|
34749
|
-
certificateRenewalResponseSchema,
|
|
34750
|
-
{}
|
|
34751
|
-
),
|
|
34752
|
-
enrollmentKeys: async () => call2(
|
|
34753
|
-
endpoint(options.endpoints.enrollmentKeys, "enrollment keys"),
|
|
34754
|
-
enrollmentKeysResponseSchema,
|
|
34755
|
-
void 0,
|
|
34756
|
-
void 0,
|
|
34757
|
-
"GET"
|
|
34758
|
-
),
|
|
34759
|
-
setConnection: async (state) => call2(
|
|
34760
|
-
endpoint(options.endpoints.hostConnection, "workspace connection"),
|
|
34761
|
-
hostConnectionChangeResponseSchema,
|
|
34762
|
-
{ host_enrollment_id: options.hostEnrollmentId, state }
|
|
34763
|
-
),
|
|
34764
|
-
modelCredentials: async (harness) => call2(
|
|
34765
|
-
endpoint(options.endpoints.modelCredentials, "model credentials"),
|
|
34766
|
-
hostModelCredentialsResponseSchema,
|
|
34767
|
-
{ host_enrollment_id: options.hostEnrollmentId, harness }
|
|
34768
|
-
),
|
|
34769
|
-
reportModelCredential: async (credentialId, report) => call2(
|
|
34770
|
-
endpoint(
|
|
34771
|
-
options.endpoints.modelCredentialState,
|
|
34772
|
-
"model credential report"
|
|
34773
|
-
),
|
|
34774
|
-
hostModelCredentialStateResponseSchema,
|
|
34775
|
-
{
|
|
34776
|
-
host_enrollment_id: options.hostEnrollmentId,
|
|
34777
|
-
credential_id: credentialId,
|
|
34778
|
-
report
|
|
34779
|
-
}
|
|
34780
|
-
),
|
|
34781
|
-
// The body names exactly the contract's fields. It carries no enrollment
|
|
34782
|
-
// id: the server reads the host from the key. The run's token goes in a
|
|
34783
|
-
// header, so it stays out of the input the kernel hashes and audits.
|
|
34784
|
-
claimWorkCriterion: async (claim2, token) => call2(
|
|
34785
|
-
endpoint(options.endpoints.workCriterionClaim, "criterion claim"),
|
|
34786
|
-
workCriterionClaimResponseSchema,
|
|
34787
|
-
{
|
|
34788
|
-
item_id: claim2.item_id,
|
|
34789
|
-
work_order_id: claim2.work_order_id,
|
|
34790
|
-
criterion_id: claim2.criterion_id,
|
|
34791
|
-
head_sha: claim2.head_sha,
|
|
34792
|
-
text: claim2.text,
|
|
34793
|
-
status: claim2.status,
|
|
34794
|
-
evidence: claim2.evidence
|
|
34795
|
-
},
|
|
34796
|
-
void 0,
|
|
34797
|
-
"POST",
|
|
34798
|
-
{ [WORK_ORDER_TOKEN_HEADER]: token }
|
|
34799
|
-
),
|
|
34800
|
-
readWorkOrderChecklist: async (workOrderId, token) => call2(
|
|
34801
|
-
endpoint(options.endpoints.workOrderChecklist, "work order checklist"),
|
|
34802
|
-
workOrderChecklistResponseSchema,
|
|
34803
|
-
{
|
|
34804
|
-
host_enrollment_id: options.hostEnrollmentId,
|
|
34805
|
-
work_order_id: workOrderId
|
|
34806
|
-
},
|
|
34807
|
-
void 0,
|
|
34808
|
-
"POST",
|
|
34809
|
-
{ [WORK_ORDER_TOKEN_HEADER]: token }
|
|
34810
|
-
),
|
|
34811
|
-
// The body names exactly the contract's fields, and `ask` only when the
|
|
34812
|
-
// agent asked something. The token goes in a header, as for a claim.
|
|
34813
|
-
postWorkProgress: async (progress, token) => call2(
|
|
34814
|
-
endpoint(options.endpoints.workOrderProgress, "progress update"),
|
|
34815
|
-
workProgressResponseSchema,
|
|
34816
|
-
{
|
|
34817
|
-
work_order_id: progress.work_order_id,
|
|
34818
|
-
step: { n: progress.step.n, of: progress.step.of },
|
|
34819
|
-
changed: progress.changed,
|
|
34820
|
-
passed: progress.passed,
|
|
34821
|
-
next: progress.next,
|
|
34822
|
-
...progress.ask !== void 0 ? { ask: progress.ask } : {}
|
|
34823
|
-
},
|
|
34824
|
-
void 0,
|
|
34825
|
-
"POST",
|
|
34826
|
-
{ [WORK_ORDER_TOKEN_HEADER]: token }
|
|
34827
|
-
)
|
|
34828
|
-
};
|
|
34829
|
-
}
|
|
34830
|
-
function controlErrorMessage(error2) {
|
|
34831
|
-
try {
|
|
34832
|
-
const body2 = JSON.parse(error2.body);
|
|
34833
|
-
if (typeof body2 === "object" && body2 !== null) {
|
|
34834
|
-
const inner = body2["error"];
|
|
34835
|
-
if (typeof inner === "object" && inner !== null) {
|
|
34836
|
-
const message3 = inner["message"];
|
|
34837
|
-
if (typeof message3 === "string" && message3.length > 0) return message3;
|
|
34838
|
-
}
|
|
34839
|
-
const message2 = body2["message"];
|
|
34840
|
-
if (typeof message2 === "string" && message2.length > 0) return message2;
|
|
34841
|
-
}
|
|
34842
|
-
} catch {
|
|
34843
|
-
}
|
|
34844
|
-
return `Oxagen answered ${error2.status}.`;
|
|
34845
|
-
}
|
|
34846
|
-
function controlErrorReason(error2) {
|
|
34847
|
-
try {
|
|
34848
|
-
const body2 = JSON.parse(error2.body);
|
|
34849
|
-
if (typeof body2 === "object" && body2 !== null) {
|
|
34850
|
-
const inner = body2["error"];
|
|
34851
|
-
if (typeof inner === "object" && inner !== null) {
|
|
34852
|
-
const reason4 = inner["reason"];
|
|
34853
|
-
if (typeof reason4 === "string" && reason4.length > 0) return reason4;
|
|
34854
|
-
}
|
|
34855
|
-
}
|
|
34856
|
-
} catch {
|
|
34857
|
-
}
|
|
34858
|
-
return void 0;
|
|
34859
|
-
}
|
|
34860
|
-
var TACHO_INGEST_TIMEOUT_MS, ControlError, ControlUnreachable, ControlAnswerUnreadable;
|
|
34861
|
-
var init_control_client = __esm({
|
|
34862
|
-
"../../packages/tacho/src/host/control-client.ts"() {
|
|
34863
|
-
"use strict";
|
|
34864
|
-
init_schema();
|
|
34865
|
-
init_request_signature();
|
|
34866
|
-
init_wire();
|
|
34867
|
-
TACHO_INGEST_TIMEOUT_MS = 6e4;
|
|
34868
|
-
ControlError = class extends Error {
|
|
34869
|
-
status;
|
|
34870
|
-
body;
|
|
34871
|
-
/**
|
|
34872
|
-
* What the server said about waiting, when it said anything. Carried on the
|
|
34873
|
-
* error so the Shipper can honour a 429's `Retry-After` instead of doubling
|
|
34874
|
-
* its own backoff past the window the server actually named.
|
|
34875
|
-
*/
|
|
34876
|
-
rateLimit;
|
|
34877
|
-
constructor(status2, body2, message2, rateLimit) {
|
|
34878
|
-
super(message2 ?? `control plane answered ${status2}: ${body2.slice(0, 256)}`);
|
|
34879
|
-
this.name = "ControlError";
|
|
34880
|
-
this.status = status2;
|
|
34881
|
-
this.body = body2;
|
|
34882
|
-
this.rateLimit = rateLimit;
|
|
34883
|
-
}
|
|
34884
|
-
};
|
|
34885
|
-
ControlUnreachable = class extends Error {
|
|
34886
|
-
/** The endpoint the request was for, when the caller named it. */
|
|
34887
|
-
url;
|
|
34888
|
-
constructor(cause, url2) {
|
|
34889
|
-
super(
|
|
34890
|
-
`control plane unreachable${url2 === void 0 ? "" : ` at ${url2}`}: ${cause instanceof Error ? cause.message : String(cause)}`,
|
|
34891
|
-
{ cause }
|
|
34892
|
-
);
|
|
34893
|
-
this.name = "ControlUnreachable";
|
|
34894
|
-
this.url = url2;
|
|
34895
|
-
}
|
|
34896
|
-
};
|
|
34897
|
-
ControlAnswerUnreadable = class extends Error {
|
|
34898
|
-
url;
|
|
34899
|
-
constructor(url2, issues) {
|
|
34900
|
-
super(
|
|
34901
|
-
`control plane answered ${url2} in a shape this host does not read: ${issues}`
|
|
34902
|
-
);
|
|
34903
|
-
this.name = "ControlAnswerUnreadable";
|
|
34904
|
-
this.url = url2;
|
|
34905
|
-
}
|
|
34906
|
-
};
|
|
34907
|
-
}
|
|
34908
|
-
});
|
|
34909
|
-
|
|
34910
35617
|
// ../../packages/tacho/src/host/wal-index.ts
|
|
34911
35618
|
import {
|
|
34912
35619
|
appendFileSync,
|
|
@@ -39449,6 +40156,11 @@ function restartForRemaining(installed, deps) {
|
|
|
39449
40156
|
return warning;
|
|
39450
40157
|
}
|
|
39451
40158
|
}
|
|
40159
|
+
function owedWarnings(owed) {
|
|
40160
|
+
return owed.map(
|
|
40161
|
+
(login) => `Oxagen does not hold ${login}. This machine refreshed that login, so the tokens in its custody are the only ones that still work, and unenrolling would delete them`
|
|
40162
|
+
);
|
|
40163
|
+
}
|
|
39452
40164
|
function listOf2(items) {
|
|
39453
40165
|
if (items.length <= 1) return items.join("");
|
|
39454
40166
|
return `${items.slice(0, -1).join(", ")} and ${items[items.length - 1]}`;
|
|
@@ -39477,6 +40189,14 @@ async function unenrollLocked(options, deps) {
|
|
|
39477
40189
|
return { ok: false, settingsChanged: false, revoked: false, warnings };
|
|
39478
40190
|
}
|
|
39479
40191
|
const credentials2 = await restoreCredentials(host, deps, "unenroll");
|
|
40192
|
+
if (credentials2.owed.length > 0) {
|
|
40193
|
+
warnings.push(...credentials2.warnings, ...owedWarnings(credentials2.owed));
|
|
40194
|
+
warnings.push(
|
|
40195
|
+
"Unenrollment stopped before it changed anything. Run `oxagen agent unenroll` again once this machine can reach Oxagen."
|
|
40196
|
+
);
|
|
40197
|
+
for (const warning of warnings) deps.err(`warning: ${warning}`);
|
|
40198
|
+
return { ok: false, settingsChanged: false, revoked: false, warnings };
|
|
40199
|
+
}
|
|
39480
40200
|
for (const file2 of credentials2.restored)
|
|
39481
40201
|
deps.out(` model credential given back to ${file2}`);
|
|
39482
40202
|
warnings.push(...credentials2.warnings);
|
|
@@ -39580,6 +40300,25 @@ async function unenrollLocked(options, deps) {
|
|
|
39580
40300
|
warnings
|
|
39581
40301
|
};
|
|
39582
40302
|
}
|
|
40303
|
+
const owedNow = await owedBeforeRelease(deps);
|
|
40304
|
+
const waiting2 = owedNow.filter((login) => login.retryable);
|
|
40305
|
+
if (waiting2.length > 0) {
|
|
40306
|
+
warnings.push(...owedWarnings(waiting2.map(describeOwedLogin)));
|
|
40307
|
+
warnings.push(
|
|
40308
|
+
"Unenrollment stopped before the revoke. The hooks and the service are removed, and the host key and the credential store are kept. Run `oxagen agent unenroll` again once this machine can reach Oxagen."
|
|
40309
|
+
);
|
|
40310
|
+
for (const warning of warnings) deps.err(`warning: ${warning}`);
|
|
40311
|
+
return {
|
|
40312
|
+
ok: false,
|
|
40313
|
+
settingsChanged: stripped.settingsChanged,
|
|
40314
|
+
revoked: false,
|
|
40315
|
+
warnings
|
|
40316
|
+
};
|
|
40317
|
+
}
|
|
40318
|
+
for (const lost of owedNow) {
|
|
40319
|
+
const warning = lostLoginWarning(lost);
|
|
40320
|
+
if (!warnings.includes(warning)) warnings.push(warning);
|
|
40321
|
+
}
|
|
39583
40322
|
let revoked = false;
|
|
39584
40323
|
if (host === void 0) {
|
|
39585
40324
|
deps.out("[3/4] No enrollment on this machine; nothing to revoke");
|
|
@@ -39727,6 +40466,7 @@ var init_unenroll = __esm({
|
|
|
39727
40466
|
init_host_file();
|
|
39728
40467
|
init_github();
|
|
39729
40468
|
init_credential();
|
|
40469
|
+
init_login_write_back();
|
|
39730
40470
|
init_model_base_url();
|
|
39731
40471
|
init_settings_writer();
|
|
39732
40472
|
init_stella_writer();
|
|
@@ -48285,6 +49025,16 @@ async function renewStaticToken(harness, deps) {
|
|
|
48285
49025
|
return "failed";
|
|
48286
49026
|
}
|
|
48287
49027
|
}
|
|
49028
|
+
async function owedAfterWriteBack(deps) {
|
|
49029
|
+
if (deps.writeBack === void 0) return [];
|
|
49030
|
+
try {
|
|
49031
|
+
return await deps.writeBack();
|
|
49032
|
+
} catch (error2) {
|
|
49033
|
+
return [
|
|
49034
|
+
`the write-back did not run (${error2 instanceof Error ? error2.message : String(error2)})`
|
|
49035
|
+
];
|
|
49036
|
+
}
|
|
49037
|
+
}
|
|
48288
49038
|
async function giveBackChatGptLogin(deps) {
|
|
48289
49039
|
const dirs = deps.codexHome !== void 0 ? { codexHome: deps.codexHome } : {};
|
|
48290
49040
|
const taken = codexHoldsTakenChatGptLogin(deps.home, dirs);
|
|
@@ -48300,6 +49050,13 @@ async function giveBackChatGptLogin(deps) {
|
|
|
48300
49050
|
}
|
|
48301
49051
|
if (held?.kind !== "chatgpt") return "none";
|
|
48302
49052
|
if (!taken) {
|
|
49053
|
+
const owed2 = await owedAfterWriteBack(deps);
|
|
49054
|
+
if (owed2.length > 0) {
|
|
49055
|
+
deps.log(
|
|
49056
|
+
`ChatGPT login give-back: Codex holds its own login, and custody keeps its copy until Oxagen holds ${owed2.join("; ")}`
|
|
49057
|
+
);
|
|
49058
|
+
return "failed";
|
|
49059
|
+
}
|
|
48303
49060
|
try {
|
|
48304
49061
|
deps.release();
|
|
48305
49062
|
} catch (error2) {
|
|
@@ -48330,6 +49087,13 @@ async function giveBackChatGptLogin(deps) {
|
|
|
48330
49087
|
);
|
|
48331
49088
|
return "failed";
|
|
48332
49089
|
}
|
|
49090
|
+
const owed = await owedAfterWriteBack(deps);
|
|
49091
|
+
if (owed.length > 0) {
|
|
49092
|
+
deps.log(
|
|
49093
|
+
`ChatGPT login give-back: wrote auth.json, and custody keeps its copy until Oxagen holds ${owed.join("; ")}`
|
|
49094
|
+
);
|
|
49095
|
+
return "given_back";
|
|
49096
|
+
}
|
|
48333
49097
|
try {
|
|
48334
49098
|
deps.release();
|
|
48335
49099
|
} catch (error2) {
|
|
@@ -48353,6 +49117,176 @@ var init_static_token_renewal = __esm({
|
|
|
48353
49117
|
}
|
|
48354
49118
|
});
|
|
48355
49119
|
|
|
49120
|
+
// ../../packages/tacho/src/host/credential-pool.ts
|
|
49121
|
+
function chatGptTokensFromVault(saved) {
|
|
49122
|
+
let parsed2;
|
|
49123
|
+
try {
|
|
49124
|
+
parsed2 = JSON.parse(saved);
|
|
49125
|
+
} catch {
|
|
49126
|
+
return void 0;
|
|
49127
|
+
}
|
|
49128
|
+
if (parsed2 === null || typeof parsed2 !== "object") return void 0;
|
|
49129
|
+
const outer = parsed2;
|
|
49130
|
+
const inner = outer["tokens"];
|
|
49131
|
+
const tokens = inner !== null && typeof inner === "object" ? inner : outer;
|
|
49132
|
+
const text6 = (key) => {
|
|
49133
|
+
const value = tokens[key];
|
|
49134
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
49135
|
+
};
|
|
49136
|
+
const access2 = text6("access_token");
|
|
49137
|
+
if (access2 === void 0) return void 0;
|
|
49138
|
+
const idToken = text6("id_token");
|
|
49139
|
+
const accountId = text6("account_id") ?? chatGptTokenAccountOf(idToken);
|
|
49140
|
+
return JSON.stringify({
|
|
49141
|
+
access_token: access2,
|
|
49142
|
+
refresh_token: text6("refresh_token") ?? "",
|
|
49143
|
+
...idToken !== void 0 ? { id_token: idToken } : {},
|
|
49144
|
+
...accountId !== void 0 ? { account_id: accountId } : {}
|
|
49145
|
+
});
|
|
49146
|
+
}
|
|
49147
|
+
function chatGptTokenAccountOf(token) {
|
|
49148
|
+
const payload = token?.split(".")[1];
|
|
49149
|
+
if (payload === void 0 || payload.length === 0) return void 0;
|
|
49150
|
+
let claims2;
|
|
49151
|
+
try {
|
|
49152
|
+
claims2 = JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));
|
|
49153
|
+
} catch {
|
|
49154
|
+
return void 0;
|
|
49155
|
+
}
|
|
49156
|
+
if (claims2 === null || typeof claims2 !== "object") return void 0;
|
|
49157
|
+
const auth2 = claims2["https://api.openai.com/auth"];
|
|
49158
|
+
if (auth2 === null || typeof auth2 !== "object") return void 0;
|
|
49159
|
+
const account = auth2["chatgpt_account_id"];
|
|
49160
|
+
return typeof account === "string" && account.length > 0 ? account : void 0;
|
|
49161
|
+
}
|
|
49162
|
+
function poolMemberOf(credential, provider, harness) {
|
|
49163
|
+
if (credential.provider !== provider)
|
|
49164
|
+
return { skipped: `it is a ${credential.provider} credential` };
|
|
49165
|
+
if (credential.status !== "active")
|
|
49166
|
+
return { skipped: `it is ${credential.status}` };
|
|
49167
|
+
let kind;
|
|
49168
|
+
let secret = credential.secret.trim();
|
|
49169
|
+
if (credential.authType === "api_key" && credential.harness === null) {
|
|
49170
|
+
kind = provider === "anthropic" ? anthropicCredentialKind(secret, "api_key") : "bearer";
|
|
49171
|
+
} else if (credential.authType === "subscription_token" && credential.harness === harness && harness === "claude-code" && provider === "anthropic") {
|
|
49172
|
+
kind = "oauth";
|
|
49173
|
+
} else if (credential.authType === "subscription_token" && credential.harness === harness && harness === "codex" && provider === "openai") {
|
|
49174
|
+
const tokens = chatGptTokensFromVault(secret);
|
|
49175
|
+
if (tokens === void 0)
|
|
49176
|
+
return { skipped: "its ChatGPT login holds no access token" };
|
|
49177
|
+
kind = "chatgpt";
|
|
49178
|
+
secret = tokens;
|
|
49179
|
+
} else {
|
|
49180
|
+
return { skipped: `a ${credential.authType} does not serve ${harness}` };
|
|
49181
|
+
}
|
|
49182
|
+
const limitedUntil = credential.limitedUntil === null ? Number.NaN : Date.parse(credential.limitedUntil);
|
|
49183
|
+
return {
|
|
49184
|
+
credential_id: credential.id,
|
|
49185
|
+
kind,
|
|
49186
|
+
secret,
|
|
49187
|
+
hint: credential.hint,
|
|
49188
|
+
...credential.label !== null ? { label: credential.label } : {},
|
|
49189
|
+
...Number.isFinite(limitedUntil) ? { limited_until: limitedUntil } : {},
|
|
49190
|
+
changed_at: credential.rotatedAt ?? credential.createdAt
|
|
49191
|
+
};
|
|
49192
|
+
}
|
|
49193
|
+
function slotTakesPool(store, provider, harness) {
|
|
49194
|
+
const own2 = store.pool(provider, harness).find((member4) => member4.source !== VAULT_POOL_SOURCE);
|
|
49195
|
+
return own2 !== void 0 && own2.source !== "sandbox:launch";
|
|
49196
|
+
}
|
|
49197
|
+
async function syncCredentialPools(deps) {
|
|
49198
|
+
const reports = [];
|
|
49199
|
+
const harnesses = [...new Set(deps.harnesses)].filter(isBrokerableHarness);
|
|
49200
|
+
for (const harness of harnesses) {
|
|
49201
|
+
const provider = BROKERABLE_HARNESS_PROVIDER[harness];
|
|
49202
|
+
let takes;
|
|
49203
|
+
try {
|
|
49204
|
+
takes = slotTakesPool(deps.store, provider, harness);
|
|
49205
|
+
} catch (error2) {
|
|
49206
|
+
const detail = error2 instanceof Error ? error2.message : String(error2);
|
|
49207
|
+
deps.log(
|
|
49208
|
+
`credential pool sync: custody for ${harness} is unreadable, so it was not synced: ${detail}`
|
|
49209
|
+
);
|
|
49210
|
+
reports.push({ harness, synced: false, reason: "fetch_failed", detail });
|
|
49211
|
+
continue;
|
|
49212
|
+
}
|
|
49213
|
+
if (!takes) {
|
|
49214
|
+
reports.push({ harness, synced: false, reason: "not_brokered" });
|
|
49215
|
+
continue;
|
|
49216
|
+
}
|
|
49217
|
+
let credentials2;
|
|
49218
|
+
try {
|
|
49219
|
+
credentials2 = (await deps.client.modelCredentials(harness)).credentials;
|
|
49220
|
+
} catch (error2) {
|
|
49221
|
+
const detail = error2 instanceof ControlError ? controlErrorMessage(error2) : error2 instanceof Error ? error2.message : String(error2);
|
|
49222
|
+
deps.log(
|
|
49223
|
+
`credential pool sync: could not read the credentials saved for ${harness}, so custody keeps what it holds: ${detail}`
|
|
49224
|
+
);
|
|
49225
|
+
reports.push({ harness, synced: false, reason: "fetch_failed", detail });
|
|
49226
|
+
continue;
|
|
49227
|
+
}
|
|
49228
|
+
const members3 = [];
|
|
49229
|
+
for (const credential of credentials2) {
|
|
49230
|
+
const member4 = poolMemberOf(credential, provider, harness);
|
|
49231
|
+
if ("skipped" in member4) {
|
|
49232
|
+
deps.log(
|
|
49233
|
+
`credential pool sync: ${credential.id} does not join ${harness}'s pool: ${member4.skipped}`
|
|
49234
|
+
);
|
|
49235
|
+
continue;
|
|
49236
|
+
}
|
|
49237
|
+
members3.push(member4);
|
|
49238
|
+
}
|
|
49239
|
+
try {
|
|
49240
|
+
const outcome = deps.store.syncPool(
|
|
49241
|
+
provider,
|
|
49242
|
+
harness,
|
|
49243
|
+
members3,
|
|
49244
|
+
deps.now()
|
|
49245
|
+
);
|
|
49246
|
+
if (outcome.synced)
|
|
49247
|
+
deps.log(
|
|
49248
|
+
`credential pool sync: ${harness} holds ${outcome.added + outcome.kept} saved credentials after its own (${outcome.added} added, ${outcome.removed} removed)`
|
|
49249
|
+
);
|
|
49250
|
+
reports.push({ harness, ...outcome });
|
|
49251
|
+
} catch (error2) {
|
|
49252
|
+
const detail = error2 instanceof Error ? error2.message : String(error2);
|
|
49253
|
+
deps.log(
|
|
49254
|
+
`credential pool sync: custody for ${harness} could not be written, so it keeps what it held: ${detail}`
|
|
49255
|
+
);
|
|
49256
|
+
reports.push({ harness, synced: false, reason: "fetch_failed", detail });
|
|
49257
|
+
}
|
|
49258
|
+
}
|
|
49259
|
+
return reports;
|
|
49260
|
+
}
|
|
49261
|
+
function createCredentialStateReporter(deps) {
|
|
49262
|
+
const sent = /* @__PURE__ */ new Map();
|
|
49263
|
+
return (credentialId, report) => {
|
|
49264
|
+
const key = report.state === "invalid" ? `invalid:${report.reason}` : report.state === "limited" ? `limited:${report.scope ?? ""}` : report.state;
|
|
49265
|
+
const at2 = deps.now();
|
|
49266
|
+
const last = sent.get(credentialId);
|
|
49267
|
+
if (last !== void 0 && last.key === key && at2 - last.at < CREDENTIAL_REPORT_REPEAT_MS)
|
|
49268
|
+
return;
|
|
49269
|
+
sent.set(credentialId, { key, at: at2 });
|
|
49270
|
+
void deps.client.reportModelCredential(credentialId, report).catch((error2) => {
|
|
49271
|
+
sent.delete(credentialId);
|
|
49272
|
+
deps.log(
|
|
49273
|
+
`credential pool: could not tell Oxagen that ${credentialId} is ${report.state}: ${error2 instanceof ControlError ? controlErrorMessage(error2) : error2 instanceof Error ? error2.message : String(error2)}`
|
|
49274
|
+
);
|
|
49275
|
+
});
|
|
49276
|
+
};
|
|
49277
|
+
}
|
|
49278
|
+
var CREDENTIAL_POOL_SYNC_MS, CREDENTIAL_REPORT_REPEAT_MS;
|
|
49279
|
+
var init_credential_pool = __esm({
|
|
49280
|
+
"../../packages/tacho/src/host/credential-pool.ts"() {
|
|
49281
|
+
"use strict";
|
|
49282
|
+
init_credential_store();
|
|
49283
|
+
init_control_client();
|
|
49284
|
+
init_wire();
|
|
49285
|
+
CREDENTIAL_POOL_SYNC_MS = 15 * 6e4;
|
|
49286
|
+
CREDENTIAL_REPORT_REPEAT_MS = 6e4;
|
|
49287
|
+
}
|
|
49288
|
+
});
|
|
49289
|
+
|
|
48356
49290
|
// ../../packages/tacho/src/host/chatgpt-refresh.ts
|
|
48357
49291
|
function jwtExpiryMs(token) {
|
|
48358
49292
|
const payload = token.split(".")[1];
|
|
@@ -48366,6 +49300,12 @@ function jwtExpiryMs(token) {
|
|
|
48366
49300
|
return void 0;
|
|
48367
49301
|
}
|
|
48368
49302
|
}
|
|
49303
|
+
function accountOfLogin(login) {
|
|
49304
|
+
return login.account_id ?? chatGptTokenAccountOf(login.access_token);
|
|
49305
|
+
}
|
|
49306
|
+
function accountOfTokens(login) {
|
|
49307
|
+
return chatGptTokenAccountOf(login.access_token) ?? chatGptTokenAccountOf(login.id_token);
|
|
49308
|
+
}
|
|
48369
49309
|
function chatGptLoginDue(login, takenAt, now) {
|
|
48370
49310
|
const exp = jwtExpiryMs(login.access_token);
|
|
48371
49311
|
if (exp !== void 0) return exp - now < CHATGPT_REFRESH_MARGIN_MS;
|
|
@@ -48459,6 +49399,24 @@ function createChatGptRefresher(deps) {
|
|
|
48459
49399
|
const timeoutMs = deps.timeoutMs ?? CHATGPT_REFRESH_TIMEOUT_MS;
|
|
48460
49400
|
const running = /* @__PURE__ */ new Map();
|
|
48461
49401
|
const memberOf2 = (id2) => store.pool(...SLOT).find((member4) => member4.id === id2);
|
|
49402
|
+
const owes = (id2) => store.owedLogins().some(
|
|
49403
|
+
(owed) => owed.provider === SLOT[0] && owed.harness === SLOT[1] && owed.id === id2
|
|
49404
|
+
);
|
|
49405
|
+
async function stillOwed(credentialId) {
|
|
49406
|
+
if (deps.sendOwedFirst === void 0) return void 0;
|
|
49407
|
+
let report;
|
|
49408
|
+
try {
|
|
49409
|
+
report = await deps.sendOwedFirst();
|
|
49410
|
+
} catch (error2) {
|
|
49411
|
+
return `Oxagen has not answered for the tokens this machine refreshed last (the send failed: ${error2 instanceof Error ? error2.message : String(error2)}), so they are not refreshed again until it does`;
|
|
49412
|
+
}
|
|
49413
|
+
if (report.superseded.some((s2) => s2.credential_id === credentialId))
|
|
49414
|
+
return SUPERSEDED;
|
|
49415
|
+
const left = report.owed.find(
|
|
49416
|
+
(owed) => owed.credential_id === credentialId && owed.retryable
|
|
49417
|
+
);
|
|
49418
|
+
return left === void 0 ? void 0 : `Oxagen has not answered for the tokens this machine refreshed last (${left.detail}), so they are not refreshed again until it does`;
|
|
49419
|
+
}
|
|
48462
49420
|
async function refreshOnce(id2) {
|
|
48463
49421
|
const member4 = memberOf2(id2);
|
|
48464
49422
|
if (member4 === void 0 || member4.kind !== "chatgpt")
|
|
@@ -48471,11 +49429,26 @@ function createChatGptRefresher(deps) {
|
|
|
48471
49429
|
outcome: member4.refresh_refused,
|
|
48472
49430
|
detail: `auth.openai.com already refused to refresh these tokens; ${RELOGIN}`
|
|
48473
49431
|
};
|
|
49432
|
+
if (member4.write_back_refused === true)
|
|
49433
|
+
return { outcome: "failed", detail: SUPERSEDED };
|
|
49434
|
+
if (member4.credential_id !== void 0 && owes(id2)) {
|
|
49435
|
+
const waiting2 = await stillOwed(member4.credential_id);
|
|
49436
|
+
if (waiting2 !== void 0) return { outcome: "failed", detail: waiting2 };
|
|
49437
|
+
}
|
|
48474
49438
|
const held = store.open(...SLOT, id2);
|
|
48475
49439
|
const login = held?.kind === "chatgpt" ? decodeChatGptLogin(held.secret) : void 0;
|
|
48476
49440
|
if (login === void 0)
|
|
48477
49441
|
return { outcome: "failed", detail: "custody holds no ChatGPT login" };
|
|
48478
|
-
|
|
49442
|
+
let answer = await exchange(login, deps.fetch, timeoutMs);
|
|
49443
|
+
if ("login" in answer && member4.credential_id !== void 0) {
|
|
49444
|
+
const named2 = accountOfLogin(login);
|
|
49445
|
+
const issued = accountOfTokens(answer.login);
|
|
49446
|
+
if (named2 !== void 0 && issued !== void 0 && named2 !== issued)
|
|
49447
|
+
answer = {
|
|
49448
|
+
outcome: "refused",
|
|
49449
|
+
detail: `auth.openai.com answered the refresh with tokens for another ChatGPT account, so none were kept; ${RELOGIN}`
|
|
49450
|
+
};
|
|
49451
|
+
}
|
|
48479
49452
|
if (!("login" in answer)) {
|
|
48480
49453
|
if (answer.outcome !== "failed")
|
|
48481
49454
|
store.markFailed(
|
|
@@ -48512,22 +49485,38 @@ function createChatGptRefresher(deps) {
|
|
|
48512
49485
|
running.set(id2, started);
|
|
48513
49486
|
return started;
|
|
48514
49487
|
}
|
|
49488
|
+
const chatGptLogins = () => store.pool(...SLOT).filter((member4) => member4.kind === "chatgpt");
|
|
49489
|
+
function due(member4) {
|
|
49490
|
+
if (member4.refresh_refused !== void 0) return false;
|
|
49491
|
+
const held = store.open(...SLOT, member4.id);
|
|
49492
|
+
const login = held?.kind === "chatgpt" ? decodeChatGptLogin(held.secret) : void 0;
|
|
49493
|
+
if (login === void 0) return void 0;
|
|
49494
|
+
return member4.failure !== void 0 && isTokenRefused(member4.failure.kind) || chatGptLoginDue(login, Date.parse(member4.taken_at), deps.now());
|
|
49495
|
+
}
|
|
48515
49496
|
async function refreshDue() {
|
|
48516
|
-
|
|
49497
|
+
let logins = chatGptLogins();
|
|
48517
49498
|
if (logins.length === 0) return "none";
|
|
49499
|
+
if (deps.syncFirst !== void 0 && logins.some(
|
|
49500
|
+
(member4) => member4.credential_id !== void 0 && due(member4) === true
|
|
49501
|
+
)) {
|
|
49502
|
+
try {
|
|
49503
|
+
await deps.syncFirst();
|
|
49504
|
+
} catch {
|
|
49505
|
+
}
|
|
49506
|
+
logins = chatGptLogins();
|
|
49507
|
+
if (logins.length === 0) return "none";
|
|
49508
|
+
}
|
|
48518
49509
|
let refreshed = 0;
|
|
48519
49510
|
const failed5 = [];
|
|
48520
49511
|
for (const member4 of logins) {
|
|
48521
49512
|
const name2 = logins.length === 1 ? "" : `${member4.hint !== void 0 ? `\u2026${member4.hint}` : member4.id}: `;
|
|
48522
49513
|
if (member4.refresh_refused !== void 0) continue;
|
|
48523
|
-
const
|
|
48524
|
-
|
|
48525
|
-
if (login === void 0) {
|
|
49514
|
+
const isDue = due(member4);
|
|
49515
|
+
if (isDue === void 0) {
|
|
48526
49516
|
failed5.push(`${name2}custody holds no ChatGPT login`);
|
|
48527
49517
|
continue;
|
|
48528
49518
|
}
|
|
48529
|
-
|
|
48530
|
-
if (!due) continue;
|
|
49519
|
+
if (!isDue) continue;
|
|
48531
49520
|
const result2 = await refresh(member4.id);
|
|
48532
49521
|
if (result2.outcome === "refreshed") refreshed += 1;
|
|
48533
49522
|
else failed5.push(`${name2}${result2.detail}`);
|
|
@@ -48537,11 +49526,12 @@ function createChatGptRefresher(deps) {
|
|
|
48537
49526
|
}
|
|
48538
49527
|
return { refresh, refreshDue };
|
|
48539
49528
|
}
|
|
48540
|
-
var CODEX_OAUTH_CLIENT_ID, CHATGPT_TOKEN_URL, CHATGPT_REFRESH_MARGIN_MS, CHATGPT_REFRESH_MAX_AGE_MS, CHATGPT_REFRESH_TIMEOUT_MS, ROTATED_REFRESH_CODES, RELOGIN, SLOT;
|
|
49529
|
+
var CODEX_OAUTH_CLIENT_ID, CHATGPT_TOKEN_URL, CHATGPT_REFRESH_MARGIN_MS, CHATGPT_REFRESH_MAX_AGE_MS, CHATGPT_REFRESH_TIMEOUT_MS, ROTATED_REFRESH_CODES, RELOGIN, SLOT, SUPERSEDED;
|
|
48541
49530
|
var init_chatgpt_refresh = __esm({
|
|
48542
49531
|
"../../packages/tacho/src/host/chatgpt-refresh.ts"() {
|
|
48543
49532
|
"use strict";
|
|
48544
49533
|
init_model_failure();
|
|
49534
|
+
init_credential_pool();
|
|
48545
49535
|
init_model_credential();
|
|
48546
49536
|
CODEX_OAUTH_CLIENT_ID = "app_EMoamEEZ73f0CkXaXp7hrann";
|
|
48547
49537
|
CHATGPT_TOKEN_URL = "https://auth.openai.com/oauth/token";
|
|
@@ -48554,176 +49544,7 @@ var init_chatgpt_refresh = __esm({
|
|
|
48554
49544
|
]);
|
|
48555
49545
|
RELOGIN = "run `codex login`, then `oxagen agent enroll`";
|
|
48556
49546
|
SLOT = ["openai", "codex"];
|
|
48557
|
-
|
|
48558
|
-
});
|
|
48559
|
-
|
|
48560
|
-
// ../../packages/tacho/src/host/credential-pool.ts
|
|
48561
|
-
function chatGptTokensFromVault(saved) {
|
|
48562
|
-
let parsed2;
|
|
48563
|
-
try {
|
|
48564
|
-
parsed2 = JSON.parse(saved);
|
|
48565
|
-
} catch {
|
|
48566
|
-
return void 0;
|
|
48567
|
-
}
|
|
48568
|
-
if (parsed2 === null || typeof parsed2 !== "object") return void 0;
|
|
48569
|
-
const outer = parsed2;
|
|
48570
|
-
const inner = outer["tokens"];
|
|
48571
|
-
const tokens = inner !== null && typeof inner === "object" ? inner : outer;
|
|
48572
|
-
const text6 = (key) => {
|
|
48573
|
-
const value = tokens[key];
|
|
48574
|
-
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
48575
|
-
};
|
|
48576
|
-
const access2 = text6("access_token");
|
|
48577
|
-
if (access2 === void 0) return void 0;
|
|
48578
|
-
const idToken = text6("id_token");
|
|
48579
|
-
const accountId = text6("account_id") ?? accountOfIdToken(idToken);
|
|
48580
|
-
return JSON.stringify({
|
|
48581
|
-
access_token: access2,
|
|
48582
|
-
refresh_token: text6("refresh_token") ?? "",
|
|
48583
|
-
...idToken !== void 0 ? { id_token: idToken } : {},
|
|
48584
|
-
...accountId !== void 0 ? { account_id: accountId } : {}
|
|
48585
|
-
});
|
|
48586
|
-
}
|
|
48587
|
-
function accountOfIdToken(idToken) {
|
|
48588
|
-
const payload = idToken?.split(".")[1];
|
|
48589
|
-
if (payload === void 0 || payload.length === 0) return void 0;
|
|
48590
|
-
let claims2;
|
|
48591
|
-
try {
|
|
48592
|
-
claims2 = JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));
|
|
48593
|
-
} catch {
|
|
48594
|
-
return void 0;
|
|
48595
|
-
}
|
|
48596
|
-
if (claims2 === null || typeof claims2 !== "object") return void 0;
|
|
48597
|
-
const auth2 = claims2["https://api.openai.com/auth"];
|
|
48598
|
-
if (auth2 === null || typeof auth2 !== "object") return void 0;
|
|
48599
|
-
const account = auth2["chatgpt_account_id"];
|
|
48600
|
-
return typeof account === "string" && account.length > 0 ? account : void 0;
|
|
48601
|
-
}
|
|
48602
|
-
function poolMemberOf(credential, provider, harness) {
|
|
48603
|
-
if (credential.provider !== provider)
|
|
48604
|
-
return { skipped: `it is a ${credential.provider} credential` };
|
|
48605
|
-
if (credential.status !== "active")
|
|
48606
|
-
return { skipped: `it is ${credential.status}` };
|
|
48607
|
-
let kind;
|
|
48608
|
-
let secret = credential.secret.trim();
|
|
48609
|
-
if (credential.authType === "api_key" && credential.harness === null) {
|
|
48610
|
-
kind = provider === "anthropic" ? anthropicCredentialKind(secret, "api_key") : "bearer";
|
|
48611
|
-
} else if (credential.authType === "subscription_token" && credential.harness === harness && harness === "claude-code" && provider === "anthropic") {
|
|
48612
|
-
kind = "oauth";
|
|
48613
|
-
} else if (credential.authType === "subscription_token" && credential.harness === harness && harness === "codex" && provider === "openai") {
|
|
48614
|
-
const tokens = chatGptTokensFromVault(secret);
|
|
48615
|
-
if (tokens === void 0)
|
|
48616
|
-
return { skipped: "its ChatGPT login holds no access token" };
|
|
48617
|
-
kind = "chatgpt";
|
|
48618
|
-
secret = tokens;
|
|
48619
|
-
} else {
|
|
48620
|
-
return { skipped: `a ${credential.authType} does not serve ${harness}` };
|
|
48621
|
-
}
|
|
48622
|
-
const limitedUntil = credential.limitedUntil === null ? Number.NaN : Date.parse(credential.limitedUntil);
|
|
48623
|
-
return {
|
|
48624
|
-
credential_id: credential.id,
|
|
48625
|
-
kind,
|
|
48626
|
-
secret,
|
|
48627
|
-
hint: credential.hint,
|
|
48628
|
-
...credential.label !== null ? { label: credential.label } : {},
|
|
48629
|
-
...Number.isFinite(limitedUntil) ? { limited_until: limitedUntil } : {},
|
|
48630
|
-
changed_at: credential.rotatedAt ?? credential.createdAt
|
|
48631
|
-
};
|
|
48632
|
-
}
|
|
48633
|
-
function slotTakesPool(store, provider, harness) {
|
|
48634
|
-
const own2 = store.pool(provider, harness).find((member4) => member4.source !== VAULT_POOL_SOURCE);
|
|
48635
|
-
return own2 !== void 0 && own2.source !== "sandbox:launch";
|
|
48636
|
-
}
|
|
48637
|
-
async function syncCredentialPools(deps) {
|
|
48638
|
-
const reports = [];
|
|
48639
|
-
const harnesses = [...new Set(deps.harnesses)].filter(isBrokerableHarness);
|
|
48640
|
-
for (const harness of harnesses) {
|
|
48641
|
-
const provider = BROKERABLE_HARNESS_PROVIDER[harness];
|
|
48642
|
-
let takes;
|
|
48643
|
-
try {
|
|
48644
|
-
takes = slotTakesPool(deps.store, provider, harness);
|
|
48645
|
-
} catch (error2) {
|
|
48646
|
-
const detail = error2 instanceof Error ? error2.message : String(error2);
|
|
48647
|
-
deps.log(
|
|
48648
|
-
`credential pool sync: custody for ${harness} is unreadable, so it was not synced: ${detail}`
|
|
48649
|
-
);
|
|
48650
|
-
reports.push({ harness, synced: false, reason: "fetch_failed", detail });
|
|
48651
|
-
continue;
|
|
48652
|
-
}
|
|
48653
|
-
if (!takes) {
|
|
48654
|
-
reports.push({ harness, synced: false, reason: "not_brokered" });
|
|
48655
|
-
continue;
|
|
48656
|
-
}
|
|
48657
|
-
let credentials2;
|
|
48658
|
-
try {
|
|
48659
|
-
credentials2 = (await deps.client.modelCredentials(harness)).credentials;
|
|
48660
|
-
} catch (error2) {
|
|
48661
|
-
const detail = error2 instanceof ControlError ? controlErrorMessage(error2) : error2 instanceof Error ? error2.message : String(error2);
|
|
48662
|
-
deps.log(
|
|
48663
|
-
`credential pool sync: could not read the credentials saved for ${harness}, so custody keeps what it holds: ${detail}`
|
|
48664
|
-
);
|
|
48665
|
-
reports.push({ harness, synced: false, reason: "fetch_failed", detail });
|
|
48666
|
-
continue;
|
|
48667
|
-
}
|
|
48668
|
-
const members3 = [];
|
|
48669
|
-
for (const credential of credentials2) {
|
|
48670
|
-
const member4 = poolMemberOf(credential, provider, harness);
|
|
48671
|
-
if ("skipped" in member4) {
|
|
48672
|
-
deps.log(
|
|
48673
|
-
`credential pool sync: ${credential.id} does not join ${harness}'s pool: ${member4.skipped}`
|
|
48674
|
-
);
|
|
48675
|
-
continue;
|
|
48676
|
-
}
|
|
48677
|
-
members3.push(member4);
|
|
48678
|
-
}
|
|
48679
|
-
try {
|
|
48680
|
-
const outcome = deps.store.syncPool(
|
|
48681
|
-
provider,
|
|
48682
|
-
harness,
|
|
48683
|
-
members3,
|
|
48684
|
-
deps.now()
|
|
48685
|
-
);
|
|
48686
|
-
if (outcome.synced)
|
|
48687
|
-
deps.log(
|
|
48688
|
-
`credential pool sync: ${harness} holds ${outcome.added + outcome.kept} saved credentials after its own (${outcome.added} added, ${outcome.removed} removed)`
|
|
48689
|
-
);
|
|
48690
|
-
reports.push({ harness, ...outcome });
|
|
48691
|
-
} catch (error2) {
|
|
48692
|
-
const detail = error2 instanceof Error ? error2.message : String(error2);
|
|
48693
|
-
deps.log(
|
|
48694
|
-
`credential pool sync: custody for ${harness} could not be written, so it keeps what it held: ${detail}`
|
|
48695
|
-
);
|
|
48696
|
-
reports.push({ harness, synced: false, reason: "fetch_failed", detail });
|
|
48697
|
-
}
|
|
48698
|
-
}
|
|
48699
|
-
return reports;
|
|
48700
|
-
}
|
|
48701
|
-
function createCredentialStateReporter(deps) {
|
|
48702
|
-
const sent = /* @__PURE__ */ new Map();
|
|
48703
|
-
return (credentialId, report) => {
|
|
48704
|
-
const key = report.state === "invalid" ? `invalid:${report.reason}` : report.state === "limited" ? `limited:${report.scope ?? ""}` : report.state;
|
|
48705
|
-
const at2 = deps.now();
|
|
48706
|
-
const last = sent.get(credentialId);
|
|
48707
|
-
if (last !== void 0 && last.key === key && at2 - last.at < CREDENTIAL_REPORT_REPEAT_MS)
|
|
48708
|
-
return;
|
|
48709
|
-
sent.set(credentialId, { key, at: at2 });
|
|
48710
|
-
void deps.client.reportModelCredential(credentialId, report).catch((error2) => {
|
|
48711
|
-
sent.delete(credentialId);
|
|
48712
|
-
deps.log(
|
|
48713
|
-
`credential pool: could not tell Oxagen that ${credentialId} is ${report.state}: ${error2 instanceof ControlError ? controlErrorMessage(error2) : error2 instanceof Error ? error2.message : String(error2)}`
|
|
48714
|
-
);
|
|
48715
|
-
});
|
|
48716
|
-
};
|
|
48717
|
-
}
|
|
48718
|
-
var CREDENTIAL_POOL_SYNC_MS, CREDENTIAL_REPORT_REPEAT_MS;
|
|
48719
|
-
var init_credential_pool = __esm({
|
|
48720
|
-
"../../packages/tacho/src/host/credential-pool.ts"() {
|
|
48721
|
-
"use strict";
|
|
48722
|
-
init_credential_store();
|
|
48723
|
-
init_control_client();
|
|
48724
|
-
init_wire();
|
|
48725
|
-
CREDENTIAL_POOL_SYNC_MS = 15 * 6e4;
|
|
48726
|
-
CREDENTIAL_REPORT_REPEAT_MS = 6e4;
|
|
49547
|
+
SUPERSEDED = "Oxagen holds a newer copy of this saved login, so this machine takes that copy at its next sync and does not refresh its own";
|
|
48727
49548
|
}
|
|
48728
49549
|
});
|
|
48729
49550
|
|
|
@@ -49761,7 +50582,7 @@ function staffingArgs(harness, staffing) {
|
|
|
49761
50582
|
function isFinalRefusal(error2) {
|
|
49762
50583
|
return error2.status >= 400 && error2.status < 500 && error2.status !== 408 && error2.status !== 429;
|
|
49763
50584
|
}
|
|
49764
|
-
function
|
|
50585
|
+
function messageOf3(error2) {
|
|
49765
50586
|
if (error2 instanceof ControlError) return controlErrorMessage(error2);
|
|
49766
50587
|
return error2 instanceof Error ? error2.message : String(error2);
|
|
49767
50588
|
}
|
|
@@ -49779,7 +50600,7 @@ async function claimForStart(client, host, id2) {
|
|
|
49779
50600
|
};
|
|
49780
50601
|
if (error2 instanceof ControlUnreachable)
|
|
49781
50602
|
return { kind: "unreachable", message: error2.message };
|
|
49782
|
-
return { kind: "unreadable", message:
|
|
50603
|
+
return { kind: "unreadable", message: messageOf3(error2) };
|
|
49783
50604
|
}
|
|
49784
50605
|
const harness = claim2.work_order.harness;
|
|
49785
50606
|
if (!isWrappedHarness(harness) || !host.harnesses.includes(harness)) {
|
|
@@ -49809,7 +50630,7 @@ async function refuseWorkOrder(client, id2, reason4) {
|
|
|
49809
50630
|
await client.rejectWorkOrder(id2, reason4);
|
|
49810
50631
|
return void 0;
|
|
49811
50632
|
} catch (error2) {
|
|
49812
|
-
return
|
|
50633
|
+
return messageOf3(error2);
|
|
49813
50634
|
}
|
|
49814
50635
|
}
|
|
49815
50636
|
function spawnRefusalReason(binary, error2) {
|
|
@@ -60775,7 +61596,7 @@ import { isAbsolute as isAbsolute14 } from "node:path";
|
|
|
60775
61596
|
function isCodeGraphRoute(value) {
|
|
60776
61597
|
return CODE_GRAPH_ROUTES.includes(value);
|
|
60777
61598
|
}
|
|
60778
|
-
function
|
|
61599
|
+
function messageOf4(error2) {
|
|
60779
61600
|
return error2 instanceof Error ? error2.message : String(error2);
|
|
60780
61601
|
}
|
|
60781
61602
|
async function answerCodeGraphRoute(codegraph, route, body2) {
|
|
@@ -60793,7 +61614,7 @@ async function answerCodeGraphRoute(codegraph, route, body2) {
|
|
|
60793
61614
|
} catch (error2) {
|
|
60794
61615
|
return {
|
|
60795
61616
|
status: 503,
|
|
60796
|
-
body: { error:
|
|
61617
|
+
body: { error: messageOf4(error2), supervisor: codegraph.describe() }
|
|
60797
61618
|
};
|
|
60798
61619
|
}
|
|
60799
61620
|
}
|
|
@@ -60814,7 +61635,7 @@ async function answerCodeGraphRoute(codegraph, route, body2) {
|
|
|
60814
61635
|
} catch (error2) {
|
|
60815
61636
|
return {
|
|
60816
61637
|
status: 503,
|
|
60817
|
-
body: { error:
|
|
61638
|
+
body: { error: messageOf4(error2), supervisor: codegraph.describe() }
|
|
60818
61639
|
};
|
|
60819
61640
|
}
|
|
60820
61641
|
}
|
|
@@ -69426,7 +70247,10 @@ function cloudGatewayCredentialStore(disk, runToken) {
|
|
|
69426
70247
|
markFailed: () => false,
|
|
69427
70248
|
clearFailure: () => false,
|
|
69428
70249
|
replaceSecret: () => false,
|
|
69429
|
-
syncPool: () => ({ synced: false, reason: "sandbox" })
|
|
70250
|
+
syncPool: () => ({ synced: false, reason: "sandbox" }),
|
|
70251
|
+
// No pool, so no saved login is ever refreshed here.
|
|
70252
|
+
owedLogins: () => [],
|
|
70253
|
+
settleWriteBack: () => false
|
|
69430
70254
|
};
|
|
69431
70255
|
}
|
|
69432
70256
|
function readTextOrUndefined(path2) {
|
|
@@ -72196,12 +73020,26 @@ async function initializeDaemon(options, server, port, ready, clock2) {
|
|
|
72196
73020
|
now,
|
|
72197
73021
|
log
|
|
72198
73022
|
});
|
|
73023
|
+
const loginWriteBack = createLoginWriteBack({
|
|
73024
|
+
store: credentialStore,
|
|
73025
|
+
client,
|
|
73026
|
+
now,
|
|
73027
|
+
log
|
|
73028
|
+
});
|
|
72199
73029
|
const chatGptRefresher = createChatGptRefresher({
|
|
72200
73030
|
store: credentialStore,
|
|
72201
73031
|
fetch: options.fetch ?? fetch,
|
|
72202
73032
|
now,
|
|
73033
|
+
// Another machine may have refreshed a saved login since the last sync.
|
|
73034
|
+
// Its tokens are taken from the vault before this one spends a refresh
|
|
73035
|
+
// token that machine already used.
|
|
73036
|
+
syncFirst: () => syncPools(),
|
|
73037
|
+
// Tokens refreshed last go to Oxagen before the login is refreshed
|
|
73038
|
+
// again, so a lost answer never leaves newer tokens on an old base.
|
|
73039
|
+
sendOwedFirst: () => loginWriteBack.drain(),
|
|
72203
73040
|
refreshed: (member4) => {
|
|
72204
73041
|
if (member4.credential_id === void 0) return;
|
|
73042
|
+
void loginWriteBack.drain();
|
|
72205
73043
|
if (member4.failure !== void 0 && Date.parse(member4.failure.until) > now())
|
|
72206
73044
|
return;
|
|
72207
73045
|
reportCredentialState(member4.credential_id, { state: "recovered" });
|
|
@@ -73313,6 +74151,7 @@ async function initializeDaemon(options, server, port, ready, clock2) {
|
|
|
73313
74151
|
}
|
|
73314
74152
|
let lastStaticRenewalAt = 0;
|
|
73315
74153
|
let lastLoginRefreshAt = 0;
|
|
74154
|
+
let lastGiveBackLine;
|
|
73316
74155
|
async function renewStaticTokens() {
|
|
73317
74156
|
const harnesses = STATIC_TOKEN_HARNESSES.filter(
|
|
73318
74157
|
(h) => host.harnesses.includes(h)
|
|
@@ -73324,12 +74163,23 @@ async function initializeDaemon(options, server, port, ready, clock2) {
|
|
|
73324
74163
|
home: options.home ?? homedir9(),
|
|
73325
74164
|
...codexDirs,
|
|
73326
74165
|
read: () => credentialStore.read("openai", "codex"),
|
|
74166
|
+
// A release drops the saved logins in Codex's slot too, so each one
|
|
74167
|
+
// this machine refreshed goes to Oxagen first (#8795).
|
|
74168
|
+
writeBack: async () => owedIn(await loginWriteBack.drain(), {
|
|
74169
|
+
provider: "openai",
|
|
74170
|
+
harness: "codex"
|
|
74171
|
+
}).map(describeOwedLogin),
|
|
73327
74172
|
release: () => {
|
|
73328
74173
|
credentialStore.release("openai", "codex");
|
|
73329
74174
|
},
|
|
73330
|
-
|
|
74175
|
+
// The pass runs on every tick, so a line it repeats is logged once.
|
|
74176
|
+
log: (line) => {
|
|
74177
|
+
if (line === lastGiveBackLine) return;
|
|
74178
|
+
lastGiveBackLine = line;
|
|
74179
|
+
log(line);
|
|
74180
|
+
}
|
|
73331
74181
|
});
|
|
73332
|
-
if (harnesses.includes("codex") && now() - lastLoginRefreshAt >= CHATGPT_LOGIN_CHECK_MS && mayRefreshChatGptCustody(options.home ?? homedir9(), codexDirs)) {
|
|
74182
|
+
if (harnesses.includes("codex") && now() - lastLoginRefreshAt >= CHATGPT_LOGIN_CHECK_MS && host.host_status !== "revoked" && host.host_status !== "suspended" && mayRefreshChatGptCustody(options.home ?? homedir9(), codexDirs)) {
|
|
73333
74183
|
lastLoginRefreshAt = now();
|
|
73334
74184
|
try {
|
|
73335
74185
|
const refreshed = await chatGptRefresher.refreshDue();
|
|
@@ -73361,6 +74211,7 @@ async function initializeDaemon(options, server, port, ready, clock2) {
|
|
|
73361
74211
|
async function syncPools() {
|
|
73362
74212
|
if (options.cloudGateway !== void 0) return [];
|
|
73363
74213
|
lastPoolSyncAt = now();
|
|
74214
|
+
await loginWriteBack.drain();
|
|
73364
74215
|
const served2 = [];
|
|
73365
74216
|
for (const harness of host.harnesses) {
|
|
73366
74217
|
const route = POOL_ROUTES[harness];
|
|
@@ -73385,10 +74236,15 @@ async function initializeDaemon(options, server, port, ready, clock2) {
|
|
|
73385
74236
|
if (now() - lastPoolSyncAt < CREDENTIAL_POOL_SYNC_MS) return;
|
|
73386
74237
|
await syncPools();
|
|
73387
74238
|
}
|
|
74239
|
+
async function writeBackLogins() {
|
|
74240
|
+
if (options.cloudGateway !== void 0) return;
|
|
74241
|
+
await loginWriteBack.drain();
|
|
74242
|
+
}
|
|
73388
74243
|
async function tick() {
|
|
73389
74244
|
await controlTick();
|
|
73390
74245
|
await renewCertificate();
|
|
73391
74246
|
await renewStaticTokens();
|
|
74247
|
+
await writeBackLogins();
|
|
73392
74248
|
await syncPoolsWhenDue();
|
|
73393
74249
|
await gitLane;
|
|
73394
74250
|
}
|
|
@@ -73400,7 +74256,7 @@ async function initializeDaemon(options, server, port, ready, clock2) {
|
|
|
73400
74256
|
if (pendingSessionEnds.size > 0) void startGitReads();
|
|
73401
74257
|
if (ticking) return;
|
|
73402
74258
|
ticking = true;
|
|
73403
|
-
controlTick().then(() => renewCertificate()).then(() => renewStaticTokens()).then(() => syncPoolsWhenDue()).catch((error2) => {
|
|
74259
|
+
controlTick().then(() => renewCertificate()).then(() => renewStaticTokens()).then(() => writeBackLogins()).then(() => syncPoolsWhenDue()).catch((error2) => {
|
|
73404
74260
|
const code = error2 instanceof Error && "code" in error2 ? ` [${String(error2.code)}]` : "";
|
|
73405
74261
|
const site = error2 instanceof Error && typeof error2.stack === "string" ? error2.stack.split("\n")[1]?.trim() ?? "" : "";
|
|
73406
74262
|
log(
|
|
@@ -73696,6 +74552,7 @@ var init_daemon = __esm({
|
|
|
73696
74552
|
init_static_token_renewal();
|
|
73697
74553
|
init_chatgpt_refresh();
|
|
73698
74554
|
init_credential_pool();
|
|
74555
|
+
init_login_write_back();
|
|
73699
74556
|
init_run_token();
|
|
73700
74557
|
init_process_scan();
|
|
73701
74558
|
init_retention();
|
|
@@ -74331,7 +75188,7 @@ function workOrderTokenFrom(deps, command2) {
|
|
|
74331
75188
|
);
|
|
74332
75189
|
return token;
|
|
74333
75190
|
}
|
|
74334
|
-
function
|
|
75191
|
+
function messageOf5(error2) {
|
|
74335
75192
|
if (error2 instanceof ControlError) return controlErrorMessage(error2);
|
|
74336
75193
|
return error2 instanceof Error ? error2.message : String(error2);
|
|
74337
75194
|
}
|
|
@@ -74525,7 +75382,7 @@ function runProofCommand(command2, cwd, timeoutMs = PROOF_COMMAND_TIMEOUT_MS) {
|
|
|
74525
75382
|
windowsHide: true
|
|
74526
75383
|
});
|
|
74527
75384
|
} catch (error2) {
|
|
74528
|
-
resolve29({ exitCode: -1, durationMs: 0, output:
|
|
75385
|
+
resolve29({ exitCode: -1, durationMs: 0, output: messageOf5(error2) });
|
|
74529
75386
|
return;
|
|
74530
75387
|
}
|
|
74531
75388
|
let timedOut = false;
|
|
@@ -74553,7 +75410,7 @@ function runProofCommand(command2, cwd, timeoutMs = PROOF_COMMAND_TIMEOUT_MS) {
|
|
|
74553
75410
|
resolve29({ exitCode, durationMs: Date.now() - started, output: output2 });
|
|
74554
75411
|
};
|
|
74555
75412
|
child.on("error", (error2) => {
|
|
74556
|
-
hold(Buffer.from(
|
|
75413
|
+
hold(Buffer.from(messageOf5(error2)));
|
|
74557
75414
|
settle5(-1);
|
|
74558
75415
|
});
|
|
74559
75416
|
child.on("close", (code) => {
|
|
@@ -74775,7 +75632,7 @@ ${last}`}`
|
|
|
74775
75632
|
);
|
|
74776
75633
|
else
|
|
74777
75634
|
deps.err(
|
|
74778
|
-
`Could not read Oxagen's answer to the claim on ${criterionId}. Run this command again. The same claim on the same commit records nothing new. (${
|
|
75635
|
+
`Could not read Oxagen's answer to the claim on ${criterionId}. Run this command again. The same claim on the same commit records nothing new. (${messageOf5(error2)})`
|
|
74779
75636
|
);
|
|
74780
75637
|
return 1;
|
|
74781
75638
|
}
|
|
@@ -74833,7 +75690,7 @@ async function workChecklist(options, deps) {
|
|
|
74833
75690
|
answer = await client.readWorkOrderChecklist(run3.workOrderId, token);
|
|
74834
75691
|
} catch (error2) {
|
|
74835
75692
|
deps.err(
|
|
74836
|
-
error2 instanceof ControlUnreachable ? `Could not reach Oxagen to read the checklist of ${run3.workOrderId}. Run this command again once this machine is online. (${error2.message})` : `Oxagen did not answer with the checklist of ${run3.workOrderId}. ${
|
|
75693
|
+
error2 instanceof ControlUnreachable ? `Could not reach Oxagen to read the checklist of ${run3.workOrderId}. Run this command again once this machine is online. (${error2.message})` : `Oxagen did not answer with the checklist of ${run3.workOrderId}. ${messageOf5(error2)}`
|
|
74837
75694
|
);
|
|
74838
75695
|
return 1;
|
|
74839
75696
|
}
|
|
@@ -74946,7 +75803,7 @@ async function workProgress(options, deps) {
|
|
|
74946
75803
|
);
|
|
74947
75804
|
else
|
|
74948
75805
|
deps.err(
|
|
74949
|
-
`Could not read Oxagen's answer to the progress update. Wait a minute, then run this command again. (${
|
|
75806
|
+
`Could not read Oxagen's answer to the progress update. Wait a minute, then run this command again. (${messageOf5(error2)})`
|
|
74950
75807
|
);
|
|
74951
75808
|
return 1;
|
|
74952
75809
|
}
|
|
@@ -75040,7 +75897,7 @@ function planWorkspaceSwitch(home, target, isAlive = processIsAlive) {
|
|
|
75040
75897
|
running
|
|
75041
75898
|
};
|
|
75042
75899
|
}
|
|
75043
|
-
function
|
|
75900
|
+
function messageOf6(error2) {
|
|
75044
75901
|
if (error2 instanceof ControlError) return controlErrorMessage(error2);
|
|
75045
75902
|
return error2 instanceof Error ? error2.message : String(error2);
|
|
75046
75903
|
}
|
|
@@ -75124,7 +75981,7 @@ async function switchLocked(home, target, options) {
|
|
|
75124
75981
|
outcomes.push({
|
|
75125
75982
|
...described(agent.host),
|
|
75126
75983
|
state: "failed",
|
|
75127
|
-
message:
|
|
75984
|
+
message: messageOf6(error2)
|
|
75128
75985
|
});
|
|
75129
75986
|
}
|
|
75130
75987
|
}
|
|
@@ -75141,7 +75998,7 @@ async function switchLocked(home, target, options) {
|
|
|
75141
75998
|
endedSends: answer.ended_sends
|
|
75142
75999
|
});
|
|
75143
76000
|
} catch (error2) {
|
|
75144
|
-
const message2 =
|
|
76001
|
+
const message2 = messageOf6(error2);
|
|
75145
76002
|
refused3.push(`${agent.host.agent_key}: ${message2}`);
|
|
75146
76003
|
outcomes.push({ ...described(agent.host), state: "failed", message: message2 });
|
|
75147
76004
|
}
|
|
@@ -75244,7 +76101,7 @@ async function standByOutsideConnection(home, options = {}) {
|
|
|
75244
76101
|
failed5.push({
|
|
75245
76102
|
...described(agent.host),
|
|
75246
76103
|
state: "failed",
|
|
75247
|
-
message:
|
|
76104
|
+
message: messageOf6(error2)
|
|
75248
76105
|
});
|
|
75249
76106
|
}
|
|
75250
76107
|
}
|
|
@@ -75799,8 +76656,10 @@ __export(cli_exports, {
|
|
|
75799
76656
|
heldBodiesOf: () => heldBodiesOf,
|
|
75800
76657
|
isNativeBuild: () => isNativeBuild,
|
|
75801
76658
|
launchSandboxFromEnv: () => launchSandboxFromEnv,
|
|
76659
|
+
lostLoginWarning: () => lostLoginWarning,
|
|
75802
76660
|
needsClaudeCodeMcp: () => needsClaudeCodeMcp,
|
|
75803
76661
|
observedTiers: () => observedTiers,
|
|
76662
|
+
owedBeforeRelease: () => owedBeforeRelease,
|
|
75804
76663
|
oxagenRuntimeCommands: () => oxagenRuntimeCommands,
|
|
75805
76664
|
parseCredentialMode: () => parseCredentialMode,
|
|
75806
76665
|
parseHarnesses: () => parseHarnesses,
|
|
@@ -81403,7 +82262,7 @@ var init_package = __esm({
|
|
|
81403
82262
|
"package.json"() {
|
|
81404
82263
|
package_default = {
|
|
81405
82264
|
name: "@oxagen/cli",
|
|
81406
|
-
version: "5.5.1-
|
|
82265
|
+
version: "5.5.1-278",
|
|
81407
82266
|
description: "Oxagen governance CLI: spend, source tracking, grounding, credentials, and audit (agentic coding lives in the stella CLI)",
|
|
81408
82267
|
type: "module",
|
|
81409
82268
|
main: "./dist/index.js",
|
|
@@ -102854,6 +103713,7 @@ __export(host_exports, {
|
|
|
102854
103713
|
HTTP_HOOK_EVENTS: () => HTTP_HOOK_EVENTS,
|
|
102855
103714
|
LEGACY_CREATED_WANTS_MARK: () => LEGACY_CREATED_WANTS_MARK,
|
|
102856
103715
|
LOGIN_REFRESH_REFUSALS: () => LOGIN_REFRESH_REFUSALS,
|
|
103716
|
+
LOGIN_WRITE_BACK_STATES: () => LOGIN_WRITE_BACK_STATES,
|
|
102857
103717
|
REQUEST_SIGNATURE_DOMAIN: () => REQUEST_SIGNATURE_DOMAIN,
|
|
102858
103718
|
REQUEST_SIGNATURE_HEADER: () => REQUEST_SIGNATURE_HEADER,
|
|
102859
103719
|
REQUEST_SIGNATURE_MAX_SKEW_S: () => REQUEST_SIGNATURE_MAX_SKEW_S,
|
|
@@ -108332,14 +109192,14 @@ function formatDollars(micros2) {
|
|
|
108332
109192
|
function formatCount(count15) {
|
|
108333
109193
|
return Number.isInteger(count15) ? String(count15) : count15.toFixed(1);
|
|
108334
109194
|
}
|
|
108335
|
-
function
|
|
109195
|
+
function nameOf2(group) {
|
|
108336
109196
|
const { name: name2, number: itemNumber } = group.display;
|
|
108337
109197
|
if (name2 === null) return SPECIAL_NAMES[group.key] ?? group.key;
|
|
108338
109198
|
return itemNumber ? `${itemNumber} ${name2}` : name2;
|
|
108339
109199
|
}
|
|
108340
109200
|
function namesByKey(groups) {
|
|
108341
109201
|
const names2 = /* @__PURE__ */ new Map();
|
|
108342
|
-
for (const group of groups) names2.set(group.key,
|
|
109202
|
+
for (const group of groups) names2.set(group.key, nameOf2(group));
|
|
108343
109203
|
return names2;
|
|
108344
109204
|
}
|
|
108345
109205
|
function wordOf(dimension) {
|
|
@@ -108376,7 +109236,7 @@ function render(result2, writer) {
|
|
|
108376
109236
|
"MERGED"
|
|
108377
109237
|
],
|
|
108378
109238
|
result2.groups.map((group) => [
|
|
108379
|
-
|
|
109239
|
+
nameOf2(group),
|
|
108380
109240
|
formatDollars(group.spend),
|
|
108381
109241
|
...withCompared ? [group.compared === null ? "-" : formatDollars(group.compared.spend)] : [],
|
|
108382
109242
|
formatDollars(group.wasted),
|
|
@@ -112246,7 +113106,7 @@ var init_paths2 = __esm({
|
|
|
112246
113106
|
});
|
|
112247
113107
|
|
|
112248
113108
|
// ../../packages/oxagen/src/steering-repo/harness-files.ts
|
|
112249
|
-
function
|
|
113109
|
+
function nameOf3(path2) {
|
|
112250
113110
|
const cut = path2.lastIndexOf("/");
|
|
112251
113111
|
return cut < 0 ? path2 : path2.slice(cut + 1);
|
|
112252
113112
|
}
|
|
@@ -112254,7 +113114,7 @@ function isMarkdown(name2) {
|
|
|
112254
113114
|
return name2.endsWith(".md") || name2.endsWith(".mdc");
|
|
112255
113115
|
}
|
|
112256
113116
|
function instructionEntryOf(path2) {
|
|
112257
|
-
const name2 =
|
|
113117
|
+
const name2 = nameOf3(path2);
|
|
112258
113118
|
const nested2 = NESTED.get(name2) ?? SINGLE2.get(name2);
|
|
112259
113119
|
if (nested2) return nested2;
|
|
112260
113120
|
if (path2 === ".github/copilot-instructions.md")
|
|
@@ -112278,7 +113138,7 @@ function classifyHarnessFile(path2) {
|
|
|
112278
113138
|
const root = ROOT_FILES2.get(path2);
|
|
112279
113139
|
if (root) return { ...root, path: path2, skillFolder: null };
|
|
112280
113140
|
for (const { folder, entry: entry2 } of MARKDOWN_FOLDERS) {
|
|
112281
|
-
if (path2.startsWith(folder) &&
|
|
113141
|
+
if (path2.startsWith(folder) && nameOf3(path2).endsWith(".md"))
|
|
112282
113142
|
return { ...entry2, path: path2, skillFolder: null };
|
|
112283
113143
|
}
|
|
112284
113144
|
return null;
|
|
@@ -156588,7 +157448,7 @@ var init_local_discovery_envelope = __esm({
|
|
|
156588
157448
|
});
|
|
156589
157449
|
|
|
156590
157450
|
// ../../packages/mcp-studio/src/execute/util.ts
|
|
156591
|
-
function
|
|
157451
|
+
function messageOf7(error2) {
|
|
156592
157452
|
return error2 instanceof Error ? error2.message : String(error2);
|
|
156593
157453
|
}
|
|
156594
157454
|
function isRecord11(value) {
|
|
@@ -169719,7 +170579,7 @@ function buildFile(parsed2, notes) {
|
|
|
169719
170579
|
if (parsed2.header.syntax === "proto3") proto.syntax = "proto3";
|
|
169720
170580
|
for (const child of holder.nestedArray) {
|
|
169721
170581
|
if (isType(child)) {
|
|
169722
|
-
proto.messageType.push(
|
|
170582
|
+
proto.messageType.push(messageOf8(child, prefix, build2));
|
|
169723
170583
|
} else if (isEnum(child)) {
|
|
169724
170584
|
proto.enumType.push(enumOf(child, prefix, build2));
|
|
169725
170585
|
} else if (isService(child)) {
|
|
@@ -169773,7 +170633,7 @@ function mapEntryNameOf(name2) {
|
|
|
169773
170633
|
}
|
|
169774
170634
|
return `${out}Entry`;
|
|
169775
170635
|
}
|
|
169776
|
-
function
|
|
170636
|
+
function messageOf8(type, scope, build2) {
|
|
169777
170637
|
const full = `${scope}${type.name}`;
|
|
169778
170638
|
if (type.group === true) {
|
|
169779
170639
|
throw new GrpcImportError(
|
|
@@ -169808,7 +170668,7 @@ function messageOf7(type, scope, build2) {
|
|
|
169808
170668
|
checkJsonNames(message2, full, build2);
|
|
169809
170669
|
for (const child of type.nestedArray) {
|
|
169810
170670
|
if (isType(child)) {
|
|
169811
|
-
message2.nestedType.push(
|
|
170671
|
+
message2.nestedType.push(messageOf8(child, `${full}.`, build2));
|
|
169812
170672
|
} else if (isEnum(child)) {
|
|
169813
170673
|
message2.enumType.push(enumOf(child, `${full}.`, build2));
|
|
169814
170674
|
} else if (isExtension(child)) {
|
|
@@ -170306,13 +171166,13 @@ function optionsOf(schema, raw, skip2, where2, build2) {
|
|
|
170306
171166
|
if (Object.keys(rest).every((key) => known.has(key))) {
|
|
170307
171167
|
throw new GrpcImportError(
|
|
170308
171168
|
"invalid",
|
|
170309
|
-
`${build2.file} sets an option on ${where2} to a value of the wrong type for ${schema.typeName}: ${
|
|
171169
|
+
`${build2.file} sets an option on ${where2} to a value of the wrong type for ${schema.typeName}: ${messageOf7(error2)}. Correct the value.`,
|
|
170310
171170
|
build2.file
|
|
170311
171171
|
);
|
|
170312
171172
|
}
|
|
170313
171173
|
throw new GrpcImportError(
|
|
170314
171174
|
"unsupported",
|
|
170315
|
-
`${build2.file} sets an option on ${where2} that ${schema.typeName} does not define: ${
|
|
171175
|
+
`${build2.file} sets an option on ${where2} that ${schema.typeName} does not define: ${messageOf7(error2)}. Correct or remove the option.`,
|
|
170316
171176
|
build2.file
|
|
170317
171177
|
);
|
|
170318
171178
|
}
|
|
@@ -171327,7 +172187,7 @@ function parseProto(name2, text6) {
|
|
|
171327
172187
|
} catch (error2) {
|
|
171328
172188
|
throw new GrpcImportError(
|
|
171329
172189
|
"parse",
|
|
171330
|
-
`${name2} does not parse: ${
|
|
172190
|
+
`${name2} does not parse: ${messageOf7(error2)}. Fix the file and import it again.`,
|
|
171331
172191
|
name2
|
|
171332
172192
|
);
|
|
171333
172193
|
}
|
|
@@ -171599,7 +172459,7 @@ function buildSet(input2, notes) {
|
|
|
171599
172459
|
} catch (error2) {
|
|
171600
172460
|
throw new GrpcImportError(
|
|
171601
172461
|
"invalid",
|
|
171602
|
-
`The files do not form a valid descriptor set: ${
|
|
172462
|
+
`The files do not form a valid descriptor set: ${messageOf7(error2)}. Fix the definition and import again.`
|
|
171603
172463
|
);
|
|
171604
172464
|
}
|
|
171605
172465
|
return {
|
|
@@ -171904,7 +172764,7 @@ function decodeAll(protos) {
|
|
|
171904
172764
|
} catch (error2) {
|
|
171905
172765
|
throw new GrpcImportError(
|
|
171906
172766
|
"reflection",
|
|
171907
|
-
`Entry ${index + 1} of the reflection result is not a FileDescriptorProto: ${
|
|
172767
|
+
`Entry ${index + 1} of the reflection result is not a FileDescriptorProto: ${messageOf7(error2)}. Check that the server runs gRPC reflection, or import its .proto files instead.`
|
|
171908
172768
|
);
|
|
171909
172769
|
}
|
|
171910
172770
|
const earlier = byName2.get(file2.name);
|
|
@@ -172824,7 +173684,7 @@ function compileTool(input2, key, entry2, auth2, issues) {
|
|
|
172824
173684
|
issues.push({
|
|
172825
173685
|
tool: key,
|
|
172826
173686
|
field: "name",
|
|
172827
|
-
message: `${key}: ${
|
|
173687
|
+
message: `${key}: ${messageOf7(error2)}`
|
|
172828
173688
|
});
|
|
172829
173689
|
return void 0;
|
|
172830
173690
|
}
|
|
@@ -172971,7 +173831,7 @@ function resolveEnvironments(server, issues) {
|
|
|
172971
173831
|
issues.push({
|
|
172972
173832
|
tool: void 0,
|
|
172973
173833
|
field: "environments",
|
|
172974
|
-
message:
|
|
173834
|
+
message: messageOf7(error2)
|
|
172975
173835
|
});
|
|
172976
173836
|
return {};
|
|
172977
173837
|
}
|
|
@@ -173023,7 +173883,7 @@ function resolveAuth(input2, environments2, issues) {
|
|
|
173023
173883
|
try {
|
|
173024
173884
|
apply = builtinSecurityScheme(scheme, declared.header);
|
|
173025
173885
|
} catch (error2) {
|
|
173026
|
-
return fail3(
|
|
173886
|
+
return fail3(messageOf7(error2));
|
|
173027
173887
|
}
|
|
173028
173888
|
}
|
|
173029
173889
|
if (apply.type === "mutual_tls") {
|
|
@@ -174546,7 +175406,7 @@ function transportFailure(error2) {
|
|
|
174546
175406
|
return {
|
|
174547
175407
|
error: {
|
|
174548
175408
|
title: "Transport error",
|
|
174549
|
-
detail:
|
|
175409
|
+
detail: messageOf7(error2),
|
|
174550
175410
|
status: void 0
|
|
174551
175411
|
},
|
|
174552
175412
|
sent: true
|
|
@@ -174623,7 +175483,7 @@ function parseJson4(text6) {
|
|
|
174623
175483
|
const value = JSON.parse(text6);
|
|
174624
175484
|
return { ok: true, value };
|
|
174625
175485
|
} catch (error2) {
|
|
174626
|
-
return { ok: false, message:
|
|
175486
|
+
return { ok: false, message: messageOf7(error2) };
|
|
174627
175487
|
}
|
|
174628
175488
|
}
|
|
174629
175489
|
function isJsonMediaType(contentType) {
|
|
@@ -174878,7 +175738,7 @@ function sendFailure(error2, sender) {
|
|
|
174878
175738
|
ok: false,
|
|
174879
175739
|
error: {
|
|
174880
175740
|
title: "Internal error",
|
|
174881
|
-
detail: `The ${sender} Sender failed: ${
|
|
175741
|
+
detail: `The ${sender} Sender failed: ${messageOf7(error2)}`,
|
|
174882
175742
|
status: void 0
|
|
174883
175743
|
},
|
|
174884
175744
|
attempts: 0
|
|
@@ -176257,7 +177117,7 @@ function registryFor(descriptorSet) {
|
|
|
176257
177117
|
registry3 = createFileRegistry(fromBinary(FileDescriptorSetSchema, bytes));
|
|
176258
177118
|
} catch (error2) {
|
|
176259
177119
|
throw new DescriptorError(
|
|
176260
|
-
`The server's descriptor_set does not parse: ${
|
|
177120
|
+
`The server's descriptor_set does not parse: ${messageOf7(error2)}`
|
|
176261
177121
|
);
|
|
176262
177122
|
}
|
|
176263
177123
|
if (registries.size >= REGISTRY_CACHE_SIZE) {
|
|
@@ -176323,7 +177183,7 @@ function encodeRequest(method, args) {
|
|
|
176323
177183
|
);
|
|
176324
177184
|
} catch (error2) {
|
|
176325
177185
|
throw new DescriptorError(
|
|
176326
|
-
`The arguments do not encode as ${method.input.typeName}: ${
|
|
177186
|
+
`The arguments do not encode as ${method.input.typeName}: ${messageOf7(error2)}`
|
|
176327
177187
|
);
|
|
176328
177188
|
}
|
|
176329
177189
|
}
|
|
@@ -176334,7 +177194,7 @@ function requestJson(method, bytes) {
|
|
|
176334
177194
|
});
|
|
176335
177195
|
} catch (error2) {
|
|
176336
177196
|
throw new DescriptorError(
|
|
176337
|
-
`The request does not decode as ${method.input.typeName}: ${
|
|
177197
|
+
`The request does not decode as ${method.input.typeName}: ${messageOf7(error2)}`
|
|
176338
177198
|
);
|
|
176339
177199
|
}
|
|
176340
177200
|
}
|
|
@@ -176346,7 +177206,7 @@ function decodeResponse(method, bytes) {
|
|
|
176346
177206
|
});
|
|
176347
177207
|
} catch (error2) {
|
|
176348
177208
|
throw new DescriptorError(
|
|
176349
|
-
`The response does not decode as ${method.output.typeName}: ${
|
|
177209
|
+
`The response does not decode as ${method.output.typeName}: ${messageOf7(error2)}`
|
|
176350
177210
|
);
|
|
176351
177211
|
}
|
|
176352
177212
|
}
|
|
@@ -176560,7 +177420,7 @@ function createGrpcSender(options = {}) {
|
|
|
176560
177420
|
ok: false,
|
|
176561
177421
|
error: {
|
|
176562
177422
|
title: "Internal error",
|
|
176563
|
-
detail: `The gRPC Sender failed: ${
|
|
177423
|
+
detail: `The gRPC Sender failed: ${messageOf7(error2)}`,
|
|
176564
177424
|
status: void 0
|
|
176565
177425
|
},
|
|
176566
177426
|
attempts: 0,
|
|
@@ -176604,7 +177464,7 @@ function prepare(template, args, context) {
|
|
|
176604
177464
|
ok: false,
|
|
176605
177465
|
error: {
|
|
176606
177466
|
title: "Invalid descriptor set",
|
|
176607
|
-
detail:
|
|
177467
|
+
detail: messageOf7(error2),
|
|
176608
177468
|
status: void 0
|
|
176609
177469
|
}
|
|
176610
177470
|
};
|
|
@@ -176627,7 +177487,7 @@ function prepare(template, args, context) {
|
|
|
176627
177487
|
const title = error2 instanceof BuildError ? error2.title : "Invalid request";
|
|
176628
177488
|
return {
|
|
176629
177489
|
ok: false,
|
|
176630
|
-
error: { title, detail:
|
|
177490
|
+
error: { title, detail: messageOf7(error2), status: void 0 }
|
|
176631
177491
|
};
|
|
176632
177492
|
}
|
|
176633
177493
|
let message2;
|
|
@@ -176638,7 +177498,7 @@ function prepare(template, args, context) {
|
|
|
176638
177498
|
ok: false,
|
|
176639
177499
|
error: {
|
|
176640
177500
|
title: "Invalid arguments",
|
|
176641
|
-
detail:
|
|
177501
|
+
detail: messageOf7(error2),
|
|
176642
177502
|
status: void 0
|
|
176643
177503
|
}
|
|
176644
177504
|
};
|
|
@@ -176713,7 +177573,7 @@ async function read(response, call2, clock2, settings) {
|
|
|
176713
177573
|
item = decodeResponse(call2.method, encoded);
|
|
176714
177574
|
} catch (error2) {
|
|
176715
177575
|
response.cancel();
|
|
176716
|
-
return failed3(internal(
|
|
177576
|
+
return failed3(internal(messageOf7(error2)));
|
|
176717
177577
|
}
|
|
176718
177578
|
items.push(item);
|
|
176719
177579
|
if (template.streaming === "server") {
|
|
@@ -176764,7 +177624,7 @@ function transportFailure2(error2, call2, items) {
|
|
|
176764
177624
|
if (!(error2 instanceof TransportError)) {
|
|
176765
177625
|
return failed3({
|
|
176766
177626
|
title: "Transport error",
|
|
176767
|
-
detail:
|
|
177627
|
+
detail: messageOf7(error2),
|
|
176768
177628
|
status: void 0
|
|
176769
177629
|
});
|
|
176770
177630
|
}
|