@gitroll/tacitt-cli 0.3.0 → 0.4.1

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.
@@ -1,10 +1,10 @@
1
- import { A as runConfiguredSessionJob, C as readConfiguredSearchFields, D as captureLogicalJourneySources, F as sessionWorkerFailure, G as staticMaskCategory, H as readLogicalJourneyFinalMasks, I as privateCollectionDirectory, K as readWorkspacePair, L as defaultParallelism, M as parseCollectionWorkspaceSummary, N as createSharedSessionPool, O as capturedJourneyScope, P as SessionWorkerError, Q as createCleanup, R as gitSeedsProvider, S as readOriginalSearchFields, T as checkReusableBundle, U as readConfiguredOutputInfo, V as privateJourneyDirectory, W as processJourneyMetadataFields, X as createTemporary, Z as removeNamedTemporarySpools, _ as readStaticSessionMasks, a as scanReviewFields, at as isWindowsAclFailure, c as readSessionScanRecords, g as processJourneyMetadata, h as readCapturedOriginalRows, i as buildWorkScanBatches, it as windowsOwnerOnly, j as readCollectionIndex, l as scanPreparedSession, n as verifyPreparedSessionSources, nt as openPrivateFile, o as createWorkPieces, ot as windowsAclCodes, p as openConfiguredUpload, r as prepareSessionScans, rt as restrictToOwner, s as readSessionScanFields, t as preparedScanConfiguration, tt as makePrivateDirectory, v as staticSessionJobs, w as createCollectionArtifacts, z as parallelismLimits } from "./src-CPbdnGrk.mjs";
1
+ import { A as runConfiguredSessionJob, C as readConfiguredSearchFields, D as captureLogicalJourneySources, F as sessionWorkerFailure, G as staticMaskCategory, H as readLogicalJourneyFinalMasks, I as privateCollectionDirectory, K as readWorkspacePair, L as defaultParallelism, M as parseCollectionWorkspaceSummary, N as createSharedSessionPool, O as capturedJourneyScope, P as SessionWorkerError, Q as createCleanup, R as gitSeedsProvider, S as readOriginalSearchFields, T as checkReusableBundle, U as readConfiguredOutputInfo, V as privateJourneyDirectory, W as processJourneyMetadataFields, X as createTemporary, Z as removeNamedTemporarySpools, _ as readStaticSessionMasks, a as scanReviewFields, at as isWindowsAclFailure, c as readSessionScanRecords, g as processJourneyMetadata, h as readCapturedOriginalRows, i as buildWorkScanBatches, it as windowsOwnerOnly, j as readCollectionIndex, l as scanPreparedSession, n as verifyPreparedSessionSources, nt as openPrivateFile, o as createWorkPieces, ot as windowsAclCodes, p as openConfiguredUpload, r as prepareSessionScans, rt as restrictToOwner, s as readSessionScanFields, t as preparedScanConfiguration, tt as makePrivateDirectory, v as staticSessionJobs, w as createCollectionArtifacts, z as parallelismLimits } from "./src-DIuh0LHk.mjs";
2
2
  import { Bt as sessionPeriodSchema, Dn as entityDictionaryVersion, F as bClassificationKey, Fn as frameRecords, Ft as termTypeInfo, Gt as safeField, H as codePointLength, Ht as ApplicationError, Jt as reviewFamilies, K as utf16Offset, N as bUnitFragments, Ot as privacyTermKey, Qn as admitGitName, T as bLiteralTerms, Ut as UnfinishedJourneyError, V as bDigest, Wt as safeCode, Xn as createEntityMatcher, Zn as admitCustomTerm, Zt as observeSource, b as validateBReview, c as textDigest, h as reviewFindingsDigest, ht as journeyDescribeSchema, jt as reviewTermsInputSchema, l as validateReview, mn as currentDetectorVersion, n as compileBFindings, r as reviewBatchChunks, s as reviewSubmitSchema, t as locateTerms, yn as createStaticProcessor, z as bAnchorKey } from "./locate-U3-nkird.mjs";
