@moorline/contracts 0.0.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.
@@ -0,0 +1,575 @@
1
+ import type { Capability } from './capabilities.js';
2
+ import type { PluginManifest, RuntimeManagementContribution } from './plugin.js';
3
+ import type { RuntimeProviderTestResult } from './provider.js';
4
+ import type { RuntimeActionDefinition, RuntimeActorIdentity, RuntimeAttachmentPayload, RuntimeMessagePayload, RuntimeSurfaceState, RuntimeTransportEvent } from './transport.js';
5
+ import type { PendingRuntimeRequestRecord, ProviderRuntimeEvent, ProviderSessionStatus, ProviderThreadTokenUsage, RuntimeModeName } from './runtime.js';
6
+ export interface RuntimeDomainEvent {
7
+ eventId: string;
8
+ threadId: string;
9
+ spaceId?: string | null;
10
+ sessionId?: string | null;
11
+ missionId?: string | null;
12
+ sourceProviderEventId?: string | null;
13
+ createdAt: string;
14
+ type: string;
15
+ payload?: unknown;
16
+ }
17
+ export interface RuntimeActionDispatchResult {
18
+ handled: boolean;
19
+ reply?: RuntimeMessagePayload;
20
+ audit?: {
21
+ event: string;
22
+ payload?: Record<string, unknown>;
23
+ };
24
+ continueDispatch?: boolean;
25
+ }
26
+ export interface RuntimeToolResult {
27
+ content: string;
28
+ }
29
+ export interface SkillCatalogEntry {
30
+ name: string;
31
+ description?: string;
32
+ tags?: string[];
33
+ }
34
+ export interface LoadedSkill extends SkillCatalogEntry {
35
+ body?: string;
36
+ }
37
+ export interface WrittenSkillResult {
38
+ skillDir: string;
39
+ skillPath: string;
40
+ resourcePaths: string[];
41
+ }
42
+ export type RuntimeEntityRecord = {
43
+ id?: string;
44
+ sessionId?: string;
45
+ missionId?: string;
46
+ runId?: string;
47
+ threadId?: string;
48
+ spaceId?: string;
49
+ name?: string;
50
+ title?: string;
51
+ status?: string;
52
+ lifecycleStatus?: string;
53
+ runtimeMode?: RuntimeModeName;
54
+ };
55
+ export type SessionLifecycleStatus = 'hot' | 'cool' | 'archived';
56
+ export type RuntimeSessionRow = RuntimeEntityRecord & {
57
+ sessionId: string;
58
+ scopeId: string;
59
+ threadId: string;
60
+ spaceId: string;
61
+ spaceName: string;
62
+ workspacePath: string;
63
+ summary: string | null;
64
+ provider: string;
65
+ providerThreadId: string | null;
66
+ resumeThreadId: string | null;
67
+ providerStatus: ProviderSessionStatus;
68
+ activeTurnId: string | null;
69
+ createdAt: string;
70
+ updatedAt: string;
71
+ lastActivityAt: string;
72
+ archivedAt: string | null;
73
+ lastError: string | null;
74
+ lifecycleStatus: SessionLifecycleStatus;
75
+ runtimeMode: RuntimeModeName;
76
+ };
77
+ export type RuntimeMissionRow = RuntimeEntityRecord & {
78
+ missionId: string;
79
+ title: string;
80
+ spaceId: string;
81
+ };
82
+ export type RuntimeMissionRunRow = RuntimeEntityRecord & {
83
+ runId: string;
84
+ missionId: string;
85
+ };
86
+ export type RuntimeMissionHookBindingRow = RuntimeEntityRecord & {
87
+ bindingId: string;
88
+ missionId: string;
89
+ hookKey: string;
90
+ };
91
+ export interface RuntimeReceiptRecord {
92
+ threadId: string;
93
+ sessionId: string | null;
94
+ spaceId: string | null;
95
+ state: string;
96
+ updatedAt: string;
97
+ }
98
+ export interface RuntimeActivityRecord {
99
+ id?: string;
100
+ threadId?: string;
101
+ type?: string;
102
+ createdAt?: string;
103
+ }
104
+ export interface RuntimeProviderConnectionSnapshot {
105
+ threadId: string;
106
+ providerPackageId: string;
107
+ runtimeMode: RuntimeModeName;
108
+ workspacePath: string;
109
+ providerThreadId: string | null;
110
+ status: ProviderSessionStatus;
111
+ model: string | null;
112
+ accountLabel: string | null;
113
+ availableModels: string[];
114
+ updatedAt: string;
115
+ lastError: string | null;
116
+ tokenUsage?: ProviderThreadTokenUsage;
117
+ capabilityMetadata: Record<string, unknown>;
118
+ }
119
+ export interface RuntimeSessionSnapshot {
120
+ session: RuntimeSessionRow;
121
+ receipt: RuntimeReceiptRecord | null;
122
+ provider: RuntimeProviderConnectionSnapshot | null;
123
+ pendingRequests: PendingRuntimeRequestRecord[];
124
+ recentActivities: RuntimeActivityRecord[];
125
+ }
126
+ export interface RuntimeOverviewSnapshot {
127
+ sessions: RuntimeSessionSnapshot[];
128
+ receipts: RuntimeReceiptRecord[];
129
+ providers: RuntimeProviderConnectionSnapshot[];
130
+ projectionStates: Array<{
131
+ projector: string;
132
+ lastEventId: string | null;
133
+ lastAppliedAt: string;
134
+ failure: string | null;
135
+ }>;
136
+ openRequests: PendingRuntimeRequestRecord[];
137
+ }
138
+ export type RuntimeReloadMode = 'graceful' | 'force';
139
+ export interface RuntimeControlStatus {
140
+ acceptingNewWork: boolean;
141
+ reloadInProgress?: boolean;
142
+ providerRunning?: boolean;
143
+ }
144
+ export interface RuntimeControlResult {
145
+ accepted: boolean;
146
+ detail?: string;
147
+ }
148
+ export interface ProviderControlResult {
149
+ ok: boolean;
150
+ action: 'start' | 'stop';
151
+ scope: 'all' | 'thread';
152
+ threadId: string | null;
153
+ requestedCount: number;
154
+ affectedCount: number;
155
+ skippedCount: number;
156
+ failures: Array<{
157
+ threadId: string;
158
+ error: string;
159
+ }>;
160
+ message: string;
161
+ remediation?: string;
162
+ }
163
+ export type SessionInventoryScope = 'active' | 'archived' | 'all' | string;
164
+ export type SidecarScopeKind = 'global' | 'session' | 'ephemeral';
165
+ export type SidecarReadinessProbe = {
166
+ kind: 'none';
167
+ } | {
168
+ kind: 'stdio';
169
+ pattern: string;
170
+ stream?: 'stdout' | 'stderr' | 'both';
171
+ timeoutMs?: number;
172
+ };
173
+ export type ManagedSidecarScope = {
174
+ kind: 'global';
175
+ } | {
176
+ kind: 'session';
177
+ key: string;
178
+ } | {
179
+ kind: 'ephemeral';
180
+ key: string;
181
+ };
182
+ export interface ManagedSidecarLaunchSpec {
183
+ command: string;
184
+ args?: string[];
185
+ cwd?: string;
186
+ env?: Record<string, string>;
187
+ restart?: {
188
+ policy?: 'never' | 'on-failure';
189
+ maxRestarts?: number;
190
+ };
191
+ readiness?: SidecarReadinessProbe;
192
+ }
193
+ export interface ManagedSidecarDefinition {
194
+ name: string;
195
+ scope: ManagedSidecarScope;
196
+ launch: ManagedSidecarLaunchSpec;
197
+ }
198
+ export interface ManagedSidecarRecord {
199
+ id?: string;
200
+ sidecarId?: string;
201
+ instanceId?: string;
202
+ pluginId?: string;
203
+ name: string;
204
+ scopeKind: SidecarScopeKind;
205
+ scopeKey: string;
206
+ status: string;
207
+ }
208
+ export type AgentSurface = 'main_chat' | 'session' | 'mission';
209
+ export interface BeforeAgentPromptInput {
210
+ surface: AgentSurface;
211
+ spaceId: string;
212
+ actorId: string;
213
+ actorLabel: string;
214
+ text: string;
215
+ attachments?: RuntimeAttachmentPayload[];
216
+ session: RuntimeSessionRow | null;
217
+ }
218
+ export interface AfterAgentResponseInput extends BeforeAgentPromptInput {
219
+ replyMessage: string;
220
+ }
221
+ export interface CreatedSessionResult {
222
+ session: RuntimeSessionRow;
223
+ spaceId: string;
224
+ }
225
+ export type MissionHookCondition = Record<string, string | number | boolean | null>;
226
+ export interface MissionHookDispatchResult {
227
+ hookKey: string;
228
+ source: string;
229
+ bindingCount: number;
230
+ matchedBindingCount: number;
231
+ triggeredMissionIds: string[];
232
+ }
233
+ export type ArchivedSpaceTarget = {
234
+ kind: 'session';
235
+ session: RuntimeSessionRow;
236
+ } | {
237
+ kind: 'mission';
238
+ mission: RuntimeMissionRow;
239
+ };
240
+ export type SessionOwnerKind = 'mission' | 'run' | 'parent_session' | 'orchestrator';
241
+ export interface SessionOwnerLink {
242
+ kind: SessionOwnerKind;
243
+ id: string;
244
+ label?: string;
245
+ }
246
+ export interface SessionQueryFilter {
247
+ scope?: SessionInventoryScope;
248
+ lifecycleStatuses?: RuntimeSessionRow['lifecycleStatus'][];
249
+ runtimeModes?: RuntimeModeName[];
250
+ ownerKind?: SessionOwnerKind;
251
+ ownerId?: string;
252
+ tag?: string;
253
+ objectiveText?: string;
254
+ waitStates?: Array<'idle' | 'running' | 'waiting_for_approval' | 'waiting_for_input' | 'completed' | 'failed' | 'interrupted' | 'cancelled'>;
255
+ includeArchived?: boolean;
256
+ limit?: number;
257
+ }
258
+ export interface RetrievedMemorySnippet {
259
+ id: string;
260
+ content: string;
261
+ sourceRefs: string[];
262
+ strategy: 'symbolic' | 'semantic' | 'metadata';
263
+ }
264
+ export interface RuntimePluginAdminConfig {
265
+ accessGroupIds: string[];
266
+ userIds: string[];
267
+ allowTransportAdmin?: boolean;
268
+ managedAdminAccessGroup: {
269
+ enabled: boolean;
270
+ name: string;
271
+ };
272
+ managedMemberAccessGroup: {
273
+ enabled: boolean;
274
+ name: string;
275
+ };
276
+ }
277
+ export type RuntimePluginConfig = object;
278
+ export type RuntimePluginNamespaceState = RuntimeSurfaceState;
279
+ export interface RuntimeToolContext {
280
+ readonly actorId: string;
281
+ readonly config: RuntimePluginConfig;
282
+ getCurrentSpaceId(): string;
283
+ getCurrentThreadId(): string;
284
+ getCurrentWorkspacePath(): string;
285
+ getChatWorkspacePath(): string;
286
+ listSkills(): SkillCatalogEntry[];
287
+ loadSkill(name: string): Promise<LoadedSkill | null>;
288
+ writeSkill(input: {
289
+ name: string;
290
+ description?: string;
291
+ tags?: string[];
292
+ body: string;
293
+ directoryName?: string;
294
+ resourceFiles?: Array<{
295
+ path: string;
296
+ content: string;
297
+ }>;
298
+ }): Promise<WrittenSkillResult>;
299
+ listSessions(): RuntimeSessionRow[];
300
+ getSessionBySpaceId(spaceId: string): RuntimeSessionRow | null;
301
+ getSessionById(sessionId: string): RuntimeSessionRow | null;
302
+ listMissions(): RuntimeMissionRow[];
303
+ getMissionBySpaceId(spaceId: string): RuntimeMissionRow | null;
304
+ getMissionById(missionId: string): RuntimeMissionRow | null;
305
+ listMissionRuns(missionId: string, limit?: number): RuntimeMissionRunRow[];
306
+ listMissionHookBindings(filter?: {
307
+ missionId?: string;
308
+ hookKey?: string;
309
+ }): RuntimeMissionHookBindingRow[];
310
+ bindMissionHook(input: {
311
+ missionId: string;
312
+ hookKey: string;
313
+ condition?: MissionHookCondition;
314
+ }): Promise<RuntimeMissionHookBindingRow>;
315
+ unbindMissionHook(input: {
316
+ bindingId: string;
317
+ }): Promise<RuntimeMissionHookBindingRow | null>;
318
+ emitMissionHook(input: {
319
+ hookKey: string;
320
+ payload?: Record<string, unknown>;
321
+ source?: string;
322
+ }): Promise<MissionHookDispatchResult>;
323
+ querySessions(filter?: SessionQueryFilter): RuntimeSessionSnapshot[];
324
+ createSession(input: {
325
+ requestedName: string;
326
+ runtimeMode: RuntimeModeName;
327
+ initialInstruction?: string;
328
+ objective?: string;
329
+ owner?: SessionOwnerLink;
330
+ tags?: string[];
331
+ }): Promise<CreatedSessionResult>;
332
+ directSession(input: {
333
+ sessionId?: string;
334
+ spaceId?: string;
335
+ instruction: string;
336
+ reason?: string;
337
+ }): Promise<{
338
+ session: RuntimeSessionRow;
339
+ reply: RuntimeMessagePayload;
340
+ }>;
341
+ archiveSession(input: {
342
+ spaceId: string;
343
+ sessionId?: string;
344
+ }): Promise<RuntimeSessionRow | null>;
345
+ deleteArchivedSession(input: {
346
+ spaceId: string;
347
+ sessionId?: string;
348
+ }): Promise<RuntimeSessionRow | null>;
349
+ createMission(input: {
350
+ title: string;
351
+ goal: string;
352
+ schedule: string;
353
+ startTime?: string;
354
+ runtimeMode: RuntimeModeName;
355
+ }): Promise<{
356
+ mission: RuntimeMissionRow;
357
+ spaceId: string;
358
+ }>;
359
+ pauseMission(input: {
360
+ spaceId: string;
361
+ missionId?: string;
362
+ }): Promise<RuntimeMissionRow | null>;
363
+ resumeMission(input: {
364
+ spaceId: string;
365
+ missionId?: string;
366
+ }): Promise<RuntimeMissionRow | null>;
367
+ stopMission(input: {
368
+ spaceId: string;
369
+ missionId?: string;
370
+ }): Promise<RuntimeMissionRow | null>;
371
+ runMissionNow(input: {
372
+ spaceId: string;
373
+ missionId?: string;
374
+ requesterActorId?: string;
375
+ }): Promise<RuntimeMissionRow | null>;
376
+ sendMessage(spaceId: string, payload: RuntimeMessagePayload): Promise<void>;
377
+ sendStatusUpdate(payload: RuntimeMessagePayload): Promise<void>;
378
+ appendAuditEvent(event: string, payload: Record<string, unknown>): void;
379
+ nowIso(): string;
380
+ }
381
+ export interface RuntimePluginAdminCapability {
382
+ getAdminConfig(): RuntimePluginAdminConfig;
383
+ isAdminActor(input: RuntimeActorIdentity): boolean;
384
+ getNamespaceState(): RuntimePluginNamespaceState;
385
+ }
386
+ export interface RuntimePluginObservabilityCapability {
387
+ listPendingRequests(spaceId: string): PendingRuntimeRequestRecord[];
388
+ listRuntimeReceipts(): RuntimeReceiptRecord[];
389
+ listProviderConnections(): RuntimeProviderConnectionSnapshot[];
390
+ listRuntimeActivities(threadId?: string): RuntimeActivityRecord[];
391
+ getSessionSnapshotBySpaceId(spaceId: string): RuntimeSessionSnapshot | null;
392
+ getSessionSnapshotById(sessionId: string): RuntimeSessionSnapshot | null;
393
+ getRuntimeOverview(): RuntimeOverviewSnapshot;
394
+ listProjectionStates(): Array<{
395
+ projector: string;
396
+ lastEventId: string | null;
397
+ lastAppliedAt: string;
398
+ failure: string | null;
399
+ }>;
400
+ getProviderDiagnostics(): {
401
+ accountLabel: string | null;
402
+ availableModels: string[];
403
+ connectedSessions: number;
404
+ statusCounts: Record<string, number>;
405
+ capabilityMetadata: Record<string, unknown>;
406
+ };
407
+ getDefaultModel(): string;
408
+ setDefaultModel(model: string): Promise<void>;
409
+ getRuntimeStatus(): {
410
+ uptimeSeconds: number;
411
+ openSessions: number;
412
+ coolSessions: number;
413
+ archivedSessions: number;
414
+ waitingSessions: number;
415
+ runningSessions: number;
416
+ };
417
+ listRuntimeEvents(threadId: string): ProviderRuntimeEvent[];
418
+ listDomainEvents(threadId: string): RuntimeDomainEvent[];
419
+ updateSessionSummary(spaceId: string, summary: string, nowIso: string): Promise<void>;
420
+ }
421
+ export interface RuntimePluginMemoryCapability {
422
+ retrieveMemory(input: {
423
+ query: string;
424
+ scopeId: string;
425
+ spaceId?: string;
426
+ threadId?: string | null;
427
+ maxResults?: number;
428
+ enableRerank?: boolean;
429
+ }): Promise<RetrievedMemorySnippet[]>;
430
+ writeSessionMemory(input: {
431
+ scopeId: string;
432
+ spaceId: string;
433
+ threadId?: string | null;
434
+ kind: 'log' | 'summary' | 'facts' | 'tasks';
435
+ content: string;
436
+ sourceRefs: string[];
437
+ }): Promise<void>;
438
+ writeServerMemory(input: {
439
+ scopeId: string;
440
+ kind: 'facts' | 'tasks';
441
+ content: string;
442
+ sourceRefs: string[];
443
+ }): Promise<void>;
444
+ writeProjectMemory(input: {
445
+ projectKey?: string;
446
+ kind: 'facts' | 'tasks';
447
+ content: string;
448
+ sourceRefs: string[];
449
+ }): Promise<void>;
450
+ }
451
+ export interface RuntimePluginWorkManagementCapability {
452
+ archiveMission(input: {
453
+ spaceId: string;
454
+ missionId?: string;
455
+ }): Promise<RuntimeMissionRow | null>;
456
+ deleteArchivedMission(input: {
457
+ spaceId: string;
458
+ missionId?: string;
459
+ }): Promise<RuntimeMissionRow | null>;
460
+ archiveSpaceTarget(input: {
461
+ spaceId: string;
462
+ }): Promise<ArchivedSpaceTarget | null>;
463
+ deleteArchivedSpaceTarget(input: {
464
+ spaceId: string;
465
+ }): Promise<ArchivedSpaceTarget | null>;
466
+ respondToRuntimeRequest(input: {
467
+ threadId: string;
468
+ requestId: string;
469
+ decision: 'accept' | 'decline' | 'cancel';
470
+ requesterActor?: RuntimeActorIdentity;
471
+ }): Promise<void>;
472
+ respondToRuntimeUserInput(input: {
473
+ threadId: string;
474
+ requestId: string;
475
+ answers: Record<string, string | string[]>;
476
+ requesterActor?: RuntimeActorIdentity;
477
+ }): Promise<void>;
478
+ cancelRuntimeRequest(input: {
479
+ threadId: string;
480
+ requestId: string;
481
+ requestType: PendingRuntimeRequestRecord['requestType'];
482
+ requesterActor?: RuntimeActorIdentity;
483
+ }): Promise<void>;
484
+ interruptTurn(input: {
485
+ threadId: string;
486
+ }): Promise<void>;
487
+ }
488
+ export interface RuntimePluginRuntimeControlCapability {
489
+ getRuntimeControlStatus(): RuntimeControlStatus;
490
+ requestRuntimeReload(input: {
491
+ mode: RuntimeReloadMode;
492
+ reason: string;
493
+ requestedBy: RuntimeActorIdentity;
494
+ }): Promise<RuntimeControlResult>;
495
+ setRuntimeAcceptingNewWork(input: {
496
+ accepting: boolean;
497
+ reason: string;
498
+ requestedBy: RuntimeActorIdentity;
499
+ }): Promise<void>;
500
+ testProvider(input: {
501
+ sendTurn?: boolean;
502
+ prompt?: string;
503
+ reason: string;
504
+ requestedBy: RuntimeActorIdentity;
505
+ }): Promise<RuntimeProviderTestResult>;
506
+ stopProvider(input: {
507
+ threadId?: string;
508
+ reason: string;
509
+ requestedBy: RuntimeActorIdentity;
510
+ }): Promise<ProviderControlResult>;
511
+ startProvider(input: {
512
+ threadId?: string;
513
+ reason: string;
514
+ requestedBy: RuntimeActorIdentity;
515
+ }): Promise<ProviderControlResult>;
516
+ }
517
+ export interface RuntimePluginSidecarCapability {
518
+ ensureSidecar(input: Omit<ManagedSidecarDefinition, 'pluginId'>): Promise<ManagedSidecarRecord>;
519
+ stopSidecar(input: {
520
+ name: string;
521
+ scopeKind: SidecarScopeKind;
522
+ scopeKey: string;
523
+ }): Promise<ManagedSidecarRecord | null>;
524
+ listSidecars(filter?: {
525
+ pluginId?: string;
526
+ scopeKind?: SidecarScopeKind;
527
+ scopeKey?: string;
528
+ status?: ManagedSidecarRecord['status'];
529
+ }): ManagedSidecarRecord[];
530
+ }
531
+ export interface RuntimePluginAgentCapability {
532
+ runAgent(input: {
533
+ surface: AgentSurface;
534
+ spaceId: string;
535
+ actorId: string;
536
+ actorLabel: string;
537
+ text: string;
538
+ attachments?: RuntimeAttachmentPayload[];
539
+ session: RuntimeSessionRow | null;
540
+ cwd: string;
541
+ runtimeMode: RuntimeModeName;
542
+ basePromptSections: string[];
543
+ promptSource?: string;
544
+ }): Promise<RuntimeMessagePayload>;
545
+ drainRuntimeWork(): Promise<void>;
546
+ }
547
+ export type RuntimePluginContext = RuntimeToolContext & RuntimePluginAdminCapability & RuntimePluginObservabilityCapability & RuntimePluginMemoryCapability & RuntimePluginWorkManagementCapability & RuntimePluginRuntimeControlCapability & RuntimePluginSidecarCapability & RuntimePluginAgentCapability;
548
+ export interface RuntimeToolDefinition {
549
+ pluginId?: string;
550
+ name: string;
551
+ description?: string;
552
+ inputSchema?: Record<string, unknown>;
553
+ requiredCapability?: Capability;
554
+ execute(input: Record<string, unknown>, context: RuntimeToolContext): Promise<RuntimeToolResult> | RuntimeToolResult;
555
+ }
556
+ export interface RuntimePlugin {
557
+ readonly id: string;
558
+ readonly manifest: PluginManifest;
559
+ actions?(context: RuntimePluginContext): RuntimeActionDefinition[];
560
+ managementContributions?(context: RuntimePluginContext): RuntimeManagementContribution[];
561
+ tools?(context: RuntimeToolContext): RuntimeToolDefinition[];
562
+ onRuntimeStarted?(context: RuntimePluginContext): Promise<void> | void;
563
+ onTransportEvent?(event: RuntimeTransportEvent, context: RuntimePluginContext): Promise<RuntimeActionDispatchResult | boolean | void> | RuntimeActionDispatchResult | boolean | void;
564
+ onAction?(event: Extract<RuntimeTransportEvent, {
565
+ type: 'action.invoked';
566
+ }>, context: RuntimePluginContext): Promise<RuntimeActionDispatchResult | boolean | void> | RuntimeActionDispatchResult | boolean | void;
567
+ onRuntimeEvent?(event: ProviderRuntimeEvent, context: RuntimePluginContext): Promise<void> | void;
568
+ beforeAgentPrompt?(input: BeforeAgentPromptInput, context: RuntimePluginContext): Promise<string[]> | string[];
569
+ afterAgentResponse?(input: AfterAgentResponseInput, context: RuntimePluginContext): Promise<void> | void;
570
+ onDomainEvent?(event: RuntimeDomainEvent, context: RuntimePluginContext): Promise<void> | void;
571
+ onRuntimeReceipt?(receipt: RuntimeReceiptRecord, context: RuntimePluginContext): Promise<void> | void;
572
+ onRuntimeActivity?(activity: RuntimeActivityRecord, context: RuntimePluginContext): Promise<void> | void;
573
+ }
574
+ export type RuntimeActionPlugin = RuntimePlugin;
575
+ export type RuntimeToolPlugin = RuntimePlugin;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=plugin-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-runtime.js","sourceRoot":"","sources":["../src/plugin-runtime.ts"],"names":[],"mappings":""}
@@ -0,0 +1,30 @@
1
+ import type { JsonSchemaLike, PackageDependency, PackageManifestBase } from './package.js';
2
+ import { type Capability } from './capabilities.js';
3
+ import type { RuntimeActionDefinition } from './transport.js';
4
+ export interface PluginManifest extends PackageManifestBase {
5
+ type: 'plugin';
6
+ entrypoint?: string;
7
+ priority?: number;
8
+ capabilities: Capability[];
9
+ hooks?: string[];
10
+ defaultEnabled?: boolean;
11
+ dependencies?: PackageDependency[];
12
+ configSchema?: JsonSchemaLike;
13
+ displayCategory?: string;
14
+ }
15
+ export interface RuntimeManagementContribution {
16
+ id: string;
17
+ title: string;
18
+ surface: 'cli';
19
+ packageId: string;
20
+ placement: 'overview' | 'control' | 'work' | 'packages' | 'health' | 'settings';
21
+ kind: 'action' | 'form' | 'status_card' | 'table' | 'link';
22
+ requiredCapability?: Capability;
23
+ inputSchema?: Record<string, unknown>;
24
+ executeActionId?: string;
25
+ readModelSelector?: string;
26
+ }
27
+ export type { RuntimeActionDefinition };
28
+ export * from './plugin-runtime.js';
29
+ export declare const KNOWN_PLUGIN_HOOKS: readonly ["onRuntimeStarted", "onTransportEvent", "onAction", "onRuntimeEvent", "beforeAgentPrompt", "afterAgentResponse", "onDomainEvent", "onRuntimeReceipt", "onRuntimeActivity"];
30
+ export declare function validatePluginManifest(manifest: PluginManifest): PluginManifest;
package/dist/plugin.js ADDED
@@ -0,0 +1,77 @@
1
+ import { validateJsonSchemaLike, validatePackageActivationRule, validatePackageDependencies, validatePackageId } from './package.js';
2
+ import { isCapability, packageOwnsCapability } from './capabilities.js';
3
+ export * from './plugin-runtime.js';
4
+ export const KNOWN_PLUGIN_HOOKS = [
5
+ 'onRuntimeStarted',
6
+ 'onTransportEvent',
7
+ 'onAction',
8
+ 'onRuntimeEvent',
9
+ 'beforeAgentPrompt',
10
+ 'afterAgentResponse',
11
+ 'onDomainEvent',
12
+ 'onRuntimeReceipt',
13
+ 'onRuntimeActivity'
14
+ ];
15
+ const KNOWN_PLUGIN_HOOK_SET = new Set(KNOWN_PLUGIN_HOOKS);
16
+ export function validatePluginManifest(manifest) {
17
+ if (!manifest || typeof manifest !== 'object' || Array.isArray(manifest)) {
18
+ throw new Error('Plugin manifest must be an object');
19
+ }
20
+ const record = manifest;
21
+ validatePackageId(record.id, 'Plugin manifest id');
22
+ if (typeof record.name !== 'string' || !record.name.trim()) {
23
+ throw new Error('Plugin manifest name is required');
24
+ }
25
+ if (typeof record.version !== 'string' || !record.version.trim()) {
26
+ throw new Error('Plugin manifest version is required');
27
+ }
28
+ if (record.type !== 'plugin') {
29
+ throw new Error('Plugin manifest type must be "plugin"');
30
+ }
31
+ if (record.description !== undefined && (typeof record.description !== 'string' || !record.description.trim())) {
32
+ throw new Error('Plugin manifest description must be non-empty when provided');
33
+ }
34
+ if (record.entrypoint !== undefined && (typeof record.entrypoint !== 'string' || !record.entrypoint.trim())) {
35
+ throw new Error('Plugin manifest entrypoint must be non-empty when provided');
36
+ }
37
+ if (record.priority !== undefined && (!Number.isInteger(record.priority) || record.priority < 0)) {
38
+ throw new Error('Plugin manifest priority must be a non-negative integer when provided');
39
+ }
40
+ if (record.defaultEnabled !== undefined && typeof record.defaultEnabled !== 'boolean') {
41
+ throw new Error('Plugin manifest defaultEnabled must be a boolean when provided');
42
+ }
43
+ if (record.displayCategory !== undefined &&
44
+ (typeof record.displayCategory !== 'string' || !record.displayCategory.trim())) {
45
+ throw new Error('Plugin manifest displayCategory must be a non-empty string when provided');
46
+ }
47
+ if (!Array.isArray(record.capabilities) || record.capabilities.length === 0) {
48
+ throw new Error('Plugin manifest capabilities must declare at least one capability');
49
+ }
50
+ validatePackageDependencies(record.dependencies, 'plugin manifest');
51
+ validateJsonSchemaLike(record.configSchema, 'plugin manifest');
52
+ const activation = validatePackageActivationRule(record.activation, 'plugin manifest');
53
+ for (const capability of record.capabilities) {
54
+ if (!isCapability(capability)) {
55
+ throw new Error(`Unknown capability: ${capability}`);
56
+ }
57
+ if (!packageOwnsCapability(record.id, capability)) {
58
+ throw new Error(`Package-local capability ${capability} is not owned by plugin ${record.id}`);
59
+ }
60
+ }
61
+ if (record.hooks !== undefined && !Array.isArray(record.hooks)) {
62
+ throw new Error('Plugin manifest hooks must be an array when provided');
63
+ }
64
+ for (const hook of record.hooks ?? []) {
65
+ if (typeof hook !== 'string' || !hook.trim()) {
66
+ throw new Error('Plugin manifest hooks must be non-empty');
67
+ }
68
+ if (!KNOWN_PLUGIN_HOOK_SET.has(hook)) {
69
+ throw new Error(`Unknown plugin hook: ${hook}`);
70
+ }
71
+ }
72
+ return {
73
+ ...manifest,
74
+ ...(activation !== undefined ? { activation } : {})
75
+ };
76
+ }
77
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,2BAA2B,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACrI,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAmB,MAAM,mBAAmB,CAAC;AA8BzF,cAAc,qBAAqB,CAAC;AAEpC,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,kBAAkB;IAClB,kBAAkB;IAClB,UAAU;IACV,gBAAgB;IAChB,mBAAmB;IACnB,oBAAoB;IACpB,eAAe;IACf,kBAAkB;IAClB,mBAAmB;CACX,CAAC;AAEX,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAS,kBAAkB,CAAC,CAAC;AAClE,MAAM,UAAU,sBAAsB,CAAC,QAAwB;IAC7D,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QACzE,MAAM,IAAI,KAAK,CAAC,mCAAmC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