@manifesto-ai/sdk 3.18.1 → 5.0.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,8 +1,7 @@
1
- import type { DispatchReport, ExecutionDiagnostics, ExecutionFailureInfo, ExecutionOutcome, IntentAdmission, ManifestoDomainShape, Snapshot, TypedIntent } from "../types.js";
1
+ import type { DispatchReport, ExecutionDiagnostics, ExecutionFailureInfo, DispatchExecutionOutcome, IntentAdmission, ManifestoDomainShape, ProjectedSnapshot, TypedIntent } from "../types.js";
2
2
  import type { ExtensionKernel } from "../extensions-types.js";
3
3
  import type { RuntimeKernel } from "../compat/internal.js";
4
4
  import { ManifestoError } from "../errors.js";
5
- import { emitDispatchRejectedEvent } from "./events.js";
6
5
  import type { RuntimePublicationHelpers } from "./facets.js";
7
6
  type RejectedAttempt<T extends ManifestoDomainShape> = {
8
7
  readonly kind: "rejected";
@@ -10,9 +9,12 @@ type RejectedAttempt<T extends ManifestoDomainShape> = {
10
9
  readonly admission: Extract<IntentAdmission<T>, {
11
10
  readonly kind: "blocked";
12
11
  }>;
13
- readonly beforeSnapshot: Snapshot<T["state"]>;
12
+ readonly beforeSnapshot: ProjectedSnapshot<T>;
14
13
  readonly beforeCanonicalSnapshot: ReturnType<RuntimeKernel<T>["getCanonicalSnapshot"]>;
15
- readonly rejection: ReturnType<typeof emitDispatchRejectedEvent<T>>;
14
+ readonly rejection: {
15
+ readonly code: "ACTION_UNAVAILABLE" | "INTENT_NOT_DISPATCHABLE" | "INVALID_INPUT";
16
+ readonly reason: string;
17
+ };
16
18
  readonly rejectionError: ManifestoError;
17
19
  };
18
20
  type FailedAttempt<T extends ManifestoDomainShape> = {
@@ -21,13 +23,13 @@ type FailedAttempt<T extends ManifestoDomainShape> = {
21
23
  readonly admission: Extract<IntentAdmission<T>, {
22
24
  readonly kind: "admitted";
23
25
  }>;
24
- readonly beforeSnapshot: Snapshot<T["state"]>;
26
+ readonly beforeSnapshot: ProjectedSnapshot<T>;
25
27
  readonly beforeCanonicalSnapshot: ReturnType<RuntimeKernel<T>["getCanonicalSnapshot"]>;
26
28
  readonly failure: Error;
27
29
  readonly errorInfo: ExecutionFailureInfo;
28
30
  readonly published: boolean;
29
31
  readonly diagnostics?: ExecutionDiagnostics;
30
- readonly outcome?: ExecutionOutcome<T>;
32
+ readonly outcome?: DispatchExecutionOutcome<T>;
31
33
  };
32
34
  type CompletedAttempt<T extends ManifestoDomainShape> = {
33
35
  readonly kind: "completed";
@@ -35,12 +37,12 @@ type CompletedAttempt<T extends ManifestoDomainShape> = {
35
37
  readonly admission: Extract<IntentAdmission<T>, {
36
38
  readonly kind: "admitted";
37
39
  }>;
38
- readonly publishedSnapshot: Snapshot<T["state"]>;
39
- readonly outcome: ExecutionOutcome<T>;
40
+ readonly publishedSnapshot: ProjectedSnapshot<T>;
41
+ readonly outcome: DispatchExecutionOutcome<T>;
40
42
  readonly diagnostics: ExecutionDiagnostics;
41
43
  };
42
44
  export type BaseDispatchAttemptResult<T extends ManifestoDomainShape = ManifestoDomainShape> = RejectedAttempt<T> | FailedAttempt<T> | CompletedAttempt<T>;
43
- export declare function runBaseDispatchAttempt<T extends ManifestoDomainShape>(kernel: RuntimeKernel<T>, extensionKernel: Pick<ExtensionKernel<T>, "projectSnapshot">, publication: Pick<RuntimePublicationHelpers<T>, "publishCompletedHostResult" | "publishFailedHostResult">, intent: TypedIntent<T>): Promise<BaseDispatchAttemptResult<T>>;
44
- export declare function attemptToDispatchAsyncResult<T extends ManifestoDomainShape>(attempt: BaseDispatchAttemptResult<T>): Snapshot<T["state"]>;
45
+ export declare function runBaseDispatchAttempt<T extends ManifestoDomainShape>(kernel: RuntimeKernel<T>, extensionKernel: Pick<ExtensionKernel<T>, "projectSnapshot">, publication: Pick<RuntimePublicationHelpers<T>, "publishCompletedHostResult" | "publishFailedHostResult">, intent: TypedIntent<T>, context: ReturnType<RuntimeKernel<T>["createComputeContext"]>): Promise<BaseDispatchAttemptResult<T>>;
46
+ export declare function attemptToDispatchAsyncResult<T extends ManifestoDomainShape>(attempt: BaseDispatchAttemptResult<T>): ProjectedSnapshot<T>;
45
47
  export declare function attemptToDispatchReport<T extends ManifestoDomainShape>(attempt: BaseDispatchAttemptResult<T>): DispatchReport<T>;
46
48
  export {};
@@ -1,3 +1,10 @@
1
- import type { ManifestoBaseInstance, ManifestoDomainShape } from "../types.js";
1
+ import type { ManifestoApp, ManifestoDomainShape, PreviewDiagnosticsMode, SubmitReportMode } from "../types.js";
2
2
  import { type RuntimeKernel } from "../compat/internal.js";
3
- export declare function createBaseRuntimeInstance<T extends ManifestoDomainShape>(kernel: RuntimeKernel<T>): ManifestoBaseInstance<T>;
3
+ type BaseMode = "base";
4
+ type RuntimeExecutionView<T extends ManifestoDomainShape> = {
5
+ readonly context?: ReturnType<RuntimeKernel<T>["getExternalContext"]>;
6
+ readonly diagnostics?: PreviewDiagnosticsMode;
7
+ readonly report?: SubmitReportMode;
8
+ };
9
+ export declare function createBaseRuntimeInstance<T extends ManifestoDomainShape>(kernel: RuntimeKernel<T>, view?: RuntimeExecutionView<T>, isView?: boolean): ManifestoApp<T, BaseMode>;
10
+ export {};
@@ -0,0 +1,4 @@
1
+ import { type DomainSchema } from "@manifesto-ai/core";
2
+ import type { DomainExternalContext, ManifestoDomainShape } from "../types.js";
3
+ export declare function materializeExternalContext<T extends ManifestoDomainShape>(schema: DomainSchema, value: unknown, source: string): DomainExternalContext<T>;
4
+ export declare function captureExternalContext<T extends ManifestoDomainShape>(schema: DomainSchema, current: DomainExternalContext<T>, override: unknown, source: string): DomainExternalContext<T>;
@@ -1,24 +1,24 @@
1
- import type { ComputeStatus, Patch, Requirement, Snapshot as CoreSnapshot, SystemDelta } from "@manifesto-ai/core";
1
+ import type { Context, ComputeStatus, Patch, Requirement, Snapshot as CoreSnapshot, SystemDelta } from "@manifesto-ai/core";
2
2
  import type { HostResult } from "@manifesto-ai/host";
3
- import type { DispatchBlocker, CanonicalSnapshot, ExecutionDiagnostics, ExecutionFailureInfo, ExecutionOutcome, IntentAdmission, IntentExplanation, ManifestoDomainShape, ManifestoEvent, ManifestoEventMap, SimulationDiagnostics, Snapshot, TypedIntent, TypedOn, TypedSubscribe } from "../types.js";
3
+ import type { DispatchBlocker, CanonicalSnapshot, DomainExternalContext, DispatchExecutionOutcome, ExecutionDiagnostics, ExecutionFailureInfo, IntentAdmission, IntentExplanation, ManifestoDomainShape, ManifestoEvent, ManifestoEventPayloadMap, ProjectedSnapshot, SimulationDiagnostics, TypedIntent, TypedOn, TypedSubscribe } from "../types.js";
4
4
  import type { ManifestoError } from "../errors.js";
5
5
  export interface RuntimeStateStore<T extends ManifestoDomainShape> {
6
6
  readonly subscribe: TypedSubscribe<T>;
7
7
  readonly on: TypedOn<T>;
8
- readonly getSnapshot: () => Snapshot<T["state"]>;
8
+ readonly getSnapshot: () => ProjectedSnapshot<T>;
9
9
  readonly getCanonicalSnapshot: () => CanonicalSnapshot<T["state"]>;
10
10
  readonly getVisibleCoreSnapshot: () => CoreSnapshot;
11
11
  readonly setVisibleSnapshot: (snapshot: CoreSnapshot, options?: {
12
12
  readonly notify?: boolean;
13
- }) => Snapshot<T["state"]>;
13
+ }) => ProjectedSnapshot<T>;
14
14
  readonly restoreVisibleSnapshot: () => void;
15
- readonly emitEvent: <K extends ManifestoEvent>(event: K, payload: ManifestoEventMap<T>[K]) => void;
15
+ readonly emitEvent: <K extends ManifestoEvent>(event: K, payload: ManifestoEventPayloadMap[K]) => void;
16
16
  readonly enqueue: <R>(task: () => Promise<R>) => Promise<R>;
17
17
  readonly dispose: () => void;
18
18
  readonly isDisposed: () => boolean;
19
19
  }
20
20
  export interface RuntimeReportHelpers<T extends ManifestoDomainShape> {
21
- readonly deriveExecutionOutcome: (beforeSnapshot: CanonicalSnapshot<T["state"]>, afterSnapshot: CanonicalSnapshot<T["state"]>) => ExecutionOutcome<T>;
21
+ readonly deriveExecutionOutcome: (beforeSnapshot: CanonicalSnapshot<T["state"]>, afterSnapshot: CanonicalSnapshot<T["state"]>) => DispatchExecutionOutcome<T>;
22
22
  readonly classifyExecutionFailure: (error: unknown, stage: "host" | "seal") => ExecutionFailureInfo;
23
23
  readonly createExecutionDiagnostics: (result: HostResult) => ExecutionDiagnostics;
24
24
  }
@@ -49,7 +49,10 @@ export type RuntimeSimulationResult<T extends ManifestoDomainShape = ManifestoDo
49
49
  readonly requirements: readonly Requirement[];
50
50
  readonly diagnostics?: SimulationDiagnostics;
51
51
  };
