@integrity-labs/agt-cli 0.28.1085 → 0.28.1086

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/bin/agt.js CHANGED
@@ -40,7 +40,7 @@ import {
40
40
  success,
41
41
  table,
42
42
  warn
43
- } from "../chunk-QJHOJMYV.js";
43
+ } from "../chunk-IGW25UXZ.js";
44
44
  import {
45
45
  getProjectDir,
46
46
  isSessionResumeDisabled,
@@ -5474,7 +5474,7 @@ import { execFileSync, execSync } from "child_process";
5474
5474
  import { existsSync as existsSync11, realpathSync as realpathSync2 } from "fs";
5475
5475
  import chalk18 from "chalk";
5476
5476
  import ora16 from "ora";
5477
- var cliVersion = true ? "0.28.1085" : "dev";
5477
+ var cliVersion = true ? "0.28.1086" : "dev";
5478
5478
  async function fetchLatestVersion() {
5479
5479
  const host2 = getHost();
5480
5480
  if (!host2) return null;
@@ -6734,7 +6734,7 @@ function handleError(err) {
6734
6734
  }
6735
6735
 
6736
6736
  // src/bin/agt.ts
6737
- var cliVersion2 = true ? "0.28.1085" : "dev";
6737
+ var cliVersion2 = true ? "0.28.1086" : "dev";
6738
6738
  var program = new Command();
6739
6739
  program.name("agt").description("Augmented CLI \u2014 agent provisioning and management").version(cliVersion2).option("--json", "Emit machine-readable JSON output (suppress spinners and colors)").option("--skip-update-check", "Skip the automatic update check on startup");
6740
6740
  program.hook("preAction", async (thisCommand, actionCommand) => {
@@ -7122,7 +7122,7 @@ function exchangeFailureKind(err) {
7122
7122
  }
7123
7123
 
7124
7124
  // src/lib/api-client.ts
7125
- var agtCliVersion = true ? "0.28.1085" : "dev";
7125
+ var agtCliVersion = true ? "0.28.1086" : "dev";
7126
7126
  var lastConfigHash = null;
7127
7127
  function setConfigHash(hash) {
7128
7128
  lastConfigHash = hash && hash.length > 0 ? hash : null;
@@ -12095,4 +12095,4 @@ export {
12095
12095
  managerInstallSystemUnitCommand,
12096
12096
  managerUninstallSystemUnitCommand
12097
12097
  };
12098
- //# sourceMappingURL=chunk-QJHOJMYV.js.map
12098
+ //# sourceMappingURL=chunk-IGW25UXZ.js.map
@@ -67,7 +67,7 @@ import {
67
67
  safeWriteJsonAtomic,
68
68
  setConfigHash,
69
69
  tripClass
70
- } from "../chunk-QJHOJMYV.js";
70
+ } from "../chunk-IGW25UXZ.js";
71
71
  import {
72
72
  getProjectDir as getProjectDir2,
73
73
  getReadyTasks,
@@ -14900,7 +14900,7 @@ var agentRestartTimezoneInputs = /* @__PURE__ */ new Map();
14900
14900
  var lastVersionCheckAt = 0;
14901
14901
  var VERSION_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
14902
14902
  var lastResponsivenessProbeAt = 0;
14903
- var agtCliVersion = true ? "0.28.1085" : "dev";
14903
+ var agtCliVersion = true ? "0.28.1086" : "dev";
14904
14904
  function resolveBrewPath(execFileSync3) {
14905
14905
  try {
14906
14906
  const out = execFileSync3("which", ["brew"], { timeout: 5e3 }).toString().trim();
package/dist/mcp/xero.js CHANGED
@@ -114339,9 +114339,17 @@ function ensureError(value) {
114339
114339
  }
114340
114340
 
114341
114341
  // src/helpers/pick-tenant-id.ts
114342
- function pickTenantId(tenants, desired) {
114342
+ var UNEXPANDED_PLACEHOLDER = /^\$\{[^}]*\}$/;
114343
+ function normaliseDesiredTenant(raw) {
114344
+ if (typeof raw !== "string") return void 0;
114345
+ const trimmed = raw.trim();
114346
+ if (trimmed === "" || UNEXPANDED_PLACEHOLDER.test(trimmed)) return void 0;
114347
+ return trimmed;
114348
+ }
114349
+ function pickTenantId(tenants, rawDesired) {
114350
+ const desired = normaliseDesiredTenant(rawDesired);
114343
114351
  if (!desired) {
114344
- return tenants[0]?.tenantId ?? "";
114352
+ return tenants.length === 1 ? tenants[0].tenantId : "";
114345
114353
  }
114346
114354
  const match = tenants.find((t) => t.tenantId === desired);
114347
114355
  if (!match) {
@@ -114363,6 +114371,49 @@ function currentCallTenant() {
114363
114371
  return store.getStore()?.tenantId;
114364
114372
  }
114365
114373
 
114374
+ // src/helpers/resolve-call-tenant.ts
114375
+ function describe(allowed) {
114376
+ return allowed.map((t) => t.tenantName ? `${t.tenantName} (${t.tenantId})` : t.tenantId).join(", ");
114377
+ }
114378
+ function resolveCallTenant(allowed, requested) {
114379
+ const wanted = typeof requested === "string" ? requested.trim() : "";
114380
+ if (allowed !== null && allowed.length === 0) {
114381
+ return {
114382
+ ok: false,
114383
+ message: "This agent has no Xero organisations selected, so no Xero call can run. Ask an admin to choose the organisations for this integration."
114384
+ };
114385
+ }
114386
+ if (allowed === null) {
114387
+ if (wanted) {
114388
+ return {
114389
+ ok: false,
114390
+ message: `tenant_id ${wanted} cannot be used: this Xero connection has no organisation list to check it against.`
114391
+ };
114392
+ }
114393
+ return { ok: true, tenantId: void 0 };
114394
+ }
114395
+ if (wanted) {
114396
+ if (allowed.some((t) => t.tenantId === wanted)) return { ok: true, tenantId: wanted };
114397
+ return {
114398
+ ok: false,
114399
+ message: `tenant_id ${wanted} is not one of the Xero organisations this agent may use: ${describe(allowed)}.`
114400
+ };
114401
+ }
114402
+ if (allowed.length === 1) return { ok: true, tenantId: allowed[0].tenantId };
114403
+ return {
114404
+ ok: false,
114405
+ message: `This agent can use more than one Xero organisation, so pass tenant_id. Allowed: ${describe(allowed)}. Call list-organisations to see them.`
114406
+ };
114407
+ }
114408
+ function fallbackAllowedTenants(pinnedTenantId, tokenTenants) {
114409
+ const fromToken = tokenTenants.filter((t) => typeof t?.tenantId === "string" && t.tenantId !== "").map((t) => ({ tenantId: t.tenantId, tenantName: typeof t.tenantName === "string" ? t.tenantName : null }));
114410
+ if (pinnedTenantId) {
114411
+ const match = fromToken.find((t) => t.tenantId === pinnedTenantId);
114412
+ return [{ tenantId: pinnedTenantId, tenantName: match?.tenantName ?? null }];
114413
+ }
114414
+ return fromToken;
114415
+ }
114416
+
114366
114417
  // src/clients/broker-credential-client.ts
114367
114418
  function makeError(status, message, needsReauth = false) {
114368
114419
  const err = new Error(message);
@@ -114541,6 +114592,15 @@ var MCPXeroClient = class extends import_xero_node.XeroClient {
114541
114592
  * despite the operator allowing nothing.
114542
114593
  */
114543
114594
  allowedTenants = null;
114595
+ /**
114596
+ * CS-1944 (Obi Wan on #6802): the organisations this token carries, for
114597
+ * clients that learn them WITHOUT going through xero-node's updateTenants()
114598
+ * (whose `tenants` is a read-only getter here). Custom Connections read
114599
+ * /connections directly, so without this the unpinned multi-organisation
114600
+ * fallback saw an empty list and refused every call, explicit tenant_id
114601
+ * included.
114602
+ */
114603
+ tokenTenants = null;
114544
114604
  constructor(config2) {
114545
114605
  super(config2);
114546
114606
  }
@@ -114561,9 +114621,7 @@ var MCPXeroClient = class extends import_xero_node.XeroClient {
114561
114621
  async getAllowedTenants() {
114562
114622
  await this.authenticate();
114563
114623
  if (this.allowedTenants !== null) return this.allowedTenants;
114564
- if (!this.pinnedTenantId) return [];
114565
- const match = (this.tenants ?? []).find((t) => t?.tenantId === this.pinnedTenantId);
114566
- return [{ tenantId: this.pinnedTenantId, tenantName: match?.tenantName ?? null }];
114624
+ return fallbackAllowedTenants(this.pinnedTenantId, this.tokenTenants ?? this.tenants ?? []);
114567
114625
  }
114568
114626
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
114569
114627
  async updateTenants(fullOrgDetails) {
@@ -114687,12 +114745,9 @@ var CustomConnectionsXeroClient = class extends MCPXeroClient {
114687
114745
  }
114688
114746
  }
114689
114747
  );
114690
- if (connectionsResponse.data && connectionsResponse.data.length > 0) {
114691
- this.tenantId = pickTenantId(
114692
- connectionsResponse.data,
114693
- process.env.XERO_TENANT_ID
114694
- );
114695
- }
114748
+ const connections = Array.isArray(connectionsResponse.data) ? connectionsResponse.data : [];
114749
+ this.tokenTenants = connections;
114750
+ this.tenantId = pickTenantId(connections, process.env.XERO_TENANT_ID);
114696
114751
  return response.data;
114697
114752
  }
114698
114753
  async authenticate() {
@@ -120917,12 +120972,14 @@ var ListOrganisationsTool = CreateXeroTool(
120917
120972
  isError: true
120918
120973
  };
120919
120974
  }
120975
+ const single = allowed.length === 1;
120920
120976
  const lines = allowed.map(
120921
- (t, i) => `${i + 1}. ${t.tenantName ?? "(name unknown)"} - tenant_id: ${t.tenantId}${i === 0 ? " (default)" : ""}`
120977
+ (t, i) => `${i + 1}. ${t.tenantName ?? "(name unknown)"} - tenant_id: ${t.tenantId}${single ? " (default)" : ""}`
120922
120978
  );
120979
+ const footer = single ? "" : "\nThere is no default: pass tenant_id on every Xero call to choose one of these.";
120923
120980
  return {
120924
120981
  content: [{ type: "text", text: `Xero organisations this agent may use:
120925
- ${lines.join("\n")}` }]
120982
+ ${lines.join("\n")}${footer}` }]
120926
120983
  };
120927
120984
  } catch (error2) {
120928
120985
  return {
@@ -120934,41 +120991,6 @@ ${lines.join("\n")}` }]
120934
120991
  );
120935
120992
  var list_organisations_tool_default = ListOrganisationsTool;
120936
120993
 
120937
- // src/helpers/resolve-call-tenant.ts
120938
- function describe(allowed) {
120939
- return allowed.map((t) => t.tenantName ? `${t.tenantName} (${t.tenantId})` : t.tenantId).join(", ");
120940
- }
120941
- function resolveCallTenant(allowed, requested) {
120942
- const wanted = typeof requested === "string" ? requested.trim() : "";
120943
- if (allowed !== null && allowed.length === 0) {
120944
- return {
120945
- ok: false,
120946
- message: "This agent has no Xero organisations selected, so no Xero call can run. Ask an admin to choose the organisations for this integration."
120947
- };
120948
- }
120949
- if (allowed === null) {
120950
- if (wanted) {
120951
- return {
120952
- ok: false,
120953
- message: `tenant_id ${wanted} cannot be used: this Xero connection has no organisation list to check it against.`
120954
- };
120955
- }
120956
- return { ok: true, tenantId: void 0 };
120957
- }
120958
- if (wanted) {
120959
- if (allowed.some((t) => t.tenantId === wanted)) return { ok: true, tenantId: wanted };
120960
- return {
120961
- ok: false,
120962
- message: `tenant_id ${wanted} is not one of the Xero organisations this agent may use: ${describe(allowed)}.`
120963
- };
120964
- }
120965
- if (allowed.length === 1) return { ok: true, tenantId: allowed[0].tenantId };
120966
- return {
120967
- ok: false,
120968
- message: `This agent can use more than one Xero organisation, so pass tenant_id. Allowed: ${describe(allowed)}. Call list-organisations to see them.`
120969
- };
120970
- }
120971
-
120972
120994
  // src/tools/tenant-scope.ts
120973
120995
  var TENANT_ID_ARG_DESCRIPTION = "Optional. The Xero organisation id (tenant) to use. Needed only when this agent can use more than one Xero organisation; call list-organisations to see them. Defaults to the only allowed organisation.";
120974
120996
  function errorResult(text) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integrity-labs/agt-cli",
3
- "version": "0.28.1085",
3
+ "version": "0.28.1086",
4
4
  "description": "Augmented Team CLI — agent provisioning and management",
5
5
  "type": "module",
6
6
  "engines": {