@telorun/sdk 0.2.3 → 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.
Files changed (56) hide show
  1. package/README.md +5 -5
  2. package/dist/capabilities/invokable.d.ts +4 -0
  3. package/dist/capabilities/invokable.d.ts.map +1 -0
  4. package/dist/capabilities/invokable.js +1 -0
  5. package/dist/capabilities/provider.d.ts +4 -0
  6. package/dist/capabilities/provider.d.ts.map +1 -0
  7. package/dist/capabilities/provider.js +1 -0
  8. package/dist/capabilities/runnable.d.ts +4 -0
  9. package/dist/capabilities/runnable.d.ts.map +1 -0
  10. package/dist/capabilities/runnable.js +1 -0
  11. package/dist/context-provider.d.ts +18 -0
  12. package/dist/context-provider.d.ts.map +1 -0
  13. package/dist/context-provider.js +11 -0
  14. package/dist/controller-context.d.ts +2 -2
  15. package/dist/controller-context.d.ts.map +1 -0
  16. package/dist/evaluation-context.d.ts +103 -0
  17. package/dist/evaluation-context.d.ts.map +1 -0
  18. package/dist/evaluation-context.js +256 -0
  19. package/dist/execution-context.d.ts +13 -0
  20. package/dist/execution-context.d.ts.map +1 -0
  21. package/dist/execution-context.js +13 -0
  22. package/dist/index.d.ts +15 -7
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +14 -7
  25. package/dist/module-context.d.ts +51 -0
  26. package/dist/module-context.d.ts.map +1 -0
  27. package/dist/module-context.js +150 -0
  28. package/dist/resource-context.d.ts +21 -1
  29. package/dist/resource-context.d.ts.map +1 -0
  30. package/dist/resource-instance.d.ts +1 -0
  31. package/dist/resource-instance.d.ts.map +1 -0
  32. package/dist/resource-manifest.d.ts +2 -1
  33. package/dist/resource-manifest.d.ts.map +1 -0
  34. package/dist/runtime-error.d.ts +2 -1
  35. package/dist/runtime-error.d.ts.map +1 -0
  36. package/dist/runtime-event.d.ts +1 -0
  37. package/dist/runtime-event.d.ts.map +1 -0
  38. package/dist/runtime-resource.d.ts +1 -0
  39. package/dist/runtime-resource.d.ts.map +1 -0
  40. package/dist/types.d.ts +62 -0
  41. package/dist/types.d.ts.map +1 -0
  42. package/dist/types.js +8 -0
  43. package/package.json +5 -1
  44. package/src/capabilities/invokable.ts +3 -0
  45. package/src/capabilities/provider.ts +3 -0
  46. package/src/capabilities/runnable.ts +3 -0
  47. package/src/context-provider.ts +25 -0
  48. package/src/controller-context.ts +4 -14
  49. package/src/evaluation-context.ts +337 -0
  50. package/src/execution-context.ts +21 -0
  51. package/src/index.ts +14 -7
  52. package/src/module-context.ts +187 -0
  53. package/src/resource-context.ts +17 -5
  54. package/src/resource-manifest.ts +1 -1
  55. package/src/runtime-error.ts +11 -7
  56. 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
+ }