orionfold-relay 0.27.0 → 0.28.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.
Files changed (103) hide show
  1. package/dist/cli.js +414 -344
  2. package/package.json +1 -1
  3. package/src/app/{profiles → agents}/[id]/edit/page.tsx +2 -2
  4. package/src/app/{profiles → agents}/[id]/page.tsx +1 -1
  5. package/src/app/{profiles → agents}/new/page.tsx +1 -1
  6. package/src/app/{profiles → agents}/page.tsx +2 -2
  7. package/src/app/api/{profiles → agents}/[id]/context/route.ts +3 -3
  8. package/src/app/api/{profiles → agents}/[id]/test/route.ts +1 -1
  9. package/src/app/api/{profiles → agents}/[id]/test-results/route.ts +1 -1
  10. package/src/app/api/{profiles → agents}/[id]/test-single/route.ts +1 -1
  11. package/src/app/api/{profiles → agents}/import/route.ts +1 -1
  12. package/src/app/api/{profiles → agents}/import-repo/apply-updates/route.ts +1 -1
  13. package/src/app/api/{profiles → agents}/import-repo/check-updates/route.ts +1 -1
  14. package/src/app/api/{profiles → agents}/import-repo/confirm/route.ts +1 -1
  15. package/src/app/api/{profiles → agents}/import-repo/preview/route.ts +1 -1
  16. package/src/app/api/{profiles → agents}/import-repo/route.ts +1 -1
  17. package/src/app/api/{profiles → agents}/import-repo/scan/route.ts +1 -1
  18. package/src/app/api/{profiles → agents}/route.ts +3 -3
  19. package/src/app/{workflows/blueprints → blueprints}/[id]/page.tsx +1 -1
  20. package/src/app/{workflows/blueprints → blueprints}/new/page.tsx +1 -1
  21. package/src/app/{tables/templates → schemas}/page.tsx +2 -2
  22. package/src/components/apps/last-run-card.tsx +6 -6
  23. package/src/components/apps/ledger-hero-panel.tsx +1 -1
  24. package/src/components/apps/run-now-actions.ts +87 -0
  25. package/src/components/apps/run-now-button.tsx +64 -48
  26. package/src/components/apps/run-now-sheet.tsx +30 -31
  27. package/src/components/apps/run-now-toast.ts +21 -0
  28. package/src/components/dashboard/quick-actions.tsx +1 -1
  29. package/src/components/profiles/context-proposal-review.tsx +1 -1
  30. package/src/components/profiles/learned-context-panel.tsx +3 -3
  31. package/src/components/profiles/profile-assist-panel.tsx +4 -4
  32. package/src/components/profiles/profile-browser.tsx +9 -9
  33. package/src/components/profiles/profile-detail-view.tsx +15 -15
  34. package/src/components/profiles/profile-form-view.tsx +14 -14
  35. package/src/components/profiles/profile-import-dialog.tsx +2 -2
  36. package/src/components/profiles/repo-import-wizard.tsx +3 -3
  37. package/src/components/schedules/schedule-create-dialog.tsx +1 -1
  38. package/src/components/schedules/schedule-form.tsx +1 -1
  39. package/src/components/shared/command-palette.tsx +1 -1
  40. package/src/components/shared/global-shortcuts.tsx +1 -1
  41. package/src/components/shell/nav-items.ts +5 -1
  42. package/src/components/tables/table-browser.tsx +2 -2
  43. package/src/components/tables/table-enrichment-sheet.tsx +1 -1
  44. package/src/components/tables/table-template-gallery.tsx +3 -3
  45. package/src/components/tasks/task-create-panel.tsx +1 -1
  46. package/src/components/tasks/task-edit-dialog.tsx +1 -1
  47. package/src/components/workflows/blueprint-gallery.tsx +3 -3
  48. package/src/components/workflows/workflow-page-actions.tsx +1 -1
  49. package/src/hooks/use-project-skills.ts +1 -1
  50. package/src/hooks/use-tag-suggestions.ts +1 -1
  51. package/src/lib/agents/profiles/agent-file.ts +36 -0
  52. package/src/lib/agents/profiles/app-manifest-source.ts +8 -4
  53. package/src/lib/agents/profiles/project-profiles.ts +7 -6
  54. package/src/lib/agents/profiles/registry.ts +39 -18
  55. package/src/lib/chat/command-data.ts +2 -2
  56. package/src/lib/notifications/actionable.ts +1 -1
  57. package/src/lib/plugins/examples/echo-server/plugin.yaml +1 -1
  58. package/src/lib/plugins/examples/finance-pack/plugin.yaml +1 -1
  59. package/src/lib/plugins/examples/reading-radar/plugin.yaml +1 -1
  60. package/src/lib/plugins/registry.ts +1 -1
  61. package/src/lib/plugins/sdk/types.ts +1 -1
  62. package/src/lib/utils/migrate-to-ainative.ts +63 -1
  63. /package/src/app/api/{profiles → agents}/[id]/route.ts +0 -0
  64. /package/src/app/api/{profiles → agents}/assist/route.ts +0 -0
  65. /package/src/app/{workflows/blueprints → blueprints}/page.tsx +0 -0
  66. /package/src/lib/agents/profiles/builtins/code-reviewer/{profile.yaml → agent.yaml} +0 -0
  67. /package/src/lib/agents/profiles/builtins/content-creator/{profile.yaml → agent.yaml} +0 -0
  68. /package/src/lib/agents/profiles/builtins/customer-support-agent/{profile.yaml → agent.yaml} +0 -0
  69. /package/src/lib/agents/profiles/builtins/data-analyst/{profile.yaml → agent.yaml} +0 -0
  70. /package/src/lib/agents/profiles/builtins/devops-engineer/{profile.yaml → agent.yaml} +0 -0
  71. /package/src/lib/agents/profiles/builtins/document-writer/{profile.yaml → agent.yaml} +0 -0
  72. /package/src/lib/agents/profiles/builtins/financial-analyst/{profile.yaml → agent.yaml} +0 -0
  73. /package/src/lib/agents/profiles/builtins/general/{profile.yaml → agent.yaml} +0 -0
  74. /package/src/lib/agents/profiles/builtins/health-fitness-coach/{profile.yaml → agent.yaml} +0 -0
  75. /package/src/lib/agents/profiles/builtins/learning-coach/{profile.yaml → agent.yaml} +0 -0
  76. /package/src/lib/agents/profiles/builtins/marketing-strategist/{profile.yaml → agent.yaml} +0 -0
  77. /package/src/lib/agents/profiles/builtins/operations-coordinator/{profile.yaml → agent.yaml} +0 -0
  78. /package/src/lib/agents/profiles/builtins/project-manager/{profile.yaml → agent.yaml} +0 -0
  79. /package/src/lib/agents/profiles/builtins/researcher/{profile.yaml → agent.yaml} +0 -0
  80. /package/src/lib/agents/profiles/builtins/sales-researcher/{profile.yaml → agent.yaml} +0 -0
  81. /package/src/lib/agents/profiles/builtins/shopping-assistant/{profile.yaml → agent.yaml} +0 -0
  82. /package/src/lib/agents/profiles/builtins/sweep/{profile.yaml → agent.yaml} +0 -0
  83. /package/src/lib/agents/profiles/builtins/technical-writer/{profile.yaml → agent.yaml} +0 -0
  84. /package/src/lib/agents/profiles/builtins/travel-planner/{profile.yaml → agent.yaml} +0 -0
  85. /package/src/lib/agents/profiles/builtins/upgrade-assistant/{profile.yaml → agent.yaml} +0 -0
  86. /package/src/lib/agents/profiles/builtins/wealth-manager/{profile.yaml → agent.yaml} +0 -0
  87. /package/src/lib/packs/templates/relay-agency/base/profiles/relay-agency--bookkeeper/{profile.yaml → agent.yaml} +0 -0
  88. /package/src/lib/packs/templates/relay-agency/base/profiles/relay-agency--cre-analyst/{profile.yaml → agent.yaml} +0 -0
  89. /package/src/lib/packs/templates/relay-agency/base/profiles/relay-agency--cre-listing-writer/{profile.yaml → agent.yaml} +0 -0
  90. /package/src/lib/packs/templates/relay-agency/base/profiles/relay-agency--governance-officer/{profile.yaml → agent.yaml} +0 -0
  91. /package/src/lib/packs/templates/relay-agency/base/profiles/relay-agency--grant-researcher/{profile.yaml → agent.yaml} +0 -0
  92. /package/src/lib/packs/templates/relay-agency/base/profiles/relay-agency--impact-writer/{profile.yaml → agent.yaml} +0 -0
  93. /package/src/lib/packs/templates/relay-agency/base/profiles/relay-agency--onboarding-runner/{profile.yaml → agent.yaml} +0 -0
  94. /package/src/lib/packs/templates/relay-agency-pro/base/profiles/relay-agency-pro--cre-renewal-analyst/{profile.yaml → agent.yaml} +0 -0
  95. /package/src/lib/packs/templates/relay-agency-pro/base/profiles/relay-agency-pro--finance-controller/{profile.yaml → agent.yaml} +0 -0
  96. /package/src/lib/packs/templates/relay-agency-pro/base/profiles/relay-agency-pro--governance-auditor/{profile.yaml → agent.yaml} +0 -0
  97. /package/src/lib/packs/templates/relay-agency-pro/base/profiles/relay-agency-pro--intake-coordinator/{profile.yaml → agent.yaml} +0 -0
  98. /package/src/lib/packs/templates/relay-agency-pro/base/profiles/relay-agency-pro--nonprofit-grants-analyst/{profile.yaml → agent.yaml} +0 -0
  99. /package/src/lib/packs/templates/relay-agency-pro/base/profiles/relay-agency-pro--proposal-writer/{profile.yaml → agent.yaml} +0 -0
  100. /package/src/lib/packs/templates/relay-agency-pro/base/profiles/relay-agency-pro--prospect-researcher/{profile.yaml → agent.yaml} +0 -0
  101. /package/src/lib/packs/templates/relay-agency-pro/base/profiles/relay-agency-pro--sensitive-client-analyst/{profile.yaml → agent.yaml} +0 -0
  102. /package/src/lib/plugins/examples/finance-pack/profiles/personal-cfo/{profile.yaml → agent.yaml} +0 -0
  103. /package/src/lib/plugins/examples/reading-radar/profiles/reader-coach/{profile.yaml → agent.yaml} +0 -0
