@integrity-labs/xero-broker 0.1.1 → 0.1.2

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.js +30 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -20985,6 +20985,26 @@ var StdioServerTransport = class {
20985
20985
  }
20986
20986
  };
20987
20987
 
20988
+ // src/turn-initiator-marker.ts
20989
+ import { readFileSync } from "fs";
20990
+ var TURN_INITIATOR_MAX_AGE_MS = 5 * 60 * 1e3;
20991
+ function readTurnInitiator(maxAgeMs = TURN_INITIATOR_MAX_AGE_MS) {
20992
+ const file = process.env["AGT_TURN_INITIATOR_FILE"];
20993
+ if (!file) return null;
20994
+ try {
20995
+ const raw = readFileSync(file, "utf8");
20996
+ const m = JSON.parse(raw);
20997
+ if (typeof m.channel !== "string" || !m.channel) return null;
20998
+ if (typeof m.sender_id !== "string" || !m.sender_id) return null;
20999
+ if (typeof m.ts !== "number" || !Number.isFinite(m.ts)) return null;
21000
+ const age = Date.now() - m.ts;
21001
+ if (age < 0 || age > maxAgeMs) return null;
21002
+ return { channel: m.channel, sender_id: m.sender_id };
21003
+ } catch {
21004
+ return null;
21005
+ }
21006
+ }
21007
+
20988
21008
  // src/broker-client.ts
20989
21009
  function makeBrokerError(status, message, detail) {
20990
21010
  const err = new Error(message);
@@ -21103,8 +21123,16 @@ var XeroBrokerClient = class {
21103
21123
  if (!runId) {
21104
21124
  throw makeBrokerError(400, "XeroBrokerClient.requestApproval requires runId");
21105
21125
  }
21126
+ const turnInitiator = readTurnInitiator();
21127
+ const { turn_initiator: _ignoredForged, ...safeArgs } = args;
21128
+ void _ignoredForged;
21106
21129
  return this.request("POST", "/xero-broker/requests", {
21107
- body: { ...args, agent_id: agentId, run_id: runId }
21130
+ body: {
21131
+ ...safeArgs,
21132
+ agent_id: agentId,
21133
+ run_id: runId,
21134
+ ...turnInitiator ? { turn_initiator: turnInitiator } : {}
21135
+ }
21108
21136
  });
21109
21137
  }
21110
21138
  pollDecision(args) {
@@ -21179,7 +21207,7 @@ var awaitDecisionSchema = external_exports.object({
21179
21207
  // package.json
21180
21208
  var package_default = {
21181
21209
  name: "@integrity-labs/xero-broker",
21182
- version: "0.1.1",
21210
+ version: "0.1.2",
21183
21211
  description: "Xero Broker \u2014 MCP server that routes money- and ledger-touching Xero writes through approval-core (HITL). Sibling to cloud-broker / channel-broker; the only write path for an agent once the vendor xero-mcp-server's write tools are stripped. ENG-4922.",
21184
21212
  type: "module",
21185
21213
  bin: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integrity-labs/xero-broker",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Xero Broker — MCP server that routes money- and ledger-touching Xero writes through approval-core (HITL). Sibling to cloud-broker / channel-broker; the only write path for an agent once the vendor xero-mcp-server's write tools are stripped. ENG-4922.",
5
5
  "type": "module",
6
6
  "bin": {