@aigne/afs 1.11.0-beta.11 → 1.11.0-beta.12

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 (139) hide show
  1. package/dist/afs-enrichment.cjs +79 -0
  2. package/dist/afs-enrichment.mjs +80 -0
  3. package/dist/afs-enrichment.mjs.map +1 -0
  4. package/dist/afs-explain.cjs +224 -0
  5. package/dist/afs-explain.mjs +220 -0
  6. package/dist/afs-explain.mjs.map +1 -0
  7. package/dist/afs-root-handlers.cjs +449 -0
  8. package/dist/afs-root-handlers.mjs +444 -0
  9. package/dist/afs-root-handlers.mjs.map +1 -0
  10. package/dist/afs.cjs +456 -559
  11. package/dist/afs.d.cts +116 -70
  12. package/dist/afs.d.cts.map +1 -1
  13. package/dist/afs.d.mts +116 -70
  14. package/dist/afs.d.mts.map +1 -1
  15. package/dist/afs.mjs +457 -560
  16. package/dist/afs.mjs.map +1 -1
  17. package/dist/capabilities/index.d.mts +1 -1
  18. package/dist/capabilities/types.d.cts +64 -1
  19. package/dist/capabilities/types.d.cts.map +1 -1
  20. package/dist/capabilities/types.d.mts +64 -1
  21. package/dist/capabilities/types.d.mts.map +1 -1
  22. package/dist/capability-enforcer.cjs +205 -0
  23. package/dist/capability-enforcer.d.cts +65 -0
  24. package/dist/capability-enforcer.d.cts.map +1 -0
  25. package/dist/capability-enforcer.d.mts +65 -0
  26. package/dist/capability-enforcer.d.mts.map +1 -0
  27. package/dist/capability-enforcer.mjs +204 -0
  28. package/dist/capability-enforcer.mjs.map +1 -0
  29. package/dist/error.cjs +53 -0
  30. package/dist/error.d.cts +32 -1
  31. package/dist/error.d.cts.map +1 -1
  32. package/dist/error.d.mts +32 -1
  33. package/dist/error.d.mts.map +1 -1
  34. package/dist/error.mjs +50 -1
  35. package/dist/error.mjs.map +1 -1
  36. package/dist/events.cjs +91 -0
  37. package/dist/events.d.cts +55 -0
  38. package/dist/events.d.cts.map +1 -0
  39. package/dist/events.d.mts +55 -0
  40. package/dist/events.d.mts.map +1 -0
  41. package/dist/events.mjs +91 -0
  42. package/dist/events.mjs.map +1 -0
  43. package/dist/index.cjs +29 -0
  44. package/dist/index.d.cts +13 -5
  45. package/dist/index.d.mts +14 -5
  46. package/dist/index.mjs +12 -4
  47. package/dist/loader/index.cjs +1 -1
  48. package/dist/loader/index.mjs +1 -1
  49. package/dist/meta/index.mjs +1 -1
  50. package/dist/meta/well-known-kinds.cjs +19 -0
  51. package/dist/meta/well-known-kinds.d.cts +6 -1
  52. package/dist/meta/well-known-kinds.d.cts.map +1 -1
  53. package/dist/meta/well-known-kinds.d.mts +6 -1
  54. package/dist/meta/well-known-kinds.d.mts.map +1 -1
  55. package/dist/meta/well-known-kinds.mjs +19 -1
  56. package/dist/meta/well-known-kinds.mjs.map +1 -1
  57. package/dist/path.cjs +10 -2
  58. package/dist/path.d.cts.map +1 -1
  59. package/dist/path.d.mts.map +1 -1
  60. package/dist/path.mjs +10 -2
  61. package/dist/path.mjs.map +1 -1
  62. package/dist/policy.cjs +32 -0
  63. package/dist/policy.d.cts +16 -0
  64. package/dist/policy.d.cts.map +1 -0
  65. package/dist/policy.d.mts +16 -0
  66. package/dist/policy.d.mts.map +1 -0
  67. package/dist/policy.mjs +32 -0
  68. package/dist/policy.mjs.map +1 -0
  69. package/dist/program/index.cjs +3 -0
  70. package/dist/program/index.d.mts +4 -0
  71. package/dist/program/index.mjs +5 -0
  72. package/dist/program/parse-manifest.cjs +59 -0
  73. package/dist/program/parse-manifest.d.cts +14 -0
  74. package/dist/program/parse-manifest.d.cts.map +1 -0
  75. package/dist/program/parse-manifest.d.mts +14 -0
  76. package/dist/program/parse-manifest.d.mts.map +1 -0
  77. package/dist/program/parse-manifest.mjs +60 -0
  78. package/dist/program/parse-manifest.mjs.map +1 -0
  79. package/dist/program/program-afs.cjs +135 -0
  80. package/dist/program/program-afs.d.cts +45 -0
  81. package/dist/program/program-afs.d.cts.map +1 -0
  82. package/dist/program/program-afs.d.mts +45 -0
  83. package/dist/program/program-afs.d.mts.map +1 -0
  84. package/dist/program/program-afs.mjs +135 -0
  85. package/dist/program/program-afs.mjs.map +1 -0
  86. package/dist/program/projection-provider.cjs +67 -0
  87. package/dist/program/projection-provider.d.cts +39 -0
  88. package/dist/program/projection-provider.d.cts.map +1 -0
  89. package/dist/program/projection-provider.d.mts +39 -0
  90. package/dist/program/projection-provider.d.mts.map +1 -0
  91. package/dist/program/projection-provider.mjs +68 -0
  92. package/dist/program/projection-provider.mjs.map +1 -0
  93. package/dist/program/types.d.cts +41 -0
  94. package/dist/program/types.d.cts.map +1 -0
  95. package/dist/program/types.d.mts +41 -0
  96. package/dist/program/types.d.mts.map +1 -0
  97. package/dist/provider/base.cjs +144 -9
  98. package/dist/provider/base.d.cts +53 -2
  99. package/dist/provider/base.d.cts.map +1 -1
  100. package/dist/provider/base.d.mts +53 -2
  101. package/dist/provider/base.d.mts.map +1 -1
  102. package/dist/provider/base.mjs +145 -10
  103. package/dist/provider/base.mjs.map +1 -1
  104. package/dist/provider/router.cjs +17 -1
  105. package/dist/provider/router.d.cts.map +1 -1
  106. package/dist/provider/router.d.mts.map +1 -1
  107. package/dist/provider/router.mjs +18 -1
  108. package/dist/provider/router.mjs.map +1 -1
  109. package/dist/provider/types.d.cts +2 -0
  110. package/dist/provider/types.d.cts.map +1 -1
  111. package/dist/provider/types.d.mts +2 -0
  112. package/dist/provider/types.d.mts.map +1 -1
  113. package/dist/registry.cjs +80 -8
  114. package/dist/registry.d.cts.map +1 -1
  115. package/dist/registry.d.mts.map +1 -1
  116. package/dist/registry.mjs +77 -5
  117. package/dist/registry.mjs.map +1 -1
  118. package/dist/secret-capability.cjs +116 -0
  119. package/dist/secret-capability.d.cts +57 -0
  120. package/dist/secret-capability.d.cts.map +1 -0
  121. package/dist/secret-capability.d.mts +57 -0
  122. package/dist/secret-capability.d.mts.map +1 -0
  123. package/dist/secret-capability.mjs +113 -0
  124. package/dist/secret-capability.mjs.map +1 -0
  125. package/dist/type.cjs +54 -1
  126. package/dist/type.d.cts +345 -7
  127. package/dist/type.d.cts.map +1 -1
  128. package/dist/type.d.mts +345 -7
  129. package/dist/type.d.mts.map +1 -1
  130. package/dist/type.mjs +53 -2
  131. package/dist/type.mjs.map +1 -1
  132. package/dist/utils/patch.cjs +43 -0
  133. package/dist/utils/patch.d.cts +17 -0
  134. package/dist/utils/patch.d.cts.map +1 -0
  135. package/dist/utils/patch.d.mts +17 -0
  136. package/dist/utils/patch.d.mts.map +1 -0
  137. package/dist/utils/patch.mjs +43 -0
  138. package/dist/utils/patch.mjs.map +1 -0
  139. package/package.json +9 -5
