@useago/sdk 0.4.3 → 0.4.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.
- package/dist/{createConversationSession-DtaeA418.cjs → createConversationSession-0F_OXdQB.cjs} +1 -1
- package/dist/{createConversationSession-D9FesBQS.js → createConversationSession-DbuVzvoX.js} +1 -1
- package/dist/createFormCollector-BMTdfhHg.cjs +1 -0
- package/dist/createFormCollector-Cujr7hW4.js +244 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +64 -7
- package/dist/index.d.ts +64 -7
- package/dist/index.js +59 -58
- package/dist/react.cjs +13 -13
- package/dist/react.d.cts +69 -9
- package/dist/react.d.ts +69 -9
- package/dist/react.js +1031 -1025
- package/dist/widget.cjs +1 -1
- package/dist/widget.d.cts +47 -5
- package/dist/widget.d.ts +47 -5
- package/dist/widget.js +44 -42
- package/package.json +1 -1
- package/dist/createFormCollector-BwvkKi48.js +0 -211
- package/dist/createFormCollector-Wb8Rr-U2.cjs +0 -1
package/dist/react.d.cts
CHANGED
|
@@ -542,6 +542,19 @@ export declare interface CreateFormCollectorOptions<V = Record<string, unknown>>
|
|
|
542
542
|
*/
|
|
543
543
|
export declare function createMockClient(options?: MockAgoClientOptions): MockAgoClient;
|
|
544
544
|
|
|
545
|
+
/**
|
|
546
|
+
* Compute which required fields are still empty and whether the form is complete.
|
|
547
|
+
* Pure — the single home for the "required + non-empty" rule, shared by the update
|
|
548
|
+
* handler, submit, the dynamic context, and the React hook. Derived on read so the
|
|
549
|
+
* store only ever holds canonical state ({@link FormCollectorState}).
|
|
550
|
+
*
|
|
551
|
+
* Requiredness is answer-dependent: a field listed in `required` is required unless
|
|
552
|
+
* it carries a `requiredWhen` that doesn't currently hold, and any field whose
|
|
553
|
+
* `requiredWhen` holds becomes required. So conditional fields surface in `missing`
|
|
554
|
+
* exactly when the answers make them relevant.
|
|
555
|
+
*/
|
|
556
|
+
export declare function deriveFormStatus(schema: FormCollectorSchema, values: Partial<Record<string, unknown>>): FormCollectorStatus;
|
|
557
|
+
|
|
545
558
|
/**
|
|
546
559
|
* A function that returns a fresh context entry on demand.
|
|
547
560
|
* Evaluated every time a message is sent — use it to pull data from stores,
|
|
@@ -577,22 +590,29 @@ export declare interface FormCollector<V = Record<string, unknown>> {
|
|
|
577
590
|
}
|
|
578
591
|
|
|
579
592
|
/**
|
|
580
|
-
*
|
|
581
|
-
*
|
|
582
|
-
* dynamic context with no second type.
|
|
593
|
+
* Shape of a form's fields. Mirrors a client function's `parameters` (so the same
|
|
594
|
+
* object feeds the store, the update function, and the dynamic context). Additionally allows the SDK-only per-field `requiredWhen`, which {@link toWireParameters} removes before the schema reaches the LLM.
|
|
583
595
|
*/
|
|
584
|
-
export declare
|
|
596
|
+
export declare interface FormCollectorSchema {
|
|
597
|
+
type: "object";
|
|
598
|
+
properties: Record<string, FormFieldSchema>;
|
|
599
|
+
required?: string[];
|
|
600
|
+
}
|
|
585
601
|
|
|
586
|
-
/**
|
|
602
|
+
/** Canonical, source-of-truth state held in the collector's store. */
|
|
587
603
|
export declare interface FormCollectorState<V = Record<string, unknown>> {
|
|
588
604
|
/** Field values collected so far. */
|
|
589
605
|
values: Partial<V>;
|
|
606
|
+
/** True once a submit succeeded. */
|
|
607
|
+
submitted: boolean;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
/** Completeness status derived from values + schema — computed on read, never stored. */
|
|
611
|
+
export declare interface FormCollectorStatus {
|
|
590
612
|
/** Required field names still empty. */
|
|
591
613
|
missing: string[];
|
|
592
614
|
/** True when no required field is missing. */
|
|
593
615
|
complete: boolean;
|
|
594
|
-
/** True once a submit succeeded. */
|
|
595
|
-
submitted: boolean;
|
|
596
616
|
}
|
|
597
617
|
|
|
598
618
|
declare interface FormField {
|
|
@@ -603,6 +623,43 @@ declare interface FormField {
|
|
|
603
623
|
default?: unknown;
|
|
604
624
|
}
|
|
605
625
|
|
|
626
|
+
/**
|
|
627
|
+
* A field's conditional-requiredness rule. The field becomes required exactly
|
|
628
|
+
* when the controlling `property` matches `value` against the answers collected
|
|
629
|
+
* so far:
|
|
630
|
+
* - a single `value`, no `op` — equality (compared as strings);
|
|
631
|
+
* - a single `value` with `op` — numeric comparison (both sides coerced to numbers);
|
|
632
|
+
* - an array `value`, no `op` — "one of": matches when the property equals any
|
|
633
|
+
* listed value.
|
|
634
|
+
*
|
|
635
|
+
* SDK-only — it is stripped from the schema before it reaches the LLM tool
|
|
636
|
+
*/
|
|
637
|
+
declare interface FormFieldCondition {
|
|
638
|
+
/** The controlling field whose value the rule tests. */
|
|
639
|
+
property: string;
|
|
640
|
+
/** Comparison operator; omitted means equality. Ignored when `value` is an array. */
|
|
641
|
+
op?: ">=" | "<=" | ">" | "<";
|
|
642
|
+
/**
|
|
643
|
+
* The value(s) to test the controlling field against. A single value is an
|
|
644
|
+
* equality (or, with `op`, a numeric comparison); an array is an "is one of"
|
|
645
|
+
* membership test, e.g. `value: ["1", "2", "3"]`.
|
|
646
|
+
*/
|
|
647
|
+
value: string | number | Array<string | number>;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
/** A single field's schema: the wire-legal keys plus the SDK-only `requiredWhen`. */
|
|
651
|
+
declare interface FormFieldSchema {
|
|
652
|
+
type: string;
|
|
653
|
+
description?: string;
|
|
654
|
+
enum?: string[];
|
|
655
|
+
default?: unknown;
|
|
656
|
+
/**
|
|
657
|
+
* Makes the field required only while this condition holds. Drives the dynamic
|
|
658
|
+
* `missing` list; stripped before the LLM tool — see {@link toWireParameters}.
|
|
659
|
+
*/
|
|
660
|
+
requiredWhen?: FormFieldCondition;
|
|
661
|
+
}
|
|
662
|
+
|
|
606
663
|
/**
|
|
607
664
|
* Form schema for tool calls requiring user input
|
|
608
665
|
*/
|
|
@@ -994,8 +1051,11 @@ export declare interface UseConversationResult {
|
|
|
994
1051
|
export declare function useFormCollector<V = Record<string, unknown>>(options: CreateFormCollectorOptions<V>): UseFormCollectorResult<V>;
|
|
995
1052
|
|
|
996
1053
|
export declare interface UseFormCollectorResult<V = Record<string, unknown>> extends FormCollector<V> {
|
|
997
|
-
/**
|
|
998
|
-
|
|
1054
|
+
/**
|
|
1055
|
+
* Live form state from the store (`values`, `submitted`) plus the completeness
|
|
1056
|
+
* status (`missing`, `complete`) derived on read — re-renders on every change.
|
|
1057
|
+
*/
|
|
1058
|
+
state: FormCollectorState<V> & FormCollectorStatus;
|
|
999
1059
|
}
|
|
1000
1060
|
|
|
1001
1061
|
/**
|
package/dist/react.d.ts
CHANGED
|
@@ -542,6 +542,19 @@ export declare interface CreateFormCollectorOptions<V = Record<string, unknown>>
|
|
|
542
542
|
*/
|
|
543
543
|
export declare function createMockClient(options?: MockAgoClientOptions): MockAgoClient;
|
|
544
544
|
|
|
545
|
+
/**
|
|
546
|
+
* Compute which required fields are still empty and whether the form is complete.
|
|
547
|
+
* Pure — the single home for the "required + non-empty" rule, shared by the update
|
|
548
|
+
* handler, submit, the dynamic context, and the React hook. Derived on read so the
|
|
549
|
+
* store only ever holds canonical state ({@link FormCollectorState}).
|
|
550
|
+
*
|
|
551
|
+
* Requiredness is answer-dependent: a field listed in `required` is required unless
|
|
552
|
+
* it carries a `requiredWhen` that doesn't currently hold, and any field whose
|
|
553
|
+
* `requiredWhen` holds becomes required. So conditional fields surface in `missing`
|
|
554
|
+
* exactly when the answers make them relevant.
|
|
555
|
+
*/
|
|
556
|
+
export declare function deriveFormStatus(schema: FormCollectorSchema, values: Partial<Record<string, unknown>>): FormCollectorStatus;
|
|
557
|
+
|
|
545
558
|
/**
|
|
546
559
|
* A function that returns a fresh context entry on demand.
|
|
547
560
|
* Evaluated every time a message is sent — use it to pull data from stores,
|
|
@@ -577,22 +590,29 @@ export declare interface FormCollector<V = Record<string, unknown>> {
|
|
|
577
590
|
}
|
|
578
591
|
|
|
579
592
|
/**
|
|
580
|
-
*
|
|
581
|
-
*
|
|
582
|
-
* dynamic context with no second type.
|
|
593
|
+
* Shape of a form's fields. Mirrors a client function's `parameters` (so the same
|
|
594
|
+
* object feeds the store, the update function, and the dynamic context). Additionally allows the SDK-only per-field `requiredWhen`, which {@link toWireParameters} removes before the schema reaches the LLM.
|
|
583
595
|
*/
|
|
584
|
-
export declare
|
|
596
|
+
export declare interface FormCollectorSchema {
|
|
597
|
+
type: "object";
|
|
598
|
+
properties: Record<string, FormFieldSchema>;
|
|
599
|
+
required?: string[];
|
|
600
|
+
}
|
|
585
601
|
|
|
586
|
-
/**
|
|
602
|
+
/** Canonical, source-of-truth state held in the collector's store. */
|
|
587
603
|
export declare interface FormCollectorState<V = Record<string, unknown>> {
|
|
588
604
|
/** Field values collected so far. */
|
|
589
605
|
values: Partial<V>;
|
|
606
|
+
/** True once a submit succeeded. */
|
|
607
|
+
submitted: boolean;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
/** Completeness status derived from values + schema — computed on read, never stored. */
|
|
611
|
+
export declare interface FormCollectorStatus {
|
|
590
612
|
/** Required field names still empty. */
|
|
591
613
|
missing: string[];
|
|
592
614
|
/** True when no required field is missing. */
|
|
593
615
|
complete: boolean;
|
|
594
|
-
/** True once a submit succeeded. */
|
|
595
|
-
submitted: boolean;
|
|
596
616
|
}
|
|
597
617
|
|
|
598
618
|
declare interface FormField {
|
|
@@ -603,6 +623,43 @@ declare interface FormField {
|
|
|
603
623
|
default?: unknown;
|
|
604
624
|
}
|
|
605
625
|
|
|
626
|
+
/**
|
|
627
|
+
* A field's conditional-requiredness rule. The field becomes required exactly
|
|
628
|
+
* when the controlling `property` matches `value` against the answers collected
|
|
629
|
+
* so far:
|
|
630
|
+
* - a single `value`, no `op` — equality (compared as strings);
|
|
631
|
+
* - a single `value` with `op` — numeric comparison (both sides coerced to numbers);
|
|
632
|
+
* - an array `value`, no `op` — "one of": matches when the property equals any
|
|
633
|
+
* listed value.
|
|
634
|
+
*
|
|
635
|
+
* SDK-only — it is stripped from the schema before it reaches the LLM tool
|
|
636
|
+
*/
|
|
637
|
+
declare interface FormFieldCondition {
|
|
638
|
+
/** The controlling field whose value the rule tests. */
|
|
639
|
+
property: string;
|
|
640
|
+
/** Comparison operator; omitted means equality. Ignored when `value` is an array. */
|
|
641
|
+
op?: ">=" | "<=" | ">" | "<";
|
|
642
|
+
/**
|
|
643
|
+
* The value(s) to test the controlling field against. A single value is an
|
|
644
|
+
* equality (or, with `op`, a numeric comparison); an array is an "is one of"
|
|
645
|
+
* membership test, e.g. `value: ["1", "2", "3"]`.
|
|
646
|
+
*/
|
|
647
|
+
value: string | number | Array<string | number>;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
/** A single field's schema: the wire-legal keys plus the SDK-only `requiredWhen`. */
|
|
651
|
+
declare interface FormFieldSchema {
|
|
652
|
+
type: string;
|
|
653
|
+
description?: string;
|
|
654
|
+
enum?: string[];
|
|
655
|
+
default?: unknown;
|
|
656
|
+
/**
|
|
657
|
+
* Makes the field required only while this condition holds. Drives the dynamic
|
|
658
|
+
* `missing` list; stripped before the LLM tool — see {@link toWireParameters}.
|
|
659
|
+
*/
|
|
660
|
+
requiredWhen?: FormFieldCondition;
|
|
661
|
+
}
|
|
662
|
+
|
|
606
663
|
/**
|
|
607
664
|
* Form schema for tool calls requiring user input
|
|
608
665
|
*/
|
|
@@ -994,8 +1051,11 @@ export declare interface UseConversationResult {
|
|
|
994
1051
|
export declare function useFormCollector<V = Record<string, unknown>>(options: CreateFormCollectorOptions<V>): UseFormCollectorResult<V>;
|
|
995
1052
|
|
|
996
1053
|
export declare interface UseFormCollectorResult<V = Record<string, unknown>> extends FormCollector<V> {
|
|
997
|
-
/**
|
|
998
|
-
|
|
1054
|
+
/**
|
|
1055
|
+
* Live form state from the store (`values`, `submitted`) plus the completeness
|
|
1056
|
+
* status (`missing`, `complete`) derived on read — re-renders on every change.
|
|
1057
|
+
*/
|
|
1058
|
+
state: FormCollectorState<V> & FormCollectorStatus;
|
|
999
1059
|
}
|
|
1000
1060
|
|
|
1001
1061
|
/**
|