@hivemagnus/ardent-studio 0.0.0-stage → 0.1.1

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.
Files changed (159) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +12 -0
  3. package/README.md +133 -2
  4. package/dist/agents/config-edit.d.ts +20 -0
  5. package/dist/agents/config-edit.js +75 -0
  6. package/dist/agents/directory.d.ts +27 -0
  7. package/dist/agents/directory.js +97 -0
  8. package/dist/agents/operations.d.ts +47 -0
  9. package/dist/agents/operations.js +93 -0
  10. package/dist/auth/links.d.ts +27 -0
  11. package/dist/auth/links.js +46 -0
  12. package/dist/auth/oathweave.d.ts +46 -0
  13. package/dist/auth/oathweave.js +123 -0
  14. package/dist/blobs/store.d.ts +45 -0
  15. package/dist/blobs/store.js +159 -0
  16. package/dist/clients/chattermost.d.ts +16 -0
  17. package/dist/clients/chattermost.js +36 -0
  18. package/dist/clients/hivemem.d.ts +85 -0
  19. package/dist/clients/hivemem.js +89 -0
  20. package/dist/clients/magnus.d.ts +417 -0
  21. package/dist/clients/magnus.js +343 -0
  22. package/dist/clients/service-token.d.ts +24 -0
  23. package/dist/clients/service-token.js +87 -0
  24. package/dist/clients/sse.d.ts +8 -0
  25. package/dist/clients/sse.js +42 -0
  26. package/dist/conductor/activity.d.ts +38 -0
  27. package/dist/conductor/activity.js +101 -0
  28. package/dist/conductor/addressing.d.ts +24 -0
  29. package/dist/conductor/addressing.js +42 -0
  30. package/dist/conductor/conductor.d.ts +225 -0
  31. package/dist/conductor/conductor.js +939 -0
  32. package/dist/conductor/follower.d.ts +48 -0
  33. package/dist/conductor/follower.js +154 -0
  34. package/dist/conductor/live.d.ts +23 -0
  35. package/dist/conductor/live.js +32 -0
  36. package/dist/conductor/prompting.d.ts +74 -0
  37. package/dist/conductor/prompting.js +177 -0
  38. package/dist/config.d.ts +52 -0
  39. package/dist/config.js +163 -0
  40. package/dist/db/database.d.ts +12 -0
  41. package/dist/db/database.js +62 -0
  42. package/dist/db/json.d.ts +8 -0
  43. package/dist/db/json.js +13 -0
  44. package/dist/db/migrations.d.ts +6 -0
  45. package/dist/db/migrations.js +571 -0
  46. package/dist/db/repos/agents.d.ts +86 -0
  47. package/dist/db/repos/agents.js +92 -0
  48. package/dist/db/repos/audit.d.ts +37 -0
  49. package/dist/db/repos/audit.js +20 -0
  50. package/dist/db/repos/events.d.ts +29 -0
  51. package/dist/db/repos/events.js +55 -0
  52. package/dist/db/repos/files.d.ts +41 -0
  53. package/dist/db/repos/files.js +72 -0
  54. package/dist/db/repos/idempotency.d.ts +27 -0
  55. package/dist/db/repos/idempotency.js +46 -0
  56. package/dist/db/repos/links.d.ts +47 -0
  57. package/dist/db/repos/links.js +99 -0
  58. package/dist/db/repos/projects.d.ts +44 -0
  59. package/dist/db/repos/projects.js +107 -0
  60. package/dist/db/repos/proposals.d.ts +46 -0
  61. package/dist/db/repos/proposals.js +65 -0
  62. package/dist/db/repos/review.d.ts +191 -0
  63. package/dist/db/repos/review.js +195 -0
  64. package/dist/db/repos/room.d.ts +163 -0
  65. package/dist/db/repos/room.js +151 -0
  66. package/dist/db/repos/sessions.d.ts +36 -0
  67. package/dist/db/repos/sessions.js +30 -0
  68. package/dist/db/repos/summaries.d.ts +22 -0
  69. package/dist/db/repos/summaries.js +105 -0
  70. package/dist/db/repos/tasks.d.ts +103 -0
  71. package/dist/db/repos/tasks.js +112 -0
  72. package/dist/db/repos/team.d.ts +49 -0
  73. package/dist/db/repos/team.js +95 -0
  74. package/dist/db/repos/templates.d.ts +55 -0
  75. package/dist/db/repos/templates.js +120 -0
  76. package/dist/db/store.d.ts +57 -0
  77. package/dist/db/store.js +108 -0
  78. package/dist/events/bus.d.ts +21 -0
  79. package/dist/events/bus.js +31 -0
  80. package/dist/events/types.d.ts +3 -0
  81. package/dist/events/types.js +1 -0
  82. package/dist/ids.d.ts +28 -0
  83. package/dist/ids.js +81 -0
  84. package/dist/index.d.ts +18 -0
  85. package/dist/index.js +17 -0
  86. package/dist/knowledge/extract.d.ts +17 -0
  87. package/dist/knowledge/extract.js +82 -0
  88. package/dist/knowledge/sync.d.ts +40 -0
  89. package/dist/knowledge/sync.js +172 -0
  90. package/dist/logger.d.ts +5 -0
  91. package/dist/logger.js +11 -0
  92. package/dist/main.d.ts +2 -0
  93. package/dist/main.js +42 -0
  94. package/dist/review/anchors.d.ts +16 -0
  95. package/dist/review/anchors.js +67 -0
  96. package/dist/review/context.d.ts +4 -0
  97. package/dist/review/context.js +29 -0
  98. package/dist/review/docx.d.ts +29 -0
  99. package/dist/review/docx.js +21 -0
  100. package/dist/review/export.d.ts +16 -0
  101. package/dist/review/export.js +84 -0
  102. package/dist/review/importer.d.ts +68 -0
  103. package/dist/review/importer.js +215 -0
  104. package/dist/review/index.d.ts +13 -0
  105. package/dist/review/index.js +7 -0
  106. package/dist/server/app.d.ts +5 -0
  107. package/dist/server/app.js +44 -0
  108. package/dist/server/deps.d.ts +43 -0
  109. package/dist/server/deps.js +17 -0
  110. package/dist/server/env.d.ts +6 -0
  111. package/dist/server/env.js +1 -0
  112. package/dist/server/errors.d.ts +12 -0
  113. package/dist/server/errors.js +25 -0
  114. package/dist/server/routes/agent-studio.d.ts +5 -0
  115. package/dist/server/routes/agent-studio.js +441 -0
  116. package/dist/server/routes/agents.d.ts +3 -0
  117. package/dist/server/routes/agents.js +4 -0
  118. package/dist/server/routes/files.d.ts +3 -0
  119. package/dist/server/routes/files.js +88 -0
  120. package/dist/server/routes/health.d.ts +3 -0
  121. package/dist/server/routes/health.js +31 -0
  122. package/dist/server/routes/links.d.ts +3 -0
  123. package/dist/server/routes/links.js +79 -0
  124. package/dist/server/routes/projects.d.ts +3 -0
  125. package/dist/server/routes/projects.js +119 -0
  126. package/dist/server/routes/review.d.ts +3 -0
  127. package/dist/server/routes/review.js +198 -0
  128. package/dist/server/routes/room.d.ts +9 -0
  129. package/dist/server/routes/room.js +224 -0
  130. package/dist/server/routes/stream.d.ts +4 -0
  131. package/dist/server/routes/stream.js +104 -0
  132. package/dist/server/routes/team.d.ts +3 -0
  133. package/dist/server/routes/team.js +183 -0
  134. package/dist/server/routes/templates.d.ts +11 -0
  135. package/dist/server/routes/templates.js +103 -0
  136. package/dist/server/routes/work.d.ts +3 -0
  137. package/dist/server/routes/work.js +139 -0
  138. package/dist/server/routing.d.ts +31 -0
  139. package/dist/server/routing.js +132 -0
  140. package/dist/service.d.ts +34 -0
  141. package/dist/service.js +93 -0
  142. package/dist/shared/browser.d.ts +5824 -0
  143. package/dist/shared/browser.js +1318 -0
  144. package/dist/team/proposals.d.ts +129 -0
  145. package/dist/team/proposals.js +349 -0
  146. package/dist/team/service.d.ts +12 -0
  147. package/dist/team/service.js +13 -0
  148. package/dist/team/validation.d.ts +37 -0
  149. package/dist/team/validation.js +157 -0
  150. package/dist/templates/secrets.d.ts +2 -0
  151. package/dist/templates/secrets.js +23 -0
  152. package/dist/templates/seeds.d.ts +34 -0
  153. package/dist/templates/seeds.js +277 -0
  154. package/dist/url.d.ts +2 -0
  155. package/dist/url.js +7 -0
  156. package/dist/version.d.ts +2 -0
  157. package/dist/version.js +11 -0
  158. package/docs/openapi-browser.json +12658 -0
  159. package/package.json +95 -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