52
- export type RuntimeSimulateSync<T extends ManifestoDomainShape = ManifestoDomainShape> = (snapshot: CanonicalSnapshot<T["state"]>, intent: TypedIntent<T>) => RuntimeSimulationResult<T>;
52
+ export type RuntimeSimulateSync<T extends ManifestoDomainShape = ManifestoDomainShape> = (snapshot: CanonicalSnapshot<T["state"]>, intent: TypedIntent<T>, options?: {
53
+ readonly externalContext?: DomainExternalContext<T>;
54
+ readonly context?: Context;
55
+ }) => RuntimeSimulationResult<T>;
53
56
  export interface RuntimeAdmission<T extends ManifestoDomainShape> {
54
57
  readonly getIntentBlockersFor: (snapshot: CanonicalSnapshot<T["state"]>, intent: TypedIntent<T>) => readonly DispatchBlocker[];
55
58
  readonly validateIntentInputFor: (snapshot: CanonicalSnapshot<T["state"]>, intent: TypedIntent<T>) => ManifestoError | null;
@@ -63,12 +66,12 @@ export interface RuntimeAdmission<T extends ManifestoDomainShape> {
63
66
  readonly rejectNotDispatchable: (intent: TypedIntent<T>) => never;
64
67
  }
65
68
  export type PublishedRuntimeSnapshot<T extends ManifestoDomainShape = ManifestoDomainShape> = {
66
- readonly publishedSnapshot: Snapshot<T["state"]>;
69
+ readonly publishedSnapshot: ProjectedSnapshot<T>;
67
70
  readonly publishedCanonicalSnapshot: CanonicalSnapshot<T["state"]>;
68
71
  };
69
72
  export interface RuntimePublicationHelpers<T extends ManifestoDomainShape> {
70
73
  readonly replaceVisibleSnapshot: RuntimeStateStore<T>["setVisibleSnapshot"];
71
74
  readonly restoreVisibleSnapshot: RuntimeStateStore<T>["restoreVisibleSnapshot"];
72
- readonly publishCompletedHostResult: (intent: TypedIntent<T>, snapshot: CoreSnapshot) => PublishedRuntimeSnapshot<T>;
73
- readonly publishFailedHostResult: (intent: TypedIntent<T>, error: Error, snapshot: CoreSnapshot) => PublishedRuntimeSnapshot<T>;
75
+ readonly publishCompletedHostResult: (snapshot: CoreSnapshot) => PublishedRuntimeSnapshot<T>;
76
+ readonly publishFailedHostResult: (snapshot: CoreSnapshot) => PublishedRuntimeSnapshot<T>;
74
77
  }
@@ -1,3 +1,3 @@
1
1
  import type { ManifestoDomainShape } from "../types.js";
2
2
  import type { RuntimeKernel, RuntimeKernelOptions } from "../compat/internal.js";
3
- export declare function createRuntimeKernel<T extends ManifestoDomainShape>({ schema, projectionPlan, host, hostContextProvider, MEL, createIntent, }: RuntimeKernelOptions<T>): RuntimeKernel<T>;
3
+ export declare function createRuntimeKernel<T extends ManifestoDomainShape>({ schema, projectionPlan, actionAnnotations, host, hostContextProvider, MEL, createIntent, initialContext, }: RuntimeKernelOptions<T>): RuntimeKernel<T>;
@@ -1,13 +1,12 @@
1
1
  import type { Snapshot as CoreSnapshot } from "@manifesto-ai/core";
2
- import type { CanonicalSnapshot, ManifestoDomainShape, ManifestoEventMap, Snapshot } from "../types.js";
2
+ import type { CanonicalSnapshot, ManifestoDomainShape, ProjectedSnapshot } from "../types.js";
3
3
  import type { RuntimePublicationHelpers } from "./facets.js";
4
4
  type RuntimePublicationOptions<T extends ManifestoDomainShape> = {
5
5
  readonly setVisibleSnapshot: (snapshot: CoreSnapshot, options?: {
6
6
  readonly notify?: boolean;
7
- }) => Snapshot<T["state"]>;
7
+ }) => ProjectedSnapshot<T>;
8
8
  readonly restoreVisibleSnapshot: () => void;
