agentful 0.4.33 → 0.4.34
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.
- package/dist/index.cjs +57 -7
- 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.
|
|
3047
|
+
VERSION = "0.4.34" ? "0.4.34" : 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: "
|
|
6013
|
-
why: "
|
|
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",
|
|
@@ -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:
|
|
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:
|
|
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}.`);
|
|
@@ -10811,6 +10850,11 @@ async function modelsCommand(opts) {
|
|
|
10811
10850
|
for (const m of catalog.models) {
|
|
10812
10851
|
console.log(` ${m.id === catalog.defaultModel ? paint.primary("\u25CF") : " "} ${m.name} ${paint.dim(m.id)}`);
|
|
10813
10852
|
}
|
|
10853
|
+
const modelNotice = modelLimitNotice(policy);
|
|
10854
|
+
if (modelNotice) {
|
|
10855
|
+
ui.info(modelNotice);
|
|
10856
|
+
ui.info(policyRequestHint(policy));
|
|
10857
|
+
}
|
|
10814
10858
|
const decision = decideLocalProviders(policy);
|
|
10815
10859
|
const resolved = resolveLocalProviders(policy);
|
|
10816
10860
|
const configured = Object.keys(readLocalProviders());
|
|
@@ -10861,6 +10905,8 @@ async function modelsCommand(opts) {
|
|
|
10861
10905
|
console.log(paint.bold("Local providers") + paint.dim(" (your key, direct to the provider)"));
|
|
10862
10906
|
if (!decision.allowed) {
|
|
10863
10907
|
ui.warn(decision.reason || "Local providers are not permitted for your account.");
|
|
10908
|
+
const hint = policyRequestHint(policy);
|
|
10909
|
+
if (hint) ui.info(hint);
|
|
10864
10910
|
} else if (!configured.length) {
|
|
10865
10911
|
console.log(paint.dim(" none configured"));
|
|
10866
10912
|
} else {
|
|
@@ -10871,6 +10917,10 @@ async function modelsCommand(opts) {
|
|
|
10871
10917
|
console.log(` ${paint.warn("\u2716")} ${id} ${paint.dim("\u2014 blocked by your organization")}`);
|
|
10872
10918
|
}
|
|
10873
10919
|
if (resolved.policyReason) ui.info(resolved.policyReason);
|
|
10920
|
+
if (resolved.blocked.length) {
|
|
10921
|
+
const hint = policyRequestHint(policy);
|
|
10922
|
+
if (hint) ui.info(hint);
|
|
10923
|
+
}
|
|
10874
10924
|
}
|
|
10875
10925
|
if (decision.allowed) {
|
|
10876
10926
|
if (opts.addLocal || !configured.length) {
|