@absolutejs/artifacts 0.0.4 → 0.0.5

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
@@ -14,14 +14,19 @@ var __export = (target, all) => {
14
14
  set: __exportSetter.bind(all, name)
15
15
  });
16
16
  };
17
- var defineManifest = () => (manifest) => {
18
- const defined = manifest;
19
- return defined;
17
+ var defineManifest = () => (manifest) => manifest;
18
+ var literal = (value) => value;
19
+ var RUNTIME_KIND = literal("runtime");
20
+ var WORKSPACE_KIND = literal("workspace");
21
+ var toolFactory = () => {
22
+ function runtime(definition) {
23
+ return { kind: RUNTIME_KIND, ...definition };
24
+ }
25
+ function workspace(definition) {
26
+ return { kind: WORKSPACE_KIND, ...definition };
27
+ }
28
+ return { runtime, workspace };
20
29
  };
21
- var toolFactory = () => ({
22
- runtime: (definition) => ({ kind: "runtime", ...definition }),
23
- workspace: (definition) => ({ kind: "workspace", ...definition })
24
- });
25
30
  function IsAsyncIterator(value) {
26
31
  return IsObject(value) && globalThis.Symbol.asyncIterator in value;
27
32
  }
@@ -759,7 +764,7 @@ function String2(options) {
759
764
  function* FromUnion(syntax) {
760
765
  const trim = syntax.trim().replace(/"|'/g, "");
761
766
  return trim === "boolean" ? yield Boolean() : trim === "number" ? yield Number2() : trim === "bigint" ? yield BigInt2() : trim === "string" ? yield String2() : yield (() => {
762
- const literals = trim.split("|").map((literal) => Literal(literal.trim()));
767
+ const literals = trim.split("|").map((literal2) => Literal(literal2.trim()));
763
768
  return literals.length === 0 ? Never() : literals.length === 1 ? literals[0] : UnionEvaluated(literals);
764
769
  })();
765
770
  }
@@ -3467,10 +3472,10 @@ function ScoreUnion(schema, references, value) {
3467
3472
  const keys = Object.getOwnPropertyNames(value);
3468
3473
  const entries = Object.entries(object.properties);
3469
3474
  return entries.reduce((acc, [key, schema2]) => {
3470
- const literal = schema2[Kind] === "Literal" && schema2.const === value[key] ? 100 : 0;
3475
+ const literal2 = schema2[Kind] === "Literal" && schema2.const === value[key] ? 100 : 0;
3471
3476
  const checks = Check(schema2, references, value[key]) ? 10 : 0;
3472
3477
  const exists = keys.includes(key) ? 1 : 0;
3473
- return acc + (literal + checks + exists);
3478
+ return acc + (literal2 + checks + exists);
3474
3479
  }, 0);
3475
3480
  } else if (schema[Kind] === "Union") {
3476
3481
  const schemas = schema.anyOf.map((schema2) => Deref(schema2, references));
@@ -5807,7 +5812,13 @@ var wiringSnippet = Type.Object({
5807
5812
  Type.Literal("server-plugin")
5808
5813
  ]))
5809
5814
  });
5810
- var clientFrameworks = ["angular", "client", "react", "svelte", "vue"];
5815
+ var clientFrameworks = [
5816
+ "angular",
5817
+ "client",
5818
+ "react",
5819
+ "svelte",
5820
+ "vue"
5821
+ ];
5811
5822
  var wiringRecipe = Type.Object({
5812
5823
  client: Type.Optional(Type.Partial(Type.Object(Object.fromEntries(clientFrameworks.map((framework) => [framework, wiringSnippet]))))),
5813
5824
  description: Type.Optional(Type.String()),
@@ -5872,8 +5883,47 @@ var toolAnnotations = Type.Object({
5872
5883
  readOnlyHint: Type.Optional(Type.Boolean()),
5873
5884
  title: Type.Optional(Type.String())
5874
5885
  });
5886
+ var toolAuthorization = Type.Object({
5887
+ approval: Type.Union([
5888
+ Type.Literal("always"),
5889
+ Type.Literal("never"),
5890
+ Type.Literal("policy")
5891
+ ]),
5892
+ audience: Type.Union([
5893
+ Type.Literal("admin"),
5894
+ Type.Literal("authenticated"),
5895
+ Type.Literal("owner"),
5896
+ Type.Literal("public")
5897
+ ]),
5898
+ compensatingTool: Type.Optional(Type.String({ pattern: TOOL_NAME_PATTERN.source })),
5899
+ destinationFields: Type.Optional(Type.Array(Type.String({ minLength: 1 }), { minItems: 1 })),
5900
+ destinations: Type.Optional(Type.Array(Type.String({ minLength: 1 }), { minItems: 1 })),
5901
+ effects: Type.Array(Type.String({ minLength: 1 }), { minItems: 1 }),
5902
+ idempotency: Type.Optional(Type.Union([
5903
+ Type.Object({
5904
+ field: Type.String({ minLength: 1 }),
5905
+ mode: Type.Literal("field")
5906
+ }),
5907
+ Type.Object({ mode: Type.Literal("host") }),
5908
+ Type.Object({ mode: Type.Literal("resource") })
5909
+ ])),
5910
+ requiredScopes: Type.Optional(Type.Array(Type.String({ minLength: 1 }), { minItems: 1 })),
5911
+ resource: Type.Optional(Type.Object({
5912
+ idField: Type.Optional(Type.String({ minLength: 1 })),
5913
+ ownerIdField: Type.Optional(Type.String({ minLength: 1 })),
5914
+ tenantIdField: Type.Optional(Type.String({ minLength: 1 })),
5915
+ type: Type.String({ minLength: 1 })
5916
+ })),
5917
+ reversible: Type.Optional(Type.Boolean()),
5918
+ spend: Type.Optional(Type.Object({
5919
+ amountMinorField: Type.String({ minLength: 1 }),
5920
+ currencyField: Type.String({ minLength: 1 }),
5921
+ maximumAmountMinor: Type.Optional(Type.Integer({ minimum: 0 }))
5922
+ }))
5923
+ });
5875
5924
  var serializedTool = Type.Object({
5876
5925
  annotations: Type.Optional(toolAnnotations),
5926
+ authorization: Type.Optional(toolAuthorization),
5877
5927
  capabilities: Type.Optional(Type.Array(Type.Union([
5878
5928
  Type.Literal("exec"),
5879
5929
  Type.Literal("glob"),
@@ -5885,7 +5935,15 @@ var serializedTool = Type.Object({
5885
5935
  kind: Type.Union([Type.Literal("runtime"), Type.Literal("workspace")])
5886
5936
  });
5887
5937
  var manifestSchema = Type.Object({
5888
- contract: Type.Literal(1),
5938
+ contract: Type.Union([Type.Literal(1), Type.Literal(2)]),
5939
+ discovery: Type.Optional(Type.Object({
5940
+ audiences: Type.Optional(Type.Array(Type.String({ minLength: 1 }))),
5941
+ certificationUrl: Type.Optional(Type.String()),
5942
+ intents: Type.Optional(Type.Array(Type.String({ minLength: 1 }))),
5943
+ keywords: Type.Optional(Type.Array(Type.String({ minLength: 1 }))),
5944
+ protocols: Type.Optional(Type.Array(Type.String({ minLength: 1 }))),
5945
+ url: Type.Optional(Type.String())
5946
+ })),
5889
5947
  identity: Type.Object({
5890
5948
  accent: Type.Optional(Type.String({ pattern: "^#[0-9a-fA-F]{3,8}$" })),
5891
5949
  category: Type.String({ minLength: 1 }),
@@ -5895,7 +5953,9 @@ var manifestSchema = Type.Object({
5895
5953
  svg: Type.Optional(Type.String()),
5896
5954
  url: Type.Optional(Type.String())
5897
5955
  })),
5898
- name: Type.String({ pattern: "^(@[a-z0-9-~][a-z0-9-._~]*/)?[a-z0-9-~][a-z0-9-._~]*$" }),
5956
+ name: Type.String({
5957
+ pattern: "^(@[a-z0-9-~][a-z0-9-._~]*/)?[a-z0-9-~][a-z0-9-._~]*$"
5958
+ }),
5899
5959
  tagline: Type.String({ minLength: 1 })
5900
5960
  }),
5901
5961
  implements: Type.Optional(Type.Array(adapterImplementation)),
@@ -5917,7 +5977,7 @@ var manifestSchema = Type.Object({
5917
5977
  import { Type as Type2 } from "@sinclair/typebox";
5918
5978
  var tool = toolFactory();
5919
5979
  var manifest = defineManifest()({
5920
- contract: 1,
5980
+ contract: 2,
5921
5981
  identity: {
5922
5982
  accent: "#8b5cf6",
5923
5983
  category: "ai",
@@ -5939,6 +5999,17 @@ var manifest = defineManifest()({
5939
5999
  tools: {
5940
6000
  artifact_get: tool.runtime({
5941
6001
  annotations: { readOnlyHint: true },
6002
+ authorization: {
6003
+ approval: "never",
6004
+ audience: "owner",
6005
+ effects: ["read"],
6006
+ requiredScopes: ["artifacts:read"],
6007
+ resource: {
6008
+ idField: "artifactId",
6009
+ ownerIdField: "ownerId",
6010
+ type: "artifact"
6011
+ }
6012
+ },
5942
6013
  description: "Open one artifact owned by a user.",
5943
6014
  handler: async ({ artifactId, ownerId }, service) => JSON.stringify(await service.get(ownerId, artifactId)),
5944
6015
  input: Type2.Object({
@@ -5948,6 +6019,13 @@ var manifest = defineManifest()({
5948
6019
  }),
5949
6020
  artifact_list: tool.runtime({
5950
6021
  annotations: { readOnlyHint: true },
6022
+ authorization: {
6023
+ approval: "never",
6024
+ audience: "owner",
6025
+ effects: ["read"],
6026
+ requiredScopes: ["artifacts:read"],
6027
+ resource: { ownerIdField: "ownerId", type: "artifact" }
6028
+ },
5951
6029
  description: "List artifacts owned by a user.",
5952
6030
  handler: async ({ kind, ownerId }, service) => JSON.stringify(await service.list(ownerId, { kind })),
5953
6031
  input: Type2.Object({
@@ -5957,6 +6035,17 @@ var manifest = defineManifest()({
5957
6035
  }),
5958
6036
  artifact_history: tool.runtime({
5959
6037
  annotations: { readOnlyHint: true },
6038
+ authorization: {
6039
+ approval: "never",
6040
+ audience: "owner",
6041
+ effects: ["read"],
6042
+ requiredScopes: ["artifacts:read"],
6043
+ resource: {
6044
+ idField: "artifactId",
6045
+ ownerIdField: "ownerId",
6046
+ type: "artifact-revision"
6047
+ }
6048
+ },
5960
6049
  description: "List immutable revisions of one artifact owned by a user.",
5961
6050
  handler: async ({ artifactId, ownerId }, service) => JSON.stringify(await service.listRevisions(ownerId, artifactId)),
5962
6051
  input: Type2.Object({
@@ -5965,6 +6054,19 @@ var manifest = defineManifest()({
5965
6054
  })
5966
6055
  }),
5967
6056
  artifact_restore: tool.runtime({
6057
+ authorization: {
6058
+ approval: "policy",
6059
+ audience: "owner",
6060
+ effects: ["write"],
6061
+ idempotency: { mode: "host" },
6062
+ requiredScopes: ["artifacts:write"],
6063
+ resource: {
6064
+ idField: "artifactId",
6065
+ ownerIdField: "ownerId",
6066
+ type: "artifact-revision"
6067
+ },
6068
+ reversible: false
6069
+ },
5968
6070
  description: "Restore an old artifact revision as a new private draft.",
5969
6071
  handler: async ({ artifactId, ownerId, revision }, service) => JSON.stringify(await service.restore(ownerId, artifactId, revision)),
5970
6072
  input: Type2.Object({
@@ -1,5 +1,5 @@
1
1
  {
2
- "contract": 1,
2
+ "contract": 2,
3
3
  "identity": {
4
4
  "accent": "#8b5cf6",
5
5
  "category": "ai",
@@ -53,6 +53,21 @@
53
53
  "annotations": {
54
54
  "readOnlyHint": true
55
55
  },
56
+ "authorization": {
57
+ "approval": "never",
58
+ "audience": "owner",
59
+ "effects": [
60
+ "read"
61
+ ],
62
+ "requiredScopes": [
63
+ "artifacts:read"
64
+ ],
65
+ "resource": {
66
+ "idField": "artifactId",
67
+ "ownerIdField": "ownerId",
68
+ "type": "artifact"
69
+ }
70
+ },
56
71
  "description": "Open one artifact owned by a user.",
57
72
  "input": {
58
73
  "type": "object",
@@ -77,6 +92,20 @@
77
92
  "annotations": {
78
93
  "readOnlyHint": true
79
94
  },
95
+ "authorization": {
96
+ "approval": "never",
97
+ "audience": "owner",
98
+ "effects": [
99
+ "read"
100
+ ],
101
+ "requiredScopes": [
102
+ "artifacts:read"
103
+ ],
104
+ "resource": {
105
+ "ownerIdField": "ownerId",
106
+ "type": "artifact"
107
+ }
108
+ },
80
109
  "description": "List artifacts owned by a user.",
81
110
  "input": {
82
111
  "type": "object",
@@ -100,6 +129,21 @@
100
129
  "annotations": {
101
130
  "readOnlyHint": true
102
131
  },
132
+ "authorization": {
133
+ "approval": "never",
134
+ "audience": "owner",
135
+ "effects": [
136
+ "read"
137
+ ],
138
+ "requiredScopes": [
139
+ "artifacts:read"
140
+ ],
141
+ "resource": {
142
+ "idField": "artifactId",
143
+ "ownerIdField": "ownerId",
144
+ "type": "artifact-revision"
145
+ }
146
+ },
103
147
  "description": "List immutable revisions of one artifact owned by a user.",
104
148
  "input": {
105
149
  "type": "object",
@@ -121,6 +165,25 @@
121
165
  "kind": "runtime"
122
166
  },
123
167
  "artifact_restore": {
168
+ "authorization": {
169
+ "approval": "policy",
170
+ "audience": "owner",
171
+ "effects": [
172
+ "write"
173
+ ],
174
+ "idempotency": {
175
+ "mode": "host"
176
+ },
177
+ "requiredScopes": [
178
+ "artifacts:write"
179
+ ],
180
+ "resource": {
181
+ "idField": "artifactId",
182
+ "ownerIdField": "ownerId",
183
+ "type": "artifact-revision"
184
+ },
185
+ "reversible": false
186
+ },
124
187
  "description": "Restore an old artifact revision as a new private draft.",
125
188
  "input": {
126
189
  "type": "object",
@@ -1,4 +1,4 @@
1
- export declare const manifest: import("@absolutejs/manifest").PackageManifest<Record<string, never>, {
1
+ export declare const manifest: Omit<import("@absolutejs/manifest").PackageManifest<Record<string, never>, {
2
2
  archive: (ownerId: string, artifactId: string) => Promise<import("./types").ArtifactRecord>;
3
3
  attach: (ownerId: string, artifactId: string, input: import("./types").ArtifactAssetWriteInput, expectedRevision?: number) => Promise<import("./types").ArtifactRecord>;
4
4
  attachBundle: (ownerId: string, artifactId: string, inputs: import("./types").ArtifactAssetWriteInput[], expectedRevision?: number) => Promise<import("./types").ArtifactRecord>;
@@ -30,4 +30,76 @@ export declare const manifest: import("@absolutejs/manifest").PackageManifest<Re
30
30
  restore: (ownerId: string, artifactId: string, revision: number, expectedRevision?: number) => Promise<import("./types").ArtifactRecord>;
31
31
  unpublish: (ownerId: string, artifactId: string) => Promise<import("./types").ArtifactRecord>;
32
32
  update: (ownerId: string, artifactId: string, input: import("./types").ArtifactUpdateInput) => Promise<import("./types").ArtifactRecord>;
33
- }>;
33
+ }>, "contract" | "settings" | "tools"> & (({
34
+ contract: 1;
35
+ tools?: Record<string, import("@absolutejs/manifest").LegacyManifestTool<{
36
+ archive: (ownerId: string, artifactId: string) => Promise<import("./types").ArtifactRecord>;
37
+ attach: (ownerId: string, artifactId: string, input: import("./types").ArtifactAssetWriteInput, expectedRevision?: number) => Promise<import("./types").ArtifactRecord>;
38
+ attachBundle: (ownerId: string, artifactId: string, inputs: import("./types").ArtifactAssetWriteInput[], expectedRevision?: number) => Promise<import("./types").ArtifactRecord>;
39
+ collectAssetGarbage: (input: {
40
+ dryRun?: boolean;
41
+ minimumAgeMs?: number;
42
+ }) => Promise<import("./types").ArtifactGarbageCollectionResult>;
43
+ create: (ownerId: string, input: import("./types").ArtifactCreateInput) => Promise<import("./types").ArtifactRecord>;
44
+ createBundle: (ownerId: string, input: import("./types").ArtifactBundleCreateInput) => Promise<import("./types").ArtifactRecord>;
45
+ detach: (ownerId: string, artifactId: string, assetId: string, expectedRevision?: number) => Promise<import("./types").ArtifactRecord>;
46
+ get: (ownerId: string, artifactId: string) => Promise<import("./types").ArtifactRecord>;
47
+ getIndexingState: (ownerId: string, artifactId: string) => Promise<import("./types").ArtifactIndexingState | null>;
48
+ getRevision: (ownerId: string, artifactId: string, revision: number) => Promise<Readonly<import("./types").ArtifactRecord<unknown>>>;
49
+ list: (ownerId: string, query?: import("./types").ArtifactListQuery) => Promise<import("./types").ArtifactRecord[]>;
50
+ listEvents: (query?: import("./types").ArtifactEventQuery) => Promise<import("./types").ArtifactEvent[]>;
51
+ listRevisions: (ownerId: string, artifactId: string) => Promise<Readonly<import("./types").ArtifactRecord<unknown>>[]>;
52
+ markEventProcessed: (eventId: string, processedAt?: string) => Promise<boolean>;
53
+ markIndexing: (ownerId: string, artifactId: string, input: {
54
+ documentIds?: string[];
55
+ error?: string;
56
+ revision: number;
57
+ status: import("./types").ArtifactIndexingStatus;
58
+ }) => Promise<import("./types").ArtifactIndexingState>;
59
+ publish: (ownerId: string, artifactId: string, input?: import("./types").ArtifactPublishInput) => Promise<import("./types").ArtifactRecord>;
60
+ readAsset: (ownerId: string, artifactId: string, assetId: string) => Promise<{
61
+ asset: import("./types").ArtifactAssetReference;
62
+ data: Uint8Array<ArrayBufferLike>;
63
+ }>;
64
+ restore: (ownerId: string, artifactId: string, revision: number, expectedRevision?: number) => Promise<import("./types").ArtifactRecord>;
65
+ unpublish: (ownerId: string, artifactId: string) => Promise<import("./types").ArtifactRecord>;
66
+ update: (ownerId: string, artifactId: string, input: import("./types").ArtifactUpdateInput) => Promise<import("./types").ArtifactRecord>;
67
+ }>> | undefined;
68
+ } | {
69
+ contract: 2;
70
+ tools?: Record<string, import("@absolutejs/manifest").AuthorizedManifestTool<{
71
+ archive: (ownerId: string, artifactId: string) => Promise<import("./types").ArtifactRecord>;
72
+ attach: (ownerId: string, artifactId: string, input: import("./types").ArtifactAssetWriteInput, expectedRevision?: number) => Promise<import("./types").ArtifactRecord>;
73
+ attachBundle: (ownerId: string, artifactId: string, inputs: import("./types").ArtifactAssetWriteInput[], expectedRevision?: number) => Promise<import("./types").ArtifactRecord>;
74
+ collectAssetGarbage: (input: {
75
+ dryRun?: boolean;
76
+ minimumAgeMs?: number;
77
+ }) => Promise<import("./types").ArtifactGarbageCollectionResult>;
78
+ create: (ownerId: string, input: import("./types").ArtifactCreateInput) => Promise<import("./types").ArtifactRecord>;
79
+ createBundle: (ownerId: string, input: import("./types").ArtifactBundleCreateInput) => Promise<import("./types").ArtifactRecord>;
80
+ detach: (ownerId: string, artifactId: string, assetId: string, expectedRevision?: number) => Promise<import("./types").ArtifactRecord>;
81
+ get: (ownerId: string, artifactId: string) => Promise<import("./types").ArtifactRecord>;
82
+ getIndexingState: (ownerId: string, artifactId: string) => Promise<import("./types").ArtifactIndexingState | null>;
83
+ getRevision: (ownerId: string, artifactId: string, revision: number) => Promise<Readonly<import("./types").ArtifactRecord<unknown>>>;
84
+ list: (ownerId: string, query?: import("./types").ArtifactListQuery) => Promise<import("./types").ArtifactRecord[]>;
85
+ listEvents: (query?: import("./types").ArtifactEventQuery) => Promise<import("./types").ArtifactEvent[]>;
86
+ listRevisions: (ownerId: string, artifactId: string) => Promise<Readonly<import("./types").ArtifactRecord<unknown>>[]>;
87
+ markEventProcessed: (eventId: string, processedAt?: string) => Promise<boolean>;
88
+ markIndexing: (ownerId: string, artifactId: string, input: {
89
+ documentIds?: string[];
90
+ error?: string;
91
+ revision: number;
92
+ status: import("./types").ArtifactIndexingStatus;
93
+ }) => Promise<import("./types").ArtifactIndexingState>;
94
+ publish: (ownerId: string, artifactId: string, input?: import("./types").ArtifactPublishInput) => Promise<import("./types").ArtifactRecord>;
95
+ readAsset: (ownerId: string, artifactId: string, assetId: string) => Promise<{
96
+ asset: import("./types").ArtifactAssetReference;
97
+ data: Uint8Array<ArrayBufferLike>;
98
+ }>;
99
+ restore: (ownerId: string, artifactId: string, revision: number, expectedRevision?: number) => Promise<import("./types").ArtifactRecord>;
100
+ unpublish: (ownerId: string, artifactId: string) => Promise<import("./types").ArtifactRecord>;
101
+ update: (ownerId: string, artifactId: string, input: import("./types").ArtifactUpdateInput) => Promise<import("./types").ArtifactRecord>;
102
+ }>> | undefined;
103
+ }) & {
104
+ settings: import("@sinclair/typebox").TObject<{}>;
105
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@absolutejs/artifacts",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Typed, versioned artifacts for AI products — schemas, lifecycle, storage, rendering, publishing, revisions, and agent tools without prescribing a database or host.",
5
5
  "author": "Alex Kahn",
6
6
  "license": "BUSL-1.1",
@@ -31,7 +31,7 @@
31
31
  "access": "public"
32
32
  },
33
33
  "absolutejs": {
34
- "manifestContract": 1
34
+ "manifestContract": 2
35
35
  },
36
36
  "exports": {
37
37
  ".": {
@@ -52,7 +52,7 @@
52
52
  }
53
53
  },
54
54
  "dependencies": {
55
- "@absolutejs/manifest": "^0.1.0",
55
+ "@absolutejs/manifest": "^0.4.0",
56
56
  "@sinclair/typebox": "^0.34.0"
57
57
  },
58
58
  "peerDependencies": {