@telorun/kernel 0.2.9 → 0.3.2

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 (127) hide show
  1. package/README.md +7 -7
  2. package/dist/controllers/module/import-controller.d.ts.map +1 -1
  3. package/dist/controllers/module/import-controller.js +22 -23
  4. package/dist/controllers/module/import-controller.js.map +1 -1
  5. package/dist/controllers/resource-definition/resource-definition-controller.d.ts +1 -1
  6. package/dist/controllers/resource-definition/resource-definition-controller.d.ts.map +1 -1
  7. package/dist/evaluation-context.d.ts +21 -4
  8. package/dist/evaluation-context.d.ts.map +1 -1
  9. package/dist/evaluation-context.js +216 -26
  10. package/dist/evaluation-context.js.map +1 -1
  11. package/dist/kernel.d.ts +11 -8
  12. package/dist/kernel.d.ts.map +1 -1
  13. package/dist/kernel.js +38 -16
  14. package/dist/kernel.js.map +1 -1
  15. package/dist/manifest-schemas.d.ts +44 -1
  16. package/dist/manifest-schemas.d.ts.map +1 -1
  17. package/dist/manifest-schemas.js +59 -15
  18. package/dist/manifest-schemas.js.map +1 -1
  19. package/dist/module-context.d.ts +1 -1
  20. package/dist/module-context.js +1 -1
  21. package/dist/resource-context.d.ts +6 -2
  22. package/dist/resource-context.d.ts.map +1 -1
  23. package/dist/resource-context.js +24 -4
  24. package/dist/resource-context.js.map +1 -1
  25. package/package.json +3 -3
  26. package/src/controllers/module/import-controller.ts +28 -28
  27. package/src/controllers/resource-definition/resource-definition-controller.ts +1 -1
  28. package/src/evaluation-context.ts +227 -32
  29. package/src/kernel.ts +52 -18
  30. package/src/manifest-schemas.ts +61 -15
  31. package/src/module-context.ts +1 -1
  32. package/src/resource-context.ts +38 -3
  33. package/dist/base-definition.d.ts +0 -14
  34. package/dist/base-definition.d.ts.map +0 -1
  35. package/dist/base-definition.js +0 -17
  36. package/dist/base-definition.js.map +0 -1
  37. package/dist/capabilities/capabilities/component.yaml +0 -4
  38. package/dist/capabilities/capabilities/executable.yaml +0 -8
  39. package/dist/capabilities/capabilities/handler.yaml +0 -4
  40. package/dist/capabilities/capabilities/listener.yaml +0 -4
  41. package/dist/capabilities/capabilities/provider.yaml +0 -4
  42. package/dist/capabilities/capabilities/template.yaml +0 -4
  43. package/dist/capabilities/capabilities/type.yaml +0 -4
  44. package/dist/capabilities/component.d.ts +0 -3
  45. package/dist/capabilities/component.d.ts.map +0 -1
  46. package/dist/capabilities/component.js +0 -4
  47. package/dist/capabilities/component.js.map +0 -1
  48. package/dist/capabilities/component.yaml +0 -3
  49. package/dist/capabilities/executable.d.ts +0 -3
  50. package/dist/capabilities/executable.d.ts.map +0 -1
  51. package/dist/capabilities/executable.js +0 -5
  52. package/dist/capabilities/executable.js.map +0 -1
  53. package/dist/capabilities/executable.yaml +0 -7
  54. package/dist/capabilities/handler.d.ts +0 -3
  55. package/dist/capabilities/handler.d.ts.map +0 -1
  56. package/dist/capabilities/handler.js +0 -4
  57. package/dist/capabilities/handler.js.map +0 -1
  58. package/dist/capabilities/handler.yaml +0 -3
  59. package/dist/capabilities/invokable.d.ts +0 -3
  60. package/dist/capabilities/invokable.d.ts.map +0 -1
  61. package/dist/capabilities/invokable.js +0 -5
  62. package/dist/capabilities/invokable.js.map +0 -1
  63. package/dist/capabilities/listener.d.ts +0 -3
  64. package/dist/capabilities/listener.d.ts.map +0 -1
  65. package/dist/capabilities/listener.js +0 -5
  66. package/dist/capabilities/listener.js.map +0 -1
  67. package/dist/capabilities/listener.yaml +0 -3
  68. package/dist/capabilities/mount.d.ts +0 -3
  69. package/dist/capabilities/mount.d.ts.map +0 -1
  70. package/dist/capabilities/mount.js +0 -5
  71. package/dist/capabilities/mount.js.map +0 -1
  72. package/dist/capabilities/provider.d.ts +0 -3
  73. package/dist/capabilities/provider.d.ts.map +0 -1
  74. package/dist/capabilities/provider.js +0 -8
  75. package/dist/capabilities/provider.js.map +0 -1
  76. package/dist/capabilities/provider.yaml +0 -3
  77. package/dist/capabilities/runnable.d.ts +0 -3
  78. package/dist/capabilities/runnable.d.ts.map +0 -1
  79. package/dist/capabilities/runnable.js +0 -5
  80. package/dist/capabilities/runnable.js.map +0 -1
  81. package/dist/capabilities/service.d.ts +0 -3
  82. package/dist/capabilities/service.d.ts.map +0 -1
  83. package/dist/capabilities/service.js +0 -5
  84. package/dist/capabilities/service.js.map +0 -1
  85. package/dist/capabilities/template.d.ts +0 -3
  86. package/dist/capabilities/template.d.ts.map +0 -1
  87. package/dist/capabilities/template.js +0 -5
  88. package/dist/capabilities/template.js.map +0 -1
  89. package/dist/capabilities/template.yaml +0 -3
  90. package/dist/capabilities/type.d.ts +0 -3
  91. package/dist/capabilities/type.d.ts.map +0 -1
  92. package/dist/capabilities/type.js +0 -5
  93. package/dist/capabilities/type.js.map +0 -1
  94. package/dist/capabilities/type.yaml +0 -3
  95. package/dist/controllers/capability/capability-controller.d.ts +0 -32
  96. package/dist/controllers/capability/capability-controller.d.ts.map +0 -1
  97. package/dist/controllers/capability/capability-controller.js +0 -26
  98. package/dist/controllers/capability/capability-controller.js.map +0 -1
  99. package/dist/controllers/module/module.json +0 -48
  100. package/dist/loader.d.ts +0 -18
  101. package/dist/loader.d.ts.map +0 -1
  102. package/dist/loader.js +0 -127
  103. package/dist/loader.js.map +0 -1
  104. package/dist/manifest-adapters/http-adapter.d.ts +0 -8
  105. package/dist/manifest-adapters/http-adapter.d.ts.map +0 -1
  106. package/dist/manifest-adapters/http-adapter.js +0 -31
  107. package/dist/manifest-adapters/http-adapter.js.map +0 -1
  108. package/dist/manifest-adapters/registry-adapter.d.ts +0 -9
  109. package/dist/manifest-adapters/registry-adapter.d.ts.map +0 -1
  110. package/dist/manifest-adapters/registry-adapter.js +0 -48
  111. package/dist/manifest-adapters/registry-adapter.js.map +0 -1
  112. package/dist/module-context-registry.d.ts +0 -48
  113. package/dist/module-context-registry.d.ts.map +0 -1
  114. package/dist/module-context-registry.js +0 -91
  115. package/dist/module-context-registry.js.map +0 -1
  116. package/dist/schema-valiator.d.ts +0 -15
  117. package/dist/schema-valiator.d.ts.map +0 -1
  118. package/dist/schema-valiator.js +0 -127
  119. package/dist/schema-valiator.js.map +0 -1
  120. package/dist/snapshot-serializer.d.ts +0 -62
  121. package/dist/snapshot-serializer.d.ts.map +0 -1
  122. package/dist/snapshot-serializer.js +0 -164
  123. package/dist/snapshot-serializer.js.map +0 -1
  124. package/dist/types.d.ts +0 -65
  125. package/dist/types.d.ts.map +0 -1
  126. package/dist/types.js +0 -8
  127. package/dist/types.js.map +0 -1
