apps 0.0.1-beta.4 → 0.0.1-beta.5

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 (67) hide show
  1. package/framework-reference.json +1 -1
  2. package/js/{chunk-SATWJKN6.js → chunk-27F7W2LG.js} +1 -1
  3. package/js/{chunk-PYUYJRSK.js → chunk-3XKZDQLM.js} +2 -2
  4. package/js/chunk-4M277YTM.js +136 -0
  5. package/js/{chunk-HDJH3RPR.js → chunk-57RKNWL2.js} +2 -2
  6. package/js/{chunk-EQB7JMAL.js → chunk-67EVWIGJ.js} +8 -8
  7. package/js/{chunk-DHUDODG5.js → chunk-C3VAOK5B.js} +11 -9
  8. package/js/{chunk-FW5HBOIK.js → chunk-CDL5PM2Q.js} +307 -169
  9. package/js/{chunk-D47C7KG5.js → chunk-CYYBFC2K.js} +2 -2
  10. package/js/{chunk-3M2MEDNL.js → chunk-DQAZTA4I.js} +145 -20
  11. package/js/{chunk-WFSQXYUT.js → chunk-FWQC6I3C.js} +2 -2
  12. package/js/{chunk-ZJWDMTE3.js → chunk-G7T27IWB.js} +3 -3
  13. package/js/{chunk-G7ZIRKMK.js → chunk-IJX4CYZO.js} +3 -3
  14. package/js/{chunk-FDNTX5QJ.js → chunk-IPI4MFSN.js} +2 -2
  15. package/js/{chunk-YEJOQEII.js → chunk-JU7VHODU.js} +1 -1
  16. package/js/{chunk-NQ3OMCA5.js → chunk-KUMBKVJD.js} +2 -2
  17. package/js/{chunk-6VRYO2BG.js → chunk-LUVSFETN.js} +235 -58
  18. package/js/{chunk-EVJUVWN2.js → chunk-M3B3DE4K.js} +2 -2
  19. package/js/{chunk-BMOIAIVR.js → chunk-N7YDVXYJ.js} +49 -1
  20. package/js/{chunk-M6ZRRIBI.js → chunk-PJJ24GU7.js} +1 -1
  21. package/js/{chunk-FZJOYIZO.js → chunk-PZB6T6KU.js} +1 -1
  22. package/js/{chunk-ZCAMUXSG.js → chunk-RJDDBDSN.js} +3 -3
  23. package/js/{chunk-W7D7WVSY.js → chunk-SB3V4YVR.js} +2 -2
  24. package/js/{chunk-Z5NMEGJN.js → chunk-TDNYXSIX.js} +1 -1
  25. package/js/{chunk-2VPJHFOU.js → chunk-UDDE5KOR.js} +6 -6
  26. package/js/{chunk-QKHR7BMF.js → chunk-UK573G7W.js} +1 -1
  27. package/js/{chunk-T2LAZCAD.js → chunk-VFZKSM3T.js} +1 -1
  28. package/js/{chunk-SWPD52J7.js → chunk-W4DMKWAB.js} +1 -1
  29. package/js/{chunk-5MQZEB6Y.js → chunk-XHO2ZX6W.js} +4 -4
  30. package/js/{chunk-LGIYBDWA.js → chunk-YEPYT6SD.js} +1 -1
  31. package/js/{chunk-PLCMJREA.js → chunk-ZQINWV4W.js} +60 -20
  32. package/js/client.js +10 -10
  33. package/js/contracts.js +32 -9
  34. package/js/effect.js +21 -20
  35. package/js/graphql.js +23 -22
  36. package/js/host.js +21 -20
  37. package/js/index.js +14 -14
  38. package/js/mcp/effect.js +23 -22
  39. package/js/mcp/stdio.js +23 -22
  40. package/js/mcp.js +25 -24
  41. package/js/openapi.js +23 -123
  42. package/js/react.js +3 -3
  43. package/js/skills/effect.js +3 -3
  44. package/js/skills.js +12 -12
  45. package/js/storage/facet.js +4 -4
  46. package/js/ui/auth/contracts.js +2 -2
  47. package/js/ui/auth.js +5 -5
  48. package/js/ui/contracts.js +4 -4
  49. package/js/ui/serving.js +8 -8
  50. package/package.json +1 -1
  51. package/runtime.json +1 -1
  52. package/types/app-data/src/contracts/database.d.ts +33 -6
  53. package/types/app-data/src/implementation/schema.d.ts +2 -17
  54. package/types/apps/src/contracts/failure.d.ts +25 -0
  55. package/types/apps/src/contracts/host.d.ts +11 -6
  56. package/types/apps/src/contracts/openapi.d.ts +1 -1
  57. package/types/apps/src/contracts/protocol-version.d.ts +2 -2
  58. package/types/apps/src/contracts/protocols/1.d.ts +15 -1
  59. package/types/apps/src/contracts/protocols/2.d.ts +2 -2
  60. package/types/apps/src/contracts/protocols/3.d.ts +676 -0
  61. package/types/apps/src/contracts/storage.d.ts +3 -3
  62. package/types/apps/src/contracts/workflows.d.ts +34 -3
  63. package/types/apps/src/implementation/elicitation.d.ts +1 -1
  64. package/types/apps/src/implementation/failure-detail.d.ts +25 -0
  65. package/types/apps/src/implementation/storage.d.ts +5 -3
  66. package/types/apps/src/implementation/webhooks.d.ts +1 -1
  67. package/types/apps/src/implementation/workflow-context.d.ts +11 -3