9
9
  readonly getCanonicalSnapshot: () => CanonicalSnapshot<T["state"]>;
10
- readonly emitEvent: <K extends keyof ManifestoEventMap<T>>(event: K, payload: ManifestoEventMap<T>[K]) => void;
11
10
  };
12
- export declare function createRuntimePublication<T extends ManifestoDomainShape>({ setVisibleSnapshot, restoreVisibleSnapshot, getCanonicalSnapshot, emitEvent, }: RuntimePublicationOptions<T>): RuntimePublicationHelpers<T>;
11
+ export declare function createRuntimePublication<T extends ManifestoDomainShape>({ setVisibleSnapshot, restoreVisibleSnapshot, getCanonicalSnapshot, }: RuntimePublicationOptions<T>): RuntimePublicationHelpers<T>;
13
12
  export {};
@@ -1,10 +1,10 @@
1
1
  import type { Snapshot as CoreSnapshot } from "@manifesto-ai/core";
2
- import type { CanonicalSnapshot, ManifestoDomainShape, Snapshot } from "../types.js";
2
+ import type { CanonicalSnapshot, ChangedPath, ManifestoDomainShape, ProjectedSnapshot, Snapshot } from "../types.js";
3
3
  import type { RuntimeReportHelpers } from "./facets.js";
