apps 1.0.0-beta.3 → 2.0.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/README.md +10 -48
  2. package/check-publish.mjs +7 -0
  3. package/package.json +27 -56
  4. package/src/Access.ts +37 -0
  5. package/src/Accounts.ts +468 -0
  6. package/src/App.ts +11 -0
  7. package/src/Ask.ts +156 -0
  8. package/src/Changes.ts +13 -0
  9. package/src/Http.ts +30 -0
  10. package/src/Provider.ts +146 -0
  11. package/src/Session.ts +52 -0
  12. package/src/Settings.ts +164 -0
  13. package/src/contract.ts +852 -0
  14. package/src/css-modules.d.ts +2 -0
  15. package/src/desktop/Desktop.ts +192 -0
  16. package/src/desktop/bridge.ts +62 -0
  17. package/src/desktop/errors.ts +88 -0
  18. package/src/desktop/index.ts +15 -0
  19. package/src/entry.ts +48 -0
  20. package/src/index.ts +16 -4
  21. package/src/internal/defects.ts +62 -0
  22. package/src/internal/files.ts +369 -0
  23. package/src/internal/host.ts +17 -0
  24. package/src/internal/query.ts +114 -0
  25. package/src/internal/records.ts +838 -0
  26. package/src/internal/retention.ts +87 -0
  27. package/src/internal/retries.ts +185 -0
  28. package/src/internal/telemetry.ts +167 -0
  29. package/src/migrations.ts +110 -0
  30. package/src/page/Accounts.ts +27 -0
  31. package/src/page/Changes.ts +126 -0
  32. package/src/page/Session.ts +46 -0
  33. package/src/page/client.ts +107 -0
  34. package/src/page/errors.ts +15 -0
  35. package/src/page/http.ts +21 -0
  36. package/src/page/index.ts +18 -0
  37. package/src/page/paths.ts +22 -0
  38. package/src/providers/anthropic.ts +26 -0
  39. package/src/providers/github.ts +49 -0
  40. package/src/providers/google.ts +67 -0
  41. package/src/providers/openai.ts +62 -0
  42. package/src/providers/slack.ts +81 -0
  43. package/src/runtime.ts +1540 -0
  44. package/src/testing.ts +660 -0
  45. package/src/text-modules.d.ts +5 -0
  46. package/src/theme.css +50 -0
  47. package/dist/authoring/index.d.ts +0 -393
  48. package/dist/authoring/index.js +0 -36
  49. package/dist/chunk-4OZFMCTT.js +0 -17
  50. package/dist/chunk-A3H32P2J.js +0 -143
  51. package/dist/chunk-B7NEUIJL.js +0 -14
  52. package/dist/chunk-F7GZYEAC.js +0 -41
  53. package/dist/chunk-MUFMJRXR.js +0 -308
  54. package/dist/chunk-S5KFP4JQ.js +0 -20
  55. package/dist/chunk-Y6LLTN7W.js +0 -99
  56. package/dist/chunk-YUZ4TXOY.js +0 -27
  57. package/dist/http/index.d.ts +0 -9
  58. package/dist/http/index.js +0 -6
  59. package/dist/index.d.ts +0 -4
  60. package/dist/index.js +0 -48
  61. package/dist/manifest/contract.d.ts +0 -63
  62. package/dist/manifest/contract.js +0 -8
  63. package/dist/manifest/index.d.ts +0 -20
  64. package/dist/manifest/index.js +0 -16
  65. package/dist/mcp/client.d.ts +0 -9
  66. package/dist/mcp/index.d.ts +0 -11
  67. package/dist/mcp/index.js +0 -7
  68. package/dist/openapi/index.d.ts +0 -14
  69. package/dist/openapi/index.js +0 -7
  70. package/dist/openapi/mapper.d.ts +0 -7
  71. package/dist/runner/index.d.ts +0 -4
  72. package/dist/runner/index.js +0 -66
  73. package/dist/runner/protocol.d.ts +0 -33
  74. package/dist/runner/protocol.js +0 -8
  75. package/dist/runtime/index.d.ts +0 -83
  76. package/dist/runtime/index.js +0 -12
  77. package/dist/workerd/index.d.ts +0 -7
  78. package/dist/workerd/index.js +0 -10
  79. package/src/authoring/index.ts +0 -658
  80. package/src/http/index.ts +0 -26
  81. package/src/manifest/contract.ts +0 -64
  82. package/src/manifest/index.ts +0 -156
  83. package/src/mcp/client.ts +0 -59
  84. package/src/mcp/index.ts +0 -42
  85. package/src/openapi/index.ts +0 -70
  86. package/src/openapi/mapper.ts +0 -25
  87. package/src/runner/index.ts +0 -80
  88. package/src/runner/protocol.ts +0 -54
  89. package/src/runtime/index.ts +0 -550
  90. package/src/workerd/index.ts +0 -17