@@ -0,0 +1,79 @@
1
+ let ufo = require("ufo");
2
+
3
+ //#region src/afs-enrichment.ts
4
+ /**
5
+ * Enrichment helpers for AFS entries.
6
+ *
7
+ * These functions fetch actions and meta from a provider module
8
+ * and merge them into AFS entries. They are pure functions that
9
+ * operate on an AFSModule and a subpath — no AFS instance needed.
10
+ */
11
+ /**
12
+ * Check if a path should skip enrichment.
13
+ * Virtual system paths (/.meta, /.actions, /.perception) are not enrichable.
14
+ */
15
+ function shouldSkipEnrich(path) {
16
+ return path.endsWith("/.meta") || path.endsWith("/.actions") || path.includes("/.perception");
17
+ }
18
+ /**
19
+ * Fetch actions for a path by listing path/.actions.
20
+ * Returns ActionSummary[] on success, [] on failure.
21
+ */
22
+ async function fetchActions(module, subpath) {
23
+ try {
24
+ const actionsPath = (0, ufo.joinURL)(subpath, ".actions");
25
+ const result = await module.list?.(actionsPath);
26
+ if (!result?.data) return [];
27
+ return result.data.filter((entry) => entry.meta?.kind === "afs:executable").map((entry) => {
28
+ const summary = {
29
+ name: entry.id,
30
+ description: entry.meta?.description,
31
+ inputSchema: entry.meta?.inputSchema
32
+ };
33
+ const sev = entry.meta?.severity;
34
+ if (sev === "ambient" || sev === "boundary" || sev === "critical") summary.severity = sev;
35
+ return summary;
36
+ });
37
+ } catch {
38
+ return [];
39
+ }
40
+ }
41
+ /**
42
+ * Fetch meta for a path by reading path/.meta.
43
+ * Returns the meta content on success, null on failure.
44
+ */
45
+ async function fetchMeta(module, subpath) {
46
+ try {
47
+ const metaPath = (0, ufo.joinURL)(subpath, ".meta");
48
+ const result = await module.read?.(metaPath);
49
+ if (!result?.data?.content) return null;
50
+ const content = result.data.content;
51
+ if (typeof content === "object" && content !== null && !Array.isArray(content)) return content;
52
+ return null;
53
+ } catch {
54
+ return null;
55
+ }
56
+ }
57
+ /**
58
+ * Enrich an AFS entry with actions and meta from the provider.
59
+ * Skips enrichment for virtual system paths.
60
+ */
61
+ async function enrichData(data, module, subpath) {
62
+ if (shouldSkipEnrich(subpath)) return data;
63
+ const result = { ...data };
64
+ const enrichPromises = [];
65
+ if (result.actions === void 0) enrichPromises.push(fetchActions(module, subpath).then((actions) => {
66
+ result.actions = actions;
67
+ }));
68
+ if (result.meta?.kind === void 0) enrichPromises.push(fetchMeta(module, subpath).then((meta) => {
69
+ if (meta) result.meta = {
70
+ ...result.meta,
71
+ ...meta
72
+ };
73
+ }));
74
+ await Promise.all(enrichPromises);
75
+ return result;
76
+ }
77
+
78
+ //#endregion
79
+ exports.enrichData = enrichData;
@@ -0,0 +1,80 @@
1
+ import { joinURL } from "ufo";
2
+
3
+ //#region src/afs-enrichment.ts
4
+ /**
5
+ * Enrichment helpers for AFS entries.
6
+ *
7
+ * These functions fetch actions and meta from a provider module
8
+ * and merge them into AFS entries. They are pure functions that
9
+ * operate on an AFSModule and a subpath — no AFS instance needed.
10
+ */
11
+ /**
12
+ * Check if a path should skip enrichment.
13
+ * Virtual system paths (/.meta, /.actions, /.perception) are not enrichable.
14
+ */
15
+ function shouldSkipEnrich(path) {
16
+ return path.endsWith("/.meta") || path.endsWith("/.actions") || path.includes("/.perception");
17
+ }
18
+ /**
19
+ * Fetch actions for a path by listing path/.actions.
20
+ * Returns ActionSummary[] on success, [] on failure.
21
+ */
22
+ async function fetchActions(module, subpath) {
23
+ try {
24
+ const actionsPath = joinURL(subpath, ".actions");
25
+ const result = await module.list?.(actionsPath);
26
+ if (!result?.data) return [];
27
+ return result.data.filter((entry) => entry.meta?.kind === "afs:executable").map((entry) => {
28
+ const summary = {
29
+ name: entry.id,
30
+ description: entry.meta?.description,
31
+ inputSchema: entry.meta?.inputSchema
32
+ };
33
+ const sev = entry.meta?.severity;
34
+ if (sev === "ambient" || sev === "boundary" || sev === "critical") summary.severity = sev;
35
+ return summary;
36
+ });
37
+ } catch {
38
+ return [];
39
+ }
40
+ }
41
+ /**
42
+ * Fetch meta for a path by reading path/.meta.
43
+ * Returns the meta content on success, null on failure.
44
+ */
45
+ async function fetchMeta(module, subpath) {
46
+ try {
47
+ const metaPath = joinURL(subpath, ".meta");
48
+ const result = await module.read?.(metaPath);
49
+ if (!result?.data?.content) return null;
50
+ const content = result.data.content;
51
+ if (typeof content === "object" && content !== null && !Array.isArray(content)) return content;
52
+ return null;
53
+ } catch {
54
+ return null;
55
+ }
56
+ }
57
+ /**
58
+ * Enrich an AFS entry with actions and meta from the provider.
59
+ * Skips enrichment for virtual system paths.
60
+ */
61
+ async function enrichData(data, module, subpath) {
62
+ if (shouldSkipEnrich(subpath)) return data;
63
+ const result = { ...data };
64
+ const enrichPromises = [];
65
+ if (result.actions === void 0) enrichPromises.push(fetchActions(module, subpath).then((actions) => {
66
+ result.actions = actions;
67
+ }));
68
+ if (result.meta?.kind === void 0) enrichPromises.push(fetchMeta(module, subpath).then((meta) => {
69
+ if (meta) result.meta = {
70
+ ...result.meta,
71
+ ...meta
72
+ };
73
+ }));
74
+ await Promise.all(enrichPromises);
75
+ return result;
76
+ }
77
+
78
+ //#endregion
79
+ export { enrichData };
80
+ //# sourceMappingURL=afs-enrichment.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"afs-enrichment.mjs","names":[],"sources":["../src/afs-enrichment.ts"],"sourcesContent":["/**\n * Enrichment helpers for AFS entries.\n *\n * These functions fetch actions and meta from a provider module\n * and merge them into AFS entries. They are pure functions that\n * operate on an AFSModule and a subpath — no AFS instance needed.\n */\nimport { joinURL } from \"ufo\";\nimport type { ActionSummary, AFSModule } from \"./type.js\";\n\n/**\n * Check if a path should skip enrichment.\n * Virtual system paths (/.meta, /.actions, /.perception) are not enrichable.\n */\nexport function shouldSkipEnrich(path: string): boolean {\n return path.endsWith(\"/.meta\") || path.endsWith(\"/.actions\") || path.includes(\"/.perception\");\n}\n\n/**\n * Fetch actions for a path by listing path/.actions.\n * Returns ActionSummary[] on success, [] on failure.\n */\nexport async function fetchActions(module: AFSModule, subpath: string): Promise<ActionSummary[]> {\n try {\n const actionsPath = joinURL(subpath, \".actions\");\n const result = await module.list?.(actionsPath);\n if (!result?.data) return [];\n\n return result.data\n .filter((entry) => entry.meta?.kind === \"afs:executable\")\n .map((entry) => {\n const summary: ActionSummary = {\n name: entry.id,\n description: entry.meta?.description as string | undefined,\n inputSchema: entry.meta?.inputSchema as ActionSummary[\"inputSchema\"],\n };\n const sev = entry.meta?.severity as string | undefined;\n if (sev === \"ambient\" || sev === \"boundary\" || sev === \"critical\") {\n summary.severity = sev;\n }\n return summary;\n });\n } catch {\n return [];\n }\n}\n\n/**\n * Fetch meta for a path by reading path/.meta.\n * Returns the meta content on success, null on failure.\n */\nexport async function fetchMeta(\n module: AFSModule,\n subpath: string,\n): Promise<Record<string, unknown> | null> {\n try {\n const metaPath = joinURL(subpath, \".meta\");\n const result = await module.read?.(metaPath);\n if (!result?.data?.content) return null;\n\n // content should be an object containing meta fields\n const content = result.data.content;\n if (typeof content === \"object\" && content !== null && !Array.isArray(content)) {\n return content as Record<string, unknown>;\n }\n return null;\n } catch {\n return null;\n }\n}\n\n/**\n * Enrich an AFS entry with actions and meta from the provider.\n * Skips enrichment for virtual system paths.\n */\nexport async function enrichData<\n T extends { path: string; actions?: ActionSummary[]; meta?: Record<string, unknown> | null },\n>(data: T, module: AFSModule, subpath: string): Promise<T> {\n // Skip enrichment for virtual paths\n if (shouldSkipEnrich(subpath)) {\n return data;\n }\n\n const result = { ...data };\n const enrichPromises: Promise<void>[] = [];\n\n // Fetch actions if not present (undefined means fetch, [] means keep as-is)\n if (result.actions === undefined) {\n enrichPromises.push(\n fetchActions(module, subpath).then((actions) => {\n result.actions = actions;\n }),\n );\n }\n\n // Fetch meta if kind is not present\n if (result.meta?.kind === undefined) {\n enrichPromises.push(\n fetchMeta(module, subpath).then((meta) => {\n if (meta) {\n result.meta = { ...result.meta, ...meta };\n }\n }),\n );\n }\n\n await Promise.all(enrichPromises);\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,SAAgB,iBAAiB,MAAuB;AACtD,QAAO,KAAK,SAAS,SAAS,IAAI,KAAK,SAAS,YAAY,IAAI,KAAK,SAAS,eAAe;;;;;;AAO/F,eAAsB,aAAa,QAAmB,SAA2C;AAC/F,KAAI;EACF,MAAM,cAAc,QAAQ,SAAS,WAAW;EAChD,MAAM,SAAS,MAAM,OAAO,OAAO,YAAY;AAC/C,MAAI,CAAC,QAAQ,KAAM,QAAO,EAAE;AAE5B,SAAO,OAAO,KACX,QAAQ,UAAU,MAAM,MAAM,SAAS,iBAAiB,CACxD,KAAK,UAAU;GACd,MAAM,UAAyB;IAC7B,MAAM,MAAM;IACZ,aAAa,MAAM,MAAM;IACzB,aAAa,MAAM,MAAM;IAC1B;GACD,MAAM,MAAM,MAAM,MAAM;AACxB,OAAI,QAAQ,aAAa,QAAQ,cAAc,QAAQ,WACrD,SAAQ,WAAW;AAErB,UAAO;IACP;SACE;AACN,SAAO,EAAE;;;;;;;AAQb,eAAsB,UACpB,QACA,SACyC;AACzC,KAAI;EACF,MAAM,WAAW,QAAQ,SAAS,QAAQ;EAC1C,MAAM,SAAS,MAAM,OAAO,OAAO,SAAS;AAC5C,MAAI,CAAC,QAAQ,MAAM,QAAS,QAAO;EAGnC,MAAM,UAAU,OAAO,KAAK;AAC5B,MAAI,OAAO,YAAY,YAAY,YAAY,QAAQ,CAAC,MAAM,QAAQ,QAAQ,CAC5E,QAAO;AAET,SAAO;SACD;AACN,SAAO;;;;;;;AAQX,eAAsB,WAEpB,MAAS,QAAmB,SAA6B;AAEzD,KAAI,iBAAiB,QAAQ,CAC3B,QAAO;CAGT,MAAM,SAAS,EAAE,GAAG,MAAM;CAC1B,MAAM,iBAAkC,EAAE;AAG1C,KAAI,OAAO,YAAY,OACrB,gBAAe,KACb,aAAa,QAAQ,QAAQ,CAAC,MAAM,YAAY;AAC9C,SAAO,UAAU;GACjB,CACH;AAIH,KAAI,OAAO,MAAM,SAAS,OACxB,gBAAe,KACb,UAAU,QAAQ,QAAQ,CAAC,MAAM,SAAS;AACxC,MAAI,KACF,QAAO,OAAO;GAAE,GAAG,OAAO;GAAM,GAAG;GAAM;GAE3C,CACH;AAGH,OAAM,QAAQ,IAAI,eAAe;AACjC,QAAO"}
@@ -0,0 +1,224 @@
1
+
2
+ //#region src/afs-explain.ts
3
+ /**
4
+ * Format bytes to human-readable string.
5
+ */
6
+ function formatBytes(bytes) {
7
+ if (bytes === 0) return "0 B";
8
+ const k = 1024;
9
+ const sizes = [
10
+ "B",
11
+ "KB",
12
+ "MB",
13
+ "GB",
14
+ "TB"
15
+ ];
16
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
17
+ return `${Number.parseFloat((bytes / k ** i).toFixed(2))} ${sizes[i]}`;
18
+ }
19
+ /**
20
+ * Build explain markdown from stat data.
21
+ * Used by both the module-found fallback and the no-module safety net.
22
+ */
23
+ function buildExplainFromStat(path, data) {
24
+ const lines = [];
25
+ lines.push(`# ${path}`);
26
+ lines.push("");
27
+ const meta = data.meta || {};
28
+ if (meta.size !== void 0) lines.push(`- **Size**: ${formatBytes(meta.size)}`);
29
+ if (meta.childrenCount !== void 0) lines.push(`- **Children**: ${meta.childrenCount} items`);
30
+ if (data.updatedAt) lines.push(`- **Modified**: ${data.updatedAt.toISOString()}`);
31
+ if (meta.description) {
32
+ lines.push("");
33
+ lines.push("## Description");
34
+ lines.push(String(meta.description));
35
+ }
36
+ if (meta.provider) lines.push(`- **Provider**: ${meta.provider}`);
37
+ if (meta.kind) lines.push(`- **Kind**: ${meta.kind}`);
38
+ if (meta.kinds && Array.isArray(meta.kinds)) lines.push(`- **Kinds**: ${meta.kinds.join(", ")}`);
39
+ if (data.actions && data.actions.length > 0) {
40
+ lines.push("");
41
+ lines.push("## Actions");
42
+ for (const action of data.actions) lines.push(`- **${action.name}**${action.description ? `: ${action.description}` : ""}`);
43
+ }
44
+ return {
45
+ format: "markdown",
46
+ content: lines.join("\n")
47
+ };
48
+ }
49
+ /**
50
+ * Build explain for a virtual intermediate directory.
51
+ */
52
+ function buildVirtualDirExplain(path, data) {
53
+ const childrenCount = data.meta?.childrenCount;
54
+ const lines = [];
55
+ lines.push(`# ${path}`);
56
+ lines.push("");
57
+ lines.push("- **Type**: Virtual directory");
58
+ if (childrenCount !== void 0) lines.push(`- **Children**: ${childrenCount} items`);
59
+ return {
60
+ format: "markdown",
61
+ content: lines.join("\n")
62
+ };
63
+ }
64
+ /**
65
+ * Generate root explain: intro + 4 sections.
66
+ */
67
+ async function explainRoot(mounts, listRootActions) {
68
+ const lines = [];
69
+ lines.push("# AFS — Agentic File System");
70
+ lines.push("");
71
+ lines.push("AFS is a virtual filesystem developed by [ArcBlock](https://www.arcblock.io) that gives AI agents a unified, path-based interface to any data source.");
72
+ lines.push("Inspired by Unix and Plan 9's \"everything is a file\", AFS extends the idea to **everything is context** — databases, APIs, smart home devices, and cloud services all become files and directories that agents can read, write, search, and act on.");
73
+ lines.push("");
74
+ lines.push("## Mounted Providers");
75
+ lines.push("");
76
+ if (mounts.length === 0) {
77
+ lines.push("No providers currently mounted. Use the `mount` action to add providers.");
78
+ lines.push("");
79
+ } else {
80
+ for (const m of mounts) if (m.module.description) {
81
+ const descLines = m.module.description.split("\n");
82
+ lines.push(`- **${m.module.name}** (\`${m.path}\`) — ${descLines[0]}`);
83
+ for (let i = 1; i < descLines.length; i++) lines.push(` ${descLines[i]}`);
84
+ } else lines.push(`- **${m.module.name}** (\`${m.path}\`)`);
85
+ lines.push("");
86
+ }
87
+ lines.push("## Standard Operations");
88
+ lines.push("");
89
+ lines.push("- **read** — Read file or node content");
90
+ lines.push("- **list** — List children of a directory or container");
91
+ lines.push("- **stat** — Get metadata without content");
92
+ lines.push("- **explain** — Get human-readable documentation for a path");
93
+ lines.push("- **search** — Search within a mounted provider");
94
+ lines.push("- **write** — Create or update content");
95
+ lines.push("- **delete** — Remove a file or node");
96
+ lines.push("- **exec** — Execute an action at a path");
97
+ lines.push("");
98
+ lines.push("## Root Actions");
99
+ lines.push("");
100
+ const { data: actions } = await listRootActions();
101
+ for (const action of actions) {
102
+ const desc = action.actions?.[0]?.description || action.summary || "";
103
+ lines.push(`- **${action.id}** — ${desc}`);
104
+ }
105
+ lines.push("");
106
+ lines.push("Use `explain('/.actions/<name>')` for detailed usage.");
107
+ lines.push("");
108
+ lines.push("## Built-in Systems");
109
+ lines.push("");
110
+ lines.push("- **`.meta`** — Metadata for any node. Access via `read('/.meta')` at root, or append `/.meta` to any path.");
111
+ lines.push("- **`.actions`** — Executable actions. Access via `read('/.actions')` to list, `exec('/.actions/<name>', args)` to run.");
112
+ lines.push("");
113
+ return {
114
+ format: "markdown",
115
+ content: lines.join("\n")
116
+ };
117
+ }
118
+ /**
119
+ * Explain a root action path (/.actions or /.actions/{name}).
120
+ */
121
+ async function explainRootAction(path, listRootActions) {
122
+ if (path === "/.actions") {
123
+ const lines$1 = [];
124
+ lines$1.push("# Root Actions");
125
+ lines$1.push("");
126
+ lines$1.push("Available actions at the AFS root level:");
127
+ lines$1.push("");
128
+ const { data: actions$1 } = await listRootActions();
129
+ for (const action$1 of actions$1) {
130
+ const desc = action$1.actions?.[0]?.description || action$1.summary || "";
131
+ lines$1.push(`- **${action$1.id}** — ${desc}`);
132
+ }
133
+ lines$1.push("");
134
+ lines$1.push("Use `explain('/.actions/<name>')` for detailed parameters and usage.");
135
+ return {
136
+ format: "markdown",
137
+ content: lines$1.join("\n")
138
+ };
139
+ }
140
+ const actionName = path.slice(10);
141
+ const { data: actions } = await listRootActions();
142
+ const entry = actions.find((a) => a.id === actionName);
143
+ if (!entry) return {
144
+ format: "markdown",
145
+ content: ""
146
+ };
147
+ const action = entry.actions?.[0];
148
+ const lines = [];
149
+ lines.push(`# ${actionName}`);
150
+ lines.push("");
151
+ if (action?.description) {
152
+ lines.push(action.description);
153
+ lines.push("");
154
+ }
155
+ const schema = action?.inputSchema;
156
+ const properties = schema?.properties;
157
+ const required = schema?.required || [];
158
+ if (properties && Object.keys(properties).length > 0) {
159
+ lines.push("## Parameters");
160
+ lines.push("");
161
+ lines.push("| Name | Type | Required | Description |");
162
+ lines.push("|------|------|----------|-------------|");
163
+ for (const [name, prop] of Object.entries(properties)) {
164
+ const propObj = prop;
165
+ const type = propObj.type || "any";
166
+ const isRequired = required.includes(name) ? "yes" : "no";
167
+ const desc = propObj.description || "";
168
+ lines.push(`| ${name} | ${type} | ${isRequired} | ${desc} |`);
169
+ }
170
+ lines.push("");
171
+ }
172
+ lines.push("## Example");
173
+ lines.push("");
174
+ const exampleArgs = {};
175
+ for (const name of required) exampleArgs[name] = `<${name}>`;
176
+ lines.push(`\`\`\`\nexec('/.actions/${actionName}', ${JSON.stringify(exampleArgs, null, 2)})\n\`\`\``);
177
+ return {
178
+ format: "markdown",
179
+ content: lines.join("\n")
180
+ };
181
+ }
182
+ /**
183
+ * Explain a root meta path (/.meta or /.meta/{subpath}).
184
+ * Returns null if the path is not a recognized root meta path.
185
+ */
186
+ function explainRootMeta(path) {
187
+ if (path === "/.meta") {
188
+ const lines = [];
189
+ lines.push("# Root Metadata");
190
+ lines.push("");
191
+ lines.push("The `.meta` system provides metadata about any AFS node.");
192
+ lines.push("");
193
+ lines.push("## Available Sub-paths");
194
+ lines.push("");
195
+ lines.push("- **`.capabilities`** — Aggregated capabilities from all mounted providers");
196
+ lines.push("");
197
+ lines.push("Use `read('/.meta')` to get structured root metadata including mounted providers and available actions.");
198
+ return {
199
+ format: "markdown",
200
+ content: lines.join("\n")
201
+ };
202
+ }
203
+ if (path === "/.meta/.capabilities") {
204
+ const lines = [];
205
+ lines.push("# Capabilities");
206
+ lines.push("");
207
+ lines.push("Aggregated capabilities manifest from all mounted providers.");
208
+ lines.push("Describes the combined operations, tools, and action catalogs available across the system.");
209
+ lines.push("");
210
+ lines.push("Use `read('/.meta/.capabilities')` to get the full structured capabilities data.");
211
+ return {
212
+ format: "markdown",
213
+ content: lines.join("\n")
214
+ };
215
+ }
216
+ return null;
217
+ }
218
+
219
+ //#endregion
220
+ exports.buildExplainFromStat = buildExplainFromStat;
221
+ exports.buildVirtualDirExplain = buildVirtualDirExplain;
222
+ exports.explainRoot = explainRoot;
223
+ exports.explainRootAction = explainRootAction;
224
+ exports.explainRootMeta = explainRootMeta;
@@ -0,0 +1,220 @@
1
+ //#region src/afs-explain.ts
2
+ /**
3
+ * Format bytes to human-readable string.
4
+ */
5
+ function formatBytes(bytes) {
6
+ if (bytes === 0) return "0 B";
7
+ const k = 1024;
8
+ const sizes = [
9
+ "B",
10
+ "KB",
11
+ "MB",
12
+ "GB",
13
+ "TB"
14
+ ];
15
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
16
+ return `${Number.parseFloat((bytes / k ** i).toFixed(2))} ${sizes[i]}`;
17
+ }
18
+ /**
19
+ * Build explain markdown from stat data.
20
+ * Used by both the module-found fallback and the no-module safety net.
21
+ */
22
+ function buildExplainFromStat(path, data) {
23
+ const lines = [];
24
+ lines.push(`# ${path}`);
25
+ lines.push("");
26
+ const meta = data.meta || {};
27
+ if (meta.size !== void 0) lines.push(`- **Size**: ${formatBytes(meta.size)}`);
28
+ if (meta.childrenCount !== void 0) lines.push(`- **Children**: ${meta.childrenCount} items`);
29
+ if (data.updatedAt) lines.push(`- **Modified**: ${data.updatedAt.toISOString()}`);
30
+ if (meta.description) {
31
+ lines.push("");
32
+ lines.push("## Description");
33
+ lines.push(String(meta.description));
34
+ }
35
+ if (meta.provider) lines.push(`- **Provider**: ${meta.provider}`);
36
+ if (meta.kind) lines.push(`- **Kind**: ${meta.kind}`);
37
+ if (meta.kinds && Array.isArray(meta.kinds)) lines.push(`- **Kinds**: ${meta.kinds.join(", ")}`);
38
+ if (data.actions && data.actions.length > 0) {
39
+ lines.push("");
40
+ lines.push("## Actions");
41
+ for (const action of data.actions) lines.push(`- **${action.name}**${action.description ? `: ${action.description}` : ""}`);
42
+ }
43
+ return {
44
+ format: "markdown",
45
+ content: lines.join("\n")
46
+ };
47
+ }
48
+ /**
49
+ * Build explain for a virtual intermediate directory.
50
+ */
51
+ function buildVirtualDirExplain(path, data) {
52
+ const childrenCount = data.meta?.childrenCount;
53
+ const lines = [];
54
+ lines.push(`# ${path}`);
55
+ lines.push("");
56
+ lines.push("- **Type**: Virtual directory");
57
+ if (childrenCount !== void 0) lines.push(`- **Children**: ${childrenCount} items`);
58
+ return {
59
+ format: "markdown",
60
+ content: lines.join("\n")
61
+ };
62
+ }
63
+ /**
64
+ * Generate root explain: intro + 4 sections.
65
+ */
66
+ async function explainRoot(mounts, listRootActions) {
67
+ const lines = [];
68
+ lines.push("# AFS — Agentic File System");
69
+ lines.push("");
70
+ lines.push("AFS is a virtual filesystem developed by [ArcBlock](https://www.arcblock.io) that gives AI agents a unified, path-based interface to any data source.");
71
+ lines.push("Inspired by Unix and Plan 9's \"everything is a file\", AFS extends the idea to **everything is context** — databases, APIs, smart home devices, and cloud services all become files and directories that agents can read, write, search, and act on.");
72
+ lines.push("");
73
+ lines.push("## Mounted Providers");
74
+ lines.push("");
75
+ if (mounts.length === 0) {
76
+ lines.push("No providers currently mounted. Use the `mount` action to add providers.");
77
+ lines.push("");
78
+ } else {
79
+ for (const m of mounts) if (m.module.description) {
80
+ const descLines = m.module.description.split("\n");
81
+ lines.push(`- **${m.module.name}** (\`${m.path}\`) — ${descLines[0]}`);
82
+ for (let i = 1; i < descLines.length; i++) lines.push(` ${descLines[i]}`);
83
+ } else lines.push(`- **${m.module.name}** (\`${m.path}\`)`);
84
+ lines.push("");
85
+ }
86
+ lines.push("## Standard Operations");
87
+ lines.push("");
88
+ lines.push("- **read** — Read file or node content");
89
+ lines.push("- **list** — List children of a directory or container");
90
+ lines.push("- **stat** — Get metadata without content");
91
+ lines.push("- **explain** — Get human-readable documentation for a path");
92
+ lines.push("- **search** — Search within a mounted provider");
93
+ lines.push("- **write** — Create or update content");
94
+ lines.push("- **delete** — Remove a file or node");
95
+ lines.push("- **exec** — Execute an action at a path");
96
+ lines.push("");
97
+ lines.push("## Root Actions");
98
+ lines.push("");
99
+ const { data: actions } = await listRootActions();
100
+ for (const action of actions) {
101
+ const desc = action.actions?.[0]?.description || action.summary || "";
102
+ lines.push(`- **${action.id}** — ${desc}`);
103
+ }
104
+ lines.push("");
105
+ lines.push("Use `explain('/.actions/<name>')` for detailed usage.");
106
+ lines.push("");
107
+ lines.push("## Built-in Systems");
108
+ lines.push("");
109
+ lines.push("- **`.meta`** — Metadata for any node. Access via `read('/.meta')` at root, or append `/.meta` to any path.");
110
+ lines.push("- **`.actions`** — Executable actions. Access via `read('/.actions')` to list, `exec('/.actions/<name>', args)` to run.");
111
+ lines.push("");
112
+ return {
113
+ format: "markdown",
114
+ content: lines.join("\n")
115
+ };
116
+ }
117
+ /**
118
+ * Explain a root action path (/.actions or /.actions/{name}).
119
+ */
120
+ async function explainRootAction(path, listRootActions) {
121
+ if (path === "/.actions") {
122
+ const lines$1 = [];
123
+ lines$1.push("# Root Actions");
124
+ lines$1.push("");
125
+ lines$1.push("Available actions at the AFS root level:");
126
+ lines$1.push("");
127
+ const { data: actions$1 } = await listRootActions();
128
+ for (const action$1 of actions$1) {
129
+ const desc = action$1.actions?.[0]?.description || action$1.summary || "";
130
+ lines$1.push(`- **${action$1.id}** — ${desc}`);
131
+ }
132
+ lines$1.push("");
133
+ lines$1.push("Use `explain('/.actions/<name>')` for detailed parameters and usage.");
134
+ return {
135
+ format: "markdown",
136
+ content: lines$1.join("\n")
137
+ };
138
+ }
139
+ const actionName = path.slice(10);
140
+ const { data: actions } = await listRootActions();
141
+ const entry = actions.find((a) => a.id === actionName);
142
+ if (!entry) return {
143
+ format: "markdown",
144
+ content: ""
145
+ };
146
+ const action = entry.actions?.[0];
147
+ const lines = [];
148
+ lines.push(`# ${actionName}`);
149
+ lines.push("");
150
+ if (action?.description) {
151
+ lines.push(action.description);
152
+ lines.push("");
153
+ }
154
+ const schema = action?.inputSchema;
155
+ const properties = schema?.properties;
156
+ const required = schema?.required || [];
157
+ if (properties && Object.keys(properties).length > 0) {
158
+ lines.push("## Parameters");
159
+ lines.push("");
160
+ lines.push("| Name | Type | Required | Description |");
161
+ lines.push("|------|------|----------|-------------|");
162
+ for (const [name, prop] of Object.entries(properties)) {
163
+ const propObj = prop;
164
+ const type = propObj.type || "any";
165
+ const isRequired = required.includes(name) ? "yes" : "no";
166
+ const desc = propObj.description || "";
167
+ lines.push(`| ${name} | ${type} | ${isRequired} | ${desc} |`);
168
+ }
169
+ lines.push("");
170
+ }
171
+ lines.push("## Example");
172
+ lines.push("");
173
+ const exampleArgs = {};
174
+ for (const name of required) exampleArgs[name] = `<${name}>`;
175
+ lines.push(`\`\`\`\nexec('/.actions/${actionName}', ${JSON.stringify(exampleArgs, null, 2)})\n\`\`\``);
176
+ return {
177
+ format: "markdown",
178
+ content: lines.join("\n")
179
+ };
180
+ }
181
+ /**
182
+ * Explain a root meta path (/.meta or /.meta/{subpath}).
183
+ * Returns null if the path is not a recognized root meta path.
184
+ */
185
+ function explainRootMeta(path) {
186
+ if (path === "/.meta") {
187
+ const lines = [];
188
+ lines.push("# Root Metadata");
189
+ lines.push("");
190
+ lines.push("The `.meta` system provides metadata about any AFS node.");
191
+ lines.push("");
192
+ lines.push("## Available Sub-paths");
193
+ lines.push("");
194
+ lines.push("- **`.capabilities`** — Aggregated capabilities from all mounted providers");
195
+ lines.push("");
196
+ lines.push("Use `read('/.meta')` to get structured root metadata including mounted providers and available actions.");
197
+ return {
198
+ format: "markdown",
199
+ content: lines.join("\n")
200
+ };
201
+ }
202
+ if (path === "/.meta/.capabilities") {
203
+ const lines = [];
204
+ lines.push("# Capabilities");
205
+ lines.push("");
206
+ lines.push("Aggregated capabilities manifest from all mounted providers.");
207
+ lines.push("Describes the combined operations, tools, and action catalogs available across the system.");
208
+ lines.push("");
209
+ lines.push("Use `read('/.meta/.capabilities')` to get the full structured capabilities data.");
210
+ return {
211
+ format: "markdown",
212
+ content: lines.join("\n")
213
+ };
214
+ }
215
+ return null;
216
+ }
217
+
218
+ //#endregion
219
+ export { buildExplainFromStat, buildVirtualDirExplain, explainRoot, explainRootAction, explainRootMeta };
220
+ //# sourceMappingURL=afs-explain.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"afs-explain.mjs","names":["lines","actions","action"],"sources":["../src/afs-explain.ts"],"sourcesContent":["/**\n * Explain generation helpers for AFS.\n *\n * These functions produce human-readable markdown documentation\n * for AFS paths. They take structured data as input and return\n * formatted markdown — no AFS instance dependencies.\n */\nimport type { AFSEntry, AFSExplainResult, AFSListResult } from \"./type.js\";\n\n/** Mount info needed by explainRoot() */\nexport interface MountInfo {\n path: string;\n module: { name: string; description?: string };\n}\n\n/**\n * Format bytes to human-readable string.\n */\nexport function formatBytes(bytes: number): string {\n if (bytes === 0) return \"0 B\";\n const k = 1024;\n const sizes = [\"B\", \"KB\", \"MB\", \"GB\", \"TB\"];\n const i = Math.floor(Math.log(bytes) / Math.log(k));\n return `${Number.parseFloat((bytes / k ** i).toFixed(2))} ${sizes[i]}`;\n}\n\n/**\n * Build explain markdown from stat data.\n * Used by both the module-found fallback and the no-module safety net.\n */\nexport function buildExplainFromStat(\n path: string,\n data: Omit<AFSEntry, \"content\">,\n): AFSExplainResult {\n const lines: string[] = [];\n lines.push(`# ${path}`);\n lines.push(\"\");\n\n const meta = data.meta || {};\n\n if (meta.size !== undefined) {\n lines.push(`- **Size**: ${formatBytes(meta.size as number)}`);\n }\n if (meta.childrenCount !== undefined) {\n lines.push(`- **Children**: ${meta.childrenCount} items`);\n }\n if (data.updatedAt) {\n lines.push(`- **Modified**: ${data.updatedAt.toISOString()}`);\n }\n\n if (meta.description) {\n lines.push(\"\");\n lines.push(\"## Description\");\n lines.push(String(meta.description));\n }\n if (meta.provider) {\n lines.push(`- **Provider**: ${meta.provider}`);\n }\n if (meta.kind) {\n lines.push(`- **Kind**: ${meta.kind}`);\n }\n if (meta.kinds && Array.isArray(meta.kinds)) {\n lines.push(`- **Kinds**: ${meta.kinds.join(\", \")}`);\n }\n\n if (data.actions && data.actions.length > 0) {\n lines.push(\"\");\n lines.push(\"## Actions\");\n for (const action of data.actions) {\n lines.push(`- **${action.name}**${action.description ? `: ${action.description}` : \"\"}`);\n }\n }\n\n return {\n format: \"markdown\",\n content: lines.join(\"\\n\"),\n };\n}\n\n/**\n * Build explain for a virtual intermediate directory.\n */\nexport function buildVirtualDirExplain(path: string, data: AFSEntry): AFSExplainResult {\n const childrenCount = data.meta?.childrenCount;\n const lines: string[] = [];\n lines.push(`# ${path}`);\n lines.push(\"\");\n lines.push(\"- **Type**: Virtual directory\");\n if (childrenCount !== undefined) {\n lines.push(`- **Children**: ${childrenCount} items`);\n }\n\n return {\n format: \"markdown\",\n content: lines.join(\"\\n\"),\n };\n}\n\n/**\n * Generate root explain: intro + 4 sections.\n */\nexport async function explainRoot(\n mounts: MountInfo[],\n listRootActions: () => Promise<AFSListResult>,\n): Promise<AFSExplainResult> {\n const lines: string[] = [];\n lines.push(\"# AFS — Agentic File System\");\n lines.push(\"\");\n lines.push(\n \"AFS is a virtual filesystem developed by [ArcBlock](https://www.arcblock.io) that gives AI agents a unified, path-based interface to any data source.\",\n );\n lines.push(\n 'Inspired by Unix and Plan 9\\'s \"everything is a file\", AFS extends the idea to **everything is context** — databases, APIs, smart home devices, and cloud services all become files and directories that agents can read, write, search, and act on.',\n );\n lines.push(\"\");\n\n // Section 1: Mounted Providers\n lines.push(\"## Mounted Providers\");\n lines.push(\"\");\n if (mounts.length === 0) {\n lines.push(\"No providers currently mounted. Use the `mount` action to add providers.\");\n lines.push(\"\");\n } else {\n for (const m of mounts) {\n if (m.module.description) {\n // Multi-line descriptions: first line as header, rest indented\n const descLines = m.module.description.split(\"\\n\");\n lines.push(`- **${m.module.name}** (\\`${m.path}\\`) — ${descLines[0]}`);\n for (let i = 1; i < descLines.length; i++) {\n lines.push(` ${descLines[i]}`);\n }\n } else {\n lines.push(`- **${m.module.name}** (\\`${m.path}\\`)`);\n }\n }\n lines.push(\"\");\n }\n\n // Section 2: Standard Operations\n lines.push(\"## Standard Operations\");\n lines.push(\"\");\n lines.push(\"- **read** — Read file or node content\");\n lines.push(\"- **list** — List children of a directory or container\");\n lines.push(\"- **stat** — Get metadata without content\");\n lines.push(\"- **explain** — Get human-readable documentation for a path\");\n lines.push(\"- **search** — Search within a mounted provider\");\n lines.push(\"- **write** — Create or update content\");\n lines.push(\"- **delete** — Remove a file or node\");\n lines.push(\"- **exec** — Execute an action at a path\");\n lines.push(\"\");\n\n // Section 3: Root Actions\n lines.push(\"## Root Actions\");\n lines.push(\"\");\n const { data: actions } = await listRootActions();\n for (const action of actions) {\n const desc = action.actions?.[0]?.description || action.summary || \"\";\n lines.push(`- **${action.id}** — ${desc}`);\n }\n lines.push(\"\");\n lines.push(\"Use `explain('/.actions/<name>')` for detailed usage.\");\n lines.push(\"\");\n\n // Section 4: Built-in Systems\n lines.push(\"## Built-in Systems\");\n lines.push(\"\");\n lines.push(\n \"- **`.meta`** — Metadata for any node. Access via `read('/.meta')` at root, or append `/.meta` to any path.\",\n );\n lines.push(\n \"- **`.actions`** — Executable actions. Access via `read('/.actions')` to list, `exec('/.actions/<name>', args)` to run.\",\n );\n lines.push(\"\");\n\n return { format: \"markdown\", content: lines.join(\"\\n\") };\n}\n\n/**\n * Explain a root action path (/.actions or /.actions/{name}).\n */\nexport async function explainRootAction(\n path: string,\n listRootActions: () => Promise<AFSListResult>,\n): Promise<AFSExplainResult> {\n if (path === \"/.actions\") {\n const lines: string[] = [];\n lines.push(\"# Root Actions\");\n lines.push(\"\");\n lines.push(\"Available actions at the AFS root level:\");\n lines.push(\"\");\n const { data: actions } = await listRootActions();\n for (const action of actions) {\n const desc = action.actions?.[0]?.description || action.summary || \"\";\n lines.push(`- **${action.id}** — ${desc}`);\n }\n lines.push(\"\");\n lines.push(\"Use `explain('/.actions/<name>')` for detailed parameters and usage.\");\n return { format: \"markdown\", content: lines.join(\"\\n\") };\n }\n\n // /.actions/{name} — generate parameter table from inputSchema\n const actionName = path.slice(\"/.actions/\".length);\n const { data: actions } = await listRootActions();\n const entry = actions.find((a) => a.id === actionName);\n if (!entry) {\n // Caller should handle AFSNotFoundError\n return { format: \"markdown\", content: \"\" };\n }\n\n const action = entry.actions?.[0];\n const lines: string[] = [];\n lines.push(`# ${actionName}`);\n lines.push(\"\");\n if (action?.description) {\n lines.push(action.description);\n lines.push(\"\");\n }\n\n // Parameter table from inputSchema\n const schema = action?.inputSchema as Record<string, any> | undefined;\n const properties = schema?.properties as Record<string, any> | undefined;\n const required = (schema?.required as string[]) || [];\n\n if (properties && Object.keys(properties).length > 0) {\n lines.push(\"## Parameters\");\n lines.push(\"\");\n lines.push(\"| Name | Type | Required | Description |\");\n lines.push(\"|------|------|----------|-------------|\");\n for (const [name, prop] of Object.entries(properties)) {\n const propObj = prop as Record<string, unknown>;\n const type = (propObj.type as string) || \"any\";\n const isRequired = required.includes(name) ? \"yes\" : \"no\";\n const desc = (propObj.description as string) || \"\";\n lines.push(`| ${name} | ${type} | ${isRequired} | ${desc} |`);\n }\n lines.push(\"\");\n }\n\n // Usage example\n lines.push(\"## Example\");\n lines.push(\"\");\n const exampleArgs: Record<string, string> = {};\n for (const name of required) {\n exampleArgs[name] = `<${name}>`;\n }\n lines.push(\n `\\`\\`\\`\\nexec('/.actions/${actionName}', ${JSON.stringify(exampleArgs, null, 2)})\\n\\`\\`\\``,\n );\n\n return { format: \"markdown\", content: lines.join(\"\\n\") };\n}\n\n/**\n * Explain a root meta path (/.meta or /.meta/{subpath}).\n * Returns null if the path is not a recognized root meta path.\n */\nexport function explainRootMeta(path: string): AFSExplainResult | null {\n if (path === \"/.meta\") {\n const lines: string[] = [];\n lines.push(\"# Root Metadata\");\n lines.push(\"\");\n lines.push(\"The `.meta` system provides metadata about any AFS node.\");\n lines.push(\"\");\n lines.push(\"## Available Sub-paths\");\n lines.push(\"\");\n lines.push(\"- **`.capabilities`** — Aggregated capabilities from all mounted providers\");\n lines.push(\"\");\n lines.push(\n \"Use `read('/.meta')` to get structured root metadata including mounted providers and available actions.\",\n );\n return { format: \"markdown\", content: lines.join(\"\\n\") };\n }\n\n if (path === \"/.meta/.capabilities\") {\n const lines: string[] = [];\n lines.push(\"# Capabilities\");\n lines.push(\"\");\n lines.push(\"Aggregated capabilities manifest from all mounted providers.\");\n lines.push(\n \"Describes the combined operations, tools, and action catalogs available across the system.\",\n );\n lines.push(\"\");\n lines.push(\"Use `read('/.meta/.capabilities')` to get the full structured capabilities data.\");\n return { format: \"markdown\", content: lines.join(\"\\n\") };\n }\n\n return null;\n}\n"],"mappings":";;;;AAkBA,SAAgB,YAAY,OAAuB;AACjD,KAAI,UAAU,EAAG,QAAO;CACxB,MAAM,IAAI;CACV,MAAM,QAAQ;EAAC;EAAK;EAAM;EAAM;EAAM;EAAK;CAC3C,MAAM,IAAI,KAAK,MAAM,KAAK,IAAI,MAAM,GAAG,KAAK,IAAI,EAAE,CAAC;AACnD,QAAO,GAAG,OAAO,YAAY,QAAQ,KAAK,GAAG,QAAQ,EAAE,CAAC,CAAC,GAAG,MAAM;;;;;;AAOpE,SAAgB,qBACd,MACA,MACkB;CAClB,MAAM,QAAkB,EAAE;AAC1B,OAAM,KAAK,KAAK,OAAO;AACvB,OAAM,KAAK,GAAG;CAEd,MAAM,OAAO,KAAK,QAAQ,EAAE;AAE5B,KAAI,KAAK,SAAS,OAChB,OAAM,KAAK,eAAe,YAAY,KAAK,KAAe,GAAG;AAE/D,KAAI,KAAK,kBAAkB,OACzB,OAAM,KAAK,mBAAmB,KAAK,cAAc,QAAQ;AAE3D,KAAI,KAAK,UACP,OAAM,KAAK,mBAAmB,KA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