agentful 0.3.7 → 0.3.9

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.cjs +54 -20
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -3044,7 +3044,7 @@ var VERSION, brand, useColor, wrap, paint, sym, ui;
3044
3044
  var init_branding = __esm({
3045
3045
  "src/branding.ts"() {
3046
3046
  "use strict";
3047
- VERSION = "0.3.7" ? "0.3.7" : null.version;
3047
+ VERSION = "0.3.9" ? "0.3.9" : null.version;
3048
3048
  brand = {
3049
3049
  name: "agentful",
3050
3050
  // the command users type
@@ -6753,6 +6753,10 @@ is fine \u2014 but then say clearly that \`agentful push\` cannot deploy it.
6753
6753
  vars (\`database.anon_key\`/\`publishable_key\` expanded as
6754
6754
  \`VITE_\`/\`PUBLIC_\`/\`NEXT_PUBLIC_\`). Never rely on \`.env*\` files reaching the
6755
6755
  cloud \u2014 the CLI and server both strip them.
6756
+ - \`.agentful/\` is local CLI control metadata and is excluded from the cloud
6757
+ build source. You may read \`.agentful/project.json\` while authoring, but app
6758
+ code must never import or fetch it. Copy the fixed project ID into an ordinary
6759
+ source constant when the managed backend client needs it.
6756
6760
 
6757
6761
  ## Supported frameworks (the cloud build table)
6758
6762
 
@@ -6778,7 +6782,9 @@ process, and never a script the user must run locally to produce the result.
6778
6782
 
6779
6783
  When the project uses the platform's managed backend, its ONLY API surface is:
6780
6784
 
6781
- - Base: \`/api/p/{projectId}/\` \u2014 projectId comes from \`.agentful/project.json\`.
6785
+ - Base: \`/api/p/{projectId}/\` \u2014 while authoring, read projectId from
6786
+ \`.agentful/project.json\` and materialize it in a normal app source constant;
6787
+ never import \`.agentful/\` from app code.
6782
6788
  - End-user auth: \`\u2026/auth/*\` (\`register\`, \`login\`, \`me\`, \`verify\`, \u2026).
6783
6789
  - Data CRUD: \`\u2026/data/{collection}\` and \`\u2026/data/{collection}/{docId}\`.
6784
6790
  - Managed Server Actions: \`POST \u2026/actions/{action-name}\` \u2014 and NOTHING else.
@@ -8084,28 +8090,47 @@ async function shareCommand(opts) {
8084
8090
  }
8085
8091
 
8086
8092
  // src/commands/pull.ts
8087
- var import_node_fs18 = require("fs");
8088
- var import_node_path21 = require("path");
8093
+ var import_node_fs19 = require("fs");
8094
+ var import_node_path22 = require("path");
8089
8095
  init_branding();
8090
8096
  init_branding();
8091
- function isProbablyBase64Binary(path) {
8092
- return /\.(png|jpe?g|gif|webp|ico|woff2?|ttf|otf|eot|pdf|zip|mp[34]|webm|avif)$/i.test(path);
8097
+
8098
+ // src/lib/pullFiles.ts
8099
+ var import_node_fs18 = require("fs");
8100
+ var import_node_path21 = require("path");
8101
+ var INLINE_BASE64_EXTENSIONS = /\.(?:png|jpe?g|gif|webp|avif|svg|ico|bmp|tiff?|woff2?|ttf|otf|eot|pdf|docx?|xlsx?|pptx?|zip|tar|gz|7z|rar|bz2|mp[34]|m4a|wav|ogg|avi|mov|mkv|flac|webm|exe|dll|so|dylib|bin|wasm)$/i;
8102
+ function inlineContent(value) {
8103
+ return typeof value === "object" && value !== null && "content" in value ? String(value.content) : String(value ?? "");
8093
8104
  }
8094
- function writeEntry(root, rel, value) {
8105
+ function writePulledWorkspaceEntry(root, rel, value) {
8095
8106
  const target = (0, import_node_path21.join)(root, rel);
8096
8107
  (0, import_node_fs18.mkdirSync)((0, import_node_path21.dirname)(target), { recursive: true });
8097
- const content = typeof value === "object" && value !== null && "content" in value ? String(value.content) : String(value ?? "");
8098
- if (isProbablyBase64Binary(rel)) {
8108
+ const content = inlineContent(value);
8109
+ if (INLINE_BASE64_EXTENSIONS.test(rel)) {
8099
8110
  (0, import_node_fs18.writeFileSync)(target, Buffer.from(content, "base64"));
8100
- } else {
8101
- (0, import_node_fs18.writeFileSync)(target, content, "utf8");
8111
+ return;
8102
8112
  }
8113
+ (0, import_node_fs18.writeFileSync)(target, content, "utf8");
8103
8114
  }
8115
+ function writePulledBackendDeclaration(root, declaration) {
8116
+ const target = (0, import_node_path21.join)(root, ".agentful", "backend.json");
8117
+ (0, import_node_fs18.mkdirSync)((0, import_node_path21.dirname)(target), { recursive: true });
8118
+ const {
8119
+ source: _source,
8120
+ received_at: _receivedAt,
8121
+ last_sync: _lastSync,
8122
+ ...portableDeclaration
8123
+ } = declaration;
8124
+ (0, import_node_fs18.writeFileSync)(target, `${JSON.stringify(portableDeclaration, null, 2)}
8125
+ `, "utf8");
8126
+ }
8127
+
8128
+ // src/commands/pull.ts
8104
8129
  async function pullCommand(opts) {
8105
8130
  console.log(banner());
8106
8131
  const auth = await ensureAuth();
8107
8132
  const project = requireProject();
8108
- const nonHidden = (0, import_node_fs18.readdirSync)(process.cwd()).filter((n) => n !== ".agentful" && !n.startsWith("."));
8133
+ const nonHidden = (0, import_node_fs19.readdirSync)(process.cwd()).filter((n) => n !== ".agentful" && !n.startsWith("."));
8109
8134
  if (nonHidden.length > 0 && !opts.force) {
8110
8135
  throw new ApiError(
8111
8136
  0,
@@ -8114,10 +8139,13 @@ async function pullCommand(opts) {
8114
8139
  );
8115
8140
  }
8116
8141
  ui.step("Fetching workspace\u2026");
8117
- const data = await request(
8118
- `${PB_URL}/api/workspaces/${project.userId}/${project.projectId}`,
8119
- { token: auth.pb_token, timeoutMs: 12e4 }
8120
- );
8142
+ const [data, backendState] = await Promise.all([
8143
+ request(
8144
+ `${PB_URL}/api/workspaces/${project.userId}/${project.projectId}`,
8145
+ { token: auth.pb_token, timeoutMs: 12e4 }
8146
+ ),
8147
+ fetchBackendSessionState(auth, project.userId, project.projectId)
8148
+ ]);
8121
8149
  let written = 0;
8122
8150
  if (data.mode === "presigned" && data.urls) {
8123
8151
  for (const [rel, url] of Object.entries(data.urls)) {
@@ -8129,20 +8157,26 @@ async function pullCommand(opts) {
8129
8157
  ui.warn(`Skipped ${rel} (HTTP ${resp.status})`);
8130
8158
  continue;
8131
8159
  }
8132
- const target = (0, import_node_path21.join)(process.cwd(), rel);
8133
- (0, import_node_fs18.mkdirSync)((0, import_node_path21.dirname)(target), { recursive: true });
8134
- (0, import_node_fs18.writeFileSync)(target, Buffer.from(await resp.arrayBuffer()));
8160
+ const target = (0, import_node_path22.join)(process.cwd(), rel);
8161
+ (0, import_node_fs19.mkdirSync)((0, import_node_path22.dirname)(target), { recursive: true });
8162
+ (0, import_node_fs19.writeFileSync)(target, Buffer.from(await resp.arrayBuffer()));
8135
8163
  written++;
8136
8164
  }
8137
8165
  } else if (data.files) {
8138
8166
  for (const [rel, value] of Object.entries(data.files)) {
8139
- writeEntry(process.cwd(), rel, value);
8167
+ writePulledWorkspaceEntry(process.cwd(), rel, value);
8140
8168
  written++;
8141
8169
  }
8142
8170
  } else {
8143
8171
  throw new ApiError(0, "empty_workspace", "The cloud workspace has no files yet.");
8144
8172
  }
8145
8173
  ui.ok(`Pulled ${written} files from the cloud workspace.`);
8174
+ if (backendState?.declaration) {
8175
+ writePulledBackendDeclaration(process.cwd(), backendState.declaration);
8176
+ ui.ok("Restored .agentful/backend.json from the platform declaration.");
8177
+ } else if (backendState === null) {
8178
+ ui.warn("Could not read the platform backend declaration; .agentful/backend.json was not restored.");
8179
+ }
8146
8180
  }
8147
8181
 
8148
8182
  // THIRD-PARTY-LICENSES.txt
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentful",
3
- "version": "0.3.7",
3
+ "version": "0.3.9",
4
4
  "description": "Agentful in your terminal — local development with push-to-cloud previews",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://agentful.dev",