@absolutejs/artifacts 0.0.1 → 0.0.3

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/dist/manifest.js CHANGED
@@ -5954,6 +5954,24 @@ var manifest = defineManifest()({
5954
5954
  kind: Type2.Optional(Type2.String({ minLength: 1 })),
5955
5955
  ownerId: Type2.String({ minLength: 1 })
5956
5956
  })
5957
+ }),
5958
+ artifact_history: tool.runtime({
5959
+ annotations: { readOnlyHint: true },
5960
+ description: "List immutable revisions of one artifact owned by a user.",
5961
+ handler: async ({ artifactId, ownerId }, service) => JSON.stringify(await service.listRevisions(ownerId, artifactId)),
5962
+ input: Type2.Object({
5963
+ artifactId: Type2.String({ minLength: 1 }),
5964
+ ownerId: Type2.String({ minLength: 1 })
5965
+ })
5966
+ }),
5967
+ artifact_restore: tool.runtime({
5968
+ description: "Restore an old artifact revision as a new private draft.",
5969
+ handler: async ({ artifactId, ownerId, revision }, service) => JSON.stringify(await service.restore(ownerId, artifactId, revision)),
5970
+ input: Type2.Object({
5971
+ artifactId: Type2.String({ minLength: 1 }),
5972
+ ownerId: Type2.String({ minLength: 1 }),
5973
+ revision: Type2.Integer({ minimum: 1 })
5974
+ })
5957
5975
  })
5958
5976
  },
5959
5977
  wiring: [
@@ -95,6 +95,56 @@
95
95
  }
96
96
  },
97
97
  "kind": "runtime"
98
+ },
99
+ "artifact_history": {
100
+ "annotations": {
101
+ "readOnlyHint": true
102
+ },
103
+ "description": "List immutable revisions of one artifact owned by a user.",
104
+ "input": {
105
+ "type": "object",
106
+ "required": [
107
+ "artifactId",
108
+ "ownerId"
109
+ ],
110
+ "properties": {
111
+ "artifactId": {
112
+ "minLength": 1,
113
+ "type": "string"
114
+ },
115
+ "ownerId": {
116
+ "minLength": 1,
117
+ "type": "string"
118
+ }
119
+ }
120
+ },
121
+ "kind": "runtime"
122
+ },
123
+ "artifact_restore": {
124
+ "description": "Restore an old artifact revision as a new private draft.",
125
+ "input": {
126
+ "type": "object",
127
+ "required": [
128
+ "artifactId",
129
+ "ownerId",
130
+ "revision"
131
+ ],
132
+ "properties": {
133
+ "artifactId": {
134
+ "minLength": 1,
135
+ "type": "string"
136
+ },
137
+ "ownerId": {
138
+ "minLength": 1,
139
+ "type": "string"
140
+ },
141
+ "revision": {
142
+ "minimum": 1,
143
+ "type": "integer"
144
+ }
145
+ }
146
+ },
147
+ "kind": "runtime"
98
148
  }
99
149
  }
100
150
  }
