@oomol-lab/open-flow 0.1.0-beta.78 → 0.1.0-beta.79

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 (35) hide show
  1. package/dist/browser/{createResourceDialog-DCGxfKFM.js → createResourceDialog-DkovGogv.js} +2 -2
  2. package/dist/browser/{dialog-WzR4CRFH.js → dialog-CFFuRM8s.js} +27 -6
  3. package/dist/browser/{flowChanges-Bz4dbDN_.js → flowChanges-CN2R-m1M.js} +59 -40
  4. package/dist/browser/{flowWorkspace-BI6L6a4r.js → flowWorkspace-CXVL1FNv.js} +85 -39
  5. package/dist/browser/preview.js +122 -48
  6. package/dist/browser/{typeScriptSession-CRoezJPN.js → typeScriptSession-CoEIptNC.js} +1 -1
  7. package/dist/browser/workbench.js +4 -4
  8. package/dist/browser/{workbenchSelect-DtAd0zc4.js → workbenchSelect-CkOS95gX.js} +1 -1
  9. package/dist/command/index.js +29 -29
  10. package/dist/common/control-api-conformance.js +80 -7
  11. package/dist/common/control-api.d.ts +3 -2
  12. package/dist/common/control-api.js +40 -7
  13. package/dist/common/control-requests.d.ts +5 -0
  14. package/dist/common/control-requests.js +28 -5
  15. package/dist/common/flow-authoring.js +26 -5
  16. package/dist/common/flow-change.js +26 -5
  17. package/dist/common/flow-encoding.js +26 -5
  18. package/dist/common/flow-semantics.js +26 -5
  19. package/dist/common/flow-state.d.ts +33 -4
  20. package/dist/common/flow-state.js +49 -6
  21. package/dist/common/mcp.d.ts +32 -1
  22. package/dist/common/mcp.js +40 -8
  23. package/dist/common/runtime-contract.d.ts +4 -1
  24. package/dist/common/runtime-contract.js +60 -5
  25. package/dist/common/scheduler.js +26 -5
  26. package/dist/index.d.ts +1 -0
  27. package/package.json +1 -1
  28. package/src/control/common/api.ts +16 -4
  29. package/src/control/common/conformance.ts +31 -0
  30. package/src/control/common/mcp.ts +7 -2
  31. package/src/control/common/requests.ts +3 -0
  32. package/src/runtime/common/runtime.ts +39 -5
  33. package/src/state/common/conformance.ts +16 -0
  34. package/src/state/common/state.ts +41 -8
  35. package/src/types/index.ts +1 -0
@@ -5,14 +5,24 @@ import { z } from 'zod'
5
5
  export { stateConformanceCases, type StateConformanceHarness } from './conformance.ts'
6
6
 
7
7
  export type StateScope = 'draft' | 'live'
8
- export const stateQuerySchema = z.strictObject({ scope: z.enum(['draft', 'live']), values: z.boolean().optional() })
9
- export const stateClearSchema = z.strictObject({
8
+ export const stateReadLimits = { maxKeys: 16, maxBytes: 1024 * 1024 }
9
+ const keySchema = z
10
+ .string()
11
+ .min(1)
12
+ .refine((value) => new TextEncoder().encode(value).length <= 256)
13
+ export const stateQuerySchema = z.strictObject({ scope: z.enum(['draft', 'live']), values: z.literal(false).optional() })
14
+ export const stateReadSchema = z.strictObject({
10
15
  scope: z.enum(['draft', 'live']),
11
- key: z
12
- .string()
16
+ keys: z
17
+ .array(keySchema)
13
18
  .min(1)
14
- .refine((key) => new TextEncoder().encode(key).length <= 256)
15
- .optional(),
19
+ .max(stateReadLimits.maxKeys)
20
+ .refine((keys) => new Set(keys).size === keys.length, 'State keys must be distinct.'),
21
+ })
22
+ export type StateRead = z.infer<typeof stateReadSchema>
23
+ export const stateClearSchema = z.strictObject({
24
+ scope: z.enum(['draft', 'live']),
25
+ key: keySchema.optional(),
16
26
  })
17
27
  export const dedupeClearSchema = z.strictObject({ scope: z.enum(['draft', 'live']), space: z.string().regex(/^(flow|node:.+)$/) })
18
28
  export type DedupeIdentity = string | number
@@ -108,7 +118,7 @@ export interface FlowStateView {
108
118
  readonly maxIdentities: number
109
119
  readonly maxRunWrites: number
110
120
  }
111
- readonly values: readonly { readonly key: string; readonly size: number; readonly updatedAt: number; readonly value?: JsonValue }[]
121
+ readonly values: readonly { readonly key: string; readonly size: number; readonly updatedAt: number }[]
112
122
  readonly spaces: readonly {
113
123
  readonly space: string
114
124
  readonly count: number
@@ -128,7 +138,7 @@ export const flowStateViewSchema = z.object({
128
138
  maxIdentities: z.number().positive(),
129
139
  maxRunWrites: z.number().positive(),
130
140
  }),
131
- values: z.array(z.object({ key: z.string(), size: z.number().nonnegative(), updatedAt: z.number(), value: z.json().optional() })),
141
+ values: z.array(z.strictObject({ key: z.string(), size: z.number().nonnegative(), updatedAt: z.number() })),
132
142
  spaces: z.array(
133
143
  z.object({
134
144
  space: z.string(),
@@ -139,3 +149,26 @@ export const flowStateViewSchema = z.object({
139
149
  }),
140
150
  ),
141
151
  })
152
+
153
+ export interface FlowStateValues {
154
+ readonly version: 1
155
+ readonly scope: StateScope
156
+ readonly values: readonly { readonly key: string; readonly value: JsonValue }[]
157
+ }
158
+
159
+ export const flowStateValuesSchema = z
160
+ .object({
161
+ version: z.literal(1),
162
+ scope: z.enum(['draft', 'live']),
163
+ values: z
164
+ .array(z.strictObject({ key: keySchema, value: z.json() }))
165
+ .min(1)
166
+ .max(stateReadLimits.maxKeys),
167
+ })
168
+ .refine((response) => {
169
+ const encoder = new TextEncoder()
170
+ return (
171
+ response.values.reduce((bytes, item) => bytes + (item.value === null ? 0 : encoder.encode(JSON.stringify(item.value)).byteLength), 0) <=
172
+ stateReadLimits.maxBytes
173
+ )
174
+ }, 'State values exceed the 1 MiB read limit.')
@@ -121,6 +121,7 @@ export interface TaskContext<
121
121
  readonly blockId: string
122
122
  readonly state: {
123
123
  get(key: string): Promise<JsonValue | null>
124
+ get(keys: readonly string[]): Promise<(JsonValue | null)[]>
124
125
  set(key: string, value: JsonValue): Promise<void>
125
126
  insert(key: string, value: Exclude<JsonValue, null>): Promise<boolean>
126
127
  delete(key: string): Promise<void>