@@ -1,9 +0,0 @@
1
- /** Stub-contract MCP client used by the fromMCP dynamic pair. */
2
- import type { AuthComposeFn, DiscoveredToolSpec, OperationSelection } from "../authoring/index";
3
- /** Normalize authored placement, or apply MCP's bearer default. */
4
- export declare const composePlacement: (auth: AuthComposeFn<never> | undefined, ctx: unknown) => {
5
- headers: Headers;
6
- searchParams: URLSearchParams;
7
- };
8
- export declare const mcpDiscover: (_endpoint: string, _ctx: unknown, _auth: AuthComposeFn<never> | undefined, _operations: OperationSelection | undefined) => Promise<readonly DiscoveredToolSpec[]>;
9
- export declare const mcpCall: (_endpoint: string, _tool: string, _input: unknown, _ctx: unknown, _auth: AuthComposeFn<never> | undefined) => Promise<unknown>;
@@ -1,11 +0,0 @@
1
- /** fromMCP sugar over the authored dynamic-tools primitive. */
2
- import { type AuthComposeFn, type DynamicToolSet, type OperationSelection, type Requirement } from "../authoring/index";
3
- export type FromMCPOptions<Reqs extends Readonly<Record<string, Requirement>>> = {
4
- readonly requirements: Reqs;
5
- readonly auth?: AuthComposeFn<NoInfer<Reqs>>;
6
- readonly operations?: OperationSelection;
7
- };
8
- export declare function fromMCP<const Reqs extends Readonly<Record<string, Requirement>>>(endpoint: string, options: FromMCPOptions<Reqs>): DynamicToolSet;
9
- export declare function fromMCP(endpoint: string, options?: {
10
- readonly operations?: OperationSelection;
11
- }): DynamicToolSet;
package/dist/mcp/index.js DELETED
@@ -1,7 +0,0 @@
1
- import {
2
- fromMCP
3
- } from "../chunk-YUZ4TXOY.js";
4
- import "../chunk-A3H32P2J.js";
5
- export {
6
- fromMCP
7
- };
@@ -1,14 +0,0 @@
1
- /** fromOpenAPI sugar over the authored dynamic-tools primitive. */
2
- import { type AuthComposeFn, type DynamicToolSet, type OperationSelection, type Requirement, type RequiresAuthCompose } from "../authoring/index";
3
- export type FromOpenAPIOptions<Reqs extends Readonly<Record<string, Requirement>>> = {
4
- readonly requirements: Reqs;
5
- readonly auth?: AuthComposeFn<NoInfer<Reqs>>;
6
- readonly operations?: OperationSelection;
7
- } & (RequiresAuthCompose<Reqs> extends true ? {
8
- readonly auth: AuthComposeFn<NoInfer<Reqs>>;
9
- } : unknown);
10
- export type OpenAPIDocumentInput = string | Readonly<Record<string, unknown>>;
11
- export declare function fromOpenAPI<const Reqs extends Readonly<Record<string, Requirement>>>(spec: OpenAPIDocumentInput, options: FromOpenAPIOptions<Reqs>): DynamicToolSet;
12
- export declare function fromOpenAPI(spec: OpenAPIDocumentInput, options?: {
13
- readonly operations?: OperationSelection;
14
- }): DynamicToolSet;
@@ -1,7 +0,0 @@
1
- import {
2
- fromOpenAPI
3
- } from "../chunk-F7GZYEAC.js";
4
- import "../chunk-A3H32P2J.js";
5
- export {
6
- fromOpenAPI
7
- };
@@ -1,7 +0,0 @@
1
- /** Stub-contract OpenAPI discovery and call mapper. */
2
- import type { AuthComposeFn, DiscoveredToolSpec, OperationSelection } from "../authoring/index";
3
- export declare const openapiDiscover: (_spec: string | Readonly<Record<string, unknown>>, _ctx: unknown, _auth: AuthComposeFn<never> | undefined, _operations: OperationSelection | undefined) => Promise<readonly DiscoveredToolSpec[]>;
4
- export declare const openapiCall: (_tool: {
5
- readonly name: string;
6
- readonly detail: unknown;
7
- }, _input: unknown, _ctx: unknown, _auth: AuthComposeFn<never> | undefined) => Promise<unknown>;
@@ -1,4 +0,0 @@
1
- import { type AppRunner } from "./protocol";
2
- export * from "./protocol";
3
- /** Creates a permissive in-process runner for local development and tests. */
4
- export declare const localRunner: (appDir: string) => AppRunner;
@@ -1,66 +0,0 @@
1
- import {
2
- loadApp
3
- } from "../chunk-Y6LLTN7W.js";
4
- import {
5
- callTool,
6
- discoverTool
7
- } from "../chunk-MUFMJRXR.js";
8
- import "../chunk-B7NEUIJL.js";
9
- import {
10
- CallError,
11
- DiscoverError
12
- } from "../chunk-4OZFMCTT.js";
13
- import "../chunk-A3H32P2J.js";
14
-
15
- // src/runner/index.ts
16
- import { Effect } from "effect";
17
- var localRunner = (appDir) => {
18
- let cachedLoad;
19
- const loaded = () => Effect.suspend(() => {
20
- if (cachedLoad !== void 0) return cachedLoad;
21
- return Effect.flatMap(
22
- Effect.cached(loadApp(appDir)),
23
- (effect) => Effect.sync(() => {
24
- cachedLoad = effect;
25
- return effect;
26
- }).pipe(Effect.flatten)
27
- );
28
- });
29
- const registryFor = (target) => loaded().pipe(
30
- Effect.map(({ registry }) => registry),
31
- Effect.mapError(
32
- (error) => new CallError({
33
- target,
34
- kind: "handler",
35
- reason: `app failed to load (${error.message})`
36
- })
37
- )
38
- );
39
- const settle = (target, outcome) => outcome.ok ? Effect.succeed(outcome.value) : Effect.fail(new CallError({
40
- target,
41
- kind: outcome.kind,
42
- reason: outcome.reason
43
- }));
44
- const settleDiscovery = (segment, outcome) => outcome.ok ? Effect.succeed(outcome.value) : Effect.fail(new DiscoverError({ segment, reason: outcome.reason }));
45
- return {
46
- manifest: () => Effect.map(loaded(), ({ result }) => result),
47
- call: (address, input, ctx, detail) => registryFor(address).pipe(
48
- Effect.flatMap(
49
- (registry) => Effect.promise(() => callTool(registry, address, input, ctx, detail))
50
- ),
51
- Effect.flatMap((outcome) => settle(address, outcome))
52
- ),
53
- discover: (segment, ctx) => registryFor(segment).pipe(
54
- Effect.mapError((error) => new DiscoverError({ segment, reason: error.reason })),
55
- Effect.flatMap(
56
- (registry) => Effect.promise(() => discoverTool(registry, segment, ctx))
57
- ),
58
- Effect.flatMap((outcome) => settleDiscovery(segment, outcome))
59
- )
60
- };
61
- };
62
- export {
63
- CallError,
64
- DiscoverError,
65
- localRunner
66
- };
@@ -1,33 +0,0 @@
1
- import { type Effect, FileSystem } from "effect";
2
- import type { AppManifestResult, PublishError } from "../manifest/contract";
3
- import type { CallFailureKind, DiscoveredTool, ToolCtx } from "../runtime/index";
4
- export type { DiscoveredTool, ToolCtx, ToolCtxEntry, ToolDescriptor, } from "../runtime/index";
5
- /** Which invocation phase failed. */
6
- export type CallErrorKind = CallFailureKind;
7
- declare const CallError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
8
- readonly _tag: "CallError";
9
- } & Readonly<A>;
10
- /** A runner operation failure associated with its target and phase. */
11
- export declare class CallError extends CallError_base<{
12
- readonly target: string;
13
- readonly kind: CallErrorKind;
14
- readonly reason: string;
15
- }> {
16
- get message(): string;
17
- }
18
- declare const DiscoverError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
19
- readonly _tag: "DiscoverError";
20
- } & Readonly<A>;
21
- /** A discovery failure associated with one dynamic segment. */
22
- export declare class DiscoverError extends DiscoverError_base<{
23
- readonly segment: string;
24
- readonly reason: string;
25
- }> {
26
- get message(): string;
27
- }
28
- /** The platform protocol implemented by an app execution environment. */
29
- export interface AppRunner {
30
- manifest(): Effect.Effect<AppManifestResult, PublishError, FileSystem.FileSystem>;
31
- call(address: string, input: unknown, ctx: ToolCtx, detail?: unknown): Effect.Effect<unknown, CallError, FileSystem.FileSystem>;
32
- discover(segment: string, ctx: ToolCtx): Effect.Effect<readonly DiscoveredTool[], DiscoverError, FileSystem.FileSystem>;
33
- }
@@ -1,8 +0,0 @@
1
- import {
2
- CallError,
3
- DiscoverError
4
- } from "../chunk-4OZFMCTT.js";
5
- export {
6
- CallError,
7
- DiscoverError
8
- };
@@ -1,83 +0,0 @@
1
- /**
2
- * The execution core: everything that happens after authored modules
3
- * load, in any environment. Project a registry into its deterministic
4
- * manifest, validate a call's input, run the handler, shape the
5
- * outcome. There is exactly one implementation of this logic; the
6
- * local runner and the sandboxed workerd guest are both thin doors
7
- * onto this module.
8
- *
9
- * Deliberately dependency-free (no effect, no node builtins): this
10
- * module bundles into sandboxed guests, where every dependency is
11
- * paid on each cold start. Digesting uses WebCrypto, which node, bun,
12
- * and workerd all provide.
13
- */
14
- import type { Registry } from "../authoring/index";
15
- import type { AppManifestResult, JsonSchemaObject } from "../manifest/contract";
16
- /** The capability exposed to one tool requirement role. */
17
- export interface ToolCtxEntry {
18
- readonly grant: string;
19
- readonly kind: "bearer" | "basic" | "secrets" | "oauth";
20
- readonly token?: string;
21
- readonly username?: string;
22
- readonly password?: string;
23
- readonly secrets?: Readonly<Record<string, string>>;
24
- fetch(path: string, init?: RequestInit): Promise<Response>;
25
- }
26
- /** Tool capabilities keyed by requirement role. */
27
- export type ToolCtx = Readonly<Record<string, ToolCtxEntry>>;
28
- /** A manifest projection: the app's deterministic description, or why not. */
29
- export type ManifestOutcome = {
30
- readonly ok: true;
31
- readonly result: AppManifestResult;
32
- } | {
33
- readonly ok: false;
34
- readonly problems: readonly string[];
35
- };
36
- /** Which invocation phase failed. */
37
- export type CallFailureKind = "input" | "handler";
38
- /** One tool invocation's result envelope. */
39
- export type CallOutcome = {
40
- readonly ok: true;
41
- readonly value: unknown;
42
- } | {
43
- readonly ok: false;
44
- readonly kind: CallFailureKind;
45
- readonly reason: string;
46
- };
47
- /** Agent-facing descriptor compiled from one discovery result. */
48
- export interface ToolDescriptor {
49
- readonly description: string;
50
- readonly inputSchema: JsonSchemaObject;
51
- readonly annotations: {
52
- readonly readOnly?: boolean;
53
- readonly destructive?: boolean;
54
- };
55
- }
56
- /** One tool emitted by a dynamic segment discovery. */
57
- export interface DiscoveredTool {
58
- readonly segment: string;
59
- readonly name: string;
60
- readonly descriptor: ToolDescriptor;
61
- readonly detail: unknown;
62
- }
63
- /** One dynamic discovery result envelope. */
64
- export type DiscoverOutcome = {
65
- readonly ok: true;
66
- readonly value: readonly DiscoveredTool[];
67
- } | {
68
- readonly ok: false;
69
- readonly reason: string;
70
- };
71
- type InputSchemaCompilation = {
72
- readonly value: JsonSchemaObject;
73
- } | {
74
- readonly problem: string;
75
- };
76
- export declare const compileInputSchema: (input: object, where: string) => InputSchemaCompilation;
77
- /** Project a loaded registry into the app's deterministic manifest. */
78
- export declare const manifestOf: (registry: Registry) => Promise<ManifestOutcome>;
79
- /** Validate input and run one static or dynamic tool handler. */
80
- export declare const callTool: (registry: Registry, address: string, input: unknown, ctx: ToolCtx, detail?: unknown) => Promise<CallOutcome>;
81
- /** Discover and compile one dynamic segment. */
82
- export declare const discoverTool: (registry: Registry, segment: string, ctx: ToolCtx) => Promise<DiscoverOutcome>;
83
- export {};
@@ -1,12 +0,0 @@
1
- import {
2
- callTool,
3
- compileInputSchema,
4
- discoverTool,
5
- manifestOf
6
- } from "../chunk-MUFMJRXR.js";
7
- export {
8
- callTool,
9
- compileInputSchema,
10
- discoverTool,
11
- manifestOf
12
- };
@@ -1,7 +0,0 @@
1
- /**
2
- * The execution core re-exported for sandboxed guests. A generated
3
- * guest module imports the authored files (filling the registry) and
4
- * exposes these verbs over RPC; the logic itself lives in ../runtime
5
- * and is identical to what the local runner executes. @internal
6
- */
7
- export { callTool, discoverTool, manifestOf, type CallOutcome, type DiscoverOutcome, type DiscoveredTool, type ManifestOutcome, type ToolCtx, type ToolCtxEntry, } from "../runtime/index";
@@ -1,10 +0,0 @@
1
- import {
2
- callTool,
3
- discoverTool,
4
- manifestOf
5
- } from "../chunk-MUFMJRXR.js";
6
- export {
7
- callTool,
8
- discoverTool,
9
- manifestOf
10
- };