apps 0.0.1-beta.46 → 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.
- package/framework-reference.json +1 -1
- package/js/{chunk-XK5I2XOI.js → chunk-D45JTD6N.js} +2 -2
- package/js/{chunk-3B2JAOSE.js → chunk-GDYPM7RS.js} +102 -3
- package/js/{chunk-CVAJ4F6O.js → chunk-JY56GVSV.js} +81 -3
- package/js/{chunk-OJ47HQVJ.js → chunk-PO5NPRFT.js} +67 -14
- package/js/{chunk-7LGRK7TP.js → chunk-QKHTRD6G.js} +2 -2
- package/js/{chunk-3UGDI2UI.js → chunk-SVHI6AKV.js} +2 -2
- package/js/{chunk-LHCGND3R.js → chunk-X5U5KIWQ.js} +1 -1
- package/js/{chunk-6QXPBJ5T.js → chunk-YQD2MLFY.js} +2 -2
- package/js/contracts.js +19 -1
- package/js/effect.js +5 -5
- package/js/graphql.js +6 -6
- package/js/host.js +5 -5
- package/js/index.js +6 -4
- package/js/mcp/effect.js +7 -7
- package/js/mcp/stdio.js +7 -7
- package/js/mcp.js +8 -8
- package/js/openapi.js +4 -4
- package/package.json +1 -1
- package/runtime.json +1 -1
- package/types/apps/src/contracts/app.d.ts +2 -0
- package/types/apps/src/contracts/context.d.ts +8 -1
- package/types/apps/src/contracts/events.d.ts +93 -0
- package/types/apps/src/contracts/host.d.ts +6 -4
- package/types/apps/src/contracts/protocol-version.d.ts +2 -2
- package/types/apps/src/contracts/protocols/11.d.ts +1098 -0
- package/types/apps/src/implementation/account-router.d.ts +4 -3
- package/types/apps/src/implementation/events.d.ts +59 -0
- package/types/apps/src/implementation/operations.d.ts +5 -0
- package/types/apps/src/implementation/router.d.ts +7 -5
- package/types/apps/src/implementation/sql.d.ts +5 -0
- package/types/apps/src/index.d.ts +3 -1
|
@@ -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
|
|
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>>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/** Event declarations and the per-invocation emitter. Emitted events leave in the reply. */
|
|
2
|
+
import { Effect, Schema as EffectSchema } from "effect";
|
|
3
|
+
import { EmittedEvent, type AppEvent, type EmitOptions } from "../contracts/events.js";
|
|
4
|
+
import { type Fields, type Infer, type ObjectValue, type Schema } from "./schema.js";
|
|
5
|
+
declare const Native: unique symbol;
|
|
6
|
+
/** An event an app emits. Declare it in `defineApp`'s requirements under `events`. */
|
|
7
|
+
export interface EventDeclaration<F extends Fields, P extends Schema<unknown, boolean>> {
|
|
8
|
+
readonly [Native]: AppEvent;
|
|
9
|
+
readonly description: string;
|
|
10
|
+
readonly filters: F;
|
|
11
|
+
readonly payload: P;
|
|
12
|
+
}
|
|
13
|
+
/** Any declared event, for requirement constraints. */
|
|
14
|
+
export type AnyEventDeclaration = EventDeclaration<Fields, Schema<unknown, boolean>>;
|
|
15
|
+
/**
|
|
16
|
+
* Declare an event. `filters` are scalar fields subscribers can narrow on, such as a repository;
|
|
17
|
+
* every emitted occurrence supplies their values. `payload` describes each occurrence's data.
|
|
18
|
+
*/
|
|
19
|
+
export declare const event: <const F extends Fields = {}, P extends Schema<unknown, boolean> = Schema<unknown>>(options: {
|
|
20
|
+
readonly description: string;
|
|
21
|
+
readonly filters?: F;
|
|
22
|
+
readonly payload: P;
|
|
23
|
+
}) => EventDeclaration<F, P>;
|
|
24
|
+
/** The native declaration retained by an author event. */
|
|
25
|
+
export declare const nativeEvent: (declaration: unknown) => AppEvent | undefined;
|
|
26
|
+
/** JSON Schema for each declared event, as the host reads it from requirements. */
|
|
27
|
+
export declare const declaredEvents: (events: Readonly<Record<string, AppEvent>>) => Effect.Effect<{
|
|
28
|
+
readonly [x: string]: {
|
|
29
|
+
readonly description: string;
|
|
30
|
+
readonly filters: {
|
|
31
|
+
readonly [x: string]: EffectSchema.Json;
|
|
32
|
+
};
|
|
33
|
+
readonly payload: {
|
|
34
|
+
readonly [x: string]: EffectSchema.Json;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
}, EffectSchema.SchemaError, never>;
|
|
38
|
+
/** Emit options typed by the event's filters: required exactly when it declares some. */
|
|
39
|
+
type OptionsFor<F extends Fields> = keyof F extends never ? [options?: Omit<EmitOptions<never>, "filters">] : [options: EmitOptions<ObjectValue<F>> & {
|
|
40
|
+
readonly filters: ObjectValue<F>;
|
|
41
|
+
}];
|
|
42
|
+
/** `ctx.events` in mutations and webhook handlers. */
|
|
43
|
+
export interface EventEmitter<Events extends Readonly<Record<string, AnyEventDeclaration>>> {
|
|
44
|
+
/**
|
|
45
|
+
* Record an occurrence. It is delivered only if this invocation succeeds. Invalid data, filters
|
|
46
|
+
* or options throw here, before anything is recorded.
|
|
47
|
+
*/
|
|
48
|
+
readonly emit: <Name extends keyof Events & string>(name: Name, data: Infer<Events[Name]["payload"]>, ...options: OptionsFor<Events[Name]["filters"]>) => void;
|
|
49
|
+
}
|
|
50
|
+
/** One invocation's buffer. The handler reads `emitted` only after the invocation succeeds. */
|
|
51
|
+
export declare const makeEmitter: (input: {
|
|
52
|
+
readonly events: Readonly<Record<string, AppEvent>>;
|
|
53
|
+
/** Every account ID bound to this invocation. */
|
|
54
|
+
readonly accounts: readonly string[];
|
|
55
|
+
/** The webhook's source account, which an emit names by default. */
|
|
56
|
+
readonly sourceAccount?: string;
|
|
57
|
+
readonly emitted: EmittedEvent[];
|
|
58
|
+
}) => EventEmitter<Readonly<Record<string, AnyEventDeclaration>>>;
|
|
59
|
+
export {};
|
|
@@ -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) =>
|
|
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. */
|
|
@@ -22,6 +22,11 @@ export interface StepReplay {
|
|
|
22
22
|
export declare const authorSql: (storage: AppSqlStorage, options: {
|
|
23
23
|
readonly signal: AbortSignal;
|
|
24
24
|
readonly step?: StepReplay;
|
|
25
|
+
/**
|
|
26
|
+
* The invocation's emitted events. A transaction that rolls back also discards the events its
|
|
27
|
+
* callback emitted, so subscribers never hear of writes that did not commit.
|
|
28
|
+
*/
|
|
29
|
+
readonly emitted?: unknown[];
|
|
25
30
|
}) => {
|
|
26
31
|
reader: SqlReader;
|
|
27
32
|
writer: Sql;
|
|
@@ -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";
|
|
@@ -59,6 +59,8 @@ export declare function oauth2<Response extends Schema<unknown, boolean>>(option
|
|
|
59
59
|
export type { AccountSlots } from "./contracts/app.js";
|
|
60
60
|
export type { AppRequirements, AppContext, QueryContext, MutationContext, WebhookContext, } from "./contracts/context.js";
|
|
61
61
|
export { type App, type AppDefinition, defineApp } from "./implementation/app.js";
|
|
62
|
+
export { event, type EventDeclaration, type EventEmitter } from "./implementation/events.js";
|
|
63
|
+
export type { EmitOptions } from "./contracts/events.js";
|
|
62
64
|
export type { Approval, ApprovalContext, ApprovalDecision } from "./approval.js";
|
|
63
65
|
type AuthorWebhook<Member, Config, State> = Member extends object ? Omit<PromiseMethods<Member>, "config" | "state"> & {
|
|
64
66
|
readonly config: Config;
|