@lushly-dev/afd-server 2.4.0 → 3.0.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 (279) hide show
  1. package/README.md +239 -56
  2. package/dist/admission.d.ts +137 -0
  3. package/dist/admission.d.ts.map +1 -0
  4. package/dist/admission.js +144 -0
  5. package/dist/admission.js.map +1 -0
  6. package/dist/app-call-registry.d.ts +31 -0
  7. package/dist/app-call-registry.d.ts.map +1 -0
  8. package/dist/app-call-registry.js +64 -0
  9. package/dist/app-call-registry.js.map +1 -0
  10. package/dist/approval-admission.d.ts +139 -0
  11. package/dist/approval-admission.d.ts.map +1 -0
  12. package/dist/approval-admission.js +252 -0
  13. package/dist/approval-admission.js.map +1 -0
  14. package/dist/approval-crypto.d.ts +37 -17
  15. package/dist/approval-crypto.d.ts.map +1 -1
  16. package/dist/approval-crypto.js +84 -75
  17. package/dist/approval-crypto.js.map +1 -1
  18. package/dist/approval-process-state.d.ts +21 -0
  19. package/dist/approval-process-state.d.ts.map +1 -0
  20. package/dist/approval-process-state.js +29 -0
  21. package/dist/approval-process-state.js.map +1 -0
  22. package/dist/approval-relay.d.ts +192 -9
  23. package/dist/approval-relay.d.ts.map +1 -1
  24. package/dist/approval-relay.js +45 -9
  25. package/dist/approval-relay.js.map +1 -1
  26. package/dist/approval-up-front.d.ts +40 -0
  27. package/dist/approval-up-front.d.ts.map +1 -0
  28. package/dist/approval-up-front.js +409 -0
  29. package/dist/approval-up-front.js.map +1 -0
  30. package/dist/approval.d.ts +65 -12
  31. package/dist/approval.d.ts.map +1 -1
  32. package/dist/approval.js +311 -47
  33. package/dist/approval.js.map +1 -1
  34. package/dist/approver.d.ts +84 -0
  35. package/dist/approver.d.ts.map +1 -0
  36. package/dist/approver.js +107 -0
  37. package/dist/approver.js.map +1 -0
  38. package/dist/auth-middleware-check.d.ts +23 -0
  39. package/dist/auth-middleware-check.d.ts.map +1 -0
  40. package/dist/auth-middleware-check.js +48 -0
  41. package/dist/auth-middleware-check.js.map +1 -0
  42. package/dist/bootstrap/afd-context.d.ts.map +1 -1
  43. package/dist/bootstrap/afd-context.js +27 -3
  44. package/dist/bootstrap/afd-context.js.map +1 -1
  45. package/dist/bootstrap/afd-docs.d.ts.map +1 -1
  46. package/dist/bootstrap/afd-docs.js +4 -0
  47. package/dist/bootstrap/afd-docs.js.map +1 -1
  48. package/dist/bootstrap/afd-help.d.ts +4 -1
  49. package/dist/bootstrap/afd-help.d.ts.map +1 -1
  50. package/dist/bootstrap/afd-help.js +19 -4
  51. package/dist/bootstrap/afd-help.js.map +1 -1
  52. package/dist/bootstrap/described-command.d.ts +3 -1
  53. package/dist/bootstrap/described-command.d.ts.map +1 -1
  54. package/dist/bootstrap/described-command.js.map +1 -1
  55. package/dist/command-allow.d.ts +4 -4
  56. package/dist/command-allow.d.ts.map +1 -1
  57. package/dist/command-allow.js +10 -15
  58. package/dist/command-allow.js.map +1 -1
  59. package/dist/command-routing.d.ts +56 -8
  60. package/dist/command-routing.d.ts.map +1 -1
  61. package/dist/command-routing.js +82 -16
  62. package/dist/command-routing.js.map +1 -1
  63. package/dist/command-timeout.d.ts +17 -0
  64. package/dist/command-timeout.d.ts.map +1 -0
  65. package/dist/command-timeout.js +99 -0
  66. package/dist/command-timeout.js.map +1 -0
  67. package/dist/confirmation-gate.d.ts +7 -7
  68. package/dist/confirmation-gate.d.ts.map +1 -1
  69. package/dist/confirmation-gate.js +26 -12
  70. package/dist/confirmation-gate.js.map +1 -1
  71. package/dist/confirmations.d.ts +28 -3
  72. package/dist/confirmations.d.ts.map +1 -1
  73. package/dist/confirmations.js +6 -7
  74. package/dist/confirmations.js.map +1 -1
  75. package/dist/context-fields.d.ts +16 -1
  76. package/dist/context-fields.d.ts.map +1 -1
  77. package/dist/context-fields.js +30 -13
  78. package/dist/context-fields.js.map +1 -1
  79. package/dist/context-scope.d.ts +3 -3
  80. package/dist/context-scope.d.ts.map +1 -1
  81. package/dist/context-scope.js +7 -8
  82. package/dist/context-scope.js.map +1 -1
  83. package/dist/define-core.d.ts +63 -1
  84. package/dist/define-core.d.ts.map +1 -1
  85. package/dist/define-core.js +27 -4
  86. package/dist/define-core.js.map +1 -1
  87. package/dist/define.d.ts +4 -3
  88. package/dist/define.d.ts.map +1 -1
  89. package/dist/define.js +1 -1
  90. package/dist/define.js.map +1 -1
  91. package/dist/direct-registry.d.ts +54 -8
  92. package/dist/direct-registry.d.ts.map +1 -1
  93. package/dist/direct-registry.js +64 -8
  94. package/dist/direct-registry.js.map +1 -1
  95. package/dist/direct-tool-surface.d.ts +1 -1
  96. package/dist/direct-tool-surface.d.ts.map +1 -1
  97. package/dist/direct-tool-surface.js +28 -6
  98. package/dist/direct-tool-surface.js.map +1 -1
  99. package/dist/direct.d.ts +6 -2
  100. package/dist/direct.d.ts.map +1 -1
  101. package/dist/direct.js +4 -1
  102. package/dist/direct.js.map +1 -1
  103. package/dist/elicitation-state.d.ts +5 -1
  104. package/dist/elicitation-state.d.ts.map +1 -1
  105. package/dist/elicitation-state.js +4 -1
  106. package/dist/elicitation-state.js.map +1 -1
  107. package/dist/execution.d.ts +52 -6
  108. package/dist/execution.d.ts.map +1 -1
  109. package/dist/execution.js +183 -19
  110. package/dist/execution.js.map +1 -1
  111. package/dist/host-state.d.ts +81 -0
  112. package/dist/host-state.d.ts.map +1 -0
  113. package/dist/host-state.js +62 -0
  114. package/dist/host-state.js.map +1 -0
  115. package/dist/http-handler.d.ts +48 -11
  116. package/dist/http-handler.d.ts.map +1 -1
  117. package/dist/http-handler.js +207 -58
  118. package/dist/http-handler.js.map +1 -1
  119. package/dist/http-security.d.ts +14 -1
  120. package/dist/http-security.d.ts.map +1 -1
  121. package/dist/http-security.js +79 -17
  122. package/dist/http-security.js.map +1 -1
  123. package/dist/http-sessions.d.ts +45 -5
  124. package/dist/http-sessions.d.ts.map +1 -1
  125. package/dist/http-sessions.js +52 -10
  126. package/dist/http-sessions.js.map +1 -1
  127. package/dist/http-sse.d.ts +9 -0
  128. package/dist/http-sse.d.ts.map +1 -1
  129. package/dist/http-sse.js +12 -3
  130. package/dist/http-sse.js.map +1 -1
  131. package/dist/human-relay.d.ts +195 -0
  132. package/dist/human-relay.d.ts.map +1 -0
  133. package/dist/human-relay.js +670 -0
  134. package/dist/human-relay.js.map +1 -0
  135. package/dist/idempotency-step.d.ts +231 -0
  136. package/dist/idempotency-step.d.ts.map +1 -0
  137. package/dist/idempotency-step.js +389 -0
  138. package/dist/idempotency-step.js.map +1 -0
  139. package/dist/idempotency-store.d.ts +107 -0
  140. package/dist/idempotency-store.d.ts.map +1 -0
  141. package/dist/idempotency-store.js +100 -0
  142. package/dist/idempotency-store.js.map +1 -0
  143. package/dist/index.d.ts +18 -8
  144. package/dist/index.d.ts.map +1 -1
  145. package/dist/index.js +15 -4
  146. package/dist/index.js.map +1 -1
  147. package/dist/instance-state.d.ts +53 -0
  148. package/dist/instance-state.d.ts.map +1 -0
  149. package/dist/instance-state.js +94 -0
  150. package/dist/instance-state.js.map +1 -0
  151. package/dist/journal-off-tape.d.ts +52 -0
  152. package/dist/journal-off-tape.d.ts.map +1 -0
  153. package/dist/journal-off-tape.js +150 -0
  154. package/dist/journal-off-tape.js.map +1 -0
  155. package/dist/journal-replay.d.ts.map +1 -1
  156. package/dist/journal-replay.js +48 -3
  157. package/dist/journal-replay.js.map +1 -1
  158. package/dist/journal-view.d.ts +50 -0
  159. package/dist/journal-view.d.ts.map +1 -0
  160. package/dist/journal-view.js +214 -0
  161. package/dist/journal-view.js.map +1 -0
  162. package/dist/journal.d.ts +34 -6
  163. package/dist/journal.d.ts.map +1 -1
  164. package/dist/journal.js +183 -47
  165. package/dist/journal.js.map +1 -1
  166. package/dist/json-rpc.d.ts +3 -2
  167. package/dist/json-rpc.d.ts.map +1 -1
  168. package/dist/json-rpc.js +5 -3
  169. package/dist/json-rpc.js.map +1 -1
  170. package/dist/lazy-tools.d.ts +27 -2
  171. package/dist/lazy-tools.d.ts.map +1 -1
  172. package/dist/lazy-tools.js +22 -4
  173. package/dist/lazy-tools.js.map +1 -1
  174. package/dist/mcp-auth-bearer.d.ts +2 -0
  175. package/dist/mcp-auth-bearer.d.ts.map +1 -1
  176. package/dist/mcp-auth-bearer.js +1 -1
  177. package/dist/mcp-auth-bearer.js.map +1 -1
  178. package/dist/mcp-auth-dispatch.d.ts +38 -0
  179. package/dist/mcp-auth-dispatch.d.ts.map +1 -0
  180. package/dist/mcp-auth-dispatch.js +113 -0
  181. package/dist/mcp-auth-dispatch.js.map +1 -0
  182. package/dist/mcp-auth-jwt.d.ts +3 -2
  183. package/dist/mcp-auth-jwt.d.ts.map +1 -1
  184. package/dist/mcp-auth-jwt.js.map +1 -1
  185. package/dist/mcp-auth-resource.d.ts +6 -2
  186. package/dist/mcp-auth-resource.d.ts.map +1 -1
  187. package/dist/mcp-auth-resource.js +6 -5
  188. package/dist/mcp-auth-resource.js.map +1 -1
  189. package/dist/mcp-auth-scopes.d.ts +84 -0
  190. package/dist/mcp-auth-scopes.d.ts.map +1 -0
  191. package/dist/mcp-auth-scopes.js +125 -0
  192. package/dist/mcp-auth-scopes.js.map +1 -0
  193. package/dist/mcp-auth-view.d.ts +50 -0
  194. package/dist/mcp-auth-view.d.ts.map +1 -0
  195. package/dist/mcp-auth-view.js +179 -0
  196. package/dist/mcp-auth-view.js.map +1 -0
  197. package/dist/mcp-auth.d.ts +94 -3
  198. package/dist/mcp-auth.d.ts.map +1 -1
  199. package/dist/mcp-auth.js +241 -23
  200. package/dist/mcp-auth.js.map +1 -1
  201. package/dist/mcp-modern.d.ts +80 -6
  202. package/dist/mcp-modern.d.ts.map +1 -1
  203. package/dist/mcp-modern.js +378 -91
  204. package/dist/mcp-modern.js.map +1 -1
  205. package/dist/meta-argument.d.ts +9 -8
  206. package/dist/meta-argument.d.ts.map +1 -1
  207. package/dist/meta-argument.js +28 -10
  208. package/dist/meta-argument.js.map +1 -1
  209. package/dist/meta-tools.js +2 -2
  210. package/dist/meta-tools.js.map +1 -1
  211. package/dist/middleware.d.ts +16 -1
  212. package/dist/middleware.d.ts.map +1 -1
  213. package/dist/middleware.js +57 -10
  214. package/dist/middleware.js.map +1 -1
  215. package/dist/output-budget.d.ts +77 -0
  216. package/dist/output-budget.d.ts.map +1 -0
  217. package/dist/output-budget.js +202 -0
  218. package/dist/output-budget.js.map +1 -0
  219. package/dist/principal-binding.js +1 -1
  220. package/dist/principal-binding.js.map +1 -1
  221. package/dist/relay-evidence.d.ts +74 -0
  222. package/dist/relay-evidence.d.ts.map +1 -0
  223. package/dist/relay-evidence.js +143 -0
  224. package/dist/relay-evidence.js.map +1 -0
  225. package/dist/resources.d.ts +35 -10
  226. package/dist/resources.d.ts.map +1 -1
  227. package/dist/resources.js +59 -18
  228. package/dist/resources.js.map +1 -1
  229. package/dist/schema.d.ts +4 -3
  230. package/dist/schema.d.ts.map +1 -1
  231. package/dist/schema.js +3 -3
  232. package/dist/schema.js.map +1 -1
  233. package/dist/scope-view.d.ts +65 -0
  234. package/dist/scope-view.d.ts.map +1 -0
  235. package/dist/scope-view.js +45 -0
  236. package/dist/scope-view.js.map +1 -0
  237. package/dist/server-types.d.ts +182 -27
  238. package/dist/server-types.d.ts.map +1 -1
  239. package/dist/server-types.js.map +1 -1
  240. package/dist/server.d.ts +26 -0
  241. package/dist/server.d.ts.map +1 -1
  242. package/dist/server.js +403 -61
  243. package/dist/server.js.map +1 -1
  244. package/dist/skills.d.ts.map +1 -1
  245. package/dist/skills.js +99 -3
  246. package/dist/skills.js.map +1 -1
  247. package/dist/task-dispatch.d.ts +35 -0
  248. package/dist/task-dispatch.d.ts.map +1 -0
  249. package/dist/task-dispatch.js +25 -0
  250. package/dist/task-dispatch.js.map +1 -0
  251. package/dist/tasks-runtime.d.ts +115 -0
  252. package/dist/tasks-runtime.d.ts.map +1 -0
  253. package/dist/tasks-runtime.js +760 -0
  254. package/dist/tasks-runtime.js.map +1 -0
  255. package/dist/tasks.d.ts +237 -0
  256. package/dist/tasks.d.ts.map +1 -0
  257. package/dist/tasks.js +321 -0
  258. package/dist/tasks.js.map +1 -0
  259. package/dist/tool-router.d.ts +68 -3
  260. package/dist/tool-router.d.ts.map +1 -1
  261. package/dist/tool-router.js +293 -70
  262. package/dist/tool-router.js.map +1 -1
  263. package/dist/tools.d.ts +32 -0
  264. package/dist/tools.d.ts.map +1 -1
  265. package/dist/tools.js +162 -55
  266. package/dist/tools.js.map +1 -1
  267. package/dist/up-front-steps.d.ts +35 -0
  268. package/dist/up-front-steps.d.ts.map +1 -0
  269. package/dist/up-front-steps.js +159 -0
  270. package/dist/up-front-steps.js.map +1 -0
  271. package/dist/validation.d.ts +38 -3
  272. package/dist/validation.d.ts.map +1 -1
  273. package/dist/validation.js +118 -23
  274. package/dist/validation.js.map +1 -1
  275. package/dist/verified-credentials.d.ts +13 -5
  276. package/dist/verified-credentials.d.ts.map +1 -1
  277. package/dist/verified-credentials.js +43 -10
  278. package/dist/verified-credentials.js.map +1 -1
  279. package/package.json +15 -11