package/dist/rag.js ADDED
@@ -0,0 +1,76 @@
1
+ // @bun
2
+ // src/rag.ts
3
+ import { Buffer } from "buffer";
4
+ var artifactMetadata = (artifact) => ({
5
+ artifactId: artifact.id,
6
+ artifactKind: artifact.kind,
7
+ artifactRevision: artifact.revision,
8
+ artifactStatus: artifact.status,
9
+ ...artifact.metadata
10
+ });
11
+ var artifactToRAGUploads = async (artifact, reader, options = {}) => {
12
+ const metadata = artifactMetadata(artifact);
13
+ const uploads = await Promise.all(artifact.assets.map(async (asset) => ({
14
+ content: Buffer.from(await reader.read(asset, { artifact })).toString("base64"),
15
+ contentType: asset.mediaType,
16
+ encoding: "base64",
17
+ metadata: {
18
+ ...metadata,
19
+ artifactAssetId: asset.id,
20
+ artifactAssetRole: asset.role,
21
+ ...asset.metadata
22
+ },
23
+ name: asset.name,
24
+ source: `artifact:${artifact.id}:revision:${artifact.revision}:asset:${asset.id}`,
25
+ title: artifact.title
26
+ })));
27
+ if (options.includeStructuredContent === false)
28
+ return uploads;
29
+ return [
30
+ {
31
+ content: JSON.stringify(artifact.content),
32
+ contentType: "application/json",
33
+ encoding: "utf8",
34
+ metadata: { ...metadata, artifactStructuredContent: true },
35
+ name: `${artifact.kind}-${artifact.id}-r${artifact.revision}.json`,
36
+ source: `artifact:${artifact.id}:revision:${artifact.revision}:content`,
37
+ title: artifact.title
38
+ },
39
+ ...uploads
40
+ ];
41
+ };
42
+ var createArtifactRAGIndexCoordinator = (options) => ({
43
+ index: async (artifact) => {
44
+ const previous = await options.service.getIndexingState(artifact.ownerId, artifact.id);
45
+ await options.service.markIndexing(artifact.ownerId, artifact.id, {
46
+ documentIds: previous?.documentIds,
47
+ revision: artifact.revision,
48
+ status: "pending"
49
+ });
50
+ try {
51
+ const uploads = await artifactToRAGUploads(artifact, options.reader);
52
+ const indexed = await options.target.index(uploads, { artifact });
53
+ if (previous?.documentIds.length && options.target.remove) {
54
+ await options.target.remove(previous.documentIds, { artifact });
55
+ }
56
+ await options.service.markIndexing(artifact.ownerId, artifact.id, {
57
+ documentIds: indexed.documentIds,
58
+ revision: artifact.revision,
59
+ status: "indexed"
60
+ });
61
+ return indexed;
62
+ } catch (error) {
63
+ await options.service.markIndexing(artifact.ownerId, artifact.id, {
64
+ documentIds: previous?.documentIds,
65
+ error: error instanceof Error ? error.message : String(error),
66
+ revision: artifact.revision,
67
+ status: "failed"
68
+ });
69
+ throw error;
70
+ }
71
+ }
72
+ });
73
+ export {
74
+ createArtifactRAGIndexCoordinator,
75
+ artifactToRAGUploads
76
+ };
@@ -0,0 +1,34 @@
1
+ import type { ArtifactAssetWriteInput, ArtifactBundleCreateInput, ArtifactProvenance, ArtifactRecord } from "./types";
2
+ export type ArtifactGenerationInput = {
3
+ createdBy: string;
4
+ input?: Record<string, unknown>;
5
+ kind: string;
6
+ ownerId: string;
7
+ prompt?: string;
8
+ title?: string;
9
+ };
10
+ export type ArtifactGenerationContext = {
11
+ ownerId: string;
12
+ };
13
+ export type ArtifactGenerationResult = {
14
+ assets?: ArtifactAssetWriteInput[];
15
+ content: unknown;
16
+ metadata?: Record<string, unknown>;
17
+ provenance?: ArtifactProvenance;
18
+ title?: string;
19
+ warnings?: string[];
20
+ };
21
+ export type ArtifactGenerator = {
22
+ generate(input: ArtifactGenerationInput, context: ArtifactGenerationContext): Promise<ArtifactGenerationResult>;
23
+ kind: string;
24
+ name: string;
25
+ };
26
+ export type ArtifactBundleCreator = {
27
+ createBundle(ownerId: string, input: ArtifactBundleCreateInput): Promise<ArtifactRecord>;
28
+ };
29
+ export declare const createArtifactGeneratorRegistry: (initial?: ArtifactGenerator[]) => {
30
+ generate: (service: ArtifactBundleCreator, input: ArtifactGenerationInput) => Promise<ArtifactRecord>;
31
+ kinds: () => string[];
32
+ register: (generator: ArtifactGenerator) => void;
33
+ };
34
+ export type ArtifactGeneratorRegistry = ReturnType<typeof createArtifactGeneratorRegistry>;
@@ -7,8 +7,10 @@
7
7
  * retains authorization, persistence, URLs, UI, and delivery policy.
8
8
  */
9
9
  export { defineArtifactRegistry, type ArtifactContent, type ArtifactKindDefinition, type ArtifactKindDefinitions, type ArtifactRegistry, } from "./registry";
