inistate-mcp 1.1.0 → 1.1.1

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/README.md CHANGED
@@ -12,6 +12,7 @@ MCP server for the [Inistate](https://inistate.com) platform — module discover
12
12
  | `INISTATE_API_BASE` | No | `https://api.inistate.com` | API base URL |
13
13
  | `INISTATE_MCP_MODE` | No | `configure` | Initial mode: `runtime`, `configure`, or `frontend` (see [Modes](#modes)) |
14
14
  | `INISTATE_MCP_NO_SETUP` | No | — | Set to `1` to force server mode from a terminal (skip the interactive wizard) |
15
+ | `INISTATE_DEBUG_FILE` | No | — | Set to `1` to log write-path tool calls to `./debug.log`, or to a path to log there. Off by default; logs identifiers only, never field values |
15
16
 
16
17
  ### Install from npm (recommended)
17
18
 
@@ -140,13 +141,12 @@ Tools and resources marked **(configure)** / **(frontend)** are absent from the
140
141
 
141
142
  ## Typical Workflow
142
143
 
143
- 1. `list_workspaces` → `set_workspace` — select a workspace
144
- 2. `list_modules` — find the module you need
145
- 3. `get_module_schema` — understand its fields, states, and activities
146
- 4. `get_form` — discover required fields before submitting
147
- 5. `submit_activity` — create or update entries
148
- 6. `list_entries` — query and browse data
149
- 7. `get_entry_history` — review entry history
144
+ 1. `list_workspaces` → `set_workspace` — select a workspace (auto-selected when exactly one matches; both return the workspace's module list, so `list_modules` is only needed to refresh)
145
+ 2. `get_module_schema` — understand a module's fields, states, and activities
146
+ 3. `get_form` — discover required fields before the first submission per (module, activity); reuse its schema for further entries
147
+ 4. `submit_activity` — create or update entries (`submit_activities` for bulk)
148
+ 5. `list_entries` — query and browse data (use the `fields` parameter to keep payloads small)
149
+ 6. `get_entry_history` — review entry history
150
150
 
151
151
  ## Development
152
152
 
@@ -155,6 +155,58 @@ npm run watch # Watch mode for TypeScript compilation
155
155
  npm run inspector # Test with MCP Inspector
156
156
  ```
157
157
 
158
+ ### MCP Setup
159
+ 1. Setup
160
+ ```bash
161
+ curl -L "https://github.com/modelcontextprotocol/registry/releases/latest/download/mcp-publisher_$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/').tar.gz" | tar xz mcp-publisher && sudo mv mcp-publisher /usr/local/bin/
162
+ ```
163
+
164
+ or
165
+
166
+ ```powershell
167
+ $arch = if ([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture -eq "Arm64") { "arm64" } else { "amd64" }; Invoke-WebRequest -Uri "https://github.com/modelcontextprotocol/registry/releases/latest/download/mcp-publisher_windows_$arch.tar.gz" -OutFile "mcp-publisher.tar.gz"; tar xf mcp-publisher.tar.gz mcp-publisher.exe; rm mcp-publisher.tar.gz
168
+
169
+ ```
170
+
171
+ 2. Verify
172
+ ```
173
+ mcp-publisher --help
174
+ ```
175
+
176
+ 3. Authenticate
177
+ ```
178
+ mcp-publisher login github
179
+ ```
180
+
181
+ 4. Publish: see below
182
+
183
+ ### Packaging & Versioning
184
+ ```bash
185
+ # Example adding new feature
186
+ git checkout -b feat/add-user-tool
187
+
188
+
189
+ # After coding
190
+ npx changeset
191
+
192
+ # Choose:
193
+ #
194
+ # minor
195
+ # Added new user search tool
196
+
197
+ # Release
198
+ npm run release
199
+
200
+ # This does:
201
+ # install dependencies
202
+ # test
203
+ # bump version + update changelog + sync server.json
204
+ # validate MCP server config
205
+ # build (via npm prepare hook)
206
+ # publish to npm
207
+ # publish to MCP registry
208
+ ```
209
+
158
210
  ## PM2 (Ubuntu/AWS)
159
211
 
160
212
  Run the HTTP transport in production using PM2:
@@ -19,8 +19,14 @@ interface FieldInfo {
19
19
  type: string;
20
20
  }
21
21
  interface ExtendedSchema {
22
- activities?: ActivityDef[];
22
+ activities?: Array<ActivityDef | string>;
23
23
  information?: FieldInfo[];
24
+ states?: Array<string | {
25
+ name?: string;
26
+ }>;
27
+ }
28
+ interface CanvasSchema {
29
+ activities?: ActivityDef[];
24
30
  }
25
31
  /**
26
32
  * Source of a module's extended schema. Defaults to the cloud API; the MCP tool
@@ -28,6 +34,24 @@ interface ExtendedSchema {
28
34
  * backend is injected (cloud or local) instead of always hitting api.ts.
29
35
  */
30
36
  export type SchemaFetcher = (moduleName: string) => Promise<ExtendedSchema | null>;
37
+ /**
38
+ * Warm the schema cache in the background (fire-and-forget). Called from
39
+ * get_form so the guard/shape lookups on the submit_activity that typically
40
+ * follows hit cache instead of paying an extra round trip ahead of the write.
41
+ */
42
+ export declare function primeSchemaCache(moduleName: string, fetchSchema?: SchemaFetcher): void;
43
+ /**
44
+ * Seed the schema cache with an extended schema the caller already fetched
45
+ * (e.g. the get_module_schema tool's own tier=extended response), so the
46
+ * guard does not re-fetch what just passed through this process.
47
+ */
48
+ export declare function seedSchemaCache(moduleName: string, schema: unknown): void;
49
+ /**
50
+ * Source of a module's canvas (actor data). Like SchemaFetcher, the tool
51
+ * handlers pass a backend-routed fetcher so the actor fallback works against
52
+ * whatever backend is injected; the default hits the cloud API.
53
+ */
54
+ export type CanvasFetcher = (moduleName: string) => Promise<CanvasSchema | null>;
31
55
  interface FlaggedRecord {
32
56
  confidence: number;
33
57
  at: number;
@@ -50,13 +74,18 @@ export type GuardOutcome = {
50
74
  ok: false;
51
75
  structured: Record<string, unknown>;
52
76
  };
53
- export declare function evaluateActivity(input: GuardInput, fetchSchema?: SchemaFetcher): Promise<GuardOutcome>;
77
+ export declare function evaluateActivity(input: GuardInput, fetchSchema?: SchemaFetcher, fetchCanvas?: CanvasFetcher): Promise<GuardOutcome>;
54
78
  export interface RefShapeError {
55
79
  field: string;
56
80
  type: string;
57
81
  message: string;
58
82
  received: unknown;
59
83
  }
84
+ /**
85
+ * State names for a module, from the cached extended schema. Tolerates both
86
+ * string[] and [{name}] shapes; null when unavailable (let the API decide).
87
+ */
88
+ export declare function getModuleStates(moduleName: string, fetchSchema?: SchemaFetcher): Promise<string[] | null>;
60
89
  /**
61
90
  * Build a field-name → field-type map for a module. Returns null when the
62
91
  * schema cannot be loaded (callers should let the server decide). The
@@ -80,5 +109,14 @@ export declare function validateInputShapesWith(types: Map<string, string> | nul
80
109
  * directly.
81
110
  */
82
111
  export declare function validateInputShapes(moduleName: string, input: Record<string, unknown> | undefined | null, fetchSchema?: SchemaFetcher): Promise<RefShapeError[]>;
112
+ /**
113
+ * Annotation merged into platform responses that carry `flagged: true`. The
114
+ * platform itself returns the bare flag with no explanation — without this,
115
+ * agents loop retrying with higher confidence or `confirmed: true`.
116
+ */
117
+ export declare const FLAGGED_ANNOTATION: {
118
+ readonly flag_reason: "Flagged submissions are recorded as intentions pending human review — the state transition did NOT occur. Causes: ai.confidence below the activity's confidence_threshold, or the activity's actor does not permit AI execution.";
119
+ readonly agent_action: "Do not retry with a higher confidence. Report the flag to the user; a human can complete the activity in Inistate.";
120
+ };
83
121
  export declare function __resetGuardCaches(): void;
84
122
  export {};
@@ -3,6 +3,8 @@ import { requestContext } from "./context.js";
3
3
  const REF_FIELD_TYPES = new Set(["User", "Users", "Module", "Modules"]);
4
4
  // Standard activities are inherent platform operations and have no actor in the
5
5
  // module schema. They bypass the actor check (but state-change checks still run).
6
+ // The platform uses both names for the direct state change — availableActivities
7
+ // lists "changeState" while forms and history say "changeStatus".
6
8
  const STANDARD_ACTIVITIES = new Set([
7
9
  "create",
8
10
  "edit",
@@ -12,6 +14,7 @@ const STANDARD_ACTIVITIES = new Set([
12
14
  "manage",
13
15
  "view",
14
16
  "changeStatus",
17
+ "changeState",
15
18
  ]);
16
19
  const SCHEMA_TTL_MS = 5 * 60 * 1000;
17
20
  const schemaCache = new Map();
@@ -40,9 +43,59 @@ async function getExtendedSchema(moduleName, fetchSchema = defaultSchemaFetcher)
40
43
  schemaCache.set(key, { schema, at: now });
41
44
  return schema;
42
45
  }
43
- async function getActivityDef(moduleName, activity, fetchSchema = defaultSchemaFetcher) {
46
+ /**
47
+ * Warm the schema cache in the background (fire-and-forget). Called from
48
+ * get_form so the guard/shape lookups on the submit_activity that typically
49
+ * follows hit cache instead of paying an extra round trip ahead of the write.
50
+ */
51
+ export function primeSchemaCache(moduleName, fetchSchema = defaultSchemaFetcher) {
52
+ void getExtendedSchema(moduleName, fetchSchema).catch(() => { });
53
+ }
54
+ /**
55
+ * Seed the schema cache with an extended schema the caller already fetched
56
+ * (e.g. the get_module_schema tool's own tier=extended response), so the
57
+ * guard does not re-fetch what just passed through this process.
58
+ */
59
+ export function seedSchemaCache(moduleName, schema) {
60
+ if (!schema || typeof schema !== "object")
61
+ return;
62
+ schemaCache.set(cacheKey("schema", [moduleName]), {
63
+ schema: schema,
64
+ at: Date.now(),
65
+ });
66
+ }
67
+ const canvasCache = new Map();
68
+ const defaultCanvasFetcher = async (moduleName) => {
69
+ try {
70
+ return (await api.get(`/api/configure/${api.enc(moduleName)}`));
71
+ }
72
+ catch {
73
+ return null;
74
+ }
75
+ };
76
+ async function getCanvasSchema(moduleName, fetchCanvas = defaultCanvasFetcher) {
77
+ const key = cacheKey("canvas", [moduleName]);
78
+ const now = Date.now();
79
+ const cached = canvasCache.get(key);
80
+ if (cached && now - cached.at < SCHEMA_TTL_MS)
81
+ return cached.canvas;
82
+ // Cache the miss too — a caller without configure access would otherwise
83
+ // pay a failing round trip on every submit.
84
+ const canvas = await fetchCanvas(moduleName);
85
+ canvasCache.set(key, { canvas, at: now });
86
+ return canvas;
87
+ }
88
+ async function getActivityDef(moduleName, activity, fetchSchema = defaultSchemaFetcher, fetchCanvas = defaultCanvasFetcher) {
44
89
  const schema = await getExtendedSchema(moduleName, fetchSchema);
45
- return schema?.activities?.find((a) => a.name === activity) ?? null;
90
+ for (const a of schema?.activities ?? []) {
91
+ if (a && typeof a === "object" && a.name === activity) {
92
+ if (a.actor)
93
+ return a;
94
+ break; // listed without actor info — consult the canvas
95
+ }
96
+ }
97
+ const canvas = await getCanvasSchema(moduleName, fetchCanvas);
98
+ return canvas?.activities?.find((a) => a && typeof a === "object" && a.name === activity) ?? null;
46
99
  }
47
100
  const FLAG_TTL_MS = 60 * 60 * 1000;
48
101
  const flaggedCache = new Map();
@@ -66,7 +119,7 @@ export function getPriorFlag(moduleName, entryId, activity) {
66
119
  }
67
120
  return rec;
68
121
  }
69
- export async function evaluateActivity(input, fetchSchema = defaultSchemaFetcher) {
122
+ export async function evaluateActivity(input, fetchSchema = defaultSchemaFetcher, fetchCanvas = defaultCanvasFetcher) {
70
123
  const { module: moduleName, activity, entryId, entryIds, state, confidence, confirmed } = input;
71
124
  // Rule 1 — confidence inflation after a prior flag.
72
125
  const targets = entryIds && entryIds.length > 0 ? entryIds : [entryId];
@@ -87,13 +140,31 @@ export async function evaluateActivity(input, fetchSchema = defaultSchemaFetcher
87
140
  };
88
141
  }
89
142
  }
90
- // Rule 2a — `changeStatus` is the explicit state-change override.
91
- if (activity === "changeStatus" && !confirmed) {
143
+ // Rule 2 pre-flight — a target state must exist before any confirmation
144
+ // dance. The platform returns an opaque error for unknown states.
145
+ if (state) {
146
+ const states = await getModuleStates(moduleName, fetchSchema);
147
+ if (states && !states.includes(state)) {
148
+ return {
149
+ ok: false,
150
+ structured: {
151
+ error: "unknown_state",
152
+ message: `State '${state}' does not exist on module '${moduleName}'. Available states: ${states.join(", ")}.`,
153
+ activity,
154
+ state,
155
+ agent_action: "Use one of the listed states, or omit 'state' to follow the activity's normal flow.",
156
+ },
157
+ };
158
+ }
159
+ }
160
+ // Rule 2a — `changeStatus` (alias `changeState`) is the explicit
161
+ // state-change override.
162
+ if ((activity === "changeStatus" || activity === "changeState") && !confirmed) {
92
163
  return {
93
164
  ok: false,
94
165
  structured: {
95
166
  error: "state_change_requires_confirmation",
96
- message: "The 'changeStatus' activity bypasses the workflow to change an entry's state directly. AI agents must not call it on their own initiative.",
167
+ message: `The '${activity}' activity bypasses the workflow to change an entry's state directly. AI agents must not call it on their own initiative.`,
97
168
  activity,
98
169
  agent_action: "Ask the user explicitly whether to change the entry's state. After they confirm, resubmit with confirmed: true.",
99
170
  },
@@ -115,7 +186,7 @@ export async function evaluateActivity(input, fetchSchema = defaultSchemaFetcher
115
186
  // Rules 3 & 4 apply to custom (workflow-defined) activities only.
116
187
  if (STANDARD_ACTIVITIES.has(activity))
117
188
  return { ok: true };
118
- const def = await getActivityDef(moduleName, activity, fetchSchema);
189
+ const def = await getActivityDef(moduleName, activity, fetchSchema, fetchCanvas);
119
190
  if (!def)
120
191
  return { ok: true }; // unknown activity — let the API decide.
121
192
  const actor = (def.actor || "").toLowerCase();
@@ -206,6 +277,20 @@ function checkRefValue(field, type, value) {
206
277
  }
207
278
  return checkSingleRef(field, type, value);
208
279
  }
280
+ /**
281
+ * State names for a module, from the cached extended schema. Tolerates both
282
+ * string[] and [{name}] shapes; null when unavailable (let the API decide).
283
+ */
284
+ export async function getModuleStates(moduleName, fetchSchema = defaultSchemaFetcher) {
285
+ const schema = await getExtendedSchema(moduleName, fetchSchema);
286
+ const raw = schema?.states;
287
+ if (!Array.isArray(raw) || raw.length === 0)
288
+ return null;
289
+ const names = raw
290
+ .map((s) => (typeof s === "string" ? s : s?.name))
291
+ .filter((n) => typeof n === "string" && n.length > 0);
292
+ return names.length > 0 ? names : null;
293
+ }
209
294
  /**
210
295
  * Build a field-name → field-type map for a module. Returns null when the
211
296
  * schema cannot be loaded (callers should let the server decide). The
@@ -258,8 +343,18 @@ export async function validateInputShapes(moduleName, input, fetchSchema = defau
258
343
  const types = await getModuleFieldTypes(moduleName, fetchSchema);
259
344
  return validateInputShapesWith(types, input);
260
345
  }
346
+ /**
347
+ * Annotation merged into platform responses that carry `flagged: true`. The
348
+ * platform itself returns the bare flag with no explanation — without this,
349
+ * agents loop retrying with higher confidence or `confirmed: true`.
350
+ */
351
+ export const FLAGGED_ANNOTATION = {
352
+ flag_reason: "Flagged submissions are recorded as intentions pending human review — the state transition did NOT occur. Causes: ai.confidence below the activity's confidence_threshold, or the activity's actor does not permit AI execution.",
353
+ agent_action: "Do not retry with a higher confidence. Report the flag to the user; a human can complete the activity in Inistate.",
354
+ };
261
355
  // Test-only helpers.
262
356
  export function __resetGuardCaches() {
263
357
  schemaCache.clear();
358
+ canvasCache.clear();
264
359
  flaggedCache.clear();
265
360
  }
package/build/api.js CHANGED
@@ -111,14 +111,32 @@ async function handleResponse(res) {
111
111
  if (!text)
112
112
  return null;
113
113
  const data = JSON.parse(text);
114
- // §14.8 — truncate large list responses to avoid blowing up agent context
115
- if (text.length > 30_000 &&
114
+ // §14.8 — truncate large list responses to avoid blowing up agent context.
115
+ // Size-aware: keep as many items as fit the byte budget (a fixed item count
116
+ // either overshoots for wide rows or wastes refetches for narrow ones).
117
+ const TRUNCATE_BUDGET = 30_000;
118
+ if (text.length > TRUNCATE_BUDGET &&
116
119
  data &&
117
120
  typeof data === "object" &&
118
- Array.isArray(data.list)) {
119
- data.list = data.list.slice(0, 10);
120
- data._truncated = true;
121
- data._truncated_message = `Response truncated to 10 of ${data.totalItems ?? "unknown"} items. Use pagination (currentPage, pageSize) to retrieve more.`;
121
+ Array.isArray(data.list) &&
122
+ data.list.length > 1) {
123
+ const items = data.list;
124
+ const overhead = text.length - JSON.stringify(items).length;
125
+ const budget = Math.max(TRUNCATE_BUDGET - overhead, 2_000);
126
+ let size = 2;
127
+ let keep = 0;
128
+ for (const item of items) {
129
+ const itemLen = JSON.stringify(item).length + 1;
130
+ if (keep > 0 && size + itemLen > budget)
131
+ break;
132
+ size += itemLen;
133
+ keep++;
134
+ }
135
+ if (keep < items.length) {
136
+ data.list = items.slice(0, keep);
137
+ data._truncated = true;
138
+ data._truncated_message = `Response truncated to ${keep} of ${items.length} items on this page (~30KB cap; ${data.totalItems ?? "unknown"} total). Narrow the payload with the fields parameter (biggest saving) or filters, and paginate with currentPage/pageSize.`;
139
+ }
122
140
  }
123
141
  return data;
124
142
  }
@@ -7,8 +7,10 @@ import type { AuthInfo } from "@modelcontextprotocol/sdk/server/auth/types.js";
7
7
  export declare function decodeJwtSub(jwt: string): string | undefined;
8
8
  declare class InMemoryClientsStore implements OAuthRegisteredClientsStore {
9
9
  private clients;
10
+ constructor();
10
11
  getClient(clientId: string): OAuthClientInformationFull | undefined;
11
12
  registerClient(client: Omit<OAuthClientInformationFull, "client_id" | "client_id_issued_at">): OAuthClientInformationFull;
13
+ dump(): OAuthClientInformationFull[];
12
14
  }
13
15
  export declare class InistateOAuthProvider implements OAuthServerProvider {
14
16
  readonly clientsStore: InMemoryClientsStore;
@@ -36,6 +36,20 @@ function expiresInFromExp(exp) {
36
36
  }
37
37
  class InMemoryClientsStore {
38
38
  clients = new Map();
39
+ constructor() {
40
+ const seed = process.env.OAUTH_KNOWN_CLIENTS;
41
+ if (seed) {
42
+ try {
43
+ for (const client of JSON.parse(seed)) {
44
+ this.clients.set(client.client_id, client);
45
+ }
46
+ console.log(`OAuth client store seeded with ${this.clients.size} client(s)`);
47
+ }
48
+ catch {
49
+ console.error("Failed to parse OAUTH_KNOWN_CLIENTS — must be a JSON array");
50
+ }
51
+ }
52
+ }
39
53
  getClient(clientId) {
40
54
  return this.clients.get(clientId);
41
55
  }
@@ -48,6 +62,9 @@ class InMemoryClientsStore {
48
62
  this.clients.set(full.client_id, full);
49
63
  return full;
50
64
  }
65
+ dump() {
66
+ return [...this.clients.values()];
67
+ }
51
68
  }
52
69
  /* ------------------------------------------------------------------ */
53
70
  /* Provider */
@@ -65,7 +65,7 @@ Standard activities (\`create\`, \`edit\`, \`delete\`, \`comment\`, \`duplicate\
65
65
  }));
66
66
  // 4a. inistate://schema/runtime — runtime operations (default)
67
67
  server.registerResource("schema-runtime", "inistate://schema/runtime", {
68
- description: "DEFAULT resource — load this at session start for runtime operations: listing/reading entries, submitting activities, uploading/downloading files, reading history. Contains only the tools and types needed to USE existing modules: list_entries, get_entry, get_form, submit_activity, get_history, request_upload_url + confirm_upload (ALWAYS the default upload flow), download_file, upload_file (fallback only — use only if the presigned flow fails), plus field value shapes (File/Image/Module/User) and filter operators. Does NOT include module design content — if the user asks to create or update a module, load inistate://schema/configure + inistate://design-guide instead. Loading this AND configure together doubles context cost — pick one.",
68
+ description: "DEFAULT resource — load at session start for runtime work (reading/writing entries, files, history). Reference for what tool schemas don't carry: response/type definitions (entry, form, history), field value shapes (File/Image/Module/User), filter operators, and key workflow rules. Tool inputs are documented on the tools themselves. Does NOT include module design content — for creating/updating modules load inistate://schema/configure + inistate://design-guide instead; loading both doubles context cost, pick one.",
69
69
  mimeType: "application/json",
70
70
  }, async (uri) => {
71
71
  return {
@@ -74,7 +74,7 @@ Standard activities (\`create\`, \`edit\`, \`delete\`, \`comment\`, \`duplicate\
74
74
  });
75
75
  // 4b. inistate://schema/configure — module design & configuration (configure mode)
76
76
  configureResources.push(server.registerResource("schema-configure", "inistate://schema/configure", {
77
- description: "Load ONLY when the user asks to create a new module, edit a module schema, or design a workflow. Contains ModuleSchema write format, FieldDefinition/StateDefinition/ActivityDefinition/FlowDefinition, state color palette with decision rules and keyword hints, module_types (workflow vs record list), and the configure-mode tools (get_module_schema, create_module, update_module). Pair with inistate://design-guide for a complete design context. Do NOT load for runtime data operations — use inistate://schema/runtime instead.",
77
+ description: "Load ONLY when the user asks to create a new module, edit a module schema, or design a workflow. Contains the ModuleSchema write format (Field/State/Activity/Flow definitions), state color palette with decision rules and keyword hints, and module_types (workflow vs record list). Pair with inistate://design-guide for a complete design context. Do NOT load for runtime data operations — use inistate://schema/runtime instead.",
78
78
  mimeType: "application/json",
79
79
  }, async (uri) => {
80
80
  return {
package/build/schema.d.ts CHANGED
@@ -9,9 +9,32 @@ export declare const COLOR_PALETTE: Record<string, string>;
9
9
  export declare const VALID_COLORS: string[];
10
10
  export declare const COLOR_KEYWORDS: Record<string, string[]>;
11
11
  export declare function isValidFieldType(type: string): boolean;
12
+ export declare function isReferenceFieldType(type: string): boolean;
13
+ /** Map a type to its canonical name (case/space/alias tolerant, preserves
14
+ * inline "(...)" option syntax). Unknown types pass through unchanged so
15
+ * validation can report them. */
16
+ export declare function normalizeFieldType(type: string | undefined | null): {
17
+ type: string | undefined;
18
+ changed: boolean;
19
+ };
20
+ /** Snap any color to the palette: exact match passes, color names map by
21
+ * meaning, hex snaps to the nearest palette color, anything else falls back
22
+ * to the keyword suggestion for the state name. Never fails. */
23
+ export declare function normalizeStateColor(color: string | undefined | null, stateName: string): {
24
+ color: string | undefined;
25
+ changed: boolean;
26
+ };
12
27
  export declare function isValidColor(hex: string): boolean;
13
28
  export declare function isValidActor(actor: string): boolean;
14
29
  export declare function suggestColorForState(stateName: string): string;
30
+ /**
31
+ * Resolve local-id references to names, in place. Agents commonly tag
32
+ * states/activities/fields with short ids (s1, a1, f1) and then point flows or
33
+ * activity field refs at those ids; the platform wants names. A ref is only
34
+ * rewritten when it matches a declared id and no declared name, so names
35
+ * always win. Returns one note per rewritten reference.
36
+ */
37
+ export declare function resolveDesignRefs(schema: Record<string, any>): string[];
15
38
  interface ValidationResult {
16
39
  valid: boolean;
17
40
  errors: string[];
@@ -22,7 +45,17 @@ export declare function validateDesign(schema: Record<string, any>, mode?: "crea
22
45
  interface DesignTemplate {
23
46
  template: Record<string, any>;
24
47
  suggestions: Record<string, any>;
48
+ constraints: Record<string, any>;
25
49
  next_step: string;
26
50
  }
51
+ /**
52
+ * Pull an explicitly enumerated state list out of a description, e.g.
53
+ * "Lifecycle states: Proposed, Active, On Hold" / "states like Planning,
54
+ * In Progress" / "status (Draft, Sent, Paid)". Returns [] when none found —
55
+ * callers fall back to the pattern template.
56
+ */
57
+ export declare function parseStatesFromDescription(desc: string): string[];
58
+ /** Map free-text industry to a known key; unknown text falls back to general. */
59
+ export declare function normalizeIndustry(industry?: string | null): string;
27
60
  export declare function designWorkflow(description: string, industry?: string): DesignTemplate;
28
61
  export {};