@@ -0,0 +1,202 @@
1
+ /**
2
+ * @fileoverview Server-side per-command output budgets (`spec/output-budgets.md`, B2 to B8):
3
+ * per-call ask binding, validation, effective budget calculation, canonical-JSON measurement,
4
+ * and the post-handler check (replacement for reads, caution warning for mutations, report in
5
+ * `metadata["dev.afd/outputBudget"]`).
6
+ *
7
+ * Browser-safe: imports no Node.js built-ins, no MCP SDK and no Zod.
8
+ */
9
+ import { AFD_OUTPUT_BUDGET_META_KEY, failure, MAX_OUTPUT_BUDGET_BYTES } from '@lushly-dev/afd-core';
10
+ /**
11
+ * Private context carrier for an output budget ask arriving from `_meta["dev.afd/outputBudget"]`,
12
+ * a meta-tool's `meta` argument, an in-process call option (`DirectExecuteOptions.outputBudget`),
13
+ * or `replayJournal()`. Registered with `Symbol.for` so separately loaded copies of `afd-server`
14
+ * agree on replay, matching `JOURNAL_REPLAY`.
15
+ */
16
+ export const OUTPUT_BUDGET_ASK = Symbol.for('@lushly-dev/afd-server/output-budget-ask');
17
+ /**
18
+ * Module-internal context marker set by buffered `executeStream()` so B5 is skipped on streamed
19
+ * commands (`spec/output-budgets.md`, B7: "A streamed command's chunks are not checked in this
20
+ * version; B5 applies to a command executed without streaming").
21
+ */
22
+ export const SKIP_OUTPUT_BUDGET = Symbol('afd.skipOutputBudget');
23
+ /**
24
+ * Module-internal immutable carrier of the effective output budget captured by the execution
25
+ * engine before middleware runs, so the journal records the exact limit B5 enforced even if
26
+ * middleware mutates `context.outputBudget` (B8).
27
+ */
28
+ export const EFFECTIVE_OUTPUT_BUDGET = Symbol('afd.effectiveOutputBudget');
29
+ const utf8 = new TextEncoder();
30
+ function isPlainObject(value) {
31
+ if (typeof value !== 'object' || value === null || Array.isArray(value))
32
+ return false;
33
+ const proto = Object.getPrototypeOf(value);
34
+ return proto === Object.prototype || proto === null;
35
+ }
36
+ /** Bind a raw output budget ask onto a copy of `context`. */
37
+ export function bindOutputBudgetAsk(context, ask) {
38
+ return { ...context, [OUTPUT_BUDGET_ASK]: ask };
39
+ }
40
+ /**
41
+ * Bind `_meta["dev.afd/outputBudget"]` onto `context` unless trusted host code (`createContext`)
42
+ * already set `outputBudget`.
43
+ */
44
+ export function withMetaOutputBudget(context, meta, trusted = {}) {
45
+ if (Object.hasOwn(trusted, 'outputBudget') && trusted.outputBudget !== undefined) {
46
+ return context;
47
+ }
48
+ if (!isPlainObject(meta) || !Object.hasOwn(meta, AFD_OUTPUT_BUDGET_META_KEY)) {
49
+ return context;
50
+ }
51
+ const ask = meta[AFD_OUTPUT_BUDGET_META_KEY];
52
+ return ask === undefined ? context : bindOutputBudgetAsk(context, ask);
53
+ }
54
+ /**
55
+ * Parse an ask in its `_meta` form: `{ "maxBytes": n }` where `n` is a safe integer in
56
+ * `1..=9007199254740991` and no other member is present. Returns `undefined` for anything else.
57
+ */
58
+ export function parseOutputBudgetAsk(value) {
59
+ if (!isPlainObject(value))
60
+ return undefined;
61
+ const keys = Object.keys(value);
62
+ if (keys.length !== 1 || keys[0] !== 'maxBytes')
63
+ return undefined;
64
+ const maxBytes = value.maxBytes;
65
+ if (typeof maxBytes !== 'number' ||
66
+ !Number.isSafeInteger(maxBytes) ||
67
+ maxBytes < 1 ||
68
+ maxBytes > MAX_OUTPUT_BUDGET_BYTES) {
69
+ return undefined;
70
+ }
71
+ return maxBytes;
72
+ }
73
+ /** Effective budget for a command with `declaration` and optional validated `ask` (B3). */
74
+ export function effectiveOutputBudget(declaration, ask) {
75
+ return ask === undefined ? declaration.defaultBytes : Math.min(ask, declaration.maxBytes);
76
+ }
77
+ /** The `VALIDATION_ERROR` returned for an invalid ask (B2). */
78
+ function invalidAskFailure() {
79
+ return failure({
80
+ code: 'VALIDATION_ERROR',
81
+ message: 'The output budget ask is not valid',
82
+ suggestion: `Send _meta["${AFD_OUTPUT_BUDGET_META_KEY}"] = { "maxBytes": <positive integer> }, or leave it out`,
83
+ retryable: false,
84
+ recovery: { kind: 'external' },
85
+ details: { field: 'outputBudget', meta: AFD_OUTPUT_BUDGET_META_KEY },
86
+ });
87
+ }
88
+ /**
89
+ * Validate the call's output budget ask and set `context.outputBudget` to the effective budget
90
+ * in place (B2, B3, B4).
91
+ *
92
+ * A value set directly on `context.outputBudget` by trusted code (`createContext` or in-process
93
+ * caller) wins over `_meta["dev.afd/outputBudget"]`. An ask on an unbudgeted command is still
94
+ * validated and then ignored (`context.outputBudget` is cleared).
95
+ */
96
+ export function applyOutputBudget(command, context) {
97
+ const carrier = context;
98
+ let rawAsk;
99
+ if (Object.hasOwn(context, 'outputBudget') && context.outputBudget !== undefined) {
100
+ const trusted = context.outputBudget;
101
+ rawAsk = typeof trusted === 'number' ? { maxBytes: trusted } : trusted;
102
+ }
103
+ else {
104
+ rawAsk = carrier[OUTPUT_BUDGET_ASK];
105
+ }
106
+ delete context.outputBudget;
107
+ delete carrier[OUTPUT_BUDGET_ASK];
108
+ let askBytes;
109
+ if (rawAsk !== undefined && rawAsk !== null) {
110
+ askBytes = parseOutputBudgetAsk(rawAsk);
111
+ if (askBytes === undefined)
112
+ return invalidAskFailure();
113
+ }
114
+ if (command.outputBudget) {
115
+ context.outputBudget = effectiveOutputBudget(command.outputBudget, askBytes);
116
+ }
117
+ return undefined;
118
+ }
119
+ /**
120
+ * Measure the UTF-8 byte length of the canonical JSON of `result` with its top-level `metadata`
121
+ * member removed (B5, step 2).
122
+ *
123
+ * JavaScript's `JSON.stringify` emits compact JSON with the spec's exact string escaping and
124
+ * number spelling, and object key order never changes UTF-8 byte length. Returns `undefined` if
125
+ * `result` cannot be serialized as JSON (e.g. a circular reference or `bigint`).
126
+ */
127
+ export function measureOutputBudgetBytes(result) {
128
+ try {
129
+ // Null prototype so an own top-level "__proto__" key is preserved as data rather than
130
+ // mutating the object's prototype and disappearing from JSON.stringify.
131
+ const withoutMetadata = Object.create(null);
132
+ const record = result;
133
+ for (const key of Object.keys(record)) {
134
+ if (key !== 'metadata')
135
+ withoutMetadata[key] = record[key];
136
+ }
137
+ const json = JSON.stringify(withoutMetadata);
138
+ if (json === undefined)
139
+ return undefined;
140
+ return utf8.encode(json).length;
141
+ }
142
+ catch {
143
+ return undefined;
144
+ }
145
+ }
146
+ /**
147
+ * Post-handler output budget check (B5, B6).
148
+ *
149
+ * - Failures and unbudgeted calls pass unchanged with no report.
150
+ * - Within budget: keeps the result and attaches `metadata["dev.afd/outputBudget"]`.
151
+ * - Over budget, read (`mutation` unset or `false`): replaces with `OUTPUT_BUDGET_EXCEEDED`
152
+ * failure and no report.
153
+ * - Over budget, mutation (`mutation: true`): keeps the result, appends a `caution`
154
+ * `OUTPUT_BUDGET_EXCEEDED` warning (not counted in `usedBytes`), and attaches the report.
155
+ */
156
+ export function checkOutputBudgetResult(command, limitBytes, result) {
157
+ const declaration = command.outputBudget;
158
+ if (!declaration || result.success !== true)
159
+ return result;
160
+ const usedBytes = measureOutputBudgetBytes(result);
161
+ if (usedBytes === undefined)
162
+ return result;
163
+ if (usedBytes > limitBytes && command.mutation !== true) {
164
+ const { maxBytes } = declaration;
165
+ const suggestion = limitBytes < maxBytes
166
+ ? `Narrow the request (fewer results, a smaller window or a filter), or ask for up to ${maxBytes} bytes with _meta["${AFD_OUTPUT_BUDGET_META_KEY}"] = { "maxBytes": ${maxBytes} }.`
167
+ : `Narrow the request (fewer results, a smaller window or a filter); ${maxBytes} bytes is this command's largest output budget.`;
168
+ return failure({
169
+ code: 'OUTPUT_BUDGET_EXCEEDED',
170
+ message: `The result is ${usedBytes} bytes, over this call's output budget of ${limitBytes} bytes`,
171
+ suggestion,
172
+ retryable: false,
173
+ recovery: { kind: 'external' },
174
+ details: { limitBytes, actualBytes: usedBytes, maxBytes },
175
+ });
176
+ }
177
+ const report = { limitBytes, usedBytes };
178
+ if (usedBytes > limitBytes) {
179
+ const warning = {
180
+ code: 'OUTPUT_BUDGET_EXCEEDED',
181
+ message: `The result is ${usedBytes} bytes, over this call's output budget of ${limitBytes} bytes; the change was made`,
182
+ severity: 'caution',
183
+ details: { limitBytes, actualBytes: usedBytes },
184
+ };
185
+ return {
186
+ ...result,
187
+ warnings: [...(result.warnings ?? []), warning],
188
+ metadata: {
189
+ ...result.metadata,
190
+ [AFD_OUTPUT_BUDGET_META_KEY]: report,
191
+ },
192
+ };
193
+ }
194
+ return {
195
+ ...result,
196
+ metadata: {
197
+ ...result.metadata,
198
+ [AFD_OUTPUT_BUDGET_META_KEY]: report,
199
+ },
200
+ };
201
+ }
202
+ //# sourceMappingURL=output-budget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output-budget.js","sourceRoot":"","sources":["../src/output-budget.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,0BAA0B,EAAE,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAEpG;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAkB,MAAM,CAAC,GAAG,CACzD,0CAA0C,CAC1C,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAkB,MAAM,CAAC,sBAAsB,CAAC,C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IACzC,IAAI,SAAS,GAAG,UAAU,EAAE,CAAC;QAC5B,MAAM,OAAO,GAAY;YACxB,IAAI,EAAE,wBAAwB;YAC9B,OAAO,EAAE,iBAAiB,SAAS,6CAA6C,UAAU,6BAA6B;YACvH,QAAQ,EAAE,SAAS;YACnB,OAAO,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE;SAC/C,CAAC;QACF,OAAO;YACN,GAAG,MAAM;YACT,QAAQ,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,OAAO,CAAC;YAC/C,QAAQ,EAAE;gBACT,GAAG,MAAM,CAAC,QAAQ;gBAClB,CAAC,0BAA0B,CAAC,EAAE,MAAM;aACpC;SACD,CAAC;IACH,CAAC;IAED,OAAO;QACN,GAAG,MAAM;QACT,QAAQ,EAAE;YACT,GAAG,MAAM,CAAC,QAAQ;YAClB,CAAC,0BAA0B,CAAC,EAAE,MAAM;SACpC;KACD,CAAC;AACH,CAAC"}
@@ -5,7 +5,7 @@
5
5
  * Loads no Node.js built-in: the canonical JSON is the approval tokens' (`approval-crypto.ts`),