4
4
  type RuntimeReportHelperOptions<T extends ManifestoDomainShape> = {
5
5
  readonly getAvailableActionsFor: (snapshot: CanonicalSnapshot<T["state"]>) => readonly (keyof T["actions"])[];
6
- readonly projectSnapshotFromCanonical: (snapshot: CoreSnapshot) => Snapshot<T["state"]>;
6
+ readonly projectSnapshotFromCanonical: (snapshot: CoreSnapshot) => ProjectedSnapshot<T>;
7
7
  };
8
8
  export declare function createRuntimeReportHelpers<T extends ManifestoDomainShape>({ getAvailableActionsFor, projectSnapshotFromCanonical, }: RuntimeReportHelperOptions<T>): RuntimeReportHelpers<T>;
9
- export declare function diffProjectedPaths<T>(left: Snapshot<T>, right: Snapshot<T>): readonly string[];
9
+ export declare function diffProjectedPaths<T>(left: Snapshot<T>, right: Snapshot<T>): readonly ChangedPath[];
10
10
  export {};
@@ -9,7 +9,7 @@ type RuntimeSimulationOptions<T extends ManifestoDomainShape> = {
9
9
  readonly evaluateIntentLegalityFor: (snapshot: CanonicalSnapshot<T["state"]>, intent: TypedIntent<T>) => IntentLegalityEvaluation<T>;
10
10
  };
11
11
  export declare function createRuntimeSimulation<T extends ManifestoDomainShape>({ schema, hostContextProvider, evaluateIntentLegalityFor, }: RuntimeSimulationOptions<T>): Readonly<{
12
- withHostIntentSlot: (snapshot: CoreSnapshot, intent: TypedIntent<T>, context: ReturnType<HostContextProvider["createFrozenContext"]>) => CoreSnapshot;
12
+ withHostIntentSlot: (snapshot: CoreSnapshot, intent: TypedIntent<T>) => CoreSnapshot;
13
13
  createSimulationUnavailableError: (intent: TypedIntent<T>) => ManifestoError;
14
14
  createSimulationNotDispatchableError: (intent: TypedIntent<T>) => ManifestoError;
15
15
  simulateSync: RuntimeSimulateSync<T>;
@@ -5,7 +5,7 @@ import type { RuntimeStateStore } from "./facets.js";
5
5
  type RuntimeStateStoreOptions<T extends ManifestoDomainShape> = {
6
6
  readonly host: ManifestoHost;
7
7
  readonly initialCanonicalSnapshot: CoreSnapshot;
8
- readonly projectSnapshotFromCanonical: (snapshot: CoreSnapshot) => Snapshot<T["state"]>;
8
+ readonly projectSnapshotFromCanonical: (snapshot: CoreSnapshot) => Snapshot<T["state"], T["computed"]>;
9
9
  };
10
10
  export declare function createRuntimeStateStore<T extends ManifestoDomainShape>({ host, initialCanonicalSnapshot, projectSnapshotFromCanonical, }: RuntimeStateStoreOptions<T>): RuntimeStateStore<T>;
11
11
  export {};