@iloveagents/foundry-agent 0.3.0 → 0.4.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.
Files changed (51) hide show
  1. package/README.md +16 -0
  2. package/dist/client/agui-runner.d.ts +53 -0
  3. package/dist/client/agui-runner.js +320 -0
  4. package/dist/client/runner-events.d.ts +54 -0
  5. package/dist/client/runner-events.js +1 -0
  6. package/dist/client/service-fetch.d.ts +112 -0
  7. package/dist/client/service-fetch.js +244 -0
  8. package/dist/index.d.ts +7 -0
  9. package/dist/index.js +10 -0
  10. package/dist/msal/auth-config.d.ts +91 -0
  11. package/dist/msal/auth-config.js +70 -0
  12. package/dist/msal/auth-store.d.ts +95 -0
  13. package/dist/msal/auth-store.js +372 -0
  14. package/dist/msal/index.d.ts +3 -0
  15. package/dist/msal/index.js +3 -0
  16. package/dist/msal/token-fetch.d.ts +16 -0
  17. package/dist/msal/token-fetch.js +57 -0
  18. package/dist/store/citation-store.d.ts +42 -0
  19. package/dist/store/citation-store.js +14 -0
  20. package/dist/store/link-store.d.ts +29 -0
  21. package/dist/store/link-store.js +28 -0
  22. package/dist/store/streaming-status-store.d.ts +15 -0
  23. package/dist/store/streaming-status-store.js +9 -0
  24. package/dist/tools/registry.d.ts +48 -0
  25. package/dist/tools/registry.js +50 -0
  26. package/package.json +23 -9
  27. package/AGENTS.md +0 -91
  28. package/CHANGELOG.md +0 -180
  29. package/CLAUDE.md +0 -1
  30. package/src/__tests__/agui-runner.test.ts +0 -404
  31. package/src/__tests__/auth-store.test.ts +0 -596
  32. package/src/__tests__/citation-store.test.ts +0 -52
  33. package/src/__tests__/client-tool-registry.test.ts +0 -84
  34. package/src/__tests__/link-store.test.ts +0 -48
  35. package/src/__tests__/service-fetch.test.ts +0 -525
  36. package/src/__tests__/streaming-status-store.test.ts +0 -22
  37. package/src/__tests__/token-fetch.test.ts +0 -134
  38. package/src/client/agui-runner.ts +0 -382
  39. package/src/client/runner-events.ts +0 -27
  40. package/src/client/service-fetch.ts +0 -318
  41. package/src/index.ts +0 -27
  42. package/src/msal/auth-config.ts +0 -150
  43. package/src/msal/auth-store.ts +0 -517
  44. package/src/msal/index.ts +0 -14
  45. package/src/msal/token-fetch.ts +0 -68
  46. package/src/store/citation-store.ts +0 -52
  47. package/src/store/link-store.ts +0 -53
  48. package/src/store/streaming-status-store.ts +0 -21
  49. package/src/tools/registry.ts +0 -112
  50. package/tsconfig.json +0 -15
  51. package/vitest.config.ts +0 -8
