@hivemagnus/ardent-studio 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +12 -0
- package/README.md +133 -2
- package/dist/agents/config-edit.d.ts +20 -0
- package/dist/agents/config-edit.js +75 -0
- package/dist/agents/directory.d.ts +27 -0
- package/dist/agents/directory.js +97 -0
- package/dist/agents/operations.d.ts +47 -0
- package/dist/agents/operations.js +93 -0
- package/dist/auth/links.d.ts +27 -0
- package/dist/auth/links.js +46 -0
- package/dist/auth/oathweave.d.ts +46 -0
- package/dist/auth/oathweave.js +123 -0
- package/dist/blobs/store.d.ts +45 -0
- package/dist/blobs/store.js +159 -0
- package/dist/clients/chattermost.d.ts +16 -0
- package/dist/clients/chattermost.js +36 -0
- package/dist/clients/hivemem.d.ts +85 -0
- package/dist/clients/hivemem.js +89 -0
- package/dist/clients/magnus.d.ts +851 -0
- package/dist/clients/magnus.js +541 -0
- package/dist/clients/service-token.d.ts +24 -0
- package/dist/clients/service-token.js +87 -0
- package/dist/clients/sse.d.ts +8 -0
- package/dist/clients/sse.js +42 -0
- package/dist/conductor/activity.d.ts +38 -0
- package/dist/conductor/activity.js +101 -0
- package/dist/conductor/addressing.d.ts +24 -0
- package/dist/conductor/addressing.js +42 -0
- package/dist/conductor/conductor.d.ts +225 -0
- package/dist/conductor/conductor.js +939 -0
- package/dist/conductor/follower.d.ts +48 -0
- package/dist/conductor/follower.js +154 -0
- package/dist/conductor/live.d.ts +23 -0
- package/dist/conductor/live.js +32 -0
- package/dist/conductor/prompting.d.ts +74 -0
- package/dist/conductor/prompting.js +177 -0
- package/dist/config.d.ts +52 -0
- package/dist/config.js +163 -0
- package/dist/db/database.d.ts +12 -0
- package/dist/db/database.js +62 -0
- package/dist/db/json.d.ts +8 -0
- package/dist/db/json.js +13 -0
- package/dist/db/migrations.d.ts +6 -0
- package/dist/db/migrations.js +571 -0
- package/dist/db/repos/agents.d.ts +86 -0
- package/dist/db/repos/agents.js +92 -0
- package/dist/db/repos/audit.d.ts +37 -0
- package/dist/db/repos/audit.js +20 -0
- package/dist/db/repos/events.d.ts +29 -0
- package/dist/db/repos/events.js +55 -0
- package/dist/db/repos/files.d.ts +41 -0
- package/dist/db/repos/files.js +72 -0
- package/dist/db/repos/idempotency.d.ts +27 -0
- package/dist/db/repos/idempotency.js +46 -0
- package/dist/db/repos/links.d.ts +47 -0
- package/dist/db/repos/links.js +99 -0
- package/dist/db/repos/projects.d.ts +44 -0
- package/dist/db/repos/projects.js +107 -0
- package/dist/db/repos/proposals.d.ts +46 -0
- package/dist/db/repos/proposals.js +65 -0
- package/dist/db/repos/review.d.ts +191 -0
- package/dist/db/repos/review.js +195 -0
- package/dist/db/repos/room.d.ts +163 -0
- package/dist/db/repos/room.js +151 -0
- package/dist/db/repos/sessions.d.ts +36 -0
- package/dist/db/repos/sessions.js +30 -0
- package/dist/db/repos/summaries.d.ts +22 -0
- package/dist/db/repos/summaries.js +105 -0
- package/dist/db/repos/tasks.d.ts +103 -0
- package/dist/db/repos/tasks.js +112 -0
- package/dist/db/repos/team.d.ts +49 -0
- package/dist/db/repos/team.js +95 -0
- package/dist/db/repos/templates.d.ts +55 -0
- package/dist/db/repos/templates.js +120 -0
- package/dist/db/store.d.ts +57 -0
- package/dist/db/store.js +108 -0
- package/dist/events/bus.d.ts +21 -0
- package/dist/events/bus.js +31 -0
- package/dist/events/types.d.ts +3 -0
- package/dist/events/types.js +1 -0
- package/dist/ids.d.ts +28 -0
- package/dist/ids.js +81 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +17 -0
- package/dist/knowledge/extract.d.ts +17 -0
- package/dist/knowledge/extract.js +82 -0
- package/dist/knowledge/sync.d.ts +40 -0
- package/dist/knowledge/sync.js +172 -0
- package/dist/logger.d.ts +5 -0
- package/dist/logger.js +11 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +42 -0
- package/dist/review/anchors.d.ts +16 -0
- package/dist/review/anchors.js +67 -0
- package/dist/review/context.d.ts +4 -0
- package/dist/review/context.js +29 -0
- package/dist/review/docx.d.ts +29 -0
- package/dist/review/docx.js +21 -0
- package/dist/review/export.d.ts +16 -0
- package/dist/review/export.js +84 -0
- package/dist/review/importer.d.ts +68 -0
- package/dist/review/importer.js +215 -0
- package/dist/review/index.d.ts +13 -0
- package/dist/review/index.js +7 -0
- package/dist/server/app.d.ts +5 -0
- package/dist/server/app.js +44 -0
- package/dist/server/deps.d.ts +43 -0
- package/dist/server/deps.js +17 -0
- package/dist/server/env.d.ts +6 -0
- package/dist/server/env.js +1 -0
- package/dist/server/errors.d.ts +12 -0
- package/dist/server/errors.js +25 -0
- package/dist/server/routes/agent-studio.d.ts +5 -0
- package/dist/server/routes/agent-studio.js +441 -0
- package/dist/server/routes/agents.d.ts +3 -0
- package/dist/server/routes/agents.js +4 -0
- package/dist/server/routes/files.d.ts +3 -0
- package/dist/server/routes/files.js +88 -0
- package/dist/server/routes/health.d.ts +3 -0
- package/dist/server/routes/health.js +31 -0
- package/dist/server/routes/links.d.ts +3 -0
- package/dist/server/routes/links.js +79 -0
- package/dist/server/routes/projects.d.ts +3 -0
- package/dist/server/routes/projects.js +119 -0
- package/dist/server/routes/review.d.ts +3 -0
- package/dist/server/routes/review.js +198 -0
- package/dist/server/routes/room.d.ts +9 -0
- package/dist/server/routes/room.js +224 -0
- package/dist/server/routes/stream.d.ts +4 -0
- package/dist/server/routes/stream.js +104 -0
- package/dist/server/routes/team.d.ts +3 -0
- package/dist/server/routes/team.js +183 -0
- package/dist/server/routes/templates.d.ts +11 -0
- package/dist/server/routes/templates.js +103 -0
- package/dist/server/routes/work.d.ts +3 -0
- package/dist/server/routes/work.js +139 -0
- package/dist/server/routing.d.ts +31 -0
- package/dist/server/routing.js +132 -0
- package/dist/service.d.ts +34 -0
- package/dist/service.js +93 -0
- package/dist/shared/browser.d.ts +5824 -0
- package/dist/shared/browser.js +1318 -0
- package/dist/team/proposals.d.ts +129 -0
- package/dist/team/proposals.js +349 -0
- package/dist/team/service.d.ts +12 -0
- package/dist/team/service.js +13 -0
- package/dist/team/validation.d.ts +37 -0
- package/dist/team/validation.js +157 -0
- package/dist/templates/secrets.d.ts +2 -0
- package/dist/templates/secrets.js +23 -0
- package/dist/templates/seeds.d.ts +34 -0
- package/dist/templates/seeds.js +277 -0
- package/dist/url.d.ts +2 -0
- package/dist/url.js +7 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +11 -0
- package/docs/openapi-browser.json +12658 -0
- package/package.json +91 -4
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ServiceTokenProvider } from './service-token.js';
|
|
3
|
+
export declare class HiveMemError extends Error {
|
|
4
|
+
readonly status: number;
|
|
5
|
+
name: string;
|
|
6
|
+
constructor(message: string, status: number);
|
|
7
|
+
}
|
|
8
|
+
export interface KnowledgeChunk {
|
|
9
|
+
chunk_key: string;
|
|
10
|
+
content: string;
|
|
11
|
+
content_hash: string;
|
|
12
|
+
heading?: string | null;
|
|
13
|
+
tags?: string[];
|
|
14
|
+
}
|
|
15
|
+
export interface KnowledgeSyncRequest {
|
|
16
|
+
mode: 'preview' | 'apply';
|
|
17
|
+
workspace_id: string;
|
|
18
|
+
project_id: string;
|
|
19
|
+
source_id: string;
|
|
20
|
+
source_uri: string;
|
|
21
|
+
revision: string;
|
|
22
|
+
observed_at: string;
|
|
23
|
+
expires_at?: string | null;
|
|
24
|
+
chunks: KnowledgeChunk[];
|
|
25
|
+
}
|
|
26
|
+
export declare const knowledgeSyncResponseSchema: z.ZodObject<{
|
|
27
|
+
mode: z.ZodEnum<{
|
|
28
|
+
preview: "preview";
|
|
29
|
+
apply: "apply";
|
|
30
|
+
}>;
|
|
31
|
+
workspace_id: z.ZodString;
|
|
32
|
+
project_id: z.ZodString;
|
|
33
|
+
source_id: z.ZodString;
|
|
34
|
+
revision: z.ZodString;
|
|
35
|
+
created: z.ZodNumber;
|
|
36
|
+
superseded: z.ZodNumber;
|
|
37
|
+
retired: z.ZodNumber;
|
|
38
|
+
unchanged: z.ZodNumber;
|
|
39
|
+
}, z.core.$loose>;
|
|
40
|
+
export type KnowledgeSyncResponse = z.infer<typeof knowledgeSyncResponseSchema>;
|
|
41
|
+
export declare const workspaceSchema: z.ZodObject<{
|
|
42
|
+
workspace_id: z.ZodString;
|
|
43
|
+
owner_agent_id: z.ZodString;
|
|
44
|
+
deleted_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
45
|
+
}, z.core.$loose>;
|
|
46
|
+
/** HiveMem limits one source sync to 500 chunks, 64 KiB per chunk and 4 MiB in total. */
|
|
47
|
+
export declare const HIVEMEM_MAX_CHUNKS = 500;
|
|
48
|
+
export declare const HIVEMEM_MAX_CHUNK_BYTES = 65536;
|
|
49
|
+
export declare const HIVEMEM_MAX_SYNC_BYTES: number;
|
|
50
|
+
export declare function chunkHash(content: string): string;
|
|
51
|
+
export interface HiveMemClientOptions {
|
|
52
|
+
baseUrl: string;
|
|
53
|
+
tokens: Pick<ServiceTokenProvider, 'token' | 'invalidate'>;
|
|
54
|
+
fetch?: typeof fetch;
|
|
55
|
+
timeoutMs?: number;
|
|
56
|
+
}
|
|
57
|
+
export declare class HiveMemClient {
|
|
58
|
+
private readonly options;
|
|
59
|
+
private readonly request;
|
|
60
|
+
private readonly baseUrl;
|
|
61
|
+
constructor(options: HiveMemClientOptions);
|
|
62
|
+
/** Unauthenticated liveness of the HiveMem service. */
|
|
63
|
+
health(): Promise<{
|
|
64
|
+
status: string;
|
|
65
|
+
}>;
|
|
66
|
+
/** Create the project workspace. HiveMem returns the existing workspace when it already exists. */
|
|
67
|
+
ensureWorkspace(input: {
|
|
68
|
+
workspace_id: string;
|
|
69
|
+
title: string;
|
|
70
|
+
description?: string;
|
|
71
|
+
metadata?: Record<string, string>;
|
|
72
|
+
}): Promise<{
|
|
73
|
+
[x: string]: unknown;
|
|
74
|
+
workspace_id: string;
|
|
75
|
+
owner_agent_id: string;
|
|
76
|
+
deleted_at?: string | null | undefined;
|
|
77
|
+
}>;
|
|
78
|
+
syncKnowledgeSource(body: KnowledgeSyncRequest): Promise<KnowledgeSyncResponse>;
|
|
79
|
+
/** Validate, then write: a preview proves the request before anything changes. */
|
|
80
|
+
syncKnowledgeSourceChecked(body: Omit<KnowledgeSyncRequest, 'mode'>): Promise<{
|
|
81
|
+
preview: KnowledgeSyncResponse;
|
|
82
|
+
applied: KnowledgeSyncResponse;
|
|
83
|
+
}>;
|
|
84
|
+
private call;
|
|
85
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// HiveMem holds project knowledge: one workspace per project, with each reference file synced
|
|
2
|
+
// as a revision-aware source (POST /v1/knowledge/sources/sync). ArdentStudio calls it with its
|
|
3
|
+
// own Oathweave service identity (audience `hivemem`), linked in HiveMem's
|
|
4
|
+
// HIVEMEM_OATHWEAVE_SERVICES_JSON with the memories:write and workspaces:write scopes.
|
|
5
|
+
import { createHash } from 'node:crypto';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { trimTrailingSlashes } from '../url.js';
|
|
8
|
+
export class HiveMemError extends Error {
|
|
9
|
+
status;
|
|
10
|
+
name = 'HiveMemError';
|
|
11
|
+
constructor(message, status) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.status = status;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export const knowledgeSyncResponseSchema = z.object({
|
|
17
|
+
mode: z.enum(['preview', 'apply']),
|
|
18
|
+
workspace_id: z.string(),
|
|
19
|
+
project_id: z.string(),
|
|
20
|
+
source_id: z.string(),
|
|
21
|
+
revision: z.string(),
|
|
22
|
+
created: z.number().int(),
|
|
23
|
+
superseded: z.number().int(),
|
|
24
|
+
retired: z.number().int(),
|
|
25
|
+
unchanged: z.number().int(),
|
|
26
|
+
}).loose();
|
|
27
|
+
export const workspaceSchema = z.object({ workspace_id: z.string(), owner_agent_id: z.string(), deleted_at: z.string().nullable().optional() }).loose();
|
|
28
|
+
/** HiveMem limits one source sync to 500 chunks, 64 KiB per chunk and 4 MiB in total. */
|
|
29
|
+
export const HIVEMEM_MAX_CHUNKS = 500;
|
|
30
|
+
export const HIVEMEM_MAX_CHUNK_BYTES = 65_536;
|
|
31
|
+
export const HIVEMEM_MAX_SYNC_BYTES = 4 * 1024 * 1024;
|
|
32
|
+
export function chunkHash(content) {
|
|
33
|
+
return createHash('sha256').update(content).digest('hex');
|
|
34
|
+
}
|
|
35
|
+
export class HiveMemClient {
|
|
36
|
+
options;
|
|
37
|
+
request;
|
|
38
|
+
baseUrl;
|
|
39
|
+
constructor(options) {
|
|
40
|
+
this.options = options;
|
|
41
|
+
this.request = options.fetch ?? ((input, init) => fetch(input, init));
|
|
42
|
+
this.baseUrl = trimTrailingSlashes(options.baseUrl);
|
|
43
|
+
}
|
|
44
|
+
/** Unauthenticated liveness of the HiveMem service. */
|
|
45
|
+
async health() {
|
|
46
|
+
const response = await this.request(`${this.baseUrl}/v1/health`, { redirect: 'error', signal: AbortSignal.timeout(5_000) });
|
|
47
|
+
if (!response.ok)
|
|
48
|
+
throw new HiveMemError(`HiveMem health answered HTTP ${response.status}`, response.status);
|
|
49
|
+
return z.object({ status: z.string() }).loose().parse(await response.json());
|
|
50
|
+
}
|
|
51
|
+
/** Create the project workspace. HiveMem returns the existing workspace when it already exists. */
|
|
52
|
+
async ensureWorkspace(input) {
|
|
53
|
+
return workspaceSchema.parse(await this.call('POST', '/v1/workspaces', {
|
|
54
|
+
workspace_id: input.workspace_id, title: input.title.slice(0, 200), description: input.description ?? null, metadata: input.metadata ?? {},
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
async syncKnowledgeSource(body) {
|
|
58
|
+
if (body.chunks.length > HIVEMEM_MAX_CHUNKS)
|
|
59
|
+
throw new HiveMemError(`A source sync holds at most ${HIVEMEM_MAX_CHUNKS} chunks`, 400);
|
|
60
|
+
return knowledgeSyncResponseSchema.parse(await this.call('POST', '/v1/knowledge/sources/sync', body));
|
|
61
|
+
}
|
|
62
|
+
/** Validate, then write: a preview proves the request before anything changes. */
|
|
63
|
+
async syncKnowledgeSourceChecked(body) {
|
|
64
|
+
const preview = await this.syncKnowledgeSource({ ...body, mode: 'preview' });
|
|
65
|
+
const applied = await this.syncKnowledgeSource({ ...body, mode: 'apply' });
|
|
66
|
+
return { preview, applied };
|
|
67
|
+
}
|
|
68
|
+
async call(method, path, body) {
|
|
69
|
+
const attempt = async () => this.request(`${this.baseUrl}${path}`, {
|
|
70
|
+
method,
|
|
71
|
+
headers: { authorization: `Bearer ${await this.options.tokens.token()}`, accept: 'application/json', ...(body !== undefined ? { 'content-type': 'application/json' } : {}) },
|
|
72
|
+
...(body !== undefined ? { body: JSON.stringify(body) } : {}),
|
|
73
|
+
redirect: 'error',
|
|
74
|
+
signal: AbortSignal.timeout(this.options.timeoutMs ?? 30_000),
|
|
75
|
+
});
|
|
76
|
+
let response = await attempt();
|
|
77
|
+
if (response.status === 401) {
|
|
78
|
+
await response.body?.cancel();
|
|
79
|
+
this.options.tokens.invalidate();
|
|
80
|
+
response = await attempt();
|
|
81
|
+
}
|
|
82
|
+
if (!response.ok) {
|
|
83
|
+
const detail = await response.json().catch(() => null);
|
|
84
|
+
const message = typeof detail?.detail === 'string' ? detail.detail : typeof detail?.error === 'string' ? detail.error : `HiveMem answered HTTP ${response.status}`;
|
|
85
|
+
throw new HiveMemError(message.slice(0, 300), response.status);
|
|
86
|
+
}
|
|
87
|
+
return response.status === 204 ? null : response.json();
|
|
88
|
+
}
|
|
89
|
+
}
|