orionfold-relay 0.17.0 → 0.18.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/cli.js CHANGED
@@ -1177,14 +1177,16 @@ var init_detect = __esm({
1177
1177
  var types_exports = {};
1178
1178
  __export(types_exports, {
1179
1179
  CAPABILITY_VALUES: () => CAPABILITY_VALUES,
1180
+ CURRENT_PLUGIN_API_VERSION: () => CURRENT_PLUGIN_API_VERSION,
1180
1181
  ORIGIN_VALUES: () => ORIGIN_VALUES,
1181
1182
  PluginManifestSchema: () => PluginManifestSchema
1182
1183
  });
1183
1184
  import { z } from "zod";
1184
- var CAPABILITY_VALUES, ORIGIN_VALUES, PrimitivesBundleManifestSchema, ChatToolsPluginManifestSchema, PluginManifestSchema;
1185
+ var CURRENT_PLUGIN_API_VERSION, CAPABILITY_VALUES, ORIGIN_VALUES, PrimitivesBundleManifestSchema, ChatToolsPluginManifestSchema, PluginManifestSchema;
1185
1186
  var init_types = __esm({
1186
1187
  "src/lib/plugins/sdk/types.ts"() {
1187
1188
  "use strict";
1189
+ CURRENT_PLUGIN_API_VERSION = "0.17";
1188
1190
  CAPABILITY_VALUES = ["fs", "net", "child_process", "env"];
1189
1191
  ORIGIN_VALUES = ["ainative-internal", "third-party"];
1190
1192
  PrimitivesBundleManifestSchema = z.object({
@@ -1230,16 +1232,16 @@ function computeHash(content) {
1230
1232
  function safePreview(content) {
1231
1233
  return content.slice(0, MAX_PREVIEW_CHARS).trim();
1232
1234
  }
1233
- function safeStat(path20) {
1235
+ function safeStat(path21) {
1234
1236
  try {
1235
- return statSync2(path20);
1237
+ return statSync2(path21);
1236
1238
  } catch {
1237
1239
  return null;
1238
1240
  }
1239
1241
  }
1240
- function safeReadFile(path20) {
1242
+ function safeReadFile(path21) {
1241
1243
  try {
1242
- return readFileSync4(path20, "utf-8");
1244
+ return readFileSync4(path21, "utf-8");
1243
1245
  } catch {
1244
1246
  return null;
1245
1247
  }
@@ -3717,6 +3719,14 @@ var init_format = __esm({
3717
3719
  * The string is the unit of entitlement, version- and pack-id-agnostic.
3718
3720
  */
3719
3721
  entitlement: z3.string().min(1).optional(),
3722
+ /**
3723
+ * Premium display copy (D6). Offline strings rendered on the locked
3724
+ * gallery card — the Website still owns actual pricing. Meaningful only
3725
+ * alongside `entitlement`; harmless on a free pack.
3726
+ */
3727
+ price: z3.string().min(1).optional(),
3728
+ /** Get-license CTA target on the locked card. */
3729
+ purchaseUrl: z3.url().optional(),
3720
3730
  /** Customer slugs seeded via ensureCustomer at install. */
3721
3731
  customers: z3.array(z3.string()).default([])
3722
3732
  }).strict();
@@ -3731,6 +3741,82 @@ var init_format = __esm({
3731
3741
  }
3732
3742
  });
3733
3743
 
3744
+ // src/lib/packs/catalog.ts
3745
+ var catalog_exports = {};
3746
+ __export(catalog_exports, {
3747
+ UnknownPackNameError: () => UnknownPackNameError,
3748
+ findPackTemplate: () => findPackTemplate,
3749
+ listPackTemplates: () => listPackTemplates,
3750
+ packTemplatesDir: () => packTemplatesDir,
3751
+ resolvePackSource: () => resolvePackSource
3752
+ });
3753
+ import fs4 from "fs";
3754
+ import path4 from "path";
3755
+ function packTemplatesDir(opts2 = {}) {
3756
+ return opts2.templatesDir ?? path4.join(
3757
+ getAppRoot(import.meta.dirname, 3),
3758
+ "src",
3759
+ "lib",
3760
+ "packs",
3761
+ "templates"
3762
+ );
3763
+ }
3764
+ function listPackTemplates(opts2 = {}) {
3765
+ const dir = packTemplatesDir(opts2);
3766
+ if (!fs4.existsSync(dir)) return [];
3767
+ const out = [];
3768
+ for (const entry of fs4.readdirSync(dir, { withFileTypes: true })) {
3769
+ if (!entry.isDirectory()) continue;
3770
+ const templateDir = path4.join(dir, entry.name);
3771
+ try {
3772
+ const pack = parsePack(templateDir);
3773
+ out.push({
3774
+ id: pack.meta.id,
3775
+ dir: templateDir,
3776
+ meta: pack.meta,
3777
+ primitivesSummary: buildPrimitivesSummary(pack.manifest)
3778
+ });
3779
+ } catch (err2) {
3780
+ out.push({
3781
+ id: entry.name,
3782
+ dir: templateDir,
3783
+ error: err2 instanceof Error ? err2.message : String(err2)
3784
+ });
3785
+ }
3786
+ }
3787
+ return out.sort((a, b) => a.id.localeCompare(b.id));
3788
+ }
3789
+ function findPackTemplate(id, opts2 = {}) {
3790
+ const match = listPackTemplates(opts2).find((t) => t.id === id);
3791
+ return match && !match.error ? match : null;
3792
+ }
3793
+ function resolvePackSource(source, opts2 = {}) {
3794
+ if (fs4.existsSync(path4.resolve(source))) return source;
3795
+ if (!BARE_NAME.test(source)) return source;
3796
+ const template = findPackTemplate(source, opts2);
3797
+ if (template) return template.dir;
3798
+ const ids = listPackTemplates(opts2).filter((t) => !t.error).map((t) => t.id);
3799
+ throw new UnknownPackNameError(
3800
+ `Unknown pack "${source}". Bundled packs: ${ids.length ? ids.join(", ") : "(none)"}. Otherwise pass a folder path or git URL.`
3801
+ );
3802
+ }
3803
+ var UnknownPackNameError, BARE_NAME;
3804
+ var init_catalog = __esm({
3805
+ "src/lib/packs/catalog.ts"() {
3806
+ "use strict";
3807
+ init_app_root();
3808
+ init_registry();
3809
+ init_format();
3810
+ UnknownPackNameError = class extends Error {
3811
+ constructor(message) {
3812
+ super(message);
3813
+ this.name = "UnknownPackNameError";
3814
+ }
3815
+ };
3816
+ BARE_NAME = /^[a-z0-9][a-z0-9-]*$/;
3817
+ }
3818
+ });
3819
+
3734
3820
  // src/lib/licensing/canonicalize.ts
3735
3821
  function canonicalize(v) {
3736
3822
  if (Array.isArray(v)) {
@@ -3914,7 +4000,7 @@ __export(load_exports, {
3914
4000
  LicenseLoadError: () => LicenseLoadError,
3915
4001
  loadLicense: () => loadLicense
3916
4002
  });
3917
- import fs4 from "fs";
4003
+ import fs5 from "fs";
3918
4004
  import { fileURLToPath as fileURLToPath3 } from "url";
3919
4005
  function assertEnvelope(value, origin) {
3920
4006
  if (!value || typeof value !== "object") {
@@ -3962,7 +4048,7 @@ async function loadLicense(urlOrPath) {
3962
4048
  const filePath = urlOrPath.startsWith("file://") ? fileURLToPath3(urlOrPath) : urlOrPath;
3963
4049
  let text2;
3964
4050
  try {
3965
- text2 = fs4.readFileSync(filePath, "utf-8");
4051
+ text2 = fs5.readFileSync(filePath, "utf-8");
3966
4052
  } catch (err2) {
3967
4053
  throw new LicenseLoadError(
3968
4054
  `Could not read license file at ${filePath}.`,
@@ -3997,10 +4083,10 @@ __export(store_exports, {
3997
4083
  removeLicense: () => removeLicense,
3998
4084
  saveLicense: () => saveLicense
3999
4085
  });
4000
- import fs5 from "fs";
4001
- import path4 from "path";
4086
+ import fs6 from "fs";
4087
+ import path5 from "path";
4002
4088
  function licensesDir(opts2 = {}) {
4003
- return opts2.dir ?? path4.join(getAinativeDataDir(), "licenses");
4089
+ return opts2.dir ?? path5.join(getAinativeDataDir(), "licenses");
4004
4090
  }
4005
4091
  function readIdentity(payload) {
4006
4092
  const raw = payload.issued_to && typeof payload.issued_to === "object" ? payload.issued_to : {};
@@ -4012,7 +4098,7 @@ function readIdentity(payload) {
4012
4098
  }
4013
4099
  function buildInfo(payload, filePath, valid, reason) {
4014
4100
  return {
4015
- licenseId: String(payload.license_id ?? path4.basename(filePath, FILE_SUFFIX)),
4101
+ licenseId: String(payload.license_id ?? path5.basename(filePath, FILE_SUFFIX)),
4016
4102
  filePath,
4017
4103
  valid,
4018
4104
  ...reason ? { reason } : {},
@@ -4051,14 +4137,14 @@ function saveLicense(envelope, opts2 = {}) {
4051
4137
  throw new LicenseStoreError(`License not saved: ${term.detail}`);
4052
4138
  }
4053
4139
  const dir = licensesDir(opts2);
4054
- const filePath = path4.join(dir, `${licenseId}${FILE_SUFFIX}`);
4140
+ const filePath = path5.join(dir, `${licenseId}${FILE_SUFFIX}`);
4055
4141
  try {
4056
- fs5.mkdirSync(dir, { recursive: true });
4057
- const tmp = path4.join(dir, `.${licenseId}.${process.pid}.tmp`);
4058
- fs5.writeFileSync(tmp, JSON.stringify(envelope, null, 2) + "\n", {
4142
+ fs6.mkdirSync(dir, { recursive: true });
4143
+ const tmp = path5.join(dir, `.${licenseId}.${process.pid}.tmp`);
4144
+ fs6.writeFileSync(tmp, JSON.stringify(envelope, null, 2) + "\n", {
4059
4145
  mode: 384
4060
4146
  });
4061
- fs5.renameSync(tmp, filePath);
4147
+ fs6.renameSync(tmp, filePath);
4062
4148
  } catch (err2) {
4063
4149
  throw new LicenseStoreError(
4064
4150
  `Could not write license to ${filePath}: ${err2 instanceof Error ? err2.message : String(err2)}`,
@@ -4070,7 +4156,7 @@ function saveLicense(envelope, opts2 = {}) {
4070
4156
  function readEnvelope(filePath) {
4071
4157
  let text2;
4072
4158
  try {
4073
- text2 = fs5.readFileSync(filePath, "utf-8");
4159
+ text2 = fs6.readFileSync(filePath, "utf-8");
4074
4160
  } catch (err2) {
4075
4161
  return {
4076
4162
  error: `unreadable: ${err2 instanceof Error ? err2.message : String(err2)}`
@@ -4089,11 +4175,11 @@ function readEnvelope(filePath) {
4089
4175
  function listLicenses(opts2 = {}) {
4090
4176
  const dir = licensesDir(opts2);
4091
4177
  const now = opts2.now ?? /* @__PURE__ */ new Date();
4092
- if (!fs5.existsSync(dir)) return [];
4178
+ if (!fs6.existsSync(dir)) return [];
4093
4179
  const out = [];
4094
- for (const file of fs5.readdirSync(dir).sort()) {
4180
+ for (const file of fs6.readdirSync(dir).sort()) {
4095
4181
  if (!file.endsWith(FILE_SUFFIX)) continue;
4096
- const filePath = path4.join(dir, file);
4182
+ const filePath = path5.join(dir, file);
4097
4183
  const read = readEnvelope(filePath);
4098
4184
  if ("error" in read) {
4099
4185
  out.push(buildInfo({}, filePath, false, read.error));
@@ -4120,10 +4206,10 @@ function listLicenses(opts2 = {}) {
4120
4206
  function findEntitledLicense(entitlement, opts2 = {}) {
4121
4207
  const dir = licensesDir(opts2);
4122
4208
  const now = opts2.now ?? /* @__PURE__ */ new Date();
4123
- if (!fs5.existsSync(dir)) return null;
4124
- for (const file of fs5.readdirSync(dir).sort()) {
4209
+ if (!fs6.existsSync(dir)) return null;
4210
+ for (const file of fs6.readdirSync(dir).sort()) {
4125
4211
  if (!file.endsWith(FILE_SUFFIX)) continue;
4126
- const filePath = path4.join(dir, file);
4212
+ const filePath = path5.join(dir, file);
4127
4213
  const read = readEnvelope(filePath);
4128
4214
  if ("error" in read) continue;
4129
4215
  try {
@@ -4149,10 +4235,10 @@ function findEntitledLicense(entitlement, opts2 = {}) {
4149
4235
  }
4150
4236
  function removeLicense(licenseId, opts2 = {}) {
4151
4237
  if (!SAFE_ID.test(licenseId)) return false;
4152
- const filePath = path4.join(licensesDir(opts2), `${licenseId}${FILE_SUFFIX}`);
4153
- if (!fs5.existsSync(filePath)) return false;
4238
+ const filePath = path5.join(licensesDir(opts2), `${licenseId}${FILE_SUFFIX}`);
4239
+ if (!fs6.existsSync(filePath)) return false;
4154
4240
  try {
4155
- fs5.rmSync(filePath);
4241
+ fs6.rmSync(filePath);
4156
4242
  } catch (err2) {
4157
4243
  throw new LicenseStoreError(
4158
4244
  `Could not remove license ${licenseId}: ${err2 instanceof Error ? err2.message : String(err2)}`,
@@ -4211,8 +4297,8 @@ __export(compose_integration_exports, {
4211
4297
  extractAppIdFromArtifactId: () => extractAppIdFromArtifactId,
4212
4298
  upsertAppManifest: () => upsertAppManifest
4213
4299
  });
4214
- import fs6 from "fs";
4215
- import path5 from "path";
4300
+ import fs7 from "fs";
4301
+ import path6 from "path";
4216
4302
  import yaml3 from "js-yaml";
4217
4303
  import { eq as eq3 } from "drizzle-orm";
4218
4304
  function titleCase(slug) {
@@ -4233,10 +4319,10 @@ async function ensureAppProject(appId, appsDir = getAinativeAppsDir()) {
4233
4319
  return { projectId: appId, created: true };
4234
4320
  }
4235
4321
  function resolveAppName(appId, appsDir) {
4236
- const manifestPath = path5.join(appsDir, appId, "manifest.yaml");
4237
- if (fs6.existsSync(manifestPath)) {
4322
+ const manifestPath = path6.join(appsDir, appId, "manifest.yaml");
4323
+ if (fs7.existsSync(manifestPath)) {
4238
4324
  try {
4239
- const parsed = yaml3.load(fs6.readFileSync(manifestPath, "utf-8"));
4325
+ const parsed = yaml3.load(fs7.readFileSync(manifestPath, "utf-8"));
4240
4326
  const result = AppManifestSchema.safeParse(parsed);
4241
4327
  if (result.success) return result.data.name;
4242
4328
  } catch {
@@ -4245,13 +4331,13 @@ function resolveAppName(appId, appsDir) {
4245
4331
  return titleCase(appId);
4246
4332
  }
4247
4333
  function upsertAppManifest(appId, artifact, displayName, appsDir = getAinativeAppsDir()) {
4248
- const appDir2 = path5.join(appsDir, appId);
4249
- const manifestPath = path5.join(appDir2, "manifest.yaml");
4250
- fs6.mkdirSync(appDir2, { recursive: true });
4334
+ const appDir2 = path6.join(appsDir, appId);
4335
+ const manifestPath = path6.join(appDir2, "manifest.yaml");
4336
+ fs7.mkdirSync(appDir2, { recursive: true });
4251
4337
  let manifest = emptyManifest(appId, displayName);
4252
- if (fs6.existsSync(manifestPath)) {
4338
+ if (fs7.existsSync(manifestPath)) {
4253
4339
  try {
4254
- const parsed = yaml3.load(fs6.readFileSync(manifestPath, "utf-8"));
4340
+ const parsed = yaml3.load(fs7.readFileSync(manifestPath, "utf-8"));
4255
4341
  const result = AppManifestSchema.safeParse(parsed);
4256
4342
  if (result.success) manifest = result.data;
4257
4343
  } catch {
@@ -4266,7 +4352,7 @@ function upsertAppManifest(appId, artifact, displayName, appsDir = getAinativeAp
4266
4352
  if (artifact.runs) entry.runs = artifact.runs;
4267
4353
  arr.push(entry);
4268
4354
  }
4269
- fs6.writeFileSync(manifestPath, yaml3.dump(manifest));
4355
+ fs7.writeFileSync(manifestPath, yaml3.dump(manifest));
4270
4356
  invalidateAppsCache();
4271
4357
  return manifest;
4272
4358
  }
@@ -4622,8 +4708,8 @@ var init_blueprint = __esm({
4622
4708
  });
4623
4709
 
4624
4710
  // src/lib/agents/runtime/catalog.ts
4625
- var catalog_exports = {};
4626
- __export(catalog_exports, {
4711
+ var catalog_exports2 = {};
4712
+ __export(catalog_exports2, {
4627
4713
  DEFAULT_AGENT_RUNTIME: () => DEFAULT_AGENT_RUNTIME,
4628
4714
  SUPPORTED_AGENT_RUNTIMES: () => SUPPORTED_AGENT_RUNTIMES,
4629
4715
  getRuntimeCapabilities: () => getRuntimeCapabilities,
@@ -4655,7 +4741,7 @@ function listRuntimeCatalog() {
4655
4741
  return SUPPORTED_AGENT_RUNTIMES.map((runtimeId) => RUNTIME_CATALOG[runtimeId]);
4656
4742
  }
4657
4743
  var SUPPORTED_AGENT_RUNTIMES, DEFAULT_AGENT_RUNTIME, RUNTIME_CATALOG;
4658
- var init_catalog = __esm({
4744
+ var init_catalog2 = __esm({
4659
4745
  "src/lib/agents/runtime/catalog.ts"() {
4660
4746
  "use strict";
4661
4747
  SUPPORTED_AGENT_RUNTIMES = [
@@ -4869,7 +4955,7 @@ var runtimeIdSchema, profileTestsSchema, canUseToolPolicySchema, profileRuntimeO
4869
4955
  var init_profile = __esm({
4870
4956
  "src/lib/validators/profile.ts"() {
4871
4957
  "use strict";
4872
- init_catalog();
4958
+ init_catalog2();
4873
4959
  runtimeIdSchema = z5.enum(SUPPORTED_AGENT_RUNTIMES);
4874
4960
  profileTestsSchema = z5.array(
4875
4961
  z5.object({
@@ -4991,29 +5077,29 @@ function resolveProfileRuntimePayload(profile, runtimeId) {
4991
5077
  var init_compatibility = __esm({
4992
5078
  "src/lib/agents/profiles/compatibility.ts"() {
4993
5079
  "use strict";
4994
- init_catalog();
5080
+ init_catalog2();
4995
5081
  }
4996
5082
  });
4997
5083
 
4998
5084
  // src/lib/agents/profiles/project-profiles.ts
4999
- import fs7 from "fs";
5000
- import path6 from "path";
5085
+ import fs8 from "fs";
5086
+ import path7 from "path";
5001
5087
  import yaml4 from "js-yaml";
5002
5088
  function getProjectSkillsSignature(skillsDir) {
5003
- if (!fs7.existsSync(skillsDir)) return "missing";
5004
- const entries = fs7.readdirSync(skillsDir, { withFileTypes: true }).filter((e) => e.isDirectory()).sort((a, b) => a.name.localeCompare(b.name));
5089
+ if (!fs8.existsSync(skillsDir)) return "missing";
5090
+ const entries = fs8.readdirSync(skillsDir, { withFileTypes: true }).filter((e) => e.isDirectory()).sort((a, b) => a.name.localeCompare(b.name));
5005
5091
  const parts = [];
5006
5092
  for (const entry of entries) {
5007
- const dir = path6.join(skillsDir, entry.name);
5093
+ const dir = path7.join(skillsDir, entry.name);
5008
5094
  parts.push(entry.name);
5009
- const yamlPath = path6.join(dir, "profile.yaml");
5010
- if (fs7.existsSync(yamlPath)) {
5011
- const s = fs7.statSync(yamlPath);
5095
+ const yamlPath = path7.join(dir, "profile.yaml");
5096
+ if (fs8.existsSync(yamlPath)) {
5097
+ const s = fs8.statSync(yamlPath);
5012
5098
  parts.push(`yaml:${s.mtimeMs}:${s.size}`);
5013
5099
  }
5014
- const skillPath = path6.join(dir, "SKILL.md");
5015
- if (fs7.existsSync(skillPath)) {
5016
- const s = fs7.statSync(skillPath);
5100
+ const skillPath = path7.join(dir, "SKILL.md");
5101
+ if (fs8.existsSync(skillPath)) {
5102
+ const s = fs8.statSync(skillPath);
5017
5103
  parts.push(`skill:${s.mtimeMs}:${s.size}`);
5018
5104
  }
5019
5105
  }
@@ -5034,8 +5120,8 @@ function parseFrontmatter(content) {
5034
5120
  return fm;
5035
5121
  }
5036
5122
  function generateMinimalProfile(skillDir, dirName, projectDir) {
5037
- const skillPath = path6.join(skillDir, "SKILL.md");
5038
- const skillMd = fs7.readFileSync(skillPath, "utf-8");
5123
+ const skillPath = path7.join(skillDir, "SKILL.md");
5124
+ const skillMd = fs8.readFileSync(skillPath, "utf-8");
5039
5125
  const fm = parseFrontmatter(skillMd);
5040
5126
  return {
5041
5127
  id: dirName,
@@ -5052,20 +5138,20 @@ function generateMinimalProfile(skillDir, dirName, projectDir) {
5052
5138
  };
5053
5139
  }
5054
5140
  function scanProjectProfiles(projectDir) {
5055
- const skillsDir = path6.join(projectDir, ".claude", "skills");
5056
- if (!fs7.existsSync(skillsDir)) return [];
5141
+ const skillsDir = path7.join(projectDir, ".claude", "skills");
5142
+ if (!fs8.existsSync(skillsDir)) return [];
5057
5143
  const signature = getProjectSkillsSignature(skillsDir);
5058
5144
  const cached = projectProfileCache.get(projectDir);
5059
5145
  if (cached && cached.signature === signature) return cached.profiles;
5060
5146
  const profiles = [];
5061
- for (const entry of fs7.readdirSync(skillsDir, { withFileTypes: true })) {
5147
+ for (const entry of fs8.readdirSync(skillsDir, { withFileTypes: true })) {
5062
5148
  if (!entry.isDirectory()) continue;
5063
- const dir = path6.join(skillsDir, entry.name);
5064
- const yamlPath = path6.join(dir, "profile.yaml");
5065
- const skillPath = path6.join(dir, "SKILL.md");
5066
- if (fs7.existsSync(yamlPath) && fs7.existsSync(skillPath)) {
5149
+ const dir = path7.join(skillsDir, entry.name);
5150
+ const yamlPath = path7.join(dir, "profile.yaml");
5151
+ const skillPath = path7.join(dir, "SKILL.md");
5152
+ if (fs8.existsSync(yamlPath) && fs8.existsSync(skillPath)) {
5067
5153
  try {
5068
- const rawYaml = fs7.readFileSync(yamlPath, "utf-8");
5154
+ const rawYaml = fs8.readFileSync(yamlPath, "utf-8");
5069
5155
  const parsed = yaml4.load(rawYaml);
5070
5156
  const result = ProfileConfigSchema.safeParse(parsed);
5071
5157
  if (!result.success) {
@@ -5076,7 +5162,7 @@ function scanProjectProfiles(projectDir) {
5076
5162
  continue;
5077
5163
  }
5078
5164
  const config = result.data;
5079
- const skillMd = fs7.readFileSync(skillPath, "utf-8");
5165
+ const skillMd = fs8.readFileSync(skillPath, "utf-8");
5080
5166
  const descMatch = skillMd.match(
5081
5167
  /^---\s*\n[\s\S]*?description:\s*(.+?)\s*\n[\s\S]*?---/
5082
5168
  );
@@ -5110,7 +5196,7 @@ function scanProjectProfiles(projectDir) {
5110
5196
  err2
5111
5197
  );
5112
5198
  }
5113
- } else if (fs7.existsSync(skillPath)) {
5199
+ } else if (fs8.existsSync(skillPath)) {
5114
5200
  try {
5115
5201
  profiles.push(generateMinimalProfile(dir, entry.name, projectDir));
5116
5202
  } catch (err2) {
@@ -5136,7 +5222,7 @@ var init_project_profiles = __esm({
5136
5222
 
5137
5223
  // src/lib/environment/profile-linker.ts
5138
5224
  import { eq as eq6, and as and2, isNull } from "drizzle-orm";
5139
- import path7 from "path";
5225
+ import path8 from "path";
5140
5226
  var init_profile_linker = __esm({
5141
5227
  "src/lib/environment/profile-linker.ts"() {
5142
5228
  "use strict";
@@ -5187,23 +5273,23 @@ var init_data = __esm({
5187
5273
  });
5188
5274
 
5189
5275
  // src/lib/agents/profiles/app-manifest-source.ts
5190
- import fs8 from "fs";
5191
- import path8 from "path";
5276
+ import fs9 from "fs";
5277
+ import path9 from "path";
5192
5278
  import yaml5 from "js-yaml";
5193
5279
  function titleCase2(slug) {
5194
5280
  return slug.split("-").filter(Boolean).map((p) => p.charAt(0).toUpperCase() + p.slice(1)).join(" ");
5195
5281
  }
5196
5282
  function loadAppManifestProfiles(appsDir, profilesDir, builtinsDir) {
5197
- if (!fs8.existsSync(appsDir)) return [];
5283
+ if (!fs9.existsSync(appsDir)) return [];
5198
5284
  const synthesized = /* @__PURE__ */ new Map();
5199
- for (const entry of fs8.readdirSync(appsDir, { withFileTypes: true })) {
5285
+ for (const entry of fs9.readdirSync(appsDir, { withFileTypes: true })) {
5200
5286
  if (!entry.isDirectory()) continue;
5201
5287
  const appId = entry.name;
5202
- const manifestPath = path8.join(appsDir, appId, "manifest.yaml");
5203
- if (!fs8.existsSync(manifestPath)) continue;
5288
+ const manifestPath = path9.join(appsDir, appId, "manifest.yaml");
5289
+ if (!fs9.existsSync(manifestPath)) continue;
5204
5290
  let manifest;
5205
5291
  try {
5206
- const parsed = yaml5.load(fs8.readFileSync(manifestPath, "utf-8"));
5292
+ const parsed = yaml5.load(fs9.readFileSync(manifestPath, "utf-8"));
5207
5293
  manifest = AppManifestSchema.safeParse(parsed);
5208
5294
  } catch (err2) {
5209
5295
  console.warn(`[app-manifest-source] Malformed manifest for ${appId}:`, err2);
@@ -5215,9 +5301,9 @@ function loadAppManifestProfiles(appsDir, profilesDir, builtinsDir) {
5215
5301
  }
5216
5302
  for (const profileRef of manifest.data.profiles ?? []) {
5217
5303
  const profileId = profileRef.id;
5218
- const userYaml = path8.join(profilesDir, profileId, "profile.yaml");
5219
- const builtinYaml = path8.join(builtinsDir, profileId, "profile.yaml");
5220
- if (fs8.existsSync(userYaml) || fs8.existsSync(builtinYaml)) continue;
5304
+ const userYaml = path9.join(profilesDir, profileId, "profile.yaml");
5305
+ const builtinYaml = path9.join(builtinsDir, profileId, "profile.yaml");
5306
+ if (fs9.existsSync(userYaml) || fs9.existsSync(builtinYaml)) continue;
5221
5307
  const existing = synthesized.get(profileId);
5222
5308
  if (existing) {
5223
5309
  if (!existing.tags.includes(appId)) {
@@ -5248,7 +5334,7 @@ function loadAppManifestProfiles(appsDir, profilesDir, builtinsDir) {
5248
5334
  var init_app_manifest_source = __esm({
5249
5335
  "src/lib/agents/profiles/app-manifest-source.ts"() {
5250
5336
  "use strict";
5251
- init_catalog();
5337
+ init_catalog2();
5252
5338
  init_registry();
5253
5339
  }
5254
5340
  });
@@ -5273,29 +5359,29 @@ __export(registry_exports2, {
5273
5359
  scanProfilesIntoMap: () => scanProfilesIntoMap,
5274
5360
  updateProfile: () => updateProfile
5275
5361
  });
5276
- import fs9 from "fs";
5362
+ import fs10 from "fs";
5277
5363
  import { homedir as homedir3 } from "os";
5278
- import path9 from "path";
5364
+ import path10 from "path";
5279
5365
  import yaml6 from "js-yaml";
5280
5366
  import { eq as eq8, and as and4 } from "drizzle-orm";
5281
5367
  function getBuiltinsDir() {
5282
5368
  return BUILTINS_DIR;
5283
5369
  }
5284
5370
  function getDirectorySignatureParts(baseDir) {
5285
- if (!fs9.existsSync(baseDir)) return [];
5286
- const entries = fs9.readdirSync(baseDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).sort((a, b) => a.name.localeCompare(b.name));
5371
+ if (!fs10.existsSync(baseDir)) return [];
5372
+ const entries = fs10.readdirSync(baseDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).sort((a, b) => a.name.localeCompare(b.name));
5287
5373
  const parts = [];
5288
5374
  for (const entry of entries) {
5289
- const dir = path9.join(baseDir, entry.name);
5290
- const yamlPath = path9.join(dir, "profile.yaml");
5291
- const skillPath = path9.join(dir, "SKILL.md");
5375
+ const dir = path10.join(baseDir, entry.name);
5376
+ const yamlPath = path10.join(dir, "profile.yaml");
5377
+ const skillPath = path10.join(dir, "SKILL.md");
5292
5378
  parts.push(entry.name);
5293
- if (fs9.existsSync(yamlPath)) {
5294
- const stats = fs9.statSync(yamlPath);
5379
+ if (fs10.existsSync(yamlPath)) {
5380
+ const stats = fs10.statSync(yamlPath);
5295
5381
  parts.push(`yaml:${stats.mtimeMs}:${stats.size}`);
5296
5382
  }
5297
- if (fs9.existsSync(skillPath)) {
5298
- const stats = fs9.statSync(skillPath);
5383
+ if (fs10.existsSync(skillPath)) {
5384
+ const stats = fs10.statSync(skillPath);
5299
5385
  parts.push(`skill:${stats.mtimeMs}:${stats.size}`);
5300
5386
  }
5301
5387
  }
@@ -5303,14 +5389,14 @@ function getDirectorySignatureParts(baseDir) {
5303
5389
  }
5304
5390
  function getAppsDirectorySignature() {
5305
5391
  const appsDir = getAinativeAppsDir();
5306
- if (!fs9.existsSync(appsDir)) return "no-apps";
5392
+ if (!fs10.existsSync(appsDir)) return "no-apps";
5307
5393
  const parts = [];
5308
- const entries = fs9.readdirSync(appsDir, { withFileTypes: true }).filter((e) => e.isDirectory()).sort((a, b) => a.name.localeCompare(b.name));
5394
+ const entries = fs10.readdirSync(appsDir, { withFileTypes: true }).filter((e) => e.isDirectory()).sort((a, b) => a.name.localeCompare(b.name));
5309
5395
  for (const entry of entries) {
5310
- const manifestPath = path9.join(appsDir, entry.name, "manifest.yaml");
5396
+ const manifestPath = path10.join(appsDir, entry.name, "manifest.yaml");
5311
5397
  parts.push(entry.name);
5312
- if (fs9.existsSync(manifestPath)) {
5313
- const stats = fs9.statSync(manifestPath);
5398
+ if (fs10.existsSync(manifestPath)) {
5399
+ const stats = fs10.statSync(manifestPath);
5314
5400
  parts.push(`manifest:${stats.mtimeMs}:${stats.size}`);
5315
5401
  }
5316
5402
  }
@@ -5333,17 +5419,17 @@ function getSkillsDirectorySignature() {
5333
5419
  }
5334
5420
  function ensureBuiltins() {
5335
5421
  const builtinsDir = getBuiltinsDir();
5336
- if (!fs9.existsSync(builtinsDir)) return;
5337
- fs9.mkdirSync(SKILLS_DIR, { recursive: true });
5338
- for (const entry of fs9.readdirSync(builtinsDir, { withFileTypes: true })) {
5422
+ if (!fs10.existsSync(builtinsDir)) return;
5423
+ fs10.mkdirSync(SKILLS_DIR, { recursive: true });
5424
+ for (const entry of fs10.readdirSync(builtinsDir, { withFileTypes: true })) {
5339
5425
  if (!entry.isDirectory()) continue;
5340
- const targetDir = path9.join(SKILLS_DIR, entry.name);
5341
- const targetYaml = path9.join(targetDir, "profile.yaml");
5342
- const srcYaml = path9.join(builtinsDir, entry.name, "profile.yaml");
5343
- if (fs9.existsSync(targetYaml)) {
5426
+ const targetDir = path10.join(SKILLS_DIR, entry.name);
5427
+ const targetYaml = path10.join(targetDir, "profile.yaml");
5428
+ const srcYaml = path10.join(builtinsDir, entry.name, "profile.yaml");
5429
+ if (fs10.existsSync(targetYaml)) {
5344
5430
  try {
5345
- const source = yaml6.load(fs9.readFileSync(srcYaml, "utf-8")) ?? {};
5346
- const target = yaml6.load(fs9.readFileSync(targetYaml, "utf-8")) ?? {};
5431
+ const source = yaml6.load(fs10.readFileSync(srcYaml, "utf-8")) ?? {};
5432
+ const target = yaml6.load(fs10.readFileSync(targetYaml, "utf-8")) ?? {};
5347
5433
  let changed = false;
5348
5434
  if (source.supportedRuntimes !== void 0 && target.supportedRuntimes === void 0) {
5349
5435
  target.supportedRuntimes = source.supportedRuntimes;
@@ -5362,29 +5448,29 @@ function ensureBuiltins() {
5362
5448
  changed = true;
5363
5449
  }
5364
5450
  if (changed) {
5365
- fs9.writeFileSync(targetYaml, yaml6.dump(target));
5451
+ fs10.writeFileSync(targetYaml, yaml6.dump(target));
5366
5452
  }
5367
5453
  } catch {
5368
5454
  }
5369
5455
  continue;
5370
5456
  }
5371
- fs9.mkdirSync(targetDir, { recursive: true });
5372
- const srcDir = path9.join(builtinsDir, entry.name);
5373
- for (const file of fs9.readdirSync(srcDir)) {
5374
- fs9.copyFileSync(path9.join(srcDir, file), path9.join(targetDir, file));
5457
+ fs10.mkdirSync(targetDir, { recursive: true });
5458
+ const srcDir = path10.join(builtinsDir, entry.name);
5459
+ for (const file of fs10.readdirSync(srcDir)) {
5460
+ fs10.copyFileSync(path10.join(srcDir, file), path10.join(targetDir, file));
5375
5461
  }
5376
5462
  }
5377
5463
  }
5378
5464
  function scanProfilesFromDir(baseDir, profiles, options = {}) {
5379
- if (!fs9.existsSync(baseDir)) return;
5380
- for (const entry of fs9.readdirSync(baseDir, { withFileTypes: true })) {
5465
+ if (!fs10.existsSync(baseDir)) return;
5466
+ for (const entry of fs10.readdirSync(baseDir, { withFileTypes: true })) {
5381
5467
  if (!entry.isDirectory()) continue;
5382
- const dir = path9.join(baseDir, entry.name);
5383
- const yamlPath = path9.join(dir, "profile.yaml");
5384
- const skillPath = path9.join(dir, "SKILL.md");
5385
- if (!fs9.existsSync(yamlPath)) continue;
5468
+ const dir = path10.join(baseDir, entry.name);
5469
+ const yamlPath = path10.join(dir, "profile.yaml");
5470
+ const skillPath = path10.join(dir, "SKILL.md");
5471
+ if (!fs10.existsSync(yamlPath)) continue;
5386
5472
  try {
5387
- const rawYaml = fs9.readFileSync(yamlPath, "utf-8");
5473
+ const rawYaml = fs10.readFileSync(yamlPath, "utf-8");
5388
5474
  const parsed = yaml6.load(rawYaml);
5389
5475
  const result = ProfileConfigSchema.safeParse(parsed);
5390
5476
  if (!result.success) {
@@ -5395,7 +5481,7 @@ function scanProfilesFromDir(baseDir, profiles, options = {}) {
5395
5481
  continue;
5396
5482
  }
5397
5483
  const config = result.data;
5398
- const skillMd = fs9.existsSync(skillPath) ? fs9.readFileSync(skillPath, "utf-8") : "";
5484
+ const skillMd = fs10.existsSync(skillPath) ? fs10.readFileSync(skillPath, "utf-8") : "";
5399
5485
  const descMatch = skillMd.match(
5400
5486
  /^---\s*\n[\s\S]*?description:\s*(.+?)\s*\n[\s\S]*?---/
5401
5487
  );
@@ -5485,20 +5571,20 @@ function reloadProfiles() {
5485
5571
  profileCacheSignature = null;
5486
5572
  }
5487
5573
  function isBuiltin(id) {
5488
- return fs9.existsSync(path9.join(getBuiltinsDir(), id, "profile.yaml"));
5574
+ return fs10.existsSync(path10.join(getBuiltinsDir(), id, "profile.yaml"));
5489
5575
  }
5490
5576
  function createProfile(config, skillMd) {
5491
5577
  const result = ProfileConfigSchema.safeParse(config);
5492
5578
  if (!result.success) {
5493
5579
  throw new Error(`Invalid profile: ${result.error.issues.map((i) => i.message).join(", ")}`);
5494
5580
  }
5495
- const dir = path9.join(SKILLS_DIR, config.id);
5496
- if (fs9.existsSync(path9.join(dir, "profile.yaml"))) {
5581
+ const dir = path10.join(SKILLS_DIR, config.id);
5582
+ if (fs10.existsSync(path10.join(dir, "profile.yaml"))) {
5497
5583
  throw new Error(`Profile "${config.id}" already exists`);
5498
5584
  }
5499
- fs9.mkdirSync(dir, { recursive: true });
5500
- fs9.writeFileSync(path9.join(dir, "profile.yaml"), yaml6.dump(config));
5501
- fs9.writeFileSync(path9.join(dir, "SKILL.md"), skillMd);
5585
+ fs10.mkdirSync(dir, { recursive: true });
5586
+ fs10.writeFileSync(path10.join(dir, "profile.yaml"), yaml6.dump(config));
5587
+ fs10.writeFileSync(path10.join(dir, "SKILL.md"), skillMd);
5502
5588
  reloadProfiles();
5503
5589
  invalidateLatestScan();
5504
5590
  }
@@ -5507,13 +5593,13 @@ function createPromotedProfile(config, skillMd) {
5507
5593
  if (!result.success) {
5508
5594
  throw new Error(`Invalid profile: ${result.error.issues.map((i) => i.message).join(", ")}`);
5509
5595
  }
5510
- const dir = path9.join(PROMOTED_PROFILES_DIR, config.id);
5511
- if (fs9.existsSync(path9.join(dir, "profile.yaml"))) {
5596
+ const dir = path10.join(PROMOTED_PROFILES_DIR, config.id);
5597
+ if (fs10.existsSync(path10.join(dir, "profile.yaml"))) {
5512
5598
  throw new Error(`Profile "${config.id}" already exists`);
5513
5599
  }
5514
- fs9.mkdirSync(dir, { recursive: true });
5515
- fs9.writeFileSync(path9.join(dir, "profile.yaml"), yaml6.dump(config));
5516
- fs9.writeFileSync(path9.join(dir, "SKILL.md"), skillMd);
5600
+ fs10.mkdirSync(dir, { recursive: true });
5601
+ fs10.writeFileSync(path10.join(dir, "profile.yaml"), yaml6.dump(config));
5602
+ fs10.writeFileSync(path10.join(dir, "SKILL.md"), skillMd);
5517
5603
  reloadProfiles();
5518
5604
  invalidateLatestScan();
5519
5605
  }
@@ -5525,14 +5611,14 @@ function updateProfile(id, config, skillMd) {
5525
5611
  if (!result.success) {
5526
5612
  throw new Error(`Invalid profile: ${result.error.issues.map((i) => i.message).join(", ")}`);
5527
5613
  }
5528
- const skillsDir = path9.join(SKILLS_DIR, id);
5529
- const promotedDir = path9.join(PROMOTED_PROFILES_DIR, id);
5530
- const dir = fs9.existsSync(skillsDir) ? skillsDir : fs9.existsSync(promotedDir) ? promotedDir : null;
5614
+ const skillsDir = path10.join(SKILLS_DIR, id);
5615
+ const promotedDir = path10.join(PROMOTED_PROFILES_DIR, id);
5616
+ const dir = fs10.existsSync(skillsDir) ? skillsDir : fs10.existsSync(promotedDir) ? promotedDir : null;
5531
5617
  if (!dir) {
5532
5618
  throw new Error(`Profile "${id}" not found`);
5533
5619
  }
5534
- fs9.writeFileSync(path9.join(dir, "profile.yaml"), yaml6.dump(config));
5535
- fs9.writeFileSync(path9.join(dir, "SKILL.md"), skillMd);
5620
+ fs10.writeFileSync(path10.join(dir, "profile.yaml"), yaml6.dump(config));
5621
+ fs10.writeFileSync(path10.join(dir, "SKILL.md"), skillMd);
5536
5622
  reloadProfiles();
5537
5623
  invalidateLatestScan();
5538
5624
  }
@@ -5540,13 +5626,13 @@ function deleteProfile(id) {
5540
5626
  if (isBuiltin(id)) {
5541
5627
  throw new Error("Cannot delete built-in profiles");
5542
5628
  }
5543
- const skillsDir = path9.join(SKILLS_DIR, id);
5544
- const promotedDir = path9.join(PROMOTED_PROFILES_DIR, id);
5545
- const dir = fs9.existsSync(skillsDir) ? skillsDir : fs9.existsSync(promotedDir) ? promotedDir : null;
5629
+ const skillsDir = path10.join(SKILLS_DIR, id);
5630
+ const promotedDir = path10.join(PROMOTED_PROFILES_DIR, id);
5631
+ const dir = fs10.existsSync(skillsDir) ? skillsDir : fs10.existsSync(promotedDir) ? promotedDir : null;
5546
5632
  if (!dir) {
5547
5633
  throw new Error(`Profile "${id}" not found`);
5548
5634
  }
5549
- fs9.rmSync(dir, { recursive: true, force: true });
5635
+ fs10.rmSync(dir, { recursive: true, force: true });
5550
5636
  reloadProfiles();
5551
5637
  invalidateLatestScan();
5552
5638
  }
@@ -5630,7 +5716,7 @@ var init_registry2 = __esm({
5630
5716
  init_ainative_paths();
5631
5717
  init_app_manifest_source();
5632
5718
  init_app_root();
5633
- BUILTINS_DIR = path9.resolve(
5719
+ BUILTINS_DIR = path10.resolve(
5634
5720
  getAppRoot(import.meta.dirname, 4),
5635
5721
  "src",
5636
5722
  "lib",
@@ -5638,7 +5724,7 @@ var init_registry2 = __esm({
5638
5724
  "profiles",
5639
5725
  "builtins"
5640
5726
  );
5641
- SKILLS_DIR = path9.join(
5727
+ SKILLS_DIR = path10.join(
5642
5728
  process.env.HOME ?? process.env.USERPROFILE ?? homedir3(),
5643
5729
  ".claude",
5644
5730
  "skills"
@@ -5666,16 +5752,16 @@ __export(registry_exports3, {
5666
5752
  reloadBlueprints: () => reloadBlueprints,
5667
5753
  validateBlueprintRefs: () => validateBlueprintRefs
5668
5754
  });
5669
- import fs10 from "fs";
5670
- import path10 from "path";
5755
+ import fs11 from "fs";
5756
+ import path11 from "path";
5671
5757
  import yaml7 from "js-yaml";
5672
5758
  function scanDirectory(dir, isBuiltin2) {
5673
5759
  const blueprints = /* @__PURE__ */ new Map();
5674
- if (!fs10.existsSync(dir)) return blueprints;
5675
- for (const file of fs10.readdirSync(dir)) {
5760
+ if (!fs11.existsSync(dir)) return blueprints;
5761
+ for (const file of fs11.readdirSync(dir)) {
5676
5762
  if (!file.endsWith(".yaml") && !file.endsWith(".yml")) continue;
5677
5763
  try {
5678
- const content = fs10.readFileSync(path10.join(dir, file), "utf-8");
5764
+ const content = fs11.readFileSync(path11.join(dir, file), "utf-8");
5679
5765
  const parsed = yaml7.load(content);
5680
5766
  const result = BlueprintSchema.safeParse(parsed);
5681
5767
  if (!result.success) {
@@ -5729,12 +5815,12 @@ function createBlueprint(yamlContent) {
5729
5815
  `Invalid blueprint: ${result.error.issues.map((i) => i.message).join(", ")}`
5730
5816
  );
5731
5817
  }
5732
- fs10.mkdirSync(USER_BLUEPRINTS_DIR, { recursive: true });
5733
- const filePath = path10.join(USER_BLUEPRINTS_DIR, `${result.data.id}.yaml`);
5734
- if (fs10.existsSync(filePath)) {
5818
+ fs11.mkdirSync(USER_BLUEPRINTS_DIR, { recursive: true });
5819
+ const filePath = path11.join(USER_BLUEPRINTS_DIR, `${result.data.id}.yaml`);
5820
+ if (fs11.existsSync(filePath)) {
5735
5821
  throw new Error(`Blueprint "${result.data.id}" already exists`);
5736
5822
  }
5737
- fs10.writeFileSync(filePath, yamlContent);
5823
+ fs11.writeFileSync(filePath, yamlContent);
5738
5824
  reloadBlueprints();
5739
5825
  return { ...result.data, isBuiltin: false };
5740
5826
  }
@@ -5742,11 +5828,11 @@ function deleteBlueprint(id) {
5742
5828
  if (isBuiltinBlueprint(id)) {
5743
5829
  throw new Error("Cannot delete built-in blueprints");
5744
5830
  }
5745
- const filePath = path10.join(USER_BLUEPRINTS_DIR, `${id}.yaml`);
5746
- if (!fs10.existsSync(filePath)) {
5831
+ const filePath = path11.join(USER_BLUEPRINTS_DIR, `${id}.yaml`);
5832
+ if (!fs11.existsSync(filePath)) {
5747
5833
  throw new Error(`Blueprint "${id}" not found`);
5748
5834
  }
5749
- fs10.unlinkSync(filePath);
5835
+ fs11.unlinkSync(filePath);
5750
5836
  reloadBlueprints();
5751
5837
  }
5752
5838
  function getUserBlueprintsDir() {
@@ -5805,7 +5891,7 @@ var init_registry3 = __esm({
5805
5891
  init_ainative_paths();
5806
5892
  init_app_root();
5807
5893
  init_registry2();
5808
- BUILTINS_DIR2 = path10.resolve(
5894
+ BUILTINS_DIR2 = path11.resolve(
5809
5895
  getAppRoot(import.meta.dirname, 4),
5810
5896
  "src",
5811
5897
  "lib",
@@ -6667,18 +6753,18 @@ var init_processor = __esm({
6667
6753
  });
6668
6754
 
6669
6755
  // src/lib/documents/output-scanner.ts
6670
- import path11 from "path";
6671
- import fs11 from "fs/promises";
6756
+ import path12 from "path";
6757
+ import fs12 from "fs/promises";
6672
6758
  import { and as and6, eq as eq14 } from "drizzle-orm";
6673
6759
  function getTaskOutputDirectory(taskId) {
6674
- return path11.join(TASK_OUTPUTS_DIR, taskId);
6760
+ return path12.join(TASK_OUTPUTS_DIR, taskId);
6675
6761
  }
6676
6762
  async function prepareTaskOutputDirectory(taskId, options = {}) {
6677
6763
  const outputDir = getTaskOutputDirectory(taskId);
6678
6764
  if (options.clearExisting) {
6679
- await fs11.rm(outputDir, { recursive: true, force: true });
6765
+ await fs12.rm(outputDir, { recursive: true, force: true });
6680
6766
  }
6681
- await fs11.mkdir(outputDir, { recursive: true });
6767
+ await fs12.mkdir(outputDir, { recursive: true });
6682
6768
  return outputDir;
6683
6769
  }
6684
6770
  function buildTaskOutputInstructions(taskId) {
@@ -6691,10 +6777,10 @@ function buildTaskOutputInstructions(taskId) {
6691
6777
  ].join("\n");
6692
6778
  }
6693
6779
  async function listFilesRecursively(rootDir) {
6694
- const entries = await fs11.readdir(rootDir, { withFileTypes: true });
6780
+ const entries = await fs12.readdir(rootDir, { withFileTypes: true });
6695
6781
  const files = await Promise.all(
6696
6782
  entries.map(async (entry) => {
6697
- const resolved = path11.join(rootDir, entry.name);
6783
+ const resolved = path12.join(rootDir, entry.name);
6698
6784
  if (entry.isDirectory()) {
6699
6785
  return listFilesRecursively(resolved);
6700
6786
  }
@@ -6704,13 +6790,13 @@ async function listFilesRecursively(rootDir) {
6704
6790
  return files.flat();
6705
6791
  }
6706
6792
  function resolveOutputMimeType(filename) {
6707
- return OUTPUT_MIME_TYPES[path11.extname(filename).toLowerCase()] ?? null;
6793
+ return OUTPUT_MIME_TYPES[path12.extname(filename).toLowerCase()] ?? null;
6708
6794
  }
6709
6795
  function normalizeRelativePath(value) {
6710
- return value.split(path11.sep).join("/");
6796
+ return value.split(path12.sep).join("/");
6711
6797
  }
6712
6798
  function buildArchivedFilename(relativePath, version) {
6713
- const parsed = path11.parse(relativePath);
6799
+ const parsed = path12.parse(relativePath);
6714
6800
  const sanitizedBase = parsed.name.replace(/[^a-zA-Z0-9._-]+/g, "-");
6715
6801
  const nestedPrefix = parsed.dir ? `${parsed.dir.replace(/[\\/]+/g, "__")}__` : "";
6716
6802
  return `${nestedPrefix}${sanitizedBase || "output"}-v${version}${parsed.ext}`;
@@ -6722,7 +6808,7 @@ async function scanTaskOutputDocuments(taskId) {
6722
6808
  throw new Error(`Task ${taskId} not found`);
6723
6809
  }
6724
6810
  try {
6725
- await fs11.access(outputDir);
6811
+ await fs12.access(outputDir);
6726
6812
  } catch {
6727
6813
  return [];
6728
6814
  }
@@ -6742,22 +6828,22 @@ async function scanTaskOutputDocuments(taskId) {
6742
6828
  const discoveredFiles = await listFilesRecursively(outputDir);
6743
6829
  const registeredDocumentIds = [];
6744
6830
  for (const sourcePath of discoveredFiles) {
6745
- const relativePath = normalizeRelativePath(path11.relative(outputDir, sourcePath));
6831
+ const relativePath = normalizeRelativePath(path12.relative(outputDir, sourcePath));
6746
6832
  const mimeType = resolveOutputMimeType(relativePath);
6747
6833
  if (!mimeType) {
6748
6834
  continue;
6749
6835
  }
6750
- const stats = await fs11.stat(sourcePath);
6836
+ const stats = await fs12.stat(sourcePath);
6751
6837
  if (!stats.isFile()) {
6752
6838
  continue;
6753
6839
  }
6754
6840
  const nextVersion = (versionMap.get(relativePath) ?? 0) + 1;
6755
6841
  versionMap.set(relativePath, nextVersion);
6756
- const archiveDir = path11.join(OUTPUT_ARCHIVE_DIR, taskId);
6757
- await fs11.mkdir(archiveDir, { recursive: true });
6842
+ const archiveDir = path12.join(OUTPUT_ARCHIVE_DIR, taskId);
6843
+ await fs12.mkdir(archiveDir, { recursive: true });
6758
6844
  const archivedFilename = buildArchivedFilename(relativePath, nextVersion);
6759
- const archivedPath = path11.join(archiveDir, archivedFilename);
6760
- await fs11.copyFile(sourcePath, archivedPath);
6845
+ const archivedPath = path12.join(archiveDir, archivedFilename);
6846
+ await fs12.copyFile(sourcePath, archivedPath);
6761
6847
  const documentId = crypto.randomUUID();
6762
6848
  const now = /* @__PURE__ */ new Date();
6763
6849
  await db.insert(documents).values({
@@ -6788,8 +6874,8 @@ var init_output_scanner = __esm({
6788
6874
  init_schema();
6789
6875
  init_env();
6790
6876
  init_processor();
6791
- TASK_OUTPUTS_DIR = path11.join(dataDir(), "outputs");
6792
- OUTPUT_ARCHIVE_DIR = path11.join(dataDir(), "documents", "output");
6877
+ TASK_OUTPUTS_DIR = path12.join(dataDir(), "outputs");
6878
+ OUTPUT_ARCHIVE_DIR = path12.join(dataDir(), "documents", "output");
6793
6879
  OUTPUT_MIME_TYPES = {
6794
6880
  ".md": "text/markdown",
6795
6881
  ".txt": "text/plain",
@@ -6849,7 +6935,7 @@ var CHAT_MODELS;
6849
6935
  var init_types2 = __esm({
6850
6936
  "src/lib/chat/types.ts"() {
6851
6937
  "use strict";
6852
- init_catalog();
6938
+ init_catalog2();
6853
6939
  CHAT_MODELS = [
6854
6940
  // Anthropic — uses SDK short names
6855
6941
  { id: "haiku", label: "Haiku", provider: "anthropic", tier: "Fast", costLabel: "$" },
@@ -6861,7 +6947,7 @@ var init_types2 = __esm({
6861
6947
  { id: "gpt-5.4", label: "GPT-5.4", provider: "openai", tier: "Best", costLabel: "$$$" }
6862
6948
  ];
6863
6949
  try {
6864
- const { listRuntimeCatalog: listRuntimeCatalog2 } = (init_catalog(), __toCommonJS(catalog_exports));
6950
+ const { listRuntimeCatalog: listRuntimeCatalog2 } = (init_catalog2(), __toCommonJS(catalog_exports2));
6865
6951
  const allSupportedModels = /* @__PURE__ */ new Set();
6866
6952
  for (const runtime of listRuntimeCatalog2()) {
6867
6953
  for (const model of runtime.models.supported) {
@@ -7920,7 +8006,7 @@ var init_ledger = __esm({
7920
8006
  });
7921
8007
 
7922
8008
  // src/lib/plugins/classify-trust.ts
7923
- import path12 from "path";
8009
+ import path13 from "path";
7924
8010
  import os from "os";
7925
8011
  function classifyPluginTrust(manifest, rootDir, opts2 = {}) {
7926
8012
  if (manifest.kind === "primitives-bundle") return "self";
@@ -7934,9 +8020,9 @@ function classifyPluginTrust(manifest, rootDir, opts2 = {}) {
7934
8020
  if (manifest.author === currentUser) return "self";
7935
8021
  }
7936
8022
  const appsBase = opts2.appsBaseDir ?? getAinativeAppsDir();
7937
- const normalizedRoot = path12.resolve(rootDir);
7938
- const normalizedApps = path12.resolve(appsBase);
7939
- const sep = path12.sep;
8023
+ const normalizedRoot = path13.resolve(rootDir);
8024
+ const normalizedApps = path13.resolve(appsBase);
8025
+ const sep = path13.sep;
7940
8026
  if (normalizedRoot === normalizedApps || normalizedRoot.startsWith(normalizedApps + sep)) {
7941
8027
  return "self";
7942
8028
  }
@@ -7957,15 +8043,15 @@ __export(transport_dispatch_exports, {
7957
8043
  validateStdioMcp: () => validateStdioMcp
7958
8044
  });
7959
8045
  import { spawn } from "child_process";
7960
- import fs12 from "fs";
7961
- import path13 from "path";
8046
+ import fs13 from "fs";
8047
+ import path14 from "path";
7962
8048
  import readline from "readline";
7963
8049
  function logToFile2(line) {
7964
8050
  try {
7965
8051
  const logsDir = getAinativeLogsDir();
7966
- fs12.mkdirSync(logsDir, { recursive: true });
7967
- fs12.appendFileSync(
7968
- path13.join(logsDir, "plugins.log"),
8052
+ fs13.mkdirSync(logsDir, { recursive: true });
8053
+ fs13.appendFileSync(
8054
+ path14.join(logsDir, "plugins.log"),
7969
8055
  `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
7970
8056
  `
7971
8057
  );
@@ -8100,14 +8186,14 @@ async function validateInProcessSdk(config, pluginId, serverName) {
8100
8186
  };
8101
8187
  }
8102
8188
  const absPath = config.entry;
8103
- if (!path13.isAbsolute(absPath)) {
8189
+ if (!path14.isAbsolute(absPath)) {
8104
8190
  return {
8105
8191
  ok: false,
8106
8192
  reason: "sdk_invalid_export",
8107
8193
  detail: `entry must be absolute path, got: ${absPath}`
8108
8194
  };
8109
8195
  }
8110
- const ext = path13.extname(absPath);
8196
+ const ext = path14.extname(absPath);
8111
8197
  if (ext === ".ts") {
8112
8198
  return {
8113
8199
  ok: false,
@@ -8226,8 +8312,8 @@ __export(mcp_loader_exports, {
8226
8312
  loadPluginMcpServers: () => loadPluginMcpServers,
8227
8313
  reloadPluginMcpRegistrations: () => reloadPluginMcpRegistrations
8228
8314
  });
8229
- import fs13 from "fs";
8230
- import path14 from "path";
8315
+ import fs14 from "fs";
8316
+ import path15 from "path";
8231
8317
  import os2 from "os";
8232
8318
  import yaml8 from "js-yaml";
8233
8319
  function __resetDockerBootSweepForTests() {
@@ -8236,9 +8322,9 @@ function __resetDockerBootSweepForTests() {
8236
8322
  function logToFile3(line) {
8237
8323
  try {
8238
8324
  const logsDir = getAinativeLogsDir();
8239
- fs13.mkdirSync(logsDir, { recursive: true });
8240
- fs13.appendFileSync(
8241
- path14.join(logsDir, "plugins.log"),
8325
+ fs14.mkdirSync(logsDir, { recursive: true });
8326
+ fs14.appendFileSync(
8327
+ path15.join(logsDir, "plugins.log"),
8242
8328
  `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
8243
8329
  `
8244
8330
  );
@@ -8263,10 +8349,10 @@ function isRelativeCommand(command) {
8263
8349
  }
8264
8350
  async function scanPlugin(pluginDir, pluginId) {
8265
8351
  const registrations = [];
8266
- const pluginYamlPath = path14.join(pluginDir, "plugin.yaml");
8352
+ const pluginYamlPath = path15.join(pluginDir, "plugin.yaml");
8267
8353
  let pluginYamlContent;
8268
8354
  try {
8269
- pluginYamlContent = fs13.readFileSync(pluginYamlPath, "utf-8");
8355
+ pluginYamlContent = fs14.readFileSync(pluginYamlPath, "utf-8");
8270
8356
  } catch {
8271
8357
  return { registrations };
8272
8358
  }
@@ -8288,7 +8374,7 @@ async function scanPlugin(pluginDir, pluginId) {
8288
8374
  if (manifest.kind !== "chat-tools") {
8289
8375
  return { registrations };
8290
8376
  }
8291
- const mcpJsonPath = path14.join(pluginDir, ".mcp.json");
8377
+ const mcpJsonPath = path15.join(pluginDir, ".mcp.json");
8292
8378
  const mcpServers = parseMcpConfigFile(mcpJsonPath);
8293
8379
  if (mcpServers === null) {
8294
8380
  logToFile3(
@@ -8392,8 +8478,8 @@ async function scanPlugin(pluginDir, pluginId) {
8392
8478
  const resolvedEnv = resolveEnvTemplates(rawEntry.env, context);
8393
8479
  let resolvedCommand;
8394
8480
  if (isRelativeCommand(rawCommand)) {
8395
- const absCommand = path14.resolve(pluginDir, rawCommand);
8396
- if (!fs13.existsSync(absCommand)) {
8481
+ const absCommand = path15.resolve(pluginDir, rawCommand);
8482
+ if (!fs14.existsSync(absCommand)) {
8397
8483
  logToFile3(
8398
8484
  `[mcp-loader] plugin ${pluginId} server "${serverName}": command "${rawCommand}" not found at ${absCommand} (server_not_found)`
8399
8485
  );
@@ -8487,8 +8573,8 @@ async function scanPlugin(pluginDir, pluginId) {
8487
8573
  });
8488
8574
  continue;
8489
8575
  }
8490
- const absEntry = path14.resolve(pluginDir, entryField);
8491
- if (!fs13.existsSync(absEntry)) {
8576
+ const absEntry = path15.resolve(pluginDir, entryField);
8577
+ if (!fs14.existsSync(absEntry)) {
8492
8578
  logToFile3(
8493
8579
  `[mcp-loader] plugin ${pluginId} server "${serverName}": entry "${entryField}" not found at ${absEntry} (sdk_entry_not_found)`
8494
8580
  );
@@ -8557,9 +8643,9 @@ async function listPluginMcpRegistrations(opts2) {
8557
8643
  const features = getRuntimeFeatures(opts2.runtime);
8558
8644
  if (!features.supportsPluginMcpServers) {
8559
8645
  const pluginsDir2 = getAinativePluginsDir();
8560
- if (fs13.existsSync(pluginsDir2)) {
8646
+ if (fs14.existsSync(pluginsDir2)) {
8561
8647
  try {
8562
- for (const entry of fs13.readdirSync(pluginsDir2).sort()) {
8648
+ for (const entry of fs14.readdirSync(pluginsDir2).sort()) {
8563
8649
  const logKey = `${entry}@${opts2.runtime}@${pluginsDir2}`;
8564
8650
  if (!ollamaSkipLogged.has(logKey)) {
8565
8651
  ollamaSkipLogged.add(logKey);
@@ -8582,22 +8668,22 @@ async function listPluginMcpRegistrations(opts2) {
8582
8668
  }
8583
8669
  }
8584
8670
  const pluginsDir = getAinativePluginsDir();
8585
- if (!fs13.existsSync(pluginsDir)) {
8671
+ if (!fs14.existsSync(pluginsDir)) {
8586
8672
  return [];
8587
8673
  }
8588
8674
  let pluginDirEntries;
8589
8675
  try {
8590
- pluginDirEntries = fs13.readdirSync(pluginsDir).sort();
8676
+ pluginDirEntries = fs14.readdirSync(pluginsDir).sort();
8591
8677
  } catch {
8592
8678
  logToFile3(`[mcp-loader] could not read plugins directory: ${pluginsDir}`);
8593
8679
  return [];
8594
8680
  }
8595
8681
  const allRegistrations = [];
8596
8682
  for (const entry of pluginDirEntries) {
8597
- const pluginDir = path14.join(pluginsDir, entry);
8683
+ const pluginDir = path15.join(pluginsDir, entry);
8598
8684
  let stat2;
8599
8685
  try {
8600
- stat2 = fs13.statSync(pluginDir);
8686
+ stat2 = fs14.statSync(pluginDir);
8601
8687
  } catch {
8602
8688
  continue;
8603
8689
  }
@@ -8622,18 +8708,18 @@ async function loadPluginMcpServers(opts2) {
8622
8708
  }
8623
8709
  function hasAnyDockerConfinedPlugin() {
8624
8710
  const pluginsDir = getAinativePluginsDir();
8625
- if (!fs13.existsSync(pluginsDir)) return false;
8711
+ if (!fs14.existsSync(pluginsDir)) return false;
8626
8712
  let entries;
8627
8713
  try {
8628
- entries = fs13.readdirSync(pluginsDir);
8714
+ entries = fs14.readdirSync(pluginsDir);
8629
8715
  } catch {
8630
8716
  return false;
8631
8717
  }
8632
8718
  for (const entry of entries) {
8633
- const pluginYamlPath = path14.join(pluginsDir, entry, "plugin.yaml");
8719
+ const pluginYamlPath = path15.join(pluginsDir, entry, "plugin.yaml");
8634
8720
  let content;
8635
8721
  try {
8636
- content = fs13.readFileSync(pluginYamlPath, "utf-8");
8722
+ content = fs14.readFileSync(pluginYamlPath, "utf-8");
8637
8723
  } catch {
8638
8724
  continue;
8639
8725
  }
@@ -8653,26 +8739,26 @@ function hasAnyDockerConfinedPlugin() {
8653
8739
  function buildSafeModeRegistrations() {
8654
8740
  const out = [];
8655
8741
  const pluginsDir = getAinativePluginsDir();
8656
- if (!fs13.existsSync(pluginsDir)) return out;
8742
+ if (!fs14.existsSync(pluginsDir)) return out;
8657
8743
  let entries;
8658
8744
  try {
8659
- entries = fs13.readdirSync(pluginsDir).sort();
8745
+ entries = fs14.readdirSync(pluginsDir).sort();
8660
8746
  } catch {
8661
8747
  return out;
8662
8748
  }
8663
8749
  for (const entry of entries) {
8664
- const pluginDir = path14.join(pluginsDir, entry);
8750
+ const pluginDir = path15.join(pluginsDir, entry);
8665
8751
  let stat2;
8666
8752
  try {
8667
- stat2 = fs13.statSync(pluginDir);
8753
+ stat2 = fs14.statSync(pluginDir);
8668
8754
  } catch {
8669
8755
  continue;
8670
8756
  }
8671
8757
  if (!stat2.isDirectory()) continue;
8672
- const pluginYamlPath = path14.join(pluginDir, "plugin.yaml");
8758
+ const pluginYamlPath = path15.join(pluginDir, "plugin.yaml");
8673
8759
  let content;
8674
8760
  try {
8675
- content = fs13.readFileSync(pluginYamlPath, "utf-8");
8761
+ content = fs14.readFileSync(pluginYamlPath, "utf-8");
8676
8762
  } catch {
8677
8763
  continue;
8678
8764
  }
@@ -8739,7 +8825,7 @@ var init_mcp_loader = __esm({
8739
8825
  init_types();
8740
8826
  init_capability_check();
8741
8827
  init_mcp_config();
8742
- init_catalog();
8828
+ init_catalog2();
8743
8829
  init_ainative_paths();
8744
8830
  init_transport_dispatch();
8745
8831
  init_wrap();
@@ -8765,17 +8851,17 @@ __export(capability_check_exports, {
8765
8851
  writePluginsLock: () => writePluginsLock
8766
8852
  });
8767
8853
  import crypto3 from "crypto";
8768
- import fs14 from "fs";
8854
+ import fs15 from "fs";
8769
8855
  import os3 from "os";
8770
- import path15 from "path";
8856
+ import path16 from "path";
8771
8857
  import yaml9 from "js-yaml";
8772
8858
  import { z as z6 } from "zod";
8773
8859
  function logToFile4(line) {
8774
8860
  try {
8775
8861
  const logsDir = getAinativeLogsDir();
8776
- fs14.mkdirSync(logsDir, { recursive: true });
8777
- fs14.appendFileSync(
8778
- path15.join(logsDir, "plugins.log"),
8862
+ fs15.mkdirSync(logsDir, { recursive: true });
8863
+ fs15.appendFileSync(
8864
+ path16.join(logsDir, "plugins.log"),
8779
8865
  `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
8780
8866
  `
8781
8867
  );
@@ -8815,12 +8901,12 @@ function deriveManifestHash(pluginYamlContent) {
8815
8901
  }
8816
8902
  function readPluginsLock() {
8817
8903
  const lockPath = getAinativePluginsLockPath();
8818
- if (!fs14.existsSync(lockPath)) {
8904
+ if (!fs15.existsSync(lockPath)) {
8819
8905
  return { version: 1, accepted: {} };
8820
8906
  }
8821
8907
  let raw;
8822
8908
  try {
8823
- raw = yaml9.load(fs14.readFileSync(lockPath, "utf-8"));
8909
+ raw = yaml9.load(fs15.readFileSync(lockPath, "utf-8"));
8824
8910
  } catch (err2) {
8825
8911
  logToFile4(
8826
8912
  `[capability-check] WARN: plugins.lock is not valid YAML \u2014 treating as empty. Error: ${err2 instanceof Error ? err2.message : String(err2)}`
@@ -8839,31 +8925,31 @@ function readPluginsLock() {
8839
8925
  function writePluginsLock(pluginId, entry) {
8840
8926
  const lockPath = getAinativePluginsLockPath();
8841
8927
  const bakPath = lockPath + ".bak";
8842
- const lockDir = path15.dirname(lockPath);
8843
- fs14.mkdirSync(lockDir, { recursive: true });
8928
+ const lockDir = path16.dirname(lockPath);
8929
+ fs15.mkdirSync(lockDir, { recursive: true });
8844
8930
  const current = readPluginsLock();
8845
8931
  current.accepted[pluginId] = entry;
8846
8932
  const newContent = yaml9.dump(current, { lineWidth: -1 });
8847
- if (fs14.existsSync(lockPath)) {
8848
- fs14.copyFileSync(lockPath, bakPath);
8933
+ if (fs15.existsSync(lockPath)) {
8934
+ fs15.copyFileSync(lockPath, bakPath);
8849
8935
  try {
8850
- fs14.chmodSync(bakPath, 384);
8936
+ fs15.chmodSync(bakPath, 384);
8851
8937
  } catch {
8852
8938
  }
8853
8939
  }
8854
8940
  const tmpPath = `${lockPath}.tmp-${crypto3.randomBytes(6).toString("hex")}`;
8855
8941
  try {
8856
- fs14.writeFileSync(tmpPath, newContent, { mode: 384 });
8857
- fs14.renameSync(tmpPath, lockPath);
8942
+ fs15.writeFileSync(tmpPath, newContent, { mode: 384 });
8943
+ fs15.renameSync(tmpPath, lockPath);
8858
8944
  } catch (err2) {
8859
8945
  try {
8860
- fs14.unlinkSync(tmpPath);
8946
+ fs15.unlinkSync(tmpPath);
8861
8947
  } catch {
8862
8948
  }
8863
8949
  throw err2;
8864
8950
  }
8865
8951
  try {
8866
- fs14.chmodSync(lockPath, 384);
8952
+ fs15.chmodSync(lockPath, 384);
8867
8953
  } catch {
8868
8954
  }
8869
8955
  }
@@ -8874,28 +8960,28 @@ function removePluginsLockEntry(pluginId) {
8874
8960
  if (!(pluginId in current.accepted)) return;
8875
8961
  delete current.accepted[pluginId];
8876
8962
  const newContent = yaml9.dump(current, { lineWidth: -1 });
8877
- const lockDir = path15.dirname(lockPath);
8878
- fs14.mkdirSync(lockDir, { recursive: true });
8879
- if (fs14.existsSync(lockPath)) {
8880
- fs14.copyFileSync(lockPath, bakPath);
8963
+ const lockDir = path16.dirname(lockPath);
8964
+ fs15.mkdirSync(lockDir, { recursive: true });
8965
+ if (fs15.existsSync(lockPath)) {
8966
+ fs15.copyFileSync(lockPath, bakPath);
8881
8967
  try {
8882
- fs14.chmodSync(bakPath, 384);
8968
+ fs15.chmodSync(bakPath, 384);
8883
8969
  } catch {
8884
8970
  }
8885
8971
  }
8886
8972
  const tmpPath = `${lockPath}.tmp-${crypto3.randomBytes(6).toString("hex")}`;
8887
8973
  try {
8888
- fs14.writeFileSync(tmpPath, newContent, { mode: 384 });
8889
- fs14.renameSync(tmpPath, lockPath);
8974
+ fs15.writeFileSync(tmpPath, newContent, { mode: 384 });
8975
+ fs15.renameSync(tmpPath, lockPath);
8890
8976
  } catch (err2) {
8891
8977
  try {
8892
- fs14.unlinkSync(tmpPath);
8978
+ fs15.unlinkSync(tmpPath);
8893
8979
  } catch {
8894
8980
  }
8895
8981
  throw err2;
8896
8982
  }
8897
8983
  try {
8898
- fs14.chmodSync(lockPath, 384);
8984
+ fs15.chmodSync(lockPath, 384);
8899
8985
  } catch {
8900
8986
  }
8901
8987
  }
@@ -8981,9 +9067,9 @@ function getPluginToolApprovalMode(pluginId, toolName, defaultFromManifest) {
8981
9067
  }
8982
9068
  function readManifestDefaultApproval(pluginId) {
8983
9069
  try {
8984
- const pluginYamlPath = path15.join(getAinativePluginsDir(), pluginId, "plugin.yaml");
8985
- if (!fs14.existsSync(pluginYamlPath)) return void 0;
8986
- const content = fs14.readFileSync(pluginYamlPath, "utf-8");
9070
+ const pluginYamlPath = path16.join(getAinativePluginsDir(), pluginId, "plugin.yaml");
9071
+ if (!fs15.existsSync(pluginYamlPath)) return void 0;
9072
+ const content = fs15.readFileSync(pluginYamlPath, "utf-8");
8987
9073
  const raw = yaml9.load(content);
8988
9074
  if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return void 0;
8989
9075
  const record = raw;
@@ -9075,13 +9161,13 @@ async function revokePluginCapabilities(pluginId) {
9075
9161
  }
9076
9162
  async function grantPluginCapabilities(pluginId, opts2) {
9077
9163
  const { getAinativePluginsDir: getDir } = await Promise.resolve().then(() => (init_ainative_paths(), ainative_paths_exports));
9078
- const pluginYamlPath = path15.join(getDir(), pluginId, "plugin.yaml");
9079
- if (!fs14.existsSync(pluginYamlPath)) {
9164
+ const pluginYamlPath = path16.join(getDir(), pluginId, "plugin.yaml");
9165
+ if (!fs15.existsSync(pluginYamlPath)) {
9080
9166
  return { granted: false, reason: "not_found" };
9081
9167
  }
9082
9168
  let content;
9083
9169
  try {
9084
- content = fs14.readFileSync(pluginYamlPath, "utf-8");
9170
+ content = fs15.readFileSync(pluginYamlPath, "utf-8");
9085
9171
  } catch (err2) {
9086
9172
  return {
9087
9173
  granted: false,
@@ -9472,7 +9558,7 @@ var RetryableRuntimeLaunchError;
9472
9558
  var init_launch_failure = __esm({
9473
9559
  "src/lib/agents/runtime/launch-failure.ts"() {
9474
9560
  "use strict";
9475
- init_catalog();
9561
+ init_catalog2();
9476
9562
  RetryableRuntimeLaunchError = class extends Error {
9477
9563
  runtimeId;
9478
9564
  cause;
@@ -9764,7 +9850,7 @@ var init_router = __esm({
9764
9850
  "use strict";
9765
9851
  init_registry2();
9766
9852
  init_compatibility();
9767
- init_catalog();
9853
+ init_catalog2();
9768
9854
  init_task_dispatch();
9769
9855
  RUNTIME_KEYWORD_SIGNALS = {
9770
9856
  // File/code operations → claude-code (needs filesystem)
@@ -10094,7 +10180,7 @@ var init_task_tools = __esm({
10094
10180
  init_db();
10095
10181
  init_schema();
10096
10182
  init_helpers2();
10097
- init_catalog();
10183
+ init_catalog2();
10098
10184
  init_registry2();
10099
10185
  VALID_TASK_STATUSES = [
10100
10186
  "planned",
@@ -10325,7 +10411,7 @@ function workflowTools(ctx) {
10325
10411
  args.definition = JSON.stringify(parsedDef);
10326
10412
  let runtimeId = null;
10327
10413
  if (args.runtime) {
10328
- const { isAgentRuntimeId: isAgentRuntimeId2 } = await Promise.resolve().then(() => (init_catalog(), catalog_exports));
10414
+ const { isAgentRuntimeId: isAgentRuntimeId2 } = await Promise.resolve().then(() => (init_catalog2(), catalog_exports2));
10329
10415
  if (!isAgentRuntimeId2(args.runtime)) {
10330
10416
  return err(`Invalid runtime "${args.runtime}". Use list_runtimes to see available options.`);
10331
10417
  }
@@ -11848,9 +11934,9 @@ function buildPermissionSummary(toolName, input) {
11848
11934
  }
11849
11935
  }
11850
11936
  if (toolName === "Read" || toolName === "Write" || toolName === "Edit" || toolName === "read" || toolName === "write" || toolName === "edit") {
11851
- const path20 = input.file_path ?? input.path;
11852
- if (typeof path20 === "string" && path20.trim().length > 0) {
11853
- return truncate(path20.trim());
11937
+ const path21 = input.file_path ?? input.path;
11938
+ if (typeof path21 === "string" && path21.trim().length > 0) {
11939
+ return truncate(path21.trim());
11854
11940
  }
11855
11941
  }
11856
11942
  if (toolName?.startsWith("mcp__")) {
@@ -11884,9 +11970,9 @@ function getPermissionDetailEntries(toolName, input) {
11884
11970
  }
11885
11971
  }
11886
11972
  if (toolName === "Read" || toolName === "Write" || toolName === "Edit" || toolName === "read" || toolName === "write" || toolName === "edit") {
11887
- const path20 = input.file_path ?? input.path;
11888
- if (typeof path20 === "string") {
11889
- return [{ label: "Path", value: path20 }];
11973
+ const path21 = input.file_path ?? input.path;
11974
+ if (typeof path21 === "string") {
11975
+ return [{ label: "Path", value: path21 }];
11890
11976
  }
11891
11977
  }
11892
11978
  return Object.entries(input).slice(0, 6).map(([key, value]) => ({
@@ -12174,16 +12260,16 @@ __export(registry_exports4, {
12174
12260
  reloadSchedules: () => reloadSchedules,
12175
12261
  validateScheduleRefs: () => validateScheduleRefs
12176
12262
  });
12177
- import fs15 from "fs";
12178
- import path16 from "path";
12263
+ import fs16 from "fs";
12264
+ import path17 from "path";
12179
12265
  import yaml10 from "js-yaml";
12180
12266
  function scanDirectory2(dir) {
12181
12267
  const schedules2 = /* @__PURE__ */ new Map();
12182
- if (!fs15.existsSync(dir)) return schedules2;
12183
- for (const file of fs15.readdirSync(dir)) {
12268
+ if (!fs16.existsSync(dir)) return schedules2;
12269
+ for (const file of fs16.readdirSync(dir)) {
12184
12270
  if (!file.endsWith(".yaml") && !file.endsWith(".yml")) continue;
12185
12271
  try {
12186
- const content = fs15.readFileSync(path16.join(dir, file), "utf-8");
12272
+ const content = fs16.readFileSync(path17.join(dir, file), "utf-8");
12187
12273
  const parsed = yaml10.load(content);
12188
12274
  const result = ScheduleSpecSchema.safeParse(parsed);
12189
12275
  if (!result.success) {
@@ -12239,12 +12325,12 @@ function createScheduleFromYaml(yamlContent) {
12239
12325
  `Invalid schedule: ${result.error.issues.map((i) => i.message).join(", ")}`
12240
12326
  );
12241
12327
  }
12242
- fs15.mkdirSync(USER_DIR, { recursive: true });
12243
- const filePath = path16.join(USER_DIR, `${result.data.id}.yaml`);
12244
- if (fs15.existsSync(filePath)) {
12328
+ fs16.mkdirSync(USER_DIR, { recursive: true });
12329
+ const filePath = path17.join(USER_DIR, `${result.data.id}.yaml`);
12330
+ if (fs16.existsSync(filePath)) {
12245
12331
  throw new Error(`Schedule "${result.data.id}" already exists`);
12246
12332
  }
12247
- fs15.writeFileSync(filePath, yamlContent);
12333
+ fs16.writeFileSync(filePath, yamlContent);
12248
12334
  reloadSchedules();
12249
12335
  return result.data;
12250
12336
  }
@@ -12296,11 +12382,11 @@ function deleteSchedule(id) {
12296
12382
  if (isBuiltinSchedule(id)) {
12297
12383
  throw new Error("Cannot delete built-in schedules");
12298
12384
  }
12299
- const filePath = path16.join(USER_DIR, `${id}.yaml`);
12300
- if (!fs15.existsSync(filePath)) {
12385
+ const filePath = path17.join(USER_DIR, `${id}.yaml`);
12386
+ if (!fs16.existsSync(filePath)) {
12301
12387
  throw new Error(`Schedule "${id}" not found`);
12302
12388
  }
12303
- fs15.unlinkSync(filePath);
12389
+ fs16.unlinkSync(filePath);
12304
12390
  reloadSchedules();
12305
12391
  }
12306
12392
  var BUILTINS_DIR3, USER_DIR, scheduleCache, builtinIdsCache, pluginScheduleIndex;
@@ -12310,7 +12396,7 @@ var init_registry5 = __esm({
12310
12396
  init_schedule_spec();
12311
12397
  init_ainative_paths();
12312
12398
  init_app_root();
12313
- BUILTINS_DIR3 = path16.resolve(
12399
+ BUILTINS_DIR3 = path17.resolve(
12314
12400
  getAppRoot(import.meta.dirname, 4),
12315
12401
  "src",
12316
12402
  "lib",
@@ -12444,8 +12530,8 @@ __export(registry_exports5, {
12444
12530
  reloadPlugins: () => reloadPlugins,
12445
12531
  scanBundleSection: () => scanBundleSection
12446
12532
  });
12447
- import fs16 from "fs";
12448
- import path17 from "path";
12533
+ import fs17 from "fs";
12534
+ import path18 from "path";
12449
12535
  import yaml11 from "js-yaml";
12450
12536
  import { z as z16 } from "zod";
12451
12537
  function isSupportedApiVersion(apiVersion) {
@@ -12454,9 +12540,9 @@ function isSupportedApiVersion(apiVersion) {
12454
12540
  function logToFile5(line) {
12455
12541
  try {
12456
12542
  const logsDir = getAinativeLogsDir();
12457
- fs16.mkdirSync(logsDir, { recursive: true });
12458
- fs16.appendFileSync(
12459
- path17.join(logsDir, "plugins.log"),
12543
+ fs17.mkdirSync(logsDir, { recursive: true });
12544
+ fs17.appendFileSync(
12545
+ path18.join(logsDir, "plugins.log"),
12460
12546
  `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
12461
12547
  `
12462
12548
  );
@@ -12464,11 +12550,11 @@ function logToFile5(line) {
12464
12550
  }
12465
12551
  }
12466
12552
  function readManifest(rootDir) {
12467
- const manifestPath = path17.join(rootDir, "plugin.yaml");
12468
- if (!fs16.existsSync(manifestPath)) return { error: "missing plugin.yaml" };
12553
+ const manifestPath = path18.join(rootDir, "plugin.yaml");
12554
+ if (!fs17.existsSync(manifestPath)) return { error: "missing plugin.yaml" };
12469
12555
  let raw;
12470
12556
  try {
12471
- raw = yaml11.load(fs16.readFileSync(manifestPath, "utf-8"));
12557
+ raw = yaml11.load(fs17.readFileSync(manifestPath, "utf-8"));
12472
12558
  } catch (err2) {
12473
12559
  return { error: `yaml_parse: ${err2 instanceof Error ? err2.message : String(err2)}` };
12474
12560
  }
@@ -12480,16 +12566,16 @@ function readManifest(rootDir) {
12480
12566
  }
12481
12567
  function discoverBundleRoots() {
12482
12568
  const baseDir = getAinativePluginsDir();
12483
- if (!fs16.existsSync(baseDir)) return [];
12484
- return fs16.readdirSync(baseDir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => path17.join(baseDir, e.name)).sort();
12569
+ if (!fs17.existsSync(baseDir)) return [];
12570
+ return fs17.readdirSync(baseDir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => path18.join(baseDir, e.name)).sort();
12485
12571
  }
12486
12572
  function scanBundleSection(opts2) {
12487
- const dir = path17.join(opts2.rootDir, opts2.section);
12488
- if (!fs16.existsSync(dir)) return [];
12573
+ const dir = path18.join(opts2.rootDir, opts2.section);
12574
+ if (!fs17.existsSync(dir)) return [];
12489
12575
  const out = [];
12490
- for (const file of fs16.readdirSync(dir)) {
12576
+ for (const file of fs17.readdirSync(dir)) {
12491
12577
  if (!file.endsWith(".yaml") && !file.endsWith(".yml")) continue;
12492
- const filePath = path17.join(dir, file);
12578
+ const filePath = path18.join(dir, file);
12493
12579
  try {
12494
12580
  const result = opts2.parseFile(filePath);
12495
12581
  if (result !== null) out.push(result);
@@ -12500,8 +12586,8 @@ function scanBundleSection(opts2) {
12500
12586
  return out;
12501
12587
  }
12502
12588
  function scanBundleProfiles(rootDir, pluginId) {
12503
- const profilesDir = path17.join(rootDir, "profiles");
12504
- if (!fs16.existsSync(profilesDir)) return [];
12589
+ const profilesDir = path18.join(rootDir, "profiles");
12590
+ if (!fs17.existsSync(profilesDir)) return [];
12505
12591
  const tmp = /* @__PURE__ */ new Map();
12506
12592
  scanProfilesIntoMap(profilesDir, tmp, { namespace: pluginId });
12507
12593
  return Array.from(tmp.entries()).map(([id, profile]) => ({
@@ -12514,9 +12600,9 @@ function scanBundleBlueprints(rootDir, pluginId, siblingProfileIds) {
12514
12600
  rootDir,
12515
12601
  section: "blueprints",
12516
12602
  parseFile: (filePath) => {
12517
- const file = path17.basename(filePath);
12603
+ const file = path18.basename(filePath);
12518
12604
  try {
12519
- const raw = yaml11.load(fs16.readFileSync(filePath, "utf-8"));
12605
+ const raw = yaml11.load(fs17.readFileSync(filePath, "utf-8"));
12520
12606
  const parsed = BlueprintSchema.safeParse(raw);
12521
12607
  if (!parsed.success) {
12522
12608
  logToFile5(`skip blueprint ${pluginId}/${file}: ${parsed.error.issues.map((i) => i.message).join("; ")}`);
@@ -12542,9 +12628,9 @@ function scanBundleTables(rootDir, pluginId) {
12542
12628
  rootDir,
12543
12629
  section: "tables",
12544
12630
  parseFile: (filePath) => {
12545
- const file = path17.basename(filePath);
12631
+ const file = path18.basename(filePath);
12546
12632
  try {
12547
- const raw = yaml11.load(fs16.readFileSync(filePath, "utf-8"));
12633
+ const raw = yaml11.load(fs17.readFileSync(filePath, "utf-8"));
12548
12634
  const parsed = PluginTableSchema.safeParse(raw);
12549
12635
  if (!parsed.success) {
12550
12636
  logToFile5(`skip table ${pluginId}/${file}: ${parsed.error.issues.map((i) => i.message).join("; ")}`);
@@ -12563,9 +12649,9 @@ function scanBundleSchedules(rootDir, pluginId) {
12563
12649
  rootDir,
12564
12650
  section: "schedules",
12565
12651
  parseFile: (filePath) => {
12566
- const file = path17.basename(filePath);
12652
+ const file = path18.basename(filePath);
12567
12653
  try {
12568
- const raw = yaml11.load(fs16.readFileSync(filePath, "utf-8"));
12654
+ const raw = yaml11.load(fs17.readFileSync(filePath, "utf-8"));
12569
12655
  const parsed = ScheduleSpecSchema.safeParse(raw);
12570
12656
  if (!parsed.success) {
12571
12657
  logToFile5(`skip schedule ${pluginId}/${file}: ${parsed.error.issues.map((i) => i.message).join("; ")}`);
@@ -12652,7 +12738,7 @@ async function scanPlugins() {
12652
12738
  for (const rootDir of discoverBundleRoots()) {
12653
12739
  const { manifest, error } = readManifest(rootDir);
12654
12740
  if (!manifest) {
12655
- const fallbackId = path17.basename(rootDir);
12741
+ const fallbackId = path18.basename(rootDir);
12656
12742
  result.push({
12657
12743
  id: fallbackId,
12658
12744
  manifest: { id: fallbackId, version: "0.0.0", apiVersion: "0.0", kind: "primitives-bundle" },
@@ -12776,7 +12862,7 @@ var init_registry6 = __esm({
12776
12862
  init_registry5();
12777
12863
  init_installer();
12778
12864
  init_schedule_spec();
12779
- SUPPORTED_API_VERSIONS = /* @__PURE__ */ new Set(["0.14", "0.13", "0.12"]);
12865
+ SUPPORTED_API_VERSIONS = /* @__PURE__ */ new Set([CURRENT_PLUGIN_API_VERSION, "0.16"]);
12780
12866
  pluginCache = null;
12781
12867
  lastLoadedPluginIds = /* @__PURE__ */ new Set();
12782
12868
  PluginTableSchema = z16.object({
@@ -12819,8 +12905,8 @@ function pluginTools(_ctx) {
12819
12905
  Promise.resolve().then(() => (init_ainative_paths(), ainative_paths_exports)),
12820
12906
  Promise.resolve().then(() => (init_types(), types_exports))
12821
12907
  ]);
12822
- const fs19 = await import("fs");
12823
- const path20 = await import("path");
12908
+ const fs20 = await import("fs");
12909
+ const path21 = await import("path");
12824
12910
  const yaml13 = await import("js-yaml");
12825
12911
  const kind5 = listPlugins2();
12826
12912
  const registrations = await listPluginMcpRegistrations2();
@@ -12837,13 +12923,13 @@ function pluginTools(_ctx) {
12837
12923
  let manifestHash;
12838
12924
  let capabilityAcceptStatus = "pending";
12839
12925
  try {
12840
- const pluginYamlPath = path20.join(
12926
+ const pluginYamlPath = path21.join(
12841
12927
  pluginsDir,
12842
12928
  pluginId,
12843
12929
  "plugin.yaml"
12844
12930
  );
12845
- if (fs19.existsSync(pluginYamlPath)) {
12846
- const content = fs19.readFileSync(pluginYamlPath, "utf-8");
12931
+ if (fs20.existsSync(pluginYamlPath)) {
12932
+ const content = fs20.readFileSync(pluginYamlPath, "utf-8");
12847
12933
  const rawManifest = yaml13.load(content);
12848
12934
  if (rawManifest !== null && typeof rawManifest === "object" && !Array.isArray(rawManifest)) {
12849
12935
  const record = rawManifest;
@@ -12856,7 +12942,7 @@ function pluginTools(_ctx) {
12856
12942
  try {
12857
12943
  manifestHash = deriveManifestHash2(content);
12858
12944
  const parsed = PluginManifestSchema2.safeParse(rawManifest);
12859
- const pluginRootDir = path20.join(pluginsDir, pluginId);
12945
+ const pluginRootDir = path21.join(pluginsDir, pluginId);
12860
12946
  const check = isCapabilityAccepted2(
12861
12947
  pluginId,
12862
12948
  manifestHash,
@@ -15576,7 +15662,7 @@ var init_runtime_tools = __esm({
15576
15662
  "use strict";
15577
15663
  init_tool_registry();
15578
15664
  init_helpers2();
15579
- init_catalog();
15665
+ init_catalog2();
15580
15666
  }
15581
15667
  });
15582
15668
 
@@ -16690,7 +16776,7 @@ async function activateSkill(args) {
16690
16776
  return { kind: "error", message: `Conversation not found: ${conversationId}` };
16691
16777
  }
16692
16778
  if (mode === "add") {
16693
- const { getRuntimeFeatures: getRuntimeFeatures2 } = await Promise.resolve().then(() => (init_catalog(), catalog_exports));
16779
+ const { getRuntimeFeatures: getRuntimeFeatures2 } = await Promise.resolve().then(() => (init_catalog2(), catalog_exports2));
16694
16780
  let features;
16695
16781
  try {
16696
16782
  features = getRuntimeFeatures2(
@@ -17011,8 +17097,8 @@ var init_schedule_spec_tools = __esm({
17011
17097
 
17012
17098
  // src/lib/chat/tools/plugin-spec-tools.ts
17013
17099
  import { z as z27 } from "zod";
17014
- import * as fs17 from "fs";
17015
- import * as path18 from "path";
17100
+ import * as fs18 from "fs";
17101
+ import * as path19 from "path";
17016
17102
  function validateId(id) {
17017
17103
  if (id.length < 2) {
17018
17104
  throw new PluginSpecInvalidIdError(id, "must be at least 2 chars");
@@ -17040,7 +17126,7 @@ function renderPluginYaml(input) {
17040
17126
  ``,
17041
17127
  `id: ${input.id}`,
17042
17128
  `version: 0.1.0`,
17043
- `apiVersion: "0.14"`,
17129
+ `apiVersion: "${CURRENT_PLUGIN_API_VERSION}"`,
17044
17130
  `kind: chat-tools`,
17045
17131
  `name: ${JSON.stringify(input.name)}`,
17046
17132
  `description: ${JSON.stringify(input.description)}`,
@@ -17275,20 +17361,20 @@ directory at load time \u2014 you do not need to edit that path.
17275
17361
  function scaffoldPluginSpec(input) {
17276
17362
  validateId(input.id);
17277
17363
  const pluginsDir = getAinativePluginsDir();
17278
- const pluginDir = path18.join(pluginsDir, input.id);
17279
- const tmpDir = path18.join(pluginsDir, `${input.id}.tmp-${Date.now()}`);
17280
- if (fs17.existsSync(pluginDir)) {
17364
+ const pluginDir = path19.join(pluginsDir, input.id);
17365
+ const tmpDir = path19.join(pluginsDir, `${input.id}.tmp-${Date.now()}`);
17366
+ if (fs18.existsSync(pluginDir)) {
17281
17367
  throw new PluginSpecAlreadyExistsError(pluginDir);
17282
17368
  }
17283
17369
  try {
17284
- fs17.mkdirSync(tmpDir, { recursive: true });
17285
- fs17.writeFileSync(
17286
- path18.join(tmpDir, "plugin.yaml"),
17370
+ fs18.mkdirSync(tmpDir, { recursive: true });
17371
+ fs18.writeFileSync(
17372
+ path19.join(tmpDir, "plugin.yaml"),
17287
17373
  renderPluginYaml(input),
17288
17374
  "utf-8"
17289
17375
  );
17290
- fs17.writeFileSync(
17291
- path18.join(tmpDir, ".mcp.json"),
17376
+ fs18.writeFileSync(
17377
+ path19.join(tmpDir, ".mcp.json"),
17292
17378
  renderMcpJson({
17293
17379
  id: input.id,
17294
17380
  transport: input.transport,
@@ -17296,8 +17382,8 @@ function scaffoldPluginSpec(input) {
17296
17382
  }),
17297
17383
  "utf-8"
17298
17384
  );
17299
- fs17.writeFileSync(
17300
- path18.join(tmpDir, "server.py"),
17385
+ fs18.writeFileSync(
17386
+ path19.join(tmpDir, "server.py"),
17301
17387
  renderServerPy({
17302
17388
  id: input.id,
17303
17389
  tools: input.tools,
@@ -17306,8 +17392,8 @@ function scaffoldPluginSpec(input) {
17306
17392
  }),
17307
17393
  "utf-8"
17308
17394
  );
17309
- fs17.writeFileSync(
17310
- path18.join(tmpDir, "README.md"),
17395
+ fs18.writeFileSync(
17396
+ path19.join(tmpDir, "README.md"),
17311
17397
  renderReadme({
17312
17398
  id: input.id,
17313
17399
  name: input.name,
@@ -17315,11 +17401,11 @@ function scaffoldPluginSpec(input) {
17315
17401
  }),
17316
17402
  "utf-8"
17317
17403
  );
17318
- fs17.renameSync(tmpDir, pluginDir);
17404
+ fs18.renameSync(tmpDir, pluginDir);
17319
17405
  } catch (cause) {
17320
17406
  try {
17321
- if (fs17.existsSync(tmpDir)) {
17322
- fs17.rmSync(tmpDir, { recursive: true, force: true });
17407
+ if (fs18.existsSync(tmpDir)) {
17408
+ fs18.rmSync(tmpDir, { recursive: true, force: true });
17323
17409
  }
17324
17410
  } catch {
17325
17411
  }
@@ -17330,10 +17416,10 @@ function scaffoldPluginSpec(input) {
17330
17416
  id: input.id,
17331
17417
  pluginDir,
17332
17418
  files: {
17333
- pluginYaml: path18.join(pluginDir, "plugin.yaml"),
17334
- mcpJson: path18.join(pluginDir, ".mcp.json"),
17335
- serverPy: path18.join(pluginDir, "server.py"),
17336
- readme: path18.join(pluginDir, "README.md")
17419
+ pluginYaml: path19.join(pluginDir, "plugin.yaml"),
17420
+ mcpJson: path19.join(pluginDir, ".mcp.json"),
17421
+ serverPy: path19.join(pluginDir, "server.py"),
17422
+ readme: path19.join(pluginDir, "README.md")
17337
17423
  },
17338
17424
  tools: input.tools.map((t) => t.name),
17339
17425
  message: `Scaffolded ${input.id}. Reload ainative to register.`
@@ -17399,6 +17485,7 @@ var init_plugin_spec_tools = __esm({
17399
17485
  init_tool_registry();
17400
17486
  init_helpers2();
17401
17487
  init_ainative_paths();
17488
+ init_types();
17402
17489
  PluginSpecAlreadyExistsError = class extends Error {
17403
17490
  constructor(pluginDir) {
17404
17491
  super(
@@ -18864,7 +18951,7 @@ var init_claude = __esm({
18864
18951
  init_registry2();
18865
18952
  init_compatibility();
18866
18953
  init_claude_agent();
18867
- init_catalog();
18954
+ init_catalog2();
18868
18955
  init_claude_sdk();
18869
18956
  init_workspace_context();
18870
18957
  init_helpers();
@@ -19271,13 +19358,13 @@ var init_codex_app_server_client = __esm({
19271
19358
  await syncPluginMcpToCodex2();
19272
19359
  } catch (err2) {
19273
19360
  try {
19274
- const fs19 = await import("fs");
19275
- const path20 = await import("path");
19361
+ const fs20 = await import("fs");
19362
+ const path21 = await import("path");
19276
19363
  const { getAinativeLogsDir: getAinativeLogsDir2 } = await Promise.resolve().then(() => (init_ainative_paths(), ainative_paths_exports));
19277
19364
  const dir = getAinativeLogsDir2();
19278
- fs19.mkdirSync(dir, { recursive: true });
19279
- fs19.appendFileSync(
19280
- path20.join(dir, "plugins.log"),
19365
+ fs20.mkdirSync(dir, { recursive: true });
19366
+ fs20.appendFileSync(
19367
+ path21.join(dir, "plugins.log"),
19281
19368
  `${(/* @__PURE__ */ new Date()).toISOString()} codex-sync-failed: ${err2 instanceof Error ? err2.message : String(err2)}
19282
19369
  `
19283
19370
  );
@@ -20403,7 +20490,7 @@ var init_openai_codex = __esm({
20403
20490
  init_context_builder();
20404
20491
  init_output_scanner();
20405
20492
  init_permissions();
20406
- init_catalog();
20493
+ init_catalog2();
20407
20494
  init_workspace_context();
20408
20495
  init_openai_codex_auth();
20409
20496
  init_launch_failure();
@@ -21016,7 +21103,7 @@ var init_anthropic_direct = __esm({
21016
21103
  init_ainative_tools();
21017
21104
  init_tool_permissions();
21018
21105
  init_agentic_loop();
21019
- init_catalog();
21106
+ init_catalog2();
21020
21107
  init_registry2();
21021
21108
  init_ledger();
21022
21109
  init_output_scanner();
@@ -21450,7 +21537,7 @@ var init_openai_direct = __esm({
21450
21537
  init_ainative_tools();
21451
21538
  init_tool_permissions();
21452
21539
  init_agentic_loop();
21453
- init_catalog();
21540
+ init_catalog2();
21454
21541
  init_registry2();
21455
21542
  init_ledger();
21456
21543
  init_output_scanner();
@@ -21757,7 +21844,7 @@ var init_ollama_adapter = __esm({
21757
21844
  init_schema();
21758
21845
  init_execution_manager();
21759
21846
  init_claude_agent();
21760
- init_catalog();
21847
+ init_catalog2();
21761
21848
  init_registry2();
21762
21849
  init_ledger();
21763
21850
  DEFAULT_OLLAMA_BASE_URL = "http://localhost:11434";
@@ -21794,7 +21881,7 @@ var updateAuthSettingsSchema, updateOpenAISettingsSchema, nullablePositiveNumber
21794
21881
  var init_settings3 = __esm({
21795
21882
  "src/lib/validators/settings.ts"() {
21796
21883
  "use strict";
21797
- init_catalog();
21884
+ init_catalog2();
21798
21885
  updateAuthSettingsSchema = z29.object({
21799
21886
  method: z29.enum(["api_key", "oauth"]).optional(),
21800
21887
  apiKey: z29.string().startsWith("sk-ant-", "API key must start with sk-ant-").optional(),
@@ -21897,7 +21984,7 @@ function listConfiguredRuntimeIds(states) {
21897
21984
  var init_runtime_setup = __esm({
21898
21985
  "src/lib/settings/runtime-setup.ts"() {
21899
21986
  "use strict";
21900
- init_catalog();
21987
+ init_catalog2();
21901
21988
  init_auth();
21902
21989
  init_openai_auth();
21903
21990
  }
@@ -22317,7 +22404,7 @@ var init_budget_guardrails = __esm({
22317
22404
  init_db();
22318
22405
  init_schema();
22319
22406
  init_settings();
22320
- init_catalog();
22407
+ init_catalog2();
22321
22408
  init_helpers();
22322
22409
  init_settings3();
22323
22410
  init_ledger();
@@ -22372,7 +22459,7 @@ var runtimeRegistry;
22372
22459
  var init_runtime = __esm({
22373
22460
  "src/lib/agents/runtime/index.ts"() {
22374
22461
  "use strict";
22375
- init_catalog();
22462
+ init_catalog2();
22376
22463
  init_claude();
22377
22464
  init_openai_codex();
22378
22465
  init_anthropic_direct();
@@ -22647,7 +22734,7 @@ var init_execution_target = __esm({
22647
22734
  init_registry2();
22648
22735
  init_compatibility();
22649
22736
  init_router();
22650
- init_catalog();
22737
+ init_catalog2();
22651
22738
  init_runtime();
22652
22739
  init_routing();
22653
22740
  init_runtime_setup();
@@ -22829,7 +22916,7 @@ var init_task_dispatch = __esm({
22829
22916
  init_runtime();
22830
22917
  init_execution_target();
22831
22918
  init_launch_failure();
22832
- init_catalog();
22919
+ init_catalog2();
22833
22920
  }
22834
22921
  });
22835
22922
 
@@ -22869,14 +22956,14 @@ function resolvePostAction(action, row, itemVariable) {
22869
22956
  function substituteRowPath(template, row, itemVariable) {
22870
22957
  const escaped = itemVariable.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
22871
22958
  const pattern = new RegExp(`\\{\\{\\s*${escaped}\\.([\\w.]+)\\s*\\}\\}`, "g");
22872
- return template.replace(pattern, (_match, path20) => {
22873
- const value = readPath(row, path20);
22959
+ return template.replace(pattern, (_match, path21) => {
22960
+ const value = readPath(row, path21);
22874
22961
  if (value === void 0 || value === null) return "";
22875
22962
  return String(value);
22876
22963
  });
22877
22964
  }
22878
- function readPath(obj, path20) {
22879
- const parts = path20.split(".");
22965
+ function readPath(obj, path21) {
22966
+ const parts = path21.split(".");
22880
22967
  let current = obj;
22881
22968
  for (const part of parts) {
22882
22969
  if (current === null || current === void 0) return void 0;
@@ -23063,14 +23150,14 @@ ${resolvedTemplate}`);
23063
23150
  return parts.join("");
23064
23151
  }
23065
23152
  function resolveRowTemplate(template, context) {
23066
- return template.replace(/\{\{\s*([^}]+)\s*\}\}/g, (_match, path20) => {
23067
- const value = readContextPath(context, path20.trim());
23153
+ return template.replace(/\{\{\s*([^}]+)\s*\}\}/g, (_match, path21) => {
23154
+ const value = readContextPath(context, path21.trim());
23068
23155
  if (value === void 0 || value === null) return "";
23069
23156
  return typeof value === "string" ? value : JSON.stringify(value);
23070
23157
  });
23071
23158
  }
23072
- function readContextPath(value, path20) {
23073
- const parts = path20.split(".");
23159
+ function readContextPath(value, path21) {
23160
+ const parts = path21.split(".");
23074
23161
  let current = value;
23075
23162
  for (const part of parts) {
23076
23163
  if (current === null || current === void 0) return void 0;
@@ -24803,7 +24890,7 @@ var init_engine = __esm({
24803
24890
  init_learning_session();
24804
24891
  init_context_builder();
24805
24892
  init_cost_estimator();
24806
- init_catalog();
24893
+ init_catalog2();
24807
24894
  init_helpers();
24808
24895
  init_execution_stats();
24809
24896
  }
@@ -25435,20 +25522,20 @@ var install_exports = {};
25435
25522
  __export(install_exports, {
25436
25523
  installPack: () => installPack
25437
25524
  });
25438
- import fs18 from "fs";
25439
- import path19 from "path";
25525
+ import fs19 from "fs";
25526
+ import path20 from "path";
25440
25527
  import os4 from "os";
25441
25528
  import { execFileSync as execFileSync3 } from "child_process";
25442
25529
  import yaml12 from "js-yaml";
25443
25530
  import semver from "semver";
25444
25531
  function relayCoreVersion() {
25445
- if (semver.valid("0.17.0")) {
25446
- return "0.17.0";
25532
+ if (semver.valid("0.18.0")) {
25533
+ return "0.18.0";
25447
25534
  }
25448
25535
  try {
25449
25536
  const root = getAppRoot(import.meta.dirname, 3);
25450
25537
  const pkg2 = JSON.parse(
25451
- fs18.readFileSync(path19.join(root, "package.json"), "utf-8")
25538
+ fs19.readFileSync(path20.join(root, "package.json"), "utf-8")
25452
25539
  );
25453
25540
  if (pkg2.version && semver.valid(pkg2.version)) return pkg2.version;
25454
25541
  } catch {
@@ -25460,7 +25547,11 @@ async function installPack(source, options = {}) {
25460
25547
  const profilesDir = options.profilesDir ?? getAinativeProfilesDir();
25461
25548
  const blueprintsDir = options.blueprintsDir ?? getAinativeBlueprintsDir();
25462
25549
  const coreVersion = options.coreVersion ?? relayCoreVersion();
25463
- const { dir: packDir, cleanup } = acquirePack(source);
25550
+ const { resolvePackSource: resolvePackSource2 } = await Promise.resolve().then(() => (init_catalog(), catalog_exports));
25551
+ const resolvedSource = resolvePackSource2(source, {
25552
+ templatesDir: options.templatesDir
25553
+ });
25554
+ const { dir: packDir, cleanup } = acquirePack(resolvedSource);
25464
25555
  try {
25465
25556
  const pack = parsePack(packDir);
25466
25557
  if (pack.meta.relayCore) {
@@ -25565,25 +25656,25 @@ function isGitUrl(source) {
25565
25656
  }
25566
25657
  function acquirePack(source) {
25567
25658
  if (!isGitUrl(source)) {
25568
- const resolved = path19.resolve(source);
25569
- if (!fs18.existsSync(resolved)) {
25659
+ const resolved = path20.resolve(source);
25660
+ if (!fs19.existsSync(resolved)) {
25570
25661
  throw new PackValidationError(`Pack path does not exist: ${resolved}`);
25571
25662
  }
25572
25663
  return { dir: resolved, cleanup: () => {
25573
25664
  } };
25574
25665
  }
25575
- const tmp = fs18.mkdtempSync(path19.join(os4.tmpdir(), "ainative-pack-clone-"));
25666
+ const tmp = fs19.mkdtempSync(path20.join(os4.tmpdir(), "ainative-pack-clone-"));
25576
25667
  try {
25577
25668
  execFileSync3("git", ["clone", "--depth", "1", source, tmp], {
25578
25669
  stdio: "pipe"
25579
25670
  });
25580
25671
  } catch (err2) {
25581
- fs18.rmSync(tmp, { recursive: true, force: true });
25672
+ fs19.rmSync(tmp, { recursive: true, force: true });
25582
25673
  throw new PackValidationError(`git clone failed for ${source}`, err2);
25583
25674
  }
25584
25675
  return {
25585
25676
  dir: tmp,
25586
- cleanup: () => fs18.rmSync(tmp, { recursive: true, force: true })
25677
+ cleanup: () => fs19.rmSync(tmp, { recursive: true, force: true })
25587
25678
  };
25588
25679
  }
25589
25680
  function findResolved(files, relPath) {
@@ -25592,7 +25683,7 @@ function findResolved(files, relPath) {
25592
25683
  function readCustomerSeed(resolved) {
25593
25684
  const file = findResolved(resolved.files, "seed/customers.yaml");
25594
25685
  if (!file) return [];
25595
- const parsed = yaml12.load(fs18.readFileSync(file.absPath, "utf-8"));
25686
+ const parsed = yaml12.load(fs19.readFileSync(file.absPath, "utf-8"));
25596
25687
  if (!Array.isArray(parsed)) {
25597
25688
  throw new PackValidationError(
25598
25689
  "seed/customers.yaml must be a YAML list of { slug, name, ... }"
@@ -25604,7 +25695,7 @@ function readTableSeed(resolved, logicalId) {
25604
25695
  for (const ext of ["json", "yaml", "yml"]) {
25605
25696
  const file = findResolved(resolved.files, `seed/tables/${logicalId}.${ext}`);
25606
25697
  if (!file) continue;
25607
- const text2 = fs18.readFileSync(file.absPath, "utf-8");
25698
+ const text2 = fs19.readFileSync(file.absPath, "utf-8");
25608
25699
  const parsed = ext === "json" ? JSON.parse(text2) : yaml12.load(text2);
25609
25700
  if (!Array.isArray(parsed)) {
25610
25701
  throw new PackValidationError(
@@ -25649,7 +25740,7 @@ function rewriteViewTableRefs(view, logicalToReal) {
25649
25740
  return view;
25650
25741
  }
25651
25742
  function writeManifest(appsDir, appId, manifest) {
25652
- fs18.mkdirSync(path19.join(appsDir, appId), { recursive: true });
25743
+ fs19.mkdirSync(path20.join(appsDir, appId), { recursive: true });
25653
25744
  writeAppManifest(appId, manifest, appsDir);
25654
25745
  }
25655
25746
  function dropArtifacts(files, profilesDir, blueprintsDir) {
@@ -25657,18 +25748,18 @@ function dropArtifacts(files, profilesDir, blueprintsDir) {
25657
25748
  let blueprintsDropped = 0;
25658
25749
  for (const file of files) {
25659
25750
  if (file.relPath.startsWith("profiles/")) {
25660
- const dest = path19.join(profilesDir, file.relPath.slice("profiles/".length));
25661
- fs18.mkdirSync(path19.dirname(dest), { recursive: true });
25662
- fs18.copyFileSync(file.absPath, dest);
25751
+ const dest = path20.join(profilesDir, file.relPath.slice("profiles/".length));
25752
+ fs19.mkdirSync(path20.dirname(dest), { recursive: true });
25753
+ fs19.copyFileSync(file.absPath, dest);
25663
25754
  const top = file.relPath.split("/")[1];
25664
25755
  if (top) profileDirs.add(top);
25665
25756
  } else if (file.relPath.startsWith("blueprints/") && file.relPath.endsWith(".yaml")) {
25666
- const dest = path19.join(
25757
+ const dest = path20.join(
25667
25758
  blueprintsDir,
25668
25759
  file.relPath.slice("blueprints/".length)
25669
25760
  );
25670
- fs18.mkdirSync(path19.dirname(dest), { recursive: true });
25671
- fs18.copyFileSync(file.absPath, dest);
25761
+ fs19.mkdirSync(path20.dirname(dest), { recursive: true });
25762
+ fs19.copyFileSync(file.absPath, dest);
25672
25763
  blueprintsDropped += 1;
25673
25764
  }
25674
25765
  }
@@ -25729,7 +25820,7 @@ async function runPackCommand(argv, io) {
25729
25820
  }
25730
25821
  async function runAdd(source, licenseUrl, io) {
25731
25822
  if (!source) {
25732
- io.error("Missing pack path. Usage: relay pack add <path|git-url>");
25823
+ io.error("Missing pack source. Usage: relay pack add <name|path|git-url>");
25733
25824
  return 1;
25734
25825
  }
25735
25826
  try {
@@ -25815,7 +25906,7 @@ var init_cli = __esm({
25815
25906
  init_ainative_paths();
25816
25907
  USAGE = [
25817
25908
  "Usage: relay pack <action>",
25818
- " add <path|git-url> [--license-url=<path|url>] install a pack",
25909
+ " add <name|path|git-url> [--license-url=<path|url>] install a pack",
25819
25910
  " list list installed packs",
25820
25911
  " remove <id> uninstall a pack",
25821
25912
  " update <id> (v1 stub \u2014 editable-seed; edit in place)"
@@ -26288,10 +26379,10 @@ import { existsSync as existsSync4, renameSync, cpSync, rmSync as rmSync2, readF
26288
26379
  import { join as join6 } from "path";
26289
26380
  import { homedir as homedir2 } from "os";
26290
26381
  import Database from "better-sqlite3";
26291
- function hasSqliteHeader(path20) {
26382
+ function hasSqliteHeader(path21) {
26292
26383
  const SQLITE_MAGIC = "SQLite format 3\0";
26293
26384
  try {
26294
- const header = readFileSync3(path20, { encoding: null });
26385
+ const header = readFileSync3(path21, { encoding: null });
26295
26386
  return header.length >= 16 && header.subarray(0, 16).toString("binary") === SQLITE_MAGIC;
26296
26387
  } catch {
26297
26388
  return false;