open-agentic-web 0.0.0-stage β†’ 1.0.1

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 ADDED
@@ -0,0 +1,17 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ Copyright 2026 Open Agentic Web Community / TripSteward Authors
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,287 @@
1
- # Temporary Holding Version
1
+ # 🌐 Open Agentic Web SDK (`open-agentic-web`)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![npm version](https://img.shields.io/badge/npm-v1.0.1-blue.svg)](https://www.npmjs.com/package/open-agentic-web)
4
+ [![License](https://img.shields.io/badge/License-Apache_2.0-green.svg)](https://opensource.org/licenses/Apache-2.0)
5
+ [![Specification](https://img.shields.io/badge/Spec-Open%20Agentic%20Web%20MVP%200.3-orange.svg)](https://cognizant-ai-labs.github.io/agentic-web/specs/mvp-v0.3.json)
6
+
7
+ The **Open Agentic Web SDK** (`open-agentic-web`) is the official developer toolkit, conformance linter, and in-browser runtime for building, validating, and federating autonomous web agents.
8
+
9
+ Compliant with the **Cognizant AI Lab / Mozilla Otari / MIT NANDA Open Agentic Web (MVP Profile 0.3)** specification.
10
+
11
+ ---
12
+
13
+ ## ⚑ Why `open-agentic-web`?
14
+
15
+ In the emerging Agentic Web, AI agents don't just chatβ€”they act directly on websites on behalf of users, discovering inventory, holding reservations, and issuing tickets across independent domains without aggregator markups.
16
+
17
+ Building a conforming agentic website previously required manually writing repetitive boilerplate:
18
+ 1. **Manifest & Network validation**: No standard CLI existed to verify whether your `agent-manifest.json` or `*.network.json` met the Open Agentic Web specification.
19
+ 2. **Action tool validation**: Tools called by LLMs (`website_*`) lacked standard runtime JSON schema enforcement and effect classification (`read` vs `irreversible`).
20
+ 3. **Cross-origin iframe bridging**: Implementing secure postMessage handshakes and MessageChannels for `bridge/action-bridge.html` required hundreds of lines of fragile glue code.
21
+ 4. **Dynamic Swarm Federation**: No reusable client existed to discover, consent-check, and mount remote agent nodes in browser RAM on the fly.
22
+
23
+ `open-agentic-web` provides a **zero-dependency**, universal toolkit for all of these needs.
24
+
25
+ ---
26
+
27
+ ## πŸ“¦ Installation
28
+
29
+ ```bash
30
+ # Install globally or as a dev dependency for CLI validation
31
+ npm install -D open-agentic-web
32
+
33
+ # Or use directly with npx
34
+ npx open-agentic-web validate .
35
+ ```
36
+
37
+ ---
38
+
39
+ ## πŸš€ 1. Conformance Linter & CLI (`oaw` / `open-agentic-web`)
40
+
41
+ Validate any agentic website or scaffold a brand-new conforming node in seconds.
42
+
43
+ ### Validate Conformance
44
+ Run automated checks against `agent-manifest.json`, declarative `*.network.json` graphs, `bridge/action-bridge.html`, and `site-actions.js`:
45
+
46
+ ```bash
47
+ # Validate current directory
48
+ npx open-agentic-web validate .
49
+
50
+ # Validate multiple agent nodes
51
+ npx oaw validate sites/hub sites/mobility sites/ticketing
52
+ ```
53
+
54
+ Output:
55
+ ```text
56
+ ✈️ Running Open Agentic Web Conformance Linter
57
+
58
+ Testing Node: ./sites/tripsteward-hub
59
+ βœ… PASS: Contains 'agent-manifest.json'
60
+ βœ… PASS: Manifest declares valid name or brand ('HarborView Hotel')
61
+ βœ… PASS: Network[0] declares 'front_man' (travel_concierge)
62
+ βœ… PASS: Referenced network file exists: ./tripsteward_concierge.network.json
63
+ βœ… PASS: Manifest declares 'llm_router' with valid 'base_url'
64
+ βœ… PASS: Node provides 'bridge/action-bridge.html' for cross-origin tool execution
65
+ βœ… PASS: Front agent 'travel_concierge' has grounded instructions
66
+ βœ… PASS: site-actions provides registered action tools (7 declared)
67
+
68
+ All nodes conform 100% to Open Agentic Web MVP Profile 0.3!
69
+ ```
70
+
71
+ ### Validate Federated Mesh
72
+ Verify cross-site peer link mappings and compatibility between an orchestrator hub and peer nodes:
73
+
74
+ ```bash
75
+ npx oaw federation sites/hub sites/mobility sites/ticketing
76
+ ```
77
+
78
+ ### Scaffold a New Agentic Web Node
79
+ Generate a conforming node structure ready to deploy on any static host:
80
+
81
+ ```bash
82
+ npx oaw init my-dining-node --name "tablebespoke_dining"
83
+ ```
84
+
85
+ Generates:
86
+ ```text
87
+ my-dining-node/
88
+ β”œβ”€β”€ agent-manifest.json # Machine discovery root
89
+ β”œβ”€β”€ tablebespoke_dining.network.json # Declarative Neuro SAN agent graph
90
+ β”œβ”€β”€ site-actions.js # Executable JavaScript tools (website_*)
91
+ β”œβ”€β”€ bridge/
92
+ β”‚ └── action-bridge.html # Sandboxed cross-origin iframe bridge
93
+ └── links.json # Peer network resolution map
94
+ ```
95
+
96
+ ---
97
+
98
+ ## πŸ› οΈ 2. Site Actions Framework (`open-agentic-web/actions`)
99
+
100
+ Define grounded, machine-executable action tools with built-in JSON schema validation and effect tagging.
101
+
102
+ ```javascript
103
+ import { defineAction, createActionRegistry } from "open-agentic-web";
104
+
105
+ export class SiteActions {
106
+ static registerActions(registry) {
107
+ // 1. Read-only action (safe query, no confirmation needed)
108
+ registry.register(
109
+ defineAction({
110
+ name: "website_search_availability",
111
+ description: "Search open slots by category and party size.",
112
+ effect: "read", // "read" | "irreversible" | "undoable"
113
+ inputSchema: {
114
+ type: "object",
115
+ properties: {
116
+ category: { type: "string" },
117
+ party_size: { type: "integer", minimum: 1 }
118
+ },
119
+ required: ["party_size"],
120
+ additionalProperties: false
121
+ },
122
+ execute: async (args) => {
123
+ return {
124
+ ok: true,
125
+ available_slots: [
126
+ { time: "7:00 PM", table: "Patio A" }
127
+ ]
128
+ };
129
+ }
130
+ })
131
+ );
132
+
133
+ // 2. Irreversible action (enforces human confirmation before execution)
134
+ registry.register(
135
+ defineAction({
136
+ name: "website_commit_booking",
137
+ description: "Commit binding reservation with direct provider.",
138
+ effect: "irreversible",
139
+ inputSchema: {
140
+ type: "object",
141
+ properties: {
142
+ slot_id: { type: "string" },
143
+ guest_name: { type: "string" }
144
+ },
145
+ required: ["slot_id", "guest_name"],
146
+ additionalProperties: false
147
+ },
148
+ execute: async (args) => {
149
+ const bookingId = "BOOK-" + Math.floor(1000 + Math.random() * 9000);
150
+ return { ok: true, booking_id: bookingId, status: "CONFIRMED_DIRECT" };
151
+ }
152
+ })
153
+ );
154
+ }
155
+ }
156
+ ```
157
+
158
+ ---
159
+
160
+ ## πŸŒ‰ 3. Sandboxed Action Bridge (`open-agentic-web/bridge`)
161
+
162
+ Enable parent orchestrators to execute your site tools from an iframe using the standard `nsdeploy-actions-v1` protocol.
163
+
164
+ ### In `bridge/action-bridge.html`:
165
+ ```html
166
+ <!doctype html>
167
+ <html lang="en">
168
+ <head>
169
+ <meta charset="utf-8">
170
+ <title>Action Bridge</title>
171
+ <!-- Browser Import Map for static hosting without bundlers -->
172
+ <script type="importmap">
173
+ {
174
+ "imports": {
175
+ "open-agentic-web": "https://esm.sh/open-agentic-web@1.0.0",
176
+ "open-agentic-web/": "https://esm.sh/open-agentic-web@1.0.0/"
177
+ }
178
+ }
179
+ </script>
180
+ <script type="module">
181
+ import { createActionRegistry, setupActionBridge } from "open-agentic-web";
182
+ import { SiteActions } from "../site-actions.js";
183
+
184
+ const registry = createActionRegistry();
185
+ SiteActions.registerActions(registry);
186
+
187
+ // Listens for postMessage and MessageChannel handshakes from orchestrators
188
+ // Enforces human confirmation dialog for irreversible actions
189
+ setupActionBridge({
190
+ registry,
191
+ onConfirm: async ({ action, arguments: args, origin }) => {
192
+ return window.confirm(`Authorize action '${action}' requested by ${origin}?`);
193
+ }
194
+ });
195
+ </script>
196
+ </head>
197
+ <body></body>
198
+ </html>
199
+ ```
200
+
201
+ ### In Orchestrator Client:
202
+ ```javascript
203
+ import { createActionBridgeClient } from "open-agentic-web";
204
+
205
+ const client = createActionBridgeClient({
206
+ bridgeUrl: "https://partner-site.com/bridge/action-bridge.html",
207
+ brand: "Partner Transfers"
208
+ });
209
+
210
+ // Calls remote site action over sandboxed MessagePort
211
+ const quote = await client.execute("website_quote_transfer", {
212
+ destination: "HarborView Hotel",
213
+ flight_number: "UA 482"
214
+ });
215
+ ```
216
+
217
+ ---
218
+
219
+ ## 🌐 4. Dynamic Federation & In-Browser LLM Runtime (`open-agentic-web/federation`)
220
+
221
+ Mount third-party agentic web nodes on the fly in browser RAM and execute autonomous agent turns with tool-calling:
222
+
223
+ ```javascript
224
+ import { AgentSwarm } from "open-agentic-web";
225
+
226
+ const swarm = new AgentSwarm({
227
+ defaultRouter: "https://api.otari.ai/api/v1",
228
+ defaultModel: "alibaba/qwen3.8-flash"
229
+ });
230
+
231
+ // 1. Mount an external specialist node with interactive user consent
232
+ await swarm.mountFromUrl("https://partner-dining.com", {
233
+ onConsent: async ({ candidate, origin }) => {
234
+ return window.confirm(`Allow agent '${candidate.name}' from ${origin} to join your journey?`);
235
+ }
236
+ });
237
+
238
+ // 2. Search active specialist nodes in the swarm
239
+ const diningAgents = swarm.search({ category: "Dining" });
240
+
241
+ // 3. Execute an autonomous multi-step turn with BYOK LLM tool-calling
242
+ const turnResult = await swarm.runTurn({
243
+ prompt: "Find a waterfront dinner table for 2 guests around 7 PM",
244
+ apiKey: "otk_my_key", // Visitor's BYOK key
245
+ actionExecutor: async (toolName, args) => {
246
+ return client.execute(toolName, args);
247
+ },
248
+ onStep: ({ step, tool, arguments: args, result }) => {
249
+ console.log(`[Step ${step}] Executed ${tool}:`, result);
250
+ }
251
+ });
252
+
253
+ console.log("Agent response:", turnResult.text);
254
+
255
+ // 4. Export current peer mappings to links.json format
256
+ const linksConfig = swarm.exportLinks("my_hub_network");
257
+ });
258
+
259
+ // Search active specialist nodes in the swarm
260
+ const diningAgents = swarm.search({ category: "Dining" });
261
+
262
+ // Export current peer mappings to links.json format
263
+ const linksConfig = swarm.exportLinks("my_hub_network");
264
+ ```
265
+
266
+ ---
267
+
268
+ ## πŸ“‹ API Reference
269
+
270
+ | Module | Export | Description |
271
+ |---|---|---|
272
+ | `open-agentic-web/validator` | `validateNode(dir)` | End-to-end conformance validator for an agentic web node |
273
+ | `open-agentic-web/validator` | `validateManifest(json)` | Validates `agent-manifest.json` against MVP Profile 0.3 |
274
+ | `open-agentic-web/validator` | `validateNetwork(json)` | Validates declarative `*.network.json` graph |
275
+ | `open-agentic-web/validator` | `validateFederation(hub, peers)` | Validates multi-site federated mesh and link mappings |
276
+ | `open-agentic-web/actions` | `defineAction(def)` | Defines action tool with runtime argument schema validation |
277
+ | `open-agentic-web/actions` | `createActionRegistry()` | Manages action registry, discovery catalog, and execution |
278
+ | `open-agentic-web/actions` | `validateSchema(schema, data)` | Pure-JS JSON schema validator (zero external deps) |
279
+ | `open-agentic-web/bridge` | `setupActionBridge(opts)` | Connects iframe postMessage handler to action registry |
280
+ | `open-agentic-web/bridge` | `createActionBridgeClient(opts)` | Parent orchestrator client for calling remote bridges |
281
+ | `open-agentic-web/federation` | `AgentSwarm` | Dynamic multi-agent swarm manager with consent hooks |
282
+
283
+ ---
284
+
285
+ ## πŸ›‘οΈ License
286
+
287
+ Apache-2.0. Built for the Open Agentic Web community.
package/bin/cli.mjs ADDED
@@ -0,0 +1,351 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Open Agentic Web CLI (oaw / open-agentic-web)
5
+ * Validates, scaffolds, and inspects conforming Agentic Web nodes.
6
+ */
7
+
8
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
9
+ import { basename, join, resolve } from "node:path";
10
+ import { validateFederation, validateNode } from "../src/validator.js";
11
+
12
+ const args = process.argv.slice(2);
13
+ const command = args[0] || "help";
14
+
15
+ const colors = {
16
+ reset: "\x1b[0m",
17
+ bold: "\x1b[1m",
18
+ green: "\x1b[32m",
19
+ red: "\x1b[31m",
20
+ yellow: "\x1b[33m",
21
+ cyan: "\x1b[36m",
22
+ gray: "\x1b[90m"
23
+ };
24
+
25
+ function printHelp() {
26
+ console.log(`
27
+ ${colors.bold}${colors.cyan}🌐 Open Agentic Web CLI${colors.reset} β€” Conformance Linter & Developer Toolkit
28
+ Spec: Cognizant / Mozilla / MIT NANDA MVP Profile 0.3
29
+
30
+ ${colors.bold}USAGE:${colors.reset}
31
+ $ open-agentic-web <command> [options]
32
+ $ oaw <command> [options]
33
+
34
+ ${colors.bold}COMMANDS:${colors.reset}
35
+ ${colors.cyan}validate${colors.reset} [paths...] Validate one or more site directories for specification conformance.
36
+ ${colors.cyan}federation${colors.reset} <hub> [peers...] Validate cross-site federation, peer links, and manifests.
37
+ ${colors.cyan}init${colors.reset} [dir] Scaffold a new, 100% conforming Open Agentic Web node.
38
+ ${colors.cyan}inspect${colors.reset} [path] Inspect and print the declarative agent graph and tool catalog.
39
+ ${colors.cyan}help${colors.reset} Display this help message.
40
+ ${colors.cyan}version${colors.reset} Print current package version.
41
+
42
+ ${colors.bold}EXAMPLES:${colors.reset}
43
+ $ npx open-agentic-web validate .
44
+ $ npx oaw validate sites/tripsteward-hub sites/cityglide-node
45
+ $ npx oaw federation sites/tripsteward-hub sites/cityglide-node sites/metropass-node
46
+ $ npx oaw init my-dining-node --name "tablebespoke_dining"
47
+ `);
48
+ }
49
+
50
+ async function runValidate() {
51
+ const targetDirs = args.slice(1).length > 0 ? args.slice(1) : ["."];
52
+ let overallFailed = 0;
53
+
54
+ console.log(`\n${colors.bold}✈️ Running Open Agentic Web Conformance Linter${colors.reset}\n`);
55
+
56
+ for (const dir of targetDirs) {
57
+ const summary = await validateNode(dir);
58
+ console.log(`${colors.bold}Testing Node:${colors.reset} ${colors.cyan}${summary.target}${colors.reset}`);
59
+
60
+ summary.results.forEach(res => {
61
+ if (res.status === "PASS") {
62
+ console.log(` ${colors.green}βœ… PASS:${colors.reset} ${res.message}`);
63
+ } else if (res.status === "WARN") {
64
+ console.log(` ${colors.yellow}⚠️ WARN:${colors.reset} ${res.message}`);
65
+ } else {
66
+ console.log(` ${colors.red}❌ FAIL:${colors.reset} ${res.message}`);
67
+ }
68
+ });
69
+
70
+ if (!summary.valid) {
71
+ overallFailed += summary.failed;
72
+ }
73
+ console.log("");
74
+ }
75
+
76
+ if (overallFailed > 0) {
77
+ console.error(`${colors.red}${colors.bold}Validation failed with ${overallFailed} error(s).${colors.reset}\n`);
78
+ process.exit(1);
79
+ } else {
80
+ console.log(`${colors.green}${colors.bold}All nodes conform 100% to Open Agentic Web MVP Profile 0.3!${colors.reset}\n`);
81
+ process.exit(0);
82
+ }
83
+ }
84
+
85
+ async function runFederation() {
86
+ const paths = args.slice(1);
87
+ if (paths.length < 1) {
88
+ console.error(`${colors.red}Error: 'federation' requires at least a hub directory.${colors.reset}`);
89
+ process.exit(1);
90
+ }
91
+
92
+ const hubDir = paths[0];
93
+ const peerDirs = paths.slice(1);
94
+
95
+ console.log(`\n${colors.bold}🌐 Validating Federated Mesh:${colors.reset} Hub (${hubDir}) + ${peerDirs.length} peer(s)\n`);
96
+ const fed = await validateFederation(hubDir, peerDirs);
97
+
98
+ console.log(`Total checks run: ${fed.totalChecks}`);
99
+ console.log(`Passed: ${colors.green}${fed.totalPassed}${colors.reset} | Failed: ${colors.red}${fed.totalFailed}${colors.reset}`);
100
+
101
+ if (!fed.valid) {
102
+ console.error(`\n${colors.red}${colors.bold}Federation validation failed.${colors.reset}\n`);
103
+ process.exit(1);
104
+ } else {
105
+ console.log(`\n${colors.green}${colors.bold}Federation verified successfully!${colors.reset}\n`);
106
+ process.exit(0);
107
+ }
108
+ }
109
+
110
+ function runInit() {
111
+ const targetDir = args[1] || "my-agentic-node";
112
+ const nameIndex = args.indexOf("--name");
113
+ const nodeName = nameIndex !== -1 && args[nameIndex + 1] ? args[nameIndex + 1] : basename(targetDir);
114
+
115
+ const fullPath = resolve(targetDir);
116
+ if (!existsSync(fullPath)) {
117
+ mkdirSync(fullPath, { recursive: true });
118
+ }
119
+
120
+ const bridgeDir = join(fullPath, "bridge");
121
+ if (!existsSync(bridgeDir)) {
122
+ mkdirSync(bridgeDir, { recursive: true });
123
+ }
124
+
125
+ // 1. agent-manifest.json
126
+ const manifest = {
127
+ specification: "https://cognizant-ai-labs.github.io/agentic-web/specs/mvp-v0.3.json",
128
+ name: nodeName,
129
+ version: "1.0.0",
130
+ description: `${nodeName}: Conforming Open Agentic Web Specialist Node`,
131
+ networks: [
132
+ {
133
+ name: `${nodeName}_network`,
134
+ hocon: `./${nodeName}.network.json`,
135
+ front_man: "specialist_concierge"
136
+ }
137
+ ],
138
+ llm_router: {
139
+ base_url: "https://api.otari.ai/api/v1",
140
+ default_model: "alibaba/qwen3.8-flash"
141
+ },
142
+ actions: {
143
+ agentTools: [
144
+ `website_query_inventory`,
145
+ `website_commit_reservation`
146
+ ]
147
+ },
148
+ peer_policy: {
149
+ mode: "open"
150
+ }
151
+ };
152
+ writeFileSync(join(fullPath, "agent-manifest.json"), JSON.stringify(manifest, null, 2));
153
+
154
+ // 2. <nodeName>.network.json
155
+ const network = {
156
+ tools: [
157
+ {
158
+ name: "specialist_concierge",
159
+ role: "Specialist Provider Concierge",
160
+ instructions: `You are the ${nodeName} autonomous agent concierge. Inspect open inventory using website_query_inventory, and once the traveler approves, secure the booking directly via website_commit_reservation.`,
161
+ function: {
162
+ parameters: {
163
+ type: "object",
164
+ properties: {
165
+ request: { type: "string" }
166
+ },
167
+ required: ["request"]
168
+ }
169
+ }
170
+ }
171
+ ]
172
+ };
173
+ writeFileSync(join(fullPath, `${nodeName}.network.json`), JSON.stringify(network, null, 2));
174
+
175
+ // 3. site-actions.js
176
+ const actionsJs = `// Grounded executable site actions for ${nodeName}
177
+ import { defineAction, createActionRegistry } from "open-agentic-web";
178
+
179
+ export class SiteActions {
180
+ static registerActions(registry) {
181
+ registry.register(
182
+ defineAction({
183
+ name: "website_query_inventory",
184
+ description: "Check live provider availability with zero middleman markup.",
185
+ effect: "read",
186
+ inputSchema: {
187
+ type: "object",
188
+ properties: {
189
+ category: { type: "string" }
190
+ }
191
+ },
192
+ execute: async (args) => {
193
+ return { ok: true, available: true, items: [] };
194
+ }
195
+ })
196
+ );
197
+
198
+ registry.register(
199
+ defineAction({
200
+ name: "website_commit_reservation",
201
+ description: "Confirm and commit a direct provider reservation.",
202
+ effect: "irreversible",
203
+ inputSchema: {
204
+ type: "object",
205
+ properties: {
206
+ item_id: { type: "string" }
207
+ },
208
+ required: ["item_id"]
209
+ },
210
+ execute: async (args) => {
211
+ return { ok: true, booking_id: "RES-" + Math.floor(1000 + Math.random() * 9000), status: "CONFIRMED" };
212
+ }
213
+ })
214
+ );
215
+ }
216
+ }
217
+ `;
218
+ writeFileSync(join(fullPath, "site-actions.js"), actionsJs);
219
+
220
+ // 4. bridge/action-bridge.html
221
+ const bridgeHtml = `<!doctype html>
222
+ <html lang="en">
223
+ <head>
224
+ <meta charset="utf-8">
225
+ <title>Action Bridge - ${nodeName}</title>
226
+ <!-- Browser Import Map: Resolves bare module specifiers on static hosts without a bundler -->
227
+ <script type="importmap">
228
+ {
229
+ "imports": {
230
+ "open-agentic-web": "https://esm.sh/open-agentic-web@1.0.0",
231
+ "open-agentic-web/": "https://esm.sh/open-agentic-web@1.0.0/"
232
+ }
233
+ }
234
+ </script>
235
+ <script type="module">
236
+ import { createActionRegistry, setupActionBridge } from "open-agentic-web";
237
+ import { SiteActions } from "../site-actions.js";
238
+
239
+ const registry = createActionRegistry();
240
+ SiteActions.registerActions(registry);
241
+
242
+ // Secure action bridge with human confirmation for irreversible actions
243
+ setupActionBridge({
244
+ registry,
245
+ onConfirm: async ({ action, arguments: args, origin }) => {
246
+ return window.confirm(\`[Action Authorization] \${origin} is requesting to execute '\${action}'. Authorize this action?\`);
247
+ }
248
+ });
249
+ </script>
250
+ </head>
251
+ <body>
252
+ <h3>Action Bridge for ${nodeName}</h3>
253
+ </body>
254
+ </html>
255
+ `;
256
+ writeFileSync(join(bridgeDir, "action-bridge.html"), bridgeHtml);
257
+
258
+ // 5. index.html presentation starter
259
+ const indexHtml = `<!doctype html>
260
+ <html lang="en">
261
+ <head>
262
+ <meta charset="utf-8">
263
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
264
+ <title>${nodeName} - Open Agentic Web Node</title>
265
+ <script type="importmap">
266
+ {
267
+ "imports": {
268
+ "open-agentic-web": "https://esm.sh/open-agentic-web@1.0.0",
269
+ "open-agentic-web/": "https://esm.sh/open-agentic-web@1.0.0/"
270
+ }
271
+ }
272
+ </script>
273
+ </head>
274
+ <body style="font-family: system-ui, sans-serif; max-width: 720px; margin: 40px auto; padding: 0 16px; line-height: 1.5;">
275
+ <h1>🌐 ${nodeName}</h1>
276
+ <p>This is a conforming <strong>Open Agentic Web (MVP Profile 0.3)</strong> node.</p>
277
+ <ul>
278
+ <li>Machine Manifest: <code><a href="./agent-manifest.json">agent-manifest.json</a></code></li>
279
+ <li>Declarative Network: <code><a href="./${nodeName}.network.json">${nodeName}.network.json</a></code></li>
280
+ <li>Action Bridge: <code><a href="./bridge/action-bridge.html">bridge/action-bridge.html</a></code></li>
281
+ </ul>
282
+ </body>
283
+ </html>
284
+ `;
285
+ writeFileSync(join(fullPath, "index.html"), indexHtml);
286
+
287
+ // 5. links.json
288
+ const links = {
289
+ networks: {
290
+ [`${nodeName}_network`]: {}
291
+ }
292
+ };
293
+ writeFileSync(join(fullPath, "links.json"), JSON.stringify(links, null, 2));
294
+
295
+ console.log(`\n${colors.green}${colors.bold}✨ Scaffolding complete!${colors.reset}`);
296
+ console.log(`Created conforming Open Agentic Web node at: ${colors.cyan}${fullPath}${colors.reset}`);
297
+ console.log(`Files generated:
298
+ β”œβ”€β”€ agent-manifest.json
299
+ β”œβ”€β”€ ${nodeName}.network.json
300
+ β”œβ”€β”€ site-actions.js
301
+ β”œβ”€β”€ bridge/action-bridge.html
302
+ └── links.json\n`);
303
+ console.log(`Verify conformance with: ${colors.cyan}npx open-agentic-web validate ${targetDir}${colors.reset}\n`);
304
+ }
305
+
306
+ async function runInspect() {
307
+ const targetDir = args[1] || ".";
308
+ const manifestPath = join(resolve(targetDir), "agent-manifest.json");
309
+ if (!existsSync(manifestPath)) {
310
+ console.error(`${colors.red}Error: No 'agent-manifest.json' found at ${targetDir}${colors.reset}`);
311
+ process.exit(1);
312
+ }
313
+
314
+ const manifest = JSON.parse(readFileSync(manifestPath, "utf-8"));
315
+ console.log(`\n${colors.bold}πŸ” Agentic Node Inspection: ${manifest.name}${colors.reset}`);
316
+ console.log(`Description: ${manifest.description || "N/A"}`);
317
+ console.log(`Specification: ${manifest.specification || "N/A"}`);
318
+ console.log(`LLM Router: ${manifest.llm_router?.base_url || "N/A"} (${manifest.llm_router?.default_model || "N/A"})`);
319
+ console.log(`Registered Agent Tools (${manifest.actions?.agentTools?.length || 0}):`);
320
+ manifest.actions?.agentTools?.forEach(t => console.log(` β€’ ${colors.cyan}${t}${colors.reset}`));
321
+ console.log("");
322
+ }
323
+
324
+ switch (command) {
325
+ case "validate":
326
+ case "test":
327
+ case "check":
328
+ runValidate();
329
+ break;
330
+ case "federation":
331
+ runFederation();
332
+ break;
333
+ case "init":
334
+ case "scaffold":
335
+ case "new":
336
+ runInit();
337
+ break;
338
+ case "inspect":
339
+ runInspect();
340
+ break;
341
+ case "version":
342
+ case "-v":
343
+ case "--version":
344
+ console.log("open-agentic-web v1.0.1");
345
+ break;
346
+ case "help":
347
+ case "--help":
348
+ default:
349
+ printHelp();
350
+ break;
351
+ }