@agentronics/sdk 0.1.2 → 0.2.0

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/init-only.js CHANGED
@@ -1,2 +1,2 @@
1
- export{P as init}from'./chunk-VWQY7QIL.js';import'./chunk-5BS4OAQA.js';//# sourceMappingURL=init-only.js.map
1
+ export{P as init}from'./chunk-7CJGV4LL.js';import'./chunk-LLD3Y2LZ.js';//# sourceMappingURL=init-only.js.map
2
2
  //# sourceMappingURL=init-only.js.map
package/dist/lite.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var c=()=>{if(typeof navigator>"u")return null;let t=navigator.modelContext;return t&&typeof t=="object"?t:null},o=async(t={})=>{let{pollMs:e=500}=t,n=Date.now();for(;;){let i=c();if(i)return l(i);if(Date.now()-n>=e)return null;await new Promise(s=>setTimeout(s,50));}},l=t=>({class:"webmcp",trust:"detected",confidence:1,vendor:t.vendor??t.client??null,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:{webmcp:true,toolCount:Array.isArray(t.tools)?t.tools.length:0}});var r="agtx_pk_",p="agtx_sk_",u=({publishableKey:t,siteId:e="default",debug:n=false})=>{if(t.startsWith(p))throw new Error("A secret key was passed to Agentronics lite init(). Browser code must use a publishable key (agtx_pk_*).");if(!t.startsWith(r))throw new Error(`Agentronics lite init() expected a key starting with "${r}".`);return Object.freeze({publishableKey:t,siteId:e,debug:n,detectWebMcp:o})},g="0.1.0-lite";exports.VERSION=g;exports.detectWebMcp=o;exports.init=u;//# sourceMappingURL=lite.cjs.map
1
+ 'use strict';var r="0.1.2";var l=()=>{if(typeof navigator>"u")return null;let t=navigator.modelContext;return t&&typeof t=="object"?t:null},o=async(t={})=>{let{pollMs:e=500}=t,n=Date.now();for(;;){let i=l();if(i)return p(i);if(Date.now()-n>=e)return null;await new Promise(c=>setTimeout(c,50));}},p=t=>({class:"webmcp",trust:"detected",confidence:1,vendor:t.vendor??t.client??null,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:r,signals:{webmcp:true,toolCount:Array.isArray(t.tools)?t.tools.length:0}});var s="agtx_pk_",a="agtx_sk_",b=({publishableKey:t,siteId:e="default",debug:n=false})=>{if(t.startsWith(a))throw new Error("A secret key was passed to Agentronics lite init(). Browser code must use a publishable key (agtx_pk_*).");if(!t.startsWith(s))throw new Error(`Agentronics lite init() expected a key starting with "${s}".`);return Object.freeze({publishableKey:t,siteId:e,debug:n,detectWebMcp:o})},y="0.1.0-lite";exports.VERSION=y;exports.detectWebMcp=o;exports.init=b;//# sourceMappingURL=lite.cjs.map
2
2
  //# sourceMappingURL=lite.cjs.map
