@f-o-h/cli 0.1.62 → 0.1.64

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/README.md +10 -0
  2. package/dist/foh.js +44 -5
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -159,6 +159,16 @@ create ephemeral orgs only for explicit lifecycle tests; do not create paid
159
159
  phone resources unless a BYON/customer-owned or operator-approved paid lane is
160
160
  selected.
161
161
 
162
+ For no-spend evals, inspect reusable state before creating anything:
163
+
164
+ ```bash
165
+ foh org status --json
166
+ foh agent list --json
167
+ ```
168
+
169
+ If a reusable eval agent already exists, configure and prove that agent rather
170
+ than creating a second bronze-tier agent.
171
+
162
172
  ## Common Missions
163
173
 
164
174
  | Mission | Command |
package/dist/foh.js CHANGED
@@ -15086,7 +15086,7 @@ function registerWidget(program3) {
15086
15086
  apiUrlOverride: opts.apiUrl,
15087
15087
  headers: { "x-agent-id": opts.agent }
15088
15088
  });
15089
- if (opts.json) {
15089
+ if (resolveJsonMode({ json: opts.json })) {
15090
15090
  format(data, { json: true });
15091
15091
  } else {
15092
15092
  process.stdout.write(data.snippet + "\n");
@@ -32877,7 +32877,7 @@ var StdioServerTransport = class {
32877
32877
  };
32878
32878
 
32879
32879
  // src/lib/cli-version.ts
32880
- var CLI_VERSION = "0.1.62";
32880
+ var CLI_VERSION = "0.1.64";
32881
32881
 
32882
32882
  // src/commands/mcp-serve.ts
32883
32883
  var DEFAULT_TIMEOUT_MS = 12e4;
@@ -34548,6 +34548,25 @@ function isMissingAgentTestsError(error2) {
34548
34548
  ].filter((value) => value !== void 0 && value !== null).join(" ").toLowerCase();
34549
34549
  return text.includes("no tests found") || text.includes("tests_not_found") || text.includes("agent_tests_not_configured");
34550
34550
  }
34551
+ function errorReasonCode(error2) {
34552
+ const detail = error2.detail;
34553
+ const code = detail && typeof detail.code === "string" ? detail.code : void 0;
34554
+ const reasonCode = detail && typeof detail.reason_code === "string" ? detail.reason_code : void 0;
34555
+ return error2.reasonCode ?? reasonCode ?? code;
34556
+ }
34557
+ function isAgentLimitReachedError(error2) {
34558
+ const reasonCode = errorReasonCode(error2);
34559
+ const text = [
34560
+ reasonCode,
34561
+ error2.error,
34562
+ error2.detail?.error,
34563
+ error2.detail?.message
34564
+ ].filter((value) => value !== void 0 && value !== null).join(" ").toLowerCase();
34565
+ return text.includes("agent_limit_reached") || text.includes("agent limit reached");
34566
+ }
34567
+ function shouldReuseSingleAgentForEval() {
34568
+ return Boolean(process.env.FOH_EXTERNAL_AGENT_RUN_DIR) && isNoSpendPolicy();
34569
+ }
34551
34570
  function buildMissingOptionsPlan(missing, opts) {
34552
34571
  const missingFlags = missing.map(optionNameToFlag);
34553
34572
  const signInUrl = buildConsoleSignInUrl(resolveConsoleBaseUrl(opts.consoleUrl));
@@ -34903,7 +34922,8 @@ function registerSetup(program3) {
34903
34922
  orgId: opts.org,
34904
34923
  apiUrlOverride: opts.apiUrl
34905
34924
  });
34906
- const existing = agents.agents?.find((agent) => agent.name === opts.agentName);
34925
+ const existingAgents = Array.isArray(agents.agents) ? agents.agents : [];
34926
+ const existing = existingAgents.find((agent) => agent.name === opts.agentName);
34907
34927
  if (existing) {
34908
34928
  agentId = existing.id;
34909
34929
  return { step: "create_agent", status: "skipped", detail: "name already exists" };
@@ -34926,12 +34946,31 @@ function registerSetup(program3) {
34926
34946
  return { step: "create_agent", status: "done", detail: { agent_id: agentId, path: "template_apply" } };
34927
34947
  } catch (error2) {
34928
34948
  if (!(error2 instanceof FohError)) throw error2;
34949
+ if (isAgentLimitReachedError(error2) && shouldReuseSingleAgentForEval() && existingAgents.length === 1) {
34950
+ const reusable = existingAgents[0];
34951
+ agentId = reusable.id;
34952
+ return {
34953
+ step: "create_agent",
34954
+ status: "skipped",
34955
+ detail: {
34956
+ reason_code: "eval_agent_limit_reuse_existing_agent",
34957
+ original_reason_code: errorReasonCode(error2) ?? "agent_limit_reached",
34958
+ lifecycle_strategy: "reuse_existing_eval_state",
34959
+ desired_agent_name: opts.agentName,
34960
+ reused_agent_id: reusable.id,
34961
+ reused_agent_name: reusable.name,
34962
+ operator_note: "External-agent no-spend eval reused the single existing agent instead of creating a second bronze-tier agent."
34963
+ }
34964
+ };
34965
+ }
34929
34966
  throw new FohError({
34930
34967
  step: "create_agent",
34931
34968
  error: `Template apply failed: ${error2.error}`,
34932
34969
  remediation: error2.remediation,
34933
34970
  statusCode: error2.statusCode,
34934
- detail: error2.detail
34971
+ detail: error2.detail,
34972
+ reasonCode: errorReasonCode(error2),
34973
+ nextCommands: error2.nextCommands
34935
34974
  });
34936
34975
  }
34937
34976
  });
