inistate-mcp 1.5.1 → 1.6.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/build/api.d.ts +13 -1
- package/build/api.js +51 -4
- package/build/http.js +5 -0
- package/build/schema.js +2 -2
- package/build/server-card.d.ts +47 -0
- package/build/server-card.js +35 -0
- package/build/server-identity.d.ts +6 -0
- package/build/server-identity.js +7 -0
- package/build/server.js +23 -12
- package/build/tools.js +223 -97
- package/inistate-schema.json +12 -0
- package/package.json +1 -1
- package/server.json +2 -2
package/build/api.d.ts
CHANGED
|
@@ -30,7 +30,19 @@ export declare function annotateModuleNotFound(message: string): string;
|
|
|
30
30
|
* The next step for the agent after an API error: the server's own when it sends one (it knows why, e.g. a
|
|
31
31
|
* write that may already be saved), else the status's generic one.
|
|
32
32
|
*/
|
|
33
|
-
export declare function errorAgentAction(status: number, body: Record<string, unknown
|
|
33
|
+
export declare function errorAgentAction(status: number, body: Record<string, unknown>, retryAfter?: number | null): string;
|
|
34
|
+
/** The seconds a response's Retry-After asks for (seconds, or an HTTP date), or null when it names none. */
|
|
35
|
+
export declare function retryAfterSeconds(res: Response): number | null;
|
|
36
|
+
/**
|
|
37
|
+
* A rate limit asking for a short wait (the platform's burst limit asks for 1 second) is waited out once here, so
|
|
38
|
+
* a burst of calls slows down instead of failing. Only a 429 that names its wait is retried: the platform's rate
|
|
39
|
+
* limiter sends Retry-After and refuses before the call runs, so the retry cannot run anything twice. A longer
|
|
40
|
+
* wait goes back to the agent with retry_after_seconds. The fields are settable for tests.
|
|
41
|
+
*/
|
|
42
|
+
export declare const rateLimitRetry: {
|
|
43
|
+
maxWaitSeconds: number;
|
|
44
|
+
sleep: (ms: number) => Promise<void>;
|
|
45
|
+
};
|
|
34
46
|
/** What a tool result may weigh, as the compact JSON the tools send (tools.ts `ok`). */
|
|
35
47
|
export declare const TRUNCATE_BUDGET = 30000;
|
|
36
48
|
/**
|
package/build/api.js
CHANGED
|
@@ -104,10 +104,44 @@ export function annotateModuleNotFound(message) {
|
|
|
104
104
|
* The next step for the agent after an API error: the server's own when it sends one (it knows why, e.g. a
|
|
105
105
|
* write that may already be saved), else the status's generic one.
|
|
106
106
|
*/
|
|
107
|
-
export function errorAgentAction(status, body) {
|
|
107
|
+
export function errorAgentAction(status, body, retryAfter = null) {
|
|
108
108
|
const own = body?.agent_action;
|
|
109
|
-
|
|
109
|
+
if (typeof own === "string" && own.trim())
|
|
110
|
+
return own;
|
|
111
|
+
return status === 429 ? rateLimitedAction(retryAfter) : agentAction(status);
|
|
110
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* A 429 is a refusal before the call ran: nothing was read or saved. It used to read "Unexpected error. Report to
|
|
115
|
+
* user." with no wait (QA 2026-11-25, after ~85 calls in a few minutes), so the agent stopped, or retried at once
|
|
116
|
+
* and was refused again.
|
|
117
|
+
*/
|
|
118
|
+
function rateLimitedAction(retryAfter) {
|
|
119
|
+
const wait = retryAfter !== null
|
|
120
|
+
? `Wait ${retryAfter} second${retryAfter === 1 ? "" : "s"} (retry_after_seconds)`
|
|
121
|
+
: "Wait a minute";
|
|
122
|
+
return `Too many calls in a short time: this call was not run, so nothing was read or saved. ${wait}, then make the same call again. `
|
|
123
|
+
+ "To need fewer calls: reuse one get_form answer for every entry of the same module and activity, write many entries with submit_activities, and count or total with aggregate_entries.";
|
|
124
|
+
}
|
|
125
|
+
/** The seconds a response's Retry-After asks for (seconds, or an HTTP date), or null when it names none. */
|
|
126
|
+
export function retryAfterSeconds(res) {
|
|
127
|
+
const raw = res.headers.get("Retry-After")?.trim();
|
|
128
|
+
if (!raw)
|
|
129
|
+
return null;
|
|
130
|
+
if (/^\d+(\.\d+)?$/.test(raw))
|
|
131
|
+
return Math.ceil(Number(raw));
|
|
132
|
+
const at = Date.parse(raw);
|
|
133
|
+
return Number.isNaN(at) ? null : Math.max(0, Math.ceil((at - Date.now()) / 1000));
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* A rate limit asking for a short wait (the platform's burst limit asks for 1 second) is waited out once here, so
|
|
137
|
+
* a burst of calls slows down instead of failing. Only a 429 that names its wait is retried: the platform's rate
|
|
138
|
+
* limiter sends Retry-After and refuses before the call runs, so the retry cannot run anything twice. A longer
|
|
139
|
+
* wait goes back to the agent with retry_after_seconds. The fields are settable for tests.
|
|
140
|
+
*/
|
|
141
|
+
export const rateLimitRetry = {
|
|
142
|
+
maxWaitSeconds: 2,
|
|
143
|
+
sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
|
|
144
|
+
};
|
|
111
145
|
function agentAction(status) {
|
|
112
146
|
switch (status) {
|
|
113
147
|
case 400:
|
|
@@ -137,12 +171,15 @@ async function handleResponse(res) {
|
|
|
137
171
|
catch {
|
|
138
172
|
/* not JSON */
|
|
139
173
|
}
|
|
174
|
+
const retryAfter = res.status === 429 ? retryAfterSeconds(res) : null;
|
|
140
175
|
const error = {
|
|
141
176
|
error: body.error || `HTTP ${res.status}`,
|
|
142
177
|
message: annotateModuleNotFound(String(body.message || text || res.statusText)),
|
|
143
178
|
details: body.details || null,
|
|
144
|
-
agent_action: errorAgentAction(res.status, body),
|
|
179
|
+
agent_action: errorAgentAction(res.status, body, retryAfter),
|
|
145
180
|
};
|
|
181
|
+
if (res.status === 429)
|
|
182
|
+
error.retry_after_seconds = retryAfter;
|
|
146
183
|
log("api_error", { status: res.status, url: res.url, error: error.error, message: error.message, details: error.details });
|
|
147
184
|
// `body` keeps the server's own envelope for the tools that relay it whole
|
|
148
185
|
// (set_module_access: changes, warnings, the server's agent_action). err()
|
|
@@ -221,8 +258,18 @@ async function request(url, init, getHeaders) {
|
|
|
221
258
|
const method = init.method || "GET";
|
|
222
259
|
log("request", { method, url });
|
|
223
260
|
const start = Date.now();
|
|
224
|
-
|
|
261
|
+
let res = await fetch(url, { ...init, headers: getHeaders() });
|
|
225
262
|
log("response", { method, url, status: res.status, ms: Date.now() - start });
|
|
263
|
+
if (res.status === 429) {
|
|
264
|
+
const wait = retryAfterSeconds(res);
|
|
265
|
+
if (wait !== null && wait <= rateLimitRetry.maxWaitSeconds) {
|
|
266
|
+
await res.text().catch(() => undefined);
|
|
267
|
+
log("rate_limited_retry", { method, url, wait });
|
|
268
|
+
await rateLimitRetry.sleep(Math.max(wait, 1) * 1000);
|
|
269
|
+
res = await fetch(url, { ...init, headers: getHeaders() });
|
|
270
|
+
log("response", { method, url, status: res.status, ms: Date.now() - start, retried: true });
|
|
271
|
+
}
|
|
272
|
+
}
|
|
226
273
|
return res;
|
|
227
274
|
}
|
|
228
275
|
export async function get(path) {
|
package/build/http.js
CHANGED
|
@@ -12,6 +12,9 @@ import { requestContext } from "./context.js";
|
|
|
12
12
|
import { InistateOAuthProvider, decodeJwtSub, isConnectionToken, connectionModeKey, browserSecretCookieName, browserSecretCookieOptions, readCookie, SUPPORTED_SCOPES, } from "./oauth-provider.js";
|
|
13
13
|
import { getUserMode } from "./mode-store.js";
|
|
14
14
|
import { registerAppAuthorizeRoutes } from "./authorize-app-routes.js";
|
|
15
|
+
import { registerServerCardRoutes } from "./server-card.js";
|
|
16
|
+
import { readFileSync } from "node:fs";
|
|
17
|
+
const { version: pkgVersion } = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
15
18
|
const PORT = parseInt(process.env.PORT || "3000", 10);
|
|
16
19
|
const BASE_URL = process.env.INISTATE_API_BASE ||
|
|
17
20
|
process.env.INISTATE_API_URL ||
|
|
@@ -85,6 +88,8 @@ app.post("/authorize/callback", express.urlencoded({ extended: false }), (req, r
|
|
|
85
88
|
});
|
|
86
89
|
// SS06370: the Inistate App approves natively (no cookie); the originating browser finishes.
|
|
87
90
|
registerAppAuthorizeRoutes(app, oauthProvider, ISSUER_URL);
|
|
91
|
+
// Public discovery card (/.well-known/mcp/server-card.json, /.well-known/mcp.json).
|
|
92
|
+
registerServerCardRoutes(app, { name: "inistate-mcp", version: pkgVersion, issuerUrl: ISSUER_URL, scopes: SUPPORTED_SCOPES });
|
|
88
93
|
/* ------------------------------------------------------------------ */
|
|
89
94
|
/* Health check */
|
|
90
95
|
/* ------------------------------------------------------------------ */
|
package/build/schema.js
CHANGED
|
@@ -655,7 +655,7 @@ export function validateDesign(schema, mode = "create") {
|
|
|
655
655
|
errors.push(`Information field '${f.name}' uses a reserved name: ${RESERVED_INFORMATION_NAMES.join(", ")} are built into every module, and Studio will not accept the design. Rename it to say what it holds (for example 'Requested By' rather than 'Created By', 'Reference No' rather than 'ID').`);
|
|
656
656
|
}
|
|
657
657
|
if (!f.type) {
|
|
658
|
-
errors.push(`Field '${f.name}' is missing a 'type'. Valid types: ${
|
|
658
|
+
errors.push(`Field '${f.name}' is missing a 'type'. Valid types: ${AI_CREATABLE_FIELD_TYPES.join(", ")}.`);
|
|
659
659
|
continue;
|
|
660
660
|
}
|
|
661
661
|
const norm = normalizeFieldType(f.type);
|
|
@@ -664,7 +664,7 @@ export function validateDesign(schema, mode = "create") {
|
|
|
664
664
|
warnings.push(`Field '${f.name}' type '${f.type}' normalized to '${ftype}'.`);
|
|
665
665
|
}
|
|
666
666
|
if (!isValidFieldType(ftype)) {
|
|
667
|
-
errors.push(`Field '${f.name}' has invalid type '${f.type}'. Valid types: ${
|
|
667
|
+
errors.push(`Field '${f.name}' has invalid type '${f.type}'. Valid types: ${AI_CREATABLE_FIELD_TYPES.join(", ")}.`);
|
|
668
668
|
}
|
|
669
669
|
const base = baseTypeOf(ftype);
|
|
670
670
|
const hasConnection = typeof f.connection === "string" && f.connection.trim() !== "";
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Express } from "express";
|
|
2
|
+
/**
|
|
3
|
+
* Public, unauthenticated discovery document for the remote endpoint (MCP Server Card), so
|
|
4
|
+
* directories and clients can learn what the server is and how to connect without first
|
|
5
|
+
* passing the OAuth challenge on /mcp.
|
|
6
|
+
*/
|
|
7
|
+
export declare function buildServerCard(opts: {
|
|
8
|
+
name: string;
|
|
9
|
+
version: string;
|
|
10
|
+
issuerUrl: string;
|
|
11
|
+
scopes: string[];
|
|
12
|
+
}): {
|
|
13
|
+
$schema: string;
|
|
14
|
+
version: string;
|
|
15
|
+
serverInfo: {
|
|
16
|
+
name: string;
|
|
17
|
+
title: string;
|
|
18
|
+
version: string;
|
|
19
|
+
};
|
|
20
|
+
description: string;
|
|
21
|
+
iconUrl: string;
|
|
22
|
+
documentationUrl: string;
|
|
23
|
+
websiteUrl: string;
|
|
24
|
+
transport: {
|
|
25
|
+
type: string;
|
|
26
|
+
endpoint: string;
|
|
27
|
+
};
|
|
28
|
+
capabilities: {
|
|
29
|
+
tools: {
|
|
30
|
+
listChanged: boolean;
|
|
31
|
+
};
|
|
32
|
+
resources: {
|
|
33
|
+
listChanged: boolean;
|
|
34
|
+
};
|
|
35
|
+
prompts: {
|
|
36
|
+
listChanged: boolean;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
authentication: {
|
|
40
|
+
required: boolean;
|
|
41
|
+
schemes: string[];
|
|
42
|
+
protectedResourceMetadata: string;
|
|
43
|
+
authorizationServerMetadata: string;
|
|
44
|
+
scopes: string[];
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export declare function registerServerCardRoutes(app: Express, opts: Parameters<typeof buildServerCard>[0]): void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { SERVER_DESCRIPTION, SERVER_ICON_DATA_URI, SERVER_TITLE, SERVER_WEBSITE_URL } from "./server-identity.js";
|
|
2
|
+
/**
|
|
3
|
+
* Public, unauthenticated discovery document for the remote endpoint (MCP Server Card), so
|
|
4
|
+
* directories and clients can learn what the server is and how to connect without first
|
|
5
|
+
* passing the OAuth challenge on /mcp.
|
|
6
|
+
*/
|
|
7
|
+
export function buildServerCard(opts) {
|
|
8
|
+
const base = opts.issuerUrl.replace(/\/$/, "");
|
|
9
|
+
return {
|
|
10
|
+
$schema: "https://static.modelcontextprotocol.io/schemas/mcp-server-card/v1.json",
|
|
11
|
+
version: "1.0",
|
|
12
|
+
serverInfo: { name: opts.name, title: SERVER_TITLE, version: opts.version },
|
|
13
|
+
description: SERVER_DESCRIPTION,
|
|
14
|
+
iconUrl: SERVER_ICON_DATA_URI,
|
|
15
|
+
documentationUrl: SERVER_WEBSITE_URL,
|
|
16
|
+
websiteUrl: SERVER_WEBSITE_URL,
|
|
17
|
+
transport: { type: "streamable-http", endpoint: `${base}/mcp` },
|
|
18
|
+
capabilities: { tools: { listChanged: true }, resources: { listChanged: true }, prompts: { listChanged: true } },
|
|
19
|
+
authentication: {
|
|
20
|
+
required: true,
|
|
21
|
+
schemes: ["oauth2"],
|
|
22
|
+
protectedResourceMetadata: `${base}/.well-known/oauth-protected-resource/mcp`,
|
|
23
|
+
authorizationServerMetadata: `${base}/.well-known/oauth-authorization-server`,
|
|
24
|
+
scopes: opts.scopes,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export function registerServerCardRoutes(app, opts) {
|
|
29
|
+
const card = buildServerCard(opts);
|
|
30
|
+
for (const path of ["/.well-known/mcp/server-card.json", "/.well-known/mcp.json", "/.well-known/mcp"]) {
|
|
31
|
+
app.get(path, (_req, res) => {
|
|
32
|
+
res.set("Cache-Control", "public, max-age=300").json(card);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Public identity of the server, shared by the initialize handshake and the discovery card. */
|
|
2
|
+
export declare const SERVER_TITLE = "Inistate";
|
|
3
|
+
export declare const SERVER_DESCRIPTION = "Lets an agent work with the Inistate no-code workflow platform: discover workspaces and modules, read and aggregate entries, submit activities, design and update modules, and manage access, listings and automations.";
|
|
4
|
+
export declare const SERVER_WEBSITE_URL = "https://inistate.com";
|
|
5
|
+
/** Vector (scalable) logomark as a data: URI, so no extra route or request is needed. */
|
|
6
|
+
export declare const SERVER_ICON_DATA_URI: string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { INISTATE_LOGO_SVG } from "./inistate-logo.js";
|
|
2
|
+
/** Public identity of the server, shared by the initialize handshake and the discovery card. */
|
|
3
|
+
export const SERVER_TITLE = "Inistate";
|
|
4
|
+
export const SERVER_DESCRIPTION = "Lets an agent work with the Inistate no-code workflow platform: discover workspaces and modules, read and aggregate entries, submit activities, design and update modules, and manage access, listings and automations.";
|
|
5
|
+
export const SERVER_WEBSITE_URL = "https://inistate.com";
|
|
6
|
+
/** Vector (scalable) logomark as a data: URI, so no extra route or request is needed. */
|
|
7
|
+
export const SERVER_ICON_DATA_URI = `data:image/svg+xml;base64,${Buffer.from(INISTATE_LOGO_SVG, "utf8").toString("base64")}`;
|
package/build/server.js
CHANGED
|
@@ -10,6 +10,7 @@ import { setUserMode } from "./mode-store.js";
|
|
|
10
10
|
import { CloudBackend } from "./backend.js";
|
|
11
11
|
import { capabilityMessage } from "./capability.js";
|
|
12
12
|
import { strictArguments } from "./strict-arguments.js";
|
|
13
|
+
import { SERVER_DESCRIPTION, SERVER_ICON_DATA_URI, SERVER_TITLE, SERVER_WEBSITE_URL } from "./server-identity.js";
|
|
13
14
|
export function createServer(options = {}) {
|
|
14
15
|
const { backend = new CloudBackend(), initialMode, name = "inistate-mcp", version = pkgVersion } = options;
|
|
15
16
|
const caps = backend.capabilities();
|
|
@@ -20,12 +21,16 @@ export function createServer(options = {}) {
|
|
|
20
21
|
- Orient: list_workspaces (returns the module list itself when exactly one workspace matches) or set_workspace (looks one up by id or name). Both return the workspace's module list; list_modules is only for refreshing it. The MCP keeps no state between calls: pass workspaceId on every call (omit it only when INISTATE_WORKSPACE_ID is configured).
|
|
21
22
|
- Read: list_entries with the fields parameter (keeps payloads small) and filters; get_entry for one record; aggregate_entries for counts and totals (never add up list_entries pages).
|
|
22
23
|
- Write: get_form once per (module, activity), then submit_activity; reuse the form schema for more entries of the same kind. Use submit_activities for bulk writes (max 100 per call).
|
|
23
|
-
- Design: design_workflow -> create_module (validates internally; validate_design is an optional dry-run). Modify: get_module_canvas -> edit -> update_module (
|
|
24
|
+
- Design: design_workflow -> create_module (validates internally; validate_design is an optional dry-run). Modify: get_module_canvas -> edit -> update_module (validates internally, a partial payload as laid over the module's design). Who can do what: get_module_access -> set_module_access (dryRun first; confirmed only after the user approves a widening); which entries people see: save_listing.${caps.automations ? " Automations: get_module_automations -> save_automation with its tests (dryRun first; a new one is saved off, and switching on needs its tests passing and confirmed:true after the admin's yes) -> get_automation_runs to watch its first live runs." : ""}${caps.designRecord ? " Every create_module / update_module carries ai.reasoning (why the design changes, kept in the module history); before changing or removing an existing item, read get_module_history — a recent change with a stated reason is a decision, so ask before undoing it." : ""}${caps.designApprovals ? " A design write answered design_approval_required needs a person: report the reasons and offer to send it with approval; never send unasked." : ""}
|
|
24
25
|
- Files: request_upload_url -> PUT bytes -> confirm_upload (default); upload_file only if that flow fails.
|
|
25
|
-
- Guardrails: actor='human' activities are never executable by AI (when the user wants one done, submit_activity with approval sends it to a person to approve); hybrid actors, changeStatus, and state overrides need confirmed:true after explicit user approval. Load inistate://schema/runtime for response shapes and filter operators.`;
|
|
26
|
+
- Guardrails: actor='human' activities are never executable by AI (when the user wants one done, submit_activity with approval sends it to a person to approve); hybrid actors, changeStatus, and state overrides need confirmed:true after explicit user approval. A 429 rate_limited answer means the call was not run: wait retry_after_seconds, then make the same call again. Load inistate://schema/runtime for response shapes and filter operators.`;
|
|
26
27
|
const server = new McpServer({
|
|
27
28
|
name,
|
|
28
29
|
version,
|
|
30
|
+
title: SERVER_TITLE,
|
|
31
|
+
description: SERVER_DESCRIPTION,
|
|
32
|
+
websiteUrl: SERVER_WEBSITE_URL,
|
|
33
|
+
icons: [{ src: SERVER_ICON_DATA_URI, mimeType: "image/svg+xml", sizes: ["any"] }],
|
|
29
34
|
}, { instructions });
|
|
30
35
|
const { configureTools } = registerTools(server, backend);
|
|
31
36
|
const { configureResources, frontendResources } = registerResources(server, backend);
|
|
@@ -59,21 +64,30 @@ export function createServer(options = {}) {
|
|
|
59
64
|
}
|
|
60
65
|
let currentMode = startMode;
|
|
61
66
|
server.registerTool("switch_mode", {
|
|
67
|
+
title: "Switch Mode",
|
|
62
68
|
description: "Switch tool surface. 'configure' (default) = entry CRUD + module design tools and design resources. 'runtime' = entry CRUD plus get_module_schema (available in every mode). 'frontend' = configure + the inistate://frontend-guide resource (REST reference for building Vue/React UIs that call the Inistate API directly) — use it when the user wants a custom UI. The tool/resource list refreshes via list_changed after this call.",
|
|
63
69
|
// Registered here rather than through tools.ts registerTool, so it refuses an unknown argument
|
|
64
70
|
// the same way (strict-arguments.ts); its handler reads only `mode`.
|
|
65
71
|
inputSchema: strictArguments("switch_mode", {
|
|
66
|
-
mode: z.enum(["runtime", "configure", "frontend"]).describe("
|
|
72
|
+
mode: z.enum(["runtime", "configure", "frontend"]).describe("The tool surface to switch to: runtime (entry CRUD only), configure (adds module design tools and design resources) or frontend (configure plus the inistate://frontend-guide resource). Frontend is unavailable on a backend that lacks that guide."),
|
|
67
73
|
}).schema,
|
|
74
|
+
outputSchema: z.object({
|
|
75
|
+
mode: z.enum(["runtime", "configure", "frontend"]).optional().describe("The mode now active. Absent when the switch was refused."),
|
|
76
|
+
message: z.string().optional().describe("A short confirmation, or the reason the switch was refused."),
|
|
77
|
+
error: z.string().optional().describe("capability_unavailable when this backend cannot serve the requested mode; nothing was switched."),
|
|
78
|
+
backend: z.string().optional().describe("Only with error: the backend that cannot serve the mode."),
|
|
79
|
+
capability: z.string().optional().describe("Only with error: the capability that is missing."),
|
|
80
|
+
upgrade: z.string().optional().describe("Only with error: how to get the missing capability."),
|
|
81
|
+
}).passthrough(),
|
|
68
82
|
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: false, idempotentHint: true },
|
|
69
83
|
}, async ({ mode }) => {
|
|
70
84
|
if (!caps.modes.includes(mode)) {
|
|
71
85
|
// The only mode a backend may withhold is `frontend` — its REST guide
|
|
72
86
|
// targets the Platform API. runtime/configure are always available.
|
|
87
|
+
const refusal = capabilityMessage("frontend_guide", backend.kind);
|
|
73
88
|
return {
|
|
74
|
-
content: [
|
|
75
|
-
|
|
76
|
-
],
|
|
89
|
+
content: [{ type: "text", text: JSON.stringify(refusal) }],
|
|
90
|
+
structuredContent: { ...refusal },
|
|
77
91
|
};
|
|
78
92
|
}
|
|
79
93
|
const enableConfigure = mode === "configure" || mode === "frontend";
|
|
@@ -91,13 +105,10 @@ export function createServer(options = {}) {
|
|
|
91
105
|
const userId = requestContext.getStore()?.userId;
|
|
92
106
|
if (userId)
|
|
93
107
|
setUserMode(userId, mode);
|
|
108
|
+
const switched = { mode: currentMode, message: `Switched to ${mode} mode` };
|
|
94
109
|
return {
|
|
95
|
-
content: [
|
|
96
|
-
|
|
97
|
-
type: "text",
|
|
98
|
-
text: JSON.stringify({ mode: currentMode, message: `Switched to ${mode} mode` }),
|
|
99
|
-
},
|
|
100
|
-
],
|
|
110
|
+
content: [{ type: "text", text: JSON.stringify(switched) }],
|
|
111
|
+
structuredContent: switched,
|
|
101
112
|
};
|
|
102
113
|
});
|
|
103
114
|
return server;
|
package/build/tools.js
CHANGED
|
@@ -29,6 +29,57 @@ function ok(data) {
|
|
|
29
29
|
content: [{ type: "text", text: JSON.stringify(data) }],
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* ok() that also carries the answer as structuredContent, for the tools that declare an outputSchema.
|
|
34
|
+
* The platform's answer is relayed as it came, so a body that is not a JSON object is wrapped as
|
|
35
|
+
* { result } rather than failing the output check after the write already happened.
|
|
36
|
+
*/
|
|
37
|
+
function okStructured(data) {
|
|
38
|
+
const structured = data && typeof data === "object" && !Array.isArray(data)
|
|
39
|
+
? data
|
|
40
|
+
: { result: data ?? null };
|
|
41
|
+
return {
|
|
42
|
+
content: [{ type: "text", text: JSON.stringify(data) }],
|
|
43
|
+
structuredContent: structured,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
// Output schemas. The platform's answers are relayed unchanged (the backend returns `unknown`), so each
|
|
47
|
+
// schema names only the fields the API contract (inistate-schema.json, the specification) or this code
|
|
48
|
+
// documents, all optional and lenient; any other field passes through.
|
|
49
|
+
const nullish = (t) => t.nullish();
|
|
50
|
+
const idValue = z.union([z.string(), z.number()]);
|
|
51
|
+
const moduleWriteOutput = {
|
|
52
|
+
id: nullish(idValue).describe("The module's id, to pass as update_module's id."),
|
|
53
|
+
name: nullish(z.string()).describe("The module's name."),
|
|
54
|
+
emoji: nullish(z.string()).describe("The module's icon."),
|
|
55
|
+
updatedDate: nullish(z.string()).describe("When the module was saved, as a date-time."),
|
|
56
|
+
version: nullish(z.string()).describe("The design version saved; null when the platform keeps none."),
|
|
57
|
+
documentIdExample: nullish(z.string()).describe("A sample of the document number the module's documentIdFormat produces."),
|
|
58
|
+
cardStatus: z.unknown().optional().describe("Whether the listing card passed; when it did not, why, and the module has the platform's default card."),
|
|
59
|
+
hint: nullish(z.string()).describe("update_module only: which items were created as new because their ids matched nothing."),
|
|
60
|
+
performed: nullish(z.boolean()).describe("false when the change was sent to a person for approval instead of saved; then requestId names the request."),
|
|
61
|
+
requestId: nullish(idValue).describe("The approval request, when performed is false. Read the outcome with get_approval_request."),
|
|
62
|
+
ok: nullish(z.boolean()).describe("update_module with dryRun only: whether the update would pass."),
|
|
63
|
+
checks: z.unknown().optional().describe("update_module with dryRun only: each check and stored test with its result."),
|
|
64
|
+
errors: nullish(z.array(z.unknown())).describe("update_module with dryRun only: what would fail."),
|
|
65
|
+
changes: z.unknown().optional().describe("update_module with dryRun only: the changes the update would make."),
|
|
66
|
+
schema: z.unknown().optional().describe("update_module with dryRun only: the design as it would read after the update."),
|
|
67
|
+
};
|
|
68
|
+
const submitActivityOutput = {
|
|
69
|
+
module: nullish(z.string()).describe("The module the activity ran in."),
|
|
70
|
+
activity: nullish(z.string()).describe("The activity that was performed."),
|
|
71
|
+
entryId: nullish(idValue).describe("The entry it ran on; for create, the new entry's id."),
|
|
72
|
+
documentId: nullish(z.string()).describe("The entry's human-readable document id."),
|
|
73
|
+
state: nullish(z.string()).describe("The entry's state afterwards; null when no state change happened, for example when flagged."),
|
|
74
|
+
message: nullish(z.string()).describe("A note from the platform, when it has one."),
|
|
75
|
+
flagged: nullish(z.boolean()).describe("true when the AI's confidence was below the activity's confidence_threshold: the state change was suppressed and the entry flagged for a person. Present only when true."),
|
|
76
|
+
ai_instruction: nullish(z.string()).describe("The new state's ai_instruction, when the activity changed state into one that has it. Follow it."),
|
|
77
|
+
availableActivities: nullish(z.record(z.unknown())).describe("What can be done on the entry next: standard and custom activities and the state flow."),
|
|
78
|
+
performed: nullish(z.boolean()).describe("false when the activity was sent to a person for approval instead of performed; then requestId names the request."),
|
|
79
|
+
requestId: nullish(idValue).describe("The approval request, when performed is false. Read the outcome with get_approval_request."),
|
|
80
|
+
input_key_notes: nullish(z.array(z.unknown())).describe("Notes on input keys the server corrected to field display names."),
|
|
81
|
+
ok: nullish(z.boolean()).describe("dryRun only: whether the simulated run would succeed."),
|
|
82
|
+
};
|
|
32
83
|
/** ok() with a file: the short JSON text part first, then the file as an embedded resource (get_document's
|
|
33
84
|
* `as: "file"`; any tool that returns bytes, a PNG preview say, reuses it). */
|
|
34
85
|
function okWithResource(data, resource) {
|
|
@@ -106,7 +157,7 @@ const SYSTEM_ENTRY_FIELDS = new Set([
|
|
|
106
157
|
const wsParam = z
|
|
107
158
|
.union([z.string(), z.number()])
|
|
108
159
|
.optional()
|
|
109
|
-
.describe("
|
|
160
|
+
.describe("ID of the Inistate workspace to act in, from list_workspaces or set_workspace. The MCP remembers no workspace between calls, so send it on every call; it may be left out only when INISTATE_WORKSPACE_ID is configured.");
|
|
110
161
|
/**
|
|
111
162
|
* Names that belong to more than one module record in the listed workspace. The platform
|
|
112
163
|
* resolves a module named by name to the first match only, so with two "Customer" records
|
|
@@ -248,63 +299,63 @@ const repairFlow = (raw) => {
|
|
|
248
299
|
// form). The platform checks it: "=" syntax, display names, the module's states.
|
|
249
300
|
const FIELD_FORMULA_HINT = "The field's value as a formula, making it a computed field: worked out on every submit of every activity and read-only on every form. Write it in the \"=\" syntax with display names, e.g. \"=SUM({{form.Lines.Amount}})\" or \"={{form.Price}} * {{form.Quantity}}\". \"\" makes it an ordinary field again; omit to keep it. get_module_canvas shows it as written; send it back unchanged to keep it.";
|
|
250
301
|
const subFieldShape = z.preprocess(repairItem, z.object({
|
|
251
|
-
id: z.string().optional(),
|
|
252
|
-
name: z.string(),
|
|
253
|
-
type: z.string().optional(),
|
|
254
|
-
connection: z.string().optional().describe("Module columns only:
|
|
255
|
-
display: z.string().optional().describe("Module columns only:
|
|
256
|
-
options: z.array(z.string()).optional(),
|
|
257
|
-
ai_hint: z.string().optional(),
|
|
302
|
+
id: z.string().optional().describe("Id of an existing column, as get_module_canvas returns it. Send it back so a rename keeps the column's data; omit for a new column."),
|
|
303
|
+
name: z.string().describe("The column's display name: its heading, and the key of its value in each submitted Table row."),
|
|
304
|
+
type: z.string().optional().describe("The column's data type, e.g. Text or Number. inistate://schema/configure lists the types."),
|
|
305
|
+
connection: z.string().optional().describe("Module columns only: the existing module whose records each row links to, by name (e.g. \"Products\" for line items). Modules, User and Users columns are not offered inside a table."),
|
|
306
|
+
display: z.string().optional().describe("Module columns only: which field of the linked module labels a picked record. Defaults to the first Text field."),
|
|
307
|
+
options: z.array(z.string()).optional().describe("The choices offered by a Selection column."),
|
|
308
|
+
ai_hint: z.string().optional().describe("Guidance for AI agents on how to fill this column."),
|
|
258
309
|
formula: z.string().optional().describe("The column's value on each row as a formula, making it a computed column: worked out on every row on every submit (submit_activity included, so leave it out of the rows you send), and read-only on every form. Name the row's own columns through the table, e.g. \"={{form.Lines.Qty}} * {{form.Lines.Price}}\". A field's formula can total it: \"=SUM({{form.Lines.Amount}})\". \"\" makes it an ordinary column again; omit to keep it."),
|
|
259
310
|
}));
|
|
260
311
|
const fieldShape = z.preprocess(repairItem, z.object({
|
|
261
|
-
id: z.string().optional(),
|
|
262
|
-
name: z.string(),
|
|
263
|
-
type: z.string().optional(),
|
|
264
|
-
connection: z.string().optional().describe("
|
|
265
|
-
display: z.string().optional().describe("User/Users/Module/Modules only:
|
|
266
|
-
options: z.array(z.string()).optional(),
|
|
267
|
-
fields: z.array(subFieldShape).optional().describe("
|
|
268
|
-
ai_hint: z.string().optional(),
|
|
312
|
+
id: z.string().optional().describe("Id of an existing field, as get_module_canvas returns it. Send it back so a rename or retype keeps the field's entry data; omit for a new field."),
|
|
313
|
+
name: z.string().describe("The field's display name: its label on forms and listings, and the key of its value in submit_activity's input."),
|
|
314
|
+
type: z.string().optional().describe("The field's data type, e.g. Text, Number or Selection. inistate://schema/configure lists the types."),
|
|
315
|
+
connection: z.string().optional().describe("The existing module this field links to, by name; the field's values are records of that module. Needed for the User, Users, Module and Modules types."),
|
|
316
|
+
display: z.string().optional().describe("User/Users/Module/Modules only: which field of the linked module labels a picked record. Defaults to Full Name/Name for users, else the first Text field."),
|
|
317
|
+
options: z.array(z.string()).optional().describe("The choices offered by a Selection (or Tag) field."),
|
|
318
|
+
fields: z.array(subFieldShape).optional().describe("The columns of a Table field."),
|
|
319
|
+
ai_hint: z.string().optional().describe("Guidance for AI agents on how to interpret or fill this field."),
|
|
269
320
|
formula: z.string().optional().describe(FIELD_FORMULA_HINT),
|
|
270
321
|
}));
|
|
271
322
|
const stateShape = z.preprocess(repairItem, z.object({
|
|
272
|
-
id: z.string().optional(),
|
|
273
|
-
name: z.string(),
|
|
274
|
-
color: z.string().optional().describe("
|
|
275
|
-
initial: z.boolean().optional(),
|
|
276
|
-
ai_hint: z.string().optional(),
|
|
277
|
-
ai_instruction: z.string().optional(),
|
|
323
|
+
id: z.string().optional().describe("Id of an existing state, as get_module_canvas returns it. Send it back so a rename keeps the entries in that state; omit for a new state."),
|
|
324
|
+
name: z.string().describe("The state's display name, as shown on entries and referenced by flows and by submit_activity's state."),
|
|
325
|
+
color: z.string().optional().describe("The state's badge color, one of the palette #5A6070 #2968A8 #2A7B50 #A07828 #C0392B #6B4D91 #1E6B45 #8B2D2D; a color name ('red', 'amber') or another hex is mapped to the nearest."),
|
|
326
|
+
initial: z.boolean().optional().describe("Marks the state new entries start in. A workflow module has exactly one."),
|
|
327
|
+
ai_hint: z.string().optional().describe("Guidance for AI agents on when an entry belongs in this state."),
|
|
328
|
+
ai_instruction: z.string().optional().describe("What an AI agent should do when an entry reaches this state, e.g. \"Notify the approver\". Unlike ai_hint, it prescribes an action. Changing the text needs a person's approval."),
|
|
278
329
|
}));
|
|
279
330
|
// A form's conditions on one of its fields, as Studio's form designer sets them. The platform checks them.
|
|
280
331
|
const FORM_CONDITION_HINT = "a true/false condition in the \"=\" syntax with display names, e.g. \"={{form.Type}} = \\\"Travel\\\"\" or \"={{form.Amount}} > 1000\". \"\" removes it; omit to keep it. get_module_canvas shows it as written; send it back unchanged to keep it.";
|
|
281
332
|
const activityFieldRefShape = z.preprocess(repairItem, z.object({
|
|
282
|
-
name: z.string(),
|
|
283
|
-
required: z.boolean().optional(),
|
|
284
|
-
readOnly: z.boolean().optional(),
|
|
285
|
-
options: z.array(z.string()).optional(),
|
|
333
|
+
name: z.string().describe("Display name of a field from information to include on this activity's form."),
|
|
334
|
+
required: z.boolean().optional().describe("Make the field mandatory on this activity's form."),
|
|
335
|
+
readOnly: z.boolean().optional().describe("Show the field on this activity's form but not editable."),
|
|
336
|
+
options: z.array(z.string()).optional().describe("For a Selection or Tag field: the subset of its options this activity's form offers. Omit to offer them all."),
|
|
286
337
|
visibleWhen: z.string().optional().describe("The form shows this field only while this holds: " + FORM_CONDITION_HINT),
|
|
287
338
|
requiredWhen: z.string().optional().describe("The field is required on this form while this holds: " + FORM_CONDITION_HINT),
|
|
288
339
|
readOnlyWhen: z.string().optional().describe("The field is read-only on this form while this holds: " + FORM_CONDITION_HINT),
|
|
289
340
|
}));
|
|
290
341
|
const activityShape = z.preprocess(repairItem, z.object({
|
|
291
|
-
id: z.string().optional(),
|
|
292
|
-
name: z.string(),
|
|
342
|
+
id: z.string().optional().describe("Id of an existing activity, as get_module_canvas returns it. Send it back so a rename keeps its history; omit for a new activity."),
|
|
343
|
+
name: z.string().describe("The activity's display name: what users see on the button, and the `activity` value submit_activity takes."),
|
|
293
344
|
actor: z.enum(["human", "ai", "hybrid"]).optional().describe("Who performs the activity when an AI is asked to: ai — the AI submits it; hybrid — the user approves the planned submission first; human — a person performs it. Studio and the TeamMate call these Performs, Asks first and Human only: a user asking for \"Asks first\" means hybrid. Omitted, a workflow activity is hybrid (Asks first); set human for one only a person may perform."),
|
|
294
345
|
humanWhen: z.string().optional().describe("Human only when — on an ai or hybrid activity, a true/false condition that makes it human-only for the values it holds for, e.g. \"{{form.Amount}} > 10000\". Name fields as {{form.Field Name}} (submitted values over stored) or {{entry.Field Name}} (as stored). \"\" removes it; omit to keep it. Removing or rewriting one needs a person: the write answers design_approval_required (confirmed: true does not pass it), and only if the user says so, send it again with approval."),
|
|
295
|
-
fields: z.array(z.union([z.string(), activityFieldRefShape])).optional(),
|
|
296
|
-
ai_hint: z.string().optional(),
|
|
297
|
-
ai_instruction: z.string().optional(),
|
|
298
|
-
confidence_threshold: z.number().min(0).max(100).optional().describe("0
|
|
346
|
+
fields: z.array(z.union([z.string(), activityFieldRefShape])).optional().describe("The fields on this activity's form: a bare field name, or an object that also sets per-form constraints."),
|
|
347
|
+
ai_hint: z.string().optional().describe("Guidance for AI agents on when and how to perform this activity."),
|
|
348
|
+
ai_instruction: z.string().optional().describe("What an AI agent should do when performing this activity, e.g. \"Check that every document is attached before approving\". Unlike ai_hint, it prescribes the work. Changing the text needs a person's approval."),
|
|
349
|
+
confidence_threshold: z.number().min(0).max(100).optional().describe("Minimum AI confidence for this activity's state change to go ahead; below it the change is suppressed and the entry is flagged for a person. Give a fraction (0.8) or a percent (80); 0 or omitted turns the gate off."),
|
|
299
350
|
}));
|
|
300
351
|
// from/to/activity are required semantically but optional on the wire: a flow
|
|
301
352
|
// missing one would otherwise die as a raw Zod -32602; loose parsing lets the
|
|
302
353
|
// design validator report what's missing as a structured error instead.
|
|
303
354
|
const flowShape = z.preprocess(repairFlow, z.object({
|
|
304
|
-
from: z.string().optional(),
|
|
305
|
-
to: z.string().optional(),
|
|
306
|
-
activity: z.string().optional().describe("
|
|
307
|
-
ai_hint: z.string().optional(),
|
|
355
|
+
from: z.string().optional().describe("Name of the state the transition starts from; an empty string means any state."),
|
|
356
|
+
to: z.string().optional().describe("Name of the state the entry moves to."),
|
|
357
|
+
activity: z.string().optional().describe("Name of the activity that triggers this transition."),
|
|
358
|
+
ai_hint: z.string().optional().describe("Guidance for AI agents on when to take this transition."),
|
|
308
359
|
}));
|
|
309
360
|
// ---------- Listing card (the `card` block on create_module / update_module) ----------
|
|
310
361
|
// The listing card is part of the design, not a follow-up: the same call that writes
|
|
@@ -346,23 +397,23 @@ const repairCardItem = (raw) => {
|
|
|
346
397
|
return it;
|
|
347
398
|
};
|
|
348
399
|
const cardItemShape = z.preprocess(repairCardItem, z.object({
|
|
349
|
-
type: z.string().describe("field
|
|
350
|
-
name: z.string().optional().describe("
|
|
351
|
-
size: z.string().optional().describe("S
|
|
352
|
-
style: z.string().optional().describe("l
|
|
353
|
-
ratio: z.string().optional().describe("Image/File fields only: 1:1
|
|
354
|
-
orientation: z.string().optional().describe("Image/File fields only: portrait
|
|
355
|
-
settings: z.record(z.any()).optional().describe("defaultCard
|
|
400
|
+
type: z.string().describe("What the item shows: 'field' (a field's value), 'state' (the state chip), 'activity' (a button for a business activity) or 'widget' (the defaultCard collaboration row)."),
|
|
401
|
+
name: z.string().optional().describe("The field or activity it shows, by name; 'defaultCard' for the widget. Left out for state."),
|
|
402
|
+
size: z.string().optional().describe("Text size of the value: S, M or L. Text, number and date fields only."),
|
|
403
|
+
style: z.string().optional().describe("Weight of the value: l light, n normal or b bold. Text, number and date fields only."),
|
|
404
|
+
ratio: z.string().optional().describe("Image/File fields only: the picture's aspect ratio, 1:1, 3:2, 4:3 or 16:9."),
|
|
405
|
+
orientation: z.string().optional().describe("Image/File fields only: portrait or landscape."),
|
|
406
|
+
settings: z.record(z.any()).optional().describe("Widget only: which defaultCard parts to show, each a boolean switch: title, state, assignees, comment, createdBy, createdDate, due, documentId. All are on unless set false, except documentId."),
|
|
356
407
|
}));
|
|
357
408
|
const cardRowShape = z.preprocess((v) => (Array.isArray(v) ? { items: v } : v), z.object({ items: arrayish(z.array(cardItemShape)).describe("1–3 items") }));
|
|
358
409
|
const cardIconShape = z.preprocess((v) => (typeof v === "string" ? { field: v } : v), z.object({
|
|
359
|
-
field: z.string().describe("
|
|
360
|
-
size: z.string().optional().describe("XS
|
|
410
|
+
field: z.string().describe("The field whose value is the card's icon, by name: an Image, Images, File, Files or Selection field."),
|
|
411
|
+
size: z.string().optional().describe("Icon size: XS, S, M or L. S suits a Selection (its emoji-prefixed options show), M an image."),
|
|
361
412
|
}));
|
|
362
413
|
const cardShape = z.object({
|
|
363
|
-
type: z.string().describe("'grid'
|
|
364
|
-
action: z.string().optional().describe("'view' (the default when activities exist), 'edit', or an activity name"),
|
|
365
|
-
size: z.string().optional().describe("Grid only:
|
|
414
|
+
type: z.string().describe("The card layout: 'grid' (image tiles, for a module with an Image/Images field, the image alone in row 1) or 'detail' (a row with an icon)."),
|
|
415
|
+
action: z.string().optional().describe("What tapping an entry does: 'view' (the default when activities exist), 'edit', or an activity name."),
|
|
416
|
+
size: z.string().optional().describe("Grid only: tile size, which sets the columns on a phone (L is 1, M is 2, S is 3)."),
|
|
366
417
|
icon: cardIconShape.optional().describe("Detail only"),
|
|
367
418
|
rows: arrayish(z.array(cardRowShape)).optional().describe("1–5 rows of 1–3 items: the state row first (or the defaultCard widget alone), the title field L/b, secondary fields S/M, activities in their own row"),
|
|
368
419
|
});
|
|
@@ -483,7 +534,7 @@ const automationGraphShape = z.object({
|
|
|
483
534
|
// M2 and M3). The platform checks them (SimulationExpectations, SimulationPersona).
|
|
484
535
|
const expectationsShape = z.array(z.object({
|
|
485
536
|
check: z.string().describe("ok, failed, created, changed, deleted, field, lines, state, branch, automation, notification, effect, preflight or allowed"),
|
|
486
|
-
}).passthrough()).describe('What the run must do, e.g. { "check": "automation", "automation": "Post the voucher", "equals": "Completed" }, { "check": "state", "equals": "Posted" }, { "check": "field", "module": "Cash Book", "field": "Amount", "equals": 381.9 }, { "check": "preflight" } (every
|
|
537
|
+
}).passthrough()).describe('What the run must do, e.g. { "check": "automation", "automation": "Post the voucher", "equals": "Completed" }, { "check": "state", "equals": "Posted" }, { "check": "field", "module": "Cash Book", "field": "Amount", "equals": 381.9 }, { "check": "preflight" } (every code sent to a connected book is in it), { "check": "allowed", "equals": false }. None: the run must go through');
|
|
487
538
|
const simulateAsShape = z.object({
|
|
488
539
|
member: z.string().optional().describe("A member's username: the run acts as them"),
|
|
489
540
|
field: z.string().optional().describe("Or a people-module field, e.g. Position"),
|
|
@@ -506,7 +557,7 @@ const automationTestShape = z.union([
|
|
|
506
557
|
}).passthrough(),
|
|
507
558
|
]);
|
|
508
559
|
// submit_activity / submit_activities: the same call, rehearsed (flagship plan §4 M3, the sixth row).
|
|
509
|
-
const DRY_RUN_HINT = "Rehearse it: every check the submit runs, then the submit itself inside a simulation, so automations run, documents are made in memory and
|
|
560
|
+
const DRY_RUN_HINT = "Rehearse it: every check the submit runs, then the submit itself inside a simulation, so automations run, documents are made in memory and codes picked from a connected book are checked against it. Nothing is stored or sent. Never refused for its actor, so a human step can be rehearsed too. The answer is { ok, checks, errors } with the simulation's report (changes, automations, effects, the trace). A write to a module kept at an external API is planned and checked, not sent (a passing check named planned › <module>): the provider has not seen it, so it can still refuse what only it checks, such as its own codes, balances or plan limits.";
|
|
510
561
|
const automationShape = z.preprocess(repairItem, z.object({
|
|
511
562
|
id: z.string().optional().describe("The automation's id from get_module_automations; omit to add a new one"),
|
|
512
563
|
name: z.string().optional().describe("Unique in the module; required for a new one"),
|
|
@@ -641,7 +692,7 @@ function dryRunRefusal(tool, dryRun, expect, actsAs, approval) {
|
|
|
641
692
|
return null;
|
|
642
693
|
}
|
|
643
694
|
const moduleSectionsShape = {
|
|
644
|
-
icon: z.string().optional().describe("
|
|
695
|
+
icon: z.string().optional().describe("The icon shown beside the module's name in the workspace's module list, given as an emoji identifier. On update, omit to keep the current icon."),
|
|
645
696
|
description: z.string().optional().describe("The module's own description, shown to its users. Not a change note: say why you changed the design in ai.reasoning."),
|
|
646
697
|
information: arrayish(z.array(fieldShape)).optional().describe("Field definitions. Items matched by id on update enable renaming."),
|
|
647
698
|
states: arrayish(z.array(stateShape)).optional().describe("Workflow states. Omit for record list modules."),
|
|
@@ -699,8 +750,11 @@ const listQueryParams = {
|
|
|
699
750
|
.optional()
|
|
700
751
|
.describe("Listing (saved view) name to query, case-insensitive; 'archive' targets archived entries. Defaults to the unfiltered 'Everything' view, which is admin-only on modules with listings — non-admins must name an accessible listing (an access-denied response lists them)."),
|
|
701
752
|
state: z.string().optional(),
|
|
702
|
-
search: z.string().optional().describe("Free-text search across document ID, state, and text-like fields; supports * and ? wildcards"),
|
|
703
|
-
filters: z
|
|
753
|
+
search: z.string().optional().describe("Free-text search across document ID, state, and text-like fields; supports * and ? wildcards on the entries Inistate stores. A module whose entries are kept in another connected system passes the text to that system as typed, where * and ? are not wildcards: search plain text there"),
|
|
754
|
+
filters: z
|
|
755
|
+
.record(z.unknown())
|
|
756
|
+
.optional()
|
|
757
|
+
.describe('Filter keys are field display names; see the tool description for the operators. To filter on a Table field\'s columns, name the table and put the conditions in `rows`: { "Result Details": { "rows": [ { "Out of Spec": { "yes": true } } ] } } returns the entries with at least one row meeting the conditions. A column is named bare (never "Table.Column" and never directly under the table: { "Result Details": { "Out of Spec": true } } only means "has rows"), takes the operators of its own type, and a Module column matches by display value ({ "Parameter": "Sodium (as Na)" }). Conditions in rows are AND-ed. { "Table": { "exists": true } } and { "Table": { "none": true } } test for rows. The entries come back with all their rows, not only the matching ones.'),
|
|
704
758
|
};
|
|
705
759
|
export function registerTools(server, backend) {
|
|
706
760
|
const configureTools = [];
|
|
@@ -779,6 +833,51 @@ export function registerTools(server, backend) {
|
|
|
779
833
|
}
|
|
780
834
|
return repairs;
|
|
781
835
|
};
|
|
836
|
+
/**
|
|
837
|
+
* An update's design checked as the module will read after it: the payload's sections laid over the module's
|
|
838
|
+
* current canvas, a passed section replacing that section as update_module saves it. A partial payload used to be
|
|
839
|
+
* checked alone, so a flow from "Draft" to a state "Nowhere" by an activity "Missing" passed validate_design in
|
|
840
|
+
* update mode (QA 2026-11-25, N3): the checks that need the states and activities skipped a payload without them.
|
|
841
|
+
* What the module's design already gets wrong is a warning here, not an error: this payload did not cause it, and
|
|
842
|
+
* the platform judges it as before. Null when the payload omits no section the canvas has (it is checked alone,
|
|
843
|
+
* as a full canvas) or the canvas cannot be read (the caller checks the payload alone, as before).
|
|
844
|
+
*/
|
|
845
|
+
const DESIGN_SECTIONS = ["information", "states", "activities", "flows"];
|
|
846
|
+
const validateOverCanvas = async (moduleRef, payload) => {
|
|
847
|
+
const canvas = (await fetchCanvas(moduleRef));
|
|
848
|
+
if (!canvas || typeof canvas !== "object")
|
|
849
|
+
return null;
|
|
850
|
+
const current = {};
|
|
851
|
+
for (const s of DESIGN_SECTIONS)
|
|
852
|
+
if (Array.isArray(canvas[s]))
|
|
853
|
+
current[s] = canvas[s];
|
|
854
|
+
const kept = DESIGN_SECTIONS.filter((s) => payload[s] === undefined && current[s] !== undefined);
|
|
855
|
+
if (kept.length === 0)
|
|
856
|
+
return null;
|
|
857
|
+
const merged = { ...payload };
|
|
858
|
+
for (const s of kept)
|
|
859
|
+
merged[s] = current[s];
|
|
860
|
+
const before = validateDesign(structuredClone(current), "update");
|
|
861
|
+
const after = validateDesign(structuredClone(merged), "update");
|
|
862
|
+
// An error is the same one when it differs only in the names it offers ("Available states: ...").
|
|
863
|
+
const same = (m) => m.replace(/ Available [a-z]+: .*$/s, "");
|
|
864
|
+
const knownErrors = new Set(before.errors.map(same));
|
|
865
|
+
const knownWarnings = new Set(before.warnings.map(same));
|
|
866
|
+
const errors = after.errors.filter((e) => !knownErrors.has(same(e)));
|
|
867
|
+
const warnings = [
|
|
868
|
+
...after.warnings.filter((w) => !knownWarnings.has(same(w))),
|
|
869
|
+
...after.errors
|
|
870
|
+
.filter((e) => knownErrors.has(same(e)))
|
|
871
|
+
.map((e) => `Already in the module's design, not from this payload: ${e}`),
|
|
872
|
+
];
|
|
873
|
+
return {
|
|
874
|
+
valid: errors.length === 0,
|
|
875
|
+
errors,
|
|
876
|
+
warnings,
|
|
877
|
+
summary: errors.length === 0 ? after.summary : null,
|
|
878
|
+
checked: `The payload over module ${moduleRef}'s current design (its ${kept.join(", ")} as saved).`,
|
|
879
|
+
};
|
|
880
|
+
};
|
|
782
881
|
/**
|
|
783
882
|
* Point this call at workspaceId when given. It writes the call's own context (registerTool
|
|
784
883
|
* below), never anything a later call sees.
|
|
@@ -879,7 +978,11 @@ export function registerTools(server, backend) {
|
|
|
879
978
|
// are exposed.
|
|
880
979
|
const gov = caps.governance;
|
|
881
980
|
const aiSourcesShape = z
|
|
882
|
-
.array(z.object({
|
|
981
|
+
.array(z.object({
|
|
982
|
+
type: z.string().optional().describe("Kind of evidence: user_message, entry, document, url or module."),
|
|
983
|
+
reference: z.string().optional().describe("Id or URL that locates the source."),
|
|
984
|
+
excerpt: z.string().optional().describe("The part of the source the decision relied on."),
|
|
985
|
+
}))
|
|
883
986
|
.optional();
|
|
884
987
|
// Coerce a stringly-typed confidence ("0.95") before the number check, in
|
|
885
988
|
// place — the single mismatch that most often dead-ends a weaker model's
|
|
@@ -894,11 +997,11 @@ export function registerTools(server, backend) {
|
|
|
894
997
|
};
|
|
895
998
|
const submitAiShape = z.preprocess(repairAi, z.object({
|
|
896
999
|
reasoning: z.string().describe("Why the AI chose this action — recorded for audit. Keep short and precise; one or two sentences."),
|
|
897
|
-
model: z.string().describe("e.g. claude-haiku-4-5
|
|
898
|
-
confidence: z.number().min(0).max(100).describe("0
|
|
899
|
-
sources: aiSourcesShape,
|
|
900
|
-
model_version: z.string().optional(),
|
|
901
|
-
prompt_hash: z.string().optional(),
|
|
1000
|
+
model: z.string().describe("Identifier of the model making this call, e.g. claude-haiku-4-5."),
|
|
1001
|
+
confidence: z.number().min(0).max(100).describe("How confident the AI is in this action: a fraction (0.95) or a percent (95; values above 1 are read as percent). Compared with the activity's confidence_threshold, below which the state change is suppressed and the entry flagged."),
|
|
1002
|
+
sources: aiSourcesShape.describe("What the AI based the action on."),
|
|
1003
|
+
model_version: z.string().optional().describe("Version or checkpoint of the model."),
|
|
1004
|
+
prompt_hash: z.string().optional().describe("Hash of the system prompt used."),
|
|
902
1005
|
}));
|
|
903
1006
|
const submitAiParam = gov
|
|
904
1007
|
? submitAiShape.describe("REQUIRED — AI agent traceability")
|
|
@@ -928,11 +1031,11 @@ export function registerTools(server, backend) {
|
|
|
928
1031
|
const designRecordKept = caps.designRecord === true;
|
|
929
1032
|
const designAiShape = z.preprocess(repairAi, z.object({
|
|
930
1033
|
reasoning: z.string().describe("Why the design changes this way — the change note kept in the module's history (≤ 2000 chars). One or two sentences naming the decision, e.g. \"Added Discount because quotes over 10k need a negotiated price\"."),
|
|
931
|
-
model: z.string().describe("e.g. claude-opus-4-7"),
|
|
1034
|
+
model: z.string().describe("Identifier of the model making this call, e.g. claude-opus-4-7."),
|
|
932
1035
|
request: z.string().optional().describe("A short paraphrase of what the user asked for (≤ 500 chars). No personal data beyond what the design needs."),
|
|
933
1036
|
sources: aiSourcesShape.describe("Evidence for the change: {type: user_message | entry | document | url | module, reference, excerpt}. References as ids or URLs."),
|
|
934
|
-
model_version: z.string().optional(),
|
|
935
|
-
prompt_hash: z.string().optional(),
|
|
1037
|
+
model_version: z.string().optional().describe("Version or checkpoint of the model."),
|
|
1038
|
+
prompt_hash: z.string().optional().describe("Hash of the system prompt used."),
|
|
936
1039
|
}));
|
|
937
1040
|
const designAiParam = designRecordKept && gov
|
|
938
1041
|
? designAiShape.describe("REQUIRED — why the design changes, kept in the module's history. Not the module's description.")
|
|
@@ -969,10 +1072,10 @@ export function registerTools(server, backend) {
|
|
|
969
1072
|
.describe("Optimistic concurrency: the `version` from get_entry. The write fails with CONFLICT if the stored version differs."),
|
|
970
1073
|
};
|
|
971
1074
|
const submitActivityDescription = gov
|
|
972
|
-
? "Write operation: one call performs exactly one named activity on one entry of one module, and nothing else runs. The activity is the `activity` argument — a standard one (create [no entryId], edit, delete, changeStatus, comment, duplicate, manage) or a custom activity the workspace's designer defined (listed by get_module_schema tier=extended); activity names are data, not hidden tools. Call get_form before the first submission per (module, activity); reuse its schema for further entries. The `ai` object is REQUIRED (reasoning + model + confidence). If confidence < the activity's threshold, the transition is suppressed and the entry is flagged. Server-side guard rules (human/hybrid actor, state-change confirm, confidence-inflation) may block — see inistate://guardrails. Input shapes: ActivitySubmission in inistate://schema/runtime."
|
|
1075
|
+
? "Write operation: one call performs exactly one named activity on one entry of one module, and nothing else runs. The activity is the `activity` argument — a standard one (create [no entryId], edit, delete, changeStatus, comment, duplicate, manage) or a custom activity the workspace's designer defined (listed by get_module_schema tier=extended); activity names are data, not hidden tools. Call get_form before the first submission per (module, activity); reuse its schema for further entries. The `ai` object is REQUIRED (reasoning + model + confidence). If confidence < the activity's threshold, the transition is suppressed and the entry is flagged. Server-side guard rules (human/hybrid actor, state-change confirm, confidence-inflation) may block — see inistate://guardrails. Input shapes: ActivitySubmission in inistate://schema/runtime. Fields masked for AI (listed under aiPrivacy in get_module_schema and get_form) arrive as ••••6789: to keep such a value, send the mask back unchanged or leave the field out; send a full new value only when the user gave one, and never guess the hidden part."
|
|
973
1076
|
: "Write operation: one call performs exactly one named activity on one entry of one module, and nothing else runs. The activity is the `activity` argument — create (no entryId), edit, delete, or a custom activity defined by the workspace's designer that drives a state transition; activity names are data, not hidden tools. Call get_form before the first submission per (module, activity); reuse its schema for further entries. A custom activity is accepted only if a flow permits it from the entry's current state — otherwise it is rejected (Illegal transition) and nothing is written. The local runtime applies no confidence/actor gating: `ai` is optional and there is no flagged outcome. Use idempotencyKey for safe retries and expectedVersion for optimistic concurrency.";
|
|
974
1077
|
const submitActivitiesDescription = gov
|
|
975
|
-
? "Write operation, the bulk variant of submit_activity: one call applies one named activity of one module to many entries (the same activity for every item; nothing else runs), each item with its own input. Use instead of N sequential submit_activity calls when creating/editing many rows — one tool turn instead of N. A per-item `ai` wholly replaces the top-level default (no partial merge). Items run sequentially fail-soft on the server: one failure does not abort the rest; per-item outcomes (success, entryId, flagged, validation details) return in `results` — use `clientRef` to correlate. Max 100 items; chunk beyond that. Guardrails match submit_activity at batch level: actor='human' rejects the whole batch; actor='hybrid', activity='changeStatus', or any state override (top-level or per-item) requires `confirmed: true`."
|
|
1078
|
+
? "Write operation, the bulk variant of submit_activity: one call applies one named activity of one module to many entries (the same activity for every item; nothing else runs), each item with its own input. Use instead of N sequential submit_activity calls when creating/editing many rows — one tool turn instead of N. A per-item `ai` wholly replaces the top-level default (no partial merge). Items run sequentially fail-soft on the server: one failure does not abort the rest; per-item outcomes (success, entryId, flagged, validation details) return in `results` — use `clientRef` to correlate. Max 100 items; chunk beyond that. Guardrails match submit_activity at batch level: actor='human' rejects the whole batch; actor='hybrid', activity='changeStatus', or any state override (top-level or per-item) requires `confirmed: true`. Fields masked for AI (listed under aiPrivacy in get_module_schema and get_form) arrive as ••••6789: to keep such a value, send the mask back unchanged or leave the field out; send a full new value only when the user gave one, and never guess the hidden part."
|
|
976
1079
|
: "Write operation, the bulk variant of submit_activity: one call applies one named activity of one module to many entries (the same activity for every item; nothing else runs), each item with its own input. Use instead of N sequential submit_activity calls when creating/editing many rows. A per-item `ai` wholly replaces the top-level default. Items run sequentially fail-soft: one failure does not abort the rest; per-item outcomes return in `results` — use `clientRef` to correlate. Max 100 items per request. The local runtime applies no confidence/actor gating.";
|
|
977
1080
|
/**
|
|
978
1081
|
* A module's states as an agent needs them on arrival: each name plus what
|
|
@@ -1106,7 +1209,7 @@ export function registerTools(server, backend) {
|
|
|
1106
1209
|
// ═══════════════════════════════════════════
|
|
1107
1210
|
registerTool("list_workspaces", {
|
|
1108
1211
|
title: "List Workspaces",
|
|
1109
|
-
description: gatedDesc(caps.workspaces, "List workspaces the current user has access to. Typically the first call of a session.
|
|
1212
|
+
description: gatedDesc(caps.workspaces, "List workspaces the current user has access to. Typically the first call of a session. Answers { workspaces: [{ id, name }] }; if exactly one workspace matches, its module list is returned too (`autoSelected`) — no set_workspace or list_modules needed. The MCP keeps no workspace between calls: pass the chosen workspace's id as workspaceId on every later call. Administrators: without `search` this lists your own memberships; pass `search` to find any workspace by name."),
|
|
1110
1213
|
inputSchema: {
|
|
1111
1214
|
search: z
|
|
1112
1215
|
.string()
|
|
@@ -1140,7 +1243,9 @@ export function registerTools(server, backend) {
|
|
|
1140
1243
|
}
|
|
1141
1244
|
}
|
|
1142
1245
|
}
|
|
1143
|
-
|
|
1246
|
+
// One shape however many match (QA 2026-11-25, N12): it used to be a bare list for several workspaces and an
|
|
1247
|
+
// object for one.
|
|
1248
|
+
return ok(Array.isArray(data) ? { workspaces: data } : data);
|
|
1144
1249
|
}
|
|
1145
1250
|
catch (e) {
|
|
1146
1251
|
return err(e);
|
|
@@ -1721,11 +1826,11 @@ Only platform administrators bypass these rules; workspace admins are subject to
|
|
|
1721
1826
|
- Every save runs the automation's stored tests (sent with it in \`tests\`, or kept) on the design with it, and answers with each test's result. A schedule's save simulates its next run on the entries it matches now instead. Nothing is stored or sent by either.
|
|
1722
1827
|
- Use dryRun: true to see the checks, the tests and the simulation without saving. Do this before every real save.
|
|
1723
1828
|
- A new automation is saved switched off. Switching one on, or changing one that is on, returns automation_on_requires_confirmation and saves nothing: show the admin the dry run's test report (or the simulated next run) and ask. Resend with confirmed: true only after they explicitly say yes; never confirm on their behalf.
|
|
1724
|
-
- Switching on also needs at least one stored test, all passing (a schedule: its next run simulating cleanly). The AI cannot override this.
|
|
1829
|
+
- Switching on also needs at least one stored test, all passing (a schedule: its next run simulating cleanly). The AI cannot override this. A test whose automation writes to a module kept at an external API plans that write and checks it without sending it, so it can pass; what only the provider checks is proven by the first live runs, which probation watches (it pauses the automation after failures in a row).
|
|
1725
1830
|
- A save is a new version of the module by the connection's user, so the Studio's version history can restore the one before. Once on, its first live runs are watched (probation, see get_automation_runs).`, "The connected backend has no automations."),
|
|
1726
1831
|
inputSchema: {
|
|
1727
1832
|
module: z.string().describe("Module name or numeric ID"),
|
|
1728
|
-
automation: automationShape.describe("The automation: { id?, name, activity, enabled?, before?, after?, queued?, tests? } (queued: true runs `after` from the queue with retries, for a write to
|
|
1833
|
+
automation: automationShape.describe("The automation: { id?, name, activity, enabled?, before?, after?, queued?, tests? } (queued: true runs `after` from the queue with retries, for a write to an outside system), or a schedule { id?, name, schedule, filter, execution?, run, enabled? }"),
|
|
1729
1834
|
dryRun: z.boolean().optional().describe("Check, test and simulate without saving"),
|
|
1730
1835
|
confirmed: z.boolean().optional().describe("Set only after the admin explicitly approved switching it on (or changing one that is on)"),
|
|
1731
1836
|
workspaceId: wsParam,
|
|
@@ -1839,7 +1944,7 @@ Only platform administrators bypass these rules; workspace admins are subject to
|
|
|
1839
1944
|
sortBy: z.string().optional(),
|
|
1840
1945
|
sortDirection: z.enum(["asc", "desc"]).default("asc").optional(),
|
|
1841
1946
|
currentPage: z.number().int().default(0).optional(),
|
|
1842
|
-
pageSize: z.number().int().default(50).optional().describe("Default 50,
|
|
1947
|
+
pageSize: z.number().int().default(50).optional().describe("Default 50. A page holds at most 500 rows: a larger pageSize is read as 500, and the answer says so (pageSize_note)"),
|
|
1843
1948
|
fields: z
|
|
1844
1949
|
.array(z.string())
|
|
1845
1950
|
.optional()
|
|
@@ -1910,6 +2015,15 @@ Only platform administrators bypass these rules; workspace admins are subject to
|
|
|
1910
2015
|
: `check: ${issues.join("; ")}`;
|
|
1911
2016
|
}
|
|
1912
2017
|
}
|
|
2018
|
+
// A pageSize above what one page holds came back as a smaller page with nothing said (QA 2026-11-25, N9:
|
|
2019
|
+
// pageSize 1000 answered pageSize 500), so a full page read as the whole list.
|
|
2020
|
+
if (data && typeof data === "object" && typeof pageSize === "number") {
|
|
2021
|
+
const served = Number(data.pageSize);
|
|
2022
|
+
if (Number.isFinite(served) && served > 0 && served < pageSize) {
|
|
2023
|
+
data.pageSize_note =
|
|
2024
|
+
`A page holds at most ${served} rows, so pageSize ${pageSize} was read as ${served}. Read on with currentPage (hasMore says whether there is more), or count and total with aggregate_entries.`;
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
1913
2027
|
return ok(data);
|
|
1914
2028
|
}
|
|
1915
2029
|
catch (e) {
|
|
@@ -2033,10 +2147,10 @@ Only platform administrators bypass these rules; workspace admins are subject to
|
|
|
2033
2147
|
title: "Submit Activity",
|
|
2034
2148
|
description: submitActivityDescription,
|
|
2035
2149
|
inputSchema: {
|
|
2036
|
-
module: z.string(),
|
|
2037
|
-
activity: z.string().default("create"),
|
|
2038
|
-
entryId: z.union([z.string(), z.number()]).optional().describe("
|
|
2039
|
-
entryIds: z.array(z.union([z.string(), z.number()])).optional().describe("
|
|
2150
|
+
module: z.string().describe("Name of the module the entry belongs to, as list_modules returns it."),
|
|
2151
|
+
activity: z.string().default("create").describe("Name of the activity to perform: create, edit, delete, or a custom activity of the module (get_form and get_module_schema list them)."),
|
|
2152
|
+
entryId: z.union([z.string(), z.number()]).optional().describe("The entry to act on: the entryId from list_entries or get_entry. Leave out when the activity is create."),
|
|
2153
|
+
entryIds: z.array(z.union([z.string(), z.number()])).optional().describe("The entries a bulk operation applies to, as entryId values from list_entries; use entryId for a single entry."),
|
|
2040
2154
|
// `null` is the one non-object worth tolerating: several clients send it for "no fields".
|
|
2041
2155
|
// Anything else that is not an object reaches the handler and is REFUSED there. It used to
|
|
2042
2156
|
// be coerced to undefined, which meant a string or array of field values was dropped and the
|
|
@@ -2047,10 +2161,10 @@ Only platform administrators bypass these rules; workspace admins are subject to
|
|
|
2047
2161
|
input: z
|
|
2048
2162
|
.preprocess(v => (v === null ? undefined : isNonObjectInput(v) ? { [NON_OBJECT_INPUT]: v } : v), z.record(z.unknown()).optional())
|
|
2049
2163
|
.describe("Field values keyed by display name, as an object (never a JSON-encoded string). File/Image: {name,path}. Module: {id,value} (both required). User: {id,value,username} (all three required). Plural variants (Users/Modules/Files/Images): arrays of those objects. Location: {lat,lng,placeName} — lat/lng unquoted numbers, placeName the place's display name; never a combined \"lat,lng\" string. Table: an array of row objects keyed by sub-field name, e.g. [{\"Item Code\": \"A-1\", \"Qty\": 2}]. Number/Currency/Integer: JSON numbers, never strings, at the top level and inside Table rows. YesNo: true or false, never \"yes\". Text/MultilineText/Email: one string — join lines with \\n, never an array. User/Module/Location shapes and YesNo/text value types are validated pre-flight — bare ids, bare strings, wrong value types, or objects missing any required key will be rejected."),
|
|
2050
|
-
state: z.string().optional().describe("
|
|
2051
|
-
comment: z.string().optional().describe("
|
|
2052
|
-
assignees: z.array(z.string()).optional().describe("Usernames"),
|
|
2053
|
-
due: z.string().optional().describe("ISO 8601"),
|
|
2164
|
+
state: z.string().optional().describe("Name of a state to move the entry to, overriding the flow. Needs confirmed: true after the user approves."),
|
|
2165
|
+
comment: z.string().optional().describe("A note to the user, only when something must be said directly. Keep it short; the detail belongs in the fields."),
|
|
2166
|
+
assignees: z.array(z.string()).optional().describe("Usernames of the members to assign the entry to."),
|
|
2167
|
+
due: z.string().optional().describe("The entry's due date as an ISO 8601 date-time."),
|
|
2054
2168
|
ai: submitAiParam,
|
|
2055
2169
|
confirmed: z
|
|
2056
2170
|
.boolean()
|
|
@@ -2063,6 +2177,7 @@ Only platform administrators bypass these rules; workspace admins are subject to
|
|
|
2063
2177
|
...reliabilityParams,
|
|
2064
2178
|
workspaceId: wsParam,
|
|
2065
2179
|
},
|
|
2180
|
+
outputSchema: z.object(submitActivityOutput).passthrough(),
|
|
2066
2181
|
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false, idempotentHint: false },
|
|
2067
2182
|
}, async ({ module: moduleName, activity, entryId, entryIds, input: wrappedInput, state, comment, assignees, due, ai, confirmed, approval, dryRun, expect, as: actsAs, workspaceId, ...extra }) => {
|
|
2068
2183
|
// Local-runtime-only reliability controls (absent from the cloud schema).
|
|
@@ -2097,7 +2212,7 @@ Only platform administrators bypass these rules; workspace admins are subject to
|
|
|
2097
2212
|
return rehearsal;
|
|
2098
2213
|
if (approval) {
|
|
2099
2214
|
if (!approvalsAvailable)
|
|
2100
|
-
return
|
|
2215
|
+
return okStructured(capabilityMessage("approvals", backend.kind));
|
|
2101
2216
|
const extras = [state && "state", comment && "comment", assignees && "assignees", due && "due", entryIds && "entryIds"]
|
|
2102
2217
|
.filter(Boolean);
|
|
2103
2218
|
if (extras.length > 0) {
|
|
@@ -2241,7 +2356,7 @@ Only platform administrators bypass these rules; workspace admins are subject to
|
|
|
2241
2356
|
if (inputKeyNotes.length > 0 && sent && typeof sent === "object") {
|
|
2242
2357
|
sent.input_key_notes = inputKeyNotes;
|
|
2243
2358
|
}
|
|
2244
|
-
return
|
|
2359
|
+
return okStructured(sent);
|
|
2245
2360
|
}
|
|
2246
2361
|
catch (e) {
|
|
2247
2362
|
return approvalsNotSupported(e);
|
|
@@ -2289,7 +2404,7 @@ Only platform administrators bypass these rules; workspace admins are subject to
|
|
|
2289
2404
|
const data = await backend.submitActivity(body);
|
|
2290
2405
|
if (dryRun) {
|
|
2291
2406
|
log("submit_activity", `module=${moduleName} activity=${activity} entry=${target} → simulated ok=${data?.ok}`);
|
|
2292
|
-
return
|
|
2407
|
+
return okStructured(data);
|
|
2293
2408
|
}
|
|
2294
2409
|
const flagged = data && typeof data === "object" && data.flagged === true;
|
|
2295
2410
|
const flagTargets = entryIds && entryIds.length > 0 ? entryIds : [entryId];
|
|
@@ -2311,7 +2426,7 @@ Only platform administrators bypass these rules; workspace admins are subject to
|
|
|
2311
2426
|
data.input_key_notes = inputKeyNotes;
|
|
2312
2427
|
}
|
|
2313
2428
|
log("submit_activity", `module=${moduleName} activity=${activity} entry=${target} → ${flagged ? "flagged" : "ok"}`);
|
|
2314
|
-
return
|
|
2429
|
+
return okStructured(data);
|
|
2315
2430
|
}
|
|
2316
2431
|
catch (e) {
|
|
2317
2432
|
const target = entryId ?? (entryIds ? `bulk(${entryIds.length})` : "new");
|
|
@@ -2738,7 +2853,7 @@ Only platform administrators bypass these rules; workspace admins are subject to
|
|
|
2738
2853
|
// ═══════════════════════════════════════════
|
|
2739
2854
|
registerTool("download_file", {
|
|
2740
2855
|
title: "Download File",
|
|
2741
|
-
description: gatedDesc(caps.files, "Download a file by module name. Construct the URL from a File/Image field value: field.path = '/s/{guid}/{fileName}'. Returns a pre-signed S3 URL (1hr TTL)."),
|
|
2856
|
+
description: gatedDesc(caps.files, "Download a file by module name. Construct the URL from a File/Image field value: field.path = '/s/{guid}/{fileName}'. Returns a pre-signed S3 URL (1hr TTL). It takes files Inistate stores only: a file kept in another connected system is not one (its entry's link field, read with get_entry, opens it), so an entry id, a storage key or a bare filename answers not found."),
|
|
2742
2857
|
inputSchema: {
|
|
2743
2858
|
moduleName: z.string().describe("Module name (resolved to vectorId internally)"),
|
|
2744
2859
|
guid: z.string().describe("Short ID from the file URL"),
|
|
@@ -2926,21 +3041,29 @@ Load resources inistate://schema/configure and inistate://design-guide before de
|
|
|
2926
3041
|
// ═══════════════════════════════════════════
|
|
2927
3042
|
configureTools.push(registerTool("validate_design", {
|
|
2928
3043
|
title: "Validate Design",
|
|
2929
|
-
description: "Validate a module schema without submitting anything. create_module
|
|
3044
|
+
description: "Validate a module schema without submitting anything. create_module and update_module run these same checks internally, so this tool is optional — use it to iterate on a draft. In update mode, put the module's id (from get_module_canvas) in the schema with the sections you change: the sections you leave out are read from the module, and the design is checked as the module will read after the update (flows against its states and activities). Problems already in the module's design come back as warnings.",
|
|
2930
3045
|
inputSchema: {
|
|
2931
3046
|
schema: z
|
|
2932
3047
|
.record(z.unknown())
|
|
2933
|
-
.describe("A complete or partial ModuleSchema object"),
|
|
3048
|
+
.describe("A complete or partial ModuleSchema object; in update mode, with the module's id"),
|
|
2934
3049
|
mode: z
|
|
2935
3050
|
.enum(["create", "update"])
|
|
2936
3051
|
.default("create")
|
|
2937
|
-
.describe("create = new module (all rules). update =
|
|
3052
|
+
.describe("create = new module (all rules). update = the sections given, laid over the module named by schema.id (omitted sections are read from it)."),
|
|
2938
3053
|
workspaceId: wsParam,
|
|
2939
3054
|
},
|
|
2940
3055
|
annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false, idempotentHint: true },
|
|
2941
3056
|
}, async ({ schema, mode, workspaceId }) => {
|
|
2942
3057
|
applyWorkspace(workspaceId);
|
|
2943
|
-
const
|
|
3058
|
+
const moduleId = schema.id;
|
|
3059
|
+
const overCanvas = mode === "update" && (typeof moduleId === "string" || typeof moduleId === "number") && moduleId !== ""
|
|
3060
|
+
? await validateOverCanvas(String(moduleId), schema)
|
|
3061
|
+
: null;
|
|
3062
|
+
const result = overCanvas ?? validateDesign(schema, mode);
|
|
3063
|
+
if (!overCanvas && mode === "update" && Array.isArray(schema.flows)
|
|
3064
|
+
&& (!Array.isArray(schema.states) || !Array.isArray(schema.activities))) {
|
|
3065
|
+
result.warnings.push("The flows were checked only for completeness: this schema carries no states or activities, and the module's own could not be read (no module id in the schema, or the read failed), so a flow naming a state or activity that does not exist would pass here. Put the module's id (from get_module_canvas) in the schema to check them against the module.");
|
|
3066
|
+
}
|
|
2944
3067
|
// create_module rejects connections naming a module that does not exist
|
|
2945
3068
|
// in the workspace — check here too so this dry-run keeps its
|
|
2946
3069
|
// no-surprises contract (fails open when the module list is unavailable).
|
|
@@ -2961,7 +3084,7 @@ Load resources inistate://schema/configure and inistate://design-guide before de
|
|
|
2961
3084
|
title: "Create Module",
|
|
2962
3085
|
description: "Create a new module. Supports workflow modules (states, activities, flows) and record list modules (fields only). Requires Administrator, Consultant, or Workspace Admin role. Validates internally with the same rules as validate_design and returns structured errors without creating anything — a separate validate_design call beforehand is optional. See inistate://schema/configure for field types, color palette, and design rules. A new module is open to everyone in the workspace until set_module_access restricts it.",
|
|
2963
3086
|
inputSchema: {
|
|
2964
|
-
name: z.string().describe("
|
|
3087
|
+
name: z.string().describe("Display name of the new module, shown in the module list and used as the `module` argument in other tools. Names that repeat one already in the workspace are ambiguous: the platform resolves a name to its first match only."),
|
|
2965
3088
|
...moduleSectionsShape,
|
|
2966
3089
|
profile: z.boolean().optional().describe("Make it a people module: one entry per member, linked by the built-in Username field (name 'Username' in an activity's fields; the standard Create, Edit and View forms carry it). Its fields — e.g. a Position selection — are what position grants in set_module_access read. Create only."),
|
|
2967
3090
|
dryRun: z.unknown().optional().describe("Not here: create_module always creates. validate_design checks a new design without creating it."),
|
|
@@ -2969,6 +3092,7 @@ Load resources inistate://schema/configure and inistate://design-guide before de
|
|
|
2969
3092
|
approval: designApprovalParam,
|
|
2970
3093
|
workspaceId: wsParam,
|
|
2971
3094
|
},
|
|
3095
|
+
outputSchema: z.object(moduleWriteOutput).passthrough(),
|
|
2972
3096
|
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: false, idempotentHint: false },
|
|
2973
3097
|
}, async ({ name, icon, description: desc, information, states, activities, flows, card, profile, documentIdFormat, dryRun, ai, approval, workspaceId, }) => {
|
|
2974
3098
|
// Declared only to answer with the right tool (G6): zod would drop it, and the module be created.
|
|
@@ -3046,7 +3170,7 @@ Load resources inistate://schema/configure and inistate://design-guide before de
|
|
|
3046
3170
|
return err({ structured: designApprovalsUnsupported });
|
|
3047
3171
|
const data = await backend.createModule(body, designProvenance());
|
|
3048
3172
|
log("create_module", `name=${name} → ok`);
|
|
3049
|
-
return
|
|
3173
|
+
return okStructured(data);
|
|
3050
3174
|
}
|
|
3051
3175
|
catch (e) {
|
|
3052
3176
|
log("create_module", `name=${name} → FAILED: ${e instanceof Error ? e.message : String(e)}`);
|
|
@@ -3058,7 +3182,7 @@ Load resources inistate://schema/configure and inistate://design-guide before de
|
|
|
3058
3182
|
// ═══════════════════════════════════════════
|
|
3059
3183
|
configureTools.push(registerTool("update_module", {
|
|
3060
3184
|
title: "Update Module",
|
|
3061
|
-
description: "Update an existing module. A section you pass (information/states/activities/flows) replaces that section's entire list — include every existing item you want to keep (matched by id, which enables renaming; omit id to add new items). Omitted sections are left unchanged. Always call get_module_canvas first to obtain the stable module id and item ids.
|
|
3185
|
+
description: "Update an existing module. A section you pass (information/states/activities/flows) replaces that section's entire list — include every existing item you want to keep (matched by id, which enables renaming; omit id to add new items). Omitted sections are left unchanged. Always call get_module_canvas first to obtain the stable module id and item ids. The update is validated internally like create_module, a partial payload as laid over the module's current design (flows against the states and activities it keeps); a problem already in that design does not block it. dryRun: true checks the update and runs the module's stored tests on it without saving. Access rules are not changed here: use set_module_access. A change that needs a person — an activity's actor loosened or its humanWhen removed or rewritten, access rules or designActor changed, a field, state, activity or flow with entries behind it removed, a field with values renamed or retyped, ai_instruction text, a script removed with the item that holds it (scripts are read-only here; leave get_module_canvas's scripts out), the module renamed or unpublished, or any change to a module or workspace that asks for every one — answers design_approval_required with the reasons: tell the user and offer to send it; only if they say so, send the same payload again with approval." +
|
|
3062
3186
|
(caps.relink ? " Changing what a Module field (or a table's Module column) links while entries hold values in it answers relink_required: move the field and its values with relink_field instead." : ""),
|
|
3063
3187
|
inputSchema: {
|
|
3064
3188
|
id: z
|
|
@@ -3075,6 +3199,7 @@ Load resources inistate://schema/configure and inistate://design-guide before de
|
|
|
3075
3199
|
baseVersion: z.string().optional().describe("The versionId get_module_canvas returned: the design version you edited. A save from an older version still goes through and is marked stale in the history."),
|
|
3076
3200
|
workspaceId: wsParam,
|
|
3077
3201
|
},
|
|
3202
|
+
outputSchema: z.object(moduleWriteOutput).passthrough(),
|
|
3078
3203
|
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false, idempotentHint: true },
|
|
3079
3204
|
}, async ({ id, name, icon, description: desc, information, states, activities, flows, card, access, listings, automations, documentIdFormat, dryRun, ai, approval, baseVersion, workspaceId, }) => {
|
|
3080
3205
|
const redirected = Object.entries({ access, listings, automations }).find(([, value]) => value !== undefined);
|
|
@@ -3159,12 +3284,13 @@ Load resources inistate://schema/configure and inistate://design-guide before de
|
|
|
3159
3284
|
});
|
|
3160
3285
|
}
|
|
3161
3286
|
}
|
|
3162
|
-
//
|
|
3163
|
-
//
|
|
3164
|
-
//
|
|
3165
|
-
// platform
|
|
3166
|
-
|
|
3167
|
-
|
|
3287
|
+
// A payload with information is checked alone, as before (the check also repairs it in place). One that
|
|
3288
|
+
// leaves out a section the module has is checked laid over the module's canvas, as validate_design does in
|
|
3289
|
+
// update mode: its flows against the states and activities the module keeps (N3). Fail-open: no canvas,
|
|
3290
|
+
// and a payload without information goes to the platform as before.
|
|
3291
|
+
const alone = information ? validateDesign(body, "update") : null;
|
|
3292
|
+
const validation = (await validateOverCanvas(String(id), body)) ?? alone;
|
|
3293
|
+
if (validation) {
|
|
3168
3294
|
const connErrors = await checkConnectionTargets(body.information, name);
|
|
3169
3295
|
if (!validation.valid || connErrors.length > 0) {
|
|
3170
3296
|
const errors = [...validation.errors, ...connErrors];
|
|
@@ -3186,12 +3312,12 @@ Load resources inistate://schema/configure and inistate://design-guide before de
|
|
|
3186
3312
|
const data = await backend.updateModule(body, designProvenance());
|
|
3187
3313
|
log("update_module", `id=${id} → ok`);
|
|
3188
3314
|
if (idRepairs.length > 0 && data && typeof data === "object" && !Array.isArray(data)) {
|
|
3189
|
-
return
|
|
3315
|
+
return okStructured({
|
|
3190
3316
|
...data,
|
|
3191
3317
|
hint: `Ids matching no existing element were removed; these items were created as new: ${idRepairs.join(", ")}. Use ids from get_module_canvas to update/rename existing items.`,
|
|
3192
3318
|
});
|
|
3193
3319
|
}
|
|
3194
|
-
return
|
|
3320
|
+
return okStructured(data);
|
|
3195
3321
|
}
|
|
3196
3322
|
catch (e) {
|
|
3197
3323
|
// The platform's canvas-consistency failure ("Column references
|
package/inistate-schema.json
CHANGED
|
@@ -904,6 +904,18 @@
|
|
|
904
904
|
"not": { "type": "string" },
|
|
905
905
|
"includes": { "type": "string" }
|
|
906
906
|
}
|
|
907
|
+
},
|
|
908
|
+
"_table": {
|
|
909
|
+
"type": "object",
|
|
910
|
+
"description": "Table field operators. Filter a Table's columns with `rows`: an array of conditions keyed by column display name (bare, never 'Table.Column'), each using the operators of that column's own type; a Module column matches by display value. Conditions are AND-ed. The entry matches when at least one row meets them. Example: {\"Result Details\": {\"rows\": [{\"Out of Spec\": {\"yes\": true}}, {\"Parameter\": \"Sodium (as Na)\"}]}}. Naming a column directly under the table ({\"Result Details\": {\"Out of Spec\": true}}) is not a column filter: it matches every entry that has rows. The entries are returned with all their rows, not only the matching ones.",
|
|
911
|
+
"properties": {
|
|
912
|
+
"rows": {
|
|
913
|
+
"type": "array",
|
|
914
|
+
"items": { "type": "object", "description": "One condition set, keyed by column display name" }
|
|
915
|
+
},
|
|
916
|
+
"exists": { "type": "boolean", "description": "The table has at least one row" },
|
|
917
|
+
"none": { "type": "boolean", "description": "The table has no rows" }
|
|
918
|
+
}
|
|
907
919
|
}
|
|
908
920
|
}
|
|
909
921
|
},
|
package/package.json
CHANGED
package/server.json
CHANGED
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"url": "https://github.com/inistate/inistate-mcp",
|
|
9
9
|
"source": "github"
|
|
10
10
|
},
|
|
11
|
-
"version": "1.
|
|
11
|
+
"version": "1.6.1",
|
|
12
12
|
"packages": [
|
|
13
13
|
{
|
|
14
14
|
"registryType": "npm",
|
|
15
15
|
"registryBaseUrl": "https://registry.npmjs.org",
|
|
16
16
|
"identifier": "inistate-mcp",
|
|
17
|
-
"version": "1.
|
|
17
|
+
"version": "1.6.1",
|
|
18
18
|
"transport": {
|
|
19
19
|
"type": "stdio"
|
|
20
20
|
},
|