apps 0.0.1-beta.1 → 0.0.1-beta.3

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 (58) hide show
  1. package/framework-reference.json +1 -1
  2. package/js/browser-XIPJGLH2.js +65 -0
  3. package/js/{chunk-6YBRWRK3.js → chunk-5MQZEB6Y.js} +16 -4
  4. package/js/chunk-D47C7KG5.js +172 -0
  5. package/js/{chunk-ZTFQHGEB.js → chunk-FDNTX5QJ.js} +1 -3
  6. package/js/{chunk-OHRT55C4.js → chunk-G7ZIRKMK.js} +0 -3
  7. package/js/{chunk-G7IE6BKC.js → chunk-HDTGZWP2.js} +2 -2
  8. package/js/{chunk-KOXMLKTM.js → chunk-J7O55ZV7.js} +20 -148
  9. package/js/{chunk-RBAC33PQ.js → chunk-JN55AYQH.js} +3 -57
  10. package/js/chunk-LGIYBDWA.js +85 -0
  11. package/js/{chunk-IHQ4ML7K.js → chunk-MYYEW3RA.js} +130 -86
  12. package/js/chunk-NQ3OMCA5.js +39 -0
  13. package/js/{chunk-PZ36XMXW.js → chunk-PYUYJRSK.js} +1 -1
  14. package/js/{chunk-X7SFGU4Q.js → chunk-RN2MXB4R.js} +4 -4
  15. package/js/{chunk-4LPG6RCH.js → chunk-T2LAZCAD.js} +4 -24
  16. package/js/{chunk-NCYXZN2G.js → chunk-UVL56Z6E.js} +390 -23
  17. package/js/{chunk-2HHMABB6.js → chunk-WFSQXYUT.js} +46 -10
  18. package/js/{chunk-6IIO4NPI.js → chunk-Z5NMEGJN.js} +1 -1
  19. package/js/client.js +2 -2
  20. package/js/contracts.js +8 -1
  21. package/js/effect.js +8 -7
  22. package/js/es-APDZKREY.js +40968 -0
  23. package/js/graphql.js +10 -9
  24. package/js/host.js +12 -11
  25. package/js/index.js +7 -5
  26. package/js/mcp/effect.js +10 -9
  27. package/js/mcp/stdio.js +10 -9
  28. package/js/mcp.js +12 -11
  29. package/js/openapi.js +776 -41590
  30. package/js/skills/effect.js +1 -2
  31. package/js/skills.js +47 -10
  32. package/js/ui/auth/contracts.js +7 -8
  33. package/js/ui/auth.js +13 -11
  34. package/js/ui/contracts.js +1 -1
  35. package/js/ui/serving.js +3 -2
  36. package/package.json +1 -1
  37. package/runtime.json +1 -1
  38. package/types/app-cache/src/contracts/cache.d.ts +42 -2
  39. package/types/app-cache/src/index.d.ts +59 -1
  40. package/types/apps/src/contracts/cache.d.ts +4 -1
  41. package/types/apps/src/contracts/host.d.ts +8 -672
  42. package/types/apps/src/contracts/openapi.d.ts +6 -0
  43. package/types/apps/src/contracts/protocol-version.d.ts +6 -0
  44. package/types/apps/src/contracts/protocols/1.d.ts +1575 -0
  45. package/types/apps/src/contracts/skills.d.ts +17 -8
  46. package/types/apps/src/contracts/ui-auth.d.ts +6 -14
  47. package/types/apps/src/implementation/cache.d.ts +3 -1
  48. package/types/apps/src/implementation/openapi-compile.d.ts +1 -1
  49. package/types/apps/src/implementation/openapi-document.d.ts +0 -2
  50. package/types/apps/src/implementation/openapi-names.d.ts +18 -0
  51. package/types/apps/src/implementation/openapi-request.d.ts +0 -1
  52. package/types/apps/src/implementation/openapi-source.d.ts +5 -1
  53. package/types/apps/src/implementation/schema.d.ts +0 -5
  54. package/types/apps/src/implementation/swagger-client.d.ts +28 -0
  55. package/types/apps/src/implementation/ui-auth.d.ts +11 -5
  56. package/types/apps/src/skills.d.ts +6 -3
  57. package/types/apps/src/ui-auth.d.ts +2 -2
  58. package/js/chunk-TE4KO4HI.js +0 -47