10
+ export { createArtifactGeneratorRegistry, type ArtifactBundleCreator, type ArtifactGenerationContext, type ArtifactGenerationInput, type ArtifactGenerationResult, type ArtifactGenerator, type ArtifactGeneratorRegistry, } from "./generators";
11
+ export { STANDARD_ARTIFACT_KIND_NAMES, standardArtifactDefinitions, } from "./standardKinds";
10
12
  export { createArtifactRendererRegistry, type ArtifactRenderer, type ArtifactRendererRegistry, type ArtifactRenderResult, } from "./renderers";
11
13
  export { createArtifactService, type ArtifactPublisher, type ArtifactService, type ArtifactServiceOptions, } from "./service";
12
- export { createMemoryArtifactStore, type ArtifactStore } from "./store";
14
+ export { createMemoryArtifactStore, createMemoryArtifactAssetStore, type ArtifactAssetStore, type ArtifactAssetTransaction, type ArtifactStore, } from "./store";
13
15
  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";
16
+ export { ARTIFACT_STATUSES, ARTIFACT_EVENT_TYPES, ArtifactError, type ArtifactAssetReference, type ArtifactAssetRole, type ArtifactAssetWriteInput, type ArtifactBundleCreateInput, type ArtifactCapability, type ArtifactCreateInput, type ArtifactErrorCode, type ArtifactEvent, type ArtifactEventQuery, type ArtifactEventType, type ArtifactGarbageCollectionResult, type ArtifactIndexingState, type ArtifactIndexingStatus, type ArtifactListQuery, type ArtifactLineageReference, type ArtifactLineageRelation, type ArtifactProvenance, type ArtifactPublication, type ArtifactPublishInput, type ArtifactRecord, type ArtifactRevision, type ArtifactRetentionCandidate, type ArtifactStatus, type ArtifactUpdateInput, } from "./types";
@@ -1,9 +1,33 @@
1
1
  export declare const manifest: import("@absolutejs/manifest").PackageManifest<Record<string, never>, {
2
2
  archive: (ownerId: string, artifactId: string) => Promise<import("./types").ArtifactRecord>;
3
+ attach: (ownerId: string, artifactId: string, input: import("./types").ArtifactAssetWriteInput, expectedRevision?: number) => Promise<import("./types").ArtifactRecord>;
4
+ attachBundle: (ownerId: string, artifactId: string, inputs: import("./types").ArtifactAssetWriteInput[], expectedRevision?: number) => Promise<import("./types").ArtifactRecord>;
5
+ collectAssetGarbage: (input: {
6
+ dryRun?: boolean;
7
+ minimumAgeMs?: number;
8
+ }) => Promise<import("./types").ArtifactGarbageCollectionResult>;
3
9
  create: (ownerId: string, input: import("./types").ArtifactCreateInput) => Promise<import("./types").ArtifactRecord>;
10
+ createBundle: (ownerId: string, input: import("./types").ArtifactBundleCreateInput) => Promise<import("./types").ArtifactRecord>;
11
+ detach: (ownerId: string, artifactId: string, assetId: string, expectedRevision?: number) => Promise<import("./types").ArtifactRecord>;
4
12
  get: (ownerId: string, artifactId: string) => Promise<import("./types").ArtifactRecord>;
13
+ getIndexingState: (ownerId: string, artifactId: string) => Promise<import("./types").ArtifactIndexingState | null>;
14
+ getRevision: (ownerId: string, artifactId: string, revision: number) => Promise<Readonly<import("./types").ArtifactRecord<unknown>>>;
5
15
  list: (ownerId: string, query?: import("./types").ArtifactListQuery) => Promise<import("./types").ArtifactRecord[]>;
6
- publish: (ownerId: string, artifactId: string) => Promise<import("./types").ArtifactRecord>;
16
+ listEvents: (query?: import("./types").ArtifactEventQuery) => Promise<import("./types").ArtifactEvent[]>;
17
+ listRevisions: (ownerId: string, artifactId: string) => Promise<Readonly<import("./types").ArtifactRecord<unknown>>[]>;
18
+ markEventProcessed: (eventId: string, processedAt?: string) => Promise<boolean>;
19
+ markIndexing: (ownerId: string, artifactId: string, input: {
20
+ documentIds?: string[];
21
+ error?: string;
22
+ revision: number;
23
+ status: import("./types").ArtifactIndexingStatus;
24
+ }) => Promise<import("./types").ArtifactIndexingState>;
25
+ publish: (ownerId: string, artifactId: string, input?: import("./types").ArtifactPublishInput) => Promise<import("./types").ArtifactRecord>;
26
+ readAsset: (ownerId: string, artifactId: string, assetId: string) => Promise<{
27
+ asset: import("./types").ArtifactAssetReference;
28
+ data: Uint8Array<ArrayBufferLike>;
29
+ }>;
30
+ restore: (ownerId: string, artifactId: string, revision: number, expectedRevision?: number) => Promise<import("./types").ArtifactRecord>;
7
31
  unpublish: (ownerId: string, artifactId: string) => Promise<import("./types").ArtifactRecord>;
8
32
  update: (ownerId: string, artifactId: string, input: import("./types").ArtifactUpdateInput) => Promise<import("./types").ArtifactRecord>;
9
33
  }>;