6
6
  * which runs in the browser too.
7
7
  */
8
- import { canonicalJson } from './approval-crypto.js';
8
+ import { canonicalJson } from '@lushly-dev/afd-core/internal/canonical-json';
9
9
  function isRecord(value) {
10
10
  return !!value && typeof value === 'object' && !Array.isArray(value);
11
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"principal-binding.js","sourceRoot":"","sources":["../src/principal-binding.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAgBrD,SAAS,QAAQ,CAAC,KAAc;IAC/B,OAAO,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACtE,CAAC;AAED;;;;;GAKG;AACH,SAAS,QAAQ,CAAC,WAA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I,SAAS,CAAC,yBAAyB,CAAC,CAAC;IACrE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC;AACzE,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,gBAAgB,CAC/B,KAA+B,EAC/B,WAAyC;IAEzC,OAAO,aAAa,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,EAAE,WAAW,EAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;AAC3F,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,WAAyC;IAC3E,OAAO,aAAa,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * @fileoverview Private relay evidence carrier (`spec/approvals.md`, "Relay evidence").
3
+ *
4
+ * Set only by the MCP server's `HumanRelay` gate after `resume` returns `Approved`, read by
5
+ * `createApprovalMiddleware`, and cleared by the execution engine before the command handler runs.
6
+ * Never exported publicly, never read from tool arguments, `_meta`, headers or `requestState`,
7
+ * and never stored as a property on `CommandContext` (so `JSON.stringify`, `Object.keys`,
8
+ * `Object.getOwnPropertySymbols` and `util.inspect(ctx, { showHidden: true })` never expose it).
9
+ *
10
+ * Records live in one `WeakMap` on `globalThis` under a registered symbol, installed as a
11
+ * non-writable, non-configurable, non-enumerable property (matching `approval-admission.ts`), so
12
+ * split installations of `@lushly-dev/afd-server` (an engine from one copy and approval middleware
13
+ * from another) share the carrier cleanly.
14
+ *
15
+ * Module-graph rule: loads no Node.js built-in and no MCP SDK, so `/direct` stays browser-safe.
16
+ */
17
+ import type { CommandContext } from '@lushly-dev/afd-core';
18
+ /**
19
+ * Server-private approval evidence from an approved `HumanRelay` decision.
20
+ */
21
+ export interface RelayEvidence {
22
+ readonly command: string;
23
+ readonly inputDigest: string;
24
+ readonly actor: string;
25
+ readonly credentialsBinding: string;
26
+ readonly decisionId: string;
27
+ }
28
+ /**
29
+ * One-shot dispatch guard for a host-verified call, checked immediately before the handler runs
30
+ * regardless of whether the command also declares an `approval` policy.
31
+ */
32
+ export interface RelayDispatchAdmission {
33
+ readonly command: string;
34
+ readonly canonical: string;
35
+ readonly canonicalize: (value: unknown) => string | undefined;
36
+ taken?: boolean;
37
+ }
38
+ /**
39
+ * The shared map on `holder` (`globalThis`) when another copy installed it as this module does,
40
+ * else a fresh one, installed on `holder` when the key is free. Exported for tests.
41
+ */
42
+ export declare function installRelayEvidenceRecords(holder?: object): WeakMap<object, unknown>;
43
+ /** Attach `evidence` to `context` off-object in the private WeakMap. */
44
+ export declare function attachRelayEvidence(context: CommandContext, evidence: RelayEvidence): void;
45
+ /** Return a copy of `context` carrying private `evidence`. */
46
+ export declare function bindRelayEvidence(context: CommandContext, evidence: RelayEvidence): CommandContext;
47
+ /** Read the private relay evidence bound to `context`, if any. */
48
+ export declare function relayEvidenceOf(context: CommandContext | undefined): RelayEvidence | undefined;
49
+ /** Clear private relay evidence (and any unused prevalidated input) before the handler runs. */
50
+ export declare function clearRelayEvidence(context: CommandContext): void;
51
+ /** Attach already-validated input for a host-verified dispatch so dynamic defaults never drift. */
52
+ export declare function attachRelayValidatedInput(context: CommandContext, command: string, data: unknown): void;
53
+ /** Take the already-validated input for `command` once, if attached. */
54
+ export declare function takeRelayValidatedInput(context: CommandContext | undefined, command: string): {
55
+ found: true;
56
+ data: unknown;
57
+ } | undefined;
58
+ /** Attach a one-shot host-verified dispatch admission for `context`. */
59
+ export declare function attachRelayDispatchAdmission(context: CommandContext, admission: Omit<RelayDispatchAdmission, 'taken'>): void;
60
+ /**
61
+ * Carry private relay state from `from` (`callerContext`) onto the engine's per-call `to`
62
+ * (`context`) object, once only (on the `HumanRelay` -> engine handoff). Never moves or deletes
63
+ * state off an active engine context, so nested `execute(..., context)` calls neither steal the
64
+ * outer call's retry guard nor inherit its `taken` admission.
65
+ */
66
+ export declare function transferRelayState(from: CommandContext, to: CommandContext): void;
67
+ /**
68
+ * Consume the one-shot host-verified dispatch admission on `context` right before invoking the
69
+ * handler. Returns `'none'` for non-relay calls, `'admitted'` when this dispatch matches the
70
+ * command and canonical input the person confirmed, and `'mismatch'` if input was mutated in
71
+ * middleware or a retry middleware attempted a second dispatch under the same decision.
72
+ */
73
+ export declare function takeRelayDispatchAdmission(context: CommandContext, commandName: string, data: unknown): 'none' | 'admitted' | 'mismatch';
74
+ //# sourceMappingURL=relay-evidence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relay-evidence.d.ts","sourceRoot":"","sources":["../src/relay-evidence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC5B;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,YAAY,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,GAAG,SAAS,CAAC;IAC9D,KAAK,CAAC,EAAE,OAAO,CAAC;CAChB;AAeD;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,GAAE,MAAmB,GAAG,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CA4BjG;AAkBD,wEAAwE;AACxE,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI,CAE1F;AAED,8DAA8D;AAC9D,wBAAgB,iBAAiB,CAChC,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,aAAa,GACrB,cAAc,CAIhB;AAED,kEAAkE;AAClE,wBAAgB,eAAe,CAAC,OAAO,EAAE,cAAc,GAAG,SAAS,GAAG,aAAa,GAAG,SAAS,CAE9F;AAED,gGAAgG;AAChG,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAQhE;AAED,mGAAmG;AACnG,wBAAgB,yBAAyB,CACxC,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,OAAO,GACX,IAAI,CAEN;AAED,wEAAwE;AACxE,wBAAgB,uBAAuB,CACtC,OAAO,EAAE,cAAc,GAAG,SAAS,EACnC,OAAO,EAAE,MAAM,GACb;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,CAM5C;AAED,wEAAwE;AACxE,wBAAgB,4BAA4B,CAC3C,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,IAAI,CAAC,sBAAsB,EAAE,OAAO,CAAC,GAC9C,IAAI,CAEN;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,cAAc,EAAE,EAAE,EAAE,cAAc,GAAG,IAAI,CAMjF;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACzC,OAAO,EAAE,cAAc,EACvB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,OAAO,GACX,MAAM,GAAG,UAAU,GAAG,UAAU,CASlC"}
@@ -0,0 +1,143 @@
1
+ /**
2
+ * @fileoverview Private relay evidence carrier (`spec/approvals.md`, "Relay evidence").
3
+ *
4
+ * Set only by the MCP server's `HumanRelay` gate after `resume` returns `Approved`, read by
5
+ * `createApprovalMiddleware`, and cleared by the execution engine before the command handler runs.
6
+ * Never exported publicly, never read from tool arguments, `_meta`, headers or `requestState`,
7
+ * and never stored as a property on `CommandContext` (so `JSON.stringify`, `Object.keys`,
8
+ * `Object.getOwnPropertySymbols` and `util.inspect(ctx, { showHidden: true })` never expose it).
9
+ *
10
+ * Records live in one `WeakMap` on `globalThis` under a registered symbol, installed as a
11
+ * non-writable, non-configurable, non-enumerable property (matching `approval-admission.ts`), so
12
+ * split installations of `@lushly-dev/afd-server` (an engine from one copy and approval middleware
13
+ * from another) share the carrier cleanly.
14
+ *
15
+ * Module-graph rule: loads no Node.js built-in and no MCP SDK, so `/direct` stays browser-safe.
16
+ */
17
+ const KEY = Symbol.for('dev.afd/relay-evidence');
18
+ // Captured once, so later changes to WeakMap.prototype do not reach these records.
19
+ const weakGet = WeakMap.prototype.get;
20
+ const weakSet = WeakMap.prototype.set;
21
+ const weakDelete = WeakMap.prototype.delete;
22
+ /**
23
+ * The shared map on `holder` (`globalThis`) when another copy installed it as this module does,
24
+ * else a fresh one, installed on `holder` when the key is free. Exported for tests.
25
+ */
26
+ export function installRelayEvidenceRecords(holder = globalThis) {
27
+ const existing = Object.getOwnPropertyDescriptor(holder, KEY);
28
+ if (existing === undefined) {
29
+ const map = new WeakMap();
30
+ try {
31
+ Object.defineProperty(holder, KEY, {
32
+ value: map,
33
+ writable: false,
34
+ configurable: false,
35
+ enumerable: false,
36
+ });
37
+ }
38
+ catch {
39
+ // A frozen or non-extensible global: keep the records private.
40
+ }
41
+ return map;
42
+ }
43
+ const value = existing.value;
44
+ if ('value' in existing &&
45
+ existing.writable === false &&
46
+ existing.configurable === false &&
47
+ value instanceof WeakMap &&
48
+ Object.getPrototypeOf(value) === WeakMap.prototype &&
49
+ Reflect.ownKeys(value).length === 0) {
50
+ return value;
51
+ }
52
+ return new WeakMap();
53
+ }
54
+ const RECORDS = installRelayEvidenceRecords();
55
+ function getOrCreate(context) {
56
+ let carrier = weakGet.call(RECORDS, context);
57
+ if (!carrier) {
58
+ carrier = {};
59
+ weakSet.call(RECORDS, context, carrier);
60
+ }
61
+ return carrier;
62
+ }
63
+ function getCarrier(context) {
64
+ if (!context)
65
+ return undefined;
66
+ return weakGet.call(RECORDS, context);
67
+ }
68
+ /** Attach `evidence` to `context` off-object in the private WeakMap. */
69
+ export function attachRelayEvidence(context, evidence) {
70
+ getOrCreate(context).evidence = evidence;
71
+ }
72
+ /** Return a copy of `context` carrying private `evidence`. */
73
+ export function bindRelayEvidence(context, evidence) {
74
+ const copy = { ...context };
75
+ attachRelayEvidence(copy, evidence);
76
+ return copy;
77
+ }
78
+ /** Read the private relay evidence bound to `context`, if any. */
79
+ export function relayEvidenceOf(context) {
80
+ return getCarrier(context)?.evidence;
81
+ }
82
+ /** Clear private relay evidence (and any unused prevalidated input) before the handler runs. */
83
+ export function clearRelayEvidence(context) {
84
+ const carrier = getCarrier(context);
85
+ if (!carrier)
86
+ return;
87
+ carrier.evidence = undefined;
88
+ carrier.validatedInput = undefined;
89
+ if (!carrier.dispatchAdmission) {
90
+ weakDelete.call(RECORDS, context);
91
+ }
92
+ }
93
+ /** Attach already-validated input for a host-verified dispatch so dynamic defaults never drift. */
94
+ export function attachRelayValidatedInput(context, command, data) {
95
+ getOrCreate(context).validatedInput = { command, data };
96
+ }
97
+ /** Take the already-validated input for `command` once, if attached. */
98
+ export function takeRelayValidatedInput(context, command) {
99
+ const carrier = getCarrier(context);
100
+ const entry = carrier?.validatedInput;
101
+ if (!entry || entry.command !== command)
102
+ return undefined;
103
+ carrier.validatedInput = undefined;
104
+ return { found: true, data: entry.data };
105
+ }
106
+ /** Attach a one-shot host-verified dispatch admission for `context`. */
107
+ export function attachRelayDispatchAdmission(context, admission) {
108
+ getOrCreate(context).dispatchAdmission = { ...admission, taken: false };
109
+ }
110
+ /**
111
+ * Carry private relay state from `from` (`callerContext`) onto the engine's per-call `to`
112
+ * (`context`) object, once only (on the `HumanRelay` -> engine handoff). Never moves or deletes
113
+ * state off an active engine context, so nested `execute(..., context)` calls neither steal the
114
+ * outer call's retry guard nor inherit its `taken` admission.
115
+ */
116
+ export function transferRelayState(from, to) {
117
+ const carrier = getCarrier(from);
118
+ if (!carrier || carrier.transferred)
119
+ return;
120
+ weakDelete.call(RECORDS, from);
121
+ carrier.transferred = true;
122
+ weakSet.call(RECORDS, to, carrier);
123
+ }
124
+ /**
125
+ * Consume the one-shot host-verified dispatch admission on `context` right before invoking the
126
+ * handler. Returns `'none'` for non-relay calls, `'admitted'` when this dispatch matches the
127
+ * command and canonical input the person confirmed, and `'mismatch'` if input was mutated in
128
+ * middleware or a retry middleware attempted a second dispatch under the same decision.
129
+ */
130
+ export function takeRelayDispatchAdmission(context, commandName, data) {
131
+ const carrier = getCarrier(context);
132
+ const admission = carrier?.dispatchAdmission;
133
+ if (!admission)
134
+ return 'none';
135
+ if (admission.taken)
136
+ return 'mismatch';
137
+ admission.taken = true;
138
+ if (admission.command !== commandName)
139
+ return 'mismatch';
140
+ const canonical = admission.canonicalize(data);
141
+ return canonical !== undefined && canonical === admission.canonical ? 'admitted' : 'mismatch';
142
+ }
143
+ //# sourceMappingURL=relay-evidence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relay-evidence.js","sourceRoot":"","sources":["../src/relay-evidence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAiCH,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;AACjD,mFAAmF;AACnF,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC;AACtC,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC;AACtC,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC;AAE5C;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CAAC,MAAM,GAAW,UAAU;IACtE,MAAM,QAAQ,GAAG,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9D,IAAI,QAAQ,KAAK,SAAS,EAAE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AAS,IAAI,SAAS,KAAK,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC;AAC/F,CAAC"}
@@ -12,6 +12,8 @@
12
12
  * unknown URI is `-32602` with `data.uri` on both MCP eras.
13
13
  */
14
14
  import { ProtocolError, type Server } from '@modelcontextprotocol/server';
15
+ import type { Credentials } from './mcp-auth-rules.js';
16
+ import type { ScopeView } from './scope-view.js';
15
17
  import { type SkillCatalog } from './skills.js';
16
18
  /** The MIME type MCP Apps requires of a `ui://` resource. */
17
19
  export declare const MCP_APP_MIME_TYPE = "text/html;profile=mcp-app";
@@ -61,23 +63,38 @@ export interface ResourceContents {
61
63
  */
62
64
  _meta?: Record<string, unknown>;
63
65
  }
66
+ /**
67
+ * Who is listing or reading resources: what a {@link ResourceProvider} may gate on
68
+ * (`spec/authorization.md`, M6, "Other methods"; `spec/mcp-resources.md`, R3/R4). Fields can be
69
+ * added without breaking providers.
70
+ */
71
+ export interface ResourceCaller {
72
+ /**
73
+ * The verified credentials of the request on a server configured with MCP authorization;
74
+ * `undefined` on unauthenticated servers and over stdio.
75
+ */
76
+ readonly credentials?: Credentials;
77
+ }
64
78
  /**
65
79
  * What a server is given to serve resources (`spec/mcp-resources.md`, "Terms").
66
80
  *
67
- * `list` is called each time the server lists, so a provider may change its entries while the
68
- * server runs; the list MUST NOT vary by caller, connection or context, and an AFD provider is
69
- * given no request input. An entry with `content` is served by the server; any other is read
70
- * through `read`.
81
+ * `list` is called with no `caller` at server startup (to check static entries) and with a
82
+ * {@link ResourceCaller} on each `resources/list` and `resources/read` request so a provider may
83
+ * filter entries per caller on an authorized server. The list MUST NOT vary by connection, 2025
84
+ * session or `_meta["dev.afd/context"]`. An entry with `content` is served by the server; any
85
+ * other is read through `read`.
71
86
  */
72
87
  export interface ResourceProvider {
73
88
  /** The entries, in the order `resources/list` returns them. */
74
- list(): readonly ResourceEntry[];
89
+ list(caller?: ResourceCaller): readonly ResourceEntry[];
75
90
  /**
76
91
  * The content at `uri`, or `undefined` when the provider serves nothing there (`-32602`). A
77
92
  * server MAY serve a URI it does not list, so this is called for every URI that is not a skill
78
- * file and not an entry with `content`. A throw is `-32603`, reported to `onError`.
93
+ * file and not an entry with `content`. Return `undefined` for a resource `caller` may not
94
+ * read so that it answers identically to an absent URI. A throw is `-32603`, reported to
95
+ * `onError`.
79
96
  */
80
- read?(uri: string): ResourceContents | undefined | Promise<ResourceContents | undefined>;
97
+ read?(uri: string, caller?: ResourceCaller): ResourceContents | undefined | Promise<ResourceContents | undefined>;
81
98
  }
82
99
  /** What `createMcpServer` and `createMcpHandler` take as `resources`: a provider, or static entries. */
83
100
  export type ResourcesOption = ResourceProvider | readonly ResourceEntry[];
@@ -87,6 +104,8 @@ export declare function checkEntries(entries: readonly ResourceEntry[]): void;
87
104
  export interface ResourceService {
88
105
  /** The capabilities to declare in `server/discover` and `initialize` (R1, S1). */
89
106
  readonly capabilities: Record<string, unknown>;
107
+ /** Whether this service has a {@link ResourceProvider} attached (as opposed to skills only). */
108
+ readonly hasProvider: boolean;
90
109
  /** Install the handlers on one `Server` instance. */
91
110
  install(server: Server, options: ResourceServing): void;
92
111
  }
@@ -96,6 +115,12 @@ export interface ResourceServing {
96
115
  modern: boolean;
97
116
  /** The error a failure while serving becomes (`-32603`, reported to `onError`). */
98
117
  internalError(error: unknown): ProtocolError;
118
+ /** The current request's scope view, when MCP authorization is configured on HTTP. */
119
+ requestView?: () => ScopeView | undefined;
120
+ /** Whether MCP authorization is configured on this server (R3/R4 `cacheScope`). */
121
+ authConfigured?: boolean;
122
+ /** Whether requests must carry an admitted scope view (HTTP with `auth`, M1 fail-closed). */
123
+ requireView?: boolean;
99
124
  }
100
125
  /**
101
126
  * Build the resource service, or `undefined` when the server was given neither a provider nor a
@@ -105,10 +130,10 @@ export interface ResourceServing {
105
130
  */
106
131
  export declare function createResourceService(option: ResourcesOption | undefined, skills: SkillCatalog | undefined, ttlMs: number): ResourceService | undefined;
107
132
  /** The cache hints the SDK applies to the standard resource results of a modern-era server. */
108
- export declare function resourceCacheHints(ttlMs: number): {
133
+ export declare function resourceCacheHints(ttlMs: number, privateProvider?: boolean): {
109
134
  readonly 'resources/list': {
110
135
  readonly ttlMs: number;
111
- readonly cacheScope: 'public';
136
+ readonly cacheScope: "private" | "public";
112
137
  };
113
138
  readonly 'resources/templates/list': {
114
139
  readonly ttlMs: number;
@@ -116,7 +141,7 @@ export declare function resourceCacheHints(ttlMs: number): {
116
141
  };
117
142
  readonly 'resources/read': {
118
143
  readonly ttlMs: number;
119
- readonly cacheScope: 'public';
144
+ readonly cacheScope: "private" | "public";
120
145
  };
121
146
  };
122
147
  //# sourceMappingURL=resources.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../src/resources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,aAAa,EAAqB,KAAK,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAG7F,OAAO,EAAwC,KAAK,YAAY,EAAgB,MAAM,aAAa,CAAC;AAEpG,6DAA6D;AAC7D,eAAO,MAAM,iBAAiB,8BAA8B,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC7B,kGAAkG;IAClG,GAAG,EAAE,MAAM,CAAC;IACZ,iBAAiB;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,sEAAsE;IACtE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC;;;;O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