apps 0.0.1-beta.1 → 0.0.1-beta.100

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 (211) hide show
  1. package/README.md +112 -72
  2. package/framework-reference.json +1 -1
  3. package/js/browser-XIPJGLH2.js +65 -0
  4. package/js/chunk-2CURR5Y7.js +264 -0
  5. package/js/chunk-2LSGC7XY.js +42 -0
  6. package/js/{chunk-YEJOQEII.js → chunk-4PIQKACY.js} +65 -10
  7. package/js/chunk-4UPC36ZL.js +5185 -0
  8. package/js/{chunk-4LPG6RCH.js → chunk-4X2UI4R2.js} +7 -27
  9. package/js/chunk-5C6RAGAS.js +335 -0
  10. package/js/chunk-62NVUKED.js +39 -0
  11. package/js/chunk-74H25C4X.js +95 -0
  12. package/js/chunk-7HG422GB.js +90 -0
  13. package/js/chunk-7STIP5CS.js +171 -0
  14. package/js/{chunk-QKHR7BMF.js → chunk-ACQXVKVQ.js} +87 -51
  15. package/js/{chunk-OHRT55C4.js → chunk-DILSCQPJ.js} +226 -265
  16. package/js/chunk-ILYCJ3HV.js +449 -0
  17. package/js/chunk-K6TSCYAO.js +712 -0
  18. package/js/{chunk-EVJUVWN2.js → chunk-KLSEU35Y.js} +463 -218
  19. package/js/chunk-OD3KFKZD.js +1617 -0
  20. package/js/chunk-OWN3DP2W.js +88 -0
  21. package/js/{chunk-ZTFQHGEB.js → chunk-PBGPES67.js} +3 -5
  22. package/js/chunk-QI66R4FP.js +786 -0
  23. package/js/chunk-RN4YB4JT.js +1922 -0
  24. package/js/{chunk-ZCAMUXSG.js → chunk-URKOTNDA.js} +795 -177
  25. package/js/{chunk-NCYXZN2G.js → chunk-UVL56Z6E.js} +390 -23
  26. package/js/{chunk-2HHMABB6.js → chunk-VAI3EVCS.js} +700 -78
  27. package/js/chunk-VCYWAA4N.js +49 -0
  28. package/js/{chunk-HDJH3RPR.js → chunk-YDW7DX3A.js} +4 -4
  29. package/js/chunk-YWVISRZD.js +268 -0
  30. package/js/{chunk-FW5HBOIK.js → chunk-ZKDXML77.js} +19272 -18299
  31. package/js/client.js +148 -100
  32. package/js/contracts.js +208 -24
  33. package/js/effect.js +18 -19
  34. package/js/es-DIULA3ZF.js +39371 -0
  35. package/js/graphql.js +62 -58
  36. package/js/host.js +83 -60
  37. package/js/index.js +381 -263
  38. package/js/mcp/effect.js +21 -21
  39. package/js/mcp.js +117 -74
  40. package/js/openapi.js +4613 -42691
  41. package/js/react.js +2 -3
  42. package/js/skills/effect.js +6 -4
  43. package/js/skills.js +233 -70
  44. package/js/storage/facet.js +1 -540
  45. package/js/ui/auth/contracts.js +8 -9
  46. package/js/ui/auth.js +16 -14
  47. package/js/ui/contracts.js +9 -8
  48. package/js/ui/serving.js +8609 -227
  49. package/package.json +3 -8
  50. package/runtime.json +1 -1
  51. package/types/app-cache/src/contracts/cache.d.ts +60 -2
  52. package/types/app-cache/src/index.d.ts +92 -2
  53. package/types/app-data/src/contracts/database.d.ts +33 -6
  54. package/types/apps/src/contracts/api-response-error.d.ts +4 -0
  55. package/types/apps/src/contracts/app.d.ts +63 -17
  56. package/types/apps/src/contracts/cache.d.ts +24 -1
  57. package/types/apps/src/contracts/context.d.ts +60 -17
  58. package/types/apps/src/contracts/elicitation.d.ts +23 -7
  59. package/types/apps/src/contracts/events.d.ts +94 -0
  60. package/types/apps/src/contracts/failure.d.ts +54 -0
  61. package/types/apps/src/contracts/graphql.d.ts +2 -1
  62. package/types/apps/src/contracts/host.d.ts +1325 -534
  63. package/types/apps/src/contracts/icons.d.ts +28 -0
  64. package/types/apps/src/contracts/live.d.ts +2 -0
  65. package/types/apps/src/contracts/mcp.d.ts +97 -20
  66. package/types/apps/src/contracts/network.d.ts +120 -0
  67. package/types/apps/src/contracts/openapi-compile.d.ts +82 -3
  68. package/types/apps/src/contracts/openapi-document.d.ts +1 -1
  69. package/types/apps/src/contracts/openapi.d.ts +51 -9
  70. package/types/apps/src/contracts/operations.d.ts +14 -12
  71. package/types/apps/src/contracts/placement.d.ts +102 -0
  72. package/types/apps/src/contracts/protocol-version.d.ts +6 -0
  73. package/types/apps/src/contracts/protocols/1.d.ts +2241 -0
  74. package/types/apps/src/contracts/protocols/10.d.ts +1450 -0
  75. package/types/apps/src/contracts/protocols/11.d.ts +1149 -0
  76. package/types/apps/src/contracts/protocols/12.d.ts +3310 -0
  77. package/types/apps/src/contracts/protocols/2.d.ts +711 -0
  78. package/types/apps/src/contracts/protocols/3.d.ts +776 -0
  79. package/types/apps/src/contracts/protocols/4.d.ts +1306 -0
  80. package/types/apps/src/contracts/protocols/5.d.ts +1200 -0
  81. package/types/apps/src/contracts/protocols/6.d.ts +1629 -0
  82. package/types/apps/src/contracts/protocols/7.d.ts +1785 -0
  83. package/types/apps/src/contracts/protocols/8.d.ts +1182 -0
  84. package/types/apps/src/contracts/protocols/9.d.ts +1104 -0
  85. package/types/apps/src/contracts/protocols/current.d.ts +6857 -0
  86. package/types/apps/src/contracts/protocols/oauth-6.d.ts +74 -0
  87. package/types/apps/src/contracts/protocols/oauth.d.ts +134 -0
  88. package/types/apps/src/contracts/provider-error.d.ts +9 -0
  89. package/types/apps/src/contracts/provider.d.ts +140 -10
  90. package/types/apps/src/contracts/router.d.ts +59 -0
  91. package/types/apps/src/contracts/schedules.d.ts +7 -1
  92. package/types/apps/src/contracts/schema.d.ts +21 -0
  93. package/types/apps/src/contracts/shared-catalog.d.ts +11 -0
  94. package/types/apps/src/contracts/skills.d.ts +60 -14
  95. package/types/apps/src/contracts/sql.d.ts +63 -0
  96. package/types/apps/src/contracts/ui-auth.d.ts +6 -14
  97. package/types/apps/src/contracts/ui.d.ts +70 -30
  98. package/types/apps/src/contracts/webhooks.d.ts +24 -7
  99. package/types/apps/src/contracts/workflows.d.ts +89 -36
  100. package/types/apps/src/facet.d.ts +4 -5
  101. package/types/apps/src/graphql.d.ts +1 -3
  102. package/types/apps/src/host.d.ts +5 -0
  103. package/types/apps/src/implementation/account-router.d.ts +13 -0
  104. package/types/apps/src/implementation/app.d.ts +44 -16
  105. package/types/apps/src/implementation/authoring.d.ts +25 -5
  106. package/types/apps/src/implementation/browser-scripts.gen.d.ts +6 -0
  107. package/types/apps/src/implementation/cache.d.ts +32 -3
  108. package/types/apps/src/implementation/catalog-cache.d.ts +43 -5
  109. package/types/apps/src/implementation/elicitation.d.ts +18 -15
  110. package/types/apps/src/implementation/events.d.ts +64 -0
  111. package/types/apps/src/implementation/failure-detail.d.ts +48 -0
  112. package/types/apps/src/implementation/graphql-catalog.d.ts +4 -7
  113. package/types/apps/src/implementation/graphql.d.ts +4 -3
  114. package/types/apps/src/implementation/input-problems.d.ts +6 -2
  115. package/types/apps/src/implementation/invocation-timing.d.ts +18 -0
  116. package/types/apps/src/implementation/live.d.ts +2 -2
  117. package/types/apps/src/implementation/mcp-call.d.ts +6 -5
  118. package/types/apps/src/implementation/mcp-catalog.d.ts +7 -8
  119. package/types/apps/src/implementation/mcp-client.d.ts +49 -25
  120. package/types/apps/src/implementation/mcp-tools.d.ts +2 -1
  121. package/types/apps/src/implementation/mcp.d.ts +52 -25
  122. package/types/apps/src/implementation/network.d.ts +16 -0
  123. package/types/apps/src/implementation/openapi-compile.d.ts +30 -8
  124. package/types/apps/src/implementation/openapi-document.d.ts +46 -21
  125. package/types/apps/src/implementation/openapi-names.d.ts +23 -0
  126. package/types/apps/src/implementation/openapi-request.d.ts +10 -3
  127. package/types/apps/src/implementation/openapi-source.d.ts +30 -8
  128. package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
  129. package/types/apps/src/implementation/operations.d.ts +84 -10
  130. package/types/apps/src/implementation/optimistic.d.ts +1 -1
  131. package/types/apps/src/implementation/placement.d.ts +60 -0
  132. package/types/apps/src/implementation/protocol-operations.d.ts +6 -4
  133. package/types/apps/src/implementation/provider-error.d.ts +28 -1
  134. package/types/apps/src/implementation/provider.d.ts +26 -6
  135. package/types/apps/src/implementation/query-commit.d.ts +1 -1
  136. package/types/apps/src/implementation/router-catalog.d.ts +227 -0
  137. package/types/apps/src/implementation/router.d.ts +78 -0
  138. package/types/apps/src/implementation/runtime-yield.d.ts +7 -0
  139. package/types/apps/src/implementation/schedules.d.ts +39 -8
  140. package/types/apps/src/implementation/schema.d.ts +111 -15
  141. package/types/apps/src/implementation/skills.d.ts +18 -24
  142. package/types/apps/src/implementation/sql.d.ts +71 -0
  143. package/types/apps/src/implementation/swagger-client.d.ts +28 -0
  144. package/types/apps/src/implementation/ui-account-notice.d.ts +9 -0
  145. package/types/apps/src/implementation/ui-auth.d.ts +12 -6
  146. package/types/apps/src/implementation/ui-client.d.ts +3 -3
  147. package/types/apps/src/implementation/ui-document.d.ts +5 -0
  148. package/types/apps/src/implementation/ui-errors.d.ts +1 -1
  149. package/types/apps/src/implementation/ui-serving.d.ts +31 -12
  150. package/types/apps/src/implementation/ui-watch.d.ts +1 -1
  151. package/types/apps/src/implementation/upstream-error.d.ts +7 -0
  152. package/types/apps/src/implementation/webhooks.d.ts +15 -6
  153. package/types/apps/src/implementation/workflow-context.d.ts +17 -5
  154. package/types/apps/src/implementation/workflows.d.ts +11 -4
  155. package/types/apps/src/index.d.ts +71 -21
  156. package/types/apps/src/mcp.d.ts +25 -5
  157. package/types/apps/src/openapi.d.ts +11 -6
  158. package/types/apps/src/react.d.ts +1 -1
  159. package/types/apps/src/skills.d.ts +13 -8
  160. package/types/apps/src/ui-auth.d.ts +2 -2
  161. package/types/apps/src/ui-serving.d.ts +1 -1
  162. package/types/telemetry/src/app-records.d.ts +42 -0
  163. package/types/telemetry/src/browser-operations.d.ts +7 -4
  164. package/types/telemetry/src/browser.d.ts +8 -3
  165. package/types/telemetry/src/config.d.ts +2 -2
  166. package/types/telemetry/src/index.d.ts +2 -1
  167. package/types/telemetry/src/layer.d.ts +10 -4
  168. package/types/telemetry/src/measurements.d.ts +1 -1
  169. package/types/telemetry/src/ownership.d.ts +60 -0
  170. package/types/telemetry/src/recorded-failure.d.ts +29 -0
  171. package/types/telemetry/src/relay.d.ts +16 -6
  172. package/types/telemetry/src/span-attributes.d.ts +17 -1
  173. package/types/telemetry/src/transport.d.ts +8 -1
  174. package/types/utils/src/api-error.d.ts +55 -0
  175. package/types/utils/src/connection-failure.d.ts +33 -0
  176. package/types/utils/src/legacy-keys.d.ts +20 -0
  177. package/types/utils/src/recorded-message.d.ts +18 -0
  178. package/types/utils/src/schema-definitions.d.ts +13 -0
  179. package/types/utils/src/user-facing-error.d.ts +83 -0
  180. package/js/chunk-6IIO4NPI.js +0 -29
  181. package/js/chunk-6YBRWRK3.js +0 -160
  182. package/js/chunk-BMOIAIVR.js +0 -138
  183. package/js/chunk-FZJOYIZO.js +0 -19
  184. package/js/chunk-G7IE6BKC.js +0 -224
  185. package/js/chunk-IHQ4ML7K.js +0 -2193
  186. package/js/chunk-KOXMLKTM.js +0 -1288
  187. package/js/chunk-M6ZRRIBI.js +0 -877
  188. package/js/chunk-PLCMJREA.js +0 -590
  189. package/js/chunk-PZ36XMXW.js +0 -93
  190. package/js/chunk-RBAC33PQ.js +0 -267
  191. package/js/chunk-SATWJKN6.js +0 -34
  192. package/js/chunk-SWPD52J7.js +0 -35
  193. package/js/chunk-TE4KO4HI.js +0 -47
  194. package/js/chunk-W7D7WVSY.js +0 -18
  195. package/js/chunk-X7SFGU4Q.js +0 -280
  196. package/js/chunk-ZJWDMTE3.js +0 -63
  197. package/js/mcp/stdio.js +0 -128
  198. package/types/app-data/src/implementation/cursor.d.ts +0 -10
  199. package/types/app-data/src/implementation/index-key.d.ts +0 -7
  200. package/types/app-data/src/implementation/promise.d.ts +0 -68
  201. package/types/app-data/src/implementation/range.d.ts +0 -8
  202. package/types/app-data/src/implementation/schema.d.ts +0 -33
  203. package/types/app-data/src/implementation/sqlite.d.ts +0 -11
  204. package/types/app-data/src/index.d.ts +0 -4
  205. package/types/apps/src/contracts/dynamic-tools.d.ts +0 -13
  206. package/types/apps/src/contracts/storage.d.ts +0 -68
  207. package/types/apps/src/implementation/account-operations.d.ts +0 -151
  208. package/types/apps/src/implementation/dynamic-tools.d.ts +0 -8
  209. package/types/apps/src/implementation/mcp-stdio.d.ts +0 -4
  210. package/types/apps/src/implementation/storage.d.ts +0 -13
  211. package/types/apps/src/mcp-stdio.d.ts +0 -8
