agentful 0.4.33 → 0.4.35

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 +147 -14
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -3044,7 +3044,7 @@ var VERSION, brand, useColor, wrap, paint, tuiDesign, sym, ui;
3044
3044
  var init_branding = __esm({
3045
3045
  "src/branding.ts"() {
3046
3046
  "use strict";
3047
- VERSION = "0.4.33" ? "0.4.33" : null.version;
3047
+ VERSION = "0.4.35" ? "0.4.35" : null.version;
3048
3048
  brand = {
3049
3049
  name: "agentful",
3050
3050
  // the command users type
@@ -6009,9 +6009,9 @@ var contract_default = {
6009
6009
  workaround: "Polling, or a third-party realtime service"
6010
6010
  },
6011
6011
  {
6012
- what: "Access protection",
6013
- why: "Actions are publicly invokable",
6014
- workaround: "Every action starts with a caller gate: ctx.user, or for machine callers a header token or a look-up at the provider"
6012
+ what: "Role or ownership checks by the platform",
6013
+ why: "The platform only refuses a call without a signed-in end user to an action whose file carries no marker (401 auth_required); an action with a marker is public, and which signed-in user may do what is not checked",
6014
+ workaround: "Every action starts with a caller gate: ctx.user and the action's own role or ownership check, or for machine callers a header token or a look-up at the provider"
6015
6015
  },
6016
6016
  {
6017
6017
  what: "Custom status codes, headers, cookies, redirects, HTML or binary responses",
@@ -9230,7 +9230,7 @@ Apart from a change I approved in step 2, do not modify project files.`
9230
9230
  },
9231
9231
  publish: {
9232
9232
  description: `${brand.displayName}: publish on a public subdomain`,
9233
- template: "Ask me for the subdomain if I did not provide one in $ARGUMENTS, then run `agentful publish <subdomain>` from the project root using the bash tool and report the public URL. " + NEEDS_A_PUSH
9233
+ template: "Ask me for the subdomain if I did not provide one in $ARGUMENTS, then run `agentful publish <subdomain>` from the project root using the bash tool and report the public URL. If the output lists findings of the security check, repeat them as they are; they are warnings, the app is published either way. " + NEEDS_A_PUSH
9234
9234
  },
9235
9235
  share: {
9236
9236
  description: `${brand.displayName}: make the live preview public (or private again)`,
@@ -9669,41 +9669,74 @@ async function fetchModelCatalog(auth, fallback) {
9669
9669
  }
9670
9670
 
9671
9671
  // src/lib/orgPolicy.ts
9672
+ var LEVELS = ["org", "department", "person"];
9673
+ function asLevel(value) {
9674
+ return LEVELS.includes(value) ? value : void 0;
9675
+ }
9672
9676
  async function fetchLocalProviderPolicy(auth) {
9673
9677
  try {
9674
9678
  const me = await request(`${PB_URL}/api/org/me`, { token: auth.pb_token, timeoutMs: 1e4 });
9675
9679
  if (!me?.has_org) return { hasOrg: false, allowedProviders: [] };
9676
9680
  const policy = me.effective_policy || {};
9681
+ const sources = policy.sources || {};
9682
+ const modelLevels = Array.isArray(sources.allowed_models) ? LEVELS.filter((l) => sources.allowed_models.includes(l)) : [];
9677
9683
  return {
9678
9684
  hasOrg: true,
9679
9685
  byokMode: policy.byok_mode || "allow",
9680
9686
  allowedProviders: Array.isArray(policy.allowed_byok_providers) ? policy.allowed_byok_providers : [],
9681
9687
  // /api/org/me reports the org as `org.id`; effective_policy carries no
9682
9688
  // org_id (orgs.pb.js GET /api/org/me). Befunde-Plan 2026-09-27, AP6.
9683
- orgId: me.org?.id || void 0
9689
+ orgId: me.org?.id || void 0,
9690
+ orgRole: typeof me.org_role === "string" ? me.org_role : void 0,
9691
+ departmentName: typeof me.department?.name === "string" && me.department.name ? me.department.name : void 0,
9692
+ modelLevels,
9693
+ byokLevel: asLevel(sources.byok_mode)
9684
9694
  };
9685
9695
  } catch {
9686
9696
  return { hasOrg: true, byokMode: "disabled", allowedProviders: [] };
9687
9697
  }
9688
9698
  }
9699
+ function levelName(policy, level) {
9700
+ if (level === "department") {
9701
+ return policy.departmentName ? `your department (${policy.departmentName})` : "your department";
9702
+ }
9703
+ if (level === "person") return "a rule set for you personally";
9704
+ return "your organization";
9705
+ }
9706
+ function capitalize(text) {
9707
+ return text.charAt(0).toUpperCase() + text.slice(1);
9708
+ }
9689
9709
  function decideLocalProviders(policy) {
9690
9710
  if (!policy.hasOrg) return { allowed: true, allowlist: [] };
9711
+ const who = capitalize(levelName(policy, policy.byokLevel));
9691
9712
  if (policy.byokMode === "disabled") {
9692
9713
  return {
9693
9714
  allowed: false,
9694
9715
  allowlist: [],
9695
- reason: "Your organization has disabled bring-your-own-key, which includes local providers."
9716
+ reason: `${who} has disabled bring-your-own-key, which includes local providers.`
9696
9717
  };
9697
9718
  }
9698
9719
  if (policy.byokMode === "provider_allowlist") {
9699
9720
  return {
9700
9721
  allowed: true,
9701
9722
  allowlist: policy.allowedProviders,
9702
- reason: `Your organization allows only these providers: ${policy.allowedProviders.join(", ") || "(none)"}`
9723
+ reason: `${who} allows only these providers: ${policy.allowedProviders.join(", ") || "(none)"}`
9703
9724
  };
9704
9725
  }
9705
9726
  return { allowed: true, allowlist: [] };
9706
9727
  }
9728
+ function policyRequestHint(policy) {
9729
+ if (!policy.hasOrg) return void 0;
9730
+ const page = `${APP_URL}/dashboard/organization`;
9731
+ if (policy.orgRole === "owner" || policy.orgRole === "admin") return `Change it under Settings \u2192 Organization: ${page}`;
9732
+ return `Ask for access: ${page}?request=1`;
9733
+ }
9734
+ function modelLimitNotice(policy) {
9735
+ if (!policy.hasOrg || !policy.modelLevels?.length) return void 0;
9736
+ const names = policy.modelLevels.map((l) => levelName(policy, l));
9737
+ const list = names.length === 1 ? names[0] : `${names.slice(0, -1).join(", ")} and ${names[names.length - 1]}`;
9738
+ return `Which models you can use is limited by ${list}.`;
9739
+ }
9707
9740
 
9708
9741
  // src/lib/localProviders.ts
9709
9742
  var import_node_fs16 = require("fs");
@@ -10386,6 +10419,12 @@ async function tuiCommand(opts = {}) {
10386
10419
  if (local.blocked.length) {
10387
10420
  ui.warn(`Local provider(s) not loaded: ${local.blocked.join(", ")} \u2014 ${local.policyReason || "blocked by policy"}`);
10388
10421
  }
10422
+ const modelNotice = modelLimitNotice(policy);
10423
+ if (modelNotice || local.blocked.length) {
10424
+ const hint = policyRequestHint(policy);
10425
+ if (modelNotice) ui.info(paint.dim(modelNotice));
10426
+ if (hint) ui.info(paint.dim(hint));
10427
+ }
10389
10428
  if (initialPin) {
10390
10429
  const variant = initialPin.variant || "provider default";
10391
10430
  ui.info(`Pinned model: ${paint.accent(initialPin.model)} \xB7 variant ${paint.accent(variant)} \xB7 source ${initialPin.modelSource}.`);
@@ -10524,9 +10563,80 @@ async function tuiCommand(opts = {}) {
10524
10563
 
10525
10564
  // src/commands/publish.ts
10526
10565
  init_branding();
10566
+
10567
+ // src/lib/publishCheck.ts
10568
+ var COVERAGE_LINE = "The check looks at the access rules of your collections, at actions anyone can call and at known keys in the built files. The rest of your code and a database of your own are not part of it.";
10569
+ var GAP_LINES = {
10570
+ build_not_checked: "There is no result for the built files yet. The next build creates one.",
10571
+ build_partly_read: "The built files were read only in part (very large or very many files).",
10572
+ builds_unreadable: "The result for the built files could not be read just now.",
10573
+ project_partly_read: "Collections or actions were read only in part."
10574
+ };
10575
+ function publishCheckReport(answer) {
10576
+ const report = { shown: false, critical: [], review: [], notes: [] };
10577
+ if (!answer || answer.enabled !== true) return report;
10578
+ report.shown = true;
10579
+ if (answer.state !== "checked") {
10580
+ report.notes.push("The security check could not run just now. The publish went through without it.");
10581
+ return report;
10582
+ }
10583
+ for (const finding of Array.isArray(answer.findings) ? answer.findings : []) {
10584
+ if (!finding || typeof finding.rule_id !== "string") continue;
10585
+ if (typeof finding.version_id === "string" && finding.live !== true) continue;
10586
+ const text = finding.message || finding.rule_id;
10587
+ (finding.level === "critical" ? report.critical : report.review).push(text);
10588
+ }
10589
+ for (const gap of Array.isArray(answer.gaps) ? answer.gaps : []) {
10590
+ if (GAP_LINES[gap]) report.notes.push(GAP_LINES[gap]);
10591
+ if (gap === "actions_not_understood") {
10592
+ const count2 = answer.counts?.actions_not_understood ?? 0;
10593
+ report.notes.push(`Actions the check does not understand and so did not judge: ${count2}`);
10594
+ }
10595
+ }
10596
+ return report;
10597
+ }
10598
+ function publishCheckJson(answer) {
10599
+ if (!answer || answer.enabled !== true) return null;
10600
+ const report = publishCheckReport(answer);
10601
+ return {
10602
+ state: answer.state ?? "failed",
10603
+ critical: report.critical.length,
10604
+ review: report.review.length,
10605
+ findings: (Array.isArray(answer.findings) ? answer.findings : []).filter((f) => f && typeof f.rule_id === "string" && !(typeof f.version_id === "string" && f.live !== true)),
10606
+ gaps: Array.isArray(answer.gaps) ? answer.gaps : [],
10607
+ coverage: COVERAGE_LINE
10608
+ };
10609
+ }
10610
+
10611
+ // src/commands/publish.ts
10527
10612
  var SUBDOMAIN_RE = /^[a-z0-9](?:[a-z0-9-]{1,61}[a-z0-9])?$/;
10528
- async function publishCommand(subdomain) {
10529
- console.log(banner());
10613
+ async function readPublishCheck(token, userId, projectId) {
10614
+ try {
10615
+ return await request(
10616
+ `${PUBLIC_API_URL}/api/workspaces/${encodeURIComponent(userId)}/${encodeURIComponent(projectId)}/publish-check?surface=cli`,
10617
+ { token, timeoutMs: 15e3 }
10618
+ );
10619
+ } catch {
10620
+ return null;
10621
+ }
10622
+ }
10623
+ function printPublishCheck(answer) {
10624
+ const report = publishCheckReport(answer);
10625
+ if (!report.shown) return;
10626
+ console.log("");
10627
+ const found = report.critical.length + report.review.length;
10628
+ if (found) ui.warn(`Security check: ${report.critical.length} critical, ${report.review.length} to review`);
10629
+ else ui.info("Security check: nothing reported");
10630
+ for (const line of report.critical) console.log(` critical ${line}`);
10631
+ for (const line of report.review) console.log(` review ${line}`);
10632
+ for (const line of report.notes) console.log(` note ${line}`);
10633
+ console.log(` ${COVERAGE_LINE}`);
10634
+ }
10635
+ async function publishCommand(subdomain, opts = {}) {
10636
+ const say = (line) => {
10637
+ if (!opts.json) ui.step(line);
10638
+ };
10639
+ if (!opts.json) console.log(banner());
10530
10640
  const auth = await ensureAuth();
10531
10641
  const project = requireProject();
10532
10642
  const name = subdomain.trim().toLowerCase();
@@ -10537,7 +10647,7 @@ async function publishCommand(subdomain) {
10537
10647
  "Subdomain must be 3-63 chars, lowercase letters/digits/hyphens, no leading/trailing hyphen."
10538
10648
  );
10539
10649
  }
10540
- ui.step(`Checking availability of ${name}.${PUBLISHED_DOMAIN}\u2026`);
10650
+ say(`Checking availability of ${name}.${PUBLISHED_DOMAIN}\u2026`);
10541
10651
  const check = await request(
10542
10652
  `${PUBLIC_API_URL}/api/subdomains/check/${name}`,
10543
10653
  { token: auth.pb_token }
@@ -10545,7 +10655,7 @@ async function publishCommand(subdomain) {
10545
10655
  if (check.available === false) {
10546
10656
  throw new ApiError(409, "subdomain_taken", check.message || `"${name}" is not available.`);
10547
10657
  }
10548
- ui.step("Publishing\u2026");
10658
+ say("Publishing\u2026");
10549
10659
  const res = await request(
10550
10660
  `${PUBLIC_API_URL}/api/publish`,
10551
10661
  {
@@ -10559,8 +10669,20 @@ async function publishCommand(subdomain) {
10559
10669
  if (res.success === false) {
10560
10670
  throw new ApiError(0, "publish_failed", res.message || "Publish failed.");
10561
10671
  }
10672
+ const publicUrl = res.public_url || `https://${name}.${PUBLISHED_DOMAIN}`;
10673
+ const securityCheck = await readPublishCheck(auth.pb_token, project.userId, project.projectId);
10674
+ if (opts.json) {
10675
+ process.stdout.write(JSON.stringify({
10676
+ published: true,
10677
+ public_url: publicUrl,
10678
+ subdomain: res.subdomain || name,
10679
+ publish_check: publishCheckJson(securityCheck)
10680
+ }, null, 2) + "\n");
10681
+ return;
10682
+ }
10562
10683
  console.log("");
10563
- ui.ok(`Published: ${ui.url(res.public_url || `https://${name}.${PUBLISHED_DOMAIN}`)}`);
10684
+ ui.ok(`Published: ${ui.url(publicUrl)}`);
10685
+ printPublishCheck(securityCheck);
10564
10686
  }
10565
10687
 
10566
10688
  // src/commands/share.ts
@@ -10811,6 +10933,11 @@ async function modelsCommand(opts) {
10811
10933
  for (const m of catalog.models) {
10812
10934
  console.log(` ${m.id === catalog.defaultModel ? paint.primary("\u25CF") : " "} ${m.name} ${paint.dim(m.id)}`);
10813
10935
  }
10936
+ const modelNotice = modelLimitNotice(policy);
10937
+ if (modelNotice) {
10938
+ ui.info(modelNotice);
10939
+ ui.info(policyRequestHint(policy));
10940
+ }
10814
10941
  const decision = decideLocalProviders(policy);
10815
10942
  const resolved = resolveLocalProviders(policy);
10816
10943
  const configured = Object.keys(readLocalProviders());
@@ -10861,6 +10988,8 @@ async function modelsCommand(opts) {
10861
10988
  console.log(paint.bold("Local providers") + paint.dim(" (your key, direct to the provider)"));
10862
10989
  if (!decision.allowed) {
10863
10990
  ui.warn(decision.reason || "Local providers are not permitted for your account.");
10991
+ const hint = policyRequestHint(policy);
10992
+ if (hint) ui.info(hint);
10864
10993
  } else if (!configured.length) {
10865
10994
  console.log(paint.dim(" none configured"));
10866
10995
  } else {
@@ -10871,6 +11000,10 @@ async function modelsCommand(opts) {
10871
11000
  console.log(` ${paint.warn("\u2716")} ${id} ${paint.dim("\u2014 blocked by your organization")}`);
10872
11001
  }
10873
11002
  if (resolved.policyReason) ui.info(resolved.policyReason);
11003
+ if (resolved.blocked.length) {
11004
+ const hint = policyRequestHint(policy);
11005
+ if (hint) ui.info(hint);
11006
+ }
10874
11007
  }
10875
11008
  if (decision.allowed) {
10876
11009
  if (opts.addLocal || !configured.length) {
@@ -10970,7 +11103,7 @@ program2.command("build-status").description("Show the cloud's record of the las
10970
11103
  program2.command("backend").description("Open this project's Backend tab (managed DB + server actions) in the browser").action(run(backendCommand));
10971
11104
  program2.command("open").description("Open the live preview in the browser").action(run(openCommand));
10972
11105
  program2.command("tui").description("Start the Agentful coding TUI with your Agentful account").option("-s, --session <id>", "resume a previous session").option("-m, --model <provider/model>", "pin an exact model from the final engine catalog").option("--variant <name>", "pin the provider-specific model variant (for example high)").action(run((_opts, cmd) => tuiCommand(tuiOptionsFrom(cmd))));
10973
- program2.command("publish <subdomain>").description("Publish the built project at https://<subdomain>.agentful.page").action(run(publishCommand));
11106
+ program2.command("publish <subdomain>").description("Publish the built project at https://<subdomain>.agentful.page").option("--json", "print the address and the security check as JSON (for scripts and agents)").action(run(publishCommand));
10974
11107
  program2.command("share").description("Make the live preview public (anyone with the link)").option("--private", "make the preview owner-only again").action(run((opts) => shareCommand(opts)));
10975
11108
  program2.command("pull").description("Download the cloud workspace into this directory").option("--force", "overwrite files in a non-empty directory").action(run((opts) => pullCommand(opts)));
10976
11109
  program2.command("models").description("List available models and manage local providers with your own key").option("--add-local", "create/show the local provider file to edit").option("--refresh", "refresh the engine model cache from models.dev").action(run((opts) => modelsCommand(opts)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentful",
3
- "version": "0.4.33",
3
+ "version": "0.4.35",
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",