@oxagen/cli 5.5.1-271 → 5.5.1-274
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 +1626 -898
- 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"]),
|
|
@@ -29471,6 +29478,7 @@ function memberOf(entry2) {
|
|
|
29471
29478
|
...entry2.label !== void 0 ? { label: entry2.label } : {},
|
|
29472
29479
|
...entry2.refreshed_at !== void 0 ? { refreshed_at: entry2.refreshed_at } : {},
|
|
29473
29480
|
...entry2.refresh_refused !== void 0 ? { refresh_refused: entry2.refresh_refused } : {},
|
|
29481
|
+
...entry2.write_back === "refused" ? { write_back_refused: true } : {},
|
|
29474
29482
|
...entry2.failure !== void 0 ? { failure: { ...entry2.failure } } : {}
|
|
29475
29483
|
};
|
|
29476
29484
|
}
|
|
@@ -29480,6 +29488,45 @@ function refreshedSince(entry2, vaultChangedAt) {
|
|
|
29480
29488
|
const changed = Date.parse(vaultChangedAt);
|
|
29481
29489
|
return Number.isFinite(refreshed) && Number.isFinite(changed) && refreshed > changed;
|
|
29482
29490
|
}
|
|
29491
|
+
function owedOf(entry2) {
|
|
29492
|
+
if (entry2.kind !== "chatgpt") return void 0;
|
|
29493
|
+
const {
|
|
29494
|
+
credential_id: credentialId,
|
|
29495
|
+
vault_changed_at: vaultChangedAt,
|
|
29496
|
+
refreshed_at: refreshedAt
|
|
29497
|
+
} = entry2;
|
|
29498
|
+
if (credentialId === void 0 || vaultChangedAt === void 0 || refreshedAt === void 0)
|
|
29499
|
+
return void 0;
|
|
29500
|
+
const owed = entry2.write_back !== void 0 ? entry2.write_back === "owed" : refreshedSince(entry2, vaultChangedAt);
|
|
29501
|
+
if (!owed) return void 0;
|
|
29502
|
+
return {
|
|
29503
|
+
provider: entry2.provider,
|
|
29504
|
+
harness: harnessOf(entry2),
|
|
29505
|
+
id: memberIdOf(entry2),
|
|
29506
|
+
credential_id: credentialId,
|
|
29507
|
+
vault_changed_at: vaultChangedAt,
|
|
29508
|
+
refreshed_at: refreshedAt,
|
|
29509
|
+
...entry2.hint !== void 0 ? { hint: entry2.hint } : {},
|
|
29510
|
+
...entry2.label !== void 0 ? { label: entry2.label } : {}
|
|
29511
|
+
};
|
|
29512
|
+
}
|
|
29513
|
+
function keepsOwnTokens(entry2, changedAt) {
|
|
29514
|
+
if (entry2.write_back === "refused") return false;
|
|
29515
|
+
if (entry2.vault_changed_at === changedAt) return true;
|
|
29516
|
+
if (entry2.vault_changed_at !== void 0 && vaultTimeBefore(changedAt, entry2.vault_changed_at))
|
|
29517
|
+
return true;
|
|
29518
|
+
return entry2.write_back !== "stored" && refreshedSince(entry2, changedAt);
|
|
29519
|
+
}
|
|
29520
|
+
function vaultTimeBefore(a, b3) {
|
|
29521
|
+
const left = Date.parse(a);
|
|
29522
|
+
const right = Date.parse(b3);
|
|
29523
|
+
return Number.isFinite(left) && Number.isFinite(right) && left < right;
|
|
29524
|
+
}
|
|
29525
|
+
function servingEntries(entries2, provider, harness) {
|
|
29526
|
+
return slotEntries(entries2, provider, harness).filter(
|
|
29527
|
+
(e) => e.unlisted !== true
|
|
29528
|
+
);
|
|
29529
|
+
}
|
|
29483
29530
|
function prefixOf(kind, secret) {
|
|
29484
29531
|
return kind === "chatgpt" ? "login" : credentialPrefix(secret);
|
|
29485
29532
|
}
|
|
@@ -29572,11 +29619,13 @@ function openCredentialStore(paths) {
|
|
|
29572
29619
|
return {
|
|
29573
29620
|
has: (provider, harness) => {
|
|
29574
29621
|
const owner = ownerOf(provider, harness);
|
|
29575
|
-
return readAll()
|
|
29622
|
+
return servingEntries(readAll(), provider, owner).length > 0;
|
|
29576
29623
|
},
|
|
29577
29624
|
read: (provider, harness) => {
|
|
29578
29625
|
const owner = ownerOf(provider, harness);
|
|
29579
|
-
const entry2 = slotEntries(readAll(), provider, owner)
|
|
29626
|
+
const entry2 = slotEntries(readAll(), provider, owner).find(
|
|
29627
|
+
(e) => !isVaultCopy(e)
|
|
29628
|
+
);
|
|
29580
29629
|
return entry2 === void 0 ? void 0 : openEntry(entry2);
|
|
29581
29630
|
},
|
|
29582
29631
|
take: (provider, { kind, secret }, source, now, harness) => {
|
|
@@ -29596,22 +29645,41 @@ function openCredentialStore(paths) {
|
|
|
29596
29645
|
...hint !== void 0 ? { hint } : {}
|
|
29597
29646
|
};
|
|
29598
29647
|
const entries2 = readAll();
|
|
29599
|
-
const
|
|
29648
|
+
const slot = slotEntries(entries2, provider, owner);
|
|
29649
|
+
const copies = slot.filter(isVaultCopy);
|
|
29650
|
+
const previous = slot.find((e) => !isVaultCopy(e));
|
|
29651
|
+
const pending = [];
|
|
29652
|
+
if (previous !== void 0 && owedOf(previous) !== void 0 && !copies.some((c) => c.credential_id === previous.credential_id)) {
|
|
29653
|
+
const kept = openEntry(previous);
|
|
29654
|
+
if (identityOf(kept.kind, kept.secret) !== identityOf(kind, secret)) {
|
|
29655
|
+
const copy = {
|
|
29656
|
+
...previous,
|
|
29657
|
+
source: VAULT_POOL_SOURCE,
|
|
29658
|
+
unlisted: true
|
|
29659
|
+
};
|
|
29660
|
+
pending.push({
|
|
29661
|
+
...copy,
|
|
29662
|
+
sealed: seal(keyForWrite(), kept.secret, entryContext(copy))
|
|
29663
|
+
});
|
|
29664
|
+
}
|
|
29665
|
+
}
|
|
29600
29666
|
writeAll3([
|
|
29601
29667
|
...entries2.filter((e) => !matches(e, provider, owner)),
|
|
29602
29668
|
entry2,
|
|
29603
|
-
...copies
|
|
29669
|
+
...copies,
|
|
29670
|
+
...pending
|
|
29604
29671
|
]);
|
|
29605
29672
|
return custodyOf(entry2);
|
|
29606
29673
|
},
|
|
29607
|
-
release: (provider, harness) => {
|
|
29674
|
+
release: (provider, harness, options) => {
|
|
29608
29675
|
const owner = ownerOf(provider, harness);
|
|
29609
29676
|
const entries2 = readAll();
|
|
29610
29677
|
const slot = slotEntries(entries2, provider, owner);
|
|
29611
29678
|
if (slot.length === 0) return void 0;
|
|
29612
29679
|
const own2 = slot.find((e) => !isVaultCopy(e));
|
|
29613
29680
|
const held = own2 === void 0 ? void 0 : openEntry(own2);
|
|
29614
|
-
|
|
29681
|
+
const kept = options?.keepOwed === true ? slot.filter((e) => owedOf(e) !== void 0).map((e) => ({ ...e, unlisted: true })) : [];
|
|
29682
|
+
writeAll3(withSlot(entries2, provider, owner, kept));
|
|
29615
29683
|
return held;
|
|
29616
29684
|
},
|
|
29617
29685
|
status: () => {
|
|
@@ -29628,7 +29696,7 @@ function openCredentialStore(paths) {
|
|
|
29628
29696
|
}
|
|
29629
29697
|
return rows;
|
|
29630
29698
|
},
|
|
29631
|
-
pool: (provider, harness) =>
|
|
29699
|
+
pool: (provider, harness) => servingEntries(readAll(), provider, ownerOf(provider, harness)).map(
|
|
29632
29700
|
memberOf
|
|
29633
29701
|
),
|
|
29634
29702
|
open: (provider, harness, id2) => {
|
|
@@ -29638,7 +29706,7 @@ function openCredentialStore(paths) {
|
|
|
29638
29706
|
return entry2 === void 0 ? void 0 : openEntry(entry2);
|
|
29639
29707
|
},
|
|
29640
29708
|
nextUntried: (provider, harness, options) => {
|
|
29641
|
-
const eligible =
|
|
29709
|
+
const eligible = servingEntries(readAll(), provider, harness).map(memberOf).filter(
|
|
29642
29710
|
(member4) => !(options.tried?.has(member4.id) ?? false) && (options.loginsOnly !== true || isLoginKind(member4.kind)) && (options.fits?.(member4) ?? true)
|
|
29643
29711
|
);
|
|
29644
29712
|
const ready = eligible.find(
|
|
@@ -29679,7 +29747,12 @@ function openCredentialStore(paths) {
|
|
|
29679
29747
|
if (secret.trim().length === 0)
|
|
29680
29748
|
throw new Error("refusing to take an empty credential into custody");
|
|
29681
29749
|
return updateMember(provider, harness, id2, (entry2) => {
|
|
29682
|
-
const {
|
|
29750
|
+
const {
|
|
29751
|
+
failure: failure5,
|
|
29752
|
+
refresh_refused: _refused,
|
|
29753
|
+
write_back: _writeBack,
|
|
29754
|
+
...rest
|
|
29755
|
+
} = entry2;
|
|
29683
29756
|
const at2 = new Date(now).toISOString();
|
|
29684
29757
|
const next = {
|
|
29685
29758
|
...rest,
|
|
@@ -29690,6 +29763,10 @@ function openCredentialStore(paths) {
|
|
|
29690
29763
|
taken_at: at2,
|
|
29691
29764
|
refreshed_at: at2,
|
|
29692
29765
|
prefix: prefixOf(kind, secret),
|
|
29766
|
+
// New tokens for a login the vault holds too are owed to the vault
|
|
29767
|
+
// until Oxagen stores them: its copy now holds a spent refresh
|
|
29768
|
+
// token.
|
|
29769
|
+
...kind === "chatgpt" && entry2.credential_id !== void 0 ? { write_back: "owed" } : {},
|
|
29693
29770
|
...failure5 !== void 0 && !isTokenRefused(failure5.kind) ? { failure: failure5 } : {},
|
|
29694
29771
|
sealed: entry2.sealed
|
|
29695
29772
|
};
|
|
@@ -29727,7 +29804,7 @@ function openCredentialStore(paths) {
|
|
|
29727
29804
|
identities.add(identity);
|
|
29728
29805
|
const before = local.get(member4.credential_id);
|
|
29729
29806
|
const label = member4.label?.slice(0, 80);
|
|
29730
|
-
const unchanged = before !== void 0 && before.kind === member4.kind && (before
|
|
29807
|
+
const unchanged = before !== void 0 && before.kind === member4.kind && keepsOwnTokens(before, member4.changed_at);
|
|
29731
29808
|
if (before !== void 0) kept += 1;
|
|
29732
29809
|
else added += 1;
|
|
29733
29810
|
const base2 = unchanged ? { ...before } : {
|
|
@@ -29742,7 +29819,12 @@ function openCredentialStore(paths) {
|
|
|
29742
29819
|
// Replaced below, once the row's context is known.
|
|
29743
29820
|
sealed: own2.sealed
|
|
29744
29821
|
};
|
|
29745
|
-
const {
|
|
29822
|
+
const {
|
|
29823
|
+
label: _label,
|
|
29824
|
+
failure: _failure,
|
|
29825
|
+
unlisted: _unlisted,
|
|
29826
|
+
...rest
|
|
29827
|
+
} = base2;
|
|
29746
29828
|
const failure5 = mergedFailure(
|
|
29747
29829
|
unchanged ? before.failure : void 0,
|
|
29748
29830
|
member4.limited_until,
|
|
@@ -29761,31 +29843,109 @@ function openCredentialStore(paths) {
|
|
|
29761
29843
|
}
|
|
29762
29844
|
);
|
|
29763
29845
|
}
|
|
29764
|
-
const
|
|
29765
|
-
|
|
29766
|
-
|
|
29846
|
+
const carried = new Set(copies.map(memberIdOf));
|
|
29847
|
+
const parked = [];
|
|
29848
|
+
let removed = 0;
|
|
29849
|
+
for (const [id2, entry2] of local) {
|
|
29850
|
+
if (carried.has(id2)) continue;
|
|
29851
|
+
if (id2 !== ownCopy?.credential_id && owedOf(entry2) !== void 0) {
|
|
29852
|
+
parked.push({ ...entry2, unlisted: true });
|
|
29853
|
+
continue;
|
|
29854
|
+
}
|
|
29855
|
+
if (!members3.some((m) => m.credential_id === id2)) removed += 1;
|
|
29856
|
+
}
|
|
29767
29857
|
const {
|
|
29768
29858
|
credential_id: _id,
|
|
29769
29859
|
label: _ownLabel,
|
|
29770
29860
|
failure: _ownFailure,
|
|
29861
|
+
vault_changed_at: ownBase,
|
|
29862
|
+
write_back: ownWriteBack,
|
|
29771
29863
|
...ownBare
|
|
29772
29864
|
} = own2;
|
|
29773
29865
|
const ownLabel = ownCopy?.label?.slice(0, 80);
|
|
29866
|
+
const ownLogin = own2.kind === "chatgpt" && ownCopy?.kind === "chatgpt" ? ownCopy : void 0;
|
|
29867
|
+
const sameVaultLogin = own2.credential_id === ownLogin?.credential_id;
|
|
29868
|
+
const takesVaultTokens = ownLogin !== void 0 && sameVaultLogin && ownBase !== void 0 && !keepsOwnTokens(own2, ownLogin.changed_at);
|
|
29774
29869
|
const ownFailure = mergedFailure(
|
|
29775
|
-
|
|
29870
|
+
// New tokens cure a token the provider refused, as a refresh does.
|
|
29871
|
+
takesVaultTokens && own2.failure !== void 0 && isTokenRefused(own2.failure.kind) ? void 0 : own2.failure,
|
|
29776
29872
|
ownCopy?.limited_until,
|
|
29777
29873
|
now
|
|
29778
29874
|
);
|
|
29779
|
-
const
|
|
29780
|
-
...ownBare,
|
|
29875
|
+
const ownNamed = {
|
|
29781
29876
|
...ownCopy !== void 0 ? { credential_id: ownCopy.credential_id } : {},
|
|
29782
29877
|
...ownLabel !== void 0 && ownLabel.length > 0 ? { label: ownLabel } : {},
|
|
29783
29878
|
...own2.hint === void 0 && ownCopy !== void 0 ? { hint: ownCopy.hint.slice(-4) } : {},
|
|
29784
29879
|
...ownFailure !== void 0 ? { failure: ownFailure } : {}
|
|
29785
29880
|
};
|
|
29786
|
-
|
|
29881
|
+
let ownNext;
|
|
29882
|
+
if (ownLogin !== void 0 && takesVaultTokens) {
|
|
29883
|
+
const {
|
|
29884
|
+
refreshed_at: _refreshedAt,
|
|
29885
|
+
refresh_refused: _refreshRefused,
|
|
29886
|
+
...ownKept
|
|
29887
|
+
} = ownBare;
|
|
29888
|
+
ownNext = {
|
|
29889
|
+
...ownKept,
|
|
29890
|
+
...ownNamed,
|
|
29891
|
+
taken_at: new Date(now).toISOString(),
|
|
29892
|
+
prefix: prefixOf(ownLogin.kind, ownLogin.secret),
|
|
29893
|
+
vault_changed_at: ownLogin.changed_at,
|
|
29894
|
+
sealed: seal(
|
|
29895
|
+
keyForWrite(),
|
|
29896
|
+
ownLogin.secret,
|
|
29897
|
+
sealingContext(provider, harness)
|
|
29898
|
+
)
|
|
29899
|
+
};
|
|
29900
|
+
} else if (ownLogin !== void 0) {
|
|
29901
|
+
const writeBack = sameVaultLogin ? ownWriteBack : ownWriteBack === "owed" ? ownWriteBack : void 0;
|
|
29902
|
+
ownNext = {
|
|
29903
|
+
...ownBare,
|
|
29904
|
+
...ownNamed,
|
|
29905
|
+
vault_changed_at: sameVaultLogin && ownBase !== void 0 ? ownBase : ownLogin.changed_at,
|
|
29906
|
+
...writeBack !== void 0 ? { write_back: writeBack } : {}
|
|
29907
|
+
};
|
|
29908
|
+
} else if (ownCopy === void 0 && owedOf(own2) !== void 0) {
|
|
29909
|
+
ownNext = {
|
|
29910
|
+
...ownBare,
|
|
29911
|
+
...ownNamed,
|
|
29912
|
+
credential_id: own2.credential_id,
|
|
29913
|
+
...own2.label !== void 0 ? { label: own2.label } : {},
|
|
29914
|
+
...ownBase !== void 0 ? { vault_changed_at: ownBase } : {},
|
|
29915
|
+
...ownWriteBack !== void 0 ? { write_back: ownWriteBack } : {}
|
|
29916
|
+
};
|
|
29917
|
+
} else {
|
|
29918
|
+
ownNext = { ...ownBare, ...ownNamed };
|
|
29919
|
+
}
|
|
29920
|
+
writeAll3(
|
|
29921
|
+
withSlot(entries2, provider, harness, [ownNext, ...copies, ...parked])
|
|
29922
|
+
);
|
|
29787
29923
|
return { synced: true, added, kept, removed };
|
|
29788
29924
|
},
|
|
29925
|
+
owedLogins: () => {
|
|
29926
|
+
const owed = [];
|
|
29927
|
+
for (const entry2 of readAll()) {
|
|
29928
|
+
const login = owedOf(entry2);
|
|
29929
|
+
if (login !== void 0) owed.push(login);
|
|
29930
|
+
}
|
|
29931
|
+
return owed;
|
|
29932
|
+
},
|
|
29933
|
+
settleWriteBack: (provider, harness, id2, refreshedAt, settlement) => {
|
|
29934
|
+
let settled2 = false;
|
|
29935
|
+
updateMember(provider, harness, id2, (entry2) => {
|
|
29936
|
+
if (owedOf(entry2) === void 0) return void 0;
|
|
29937
|
+
if (entry2.refreshed_at !== refreshedAt) {
|
|
29938
|
+
return settlement.state === "stored" ? { ...entry2, vault_changed_at: settlement.changedAt } : void 0;
|
|
29939
|
+
}
|
|
29940
|
+
settled2 = true;
|
|
29941
|
+
return settlement.state === "stored" ? {
|
|
29942
|
+
...entry2,
|
|
29943
|
+
vault_changed_at: settlement.changedAt,
|
|
29944
|
+
write_back: "stored"
|
|
29945
|
+
} : { ...entry2, write_back: "refused" };
|
|
29946
|
+
});
|
|
29947
|
+
return settled2;
|
|
29948
|
+
},
|
|
29789
29949
|
shred: () => {
|
|
29790
29950
|
let overwrite;
|
|
29791
29951
|
try {
|
|
@@ -29804,7 +29964,7 @@ function openCredentialStore(paths) {
|
|
|
29804
29964
|
}
|
|
29805
29965
|
};
|
|
29806
29966
|
}
|
|
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;
|
|
29967
|
+
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
29968
|
var init_credential_store = __esm({
|
|
29809
29969
|
"../../packages/tacho/src/host/credential-store.ts"() {
|
|
29810
29970
|
"use strict";
|
|
@@ -29855,6 +30015,7 @@ var init_credential_store = __esm({
|
|
|
29855
30015
|
];
|
|
29856
30016
|
CLAUDE_OAUTH_TOKEN_PREFIX = "sk-ant-oat";
|
|
29857
30017
|
LOGIN_REFRESH_REFUSALS = ["rotated", "refused"];
|
|
30018
|
+
LOGIN_WRITE_BACK_STATES = ["owed", "stored", "refused"];
|
|
29858
30019
|
sealedSchema = external_exports.object({
|
|
29859
30020
|
/** AES-256-GCM: 12-byte nonce, ciphertext, 16-byte tag, all base64. */
|
|
29860
30021
|
nonce: external_exports.string().min(1),
|
|
@@ -29895,11 +30056,28 @@ var init_credential_store = __esm({
|
|
|
29895
30056
|
/** The name the person gave it in Oxagen, such as the account's email. */
|
|
29896
30057
|
label: external_exports.string().max(80).optional(),
|
|
29897
30058
|
/**
|
|
29898
|
-
* When the vault last changed the secret
|
|
29899
|
-
*
|
|
29900
|
-
*
|
|
30059
|
+
* When the vault last changed the secret this row's tokens came from:
|
|
30060
|
+
* every `vault:pool` member, and the machine's own ChatGPT login while
|
|
30061
|
+
* the vault holds a login for the same account. A write-back sends it,
|
|
30062
|
+
* and Oxagen stores the new tokens only while its row still carries this
|
|
30063
|
+
* time. A ChatGPT login this machine refreshed after that time keeps its
|
|
30064
|
+
* own, newer tokens on the next sync.
|
|
29901
30065
|
*/
|
|
29902
30066
|
vault_changed_at: external_exports.string().optional(),
|
|
30067
|
+
/**
|
|
30068
|
+
* Where this row's tokens stand with the vault (`LoginWriteBackState`).
|
|
30069
|
+
* Absent on a row never refreshed here, and on a row an earlier build
|
|
30070
|
+
* refreshed, which reads as owed when `refreshed_at` is after
|
|
30071
|
+
* `vault_changed_at`.
|
|
30072
|
+
*/
|
|
30073
|
+
write_back: external_exports.enum(LOGIN_WRITE_BACK_STATES).optional(),
|
|
30074
|
+
/**
|
|
30075
|
+
* The vault's last list left this copy out, and it is kept only because
|
|
30076
|
+
* it still owes the vault its tokens. The gateway spends no call on it
|
|
30077
|
+
* and never refreshes it. It goes at the first sync after Oxagen answers
|
|
30078
|
+
* the write-back.
|
|
30079
|
+
*/
|
|
30080
|
+
unlisted: external_exports.literal(true).optional(),
|
|
29903
30081
|
/** When this machine last refreshed the secret (`replaceSecret`), ISO-8601. */
|
|
29904
30082
|
refreshed_at: external_exports.string().optional(),
|
|
29905
30083
|
/**
|
|
@@ -30083,6 +30261,879 @@ var init_claude_setup_token = __esm({
|
|
|
30083
30261
|
}
|
|
30084
30262
|
});
|
|
30085
30263
|
|
|
30264
|
+
// ../../packages/tacho/src/arp/schema.ts
|
|
30265
|
+
function arpFail(message2) {
|
|
30266
|
+
throw new Error(`ARP: ${message2}`);
|
|
30267
|
+
}
|
|
30268
|
+
function zodIssues(error2) {
|
|
30269
|
+
return error2.issues.map((issue2) => `${issue2.path.join(".") || "(root)"}: ${issue2.message}`).join("; ");
|
|
30270
|
+
}
|
|
30271
|
+
function safeRelativePath(path2) {
|
|
30272
|
+
const unsafe = () => arpFail(
|
|
30273
|
+
`Path ${JSON.stringify(path2)} is unsafe on a supported destination filesystem.`
|
|
30274
|
+
);
|
|
30275
|
+
if (!path2 || path2.length > 4096 || /[\\:\x00-\x1f\x7f<>"|?*]/u.test(path2))
|
|
30276
|
+
unsafe();
|
|
30277
|
+
for (const part of path2.split("/")) {
|
|
30278
|
+
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))
|
|
30279
|
+
unsafe();
|
|
30280
|
+
}
|
|
30281
|
+
return path2;
|
|
30282
|
+
}
|
|
30283
|
+
var ARP_MAX_BLOB_BYTES, ARP_MAX_TOTAL_BYTES, ARP_MAX_FILES, text2, digestSchema, empty, extensions, path, blobRefSchema, arpFrameSchema, arpCheckpointSchema, arpWorkspaceSchema;
|
|
30284
|
+
var init_schema = __esm({
|
|
30285
|
+
"../../packages/tacho/src/arp/schema.ts"() {
|
|
30286
|
+
"use strict";
|
|
30287
|
+
init_zod();
|
|
30288
|
+
init_digest();
|
|
30289
|
+
ARP_MAX_BLOB_BYTES = 64 * 1024 * 1024;
|
|
30290
|
+
ARP_MAX_TOTAL_BYTES = 512 * 1024 * 1024;
|
|
30291
|
+
ARP_MAX_FILES = 1e4;
|
|
30292
|
+
text2 = external_exports.string().min(1).max(4096);
|
|
30293
|
+
digestSchema = external_exports.string().regex(SHA256_DIGEST_PATTERN);
|
|
30294
|
+
empty = external_exports.array(external_exports.never()).max(0);
|
|
30295
|
+
extensions = external_exports.object({}).strict();
|
|
30296
|
+
path = text2.refine((value) => {
|
|
30297
|
+
try {
|
|
30298
|
+
safeRelativePath(value);
|
|
30299
|
+
return true;
|
|
30300
|
+
} catch {
|
|
30301
|
+
return false;
|
|
30302
|
+
}
|
|
30303
|
+
}, "Unsafe ARP workspace path");
|
|
30304
|
+
blobRefSchema = external_exports.object({
|
|
30305
|
+
digest: digestSchema,
|
|
30306
|
+
bytes: external_exports.number().int().min(0).max(ARP_MAX_BLOB_BYTES),
|
|
30307
|
+
media_type: text2
|
|
30308
|
+
}).strict();
|
|
30309
|
+
arpFrameSchema = external_exports.object({
|
|
30310
|
+
format: external_exports.literal("tacho/1.0"),
|
|
30311
|
+
issuer: text2,
|
|
30312
|
+
stream_id: text2,
|
|
30313
|
+
seq: external_exports.string().regex(/^(0|[1-9][0-9]*)$/),
|
|
30314
|
+
digest: digestSchema
|
|
30315
|
+
}).strict();
|
|
30316
|
+
arpCheckpointSchema = external_exports.object({
|
|
30317
|
+
schema: external_exports.literal("arp.checkpoint/0.1"),
|
|
30318
|
+
checkpoint_id: text2,
|
|
30319
|
+
issuer: text2,
|
|
30320
|
+
profile: external_exports.literal("code-workspace/0.1"),
|
|
30321
|
+
created_at: external_exports.string().datetime({ offset: true }),
|
|
30322
|
+
source: external_exports.object({
|
|
30323
|
+
boundary: arpFrameSchema,
|
|
30324
|
+
position: external_exports.literal("after"),
|
|
30325
|
+
evidence_prefix: blobRefSchema
|
|
30326
|
+
}).strict(),
|
|
30327
|
+
capture: external_exports.object({
|
|
30328
|
+
boundary_kind: external_exports.literal("turn_completed"),
|
|
30329
|
+
quiescence: external_exports.enum(["client_attested", "runner_enforced"]),
|
|
30330
|
+
barrier_evidence: blobRefSchema,
|
|
30331
|
+
pending_operations: empty,
|
|
30332
|
+
active_children: empty
|
|
30333
|
+
}).strict(),
|
|
30334
|
+
task: blobRefSchema,
|
|
30335
|
+
context: blobRefSchema,
|
|
30336
|
+
workspace: blobRefSchema,
|
|
30337
|
+
environment: blobRefSchema,
|
|
30338
|
+
tools: blobRefSchema,
|
|
30339
|
+
authority: blobRefSchema,
|
|
30340
|
+
effects: external_exports.array(
|
|
30341
|
+
external_exports.object({
|
|
30342
|
+
operation_id: text2,
|
|
30343
|
+
status: external_exports.enum(["settled", "unknown"]),
|
|
30344
|
+
receipt: blobRefSchema.optional(),
|
|
30345
|
+
external_ids: external_exports.array(text2).max(ARP_MAX_FILES),
|
|
30346
|
+
idempotency_key: text2.optional()
|
|
30347
|
+
}).strict()
|
|
30348
|
+
).max(ARP_MAX_FILES),
|
|
30349
|
+
gaps: external_exports.array(
|
|
30350
|
+
external_exports.object({
|
|
30351
|
+
code: text2,
|
|
30352
|
+
dimension: external_exports.enum([
|
|
30353
|
+
"workspace",
|
|
30354
|
+
"environment",
|
|
30355
|
+
"context",
|
|
30356
|
+
"tools",
|
|
30357
|
+
"effects",
|
|
30358
|
+
"authority",
|
|
30359
|
+
"evidence"
|
|
30360
|
+
]),
|
|
30361
|
+
required: external_exports.boolean(),
|
|
30362
|
+
detail: text2,
|
|
30363
|
+
source: arpFrameSchema.optional()
|
|
30364
|
+
}).strict()
|
|
30365
|
+
).max(ARP_MAX_FILES),
|
|
30366
|
+
extensions,
|
|
30367
|
+
required_extensions: empty
|
|
30368
|
+
}).strict();
|
|
30369
|
+
arpWorkspaceSchema = external_exports.object({
|
|
30370
|
+
schema: external_exports.literal("arp.workspace/0.1"),
|
|
30371
|
+
complete_scope: external_exports.literal(true),
|
|
30372
|
+
repositories: external_exports.array(
|
|
30373
|
+
external_exports.object({
|
|
30374
|
+
root: external_exports.union([external_exports.literal("."), path]),
|
|
30375
|
+
provider_id: text2,
|
|
30376
|
+
base_object: text2
|
|
30377
|
+
}).strict()
|
|
30378
|
+
).max(ARP_MAX_FILES),
|
|
30379
|
+
entries: external_exports.array(
|
|
30380
|
+
external_exports.discriminatedUnion("kind", [
|
|
30381
|
+
external_exports.object({ path, kind: external_exports.literal("directory") }).strict(),
|
|
30382
|
+
external_exports.object({
|
|
30383
|
+
path,
|
|
30384
|
+
kind: external_exports.literal("file"),
|
|
30385
|
+
blob: blobRefSchema,
|
|
30386
|
+
executable: external_exports.boolean()
|
|
30387
|
+
}).strict()
|
|
30388
|
+
])
|
|
30389
|
+
).max(ARP_MAX_FILES),
|
|
30390
|
+
// Exclusions describe omitted paths, including reserved metadata directories.
|
|
30391
|
+
exclusions: external_exports.array(
|
|
30392
|
+
external_exports.object({ path: text2, reason: text2, required: external_exports.boolean() }).strict()
|
|
30393
|
+
).max(ARP_MAX_FILES),
|
|
30394
|
+
resources: empty,
|
|
30395
|
+
extensions,
|
|
30396
|
+
required_extensions: empty
|
|
30397
|
+
}).strict();
|
|
30398
|
+
}
|
|
30399
|
+
});
|
|
30400
|
+
|
|
30401
|
+
// ../../packages/tacho/src/host/device-key.ts
|
|
30402
|
+
import {
|
|
30403
|
+
createHash as createHash6,
|
|
30404
|
+
createPrivateKey,
|
|
30405
|
+
createPublicKey as createPublicKey3,
|
|
30406
|
+
generateKeyPairSync,
|
|
30407
|
+
sign as sign3,
|
|
30408
|
+
verify as verify3
|
|
30409
|
+
} from "node:crypto";
|
|
30410
|
+
import { readFileSync as readFileSync10 } from "node:fs";
|
|
30411
|
+
function encodePublicKey(privateKey) {
|
|
30412
|
+
const spki = createPublicKey3(privateKey).export({
|
|
30413
|
+
type: "spki",
|
|
30414
|
+
format: "der"
|
|
30415
|
+
});
|
|
30416
|
+
const raw = spki.subarray(SPKI_ED25519_PREFIX_BYTES);
|
|
30417
|
+
return `ed25519:${raw.toString("base64")}`;
|
|
30418
|
+
}
|
|
30419
|
+
function deviceKeyFingerprint(publicKey) {
|
|
30420
|
+
return createHash6("sha256").update(publicKey, "utf8").digest("hex").slice(0, 16);
|
|
30421
|
+
}
|
|
30422
|
+
function fromPrivateKey(privateKey) {
|
|
30423
|
+
if (privateKey.asymmetricKeyType !== "ed25519") {
|
|
30424
|
+
throw new Error(
|
|
30425
|
+
`device key must be ed25519, got ${privateKey.asymmetricKeyType ?? "unknown"}`
|
|
30426
|
+
);
|
|
30427
|
+
}
|
|
30428
|
+
const publicKey = encodePublicKey(privateKey);
|
|
30429
|
+
return {
|
|
30430
|
+
privateKey,
|
|
30431
|
+
publicKey,
|
|
30432
|
+
fingerprint: deviceKeyFingerprint(publicKey),
|
|
30433
|
+
sign: (message2) => sign3(null, Buffer.from(message2, "utf8"), privateKey).toString("base64")
|
|
30434
|
+
};
|
|
30435
|
+
}
|
|
30436
|
+
function generateDeviceKey() {
|
|
30437
|
+
return fromPrivateKey(generateKeyPairSync("ed25519").privateKey);
|
|
30438
|
+
}
|
|
30439
|
+
function deviceKeyFromPem(pem2) {
|
|
30440
|
+
return fromPrivateKey(createPrivateKey(pem2));
|
|
30441
|
+
}
|
|
30442
|
+
function deviceKeyPem(key) {
|
|
30443
|
+
return key.privateKey.export({ type: "pkcs8", format: "pem" }).toString();
|
|
30444
|
+
}
|
|
30445
|
+
function loadOrCreateDeviceKey(path2) {
|
|
30446
|
+
try {
|
|
30447
|
+
return {
|
|
30448
|
+
key: deviceKeyFromPem(readFileSync10(path2, "utf8")),
|
|
30449
|
+
created: false
|
|
30450
|
+
};
|
|
30451
|
+
} catch (error2) {
|
|
30452
|
+
if (error2.code !== "ENOENT") throw error2;
|
|
30453
|
+
}
|
|
30454
|
+
const key = generateDeviceKey();
|
|
30455
|
+
writeSensitiveFileAtomic(path2, deviceKeyPem(key));
|
|
30456
|
+
return { key, created: true };
|
|
30457
|
+
}
|
|
30458
|
+
function credentialDigest(credential) {
|
|
30459
|
+
return createHash6("sha256").update(credential, "utf8").digest("hex");
|
|
30460
|
+
}
|
|
30461
|
+
function deviceKeyProofMessage(claims2) {
|
|
30462
|
+
return JSON.stringify([
|
|
30463
|
+
DEVICE_KEY_PROOF_DOMAIN,
|
|
30464
|
+
claims2.credentialDigest,
|
|
30465
|
+
claims2.devicePublicKey,
|
|
30466
|
+
claims2.hostname,
|
|
30467
|
+
claims2.osUser,
|
|
30468
|
+
claims2.platform,
|
|
30469
|
+
[...claims2.harnesses],
|
|
30470
|
+
claims2.signedAtUnixS
|
|
30471
|
+
]);
|
|
30472
|
+
}
|
|
30473
|
+
function signDeviceKeyProof(key, claims2) {
|
|
30474
|
+
return {
|
|
30475
|
+
signedAtUnixS: claims2.signedAtUnixS,
|
|
30476
|
+
signature: key.sign(
|
|
30477
|
+
deviceKeyProofMessage({ ...claims2, devicePublicKey: key.publicKey })
|
|
30478
|
+
)
|
|
30479
|
+
};
|
|
30480
|
+
}
|
|
30481
|
+
function verifyDeviceSignature(publicKey, message2, signatureBase64) {
|
|
30482
|
+
if (!publicKey.startsWith("ed25519:")) return false;
|
|
30483
|
+
const raw = Buffer.from(publicKey.slice("ed25519:".length), "base64");
|
|
30484
|
+
if (raw.length !== 32) return false;
|
|
30485
|
+
const spki = Buffer.concat([
|
|
30486
|
+
Buffer.from("302a300506032b6570032100", "hex"),
|
|
30487
|
+
raw
|
|
30488
|
+
]);
|
|
30489
|
+
try {
|
|
30490
|
+
return verify3(
|
|
30491
|
+
null,
|
|
30492
|
+
Buffer.from(message2, "utf8"),
|
|
30493
|
+
createPublicKey3({ key: spki, format: "der", type: "spki" }),
|
|
30494
|
+
Buffer.from(signatureBase64, "base64")
|
|
30495
|
+
);
|
|
30496
|
+
} catch {
|
|
30497
|
+
return false;
|
|
30498
|
+
}
|
|
30499
|
+
}
|
|
30500
|
+
var SPKI_ED25519_PREFIX_BYTES, DEVICE_KEY_PROOF_DOMAIN;
|
|
30501
|
+
var init_device_key = __esm({
|
|
30502
|
+
"../../packages/tacho/src/host/device-key.ts"() {
|
|
30503
|
+
"use strict";
|
|
30504
|
+
init_fs();
|
|
30505
|
+
SPKI_ED25519_PREFIX_BYTES = 12;
|
|
30506
|
+
DEVICE_KEY_PROOF_DOMAIN = "oxagen.tacho.device-key-proof.v1";
|
|
30507
|
+
}
|
|
30508
|
+
});
|
|
30509
|
+
|
|
30510
|
+
// ../../packages/tacho/src/host/request-signature.ts
|
|
30511
|
+
import { createHash as createHash7 } from "node:crypto";
|
|
30512
|
+
function bodySha256(body2) {
|
|
30513
|
+
return createHash7("sha256").update(body2).digest("hex");
|
|
30514
|
+
}
|
|
30515
|
+
function requestSignatureMessage(input2) {
|
|
30516
|
+
return JSON.stringify([
|
|
30517
|
+
REQUEST_SIGNATURE_DOMAIN,
|
|
30518
|
+
input2.method.toUpperCase(),
|
|
30519
|
+
input2.path,
|
|
30520
|
+
input2.signedAtUnixS,
|
|
30521
|
+
input2.bodySha256
|
|
30522
|
+
]);
|
|
30523
|
+
}
|
|
30524
|
+
function signRequest(key, input2) {
|
|
30525
|
+
return `v1 ts=${input2.signedAtUnixS} sig=${key.sign(requestSignatureMessage(input2))}`;
|
|
30526
|
+
}
|
|
30527
|
+
function parseRequestSignature(header2) {
|
|
30528
|
+
if (!header2) return void 0;
|
|
30529
|
+
const match = HEADER_PATTERN.exec(header2.trim());
|
|
30530
|
+
if (!match) return void 0;
|
|
30531
|
+
return { signedAtUnixS: Number(match[1]), signature: match[2] };
|
|
30532
|
+
}
|
|
30533
|
+
function verifyRequestSignature(devicePublicKey, header2, request4, nowUnixS, maxSkewS = REQUEST_SIGNATURE_MAX_SKEW_S) {
|
|
30534
|
+
if (!header2) return "missing";
|
|
30535
|
+
const parsed2 = parseRequestSignature(header2);
|
|
30536
|
+
if (parsed2 === void 0) return "malformed";
|
|
30537
|
+
if (Math.abs(nowUnixS - parsed2.signedAtUnixS) > maxSkewS) return "stale";
|
|
30538
|
+
const message2 = requestSignatureMessage({
|
|
30539
|
+
...request4,
|
|
30540
|
+
signedAtUnixS: parsed2.signedAtUnixS
|
|
30541
|
+
});
|
|
30542
|
+
return verifyDeviceSignature(devicePublicKey, message2, parsed2.signature) ? void 0 : "invalid";
|
|
30543
|
+
}
|
|
30544
|
+
function signedPathOf(url2) {
|
|
30545
|
+
const parsed2 = new URL(url2);
|
|
30546
|
+
return `${parsed2.pathname}${parsed2.search}`;
|
|
30547
|
+
}
|
|
30548
|
+
function deviceSignatureHeader(key, method, url2, body2, nowMs = Date.now()) {
|
|
30549
|
+
return {
|
|
30550
|
+
[REQUEST_SIGNATURE_HEADER]: signRequest(key, {
|
|
30551
|
+
method,
|
|
30552
|
+
path: signedPathOf(url2),
|
|
30553
|
+
bodySha256: bodySha256(body2),
|
|
30554
|
+
signedAtUnixS: Math.floor(nowMs / 1e3)
|
|
30555
|
+
})
|
|
30556
|
+
};
|
|
30557
|
+
}
|
|
30558
|
+
var REQUEST_SIGNATURE_HEADER, REQUEST_SIGNATURE_DOMAIN, REQUEST_SIGNATURE_MAX_SKEW_S, HEADER_PATTERN;
|
|
30559
|
+
var init_request_signature = __esm({
|
|
30560
|
+
"../../packages/tacho/src/host/request-signature.ts"() {
|
|
30561
|
+
"use strict";
|
|
30562
|
+
init_device_key();
|
|
30563
|
+
REQUEST_SIGNATURE_HEADER = "x-oxagen-device-signature";
|
|
30564
|
+
REQUEST_SIGNATURE_DOMAIN = "oxagen.tacho.request-signature.v1";
|
|
30565
|
+
REQUEST_SIGNATURE_MAX_SKEW_S = 300;
|
|
30566
|
+
HEADER_PATTERN = /^v1 ts=(\d{1,12}) sig=([A-Za-z0-9+/]+={0,2})$/;
|
|
30567
|
+
}
|
|
30568
|
+
});
|
|
30569
|
+
|
|
30570
|
+
// ../../packages/tacho/src/host/control-client.ts
|
|
30571
|
+
function parseRetryAfter(value, nowMs) {
|
|
30572
|
+
if (!value) return void 0;
|
|
30573
|
+
const seconds = Number(value);
|
|
30574
|
+
if (Number.isFinite(seconds)) return Math.max(0, seconds * 1e3);
|
|
30575
|
+
const at2 = Date.parse(value);
|
|
30576
|
+
return Number.isNaN(at2) ? void 0 : Math.max(0, at2 - nowMs);
|
|
30577
|
+
}
|
|
30578
|
+
function headerNumber(value) {
|
|
30579
|
+
if (value === null || value.trim().length === 0) return void 0;
|
|
30580
|
+
const parsed2 = Number(value);
|
|
30581
|
+
return Number.isFinite(parsed2) ? parsed2 : void 0;
|
|
30582
|
+
}
|
|
30583
|
+
function readRateLimitHint(headers, nowMs) {
|
|
30584
|
+
if (!headers) return void 0;
|
|
30585
|
+
const hint = {};
|
|
30586
|
+
const remaining = headerNumber(headers.get("x-ratelimit-remaining"));
|
|
30587
|
+
if (remaining !== void 0) hint.remaining = remaining;
|
|
30588
|
+
const reset = headerNumber(headers.get("x-ratelimit-reset"));
|
|
30589
|
+
if (reset !== void 0 && reset > 0) hint.resetAtMs = reset * 1e3;
|
|
30590
|
+
const retryAfter = parseRetryAfter(headers.get("retry-after"), nowMs);
|
|
30591
|
+
if (retryAfter !== void 0) hint.retryAfterMs = retryAfter;
|
|
30592
|
+
return Object.keys(hint).length > 0 ? hint : void 0;
|
|
30593
|
+
}
|
|
30594
|
+
function workOrderEndpointsFor(apiUrl) {
|
|
30595
|
+
const base2 = apiUrl.replace(/\/+$/, "");
|
|
30596
|
+
return {
|
|
30597
|
+
workOrderClaim: `${base2}${WORK_ORDER_CLAIM_PATH}`,
|
|
30598
|
+
workOrderReject: `${base2}${WORK_ORDER_REJECT_PATH}`,
|
|
30599
|
+
workCriterionClaim: `${base2}${WORK_CRITERION_CLAIM_PATH}`,
|
|
30600
|
+
workOrderChecklist: `${base2}${WORK_ORDER_CHECKLIST_PATH}`,
|
|
30601
|
+
workOrderProgress: `${base2}${WORK_ORDER_PROGRESS_PATH}`,
|
|
30602
|
+
certificate: `${base2}${CERTIFICATE_RENEW_PATH}`,
|
|
30603
|
+
enrollmentKeys: `${base2}${ENROLLMENT_KEYS_PATH}`,
|
|
30604
|
+
hostConnection: `${base2}${HOST_CONNECTION_PATH}`,
|
|
30605
|
+
modelCredentials: `${base2}${HOST_MODEL_CREDENTIALS_PATH}`,
|
|
30606
|
+
modelCredentialState: `${base2}${HOST_MODEL_CREDENTIAL_STATE_PATH}`,
|
|
30607
|
+
modelCredentialRefresh: `${base2}${HOST_MODEL_CREDENTIAL_REFRESH_PATH}`
|
|
30608
|
+
};
|
|
30609
|
+
}
|
|
30610
|
+
function createControlClient(options) {
|
|
30611
|
+
const fetchImpl = options.fetch ?? ((input2, init) => fetch(input2, init));
|
|
30612
|
+
const timeoutMs = options.timeoutMs ?? 15e3;
|
|
30613
|
+
const ingestTimeoutMs = options.ingestTimeoutMs ?? TACHO_INGEST_TIMEOUT_MS;
|
|
30614
|
+
const nowMs = options.now ?? Date.now;
|
|
30615
|
+
async function post3(url2, body2, boundMs = timeoutMs, method = "POST", extraHeaders = {}) {
|
|
30616
|
+
const controller = new AbortController();
|
|
30617
|
+
const timer = setTimeout(() => controller.abort(), boundMs);
|
|
30618
|
+
const signal = options.signal === void 0 ? controller.signal : AbortSignal.any([controller.signal, options.signal]);
|
|
30619
|
+
let response;
|
|
30620
|
+
let text6;
|
|
30621
|
+
try {
|
|
30622
|
+
const payload = method === "GET" ? "" : JSON.stringify(body2);
|
|
30623
|
+
response = await fetchImpl(url2, {
|
|
30624
|
+
method,
|
|
30625
|
+
headers: {
|
|
30626
|
+
...method === "GET" ? {} : { Authorization: `Bearer ${options.apiKey}` },
|
|
30627
|
+
"Content-Type": "application/json",
|
|
30628
|
+
"User-Agent": options.userAgent ?? "tachod",
|
|
30629
|
+
...extraHeaders,
|
|
30630
|
+
...options.deviceKey !== void 0 && method !== "GET" ? deviceSignatureHeader(
|
|
30631
|
+
options.deviceKey,
|
|
30632
|
+
method,
|
|
30633
|
+
url2,
|
|
30634
|
+
payload,
|
|
30635
|
+
nowMs()
|
|
30636
|
+
) : {}
|
|
30637
|
+
},
|
|
30638
|
+
...method === "GET" ? {} : { body: payload },
|
|
30639
|
+
signal
|
|
30640
|
+
});
|
|
30641
|
+
text6 = await response.text();
|
|
30642
|
+
} catch (error2) {
|
|
30643
|
+
throw new ControlUnreachable(error2, url2);
|
|
30644
|
+
} finally {
|
|
30645
|
+
clearTimeout(timer);
|
|
30646
|
+
}
|
|
30647
|
+
const hint = readRateLimitHint(response.headers, nowMs());
|
|
30648
|
+
if (hint) options.onRateLimit?.(hint);
|
|
30649
|
+
if (!response.ok)
|
|
30650
|
+
throw new ControlError(response.status, text6, void 0, hint);
|
|
30651
|
+
try {
|
|
30652
|
+
return JSON.parse(text6);
|
|
30653
|
+
} catch {
|
|
30654
|
+
throw new ControlError(
|
|
30655
|
+
response.status,
|
|
30656
|
+
text6,
|
|
30657
|
+
"control plane answered non-JSON",
|
|
30658
|
+
hint
|
|
30659
|
+
);
|
|
30660
|
+
}
|
|
30661
|
+
}
|
|
30662
|
+
function endpoint(url2, name2) {
|
|
30663
|
+
if (url2 === void 0)
|
|
30664
|
+
throw new Error(`the control client has no ${name2} endpoint`);
|
|
30665
|
+
return url2;
|
|
30666
|
+
}
|
|
30667
|
+
async function call2(url2, schema, body2, boundMs, method = "POST", extraHeaders) {
|
|
30668
|
+
const parsed2 = schema.safeParse(
|
|
30669
|
+
await post3(url2, body2, boundMs, method, extraHeaders)
|
|
30670
|
+
);
|
|
30671
|
+
if (!parsed2.success)
|
|
30672
|
+
throw new ControlAnswerUnreadable(url2, zodIssues(parsed2.error));
|
|
30673
|
+
return parsed2.data;
|
|
30674
|
+
}
|
|
30675
|
+
return {
|
|
30676
|
+
ingest: (events, daemon, bodies) => call2(
|
|
30677
|
+
options.endpoints.ingest,
|
|
30678
|
+
ingestResponseSchema,
|
|
30679
|
+
{
|
|
30680
|
+
schema: TACHO_BATCH_SCHEMA,
|
|
30681
|
+
host_enrollment_id: options.hostEnrollmentId,
|
|
30682
|
+
events,
|
|
30683
|
+
...bodies !== void 0 && bodies.length > 0 ? { bodies } : {},
|
|
30684
|
+
...daemon !== void 0 ? { daemon } : {}
|
|
30685
|
+
},
|
|
30686
|
+
ingestTimeoutMs
|
|
30687
|
+
),
|
|
30688
|
+
bundle: (etag, run3) => call2(options.endpoints.bundle, bundleResponseSchema, {
|
|
30689
|
+
host_enrollment_id: options.hostEnrollmentId,
|
|
30690
|
+
...etag !== void 0 ? { etag } : {},
|
|
30691
|
+
...run3?.remote !== void 0 ? { remote: run3.remote } : {},
|
|
30692
|
+
...run3?.harness !== void 0 ? { harness: run3.harness } : {}
|
|
30693
|
+
}),
|
|
30694
|
+
commands: (acknowledgements = [], daemon) => call2(options.endpoints.commands, commandsResponseSchema, {
|
|
30695
|
+
schema: TACHO_COMMANDS_SCHEMA,
|
|
30696
|
+
host_enrollment_id: options.hostEnrollmentId,
|
|
30697
|
+
acknowledgements,
|
|
30698
|
+
...daemon !== void 0 ? { daemon } : {}
|
|
30699
|
+
}),
|
|
30700
|
+
claimWorkOrder: async (workOrderId) => call2(
|
|
30701
|
+
endpoint(options.endpoints.workOrderClaim, "work order claim"),
|
|
30702
|
+
workOrderClaimResponseSchema,
|
|
30703
|
+
{
|
|
30704
|
+
host_enrollment_id: options.hostEnrollmentId,
|
|
30705
|
+
work_order_id: workOrderId
|
|
30706
|
+
}
|
|
30707
|
+
),
|
|
30708
|
+
rejectWorkOrder: async (workOrderId, reason4) => call2(
|
|
30709
|
+
endpoint(options.endpoints.workOrderReject, "work order refusal"),
|
|
30710
|
+
workOrderRejectResponseSchema,
|
|
30711
|
+
{
|
|
30712
|
+
host_enrollment_id: options.hostEnrollmentId,
|
|
30713
|
+
work_order_id: workOrderId,
|
|
30714
|
+
reason: reason4
|
|
30715
|
+
}
|
|
30716
|
+
),
|
|
30717
|
+
// An empty body: the server reads the host from the key, and the device
|
|
30718
|
+
// signature over the request proves the machine holds the key the
|
|
30719
|
+
// certificate names.
|
|
30720
|
+
renewCertificate: async () => call2(
|
|
30721
|
+
endpoint(options.endpoints.certificate, "certificate renewal"),
|
|
30722
|
+
certificateRenewalResponseSchema,
|
|
30723
|
+
{}
|
|
30724
|
+
),
|
|
30725
|
+
enrollmentKeys: async () => call2(
|
|
30726
|
+
endpoint(options.endpoints.enrollmentKeys, "enrollment keys"),
|
|
30727
|
+
enrollmentKeysResponseSchema,
|
|
30728
|
+
void 0,
|
|
30729
|
+
void 0,
|
|
30730
|
+
"GET"
|
|
30731
|
+
),
|
|
30732
|
+
setConnection: async (state) => call2(
|
|
30733
|
+
endpoint(options.endpoints.hostConnection, "workspace connection"),
|
|
30734
|
+
hostConnectionChangeResponseSchema,
|
|
30735
|
+
{ host_enrollment_id: options.hostEnrollmentId, state }
|
|
30736
|
+
),
|
|
30737
|
+
modelCredentials: async (harness) => call2(
|
|
30738
|
+
endpoint(options.endpoints.modelCredentials, "model credentials"),
|
|
30739
|
+
hostModelCredentialsResponseSchema,
|
|
30740
|
+
{ host_enrollment_id: options.hostEnrollmentId, harness }
|
|
30741
|
+
),
|
|
30742
|
+
reportModelCredential: async (credentialId, report) => call2(
|
|
30743
|
+
endpoint(
|
|
30744
|
+
options.endpoints.modelCredentialState,
|
|
30745
|
+
"model credential report"
|
|
30746
|
+
),
|
|
30747
|
+
hostModelCredentialStateResponseSchema,
|
|
30748
|
+
{
|
|
30749
|
+
host_enrollment_id: options.hostEnrollmentId,
|
|
30750
|
+
credential_id: credentialId,
|
|
30751
|
+
report
|
|
30752
|
+
}
|
|
30753
|
+
),
|
|
30754
|
+
refreshModelCredential: async (credentialId, refresh) => call2(
|
|
30755
|
+
endpoint(
|
|
30756
|
+
options.endpoints.modelCredentialRefresh,
|
|
30757
|
+
"model credential refresh"
|
|
30758
|
+
),
|
|
30759
|
+
hostModelCredentialRefreshResponseSchema,
|
|
30760
|
+
{
|
|
30761
|
+
host_enrollment_id: options.hostEnrollmentId,
|
|
30762
|
+
credential_id: credentialId,
|
|
30763
|
+
vault_changed_at: refresh.vault_changed_at,
|
|
30764
|
+
secret: refresh.secret
|
|
30765
|
+
}
|
|
30766
|
+
),
|
|
30767
|
+
// The body names exactly the contract's fields. It carries no enrollment
|
|
30768
|
+
// id: the server reads the host from the key. The run's token goes in a
|
|
30769
|
+
// header, so it stays out of the input the kernel hashes and audits.
|
|
30770
|
+
claimWorkCriterion: async (claim2, token) => call2(
|
|
30771
|
+
endpoint(options.endpoints.workCriterionClaim, "criterion claim"),
|
|
30772
|
+
workCriterionClaimResponseSchema,
|
|
30773
|
+
{
|
|
30774
|
+
item_id: claim2.item_id,
|
|
30775
|
+
work_order_id: claim2.work_order_id,
|
|
30776
|
+
criterion_id: claim2.criterion_id,
|
|
30777
|
+
head_sha: claim2.head_sha,
|
|
30778
|
+
text: claim2.text,
|
|
30779
|
+
status: claim2.status,
|
|
30780
|
+
evidence: claim2.evidence
|
|
30781
|
+
},
|
|
30782
|
+
void 0,
|
|
30783
|
+
"POST",
|
|
30784
|
+
{ [WORK_ORDER_TOKEN_HEADER]: token }
|
|
30785
|
+
),
|
|
30786
|
+
readWorkOrderChecklist: async (workOrderId, token) => call2(
|
|
30787
|
+
endpoint(options.endpoints.workOrderChecklist, "work order checklist"),
|
|
30788
|
+
workOrderChecklistResponseSchema,
|
|
30789
|
+
{
|
|
30790
|
+
host_enrollment_id: options.hostEnrollmentId,
|
|
30791
|
+
work_order_id: workOrderId
|
|
30792
|
+
},
|
|
30793
|
+
void 0,
|
|
30794
|
+
"POST",
|
|
30795
|
+
{ [WORK_ORDER_TOKEN_HEADER]: token }
|
|
30796
|
+
),
|
|
30797
|
+
// The body names exactly the contract's fields, and `ask` only when the
|
|
30798
|
+
// agent asked something. The token goes in a header, as for a claim.
|
|
30799
|
+
postWorkProgress: async (progress, token) => call2(
|
|
30800
|
+
endpoint(options.endpoints.workOrderProgress, "progress update"),
|
|
30801
|
+
workProgressResponseSchema,
|
|
30802
|
+
{
|
|
30803
|
+
work_order_id: progress.work_order_id,
|
|
30804
|
+
step: { n: progress.step.n, of: progress.step.of },
|
|
30805
|
+
changed: progress.changed,
|
|
30806
|
+
passed: progress.passed,
|
|
30807
|
+
next: progress.next,
|
|
30808
|
+
...progress.ask !== void 0 ? { ask: progress.ask } : {}
|
|
30809
|
+
},
|
|
30810
|
+
void 0,
|
|
30811
|
+
"POST",
|
|
30812
|
+
{ [WORK_ORDER_TOKEN_HEADER]: token }
|
|
30813
|
+
)
|
|
30814
|
+
};
|
|
30815
|
+
}
|
|
30816
|
+
function controlErrorMessage(error2) {
|
|
30817
|
+
try {
|
|
30818
|
+
const body2 = JSON.parse(error2.body);
|
|
30819
|
+
if (typeof body2 === "object" && body2 !== null) {
|
|
30820
|
+
const inner = body2["error"];
|
|
30821
|
+
if (typeof inner === "object" && inner !== null) {
|
|
30822
|
+
const message3 = inner["message"];
|
|
30823
|
+
if (typeof message3 === "string" && message3.length > 0) return message3;
|
|
30824
|
+
}
|
|
30825
|
+
const message2 = body2["message"];
|
|
30826
|
+
if (typeof message2 === "string" && message2.length > 0) return message2;
|
|
30827
|
+
}
|
|
30828
|
+
} catch {
|
|
30829
|
+
}
|
|
30830
|
+
return `Oxagen answered ${error2.status}.`;
|
|
30831
|
+
}
|
|
30832
|
+
function controlErrorReason(error2) {
|
|
30833
|
+
try {
|
|
30834
|
+
const body2 = JSON.parse(error2.body);
|
|
30835
|
+
if (typeof body2 === "object" && body2 !== null) {
|
|
30836
|
+
const inner = body2["error"];
|
|
30837
|
+
if (typeof inner === "object" && inner !== null) {
|
|
30838
|
+
const reason4 = inner["reason"];
|
|
30839
|
+
if (typeof reason4 === "string" && reason4.length > 0) return reason4;
|
|
30840
|
+
}
|
|
30841
|
+
}
|
|
30842
|
+
} catch {
|
|
30843
|
+
}
|
|
30844
|
+
return void 0;
|
|
30845
|
+
}
|
|
30846
|
+
var TACHO_INGEST_TIMEOUT_MS, ControlError, ControlUnreachable, ControlAnswerUnreadable;
|
|
30847
|
+
var init_control_client = __esm({
|
|
30848
|
+
"../../packages/tacho/src/host/control-client.ts"() {
|
|
30849
|
+
"use strict";
|
|
30850
|
+
init_schema();
|
|
30851
|
+
init_request_signature();
|
|
30852
|
+
init_wire();
|
|
30853
|
+
TACHO_INGEST_TIMEOUT_MS = 6e4;
|
|
30854
|
+
ControlError = class extends Error {
|
|
30855
|
+
status;
|
|
30856
|
+
body;
|
|
30857
|
+
/**
|
|
30858
|
+
* What the server said about waiting, when it said anything. Carried on the
|
|
30859
|
+
* error so the Shipper can honour a 429's `Retry-After` instead of doubling
|
|
30860
|
+
* its own backoff past the window the server actually named.
|
|
30861
|
+
*/
|
|
30862
|
+
rateLimit;
|
|
30863
|
+
constructor(status2, body2, message2, rateLimit) {
|
|
30864
|
+
super(message2 ?? `control plane answered ${status2}: ${body2.slice(0, 256)}`);
|
|
30865
|
+
this.name = "ControlError";
|
|
30866
|
+
this.status = status2;
|
|
30867
|
+
this.body = body2;
|
|
30868
|
+
this.rateLimit = rateLimit;
|
|
30869
|
+
}
|
|
30870
|
+
};
|
|
30871
|
+
ControlUnreachable = class extends Error {
|
|
30872
|
+
/** The endpoint the request was for, when the caller named it. */
|
|
30873
|
+
url;
|
|
30874
|
+
constructor(cause, url2) {
|
|
30875
|
+
super(
|
|
30876
|
+
`control plane unreachable${url2 === void 0 ? "" : ` at ${url2}`}: ${cause instanceof Error ? cause.message : String(cause)}`,
|
|
30877
|
+
{ cause }
|
|
30878
|
+
);
|
|
30879
|
+
this.name = "ControlUnreachable";
|
|
30880
|
+
this.url = url2;
|
|
30881
|
+
}
|
|
30882
|
+
};
|
|
30883
|
+
ControlAnswerUnreadable = class extends Error {
|
|
30884
|
+
url;
|
|
30885
|
+
constructor(url2, issues) {
|
|
30886
|
+
super(
|
|
30887
|
+
`control plane answered ${url2} in a shape this host does not read: ${issues}`
|
|
30888
|
+
);
|
|
30889
|
+
this.name = "ControlAnswerUnreadable";
|
|
30890
|
+
this.url = url2;
|
|
30891
|
+
}
|
|
30892
|
+
};
|
|
30893
|
+
}
|
|
30894
|
+
});
|
|
30895
|
+
|
|
30896
|
+
// ../../packages/tacho/src/host/login-write-back.ts
|
|
30897
|
+
function statusRetryable(status2) {
|
|
30898
|
+
return status2 === 408 || status2 === 429 || status2 >= 500 || status2 < 400;
|
|
30899
|
+
}
|
|
30900
|
+
function nameOf(login) {
|
|
30901
|
+
return login.hint !== void 0 ? `\u2026${login.hint}` : login.credential_id;
|
|
30902
|
+
}
|
|
30903
|
+
function messageOf2(error2) {
|
|
30904
|
+
return error2 instanceof Error ? error2.message : String(error2);
|
|
30905
|
+
}
|
|
30906
|
+
function describeOwedLogin(left) {
|
|
30907
|
+
return `the saved ChatGPT login ${left.name} (${left.credential_id}): ${left.detail}`;
|
|
30908
|
+
}
|
|
30909
|
+
async function writeBackOwedLogins(deps, gate) {
|
|
30910
|
+
const report = { stored: [], superseded: [], owed: [] };
|
|
30911
|
+
let owed;
|
|
30912
|
+
try {
|
|
30913
|
+
owed = deps.store.owedLogins();
|
|
30914
|
+
} catch (error2) {
|
|
30915
|
+
report.unreadable = messageOf2(error2);
|
|
30916
|
+
return report;
|
|
30917
|
+
}
|
|
30918
|
+
for (const login of owed) {
|
|
30919
|
+
const left = (detail, retryable) => ({
|
|
30920
|
+
provider: login.provider,
|
|
30921
|
+
harness: login.harness,
|
|
30922
|
+
credential_id: login.credential_id,
|
|
30923
|
+
name: nameOf(login),
|
|
30924
|
+
detail,
|
|
30925
|
+
retryable
|
|
30926
|
+
});
|
|
30927
|
+
const waiting2 = gate?.waiting(login);
|
|
30928
|
+
if (waiting2 !== void 0) {
|
|
30929
|
+
report.owed.push(waiting2);
|
|
30930
|
+
continue;
|
|
30931
|
+
}
|
|
30932
|
+
const keep = (owedLeft) => {
|
|
30933
|
+
report.owed.push(owedLeft);
|
|
30934
|
+
gate?.sent(login, owedLeft);
|
|
30935
|
+
deps.log(
|
|
30936
|
+
`saved login write-back: Oxagen does not hold ${describeOwedLogin(owedLeft)}`
|
|
30937
|
+
);
|
|
30938
|
+
};
|
|
30939
|
+
let secret;
|
|
30940
|
+
try {
|
|
30941
|
+
const held = deps.store.open(login.provider, login.harness, login.id);
|
|
30942
|
+
if (held === void 0 || held.kind !== "chatgpt") continue;
|
|
30943
|
+
secret = held.secret;
|
|
30944
|
+
} catch (error2) {
|
|
30945
|
+
keep(left(`custody could not be read (${messageOf2(error2)})`, true));
|
|
30946
|
+
continue;
|
|
30947
|
+
}
|
|
30948
|
+
let outcome;
|
|
30949
|
+
let changedAt;
|
|
30950
|
+
try {
|
|
30951
|
+
const answer = await deps.client.refreshModelCredential(
|
|
30952
|
+
login.credential_id,
|
|
30953
|
+
{ vault_changed_at: login.vault_changed_at, secret }
|
|
30954
|
+
);
|
|
30955
|
+
outcome = answer.outcome;
|
|
30956
|
+
changedAt = answer.changed_at;
|
|
30957
|
+
} catch (error2) {
|
|
30958
|
+
if (error2 instanceof ControlError)
|
|
30959
|
+
keep(
|
|
30960
|
+
left(
|
|
30961
|
+
`Oxagen answered ${error2.status}: ${controlErrorMessage(error2)}`,
|
|
30962
|
+
statusRetryable(error2.status)
|
|
30963
|
+
)
|
|
30964
|
+
);
|
|
30965
|
+
else if (error2 instanceof ControlUnreachable)
|
|
30966
|
+
keep(left("Oxagen could not be reached", true));
|
|
30967
|
+
else if (error2 instanceof ControlAnswerUnreadable)
|
|
30968
|
+
keep(left("Oxagen answered in a shape this build does not read", true));
|
|
30969
|
+
else keep(left(`the request failed (${messageOf2(error2)})`, true));
|
|
30970
|
+
continue;
|
|
30971
|
+
}
|
|
30972
|
+
const refreshedAgain = () => deps.store.owedLogins().some(
|
|
30973
|
+
(o) => o.provider === login.provider && o.harness === login.harness && o.id === login.id && o.refreshed_at !== login.refreshed_at
|
|
30974
|
+
);
|
|
30975
|
+
const owedNewer = () => {
|
|
30976
|
+
const owedLeft = left(
|
|
30977
|
+
"it was refreshed again while the earlier tokens were sent, and the newer tokens go on the next pass",
|
|
30978
|
+
true
|
|
30979
|
+
);
|
|
30980
|
+
report.owed.push(owedLeft);
|
|
30981
|
+
gate?.sent(login, void 0);
|
|
30982
|
+
deps.log(
|
|
30983
|
+
`saved login write-back: Oxagen does not hold ${describeOwedLogin(owedLeft)}`
|
|
30984
|
+
);
|
|
30985
|
+
};
|
|
30986
|
+
try {
|
|
30987
|
+
if ((outcome === "stored" || outcome === "already_stored") && changedAt !== null) {
|
|
30988
|
+
const settled2 = deps.store.settleWriteBack(
|
|
30989
|
+
login.provider,
|
|
30990
|
+
login.harness,
|
|
30991
|
+
login.id,
|
|
30992
|
+
login.refreshed_at,
|
|
30993
|
+
{ state: "stored", changedAt }
|
|
30994
|
+
);
|
|
30995
|
+
if (!settled2 && refreshedAgain()) {
|
|
30996
|
+
owedNewer();
|
|
30997
|
+
continue;
|
|
30998
|
+
}
|
|
30999
|
+
report.stored.push(login.credential_id);
|
|
31000
|
+
gate?.sent(login, void 0);
|
|
31001
|
+
continue;
|
|
31002
|
+
}
|
|
31003
|
+
if (SUPERSEDED_OUTCOMES.has(outcome)) {
|
|
31004
|
+
const settled2 = deps.store.settleWriteBack(
|
|
31005
|
+
login.provider,
|
|
31006
|
+
login.harness,
|
|
31007
|
+
login.id,
|
|
31008
|
+
login.refreshed_at,
|
|
31009
|
+
{ state: "refused" }
|
|
31010
|
+
);
|
|
31011
|
+
if (!settled2 && refreshedAgain()) {
|
|
31012
|
+
owedNewer();
|
|
31013
|
+
continue;
|
|
31014
|
+
}
|
|
31015
|
+
report.superseded.push({
|
|
31016
|
+
credential_id: login.credential_id,
|
|
31017
|
+
outcome
|
|
31018
|
+
});
|
|
31019
|
+
gate?.sent(login, void 0);
|
|
31020
|
+
deps.log(
|
|
31021
|
+
`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`
|
|
31022
|
+
);
|
|
31023
|
+
continue;
|
|
31024
|
+
}
|
|
31025
|
+
} catch (error2) {
|
|
31026
|
+
keep(left(`custody could not be written (${messageOf2(error2)})`, true));
|
|
31027
|
+
continue;
|
|
31028
|
+
}
|
|
31029
|
+
keep(
|
|
31030
|
+
left(
|
|
31031
|
+
`Oxagen answered "${outcome.slice(0, 64)}", which this build does not read`,
|
|
31032
|
+
true
|
|
31033
|
+
)
|
|
31034
|
+
);
|
|
31035
|
+
}
|
|
31036
|
+
try {
|
|
31037
|
+
const listed = new Set(report.owed.map(slotKeyOf));
|
|
31038
|
+
for (const login of deps.store.owedLogins()) {
|
|
31039
|
+
if (listed.has(slotKeyOf(login))) continue;
|
|
31040
|
+
report.owed.push({
|
|
31041
|
+
provider: login.provider,
|
|
31042
|
+
harness: login.harness,
|
|
31043
|
+
credential_id: login.credential_id,
|
|
31044
|
+
name: nameOf(login),
|
|
31045
|
+
detail: "it was refreshed while this pass ran, and the next pass sends it",
|
|
31046
|
+
retryable: true
|
|
31047
|
+
});
|
|
31048
|
+
}
|
|
31049
|
+
} catch {
|
|
31050
|
+
}
|
|
31051
|
+
return report;
|
|
31052
|
+
}
|
|
31053
|
+
function slotKeyOf(login) {
|
|
31054
|
+
return `${login.provider}\0${login.harness}\0${login.credential_id}`;
|
|
31055
|
+
}
|
|
31056
|
+
function owedWithNoSender(store, detail, retryable = false) {
|
|
31057
|
+
const report = { stored: [], superseded: [], owed: [] };
|
|
31058
|
+
try {
|
|
31059
|
+
for (const login of store.owedLogins())
|
|
31060
|
+
report.owed.push({
|
|
31061
|
+
provider: login.provider,
|
|
31062
|
+
harness: login.harness,
|
|
31063
|
+
credential_id: login.credential_id,
|
|
31064
|
+
name: nameOf(login),
|
|
31065
|
+
detail,
|
|
31066
|
+
retryable
|
|
31067
|
+
});
|
|
31068
|
+
} catch (error2) {
|
|
31069
|
+
report.unreadable = messageOf2(error2);
|
|
31070
|
+
}
|
|
31071
|
+
return report;
|
|
31072
|
+
}
|
|
31073
|
+
function createLoginWriteBack(deps) {
|
|
31074
|
+
const failed5 = /* @__PURE__ */ new Map();
|
|
31075
|
+
const gate = {
|
|
31076
|
+
waiting: (login) => {
|
|
31077
|
+
const last = failed5.get(login.credential_id);
|
|
31078
|
+
if (last === void 0 || last.refreshedAt !== login.refreshed_at)
|
|
31079
|
+
return void 0;
|
|
31080
|
+
return deps.now() < last.nextAt ? last.left : void 0;
|
|
31081
|
+
},
|
|
31082
|
+
sent: (login, left) => {
|
|
31083
|
+
if (left === void 0) {
|
|
31084
|
+
failed5.delete(login.credential_id);
|
|
31085
|
+
return;
|
|
31086
|
+
}
|
|
31087
|
+
const last = failed5.get(login.credential_id);
|
|
31088
|
+
const count15 = last !== void 0 && last.refreshedAt === login.refreshed_at ? last.count + 1 : 1;
|
|
31089
|
+
failed5.set(login.credential_id, {
|
|
31090
|
+
refreshedAt: login.refreshed_at,
|
|
31091
|
+
count: count15,
|
|
31092
|
+
nextAt: deps.now() + Math.min(
|
|
31093
|
+
WRITE_BACK_RETRY_MS * 2 ** (count15 - 1),
|
|
31094
|
+
WRITE_BACK_RETRY_MAX_MS
|
|
31095
|
+
),
|
|
31096
|
+
left
|
|
31097
|
+
});
|
|
31098
|
+
}
|
|
31099
|
+
};
|
|
31100
|
+
let running;
|
|
31101
|
+
return {
|
|
31102
|
+
drain: () => {
|
|
31103
|
+
running ??= writeBackOwedLogins(deps, gate).catch(
|
|
31104
|
+
(error2) => ({
|
|
31105
|
+
stored: [],
|
|
31106
|
+
superseded: [],
|
|
31107
|
+
owed: [],
|
|
31108
|
+
unreadable: messageOf2(error2)
|
|
31109
|
+
})
|
|
31110
|
+
).finally(() => {
|
|
31111
|
+
running = void 0;
|
|
31112
|
+
});
|
|
31113
|
+
return running;
|
|
31114
|
+
}
|
|
31115
|
+
};
|
|
31116
|
+
}
|
|
31117
|
+
function owedIn(report, slot) {
|
|
31118
|
+
return slot === void 0 ? report.owed : report.owed.filter(
|
|
31119
|
+
(left) => left.provider === slot.provider && left.harness === slot.harness
|
|
31120
|
+
);
|
|
31121
|
+
}
|
|
31122
|
+
var SUPERSEDED_OUTCOMES, WRITE_BACK_RETRY_MS, WRITE_BACK_RETRY_MAX_MS;
|
|
31123
|
+
var init_login_write_back = __esm({
|
|
31124
|
+
"../../packages/tacho/src/host/login-write-back.ts"() {
|
|
31125
|
+
"use strict";
|
|
31126
|
+
init_control_client();
|
|
31127
|
+
SUPERSEDED_OUTCOMES = /* @__PURE__ */ new Set([
|
|
31128
|
+
"changed_elsewhere",
|
|
31129
|
+
"different_account",
|
|
31130
|
+
"not_found"
|
|
31131
|
+
]);
|
|
31132
|
+
WRITE_BACK_RETRY_MS = 6e4;
|
|
31133
|
+
WRITE_BACK_RETRY_MAX_MS = 15 * 6e4;
|
|
31134
|
+
}
|
|
31135
|
+
});
|
|
31136
|
+
|
|
30086
31137
|
// ../../packages/tacho/src/host/model-base-url-toml.ts
|
|
30087
31138
|
function splitLines(text6) {
|
|
30088
31139
|
const lines = [];
|
|
@@ -30208,7 +31259,7 @@ var init_model_base_url_toml = __esm({
|
|
|
30208
31259
|
});
|
|
30209
31260
|
|
|
30210
31261
|
// ../../packages/tacho/src/host/model-base-url.ts
|
|
30211
|
-
import { chmodSync as chmodSync3, existsSync as existsSync9, readFileSync as
|
|
31262
|
+
import { chmodSync as chmodSync3, existsSync as existsSync9, readFileSync as readFileSync11, unlinkSync as unlinkSync6 } from "node:fs";
|
|
30212
31263
|
import { basename as basename4, dirname as dirname12, join as join18 } from "node:path";
|
|
30213
31264
|
function claudeToolSearchEnabled(value) {
|
|
30214
31265
|
return typeof value === "string" && /^(true|auto(:\d+)?)$/i.test(value);
|
|
@@ -30586,7 +31637,7 @@ function describe3(harness, options, { changed, text: text6, sidecar, unreadable
|
|
|
30586
31637
|
}
|
|
30587
31638
|
function readBytesIfExists(path2) {
|
|
30588
31639
|
try {
|
|
30589
|
-
return
|
|
31640
|
+
return readFileSync11(path2);
|
|
30590
31641
|
} catch (error2) {
|
|
30591
31642
|
if (error2.code === "ENOENT") return void 0;
|
|
30592
31643
|
throw error2;
|
|
@@ -31751,6 +32802,41 @@ function harnessDirsOf(deps) {
|
|
|
31751
32802
|
stellaHome: dirname13(deps.paths.stellaToml)
|
|
31752
32803
|
};
|
|
31753
32804
|
}
|
|
32805
|
+
async function owedBeforeRelease(deps, slot) {
|
|
32806
|
+
const store = deps.credentialStore;
|
|
32807
|
+
if (store === void 0) return [];
|
|
32808
|
+
try {
|
|
32809
|
+
const owes = store.owedLogins().some(
|
|
32810
|
+
(login) => slot === void 0 || login.provider === slot.provider && login.harness === slot.harness
|
|
32811
|
+
);
|
|
32812
|
+
if (!owes) return [];
|
|
32813
|
+
} catch {
|
|
32814
|
+
return [];
|
|
32815
|
+
}
|
|
32816
|
+
let report;
|
|
32817
|
+
if (deps.writeBackLogins === void 0)
|
|
32818
|
+
report = owedWithNoSender(
|
|
32819
|
+
store,
|
|
32820
|
+
"this command has no way to send it to Oxagen"
|
|
32821
|
+
);
|
|
32822
|
+
else
|
|
32823
|
+
try {
|
|
32824
|
+
report = await deps.writeBackLogins();
|
|
32825
|
+
} catch (error2) {
|
|
32826
|
+
report = owedWithNoSender(
|
|
32827
|
+
store,
|
|
32828
|
+
`the write-back did not run (${error2 instanceof Error ? error2.message : String(error2)})`,
|
|
32829
|
+
true
|
|
32830
|
+
);
|
|
32831
|
+
}
|
|
32832
|
+
return owedIn(report, slot);
|
|
32833
|
+
}
|
|
32834
|
+
function lostLoginWarning(lost) {
|
|
32835
|
+
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`;
|
|
32836
|
+
}
|
|
32837
|
+
function owedList(owed) {
|
|
32838
|
+
return owed.map(describeOwedLogin).join("; ");
|
|
32839
|
+
}
|
|
31754
32840
|
function parseCredentialMode(value) {
|
|
31755
32841
|
if (value === void 0 || value.length === 0) return "brokered";
|
|
31756
32842
|
if (CREDENTIAL_MODES.includes(value))
|
|
@@ -32013,6 +33099,7 @@ async function brokerCredentials(host, harnesses, deps) {
|
|
|
32013
33099
|
return { harnesses: [], taken: [], warnings };
|
|
32014
33100
|
const helperCommand = deps.runtime.credentialHelperCommand;
|
|
32015
33101
|
const dirs = harnessDirsOf(deps);
|
|
33102
|
+
await owedBeforeRelease(deps);
|
|
32016
33103
|
if (targets.includes("codex") && codexHoldsTakenChatGptLogin(deps.home, dirs)) {
|
|
32017
33104
|
let held;
|
|
32018
33105
|
try {
|
|
@@ -32032,10 +33119,20 @@ async function brokerCredentials(host, harnesses, deps) {
|
|
|
32032
33119
|
if (targets.includes("codex") && codexHoldsOwnChatGptLogin(deps.home, dirs)) {
|
|
32033
33120
|
try {
|
|
32034
33121
|
if (store.read("openai", "codex")?.kind === "chatgpt") {
|
|
32035
|
-
|
|
32036
|
-
|
|
32037
|
-
|
|
32038
|
-
);
|
|
33122
|
+
const owed = await owedBeforeRelease(deps, {
|
|
33123
|
+
provider: "openai",
|
|
33124
|
+
harness: "codex"
|
|
33125
|
+
});
|
|
33126
|
+
if (owed.length > 0) {
|
|
33127
|
+
warnings.push(
|
|
33128
|
+
`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`
|
|
33129
|
+
);
|
|
33130
|
+
} else {
|
|
33131
|
+
store.release("openai", "codex");
|
|
33132
|
+
warnings.push(
|
|
33133
|
+
"dropped the gateway's copy of Codex's ChatGPT login; Codex keeps its own"
|
|
33134
|
+
);
|
|
33135
|
+
}
|
|
32039
33136
|
}
|
|
32040
33137
|
} catch (error2) {
|
|
32041
33138
|
warnings.push(
|
|
@@ -32126,9 +33223,22 @@ async function brokerCredentials(host, harnesses, deps) {
|
|
|
32126
33223
|
staticTokens
|
|
32127
33224
|
});
|
|
32128
33225
|
} catch (error2) {
|
|
32129
|
-
|
|
33226
|
+
const kept = [];
|
|
33227
|
+
for (const { provider, harness } of takenNow) {
|
|
33228
|
+
const owed = await owedBeforeRelease(deps, { provider, harness });
|
|
33229
|
+
if (owed.length > 0) {
|
|
33230
|
+
kept.push(
|
|
33231
|
+
`custody keeps ${TACHO_HARNESS_LABELS[harness]}'s ${provider} credential, because giving it up would also drop the only working tokens of ${owedList(owed)}`
|
|
33232
|
+
);
|
|
33233
|
+
continue;
|
|
33234
|
+
}
|
|
32130
33235
|
store.release(provider, harness);
|
|
32131
|
-
|
|
33236
|
+
}
|
|
33237
|
+
if (kept.length === 0) throw error2;
|
|
33238
|
+
throw new Error(
|
|
33239
|
+
`${error2 instanceof Error ? error2.message : String(error2)}; ${kept.join("; ")}. Run \`oxagen agent enroll\` again once Oxagen is reachable`,
|
|
33240
|
+
{ cause: error2 }
|
|
33241
|
+
);
|
|
32132
33242
|
}
|
|
32133
33243
|
for (const taken of state.taken) {
|
|
32134
33244
|
if (offered.has(taken.harness)) continue;
|
|
@@ -32165,6 +33275,13 @@ async function brokerCredentials(host, harnesses, deps) {
|
|
|
32165
33275
|
}
|
|
32166
33276
|
const at2 = takenNow.findIndex((t) => t.harness === harness);
|
|
32167
33277
|
if (at2 >= 0 && store.has(provider, harness)) {
|
|
33278
|
+
const owed = await owedBeforeRelease(deps, { provider, harness });
|
|
33279
|
+
if (owed.length > 0) {
|
|
33280
|
+
warnings.push(
|
|
33281
|
+
`${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`
|
|
33282
|
+
);
|
|
33283
|
+
continue;
|
|
33284
|
+
}
|
|
32168
33285
|
const released = store.release(provider, harness);
|
|
32169
33286
|
takenNow.splice(at2, 1);
|
|
32170
33287
|
const offer = offered.get(harness);
|
|
@@ -32192,10 +33309,27 @@ async function restoreCredentials(host, deps, mode = "unenroll", only) {
|
|
|
32192
33309
|
const failed5 = [];
|
|
32193
33310
|
const warnings = [];
|
|
32194
33311
|
let custodyUnreadable = false;
|
|
33312
|
+
const owed = [];
|
|
32195
33313
|
const contract = deps.modelCredentials;
|
|
32196
33314
|
const store = deps.credentialStore;
|
|
32197
33315
|
if (contract === void 0)
|
|
32198
|
-
return { restored, failed: failed5, warnings, custodyUnreadable };
|
|
33316
|
+
return { restored, failed: failed5, warnings, custodyUnreadable, owed };
|
|
33317
|
+
if (mode === "unenroll") {
|
|
33318
|
+
const left = await owedBeforeRelease(deps);
|
|
33319
|
+
const waiting2 = left.filter((login) => login.retryable);
|
|
33320
|
+
if (waiting2.length > 0)
|
|
33321
|
+
return {
|
|
33322
|
+
restored,
|
|
33323
|
+
failed: failed5,
|
|
33324
|
+
warnings,
|
|
33325
|
+
custodyUnreadable,
|
|
33326
|
+
owed: waiting2.map(describeOwedLogin)
|
|
33327
|
+
};
|
|
33328
|
+
for (const lost of left) warnings.push(lostLoginWarning(lost));
|
|
33329
|
+
}
|
|
33330
|
+
const releaseSlot = (provider, harness) => {
|
|
33331
|
+
store?.release(provider, harness, { keepOwed: mode === "unenroll" });
|
|
33332
|
+
};
|
|
32199
33333
|
const helperCommand = deps.runtime.credentialHelperCommand;
|
|
32200
33334
|
const heldElsewhere = harnessesHeldElsewhere(deps.paths, deps.paths.dir);
|
|
32201
33335
|
for (const harness of MODEL_CREDENTIAL_HARNESSES) {
|
|
@@ -32219,11 +33353,28 @@ async function restoreCredentials(host, deps, mode = "unenroll", only) {
|
|
|
32219
33353
|
fromLogin = store?.status().some(
|
|
32220
33354
|
(c) => c.provider === provider && c.harness === harness && c.source === "claude:setup-token"
|
|
32221
33355
|
) === true;
|
|
32222
|
-
if (fromLogin) store?.
|
|
32223
|
-
else released = store?.read(provider, harness);
|
|
33356
|
+
if (!fromLogin) released = store?.read(provider, harness);
|
|
32224
33357
|
} catch (error2) {
|
|
32225
33358
|
unreadable = error2 instanceof Error ? error2.message : String(error2);
|
|
32226
33359
|
}
|
|
33360
|
+
const givesLoginBack = released?.kind === "chatgpt";
|
|
33361
|
+
if (mode === "passthrough" && unreadable === void 0 && !givesLoginBack) {
|
|
33362
|
+
const left = await owedBeforeRelease(deps, { provider, harness });
|
|
33363
|
+
if (left.length > 0) {
|
|
33364
|
+
owed.push(...left.map(describeOwedLogin));
|
|
33365
|
+
failed5.push(
|
|
33366
|
+
`${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`
|
|
33367
|
+
);
|
|
33368
|
+
continue;
|
|
33369
|
+
}
|
|
33370
|
+
}
|
|
33371
|
+
if (fromLogin && unreadable === void 0) {
|
|
33372
|
+
try {
|
|
33373
|
+
store?.release(provider, harness);
|
|
33374
|
+
} catch (error2) {
|
|
33375
|
+
unreadable = error2 instanceof Error ? error2.message : String(error2);
|
|
33376
|
+
}
|
|
33377
|
+
}
|
|
32227
33378
|
if (unreadable !== void 0) {
|
|
32228
33379
|
custodyUnreadable = true;
|
|
32229
33380
|
if (mode === "passthrough") {
|
|
@@ -32249,11 +33400,21 @@ async function restoreCredentials(host, deps, mode = "unenroll", only) {
|
|
|
32249
33400
|
if (entry2.changed) restored.push(entry2.file);
|
|
32250
33401
|
if (released === void 0) continue;
|
|
32251
33402
|
if (entry2.secretRestored === true) {
|
|
32252
|
-
|
|
33403
|
+
if (mode === "passthrough") {
|
|
33404
|
+
const left = await owedBeforeRelease(deps, { provider, harness });
|
|
33405
|
+
if (left.length > 0) {
|
|
33406
|
+
owed.push(...left.map(describeOwedLogin));
|
|
33407
|
+
warnings.push(
|
|
33408
|
+
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`
|
|
33409
|
+
);
|
|
33410
|
+
continue;
|
|
33411
|
+
}
|
|
33412
|
+
}
|
|
33413
|
+
releaseSlot(provider, harness);
|
|
32253
33414
|
continue;
|
|
32254
33415
|
}
|
|
32255
33416
|
if (mode === "unenroll") {
|
|
32256
|
-
|
|
33417
|
+
releaseSlot(provider, harness);
|
|
32257
33418
|
warnings.push(
|
|
32258
33419
|
`${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
33420
|
);
|
|
@@ -32267,7 +33428,7 @@ async function restoreCredentials(host, deps, mode = "unenroll", only) {
|
|
|
32267
33428
|
failed5.push(error2 instanceof Error ? error2.message : String(error2));
|
|
32268
33429
|
}
|
|
32269
33430
|
}
|
|
32270
|
-
return { restored, failed: failed5, warnings, custodyUnreadable };
|
|
33431
|
+
return { restored, failed: failed5, warnings, custodyUnreadable, owed };
|
|
32271
33432
|
}
|
|
32272
33433
|
async function acquireSubscriptionToken(options, deps) {
|
|
32273
33434
|
const io = deps.subscriptionLogin;
|
|
@@ -32456,6 +33617,7 @@ var init_credential = __esm({
|
|
|
32456
33617
|
init_zod();
|
|
32457
33618
|
init_claude_setup_token();
|
|
32458
33619
|
init_credential_store();
|
|
33620
|
+
init_login_write_back();
|
|
32459
33621
|
init_host_file();
|
|
32460
33622
|
init_model_credential();
|
|
32461
33623
|
init_agents();
|
|
@@ -32731,7 +33893,7 @@ import { join as join20 } from "node:path";
|
|
|
32731
33893
|
import {
|
|
32732
33894
|
existsSync as existsSync12,
|
|
32733
33895
|
readdirSync as readdirSync7,
|
|
32734
|
-
readFileSync as
|
|
33896
|
+
readFileSync as readFileSync12,
|
|
32735
33897
|
rmdirSync as rmdirSync4,
|
|
32736
33898
|
unlinkSync as unlinkSync8
|
|
32737
33899
|
} from "node:fs";
|
|
@@ -32832,7 +33994,7 @@ function launchdManager(options) {
|
|
|
32832
33994
|
unitPath,
|
|
32833
33995
|
install: (spec) => {
|
|
32834
33996
|
const plist = renderLaunchdPlist(spec);
|
|
32835
|
-
const unchanged = existsSync12(unitPath) &&
|
|
33997
|
+
const unchanged = existsSync12(unitPath) && readFileSync12(unitPath, "utf8") === plist;
|
|
32836
33998
|
if (unchanged && loaded()) {
|
|
32837
33999
|
const kicked = options.exec("launchctl", ["kickstart", "-k", target]);
|
|
32838
34000
|
if (kicked.status === 0 && loaded()) return;
|
|
@@ -32882,7 +34044,7 @@ function noUserManager(result2) {
|
|
|
32882
34044
|
function stopByPidFile(options) {
|
|
32883
34045
|
const { pidPath } = options;
|
|
32884
34046
|
if (pidPath === void 0 || !existsSync12(pidPath)) return;
|
|
32885
|
-
const record2 = parseDaemonPid(
|
|
34047
|
+
const record2 = parseDaemonPid(readFileSync12(pidPath, "utf8"));
|
|
32886
34048
|
if (record2 === void 0) return;
|
|
32887
34049
|
const sleep3 = options.sleep ?? blockingSleep;
|
|
32888
34050
|
const processes = options.processes ?? {
|
|
@@ -32933,7 +34095,7 @@ function systemdManager(options) {
|
|
|
32933
34095
|
throw new Error(
|
|
32934
34096
|
`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
34097
|
);
|
|
32936
|
-
const previous = existsSync12(unitPath) ?
|
|
34098
|
+
const previous = existsSync12(unitPath) ? readFileSync12(unitPath, "utf8") : void 0;
|
|
32937
34099
|
const createsWants = previous === void 0 ? !existsSync12(wants) : unitCreatedWants(previous);
|
|
32938
34100
|
ensureDir(dir, 493);
|
|
32939
34101
|
writeSensitiveFileAtomic(
|
|
@@ -32992,7 +34154,7 @@ function systemdManager(options) {
|
|
|
32992
34154
|
`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
34155
|
);
|
|
32994
34156
|
}
|
|
32995
|
-
const unit4 = existsSync12(unitPath) ?
|
|
34157
|
+
const unit4 = existsSync12(unitPath) ? readFileSync12(unitPath, "utf8") : void 0;
|
|
32996
34158
|
if (unit4 !== void 0) unlinkSync8(unitPath);
|
|
32997
34159
|
try {
|
|
32998
34160
|
const reload = options.exec("systemctl", ["--user", "daemon-reload"]);
|
|
@@ -33078,7 +34240,7 @@ function schtasksManager(options) {
|
|
|
33078
34240
|
const pidPath = options.pidPath ?? join20(launcher, "..", "tachod.pid");
|
|
33079
34241
|
const liveRecord = () => {
|
|
33080
34242
|
if (!existsSync12(pidPath)) return void 0;
|
|
33081
|
-
const record2 = parseDaemonPid(
|
|
34243
|
+
const record2 = parseDaemonPid(readFileSync12(pidPath, "utf8"));
|
|
33082
34244
|
if (record2 === void 0) return void 0;
|
|
33083
34245
|
const { pid } = record2;
|
|
33084
34246
|
const query = options.exec("tasklist", [
|
|
@@ -33249,15 +34411,15 @@ var init_service = __esm({
|
|
|
33249
34411
|
});
|
|
33250
34412
|
|
|
33251
34413
|
// ../../packages/tacho/src/version.ts
|
|
33252
|
-
import { readFileSync as
|
|
34414
|
+
import { readFileSync as readFileSync13 } from "node:fs";
|
|
33253
34415
|
import { dirname as dirname14, resolve as resolve3 } from "node:path";
|
|
33254
34416
|
import { fileURLToPath } from "node:url";
|
|
33255
34417
|
function readVersion() {
|
|
33256
|
-
if (true) return "5.5.1-
|
|
34418
|
+
if (true) return "5.5.1-274";
|
|
33257
34419
|
try {
|
|
33258
34420
|
const here = dirname14(fileURLToPath(import.meta.url));
|
|
33259
34421
|
const pkg = JSON.parse(
|
|
33260
|
-
|
|
34422
|
+
readFileSync13(resolve3(here, "..", "package.json"), "utf8")
|
|
33261
34423
|
);
|
|
33262
34424
|
return pkg.version ?? "0.0.0";
|
|
33263
34425
|
} catch {
|
|
@@ -33653,6 +34815,10 @@ function defaultCliDeps(overrides = {}, managed = {}) {
|
|
|
33653
34815
|
const credentialInternals = { managedSettingsFile: claudeManaged };
|
|
33654
34816
|
const paths = overrides.paths ?? defaultAgentPaths(tachoHome(env, home, platform2));
|
|
33655
34817
|
const harnessFiles = new HarnessFiles(paths.dir);
|
|
34818
|
+
const credentialStore = openCredentialStore({
|
|
34819
|
+
file: paths.credentials,
|
|
34820
|
+
key: paths.credentialsKey
|
|
34821
|
+
});
|
|
33656
34822
|
const harnessDirs = {
|
|
33657
34823
|
claudeConfigDir: dirname15(paths.claudeSettings),
|
|
33658
34824
|
codexHome: dirname15(paths.codexHooks),
|
|
@@ -33830,10 +34996,34 @@ function defaultCliDeps(overrides = {}, managed = {}) {
|
|
|
33830
34996
|
credentialInternals
|
|
33831
34997
|
)
|
|
33832
34998
|
},
|
|
33833
|
-
credentialStore
|
|
33834
|
-
|
|
33835
|
-
|
|
33836
|
-
|
|
34999
|
+
credentialStore,
|
|
35000
|
+
writeBackLogins: async () => {
|
|
35001
|
+
const custody = overrides.credentialStore ?? credentialStore;
|
|
35002
|
+
const host = readHostFileLenient(paths.hostFile).host;
|
|
35003
|
+
if (host === void 0)
|
|
35004
|
+
return owedWithNoSender(
|
|
35005
|
+
custody,
|
|
35006
|
+
"this machine has no enrollment to send it with"
|
|
35007
|
+
);
|
|
35008
|
+
return writeBackOwedLogins({
|
|
35009
|
+
store: custody,
|
|
35010
|
+
client: createControlClient({
|
|
35011
|
+
endpoints: {
|
|
35012
|
+
...host.endpoints,
|
|
35013
|
+
...workOrderEndpointsFor(host.api_url)
|
|
35014
|
+
},
|
|
35015
|
+
apiKey: host.api_key,
|
|
35016
|
+
hostEnrollmentId: host.host_enrollment_id,
|
|
35017
|
+
// Every request carries the device signature the control plane
|
|
35018
|
+
// checks (ADR-6604); the key is this agent's, beside its host.json.
|
|
35019
|
+
deviceKey: loadOrCreateDeviceKey(paths.deviceKey).key,
|
|
35020
|
+
userAgent: `oxagen/${host.wrapper_version}`
|
|
35021
|
+
}),
|
|
35022
|
+
// The command that asked prints what is left owed.
|
|
35023
|
+
log: () => {
|
|
35024
|
+
}
|
|
35025
|
+
});
|
|
35026
|
+
},
|
|
33837
35027
|
subscriptionLogin: realSubscriptionLogin(env, home),
|
|
33838
35028
|
daemonPost: async (path2, body2) => {
|
|
33839
35029
|
const host = readHostFile(paths.hostFile);
|
|
@@ -33930,7 +35120,10 @@ var init_deps = __esm({
|
|
|
33930
35120
|
init_hook_client();
|
|
33931
35121
|
init_claude_setup_token();
|
|
33932
35122
|
init_codex_app_server();
|
|
35123
|
+
init_control_client();
|
|
33933
35124
|
init_credential_store();
|
|
35125
|
+
init_device_key();
|
|
35126
|
+
init_login_write_back();
|
|
33934
35127
|
init_claude_config_lock();
|
|
33935
35128
|
init_fs();
|
|
33936
35129
|
init_harness_file();
|
|
@@ -34289,624 +35482,6 @@ var init_codex_hook_trust = __esm({
|
|
|
34289
35482
|
}
|
|
34290
35483
|
});
|
|
34291
35484
|
|
|
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
35485
|
// ../../packages/tacho/src/host/wal-index.ts
|
|
34911
35486
|
import {
|
|
34912
35487
|
appendFileSync,
|
|
@@ -39449,6 +40024,11 @@ function restartForRemaining(installed, deps) {
|
|
|
39449
40024
|
return warning;
|
|
39450
40025
|
}
|
|
39451
40026
|
}
|
|
40027
|
+
function owedWarnings(owed) {
|
|
40028
|
+
return owed.map(
|
|
40029
|
+
(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`
|
|
40030
|
+
);
|
|
40031
|
+
}
|
|
39452
40032
|
function listOf2(items) {
|
|
39453
40033
|
if (items.length <= 1) return items.join("");
|
|
39454
40034
|
return `${items.slice(0, -1).join(", ")} and ${items[items.length - 1]}`;
|
|
@@ -39477,6 +40057,14 @@ async function unenrollLocked(options, deps) {
|
|
|
39477
40057
|
return { ok: false, settingsChanged: false, revoked: false, warnings };
|
|
39478
40058
|
}
|
|
39479
40059
|
const credentials2 = await restoreCredentials(host, deps, "unenroll");
|
|
40060
|
+
if (credentials2.owed.length > 0) {
|
|
40061
|
+
warnings.push(...credentials2.warnings, ...owedWarnings(credentials2.owed));
|
|
40062
|
+
warnings.push(
|
|
40063
|
+
"Unenrollment stopped before it changed anything. Run `oxagen agent unenroll` again once this machine can reach Oxagen."
|
|
40064
|
+
);
|
|
40065
|
+
for (const warning of warnings) deps.err(`warning: ${warning}`);
|
|
40066
|
+
return { ok: false, settingsChanged: false, revoked: false, warnings };
|
|
40067
|
+
}
|
|
39480
40068
|
for (const file2 of credentials2.restored)
|
|
39481
40069
|
deps.out(` model credential given back to ${file2}`);
|
|
39482
40070
|
warnings.push(...credentials2.warnings);
|
|
@@ -39580,6 +40168,25 @@ async function unenrollLocked(options, deps) {
|
|
|
39580
40168
|
warnings
|
|
39581
40169
|
};
|
|
39582
40170
|
}
|
|
40171
|
+
const owedNow = await owedBeforeRelease(deps);
|
|
40172
|
+
const waiting2 = owedNow.filter((login) => login.retryable);
|
|
40173
|
+
if (waiting2.length > 0) {
|
|
40174
|
+
warnings.push(...owedWarnings(waiting2.map(describeOwedLogin)));
|
|
40175
|
+
warnings.push(
|
|
40176
|
+
"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."
|
|
40177
|
+
);
|
|
40178
|
+
for (const warning of warnings) deps.err(`warning: ${warning}`);
|
|
40179
|
+
return {
|
|
40180
|
+
ok: false,
|
|
40181
|
+
settingsChanged: stripped.settingsChanged,
|
|
40182
|
+
revoked: false,
|
|
40183
|
+
warnings
|
|
40184
|
+
};
|
|
40185
|
+
}
|
|
40186
|
+
for (const lost of owedNow) {
|
|
40187
|
+
const warning = lostLoginWarning(lost);
|
|
40188
|
+
if (!warnings.includes(warning)) warnings.push(warning);
|
|
40189
|
+
}
|
|
39583
40190
|
let revoked = false;
|
|
39584
40191
|
if (host === void 0) {
|
|
39585
40192
|
deps.out("[3/4] No enrollment on this machine; nothing to revoke");
|
|
@@ -39727,6 +40334,7 @@ var init_unenroll = __esm({
|
|
|
39727
40334
|
init_host_file();
|
|
39728
40335
|
init_github();
|
|
39729
40336
|
init_credential();
|
|
40337
|
+
init_login_write_back();
|
|
39730
40338
|
init_model_base_url();
|
|
39731
40339
|
init_settings_writer();
|
|
39732
40340
|
init_stella_writer();
|
|
@@ -48285,6 +48893,16 @@ async function renewStaticToken(harness, deps) {
|
|
|
48285
48893
|
return "failed";
|
|
48286
48894
|
}
|
|
48287
48895
|
}
|
|
48896
|
+
async function owedAfterWriteBack(deps) {
|
|
48897
|
+
if (deps.writeBack === void 0) return [];
|
|
48898
|
+
try {
|
|
48899
|
+
return await deps.writeBack();
|
|
48900
|
+
} catch (error2) {
|
|
48901
|
+
return [
|
|
48902
|
+
`the write-back did not run (${error2 instanceof Error ? error2.message : String(error2)})`
|
|
48903
|
+
];
|
|
48904
|
+
}
|
|
48905
|
+
}
|
|
48288
48906
|
async function giveBackChatGptLogin(deps) {
|
|
48289
48907
|
const dirs = deps.codexHome !== void 0 ? { codexHome: deps.codexHome } : {};
|
|
48290
48908
|
const taken = codexHoldsTakenChatGptLogin(deps.home, dirs);
|
|
@@ -48300,6 +48918,13 @@ async function giveBackChatGptLogin(deps) {
|
|
|
48300
48918
|
}
|
|
48301
48919
|
if (held?.kind !== "chatgpt") return "none";
|
|
48302
48920
|
if (!taken) {
|
|
48921
|
+
const owed2 = await owedAfterWriteBack(deps);
|
|
48922
|
+
if (owed2.length > 0) {
|
|
48923
|
+
deps.log(
|
|
48924
|
+
`ChatGPT login give-back: Codex holds its own login, and custody keeps its copy until Oxagen holds ${owed2.join("; ")}`
|
|
48925
|
+
);
|
|
48926
|
+
return "failed";
|
|
48927
|
+
}
|
|
48303
48928
|
try {
|
|
48304
48929
|
deps.release();
|
|
48305
48930
|
} catch (error2) {
|
|
@@ -48330,6 +48955,13 @@ async function giveBackChatGptLogin(deps) {
|
|
|
48330
48955
|
);
|
|
48331
48956
|
return "failed";
|
|
48332
48957
|
}
|
|
48958
|
+
const owed = await owedAfterWriteBack(deps);
|
|
48959
|
+
if (owed.length > 0) {
|
|
48960
|
+
deps.log(
|
|
48961
|
+
`ChatGPT login give-back: wrote auth.json, and custody keeps its copy until Oxagen holds ${owed.join("; ")}`
|
|
48962
|
+
);
|
|
48963
|
+
return "given_back";
|
|
48964
|
+
}
|
|
48333
48965
|
try {
|
|
48334
48966
|
deps.release();
|
|
48335
48967
|
} catch (error2) {
|
|
@@ -48353,6 +48985,176 @@ var init_static_token_renewal = __esm({
|
|
|
48353
48985
|
}
|
|
48354
48986
|
});
|
|
48355
48987
|
|
|
48988
|
+
// ../../packages/tacho/src/host/credential-pool.ts
|
|
48989
|
+
function chatGptTokensFromVault(saved) {
|
|
48990
|
+
let parsed2;
|
|
48991
|
+
try {
|
|
48992
|
+
parsed2 = JSON.parse(saved);
|
|
48993
|
+
} catch {
|
|
48994
|
+
return void 0;
|
|
48995
|
+
}
|
|
48996
|
+
if (parsed2 === null || typeof parsed2 !== "object") return void 0;
|
|
48997
|
+
const outer = parsed2;
|
|
48998
|
+
const inner = outer["tokens"];
|
|
48999
|
+
const tokens = inner !== null && typeof inner === "object" ? inner : outer;
|
|
49000
|
+
const text6 = (key) => {
|
|
49001
|
+
const value = tokens[key];
|
|
49002
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
49003
|
+
};
|
|
49004
|
+
const access2 = text6("access_token");
|
|
49005
|
+
if (access2 === void 0) return void 0;
|
|
49006
|
+
const idToken = text6("id_token");
|
|
49007
|
+
const accountId = text6("account_id") ?? chatGptTokenAccountOf(idToken);
|
|
49008
|
+
return JSON.stringify({
|
|
49009
|
+
access_token: access2,
|
|
49010
|
+
refresh_token: text6("refresh_token") ?? "",
|
|
49011
|
+
...idToken !== void 0 ? { id_token: idToken } : {},
|
|
49012
|
+
...accountId !== void 0 ? { account_id: accountId } : {}
|
|
49013
|
+
});
|
|
49014
|
+
}
|
|
49015
|
+
function chatGptTokenAccountOf(token) {
|
|
49016
|
+
const payload = token?.split(".")[1];
|
|
49017
|
+
if (payload === void 0 || payload.length === 0) return void 0;
|
|
49018
|
+
let claims2;
|
|
49019
|
+
try {
|
|
49020
|
+
claims2 = JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));
|
|
49021
|
+
} catch {
|
|
49022
|
+
return void 0;
|
|
49023
|
+
}
|
|
49024
|
+
if (claims2 === null || typeof claims2 !== "object") return void 0;
|
|
49025
|
+
const auth2 = claims2["https://api.openai.com/auth"];
|
|
49026
|
+
if (auth2 === null || typeof auth2 !== "object") return void 0;
|
|
49027
|
+
const account = auth2["chatgpt_account_id"];
|
|
49028
|
+
return typeof account === "string" && account.length > 0 ? account : void 0;
|
|
49029
|
+
}
|
|
49030
|
+
function poolMemberOf(credential, provider, harness) {
|
|
49031
|
+
if (credential.provider !== provider)
|
|
49032
|
+
return { skipped: `it is a ${credential.provider} credential` };
|
|
49033
|
+
if (credential.status !== "active")
|
|
49034
|
+
return { skipped: `it is ${credential.status}` };
|
|
49035
|
+
let kind;
|
|
49036
|
+
let secret = credential.secret.trim();
|
|
49037
|
+
if (credential.authType === "api_key" && credential.harness === null) {
|
|
49038
|
+
kind = provider === "anthropic" ? anthropicCredentialKind(secret, "api_key") : "bearer";
|
|
49039
|
+
} else if (credential.authType === "subscription_token" && credential.harness === harness && harness === "claude-code" && provider === "anthropic") {
|
|
49040
|
+
kind = "oauth";
|
|
49041
|
+
} else if (credential.authType === "subscription_token" && credential.harness === harness && harness === "codex" && provider === "openai") {
|
|
49042
|
+
const tokens = chatGptTokensFromVault(secret);
|
|
49043
|
+
if (tokens === void 0)
|
|
49044
|
+
return { skipped: "its ChatGPT login holds no access token" };
|
|
49045
|
+
kind = "chatgpt";
|
|
49046
|
+
secret = tokens;
|
|
49047
|
+
} else {
|
|
49048
|
+
return { skipped: `a ${credential.authType} does not serve ${harness}` };
|
|
49049
|
+
}
|
|
49050
|
+
const limitedUntil = credential.limitedUntil === null ? Number.NaN : Date.parse(credential.limitedUntil);
|
|
49051
|
+
return {
|
|
49052
|
+
credential_id: credential.id,
|
|
49053
|
+
kind,
|
|
49054
|
+
secret,
|
|
49055
|
+
hint: credential.hint,
|
|
49056
|
+
...credential.label !== null ? { label: credential.label } : {},
|
|
49057
|
+
...Number.isFinite(limitedUntil) ? { limited_until: limitedUntil } : {},
|
|
49058
|
+
changed_at: credential.rotatedAt ?? credential.createdAt
|
|
49059
|
+
};
|
|
49060
|
+
}
|
|
49061
|
+
function slotTakesPool(store, provider, harness) {
|
|
49062
|
+
const own2 = store.pool(provider, harness).find((member4) => member4.source !== VAULT_POOL_SOURCE);
|
|
49063
|
+
return own2 !== void 0 && own2.source !== "sandbox:launch";
|
|
49064
|
+
}
|
|
49065
|
+
async function syncCredentialPools(deps) {
|
|
49066
|
+
const reports = [];
|
|
49067
|
+
const harnesses = [...new Set(deps.harnesses)].filter(isBrokerableHarness);
|
|
49068
|
+
for (const harness of harnesses) {
|
|
49069
|
+
const provider = BROKERABLE_HARNESS_PROVIDER[harness];
|
|
49070
|
+
let takes;
|
|
49071
|
+
try {
|
|
49072
|
+
takes = slotTakesPool(deps.store, provider, harness);
|
|
49073
|
+
} catch (error2) {
|
|
49074
|
+
const detail = error2 instanceof Error ? error2.message : String(error2);
|
|
49075
|
+
deps.log(
|
|
49076
|
+
`credential pool sync: custody for ${harness} is unreadable, so it was not synced: ${detail}`
|
|
49077
|
+
);
|
|
49078
|
+
reports.push({ harness, synced: false, reason: "fetch_failed", detail });
|
|
49079
|
+
continue;
|
|
49080
|
+
}
|
|
49081
|
+
if (!takes) {
|
|
49082
|
+
reports.push({ harness, synced: false, reason: "not_brokered" });
|
|
49083
|
+
continue;
|
|
49084
|
+
}
|
|
49085
|
+
let credentials2;
|
|
49086
|
+
try {
|
|
49087
|
+
credentials2 = (await deps.client.modelCredentials(harness)).credentials;
|
|
49088
|
+
} catch (error2) {
|
|
49089
|
+
const detail = error2 instanceof ControlError ? controlErrorMessage(error2) : error2 instanceof Error ? error2.message : String(error2);
|
|
49090
|
+
deps.log(
|
|
49091
|
+
`credential pool sync: could not read the credentials saved for ${harness}, so custody keeps what it holds: ${detail}`
|
|
49092
|
+
);
|
|
49093
|
+
reports.push({ harness, synced: false, reason: "fetch_failed", detail });
|
|
49094
|
+
continue;
|
|
49095
|
+
}
|
|
49096
|
+
const members3 = [];
|
|
49097
|
+
for (const credential of credentials2) {
|
|
49098
|
+
const member4 = poolMemberOf(credential, provider, harness);
|
|
49099
|
+
if ("skipped" in member4) {
|
|
49100
|
+
deps.log(
|
|
49101
|
+
`credential pool sync: ${credential.id} does not join ${harness}'s pool: ${member4.skipped}`
|
|
49102
|
+
);
|
|
49103
|
+
continue;
|
|
49104
|
+
}
|
|
49105
|
+
members3.push(member4);
|
|
49106
|
+
}
|
|
49107
|
+
try {
|
|
49108
|
+
const outcome = deps.store.syncPool(
|
|
49109
|
+
provider,
|
|
49110
|
+
harness,
|
|
49111
|
+
members3,
|
|
49112
|
+
deps.now()
|
|
49113
|
+
);
|
|
49114
|
+
if (outcome.synced)
|
|
49115
|
+
deps.log(
|
|
49116
|
+
`credential pool sync: ${harness} holds ${outcome.added + outcome.kept} saved credentials after its own (${outcome.added} added, ${outcome.removed} removed)`
|
|
49117
|
+
);
|
|
49118
|
+
reports.push({ harness, ...outcome });
|
|
49119
|
+
} catch (error2) {
|
|
49120
|
+
const detail = error2 instanceof Error ? error2.message : String(error2);
|
|
49121
|
+
deps.log(
|
|
49122
|
+
`credential pool sync: custody for ${harness} could not be written, so it keeps what it held: ${detail}`
|
|
49123
|
+
);
|
|
49124
|
+
reports.push({ harness, synced: false, reason: "fetch_failed", detail });
|
|
49125
|
+
}
|
|
49126
|
+
}
|
|
49127
|
+
return reports;
|
|
49128
|
+
}
|
|
49129
|
+
function createCredentialStateReporter(deps) {
|
|
49130
|
+
const sent = /* @__PURE__ */ new Map();
|
|
49131
|
+
return (credentialId, report) => {
|
|
49132
|
+
const key = report.state === "invalid" ? `invalid:${report.reason}` : report.state === "limited" ? `limited:${report.scope ?? ""}` : report.state;
|
|
49133
|
+
const at2 = deps.now();
|
|
49134
|
+
const last = sent.get(credentialId);
|
|
49135
|
+
if (last !== void 0 && last.key === key && at2 - last.at < CREDENTIAL_REPORT_REPEAT_MS)
|
|
49136
|
+
return;
|
|
49137
|
+
sent.set(credentialId, { key, at: at2 });
|
|
49138
|
+
void deps.client.reportModelCredential(credentialId, report).catch((error2) => {
|
|
49139
|
+
sent.delete(credentialId);
|
|
49140
|
+
deps.log(
|
|
49141
|
+
`credential pool: could not tell Oxagen that ${credentialId} is ${report.state}: ${error2 instanceof ControlError ? controlErrorMessage(error2) : error2 instanceof Error ? error2.message : String(error2)}`
|
|
49142
|
+
);
|
|
49143
|
+
});
|
|
49144
|
+
};
|
|
49145
|
+
}
|
|
49146
|
+
var CREDENTIAL_POOL_SYNC_MS, CREDENTIAL_REPORT_REPEAT_MS;
|
|
49147
|
+
var init_credential_pool = __esm({
|
|
49148
|
+
"../../packages/tacho/src/host/credential-pool.ts"() {
|
|
49149
|
+
"use strict";
|
|
49150
|
+
init_credential_store();
|
|
49151
|
+
init_control_client();
|
|
49152
|
+
init_wire();
|
|
49153
|
+
CREDENTIAL_POOL_SYNC_MS = 15 * 6e4;
|
|
49154
|
+
CREDENTIAL_REPORT_REPEAT_MS = 6e4;
|
|
49155
|
+
}
|
|
49156
|
+
});
|
|
49157
|
+
|
|
48356
49158
|
// ../../packages/tacho/src/host/chatgpt-refresh.ts
|
|
48357
49159
|
function jwtExpiryMs(token) {
|
|
48358
49160
|
const payload = token.split(".")[1];
|
|
@@ -48366,6 +49168,12 @@ function jwtExpiryMs(token) {
|
|
|
48366
49168
|
return void 0;
|
|
48367
49169
|
}
|
|
48368
49170
|
}
|
|
49171
|
+
function accountOfLogin(login) {
|
|
49172
|
+
return login.account_id ?? chatGptTokenAccountOf(login.access_token);
|
|
49173
|
+
}
|
|
49174
|
+
function accountOfTokens(login) {
|
|
49175
|
+
return chatGptTokenAccountOf(login.access_token) ?? chatGptTokenAccountOf(login.id_token);
|
|
49176
|
+
}
|
|
48369
49177
|
function chatGptLoginDue(login, takenAt, now) {
|
|
48370
49178
|
const exp = jwtExpiryMs(login.access_token);
|
|
48371
49179
|
if (exp !== void 0) return exp - now < CHATGPT_REFRESH_MARGIN_MS;
|
|
@@ -48459,6 +49267,24 @@ function createChatGptRefresher(deps) {
|
|
|
48459
49267
|
const timeoutMs = deps.timeoutMs ?? CHATGPT_REFRESH_TIMEOUT_MS;
|
|
48460
49268
|
const running = /* @__PURE__ */ new Map();
|
|
48461
49269
|
const memberOf2 = (id2) => store.pool(...SLOT).find((member4) => member4.id === id2);
|
|
49270
|
+
const owes = (id2) => store.owedLogins().some(
|
|
49271
|
+
(owed) => owed.provider === SLOT[0] && owed.harness === SLOT[1] && owed.id === id2
|
|
49272
|
+
);
|
|
49273
|
+
async function stillOwed(credentialId) {
|
|
49274
|
+
if (deps.sendOwedFirst === void 0) return void 0;
|
|
49275
|
+
let report;
|
|
49276
|
+
try {
|
|
49277
|
+
report = await deps.sendOwedFirst();
|
|
49278
|
+
} catch (error2) {
|
|
49279
|
+
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`;
|
|
49280
|
+
}
|
|
49281
|
+
if (report.superseded.some((s2) => s2.credential_id === credentialId))
|
|
49282
|
+
return SUPERSEDED;
|
|
49283
|
+
const left = report.owed.find(
|
|
49284
|
+
(owed) => owed.credential_id === credentialId && owed.retryable
|
|
49285
|
+
);
|
|
49286
|
+
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`;
|
|
49287
|
+
}
|
|
48462
49288
|
async function refreshOnce(id2) {
|
|
48463
49289
|
const member4 = memberOf2(id2);
|
|
48464
49290
|
if (member4 === void 0 || member4.kind !== "chatgpt")
|
|
@@ -48471,11 +49297,26 @@ function createChatGptRefresher(deps) {
|
|
|
48471
49297
|
outcome: member4.refresh_refused,
|
|
48472
49298
|
detail: `auth.openai.com already refused to refresh these tokens; ${RELOGIN}`
|
|
48473
49299
|
};
|
|
49300
|
+
if (member4.write_back_refused === true)
|
|
49301
|
+
return { outcome: "failed", detail: SUPERSEDED };
|
|
49302
|
+
if (member4.credential_id !== void 0 && owes(id2)) {
|
|
49303
|
+
const waiting2 = await stillOwed(member4.credential_id);
|
|
49304
|
+
if (waiting2 !== void 0) return { outcome: "failed", detail: waiting2 };
|
|
49305
|
+
}
|
|
48474
49306
|
const held = store.open(...SLOT, id2);
|
|
48475
49307
|
const login = held?.kind === "chatgpt" ? decodeChatGptLogin(held.secret) : void 0;
|
|
48476
49308
|
if (login === void 0)
|
|
48477
49309
|
return { outcome: "failed", detail: "custody holds no ChatGPT login" };
|
|
48478
|
-
|
|
49310
|
+
let answer = await exchange(login, deps.fetch, timeoutMs);
|
|
49311
|
+
if ("login" in answer && member4.credential_id !== void 0) {
|
|
49312
|
+
const named2 = accountOfLogin(login);
|
|
49313
|
+
const issued = accountOfTokens(answer.login);
|
|
49314
|
+
if (named2 !== void 0 && issued !== void 0 && named2 !== issued)
|
|
49315
|
+
answer = {
|
|
49316
|
+
outcome: "refused",
|
|
49317
|
+
detail: `auth.openai.com answered the refresh with tokens for another ChatGPT account, so none were kept; ${RELOGIN}`
|
|
49318
|
+
};
|
|
49319
|
+
}
|
|
48479
49320
|
if (!("login" in answer)) {
|
|
48480
49321
|
if (answer.outcome !== "failed")
|
|
48481
49322
|
store.markFailed(
|
|
@@ -48512,22 +49353,38 @@ function createChatGptRefresher(deps) {
|
|
|
48512
49353
|
running.set(id2, started);
|
|
48513
49354
|
return started;
|
|
48514
49355
|
}
|
|
49356
|
+
const chatGptLogins = () => store.pool(...SLOT).filter((member4) => member4.kind === "chatgpt");
|
|
49357
|
+
function due(member4) {
|
|
49358
|
+
if (member4.refresh_refused !== void 0) return false;
|
|
49359
|
+
const held = store.open(...SLOT, member4.id);
|
|
49360
|
+
const login = held?.kind === "chatgpt" ? decodeChatGptLogin(held.secret) : void 0;
|
|
49361
|
+
if (login === void 0) return void 0;
|
|
49362
|
+
return member4.failure !== void 0 && isTokenRefused(member4.failure.kind) || chatGptLoginDue(login, Date.parse(member4.taken_at), deps.now());
|
|
49363
|
+
}
|
|
48515
49364
|
async function refreshDue() {
|
|
48516
|
-
|
|
49365
|
+
let logins = chatGptLogins();
|
|
48517
49366
|
if (logins.length === 0) return "none";
|
|
49367
|
+
if (deps.syncFirst !== void 0 && logins.some(
|
|
49368
|
+
(member4) => member4.credential_id !== void 0 && due(member4) === true
|
|
49369
|
+
)) {
|
|
49370
|
+
try {
|
|
49371
|
+
await deps.syncFirst();
|
|
49372
|
+
} catch {
|
|
49373
|
+
}
|
|
49374
|
+
logins = chatGptLogins();
|
|
49375
|
+
if (logins.length === 0) return "none";
|
|
49376
|
+
}
|
|
48518
49377
|
let refreshed = 0;
|
|
48519
49378
|
const failed5 = [];
|
|
48520
49379
|
for (const member4 of logins) {
|
|
48521
49380
|
const name2 = logins.length === 1 ? "" : `${member4.hint !== void 0 ? `\u2026${member4.hint}` : member4.id}: `;
|
|
48522
49381
|
if (member4.refresh_refused !== void 0) continue;
|
|
48523
|
-
const
|
|
48524
|
-
|
|
48525
|
-
if (login === void 0) {
|
|
49382
|
+
const isDue = due(member4);
|
|
49383
|
+
if (isDue === void 0) {
|
|
48526
49384
|
failed5.push(`${name2}custody holds no ChatGPT login`);
|
|
48527
49385
|
continue;
|
|
48528
49386
|
}
|
|
48529
|
-
|
|
48530
|
-
if (!due) continue;
|
|
49387
|
+
if (!isDue) continue;
|
|
48531
49388
|
const result2 = await refresh(member4.id);
|
|
48532
49389
|
if (result2.outcome === "refreshed") refreshed += 1;
|
|
48533
49390
|
else failed5.push(`${name2}${result2.detail}`);
|
|
@@ -48537,11 +49394,12 @@ function createChatGptRefresher(deps) {
|
|
|
48537
49394
|
}
|
|
48538
49395
|
return { refresh, refreshDue };
|
|
48539
49396
|
}
|
|
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;
|
|
49397
|
+
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
49398
|
var init_chatgpt_refresh = __esm({
|
|
48542
49399
|
"../../packages/tacho/src/host/chatgpt-refresh.ts"() {
|
|
48543
49400
|
"use strict";
|
|
48544
49401
|
init_model_failure();
|
|
49402
|
+
init_credential_pool();
|
|
48545
49403
|
init_model_credential();
|
|
48546
49404
|
CODEX_OAUTH_CLIENT_ID = "app_EMoamEEZ73f0CkXaXp7hrann";
|
|
48547
49405
|
CHATGPT_TOKEN_URL = "https://auth.openai.com/oauth/token";
|
|
@@ -48554,176 +49412,7 @@ var init_chatgpt_refresh = __esm({
|
|
|
48554
49412
|
]);
|
|
48555
49413
|
RELOGIN = "run `codex login`, then `oxagen agent enroll`";
|
|
48556
49414
|
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;
|
|
49415
|
+
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
49416
|
}
|
|
48728
49417
|
});
|
|
48729
49418
|
|
|
@@ -49761,7 +50450,7 @@ function staffingArgs(harness, staffing) {
|
|
|
49761
50450
|
function isFinalRefusal(error2) {
|
|
49762
50451
|
return error2.status >= 400 && error2.status < 500 && error2.status !== 408 && error2.status !== 429;
|
|
49763
50452
|
}
|
|
49764
|
-
function
|
|
50453
|
+
function messageOf3(error2) {
|
|
49765
50454
|
if (error2 instanceof ControlError) return controlErrorMessage(error2);
|
|
49766
50455
|
return error2 instanceof Error ? error2.message : String(error2);
|
|
49767
50456
|
}
|
|
@@ -49779,7 +50468,7 @@ async function claimForStart(client, host, id2) {
|
|
|
49779
50468
|
};
|
|
49780
50469
|
if (error2 instanceof ControlUnreachable)
|
|
49781
50470
|
return { kind: "unreachable", message: error2.message };
|
|
49782
|
-
return { kind: "unreadable", message:
|
|
50471
|
+
return { kind: "unreadable", message: messageOf3(error2) };
|
|
49783
50472
|
}
|
|
49784
50473
|
const harness = claim2.work_order.harness;
|
|
49785
50474
|
if (!isWrappedHarness(harness) || !host.harnesses.includes(harness)) {
|
|
@@ -49809,7 +50498,7 @@ async function refuseWorkOrder(client, id2, reason4) {
|
|
|
49809
50498
|
await client.rejectWorkOrder(id2, reason4);
|
|
49810
50499
|
return void 0;
|
|
49811
50500
|
} catch (error2) {
|
|
49812
|
-
return
|
|
50501
|
+
return messageOf3(error2);
|
|
49813
50502
|
}
|
|
49814
50503
|
}
|
|
49815
50504
|
function spawnRefusalReason(binary, error2) {
|
|
@@ -60775,7 +61464,7 @@ import { isAbsolute as isAbsolute14 } from "node:path";
|
|
|
60775
61464
|
function isCodeGraphRoute(value) {
|
|
60776
61465
|
return CODE_GRAPH_ROUTES.includes(value);
|
|
60777
61466
|
}
|
|
60778
|
-
function
|
|
61467
|
+
function messageOf4(error2) {
|
|
60779
61468
|
return error2 instanceof Error ? error2.message : String(error2);
|
|
60780
61469
|
}
|
|
60781
61470
|
async function answerCodeGraphRoute(codegraph, route, body2) {
|
|
@@ -60793,7 +61482,7 @@ async function answerCodeGraphRoute(codegraph, route, body2) {
|
|
|
60793
61482
|
} catch (error2) {
|
|
60794
61483
|
return {
|
|
60795
61484
|
status: 503,
|
|
60796
|
-
body: { error:
|
|
61485
|
+
body: { error: messageOf4(error2), supervisor: codegraph.describe() }
|
|
60797
61486
|
};
|
|
60798
61487
|
}
|
|
60799
61488
|
}
|
|
@@ -60814,7 +61503,7 @@ async function answerCodeGraphRoute(codegraph, route, body2) {
|
|
|
60814
61503
|
} catch (error2) {
|
|
60815
61504
|
return {
|
|
60816
61505
|
status: 503,
|
|
60817
|
-
body: { error:
|
|
61506
|
+
body: { error: messageOf4(error2), supervisor: codegraph.describe() }
|
|
60818
61507
|
};
|
|
60819
61508
|
}
|
|
60820
61509
|
}
|
|
@@ -69426,7 +70115,10 @@ function cloudGatewayCredentialStore(disk, runToken) {
|
|
|
69426
70115
|
markFailed: () => false,
|
|
69427
70116
|
clearFailure: () => false,
|
|
69428
70117
|
replaceSecret: () => false,
|
|
69429
|
-
syncPool: () => ({ synced: false, reason: "sandbox" })
|
|
70118
|
+
syncPool: () => ({ synced: false, reason: "sandbox" }),
|
|
70119
|
+
// No pool, so no saved login is ever refreshed here.
|
|
70120
|
+
owedLogins: () => [],
|
|
70121
|
+
settleWriteBack: () => false
|
|
69430
70122
|
};
|
|
69431
70123
|
}
|
|
69432
70124
|
function readTextOrUndefined(path2) {
|
|
@@ -72196,12 +72888,26 @@ async function initializeDaemon(options, server, port, ready, clock2) {
|
|
|
72196
72888
|
now,
|
|
72197
72889
|
log
|
|
72198
72890
|
});
|
|
72891
|
+
const loginWriteBack = createLoginWriteBack({
|
|
72892
|
+
store: credentialStore,
|
|
72893
|
+
client,
|
|
72894
|
+
now,
|
|
72895
|
+
log
|
|
72896
|
+
});
|
|
72199
72897
|
const chatGptRefresher = createChatGptRefresher({
|
|
72200
72898
|
store: credentialStore,
|
|
72201
72899
|
fetch: options.fetch ?? fetch,
|
|
72202
72900
|
now,
|
|
72901
|
+
// Another machine may have refreshed a saved login since the last sync.
|
|
72902
|
+
// Its tokens are taken from the vault before this one spends a refresh
|
|
72903
|
+
// token that machine already used.
|
|
72904
|
+
syncFirst: () => syncPools(),
|
|
72905
|
+
// Tokens refreshed last go to Oxagen before the login is refreshed
|
|
72906
|
+
// again, so a lost answer never leaves newer tokens on an old base.
|
|
72907
|
+
sendOwedFirst: () => loginWriteBack.drain(),
|
|
72203
72908
|
refreshed: (member4) => {
|
|
72204
72909
|
if (member4.credential_id === void 0) return;
|
|
72910
|
+
void loginWriteBack.drain();
|
|
72205
72911
|
if (member4.failure !== void 0 && Date.parse(member4.failure.until) > now())
|
|
72206
72912
|
return;
|
|
72207
72913
|
reportCredentialState(member4.credential_id, { state: "recovered" });
|
|
@@ -73313,6 +74019,7 @@ async function initializeDaemon(options, server, port, ready, clock2) {
|
|
|
73313
74019
|
}
|
|
73314
74020
|
let lastStaticRenewalAt = 0;
|
|
73315
74021
|
let lastLoginRefreshAt = 0;
|
|
74022
|
+
let lastGiveBackLine;
|
|
73316
74023
|
async function renewStaticTokens() {
|
|
73317
74024
|
const harnesses = STATIC_TOKEN_HARNESSES.filter(
|
|
73318
74025
|
(h) => host.harnesses.includes(h)
|
|
@@ -73324,12 +74031,23 @@ async function initializeDaemon(options, server, port, ready, clock2) {
|
|
|
73324
74031
|
home: options.home ?? homedir9(),
|
|
73325
74032
|
...codexDirs,
|
|
73326
74033
|
read: () => credentialStore.read("openai", "codex"),
|
|
74034
|
+
// A release drops the saved logins in Codex's slot too, so each one
|
|
74035
|
+
// this machine refreshed goes to Oxagen first (#8795).
|
|
74036
|
+
writeBack: async () => owedIn(await loginWriteBack.drain(), {
|
|
74037
|
+
provider: "openai",
|
|
74038
|
+
harness: "codex"
|
|
74039
|
+
}).map(describeOwedLogin),
|
|
73327
74040
|
release: () => {
|
|
73328
74041
|
credentialStore.release("openai", "codex");
|
|
73329
74042
|
},
|
|
73330
|
-
|
|
74043
|
+
// The pass runs on every tick, so a line it repeats is logged once.
|
|
74044
|
+
log: (line) => {
|
|
74045
|
+
if (line === lastGiveBackLine) return;
|
|
74046
|
+
lastGiveBackLine = line;
|
|
74047
|
+
log(line);
|
|
74048
|
+
}
|
|
73331
74049
|
});
|
|
73332
|
-
if (harnesses.includes("codex") && now() - lastLoginRefreshAt >= CHATGPT_LOGIN_CHECK_MS && mayRefreshChatGptCustody(options.home ?? homedir9(), codexDirs)) {
|
|
74050
|
+
if (harnesses.includes("codex") && now() - lastLoginRefreshAt >= CHATGPT_LOGIN_CHECK_MS && host.host_status !== "revoked" && host.host_status !== "suspended" && mayRefreshChatGptCustody(options.home ?? homedir9(), codexDirs)) {
|
|
73333
74051
|
lastLoginRefreshAt = now();
|
|
73334
74052
|
try {
|
|
73335
74053
|
const refreshed = await chatGptRefresher.refreshDue();
|
|
@@ -73361,6 +74079,7 @@ async function initializeDaemon(options, server, port, ready, clock2) {
|
|
|
73361
74079
|
async function syncPools() {
|
|
73362
74080
|
if (options.cloudGateway !== void 0) return [];
|
|
73363
74081
|
lastPoolSyncAt = now();
|
|
74082
|
+
await loginWriteBack.drain();
|
|
73364
74083
|
const served2 = [];
|
|
73365
74084
|
for (const harness of host.harnesses) {
|
|
73366
74085
|
const route = POOL_ROUTES[harness];
|
|
@@ -73385,10 +74104,15 @@ async function initializeDaemon(options, server, port, ready, clock2) {
|
|
|
73385
74104
|
if (now() - lastPoolSyncAt < CREDENTIAL_POOL_SYNC_MS) return;
|
|
73386
74105
|
await syncPools();
|
|
73387
74106
|
}
|
|
74107
|
+
async function writeBackLogins() {
|
|
74108
|
+
if (options.cloudGateway !== void 0) return;
|
|
74109
|
+
await loginWriteBack.drain();
|
|
74110
|
+
}
|
|
73388
74111
|
async function tick() {
|
|
73389
74112
|
await controlTick();
|
|
73390
74113
|
await renewCertificate();
|
|
73391
74114
|
await renewStaticTokens();
|
|
74115
|
+
await writeBackLogins();
|
|
73392
74116
|
await syncPoolsWhenDue();
|
|
73393
74117
|
await gitLane;
|
|
73394
74118
|
}
|
|
@@ -73400,7 +74124,7 @@ async function initializeDaemon(options, server, port, ready, clock2) {
|
|
|
73400
74124
|
if (pendingSessionEnds.size > 0) void startGitReads();
|
|
73401
74125
|
if (ticking) return;
|
|
73402
74126
|
ticking = true;
|
|
73403
|
-
controlTick().then(() => renewCertificate()).then(() => renewStaticTokens()).then(() => syncPoolsWhenDue()).catch((error2) => {
|
|
74127
|
+
controlTick().then(() => renewCertificate()).then(() => renewStaticTokens()).then(() => writeBackLogins()).then(() => syncPoolsWhenDue()).catch((error2) => {
|
|
73404
74128
|
const code = error2 instanceof Error && "code" in error2 ? ` [${String(error2.code)}]` : "";
|
|
73405
74129
|
const site = error2 instanceof Error && typeof error2.stack === "string" ? error2.stack.split("\n")[1]?.trim() ?? "" : "";
|
|
73406
74130
|
log(
|
|
@@ -73696,6 +74420,7 @@ var init_daemon = __esm({
|
|
|
73696
74420
|
init_static_token_renewal();
|
|
73697
74421
|
init_chatgpt_refresh();
|
|
73698
74422
|
init_credential_pool();
|
|
74423
|
+
init_login_write_back();
|
|
73699
74424
|
init_run_token();
|
|
73700
74425
|
init_process_scan();
|
|
73701
74426
|
init_retention();
|
|
@@ -74331,7 +75056,7 @@ function workOrderTokenFrom(deps, command2) {
|
|
|
74331
75056
|
);
|
|
74332
75057
|
return token;
|
|
74333
75058
|
}
|
|
74334
|
-
function
|
|
75059
|
+
function messageOf5(error2) {
|
|
74335
75060
|
if (error2 instanceof ControlError) return controlErrorMessage(error2);
|
|
74336
75061
|
return error2 instanceof Error ? error2.message : String(error2);
|
|
74337
75062
|
}
|
|
@@ -74525,7 +75250,7 @@ function runProofCommand(command2, cwd, timeoutMs = PROOF_COMMAND_TIMEOUT_MS) {
|
|
|
74525
75250
|
windowsHide: true
|
|
74526
75251
|
});
|
|
74527
75252
|
} catch (error2) {
|
|
74528
|
-
resolve29({ exitCode: -1, durationMs: 0, output:
|
|
75253
|
+
resolve29({ exitCode: -1, durationMs: 0, output: messageOf5(error2) });
|
|
74529
75254
|
return;
|
|
74530
75255
|
}
|
|
74531
75256
|
let timedOut = false;
|
|
@@ -74553,7 +75278,7 @@ function runProofCommand(command2, cwd, timeoutMs = PROOF_COMMAND_TIMEOUT_MS) {
|
|
|
74553
75278
|
resolve29({ exitCode, durationMs: Date.now() - started, output: output2 });
|
|
74554
75279
|
};
|
|
74555
75280
|
child.on("error", (error2) => {
|
|
74556
|
-
hold(Buffer.from(
|
|
75281
|
+
hold(Buffer.from(messageOf5(error2)));
|
|
74557
75282
|
settle5(-1);
|
|
74558
75283
|
});
|
|
74559
75284
|
child.on("close", (code) => {
|
|
@@ -74775,7 +75500,7 @@ ${last}`}`
|
|
|
74775
75500
|
);
|
|
74776
75501
|
else
|
|
74777
75502
|
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. (${
|
|
75503
|
+
`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
75504
|
);
|
|
74780
75505
|
return 1;
|
|
74781
75506
|
}
|
|
@@ -74833,7 +75558,7 @@ async function workChecklist(options, deps) {
|
|
|
74833
75558
|
answer = await client.readWorkOrderChecklist(run3.workOrderId, token);
|
|
74834
75559
|
} catch (error2) {
|
|
74835
75560
|
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}. ${
|
|
75561
|
+
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
75562
|
);
|
|
74838
75563
|
return 1;
|
|
74839
75564
|
}
|
|
@@ -74946,7 +75671,7 @@ async function workProgress(options, deps) {
|
|
|
74946
75671
|
);
|
|
74947
75672
|
else
|
|
74948
75673
|
deps.err(
|
|
74949
|
-
`Could not read Oxagen's answer to the progress update. Wait a minute, then run this command again. (${
|
|
75674
|
+
`Could not read Oxagen's answer to the progress update. Wait a minute, then run this command again. (${messageOf5(error2)})`
|
|
74950
75675
|
);
|
|
74951
75676
|
return 1;
|
|
74952
75677
|
}
|
|
@@ -75040,7 +75765,7 @@ function planWorkspaceSwitch(home, target, isAlive = processIsAlive) {
|
|
|
75040
75765
|
running
|
|
75041
75766
|
};
|
|
75042
75767
|
}
|
|
75043
|
-
function
|
|
75768
|
+
function messageOf6(error2) {
|
|
75044
75769
|
if (error2 instanceof ControlError) return controlErrorMessage(error2);
|
|
75045
75770
|
return error2 instanceof Error ? error2.message : String(error2);
|
|
75046
75771
|
}
|
|
@@ -75124,7 +75849,7 @@ async function switchLocked(home, target, options) {
|
|
|
75124
75849
|
outcomes.push({
|
|
75125
75850
|
...described(agent.host),
|
|
75126
75851
|
state: "failed",
|
|
75127
|
-
message:
|
|
75852
|
+
message: messageOf6(error2)
|
|
75128
75853
|
});
|
|
75129
75854
|
}
|
|
75130
75855
|
}
|
|
@@ -75141,7 +75866,7 @@ async function switchLocked(home, target, options) {
|
|
|
75141
75866
|
endedSends: answer.ended_sends
|
|
75142
75867
|
});
|
|
75143
75868
|
} catch (error2) {
|
|
75144
|
-
const message2 =
|
|
75869
|
+
const message2 = messageOf6(error2);
|
|
75145
75870
|
refused3.push(`${agent.host.agent_key}: ${message2}`);
|
|
75146
75871
|
outcomes.push({ ...described(agent.host), state: "failed", message: message2 });
|
|
75147
75872
|
}
|
|
@@ -75244,7 +75969,7 @@ async function standByOutsideConnection(home, options = {}) {
|
|
|
75244
75969
|
failed5.push({
|
|
75245
75970
|
...described(agent.host),
|
|
75246
75971
|
state: "failed",
|
|
75247
|
-
message:
|
|
75972
|
+
message: messageOf6(error2)
|
|
75248
75973
|
});
|
|
75249
75974
|
}
|
|
75250
75975
|
}
|
|
@@ -75799,8 +76524,10 @@ __export(cli_exports, {
|
|
|
75799
76524
|
heldBodiesOf: () => heldBodiesOf,
|
|
75800
76525
|
isNativeBuild: () => isNativeBuild,
|
|
75801
76526
|
launchSandboxFromEnv: () => launchSandboxFromEnv,
|
|
76527
|
+
lostLoginWarning: () => lostLoginWarning,
|
|
75802
76528
|
needsClaudeCodeMcp: () => needsClaudeCodeMcp,
|
|
75803
76529
|
observedTiers: () => observedTiers,
|
|
76530
|
+
owedBeforeRelease: () => owedBeforeRelease,
|
|
75804
76531
|
oxagenRuntimeCommands: () => oxagenRuntimeCommands,
|
|
75805
76532
|
parseCredentialMode: () => parseCredentialMode,
|
|
75806
76533
|
parseHarnesses: () => parseHarnesses,
|
|
@@ -81403,7 +82130,7 @@ var init_package = __esm({
|
|
|
81403
82130
|
"package.json"() {
|
|
81404
82131
|
package_default = {
|
|
81405
82132
|
name: "@oxagen/cli",
|
|
81406
|
-
version: "5.5.1-
|
|
82133
|
+
version: "5.5.1-274",
|
|
81407
82134
|
description: "Oxagen governance CLI: spend, source tracking, grounding, credentials, and audit (agentic coding lives in the stella CLI)",
|
|
81408
82135
|
type: "module",
|
|
81409
82136
|
main: "./dist/index.js",
|
|
@@ -102854,6 +103581,7 @@ __export(host_exports, {
|
|
|
102854
103581
|
HTTP_HOOK_EVENTS: () => HTTP_HOOK_EVENTS,
|
|
102855
103582
|
LEGACY_CREATED_WANTS_MARK: () => LEGACY_CREATED_WANTS_MARK,
|
|
102856
103583
|
LOGIN_REFRESH_REFUSALS: () => LOGIN_REFRESH_REFUSALS,
|
|
103584
|
+
LOGIN_WRITE_BACK_STATES: () => LOGIN_WRITE_BACK_STATES,
|
|
102857
103585
|
REQUEST_SIGNATURE_DOMAIN: () => REQUEST_SIGNATURE_DOMAIN,
|
|
102858
103586
|
REQUEST_SIGNATURE_HEADER: () => REQUEST_SIGNATURE_HEADER,
|
|
102859
103587
|
REQUEST_SIGNATURE_MAX_SKEW_S: () => REQUEST_SIGNATURE_MAX_SKEW_S,
|
|
@@ -108332,14 +109060,14 @@ function formatDollars(micros2) {
|
|
|
108332
109060
|
function formatCount(count15) {
|
|
108333
109061
|
return Number.isInteger(count15) ? String(count15) : count15.toFixed(1);
|
|
108334
109062
|
}
|
|
108335
|
-
function
|
|
109063
|
+
function nameOf2(group) {
|
|
108336
109064
|
const { name: name2, number: itemNumber } = group.display;
|
|
108337
109065
|
if (name2 === null) return SPECIAL_NAMES[group.key] ?? group.key;
|
|
108338
109066
|
return itemNumber ? `${itemNumber} ${name2}` : name2;
|
|
108339
109067
|
}
|
|
108340
109068
|
function namesByKey(groups) {
|
|
108341
109069
|
const names2 = /* @__PURE__ */ new Map();
|
|
108342
|
-
for (const group of groups) names2.set(group.key,
|
|
109070
|
+
for (const group of groups) names2.set(group.key, nameOf2(group));
|
|
108343
109071
|
return names2;
|
|
108344
109072
|
}
|
|
108345
109073
|
function wordOf(dimension) {
|
|
@@ -108376,7 +109104,7 @@ function render(result2, writer) {
|
|
|
108376
109104
|
"MERGED"
|
|
108377
109105
|
],
|
|
108378
109106
|
result2.groups.map((group) => [
|
|
108379
|
-
|
|
109107
|
+
nameOf2(group),
|
|
108380
109108
|
formatDollars(group.spend),
|
|
108381
109109
|
...withCompared ? [group.compared === null ? "-" : formatDollars(group.compared.spend)] : [],
|
|
108382
109110
|
formatDollars(group.wasted),
|
|
@@ -112246,7 +112974,7 @@ var init_paths2 = __esm({
|
|
|
112246
112974
|
});
|
|
112247
112975
|
|
|
112248
112976
|
// ../../packages/oxagen/src/steering-repo/harness-files.ts
|
|
112249
|
-
function
|
|
112977
|
+
function nameOf3(path2) {
|
|
112250
112978
|
const cut = path2.lastIndexOf("/");
|
|
112251
112979
|
return cut < 0 ? path2 : path2.slice(cut + 1);
|
|
112252
112980
|
}
|
|
@@ -112254,7 +112982,7 @@ function isMarkdown(name2) {
|
|
|
112254
112982
|
return name2.endsWith(".md") || name2.endsWith(".mdc");
|
|
112255
112983
|
}
|
|
112256
112984
|
function instructionEntryOf(path2) {
|
|
112257
|
-
const name2 =
|
|
112985
|
+
const name2 = nameOf3(path2);
|
|
112258
112986
|
const nested2 = NESTED.get(name2) ?? SINGLE2.get(name2);
|
|
112259
112987
|
if (nested2) return nested2;
|
|
112260
112988
|
if (path2 === ".github/copilot-instructions.md")
|
|
@@ -112278,7 +113006,7 @@ function classifyHarnessFile(path2) {
|
|
|
112278
113006
|
const root = ROOT_FILES2.get(path2);
|
|
112279
113007
|
if (root) return { ...root, path: path2, skillFolder: null };
|
|
112280
113008
|
for (const { folder, entry: entry2 } of MARKDOWN_FOLDERS) {
|
|
112281
|
-
if (path2.startsWith(folder) &&
|
|
113009
|
+
if (path2.startsWith(folder) && nameOf3(path2).endsWith(".md"))
|
|
112282
113010
|
return { ...entry2, path: path2, skillFolder: null };
|
|
112283
113011
|
}
|
|
112284
113012
|
return null;
|
|
@@ -156588,7 +157316,7 @@ var init_local_discovery_envelope = __esm({
|
|
|
156588
157316
|
});
|
|
156589
157317
|
|
|
156590
157318
|
// ../../packages/mcp-studio/src/execute/util.ts
|
|
156591
|
-
function
|
|
157319
|
+
function messageOf7(error2) {
|
|
156592
157320
|
return error2 instanceof Error ? error2.message : String(error2);
|
|
156593
157321
|
}
|
|
156594
157322
|
function isRecord11(value) {
|
|
@@ -169719,7 +170447,7 @@ function buildFile(parsed2, notes) {
|
|
|
169719
170447
|
if (parsed2.header.syntax === "proto3") proto.syntax = "proto3";
|
|
169720
170448
|
for (const child of holder.nestedArray) {
|
|
169721
170449
|
if (isType(child)) {
|
|
169722
|
-
proto.messageType.push(
|
|
170450
|
+
proto.messageType.push(messageOf8(child, prefix, build2));
|
|
169723
170451
|
} else if (isEnum(child)) {
|
|
169724
170452
|
proto.enumType.push(enumOf(child, prefix, build2));
|
|
169725
170453
|
} else if (isService(child)) {
|
|
@@ -169773,7 +170501,7 @@ function mapEntryNameOf(name2) {
|
|
|
169773
170501
|
}
|
|
169774
170502
|
return `${out}Entry`;
|
|
169775
170503
|
}
|
|
169776
|
-
function
|
|
170504
|
+
function messageOf8(type, scope, build2) {
|
|
169777
170505
|
const full = `${scope}${type.name}`;
|
|
169778
170506
|
if (type.group === true) {
|
|
169779
170507
|
throw new GrpcImportError(
|
|
@@ -169808,7 +170536,7 @@ function messageOf7(type, scope, build2) {
|
|
|
169808
170536
|
checkJsonNames(message2, full, build2);
|
|
169809
170537
|
for (const child of type.nestedArray) {
|
|
169810
170538
|
if (isType(child)) {
|
|
169811
|
-
message2.nestedType.push(
|
|
170539
|
+
message2.nestedType.push(messageOf8(child, `${full}.`, build2));
|
|
169812
170540
|
} else if (isEnum(child)) {
|
|
169813
170541
|
message2.enumType.push(enumOf(child, `${full}.`, build2));
|
|
169814
170542
|
} else if (isExtension(child)) {
|
|
@@ -170306,13 +171034,13 @@ function optionsOf(schema, raw, skip2, where2, build2) {
|
|
|
170306
171034
|
if (Object.keys(rest).every((key) => known.has(key))) {
|
|
170307
171035
|
throw new GrpcImportError(
|
|
170308
171036
|
"invalid",
|
|
170309
|
-
`${build2.file} sets an option on ${where2} to a value of the wrong type for ${schema.typeName}: ${
|
|
171037
|
+
`${build2.file} sets an option on ${where2} to a value of the wrong type for ${schema.typeName}: ${messageOf7(error2)}. Correct the value.`,
|
|
170310
171038
|
build2.file
|
|
170311
171039
|
);
|
|
170312
171040
|
}
|
|
170313
171041
|
throw new GrpcImportError(
|
|
170314
171042
|
"unsupported",
|
|
170315
|
-
`${build2.file} sets an option on ${where2} that ${schema.typeName} does not define: ${
|
|
171043
|
+
`${build2.file} sets an option on ${where2} that ${schema.typeName} does not define: ${messageOf7(error2)}. Correct or remove the option.`,
|
|
170316
171044
|
build2.file
|
|
170317
171045
|
);
|
|
170318
171046
|
}
|
|
@@ -171327,7 +172055,7 @@ function parseProto(name2, text6) {
|
|
|
171327
172055
|
} catch (error2) {
|
|
171328
172056
|
throw new GrpcImportError(
|
|
171329
172057
|
"parse",
|
|
171330
|
-
`${name2} does not parse: ${
|
|
172058
|
+
`${name2} does not parse: ${messageOf7(error2)}. Fix the file and import it again.`,
|
|
171331
172059
|
name2
|
|
171332
172060
|
);
|
|
171333
172061
|
}
|
|
@@ -171599,7 +172327,7 @@ function buildSet(input2, notes) {
|
|
|
171599
172327
|
} catch (error2) {
|
|
171600
172328
|
throw new GrpcImportError(
|
|
171601
172329
|
"invalid",
|
|
171602
|
-
`The files do not form a valid descriptor set: ${
|
|
172330
|
+
`The files do not form a valid descriptor set: ${messageOf7(error2)}. Fix the definition and import again.`
|
|
171603
172331
|
);
|
|
171604
172332
|
}
|
|
171605
172333
|
return {
|
|
@@ -171904,7 +172632,7 @@ function decodeAll(protos) {
|
|
|
171904
172632
|
} catch (error2) {
|
|
171905
172633
|
throw new GrpcImportError(
|
|
171906
172634
|
"reflection",
|
|
171907
|
-
`Entry ${index + 1} of the reflection result is not a FileDescriptorProto: ${
|
|
172635
|
+
`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
172636
|
);
|
|
171909
172637
|
}
|
|
171910
172638
|
const earlier = byName2.get(file2.name);
|
|
@@ -172824,7 +173552,7 @@ function compileTool(input2, key, entry2, auth2, issues) {
|
|
|
172824
173552
|
issues.push({
|
|
172825
173553
|
tool: key,
|
|
172826
173554
|
field: "name",
|
|
172827
|
-
message: `${key}: ${
|
|
173555
|
+
message: `${key}: ${messageOf7(error2)}`
|
|
172828
173556
|
});
|
|
172829
173557
|
return void 0;
|
|
172830
173558
|
}
|
|
@@ -172971,7 +173699,7 @@ function resolveEnvironments(server, issues) {
|
|
|
172971
173699
|
issues.push({
|
|
172972
173700
|
tool: void 0,
|
|
172973
173701
|
field: "environments",
|
|
172974
|
-
message:
|
|
173702
|
+
message: messageOf7(error2)
|
|
172975
173703
|
});
|
|
172976
173704
|
return {};
|
|
172977
173705
|
}
|
|
@@ -173023,7 +173751,7 @@ function resolveAuth(input2, environments2, issues) {
|
|
|
173023
173751
|
try {
|
|
173024
173752
|
apply = builtinSecurityScheme(scheme, declared.header);
|
|
173025
173753
|
} catch (error2) {
|
|
173026
|
-
return fail3(
|
|
173754
|
+
return fail3(messageOf7(error2));
|
|
173027
173755
|
}
|
|
173028
173756
|
}
|
|
173029
173757
|
if (apply.type === "mutual_tls") {
|
|
@@ -174546,7 +175274,7 @@ function transportFailure(error2) {
|
|
|
174546
175274
|
return {
|
|
174547
175275
|
error: {
|
|
174548
175276
|
title: "Transport error",
|
|
174549
|
-
detail:
|
|
175277
|
+
detail: messageOf7(error2),
|
|
174550
175278
|
status: void 0
|
|
174551
175279
|
},
|
|
174552
175280
|
sent: true
|
|
@@ -174623,7 +175351,7 @@ function parseJson4(text6) {
|
|
|
174623
175351
|
const value = JSON.parse(text6);
|
|
174624
175352
|
return { ok: true, value };
|
|
174625
175353
|
} catch (error2) {
|
|
174626
|
-
return { ok: false, message:
|
|
175354
|
+
return { ok: false, message: messageOf7(error2) };
|
|
174627
175355
|
}
|
|
174628
175356
|
}
|
|
174629
175357
|
function isJsonMediaType(contentType) {
|
|
@@ -174878,7 +175606,7 @@ function sendFailure(error2, sender) {
|
|
|
174878
175606
|
ok: false,
|
|
174879
175607
|
error: {
|
|
174880
175608
|
title: "Internal error",
|
|
174881
|
-
detail: `The ${sender} Sender failed: ${
|
|
175609
|
+
detail: `The ${sender} Sender failed: ${messageOf7(error2)}`,
|
|
174882
175610
|
status: void 0
|
|
174883
175611
|
},
|
|
174884
175612
|
attempts: 0
|
|
@@ -176257,7 +176985,7 @@ function registryFor(descriptorSet) {
|
|
|
176257
176985
|
registry3 = createFileRegistry(fromBinary(FileDescriptorSetSchema, bytes));
|
|
176258
176986
|
} catch (error2) {
|
|
176259
176987
|
throw new DescriptorError(
|
|
176260
|
-
`The server's descriptor_set does not parse: ${
|
|
176988
|
+
`The server's descriptor_set does not parse: ${messageOf7(error2)}`
|
|
176261
176989
|
);
|
|
176262
176990
|
}
|
|
176263
176991
|
if (registries.size >= REGISTRY_CACHE_SIZE) {
|
|
@@ -176323,7 +177051,7 @@ function encodeRequest(method, args) {
|
|
|
176323
177051
|
);
|
|
176324
177052
|
} catch (error2) {
|
|
176325
177053
|
throw new DescriptorError(
|
|
176326
|
-
`The arguments do not encode as ${method.input.typeName}: ${
|
|
177054
|
+
`The arguments do not encode as ${method.input.typeName}: ${messageOf7(error2)}`
|
|
176327
177055
|
);
|
|
176328
177056
|
}
|
|
176329
177057
|
}
|
|
@@ -176334,7 +177062,7 @@ function requestJson(method, bytes) {
|
|
|
176334
177062
|
});
|
|
176335
177063
|
} catch (error2) {
|
|
176336
177064
|
throw new DescriptorError(
|
|
176337
|
-
`The request does not decode as ${method.input.typeName}: ${
|
|
177065
|
+
`The request does not decode as ${method.input.typeName}: ${messageOf7(error2)}`
|
|
176338
177066
|
);
|
|
176339
177067
|
}
|
|
176340
177068
|
}
|
|
@@ -176346,7 +177074,7 @@ function decodeResponse(method, bytes) {
|
|
|
176346
177074
|
});
|
|
176347
177075
|
} catch (error2) {
|
|
176348
177076
|
throw new DescriptorError(
|
|
176349
|
-
`The response does not decode as ${method.output.typeName}: ${
|
|
177077
|
+
`The response does not decode as ${method.output.typeName}: ${messageOf7(error2)}`
|
|
176350
177078
|
);
|
|
176351
177079
|
}
|
|
176352
177080
|
}
|
|
@@ -176560,7 +177288,7 @@ function createGrpcSender(options = {}) {
|
|
|
176560
177288
|
ok: false,
|
|
176561
177289
|
error: {
|
|
176562
177290
|
title: "Internal error",
|
|
176563
|
-
detail: `The gRPC Sender failed: ${
|
|
177291
|
+
detail: `The gRPC Sender failed: ${messageOf7(error2)}`,
|
|
176564
177292
|
status: void 0
|
|
176565
177293
|
},
|
|
176566
177294
|
attempts: 0,
|
|
@@ -176604,7 +177332,7 @@ function prepare(template, args, context) {
|
|
|
176604
177332
|
ok: false,
|
|
176605
177333
|
error: {
|
|
176606
177334
|
title: "Invalid descriptor set",
|
|
176607
|
-
detail:
|
|
177335
|
+
detail: messageOf7(error2),
|
|
176608
177336
|
status: void 0
|
|
176609
177337
|
}
|
|
176610
177338
|
};
|
|
@@ -176627,7 +177355,7 @@ function prepare(template, args, context) {
|
|
|
176627
177355
|
const title = error2 instanceof BuildError ? error2.title : "Invalid request";
|
|
176628
177356
|
return {
|
|
176629
177357
|
ok: false,
|
|
176630
|
-
error: { title, detail:
|
|
177358
|
+
error: { title, detail: messageOf7(error2), status: void 0 }
|
|
176631
177359
|
};
|
|
176632
177360
|
}
|
|
176633
177361
|
let message2;
|
|
@@ -176638,7 +177366,7 @@ function prepare(template, args, context) {
|
|
|
176638
177366
|
ok: false,
|
|
176639
177367
|
error: {
|
|
176640
177368
|
title: "Invalid arguments",
|
|
176641
|
-
detail:
|
|
177369
|
+
detail: messageOf7(error2),
|
|
176642
177370
|
status: void 0
|
|
176643
177371
|
}
|
|
176644
177372
|
};
|
|
@@ -176713,7 +177441,7 @@ async function read(response, call2, clock2, settings) {
|
|
|
176713
177441
|
item = decodeResponse(call2.method, encoded);
|
|
176714
177442
|
} catch (error2) {
|
|
176715
177443
|
response.cancel();
|
|
176716
|
-
return failed3(internal(
|
|
177444
|
+
return failed3(internal(messageOf7(error2)));
|
|
176717
177445
|
}
|
|
176718
177446
|
items.push(item);
|
|
176719
177447
|
if (template.streaming === "server") {
|
|
@@ -176764,7 +177492,7 @@ function transportFailure2(error2, call2, items) {
|
|
|
176764
177492
|
if (!(error2 instanceof TransportError)) {
|
|
176765
177493
|
return failed3({
|
|
176766
177494
|
title: "Transport error",
|
|
176767
|
-
detail:
|
|
177495
|
+
detail: messageOf7(error2),
|
|
176768
177496
|
status: void 0
|
|
176769
177497
|
});
|
|
176770
177498
|
}
|