@baguette-studios/kernl-ui-core 0.1.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.
@@ -0,0 +1,97 @@
1
+ import type { AgentAsset, AgentInFlightSubmitMode, AgentNavRef } from "@baguette-studios/kernl-core";
2
+ export type AgentRenderable = unknown;
3
+ export type AgentChatRole = "system" | "user" | "assistant" | "tool";
4
+ export type AgentStatus = "idle" | "running" | "waiting" | "blocked" | "error" | "complete" | (string & {});
5
+ export type AgentTone = "neutral" | "active" | "waiting" | "success" | "danger";
6
+ export type AgentRisk = "low" | "medium" | "high";
7
+ export interface AgentCommand<TContent = AgentRenderable> {
8
+ id: string;
9
+ label: string;
10
+ description?: TContent | undefined;
11
+ shortcut?: string | undefined;
12
+ disabled?: boolean | undefined;
13
+ run?: ((input?: string) => void | Promise<void>) | undefined;
14
+ }
15
+ export interface AgentQuickAction<TContent = AgentRenderable> {
16
+ id: string;
17
+ label: string;
18
+ prompt: string;
19
+ description?: TContent | undefined;
20
+ scopeId?: string | undefined;
21
+ disabled?: boolean | undefined;
22
+ run?: ((action: AgentQuickAction<TContent>) => void | Promise<void>) | undefined;
23
+ }
24
+ export interface AgentChatMessage<TContent = AgentRenderable> {
25
+ id: string;
26
+ role: AgentChatRole;
27
+ content: TContent;
28
+ nav?: AgentNavRef[] | undefined;
29
+ assets?: readonly AgentAsset[] | undefined;
30
+ agentId?: string | undefined;
31
+ agentName?: TContent | undefined;
32
+ createdAt?: Date | string | number | undefined;
33
+ status?: AgentStatus | undefined;
34
+ }
35
+ export interface AgentChatThread<TContent = AgentRenderable> {
36
+ id: string;
37
+ title: TContent;
38
+ description?: TContent | undefined;
39
+ updatedAt?: Date | string | number | undefined;
40
+ messageCount?: number | undefined;
41
+ status?: AgentStatus | undefined;
42
+ statusLabel?: TContent | undefined;
43
+ active?: boolean | undefined;
44
+ waitingForInput?: boolean | undefined;
45
+ hasUnseenUpdates?: boolean | undefined;
46
+ }
47
+ export interface AgentActionRequest<TContent = AgentRenderable> {
48
+ id: string;
49
+ title: string;
50
+ description?: TContent | undefined;
51
+ command?: string | undefined;
52
+ subject?: string | undefined;
53
+ risk?: AgentRisk | undefined;
54
+ status?: "pending" | "approved" | "rejected" | "running" | undefined;
55
+ requestedBy?: string | undefined;
56
+ requestedAt?: Date | string | number | undefined;
57
+ metadata?: Record<string, TContent> | undefined;
58
+ onApprove?: ((action: AgentActionRequest<TContent>) => void | Promise<void>) | undefined;
59
+ onReject?: ((action: AgentActionRequest<TContent>) => void | Promise<void>) | undefined;
60
+ }
61
+ export interface AgentActivityItem<TContent = AgentRenderable> {
62
+ id: string;
63
+ title: string;
64
+ detail?: TContent | undefined;
65
+ status?: AgentStatus | undefined;
66
+ actor?: string | undefined;
67
+ at?: Date | string | number | undefined;
68
+ metadata?: TContent | undefined;
69
+ }
70
+ export type AgentPromptSubmitResult = void | boolean | {
71
+ accepted?: boolean | undefined;
72
+ };
73
+ export type AgentPromptSubmitOptions = {
74
+ mode?: AgentInFlightSubmitMode | undefined;
75
+ submittedWhileRunning?: boolean | undefined;
76
+ assets?: readonly AgentAsset[] | undefined;
77
+ };
78
+ export interface AgentUiSnapshot<TContent = AgentRenderable> {
79
+ status: AgentStatus;
80
+ statusLabel?: TContent | undefined;
81
+ statusDetail?: TContent | undefined;
82
+ goal?: TContent | undefined;
83
+ currentTask?: TContent | undefined;
84
+ model?: TContent | undefined;
85
+ commands: AgentCommand<TContent>[];
86
+ quickActions: AgentQuickAction<TContent>[];
87
+ actions: AgentActionRequest<TContent>[];
88
+ activity: AgentActivityItem<TContent>[];
89
+ onCommand?: ((command: string, input?: string) => void | Promise<void>) | undefined;
90
+ onPrompt?: ((prompt: string, options?: AgentPromptSubmitOptions) => AgentPromptSubmitResult | Promise<AgentPromptSubmitResult>) | undefined;
91
+ onApproveAction?: ((action: AgentActionRequest<TContent>) => void | Promise<void>) | undefined;
92
+ onRejectAction?: ((action: AgentActionRequest<TContent>) => void | Promise<void>) | undefined;
93
+ }
94
+ export interface AgentComponentProps {
95
+ className?: string | undefined;
96
+ }
97
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAErG,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC;AAEtC,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;AAErE,MAAM,MAAM,WAAW,GACnB,MAAM,GACN,SAAS,GACT,SAAS,GACT,SAAS,GACT,OAAO,GACP,UAAU,GACV,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEhF,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAElD,MAAM,WAAW,YAAY,CAAC,QAAQ,GAAG,eAAe;IACtD,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC/B,GAAG,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC;CAC9D;AAED,MAAM,WAAW,gBAAgB,CAAC,QAAQ,GAAG,eAAe;IAC1D,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,QAAQ,GAA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CAAC,uBAAuB,CAAC,CAAC,GAAG,SAAS,CAAC;IAC5I,eAAe,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,kBAAkB,CAAC,QAAQ,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC;IAC/F,cAAc,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,kBAAkB,CAAC,QAAQ,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC;CAC/F;AAED,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC"}
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ import type { AgentActionRequest, AgentStatus, AgentTone } from "./types";
2
+ export declare function cx(...parts: Array<string | false | null | undefined>): string;
3
+ export declare function statusTone(status: AgentStatus | undefined): AgentTone;
4
+ export declare function humanizeStatus(status: AgentStatus | undefined): string;
5
+ export declare function riskTone<TContent>(action: AgentActionRequest<TContent> | undefined): AgentTone;
6
+ export declare function formatTimestamp(value: Date | string | number | undefined): string | undefined;
7
+ export declare function formatRelativeAge(value: Date | string | number | undefined, now?: number): string | undefined;
8
+ export declare function firstPendingAction<TContent>(actions: AgentActionRequest<TContent>[]): AgentActionRequest<TContent> | undefined;
9
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAE1E,wBAAgB,EAAE,CAAC,GAAG,KAAK,EAAE,KAAK,CAAC,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,MAAM,CAE7E;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,SAAS,CAcrE;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,MAAM,CAQtE;AAED,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,kBAAkB,CAAC,QAAQ,CAAC,GAAG,SAAS,GAAG,SAAS,CAW9F;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAc7F;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,EAAE,GAAG,SAAa,GAAG,MAAM,GAAG,SAAS,CA+BjH;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EACzC,OAAO,EAAE,kBAAkB,CAAC,QAAQ,CAAC,EAAE,GACtC,kBAAkB,CAAC,QAAQ,CAAC,GAAG,SAAS,CAE1C"}
package/dist/utils.js ADDED
@@ -0,0 +1,80 @@
1
+ export function cx(...parts) {
2
+ return parts.filter(Boolean).join(" ");
3
+ }
4
+ export function statusTone(status) {
5
+ switch (status) {
6
+ case "running":
7
+ return "active";
8
+ case "waiting":
9
+ case "blocked":
10
+ return "waiting";
11
+ case "complete":
12
+ return "success";
13
+ case "error":
14
+ return "danger";
15
+ default:
16
+ return "neutral";
17
+ }
18
+ }
19
+ export function humanizeStatus(status) {
20
+ if (!status) {
21
+ return "Idle";
22
+ }
23
+ return status
24
+ .replace(/[-_]+/g, " ")
25
+ .replace(/\b\w/g, (letter) => letter.toUpperCase());
26
+ }
27
+ export function riskTone(action) {
28
+ switch (action?.risk) {
29
+ case "high":
30
+ return "danger";
31
+ case "medium":
32
+ return "waiting";
33
+ case "low":
34
+ return "success";
35
+ default:
36
+ return "neutral";
37
+ }
38
+ }
39
+ export function formatTimestamp(value) {
40
+ if (!value) {
41
+ return undefined;
42
+ }
43
+ const date = value instanceof Date ? value : new Date(value);
44
+ if (Number.isNaN(date.getTime())) {
45
+ return String(value);
46
+ }
47
+ return new Intl.DateTimeFormat(undefined, {
48
+ hour: "2-digit",
49
+ minute: "2-digit"
50
+ }).format(date);
51
+ }
52
+ export function formatRelativeAge(value, now = Date.now()) {
53
+ if (!value) {
54
+ return undefined;
55
+ }
56
+ const date = value instanceof Date ? value : new Date(value);
57
+ if (Number.isNaN(date.getTime())) {
58
+ return String(value);
59
+ }
60
+ const seconds = Math.max(0, Math.floor((now - date.getTime()) / 1000));
61
+ if (seconds < 60) {
62
+ return `${seconds}s`;
63
+ }
64
+ const minutes = Math.floor(seconds / 60);
65
+ if (minutes < 60) {
66
+ return `${minutes}m`;
67
+ }
68
+ const hours = Math.floor(minutes / 60);
69
+ if (hours < 24) {
70
+ return `${hours}h`;
71
+ }
72
+ const days = Math.floor(hours / 24);
73
+ if (days < 30) {
74
+ return `${days}d`;
75
+ }
76
+ return `${Math.max(1, Math.floor(days / 30))}mo`;
77
+ }
78
+ export function firstPendingAction(actions) {
79
+ return actions.find((action) => !action.status || action.status === "pending") ?? actions[0];
80
+ }
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@baguette-studios/kernl-ui-core",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "private": false,
6
+ "description": "Framework-neutral UI model, theme tokens, and shared styles for kernl.",
7
+ "license": "ISC",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/Jules-Astier/agent-context.git",
11
+ "directory": "packages/ui-core"
12
+ },
13
+ "homepage": "https://github.com/Jules-Astier/agent-context#readme",
14
+ "bugs": { "url": "https://github.com/Jules-Astier/agent-context/issues" },
15
+ "publishConfig": { "access": "public", "registry": "https://registry.npmjs.org/" },
16
+ "sideEffects": ["*.css", "**/*.css"],
17
+ "main": "./dist/index.js",
18
+ "types": "./dist/index.d.ts",
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/index.d.ts",
22
+ "import": "./dist/index.js"
23
+ },
24
+ "./theme": {
25
+ "types": "./dist/theme.d.ts",
26
+ "import": "./dist/theme.js"
27
+ },
28
+ "./types": {
29
+ "types": "./dist/types.d.ts",
30
+ "import": "./dist/types.js"
31
+ },
32
+ "./derive": {
33
+ "types": "./dist/derive.d.ts",
34
+ "import": "./dist/derive.js"
35
+ },
36
+ "./icons": {
37
+ "types": "./dist/icons.d.ts",
38
+ "import": "./dist/icons.js"
39
+ },
40
+ "./utils": {
41
+ "types": "./dist/utils.d.ts",
42
+ "import": "./dist/utils.js"
43
+ },
44
+ "./styles.css": "./dist/styles.css",
45
+ "./theme.css": "./dist/theme.css",
46
+ "./tailwind.css": "./dist/tailwind.css"
47
+ },
48
+ "files": [
49
+ "dist",
50
+ "README.md",
51
+ "LICENSE"
52
+ ],
53
+ "scripts": {
54
+ "build": "tsc -p tsconfig.json && cp src/styles.css src/theme.css src/tailwind.css dist/",
55
+ "typecheck": "tsc -p tsconfig.json --noEmit",
56
+ "test": "cd ../.. && vitest run packages/ui-core/src"
57
+ },
58
+ "dependencies": {
59
+ "@baguette-studios/kernl-core": "0.1.0"
60
+ },
61
+ "devDependencies": {
62
+ "typescript": "^5.8.3",
63
+ "vitest": "^4.1.9"
64
+ }
65
+ }