@@ -2,7 +2,7 @@
2
2
  import { Schema, type Effect } from "effect";
3
3
  import type { RowMetadata, ReadTable, WriteTable } from "../../../app-data/src/index.js";
4
4
  import type { Fields, ObjectValue } from "../implementation/schema.js";
5
- import type { DatabaseSchema, DatabaseSession, AppDatabaseError } from "../../../app-data/src/contracts/database.js";
5
+ import type { DatabaseSchema, DatabaseSession, DatabaseError } from "../../../app-data/src/contracts/database.js";
6
6
  /** Names for authored operations and tables. */
7
7
  export declare const StorageName: Schema.NonEmptyString;
8
8
  declare const AppStorageUnavailable_base: Schema.Class<AppStorageUnavailable, Schema.TaggedStruct<"AppStorageUnavailable", {}>, import("effect/Cause").YieldableError>;
@@ -15,8 +15,8 @@ export declare class AppStorageError extends AppStorageError_base {
15
15
  }
16
16
  /** The adapter owns the database connection and transaction for the whole authored invocation. */
17
17
  export interface AppStorage {
18
- readonly read: <A, E>(schema: DatabaseSchema, work: (session: DatabaseSession) => Effect.Effect<A, E>) => Effect.Effect<A, E | AppDatabaseError | AppStorageUnavailable | AppStorageError>;
19
- readonly mutate: <A, E>(schema: DatabaseSchema, work: (session: DatabaseSession) => Effect.Effect<A, E>) => Effect.Effect<A, E | AppDatabaseError | AppStorageUnavailable | AppStorageError>;
18
+ readonly read: <A, E>(schema: DatabaseSchema, work: (session: DatabaseSession) => Effect.Effect<A, E>) => Effect.Effect<A, E | DatabaseError | AppStorageUnavailable | AppStorageError>;
19
+ readonly mutate: <A, E>(schema: DatabaseSchema, work: (session: DatabaseSession) => Effect.Effect<A, E>) => Effect.Effect<A, E | DatabaseError | AppStorageUnavailable | AppStorageError>;
20
20
  }
