@backifydev/cli 0.3.16 → 0.3.18

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 (2) hide show
  1. package/dist/index.js +62 -21
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -35339,6 +35339,8 @@ function parseApplicationManifest(source) {
35339
35339
  throw new Error("Capabilities must be an explicit mapping");
35340
35340
  const capabilities = {};
35341
35341
  for (const [name2, settings] of Object.entries(value.capabilities)) {
35342
+ if (name2 === "audit")
35343
+ throw new Error("The audit capability was removed. Record application events with events.track and declare the events capability instead.");
35342
35344
  if (!Object.hasOwn(CAPABILITY_REGISTRY, name2))
35343
35345
  throw new Error("Unknown capability: " + name2);
35344
35346
  if (!object(settings))
@@ -35412,12 +35414,12 @@ function manifestDiagnostics(manifest, used, authentication) {
35412
35414
  // ../platform/dist/delivery.js
35413
35415
  var deliveryInstructions = `# Backify application delivery and prompt history
35414
35416
 
35415
- Instruction version: 11
35416
- Versioned guide: https://agent.backify.dev/v11/delivery.md
35417
+ Instruction version: 12
35418
+ Versioned guide: https://agent.backify.dev/v12/delivery.md
35417
35419
 
35418
35420
  ## Environment and documentation prerequisites
35419
35421
 
35420
- Before installation or connection, read https://agent.backify.dev/v11 for execution capability checks, required endpoints (including https://docs.backify.dev), native permission requests, verified retries and fallback guidance. Follow the current tool's supported approval mechanism; never bypass restrictions. Read relevant capability documentation before implementation. Local validation must not depend on cloud deployment.
35422
+ Before installation or connection, read https://agent.backify.dev/v12 for execution capability checks, required endpoints (including https://docs.backify.dev), native permission requests, verified retries and fallback guidance. Follow the current tool's supported approval mechanism; never bypass restrictions. Read relevant capability documentation before implementation. Local validation must not depend on cloud deployment.
35421
35423
 
35422
35424
  Before application implementation, all required setup checks and connected status must be verified OK. If any required check fails or remains unverified after supported recovery, stop setup and implementation; do not build a local website, minimal shell, placeholder, dependency-free fallback, or downloadable application archive. Report the blockers and recommend running the setup prompt in an AI coding tool such as Codex, Claude Code, or VS Code with GitHub Copilot agent mode, with terminal access, a persistent writable workspace, package installation, outbound HTTPS/DNS, and test execution enabled. Tool names alone do not guarantee readiness. Do not ask the application requirements question while setup is blocked. Later preview approval or deployment failures do not invalidate an already verified setup gate.
35423
35425
 
@@ -35437,7 +35439,7 @@ Initialize using App Id from the copied prompt and the current tool selection:
35437
35439
 
35438
35440
  npx @backifydev/cli@latest init --app <app-id> --agent <current-tool>
35439
35441
 
35440
- For a tool without a built-in preset, replace --agent <current-tool> with --instruction-file <relative-path>. Read BACKIFY.md and the instruction file used by the current AI coding tool before changing application code. Create or update only instruction files used by that tool; never create files for other coding tools. Use --agent for a built-in tool preset or --instruction-file <relative-path> for the current tool's native instruction file, as described in the setup guide. Initialization installs this workflow alongside the persistent SDK instructions. Follow https://agent.backify.dev/v11 for instruction version 11; use the guide matching backify.json in an existing application. Do not silently upgrade its managed instruction version or overwrite instructions outside the managed block.
35442
+ For a tool without a built-in preset, replace --agent <current-tool> with --instruction-file <relative-path>. Read BACKIFY.md and the instruction file used by the current AI coding tool before changing application code. Create or update only instruction files used by that tool; never create files for other coding tools. Use --agent for a built-in tool preset or --instruction-file <relative-path> for the current tool's native instruction file, as described in the setup guide. Initialization installs this workflow alongside the persistent SDK instructions. Follow https://agent.backify.dev/v12 for instruction version 12; use the guide matching backify.json in an existing application. Do not silently upgrade its managed instruction version or overwrite instructions outside the managed block.
35441
35443
 
35442
35444
  Run the following to discover the connected hosting target, repository, branch, reports, releases, and deployment failures:
35443
35445
 
@@ -35519,7 +35521,7 @@ These instructions are an explicit agent workflow, not a universal chat intercep
35519
35521
  `;
35520
35522
 
35521
35523
  // ../platform/dist/index.js
35522
- var INSTRUCTION_VERSION = 11;
35524
+ var INSTRUCTION_VERSION = 12;
35523
35525
  var SDK_PACKAGE = "@backifydev/sdk";
35524
35526
  var DOCS_URL = "https://docs.backify.dev";
35525
35527
  var MAIL_LIMITS = Object.freeze({
@@ -35550,12 +35552,11 @@ var CAPABILITIES = [
35550
35552
  capability("integrations", "integrations", "Approved, versioned API contracts and environment-scoped operation grants", true),
35551
35553
  capability("http", "http", "Governed outbound HTTP"),
35552
35554
  capability("ai", "ai", "Server-only ai.generate, ai.extract, ai.classify and ai.embed. Declare capabilities.ai in backify.yaml; optional models may use default, fast, smart or foundry- IDs from the application's location-aware AI catalog, within its allowed-model policy. Backify provisions isolated Azure Foundry model deployments and supplies scoped runtime credentials automatically. Do not add Azure/OpenAI credentials to application code."),
35553
- capability("audit", "audit", "Structured audit records"),
35554
35555
  capability("logs", "logs", "Structured application logging"),
35555
35556
  capability("config", "config", "Non-secret application configuration")
35556
35557
  ];
35557
35558
  var CAPABILITY_REGISTRY = Object.fromEntries(CAPABILITIES.map((x) => [x.name, x]));
35558
- var SDK_IMPORT_CAPABILITIES = { integrations: "integrations", defineJob: "jobs", database: "database", auth: "auth", db: "database", storage: "storage", functions: "functions", defineFunction: "functions", jobs: "jobs", mail: "mail", webhooks: "events", events: "events", secrets: "secrets", http: "http", ai: "ai", audit: "audit", logs: "logs", logging: "logs", config: "config" };
35559
+ var SDK_IMPORT_CAPABILITIES = { integrations: "integrations", defineJob: "jobs", database: "database", auth: "auth", db: "database", storage: "storage", functions: "functions", defineFunction: "functions", jobs: "jobs", mail: "mail", webhooks: "events", events: "events", secrets: "secrets", http: "http", ai: "ai", logs: "logs", logging: "logs", config: "config" };
35559
35560
  var MANAGED_START = "<!-- BACKIFY:MANAGED:START -->";
35560
35561
  var MANAGED_END = "<!-- BACKIFY:MANAGED:END -->";
35561
35562
  function managedInstructions() {
@@ -35578,8 +35579,8 @@ Before dependent setup operations, follow the environment checks and permission
35578
35579
  - Authentication and authorization: \`auth\`.
35579
35580
  - Persistent data and files: \`db\` and \`storage\`.
35580
35581
  - Server functions: \`defineFunction\`; background work and schedules: \`jobs\` and \`jobs.schedule\`.
35581
- - Events, outbound HTTP, and AI: \`events\`, \`http.fetch\`, and \`ai\`.
35582
- - Server-side secrets, configuration, audit, and logs: \`secrets\`, \`config\`, \`audit\`, and \`logs\`.
35582
+ - Events and event tracking, outbound HTTP, and AI: \`events\` (\`events.track\` records application events), \`http.fetch\`, and \`ai\`.
35583
+ - Server-side secrets, configuration, and logs: \`secrets\`, \`config\`, and \`logs\`.
35583
35584
 
35584
35585
  Verify API signatures against the installed SDK types and the relevant guide at ${DOCS_URL}/capabilities/. Never invent SDK methods. Use \`@backifydev/sdk/local\` for tests and local development; \`@backifydev/sdk/runtime\` is for runtime hosts, not application code.
35585
35586
 
@@ -35845,7 +35846,7 @@ import { hostname, platform, release, arch } from "node:os";
35845
35846
  // package.json
35846
35847
  var package_default = {
35847
35848
  name: "@backifydev/cli",
35848
- version: "0.3.16",
35849
+ version: "0.3.18",
35849
35850
  description: "Command-line setup and diagnostics for Backify applications",
35850
35851
  type: "module",
35851
35852
  bin: {
@@ -36692,7 +36693,7 @@ import { existsSync as existsSync14, mkdirSync as mkdirSync7, readFileSync as re
36692
36693
  import { dirname as dirname13, isAbsolute as isAbsolute14, join as join16, relative as relative8, resolve as resolve19 } from "node:path";
36693
36694
 
36694
36695
  // src/local-development.ts
36695
- import { context as context2 } from "esbuild";
36696
+ import { context as context2, formatMessagesSync } from "esbuild";
36696
36697
  import { spawn as spawn4 } from "node:child_process";
36697
36698
  import { randomBytes as randomBytes6, randomUUID as randomUUID10, createHash as createHash13 } from "node:crypto";
36698
36699
  import { existsSync as existsSync13, lstatSync as lstatSync15, mkdirSync as mkdirSync6, readFileSync as readFileSync21, realpathSync as realpathSync5, writeFileSync as writeFileSync11, unlinkSync as unlinkSync5 } from "node:fs";
@@ -37916,7 +37917,15 @@ function createHcrEventsProvider(options) {
37916
37917
  throw new Error("Invalid event binding name");
37917
37918
  const route = base.toString().replace(/\/$/, "") + "/v1/events/" + binding;
37918
37919
  const transport = options.fetch ?? globalThis.fetch;
37919
- const request = async (path, body, deliveries = false, metadata = false) => {
37920
+ const validateId = (id) => {
37921
+ if (typeof id !== "string" || !/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/.test(id) || id.length !== 36 || id === "00000000-0000-0000-0000-000000000000")
37922
+ throw new Error("Invalid event delivery id");
37923
+ };
37924
+ const validateReceipt = (receipt) => {
37925
+ if (typeof receipt !== "string" || !/^[a-f0-9]{64}$/.test(receipt) || receipt.length !== 64)
37926
+ throw new Error("Invalid event delivery receipt");
37927
+ };
37928
+ const request = async (path, body, deliveries = false, metadata = false, maximumBytes3 = metadata ? 131072 : 5242880) => {
37920
37929
  serverOnly();
37921
37930
  let token;
37922
37931
  try {
@@ -37963,7 +37972,7 @@ function createHcrEventsProvider(options) {
37963
37972
  if (part.done)
37964
37973
  break;
37965
37974
  length += part.value.length;
37966
- if (length > (metadata ? 131072 : 5242880))
37975
+ if (length > maximumBytes3)
37967
37976
  throw new Error("Event response exceeds its bound");
37968
37977
  chunks.push(part.value);
37969
37978
  }
@@ -38051,10 +38060,31 @@ function createHcrEventsProvider(options) {
38051
38060
  }
38052
38061
  return value;
38053
38062
  },
38054
- async complete(id, receipt, retry) {
38055
- if (typeof id !== "string" || !/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/.test(id) || id.length !== 36 || id === "00000000-0000-0000-0000-000000000000" || typeof receipt !== "string" || !/^[a-f0-9]{64}$/.test(receipt) || receipt.length !== 64 || retry !== void 0 && typeof retry !== "boolean")
38063
+ async complete(id, receipt, retry, completeOptions) {
38064
+ try {
38065
+ validateId(id);
38066
+ validateReceipt(receipt);
38067
+ } catch {
38068
+ throw new Error("Invalid event delivery receipt");
38069
+ }
38070
+ if (retry !== void 0 && typeof retry !== "boolean")
38056
38071
  throw new Error("Invalid event delivery receipt");
38057
- await request("/" + id + "/complete", { receipt, retry: retry ?? false });
38072
+ const delay = completeOptions?.retryDelaySeconds;
38073
+ if (delay !== void 0 && (!Number.isInteger(delay) || delay < 0 || delay > 3600 || !retry && delay !== 0))
38074
+ throw new Error("Invalid event retry delay");
38075
+ await request("/" + id + "/complete", { receipt, retry: retry ?? false, ...delay === void 0 ? {} : { retryDelaySeconds: delay } });
38076
+ },
38077
+ async renew(id, receipt) {
38078
+ validateId(id);
38079
+ validateReceipt(receipt);
38080
+ const value = await request("/" + id + "/renew", { receipt }, true, false, 1024);
38081
+ if (!value || typeof value !== "object" || Object.keys(value).join(",") !== "leaseExpiresAt" || typeof value.leaseExpiresAt !== "string" || !Number.isFinite(Date.parse(value.leaseExpiresAt)))
38082
+ throw new Error("HCR events returned an invalid lease");
38083
+ return value;
38084
+ },
38085
+ async replay(id) {
38086
+ validateId(id);
38087
+ await request("/" + id + "/replay", {});
38058
38088
  }
38059
38089
  };
38060
38090
  }
@@ -39896,7 +39926,7 @@ async function stopFrontend(child) {
39896
39926
  else child.kill("SIGTERM");
39897
39927
  });
39898
39928
  }
39899
- async function startLocalFrontend(prepared, port, backendUrl) {
39929
+ async function startLocalFrontend(prepared, port, backendUrl, onDiagnostic) {
39900
39930
  if (prepared.adapter === "static") return startLocalStaticFrontend(prepared.directory, port, backendUrl);
39901
39931
  const assignedPort = await allocateLocalPort(port);
39902
39932
  const url2 = "http://127.0.0.1:" + assignedPort;
@@ -39906,7 +39936,11 @@ async function startLocalFrontend(prepared, port, backendUrl) {
39906
39936
  const denied = [".env", ".env.*", "*.{crt,pem}", "**/.git/**", "**/.backify", "**/.backify/**", "**/.local-secrets", "**/.local-secrets/**", ...prepared.privateFiles.map((filename2) => filename2.replaceAll("\\", "/"))];
39907
39937
  const settings = { moduleUrl: pathToFileURL(prepared.modulePath).href, directory: prepared.directory, port: assignedPort, denied, privateFiles: prepared.privateFiles.map((filename2) => filename2.replaceAll("\\", "/")) };
39908
39938
  const launcher = "const settings=" + JSON.stringify(settings) + ";\n" + protectedFrontendSource;
39909
- const child = spawn3(process.execPath, ["--input-type=module", "--eval", launcher], { cwd: prepared.directory, windowsHide: true, stdio: ["ignore", 2, 2, "ipc"], env: environment });
39939
+ const child = spawn3(process.execPath, ["--input-type=module", "--eval", launcher], { cwd: prepared.directory, windowsHide: true, stdio: ["ignore", onDiagnostic ? "pipe" : 2, onDiagnostic ? "pipe" : 2, "ipc"], env: environment });
39940
+ if (onDiagnostic) {
39941
+ child.stdout?.on("data", (chunk) => onDiagnostic(chunk.toString()));
39942
+ child.stderr?.on("data", (chunk) => onDiagnostic(chunk.toString()));
39943
+ }
39910
39944
  let failed = false;
39911
39945
  child.on("error", () => {
39912
39946
  failed = true;
@@ -40399,7 +40433,7 @@ async function startLocalDevelopment(options = {}) {
40399
40433
  let frontend;
40400
40434
  try {
40401
40435
  if (mode === "full") services = await startLocalServices(root, manifest, { ...options, jobArtifacts, jobIdentityScope: jobWorker?.authTrust?.scope });
40402
- if (preparedFrontend) frontend = await startLocalFrontend(preparedFrontend, options.frontendPort, backendUrl);
40436
+ if (preparedFrontend) frontend = await startLocalFrontend(preparedFrontend, options.frontendPort, backendUrl, options.onDiagnostic);
40403
40437
  } catch (error2) {
40404
40438
  try {
40405
40439
  await services?.stop();
@@ -40455,7 +40489,11 @@ async function startLocalDevelopment(options = {}) {
40455
40489
  await stopChild(child);
40456
40490
  if (stopping) return;
40457
40491
  const version2 = createHash13("sha256").update(readFileSync21(outfile)).update(services?.configurationFingerprint ?? "lightweight").digest("hex");
40458
- const worker = spawn4(process.execPath, [outfile], { cwd: root, windowsHide: true, stdio: ["ignore", 2, 2, "ipc"], env: { ...process.env, ...identityEnvironment(), BACKIFY_LOCAL_SECRETS_IPC: "1", HOST: "127.0.0.1", ...backendPort === void 0 ? {} : { PORT: String(backendPort) }, BACKIFY_LOCAL_BACKEND_URL: backendUrl ?? "", BACKIFY_LOCAL_FRONTEND_URL: frontend?.url ?? "", BACKIFY_LOCAL_DATABASE_ENABLED: manifest.capabilities.database && manifest.capabilities.database.enabled !== false ? "1" : "0", BACKIFY_LOCAL_STORAGE_ENABLED: manifest.capabilities.storage && manifest.capabilities.storage.enabled !== false ? "1" : "0", BACKIFY_LOCAL_STORAGE_BUCKETS: JSON.stringify(manifest.capabilities.storage?.buckets?.map((bucket) => bucket.name) ?? (manifest.capabilities.storage ? ["default"] : [])), BACKIFY_LOCAL_TOKEN: token, BACKIFY_LOCAL_PORT: String(dashboardPort), BACKIFY_LOCAL_STATE: join15(directory2, "state.json"), BACKIFY_LOCAL_VERSION: version2, BACKIFY_LOCAL_HCR_URL: services?.runtimeUrl ?? "", BACKIFY_LOCAL_WORKLOAD_TOKEN_PATH: services?.tokenPath ?? "", BACKIFY_LOCAL_DATABASE: services ? services.database ? "postgres" : "disabled" : "document-emulator", BACKIFY_LOCAL_EVENTS: services?.events ? "postgres-events" : services ? "disabled" : "snapshot-emulator", BACKIFY_LOCAL_STORAGE: services ? services.storage ? "filesystem" : "disabled" : "snapshot-emulator" } });
40492
+ const worker = spawn4(process.execPath, [outfile], { cwd: root, windowsHide: true, stdio: ["ignore", options.onDiagnostic ? "pipe" : 2, options.onDiagnostic ? "pipe" : 2, "ipc"], env: { ...process.env, ...identityEnvironment(), BACKIFY_LOCAL_SECRETS_IPC: "1", HOST: "127.0.0.1", ...backendPort === void 0 ? {} : { PORT: String(backendPort) }, BACKIFY_LOCAL_BACKEND_URL: backendUrl ?? "", BACKIFY_LOCAL_FRONTEND_URL: frontend?.url ?? "", BACKIFY_LOCAL_DATABASE_ENABLED: manifest.capabilities.database && manifest.capabilities.database.enabled !== false ? "1" : "0", BACKIFY_LOCAL_STORAGE_ENABLED: manifest.capabilities.storage && manifest.capabilities.storage.enabled !== false ? "1" : "0", BACKIFY_LOCAL_STORAGE_BUCKETS: JSON.stringify(manifest.capabilities.storage?.buckets?.map((bucket) => bucket.name) ?? (manifest.capabilities.storage ? ["default"] : [])), BACKIFY_LOCAL_TOKEN: token, BACKIFY_LOCAL_PORT: String(dashboardPort), BACKIFY_LOCAL_STATE: join15(directory2, "state.json"), BACKIFY_LOCAL_VERSION: version2, BACKIFY_LOCAL_HCR_URL: services?.runtimeUrl ?? "", BACKIFY_LOCAL_WORKLOAD_TOKEN_PATH: services?.tokenPath ?? "", BACKIFY_LOCAL_DATABASE: services ? services.database ? "postgres" : "disabled" : "document-emulator", BACKIFY_LOCAL_EVENTS: services?.events ? "postgres-events" : services ? "disabled" : "snapshot-emulator", BACKIFY_LOCAL_STORAGE: services ? services.storage ? "filesystem" : "disabled" : "snapshot-emulator" } });
40493
+ if (options.onDiagnostic) {
40494
+ worker.stdout?.on("data", (chunk) => options.onDiagnostic(chunk.toString()));
40495
+ worker.stderr?.on("data", (chunk) => options.onDiagnostic(chunk.toString()));
40496
+ }
40459
40497
  child = worker;
40460
40498
  worker.send({ type: "local-secrets", secrets }, (error2) => {
40461
40499
  if (error2) {
@@ -40489,7 +40527,7 @@ async function startLocalDevelopment(options = {}) {
40489
40527
  });
40490
40528
  };
40491
40529
  try {
40492
- buildContext = await context2({ absWorkingDir: root, stdin: { contents: localWorkerSource(resolve18(root, manifest.runtime.entrypoint)), resolveDir: root, sourcefile: "backify-local-worker.ts", loader: "ts" }, bundle: true, platform: "node", format: "esm", target: "node20", outfile, sourcemap: true, banner: { js: 'import { createRequire as __backifyCreateRequire } from "node:module"; var require = __backifyCreateRequire(import.meta.url);' }, plugins: [{ name: "backify-local-lifecycle", setup(build3) {
40530
+ buildContext = await context2({ logLevel: options.onDiagnostic ? "silent" : void 0, absWorkingDir: root, stdin: { contents: localWorkerSource(resolve18(root, manifest.runtime.entrypoint)), resolveDir: root, sourcefile: "backify-local-worker.ts", loader: "ts" }, bundle: true, platform: "node", format: "esm", target: "node20", outfile, sourcemap: true, banner: { js: 'import { createRequire as __backifyCreateRequire } from "node:module"; var require = __backifyCreateRequire(import.meta.url);' }, plugins: [{ name: "backify-local-lifecycle", setup(build3) {
40493
40531
  build3.onLoad({ filter: /./, namespace: "file" }, (input) => {
40494
40532
  if (input.path !== resolve18(root, manifest.runtime.entrypoint)) return;
40495
40533
  try {
@@ -40502,6 +40540,9 @@ async function startLocalDevelopment(options = {}) {
40502
40540
  return { contents: readFileSync21(input.path, "utf8"), loader: input.path.endsWith(".tsx") ? "tsx" : /\.(ts|mts|cts)$/.test(input.path) ? "ts" : input.path.endsWith(".jsx") ? "jsx" : "js", watchFiles: [join15(root, "backify.yaml")] };
40503
40541
  });
40504
40542
  build3.onEnd((result) => {
40543
+ if (options.onDiagnostic) {
40544
+ for (const kind of ["error", "warning"]) for (const message of formatMessagesSync(kind === "error" ? result.errors : result.warnings, { kind, color: false })) options.onDiagnostic(message);
40545
+ }
40505
40546
  if (result.errors.length) rejectStartup(new Error("Local application build failed"));
40506
40547
  else if (!stopping) restarting = restarting.then(restart).catch(() => {
40507
40548
  rejectStartup(new Error("Local application restart failed"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backifydev/cli",
3
- "version": "0.3.16",
3
+ "version": "0.3.18",
4
4
  "description": "Command-line setup and diagnostics for Backify applications",
5
5
  "type": "module",
6
6
  "bin": {