3
- import { a as mainTextChunks, c as previewInWorker, i as nearestSortingRepository, l as createNativeAdapters, n as createProjectEvidenceCollector, o as mainTextFields, r as sortingRepositoryId, s as textChunks, t as createHarnesses, u as createGitNameSeedProvider } from "./src-qoLRvX-A.mjs";
4
- import { $ as settingsQuerySchema, $n as reviewCandidateInputSchema, $t as journeySearchResultSchema, A as deviceProfileScopeSchema, Ar as nativeEventsSchema, B as validateInspectionBatch, Br as isSelectedWork, Bt as journeyReviewStorageQuerySchema, C as rebindReviewSubmit, Ct as sendStartSchema, D as createAccount, Dt as sendReplaceResultSchema, E as staticallyHiddenFindings, En as confirmedHideAdditions, Er as journeyClassificationSessionsSchema, Et as sendReceiptSchema, Gr as journeyFindingsSchema, Gt as retireScanGeneration, Hr as withReadingProgress, Jr as journeyRenderSchema, Jt as journeyContextQuerySchema, Kn as journeyConfirmedHides, Kr as journeyPreviewSchema, Kt as newJourneyWork, L as createApplication, Lr as hasCompleteWorkDescription, M as readAccountAvatarUrl, Mr as nativeRespondSchema, Mt as obsoleteJourney, N as storedCredentialSchema, Nr as hasCurrentStaticReview, O as accountProfileSchema, On as readConfirmedHideChange, Or as assertJourneyPrivacyReady, Ot as sendResolutionSchema, Pr as staticReviewDigest, Q as settingsBatchSchema, Qn as workCorrectionBinding, Qr as selectionSchema, R as inspectionCancelSchema, Rr as isClassifying, Rt as applyClassification, S as rebindReviewOverlay, St as sendPrepareSchema, T as guardedFindingText, Tt as sendArtifactSchema, U as inspectionQuerySchema, Un as confirmedHideKinds, Ut as classificationPartition, Vn as confirmedHideGroupIds, Wr as journeyFindingImpactSchema, Wt as classificationWorks, Xn as workDecisionDigest, Xr as packageCommandSchema, Yn as retireWorkDescription, Yr as commandSchema, Zr as selectionBatchSchema, _n as sessionReviewInputSchema, _r as journeyInventoryQuerySchema, _t as maximumTermsFileBytes, a as bCrossSegmentReviewSchema, b as bReviewScope, bt as sendActionSchema, c as reconstructBFields, ct as validateFailureLocation, d as selectedValueMembers, dr as scanGitSeedsId, dt as manualUploadChoiceSchema, ei as producerVersion, er as reviewCandidateResourceSchema, et as readWorkspaceOutcomes, f as splitSelectorValues, fn as sessionReconcileInputSchema, fr as scanGitSeedsResource, ft as manualUploadPrepareSchema, g as changeJourney, gt as emptyTermsRevision, hn as sessionRereadInputSchema, i as validateBCrossSegmentReview, in as journeyResourceQuerySchema, ir as bReviewDigest, j as profileUrlMatchesIdentity, jn as termHideAdditions, jr as nativeGetSchema, jt as currentJourneyAdapters, k as deviceAuthorizationSchema, kr as privacyDecisionDigest, kt as sendSettingsSchema, ln as reviewAttemptResourceSchema, lr as scanPreparationDigest, lt as manualUploadActionSchema, m as hideScopeDigest, mr as scanExclusionResourceSchema, mt as manualUploadStartSchema, n as scanBatchEquivalenceDigest, nn as journeyPolicyRespondSchema, nr as reviewRepairResourceSchema, nt as appendSensitiveTerms, o as bRereadDigest, or as planBRepair, ot as artifactFailureDetailSchema, p as activeJourneyTerms, pr as verifiedScanGitSeeds, pt as manualUploadSchema, qn as maskedHitsStale, qr as journeyRenderInputSchema, qt as reviewCompileSchema, r as locateTermEvidence, ri as recommendParallelism, s as reconcileBSession, sn as journeyPlaceSchema, st as resolveFailureLocation, t as scanBatchContextDigest, ti as stateSchema, tn as searchScopeDigest, tr as reviewRepairInputSchema, ur as scanSessionResourceSchema, vn as sessionReviewQuerySchema, vt as normalizeSensitiveTerms, w as reviewBatchReuse, wt as journeySendSchema, x as rebindReviewAlignment, xn as sessionUsefulnessInputSchema, xr as emptyPreparationFacts, xt as sendChoiceSchema, y as isGenericPublicTerm, yt as replaceSensitiveTermsSchema, z as inspectionStartSchema, zn as bTermMatcher, zr as isReadingComplete } from "./src-B4R5XMEP.mjs";
5
- import { $ as checkVersion, A as resourceSelectionQuerySchema, B as termReuseQuerySchema, C as loadAcceptedReview, D as aggregateUsefulness, E as loadPrivateResource, F as validateUnitCandidate, G as requireActiveBatch, H as batchHeader, I as reuseQuerySchema, J as validateDatabase, K as initializeAndClaim, L as batchQuery, M as evaluateUnitEvidence, N as sameCandidateRequest, O as sessionUsefulnessRecommendation, P as validateCandidateAttempt, Q as validateState, R as isPrivateResourceKind, S as validateSessionBindings, T as loadBatch, U as createJourneyPayloadFiles, V as privateReviewHash, W as validateBatchBody, X as readBundleDirectory, Y as withDatabase, Z as readStoredState, _ as loadReconciliation, _t as isCoordinationBusy, a as decodeError, at as hasResetMarker, b as validatePreparationSelection, c as dropsAnchor, ct as privatePath, d as parseDelivery, dt as stateDirectory, et as schemaVersion, f as validateCandidate, ft as syncDirectory, g as loadPreparedBodies, gt as errorCode$1, h as loadPreparation, ht as StoreError, i as createExecutor, it as finishReset, j as inspectionQuerySchema$1, k as sessionQuery, l as replySchema, lt as readResetMarker, m as loadStatus, mt as withFileCheckTimings, n as releaseInheritedHeapFlags, nt as createDatabaseFile, o as ProtocolError, ot as inspectStateFiles, p as classificationJourneyCommit, pt as withStateSnapshot, q as ownership, r as storeHeapLimits, rt as databaseName, s as allowedReplies, st as present, tt as beginReset, u as operations, ut as recheckPrivatePath, v as loadRereadBodies, vt as isSqliteCorruption, w as loadAuthenticatedReview, x as validateSessionReconciliation, y as loadSessionBodies, z as privateResourceHeader } from "./heap-eO_uWpD1.mjs";
6
- import { _ as staticBaseProduction, a as writeJourneyOutput, c as mergeHideIndexTokens, f as writeJourneyBase, g as staticBaseInputs, h as staticSessions, l as packRenderHideIndex, m as saveStaticSession, o as createHideIndexTokens, p as readStaticResult, s as hideIndexTexts, t as journeyOutputJob, u as journeyBaseJob, v as prepareSourcePlan, y as workApproval } from "./job-rK-Ho9OD.mjs";
7
- import { t as createAgentSetupPort } from "./agent-setup-CLXdKr2I.mjs";
3
+ import { a as mainTextChunks, c as previewInWorker, i as nearestSortingRepository, l as createNativeAdapters, n as createProjectEvidenceCollector, o as mainTextFields, r as sortingRepositoryId, s as textChunks, t as createHarnesses, u as createGitNameSeedProvider } from "./src-BESjwh7X.mjs";
4
+ import { $ as settingsQuerySchema, $r as packageCommandSchema, A as deviceProfileScopeSchema, B as validateInspectionBatch, Bn as journeyConfirmedHides, Br as hasCompleteWorkDescription, Bt as newJourneyWork, C as rebindReviewSubmit, Cr as privacyDecisionDigest, Ct as sendStartSchema, D as createAccount, Dr as hasCurrentStaticReview, E as staticallyHiddenFindings, Er as nativeRespondSchema, Et as obsoleteJourney, Fn as confirmedHideGroupIds, Fr as sendArtifactSchema, Gr as withReadingProgress, Hr as isReadingComplete, Ht as journeyContextQuerySchema, Ir as sendReceiptSchema, Jn as reviewCandidateResourceSchema, Jr as journeyFindingsSchema, Kn as workCorrectionBinding, L as createApplication, Ln as confirmedHideKinds, Lr as sendReplaceResultSchema, Lt as classificationPartition, M as readAccountAvatarUrl, Mr as agentSourceSchema, Mt as applyClassification, N as storedCredentialSchema, Nn as bTermMatcher, Nr as agentSourcesSchema, O as accountProfileSchema, Or as staticReviewDigest, Pr as journeySendSchema, Pt as journeyReviewStorageQuerySchema, Q as settingsBatchSchema, Qn as bReviewDigest, Qr as commandSchema, Qt as journeyResourceQuerySchema, R as inspectionCancelSchema, Rr as sendResolutionSchema, Rt as classificationWorks, S as rebindReviewOverlay, Sn as readConfirmedHideChange, Sr as assertJourneyPrivacyReady, St as sendPrepareSchema, T as guardedFindingText, Tn as termHideAdditions, Tr as nativeGetSchema, Tt as currentJourneyAdapters, U as inspectionQuerySchema, Un as retireWorkDescription, Ur as isSelectedWork, Vn as maskedHitsStale, Vr as isClassifying, Vt as reviewCompileSchema, Wn as workDecisionDigest, Xn as reviewRepairResourceSchema, Xr as journeyRenderInputSchema, Xt as journeyPolicyRespondSchema, Yn as reviewRepairInputSchema, Yr as journeyPreviewSchema, Yt as searchScopeDigest, Zr as journeyRenderSchema, _t as maximumTermsFileBytes, a as bCrossSegmentReviewSchema, ar as scanGitSeedsId, b as bReviewScope, bn as confirmedHideAdditions, br as journeyClassificationSessionsSchema, bt as sendActionSchema, c as reconstructBFields, cr as scanExclusionResourceSchema, ct as validateFailureLocation, d as selectedValueMembers, dn as sessionReviewInputSchema, dr as journeyInventoryQuerySchema, dt as manualUploadChoiceSchema, ei as selectionBatchSchema, er as planBRepair, et as readWorkspaceOutcomes, f as splitSelectorValues, fn as sessionReviewQuerySchema, ft as manualUploadPrepareSchema, g as changeJourney, gt as emptyTermsRevision, hn as sessionUsefulnessInputSchema, hr as emptyPreparationFacts, i as validateBCrossSegmentReview, ii as stateSchema, ir as scanSessionResourceSchema, j as profileUrlMatchesIdentity, k as deviceAuthorizationSchema, ln as sessionRereadInputSchema, lt as manualUploadActionSchema, m as hideScopeDigest, mt as manualUploadStartSchema, n as scanBatchEquivalenceDigest, nt as appendSensitiveTerms, o as bRereadDigest, oi as recommendParallelism, on as sessionReconcileInputSchema, or as scanGitSeedsResource, ot as artifactFailureDetailSchema, p as activeJourneyTerms, pt as manualUploadSchema, qn as reviewCandidateInputSchema, qr as journeyFindingImpactSchema, qt as journeySearchResultSchema, r as locateTermEvidence, ri as producerVersion, rn as reviewAttemptResourceSchema, rr as scanPreparationDigest, s as reconcileBSession, sr as verifiedScanGitSeeds, st as resolveFailureLocation, t as scanBatchContextDigest, ti as selectionSchema, tn as journeyPlaceSchema, vt as normalizeSensitiveTerms, w as reviewBatchReuse, wr as nativeEventsSchema, x as rebindReviewAlignment, xt as sendChoiceSchema, y as isGenericPublicTerm, yt as replaceSensitiveTermsSchema, z as inspectionStartSchema, zr as sendSettingsSchema, zt as retireScanGeneration } from "./src-DSDRF7i6.mjs";
5
+ import { $ as checkVersion, A as resourceSelectionQuerySchema, B as termReuseQuerySchema, C as loadAcceptedReview, D as aggregateUsefulness, E as loadPrivateResource, F as validateUnitCandidate, G as requireActiveBatch, H as batchHeader, I as reuseQuerySchema, J as validateDatabase, K as initializeAndClaim, L as batchQuery, M as evaluateUnitEvidence, N as sameCandidateRequest, O as sessionUsefulnessRecommendation, P as validateCandidateAttempt, Q as validateState, R as isPrivateResourceKind, S as validateSessionBindings, T as loadBatch, U as createJourneyPayloadFiles, V as privateReviewHash, W as validateBatchBody, X as readBundleDirectory, Y as withDatabase, Z as readStoredState, _ as loadReconciliation, _t as isCoordinationBusy, a as decodeError, at as hasResetMarker, b as validatePreparationSelection, c as dropsAnchor, ct as privatePath, d as parseDelivery, dt as stateDirectory, et as schemaVersion, f as validateCandidate, ft as syncDirectory, g as loadPreparedBodies, gt as errorCode$1, h as loadPreparation, ht as StoreError, i as createExecutor, it as finishReset, j as inspectionQuerySchema$1, k as sessionQuery, l as replySchema, lt as readResetMarker, m as loadStatus, mt as withFileCheckTimings, n as releaseInheritedHeapFlags, nt as createDatabaseFile, o as ProtocolError, ot as inspectStateFiles, p as classificationJourneyCommit, pt as withStateSnapshot, q as ownership, r as storeHeapLimits, rt as databaseName, s as allowedReplies, st as present, tt as beginReset, u as operations, ut as recheckPrivatePath, v as loadRereadBodies, vt as isSqliteCorruption, w as loadAuthenticatedReview, x as validateSessionReconciliation, y as loadSessionBodies, z as privateResourceHeader } from "./heap-eZTo0VYj.mjs";
6
+ import { _ as staticBaseProduction, a as writeJourneyOutput, c as mergeHideIndexTokens, f as writeJourneyBase, g as staticBaseInputs, h as staticSessions, l as packRenderHideIndex, m as saveStaticSession, o as createHideIndexTokens, p as readStaticResult, s as hideIndexTexts, t as journeyOutputJob, u as journeyBaseJob, v as prepareSourcePlan, y as workApproval } from "./job-Bi57uRU-.mjs";
7
+ import { t as createAgentSetupPort } from "./agent-setup-Cb_spmGb.mjs";
8
8
  import { t as workerMessageSchema } from "./messages-D3m3bhva.mjs";
