@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,89 @@
1
+ import type { JsonSchemaLike, PackageDependency, PackageManifestBase } from './package.js';
2
+ import type { EventEmitter } from 'node:events';
3
+ import type { ProviderPackageId, ProviderInputImage, ProviderRuntimeEvent, ProviderSessionRecord, RuntimeCommandRunner, RuntimeModeName } from './runtime.js';
4
+ export interface ProviderPackageManifest extends PackageManifestBase {
5
+ type: 'provider';
6
+ entrypoint?: string;
7
+ dependencies?: PackageDependency[];
8
+ configSchema?: JsonSchemaLike;
9
+ displayCategory?: string;
10
+ }
11
+ export interface RuntimeProviderPackageContext {
12
+ config: Record<string, unknown>;
13
+ commandRunner?: RuntimeCommandRunner;
14
+ }
15
+ export interface RuntimeProviderDiagnostics {
16
+ accountLabel: string | null;
17
+ availableModels: string[];
18
+ connectedSessions: number;
19
+ statusCounts: Record<string, number>;
20
+ capabilityMetadata: Record<string, unknown>;
21
+ }
22
+ export interface RuntimeProviderTestResult {
23
+ ok: boolean;
24
+ message: string;
25
+ remediation?: string;
26
+ accountLabel: string | null;
27
+ availableModels: string[];
28
+ sentTurn: boolean;
29
+ error?: string;
30
+ }
31
+ export interface RuntimeProviderSessionInput {
32
+ sessionId: string;
33
+ threadId: string;
34
+ spaceId: string;
35
+ runtimeMode: RuntimeModeName;
36
+ workspacePath: string;
37
+ resumeThreadId: string | null;
38
+ lifecycleStatus: string;
39
+ providerAutoStartEnabled?: boolean;
40
+ }
41
+ export interface RuntimeProvider extends EventEmitter<{
42
+ providerEvent: [event: ProviderRuntimeEvent];
43
+ }> {
44
+ listSessions(): ProviderSessionRecord[];
45
+ getDiagnostics(): RuntimeProviderDiagnostics;
46
+ startOrResumeSession(input: {
47
+ session: RuntimeProviderSessionInput;
48
+ runtimeRoot: string;
49
+ actor: string;
50
+ model?: string;
51
+ }): Promise<ProviderSessionRecord>;
52
+ recoverSessions(input: {
53
+ sessions: RuntimeProviderSessionInput[];
54
+ runtimeRoot: string;
55
+ model?: string;
56
+ }): Promise<void>;
57
+ testConnection?(input: {
58
+ runtimeRoot: string;
59
+ actor: string;
60
+ model?: string;
61
+ sendTurn?: boolean;
62
+ prompt?: string;
63
+ }): Promise<RuntimeProviderTestResult>;
64
+ sendTurn(threadId: string, input: {
65
+ text: string;
66
+ images?: ProviderInputImage[];
67
+ }, model?: string): Promise<{
68
+ turnId: string;
69
+ }>;
70
+ compactThread(threadId: string): Promise<void>;
71
+ respondToRequest(threadId: string, requestId: string, decision: 'accept' | 'acceptForSession' | 'decline' | 'cancel'): Promise<void>;
72
+ respondToUserInput(threadId: string, requestId: string, answers: Record<string, string | string[]>): Promise<void>;
73
+ interruptTurn(threadId: string): Promise<void>;
74
+ drain(): Promise<void>;
75
+ stopSession(threadId: string): void;
76
+ stopAll(): void;
77
+ }
78
+ export interface RuntimeProviderFactoryContext {
79
+ providerPackageId: ProviderPackageId;
80
+ }
81
+ export type RuntimeProviderFactory = (input: RuntimeProviderFactoryContext) => RuntimeProvider;
82
+ export type RuntimeEnvironmentVerifier = () => Promise<void>;
83
+ export interface RuntimeProviderPackage {
84
+ manifest: ProviderPackageManifest;
85
+ createProviderFactory(input: RuntimeProviderPackageContext): RuntimeProviderFactory;
86
+ createEnvironmentVerifier?(input: RuntimeProviderPackageContext): RuntimeEnvironmentVerifier | null;
87
+ }
88
+ export declare function validateProviderPackageManifest(manifest: ProviderPackageManifest): ProviderPackageManifest;
89
+ export declare function validateProviderPackageRuntimeContract(pkg: RuntimeProviderPackage): void;
@@ -0,0 +1,43 @@
1
+ import { validateJsonSchemaLike, validatePackageActivationRule, validatePackageDependencies, validatePackageId } from './package.js';
2
+ export function validateProviderPackageManifest(manifest) {
3
+ if (!manifest || typeof manifest !== 'object' || Array.isArray(manifest)) {
4
+ throw new Error('Provider package manifest must be an object');
5
+ }
6
+ const record = manifest;
7
+ validatePackageId(record.id, 'Provider package manifest id');
8
+ if (typeof record.name !== 'string' || !record.name.trim()) {
9
+ throw new Error('Provider package manifest name is required');
10
+ }
11
+ if (typeof record.version !== 'string' || !record.version.trim()) {
12
+ throw new Error('Provider package manifest version is required');
13
+ }
14
+ if (record.type !== 'provider') {
15
+ throw new Error('Provider package manifest type must be "provider"');
16
+ }
17
+ if (record.description !== undefined && (typeof record.description !== 'string' || !record.description.trim())) {
18
+ throw new Error('Provider package manifest description must be non-empty when provided');
19
+ }
20
+ if (record.entrypoint !== undefined && (typeof record.entrypoint !== 'string' || !record.entrypoint.trim())) {
21
+ throw new Error('Provider package manifest entrypoint must be non-empty when provided');
22
+ }
23
+ if (record.displayCategory !== undefined &&
24
+ (typeof record.displayCategory !== 'string' || !record.displayCategory.trim())) {
25
+ throw new Error('Provider package manifest displayCategory must be non-empty when provided');
26
+ }
27
+ validatePackageDependencies(record.dependencies, 'provider package manifest');
28
+ validateJsonSchemaLike(record.configSchema, 'provider package manifest');
29
+ const activation = validatePackageActivationRule(record.activation, 'provider package manifest');
30
+ return {
31
+ ...manifest,
32
+ ...(activation !== undefined ? { activation } : {})
33
+ };
34
+ }
35
+ export function validateProviderPackageRuntimeContract(pkg) {
36
+ if (typeof pkg.createProviderFactory !== 'function') {
37
+ throw new Error(`Provider package ${pkg.manifest.id} must implement createProviderFactory`);
38
+ }
39
+ if (pkg.createEnvironmentVerifier !== undefined && typeof pkg.createEnvironmentVerifier !== 'function') {
40
+ throw new Error(`Provider package ${pkg.manifest.id} exported invalid createEnvironmentVerifier`);
41
+ }
42
+ }
43
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,2BAA2B,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAuGrI,MAAM,UAAU,+BAA+B,CAAC,QAAiC;IAC/E,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QACzE,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IACjE,CAAC;IACD,MAAM,MAAM,GAAG,QAA8C,CAAC;IAC9D,iBAAiB,CAAC,MAAM,CAAC,EAAE,EAAE,8BAA8B,CAAC,CAAC;IAC7D,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;QAC3D,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC;IACD,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;QACjE,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;IACnE,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;IACD,IAAI,MAAM,CAAC,WAAW,KAAK,SAAS,IAAI,CAAC,OAAO,MAAM,CAAC,WAAW,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;QAC/G,MAAM,IAAI,KAAK,CAAC,uEAAuE,CAAC,CAAC;IAC3F,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS,IAAI,CAAC,OAAO,MAAM,CAAC,UAAU,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;QAC5G,MAAM,IAAI,KAAK,CAAC,sEAAsE,CAAC,CAAC;IAC1F,CAAC;IACD,IACE,MAAM,CAAC,eAAe,KAAK,SAAS;QACpC,CAAC,OAAO,MAAM,CAAC,eAAe,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,EAC9E,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,2EAA2E,CAAC,CAAC;IAC/F,CAAC;IACD,2BAA2B,CAAC,MAAM,CAAC,YAAY,EAAE,2BAA2B,CAAC,CAAC;IAC9E,sBAAsB,CAAC,MAAM,CAAC,YAAY,EAAE,2BAA2B,CAAC,CAAC;IACzE,MAAM,UAAU,GAAG,6BAA6B,CAAC,MAAM,CAAC,UAAU,EAAE,2BAA2B,CAAC,CAAC;IACjG,OAAO;QACL,GAAG,QAAQ;QACX,GAAG,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACpD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,sCAAsC,CAAC,GAA2B;IAChF,IAAI,OAAO,GAAG,CAAC,qBAAqB,KAAK,UAAU,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CAAC,oBAAoB,GAAG,CAAC,QAAQ,CAAC,EAAE,uCAAuC,CAAC,CAAC;IAC9F,CAAC;IACD,IAAI,GAAG,CAAC,yBAAyB,KAAK,SAAS,IAAI,OAAO,GAAG,CAAC,yBAAyB,KAAK,UAAU,EAAE,CAAC;QACvG,MAAM,IAAI,KAAK,CAAC,oBAAoB,GAAG,CAAC,QAAQ,CAAC,EAAE,6CAA6C,CAAC,CAAC;IACpG,CAAC;AACH,CAAC"}
@@ -0,0 +1,176 @@
1
+ export interface CommandResult {
2
+ exitCode: number;
3
+ stdout: string;
4
+ stderr: string;
5
+ }
6
+ export interface RuntimeCommandRunner {
7
+ run(command: string, args: string[], cwd?: string): Promise<CommandResult>;
8
+ }
9
+ export type RuntimeModeName = 'full-access' | 'approval-required';
10
+ export declare function parseRuntimeModeName(value: unknown, label?: string): RuntimeModeName;
11
+ export type ProviderPackageId = string;
12
+ export type ProviderSessionStatus = 'connecting' | 'ready' | 'running' | 'waiting' | 'error' | 'closed';
13
+ export interface ProviderAccountMetadata {
14
+ accountLabel: string | null;
15
+ availableModels: string[];
16
+ }
17
+ export type ProviderInputImage = {
18
+ url: string;
19
+ } | {
20
+ localPath: string;
21
+ };
22
+ export type ProviderMessagePhase = 'commentary' | 'final_answer';
23
+ export interface ProviderThreadTokenUsage {
24
+ totalTokens: number;
25
+ lastTurnTokens: number | null;
26
+ modelContextWindow: number | null;
27
+ }
28
+ export type CanonicalItemType = 'assistant_message' | 'reasoning' | 'plan' | 'command_execution' | 'file_change' | 'web_search' | 'image_view' | 'dynamic_tool_call' | 'error' | 'unknown';
29
+ export type CanonicalRequestType = 'command_execution_approval' | 'file_read_approval' | 'file_change_approval' | 'apply_patch_approval' | 'exec_command_approval' | 'tool_user_input' | 'dynamic_tool_call' | 'auth_tokens_refresh' | 'unknown';
30
+ export type ProviderApprovalDecision = 'accept' | 'acceptForSession' | 'decline' | 'cancel';
31
+ export interface ProviderSessionRecord {
32
+ providerPackageId: ProviderPackageId;
33
+ provider?: ProviderPackageId;
34
+ providerSessionKind?: string;
35
+ capabilities?: Record<string, unknown>;
36
+ nativeMetadata?: Record<string, unknown>;
37
+ threadId: string;
38
+ runtimeMode: RuntimeModeName;
39
+ cwd: string;
40
+ model?: string;
41
+ status: ProviderSessionStatus;
42
+ activeTurnId?: string;
43
+ resumeCursor?: {
44
+ threadId: string;
45
+ };
46
+ createdAt: string;
47
+ updatedAt: string;
48
+ lastError?: string;
49
+ }
50
+ export interface ProviderRuntimeEventBase {
51
+ eventId: string;
52
+ providerPackageId: ProviderPackageId;
53
+ provider?: ProviderPackageId;
54
+ providerSessionKind?: string;
55
+ capabilities?: Record<string, unknown>;
56
+ nativeMetadata?: Record<string, unknown>;
57
+ threadId: string;
58
+ createdAt: string;
59
+ turnId?: string;
60
+ itemId?: string;
61
+ requestId?: string;
62
+ }
63
+ export type ProviderRuntimeEvent = (ProviderRuntimeEventBase & {
64
+ type: 'provider.metadata.updated';
65
+ payload: ProviderAccountMetadata;
66
+ }) | (ProviderRuntimeEventBase & {
67
+ type: 'session.state.changed';
68
+ payload: {
69
+ state: ProviderSessionStatus;
70
+ reason?: string;
71
+ };
72
+ }) | (ProviderRuntimeEventBase & {
73
+ type: 'thread.started';
74
+ payload: {
75
+ providerThreadId: string;
76
+ };
77
+ }) | (ProviderRuntimeEventBase & {
78
+ type: 'thread.state.changed';
79
+ payload: {
80
+ state: 'open' | 'archived' | 'closed' | 'compacted';
81
+ detail?: unknown;
82
+ };
83
+ }) | (ProviderRuntimeEventBase & {
84
+ type: 'thread.token-usage.updated';
85
+ payload: ProviderThreadTokenUsage;
86
+ }) | (ProviderRuntimeEventBase & {
87
+ type: 'turn.started';
88
+ payload: {
89
+ model?: string;
90
+ effort?: string;
91
+ };
92
+ }) | (ProviderRuntimeEventBase & {
93
+ type: 'turn.completed';
94
+ payload: {
95
+ state: 'completed' | 'failed' | 'cancelled' | 'interrupted';
96
+ stopReason?: string;
97
+ errorMessage?: string;
98
+ };
99
+ }) | (ProviderRuntimeEventBase & {
100
+ type: 'turn.aborted';
101
+ payload: {
102
+ reason: string;
103
+ };
104
+ }) | (ProviderRuntimeEventBase & {
105
+ type: 'content.delta';
106
+ payload: {
107
+ streamKind: 'assistant_text';
108
+ delta: string;
109
+ };
110
+ }) | (ProviderRuntimeEventBase & {
111
+ type: 'item.started' | 'item.completed';
112
+ payload: {
113
+ itemType: CanonicalItemType;
114
+ title?: string;
115
+ detail?: string;
116
+ status?: string;
117
+ localPath?: string;
118
+ phase?: ProviderMessagePhase;
119
+ };
120
+ }) | (ProviderRuntimeEventBase & {
121
+ type: 'request.opened';
122
+ payload: {
123
+ requestType: CanonicalRequestType;
124
+ detail?: string;
125
+ args?: unknown;
126
+ parameterKeys?: string[];
127
+ parameterSummary?: Record<string, unknown>;
128
+ };
129
+ }) | (ProviderRuntimeEventBase & {
130
+ type: 'request.resolved';
131
+ payload: {
132
+ requestType: CanonicalRequestType;
133
+ decision?: ProviderApprovalDecision;
134
+ resolution?: unknown;
135
+ };
136
+ }) | (ProviderRuntimeEventBase & {
137
+ type: 'user-input.requested';
138
+ payload: {
139
+ questions: Array<{
140
+ id: string;
141
+ header: string;
142
+ question: string;
143
+ options: Array<{
144
+ label: string;
145
+ description: string;
146
+ }>;
147
+ }>;
148
+ };
149
+ }) | (ProviderRuntimeEventBase & {
150
+ type: 'user-input.resolved';
151
+ payload: {
152
+ answers: Record<string, string | string[]>;
153
+ };
154
+ }) | (ProviderRuntimeEventBase & {
155
+ type: 'runtime.warning' | 'runtime.error';
156
+ payload: {
157
+ message: string;
158
+ class?: string;
159
+ detail?: unknown;
160
+ };
161
+ });
162
+ export interface PendingRuntimeRequestRecord {
163
+ requestId: string;
164
+ threadId: string;
165
+ turnId: string | null;
166
+ spaceId: string;
167
+ requesterUserId: string | null;
168
+ messageId: string | null;
169
+ requestType: CanonicalRequestType;
170
+ status: 'open' | 'resolved';
171
+ detail: string | null;
172
+ questionsJson: string | null;
173
+ decision: ProviderApprovalDecision | null;
174
+ createdAt: string;
175
+ resolvedAt: string | null;
176
+ }
@@ -0,0 +1,11 @@
1
+ const RUNTIME_MODE_NAMES = ['full-access', 'approval-required'];
2
+ function isRuntimeModeName(value) {
3
+ return value === 'full-access' || value === 'approval-required';
4
+ }
5
+ export function parseRuntimeModeName(value, label = 'runtime_mode') {
6
+ if (isRuntimeModeName(value)) {
7
+ return value;
8
+ }
9
+ throw new Error(`${label} must be one of: ${RUNTIME_MODE_NAMES.join(', ')}.`);
10
+ }
11
+ //# sourceMappingURL=runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAYA,MAAM,kBAAkB,GAAsB,CAAC,aAAa,EAAE,mBAAmB,CAAC,CAAC;AAEnF,SAAS,iBAAiB,CAAC,KAAc;IACvC,OAAO,KAAK,KAAK,aAAa,IAAI,KAAK,KAAK,mBAAmB,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,KAAc,EAAE,KAAK,GAAG,cAAc;IACzE,IAAI,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,oBAAoB,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAChF,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { JsonSchemaLike, PackageDependency, PackageManifestBase } from './package.js';
2
+ export interface SkillPackageManifest extends PackageManifestBase {
3
+ type: 'skill';
4
+ skillsRoot?: string;
5
+ dependencies?: PackageDependency[];
6
+ configSchema?: JsonSchemaLike;
7
+ }
8
+ export declare function validateSkillPackageManifest(manifest: SkillPackageManifest): SkillPackageManifest;
package/dist/skill.js ADDED
@@ -0,0 +1,31 @@
1
+ import { validateJsonSchemaLike, validatePackageActivationRule, validatePackageDependencies, validatePackageId } from './package.js';
2
+ export function validateSkillPackageManifest(manifest) {
3
+ if (!manifest || typeof manifest !== 'object' || Array.isArray(manifest)) {
4
+ throw new Error('Skill package manifest must be an object');
5
+ }
6
+ const record = manifest;
7
+ validatePackageId(record.id, 'Skill package manifest id');
8
+ if (typeof record.name !== 'string' || !record.name.trim()) {
9
+ throw new Error('Skill package manifest name is required');
10
+ }
11
+ if (typeof record.version !== 'string' || !record.version.trim()) {
12
+ throw new Error('Skill package manifest version is required');
13
+ }
14
+ if (record.type !== 'skill') {
15
+ throw new Error('Skill package manifest type must be "skill"');
16
+ }
17
+ if (record.description !== undefined && (typeof record.description !== 'string' || !record.description.trim())) {
18
+ throw new Error('Skill package manifest description must be non-empty when provided');
19
+ }
20
+ if (record.skillsRoot !== undefined && (typeof record.skillsRoot !== 'string' || !record.skillsRoot.trim())) {
21
+ throw new Error('Skill package manifest skillsRoot must be non-empty when provided');
22
+ }
23
+ validatePackageDependencies(record.dependencies, 'skill manifest');
24
+ validateJsonSchemaLike(record.configSchema, 'skill manifest');
25
+ const activation = validatePackageActivationRule(record.activation, 'skill manifest');
26
+ return {
27
+ ...manifest,
28
+ ...(activation !== undefined ? { activation } : {})
29
+ };
30
+ }
31
+ //# sourceMappingURL=skill.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill.js","sourceRoot":"","sources":["../src/skill.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,2BAA2B,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AASrI,MAAM,UAAU,4BAA4B,CAAC,QAA8B;IACzE,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QACzE,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IACD,MAAM,MAAM,GAAG,QAA8C,CAAC;IAC9D,iBAAiB,CAAC,MAAM,CAAC,EAAE,EAAE,2BAA2B,CAAC,CAAC;IAC1D,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;QAC3D,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC7D,CAAC;IACD,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;QACjE,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IACjE,CAAC;IACD,IAAI,MAAM,CAAC,WAAW,KAAK,SAAS,IAAI,CAAC,OAAO,MAAM,CAAC,WAAW,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;QAC/G,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;IACxF,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS,IAAI,CAAC,OAAO,MAAM,CAAC,UAAU,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;QAC5G,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAC;IACvF,CAAC;IACD,2BAA2B,CAAC,MAAM,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;IACnE,sBAAsB,CAAC,MAAM,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;IAC9D,MAAM,UAAU,GAAG,6BAA6B,CAAC,MAAM,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;IACtF,OAAO;QACL,GAAG,QAAQ;QACX,GAAG,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACpD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,269 @@
1
+ import type { JsonSchemaLike, PackageDependency, PackageManifestBase } from './package.js';
2
+ import type { RuntimeCommandRunner } from './runtime.js';
3
+ export type RuntimeScopeId = string;
4
+ export type RuntimeSpaceId = string;
5
+ export type RuntimeThreadId = string;
6
+ export interface RuntimeSurfaceNames {
7
+ mainCategoryName: string;
8
+ chatChannelName: string;
9
+ statusChannelName: string;
10
+ sessionsCategoryName: string;
11
+ missionsCategoryName: string;
12
+ archiveCategoryName: string;
13
+ }
14
+ export interface ManagedAdminAccessGroupConfig {
15
+ enabled: boolean;
16
+ name: string;
17
+ }
18
+ export interface ManagedMemberAccessGroupConfig {
19
+ enabled: boolean;
20
+ name: string;
21
+ }
22
+ export type RuntimeAccessGroupKind = 'admin' | 'member';
23
+ export interface RuntimeAccessGroupRecord {
24
+ id: string;
25
+ kind: RuntimeAccessGroupKind;
26
+ name: string;
27
+ verifiedAt?: string;
28
+ metadata?: Record<string, unknown>;
29
+ }
30
+ export interface RuntimeAccessGroupInput {
31
+ scopeId: RuntimeScopeId;
32
+ kind: RuntimeAccessGroupKind;
33
+ name: string;
34
+ previousId?: string;
35
+ metadata?: Record<string, unknown>;
36
+ }
37
+ export interface RuntimeSurfaceState {
38
+ scopeId?: string;
39
+ mainCategoryId: string;
40
+ chatChannelId: string;
41
+ statusChannelId: string;
42
+ sessionsCategoryId: string;
43
+ missionsCategoryId: string;
44
+ archiveCategoryId: string;
45
+ adminAccessGroupId?: string;
46
+ memberAccessGroupId?: string;
47
+ adminAccessGroupName?: string;
48
+ memberAccessGroupName?: string;
49
+ adminAccessGroupVerifiedAt?: string;
50
+ memberAccessGroupVerifiedAt?: string;
51
+ createdAt: string;
52
+ updatedAt: string;
53
+ metadata?: Record<string, unknown>;
54
+ }
55
+ export interface RuntimeSurfaceBootstrapInput {
56
+ scopeId?: RuntimeScopeId;
57
+ actorId?: string;
58
+ names?: Partial<RuntimeSurfaceNames>;
59
+ managedAdminAccessGroup?: ManagedAdminAccessGroupConfig;
60
+ managedMemberAccessGroup?: ManagedMemberAccessGroupConfig;
61
+ explicitAdminRoleIds?: string[];
62
+ explicitAdminUserIds?: string[];
63
+ previousState: RuntimeSurfaceState | null;
64
+ nowIso: string;
65
+ config?: Record<string, unknown>;
66
+ }
67
+ export interface RuntimeActorIdentity {
68
+ actorId: string;
69
+ displayName?: string;
70
+ accessGroupIds?: string[];
71
+ isSurfaceAdmin?: boolean;
72
+ transportMetadata?: Record<string, unknown>;
73
+ }
74
+ export interface RuntimeSpaceRecord {
75
+ id: RuntimeSpaceId;
76
+ name: string;
77
+ kind: 'root' | 'group' | 'room' | 'thread' | 'dm' | 'external';
78
+ parentId: RuntimeSpaceId | null;
79
+ metadata?: Record<string, unknown>;
80
+ }
81
+ export interface RuntimeAttachmentPayload {
82
+ kind: 'file' | 'image' | 'link';
83
+ path?: string;
84
+ url?: string;
85
+ name?: string;
86
+ description?: string;
87
+ contentType?: string;
88
+ metadata?: Record<string, unknown>;
89
+ }
90
+ export interface RuntimeMessageBlock {
91
+ kind: 'text' | 'section' | 'fields' | 'notice';
92
+ text?: string;
93
+ title?: string;
94
+ fields?: Array<{
95
+ label: string;
96
+ value: string;
97
+ inline?: boolean;
98
+ }>;
99
+ tone?: 'default' | 'info' | 'success' | 'warning' | 'danger';
100
+ metadata?: Record<string, unknown>;
101
+ }
102
+ export interface RuntimeActionReference {
103
+ actionId: string;
104
+ label: string;
105
+ style?: 'primary' | 'secondary' | 'success' | 'danger';
106
+ input?: Record<string, unknown>;
107
+ disabled?: boolean;
108
+ }
109
+ export interface RuntimeMessagePayload {
110
+ text?: string;
111
+ blocks?: RuntimeMessageBlock[];
112
+ attachments?: RuntimeAttachmentPayload[];
113
+ actions?: RuntimeActionReference[];
114
+ metadata?: Record<string, unknown>;
115
+ }
116
+ export interface RuntimeMessageReceipt {
117
+ id: string;
118
+ nativeId?: string;
119
+ metadata?: Record<string, unknown>;
120
+ }
121
+ export interface RuntimeInboundMessage {
122
+ id?: string;
123
+ text: string;
124
+ attachments?: RuntimeAttachmentPayload[];
125
+ metadata?: Record<string, unknown>;
126
+ }
127
+ export interface RuntimeNativeInteraction {
128
+ kind: string;
129
+ id?: string;
130
+ payload?: unknown;
131
+ }
132
+ export type RuntimeTransportEvent = {
133
+ type: 'message.received';
134
+ scopeId: RuntimeScopeId;
135
+ spaceId: RuntimeSpaceId;
136
+ actor: RuntimeActorIdentity;
137
+ message: RuntimeInboundMessage;
138
+ } | {
139
+ type: 'action.invoked';
140
+ scopeId: RuntimeScopeId;
141
+ spaceId?: RuntimeSpaceId;
142
+ actor: RuntimeActorIdentity;
143
+ actionId: string;
144
+ input: Record<string, unknown>;
145
+ native?: RuntimeNativeInteraction;
146
+ } | {
147
+ type: 'resource.lifecycle';
148
+ scopeId: RuntimeScopeId;
149
+ resource: RuntimeSpaceRecord;
150
+ action: 'created' | 'updated' | 'deleted';
151
+ previous?: Partial<RuntimeSpaceRecord>;
152
+ };
153
+ export interface RuntimeTransportAccessInput {
154
+ authToken?: string;
155
+ scopeId: RuntimeScopeId;
156
+ applicationId?: string;
157
+ metadata?: Record<string, unknown>;
158
+ }
159
+ export interface RuntimeTransportVerification {
160
+ scopeId: RuntimeScopeId;
161
+ scopeName: string;
162
+ actorId: string;
163
+ actorName: string;
164
+ applicationId?: string;
165
+ metadata?: Record<string, unknown>;
166
+ }
167
+ export interface RuntimeTransportAuth {
168
+ token?: string;
169
+ metadata?: Record<string, unknown>;
170
+ }
171
+ export interface RuntimeMessageTarget {
172
+ scopeId?: RuntimeScopeId;
173
+ spaceId: RuntimeSpaceId;
174
+ threadId?: RuntimeThreadId;
175
+ }
176
+ export interface RuntimeTransportCapabilities {
177
+ nativeActions: boolean;
178
+ spaces: {
179
+ list: boolean;
180
+ create: boolean;
181
+ update: boolean;
182
+ delete: boolean;
183
+ };
184
+ presence: boolean;
185
+ maxMessageTextLength?: number;
186
+ maxAttachmentBytes?: number;
187
+ metadata?: Record<string, unknown>;
188
+ }
189
+ export interface RuntimeCreateSpaceInput {
190
+ scopeId: RuntimeScopeId;
191
+ name: string;
192
+ kind: RuntimeSpaceRecord['kind'];
193
+ parentId?: RuntimeSpaceId | null;
194
+ metadata?: Record<string, unknown>;
195
+ }
196
+ export interface RuntimeUpdateSpaceInput {
197
+ scopeId: RuntimeScopeId;
198
+ spaceId: RuntimeSpaceId;
199
+ name?: string;
200
+ parentId?: RuntimeSpaceId | null;
201
+ metadata?: Record<string, unknown>;
202
+ }
203
+ export interface RuntimeDeleteSpaceInput {
204
+ scopeId: RuntimeScopeId;
205
+ spaceId: RuntimeSpaceId;
206
+ }
207
+ export interface RuntimePresenceInput {
208
+ scopeId?: RuntimeScopeId;
209
+ spaceId?: RuntimeSpaceId;
210
+ status: 'online' | 'idle' | 'busy' | 'offline';
211
+ text?: string;
212
+ }
213
+ export interface RuntimeNativeActionRegistration {
214
+ scopeId: RuntimeScopeId;
215
+ actions: RuntimeActionDefinition[];
216
+ }
217
+ export interface RuntimeActionDefinition {
218
+ id: string;
219
+ title: string;
220
+ description?: string;
221
+ inputSchema?: Record<string, unknown>;
222
+ requiredCapability?: string;
223
+ policy?: {
224
+ allowedWhileDraining?: boolean;
225
+ bypassQueue?: boolean;
226
+ };
227
+ metadata?: Record<string, unknown>;
228
+ }
229
+ export interface RuntimeTransport {
230
+ verifyAccess(input: RuntimeTransportAccessInput): Promise<RuntimeTransportVerification>;
231
+ start(auth: RuntimeTransportAuth): Promise<void>;
232
+ stop(): Promise<void>;
233
+ capabilities(): RuntimeTransportCapabilities;
234
+ onEvent(handler: (event: RuntimeTransportEvent) => Promise<void>): void;
235
+ sendMessage(target: RuntimeMessageTarget, payload: RuntimeMessagePayload): Promise<RuntimeMessageReceipt>;
236
+ listSpaces?(scopeId: RuntimeScopeId): Promise<RuntimeSpaceRecord[]>;
237
+ createSpace?(input: RuntimeCreateSpaceInput): Promise<RuntimeSpaceRecord>;
238
+ updateSpace?(input: RuntimeUpdateSpaceInput): Promise<RuntimeSpaceRecord>;
239
+ deleteSpace?(input: RuntimeDeleteSpaceInput): Promise<void>;
240
+ setPresence?(input: RuntimePresenceInput): Promise<void>;
241
+ registerNativeActions?(input: RuntimeNativeActionRegistration): Promise<void>;
242
+ ensureAccessGroup?(input: RuntimeAccessGroupInput): Promise<RuntimeAccessGroupRecord>;
243
+ reconcileRuntimeSurface?(input: RuntimeSurfaceBootstrapInput): Promise<RuntimeSurfaceState>;
244
+ }
245
+ export interface TransportPackageManifest extends PackageManifestBase {
246
+ type: 'transport';
247
+ entrypoint?: string;
248
+ dependencies?: PackageDependency[];
249
+ configSchema?: JsonSchemaLike;
250
+ displayCategory?: string;
251
+ }
252
+ export interface RuntimeTransportPackageContext {
253
+ config: Record<string, unknown>;
254
+ commandRunner?: RuntimeCommandRunner;
255
+ }
256
+ export interface RuntimeTransportConfigCompletionInput {
257
+ config: Record<string, unknown>;
258
+ }
259
+ export interface RuntimeTransportConfigCompletionResult {
260
+ config: Record<string, unknown>;
261
+ warnings?: string[];
262
+ }
263
+ export interface RuntimeTransportPackage {
264
+ manifest: TransportPackageManifest;
265
+ createTransport(input: RuntimeTransportPackageContext): RuntimeTransport;
266
+ completeConfig?(input: RuntimeTransportConfigCompletionInput): RuntimeTransportConfigCompletionResult | Promise<RuntimeTransportConfigCompletionResult>;
267
+ }
268
+ export declare function validateTransportPackageManifest(manifest: TransportPackageManifest): TransportPackageManifest;
269
+ export declare function validateTransportPackageRuntimeContract(pkg: RuntimeTransportPackage): void;