apps 1.0.0-beta.4 → 2.0.0-next.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 (90) hide show
  1. package/README.md +10 -48
  2. package/check-publish.mjs +7 -0
  3. package/package.json +27 -56
  4. package/src/Access.ts +37 -0
  5. package/src/Accounts.ts +468 -0
  6. package/src/App.ts +11 -0
  7. package/src/Ask.ts +156 -0
  8. package/src/Changes.ts +13 -0
  9. package/src/Http.ts +30 -0
  10. package/src/Provider.ts +146 -0
  11. package/src/Session.ts +52 -0
  12. package/src/Settings.ts +164 -0
  13. package/src/contract.ts +852 -0
  14. package/src/css-modules.d.ts +2 -0
  15. package/src/desktop/Desktop.ts +192 -0
  16. package/src/desktop/bridge.ts +62 -0
  17. package/src/desktop/errors.ts +88 -0
  18. package/src/desktop/index.ts +15 -0
  19. package/src/entry.ts +48 -0
  20. package/src/index.ts +16 -4
  21. package/src/internal/defects.ts +62 -0
  22. package/src/internal/files.ts +369 -0
  23. package/src/internal/host.ts +17 -0
  24. package/src/internal/query.ts +114 -0
  25. package/src/internal/records.ts +838 -0
  26. package/src/internal/retention.ts +87 -0
  27. package/src/internal/retries.ts +185 -0
  28. package/src/internal/telemetry.ts +167 -0
  29. package/src/migrations.ts +110 -0
  30. package/src/page/Accounts.ts +27 -0
  31. package/src/page/Changes.ts +126 -0
  32. package/src/page/Session.ts +46 -0
  33. package/src/page/client.ts +107 -0
  34. package/src/page/errors.ts +15 -0
  35. package/src/page/http.ts +21 -0
  36. package/src/page/index.ts +18 -0
  37. package/src/page/paths.ts +22 -0
  38. package/src/providers/anthropic.ts +26 -0
  39. package/src/providers/github.ts +49 -0
  40. package/src/providers/google.ts +67 -0
  41. package/src/providers/openai.ts +62 -0
  42. package/src/providers/slack.ts +81 -0
  43. package/src/runtime.ts +1540 -0
  44. package/src/testing.ts +660 -0
  45. package/src/text-modules.d.ts +5 -0
  46. package/src/theme.css +50 -0
  47. package/dist/authoring/index.d.ts +0 -422
  48. package/dist/authoring/index.js +0 -36
  49. package/dist/chunk-2DVKSPQH.js +0 -312
  50. package/dist/chunk-4OZFMCTT.js +0 -17
  51. package/dist/chunk-535V5K64.js +0 -155
  52. package/dist/chunk-B7NEUIJL.js +0 -14
  53. package/dist/chunk-DP6UJCMX.js +0 -27
  54. package/dist/chunk-QA72XJZU.js +0 -41
  55. package/dist/chunk-S5KFP4JQ.js +0 -20
  56. package/dist/chunk-XYT6GZ7M.js +0 -99
  57. package/dist/http/index.d.ts +0 -9
  58. package/dist/http/index.js +0 -6
  59. package/dist/index.d.ts +0 -4
  60. package/dist/index.js +0 -48
  61. package/dist/manifest/contract.d.ts +0 -63
  62. package/dist/manifest/contract.js +0 -8
  63. package/dist/manifest/index.d.ts +0 -20
  64. package/dist/manifest/index.js +0 -16
  65. package/dist/mcp/client.d.ts +0 -9
  66. package/dist/mcp/index.d.ts +0 -11
  67. package/dist/mcp/index.js +0 -7
  68. package/dist/openapi/index.d.ts +0 -14
  69. package/dist/openapi/index.js +0 -7
  70. package/dist/openapi/mapper.d.ts +0 -7
  71. package/dist/runner/index.d.ts +0 -4
  72. package/dist/runner/index.js +0 -66
  73. package/dist/runner/protocol.d.ts +0 -33
  74. package/dist/runner/protocol.js +0 -8
  75. package/dist/runtime/index.d.ts +0 -83
  76. package/dist/runtime/index.js +0 -12
  77. package/dist/workerd/index.d.ts +0 -7
  78. package/dist/workerd/index.js +0 -10
  79. package/src/authoring/index.ts +0 -686
  80. package/src/http/index.ts +0 -26
  81. package/src/manifest/contract.ts +0 -64
  82. package/src/manifest/index.ts +0 -156
  83. package/src/mcp/client.ts +0 -59
  84. package/src/mcp/index.ts +0 -42
  85. package/src/openapi/index.ts +0 -70
  86. package/src/openapi/mapper.ts +0 -25
  87. package/src/runner/index.ts +0 -80
  88. package/src/runner/protocol.ts +0 -54
  89. package/src/runtime/index.ts +0 -554
  90. package/src/workerd/index.ts +0 -17
