@larkup/marketplace 0.3.17 → 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 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.3.17",
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.8.7"
34
+ "@larkup/core": "0.9.1"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "^26",
@@ -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.26',
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.12',
598
+ version: '0.3.15',
599
599
  pricing: 'free',
600
600
  emoji: '📝',
601
601
  icon: 'FileEdit',
@@ -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
  }
@@ -9,7 +9,7 @@ describe('tool registry fallback catalog', () => {
9
9
  expect(registry['video-intelligence']).toMatchObject({
10
10
  id: 'video-intelligence',
11
11
  packageName: '@larkup/tool-video-intelligence',
12
- version: '0.3.26',
12
+ version: '0.3.29',
13
13
  });
14
14
  });
15
15
  });
package/src/types.ts CHANGED
@@ -94,7 +94,14 @@ export interface ToolUsageDescriptor {
94
94
 
95
95
  export interface ToolUiSurface {
96
96
  id: string;
97
- slot: 'data-indexing' | 'settings' | 'chat-result' | 'asset-actions';
97
+ /**
98
+ * Where the host mounts this surface. `chat-result` renders inline in a chat
99
+ * message; `canvas` renders in the expandable side panel the chat opens next
100
+ * to the conversation. Both are driven generically by the host's chat surface
101
+ * registry — see `@larkup/core/chat-surface` for the serializable contract a
102
+ * tool output carries to select one.
103
+ */
104
+ slot: 'data-indexing' | 'settings' | 'chat-result' | 'canvas' | 'asset-actions';
98
105
  title: string;
99
106
  description?: string;
100
107
  entrypoint?: string;
@@ -1,2 +0,0 @@
1
- /** Built-in Marketplace tool manifests. */
2
- export declare const BUILTIN_TOOLS: Record<string, unknown>[];
@@ -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
- ];
@@ -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
- }