package/dist/lite.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/detection/webmcp.ts","../src/lite.ts"],"names":["readModelContext","value","detectWebMcp","options","pollMs","start","ctx","buildIdentity","resolve","PUBLISHABLE_KEY_PREFIX","SECRET_KEY_PREFIX","init","publishableKey","siteId","debug","VERSION"],"mappings":"aAQA,IAAMA,EAAmB,IAA+B,CACtD,GAAI,OAAO,UAAc,GAAA,CAAa,OAAO,IAAA,CAC7C,IAAMC,EAAS,SAAA,CAA6D,YAAA,CAC5E,OAAOA,CAAAA,EAAS,OAAOA,GAAU,QAAA,CAAWA,CAAAA,CAAQ,IACtD,CAAA,CAUaC,EAAe,MAC1BC,CAAAA,CAA+B,EAAC,GACE,CAClC,GAAM,CAAE,MAAA,CAAAC,CAAAA,CAAS,GAAI,CAAA,CAAID,CAAAA,CACnBE,EAAQ,IAAA,CAAK,GAAA,GAEnB,OAAa,CACX,IAAMC,CAAAA,CAAMN,GAAiB,CAC7B,GAAIM,CAAAA,CAAK,OAAOC,EAAcD,CAAG,CAAA,CACjC,GAAI,IAAA,CAAK,KAAI,CAAID,CAAAA,EAASD,EAAQ,OAAO,IAAA,CACzC,MAAM,IAAI,OAAA,CAASI,CAAAA,EAAY,UAAA,CAAWA,EAAS,EAAE,CAAC,EACxD,CACF,EAEMD,CAAAA,CAAiBD,CAAAA,GAA0C,CAC/D,KAAA,CAAO,SACP,KAAA,CAAO,UAAA,CACP,WAAY,CAAA,CACZ,MAAA,CAAQA,EAAI,MAAA,EAAUA,CAAAA,CAAI,MAAA,EAAU,IAAA,CACpC,UAAW,OAAO,SAAA,CAAc,GAAA,CAAc,IAAA,CAAO,UAAU,SAAA,CAC/D,gBAAA,CAAkB,SAAA,CAClB,OAAA,CAAS,CACP,MAAA,CAAQ,IAAA,CACR,UAAW,KAAA,CAAM,OAAA,CAAQA,EAAI,KAAK,CAAA,CAAIA,CAAAA,CAAI,KAAA,CAAM,OAAS,CAC3D,CACF,CAAA,EC5CA,IAAMG,EAAyB,UAAA,CACzBC,CAAAA,CAAoB,UAAA,CAebC,CAAAA,CAAO,CAAC,CACnB,cAAA,CAAAC,EACA,MAAA,CAAAC,CAAAA,CAAS,UACT,KAAA,CAAAC,CAAAA,CAAQ,KACV,CAAA,GAA8C,CAC5C,GAAIF,CAAAA,CAAe,UAAA,CAAWF,CAAiB,EAC7C,MAAM,IAAI,KAAA,CACR,0GACF,EAEF,GAAI,CAACE,EAAe,UAAA,CAAWH,CAAsB,EACnD,MAAM,IAAI,KAAA,CAAM,CAAA,sDAAA,EAAyDA,CAAsB,CAAA,EAAA,CAAI,CAAA,CAGrG,OAAO,MAAA,CAAO,MAAA,CAAO,CACnB,cAAA,CAAAG,CAAAA,CACA,MAAA,CAAAC,CAAAA,CACA,MAAAC,CAAAA,CACA,YAAA,CAAAZ,CACF,CAAC,CACH,EAKaa,CAAAA,CAAU","file":"lite.cjs","sourcesContent":["import type { AgentIdentity } from '@agentronics/protocol'\n\ninterface ModelContextLike {\n client?: string\n vendor?: string\n tools?: unknown[]\n}\n\nconst readModelContext = (): ModelContextLike | null => {\n if (typeof navigator === 'undefined') return null\n const value = (navigator as unknown as { modelContext?: ModelContextLike }).modelContext\n return value && typeof value === 'object' ? value : null\n}\n\nexport interface DetectWebMcpOptions {\n /**\n * Some extensions inject `navigator.modelContext` after first paint. Poll for this many\n * milliseconds before giving up. Set to 0 to read synchronously and return immediately.\n */\n pollMs?: number\n}\n\nexport const detectWebMcp = async (\n options: DetectWebMcpOptions = {}\n): Promise<AgentIdentity | null> => {\n const { pollMs = 500 } = options\n const start = Date.now()\n\n while (true) {\n const ctx = readModelContext()\n if (ctx) return buildIdentity(ctx)\n if (Date.now() - start >= pollMs) return null\n await new Promise((resolve) => setTimeout(resolve, 50))\n }\n}\n\nconst buildIdentity = (ctx: ModelContextLike): AgentIdentity => ({\n class: 'webmcp',\n trust: 'detected',\n confidence: 1,\n vendor: ctx.vendor ?? ctx.client ?? null,\n userAgent: typeof navigator === 'undefined' ? null : navigator.userAgent,\n detectionVersion: '2026.04',\n signals: {\n webmcp: true,\n toolCount: Array.isArray(ctx.tools) ? ctx.tools.length : 0,\n },\n})\n","import type { AgentIdentity } from '@agentronics/protocol'\nimport { detectWebMcp, type DetectWebMcpOptions } from './detection/webmcp.js'\n\nconst PUBLISHABLE_KEY_PREFIX = 'agtx_pk_'\nconst SECRET_KEY_PREFIX = 'agtx_sk_'\n\nexport interface LiteInitOptions {\n publishableKey: string\n siteId?: string\n debug?: boolean\n}\n\nexport interface LiteAgentronicsClient {\n readonly publishableKey: string\n readonly siteId: string\n readonly debug: boolean\n detectWebMcp(options?: DetectWebMcpOptions): Promise<AgentIdentity | null>\n}\n\nexport const init = ({\n publishableKey,\n siteId = 'default',\n debug = false,\n}: LiteInitOptions): LiteAgentronicsClient => {\n if (publishableKey.startsWith(SECRET_KEY_PREFIX)) {\n throw new Error(\n 'A secret key was passed to Agentronics lite init(). Browser code must use a publishable key (agtx_pk_*).'\n )\n }\n if (!publishableKey.startsWith(PUBLISHABLE_KEY_PREFIX)) {\n throw new Error(`Agentronics lite init() expected a key starting with \"${PUBLISHABLE_KEY_PREFIX}\".`)\n }\n\n return Object.freeze({\n publishableKey,\n siteId,\n debug,\n detectWebMcp,\n })\n}\n\nexport { detectWebMcp } from './detection/webmcp.js'\nexport type { DetectWebMcpOptions } from './detection/webmcp.js'\n\nexport const VERSION = '0.1.0-lite'\n"]}
1
+ {"version":3,"sources":["../src/version.ts","../src/detection/webmcp.ts","../src/lite.ts"],"names":["SDK_VERSION","readModelContext","value","detectWebMcp","options","pollMs","start","ctx","buildIdentity","resolve","PUBLISHABLE_KEY_PREFIX","SECRET_KEY_PREFIX","init","publishableKey","siteId","debug","VERSION"],"mappings":"aAKO,IAAMA,EAAc,OAAA,CCI3B,IAAMC,CAAAA,CAAmB,IAA+B,CACtD,GAAI,OAAO,SAAA,CAAc,GAAA,CAAa,OAAO,IAAA,CAC7C,IAAMC,EAAS,SAAA,CAA6D,YAAA,CAC5E,OAAOA,CAAAA,EAAS,OAAOA,CAAAA,EAAU,QAAA,CAAWA,EAAQ,IACtD,CAAA,CAUaC,EAAe,MAC1BC,CAAAA,CAA+B,EAAC,GACE,CAClC,GAAM,CAAE,OAAAC,CAAAA,CAAS,GAAI,EAAID,CAAAA,CACnBE,CAAAA,CAAQ,KAAK,GAAA,EAAI,CAEvB,OAAa,CACX,IAAMC,CAAAA,CAAMN,CAAAA,EAAiB,CAC7B,GAAIM,EAAK,OAAOC,CAAAA,CAAcD,CAAG,CAAA,CACjC,GAAI,IAAA,CAAK,GAAA,GAAQD,CAAAA,EAASD,CAAAA,CAAQ,OAAO,IAAA,CACzC,MAAM,IAAI,OAAA,CAASI,GAAY,UAAA,CAAWA,CAAAA,CAAS,EAAE,CAAC,EACxD,CACF,CAAA,CAEMD,CAAAA,CAAiBD,CAAAA,GAA0C,CAC/D,MAAO,QAAA,CACP,KAAA,CAAO,WACP,UAAA,CAAY,CAAA,CACZ,OAAQA,CAAAA,CAAI,MAAA,EAAUA,CAAAA,CAAI,MAAA,EAAU,KACpC,SAAA,CAAW,OAAO,SAAA,CAAc,GAAA,CAAc,KAAO,SAAA,CAAU,SAAA,CAC/D,gBAAA,CAAkBP,CAAAA,CAClB,QAAS,CACP,MAAA,CAAQ,KACR,SAAA,CAAW,KAAA,CAAM,QAAQO,CAAAA,CAAI,KAAK,CAAA,CAAIA,CAAAA,CAAI,MAAM,MAAA,CAAS,CAC3D,CACF,CAAA,EC7CA,IAAMG,EAAyB,UAAA,CACzBC,CAAAA,CAAoB,UAAA,CAebC,CAAAA,CAAO,CAAC,CACnB,cAAA,CAAAC,EACA,MAAA,CAAAC,CAAAA,CAAS,UACT,KAAA,CAAAC,CAAAA,CAAQ,KACV,CAAA,GAA8C,CAC5C,GAAIF,CAAAA,CAAe,UAAA,CAAWF,CAAiB,EAC7C,MAAM,IAAI,KAAA,CACR,0GACF,EAEF,GAAI,CAACE,EAAe,UAAA,CAAWH,CAAsB,EACnD,MAAM,IAAI,KAAA,CAAM,CAAA,sDAAA,EAAyDA,CAAsB,CAAA,EAAA,CAAI,CAAA,CAGrG,OAAO,MAAA,CAAO,MAAA,CAAO,CACnB,cAAA,CAAAG,CAAAA,CACA,MAAA,CAAAC,CAAAA,CACA,MAAAC,CAAAA,CACA,YAAA,CAAAZ,CACF,CAAC,CACH,EAKaa,CAAAA,CAAU","file":"lite.cjs","sourcesContent":["// Single source of truth for the SDK build version, surfaced on every\n// AgentIdentity as `detectionVersion` so traces can be filtered by SDK\n// generation. tsup inlines a pkg-version replacement at build time;\n// the literal here is the dev/test fallback. Bump this when you cut a\n// new SDK release.\nexport const SDK_VERSION = '0.1.2'\n","import type { AgentIdentity } from '@agentronics/protocol'\nimport { SDK_VERSION } from \"../version.js\"\n\ninterface ModelContextLike {\n client?: string\n vendor?: string\n tools?: unknown[]\n}\n\nconst readModelContext = (): ModelContextLike | null => {\n if (typeof navigator === 'undefined') return null\n const value = (navigator as unknown as { modelContext?: ModelContextLike }).modelContext\n return value && typeof value === 'object' ? value : null\n}\n\nexport interface DetectWebMcpOptions {\n /**\n * Some extensions inject `navigator.modelContext` after first paint. Poll for this many\n * milliseconds before giving up. Set to 0 to read synchronously and return immediately.\n */\n pollMs?: number\n}\n\nexport const detectWebMcp = async (\n options: DetectWebMcpOptions = {}\n): Promise<AgentIdentity | null> => {\n const { pollMs = 500 } = options\n const start = Date.now()\n\n while (true) {\n const ctx = readModelContext()\n if (ctx) return buildIdentity(ctx)\n if (Date.now() - start >= pollMs) return null\n await new Promise((resolve) => setTimeout(resolve, 50))\n }\n}\n\nconst buildIdentity = (ctx: ModelContextLike): AgentIdentity => ({\n class: 'webmcp',\n trust: 'detected',\n confidence: 1,\n vendor: ctx.vendor ?? ctx.client ?? null,\n userAgent: typeof navigator === 'undefined' ? null : navigator.userAgent,\n detectionVersion: SDK_VERSION,\n signals: {\n webmcp: true,\n toolCount: Array.isArray(ctx.tools) ? ctx.tools.length : 0,\n },\n})\n","import type { AgentIdentity } from '@agentronics/protocol'\nimport { detectWebMcp, type DetectWebMcpOptions } from './detection/webmcp.js'\n\nconst PUBLISHABLE_KEY_PREFIX = 'agtx_pk_'\nconst SECRET_KEY_PREFIX = 'agtx_sk_'\n\nexport interface LiteInitOptions {\n publishableKey: string\n siteId?: string\n debug?: boolean\n}\n\nexport interface LiteAgentronicsClient {\n readonly publishableKey: string\n readonly siteId: string\n readonly debug: boolean\n detectWebMcp(options?: DetectWebMcpOptions): Promise<AgentIdentity | null>\n}\n\nexport const init = ({\n publishableKey,\n siteId = 'default',\n debug = false,\n}: LiteInitOptions): LiteAgentronicsClient => {\n if (publishableKey.startsWith(SECRET_KEY_PREFIX)) {\n throw new Error(\n 'A secret key was passed to Agentronics lite init(). Browser code must use a publishable key (agtx_pk_*).'\n )\n }\n if (!publishableKey.startsWith(PUBLISHABLE_KEY_PREFIX)) {\n throw new Error(`Agentronics lite init() expected a key starting with \"${PUBLISHABLE_KEY_PREFIX}\".`)\n }\n\n return Object.freeze({\n publishableKey,\n siteId,\n debug,\n detectWebMcp,\n })\n}\n\nexport { detectWebMcp } from './detection/webmcp.js'\nexport type { DetectWebMcpOptions } from './detection/webmcp.js'\n\nexport const VERSION = '0.1.0-lite'\n"]}
@@ -1,2 +1,2 @@
1
- var Agentronics=(function(exports){'use strict';var c=()=>{if(typeof navigator>"u")return null;let t=navigator.modelContext;return t&&typeof t=="object"?t:null},o=async(t={})=>{let{pollMs:e=500}=t,n=Date.now();for(;;){let i=c();if(i)return l(i);if(Date.now()-n>=e)return null;await new Promise(s=>setTimeout(s,50));}},l=t=>({class:"webmcp",trust:"detected",confidence:1,vendor:t.vendor??t.client??null,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:{webmcp:true,toolCount:Array.isArray(t.tools)?t.tools.length:0}});var r="agtx_pk_",p="agtx_sk_",u=({publishableKey:t,siteId:e="default",debug:n=false})=>{if(t.startsWith(p))throw new Error("A secret key was passed to Agentronics lite init(). Browser code must use a publishable key (agtx_pk_*).");if(!t.startsWith(r))throw new Error(`Agentronics lite init() expected a key starting with "${r}".`);return Object.freeze({publishableKey:t,siteId:e,debug:n,detectWebMcp:o})},g="0.1.0-lite";exports.VERSION=g;exports.detectWebMcp=o;exports.init=u;return exports;})({});//# sourceMappingURL=lite.global.js.map
1
+ var Agentronics=(function(exports){'use strict';var r="0.1.2";var l=()=>{if(typeof navigator>"u")return null;let t=navigator.modelContext;return t&&typeof t=="object"?t:null},o=async(t={})=>{let{pollMs:e=500}=t,n=Date.now();for(;;){let i=l();if(i)return p(i);if(Date.now()-n>=e)return null;await new Promise(c=>setTimeout(c,50));}},p=t=>({class:"webmcp",trust:"detected",confidence:1,vendor:t.vendor??t.client??null,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:r,signals:{webmcp:true,toolCount:Array.isArray(t.tools)?t.tools.length:0}});var s="agtx_pk_",a="agtx_sk_",b=({publishableKey:t,siteId:e="default",debug:n=false})=>{if(t.startsWith(a))throw new Error("A secret key was passed to Agentronics lite init(). Browser code must use a publishable key (agtx_pk_*).");if(!t.startsWith(s))throw new Error(`Agentronics lite init() expected a key starting with "${s}".`);return Object.freeze({publishableKey:t,siteId:e,debug:n,detectWebMcp:o})},y="0.1.0-lite";exports.VERSION=y;exports.detectWebMcp=o;exports.init=b;return exports;})({});//# sourceMappingURL=lite.global.js.map
2
2
  //# sourceMappingURL=lite.global.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/detection/webmcp.ts","../src/lite.ts"],"names":["readModelContext","value","detectWebMcp","options","pollMs","start","ctx","buildIdentity","resolve","PUBLISHABLE_KEY_PREFIX","SECRET_KEY_PREFIX","init","publishableKey","siteId","debug","VERSION"],"mappings":"gDAQA,IAAMA,EAAmB,IAA+B,CACtD,GAAI,OAAO,UAAc,GAAA,CAAa,OAAO,IAAA,CAC7C,IAAMC,EAAS,SAAA,CAA6D,YAAA,CAC5E,OAAOA,CAAAA,EAAS,OAAOA,GAAU,QAAA,CAAWA,CAAAA,CAAQ,IACtD,CAAA,CAUaC,EAAe,MAC1BC,CAAAA,CAA+B,EAAC,GACE,CAClC,GAAM,CAAE,MAAA,CAAAC,CAAAA,CAAS,GAAI,CAAA,CAAID,CAAAA,CACnBE,EAAQ,IAAA,CAAK,GAAA,GAEnB,OAAa,CACX,IAAMC,CAAAA,CAAMN,GAAiB,CAC7B,GAAIM,CAAAA,CAAK,OAAOC,EAAcD,CAAG,CAAA,CACjC,GAAI,IAAA,CAAK,KAAI,CAAID,CAAAA,EAASD,EAAQ,OAAO,IAAA,CACzC,MAAM,IAAI,OAAA,CAASI,CAAAA,EAAY,UAAA,CAAWA,EAAS,EAAE,CAAC,EACxD,CACF,EAEMD,CAAAA,CAAiBD,CAAAA,GAA0C,CAC/D,KAAA,CAAO,SACP,KAAA,CAAO,UAAA,CACP,WAAY,CAAA,CACZ,MAAA,CAAQA,EAAI,MAAA,EAAUA,CAAAA,CAAI,MAAA,EAAU,IAAA,CACpC,UAAW,OAAO,SAAA,CAAc,GAAA,CAAc,IAAA,CAAO,UAAU,SAAA,CAC/D,gBAAA,CAAkB,SAAA,CAClB,OAAA,CAAS,CACP,MAAA,CAAQ,IAAA,CACR,UAAW,KAAA,CAAM,OAAA,CAAQA,EAAI,KAAK,CAAA,CAAIA,CAAAA,CAAI,KAAA,CAAM,OAAS,CAC3D,CACF,CAAA,EC5CA,IAAMG,EAAyB,UAAA,CACzBC,CAAAA,CAAoB,UAAA,CAebC,CAAAA,CAAO,CAAC,CACnB,cAAA,CAAAC,EACA,MAAA,CAAAC,CAAAA,CAAS,UACT,KAAA,CAAAC,CAAAA,CAAQ,KACV,CAAA,GAA8C,CAC5C,GAAIF,CAAAA,CAAe,UAAA,CAAWF,CAAiB,EAC7C,MAAM,IAAI,KAAA,CACR,0GACF,EAEF,GAAI,CAACE,EAAe,UAAA,CAAWH,CAAsB,EACnD,MAAM,IAAI,KAAA,CAAM,CAAA,sDAAA,EAAyDA,CAAsB,CAAA,EAAA,CAAI,CAAA,CAGrG,OAAO,MAAA,CAAO,MAAA,CAAO,CACnB,cAAA,CAAAG,CAAAA,CACA,MAAA,CAAAC,CAAAA,CACA,MAAAC,CAAAA,CACA,YAAA,CAAAZ,CACF,CAAC,CACH,EAKaa,CAAAA,CAAU","file":"lite.global.js","sourcesContent":["import type { AgentIdentity } from '@agentronics/protocol'\n\ninterface ModelContextLike {\n client?: string\n vendor?: string\n tools?: unknown[]\n}\n\nconst readModelContext = (): ModelContextLike | null => {\n if (typeof navigator === 'undefined') return null\n const value = (navigator as unknown as { modelContext?: ModelContextLike }).modelContext\n return value && typeof value === 'object' ? value : null\n}\n\nexport interface DetectWebMcpOptions {\n /**\n * Some extensions inject `navigator.modelContext` after first paint. Poll for this many\n * milliseconds before giving up. Set to 0 to read synchronously and return immediately.\n */\n pollMs?: number\n}\n\nexport const detectWebMcp = async (\n options: DetectWebMcpOptions = {}\n): Promise<AgentIdentity | null> => {\n const { pollMs = 500 } = options\n const start = Date.now()\n\n while (true) {\n const ctx = readModelContext()\n if (ctx) return buildIdentity(ctx)\n if (Date.now() - start >= pollMs) return null\n await new Promise((resolve) => setTimeout(resolve, 50))\n }\n}\n\nconst buildIdentity = (ctx: ModelContextLike): AgentIdentity => ({\n class: 'webmcp',\n trust: 'detected',\n confidence: 1,\n vendor: ctx.vendor ?? ctx.client ?? null,\n userAgent: typeof navigator === 'undefined' ? null : navigator.userAgent,\n detectionVersion: '2026.04',\n signals: {\n webmcp: true,\n toolCount: Array.isArray(ctx.tools) ? ctx.tools.length : 0,\n },\n})\n","import type { AgentIdentity } from '@agentronics/protocol'\nimport { detectWebMcp, type DetectWebMcpOptions } from './detection/webmcp.js'\n\nconst PUBLISHABLE_KEY_PREFIX = 'agtx_pk_'\nconst SECRET_KEY_PREFIX = 'agtx_sk_'\n\nexport interface LiteInitOptions {\n publishableKey: string\n siteId?: string\n debug?: boolean\n}\n\nexport interface LiteAgentronicsClient {\n readonly publishableKey: string\n readonly siteId: string\n readonly debug: boolean\n detectWebMcp(options?: DetectWebMcpOptions): Promise<AgentIdentity | null>\n}\n\nexport const init = ({\n publishableKey,\n siteId = 'default',\n debug = false,\n}: LiteInitOptions): LiteAgentronicsClient => {\n if (publishableKey.startsWith(SECRET_KEY_PREFIX)) {\n throw new Error(\n 'A secret key was passed to Agentronics lite init(). Browser code must use a publishable key (agtx_pk_*).'\n )\n }\n if (!publishableKey.startsWith(PUBLISHABLE_KEY_PREFIX)) {\n throw new Error(`Agentronics lite init() expected a key starting with \"${PUBLISHABLE_KEY_PREFIX}\".`)\n }\n\n return Object.freeze({\n publishableKey,\n siteId,\n debug,\n detectWebMcp,\n })\n}\n\nexport { detectWebMcp } from './detection/webmcp.js'\nexport type { DetectWebMcpOptions } from './detection/webmcp.js'\n\nexport const VERSION = '0.1.0-lite'\n"]}
