@ai-gui/plugin-artifact 0.4.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/CHANGELOG.md +18 -0
- package/LICENSE +21 -0
- package/README.md +68 -0
- package/dist/index.cjs +1027 -0
- package/dist/index.d.cts +103 -0
- package/dist/index.d.ts +103 -0
- package/dist/index.js +1010 -0
- package/package.json +60 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { AIGuiPlugin } from "@ai-gui/core";
|
|
2
|
+
|
|
3
|
+
//#region src/index.d.ts
|
|
4
|
+
type ArtifactKind = "text" | "code" | "markdown" | "json";
|
|
5
|
+
interface ArtifactDefinition {
|
|
6
|
+
id: string;
|
|
7
|
+
title: string;
|
|
8
|
+
filename: string;
|
|
9
|
+
kind: ArtifactKind;
|
|
10
|
+
language?: string;
|
|
11
|
+
content: string;
|
|
12
|
+
}
|
|
13
|
+
interface ArtifactCreateCommand {
|
|
14
|
+
version: 1;
|
|
15
|
+
operationId: string;
|
|
16
|
+
artifact: ArtifactDefinition;
|
|
17
|
+
}
|
|
18
|
+
interface ArtifactUpdateCommand {
|
|
19
|
+
version: 1;
|
|
20
|
+
operationId: string;
|
|
21
|
+
id: string;
|
|
22
|
+
baseRevision: number;
|
|
23
|
+
content: string;
|
|
24
|
+
title?: string;
|
|
25
|
+
filename?: string;
|
|
26
|
+
language?: string;
|
|
27
|
+
}
|
|
28
|
+
interface ArtifactRecord extends ArtifactDefinition {
|
|
29
|
+
revision: number;
|
|
30
|
+
}
|
|
31
|
+
interface ArtifactOperationReceipt {
|
|
32
|
+
operationId: string;
|
|
33
|
+
command: "create" | "update";
|
|
34
|
+
record: ArtifactRecord;
|
|
35
|
+
}
|
|
36
|
+
interface ArtifactSnapshotReceipt {
|
|
37
|
+
operationId: string;
|
|
38
|
+
canonical: string;
|
|
39
|
+
receipt: ArtifactOperationReceipt;
|
|
40
|
+
}
|
|
41
|
+
interface ArtifactSnapshot {
|
|
42
|
+
version: 1;
|
|
43
|
+
records: ArtifactRecord[];
|
|
44
|
+
receipts: ArtifactSnapshotReceipt[];
|
|
45
|
+
}
|
|
46
|
+
interface ArtifactStoreOptions {
|
|
47
|
+
maxArtifacts?: number;
|
|
48
|
+
maxArtifactBytes?: number;
|
|
49
|
+
maxTotalBytes?: number;
|
|
50
|
+
}
|
|
51
|
+
interface ArtifactPluginOptions {
|
|
52
|
+
store?: ArtifactStore;
|
|
53
|
+
}
|
|
54
|
+
type ArtifactParseResult<T> = {
|
|
55
|
+
valid: true;
|
|
56
|
+
data: T;
|
|
57
|
+
} | {
|
|
58
|
+
valid: false;
|
|
59
|
+
issues: string[];
|
|
60
|
+
};
|
|
61
|
+
type ArtifactListener = (record: ArtifactRecord | undefined) => void;
|
|
62
|
+
type ArtifactStoreListener = (records: readonly ArtifactRecord[]) => void;
|
|
63
|
+
declare class ArtifactError extends Error {}
|
|
64
|
+
declare class ArtifactValidationError extends ArtifactError {}
|
|
65
|
+
declare class ArtifactLimitError extends ArtifactError {}
|
|
66
|
+
declare class ArtifactNotFoundError extends ArtifactError {}
|
|
67
|
+
declare class ArtifactConflictError extends ArtifactError {}
|
|
68
|
+
declare class ArtifactOperationConflictError extends ArtifactError {}
|
|
69
|
+
declare class ArtifactSnapshotError extends ArtifactError {}
|
|
70
|
+
declare class ArtifactStore {
|
|
71
|
+
private records;
|
|
72
|
+
private receipts;
|
|
73
|
+
private listeners;
|
|
74
|
+
private allListeners;
|
|
75
|
+
private epoch;
|
|
76
|
+
private readonly limits;
|
|
77
|
+
constructor(options?: ArtifactStoreOptions);
|
|
78
|
+
create(command: ArtifactCreateCommand): ArtifactOperationReceipt;
|
|
79
|
+
update(command: ArtifactUpdateCommand): ArtifactOperationReceipt;
|
|
80
|
+
get(id: string): ArtifactRecord | undefined;
|
|
81
|
+
list(): readonly ArtifactRecord[];
|
|
82
|
+
subscribe(id: string, listener: ArtifactListener): () => void;
|
|
83
|
+
subscribeAll(listener: ArtifactStoreListener): () => void;
|
|
84
|
+
delete(id: string): boolean;
|
|
85
|
+
clear(): void;
|
|
86
|
+
snapshot(): ArtifactSnapshot;
|
|
87
|
+
restore(snapshot: unknown): void;
|
|
88
|
+
captureMutationEpoch(): number;
|
|
89
|
+
private checkReceipt;
|
|
90
|
+
private assertCapacity;
|
|
91
|
+
private mutated;
|
|
92
|
+
private notifyOne;
|
|
93
|
+
private notifyAll;
|
|
94
|
+
}
|
|
95
|
+
declare function parseArtifactCreate(source: string): ArtifactParseResult<ArtifactCreateCommand>;
|
|
96
|
+
declare function parseArtifactUpdate(source: string): ArtifactParseResult<ArtifactUpdateCommand>;
|
|
97
|
+
declare function serializeArtifactCreate(command: ArtifactCreateCommand): string;
|
|
98
|
+
declare function serializeArtifactUpdate(command: ArtifactUpdateCommand): string;
|
|
99
|
+
declare function artifactPromptSpec(store?: ArtifactStore): string;
|
|
100
|
+
declare function artifact(options?: ArtifactPluginOptions): AIGuiPlugin;
|
|
101
|
+
declare function mountArtifactWorkspace(host: HTMLElement, store: ArtifactStore): () => void;
|
|
102
|
+
declare const artifactCss: string; //#endregion
|
|
103
|
+
export { ArtifactConflictError, ArtifactCreateCommand, ArtifactDefinition, ArtifactError, ArtifactKind, ArtifactLimitError, ArtifactListener, ArtifactNotFoundError, ArtifactOperationConflictError, ArtifactOperationReceipt, ArtifactParseResult, ArtifactPluginOptions, ArtifactRecord, ArtifactSnapshot, ArtifactSnapshotError, ArtifactSnapshotReceipt, ArtifactStore, ArtifactStoreListener, ArtifactStoreOptions, ArtifactUpdateCommand, ArtifactValidationError, artifact, artifactCss, artifactPromptSpec, mountArtifactWorkspace, parseArtifactCreate, parseArtifactUpdate, serializeArtifactCreate, serializeArtifactUpdate };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { AIGuiPlugin } from "@ai-gui/core";
|
|
2
|
+
|
|
3
|
+
//#region src/index.d.ts
|
|
4
|
+
type ArtifactKind = "text" | "code" | "markdown" | "json";
|
|
5
|
+
interface ArtifactDefinition {
|
|
6
|
+
id: string;
|
|
7
|
+
title: string;
|
|
8
|
+
filename: string;
|
|
9
|
+
kind: ArtifactKind;
|
|
10
|
+
language?: string;
|
|
11
|
+
content: string;
|
|
12
|
+
}
|
|
13
|
+
interface ArtifactCreateCommand {
|
|
14
|
+
version: 1;
|
|
15
|
+
operationId: string;
|
|
16
|
+
artifact: ArtifactDefinition;
|
|
17
|
+
}
|
|
18
|
+
interface ArtifactUpdateCommand {
|
|
19
|
+
version: 1;
|
|
20
|
+
operationId: string;
|
|
21
|
+
id: string;
|
|
22
|
+
baseRevision: number;
|
|
23
|
+
content: string;
|
|
24
|
+
title?: string;
|
|
25
|
+
filename?: string;
|
|
26
|
+
language?: string;
|
|
27
|
+
}
|
|
28
|
+
interface ArtifactRecord extends ArtifactDefinition {
|
|
29
|
+
revision: number;
|
|
30
|
+
}
|
|
31
|
+
interface ArtifactOperationReceipt {
|
|
32
|
+
operationId: string;
|
|
33
|
+
command: "create" | "update";
|
|
34
|
+
record: ArtifactRecord;
|
|
35
|
+
}
|
|
36
|
+
interface ArtifactSnapshotReceipt {
|
|
37
|
+
operationId: string;
|
|
38
|
+
canonical: string;
|
|
39
|
+
receipt: ArtifactOperationReceipt;
|
|
40
|
+
}
|
|
41
|
+
interface ArtifactSnapshot {
|
|
42
|
+
version: 1;
|
|
43
|
+
records: ArtifactRecord[];
|
|
44
|
+
receipts: ArtifactSnapshotReceipt[];
|
|
45
|
+
}
|
|
46
|
+
interface ArtifactStoreOptions {
|
|
47
|
+
maxArtifacts?: number;
|
|
48
|
+
maxArtifactBytes?: number;
|
|
49
|
+
maxTotalBytes?: number;
|
|
50
|
+
}
|
|
51
|
+
interface ArtifactPluginOptions {
|
|
52
|
+
store?: ArtifactStore;
|
|
53
|
+
}
|
|
54
|
+
type ArtifactParseResult<T> = {
|
|
55
|
+
valid: true;
|
|
56
|
+
data: T;
|
|
57
|
+
} | {
|
|
58
|
+
valid: false;
|
|
59
|
+
issues: string[];
|
|
60
|
+
};
|
|
61
|
+
type ArtifactListener = (record: ArtifactRecord | undefined) => void;
|
|
62
|
+
type ArtifactStoreListener = (records: readonly ArtifactRecord[]) => void;
|
|
63
|
+
declare class ArtifactError extends Error {}
|
|
64
|
+
declare class ArtifactValidationError extends ArtifactError {}
|
|
65
|
+
declare class ArtifactLimitError extends ArtifactError {}
|
|
66
|
+
declare class ArtifactNotFoundError extends ArtifactError {}
|
|
67
|
+
declare class ArtifactConflictError extends ArtifactError {}
|
|
68
|
+
declare class ArtifactOperationConflictError extends ArtifactError {}
|
|
69
|
+
declare class ArtifactSnapshotError extends ArtifactError {}
|
|
70
|
+
declare class ArtifactStore {
|
|
71
|
+
private records;
|
|
72
|
+
private receipts;
|
|
73
|
+
private listeners;
|
|
74
|
+
private allListeners;
|
|
75
|
+
private epoch;
|
|
76
|
+
private readonly limits;
|
|
77
|
+
constructor(options?: ArtifactStoreOptions);
|
|
78
|
+
create(command: ArtifactCreateCommand): ArtifactOperationReceipt;
|
|
79
|
+
update(command: ArtifactUpdateCommand): ArtifactOperationReceipt;
|
|
80
|
+
get(id: string): ArtifactRecord | undefined;
|
|
81
|
+
list(): readonly ArtifactRecord[];
|
|
82
|
+
subscribe(id: string, listener: ArtifactListener): () => void;
|
|
83
|
+
subscribeAll(listener: ArtifactStoreListener): () => void;
|
|
84
|
+
delete(id: string): boolean;
|
|
85
|
+
clear(): void;
|
|
86
|
+
snapshot(): ArtifactSnapshot;
|
|
87
|
+
restore(snapshot: unknown): void;
|
|
88
|
+
captureMutationEpoch(): number;
|
|
89
|
+
private checkReceipt;
|
|
90
|
+
private assertCapacity;
|
|
91
|
+
private mutated;
|
|
92
|
+
private notifyOne;
|
|
93
|
+
private notifyAll;
|
|
94
|
+
}
|
|
95
|
+
declare function parseArtifactCreate(source: string): ArtifactParseResult<ArtifactCreateCommand>;
|
|
96
|
+
declare function parseArtifactUpdate(source: string): ArtifactParseResult<ArtifactUpdateCommand>;
|
|
97
|
+
declare function serializeArtifactCreate(command: ArtifactCreateCommand): string;
|
|
98
|
+
declare function serializeArtifactUpdate(command: ArtifactUpdateCommand): string;
|
|
99
|
+
declare function artifactPromptSpec(store?: ArtifactStore): string;
|
|
100
|
+
declare function artifact(options?: ArtifactPluginOptions): AIGuiPlugin;
|
|
101
|
+
declare function mountArtifactWorkspace(host: HTMLElement, store: ArtifactStore): () => void;
|
|
102
|
+
declare const artifactCss: string; //#endregion
|
|
103
|
+
export { ArtifactConflictError, ArtifactCreateCommand, ArtifactDefinition, ArtifactError, ArtifactKind, ArtifactLimitError, ArtifactListener, ArtifactNotFoundError, ArtifactOperationConflictError, ArtifactOperationReceipt, ArtifactParseResult, ArtifactPluginOptions, ArtifactRecord, ArtifactSnapshot, ArtifactSnapshotError, ArtifactSnapshotReceipt, ArtifactStore, ArtifactStoreListener, ArtifactStoreOptions, ArtifactUpdateCommand, ArtifactValidationError, artifact, artifactCss, artifactPromptSpec, mountArtifactWorkspace, parseArtifactCreate, parseArtifactUpdate, serializeArtifactCreate, serializeArtifactUpdate };
|