@@ -2,6 +2,8 @@
2
2
  import { Schema, type Effect } from "effect";
3
3
  declare const CacheError_base: Schema.Class<CacheError, Schema.TaggedStruct<"CacheError", {
4
4
  readonly reason: Schema.Literals<readonly ["unavailable", "storage", "invalid", "capacity", "timeout"]>;
5
+ /** Which of `cacheLimits` the request exceeded, when one did. */
6
+ readonly limit: Schema.optionalKey<Schema.Literals<readonly ["keyBytes", "entryBytes", "batchBytes", "batchEntries", "totalBytes", "totalEntries"]>>;
5
7
  }>, import("effect/Cause").YieldableError>;
6
8
  /** Expected cache failures never include keys, values or upstream exception text. */
7
9
  export declare class CacheError extends CacheError_base {
@@ -16,7 +18,17 @@ export declare const cacheLimits: {
16
18
  readonly totalEntries: 100000;
17
19
  readonly retentionMs: number;
18
20
  readonly loadTimeoutMs: 90000;
19
- readonly leaseMs: 120000;
21
+ /**
22
+ * A loader's lease lapses this long after its host last renewed it. Hosts renew every
23
+ * `renewMs` while the invocation that claimed it runs, so a stalled or lost holder frees the
24
+ * key well inside an MCP execute budget.
25
+ */
26
+ readonly leaseMs: 15000;
27
+ readonly renewMs: 5000;
28
+ /** The longest a caller waits on another loader before loading for itself without publishing. */
29
+ readonly waitMs: 10000;
30
+ /** Bound for one command to a host store; a lost reply fails instead of holding its caller. */
31
+ readonly commandTimeoutMs: 10000;
20
32
  };
21
33
  /** Stored values carry a version independent of their freshness clock. */
22
34
  export declare const CacheEntry: Schema.Struct<{
@@ -27,10 +39,47 @@ export declare const CacheEntry: Schema.Struct<{
27
39
  }>;
28
40
  /** Decoded cache value envelope. */
29
41
  export type CacheEntry = typeof CacheEntry.Type;
30
- /** Publication requires the lease acquired against the previously observed version. */
42
+ /** The current entry, and a lease when this caller now owns its load. */
43
+ export declare const CacheAcquired: Schema.Struct<{
44
+ readonly entry: Schema.NullOr<Schema.Struct<{
45
+ readonly value: Schema.Codec<Schema.Json, Schema.Json, never, never>;
46
+ readonly version: Schema.String;
47
+ readonly freshUntil: Schema.Finite;
48
+ readonly staleUntil: Schema.Finite;
49
+ }>>;
50
+ readonly lease: Schema.NullOr<Schema.String>;
51
+ /**
52
+ * The entries of the command's `reads`, in order, read in the same transaction as `entry`.
53
+ * Absent when the store did not read them: a store that predates them, or reads past the
54
+ * batch byte bound. The caller then reads them with a separate `read`.
55
+ */
56
+ readonly reads: Schema.optionalKey<Schema.$Array<Schema.NullOr<Schema.Struct<{
57
+ readonly value: Schema.Codec<Schema.Json, Schema.Json, never, never>;
58
+ readonly version: Schema.String;
59
+ readonly freshUntil: Schema.Finite;
60
+ readonly staleUntil: Schema.Finite;
61
+ }>>>>;
62
+ }>;
63
+ /**
64
+ * Publication requires the lease acquired against the previously observed version.
65
+ * `acquire` reads one entry and claims its load in the same transaction, so a cache
66
+ * miss costs one round trip. `read` and `claim` remain for builds retained before it.
67
+ */
31
68
  export declare const CacheCommand: Schema.Union<readonly [Schema.Struct<{
32
69
  readonly operation: Schema.Literal<"read">;
33
70
  readonly keys: Schema.$Array<Schema.String>;
71
+ }>, Schema.Struct<{
72
+ readonly operation: Schema.Literal<"acquire">;
73
+ readonly key: Schema.String;
74
+ /** Claim even a fresh entry, as an explicit refresh does. */
75
+ readonly refresh: Schema.Boolean;
76
+ /** Claim only while the entry still has this version. Absent accepts the current one. */
77
+ readonly version: Schema.optionalKey<Schema.NullOr<Schema.String>>;
78
+ /**
79
+ * Other keys to read in the same transaction, as `read` would, so a caller that needs them
80
+ * beside the entry makes one round trip. Reading them claims and changes nothing.
81
+ */
82
+ readonly reads: Schema.optionalKey<Schema.$Array<Schema.String>>;
34
83
  }>, Schema.Struct<{
35
84
  readonly operation: Schema.Literal<"claim">;
36
85
  readonly key: Schema.String;
@@ -49,6 +98,10 @@ export declare const CacheCommand: Schema.Union<readonly [Schema.Struct<{
49
98
  readonly operation: Schema.Literal<"release">;
50
99
  readonly key: Schema.String;
51
100
  readonly lease: Schema.String;
101
+ }>, Schema.Struct<{
102
+ readonly operation: Schema.Literal<"renew">;
103
+ readonly key: Schema.String;
104
+ readonly lease: Schema.String;
52
105
  }>, Schema.Struct<{
53
106
  readonly operation: Schema.Literal<"write">;
54
107
  readonly entries: Schema.$Array<Schema.Struct<{
@@ -68,6 +121,11 @@ export declare const CacheCommand: Schema.Union<readonly [Schema.Struct<{
68
121
  export type CacheCommand = typeof CacheCommand.Type;
69
122
  /** Replies remain JSON across Worker RPC and are decoded by each caller. */
70
123
  export type CacheTransport = (command: CacheCommand) => Effect.Effect<Schema.Json, CacheError>;
124
+ /**
125
+ * Whether a command replaced or removed retained data: a published refresh, a direct write or an
126
+ * invalidation. Hosts report these so results evaluated from the earlier data are not reused.
127
+ */
128
+ export declare const changesCache: (command: unknown) => boolean;
71
129
  /** Safe protocol envelope used at process boundaries. */
72
130
  export declare const CacheReply: Schema.Union<readonly [Schema.Struct<{
73
131
  readonly ok: Schema.Literal<true>;
@@ -10,10 +10,23 @@ export interface CacheGet<A> {
10
10
  readonly schema: Schema.Decoder<A>;
11
11
  readonly freshFor: Duration.Input;
12
12
  readonly staleFor?: Duration.Input;
13
+ /**
14
+ * What a read does with a value past `freshFor` and within `staleFor`. `serve`, the default,
15
+ * returns it while one background load replaces it. `revalidate` awaits that load first, like a
16
+ * miss; the value stays readable to the load, which can confirm it instead of rebuilding it.
17
+ */
18
+ readonly stale?: "serve" | "revalidate";
13
19
  readonly load: Effect.Effect<A, unknown>;
14
20
  }
15
21
  /** Create a scoped cache client; a background runner must retain all task resources until completion. */
16
- export declare const makeCache: (transport: CacheTransport, background: (task: Effect.Effect<void, unknown>) => Effect.Effect<void>, scope?: Schema.Json) => {
22
+ export declare const makeCache: (host: CacheTransport, background: (task: Effect.Effect<void, unknown>) => Effect.Effect<void>, scope?: Schema.Json,
23
+ /** The caller's own deadline, when the host supplies one. Waiting never runs past it. */
24
+ deadline?: number,
25
+ /**
26
+ * Wraps the time this caller waits on another caller's load of the same entry, polls included,
27
+ * so the host can trace it and count it as waiting rather than as its own work.
28
+ */
29
+ leaseWait?: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>) => {
17
30
  /** Read arbitrary retained JSON entries without initiating a refresh. Missing and null are distinct. */
18
31
  read: (keys: readonly Schema.Json[]) => Effect.Effect<readonly ({
19
32
  readonly value: Schema.Json;
@@ -28,8 +41,85 @@ export declare const makeCache: (transport: CacheTransport, background: (task: E
28
41
  }[], retention: Duration.Input) => Effect.Effect<void, CacheError, never>;
29
42
  /** Revoke retained data and any loader's right to publish its in-flight result. */
30
43
  invalidate: (key: Schema.Json) => Effect.Effect<void, CacheError, never>;
31
- /** Read fresh data, refresh stale data in the background, or wait for the lease owner. */
44
+ /**
45
+ * Read fresh data, refresh stale data in the background (or first, with `stale: "revalidate"`),
46
+ * or wait for the lease owner.
47
+ */
32
48
  get: <A>(options: CacheGet<A>) => Effect.Effect<A, unknown, never>;
49
+ /**
50
+ * `get`, also reading the keys of this scope that `keys` names in the same round trip. `keys`
51
+ * gets the entry's store key, which is unique to this scope and key, so a caller can remember
52
+ * what it read under it. `reads` holds their entries, undecoded and in order, when the value
53
+ * was read from the store; it is undefined when the value was loaded or the store did not read
54
+ * them, and the caller then reads what it still needs.
55
+ */
56
+ getWith: <A>(options: CacheGet<A>, keys: (key: string) => readonly Schema.Json[]) => Effect.Effect<{
57
+ value: A;
58
+ key: string;
59
+ reads: readonly ({
60
+ readonly value: Schema.Json;
61
+ readonly version: string;
62
+ readonly freshUntil: number;
63
+ readonly staleUntil: number;
64
+ } | null)[] | undefined;
65
+ }, unknown, never>;
33
66
  /** Force one awaited refresh without removing the retained value. Concurrent refreshes share a load. */
34
67
  revalidate: <A>(options: CacheGet<A>) => Effect.Effect<A, unknown, never>;
35
68
  };
69
+ /**
70
+ * Host-side lease ownership for one app invocation. Leases the invocation claims are renewed while
71
+ * it runs, so a slow load keeps its key, and released when the host ends the invocation, including
72
+ * interrupted and cancelled ones and loads whose own release never arrived. A holder that stops
73
+ * running, or whose store channel stops answering, loses its lease within `leaseMs`.
74
+ */
75
+ export declare const holdLeases: (transport: CacheTransport) => Effect.Effect<{
76
+ /** Use for every command of the invocation. Each command is bounded by `commandTimeoutMs`. */
77
+ transport: (input: {
78
+ readonly operation: "read";
79
+ readonly keys: readonly string[];
80
+ } | {
81
+ readonly operation: "acquire";
82
+ readonly key: string;
83
+ readonly refresh: boolean;
84
+ readonly version?: string | null;
85
+ readonly reads?: readonly string[];
86
+ } | {
87
+ readonly operation: "claim";
88
+ readonly key: string;
89
+ readonly version: string | null;
90
+ } | {
91
+ readonly operation: "publish";
92
+ readonly key: string;
93
+ readonly lease: string;
94
+ readonly entry: {
95
+ readonly value: Schema.Json;
96
+ readonly version: string;
97
+ readonly freshUntil: number;
98
+ readonly staleUntil: number;
99
+ };
100
+ } | {
101
+ readonly operation: "release";
102
+ readonly key: string;
103
+ readonly lease: string;
104
+ } | {
105
+ readonly operation: "renew";
106
+ readonly key: string;
107
+ readonly lease: string;
108
+ } | {
109
+ readonly operation: "write";
110
+ readonly entries: readonly {
111
+ readonly key: string;
112
+ readonly entry: {
113
+ readonly value: Schema.Json;
114
+ readonly version: string;
115
+ readonly freshUntil: number;
116
+ readonly staleUntil: number;
117
+ };
118
+ }[];
119
+ } | {
120
+ readonly operation: "invalidate";
121
+ readonly key: string;
122
+ }) => Effect.Effect<Schema.Json, CacheError, never>;
123
+ /** Stop renewing and release every lease the invocation still holds. */
124
+ close: Effect.Effect<void, never, never>;
125
+ }, never, never>;
@@ -157,6 +157,33 @@ export declare const DatabaseLimits: Schema.Struct<{
157
157
  export type DatabaseLimits = typeof DatabaseLimits.Type;
158
158
  /** Current per-invocation budgets, shared by every database adapter. */
159
159
  export declare const defaultDatabaseLimits: DatabaseLimits;
160
+ /**
161
+ * The budget a query or mutation exhausted. `pageSize` bounds one take(n) or paginate call;
162
+ * `valueBytes` bounds one stored row; the rest accumulate across the whole invocation.
163
+ */
164
+ export declare const DatabaseLimit: Schema.Literals<readonly ["scanCalls", "directGets", "rowsRead", "rowsReturned", "pageSize", "bytesRead", "writes", "valueBytes"]>;
165
+ export type DatabaseLimit = typeof DatabaseLimit.Type;
166
+ declare const DatabaseLimitExceeded_base: Schema.Class<DatabaseLimitExceeded, Schema.TaggedStruct<"DatabaseLimitExceeded", {
167
+ readonly limit: Schema.Literals<readonly ["scanCalls", "directGets", "rowsRead", "rowsReturned", "pageSize", "bytesRead", "writes", "valueBytes"]>;
168
+ readonly maximum: Schema.Int;
169
+ readonly requested: Schema.Int;
170
+ }>, import("effect/Cause").YieldableError>;
171
+ /** A query or mutation exceeded one of its database budgets. Nothing it wrote is committed. */
172
+ export declare class DatabaseLimitExceeded extends DatabaseLimitExceeded_base {
173
+ get message(): string;
174
+ }
175
+ /** Host-owned row metadata that authored tables cannot declare. */
176
+ export declare const reservedFieldNames: readonly ["id", "createdAt", "updatedAt"];
177
+ declare const DatabaseFieldReserved_base: Schema.Class<DatabaseFieldReserved, Schema.TaggedStruct<"DatabaseFieldReserved", {
178
+ readonly table: Schema.String;
179
+ readonly field: Schema.Literals<readonly ["id", "createdAt", "updatedAt"]>;
180
+ }>, import("effect/Cause").YieldableError>;
181
+ /** A table declared a field the host adds to every row. */
182
+ export declare class DatabaseFieldReserved extends DatabaseFieldReserved_base {
183
+ get message(): string;
184
+ }
185
+ /** Failures a database session reports to authored code and its host. */
186
+ export type DatabaseError = AppDatabaseError | DatabaseLimitExceeded;
160
187
  /** Host resource bounds outside an individual database transaction. Durations are milliseconds. */
161
188
  export declare const DatabaseRuntimeLimits: Schema.Struct<{
162
189
  readonly maxCursorChars: Schema.Int;
@@ -173,21 +200,21 @@ export declare const defaultDatabaseRuntimeLimits: {
173
200
  /** The host binds one database and read/write authority for the entire invocation. */
174
201
  export interface DatabaseSession {
175
202
  /** Host-only idempotency receipt, committed atomically with the mutation and validated result. */
176
- readonly once: <E, R>(key: string, fingerprint: string, work: () => Effect.Effect<Schema.Json, E, R>) => Effect.Effect<Schema.Json, E | AppDatabaseError, R>;
203
+ readonly once: <E, R>(key: string, fingerprint: string, work: () => Effect.Effect<Schema.Json, E, R>) => Effect.Effect<Schema.Json, E | DatabaseError, R>;
177
204
  readonly readTables: ReadonlySet<string>;
178
205
  readonly changedTables: ReadonlySet<string>;
179
- readonly execute: (operation: DatabaseOperation) => Effect.Effect<OperationResult, AppDatabaseError>;
206
+ readonly execute: (operation: DatabaseOperation) => Effect.Effect<OperationResult, DatabaseError>;
180
207
  }
181
208
  /** Native operation scope owns snapshot consistency, write rollback and commit notifications. */
182
209
  export interface AppDatabase {
183
210
  readonly schema: DatabaseSchema;
184
211
  readonly schemaHash: string;
185
- readonly read: <A, E, R>(work: (session: DatabaseSession) => Effect.Effect<A, E, R>) => Effect.Effect<A, E | AppDatabaseError, R>;
186
- readonly mutate: <A, E, R>(work: (session: DatabaseSession) => Effect.Effect<A, E, R>) => Effect.Effect<A, E | AppDatabaseError, R>;
212
+ readonly read: <A, E, R>(work: (session: DatabaseSession) => Effect.Effect<A, E, R>) => Effect.Effect<A, E | DatabaseError, R>;
213
+ readonly mutate: <A, E, R>(work: (session: DatabaseSession) => Effect.Effect<A, E, R>) => Effect.Effect<A, E | DatabaseError, R>;
187
214
  }
188
215
  /** Product-independent app partitions. A host supplies persistent storage; callers never choose filenames. */
189
216
  export interface AppDatabases {
190
- readonly read: <A, E>(app: string, schema: DatabaseSchema, work: (session: DatabaseSession) => Effect.Effect<A, E>) => Effect.Effect<A, E | AppDatabaseError>;
191
- readonly mutate: <A, E>(app: string, schema: DatabaseSchema, work: (session: DatabaseSession) => Effect.Effect<A, E>) => Effect.Effect<A, E | AppDatabaseError>;
217
+ readonly read: <A, E>(app: string, schema: DatabaseSchema, work: (session: DatabaseSession) => Effect.Effect<A, E>) => Effect.Effect<A, E | DatabaseError>;
218
+ readonly mutate: <A, E>(app: string, schema: DatabaseSchema, work: (session: DatabaseSession) => Effect.Effect<A, E>) => Effect.Effect<A, E | DatabaseError>;
192
219
  }
193
220
  export {};
@@ -1,4 +1,6 @@
1
1
  import { Schema } from "effect";
2
+ /** Longest agent guidance an API error's recovery carries. */
3
+ export declare const maxApiErrorInstructionsLength = 4096;
2
4
  /** Bounded recovery a declared API error published for its caller: a short next step and agent guidance. */
3
5
  export declare const ApiErrorRecovery: Schema.Struct<{
4
6
  readonly action: Schema.NonEmptyString;
@@ -6,6 +8,8 @@ export declare const ApiErrorRecovery: Schema.Struct<{
6
8
  }>;
7
9
  /** Recovery copied from an error response body; extra keys are dropped on decode. */
8
10
  export type ApiErrorRecovery = typeof ApiErrorRecovery.Type;
11
+ /** Longest message an API error response carries. */
12
+ export declare const maxApiErrorMessageLength = 4096;
9
13
  /** Bounded public fields from a response matching its declared API error schema. */
10
14
  export declare const ApiErrorResponse: Schema.Struct<{
11
15
  readonly code: Schema.NonEmptyString;
@@ -1,9 +1,7 @@
1
1
  import type { AppSkillSource, SkillFile } from "./skills.js";
2
- import type { DatabaseDefinition } from "./storage.js";
3
2
  /** Native app contracts; factories and handlers compose in the host's Effect runtime. */
4
3
  import { type Effect, Schema } from "effect";
5
4
  import type { OperationSchedule } from "./schedules.js";
6
- import type { AppOperation } from "./operations.js";
7
5
  import type { AccountOf, AuthMethods, ManyAccounts, Provider } from "./provider.js";
8
6
  import type { AppWorkflow, WorkflowReads } from "./workflows.js";
9
7
  import type { Elicit } from "./elicitation.js";
@@ -11,8 +9,8 @@ import type { Elicit } from "./elicitation.js";
11
9
  type Handler<Context> = (context: Context, input: never) => Effect.Effect<unknown, unknown>;
12
10
  /** App capabilities share one account context. Package metadata belongs in package.json. */
13
11
  export interface AppDefinition<Context> {
14
- /** Optional dynamic tools; resolution does not enumerate the catalog. */
15
- readonly dynamicTools?: import("./dynamic-tools.js").DynamicTools;
12
+ /** The app's root router. Its keys form tool paths such as `issues.list`. */
13
+ readonly tools?: import("./router.js").AppRouter | import("./router.js").DynamicRouter;
16
14
  /** Omission reads packaged skills/. An explicit catalog replaces that default, including []. */
17
15
  readonly skills?: readonly AppSkillSource[];
18
16
  /** Optional lazy skills, added to the static catalog. Only skill reads call them. */
@@ -21,10 +19,8 @@ export interface AppDefinition<Context> {
21
19
  readonly schedules?: Readonly<Record<string, Omit<OperationSchedule, "name"> & {
22
20
  readonly tool: string;
23
21
  }>>;
24
- readonly queries?: Readonly<Record<string, AppOperation>>;
25
- readonly mutations?: Readonly<Record<string, AppOperation>>;
26
22
  readonly webhooks?: Readonly<Record<string, {
27
- readonly account: string;
23
+ readonly account: WebhookAccount;
28
24
  readonly config: Schema.Decoder<unknown>;
29
25
  readonly state: Schema.Decoder<unknown>;
30
26
  readonly setup?: import("./webhook-protocol.js").ManualWebhookSetup;
@@ -33,32 +29,82 @@ export interface AppDefinition<Context> {
33
29
  readonly unregister?: Handler<Context>;
34
30
  }>>;
35
31
  }
32
+ /**
33
+ * Whose accounts a requirement or context names. App accounts are linked for everyone by the app's
34
+ * managers and fill the requirement for every caller and for the app's background work; user
35
+ * accounts are the caller's own links. App-scope work, such as an app schedule, has no caller.
36
+ */
37
+ export type AccountScope = "app" | "user";
38
+ /** The requirement a webhook's source account fills, in its scope. */
39
+ export type WebhookAccount = {
40
+ readonly app: string;
41
+ } | {
42
+ readonly user: string;
43
+ };
36
44
  /** Named requirements for one account or a collection from a provider. */
37
45
  export type AccountSlots = Readonly<Record<string, Provider<AuthMethods> | ManyAccounts<AuthMethods>>>;
46
+ /**
47
+ * An app's requirements by scope. A requirement name is unique across both scopes, so a host can
48
+ * name one requirement without its scope.
49
+ */
50
+ export interface ScopedSlots {
51
+ readonly app: AccountSlots;
52
+ readonly user: AccountSlots;
53
+ }
38
54
  type AccountsFor<Slot> = Slot extends ManyAccounts<infer Auth> ? readonly AccountOf<Provider<Auth>>[] : AccountOf<Slot>;
39
- /** Current credentials for one invocation. Never retained in source or build output. */
40
- export interface BoundContext<Slots extends AccountSlots> {
55
+ /** One scope's current accounts, by requirement. */
56
+ export type BoundAccounts<Slots extends AccountSlots> = {
57
+ readonly [Slot in keyof Slots]: AccountsFor<Slots[Slot]>;
58
+ };
59
+ /** Invocation capabilities every context has, whatever its accounts. */
60
+ export interface InvocationServices {
41
61
  /** Explicit app/build-scoped caching. Account-specific loaders opt into forAccount. */
42
62
  readonly cache: import("./cache.js").AppCache;
43
- /** Text files retained in this deployment. Paths are package-relative, never host filesystem paths. */
63
+ /** Text files retained in this version. Paths are package-relative, never host filesystem paths. */
44
64
  readonly files: readonly SkillFile[];
45
65
  /** Read-only run management, bound to this configured app. */
46
66
  readonly workflows: WorkflowReads;
47
67
  /** Ask for user input during this tool call. Unavailable during discovery and after the invocation closes. */
48
68
  readonly elicit: Elicit;
49
- /** Invocation-owned HTTP requests with trace propagation and host cancellation. */
69
+ /**
70
+ * Invocation-owned HTTP requests with trace propagation and host cancellation. It lasts until the
71
+ * invocation and every app cache refresh it started in the background have ended, so a catalog
72
+ * loader given this fetch can refresh after the reply.
73
+ */
50
74
  readonly fetch: (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
51
75
  /** Host cancellation for this invocation. Pass it to fetch and other interruptible APIs. */
52
76
  readonly signal: AbortSignal;
53
- readonly accounts: {
54
- readonly [Slot in keyof Slots]: AccountsFor<Slots[Slot]>;
77
+ }
78
+ /** The app's own accounts, linked for everyone by its managers. Every invocation has them. */
79
+ export interface AppAccountsContext<Slots extends AccountSlots> {
80
+ readonly app: {
81
+ readonly accounts: BoundAccounts<Slots>;
82
+ };
83
+ }
84
+ /** The caller's own linked accounts. App-scope work has no caller, so it has none. */
85
+ export interface UserAccountsContext<Slots extends AccountSlots> {
86
+ readonly user: {
87
+ readonly accounts: BoundAccounts<Slots>;
55
88
  };
56
89
  }
57
- /** The host evaluates this factory fresh with the configured app's selected accounts. */
58
- export interface App<Slots extends AccountSlots, Def extends AppDefinition<never>> {
90
+ /**
91
+ * Current credentials for one invocation. Never retained in source or build output. A context of
92
+ * the `"app"` scope has no `user`: it serves work without a caller, such as an app schedule.
93
+ */
94
+ export type BoundContext<Slots extends ScopedSlots, Scope extends AccountScope = "user"> = InvocationServices & AppAccountsContext<Slots["app"]> & ([Scope] extends ["user"] ? UserAccountsContext<Slots["user"]> : unknown);
95
+ /**
96
+ * What the app factory receives: the app's accounts, and the caller's when the invocation has a
97
+ * caller. App-scope work evaluates the factory without `user`.
98
+ */
99
+ export type EvaluationContext<Slots extends ScopedSlots> = BoundContext<Slots, "app"> & Partial<UserAccountsContext<Slots["user"]>>;
100
+ /** The host evaluates this factory fresh with the invocation's accounts. */
101
+ export interface App<Slots extends ScopedSlots, Def extends AppDefinition<never>> {
59
102
  readonly accounts: Slots;
60
- readonly database?: DatabaseDefinition;
61
- readonly evaluate: (context: BoundContext<Slots>) => Effect.Effect<Def, unknown>;
103
+ /** Declared beside the accounts, so a host lists them without evaluating the app. */
104
+ readonly events?: Readonly<Record<string, import("./events.js").AppEvent>>;
105
+ /** Declared beside the accounts and checked when the module loads. */
106
+ readonly icons?: import("./icons.js").AppIcons;
107
+ readonly evaluate: (context: EvaluationContext<Slots>) => Effect.Effect<Def, unknown>;
62
108
  }
63
109
  declare const NotImplemented_base: Schema.Class<NotImplemented, Schema.TaggedStruct<"NotImplemented", {
64
110
  readonly operation: Schema.String;
@@ -15,6 +15,12 @@ export interface CacheGetOptions<A> {
15
15
  readonly schema: Schema<A, boolean>;
16
16
  readonly freshFor: Duration.Input;
17
17
  readonly staleFor?: Duration.Input;
18
+ /**
19
+ * Past `freshFor`, `serve` (the default) returns the kept value while `load` replaces it in the
20
+ * background. `revalidate` awaits `load` first; the kept value stays readable with `read`, so
21
+ * the loader can confirm it with the source instead of rebuilding it.
22
+ */
23
+ readonly stale?: "serve" | "revalidate";
18
24
  readonly load: (context: CacheLoadContext) => Promise<A>;
19
25
  }
20
26
  /** Cache keys describe every input that affects the value; the host adds app/build isolation. */
@@ -29,11 +35,28 @@ export interface AppCache {
29
35
  readonly value: JsonValue;
30
36
  }[], retention: Duration.Input) => Promise<void>;
31
37
  readonly invalidate: (key: JsonValue) => Promise<void>;
32
- /** Uses the current bound credentials' fingerprint, never just the saved account ID. */
38
+ /**
39
+ * Scope entries to a bound account and its credential generation. Token renewal keeps the
40
+ * entries; reconnecting or replacing the account's credentials starts an empty scope.
41
+ */
33
42
  readonly forAccount: (account: {
34
43
  readonly id: string;
35
44
  }) => AppCache;
36
45
  }
46
+ /**
47
+ * A credential a remote read sends, and the account it belongs to. A public source takes neither.
48
+ * A credential comes only with its account, so the read is cached in that account's scope.
49
+ */
50
+ export type AccountCredential<Credential extends object> = ({
51
+ readonly account?: undefined;
52
+ } & {
53
+ readonly [Field in keyof Credential]?: undefined;
54
+ }) | ({
55
+ /** The selected account, as `ctx.app.accounts.<slot>` or `ctx.user.accounts.<slot>` provides it. */
56
+ readonly account: {
57
+ readonly id: string;
58
+ };
59
+ } & Credential);
37
60
  /** Trusted storage and background ownership; never accepted from request JSON. */
38
61
  export interface HostCache {
39
62
  readonly transport: CacheTransport;
@@ -1,25 +1,68 @@
1
1
  /** Public handler contexts derive capabilities from one shared requirements declaration. */
2
2
  import type { WorkflowControls } from "./workflows.js";
3
- import type { AccountSlots, BoundContext } from "./app.js";
4
- import type { Database, DatabaseDefinition, DatabaseReader, Tables } from "./storage.js";
5
- /** Requirements are pure values; selected accounts and database sessions belong to invocations. */
3
+ import type { AccountScope, AccountSlots, BoundContext } from "./app.js";
4
+ import type { Sql, SqlReader } from "./sql.js";
5
+ import type { AnyEventDeclaration, EventEmitter } from "../implementation/events.js";
6
+ import type { AppIcon } from "./icons.js";
7
+ /**
8
+ * Requirements are pure values; bound accounts and SQL access belong to invocations. `app` names the
9
+ * accounts the app's managers link for every caller and for background work, `user` the accounts
10
+ * each caller links. A requirement name is used once across both.
11
+ */
6
12
  export interface AppRequirements {
7
- readonly accounts: AccountSlots;
8
- readonly database?: DatabaseDefinition;
13
+ readonly app?: {
14
+ readonly accounts: AccountSlots;
15
+ };
16
+ readonly user?: {
17
+ readonly accounts: AccountSlots;
18
+ };
19
+ /** Removed: declare `user: { accounts }` for the caller's accounts or `app: { accounts }`. */
20
+ readonly accounts?: never;
21
+ /** Events this app emits, by name, such as `issue.opened`. */
22
+ readonly events?: Readonly<Record<string, AnyEventDeclaration>>;
23
+ /**
24
+ * Images a dashboard shows for the app, such as its logo in light and dark variants. Each `src`
25
+ * is base64 `data:image/...` or an `https:` URL; at most 8 icons and 32 KiB in total.
26
+ */
27
+ readonly icons?: ReadonlyArray<AppIcon>;
9
28
  }
10
- type StorageContext<Requirements, Writable extends boolean> = Requirements extends {
11
- readonly database: DatabaseDefinition<infer T extends Tables>;
12
- } ? {
13
- readonly db: Writable extends true ? Database<T> : DatabaseReader<T>;
14
- } : {};
15
- /** Context available during dynamic app evaluation; storage opens only for handlers. */
16
- export type AppContext<Requirements extends AppRequirements = AppRequirements> = BoundContext<Requirements["accounts"]>;
29
+ /** One scope's requirements; none when the app declares none in it. */
30
+ type ScopeSlots<Requirements, Scope extends AccountScope> = Scope extends keyof Requirements ? NonNullable<Requirements[Scope]> extends {
31
+ readonly accounts: infer Slots extends AccountSlots;
32
+ } ? Slots : Record<never, never> : Record<never, never>;
33
+ /** An app's requirements by scope, as contexts bind them. */
34
+ export type RequirementSlots<Requirements extends AppRequirements> = {
35
+ readonly app: ScopeSlots<Requirements, "app">;
36
+ readonly user: ScopeSlots<Requirements, "user">;
37
+ };
38
+ /** The emitter for an app's declared events. */
39
+ type EventsContext<Requirements extends AppRequirements> = {
40
+ readonly events: EventEmitter<NonNullable<Requirements["events"]>>;
41
+ };
42
+ /**
43
+ * Every handler has `ctx.sql`. The app's database exists once the build has SQL files in
44
+ * `migrations/`; before that, any statement fails and says so.
45
+ */
46
+ type StorageContext<Writable extends boolean> = {
47
+ readonly sql: Writable extends true ? Sql : SqlReader;
48
+ };
49
+ /**
50
+ * Context available during dynamic app evaluation; storage opens only for handlers. `ctx.app.accounts`
51
+ * holds the app's accounts and `ctx.user.accounts` the caller's. With the `"app"` scope there is no
52
+ * `user`: app schedules and app-account webhooks run without a caller.
53
+ */
54
+ export type AppContext<Requirements extends AppRequirements = AppRequirements, Scope extends AccountScope = "user"> = BoundContext<RequirementSlots<Requirements>, Scope>;
17
55
  /** Interactive query context; declared storage exposes only read methods. */
18
- export type QueryContext<Requirements extends AppRequirements = AppRequirements> = AppContext<Requirements> & StorageContext<Requirements, false>;
19
- /** Interactive mutation context; declared storage belongs to the invocation transaction. */
20
- export type MutationContext<Requirements extends AppRequirements = AppRequirements> = Omit<AppContext<Requirements>, "workflows"> & {
56
+ export type QueryContext<Requirements extends AppRequirements = AppRequirements, Scope extends AccountScope = "user"> = AppContext<Requirements, Scope> & StorageContext<false>;
57
+ /** Interactive mutation context; outside calls happen between SQL transactions, never inside one. */
58
+ export type MutationContext<Requirements extends AppRequirements = AppRequirements, Scope extends AccountScope = "user"> = Omit<AppContext<Requirements, Scope>, "workflows"> & {
21
59
  readonly workflows: WorkflowControls;
22
- } & StorageContext<Requirements, true>;
60
+ } & StorageContext<true> & EventsContext<Requirements>;
61
+ /**
62
+ * The context of a mutation whose handler declares no parameters. It uses no context, so it may run
63
+ * as the app, such as from an app schedule, where `user` is absent.
64
+ */
65
+ export type AnyScopeMutationContext<Requirements extends AppRequirements = AppRequirements> = MutationContext<Requirements, "app"> & Partial<Pick<MutationContext<Requirements>, "user">>;
23
66
  /** Background webhook context has account and storage access without interactive input. */
24
- export type WebhookContext<Requirements extends AppRequirements = AppRequirements> = Omit<MutationContext<Requirements>, "elicit">;
67
+ export type WebhookContext<Requirements extends AppRequirements = AppRequirements, Scope extends AccountScope = "user"> = Omit<MutationContext<Requirements, Scope>, "elicit">;
25
68
  export {};
@@ -1,6 +1,6 @@
1
1
  /** Shared MCP elicitation data. Delivery belongs to the host, independently of its transport. */
2
2
  import { Schema, type Effect } from "effect";
3
- import * as McpSchema from "effect/unstable/ai/McpSchema";
3
+ import * as McpSchema from "effect/ai/McpSchema";
4
4
  import { type JsonValue } from "./schema.js";
5
5
  /** Maximum human-input wait, separate from active provider execution time. */
6
6
  export declare const ElicitationLimits: Schema.Struct<{
@@ -15,10 +15,10 @@ export declare const defaultElicitationLimits: {
15
15
  export declare const FormElicitation: Schema.Struct<{
16
16
  readonly mode: Schema.Literal<"form">;
17
17
  readonly requestedSchema: Schema.toEncoded<Schema.Struct<{
18
- readonly $schema: Schema.decodeTo<Schema.optional<Schema.String>, Schema.optionalKey<Schema.String>, never, never>;
18
+ readonly $schema: Schema.decodeTo<Schema.toType<Schema.optional<Schema.String>>, Schema.optionalKey<Schema.String>, never, never>;
19
19
  readonly type: Schema.tag<"object">;
20
20
  readonly properties: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.Union<readonly [typeof McpSchema.LegacyTitledEnum, Schema.Union<readonly [typeof McpSchema.UntitledSingleSelectEnum, typeof McpSchema.TitledSingleSelectEnum]>, Schema.Union<readonly [typeof McpSchema.UntitledMultiSelectEnum, typeof McpSchema.TitledMultiSelectEnum]>]>, typeof McpSchema.ElicitationString, typeof McpSchema.ElicitationNumber, typeof McpSchema.ElicitationBoolean]>>;
21
- readonly required: Schema.decodeTo<Schema.optional<Schema.$Array<Schema.String>>, Schema.optionalKey<Schema.$Array<Schema.String>>, never, never>;
21
+ readonly required: Schema.decodeTo<Schema.toType<Schema.optional<Schema.$Array<Schema.String>>>, Schema.optionalKey<Schema.$Array<Schema.String>>, never, never>;
22
22
  }>>;
23
23
  readonly _meta: Schema.optional<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
24
24
  readonly message: Schema.String;
@@ -28,7 +28,7 @@ export type FormElicitation = typeof FormElicitation.Type;
28
28
  export declare const ElicitationResponse: Schema.Union<readonly [Schema.Struct<{
29
29
  readonly _meta: Schema.optional<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
30
30
  readonly action: Schema.Literal<"accept">;
31
- readonly content: Schema.decodeTo<Schema.optional<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Finite, Schema.Boolean, Schema.$Array<Schema.String>]>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Finite, Schema.Boolean, Schema.$Array<Schema.String>]>>>, never, never>;
31
+ readonly content: Schema.decodeTo<Schema.toType<Schema.optional<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Finite, Schema.Boolean, Schema.$Array<Schema.String>]>>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Finite, Schema.Boolean, Schema.$Array<Schema.String>]>>>, never, never>;
32
32
  }>, Schema.Struct<{
33
33
  readonly _meta: Schema.optional<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
34
34
  readonly action: Schema.Literals<readonly ["cancel", "decline"]>;
@@ -50,7 +50,7 @@ export declare const ElicitationReply: Schema.Union<readonly [Schema.Struct<{
50
50
  readonly response: Schema.Union<readonly [Schema.Struct<{
51
51
  readonly _meta: Schema.optional<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
52
52
  readonly action: Schema.Literal<"accept">;
53
- readonly content: Schema.decodeTo<Schema.optional<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Finite, Schema.Boolean, Schema.$Array<Schema.String>]>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Finite, Schema.Boolean, Schema.$Array<Schema.String>]>>>, never, never>;
53
+ readonly content: Schema.decodeTo<Schema.toType<Schema.optional<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Finite, Schema.Boolean, Schema.$Array<Schema.String>]>>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Finite, Schema.Boolean, Schema.$Array<Schema.String>]>>>, never, never>;
54
54
  }>, Schema.Struct<{
55
55
  readonly _meta: Schema.optional<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
56
56
  readonly action: Schema.Literals<readonly ["cancel", "decline"]>;
@@ -75,12 +75,28 @@ export type ApprovalElicitation = typeof ApprovalElicitation.Type;
75
75
  export declare const ApprovalResponse: Schema.Union<readonly [Schema.Struct<{
76
76
  readonly _meta: Schema.optional<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
77
77
  readonly action: Schema.Literal<"accept">;
78
- readonly content: Schema.decodeTo<Schema.optional<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Finite, Schema.Boolean, Schema.$Array<Schema.String>]>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Finite, Schema.Boolean, Schema.$Array<Schema.String>]>>>, never, never>;
78
+ readonly content: Schema.decodeTo<Schema.toType<Schema.optional<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Finite, Schema.Boolean, Schema.$Array<Schema.String>]>>>>, Schema.optionalKey<Schema.$Record<Schema.String, Schema.Union<readonly [Schema.String, Schema.Finite, Schema.Boolean, Schema.$Array<Schema.String>]>>>, never, never>;
79
79
  }>, Schema.Struct<{
80
80
  readonly _meta: Schema.optional<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
81
81
  readonly action: Schema.Literals<readonly ["cancel", "decline"]>;
82
82
  }>]>;
83
83
  export type ApprovalResponse = typeof ApprovalResponse.Type;
84
- /** Build the framework's own policy prompt after native input decoding. Includes no account credentials. */
84
+ /**
85
+ * UTF-16 code units of pretty-printed arguments the saved consent prompt shows. Arguments within it
86
+ * are shown exactly; longer ones are shortened, so a pending request holds the arguments once and
87
+ * stays small however large the call. The saved call keeps the exact arguments, and surfaces with
88
+ * room for them show those instead; see `exactApprovalElicitation`.
89
+ */
90
+ export declare const approvalPreviewChars = 4000;
91
+ /**
92
+ * The policy prompt with the exact arguments, or undefined when their pretty-printed JSON is longer
93
+ * than `maxChars` code units. Its work stops at that bound. Includes no account credentials.
94
+ */
95
+ export declare const exactApprovalElicitation: (toolName: string, input: JsonValue, maxChars: number) => ApprovalElicitation | undefined;
96
+ /**
97
+ * The policy prompt saved with a pending call: the exact arguments when they fit
98
+ * `approvalPreviewChars`, otherwise long strings shortened with their length stated. Hosts build it
99
+ * from the call they saved, so it always describes the exact call approval runs.
100
+ */
85
101
  export declare const approvalElicitation: (toolName: string, input: JsonValue) => ApprovalElicitation;
86
102
  export {};