@manifesto-ai/sdk 3.4.0 → 3.6.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.
@@ -1,14 +1,24 @@
1
- import { type DomainSchema, type Snapshot as CoreSnapshot } from "@manifesto-ai/core";
2
- import type { HostResult, ManifestoHost } from "@manifesto-ai/host";
3
- import type { BaseLaws, CanonicalSnapshot, ComposableManifesto, ManifestoBaseInstance, ManifestoDomainShape, ManifestoEvent, ManifestoEventMap, Snapshot, TypedCreateIntent, TypedGetActionMetadata, TypedIntent, TypedMEL, TypedOn, TypedSubscribe } from "./types.js";
1
+ import { type ComputeStatus, type DomainSchema, type Patch, type Requirement, type Snapshot as CoreSnapshot, type SystemDelta } from "@manifesto-ai/core";
2
+ import type { HostContextProvider, HostResult, ManifestoHost } from "@manifesto-ai/host";
3
+ import { ManifestoError } from "./errors.js";
4
+ import type { BaseLaws, CanonicalSnapshot, ComposableManifesto, ManifestoBaseInstance, ManifestoDomainShape, ManifestoEvent, ManifestoEventMap, SchemaGraph, Snapshot, TypedCreateIntent, TypedGetActionMetadata, TypedIntent, TypedMEL, TypedOn, TypedSimulate, TypedSubscribe } from "./types.js";
4
5
  import { type SnapshotProjectionPlan } from "./snapshot-projection.js";
6
+ import type { ExtensionKernel } from "./extensions-types.js";
5
7
  export declare const ACTION_PARAM_NAMES: unique symbol;
6
8
  export declare const RUNTIME_KERNEL_FACTORY: unique symbol;
7
9
  export declare const ACTIVATION_STATE: unique symbol;
10
+ export declare const EXTENSION_KERNEL: unique symbol;
8
11
  export type ActivationState = {
9
12
  activated: boolean;
10
13
  };
11
14
  export type HostDispatchOptions = NonNullable<Parameters<ManifestoHost["dispatch"]>[1]>;
