@cotal-ai/connector-codex 0.28.0-hack-20260823234508 → 0.28.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.
- package/dist/host.js +374 -361
- package/dist/index.js +1 -1
- package/package.json +5 -5
package/dist/host.js
CHANGED
|
@@ -13615,11 +13615,11 @@ var require_connect = __commonJS({
|
|
|
13615
13615
|
"../../node_modules/.pnpm/@nats-io+transport-node@3.4.0/node_modules/@nats-io/transport-node/lib/connect.js"(exports) {
|
|
13616
13616
|
"use strict";
|
|
13617
13617
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13618
|
-
exports.connect =
|
|
13618
|
+
exports.connect = connect7;
|
|
13619
13619
|
var node_transport_1 = require_node_transport();
|
|
13620
13620
|
var nats_base_client_1 = require_nats_base_client();
|
|
13621
13621
|
var nats_base_client_2 = require_nats_base_client();
|
|
13622
|
-
function
|
|
13622
|
+
function connect7(opts = {}) {
|
|
13623
13623
|
if ((0, nats_base_client_2.hasWsProtocol)(opts)) {
|
|
13624
13624
|
return Promise.reject(nats_base_client_2.errors.InvalidArgumentError.format(`servers`, `node client doesn't support websockets, use the 'wsconnect' function instead`));
|
|
13625
13625
|
}
|
|
@@ -40107,49 +40107,33 @@ var SYS_LIMITS = { ...BASE_LIMITS, mem_storage: 0, disk_storage: 0 };
|
|
|
40107
40107
|
var import_nkeys4 = __toESM(require_mod2(), 1);
|
|
40108
40108
|
|
|
40109
40109
|
// ../../packages/core/dist/channels.js
|
|
40110
|
-
var
|
|
40111
|
-
var
|
|
40112
|
-
|
|
40113
|
-
|
|
40114
|
-
|
|
40115
|
-
|
|
40116
|
-
|
|
40117
|
-
|
|
40118
|
-
|
|
40119
|
-
|
|
40120
|
-
|
|
40121
|
-
|
|
40122
|
-
|
|
40123
|
-
|
|
40124
|
-
|
|
40125
|
-
|
|
40126
|
-
|
|
40127
|
-
function effectiveDeliveryClass(cfg, defaults) {
|
|
40128
|
-
return cfg?.deliveryClass ?? defaults?.deliveryClass ?? "durable";
|
|
40129
|
-
}
|
|
40130
|
-
async function openChannelRegistry(nc, space, opts = {}) {
|
|
40131
|
-
const kvm = new import_kv4.Kvm(nc);
|
|
40132
|
-
return opts.create ? kvm.create(channelBucket(space)) : kvm.open(channelBucket(space));
|
|
40133
|
-
}
|
|
40134
|
-
async function readChannelConfig(kv, channel) {
|
|
40135
|
-
return decode2(kv, channel);
|
|
40136
|
-
}
|
|
40137
|
-
async function readChannelDefaults(kv) {
|
|
40138
|
-
return decode2(kv, CHANNEL_DEFAULTS_KEY);
|
|
40139
|
-
}
|
|
40140
|
-
async function decode2(kv, key) {
|
|
40141
|
-
const e = await kv.get(key);
|
|
40142
|
-
if (!e || e.operation === "DEL" || e.operation === "PURGE")
|
|
40143
|
-
return void 0;
|
|
40144
|
-
try {
|
|
40145
|
-
return e.json();
|
|
40146
|
-
} catch {
|
|
40147
|
-
return void 0;
|
|
40148
|
-
}
|
|
40110
|
+
var import_kv7 = __toESM(require_mod6(), 1);
|
|
40111
|
+
var import_transport_node15 = __toESM(require_transport_node(), 1);
|
|
40112
|
+
|
|
40113
|
+
// ../../packages/core/dist/endpoint.js
|
|
40114
|
+
var import_transport_node14 = __toESM(require_transport_node(), 1);
|
|
40115
|
+
var import_nats_core = __toESM(require_mod3(), 1);
|
|
40116
|
+
import { EventEmitter } from "node:events";
|
|
40117
|
+
import { randomUUID } from "node:crypto";
|
|
40118
|
+
import { createConnection } from "node:net";
|
|
40119
|
+
|
|
40120
|
+
// ../../packages/core/dist/artifact.js
|
|
40121
|
+
var ARTIFACT_PART_KIND = "artifact";
|
|
40122
|
+
function isArtifactPart(value) {
|
|
40123
|
+
if (!value || typeof value !== "object")
|
|
40124
|
+
return false;
|
|
40125
|
+
const p = value;
|
|
40126
|
+
return p.kind === ARTIFACT_PART_KIND && typeof p.name === "string" && p.name.length > 0 && typeof p.mediaType === "string" && p.mediaType.length > 0 && typeof p.digest === "string" && isContractDigest(p.digest) && typeof p.size === "number" && Number.isSafeInteger(p.size) && p.size >= 0;
|
|
40149
40127
|
}
|
|
40150
40128
|
|
|
40129
|
+
// ../../packages/core/dist/endpoint.js
|
|
40130
|
+
var import_jetstream13 = __toESM(require_mod4(), 1);
|
|
40131
|
+
var import_jetstream14 = __toESM(require_mod4(), 1);
|
|
40132
|
+
var import_kv6 = __toESM(require_mod6(), 1);
|
|
40133
|
+
var import_internal2 = __toESM(require_internal_mod3(), 1);
|
|
40134
|
+
|
|
40151
40135
|
// ../../packages/core/dist/members.js
|
|
40152
|
-
var
|
|
40136
|
+
var import_kv4 = __toESM(require_mod6(), 1);
|
|
40153
40137
|
var StaleMembershipWrite = class extends Error {
|
|
40154
40138
|
constructor(channel, owner, attempted, current) {
|
|
40155
40139
|
super(`stale membership write for ${channel}/${owner}: generation ${attempted} < current ${current}`);
|
|
@@ -40157,7 +40141,7 @@ var StaleMembershipWrite = class extends Error {
|
|
|
40157
40141
|
}
|
|
40158
40142
|
};
|
|
40159
40143
|
async function openMembersRegistry(nc, space, opts = {}) {
|
|
40160
|
-
const kvm = new
|
|
40144
|
+
const kvm = new import_kv4.Kvm(nc);
|
|
40161
40145
|
return opts.create ? kvm.create(membersBucket(space)) : kvm.open(membersBucket(space));
|
|
40162
40146
|
}
|
|
40163
40147
|
async function readMember(kv, channel, owner, lifecycleUid) {
|
|
@@ -40257,306 +40241,14 @@ function durableEligible(rec, seq) {
|
|
|
40257
40241
|
return true;
|
|
40258
40242
|
}
|
|
40259
40243
|
|
|
40260
|
-
// ../../packages/core/dist/membership-feed.js
|
|
40261
|
-
var import_transport_node14 = __toESM(require_transport_node(), 1);
|
|
40262
|
-
var import_kv6 = __toESM(require_mod6(), 1);
|
|
40263
|
-
|
|
40264
|
-
// ../../packages/core/dist/evict.js
|
|
40265
|
-
var import_transport_node15 = __toESM(require_transport_node(), 1);
|
|
40266
|
-
|
|
40267
40244
|
// ../../packages/core/dist/lease.js
|
|
40268
|
-
var
|
|
40269
|
-
var
|
|
40245
|
+
var import_kv5 = __toESM(require_mod6(), 1);
|
|
40246
|
+
var import_transport_node13 = __toESM(require_transport_node(), 1);
|
|
40270
40247
|
async function openDeliveryRegistry(nc, space) {
|
|
40271
|
-
return new
|
|
40272
|
-
}
|
|
40273
|
-
|
|
40274
|
-
// ../../packages/core/dist/agent-file.js
|
|
40275
|
-
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
40276
|
-
var import_yaml = __toESM(require_dist(), 1);
|
|
40277
|
-
function parseFrontmatter(src, path) {
|
|
40278
|
-
let doc;
|
|
40279
|
-
try {
|
|
40280
|
-
doc = (0, import_yaml.parse)(src);
|
|
40281
|
-
} catch (e) {
|
|
40282
|
-
throw new Error(`agent file ${path}: invalid YAML frontmatter; ${e.message}`);
|
|
40283
|
-
}
|
|
40284
|
-
if (doc === null || doc === void 0)
|
|
40285
|
-
return {};
|
|
40286
|
-
if (typeof doc !== "object" || Array.isArray(doc))
|
|
40287
|
-
throw new Error(`agent file ${path}: frontmatter must be a YAML mapping (key: value pairs)`);
|
|
40288
|
-
return doc;
|
|
40289
|
-
}
|
|
40290
|
-
function loadAgentFile(path) {
|
|
40291
|
-
const src = readFileSync(path, "utf8");
|
|
40292
|
-
const m = /^---\n([\s\S]*?)\n---\n?([\s\S]*)$/.exec(src);
|
|
40293
|
-
if (!m)
|
|
40294
|
-
throw new Error(`agent file ${path}: missing "---" frontmatter block`);
|
|
40295
|
-
const fm = parseFrontmatter(m[1], path);
|
|
40296
|
-
const persona = m[2].trim();
|
|
40297
|
-
const str2 = (k) => {
|
|
40298
|
-
const v = fm[k];
|
|
40299
|
-
if (v === void 0 || v === null)
|
|
40300
|
-
return void 0;
|
|
40301
|
-
if (typeof v === "object")
|
|
40302
|
-
throw new Error(`agent file ${path}: "${k}" must be a scalar`);
|
|
40303
|
-
return String(v);
|
|
40304
|
-
};
|
|
40305
|
-
const list = (k) => {
|
|
40306
|
-
const v = fm[k];
|
|
40307
|
-
if (v === void 0 || v === null)
|
|
40308
|
-
return void 0;
|
|
40309
|
-
return (Array.isArray(v) ? v : [v]).map((x) => {
|
|
40310
|
-
if (x === null || typeof x === "object")
|
|
40311
|
-
throw new Error(`agent file ${path}: "${k}" list items must be scalars`);
|
|
40312
|
-
return String(x);
|
|
40313
|
-
});
|
|
40314
|
-
};
|
|
40315
|
-
const name = str2("name");
|
|
40316
|
-
if (!name)
|
|
40317
|
-
throw new Error(`agent file ${path}: "name" is required`);
|
|
40318
|
-
assertValidName(name);
|
|
40319
|
-
const kind = str2("kind");
|
|
40320
|
-
if (kind && kind !== "agent" && kind !== "endpoint")
|
|
40321
|
-
throw new Error(`agent file ${path}: "kind" must be "agent" or "endpoint"`);
|
|
40322
|
-
for (const old of ["channels", "publish"])
|
|
40323
|
-
if (old in fm)
|
|
40324
|
-
throw new Error(`agent file ${path}: "${old}" was renamed - use "subscribe"/"allowSubscribe" (read) and "allowPublish" (post)`);
|
|
40325
|
-
const subscribe = list("subscribe");
|
|
40326
|
-
const allowSubscribe = list("allowSubscribe");
|
|
40327
|
-
const allowPublish = list("allowPublish");
|
|
40328
|
-
const quiet = list("quiet");
|
|
40329
|
-
const muted = list("muted");
|
|
40330
|
-
for (const ch of [...subscribe ?? [], ...allowSubscribe ?? [], ...allowPublish ?? []])
|
|
40331
|
-
try {
|
|
40332
|
-
assertValidChannel(ch);
|
|
40333
|
-
} catch (e) {
|
|
40334
|
-
throw new Error(`agent file ${path}: ${e.message}`);
|
|
40335
|
-
}
|
|
40336
|
-
const effSubscribe = subscribe?.length ? subscribe : ["general"];
|
|
40337
|
-
const effAllow = allowSubscribe?.length ? allowSubscribe : effSubscribe;
|
|
40338
|
-
for (const ch of effSubscribe)
|
|
40339
|
-
if (!channelInAllow(effAllow, ch))
|
|
40340
|
-
throw new Error(`agent file ${path}: subscribe channel "${ch}" is not within allowSubscribe [${effAllow.join(", ")}]`);
|
|
40341
|
-
const both = (quiet ?? []).filter((c) => (muted ?? []).includes(c));
|
|
40342
|
-
if (both.length)
|
|
40343
|
-
throw new Error(`agent file ${path}: channel(s) [${both.join(", ")}] are in both quiet and muted - pick one`);
|
|
40344
|
-
for (const [field, chans] of [["quiet", quiet], ["muted", muted]])
|
|
40345
|
-
for (const ch of chans ?? []) {
|
|
40346
|
-
try {
|
|
40347
|
-
assertValidChannel(ch);
|
|
40348
|
-
} catch (e) {
|
|
40349
|
-
throw new Error(`agent file ${path}: ${e.message}`);
|
|
40350
|
-
}
|
|
40351
|
-
if (!isConcreteChannel(ch))
|
|
40352
|
-
throw new Error(`agent file ${path}: ${field} channel "${ch}" must be a concrete channel (no wildcard)`);
|
|
40353
|
-
if (!channelInAllow(effAllow, ch))
|
|
40354
|
-
throw new Error(`agent file ${path}: ${field} channel "${ch}" is not within your read ACL / allowSubscribe [${effAllow.join(", ")}]`);
|
|
40355
|
-
}
|
|
40356
|
-
const launchOptionsRaw = fm["launchOptions"];
|
|
40357
|
-
let launchOptions;
|
|
40358
|
-
if (launchOptionsRaw !== void 0 && launchOptionsRaw !== null) {
|
|
40359
|
-
if (typeof launchOptionsRaw !== "object" || Array.isArray(launchOptionsRaw))
|
|
40360
|
-
throw new Error(`agent file ${path}: "launchOptions" must be a mapping of key: value pairs`);
|
|
40361
|
-
launchOptions = launchOptionsRaw;
|
|
40362
|
-
}
|
|
40363
|
-
const known = /* @__PURE__ */ new Set(["name", "role", "kind", "description", "tags", "subscribe", "allowSubscribe", "allowPublish", "quiet", "muted", "model", "variant", "launchOptions", "capabilities", "owner"]);
|
|
40364
|
-
const meta3 = {};
|
|
40365
|
-
for (const [k, v] of Object.entries(fm))
|
|
40366
|
-
if (!known.has(k) && v !== null && typeof v !== "object")
|
|
40367
|
-
meta3[k] = String(v);
|
|
40368
|
-
return {
|
|
40369
|
-
name,
|
|
40370
|
-
role: str2("role"),
|
|
40371
|
-
kind,
|
|
40372
|
-
description: str2("description"),
|
|
40373
|
-
tags: list("tags"),
|
|
40374
|
-
subscribe,
|
|
40375
|
-
allowSubscribe,
|
|
40376
|
-
allowPublish,
|
|
40377
|
-
quiet,
|
|
40378
|
-
muted,
|
|
40379
|
-
model: str2("model"),
|
|
40380
|
-
variant: str2("variant"),
|
|
40381
|
-
launchOptions,
|
|
40382
|
-
capabilities: list("capabilities"),
|
|
40383
|
-
owner: str2("owner"),
|
|
40384
|
-
meta: Object.keys(meta3).length ? meta3 : void 0,
|
|
40385
|
-
persona: persona || void 0
|
|
40386
|
-
};
|
|
40387
|
-
}
|
|
40388
|
-
|
|
40389
|
-
// ../../packages/core/dist/fs-safe.js
|
|
40390
|
-
import { lstatSync, mkdirSync as mkdirSync2, unlinkSync } from "node:fs";
|
|
40391
|
-
import { join } from "node:path";
|
|
40392
|
-
function ensureDirNoSymlink(parent, ...segments) {
|
|
40393
|
-
let dir = parent;
|
|
40394
|
-
for (const seg of segments) {
|
|
40395
|
-
dir = join(dir, seg);
|
|
40396
|
-
let st;
|
|
40397
|
-
try {
|
|
40398
|
-
st = lstatSync(dir);
|
|
40399
|
-
} catch (e) {
|
|
40400
|
-
if (e.code === "ENOENT") {
|
|
40401
|
-
mkdirSync2(dir, { mode: 448 });
|
|
40402
|
-
continue;
|
|
40403
|
-
}
|
|
40404
|
-
throw e;
|
|
40405
|
-
}
|
|
40406
|
-
if (st.isSymbolicLink())
|
|
40407
|
-
throw new Error(`refusing to write under "${dir}": it is a symlink`);
|
|
40408
|
-
if (!st.isDirectory())
|
|
40409
|
-
throw new Error(`refusing to write under "${dir}": not a directory`);
|
|
40410
|
-
}
|
|
40411
|
-
return dir;
|
|
40412
|
-
}
|
|
40413
|
-
|
|
40414
|
-
// ../../packages/core/dist/secret-fs.js
|
|
40415
|
-
import { chmodSync, mkdirSync as mkdirSync3, renameSync, unlinkSync as unlinkSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
40416
|
-
import { execFileSync } from "node:child_process";
|
|
40417
|
-
import { join as join2 } from "node:path";
|
|
40418
|
-
var isWin = process.platform === "win32";
|
|
40419
|
-
function sys32(exe) {
|
|
40420
|
-
const root = process.env.SystemRoot || process.env.windir || "C:\\Windows";
|
|
40421
|
-
return join2(root, "System32", exe);
|
|
40422
|
-
}
|
|
40423
|
-
var cachedSid;
|
|
40424
|
-
function ownerSid() {
|
|
40425
|
-
if (cachedSid)
|
|
40426
|
-
return cachedSid;
|
|
40427
|
-
const out = execFileSync(sys32("whoami.exe"), ["/user", "/fo", "csv", "/nh"], { encoding: "utf8" });
|
|
40428
|
-
const sid = out.trim().split(",").pop()?.replace(/^"|"$/g, "").trim();
|
|
40429
|
-
if (!sid || !/^S-1-/.test(sid))
|
|
40430
|
-
throw new Error(`could not determine the current user's SID from \`whoami\` (got: ${out.trim()})`);
|
|
40431
|
-
cachedSid = sid;
|
|
40432
|
-
return sid;
|
|
40433
|
-
}
|
|
40434
|
-
var BROAD_SIDS = ["S-1-1-0", "S-1-5-11", "S-1-5-32-545"];
|
|
40435
|
-
function hardenPrivate(path, kind) {
|
|
40436
|
-
if (!isWin) {
|
|
40437
|
-
chmodSync(path, kind === "dir" ? 448 : 384);
|
|
40438
|
-
return;
|
|
40439
|
-
}
|
|
40440
|
-
const perm = kind === "dir" ? "(OI)(CI)(F)" : "(F)";
|
|
40441
|
-
const removeBroad = BROAD_SIDS.flatMap((sid) => ["/remove:g", `*${sid}`]);
|
|
40442
|
-
const grant = (sid) => ["/grant:r", `*${sid}:${perm}`];
|
|
40443
|
-
try {
|
|
40444
|
-
execFileSync(sys32("icacls.exe"), [
|
|
40445
|
-
path,
|
|
40446
|
-
"/inheritance:r",
|
|
40447
|
-
...removeBroad,
|
|
40448
|
-
...grant(ownerSid()),
|
|
40449
|
-
...grant("S-1-5-18"),
|
|
40450
|
-
...grant("S-1-5-32-544")
|
|
40451
|
-
], { stdio: ["ignore", "ignore", "pipe"] });
|
|
40452
|
-
} catch (e) {
|
|
40453
|
-
throw new Error(`failed to harden ${kind} "${path}" to private via icacls: ${e.message.trim()}. Cotal will not leave a secret with a permissive ACL - ensure the path is on an NTFS volume and %SystemRoot%\\System32\\icacls.exe is available.`);
|
|
40454
|
-
}
|
|
40455
|
-
}
|
|
40456
|
-
|
|
40457
|
-
// ../../packages/core/dist/launch-material.js
|
|
40458
|
-
import { mkdtempSync, readFileSync as readFileSync2, realpathSync, rmSync, rmdirSync, statSync } from "node:fs";
|
|
40459
|
-
import { tmpdir } from "node:os";
|
|
40460
|
-
import { basename, dirname, join as join3, resolve } from "node:path";
|
|
40461
|
-
var DIR_PREFIX = "cotal-launch-";
|
|
40462
|
-
var MATERIAL_FILE = "material.json";
|
|
40463
|
-
var LAUNCH_MATERIAL_ENV = "COTAL_LAUNCH_MATERIAL";
|
|
40464
|
-
function readLaunchMaterial(path) {
|
|
40465
|
-
let raw;
|
|
40466
|
-
try {
|
|
40467
|
-
if (process.platform !== "win32") {
|
|
40468
|
-
const mode = statSync(path).mode & 511;
|
|
40469
|
-
if (mode & 63)
|
|
40470
|
-
throw new Error(`is readable beyond its owner (mode ${mode.toString(8)}) - refusing to read connection material out of a file other local users can open`);
|
|
40471
|
-
}
|
|
40472
|
-
raw = readFileSync2(path, "utf8");
|
|
40473
|
-
} catch (e) {
|
|
40474
|
-
throw new Error(`launch material: cannot read ${path} (${e instanceof Error ? e.message : String(e)})`);
|
|
40475
|
-
}
|
|
40476
|
-
let parsed;
|
|
40477
|
-
try {
|
|
40478
|
-
parsed = JSON.parse(raw);
|
|
40479
|
-
} catch {
|
|
40480
|
-
throw new Error(`launch material: ${path} is not valid JSON`);
|
|
40481
|
-
}
|
|
40482
|
-
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
|
|
40483
|
-
throw new Error(`launch material: ${path} must contain a JSON object`);
|
|
40484
|
-
return validate(parsed, path);
|
|
40485
|
-
}
|
|
40486
|
-
function validate(raw, path) {
|
|
40487
|
-
const material = {};
|
|
40488
|
-
const str2 = (key) => {
|
|
40489
|
-
const v = raw[key];
|
|
40490
|
-
if (v === void 0)
|
|
40491
|
-
return;
|
|
40492
|
-
if (typeof v !== "string" || !v.trim())
|
|
40493
|
-
throw new Error(`launch material: ${path} has a ${key} that is not a non-empty string`);
|
|
40494
|
-
material[key] = v;
|
|
40495
|
-
};
|
|
40496
|
-
str2("servers");
|
|
40497
|
-
str2("creds");
|
|
40498
|
-
str2("token");
|
|
40499
|
-
str2("controlToken");
|
|
40500
|
-
if (raw.userAuth !== void 0) {
|
|
40501
|
-
const u = raw.userAuth;
|
|
40502
|
-
if (typeof u !== "object" || u === null || Array.isArray(u))
|
|
40503
|
-
throw new Error(`launch material: ${path} has a userAuth that is not an object`);
|
|
40504
|
-
const { owner, actor, sentinelCredsPath, bearerCmd } = u;
|
|
40505
|
-
const named = { owner, actor, sentinelCredsPath };
|
|
40506
|
-
for (const [k, v] of Object.entries(named))
|
|
40507
|
-
if (typeof v !== "string" || !v.trim())
|
|
40508
|
-
throw new Error(`launch material: ${path} has a userAuth.${k} that is not a non-empty string`);
|
|
40509
|
-
if (!Array.isArray(bearerCmd) || bearerCmd.length === 0 || !bearerCmd.every((a) => typeof a === "string" && a))
|
|
40510
|
-
throw new Error(`launch material: ${path} has a userAuth.bearerCmd that is not a non-empty array of strings`);
|
|
40511
|
-
material.userAuth = {
|
|
40512
|
-
owner,
|
|
40513
|
-
actor,
|
|
40514
|
-
sentinelCredsPath,
|
|
40515
|
-
bearerCmd
|
|
40516
|
-
};
|
|
40517
|
-
}
|
|
40518
|
-
if (Object.keys(material).length === 0)
|
|
40519
|
-
throw new Error(`launch material: ${path} carries nothing this reader recognises. A launch that references material and supplies none is a broken launcher, not an open-mode launch, so it is refused rather than defaulted.`);
|
|
40520
|
-
return material;
|
|
40521
|
-
}
|
|
40522
|
-
function discardLaunchMaterial(path) {
|
|
40523
|
-
const file2 = resolve(path);
|
|
40524
|
-
try {
|
|
40525
|
-
rmSync(file2, { force: true });
|
|
40526
|
-
} catch {
|
|
40527
|
-
}
|
|
40528
|
-
const dir = dirname(file2);
|
|
40529
|
-
if (basename(file2) !== MATERIAL_FILE || !basename(dir).startsWith(DIR_PREFIX))
|
|
40530
|
-
return;
|
|
40531
|
-
try {
|
|
40532
|
-
if (realpathSync(dirname(dir)) !== realpathSync(tmpdir()))
|
|
40533
|
-
return;
|
|
40534
|
-
rmdirSync(dir);
|
|
40535
|
-
} catch {
|
|
40536
|
-
}
|
|
40537
|
-
}
|
|
40538
|
-
|
|
40539
|
-
// ../../packages/core/dist/endpoint.js
|
|
40540
|
-
var import_transport_node17 = __toESM(require_transport_node(), 1);
|
|
40541
|
-
var import_nats_core = __toESM(require_mod3(), 1);
|
|
40542
|
-
import { EventEmitter } from "node:events";
|
|
40543
|
-
import { randomUUID } from "node:crypto";
|
|
40544
|
-
import { createConnection } from "node:net";
|
|
40545
|
-
|
|
40546
|
-
// ../../packages/core/dist/artifact.js
|
|
40547
|
-
var ARTIFACT_PART_KIND = "artifact";
|
|
40548
|
-
function isArtifactPart(value) {
|
|
40549
|
-
if (!value || typeof value !== "object")
|
|
40550
|
-
return false;
|
|
40551
|
-
const p = value;
|
|
40552
|
-
return p.kind === ARTIFACT_PART_KIND && typeof p.name === "string" && p.name.length > 0 && typeof p.mediaType === "string" && p.mediaType.length > 0 && typeof p.digest === "string" && isContractDigest(p.digest) && typeof p.size === "number" && Number.isSafeInteger(p.size) && p.size >= 0;
|
|
40248
|
+
return new import_kv5.Kvm(nc).open(deliveryBucket(space));
|
|
40553
40249
|
}
|
|
40554
40250
|
|
|
40555
40251
|
// ../../packages/core/dist/endpoint.js
|
|
40556
|
-
var import_jetstream13 = __toESM(require_mod4(), 1);
|
|
40557
|
-
var import_jetstream14 = __toESM(require_mod4(), 1);
|
|
40558
|
-
var import_kv8 = __toESM(require_mod6(), 1);
|
|
40559
|
-
var import_internal2 = __toESM(require_internal_mod3(), 1);
|
|
40560
40252
|
var DEFAULT_SERVER = "nats://127.0.0.1:4222";
|
|
40561
40253
|
var PLANE3_FRAME_HEADER = "Cotal-Delivery-Frame";
|
|
40562
40254
|
var READER_MAX_REDELIVERIES = 10;
|
|
@@ -40807,7 +40499,7 @@ var CotalEndpoint = class _CotalEndpoint extends EventEmitter {
|
|
|
40807
40499
|
this.user = opts.user;
|
|
40808
40500
|
this.pass = opts.pass;
|
|
40809
40501
|
this.tls = opts.tls ?? false;
|
|
40810
|
-
this.channels = opts.channels ?? [
|
|
40502
|
+
this.channels = opts.channels ?? [];
|
|
40811
40503
|
this.heartbeatMs = opts.heartbeatMs ?? 2e3;
|
|
40812
40504
|
this.ttlMs = opts.ttlMs ?? 6e3;
|
|
40813
40505
|
this.doRegister = opts.registerPresence ?? true;
|
|
@@ -41070,7 +40762,7 @@ var CotalEndpoint = class _CotalEndpoint extends EventEmitter {
|
|
|
41070
40762
|
this.watchStatus();
|
|
41071
40763
|
this.js = (0, import_jetstream13.jetstream)(this.nc);
|
|
41072
40764
|
if (this.doWatch || this.doRegister) {
|
|
41073
|
-
const kvm = new
|
|
40765
|
+
const kvm = new import_kv6.Kvm(this.nc);
|
|
41074
40766
|
this.kv = this.authed ? await kvm.open(presenceBucket(this.space)) : await kvm.create(presenceBucket(this.space), { ttl: this.ttlMs });
|
|
41075
40767
|
}
|
|
41076
40768
|
if (this.doWatch) {
|
|
@@ -41334,7 +41026,9 @@ var CotalEndpoint = class _CotalEndpoint extends EventEmitter {
|
|
|
41334
41026
|
// ---- messaging -----------------------------------------------------------
|
|
41335
41027
|
/** Multicast: broadcast to everyone on a channel. */
|
|
41336
41028
|
async multicast(text, opts) {
|
|
41337
|
-
const channel = opts?.channel ?? this.channels.find(isConcreteChannel)
|
|
41029
|
+
const channel = opts?.channel ?? this.channels.find(isConcreteChannel);
|
|
41030
|
+
if (!channel)
|
|
41031
|
+
throw new Error("send() needs a channel: this endpoint is on no concrete channel, so there is no default to fall back to - pass opts.channel");
|
|
41338
41032
|
if (!isConcreteChannel(channel))
|
|
41339
41033
|
throw new Error(`cannot publish to wildcard channel "${channel}" - pick a concrete sub-channel`);
|
|
41340
41034
|
const msg = {
|
|
@@ -41450,7 +41144,7 @@ var CotalEndpoint = class _CotalEndpoint extends EventEmitter {
|
|
|
41450
41144
|
throw new Error(`expectedLastSubjectSeq must be a non-negative safe integer, got ${JSON.stringify(opts.expectedLastSubjectSeq)}`);
|
|
41451
41145
|
if (!Array.isArray(opts.parts) || opts.parts.length === 0)
|
|
41452
41146
|
throw new Error("encodedSize requires at least one part");
|
|
41453
|
-
const mh = (0,
|
|
41147
|
+
const mh = (0, import_transport_node14.headers)();
|
|
41454
41148
|
mh.set("Nats-Msg-Id", opts.id);
|
|
41455
41149
|
mh.set("Nats-Expected-Last-Subject-Sequence", `${opts.expectedLastSubjectSeq}`);
|
|
41456
41150
|
const headerBytes = mh.encode().length;
|
|
@@ -41956,7 +41650,7 @@ var CotalEndpoint = class _CotalEndpoint extends EventEmitter {
|
|
|
41956
41650
|
async membershipFeedRegistry() {
|
|
41957
41651
|
if (!this.nc)
|
|
41958
41652
|
throw new Error("endpoint not started");
|
|
41959
|
-
this.membershipFeedKv ??= await new
|
|
41653
|
+
this.membershipFeedKv ??= await new import_kv6.Kvm(this.nc).open(membershipBucket(this.space));
|
|
41960
41654
|
return this.membershipFeedKv;
|
|
41961
41655
|
}
|
|
41962
41656
|
/**
|
|
@@ -42322,7 +42016,7 @@ var CotalEndpoint = class _CotalEndpoint extends EventEmitter {
|
|
|
42322
42016
|
for await (const s of this.nc.status()) {
|
|
42323
42017
|
if (s.type !== "error")
|
|
42324
42018
|
continue;
|
|
42325
|
-
if (s.error instanceof
|
|
42019
|
+
if (s.error instanceof import_transport_node14.PermissionViolationError && this.confirmingChatSubs.has(s.error.subject))
|
|
42326
42020
|
continue;
|
|
42327
42021
|
this.emit("error", describeStatusError(s.error));
|
|
42328
42022
|
}
|
|
@@ -42545,7 +42239,7 @@ var CotalEndpoint = class _CotalEndpoint extends EventEmitter {
|
|
|
42545
42239
|
throw new Error("endpoint not started");
|
|
42546
42240
|
if (this.managerLeaseKv)
|
|
42547
42241
|
return this.managerLeaseKv;
|
|
42548
|
-
const kvm = new
|
|
42242
|
+
const kvm = new import_kv6.Kvm((0, import_jetstream13.jetstream)(this.nc, { timeout: MANAGER_LEASE_ATTEMPT_MS }));
|
|
42549
42243
|
if (this.authed) {
|
|
42550
42244
|
this.managerLeaseKv = await kvm.open(managerBucket(this.space));
|
|
42551
42245
|
} else {
|
|
@@ -42775,7 +42469,7 @@ var CotalEndpoint = class _CotalEndpoint extends EventEmitter {
|
|
|
42775
42469
|
filter_subject: subject,
|
|
42776
42470
|
ack_policy: import_jetstream13.AckPolicy.None,
|
|
42777
42471
|
mem_storage: true,
|
|
42778
|
-
inactive_threshold: (0,
|
|
42472
|
+
inactive_threshold: (0, import_transport_node14.nanos)(3e4),
|
|
42779
42473
|
deliver_policy: import_jetstream13.DeliverPolicy.StartSequence,
|
|
42780
42474
|
opt_start_seq: fromSeqExcl + 1
|
|
42781
42475
|
});
|
|
@@ -43237,7 +42931,7 @@ var CotalEndpoint = class _CotalEndpoint extends EventEmitter {
|
|
|
43237
42931
|
channel: entry.channel,
|
|
43238
42932
|
msg: authenticatedChannelMessage(entry.msg, entry.channel)
|
|
43239
42933
|
};
|
|
43240
|
-
const frameHeaders = (0,
|
|
42934
|
+
const frameHeaders = (0, import_transport_node14.headers)();
|
|
43241
42935
|
frameHeaders.set(PLANE3_FRAME_HEADER, "1");
|
|
43242
42936
|
await this.js.publish(dlvSubject(this.space, pr.owner, pr.actor, pr.lifecycleUid), JSON.stringify(frame), {
|
|
43243
42937
|
msgID: `${entry.msg.id}:${owner}:${pr.lifecycleUid}:${entry.generation}`,
|
|
@@ -43367,7 +43061,7 @@ var CotalEndpoint = class _CotalEndpoint extends EventEmitter {
|
|
|
43367
43061
|
* distinct from a responder that errored. nats.js surfaces it as NoRespondersError, or a RequestError
|
|
43368
43062
|
* whose `isNoResponders()` is true. */
|
|
43369
43063
|
isNoResponders(e) {
|
|
43370
|
-
return e instanceof
|
|
43064
|
+
return e instanceof import_transport_node14.NoRespondersError || e instanceof import_transport_node14.RequestError && e.isNoResponders();
|
|
43371
43065
|
}
|
|
43372
43066
|
/** Agent-side: this session's CURRENT durable memberships (channel + join generation) from the
|
|
43373
43067
|
* manager — the agent holds no read on the privileged members KV. `undefined` ⇒ NO control responder
|
|
@@ -43710,7 +43404,7 @@ var CotalEndpoint = class _CotalEndpoint extends EventEmitter {
|
|
|
43710
43404
|
filter_subject: subject,
|
|
43711
43405
|
ack_policy: import_jetstream13.AckPolicy.None,
|
|
43712
43406
|
mem_storage: true,
|
|
43713
|
-
inactive_threshold: (0,
|
|
43407
|
+
inactive_threshold: (0, import_transport_node14.nanos)(3e4),
|
|
43714
43408
|
..."time" in start ? { deliver_policy: import_jetstream13.DeliverPolicy.StartTime, opt_start_time: start.time.toISOString() } : { deliver_policy: import_jetstream13.DeliverPolicy.StartSequence, opt_start_seq: start.seq }
|
|
43715
43409
|
});
|
|
43716
43410
|
try {
|
|
@@ -44071,7 +43765,7 @@ function authOpts(a) {
|
|
|
44071
43765
|
if (!a.sentinelCreds)
|
|
44072
43766
|
throw new Error("user-mode bearer requires sentinelCreds");
|
|
44073
43767
|
return {
|
|
44074
|
-
authenticator: [(0,
|
|
43768
|
+
authenticator: [(0, import_transport_node14.credsAuthenticator)(new TextEncoder().encode(a.sentinelCreds)), (0, import_transport_node14.tokenAuthenticator)(a.bearer)],
|
|
44075
43769
|
tls
|
|
44076
43770
|
};
|
|
44077
43771
|
}
|
|
@@ -44079,7 +43773,7 @@ function authOpts(a) {
|
|
|
44079
43773
|
if (a.token || a.user || a.pass)
|
|
44080
43774
|
throw new Error("creds are mutually exclusive with token/user/pass auth");
|
|
44081
43775
|
const creds = a.creds;
|
|
44082
|
-
const authenticator = typeof creds === "function" ? (nonce3) => (0,
|
|
43776
|
+
const authenticator = typeof creds === "function" ? (nonce3) => (0, import_transport_node14.credsAuthenticator)(new TextEncoder().encode(creds()))(nonce3) : (0, import_transport_node14.credsAuthenticator)(new TextEncoder().encode(creds));
|
|
44083
43777
|
return { authenticator, tls };
|
|
44084
43778
|
}
|
|
44085
43779
|
return { token: a.token, user: a.user, pass: a.pass, tls };
|
|
@@ -44114,25 +43808,32 @@ function decodeBearerPrincipal(bearer) {
|
|
|
44114
43808
|
return { owner, actor };
|
|
44115
43809
|
}
|
|
44116
43810
|
function describeStatusError(err2) {
|
|
44117
|
-
if (err2 instanceof
|
|
43811
|
+
if (err2 instanceof import_transport_node14.PermissionViolationError) {
|
|
44118
43812
|
return new Error(`NATS permission denied: cannot ${err2.operation} "${err2.subject}" - check this endpoint's ACLs (a denied peer looks "absent" rather than blocked)`, { cause: err2 });
|
|
44119
43813
|
}
|
|
44120
43814
|
return err2;
|
|
44121
43815
|
}
|
|
44122
43816
|
function isPermissionDenied(e) {
|
|
44123
|
-
if (e instanceof
|
|
43817
|
+
if (e instanceof import_transport_node14.PermissionViolationError)
|
|
44124
43818
|
return true;
|
|
44125
|
-
if (e?.cause instanceof
|
|
43819
|
+
if (e?.cause instanceof import_transport_node14.PermissionViolationError)
|
|
44126
43820
|
return true;
|
|
44127
43821
|
return /permissions?\s+violation/i.test(String(e?.message ?? ""));
|
|
44128
43822
|
}
|
|
44129
43823
|
function isPublishPermissionDenied(e) {
|
|
44130
|
-
const typed = e instanceof
|
|
43824
|
+
const typed = e instanceof import_transport_node14.PermissionViolationError ? e : e?.cause instanceof import_transport_node14.PermissionViolationError ? e.cause : void 0;
|
|
44131
43825
|
return typed?.operation === "publish";
|
|
44132
43826
|
}
|
|
43827
|
+
function wsServers(servers) {
|
|
43828
|
+
return /^wss?:\/\//i.test((servers.split(",")[0] ?? "").trim());
|
|
43829
|
+
}
|
|
44133
43830
|
function dialerFor(servers) {
|
|
44134
|
-
|
|
44135
|
-
|
|
43831
|
+
if (!wsServers(servers))
|
|
43832
|
+
return import_transport_node14.connect;
|
|
43833
|
+
return ((opts) => {
|
|
43834
|
+
const { tls: _tls, ...rest } = opts ?? {};
|
|
43835
|
+
return (0, import_nats_core.wsconnect)(rest);
|
|
43836
|
+
});
|
|
44136
43837
|
}
|
|
44137
43838
|
function hostPort(server) {
|
|
44138
43839
|
const raw = (server.split(",")[0] ?? "").trim();
|
|
@@ -44197,13 +43898,325 @@ function classifyProbeFailure(e, opts) {
|
|
|
44197
43898
|
} catch {
|
|
44198
43899
|
}
|
|
44199
43900
|
}
|
|
44200
|
-
if (e instanceof
|
|
43901
|
+
if (e instanceof import_transport_node14.UserAuthenticationExpiredError)
|
|
44201
43902
|
return { ok: false, reason: "stale-auth" };
|
|
44202
|
-
if (e instanceof
|
|
43903
|
+
if (e instanceof import_transport_node14.AuthorizationError)
|
|
44203
43904
|
return { ok: false, reason: "auth-required" };
|
|
44204
43905
|
return { ok: false, reason: "unreachable" };
|
|
44205
43906
|
}
|
|
44206
43907
|
|
|
43908
|
+
// ../../packages/core/dist/channels.js
|
|
43909
|
+
function parseDuration(s) {
|
|
43910
|
+
const m = /^(\d+)(s|m|h|d)$/.exec(s.trim());
|
|
43911
|
+
if (!m)
|
|
43912
|
+
throw new Error(`invalid duration "${s}" - expected <number><s|m|h|d>, e.g. "24h"`);
|
|
43913
|
+
const n = Number(m[1]);
|
|
43914
|
+
const unit = { s: 1e3, m: 6e4, h: 36e5, d: 864e5 }[m[2]];
|
|
43915
|
+
return n * unit;
|
|
43916
|
+
}
|
|
43917
|
+
function effectiveReplay(cfg, defaults) {
|
|
43918
|
+
return cfg?.replay ?? defaults?.replay ?? true;
|
|
43919
|
+
}
|
|
43920
|
+
function effectiveReplayWindowMs(cfg, defaults) {
|
|
43921
|
+
const w = cfg?.replayWindow ?? defaults?.replayWindow;
|
|
43922
|
+
return w === void 0 ? void 0 : parseDuration(w);
|
|
43923
|
+
}
|
|
43924
|
+
function effectiveDeliveryClass(cfg, defaults) {
|
|
43925
|
+
return cfg?.deliveryClass ?? defaults?.deliveryClass ?? "durable";
|
|
43926
|
+
}
|
|
43927
|
+
async function openChannelRegistry(nc, space, opts = {}) {
|
|
43928
|
+
const kvm = new import_kv7.Kvm(nc);
|
|
43929
|
+
return opts.create ? kvm.create(channelBucket(space)) : kvm.open(channelBucket(space));
|
|
43930
|
+
}
|
|
43931
|
+
async function readChannelConfig(kv, channel) {
|
|
43932
|
+
return decode2(kv, channel);
|
|
43933
|
+
}
|
|
43934
|
+
async function readChannelDefaults(kv) {
|
|
43935
|
+
return decode2(kv, CHANNEL_DEFAULTS_KEY);
|
|
43936
|
+
}
|
|
43937
|
+
async function decode2(kv, key) {
|
|
43938
|
+
const e = await kv.get(key);
|
|
43939
|
+
if (!e || e.operation === "DEL" || e.operation === "PURGE")
|
|
43940
|
+
return void 0;
|
|
43941
|
+
try {
|
|
43942
|
+
return e.json();
|
|
43943
|
+
} catch {
|
|
43944
|
+
return void 0;
|
|
43945
|
+
}
|
|
43946
|
+
}
|
|
43947
|
+
|
|
43948
|
+
// ../../packages/core/dist/membership-feed.js
|
|
43949
|
+
var import_transport_node16 = __toESM(require_transport_node(), 1);
|
|
43950
|
+
var import_kv8 = __toESM(require_mod6(), 1);
|
|
43951
|
+
|
|
43952
|
+
// ../../packages/core/dist/evict.js
|
|
43953
|
+
var import_transport_node17 = __toESM(require_transport_node(), 1);
|
|
43954
|
+
|
|
43955
|
+
// ../../packages/core/dist/agent-file.js
|
|
43956
|
+
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
43957
|
+
var import_yaml = __toESM(require_dist(), 1);
|
|
43958
|
+
function parseFrontmatter(src, path) {
|
|
43959
|
+
let doc;
|
|
43960
|
+
try {
|
|
43961
|
+
doc = (0, import_yaml.parse)(src);
|
|
43962
|
+
} catch (e) {
|
|
43963
|
+
throw new Error(`agent file ${path}: invalid YAML frontmatter; ${e.message}`);
|
|
43964
|
+
}
|
|
43965
|
+
if (doc === null || doc === void 0)
|
|
43966
|
+
return {};
|
|
43967
|
+
if (typeof doc !== "object" || Array.isArray(doc))
|
|
43968
|
+
throw new Error(`agent file ${path}: frontmatter must be a YAML mapping (key: value pairs)`);
|
|
43969
|
+
return doc;
|
|
43970
|
+
}
|
|
43971
|
+
function loadAgentFile(path) {
|
|
43972
|
+
const src = readFileSync(path, "utf8");
|
|
43973
|
+
const m = /^---\n([\s\S]*?)\n---\n?([\s\S]*)$/.exec(src);
|
|
43974
|
+
if (!m)
|
|
43975
|
+
throw new Error(`agent file ${path}: missing "---" frontmatter block`);
|
|
43976
|
+
const fm = parseFrontmatter(m[1], path);
|
|
43977
|
+
const persona = m[2].trim();
|
|
43978
|
+
const str2 = (k) => {
|
|
43979
|
+
const v = fm[k];
|
|
43980
|
+
if (v === void 0 || v === null)
|
|
43981
|
+
return void 0;
|
|
43982
|
+
if (typeof v === "object")
|
|
43983
|
+
throw new Error(`agent file ${path}: "${k}" must be a scalar`);
|
|
43984
|
+
return String(v);
|
|
43985
|
+
};
|
|
43986
|
+
const list = (k) => {
|
|
43987
|
+
const v = fm[k];
|
|
43988
|
+
if (v === void 0 || v === null)
|
|
43989
|
+
return void 0;
|
|
43990
|
+
return (Array.isArray(v) ? v : [v]).map((x) => {
|
|
43991
|
+
if (x === null || typeof x === "object")
|
|
43992
|
+
throw new Error(`agent file ${path}: "${k}" list items must be scalars`);
|
|
43993
|
+
return String(x);
|
|
43994
|
+
});
|
|
43995
|
+
};
|
|
43996
|
+
const name = str2("name");
|
|
43997
|
+
if (!name)
|
|
43998
|
+
throw new Error(`agent file ${path}: "name" is required`);
|
|
43999
|
+
assertValidName(name);
|
|
44000
|
+
const kind = str2("kind");
|
|
44001
|
+
if (kind && kind !== "agent" && kind !== "endpoint")
|
|
44002
|
+
throw new Error(`agent file ${path}: "kind" must be "agent" or "endpoint"`);
|
|
44003
|
+
for (const old of ["channels", "publish"])
|
|
44004
|
+
if (old in fm)
|
|
44005
|
+
throw new Error(`agent file ${path}: "${old}" was renamed - use "subscribe"/"allowSubscribe" (read) and "allowPublish" (post)`);
|
|
44006
|
+
const subscribe = list("subscribe");
|
|
44007
|
+
const allowSubscribe = list("allowSubscribe");
|
|
44008
|
+
const allowPublish = list("allowPublish");
|
|
44009
|
+
const quiet = list("quiet");
|
|
44010
|
+
const muted = list("muted");
|
|
44011
|
+
for (const ch of [...subscribe ?? [], ...allowSubscribe ?? [], ...allowPublish ?? []])
|
|
44012
|
+
try {
|
|
44013
|
+
assertValidChannel(ch);
|
|
44014
|
+
} catch (e) {
|
|
44015
|
+
throw new Error(`agent file ${path}: ${e.message}`);
|
|
44016
|
+
}
|
|
44017
|
+
const effSubscribe = subscribe ?? [];
|
|
44018
|
+
const effAllow = allowSubscribe?.length ? allowSubscribe : effSubscribe;
|
|
44019
|
+
for (const ch of effSubscribe)
|
|
44020
|
+
if (!channelInAllow(effAllow, ch))
|
|
44021
|
+
throw new Error(`agent file ${path}: subscribe channel "${ch}" is not within allowSubscribe [${effAllow.join(", ")}]`);
|
|
44022
|
+
const both = (quiet ?? []).filter((c) => (muted ?? []).includes(c));
|
|
44023
|
+
if (both.length)
|
|
44024
|
+
throw new Error(`agent file ${path}: channel(s) [${both.join(", ")}] are in both quiet and muted - pick one`);
|
|
44025
|
+
for (const [field, chans] of [["quiet", quiet], ["muted", muted]])
|
|
44026
|
+
for (const ch of chans ?? []) {
|
|
44027
|
+
try {
|
|
44028
|
+
assertValidChannel(ch);
|
|
44029
|
+
} catch (e) {
|
|
44030
|
+
throw new Error(`agent file ${path}: ${e.message}`);
|
|
44031
|
+
}
|
|
44032
|
+
if (!isConcreteChannel(ch))
|
|
44033
|
+
throw new Error(`agent file ${path}: ${field} channel "${ch}" must be a concrete channel (no wildcard)`);
|
|
44034
|
+
if (!channelInAllow(effAllow, ch))
|
|
44035
|
+
throw new Error(`agent file ${path}: ${field} channel "${ch}" is not within your read ACL / allowSubscribe [${effAllow.join(", ")}]`);
|
|
44036
|
+
}
|
|
44037
|
+
const launchOptionsRaw = fm["launchOptions"];
|
|
44038
|
+
let launchOptions;
|
|
44039
|
+
if (launchOptionsRaw !== void 0 && launchOptionsRaw !== null) {
|
|
44040
|
+
if (typeof launchOptionsRaw !== "object" || Array.isArray(launchOptionsRaw))
|
|
44041
|
+
throw new Error(`agent file ${path}: "launchOptions" must be a mapping of key: value pairs`);
|
|
44042
|
+
launchOptions = launchOptionsRaw;
|
|
44043
|
+
}
|
|
44044
|
+
const known = /* @__PURE__ */ new Set(["name", "role", "kind", "description", "tags", "subscribe", "allowSubscribe", "allowPublish", "quiet", "muted", "model", "variant", "launchOptions", "capabilities", "owner"]);
|
|
44045
|
+
const meta3 = {};
|
|
44046
|
+
for (const [k, v] of Object.entries(fm))
|
|
44047
|
+
if (!known.has(k) && v !== null && typeof v !== "object")
|
|
44048
|
+
meta3[k] = String(v);
|
|
44049
|
+
return {
|
|
44050
|
+
name,
|
|
44051
|
+
role: str2("role"),
|
|
44052
|
+
kind,
|
|
44053
|
+
description: str2("description"),
|
|
44054
|
+
tags: list("tags"),
|
|
44055
|
+
subscribe,
|
|
44056
|
+
allowSubscribe,
|
|
44057
|
+
allowPublish,
|
|
44058
|
+
quiet,
|
|
44059
|
+
muted,
|
|
44060
|
+
model: str2("model"),
|
|
44061
|
+
variant: str2("variant"),
|
|
44062
|
+
launchOptions,
|
|
44063
|
+
capabilities: list("capabilities"),
|
|
44064
|
+
owner: str2("owner"),
|
|
44065
|
+
meta: Object.keys(meta3).length ? meta3 : void 0,
|
|
44066
|
+
persona: persona || void 0
|
|
44067
|
+
};
|
|
44068
|
+
}
|
|
44069
|
+
|
|
44070
|
+
// ../../packages/core/dist/fs-safe.js
|
|
44071
|
+
import { lstatSync, mkdirSync as mkdirSync2, unlinkSync } from "node:fs";
|
|
44072
|
+
import { join } from "node:path";
|
|
44073
|
+
function ensureDirNoSymlink(parent, ...segments) {
|
|
44074
|
+
let dir = parent;
|
|
44075
|
+
for (const seg of segments) {
|
|
44076
|
+
dir = join(dir, seg);
|
|
44077
|
+
let st;
|
|
44078
|
+
try {
|
|
44079
|
+
st = lstatSync(dir);
|
|
44080
|
+
} catch (e) {
|
|
44081
|
+
if (e.code === "ENOENT") {
|
|
44082
|
+
mkdirSync2(dir, { mode: 448 });
|
|
44083
|
+
continue;
|
|
44084
|
+
}
|
|
44085
|
+
throw e;
|
|
44086
|
+
}
|
|
44087
|
+
if (st.isSymbolicLink())
|
|
44088
|
+
throw new Error(`refusing to write under "${dir}": it is a symlink`);
|
|
44089
|
+
if (!st.isDirectory())
|
|
44090
|
+
throw new Error(`refusing to write under "${dir}": not a directory`);
|
|
44091
|
+
}
|
|
44092
|
+
return dir;
|
|
44093
|
+
}
|
|
44094
|
+
|
|
44095
|
+
// ../../packages/core/dist/secret-fs.js
|
|
44096
|
+
import { chmodSync, mkdirSync as mkdirSync3, renameSync, unlinkSync as unlinkSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
44097
|
+
import { execFileSync } from "node:child_process";
|
|
44098
|
+
import { join as join2 } from "node:path";
|
|
44099
|
+
var isWin = process.platform === "win32";
|
|
44100
|
+
function sys32(exe) {
|
|
44101
|
+
const root = process.env.SystemRoot || process.env.windir || "C:\\Windows";
|
|
44102
|
+
return join2(root, "System32", exe);
|
|
44103
|
+
}
|
|
44104
|
+
var cachedSid;
|
|
44105
|
+
function ownerSid() {
|
|
44106
|
+
if (cachedSid)
|
|
44107
|
+
return cachedSid;
|
|
44108
|
+
const out = execFileSync(sys32("whoami.exe"), ["/user", "/fo", "csv", "/nh"], { encoding: "utf8" });
|
|
44109
|
+
const sid = out.trim().split(",").pop()?.replace(/^"|"$/g, "").trim();
|
|
44110
|
+
if (!sid || !/^S-1-/.test(sid))
|
|
44111
|
+
throw new Error(`could not determine the current user's SID from \`whoami\` (got: ${out.trim()})`);
|
|
44112
|
+
cachedSid = sid;
|
|
44113
|
+
return sid;
|
|
44114
|
+
}
|
|
44115
|
+
var BROAD_SIDS = ["S-1-1-0", "S-1-5-11", "S-1-5-32-545"];
|
|
44116
|
+
function hardenPrivate(path, kind) {
|
|
44117
|
+
if (!isWin) {
|
|
44118
|
+
chmodSync(path, kind === "dir" ? 448 : 384);
|
|
44119
|
+
return;
|
|
44120
|
+
}
|
|
44121
|
+
const perm = kind === "dir" ? "(OI)(CI)(F)" : "(F)";
|
|
44122
|
+
const removeBroad = BROAD_SIDS.flatMap((sid) => ["/remove:g", `*${sid}`]);
|
|
44123
|
+
const grant = (sid) => ["/grant:r", `*${sid}:${perm}`];
|
|
44124
|
+
try {
|
|
44125
|
+
execFileSync(sys32("icacls.exe"), [
|
|
44126
|
+
path,
|
|
44127
|
+
"/inheritance:r",
|
|
44128
|
+
...removeBroad,
|
|
44129
|
+
...grant(ownerSid()),
|
|
44130
|
+
...grant("S-1-5-18"),
|
|
44131
|
+
...grant("S-1-5-32-544")
|
|
44132
|
+
], { stdio: ["ignore", "ignore", "pipe"] });
|
|
44133
|
+
} catch (e) {
|
|
44134
|
+
throw new Error(`failed to harden ${kind} "${path}" to private via icacls: ${e.message.trim()}. Cotal will not leave a secret with a permissive ACL - ensure the path is on an NTFS volume and %SystemRoot%\\System32\\icacls.exe is available.`);
|
|
44135
|
+
}
|
|
44136
|
+
}
|
|
44137
|
+
|
|
44138
|
+
// ../../packages/core/dist/launch-material.js
|
|
44139
|
+
import { mkdtempSync, readFileSync as readFileSync2, realpathSync, rmSync, rmdirSync, statSync } from "node:fs";
|
|
44140
|
+
import { tmpdir } from "node:os";
|
|
44141
|
+
import { basename, dirname, join as join3, resolve } from "node:path";
|
|
44142
|
+
var DIR_PREFIX = "cotal-launch-";
|
|
44143
|
+
var MATERIAL_FILE = "material.json";
|
|
44144
|
+
var LAUNCH_MATERIAL_ENV = "COTAL_LAUNCH_MATERIAL";
|
|
44145
|
+
function readLaunchMaterial(path) {
|
|
44146
|
+
let raw;
|
|
44147
|
+
try {
|
|
44148
|
+
if (process.platform !== "win32") {
|
|
44149
|
+
const mode = statSync(path).mode & 511;
|
|
44150
|
+
if (mode & 63)
|
|
44151
|
+
throw new Error(`is readable beyond its owner (mode ${mode.toString(8)}) - refusing to read connection material out of a file other local users can open`);
|
|
44152
|
+
}
|
|
44153
|
+
raw = readFileSync2(path, "utf8");
|
|
44154
|
+
} catch (e) {
|
|
44155
|
+
throw new Error(`launch material: cannot read ${path} (${e instanceof Error ? e.message : String(e)})`);
|
|
44156
|
+
}
|
|
44157
|
+
let parsed;
|
|
44158
|
+
try {
|
|
44159
|
+
parsed = JSON.parse(raw);
|
|
44160
|
+
} catch {
|
|
44161
|
+
throw new Error(`launch material: ${path} is not valid JSON`);
|
|
44162
|
+
}
|
|
44163
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
|
|
44164
|
+
throw new Error(`launch material: ${path} must contain a JSON object`);
|
|
44165
|
+
return validate(parsed, path);
|
|
44166
|
+
}
|
|
44167
|
+
function validate(raw, path) {
|
|
44168
|
+
const material = {};
|
|
44169
|
+
const str2 = (key) => {
|
|
44170
|
+
const v = raw[key];
|
|
44171
|
+
if (v === void 0)
|
|
44172
|
+
return;
|
|
44173
|
+
if (typeof v !== "string" || !v.trim())
|
|
44174
|
+
throw new Error(`launch material: ${path} has a ${key} that is not a non-empty string`);
|
|
44175
|
+
material[key] = v;
|
|
44176
|
+
};
|
|
44177
|
+
str2("servers");
|
|
44178
|
+
str2("creds");
|
|
44179
|
+
str2("token");
|
|
44180
|
+
str2("controlToken");
|
|
44181
|
+
if (raw.userAuth !== void 0) {
|
|
44182
|
+
const u = raw.userAuth;
|
|
44183
|
+
if (typeof u !== "object" || u === null || Array.isArray(u))
|
|
44184
|
+
throw new Error(`launch material: ${path} has a userAuth that is not an object`);
|
|
44185
|
+
const { owner, actor, sentinelCredsPath, bearerCmd } = u;
|
|
44186
|
+
const named = { owner, actor, sentinelCredsPath };
|
|
44187
|
+
for (const [k, v] of Object.entries(named))
|
|
44188
|
+
if (typeof v !== "string" || !v.trim())
|
|
44189
|
+
throw new Error(`launch material: ${path} has a userAuth.${k} that is not a non-empty string`);
|
|
44190
|
+
if (!Array.isArray(bearerCmd) || bearerCmd.length === 0 || !bearerCmd.every((a) => typeof a === "string" && a))
|
|
44191
|
+
throw new Error(`launch material: ${path} has a userAuth.bearerCmd that is not a non-empty array of strings`);
|
|
44192
|
+
material.userAuth = {
|
|
44193
|
+
owner,
|
|
44194
|
+
actor,
|
|
44195
|
+
sentinelCredsPath,
|
|
44196
|
+
bearerCmd
|
|
44197
|
+
};
|
|
44198
|
+
}
|
|
44199
|
+
if (Object.keys(material).length === 0)
|
|
44200
|
+
throw new Error(`launch material: ${path} carries nothing this reader recognises. A launch that references material and supplies none is a broken launcher, not an open-mode launch, so it is refused rather than defaulted.`);
|
|
44201
|
+
return material;
|
|
44202
|
+
}
|
|
44203
|
+
function discardLaunchMaterial(path) {
|
|
44204
|
+
const file2 = resolve(path);
|
|
44205
|
+
try {
|
|
44206
|
+
rmSync(file2, { force: true });
|
|
44207
|
+
} catch {
|
|
44208
|
+
}
|
|
44209
|
+
const dir = dirname(file2);
|
|
44210
|
+
if (basename(file2) !== MATERIAL_FILE || !basename(dir).startsWith(DIR_PREFIX))
|
|
44211
|
+
return;
|
|
44212
|
+
try {
|
|
44213
|
+
if (realpathSync(dirname(dir)) !== realpathSync(tmpdir()))
|
|
44214
|
+
return;
|
|
44215
|
+
rmdirSync(dir);
|
|
44216
|
+
} catch {
|
|
44217
|
+
}
|
|
44218
|
+
}
|
|
44219
|
+
|
|
44207
44220
|
// ../../packages/core/dist/spaces.js
|
|
44208
44221
|
var import_transport_node18 = __toESM(require_transport_node(), 1);
|
|
44209
44222
|
var import_jetstream15 = __toESM(require_mod4(), 1);
|
|
@@ -44407,7 +44420,7 @@ function configFromEnv(env = process.env) {
|
|
|
44407
44420
|
if (!name)
|
|
44408
44421
|
throw new Error("COTAL_NAME, COTAL_AGENT_FILE or COTAL_LINK is required \u2014 a Cotal session needs an explicit identity from its launcher");
|
|
44409
44422
|
const subscribe = splitList(env.COTAL_SUBSCRIBE);
|
|
44410
|
-
const resolvedSubscribe = subscribe.length ? subscribe : def?.subscribe ?? link?.channels ?? [
|
|
44423
|
+
const resolvedSubscribe = subscribe.length ? subscribe : def?.subscribe ?? link?.channels ?? [];
|
|
44411
44424
|
const allowSub = splitList(env.COTAL_ALLOW_SUBSCRIBE);
|
|
44412
44425
|
const resolvedAllowSub = allowSub.length ? allowSub : def?.allowSubscribe ?? resolvedSubscribe;
|
|
44413
44426
|
for (const ch of resolvedSubscribe)
|
|
@@ -62043,7 +62056,7 @@ config(en_default());
|
|
|
62043
62056
|
|
|
62044
62057
|
// ../connector-core/dist/docs-bundle.generated.js
|
|
62045
62058
|
var DOCS_BUNDLE = {
|
|
62046
|
-
"version": "0.
|
|
62059
|
+
"version": "0.28.1",
|
|
62047
62060
|
"generatedFrom": "docs/*.md + SPEC.md + spec/cotal-lang.md + spec/cotal.schema.json",
|
|
62048
62061
|
"pages": [
|
|
62049
62062
|
{
|
package/dist/index.js
CHANGED
|
@@ -14831,7 +14831,7 @@ import { isConcreteChannel as isConcreteChannel3, channelInAllow as channelInAll
|
|
|
14831
14831
|
|
|
14832
14832
|
// ../connector-core/dist/docs-bundle.generated.js
|
|
14833
14833
|
var DOCS_BUNDLE = {
|
|
14834
|
-
"version": "0.
|
|
14834
|
+
"version": "0.28.1",
|
|
14835
14835
|
"generatedFrom": "docs/*.md + SPEC.md + spec/cotal-lang.md + spec/cotal.schema.json",
|
|
14836
14836
|
"pages": [
|
|
14837
14837
|
{
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cotal-ai/connector-codex",
|
|
3
3
|
"description": "Cotal connector for OpenAI Codex: a host-mode peer driving codex app-server, with Codex's own TUI attached and the cotal_* tools served over a loopback MCP endpoint.",
|
|
4
|
-
"version": "0.28.
|
|
4
|
+
"version": "0.28.1",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
|
-
"@cotal-ai/core": "0.
|
|
21
|
+
"@cotal-ai/core": ">=0.1.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"tsx": "^4.22.4",
|
|
28
28
|
"ws": "^8.21.0",
|
|
29
29
|
"zod": "^4.4.3",
|
|
30
|
-
"@cotal-ai/
|
|
31
|
-
"@cotal-ai/
|
|
32
|
-
"@cotal-ai/
|
|
30
|
+
"@cotal-ai/core": "0.28.1",
|
|
31
|
+
"@cotal-ai/smoke-kit": "0.0.0",
|
|
32
|
+
"@cotal-ai/connector-core": "0.28.1"
|
|
33
33
|
},
|
|
34
34
|
"files": [
|
|
35
35
|
"dist"
|