@astrale-os/sdk 0.5.0-beta.99 → 0.6.0-beta.0

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 (270) hide show
  1. package/README.md +165 -2
  2. package/dist/application/action/action.d.ts +7 -4
  3. package/dist/application/action/authoring.d.ts +2 -1
  4. package/dist/application/action/context.d.ts +18 -13
  5. package/dist/application/action/define.d.ts +5 -1
  6. package/dist/application/action/define.js +6 -1
  7. package/dist/application/action/index.d.ts +2 -1
  8. package/dist/application/dependency/index.d.ts +1 -0
  9. package/dist/application/dependency/invoker.d.ts +26 -0
  10. package/dist/application/error/error.d.ts +23 -0
  11. package/dist/application/error/error.js +87 -0
  12. package/dist/application/error/index.d.ts +2 -0
  13. package/dist/application/error/index.js +1 -0
  14. package/dist/application/index.d.ts +2 -2
  15. package/dist/application/integration/authentication.d.ts +10 -0
  16. package/dist/application/integration/authentication.typecheck.js +18 -0
  17. package/dist/application/integration/client.d.ts +2 -0
  18. package/dist/application/integration/client.js +19 -2
  19. package/dist/application/integration/index.d.ts +1 -0
  20. package/dist/application/integration/operation.d.ts +3 -0
  21. package/dist/application/mutation/authoring/builder.js +2 -2
  22. package/dist/application/mutation/authoring/endpoint.d.ts +3 -3
  23. package/dist/application/mutation/authoring/endpoint.js +9 -0
  24. package/dist/application/mutation/failure.js +13 -7
  25. package/dist/application/mutation/index.d.ts +1 -0
  26. package/dist/application/requirements/{profiles.d.ts → core.d.ts} +5 -3
  27. package/dist/application/requirements/{profiles.js → core.js} +6 -6
  28. package/dist/application/requirements/index.d.ts +4 -4
  29. package/dist/application/requirements/index.js +5 -5
  30. package/dist/application/requirements/requirement.d.ts +3 -2
  31. package/dist/application/runtime/authoring.d.ts +1 -0
  32. package/dist/application/runtime/callables.js +2 -2
  33. package/dist/application/runtime/declarations.d.ts +43 -0
  34. package/dist/application/runtime/define.d.ts +2 -1
  35. package/dist/application/view/index.d.ts +1 -1
  36. package/dist/application/view/route.d.ts +4 -0
  37. package/dist/application/view/route.js +5 -1
  38. package/dist/application/workflow/authoring.d.ts +1 -0
  39. package/dist/application/workflow/context.d.ts +2 -1
  40. package/dist/application/workflow/define.d.ts +5 -1
  41. package/dist/application/workflow/define.js +6 -1
  42. package/dist/application/workflow/index.d.ts +1 -0
  43. package/dist/application/workflow/runner/runner.d.ts +3 -2
  44. package/dist/application/workflow/workflow.d.ts +4 -3
  45. package/dist/deployment/adapter/adapter.d.ts +12 -7
  46. package/dist/deployment/adapter/define.d.ts +5 -2
  47. package/dist/deployment/adapter/define.js +15 -17
  48. package/dist/deployment/adapter/deploy/context.d.ts +6 -0
  49. package/dist/deployment/adapter/deploy/result.d.ts +2 -0
  50. package/dist/deployment/adapter/index.d.ts +2 -3
  51. package/dist/deployment/adapter/index.js +1 -1
  52. package/dist/deployment/adapter/prepare/context.d.ts +13 -5
  53. package/dist/deployment/authoring.d.ts +1 -1
  54. package/dist/deployment/build/compile.js +21 -19
  55. package/dist/deployment/build/frontend/compilation.d.ts +2 -1
  56. package/dist/deployment/build/frontend/compilation.js +1 -0
  57. package/dist/deployment/build/material.js +5 -5
  58. package/dist/deployment/deploy.d.ts +10 -4
  59. package/dist/deployment/deploy.js +5 -5
  60. package/dist/deployment/deployment.d.ts +8 -5
  61. package/dist/deployment/deployment.js +10 -1
  62. package/dist/deployment/index.d.ts +5 -4
  63. package/dist/deployment/index.js +3 -2
  64. package/dist/deployment/release/addressing.d.ts +6 -2
  65. package/dist/deployment/release/addressing.js +9 -4
  66. package/dist/deployment/release/publication/callables.js +1 -1
  67. package/dist/deployment/release/publication/index.d.ts +1 -1
  68. package/dist/deployment/release/publication/index.js +1 -1
  69. package/dist/deployment/release/publication/routes.js +1 -1
  70. package/dist/deployment/release/publication/seal.d.ts +0 -1
  71. package/dist/deployment/release/publication/seal.js +4 -5
  72. package/dist/deployment/release/publication/views.js +2 -1
  73. package/dist/deployment/verify/preflight/artifact.js +1 -1
  74. package/dist/deployment/verify/readiness/deployment.js +7 -3
  75. package/dist/deployment/verify/readiness/identity.js +1 -1
  76. package/dist/deployment/verify/readiness/publication.js +2 -2
  77. package/dist/execution/identity/authentication.js +0 -1
  78. package/dist/execution/identity/exchange.d.ts +1 -0
  79. package/dist/execution/identity/exchange.js +1 -1
  80. package/dist/execution/identity/jwks.js +1 -1
  81. package/dist/execution/invocation/admission/authentication.d.ts +6 -3
  82. package/dist/execution/invocation/admission/authentication.js +16 -6
  83. package/dist/execution/invocation/admission/authority.d.ts +2 -2
  84. package/dist/execution/invocation/dependency/bind.d.ts +5 -0
  85. package/dist/execution/invocation/dependency/bind.js +68 -0
  86. package/dist/execution/invocation/dependency/index.d.ts +1 -0
  87. package/dist/execution/invocation/dependency/index.js +1 -0
  88. package/dist/execution/invocation/dispatch/action.js +19 -2
  89. package/dist/execution/invocation/dispatch/context.d.ts +4 -4
  90. package/dist/execution/invocation/dispatch/context.js +29 -9
  91. package/dist/execution/invocation/dispatch/workflow.js +17 -4
  92. package/dist/execution/invocation/integration/authentication.d.ts +5 -0
  93. package/dist/execution/invocation/integration/authentication.js +53 -0
  94. package/dist/execution/invocation/integration/call.d.ts +7 -1
  95. package/dist/execution/invocation/integration/call.js +8 -3
  96. package/dist/execution/invocation/integration/clients.d.ts +2 -2
  97. package/dist/execution/invocation/integration/clients.js +2 -2
  98. package/dist/execution/invocation/lifecycle/active.js +30 -5
  99. package/dist/execution/invocation/result/errors.d.ts +1 -0
  100. package/dist/execution/invocation/result/errors.js +15 -10
  101. package/dist/execution/service/create.js +3 -1
  102. package/dist/execution/service/service.d.ts +1 -1
  103. package/dist/index.d.ts +3 -1
  104. package/dist/index.js +1 -0
  105. package/dist/platform/auth/index.d.ts +1 -1
  106. package/dist/platform/auth/index.js +0 -1
  107. package/dist/platform/graph/alias.d.ts +6 -0
  108. package/dist/platform/graph/alias.js +6 -0
  109. package/dist/platform/graph/document/index.d.ts +2 -1
  110. package/dist/platform/graph/document/index.js +2 -1
  111. package/dist/platform/graph/index.d.ts +2 -1
  112. package/dist/platform/graph/index.js +2 -1
  113. package/dist/platform/schema/class-authoring.d.ts +37 -0
  114. package/dist/platform/schema/class-authoring.js +20 -0
  115. package/dist/platform/schema/class-icon.d.ts +15 -0
  116. package/dist/platform/schema/class-icon.js +46 -0
  117. package/dist/platform/schema/error.d.ts +11 -0
  118. package/dist/platform/schema/error.js +34 -0
  119. package/dist/platform/schema/errors/index.d.ts +3 -0
  120. package/dist/platform/schema/errors/index.js +2 -0
  121. package/dist/platform/schema/icons/index.d.ts +2 -0
  122. package/dist/platform/schema/icons/index.js +2 -0
  123. package/dist/platform/schema/index.d.ts +20 -13
  124. package/dist/platform/schema/index.js +9 -4
  125. package/dist/platform/schema/kernel.d.ts +22 -0
  126. package/dist/platform/schema/kernel.js +5 -0
  127. package/dist/platform/schema/node-id.d.ts +3 -0
  128. package/dist/platform/schema/node-id.js +6 -0
  129. package/dist/platform/schema/property.d.ts +12 -0
  130. package/dist/platform/schema/property.js +3 -0
  131. package/dist/platform/schema/schema-authoring.d.ts +48 -0
  132. package/dist/platform/schema/schema-authoring.js +3 -0
  133. package/dist/platform/schema/state-property.d.ts +11 -0
  134. package/dist/platform/schema/state-property.js +3 -0
  135. package/dist/project/admit.d.ts +4 -0
  136. package/dist/project/admit.js +22 -0
  137. package/dist/project/define.d.ts +12 -0
  138. package/dist/project/define.js +106 -0
  139. package/dist/project/index.d.ts +4 -0
  140. package/dist/project/index.js +2 -0
  141. package/dist/project/project.d.ts +24 -0
  142. package/dist/project/project.js +1 -0
  143. package/dist/testing/dataset/admission.d.ts +13 -0
  144. package/dist/testing/dataset/admission.js +107 -0
  145. package/dist/testing/dataset/builder.d.ts +42 -0
  146. package/dist/testing/dataset/builder.js +127 -0
  147. package/dist/testing/dataset/codec.d.ts +6 -0
  148. package/dist/testing/dataset/codec.js +113 -0
  149. package/dist/testing/dataset/dataset.d.ts +58 -0
  150. package/dist/testing/dataset/dataset.js +2 -0
  151. package/dist/testing/dataset/define.d.ts +33 -0
  152. package/dist/testing/dataset/define.js +105 -0
  153. package/dist/testing/dataset/index.d.ts +8 -0
  154. package/dist/testing/dataset/index.js +4 -0
  155. package/dist/testing/dataset/references.d.ts +14 -0
  156. package/dist/testing/dataset/references.js +56 -0
  157. package/dist/testing/index.d.ts +9 -0
  158. package/dist/testing/index.js +5 -0
  159. package/dist/testing/load.d.ts +14 -0
  160. package/dist/testing/load.js +44 -0
  161. package/dist/testing/reference.d.ts +11 -0
  162. package/dist/testing/reference.js +19 -0
  163. package/dist/testing/tests.d.ts +12 -0
  164. package/dist/testing/tests.js +31 -0
  165. package/dist/tooling/cli/arguments.d.ts +7 -4
  166. package/dist/tooling/cli/arguments.js +82 -107
  167. package/dist/tooling/cli/astrale/authority.d.ts +5 -0
  168. package/dist/tooling/cli/astrale/authority.js +11 -0
  169. package/dist/tooling/cli/astrale/executable.d.ts +2 -0
  170. package/dist/tooling/cli/astrale/executable.js +47 -0
  171. package/dist/tooling/cli/astrale/failure.d.ts +6 -0
  172. package/dist/tooling/cli/astrale/failure.js +48 -0
  173. package/dist/tooling/cli/astrale/instance.d.ts +11 -0
  174. package/dist/tooling/cli/astrale/instance.js +52 -0
  175. package/dist/tooling/cli/astrale/process.d.ts +13 -0
  176. package/dist/tooling/cli/astrale/process.js +94 -0
  177. package/dist/tooling/cli/astrale/version.d.ts +18 -0
  178. package/dist/tooling/cli/astrale/version.js +55 -0
  179. package/dist/tooling/cli/bun.js +1 -1
  180. package/dist/tooling/cli/credential.d.ts +2 -0
  181. package/dist/tooling/cli/credential.js +57 -0
  182. package/dist/tooling/cli/development/candidate.d.ts +25 -0
  183. package/dist/tooling/cli/development/candidate.js +176 -0
  184. package/dist/tooling/cli/development/deployment.d.ts +16 -0
  185. package/dist/tooling/cli/development/deployment.js +39 -0
  186. package/dist/tooling/cli/development/develop.d.ts +4 -3
  187. package/dist/tooling/cli/development/develop.js +125 -289
  188. package/dist/tooling/cli/development/lease.d.ts +18 -0
  189. package/dist/tooling/cli/development/lease.js +163 -0
  190. package/dist/tooling/cli/development/lifecycle.js +4 -0
  191. package/dist/tooling/cli/development/project-imports.d.ts +22 -0
  192. package/dist/tooling/cli/development/project-imports.js +39 -0
  193. package/dist/tooling/cli/development/project-lock.d.ts +3 -4
  194. package/dist/tooling/cli/development/project-lock.js +14 -166
  195. package/dist/tooling/cli/development/release-evidence.d.ts +4 -0
  196. package/dist/tooling/cli/development/release-evidence.js +10 -0
  197. package/dist/tooling/cli/development/report.d.ts +6 -0
  198. package/dist/tooling/cli/development/report.js +14 -0
  199. package/dist/tooling/cli/development/source-watch.js +53 -5
  200. package/dist/tooling/cli/development/sources.d.ts +7 -0
  201. package/dist/tooling/cli/development/sources.js +48 -0
  202. package/dist/tooling/cli/development/target-lock.d.ts +16 -0
  203. package/dist/tooling/cli/development/target-lock.js +68 -0
  204. package/dist/tooling/cli/development/view.d.ts +28 -0
  205. package/dist/tooling/cli/development/view.js +151 -0
  206. package/dist/tooling/cli/environment-release.d.ts +21 -0
  207. package/dist/tooling/cli/environment-release.js +46 -0
  208. package/dist/tooling/cli/evidence.d.ts +11 -0
  209. package/dist/tooling/cli/evidence.js +53 -0
  210. package/dist/tooling/cli/help.js +78 -34
  211. package/dist/tooling/cli/index.d.ts +1 -1
  212. package/dist/tooling/cli/index.js +1 -1
  213. package/dist/tooling/cli/installation/index.d.ts +2 -0
  214. package/dist/tooling/cli/installation/index.js +1 -0
  215. package/dist/tooling/cli/installation/observation.d.ts +10 -0
  216. package/dist/tooling/cli/installation/observation.js +44 -0
  217. package/dist/tooling/cli/installation/reconcile.d.ts +32 -0
  218. package/dist/tooling/cli/installation/reconcile.js +122 -0
  219. package/dist/tooling/cli/orchestrate.js +84 -44
  220. package/dist/tooling/cli/project.d.ts +17 -0
  221. package/dist/tooling/cli/project.js +18 -0
  222. package/dist/tooling/cli/test.d.ts +12 -0
  223. package/dist/tooling/cli/test.js +47 -0
  224. package/dist/tooling/cli/upgrade/index.d.ts +6 -0
  225. package/dist/tooling/cli/upgrade/index.js +115 -0
  226. package/dist/tooling/cli/upgrade/manifest.d.ts +18 -0
  227. package/dist/tooling/cli/upgrade/manifest.js +77 -0
  228. package/dist/tooling/cli/upgrade/process.d.ts +2 -0
  229. package/dist/tooling/cli/upgrade/process.js +57 -0
  230. package/dist/tooling/linter/adapters/typescript/imports.js +2 -0
  231. package/dist/tooling/linter/adapters/typescript/index.d.ts +1 -0
  232. package/dist/tooling/linter/adapters/typescript/index.js +1 -0
  233. package/dist/tooling/linter/adapters/typescript/query-collection-type.js +4 -51
  234. package/dist/tooling/linter/adapters/typescript/type-analysis.d.ts +9 -0
  235. package/dist/tooling/linter/adapters/typescript/type-analysis.js +55 -0
  236. package/dist/tooling/linter/implementations/source/callable-requirements.d.ts +28 -0
  237. package/dist/tooling/linter/implementations/source/callable-requirements.js +234 -0
  238. package/dist/tooling/linter/implementations/source/dependencies.d.ts +2 -0
  239. package/dist/tooling/linter/implementations/source/dependencies.js +219 -0
  240. package/dist/tooling/linter/implementations/source/global.js +52 -2
  241. package/dist/tooling/linter/implementations/source/mutations.js +520 -38
  242. package/dist/tooling/linter/implementations/source/providers.js +19 -164
  243. package/dist/tooling/linter/implementations/source/schema.js +454 -2
  244. package/dist/tooling/linter/implementations/source/verifiers.js +2 -0
  245. package/dist/tooling/linter/implementations/source/workflows.js +8 -35
  246. package/dist/tooling/linter/policy/generated.js +2 -2
  247. package/dist/tooling/linter/requirements/registry.js +9 -3
  248. package/dist/tooling/packaging/declarations/normalize.js +3 -38
  249. package/dist/tooling/packaging/declarations/paths.d.ts +5 -0
  250. package/dist/tooling/packaging/declarations/paths.js +38 -0
  251. package/dist/tooling/packaging/finalize.d.ts +13 -0
  252. package/dist/tooling/packaging/finalize.js +62 -0
  253. package/dist/tooling/packaging/index.d.ts +2 -0
  254. package/dist/tooling/packaging/index.js +1 -0
  255. package/dist/tooling/packaging/javascript.d.ts +3 -0
  256. package/dist/tooling/packaging/javascript.js +45 -2
  257. package/dist/tooling/packaging/packaging.d.ts +2 -5
  258. package/dist/tooling/packaging/packaging.js +6 -30
  259. package/package.json +42 -12
  260. package/CHANGELOG.md +0 -1506
  261. package/dist/deployment/adapter/development/context.d.ts +0 -18
  262. package/dist/deployment/adapter/development/index.d.ts +0 -4
  263. package/dist/deployment/adapter/development/input.d.ts +0 -6
  264. package/dist/deployment/adapter/development/placement.d.ts +0 -15
  265. package/dist/deployment/adapter/development/session.d.ts +0 -9
  266. /package/dist/{deployment/adapter/development → application/dependency}/index.js +0 -0
  267. /package/dist/{deployment/adapter/development/context.js → application/dependency/invoker.js} +0 -0
  268. /package/dist/{deployment/adapter/development/input.js → application/integration/authentication.js} +0 -0
  269. /package/dist/{deployment/adapter/development/placement.js → application/integration/authentication.typecheck.d.ts} +0 -0
  270. /package/dist/{deployment/adapter/development/session.js → application/runtime/declarations.js} +0 -0
