githolon 0.110.0 → 0.111.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compile_mountability_entry.js +161 -127
- package/dist/dev-server.mjs +146 -123
- package/dist/full-cli.mjs +273 -144
- package/package.json +2 -2
package/dist/full-cli.mjs
CHANGED
|
@@ -20640,6 +20640,15 @@ var init_replica_follow_controller = __esm({
|
|
|
20640
20640
|
}
|
|
20641
20641
|
if (result.stillAhead || result.pushFailed || result.directOfferDeferred || result.reconnectRequired) {
|
|
20642
20642
|
if (result.directOfferDeferred) {
|
|
20643
|
+
if (!result.reconnectRequired) {
|
|
20644
|
+
this.#desk.transition(result.workspace, {
|
|
20645
|
+
case: ReplicaFollowEventKind.Failed,
|
|
20646
|
+
nowUnixMillis,
|
|
20647
|
+
failure: "remote workspace opening; retrying",
|
|
20648
|
+
retryWithinMillis: 5e3
|
|
20649
|
+
});
|
|
20650
|
+
return delayUntilDue(this.#desk.get(result.workspace), nowUnixMillis);
|
|
20651
|
+
}
|
|
20643
20652
|
this.#desk.transition(result.workspace, {
|
|
20644
20653
|
case: ReplicaFollowEventKind.DependencyDeferred,
|
|
20645
20654
|
nowUnixMillis,
|
|
@@ -22644,6 +22653,34 @@ var init_custody_replacement = __esm({
|
|
|
22644
22653
|
|
|
22645
22654
|
// ../peer-office/src/runtime/custody_offer.ts
|
|
22646
22655
|
import { create as create54, fromBinary as fromBinary19, toBinary as toBinary17 } from "@bufbuild/protobuf";
|
|
22656
|
+
function settleCustodyOfferExchange(awaiting, response) {
|
|
22657
|
+
if (response.status === 202 && response.contentType?.includes("application/json")) {
|
|
22658
|
+
try {
|
|
22659
|
+
const pending = JSON.parse(new TextDecoder().decode(response.body));
|
|
22660
|
+
if (pending?.retryable === true && typeof pending.preparing === "string") {
|
|
22661
|
+
return { case: "maintenance", kind: pending.preparing };
|
|
22662
|
+
}
|
|
22663
|
+
} catch {
|
|
22664
|
+
}
|
|
22665
|
+
}
|
|
22666
|
+
if (!response.contentType?.includes(CUSTODY_OFFER_RESULT_MEDIA_TYPE)) {
|
|
22667
|
+
return {
|
|
22668
|
+
case: "unexpected",
|
|
22669
|
+
status: response.status,
|
|
22670
|
+
...response.contentType === void 0 ? {} : { contentType: response.contentType }
|
|
22671
|
+
};
|
|
22672
|
+
}
|
|
22673
|
+
const verdict = decodeCustodyOffer(response.body, awaiting.requestId);
|
|
22674
|
+
const receipt = custodyOfferReceipt(awaiting.requestId, verdict);
|
|
22675
|
+
switch (verdict.case) {
|
|
22676
|
+
case "admission":
|
|
22677
|
+
return { case: "admission", value: verdict.value, receipt, status: response.status };
|
|
22678
|
+
case "failure":
|
|
22679
|
+
return { case: "failure", value: verdict.value, receipt, status: response.status };
|
|
22680
|
+
case "blocked":
|
|
22681
|
+
return { case: "blocked", value: verdict.value, receipt, status: response.status };
|
|
22682
|
+
}
|
|
22683
|
+
}
|
|
22647
22684
|
function encodeInlineCustodyOffer(args) {
|
|
22648
22685
|
return toBinary17(CustodyOfferBatchRequestSchema, create54(CustodyOfferBatchRequestSchema, {
|
|
22649
22686
|
protocolVersion: 2,
|
|
@@ -22781,7 +22818,7 @@ import { create as create55, fromBinary as fromBinary20 } from "@bufbuild/protob
|
|
|
22781
22818
|
function releaseSyncJudgment(workspace) {
|
|
22782
22819
|
judgedThisLifetime.delete(workspace);
|
|
22783
22820
|
}
|
|
22784
|
-
var PLACEMENT_REF3, LAW_PRODUCTS_MEDIA_TYPE, WorkspaceSyncPhase, trackedMain,
|
|
22821
|
+
var PLACEMENT_REF3, LAW_PRODUCTS_MEDIA_TYPE, WorkspaceSyncPhase, trackedMain, deferredRemote, deferredLocal, judgedThisLifetime, MAX_REBASES_PER_ROUND, elapsedMillis, WorkspaceSyncWork;
|
|
22785
22822
|
var init_workspace_sync = __esm({
|
|
22786
22823
|
"../peer-office/src/runtime/workspace_sync.ts"() {
|
|
22787
22824
|
"use strict";
|
|
@@ -22797,6 +22834,7 @@ var init_workspace_sync = __esm({
|
|
|
22797
22834
|
PLACEMENT_REF3 = "refs/nomos/placement";
|
|
22798
22835
|
LAW_PRODUCTS_MEDIA_TYPE = "application/vnd.nomos.export-law-products-response+protobuf";
|
|
22799
22836
|
WorkspaceSyncPhase = Object.freeze({
|
|
22837
|
+
Idle: "idle",
|
|
22800
22838
|
Probe: "probe",
|
|
22801
22839
|
Offer: "offer",
|
|
22802
22840
|
Lease: "lease",
|
|
@@ -22806,7 +22844,6 @@ var init_workspace_sync = __esm({
|
|
|
22806
22844
|
Done: "done"
|
|
22807
22845
|
});
|
|
22808
22846
|
trackedMain = "refs/remotes/nomos/main";
|
|
22809
|
-
NO_COMMON_BASE = "this replica holds local history with no frontier its upstream ever confirmed; convergence needs a common admitted base \u2014 drop the local copy to refetch it, or re-discover a provider holding this lineage";
|
|
22810
22847
|
deferredRemote = "refs/remotes/nomos/deferred";
|
|
22811
22848
|
deferredLocal = "refs/nomos/sync-deferred-local";
|
|
22812
22849
|
judgedThisLifetime = /* @__PURE__ */ new Map();
|
|
@@ -22827,7 +22864,6 @@ var init_workspace_sync = __esm({
|
|
|
22827
22864
|
#rediscover;
|
|
22828
22865
|
/** The route the directory's answer yields, recomputed once that answer is observed. */
|
|
22829
22866
|
#reroute;
|
|
22830
|
-
#placementFetch;
|
|
22831
22867
|
#discoveredFrontier;
|
|
22832
22868
|
#observePlacement;
|
|
22833
22869
|
/** Ask the directory for the provider's current placement frontier this round although a
|
|
@@ -22836,19 +22872,14 @@ var init_workspace_sync = __esm({
|
|
|
22836
22872
|
#directoryAnswered;
|
|
22837
22873
|
#placementFetched;
|
|
22838
22874
|
/** A round which converged without leasing, finishing once placement alone is fetched. */
|
|
22839
|
-
#afterPlacement;
|
|
22840
22875
|
#leased = false;
|
|
22841
|
-
#lease;
|
|
22842
22876
|
#command;
|
|
22843
22877
|
#requestId;
|
|
22844
22878
|
#started;
|
|
22845
|
-
#
|
|
22879
|
+
#state = { phase: WorkspaceSyncPhase.Idle };
|
|
22846
22880
|
#localHead;
|
|
22847
22881
|
#offerHead;
|
|
22848
22882
|
#previousHead;
|
|
22849
|
-
#fetchStarted;
|
|
22850
|
-
#offerStarted;
|
|
22851
|
-
#offerRequestId;
|
|
22852
22883
|
#pushMillis = 0;
|
|
22853
22884
|
#pushBytes = 0n;
|
|
22854
22885
|
#desiredHead;
|
|
@@ -22943,7 +22974,7 @@ var init_workspace_sync = __esm({
|
|
|
22943
22974
|
throw new Error(`replica '${this.#binding.replicaId}' has no custody remote`);
|
|
22944
22975
|
}
|
|
22945
22976
|
if (this.#rediscover || this.#recheckPlacement || !this.#route?.placementObserved && !this.#route?.placementFrontier && !this.#kernel.resolveRef(this.#mount, this.#requestId, PLACEMENT_REF3)) {
|
|
22946
|
-
this.#
|
|
22977
|
+
this.#state = { phase: WorkspaceSyncPhase.Discover };
|
|
22947
22978
|
return this.#remember({
|
|
22948
22979
|
case: "pending",
|
|
22949
22980
|
value: create55(CorrespondencePendingSchema, {
|
|
@@ -22963,13 +22994,13 @@ var init_workspace_sync = __esm({
|
|
|
22963
22994
|
#openRound() {
|
|
22964
22995
|
if (this.#receiveState || this.#replaceLocalHead !== void 0) return this.#leaseEffect();
|
|
22965
22996
|
if (!this.#localHead) return this.#leaseEffect();
|
|
22966
|
-
|
|
22997
|
+
const requestId = `${this.#binding.replicaId}:${this.#requestId}:${this.workId}:frontier`;
|
|
22967
22998
|
return this.#beginOffer(encodeInlineCustodyOffer({
|
|
22968
22999
|
session: this.#binding.replicaId,
|
|
22969
|
-
requestId
|
|
23000
|
+
requestId,
|
|
22970
23001
|
observedHead: this.#localHead,
|
|
22971
23002
|
intents: []
|
|
22972
|
-
}), true);
|
|
23003
|
+
}), { case: "awaiting", requestId }, true);
|
|
22973
23004
|
}
|
|
22974
23005
|
#offerOrReconcile() {
|
|
22975
23006
|
if (this.#command.admit && this.#localHead && this.#localHead !== this.#previousHead) {
|
|
@@ -22990,13 +23021,13 @@ var init_workspace_sync = __esm({
|
|
|
22990
23021
|
throw new Error(`kernel did not classify transport for intent '${unspecified.intentId}'`);
|
|
22991
23022
|
}
|
|
22992
23023
|
if (suffix.length > 0) {
|
|
22993
|
-
|
|
22994
|
-
|
|
23024
|
+
const requestId2 = `${this.#binding.replicaId}:${this.#requestId}:${this.workId}`;
|
|
23025
|
+
const startedAt = this.#clock.monotonicNanoseconds();
|
|
22995
23026
|
this.#offerAfterConverge = true;
|
|
22996
23027
|
this.#rebaseFrom = this.#previousHead;
|
|
22997
23028
|
return this.#beginOffer(encodeInlineCustodyOffer({
|
|
22998
23029
|
session: this.#binding.replicaId,
|
|
22999
|
-
requestId:
|
|
23030
|
+
requestId: requestId2,
|
|
23000
23031
|
...this.#previousHead === void 0 ? {} : { baseHead: this.#previousHead },
|
|
23001
23032
|
observedHead: this.#localHead,
|
|
23002
23033
|
intents: suffix,
|
|
@@ -23007,51 +23038,26 @@ var init_workspace_sync = __esm({
|
|
|
23007
23038
|
this.#previousHead
|
|
23008
23039
|
) : void 0,
|
|
23009
23040
|
fastForwardOnly: true
|
|
23010
|
-
}));
|
|
23041
|
+
}), { case: "awaiting", requestId: requestId2, startedAt });
|
|
23011
23042
|
}
|
|
23012
23043
|
}
|
|
23013
|
-
|
|
23044
|
+
const requestId = `${this.#binding.replicaId}:${this.#requestId}:${this.workId}:reconcile`;
|
|
23014
23045
|
return this.#beginOffer(encodeInlineCustodyOffer({
|
|
23015
23046
|
session: this.#binding.replicaId,
|
|
23016
|
-
requestId
|
|
23047
|
+
requestId,
|
|
23017
23048
|
baseHead: this.#previousHead,
|
|
23018
23049
|
observedHead: this.#localHead,
|
|
23019
23050
|
intents: []
|
|
23020
|
-
}));
|
|
23051
|
+
}), { case: "awaiting", requestId });
|
|
23021
23052
|
}
|
|
23022
23053
|
/**
|
|
23023
|
-
*
|
|
23024
|
-
*
|
|
23025
|
-
*
|
|
23026
|
-
*
|
|
23027
|
-
* state ("a non-empty live ledger requires a common admitted base"), so every step after the
|
|
23028
|
-
* O(1) frontier probe is wasted work — and it is not cheap waste: the fetch negotiates with
|
|
23029
|
-
* no `have` (a full-history pack), and the dependency planner decodes EVERY intent from
|
|
23030
|
-
* genesis and inspects every change, once per round. That is O(history) per follow round,
|
|
23031
|
-
* repeated at every retry, for a round that can only end in a refusal.
|
|
23032
|
-
*
|
|
23033
|
-
* The one base this round can establish costs nothing and is established before this is
|
|
23034
|
-
* asked: an upstream holding exactly this replica's head (the probe's answer) converges it
|
|
23035
|
-
* and records the tracking frontier. Anything else needs the local copy to be dropped and
|
|
23036
|
-
* refetched (an application decision, which preserves the copy), or a re-discovery that
|
|
23037
|
-
* names a provider holding this lineage. Both are reported, at O(1), as this failure.
|
|
23038
|
-
*/
|
|
23039
|
-
/**
|
|
23040
|
-
* Establish this round's base when none is tracked, without walking any history it can avoid.
|
|
23041
|
-
*
|
|
23042
|
-
* The upstream just named its own frontier. If that commit is in THIS replica's lineage, it is
|
|
23043
|
-
* a common admitted base by definition — both sides hold it — and adopting it turns the round
|
|
23044
|
-
* into an ordinary fast-forward: the offer carries only the suffix above it, the fetch can name
|
|
23045
|
-
* it as a truthful `have`, and convergence has the base the kernel requires. One commit walk
|
|
23046
|
-
* (no change decoding, no pack, no network) decides it.
|
|
23047
|
-
*
|
|
23048
|
-
* If it is not in this replica's lineage, no base exists to establish and the round is refused
|
|
23049
|
-
* (#noCommonBase) before it leases, fetches or plans anything.
|
|
23050
|
-
*
|
|
23051
|
-
* A kernel without the commit walk cannot be asked, so it keeps the previous behaviour.
|
|
23054
|
+
* Establish a cheap base when the provider's current tip is in our local chain.
|
|
23055
|
+
* A negative answer means the base is unknown: both sides may have advanced from
|
|
23056
|
+
* an earlier shared commit. Acquire the candidate and let the kernel discover
|
|
23057
|
+
* and judge that history. A tracking bookmark is not an admission prerequisite.
|
|
23052
23058
|
*/
|
|
23053
23059
|
#establishBase(upstreamHead) {
|
|
23054
|
-
if (!this.#
|
|
23060
|
+
if (!this.#missingTrackedBase() || !this.#kernel.historySummary) return true;
|
|
23055
23061
|
const summary = this.#kernel.historySummary(this.#mount, this.#requestId, upstreamHead, this.#localHead);
|
|
23056
23062
|
if (!summary.reachedBase) return false;
|
|
23057
23063
|
this.#previousHead = upstreamHead;
|
|
@@ -23066,26 +23072,9 @@ var init_workspace_sync = __esm({
|
|
|
23066
23072
|
get establishedBase() {
|
|
23067
23073
|
return this.#establishedBase;
|
|
23068
23074
|
}
|
|
23069
|
-
#
|
|
23075
|
+
#missingTrackedBase() {
|
|
23070
23076
|
return this.#previousHead === void 0 && this.#localHead !== void 0 && this.#replaceLocalHead === void 0;
|
|
23071
23077
|
}
|
|
23072
|
-
#noCommonBaseResult() {
|
|
23073
|
-
return this.#finish(create55(SyncWorkspaceResponseSchema, {
|
|
23074
|
-
workspace: this.#mount.workspace,
|
|
23075
|
-
...this.#localHead === void 0 ? {} : { currentHead: this.#localHead },
|
|
23076
|
-
stillAhead: true,
|
|
23077
|
-
...this.#offerReceipt === void 0 ? {} : { offerReceipt: this.#offerReceipt },
|
|
23078
|
-
pushError: create55(RuntimeTransportFailureSchema, {
|
|
23079
|
-
endpoint: this.#offerEndpoint(),
|
|
23080
|
-
status: 409,
|
|
23081
|
-
refused: true,
|
|
23082
|
-
message: NO_COMMON_BASE
|
|
23083
|
-
}),
|
|
23084
|
-
timings: create55(SyncPhaseTimingsSchema, {
|
|
23085
|
-
convergeMillis: elapsedMillis(this.#clock, this.#started)
|
|
23086
|
-
})
|
|
23087
|
-
}));
|
|
23088
|
-
}
|
|
23089
23078
|
#holdsLocalWork() {
|
|
23090
23079
|
return this.#command.admit && !!this.#localHead && this.#localHead !== this.#previousHead;
|
|
23091
23080
|
}
|
|
@@ -23093,18 +23082,18 @@ var init_workspace_sync = __esm({
|
|
|
23093
23082
|
#pullBeforeOffer() {
|
|
23094
23083
|
this.#offerAfterConverge = true;
|
|
23095
23084
|
this.#rebaseFrom = this.#previousHead;
|
|
23096
|
-
|
|
23085
|
+
const requestId = `${this.#binding.replicaId}:${this.#requestId}:${this.workId}:pull-${this.#rebases}`;
|
|
23097
23086
|
return this.#beginOffer(encodeInlineCustodyOffer({
|
|
23098
23087
|
session: this.#binding.replicaId,
|
|
23099
|
-
requestId
|
|
23088
|
+
requestId,
|
|
23100
23089
|
...this.#previousHead === void 0 ? {} : { baseHead: this.#previousHead },
|
|
23101
23090
|
observedHead: this.#localHead,
|
|
23102
23091
|
intents: []
|
|
23103
|
-
}));
|
|
23092
|
+
}), { case: "awaiting", requestId });
|
|
23104
23093
|
}
|
|
23105
|
-
#leaseEffect() {
|
|
23094
|
+
#leaseEffect(afterPlacement) {
|
|
23106
23095
|
const token = this.#authToken();
|
|
23107
|
-
this.#
|
|
23096
|
+
this.#state = { phase: WorkspaceSyncPhase.Lease, ...afterPlacement ? { afterPlacement } : {} };
|
|
23108
23097
|
return this.#remember({
|
|
23109
23098
|
case: "pending",
|
|
23110
23099
|
value: create55(CorrespondencePendingSchema, {
|
|
@@ -23133,35 +23122,38 @@ var init_workspace_sync = __esm({
|
|
|
23133
23122
|
`workspace sync '${this.workId}' expected effect '${expected}', received '${receipt.effectId}'`
|
|
23134
23123
|
);
|
|
23135
23124
|
}
|
|
23125
|
+
const state = this.#state;
|
|
23136
23126
|
const previousReceipt = this.#lastReceiptEffectId;
|
|
23137
23127
|
this.#lastReceiptEffectId = receipt.effectId;
|
|
23138
23128
|
try {
|
|
23139
23129
|
if (receipt.outcome.case === "failure") {
|
|
23140
|
-
if (
|
|
23130
|
+
if (state.phase === WorkspaceSyncPhase.Discover) return this.#openRound();
|
|
23141
23131
|
return this.#transportFailure(
|
|
23142
23132
|
receipt.outcome.value.message,
|
|
23143
23133
|
receipt.outcome.value.reason === PeerEffectFailureReason.OFFLINE
|
|
23144
23134
|
);
|
|
23145
23135
|
}
|
|
23146
|
-
if (
|
|
23147
|
-
|
|
23148
|
-
|
|
23149
|
-
if (
|
|
23150
|
-
|
|
23151
|
-
|
|
23136
|
+
if (state.phase === WorkspaceSyncPhase.Offer || state.phase === WorkspaceSyncPhase.Probe) {
|
|
23137
|
+
return this.#acceptOffer(receipt, state);
|
|
23138
|
+
}
|
|
23139
|
+
if (state.phase === WorkspaceSyncPhase.Lease) return this.#acceptLease(receipt, state);
|
|
23140
|
+
if (state.phase === WorkspaceSyncPhase.Discover) return this.#acceptDiscovery(receipt);
|
|
23141
|
+
if (state.phase === WorkspaceSyncPhase.Placement) {
|
|
23142
|
+
state.transfer.accept(receipt);
|
|
23152
23143
|
this.#placementFetched?.();
|
|
23153
|
-
if (
|
|
23154
|
-
return this.#beginMainFetch(
|
|
23144
|
+
if (state.afterPlacement) return this.#finish(state.afterPlacement);
|
|
23145
|
+
return this.#beginMainFetch(state.lease);
|
|
23155
23146
|
}
|
|
23156
|
-
if (
|
|
23147
|
+
if (state.phase === WorkspaceSyncPhase.Fetch) return this.#acceptFetch(receipt, state);
|
|
23157
23148
|
throw new Error(`workspace sync '${this.workId}' is already complete`);
|
|
23158
23149
|
} catch (error) {
|
|
23159
23150
|
this.#lastReceiptEffectId = previousReceipt;
|
|
23160
23151
|
throw error;
|
|
23161
23152
|
}
|
|
23162
23153
|
}
|
|
23163
|
-
#beginOffer(body, probe = false) {
|
|
23164
|
-
|
|
23154
|
+
#beginOffer(body, exchange, probe = false) {
|
|
23155
|
+
const phase = probe ? WorkspaceSyncPhase.Probe : WorkspaceSyncPhase.Offer;
|
|
23156
|
+
this.#state = { phase, exchange };
|
|
23165
23157
|
const token = this.#authToken();
|
|
23166
23158
|
this.#pushBytes += BigInt(body.byteLength);
|
|
23167
23159
|
return this.#remember({
|
|
@@ -23171,7 +23163,7 @@ var init_workspace_sync = __esm({
|
|
|
23171
23163
|
effect: {
|
|
23172
23164
|
case: "http",
|
|
23173
23165
|
value: create55(PeerHttpEffectSchema, {
|
|
23174
|
-
effectId: `${this.workId}:${
|
|
23166
|
+
effectId: `${this.workId}:${phase}`,
|
|
23175
23167
|
method: PeerHttpMethod.POST,
|
|
23176
23168
|
url: this.#offerEndpoint(),
|
|
23177
23169
|
contentType: CUSTODY_OFFER_MEDIA_TYPE,
|
|
@@ -23188,28 +23180,30 @@ var init_workspace_sync = __esm({
|
|
|
23188
23180
|
})
|
|
23189
23181
|
});
|
|
23190
23182
|
}
|
|
23191
|
-
#acceptOffer(receipt) {
|
|
23192
|
-
|
|
23183
|
+
#acceptOffer(receipt, state) {
|
|
23184
|
+
const exchange = state.exchange;
|
|
23185
|
+
this.#pushMillis = exchange.startedAt === void 0 ? 0 : elapsedMillis(this.#clock, exchange.startedAt);
|
|
23193
23186
|
if (receipt.outcome.case !== "response") {
|
|
23194
23187
|
throw new Error("platform returned the wrong receipt for a custody offer");
|
|
23195
23188
|
}
|
|
23196
|
-
const
|
|
23197
|
-
if (
|
|
23189
|
+
const outcome = settleCustodyOfferExchange(exchange, receipt.outcome.value);
|
|
23190
|
+
if (outcome.case === "maintenance") {
|
|
23191
|
+
return this.#finishOfferOutcome(true, false);
|
|
23192
|
+
}
|
|
23193
|
+
if (outcome.case === "unexpected") {
|
|
23198
23194
|
this.#pushError = create55(RuntimeTransportFailureSchema, {
|
|
23199
23195
|
endpoint: this.#offerEndpoint(),
|
|
23200
|
-
status:
|
|
23196
|
+
status: outcome.status,
|
|
23201
23197
|
refused: false,
|
|
23202
|
-
message: `Sync received an unexpected server response (HTTP ${
|
|
23198
|
+
message: `Sync received an unexpected server response (HTTP ${outcome.status}; ${outcome.contentType || "no content type"}). No custody receipt was returned.`
|
|
23203
23199
|
});
|
|
23204
23200
|
return this.#finishOfferOutcome(false);
|
|
23205
23201
|
}
|
|
23206
|
-
|
|
23207
|
-
const outcome = decodeCustodyOffer(response.body, this.#offerRequestId);
|
|
23208
|
-
this.#offerReceipt = custodyOfferReceipt(this.#offerRequestId, outcome);
|
|
23202
|
+
this.#offerReceipt = outcome.receipt;
|
|
23209
23203
|
if (outcome.case === "failure") {
|
|
23210
23204
|
this.#pushError = create55(RuntimeTransportFailureSchema, {
|
|
23211
23205
|
endpoint: this.#offerEndpoint(),
|
|
23212
|
-
status:
|
|
23206
|
+
status: outcome.status,
|
|
23213
23207
|
refused: false,
|
|
23214
23208
|
message: `${outcome.value.code}: ${outcome.value.message}`
|
|
23215
23209
|
});
|
|
@@ -23218,12 +23212,12 @@ var init_workspace_sync = __esm({
|
|
|
23218
23212
|
if (outcome.case === "blocked") {
|
|
23219
23213
|
return this.#finishOfferOutcome(true);
|
|
23220
23214
|
}
|
|
23221
|
-
if (
|
|
23215
|
+
if (outcome.status < 200 || outcome.status >= 300) {
|
|
23222
23216
|
this.#pushError = create55(RuntimeTransportFailureSchema, {
|
|
23223
23217
|
endpoint: this.#offerEndpoint(),
|
|
23224
|
-
status:
|
|
23225
|
-
refused:
|
|
23226
|
-
message: `custody offer returned an admission verdict with HTTP ${
|
|
23218
|
+
status: outcome.status,
|
|
23219
|
+
refused: outcome.status === 422,
|
|
23220
|
+
message: `custody offer returned an admission verdict with HTTP ${outcome.status}`
|
|
23227
23221
|
});
|
|
23228
23222
|
return this.#finishOfferOutcome(false);
|
|
23229
23223
|
}
|
|
@@ -23231,8 +23225,7 @@ var init_workspace_sync = __esm({
|
|
|
23231
23225
|
this.#desiredHead = admission.main || void 0;
|
|
23232
23226
|
if (!this.#desiredHead) return this.#transportFailure("resident peer returned no admitted frontier", false);
|
|
23233
23227
|
this.#candidateDurable = admission.sealedMain === this.#desiredHead;
|
|
23234
|
-
if (
|
|
23235
|
-
if (!this.#establishBase(this.#desiredHead)) return this.#noCommonBaseResult();
|
|
23228
|
+
if (state.phase === WorkspaceSyncPhase.Probe && this.#desiredHead !== this.#localHead) {
|
|
23236
23229
|
if (this.#alreadyJudged(this.#desiredHead)) {
|
|
23237
23230
|
return this.#finish(create55(SyncWorkspaceResponseSchema, {
|
|
23238
23231
|
workspace: this.#mount.workspace,
|
|
@@ -23244,6 +23237,22 @@ var init_workspace_sync = __esm({
|
|
|
23244
23237
|
offerReceipt: this.#offerReceipt
|
|
23245
23238
|
}));
|
|
23246
23239
|
}
|
|
23240
|
+
if (!this.#establishBase(this.#desiredHead)) {
|
|
23241
|
+
this.#offerAfterConverge = this.#command.admit;
|
|
23242
|
+
this.#rebaseFrom = void 0;
|
|
23243
|
+
return this.#leaseEffect();
|
|
23244
|
+
}
|
|
23245
|
+
if (this.#establishedBase && !this.#candidateDurable && this.#kernel.resolveRef(this.#mount, this.#requestId, trackedMain) === void 0) {
|
|
23246
|
+
return this.#finish(create55(SyncWorkspaceResponseSchema, {
|
|
23247
|
+
workspace: this.#mount.workspace,
|
|
23248
|
+
currentHead: this.#localHead,
|
|
23249
|
+
previousHead: this.#previousHead,
|
|
23250
|
+
stillAhead: true,
|
|
23251
|
+
directOfferDeferred: true,
|
|
23252
|
+
reconnectRequired: false,
|
|
23253
|
+
offerReceipt: this.#offerReceipt
|
|
23254
|
+
}));
|
|
23255
|
+
}
|
|
23247
23256
|
if (this.#probeOnly) {
|
|
23248
23257
|
this.#needsReconciliation = true;
|
|
23249
23258
|
return this.#finish(create55(SyncWorkspaceResponseSchema, {
|
|
@@ -23289,11 +23298,11 @@ var init_workspace_sync = __esm({
|
|
|
23289
23298
|
return this.#converge(this.#desiredHead, admission.resultPack.byteLength, 0);
|
|
23290
23299
|
}
|
|
23291
23300
|
if (this.#desiredHead === this.#previousHead) return this.#converge(this.#desiredHead, 0, 0);
|
|
23292
|
-
|
|
23301
|
+
this.#establishBase(this.#desiredHead);
|
|
23293
23302
|
if (admission.recoveryRequired !== false) return this.#leaseEffect();
|
|
23294
23303
|
return this.#transportFailure("resident peer supplied neither the missing delta nor a history gap", false);
|
|
23295
23304
|
}
|
|
23296
|
-
#acceptLease(receipt) {
|
|
23305
|
+
#acceptLease(receipt, state) {
|
|
23297
23306
|
if (receipt.outcome.case !== "response") {
|
|
23298
23307
|
throw new Error("platform returned the wrong receipt for a Git read lease");
|
|
23299
23308
|
}
|
|
@@ -23309,21 +23318,25 @@ var init_workspace_sync = __esm({
|
|
|
23309
23318
|
this.#leased = true;
|
|
23310
23319
|
const frontier = this.#placementFrontier();
|
|
23311
23320
|
if (frontier) {
|
|
23312
|
-
|
|
23321
|
+
const transfer = new PlacementFetch(
|
|
23313
23322
|
this.#kernel,
|
|
23314
23323
|
this.#mount,
|
|
23315
23324
|
this.#requestId,
|
|
23316
23325
|
this.workId,
|
|
23317
23326
|
frontier
|
|
23318
23327
|
);
|
|
23319
|
-
const pending =
|
|
23328
|
+
const pending = transfer.start(lease);
|
|
23320
23329
|
if (pending) {
|
|
23321
|
-
this.#
|
|
23322
|
-
|
|
23330
|
+
this.#state = {
|
|
23331
|
+
phase: WorkspaceSyncPhase.Placement,
|
|
23332
|
+
transfer,
|
|
23333
|
+
lease,
|
|
23334
|
+
...state.afterPlacement ? { afterPlacement: state.afterPlacement } : {}
|
|
23335
|
+
};
|
|
23323
23336
|
return this.#remember({ case: "pending", value: pending });
|
|
23324
23337
|
}
|
|
23325
23338
|
}
|
|
23326
|
-
if (
|
|
23339
|
+
if (state.afterPlacement) return this.#finish(state.afterPlacement);
|
|
23327
23340
|
return this.#beginMainFetch(lease);
|
|
23328
23341
|
}
|
|
23329
23342
|
/** The provider's placement frontier as this round knows it: what the directory named in this
|
|
@@ -23343,8 +23356,7 @@ var init_workspace_sync = __esm({
|
|
|
23343
23356
|
if (!new PlacementFetch(this.#kernel, this.#mount, this.#requestId, this.workId, frontier).wanted()) {
|
|
23344
23357
|
return void 0;
|
|
23345
23358
|
}
|
|
23346
|
-
this.#
|
|
23347
|
-
return this.#leaseEffect();
|
|
23359
|
+
return this.#leaseEffect(presented);
|
|
23348
23360
|
}
|
|
23349
23361
|
#acceptDiscovery(receipt) {
|
|
23350
23362
|
this.#directoryAnswered?.();
|
|
@@ -23368,9 +23380,11 @@ var init_workspace_sync = __esm({
|
|
|
23368
23380
|
return this.#replaceLocalHead !== void 0 || this.#localHead === void 0 && this.#previousHead === void 0;
|
|
23369
23381
|
}
|
|
23370
23382
|
#beginMainFetch(lease) {
|
|
23371
|
-
this.#phase = WorkspaceSyncPhase.Fetch;
|
|
23372
23383
|
const lawProducts = this.#lawProductsAlongside();
|
|
23373
|
-
this.#
|
|
23384
|
+
this.#state = {
|
|
23385
|
+
phase: WorkspaceSyncPhase.Fetch,
|
|
23386
|
+
startedAt: this.#clock.monotonicNanoseconds()
|
|
23387
|
+
};
|
|
23374
23388
|
const haves = this.#replaceLocalHead !== void 0 ? this.#repairMissingCommit ? [] : [this.#kernel.resolveRef(this.#mount, this.#requestId, deferredRemote)].filter(
|
|
23375
23389
|
(head) => !!head
|
|
23376
23390
|
) : [...new Set([
|
|
@@ -23401,7 +23415,7 @@ var init_workspace_sync = __esm({
|
|
|
23401
23415
|
})
|
|
23402
23416
|
});
|
|
23403
23417
|
}
|
|
23404
|
-
#acceptFetch(receipt) {
|
|
23418
|
+
#acceptFetch(receipt, state) {
|
|
23405
23419
|
if (receipt.outcome.case !== "gitFetch") {
|
|
23406
23420
|
throw new Error("platform returned the wrong receipt for a Git object fetch");
|
|
23407
23421
|
}
|
|
@@ -23411,7 +23425,7 @@ var init_workspace_sync = __esm({
|
|
|
23411
23425
|
if (fetched.pack.byteLength > 0) {
|
|
23412
23426
|
this.#kernel.applyPack(this.#mount, this.#requestId, fetched.pack, fetched.head, fetched.shallow);
|
|
23413
23427
|
}
|
|
23414
|
-
const prefetchMillis =
|
|
23428
|
+
const prefetchMillis = elapsedMillis(this.#clock, state.startedAt);
|
|
23415
23429
|
const candidateHead = this.#receiveState ? this.#kernel.resolveStatePosition?.(this.#mount, this.#requestId, fetched.head, this.#receiveState) : fetched.head;
|
|
23416
23430
|
if (!candidateHead) {
|
|
23417
23431
|
return this.#finish(create55(SyncWorkspaceResponseSchema, {
|
|
@@ -23507,7 +23521,7 @@ var init_workspace_sync = __esm({
|
|
|
23507
23521
|
}
|
|
23508
23522
|
}
|
|
23509
23523
|
#converge(candidateHead, receivedBytes, prefetchMillis) {
|
|
23510
|
-
|
|
23524
|
+
this.#establishBase(candidateHead);
|
|
23511
23525
|
this.#beforeConverge?.(candidateHead, this.#previousHead);
|
|
23512
23526
|
const convergeStarted = this.#clock.monotonicNanoseconds();
|
|
23513
23527
|
let judged;
|
|
@@ -23762,11 +23776,11 @@ var init_workspace_sync = __esm({
|
|
|
23762
23776
|
pushBytes: this.#pushBytes,
|
|
23763
23777
|
pullBytes: BigInt(receivedBytes),
|
|
23764
23778
|
serverMillis: this.#admissionSummary?.serverMillis ?? 0,
|
|
23765
|
-
offerInPush: this.#
|
|
23779
|
+
offerInPush: this.#pushBytes > 0n
|
|
23766
23780
|
})
|
|
23767
23781
|
});
|
|
23768
23782
|
}
|
|
23769
|
-
#finishOfferOutcome(blocked) {
|
|
23783
|
+
#finishOfferOutcome(blocked, reconnectRequired = true) {
|
|
23770
23784
|
return this.#finish(create55(SyncWorkspaceResponseSchema, {
|
|
23771
23785
|
workspace: this.#mount.workspace,
|
|
23772
23786
|
previousHead: this.#previousHead,
|
|
@@ -23774,7 +23788,7 @@ var init_workspace_sync = __esm({
|
|
|
23774
23788
|
admitted: BigInt(this.#admissionSummary?.admittedIntentIds.length ?? 0),
|
|
23775
23789
|
refused: BigInt((this.#admissionSummary?.refusedMessages.length ?? 0) + this.#parkedLocal),
|
|
23776
23790
|
deferred: BigInt(this.#admissionSummary ? this.#admissionSummary.blockedMessages.length + this.#admissionSummary.deadLetteredMessages.length + this.#admissionSummary.quarantinedMessages.length + this.#admissionSummary.deferredMessages.length : blocked ? 1 : 0),
|
|
23777
|
-
reconnectRequired
|
|
23791
|
+
reconnectRequired,
|
|
23778
23792
|
stillAhead: this.#localHead !== this.#previousHead,
|
|
23779
23793
|
directOfferDeferred: blocked,
|
|
23780
23794
|
offerReceipt: this.#offerReceipt,
|
|
@@ -23788,15 +23802,16 @@ var init_workspace_sync = __esm({
|
|
|
23788
23802
|
}));
|
|
23789
23803
|
}
|
|
23790
23804
|
#transportFailure(message, offline, status2 = -1) {
|
|
23791
|
-
const
|
|
23805
|
+
const state = this.#state;
|
|
23806
|
+
const pushFailed = state.phase === WorkspaceSyncPhase.Offer;
|
|
23792
23807
|
const failedEndpoint = this.#offerEndpoint();
|
|
23793
23808
|
const failure = create55(RuntimeTransportFailureSchema, {
|
|
23794
23809
|
endpoint: pushFailed ? failedEndpoint : this.#binding.cloud ?? "",
|
|
23795
23810
|
status: status2,
|
|
23796
23811
|
message
|
|
23797
23812
|
});
|
|
23798
|
-
if (
|
|
23799
|
-
this.#pushMillis =
|
|
23813
|
+
if (state.phase === WorkspaceSyncPhase.Offer) {
|
|
23814
|
+
this.#pushMillis = state.exchange.startedAt === void 0 ? 0 : elapsedMillis(this.#clock, state.exchange.startedAt);
|
|
23800
23815
|
this.#pushError = failure;
|
|
23801
23816
|
}
|
|
23802
23817
|
return this.#finish(create55(SyncWorkspaceResponseSchema, {
|
|
@@ -23813,7 +23828,7 @@ var init_workspace_sync = __esm({
|
|
|
23813
23828
|
pushMillis: this.#pushMillis,
|
|
23814
23829
|
pushBytes: this.#pushBytes,
|
|
23815
23830
|
prefetchMillis: elapsedMillis(this.#clock, this.#started),
|
|
23816
|
-
offerInPush: this.#
|
|
23831
|
+
offerInPush: this.#pushBytes > 0n
|
|
23817
23832
|
})
|
|
23818
23833
|
}));
|
|
23819
23834
|
}
|
|
@@ -23823,7 +23838,7 @@ var init_workspace_sync = __esm({
|
|
|
23823
23838
|
return step;
|
|
23824
23839
|
}
|
|
23825
23840
|
#finish(value) {
|
|
23826
|
-
this.#
|
|
23841
|
+
this.#state = { phase: WorkspaceSyncPhase.Done };
|
|
23827
23842
|
this.#current = void 0;
|
|
23828
23843
|
return this.#remember({ case: "synced", value });
|
|
23829
23844
|
}
|
|
@@ -26040,13 +26055,21 @@ var init_correspondence_desk = __esm({
|
|
|
26040
26055
|
}
|
|
26041
26056
|
#observeSyncResult(requestId, workId2, result) {
|
|
26042
26057
|
const timings = result.timings;
|
|
26058
|
+
const receipt = result.offerReceipt?.outcome;
|
|
26059
|
+
const admission = receipt?.case === "admission" ? receipt.value : void 0;
|
|
26043
26060
|
this.#events.instant("peer.follow.sync-result", {
|
|
26044
26061
|
request: create60(RuntimeRequestSchema, { protocolVersion: 2, requestId }),
|
|
26045
26062
|
workspace: result.workspace
|
|
26046
26063
|
}, {
|
|
26047
26064
|
"sync.workId": workId2,
|
|
26048
26065
|
...result.currentHead ? { "sync.head": result.currentHead } : {},
|
|
26066
|
+
...result.previousHead ? { "sync.previousHead": result.previousHead } : {},
|
|
26067
|
+
...admission?.main ? { "sync.providerHead": admission.main } : {},
|
|
26068
|
+
...admission?.sealedMain ? { "sync.sealedHead": admission.sealedMain } : {},
|
|
26049
26069
|
"sync.stillAhead": result.stillAhead,
|
|
26070
|
+
"sync.reconnectRequired": result.reconnectRequired,
|
|
26071
|
+
"sync.refused": result.refused,
|
|
26072
|
+
"sync.deferred": result.deferred,
|
|
26050
26073
|
"sync.directOfferDeferred": result.directOfferDeferred,
|
|
26051
26074
|
"sync.offline": result.offline,
|
|
26052
26075
|
...timings ? {
|
|
@@ -32348,8 +32371,19 @@ async function ensureApplicationWorkspace(application, opts = {}) {
|
|
|
32348
32371
|
}
|
|
32349
32372
|
const statusUrl = `${cloud}/v2/workspaces/${encodeURIComponent(application)}`;
|
|
32350
32373
|
const current = await fetch(statusUrl).catch(() => null);
|
|
32351
|
-
|
|
32352
|
-
|
|
32374
|
+
const status2 = current?.ok ? await current.json().catch(() => null) : null;
|
|
32375
|
+
let unborn = false;
|
|
32376
|
+
if (current?.ok && !status2?.lineage && !status2?.durableHead && !status2?.sealedHead) {
|
|
32377
|
+
const domains2 = await fetch(`${statusUrl}/domains`);
|
|
32378
|
+
if (domains2.status === 409) {
|
|
32379
|
+
const body2 = await domains2.json().catch(() => null);
|
|
32380
|
+
unborn = typeof body2?.error === "string" && body2.error.includes("unborn");
|
|
32381
|
+
}
|
|
32382
|
+
if (!unborn && !domains2.ok) {
|
|
32383
|
+
throw new Error(`could not establish whether application '${application}' has custody (${domains2.status})`);
|
|
32384
|
+
}
|
|
32385
|
+
}
|
|
32386
|
+
if (current?.ok && !unborn) {
|
|
32353
32387
|
const principal = String(status2?.lineage?.principal ?? "");
|
|
32354
32388
|
const actualParent = String(status2?.lineage?.parent ?? "");
|
|
32355
32389
|
const expectedParent = requestedParent === "root" ? "" : requestedParent;
|
|
@@ -32385,7 +32419,7 @@ async function ensureApplicationWorkspace(application, opts = {}) {
|
|
|
32385
32419
|
...principal !== "" && session !== "" && sameIdentity(principal, session) ? { deployPrincipal: principal } : {}
|
|
32386
32420
|
};
|
|
32387
32421
|
}
|
|
32388
|
-
if (current !== null && current.status !== 404 && current.status !== 409) {
|
|
32422
|
+
if (current !== null && !unborn && current.status !== 404 && current.status !== 409) {
|
|
32389
32423
|
throw new Error(`could not inspect deploy target '${application}' (${current.status}); refusing to guess that it is unborn`);
|
|
32390
32424
|
}
|
|
32391
32425
|
if (requestedParent !== void 0) {
|
|
@@ -34265,6 +34299,7 @@ var init_commands = __esm({
|
|
|
34265
34299
|
"test",
|
|
34266
34300
|
"doctor",
|
|
34267
34301
|
"cloud",
|
|
34302
|
+
"console",
|
|
34268
34303
|
"status",
|
|
34269
34304
|
"model",
|
|
34270
34305
|
"platform",
|
|
@@ -34315,6 +34350,19 @@ var init_help = __esm({
|
|
|
34315
34350
|
"use strict";
|
|
34316
34351
|
init_commands();
|
|
34317
34352
|
HELP = {
|
|
34353
|
+
console: {
|
|
34354
|
+
usage: "githolon console <login|logout|workspaces|universe|rollouts>",
|
|
34355
|
+
what: "Use a downloaded console API credential. The browser and CLI use the same console API.\nCredentials are stored locally with owner-only permissions; tokens are never printed.",
|
|
34356
|
+
flags: [
|
|
34357
|
+
["login --file <credential.json>", "verify and save a downloaded credential"],
|
|
34358
|
+
["logout", "remove the local credential; revoke other copies in the console"],
|
|
34359
|
+
["workspaces | universe", "read registered workspaces or their live subtree as JSON"],
|
|
34360
|
+
["rollouts [show <id>]", "list runs or inspect one"],
|
|
34361
|
+
["rollouts start --file <request.json>", "submit {payload:{kind:law,source:workspace},only:[workspace]} (JSON strings quoted)"],
|
|
34362
|
+
["rollouts resume <id>", "retry an existing law rollout"]
|
|
34363
|
+
],
|
|
34364
|
+
examples: ["githolon console login --file nomos-console-example.json", "githolon console workspaces"]
|
|
34365
|
+
},
|
|
34318
34366
|
compile: {
|
|
34319
34367
|
usage: "githolon compile [config] [--require-usdcat]",
|
|
34320
34368
|
what: "Compile typed authoring input into canonical OpenUSD. nomos.project.ts emits the readable law\nclosure, its .law.usdz transport archive, and generated clients; nomos.application.ts emits the application\ncomposition stage. TypeScript is authoring input only: the kernel admits and custodies USD.",
|
|
@@ -34646,6 +34694,84 @@ var init_help = __esm({
|
|
|
34646
34694
|
}
|
|
34647
34695
|
});
|
|
34648
34696
|
|
|
34697
|
+
// src/console.ts
|
|
34698
|
+
var console_exports = {};
|
|
34699
|
+
__export(console_exports, {
|
|
34700
|
+
consoleCommand: () => consoleCommand,
|
|
34701
|
+
consoleCredential: () => consoleCredential,
|
|
34702
|
+
consoleRequest: () => consoleRequest
|
|
34703
|
+
});
|
|
34704
|
+
import { URL as URL2 } from "node:url";
|
|
34705
|
+
import { chmodSync as chmodSync3, mkdirSync as mkdirSync10, readFileSync as readFileSync11, renameSync as renameSync4, rmSync as rmSync5, writeFileSync as writeFileSync11 } from "node:fs";
|
|
34706
|
+
import { join as join15 } from "node:path";
|
|
34707
|
+
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
34708
|
+
function consoleCredential(value) {
|
|
34709
|
+
if (!value || typeof value !== "object") throw new Error("Invalid console credential file");
|
|
34710
|
+
const v = value;
|
|
34711
|
+
if (v.format !== "nomos-console-credential-v1" || typeof v.endpoint !== "string" || typeof v.tenant !== "string" || typeof v.token !== "string") throw new Error("Invalid console credential file");
|
|
34712
|
+
const endpoint = new URL2(v.endpoint);
|
|
34713
|
+
if (endpoint.protocol !== "https:" || endpoint.username || endpoint.password || endpoint.pathname !== "/" || endpoint.search || endpoint.hash) throw new Error("Console endpoint must be an HTTPS origin");
|
|
34714
|
+
const token = /^nomos_api\.([a-z][a-z0-9-]{1,62})\.[a-f0-9]{32}\.[A-Za-z0-9_-]{43}$/.exec(v.token);
|
|
34715
|
+
if (!token || token[1] !== v.tenant) throw new Error("Credential does not match its workspace account");
|
|
34716
|
+
return { format: v.format, endpoint: endpoint.origin, tenant: v.tenant, token: v.token };
|
|
34717
|
+
}
|
|
34718
|
+
async function consoleRequest(profile, path4, method = "GET", body, fetcher = fetch) {
|
|
34719
|
+
const response = await fetcher(profile.endpoint + path4, {
|
|
34720
|
+
method,
|
|
34721
|
+
redirect: "error",
|
|
34722
|
+
signal: AbortSignal.timeout(12e4),
|
|
34723
|
+
headers: { authorization: `Bearer ${profile.token}`, "content-type": "application/json" },
|
|
34724
|
+
...body !== void 0 ? { body: JSON.stringify(body) } : {}
|
|
34725
|
+
});
|
|
34726
|
+
const result = await response.json();
|
|
34727
|
+
if (!response.ok) throw new Error(`Console ${response.status}: ${result.error ?? "request refused"}`);
|
|
34728
|
+
return result;
|
|
34729
|
+
}
|
|
34730
|
+
async function consoleCommand(args) {
|
|
34731
|
+
const file = join15(configDir(), "console.json");
|
|
34732
|
+
if (args[0] === "login" && args.length === 3 && args[1] === "--file") {
|
|
34733
|
+
const profile2 = consoleCredential(JSON.parse(readFileSync11(args[2], "utf8")));
|
|
34734
|
+
await consoleRequest(profile2, `/v1/tenants/${profile2.tenant}/workspaces`);
|
|
34735
|
+
mkdirSync10(configDir(), { recursive: true });
|
|
34736
|
+
const temporary = `${file}.${randomUUID4()}.tmp`;
|
|
34737
|
+
try {
|
|
34738
|
+
writeFileSync11(temporary, JSON.stringify(profile2) + "\n", { mode: 384, flag: "wx" });
|
|
34739
|
+
renameSync4(temporary, file);
|
|
34740
|
+
chmodSync3(file, 384);
|
|
34741
|
+
} finally {
|
|
34742
|
+
rmSync5(temporary, { force: true });
|
|
34743
|
+
}
|
|
34744
|
+
console.log(`Console credential saved for ${profile2.tenant} at ${profile2.endpoint}`);
|
|
34745
|
+
return 0;
|
|
34746
|
+
}
|
|
34747
|
+
if (args[0] === "logout" && args.length === 1) {
|
|
34748
|
+
rmSync5(file, { force: true });
|
|
34749
|
+
console.log("Local console credential removed. Revoke the key in the console to disable other copies.");
|
|
34750
|
+
return 0;
|
|
34751
|
+
}
|
|
34752
|
+
const profile = consoleCredential(JSON.parse(readFileSync11(file, "utf8")));
|
|
34753
|
+
const root = `/v1/tenants/${encodeURIComponent(profile.tenant)}`;
|
|
34754
|
+
let result;
|
|
34755
|
+
if (args[0] === "workspaces" && args.length === 1) result = await consoleRequest(profile, `${root}/workspaces`);
|
|
34756
|
+
else if (args[0] === "universe" && args.length === 1) result = await consoleRequest(profile, "/v1/universe");
|
|
34757
|
+
else if (args[0] === "rollouts" && args.length === 1) result = await consoleRequest(profile, `${root}/rollouts`);
|
|
34758
|
+
else if (args[0] === "rollouts" && args[1] === "show" && args.length === 3) result = await consoleRequest(profile, `${root}/rollouts/${encodeURIComponent(args[2])}`);
|
|
34759
|
+
else if (args[0] === "rollouts" && args[1] === "resume" && args.length === 3) result = await consoleRequest(profile, `${root}/rollouts/${encodeURIComponent(args[2])}/resume`, "POST", {});
|
|
34760
|
+
else if (args[0] === "rollouts" && args[1] === "start" && args[2] === "--file" && args.length === 4) {
|
|
34761
|
+
const input = JSON.parse(readFileSync11(args[3], "utf8"));
|
|
34762
|
+
if (input?.payload?.kind !== "law") throw new Error("Console CLI supports law rollouts only");
|
|
34763
|
+
result = await consoleRequest(profile, `${root}/rollouts`, "POST", input);
|
|
34764
|
+
} else throw new Error("See githolon console --help for supported commands");
|
|
34765
|
+
console.log(JSON.stringify(result, null, 2));
|
|
34766
|
+
return 0;
|
|
34767
|
+
}
|
|
34768
|
+
var init_console = __esm({
|
|
34769
|
+
"src/console.ts"() {
|
|
34770
|
+
"use strict";
|
|
34771
|
+
init_cloud();
|
|
34772
|
+
}
|
|
34773
|
+
});
|
|
34774
|
+
|
|
34649
34775
|
// src/mcp.ts
|
|
34650
34776
|
var mcp_exports = {};
|
|
34651
34777
|
__export(mcp_exports, {
|
|
@@ -35576,7 +35702,7 @@ var init_law_command_projection = __esm({
|
|
|
35576
35702
|
});
|
|
35577
35703
|
|
|
35578
35704
|
// src/law_encoder.ts
|
|
35579
|
-
import { readFileSync as
|
|
35705
|
+
import { readFileSync as readFileSync12 } from "node:fs";
|
|
35580
35706
|
async function loadInstalledLaw(input) {
|
|
35581
35707
|
const file = discoverLawUsdz(input.cwd ?? process.cwd(), input.file);
|
|
35582
35708
|
const inspected = await inspectLawArchive(input.cloud, file);
|
|
@@ -35588,7 +35714,7 @@ async function loadInstalledLaw(input) {
|
|
|
35588
35714
|
);
|
|
35589
35715
|
}
|
|
35590
35716
|
const projection = parseLawCommandProjection(
|
|
35591
|
-
readLawClosureAsset(new Uint8Array(
|
|
35717
|
+
readLawClosureAsset(new Uint8Array(readFileSync12(file)), COMMAND_PROJECTION)
|
|
35592
35718
|
);
|
|
35593
35719
|
return { identity: inspected.identity, servedDomains: served, projection, file };
|
|
35594
35720
|
}
|
|
@@ -36074,8 +36200,8 @@ __export(platform_exports, {
|
|
|
36074
36200
|
storeSeatDevice: () => storeSeatDevice
|
|
36075
36201
|
});
|
|
36076
36202
|
import { createHash as createHash6 } from "node:crypto";
|
|
36077
|
-
import { existsSync as existsSync14, mkdirSync as
|
|
36078
|
-
import { join as
|
|
36203
|
+
import { existsSync as existsSync14, mkdirSync as mkdirSync11, readFileSync as readFileSync13, writeFileSync as writeFileSync12 } from "node:fs";
|
|
36204
|
+
import { join as join17 } from "node:path";
|
|
36079
36205
|
function refuse(message) {
|
|
36080
36206
|
throw new PlatformRefusal(message);
|
|
36081
36207
|
}
|
|
@@ -36149,7 +36275,7 @@ async function readModelAuthority(cloud, platform, seatedAt) {
|
|
|
36149
36275
|
function loadSeatDevice(workspace) {
|
|
36150
36276
|
const path4 = seatDevicePath(workspace);
|
|
36151
36277
|
if (!existsSync14(path4)) return void 0;
|
|
36152
|
-
const stored = JSON.parse(
|
|
36278
|
+
const stored = JSON.parse(readFileSync13(path4, "utf8"));
|
|
36153
36279
|
const publicKey = stored.publicKey ?? (stored.publicKeyHex === void 0 ? void 0 : Buffer.from(stored.publicKeyHex, "hex").toString("base64"));
|
|
36154
36280
|
if (typeof stored.secret !== "string" || publicKey === void 0 || typeof stored.keyHash !== "string") {
|
|
36155
36281
|
refuse(`${path4} is not a stored device key {secret, publicKey, keyHash}`);
|
|
@@ -36158,8 +36284,8 @@ function loadSeatDevice(workspace) {
|
|
|
36158
36284
|
}
|
|
36159
36285
|
function storeSeatDevice(workspace, device) {
|
|
36160
36286
|
const path4 = seatDevicePath(workspace);
|
|
36161
|
-
|
|
36162
|
-
|
|
36287
|
+
mkdirSync11(join17(path4, ".."), { recursive: true });
|
|
36288
|
+
writeFileSync12(path4, JSON.stringify(device, null, 2) + "\n", { mode: 384 });
|
|
36163
36289
|
}
|
|
36164
36290
|
async function mintSeatDevice(cloud) {
|
|
36165
36291
|
const generated = await generateDeviceKey(cloud);
|
|
@@ -36382,7 +36508,7 @@ async function platformAuthor(workspace, directiveId, opts) {
|
|
|
36382
36508
|
}
|
|
36383
36509
|
}
|
|
36384
36510
|
function readPayload(opts) {
|
|
36385
|
-
const raw = opts.payloadFile !== void 0 ?
|
|
36511
|
+
const raw = opts.payloadFile !== void 0 ? readFileSync13(opts.payloadFile, "utf8") : opts.payload;
|
|
36386
36512
|
if (raw === void 0 || raw.trim() === "") refuse("author needs --payload <json> or --payload-file <file>");
|
|
36387
36513
|
let parsed;
|
|
36388
36514
|
try {
|
|
@@ -36594,7 +36720,7 @@ var init_platform = __esm({
|
|
|
36594
36720
|
PlatformRefusal = class extends Error {
|
|
36595
36721
|
};
|
|
36596
36722
|
ws = (name) => encodeURIComponent(name);
|
|
36597
|
-
seatDevicePath = (workspace) =>
|
|
36723
|
+
seatDevicePath = (workspace) => join17(configDir(), `seat-device-${workspace}.json`);
|
|
36598
36724
|
SEAT_CONVERGENCE_MILLIS = 18e4;
|
|
36599
36725
|
}
|
|
36600
36726
|
});
|
|
@@ -36660,8 +36786,8 @@ var init_dlq = __esm({
|
|
|
36660
36786
|
|
|
36661
36787
|
// src/custodian.ts
|
|
36662
36788
|
import { createHash as createHash7, createPrivateKey as createPrivateKey2, createPublicKey as createPublicKey2 } from "node:crypto";
|
|
36663
|
-
import { existsSync as existsSync15, readFileSync as
|
|
36664
|
-
import { dirname as dirname5, isAbsolute as isAbsolute3, join as
|
|
36789
|
+
import { existsSync as existsSync15, readFileSync as readFileSync14 } from "node:fs";
|
|
36790
|
+
import { dirname as dirname5, isAbsolute as isAbsolute3, join as join18, resolve as resolve6 } from "node:path";
|
|
36665
36791
|
import { fileURLToPath as fileURLToPath3, pathToFileURL as pathToFileURL3 } from "node:url";
|
|
36666
36792
|
import { create as create80 } from "@bufbuild/protobuf";
|
|
36667
36793
|
import { AnySchema as AnySchema3 } from "@bufbuild/protobuf/wkt";
|
|
@@ -36709,7 +36835,7 @@ async function resolveCustodianCredential(reference) {
|
|
|
36709
36835
|
}
|
|
36710
36836
|
if (scheme === "file") {
|
|
36711
36837
|
if (rest === "" || !existsSync15(rest)) throw new Error(`--custodian-key file:<path> \u2014 no file at '${rest}'`);
|
|
36712
|
-
return fromSeed(custodianSeedFromText(
|
|
36838
|
+
return fromSeed(custodianSeedFromText(readFileSync14(rest, "utf8"), rest), `file:${rest}`);
|
|
36713
36839
|
}
|
|
36714
36840
|
if (scheme === "env") {
|
|
36715
36841
|
const value = process.env[rest];
|
|
@@ -36736,7 +36862,7 @@ async function resolveCustodianCredential(reference) {
|
|
|
36736
36862
|
function readCustodianChain(file) {
|
|
36737
36863
|
if (file === void 0) return [];
|
|
36738
36864
|
if (!existsSync15(file)) throw new Error(`--chain <file> \u2014 no file at '${file}'`);
|
|
36739
|
-
const parsed = JSON.parse(
|
|
36865
|
+
const parsed = JSON.parse(readFileSync14(file, "utf8"));
|
|
36740
36866
|
const links = Array.isArray(parsed) ? parsed : typeof parsed === "object" && parsed !== null && Array.isArray(parsed.certChain) ? parsed.certChain : void 0;
|
|
36741
36867
|
if (links === void 0) {
|
|
36742
36868
|
throw new Error(
|
|
@@ -36786,7 +36912,7 @@ function scarFromVerdict(verdict) {
|
|
|
36786
36912
|
}
|
|
36787
36913
|
function frameworkReceptionPath(here = moduleDirectory()) {
|
|
36788
36914
|
const candidates = [
|
|
36789
|
-
|
|
36915
|
+
join18(here, "framework", "nomos.reception.mjs"),
|
|
36790
36916
|
resolve6(here, "../../cloud/cloudflare-shell/domains/build/nomos/nomos.reception.mjs")
|
|
36791
36917
|
];
|
|
36792
36918
|
const found = candidates.find((candidate) => existsSync15(candidate));
|
|
@@ -36864,7 +36990,7 @@ async function encodeDirectiveCall(receptionPath, domain, directiveId, workspace
|
|
|
36864
36990
|
return captured;
|
|
36865
36991
|
}
|
|
36866
36992
|
function readPayload2(opts) {
|
|
36867
|
-
const text2 = opts.payloadFile !== void 0 ?
|
|
36993
|
+
const text2 = opts.payloadFile !== void 0 ? readFileSync14(opts.payloadFile, "utf8") : opts.payload;
|
|
36868
36994
|
if (text2 === void 0) throw new Error("pass the directive's payload with --payload <json> or --payload-file <file>");
|
|
36869
36995
|
const parsed = JSON.parse(text2);
|
|
36870
36996
|
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
@@ -37204,8 +37330,8 @@ Options
|
|
|
37204
37330
|
});
|
|
37205
37331
|
|
|
37206
37332
|
// src/cli.ts
|
|
37207
|
-
import { existsSync as existsSync16, readFileSync as
|
|
37208
|
-
import { dirname as dirname6, join as
|
|
37333
|
+
import { existsSync as existsSync16, readFileSync as readFileSync15 } from "node:fs";
|
|
37334
|
+
import { dirname as dirname6, join as join19, resolve as resolve7 } from "node:path";
|
|
37209
37335
|
import { pathToFileURL as pathToFileURL4, fileURLToPath as fileURLToPath4 } from "node:url";
|
|
37210
37336
|
|
|
37211
37337
|
// src/generate.ts
|
|
@@ -37906,6 +38032,9 @@ async function main(argv) {
|
|
|
37906
38032
|
process.stdout.write(USAGE2);
|
|
37907
38033
|
return 0;
|
|
37908
38034
|
}
|
|
38035
|
+
if (argv[0] === "console") {
|
|
38036
|
+
return (await Promise.resolve().then(() => (init_console(), console_exports))).consoleCommand(argv.slice(1));
|
|
38037
|
+
}
|
|
37909
38038
|
if (argv[0] === "compile") {
|
|
37910
38039
|
return runCompileCommand(argv.slice(1));
|
|
37911
38040
|
}
|