@miadi/stateloom-web 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/server/.next/BUILD_ID +1 -1
- package/server/.next/build-manifest.json +2 -2
- package/server/.next/server/app/_global-error.html +2 -2
- package/server/.next/server/app/_global-error.rsc +1 -1
- package/server/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/server/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/server/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/server/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/server/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/server/.next/server/app/_not-found.html +1 -1
- package/server/.next/server/app/_not-found.rsc +1 -1
- package/server/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/server/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/server/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/server/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/server/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/server/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/server/.next/server/app/index.html +1 -1
- package/server/.next/server/app/index.rsc +2 -2
- package/server/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/server/.next/server/app/index.segments/_full.segment.rsc +2 -2
- package/server/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/server/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/server/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/server/.next/server/app/page_client-reference-manifest.js +1 -1
- package/server/.next/server/chunks/ssr/[root-of-the-server]__edbb995c._.js +4 -4
- package/server/.next/server/pages/404.html +1 -1
- package/server/.next/server/pages/500.html +2 -2
- package/server/.next/static/chunks/56e82acb03b39fde.js +11 -0
- package/server/package-lock.json +2 -2
- package/server/package.json +1 -1
- package/server/src/components/PropertiesPanel.tsx +10 -0
- package/server/src/components/erd/ErdWorkspace.tsx +3 -2
- package/server/src/components/sequence/SequenceWorkspace.tsx +2 -1
- package/server/src/lib/systemLoad.ts +4 -3
- package/server/src/store/useDesignerStore.ts +14 -4
- package/server/src/types/definition.ts +2 -0
- package/server/stateloom-web.json +2 -2
- package/server/.next/static/chunks/8458f462f4687e07.js +0 -11
- /package/server/.next/static/{KjjOvPCIL-ta0AZ8r8SFk → 1WAhhGZT7SAtxrGNolq7i}/_buildManifest.js +0 -0
- /package/server/.next/static/{KjjOvPCIL-ta0AZ8r8SFk → 1WAhhGZT7SAtxrGNolq7i}/_clientMiddlewareManifest.json +0 -0
- /package/server/.next/static/{KjjOvPCIL-ta0AZ8r8SFk → 1WAhhGZT7SAtxrGNolq7i}/_ssgManifest.js +0 -0
package/server/package-lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@miadi/stateloom-web-source",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@miadi/stateloom-web-source",
|
|
9
|
-
"version": "0.2.
|
|
9
|
+
"version": "0.2.2",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@miadi/stateloom-canvas": "file:../bridge-canvas",
|
|
12
12
|
"@miadi/stateloom-client": "file:../bridge-client",
|
package/server/package.json
CHANGED
|
@@ -116,6 +116,16 @@ export default function PropertiesPanel() {
|
|
|
116
116
|
onChange={(e) => updateState(selection.id!, { description: e.target.value || undefined })}
|
|
117
117
|
/>
|
|
118
118
|
</label>
|
|
119
|
+
{/* Prompt: what an agent is asked to resolve while the machine is in this state. */}
|
|
120
|
+
<label className="block">
|
|
121
|
+
<span className="text-xs text-gray-500">Prompt for the agent in this state</span>
|
|
122
|
+
<textarea
|
|
123
|
+
className="w-full bg-gray-800 border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 h-20"
|
|
124
|
+
placeholder="What the agent resolves here, and how it opens…"
|
|
125
|
+
value={state.prompt ?? ""}
|
|
126
|
+
onChange={(e) => updateState(selection.id!, { prompt: e.target.value || undefined })}
|
|
127
|
+
/>
|
|
128
|
+
</label>
|
|
119
129
|
{/* Notes: what was said about this state, kept in the document for whoever opens it next. */}
|
|
120
130
|
<label className="block">
|
|
121
131
|
<span className="text-xs text-gray-500">Notes</span>
|
|
@@ -52,6 +52,7 @@ import {
|
|
|
52
52
|
type LayoutBox,
|
|
53
53
|
type StateMachineDefinition,
|
|
54
54
|
type Viewport,
|
|
55
|
+
normalizeNotes,
|
|
55
56
|
} from "@miadi/stateloom-protocol";
|
|
56
57
|
import BoardBoundary from "@/components/BoardBoundary";
|
|
57
58
|
import DocSwitcher from "@/components/DocSwitcher";
|
|
@@ -124,7 +125,7 @@ async function siblingMachines(docPath: string): Promise<Machine[]> {
|
|
|
124
125
|
try {
|
|
125
126
|
const body = await (await fetch(`/api/file${docQuery(path)}`, { cache: "no-store" })).json();
|
|
126
127
|
const parsed = JSON.parse(body.content ?? "null");
|
|
127
|
-
const def = parsed?.stateMachine ?? parsed?.StateMachine ?? parsed;
|
|
128
|
+
const def = normalizeNotes(parsed?.stateMachine ?? parsed?.StateMachine ?? parsed);
|
|
128
129
|
if (def?.state) machines.push({ path, def });
|
|
129
130
|
} catch {
|
|
130
131
|
// An unreadable sibling is skipped; it is not this document's problem.
|
|
@@ -186,7 +187,7 @@ export default function ErdWorkspace() {
|
|
|
186
187
|
const path: string = body.path ?? "";
|
|
187
188
|
let loaded: EntityRelationshipDefinition | null = null;
|
|
188
189
|
try {
|
|
189
|
-
const parsed = body.content ? JSON.parse(body.content) : null;
|
|
190
|
+
const parsed = body.content ? normalizeNotes(JSON.parse(body.content)) : null;
|
|
190
191
|
if (isErdDefinition(parsed)) loaded = { ...parsed, relationships: parsed.relationships ?? [] };
|
|
191
192
|
} catch {
|
|
192
193
|
// Falls through to the unreadable-document message below.
|
|
@@ -58,6 +58,7 @@ import {
|
|
|
58
58
|
type SqdMessage,
|
|
59
59
|
type StateMachineDefinition,
|
|
60
60
|
type Viewport,
|
|
61
|
+
normalizeNotes,
|
|
61
62
|
} from "@miadi/stateloom-protocol";
|
|
62
63
|
import DocSwitcher from "@/components/DocSwitcher";
|
|
63
64
|
import IssueIcon from "@/components/IssueIcon";
|
|
@@ -141,7 +142,7 @@ export default function SequenceWorkspace() {
|
|
|
141
142
|
const path: string = body.path ?? "";
|
|
142
143
|
let loaded: SequenceDefinition | null = null;
|
|
143
144
|
try {
|
|
144
|
-
const parsed = body.content ? JSON.parse(body.content) : null;
|
|
145
|
+
const parsed = body.content ? normalizeNotes(JSON.parse(body.content)) : null;
|
|
145
146
|
if (isSequenceDefinition(parsed)) loaded = parsed;
|
|
146
147
|
} catch {
|
|
147
148
|
// Falls through to the message below.
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
type StateMachineDefinition,
|
|
25
25
|
type SystemDefinition,
|
|
26
26
|
type SystemReconcile,
|
|
27
|
+
normalizeNotes,
|
|
27
28
|
} from "@miadi/stateloom-protocol";
|
|
28
29
|
import { createBridgeClient } from "@miadi/stateloom-client";
|
|
29
30
|
import { docQuery } from "./docParam";
|
|
@@ -94,7 +95,7 @@ export async function loadSystem(systemPath: string): Promise<LoadedSystem> {
|
|
|
94
95
|
if (!read.exists || !read.content) return { ...empty, error: `${systemPath} does not exist` };
|
|
95
96
|
let def: SystemDefinition | null = null;
|
|
96
97
|
try {
|
|
97
|
-
const parsed = JSON.parse(read.content);
|
|
98
|
+
const parsed = normalizeNotes(JSON.parse(read.content));
|
|
98
99
|
if (isSystemDefinition(parsed)) def = parsed;
|
|
99
100
|
} catch {
|
|
100
101
|
// Reported below.
|
|
@@ -119,9 +120,9 @@ export async function loadSystem(systemPath: string): Promise<LoadedSystem> {
|
|
|
119
120
|
const parsed = JSON.parse(doc.content);
|
|
120
121
|
if (kind === "machine" && parsed && (parsed.stateMachine || parsed.StateMachine)) {
|
|
121
122
|
wrapped[m.path] = true;
|
|
122
|
-
return { path: m.path, kind, def: parsed.stateMachine ?? parsed.StateMachine };
|
|
123
|
+
return { path: m.path, kind, def: normalizeNotes(parsed.stateMachine ?? parsed.StateMachine) };
|
|
123
124
|
}
|
|
124
|
-
return { path: m.path, kind, def: parsed };
|
|
125
|
+
return { path: m.path, kind, def: normalizeNotes(parsed) };
|
|
125
126
|
} catch (e) {
|
|
126
127
|
return { path: m.path, kind, def: null, error: `not JSON: ${e instanceof Error ? e.message : String(e)}` };
|
|
127
128
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { create } from "zustand";
|
|
2
|
-
import { applyPatchOps } from "@miadi/stateloom-protocol";
|
|
2
|
+
import { applyPatchOps, normalizeNotes } from "@miadi/stateloom-protocol";
|
|
3
3
|
import type { PatchOp, Presence } from "@miadi/stateloom-protocol";
|
|
4
4
|
import { autoLayout as deriveLayout, IDENTITY_VIEWPORT } from "@miadi/stateloom-react";
|
|
5
5
|
import type { Viewport } from "@miadi/stateloom-react";
|
|
@@ -350,6 +350,13 @@ function autoLayout(def: StateMachineDefinition, existing: DesignerLayout): Desi
|
|
|
350
350
|
|
|
351
351
|
const MAX_UNDO = 50;
|
|
352
352
|
|
|
353
|
+
/**
|
|
354
|
+
* Whether the document on disk was written bare (no `stateMachine` wrapper).
|
|
355
|
+
* Module state, not store state: it says how to write the file back, nothing
|
|
356
|
+
* the interface shows.
|
|
357
|
+
*/
|
|
358
|
+
let bareShape = false;
|
|
359
|
+
|
|
353
360
|
export const useDesignerStore = create<DesignerState>((set, get) => ({
|
|
354
361
|
definition: createEmptyDefinition(),
|
|
355
362
|
layout: autoLayout(createEmptyDefinition(), createDefaultLayout()),
|
|
@@ -667,7 +674,8 @@ export const useDesignerStore = create<DesignerState>((set, get) => ({
|
|
|
667
674
|
loadFromJson: (json, fileName) => {
|
|
668
675
|
try {
|
|
669
676
|
const parsed = JSON.parse(json);
|
|
670
|
-
const def: StateMachineDefinition = parsed.stateMachine ?? parsed.StateMachine ?? parsed;
|
|
677
|
+
const def: StateMachineDefinition = normalizeNotes(parsed.stateMachine ?? parsed.StateMachine ?? parsed);
|
|
678
|
+
bareShape = !!parsed && typeof parsed === "object" && "state" in parsed && !("stateMachine" in parsed) && !("StateMachine" in parsed);
|
|
671
679
|
const layout = autoLayout(def, createDefaultLayout());
|
|
672
680
|
const rootName = def.state?.name ?? "Root";
|
|
673
681
|
set({
|
|
@@ -689,13 +697,15 @@ export const useDesignerStore = create<DesignerState>((set, get) => ({
|
|
|
689
697
|
|
|
690
698
|
exportJson: () => {
|
|
691
699
|
const { definition } = get();
|
|
692
|
-
|
|
700
|
+
// A file that was written bare stays bare, so a save is a small diff.
|
|
701
|
+
return JSON.stringify(bareShape ? definition : { stateMachine: definition }, null, 2);
|
|
693
702
|
},
|
|
694
703
|
|
|
695
704
|
applyRemote: (json, mtime, fileName) => {
|
|
696
705
|
try {
|
|
697
706
|
const parsed = JSON.parse(json);
|
|
698
|
-
const def: StateMachineDefinition = parsed.stateMachine ?? parsed.StateMachine ?? parsed;
|
|
707
|
+
const def: StateMachineDefinition = normalizeNotes(parsed.stateMachine ?? parsed.StateMachine ?? parsed);
|
|
708
|
+
bareShape = !!parsed && typeof parsed === "object" && "state" in parsed && !("stateMachine" in parsed) && !("StateMachine" in parsed);
|
|
699
709
|
const layout = autoLayout(def, get().layout);
|
|
700
710
|
const rootName = def.state?.name ?? "Root";
|
|
701
711
|
|
|
@@ -101,6 +101,8 @@ export interface StateDef {
|
|
|
101
101
|
description?: string;
|
|
102
102
|
/** Working notes about this state: the conversation about it, where `description` says what it is. */
|
|
103
103
|
notes?: string;
|
|
104
|
+
/** What an agent is asked to resolve while the machine is in this state. Ignored by engines and codegen. */
|
|
105
|
+
prompt?: string;
|
|
104
106
|
onEntry?: { actions: ActionDef[] };
|
|
105
107
|
onExit?: { actions: ActionDef[] };
|
|
106
108
|
transitions?: TransitionDef[];
|