@telorun/kernel 0.2.4
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/LICENSE +17 -0
- package/dist/boot-context-registry.d.ts +47 -0
- package/dist/boot-context-registry.d.ts.map +1 -0
- package/dist/boot-context-registry.js +131 -0
- package/dist/boot-context-registry.js.map +1 -0
- package/dist/capabilities/capabilities/component.yaml +3 -0
- package/dist/capabilities/capabilities/executable.yaml +7 -0
- package/dist/capabilities/capabilities/handler.yaml +3 -0
- package/dist/capabilities/capabilities/listener.yaml +3 -0
- package/dist/capabilities/capabilities/provider.yaml +3 -0
- package/dist/capabilities/capabilities/template.yaml +3 -0
- package/dist/capabilities/capabilities/type.yaml +3 -0
- package/dist/capabilities/component.yaml +3 -0
- package/dist/capabilities/executable.yaml +7 -0
- package/dist/capabilities/handler.yaml +3 -0
- package/dist/capabilities/listener.yaml +3 -0
- package/dist/capabilities/provider.yaml +3 -0
- package/dist/capabilities/template.yaml +3 -0
- package/dist/capabilities/type.yaml +3 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +109 -0
- package/dist/cli.js.map +1 -0
- package/dist/controller-loader.d.ts +24 -0
- package/dist/controller-loader.d.ts.map +1 -0
- package/dist/controller-loader.js +265 -0
- package/dist/controller-loader.js.map +1 -0
- package/dist/controller-registry.d.ts +56 -0
- package/dist/controller-registry.d.ts.map +1 -0
- package/dist/controller-registry.js +169 -0
- package/dist/controller-registry.js.map +1 -0
- package/dist/controllers/capability/capability-controller.d.ts +37 -0
- package/dist/controllers/capability/capability-controller.d.ts.map +1 -0
- package/dist/controllers/capability/capability-controller.js +30 -0
- package/dist/controllers/capability/capability-controller.js.map +1 -0
- package/dist/controllers/module/module-controller.d.ts +16 -0
- package/dist/controllers/module/module-controller.d.ts.map +1 -0
- package/dist/controllers/module/module-controller.js +95 -0
- package/dist/controllers/module/module-controller.js.map +1 -0
- package/dist/controllers/module/module.json +48 -0
- package/dist/controllers/resource-definition/resource-definition-controller.d.ts +33 -0
- package/dist/controllers/resource-definition/resource-definition-controller.d.ts.map +1 -0
- package/dist/controllers/resource-definition/resource-definition-controller.js +44 -0
- package/dist/controllers/resource-definition/resource-definition-controller.js.map +1 -0
- package/dist/event-stream.d.ts +45 -0
- package/dist/event-stream.d.ts.map +1 -0
- package/dist/event-stream.js +98 -0
- package/dist/event-stream.js.map +1 -0
- package/dist/events.d.ts +13 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +89 -0
- package/dist/events.js.map +1 -0
- package/dist/expressions.d.ts +20 -0
- package/dist/expressions.d.ts.map +1 -0
- package/dist/expressions.js +253 -0
- package/dist/expressions.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/kernel.d.ts +113 -0
- package/dist/kernel.d.ts.map +1 -0
- package/dist/kernel.js +558 -0
- package/dist/kernel.js.map +1 -0
- package/dist/loader.d.ts +17 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +189 -0
- package/dist/loader.js.map +1 -0
- package/dist/manifest-adapters/http-adapter.d.ts +8 -0
- package/dist/manifest-adapters/http-adapter.d.ts.map +1 -0
- package/dist/manifest-adapters/http-adapter.js +29 -0
- package/dist/manifest-adapters/http-adapter.js.map +1 -0
- package/dist/manifest-adapters/local-file-adapter.d.ts +11 -0
- package/dist/manifest-adapters/local-file-adapter.d.ts.map +1 -0
- package/dist/manifest-adapters/local-file-adapter.js +51 -0
- package/dist/manifest-adapters/local-file-adapter.js.map +1 -0
- package/dist/manifest-adapters/manifest-adapter.d.ts +33 -0
- package/dist/manifest-adapters/manifest-adapter.d.ts.map +1 -0
- package/dist/manifest-adapters/manifest-adapter.js +2 -0
- package/dist/manifest-adapters/manifest-adapter.js.map +1 -0
- package/dist/manifest-adapters/registry-adapter.d.ts +9 -0
- package/dist/manifest-adapters/registry-adapter.d.ts.map +1 -0
- package/dist/manifest-adapters/registry-adapter.js +46 -0
- package/dist/manifest-adapters/registry-adapter.js.map +1 -0
- package/dist/manifest-schemas.d.ts +66 -0
- package/dist/manifest-schemas.d.ts.map +1 -0
- package/dist/manifest-schemas.js +55 -0
- package/dist/manifest-schemas.js.map +1 -0
- package/dist/registry.d.ts +41 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +122 -0
- package/dist/registry.js.map +1 -0
- package/dist/resource-context.d.ts +48 -0
- package/dist/resource-context.d.ts.map +1 -0
- package/dist/resource-context.js +146 -0
- package/dist/resource-context.js.map +1 -0
- package/dist/resource-uri.d.ts +80 -0
- package/dist/resource-uri.d.ts.map +1 -0
- package/dist/resource-uri.js +160 -0
- package/dist/resource-uri.js.map +1 -0
- package/dist/schema-valiator.d.ts +9 -0
- package/dist/schema-valiator.d.ts.map +1 -0
- package/dist/schema-valiator.js +43 -0
- package/dist/schema-valiator.js.map +1 -0
- package/dist/snapshot-serializer.d.ts +63 -0
- package/dist/snapshot-serializer.d.ts.map +1 -0
- package/dist/snapshot-serializer.js +164 -0
- package/dist/snapshot-serializer.js.map +1 -0
- package/dist/src/controllers/module/module.yaml +32 -0
- package/dist/template-definition.d.ts +38 -0
- package/dist/template-definition.d.ts.map +1 -0
- package/dist/template-definition.js +26 -0
- package/dist/template-definition.js.map +1 -0
- package/dist/template-expander.d.ts +19 -0
- package/dist/template-expander.d.ts.map +1 -0
- package/dist/template-expander.js +425 -0
- package/dist/template-expander.js.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/dist/types.js.map +1 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# SUSTAINABLE USE LICENSE (Fair-code)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 DiglyAI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to use, copy, modify, and distribute the Software for any purpose—including commercial purposes—subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
1. ANTI-COMPETITION RESTRICTION: The Software may not be provided to third parties as a managed service, commercial SaaS (Software-as-a-Service), PaaS (Platform-as-a-Service), BaaS (Backend-as-a-Service), or similar offering where the primary value provided to the user is the functionality of the Software itself, without a separate commercial license from the copyright holder.
|
|
8
|
+
|
|
9
|
+
2. PERMITTED COMMERCIAL USE: You are free to use the Software to build, host, and monetize your own commercial applications, products, and services, provided such use does not violate Clause 1.
|
|
10
|
+
|
|
11
|
+
3. ATTRIBUTION: This copyright notice and license must be included in all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
4. CONTRIBUTIONS: Contributions to the Software are welcome and encouraged. By contributing, you agree that your contributions may be incorporated into the Software and distributed under this license.
|
|
14
|
+
|
|
15
|
+
5. DISCLAIMER: The Software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the Software or the use or other dealings in the Software.
|
|
16
|
+
|
|
17
|
+
For commercial licensing, managed hosting exemptions, or enterprise inquiries, please contact DiglyAI.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Accumulates ContextProvider contributions during the AOT boot initialization
|
|
3
|
+
* multi-pass loop and enforces RBAC visibility rules.
|
|
4
|
+
*
|
|
5
|
+
* Lifecycle:
|
|
6
|
+
* 1. A provider resource is created + init()'d → kernel calls register().
|
|
7
|
+
* 2. Before a consumer resource is created → kernel calls buildContext() to
|
|
8
|
+
* obtain a per-consumer CEL evaluation context.
|
|
9
|
+
* 3. buildContext() enforces grants and scans the raw manifest for unauthorized
|
|
10
|
+
* references, throwing ERR_VISIBILITY_DENIED on violations.
|
|
11
|
+
*/
|
|
12
|
+
export declare class BootContextRegistry {
|
|
13
|
+
private providers;
|
|
14
|
+
/**
|
|
15
|
+
* Register a new context provider after its init() has completed.
|
|
16
|
+
* Called by the kernel for every resource instance that passes isContextProvider().
|
|
17
|
+
*/
|
|
18
|
+
register(kind: string, name: string, module: string, grants: string[] | undefined, context: Record<string, unknown>): void;
|
|
19
|
+
/**
|
|
20
|
+
* Returns true if at least one provider has been registered.
|
|
21
|
+
* Used by the kernel to skip context resolution when there are no providers yet.
|
|
22
|
+
*/
|
|
23
|
+
hasProviders(): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Build a CEL evaluation context for a specific consumer resource, enforcing
|
|
26
|
+
* RBAC grants.
|
|
27
|
+
*
|
|
28
|
+
* For each registered provider:
|
|
29
|
+
* - `grants === undefined` → unrestricted, always included.
|
|
30
|
+
* - `grants` defined and consumer key in grants → included.
|
|
31
|
+
* - `grants` defined and consumer key NOT in grants:
|
|
32
|
+
* - Scan the raw manifest JSON for `${{ ... }}` expressions that reference
|
|
33
|
+
* the provider's namespace prefix (`"${kind}.${name}."`).
|
|
34
|
+
* - If a reference is found → throw ERR_VISIBILITY_DENIED immediately.
|
|
35
|
+
* - If no reference → silently exclude the provider from the context.
|
|
36
|
+
*
|
|
37
|
+
* CEL context structure mirrors the kind hierarchy:
|
|
38
|
+
* kind="Config", name="database" → { Config: { database: { host, port } } }
|
|
39
|
+
* kind="MyApp.Secrets", name="vault" → { MyApp: { Secrets: { vault: { ... } } } }
|
|
40
|
+
*
|
|
41
|
+
* @param consumerKind - kind of the resource being initialized (e.g. "MyApp.Api.Server")
|
|
42
|
+
* @param consumerName - name of the resource being initialized (e.g. "api")
|
|
43
|
+
* @param rawManifest - the unresolved manifest object (used for namespace reference scan)
|
|
44
|
+
*/
|
|
45
|
+
buildContext(consumerKind: string, consumerName: string, rawManifest: Record<string, unknown>): Record<string, unknown>;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=boot-context-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boot-context-registry.d.ts","sourceRoot":"","sources":["../src/boot-context-registry.ts"],"names":[],"mappings":"AAgBA;;;;;;;;;;GAUG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,SAAS,CAAuB;IAExC;;;OAGG;IACH,QAAQ,CACN,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,EAC5B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,IAAI;IAIP;;;OAGG;IACH,YAAY,IAAI,OAAO;IAIvB;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,YAAY,CACV,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACnC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CA4B3B"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { RuntimeError } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Accumulates ContextProvider contributions during the AOT boot initialization
|
|
4
|
+
* multi-pass loop and enforces RBAC visibility rules.
|
|
5
|
+
*
|
|
6
|
+
* Lifecycle:
|
|
7
|
+
* 1. A provider resource is created + init()'d → kernel calls register().
|
|
8
|
+
* 2. Before a consumer resource is created → kernel calls buildContext() to
|
|
9
|
+
* obtain a per-consumer CEL evaluation context.
|
|
10
|
+
* 3. buildContext() enforces grants and scans the raw manifest for unauthorized
|
|
11
|
+
* references, throwing ERR_VISIBILITY_DENIED on violations.
|
|
12
|
+
*/
|
|
13
|
+
export class BootContextRegistry {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.providers = [];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Register a new context provider after its init() has completed.
|
|
19
|
+
* Called by the kernel for every resource instance that passes isContextProvider().
|
|
20
|
+
*/
|
|
21
|
+
register(kind, name, module, grants, context) {
|
|
22
|
+
this.providers.push({ kind, name, module, grants, context });
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Returns true if at least one provider has been registered.
|
|
26
|
+
* Used by the kernel to skip context resolution when there are no providers yet.
|
|
27
|
+
*/
|
|
28
|
+
hasProviders() {
|
|
29
|
+
return this.providers.length > 0;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Build a CEL evaluation context for a specific consumer resource, enforcing
|
|
33
|
+
* RBAC grants.
|
|
34
|
+
*
|
|
35
|
+
* For each registered provider:
|
|
36
|
+
* - `grants === undefined` → unrestricted, always included.
|
|
37
|
+
* - `grants` defined and consumer key in grants → included.
|
|
38
|
+
* - `grants` defined and consumer key NOT in grants:
|
|
39
|
+
* - Scan the raw manifest JSON for `${{ ... }}` expressions that reference
|
|
40
|
+
* the provider's namespace prefix (`"${kind}.${name}."`).
|
|
41
|
+
* - If a reference is found → throw ERR_VISIBILITY_DENIED immediately.
|
|
42
|
+
* - If no reference → silently exclude the provider from the context.
|
|
43
|
+
*
|
|
44
|
+
* CEL context structure mirrors the kind hierarchy:
|
|
45
|
+
* kind="Config", name="database" → { Config: { database: { host, port } } }
|
|
46
|
+
* kind="MyApp.Secrets", name="vault" → { MyApp: { Secrets: { vault: { ... } } } }
|
|
47
|
+
*
|
|
48
|
+
* @param consumerKind - kind of the resource being initialized (e.g. "MyApp.Api.Server")
|
|
49
|
+
* @param consumerName - name of the resource being initialized (e.g. "api")
|
|
50
|
+
* @param rawManifest - the unresolved manifest object (used for namespace reference scan)
|
|
51
|
+
*/
|
|
52
|
+
buildContext(consumerKind, consumerName, rawManifest) {
|
|
53
|
+
const consumerKey = `${consumerKind}/${consumerName}`;
|
|
54
|
+
const celContext = {};
|
|
55
|
+
const manifestJson = JSON.stringify(rawManifest);
|
|
56
|
+
for (const provider of this.providers) {
|
|
57
|
+
const isGranted = provider.grants === undefined || provider.grants.includes(consumerKey);
|
|
58
|
+
if (!isGranted) {
|
|
59
|
+
const namespacePrefix = buildProviderNamespacePrefix(provider.kind, provider.name);
|
|
60
|
+
if (manifestReferencesNamespace(manifestJson, namespacePrefix)) {
|
|
61
|
+
throw new RuntimeError('ERR_VISIBILITY_DENIED', `Resource "${consumerKind}/${consumerName}" references context from ` +
|
|
62
|
+
`provider "${provider.kind}/${provider.name}" but is not listed in its grants. ` +
|
|
63
|
+
`Add "${consumerKey}" to the provider's grants field to allow access.`);
|
|
64
|
+
}
|
|
65
|
+
// Not referenced and not granted — silently exclude
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
mergeProviderIntoContext(celContext, provider.kind, provider.name, provider.context);
|
|
69
|
+
}
|
|
70
|
+
return celContext;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Build the namespace prefix string that appears inside a `${{ }}` expression
|
|
75
|
+
* when a consumer references this provider.
|
|
76
|
+
*
|
|
77
|
+
* The trailing dot ensures we match the start of a property access without
|
|
78
|
+
* false-matching a shared prefix substring:
|
|
79
|
+
* kind="Config", name="database" → "Config.database."
|
|
80
|
+
* kind="MyApp.Secrets", name="vault" → "MyApp.Secrets.vault."
|
|
81
|
+
*/
|
|
82
|
+
function buildProviderNamespacePrefix(kind, name) {
|
|
83
|
+
return `${kind}.${name}.`;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Scan serialized manifest JSON for any `${{ expression }}` block that contains
|
|
87
|
+
* the provider's namespace prefix.
|
|
88
|
+
*
|
|
89
|
+
* Using JSON.stringify() as the scan target covers all nested fields uniformly.
|
|
90
|
+
* The approach cannot produce false positives from field names or non-template
|
|
91
|
+
* values because `${{` is not valid JSON syntax outside a string value.
|
|
92
|
+
*/
|
|
93
|
+
function manifestReferencesNamespace(manifestJson, namespacePrefix) {
|
|
94
|
+
let searchFrom = 0;
|
|
95
|
+
while (true) {
|
|
96
|
+
const start = manifestJson.indexOf('${{', searchFrom);
|
|
97
|
+
if (start === -1)
|
|
98
|
+
break;
|
|
99
|
+
const end = manifestJson.indexOf('}}', start + 3);
|
|
100
|
+
if (end === -1)
|
|
101
|
+
break;
|
|
102
|
+
const expression = manifestJson.slice(start + 3, end);
|
|
103
|
+
if (expression.includes(namespacePrefix)) {
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
searchFrom = end + 2;
|
|
107
|
+
}
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Place provider.context into the CEL context object under the path
|
|
112
|
+
* defined by the provider's kind segments and name.
|
|
113
|
+
*
|
|
114
|
+
* kind="Config", name="database":
|
|
115
|
+
* context.Config = { database: { host, port } }
|
|
116
|
+
*
|
|
117
|
+
* kind="MyApp.Api", name="server":
|
|
118
|
+
* context.MyApp = { Api: { server: { ... } } }
|
|
119
|
+
*/
|
|
120
|
+
function mergeProviderIntoContext(celContext, kind, name, providerData) {
|
|
121
|
+
const kindSegments = kind.split('.');
|
|
122
|
+
let cursor = celContext;
|
|
123
|
+
for (const segment of kindSegments) {
|
|
124
|
+
if (typeof cursor[segment] !== 'object' || cursor[segment] === null) {
|
|
125
|
+
cursor[segment] = {};
|
|
126
|
+
}
|
|
127
|
+
cursor = cursor[segment];
|
|
128
|
+
}
|
|
129
|
+
cursor[name] = providerData;
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=boot-context-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boot-context-registry.js","sourceRoot":"","sources":["../src/boot-context-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAgB1C;;;;;;;;;;GAUG;AACH,MAAM,OAAO,mBAAmB;IAAhC;QACU,cAAS,GAAoB,EAAE,CAAC;IA6E1C,CAAC;IA3EC;;;OAGG;IACH,QAAQ,CACN,IAAY,EACZ,IAAY,EACZ,MAAc,EACd,MAA4B,EAC5B,OAAgC;QAEhC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM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I,CAAC,GAAG,YAAY,CAAC;AAC9B,CAAC"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
const fs = __importStar(require("fs/promises"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const kernel_1 = require("./kernel");
|
|
40
|
+
async function main() {
|
|
41
|
+
const args = process.argv.slice(2);
|
|
42
|
+
const verbose = args.includes('--verbose');
|
|
43
|
+
const debug = args.includes('--debug');
|
|
44
|
+
const snapshotOnExit = args.includes('--snapshot-on-exit');
|
|
45
|
+
const filteredArgs = args.filter((arg) => arg !== '--verbose' && arg !== '--debug' && arg !== '--snapshot-on-exit');
|
|
46
|
+
if (filteredArgs.length === 0) {
|
|
47
|
+
console.error('Usage: digly [--verbose] [--debug] [--snapshot-on-exit] <runtime.yaml|directory>');
|
|
48
|
+
console.error('Example: digly --verbose --debug ./runtime.yaml');
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
const inputPath = path.resolve(filteredArgs[0]);
|
|
52
|
+
let inputStat;
|
|
53
|
+
try {
|
|
54
|
+
inputStat = await fs.stat(inputPath);
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
58
|
+
console.error(`Error reading path: ${inputPath}: ${message}`);
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
const isDirectory = inputStat.isDirectory();
|
|
62
|
+
const log = createLogger(verbose);
|
|
63
|
+
// log.info(`Digly Runtime v1.0`);
|
|
64
|
+
// log.info(`Loading from: ${inputPath}`);
|
|
65
|
+
try {
|
|
66
|
+
const kernel = new kernel_1.Kernel();
|
|
67
|
+
if (verbose) {
|
|
68
|
+
kernel.on('*', (event) => {
|
|
69
|
+
log.info(`${event.name}: ${JSON.stringify(event.payload)}`);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
// Enable event streaming if debug flag is set
|
|
73
|
+
if (debug) {
|
|
74
|
+
const debugDir = path.join(process.cwd(), '.digly-debug');
|
|
75
|
+
const eventStreamPath = path.join(debugDir, 'events.jsonl');
|
|
76
|
+
await kernel.enableEventStream(eventStreamPath);
|
|
77
|
+
log.info(`Event stream enabled: ${eventStreamPath}`);
|
|
78
|
+
}
|
|
79
|
+
// Load from manifest or directory
|
|
80
|
+
if (isDirectory) {
|
|
81
|
+
await kernel.loadDirectory(inputPath);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
await kernel.loadFromConfig(inputPath);
|
|
85
|
+
}
|
|
86
|
+
await kernel.start();
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
console.error('Error loading runtime:', error instanceof Error ? error.stack : String(error));
|
|
90
|
+
process.exit(1);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function createLogger(verbose) {
|
|
94
|
+
const useColor = process.stdout.isTTY;
|
|
95
|
+
const wrap = (code, text) => useColor ? `\x1b[${code}m${text}\x1b[0m` : text;
|
|
96
|
+
return {
|
|
97
|
+
info: (...args) => console.log(...args),
|
|
98
|
+
ok: (text) => wrap('32', text),
|
|
99
|
+
warn: (text) => wrap('33', text),
|
|
100
|
+
error: (text) => wrap('31', text),
|
|
101
|
+
dim: (text) => wrap('2', text),
|
|
102
|
+
verbose,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
main().catch((error) => {
|
|
106
|
+
console.error('Fatal error:', error);
|
|
107
|
+
process.exit(1);
|
|
108
|
+
});
|
|
109
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,gDAAkC;AAClC,2CAA6B;AAC7B,qCAAkC;AAElC,KAAK,UAAU,IAAI;IACjB,MAAM,I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,CAAC,OAAgB;IACpC,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;IACtC,MAAM,IAAI,GAAG,CAAC,IAAY,EAAE,IAAY,EAAE,EAAE,CAC1C,QAAQ,CAAC,CAAC,CAAC,QAAQ,IAAI,IAAI,IAAI,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;IAClD,OAAO;QACL,IAAI,EAAE,CAAC,GAAG,IAAW,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;QAC9C,EAAE,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC;QACtC,IAAI,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC;QACxC,KAAK,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC;QACzC,GAAG,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC;QACtC,OAAO;KACR,CAAC;AACJ,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ControllerInstance } from "./types.js";
|
|
2
|
+
export declare class ControllerLoader {
|
|
3
|
+
/**
|
|
4
|
+
* Load controller instance from URI in format:
|
|
5
|
+
*
|
|
6
|
+
* <runtime>:<registry>:<path>@<version-spec>
|
|
7
|
+
*/
|
|
8
|
+
load(purlCandidates: string[], baseUri: string): Promise<ControllerInstance>;
|
|
9
|
+
private ensureNpmPackageInstalled;
|
|
10
|
+
private getPackageName;
|
|
11
|
+
private getInstalledPackageRoot;
|
|
12
|
+
private getLocalPackageName;
|
|
13
|
+
private resolvePackageEntry;
|
|
14
|
+
private resolvePackageExportTarget;
|
|
15
|
+
private resolveExportTargetValue;
|
|
16
|
+
/**
|
|
17
|
+
* For Node.js, resolve .ts paths to their compiled .js equivalents in dist/.
|
|
18
|
+
* Bun can load .ts directly, so it returns the path unchanged.
|
|
19
|
+
*/
|
|
20
|
+
private resolveForRuntime;
|
|
21
|
+
private findInNodeModules;
|
|
22
|
+
private pathExists;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=controller-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller-loader.d.ts","sourceRoot":"","sources":["../src/controller-loader.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,kBAAkB,EAAgB,MAAM,YAAY,CAAC;AAO9D,qBAAa,gBAAgB;IAC3B;;;;OAIG;IACG,IAAI,CAAC,cAAc,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;YAqDpE,yBAAyB;IAmCvC,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,uBAAuB;YAKjB,mBAAmB;YAanB,mBAAmB;IAuEjC,OAAO,CAAC,0BAA0B;IAUlC,OAAO,CAAC,wBAAwB;IA8BhC;;;OAGG;YACW,iBAAiB;YAqBjB,iBAAiB;YAejB,UAAU;CAQzB"}
|