@@ -1,53 +0,0 @@
1
- import { createStore } from "zustand/vanilla";
2
-
3
- export interface LinkHandler {
4
- canHandle: (href: string) => boolean;
5
- normalizeHref?: (href: string) => string | null;
6
- openLink: (href: string) => void;
7
- }
8
-
9
- export interface ResolvedLinkHandler {
10
- handler: LinkHandler;
11
- href: string;
12
- }
13
-
14
- interface LinkState {
15
- /**
16
- * Latest registered handler kept for backwards-compatible consumers.
17
- * New code should use `handlers` or `resolveLinkHandler`.
18
- */
19
- handler: LinkHandler | null;
20
- handlers: LinkHandler[];
21
- setHandler: (handler: LinkHandler) => void;
22
- clear: () => void;
23
- }
24
-
25
- /**
26
- * Generic markdown-link extension point.
27
- *
28
- * Feature modules register a handler for their own deep-link namespace
29
- * (for example Spaces handles `/spaces/...`). The chat renderer stays
30
- * module-agnostic while still letting app-local links navigate in-place.
31
- */
32
- export const linkStore = createStore<LinkState>((set) => ({
33
- handler: null,
34
- handlers: [],
35
- setHandler: (handler) =>
36
- set((state) => ({
37
- handler,
38
- handlers: [...state.handlers.filter((item) => item !== handler), handler],
39
- })),
40
- clear: () => set({ handler: null, handlers: [] }),
41
- }));
42
-
43
- export function resolveLinkHandler(rawHref: string): ResolvedLinkHandler | null {
44
- const handlers = linkStore.getState().handlers;
45
- for (let i = handlers.length - 1; i >= 0; i -= 1) {
46
- const handler = handlers[i];
47
- const href = handler.normalizeHref ? handler.normalizeHref(rawHref) : rawHref;
48
- if (href && handler.canHandle(href)) {
49
- return { handler, href };
50
- }
51
- }
52
- return null;
53
- }
@@ -1,21 +0,0 @@
1
- import { createStore } from "zustand/vanilla";
2
-
3
- /** Streaming status emitted by the AG-UI runner. */
4
- export interface StreamingStatus {
5
- status: "thinking" | "calling" | "streaming" | "idle";
6
- toolName?: string;
7
- }
8
-
9
- interface StreamingStatusState {
10
- streamingStatus: StreamingStatus;
11
- setStreamingStatus: (status: StreamingStatus) => void;
12
- }
13
-
14
- /**
15
- * Vanilla store for streaming status. Use `useStore(streamingStatusStore, ...)`
16
- * from the React entry of zustand for hook-style subscriptions.
17
- */
18
- export const streamingStatusStore = createStore<StreamingStatusState>((set) => ({
19
- streamingStatus: { status: "idle" },
20
- setStreamingStatus: (streamingStatus) => set({ streamingStatus }),
21
- }));
@@ -1,112 +0,0 @@
1
- import { createStore } from "zustand/vanilla";
2
- import type { Tool as AGUITool } from "@ag-ui/core";
3
-
4
- /**
5
- * Dynamic Client Tool Registry — vanilla zustand store for client-side AG-UI
6
- * tools.
7
- *
8
- * Tools are split into two categories:
9
- * - **Global tools**: always available (navigate, set_theme, open_panel, ...)
10
- * - **Page tools**: registered by the active page via the host shell, removed
11
- * on unmount.
12
- *
13
- * The runner reads from this store on every request to get the current tool
14
- * schemas and executors. Pages declare their capabilities by calling
15
- * `registerPageTools()` — no need to edit core files.
16
- */
17
- export interface ClientToolEntry {
18
- /** Tool name (must be unique across global + page tools) */
19
- name: string;
20
- /** Tool description for the LLM */
21
- description: string;
22
- /** JSON Schema for tool parameters */
23
- parameters: Record<string, unknown>;
24
- /** Execution function — called by the runner at TOOL_CALL_END */
25
- execute: (argsJson: string) => Promise<string>;
26
- }
27
-
28
- interface ClientToolRegistryState {
29
- globalTools: Map<string, ClientToolEntry>;
30
- pageTools: Map<string, ClientToolEntry>;
31
-
32
- /** Register a global tool (called once at app init) */
33
- registerGlobal: (tool: ClientToolEntry) => void;
34
-
35
- /** Register page-scoped tools (called by the host on mount) */
36
- registerPageTools: (tools: ClientToolEntry[]) => void;
37
-
38
- /** Remove page-scoped tools (called by the host on unmount) */
39
- clearPageTools: () => void;
40
-
41
- /** Get all active tool schemas for the runner */
42
- getActiveSchemas: () => AGUITool[];
43
-
44
- /** Check if a tool name is registered */
45
- isRegistered: (name: string) => boolean;
46
-
47
- /** Execute a registered tool by name */
48
- executeTool: (name: string, argsJson: string) => Promise<string>;
49
- }
50
-
51
- export const clientToolRegistry = createStore<ClientToolRegistryState>((set, get) => ({
52
- globalTools: new Map(),
53
- pageTools: new Map(),
54
-
55
- registerGlobal: (tool) => {
56
- const { globalTools } = get();
57
- const next = new Map(globalTools);
58
- next.set(tool.name, tool);
59
- set({ globalTools: next });
60
- },
61
-
62
- registerPageTools: (tools) => {
63
- const next = new Map<string, ClientToolEntry>();
64
- for (const tool of tools) {
65
- next.set(tool.name, tool);
66
- }
67
- set({ pageTools: next });
68
- },
69
-
70
- clearPageTools: () => {
71
- set({ pageTools: new Map() });
72
- },
73
-
74
- getActiveSchemas: () => {
75
- const { globalTools, pageTools } = get();
76
- // Merge: page tools override global tools with the same name
77
- const merged = new Map<string, ClientToolEntry>();
78
- for (const tool of globalTools.values()) {
79
- merged.set(tool.name, tool);
80
- }
81
- for (const tool of pageTools.values()) {
82
- merged.set(tool.name, tool); // page overrides global
83
- }
84
- return Array.from(merged.values()).map((tool) => ({
85
- name: tool.name,
86
- description: tool.description,
87
- parameters: tool.parameters,
88
- }));
89
- },
90
-
91
- isRegistered: (name) => {
92
- const { globalTools, pageTools } = get();
93
- return pageTools.has(name) || globalTools.has(name);
94
- },
95
-
96
- executeTool: async (name, argsJson) => {
97
- const { globalTools, pageTools } = get();
98
- // Page tools take precedence
99
- const tool = pageTools.get(name) ?? globalTools.get(name);
100
- if (!tool) {
101
- return JSON.stringify({ error: `Unknown client tool: ${name}` });
102
- }
103
- return tool.execute(argsJson);
104
- },
105
- }));
106
-
107
- /** Read-only registry view — what the runner consumes. */
108
- export interface ToolRegistry {
109
- isRegistered: (name: string) => boolean;
110
- executeTool: (name: string, argsJson: string) => Promise<string>;
111
- getActiveSchemas: () => AGUITool[];
112
- }
package/tsconfig.json DELETED
@@ -1,15 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "ESNext",
5
- "moduleResolution": "bundler",
6
- "strict": true,
7
- "skipLibCheck": true,
8
- "resolveJsonModule": true,
9
- "esModuleInterop": true,
10
- "allowImportingTsExtensions": true,
11
- "noEmit": true
12
- },
13
- "include": ["src/**/*"],
14
- "exclude": ["node_modules"]
15
- }
package/vitest.config.ts DELETED
@@ -1,8 +0,0 @@
1
- import { defineConfig } from "vitest/config";
2
-
3
- export default defineConfig({
4
- test: {
5
- environment: "jsdom",
6
- include: ["src/**/*.test.{ts,tsx}"],
7
- },
8
- });