apps 0.0.1-beta.9 → 0.0.1-beta.91
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/README.md +56 -38
- package/framework-reference.json +1 -1
- package/js/chunk-3LEVTFD4.js +712 -0
- package/js/chunk-5FHWNLCI.js +88 -0
- package/js/{chunk-FL2QR3XW.js → chunk-5MDA7MKL.js} +338 -73
- package/js/chunk-6XQLA5NC.js +5047 -0
- package/js/{chunk-M3B3DE4K.js → chunk-74YVXBKY.js} +463 -218
- package/js/chunk-7PHHWYV4.js +335 -0
- package/js/chunk-DADXWWRZ.js +449 -0
- package/js/{chunk-27F7W2LG.js → chunk-DDHBUKXX.js} +18 -2
- package/js/{chunk-UK573G7W.js → chunk-EOPQ727L.js} +87 -51
- package/js/{chunk-5T57N25Q.js → chunk-GQ33QSNB.js} +583 -69
- package/js/{chunk-JU7VHODU.js → chunk-H72MEDMN.js} +65 -10
- package/js/chunk-I5C7FD5Z.js +171 -0
- package/js/{chunk-CDL5PM2Q.js → chunk-IFJU5SYQ.js} +19082 -18402
- package/js/{chunk-VFZKSM3T.js → chunk-JPEUKEV4.js} +3 -3
- package/js/{chunk-KUMBKVJD.js → chunk-KLYSEHUD.js} +2 -2
- package/js/{chunk-RFVIONFX.js → chunk-KUCCHNVY.js} +123 -44
- package/js/chunk-OD3KFKZD.js +1617 -0
- package/js/{chunk-57RKNWL2.js → chunk-PD6I2SDG.js} +4 -4
- package/js/{chunk-72JNVHPK.js → chunk-PYQLOLOC.js} +4 -3
- package/js/{chunk-ODEIDRGW.js → chunk-QWQM3CLH.js} +795 -176
- package/js/{chunk-IJX4CYZO.js → chunk-TUMGL2OC.js} +228 -264
- package/js/{chunk-IPI4MFSN.js → chunk-XBG7HHXC.js} +2 -2
- package/js/chunk-XPRZTLHD.js +1915 -0
- package/js/chunk-YNJ5CZMJ.js +93 -0
- package/js/chunk-YRGL4QEF.js +49 -0
- package/js/{chunk-Z5M2LQOZ.js → chunk-YWFUWTUJ.js} +113 -58
- package/js/client.js +142 -78
- package/js/contracts.js +142 -21
- package/js/effect.js +18 -19
- package/js/{es-APDZKREY.js → es-DIULA3ZF.js} +62 -1659
- package/js/graphql.js +49 -40
- package/js/host.js +85 -62
- package/js/index.js +165 -70
- package/js/mcp/effect.js +21 -21
- package/js/mcp.js +76 -56
- package/js/openapi.js +4189 -1411
- package/js/react.js +2 -3
- package/js/skills/effect.js +6 -3
- package/js/skills.js +208 -81
- package/js/storage/facet.js +1 -540
- package/js/ui/auth/contracts.js +2 -2
- package/js/ui/auth.js +5 -5
- package/js/ui/contracts.js +5 -4
- package/js/ui/serving.js +8605 -225
- package/package.json +3 -8
- package/runtime.json +1 -1
- package/types/app-cache/src/contracts/cache.d.ts +18 -0
- package/types/app-cache/src/index.d.ts +34 -2
- package/types/apps/src/contracts/api-response-error.d.ts +4 -0
- package/types/apps/src/contracts/app.d.ts +60 -11
- package/types/apps/src/contracts/cache.d.ts +20 -0
- package/types/apps/src/contracts/context.d.ts +60 -17
- package/types/apps/src/contracts/elicitation.d.ts +23 -7
- package/types/apps/src/contracts/events.d.ts +94 -0
- package/types/apps/src/contracts/failure.d.ts +30 -1
- package/types/apps/src/contracts/graphql.d.ts +2 -1
- package/types/apps/src/contracts/host.d.ts +1446 -17
- package/types/apps/src/contracts/icons.d.ts +28 -0
- package/types/apps/src/contracts/live.d.ts +2 -0
- package/types/apps/src/contracts/mcp.d.ts +81 -20
- package/types/apps/src/contracts/network.d.ts +120 -0
- package/types/apps/src/contracts/openapi-compile.d.ts +82 -3
- package/types/apps/src/contracts/openapi.d.ts +41 -9
- package/types/apps/src/contracts/operations.d.ts +14 -7
- package/types/apps/src/contracts/placement.d.ts +102 -0
- package/types/apps/src/contracts/protocol-version.d.ts +2 -2
- package/types/apps/src/contracts/protocols/1.d.ts +733 -81
- package/types/apps/src/contracts/protocols/10.d.ts +1450 -0
- package/types/apps/src/contracts/protocols/11.d.ts +1149 -0
- package/types/apps/src/contracts/protocols/12.d.ts +3310 -0
- package/types/apps/src/contracts/protocols/2.d.ts +69 -26
- package/types/apps/src/contracts/protocols/3.d.ts +133 -33
- package/types/apps/src/contracts/protocols/4.d.ts +122 -45
- package/types/apps/src/contracts/protocols/5.d.ts +157 -47
- package/types/apps/src/contracts/protocols/6.d.ts +1629 -0
- package/types/apps/src/contracts/protocols/7.d.ts +1785 -0
- package/types/apps/src/contracts/protocols/8.d.ts +1182 -0
- package/types/apps/src/contracts/protocols/9.d.ts +1104 -0
- package/types/apps/src/contracts/protocols/current.d.ts +6669 -0
- package/types/apps/src/contracts/protocols/oauth-6.d.ts +74 -0
- package/types/apps/src/contracts/protocols/oauth.d.ts +134 -0
- package/types/apps/src/contracts/provider-error.d.ts +9 -0
- package/types/apps/src/contracts/provider.d.ts +90 -6
- package/types/apps/src/contracts/schedules.d.ts +7 -1
- package/types/apps/src/contracts/schema.d.ts +21 -0
- package/types/apps/src/contracts/skills.d.ts +50 -13
- package/types/apps/src/contracts/sql.d.ts +63 -0
- package/types/apps/src/contracts/ui.d.ts +44 -14
- package/types/apps/src/contracts/webhooks.d.ts +24 -7
- package/types/apps/src/contracts/workflows.d.ts +19 -17
- package/types/apps/src/facet.d.ts +4 -5
- package/types/apps/src/host.d.ts +5 -0
- package/types/apps/src/implementation/account-router.d.ts +4 -3
- package/types/apps/src/implementation/app.d.ts +41 -14
- package/types/apps/src/implementation/authoring.d.ts +25 -5
- package/types/apps/src/implementation/browser-scripts.gen.d.ts +6 -0
- package/types/apps/src/implementation/cache.d.ts +29 -2
- package/types/apps/src/implementation/catalog-cache.d.ts +35 -4
- package/types/apps/src/implementation/elicitation.d.ts +18 -15
- package/types/apps/src/implementation/events.d.ts +64 -0
- package/types/apps/src/implementation/failure-detail.d.ts +28 -5
- package/types/apps/src/implementation/graphql-catalog.d.ts +3 -3
- package/types/apps/src/implementation/graphql.d.ts +4 -3
- package/types/apps/src/implementation/input-problems.d.ts +6 -2
- package/types/apps/src/implementation/invocation-timing.d.ts +18 -0
- package/types/apps/src/implementation/live.d.ts +2 -2
- package/types/apps/src/implementation/mcp-call.d.ts +6 -5
- package/types/apps/src/implementation/mcp-catalog.d.ts +6 -4
- package/types/apps/src/implementation/mcp-client.d.ts +17 -9
- package/types/apps/src/implementation/mcp-tools.d.ts +2 -1
- package/types/apps/src/implementation/mcp.d.ts +20 -9
- package/types/apps/src/implementation/network.d.ts +16 -0
- package/types/apps/src/implementation/openapi-compile.d.ts +28 -7
- package/types/apps/src/implementation/openapi-document.d.ts +46 -19
- package/types/apps/src/implementation/openapi-names.d.ts +9 -4
- package/types/apps/src/implementation/openapi-request.d.ts +10 -2
- package/types/apps/src/implementation/openapi-source.d.ts +23 -1
- package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
- package/types/apps/src/implementation/operations.d.ts +57 -7
- package/types/apps/src/implementation/optimistic.d.ts +1 -1
- package/types/apps/src/implementation/placement.d.ts +60 -0
- package/types/apps/src/implementation/protocol-operations.d.ts +3 -0
- package/types/apps/src/implementation/provider-error.d.ts +28 -1
- package/types/apps/src/implementation/provider.d.ts +19 -4
- package/types/apps/src/implementation/query-commit.d.ts +1 -1
- package/types/apps/src/implementation/router-catalog.d.ts +20 -18
- package/types/apps/src/implementation/router.d.ts +24 -5
- package/types/apps/src/implementation/runtime-yield.d.ts +7 -0
- package/types/apps/src/implementation/schedules.d.ts +39 -8
- package/types/apps/src/implementation/schema.d.ts +98 -11
- package/types/apps/src/implementation/skills.d.ts +18 -24
- package/types/apps/src/implementation/sql.d.ts +71 -0
- package/types/apps/src/implementation/ui-account-notice.d.ts +9 -0
- package/types/apps/src/implementation/ui-auth.d.ts +1 -1
- package/types/apps/src/implementation/ui-client.d.ts +2 -2
- package/types/apps/src/implementation/ui-document.d.ts +5 -0
- package/types/apps/src/implementation/ui-errors.d.ts +1 -1
- package/types/apps/src/implementation/ui-serving.d.ts +26 -9
- package/types/apps/src/implementation/ui-watch.d.ts +1 -1
- package/types/apps/src/implementation/upstream-error.d.ts +7 -0
- package/types/apps/src/implementation/webhooks.d.ts +15 -6
- package/types/apps/src/implementation/workflow-context.d.ts +6 -2
- package/types/apps/src/implementation/workflows.d.ts +11 -4
- package/types/apps/src/index.d.ts +68 -19
- package/types/apps/src/mcp.d.ts +20 -1
- package/types/apps/src/openapi.d.ts +6 -1
- package/types/apps/src/react.d.ts +1 -1
- package/types/apps/src/skills.d.ts +10 -8
- package/types/apps/src/ui-serving.d.ts +1 -1
- package/types/telemetry/src/app-records.d.ts +42 -0
- package/types/telemetry/src/browser-operations.d.ts +2 -2
- package/types/telemetry/src/browser.d.ts +8 -3
- package/types/telemetry/src/config.d.ts +2 -2
- package/types/telemetry/src/index.d.ts +2 -1
- package/types/telemetry/src/layer.d.ts +10 -4
- package/types/telemetry/src/measurements.d.ts +1 -1
- package/types/telemetry/src/ownership.d.ts +60 -0
- package/types/telemetry/src/recorded-failure.d.ts +29 -0
- package/types/telemetry/src/relay.d.ts +16 -6
- package/types/telemetry/src/span-attributes.d.ts +17 -1
- package/types/telemetry/src/transport.d.ts +8 -1
- package/types/utils/src/api-error.d.ts +55 -0
- package/types/utils/src/connection-failure.d.ts +33 -0
- package/types/utils/src/recorded-message.d.ts +18 -0
- package/types/utils/src/user-facing-error.d.ts +83 -0
- package/js/chunk-7EK2JDX4.js +0 -299
- package/js/chunk-IKS2C5MQ.js +0 -224
- package/js/chunk-MKWZPDR6.js +0 -63
- package/js/chunk-N7YDVXYJ.js +0 -186
- package/js/chunk-NKLWZJLE.js +0 -172
- package/js/chunk-PJJ24GU7.js +0 -877
- package/js/chunk-PZB6T6KU.js +0 -19
- package/js/chunk-R3EV5FTO.js +0 -97
- package/js/chunk-SJFZCGXG.js +0 -1243
- package/js/chunk-WLE7WX2U.js +0 -2645
- package/js/chunk-YXQHV65J.js +0 -242
- package/js/chunk-ZQINWV4W.js +0 -630
- package/js/mcp/stdio.js +0 -128
- package/types/app-data/src/implementation/cursor.d.ts +0 -10
- package/types/app-data/src/implementation/index-key.d.ts +0 -7
- package/types/app-data/src/implementation/promise.d.ts +0 -68
- package/types/app-data/src/implementation/range.d.ts +0 -8
- package/types/app-data/src/implementation/schema.d.ts +0 -18
- package/types/app-data/src/implementation/sqlite.d.ts +0 -11
- package/types/app-data/src/index.d.ts +0 -4
- package/types/apps/src/contracts/storage.d.ts +0 -68
- package/types/apps/src/implementation/mcp-stdio.d.ts +0 -4
- package/types/apps/src/implementation/storage.d.ts +0 -15
- package/types/apps/src/mcp-stdio.d.ts +0 -5
|
@@ -1,18 +1,35 @@
|
|
|
1
|
-
import { Effect } from "effect";
|
|
2
|
-
import { HttpServerRequest, HttpServerResponse } from "effect/
|
|
3
|
-
import { UiForbidden, type AppUiAsset } from "../contracts/ui.js";
|
|
4
|
-
/**
|
|
1
|
+
import { Effect, Option, Stream } from "effect";
|
|
2
|
+
import { HttpServerRequest, HttpServerResponse } from "effect/http";
|
|
3
|
+
import { UiFailed, UiForbidden, type AppUiAsset, type AppUiRange, type AppUiStoredFile, type UiAccountNotice } from "../contracts/ui.js";
|
|
4
|
+
/**
|
|
5
|
+
* Render an authorized deployment with a host-owned deployment watcher. Account problems that stop
|
|
6
|
+
* the app replace its document with a page that links to their fix; others add a dismissible card.
|
|
7
|
+
*/
|
|
5
8
|
export declare const appDocument: <E, R>(options: {
|
|
6
9
|
readonly deployment: string;
|
|
7
|
-
|
|
8
|
-
readonly
|
|
10
|
+
/** The account IDs the page runs with, by requirement. */
|
|
11
|
+
readonly accountIds?: Readonly<Record<string, readonly string[]>> | undefined;
|
|
9
12
|
readonly origin: string;
|
|
13
|
+
readonly accounts?: UiAccountNotice | undefined;
|
|
10
14
|
readonly asset: (path: string) => Effect.Effect<AppUiAsset | undefined, E, R>;
|
|
11
|
-
}) => Effect.Effect<HttpServerResponse.HttpServerResponse, UiForbidden | E, HttpServerRequest.HttpServerRequest | R>;
|
|
15
|
+
}) => Effect.Effect<HttpServerResponse.HttpServerResponse, UiFailed | UiForbidden | E, HttpServerRequest.HttpServerRequest | R>;
|
|
16
|
+
/**
|
|
17
|
+
* A deployment's public file, read from the host's store. The deployment lists it, so bytes that
|
|
18
|
+
* are gone are a storage fault, never a missing page.
|
|
19
|
+
*/
|
|
20
|
+
export declare const storedAppFile: <E1, E2>(stored: {
|
|
21
|
+
readonly contentType: string;
|
|
22
|
+
readonly size: number;
|
|
23
|
+
readonly etag: string;
|
|
24
|
+
}, read: (range: AppUiRange | undefined) => Effect.Effect<Option.Option<{
|
|
25
|
+
readonly body: Stream.Stream<Uint8Array, E1>;
|
|
26
|
+
}>, E2>) => AppUiStoredFile;
|
|
27
|
+
/** The file a URL path names: each segment percent-decoded, or none when one does not decode. */
|
|
28
|
+
export declare const assetPath: (path: string) => Option.Option<string>;
|
|
12
29
|
/** Serve an asset only after the host has checked current access and file existence.
|
|
13
30
|
* Asset URLs name their deployment, so their bytes never change: the browser keeps them for a year
|
|
14
31
|
* and does not ask again. Shared proxies never store them. Revoking access stops every new request
|
|
15
32
|
* and all app data, while bytes a browser already downloaded stay in its cache.
|
|
16
|
-
* HTML remains an uncached host-rendered entry point.
|
|
33
|
+
* HTML remains an uncached host-rendered entry point; other HTML files are served as they are.
|
|
17
34
|
*/
|
|
18
|
-
export declare const appAsset: (asset: AppUiAsset | undefined, build: string, path: string) => Effect.Effect<HttpServerResponse.HttpServerResponse,
|
|
35
|
+
export declare const appAsset: (asset: AppUiAsset | undefined, build: string, path: string) => Effect.Effect<HttpServerResponse.HttpServerResponse, UiFailed, HttpServerRequest.HttpServerRequest>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Dependency-free browser source served by each host after app authorization. */
|
|
2
|
-
export declare const appWatchScript
|
|
2
|
+
export declare const appWatchScript = "\"use strict\";(()=>{var s=()=>{let i=document.getElementById(\"executor-context\")?.textContent;if(!i)return;let n=JSON.parse(i);if(typeof n!=\"object\"||n===null||!(\"deployment\"in n))return;let r=n.deployment;if(typeof r!=\"string\"||r.length===0)return;let t=new EventSource(\"/_executor/version\"),l=!1,o=()=>{l||(l=!0,t.close(),location.reload())};t.addEventListener(\"version\",d=>{let e=JSON.parse(d.data);typeof e==\"object\"&&e!==null&&\"deployment\"in e&&(e.deployment===null||typeof e.deployment==\"string\")&&e.deployment!==r&&o()}),t.addEventListener(\"revoked\",o),window.addEventListener(\"executor:deployment-changed\",o),window.addEventListener(\"pagehide\",()=>t.close(),{once:!0}),window.addEventListener(\"pageshow\",d=>{d.persisted&&o()})};s();})();";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { UpstreamError } from "../contracts/failure.js";
|
|
2
|
+
/** Whether `bounded` shortened this message, so it may end partway through a secret. */
|
|
3
|
+
export declare const isShortenedUpstream: (message: string) => boolean;
|
|
4
|
+
/** The error a JSON error body states, if it uses a nested error object or OAuth's format. */
|
|
5
|
+
export declare const bodyUpstreamError: (json: unknown) => UpstreamError | undefined;
|
|
6
|
+
/** The `error` and `error_description` of a Bearer challenge (RFC 6750, section 3). */
|
|
7
|
+
export declare const challengeUpstreamError: (header: string | undefined) => UpstreamError | undefined;
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
/** Native webhook dispatch. The author verifies signatures before parsing or performing side effects. */
|
|
2
2
|
import { Effect, Schema } from "effect";
|
|
3
|
-
import type { AppDefinition } from "../contracts/app.js";
|
|
4
|
-
import { HostDeclarationInvalid, HostInputInvalid, HostOperationFailed, HostOperationNotFound,
|
|
3
|
+
import type { AppDefinition, ScopedSlots } from "../contracts/app.js";
|
|
4
|
+
import { HostDeclarationInvalid, HostInputInvalid, HostOperationFailed, HostOperationNotFound, HostAccountsInvalid, HostOutputInvalid } from "../contracts/host.js";
|
|
5
5
|
import { type WebhookCommand } from "../contracts/webhook-protocol.js";
|
|
6
|
-
|
|
6
|
+
type ScopeAccounts = {
|
|
7
|
+
readonly accounts: Readonly<Record<string, unknown>>;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Run one hook with freshly bound context. No credentials or raw failures enter the response
|
|
11
|
+
* envelope. An app-account hook runs without a caller: its context has no `user`, whatever the
|
|
12
|
+
* invocation bound.
|
|
13
|
+
*/
|
|
7
14
|
export declare const dispatchWebhook: <Context extends {
|
|
8
15
|
readonly signal?: AbortSignal;
|
|
9
|
-
readonly
|
|
10
|
-
|
|
16
|
+
readonly app: ScopeAccounts;
|
|
17
|
+
readonly user?: ScopeAccounts;
|
|
18
|
+
}>(definition: AppDefinition<Context>, command: WebhookCommand, context: Context, slots: ScopedSlots) => Effect.Effect<Schema.Json | {
|
|
11
19
|
readonly name: string;
|
|
12
20
|
readonly account: string;
|
|
13
21
|
readonly configSchema: {
|
|
@@ -26,4 +34,5 @@ export declare const dispatchWebhook: <Context extends {
|
|
|
26
34
|
readonly [x: string]: string;
|
|
27
35
|
};
|
|
28
36
|
readonly body: string;
|
|
29
|
-
},
|
|
37
|
+
}, HostDeclarationInvalid | HostAccountsInvalid | HostOperationNotFound | HostOperationFailed | HostInputInvalid | HostOutputInvalid, never>;
|
|
38
|
+
export {};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/** Author-facing step methods delegate persistence to the host's durable engine. */
|
|
2
2
|
import { Effect } from "effect";
|
|
3
|
-
import type { AppDefinition } from "../contracts/app.js";
|
|
4
|
-
import
|
|
3
|
+
import type { AccountScope, AppDefinition } from "../contracts/app.js";
|
|
4
|
+
import type { AppRequirements } from "../contracts/context.js";
|
|
5
|
+
import { WorkflowFailure, type WorkflowContext, type WorkflowExecution, type WorkflowStepContext as AuthorStepContext } from "../contracts/workflows.js";
|
|
6
|
+
/** A step's context as the host builds it: a run without a caller has no `user`. */
|
|
7
|
+
type WorkflowStepContext = AuthorStepContext<AppRequirements, AccountScope> & Partial<Pick<AuthorStepContext, "user">>;
|
|
5
8
|
/**
|
|
6
9
|
* Preserve typed failures and cancellation. Other errors keep their name and bounded message,
|
|
7
10
|
* with the given account secrets replaced.
|
|
@@ -14,3 +17,4 @@ fresh: (stepId: string, signal: AbortSignal) => Effect.Effect<{
|
|
|
14
17
|
readonly context: WorkflowStepContext;
|
|
15
18
|
readonly secrets: readonly string[];
|
|
16
19
|
}, WorkflowFailure>, signal: AbortSignal) => Effect.Effect<WorkflowContext>;
|
|
20
|
+
export {};
|
|
@@ -1,23 +1,30 @@
|
|
|
1
1
|
/** Ordinary async workflow declarations, adapted once into native Effect handlers. */
|
|
2
|
-
import {
|
|
2
|
+
import type { Schema as EffectSchema } from "effect";
|
|
3
3
|
import type { AppWorkflow, WorkflowContext } from "../contracts/workflows.js";
|
|
4
|
+
import type { AppRequirements } from "../contracts/context.js";
|
|
5
|
+
import type { AccountScope } from "../contracts/app.js";
|
|
4
6
|
import { type Schema } from "./schema.js";
|
|
5
7
|
declare const NativeWorkflow: unique symbol;
|
|
8
|
+
/**
|
|
9
|
+
* The context any workflow may declare: either scope, so a run started without a caller, such as
|
|
10
|
+
* by an app schedule, declares `WorkflowContext<typeof requirements, "app">`.
|
|
11
|
+
*/
|
|
12
|
+
export type AnyWorkflowContext = WorkflowContext<AppRequirements, AccountScope>;
|
|
6
13
|
declare const HandlerContext: unique symbol;
|
|
7
14
|
/** A workflow declaration retains input/output inference and required context compatibility. */
|
|
8
|
-
export interface Workflow<Input, Output, Context extends
|
|
15
|
+
export interface Workflow<Input, Output, Context extends AnyWorkflowContext = WorkflowContext> {
|
|
9
16
|
readonly [HandlerContext]?: (context: Context) => void;
|
|
10
17
|
readonly [NativeWorkflow]: AppWorkflow<Input, Output>;
|
|
11
18
|
}
|
|
12
19
|
/** Composition view erases input only after retaining its runtime decoder. */
|
|
13
|
-
export interface WorkflowDeclaration<Context extends
|
|
20
|
+
export interface WorkflowDeclaration<Context extends AnyWorkflowContext> {
|
|
14
21
|
readonly [HandlerContext]?: (context: Context) => void;
|
|
15
22
|
readonly [NativeWorkflow]: Omit<AppWorkflow<never>, "input"> & {
|
|
16
23
|
readonly input: EffectSchema.Decoder<unknown>;
|
|
17
24
|
};
|
|
18
25
|
}
|
|
19
26
|
/** Declare durable orchestration without starting a run or performing I/O. */
|
|
20
|
-
export declare const workflow: <Input, Output, Context extends
|
|
27
|
+
export declare const workflow: <Input, Output, Context extends AnyWorkflowContext = WorkflowContext>(options: {
|
|
21
28
|
readonly input: Schema<Input, boolean>;
|
|
22
29
|
readonly output?: Schema<Output, boolean>;
|
|
23
30
|
readonly description?: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { ProviderError } from "./contracts/provider-error.js";
|
|
2
|
+
export { FetchOptionUnsupported, NetworkRefused } from "./contracts/network.js";
|
|
2
3
|
export type { AppCache, CacheLoadContext, CacheGetOptions } from "./contracts/cache.js";
|
|
3
4
|
export { CacheError } from "../../app-cache/src/contracts/cache.js";
|
|
4
5
|
/**
|
|
@@ -6,49 +7,92 @@ export { CacheError } from "../../app-cache/src/contracts/cache.js";
|
|
|
6
7
|
* exposes ordinary declarations, schema helpers and Promise operations.
|
|
7
8
|
*/
|
|
8
9
|
import { type Schema as EffectSchema } from "effect";
|
|
9
|
-
import type { WebhookContext } from "./contracts/context.js";
|
|
10
|
+
import type { AppRequirements, WebhookContext } from "./contracts/context.js";
|
|
11
|
+
import type { AccountScope } from "./contracts/app.js";
|
|
10
12
|
import { type JsonResponse as NativeResponse } from "./contracts/http.js";
|
|
11
|
-
import { type OAuth2Config, type OAuth2Method as NativeOAuth2Method, type SecretsMethod as NativeSecretsMethod } from "./contracts/provider.js";
|
|
13
|
+
import { type OAuth2Config as NativeOAuth2Config, type OAuth2Method as NativeOAuth2Method, type ReservedAuthorizationParam, type SecretsMethod as NativeSecretsMethod } from "./contracts/provider.js";
|
|
12
14
|
import type { Webhook as NativeWebhook } from "./contracts/webhooks.js";
|
|
13
15
|
import { type PromiseMethods } from "./implementation/authoring.js";
|
|
14
|
-
import { type
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
import { type PlacementInput, type RequestPlacements } from "./implementation/placement.js";
|
|
17
|
+
import type { Placement } from "./contracts/placement.js";
|
|
18
|
+
import type { QueryContext as NativeQueryContext } from "./contracts/context.js";
|
|
19
|
+
import { query as operationQuery, type AnyContext, type OperationOptions } from "./implementation/operations.js";
|
|
20
|
+
import { type Fields, type Infer, type ObjectSchema, type Schema, type SecretFields, type SecretObject } from "./implementation/schema.js";
|
|
21
|
+
export { DeclarationInvalid, type DeclarationIssue, type JsonObject, type JsonValue, ValidationError, } from "./contracts/schema.js";
|
|
22
|
+
export { type Fields, type Infer, type ObjectSchema, type ObjectValue, type Schema, array, boolean, json, jsonSchema, literal, number, object, record, string, plain, raw, type SecretString, } from "./implementation/schema.js";
|
|
23
|
+
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";
|
|
18
24
|
export { defineProvider, type ProviderOptions } from "./implementation/provider.js";
|
|
25
|
+
export { base64, basic, bearer, header, t, type FieldRef, type FieldRefs, type PlacementInput, type PlacementValue, type RequestPlacements, } from "./implementation/placement.js";
|
|
26
|
+
export type { Placement };
|
|
27
|
+
export type { AccountRequest } from "./contracts/provider.js";
|
|
19
28
|
export { accountRouter } from "./implementation/account-router.js";
|
|
20
|
-
export { router, dynamicRouter, type RouterDeclaration, type RouterChild, type RouterOptions, } from "./implementation/router.js";
|
|
29
|
+
export { router, dynamicRouter, withApprovals, renameTools, type OperationChild, type OperationDeclaration, type RouterDeclaration, type RouterChild, type RouterOptions, } from "./implementation/router.js";
|
|
21
30
|
export type { RouterIcon } from "./contracts/router.js";
|
|
31
|
+
export type { AppIcon } from "./contracts/icons.js";
|
|
22
32
|
export { dynamicSkills } from "./implementation/dynamic-skills.js";
|
|
23
33
|
export type { HostedTool as OperationDescription } from "./contracts/host.js";
|
|
34
|
+
/** Account fields as app code receives them from a method declared with this schema. */
|
|
35
|
+
type AccountFields<S> = S extends ObjectSchema<infer F> ? SecretFields<F> : SecretObject<Infer<S>>;
|
|
24
36
|
/** A secrets declaration inferred from an author schema. */
|
|
25
|
-
export type SecretsMethod<Shape extends ObjectSchema<Fields>> = NativeSecretsMethod<EffectSchema.Decoder<
|
|
37
|
+
export type SecretsMethod<Shape extends ObjectSchema<Fields>> = NativeSecretsMethod<EffectSchema.Decoder<AccountFields<Shape>>>;
|
|
26
38
|
/** An OAuth declaration inferred from its author-facing response schema. */
|
|
27
|
-
export type OAuth2Method<Response extends Schema<unknown, boolean>> = NativeOAuth2Method<EffectSchema.Decoder<
|
|
39
|
+
export type OAuth2Method<Response extends Schema<unknown, boolean>> = NativeOAuth2Method<EffectSchema.Decoder<AccountFields<Response>>>;
|
|
40
|
+
/** The names of an object schema's fields, which a method's `request` can reference. */
|
|
41
|
+
type FieldNameOf<S> = S extends ObjectSchema<infer F> ? keyof F & string : never;
|
|
28
42
|
/** Default OAuth fields visible to app code. Host-only grants and clients stay private. */
|
|
29
43
|
export declare const OAuth2AccessToken: Schema<{
|
|
30
44
|
readonly access_token: string;
|
|
31
45
|
}, false>;
|
|
32
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* OAuth options as authors write them. `authorizationParams` naming a host-owned protocol
|
|
48
|
+
* parameter such as `state` or `scope` is a type error as well as a declaration failure.
|
|
49
|
+
*/
|
|
50
|
+
export type OAuth2Config = WithoutReservedParams<NativeOAuth2Config>;
|
|
51
|
+
type WithoutReservedParams<Config> = Config extends unknown ? "authorizationParams" extends keyof Config ? Config & {
|
|
52
|
+
readonly authorizationParams?: {
|
|
53
|
+
readonly [Key in ReservedAuthorizationParam]?: never;
|
|
54
|
+
};
|
|
55
|
+
} : Config : never;
|
|
56
|
+
/**
|
|
57
|
+
* Declare a secrets method without requiring an Effect schema from the author. `request` says
|
|
58
|
+
* where its secret fields may be sent, such as `({ token }) => bearer(token)`; it runs once, here.
|
|
59
|
+
*/
|
|
33
60
|
export declare const secrets: <const F extends Fields>(options: {
|
|
34
61
|
readonly label: string;
|
|
35
62
|
readonly fields: ObjectSchema<F>;
|
|
63
|
+
readonly request?: RequestPlacements<keyof F & string>;
|
|
36
64
|
}) => SecretsMethod<ObjectSchema<F>>;
|
|
37
|
-
/**
|
|
38
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Declare OAuth discovery/endpoints and an optional app-visible response projection.
|
|
67
|
+
* `authorizationParams` adds service-defined sign-in parameters; a declared `authorizationUrl`
|
|
68
|
+
* keeps its own query. Neither can set host-owned parameters, and each parameter appears once.
|
|
69
|
+
* `request` says where the projected secret fields may be sent, such as
|
|
70
|
+
* `({ access_token }) => bearer(access_token)`; it runs once, here.
|
|
71
|
+
*/
|
|
72
|
+
export declare function oauth2(options: OAuth2Config & {
|
|
73
|
+
readonly request?: RequestPlacements<"access_token">;
|
|
74
|
+
}): OAuth2Method<typeof OAuth2AccessToken>;
|
|
39
75
|
export declare function oauth2<Response extends Schema<unknown, boolean>>(options: OAuth2Config & {
|
|
40
76
|
readonly response: Response;
|
|
77
|
+
readonly request?: RequestPlacements<FieldNameOf<Response>>;
|
|
41
78
|
}): OAuth2Method<Response>;
|
|
42
|
-
export type { AccountSlots } from "./contracts/app.js";
|
|
43
|
-
export type { AppRequirements, AppContext, QueryContext, MutationContext, WebhookContext, } from "./contracts/context.js";
|
|
79
|
+
export type { AccountScope, AccountSlots, WebhookAccount } from "./contracts/app.js";
|
|
80
|
+
export type { AnyScopeMutationContext, AppRequirements, AppContext, QueryContext, MutationContext, WebhookContext, } from "./contracts/context.js";
|
|
44
81
|
export { type App, type AppDefinition, defineApp } from "./implementation/app.js";
|
|
82
|
+
export { event, type EventDeclaration, type EventEmitter } from "./implementation/events.js";
|
|
83
|
+
export type { EmitOptions } from "./contracts/events.js";
|
|
45
84
|
export type { Approval, ApprovalContext, ApprovalDecision } from "./approval.js";
|
|
46
85
|
type AuthorWebhook<Member, Config, State> = Member extends object ? Omit<PromiseMethods<Member>, "config" | "state"> & {
|
|
47
86
|
readonly config: Config;
|
|
48
87
|
readonly state: State;
|
|
49
88
|
} : never;
|
|
50
89
|
/** Author lifecycle methods use async functions and share native decoded context/state types. */
|
|
51
|
-
|
|
90
|
+
/**
|
|
91
|
+
* A webhook's context names its source account's scope: one with `user` serves a user requirement
|
|
92
|
+
* (`account: { user: "x" }`), one of the `"app"` scope an app requirement (`account: { app: "x" }`)
|
|
93
|
+
* and runs without a caller.
|
|
94
|
+
*/
|
|
95
|
+
export type Webhook<Context extends WebhookContext<AppRequirements, AccountScope>, Config extends Schema<unknown, boolean>, State extends Schema<unknown, boolean>> = AuthorWebhook<NativeWebhook<Context, EffectSchema.Decoder<Infer<Config>>, EffectSchema.Decoder<Infer<State>>>, Config, State>;
|
|
52
96
|
export { ResponseDecodeError, ResponseStatusError } from "./contracts/http.js";
|
|
53
97
|
/** Native fetch-compatible response accepted at the author boundary. */
|
|
54
98
|
export type JsonResponse = PromiseMethods<NativeResponse>;
|
|
@@ -56,11 +100,16 @@ export type JsonResponse = PromiseMethods<NativeResponse>;
|
|
|
56
100
|
export declare const decodeJson: <T>(response: JsonResponse, schema: Schema<T, boolean>) => Promise<T>;
|
|
57
101
|
export { NotImplemented } from "./contracts/app.js";
|
|
58
102
|
export { ElicitationFailed, type FormElicitation, type ElicitationResponse, type Elicit, } from "./contracts/elicitation.js";
|
|
59
|
-
export {
|
|
60
|
-
|
|
61
|
-
|
|
103
|
+
export type { Sql, SqlCursor, SqlReader, SqlRow, SqlTransaction, SqlValue, } from "./contracts/sql.js";
|
|
104
|
+
/**
|
|
105
|
+
* `query(options, run)` declares a read operation. `query(name, value)` inside a method's
|
|
106
|
+
* `request` places a credential in a query parameter, such as `query("key", key)`.
|
|
107
|
+
*/
|
|
108
|
+
export declare function query(name: string, value: PlacementInput): Placement;
|
|
109
|
+
export declare function query<Input, Output, Context extends AnyContext = NativeQueryContext>(options: OperationOptions<Input, Output>, run: (context: Context, input: Input) => Promise<Output>): ReturnType<typeof operationQuery<Input, Output, Context>>;
|
|
110
|
+
export { mutation, withApproval, toolAnnotations, type Approved, type Operation, type OperationOptions, } from "./implementation/operations.js";
|
|
62
111
|
export type { OperationContext } from "./contracts/operations.js";
|
|
63
112
|
export { workflow, type Workflow, type WorkflowDeclaration } from "./implementation/workflows.js";
|
|
64
113
|
export { NonRetryableError, WorkflowFailure, type WorkflowContext, type WorkflowStepContext, type WorkflowStep, type WorkflowStepOptions, type WorkflowDuration, type WorkflowReads, type WorkflowControls, } from "./contracts/workflows.js";
|
|
65
|
-
export {
|
|
114
|
+
export { appCron, appInterval, userCron, userInterval, type ScheduleDeclaration, } from "./implementation/schedules.js";
|
|
66
115
|
export type { AppSkillSource as Skill, SkillFile } from "./contracts/skills.js";
|
package/types/apps/src/mcp.d.ts
CHANGED
|
@@ -1,11 +1,30 @@
|
|
|
1
1
|
/** HTTP MCP helpers. Requires the optional @modelcontextprotocol/sdk peer. */
|
|
2
2
|
import type { OperationKinds } from "./implementation/protocol-operations.js";
|
|
3
|
+
import type { McpHealthOptions } from "./contracts/mcp.js";
|
|
4
|
+
import type { AccountCheckContext, AuthMethods } from "./contracts/provider.js";
|
|
3
5
|
import { type McpCatalogOptions } from "./implementation/mcp-catalog.js";
|
|
4
6
|
export type { McpCatalogOptions } from "./implementation/mcp-catalog.js";
|
|
5
|
-
export { McpError, type McpToolContext, type McpToolsOptions, type McpToolResult, } from "./contracts/mcp.js";
|
|
7
|
+
export { McpCredentialsUnverified, McpError, type McpHealthOptions, type McpToolContext, type McpToolsOptions, type McpToolResult, } from "./contracts/mcp.js";
|
|
6
8
|
/**
|
|
7
9
|
* A router over a server's tools for the selected account. Its title, description and
|
|
8
10
|
* instructions come from the server. Kinds override uncertain upstream read-only hints.
|
|
9
11
|
*/
|
|
10
12
|
export declare const mcpRouter: (options: McpCatalogOptions, kinds?: OperationKinds) => Promise<import("./index.js").RouterDeclaration<unknown, unknown>>;
|
|
13
|
+
/**
|
|
14
|
+
* A provider `health` check for an MCP server. Pass the check context `health` receives, then the
|
|
15
|
+
* server's `url` and the `headers` that send the account's credentials:
|
|
16
|
+
* `health: (check) => mcpHealth(check, { url, headers: headers(check.account) })`.
|
|
17
|
+
*
|
|
18
|
+
* It connects with those headers, initializes, and reads the first page of tools, then does the
|
|
19
|
+
* same without any headers. No tool runs. The check passes only when the server accepts the account
|
|
20
|
+
* and refuses the attempt without credentials. A refused account throws `ProviderError`, as HTTP
|
|
21
|
+
* helpers do. An unreachable or unusable server throws `McpError`, and a request Executor's network
|
|
22
|
+
* refuses throws `NetworkRefused`. A server that also answers without credentials, or whose answer
|
|
23
|
+
* to that attempt is not a refusal, throws `McpCredentialsUnverified`. Each of these errors means
|
|
24
|
+
* the check could not verify the account, and the account form explains why. Send credentials only
|
|
25
|
+
* in `headers`; the attempt without them uses the same `url`. The check context's `signal` cancels
|
|
26
|
+
* both attempts, and they share one budget that ends early enough before its `deadline` to report a
|
|
27
|
+
* server that did not answer in time. `timeoutMs` can only shorten that budget.
|
|
28
|
+
*/
|
|
29
|
+
export declare const mcpHealth: <Auth extends AuthMethods>(check: AccountCheckContext<Auth>, options: McpHealthOptions) => Promise<void>;
|
|
11
30
|
export type { OperationKinds } from "./implementation/protocol-operations.js";
|
|
@@ -9,4 +9,9 @@ export { OpenapiError, isOpenapiTextMedia, openapiBinaryResultSchema, OpenapiErr
|
|
|
9
9
|
export declare const openapiRouter: (options: OpenapiToolsOptions, kinds?: OperationKinds) => Promise<import("./index.js").RouterDeclaration<unknown, unknown>>;
|
|
10
10
|
export type { OperationKinds } from "./implementation/protocol-operations.js";
|
|
11
11
|
export * from "./contracts/openapi-compile.js";
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* The names `liveOpenapiRouter` gives a document's operations, from each operation's
|
|
14
|
+
* operationId, first tag, method and path alone. It reads no document and compiles nothing.
|
|
15
|
+
*/
|
|
16
|
+
export { planOperationNames, type OperationNameInput } from "./implementation/openapi-names.js";
|
|
17
|
+
export { liveOpenapiRouter, openapiToolNames, type OpenapiSourceOptions, type OpenapiToolNamesOptions, } from "./implementation/openapi-source.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AsyncResult, type Atom } from "effect/
|
|
1
|
+
import { AsyncResult, type Atom } from "effect/reactivity";
|
|
2
2
|
/** Subscribe for the component lifetime. Each mount owns and disposes its registry, including StrictMode remounts. */
|
|
3
3
|
export declare const useAppQuery: <A, E>(atom: Atom.Atom<AsyncResult.AsyncResult<A, E>>) => {
|
|
4
4
|
data: A | undefined;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { type FolderSkillsOptions, type GitHubSkillsOptions, type SkillReaderOptions, type WellKnownSkillsOptions, type SkillFile } from "./contracts/skills.js";
|
|
2
|
-
export { SkillLoadFailed, SkillDefinitionInvalid, SkillServiceName, type SkillReaderOptions, type FolderSkillsOptions, type AppSkillSource as Skill, type SkillFile, type GitHubSkillsOptions, type SkillCacheOptions, type WellKnownSkillsOptions, } from "./contracts/skills.js";
|
|
2
|
+
export { SkillLoadFailed, SkillDefinitionInvalid, SkillServiceName, type SkillReaderOptions, type FolderSkillsOptions, type AppSkillSource as Skill, type SkillFile, type GitHubSkillsAccount, type GitHubSkillsOptions, type SkillCacheOptions, type WellKnownSkillsOptions, } from "./contracts/skills.js";
|
|
3
3
|
/**
|
|
4
|
-
* Fetch a
|
|
5
|
-
* the catalog; without it, mutable refs resolve
|
|
4
|
+
* Fetch a GitHub skill collection from one resolved commit. A private repository takes `account`
|
|
5
|
+
* and its `token`. Pass `cache: ctx.cache` to reuse the catalog; without it, mutable refs resolve
|
|
6
|
+
* again on each call.
|
|
6
7
|
*/
|
|
7
8
|
export declare const githubSkills: (options: GitHubSkillsOptions) => Promise<readonly {
|
|
8
|
-
readonly name: string;
|
|
9
9
|
readonly description: string;
|
|
10
|
+
readonly name: string;
|
|
10
11
|
readonly files: readonly {
|
|
11
12
|
readonly path: string;
|
|
12
13
|
readonly content: string;
|
|
@@ -20,8 +21,8 @@ export declare const githubSkills: (options: GitHubSkillsOptions) => Promise<rea
|
|
|
20
21
|
}[]>;
|
|
21
22
|
/** Fetch a published skill index and its text files. Pass `cache: ctx.cache` to reuse the catalog. */
|
|
22
23
|
export declare const wellKnownSkills: (options: WellKnownSkillsOptions) => Promise<readonly {
|
|
23
|
-
readonly name: string;
|
|
24
24
|
readonly description: string;
|
|
25
|
+
readonly name: string;
|
|
25
26
|
readonly files: readonly {
|
|
26
27
|
readonly path: string;
|
|
27
28
|
readonly content: string;
|
|
@@ -35,8 +36,8 @@ export declare const wellKnownSkills: (options: WellKnownSkillsOptions) => Promi
|
|
|
35
36
|
}[]>;
|
|
36
37
|
/** Parse a bundled standard skill directory into an app capability. */
|
|
37
38
|
export declare const fileSkill: (files: readonly SkillFile[]) => Promise<{
|
|
38
|
-
readonly name: string;
|
|
39
39
|
readonly description: string;
|
|
40
|
+
readonly name: string;
|
|
40
41
|
readonly files: readonly {
|
|
41
42
|
readonly path: string;
|
|
42
43
|
readonly content: string;
|
|
@@ -50,8 +51,8 @@ export declare const fileSkill: (files: readonly SkillFile[]) => Promise<{
|
|
|
50
51
|
}>;
|
|
51
52
|
/** Read skill directories from ctx.files. Omitted path selects skills/; missing folders return []. */
|
|
52
53
|
export declare const folderSkills: (options: FolderSkillsOptions) => Promise<readonly {
|
|
53
|
-
readonly name: string;
|
|
54
54
|
readonly description: string;
|
|
55
|
+
readonly name: string;
|
|
55
56
|
readonly files: readonly {
|
|
56
57
|
readonly path: string;
|
|
57
58
|
readonly content: string;
|
|
@@ -65,7 +66,8 @@ export declare const folderSkills: (options: FolderSkillsOptions) => Promise<rea
|
|
|
65
66
|
}[]>;
|
|
66
67
|
/**
|
|
67
68
|
* Read files for a custom remote skill loader, such as one for GitLab. Reads share one byte
|
|
68
|
-
* budget and reject with the same safe SkillLoadFailed errors as githubSkills, naming `service
|
|
69
|
+
* budget and reject with the same safe SkillLoadFailed errors as githubSkills, naming `service`,
|
|
70
|
+
* or with `NetworkRefused` when Executor's network refuses a request.
|
|
69
71
|
*/
|
|
70
72
|
export declare const skillReader: (options: SkillReaderOptions) => {
|
|
71
73
|
/** Fetch one UTF-8 text file. */
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/** Host-only rendering utilities; the host supplies authorized retained assets. */
|
|
2
|
-
export { appDocument, appAsset } from "./implementation/ui-serving.js";
|
|
2
|
+
export { appDocument, appAsset, assetPath, storedAppFile } from "./implementation/ui-serving.js";
|
|
3
3
|
export { appWatchScript } from "./implementation/ui-watch.js";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the host keeps of the spans and logs an app isolate returns.
|
|
3
|
+
*
|
|
4
|
+
* Those records come from whatever framework the app's build bundles, and the app's own code runs
|
|
5
|
+
* in the same isolate: it can throw any text, name its errors and codes, and rewrite every record
|
|
6
|
+
* before the isolate returns it. So the host does not filter the records it receives. It builds
|
|
7
|
+
* new ones from a closed vocabulary: the framework's span names, attributes whose values are
|
|
8
|
+
* closed sets, counts and status codes, and each exception's kind. Ids, parents and timings are
|
|
9
|
+
* kept. Everything else, including events other than exceptions, links, status and exception
|
|
10
|
+
* messages, stacks and log bodies, is dropped or replaced with a fixed sentence.
|
|
11
|
+
*
|
|
12
|
+
* The vocabulary is the framework's (`packages/apps`, `app-cache`, `app-data`): host request
|
|
13
|
+
* operations, failure sources and reasons, MCP and cache attributes. A name or value outside it is
|
|
14
|
+
* recorded as `unrecognized` or not at all. `bun run check` (`scripts/check-app-telemetry.ts`)
|
|
15
|
+
* fails when the framework names a span or sets an attribute key this vocabulary does not know.
|
|
16
|
+
*/
|
|
17
|
+
import type { Schema } from "effect";
|
|
18
|
+
type Json = Schema.Json;
|
|
19
|
+
type JsonObject = {
|
|
20
|
+
readonly [key: string]: Json;
|
|
21
|
+
};
|
|
22
|
+
/** What an exception message, stack or log body from an app isolate records instead. */
|
|
23
|
+
export declare const appText = "Text from the app is not recorded";
|
|
24
|
+
/** The framework's span names, and the libraries' spans it runs. */
|
|
25
|
+
export declare const appSpanNames: ReadonlySet<string>;
|
|
26
|
+
export declare const appSpanAttributeKeys: ReadonlySet<string>;
|
|
27
|
+
/**
|
|
28
|
+
* Attributes the framework sets whose values the app chooses, such as its tool names, so the host
|
|
29
|
+
* drops them. `scripts/check-app-telemetry.ts` fails on a framework attribute in neither set.
|
|
30
|
+
*/
|
|
31
|
+
export declare const droppedAppAttributeKeys: ReadonlySet<string>;
|
|
32
|
+
/** The span the host records for one an app isolate returned, or nothing without its timings. */
|
|
33
|
+
export declare const appSpan: (span: JsonObject & {
|
|
34
|
+
readonly traceId: string;
|
|
35
|
+
readonly spanId: string;
|
|
36
|
+
}) => JsonObject | undefined;
|
|
37
|
+
/** The log record the host records for one an app isolate returned. */
|
|
38
|
+
export declare const appLog: (log: JsonObject & {
|
|
39
|
+
readonly traceId?: string | undefined;
|
|
40
|
+
readonly spanId?: string | undefined;
|
|
41
|
+
}) => JsonObject;
|
|
42
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Correlate transport and decoded outcomes without exporting response bodies or errors. */
|
|
2
2
|
import { Effect, Schema, Tracer } from "effect";
|
|
3
|
-
import { HttpClient, HttpClientError } from "effect/
|
|
3
|
+
import { HttpClient, HttpClientError } from "effect/http";
|
|
4
4
|
/**
|
|
5
5
|
* A random identity for the current browser document. It is never an authentication or user
|
|
6
6
|
* identifier. Server renders have no document, so they get none instead of sharing one per isolate.
|
|
@@ -8,7 +8,7 @@ import { HttpClient, HttpClientError } from "effect/unstable/http";
|
|
|
8
8
|
export declare const browserPageId: () => string | undefined;
|
|
9
9
|
/** Safe event shared with the host's error reporter and product analytics. */
|
|
10
10
|
export declare const BrowserOperationFailure: Schema.Struct<{
|
|
11
|
-
readonly error_type: Schema.Literals<readonly ["BrowserDecodeFailed", "BrowserTransportFailed", "BrowserOperationFailed"]>;
|
|
11
|
+
readonly error_type: Schema.Literals<readonly ["BrowserDecodeFailed", "BrowserConnectionFailed", "BrowserTransportFailed", "BrowserOperationFailed"]>;
|
|
12
12
|
readonly trace_id: Schema.String;
|
|
13
13
|
readonly span_id: Schema.String;
|
|
14
14
|
readonly page_id: Schema.String;
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
/** Browser-owned Effect telemetry, shared by Promise calls and Atom runtimes. */
|
|
2
2
|
import { Context, Effect, Layer, ManagedRuntime } from "effect";
|
|
3
|
-
import { OtlpExporter } from "effect/
|
|
4
|
-
import { Atom } from "effect/
|
|
3
|
+
import { OtlpExporter } from "effect/observability";
|
|
4
|
+
import { Atom } from "effect/reactivity";
|
|
5
5
|
import type { TelemetryConfig } from "./config.js";
|
|
6
6
|
declare const BrowserTelemetry_base: Context.ServiceClass<BrowserTelemetry, "executor/BrowserTelemetry", {
|
|
7
|
+
/**
|
|
8
|
+
* `load` names the document's initial route without a span: hydration resolves no route
|
|
9
|
+
* change, and first load is measured by the vitals. `start` opens a `ui.navigation` span
|
|
10
|
+
* that the router's next `end` closes or the next `start` interrupts.
|
|
11
|
+
*/
|
|
7
12
|
readonly navigation: (event: {
|
|
8
|
-
readonly type: "start";
|
|
13
|
+
readonly type: "load" | "start";
|
|
9
14
|
readonly path: string;
|
|
10
15
|
} | {
|
|
11
16
|
readonly type: "end";
|
|
@@ -33,8 +33,8 @@ export declare const TelemetryConfig: Schema.Struct<{
|
|
|
33
33
|
export type TelemetryConfig = typeof TelemetryConfig.Type;
|
|
34
34
|
/** Host-only destinations; never copied into an app's invocation telemetry capability. */
|
|
35
35
|
export declare const CurrentTelemetryConfig: Context.Reference<{
|
|
36
|
-
readonly version: string;
|
|
37
36
|
readonly service: string;
|
|
37
|
+
readonly version: string;
|
|
38
38
|
readonly environment: string;
|
|
39
39
|
readonly clock?: "system" | "cloudflare-io" | undefined;
|
|
40
40
|
readonly traces?: {
|
|
@@ -59,8 +59,8 @@ export declare const CurrentTelemetryConfig: Context.Reference<{
|
|
|
59
59
|
} | undefined>;
|
|
60
60
|
/** Read OTLP endpoints uniformly for all signals; development chooses which signals to configure. */
|
|
61
61
|
export declare const telemetryConfig: (service: string) => Effect.Effect<{
|
|
62
|
-
readonly version: string;
|
|
63
62
|
readonly service: string;
|
|
63
|
+
readonly version: string;
|
|
64
64
|
readonly environment: string;
|
|
65
65
|
readonly clock?: "system" | "cloudflare-io" | undefined;
|
|
66
66
|
readonly traces?: {
|
|
@@ -5,5 +5,6 @@ export { captureTelemetry, traceHeaders, withRemoteSpan, invocationFetch, type I
|
|
|
5
5
|
export { collectTelemetry, forwardTelemetry, makeTelemetryForwarder, TelemetryBatch, } from "./relay.js";
|
|
6
6
|
export { TraceContext, currentTraceContext, externalTrace, traceLinks } from "./trace-context.js";
|
|
7
7
|
export { pendingSpan } from "./pending-span.js";
|
|
8
|
+
export { makeOwnershipAccounting, measuredSpan, owned, ownedBy, ownerAttribute, type Owner, type SpanMeasure, } from "./ownership.js";
|
|
8
9
|
export { recordWorkerMeasurements } from "./measurements.js";
|
|
9
|
-
export { allowlistedSpans, httpSpanAttributeAllowlist, spanAttributeAllowed, } from "./span-attributes.js";
|
|
10
|
+
export { allowlistedSpans, httpSpanAttributeAllowlist, recordRoute, routeTemplates, spanAttributeAllowed, } from "./span-attributes.js";
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
/** Portable Effect exporters. The host owns scope and export lifetime. */
|
|
2
|
-
import { Layer, Logger } from "effect";
|
|
2
|
+
import { type Duration, Layer, Logger } from "effect";
|
|
3
3
|
import { type TelemetryConfig } from "./config.js";
|
|
4
|
-
/**
|
|
5
|
-
export
|
|
4
|
+
/** How long each signal's final flush may take when the scope closes. */
|
|
5
|
+
export type ShutdownTimeouts = Partial<Record<"traces" | "logs" | "metrics", Duration.Input>>;
|
|
6
|
+
/**
|
|
7
|
+
* Build one tracer per runtime. Event mode defers export until Worker scope finalization.
|
|
8
|
+
* A signal's final flush gets three seconds unless `shutdownTimeouts` names its own bound; only
|
|
9
|
+
* the host that owns a destination knows it answers faster.
|
|
10
|
+
*/
|
|
11
|
+
export declare const telemetryLayer: (config: TelemetryConfig, lifetime?: "process" | "event", logger?: Logger.Logger<unknown, void>, shutdownTimeouts?: ShutdownTimeouts) => Layer.Layer<import("effect/observability/OtlpExporter").Flusher, never, never>;
|
|
6
12
|
/** Node/local entry points resolve telemetry once and share it for their process lifetime. */
|
|
7
|
-
export declare const telemetryFromConfig: (service: string) => Layer.Layer<import("effect/
|
|
13
|
+
export declare const telemetryFromConfig: (service: string) => Layer.Layer<import("effect/observability/OtlpExporter").Flusher, import("effect/Schema").SchemaError | import("effect/Config").ConfigError, never>;
|
|
@@ -3,6 +3,6 @@ import { Effect } from "effect";
|
|
|
3
3
|
/** Classify URLs into a fixed set before attaching attributes; raw paths and query strings are never labels. */
|
|
4
4
|
export declare const recordResponseReady: (path: string | undefined, method: string, status: number, milliseconds: number) => Effect.Effect<void, never, never>;
|
|
5
5
|
/** Fixed failure metadata goes to both local/native logs and the metric registry, even when the remote exporter is down. */
|
|
6
|
-
export declare const recordExportFailure: (path: string, reason
|
|
6
|
+
export declare const recordExportFailure: (path: string, reason: "transport" | "interrupted" | "partial-success" | "capacity" | "acknowledgement" | "timeout" | "relay" | "shutdown", records?: number) => Effect.Effect<void, never, never>;
|
|
7
7
|
/** Record provider-owned invocation totals separately from response-ready timing. */
|
|
8
8
|
export declare const recordWorkerMeasurements: (worker: string, outcome: string, cpu: number, wall: number) => Effect.Effect<void, never, never>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who a span's work belongs to, and how a measured span's time divides among them. A span that
|
|
3
|
+
* starts work for someone other than its caller declares the owner with `ownedBy`; any other span
|
|
4
|
+
* works for whoever its parent works for. Each instant then belongs to the innermost boundary in
|
|
5
|
+
* progress, so Executor's work inside an upstream session stays Executor's, and an app's callback
|
|
6
|
+
* inside Executor's cache stays the app's. Background work is the exception: everything inside it
|
|
7
|
+
* is background, and it runs beside its caller rather than inside it. It takes no instant from the
|
|
8
|
+
* caller's window; how long it ran within the window is reported beside the division.
|
|
9
|
+
*
|
|
10
|
+
* Workers clocks advance only on I/O, so durations are comparable within one isolate and not across
|
|
11
|
+
* isolates: each isolate measures its own part, and the spans that already bracket the work define
|
|
12
|
+
* it, so the accounting and the trace agree.
|
|
13
|
+
*/
|
|
14
|
+
import { Context, Effect, Tracer } from "effect";
|
|
15
|
+
/**
|
|
16
|
+
* Executor's own work; the app's authored code; waiting on an upstream provider; waiting on a
|
|
17
|
+
* person's answer; waiting on another call that holds the lease to load a cache entry; or work
|
|
18
|
+
* handed to the background, such as refreshing a stale cache entry, that no caller waits on.
|
|
19
|
+
*/
|
|
20
|
+
export type Owner = "executor" | "app" | "upstream" | "person" | "lease" | "background";
|
|
21
|
+
/** The attribute that shows a boundary's owner in the trace; the telemetry tracer sets it. */
|
|
22
|
+
export declare const ownerAttribute = "executor.owner";
|
|
23
|
+
/** The owner a span declared when it started, if it is an ownership boundary. */
|
|
24
|
+
export declare const declaredOwner: (annotations: Context.Context<never>) => Owner | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Options for a span whose work belongs to `owner`. Every ownership boundary uses them, at the point
|
|
27
|
+
* the work starts: provider requests and sessions are the upstream's, Executor's services called by
|
|
28
|
+
* an app are Executor's, an app's callbacks are the app's, and waiting for an answer is the person's.
|
|
29
|
+
*/
|
|
30
|
+
export declare const ownedBy: (owner: Owner, options?: Tracer.SpanOptionsNoTrace) => Tracer.SpanOptionsNoTrace;
|
|
31
|
+
/** Run `effect` in span `name`, owned by `owner`. */
|
|
32
|
+
export declare const owned: (owner: Owner, name: string, options?: Tracer.SpanOptionsNoTrace) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Tracer.ParentSpan>>;
|
|
33
|
+
/** What a measured span does with its work and its end. */
|
|
34
|
+
export interface SpanMeasure {
|
|
35
|
+
/** Wraps the work inside the span, for example to observe the spans it opens. */
|
|
36
|
+
readonly around?: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
37
|
+
/** Receives the span's end, before the span ends, to record what it measured on it. */
|
|
38
|
+
readonly end: (end: bigint, span: Tracer.Span) => void;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Run `effect` in span `name`, measured by `measure` from the span's own start to its own end, so
|
|
42
|
+
* the span's duration and the measurement share both boundaries.
|
|
43
|
+
*/
|
|
44
|
+
export declare const measuredSpan: (name: string, options: Tracer.SpanOptionsNoTrace, measure: (start: bigint) => SpanMeasure) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Tracer.ParentSpan>>;
|
|
45
|
+
/**
|
|
46
|
+
* Divide a window that starts at `origin`, whose own work is `owner`'s, among owners. At each
|
|
47
|
+
* instant, the work in progress is the innermost span of each branch: a span with no child still
|
|
48
|
+
* open. Its owner takes the instant. With nothing open inside the window, `owner` takes it. Spans
|
|
49
|
+
* are counted as they open and end, in constant time each, and only spans still open are kept.
|
|
50
|
+
* `background` is not part of the division: it is how long background work was in progress.
|
|
51
|
+
*/
|
|
52
|
+
export declare const makeOwnershipAccounting: (origin: bigint, owner: Owner) => {
|
|
53
|
+
/** Run `effect` with the spans it opens observed, including spans it hands to later work. */
|
|
54
|
+
observe: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
55
|
+
/**
|
|
56
|
+
* Close the window at `end` and return its milliseconds by owner, each instant counted once.
|
|
57
|
+
* Spans still open count up to `end`; spans that open or end afterwards are ignored.
|
|
58
|
+
*/
|
|
59
|
+
read: (end: bigint) => Readonly<Record<Owner, number>>;
|
|
60
|
+
};
|