+ }
@@ -0,0 +1,417 @@
1
+ import { ARDENT_SERVICE_CONFIG_PATHS, ardentAgentDeployRequestSchema, ardentAgentOperationSchema, ardentConfigFileSchema, ardentConfigSavedSchema, ardentContextItemSchema, ardentDevelopmentNoteSchema, ardentDevelopmentRecordSchema, ardentIdentityFileSchema, ardentMissionSubmitSchema, ardentPreviewSubmitSchema, ardentServiceProfileSchema, ardentSessionContextSchema, ardentSessionOpenSchema, ardentSkillInstallResultSchema, ardentSkillInstallSchema, ardentTaskJournalEventSchema, ardentTeamMissionSchema } from '@hivemagnus/magnus-contracts/ardent-service';
2
+ import { z } from 'zod';
3
+ import { type SseMessage } from './sse.js';
4
+ import type { ServiceTokenProvider } from './service-token.js';
5
+ export { ARDENT_SERVICE_ADMIN_ACTIONS, ARDENT_SERVICE_CONFIG_PATHS, ARDENT_STUDIO_CAPABILITY, ARDENT_STUDIO_EVENT_KINDS, ardentAgentOperationSchema, ardentTaskDoneEventSchema, ardentTaskJournalEventSchema, ardentTaskTextEventSchema, ardentTeamMissionSchema, } from '@hivemagnus/magnus-contracts/ardent-service';
6
+ export { ARDENT_CONTEXT_ITEMS_MAX_BYTES } from '@hivemagnus/magnus-contracts/browser';
7
+ export declare const ACTING_SUBJECT_HEADER = "x-acting-subject";
8
+ export declare class MagnusError extends Error {
9
+ readonly status: number;
10
+ readonly code: string;
11
+ name: string;
12
+ constructor(message: string, status: number, code: string);
13
+ }
14
+ export interface AgentRefParts {
15
+ nodeId: string;
16
+ profile: string;
17
+ }
18
+ export declare function parseAgentRef(ref: string): AgentRefParts;
19
+ export declare function agentRef(nodeId: string, profile: string): string;
20
+ export interface CallContext {
21
+ /** The Oathweave subject of the person this call acts for. Omit for Studio's own background work. */
22
+ actingSubject?: string | undefined;
23
+ signal?: AbortSignal | undefined;
24
+ }
25
+ export type MagnusArdentProfile = z.infer<typeof ardentServiceProfileSchema>;
26
+ /**
27
+ * GET /ardent/installations and /ardent/installations/{nodeId}. The service contract answers these
28
+ * as records, so Studio reads only the fields it uses (Magnus ArdentFleetInstallationSchema).
29
+ */
30
+ export declare const magnusArdentInstallationSchema: z.ZodObject<{
31
+ installed: z.ZodBoolean;
32
+ version: z.ZodNullable<z.ZodString>;
33
+ owner: z.ZodString;
34
+ profiles: z.ZodArray<z.ZodObject<{
35
+ error: z.ZodNullable<z.ZodString>;
36
+ name: z.ZodString;
37
+ id: z.ZodString;
38
+ backend: z.ZodNullable<z.ZodEnum<{
39
+ llamacpp: "llamacpp";
40
+ codex: "codex";
41
+ }>>;
42
+ running: z.ZodBoolean;
43
+ apiPort: z.ZodNullable<z.ZodNumber>;
44
+ a2aEnabled: z.ZodBoolean;
45
+ channels: z.ZodRecord<z.ZodString, z.ZodBoolean>;
46
+ }, z.core.$strip>>;
47
+ checkedAt: z.ZodString;
48
+ nodeId: z.ZodString;
49
+ nodeName: z.ZodString;
50
+ hostname: z.ZodString;
51
+ reachable: z.ZodBoolean;
52
+ error: z.ZodNullable<z.ZodString>;
53
+ capabilities: z.ZodOptional<z.ZodObject<{
54
+ studio: z.ZodOptional<z.ZodNumber>;
55
+ }, z.core.$loose>>;
56
+ }, z.core.$strip>;
57
+ export type MagnusArdentInstallation = z.infer<typeof magnusArdentInstallationSchema>;
58
+ export declare const ardentTaskStateSchema: z.ZodEnum<{
59
+ unknown: "unknown";
60
+ failed: "failed";
61
+ partial: "partial";
62
+ queued: "queued";
63
+ running: "running";
64
+ cancelled: "cancelled";
65
+ input_required: "input_required";
66
+ completed: "completed";
67
+ }>;
68
+ export declare const ardentTaskSchema: z.ZodObject<{
69
+ id: z.ZodString;
70
+ caller: z.ZodString;
71
+ context: z.ZodString;
72
+ session_id: z.ZodNullable<z.ZodString>;
73
+ prompt: z.ZodString;
74
+ content_hash: z.ZodString;
75
+ idempotency_key: z.ZodNullable<z.ZodString>;
76
+ backend: z.ZodString;
77
+ state: z.ZodEnum<{
78
+ unknown: "unknown";
79
+ failed: "failed";
80
+ partial: "partial";
81
+ queued: "queued";
82
+ running: "running";
83
+ cancelled: "cancelled";
84
+ input_required: "input_required";
85
+ completed: "completed";
86
+ }>;
87
+ result: z.ZodNullable<z.ZodString>;
88
+ error: z.ZodNullable<z.ZodString>;
89
+ deadline_ms: z.ZodNumber;
90
+ created_ms: z.ZodNumber;
91
+ updated_ms: z.ZodNumber;
92
+ }, z.core.$strip>;
93
+ export declare const ardentStatusSchema: z.ZodObject<{
94
+ version: z.ZodString;
95
+ profile: z.ZodString;
96
+ backend: z.ZodString;
97
+ tasks: z.ZodNumber;
98
+ }, z.core.$strip>;
99
+ export declare const ardentMemoryStatusSchema: z.ZodObject<{
100
+ status: z.ZodEnum<{
101
+ ready: "ready";
102
+ degraded: "degraded";
103
+ }>;
104
+ agent_id: z.ZodString;
105
+ workspace_id: z.ZodString;
106
+ retrieval: z.ZodNullable<z.ZodString>;
107
+ storage: z.ZodNullable<z.ZodString>;
108
+ reason: z.ZodNullable<z.ZodString>;
109
+ }, z.core.$strip>;
110
+ export declare const ardentSkillSchema: z.ZodObject<{
111
+ name: z.ZodString;
112
+ enabled: z.ZodBoolean;
113
+ }, z.core.$loose>;
114
+ /** Profile resources Magnus lets a service identity read (the resource note of ardentServiceRoutes). */
115
+ export type ArdentResource = 'status' | 'profile' | 'skills' | 'memory/status' | 'sessions' | `sessions/${string}/messages` | 'tasks' | `tasks/${string}` | `tasks/${string}/events` | 'identity/soul' | 'identity/identity' | 'config' | `tasks/${string}/artifacts` | `artifacts/${string}/manifest` | 'development';
116
+ /** Actions released Magnus accepts on POST …/action (an ADMIN person; a service identity gets the Studio subset below). */
117
+ export declare const RELEASED_ACTIONS: readonly ["profile-create", "config-validate", "config-save", "peer-validate", "peer-save", "identity-save", "identity-restore", "provider-test", "channel-test", "peer-test", "memory-search", "task-submit", "task-cancel", "skill-set", "service-start", "service-stop", "service-restart", "package-install", "context-stage", "context-adopt", "context-rollback"];
118
+ /**
119
+ * Actions added for Ardent Project Studio. session-open needs studio >= 1, skill-install studio >= 3 and a
120
+ * Magnus with a HiveSkills registry, the others studio >= 2 and Ardent 2.2.0.
121
+ */
122
+ export declare const STUDIO_ACTIONS: readonly ["session-open", "mission-submit", "task-pause", "task-resume", "preview-submit", "development-note", "skill-install"];
123
+ export type MagnusArdentAction = typeof RELEASED_ACTIONS[number] | typeof STUDIO_ACTIONS[number];
124
+ /** A configuration value a service's config-save may change (ARDENT_SERVICE_CONFIG_PATHS); anything else answers 403 CONFIG_PATH_FORBIDDEN. */
125
+ export type ArdentServiceConfigPath = typeof ARDENT_SERVICE_CONFIG_PATHS[number];
126
+ /**
127
+ * Whether Magnus lets the Studio service identity run service-restart. It does not: a service may run
128
+ * only the session, task, mission, preview, development and ARDENT_SERVICE_ADMIN_ACTIONS actions, so a
129
+ * profile restart stays a person's act in the Magnus console.
130
+ */
131
+ export declare const ARDENT_SERVICE_CAN_RESTART = false;
132
+ export type ArdentSessionContext = z.infer<typeof ardentSessionContextSchema>;
133
+ export type ArdentIdentityFile = z.infer<typeof ardentIdentityFileSchema>;
134
+ export type ArdentConfigFile = z.infer<typeof ardentConfigFileSchema>;
135
+ export type ArdentConfigSaved = z.infer<typeof ardentConfigSavedSchema>;
136
+ export type ArdentSkillInstallResult = z.infer<typeof ardentSkillInstallResultSchema>;
137
+ export type ArdentTeamMission = z.infer<typeof ardentTeamMissionSchema>;
138
+ export type ArdentContextItem = z.infer<typeof ardentContextItemSchema>;
139
+ export type ArdentDevelopmentRecord = z.infer<typeof ardentDevelopmentRecordSchema>;
140
+ export type ArdentTaskEvent = z.infer<typeof ardentTaskJournalEventSchema>;
141
+ export type NewAgentRequest = z.input<typeof ardentAgentDeployRequestSchema>;
142
+ export type MagnusAgentOperation = z.infer<typeof ardentAgentOperationSchema>;
143
+ /** action task-submit: the prompt is at most 16000 characters and the idempotency key a UUID. */
144
+ declare const ardentTaskSubmitSchema: z.ZodObject<{
145
+ prompt: z.ZodString;
146
+ idempotency_key: z.ZodString;
147
+ session_id: z.ZodOptional<z.ZodString>;
148
+ }, z.core.$strict>;
149
+ export interface MagnusClientOptions {
150
+ baseUrl: string;
151
+ tokens: Pick<ServiceTokenProvider, 'token' | 'invalidate'>;
152
+ fetch?: typeof fetch;
153
+ timeoutMs?: number;
154
+ }
155
+ export declare class MagnusClient {
156
+ private readonly options;
157
+ private readonly request;
158
+ private readonly baseUrl;
159
+ constructor(options: MagnusClientOptions);
160
+ /** Every Magnus-managed Ardent profile across the fleet. */
161
+ listProfiles(context?: CallContext): Promise<MagnusArdentProfile[]>;
162
+ listInstallations(context?: CallContext): Promise<MagnusArdentInstallation[]>;
163
+ getInstallation(nodeId: string, context?: CallContext): Promise<MagnusArdentInstallation>;
164
+ /** Read an allow-listed Ardent management resource through Magnus. */
165
+ resource(ref: string, resource: ArdentResource, context?: CallContext & {
166
+ query?: {
167
+ after?: number | string;
168
+ limit?: number;
169
+ kind?: string;
170
+ context?: ArdentSessionContext;
171
+ };
172
+ }): Promise<unknown>;
173
+ status(ref: string, context?: CallContext): Promise<{
174
+ version: string;
175
+ profile: string;
176
+ backend: string;
177
+ tasks: number;
178
+ }>;
179
+ memoryStatus(ref: string, context?: CallContext): Promise<{
180
+ status: "ready" | "degraded";
181
+ agent_id: string;
182
+ workspace_id: string;
183
+ retrieval: string | null;
184
+ storage: string | null;
185
+ reason: string | null;
186
+ }>;
187
+ task(ref: string, taskId: string, context?: CallContext): Promise<{
188
+ id: string;
189
+ caller: string;
190
+ context: string;
191
+ session_id: string | null;
192
+ prompt: string;
193
+ content_hash: string;
194
+ idempotency_key: string | null;
195
+ backend: string;
196
+ state: "unknown" | "failed" | "partial" | "queued" | "running" | "cancelled" | "input_required" | "completed";
197
+ result: string | null;
198
+ error: string | null;
199
+ deadline_ms: number;
200
+ created_ms: number;
201
+ updated_ms: number;
202
+ }>;
203
+ skills(ref: string, context?: CallContext): Promise<Array<z.infer<typeof ardentSkillSchema>>>;
204
+ taskEvents(ref: string, taskId: string, after?: number, context?: CallContext): Promise<{
205
+ sequence: number;
206
+ task_id: string;
207
+ kind: string;
208
+ created_ms: number;
209
+ detail?: unknown;
210
+ }[]>;
211
+ identity(ref: string, kind: 'soul' | 'identity', context?: CallContext): Promise<ArdentIdentityFile>;
212
+ /** The profile's config.yaml and its revision. Needs an acting Magnus ADMIN. */
213
+ config(ref: string, context?: CallContext): Promise<ArdentConfigFile>;
214
+ /** Artifact bytes, buffered (Magnus caps them; see MAGNUS_AGENT_ARDENT_ARTIFACT_MAX_BYTES). Prefer artifactStream for large files. */
215
+ artifact(ref: string, sha256: string, context?: CallContext): Promise<Uint8Array>;
216
+ /** Artifact bytes as Magnus streams them, never buffered here. The caller verifies the digest. */
217
+ artifactStream(ref: string, sha256: string, context?: CallContext): Promise<{
218
+ body: ReadableStream<Uint8Array>;
219
+ size: number | undefined;
220
+ }>;
221
+ /** Run a management action through Magnus's audited action route. */
222
+ action(ref: string, action: MagnusArdentAction, input?: {
223
+ target?: string;
224
+ body?: unknown;
225
+ }, context?: CallContext): Promise<unknown>;
226
+ /** A direct task. The prompt is at most 16000 characters; the idempotency key is a UUID; a session (studio >= 1) carries the conversation. */
227
+ submitTask(ref: string, body: z.input<typeof ardentTaskSubmitSchema>, context?: CallContext): Promise<{
228
+ task_id: string;
229
+ state: string;
230
+ }>;
231
+ cancelTask(ref: string, taskId: string, context?: CallContext): Promise<unknown>;
232
+ /** Ardent rejects a stale revision with 409, so concurrent edits never overwrite each other. */
233
+ saveIdentity(ref: string, kind: 'soul' | 'identity', body: {
234
+ text: string;
235
+ revision: string;
236
+ }, context?: CallContext): Promise<ArdentIdentityFile>;
237
+ /** Each change answers the next configuration revision: chain it into the next skill-set or config-save. */
238
+ setSkill(ref: string, name: string, body: {
239
+ enabled: boolean;
240
+ revision: string;
241
+ }, context?: CallContext): Promise<ArdentConfigSaved>;
242
+ /**
243
+ * Install a HiveSkills catalog release (studio >= 3). Magnus answers 503 HIVESKILLS_UNCONFIGURED without a registry,
244
+ * 409 SKILL_VERSION_UNAVAILABLE or SKILL_CONFLICT, and 422 SKILL_ARCHIVE_INVALID; a Magnus that predates the action
245
+ * answers 400 "Invalid Ardent action".
246
+ */
247
+ installSkill(ref: string, body: z.input<typeof ardentSkillInstallSchema>, context?: CallContext): Promise<ArdentSkillInstallResult>;
248
+ /** Magnus refuses (403 CONFIG_PATH_FORBIDDEN) a text that changes anything outside ARDENT_SERVICE_CONFIG_PATHS. */
249
+ saveConfig(ref: string, body: {
250
+ text: string;
251
+ revision: string;
252
+ }, context?: CallContext): Promise<ArdentConfigSaved>;
253
+ /** The node agent's Studio level for a node: 0 when it reports none. */
254
+ studioLevel(nodeId: string, context?: CallContext): Promise<number>;
255
+ /** Open (or reopen: the same key answers the same session) an Ardent session. studio >= 1; a context needs studio >= 2. */
256
+ openSession(ref: string, body: z.input<typeof ardentSessionOpenSchema>, context?: CallContext): Promise<{
257
+ id: string;
258
+ caller: string;
259
+ context: string;
260
+ key: string;
261
+ created_ms: number;
262
+ updated_ms: number;
263
+ }>;
264
+ /** Submit a team mission in a session opened with context mission. studio >= 2. */
265
+ submitMission(ref: string, body: z.input<typeof ardentMissionSubmitSchema>, context?: CallContext): Promise<{
266
+ task_id: string;
267
+ state: string;
268
+ }>;
269
+ /** Pause at the next step boundary. studio >= 2; a finished task answers 409. */
270
+ pauseTask(ref: string, taskId: string, context?: CallContext): Promise<{
271
+ task_id: string;
272
+ state: string;
273
+ admission: "paused" | "open";
274
+ }>;
275
+ resumeTask(ref: string, taskId: string, context?: CallContext): Promise<{
276
+ task_id: string;
277
+ state: string;
278
+ admission: "paused" | "open";
279
+ }>;
280
+ /** A side-effect-free preview task with draft overrides. studio >= 2; needs the acting person. */
281
+ submitPreview(ref: string, body: z.input<typeof ardentPreviewSubmitSchema>, context: CallContext): Promise<{
282
+ task_id: string;
283
+ state: string;
284
+ }>;
285
+ /** Record a development note. studio >= 2; needs the acting person. */
286
+ addDevelopmentNote(ref: string, body: z.input<typeof ardentDevelopmentNoteSchema>, context: CallContext): Promise<{
287
+ id: string;
288
+ agent_ref: string;
289
+ kind: string;
290
+ title: string;
291
+ body: string;
292
+ author: "agent" | "operator" | "runtime";
293
+ epistemic: "agent_reported" | "operator_reported" | "observed";
294
+ before_sha256: string | null;
295
+ after_sha256: string | null;
296
+ sources: {
297
+ kind: string;
298
+ ref: string;
299
+ }[];
300
+ created_at: string;
301
+ }>;
302
+ /** Artifact manifests a task registered, oldest first. studio >= 2. */
303
+ taskArtifacts(ref: string, taskId: string, context?: CallContext): Promise<{
304
+ task_id: string;
305
+ superseded_by_sha256: string | null;
306
+ manifest: {
307
+ [x: string]: unknown;
308
+ schema_version: string;
309
+ name: string;
310
+ mime: string;
311
+ sha256: string;
312
+ size: number;
313
+ revision: number;
314
+ supersedes_sha256: string | null;
315
+ acceptance_status: "partial" | "unreviewed" | "rejected" | "approved";
316
+ created_at: number;
317
+ expires_at?: number | undefined;
318
+ };
319
+ }[]>;
320
+ /** One artifact manifest. studio >= 2. */
321
+ artifactManifest(ref: string, sha256: string, context?: CallContext): Promise<{
322
+ task_id: string;
323
+ superseded_by_sha256: string | null;
324
+ manifest: {
325
+ [x: string]: unknown;
326
+ schema_version: string;
327
+ name: string;
328
+ mime: string;
329
+ sha256: string;
330
+ size: number;
331
+ revision: number;
332
+ supersedes_sha256: string | null;
333
+ acceptance_status: "partial" | "unreviewed" | "rejected" | "approved";
334
+ created_at: number;
335
+ expires_at?: number | undefined;
336
+ };
337
+ }>;
338
+ /** Portable development records, cursor-paginated. studio >= 2. */
339
+ development(ref: string, query?: {
340
+ after?: string;
341
+ limit?: number;
342
+ kind?: string;
343
+ }, context?: CallContext): Promise<{
344
+ records: {
345
+ id: string;
346
+ agent_ref: string;
347
+ kind: string;
348
+ title: string;
349
+ body: string;
350
+ author: "agent" | "operator" | "runtime";
351
+ epistemic: "agent_reported" | "operator_reported" | "observed";
352
+ before_sha256: string | null;
353
+ after_sha256: string | null;
354
+ sources: {
355
+ kind: string;
356
+ ref: string;
357
+ }[];
358
+ created_at: string;
359
+ }[];
360
+ next: string | null;
361
+ }>;
362
+ /**
363
+ * Follow a task's journal and live reply text (GET …/tasks/:id/stream, piped unbuffered by
364
+ * Magnus). Yields task.event (resumable, id = journal sequence), task.text, task.delta and
365
+ * task.done. Ardent ends a stream after 60 seconds; reconnect with `after`.
366
+ */
367
+ streamTask(ref: string, taskId: string, options?: CallContext & {
368
+ after?: number;
369
+ }): AsyncGenerator<SseMessage>;
370
+ /** Magnus New Agent deploy operation. Magnus runs it only when the acting person is a Magnus ADMIN. */
371
+ createAgent(body: NewAgentRequest, context: CallContext): Promise<{
372
+ operationId: string;
373
+ }>;
374
+ /** Step receipts of a New Agent or Enable HiveMem operation. */
375
+ agentOperation(operationId: string, context?: CallContext): Promise<{
376
+ id: string;
377
+ kind: "hivemem" | "deploy";
378
+ nodeId: string;
379
+ profile: string;
380
+ status: "failed" | "running" | "succeeded";
381
+ steps: {
382
+ name: "profile-create" | "config-save" | "skill-set" | "service-start" | "service-restart" | "profile-check" | "identity-soul" | "identity-identity" | "hivemem-enroll" | "ready-probe";
383
+ status: "pending" | "failed" | "running" | "succeeded" | "skipped";
384
+ startedAt: string | null;
385
+ finishedAt: string | null;
386
+ receipt: Record<string, unknown> | null;
387
+ error: string | null;
388
+ }[];
389
+ error: string | null;
390
+ createdBy: string;
391
+ attempts: number;
392
+ request: {
393
+ apiPort: number | null;
394
+ model: {
395
+ emberpath_alias: string;
396
+ } | {
397
+ base_url: string;
398
+ model: string;
399
+ } | null;
400
+ skills: string[];
401
+ hivemem: boolean;
402
+ artifacts_max_bytes: number | null;
403
+ };
404
+ createdAt: string;
405
+ updatedAt: string;
406
+ completedAt: string | null;
407
+ }>;
408
+ /** Live operation updates: `operation` events, then one `done`. */
409
+ streamAgentOperation(operationId: string, options?: CallContext): AsyncGenerator<SseMessage>;
410
+ /** Resume a failed operation from its first unfinished step. Needs an acting ADMIN. */
411
+ resumeAgentOperation(operationId: string, context: CallContext): Promise<{
412
+ operationId: string;
413
+ }>;
414
+ private json;
415
+ private send;
416
+ private fail;
417
+ }