apps 0.0.1-beta.47 → 0.0.1-beta.48

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.
@@ -3,10 +3,11 @@ import { type RouterDeclaration } from "./router.js";
3
3
  * Discover each selected account's router and combine matching names.
4
4
  * Calls take { accountId, input }; each branch retains its account's input schema,
5
5
  * credentials, approval and output validation. Empty selections expose no operations.
6
- * Discovery is sequential and cancellation follows the caller's signal.
6
+ * Discovery is sequential and cancellation follows the caller's signal. `discover` may return the
7
+ * router or a Promise of it, and the combined router keeps its operations' handler contexts.
7
8
  */
8
9
  export declare const accountRouter: <Account extends {
9
10
  readonly id: string;
10
- }>(accounts: readonly Account[], discover: (account: Account) => Promise<RouterDeclaration>, options: {
11
+ }, Query = unknown, Mutation = unknown>(accounts: readonly Account[], discover: (account: Account) => RouterDeclaration<Query, Mutation> | Promise<RouterDeclaration<Query, Mutation>>, options: {
11
12
  readonly signal: AbortSignal;
12
- }) => Promise<RouterDeclaration>;
13
+ }) => Promise<RouterDeclaration<Query, Mutation>>;
@@ -38,6 +38,11 @@ export interface RouterChild<Query, Mutation> {
38
38
  readonly [QueryHandlerContext]?: (context: Query) => void;
39
39
  readonly [MutationHandlerContext]?: (context: Mutation) => void;
40
40
  }
41
+ /**
42
+ * A query or mutation whose handler context is checked by its kind, as a dynamic router resolves
43
+ * one. `query()` and `mutation()` results fit with their inferred contexts.
44
+ */
45
+ export type OperationChild<Query, Mutation> = RouterChild<Query, Mutation> & Pick<OperationDeclaration<"query" | "mutation">, "kind" | typeof NativeOperation>;
41
46
  /** Private key for a router's native definition. */
42
47
  export declare const NativeRouterKey: unique symbol;
43
48
  /** Typed operation handles drive browser reference inference without bundling handlers. */
@@ -2,8 +2,8 @@ import { HostedTool } from "../contracts/host.js";
2
2
  import type { AppOperation } from "../contracts/operations.js";
3
3
  import { RouterMeta, type AppRouter, type DynamicRouter, type RouterIcon } from "../contracts/router.js";
4
4
  import type { Approval } from "../approval.js";
5
- import { type OperationDeclaration, type RouterChild, type RouterDeclaration } from "./operations.js";
6
- export type { RouterChild, RouterDeclaration } from "./operations.js";
5
+ import { type OperationChild, type OperationDeclaration, type RouterChild, type RouterDeclaration } from "./operations.js";
6
+ export type { OperationChild, OperationDeclaration, RouterChild, RouterDeclaration, } from "./operations.js";
7
7
  /** Author metadata for a router. Instructions become a skill named after the router's path. */
8
8
  export interface RouterOptions {
9
9
  readonly title?: string;
@@ -28,12 +28,14 @@ export declare function router<Query, Mutation>(source: RouterDeclaration<Query,
28
28
  /**
29
29
  * Declare a router whose tools are discovered when read. `list` returns tools with names relative
30
30
  * to this router; mark queries with `readOnly: true`. `resolve` receives one of those names.
31
+ * The router carries the handler contexts of the operations `resolve` returns, so `defineApp`
32
+ * checks them like a static router's.
31
33
  */
32
- export declare const dynamicRouter: (source: {
34
+ export declare const dynamicRouter: <Query = unknown, Mutation = unknown>(source: {
33
35
  readonly meta?: () => RouterOptions | Promise<RouterOptions>;
34
36
  readonly list: () => readonly HostedTool[] | Promise<readonly HostedTool[]>;
35
- readonly resolve: (name: string) => OperationDeclaration<"query" | "mutation", unknown> | undefined | Promise<OperationDeclaration<"query" | "mutation", unknown> | undefined>;
36
- }) => RouterDeclaration;
37
+ readonly resolve: (name: string) => OperationChild<Query, Mutation> | undefined | Promise<OperationChild<Query, Mutation> | undefined>;
38
+ }) => RouterDeclaration<Query, Mutation>;
37
39
  /** Join a router path and a relative name. The root router's path is "". */
38
40
  export declare const joinPath: (path: string, name: string) => string;
39
41
  /** Where a full tool name points: a declared operation, or a name inside a dynamic router. */
@@ -18,7 +18,7 @@ export { type Fields, type Infer, type ObjectSchema, type ObjectValue, type Sche
18
18
  export { type AccountCheckContext, type AccountCheckResult, type AccountInfo, type AccountOf, type AuthMethod, type AuthMethodData, type AuthMethods, type ManyAccounts, type Provider, type ReservedAuthorizationParam, } from "./contracts/provider.js";
19
19
  export { defineProvider, type ProviderOptions } from "./implementation/provider.js";
20
20
  export { accountRouter } from "./implementation/account-router.js";
21
- export { router, dynamicRouter, withApprovals, type RouterDeclaration, type RouterChild, type RouterOptions, } from "./implementation/router.js";
21
+ export { router, dynamicRouter, withApprovals, type OperationChild, type OperationDeclaration, type RouterDeclaration, type RouterChild, type RouterOptions, } from "./implementation/router.js";
22
22
  export type { RouterIcon } from "./contracts/router.js";
23
23
  export { dynamicSkills } from "./implementation/dynamic-skills.js";
24
24
  export type { HostedTool as OperationDescription } from "./contracts/host.js";