@@ -90,19 +90,28 @@ export interface SkillTransport {
90
90
  export interface SkillReaderOptions extends SkillTransport {
91
91
  readonly service: string;
92
92
  }
93
- /** A public GitHub repository and an optional immutable commit, tag or branch. */
94
- export interface GitHubSkillsOptions extends SkillTransport {
93
+ /**
94
+ * Catalog reuse shared by remote skill loaders, with the same policy as MCP tool catalogs. Pass
95
+ * `ctx.cache` to keep the loaded catalog; without it every read fetches the source again.
96
+ */
97
+ export interface SkillCacheOptions {
98
+ readonly cache?: import("./cache.js").AppCache;
99
+ /** Reuse the catalog for this duration. Defaults to five minutes. */
100
+ readonly freshFor?: import("effect").Duration.Input;
101
+ /** Serve the retained catalog while refreshing. Defaults to one day. */
102
+ readonly staleFor?: import("effect").Duration.Input;
103
+ }
104
+ /**
105
+ * A public GitHub repository and an optional immutable commit, tag or branch. With a cache, a
106
+ * branch or tag is resolved again when the catalog refreshes, and each commit's file list is kept.
107
+ */
108
+ export interface GitHubSkillsOptions extends SkillTransport, SkillCacheOptions {
95
109
  readonly repo: string;
96
110
  readonly path?: string;
97
111
  readonly ref?: string;
98
- /**
99
- * Pass `ctx.cache` to keep each commit's skill file list. Content at a commit never changes,
100
- * so later reads of the same commit skip the tree fetch. The ref is still resolved each read.
101
- */
102
- readonly cache?: import("./cache.js").AppCache;
103
112
  }
104
113
  /** A published directory index, including its listed skill documents and text references. */
105
- export interface WellKnownSkillsOptions extends SkillTransport {
114
+ export interface WellKnownSkillsOptions extends SkillTransport, SkillCacheOptions {
106
115
  readonly url: string;
107
116
  }
108
117
  /** A folder in the deployed package; omitted path selects skills/. No host filesystem access. */
@@ -1,7 +1,5 @@
1
1
  /** Browser authentication protocol. Identity and session storage belong to the host. */
2
2
  import { Schema } from "effect";
3
- import { HttpApi, HttpApiEndpoint, HttpApiGroup } from "effect/unstable/httpapi";
4
- import { UiFailed, UiForbidden, UiUnauthorized } from "./ui.js";
5
3
  /** Opaque correlation ID; possession alone does not authorize an app session. */
6
4
  export declare const AppSignInId: Schema.brand<Schema.String, "AppSignInId">;
7
5
  export type AppSignInId = typeof AppSignInId.Type;
@@ -10,19 +8,13 @@ export declare const AppSignInCode: Schema.RedactedFromValue<Schema.String>;
10
8
  /** A path on the current app origin, including its query and fragment; never a redirect to another host or host-owned route. */
11
9
  export declare const AppReturnPath: Schema.brand<Schema.String, "AppReturnPath">;
12
10
  export type AppReturnPath = typeof AppReturnPath.Type;
13
- /** The trusted callback exchanges an authorization code bound to a browser attempt. */
11
+ /** Callback query on the app origin. The code is single-use and works only with its attempt's cookie. */
14
12
  export declare const AppSignInCallback: Schema.Struct<{
15
13
  readonly request: Schema.brand<Schema.String, "AppSignInId">;
16
14
  readonly code: Schema.RedactedFromValue<Schema.String>;
17
15
  }>;
18
- /** Host-owned endpoints on every app origin, independent of the product's login mechanism. */
19
- export declare const AppSignInApi: HttpApi.HttpApi<"app-sign-in", HttpApiGroup.HttpApiGroup<"appSignIn", HttpApiEndpoint.HttpApiEndpoint<"start", "POST", "/_executor/auth/start", never, never, Schema.toCodecJson<Schema.Struct<{
20
- readonly returnTo: Schema.brand<Schema.String, "AppReturnPath">;
21
- }>>, never, Schema.toCodecJson<Schema.Struct<{
22
- readonly url: Schema.String;
23
- }>>, Schema.toCodecJson<typeof UiForbidden | typeof UiFailed>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"complete", "POST", "/_executor/auth/complete", never, never, Schema.toCodecJson<Schema.Struct<{
24
- readonly request: Schema.brand<Schema.String, "AppSignInId">;
25
- readonly code: Schema.RedactedFromValue<Schema.String>;
26
- }>>, never, Schema.toCodecJson<Schema.Struct<{
27
- readonly returnTo: Schema.brand<Schema.String, "AppReturnPath">;
28
- }>>, Schema.toCodecJson<typeof UiUnauthorized | typeof UiForbidden | typeof UiFailed>, never, never>, false>>;
16
+ /** Host-owned callback path on every app origin. */
17
+ export declare const appSignInCallbackPath = "/_executor/auth/callback";
18
+ /** Why the product could not authorize an attempt; the dashboard explains it without retrying. */
19
+ export declare const AppSignInFailure: Schema.Literals<readonly ["ended", "forbidden", "unavailable"]>;
20
+ export type AppSignInFailure = typeof AppSignInFailure.Type;
@@ -3,4 +3,6 @@ import type { ResolvedAccounts } from "../contracts/host.js";
3
3
  /** Missing host support is explicit on use; ordinary apps do not need cache support. */
4
4
  export declare const unavailableCache: HostCache;
5
5
  /** Account scopes are derived from trusted current bindings. Loaders get a fresh owned HTTP signal. */
6
- export declare const authorCache: (host: HostCache, accounts: ResolvedAccounts, signal: AbortSignal) => AppCache;
6
+ export declare const authorCache: (host: HostCache, accounts: ResolvedAccounts, signal: AbortSignal,
7
+ /** The invocation's trusted deadline. Waiting on another caller's load never runs past it. */
8
+ deadline?: number) => AppCache;
@@ -1,7 +1,6 @@
1
1
  /** Compile an OpenAPI document into tool declarations inside the app runtime, never a second execution engine. */
2
2
  import { Effect, Schema } from "effect";
3
3
  import { JsonObject } from "../contracts/schema.js";
4
- import "../contracts/swagger-client.ts";
5
4
  import { OpenapiCompileError as TemplateError } from "../contracts/openapi-compile.js";
6
5
  import type { OpenApiImport } from "../contracts/openapi-document.js";
7
6
  import { type GeneratedOperation, type GeneratedSecrets } from "../contracts/openapi-document.js";
@@ -68,6 +67,7 @@ export declare const compileOpenApiDocument: (entry: OpenApiImport, inputDocumen
68
67
  readonly outputSchema?: {
69
68
  readonly [x: string]: Schema.Json;
70
69
  };
70
+ readonly operationId?: string;
71
71
  readonly streaming?: true;
72
72
  readonly errorResponses?: readonly {
73
73
  readonly code: string;
@@ -1,5 +1,3 @@
1
- /** OpenAPI reference and dialect rules, shared by every part of the app importer. */
2
- import "../contracts/swagger-client.ts";
3
1
  import { Schema } from "effect";
4
2
  import { JsonObject } from "../contracts/schema.js";
5
3
  /** Resolve OpenAPI objects once with Swagger; schemas retain their original recursive references.
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Group generated OpenAPI tool names as `<group>.<leaf>`, ported from Executor v1's tool paths.
3
+ * The group is the first tag, or the first meaningful path segment. The leaf is the operationId
4
+ * without a repeated group prefix, or a method-and-path name when there is no operationId.
5
+ */
6
+ export interface OperationNameInput {
7
+ readonly operationId: string | undefined;
8
+ /** The first non-empty tag. */
9
+ readonly tag: string | undefined;
10
+ readonly method: string;
11
+ readonly path: string;
12
+ }
13
+ /**
14
+ * Plan one name per input, in input order. Names that collide are refined together: first by
15
+ * the path's version segment, then by the HTTP method, then by a stable hash. Refinement only
16
+ * touches the colliding names, so adding an operation never renames an unrelated one.
17
+ */
18
+ export declare const planOperationNames: (inputs: readonly OperationNameInput[]) => string[];
@@ -1,4 +1,3 @@
1
- import "../contracts/swagger-client.ts";
2
1
  import { ProviderError } from "../contracts/provider-error.js";
3
2
  /** Swagger constructs requests; Effect owns HTTP policy and bounded results. */
4
3
  import { Effect, Schema } from "effect";
@@ -2,7 +2,7 @@
2
2
  import { Duration } from "effect";
3
3
  import type { AppCache } from "../contracts/cache.js";
4
4
  import { OpenapiOperation, type OpenapiToolsOptions } from "../contracts/openapi.js";
5
- import { JsonObject, type JsonValue } from "../contracts/schema.js";
5
+ import { JsonObject, JsonValue } from "../contracts/schema.js";
6
6
  import type { DynamicTools } from "../contracts/dynamic-tools.js";
7
7
  import { type OperationKinds } from "./protocol-operations.js";
8
8
  /** Static credential placement and destination are reviewed when the app is authored/imported. */
@@ -18,6 +18,10 @@ export interface OpenapiSourceOptions extends Omit<OpenapiToolsOptions, "operati
18
18
  readonly baseUrl?: string;
19
19
  readonly freshFor?: Duration.Input;
20
20
  readonly staleFor?: Duration.Input;
21
+ /**
22
+ * Query or mutation overrides keyed by the document's operationId. An operation without an
23
+ * operationId is keyed by its generated name without the kind, such as `users.getUsers`.
24
+ */
21
25
  readonly kinds?: OperationKinds;
22
26
  readonly fallbackSecurity?: OpenapiOperation["request"]["security"];
23
27
  readonly patches?: readonly {
@@ -80,11 +80,6 @@ export declare const compileJsonSchemaDecoder: (document: JsonObject) => Effect.
80
80
  readonly [x: string]: EffectSchema.Json;
81
81
  };
82
82
  }, ValidationError, never>;
83
- /**
84
- * Build the document only when a value is first decoded or the schema is described, then
85
- * compile its validator once. Imported apps can share definitions between many schemas
86
- * without making each one self-contained up front.
87
- */
88
83
  export declare const lazyJsonSchemaDecoder: (document: () => JsonObject) => Effect.Effect<EffectSchema.declareConstructor<EffectSchema.Json, EffectSchema.Json, readonly [], EffectSchema.Json>, never, never>;
89
84
  /** Preserve the JSON document; compile its validator only when a value is first decoded. */
90
85
  export declare const jsonSchemaDecoder: (input: unknown) => Effect.Effect<EffectSchema.declareConstructor<EffectSchema.Json, EffectSchema.Json, readonly [], EffectSchema.Json>, ValidationError, never>;
@@ -0,0 +1,28 @@
1
+ /** Swagger is most of the OpenAPI module's code. Discovery from a cached catalog never needs it,
2
+ * so a cold app Worker evaluates it only when it resolves a document or builds a request.
3
+ */
4
+ import "../contracts/swagger-client.ts";
5
+ export type SwaggerClient = typeof import("swagger-client").default;
6
+ export declare const loadSwaggerClient: () => Promise<{
7
+ buildRequest(options: {
8
+ spec: unknown;
9
+ operationId?: string;
10
+ pathName?: string;
11
+ method?: string;
12
+ parameters?: Readonly<Record<string, unknown>>;
13
+ requestBody?: unknown;
14
+ requestContentType?: string;
15
+ securities?: {
16
+ authorized: Readonly<Record<string, unknown>>;
17
+ };
18
+ }): unknown;
19
+ resolve(options: {
20
+ spec: unknown;
21
+ skipNormalization: boolean;
22
+ useCircularStructures: boolean;
23
+ requestInterceptor: () => never;
24
+ }): Promise<{
25
+ spec: unknown;
26
+ errors: readonly unknown[];
27
+ }>;
28
+ }>;
@@ -1,5 +1,6 @@
1
- /** Trusted bootstrap documents run before authored UI and never contain product credentials. */
1
+ /** Host responses around app sign-in. They carry no script and never contain product credentials. */
2
2
  import { HttpServerResponse } from "effect/unstable/http";
3
+ import { type AppSignInId } from "../contracts/ui-auth.js";
3
4
  /** Private app responses must not leak authentication URLs through caches or referrers. */
4
5
  export declare const appPrivateHeaders: {
5
6
  "cache-control": string;
@@ -7,7 +8,12 @@ export declare const appPrivateHeaders: {
7
8
  "x-content-type-options": string;
8
9
  "content-security-policy": string;
9
10
  };
10
- /** Serve only a fixed host script while authentication runs; the original URL remains available to that script. */
11
- export declare const appSignInPage: () => HttpServerResponse.HttpServerResponse;
12
- /** Preserve deep links, erase callback proofs before any request, and let the host set HttpOnly cookies. */
13
- export declare const appSignInScript: () => HttpServerResponse.HttpServerResponse;
11
+ /** Every sign-in hop is a server redirect, so the browser paints nothing until the app itself. */
12
+ export declare const appRedirect: (url: string) => HttpServerResponse.HttpServerResponse;
13
+ /**
14
+ * The callback URL carries the code in its query. It exists only as a redirect `Location`, never as
15
+ * a rendered document, and redeeming it also requires the attempt's HttpOnly cookie.
16
+ */
17
+ export declare const appSignInCallback: (origin: string, request: AppSignInId, code: string) => string;
18
+ /** A failed callback explains itself without script; reopening the app URL starts a new attempt. */
19
+ export declare const appSignInFailed: () => HttpServerResponse.HttpServerResponse;
@@ -1,6 +1,9 @@
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 WellKnownSkillsOptions, } from "./contracts/skills.js";
3
- /** Fetch a public GitHub skill collection from one resolved commit. Mutable refs refresh on each call. */
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";
3
+ /**
4
+ * Fetch a public GitHub skill collection from one resolved commit. Pass `cache: ctx.cache` to reuse
5
+ * the catalog; without it, mutable refs resolve again on each call.
6
+ */
4
7
  export declare const githubSkills: (options: GitHubSkillsOptions) => Promise<readonly {
5
8
  readonly name: string;
6
9
  readonly description: string;
@@ -15,7 +18,7 @@ export declare const githubSkills: (options: GitHubSkillsOptions) => Promise<rea
15
18
  };
16
19
  readonly "allowed-tools"?: string;
17
20
  }[]>;
18
- /** Fetch a published skill index and its text files, with no persistent cache. */
21
+ /** Fetch a published skill index and its text files. Pass `cache: ctx.cache` to reuse the catalog. */
19
22
  export declare const wellKnownSkills: (options: WellKnownSkillsOptions) => Promise<readonly {
20
23
  readonly name: string;
21
24
  readonly description: string;
@@ -1,3 +1,3 @@
1
- /** Host-only app authentication protocol and bootstrap; products supply identity and session lifecycle. */
1
+ /** Host-only app authentication protocol; products supply identity and session lifecycle. */
2
2
  export * from "./contracts/ui-auth.js";
3
- export { appPrivateHeaders, appSignInPage, appSignInScript } from "./implementation/ui-auth.js";
3
+ export { appPrivateHeaders, appRedirect, appSignInCallback, appSignInFailed, } from "./implementation/ui-auth.js";
@@ -1,47 +0,0 @@
1
- import {
2
- HttpServerResponse_exports
3
- } from "./chunk-QKHR7BMF.js";
4
-
5
- // src/implementation/ui-auth.ts
6
- var appPrivateHeaders = {
7
- "cache-control": "no-store",
8
- "referrer-policy": "no-referrer",
9
- "x-content-type-options": "nosniff",
10
- "content-security-policy": "frame-ancestors 'none'"
11
- };
12
- var appSignInPage = () => HttpServerResponse_exports.text(
13
- `<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Opening app</title></head><body><p>Opening app\u2026</p><a href="/" hidden>Try again</a><script src="/_executor/auth/browser.js"></script></body></html>`,
14
- {
15
- contentType: "text/html",
16
- headers: {
17
- ...appPrivateHeaders,
18
- "content-security-policy": "default-src 'none'; script-src 'self'; connect-src 'self'; frame-ancestors 'none'; base-uri 'none'"
19
- }
20
- }
21
- );
22
- var appSignInScript = () => HttpServerResponse_exports.text(
23
- `
24
- const callback = location.pathname === "/_executor/auth/callback";
25
- const parameters = new URLSearchParams(location.hash.slice(1));
26
- const body = callback
27
- ? {request: parameters.get("request"), code: parameters.get("code")}
28
- : {returnTo: location.pathname + location.search + location.hash};
29
- if (callback) history.replaceState(null, "", location.pathname);
30
- fetch(callback ? "/_executor/auth/complete" : "/_executor/auth/start", {
31
- method: "POST", headers: {"content-type":"application/json"}, body: JSON.stringify(body)
32
- }).then(async response => {
33
- if (!response.ok) throw new Error();
34
- const result = await response.json();
35
- location.replace(callback ? result.returnTo : result.url);
36
- }).catch(() => {
37
- document.querySelector("p").textContent = "Could not sign in to this app. Try opening it again.";
38
- document.querySelector("a").hidden = false;
39
- });`,
40
- { contentType: "text/javascript", headers: appPrivateHeaders }
41
- );
42
-
43
- export {
44
- appPrivateHeaders,
45
- appSignInPage,
46
- appSignInScript
47
- };