1
+ {"version":3,"sources":["../src/version.ts","../src/detection/webmcp.ts","../src/lite.ts"],"names":["SDK_VERSION","readModelContext","value","detectWebMcp","options","pollMs","start","ctx","buildIdentity","resolve","PUBLISHABLE_KEY_PREFIX","SECRET_KEY_PREFIX","init","publishableKey","siteId","debug","VERSION"],"mappings":"gDAKO,IAAMA,EAAc,OAAA,CCI3B,IAAMC,CAAAA,CAAmB,IAA+B,CACtD,GAAI,OAAO,SAAA,CAAc,GAAA,CAAa,OAAO,IAAA,CAC7C,IAAMC,EAAS,SAAA,CAA6D,YAAA,CAC5E,OAAOA,CAAAA,EAAS,OAAOA,CAAAA,EAAU,QAAA,CAAWA,EAAQ,IACtD,CAAA,CAUaC,EAAe,MAC1BC,CAAAA,CAA+B,EAAC,GACE,CAClC,GAAM,CAAE,OAAAC,CAAAA,CAAS,GAAI,EAAID,CAAAA,CACnBE,CAAAA,CAAQ,KAAK,GAAA,EAAI,CAEvB,OAAa,CACX,IAAMC,CAAAA,CAAMN,CAAAA,EAAiB,CAC7B,GAAIM,EAAK,OAAOC,CAAAA,CAAcD,CAAG,CAAA,CACjC,GAAI,IAAA,CAAK,GAAA,GAAQD,CAAAA,EAASD,CAAAA,CAAQ,OAAO,IAAA,CACzC,MAAM,IAAI,OAAA,CAASI,GAAY,UAAA,CAAWA,CAAAA,CAAS,EAAE,CAAC,EACxD,CACF,CAAA,CAEMD,CAAAA,CAAiBD,CAAAA,GAA0C,CAC/D,MAAO,QAAA,CACP,KAAA,CAAO,WACP,UAAA,CAAY,CAAA,CACZ,OAAQA,CAAAA,CAAI,MAAA,EAAUA,CAAAA,CAAI,MAAA,EAAU,KACpC,SAAA,CAAW,OAAO,SAAA,CAAc,GAAA,CAAc,KAAO,SAAA,CAAU,SAAA,CAC/D,gBAAA,CAAkBP,CAAAA,CAClB,QAAS,CACP,MAAA,CAAQ,KACR,SAAA,CAAW,KAAA,CAAM,QAAQO,CAAAA,CAAI,KAAK,CAAA,CAAIA,CAAAA,CAAI,MAAM,MAAA,CAAS,CAC3D,CACF,CAAA,EC7CA,IAAMG,EAAyB,UAAA,CACzBC,CAAAA,CAAoB,UAAA,CAebC,CAAAA,CAAO,CAAC,CACnB,cAAA,CAAAC,EACA,MAAA,CAAAC,CAAAA,CAAS,UACT,KAAA,CAAAC,CAAAA,CAAQ,KACV,CAAA,GAA8C,CAC5C,GAAIF,CAAAA,CAAe,UAAA,CAAWF,CAAiB,EAC7C,MAAM,IAAI,KAAA,CACR,0GACF,EAEF,GAAI,CAACE,EAAe,UAAA,CAAWH,CAAsB,EACnD,MAAM,IAAI,KAAA,CAAM,CAAA,sDAAA,EAAyDA,CAAsB,CAAA,EAAA,CAAI,CAAA,CAGrG,OAAO,MAAA,CAAO,MAAA,CAAO,CACnB,cAAA,CAAAG,CAAAA,CACA,MAAA,CAAAC,CAAAA,CACA,MAAAC,CAAAA,CACA,YAAA,CAAAZ,CACF,CAAC,CACH,EAKaa,CAAAA,CAAU","file":"lite.global.js","sourcesContent":["// Single source of truth for the SDK build version, surfaced on every\n// AgentIdentity as `detectionVersion` so traces can be filtered by SDK\n// generation. tsup inlines a pkg-version replacement at build time;\n// the literal here is the dev/test fallback. Bump this when you cut a\n// new SDK release.\nexport const SDK_VERSION = '0.1.2'\n","import type { AgentIdentity } from '@agentronics/protocol'\nimport { SDK_VERSION } from \"../version.js\"\n\ninterface ModelContextLike {\n client?: string\n vendor?: string\n tools?: unknown[]\n}\n\nconst readModelContext = (): ModelContextLike | null => {\n if (typeof navigator === 'undefined') return null\n const value = (navigator as unknown as { modelContext?: ModelContextLike }).modelContext\n return value && typeof value === 'object' ? value : null\n}\n\nexport interface DetectWebMcpOptions {\n /**\n * Some extensions inject `navigator.modelContext` after first paint. Poll for this many\n * milliseconds before giving up. Set to 0 to read synchronously and return immediately.\n */\n pollMs?: number\n}\n\nexport const detectWebMcp = async (\n options: DetectWebMcpOptions = {}\n): Promise<AgentIdentity | null> => {\n const { pollMs = 500 } = options\n const start = Date.now()\n\n while (true) {\n const ctx = readModelContext()\n if (ctx) return buildIdentity(ctx)\n if (Date.now() - start >= pollMs) return null\n await new Promise((resolve) => setTimeout(resolve, 50))\n }\n}\n\nconst buildIdentity = (ctx: ModelContextLike): AgentIdentity => ({\n class: 'webmcp',\n trust: 'detected',\n confidence: 1,\n vendor: ctx.vendor ?? ctx.client ?? null,\n userAgent: typeof navigator === 'undefined' ? null : navigator.userAgent,\n detectionVersion: SDK_VERSION,\n signals: {\n webmcp: true,\n toolCount: Array.isArray(ctx.tools) ? ctx.tools.length : 0,\n },\n})\n","import type { AgentIdentity } from '@agentronics/protocol'\nimport { detectWebMcp, type DetectWebMcpOptions } from './detection/webmcp.js'\n\nconst PUBLISHABLE_KEY_PREFIX = 'agtx_pk_'\nconst SECRET_KEY_PREFIX = 'agtx_sk_'\n\nexport interface LiteInitOptions {\n publishableKey: string\n siteId?: string\n debug?: boolean\n}\n\nexport interface LiteAgentronicsClient {\n readonly publishableKey: string\n readonly siteId: string\n readonly debug: boolean\n detectWebMcp(options?: DetectWebMcpOptions): Promise<AgentIdentity | null>\n}\n\nexport const init = ({\n publishableKey,\n siteId = 'default',\n debug = false,\n}: LiteInitOptions): LiteAgentronicsClient => {\n if (publishableKey.startsWith(SECRET_KEY_PREFIX)) {\n throw new Error(\n 'A secret key was passed to Agentronics lite init(). Browser code must use a publishable key (agtx_pk_*).'\n )\n }\n if (!publishableKey.startsWith(PUBLISHABLE_KEY_PREFIX)) {\n throw new Error(`Agentronics lite init() expected a key starting with \"${PUBLISHABLE_KEY_PREFIX}\".`)\n }\n\n return Object.freeze({\n publishableKey,\n siteId,\n debug,\n detectWebMcp,\n })\n}\n\nexport { detectWebMcp } from './detection/webmcp.js'\nexport type { DetectWebMcpOptions } from './detection/webmcp.js'\n\nexport const VERSION = '0.1.0-lite'\n"]}
package/dist/lite.js CHANGED
@@ -1,2 +1,2 @@
1
- import {a}from'./chunk-5BS4OAQA.js';export{a as detectWebMcp}from'./chunk-5BS4OAQA.js';var i="agtx_pk_",r="agtx_sk_",c=({publishableKey:t,siteId:n="default",debug:o=false})=>{if(t.startsWith(r))throw new Error("A secret key was passed to Agentronics lite init(). Browser code must use a publishable key (agtx_pk_*).");if(!t.startsWith(i))throw new Error(`Agentronics lite init() expected a key starting with "${i}".`);return Object.freeze({publishableKey:t,siteId:n,debug:o,detectWebMcp:a})},p="0.1.0-lite";export{p as VERSION,c as init};//# sourceMappingURL=lite.js.map
1
+ import {b}from'./chunk-LLD3Y2LZ.js';export{b as detectWebMcp}from'./chunk-LLD3Y2LZ.js';var i="agtx_pk_",r="agtx_sk_",c=({publishableKey:t,siteId:n="default",debug:o=false})=>{if(t.startsWith(r))throw new Error("A secret key was passed to Agentronics lite init(). Browser code must use a publishable key (agtx_pk_*).");if(!t.startsWith(i))throw new Error(`Agentronics lite init() expected a key starting with "${i}".`);return Object.freeze({publishableKey:t,siteId:n,debug:o,detectWebMcp:b})},p="0.1.0-lite";export{p as VERSION,c as init};//# sourceMappingURL=lite.js.map
2
2
  //# sourceMappingURL=lite.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentronics/sdk",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "description": "Browser SDK for the Agentronics governance layer.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -31,7 +31,7 @@
