@telorun/sdk 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/capabilities/invokable.d.ts +4 -0
- package/dist/capabilities/invokable.d.ts.map +1 -0
- package/dist/capabilities/invokable.js +1 -0
- package/dist/capabilities/provider.d.ts +4 -0
- package/dist/capabilities/provider.d.ts.map +1 -0
- package/dist/capabilities/provider.js +1 -0
- package/dist/capabilities/runnable.d.ts +4 -0
- package/dist/capabilities/runnable.d.ts.map +1 -0
- package/dist/capabilities/runnable.js +1 -0
- package/dist/context-provider.d.ts +1 -0
- package/dist/context-provider.d.ts.map +1 -0
- package/dist/controller-context.d.ts +2 -2
- package/dist/controller-context.d.ts.map +1 -0
- package/dist/evaluation-context.d.ts +103 -0
- package/dist/evaluation-context.d.ts.map +1 -0
- package/dist/evaluation-context.js +256 -0
- package/dist/execution-context.d.ts +13 -0
- package/dist/execution-context.d.ts.map +1 -0
- package/dist/execution-context.js +13 -0
- package/dist/index.d.ts +15 -8
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -8
- package/dist/module-context.d.ts +51 -0
- package/dist/module-context.d.ts.map +1 -0
- package/dist/module-context.js +150 -0
- package/dist/resource-context.d.ts +11 -0
- package/dist/resource-context.d.ts.map +1 -0
- package/dist/resource-instance.d.ts +1 -0
- package/dist/resource-instance.d.ts.map +1 -0
- package/dist/resource-manifest.d.ts +2 -1
- package/dist/resource-manifest.d.ts.map +1 -0
- package/dist/runtime-error.d.ts +2 -1
- package/dist/runtime-error.d.ts.map +1 -0
- package/dist/runtime-event.d.ts +1 -0
- package/dist/runtime-event.d.ts.map +1 -0
- package/dist/runtime-resource.d.ts +1 -0
- package/dist/runtime-resource.d.ts.map +1 -0
- package/dist/types.d.ts +62 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/package.json +5 -1
- package/src/capabilities/invokable.ts +3 -0
- package/src/capabilities/provider.ts +3 -0
- package/src/capabilities/runnable.ts +3 -0
- package/src/controller-context.ts +4 -14
- package/src/evaluation-context.ts +337 -0
- package/src/execution-context.ts +21 -0
- package/src/index.ts +14 -8
- package/src/module-context.ts +187 -0
- package/src/resource-context.ts +11 -5
- package/src/resource-manifest.ts +1 -1
- package/src/runtime-error.ts +11 -8
- package/src/types.ts +83 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { ControllerContext } from "./controller-context.js";
|
|
2
|
+
import { ResourceContext } from "./resource-context.js";
|
|
3
|
+
import { ResourceInstance } from "./resource-instance.js";
|
|
4
|
+
import { ResourceManifest } from "./resource-manifest.js";
|
|
5
|
+
import { RuntimeErrorCode } from "./runtime-error.js";
|
|
6
|
+
import { RuntimeResource } from "./runtime-resource.js";
|
|
7
|
+
|
|
8
|
+
export interface KernelContext {
|
|
9
|
+
kernel: Kernel;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ExecContext {
|
|
13
|
+
execute(urn: string, input: any): Promise<any>;
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type ResourceCapability = string;
|
|
18
|
+
|
|
19
|
+
export interface ResourceDefinition {
|
|
20
|
+
kind: string;
|
|
21
|
+
metadata: {
|
|
22
|
+
name: string;
|
|
23
|
+
module: string;
|
|
24
|
+
};
|
|
25
|
+
schema: Record<string, any>; // JSON Schema
|
|
26
|
+
capabilities: ResourceCapability[];
|
|
27
|
+
events?: string[];
|
|
28
|
+
controllers?: Array<{
|
|
29
|
+
runtime: string;
|
|
30
|
+
entry: string;
|
|
31
|
+
}>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Controller definition for a resource kind.
|
|
36
|
+
* Maps a fully-qualified resource kind to its controller implementation for a specific runtime.
|
|
37
|
+
*/
|
|
38
|
+
export interface ControllerDefinition {
|
|
39
|
+
kind: string; // Fully-qualified kind (e.g., "Http.Route")
|
|
40
|
+
runtime: string; // Runtime selector (e.g., "node@>=20")
|
|
41
|
+
entry: string; // Path to controller implementation
|
|
42
|
+
controller?: any; // Lazy-loaded controller code
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Controller instance - runtime representation of a controller that handles resource instances.
|
|
47
|
+
*/
|
|
48
|
+
export interface ControllerInstance {
|
|
49
|
+
execute?(name: string, inputs: any, ctx: ExecContext): Promise<any>;
|
|
50
|
+
compile?(
|
|
51
|
+
resource: ResourceManifest,
|
|
52
|
+
ctx: ResourceContext,
|
|
53
|
+
): RuntimeResource | Promise<RuntimeResource>;
|
|
54
|
+
register?(ctx: ControllerContext): void | Promise<void>;
|
|
55
|
+
create?(
|
|
56
|
+
resource: ResourceManifest,
|
|
57
|
+
ctx: ResourceContext,
|
|
58
|
+
): ResourceInstance | null | Promise<ResourceInstance | null>;
|
|
59
|
+
schema: any;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface Kernel {
|
|
63
|
+
loadFromConfig(runtimeYamlPath: string): Promise<void>;
|
|
64
|
+
start(): Promise<void>;
|
|
65
|
+
acquireHold(reason?: string): () => void;
|
|
66
|
+
waitForIdle(): Promise<void>;
|
|
67
|
+
requestExit(code: number): void;
|
|
68
|
+
readonly exitCode: number;
|
|
69
|
+
// teardownResource(module: string, kind: string, name: string): Promise<void>;
|
|
70
|
+
// getSourceFiles(): string[];
|
|
71
|
+
// reloadSource(sourcePath: string): Promise<void>;
|
|
72
|
+
shutdown(): void;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export class RuntimeError extends Error {
|
|
76
|
+
constructor(
|
|
77
|
+
public code: RuntimeErrorCode,
|
|
78
|
+
message: string,
|
|
79
|
+
) {
|
|
80
|
+
super(message);
|
|
81
|
+
this.name = "RuntimeError";
|
|
82
|
+
}
|
|
83
|
+
}
|