@nan0web/ui 1.10.0 → 1.12.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 +69 -3
- package/package.json +65 -29
- package/src/App/Command/DepsCommand.js +3 -4
- package/src/Frame/Props.js +12 -18
- package/src/InterfaceTemplate/InterfaceTemplate.js +9 -7
- package/src/Model/index.js +61 -6
- package/src/StdIn.js +2 -6
- package/src/cli.js +1 -0
- package/src/core/GeneratorRunner.js +67 -7
- package/src/core/InputAdapter.js +22 -5
- package/src/core/Intent.js +230 -18
- package/src/core/Message/Message.js +4 -7
- package/src/core/Message/OutputMessage.js +4 -9
- package/src/core/StreamEntry.js +20 -28
- package/src/core/index.js +4 -0
- package/src/domain/Content.js +198 -0
- package/src/domain/Document.js +25 -0
- package/src/domain/FooterModel.js +37 -19
- package/src/domain/HeaderModel.js +47 -21
- package/src/domain/HeroModel.js +24 -22
- package/src/domain/LayoutModel.js +43 -0
- package/src/domain/ModelAsApp.js +46 -0
- package/src/domain/SandboxModel.js +19 -16
- package/src/domain/app/GalleryCommand.js +53 -0
- package/src/domain/app/GalleryRenderIntent.js +77 -0
- package/src/domain/app/SnapshotAuditor.js +399 -0
- package/src/domain/app/SnapshotRunner.js +264 -0
- package/src/domain/app/UIApp.js +78 -0
- package/src/domain/components/BreadcrumbModel.js +10 -6
- package/src/domain/components/FeatureGridModel.js +62 -0
- package/src/domain/components/MarkdownModel.js +24 -0
- package/src/domain/components/ShellModel.js +243 -0
- package/src/domain/components/TableModel.js +10 -6
- package/src/domain/components/ToastModel.js +10 -6
- package/src/domain/components/index.js +3 -1
- package/src/domain/index.js +14 -4
- package/src/index.js +23 -2
- package/src/inspect.js +2 -0
- package/src/test/ScenarioAdapter.js +59 -0
- package/src/test/ScenarioTest.js +51 -0
- package/src/test/ScenarioTest.story.js +56 -0
- package/src/testing/CrashReporter.js +56 -0
- package/src/testing/GalleryGenerator.js +15 -71
- package/src/testing/LogicInspector.js +4 -4
- package/src/testing/SnapshotRunner.js +22 -0
- package/src/testing/SpecAdapter.js +114 -0
- package/src/testing/SpecRunner.js +121 -0
- package/src/testing/VisualAdapter.js +24 -19
- package/src/testing/index.js +5 -1
- package/src/testing/verifySnapshot.js +17 -0
- package/types/App/Command/DepsCommand.d.ts +0 -2
- package/types/Model/index.d.ts +56 -62
- package/types/StdIn.d.ts +3 -3
- package/types/cli.d.ts +1 -0
- package/types/core/GeneratorRunner.d.ts +14 -1
- package/types/core/InputAdapter.d.ts +50 -6
- package/types/core/Intent.d.ts +280 -32
- package/types/core/Message/Message.d.ts +2 -2
- package/types/core/Message/OutputMessage.d.ts +0 -2
- package/types/core/index.d.ts +4 -0
- package/types/domain/Content.d.ts +344 -0
- package/types/domain/Document.d.ts +40 -0
- package/types/domain/FooterModel.d.ts +22 -12
- package/types/domain/HeaderModel.d.ts +36 -13
- package/types/domain/HeroModel.d.ts +19 -17
- package/types/domain/LayoutModel.d.ts +34 -0
- package/types/domain/ModelAsApp.d.ts +23 -0
- package/types/domain/SandboxModel.d.ts +10 -0
- package/types/domain/app/GalleryCommand.d.ts +55 -0
- package/types/domain/app/GalleryRenderIntent.d.ts +31 -0
- package/types/domain/app/SnapshotAuditor.d.ts +99 -0
- package/types/domain/app/SnapshotRunner.d.ts +45 -0
- package/types/domain/app/UIApp.d.ts +60 -0
- package/types/domain/components/BreadcrumbModel.d.ts +6 -8
- package/types/domain/components/FeatureGridModel.d.ts +50 -0
- package/types/domain/components/MarkdownModel.d.ts +19 -0
- package/types/domain/components/ShellModel.d.ts +56 -0
- package/types/domain/components/TableModel.d.ts +4 -0
- package/types/domain/components/ToastModel.d.ts +4 -0
- package/types/domain/components/index.d.ts +3 -0
- package/types/domain/index.d.ts +10 -4
- package/types/index.d.ts +21 -1
- package/types/inspect.d.ts +2 -0
- package/types/test/ScenarioAdapter.d.ts +43 -0
- package/types/test/ScenarioTest.d.ts +24 -0
- package/types/test/ScenarioTest.story.d.ts +1 -0
- package/types/testing/CrashReporter.d.ts +13 -0
- package/types/testing/SnapshotRunner.d.ts +7 -0
- package/types/testing/SpecAdapter.d.ts +58 -0
- package/types/testing/SpecRunner.d.ts +41 -0
- package/types/testing/VisualAdapter.d.ts +0 -6
- package/types/testing/index.d.ts +5 -1
- package/types/testing/verifySnapshot.d.ts +14 -0
- package/src/testing/SnapshotInspector.js +0 -84
- package/types/App/Command/Options.d.ts +0 -43
- package/types/App/Command/index.d.ts +0 -8
- package/types/App/User/Command/Options.d.ts +0 -34
- package/types/core/Message/InputMessage.d.ts +0 -71
- package/types/domain/components/HeroModel.d.ts +0 -24
- package/types/domain/components/ShowcaseAppModel.d.ts +0 -32
- package/types/testing/SnapshotInspector.d.ts +0 -17
package/types/Model/index.d.ts
CHANGED
|
@@ -1,64 +1,58 @@
|
|
|
1
|
-
export { User };
|
|
2
|
-
export const HeaderModel: typeof DomainModels.HeaderModel;
|
|
3
|
-
export const FooterModel: typeof DomainModels.FooterModel;
|
|
4
|
-
export const HeroModel: typeof DomainModels.HeroModel;
|
|
5
|
-
export const ButtonModel: typeof DomainModels.ButtonModel;
|
|
6
|
-
export const ConfirmModel: typeof DomainModels.ConfirmModel;
|
|
7
|
-
export const InputModel: typeof DomainModels.InputModel;
|
|
8
|
-
export const SpinnerModel: typeof DomainModels.SpinnerModel;
|
|
9
|
-
export const TableModel: typeof DomainModels.TableModel;
|
|
10
|
-
export const ToastModel: typeof DomainModels.ToastModel;
|
|
11
|
-
export const SelectModel: typeof DomainModels.SelectModel;
|
|
12
|
-
export const AutocompleteModel: typeof DomainModels.AutocompleteModel;
|
|
13
|
-
export const TreeModel: typeof DomainModels.TreeModel;
|
|
14
|
-
export const TabsModel: typeof DomainModels.TabsModel;
|
|
15
|
-
export const AccordionModel: typeof DomainModels.AccordionModel;
|
|
16
|
-
export const GalleryModel: typeof DomainModels.GalleryModel;
|
|
17
|
-
export const PriceModel: typeof DomainModels.PriceModel;
|
|
18
|
-
export const PricingModel: typeof DomainModels.PricingModel;
|
|
19
|
-
export const CommentModel: typeof DomainModels.CommentModel;
|
|
20
|
-
export const TestimonialModel: typeof DomainModels.TestimonialModel;
|
|
21
|
-
export const StatsItemModel: typeof DomainModels.StatsItemModel;
|
|
22
|
-
export const StatsModel: typeof DomainModels.StatsModel;
|
|
23
|
-
export const TimelineItemModel: typeof DomainModels.TimelineItemModel;
|
|
24
|
-
export const TimelineModel: typeof DomainModels.TimelineModel;
|
|
25
1
|
export default Model;
|
|
26
2
|
import User from './User/User.js';
|
|
27
|
-
import
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
};
|
|
3
|
+
import { HeaderModel } from '../domain/HeaderModel.js';
|
|
4
|
+
import { FooterModel } from '../domain/FooterModel.js';
|
|
5
|
+
import { HeroModel } from '../domain/HeroModel.js';
|
|
6
|
+
import { ButtonModel } from '../domain/components/index.js';
|
|
7
|
+
import { ConfirmModel } from '../domain/components/index.js';
|
|
8
|
+
import { InputModel } from '../domain/components/index.js';
|
|
9
|
+
import { SpinnerModel } from '../domain/components/index.js';
|
|
10
|
+
import { TableModel } from '../domain/components/index.js';
|
|
11
|
+
import { ToastModel } from '../domain/components/index.js';
|
|
12
|
+
import { SelectModel } from '../domain/components/index.js';
|
|
13
|
+
import { AutocompleteModel } from '../domain/components/index.js';
|
|
14
|
+
import { TreeModel } from '../domain/components/index.js';
|
|
15
|
+
import { TabsModel } from '../domain/components/index.js';
|
|
16
|
+
import { AccordionModel } from '../domain/components/index.js';
|
|
17
|
+
import { GalleryModel } from '../domain/components/index.js';
|
|
18
|
+
import { PriceModel } from '../domain/components/index.js';
|
|
19
|
+
import { PricingModel } from '../domain/components/index.js';
|
|
20
|
+
import { CommentModel } from '../domain/components/index.js';
|
|
21
|
+
import { TestimonialModel } from '../domain/components/index.js';
|
|
22
|
+
import { StatsItemModel } from '../domain/components/index.js';
|
|
23
|
+
import { StatsModel } from '../domain/components/index.js';
|
|
24
|
+
import { TimelineItemModel } from '../domain/components/index.js';
|
|
25
|
+
import { TimelineModel } from '../domain/components/index.js';
|
|
26
|
+
import { EmptyStateModel } from '../domain/components/index.js';
|
|
27
|
+
import { BannerModel } from '../domain/components/index.js';
|
|
28
|
+
import { ProfileDropdownModel } from '../domain/components/index.js';
|
|
29
|
+
declare namespace Model {
|
|
30
|
+
export { User };
|
|
31
|
+
export { HeaderModel };
|
|
32
|
+
export { FooterModel };
|
|
33
|
+
export { HeroModel };
|
|
34
|
+
export { ButtonModel };
|
|
35
|
+
export { ConfirmModel };
|
|
36
|
+
export { InputModel };
|
|
37
|
+
export { SpinnerModel };
|
|
38
|
+
export { TableModel };
|
|
39
|
+
export { ToastModel };
|
|
40
|
+
export { SelectModel };
|
|
41
|
+
export { AutocompleteModel };
|
|
42
|
+
export { TreeModel };
|
|
43
|
+
export { TabsModel };
|
|
44
|
+
export { AccordionModel };
|
|
45
|
+
export { GalleryModel };
|
|
46
|
+
export { PriceModel };
|
|
47
|
+
export { PricingModel };
|
|
48
|
+
export { CommentModel };
|
|
49
|
+
export { TestimonialModel };
|
|
50
|
+
export { StatsItemModel };
|
|
51
|
+
export { StatsModel };
|
|
52
|
+
export { TimelineItemModel };
|
|
53
|
+
export { TimelineModel };
|
|
54
|
+
export { EmptyStateModel };
|
|
55
|
+
export { BannerModel };
|
|
56
|
+
export { ProfileDropdownModel };
|
|
57
|
+
}
|
|
58
|
+
export { User, HeaderModel, FooterModel, HeroModel, ButtonModel, ConfirmModel, InputModel, SpinnerModel, TableModel, ToastModel, SelectModel, AutocompleteModel, TreeModel, TabsModel, AccordionModel, GalleryModel, PriceModel, PricingModel, CommentModel, TestimonialModel, StatsItemModel, StatsModel, TimelineItemModel, TimelineModel, EmptyStateModel, BannerModel, ProfileDropdownModel };
|
package/types/StdIn.d.ts
CHANGED
|
@@ -22,10 +22,10 @@ export default class StdIn extends EventProcessor {
|
|
|
22
22
|
processor?: Processor | undefined;
|
|
23
23
|
stream?: UiMessage[] | undefined;
|
|
24
24
|
});
|
|
25
|
-
/** @type {UiMessage[]} Input message buffer */
|
|
26
|
-
stream: UiMessage[];
|
|
27
25
|
/** @type {Processor} Input processor */
|
|
28
26
|
processor: Processor;
|
|
27
|
+
/** @type {UiMessage[]} Input message buffer */
|
|
28
|
+
stream: UiMessage[];
|
|
29
29
|
/**
|
|
30
30
|
* Checks if there are messages waiting in the input stream.
|
|
31
31
|
* @returns {boolean} True if waiting messages, false otherwise
|
|
@@ -56,7 +56,7 @@ export default class StdIn extends EventProcessor {
|
|
|
56
56
|
decode(message: UiMessage | string[] | any): UiMessage;
|
|
57
57
|
}
|
|
58
58
|
import EventProcessor from '@nan0web/event/oop';
|
|
59
|
-
import { UiMessage } from './core/index.js';
|
|
60
59
|
declare class Processor extends EventProcessor {
|
|
61
60
|
}
|
|
61
|
+
import { UiMessage } from './core/index.js';
|
|
62
62
|
export {};
|
package/types/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { UIApp as default } from "./domain/app/UIApp.js";
|
|
@@ -29,9 +29,17 @@ export type AdapterHandlers = {
|
|
|
29
29
|
*/
|
|
30
30
|
progress?: ((intent: import("./Intent.js").ProgressIntent) => void | Promise<void>) | undefined;
|
|
31
31
|
/**
|
|
32
|
-
* Handler for '
|
|
32
|
+
* Handler for 'show' intents. Optional (defaults to no-op).
|
|
33
|
+
*/
|
|
34
|
+
show?: ((intent: import("./Intent.js").ShowIntent) => void | Promise<void>) | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Handler for 'log' intents. Optional.
|
|
33
37
|
*/
|
|
34
38
|
log?: ((intent: import("./Intent.js").LogIntent) => void | Promise<void>) | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Handler for 'agent' intents (AI Subagents). Optional (fallback to show if not implemented).
|
|
41
|
+
*/
|
|
42
|
+
agent?: ((intent: import("./Intent.js").AgentIntent) => Promise<import("./Intent.js").AgentResponse>) | undefined;
|
|
35
43
|
/**
|
|
36
44
|
* Handler for 'render' intents (visual component injection). Optional.
|
|
37
45
|
*/
|
|
@@ -52,4 +60,9 @@ export type RunnerOptions = {
|
|
|
52
60
|
* External AbortSignal for cancellation from outside.
|
|
53
61
|
*/
|
|
54
62
|
signal?: AbortSignal | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Array where all executed intents will be sequentially recorded.
|
|
65
|
+
* Useful for generating 'crash reports' or Nan0Spec files on failure.
|
|
66
|
+
*/
|
|
67
|
+
trace?: import("./Intent.js").Intent[] | undefined;
|
|
55
68
|
};
|
|
@@ -1,10 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} AskOptions
|
|
3
|
+
* @property {boolean} [silent] - Suppress logs or output.
|
|
4
|
+
* @property {string} [title] - Custom title for the prompt.
|
|
5
|
+
* @property {string} [hint] - Presentation hint (e.g., 'password', 'tree', 'markdown').
|
|
6
|
+
* @property {any} [default] - Default value if no input is provided.
|
|
7
|
+
* @property {Array<string|Object>} [options] - Array of options for select inputs.
|
|
8
|
+
* @property {Record<string, any>} [UI] - Localization dictionary/overrides.
|
|
9
|
+
* @property {string} [component] - Target specific component override.
|
|
10
|
+
*/
|
|
11
|
+
/** @typedef {import('./index.js').AskResponse} AskResponse */
|
|
1
12
|
/**
|
|
2
13
|
* Abstract input adapter for UI implementations.
|
|
3
14
|
*
|
|
4
15
|
* @class InputAdapter
|
|
5
16
|
* @extends Event
|
|
6
17
|
*/
|
|
7
|
-
export
|
|
18
|
+
export class InputAdapter extends Event {
|
|
8
19
|
static CancelError: typeof CancelError;
|
|
9
20
|
/** @returns {typeof CancelError} */
|
|
10
21
|
get CancelError(): typeof CancelError;
|
|
@@ -28,19 +39,52 @@ export default class InputAdapter extends Event {
|
|
|
28
39
|
isReady(): boolean;
|
|
29
40
|
/**
|
|
30
41
|
* Helper to ask a question.
|
|
31
|
-
* @param {string} question - Question to ask.
|
|
32
|
-
* @
|
|
42
|
+
* @param {string|import('./Message/Message.js').default|any} question - Question to ask, Form instance, or AskIntent.
|
|
43
|
+
* @param {AskOptions} [options] - Additional options.
|
|
44
|
+
* @returns {Promise<AskResponse>}
|
|
33
45
|
*/
|
|
34
|
-
ask(question: string): Promise<
|
|
46
|
+
ask(question: string | import("./Message/Message.js").default | any, options?: AskOptions): Promise<AskResponse>;
|
|
35
47
|
/**
|
|
36
48
|
* Generic selection prompt.
|
|
37
49
|
* @param {Object} config - Selection configuration.
|
|
38
|
-
* @returns {Promise<{ index
|
|
50
|
+
* @returns {Promise<{ index?: number, value: string | null }>}
|
|
39
51
|
*/
|
|
40
52
|
select(config: any): Promise<{
|
|
41
|
-
index
|
|
53
|
+
index?: number;
|
|
42
54
|
value: string | null;
|
|
43
55
|
}>;
|
|
44
56
|
}
|
|
57
|
+
export default InputAdapter;
|
|
58
|
+
export type AskOptions = {
|
|
59
|
+
/**
|
|
60
|
+
* - Suppress logs or output.
|
|
61
|
+
*/
|
|
62
|
+
silent?: boolean | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* - Custom title for the prompt.
|
|
65
|
+
*/
|
|
66
|
+
title?: string | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* - Presentation hint (e.g., 'password', 'tree', 'markdown').
|
|
69
|
+
*/
|
|
70
|
+
hint?: string | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* - Default value if no input is provided.
|
|
73
|
+
*/
|
|
74
|
+
default?: any;
|
|
75
|
+
/**
|
|
76
|
+
* - Array of options for select inputs.
|
|
77
|
+
*/
|
|
78
|
+
options?: any[] | undefined;
|
|
79
|
+
/**
|
|
80
|
+
* - Localization dictionary/overrides.
|
|
81
|
+
*/
|
|
82
|
+
UI?: Record<string, any> | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* - Target specific component override.
|
|
85
|
+
*/
|
|
86
|
+
component?: string | undefined;
|
|
87
|
+
};
|
|
88
|
+
export type AskResponse = import("./index.js").AskResponse;
|
|
45
89
|
import Event from '@nan0web/event/oop';
|
|
46
90
|
import CancelError from './Error/CancelError.js';
|
package/types/core/Intent.d.ts
CHANGED
|
@@ -12,6 +12,76 @@ export function isModelSchema(schema: any): boolean;
|
|
|
12
12
|
* @returns {intent is Intent}
|
|
13
13
|
*/
|
|
14
14
|
export function validateIntent(intent: any): intent is Intent;
|
|
15
|
+
/**
|
|
16
|
+
* Create an ask intent.
|
|
17
|
+
*
|
|
18
|
+
* Two modes:
|
|
19
|
+
* ask('amount', { help: 'Enter amount', type: 'number' }) → single field
|
|
20
|
+
* ask('transfer', TransferMoneyModel) → full Model form
|
|
21
|
+
*
|
|
22
|
+
* @param {string} field - Field name or form name.
|
|
23
|
+
* @param {object | Function} schema - Field descriptor or Model-as-Schema class.
|
|
24
|
+
* @returns {AskIntent}
|
|
25
|
+
*/
|
|
26
|
+
export function ask(field: string, schema: object | Function): AskIntent;
|
|
27
|
+
/**
|
|
28
|
+
* @typedef {Object} ProgressOptions
|
|
29
|
+
* @property {number} [total] - Absolute total steps.
|
|
30
|
+
* @property {string} [id] - Progress tracking ID.
|
|
31
|
+
* @property {number} [width] - Width of the progress bar in terminal characters.
|
|
32
|
+
* @property {number} [fps] - Frames per second update rate limit.
|
|
33
|
+
* @property {string} [format] - Custom format string (e.g. '{time} {bar} {percent} {title}').
|
|
34
|
+
* @property {number} [columns] - Number of columns (terminal width).
|
|
35
|
+
* @property {boolean} [forceOneLine] - Prevent wrapping and truncate instead.
|
|
36
|
+
* @property {boolean|'success'|'error'} [stop] - Set to true to stop, or 'success'/'error' to stop with a status icon (for spinners).
|
|
37
|
+
*/
|
|
38
|
+
/**
|
|
39
|
+
* Create a progress intent.
|
|
40
|
+
* @param {string} message - Status message from Model (i18n static field value).
|
|
41
|
+
* @param {number} [value=0] - Progress value (current step or percentage).
|
|
42
|
+
* @param {ProgressOptions|number|string} [optionsOrTotalOrId] - Options object, or absolute total steps (number), or progress tracking ID (string).
|
|
43
|
+
* @param {string} [id='default'] - Progress ID (if total is provided).
|
|
44
|
+
* @returns {ProgressIntent}
|
|
45
|
+
*/
|
|
46
|
+
export function progress(message: string, value?: number, optionsOrTotalOrId?: ProgressOptions | number | string, id?: string): ProgressIntent;
|
|
47
|
+
export function log(level: any, message: any, data?: {}): {
|
|
48
|
+
type: string;
|
|
49
|
+
level: any;
|
|
50
|
+
message: any;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Create a render intent.
|
|
54
|
+
* @param {string} component - Component name (e.g. 'App.Layout.Header').
|
|
55
|
+
* @param {object} [props] - Static props for the component.
|
|
56
|
+
* @returns {RenderIntent}
|
|
57
|
+
*/
|
|
58
|
+
export function render(component: string, props?: object): RenderIntent;
|
|
59
|
+
/**
|
|
60
|
+
* Create a result intent.
|
|
61
|
+
* @param {*} data - The raw result data.
|
|
62
|
+
* @returns {ResultIntent}
|
|
63
|
+
*/
|
|
64
|
+
export function result(data: any): ResultIntent;
|
|
65
|
+
/**
|
|
66
|
+
* @typedef {Object} ShowData
|
|
67
|
+
* @property {any} [component]
|
|
68
|
+
* @property {import('@nan0web/types').Model} [model]
|
|
69
|
+
*/
|
|
70
|
+
/**
|
|
71
|
+
* Create a show intent.
|
|
72
|
+
* @param {string | any} message Message to display.
|
|
73
|
+
* @param {ShowLevel|ShowData} [level='info'] Level of message or additional data then `level = 'info'`.
|
|
74
|
+
* @param {ShowData} [data={}] Additional data to display.
|
|
75
|
+
* @returns {ShowIntent}
|
|
76
|
+
*/
|
|
77
|
+
export function show(message: string | any, level?: ShowLevel | ShowData, data?: ShowData): ShowIntent;
|
|
78
|
+
/**
|
|
79
|
+
* Create an agent intent to delegate a task to an AI subagent.
|
|
80
|
+
* @param {string} task - The instructional task for the AI agent.
|
|
81
|
+
* @param {AgentContext} [context={}] - Contextual data (files, errors, docs).
|
|
82
|
+
* @returns {AgentIntent}
|
|
83
|
+
*/
|
|
84
|
+
export function agent(task: string, context?: AgentContext): AgentIntent;
|
|
15
85
|
/**
|
|
16
86
|
* @typedef {Object} FieldSchema
|
|
17
87
|
* @property {string} help - Human-readable label / i18n key.
|
|
@@ -36,16 +106,29 @@ export function validateIntent(intent: any): intent is Intent;
|
|
|
36
106
|
* @typedef {Object} ProgressIntent
|
|
37
107
|
* @property {'progress'} type
|
|
38
108
|
* @property {number} [value] - Progress value (0-1).
|
|
39
|
-
* @property {
|
|
109
|
+
* @property {number} [total] - Absolute total (if value is absolute).
|
|
110
|
+
* @property {string} [id] - Progress ID for tracking by Adapter to calculate speed/eta.
|
|
40
111
|
* @property {string} message - Status message from Model (i18n static field value).
|
|
112
|
+
* @property {ProgressOptions} [options] - Additional options for progress intent.
|
|
113
|
+
*/
|
|
114
|
+
/**
|
|
115
|
+
* @typedef {'info' | 'warn' | 'error' | 'success'} ShowLevel
|
|
41
116
|
*/
|
|
117
|
+
/** @typedef {ShowLevel} LogLevel */
|
|
42
118
|
/**
|
|
43
|
-
* Model emits a
|
|
119
|
+
* Model emits a show message. No response expected.
|
|
44
120
|
* Message MUST come from the Model (i18n static field value).
|
|
121
|
+
* @typedef {Object} ShowIntent
|
|
122
|
+
* @property {'show'} type
|
|
123
|
+
* @property {ShowLevel} level
|
|
124
|
+
* @property {string} message - Show message from Model (i18n static field value).
|
|
125
|
+
*/
|
|
126
|
+
/**
|
|
127
|
+
* Model emits a log message intended for debugging/developer (Not UI).
|
|
45
128
|
* @typedef {Object} LogIntent
|
|
46
129
|
* @property {'log'} type
|
|
47
|
-
* @property {
|
|
48
|
-
* @property {string} message -
|
|
130
|
+
* @property {LogLevel} level
|
|
131
|
+
* @property {string} message - Internal log message.
|
|
49
132
|
*/
|
|
50
133
|
/**
|
|
51
134
|
* Final return value from the generator.
|
|
@@ -61,16 +144,56 @@ export function validateIntent(intent: any): intent is Intent;
|
|
|
61
144
|
* @property {string} component - Component name (e.g. 'App.Layout.Header').
|
|
62
145
|
* @property {object} props - Static props for the component.
|
|
63
146
|
*/
|
|
147
|
+
/**
|
|
148
|
+
* Contextual data and attachments for the AI subagent.
|
|
149
|
+
* @typedef {Object} AgentContext
|
|
150
|
+
* @property {string[]} [instructions] - List of instructions or guidelines (e.g. ['Use 1-char emojis only']).
|
|
151
|
+
* @property {Record<string, string>} [files] - Hash map of file paths to their string contents.
|
|
152
|
+
* @property {Record<string, any>} [data] - Any arbitrary JSON data (e.g. parsed errors, ASTs, metadata) useful for the task.
|
|
153
|
+
*/
|
|
154
|
+
/**
|
|
155
|
+
* Model delegates a task to an AI subagent. The Adapter should launch the agent
|
|
156
|
+
* with the provided task and context, and return the result. If the agent is skipped,
|
|
157
|
+
* it returns { success: false } but allows user to generate a prompt.
|
|
158
|
+
* @typedef {Object} AgentIntent
|
|
159
|
+
* @property {'agent'} type
|
|
160
|
+
* @property {string} task - The instructional task for the AI agent.
|
|
161
|
+
* @property {AgentContext} context - Contextual data, files, and instructions for the task.
|
|
162
|
+
* @property {() => string} toPrompt - Helper to format task and context as an LLM prompt.
|
|
163
|
+
*/
|
|
64
164
|
/**
|
|
65
165
|
* Union of all possible yielded intents.
|
|
66
|
-
* @typedef {AskIntent | ProgressIntent | LogIntent | RenderIntent
|
|
166
|
+
* @typedef {(AskIntent | ProgressIntent | LogIntent | ShowIntent | RenderIntent | AgentIntent | ResultIntent) & {
|
|
167
|
+
* $value?: any;
|
|
168
|
+
* $success?: boolean;
|
|
169
|
+
* $files?: Record<string, string>;
|
|
170
|
+
* $message?: string;
|
|
171
|
+
* }} Intent
|
|
67
172
|
*/
|
|
68
173
|
/**
|
|
69
174
|
* Response to an AskIntent. Adapter provides the collected value.
|
|
70
175
|
* The value MUST conform to the type described in the requested FieldSchema.
|
|
71
176
|
* @typedef {Object} AskResponse
|
|
72
177
|
* @property {*} value - The value matching schema.type (collected from user / LLM / test fixture).
|
|
73
|
-
* @property {boolean}
|
|
178
|
+
* @property {boolean} cancelled - Whether the user cancelled this interaction (e.g. pressed ESC).
|
|
179
|
+
* @property {string} [action] - The action identifier (e.g., 'submit', 'exit', 'back').
|
|
180
|
+
* @property {any} [body] - Additional payload or form data.
|
|
181
|
+
* @property {any} [form] - The form model instance (if applicable).
|
|
182
|
+
* @property {number} [index] - The selected index for lists/tables.
|
|
183
|
+
*/
|
|
184
|
+
/**
|
|
185
|
+
* Response to an AgentIntent.
|
|
186
|
+
* The underlying Adapter (Orchestrator) is responsible for communicating with the LLM,
|
|
187
|
+
* enforcing output formats (e.g. Unified Diff or Tool Calls like `updateFile`),
|
|
188
|
+
* and resolving common LLM hallucinations (like Grok truncating code with `// ...`).
|
|
189
|
+
*
|
|
190
|
+
* The Model (e.g. IconsAuditor) receives this clean, resolved response and does not
|
|
191
|
+
* need to parse Markdown or interpret diffs itself.
|
|
192
|
+
*
|
|
193
|
+
* @typedef {Object} AgentResponse
|
|
194
|
+
* @property {boolean} success - True if the agent successfully processed the task.
|
|
195
|
+
* @property {Record<string, string>} [files] - Hash map of fully resolved, updated file contents.
|
|
196
|
+
* @property {string} [message] - Optional summary or explanation returned by the AI.
|
|
74
197
|
*/
|
|
75
198
|
/**
|
|
76
199
|
* Special response that Adapters can send to abort the generator.
|
|
@@ -88,27 +211,49 @@ export function validateIntent(intent: any): intent is Intent;
|
|
|
88
211
|
*/
|
|
89
212
|
/**
|
|
90
213
|
* Union of all possible responses an Adapter can send back via iterator.next().
|
|
91
|
-
* @typedef {AskResponse | AbortResponse | undefined} IntentResponse
|
|
214
|
+
* @typedef {AskResponse | AgentResponse | AbortResponse | undefined} IntentResponse
|
|
92
215
|
*/
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
216
|
+
/**
|
|
217
|
+
* @typedef {'ask' | 'show' | 'progress' | 'render' | 'agent'} IntentType
|
|
218
|
+
*/
|
|
219
|
+
export const INTENT_TYPES: readonly ["ask", "progress", "show", "log", "render", "agent"];
|
|
220
|
+
export type ProgressOptions = {
|
|
221
|
+
/**
|
|
222
|
+
* - Absolute total steps.
|
|
223
|
+
*/
|
|
224
|
+
total?: number | undefined;
|
|
225
|
+
/**
|
|
226
|
+
* - Progress tracking ID.
|
|
227
|
+
*/
|
|
228
|
+
id?: string | undefined;
|
|
229
|
+
/**
|
|
230
|
+
* - Width of the progress bar in terminal characters.
|
|
231
|
+
*/
|
|
232
|
+
width?: number | undefined;
|
|
233
|
+
/**
|
|
234
|
+
* - Frames per second update rate limit.
|
|
235
|
+
*/
|
|
236
|
+
fps?: number | undefined;
|
|
237
|
+
/**
|
|
238
|
+
* - Custom format string (e.g. '{time} {bar} {percent} {title}').
|
|
239
|
+
*/
|
|
240
|
+
format?: string | undefined;
|
|
241
|
+
/**
|
|
242
|
+
* - Number of columns (terminal width).
|
|
243
|
+
*/
|
|
244
|
+
columns?: number | undefined;
|
|
245
|
+
/**
|
|
246
|
+
* - Prevent wrapping and truncate instead.
|
|
247
|
+
*/
|
|
248
|
+
forceOneLine?: boolean | undefined;
|
|
249
|
+
/**
|
|
250
|
+
* - Set to true to stop, or 'success'/'error' to stop with a status icon (for spinners).
|
|
251
|
+
*/
|
|
252
|
+
stop?: boolean | "error" | "success" | undefined;
|
|
108
253
|
};
|
|
109
|
-
export
|
|
110
|
-
|
|
111
|
-
|
|
254
|
+
export type ShowData = {
|
|
255
|
+
component?: any;
|
|
256
|
+
model?: import("@nan0web/types").Model | undefined;
|
|
112
257
|
};
|
|
113
258
|
export type FieldSchema = {
|
|
114
259
|
/**
|
|
@@ -169,23 +314,44 @@ export type ProgressIntent = {
|
|
|
169
314
|
*/
|
|
170
315
|
value?: number | undefined;
|
|
171
316
|
/**
|
|
172
|
-
* -
|
|
317
|
+
* - Absolute total (if value is absolute).
|
|
318
|
+
*/
|
|
319
|
+
total?: number | undefined;
|
|
320
|
+
/**
|
|
321
|
+
* - Progress ID for tracking by Adapter to calculate speed/eta.
|
|
173
322
|
*/
|
|
174
323
|
id?: string | undefined;
|
|
175
324
|
/**
|
|
176
325
|
* - Status message from Model (i18n static field value).
|
|
177
326
|
*/
|
|
178
327
|
message: string;
|
|
328
|
+
/**
|
|
329
|
+
* - Additional options for progress intent.
|
|
330
|
+
*/
|
|
331
|
+
options?: ProgressOptions | undefined;
|
|
179
332
|
};
|
|
333
|
+
export type ShowLevel = "info" | "warn" | "error" | "success";
|
|
334
|
+
export type LogLevel = ShowLevel;
|
|
180
335
|
/**
|
|
181
|
-
* Model emits a
|
|
336
|
+
* Model emits a show message. No response expected.
|
|
182
337
|
* Message MUST come from the Model (i18n static field value).
|
|
183
338
|
*/
|
|
339
|
+
export type ShowIntent = {
|
|
340
|
+
type: "show";
|
|
341
|
+
level: ShowLevel;
|
|
342
|
+
/**
|
|
343
|
+
* - Show message from Model (i18n static field value).
|
|
344
|
+
*/
|
|
345
|
+
message: string;
|
|
346
|
+
};
|
|
347
|
+
/**
|
|
348
|
+
* Model emits a log message intended for debugging/developer (Not UI).
|
|
349
|
+
*/
|
|
184
350
|
export type LogIntent = {
|
|
185
351
|
type: "log";
|
|
186
|
-
level:
|
|
352
|
+
level: LogLevel;
|
|
187
353
|
/**
|
|
188
|
-
* -
|
|
354
|
+
* - Internal log message.
|
|
189
355
|
*/
|
|
190
356
|
message: string;
|
|
191
357
|
};
|
|
@@ -214,10 +380,52 @@ export type RenderIntent = {
|
|
|
214
380
|
*/
|
|
215
381
|
props: object;
|
|
216
382
|
};
|
|
383
|
+
/**
|
|
384
|
+
* Contextual data and attachments for the AI subagent.
|
|
385
|
+
*/
|
|
386
|
+
export type AgentContext = {
|
|
387
|
+
/**
|
|
388
|
+
* - List of instructions or guidelines (e.g. ['Use 1-char emojis only']).
|
|
389
|
+
*/
|
|
390
|
+
instructions?: string[] | undefined;
|
|
391
|
+
/**
|
|
392
|
+
* - Hash map of file paths to their string contents.
|
|
393
|
+
*/
|
|
394
|
+
files?: Record<string, string> | undefined;
|
|
395
|
+
/**
|
|
396
|
+
* - Any arbitrary JSON data (e.g. parsed errors, ASTs, metadata) useful for the task.
|
|
397
|
+
*/
|
|
398
|
+
data?: Record<string, any> | undefined;
|
|
399
|
+
};
|
|
400
|
+
/**
|
|
401
|
+
* Model delegates a task to an AI subagent. The Adapter should launch the agent
|
|
402
|
+
* with the provided task and context, and return the result. If the agent is skipped,
|
|
403
|
+
* it returns { success: false } but allows user to generate a prompt.
|
|
404
|
+
*/
|
|
405
|
+
export type AgentIntent = {
|
|
406
|
+
type: "agent";
|
|
407
|
+
/**
|
|
408
|
+
* - The instructional task for the AI agent.
|
|
409
|
+
*/
|
|
410
|
+
task: string;
|
|
411
|
+
/**
|
|
412
|
+
* - Contextual data, files, and instructions for the task.
|
|
413
|
+
*/
|
|
414
|
+
context: AgentContext;
|
|
415
|
+
/**
|
|
416
|
+
* - Helper to format task and context as an LLM prompt.
|
|
417
|
+
*/
|
|
418
|
+
toPrompt: () => string;
|
|
419
|
+
};
|
|
217
420
|
/**
|
|
218
421
|
* Union of all possible yielded intents.
|
|
219
422
|
*/
|
|
220
|
-
export type Intent = AskIntent | ProgressIntent | LogIntent | RenderIntent
|
|
423
|
+
export type Intent = (AskIntent | ProgressIntent | LogIntent | ShowIntent | RenderIntent | AgentIntent | ResultIntent) & {
|
|
424
|
+
$value?: any;
|
|
425
|
+
$success?: boolean;
|
|
426
|
+
$files?: Record<string, string>;
|
|
427
|
+
$message?: string;
|
|
428
|
+
};
|
|
221
429
|
/**
|
|
222
430
|
* Response to an AskIntent. Adapter provides the collected value.
|
|
223
431
|
* The value MUST conform to the type described in the requested FieldSchema.
|
|
@@ -230,7 +438,46 @@ export type AskResponse = {
|
|
|
230
438
|
/**
|
|
231
439
|
* - Whether the user cancelled this interaction (e.g. pressed ESC).
|
|
232
440
|
*/
|
|
233
|
-
cancelled
|
|
441
|
+
cancelled: boolean;
|
|
442
|
+
/**
|
|
443
|
+
* - The action identifier (e.g., 'submit', 'exit', 'back').
|
|
444
|
+
*/
|
|
445
|
+
action?: string | undefined;
|
|
446
|
+
/**
|
|
447
|
+
* - Additional payload or form data.
|
|
448
|
+
*/
|
|
449
|
+
body?: any;
|
|
450
|
+
/**
|
|
451
|
+
* - The form model instance (if applicable).
|
|
452
|
+
*/
|
|
453
|
+
form?: any;
|
|
454
|
+
/**
|
|
455
|
+
* - The selected index for lists/tables.
|
|
456
|
+
*/
|
|
457
|
+
index?: number | undefined;
|
|
458
|
+
};
|
|
459
|
+
/**
|
|
460
|
+
* Response to an AgentIntent.
|
|
461
|
+
* The underlying Adapter (Orchestrator) is responsible for communicating with the LLM,
|
|
462
|
+
* enforcing output formats (e.g. Unified Diff or Tool Calls like `updateFile`),
|
|
463
|
+
* and resolving common LLM hallucinations (like Grok truncating code with `// ...`).
|
|
464
|
+
*
|
|
465
|
+
* The Model (e.g. IconsAuditor) receives this clean, resolved response and does not
|
|
466
|
+
* need to parse Markdown or interpret diffs itself.
|
|
467
|
+
*/
|
|
468
|
+
export type AgentResponse = {
|
|
469
|
+
/**
|
|
470
|
+
* - True if the agent successfully processed the task.
|
|
471
|
+
*/
|
|
472
|
+
success: boolean;
|
|
473
|
+
/**
|
|
474
|
+
* - Hash map of fully resolved, updated file contents.
|
|
475
|
+
*/
|
|
476
|
+
files?: Record<string, string> | undefined;
|
|
477
|
+
/**
|
|
478
|
+
* - Optional summary or explanation returned by the AI.
|
|
479
|
+
*/
|
|
480
|
+
message?: string | undefined;
|
|
234
481
|
};
|
|
235
482
|
/**
|
|
236
483
|
* Special response that Adapters can send to abort the generator.
|
|
@@ -255,4 +502,5 @@ export type AbortResponse = {
|
|
|
255
502
|
/**
|
|
256
503
|
* Union of all possible responses an Adapter can send back via iterator.next().
|
|
257
504
|
*/
|
|
258
|
-
export type IntentResponse = AskResponse | AbortResponse | undefined;
|
|
505
|
+
export type IntentResponse = AskResponse | AgentResponse | AbortResponse | undefined;
|
|
506
|
+
export type IntentType = "ask" | "show" | "progress" | "render" | "agent";
|
|
@@ -61,9 +61,9 @@ export default class UiMessage extends Message {
|
|
|
61
61
|
*/
|
|
62
62
|
constructor(input?: any);
|
|
63
63
|
/** @type {string} */
|
|
64
|
-
type: string;
|
|
65
|
-
/** @type {string} */
|
|
66
64
|
id: string;
|
|
65
|
+
/** @type {string} */
|
|
66
|
+
type: string;
|
|
67
67
|
/**
|
|
68
68
|
* Validates the message body against its schema.
|
|
69
69
|
*
|