@agentronics/sdk 0.1.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/LICENSE +190 -0
- package/README.md +121 -0
- package/dist/chunk-5BS4OAQA.js +2 -0
- package/dist/chunk-5BS4OAQA.js.map +1 -0
- package/dist/chunk-DKDVADEU.js +17 -0
- package/dist/chunk-DKDVADEU.js.map +1 -0
- package/dist/index.cjs +17 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +146 -0
- package/dist/index.d.ts +146 -0
- package/dist/index.global.js +17 -0
- package/dist/index.global.js.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/init-only-6SWFNqud.d.cts +508 -0
- package/dist/init-only-DrZymcuA.d.ts +508 -0
- package/dist/init-only.cjs +17 -0
- package/dist/init-only.cjs.map +1 -0
- package/dist/init-only.d.cts +3 -0
- package/dist/init-only.d.ts +3 -0
- package/dist/init-only.global.js +17 -0
- package/dist/init-only.global.js.map +1 -0
- package/dist/init-only.js +2 -0
- package/dist/init-only.js.map +1 -0
- package/dist/lite.cjs +2 -0
- package/dist/lite.cjs.map +1 -0
- package/dist/lite.d.cts +20 -0
- package/dist/lite.d.ts +20 -0
- package/dist/lite.global.js +2 -0
- package/dist/lite.global.js.map +1 -0
- package/dist/lite.js +2 -0
- package/dist/lite.js.map +1 -0
- package/dist/webmcp-C4ikhM4g.d.cts +12 -0
- package/dist/webmcp-C4ikhM4g.d.ts +12 -0
- package/package.json +69 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {f,d,P}from'./chunk-DKDVADEU.js';export{E as DEFAULT_GROUP,w as WELL_KNOWN_PATH,b as bundledDetectors,k as createAgentContextStore,j as createAuthEngine,M as createConsoleExporter,c as createDetectorRegistry,N as createGatewayExporter,g as createIdentityStore,s as createMemoryCache,q as createMemoryStore,n as createPolicyCache,m as createPolicyEngine,A as createProgressionStore,l as createRateLimiter,e as createSignatureLoader,r as createSiteMemoryStore,z as createToolRegistry,K as createTraceBuffer,L as createTracer,J as createWebMcpAdapter,t as createWebMcpContextTool,O as createWebhookExporter,B as decideSurfacing,d as declareAgent,h as deriveTrustLevel,f as detectAgent,a as detectDom,I as estimateBudget,H as estimateToolTokens,D as explainSurfacing,x as fetchWellKnownContext,F as groupTools,i as highestTrust,P as init,p as installDomEnforcer,v as installMemoryOverlay,u as installMetaTags,G as listGroupNames,y as serializeWellKnownContext,o as showDenyOverlay,C as surfaceTools}from'./chunk-DKDVADEU.js';export{a as detectWebMcp}from'./chunk-5BS4OAQA.js';var me={init:P,declareAgent:d,detectAgent:f},ge="0.1.0";export{me as Agentronics,ge as VERSION};//# sourceMappingURL=index.js.map
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["Agentronics","init","declareAgent","detectAgent","VERSION"],"mappings":"ujCAmMO,IAAMA,EAAAA,CAAc,CAAE,IAAA,CAAAC,CAAAA,CAAM,aAAAC,CAAAA,CAAc,WAAA,CAAAC,CAAY,CAAA,CAEhDC,EAAAA,CAAU","file":"index.js","sourcesContent":["import { init, type AgentronicsClient, type InitOptions } from './init.js'\nimport {\n declareAgent,\n bundledDetectors,\n createDetectorRegistry,\n createSignatureLoader,\n detectAgent,\n detectDom,\n detectWebMcp,\n type DeclareAgentInput,\n type DetectAgentOptions,\n type DetectDomOptions,\n type DetectWebMcpOptions,\n type Detector,\n type DetectorRegistry,\n type DetectorStatus,\n type DomSignalName,\n} from './detection/index.js'\nimport {\n createIdentityStore,\n type IdentityStore,\n type PresentIdentityOptions,\n type PresentedIdentity,\n} from './auth/identity.js'\nimport { createAuthEngine, type AuthEngine, type AuthInput, type AuthMethod } from './auth/engine.js'\nimport {\n createAgentContextStore,\n type AgentContextStore,\n type AgentContextSnapshot,\n type AgentContextListener,\n} from './auth/agentContext.js'\nimport { deriveTrustLevel, highestTrust } from './auth/trustLevel.js'\nimport { createPolicyEngine, type PolicyEngine } from './authz/engine.js'\nimport { createRateLimiter, type RateLimiter } from './authz/rateLimiter.js'\nimport { createPolicyCache, type PolicyCache } from './authz/policyCache.js'\nimport { installDomEnforcer } from './authz/domEnforcer.js'\nimport { showDenyOverlay } from './authz/overlay.js'\nimport { createMemoryStore, type MemoryStore } from './memory/store.js'\nimport {\n createSiteMemoryStore,\n type SiteMemoryStore,\n type SiteMemoryListener,\n type ProvideForPageInput,\n} from './memory/siteMemory.js'\nimport { createMemoryCache, type MemoryCache } from './memory/memoryCache.js'\nimport {\n createWebMcpContextTool,\n installMetaTags,\n installMemoryOverlay,\n fetchWellKnownContext,\n serializeWellKnownContext,\n WELL_KNOWN_PATH,\n type WebMcpContextTool,\n type WebMcpContextOptions,\n} from './memory/delivery/index.js'\nimport { createToolRegistry, type GovernedTool, type ToolRegistry } from './tools/registry.js'\nimport {\n decideSurfacing,\n surfaceTools,\n explainSurfacing,\n type SurfacingContext,\n type SurfacingDecision,\n} from './tools/surfacing.js'\nimport {\n groupTools,\n listGroupNames,\n DEFAULT_GROUP,\n type ToolGroupSummary,\n} from './tools/groups.js'\nimport {\n createProgressionStore,\n type ProgressionConfig,\n type ProgressionStage,\n type ProgressionStore,\n type ProgressionTransition,\n} from './tools/progression.js'\nimport {\n estimateBudget,\n estimateToolTokens,\n type ToolTokenEstimate,\n type TokenBudgetReport,\n} from './tools/tokenEstimate.js'\nimport {\n createWebMcpAdapter,\n type WebMcpAdapter,\n type WebMcpAdapterOptions,\n type WebMcpToolDescriptor,\n type WebMcpProvider,\n} from './tools/webmcpAdapter.js'\nimport {\n createTracer,\n createTraceBuffer,\n createConsoleExporter,\n createGatewayExporter,\n createWebhookExporter,\n type TraceExporter,\n type TraceInput,\n type Tracer,\n} from './observability/index.js'\n\nexport {\n init,\n declareAgent,\n detectAgent,\n detectDom,\n detectWebMcp,\n createDetectorRegistry,\n bundledDetectors,\n createSignatureLoader,\n createIdentityStore,\n createAuthEngine,\n createAgentContextStore,\n deriveTrustLevel,\n highestTrust,\n createPolicyEngine,\n createRateLimiter,\n createPolicyCache,\n installDomEnforcer,\n showDenyOverlay,\n createToolRegistry,\n decideSurfacing,\n surfaceTools,\n explainSurfacing,\n groupTools,\n listGroupNames,\n DEFAULT_GROUP,\n createProgressionStore,\n estimateBudget,\n estimateToolTokens,\n createWebMcpAdapter,\n createMemoryStore,\n createSiteMemoryStore,\n createMemoryCache,\n createWebMcpContextTool,\n installMetaTags,\n installMemoryOverlay,\n fetchWellKnownContext,\n serializeWellKnownContext,\n WELL_KNOWN_PATH,\n createTracer,\n createTraceBuffer,\n createConsoleExporter,\n createGatewayExporter,\n createWebhookExporter,\n}\nexport type {\n AgentronicsClient,\n AuthEngine,\n AuthInput,\n AuthMethod,\n AgentContextStore,\n AgentContextSnapshot,\n AgentContextListener,\n DeclareAgentInput,\n DetectAgentOptions,\n DetectDomOptions,\n DetectWebMcpOptions,\n DomSignalName,\n IdentityStore,\n InitOptions,\n MemoryStore,\n SiteMemoryStore,\n SiteMemoryListener,\n MemoryCache,\n ProvideForPageInput,\n WebMcpContextTool,\n WebMcpContextOptions,\n GovernedTool,\n ToolRegistry,\n SurfacingContext,\n SurfacingDecision,\n ToolGroupSummary,\n ProgressionConfig,\n ProgressionStage,\n ProgressionStore,\n ProgressionTransition,\n ToolTokenEstimate,\n TokenBudgetReport,\n WebMcpAdapter,\n WebMcpAdapterOptions,\n WebMcpToolDescriptor,\n WebMcpProvider,\n PolicyEngine,\n PolicyCache,\n RateLimiter,\n Detector,\n DetectorRegistry,\n DetectorStatus,\n PresentIdentityOptions,\n PresentedIdentity,\n TraceExporter,\n TraceInput,\n Tracer,\n}\n\nexport const Agentronics = { init, declareAgent, detectAgent }\n\nexport const VERSION = '0.1.0'\n"]}
|
|
@@ -0,0 +1,508 @@
|
|
|
1
|
+
import { AgentIdentity, IdentityClaim, TraceEvent, TraceEventType, VerificationResult, AgentClass, PolicyRule, PolicyEvaluation, MemoryScope, MemoryEntry, SiteMemory, SiteMemoryPageContext } from '@agentronics/protocol';
|
|
2
|
+
import { D as DetectWebMcpOptions } from './webmcp-C4ikhM4g.cjs';
|
|
3
|
+
|
|
4
|
+
interface SignalResult {
|
|
5
|
+
hit: boolean;
|
|
6
|
+
weight: number;
|
|
7
|
+
detail?: string;
|
|
8
|
+
}
|
|
9
|
+
declare const SIGNALS: {
|
|
10
|
+
readonly webdriver: () => SignalResult;
|
|
11
|
+
readonly chromedriver: () => SignalResult;
|
|
12
|
+
readonly headlessUa: () => SignalResult;
|
|
13
|
+
readonly languages: () => SignalResult;
|
|
14
|
+
readonly permissions: () => SignalResult;
|
|
15
|
+
readonly plugins: () => SignalResult;
|
|
16
|
+
};
|
|
17
|
+
type DomSignalName = keyof typeof SIGNALS;
|
|
18
|
+
interface DetectDomOptions {
|
|
19
|
+
/** Floor below which we report no DOM agent. Defaults to 0.4. */
|
|
20
|
+
threshold?: number;
|
|
21
|
+
}
|
|
22
|
+
declare const detectDom: (options?: DetectDomOptions) => AgentIdentity | null;
|
|
23
|
+
|
|
24
|
+
type DetectorStatus = 'stable' | 'beta' | 'research';
|
|
25
|
+
interface Detector {
|
|
26
|
+
id: string;
|
|
27
|
+
status: DetectorStatus;
|
|
28
|
+
detect(): AgentIdentity | null | Promise<AgentIdentity | null>;
|
|
29
|
+
}
|
|
30
|
+
declare const bundledDetectors: () => Detector[];
|
|
31
|
+
declare const createDetectorRegistry: (initial?: Detector[]) => {
|
|
32
|
+
register(detector: Detector): void;
|
|
33
|
+
list(status?: DetectorStatus): Detector[];
|
|
34
|
+
detectAll(includeResearch?: boolean): Promise<AgentIdentity | null>;
|
|
35
|
+
};
|
|
36
|
+
type DetectorRegistry = ReturnType<typeof createDetectorRegistry>;
|
|
37
|
+
|
|
38
|
+
interface DetectAgentOptions {
|
|
39
|
+
webmcp?: DetectWebMcpOptions | false;
|
|
40
|
+
dom?: DetectDomOptions | false;
|
|
41
|
+
customDetectors?: Detector[];
|
|
42
|
+
experimental?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Run the full detection pipeline. WebMCP wins if present (exact match), then DOM heuristics.
|
|
46
|
+
* Returns `null` if no agent class fires above its threshold — caller should treat as "human or
|
|
47
|
+
* undetectable agent."
|
|
48
|
+
*/
|
|
49
|
+
declare const detectAgent: (options?: DetectAgentOptions) => Promise<AgentIdentity | null>;
|
|
50
|
+
|
|
51
|
+
interface PresentIdentityOptions extends IdentityClaim {
|
|
52
|
+
/**
|
|
53
|
+
* If false, accept the claim as `declared` (no remote verification).
|
|
54
|
+
* If true, the claim is staged for the gateway to verify; trust is `declared` until then.
|
|
55
|
+
*/
|
|
56
|
+
verifyRemotely?: boolean;
|
|
57
|
+
}
|
|
58
|
+
interface PresentedIdentity {
|
|
59
|
+
identity: AgentIdentity;
|
|
60
|
+
claim: IdentityClaim;
|
|
61
|
+
}
|
|
62
|
+
declare const createIdentityStore: () => {
|
|
63
|
+
present(input: PresentIdentityOptions): PresentedIdentity;
|
|
64
|
+
clear(): void;
|
|
65
|
+
/** Return the presented identity if it outranks the supplied detection. */
|
|
66
|
+
preferOver(detected: AgentIdentity | null): AgentIdentity | null;
|
|
67
|
+
snapshot(): PresentedIdentity | null;
|
|
68
|
+
};
|
|
69
|
+
type IdentityStore = ReturnType<typeof createIdentityStore>;
|
|
70
|
+
|
|
71
|
+
interface SamplerOptions {
|
|
72
|
+
traceRate?: number;
|
|
73
|
+
errorRate?: number;
|
|
74
|
+
random?: () => number;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
interface TraceExporter {
|
|
78
|
+
name: string;
|
|
79
|
+
export(events: TraceEvent[]): Promise<void> | void;
|
|
80
|
+
}
|
|
81
|
+
interface TraceInput {
|
|
82
|
+
type: TraceEventType;
|
|
83
|
+
outcome?: TraceEvent['outcome'];
|
|
84
|
+
tool?: string;
|
|
85
|
+
agent?: TraceEvent['agent'];
|
|
86
|
+
policy?: TraceEvent['policy'];
|
|
87
|
+
durationMs?: number;
|
|
88
|
+
error?: string;
|
|
89
|
+
metadata?: Record<string, unknown>;
|
|
90
|
+
}
|
|
91
|
+
interface TracerOptions extends SamplerOptions {
|
|
92
|
+
siteId: string;
|
|
93
|
+
bufferSize?: number;
|
|
94
|
+
sessionId?: string;
|
|
95
|
+
scrubPaths?: string[];
|
|
96
|
+
exporters?: TraceExporter[];
|
|
97
|
+
onExporterError?: (error: unknown, exporter: TraceExporter, event: TraceEvent) => void;
|
|
98
|
+
}
|
|
99
|
+
interface Tracer {
|
|
100
|
+
readonly sessionId: string;
|
|
101
|
+
emit(input: TraceInput): Promise<TraceEvent | null>;
|
|
102
|
+
list(): TraceEvent[];
|
|
103
|
+
clear(): void;
|
|
104
|
+
}
|
|
105
|
+
declare const createTracer: ({ siteId, bufferSize, sessionId, scrubPaths, exporters, onExporterError, ...samplerOptions }: TracerOptions) => Tracer;
|
|
106
|
+
|
|
107
|
+
type AuthMethodName = 'detection' | 'selfDeclaration' | 'bearer' | 'xAgentHeader' | 'extensionToken' | 'sessionLink' | 'oauth2';
|
|
108
|
+
interface AuthInput {
|
|
109
|
+
detected?: AgentIdentity | null;
|
|
110
|
+
declaration?: IdentityClaim;
|
|
111
|
+
bearerToken?: string;
|
|
112
|
+
xAgentHeader?: string;
|
|
113
|
+
extensionToken?: string;
|
|
114
|
+
sessionLinkToken?: string;
|
|
115
|
+
linkedUserId?: string;
|
|
116
|
+
oauth2AccessToken?: string;
|
|
117
|
+
oauth2Subject?: string;
|
|
118
|
+
vendorHint?: string;
|
|
119
|
+
classHint?: AgentClass;
|
|
120
|
+
}
|
|
121
|
+
interface AuthContext {
|
|
122
|
+
verifyToken?: (method: Exclude<AuthMethodName, 'detection' | 'selfDeclaration' | 'xAgentHeader'>, token: string) => Promise<VerificationResult | null>;
|
|
123
|
+
}
|
|
124
|
+
interface AuthMethod {
|
|
125
|
+
name: AuthMethodName;
|
|
126
|
+
authenticate(input: AuthInput, context: AuthContext): Promise<AgentIdentity | null>;
|
|
127
|
+
}
|
|
128
|
+
interface AuthEngineOptions {
|
|
129
|
+
methods?: AuthMethod[];
|
|
130
|
+
context?: AuthContext;
|
|
131
|
+
onTrace?: (input: TraceInput) => void;
|
|
132
|
+
}
|
|
133
|
+
declare const createAuthEngine: ({ methods, context, onTrace, }?: AuthEngineOptions) => {
|
|
134
|
+
authenticate(input: AuthInput): Promise<AgentIdentity | null>;
|
|
135
|
+
methods(): AuthMethodName[];
|
|
136
|
+
};
|
|
137
|
+
type AuthEngine = ReturnType<typeof createAuthEngine>;
|
|
138
|
+
|
|
139
|
+
interface AgentContextSnapshot {
|
|
140
|
+
identity: AgentIdentity | null;
|
|
141
|
+
source: 'detect' | 'declare' | 'authenticate' | 'cleared' | 'initial';
|
|
142
|
+
updatedAt: string | null;
|
|
143
|
+
}
|
|
144
|
+
type AgentContextListener = (snapshot: AgentContextSnapshot) => void;
|
|
145
|
+
declare const createAgentContextStore: () => {
|
|
146
|
+
snapshot(): AgentContextSnapshot;
|
|
147
|
+
set(identity: AgentIdentity | null, source: AgentContextSnapshot["source"]): void;
|
|
148
|
+
subscribe(listener: AgentContextListener): () => void;
|
|
149
|
+
};
|
|
150
|
+
type AgentContextStore = ReturnType<typeof createAgentContextStore>;
|
|
151
|
+
|
|
152
|
+
interface RateLimitRule {
|
|
153
|
+
max: number;
|
|
154
|
+
windowSeconds: number;
|
|
155
|
+
}
|
|
156
|
+
interface RateLimitResult {
|
|
157
|
+
allowed: boolean;
|
|
158
|
+
remaining: number;
|
|
159
|
+
resetAt: number;
|
|
160
|
+
}
|
|
161
|
+
interface RateLimiterStorage {
|
|
162
|
+
read(key: string): string | null;
|
|
163
|
+
write(key: string, value: string): void;
|
|
164
|
+
}
|
|
165
|
+
declare const createRateLimiter: (storage?: RateLimiterStorage) => {
|
|
166
|
+
consume(key: string, rule: RateLimitRule, now?: number): RateLimitResult;
|
|
167
|
+
};
|
|
168
|
+
type RateLimiter = ReturnType<typeof createRateLimiter>;
|
|
169
|
+
|
|
170
|
+
interface EvaluateInput {
|
|
171
|
+
tool: string;
|
|
172
|
+
identity: AgentIdentity | null;
|
|
173
|
+
}
|
|
174
|
+
interface PolicyEngineOptions {
|
|
175
|
+
rateLimiter?: RateLimiter;
|
|
176
|
+
}
|
|
177
|
+
declare const createPolicyEngine: (initial?: PolicyRule[], options?: PolicyEngineOptions) => {
|
|
178
|
+
set(next: PolicyRule[]): void;
|
|
179
|
+
list(): PolicyRule[];
|
|
180
|
+
evaluate({ tool, identity }: EvaluateInput): PolicyEvaluation;
|
|
181
|
+
};
|
|
182
|
+
type PolicyEngine = ReturnType<typeof createPolicyEngine>;
|
|
183
|
+
|
|
184
|
+
interface PolicyCacheOptions {
|
|
185
|
+
gatewayUrl: string;
|
|
186
|
+
siteId: string;
|
|
187
|
+
publishableKey: string;
|
|
188
|
+
fetcher?: typeof fetch;
|
|
189
|
+
}
|
|
190
|
+
interface PolicyCacheSnapshot {
|
|
191
|
+
policies: PolicyRule[];
|
|
192
|
+
etag: string | null;
|
|
193
|
+
}
|
|
194
|
+
declare const createPolicyCache: ({ gatewayUrl, siteId, publishableKey, fetcher, }: PolicyCacheOptions) => {
|
|
195
|
+
snapshot(): PolicyCacheSnapshot;
|
|
196
|
+
sync(): Promise<PolicyCacheSnapshot>;
|
|
197
|
+
};
|
|
198
|
+
type PolicyCache = ReturnType<typeof createPolicyCache>;
|
|
199
|
+
|
|
200
|
+
interface MemoryGetOptions {
|
|
201
|
+
scope?: MemoryScope;
|
|
202
|
+
}
|
|
203
|
+
interface MemorySetOptions {
|
|
204
|
+
scope?: MemoryScope;
|
|
205
|
+
ttlSeconds?: number;
|
|
206
|
+
}
|
|
207
|
+
interface MemoryStoreOptions {
|
|
208
|
+
onTrace?: (input: TraceInput) => void;
|
|
209
|
+
}
|
|
210
|
+
declare const createMemoryStore: (options?: MemoryStoreOptions) => {
|
|
211
|
+
get: (key: string, options?: MemoryGetOptions) => unknown;
|
|
212
|
+
set: (key: string, value: unknown, options?: MemorySetOptions) => MemoryEntry;
|
|
213
|
+
remove: (key: string, options?: MemoryGetOptions) => void;
|
|
214
|
+
list: (options?: MemoryGetOptions) => MemoryEntry[];
|
|
215
|
+
clear: (options?: MemoryGetOptions) => void;
|
|
216
|
+
};
|
|
217
|
+
type MemoryStore = ReturnType<typeof createMemoryStore>;
|
|
218
|
+
|
|
219
|
+
interface SiteMemoryStoreOptions {
|
|
220
|
+
initial?: Partial<SiteMemory>;
|
|
221
|
+
onTrace?: (input: TraceInput) => void;
|
|
222
|
+
}
|
|
223
|
+
interface ProvideForPageInput {
|
|
224
|
+
path: string;
|
|
225
|
+
payload: Record<string, unknown>;
|
|
226
|
+
}
|
|
227
|
+
type SiteMemoryListener = (snapshot: SiteMemory) => void;
|
|
228
|
+
declare const createSiteMemoryStore: (options?: SiteMemoryStoreOptions) => {
|
|
229
|
+
provide: (next: Partial<SiteMemory>) => SiteMemory;
|
|
230
|
+
update: (path: string, value: unknown) => SiteMemory;
|
|
231
|
+
provideForPage: (input: ProvideForPageInput) => SiteMemoryPageContext;
|
|
232
|
+
snapshot: () => SiteMemory;
|
|
233
|
+
get: (path?: string) => unknown;
|
|
234
|
+
getForPage: (path: string) => SiteMemoryPageContext | null;
|
|
235
|
+
replace: (next: SiteMemory) => SiteMemory;
|
|
236
|
+
subscribe: (listener: SiteMemoryListener) => (() => void);
|
|
237
|
+
};
|
|
238
|
+
type SiteMemoryStore = ReturnType<typeof createSiteMemoryStore>;
|
|
239
|
+
|
|
240
|
+
interface MemoryCacheOptions {
|
|
241
|
+
gatewayUrl: string;
|
|
242
|
+
siteId: string;
|
|
243
|
+
publishableKey: string;
|
|
244
|
+
fetcher?: typeof fetch;
|
|
245
|
+
}
|
|
246
|
+
interface MemoryCacheSnapshot {
|
|
247
|
+
memory: SiteMemory | null;
|
|
248
|
+
etag: string | null;
|
|
249
|
+
}
|
|
250
|
+
declare const createMemoryCache: ({ gatewayUrl, siteId, publishableKey, fetcher, }: MemoryCacheOptions) => {
|
|
251
|
+
snapshot(): MemoryCacheSnapshot;
|
|
252
|
+
sync(): Promise<MemoryCacheSnapshot>;
|
|
253
|
+
};
|
|
254
|
+
type MemoryCache = ReturnType<typeof createMemoryCache>;
|
|
255
|
+
|
|
256
|
+
interface GovernedTool<Input = unknown, Output = unknown> {
|
|
257
|
+
name: string;
|
|
258
|
+
version?: string;
|
|
259
|
+
group?: string;
|
|
260
|
+
description?: string;
|
|
261
|
+
inputSchema?: Record<string, unknown>;
|
|
262
|
+
stage?: string;
|
|
263
|
+
authz?: Omit<PolicyRule, 'id' | 'tool'>;
|
|
264
|
+
rateLimit?: PolicyRule['rateLimit'];
|
|
265
|
+
execute: (input: Input, context: {
|
|
266
|
+
identity: AgentIdentity | null;
|
|
267
|
+
}) => Promise<Output> | Output;
|
|
268
|
+
}
|
|
269
|
+
interface ToolRegistryOptions {
|
|
270
|
+
evaluate: (tool: string, options?: {
|
|
271
|
+
identity?: AgentIdentity | null;
|
|
272
|
+
}) => Promise<PolicyEvaluation>;
|
|
273
|
+
setPolicies?: (rules: PolicyRule[]) => void;
|
|
274
|
+
listPolicies?: () => PolicyRule[];
|
|
275
|
+
onTrace?: (input: TraceInput) => void;
|
|
276
|
+
}
|
|
277
|
+
interface ToolRegistry {
|
|
278
|
+
register(tool: GovernedTool): () => void;
|
|
279
|
+
unregister(name: string): void;
|
|
280
|
+
enable(name: string): void;
|
|
281
|
+
disable(name: string): void;
|
|
282
|
+
isEnabled(name: string): boolean;
|
|
283
|
+
list(options?: {
|
|
284
|
+
includeDisabled?: boolean;
|
|
285
|
+
}): GovernedTool[];
|
|
286
|
+
get(name: string): GovernedTool | undefined;
|
|
287
|
+
execute<Input, Output>(name: string, input: Input, identity?: AgentIdentity | null): Promise<Output>;
|
|
288
|
+
}
|
|
289
|
+
declare const createToolRegistry: ({ evaluate, setPolicies, listPolicies, onTrace, }: ToolRegistryOptions) => ToolRegistry;
|
|
290
|
+
|
|
291
|
+
interface ProgressionTransition {
|
|
292
|
+
on: string;
|
|
293
|
+
to: string;
|
|
294
|
+
}
|
|
295
|
+
interface ProgressionStage {
|
|
296
|
+
name: string;
|
|
297
|
+
enables?: string[];
|
|
298
|
+
transitions?: ProgressionTransition[];
|
|
299
|
+
}
|
|
300
|
+
interface ProgressionConfig {
|
|
301
|
+
initial: string;
|
|
302
|
+
stages: ProgressionStage[];
|
|
303
|
+
}
|
|
304
|
+
interface ProgressionStore {
|
|
305
|
+
current(): string;
|
|
306
|
+
enabledStages(): string[];
|
|
307
|
+
notify(toolName: string): {
|
|
308
|
+
changed: boolean;
|
|
309
|
+
from: string;
|
|
310
|
+
to: string;
|
|
311
|
+
};
|
|
312
|
+
set(stage: string): {
|
|
313
|
+
changed: boolean;
|
|
314
|
+
from: string;
|
|
315
|
+
to: string;
|
|
316
|
+
};
|
|
317
|
+
reset(): void;
|
|
318
|
+
snapshot(): {
|
|
319
|
+
current: string;
|
|
320
|
+
enabled: string[];
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
declare const createProgressionStore: (config: ProgressionConfig, options?: {
|
|
324
|
+
onTrace?: (input: TraceInput) => void;
|
|
325
|
+
}) => ProgressionStore;
|
|
326
|
+
|
|
327
|
+
interface SurfacingContext {
|
|
328
|
+
identity: AgentIdentity | null;
|
|
329
|
+
stage?: string | null;
|
|
330
|
+
enabledStages?: string[];
|
|
331
|
+
}
|
|
332
|
+
interface SurfacingDecision {
|
|
333
|
+
tool: GovernedTool;
|
|
334
|
+
visible: boolean;
|
|
335
|
+
reason: string;
|
|
336
|
+
}
|
|
337
|
+
declare const decideSurfacing: (tool: GovernedTool, context: SurfacingContext) => SurfacingDecision;
|
|
338
|
+
declare const surfaceTools: (tools: GovernedTool[], context: SurfacingContext) => GovernedTool[];
|
|
339
|
+
declare const explainSurfacing: (tools: GovernedTool[], context: SurfacingContext) => SurfacingDecision[];
|
|
340
|
+
|
|
341
|
+
declare const DEFAULT_GROUP = "default";
|
|
342
|
+
interface ToolGroupSummary {
|
|
343
|
+
name: string;
|
|
344
|
+
tools: GovernedTool[];
|
|
345
|
+
}
|
|
346
|
+
declare const groupTools: (tools: GovernedTool[]) => ToolGroupSummary[];
|
|
347
|
+
declare const listGroupNames: (tools: GovernedTool[]) => string[];
|
|
348
|
+
|
|
349
|
+
interface ToolTokenEstimate {
|
|
350
|
+
name: string;
|
|
351
|
+
characters: number;
|
|
352
|
+
tokens: number;
|
|
353
|
+
}
|
|
354
|
+
interface TokenBudgetReport {
|
|
355
|
+
total: number;
|
|
356
|
+
perTool: ToolTokenEstimate[];
|
|
357
|
+
}
|
|
358
|
+
declare const estimateToolTokens: (tool: GovernedTool) => ToolTokenEstimate;
|
|
359
|
+
declare const estimateBudget: (tools: GovernedTool[]) => TokenBudgetReport;
|
|
360
|
+
|
|
361
|
+
interface WebMcpToolDescriptor {
|
|
362
|
+
name: string;
|
|
363
|
+
description?: string;
|
|
364
|
+
inputSchema?: Record<string, unknown>;
|
|
365
|
+
invoke(input?: unknown): Promise<unknown>;
|
|
366
|
+
}
|
|
367
|
+
interface WebMcpProvider {
|
|
368
|
+
provideContext(payload: {
|
|
369
|
+
tools: WebMcpToolDescriptor[];
|
|
370
|
+
}): {
|
|
371
|
+
revoke: () => void;
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
interface WebMcpAdapterOptions {
|
|
375
|
+
provider?: WebMcpProvider;
|
|
376
|
+
doc?: {
|
|
377
|
+
defaultView?: WindowLike | null;
|
|
378
|
+
} | null;
|
|
379
|
+
invoke?: (tool: GovernedTool, input: unknown) => Promise<unknown>;
|
|
380
|
+
}
|
|
381
|
+
interface WindowLike {
|
|
382
|
+
navigator?: {
|
|
383
|
+
modelContext?: WebMcpProvider;
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
interface WebMcpAdapter {
|
|
387
|
+
publish(tools: GovernedTool[]): {
|
|
388
|
+
revoked: boolean;
|
|
389
|
+
};
|
|
390
|
+
revoke(): void;
|
|
391
|
+
available(): boolean;
|
|
392
|
+
}
|
|
393
|
+
declare const createWebMcpAdapter: (options?: WebMcpAdapterOptions) => WebMcpAdapter;
|
|
394
|
+
|
|
395
|
+
interface InitOptions {
|
|
396
|
+
publishableKey: string;
|
|
397
|
+
siteId?: string;
|
|
398
|
+
/**
|
|
399
|
+
* Override the gateway URL the SDK calls. **Reserved for local development
|
|
400
|
+
* only** — the only accepted values are `localhost` / `127.0.0.1` URLs (so
|
|
401
|
+
* `pnpm dev` against a local gateway works). Any other value throws at
|
|
402
|
+
* `init()` time.
|
|
403
|
+
*
|
|
404
|
+
* Production deployments must omit this option. The SDK is hard-coded to
|
|
405
|
+
* call `https://gateway.agentronics.dev`. Custom backends are not
|
|
406
|
+
* supported, by design — see the project README + LICENSE NOTICE.
|
|
407
|
+
*
|
|
408
|
+
* @internal — kept on the public type only so dev tooling type-checks.
|
|
409
|
+
*/
|
|
410
|
+
gatewayUrl?: string;
|
|
411
|
+
debug?: boolean;
|
|
412
|
+
policies?: PolicyRule[];
|
|
413
|
+
siteMemory?: Partial<SiteMemory>;
|
|
414
|
+
auth?: AuthContext;
|
|
415
|
+
progression?: ProgressionConfig;
|
|
416
|
+
tools?: GovernedTool[];
|
|
417
|
+
trace?: {
|
|
418
|
+
enabled?: boolean;
|
|
419
|
+
bufferSize?: number;
|
|
420
|
+
traceRate?: number;
|
|
421
|
+
errorRate?: number;
|
|
422
|
+
scrubPaths?: string[];
|
|
423
|
+
exporters?: TraceExporter[];
|
|
424
|
+
gateway?: boolean;
|
|
425
|
+
webhookUrl?: string;
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
interface AgentronicsClient {
|
|
429
|
+
readonly publishableKey: string;
|
|
430
|
+
readonly siteId: string;
|
|
431
|
+
readonly gatewayUrl: string;
|
|
432
|
+
readonly debug: boolean;
|
|
433
|
+
readonly memory: MemoryStore;
|
|
434
|
+
readonly siteMemory: SiteMemoryStore;
|
|
435
|
+
readonly memoryCache: MemoryCache;
|
|
436
|
+
readonly tracer: Tracer;
|
|
437
|
+
readonly auth: AuthEngine;
|
|
438
|
+
readonly agentContext: AgentContextStore;
|
|
439
|
+
readonly authz: PolicyEngine;
|
|
440
|
+
readonly policyCache: PolicyCache;
|
|
441
|
+
readonly tools: ToolRegistry;
|
|
442
|
+
readonly progression: ProgressionStore | null;
|
|
443
|
+
readonly webmcp: WebMcpAdapter;
|
|
444
|
+
detect(options?: DetectAgentOptions): Promise<AgentIdentity | null>;
|
|
445
|
+
authenticate(input: AuthInput): Promise<AgentIdentity | null>;
|
|
446
|
+
presentIdentity(input: PresentIdentityOptions): PresentedIdentity;
|
|
447
|
+
clearIdentity(): void;
|
|
448
|
+
presentedIdentity(): PresentedIdentity | null;
|
|
449
|
+
setPolicies(rules: PolicyRule[]): void;
|
|
450
|
+
listPolicies(): PolicyRule[];
|
|
451
|
+
evaluate(tool: string, options?: {
|
|
452
|
+
identity?: AgentIdentity | null;
|
|
453
|
+
}): Promise<PolicyEvaluation>;
|
|
454
|
+
syncPolicies(): Promise<PolicyRule[]>;
|
|
455
|
+
syncSiteMemory(): Promise<SiteMemory | null>;
|
|
456
|
+
provideSiteMemory(memory: Partial<SiteMemory>): SiteMemory;
|
|
457
|
+
provideForPage(input: ProvideForPageInput): void;
|
|
458
|
+
installMemoryDelivery(options?: {
|
|
459
|
+
metaTags?: boolean;
|
|
460
|
+
overlay?: boolean;
|
|
461
|
+
}): {
|
|
462
|
+
uninstall: () => void;
|
|
463
|
+
};
|
|
464
|
+
fetchWellKnown(origin?: string): Promise<SiteMemory | null>;
|
|
465
|
+
installDomEnforcer(): {
|
|
466
|
+
uninstall: () => void;
|
|
467
|
+
};
|
|
468
|
+
registerTool(tool: GovernedTool): () => void;
|
|
469
|
+
surfaceTools(options?: {
|
|
470
|
+
identity?: AgentIdentity | null;
|
|
471
|
+
}): GovernedTool[];
|
|
472
|
+
explainSurfacing(options?: {
|
|
473
|
+
identity?: AgentIdentity | null;
|
|
474
|
+
}): SurfacingDecision[];
|
|
475
|
+
groupedTools(options?: {
|
|
476
|
+
identity?: AgentIdentity | null;
|
|
477
|
+
}): ToolGroupSummary[];
|
|
478
|
+
estimateTokens(options?: {
|
|
479
|
+
identity?: AgentIdentity | null;
|
|
480
|
+
}): TokenBudgetReport;
|
|
481
|
+
publishToWebMcp(options?: {
|
|
482
|
+
identity?: AgentIdentity | null;
|
|
483
|
+
}): {
|
|
484
|
+
revoked: boolean;
|
|
485
|
+
surfaced: number;
|
|
486
|
+
};
|
|
487
|
+
notifyToolInvoked(toolName: string): void;
|
|
488
|
+
traces(): TraceEvent[];
|
|
489
|
+
clearTraces(): void;
|
|
490
|
+
/**
|
|
491
|
+
* Sanity-check the publishable key + gateway URL. Hits `GET /v1/health` and
|
|
492
|
+
* resolves to `{ ok: true, ... }` on 2xx, `{ ok: false, status, error }`
|
|
493
|
+
* otherwise. Doesn't throw — designed for "did my key wire up correctly?"
|
|
494
|
+
* UX without forcing the host page into a try/catch.
|
|
495
|
+
*/
|
|
496
|
+
ping(): Promise<{
|
|
497
|
+
ok: true;
|
|
498
|
+
status: number;
|
|
499
|
+
body: unknown;
|
|
500
|
+
} | {
|
|
501
|
+
ok: false;
|
|
502
|
+
status: number;
|
|
503
|
+
error: string;
|
|
504
|
+
}>;
|
|
505
|
+
}
|
|
506
|
+
declare const init: (options: InitOptions) => AgentronicsClient;
|
|
507
|
+
|
|
508
|
+
export { createProgressionStore as $, type AgentronicsClient as A, type ToolGroupSummary as B, type ToolRegistry as C, type DetectAgentOptions as D, type ToolTokenEstimate as E, type TraceInput as F, type GovernedTool as G, type Tracer as H, type InitOptions as I, type WebMcpAdapterOptions as J, type WebMcpProvider as K, type WebMcpToolDescriptor as L, type MemoryCache as M, bundledDetectors as N, createAgentContextStore as O, type PolicyEngine as P, createAuthEngine as Q, type RateLimiter as R, type SiteMemoryListener as S, type TraceExporter as T, createDetectorRegistry as U, createIdentityStore as V, type WebMcpAdapter as W, createMemoryCache as X, createMemoryStore as Y, createPolicyCache as Z, createPolicyEngine as _, type AgentContextListener as a, createRateLimiter as a0, createSiteMemoryStore as a1, createToolRegistry as a2, createTracer as a3, createWebMcpAdapter as a4, decideSurfacing as a5, detectAgent as a6, detectDom as a7, estimateBudget as a8, estimateToolTokens as a9, explainSurfacing as aa, groupTools as ab, init as ac, listGroupNames as ad, surfaceTools as ae, type AgentContextSnapshot as b, type AgentContextStore as c, type AuthEngine as d, type AuthInput as e, type AuthMethod as f, DEFAULT_GROUP as g, type DetectDomOptions as h, type Detector as i, type DetectorRegistry as j, type DetectorStatus as k, type DomSignalName as l, type IdentityStore as m, type MemoryStore as n, type PolicyCache as o, type PresentIdentityOptions as p, type PresentedIdentity as q, type ProgressionConfig as r, type ProgressionStage as s, type ProgressionStore as t, type ProgressionTransition as u, type ProvideForPageInput as v, type SiteMemoryStore as w, type SurfacingContext as x, type SurfacingDecision as y, type TokenBudgetReport as z };
|