@@ -0,0 +1,46 @@
1
+ import type { RAGDocumentUploadInput } from "@absolutejs/rag";
2
+ import type { ArtifactAssetReference, ArtifactRecord } from "./types";
3
+ export type ArtifactRAGAssetReader = {
4
+ read(reference: ArtifactAssetReference, context: {
5
+ artifact: ArtifactRecord;
6
+ }): Promise<Uint8Array>;
7
+ };
8
+ export type ArtifactRAGUploadOptions = {
9
+ includeStructuredContent?: boolean;
10
+ };
11
+ export type ArtifactRAGIndexTarget = {
12
+ index(uploads: RAGDocumentUploadInput[], context: {
13
+ artifact: ArtifactRecord;
14
+ }): Promise<{
15
+ documentIds: string[];
16
+ }>;
17
+ remove?(documentIds: string[], context: {
18
+ artifact: ArtifactRecord;
19
+ }): Promise<void>;
20
+ };
21
+ export type ArtifactRAGIndexStateWriter = {
22
+ getIndexingState(ownerId: string, artifactId: string): Promise<{
23
+ documentIds: string[];
24
+ } | null>;
25
+ markIndexing(ownerId: string, artifactId: string, input: {
26
+ documentIds?: string[];
27
+ error?: string;
28
+ revision: number;
29
+ status: "failed" | "indexed" | "pending" | "stale";
30
+ }): Promise<unknown>;
31
+ };
32
+ /**
33
+ * Resolve an artifact revision into upload inputs accepted by @absolutejs/rag.
34
+ * Storage URIs remain opaque; only the supplied reader is allowed to access bytes.
35
+ */
36
+ export declare const artifactToRAGUploads: (artifact: ArtifactRecord, reader: ArtifactRAGAssetReader, options?: ArtifactRAGUploadOptions) => Promise<RAGDocumentUploadInput[]>;
37
+ export declare const createArtifactRAGIndexCoordinator: (options: {
38
+ reader: ArtifactRAGAssetReader;
39
+ service: ArtifactRAGIndexStateWriter;
40
+ target: ArtifactRAGIndexTarget;
41
+ }) => {
42
+ index: (artifact: ArtifactRecord) => Promise<{
43
+ documentIds: string[];
44
+ }>;
45
+ };
46
+ export type ArtifactRAGIndexCoordinator = ReturnType<typeof createArtifactRAGIndexCoordinator>;
@@ -1,6 +1,12 @@
1
1
  import type { Static, TSchema } from "@sinclair/typebox";
2
2
  import { type ArtifactCapability } from "./types";