package/src/kernel.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { AnalysisRegistry, DEFAULT_MANIFEST_FILENAME, Loader, StaticAnalyzer } from "@telorun/analyzer";
1
+ import { AnalysisRegistry, DEFAULT_MANIFEST_FILENAME, isModuleKind, Loader, StaticAnalyzer } from "@telorun/analyzer";
2
2
  import {
3
3
  ControllerContext,
4
4
  Kernel as IKernel,
5
+ type LoadOptions,
5
6
  ResourceContext,
6
7
  ResourceDefinition,
7
8
  ResourceInstance,
@@ -13,6 +14,7 @@ import {
13
14
  type ModuleContext as IModuleContext,
14
15
  type ParsedArgs,
15
16
  } from "@telorun/sdk";
17
+ import { createHash } from "node:crypto";
16
18
  import { ModuleContext } from "./module-context.js";
17
19
  import * as path from "path";
18
20
  import { parseArgs } from "util";
@@ -29,15 +31,23 @@ export interface KernelOptions {
29
31
  stderr?: NodeJS.WritableStream;
30
32
  env?: Record<string, string | undefined>;
31
33
  argv?: string[];
34
+ /** Base URL for the registry adapter. When unset, the RegistryAdapter
35
+ * default applies. Callers (e.g. the CLI) are responsible for resolving
36
+ * `TELO_REGISTRY_URL` or any other env-based fallback before passing. */
37
+ registryUrl?: string;
32
38
  }
33
39
 
34
40
  /**
35
41
  * Kernel: Central orchestrator managing lifecycle and message bus
36
42
  * Handles resource loading, initialization, and execution through controllers
37
43
  */
44
+ const celHandlers = {
45
+ sha256: (s: string) => createHash("sha256").update(s).digest("hex"),
46
+ };
47
+
38
48
  export class Kernel implements IKernel {
39
- private readonly loader = new Loader();
40
- private readonly analyzer = new StaticAnalyzer();
49
+ private readonly loader: Loader;
50
+ private readonly analyzer = new StaticAnalyzer({ celHandlers });
41
51
  private readonly registry = new AnalysisRegistry();
42
52
  private controllers: ControllerRegistry = new ControllerRegistry();
43
53
  private eventBus: EventBus = new EventBus();
@@ -55,6 +65,7 @@ export class Kernel implements IKernel {
55
65
  readonly stderr: NodeJS.WritableStream;
56
66
  readonly env: Record<string, string | undefined>;
57
67
  readonly argv: string[];
68
+ readonly registryUrl: string | undefined;
58
69
 
59
70
  constructor(options: KernelOptions = {}) {
60
71
  this.stdin = options.stdin ?? process.stdin;
@@ -62,6 +73,8 @@ export class Kernel implements IKernel {
62
73
  this.stderr = options.stderr ?? process.stderr;
63
74
  this.env = options.env ?? process.env;
64
75
  this.argv = options.argv ?? [];
76
+ this.registryUrl = options.registryUrl;
77
+ this.loader = new Loader({ registryUrl: this.registryUrl, celHandlers });
65
78
  this.loader.register(new LocalFileAdapter());
66
79
  this.setupEventStreaming();
67
80
  }
@@ -101,6 +114,14 @@ export class Kernel implements IKernel {
101
114
  this.registry.registerImport(alias, targetModule, kinds);
102
115
  }
103
116
 
117
+ loadModule(url: string, options?: LoadOptions): Promise<ResourceManifest[]> {
118
+ return this.loader.loadModule(url, options);
119
+ }
120
+
121
+ loadManifests(url: string): Promise<ResourceManifest[]> {
122
+ return this.loader.loadManifests(url);
123
+ }
124
+
104
125
  /** Returns the live analysis registry backed by this kernel's known definitions and aliases.
105
126
  * Pass to StaticAnalyzer.analyze() for incremental validation of new manifests against
106
127
  * already-registered types (e.g. front-end editor validating a manifest before submitting). */
@@ -109,30 +130,29 @@ export class Kernel implements IKernel {
109
130
  }
110
131
 
111
132
  /**
112
- * Load built-in Runtime definitions (e.g., Kernel.Module)
133
+ * Load built-in Runtime definitions (e.g., Telo.Application, Telo.Library).
113
134
  * Also declares all known module namespaces upfront so that resources can be
114
- * registered to them. User-defined modules are declared explicitly by Kernel.Module
115
- * resources during the initialization phase.
135
+ * registered to them. User-defined modules are declared explicitly by
136
+ * Telo.Application or Telo.Library resources during the initialization phase.
116
137
  */
117
138
  private async loadBuiltinDefinitions(): Promise<void> {
118
139
  // Declare built-in module namespaces upfront so getContext() can distinguish
119
140
  // "not yet populated" from a completely unknown module name.
120
- this.rootContext.registerImport("Kernel", "Kernel", []); // built-ins, unrestricted
141
+ this.rootContext.registerImport("Telo", "Telo", []); // built-ins, unrestricted
121
142
 
122
143
  // Register built-in definitions with the controller registry.
123
144
  // AnalysisRegistry's underlying DefinitionRegistry already seeds KERNEL_BUILTINS on construction.
124
145
  for (const def of this.registry.builtinDefinitions()) this.controllers.registerDefinition(def);
125
146
 
126
147
  this.controllers.registerController(
127
- "Kernel.Definition",
148
+ "Telo.Definition",
128
149
  await import("./controllers/resource-definition/resource-definition-controller.js"),
129
150
  );
151
+ const moduleController = await import("./controllers/module/module-controller.js");
152
+ this.controllers.registerController("Telo.Application", moduleController);
153
+ this.controllers.registerController("Telo.Library", moduleController);
130
154
  this.controllers.registerController(
131
- "Kernel.Module",
132
- await import("./controllers/module/module-controller.js"),
133
- );
134
- this.controllers.registerController(
135
- "Kernel.Import",
155
+ "Telo.Import",
136
156
  await import("./controllers/module/import-controller.js"),
137
157
  );
138
158
  }
@@ -160,16 +180,28 @@ export class Kernel implements IKernel {
160
180
  this.rootContext.preInitHook = (resource, getInstance) =>
161
181
  this._injectDependencies(resource, getInstance);
162
182
 
183
+ // Expose definition lookup so invoke()/invokeResolved() can check thrown
184
+ // InvokeError.code against the declared throw union (rule 9). Propagates
185
+ // through spawnChild() to module imports and scoped handles.
186
+ this.rootContext.getDefinition = (kind) => this.controllers.getDefinition(kind);
187
+
163
188
  // Static analysis pre-flight: validates schemas and invocation context compatibility.
164
189
  // All errors are fatal — kernel does not start if analysis fails.
165
190
  const staticManifests = await this.loader.loadManifests(sourceUrl);
166
191
  this.staticManifests = staticManifests;
167
192
 
168
193
  // Register module identities for x-telo-ref resolution (Phase 3 prerequisite).
169
- // Kernel built-ins ("kernel" → "Kernel") are auto-registered when Kernel.Abstract
194
+ // Telo built-ins ("telo" → "Telo") are auto-registered when Telo.Abstract
170
195
  // definitions are registered in loadBuiltinDefinitions() above.
196
+ const rootModuleDoc = staticManifests.find((m) => isModuleKind(m.kind));
197
+ if (rootModuleDoc?.kind === "Telo.Library") {
198
+ throw new RuntimeError(
199
+ "ERR_MANIFEST_VALIDATION_FAILED",
200
+ `Root manifest '${sourceUrl}' is a Telo.Library. Only Telo.Application manifests can be run directly — libraries are imported via Telo.Import.`,
201
+ );
202
+ }
171
203
  for (const m of staticManifests) {
172
- if (m.kind === "Kernel.Module" && m.metadata?.name && m.metadata?.namespace) {
204
+ if (isModuleKind(m.kind) && m.metadata?.name && m.metadata?.namespace) {
173
205
  this.registry.registerModuleIdentity(
174
206
  m.metadata.namespace as string,
175
207
  m.metadata.name as string,
@@ -204,9 +236,10 @@ export class Kernel implements IKernel {
204
236
  this.staticManifests = normalizedManifests;
205
237
 
206
238
  for (const manifest of normalizedManifests) {
207
- if (manifest.kind === "Kernel.Module") {
208
- this.rootContext.setSecrets(manifest.secrets ?? {});
209
- this.rootContext.setVariables(manifest.variables ?? {});
239
+ if (isModuleKind(manifest.kind)) {
240
+ // Root is always Telo.Application (Library root rejected above). Applications
241
+ // have no variables/secrets fields — those are a Library-only contract, populated
242
+ // by importers, not by the root manifest itself.
210
243
  this.rootContext.setTargets(manifest.targets ?? []);
211
244
  }
212
245
  this.rootContext.registerManifest(manifest);
@@ -386,6 +419,7 @@ export class Kernel implements IKernel {
386
419
  moduleContext,
387
420
  resource.metadata,
388
421
  this.sharedSchemaValidator,
422
+ this.env,
389
423
  this.stdin,
390
424
  this.stdout,
391
425
  this.stderr,
@@ -21,41 +21,87 @@ const metadataSchema = {
21
21
  additionalProperties: true,
22
22
  };
23
23
 
24
+ const throwsSchema = {
25
+ type: "object",
26
+ additionalProperties: false,
27
+ properties: {
28
+ codes: {
29
+ type: "object",
30
+ propertyNames: { pattern: "^[A-Z][A-Z0-9_]*$" },
31
+ additionalProperties: {
32
+ type: "object",
33
+ required: ["description"],
34
+ additionalProperties: false,
35
+ properties: {
36
+ description: { type: "string" },
37
+ data: { type: "object", additionalProperties: true },
38
+ },
39
+ },
40
+ },
41
+ // "my throw union includes every code thrown by every invocable I call
42
+ // (minus codes caught in an enclosing try/catch)". Analyzer enforces
43
+ // that this is only legal on definitions whose schema declares at least
44
+ // one `x-telo-step-context` array.
45
+ inherit: { type: "boolean" },
46
+ // "my throw union is whatever `inputs.code` resolves to statically." Used
47
+ // by passthrough-style adapters. Analyzer resolves per call site.
48
+ passthrough: { type: "boolean" },
49
+ },
50
+ };
51
+
24
52
  const baseDefinition = {
25
53
  type: "object",
26
54
  required: ["kind", "metadata"],
27
55
  properties: {
28
- kind: { const: "Kernel.Definition" },
56
+ kind: { const: "Telo.Definition" },
29
57
  metadata: metadataSchema,
30
58
  capability: { type: "string" },
31
59
  schema: { type: "object", additionalProperties: true },
32
60
  controllers: { type: "array", items: { type: "string" } },
61
+ throws: throwsSchema,
33
62
  },
34
63
  unevaluatedProperties: false,
35
64
  };
36
65
 
37
66
  const KNOWN_CAPABILITIES = [
38
- "Kernel.Service",
39
- "Kernel.Runnable",
40
- "Kernel.Invocable",
41
- "Kernel.Provider",
42
- "Kernel.Type",
43
- "Kernel.Mount",
67
+ "Telo.Service",
68
+ "Telo.Runnable",
69
+ "Telo.Invocable",
70
+ "Telo.Provider",
71
+ "Telo.Type",
72
+ "Telo.Mount",
44
73
  ] as const;
45
74
 
75
+ /** Rule 8: `throws:` is only meaningful on Telo.Invocable or Telo.Runnable.
76
+ * On Service/Mount/Provider/Type/etc. a thrown error is a boot-time failure,
77
+ * not a structured runtime error for a downstream caller, so declaring one
78
+ * is a schema error. */
79
+ const forbidThrows = { not: { required: ["throws"] } };
80
+
46
81
  export const ResourceDefinitionSchema = {
47
82
  ...baseDefinition,
48
83
  oneOf: [
49
- { required: ["capability"], properties: { capability: { const: "Kernel.Service" } } },
50
- { required: ["capability"], properties: { capability: { const: "Kernel.Runnable" } } },
51
- { required: ["capability"], properties: { capability: { const: "Kernel.Invocable" } } },
52
- { required: ["capability"], properties: { capability: { const: "Kernel.Provider" } } },
53
- { required: ["capability"], properties: { capability: { const: "Kernel.Type" } } },
54
84
  {
55
85
  required: ["capability"],
56
- properties: {
57
- capability: { const: "Kernel.Mount" },
58
- },
86
+ properties: { capability: { const: "Telo.Service" } },
87
+ ...forbidThrows,
88
+ },
89
+ { required: ["capability"], properties: { capability: { const: "Telo.Runnable" } } },
90
+ { required: ["capability"], properties: { capability: { const: "Telo.Invocable" } } },
91
+ {
92
+ required: ["capability"],
93
+ properties: { capability: { const: "Telo.Provider" } },
94
+ ...forbidThrows,
95
+ },
96
+ {
97
+ required: ["capability"],
98
+ properties: { capability: { const: "Telo.Type" } },
99
+ ...forbidThrows,
100
+ },
101
+ {
102
+ required: ["capability"],
103
+ properties: { capability: { const: "Telo.Mount" } },
104
+ ...forbidThrows,
59
105
  },
60
106
  // Unknown/absent capability: open schema for third-party extensibility
61
107
  {
@@ -109,7 +109,7 @@ export class ModuleContext extends EvaluationContext implements IModuleContext {
109
109
 
110
110
  /**
111
111
  * Register an imported module under the given alias, with the list of kind names
112
- * it exports. An empty kinds array means no restriction (used for built-ins like Kernel).
112
+ * it exports. An empty kinds array means no restriction (used for built-ins like Telo).
113
113
  */
114
114
  registerImport(alias: string, targetModule: string, kinds: string[]): void {
115
115
  this.importAliases.set(alias, targetModule);
@@ -1,10 +1,13 @@
1
1
  import {
2
2
  NoopValidator,
3
3
  ResourceContext,
4
+ ResourceInstance,
5
+ ResourceManifest,
4
6
  RuntimeError,
5
7
  RuntimeResource,
6
8
  isCompiledValue,
7
9
  type EvaluationContext as IEvaluationContext,
10
+ type LoadOptions,
8
11
  type ModuleContext,
9
12
  type ParsedArgs,
10
13
  type TypeRule,
@@ -19,6 +22,7 @@ import { SchemaValidator } from "./schema-validator.js";
19
22
  const Ajv = AjvModule.default ?? AjvModule;
20
23
 
21
24
  export class ResourceContextImpl implements ResourceContext {
25
+ readonly env: Record<string, string | undefined>;
22
26
  readonly stdin: NodeJS.ReadableStream;
23
27
  readonly stdout: NodeJS.WritableStream;
24
28
  readonly stderr: NodeJS.WritableStream;
@@ -29,11 +33,13 @@ export class ResourceContextImpl implements ResourceContext {
29
33
  readonly moduleContext: ModuleContext,
30
34
  private readonly metadata: Record<string, any>,
31
35
  private readonly validator: SchemaValidator = new SchemaValidator(),
36
+ env?: Record<string, string | undefined>,
32
37
  stdin?: NodeJS.ReadableStream,
33
38
  stdout?: NodeJS.WritableStream,
34
39
  stderr?: NodeJS.WritableStream,
35
40
  args?: ParsedArgs,
36
41
  ) {
42
+ this.env = env ?? process.env;
37
43
  this.stdin = stdin ?? process.stdin;
38
44
  this.stdout = stdout ?? process.stdout;
39
45
  this.stderr = stderr ?? process.stderr;
@@ -128,6 +134,15 @@ export class ResourceContextImpl implements ResourceContext {
128
134
  return this.moduleContext.invoke(kind, name, inputs);
129
135
  }
130
136
 
137
+ invokeResolved<TInputs>(
138
+ kind: string,
139
+ name: string,
140
+ instance: ResourceInstance,
141
+ inputs: TInputs,
142
+ ): Promise<any> {
143
+ return this.moduleContext.invokeResolved(kind, name, instance, inputs);
144
+ }
145
+
131
146
  async run(name: string) {
132
147
  await this.moduleContext.run(name);
133
148
  }
@@ -136,6 +151,14 @@ export class ResourceContextImpl implements ResourceContext {
136
151
  this.moduleContext.registerManifest(resource);
137
152
  }
138
153
 
154
+ loadModule(url: string, options?: LoadOptions): Promise<ResourceManifest[]> {
155
+ return this.kernel.loadModule(url, options);
156
+ }
157
+
158
+ loadManifests(url: string): Promise<ResourceManifest[]> {
159
+ return this.kernel.loadManifests(url);
160
+ }
161
+
139
162
  /**
140
163
  * Resolves a resource into a normalized {kind, name} reference.
141
164
  * If the resource contains a definition (kind + properties), registers it as a manifest.
@@ -168,12 +191,24 @@ export class ResourceContextImpl implements ResourceContext {
168
191
  resourceName ??
169
192
  `Unnamed${Math.random().toString(16).slice(2, 8)}`;
170
193
 
171
- // If resource has properties beyond kind/name, it's a definition - register it
172
- const definitionKeys = Object.keys(resource).filter(
194
+ // Register an inline manifest when:
195
+ // - the ref carries definition properties (clearly an inline definition), or
196
+ // - the ref is bare `{kind}` with no explicit name and the caller supplied
197
+ // a `resourceName` (the slot is known-inline — e.g. a Run.Sequence step
198
+ // with `invoke: {kind: SomeInvocable}` — and wants a fresh stateless
199
+ // instance registered under the generated name).
200
+ // Pure references (`{kind, name}` pointing at an existing resource) carry
201
+ // an explicit name and skip registration.
202
+ const hasInlineProperties = Object.keys(resource).some(
173
203
  (k) => k !== "kind" && k !== "name" && k !== "metadata",
174
204
  );
205
+ const hasExplicitName =
206
+ resource.name !== undefined || resource.metadata?.name !== undefined;
207
+ const shouldRegister =
208
+ (hasInlineProperties || (!hasExplicitName && resourceName !== undefined)) &&
209
+ !this.moduleContext.hasManifest(name);
175
210
 
176
- if (definitionKeys.length > 0 && !this.moduleContext.hasManifest(name)) {
211
+ if (shouldRegister) {
177
212
  this.registerManifest({
178
213
  ...resource,
179
214
  metadata: {
@@ -1,14 +0,0 @@
1
- import type { ModuleContext, ResourceContext, ResourceDefinition, ResourceInstance, ResourceManifest } from "@telorun/sdk";
2
- export interface BaseDefinition {
3
- name: string;
4
- expand?: {
5
- compile?: string[];
6
- runtime?: string[];
7
- };
8
- onDefinition?(definition: ResourceDefinition, ctx: ResourceContext): void | Promise<void>;
9
- onManifest?(manifest: ResourceManifest, ctx: ModuleContext): ResourceManifest | Promise<ResourceManifest>;
10
- onInit?(instance: ResourceInstance, ctx: ResourceContext): Promise<void>;
11
- onInvoke?(instance: ResourceInstance, inputs: any, ctx: ResourceContext): Promise<any>;
12
- }
13
- export declare function createBaseDefinition(def: BaseDefinition): BaseDefinition;
14
- //# sourceMappingURL=base-definition.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base-definition.d.ts","sourceRoot":"","sources":["../src/base-definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE;QACP,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC;IACF,YAAY,CAAC,CAAC,UAAU,EAAE,kBAAkB,EAAE,GAAG,EAAE,eAAe,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1F,UAAU,CAAC,CACT,QAAQ,EAAE,gBAAgB,EAC1B,GAAG,EAAE,aAAa,GACjB,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAChD,MAAM,CAAC,CAAC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzE,QAAQ,CAAC,CAAC,QAAQ,EAAE,gBAAgB,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;CACxF;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,cAAc,GAAG,cAAc,CAoBxE"}
@@ -1,17 +0,0 @@
1
- export function createBaseDefinition(def) {
2
- const compile = def.expand?.compile ?? [];
3
- const runtime = def.expand?.runtime ?? [];
4
- return {
5
- ...def,
6
- onManifest: compile.length
7
- ? (manifest, ctx) => ctx.expandPaths(manifest, compile, runtime)
8
- : def.onManifest,
9
- onInvoke: runtime.length
10
- ? async (instance, inputs, _ctx) => {
11
- const expanded = _ctx.moduleContext.expandPaths(inputs, runtime);
12
- return instance.invoke(expanded);
13
- }
14
- : def.onInvoke,
15
- };
16
- }
17
- //# sourceMappingURL=base-definition.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base-definition.js","sourceRoot":"","sources":["../src/base-definition.ts"],"names":[],"mappings":"AAuBA,MAAM,UAAU,oBAAoB,CAAC,GAAmB;IACtD,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,EAAE,OAAO,IAAI,EAAE,CAAC;IAC1C,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,EAAE,OAAO,IAAI,EAAE,CAAC;IAE1C,OAAO;QACL,GAAG,GAAG;QACN,UAAU,EAAE,OAAO,CAAC,MAAM;YACxB,CAAC,CAAC,CAAC,QAAQ,EAAE,GAAG,EAAE,EAAE,CAChB,GAAG,CAAC,WAAW,CAAC,QAAmC,EAAE,OAAO,EAAE,OAAO,CAAqB;YAC9F,CAAC,CAAC,GAAG,CAAC,UAAU;QAClB,QAAQ,EAAE,OAAO,CAAC,MAAM;YACtB,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;gBAC/B,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,CAC7C,MAAiC,EACjC,OAAO,CACR,CAAC;gBACF,OAAO,QAAQ,CAAC,MAAO,CAAC,QAAQ,CAAC,CAAC;YACpC,CAAC;YACH,CAAC,CAAC,GAAG,CAAC,QAAQ;KACjB,CAAC;AACJ,CAAC"}
@@ -1,4 +0,0 @@
1
- kind: Kernel.Capability
2
- metadata:
3
- module: Kernel
4
- name: component
@@ -1,8 +0,0 @@
1
- kind: Kernel.Capability
2
- metadata:
3
- module: Kernel
4
- name: executable
5
- schema:
6
- type: object
7
- properties:
8
- foo: { type: string }
@@ -1,4 +0,0 @@
1
- kind: Kernel.Capability
2
- metadata:
3
- module: Kernel
4
- name: handler
@@ -1,4 +0,0 @@
1
- kind: Kernel.Capability
2
- metadata:
3
- module: Kernel
4
- name: listener
@@ -1,4 +0,0 @@
1
- kind: Kernel.Capability
2
- metadata:
3
- module: Kernel
4
- name: provider
@@ -1,4 +0,0 @@
1
- kind: Kernel.Capability
2
- metadata:
3
- module: Kernel
4
- name: template
@@ -1,4 +0,0 @@
1
- kind: Kernel.Capability
2
- metadata:
3
- module: Kernel
4
- name: type
@@ -1,3 +0,0 @@
1
- import type { BaseDefinition } from "../base-definition.js";
2
- export declare const component: BaseDefinition;
3
- //# sourceMappingURL=component.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/capabilities/component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,eAAO,MAAM,SAAS,EAAE,cAEvB,CAAC"}
@@ -1,4 +0,0 @@
1
- export const component = {
2
- name: "component",
3
- };
4
- //# sourceMappingURL=component.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"component.js","sourceRoot":"","sources":["../../src/capabilities/component.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,SAAS,GAAmB;IACvC,IAAI,EAAE,WAAW;CAClB,CAAC"}
@@ -1,3 +0,0 @@
1
- kind: Kernel.Capability
2
- metadata:
3
- name: component
@@ -1,3 +0,0 @@
1
- import type { ResourceDefinition } from "@telorun/sdk";
2
- export declare const runnable: ResourceDefinition;
3
- //# sourceMappingURL=executable.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"executable.d.ts","sourceRoot":"","sources":["../../src/capabilities/executable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,eAAO,MAAM,QAAQ,EAAE,kBAGtB,CAAC"}
@@ -1,5 +0,0 @@
1
- export const runnable = {
2
- kind: "Kernel.Abstract",
3
- metadata: { name: "Runnable", module: "Kernel" },
4
- };
5
- //# sourceMappingURL=executable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"executable.js","sourceRoot":"","sources":["../../src/capabilities/executable.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,QAAQ,GAAuB;IAC1C,IAAI,EAAE,iBAAiB;IACvB,QAAQ,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE;CACjD,CAAC"}
@@ -1,7 +0,0 @@
1
- kind: Kernel.Capability
2
- metadata:
3
- name: executable
4
- schema:
5
- type: object
6
- properties:
7
- foo: { type: string }
@@ -1,3 +0,0 @@
1
- import type { BaseDefinition } from "../base-definition.js";
2
- export declare const handler: BaseDefinition;
3
- //# sourceMappingURL=handler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/capabilities/handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,eAAO,MAAM,OAAO,EAAE,cAErB,CAAC"}
@@ -1,4 +0,0 @@
1
- export const handler = {
2
- name: "handler",
3
- };
4
- //# sourceMappingURL=handler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/capabilities/handler.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,OAAO,GAAmB;IACrC,IAAI,EAAE,SAAS;CAChB,CAAC"}
@@ -1,3 +0,0 @@
1
- kind: Kernel.Capability
2
- metadata:
3
- name: handler
@@ -1,3 +0,0 @@
1
- import type { ResourceDefinition } from "@telorun/sdk";
2
- export declare const invocable: ResourceDefinition;
3
- //# sourceMappingURL=invokable.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"invokable.d.ts","sourceRoot":"","sources":["../../src/capabilities/invokable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,eAAO,MAAM,SAAS,EAAE,kBAGvB,CAAC"}
@@ -1,5 +0,0 @@
1
- export const invocable = {
2
- kind: "Kernel.Abstract",
3
- metadata: { name: "Invocable", module: "Kernel" },
4
- };
5
- //# sourceMappingURL=invokable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"invokable.js","sourceRoot":"","sources":["../../src/capabilities/invokable.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,SAAS,GAAuB;IAC3C,IAAI,EAAE,iBAAiB;IACvB,QAAQ,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE;CAClD,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { ResourceDefinition } from "@telorun/sdk";
2
- export declare const service: ResourceDefinition;
3
- //# sourceMappingURL=listener.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"listener.d.ts","sourceRoot":"","sources":["../../src/capabilities/listener.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,eAAO,MAAM,OAAO,EAAE,kBAGrB,CAAC"}
@@ -1,5 +0,0 @@
1
- export const service = {
2
- kind: "Kernel.Abstract",
3
- metadata: { name: "Service", module: "Kernel" },
4
- };
5
- //# sourceMappingURL=listener.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"listener.js","sourceRoot":"","sources":["../../src/capabilities/listener.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,OAAO,GAAuB;IACzC,IAAI,EAAE,iBAAiB;IACvB,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE;CAChD,CAAC"}
@@ -1,3 +0,0 @@
1
- kind: Kernel.Capability
2
- metadata:
3
- name: listener
@@ -1,3 +0,0 @@
1
- import type { ResourceDefinition } from "@telorun/sdk";
2
- export declare const mount: ResourceDefinition;
3
- //# sourceMappingURL=mount.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../../src/capabilities/mount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,eAAO,MAAM,KAAK,EAAE,kBAGnB,CAAC"}
@@ -1,5 +0,0 @@
1
- export const mount = {
2
- kind: "Kernel.Abstract",
3
- metadata: { name: "Mount", module: "Kernel" },
4
- };
5
- //# sourceMappingURL=mount.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mount.js","sourceRoot":"","sources":["../../src/capabilities/mount.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,KAAK,GAAuB;IACvC,IAAI,EAAE,iBAAiB;IACvB,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE;CAC9C,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { ResourceDefinition } from "@telorun/sdk";
2
- export declare const provider: ResourceDefinition;
3
- //# sourceMappingURL=provider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/capabilities/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,eAAO,MAAM,QAAQ,EAAE,kBAMtB,CAAC"}
@@ -1,8 +0,0 @@
1
- export const provider = {
2
- kind: "Kernel.Abstract",
3
- metadata: { name: "Provider", module: "Kernel" },
4
- expand: {
5
- compile: ["**"],
6
- },
7
- };
8
- //# sourceMappingURL=provider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/capabilities/provider.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,QAAQ,GAAuB;IAC1C,IAAI,EAAE,iBAAiB;IACvB,QAAQ,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE;IAChD,MAAM,EAAE;QACN,OAAO,EAAE,CAAC,IAAI,CAAC;KAChB;CACF,CAAC"}
@@ -1,3 +0,0 @@
1
- kind: Kernel.Capability
2
- metadata:
3
- name: provider
@@ -1,3 +0,0 @@
1
- import type { ResourceDefinition } from "@telorun/sdk";
2
- export declare const runnable: ResourceDefinition;
3
- //# sourceMappingURL=runnable.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runnable.d.ts","sourceRoot":"","sources":["../../src/capabilities/runnable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,eAAO,MAAM,QAAQ,EAAE,kBAGtB,CAAC"}