@mindstudio-ai/agent 0.1.100 → 0.1.101
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 +54 -0
- package/dist/cli.js +90 -13
- package/dist/index.d.ts +351 -7
- package/dist/index.js +198 -6
- package/dist/index.js.map +1 -1
- package/dist/postinstall.js +90 -13
- package/llms.txt +12 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3134,28 +3134,28 @@ var stepMetadata = {
|
|
|
3134
3134
|
"scrapeUrl": {
|
|
3135
3135
|
stepType: "scrapeUrl",
|
|
3136
3136
|
description: "Extract text, HTML, or structured content from one or more web pages.",
|
|
3137
|
-
usageNotes: '- Accepts a single URL or multiple URLs (as a JSON array, comma-separated, or newline-separated).\n- Output format controls the result shape: "text" returns markdown, "html" returns raw HTML, "json" returns structured scraper data.\n- Can optionally capture a screenshot of each page.',
|
|
3138
|
-
inputSchema: { "type": "object", "properties": { "url": { "type": "string", "description": "URL(s) to scrape. Accepts a single URL, JSON array, or comma/newline-separated list" }, "service": { "enum": ["default", "firecrawl"], "type": "string", "description": "Scraping service to use" }, "autoEnhance": { "type": "boolean", "description": "
|
|
3139
|
-
outputSchema: { "type": "object", "properties": { "content": { "anyOf": [{ "type": "string" }, { "type": "array", "items": { "type": "string" } }, { "type": "object", "properties": { "text": { "type": "string", "description": "Markdown/plain-text content of the scraped page" }, "html": { "type": "string", "description": "Raw HTML content of the scraped page" }, "json": { "type": "object", "properties": {}, "required": [], "description": "Structured data extracted from the page" }, "screenshotUrl": { "type": "string", "description": "Screenshot URL of the page (if requested)" }, "metadata": { "type": "object", "properties": { "title": { "type": "string", "description": "Page title" }, "description": { "type": "string", "description": "Page meta description" }, "url": { "type": "string", "description": "Canonical URL" }, "image": { "type": "string", "description": "Open Graph image URL" } }, "required": ["title", "description", "url", "image"], "description": "Page metadata (Open Graph / meta tags)" }, "error": { "type": "object", "properties": { "code": { "type": "string" }, "message": { "type": "string" } }, "required": ["code", "message"], "description": "Set when the scrape failed. `text`/`html` still carry the human-readable error so existing callers behave as before, but callers that care \u2014 billing, in particular \u2014 can tell a failure from real page content." } }, "required": ["text", "html"] }, { "type": "array", "items": { "type": "object", "properties": { "text": { "type": "string", "description": "Markdown/plain-text content of the scraped page" }, "html": { "type": "string", "description": "Raw HTML content of the scraped page" }, "json": { "type": "object", "properties": {}, "required": [], "description": "Structured data extracted from the page" }, "screenshotUrl": { "type": "string", "description": "Screenshot URL of the page (if requested)" }, "metadata": { "type": "object", "properties": { "title": { "type": "string", "description": "Page title" }, "description": { "type": "string", "description": "Page meta description" }, "url": { "type": "string", "description": "Canonical URL" }, "image": { "type": "string", "description": "Open Graph image URL" } }, "required": ["title", "description", "url", "image"], "description": "Page metadata (Open Graph / meta tags)" }, "error": { "type": "object", "properties": { "code": { "type": "string" }, "message": { "type": "string" } }, "required": ["code", "message"], "description": "Set when the scrape failed. `text`/`html` still carry the human-readable error so existing callers behave as before, but callers that care \u2014 billing, in particular \u2014 can tell a failure from real page content." } }, "required": ["text", "html"] } }] }, "screenshot": { "anyOf": [{ "type": "string" }, { "type": "array", "items": { "type": "string" } }] } }, "required": ["content"] }
|
|
3137
|
+
usageNotes: '- Accepts a single URL or multiple URLs (as a JSON array, comma-separated, or newline-separated).\n- Output format controls the result shape: "text" returns markdown, "html" returns raw HTML, "json" returns structured scraper data, "summary" returns a model-written summary and requires the "firecrawl" service.\n- Can optionally capture a screenshot of each page.\n- Handles bot protection automatically; no proxy or rendering configuration is needed.',
|
|
3138
|
+
inputSchema: { "type": "object", "properties": { "url": { "type": "string", "description": "URL(s) to scrape. Accepts a single URL, JSON array, or comma/newline-separated list" }, "service": { "enum": ["default", "firecrawl"], "type": "string", "description": "Scraping service to use" }, "autoEnhance": { "type": "boolean", "description": "No longer selects a provider \u2014 the default service's anti-bot engine decides per request how hard to work. Retained because existing workflows set it and the builder still renders it." }, "outputFormat": { "enum": ["text", "json", "html", "summary"], "type": "string", "description": "Output format: text returns markdown, html returns raw HTML, json returns structured scraper data, summary returns a model-written summary (Firecrawl only)" }, "pageOptions": { "type": "object", "properties": { "onlyMainContent": { "type": "boolean", "description": "Whether to extract only the main content of the page, excluding navigation, footers, etc." }, "screenshot": { "type": "boolean", "description": "Whether to capture a screenshot of the page" }, "waitFor": { "type": "number", "description": "Milliseconds to wait before scraping (0 for immediate)" }, "replaceAllPathsWithAbsolutePaths": { "type": "boolean", "description": "Whether to convert relative URLs to absolute URLs in the result" }, "headers": { "type": "object", "properties": {}, "required": [], "description": "Custom HTTP request headers as key-value pairs" }, "removeTags": { "type": "array", "items": { "type": "string" }, "description": "HTML tags to remove from the scraped result" }, "mobile": { "type": "boolean", "description": "Whether to scrape using a mobile user-agent" } }, "required": ["onlyMainContent", "screenshot", "waitFor", "replaceAllPathsWithAbsolutePaths", "headers", "removeTags", "mobile"], "description": "Page-level scraping options (content filtering, screenshots, headers, etc.)" } }, "required": ["url"] },
|
|
3139
|
+
outputSchema: { "type": "object", "properties": { "content": { "anyOf": [{ "type": "string" }, { "type": "array", "items": { "type": "string" } }, { "type": "object", "properties": { "text": { "type": "string", "description": "Markdown/plain-text content of the scraped page" }, "html": { "type": "string", "description": "Raw HTML content of the scraped page" }, "json": { "type": "object", "properties": {}, "required": [], "description": "Structured data extracted from the page" }, "screenshotUrl": { "type": "string", "description": "Screenshot URL of the page (if requested)" }, "metadata": { "type": "object", "properties": { "title": { "type": "string", "description": "Page title" }, "description": { "type": "string", "description": "Page meta description" }, "url": { "type": "string", "description": "Canonical URL" }, "image": { "type": "string", "description": "Open Graph image URL" } }, "required": ["title", "description", "url", "image"], "description": "Page metadata (Open Graph / meta tags)" }, "error": { "type": "object", "properties": { "code": { "type": "string" }, "message": { "type": "string" } }, "required": ["code", "message"], "description": "Set when the scrape failed. `text`/`html` still carry the human-readable error so existing callers behave as before, but callers that care \u2014 billing, in particular \u2014 can tell a failure from real page content." }, "costUnits": { "type": "number", "description": "What the provider actually charged, when it tells us. Scrapfly returns an exact per-request credit total that varies with how hard the target fought back (6 for an unprotected page, 80 for Glassdoor), so billing a flat rate would either overcharge the easy case or eat the hard one. Providers that report nothing leave this undefined and fall back to the route's estimate.\n\nIncludes every attempt made on the caller's behalf, not just the last one." } }, "required": ["text", "html"] }, { "type": "array", "items": { "type": "object", "properties": { "text": { "type": "string", "description": "Markdown/plain-text content of the scraped page" }, "html": { "type": "string", "description": "Raw HTML content of the scraped page" }, "json": { "type": "object", "properties": {}, "required": [], "description": "Structured data extracted from the page" }, "screenshotUrl": { "type": "string", "description": "Screenshot URL of the page (if requested)" }, "metadata": { "type": "object", "properties": { "title": { "type": "string", "description": "Page title" }, "description": { "type": "string", "description": "Page meta description" }, "url": { "type": "string", "description": "Canonical URL" }, "image": { "type": "string", "description": "Open Graph image URL" } }, "required": ["title", "description", "url", "image"], "description": "Page metadata (Open Graph / meta tags)" }, "error": { "type": "object", "properties": { "code": { "type": "string" }, "message": { "type": "string" } }, "required": ["code", "message"], "description": "Set when the scrape failed. `text`/`html` still carry the human-readable error so existing callers behave as before, but callers that care \u2014 billing, in particular \u2014 can tell a failure from real page content." }, "costUnits": { "type": "number", "description": "What the provider actually charged, when it tells us. Scrapfly returns an exact per-request credit total that varies with how hard the target fought back (6 for an unprotected page, 80 for Glassdoor), so billing a flat rate would either overcharge the easy case or eat the hard one. Providers that report nothing leave this undefined and fall back to the route's estimate.\n\nIncludes every attempt made on the caller's behalf, not just the last one." } }, "required": ["text", "html"] } }] }, "screenshot": { "anyOf": [{ "type": "string" }, { "type": "array", "items": { "type": "string" } }] } }, "required": ["content"] }
|
|
3140
3140
|
},
|
|
3141
3141
|
"scrapeXPost": {
|
|
3142
3142
|
stepType: "scrapeXPost",
|
|
3143
3143
|
description: "Scrape data from a single X (Twitter) post by URL.",
|
|
3144
3144
|
usageNotes: "- Returns structured post data (text, html, optional json/screenshot/metadata).\n- Optionally saves the text content to a variable.",
|
|
3145
3145
|
inputSchema: { "type": "object", "properties": { "url": { "type": "string", "description": "Full URL to the X post (e.g. https://x.com/elonmusk/status/1655608985058267139)" } }, "required": ["url"] },
|
|
3146
|
-
outputSchema: { "type": "object", "properties": { "post": { "type": "object", "properties": { "text": { "type": "string", "description": "Markdown/plain-text content of the scraped page" }, "html": { "type": "string", "description": "Raw HTML content of the scraped page" }, "json": { "type": "object", "properties": {}, "required": [], "description": "Structured data extracted from the page" }, "screenshotUrl": { "type": "string", "description": "Screenshot URL of the page (if requested)" }, "metadata": { "type": "object", "properties": { "title": { "type": "string", "description": "Page title" }, "description": { "type": "string", "description": "Page meta description" }, "url": { "type": "string", "description": "Canonical URL" }, "image": { "type": "string", "description": "Open Graph image URL" } }, "required": ["title", "description", "url", "image"], "description": "Page metadata (Open Graph / meta tags)" }, "error": { "type": "object", "properties": { "code": { "type": "string" }, "message": { "type": "string" } }, "required": ["code", "message"], "description": "Set when the scrape failed. `text`/`html` still carry the human-readable error so existing callers behave as before, but callers that care \u2014 billing, in particular \u2014 can tell a failure from real page content." } }, "required": ["text", "html"], "description": "Scraped post data including text, HTML, and optional structured JSON" } }, "required": ["post"] }
|
|
3146
|
+
outputSchema: { "type": "object", "properties": { "post": { "type": "object", "properties": { "text": { "type": "string", "description": "Markdown/plain-text content of the scraped page" }, "html": { "type": "string", "description": "Raw HTML content of the scraped page" }, "json": { "type": "object", "properties": {}, "required": [], "description": "Structured data extracted from the page" }, "screenshotUrl": { "type": "string", "description": "Screenshot URL of the page (if requested)" }, "metadata": { "type": "object", "properties": { "title": { "type": "string", "description": "Page title" }, "description": { "type": "string", "description": "Page meta description" }, "url": { "type": "string", "description": "Canonical URL" }, "image": { "type": "string", "description": "Open Graph image URL" } }, "required": ["title", "description", "url", "image"], "description": "Page metadata (Open Graph / meta tags)" }, "error": { "type": "object", "properties": { "code": { "type": "string" }, "message": { "type": "string" } }, "required": ["code", "message"], "description": "Set when the scrape failed. `text`/`html` still carry the human-readable error so existing callers behave as before, but callers that care \u2014 billing, in particular \u2014 can tell a failure from real page content." }, "costUnits": { "type": "number", "description": "What the provider actually charged, when it tells us. Scrapfly returns an exact per-request credit total that varies with how hard the target fought back (6 for an unprotected page, 80 for Glassdoor), so billing a flat rate would either overcharge the easy case or eat the hard one. Providers that report nothing leave this undefined and fall back to the route's estimate.\n\nIncludes every attempt made on the caller's behalf, not just the last one." } }, "required": ["text", "html"], "description": "Scraped post data including text, HTML, and optional structured JSON" } }, "required": ["post"] }
|
|
3147
3147
|
},
|
|
3148
3148
|
"scrapeXProfile": {
|
|
3149
3149
|
stepType: "scrapeXProfile",
|
|
3150
3150
|
description: "Scrape public profile data from an X (Twitter) account by URL.",
|
|
3151
3151
|
usageNotes: "- Returns structured profile data.\n- Optionally saves the result to a variable.",
|
|
3152
3152
|
inputSchema: { "type": "object", "properties": { "url": { "type": "string", "description": "Full URL or username for the X profile (e.g. https://x.com/elonmusk)" } }, "required": ["url"] },
|
|
3153
|
-
outputSchema: { "type": "object", "properties": { "profile": { "type": "object", "properties": { "text": { "type": "string", "description": "Markdown/plain-text content of the scraped page" }, "html": { "type": "string", "description": "Raw HTML content of the scraped page" }, "json": { "type": "object", "properties": {}, "required": [], "description": "Structured data extracted from the page" }, "screenshotUrl": { "type": "string", "description": "Screenshot URL of the page (if requested)" }, "metadata": { "type": "object", "properties": { "title": { "type": "string", "description": "Page title" }, "description": { "type": "string", "description": "Page meta description" }, "url": { "type": "string", "description": "Canonical URL" }, "image": { "type": "string", "description": "Open Graph image URL" } }, "required": ["title", "description", "url", "image"], "description": "Page metadata (Open Graph / meta tags)" }, "error": { "type": "object", "properties": { "code": { "type": "string" }, "message": { "type": "string" } }, "required": ["code", "message"], "description": "Set when the scrape failed. `text`/`html` still carry the human-readable error so existing callers behave as before, but callers that care \u2014 billing, in particular \u2014 can tell a failure from real page content." } }, "required": ["text", "html"], "description": "Scraped profile data including text, HTML, and optional structured JSON" } }, "required": ["profile"] }
|
|
3153
|
+
outputSchema: { "type": "object", "properties": { "profile": { "type": "object", "properties": { "text": { "type": "string", "description": "Markdown/plain-text content of the scraped page" }, "html": { "type": "string", "description": "Raw HTML content of the scraped page" }, "json": { "type": "object", "properties": {}, "required": [], "description": "Structured data extracted from the page" }, "screenshotUrl": { "type": "string", "description": "Screenshot URL of the page (if requested)" }, "metadata": { "type": "object", "properties": { "title": { "type": "string", "description": "Page title" }, "description": { "type": "string", "description": "Page meta description" }, "url": { "type": "string", "description": "Canonical URL" }, "image": { "type": "string", "description": "Open Graph image URL" } }, "required": ["title", "description", "url", "image"], "description": "Page metadata (Open Graph / meta tags)" }, "error": { "type": "object", "properties": { "code": { "type": "string" }, "message": { "type": "string" } }, "required": ["code", "message"], "description": "Set when the scrape failed. `text`/`html` still carry the human-readable error so existing callers behave as before, but callers that care \u2014 billing, in particular \u2014 can tell a failure from real page content." }, "costUnits": { "type": "number", "description": "What the provider actually charged, when it tells us. Scrapfly returns an exact per-request credit total that varies with how hard the target fought back (6 for an unprotected page, 80 for Glassdoor), so billing a flat rate would either overcharge the easy case or eat the hard one. Providers that report nothing leave this undefined and fall back to the route's estimate.\n\nIncludes every attempt made on the caller's behalf, not just the last one." } }, "required": ["text", "html"], "description": "Scraped profile data including text, HTML, and optional structured JSON" } }, "required": ["profile"] }
|
|
3154
3154
|
},
|
|
3155
3155
|
"screenshotUrl": {
|
|
3156
3156
|
stepType: "screenshotUrl",
|
|
3157
3157
|
description: "Capture a screenshot of a web page as a PNG image.",
|
|
3158
|
-
usageNotes: "- Takes a viewport or full-page screenshot of the given URL.\n- Returns a CDN-hosted PNG image URL.\n- Viewport mode captures only the visible area; fullPage captures the entire scrollable page.\n-
|
|
3158
|
+
usageNotes: "- Takes a viewport or full-page screenshot of the given URL.\n- Returns a CDN-hosted PNG image URL.\n- Viewport mode captures only the visible area; fullPage captures the entire scrollable page, scrolling it first so lazy-loaded content is included.\n- Works on sites behind bot protection (Cloudflare and similar).\n- Cookie-consent banners and similar overlays are suppressed automatically.\n- `width` and `height` are the exact output pixel dimensions.\n- You can add a delay or wait for a CSS selector before capturing. A selector that never appears fails the step rather than capturing early.",
|
|
3159
3159
|
inputSchema: { "type": "object", "properties": { "url": { "type": "string", "description": "URL to screenshot" }, "mode": { "enum": ["viewport", "fullPage"], "type": "string", "description": "Screenshot mode: viewport captures visible area, fullPage captures entire page" }, "width": { "type": "number", "description": "Viewport width in pixels (default: 1280)" }, "height": { "type": "number", "description": "Viewport height in pixels (default: 800, ignored for fullPage mode)" }, "delay": { "type": "number", "description": "Milliseconds to wait before capturing (default: 0)" }, "waitFor": { "type": "string", "description": "CSS selector to wait for before capturing" } }, "required": ["url"] },
|
|
3160
3160
|
outputSchema: { "type": "object", "properties": { "screenshotUrl": { "type": "string" } }, "required": ["screenshotUrl"] }
|
|
3161
3161
|
},
|
|
@@ -5958,6 +5958,79 @@ var MindStudioAgent = class {
|
|
|
5958
5958
|
get files() {
|
|
5959
5959
|
return this._files ??= createFiles(this._filesRequest.bind(this));
|
|
5960
5960
|
}
|
|
5961
|
+
/**
|
|
5962
|
+
* Jewel surfaces: arrival-shaped triggers (`propose`) and the app-native
|
|
5963
|
+
* approval queue (`queue.list` / `queue.resolve`). See {@link JewelsApi}.
|
|
5964
|
+
*/
|
|
5965
|
+
get jewels() {
|
|
5966
|
+
return {
|
|
5967
|
+
propose: (methodId, subject, opts) => {
|
|
5968
|
+
if (!methodId || typeof methodId !== "string") {
|
|
5969
|
+
throw new MindStudioError(
|
|
5970
|
+
"methodId is required",
|
|
5971
|
+
"missing_method_id",
|
|
5972
|
+
400
|
|
5973
|
+
);
|
|
5974
|
+
}
|
|
5975
|
+
return this._jewelsRequest("propose", {
|
|
5976
|
+
methodId,
|
|
5977
|
+
subject,
|
|
5978
|
+
...opts?.idempotencyKey !== void 0 && {
|
|
5979
|
+
idempotencyKey: opts.idempotencyKey
|
|
5980
|
+
}
|
|
5981
|
+
});
|
|
5982
|
+
},
|
|
5983
|
+
queue: {
|
|
5984
|
+
list: (opts) => this._jewelsRequest("queue/list", {
|
|
5985
|
+
...opts?.methodId !== void 0 && { methodId: opts.methodId },
|
|
5986
|
+
...opts?.limit !== void 0 && { limit: opts.limit }
|
|
5987
|
+
}),
|
|
5988
|
+
resolve: (itemId, opts) => this._jewelsRequest("queue/resolve", {
|
|
5989
|
+
itemId,
|
|
5990
|
+
action: opts.action,
|
|
5991
|
+
...opts.input !== void 0 && { input: opts.input }
|
|
5992
|
+
})
|
|
5993
|
+
}
|
|
5994
|
+
};
|
|
5995
|
+
}
|
|
5996
|
+
/**
|
|
5997
|
+
* Raw hook-token call shared by the jewels surfaces (mirrors reportIssue).
|
|
5998
|
+
* No retries: propose holds the request for the jewel run and is idempotent
|
|
5999
|
+
* by key anyway; resolve applies a method and must never double-fire.
|
|
6000
|
+
*/
|
|
6001
|
+
async _jewelsRequest(path, body) {
|
|
6002
|
+
const rctx = getRequestContext();
|
|
6003
|
+
if (this._authType !== "internal" && !rctx?.callbackToken) {
|
|
6004
|
+
throw new MindStudioError(
|
|
6005
|
+
`jewels.${path.replace("/", ".")} requires an app execution context (hook token) \u2014 it cannot be called with an API key.`,
|
|
6006
|
+
"jewels_requires_app_context",
|
|
6007
|
+
400
|
|
6008
|
+
);
|
|
6009
|
+
}
|
|
6010
|
+
const url = `${this._currentHttpConfig.baseUrl}/_internal/v2/jewels/${path}`;
|
|
6011
|
+
const res = await fetch(url, {
|
|
6012
|
+
method: "POST",
|
|
6013
|
+
headers: {
|
|
6014
|
+
"Content-Type": "application/json",
|
|
6015
|
+
Authorization: this._token
|
|
6016
|
+
},
|
|
6017
|
+
body: JSON.stringify(body)
|
|
6018
|
+
});
|
|
6019
|
+
if (!res.ok) {
|
|
6020
|
+
let code = "jewels_error";
|
|
6021
|
+
let message = `jewels.${path.replace("/", ".")} failed: ${res.status} ${res.statusText}`;
|
|
6022
|
+
let details;
|
|
6023
|
+
try {
|
|
6024
|
+
const errBody = await res.json();
|
|
6025
|
+
details = errBody;
|
|
6026
|
+
if (typeof errBody.errorString === "string") code = errBody.errorString;
|
|
6027
|
+
message = typeof errBody.errorMessage === "string" && errBody.errorMessage || typeof errBody.errorString === "string" && errBody.errorString || message;
|
|
6028
|
+
} catch {
|
|
6029
|
+
}
|
|
6030
|
+
throw new MindStudioError(message, code, res.status, details);
|
|
6031
|
+
}
|
|
6032
|
+
return await res.json();
|
|
6033
|
+
}
|
|
5961
6034
|
/**
|
|
5962
6035
|
* Searchable document corpora.
|
|
5963
6036
|
*
|
|
@@ -6519,6 +6592,124 @@ function resolveToken(provided, config) {
|
|
|
6519
6592
|
);
|
|
6520
6593
|
}
|
|
6521
6594
|
|
|
6595
|
+
// src/jewel/index.ts
|
|
6596
|
+
function errorInfo(e) {
|
|
6597
|
+
if (e instanceof Error) return { message: e.message, stack: e.stack };
|
|
6598
|
+
return { message: String(e) };
|
|
6599
|
+
}
|
|
6600
|
+
function deepEqual(a, b) {
|
|
6601
|
+
if (a === b) return true;
|
|
6602
|
+
if (a === null || b === null || typeof a !== "object" || typeof b !== "object") {
|
|
6603
|
+
return false;
|
|
6604
|
+
}
|
|
6605
|
+
const aIsArray = Array.isArray(a);
|
|
6606
|
+
if (aIsArray !== Array.isArray(b)) return false;
|
|
6607
|
+
if (aIsArray) {
|
|
6608
|
+
const aa = a;
|
|
6609
|
+
const ba = b;
|
|
6610
|
+
return aa.length === ba.length && aa.every((v, i) => deepEqual(v, ba[i]));
|
|
6611
|
+
}
|
|
6612
|
+
const ao = a;
|
|
6613
|
+
const bo = b;
|
|
6614
|
+
const aKeys = Object.keys(ao).filter((k) => ao[k] !== void 0);
|
|
6615
|
+
const bKeys = Object.keys(bo).filter((k) => bo[k] !== void 0);
|
|
6616
|
+
if (aKeys.length !== bKeys.length) return false;
|
|
6617
|
+
return aKeys.every((k) => deepEqual(ao[k], bo[k]));
|
|
6618
|
+
}
|
|
6619
|
+
var VERDICTS = /* @__PURE__ */ new Set(["agree", "disagree", "skip"]);
|
|
6620
|
+
function normalizeVerdict(v) {
|
|
6621
|
+
if (!v || !VERDICTS.has(v.verdict)) {
|
|
6622
|
+
return {
|
|
6623
|
+
verdict: "skip",
|
|
6624
|
+
notes: `grade returned invalid verdict: ${JSON.stringify(v)}`
|
|
6625
|
+
};
|
|
6626
|
+
}
|
|
6627
|
+
return v.notes === void 0 ? { verdict: v.verdict } : { verdict: v.verdict, notes: v.notes };
|
|
6628
|
+
}
|
|
6629
|
+
function defineJewel(method, config) {
|
|
6630
|
+
const runGrade = async (proposed, actual) => {
|
|
6631
|
+
if (config.grade) {
|
|
6632
|
+
try {
|
|
6633
|
+
return normalizeVerdict(await config.grade({ proposed, actual }));
|
|
6634
|
+
} catch (e) {
|
|
6635
|
+
return { verdict: "skip", notes: `grade threw: ${errorInfo(e).message}` };
|
|
6636
|
+
}
|
|
6637
|
+
}
|
|
6638
|
+
return deepEqual(proposed, actual) ? { verdict: "agree" } : { verdict: "disagree" };
|
|
6639
|
+
};
|
|
6640
|
+
const run = async (params) => {
|
|
6641
|
+
const startedAt = Date.now();
|
|
6642
|
+
const customGrade = config.grade !== void 0;
|
|
6643
|
+
const done = (rest) => ({
|
|
6644
|
+
v: 1,
|
|
6645
|
+
customGrade,
|
|
6646
|
+
startedAt,
|
|
6647
|
+
durationMs: Date.now() - startedAt,
|
|
6648
|
+
...rest
|
|
6649
|
+
});
|
|
6650
|
+
if (Object.prototype.hasOwnProperty.call(params, "grade")) {
|
|
6651
|
+
const ctx = params.grade;
|
|
6652
|
+
const verdict2 = await runGrade(ctx.proposed, ctx.actual);
|
|
6653
|
+
return done({
|
|
6654
|
+
mode: "grade",
|
|
6655
|
+
proposed: ctx.proposed,
|
|
6656
|
+
actual: ctx.actual,
|
|
6657
|
+
verdict: verdict2.verdict,
|
|
6658
|
+
...verdict2.notes !== void 0 ? { notes: verdict2.notes } : {}
|
|
6659
|
+
});
|
|
6660
|
+
}
|
|
6661
|
+
const isShadow = Object.prototype.hasOwnProperty.call(params, "humanInput");
|
|
6662
|
+
const mode = isShadow ? "shadow" : "eval";
|
|
6663
|
+
const actual = isShadow ? params.humanInput : void 0;
|
|
6664
|
+
let subject;
|
|
6665
|
+
if (isShadow) {
|
|
6666
|
+
try {
|
|
6667
|
+
subject = config.subject(actual);
|
|
6668
|
+
} catch (e) {
|
|
6669
|
+
return done({ mode, actual, error: { phase: "subject", ...errorInfo(e) } });
|
|
6670
|
+
}
|
|
6671
|
+
} else {
|
|
6672
|
+
subject = params.subject;
|
|
6673
|
+
}
|
|
6674
|
+
let proposal;
|
|
6675
|
+
try {
|
|
6676
|
+
proposal = await config.propose(subject);
|
|
6677
|
+
} catch (e) {
|
|
6678
|
+
return done({
|
|
6679
|
+
mode,
|
|
6680
|
+
subject,
|
|
6681
|
+
actual,
|
|
6682
|
+
error: { phase: "propose", ...errorInfo(e) }
|
|
6683
|
+
});
|
|
6684
|
+
}
|
|
6685
|
+
if (!isShadow) {
|
|
6686
|
+
return done({
|
|
6687
|
+
mode,
|
|
6688
|
+
subject,
|
|
6689
|
+
proposed: proposal.input,
|
|
6690
|
+
reasoning: proposal.reasoning
|
|
6691
|
+
});
|
|
6692
|
+
}
|
|
6693
|
+
const verdict = await runGrade(proposal.input, actual);
|
|
6694
|
+
return done({
|
|
6695
|
+
mode,
|
|
6696
|
+
subject,
|
|
6697
|
+
proposed: proposal.input,
|
|
6698
|
+
reasoning: proposal.reasoning,
|
|
6699
|
+
actual,
|
|
6700
|
+
verdict: verdict.verdict,
|
|
6701
|
+
...verdict.notes !== void 0 ? { notes: verdict.notes } : {}
|
|
6702
|
+
});
|
|
6703
|
+
};
|
|
6704
|
+
return Object.assign(run, {
|
|
6705
|
+
kind: "jewel",
|
|
6706
|
+
method,
|
|
6707
|
+
subject: config.subject,
|
|
6708
|
+
propose: config.propose,
|
|
6709
|
+
grade: config.grade
|
|
6710
|
+
});
|
|
6711
|
+
}
|
|
6712
|
+
|
|
6522
6713
|
// src/generated/snippets.ts
|
|
6523
6714
|
var monacoSnippets = {
|
|
6524
6715
|
"activeCampaignAddNote": { fields: [["contactId", "string"], ["note", "string"]], outputKeys: [] },
|
|
@@ -6770,6 +6961,7 @@ export {
|
|
|
6770
6961
|
dataSources,
|
|
6771
6962
|
db,
|
|
6772
6963
|
index_default as default,
|
|
6964
|
+
defineJewel,
|
|
6773
6965
|
files,
|
|
6774
6966
|
getRequestContext,
|
|
6775
6967
|
mindstudio,
|