21
21
  type InputValue<F extends Fields> = {
22
22
  readonly [K in keyof F as F[K]["optionalValue"] extends true ? never : F[K] extends {
@@ -24,14 +24,33 @@ export declare const WorkflowStepOptions: Schema.Struct<{
24
24
  readonly timeout: Schema.optionalKey<Schema.Union<readonly [Schema.Finite, Schema.NonEmptyString]>>;
25
25
  }>;
26
26
  export type WorkflowStepOptions = typeof WorkflowStepOptions.Type;
27
+ /**
28
+ * Where and why a run failed: the failing step and the error the app's own code raised, its
29
+ * message bounded and with account secrets replaced. Runs from before these fields existed have none.
30
+ */
31
+ export declare const WorkflowFailureDetail: {
32
+ step: Schema.optionalKey<Schema.String>;
33
+ errorName: Schema.optionalKey<Schema.String>;
34
+ message: Schema.optionalKey<Schema.String>;
35
+ };
36
+ /** A failed run's recorded step and app error. */
37
+ export declare const WorkflowRunFailure: Schema.Struct<{
38
+ step: Schema.optionalKey<Schema.String>;
39
+ errorName: Schema.optionalKey<Schema.String>;
40
+ message: Schema.optionalKey<Schema.String>;
41
+ }>;
42
+ export type WorkflowRunFailure = typeof WorkflowRunFailure.Type;
27
43
  declare const WorkflowFailure_base: Schema.Class<WorkflowFailure, Schema.TaggedStruct<"WorkflowFailure", {
28
44
  readonly reason: Schema.Literals<readonly ["unavailable", "not_found", "input", "output", "operation", "approval", "credentials", "terminated", "execution", "conflict", "engine"]>;
29
45
  readonly retryable: Schema.Boolean;
46
+ readonly step: Schema.optionalKey<Schema.String>;
47
+ readonly errorName: Schema.optionalKey<Schema.String>;
48
+ readonly message: Schema.optionalKey<Schema.String>;
30
49
  }>, import("effect/Cause").YieldableError>;
31
- /** Safe failures cross host boundaries without authored exceptions or account fields. */
50
+ /** Failures cross host boundaries as reason codes plus the app's own bounded error detail. */
32
51
  export declare class WorkflowFailure extends WorkflowFailure_base {
33
52
  }
34
- /** Explicitly stop retrying an authored step. Its message stays inside the app runtime. */
53
+ /** Explicitly stop retrying an authored step. Its message is reported like any step error. */
35
54
  export declare class NonRetryableError extends Error {
36
55
  readonly name = "NonRetryableError";
37
56
  }
@@ -45,7 +64,7 @@ export declare const HostedWorkflow: Schema.Struct<{
45
64
  readonly outputSchema: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
46
65
  }>;
47
66
  export type HostedWorkflow = typeof HostedWorkflow.Type;
48
- /** Results are available only on completed runs; failure details are safe reason codes. */
67
+ /** Results are available only on completed runs; failures carry a reason code and app error detail. */
49
68
  export declare const WorkflowRun: Schema.Union<readonly [Schema.Struct<{
50
69
  readonly status: Schema.Literals<readonly ["queued", "running", "waiting", "paused", "waitingForPause"]>;
51
70
  readonly profile: Schema.optionalKey<Schema.NonEmptyString>;
@@ -66,6 +85,12 @@ export declare const WorkflowRun: Schema.Union<readonly [Schema.Struct<{
66
85
  }>, Schema.Struct<{
67
86
  readonly status: Schema.Literal<"errored">;
68
87
  readonly error: Schema.Literals<readonly ["unavailable", "not_found", "input", "output", "operation", "approval", "credentials", "terminated", "execution", "conflict", "engine"]>;
88
+ /** The failing step and the app's own error, when the run recorded them. */
89
+ readonly failure: Schema.optionalKey<Schema.Struct<{
90
+ step: Schema.optionalKey<Schema.String>;
91
+ errorName: Schema.optionalKey<Schema.String>;
92
+ message: Schema.optionalKey<Schema.String>;
93
+ }>>;
69
94
  readonly profile: Schema.optionalKey<Schema.NonEmptyString>;
70
95
  readonly id: Schema.brand<Schema.NonEmptyString, "wfr">;
71
96
  readonly app: Schema.NonEmptyString;
@@ -104,6 +129,12 @@ export declare const WorkflowRunPage: Schema.Struct<{
104
129
  }>, Schema.Struct<{
105
130
  readonly status: Schema.Literal<"errored">;
106
131
  readonly error: Schema.Literals<readonly ["unavailable", "not_found", "input", "output", "operation", "approval", "credentials", "terminated", "execution", "conflict", "engine"]>;
132
+ /** The failing step and the app's own error, when the run recorded them. */
133
+ readonly failure: Schema.optionalKey<Schema.Struct<{
134
+ step: Schema.optionalKey<Schema.String>;
135
+ errorName: Schema.optionalKey<Schema.String>;
136
+ message: Schema.optionalKey<Schema.String>;
137
+ }>>;
107
138
  readonly profile: Schema.optionalKey<Schema.NonEmptyString>;
108
139
  readonly id: Schema.brand<Schema.NonEmptyString, "wfr">;
109
140
  readonly app: Schema.NonEmptyString;
@@ -66,10 +66,10 @@ export declare const prepareElicitation: (input: unknown) => Effect.Effect<{
66
66
  } | {
67
67
  readonly type: "number" | "integer";
68
68
  readonly default?: number;
69
+ readonly maximum?: number;
69
70
  readonly description?: string;
70
71
  readonly title?: string;
71
72
  readonly minimum?: number;
72
- readonly maximum?: number;
73
73
  } | {
74
74
  readonly type: "boolean";
75
75
  readonly default?: boolean;
@@ -0,0 +1,25 @@
1
+ import { Redacted } from "effect";
2
+ import type { ResolvedAccounts } from "../contracts/host.js";
3
+ /** Fields of `FailureDetail` as constructor input. */
4
+ export interface FailureDetail {
5
+ readonly source?: "app" | "storage" | "service";
6
+ readonly errorName?: string;
7
+ readonly code?: string;
8
+ readonly message?: string;
9
+ }
10
+ /**
11
+ * Every credential field value of a slot-to-account record, longest first. Accepts both resolved
12
+ * host accounts and bound author accounts; each account keeps its credential values in `fields`.
13
+ */
14
+ export declare const accountFieldSecrets: (accounts: unknown) => string[];
15
+ /** Every credential field value of an invocation's selected accounts. */
16
+ export declare const accountSecrets: (accounts: Redacted.Redacted<ResolvedAccounts>) => string[];
17
+ /** Replace account secrets and bound the message for the runtime boundary. */
18
+ export declare const boundFailureMessage: (message: string, secrets: readonly string[]) => string;
19
+ /** `Name: message` for any thrown value, before redaction. */
20
+ export declare const describeFailure: (error: unknown) => string;
21
+ /**
22
+ * Describe what an operation raised for the app's own caller. App data failures keep their
23
+ * reason as a code; any other thrown value is the app's own error. Account secrets are replaced.
24
+ */
25
+ export declare const failureDetail: (error: unknown, secrets: readonly string[]) => FailureDetail;
@@ -1,10 +1,12 @@
1
- import { type DatabaseSession } from "../../../app-data/src/index.js";
1
+ import { type DatabaseSession, type reservedFieldNames } from "../../../app-data/src/index.js";
2
+ type ReservedFieldName = (typeof reservedFieldNames)[number];
2
3
  import { type AppStorage } from "../contracts/storage.js";
3
4
  import type { DatabaseDefinition, Database, Table, Tables } from "../contracts/storage.js";
4
5
  import { type Fields } from "./schema.js";
5
6
  export type { DatabaseDefinition, Database, DatabaseReader, Table, Tables, RowOf, } from "../contracts/storage.js";
6
- /** Declare scalar columns using the same schemas as operation inputs. */
7
- export declare const table: <const F extends Fields>(fields: F) => Table<F>;
7
+ /** Declare scalar columns using the same schemas as operation inputs. The host adds `id`,
8
+ * `createdAt` and `updatedAt` to every row, so tables cannot declare those names. */
9
+ export declare const table: <const F extends Fields & { readonly [K in ReservedFieldName]?: never; }>(fields: F) => Table<F>;
8
10
  /** Build a fresh Promise database facade for one authorized invocation. */
9
11
  export declare const authorDatabase: <T extends Tables>(tables: T, session: DatabaseSession, signal: AbortSignal, writable: boolean) => Database<T>;
10
12
  /** Declare storage independently of handlers; the host binds each invocation's database. */
@@ -26,4 +26,4 @@ export declare const dispatchWebhook: <Context extends {
26
26
  readonly [x: string]: string;
27
27
  };
28
28
  readonly body: string;
29
- }, HostDeclarationInvalid | HostOperationNotFound | HostOperationFailed | HostInputInvalid | HostOutputInvalid, never>;
29
+ }, HostOperationNotFound | HostInputInvalid | HostOutputInvalid | HostDeclarationInvalid | HostOperationFailed, never>;
@@ -2,7 +2,15 @@
2
2
  import { Effect } from "effect";
3
3
  import type { AppDefinition } from "../contracts/app.js";
4
4
  import { WorkflowFailure, type WorkflowContext, type WorkflowExecution, type WorkflowStepContext } from "../contracts/workflows.js";
5
- /** Preserve typed failures and cancellation; authored exception text never leaves the app. */
6
- export declare const workflowSafe: <A>(work: Effect.Effect<A, unknown>) => Effect.Effect<A, WorkflowFailure>;
5
+ /**
6
+ * Preserve typed failures and cancellation. Other errors keep their name and bounded message,
7
+ * with the given account secrets replaced.
8
+ */
9
+ export declare const workflowSafe: <A>(work: Effect.Effect<A, unknown>, secrets: readonly string[]) => Effect.Effect<A, WorkflowFailure>;
7
10
  /** Construct one replay's Promise context. Step callbacks acquire fresh capabilities per actual attempt. */
8
- export declare const makeWorkflowContext: (execution: WorkflowExecution, definition: Pick<AppDefinition<never>, "queries" | "mutations">, fresh: (stepId: string, signal: AbortSignal) => Effect.Effect<WorkflowStepContext, WorkflowFailure>, signal: AbortSignal) => Effect.Effect<WorkflowContext>;
11
+ export declare const makeWorkflowContext: (execution: WorkflowExecution, definition: Pick<AppDefinition<never>, "queries" | "mutations">,
12
+ /** A step attempt's context, and the raw account secrets its failures must not reveal. */
13
+ fresh: (stepId: string, signal: AbortSignal) => Effect.Effect<{
14
+ readonly context: WorkflowStepContext;
15
+ readonly secrets: readonly string[];
16
+ }, WorkflowFailure>, signal: AbortSignal) => Effect.Effect<WorkflowContext>;