@@ -0,0 +1,68 @@
1
+ import { Key } from '@astrale-os/kernel-dsl/v1/addressing';
2
+ import { reference } from '../../../platform/client/session/index.js';
3
+ import { NodeId } from '../../../platform/graph/node/index.js';
4
+ import { Path } from '../../../platform/graph/path/index.js';
5
+ /** Bind each explicit authority to its admitted session; metadata remains inert. */
6
+ export function bindDependencies(domain, sessions) {
7
+ const dependencies = Object.create(null);
8
+ for (const [alias, dependency] of Object.entries(domain.dependencies)) {
9
+ if (dependency.origin === 'kernel.astrale.ai')
10
+ continue;
11
+ dependencies[alias] = Object.freeze({
12
+ caller: bindDependency(dependency, sessions.caller),
13
+ self: bindDependency(dependency, sessions.self),
14
+ union: bindDependency(dependency, sessions.union),
15
+ });
16
+ }
17
+ return Object.freeze(dependencies);
18
+ }
19
+ function bindDependency(dependency, session) {
20
+ const invoke = session.invoke.bind(session);
21
+ return Object.freeze({
22
+ async invoke(select, ...args) {
23
+ if (typeof select !== 'function')
24
+ invalid();
25
+ const selected = select(dependency);
26
+ if (selected === null ||
27
+ typeof selected !== 'object' ||
28
+ !('key' in selected) ||
29
+ typeof selected.key !== 'string')
30
+ invalid();
31
+ const callable = dependency.callable(selected.key);
32
+ if (callable !== selected || Key.origin(callable.key) !== dependency.origin)
33
+ invalid();
34
+ if ('owner' in callable && (!callable.executable || !ownMethod(dependency, callable)))
35
+ invalid();
36
+ if ('owner' in callable && !callable.static) {
37
+ if (args.length < 2 || args.length > 3 || typeof args[0] !== 'string')
38
+ invalid();
39
+ const instance = Path.id(NodeId(args[0]));
40
+ return invoke(reference(dependency, callable)(instance), args[1], options(args[2]));
41
+ }
42
+ if (args.length < 1 || args.length > 2)
43
+ invalid();
44
+ return invoke(reference(dependency, callable), args[0], options(args[1]));
45
+ },
46
+ });
47
+ }
48
+ function ownMethod(domain, callable) {
49
+ const owner = Object.values(domain.classes).find((value) => value === callable.owner);
50
+ if (owner === undefined)
51
+ return false;
52
+ const methods = callable.static ? owner.self.static.methods : owner.self.methods;
53
+ return methods.get(callable.key) === callable;
54
+ }
55
+ function options(value) {
56
+ if (value === undefined)
57
+ return undefined;
58
+ if (value === null ||
59
+ typeof value !== 'object' ||
60
+ Array.isArray(value) ||
61
+ Reflect.ownKeys(value).some((key) => key !== 'timeoutMs' && key !== 'idempotencyKey'))
62
+ invalid();
63
+ // Canonical ClientSession admits option values and clamps them to the parent lifetime.
64
+ return value;
65
+ }
66
+ function invalid() {
67
+ throw new TypeError('Dependency invocation requires one owned executable callable, its input, and valid instance/options.');
68
+ }
@@ -0,0 +1 @@
1
+ export { bindDependencies } from './bind.js';
@@ -0,0 +1 @@
1
+ export { bindDependencies } from './bind.js';
@@ -1,3 +1,20 @@
1
- export function action(selected, context) {
2
- return selected.definition.run(context);
1
+ import { declaredErrorFactory, declaredErrorOf } from '../../../application/error/index.js';
2
+ import { protocolError } from '../result/index.js';
3
+ export async function action(selected, context) {
4
+ const complete = Object.freeze({
5
+ ...context,
6
+ error: declaredErrorFactory(selected.definition),
7
+ });
8
+ try {
9
+ return await selected.definition.run(complete);
10
+ }
11
+ catch (cause) {
12
+ const declared = declaredErrorOf(cause, selected.definition);
13
+ if (declared === undefined)
14
+ throw cause;
15
+ throw protocolError(declared.family, declared.message, {
16
+ code: declared.code,
17
+ details: declared.details,
18
+ });
19
+ }
3
20
  }
@@ -1,8 +1,8 @@
1
1
  import type { HandlerRequest } from '@astrale-os/kernel-server';
2
- import type { ActionExecution, Caller, DomainGraphExecutors } from '../../../application/action/index.js';
2
+ import type { ActionExecution, Caller, DomainGraphExecutors, DomainKernelSessions } from '../../../application/action/index.js';
3
+ import type { HandlerDependencies } from '../../../application/dependency/index.js';
3
4
  import type { MutationExecutor } from '../../../application/mutation/index.js';
4
5
  import type { QueryExecutor } from '../../../application/query/index.js';
5
- import type { BoundClientSession } from '../../../platform/client/session/index.js';
6
6
  import type { NodeId } from '../../../platform/graph/node/index.js';
7
7
  import type { Domain } from '../../../platform/schema/index.js';
8
8
  import type { InitializedRuntime } from '../../runtime/index.js';
@@ -11,8 +11,8 @@ export interface DispatchContext {
11
11
  readonly domain: Domain;
12
12
  readonly input: unknown;
13
13
  readonly caller: Caller;
14
- readonly client: BoundClientSession | null;
15
- readonly kernel: Readonly<Record<'caller' | 'self' | 'union', BoundClientSession>> | null;
14
+ readonly dependencies: HandlerDependencies<Domain> | null;
15
+ readonly kernel: DomainKernelSessions | null;
16
16
  readonly graph: DomainGraphExecutors | null;
17
17
  readonly query?: QueryExecutor;
18
18
  readonly mutate?: MutationExecutor;
@@ -1,8 +1,9 @@
1
1
  import { bindMutation } from '../../../application/mutation/execution/executor.js';
2
2
  import { bindQuery } from '../../../application/query/execution/executor.js';
3
+ import { bindDependencies } from '../dependency/index.js';
3
4
  import { clients } from '../integration/index.js';
4
5
  export function context(request, runtime, authentication, self) {
5
- const client = authentication.client;
6
+ const graph = authentication.graph === null ? null : bindGraph(authentication.graph, runtime.loaded.domain);
6
7
  const execution = Object.freeze({
7
8
  signal: request.context.execution.signal,
8
9
  deadline: request.context.execution.deadline,
@@ -17,16 +18,33 @@ export function context(request, runtime, authentication, self) {
17
18
  domain: runtime.loaded.domain,
18
19
  input: request.call.input,
19
20
  caller: authentication.caller,
20
- client,
21
- kernel: authentication.graph,
22
- graph: authentication.graph === null ? null : bindGraph(authentication.graph, runtime.loaded.domain),
23
- ...(client === null
21
+ kernel: authentication.graph === null
22
+ ? null
23
+ : Object.freeze({
24
+ ...authentication.graph.self,
25
+ ...authentication.graph,
26
+ }),
27
+ dependencies: authentication.graph === null
28
+ ? null
29
+ : bindDependencies(runtime.loaded.domain, authentication.graph),
30
+ graph,
31
+ ...(graph === null
24
32
  ? {}
25
33
  : {
26
- query: bindQuery(client, runtime.loaded.domain),
27
- mutate: bindMutation(client, runtime.loaded.domain),
34
+ query: graph.self.query,
35
+ mutate: graph.self.mutate,
36
+ }),
37
+ integrations: clients(runtime, request.context, authentication.graph === null
38
+ ? null
39
+ : {
40
+ caller: authentication.graph.caller,
41
+ self: authentication.graph.self,
42
+ ...(authentication.caller.authentication.expiresAt === undefined
43
+ ? {}
44
+ : {
45
+ expiresAt: authentication.caller.authentication.expiresAt,
46
+ }),
28
47
  }),
29
- integrations: clients(runtime, request.context, client),
30
48
  execution,
31
49
  ...(self === undefined ? {} : { self }),
32
50
  });
@@ -36,9 +54,11 @@ function bindGraph(clients, domain) {
36
54
  query: bindQuery(client, domain),
37
55
  mutate: bindMutation(client, domain),
38
56
  });
57
+ const self = bind(clients.self);
39
58
  return Object.freeze({
59
+ ...self,
40
60
  caller: bind(clients.caller),
41
- self: bind(clients.self),
61
+ self,
42
62
  union: bind(clients.union),
43
63
  });
44
64
  }
@@ -1,11 +1,24 @@
1
+ import { declaredErrorFactory, declaredErrorOf } from '../../../application/error/index.js';
1
2
  import { protocolError } from '../result/index.js';
2
- export function workflow(selected, context, runner) {
3
- if (context.caller.kind !== 'authenticated' || context.client === null) {
3
+ export async function workflow(selected, context, runner) {
4
+ if (context.caller.kind !== 'authenticated' || context.kernel === null) {
4
5
  throw protocolError('AUTH_MISSING', 'Workflow authentication is required.');
5
6
  }
6
- return runner.run(selected.definition, {
7
+ const complete = Object.freeze({
7
8
  ...context,
8
9
  caller: context.caller,
9
- client: context.client,
10
+ error: declaredErrorFactory(selected.definition),
10
11
  });
12
+ try {
13
+ return await runner.run(selected.definition, complete);
14
+ }
15
+ catch (cause) {
16
+ const declared = declaredErrorOf(cause, selected.definition);
17
+ if (declared === undefined)
18
+ throw cause;
19
+ throw protocolError(declared.family, declared.message, {
20
+ code: declared.code,
21
+ details: declared.details,
22
+ });
23
+ }
11
24
  }
@@ -0,0 +1,5 @@
1
+ import type { InvocationContext } from '@astrale-os/kernel-server';
2
+ import type { IntegrationAuthentication } from '../../../application/integration/index.js';
3
+ import type { BoundClientSession } from '../../../platform/client/session/index.js';
4
+ /** Capture only self mint, bounded by this invocation's verified credential horizon. */
5
+ export declare function bindIntegrationAuthentication(context: InvocationContext, self: BoundClientSession, expiresAt?: number): IntegrationAuthentication;
@@ -0,0 +1,53 @@
1
+ import { credential as credentials } from '../../../platform/auth/index.js';
2
+ import { active } from '../lifecycle/index.js';
3
+ import { protocolError } from '../result/index.js';
4
+ // Match the callback resolver's reserve; a child credential cannot outlive its source.
5
+ const TRANSPORT_RESERVE_SECONDS = 5;
6
+ /** Capture only self mint, bounded by this invocation's verified credential horizon. */
7
+ export function bindIntegrationAuthentication(context, self, expiresAt) {
8
+ if (expiresAt !== undefined && !Number.isFinite(expiresAt)) {
9
+ throw new TypeError('Invalid Integration authentication expiry.');
10
+ }
11
+ const mint = self.auth.mint.bind(self.auth);
12
+ return Object.freeze({
13
+ async mint(input) {
14
+ active(context);
15
+ if (input === null || typeof input !== 'object' || Array.isArray(input))
16
+ invalidInput();
17
+ const keys = Reflect.ownKeys(input);
18
+ const { audience, ttlSeconds } = input;
19
+ if (keys.length !== 2 ||
20
+ !keys.every((key) => key === 'audience' || key === 'ttlSeconds') ||
21
+ typeof audience !== 'string' ||
22
+ audience.length === 0 ||
23
+ audience.trim() !== audience ||
24
+ !Number.isInteger(ttlSeconds) ||
25
+ ttlSeconds < 1 ||
26
+ ttlSeconds > 60)
27
+ invalidInput();
28
+ const horizon = Math.min(context.execution.deadline / 1000, expiresAt ?? Infinity);
29
+ const remaining = Math.floor(horizon) - Math.floor(Date.now() / 1000) - TRANSPORT_RESERVE_SECONDS;
30
+ if (remaining < 1) {
31
+ throw protocolError('DEADLINE_EXCEEDED', 'Insufficient lifetime for Integration credential.');
32
+ }
33
+ const credential = await mint({ audience, ttlSeconds: Math.min(ttlSeconds, remaining) }, {
34
+ signal: context.execution.signal,
35
+ timeoutMs: Math.max(1, context.execution.deadline - Date.now()),
36
+ });
37
+ active(context);
38
+ // Inspect only the result of the trusted Kernel call, not a Provider-supplied token.
39
+ // The reserve is an optimization; this absolute check is the lifetime boundary.
40
+ const expiry = credentials.inspect(credential).claims.exp;
41
+ if (typeof expiry !== 'number' ||
42
+ !Number.isSafeInteger(expiry) ||
43
+ expiry <= Math.floor(Date.now() / 1000) ||
44
+ expiry > Math.floor(horizon)) {
45
+ throw protocolError('DEADLINE_EXCEEDED', 'Integration credential exceeds its lifetime.');
46
+ }
47
+ return credential;
48
+ },
49
+ });
50
+ }
51
+ function invalidInput() {
52
+ throw new TypeError('Invalid Integration mint input.');
53
+ }
@@ -1,5 +1,11 @@
1
1
  import type { InvocationContext } from '@astrale-os/kernel-server';
2
2
  import type { IntegrationInvocationOwner } from '../../../application/integration/index.js';
3
3
  import type { BoundClientSession } from '../../../platform/client/session/index.js';
4
+ export interface IntegrationInvocationSessions {
5
+ readonly caller: BoundClientSession;
6
+ readonly self: BoundClientSession;
7
+ /** Verified incoming carrier expiry, in Unix seconds. */
8
+ readonly expiresAt?: number;
9
+ }
4
10
  /** One invocation-owned logical Integration call sequence. */
5
- export declare function calls(context: InvocationContext, client?: BoundClientSession | null): IntegrationInvocationOwner;
11
+ export declare function calls(context: InvocationContext, sessions?: IntegrationInvocationSessions | null): IntegrationInvocationOwner;
@@ -1,8 +1,12 @@
1
1
  import { active } from '../lifecycle/index.js';
2
+ import { bindIntegrationAuthentication } from './authentication.js';
2
3
  /** One invocation-owned logical Integration call sequence. */
3
- export function calls(context, client = null) {
4
- const prefix = context.idempotencyKey ?? context.invocation;
5
- const invoke = client?.invoke.bind(client);
4
+ export function calls(context, sessions = null) {
5
+ const prefix = context.idempotencyKey ?? JSON.stringify([context.invocation.source, context.invocation.id]);
6
+ const invoke = sessions?.caller.invoke.bind(sessions.caller);
7
+ const auth = sessions === null
8
+ ? undefined
9
+ : bindIntegrationAuthentication(context, sessions.self, sessions.expiresAt);
6
10
  let sequence = 0;
7
11
  return Object.freeze({
8
12
  invoke(call) {
@@ -13,6 +17,7 @@ export function calls(context, client = null) {
13
17
  signal: context.execution.signal,
14
18
  deadline: context.execution.deadline,
15
19
  ...(invoke === undefined ? {} : { invoke }),
20
+ ...(auth === undefined ? {} : { auth }),
16
21
  });
17
22
  },
18
23
  });
@@ -1,5 +1,5 @@
1
1
  import type { InvocationContext } from '@astrale-os/kernel-server';
2
2
  import type { IntegrationClients, Integrations } from '../../../application/integration/index.js';
3
- import type { BoundClientSession } from '../../../platform/client/session/index.js';
4
3
  import type { InitializedRuntime } from '../../runtime/index.js';
5
- export declare function clients(runtime: InitializedRuntime, context: InvocationContext, client: BoundClientSession | null): IntegrationClients<Integrations>;
4
+ import type { IntegrationInvocationSessions } from './call.js';
5
+ export declare function clients(runtime: InitializedRuntime, context: InvocationContext, sessions: IntegrationInvocationSessions | null): IntegrationClients<Integrations>;
@@ -1,4 +1,4 @@
1
1
  import { calls } from './call.js';
2
- export function clients(runtime, context, client) {
3
- return runtime.clients(calls(context, client));
2
+ export function clients(runtime, context, sessions) {
3
+ return runtime.clients(calls(context, sessions));
4
4
  }
@@ -9,11 +9,17 @@ export function active(context) {
9
9
  }
10
10
  /** Close authenticated resources after finite results or stream settlement. */
11
11
  export function settle(result, close) {
12
- if (result.kind !== 'stream') {
13
- close();
14
- return result;
12
+ if (result.kind === 'stream') {
13
+ return Object.freeze({ kind: 'stream', stream: settledStream(result.stream, close) });
14
+ }
15
+ if (result.kind === 'binary' && !(result.value.body instanceof Uint8Array)) {
16
+ return Object.freeze({
17
+ kind: 'binary',
18
+ value: Object.freeze({ ...result.value, body: settledIterable(result.value.body, close) }),
19
+ });
15
20
  }
16
- return Object.freeze({ kind: 'stream', stream: settledStream(result.stream, close) });
21
+ close();
22
+ return result;
17
23
  }
18
24
  function settledStream(stream, close) {
19
25
  let settled = false;
@@ -24,6 +30,7 @@ function settledStream(stream, close) {
24
30
  close();
25
31
  };
26
32
  return Object.freeze({
33
+ ...settledIterable(stream, finish),
27
34
  async cancel(reason) {
28
35
  try {
29
36
  await stream.cancel(reason);
@@ -32,8 +39,26 @@ function settledStream(stream, close) {
32
39
  finish();
33
40
  }
34
41
  },
42
+ });
43
+ }
44
+ function settledIterable(stream, close) {
45
+ let settled = false;
46
+ const finish = () => {
47
+ if (settled)
48
+ return;
49
+ settled = true;
50
+ close();
51
+ };
52
+ return Object.freeze({
35
53
  [Symbol.asyncIterator]() {
36
- const iterator = stream[Symbol.asyncIterator]();
54
+ let iterator;
55
+ try {
56
+ iterator = stream[Symbol.asyncIterator]();
57
+ }
58
+ catch (cause) {
59
+ finish();
60
+ throw cause;
61
+ }
37
62
  return Object.freeze({
38
63
  async next() {
39
64
  try {
@@ -3,6 +3,7 @@ import type { ResolvedCallable } from '../../../application/action/index.js';
3
3
  import type { Key } from '../../../platform/schema/index.js';
4
4
  import type { Value } from '../../../platform/value/index.js';
5
5
  export type InvocationErrorCode = Extract<keyof typeof errors.CODES, 'VALIDATION_ERROR' | 'ACCESS_DENIED' | 'NOT_FOUND' | 'CONFLICT' | 'UNSUPPORTED' | 'LIMIT_EXCEEDED' | 'BACKEND_UNAVAILABLE'>;
6
+ /** @deprecated Declare expected failures on defineAction or defineWorkflow instead. */
6
7
  export declare class InvocationError extends Error {
7
8
  readonly code: InvocationErrorCode;
8
9
  readonly name = "InvocationError";
@@ -2,7 +2,10 @@ import * as errors from '@astrale-os/kernel-protocol/errors';
2
2
  import { ClientError, MissError, ProtocolError as ClientProtocolError, ResponseError, SessionError, StaleRouteError, TransportError, } from '../../../platform/client/index.js';
3
3
  const PUBLIC_DIAGNOSTICS = new Set(['VALUE_SCHEMA_INSTANCE_INVALID', 'VS_NUMBER_DOMAIN']);
4
4
  const PUBLIC_ERROR_CODES = new Set(Object.values(errors.CODES));
5
+ const PUBLIC_ERROR_NAMES = new Map(Object.entries(errors.CODES).map(([name, code]) => [code, name]));
5
6
  const MAXIMUM_DIAGNOSTICS = 32;
7
+ const admittedProtocolErrors = new WeakSet();
8
+ /** @deprecated Declare expected failures on defineAction or defineWorkflow instead. */
6
9
  export class InvocationError extends Error {
7
10
  code;
8
11
  name = 'InvocationError';
@@ -25,11 +28,13 @@ export class InvocationDefect extends Error {
25
28
  }
26
29
  }
27
30
  export function protocolError(code, message, data) {
28
- return new errors.ProtocolError({
31
+ const error = new errors.ProtocolError({
29
32
  code: errors.CODES[code],
30
33
  message,
31
34
  ...(data === undefined ? {} : { data }),
32
35
  });
36
+ admittedProtocolErrors.add(error);
37
+ return error;
33
38
  }
34
39
  export function inputError(callable, diagnostics) {
35
40
  if (diagnostics.length === 0 ||
@@ -52,19 +57,19 @@ export function inputError(callable, diagnostics) {
52
57
  return protocolError('VALIDATION_ERROR', 'Callable input is invalid.', reason);
53
58
  }
54
59
  export function projectError(input) {
55
- if (input instanceof errors.ProtocolError)
56
- return input;
57
- if (input instanceof InvocationError)
58
- return protocolError(input.code, input.message, input.reason);
60
+ if (input instanceof errors.ProtocolError) {
61
+ return admittedProtocolErrors.has(input)
62
+ ? input
63
+ : protocolError('INTERNAL_ERROR', 'Internal application error.');
64
+ }
65
+ if (input instanceof InvocationError) {
66
+ return protocolError('INTERNAL_ERROR', 'Internal application error.');
67
+ }
59
68
  if (input instanceof ResponseError) {
60
69
  if (!PUBLIC_ERROR_CODES.has(input.code)) {
61
70
  return protocolError('BACKEND_UNAVAILABLE', 'Dependency Kernel returned invalid error evidence.');
62
71
  }
63
- return new errors.ProtocolError({
64
- code: input.code,
65
- message: input.message,
66
- ...(input.data === undefined ? {} : { data: input.data }),
67
- });
72
+ return protocolError(PUBLIC_ERROR_NAMES.get(input.code), input.message, input.data);
68
73
  }
69
74
  if (input instanceof TransportError) {
70
75
  return protocolError(input.phase === 'timeout' ? 'DEADLINE_EXCEEDED' : 'BACKEND_UNAVAILABLE', input.phase === 'timeout'
@@ -33,9 +33,10 @@ export function createService(input) {
33
33
  const prepared = prepareServer({
34
34
  ...serverOptions(input.server),
35
35
  path: invocationPath(),
36
+ publicOrigin: release.addressing.publicUrl,
36
37
  invocation: {
37
38
  source: selectedIdentity.issuer,
38
- next: () => globalThis.crypto.randomUUID(),
39
+ next: () => crypto.randomUUID(),
39
40
  },
40
41
  issuer: selectedIdentity,
41
42
  ...(selectedIdentity.tokenExchange === undefined
@@ -92,6 +93,7 @@ function serverOptions(input) {
92
93
  'path',
93
94
  'invocation',
94
95
  'issuer',
96
+ 'publicOrigin',
95
97
  'tokenExchange',
96
98
  'publication',
97
99
  'delivery',
@@ -5,7 +5,7 @@ import type { WorkflowRunner } from '../../application/workflow/runner/index.js'
5
5
  import type { Release } from '../../deployment/release/index.js';
6
6
  import type { Identity } from '../identity/index.js';
7
7
  import type { ReleaseLoader } from './release.js';
8
- export type ServiceServerOptions = Omit<ServerOptions, 'path' | 'invocation' | 'issuer' | 'tokenExchange' | 'publication' | 'delivery'>;
8
+ export type ServiceServerOptions = Omit<ServerOptions, 'path' | 'invocation' | 'issuer' | 'publicOrigin' | 'tokenExchange' | 'publication' | 'delivery'>;
9
9
  export interface ServiceInput<Environment, RuntimeValue extends Runtime = Runtime> {
10
10
  readonly runtime: RuntimeValue;
11
11
  readonly environment: Environment;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /** Curated SDK authoring journey. Semantic values remain available from focused subpaths. */
2
2
  export { defineAction } from './application/action/index.js';
3
- export type { Action, ActionContext, ActionOutputOf, Caller } from './application/action/index.js';
3
+ export type { Action, ActionContext, ActionOutputOf, Caller, DeclaredErrorDefinition, DeclaredErrorFactory, DeclaredErrorFamily, DeclaredErrorOptions, DeclaredErrors, } from './application/action/index.js';
4
4
  export { defineApplication, defineFrontend, external, requirements, route, routes, vite, } from './application/index.js';
5
5
  export type { Application, Frontend, Requirements, Route, Routes } from './application/index.js';
6
6
  export { defineIntegration, defineProvider } from './application/integration/index.js';
@@ -15,5 +15,7 @@ export { defineWorkflow } from './application/workflow/index.js';
15
15
  export type { Workflow, WorkflowContext } from './application/workflow/index.js';
16
16
  export { compile, deploy, runtime } from './deployment/index.js';
17
17
  export type { Build, Deployment, Release } from './deployment/index.js';
18
+ export { defineProject } from './project/index.js';
19
+ export type { Project } from './project/index.js';
18
20
  export { serve } from './execution/index.js';
19
21
  export type { ServedApplication } from './execution/index.js';
package/dist/index.js CHANGED
@@ -7,4 +7,5 @@ export { defineCollectionQuery, defineCompositeQuery, defineQuery, executeQuery,
7
7
  export { defineRuntime } from './application/runtime/index.js';
8
8
  export { defineWorkflow } from './application/workflow/index.js';
9
9
  export { compile, deploy, runtime } from './deployment/index.js';
10
+ export { defineProject } from './project/index.js';
10
11
  export { serve } from './execution/index.js';
@@ -1,4 +1,4 @@
1
1
  /** Canonical authentication and authority values. */
2
2
  export * from '@astrale-os/kernel-core/auth';
3
- export { createAuth, type AuthApi, type PolicyDecisionInput } from '@astrale-os/kernel-client/auth';
3
+ export type { AuthApi, AdmissionOptions, FunctionAdmission, PolicyDecisionInput, RegisterRequest, RegisterIdentity, } from '@astrale-os/kernel-client/auth';
4
4
  export * as exchange from './exchange/index.js';
@@ -1,4 +1,3 @@
1
1
  /** Canonical authentication and authority values. */
2
2
  export * from '@astrale-os/kernel-core/auth';
3
- export { createAuth } from '@astrale-os/kernel-client/auth';
4
3
  export * as exchange from './exchange/index.js';
@@ -0,0 +1,6 @@
1
+ /** Graph-local names retain the canonical Kernel type and constructor identity. */
2
+ export { LocalBinding as LocalAlias, isLocalBinding as isLocalAlias, } from '@astrale-os/kernel-core/graph/graph';
3
+ /** @deprecated Use LocalAlias. */
4
+ export { LocalBinding } from '@astrale-os/kernel-core/graph/graph';
5
+ /** @deprecated Use isLocalAlias. */
6
+ export { isLocalBinding } from '@astrale-os/kernel-core/graph/graph';
@@ -0,0 +1,6 @@
1
+ /** Graph-local names retain the canonical Kernel type and constructor identity. */
2
+ export { LocalBinding as LocalAlias, isLocalBinding as isLocalAlias, } from '@astrale-os/kernel-core/graph/graph';
3
+ /** @deprecated Use LocalAlias. */
4
+ export { LocalBinding } from '@astrale-os/kernel-core/graph/graph';
5
+ /** @deprecated Use isLocalAlias. */
6
+ export { isLocalBinding } from '@astrale-os/kernel-core/graph/graph';
@@ -1,2 +1,3 @@
1
- /** Canonical graph documents and local bindings. */
1
+ /** Canonical graph documents and local aliases. */
2
2
  export * from '@astrale-os/kernel-core/graph/graph';
3
+ export { LocalAlias, isLocalAlias, LocalBinding, isLocalBinding } from '../alias.js';
@@ -1,2 +1,3 @@
1
- /** Canonical graph documents and local bindings. */
1
+ /** Canonical graph documents and local aliases. */
2
2
  export * from '@astrale-os/kernel-core/graph/graph';
3
+ export { LocalAlias, isLocalAlias, LocalBinding, isLocalBinding } from '../alias.js';
@@ -1,5 +1,6 @@
1
1
  /** Curated aggregate over canonical graph values. */
2
- export { GraphData, GraphDataDecodeError, GraphSpec, GraphSpecDecodeError, LocalBinding, } from '@astrale-os/kernel-core/graph/graph';
2
+ export { GraphData, GraphDataDecodeError, GraphSpec, GraphSpecDecodeError, } from '@astrale-os/kernel-core/graph/graph';
3
+ export { LocalAlias, isLocalAlias, LocalBinding, isLocalBinding } from './alias.js';
3
4
  export type { AnonymousNodeSpec, GraphDataJson, GraphSpecEdge, GraphSpecEndpoint, GraphSpecJson, GraphSpecNode, } from '@astrale-os/kernel-core/graph/graph';
4
5
  export * from './edge/index.js';
5
6
  export * from './node/index.js';
@@ -1,5 +1,6 @@
1
1
  /** Curated aggregate over canonical graph values. */
2
- export { GraphData, GraphDataDecodeError, GraphSpec, GraphSpecDecodeError, LocalBinding, } from '@astrale-os/kernel-core/graph/graph';
2
+ export { GraphData, GraphDataDecodeError, GraphSpec, GraphSpecDecodeError, } from '@astrale-os/kernel-core/graph/graph';
3
+ export { LocalAlias, isLocalAlias, LocalBinding, isLocalBinding } from './alias.js';
3
4
  export * from './edge/index.js';
4
5
  export * from './node/index.js';
5
6
  export * from './path/index.js';
@@ -0,0 +1,37 @@
1
+ import { nodeClass as kernelNodeClass, type DirectedEdgeClass, type DirectedEdgeInput, type NodeClass, type NodeClassInput as KernelNodeClassInput, type UndirectedEdgeClass, type UndirectedEdgeInput } from '@astrale-os/kernel-dsl/v1/builder';
2
+ import { type ClassIcon } from './class-icon.js';
3
+ /** SDK Node Class input: every author must make an explicit, admitted icon choice. */
4
+ export type NodeClassInput = Omit<KernelNodeClassInput, 'icon'> & {
5
+ readonly icon: ClassIcon;
6
+ };
7
+ /** Preserve authored input instead of serializing expanded inheritance projections in consumers. */
8
+ export interface AuthoredNodeClass<Config extends NodeClassInput> extends ReturnType<typeof kernelNodeClass<Config>> {
9
+ }
10
+ type NodeInput = {
11
+ readonly kind: 'node';
12
+ readonly abstract: boolean;
13
+ } & NodeClassInput;
14
+ type DirectedInput = {
15
+ readonly kind: 'edge';
16
+ readonly orientation: 'directed';
17
+ readonly abstract: boolean;
18
+ } & Omit<DirectedEdgeInput, 'orientation'>;
19
+ type UndirectedInput = {
20
+ readonly kind: 'edge';
21
+ readonly orientation: 'undirected';
22
+ readonly abstract: boolean;
23
+ } & Omit<UndirectedEdgeInput, 'orientation'>;
24
+ /**
25
+ * Author a Node Class whose materialized configuration always carries an explicitly selected,
26
+ * admitted SVG icon. The mapped input retains inference while expanding package-private
27
+ * Config interface names into portable structure for downstream declaration emit.
28
+ */
29
+ export declare function nodeClass<const Config extends NodeClassInput>(config: Config & Record<Exclude<keyof Config, keyof NodeClassInput>, never>): AuthoredNodeClass<{
30
+ [Key in keyof Config]: Key extends 'properties' | 'methods' | 'policies' ? {
31
+ [Member in keyof NonNullable<Config[Key]>]: NonNullable<Config[Key]>[Member];
32
+ } | Extract<Config[Key], undefined> : Key extends 'extends' ? Config[Key] extends infer Parents extends NodeClassInput['extends'] ? Parents extends readonly unknown[] ? readonly [...Parents] : Parents : never : Config[Key];
33
+ }>;
34
+ export declare function defineClass(config: NodeInput): NodeClass;
35
+ export declare function defineClass(config: DirectedInput): DirectedEdgeClass;
36
+ export declare function defineClass(config: UndirectedInput): UndirectedEdgeClass;
37
+ export {};
@@ -0,0 +1,20 @@
1
+ import { defineClass as defineKernelClass, nodeClass as kernelNodeClass, } from '@astrale-os/kernel-dsl/v1/builder';
2
+ import { classIcon } from './class-icon.js';
3
+ export function nodeClass(config) {
4
+ if (config === undefined || config.icon === undefined) {
5
+ throw new TypeError('Node Class icon is required; use classIcon.neutral to make an explicit neutral choice.');
6
+ }
7
+ return kernelNodeClass({
8
+ ...config,
9
+ icon: classIcon.svg(config.icon),
10
+ });
11
+ }
12
+ export function defineClass(config) {
13
+ if (config.kind === 'node') {
14
+ const { kind: _, ...input } = config;
15
+ return nodeClass(input);
16
+ }
17
+ if (config.orientation === 'directed')
18
+ return defineKernelClass(config);
19
+ return defineKernelClass(config);
20
+ }