@larkup/marketplace 0.4.0 → 0.4.2
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 +2 -0
- package/package.json +2 -2
- package/src/db/builtin-tools.ts +2 -2
- package/src/tool-extension.ts +21 -0
- package/src/tool-registry.test.ts +1 -1
- package/db/dist/builtin-tools.d.ts +0 -2
- package/db/dist/builtin-tools.js +0 -116
- package/db/dist/client.d.ts +0 -7
- package/db/dist/client.js +0 -20
- package/db/dist/repo.d.ts +0 -67
- package/db/dist/repo.js +0 -236
- package/db/dist/schema/audit.d.ts +0 -128
- package/db/dist/schema/audit.js +0 -18
- package/db/dist/schema/extensions.d.ts +0 -326
- package/db/dist/schema/extensions.js +0 -36
- package/db/dist/schema/index.d.ts +0 -5
- package/db/dist/schema/index.js +0 -5
- package/db/dist/schema/installations.d.ts +0 -93
- package/db/dist/schema/installations.js +0 -15
- package/db/dist/schema/publishers.d.ts +0 -110
- package/db/dist/schema/publishers.js +0 -12
- package/db/dist/schema/versions.d.ts +0 -127
- package/db/dist/schema/versions.js +0 -17
- package/db/dist/seed.d.ts +0 -2
- package/db/dist/seed.js +0 -31
- package/db/dist/validate.d.ts +0 -6
- package/db/dist/validate.js +0 -51
package/README.md
CHANGED
|
@@ -32,3 +32,5 @@ pnpm --filter @larkup/marketplace db:typecheck
|
|
|
32
32
|
|
|
33
33
|
Database migrations are committed in `db/drizzle`. Add a migration whenever a
|
|
34
34
|
schema change is made.
|
|
35
|
+
|
|
36
|
+
Media evidence hosts can supply revision-scoped `readCachedEvidence` and `saveCachedEvidence` callbacks and a validated `getAsset.playbackUrl`. A cache entry must remain scoped to the authorized source, project, and active knowledge revision.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@larkup/marketplace",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"drizzle-orm": "^0.45.2",
|
|
32
32
|
"postgres": "^4.0.0",
|
|
33
33
|
"tsx": "^4.23.5",
|
|
34
|
-
"@larkup/core": "0.9.
|
|
34
|
+
"@larkup/core": "0.9.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/node": "^26",
|
package/src/db/builtin-tools.ts
CHANGED
|
@@ -10,7 +10,7 @@ export const BUILTIN_TOOLS: Record<string, unknown>[] = [
|
|
|
10
10
|
longDescription:
|
|
11
11
|
'Turn videos into knowledge your AI can understand. It listens to what is said, reads what appears on screen, and helps you find the moments that matter.',
|
|
12
12
|
category: 'media',
|
|
13
|
-
version: '0.3.
|
|
13
|
+
version: '0.3.29',
|
|
14
14
|
pricing: 'free',
|
|
15
15
|
emoji: '🎬',
|
|
16
16
|
icon: 'Film',
|
|
@@ -595,7 +595,7 @@ export const BUILTIN_TOOLS: Record<string, unknown>[] = [
|
|
|
595
595
|
'Supports PDF form fields (AcroForm), DOCX paragraphs/tables, PPTX slide text, and plain text editing. ' +
|
|
596
596
|
'Uses pdf-lib (native) for PDF and the Docker sandbox for DOCX/PPTX via python-docx/python-pptx.',
|
|
597
597
|
category: 'utility',
|
|
598
|
-
version: '0.3.
|
|
598
|
+
version: '0.3.15',
|
|
599
599
|
pricing: 'free',
|
|
600
600
|
emoji: '📝',
|
|
601
601
|
icon: 'FileEdit',
|
package/src/tool-extension.ts
CHANGED
|
@@ -24,6 +24,26 @@ export interface AgentToolExecutionContext {
|
|
|
24
24
|
* investigation policy; the host only supplies scoped data access.
|
|
25
25
|
*/
|
|
26
26
|
mediaEvidence?: {
|
|
27
|
+
/** Host-scoped, revision-bound results; never shared across projects or source revisions. */
|
|
28
|
+
readCachedEvidence?: (mediaAssetId: string, operationKey: string) => Promise<unknown>;
|
|
29
|
+
saveCachedEvidence?: (
|
|
30
|
+
mediaAssetId: string,
|
|
31
|
+
operationKey: string,
|
|
32
|
+
result: unknown,
|
|
33
|
+
) => Promise<void>;
|
|
34
|
+
/** One immutable, source-scoped active snapshot for exact computation. */
|
|
35
|
+
readIndexedEvidence?: (mediaAssetId: string) => Promise<
|
|
36
|
+
| {
|
|
37
|
+
knowledgeRevisionId: string;
|
|
38
|
+
records: Array<{
|
|
39
|
+
id: string;
|
|
40
|
+
modality: string;
|
|
41
|
+
text: string;
|
|
42
|
+
timeRange: { startSecs: number; endSecs: number; precision?: string };
|
|
43
|
+
}>;
|
|
44
|
+
}
|
|
45
|
+
| undefined
|
|
46
|
+
>;
|
|
27
47
|
getAsset: (mediaAssetId: string) => Promise<
|
|
28
48
|
| {
|
|
29
49
|
id: string;
|
|
@@ -32,6 +52,7 @@ export interface AgentToolExecutionContext {
|
|
|
32
52
|
durationSecs?: number;
|
|
33
53
|
fileName?: string;
|
|
34
54
|
originalUrl?: string;
|
|
55
|
+
playbackUrl?: string;
|
|
35
56
|
/** Detected language of the source recording, when the host persisted it. */
|
|
36
57
|
sourceLanguage?: string;
|
|
37
58
|
}
|
package/db/dist/builtin-tools.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
/** Built-in Marketplace tool manifests. */
|
|
2
|
-
export const BUILTIN_TOOLS = [
|
|
3
|
-
{
|
|
4
|
-
id: 'video-audio',
|
|
5
|
-
name: 'Video Intelligence',
|
|
6
|
-
description: 'Build evidence-backed video timelines with adaptive attention and bounded source rewind.',
|
|
7
|
-
longDescription: 'Evidence-first video reasoning for your knowledge base. ' +
|
|
8
|
-
'Creates multilingual transcripts, activity-aware visual/OCR evidence, timestamped source ranges, ' +
|
|
9
|
-
'and bounded rewind for complex questions. Supports YouTube URLs, ' +
|
|
10
|
-
'direct file upload, and bulk processing. Includes ffmpeg automatically and prepares the YouTube downloader on first use.',
|
|
11
|
-
category: 'media',
|
|
12
|
-
version: '0.3.6',
|
|
13
|
-
pricing: 'free',
|
|
14
|
-
emoji: '🎬',
|
|
15
|
-
icon: 'Film',
|
|
16
|
-
packageName: '@larkup/tool-video-audio',
|
|
17
|
-
installSize: '~15 MB',
|
|
18
|
-
requiresSandbox: true,
|
|
19
|
-
author: 'Larkup',
|
|
20
|
-
capabilities: [
|
|
21
|
-
'video-indexing',
|
|
22
|
-
'audio-indexing',
|
|
23
|
-
'transcription',
|
|
24
|
-
'frame-extraction',
|
|
25
|
-
'youtube-import',
|
|
26
|
-
'attention-driven-analysis',
|
|
27
|
-
'temporal-evidence',
|
|
28
|
-
'bounded-source-rewind',
|
|
29
|
-
],
|
|
30
|
-
tags: ['video intelligence', 'temporal reasoning', 'transcription', 'ffmpeg', 'video', 'audio'],
|
|
31
|
-
repositoryUrl: 'https://github.com/Larkup-AI/larkup',
|
|
32
|
-
license: 'Apache-2.0',
|
|
33
|
-
updatedAt: '2026-07-20',
|
|
34
|
-
configSchema: [
|
|
35
|
-
{
|
|
36
|
-
key: 'frameInterval',
|
|
37
|
-
label: 'Baseline coverage interval (seconds)',
|
|
38
|
-
type: 'text',
|
|
39
|
-
defaultValue: '10',
|
|
40
|
-
help: 'Baseline cadence for duration-aware coverage frames; scene changes and a reserved ending pass are added separately.',
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
key: 'audioProvider',
|
|
44
|
-
label: 'Audio Provider',
|
|
45
|
-
type: 'select',
|
|
46
|
-
help: 'Choose the provider used only for audio and video transcription.',
|
|
47
|
-
options: [
|
|
48
|
-
{ label: 'OpenAI', value: 'openai' },
|
|
49
|
-
{ label: 'Groq', value: 'groq' },
|
|
50
|
-
{ label: 'Deepgram', value: 'deepgram' },
|
|
51
|
-
{ label: 'ElevenLabs', value: 'elevenlabs' },
|
|
52
|
-
{ label: 'Local Whisper', value: 'local' },
|
|
53
|
-
],
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
key: 'audioLanguage',
|
|
57
|
-
label: 'Transcription language',
|
|
58
|
-
type: 'text',
|
|
59
|
-
defaultValue: 'auto',
|
|
60
|
-
help: 'Use auto for provider language detection, or enter a language code such as ar, ar-EG, en, or de to override it.',
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
key: 'audioApiKey',
|
|
64
|
-
label: 'Audio API Key',
|
|
65
|
-
type: 'password',
|
|
66
|
-
help: 'Required for the selected audio provider and kept separate from the chat model key.',
|
|
67
|
-
},
|
|
68
|
-
],
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
id: 'clip-embeddings',
|
|
72
|
-
name: 'CLIP Image Search',
|
|
73
|
-
description: 'Direct image-to-image similarity search using CLIP/SigLIP embeddings.',
|
|
74
|
-
longDescription: 'Enable native visual similarity search by embedding images with CLIP or SigLIP models. ' +
|
|
75
|
-
"Search your image library by uploading a query image or describing what you're looking for. " +
|
|
76
|
-
'Requires downloading a ~200MB model on first use.',
|
|
77
|
-
category: 'embedding',
|
|
78
|
-
version: '0.1.0',
|
|
79
|
-
pricing: 'free',
|
|
80
|
-
emoji: '🔍',
|
|
81
|
-
icon: 'ScanEye',
|
|
82
|
-
packageName: '@larkup/tool-clip-embeddings',
|
|
83
|
-
installSize: '~200 MB',
|
|
84
|
-
author: 'Larkup',
|
|
85
|
-
capabilities: ['clip-embeddings', 'image-similarity'],
|
|
86
|
-
tags: ['clip', 'siglip', 'image-search', 'visual-similarity'],
|
|
87
|
-
repositoryUrl: 'https://github.com/Larkup-AI/larkup',
|
|
88
|
-
license: 'Apache-2.0',
|
|
89
|
-
updatedAt: '2026-07-20',
|
|
90
|
-
comingSoon: true,
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
id: 'doc-editor',
|
|
94
|
-
name: 'Document Editor',
|
|
95
|
-
description: 'AI-powered form filling and document editing with Canvas-style live preview.',
|
|
96
|
-
longDescription: 'Open PDF, Word, PowerPoint, and text files in a split-view Canvas. ' +
|
|
97
|
-
'AI fills forms using your knowledge base, edits content on request, and previews changes live. ' +
|
|
98
|
-
'Supports PDF form fields (AcroForm), DOCX paragraphs/tables, PPTX slide text, and plain text editing. ' +
|
|
99
|
-
'Uses pdf-lib (native) for PDF and the Docker sandbox for DOCX/PPTX via python-docx/python-pptx.',
|
|
100
|
-
category: 'utility',
|
|
101
|
-
version: '0.2.3',
|
|
102
|
-
pricing: 'free',
|
|
103
|
-
emoji: '📝',
|
|
104
|
-
icon: 'FileEdit',
|
|
105
|
-
packageName: '@larkup/tool-doc-editor',
|
|
106
|
-
installSize: '~5 MB',
|
|
107
|
-
systemDeps: ['docker'],
|
|
108
|
-
requiresSandbox: true,
|
|
109
|
-
author: 'Larkup',
|
|
110
|
-
capabilities: ['document-editing', 'form-filling', 'document-preview'],
|
|
111
|
-
tags: ['pdf', 'docx', 'pptx', 'form', 'canvas', 'editor', 'fill'],
|
|
112
|
-
repositoryUrl: 'https://github.com/Larkup-AI/larkup',
|
|
113
|
-
license: 'Apache-2.0',
|
|
114
|
-
updatedAt: '2026-07-20',
|
|
115
|
-
},
|
|
116
|
-
];
|
package/db/dist/client.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type PostgresJsDatabase } from 'drizzle-orm/postgres-js';
|
|
2
|
-
import * as schema from './schema/index.js';
|
|
3
|
-
export type MarketplaceDb = PostgresJsDatabase<typeof schema>;
|
|
4
|
-
/** Returns the process-local Marketplace database client. */
|
|
5
|
-
export declare function getMarketplaceDb(connectionString?: string | undefined): MarketplaceDb;
|
|
6
|
-
/** Clears the cached client for tests and scripts. */
|
|
7
|
-
export declare function resetMarketplaceDbCache(): void;
|
package/db/dist/client.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { drizzle } from 'drizzle-orm/postgres-js';
|
|
2
|
-
import postgres from 'postgres';
|
|
3
|
-
import * as schema from './schema/index.js';
|
|
4
|
-
let cached;
|
|
5
|
-
/** Returns the process-local Marketplace database client. */
|
|
6
|
-
export function getMarketplaceDb(connectionString = process.env.DATABASE_URL) {
|
|
7
|
-
if (cached)
|
|
8
|
-
return cached;
|
|
9
|
-
if (!connectionString) {
|
|
10
|
-
throw new Error('DATABASE_URL is not set. Start docker/marketplace-db.yml and copy ' +
|
|
11
|
-
'packages/marketplace/.env.example to packages/marketplace/.env.');
|
|
12
|
-
}
|
|
13
|
-
const client = postgres(connectionString, { max: 5 });
|
|
14
|
-
cached = drizzle(client, { schema });
|
|
15
|
-
return cached;
|
|
16
|
-
}
|
|
17
|
-
/** Clears the cached client for tests and scripts. */
|
|
18
|
-
export function resetMarketplaceDbCache() {
|
|
19
|
-
cached = undefined;
|
|
20
|
-
}
|
package/db/dist/repo.d.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/** Marketplace catalog queries. */
|
|
2
|
-
import type { MarketplaceDb } from './client.js';
|
|
3
|
-
export declare class ManifestInvalidError extends Error {
|
|
4
|
-
readonly errors: string[];
|
|
5
|
-
constructor(errors: string[]);
|
|
6
|
-
}
|
|
7
|
-
/** Thrown when another publisher owns the extension id. */
|
|
8
|
-
export declare class NotOwnerError extends Error {
|
|
9
|
-
constructor(extensionId: string);
|
|
10
|
-
}
|
|
11
|
-
/** Thrown when an extension version already exists. */
|
|
12
|
-
export declare class VersionExistsError extends Error {
|
|
13
|
-
constructor(extensionId: string, version: string);
|
|
14
|
-
}
|
|
15
|
-
export interface CatalogEntry {
|
|
16
|
-
id: string;
|
|
17
|
-
publisherId: string;
|
|
18
|
-
publisherName: string;
|
|
19
|
-
publisherVerification: 'unverified' | 'verified';
|
|
20
|
-
kind: string;
|
|
21
|
-
name: string;
|
|
22
|
-
description: string;
|
|
23
|
-
category: string;
|
|
24
|
-
packageName: string;
|
|
25
|
-
requiresSandbox: boolean;
|
|
26
|
-
distribution: string;
|
|
27
|
-
repositoryUrl: string | null;
|
|
28
|
-
license: string | null;
|
|
29
|
-
version: string;
|
|
30
|
-
manifest: unknown;
|
|
31
|
-
installs: number;
|
|
32
|
-
updatedAt: Date;
|
|
33
|
-
}
|
|
34
|
-
export interface ListExtensionsOptions {
|
|
35
|
-
category?: string;
|
|
36
|
-
search?: string;
|
|
37
|
-
workspaceId?: string;
|
|
38
|
-
limit?: number;
|
|
39
|
-
offset?: number;
|
|
40
|
-
}
|
|
41
|
-
export declare function listExtensions(db: MarketplaceDb, options?: ListExtensionsOptions): Promise<{
|
|
42
|
-
entries: CatalogEntry[];
|
|
43
|
-
total: number;
|
|
44
|
-
}>;
|
|
45
|
-
export declare function getExtension(db: MarketplaceDb, id: string, options?: {
|
|
46
|
-
workspaceId?: string;
|
|
47
|
-
}): Promise<{
|
|
48
|
-
entry: CatalogEntry;
|
|
49
|
-
versions: {
|
|
50
|
-
version: string;
|
|
51
|
-
publishedAt: Date;
|
|
52
|
-
}[];
|
|
53
|
-
} | null>;
|
|
54
|
-
export interface PublishInput {
|
|
55
|
-
manifest: Record<string, unknown>;
|
|
56
|
-
publisherId: string;
|
|
57
|
-
publisherName?: string;
|
|
58
|
-
}
|
|
59
|
-
/** Publishes an immutable extension version. */
|
|
60
|
-
export declare function publishExtension(db: MarketplaceDb, input: PublishInput): Promise<{
|
|
61
|
-
extensionId: string;
|
|
62
|
-
version: string;
|
|
63
|
-
}>;
|
|
64
|
-
export declare function recordInstall(db: MarketplaceDb, extensionId: string, workspaceId: string): Promise<{
|
|
65
|
-
installs: number;
|
|
66
|
-
} | null>;
|
|
67
|
-
export declare function grantWorkspaceAccess(db: MarketplaceDb, extensionId: string, workspaceId: string): Promise<void>;
|
package/db/dist/repo.js
DELETED
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
/** Marketplace catalog queries. */
|
|
2
|
-
import { and, count, eq, ilike, or, sql } from 'drizzle-orm';
|
|
3
|
-
import { auditEvents } from './schema/audit.js';
|
|
4
|
-
import { extensionWorkspaceGrants, extensions } from './schema/extensions.js';
|
|
5
|
-
import { extensionVersions } from './schema/versions.js';
|
|
6
|
-
import { publishers } from './schema/publishers.js';
|
|
7
|
-
import { workspaceInstallations } from './schema/installations.js';
|
|
8
|
-
import { validateToolManifest } from './validate.js';
|
|
9
|
-
export class ManifestInvalidError extends Error {
|
|
10
|
-
errors;
|
|
11
|
-
constructor(errors) {
|
|
12
|
-
super(`Invalid manifest: ${errors.join('; ')}`);
|
|
13
|
-
this.errors = errors;
|
|
14
|
-
this.name = 'ManifestInvalidError';
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
/** Thrown when another publisher owns the extension id. */
|
|
18
|
-
export class NotOwnerError extends Error {
|
|
19
|
-
constructor(extensionId) {
|
|
20
|
-
super(`"${extensionId}" is published by a different publisher.`);
|
|
21
|
-
this.name = 'NotOwnerError';
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
/** Thrown when an extension version already exists. */
|
|
25
|
-
export class VersionExistsError extends Error {
|
|
26
|
-
constructor(extensionId, version) {
|
|
27
|
-
super(`"${extensionId}@${version}" is already published. Publish a new version instead.`);
|
|
28
|
-
this.name = 'VersionExistsError';
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
/** Limits private extensions to granted workspaces. */
|
|
32
|
-
function visibilityFilter(workspaceId) {
|
|
33
|
-
return workspaceId
|
|
34
|
-
? or(eq(extensions.distribution, 'public'), sql `exists (select 1 from ${extensionWorkspaceGrants}
|
|
35
|
-
where ${extensionWorkspaceGrants.extensionId} = ${extensions.id}
|
|
36
|
-
and ${extensionWorkspaceGrants.workspaceId} = ${workspaceId})`)
|
|
37
|
-
: eq(extensions.distribution, 'public');
|
|
38
|
-
}
|
|
39
|
-
async function latestVersionSubquery(db, extensionId) {
|
|
40
|
-
const [latest] = await db
|
|
41
|
-
.select()
|
|
42
|
-
.from(extensionVersions)
|
|
43
|
-
.where(eq(extensionVersions.extensionId, extensionId))
|
|
44
|
-
.orderBy(sql `${extensionVersions.publishedAt} desc`)
|
|
45
|
-
.limit(1);
|
|
46
|
-
return latest;
|
|
47
|
-
}
|
|
48
|
-
export async function listExtensions(db, options = {}) {
|
|
49
|
-
const conditions = [visibilityFilter(options.workspaceId)];
|
|
50
|
-
if (options.category)
|
|
51
|
-
conditions.push(eq(extensions.category, options.category));
|
|
52
|
-
if (options.search) {
|
|
53
|
-
const q = `%${options.search}%`;
|
|
54
|
-
conditions.push(or(ilike(extensions.name, q), ilike(extensions.description, q), ilike(extensions.packageName, q)));
|
|
55
|
-
}
|
|
56
|
-
const where = and(...conditions);
|
|
57
|
-
const rows = await db
|
|
58
|
-
.select({ ext: extensions, publisher: publishers })
|
|
59
|
-
.from(extensions)
|
|
60
|
-
.innerJoin(publishers, eq(extensions.publisherId, publishers.id))
|
|
61
|
-
.where(where)
|
|
62
|
-
.orderBy(extensions.name)
|
|
63
|
-
.limit(options.limit ?? 50)
|
|
64
|
-
.offset(options.offset ?? 0);
|
|
65
|
-
const [{ value: total }] = await db.select({ value: count() }).from(extensions).where(where);
|
|
66
|
-
const entries = await Promise.all(rows.map(async ({ ext, publisher }) => {
|
|
67
|
-
const latest = await latestVersionSubquery(db, ext.id);
|
|
68
|
-
const [{ value: installs }] = await db
|
|
69
|
-
.select({ value: count() })
|
|
70
|
-
.from(workspaceInstallations)
|
|
71
|
-
.where(eq(workspaceInstallations.extensionId, ext.id));
|
|
72
|
-
return toEntry(ext, publisher, latest, installs);
|
|
73
|
-
}));
|
|
74
|
-
return { entries, total };
|
|
75
|
-
}
|
|
76
|
-
export async function getExtension(db, id, options = {}) {
|
|
77
|
-
const [row] = await db
|
|
78
|
-
.select({ ext: extensions, publisher: publishers })
|
|
79
|
-
.from(extensions)
|
|
80
|
-
.innerJoin(publishers, eq(extensions.publisherId, publishers.id))
|
|
81
|
-
.where(and(eq(extensions.id, id), visibilityFilter(options.workspaceId)))
|
|
82
|
-
.limit(1);
|
|
83
|
-
if (!row)
|
|
84
|
-
return null;
|
|
85
|
-
const versionRows = await db
|
|
86
|
-
.select({ version: extensionVersions.version, publishedAt: extensionVersions.publishedAt })
|
|
87
|
-
.from(extensionVersions)
|
|
88
|
-
.where(eq(extensionVersions.extensionId, id))
|
|
89
|
-
.orderBy(sql `${extensionVersions.publishedAt} desc`);
|
|
90
|
-
const latest = await latestVersionSubquery(db, id);
|
|
91
|
-
const [{ value: installs }] = await db
|
|
92
|
-
.select({ value: count() })
|
|
93
|
-
.from(workspaceInstallations)
|
|
94
|
-
.where(eq(workspaceInstallations.extensionId, id));
|
|
95
|
-
return { entry: toEntry(row.ext, row.publisher, latest, installs), versions: versionRows };
|
|
96
|
-
}
|
|
97
|
-
function toEntry(ext, publisher, latest, installs) {
|
|
98
|
-
return {
|
|
99
|
-
id: ext.id,
|
|
100
|
-
publisherId: ext.publisherId,
|
|
101
|
-
publisherName: publisher.name,
|
|
102
|
-
publisherVerification: publisher.verification,
|
|
103
|
-
kind: ext.kind,
|
|
104
|
-
name: ext.name,
|
|
105
|
-
description: ext.description,
|
|
106
|
-
category: ext.category,
|
|
107
|
-
packageName: ext.packageName,
|
|
108
|
-
requiresSandbox: ext.requiresSandbox,
|
|
109
|
-
distribution: ext.distribution,
|
|
110
|
-
repositoryUrl: ext.repositoryUrl,
|
|
111
|
-
license: ext.license,
|
|
112
|
-
version: latest?.version ?? '0.0.0',
|
|
113
|
-
manifest: latest?.manifest ?? {},
|
|
114
|
-
installs,
|
|
115
|
-
updatedAt: ext.updatedAt,
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
async function sha256Hex(input) {
|
|
119
|
-
const digest = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(input));
|
|
120
|
-
return Array.from(new Uint8Array(digest))
|
|
121
|
-
.map((b) => b.toString(16).padStart(2, '0'))
|
|
122
|
-
.join('');
|
|
123
|
-
}
|
|
124
|
-
/** Publishes an immutable extension version. */
|
|
125
|
-
export async function publishExtension(db, input) {
|
|
126
|
-
const manifest = {
|
|
127
|
-
...input.manifest,
|
|
128
|
-
requiresSandbox: input.manifest.requiresSandbox !== false,
|
|
129
|
-
};
|
|
130
|
-
const validation = validateToolManifest(manifest);
|
|
131
|
-
if (!validation.valid)
|
|
132
|
-
throw new ManifestInvalidError(validation.errors);
|
|
133
|
-
const m = manifest;
|
|
134
|
-
await db
|
|
135
|
-
.insert(publishers)
|
|
136
|
-
.values({ id: input.publisherId, name: input.publisherName ?? input.publisherId })
|
|
137
|
-
.onConflictDoNothing();
|
|
138
|
-
const [existing] = await db.select().from(extensions).where(eq(extensions.id, m.id)).limit(1);
|
|
139
|
-
if (existing && existing.publisherId !== input.publisherId) {
|
|
140
|
-
throw new NotOwnerError(m.id);
|
|
141
|
-
}
|
|
142
|
-
const [existingVersion] = await db
|
|
143
|
-
.select({ id: extensionVersions.id })
|
|
144
|
-
.from(extensionVersions)
|
|
145
|
-
.where(and(eq(extensionVersions.extensionId, m.id), eq(extensionVersions.version, m.version)))
|
|
146
|
-
.limit(1);
|
|
147
|
-
if (existingVersion)
|
|
148
|
-
throw new VersionExistsError(m.id, m.version);
|
|
149
|
-
const now = new Date();
|
|
150
|
-
if (existing) {
|
|
151
|
-
await db
|
|
152
|
-
.update(extensions)
|
|
153
|
-
.set({
|
|
154
|
-
name: m.name,
|
|
155
|
-
description: m.description,
|
|
156
|
-
category: m.category,
|
|
157
|
-
packageName: m.packageName,
|
|
158
|
-
requiresSandbox: m.requiresSandbox,
|
|
159
|
-
repositoryUrl: m.repositoryUrl ?? null,
|
|
160
|
-
license: m.license ?? null,
|
|
161
|
-
updatedAt: now,
|
|
162
|
-
})
|
|
163
|
-
.where(eq(extensions.id, m.id));
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
await db.insert(extensions).values({
|
|
167
|
-
id: m.id,
|
|
168
|
-
publisherId: input.publisherId,
|
|
169
|
-
kind: m.kind ?? 'tool',
|
|
170
|
-
name: m.name,
|
|
171
|
-
description: m.description,
|
|
172
|
-
category: m.category,
|
|
173
|
-
packageName: m.packageName,
|
|
174
|
-
requiresSandbox: m.requiresSandbox,
|
|
175
|
-
repositoryUrl: m.repositoryUrl ?? null,
|
|
176
|
-
license: m.license ?? null,
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
const integrity = await sha256Hex(JSON.stringify(manifest));
|
|
180
|
-
await db.insert(extensionVersions).values({
|
|
181
|
-
id: crypto.randomUUID(),
|
|
182
|
-
extensionId: m.id,
|
|
183
|
-
version: m.version,
|
|
184
|
-
manifest,
|
|
185
|
-
integrity,
|
|
186
|
-
publishedBy: input.publisherId,
|
|
187
|
-
});
|
|
188
|
-
await db.insert(auditEvents).values({
|
|
189
|
-
id: crypto.randomUUID(),
|
|
190
|
-
actor: input.publisherId,
|
|
191
|
-
action: 'extension.published',
|
|
192
|
-
extensionId: m.id,
|
|
193
|
-
metadata: { version: m.version },
|
|
194
|
-
});
|
|
195
|
-
return { extensionId: m.id, version: m.version };
|
|
196
|
-
}
|
|
197
|
-
export async function recordInstall(db, extensionId, workspaceId) {
|
|
198
|
-
const [ext] = await db
|
|
199
|
-
.select({ id: extensions.id })
|
|
200
|
-
.from(extensions)
|
|
201
|
-
.where(eq(extensions.id, extensionId));
|
|
202
|
-
if (!ext)
|
|
203
|
-
return null;
|
|
204
|
-
await db
|
|
205
|
-
.insert(workspaceInstallations)
|
|
206
|
-
.values({ id: crypto.randomUUID(), extensionId, workspaceId })
|
|
207
|
-
.onConflictDoUpdate({
|
|
208
|
-
target: [workspaceInstallations.extensionId, workspaceInstallations.workspaceId],
|
|
209
|
-
set: { updatedAt: new Date() },
|
|
210
|
-
});
|
|
211
|
-
await db.insert(auditEvents).values({
|
|
212
|
-
id: crypto.randomUUID(),
|
|
213
|
-
actor: workspaceId,
|
|
214
|
-
action: 'extension.installed',
|
|
215
|
-
extensionId,
|
|
216
|
-
workspaceId,
|
|
217
|
-
});
|
|
218
|
-
const [{ value: installs }] = await db
|
|
219
|
-
.select({ value: count() })
|
|
220
|
-
.from(workspaceInstallations)
|
|
221
|
-
.where(eq(workspaceInstallations.extensionId, extensionId));
|
|
222
|
-
return { installs };
|
|
223
|
-
}
|
|
224
|
-
export async function grantWorkspaceAccess(db, extensionId, workspaceId) {
|
|
225
|
-
await db
|
|
226
|
-
.insert(extensionWorkspaceGrants)
|
|
227
|
-
.values({ id: crypto.randomUUID(), extensionId, workspaceId })
|
|
228
|
-
.onConflictDoNothing();
|
|
229
|
-
await db.insert(auditEvents).values({
|
|
230
|
-
id: crypto.randomUUID(),
|
|
231
|
-
actor: 'system',
|
|
232
|
-
action: 'extension.grant_added',
|
|
233
|
-
extensionId,
|
|
234
|
-
workspaceId,
|
|
235
|
-
});
|
|
236
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
export declare const AUDIT_ACTIONS: readonly ["extension.published", "extension.installed", "extension.grant_added", "extension.grant_removed", "extension.deprecated"];
|
|
2
|
-
/** Catalog audit trail. */
|
|
3
|
-
export declare const auditEvents: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
4
|
-
name: "audit_events";
|
|
5
|
-
schema: undefined;
|
|
6
|
-
columns: {
|
|
7
|
-
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
8
|
-
name: "id";
|
|
9
|
-
tableName: "audit_events";
|
|
10
|
-
dataType: "string";
|
|
11
|
-
columnType: "PgText";
|
|
12
|
-
data: string;
|
|
13
|
-
driverParam: string;
|
|
14
|
-
notNull: true;
|
|
15
|
-
hasDefault: false;
|
|
16
|
-
isPrimaryKey: true;
|
|
17
|
-
isAutoincrement: false;
|
|
18
|
-
hasRuntimeDefault: false;
|
|
19
|
-
enumValues: [string, ...string[]];
|
|
20
|
-
baseColumn: never;
|
|
21
|
-
identity: undefined;
|
|
22
|
-
generated: undefined;
|
|
23
|
-
}, {}, {}>;
|
|
24
|
-
actor: import("drizzle-orm/pg-core").PgColumn<{
|
|
25
|
-
name: "actor";
|
|
26
|
-
tableName: "audit_events";
|
|
27
|
-
dataType: "string";
|
|
28
|
-
columnType: "PgText";
|
|
29
|
-
data: string;
|
|
30
|
-
driverParam: string;
|
|
31
|
-
notNull: true;
|
|
32
|
-
hasDefault: false;
|
|
33
|
-
isPrimaryKey: false;
|
|
34
|
-
isAutoincrement: false;
|
|
35
|
-
hasRuntimeDefault: false;
|
|
36
|
-
enumValues: [string, ...string[]];
|
|
37
|
-
baseColumn: never;
|
|
38
|
-
identity: undefined;
|
|
39
|
-
generated: undefined;
|
|
40
|
-
}, {}, {}>;
|
|
41
|
-
action: import("drizzle-orm/pg-core").PgColumn<{
|
|
42
|
-
name: "action";
|
|
43
|
-
tableName: "audit_events";
|
|
44
|
-
dataType: "string";
|
|
45
|
-
columnType: "PgText";
|
|
46
|
-
data: "extension.published" | "extension.installed" | "extension.grant_added" | "extension.grant_removed" | "extension.deprecated";
|
|
47
|
-
driverParam: string;
|
|
48
|
-
notNull: true;
|
|
49
|
-
hasDefault: false;
|
|
50
|
-
isPrimaryKey: false;
|
|
51
|
-
isAutoincrement: false;
|
|
52
|
-
hasRuntimeDefault: false;
|
|
53
|
-
enumValues: ["extension.published", "extension.installed", "extension.grant_added", "extension.grant_removed", "extension.deprecated"];
|
|
54
|
-
baseColumn: never;
|
|
55
|
-
identity: undefined;
|
|
56
|
-
generated: undefined;
|
|
57
|
-
}, {}, {}>;
|
|
58
|
-
extensionId: import("drizzle-orm/pg-core").PgColumn<{
|
|
59
|
-
name: "extension_id";
|
|
60
|
-
tableName: "audit_events";
|
|
61
|
-
dataType: "string";
|
|
62
|
-
columnType: "PgText";
|
|
63
|
-
data: string;
|
|
64
|
-
driverParam: string;
|
|
65
|
-
notNull: false;
|
|
66
|
-
hasDefault: false;
|
|
67
|
-
isPrimaryKey: false;
|
|
68
|
-
isAutoincrement: false;
|
|
69
|
-
hasRuntimeDefault: false;
|
|
70
|
-
enumValues: [string, ...string[]];
|
|
71
|
-
baseColumn: never;
|
|
72
|
-
identity: undefined;
|
|
73
|
-
generated: undefined;
|
|
74
|
-
}, {}, {}>;
|
|
75
|
-
workspaceId: import("drizzle-orm/pg-core").PgColumn<{
|
|
76
|
-
name: "workspace_id";
|
|
77
|
-
tableName: "audit_events";
|
|
78
|
-
dataType: "string";
|
|
79
|
-
columnType: "PgText";
|
|
80
|
-
data: string;
|
|
81
|
-
driverParam: string;
|
|
82
|
-
notNull: false;
|
|
83
|
-
hasDefault: false;
|
|
84
|
-
isPrimaryKey: false;
|
|
85
|
-
isAutoincrement: false;
|
|
86
|
-
hasRuntimeDefault: false;
|
|
87
|
-
enumValues: [string, ...string[]];
|
|
88
|
-
baseColumn: never;
|
|
89
|
-
identity: undefined;
|
|
90
|
-
generated: undefined;
|
|
91
|
-
}, {}, {}>;
|
|
92
|
-
metadata: import("drizzle-orm/pg-core").PgColumn<{
|
|
93
|
-
name: "metadata";
|
|
94
|
-
tableName: "audit_events";
|
|
95
|
-
dataType: "json";
|
|
96
|
-
columnType: "PgJsonb";
|
|
97
|
-
data: unknown;
|
|
98
|
-
driverParam: unknown;
|
|
99
|
-
notNull: false;
|
|
100
|
-
hasDefault: false;
|
|
101
|
-
isPrimaryKey: false;
|
|
102
|
-
isAutoincrement: false;
|
|
103
|
-
hasRuntimeDefault: false;
|
|
104
|
-
enumValues: undefined;
|
|
105
|
-
baseColumn: never;
|
|
106
|
-
identity: undefined;
|
|
107
|
-
generated: undefined;
|
|
108
|
-
}, {}, {}>;
|
|
109
|
-
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
110
|
-
name: "created_at";
|
|
111
|
-
tableName: "audit_events";
|
|
112
|
-
dataType: "date";
|
|
113
|
-
columnType: "PgTimestamp";
|
|
114
|
-
data: Date;
|
|
115
|
-
driverParam: string;
|
|
116
|
-
notNull: true;
|
|
117
|
-
hasDefault: true;
|
|
118
|
-
isPrimaryKey: false;
|
|
119
|
-
isAutoincrement: false;
|
|
120
|
-
hasRuntimeDefault: false;
|
|
121
|
-
enumValues: undefined;
|
|
122
|
-
baseColumn: never;
|
|
123
|
-
identity: undefined;
|
|
124
|
-
generated: undefined;
|
|
125
|
-
}, {}, {}>;
|
|
126
|
-
};
|
|
127
|
-
dialect: "pg";
|
|
128
|
-
}>;
|