@aident-ai/cli 0.3.0 → 0.3.1-staging.ci.34903740288.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/cli.mjs +72 -35
  2. package/dist/dsh.mjs +2965 -45
  3. package/package.json +2 -2
package/dist/cli.mjs CHANGED
@@ -7387,25 +7387,9 @@ async function installAgentSkillBundle(descriptorValue, options = {}, injected =
7387
7387
  const descriptor = AgentSkillBundleInstallDescriptorSchema.parse(descriptorValue);
7388
7388
  const home = options.home ?? homedir2();
7389
7389
  const env = options.env ?? process.env;
7390
- const stateRoot = join3(home, ".aident", "skills", "internal", descriptor.name);
7391
- const releasesRoot = join3(stateRoot, "releases");
7392
- const releaseDirectory = join3(releasesRoot, descriptor.artifactSha256);
7393
- await mkdir3(stateRoot, { recursive: true, mode: 448 });
7394
- const lock = await tryAcquireDirectoryLock(join3(stateRoot, "install.lock"));
7395
- if (!lock)
7396
- throw new Error(`Another ${descriptor.name} installation is already running`);
7397
- try {
7398
- if (!await pathExists(releaseDirectory)) {
7399
- const archive = await downloadArchive(descriptor, injected.fetch ?? fetch);
7400
- await materializeRelease(archive, descriptor, releasesRoot, releaseDirectory);
7401
- } else {
7402
- const existingRelease = await lstat2(releaseDirectory);
7403
- if (!existingRelease.isDirectory()) {
7404
- throw new Error(`Existing agent Skill release is not a directory: ${releaseDirectory}`);
7405
- }
7406
- await assertInstalledSkillIdentity(releaseDirectory, descriptor.name);
7407
- }
7408
- const targets = await reconcileTargets(descriptor.name, releaseDirectory, releasesRoot, home, env);
7390
+ return withInstallLock(descriptor.name, home, async () => {
7391
+ const { releaseDirectory } = await prepareRelease(descriptor, home, injected.fetch ?? fetch);
7392
+ const targets = await reconcileTargets(descriptor.name, releaseDirectory, dirname3(releaseDirectory), home, env);
7409
7393
  return {
7410
7394
  name: descriptor.name,
7411
7395
  version: descriptor.version,
@@ -7414,6 +7398,37 @@ async function installAgentSkillBundle(descriptorValue, options = {}, injected =
7414
7398
  success: targets.every((target) => target.status !== "conflict" /* Conflict */ && target.status !== "failed" /* Failed */),
7415
7399
  targets
7416
7400
  };
7401
+ });
7402
+ }
7403
+ async function prepareAgentSkillBundleRelease(descriptorValue, options = {}, injected = {}) {
7404
+ const descriptor = AgentSkillBundleInstallDescriptorSchema.parse(descriptorValue);
7405
+ const home = options.home ?? homedir2();
7406
+ return withInstallLock(descriptor.name, home, () => prepareRelease(descriptor, home, injected.fetch ?? fetch));
7407
+ }
7408
+ async function prepareRelease(descriptor, home, fetchImpl) {
7409
+ const stateRoot = join3(home, ".aident", "skills", "internal", descriptor.name);
7410
+ const releasesRoot = join3(stateRoot, "releases");
7411
+ const releaseDirectory = join3(releasesRoot, descriptor.artifactSha256);
7412
+ if (!await pathExists(releaseDirectory)) {
7413
+ const archive = await downloadArchive(descriptor, fetchImpl);
7414
+ await materializeRelease(archive, descriptor, releasesRoot, releaseDirectory);
7415
+ } else {
7416
+ const existingRelease = await lstat2(releaseDirectory);
7417
+ if (!existingRelease.isDirectory()) {
7418
+ throw new Error(`Existing agent Skill release is not a directory: ${releaseDirectory}`);
7419
+ }
7420
+ await assertInstalledSkillIdentity(releaseDirectory, descriptor.name);
7421
+ }
7422
+ return { descriptor, releaseDirectory };
7423
+ }
7424
+ async function withInstallLock(name, home, run) {
7425
+ const stateRoot = join3(home, ".aident", "skills", "internal", name);
7426
+ await mkdir3(stateRoot, { recursive: true, mode: 448 });
7427
+ const lock = await tryAcquireDirectoryLock(join3(stateRoot, "install.lock"));
7428
+ if (!lock)
7429
+ throw new Error(`Another ${name} installation is already running`);
7430
+ try {
7431
+ return await run();
7417
7432
  } finally {
7418
7433
  await lock.release();
7419
7434
  }
@@ -8167,7 +8182,7 @@ function getConfigFile() {
8167
8182
  function getConfigFileForHome(home) {
8168
8183
  return join4(getAidentDir(home), "config.json");
8169
8184
  }
8170
- var DEFAULT_BASE_URL = "https://loadout.aident.ai"?.trim() || "https://loadout.aident.ai";
8185
+ var DEFAULT_BASE_URL = "https://staging.loadout.aident.ai"?.trim() || "https://loadout.aident.ai";
8171
8186
  var CONFIG_KEYS = ["baseUrl", "packages"];
8172
8187
  async function readConfig(configFile = getConfigFile()) {
8173
8188
  try {
@@ -8460,7 +8475,7 @@ function serializeLoadoutSkillPackage(skillPackage) {
8460
8475
  }
8461
8476
 
8462
8477
  // src/version.ts
8463
- var VERSION = "0.3.0";
8478
+ var VERSION = "0.3.1-staging.ci.34903740288.1";
8464
8479
  var DESKTOP_VERSION = process.env.AIDENT_DESKTOP_VERSION?.trim() || undefined;
8465
8480
  var DESKTOP_CHANNEL = parseDesktopChannel(process.env.AIDENT_DESKTOP_CHANNEL);
8466
8481
  function parseDesktopChannel(value) {
@@ -9353,7 +9368,7 @@ var LoadoutFavoriteSkillsUpdateSchema = objectType({
9353
9368
  syncRequired: booleanType()
9354
9369
  }).strict();
9355
9370
  function getLoadoutFavoriteSkillsStateToken(skills) {
9356
- const state = skills.map(({ name, artifactVersionId }) => ({ name, artifactVersionId })).sort((left, right) => left.name.localeCompare(right.name));
9371
+ const state = skills.map(({ name, artifactVersionId, deliveryRevision }) => ({ name, artifactVersionId, deliveryRevision })).sort((left, right) => left.name.localeCompare(right.name));
9357
9372
  return createHash3("sha256").update(JSON.stringify(state)).digest("hex");
9358
9373
  }
9359
9374
 
@@ -10090,7 +10105,7 @@ function isExpired(creds) {
10090
10105
 
10091
10106
  // src/loadoutFavoriteSkills.ts
10092
10107
  import { createHash as createHash5 } from "node:crypto";
10093
- import { lstat as lstat5, mkdir as mkdir8, readFile as readFile8, readlink, rename as rename4, rm as rm3, symlink as symlink3, writeFile as writeFile6 } from "node:fs/promises";
10108
+ import { cp, lstat as lstat5, mkdir as mkdir8, readFile as readFile8, readlink, rename as rename4, rm as rm3, symlink as symlink3, writeFile as writeFile6 } from "node:fs/promises";
10094
10109
  import { homedir as homedir5 } from "node:os";
10095
10110
  import path from "node:path";
10096
10111
 
@@ -10169,6 +10184,8 @@ function assertPackage(pkg) {
10169
10184
  }
10170
10185
  if (packageBytes > LOADOUT_SKILL_MAX_PACKAGE_BYTES)
10171
10186
  throw new Error(`Package is too large: ${pkg.name}`);
10187
+ if (pkg.bundle)
10188
+ AgentSkillBundleInstallDescriptorSchema.parse(pkg.bundle);
10172
10189
  }
10173
10190
  function quoteYaml(value) {
10174
10191
  return JSON.stringify(value);
@@ -10211,7 +10228,7 @@ async function readManifest(home, env) {
10211
10228
  throw new Error("Unsupported manifest");
10212
10229
  const harnessRoots = new Set(getHarnessHosts(home, env).map(({ root }) => path.join(root, "skills")));
10213
10230
  for (const skill of value.skills) {
10214
- if (!LOADOUT_SKILL_NAME_PATTERN.test(skill.name) || !isCanonicalUuid(skill.artifactVersionId) || skill.displayName !== undefined && typeof skill.displayName !== "string" || skill.summary !== undefined && typeof skill.summary !== "string" || !/^loadout-[a-z0-9-]+-[0-9a-f]{8}$/.test(skill.commandName) || skill.installPath !== path.join(getCanonicalRoot(home, env), skill.commandName) || skill.linkPaths.some((linkPath) => !harnessRoots.has(path.dirname(linkPath)) || path.basename(linkPath) !== skill.commandName)) {
10231
+ if (!LOADOUT_SKILL_NAME_PATTERN.test(skill.name) || !isCanonicalUuid(skill.artifactVersionId) || skill.displayName !== undefined && typeof skill.displayName !== "string" || skill.summary !== undefined && typeof skill.summary !== "string" || skill.deliveryRevision !== undefined && !/^[a-f0-9]{64}$/.test(skill.deliveryRevision) || !/^loadout-[a-z0-9-]+-[0-9a-f]{8}$/.test(skill.commandName) || skill.installPath !== path.join(getCanonicalRoot(home, env), skill.commandName) || skill.linkPaths.some((linkPath) => !harnessRoots.has(path.dirname(linkPath)) || path.basename(linkPath) !== skill.commandName)) {
10215
10232
  throw new Error("Invalid favorite Skills ownership manifest");
10216
10233
  }
10217
10234
  }
@@ -10245,7 +10262,11 @@ async function removeOwnedSkill(skill) {
10245
10262
  if (await pathExists3(skill.installPath))
10246
10263
  await rm3(skill.installPath, { recursive: true });
10247
10264
  }
10248
- async function reconcileLoadoutFavoriteSkills(payload, home = getHome(), env = process.env) {
10265
+ async function writeBundlePackage(directory, pkg, releaseDirectory) {
10266
+ await cp(releaseDirectory, directory, { recursive: true });
10267
+ await writeFile6(path.join(directory, LOADOUT_SKILL_ENTRYPOINT), entrypointContent(pkg, await readFile8(path.join(releaseDirectory, LOADOUT_SKILL_ENTRYPOINT), "utf8")));
10268
+ }
10269
+ async function reconcileLoadoutFavoriteSkills(payload, home = getHome(), env = process.env, injected = {}) {
10249
10270
  const manifest = await readManifest(home, env);
10250
10271
  const previousByName = new Map(manifest.skills.map((skill) => [skill.name, skill]));
10251
10272
  const desiredNames = new Set(payload.packages.map((pkg) => pkg.name));
@@ -10260,6 +10281,12 @@ async function reconcileLoadoutFavoriteSkills(payload, home = getHome(), env = p
10260
10281
  if (payload.unavailable.some((name) => desiredNames.has(name))) {
10261
10282
  throw new Error("A favorite Skill cannot be both available and unavailable");
10262
10283
  }
10284
+ const preparedBundles = new Map;
10285
+ for (const pkg of payload.packages) {
10286
+ if (!pkg.bundle)
10287
+ continue;
10288
+ preparedBundles.set(pkg.name, await (injected.prepareBundleRelease ?? prepareAgentSkillBundleRelease)(pkg.bundle, { home, env }));
10289
+ }
10263
10290
  const nextSkills = [];
10264
10291
  const result = {
10265
10292
  installed: [],
@@ -10301,21 +10328,26 @@ async function reconcileLoadoutFavoriteSkills(payload, home = getHome(), env = p
10301
10328
  continue;
10302
10329
  }
10303
10330
  const allLinksExist = (await Promise.all(linkPaths.map(pathExists3))).every(Boolean);
10304
- if (previous?.artifactVersionId === pkg.artifactVersionId && previous.displayName === pkg.displayName && previous.summary === pkg.summary && previous.installPath === installPath && previous.linkPaths.length === linkPaths.length && previous.linkPaths.every((linkPath) => linkPaths.includes(linkPath)) && await pathExists3(installPath) && allLinksExist) {
10331
+ if (previous?.artifactVersionId === pkg.artifactVersionId && previous.displayName === pkg.displayName && previous.summary === pkg.summary && previous.deliveryRevision === pkg.bundle?.artifactSha256 && previous.installPath === installPath && previous.linkPaths.length === linkPaths.length && previous.linkPaths.every((linkPath) => linkPaths.includes(linkPath)) && await pathExists3(installPath) && allLinksExist) {
10305
10332
  result.unchanged.push(pkg.name);
10306
10333
  nextSkills.push(previous);
10307
10334
  continue;
10308
10335
  }
10336
+ const preparedBundle = preparedBundles.get(pkg.name);
10309
10337
  const temporaryPath = `${installPath}.${process.pid}.tmp`;
10310
10338
  const backupPath = `${installPath}.${process.pid}.backup`;
10311
10339
  await mkdir8(getCanonicalRoot(home, env), { recursive: true });
10312
10340
  await rm3(temporaryPath, { recursive: true, force: true });
10313
10341
  await rm3(backupPath, { recursive: true, force: true });
10314
- await mkdir8(temporaryPath, { recursive: true });
10315
- for (const file of pkg.files) {
10316
- const destination = path.join(temporaryPath, ...file.path.split("/"));
10317
- await mkdir8(path.dirname(destination), { recursive: true });
10318
- await writeFile6(destination, file.path === LOADOUT_SKILL_ENTRYPOINT ? entrypointContent(pkg, file.content) : file.content);
10342
+ if (preparedBundle) {
10343
+ await writeBundlePackage(temporaryPath, pkg, preparedBundle.releaseDirectory);
10344
+ } else {
10345
+ await mkdir8(temporaryPath, { recursive: true });
10346
+ for (const file of pkg.files) {
10347
+ const destination = path.join(temporaryPath, ...file.path.split("/"));
10348
+ await mkdir8(path.dirname(destination), { recursive: true });
10349
+ await writeFile6(destination, file.path === LOADOUT_SKILL_ENTRYPOINT ? entrypointContent(pkg, file.content) : file.content);
10350
+ }
10319
10351
  }
10320
10352
  const createdLinkPaths = [];
10321
10353
  let backedUp = false;
@@ -10350,7 +10382,8 @@ async function reconcileLoadoutFavoriteSkills(payload, home = getHome(), env = p
10350
10382
  summary: pkg.summary,
10351
10383
  commandName: nextCommandName,
10352
10384
  installPath,
10353
- linkPaths
10385
+ linkPaths,
10386
+ ...pkg.bundle ? { deliveryRevision: pkg.bundle.artifactSha256 } : {}
10354
10387
  });
10355
10388
  (previous ? result.updated : result.installed).push(pkg.name);
10356
10389
  }
@@ -18683,7 +18716,7 @@ async function stageOnboardingSkill(home, artifact) {
18683
18716
 
18684
18717
  // src/onboarding/transaction.ts
18685
18718
  import { randomUUID as randomUUID8 } from "node:crypto";
18686
- import { cp, lstat as lstat11, mkdir as mkdir12, readdir as readdir6, readFile as readFile17, rename as rename8, rm as rm7, symlink as symlink5 } from "node:fs/promises";
18719
+ import { cp as cp2, lstat as lstat11, mkdir as mkdir12, readdir as readdir6, readFile as readFile17, rename as rename8, rm as rm7, symlink as symlink5 } from "node:fs/promises";
18687
18720
  import { dirname as dirname11, join as join16, relative as relative5 } from "node:path";
18688
18721
  async function applyOnboardingPlan(plan, options) {
18689
18722
  if (options.confirmationDigest !== plan.confirmationDigest)
@@ -18851,7 +18884,7 @@ async function applyChange(change, desiredContent, options) {
18851
18884
  if (change.action === "copy" /* Copy */) {
18852
18885
  const temporary = `${change.target}.${randomUUID8()}.tmp`;
18853
18886
  await mkdir12(dirname11(temporary), { recursive: true, mode: 448 });
18854
- await cp(options.skillSourceDirectory, temporary, { recursive: true, errorOnExist: true });
18887
+ await cp2(options.skillSourceDirectory, temporary, { recursive: true, errorOnExist: true });
18855
18888
  await rename8(temporary, change.target);
18856
18889
  return;
18857
18890
  }
@@ -19002,7 +19035,7 @@ class OnboardingService {
19002
19035
  }
19003
19036
  }
19004
19037
 
19005
- // ../web/shared/loadout/LoadoutOnboardingTelemetry.ts
19038
+ // ../web/shared/loadout/LoadoutOnboardingTelemetryContract.ts
19006
19039
  var LoadoutOnboardingPath;
19007
19040
  ((LoadoutOnboardingPath) => {
19008
19041
  LoadoutOnboardingPath["Unselected"] = "unselected";
@@ -19019,6 +19052,8 @@ var LoadoutOnboardingTelemetryStage;
19019
19052
  LoadoutOnboardingTelemetryStage["LoginCompleted"] = "login_completed";
19020
19053
  LoadoutOnboardingTelemetryStage["MethodSelected"] = "method_selected";
19021
19054
  LoadoutOnboardingTelemetryStage["NativeDownloadStarted"] = "native_download_started";
19055
+ LoadoutOnboardingTelemetryStage["PackageInstallStarted"] = "package_install_started";
19056
+ LoadoutOnboardingTelemetryStage["PackageInstallCompleted"] = "package_install_completed";
19022
19057
  LoadoutOnboardingTelemetryStage["DesktopStarted"] = "desktop_started";
19023
19058
  LoadoutOnboardingTelemetryStage["InstallationCompleted"] = "installation_completed";
19024
19059
  LoadoutOnboardingTelemetryStage["OnboardingStarted"] = "onboarding_started";
@@ -19055,6 +19090,8 @@ var LoadoutOnboardingLaunchSource;
19055
19090
  LoadoutOnboardingLaunchSource["Desktop"] = "desktop";
19056
19091
  LoadoutOnboardingLaunchSource["Web"] = "web";
19057
19092
  })(LoadoutOnboardingLaunchSource ||= {});
19093
+
19094
+ // ../web/shared/loadout/LoadoutOnboardingTelemetry.ts
19058
19095
  var LoadoutOnboardingClientFamily;
19059
19096
  ((LoadoutOnboardingClientFamily) => {
19060
19097
  LoadoutOnboardingClientFamily["Aident"] = "aident";