package/src/theme.css ADDED
@@ -0,0 +1,50 @@
1
+ /*
2
+ * apps/theme.css: Executor's look, as CSS custom properties, so an app's page
3
+ * sits beside Executor's own pages without effort. Tokens only: no reset, no
4
+ * classes, nothing that depends on a framework. Import it once in the page's
5
+ * entry (`import "apps/theme.css"`) and use the variables, or map them into
6
+ * your framework's theme (Tailwind's `@theme`, for one).
7
+ *
8
+ * The values follow Executor's dashboard (packages/ui globals.css), light and
9
+ * dark from the person's system setting.
10
+ */
11
+ :root {
12
+ color-scheme: light;
13
+ --executor-font-sans: "Geist", ui-sans-serif, system-ui, sans-serif;
14
+ --executor-font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
15
+ --executor-radius-sm: 5px;
16
+ --executor-radius-md: 6px;
17
+ --executor-radius-lg: 8px;
18
+ --executor-background: #fff;
19
+ --executor-foreground: #111;
20
+ --executor-primary: #0a0a0a;
21
+ --executor-primary-foreground: #fff;
22
+ --executor-surface: #fafafa;
23
+ --executor-muted: #666;
24
+ --executor-accent: #0a0a0a;
25
+ --executor-hover: #f5f5f5;
26
+ --executor-destructive: #b4261a;
27
+ --executor-warning: #99651a;
28
+ --executor-border: #eaeaea;
29
+ --executor-input: #d4d4d4;
30
+ --executor-ring: #888;
31
+ }
32
+
33
+ @media (prefers-color-scheme: dark) {
34
+ :root {
35
+ color-scheme: dark;
36
+ --executor-background: #0a0a0a;
37
+ --executor-foreground: #ededed;
38
+ --executor-primary: #fff;
39
+ --executor-primary-foreground: #0a0a0a;
40
+ --executor-surface: #111;
41
+ --executor-muted: #9a9a9a;
42
+ --executor-accent: #fff;
43
+ --executor-hover: #1a1a1a;
44
+ --executor-destructive: #e0726a;
45
+ --executor-warning: #d6aa65;
46
+ --executor-border: #242424;
47
+ --executor-input: #333;
48
+ --executor-ring: #777;
49
+ }
50
+ }
@@ -1,422 +0,0 @@
1
- /**
2
- * Synchronous authoring primitives imported by app.ts and tools/*.ts.
3
- * Authored modules record plain claims without I/O or user context; the
4
- * manifest loader owns execution, validation, and effects.
5
- */
6
- /** A single opaque credential with RFC 6750 bearer semantics. */
7
- export interface BearerMethod {
8
- readonly kind: "bearer";
9
- readonly label: string;
10
- readonly help?: string;
11
- }
12
- /** An RFC 7617 username/password pair. */
13
- export interface BasicMethod {
14
- readonly kind: "basic";
15
- readonly label: string;
16
- readonly help?: string;
17
- }
18
- export interface SecretsMethod<F extends Readonly<Record<string, SecretField>> = Readonly<Record<string, SecretField>>> {
19
- readonly kind: "secrets";
20
- readonly label: string;
21
- /** Markdown shown under this auth method on the connect page, for example:
22
- * "Create a fine-grained token at github.com/settings/tokens." */
23
- readonly help?: string;
24
- readonly fields: F;
25
- }
26
- export interface SecretField {
27
- readonly label: string;
28
- /** Form masking. Stated, never guessed from the field name. */
29
- readonly secret: boolean;
30
- }
31
- /**
32
- * An oauth auth method is a bearer method with acquisition strategies
33
- * layered on: the material contract is always {token, refresh_token?,
34
- * expires_at?}, and the host fills it by the best strategy it can offer
35
- * — authorization-code ceremony, device-code ceremony, or paste. Paste
36
- * is the always-on floor (a pasted token spends identically), so the
37
- * auth method works on any deployment; ceremony is progressive enhancement.
38
- * Handlers cannot tell how material arrived.
39
- */
40
- export interface OAuthMethod {
41
- readonly kind: "oauth";
42
- readonly label: string;
43
- /** Markdown shown under this auth method on the connect page, for example:
44
- * "Create a fine-grained token at github.com/settings/tokens." */
45
- readonly help?: string;
46
- /** Endpoints only when the service publishes no well-knowns —
47
- * discovery (RFC 9728 + AS metadata) outranks these when present.
48
- * Authors state facts about the service, never about the client. */
49
- readonly authorizationEndpoint?: string;
50
- readonly tokenEndpoint?: string;
51
- readonly scopes?: readonly string[];
52
- /** Set false only when a user-pasted token genuinely cannot work
53
- * (audience-bound tokens, DPoP). Stated, never inferred. */
54
- readonly paste?: false;
55
- }
56
- export type AuthMethod = BearerMethod | BasicMethod | SecretsMethod | OAuthMethod;
57
- export declare const bearer: (opts: {
58
- readonly label: string;
59
- readonly help?: string;
60
- }) => BearerMethod;
61
- export declare const basic: (opts: {
62
- readonly label: string;
63
- readonly help?: string;
64
- }) => BasicMethod;
65
- export declare const secrets: <const F extends Readonly<Record<string, SecretField>>>(opts: {
66
- readonly label: string;
67
- /** Markdown shown under this auth method on the connect page, for example:
68
- * "Create a fine-grained token at github.com/settings/tokens." */
69
- readonly help?: string;
70
- readonly fields: F;
71
- }) => SecretsMethod<F>;
72
- export declare const oauth: (opts: {
73
- readonly label: string;
74
- /** Markdown shown under this auth method on the connect page, for example:
75
- * "Create a fine-grained token at github.com/settings/tokens." */
76
- readonly help?: string;
77
- readonly authorizationEndpoint?: string;
78
- readonly tokenEndpoint?: string;
79
- readonly scopes?: readonly string[];
80
- readonly paste?: false;
81
- }) => OAuthMethod;
82
- export interface ServiceDecl {
83
- /** Canonical origin, possibly templated: "https://{region}.posthog.com". */
84
- readonly origin: string;
85
- /** Hosts beyond the origin the credential legitimately travels to. */
86
- readonly reach?: readonly string[];
87
- /** Connection-scoped non-secret connect-form values; keys may fill
88
- * origin templates. */
89
- readonly params?: Readonly<Record<string, ParamSpec>>;
90
- /** Named auth methods. Key = the grant name tools switch on. */
91
- readonly auth?: Readonly<Record<string, AuthMethod>>;
92
- }
93
- export interface ParamSpec {
94
- readonly label: string;
95
- readonly options?: readonly string[];
96
- }
97
- /** What the manifest pipeline reads off a requirement value. */
98
- export interface RequirementSpec {
99
- readonly service: ServiceDecl;
100
- readonly arity: "one" | "optional" | "many";
101
- readonly grant?: string;
102
- readonly description?: string;
103
- }
104
- declare const RequirementKey: unique symbol;
105
- declare const ServiceDeclKey: unique symbol;
106
- declare const RequirementPhantom: unique symbol;
107
- /** Requirement arity, tracked at the type level so handler contexts
108
- * know whether a role arrives as one entry, maybe-one, or a list. */
109
- export type RequirementArity = "one" | "optional" | "many";
110
- /**
111
- * A requirement value in a tool's `requirements` record. A Service IS
112
- * a requirement (bare value = arity "one"); .optional()/.array()
113
- * return terminal Requirements so nonsense chains do not typecheck.
114
- * The phantom property is never assigned — it exists so auth-compose
115
- * callbacks and handler contexts can recover the service's grants, an
116
- * auth-door pin, and the arity at the type level.
117
- */
118
- export interface Requirement<D extends ServiceDecl = ServiceDecl, G extends string | undefined = string | undefined, A extends RequirementArity = RequirementArity> {
119
- readonly [RequirementKey]: RequirementSpec;
120
- readonly [RequirementPhantom]?: {
121
- readonly decl: D;
122
- readonly pinned: G;
123
- readonly arity: A;
124
- };
125
- describe(text: string): Requirement<D, G, A>;
126
- }
127
- /**
128
- * A grant-pinned requirement: what `service.auth.<name>` returns. A
129
- * deliberately narrower type than Service — it can shape arity and
130
- * describe itself, but carries no `auth` (pinning twice is nonsense)
131
- * and no declaration access. Pinning is property access because the
132
- * grants are static facts of the declaration: `github.auth.pat`
133
- * autocompletes and a wrong name fails compilation.
134
- */
135
- export interface PinnedRequirement<D extends ServiceDecl = ServiceDecl, N extends string = string> extends Requirement<D, N, "one"> {
136
- optional(): Requirement<D, N, "optional">;
137
- array(): Requirement<D, N, "many">;
138
- describe(text: string): PinnedRequirement<D, N>;
139
- }
140
- /** The grant-pinned doors of a service, keyed by declared auth method. */
141
- export type ServiceAuth<D extends ServiceDecl> = {
142
- readonly [N in keyof NonNullable<D["auth"]> & string]: PinnedRequirement<D, N>;
143
- };
144
- export interface Service<D extends ServiceDecl = ServiceDecl> extends Requirement<D, undefined, "one"> {
145
- /** Symbol-keyed so author IntelliSense shows only authoring verbs;
146
- * the declaration is plumbing the manifest reads at collection. */
147
- readonly [ServiceDeclKey]: D;
148
- /** Pin one auth method: `github.auth.pat` is this tool supporting
149
- * only that grant. */
150
- readonly auth: ServiceAuth<D>;
151
- optional(): Requirement<D, undefined, "optional">;
152
- array(): Requirement<D, undefined, "many">;
153
- describe(text: string): Service<D>;
154
- }
155
- /** A publish-time authoring problem accumulated without interrupting defines. */
156
- export interface Problem {
157
- readonly message: string;
158
- }
159
- /** One connected role, discriminated by the declared auth method kind. */
160
- export type AuthRoleEntry<D extends ServiceDecl> = {
161
- [N in keyof NonNullable<D["auth"]> & string]: NonNullable<D["auth"]>[N] extends SecretsMethod<infer F> ? {
162
- readonly grant: N;
163
- readonly kind: "secrets";
164
- readonly secrets: {
165
- readonly [K in keyof F & string]: string;
166
- };
167
- } : NonNullable<D["auth"]>[N] extends BasicMethod ? {
168
- readonly grant: N;
169
- readonly kind: "basic";
170
- readonly username: string;
171
- readonly password: string;
172
- } : {
173
- readonly grant: N;
174
- readonly kind: "bearer" | "oauth";
175
- readonly token: string;
176
- };
177
- }[keyof NonNullable<D["auth"]> & string];
178
- /** Kind-discriminated credential material accepted by surface helpers. */
179
- export type RoleMaterial = {
180
- readonly kind: "bearer" | "oauth";
181
- readonly token: string;
182
- } | {
183
- readonly kind: "basic";
184
- readonly username: string;
185
- readonly password: string;
186
- } | {
187
- readonly kind: "secrets";
188
- readonly secrets: Readonly<Record<string, string>>;
189
- };
190
- /** Recover the connected role type produced by a service requirement. */
191
- export type RoleOf<S, G extends string | undefined = undefined> = S extends Requirement<infer D, infer Pin> ? [G] extends [string] ? Extract<AuthRoleEntry<D>, {
192
- grant: G;
193
- }> : Pin extends string ? Extract<AuthRoleEntry<D>, {
194
- grant: Pin;
195
- }> : AuthRoleEntry<D> : never;
196
- /** Role record received by an authored authentication placement callback. */
197
- export type AuthRoles<Reqs extends Readonly<Record<string, Requirement>>> = {
198
- readonly [K in keyof Reqs]: NonNullable<Reqs[K][typeof RequirementPhantom]> extends {
199
- readonly decl: infer D extends ServiceDecl;
200
- readonly pinned: infer G;
201
- } ? G extends string ? Extract<AuthRoleEntry<D>, {
202
- grant: G;
203
- }> : AuthRoleEntry<D> : never;
204
- };
205
- /** Request placement returned by an authored dynamic auth callback. */
206
- export interface AuthPlacement {
207
- readonly headers?: HeadersInit;
208
- readonly searchParams?: URLSearchParams | Readonly<Record<string, string>>;
209
- }
210
- export type AuthComposeFn<Reqs extends Readonly<Record<string, Requirement>> = never> = (roles: AuthRoles<Reqs>) => AuthPlacement | undefined | void;
211
- export type HasSecretsGrant<D extends ServiceDecl> = true extends (NonNullable<D["auth"]>[keyof NonNullable<D["auth"]>] extends infer M ? M extends SecretsMethod ? true : false : never) ? true : false;
212
- /** Whether an OpenAPI wrapper must state credential placement explicitly. */
213
- export type RequiresAuthCompose<Reqs extends Readonly<Record<string, Requirement>>> = true extends {
214
- [K in keyof Reqs]: NonNullable<Reqs[K][typeof RequirementPhantom]> extends {
215
- readonly decl: infer D extends ServiceDecl;
216
- readonly pinned: infer G;
217
- } ? G extends keyof NonNullable<D["auth"]> & string ? NonNullable<D["auth"]>[G] extends SecretsMethod ? true : false : HasSecretsGrant<D> : never;
218
- }[keyof Reqs] ? true : false;
219
- /** Record a wrapper-specific publish problem on the active authored file. @internal */
220
- export declare const recordAuthoringProblem: (message: string) => void;
221
- /** Operation curation for a dynamic tool set. Exactly one of allow/block. */
222
- export type OperationSelection = {
223
- readonly allow: readonly string[];
224
- readonly block?: undefined;
225
- } | {
226
- readonly block: readonly string[];
227
- readonly allow?: undefined;
228
- };
229
- /** One tool emitted by a dynamic discovery pass. */
230
- export interface DiscoveredToolSpec {
231
- readonly name: string;
232
- readonly description: string;
233
- readonly input: SchemaLike;
234
- readonly annotations?: ToolAnnotations;
235
- readonly detail?: unknown;
236
- }
237
- /**
238
- * The generic authored shape of a dynamic pair: ctx is inferred from
239
- * the requirements record exactly as for static tools. Discovered
240
- * inputs are runtime data (the schema arrives from the upstream at
241
- * discover time), so `call`'s input is honestly `unknown` — the
242
- * runtime validates against the discovered descriptor before calling.
243
- */
244
- export interface DynamicToolsDecl<Reqs extends Readonly<Record<string, Requirement>> | undefined = Readonly<Record<string, Requirement>> | undefined> {
245
- readonly description: string;
246
- readonly requirements?: Reqs;
247
- discover(args: {
248
- readonly ctx: HandlerCtx<Reqs>;
249
- }): Promise<readonly DiscoveredToolSpec[]>;
250
- call(args: {
251
- readonly tool: {
252
- readonly name: string;
253
- readonly detail: unknown;
254
- };
255
- readonly input: unknown;
256
- readonly ctx: HandlerCtx<Reqs>;
257
- }): Promise<unknown>;
258
- }
259
- /**
260
- * The erased registry row of a dynamic pair — same storage boundary
261
- * as ToolSpec. App code: runs where handlers run (in-process locally,
262
- * inside the isolate on workerd) and places credentials itself from
263
- * ctx, like any handler. `discover` interrogates the tool source;
264
- * `call` executes one discovered tool from the identity and detail
265
- * discover emitted.
266
- */
267
- export interface DynamicToolsSpec {
268
- readonly description: string;
269
- readonly requirements?: Readonly<Record<string, Requirement>>;
270
- discover(args: never): Promise<readonly DiscoveredToolSpec[]>;
271
- call(args: never): Promise<unknown>;
272
- }
273
- declare const DynamicKey: unique symbol;
274
- /** The value defineDynamicTools returns: an opaque handle a tool file
275
- * default-exports. The spec is undefined when the definition was
276
- * invalid (a problem was recorded instead). */
277
- export interface DynamicToolSet {
278
- readonly [DynamicKey]: DynamicToolsSpec | undefined;
279
- }
280
- /** Reads a dynamic spec from a tool file's default export. @internal */
281
- export declare const dynamicSpecOf: (value: unknown) => DynamicToolsSpec | undefined;
282
- /**
283
- * The dynamic-tools primitive: an author-written discover/call pair
284
- * whose tool list is interrogated at runtime, per connection, instead
285
- * of authored one file at a time. The file's name becomes the address
286
- * segment (appKey/<stem>/<toolName>); tools land in the catalog after
287
- * discovery and never block a save. fromMCP/fromOpenAPI are shipped
288
- * pairs over this same primitive.
289
- */
290
- export declare const defineDynamicTools: <const Reqs extends Readonly<Record<string, Requirement>> | undefined = undefined>(decl: DynamicToolsDecl<Reqs>) => DynamicToolSet;
291
- /** A registered dynamic tool set and its source attribution. @internal */
292
- export interface DynamicRegistration {
293
- readonly spec: DynamicToolsSpec;
294
- readonly file: string;
295
- }
296
- /** A registered service declaration and its source attribution. @internal */
297
- export interface RegisteredService {
298
- readonly decl: ServiceDecl;
299
- readonly file: string;
300
- }
301
- /** A registered tool declaration and its source attribution. @internal */
302
- export interface RegisteredTool {
303
- readonly spec: ToolSpec;
304
- readonly file: string;
305
- }
306
- /** Mutable claim registry populated while authored modules execute. @internal */
307
- export interface Registry {
308
- app: AppManifest | undefined;
309
- readonly services: Map<string, RegisteredService>;
310
- readonly tools: Map<string, RegisteredTool>;
311
- readonly dynamic: Map<string, DynamicRegistration>;
312
- readonly problems: Problem[];
313
- readonly toolFiles: Map<string, {
314
- definitions: number;
315
- hasUnnamedTool: boolean;
316
- }>;
317
- }
318
- /** Creates an isolated empty authoring registry. @internal */
319
- export declare const newRegistry: () => Registry;
320
- /** Swaps the registry receiving subsequent authoring claims. @internal */
321
- export declare const setActiveRegistry: (registry: Registry) => Registry;
322
- /** Sets source-file attribution for subsequent authoring claims. @internal */
323
- export declare const __enterFile: (path: string) => void;
324
- /** Clears source-file attribution after an authored module import. @internal */
325
- export declare const __leaveFile: () => void;
326
- export declare const service: <const D extends ServiceDecl>(decl: D) => Service<D>;
327
- export declare const requirementSpecOf: (value: unknown) => RequirementSpec | undefined;
328
- export interface AppManifest {
329
- readonly kind: "executor-app";
330
- readonly key: string;
331
- readonly label: string;
332
- readonly description: string;
333
- }
334
- export declare const defineApp: (manifest: {
335
- readonly key: string;
336
- readonly label: string;
337
- readonly description: string;
338
- }) => AppManifest;
339
- /** Any Standard Schema (zod preferred) or a raw JSON-schema object. */
340
- export type SchemaLike = object;
341
- /**
342
- * The validated value a Standard Schema produces, recovered from its
343
- * phantom types (zod 4 and effect Schema both publish them). A raw
344
- * JSON-schema object carries no phantom, so its input is `unknown` —
345
- * stated weakness, not silent weakness.
346
- */
347
- export type InferSchema<S> = S extends {
348
- readonly "~standard": {
349
- readonly types?: infer T;
350
- };
351
- } ? NonNullable<T> extends {
352
- readonly output: infer O;
353
- } ? O : unknown : unknown;
354
- /**
355
- * The capability a handler receives for one connected requirement
356
- * role: the grant's kind-discriminated material (narrowed by any
357
- * auth-door pin) plus the spending fetch. Arity shapes the value —
358
- * `.optional()` may be absent, `.array()` is every connected account.
359
- */
360
- export type HandlerRole<R> = R extends Requirement<infer D, infer G, infer A> ? [A] extends ["many"] ? ReadonlyArray<HandlerRoleEntry<D, G>> : [A] extends ["optional"] ? HandlerRoleEntry<D, G> | undefined : HandlerRoleEntry<D, G> : never;
361
- /** One connected role entry: declared-auth material + capability fetch. */
362
- export type HandlerRoleEntry<D extends ServiceDecl, G extends string | undefined> = ([G] extends [string] ? Extract<AuthRoleEntry<D>, {
363
- grant: G;
364
- }> : AuthRoleEntry<D>) & {
365
- fetch(path: string, init?: RequestInit): Promise<Response>;
366
- };
367
- /** The ctx record a handler receives, keyed by requirement role. */
368
- export type HandlerCtx<Reqs> = [Reqs] extends [Readonly<Record<string, Requirement>>] ? {
369
- readonly [K in keyof Reqs]: HandlerRole<Reqs[K]>;
370
- } : Readonly<Record<never, never>>;
371
- export interface ToolAnnotations {
372
- readonly readOnly?: boolean;
373
- readonly destructive?: boolean;
374
- /** Facts, not flow: shortfall surfaces as the scope challenge. */
375
- readonly scopes?: readonly string[];
376
- }
377
- /**
378
- * The generic authored shape: input/ctx/output are all inferred — the
379
- * handler's input from the Standard Schema, ctx from the requirements
380
- * record (grants, pins, arity), and the return type checked against
381
- * the output schema when one is stated. The handler takes ONE
382
- * destructurable argument so unused halves never demand an underscore:
383
- * `handler: async ({ input }) => ...` / `async ({ ctx }) => ...`.
384
- */
385
- export interface ToolDecl<Input extends SchemaLike = SchemaLike, Reqs extends Readonly<Record<string, Requirement>> | undefined = Readonly<Record<string, Requirement>> | undefined, Output extends SchemaLike | undefined = SchemaLike | undefined> {
386
- /** Address segment. Single-tool files may omit it (filename). */
387
- readonly name?: string;
388
- readonly description: string;
389
- readonly requirements?: Reqs;
390
- readonly input: Input;
391
- readonly output?: Output;
392
- readonly annotations?: ToolAnnotations;
393
- handler(args: {
394
- readonly input: InferSchema<Input>;
395
- readonly ctx: HandlerCtx<Reqs>;
396
- }): Promise<Output extends SchemaLike ? InferSchema<Output> : unknown>;
397
- }
398
- /**
399
- * The erased registry row. Registration drops the generics — storage
400
- * is untyped by design, the same boundary every schema library draws
401
- * between its typed builders and its runtime representation. The
402
- * runtime re-establishes safety by validating input before the
403
- * handler runs and shaping ctx from resolved connections.
404
- */
405
- export interface ToolSpec {
406
- readonly name?: string;
407
- readonly description: string;
408
- readonly requirements?: Readonly<Record<string, Requirement>>;
409
- readonly input: SchemaLike;
410
- readonly output?: SchemaLike;
411
- readonly annotations?: ToolAnnotations;
412
- handler(args: never): Promise<unknown>;
413
- }
414
- declare const ToolKey: unique symbol;
415
- export interface Tool {
416
- readonly [ToolKey]: ToolSpec;
417
- }
418
- export declare const defineTool: <const Input extends SchemaLike, const Reqs extends Readonly<Record<string, Requirement>> | undefined = undefined, const Output extends SchemaLike | undefined = undefined>(decl: ToolDecl<Input, Reqs, Output>) => Tool;
419
- export declare const toolSpecOf: (value: unknown) => ToolSpec | undefined;
420
- /** A tool file's default export. */
421
- export type ToolExport = Tool | ReadonlyArray<Tool>;
422
- export {};
@@ -1,36 +0,0 @@
1
- import {
2
- __enterFile,
3
- __leaveFile,
4
- basic,
5
- bearer,
6
- defineApp,
7
- defineDynamicTools,
8
- defineTool,
9
- dynamicSpecOf,
10
- newRegistry,
11
- oauth,
12
- recordAuthoringProblem,
13
- requirementSpecOf,
14
- secrets,
15
- service,
16
- setActiveRegistry,
17
- toolSpecOf
18
- } from "../chunk-535V5K64.js";
19
- export {
20
- __enterFile,
21
- __leaveFile,
22
- basic,
23
- bearer,
24
- defineApp,
25
- defineDynamicTools,
26
- defineTool,
27
- dynamicSpecOf,
28
- newRegistry,
29
- oauth,
30
- recordAuthoringProblem,
31
- requirementSpecOf,
32
- secrets,
33
- service,
34
- setActiveRegistry,
35
- toolSpecOf
36
- };