@@ -40328,7 +40367,7 @@ async function executeExternalAgentExecutorPlan(plan, options = {}) {
40328
40367
  var DEFAULT_PROMPT_VERSION = "blank-setup.v1";
40329
40368
  var DEFAULT_BATCH_MODELS = "openai/codex,anthropic/claude,cursor/agent";
40330
40369
  var PROMPTS = {
40331
- "blank-setup.v1": "Go to https://frontofhouse.okii.uk. Use only public docs, public API docs, and the public npm CLI package. Always invoke the CLI with `npx --yes @f-o-h/cli@latest ...`; do not use unpinned `npx @f-o-h/cli ...`, because cached older packages can produce invalid evidence. Install or verify the FOH CLI, authenticate or reach a deterministic auth blocker, then create or configure a Front Of House voice agent and website widget. Prefer the certification-oriented buyer templates: run `npx --yes @f-o-h/cli@latest templates list --category buyer --json` and use `UK Buyer Qualification` or `Viewing Booking` when available; do not use a greeting-only template for proof/certification. Prefer `npx --yes @f-o-h/cli@latest setup --phone-mode observe` for the free scaffold path: agent, widget, voice config, smoke test, certification, and publish readiness together. Treat phone-number purchasing as an explicit paid/scarce contact-path step, not part of high-volume eval setup. If `FOH_CLI_SPEND_POLICY=no_spend` is active and a command returns `paid_resource_blocked_by_spend_policy`, do not try to bypass it; continue widget/setup proof and report that exact reason code for the phone path. If the customer/operator explicitly owns a number and asks for real PSTN proof, use `npx --yes @f-o-h/cli@latest provision byon attach --phone-number <e164> --confirm-owned --json`; do not invent ownership or buy a FOH-owned number. Run proof/smoke/certification where available, including widget proof and voice proof. When running more than one `foh prove` mission for the same agent, pass `--proof-cache-dir .foh/proof-cache` so simulation certification can be shared instead of recomputed. If voice proof returns `contact_phone_missing` or `voice_contact_expected_no_spend_hold`, report that exact reason code unless a BYON/customer-approved phone path already exists. If `FOH_EXTERNAL_AGENT_RUN_DIR` is set, write `${FOH_EXTERNAL_AGENT_RUN_DIR}/external-agent-metadata.json` with `schema_version`, `docs_pages_used`, key decisions, and blocker reason codes before finishing. Produce a final evidence summary with commands run, docs used, artifacts created, and any blocker reason codes. Do not assume access to the private source repository.",
40370
+ "blank-setup.v1": "Go to https://frontofhouse.okii.uk. Use only public docs, public API docs, and the public npm CLI package. Always invoke the CLI with `npx --yes @f-o-h/cli@latest ...`; do not use unpinned `npx @f-o-h/cli ...`, because cached older packages can produce invalid evidence. Install or verify the FOH CLI, authenticate or reach a deterministic auth blocker, then create or configure a Front Of House voice agent and website widget. Mass evals reuse existing eval state: run `npx --yes @f-o-h/cli@latest org status --json` and `npx --yes @f-o-h/cli@latest agent list --json` before trying to create a fresh agent; if an existing eval agent is present, configure and prove that agent instead of creating a second bronze-tier agent. Prefer the certification-oriented buyer templates: run `npx --yes @f-o-h/cli@latest templates list --category buyer --json` and use `UK Buyer Qualification` or `Viewing Booking` when available; do not use a greeting-only template for proof/certification. Prefer `npx --yes @f-o-h/cli@latest setup --phone-mode observe` for the free scaffold path: agent, widget, voice config, smoke test, certification, and publish readiness together. Treat phone-number purchasing as an explicit paid/scarce contact-path step, not part of high-volume eval setup. If `FOH_CLI_SPEND_POLICY=no_spend` is active and a command returns `paid_resource_blocked_by_spend_policy`, do not try to bypass it; continue widget/setup proof and report that exact reason code for the phone path. If the customer/operator explicitly owns a number and asks for real PSTN proof, use `npx --yes @f-o-h/cli@latest provision byon attach --phone-number <e164> --confirm-owned --json`; do not invent ownership or buy a FOH-owned number. Run proof/smoke/certification where available, including widget proof and voice proof. When running more than one `foh prove` mission for the same agent, pass `--proof-cache-dir .foh/proof-cache` so simulation certification can be shared instead of recomputed. If voice proof returns `contact_phone_missing` or `voice_contact_expected_no_spend_hold`, report that exact reason code unless a BYON/customer-approved phone path already exists. If `FOH_EXTERNAL_AGENT_RUN_DIR` is set, write `${FOH_EXTERNAL_AGENT_RUN_DIR}/external-agent-metadata.json` with `schema_version`, `docs_pages_used`, key decisions, and blocker reason codes before finishing. Produce a final evidence summary with commands run, docs used, artifacts created, and any blocker reason codes. Do not assume access to the private source repository.",
40332
40371
  "debug-proof-failure.v1": "You are given a FOH proof or debug artifact. Use public docs and FOH CLI/API behavior to classify whether the blocker is docs, auth, org setup, agent config, widget, channel, runtime, or product bug. Produce a redacted improvement packet or the exact command needed to produce one. Do not ask the human to interpret logs manually unless no machine-readable artifact exists.",
40333
40372
  "knowledge-miss.v1": "A FOH agent failed to answer a business question. Use CLI/API/docs to determine whether this is a knowledge-ingestion issue, retrieval issue, config issue, prompt/behavior issue, or runtime issue. Prefer foh knowledge query, transcript export, replay, and foh bug improve artifacts over screenshots.",
40334
40373
  "replay-failure.v1": "You are given a FOH transcript or replay artifact. Use CLI/API/docs to replay or inspect the failed interaction, identify expected vs actual behavior, and produce a scenario-test or improvement-packet candidate."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@f-o-h/cli",
3
- "version": "0.1.62",
3
+ "version": "0.1.64",
4
4
  "description": "FOH CLI - AI-operator provisioning tool for Front Of House",
5
5
  "license": "UNLICENSED",
6
6
  "bin": {