@alexkroman1/aai-ui 8.2.1 → 9.0.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.
package/README.md CHANGED
@@ -22,7 +22,7 @@ still React, still the same theme tokens.
22
22
  `client()` mounts the default chat shell with your sidebar, or replaces the
23
23
  whole UI with a custom component:
24
24
 
25
- ```tsx
25
+ ```tsx no-check
26
26
  import "@alexkroman1/aai-ui/styles.css";
27
27
  import { client, useAgentState, useTheme } from "@alexkroman1/aai-ui";
28
28
 
@@ -53,7 +53,7 @@ client({ sidebar: OrderSidebar });
53
53
  one control per scalar property of the workflow's own input schema, so adding
54
54
  a field to the schema adds it to the page:
55
55
 
56
- ```tsx
56
+ ```tsx no-check
57
57
  import "@alexkroman1/aai-ui/styles.css";
58
58
  import {
59
59
  Form,
@@ -64,12 +64,14 @@ import {
64
64
  WorkflowFields,
65
65
  WorkflowProgress,
66
66
  } from "@alexkroman1/aai-ui";
67
+ // Type-only, so it is ERASED — the agent module is not in this bundle.
68
+ import type { digest } from "./agent.ts";
67
69
 
68
70
  function App() {
69
- const { submit, run, pending, upload, error } = useWorkflowSubmit("digest");
71
+ const { submitForm, run, pending, upload, error } = useWorkflowSubmit<typeof digest>("digest");
70
72
  return (
71
73
  <main className="mx-auto flex max-w-2xl flex-col gap-6 p-8">
72
- <Form onSubmit={submit} error={error}>
74
+ <Form onSubmit={submitForm} error={error}>
73
75
  <WorkflowFields workflow="digest" />
74
76
  <SubmitButton pending={pending}>Summarize</SubmitButton>
75
77
  </Form>
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Synthetic workflow DEF types for this package's specs.
3
+ *
4
+ * The workflow hooks take a def rather than an output type, and the def is
5
+ * REQUIRED — there is no untyped fallback, because an escape hatch nobody needs
6
+ * is one somebody uses. That leaves the specs, whose subject is upload plumbing
7
+ * and polling rather than typing, needing a def to name.
8
+ *
9
+ * Built structurally rather than with a schema library: `zod` is not a
10
+ * dependency of this package, and `StandardSchemaV1` is published on
11
+ * `@alexkroman1/aai/host-internal`, which a browser package may not import. The
12
+ * shape below is the part of that contract `InferSchemaOutput` reads — the
13
+ * `types.output` slot — and nothing else, which is all a type-level def needs.
14
+ *
15
+ * A `.ts` module rather than a `_test-utils` export because it is types only.
16
+ */
17
+ import type { WorkflowDef } from "@alexkroman1/aai";
18
+ /** A Standard-Schema-shaped type whose parsed output is `O`. Never constructed. */
19
+ type SchemaOf<O extends Record<string, unknown>> = {
20
+ readonly "~standard": {
21
+ readonly version: 1;
22
+ readonly vendor: string;
23
+ readonly validate: (value: unknown) => {
24
+ readonly value: O;
25
+ };
26
+ readonly types?: {
27
+ readonly input: unknown;
28
+ readonly output: O;
29
+ } | undefined;
30
+ };
31
+ };
32
+ /** A workflow taking `I` and answering `O`. */
33
+ export type TestWorkflow<I extends Record<string, unknown> = Record<string, unknown>, O = unknown> = WorkflowDef<SchemaOf<I>, O>;
34
+ /** The shape most specs here need: one `recording` upload id, an unknown result. */
35
+ export type UploadWorkflow = TestWorkflow<{
36
+ recording: unknown;
37
+ }>;
38
+ export {};
@@ -32,13 +32,14 @@ import type { UploadStatus } from "../use-workflow-form.ts";
32
32
  * parent's state) has nothing to pause.
33
33
  *
34
34
  * @example
35
- * ```tsx
35
+ * ```tsx no-check
36
36
  * import { Form, SubmitButton, UploadProgressBar, useWorkflowSubmit, WorkflowFields } from "@alexkroman1/aai-ui";
37
+ * import type { transcribe } from "./agent.ts";
37
38
  *
38
39
  * function TranscribeForm() {
39
- * const { submit, upload, pending, error } = useWorkflowSubmit("transcribe");
40
+ * const { submitForm, upload, pending, error } = useWorkflowSubmit<typeof transcribe>("transcribe");
40
41
  * return (
41
- * <Form onSubmit={(values) => submit(values)} error={error}>
42
+ * <Form onSubmit={submitForm} error={error}>
42
43
  * <WorkflowFields workflow="transcribe" />
43
44
  * <UploadProgressBar upload={upload} />
44
45
  * <SubmitButton pending={pending}>Transcribe</SubmitButton>
@@ -15,14 +15,15 @@ import type { WorkflowSummary } from "@alexkroman1/aai/workflow-api";
15
15
  * beside it are not reordered when the schema lands.
16
16
  *
17
17
  * @example
18
- * ```tsx
18
+ * ```tsx no-check
19
19
  * import { Form, SubmitButton, WorkflowFields, useWorkflowSubmit }
20
20
  * from "@alexkroman1/aai-ui";
21
+ * import type { transcribe } from "./agent.ts";
21
22
  *
22
23
  * function StartRun() {
23
- * const { submit, pending, error } = useWorkflowSubmit("transcribe");
24
+ * const { submitForm, pending, error } = useWorkflowSubmit<typeof transcribe>("transcribe");
24
25
  * return (
25
- * <Form onSubmit={(values) => submit(values)} error={error}>
26
+ * <Form onSubmit={submitForm} error={error}>
26
27
  * <WorkflowFields workflow="transcribe" />
27
28
  * <SubmitButton pending={pending}>Transcribe</SubmitButton>
28
29
  * </Form>