githolon 0.105.7 → 0.105.9
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/full-cli.mjs +199 -21
- package/package.json +2 -2
package/dist/full-cli.mjs
CHANGED
|
@@ -4865,7 +4865,7 @@ var init_principal = __esm({
|
|
|
4865
4865
|
|
|
4866
4866
|
// ../cloud/web-client/src/dead_letters.ts
|
|
4867
4867
|
function createDeadLetters(ctx) {
|
|
4868
|
-
const { provider, enc: enc8, dec: dec8, b64 } = ctx;
|
|
4868
|
+
const { provider, enc: enc8, dec: dec8, b64: b642 } = ctx;
|
|
4869
4869
|
const DLQ_FILE = "dead-letters.json";
|
|
4870
4870
|
const readDlq = () => {
|
|
4871
4871
|
const d = provider.readWsFile(DLQ_FILE);
|
|
@@ -4887,7 +4887,7 @@ function createDeadLetters(ctx) {
|
|
|
4887
4887
|
directiveId = doc.payload && doc.payload.directiveId || null;
|
|
4888
4888
|
} catch {
|
|
4889
4889
|
}
|
|
4890
|
-
list.push({ id: e.id, oid: String(e.oid || e.id || "").slice(0, 10), source, error: String(error || "").slice(0, 300), domain, directiveId, at: (/* @__PURE__ */ new Date()).toISOString(), changeB64:
|
|
4890
|
+
list.push({ id: e.id, oid: String(e.oid || e.id || "").slice(0, 10), source, error: String(error || "").slice(0, 300), domain, directiveId, at: (/* @__PURE__ */ new Date()).toISOString(), changeB64: b642(e.blob) });
|
|
4891
4891
|
writeDlq(list);
|
|
4892
4892
|
}
|
|
4893
4893
|
return { readDlq, writeDlq, deadLetter };
|
|
@@ -5374,6 +5374,191 @@ var init_serialized_scheduler = __esm({
|
|
|
5374
5374
|
}
|
|
5375
5375
|
});
|
|
5376
5376
|
|
|
5377
|
+
// ../cloud/web-client/src/intent_offer_codec.ts
|
|
5378
|
+
function encodeIntentOfferBytes({ domain, directiveId, payload, domainHash, security, actor }) {
|
|
5379
|
+
const envelope = { v: 2, intent: { domain, directiveId, payload, domainHash } };
|
|
5380
|
+
const securitySidecar = security && typeof security === "object" && !Array.isArray(security) ? { ...security } : {};
|
|
5381
|
+
if (actor) securitySidecar.actor = actor;
|
|
5382
|
+
if (typeof securitySidecar.actor === "string") {
|
|
5383
|
+
const normalized = securitySidecar.actor.trim();
|
|
5384
|
+
if (normalized) securitySidecar.actor = normalized;
|
|
5385
|
+
else delete securitySidecar.actor;
|
|
5386
|
+
}
|
|
5387
|
+
if (Object.keys(securitySidecar).length > 0) envelope.security = securitySidecar;
|
|
5388
|
+
return encoder.encode(JSON.stringify(envelope));
|
|
5389
|
+
}
|
|
5390
|
+
var encoder;
|
|
5391
|
+
var init_intent_offer_codec = __esm({
|
|
5392
|
+
"../cloud/web-client/src/intent_offer_codec.ts"() {
|
|
5393
|
+
"use strict";
|
|
5394
|
+
encoder = new TextEncoder();
|
|
5395
|
+
}
|
|
5396
|
+
});
|
|
5397
|
+
|
|
5398
|
+
// ../cloud/web-client/src/remote_holon.ts
|
|
5399
|
+
function connectRemote(opts) {
|
|
5400
|
+
const { cloud, workspace } = opts;
|
|
5401
|
+
if (!cloud || !workspace) throw new Error("connectRemote requires { cloud, workspace }");
|
|
5402
|
+
const base = cloud.replace(/\/+$/, "");
|
|
5403
|
+
const _fetch = opts.fetch ?? fetch;
|
|
5404
|
+
const wsUrl = (path2) => `${base}/v2/workspaces/${encodeURIComponent(workspace)}${path2}`;
|
|
5405
|
+
const headers = (json) => {
|
|
5406
|
+
const h = {};
|
|
5407
|
+
if (json) h["content-type"] = "application/json";
|
|
5408
|
+
if (opts.authToken) h["x-nomos-auth"] = opts.authToken;
|
|
5409
|
+
else if (opts.principal) h["x-nomos-principal"] = opts.principal;
|
|
5410
|
+
return h;
|
|
5411
|
+
};
|
|
5412
|
+
const readJson = async (r, what) => {
|
|
5413
|
+
if (!r.ok) {
|
|
5414
|
+
const text = await r.text().catch(() => "");
|
|
5415
|
+
throw new Error(`${what} failed (${r.status}): ${text.slice(0, 300)}`);
|
|
5416
|
+
}
|
|
5417
|
+
return r.json();
|
|
5418
|
+
};
|
|
5419
|
+
const getRead = async (path2, what) => readJson(await _fetch(wsUrl(path2), { headers: headers(false) }), what);
|
|
5420
|
+
async function offerDirective(domain, directiveId, payload, o) {
|
|
5421
|
+
const bytes = encodeIntentOfferBytes({
|
|
5422
|
+
domain,
|
|
5423
|
+
directiveId,
|
|
5424
|
+
payload,
|
|
5425
|
+
domainHash: o?.domainHash,
|
|
5426
|
+
actor: o?.actor
|
|
5427
|
+
});
|
|
5428
|
+
const r = await _fetch(wsUrl(`/${encodeURIComponent(directiveId)}`), {
|
|
5429
|
+
method: "POST",
|
|
5430
|
+
headers: headers(true),
|
|
5431
|
+
body: JSON.stringify({ intentBytes: b64(bytes) })
|
|
5432
|
+
});
|
|
5433
|
+
const body = await r.json().catch(() => ({}));
|
|
5434
|
+
if (r.status === 422 || body?.refused === true) {
|
|
5435
|
+
throw new RemoteOfferRefusedError(
|
|
5436
|
+
String(body?.error ?? "the law refused the offer"),
|
|
5437
|
+
r.status
|
|
5438
|
+
);
|
|
5439
|
+
}
|
|
5440
|
+
if (!r.ok || body?.ok === false) {
|
|
5441
|
+
throw new Error(
|
|
5442
|
+
`offer ${directiveId} failed (${r.status}): ${String(body?.error ?? "").slice(0, 300)}`
|
|
5443
|
+
);
|
|
5444
|
+
}
|
|
5445
|
+
const result = {
|
|
5446
|
+
head: String(body.head ?? ""),
|
|
5447
|
+
...Array.isArray(body.created) ? { created: body.created } : {},
|
|
5448
|
+
...Array.isArray(body.affected) ? { affected: body.affected } : {},
|
|
5449
|
+
...typeof body.workspace === "string" ? { workspace: body.workspace } : {},
|
|
5450
|
+
...body.born !== void 0 ? { born: body.born } : {},
|
|
5451
|
+
...body.birthOutcomes !== void 0 ? { birthOutcomes: body.birthOutcomes } : {}
|
|
5452
|
+
};
|
|
5453
|
+
return o?.returnCreated ? result : result.head;
|
|
5454
|
+
}
|
|
5455
|
+
const query3 = (queryId, params) => {
|
|
5456
|
+
const qs = new URLSearchParams();
|
|
5457
|
+
for (const [k, v] of Object.entries(params ?? {})) if (v != null) qs.set(k, String(v));
|
|
5458
|
+
const suffix = qs.toString() ? `?${qs.toString()}` : "";
|
|
5459
|
+
return getRead(`/${encodeURIComponent(queryId)}${suffix}`, `query ${queryId}`);
|
|
5460
|
+
};
|
|
5461
|
+
const queryById = (aggregateId) => getRead(`/aggregates/${encodeURIComponent(aggregateId)}`, `queryById ${aggregateId}`);
|
|
5462
|
+
const tally = async (kind, id, groupKey) => {
|
|
5463
|
+
const suffix = groupKey ? `?group=${encodeURIComponent(groupKey)}` : "";
|
|
5464
|
+
const body = await getRead(`/${encodeURIComponent(id)}${suffix}`, `${kind} ${id}`);
|
|
5465
|
+
if (typeof body === "number") return body;
|
|
5466
|
+
const v = body?.[kind] ?? body?.value ?? body?.total;
|
|
5467
|
+
return typeof v === "number" ? v : Number(v ?? 0);
|
|
5468
|
+
};
|
|
5469
|
+
const poll = (read, cb, intervalMs) => {
|
|
5470
|
+
let stopped = false;
|
|
5471
|
+
let timer;
|
|
5472
|
+
const tick = async () => {
|
|
5473
|
+
if (stopped) return;
|
|
5474
|
+
try {
|
|
5475
|
+
cb(await read());
|
|
5476
|
+
} catch {
|
|
5477
|
+
}
|
|
5478
|
+
if (!stopped) timer = setTimeout(tick, intervalMs);
|
|
5479
|
+
};
|
|
5480
|
+
void tick();
|
|
5481
|
+
return () => {
|
|
5482
|
+
stopped = true;
|
|
5483
|
+
if (timer) clearTimeout(timer);
|
|
5484
|
+
};
|
|
5485
|
+
};
|
|
5486
|
+
const defaultInterval = opts.watchIntervalMs ?? 2e3;
|
|
5487
|
+
const principal = opts.principal ?? (opts.authToken ? (() => {
|
|
5488
|
+
try {
|
|
5489
|
+
const seg = opts.authToken.split(".")[1] ?? "";
|
|
5490
|
+
const b = seg.replace(/-/g, "+").replace(/_/g, "/") + "===".slice((seg.length + 3) % 4);
|
|
5491
|
+
const claims = JSON.parse(
|
|
5492
|
+
typeof atob === "function" ? atob(b) : nodeBuffer()?.from(b, "base64").toString("utf8") ?? ""
|
|
5493
|
+
);
|
|
5494
|
+
return claims.sub;
|
|
5495
|
+
} catch {
|
|
5496
|
+
return void 0;
|
|
5497
|
+
}
|
|
5498
|
+
})() : void 0);
|
|
5499
|
+
return {
|
|
5500
|
+
workspace,
|
|
5501
|
+
cloud: base,
|
|
5502
|
+
principal,
|
|
5503
|
+
offerDirective,
|
|
5504
|
+
query: query3,
|
|
5505
|
+
queryById,
|
|
5506
|
+
count: (countId, groupKey) => tally("count", countId, groupKey),
|
|
5507
|
+
sum: (sumId, groupKey) => tally("sum", sumId, groupKey),
|
|
5508
|
+
deadLetters: () => getRead(`/dead-letters`, "deadLetters"),
|
|
5509
|
+
retryDeadLetter: async (id) => {
|
|
5510
|
+
const r = await _fetch(wsUrl(`/dead-letters/retry?id=${encodeURIComponent(id)}`), {
|
|
5511
|
+
method: "POST",
|
|
5512
|
+
headers: headers(false)
|
|
5513
|
+
});
|
|
5514
|
+
const body = await readJson(r, `retryDeadLetter ${id}`);
|
|
5515
|
+
const retried = body.retried?.find((entry) => entry.intentId === id) ?? body.retried?.[0];
|
|
5516
|
+
if (retried) return { ok: true, ...retried.head ? { head: retried.head } : {} };
|
|
5517
|
+
const failed = body.failed?.find((entry) => entry.intentId === id) ?? body.failed?.[0];
|
|
5518
|
+
return { ok: false, error: failed?.error ?? `dead letter '${id}' was not retried` };
|
|
5519
|
+
},
|
|
5520
|
+
discardDeadLetter: async (id) => {
|
|
5521
|
+
const r = await _fetch(wsUrl(`/dead-letters?id=${encodeURIComponent(id)}`), {
|
|
5522
|
+
method: "DELETE",
|
|
5523
|
+
headers: headers(false)
|
|
5524
|
+
});
|
|
5525
|
+
const body = await readJson(r, `discardDeadLetter ${id}`);
|
|
5526
|
+
return { ok: true, removed: Number(body.discarded ?? body.removed ?? 0) };
|
|
5527
|
+
},
|
|
5528
|
+
watch: (queryId, params, cb, o) => poll(() => query3(queryId, params), cb, o?.intervalMs ?? defaultInterval),
|
|
5529
|
+
watchById: (aggregateId, cb, o) => poll(() => queryById(aggregateId), cb, o?.intervalMs ?? defaultInterval),
|
|
5530
|
+
/** The workspace's kernel-derived OpenAPI — the code-mode agent's map. */
|
|
5531
|
+
openapi: () => getRead(`/openapi.json`, "openapi")
|
|
5532
|
+
};
|
|
5533
|
+
}
|
|
5534
|
+
var nodeBuffer, RemoteOfferRefusedError, b64;
|
|
5535
|
+
var init_remote_holon = __esm({
|
|
5536
|
+
"../cloud/web-client/src/remote_holon.ts"() {
|
|
5537
|
+
"use strict";
|
|
5538
|
+
init_intent_offer_codec();
|
|
5539
|
+
nodeBuffer = () => globalThis.Buffer;
|
|
5540
|
+
RemoteOfferRefusedError = class extends Error {
|
|
5541
|
+
refused = true;
|
|
5542
|
+
status;
|
|
5543
|
+
constructor(message, status2) {
|
|
5544
|
+
super(message);
|
|
5545
|
+
this.name = "RemoteOfferRefusedError";
|
|
5546
|
+
this.status = status2;
|
|
5547
|
+
}
|
|
5548
|
+
};
|
|
5549
|
+
b64 = (bytes) => {
|
|
5550
|
+
let s = "";
|
|
5551
|
+
for (let i = 0; i < bytes.length; i += 32768) {
|
|
5552
|
+
s += String.fromCharCode(...bytes.subarray(i, i + 32768));
|
|
5553
|
+
}
|
|
5554
|
+
if (typeof btoa === "function") return btoa(s);
|
|
5555
|
+
const buffer = nodeBuffer();
|
|
5556
|
+
if (buffer) return buffer.from(bytes).toString("base64");
|
|
5557
|
+
throw new Error("base64 encoding is unavailable in this runtime");
|
|
5558
|
+
};
|
|
5559
|
+
}
|
|
5560
|
+
});
|
|
5561
|
+
|
|
5377
5562
|
// ../cloud/web-client/src/index.ts
|
|
5378
5563
|
var src_exports = {};
|
|
5379
5564
|
__export(src_exports, {
|
|
@@ -5388,12 +5573,14 @@ __export(src_exports, {
|
|
|
5388
5573
|
OfferDecisionError: () => OfferDecisionError,
|
|
5389
5574
|
OwnedRecoveryPendingError: () => OwnedRecoveryPendingError,
|
|
5390
5575
|
ParentSignerEnrollmentMissingError: () => ParentSignerEnrollmentMissingError,
|
|
5576
|
+
RemoteOfferRefusedError: () => RemoteOfferRefusedError,
|
|
5391
5577
|
assessKernelCoherence: () => assessKernelCoherence,
|
|
5392
5578
|
authzDiagnosisFromRefusal: () => authzDiagnosisFromRefusal,
|
|
5393
5579
|
birthOutcomeFailure: () => birthOutcomeFailure,
|
|
5394
5580
|
canonicalPrincipal: () => canonicalPrincipal,
|
|
5395
5581
|
checkCompat: () => checkCompat,
|
|
5396
5582
|
connect: () => connect,
|
|
5583
|
+
connectRemote: () => connectRemote,
|
|
5397
5584
|
createWasmEnginePlane: () => createWasmEnginePlane,
|
|
5398
5585
|
createWasmKernelProvider: () => createWasmKernelProvider,
|
|
5399
5586
|
deriveWorkspaceName: () => deriveWorkspaceName,
|
|
@@ -5460,18 +5647,6 @@ function normalizeReferenceVersionTransport(refs) {
|
|
|
5460
5647
|
}
|
|
5461
5648
|
return { unique, order };
|
|
5462
5649
|
}
|
|
5463
|
-
function encodeIntentOfferBytes({ domain, directiveId, payload, domainHash, security, actor }) {
|
|
5464
|
-
const envelope = { v: 2, intent: { domain, directiveId, payload, domainHash } };
|
|
5465
|
-
const securitySidecar = security && typeof security === "object" && !Array.isArray(security) ? { ...security } : {};
|
|
5466
|
-
if (actor) securitySidecar.actor = actor;
|
|
5467
|
-
if (typeof securitySidecar.actor === "string") {
|
|
5468
|
-
const a = securitySidecar.actor.trim();
|
|
5469
|
-
if (a) securitySidecar.actor = a;
|
|
5470
|
-
else delete securitySidecar.actor;
|
|
5471
|
-
}
|
|
5472
|
-
if (Object.keys(securitySidecar).length > 0) envelope.security = securitySidecar;
|
|
5473
|
-
return enc4.encode(JSON.stringify(envelope));
|
|
5474
|
-
}
|
|
5475
5650
|
function decodeIntentOfferBytes(intentBytes) {
|
|
5476
5651
|
const bytes = typeof intentBytes === "string" ? bytesUnb64(intentBytes) : intentBytes;
|
|
5477
5652
|
if (!(bytes instanceof Uint8Array)) throw new Error("offer requires opaque intentBytes");
|
|
@@ -6363,13 +6538,13 @@ ${String(commit).toLowerCase()}`;
|
|
|
6363
6538
|
}, _fetch);
|
|
6364
6539
|
return { ref: sessionRef, bytes: pack.byteLength };
|
|
6365
6540
|
}
|
|
6366
|
-
const
|
|
6541
|
+
const b642 = (bytes) => {
|
|
6367
6542
|
let s = "";
|
|
6368
6543
|
for (let i = 0; i < bytes.length; i += 32768) s += String.fromCharCode.apply(null, Array.from(bytes.subarray(i, i + 32768)));
|
|
6369
6544
|
return btoa(s);
|
|
6370
6545
|
};
|
|
6371
6546
|
const unb64 = (s) => Uint8Array.from(atob(s), (c) => c.charCodeAt(0));
|
|
6372
|
-
const { readDlq, writeDlq, deadLetter } = createDeadLetters({ provider, enc: enc4, dec: dec4, b64 });
|
|
6547
|
+
const { readDlq, writeDlq, deadLetter } = createDeadLetters({ provider, enc: enc4, dec: dec4, b64: b642 });
|
|
6373
6548
|
const edgeRefused = /* @__PURE__ */ new Set();
|
|
6374
6549
|
async function pullInner(edgeRejections = null, prefetchedHead = null, opts = {}) {
|
|
6375
6550
|
let remoteHead = prefetchedHead;
|
|
@@ -7064,7 +7239,7 @@ ${String(commit).toLowerCase()}`;
|
|
|
7064
7239
|
if (returnSealed) {
|
|
7065
7240
|
const d = res.intentOut && provider.readWsFile(res.intentOut);
|
|
7066
7241
|
if (!d) throw new Error(`sealed offer: the author produced no sealed intent bytes (intentOut=${res.intentOut ?? "?"})`);
|
|
7067
|
-
sealedB64 =
|
|
7242
|
+
sealedB64 = b642(d);
|
|
7068
7243
|
}
|
|
7069
7244
|
let created = null;
|
|
7070
7245
|
let affected = null;
|
|
@@ -9832,7 +10007,7 @@ ${String(commit).toLowerCase()}`;
|
|
|
9832
10007
|
* wasm decodes the id's route tag and resolves its folded shard map. Returns `{ ok, tag, shard }`
|
|
9833
10008
|
* (`shard:""` = a known-tag but unplaced home; `tag:null` = not a route-tagged id). The routed wrapper
|
|
9834
10009
|
* uses this to CARRY an offer to the right shard — the DECISION is the holon's, the client only carries. */
|
|
9835
|
-
route: (id) => serialize(async () => JSON.parse(call("query", { queryBytes:
|
|
10010
|
+
route: (id) => serialize(async () => JSON.parse(call("query", { queryBytes: b642(enc4.encode(JSON.stringify({ op: "route", id }))) }))),
|
|
9836
10011
|
/** The PLANNED-PAYLOAD write surface (domain/directiveId/payload) — the routed wrapper delegates to this
|
|
9837
10012
|
* on the resolved shard (the CARRY, not a decision; routing is `route(id)`, the holon's). */
|
|
9838
10013
|
dispatch: (domain, directiveId, payload, opts = {}) => offerDirective(domain, directiveId, payload, opts),
|
|
@@ -11367,10 +11542,13 @@ var init_src2 = __esm({
|
|
|
11367
11542
|
init_governance_offers();
|
|
11368
11543
|
init_serialized_scheduler();
|
|
11369
11544
|
init_kernel_pb();
|
|
11545
|
+
init_intent_offer_codec();
|
|
11546
|
+
init_intent_offer_codec();
|
|
11370
11547
|
init_kernel_provider_wasm();
|
|
11371
11548
|
init_errors();
|
|
11372
11549
|
init_principal();
|
|
11373
11550
|
init_kernel_coherence();
|
|
11551
|
+
init_remote_holon();
|
|
11374
11552
|
enc4 = new TextEncoder();
|
|
11375
11553
|
dec4 = new TextDecoder();
|
|
11376
11554
|
BRANCH = "main";
|
|
@@ -11413,8 +11591,8 @@ var init_src2 = __esm({
|
|
|
11413
11591
|
jwtClaim = (token, claim) => {
|
|
11414
11592
|
try {
|
|
11415
11593
|
const seg = String(token).split(".")[1];
|
|
11416
|
-
const
|
|
11417
|
-
return JSON.parse(new TextDecoder().decode(bytesUnb64(
|
|
11594
|
+
const b642 = seg.replace(/-/g, "+").replace(/_/g, "/") + "===".slice((seg.length + 3) % 4);
|
|
11595
|
+
return JSON.parse(new TextDecoder().decode(bytesUnb64(b642)))[claim];
|
|
11418
11596
|
} catch {
|
|
11419
11597
|
return void 0;
|
|
11420
11598
|
}
|
|
@@ -15157,7 +15335,7 @@ var init_engine = __esm({
|
|
|
15157
15335
|
}))
|
|
15158
15336
|
});
|
|
15159
15337
|
repoArgOfGitdir = (gitdir) => gitdir.replace(/\/nomos\.git$/, "");
|
|
15160
|
-
bytesFromB64 = (
|
|
15338
|
+
bytesFromB64 = (b642) => Uint8Array.from(atob(b642), (c) => c.charCodeAt(0));
|
|
15161
15339
|
kgit = {
|
|
15162
15340
|
// resolveRef → tip oid hex, or null if the ref is absent (replaces git.resolveRef(...).catch(()=>null)).
|
|
15163
15341
|
resolveRef: (eng, gitdir, ref) => custodyProtoCase(eng, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "githolon",
|
|
3
|
-
"version": "0.105.
|
|
3
|
+
"version": "0.105.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "githolon — the Nomos developer CLI: Rails-style generators for @githolon/dsl domains + the package compiler. Kernel-independent.",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@bjorn3/browser_wasi_shim": "0.4.2",
|
|
32
32
|
"@bufbuild/protobuf": "^2.13.0",
|
|
33
|
-
"@githolon/dsl": "^0.105.
|
|
33
|
+
"@githolon/dsl": "^0.105.9",
|
|
34
34
|
"isomorphic-git": "^1.38.4",
|
|
35
35
|
"tsx": "^4.19.2"
|
|
36
36
|
},
|