31
31
  "README.md"
32
32
  ],
33
33
  "dependencies": {
34
- "@agentronics/protocol": "0.1.1"
34
+ "@agentronics/protocol": "0.2.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@size-limit/preset-small-lib": "^11.1.6",
@@ -40,9 +40,9 @@
40
40
  "tsup": "^8.3.5",
41
41
  "typescript": "^5.7.2",
42
42
  "vitest": "^2.1.8",
43
- "@agentronics/tsup-config": "0.0.0",
43
+ "@agentronics/eslint-config": "0.0.0",
44
44
  "@agentronics/tsconfig": "0.0.0",
45
- "@agentronics/eslint-config": "0.0.0"
45
+ "@agentronics/tsup-config": "0.0.0"
46
46
  },
47
47
  "size-limit": [
48
48
  {
@@ -1,2 +0,0 @@
1
- var i=()=>{if(typeof navigator>"u")return null;let e=navigator.modelContext;return e&&typeof e=="object"?e:null},s=async(e={})=>{let{pollMs:n=500}=e,o=Date.now();for(;;){let t=i();if(t)return l(t);if(Date.now()-o>=n)return null;await new Promise(r=>setTimeout(r,50));}},l=e=>({class:"webmcp",trust:"detected",confidence:1,vendor:e.vendor??e.client??null,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:{webmcp:true,toolCount:Array.isArray(e.tools)?e.tools.length:0}});export{s as a};//# sourceMappingURL=chunk-5BS4OAQA.js.map
2
- //# sourceMappingURL=chunk-5BS4OAQA.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/detection/webmcp.ts"],"names":["readModelContext","value","detectWebMcp","options","pollMs","start","ctx","buildIdentity","resolve"],"mappings":"AAQA,IAAMA,CAAAA,CAAmB,IAA+B,CACtD,GAAI,OAAO,SAAA,CAAc,GAAA,CAAa,OAAO,IAAA,CAC7C,IAAMC,CAAAA,CAAS,UAA6D,YAAA,CAC5E,OAAOA,CAAAA,EAAS,OAAOA,CAAAA,EAAU,QAAA,CAAWA,EAAQ,IACtD,CAAA,CAUaC,CAAAA,CAAe,MAC1BC,CAAAA,CAA+B,KACG,CAClC,GAAM,CAAE,MAAA,CAAAC,CAAAA,CAAS,GAAI,EAAID,CAAAA,CACnBE,CAAAA,CAAQ,IAAA,CAAK,GAAA,EAAI,CAEvB,OAAa,CACX,IAAMC,CAAAA,CAAMN,CAAAA,EAAiB,CAC7B,GAAIM,CAAAA,CAAK,OAAOC,CAAAA,CAAcD,CAAG,CAAA,CACjC,GAAI,IAAA,CAAK,GAAA,GAAQD,CAAAA,EAASD,CAAAA,CAAQ,OAAO,IAAA,CACzC,MAAM,IAAI,QAASI,CAAAA,EAAY,UAAA,CAAWA,CAAAA,CAAS,EAAE,CAAC,EACxD,CACF,CAAA,CAEMD,CAAAA,CAAiBD,CAAAA,GAA0C,CAC/D,KAAA,CAAO,QAAA,CACP,MAAO,UAAA,CACP,UAAA,CAAY,CAAA,CACZ,MAAA,CAAQA,CAAAA,CAAI,MAAA,EAAUA,EAAI,MAAA,EAAU,IAAA,CACpC,SAAA,CAAW,OAAO,SAAA,CAAc,GAAA,CAAc,KAAO,SAAA,CAAU,SAAA,CAC/D,gBAAA,CAAkB,SAAA,CAClB,OAAA,CAAS,CACP,OAAQ,IAAA,CACR,SAAA,CAAW,KAAA,CAAM,OAAA,CAAQA,CAAAA,CAAI,KAAK,EAAIA,CAAAA,CAAI,KAAA,CAAM,MAAA,CAAS,CAC3D,CACF,CAAA","file":"chunk-5BS4OAQA.js","sourcesContent":["import type { AgentIdentity } from '@agentronics/protocol'\n\ninterface ModelContextLike {\n client?: string\n vendor?: string\n tools?: unknown[]\n}\n\nconst readModelContext = (): ModelContextLike | null => {\n if (typeof navigator === 'undefined') return null\n const value = (navigator as unknown as { modelContext?: ModelContextLike }).modelContext\n return value && typeof value === 'object' ? value : null\n}\n\nexport interface DetectWebMcpOptions {\n /**\n * Some extensions inject `navigator.modelContext` after first paint. Poll for this many\n * milliseconds before giving up. Set to 0 to read synchronously and return immediately.\n */\n pollMs?: number\n}\n\nexport const detectWebMcp = async (\n options: DetectWebMcpOptions = {}\n): Promise<AgentIdentity | null> => {\n const { pollMs = 500 } = options\n const start = Date.now()\n\n while (true) {\n const ctx = readModelContext()\n if (ctx) return buildIdentity(ctx)\n if (Date.now() - start >= pollMs) return null\n await new Promise((resolve) => setTimeout(resolve, 50))\n }\n}\n\nconst buildIdentity = (ctx: ModelContextLike): AgentIdentity => ({\n class: 'webmcp',\n trust: 'detected',\n confidence: 1,\n vendor: ctx.vendor ?? ctx.client ?? null,\n userAgent: typeof navigator === 'undefined' ? null : navigator.userAgent,\n detectionVersion: '2026.04',\n signals: {\n webmcp: true,\n toolCount: Array.isArray(ctx.tools) ? ctx.tools.length : 0,\n },\n})\n"]}
@@ -1,17 +0,0 @@
1
- import {a}from'./chunk-5BS4OAQA.js';import {AgentClass,isHigherTrust,IdentityClaim,AgentronicsError,PolicyRule,MemoryEntry,SiteMemory,SITE_MEMORY_DEFAULT,TraceEvent,classifyApiKey,PUBLISHABLE_KEY_PREFIX,TRUST_RANK,SiteMemoryPageContext}from'@agentronics/protocol';var ct=[/HeadlessChrome/i,/Headless/i,/PhantomJS/i,/SlimerJS/i],lt=()=>({hit:(typeof navigator<"u"&&navigator.webdriver)===true,weight:.6,detail:"navigator.webdriver === true"}),ut=()=>{if(typeof window>"u")return {hit:false,weight:.5};let e=Object.keys(window).filter(t=>t.startsWith("cdc_"));return {hit:e.length>0,weight:.5,detail:`window.${e[0]??"cdc_*"}`}},dt=()=>{if(typeof navigator>"u"||!navigator.plugins)return {hit:false,weight:.2};let e=/Win|Mac|Linux/.test(navigator.userAgent??""),t=navigator.plugins.length===0;return {hit:e&&t,weight:.2,detail:"desktop UA with no plugins"}},pt=()=>{if(typeof navigator>"u")return {hit:false,weight:.7};let e=navigator.userAgent??"",t=ct.some(n=>n.test(e));return t?{hit:t,weight:.7,detail:`headless UA: ${e}`}:{hit:t,weight:.7}},gt=()=>{if(typeof navigator>"u")return {hit:false,weight:.15};let e=navigator.languages;return {hit:!e||e.length===0,weight:.15,detail:"navigator.languages empty"}},mt=()=>{if(typeof navigator>"u")return {hit:false,weight:.1};let e="chrome"in window,t=navigator.userAgent??"";return {hit:/Chrome\//.test(t)&&!/Edg\//.test(t)&&!e,weight:.2,detail:"Chrome UA without window.chrome"}},yt={webdriver:lt,chromedriver:ut,headlessUa:pt,languages:gt,permissions:mt,plugins:dt},C=(e={})=>{let{threshold:t=.4}=e,n={},r=0,o=0;for(let[s,a]of Object.entries(yt)){let l=a();r+=l.weight,n[s]={hit:l.hit,weight:l.weight,detail:l.detail},l.hit&&(o+=l.weight);}let i=r===0?0:o/r;return i<t?null:{class:"dom",trust:"detected",confidence:i,vendor:null,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:n}};var ae=()=>[{id:"webmcp.model-context",status:"stable",detect:()=>a({pollMs:0})},{id:"dom.automation-heuristics",status:"beta",detect:()=>C()}],U=(e=ae())=>{let t=new Map(e.map(n=>[n.id,n]));return {register(n){t.set(n.id,n);},list(n){let r=[...t.values()];return n?r.filter(o=>o.status===n):r},async detectAll(n=false){for(let r of t.values()){if(r.status==="research"&&!n)continue;let o=await r.detect();if(o)return o}return null}}};var ht=e=>{let t=AgentClass.parse(e.class),n=e.verificationToken?"verified":"declared";return {class:t,trust:n,confidence:1,vendor:e.vendor,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:{declared:true,hasVerificationToken:!!e.verificationToken}}};var vt=({gatewayUrl:e,fetcher:t=fetch})=>{let n=null,r=[];return {snapshot(){return [...r]},async sync(){let o=await t(`${e.replace(/\/$/,"")}/v1/detector-signatures`,{headers:n?{"if-none-match":n}:{}});if(o.status===304)return this.snapshot();if(!o.ok)throw new Error(`Detector signature sync failed with status ${o.status}.`);return r=(await o.json()).signatures??[],n=o.headers.get("etag"),this.snapshot()}}};var ce=async(e={})=>{if(e.customDetectors?.length){let t=await U(e.customDetectors).detectAll(!!e.experimental);if(t)return t}if(e.webmcp!==false){let t=await a(e.webmcp??{});if(t)return t}if(e.dom!==false){let t=C(e.dom??{});if(t)return t}return null};var St=e=>({class:e.class,trust:"declared",confidence:1,vendor:e.vendor,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:{declared:true,hasToken:true,tokenExpiresAt:e.expiresAt??null}}),le=()=>{let e=null;return {present(t){let n=IdentityClaim.safeParse(t);if(!n.success)throw new AgentronicsError("invalid_api_key",`Invalid identity claim: ${n.error.issues[0]?.message??"unknown"}`);let r={claim:n.data,identity:St(n.data)};return e=r,r},clear(){e=null;},preferOver(t){return e?t?isHigherTrust(e.identity.trust,t.trust)?e.identity:t:e.identity:t},snapshot(){return e}}};var kn=({detected:e,declared:t,verified:n,linked:r})=>r?"linked":n?"verified":t?"declared":"detected",de=e=>{let t=null;for(let n of e)(!t||TRUST_RANK[n.trust]>TRUST_RANK[t.trust])&&(t=n);return t};var pe=()=>({name:"bearer",async authenticate(e,t){if(!e.bearerToken)return null;let n=await t.verifyToken?.("bearer",e.bearerToken);return {class:e.classHint??"dom",trust:n?.trust??"verified",confidence:1,vendor:n?.vendor??e.vendorHint??"bearer",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:{bearer:true,verifiedRemotely:!!n}}}});var ge=()=>({name:"detection",async authenticate(e){return e.detected??null}});var me=()=>({name:"extensionToken",async authenticate(e,t){if(!e.extensionToken)return null;let n=await t.verifyToken?.("extensionToken",e.extensionToken);return {class:"dom",trust:n?.trust??"verified",confidence:1,vendor:n?.vendor??e.vendorHint??"browser-extension",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:{extensionToken:true,verifiedRemotely:!!n}}}});var ye=()=>({name:"mtls",async authenticate(e,t){if(!e.xfccHeader)return null;let n=await t.verifyToken?.("mtls",e.xfccHeader);return {class:e.classHint??"webmcp",trust:n?.trust??"verified",confidence:1,vendor:n?.vendor??e.vendorHint??"mtls",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:{mtls:true,subject:n?.subject??null,verifiedRemotely:!!n,...n?.signals??{}}}}});var fe=()=>({name:"oauth2",async authenticate(e,t){if(!e.oauth2AccessToken)return null;let n=await t.verifyToken?.("oauth2",e.oauth2AccessToken);return {class:e.classHint??"webmcp",trust:e.oauth2Subject?"linked":n?.trust??"verified",confidence:1,vendor:n?.vendor??e.vendorHint??"oauth2",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:{oauth2:true,subject:e.oauth2Subject??null,verifiedRemotely:!!n}}}});var At=e=>({class:e.class,trust:"declared",confidence:1,vendor:e.vendor,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:{declared:true,hasToken:true,tokenExpiresAt:e.expiresAt??null}}),he=()=>({name:"selfDeclaration",async authenticate(e){return e.declaration?At(IdentityClaim.parse(e.declaration)):null}});var ve=()=>({name:"sessionLink",async authenticate(e,t){if(!e.sessionLinkToken)return null;let n=await t.verifyToken?.("sessionLink",e.sessionLinkToken);return {class:e.classHint??"screenshot",trust:e.linkedUserId?"linked":n?.trust??"verified",confidence:1,vendor:n?.vendor??e.vendorHint??"session-link",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:{sessionLink:true,linkedUserId:e.linkedUserId??null,verifiedRemotely:!!n}}}});var we=()=>({name:"sso",async authenticate(e,t){if(!e.ssoIdToken)return null;let n=await t.verifyToken?.("sso",e.ssoIdToken);return {class:e.classHint??"dom",trust:n?.trust??"verified",confidence:1,vendor:n?.vendor??e.vendorHint??"sso",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:{sso:true,subject:n?.subject??null,verifiedRemotely:!!n,...n?.signals??{}}}}});var xe=()=>({name:"spiffe",async authenticate(e,t){if(!e.spiffeJwt)return null;let n=await t.verifyToken?.("spiffe",e.spiffeJwt),r=n?.vendor==="google";return {class:e.classHint??"webmcp",trust:n?.trust??"verified",confidence:1,vendor:n?.vendor??e.vendorHint??"spiffe",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:{spiffe:true,spiffeId:n?.subject??null,subject:n?.subject??null,verifiedRemotely:!!n,...r?{googleAgent:true}:{},...n?.signals??{}}}}});var be=()=>({name:"xAgentHeader",async authenticate(e){if(!e.xAgentHeader)return null;let[t="x-agent",n="dom",r]=e.xAgentHeader.split(";"),o=AgentClass.safeParse(n);return {class:o.success?o.data:"dom",trust:r?"verified":"declared",confidence:r?1:.8,vendor:t,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:{xAgentHeader:true,hasProof:!!r}}}});var Mt=()=>[ge(),he(),pe(),be(),me(),ve(),fe(),we(),xe(),ye()],It={detection:"detection",selfDeclaration:"declaration",bearer:"bearer",xAgentHeader:"x-agent-header",extensionToken:"extension",sessionLink:"session-link",oauth2:"oauth2",sso:"sso",spiffe:"spiffe",mtls:"mtls"},Pt=(e,t)=>e==="spiffe"&&t.signals?.googleAgent===true?"google-agent":It[e],Se=({methods:e=Mt(),context:t={},onTrace:n}={})=>({async authenticate(r){let o=[],i={};for(let g of e){let d=await g.authenticate(r,t);i[g.name]=!!d,d&&o.push({method:g.name,identity:d});}let s=de(o.map(g=>g.identity)),a=s?o.find(g=>g.identity===s):void 0,l=a?Pt(a.method,a.identity):void 0,u=typeof s?.signals?.subject=="string"?s.signals.subject:void 0,p={type:s?"auth.identity_presented":"sdk.error",agent:s,outcome:s?"success":"error",metadata:{methods:i,...l?{protocol:l}:{},...u?{subject:u}:{}}};return s||(p.error="No auth method produced an identity."),n?.(p),s},methods(){return e.map(r=>r.name)}});var Rt={identity:null,source:"initial",updatedAt:null},Te=()=>{let e=Rt,t=new Set,n=()=>{t.size!==0&&t.forEach(r=>r(e));};return {snapshot(){return e},set(r,o){e={identity:r,source:o,updatedAt:new Date().toISOString()},n();},subscribe(r){return t.add(r),()=>{t.delete(r);}}}};var Et=()=>{let e=new Map;return {read:t=>e.get(t)??null,write:(t,n)=>{e.set(t,n);}}},Ot=()=>typeof window>"u"||!window.localStorage?Et():{read:e=>{try{return window.localStorage.getItem(e)}catch{return null}},write:(e,t)=>{try{window.localStorage.setItem(e,t);}catch{}}},Ct=e=>{if(!e)return null;try{let t=JSON.parse(e);if(typeof t=="object"&&t!==null&&Number.isFinite(t.count)&&Number.isFinite(t.resetAt))return t}catch{return null}return null},Ae=(e=Ot())=>({consume(t,n,r=Date.now()){let o=`agtx:rate:${t}`,i=Ct(e.read(o)),s=i&&i.resetAt>r?i.resetAt:r+n.windowSeconds*1e3,a=i&&i.resetAt>r?i.count+1:1;return e.write(o,JSON.stringify({count:a,resetAt:s})),{allowed:a<=n.max,remaining:Math.max(0,n.max-a),resetAt:s}}});var Dt=(e,t)=>e==="*"||e===t?true:e.includes("*")?new RegExp("^"+e.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*")+"$").test(t):false,Lt=(e,t)=>{let n=e?TRUST_RANK[e.trust]:-1,r=TRUST_RANK[t.minTrust];return n>=r},$t=(e,t)=>t.allowedClasses.length===0?true:e?t.allowedClasses.includes(e.class):false,Ie="review",jt=(e,t)=>{let n=t?.class??"unknown",r=t?.vendor??"unknown",o=t?.trust??"none";return `${e}:${n}:${r}:${o}`},Pe=(e=[],t={})=>{let n=e.map(o=>PolicyRule.parse(o)),r=t.rateLimiter??Ae();return {set(o){n=o.map(i=>PolicyRule.parse(i));},list(){return [...n]},evaluate({tool:o,identity:i}){for(let s of n)if(Dt(s.tool,o)){if(!Lt(i,s))return {decision:"deny",ruleId:s.id,reason:`Rule "${s.id}" requires trust >= ${s.minTrust}.`};if(!$t(i,s))return {decision:"deny",ruleId:s.id,reason:`Rule "${s.id}" restricts to classes: ${s.allowedClasses.join(", ")}.`};if(s.rateLimit){let a=r.consume(jt(o,i),s.rateLimit);if(!a.allowed)return {decision:"deny",ruleId:s.id,reason:`Rule "${s.id}" rate limit exceeded. Resets at ${new Date(a.resetAt).toISOString()}.`}}return {decision:s.decision,ruleId:s.id,reason:`Matched rule "${s.id}".`}}return {decision:Ie,ruleId:null,reason:`No rule matched tool "${o}". Falling back to "${Ie}".`}}}};var Re=({gatewayUrl:e,siteId:t,publishableKey:n,fetcher:r=fetch})=>{let o={policies:[],etag:null};return {snapshot(){return {policies:[...o.policies],etag:o.etag}},async sync(){let i=await r(`${e.replace(/\/$/,"")}/v1/sites/${encodeURIComponent(t)}/policies`,{headers:{authorization:`Bearer ${n}`,...o.etag?{"if-none-match":o.etag}:{}}});if(i.status===304)return this.snapshot();if(!i.ok)throw new Error(`Policy sync failed with status ${i.status}.`);let s=await i.json();return o={policies:PolicyRule.array().parse(s.policies??[]),etag:i.headers.get("etag")},this.snapshot()}}};var Ee=({message:e="Agent action blocked by site policy.",durationMs:t=2400,documentRef:n=typeof document>"u"?void 0:document}={})=>{if(!n?.body)return null;let r=n.createElement("div");return r.setAttribute("role","status"),r.setAttribute("data-agentronics-deny-overlay","true"),r.textContent=e,Object.assign(r.style,{position:"fixed",zIndex:"2147483647",left:"50%",bottom:"24px",transform:"translateX(-50%)",maxWidth:"min(520px, calc(100vw - 32px))",padding:"12px 16px",borderRadius:"8px",background:"#07091A",color:"#F4F4F5",border:"1px solid #6366F1",boxShadow:"0 20px 48px -16px rgba(7,9,26,0.55)",font:"13px/1.45 'Space Mono', ui-monospace, SFMono-Regular, Menlo, monospace"}),n.body.appendChild(r),window.setTimeout(()=>r.remove(),t),r};var Oe=({policyEngine:e,getIdentity:t,documentRef:n=typeof document>"u"?void 0:document,selector:r="[data-agentronics-tool]"})=>{if(!n)return {uninstall:()=>{}};let o=i=>{let s=i.target instanceof Element?i.target.closest(r):null;if(!(s instanceof HTMLElement))return;let a=s.dataset.agentronicsTool;a&&Promise.resolve(t()).then(l=>{let u=e.evaluate({tool:a,identity:l});u.decision==="deny"&&(i.preventDefault(),i.stopPropagation(),Ee({message:u.reason,documentRef:n}));});};return n.addEventListener("click",o,true),{uninstall:()=>n.removeEventListener("click",o,true)}};var _=()=>{let e=new Map;return {read:t=>e.get(t)??null,write:(t,n)=>{e.set(t,n);},remove:t=>{e.delete(t);},keys:()=>[...e.keys()]}},Ce=(e,t)=>({read:n=>{try{return e.getItem(t+n)}catch{return null}},write:(n,r)=>{try{e.setItem(t+n,r);}catch{}},remove:n=>{try{e.removeItem(t+n);}catch{}},keys:()=>{let n=[];try{for(let r=0;r<e.length;r++){let o=e.key(r);o&&o.startsWith(t)&&n.push(o.slice(t.length));}}catch{}return n}}),De="agtx:",Le=()=>{let e=typeof window<"u",t=e&&typeof window.sessionStorage<"u"?Ce(window.sessionStorage,De+"session:"):_(),n=e&&typeof window.localStorage<"u"?Ce(window.localStorage,De+"user:"):_();return {session:t,user:n,org:_()}};var je=(e,t)=>e.expiresAt!==null&&e.expiresAt<=t,We=e=>{if(!e)return null;try{let t=JSON.parse(e);return typeof t!="object"||t===null?null:t}catch{return null}},Gt=e=>JSON.stringify(e),Ge=(e={})=>{let t=Le(),n=l=>{e.onTrace?.(l);};return {get:(l,u={})=>{let p=u.scope??"session",g=t[p],d=We(g.read(l));if(!d){n({type:"memory.accessed",metadata:{operation:"get",key:l,scope:p,hit:false}});return}if(je(d,Date.now())){g.remove(l),n({type:"memory.accessed",metadata:{operation:"get",key:l,scope:p,hit:false,expired:true}});return}return n({type:"memory.accessed",metadata:{operation:"get",key:l,scope:p,hit:true}}),d.value},set:(l,u,p={})=>{let g=p.scope??"session",d=p.ttlSeconds??null,f=Date.now(),w={value:u,expiresAt:d===null?null:f+d*1e3,updatedAt:new Date(f).toISOString()};return t[g].write(l,Gt(w)),n({type:"memory.updated",metadata:{operation:"set",key:l,scope:g,ttlSeconds:d}}),MemoryEntry.parse({key:l,value:u,scope:g,ttlSeconds:d,updatedAt:w.updatedAt})},remove:(l,u={})=>{let p=u.scope??"session";t[p].remove(l),n({type:"memory.updated",metadata:{operation:"remove",key:l,scope:p}});},list:(l={})=>{let u=l.scope??"session",p=t[u],g=Date.now(),d=[];for(let f of p.keys()){let w=We(p.read(f));if(w){if(je(w,g)){p.remove(f);continue}d.push(MemoryEntry.parse({key:f,value:w.value,scope:u,ttlSeconds:w.expiresAt===null?null:Math.max(0,Math.round((w.expiresAt-g)/1e3)),updatedAt:w.updatedAt}));}}return n({type:"memory.accessed",metadata:{operation:"list",scope:u,count:d.length}}),d},clear:(l={})=>{let u=l.scope??"session",p=t[u],g=p.keys().length;for(let d of p.keys())p.remove(d);n({type:"memory.updated",metadata:{operation:"clear",scope:u,count:g}});}}};var N=e=>SiteMemory.parse(JSON.parse(JSON.stringify(e))),L=e=>({...e,updatedAt:new Date().toISOString()}),Be=(e={})=>{let t=SiteMemory.parse({...SITE_MEMORY_DEFAULT,...e.initial??{}}),n=null,r=new Set,o=m=>{e.onTrace?.(m);},i=()=>{n=null;},s=()=>{if(r.size===0)return;let m=N(t);n=m,r.forEach(h=>h(m));},a=m=>{let h=SiteMemory.parse({...t,...m,workflows:{...t.workflows,...m.workflows??{}},policies:{...t.policies,...m.policies??{}},uiGuidance:{...t.uiGuidance,...m.uiGuidance??{}},pageContexts:{...t.pageContexts,...m.pageContexts??{}}});return t=L(h),i(),o({type:"memory.updated",metadata:{kind:"site",operation:"provide",keys:Object.keys(m)}}),s(),p()},l=(m,h)=>{let v=m.split(".").filter(Boolean);if(v.length===0)throw new Error("siteMemory.update() requires a non-empty dot-path.");let A=JSON.parse(JSON.stringify(t)),k=A;for(let M=0;M<v.length-1;M++){let S=v[M],I=k[S];(typeof I!="object"||I===null||Array.isArray(I))&&(k[S]={}),k=k[S];}return k[v[v.length-1]]=h,t=L(SiteMemory.parse(A)),i(),o({type:"memory.updated",metadata:{kind:"site",operation:"update",path:m}}),s(),p()},u=m=>{let h=SiteMemoryPageContext.parse({path:m.path,payload:m.payload,updatedAt:new Date().toISOString()});return t=L({...t,pageContexts:{...t.pageContexts,[m.path]:h}}),i(),o({type:"memory.updated",metadata:{kind:"site",operation:"provideForPage",path:m.path}}),s(),{...h,payload:{...h.payload}}},p=()=>(n||(n=N(t)),n);return {provide:a,update:l,provideForPage:u,snapshot:p,get:m=>{if(o({type:"memory.accessed",metadata:{kind:"site",operation:m?"get":"snapshot",path:m??null}}),!m)return N(t);let h=m.split(".").filter(Boolean),v=t;for(let A of h){if(typeof v!="object"||v===null)return;v=v[A];}return v},getForPage:m=>{o({type:"memory.accessed",metadata:{kind:"site",operation:"getForPage",path:m}});let h=t.pageContexts[m];return h?{...h,payload:{...h.payload}}:null},replace:m=>(t=L(SiteMemory.parse(m)),i(),s(),p()),subscribe:m=>(r.add(m),()=>{r.delete(m);})}};var _e=({gatewayUrl:e,siteId:t,publishableKey:n,fetcher:r=fetch})=>{let o={memory:null,etag:null};return {snapshot(){return {memory:o.memory?SiteMemory.parse(o.memory):null,etag:o.etag}},async sync(){let i=await r(`${e.replace(/\/$/,"")}/v1/sites/${encodeURIComponent(t)}/memory`,{headers:{authorization:`Bearer ${n}`,...o.etag?{"if-none-match":o.etag}:{}}});if(i.status===304)return this.snapshot();if(!i.ok)throw new Error(`Memory sync failed with status ${i.status}.`);let s=await i.json();return o={memory:SiteMemory.parse(s.memory??{}),etag:i.headers.get("etag")},this.snapshot()}}};var _t=({toolName:e="getSiteContext",description:t="Returns Agentronics site memory: page map, workflows, policies, UI guidance.",getSnapshot:n,onAccess:r})=>({name:e,description:t,inputSchema:{type:"object",properties:{path:{type:"string",description:'Optional dot-path into the site memory (e.g. "workflows.purchase").'}},required:[]},invoke(o={}){let i=n(),s=o.path??null;if(r?.(s),!s)return {content:i};let a=s.split(".").filter(Boolean),l=i;for(let u of a){if(typeof l!="object"||l===null)return {content:void 0};l=l[u];}return {content:l}}});var T="agent-context-",H="agentronics-site-context",Nt=e=>{try{return JSON.stringify(e)}catch{return "{}"}},$=(e,t,n)=>{let r=e.querySelector(`meta[name="${t}"]`);r||(r=e.createElement("meta"),r.setAttribute("name",t),e.head.appendChild(r)),r.setAttribute("content",n);},j=(e,t)=>{e.querySelectorAll(`meta[name="${t}"]`).forEach(n=>n.remove());},F=({doc:e=typeof document>"u"?null:document,snapshot:t,schemaType:n="WebSite"})=>{if(!e)return {uninstall:()=>{}};$(e,`${T}version`,t.version),$(e,`${T}updated-at`,t.updatedAt??new Date().toISOString()),t.siteMap?.navigation?.flow&&$(e,`${T}flow`,t.siteMap.navigation.flow),$(e,`${T}workflows`,Object.keys(t.workflows).join(","));let r=e.getElementById(H);return r||(r=e.createElement("script"),r.type="application/ld+json",r.id=H,e.head.appendChild(r)),r.textContent=Nt({"@context":"https://schema.org","@type":n,name:"Agentronics Site Memory",agentronics:t}),{uninstall:()=>{j(e,`${T}version`),j(e,`${T}updated-at`),j(e,`${T}flow`),j(e,`${T}workflows`),e.getElementById(H)?.remove();}}};var Ne="agentronics-memory-overlay",Ht=e=>`
2
- position: fixed;
3
- bottom: 16px;
4
- right: 16px;
5
- max-width: 320px;
6
- padding: 10px 12px;
7
- background: rgba(17, 24, 39, 0.92);
8
- color: #f9fafb;
9
- font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
10
- border-radius: 8px;
11
- z-index: 2147483647;
12
- opacity: ${e?"0":"1"};
13
- pointer-events: ${e?"none":"auto"};
14
- box-shadow: 0 12px 32px rgba(15, 23, 42, 0.35);
15
- `,He=e=>{let t=e.siteMap?.pages?.length??0,n=Object.keys(e.workflows).length,r=Object.keys(e.uiGuidance).length;return `Agentronics site memory \xB7 pages:${t} \xB7 workflows:${n} \xB7 ui-hints:${r}`},K=({doc:e=typeof document>"u"?null:document,snapshot:t,hidden:n=false})=>{if(!e)return {uninstall:()=>{},refresh:()=>{}};let r=e.getElementById(Ne);return r||(r=e.createElement("div"),r.id=Ne,r.setAttribute("role","note"),r.setAttribute("aria-label","Agentronics site memory summary"),r.setAttribute("data-agent-context","overlay"),e.body.appendChild(r)),r.setAttribute("style",Ht(n)),r.textContent=He(t),{uninstall:()=>{r?.remove();},refresh:o=>{r&&(r.textContent=He(o));}}};var Ke="/.well-known/agent-context.json",z=async({origin:e,fetcher:t=fetch,signal:n}={})=>{let r=(e?e.replace(/\/$/,""):typeof window<"u"?window.location.origin:"")+Ke;if(!r.startsWith("http"))return null;let o={headers:{accept:"application/json"}};n!==void 0&&(o.signal=n);let i=await t(r,o);if(!i.ok){if(i.status===404)return null;throw new Error(`well-known agent-context fetch failed with status ${i.status}.`)}let s=await i.json();return SiteMemory.parse(s)},Ft=({snapshot:e})=>JSON.stringify(SiteMemory.parse(e));var ze=({evaluate:e,setPolicies:t,listPolicies:n,onTrace:r})=>{let o=new Map,i=new Set,s=a=>{if(!a.authz||!t||!n)return;let l={id:`tool:${a.name}`,tool:a.name,...a.authz,rateLimit:a.rateLimit??a.authz.rateLimit};t([...n().filter(u=>u.id!==l.id),l]);};return {register(a){return o.set(a.name,a),i.delete(a.name),s(a),r?.({type:"tool.registered",tool:a.name,metadata:{version:a.version??null,group:a.group??null,stage:a.stage??null}}),()=>{o.delete(a.name),i.delete(a.name);}},unregister(a){o.delete(a),i.delete(a);},enable(a){!o.has(a)||!i.has(a)||(i.delete(a),r?.({type:"tool.surfaced",tool:a,metadata:{state:"enabled"}}));},disable(a){!o.has(a)||i.has(a)||(i.add(a),r?.({type:"tool.surfaced",tool:a,metadata:{state:"disabled"}}));},isEnabled:a=>o.has(a)&&!i.has(a),list({includeDisabled:a=false}={}){let l=[...o.values()];return a?l:l.filter(u=>!i.has(u.name))},get:a=>o.get(a),async execute(a,l,u=null){let p=o.get(a);if(!p)throw new Error(`Tool "${a}" is not registered.`);if(i.has(a)){let f={decision:"deny",ruleId:`tool:${a}`,reason:"Tool is disabled."};throw r?.({type:"tool.executed",tool:a,agent:u,policy:f,outcome:"blocked"}),new Error(f.reason)}let g=await e(a,{identity:u});if(g.decision==="deny")throw r?.({type:"tool.executed",tool:a,agent:u,policy:g,outcome:"blocked"}),new Error(g.reason);let d=Date.now();try{let f=await p.execute(l,{identity:u});return r?.({type:"tool.executed",tool:a,agent:u,policy:g,outcome:"success",durationMs:Date.now()-d}),f}catch(f){throw r?.({type:"tool.executed",tool:a,agent:u,policy:g,outcome:"error",durationMs:Date.now()-d,error:f instanceof Error?f.message:String(f)}),f}}}};var Je=(e,t={})=>{let n=new Map;for(let s of e.stages)n.set(s.name,s);if(!n.has(e.initial))throw new Error(`Initial stage "${e.initial}" is not declared in progression stages.`);let r=e.initial,o=()=>{let s=n.get(r);return s?.enables?[r,...s.enables]:[r]},i=(s,a)=>{let l=r;if(!n.has(s))throw new Error(`Cannot transition to unknown stage "${s}".`);return s===r?{changed:false,from:l,to:s}:(r=s,t.onTrace?.({type:"tool.progressed",metadata:{from:l,to:s,trigger:a}}),{changed:true,from:l,to:s})};return {current:()=>r,enabledStages:()=>o(),notify(s){let l=n.get(r)?.transitions?.find(u=>u.on===s);return l?i(l.to,s):{changed:false,from:r,to:r}},set(s){return i(s,"manual")},reset(){let s=r;r=e.initial,s!==r&&t.onTrace?.({type:"tool.progressed",metadata:{from:s,to:r,trigger:"reset"}});},snapshot:()=>({current:r,enabled:o()})}};var Kt=(e,t)=>{let n=e.authz?.minTrust;return n?t?TRUST_RANK[t.trust]<TRUST_RANK[n]?{ok:false,reason:`trust-too-low:${t.trust}<${n}`}:{ok:true,reason:"trust-ok"}:{ok:false,reason:`requires-trust:${n}`}:{ok:true,reason:"no-trust-floor"}},zt=(e,t)=>{let n=e.authz?.allowedClasses??[];return n.length===0?{ok:true,reason:"no-class-restriction"}:t?n.includes(t.class)?{ok:true,reason:"class-ok"}:{ok:false,reason:`class-not-allowed:${t.class}`}:{ok:false,reason:`requires-class:${n.join("|")}`}},Jt=(e,t)=>e.stage?t.enabledStages&&t.enabledStages.includes(e.stage)?{ok:true,reason:`stage-enabled:${e.stage}`}:t.stage===e.stage?{ok:true,reason:`stage-active:${e.stage}`}:{ok:false,reason:`stage-locked:${e.stage}`}:{ok:true,reason:"no-stage"},qe=(e,t)=>{let n=Kt(e,t.identity);if(!n.ok)return {tool:e,visible:false,reason:n.reason};let r=zt(e,t.identity);if(!r.ok)return {tool:e,visible:false,reason:r.reason};let o=Jt(e,t);return o.ok?e.authz?.decision==="deny"?{tool:e,visible:false,reason:"authz-deny"}:{tool:e,visible:true,reason:"visible"}:{tool:e,visible:false,reason:o.reason}},Xe=(e,t)=>e.filter(n=>qe(n,t).visible),Ye=(e,t)=>e.map(n=>qe(n,t));var Qe="default",Ze=e=>{let t=new Map;for(let n of e){let r=n.group??Qe,o=t.get(r)??[];o.push(n),t.set(r,o);}return [...t.entries()].sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>({name:n,tools:r}))},Rr=e=>[...new Set(e.map(t=>t.group??Qe))].sort();var J=e=>e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(J).join(",")}]`:`{${Object.keys(e).sort().map(n=>`${JSON.stringify(n)}:${J(e[n])}`).join(",")}}`,Vt=e=>{let t={name:e.name,version:e.version??null,group:e.group??null,description:e.description??null,inputSchema:e.inputSchema??null,authz:e.authz??null,rateLimit:e.rateLimit??null},n=J(t).length;return {name:e.name,characters:n,tokens:Math.ceil(n/4)}},et=e=>{let t=e.map(Vt);return {total:t.reduce((r,o)=>r+o.tokens,0),perTool:t}};var tt=e=>e.provider?e.provider:(e.doc?.defaultView??(typeof globalThis<"u"?globalThis:null))?.navigator?.modelContext??null,qt=(e,t)=>{let n={name:e.name,invoke:r=>t(e,r)};return e.description!==void 0&&(n.description=e.description),e.inputSchema!==void 0&&(n.inputSchema=e.inputSchema),n},nt=(e={})=>{let t=e.invoke??(async(r,o)=>r.execute(o,{identity:null})),n=null;return {publish(r){let o=tt(e);return o?(n?.revoke(),n=o.provideContext({tools:r.map(i=>qt(i,t))}),{revoked:true}):{revoked:false}},revoke(){n?.revoke(),n=null;},available:()=>!!tt(e)}};var V=(e=500)=>{let t=[];return {add(n){t.push(n),t.length>e&&t.splice(0,t.length-e);},list(){return [...t]},clear(){t.length=0;}}};var rt=(e,t)=>e===void 0?t:Math.max(0,Math.min(1,e)),q=(e={})=>{let t=rt(e.traceRate,1),n=rt(e.errorRate,1),r=e.random??Math.random;return {shouldKeep(o){let i=o.outcome==="error"?n:t;return r()<i}}};var Xt="[REDACTED]",Yt=e=>{if(e!==void 0)return JSON.parse(JSON.stringify(e))},X=(e,t)=>{if(t.length===0||typeof e!="object"||e===null)return;let[n,...r]=t;if(!n)return;if(Array.isArray(e)){for(let i of e)X(i,t);return}let o=e;if(n in o){if(r.length===0){o[n]=Xt;return}X(o[n],r);}},Y=(e,t=[])=>{if(t.length===0)return e;let n=Yt(e);for(let r of t)X(n,r.split(".").filter(Boolean));return n},Q=["metadata.password","metadata.token","metadata.authorization","metadata.cookie"];var Zt=()=>typeof location<"u"&&typeof location.pathname=="string"?location.pathname:void 0,ot=e=>{let t=globalThis.crypto;return t&&"randomUUID"in t?`${e}_${t.randomUUID()}`:`${e}_${Date.now().toString(36)}_${Math.random().toString(36).slice(2)}`},Z=({siteId:e,bufferSize:t,sessionId:n=ot("ses"),scrubPaths:r=Q,exporters:o=[],onExporterError:i,pageProvider:s=Zt,...a})=>{let l=V(t),u=q(a),p=()=>{try{return s()}catch{return}};return {sessionId:n,async emit(g){let d={...g.metadata};if(d.page===void 0){let w=p();w!==void 0&&(d.page=w);}let f=TraceEvent.parse(Y({id:ot("trc"),siteId:e,sessionId:n,occurredAt:new Date().toISOString(),outcome:g.outcome??"success",...g,metadata:d},r));return u.shouldKeep(f)?(l.add(f),await Promise.all(o.map(async w=>{try{await w.export([f]);}catch(m){i?.(m,w,f);}})),f):null},list:()=>l.list(),clear:()=>l.clear()}};var ee=()=>({name:"console",export(e){for(let t of e)console.info("[agentronics:trace]",t.type,t);}});var te=({gatewayUrl:e,publishableKey:t,fetcher:n=fetch})=>({name:"gateway",async export(r){let o={publishableKey:t,events:r};await n(`${e.replace(/\/$/,"")}/v1/traces`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${t}`},body:JSON.stringify(o)});}});var en=e=>new Promise(t=>setTimeout(t,e)),re=({url:e,fetcher:t=fetch,maxRetries:n=2,queueLimit:r=500})=>({name:"webhook",async export(o){let s=[...tn(e),...o].slice(-r),a=0;for(;;){let l=await t(e,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({events:s})});if(l.ok){it(e,[]);return}if(a>=n)throw it(e,s),new Error(`Webhook exporter failed with status ${l.status}.`);a+=1,await en(100*a);}}}),ne=e=>`agtx:webhook:${e}`,tn=e=>{if(typeof window>"u"||!window.localStorage)return [];try{let t=window.localStorage.getItem(ne(e));return t?JSON.parse(t):[]}catch{return []}},it=(e,t)=>{if(!(typeof window>"u"||!window.localStorage))try{if(t.length===0){window.localStorage.removeItem(ne(e));return}window.localStorage.setItem(ne(e),JSON.stringify(t));}catch{}};var at="https://gateway.agentronics.dev",on=e=>{if(e===void 0)return at;if(e===at)return e;let t;try{t=new URL(e);}catch{throw new Error(`Agentronics SDK: \`gatewayUrl\` is not a valid URL: ${e}`)}if(t.hostname==="localhost"||t.hostname==="127.0.0.1")return e;throw new Error(`Agentronics SDK does not support custom gateway URLs. Omit \`gatewayUrl\` to use the canonical https://gateway.agentronics.dev. The only accepted override is a localhost / 127.0.0.1 URL for local development. Got: ${e}`)},vo=e=>{let{publishableKey:t,siteId:n="default",debug:r=false,policies:o=[],trace:i={}}=e,s=on(e.gatewayUrl),a=classifyApiKey(t);if(a==="secret")throw new AgentronicsError("wrong_key_kind","A secret key was passed to Agentronics.init(). Browser code must use a publishable key (agtx_pk_*).");if(a!=="publishable")throw new AgentronicsError("invalid_api_key",`Agentronics.init() expected a key starting with "${PUBLISHABLE_KEY_PREFIX}".`);let l=i.enabled??true,u=[...r?[ee()]:[],...i.gateway?[te({gatewayUrl:s,publishableKey:t})]:[],...i.webhookUrl?[re({url:i.webhookUrl})]:[],...i.exporters??[]],p={siteId:n,exporters:l?u:[],onExporterError:(c,y)=>{r&&console.warn(`[agentronics] trace exporter "${y.name}" failed`,c);}};i.bufferSize!==void 0&&(p.bufferSize=i.bufferSize),i.traceRate!==void 0&&(p.traceRate=i.traceRate),i.errorRate!==void 0&&(p.errorRate=i.errorRate),i.scrubPaths!==void 0&&(p.scrubPaths=i.scrubPaths);let g=Z(p),d=c=>{l&&g.emit(c);},f=le(),w={onTrace:d};e.auth!==void 0&&(w.context=e.auth);let m=Se(w),h=Te(),v=Pe(o),A=Re({gatewayUrl:s,siteId:n,publishableKey:t}),k=Ge({onTrace:d}),M={onTrace:d};e.siteMemory!==void 0&&(M.initial=e.siteMemory);let S=Be(M),I=_e({gatewayUrl:s,siteId:n,publishableKey:t}),W=async c=>{let y=Date.now(),x=await ce(c),b=f.preferOver(x);return l&&await g.emit({type:b?"agent.detected":"agent.missed",agent:b,durationMs:Date.now()-y,metadata:{detectedClass:x?.class??null,presented:f.snapshot()!==null}}),h.set(b,"detect"),b},oe=async(c,y={})=>{let x=Date.now(),b=y.identity!==void 0?y.identity:await W(),B=v.evaluate({tool:c,identity:b});return l&&await g.emit({type:"authz.evaluated",tool:c,agent:b,policy:B,outcome:B.decision==="deny"?"blocked":"success",durationMs:Date.now()-x}),B},P=ze({evaluate:oe,setPolicies:c=>v.set(c),listPolicies:()=>v.list(),onTrace:d});for(let c of e.tools??[])P.register(c);let R=e.progression?Je(e.progression,{onTrace:d}):null,ie=c=>{let y={identity:c};return R&&(y.stage=R.current(),y.enabledStages=R.enabledStages()),y},E=c=>Xe(P.list(),ie(c)),se=c=>{if(!R)return;R.notify(c).changed&&G.publish(E(null));},G=nt({invoke:async(c,y)=>{let x=await P.execute(c.name,y,null);return se(c.name),x}});return Object.freeze({publishableKey:t,siteId:n,gatewayUrl:s,debug:r,memory:k,siteMemory:S,memoryCache:I,tracer:g,auth:m,agentContext:h,authz:v,policyCache:A,tools:P,progression:R,webmcp:G,detect:W,authenticate:async c=>{let y=await m.authenticate(c);return h.set(y,"authenticate"),y},presentIdentity:c=>{let y=f.present(c);return d({type:"auth.identity_presented",agent:y.identity,metadata:{vendor:y.identity.vendor,class:y.identity.class}}),h.set(y.identity,"declare"),y},clearIdentity:()=>{f.clear(),d({type:"auth.identity_cleared"}),h.set(null,"cleared");},presentedIdentity:()=>f.snapshot(),setPolicies:c=>{v.set(c),d({type:"authz.policies_set",metadata:{count:c.length}});},listPolicies:()=>v.list(),syncPolicies:async()=>{let c=await A.sync();return v.set(c.policies),d({type:"authz.policies_set",metadata:{count:c.policies.length,synced:true}}),c.policies},syncSiteMemory:async()=>{let c=await I.sync();return c.memory&&(S.replace(c.memory),d({type:"memory.updated",metadata:{kind:"site",operation:"sync",etag:c.etag}})),c.memory},provideSiteMemory:c=>S.provide(c),provideForPage:c=>{S.provideForPage(c);},installMemoryDelivery:({metaTags:c=true,overlay:y=false}={})=>{let x=[];return c&&x.push(F({snapshot:S.snapshot()})),y&&x.push(K({snapshot:S.snapshot()})),{uninstall:()=>{x.forEach(b=>b.uninstall());}}},fetchWellKnown:async c=>{let y={};c!==void 0&&(y.origin=c);let x=await z(y);return x&&(S.replace(x),d({type:"memory.updated",metadata:{kind:"site",operation:"wellKnown",origin:c??null}})),x},installDomEnforcer:()=>Oe({policyEngine:v,getIdentity:()=>W({webmcp:{pollMs:0}})}),registerTool:c=>P.register(c),surfaceTools:({identity:c=null}={})=>E(c),explainSurfacing:({identity:c=null}={})=>Ye(P.list(),ie(c)),groupedTools:({identity:c=null}={})=>Ze(E(c)),estimateTokens:({identity:c=null}={})=>et(E(c)),publishToWebMcp:({identity:c=null}={})=>{let y=E(c),x=G.publish(y);return y.forEach(b=>{d({type:"tool.surfaced",tool:b.name,metadata:{state:"published",trust:c?.trust??null,group:b.group??null}});}),{revoked:x.revoked,surfaced:y.length}},notifyToolInvoked:c=>se(c),evaluate:oe,traces:()=>g.list(),clearTraces:()=>g.clear(),async ping(){try{let c=await fetch(`${s.replace(/\/$/,"")}/v1/health`,{method:"GET",headers:{authorization:`Bearer ${t}`}});if(!c.ok)return {ok:!1,status:c.status,error:`gateway returned ${c.status}`};let y=await c.json().catch(()=>null)??{};return {ok:!0,status:c.status,body:y}}catch(c){return {ok:false,status:0,error:c instanceof Error?c.message:String(c)}}}})};
16
- export{Je as A,qe as B,Xe as C,Ye as D,Qe as E,Ze as F,Rr as G,Vt as H,et as I,nt as J,V as K,Z as L,ee as M,te as N,re as O,vo as P,C as a,ae as b,U as c,ht as d,vt as e,ce as f,le as g,kn as h,de as i,Se as j,Te as k,Ae as l,Pe as m,Re as n,Ee as o,Oe as p,Ge as q,Be as r,_e as s,_t as t,F as u,K as v,Ke as w,z as x,Ft as y,ze as z};//# sourceMappingURL=chunk-VWQY7QIL.js.map
17
- //# sourceMappingURL=chunk-VWQY7QIL.js.map