@nan0web/ui 1.10.0 → 1.11.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 +61 -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 +3 -1
- package/src/core/Intent.js +200 -17
- 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 +1 -0
- package/src/domain/Content.js +196 -0
- package/src/domain/Document.js +17 -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 +401 -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 +21 -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 +3 -3
- package/src/testing/SnapshotRunner.js +22 -0
- package/src/testing/SpecAdapter.js +115 -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 +2 -1
- package/types/core/Intent.d.ts +209 -31
- package/types/core/Message/Message.d.ts +2 -2
- package/types/core/Message/OutputMessage.d.ts +0 -2
- package/types/core/index.d.ts +1 -0
- package/types/domain/Content.d.ts +340 -0
- package/types/domain/Document.d.ts +21 -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 +19 -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 +57 -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
|
};
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @class InputAdapter
|
|
5
5
|
* @extends Event
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export class InputAdapter extends Event {
|
|
8
8
|
static CancelError: typeof CancelError;
|
|
9
9
|
/** @returns {typeof CancelError} */
|
|
10
10
|
get CancelError(): typeof CancelError;
|
|
@@ -42,5 +42,6 @@ export default class InputAdapter extends Event {
|
|
|
42
42
|
value: string | null;
|
|
43
43
|
}>;
|
|
44
44
|
}
|
|
45
|
+
export default InputAdapter;
|
|
45
46
|
import Event from '@nan0web/event/oop';
|
|
46
47
|
import CancelError from './Error/CancelError.js';
|
package/types/core/Intent.d.ts
CHANGED
|
@@ -12,6 +12,65 @@ 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
|
+
* Create a progress intent.
|
|
29
|
+
* @param {string} message - Status message from Model (i18n static field value).
|
|
30
|
+
* @param {number} [value=0] - Progress value (current step or percentage).
|
|
31
|
+
* @param {number|string} [totalOrId] - Absolute total steps (number) OR progress tracking ID (string).
|
|
32
|
+
* @param {string} [id='default'] - Progress ID (if total is provided).
|
|
33
|
+
* @returns {ProgressIntent}
|
|
34
|
+
*/
|
|
35
|
+
export function progress(message: string, value?: number, totalOrId?: number | string, id?: string): ProgressIntent;
|
|
36
|
+
export function log(level: any, message: any, data?: {}): {
|
|
37
|
+
type: string;
|
|
38
|
+
level: any;
|
|
39
|
+
message: any;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Create a render intent.
|
|
43
|
+
* @param {string} component - Component name (e.g. 'App.Layout.Header').
|
|
44
|
+
* @param {object} [props] - Static props for the component.
|
|
45
|
+
* @returns {RenderIntent}
|
|
46
|
+
*/
|
|
47
|
+
export function render(component: string, props?: object): RenderIntent;
|
|
48
|
+
/**
|
|
49
|
+
* Create a result intent.
|
|
50
|
+
* @param {*} data - The raw result data.
|
|
51
|
+
* @returns {ResultIntent}
|
|
52
|
+
*/
|
|
53
|
+
export function result(data: any): ResultIntent;
|
|
54
|
+
/**
|
|
55
|
+
* @typedef {Object} ShowData
|
|
56
|
+
* @property {any} [component]
|
|
57
|
+
* @property {import('@nan0web/types').Model} [model]
|
|
58
|
+
*/
|
|
59
|
+
/**
|
|
60
|
+
* Create a show intent.
|
|
61
|
+
* @param {string | any} message Message to display.
|
|
62
|
+
* @param {ShowLevel|ShowData} [level='info'] Level of message or additional data then `level = 'info'`.
|
|
63
|
+
* @param {ShowData} [data={}] Additional data to display.
|
|
64
|
+
* @returns {ShowIntent}
|
|
65
|
+
*/
|
|
66
|
+
export function show(message: string | any, level?: ShowLevel | ShowData, data?: ShowData): ShowIntent;
|
|
67
|
+
/**
|
|
68
|
+
* Create an agent intent to delegate a task to an AI subagent.
|
|
69
|
+
* @param {string} task - The instructional task for the AI agent.
|
|
70
|
+
* @param {AgentContext} [context={}] - Contextual data (files, errors, docs).
|
|
71
|
+
* @returns {AgentIntent}
|
|
72
|
+
*/
|
|
73
|
+
export function agent(task: string, context?: AgentContext): AgentIntent;
|
|
15
74
|
/**
|
|
16
75
|
* @typedef {Object} FieldSchema
|
|
17
76
|
* @property {string} help - Human-readable label / i18n key.
|
|
@@ -36,16 +95,28 @@ export function validateIntent(intent: any): intent is Intent;
|
|
|
36
95
|
* @typedef {Object} ProgressIntent
|
|
37
96
|
* @property {'progress'} type
|
|
38
97
|
* @property {number} [value] - Progress value (0-1).
|
|
39
|
-
* @property {
|
|
98
|
+
* @property {number} [total] - Absolute total (if value is absolute).
|
|
99
|
+
* @property {string} [id] - Progress ID for tracking by Adapter to calculate speed/eta.
|
|
40
100
|
* @property {string} message - Status message from Model (i18n static field value).
|
|
41
101
|
*/
|
|
42
102
|
/**
|
|
43
|
-
*
|
|
103
|
+
* @typedef {'info' | 'warn' | 'error' | 'success'} ShowLevel
|
|
104
|
+
*/
|
|
105
|
+
/** @typedef {ShowLevel} LogLevel */
|
|
106
|
+
/**
|
|
107
|
+
* Model emits a show message. No response expected.
|
|
44
108
|
* Message MUST come from the Model (i18n static field value).
|
|
109
|
+
* @typedef {Object} ShowIntent
|
|
110
|
+
* @property {'show'} type
|
|
111
|
+
* @property {ShowLevel} level
|
|
112
|
+
* @property {string} message - Show message from Model (i18n static field value).
|
|
113
|
+
*/
|
|
114
|
+
/**
|
|
115
|
+
* Model emits a log message intended for debugging/developer (Not UI).
|
|
45
116
|
* @typedef {Object} LogIntent
|
|
46
117
|
* @property {'log'} type
|
|
47
|
-
* @property {
|
|
48
|
-
* @property {string} message -
|
|
118
|
+
* @property {LogLevel} level
|
|
119
|
+
* @property {string} message - Internal log message.
|
|
49
120
|
*/
|
|
50
121
|
/**
|
|
51
122
|
* Final return value from the generator.
|
|
@@ -61,9 +132,31 @@ export function validateIntent(intent: any): intent is Intent;
|
|
|
61
132
|
* @property {string} component - Component name (e.g. 'App.Layout.Header').
|
|
62
133
|
* @property {object} props - Static props for the component.
|
|
63
134
|
*/
|
|
135
|
+
/**
|
|
136
|
+
* Contextual data and attachments for the AI subagent.
|
|
137
|
+
* @typedef {Object} AgentContext
|
|
138
|
+
* @property {string[]} [instructions] - List of instructions or guidelines (e.g. ['Use 1-char emojis only']).
|
|
139
|
+
* @property {Record<string, string>} [files] - Hash map of file paths to their string contents.
|
|
140
|
+
* @property {Record<string, any>} [data] - Any arbitrary JSON data (e.g. parsed errors, ASTs, metadata) useful for the task.
|
|
141
|
+
*/
|
|
142
|
+
/**
|
|
143
|
+
* Model delegates a task to an AI subagent. The Adapter should launch the agent
|
|
144
|
+
* with the provided task and context, and return the result. If the agent is skipped,
|
|
145
|
+
* it returns { success: false } but allows user to generate a prompt.
|
|
146
|
+
* @typedef {Object} AgentIntent
|
|
147
|
+
* @property {'agent'} type
|
|
148
|
+
* @property {string} task - The instructional task for the AI agent.
|
|
149
|
+
* @property {AgentContext} context - Contextual data, files, and instructions for the task.
|
|
150
|
+
* @property {() => string} toPrompt - Helper to format task and context as an LLM prompt.
|
|
151
|
+
*/
|
|
64
152
|
/**
|
|
65
153
|
* Union of all possible yielded intents.
|
|
66
|
-
* @typedef {AskIntent | ProgressIntent | LogIntent | RenderIntent
|
|
154
|
+
* @typedef {(AskIntent | ProgressIntent | LogIntent | ShowIntent | RenderIntent | AgentIntent | ResultIntent) & {
|
|
155
|
+
* $value?: any;
|
|
156
|
+
* $success?: boolean;
|
|
157
|
+
* $files?: Record<string, string>;
|
|
158
|
+
* $message?: string;
|
|
159
|
+
* }} Intent
|
|
67
160
|
*/
|
|
68
161
|
/**
|
|
69
162
|
* Response to an AskIntent. Adapter provides the collected value.
|
|
@@ -72,6 +165,20 @@ export function validateIntent(intent: any): intent is Intent;
|
|
|
72
165
|
* @property {*} value - The value matching schema.type (collected from user / LLM / test fixture).
|
|
73
166
|
* @property {boolean} [cancelled] - Whether the user cancelled this interaction (e.g. pressed ESC).
|
|
74
167
|
*/
|
|
168
|
+
/**
|
|
169
|
+
* Response to an AgentIntent.
|
|
170
|
+
* The underlying Adapter (Orchestrator) is responsible for communicating with the LLM,
|
|
171
|
+
* enforcing output formats (e.g. Unified Diff or Tool Calls like `updateFile`),
|
|
172
|
+
* and resolving common LLM hallucinations (like Grok truncating code with `// ...`).
|
|
173
|
+
*
|
|
174
|
+
* The Model (e.g. IconsAuditor) receives this clean, resolved response and does not
|
|
175
|
+
* need to parse Markdown or interpret diffs itself.
|
|
176
|
+
*
|
|
177
|
+
* @typedef {Object} AgentResponse
|
|
178
|
+
* @property {boolean} success - True if the agent successfully processed the task.
|
|
179
|
+
* @property {Record<string, string>} [files] - Hash map of fully resolved, updated file contents.
|
|
180
|
+
* @property {string} [message] - Optional summary or explanation returned by the AI.
|
|
181
|
+
*/
|
|
75
182
|
/**
|
|
76
183
|
* Special response that Adapters can send to abort the generator.
|
|
77
184
|
*
|
|
@@ -88,27 +195,15 @@ export function validateIntent(intent: any): intent is Intent;
|
|
|
88
195
|
*/
|
|
89
196
|
/**
|
|
90
197
|
* Union of all possible responses an Adapter can send back via iterator.next().
|
|
91
|
-
* @typedef {AskResponse | AbortResponse | undefined} IntentResponse
|
|
198
|
+
* @typedef {AskResponse | AgentResponse | AbortResponse | undefined} IntentResponse
|
|
92
199
|
*/
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
type: string;
|
|
101
|
-
level: any;
|
|
102
|
-
message: any;
|
|
103
|
-
};
|
|
104
|
-
export function render(component: any, props?: {}): {
|
|
105
|
-
type: string;
|
|
106
|
-
component: any;
|
|
107
|
-
props: {};
|
|
108
|
-
};
|
|
109
|
-
export function result(data: any): {
|
|
110
|
-
type: string;
|
|
111
|
-
data: any;
|
|
200
|
+
/**
|
|
201
|
+
* @typedef {'ask' | 'show' | 'progress' | 'render' | 'agent'} IntentType
|
|
202
|
+
*/
|
|
203
|
+
export const INTENT_TYPES: readonly ["ask", "progress", "show", "log", "render", "agent"];
|
|
204
|
+
export type ShowData = {
|
|
205
|
+
component?: any;
|
|
206
|
+
model?: import("@nan0web/types").Model | undefined;
|
|
112
207
|
};
|
|
113
208
|
export type FieldSchema = {
|
|
114
209
|
/**
|
|
@@ -169,7 +264,11 @@ export type ProgressIntent = {
|
|
|
169
264
|
*/
|
|
170
265
|
value?: number | undefined;
|
|
171
266
|
/**
|
|
172
|
-
* -
|
|
267
|
+
* - Absolute total (if value is absolute).
|
|
268
|
+
*/
|
|
269
|
+
total?: number | undefined;
|
|
270
|
+
/**
|
|
271
|
+
* - Progress ID for tracking by Adapter to calculate speed/eta.
|
|
173
272
|
*/
|
|
174
273
|
id?: string | undefined;
|
|
175
274
|
/**
|
|
@@ -177,15 +276,28 @@ export type ProgressIntent = {
|
|
|
177
276
|
*/
|
|
178
277
|
message: string;
|
|
179
278
|
};
|
|
279
|
+
export type ShowLevel = "info" | "warn" | "error" | "success";
|
|
280
|
+
export type LogLevel = ShowLevel;
|
|
180
281
|
/**
|
|
181
|
-
* Model emits a
|
|
282
|
+
* Model emits a show message. No response expected.
|
|
182
283
|
* Message MUST come from the Model (i18n static field value).
|
|
183
284
|
*/
|
|
285
|
+
export type ShowIntent = {
|
|
286
|
+
type: "show";
|
|
287
|
+
level: ShowLevel;
|
|
288
|
+
/**
|
|
289
|
+
* - Show message from Model (i18n static field value).
|
|
290
|
+
*/
|
|
291
|
+
message: string;
|
|
292
|
+
};
|
|
293
|
+
/**
|
|
294
|
+
* Model emits a log message intended for debugging/developer (Not UI).
|
|
295
|
+
*/
|
|
184
296
|
export type LogIntent = {
|
|
185
297
|
type: "log";
|
|
186
|
-
level:
|
|
298
|
+
level: LogLevel;
|
|
187
299
|
/**
|
|
188
|
-
* -
|
|
300
|
+
* - Internal log message.
|
|
189
301
|
*/
|
|
190
302
|
message: string;
|
|
191
303
|
};
|
|
@@ -214,10 +326,52 @@ export type RenderIntent = {
|
|
|
214
326
|
*/
|
|
215
327
|
props: object;
|
|
216
328
|
};
|
|
329
|
+
/**
|
|
330
|
+
* Contextual data and attachments for the AI subagent.
|
|
331
|
+
*/
|
|
332
|
+
export type AgentContext = {
|
|
333
|
+
/**
|
|
334
|
+
* - List of instructions or guidelines (e.g. ['Use 1-char emojis only']).
|
|
335
|
+
*/
|
|
336
|
+
instructions?: string[] | undefined;
|
|
337
|
+
/**
|
|
338
|
+
* - Hash map of file paths to their string contents.
|
|
339
|
+
*/
|
|
340
|
+
files?: Record<string, string> | undefined;
|
|
341
|
+
/**
|
|
342
|
+
* - Any arbitrary JSON data (e.g. parsed errors, ASTs, metadata) useful for the task.
|
|
343
|
+
*/
|
|
344
|
+
data?: Record<string, any> | undefined;
|
|
345
|
+
};
|
|
346
|
+
/**
|
|
347
|
+
* Model delegates a task to an AI subagent. The Adapter should launch the agent
|
|
348
|
+
* with the provided task and context, and return the result. If the agent is skipped,
|
|
349
|
+
* it returns { success: false } but allows user to generate a prompt.
|
|
350
|
+
*/
|
|
351
|
+
export type AgentIntent = {
|
|
352
|
+
type: "agent";
|
|
353
|
+
/**
|
|
354
|
+
* - The instructional task for the AI agent.
|
|
355
|
+
*/
|
|
356
|
+
task: string;
|
|
357
|
+
/**
|
|
358
|
+
* - Contextual data, files, and instructions for the task.
|
|
359
|
+
*/
|
|
360
|
+
context: AgentContext;
|
|
361
|
+
/**
|
|
362
|
+
* - Helper to format task and context as an LLM prompt.
|
|
363
|
+
*/
|
|
364
|
+
toPrompt: () => string;
|
|
365
|
+
};
|
|
217
366
|
/**
|
|
218
367
|
* Union of all possible yielded intents.
|
|
219
368
|
*/
|
|
220
|
-
export type Intent = AskIntent | ProgressIntent | LogIntent | RenderIntent
|
|
369
|
+
export type Intent = (AskIntent | ProgressIntent | LogIntent | ShowIntent | RenderIntent | AgentIntent | ResultIntent) & {
|
|
370
|
+
$value?: any;
|
|
371
|
+
$success?: boolean;
|
|
372
|
+
$files?: Record<string, string>;
|
|
373
|
+
$message?: string;
|
|
374
|
+
};
|
|
221
375
|
/**
|
|
222
376
|
* Response to an AskIntent. Adapter provides the collected value.
|
|
223
377
|
* The value MUST conform to the type described in the requested FieldSchema.
|
|
@@ -232,6 +386,29 @@ export type AskResponse = {
|
|
|
232
386
|
*/
|
|
233
387
|
cancelled?: boolean | undefined;
|
|
234
388
|
};
|
|
389
|
+
/**
|
|
390
|
+
* Response to an AgentIntent.
|
|
391
|
+
* The underlying Adapter (Orchestrator) is responsible for communicating with the LLM,
|
|
392
|
+
* enforcing output formats (e.g. Unified Diff or Tool Calls like `updateFile`),
|
|
393
|
+
* and resolving common LLM hallucinations (like Grok truncating code with `// ...`).
|
|
394
|
+
*
|
|
395
|
+
* The Model (e.g. IconsAuditor) receives this clean, resolved response and does not
|
|
396
|
+
* need to parse Markdown or interpret diffs itself.
|
|
397
|
+
*/
|
|
398
|
+
export type AgentResponse = {
|
|
399
|
+
/**
|
|
400
|
+
* - True if the agent successfully processed the task.
|
|
401
|
+
*/
|
|
402
|
+
success: boolean;
|
|
403
|
+
/**
|
|
404
|
+
* - Hash map of fully resolved, updated file contents.
|
|
405
|
+
*/
|
|
406
|
+
files?: Record<string, string> | undefined;
|
|
407
|
+
/**
|
|
408
|
+
* - Optional summary or explanation returned by the AI.
|
|
409
|
+
*/
|
|
410
|
+
message?: string | undefined;
|
|
411
|
+
};
|
|
235
412
|
/**
|
|
236
413
|
* Special response that Adapters can send to abort the generator.
|
|
237
414
|
*
|
|
@@ -255,4 +432,5 @@ export type AbortResponse = {
|
|
|
255
432
|
/**
|
|
256
433
|
* Union of all possible responses an Adapter can send back via iterator.next().
|
|
257
434
|
*/
|
|
258
|
-
export type IntentResponse = AskResponse | AbortResponse | undefined;
|
|
435
|
+
export type IntentResponse = AskResponse | AgentResponse | AbortResponse | undefined;
|
|
436
|
+
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
|
*
|
package/types/core/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export { default as UiAdapter } from "./UiAdapter.js";
|
|
|
7
7
|
export { IntentErrorModel } from "./IntentErrorModel.js";
|
|
8
8
|
export { runGenerator } from "./GeneratorRunner.js";
|
|
9
9
|
export { MaskHandler } from "./MaskHandler.js";
|
|
10
|
+
export { LayoutModel } from "../domain/LayoutModel.js";
|
|
10
11
|
import UIStream from './Stream.js';
|
|
11
12
|
import StreamEntry from './StreamEntry.js';
|
|
12
13
|
import UIForm from './Form/Form.js';
|