15
+ export type SimulateResult<T extends ManifestoDomainShape = ManifestoDomainShape> = {
16
+ readonly snapshot: CanonicalSnapshot<T["state"]>;
17
+ readonly patches: readonly Patch[];
18
+ readonly systemDelta: Readonly<SystemDelta>;
19
+ readonly status: ComputeStatus;
20
+ readonly requirements: readonly Requirement[];
21
+ };
12
22
  export interface RuntimeKernel<T extends ManifestoDomainShape> {
13
23
  readonly schema: DomainSchema;
14
24
  readonly MEL: TypedMEL<T>;
@@ -17,9 +27,14 @@ export interface RuntimeKernel<T extends ManifestoDomainShape> {
17
27
  readonly on: TypedOn<T>;
18
28
  readonly getSnapshot: () => Snapshot<T["state"]>;
19
29
  readonly getCanonicalSnapshot: () => CanonicalSnapshot<T["state"]>;
30
+ readonly getAvailableActionsFor: (snapshot: CanonicalSnapshot<T["state"]>) => readonly (keyof T["actions"])[];
20
31
  readonly getAvailableActions: () => readonly (keyof T["actions"])[];
21
32
  readonly getActionMetadata: TypedGetActionMetadata<T>;
33
+ readonly isActionAvailableFor: (snapshot: CanonicalSnapshot<T["state"]>, name: keyof T["actions"]) => boolean;
22
34
  readonly isActionAvailable: (name: keyof T["actions"]) => boolean;
35
+ readonly getSchemaGraph: () => SchemaGraph;
36
+ readonly simulateSync: (snapshot: CanonicalSnapshot<T["state"]>, intent: TypedIntent<T>) => SimulateResult<T>;
37
+ readonly simulate: TypedSimulate<T>;
23
38
  readonly dispose: () => void;
24
39
  readonly isDisposed: () => boolean;
25
40
  readonly getVisibleCoreSnapshot: () => CoreSnapshot;
@@ -31,7 +46,9 @@ export interface RuntimeKernel<T extends ManifestoDomainShape> {
31
46
  readonly enqueue: <R>(task: () => Promise<R>) => Promise<R>;
32
47
  readonly ensureIntentId: (intent: TypedIntent<T>) => TypedIntent<T>;
33
48
  readonly executeHost: (intent: TypedIntent<T>, options?: HostDispatchOptions) => Promise<HostResult>;
49
+ readonly createUnavailableError: (intent: TypedIntent<T>) => ManifestoError;
34
50
  readonly rejectUnavailable: (intent: TypedIntent<T>) => never;
51
+ readonly [EXTENSION_KERNEL]: ExtensionKernel<T>;
35
52
  }
36
53
  export type RuntimeKernelFactory<T extends ManifestoDomainShape> = () => RuntimeKernel<T>;
37
54
  export type InternalComposableManifesto<T extends ManifestoDomainShape, Laws extends BaseLaws> = ComposableManifesto<T, Laws> & {
@@ -42,14 +59,17 @@ type RuntimeKernelOptions<T extends ManifestoDomainShape> = {
42
59
  readonly schema: DomainSchema;
43
60
  readonly projectionPlan: SnapshotProjectionPlan;
44
61
  readonly host: ManifestoHost;
62
+ readonly hostContextProvider: HostContextProvider;
45
63
  readonly MEL: TypedMEL<T>;
46
64
  readonly createIntent: TypedCreateIntent<T>;
47
65
  };
48
66
  export declare function attachRuntimeKernelFactory<T extends ManifestoDomainShape, Laws extends BaseLaws>(manifesto: ComposableManifesto<T, Laws>, factory: RuntimeKernelFactory<T>, activationState?: ActivationState): InternalComposableManifesto<T, Laws>;
49
67
  export declare function getRuntimeKernelFactory<T extends ManifestoDomainShape, Laws extends BaseLaws>(manifesto: ComposableManifesto<T, Laws>): RuntimeKernelFactory<T>;
68
+ export declare function attachExtensionKernel<T extends ManifestoDomainShape, TInstance extends object>(runtime: TInstance, kernel: RuntimeKernel<T>): TInstance;
69
+ export declare function getAttachedExtensionKernel<T extends ManifestoDomainShape>(runtime: object): ExtensionKernel<T>;
50
70
  export declare function getActivationState<T extends ManifestoDomainShape, Laws extends BaseLaws>(manifesto: ComposableManifesto<T, Laws>): ActivationState;
51
71
  export declare function assertComposableNotActivated<T extends ManifestoDomainShape, Laws extends BaseLaws>(manifesto: ComposableManifesto<T, Laws>): void;
52
72
  export declare function activateComposable<T extends ManifestoDomainShape, Laws extends BaseLaws>(manifesto: ComposableManifesto<T, Laws>): void;
53
- export declare function createRuntimeKernel<T extends ManifestoDomainShape>({ schema, projectionPlan, host, MEL, createIntent, }: RuntimeKernelOptions<T>): RuntimeKernel<T>;
73
+ export declare function createRuntimeKernel<T extends ManifestoDomainShape>({ schema, projectionPlan, host, hostContextProvider, MEL, createIntent, }: RuntimeKernelOptions<T>): RuntimeKernel<T>;
54
74
  export declare function createBaseRuntimeInstance<T extends ManifestoDomainShape>(kernel: RuntimeKernel<T>): ManifestoBaseInstance<T>;
55
75
  export {};
@@ -3,5 +3,5 @@
3
3
  * App code should prefer the main sdk entry point; decorator and provider authors
4
4
  * can rely on this subpath when composing or promoting runtime verbs.
5
5
  */
6
- export type { ActivationState, HostDispatchOptions, RuntimeKernel, RuntimeKernelFactory, } from "./internal.js";
7
- export { activateComposable, assertComposableNotActivated, attachRuntimeKernelFactory, createRuntimeKernel, getActivationState, getRuntimeKernelFactory, } from "./internal.js";
6
+ export type { ActivationState, HostDispatchOptions, RuntimeKernel, RuntimeKernelFactory, SimulateResult, } from "./internal.js";
7
+ export { activateComposable, assertComposableNotActivated, attachExtensionKernel, attachRuntimeKernelFactory, createRuntimeKernel, getActivationState, getRuntimeKernelFactory, } from "./internal.js";
package/dist/provider.js CHANGED
@@ -1,17 +1,2 @@
1
- import {
2
- activateComposable,
3
- assertComposableNotActivated,
4
- attachRuntimeKernelFactory,
5
- createRuntimeKernel,
6
- getActivationState,
7
- getRuntimeKernelFactory
8
- } from "./chunk-2YBJP5JT.js";
9
- export {
10
- activateComposable,
11
- assertComposableNotActivated,
12
- attachRuntimeKernelFactory,
13
- createRuntimeKernel,
14
- getActivationState,
15
- getRuntimeKernelFactory
16
- };
1
+ import{j as t,k as e,l as a,n,o,p as i,q as r}from"./chunk-NXOXNSXB.js";export{i as activateComposable,o as assertComposableNotActivated,a as attachExtensionKernel,t as attachRuntimeKernelFactory,r as createRuntimeKernel,n as getActivationState,e as getRuntimeKernelFactory};
17
2
  //# sourceMappingURL=provider.js.map
@@ -0,0 +1,3 @@
1
+ import type { SimulationSession } from "./extensions-types.js";
2
+ import type { ActivatedInstance, BaseLaws, ManifestoDomainShape } from "./types.js";
3
+ export declare function createSimulationSession<T extends ManifestoDomainShape, Laws extends BaseLaws>(app: ActivatedInstance<T, Laws>): SimulationSession<T>;
package/dist/types.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import type { DomainSchema, Intent, Patch } from "@manifesto-ai/core";
1
+ import type { ComputeStatus, DomainSchema, Intent, Patch, Requirement } from "@manifesto-ai/core";
2
+ import type { SchemaGraph as CompilerSchemaGraph, SchemaGraphEdge, SchemaGraphEdgeRelation, SchemaGraphNode, SchemaGraphNodeId, SchemaGraphNodeKind } from "@manifesto-ai/compiler";
2
3
  import type { CanonicalPlatformNamespaces, CanonicalSnapshot, Snapshot } from "./snapshot-projection.js";
3
4
  type ActionFn = {
4
5
  bivarianceHack(...args: unknown[]): unknown;
@@ -35,10 +36,12 @@ export type TypedActionRef<T extends ManifestoDomainShape, K extends keyof T["ac
35
36
  };
36
37
  export type FieldRef<TValue> = {
37
38
  readonly __kind: "FieldRef";
39
+ readonly name: string;
38
40
  readonly _type?: TValue;
39
41
  };
40
42
  export type ComputedRef<TValue> = {
41
43
  readonly __kind: "ComputedRef";
44
+ readonly name: string;
42
45
  readonly _type?: TValue;
43
46
  };
44
47
  export type TypedMEL<T extends ManifestoDomainShape> = {
@@ -67,6 +70,21 @@ export type TypedIntent<T extends ManifestoDomainShape, K extends keyof T["actio
67
70
  export type TypedCreateIntent<T extends ManifestoDomainShape> = <K extends keyof T["actions"]>(action: TypedActionRef<T, K>, ...args: CreateIntentArgs<T, K>) => TypedIntent<T, K>;
68
71
  export type TypedDispatchAsync<T extends ManifestoDomainShape> = (intent: TypedIntent<T>) => Promise<Snapshot<T["state"]>>;
69
72
  export type TypedCommitAsync<T extends ManifestoDomainShape> = TypedDispatchAsync<T>;
73
+ export type SchemaGraphNodeRef = TypedActionRef<ManifestoDomainShape> | FieldRef<unknown> | ComputedRef<unknown>;
74
+ export type SchemaGraph = CompilerSchemaGraph & {
75
+ traceUp(ref: SchemaGraphNodeRef): SchemaGraph;
76
+ traceUp(nodeId: SchemaGraphNodeId): SchemaGraph;
77
+ traceDown(ref: SchemaGraphNodeRef): SchemaGraph;
78
+ traceDown(nodeId: SchemaGraphNodeId): SchemaGraph;
79
+ };
80
+ export type SimulateResult<T extends ManifestoDomainShape = ManifestoDomainShape> = {
81
+ readonly snapshot: Snapshot<T["state"]>;
82
+ readonly changedPaths: readonly string[];
83
+ readonly newAvailableActions: readonly (keyof T["actions"])[];
84
+ readonly requirements: readonly Requirement[];
85
+ readonly status: ComputeStatus;
86
+ };
87
+ export type TypedSimulate<T extends ManifestoDomainShape> = <K extends keyof T["actions"]>(action: TypedActionRef<T, K>, ...args: CreateIntentArgs<T, K>) => SimulateResult<T>;
70
88
  export type TypedSubscribe<T extends ManifestoDomainShape> = <R>(selector: Selector<T["state"], R>, listener: (value: R) => void) => Unsubscribe;
71
89
  export type TypedActionMetadata<T extends ManifestoDomainShape, K extends keyof T["actions"] = keyof T["actions"]> = {
72
90
  readonly name: K;
@@ -109,6 +127,8 @@ export type ManifestoBaseInstance<T extends ManifestoDomainShape> = {
109
127
  readonly getAvailableActions: () => readonly (keyof T["actions"])[];
110
128
  readonly getActionMetadata: TypedGetActionMetadata<T>;
111
129
  readonly isActionAvailable: (name: keyof T["actions"]) => boolean;
130
+ readonly getSchemaGraph: () => SchemaGraph;
131
+ readonly simulate: TypedSimulate<T>;
112
132
  readonly MEL: TypedMEL<T>;
113
133
  readonly schema: DomainSchema;
114
134
  readonly dispose: () => void;
@@ -124,7 +144,7 @@ export type ActivatedInstance<T extends ManifestoDomainShape, Laws> = Laws exten
124
144
  } ? Runtime : never : Laws extends LineageLaws ? ResolvedManifestoRuntimeByLaws<T> extends {
125
145
  readonly lineage: infer Runtime;
126
146
  } ? Runtime : never : ManifestoRuntimeByLaws<T>["base"];
127
- export type { CanonicalPlatformNamespaces, CanonicalSnapshot, Snapshot, };
147
+ export type { CanonicalPlatformNamespaces, CanonicalSnapshot, Snapshot, SchemaGraphEdge, SchemaGraphEdgeRelation, SchemaGraphNode, SchemaGraphNodeId, SchemaGraphNodeKind, };
128
148
  export type ComposableManifesto<T extends ManifestoDomainShape, Laws extends BaseLaws = BaseComposableLaws> = {
129
149
  readonly _laws: Laws;
130
150
  readonly schema: DomainSchema;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manifesto-ai/sdk",
3
- "version": "3.4.0",
3
+ "version": "3.6.0",
4
4
  "description": "Manifesto SDK - Activation-first public API for the base runtime",
5
5
  "author": "eggplantiny <eggplantiny@gmail.com>",
6
6
  "license": "MIT",
@@ -30,6 +30,10 @@
30
30
  "types": "./dist/index.d.ts",
31
31
  "import": "./dist/index.js"
32
32
  },
33
+ "./extensions": {
34
+ "types": "./dist/extensions.d.ts",
35
+ "import": "./dist/extensions.js"
36
+ },
33
37
  "./provider": {
34
38
  "types": "./dist/provider.d.ts",
35
39
  "import": "./dist/provider.js"
@@ -39,9 +43,9 @@
39
43
  "dist"
40
44
  ],
41
45
  "dependencies": {
42
- "@manifesto-ai/compiler": "3.1.1",
43
- "@manifesto-ai/core": "2.9.0",
44
- "@manifesto-ai/host": "2.6.0"
46
+ "@manifesto-ai/compiler": "3.2.0",
47
+ "@manifesto-ai/core": "2.10.0",
48
+ "@manifesto-ai/host": "2.7.0"
45
49
  },
46
50
  "devDependencies": {
47
51
  "typescript": "^5.9.3",