@taui-standard/core 0.0.1
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 +27 -0
- package/dist/index.d.mts +14 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +61 -0
- package/dist/index.mjs +36 -0
- package/package.json +26 -0
- package/src/index.ts +40 -0
- package/tsconfig.json +15 -0
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# TAUI Core
|
|
2
|
+
|
|
3
|
+
The core state management and event normalization logic for the **Terminal Agent UI (TAUI)** standard.
|
|
4
|
+
|
|
5
|
+
**Author: Tariq Shams**
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
- **Stateless Runtime**: Manages the `TAUIDocument` state.
|
|
9
|
+
- **Event Normalization**: Transforms raw adapter inputs into schema-compliant `TAUIEvent` objects.
|
|
10
|
+
- **Validation-First**: All state changes are strictly validated against `@taui-standard/validator`.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
```bash
|
|
14
|
+
npm install @taui-standard/core
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
```typescript
|
|
19
|
+
import { TAUIRuntime } from '@taui-standard/core';
|
|
20
|
+
|
|
21
|
+
const runtime = new TAUIRuntime();
|
|
22
|
+
runtime.setDocument(mySpecDoc);
|
|
23
|
+
|
|
24
|
+
runtime.onEvent((event) => {
|
|
25
|
+
console.log('Agent received event:', event);
|
|
26
|
+
});
|
|
27
|
+
```
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TAUIEvent, TAUIDocument } from '@taui-standard/validator';
|
|
2
|
+
|
|
3
|
+
type TAUIEventHandler = (event: TAUIEvent) => void;
|
|
4
|
+
declare class TAUIRuntime {
|
|
5
|
+
private currentDocument;
|
|
6
|
+
private eventHandlers;
|
|
7
|
+
constructor(initialDocument?: TAUIDocument);
|
|
8
|
+
setDocument(doc: unknown): void;
|
|
9
|
+
getDocument(): TAUIDocument | null;
|
|
10
|
+
onEvent(handler: TAUIEventHandler): () => void;
|
|
11
|
+
dispatchRawEvent(rawEvent: unknown): void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { type TAUIEventHandler, TAUIRuntime };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TAUIEvent, TAUIDocument } from '@taui-standard/validator';
|
|
2
|
+
|
|
3
|
+
type TAUIEventHandler = (event: TAUIEvent) => void;
|
|
4
|
+
declare class TAUIRuntime {
|
|
5
|
+
private currentDocument;
|
|
6
|
+
private eventHandlers;
|
|
7
|
+
constructor(initialDocument?: TAUIDocument);
|
|
8
|
+
setDocument(doc: unknown): void;
|
|
9
|
+
getDocument(): TAUIDocument | null;
|
|
10
|
+
onEvent(handler: TAUIEventHandler): () => void;
|
|
11
|
+
dispatchRawEvent(rawEvent: unknown): void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { type TAUIEventHandler, TAUIRuntime };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
TAUIRuntime: () => TAUIRuntime
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
var import_validator = require("@taui-standard/validator");
|
|
27
|
+
var TAUIRuntime = class {
|
|
28
|
+
currentDocument = null;
|
|
29
|
+
eventHandlers = /* @__PURE__ */ new Set();
|
|
30
|
+
constructor(initialDocument) {
|
|
31
|
+
if (initialDocument) {
|
|
32
|
+
this.setDocument(initialDocument);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
setDocument(doc) {
|
|
36
|
+
const result = (0, import_validator.validateDocument)(doc);
|
|
37
|
+
if (!result.success) {
|
|
38
|
+
throw new Error(`Invalid TAUIDocument: ${JSON.stringify(result.error)}`);
|
|
39
|
+
}
|
|
40
|
+
this.currentDocument = result.data;
|
|
41
|
+
}
|
|
42
|
+
getDocument() {
|
|
43
|
+
return this.currentDocument;
|
|
44
|
+
}
|
|
45
|
+
onEvent(handler) {
|
|
46
|
+
this.eventHandlers.add(handler);
|
|
47
|
+
return () => this.eventHandlers.delete(handler);
|
|
48
|
+
}
|
|
49
|
+
dispatchRawEvent(rawEvent) {
|
|
50
|
+
const result = (0, import_validator.validateEvent)(rawEvent);
|
|
51
|
+
if (result.success) {
|
|
52
|
+
this.eventHandlers.forEach((handler) => handler(result.data));
|
|
53
|
+
} else {
|
|
54
|
+
console.warn("Invalid raw event suppressed:", result.error);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
59
|
+
0 && (module.exports = {
|
|
60
|
+
TAUIRuntime
|
|
61
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { validateDocument, validateEvent } from "@taui-standard/validator";
|
|
3
|
+
var TAUIRuntime = class {
|
|
4
|
+
currentDocument = null;
|
|
5
|
+
eventHandlers = /* @__PURE__ */ new Set();
|
|
6
|
+
constructor(initialDocument) {
|
|
7
|
+
if (initialDocument) {
|
|
8
|
+
this.setDocument(initialDocument);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
setDocument(doc) {
|
|
12
|
+
const result = validateDocument(doc);
|
|
13
|
+
if (!result.success) {
|
|
14
|
+
throw new Error(`Invalid TAUIDocument: ${JSON.stringify(result.error)}`);
|
|
15
|
+
}
|
|
16
|
+
this.currentDocument = result.data;
|
|
17
|
+
}
|
|
18
|
+
getDocument() {
|
|
19
|
+
return this.currentDocument;
|
|
20
|
+
}
|
|
21
|
+
onEvent(handler) {
|
|
22
|
+
this.eventHandlers.add(handler);
|
|
23
|
+
return () => this.eventHandlers.delete(handler);
|
|
24
|
+
}
|
|
25
|
+
dispatchRawEvent(rawEvent) {
|
|
26
|
+
const result = validateEvent(rawEvent);
|
|
27
|
+
if (result.success) {
|
|
28
|
+
this.eventHandlers.forEach((handler) => handler(result.data));
|
|
29
|
+
} else {
|
|
30
|
+
console.warn("Invalid raw event suppressed:", result.error);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
export {
|
|
35
|
+
TAUIRuntime
|
|
36
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@taui-standard/core",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Core runtime logic for Terminal Agent UI (TAUI)",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
13
|
+
"test": "vitest run",
|
|
14
|
+
"lint": "eslint src"
|
|
15
|
+
},
|
|
16
|
+
"author": "Tariq Shams",
|
|
17
|
+
"license": "Apache-2.0",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@taui-standard/validator": "^0.0.1"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"tsup": "^8.0.1",
|
|
23
|
+
"typescript": "^5.3.3",
|
|
24
|
+
"vitest": "^1.2.1"
|
|
25
|
+
}
|
|
26
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { TAUIDocument, TAUIEvent, validateDocument, validateEvent } from '@taui-standard/validator';
|
|
2
|
+
|
|
3
|
+
export type TAUIEventHandler = (event: TAUIEvent) => void;
|
|
4
|
+
|
|
5
|
+
export class TAUIRuntime {
|
|
6
|
+
private currentDocument: TAUIDocument | null = null;
|
|
7
|
+
private eventHandlers: Set<TAUIEventHandler> = new Set();
|
|
8
|
+
|
|
9
|
+
constructor(initialDocument?: TAUIDocument) {
|
|
10
|
+
if (initialDocument) {
|
|
11
|
+
this.setDocument(initialDocument);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public setDocument(doc: unknown): void {
|
|
16
|
+
const result = validateDocument(doc);
|
|
17
|
+
if (!result.success) {
|
|
18
|
+
throw new Error(`Invalid TAUIDocument: ${JSON.stringify(result.error)}`);
|
|
19
|
+
}
|
|
20
|
+
this.currentDocument = result.data;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public getDocument(): TAUIDocument | null {
|
|
24
|
+
return this.currentDocument;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public onEvent(handler: TAUIEventHandler): () => void {
|
|
28
|
+
this.eventHandlers.add(handler);
|
|
29
|
+
return () => this.eventHandlers.delete(handler);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public dispatchRawEvent(rawEvent: unknown): void {
|
|
33
|
+
const result = validateEvent(rawEvent);
|
|
34
|
+
if (result.success) {
|
|
35
|
+
this.eventHandlers.forEach(handler => handler(result.data));
|
|
36
|
+
} else {
|
|
37
|
+
console.warn('Invalid raw event suppressed:', result.error);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"outDir": "./dist",
|
|
8
|
+
"rootDir": "./src",
|
|
9
|
+
"strict": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true
|
|
13
|
+
},
|
|
14
|
+
"include": ["src/**/*"]
|
|
15
|
+
}
|