@inerrata-corporation/errata 2.0.0-dev.44 → 2.0.0-dev.46
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/errata.mjs +68 -2
- package/package.json +1 -1
package/errata.mjs
CHANGED
|
@@ -20931,6 +20931,11 @@ var init_client = __esm({
|
|
|
20931
20931
|
async actAs(handle2) {
|
|
20932
20932
|
return this.json("POST", "/api/gate/act-as", { handle: handle2 });
|
|
20933
20933
|
}
|
|
20934
|
+
/** Resolve-or-create the org's project for a repo locator (ambient link,
|
|
20935
|
+
* PJ-entity). Requires user identity on the JWT — login-gated like actAs. */
|
|
20936
|
+
async resolveProject(locator, name2) {
|
|
20937
|
+
return this.json("POST", "/api/gate/projects/resolve", name2 ? { locator, name: name2 } : { locator });
|
|
20938
|
+
}
|
|
20934
20939
|
// ─── ingest ────────────────────────────────────────────────────────
|
|
20935
20940
|
/** Upload one outbox batch (projected onto the reconciled wire) and fold
|
|
20936
20941
|
* the per-decision response into flush accounting.
|
|
@@ -42664,7 +42669,7 @@ function startLoopLagMonitor(thresholdMs = 1e3) {
|
|
|
42664
42669
|
}
|
|
42665
42670
|
|
|
42666
42671
|
// src/engine.ts
|
|
42667
|
-
var DAEMON_VERSION = true ? "2.0.0-dev.
|
|
42672
|
+
var DAEMON_VERSION = true ? "2.0.0-dev.46" : "2.0.0-alpha.0";
|
|
42668
42673
|
var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
|
|
42669
42674
|
var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
|
|
42670
42675
|
var GIT_OP_MUTE_MS = 4e3;
|
|
@@ -44722,6 +44727,30 @@ function runNpmInstall(channel) {
|
|
|
44722
44727
|
// src/multi.ts
|
|
44723
44728
|
init_cloud_endpoint_policy();
|
|
44724
44729
|
init_cloud_auth();
|
|
44730
|
+
|
|
44731
|
+
// src/project-link.ts
|
|
44732
|
+
async function ensureProjectLink(root, profile, client) {
|
|
44733
|
+
const locator = profile.repoLocator;
|
|
44734
|
+
if (!locator) return { linked: false, reason: "no-locator" };
|
|
44735
|
+
if (profile.projectId && profile.projectLocator === locator) {
|
|
44736
|
+
return { linked: false, reason: "already-linked" };
|
|
44737
|
+
}
|
|
44738
|
+
try {
|
|
44739
|
+
const res = await client.resolveProject(locator, profile.name);
|
|
44740
|
+
profile.projectId = res.project.id;
|
|
44741
|
+
profile.projectLocator = locator;
|
|
44742
|
+
saveProfile(root, profile);
|
|
44743
|
+
return { linked: true, projectId: res.project.id, created: res.created };
|
|
44744
|
+
} catch (err2) {
|
|
44745
|
+
return {
|
|
44746
|
+
linked: false,
|
|
44747
|
+
reason: "error",
|
|
44748
|
+
detail: err2 instanceof Error ? err2.message : String(err2)
|
|
44749
|
+
};
|
|
44750
|
+
}
|
|
44751
|
+
}
|
|
44752
|
+
|
|
44753
|
+
// src/multi.ts
|
|
44725
44754
|
function normPath(p) {
|
|
44726
44755
|
return p.replace(/\\/g, "/").replace(/\/+$/, "").toLowerCase();
|
|
44727
44756
|
}
|
|
@@ -44869,6 +44898,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
44869
44898
|
return { attached: false, id: null, reason: err2 instanceof Error ? err2.message : "build-failed" };
|
|
44870
44899
|
}
|
|
44871
44900
|
records.push(rec);
|
|
44901
|
+
void ambientLinkAll();
|
|
44872
44902
|
app.route(`/ws/${rec.id}`, rec.webApp);
|
|
44873
44903
|
try {
|
|
44874
44904
|
writeFileSync15(
|
|
@@ -45075,6 +45105,22 @@ async function startMultiDaemon(opts = {}) {
|
|
|
45075
45105
|
if (opts.reindexOnStart !== false && records.length > 0) {
|
|
45076
45106
|
void reindexAll({ skipEmbed: opts.skipEmbed ?? true });
|
|
45077
45107
|
}
|
|
45108
|
+
const ambientLinkAll = async () => {
|
|
45109
|
+
const c = loadConfig();
|
|
45110
|
+
if (!c.consent.sync || !hasCloudCredential(c)) return;
|
|
45111
|
+
const client = cloudNow();
|
|
45112
|
+
for (const r of records) {
|
|
45113
|
+
const out2 = await ensureProjectLink(r.root, r.engine.profile, client);
|
|
45114
|
+
if (out2.linked) {
|
|
45115
|
+
console.log(
|
|
45116
|
+
`[errata] linked ${r.engine.profile.name} \u2192 project ${out2.projectId}${out2.created ? " (created)" : ""}`
|
|
45117
|
+
);
|
|
45118
|
+
} else if (out2.reason === "error") {
|
|
45119
|
+
console.warn(`[errata] project link failed for ${r.engine.profile.name}: ${out2.detail}`);
|
|
45120
|
+
}
|
|
45121
|
+
}
|
|
45122
|
+
};
|
|
45123
|
+
void ambientLinkAll();
|
|
45078
45124
|
const packageAutoAll = async () => {
|
|
45079
45125
|
const out2 = /* @__PURE__ */ new Map();
|
|
45080
45126
|
for (const r of records) {
|
|
@@ -46071,7 +46117,8 @@ async function cmdStatus() {
|
|
|
46071
46117
|
console.log(` version: ${DAEMON_VERSION} (update channel: ${cfg.updateChannel})`);
|
|
46072
46118
|
console.log(` workspace: ${profile ? `${profile.name} (${profile.id})` : "(not initialized)"}`);
|
|
46073
46119
|
if (profile) {
|
|
46074
|
-
|
|
46120
|
+
const link = profile.projectId ? ` \u2192 project ${profile.projectId.slice(0, 8)}` : " (unlinked)";
|
|
46121
|
+
console.log(` repo: ${profile.repoLocator ? `${profile.repoLocator}${link}` : "(no git remote \u2014 unlinked)"}`);
|
|
46075
46122
|
console.log(` stack: ${profile.stack.join(", ") || "(none)"}`);
|
|
46076
46123
|
console.log(` languages: ${profile.languages.join(", ") || "(none)"}`);
|
|
46077
46124
|
}
|
|
@@ -46275,12 +46322,31 @@ async function cmdLoginOAuth(cfg) {
|
|
|
46275
46322
|
nextCfg.email = me.handle;
|
|
46276
46323
|
saveConfig(nextCfg);
|
|
46277
46324
|
console.log(`logged in as ${me.handle} (${me.tier}) \u2014 tokens stored at ${globalConfigPath()}`);
|
|
46325
|
+
await linkRegisteredWorkspaces(nextCfg);
|
|
46278
46326
|
} catch (err2) {
|
|
46279
46327
|
console.error(`signed in, but identity check failed: ${err2 instanceof Error ? err2.message : err2}`);
|
|
46280
46328
|
console.error(` credentials were not stored; try again or paste a key: errata login --token <key>`);
|
|
46281
46329
|
process.exitCode = 1;
|
|
46282
46330
|
}
|
|
46283
46331
|
}
|
|
46332
|
+
async function linkRegisteredWorkspaces(cfg) {
|
|
46333
|
+
if (!cfg.consent.sync) return;
|
|
46334
|
+
const client = authedCloudClient(cfg);
|
|
46335
|
+
for (const w of listWorkspaces()) {
|
|
46336
|
+
try {
|
|
46337
|
+
const profile = loadProfile(w.path);
|
|
46338
|
+
if (!profile) continue;
|
|
46339
|
+
refreshRepoLocator(w.path, profile);
|
|
46340
|
+
const out2 = await ensureProjectLink(w.path, profile, client);
|
|
46341
|
+
if (out2.linked) {
|
|
46342
|
+
console.log(
|
|
46343
|
+
` linked ${profile.name} \u2192 project ${out2.projectId}${out2.created ? " (created)" : ""}`
|
|
46344
|
+
);
|
|
46345
|
+
}
|
|
46346
|
+
} catch {
|
|
46347
|
+
}
|
|
46348
|
+
}
|
|
46349
|
+
}
|
|
46284
46350
|
async function cmdLogin() {
|
|
46285
46351
|
const cfg = loadConfig();
|
|
46286
46352
|
const flags2 = parseFlags(rest);
|