package/dist/cli.js CHANGED
@@ -1186,7 +1186,7 @@ var CURRENT_PLUGIN_API_VERSION, CAPABILITY_VALUES, ORIGIN_VALUES, PrimitivesBund
1186
1186
  var init_types = __esm({
1187
1187
  "src/lib/plugins/sdk/types.ts"() {
1188
1188
  "use strict";
1189
- CURRENT_PLUGIN_API_VERSION = "0.27";
1189
+ CURRENT_PLUGIN_API_VERSION = "0.28";
1190
1190
  CAPABILITY_VALUES = ["fs", "net", "child_process", "env"];
1191
1191
  ORIGIN_VALUES = ["ainative-internal", "third-party"];
1192
1192
  PrimitivesBundleManifestSchema = z.object({
@@ -1232,16 +1232,16 @@ function computeHash(content) {
1232
1232
  function safePreview(content) {
1233
1233
  return content.slice(0, MAX_PREVIEW_CHARS).trim();
1234
1234
  }
1235
- function safeStat(path24) {
1235
+ function safeStat(path25) {
1236
1236
  try {
1237
- return statSync2(path24);
1237
+ return statSync2(path25);
1238
1238
  } catch {
1239
1239
  return null;
1240
1240
  }
1241
1241
  }
1242
- function safeReadFile(path24) {
1242
+ function safeReadFile(path25) {
1243
1243
  try {
1244
- return readFileSync4(path24, "utf-8");
1244
+ return readFileSync4(path25, "utf-8");
1245
1245
  } catch {
1246
1246
  return null;
1247
1247
  }
@@ -5134,25 +5134,47 @@ var init_compatibility = __esm({
5134
5134
  }
5135
5135
  });
5136
5136
 
5137
- // src/lib/agents/profiles/project-profiles.ts
5137
+ // src/lib/agents/profiles/agent-file.ts
5138
5138
  import fs8 from "fs";
5139
5139
  import path7 from "path";
5140
+ function resolveAgentFile(dir) {
5141
+ const agentPath = path7.join(dir, AGENT_FILENAME);
5142
+ if (fs8.existsSync(agentPath)) return agentPath;
5143
+ const legacyPath = path7.join(dir, LEGACY_PROFILE_FILENAME);
5144
+ if (fs8.existsSync(legacyPath)) return legacyPath;
5145
+ return null;
5146
+ }
5147
+ function hasAgentFile(dir) {
5148
+ return resolveAgentFile(dir) !== null;
5149
+ }
5150
+ var AGENT_FILENAME, LEGACY_PROFILE_FILENAME;
5151
+ var init_agent_file = __esm({
5152
+ "src/lib/agents/profiles/agent-file.ts"() {
5153
+ "use strict";
5154
+ AGENT_FILENAME = "agent.yaml";
5155
+ LEGACY_PROFILE_FILENAME = "profile.yaml";
5156
+ }
5157
+ });
5158
+
5159
+ // src/lib/agents/profiles/project-profiles.ts
5160
+ import fs9 from "fs";
5161
+ import path8 from "path";
5140
5162
  import yaml4 from "js-yaml";
5141
5163
  function getProjectSkillsSignature(skillsDir) {
5142
- if (!fs8.existsSync(skillsDir)) return "missing";
5143
- const entries = fs8.readdirSync(skillsDir, { withFileTypes: true }).filter((e) => e.isDirectory()).sort((a, b) => a.name.localeCompare(b.name));
5164
+ if (!fs9.existsSync(skillsDir)) return "missing";
5165
+ const entries = fs9.readdirSync(skillsDir, { withFileTypes: true }).filter((e) => e.isDirectory()).sort((a, b) => a.name.localeCompare(b.name));
5144
5166
  const parts = [];
5145
5167
  for (const entry of entries) {
5146
- const dir = path7.join(skillsDir, entry.name);
5168
+ const dir = path8.join(skillsDir, entry.name);
5147
5169
  parts.push(entry.name);
5148
- const yamlPath = path7.join(dir, "profile.yaml");
5149
- if (fs8.existsSync(yamlPath)) {
5150
- const s = fs8.statSync(yamlPath);
5170
+ const yamlPath = resolveAgentFile(dir);
5171
+ if (yamlPath) {
5172
+ const s = fs9.statSync(yamlPath);
5151
5173
  parts.push(`yaml:${s.mtimeMs}:${s.size}`);
5152
5174
  }
5153
- const skillPath = path7.join(dir, "SKILL.md");
5154
- if (fs8.existsSync(skillPath)) {
5155
- const s = fs8.statSync(skillPath);
5175
+ const skillPath = path8.join(dir, "SKILL.md");
5176
+ if (fs9.existsSync(skillPath)) {
5177
+ const s = fs9.statSync(skillPath);
5156
5178
  parts.push(`skill:${s.mtimeMs}:${s.size}`);
5157
5179
  }
5158
5180
  }
@@ -5173,8 +5195,8 @@ function parseFrontmatter(content) {
5173
5195
  return fm;
5174
5196
  }
5175
5197
  function generateMinimalProfile(skillDir, dirName, projectDir) {
5176
- const skillPath = path7.join(skillDir, "SKILL.md");
5177
- const skillMd = fs8.readFileSync(skillPath, "utf-8");
5198
+ const skillPath = path8.join(skillDir, "SKILL.md");
5199
+ const skillMd = fs9.readFileSync(skillPath, "utf-8");
5178
5200
  const fm = parseFrontmatter(skillMd);
5179
5201
  return {
5180
5202
  id: dirName,
@@ -5191,31 +5213,31 @@ function generateMinimalProfile(skillDir, dirName, projectDir) {
5191
5213
  };
5192
5214
  }
5193
5215
  function scanProjectProfiles(projectDir) {
5194
- const skillsDir = path7.join(projectDir, ".claude", "skills");
5195
- if (!fs8.existsSync(skillsDir)) return [];
5216
+ const skillsDir = path8.join(projectDir, ".claude", "skills");
5217
+ if (!fs9.existsSync(skillsDir)) return [];
5196
5218
  const signature = getProjectSkillsSignature(skillsDir);
5197
5219
  const cached = projectProfileCache.get(projectDir);
5198
5220
  if (cached && cached.signature === signature) return cached.profiles;
5199
5221
  const profiles = [];
5200
- for (const entry of fs8.readdirSync(skillsDir, { withFileTypes: true })) {
5222
+ for (const entry of fs9.readdirSync(skillsDir, { withFileTypes: true })) {
5201
5223
  if (!entry.isDirectory()) continue;
5202
- const dir = path7.join(skillsDir, entry.name);
5203
- const yamlPath = path7.join(dir, "profile.yaml");
5204
- const skillPath = path7.join(dir, "SKILL.md");
5205
- if (fs8.existsSync(yamlPath) && fs8.existsSync(skillPath)) {
5224
+ const dir = path8.join(skillsDir, entry.name);
5225
+ const yamlPath = resolveAgentFile(dir);
5226
+ const skillPath = path8.join(dir, "SKILL.md");
5227
+ if (yamlPath && fs9.existsSync(skillPath)) {
5206
5228
  try {
5207
- const rawYaml = fs8.readFileSync(yamlPath, "utf-8");
5229
+ const rawYaml = fs9.readFileSync(yamlPath, "utf-8");
5208
5230
  const parsed = yaml4.load(rawYaml);
5209
5231
  const result = ProfileConfigSchema.safeParse(parsed);
5210
5232
  if (!result.success) {
5211
5233
  console.warn(
5212
- `[project-profiles] Invalid profile.yaml in ${entry.name}:`,
5234
+ `[project-profiles] Invalid agent manifest in ${entry.name}:`,
5213
5235
  result.error.issues.map((i) => i.message).join(", ")
5214
5236
  );
5215
5237
  continue;
5216
5238
  }
5217
5239
  const config = result.data;
5218
- const skillMd = fs8.readFileSync(skillPath, "utf-8");
5240
+ const skillMd = fs9.readFileSync(skillPath, "utf-8");
5219
5241
  const descMatch = skillMd.match(
5220
5242
  /^---\s*\n[\s\S]*?description:\s*(.+?)\s*\n[\s\S]*?---/
5221
5243
  );
@@ -5249,7 +5271,7 @@ function scanProjectProfiles(projectDir) {
5249
5271
  err2
5250
5272
  );
5251
5273
  }
5252
- } else if (fs8.existsSync(skillPath)) {
5274
+ } else if (fs9.existsSync(skillPath)) {
5253
5275
  try {
5254
5276
  profiles.push(generateMinimalProfile(dir, entry.name, projectDir));
5255
5277
  } catch (err2) {
@@ -5269,13 +5291,14 @@ var init_project_profiles = __esm({
5269
5291
  "use strict";
5270
5292
  init_profile();
5271
5293
  init_compatibility();
5294
+ init_agent_file();
5272
5295
  projectProfileCache = /* @__PURE__ */ new Map();
5273
5296
  }
5274
5297
  });
5275
5298
 
5276
5299
  // src/lib/environment/profile-linker.ts
5277
5300
  import { eq as eq6, and as and2, isNull } from "drizzle-orm";
5278
- import path8 from "path";
5301
+ import path9 from "path";
5279
5302
  var init_profile_linker = __esm({
5280
5303
  "src/lib/environment/profile-linker.ts"() {
5281
5304
  "use strict";
@@ -5326,23 +5349,23 @@ var init_data = __esm({
5326
5349
  });
5327
5350
 
5328
5351
  // src/lib/agents/profiles/app-manifest-source.ts
5329
- import fs9 from "fs";
5330
- import path9 from "path";
5352
+ import fs10 from "fs";
5353
+ import path10 from "path";
5331
5354
  import yaml5 from "js-yaml";
5332
5355
  function titleCase2(slug) {
5333
5356
  return slug.split("-").filter(Boolean).map((p) => p.charAt(0).toUpperCase() + p.slice(1)).join(" ");
5334
5357
  }
5335
5358
  function loadAppManifestProfiles(appsDir, profilesDir, builtinsDir) {
5336
- if (!fs9.existsSync(appsDir)) return [];
5359
+ if (!fs10.existsSync(appsDir)) return [];
5337
5360
  const synthesized = /* @__PURE__ */ new Map();
5338
- for (const entry of fs9.readdirSync(appsDir, { withFileTypes: true })) {
5361
+ for (const entry of fs10.readdirSync(appsDir, { withFileTypes: true })) {
5339
5362
  if (!entry.isDirectory()) continue;
5340
5363
  const appId = entry.name;
5341
- const manifestPath = path9.join(appsDir, appId, "manifest.yaml");
5342
- if (!fs9.existsSync(manifestPath)) continue;
5364
+ const manifestPath = path10.join(appsDir, appId, "manifest.yaml");
5365
+ if (!fs10.existsSync(manifestPath)) continue;
5343
5366
  let manifest;
5344
5367
  try {
5345
- const parsed = yaml5.load(fs9.readFileSync(manifestPath, "utf-8"));
5368
+ const parsed = yaml5.load(fs10.readFileSync(manifestPath, "utf-8"));
5346
5369
  manifest = AppManifestSchema.safeParse(parsed);
5347
5370
  } catch (err2) {
5348
5371
  console.warn(`[app-manifest-source] Malformed manifest for ${appId}:`, err2);
@@ -5354,9 +5377,8 @@ function loadAppManifestProfiles(appsDir, profilesDir, builtinsDir) {
5354
5377
  }
5355
5378
  for (const profileRef of manifest.data.profiles ?? []) {
5356
5379
  const profileId = profileRef.id;
5357
- const userYaml = path9.join(profilesDir, profileId, "profile.yaml");
5358
- const builtinYaml = path9.join(builtinsDir, profileId, "profile.yaml");
5359
- if (fs9.existsSync(userYaml) || fs9.existsSync(builtinYaml)) continue;
5380
+ if (hasAgentFile(path10.join(profilesDir, profileId)) || hasAgentFile(path10.join(builtinsDir, profileId)))
5381
+ continue;
5360
5382
  const existing = synthesized.get(profileId);
5361
5383
  if (existing) {
5362
5384
  if (!existing.tags.includes(appId)) {
@@ -5389,6 +5411,7 @@ var init_app_manifest_source = __esm({
5389
5411
  "use strict";
5390
5412
  init_catalog2();
5391
5413
  init_registry();
5414
+ init_agent_file();
5392
5415
  }
5393
5416
  });
5394
5417
 
@@ -5412,29 +5435,29 @@ __export(registry_exports2, {
5412
5435
  scanProfilesIntoMap: () => scanProfilesIntoMap,
5413
5436
  updateProfile: () => updateProfile
5414
5437
  });
5415
- import fs10 from "fs";
5438
+ import fs11 from "fs";
5416
5439
  import { homedir as homedir3 } from "os";
5417
- import path10 from "path";
5440
+ import path11 from "path";
5418
5441
  import yaml6 from "js-yaml";
5419
5442
  import { eq as eq8, and as and4 } from "drizzle-orm";
5420
5443
  function getBuiltinsDir() {
5421
5444
  return BUILTINS_DIR;
5422
5445
  }
5423
5446
  function getDirectorySignatureParts(baseDir) {
5424
- if (!fs10.existsSync(baseDir)) return [];
5425
- const entries = fs10.readdirSync(baseDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).sort((a, b) => a.name.localeCompare(b.name));
5447
+ if (!fs11.existsSync(baseDir)) return [];
5448
+ const entries = fs11.readdirSync(baseDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).sort((a, b) => a.name.localeCompare(b.name));
5426
5449
  const parts = [];
5427
5450
  for (const entry of entries) {
5428
- const dir = path10.join(baseDir, entry.name);
5429
- const yamlPath = path10.join(dir, "profile.yaml");
5430
- const skillPath = path10.join(dir, "SKILL.md");
5451
+ const dir = path11.join(baseDir, entry.name);
5452
+ const yamlPath = resolveAgentFile(dir);
5453
+ const skillPath = path11.join(dir, "SKILL.md");
5431
5454
  parts.push(entry.name);
5432
- if (fs10.existsSync(yamlPath)) {
5433
- const stats = fs10.statSync(yamlPath);
5455
+ if (yamlPath) {
5456
+ const stats = fs11.statSync(yamlPath);
5434
5457
  parts.push(`yaml:${stats.mtimeMs}:${stats.size}`);
5435
5458
  }
5436
- if (fs10.existsSync(skillPath)) {
5437
- const stats = fs10.statSync(skillPath);
5459
+ if (fs11.existsSync(skillPath)) {
5460
+ const stats = fs11.statSync(skillPath);
5438
5461
  parts.push(`skill:${stats.mtimeMs}:${stats.size}`);
5439
5462
  }
5440
5463
  }
@@ -5442,14 +5465,14 @@ function getDirectorySignatureParts(baseDir) {
5442
5465
  }
5443
5466
  function getAppsDirectorySignature() {
5444
5467
  const appsDir = getAinativeAppsDir();
5445
- if (!fs10.existsSync(appsDir)) return "no-apps";
5468
+ if (!fs11.existsSync(appsDir)) return "no-apps";
5446
5469
  const parts = [];
5447
- const entries = fs10.readdirSync(appsDir, { withFileTypes: true }).filter((e) => e.isDirectory()).sort((a, b) => a.name.localeCompare(b.name));
5470
+ const entries = fs11.readdirSync(appsDir, { withFileTypes: true }).filter((e) => e.isDirectory()).sort((a, b) => a.name.localeCompare(b.name));
5448
5471
  for (const entry of entries) {
5449
- const manifestPath = path10.join(appsDir, entry.name, "manifest.yaml");
5472
+ const manifestPath = path11.join(appsDir, entry.name, "manifest.yaml");
5450
5473
  parts.push(entry.name);
5451
- if (fs10.existsSync(manifestPath)) {
5452
- const stats = fs10.statSync(manifestPath);
5474
+ if (fs11.existsSync(manifestPath)) {
5475
+ const stats = fs11.statSync(manifestPath);
5453
5476
  parts.push(`manifest:${stats.mtimeMs}:${stats.size}`);
5454
5477
  }
5455
5478
  }
@@ -5472,17 +5495,19 @@ function getSkillsDirectorySignature() {
5472
5495
  }
5473
5496
  function ensureBuiltins() {
5474
5497
  const builtinsDir = getBuiltinsDir();
5475
- if (!fs10.existsSync(builtinsDir)) return;
5476
- fs10.mkdirSync(SKILLS_DIR, { recursive: true });
5477
- for (const entry of fs10.readdirSync(builtinsDir, { withFileTypes: true })) {
5498
+ if (!fs11.existsSync(builtinsDir)) return;
5499
+ fs11.mkdirSync(SKILLS_DIR, { recursive: true });
5500
+ for (const entry of fs11.readdirSync(builtinsDir, { withFileTypes: true })) {
5478
5501
  if (!entry.isDirectory()) continue;
5479
- const targetDir = path10.join(SKILLS_DIR, entry.name);
5480
- const targetYaml = path10.join(targetDir, "profile.yaml");
5481
- const srcYaml = path10.join(builtinsDir, entry.name, "profile.yaml");
5482
- if (fs10.existsSync(targetYaml)) {
5502
+ const targetDir = path11.join(SKILLS_DIR, entry.name);
5503
+ const existingTargetYaml = resolveAgentFile(targetDir);
5504
+ const srcYaml = resolveAgentFile(path11.join(builtinsDir, entry.name));
5505
+ if (!srcYaml) continue;
5506
+ if (existingTargetYaml) {
5507
+ const targetYamlForMerge = existingTargetYaml;
5483
5508
  try {
5484
- const source = yaml6.load(fs10.readFileSync(srcYaml, "utf-8")) ?? {};
5485
- const target = yaml6.load(fs10.readFileSync(targetYaml, "utf-8")) ?? {};
5509
+ const source = yaml6.load(fs11.readFileSync(srcYaml, "utf-8")) ?? {};
5510
+ const target = yaml6.load(fs11.readFileSync(targetYamlForMerge, "utf-8")) ?? {};
5486
5511
  let changed = false;
5487
5512
  if (source.supportedRuntimes !== void 0 && target.supportedRuntimes === void 0) {
5488
5513
  target.supportedRuntimes = source.supportedRuntimes;
@@ -5501,40 +5526,40 @@ function ensureBuiltins() {
5501
5526
  changed = true;
5502
5527
  }
5503
5528
  if (changed) {
5504
- fs10.writeFileSync(targetYaml, yaml6.dump(target));
5529
+ fs11.writeFileSync(targetYamlForMerge, yaml6.dump(target));
5505
5530
  }
5506
5531
  } catch {
5507
5532
  }
5508
5533
  continue;
5509
5534
  }
5510
- fs10.mkdirSync(targetDir, { recursive: true });
5511
- const srcDir = path10.join(builtinsDir, entry.name);
5512
- for (const file of fs10.readdirSync(srcDir)) {
5513
- fs10.copyFileSync(path10.join(srcDir, file), path10.join(targetDir, file));
5535
+ fs11.mkdirSync(targetDir, { recursive: true });
5536
+ const srcDir = path11.join(builtinsDir, entry.name);
5537
+ for (const file of fs11.readdirSync(srcDir)) {
5538
+ fs11.copyFileSync(path11.join(srcDir, file), path11.join(targetDir, file));
5514
5539
  }
5515
5540
  }
5516
5541
  }
5517
5542
  function scanProfilesFromDir(baseDir, profiles, options = {}) {
5518
- if (!fs10.existsSync(baseDir)) return;
5519
- for (const entry of fs10.readdirSync(baseDir, { withFileTypes: true })) {
5543
+ if (!fs11.existsSync(baseDir)) return;
5544
+ for (const entry of fs11.readdirSync(baseDir, { withFileTypes: true })) {
5520
5545
  if (!entry.isDirectory()) continue;
5521
- const dir = path10.join(baseDir, entry.name);
5522
- const yamlPath = path10.join(dir, "profile.yaml");
5523
- const skillPath = path10.join(dir, "SKILL.md");
5524
- if (!fs10.existsSync(yamlPath)) continue;
5546
+ const dir = path11.join(baseDir, entry.name);
5547
+ const yamlPath = resolveAgentFile(dir);
5548
+ const skillPath = path11.join(dir, "SKILL.md");
5549
+ if (!yamlPath) continue;
5525
5550
  try {
5526
- const rawYaml = fs10.readFileSync(yamlPath, "utf-8");
5551
+ const rawYaml = fs11.readFileSync(yamlPath, "utf-8");
5527
5552
  const parsed = yaml6.load(rawYaml);
5528
5553
  const result = ProfileConfigSchema.safeParse(parsed);
5529
5554
  if (!result.success) {
5530
5555
  console.warn(
5531
- `[profiles] Invalid profile.yaml in ${entry.name}:`,
5556
+ `[profiles] Invalid agent manifest in ${entry.name}:`,
5532
5557
  result.error.issues.map((i) => i.message).join(", ")
5533
5558
  );
5534
5559
  continue;
5535
5560
  }
5536
5561
  const config = result.data;
5537
- const skillMd = fs10.existsSync(skillPath) ? fs10.readFileSync(skillPath, "utf-8") : "";
5562
+ const skillMd = fs11.existsSync(skillPath) ? fs11.readFileSync(skillPath, "utf-8") : "";
5538
5563
  const descMatch = skillMd.match(
5539
5564
  /^---\s*\n[\s\S]*?description:\s*(.+?)\s*\n[\s\S]*?---/
5540
5565
  );
@@ -5624,20 +5649,20 @@ function reloadProfiles() {
5624
5649
  profileCacheSignature = null;
5625
5650
  }
5626
5651
  function isBuiltin(id) {
5627
- return fs10.existsSync(path10.join(getBuiltinsDir(), id, "profile.yaml"));
5652
+ return hasAgentFile(path11.join(getBuiltinsDir(), id));
5628
5653
  }
5629
5654
  function createProfile(config, skillMd) {
5630
5655
  const result = ProfileConfigSchema.safeParse(config);
5631
5656
  if (!result.success) {
5632
5657
  throw new Error(`Invalid profile: ${result.error.issues.map((i) => i.message).join(", ")}`);
5633
5658
  }
5634
- const dir = path10.join(SKILLS_DIR, config.id);
5635
- if (fs10.existsSync(path10.join(dir, "profile.yaml"))) {
5659
+ const dir = path11.join(SKILLS_DIR, config.id);
5660
+ if (hasAgentFile(dir)) {
5636
5661
  throw new Error(`Profile "${config.id}" already exists`);
5637
5662
  }
5638
- fs10.mkdirSync(dir, { recursive: true });
5639
- fs10.writeFileSync(path10.join(dir, "profile.yaml"), yaml6.dump(config));
5640
- fs10.writeFileSync(path10.join(dir, "SKILL.md"), skillMd);
5663
+ fs11.mkdirSync(dir, { recursive: true });
5664
+ fs11.writeFileSync(path11.join(dir, AGENT_FILENAME), yaml6.dump(config));
5665
+ fs11.writeFileSync(path11.join(dir, "SKILL.md"), skillMd);
5641
5666
  reloadProfiles();
5642
5667
  invalidateLatestScan();
5643
5668
  }
@@ -5646,13 +5671,13 @@ function createPromotedProfile(config, skillMd) {
5646
5671
  if (!result.success) {
5647
5672
  throw new Error(`Invalid profile: ${result.error.issues.map((i) => i.message).join(", ")}`);
5648
5673
  }
5649
- const dir = path10.join(PROMOTED_PROFILES_DIR, config.id);
5650
- if (fs10.existsSync(path10.join(dir, "profile.yaml"))) {
5674
+ const dir = path11.join(PROMOTED_PROFILES_DIR, config.id);
5675
+ if (hasAgentFile(dir)) {
5651
5676
  throw new Error(`Profile "${config.id}" already exists`);
5652
5677
  }
5653
- fs10.mkdirSync(dir, { recursive: true });
5654
- fs10.writeFileSync(path10.join(dir, "profile.yaml"), yaml6.dump(config));
5655
- fs10.writeFileSync(path10.join(dir, "SKILL.md"), skillMd);
5678
+ fs11.mkdirSync(dir, { recursive: true });
5679
+ fs11.writeFileSync(path11.join(dir, AGENT_FILENAME), yaml6.dump(config));
5680
+ fs11.writeFileSync(path11.join(dir, "SKILL.md"), skillMd);
5656
5681
  reloadProfiles();
5657
5682
  invalidateLatestScan();
5658
5683
  }
@@ -5664,14 +5689,16 @@ function updateProfile(id, config, skillMd) {
5664
5689
  if (!result.success) {
5665
5690
  throw new Error(`Invalid profile: ${result.error.issues.map((i) => i.message).join(", ")}`);
5666
5691
  }
5667
- const skillsDir = path10.join(SKILLS_DIR, id);
5668
- const promotedDir = path10.join(PROMOTED_PROFILES_DIR, id);
5669
- const dir = fs10.existsSync(skillsDir) ? skillsDir : fs10.existsSync(promotedDir) ? promotedDir : null;
5692
+ const skillsDir = path11.join(SKILLS_DIR, id);
5693
+ const promotedDir = path11.join(PROMOTED_PROFILES_DIR, id);
5694
+ const dir = fs11.existsSync(skillsDir) ? skillsDir : fs11.existsSync(promotedDir) ? promotedDir : null;
5670
5695
  if (!dir) {
5671
5696
  throw new Error(`Profile "${id}" not found`);
5672
5697
  }
5673
- fs10.writeFileSync(path10.join(dir, "profile.yaml"), yaml6.dump(config));
5674
- fs10.writeFileSync(path10.join(dir, "SKILL.md"), skillMd);
5698
+ fs11.writeFileSync(path11.join(dir, AGENT_FILENAME), yaml6.dump(config));
5699
+ const legacyPath = path11.join(dir, LEGACY_PROFILE_FILENAME);
5700
+ if (fs11.existsSync(legacyPath)) fs11.rmSync(legacyPath);
5701
+ fs11.writeFileSync(path11.join(dir, "SKILL.md"), skillMd);
5675
5702
  reloadProfiles();
5676
5703
  invalidateLatestScan();
5677
5704
  }
@@ -5679,13 +5706,13 @@ function deleteProfile(id) {
5679
5706
  if (isBuiltin(id)) {
5680
5707
  throw new Error("Cannot delete built-in profiles");
5681
5708
  }
5682
- const skillsDir = path10.join(SKILLS_DIR, id);
5683
- const promotedDir = path10.join(PROMOTED_PROFILES_DIR, id);
5684
- const dir = fs10.existsSync(skillsDir) ? skillsDir : fs10.existsSync(promotedDir) ? promotedDir : null;
5709
+ const skillsDir = path11.join(SKILLS_DIR, id);
5710
+ const promotedDir = path11.join(PROMOTED_PROFILES_DIR, id);
5711
+ const dir = fs11.existsSync(skillsDir) ? skillsDir : fs11.existsSync(promotedDir) ? promotedDir : null;
5685
5712
  if (!dir) {
5686
5713
  throw new Error(`Profile "${id}" not found`);
5687
5714
  }
5688
- fs10.rmSync(dir, { recursive: true, force: true });
5715
+ fs11.rmSync(dir, { recursive: true, force: true });
5689
5716
  reloadProfiles();
5690
5717
  invalidateLatestScan();
5691
5718
  }
@@ -5768,8 +5795,9 @@ var init_registry2 = __esm({
5768
5795
  init_schema();
5769
5796
  init_ainative_paths();
5770
5797
  init_app_manifest_source();
5798
+ init_agent_file();
5771
5799
  init_app_root();
5772
- BUILTINS_DIR = path10.resolve(
5800
+ BUILTINS_DIR = path11.resolve(
5773
5801
  getAppRoot(import.meta.dirname, 4),
5774
5802
  "src",
5775
5803
  "lib",
@@ -5777,7 +5805,7 @@ var init_registry2 = __esm({
5777
5805
  "profiles",
5778
5806
  "builtins"
5779
5807
  );
5780
- SKILLS_DIR = path10.join(
5808
+ SKILLS_DIR = path11.join(
5781
5809
  process.env.HOME ?? process.env.USERPROFILE ?? homedir3(),
5782
5810
  ".claude",
5783
5811
  "skills"
@@ -5805,23 +5833,23 @@ __export(registry_exports3, {
5805
5833
  reloadBlueprints: () => reloadBlueprints,
5806
5834
  validateBlueprintRefs: () => validateBlueprintRefs
5807
5835
  });
5808
- import fs11 from "fs";
5809
- import path11 from "path";
5836
+ import fs12 from "fs";
5837
+ import path12 from "path";
5810
5838
  import yaml7 from "js-yaml";
5811
5839
  function userDirMtimeMs() {
5812
5840
  try {
5813
- return fs11.statSync(USER_BLUEPRINTS_DIR).mtimeMs;
5841
+ return fs12.statSync(USER_BLUEPRINTS_DIR).mtimeMs;
5814
5842
  } catch {
5815
5843
  return null;
5816
5844
  }
5817
5845
  }
5818
5846
  function scanDirectory(dir, isBuiltin2) {
5819
5847
  const blueprints = /* @__PURE__ */ new Map();
5820
- if (!fs11.existsSync(dir)) return blueprints;
5821
- for (const file of fs11.readdirSync(dir)) {
5848
+ if (!fs12.existsSync(dir)) return blueprints;
5849
+ for (const file of fs12.readdirSync(dir)) {
5822
5850
  if (!file.endsWith(".yaml") && !file.endsWith(".yml")) continue;
5823
5851
  try {
5824
- const content = fs11.readFileSync(path11.join(dir, file), "utf-8");
5852
+ const content = fs12.readFileSync(path12.join(dir, file), "utf-8");
5825
5853
  const parsed = yaml7.load(content);
5826
5854
  const result = BlueprintSchema.safeParse(parsed);
5827
5855
  if (!result.success) {
@@ -5880,12 +5908,12 @@ function createBlueprint(yamlContent) {
5880
5908
  `Invalid blueprint: ${result.error.issues.map((i) => i.message).join(", ")}`
5881
5909
  );
5882
5910
  }
5883
- fs11.mkdirSync(USER_BLUEPRINTS_DIR, { recursive: true });
5884
- const filePath = path11.join(USER_BLUEPRINTS_DIR, `${result.data.id}.yaml`);
5885
- if (fs11.existsSync(filePath)) {
5911
+ fs12.mkdirSync(USER_BLUEPRINTS_DIR, { recursive: true });
5912
+ const filePath = path12.join(USER_BLUEPRINTS_DIR, `${result.data.id}.yaml`);
5913
+ if (fs12.existsSync(filePath)) {
5886
5914
  throw new Error(`Blueprint "${result.data.id}" already exists`);
5887
5915
  }
5888
- fs11.writeFileSync(filePath, yamlContent);
5916
+ fs12.writeFileSync(filePath, yamlContent);
5889
5917
  reloadBlueprints();
5890
5918
  return { ...result.data, isBuiltin: false };
5891
5919
  }
@@ -5893,11 +5921,11 @@ function deleteBlueprint(id) {
5893
5921
  if (isBuiltinBlueprint(id)) {
5894
5922
  throw new Error("Cannot delete built-in blueprints");
5895
5923
  }
5896
- const filePath = path11.join(USER_BLUEPRINTS_DIR, `${id}.yaml`);
5897
- if (!fs11.existsSync(filePath)) {
5924
+ const filePath = path12.join(USER_BLUEPRINTS_DIR, `${id}.yaml`);
5925
+ if (!fs12.existsSync(filePath)) {
5898
5926
  throw new Error(`Blueprint "${id}" not found`);
5899
5927
  }
5900
- fs11.unlinkSync(filePath);
5928
+ fs12.unlinkSync(filePath);
5901
5929
  reloadBlueprints();
5902
5930
  }
5903
5931
  function getUserBlueprintsDir() {
@@ -5961,7 +5989,7 @@ var init_registry3 = __esm({
5961
5989
  init_ainative_paths();
5962
5990
  init_app_root();
5963
5991
  init_registry2();
5964
- BUILTINS_DIR2 = path11.resolve(
5992
+ BUILTINS_DIR2 = path12.resolve(
5965
5993
  getAppRoot(import.meta.dirname, 4),
5966
5994
  "src",
5967
5995
  "lib",
@@ -6824,18 +6852,18 @@ var init_processor = __esm({
6824
6852
  });
6825
6853
 
6826
6854
  // src/lib/documents/output-scanner.ts
6827
- import path12 from "path";
6828
- import fs12 from "fs/promises";
6855
+ import path13 from "path";
6856
+ import fs13 from "fs/promises";
6829
6857
  import { and as and6, eq as eq14 } from "drizzle-orm";
6830
6858
  function getTaskOutputDirectory(taskId) {
6831
- return path12.join(TASK_OUTPUTS_DIR, taskId);
6859
+ return path13.join(TASK_OUTPUTS_DIR, taskId);
6832
6860
  }
6833
6861
  async function prepareTaskOutputDirectory(taskId, options = {}) {
6834
6862
  const outputDir = getTaskOutputDirectory(taskId);
6835
6863
  if (options.clearExisting) {
6836
- await fs12.rm(outputDir, { recursive: true, force: true });
6864
+ await fs13.rm(outputDir, { recursive: true, force: true });
6837
6865
  }
6838
- await fs12.mkdir(outputDir, { recursive: true });
6866
+ await fs13.mkdir(outputDir, { recursive: true });
6839
6867
  return outputDir;
6840
6868
  }
6841
6869
  function buildTaskOutputInstructions(taskId) {
@@ -6848,10 +6876,10 @@ function buildTaskOutputInstructions(taskId) {
6848
6876
  ].join("\n");
6849
6877
  }
6850
6878
  async function listFilesRecursively(rootDir) {
6851
- const entries = await fs12.readdir(rootDir, { withFileTypes: true });
6879
+ const entries = await fs13.readdir(rootDir, { withFileTypes: true });
6852
6880
  const files = await Promise.all(
6853
6881
  entries.map(async (entry) => {
6854
- const resolved = path12.join(rootDir, entry.name);
6882
+ const resolved = path13.join(rootDir, entry.name);
6855
6883
  if (entry.isDirectory()) {
6856
6884
  return listFilesRecursively(resolved);
6857
6885
  }
@@ -6861,13 +6889,13 @@ async function listFilesRecursively(rootDir) {
6861
6889
  return files.flat();
6862
6890
  }
6863
6891
  function resolveOutputMimeType(filename) {
6864
- return OUTPUT_MIME_TYPES[path12.extname(filename).toLowerCase()] ?? null;
6892
+ return OUTPUT_MIME_TYPES[path13.extname(filename).toLowerCase()] ?? null;
6865
6893
  }
6866
6894
  function normalizeRelativePath(value) {
6867
- return value.split(path12.sep).join("/");
6895
+ return value.split(path13.sep).join("/");
6868
6896
  }
6869
6897
  function buildArchivedFilename(relativePath, version) {
6870
- const parsed = path12.parse(relativePath);
6898
+ const parsed = path13.parse(relativePath);
6871
6899
  const sanitizedBase = parsed.name.replace(/[^a-zA-Z0-9._-]+/g, "-");
6872
6900
  const nestedPrefix = parsed.dir ? `${parsed.dir.replace(/[\\/]+/g, "__")}__` : "";
6873
6901
  return `${nestedPrefix}${sanitizedBase || "output"}-v${version}${parsed.ext}`;
@@ -6879,7 +6907,7 @@ async function scanTaskOutputDocuments(taskId) {
6879
6907
  throw new Error(`Task ${taskId} not found`);
6880
6908
  }
6881
6909
  try {
6882
- await fs12.access(outputDir);
6910
+ await fs13.access(outputDir);
6883
6911
  } catch {
6884
6912
  return [];
6885
6913
  }
@@ -6899,22 +6927,22 @@ async function scanTaskOutputDocuments(taskId) {
6899
6927
  const discoveredFiles = await listFilesRecursively(outputDir);
6900
6928
  const registeredDocumentIds = [];
6901
6929
  for (const sourcePath of discoveredFiles) {
6902
- const relativePath = normalizeRelativePath(path12.relative(outputDir, sourcePath));
6930
+ const relativePath = normalizeRelativePath(path13.relative(outputDir, sourcePath));
6903
6931
  const mimeType = resolveOutputMimeType(relativePath);
6904
6932
  if (!mimeType) {
6905
6933
  continue;
6906
6934
  }
6907
- const stats = await fs12.stat(sourcePath);
6935
+ const stats = await fs13.stat(sourcePath);
6908
6936
  if (!stats.isFile()) {
6909
6937
  continue;
6910
6938
  }
6911
6939
  const nextVersion = (versionMap.get(relativePath) ?? 0) + 1;
6912
6940
  versionMap.set(relativePath, nextVersion);
6913
- const archiveDir = path12.join(OUTPUT_ARCHIVE_DIR, taskId);
6914
- await fs12.mkdir(archiveDir, { recursive: true });
6941
+ const archiveDir = path13.join(OUTPUT_ARCHIVE_DIR, taskId);
6942
+ await fs13.mkdir(archiveDir, { recursive: true });
6915
6943
  const archivedFilename = buildArchivedFilename(relativePath, nextVersion);
6916
- const archivedPath = path12.join(archiveDir, archivedFilename);
6917
- await fs12.copyFile(sourcePath, archivedPath);
6944
+ const archivedPath = path13.join(archiveDir, archivedFilename);
6945
+ await fs13.copyFile(sourcePath, archivedPath);
6918
6946
  const documentId = crypto.randomUUID();
6919
6947
  const now = /* @__PURE__ */ new Date();
6920
6948
  await db.insert(documents).values({
@@ -6945,8 +6973,8 @@ var init_output_scanner = __esm({
6945
6973
  init_schema();
6946
6974
  init_env();
6947
6975
  init_processor();
6948
- TASK_OUTPUTS_DIR = path12.join(dataDir(), "outputs");
6949
- OUTPUT_ARCHIVE_DIR = path12.join(dataDir(), "documents", "output");
6976
+ TASK_OUTPUTS_DIR = path13.join(dataDir(), "outputs");
6977
+ OUTPUT_ARCHIVE_DIR = path13.join(dataDir(), "documents", "output");
6950
6978
  OUTPUT_MIME_TYPES = {
6951
6979
  ".md": "text/markdown",
6952
6980
  ".txt": "text/plain",
@@ -8114,7 +8142,7 @@ var init_ledger = __esm({
8114
8142
  });
8115
8143
 
8116
8144
  // src/lib/plugins/classify-trust.ts
8117
- import path13 from "path";
8145
+ import path14 from "path";
8118
8146
  import os from "os";
8119
8147
  function classifyPluginTrust(manifest, rootDir, opts2 = {}) {
8120
8148
  if (manifest.kind === "primitives-bundle") return "self";
@@ -8128,9 +8156,9 @@ function classifyPluginTrust(manifest, rootDir, opts2 = {}) {
8128
8156
  if (manifest.author === currentUser) return "self";
8129
8157
  }
8130
8158
  const appsBase = opts2.appsBaseDir ?? getAinativeAppsDir();
8131
- const normalizedRoot = path13.resolve(rootDir);
8132
- const normalizedApps = path13.resolve(appsBase);
8133
- const sep = path13.sep;
8159
+ const normalizedRoot = path14.resolve(rootDir);
8160
+ const normalizedApps = path14.resolve(appsBase);
8161
+ const sep = path14.sep;
8134
8162
  if (normalizedRoot === normalizedApps || normalizedRoot.startsWith(normalizedApps + sep)) {
8135
8163
  return "self";
8136
8164
  }
@@ -8151,15 +8179,15 @@ __export(transport_dispatch_exports, {
8151
8179
  validateStdioMcp: () => validateStdioMcp
8152
8180
  });
8153
8181
  import { spawn } from "child_process";
8154
- import fs13 from "fs";
8155
- import path14 from "path";
8182
+ import fs14 from "fs";
8183
+ import path15 from "path";
8156
8184
  import readline from "readline";
8157
8185
  function logToFile2(line) {
8158
8186
  try {
8159
8187
  const logsDir = getAinativeLogsDir();
8160
- fs13.mkdirSync(logsDir, { recursive: true });
8161
- fs13.appendFileSync(
8162
- path14.join(logsDir, "plugins.log"),
8188
+ fs14.mkdirSync(logsDir, { recursive: true });
8189
+ fs14.appendFileSync(
8190
+ path15.join(logsDir, "plugins.log"),
8163
8191
  `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
8164
8192
  `
8165
8193
  );
@@ -8294,14 +8322,14 @@ async function validateInProcessSdk(config, pluginId, serverName) {
8294
8322
  };
8295
8323
  }
8296
8324
  const absPath = config.entry;
8297
- if (!path14.isAbsolute(absPath)) {
8325
+ if (!path15.isAbsolute(absPath)) {
8298
8326
  return {
8299
8327
  ok: false,
8300
8328
  reason: "sdk_invalid_export",
8301
8329
  detail: `entry must be absolute path, got: ${absPath}`
8302
8330
  };
8303
8331
  }
8304
- const ext = path14.extname(absPath);
8332
+ const ext = path15.extname(absPath);
8305
8333
  if (ext === ".ts") {
8306
8334
  return {
8307
8335
  ok: false,
@@ -8420,8 +8448,8 @@ __export(mcp_loader_exports, {
8420
8448
  loadPluginMcpServers: () => loadPluginMcpServers,
8421
8449
  reloadPluginMcpRegistrations: () => reloadPluginMcpRegistrations
8422
8450
  });
8423
- import fs14 from "fs";
8424
- import path15 from "path";
8451
+ import fs15 from "fs";
8452
+ import path16 from "path";
8425
8453
  import os2 from "os";
8426
8454
  import yaml8 from "js-yaml";
8427
8455
  function __resetDockerBootSweepForTests() {
@@ -8430,9 +8458,9 @@ function __resetDockerBootSweepForTests() {
8430
8458
  function logToFile3(line) {
8431
8459
  try {
8432
8460
  const logsDir = getAinativeLogsDir();
8433
- fs14.mkdirSync(logsDir, { recursive: true });
8434
- fs14.appendFileSync(
8435
- path15.join(logsDir, "plugins.log"),
8461
+ fs15.mkdirSync(logsDir, { recursive: true });
8462
+ fs15.appendFileSync(
8463
+ path16.join(logsDir, "plugins.log"),
8436
8464
  `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
8437
8465
  `
8438
8466
  );
@@ -8457,10 +8485,10 @@ function isRelativeCommand(command) {
8457
8485
  }
8458
8486
  async function scanPlugin(pluginDir, pluginId) {
8459
8487
  const registrations = [];
8460
- const pluginYamlPath = path15.join(pluginDir, "plugin.yaml");
8488
+ const pluginYamlPath = path16.join(pluginDir, "plugin.yaml");
8461
8489
  let pluginYamlContent;
8462
8490
  try {
8463
- pluginYamlContent = fs14.readFileSync(pluginYamlPath, "utf-8");
8491
+ pluginYamlContent = fs15.readFileSync(pluginYamlPath, "utf-8");
8464
8492
  } catch {
8465
8493
  return { registrations };
8466
8494
  }
@@ -8482,7 +8510,7 @@ async function scanPlugin(pluginDir, pluginId) {
8482
8510
  if (manifest.kind !== "chat-tools") {
8483
8511
  return { registrations };
8484
8512
  }
8485
- const mcpJsonPath = path15.join(pluginDir, ".mcp.json");
8513
+ const mcpJsonPath = path16.join(pluginDir, ".mcp.json");
8486
8514
  const mcpServers = parseMcpConfigFile(mcpJsonPath);
8487
8515
  if (mcpServers === null) {
8488
8516
  logToFile3(
@@ -8586,8 +8614,8 @@ async function scanPlugin(pluginDir, pluginId) {
8586
8614
  const resolvedEnv = resolveEnvTemplates(rawEntry.env, context);
8587
8615
  let resolvedCommand;
8588
8616
  if (isRelativeCommand(rawCommand)) {
8589
- const absCommand = path15.resolve(pluginDir, rawCommand);
8590
- if (!fs14.existsSync(absCommand)) {
8617
+ const absCommand = path16.resolve(pluginDir, rawCommand);
8618
+ if (!fs15.existsSync(absCommand)) {
8591
8619
  logToFile3(
8592
8620
  `[mcp-loader] plugin ${pluginId} server "${serverName}": command "${rawCommand}" not found at ${absCommand} (server_not_found)`
8593
8621
  );
@@ -8681,8 +8709,8 @@ async function scanPlugin(pluginDir, pluginId) {
8681
8709
  });
8682
8710
  continue;
8683
8711
  }
8684
- const absEntry = path15.resolve(pluginDir, entryField);
8685
- if (!fs14.existsSync(absEntry)) {
8712
+ const absEntry = path16.resolve(pluginDir, entryField);
8713
+ if (!fs15.existsSync(absEntry)) {
8686
8714
  logToFile3(
8687
8715
  `[mcp-loader] plugin ${pluginId} server "${serverName}": entry "${entryField}" not found at ${absEntry} (sdk_entry_not_found)`
8688
8716
  );
@@ -8751,9 +8779,9 @@ async function listPluginMcpRegistrations(opts2) {
8751
8779
  const features = getRuntimeFeatures(opts2.runtime);
8752
8780
  if (!features.supportsPluginMcpServers) {
8753
8781
  const pluginsDir2 = getAinativePluginsDir();
8754
- if (fs14.existsSync(pluginsDir2)) {
8782
+ if (fs15.existsSync(pluginsDir2)) {
8755
8783
  try {
8756
- for (const entry of fs14.readdirSync(pluginsDir2).sort()) {
8784
+ for (const entry of fs15.readdirSync(pluginsDir2).sort()) {
8757
8785
  const logKey = `${entry}@${opts2.runtime}@${pluginsDir2}`;
8758
8786
  if (!ollamaSkipLogged.has(logKey)) {
8759
8787
  ollamaSkipLogged.add(logKey);
@@ -8776,22 +8804,22 @@ async function listPluginMcpRegistrations(opts2) {
8776
8804
  }
8777
8805
  }
8778
8806
  const pluginsDir = getAinativePluginsDir();
8779
- if (!fs14.existsSync(pluginsDir)) {
8807
+ if (!fs15.existsSync(pluginsDir)) {
8780
8808
  return [];
8781
8809
  }
8782
8810
  let pluginDirEntries;
8783
8811
  try {
8784
- pluginDirEntries = fs14.readdirSync(pluginsDir).sort();
8812
+ pluginDirEntries = fs15.readdirSync(pluginsDir).sort();
8785
8813
  } catch {
8786
8814
  logToFile3(`[mcp-loader] could not read plugins directory: ${pluginsDir}`);
8787
8815
  return [];
8788
8816
  }
8789
8817
  const allRegistrations = [];
8790
8818
  for (const entry of pluginDirEntries) {
8791
- const pluginDir = path15.join(pluginsDir, entry);
8819
+ const pluginDir = path16.join(pluginsDir, entry);
8792
8820
  let stat2;
8793
8821
  try {
8794
- stat2 = fs14.statSync(pluginDir);
8822
+ stat2 = fs15.statSync(pluginDir);
8795
8823
  } catch {
8796
8824
  continue;
8797
8825
  }
@@ -8816,18 +8844,18 @@ async function loadPluginMcpServers(opts2) {
8816
8844
  }
8817
8845
  function hasAnyDockerConfinedPlugin() {
8818
8846
  const pluginsDir = getAinativePluginsDir();
8819
- if (!fs14.existsSync(pluginsDir)) return false;
8847
+ if (!fs15.existsSync(pluginsDir)) return false;
8820
8848
  let entries;
8821
8849
  try {
8822
- entries = fs14.readdirSync(pluginsDir);
8850
+ entries = fs15.readdirSync(pluginsDir);
8823
8851
  } catch {
8824
8852
  return false;
8825
8853
  }
8826
8854
  for (const entry of entries) {
8827
- const pluginYamlPath = path15.join(pluginsDir, entry, "plugin.yaml");
8855
+ const pluginYamlPath = path16.join(pluginsDir, entry, "plugin.yaml");
8828
8856
  let content;
8829
8857
  try {
8830
- content = fs14.readFileSync(pluginYamlPath, "utf-8");
8858
+ content = fs15.readFileSync(pluginYamlPath, "utf-8");
8831
8859
  } catch {
8832
8860
  continue;
8833
8861
  }
@@ -8847,26 +8875,26 @@ function hasAnyDockerConfinedPlugin() {
8847
8875
  function buildSafeModeRegistrations() {
8848
8876
  const out = [];
8849
8877
  const pluginsDir = getAinativePluginsDir();
8850
- if (!fs14.existsSync(pluginsDir)) return out;
8878
+ if (!fs15.existsSync(pluginsDir)) return out;
8851
8879
  let entries;
8852
8880
  try {
8853
- entries = fs14.readdirSync(pluginsDir).sort();
8881
+ entries = fs15.readdirSync(pluginsDir).sort();
8854
8882
  } catch {
8855
8883
  return out;
8856
8884
  }
8857
8885
  for (const entry of entries) {
8858
- const pluginDir = path15.join(pluginsDir, entry);
8886
+ const pluginDir = path16.join(pluginsDir, entry);
8859
8887
  let stat2;
8860
8888
  try {
8861
- stat2 = fs14.statSync(pluginDir);
8889
+ stat2 = fs15.statSync(pluginDir);
8862
8890
  } catch {
8863
8891
  continue;
8864
8892
  }
8865
8893
  if (!stat2.isDirectory()) continue;
8866
- const pluginYamlPath = path15.join(pluginDir, "plugin.yaml");
8894
+ const pluginYamlPath = path16.join(pluginDir, "plugin.yaml");
8867
8895
  let content;
8868
8896
  try {
8869
- content = fs14.readFileSync(pluginYamlPath, "utf-8");
8897
+ content = fs15.readFileSync(pluginYamlPath, "utf-8");
8870
8898
  } catch {
8871
8899
  continue;
8872
8900
  }
@@ -8959,17 +8987,17 @@ __export(capability_check_exports, {
8959
8987
  writePluginsLock: () => writePluginsLock
8960
8988
  });
8961
8989
  import crypto3 from "crypto";
8962
- import fs15 from "fs";
8990
+ import fs16 from "fs";
8963
8991
  import os3 from "os";
8964
- import path16 from "path";
8992
+ import path17 from "path";
8965
8993
  import yaml9 from "js-yaml";
8966
8994
  import { z as z6 } from "zod";
8967
8995
  function logToFile4(line) {
8968
8996
  try {
8969
8997
  const logsDir = getAinativeLogsDir();
8970
- fs15.mkdirSync(logsDir, { recursive: true });
8971
- fs15.appendFileSync(
8972
- path16.join(logsDir, "plugins.log"),
8998
+ fs16.mkdirSync(logsDir, { recursive: true });
8999
+ fs16.appendFileSync(
9000
+ path17.join(logsDir, "plugins.log"),
8973
9001
  `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
8974
9002
  `
8975
9003
  );
@@ -9009,12 +9037,12 @@ function deriveManifestHash(pluginYamlContent) {
9009
9037
  }
9010
9038
  function readPluginsLock() {
9011
9039
  const lockPath = getAinativePluginsLockPath();
9012
- if (!fs15.existsSync(lockPath)) {
9040
+ if (!fs16.existsSync(lockPath)) {
9013
9041
  return { version: 1, accepted: {} };
9014
9042
  }
9015
9043
  let raw;
9016
9044
  try {
9017
- raw = yaml9.load(fs15.readFileSync(lockPath, "utf-8"));
9045
+ raw = yaml9.load(fs16.readFileSync(lockPath, "utf-8"));
9018
9046
  } catch (err2) {
9019
9047
  logToFile4(
9020
9048
  `[capability-check] WARN: plugins.lock is not valid YAML \u2014 treating as empty. Error: ${err2 instanceof Error ? err2.message : String(err2)}`
@@ -9033,31 +9061,31 @@ function readPluginsLock() {
9033
9061
  function writePluginsLock(pluginId, entry) {
9034
9062
  const lockPath = getAinativePluginsLockPath();
9035
9063
  const bakPath = lockPath + ".bak";
9036
- const lockDir = path16.dirname(lockPath);
9037
- fs15.mkdirSync(lockDir, { recursive: true });
9064
+ const lockDir = path17.dirname(lockPath);
9065
+ fs16.mkdirSync(lockDir, { recursive: true });
9038
9066
  const current = readPluginsLock();
9039
9067
  current.accepted[pluginId] = entry;
9040
9068
  const newContent = yaml9.dump(current, { lineWidth: -1 });
9041
- if (fs15.existsSync(lockPath)) {
9042
- fs15.copyFileSync(lockPath, bakPath);
9069
+ if (fs16.existsSync(lockPath)) {
9070
+ fs16.copyFileSync(lockPath, bakPath);
9043
9071
  try {
9044
- fs15.chmodSync(bakPath, 384);
9072
+ fs16.chmodSync(bakPath, 384);
9045
9073
  } catch {
9046
9074
  }
9047
9075
  }
9048
9076
  const tmpPath = `${lockPath}.tmp-${crypto3.randomBytes(6).toString("hex")}`;
9049
9077
  try {
9050
- fs15.writeFileSync(tmpPath, newContent, { mode: 384 });
9051
- fs15.renameSync(tmpPath, lockPath);
9078
+ fs16.writeFileSync(tmpPath, newContent, { mode: 384 });
9079
+ fs16.renameSync(tmpPath, lockPath);
9052
9080
  } catch (err2) {
9053
9081
  try {
9054
- fs15.unlinkSync(tmpPath);
9082
+ fs16.unlinkSync(tmpPath);
9055
9083
  } catch {
9056
9084
  }
9057
9085
  throw err2;
9058
9086
  }
9059
9087
  try {
9060
- fs15.chmodSync(lockPath, 384);
9088
+ fs16.chmodSync(lockPath, 384);
9061
9089
  } catch {
9062
9090
  }
9063
9091
  }
@@ -9068,28 +9096,28 @@ function removePluginsLockEntry(pluginId) {
9068
9096
  if (!(pluginId in current.accepted)) return;
9069
9097
  delete current.accepted[pluginId];
9070
9098
  const newContent = yaml9.dump(current, { lineWidth: -1 });
9071
- const lockDir = path16.dirname(lockPath);
9072
- fs15.mkdirSync(lockDir, { recursive: true });
9073
- if (fs15.existsSync(lockPath)) {
9074
- fs15.copyFileSync(lockPath, bakPath);
9099
+ const lockDir = path17.dirname(lockPath);
9100
+ fs16.mkdirSync(lockDir, { recursive: true });
9101
+ if (fs16.existsSync(lockPath)) {
9102
+ fs16.copyFileSync(lockPath, bakPath);
9075
9103
  try {
9076
- fs15.chmodSync(bakPath, 384);
9104
+ fs16.chmodSync(bakPath, 384);
9077
9105
  } catch {
9078
9106
  }
9079
9107
  }
9080
9108
  const tmpPath = `${lockPath}.tmp-${crypto3.randomBytes(6).toString("hex")}`;
9081
9109
  try {
9082
- fs15.writeFileSync(tmpPath, newContent, { mode: 384 });
9083
- fs15.renameSync(tmpPath, lockPath);
9110
+ fs16.writeFileSync(tmpPath, newContent, { mode: 384 });
9111
+ fs16.renameSync(tmpPath, lockPath);
9084
9112
  } catch (err2) {
9085
9113
  try {
9086
- fs15.unlinkSync(tmpPath);
9114
+ fs16.unlinkSync(tmpPath);
9087
9115
  } catch {
9088
9116
  }
9089
9117
  throw err2;
9090
9118
  }
9091
9119
  try {
9092
- fs15.chmodSync(lockPath, 384);
9120
+ fs16.chmodSync(lockPath, 384);
9093
9121
  } catch {
9094
9122
  }
9095
9123
  }
@@ -9175,9 +9203,9 @@ function getPluginToolApprovalMode(pluginId, toolName, defaultFromManifest) {
9175
9203
  }
9176
9204
  function readManifestDefaultApproval(pluginId) {
9177
9205
  try {
9178
- const pluginYamlPath = path16.join(getAinativePluginsDir(), pluginId, "plugin.yaml");
9179
- if (!fs15.existsSync(pluginYamlPath)) return void 0;
9180
- const content = fs15.readFileSync(pluginYamlPath, "utf-8");
9206
+ const pluginYamlPath = path17.join(getAinativePluginsDir(), pluginId, "plugin.yaml");
9207
+ if (!fs16.existsSync(pluginYamlPath)) return void 0;
9208
+ const content = fs16.readFileSync(pluginYamlPath, "utf-8");
9181
9209
  const raw = yaml9.load(content);
9182
9210
  if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return void 0;
9183
9211
  const record = raw;
@@ -9269,13 +9297,13 @@ async function revokePluginCapabilities(pluginId) {
9269
9297
  }
9270
9298
  async function grantPluginCapabilities(pluginId, opts2) {
9271
9299
  const { getAinativePluginsDir: getDir } = await Promise.resolve().then(() => (init_ainative_paths(), ainative_paths_exports));
9272
- const pluginYamlPath = path16.join(getDir(), pluginId, "plugin.yaml");
9273
- if (!fs15.existsSync(pluginYamlPath)) {
9300
+ const pluginYamlPath = path17.join(getDir(), pluginId, "plugin.yaml");
9301
+ if (!fs16.existsSync(pluginYamlPath)) {
9274
9302
  return { granted: false, reason: "not_found" };
9275
9303
  }
9276
9304
  let content;
9277
9305
  try {
9278
- content = fs15.readFileSync(pluginYamlPath, "utf-8");
9306
+ content = fs16.readFileSync(pluginYamlPath, "utf-8");
9279
9307
  } catch (err2) {
9280
9308
  return {
9281
9309
  granted: false,
@@ -12042,9 +12070,9 @@ function buildPermissionSummary(toolName, input) {
12042
12070
  }
12043
12071
  }
12044
12072
  if (toolName === "Read" || toolName === "Write" || toolName === "Edit" || toolName === "read" || toolName === "write" || toolName === "edit") {
12045
- const path24 = input.file_path ?? input.path;
12046
- if (typeof path24 === "string" && path24.trim().length > 0) {
12047
- return truncate(path24.trim());
12073
+ const path25 = input.file_path ?? input.path;
12074
+ if (typeof path25 === "string" && path25.trim().length > 0) {
12075
+ return truncate(path25.trim());
12048
12076
  }
12049
12077
  }
12050
12078
  if (toolName?.startsWith("mcp__")) {
@@ -12078,9 +12106,9 @@ function getPermissionDetailEntries(toolName, input) {
12078
12106
  }
12079
12107
  }
12080
12108
  if (toolName === "Read" || toolName === "Write" || toolName === "Edit" || toolName === "read" || toolName === "write" || toolName === "edit") {
12081
- const path24 = input.file_path ?? input.path;
12082
- if (typeof path24 === "string") {
12083
- return [{ label: "Path", value: path24 }];
12109
+ const path25 = input.file_path ?? input.path;
12110
+ if (typeof path25 === "string") {
12111
+ return [{ label: "Path", value: path25 }];
12084
12112
  }
12085
12113
  }
12086
12114
  return Object.entries(input).slice(0, 6).map(([key, value]) => ({
@@ -12168,7 +12196,7 @@ async function listPendingApprovalPayloads(limit = 20) {
12168
12196
  toolName: row.toolName,
12169
12197
  permissionLabel: isBatchProposal ? "Workflow Learning" : isContextProposal ? "Context Proposal" : getPermissionKindLabel(row.toolName),
12170
12198
  compactSummary: isBatchProposal ? `Batch of learned patterns from workflow execution` : isContextProposal ? `Learned patterns proposed for profile "${row.toolName}"` : buildPermissionSummary(row.toolName, parsedInput),
12171
- deepLink: isBatchProposal ? "/inbox" : isContextProposal ? `/profiles/${row.toolName}` : buildDeepLink(row.taskId, effectiveWorkflowId),
12199
+ deepLink: isBatchProposal ? "/inbox" : isContextProposal ? `/agents/${row.toolName}` : buildDeepLink(row.taskId, effectiveWorkflowId),
12172
12200
  supportedActionIds: isContextProposal || isBatchProposal ? ["allow_once", "deny"] : [...APPROVAL_ACTION_IDS],
12173
12201
  title: row.title,
12174
12202
  body: row.body,
@@ -12368,16 +12396,16 @@ __export(registry_exports4, {
12368
12396
  reloadSchedules: () => reloadSchedules,
12369
12397
  validateScheduleRefs: () => validateScheduleRefs
12370
12398
  });
12371
- import fs16 from "fs";
12372
- import path17 from "path";
12399
+ import fs17 from "fs";
12400
+ import path18 from "path";
12373
12401
  import yaml10 from "js-yaml";
12374
12402
  function scanDirectory2(dir) {
12375
12403
  const schedules2 = /* @__PURE__ */ new Map();
12376
- if (!fs16.existsSync(dir)) return schedules2;
12377
- for (const file of fs16.readdirSync(dir)) {
12404
+ if (!fs17.existsSync(dir)) return schedules2;
12405
+ for (const file of fs17.readdirSync(dir)) {
12378
12406
  if (!file.endsWith(".yaml") && !file.endsWith(".yml")) continue;
12379
12407
  try {
12380
- const content = fs16.readFileSync(path17.join(dir, file), "utf-8");
12408
+ const content = fs17.readFileSync(path18.join(dir, file), "utf-8");
12381
12409
  const parsed = yaml10.load(content);
12382
12410
  const result = ScheduleSpecSchema.safeParse(parsed);
12383
12411
  if (!result.success) {
@@ -12433,12 +12461,12 @@ function createScheduleFromYaml(yamlContent) {
12433
12461
  `Invalid schedule: ${result.error.issues.map((i) => i.message).join(", ")}`
12434
12462
  );
12435
12463
  }
12436
- fs16.mkdirSync(USER_DIR, { recursive: true });
12437
- const filePath = path17.join(USER_DIR, `${result.data.id}.yaml`);
12438
- if (fs16.existsSync(filePath)) {
12464
+ fs17.mkdirSync(USER_DIR, { recursive: true });
12465
+ const filePath = path18.join(USER_DIR, `${result.data.id}.yaml`);
12466
+ if (fs17.existsSync(filePath)) {
12439
12467
  throw new Error(`Schedule "${result.data.id}" already exists`);
12440
12468
  }
12441
- fs16.writeFileSync(filePath, yamlContent);
12469
+ fs17.writeFileSync(filePath, yamlContent);
12442
12470
  reloadSchedules();
12443
12471
  return result.data;
12444
12472
  }
@@ -12490,11 +12518,11 @@ function deleteSchedule(id) {
12490
12518
  if (isBuiltinSchedule(id)) {
12491
12519
  throw new Error("Cannot delete built-in schedules");
12492
12520
  }
12493
- const filePath = path17.join(USER_DIR, `${id}.yaml`);
12494
- if (!fs16.existsSync(filePath)) {
12521
+ const filePath = path18.join(USER_DIR, `${id}.yaml`);
12522
+ if (!fs17.existsSync(filePath)) {
12495
12523
  throw new Error(`Schedule "${id}" not found`);
12496
12524
  }
12497
- fs16.unlinkSync(filePath);
12525
+ fs17.unlinkSync(filePath);
12498
12526
  reloadSchedules();
12499
12527
  }
12500
12528
  var BUILTINS_DIR3, USER_DIR, scheduleCache, builtinIdsCache, pluginScheduleIndex;
@@ -12504,7 +12532,7 @@ var init_registry5 = __esm({
12504
12532
  init_schedule_spec();
12505
12533
  init_ainative_paths();
12506
12534
  init_app_root();
12507
- BUILTINS_DIR3 = path17.resolve(
12535
+ BUILTINS_DIR3 = path18.resolve(
12508
12536
  getAppRoot(import.meta.dirname, 4),
12509
12537
  "src",
12510
12538
  "lib",
@@ -12650,8 +12678,8 @@ __export(registry_exports5, {
12650
12678
  reloadPlugins: () => reloadPlugins,
12651
12679
  scanBundleSection: () => scanBundleSection
12652
12680
  });
12653
- import fs17 from "fs";
12654
- import path18 from "path";
12681
+ import fs18 from "fs";
12682
+ import path19 from "path";
12655
12683
  import yaml11 from "js-yaml";
12656
12684
  import { z as z16 } from "zod";
12657
12685
  function isSupportedApiVersion(apiVersion) {
@@ -12660,9 +12688,9 @@ function isSupportedApiVersion(apiVersion) {
12660
12688
  function logToFile5(line) {
12661
12689
  try {
12662
12690
  const logsDir = getAinativeLogsDir();
12663
- fs17.mkdirSync(logsDir, { recursive: true });
12664
- fs17.appendFileSync(
12665
- path18.join(logsDir, "plugins.log"),
12691
+ fs18.mkdirSync(logsDir, { recursive: true });
12692
+ fs18.appendFileSync(
12693
+ path19.join(logsDir, "plugins.log"),
12666
12694
  `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
12667
12695
  `
12668
12696
  );
@@ -12670,11 +12698,11 @@ function logToFile5(line) {
12670
12698
  }
12671
12699
  }
12672
12700
  function readManifest(rootDir) {
12673
- const manifestPath = path18.join(rootDir, "plugin.yaml");
12674
- if (!fs17.existsSync(manifestPath)) return { error: "missing plugin.yaml" };
12701
+ const manifestPath = path19.join(rootDir, "plugin.yaml");
12702
+ if (!fs18.existsSync(manifestPath)) return { error: "missing plugin.yaml" };
12675
12703
  let raw;
12676
12704
  try {
12677
- raw = yaml11.load(fs17.readFileSync(manifestPath, "utf-8"));
12705
+ raw = yaml11.load(fs18.readFileSync(manifestPath, "utf-8"));
12678
12706
  } catch (err2) {
12679
12707
  return { error: `yaml_parse: ${err2 instanceof Error ? err2.message : String(err2)}` };
12680
12708
  }
@@ -12686,16 +12714,16 @@ function readManifest(rootDir) {
12686
12714
  }
12687
12715
  function discoverBundleRoots() {
12688
12716
  const baseDir = getAinativePluginsDir();
12689
- if (!fs17.existsSync(baseDir)) return [];
12690
- return fs17.readdirSync(baseDir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => path18.join(baseDir, e.name)).sort();
12717
+ if (!fs18.existsSync(baseDir)) return [];
12718
+ return fs18.readdirSync(baseDir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => path19.join(baseDir, e.name)).sort();
12691
12719
  }
12692
12720
  function scanBundleSection(opts2) {
12693
- const dir = path18.join(opts2.rootDir, opts2.section);
12694
- if (!fs17.existsSync(dir)) return [];
12721
+ const dir = path19.join(opts2.rootDir, opts2.section);
12722
+ if (!fs18.existsSync(dir)) return [];
12695
12723
  const out = [];
12696
- for (const file of fs17.readdirSync(dir)) {
12724
+ for (const file of fs18.readdirSync(dir)) {
12697
12725
  if (!file.endsWith(".yaml") && !file.endsWith(".yml")) continue;
12698
- const filePath = path18.join(dir, file);
12726
+ const filePath = path19.join(dir, file);
12699
12727
  try {
12700
12728
  const result = opts2.parseFile(filePath);
12701
12729
  if (result !== null) out.push(result);
@@ -12706,8 +12734,8 @@ function scanBundleSection(opts2) {
12706
12734
  return out;
12707
12735
  }
12708
12736
  function scanBundleProfiles(rootDir, pluginId) {
12709
- const profilesDir = path18.join(rootDir, "profiles");
12710
- if (!fs17.existsSync(profilesDir)) return [];
12737
+ const profilesDir = path19.join(rootDir, "profiles");
12738
+ if (!fs18.existsSync(profilesDir)) return [];
12711
12739
  const tmp = /* @__PURE__ */ new Map();
12712
12740
  scanProfilesIntoMap(profilesDir, tmp, { namespace: pluginId });
12713
12741
  return Array.from(tmp.entries()).map(([id, profile]) => ({
@@ -12720,9 +12748,9 @@ function scanBundleBlueprints(rootDir, pluginId, siblingProfileIds) {
12720
12748
  rootDir,
12721
12749
  section: "blueprints",
12722
12750
  parseFile: (filePath) => {
12723
- const file = path18.basename(filePath);
12751
+ const file = path19.basename(filePath);
12724
12752
  try {
12725
- const raw = yaml11.load(fs17.readFileSync(filePath, "utf-8"));
12753
+ const raw = yaml11.load(fs18.readFileSync(filePath, "utf-8"));
12726
12754
  const parsed = BlueprintSchema.safeParse(raw);
12727
12755
  if (!parsed.success) {
12728
12756
  logToFile5(`skip blueprint ${pluginId}/${file}: ${parsed.error.issues.map((i) => i.message).join("; ")}`);
@@ -12748,9 +12776,9 @@ function scanBundleTables(rootDir, pluginId) {
12748
12776
  rootDir,
12749
12777
  section: "tables",
12750
12778
  parseFile: (filePath) => {
12751
- const file = path18.basename(filePath);
12779
+ const file = path19.basename(filePath);
12752
12780
  try {
12753
- const raw = yaml11.load(fs17.readFileSync(filePath, "utf-8"));
12781
+ const raw = yaml11.load(fs18.readFileSync(filePath, "utf-8"));
12754
12782
  const parsed = PluginTableSchema.safeParse(raw);
12755
12783
  if (!parsed.success) {
12756
12784
  logToFile5(`skip table ${pluginId}/${file}: ${parsed.error.issues.map((i) => i.message).join("; ")}`);
@@ -12769,9 +12797,9 @@ function scanBundleSchedules(rootDir, pluginId) {
12769
12797
  rootDir,
12770
12798
  section: "schedules",
12771
12799
  parseFile: (filePath) => {
12772
- const file = path18.basename(filePath);
12800
+ const file = path19.basename(filePath);
12773
12801
  try {
12774
- const raw = yaml11.load(fs17.readFileSync(filePath, "utf-8"));
12802
+ const raw = yaml11.load(fs18.readFileSync(filePath, "utf-8"));
12775
12803
  const parsed = ScheduleSpecSchema.safeParse(raw);
12776
12804
  if (!parsed.success) {
12777
12805
  logToFile5(`skip schedule ${pluginId}/${file}: ${parsed.error.issues.map((i) => i.message).join("; ")}`);
@@ -12858,7 +12886,7 @@ async function scanPlugins() {
12858
12886
  for (const rootDir of discoverBundleRoots()) {
12859
12887
  const { manifest, error } = readManifest(rootDir);
12860
12888
  if (!manifest) {
12861
- const fallbackId = path18.basename(rootDir);
12889
+ const fallbackId = path19.basename(rootDir);
12862
12890
  result.push({
12863
12891
  id: fallbackId,
12864
12892
  manifest: { id: fallbackId, version: "0.0.0", apiVersion: "0.0", kind: "primitives-bundle" },
@@ -12982,7 +13010,7 @@ var init_registry6 = __esm({
12982
13010
  init_registry5();
12983
13011
  init_installer();
12984
13012
  init_schedule_spec();
12985
- SUPPORTED_API_VERSIONS = /* @__PURE__ */ new Set([CURRENT_PLUGIN_API_VERSION, "0.26"]);
13013
+ SUPPORTED_API_VERSIONS = /* @__PURE__ */ new Set([CURRENT_PLUGIN_API_VERSION, "0.27"]);
12986
13014
  pluginCache = null;
12987
13015
  lastLoadedPluginIds = /* @__PURE__ */ new Set();
12988
13016
  PluginTableSchema = z16.object({
@@ -13025,8 +13053,8 @@ function pluginTools(_ctx) {
13025
13053
  Promise.resolve().then(() => (init_ainative_paths(), ainative_paths_exports)),
13026
13054
  Promise.resolve().then(() => (init_types(), types_exports))
13027
13055
  ]);
13028
- const fs23 = await import("fs");
13029
- const path24 = await import("path");
13056
+ const fs24 = await import("fs");
13057
+ const path25 = await import("path");
13030
13058
  const yaml13 = await import("js-yaml");
13031
13059
  const kind5 = listPlugins2();
13032
13060
  const registrations = await listPluginMcpRegistrations2();
@@ -13043,13 +13071,13 @@ function pluginTools(_ctx) {
13043
13071
  let manifestHash;
13044
13072
  let capabilityAcceptStatus = "pending";
13045
13073
  try {
13046
- const pluginYamlPath = path24.join(
13074
+ const pluginYamlPath = path25.join(
13047
13075
  pluginsDir,
13048
13076
  pluginId,
13049
13077
  "plugin.yaml"
13050
13078
  );
13051
- if (fs23.existsSync(pluginYamlPath)) {
13052
- const content = fs23.readFileSync(pluginYamlPath, "utf-8");
13079
+ if (fs24.existsSync(pluginYamlPath)) {
13080
+ const content = fs24.readFileSync(pluginYamlPath, "utf-8");
13053
13081
  const rawManifest = yaml13.load(content);
13054
13082
  if (rawManifest !== null && typeof rawManifest === "object" && !Array.isArray(rawManifest)) {
13055
13083
  const record = rawManifest;
@@ -13062,7 +13090,7 @@ function pluginTools(_ctx) {
13062
13090
  try {
13063
13091
  manifestHash = deriveManifestHash2(content);
13064
13092
  const parsed = PluginManifestSchema2.safeParse(rawManifest);
13065
- const pluginRootDir = path24.join(pluginsDir, pluginId);
13093
+ const pluginRootDir = path25.join(pluginsDir, pluginId);
13066
13094
  const check = isCapabilityAccepted2(
13067
13095
  pluginId,
13068
13096
  manifestHash,
@@ -13276,7 +13304,7 @@ var list_fused_profiles_exports = {};
13276
13304
  __export(list_fused_profiles_exports, {
13277
13305
  listFusedProfiles: () => listFusedProfiles
13278
13306
  });
13279
- import { readdirSync as readdirSync2, readFileSync as readFileSync6, statSync as statSync4, existsSync as existsSync7 } from "fs";
13307
+ import { readdirSync as readdirSync3, readFileSync as readFileSync6, statSync as statSync4, existsSync as existsSync7 } from "fs";
13280
13308
  import { join as join12 } from "path";
13281
13309
  import { homedir as homedir5 } from "os";
13282
13310
  function parseFrontmatter2(content) {
@@ -13295,7 +13323,7 @@ function parseFrontmatter2(content) {
13295
13323
  function loadFilesystemSkills(skillsDir, origin, projectRootDir) {
13296
13324
  if (!existsSync7(skillsDir)) return [];
13297
13325
  const profiles = [];
13298
- for (const entry of readdirSync2(skillsDir)) {
13326
+ for (const entry of readdirSync3(skillsDir)) {
13299
13327
  const skillPath = join12(skillsDir, entry);
13300
13328
  try {
13301
13329
  if (!statSync4(skillPath).isDirectory()) continue;
@@ -16018,7 +16046,7 @@ var init_active_skills = __esm({
16018
16046
  });
16019
16047
 
16020
16048
  // src/lib/environment/parsers/skill.ts
16021
- import { readdirSync as readdirSync3, readFileSync as readFileSync7 } from "fs";
16049
+ import { readdirSync as readdirSync4, readFileSync as readFileSync7 } from "fs";
16022
16050
  import { join as join13, basename as basename4 } from "path";
16023
16051
  function parseSkillDir(dirPath, tool, scope, baseDir) {
16024
16052
  const stat2 = safeStat(dirPath);
@@ -16028,7 +16056,7 @@ function parseSkillDir(dirPath, tool, scope, baseDir) {
16028
16056
  let mainFile = "";
16029
16057
  let content = "";
16030
16058
  try {
16031
- const files = readdirSync3(dirPath);
16059
+ const files = readdirSync4(dirPath);
16032
16060
  const skillFile = files.find((f) => f === "SKILL.md") || files.find((f) => f.endsWith(".md")) || files[0];
16033
16061
  if (skillFile) {
16034
16062
  mainFile = join13(dirPath, skillFile);
@@ -16078,7 +16106,7 @@ var init_skill = __esm({
16078
16106
  });
16079
16107
 
16080
16108
  // src/lib/environment/parsers/settings.ts
16081
- import { readdirSync as readdirSync4 } from "fs";
16109
+ import { readdirSync as readdirSync5 } from "fs";
16082
16110
  import { join as join14, basename as basename5 } from "path";
16083
16111
  function parseClaudeSettings(filePath, scope, baseDir) {
16084
16112
  const content = safeReadFile(filePath);
@@ -16182,7 +16210,7 @@ function parseOutputStyles(dirPath, tool, baseDir) {
16182
16210
  if (!stat2?.isDirectory()) return [];
16183
16211
  const artifacts = [];
16184
16212
  try {
16185
- for (const entry of readdirSync4(dirPath)) {
16213
+ for (const entry of readdirSync5(dirPath)) {
16186
16214
  const fullPath = join14(dirPath, entry);
16187
16215
  const content = safeReadFile(fullPath);
16188
16216
  if (!content) continue;
@@ -16260,7 +16288,7 @@ var init_instructions = __esm({
16260
16288
  });
16261
16289
 
16262
16290
  // src/lib/environment/scanners/claude-code.ts
16263
- import { readdirSync as readdirSync5, existsSync as existsSync8 } from "fs";
16291
+ import { readdirSync as readdirSync6, existsSync as existsSync8 } from "fs";
16264
16292
  import { join as join15 } from "path";
16265
16293
  function scanUserLevel(userHome) {
16266
16294
  const claudeDir = join15(userHome, ".claude");
@@ -16270,7 +16298,7 @@ function scanUserLevel(userHome) {
16270
16298
  const skillsDir = join15(claudeDir, "skills");
16271
16299
  if (existsSync8(skillsDir)) {
16272
16300
  try {
16273
- for (const entry of readdirSync5(skillsDir)) {
16301
+ for (const entry of readdirSync6(skillsDir)) {
16274
16302
  const skillPath = join15(skillsDir, entry);
16275
16303
  const artifact = parseSkillDir(skillPath, "claude-code", "user", userHome);
16276
16304
  if (artifact) artifacts.push(artifact);
@@ -16300,7 +16328,7 @@ function scanUserLevel(userHome) {
16300
16328
  const projectsDir = join15(claudeDir, "projects");
16301
16329
  if (existsSync8(projectsDir)) {
16302
16330
  try {
16303
- for (const projEntry of readdirSync5(projectsDir)) {
16331
+ for (const projEntry of readdirSync6(projectsDir)) {
16304
16332
  const memoryDir = join15(projectsDir, projEntry, "memory");
16305
16333
  if (!existsSync8(memoryDir)) continue;
16306
16334
  const memoryIndex = join15(memoryDir, "MEMORY.md");
@@ -16333,7 +16361,7 @@ function scanProjectLevel(projectDir) {
16333
16361
  const skillsDir = join15(claudeDir, "skills");
16334
16362
  if (existsSync8(skillsDir)) {
16335
16363
  try {
16336
- for (const entry of readdirSync5(skillsDir)) {
16364
+ for (const entry of readdirSync6(skillsDir)) {
16337
16365
  const skillPath = join15(skillsDir, entry);
16338
16366
  const artifact = parseSkillDir(skillPath, "claude-code", "project", projectDir);
16339
16367
  if (artifact) artifacts.push(artifact);
@@ -16355,7 +16383,7 @@ function scanProjectLevel(projectDir) {
16355
16383
  const hooksDir = join15(claudeDir, "hooks");
16356
16384
  if (existsSync8(hooksDir)) {
16357
16385
  try {
16358
- for (const entry of readdirSync5(hooksDir)) {
16386
+ for (const entry of readdirSync6(hooksDir)) {
16359
16387
  const hookPath = join15(hooksDir, entry);
16360
16388
  const content = safeReadFile(hookPath);
16361
16389
  if (!content) continue;
@@ -16401,7 +16429,7 @@ var init_claude_code = __esm({
16401
16429
  });
16402
16430
 
16403
16431
  // src/lib/environment/scanners/codex.ts
16404
- import { readdirSync as readdirSync6, existsSync as existsSync9 } from "fs";
16432
+ import { readdirSync as readdirSync7, existsSync as existsSync9 } from "fs";
16405
16433
  import { join as join16 } from "path";
16406
16434
  function scanUserLevel2(userHome) {
16407
16435
  const codexDir = join16(userHome, ".codex");
@@ -16411,7 +16439,7 @@ function scanUserLevel2(userHome) {
16411
16439
  const skillsDir = join16(codexDir, "skills");
16412
16440
  if (existsSync9(skillsDir)) {
16413
16441
  try {
16414
- for (const entry of readdirSync6(skillsDir)) {
16442
+ for (const entry of readdirSync7(skillsDir)) {
16415
16443
  const skillPath = join16(skillsDir, entry);
16416
16444
  const artifact = parseSkillDir(skillPath, "codex", "user", userHome);
16417
16445
  if (artifact) artifacts.push(artifact);
@@ -16428,7 +16456,7 @@ function scanUserLevel2(userHome) {
16428
16456
  const rulesDir = join16(codexDir, "rules");
16429
16457
  if (existsSync9(rulesDir)) {
16430
16458
  try {
16431
- for (const entry of readdirSync6(rulesDir)) {
16459
+ for (const entry of readdirSync7(rulesDir)) {
16432
16460
  const rulePath = join16(rulesDir, entry);
16433
16461
  const content = safeReadFile(rulePath);
16434
16462
  if (!content) continue;
@@ -16455,7 +16483,7 @@ function scanUserLevel2(userHome) {
16455
16483
  const memoriesDir = join16(codexDir, "memories");
16456
16484
  if (existsSync9(memoriesDir)) {
16457
16485
  try {
16458
- for (const entry of readdirSync6(memoriesDir)) {
16486
+ for (const entry of readdirSync7(memoriesDir)) {
16459
16487
  const memPath = join16(memoriesDir, entry);
16460
16488
  const content = safeReadFile(memPath);
16461
16489
  if (!content) continue;
@@ -16668,7 +16696,7 @@ __export(list_skills_exports, {
16668
16696
  listSkills: () => listSkills,
16669
16697
  listSkillsEnriched: () => listSkillsEnriched
16670
16698
  });
16671
- import { readFileSync as readFileSync8, readdirSync as readdirSync7, statSync as statSync5 } from "fs";
16699
+ import { readFileSync as readFileSync8, readdirSync as readdirSync8, statSync as statSync5 } from "fs";
16672
16700
  import { join as join18 } from "path";
16673
16701
  function listSkills(options = {}) {
16674
16702
  const projectDir = options.projectDir ?? getLaunchCwd();
@@ -16716,7 +16744,7 @@ function resolveSkillFile(dirPath) {
16716
16744
  }
16717
16745
  }
16718
16746
  try {
16719
- const fallback = readdirSync7(dirPath).find((f) => f.toLowerCase().endsWith(".md"));
16747
+ const fallback = readdirSync8(dirPath).find((f) => f.toLowerCase().endsWith(".md"));
16720
16748
  if (fallback) return join18(dirPath, fallback);
16721
16749
  } catch {
16722
16750
  }
@@ -17218,8 +17246,8 @@ var init_schedule_spec_tools = __esm({
17218
17246
 
17219
17247
  // src/lib/chat/tools/plugin-spec-tools.ts
17220
17248
  import { z as z27 } from "zod";
17221
- import * as fs18 from "fs";
17222
- import * as path19 from "path";
17249
+ import * as fs19 from "fs";
17250
+ import * as path20 from "path";
17223
17251
  function validateId(id) {
17224
17252
  if (id.length < 2) {
17225
17253
  throw new PluginSpecInvalidIdError(id, "must be at least 2 chars");
@@ -17482,20 +17510,20 @@ directory at load time \u2014 you do not need to edit that path.
17482
17510
  function scaffoldPluginSpec(input) {
17483
17511
  validateId(input.id);
17484
17512
  const pluginsDir = getAinativePluginsDir();
17485
- const pluginDir = path19.join(pluginsDir, input.id);
17486
- const tmpDir = path19.join(pluginsDir, `${input.id}.tmp-${Date.now()}`);
17487
- if (fs18.existsSync(pluginDir)) {
17513
+ const pluginDir = path20.join(pluginsDir, input.id);
17514
+ const tmpDir = path20.join(pluginsDir, `${input.id}.tmp-${Date.now()}`);
17515
+ if (fs19.existsSync(pluginDir)) {
17488
17516
  throw new PluginSpecAlreadyExistsError(pluginDir);
17489
17517
  }
17490
17518
  try {
17491
- fs18.mkdirSync(tmpDir, { recursive: true });
17492
- fs18.writeFileSync(
17493
- path19.join(tmpDir, "plugin.yaml"),
17519
+ fs19.mkdirSync(tmpDir, { recursive: true });
17520
+ fs19.writeFileSync(
17521
+ path20.join(tmpDir, "plugin.yaml"),
17494
17522
  renderPluginYaml(input),
17495
17523
  "utf-8"
17496
17524
  );
17497
- fs18.writeFileSync(
17498
- path19.join(tmpDir, ".mcp.json"),
17525
+ fs19.writeFileSync(
17526
+ path20.join(tmpDir, ".mcp.json"),
17499
17527
  renderMcpJson({
17500
17528
  id: input.id,
17501
17529
  transport: input.transport,
@@ -17503,8 +17531,8 @@ function scaffoldPluginSpec(input) {
17503
17531
  }),
17504
17532
  "utf-8"
17505
17533
  );
17506
- fs18.writeFileSync(
17507
- path19.join(tmpDir, "server.py"),
17534
+ fs19.writeFileSync(
17535
+ path20.join(tmpDir, "server.py"),
17508
17536
  renderServerPy({
17509
17537
  id: input.id,
17510
17538
  tools: input.tools,
@@ -17513,8 +17541,8 @@ function scaffoldPluginSpec(input) {
17513
17541
  }),
17514
17542
  "utf-8"
17515
17543
  );
17516
- fs18.writeFileSync(
17517
- path19.join(tmpDir, "README.md"),
17544
+ fs19.writeFileSync(
17545
+ path20.join(tmpDir, "README.md"),
17518
17546
  renderReadme({
17519
17547
  id: input.id,
17520
17548
  name: input.name,
@@ -17522,11 +17550,11 @@ function scaffoldPluginSpec(input) {
17522
17550
  }),
17523
17551
  "utf-8"
17524
17552
  );
17525
- fs18.renameSync(tmpDir, pluginDir);
17553
+ fs19.renameSync(tmpDir, pluginDir);
17526
17554
  } catch (cause) {
17527
17555
  try {
17528
- if (fs18.existsSync(tmpDir)) {
17529
- fs18.rmSync(tmpDir, { recursive: true, force: true });
17556
+ if (fs19.existsSync(tmpDir)) {
17557
+ fs19.rmSync(tmpDir, { recursive: true, force: true });
17530
17558
  }
17531
17559
  } catch {
17532
17560
  }
@@ -17537,10 +17565,10 @@ function scaffoldPluginSpec(input) {
17537
17565
  id: input.id,
17538
17566
  pluginDir,
17539
17567
  files: {
17540
- pluginYaml: path19.join(pluginDir, "plugin.yaml"),
17541
- mcpJson: path19.join(pluginDir, ".mcp.json"),
17542
- serverPy: path19.join(pluginDir, "server.py"),
17543
- readme: path19.join(pluginDir, "README.md")
17568
+ pluginYaml: path20.join(pluginDir, "plugin.yaml"),
17569
+ mcpJson: path20.join(pluginDir, ".mcp.json"),
17570
+ serverPy: path20.join(pluginDir, "server.py"),
17571
+ readme: path20.join(pluginDir, "README.md")
17544
17572
  },
17545
17573
  tools: input.tools.map((t) => t.name),
17546
17574
  message: `Scaffolded ${input.id}. Reload ainative to register.`
@@ -19501,13 +19529,13 @@ var init_codex_app_server_client = __esm({
19501
19529
  await syncPluginMcpToCodex2();
19502
19530
  } catch (err2) {
19503
19531
  try {
19504
- const fs23 = await import("fs");
19505
- const path24 = await import("path");
19532
+ const fs24 = await import("fs");
19533
+ const path25 = await import("path");
19506
19534
  const { getAinativeLogsDir: getAinativeLogsDir2 } = await Promise.resolve().then(() => (init_ainative_paths(), ainative_paths_exports));
19507
19535
  const dir = getAinativeLogsDir2();
19508
- fs23.mkdirSync(dir, { recursive: true });
19509
- fs23.appendFileSync(
19510
- path24.join(dir, "plugins.log"),
19536
+ fs24.mkdirSync(dir, { recursive: true });
19537
+ fs24.appendFileSync(
19538
+ path25.join(dir, "plugins.log"),
19511
19539
  `${(/* @__PURE__ */ new Date()).toISOString()} codex-sync-failed: ${err2 instanceof Error ? err2.message : String(err2)}
19512
19540
  `
19513
19541
  );
@@ -23169,14 +23197,14 @@ function resolvePostAction(action, row, itemVariable) {
23169
23197
  function substituteRowPath(template, row, itemVariable) {
23170
23198
  const escaped = itemVariable.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
23171
23199
  const pattern = new RegExp(`\\{\\{\\s*${escaped}\\.([\\w.]+)\\s*\\}\\}`, "g");
23172
- return template.replace(pattern, (_match, path24) => {
23173
- const value = readPath(row, path24);
23200
+ return template.replace(pattern, (_match, path25) => {
23201
+ const value = readPath(row, path25);
23174
23202
  if (value === void 0 || value === null) return "";
23175
23203
  return String(value);
23176
23204
  });
23177
23205
  }
23178
- function readPath(obj, path24) {
23179
- const parts = path24.split(".");
23206
+ function readPath(obj, path25) {
23207
+ const parts = path25.split(".");
23180
23208
  let current = obj;
23181
23209
  for (const part of parts) {
23182
23210
  if (current === null || current === void 0) return void 0;
@@ -23363,14 +23391,14 @@ ${resolvedTemplate}`);
23363
23391
  return parts.join("");
23364
23392
  }
23365
23393
  function resolveRowTemplate(template, context) {
23366
- return template.replace(/\{\{\s*([^}]+)\s*\}\}/g, (_match, path24) => {
23367
- const value = readContextPath(context, path24.trim());
23394
+ return template.replace(/\{\{\s*([^}]+)\s*\}\}/g, (_match, path25) => {
23395
+ const value = readContextPath(context, path25.trim());
23368
23396
  if (value === void 0 || value === null) return "";
23369
23397
  return typeof value === "string" ? value : JSON.stringify(value);
23370
23398
  });
23371
23399
  }
23372
- function readContextPath(value, path24) {
23373
- const parts = path24.split(".");
23400
+ function readContextPath(value, path25) {
23401
+ const parts = path25.split(".");
23374
23402
  let current = value;
23375
23403
  for (const part of parts) {
23376
23404
  if (current === null || current === void 0) return void 0;
@@ -25859,16 +25887,16 @@ __export(install_state_exports, {
25859
25887
  readInstallState: () => readInstallState,
25860
25888
  writeInstallState: () => writeInstallState
25861
25889
  });
25862
- import fs19 from "fs";
25863
- import path20 from "path";
25890
+ import fs20 from "fs";
25891
+ import path21 from "path";
25864
25892
  import { createHash as createHash5 } from "crypto";
25865
25893
  import { z as z30 } from "zod";
25866
25894
  function installStatePath(appsDir, appId) {
25867
- return path20.join(appsDir, appId, "install-state.json");
25895
+ return path21.join(appsDir, appId, "install-state.json");
25868
25896
  }
25869
25897
  function readInstallState(appsDir, appId) {
25870
25898
  try {
25871
- const raw = fs19.readFileSync(installStatePath(appsDir, appId), "utf-8");
25899
+ const raw = fs20.readFileSync(installStatePath(appsDir, appId), "utf-8");
25872
25900
  const parsed = InstallStateSchema.safeParse(JSON.parse(raw));
25873
25901
  return parsed.success ? parsed.data : null;
25874
25902
  } catch {
@@ -25876,14 +25904,14 @@ function readInstallState(appsDir, appId) {
25876
25904
  }
25877
25905
  }
25878
25906
  function writeInstallState(appsDir, appId, state) {
25879
- const dir = path20.join(appsDir, appId);
25880
- fs19.mkdirSync(dir, { recursive: true });
25881
- const tmp = path20.join(dir, `.install-state.${process.pid}.tmp`);
25882
- fs19.writeFileSync(tmp, JSON.stringify(state, null, 2) + "\n");
25883
- fs19.renameSync(tmp, installStatePath(appsDir, appId));
25907
+ const dir = path21.join(appsDir, appId);
25908
+ fs20.mkdirSync(dir, { recursive: true });
25909
+ const tmp = path21.join(dir, `.install-state.${process.pid}.tmp`);
25910
+ fs20.writeFileSync(tmp, JSON.stringify(state, null, 2) + "\n");
25911
+ fs20.renameSync(tmp, installStatePath(appsDir, appId));
25884
25912
  }
25885
25913
  function hashFileSha256(absPath) {
25886
- return createHash5("sha256").update(fs19.readFileSync(absPath)).digest("hex");
25914
+ return createHash5("sha256").update(fs20.readFileSync(absPath)).digest("hex");
25887
25915
  }
25888
25916
  var InstallStateSchema;
25889
25917
  var init_install_state = __esm({
@@ -25906,20 +25934,20 @@ __export(install_exports, {
25906
25934
  installPack: () => installPack,
25907
25935
  relayCoreVersion: () => relayCoreVersion
25908
25936
  });
25909
- import fs20 from "fs";
25910
- import path21 from "path";
25937
+ import fs21 from "fs";
25938
+ import path22 from "path";
25911
25939
  import os4 from "os";
25912
25940
  import { execFileSync as execFileSync3 } from "child_process";
25913
25941
  import yaml12 from "js-yaml";
25914
25942
  import semver from "semver";
25915
25943
  function relayCoreVersion() {
25916
- if (semver.valid("0.27.0")) {
25917
- return "0.27.0";
25944
+ if (semver.valid("0.28.0")) {
25945
+ return "0.28.0";
25918
25946
  }
25919
25947
  try {
25920
25948
  const root = getAppRoot(import.meta.dirname, 3);
25921
25949
  const pkg2 = JSON.parse(
25922
- fs20.readFileSync(path21.join(root, "package.json"), "utf-8")
25950
+ fs21.readFileSync(path22.join(root, "package.json"), "utf-8")
25923
25951
  );
25924
25952
  if (pkg2.version && semver.valid(pkg2.version)) return pkg2.version;
25925
25953
  } catch {
@@ -26117,25 +26145,25 @@ function isGitUrl(source) {
26117
26145
  }
26118
26146
  function acquirePack(source) {
26119
26147
  if (!isGitUrl(source)) {
26120
- const resolved = path21.resolve(source);
26121
- if (!fs20.existsSync(resolved)) {
26148
+ const resolved = path22.resolve(source);
26149
+ if (!fs21.existsSync(resolved)) {
26122
26150
  throw new PackValidationError(`Pack path does not exist: ${resolved}`);
26123
26151
  }
26124
26152
  return { dir: resolved, cleanup: () => {
26125
26153
  } };
26126
26154
  }
26127
- const tmp = fs20.mkdtempSync(path21.join(os4.tmpdir(), "ainative-pack-clone-"));
26155
+ const tmp = fs21.mkdtempSync(path22.join(os4.tmpdir(), "ainative-pack-clone-"));
26128
26156
  try {
26129
26157
  execFileSync3("git", ["clone", "--depth", "1", source, tmp], {
26130
26158
  stdio: "pipe"
26131
26159
  });
26132
26160
  } catch (err2) {
26133
- fs20.rmSync(tmp, { recursive: true, force: true });
26161
+ fs21.rmSync(tmp, { recursive: true, force: true });
26134
26162
  throw new PackValidationError(`git clone failed for ${source}`, err2);
26135
26163
  }
26136
26164
  return {
26137
26165
  dir: tmp,
26138
- cleanup: () => fs20.rmSync(tmp, { recursive: true, force: true })
26166
+ cleanup: () => fs21.rmSync(tmp, { recursive: true, force: true })
26139
26167
  };
26140
26168
  }
26141
26169
  function findResolved(files, relPath) {
@@ -26144,7 +26172,7 @@ function findResolved(files, relPath) {
26144
26172
  function readCustomerSeed(resolved) {
26145
26173
  const file = findResolved(resolved.files, "seed/customers.yaml");
26146
26174
  if (!file) return [];
26147
- const parsed = yaml12.load(fs20.readFileSync(file.absPath, "utf-8"));
26175
+ const parsed = yaml12.load(fs21.readFileSync(file.absPath, "utf-8"));
26148
26176
  if (!Array.isArray(parsed)) {
26149
26177
  throw new PackValidationError(
26150
26178
  "seed/customers.yaml must be a YAML list of { slug, name, ... }"
@@ -26156,7 +26184,7 @@ function readTableSeed(resolved, logicalId) {
26156
26184
  for (const ext of ["json", "yaml", "yml"]) {
26157
26185
  const file = findResolved(resolved.files, `seed/tables/${logicalId}.${ext}`);
26158
26186
  if (!file) continue;
26159
- const text2 = fs20.readFileSync(file.absPath, "utf-8");
26187
+ const text2 = fs21.readFileSync(file.absPath, "utf-8");
26160
26188
  const parsed = ext === "json" ? JSON.parse(text2) : yaml12.load(text2);
26161
26189
  if (!Array.isArray(parsed)) {
26162
26190
  throw new PackValidationError(
@@ -26214,15 +26242,15 @@ function rewriteViewRefs(view, maps) {
26214
26242
  return view;
26215
26243
  }
26216
26244
  function writeManifest(appsDir, appId, manifest) {
26217
- fs20.mkdirSync(path21.join(appsDir, appId), { recursive: true });
26245
+ fs21.mkdirSync(path22.join(appsDir, appId), { recursive: true });
26218
26246
  writeAppManifest(appId, manifest, appsDir);
26219
26247
  }
26220
26248
  function artifactDestPath(relPath, profilesDir, blueprintsDir) {
26221
26249
  if (relPath.startsWith("profiles/")) {
26222
- return path21.join(profilesDir, relPath.slice("profiles/".length));
26250
+ return path22.join(profilesDir, relPath.slice("profiles/".length));
26223
26251
  }
26224
26252
  if (relPath.startsWith("blueprints/") && relPath.endsWith(".yaml")) {
26225
- return path21.join(blueprintsDir, relPath.slice("blueprints/".length));
26253
+ return path22.join(blueprintsDir, relPath.slice("blueprints/".length));
26226
26254
  }
26227
26255
  return null;
26228
26256
  }
@@ -26233,8 +26261,8 @@ function dropArtifacts(files, profilesDir, blueprintsDir) {
26233
26261
  for (const file of files) {
26234
26262
  const dest = artifactDestPath(file.relPath, profilesDir, blueprintsDir);
26235
26263
  if (!dest) continue;
26236
- fs20.mkdirSync(path21.dirname(dest), { recursive: true });
26237
- fs20.copyFileSync(file.absPath, dest);
26264
+ fs21.mkdirSync(path22.dirname(dest), { recursive: true });
26265
+ fs21.copyFileSync(file.absPath, dest);
26238
26266
  dropped.push({ relPath: file.relPath, destPath: dest });
26239
26267
  if (file.relPath.startsWith("profiles/")) {
26240
26268
  const top = file.relPath.split("/")[1];
@@ -26264,8 +26292,8 @@ __export(recap_exports, {
26264
26292
  changelogWindow: () => changelogWindow,
26265
26293
  entitledPackRecaps: () => entitledPackRecaps
26266
26294
  });
26267
- import fs21 from "fs";
26268
- import path22 from "path";
26295
+ import fs22 from "fs";
26296
+ import path23 from "path";
26269
26297
  import semver2 from "semver";
26270
26298
  function changelogWindow(changelog, fromExclusive, toInclusive) {
26271
26299
  if (!changelog || !toInclusive || !semver2.valid(toInclusive)) return [];
@@ -26282,7 +26310,7 @@ function entitledPackRecaps(entitlements, opts2 = {}) {
26282
26310
  for (const tpl of listPackTemplates({ templatesDir: opts2.templatesDir })) {
26283
26311
  if (tpl.error || !tpl.meta?.entitlement) continue;
26284
26312
  if (!covered.has(tpl.meta.entitlement)) continue;
26285
- if (!fs21.existsSync(path22.join(appsDir, tpl.id))) continue;
26313
+ if (!fs22.existsSync(path23.join(appsDir, tpl.id))) continue;
26286
26314
  const avail = packUpdateAvailability(tpl.id, {
26287
26315
  appsDir,
26288
26316
  templatesDir: opts2.templatesDir
@@ -26327,8 +26355,8 @@ __export(update_exports, {
26327
26355
  packUpdateAvailability: () => packUpdateAvailability,
26328
26356
  updatePack: () => updatePack
26329
26357
  });
26330
- import fs22 from "fs";
26331
- import path23 from "path";
26358
+ import fs23 from "fs";
26359
+ import path24 from "path";
26332
26360
  import semver3 from "semver";
26333
26361
  function packUpdateAvailability(appId, opts2 = {}) {
26334
26362
  const appsDir = opts2.appsDir ?? getAinativeAppsDir();
@@ -26416,7 +26444,7 @@ async function updatePack(id, options = {}) {
26416
26444
  }
26417
26445
  }
26418
26446
  const resolved = resolvePackLayer(pack);
26419
- const backupRoot = path23.join(
26447
+ const backupRoot = path24.join(
26420
26448
  appsDir,
26421
26449
  id,
26422
26450
  "backup",
@@ -26425,12 +26453,12 @@ async function updatePack(id, options = {}) {
26425
26453
  const backedUp = [];
26426
26454
  for (const file of resolved.files) {
26427
26455
  const dest = artifactDestPath(file.relPath, profilesDir, blueprintsDir);
26428
- if (!dest || !fs22.existsSync(dest)) continue;
26456
+ if (!dest || !fs23.existsSync(dest)) continue;
26429
26457
  const recorded = state?.files[file.relPath];
26430
26458
  if (recorded !== void 0 && hashFileSha256(dest) === recorded) continue;
26431
- const backupPath = path23.join(backupRoot, file.relPath);
26432
- fs22.mkdirSync(path23.dirname(backupPath), { recursive: true });
26433
- fs22.copyFileSync(dest, backupPath);
26459
+ const backupPath = path24.join(backupRoot, file.relPath);
26460
+ fs23.mkdirSync(path24.dirname(backupPath), { recursive: true });
26461
+ fs23.copyFileSync(dest, backupPath);
26434
26462
  backedUp.push(file.relPath);
26435
26463
  }
26436
26464
  const install = await installPack(packDir, {
@@ -27149,14 +27177,21 @@ init_ainative_paths();
27149
27177
  init_bootstrap();
27150
27178
 
27151
27179
  // src/lib/utils/migrate-to-ainative.ts
27152
- import { existsSync as existsSync4, renameSync, cpSync, rmSync as rmSync2, readFileSync as readFileSync3 } from "fs";
27180
+ import {
27181
+ existsSync as existsSync4,
27182
+ renameSync,
27183
+ cpSync,
27184
+ rmSync as rmSync2,
27185
+ readFileSync as readFileSync3,
27186
+ readdirSync as readdirSync2
27187
+ } from "fs";
27153
27188
  import { join as join6 } from "path";
27154
27189
  import { homedir as homedir2 } from "os";
27155
27190
  import Database from "better-sqlite3";
27156
- function hasSqliteHeader(path24) {
27191
+ function hasSqliteHeader(path25) {
27157
27192
  const SQLITE_MAGIC = "SQLite format 3\0";
27158
27193
  try {
27159
- const header = readFileSync3(path24, { encoding: null });
27194
+ const header = readFileSync3(path25, { encoding: null });
27160
27195
  return header.length >= 16 && header.subarray(0, 16).toString("binary") === SQLITE_MAGIC;
27161
27196
  } catch {
27162
27197
  return false;
@@ -27166,6 +27201,33 @@ var MIGRATION_CHAIN = [
27166
27201
  { fromDir: ".stagent", toDir: ".ainative", fromDb: "stagent.db", toDb: "ainative.db" },
27167
27202
  { fromDir: ".ainative", toDir: ".relay", fromDb: "ainative.db", toDb: "relay.db" }
27168
27203
  ];
27204
+ function renameProfileFilesInRoot(root, log, errors) {
27205
+ if (!existsSync4(root)) return 0;
27206
+ let renamed = 0;
27207
+ let entries;
27208
+ try {
27209
+ entries = readdirSync2(root, { withFileTypes: true });
27210
+ } catch (err2) {
27211
+ errors.push(`agent-file scan failed in ${root}: ${String(err2)}`);
27212
+ return 0;
27213
+ }
27214
+ for (const entry of entries) {
27215
+ if (!entry.isDirectory()) continue;
27216
+ const dir = join6(root, entry.name);
27217
+ const legacy = join6(dir, "profile.yaml");
27218
+ const next = join6(dir, "agent.yaml");
27219
+ if (existsSync4(legacy) && !existsSync4(next)) {
27220
+ try {
27221
+ renameSync(legacy, next);
27222
+ renamed++;
27223
+ } catch (err2) {
27224
+ errors.push(`agent-file rename failed in ${dir}: ${String(err2)}`);
27225
+ }
27226
+ }
27227
+ }
27228
+ if (renamed > 0) log(`renamed ${renamed} profile.yaml -> agent.yaml in ${root}`);
27229
+ return renamed;
27230
+ }
27169
27231
  async function migrateLegacyData(options = {}) {
27170
27232
  const home = options.home ?? homedir2();
27171
27233
  const gitDir = options.gitDir ?? join6(process.cwd(), ".git");
@@ -27176,6 +27238,7 @@ async function migrateLegacyData(options = {}) {
27176
27238
  sqlRowsUpdated: 0,
27177
27239
  sentinelRenamed: false,
27178
27240
  keychainMigrated: false,
27241
+ agentFilesRenamed: 0,
27179
27242
  errors: []
27180
27243
  };
27181
27244
  const finalDir = join6(home, MIGRATION_CHAIN[MIGRATION_CHAIN.length - 1].toDir);
@@ -27281,6 +27344,13 @@ async function migrateLegacyData(options = {}) {
27281
27344
  report.errors.push(`keychain migration failed: ${String(err2)}`);
27282
27345
  }
27283
27346
  }
27347
+ const profileRoots = [
27348
+ join6(finalDir, "profiles"),
27349
+ join6(home, ".claude", "skills")
27350
+ ];
27351
+ for (const root of profileRoots) {
27352
+ report.agentFilesRenamed += renameProfileFilesInRoot(root, log, report.errors);
27353
+ }
27284
27354
  return report;
27285
27355
  }
27286
27356