@absolutejs/artifacts 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/LICENSE +90 -0
- package/README.md +128 -0
- package/dist/index.js +296 -0
- package/dist/manifest.js +5999 -0
- package/dist/manifest.json +100 -0
- package/dist/src/index.d.ts +14 -0
- package/dist/src/manifest.d.ts +9 -0
- package/dist/src/registry.d.ts +17 -0
- package/dist/src/renderers.d.ts +17 -0
- package/dist/src/service.d.ts +31 -0
- package/dist/src/store.d.ts +8 -0
- package/dist/src/tools.d.ts +17 -0
- package/dist/src/types.d.ts +55 -0
- package/package.json +58 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
{
|
|
2
|
+
"contract": 1,
|
|
3
|
+
"identity": {
|
|
4
|
+
"accent": "#8b5cf6",
|
|
5
|
+
"category": "ai",
|
|
6
|
+
"description": "Typed, versioned artifacts for AI products: define structured kinds once, then compose storage, revisions, rendering, publishing, and agent tools without coupling the contract to a database or hosting layer.",
|
|
7
|
+
"docsUrl": "https://github.com/absolutejs/artifacts",
|
|
8
|
+
"name": "@absolutejs/artifacts",
|
|
9
|
+
"tagline": "Give everything your AI makes a real lifecycle."
|
|
10
|
+
},
|
|
11
|
+
"settings": {
|
|
12
|
+
"type": "object",
|
|
13
|
+
"properties": {}
|
|
14
|
+
},
|
|
15
|
+
"slots": {
|
|
16
|
+
"service": {
|
|
17
|
+
"configPath": "$self",
|
|
18
|
+
"contract": "artifacts/service",
|
|
19
|
+
"description": "The host-configured artifact service",
|
|
20
|
+
"known": [],
|
|
21
|
+
"required": true
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"wiring": [
|
|
25
|
+
{
|
|
26
|
+
"description": "Define structured artifact kinds, provide a store, and create the lifecycle service. Add a publisher only when your host supports public access.",
|
|
27
|
+
"id": "default",
|
|
28
|
+
"server": {
|
|
29
|
+
"code": "const artifactRegistry = defineArtifactRegistry({\n\tpage: {\n\t\tcapabilities: ['archive', 'edit', 'preview', 'publish'],\n\t\tcontent: Type.Object({ blocks: Type.Array(Type.Unknown()) }),\n\t\tlabel: 'Page'\n\t}\n});\n\nconst artifactStore = createMemoryArtifactStore();\nconst artifactService = createArtifactService({\n\tregistry: artifactRegistry,\n\tstore: artifactStore\n});",
|
|
30
|
+
"imports": [
|
|
31
|
+
{
|
|
32
|
+
"from": "@absolutejs/artifacts",
|
|
33
|
+
"names": [
|
|
34
|
+
"createArtifactService",
|
|
35
|
+
"createMemoryArtifactStore",
|
|
36
|
+
"defineArtifactRegistry"
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"from": "@sinclair/typebox",
|
|
41
|
+
"names": [
|
|
42
|
+
"Type"
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
"placement": "module-scope"
|
|
47
|
+
},
|
|
48
|
+
"title": "Define artifact kinds and lifecycle"
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
"tools": {
|
|
52
|
+
"artifact_get": {
|
|
53
|
+
"annotations": {
|
|
54
|
+
"readOnlyHint": true
|
|
55
|
+
},
|
|
56
|
+
"description": "Open one artifact owned by a user.",
|
|
57
|
+
"input": {
|
|
58
|
+
"type": "object",
|
|
59
|
+
"required": [
|
|
60
|
+
"artifactId",
|
|
61
|
+
"ownerId"
|
|
62
|
+
],
|
|
63
|
+
"properties": {
|
|
64
|
+
"artifactId": {
|
|
65
|
+
"minLength": 1,
|
|
66
|
+
"type": "string"
|
|
67
|
+
},
|
|
68
|
+
"ownerId": {
|
|
69
|
+
"minLength": 1,
|
|
70
|
+
"type": "string"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"kind": "runtime"
|
|
75
|
+
},
|
|
76
|
+
"artifact_list": {
|
|
77
|
+
"annotations": {
|
|
78
|
+
"readOnlyHint": true
|
|
79
|
+
},
|
|
80
|
+
"description": "List artifacts owned by a user.",
|
|
81
|
+
"input": {
|
|
82
|
+
"type": "object",
|
|
83
|
+
"required": [
|
|
84
|
+
"ownerId"
|
|
85
|
+
],
|
|
86
|
+
"properties": {
|
|
87
|
+
"kind": {
|
|
88
|
+
"minLength": 1,
|
|
89
|
+
"type": "string"
|
|
90
|
+
},
|
|
91
|
+
"ownerId": {
|
|
92
|
+
"minLength": 1,
|
|
93
|
+
"type": "string"
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"kind": "runtime"
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@absolutejs/artifacts` — the typed lifecycle for things an AI makes.
|
|
3
|
+
*
|
|
4
|
+
* Hosts define artifact kinds with structured content schemas, then compose a
|
|
5
|
+
* storage adapter, optional publisher, renderers, and agent tools. The package
|
|
6
|
+
* owns validation, revisions, lifecycle semantics, and contracts; the host
|
|
7
|
+
* retains authorization, persistence, URLs, UI, and delivery policy.
|
|
8
|
+
*/
|
|
9
|
+
export { defineArtifactRegistry, type ArtifactContent, type ArtifactKindDefinition, type ArtifactKindDefinitions, type ArtifactRegistry, } from "./registry";
|
|
10
|
+
export { createArtifactRendererRegistry, type ArtifactRenderer, type ArtifactRendererRegistry, type ArtifactRenderResult, } from "./renderers";
|
|
11
|
+
export { createArtifactService, type ArtifactPublisher, type ArtifactService, type ArtifactServiceOptions, } from "./service";
|
|
12
|
+
export { createMemoryArtifactStore, type ArtifactStore } from "./store";
|
|
13
|
+
export { createArtifactTools, type ArtifactToolDefinition, type ArtifactToolMap, type ArtifactToolOptions, } from "./tools";
|
|
14
|
+
export { ARTIFACT_STATUSES, ArtifactError, type ArtifactCapability, type ArtifactCreateInput, type ArtifactErrorCode, type ArtifactListQuery, type ArtifactProvenance, type ArtifactPublication, type ArtifactRecord, type ArtifactStatus, type ArtifactUpdateInput, } from "./types";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const manifest: import("@absolutejs/manifest").PackageManifest<Record<string, never>, {
|
|
2
|
+
archive: (ownerId: string, artifactId: string) => Promise<import("./types").ArtifactRecord>;
|
|
3
|
+
create: (ownerId: string, input: import("./types").ArtifactCreateInput) => Promise<import("./types").ArtifactRecord>;
|
|
4
|
+
get: (ownerId: string, artifactId: string) => Promise<import("./types").ArtifactRecord>;
|
|
5
|
+
list: (ownerId: string, query?: import("./types").ArtifactListQuery) => Promise<import("./types").ArtifactRecord[]>;
|
|
6
|
+
publish: (ownerId: string, artifactId: string) => Promise<import("./types").ArtifactRecord>;
|
|
7
|
+
unpublish: (ownerId: string, artifactId: string) => Promise<import("./types").ArtifactRecord>;
|
|
8
|
+
update: (ownerId: string, artifactId: string, input: import("./types").ArtifactUpdateInput) => Promise<import("./types").ArtifactRecord>;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Static, TSchema } from "@sinclair/typebox";
|
|
2
|
+
import { type ArtifactCapability } from "./types";
|
|
3
|
+
export type ArtifactKindDefinition<TContent extends TSchema = TSchema> = {
|
|
4
|
+
capabilities?: ArtifactCapability[];
|
|
5
|
+
content: TContent;
|
|
6
|
+
description?: string;
|
|
7
|
+
label: string;
|
|
8
|
+
schemaVersion?: number;
|
|
9
|
+
};
|
|
10
|
+
export type ArtifactKindDefinitions = Record<string, ArtifactKindDefinition<TSchema>>;
|
|
11
|
+
export type ArtifactContent<TDefinitions extends ArtifactKindDefinitions, TKind extends keyof TDefinitions> = TDefinitions[TKind] extends ArtifactKindDefinition<infer TSchemaValue> ? Static<TSchemaValue> : never;
|
|
12
|
+
export type ArtifactRegistry<TDefinitions extends ArtifactKindDefinitions> = {
|
|
13
|
+
definitions: TDefinitions;
|
|
14
|
+
kindNames: Array<keyof TDefinitions & string>;
|
|
15
|
+
parse<TKind extends keyof TDefinitions & string>(kind: TKind, content: unknown): ArtifactContent<TDefinitions, TKind>;
|
|
16
|
+
};
|
|
17
|
+
export declare const defineArtifactRegistry: <const TDefinitions extends ArtifactKindDefinitions>(definitions: TDefinitions) => ArtifactRegistry<TDefinitions>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ArtifactRecord } from "./types";
|
|
2
|
+
export type ArtifactRenderResult = {
|
|
3
|
+
body: Uint8Array | string;
|
|
4
|
+
filename?: string;
|
|
5
|
+
mediaType: string;
|
|
6
|
+
};
|
|
7
|
+
export type ArtifactRenderer = {
|
|
8
|
+
format: string;
|
|
9
|
+
kind: string;
|
|
10
|
+
render(artifact: ArtifactRecord): Promise<ArtifactRenderResult>;
|
|
11
|
+
};
|
|
12
|
+
export declare const createArtifactRendererRegistry: (initial?: ArtifactRenderer[]) => {
|
|
13
|
+
formatsFor: (kind: string) => string[];
|
|
14
|
+
register: (renderer: ArtifactRenderer) => void;
|
|
15
|
+
render: (artifact: ArtifactRecord, format: string) => Promise<ArtifactRenderResult>;
|
|
16
|
+
};
|
|
17
|
+
export type ArtifactRendererRegistry = ReturnType<typeof createArtifactRendererRegistry>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ArtifactKindDefinitions, ArtifactRegistry } from "./registry";
|
|
2
|
+
import type { ArtifactStore } from "./store";
|
|
3
|
+
import { type ArtifactCreateInput, type ArtifactListQuery, type ArtifactRecord, type ArtifactUpdateInput } from "./types";
|
|
4
|
+
export type ArtifactPublisher = {
|
|
5
|
+
publish(artifact: ArtifactRecord, options: {
|
|
6
|
+
idempotencyKey: string;
|
|
7
|
+
}): Promise<{
|
|
8
|
+
id: string;
|
|
9
|
+
url: string;
|
|
10
|
+
}>;
|
|
11
|
+
unpublish(artifact: ArtifactRecord, options: {
|
|
12
|
+
idempotencyKey: string;
|
|
13
|
+
}): Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
export type ArtifactServiceOptions<TDefinitions extends ArtifactKindDefinitions = ArtifactKindDefinitions> = {
|
|
16
|
+
clock?: () => Date;
|
|
17
|
+
idFactory?: () => string;
|
|
18
|
+
publisher?: ArtifactPublisher;
|
|
19
|
+
registry: ArtifactRegistry<TDefinitions>;
|
|
20
|
+
store: ArtifactStore;
|
|
21
|
+
};
|
|
22
|
+
export type ArtifactService = ReturnType<typeof createArtifactService>;
|
|
23
|
+
export declare const createArtifactService: <TDefinitions extends ArtifactKindDefinitions>(options: ArtifactServiceOptions<TDefinitions>) => {
|
|
24
|
+
archive: (ownerId: string, artifactId: string) => Promise<ArtifactRecord>;
|
|
25
|
+
create: (ownerId: string, input: ArtifactCreateInput) => Promise<ArtifactRecord>;
|
|
26
|
+
get: (ownerId: string, artifactId: string) => Promise<ArtifactRecord>;
|
|
27
|
+
list: (ownerId: string, query?: ArtifactListQuery) => Promise<ArtifactRecord[]>;
|
|
28
|
+
publish: (ownerId: string, artifactId: string) => Promise<ArtifactRecord>;
|
|
29
|
+
unpublish: (ownerId: string, artifactId: string) => Promise<ArtifactRecord>;
|
|
30
|
+
update: (ownerId: string, artifactId: string, input: ArtifactUpdateInput) => Promise<ArtifactRecord>;
|
|
31
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ArtifactListQuery, ArtifactRecord } from "./types";
|
|
2
|
+
export type ArtifactStore = {
|
|
3
|
+
create(record: ArtifactRecord): Promise<void>;
|
|
4
|
+
get(ownerId: string, artifactId: string): Promise<ArtifactRecord | null>;
|
|
5
|
+
list(ownerId: string, query?: ArtifactListQuery): Promise<ArtifactRecord[]>;
|
|
6
|
+
save(record: ArtifactRecord, expectedRevision: number): Promise<boolean>;
|
|
7
|
+
};
|
|
8
|
+
export declare const createMemoryArtifactStore: (initial?: ArtifactRecord[]) => ArtifactStore;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type TSchema } from "@sinclair/typebox";
|
|
2
|
+
import type { ArtifactService } from "./service";
|
|
3
|
+
export type ArtifactToolDefinition = {
|
|
4
|
+
annotations?: {
|
|
5
|
+
readOnlyHint?: boolean;
|
|
6
|
+
};
|
|
7
|
+
description: string;
|
|
8
|
+
handler(input: unknown): Promise<string> | string;
|
|
9
|
+
input: TSchema;
|
|
10
|
+
};
|
|
11
|
+
export type ArtifactToolMap = Record<string, ArtifactToolDefinition>;
|
|
12
|
+
export type ArtifactToolOptions = {
|
|
13
|
+
createdBy: string;
|
|
14
|
+
ownerId: string;
|
|
15
|
+
service: ArtifactService;
|
|
16
|
+
};
|
|
17
|
+
export declare const createArtifactTools: (options: ArtifactToolOptions) => ArtifactToolMap;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export declare const ARTIFACT_STATUSES: readonly ["draft", "published", "archived"];
|
|
2
|
+
export type ArtifactStatus = (typeof ARTIFACT_STATUSES)[number];
|
|
3
|
+
export type ArtifactCapability = "archive" | "edit" | "export" | "preview" | "publish" | "refine";
|
|
4
|
+
export type ArtifactProvenance = {
|
|
5
|
+
model?: string;
|
|
6
|
+
sourceIds?: string[];
|
|
7
|
+
tool?: string;
|
|
8
|
+
traceId?: string;
|
|
9
|
+
};
|
|
10
|
+
export type ArtifactPublication = {
|
|
11
|
+
id: string;
|
|
12
|
+
publishedAt: string;
|
|
13
|
+
url: string;
|
|
14
|
+
};
|
|
15
|
+
export type ArtifactRecord<TContent = unknown> = {
|
|
16
|
+
capabilities: ArtifactCapability[];
|
|
17
|
+
content: TContent;
|
|
18
|
+
createdAt: string;
|
|
19
|
+
createdBy: string;
|
|
20
|
+
id: string;
|
|
21
|
+
kind: string;
|
|
22
|
+
metadata: Record<string, unknown>;
|
|
23
|
+
ownerId: string;
|
|
24
|
+
provenance?: ArtifactProvenance;
|
|
25
|
+
publication?: ArtifactPublication;
|
|
26
|
+
revision: number;
|
|
27
|
+
schemaVersion: number;
|
|
28
|
+
status: ArtifactStatus;
|
|
29
|
+
title: string;
|
|
30
|
+
updatedAt: string;
|
|
31
|
+
};
|
|
32
|
+
export type ArtifactListQuery = {
|
|
33
|
+
kind?: string;
|
|
34
|
+
limit?: number;
|
|
35
|
+
status?: ArtifactStatus;
|
|
36
|
+
};
|
|
37
|
+
export type ArtifactCreateInput = {
|
|
38
|
+
content: unknown;
|
|
39
|
+
createdBy: string;
|
|
40
|
+
kind: string;
|
|
41
|
+
metadata?: Record<string, unknown>;
|
|
42
|
+
provenance?: ArtifactProvenance;
|
|
43
|
+
title: string;
|
|
44
|
+
};
|
|
45
|
+
export type ArtifactUpdateInput = {
|
|
46
|
+
content?: unknown;
|
|
47
|
+
expectedRevision?: number;
|
|
48
|
+
metadata?: Record<string, unknown>;
|
|
49
|
+
title?: string;
|
|
50
|
+
};
|
|
51
|
+
export type ArtifactErrorCode = "conflict" | "invalid_content" | "not_found" | "publisher_unavailable" | "renderer_unavailable" | "unsupported_capability" | "unknown_kind";
|
|
52
|
+
export declare class ArtifactError extends Error {
|
|
53
|
+
readonly code: ArtifactErrorCode;
|
|
54
|
+
constructor(code: ArtifactErrorCode, message: string);
|
|
55
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@absolutejs/artifacts",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Typed, versioned artifacts for AI products — schemas, lifecycle, storage, rendering, publishing, revisions, and agent tools without prescribing a database or host.",
|
|
5
|
+
"author": "Alex Kahn",
|
|
6
|
+
"license": "BUSL-1.1",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"types": "./dist/src/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"README.md",
|
|
13
|
+
"LICENSE"
|
|
14
|
+
],
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/absolutejs/artifacts.git"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://github.com/absolutejs/artifacts",
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/absolutejs/artifacts/issues"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "rm -rf dist && bun build src/index.ts src/manifest.ts --outdir dist --root ./src --target=bun --external @sinclair/typebox --external @sinclair/typebox/value && tsc --emitDeclarationOnly --project tsconfig.json && absolute-manifest emit",
|
|
25
|
+
"format": "prettier --write \"./**/*.{ts,json,md}\"",
|
|
26
|
+
"release": "bun run format && bun run test && bun run build && bun publish",
|
|
27
|
+
"test": "bun test",
|
|
28
|
+
"typecheck": "tsc --noEmit --project tsconfig.json"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"absolutejs": {
|
|
34
|
+
"manifestContract": 1
|
|
35
|
+
},
|
|
36
|
+
"exports": {
|
|
37
|
+
".": {
|
|
38
|
+
"types": "./dist/src/index.d.ts",
|
|
39
|
+
"import": "./dist/index.js",
|
|
40
|
+
"default": "./dist/index.js"
|
|
41
|
+
},
|
|
42
|
+
"./manifest": {
|
|
43
|
+
"types": "./dist/src/manifest.d.ts",
|
|
44
|
+
"import": "./dist/manifest.js",
|
|
45
|
+
"default": "./dist/manifest.js"
|
|
46
|
+
},
|
|
47
|
+
"./manifest.json": "./dist/manifest.json"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@absolutejs/manifest": "^0.1.0",
|
|
51
|
+
"@sinclair/typebox": "^0.34.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@types/bun": "latest",
|
|
55
|
+
"prettier": "3.5.3",
|
|
56
|
+
"typescript": "5.8.3"
|
|
57
|
+
}
|
|
58
|
+
}
|