3
+ export type ArtifactAssetPolicy = {
4
+ /** Exact media types or wildcards such as image/* and application/*. */
5
+ acceptedMediaTypes?: string[];
6
+ maxCount?: number;
7
+ };
3
8
  export type ArtifactKindDefinition<TContent extends TSchema = TSchema> = {
9
+ assets?: ArtifactAssetPolicy;
4
10
  capabilities?: ArtifactCapability[];
5
11
  content: TContent;
6
12
  description?: string;
@@ -1,9 +1,11 @@
1
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";
2
+ import type { ArtifactAssetStore, ArtifactStore } from "./store";
3
+ import { type ArtifactAssetReference, type ArtifactAssetWriteInput, type ArtifactBundleCreateInput, type ArtifactCreateInput, type ArtifactEvent, type ArtifactEventQuery, type ArtifactGarbageCollectionResult, type ArtifactIndexingState, type ArtifactIndexingStatus, type ArtifactListQuery, type ArtifactPublishInput, type ArtifactRecord, type ArtifactUpdateInput } from "./types";
4
4
  export type ArtifactPublisher = {
5
5
  publish(artifact: ArtifactRecord, options: {
6
6
  idempotencyKey: string;
7
+ mode: "live" | "pinned";
8
+ revision: number;
7
9
  }): Promise<{
8
10
  id: string;
9
11
  url: string;
@@ -13,7 +15,9 @@ export type ArtifactPublisher = {
13
15
  }): Promise<void>;
14
16
  };
15
17
  export type ArtifactServiceOptions<TDefinitions extends ArtifactKindDefinitions = ArtifactKindDefinitions> = {
18
+ assetStore?: ArtifactAssetStore;
16
19
  clock?: () => Date;
20
+ eventIdFactory?: () => string;
17
21
  idFactory?: () => string;
18
22
  publisher?: ArtifactPublisher;
19
23
  registry: ArtifactRegistry<TDefinitions>;
@@ -22,10 +26,34 @@ export type ArtifactServiceOptions<TDefinitions extends ArtifactKindDefinitions
22
26
  export type ArtifactService = ReturnType<typeof createArtifactService>;
23
27
  export declare const createArtifactService: <TDefinitions extends ArtifactKindDefinitions>(options: ArtifactServiceOptions<TDefinitions>) => {
24
28
  archive: (ownerId: string, artifactId: string) => Promise<ArtifactRecord>;
29
+ attach: (ownerId: string, artifactId: string, input: ArtifactAssetWriteInput, expectedRevision?: number) => Promise<ArtifactRecord>;
30
+ attachBundle: (ownerId: string, artifactId: string, inputs: ArtifactAssetWriteInput[], expectedRevision?: number) => Promise<ArtifactRecord>;
31
+ collectAssetGarbage: (input: {
32
+ dryRun?: boolean;
33
+ minimumAgeMs?: number;
34
+ }) => Promise<ArtifactGarbageCollectionResult>;
25
35
  create: (ownerId: string, input: ArtifactCreateInput) => Promise<ArtifactRecord>;
36
+ createBundle: (ownerId: string, input: ArtifactBundleCreateInput) => Promise<ArtifactRecord>;
37
+ detach: (ownerId: string, artifactId: string, assetId: string, expectedRevision?: number) => Promise<ArtifactRecord>;
26
38
  get: (ownerId: string, artifactId: string) => Promise<ArtifactRecord>;
39
+ getIndexingState: (ownerId: string, artifactId: string) => Promise<ArtifactIndexingState | null>;
40
+ getRevision: (ownerId: string, artifactId: string, revision: number) => Promise<Readonly<ArtifactRecord<unknown>>>;
27
41
  list: (ownerId: string, query?: ArtifactListQuery) => Promise<ArtifactRecord[]>;
28
- publish: (ownerId: string, artifactId: string) => Promise<ArtifactRecord>;
42
+ listEvents: (query?: ArtifactEventQuery) => Promise<ArtifactEvent[]>;
43
+ listRevisions: (ownerId: string, artifactId: string) => Promise<Readonly<ArtifactRecord<unknown>>[]>;
44
+ markEventProcessed: (eventId: string, processedAt?: string) => Promise<boolean>;
45
+ markIndexing: (ownerId: string, artifactId: string, input: {
46
+ documentIds?: string[];
47
+ error?: string;
48
+ revision: number;
49
+ status: ArtifactIndexingStatus;
50
+ }) => Promise<ArtifactIndexingState>;
51
+ publish: (ownerId: string, artifactId: string, input?: ArtifactPublishInput) => Promise<ArtifactRecord>;
52
+ readAsset: (ownerId: string, artifactId: string, assetId: string) => Promise<{
53
+ asset: ArtifactAssetReference;
54
+ data: Uint8Array<ArrayBufferLike>;
55
+ }>;
56
+ restore: (ownerId: string, artifactId: string, revision: number, expectedRevision?: number) => Promise<ArtifactRecord>;
29
57
  unpublish: (ownerId: string, artifactId: string) => Promise<ArtifactRecord>;
30
58
  update: (ownerId: string, artifactId: string, input: ArtifactUpdateInput) => Promise<ArtifactRecord>;
31
59
  };
@@ -0,0 +1,157 @@
1
+ export declare const standardArtifactDefinitions: {
2
+ archive: {
3
+ assets: {
4
+ acceptedMediaTypes: string[];
5
+ maxCount: number;
6
+ };
7
+ capabilities: ("attach" | "archive" | "edit" | "export" | "preview" | "refine")[];
8
+ content: import("@sinclair/typebox").TObject<{
9
+ description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
10
+ instructions: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
11
+ summary: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
12
+ }>;
13
+ label: string;
14
+ schemaVersion: number;
15
+ };
16
+ audio: {
17
+ assets: {
18
+ acceptedMediaTypes: string[];
19
+ maxCount: number;
20
+ };
21
+ capabilities: ("attach" | "archive" | "edit" | "export" | "preview" | "refine")[];
22
+ content: import("@sinclair/typebox").TObject<{
23
+ description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
24
+ instructions: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
25
+ summary: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
26
+ }>;
27
+ label: string;
28
+ schemaVersion: number;
29
+ };
30
+ code: {
31
+ assets: {
32
+ acceptedMediaTypes: string[];
33
+ maxCount: number;
34
+ };
35
+ capabilities: ("attach" | "archive" | "edit" | "export" | "preview" | "refine")[];
36
+ content: import("@sinclair/typebox").TObject<{
37
+ description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
38
+ instructions: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
39
+ summary: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
40
+ }>;
41
+ label: string;
42
+ schemaVersion: number;
43
+ };
44
+ dataset: {
45
+ assets: {
46
+ acceptedMediaTypes: string[];
47
+ maxCount: number;
48
+ };
49
+ capabilities: ("attach" | "archive" | "edit" | "export" | "preview" | "refine")[];
50
+ content: import("@sinclair/typebox").TObject<{
51
+ description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
52
+ instructions: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
53
+ summary: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
54
+ }>;
55
+ label: string;
56
+ schemaVersion: number;
57
+ };
58
+ document: {
59
+ assets: {
60
+ acceptedMediaTypes: string[];
61
+ maxCount: number;
62
+ };
63
+ capabilities: ("attach" | "archive" | "edit" | "export" | "preview" | "refine")[];
64
+ content: import("@sinclair/typebox").TObject<{
65
+ description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
66
+ instructions: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
67
+ summary: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
68
+ }>;
69
+ label: string;
70
+ schemaVersion: number;
71
+ };
72
+ email: {
73
+ assets: {
74
+ acceptedMediaTypes: string[];
75
+ maxCount: number;
76
+ };
77
+ capabilities: ("attach" | "archive" | "edit" | "export" | "preview" | "refine")[];
78
+ content: import("@sinclair/typebox").TObject<{
79
+ description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
80
+ instructions: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
81
+ summary: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
82
+ }>;
83
+ label: string;
84
+ schemaVersion: number;
85
+ };
86
+ file: {
87
+ assets: {
88
+ acceptedMediaTypes: string[];
89
+ maxCount: number;
90
+ };
91
+ capabilities: ("attach" | "archive" | "edit" | "export" | "preview" | "refine")[];
92
+ content: import("@sinclair/typebox").TObject<{
93
+ description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
94
+ instructions: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
95
+ summary: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
96
+ }>;
97
+ label: string;
98
+ schemaVersion: number;
99
+ };
100
+ image: {
101
+ assets: {
102
+ acceptedMediaTypes: string[];
103
+ maxCount: number;
104
+ };
105
+ capabilities: ("attach" | "archive" | "edit" | "export" | "preview" | "refine")[];
106
+ content: import("@sinclair/typebox").TObject<{
107
+ description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
108
+ instructions: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
109
+ summary: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
110
+ }>;
111
+ label: string;
112
+ schemaVersion: number;
113
+ };
114
+ presentation: {
115
+ assets: {
116
+ acceptedMediaTypes: string[];
117
+ maxCount: number;
118
+ };
119
+ capabilities: ("attach" | "archive" | "edit" | "export" | "preview" | "refine")[];
120
+ content: import("@sinclair/typebox").TObject<{
121
+ description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
122
+ instructions: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
123
+ summary: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
124
+ }>;
125
+ label: string;
126
+ schemaVersion: number;
127
+ };
128
+ spreadsheet: {
129
+ assets: {
130
+ acceptedMediaTypes: string[];
131
+ maxCount: number;
132
+ };
133
+ capabilities: ("attach" | "archive" | "edit" | "export" | "preview" | "refine")[];
134
+ content: import("@sinclair/typebox").TObject<{
135
+ description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
136
+ instructions: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
137
+ summary: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
138
+ }>;
139
+ label: string;
140
+ schemaVersion: number;
141
+ };
142
+ video: {
143
+ assets: {
144
+ acceptedMediaTypes: string[];
145
+ maxCount: number;
146
+ };
147
+ capabilities: ("attach" | "archive" | "edit" | "export" | "preview" | "refine")[];
148
+ content: import("@sinclair/typebox").TObject<{
149
+ description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
150
+ instructions: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
151
+ summary: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
152
+ }>;
153
+ label: string;
154
+ schemaVersion: number;
155
+ };
156
+ };
157
+ export declare const STANDARD_ARTIFACT_KIND_NAMES: Array<keyof typeof standardArtifactDefinitions>;
@@ -1,8 +1,38 @@
1
- import type { ArtifactListQuery, ArtifactRecord } from "./types";
1
+ import type { ArtifactAssetReference, ArtifactAssetWriteInput, ArtifactEvent, ArtifactEventQuery, ArtifactIndexingState, ArtifactListQuery, ArtifactRecord, ArtifactRevision, ArtifactRetentionCandidate } from "./types";
2
+ export type ArtifactAssetTransaction = {
3
+ commit(): Promise<void>;
4
+ references: ArtifactAssetReference[];
5
+ rollback(): Promise<void>;
6
+ };
7
+ export type ArtifactAssetStore = {
8
+ delete(reference: ArtifactAssetReference): Promise<void>;
9
+ listCandidates(): Promise<ArtifactRetentionCandidate[]>;
10
+ read(reference: ArtifactAssetReference, context: {
11
+ artifact: ArtifactRecord;
12
+ }): Promise<Uint8Array>;
13
+ write(input: ArtifactAssetWriteInput, context: {
14
+ artifact: ArtifactRecord;
15
+ idempotencyKey: string;
16
+ }): Promise<ArtifactAssetReference>;
17
+ stage?(inputs: ArtifactAssetWriteInput[], context: {
18
+ artifact: ArtifactRecord;
19
+ idempotencyKey: string;
20
+ }): Promise<ArtifactAssetTransaction>;
21
+ };
2
22
  export type ArtifactStore = {
3
- create(record: ArtifactRecord): Promise<void>;
23
+ /** Persist the current record and its first immutable revision atomically. */
24
+ create(record: ArtifactRecord, events?: ArtifactEvent[]): Promise<void>;
25
+ getIndexingState(ownerId: string, artifactId: string): Promise<ArtifactIndexingState | null>;
4
26
  get(ownerId: string, artifactId: string): Promise<ArtifactRecord | null>;
27
+ getRevision(ownerId: string, artifactId: string, revision: number): Promise<ArtifactRevision | null>;
5
28
  list(ownerId: string, query?: ArtifactListQuery): Promise<ArtifactRecord[]>;
6
- save(record: ArtifactRecord, expectedRevision: number): Promise<boolean>;
29
+ listRevisions(ownerId: string, artifactId: string): Promise<ArtifactRevision[]>;
30
+ listEvents(query?: ArtifactEventQuery): Promise<ArtifactEvent[]>;
31
+ listReferencedAssetIds(): Promise<string[]>;
32
+ markEventProcessed(eventId: string, processedAt: string): Promise<boolean>;
33
+ putIndexingState(ownerId: string, state: ArtifactIndexingState, events?: ArtifactEvent[]): Promise<void>;
34
+ /** Compare, replace current state, and append its revision atomically. */
35
+ save(record: ArtifactRecord, expectedRevision: number, events?: ArtifactEvent[]): Promise<boolean>;
7
36
  };
37
+ export declare const createMemoryArtifactAssetStore: () => ArtifactAssetStore;
8
38
  export declare const createMemoryArtifactStore: (initial?: ArtifactRecord[]) => ArtifactStore;