9
9
  import { constants, write } from "node:fs";
10
10
  import { z } from "zod";
@@ -925,7 +925,7 @@ function createRouter(application, account, stopping, delivery, nativeInspection
925
925
  })
926
926
  }),
927
927
  send: t.router({
928
- get: t.procedure.input(sendAddress.partial({ sendId: true })).query(({ input }) => sending().get(input)),
928
+ get: t.procedure.input(sendAddress.partial({ sendId: true })).query(({ input, signal }) => readThroughContention(() => sending().get(input), signal)),
929
929
  prepare: t.procedure.input(sendPrepareSchema).mutation(({ input, signal }) => sending().prepare(input, signal)),
930
930
  start: t.procedure.input(sendStartSchema).mutation(({ input, signal }) => sending().start(input, signal)),
931
931
  respond: t.procedure.input(sendChoiceSchema).mutation(({ input }) => sending().respond(input)),
@@ -6660,6 +6660,7 @@ async function prepareScanContext(storage, journeyId, work, selected, processing
6660
6660
  }
6661
6661
  //#endregion
6662
6662
  //#region apps/cli/src/journey/prepare/scan-plan.ts
6663
+ let publication = Promise.resolve();
6663
6664
  /**
6664
6665
  * The second pass of a Work's Track A (ADR 0177): with every session's receipt saved, its
6665
6666
  * authenticated fields files are read in the Work's reading order twice, once to find each
@@ -6667,6 +6668,18 @@ async function prepareScanContext(storage, journeyId, work, selected, processing
6667
6668
  * Only the plan's outlines stay in memory between the reads, never the Work's text.
6668
6669
  */
6669
6670
  async function publishWorkBatches(storage, plan, work, resources, signal) {
6671
+ const previous = publication;
6672
+ const turn = Promise.withResolvers();
6673
+ publication = turn.promise;
6674
+ await previous;
6675
+ try {
6676
+ signal.throwIfAborted();
6677
+ return await publishAdmittedWork(storage, plan, work, resources, signal);
6678
+ } finally {
6679
+ turn.resolve();
6680
+ }
6681
+ }
6682
+ async function publishAdmittedWork(storage, plan, work, resources, signal) {
6670
6683
  const order = new Map(plan.approval.inventory.sessions.map((item, index) => [item.id, index]));
6671
6684
  const workIndex = (resource) => {
6672
6685
  const index = order.get(resource.input.sessionId);
@@ -9792,7 +9805,33 @@ function createJourneySendArtifacts(storage) {
9792
9805
  const output = await find(journey.journeyId, work.id, work.revision);
9793
9806
  const info = await readConfiguredOutputInfo(output.primary, signal);
9794
9807
  if (info.work.id !== work.id || info.work.access !== work.access) throw new ApplicationError("ARTIFACT_IDENTITY_MISMATCH");
9808
+ let agentSources = [];
9809
+ try {
9810
+ const base = (await storage.resources({
9811
+ journeyId: journey.journeyId,
9812
+ kind: "base"
9813
+ })).find((item) => item.kind === "base" && item.workId === work.id && item.inputRevision === output.finalMaskLedger.inputRevision && item.primary.sha256 === output.finalMaskLedger.basePrimarySha256);
9814
+ if (base?.kind === "base") {
9815
+ const included = new Set(base.sessions.map((item) => item.applicationSessionId));
9816
+ const resources = await storage.resources({
9817
+ journeyId: journey.journeyId,
9818
+ kind: "static-session"
9819
+ });
9820
+ const unique = /* @__PURE__ */ new Map();
9821
+ for (const resource of resources) {
9822
+ if (resource.kind !== "static-session" || resource.workId !== work.id || resource.inputRevision !== base.inputRevision || !included.has(resource.sessionId)) continue;
9823
+ for (const candidate of resource.agentSources ?? []) {
9824
+ const parsed = agentSourceSchema.safeParse(candidate);
9825
+ if (parsed.success && unique.size < 500) unique.set(JSON.stringify(parsed.data), parsed.data);
9826
+ }
9827
+ }
9828
+ agentSources = [...unique.values()];
9829
+ }
9830
+ } catch {
9831
+ console.error("AGENT_SOURCES_METADATA_UNAVAILABLE");
9832
+ }
9795
9833
  return sendArtifactSchema.parse({
9834
+ ...agentSources.length === 0 ? {} : { agentSources },
9796
9835
  workId: work.id,
9797
9836
  revision: work.revision,
9798
9837
  bundleId: info.manifest.bundleId,
@@ -9952,6 +9991,85 @@ async function readOwnerJson(response) {
9952
9991
  return JSON.parse(Buffer.concat(chunks, bytes).toString("utf8"));
9953
9992
  }
9954
9993
  //#endregion
9994
+ //#region apps/cli/src/account/journey/public-sources.ts
9995
+ /** Anonymous evidence only. Expected absence, refusal and lookup failure all omit enrichment. */
9996
+ async function publicSource(source, requestFetch, signal) {
9997
+ const controller = new AbortController();
9998
+ let onAbort = () => {};
9999
+ const cancelled = new Promise((resolve) => {
10000
+ onAbort = () => {
10001
+ controller.abort();
10002
+ resolve(false);
10003
+ };
10004
+ signal?.addEventListener("abort", onAbort, { once: true });
10005
+ if (signal?.aborted) onAbort();
10006
+ });
10007
+ let timer;
10008
+ const expired = new Promise((resolve) => {
10009
+ timer = setTimeout(() => {
10010
+ controller.abort();
10011
+ resolve(false);
10012
+ }, 3e3);
10013
+ });
10014
+ const check = async () => {
10015
+ const response = await requestFetch(source.type === "github" ? `https://api.github.com/repos/${source.repo}` : `https://registry.npmjs.org/${encodeURIComponent(source.package)}`, {
10016
+ method: "GET",
10017
+ credentials: "omit",
10018
+ redirect: "error",
10019
+ referrerPolicy: "no-referrer",
10020
+ cache: "no-store",
10021
+ signal: controller.signal
10022
+ });
10023
+ if (response.status !== 200 || source.type === "npm") {
10024
+ await response.body?.cancel();
10025
+ return response.status === 200;
10026
+ }
10027
+ const value = await readOwnerJson(response);
10028
+ return typeof value === "object" && value !== null && "private" in value && value.private === false;
10029
+ };
10030
+ try {
10031
+ return await Promise.race([
10032
+ check(),
10033
+ expired,
10034
+ cancelled
10035
+ ]);
10036
+ } catch {
10037
+ return false;
10038
+ } finally {
10039
+ signal?.removeEventListener("abort", onAbort);
10040
+ clearTimeout(timer);
10041
+ controller.abort();
10042
+ }
10043
+ }
10044
+ /** One upload, at most twenty distinct checks in parallel and a three-second I/O deadline. */
10045
+ async function checkPublicAgentSources(candidates, requestFetch = fetch, signal) {
10046
+ signal?.throwIfAborted();
10047
+ if (!Array.isArray(candidates) || candidates.length > 500) return [];
10048
+ const admittedShape = candidates.flatMap((item) => {
10049
+ const parsed = agentSourcesSchema.element.safeParse(item);
10050
+ return parsed.success ? [parsed.data] : [];
10051
+ });
10052
+ const cache = /* @__PURE__ */ new Map();
10053
+ const selected = [];
10054
+ for (const item of admittedShape) {
10055
+ const source = item.source;
10056
+ const key = source.type === "github" ? `github:${source.repo.toLowerCase()}` : `npm:${source.package}`;
10057
+ let result = cache.get(key);
10058
+ if (!result) {
10059
+ if (cache.size === 20) continue;
10060
+ result = publicSource(source, requestFetch, signal);
10061
+ cache.set(key, result);
10062
+ }
10063
+ selected.push({
10064
+ item,
10065
+ result
10066
+ });
10067
+ }
10068
+ const results = await Promise.all(selected.map(async ({ item, result }) => await result ? item : null));
10069
+ signal?.throwIfAborted();
10070
+ return results.filter((item) => item !== null);
10071
+ }
10072
+ //#endregion
9955
10073
  //#region apps/cli/src/account/journey/client.ts
9956
10074
  const refusalSchema = z.object({
9957
10075
  error: z.string(),
@@ -10041,6 +10159,9 @@ function createJourneyOwnerClient(options) {
10041
10159
  const receipt = (id) => sendReceiptSchema.refine((value) => value.receiptId === id);
10042
10160
  return {
10043
10161
  subject: options.subject,
10162
+ checkAgentSources(candidates, signal) {
10163
+ return checkPublicAgentSources(candidates, requestFetch, signal);
10164
+ },
10044
10165
  async assertCurrent(signal) {
10045
10166
  await options.authorize();
10046
10167
  signal.throwIfAborted();
@@ -10065,8 +10186,15 @@ function createJourneyOwnerClient(options) {
10065
10186
  membersDigest: preview.membersDigest
10066
10187
  }, "PUT");
10067
10188
  },
10068
- reserve(key, input, signal, checksumUpload = true) {
10069
- return request("/me/work-bundles/uploads", sendReceiptSchema.refine((value) => receiptMatches(input, value)), signal, input, "POST", key, requestTimeoutMs$2, checksumUpload);
10189
+ async reserve(key, input, signal, checksumUpload = true) {
10190
+ const reserve = (body) => request("/me/work-bundles/uploads", sendReceiptSchema.refine((value) => receiptMatches(input, value)), signal, body, "POST", key, requestTimeoutMs$2, checksumUpload);
10191
+ try {
10192
+ return await reserve(input);
10193
+ } catch (error) {
10194
+ if (!(error instanceof JourneyRemoteError) || error.status !== 400 || error.code !== "invalid_request" || input.agentSources === void 0) throw error;
10195
+ const { agentSources: _, ...withoutSources } = input;
10196
+ return reserve(withoutSources);
10197
+ }
10070
10198
  },
10071
10199
  complete(id, signal) {
10072
10200
  return request(`/me/work-bundles/uploads/${encodeURIComponent(id)}/complete`, receipt(id), signal, {}, "POST", void 0, completeTimeoutMs);
@@ -10219,6 +10347,8 @@ async function resolveItem(item, bindingId, connection, signal, snapshot = false
10219
10347
  resolution
10220
10348
  }, settings, null, snapshot);
10221
10349
  }
10350
+ const agentSources = await connection.checkAgentSources?.(item.artifact.agentSources, signal);
10351
+ signal.throwIfAborted();
10222
10352
  return {
10223
10353
  ...item,
10224
10354
  target,
@@ -10226,6 +10356,7 @@ async function resolveItem(item, bindingId, connection, signal, snapshot = false
10226
10356
  status: "uploading",
10227
10357
  error: null,
10228
10358
  reservation: {
10359
+ ...agentSources?.length ? { agentSources } : {},
10229
10360
  work,
10230
10361
  target,
10231
10362
  bundleId: item.artifact.bundleId,
@@ -12310,6 +12441,7 @@ function createJourneySender(dependencies, phases = 3) {
12310
12441
  if (!sameIds(input.confirmedWorkIds, snapshot.send.items.map((item) => item.workId)) || !sameIds(input.confirmedOmittedWorkIds, snapshot.send.omitted.map((item) => item.workId)) || input.scopeDigest !== snapshot.send.scopeDigest || snapshot.send.items.length === 0) throw new ApplicationError("CONFIRMATION_REQUIRED");
12311
12442
  if (snapshot.send.confirmedAt !== null) return saveSend(dependencies, snapshot, snapshot.send, input);
12312
12443
  const connection = await dependencies.auth.connect(signal);
12444
+ if (!connection && !dependencies.auth.configured) throw new ApplicationError("ACCOUNT_NOT_CONFIGURED");
12313
12445
  if (connection && snapshot.send.subject !== null && snapshot.send.subject !== connection.subject) throw new ApplicationError("IDENTITY_REJECTED");
12314
12446
  let profile = {
12315
12447
  status: "sign-in",
@@ -12484,33 +12616,36 @@ function createJourneySendAuth(account, requestFetch) {
12484
12616
  }
12485
12617
  return response;
12486
12618
  };
12487
- return { async connect(signal) {
12488
- let credential = await current();
12489
- if (!credential) return null;
12490
- let verified = await account.identity.readIdentity(credential.accessToken, signal);
12491
- if (!verified) {
12492
- await refuse(credential.accessToken);
12493
- credential = await current();
12619
+ return {
12620
+ configured: account.configuration.clientId !== null,
12621
+ async connect(signal) {
12622
+ let credential = await current();
12494
12623
  if (!credential) return null;
12495
- verified = await account.identity.readIdentity(credential.accessToken, signal);
12624
+ let verified = await account.identity.readIdentity(credential.accessToken, signal);
12496
12625
  if (!verified) {
12497
- await expire(credential.accessToken);
12498
- return null;
12626
+ await refuse(credential.accessToken);
12627
+ credential = await current();
12628
+ if (!credential) return null;
12629
+ verified = await account.identity.readIdentity(credential.accessToken, signal);
12630
+ if (!verified) {
12631
+ await expire(credential.accessToken);
12632
+ return null;
12633
+ }
12499
12634
  }
12635
+ if (verified.identityId !== credential.identityId) throw new ApplicationError("IDENTITY_REJECTED");
12636
+ return createJourneyOwnerClient({
12637
+ apiUrl: account.configuration.passportApiUrl,
12638
+ subject: verified.identityId,
12639
+ fetch: ownerFetch,
12640
+ async authorize() {
12641
+ const latest = await current();
12642
+ if (!latest) throw new ApplicationError("ACCOUNT_SIGNED_OUT");
12643
+ if (latest.identityId !== verified.identityId) throw new ApplicationError("IDENTITY_REJECTED");
12644
+ return latest.accessToken;
12645
+ }
12646
+ });
12500
12647
  }
12501
- if (verified.identityId !== credential.identityId) throw new ApplicationError("IDENTITY_REJECTED");
12502
- return createJourneyOwnerClient({
12503
- apiUrl: account.configuration.passportApiUrl,
12504
- subject: verified.identityId,
12505
- fetch: ownerFetch,
12506
- async authorize() {
12507
- const latest = await current();
12508
- if (!latest) throw new ApplicationError("ACCOUNT_SIGNED_OUT");
12509
- if (latest.identityId !== verified.identityId) throw new ApplicationError("IDENTITY_REJECTED");
12510
- return latest.accessToken;
12511
- }
12512
- });
12513
- } };
12648
+ };
12514
12649
  }
12515
12650
  //#endregion
12516
12651
  //#region apps/cli/src/operation/protocol.ts
@@ -12528,6 +12663,15 @@ const sourceExclusionReasonSchema = z.enum([
12528
12663
  ]);
12529
12664
  const identifier = z.string().regex(/^[A-Za-z0-9_-]{1,128}$/);
12530
12665
  const count = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
12666
+ const driftCountsSchema = z.object({
12667
+ "claude-row": count.optional(),
12668
+ "claude-block": count.optional(),
12669
+ "codex-row": count.optional(),
12670
+ "codex-event": count.optional(),
12671
+ "codex-item": count.optional(),
12672
+ "codex-extension": count.optional(),
12673
+ launch: count.optional()
12674
+ });
12531
12675
  const safeDiagnosticSchema = z.object({
12532
12676
  code: z.string().regex(/^[A-Z][A-Z0-9_]{0,79}$/),
12533
12677
  stage: z.string().regex(/^[a-z][a-z0-9.-]{0,63}$/).default("runtime"),
@@ -12537,6 +12681,7 @@ const safeDiagnosticSchema = z.object({
12537
12681
  at: z.string().datetime().max(64).optional(),
12538
12682
  reason: sourceExclusionReasonSchema.optional(),
12539
12683
  sourceId: z.string().regex(/^src[0-9]{1,12}$/).optional(),
12684
+ driftCounts: driftCountsSchema.optional(),
12540
12685
  counts: z.object({
12541
12686
  workspaces: count,
12542
12687
  sessions: count,
@@ -12604,6 +12749,7 @@ function projectSafeDiagnostic(value) {
12604
12749
  operationId: Reflect.get(value, "operationId"),
12605
12750
  at: Reflect.get(value, "at"),
12606
12751
  counts: Reflect.get(value, "counts"),
12752
+ driftCounts: Reflect.get(value, "driftCounts"),
12607
12753
  location: safeLocation,
12608
12754
  reason: Reflect.get(value, "reason"),
12609
12755
  sourceId: Reflect.get(value, "sourceId")
@@ -12618,11 +12764,22 @@ function createSafeProducerCallbacks(emit, record) {
12618
12764
  code: diagnostic.code,
12619
12765
  stage: diagnostic.stage,
12620
12766
  ...diagnostic.reason ? { reason: diagnostic.reason } : {},
12621
- ...diagnostic.sourceId ? { sourceId: diagnostic.sourceId } : {}
12767
+ ...diagnostic.sourceId ? { sourceId: diagnostic.sourceId } : {},
12768
+ ...diagnostic.driftCounts ? { driftCounts: diagnostic.driftCounts } : {}
12622
12769
  });
12623
12770
  emit(diagnostic);
12624
12771
  }
12625
12772
  function anomaly(stage, event) {
12773
+ if (event.code === "tolerated-harness-drift") {
12774
+ const counts = driftCountsSchema.safeParse(event.driftCounts);
12775
+ publish({
12776
+ code: "HARNESS_DRIFT_TOLERATED",
12777
+ ...counts.success ? { driftCounts: counts.data } : {},
12778
+ stage,
12779
+ .../^src[0-9]{1,12}$/.test(event.sourceId) ? { sourceId: event.sourceId } : {}
12780
+ });
12781
+ return;
12782
+ }
12626
12783
  const reason = sourceExclusionReasonSchema.safeParse(event.code);
12627
12784
  if (!reason.success) return;
12628
12785
  publish({
@@ -1,7 +1,7 @@
1
1
  import { tn as sessionSchema } from "./locate-U3-nkird.mjs";
2
2
  import { t as createZstdFrameCheck$1 } from "./frame-waS5FnN5.mjs";
3
- import "./src-B4R5XMEP.mjs";
4
- import { a as isRecord } from "./model-BBAnsFAx.mjs";
3
+ import "./src-DSDRF7i6.mjs";
4
+ import { a as isRecord } from "./model-BDrntocp.mjs";
5
5
  import { constants } from "node:fs";
6
6
  import { z } from "zod";
7
7
  import { lstat, open, stat } from "node:fs/promises";