@drawcall/market 0.8.31 → 0.9.0
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 +18 -0
- package/dist/command.js +2 -2
- package/dist/command.js.map +1 -1
- package/dist/commands/preview.d.ts +1 -1
- package/dist/commands/preview.d.ts.map +1 -1
- package/dist/commands/preview.js +2 -2
- package/dist/commands/preview.js.map +1 -1
- package/dist/commands/urls.js +2 -2
- package/dist/commands/urls.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/agent.d.ts +4 -0
- package/dist/mcp/agent.d.ts.map +1 -0
- package/dist/mcp/agent.js +27 -0
- package/dist/mcp/agent.js.map +1 -0
- package/dist/mcp/asset.d.ts +4 -0
- package/dist/mcp/asset.d.ts.map +1 -0
- package/dist/mcp/asset.js +124 -0
- package/dist/mcp/asset.js.map +1 -0
- package/dist/mcp/generation.d.ts +4 -0
- package/dist/mcp/generation.d.ts.map +1 -0
- package/dist/mcp/generation.js +28 -0
- package/dist/mcp/generation.js.map +1 -0
- package/dist/mcp/index.d.ts +3 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +2 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/instructions.d.ts +3 -0
- package/dist/mcp/instructions.d.ts.map +1 -0
- package/dist/mcp/instructions.js +16 -0
- package/dist/mcp/instructions.js.map +1 -0
- package/dist/mcp/register.d.ts +4 -0
- package/dist/mcp/register.d.ts.map +1 -0
- package/dist/mcp/register.js +13 -0
- package/dist/mcp/register.js.map +1 -0
- package/dist/mcp/result.d.ts +4 -0
- package/dist/mcp/result.d.ts.map +1 -0
- package/dist/mcp/result.js +14 -0
- package/dist/mcp/result.js.map +1 -0
- package/dist/mcp/types.d.ts +39 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +2 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/refs.d.ts +6 -0
- package/dist/refs.d.ts.map +1 -1
- package/dist/refs.js +17 -1
- package/dist/refs.js.map +1 -1
- package/dist/skill.generated.d.ts +3 -0
- package/dist/skill.generated.d.ts.map +1 -0
- package/dist/skill.generated.js +4 -0
- package/dist/skill.generated.js.map +1 -0
- package/package.json +14 -2
- package/skills/market/SKILL.md +34 -29
- package/src/command.ts +2 -2
- package/src/commands/preview.ts +2 -3
- package/src/commands/urls.ts +2 -2
- package/src/index.ts +10 -0
- package/src/mcp/agent.ts +39 -0
- package/src/mcp/asset.ts +158 -0
- package/src/mcp/generation.ts +41 -0
- package/src/mcp/index.ts +7 -0
- package/src/mcp/instructions.ts +22 -0
- package/src/mcp/register.ts +17 -0
- package/src/mcp/result.ts +18 -0
- package/src/mcp/types.ts +43 -0
- package/src/refs.ts +32 -1
- package/src/skill.generated.ts +5 -0
- package/dist/commands/asset-ref.d.ts +0 -9
- package/dist/commands/asset-ref.d.ts.map +0 -1
- package/dist/commands/asset-ref.js +0 -19
- package/dist/commands/asset-ref.js.map +0 -1
- package/dist/skill.d.ts +0 -2
- package/dist/skill.d.ts.map +0 -1
- package/dist/skill.js +0 -60
- package/dist/skill.js.map +0 -1
- package/src/commands/asset-ref.ts +0 -35
- package/src/skill.ts +0 -59
package/dist/refs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MAX_ASSET_REFS_QUERY_LENGTH } from './schemas.js';
|
|
1
|
+
import { assetNameSchema, MAX_ASSET_REFS_QUERY_LENGTH, semverSchema } from './schemas.js';
|
|
2
2
|
/** The server accepts up to 100 refs and 4,000 characters per read. */
|
|
3
3
|
const MAX_REFS_PER_CALL = 100;
|
|
4
4
|
/**
|
|
@@ -20,6 +20,22 @@ export async function lookupAssets(asset, refs, opts = {}) {
|
|
|
20
20
|
}));
|
|
21
21
|
return results.flat();
|
|
22
22
|
}
|
|
23
|
+
/** Resolve a bare asset name or exact name@version without accepting semver ranges. */
|
|
24
|
+
export async function resolveAsset(client, ref, opts = {}) {
|
|
25
|
+
const separator = ref.indexOf('@');
|
|
26
|
+
const name = assetNameSchema.parse(separator === -1 ? ref : ref.slice(0, separator));
|
|
27
|
+
const requestedVersion = separator === -1 ? undefined : semverSchema.parse(ref.slice(separator + 1));
|
|
28
|
+
const [asset] = await lookupAssets(client, [{ name, ...(requestedVersion ? { version: requestedVersion } : {}) }], {
|
|
29
|
+
includeUnapproved: opts.includeUnapproved ?? false,
|
|
30
|
+
...(opts.key ? { key: opts.key } : {}),
|
|
31
|
+
});
|
|
32
|
+
if (!asset)
|
|
33
|
+
throw new Error(`Asset "${ref}" not found`);
|
|
34
|
+
if (requestedVersion && asset.version !== requestedVersion) {
|
|
35
|
+
throw new Error(`Market API did not return requested version "${ref}"`);
|
|
36
|
+
}
|
|
37
|
+
return asset;
|
|
38
|
+
}
|
|
23
39
|
function chunkRefs(refs) {
|
|
24
40
|
const chunks = [];
|
|
25
41
|
let chunk = [];
|
package/dist/refs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refs.js","sourceRoot":"","sources":["../src/refs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"refs.js","sourceRoot":"","sources":["../src/refs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,2BAA2B,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAkBzF,uEAAuE;AACvE,MAAM,iBAAiB,GAAG,GAAG,CAAA;AAE7B;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,KAAiB,EACjB,IAAgB,EAChB,OAAsD,EAAE;IAExD,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,CAAA;IAE9B,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAC/B,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE;QAC7B,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC;YAChC,IAAI,EAAE,SAAS;YACf,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,IAAI,KAAK;YAClD,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACvC,CAAC,CAAA;QACF,IAAI,CAAC,CAAC,QAAQ,IAAI,MAAM,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAA;QAC7F,OAAO,MAAM,CAAC,MAAM,CAAA;IACtB,CAAC,CAAC,CACH,CAAA;IACD,OAAO,OAAO,CAAC,IAAI,EAAE,CAAA;AACvB,CAAC;AAED,uFAAuF;AACvF,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAkB,EAClB,GAAW,EACX,OAA4B,EAAE;IAE9B,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAClC,MAAM,IAAI,GAAG,eAAe,CAAC,KAAK,CAAC,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAA;IACpF,MAAM,gBAAgB,GACpB,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,CAAA;IAC7E,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,YAAY,CAChC,MAAM,EACN,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EACtE;QACE,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,IAAI,KAAK;QAClD,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACvC,CACF,CAAA;IAED,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,UAAU,GAAG,aAAa,CAAC,CAAA;IACvD,IAAI,gBAAgB,IAAI,KAAK,CAAC,OAAO,KAAK,gBAAgB,EAAE,CAAC;QAC3D,MAAM,IAAI,KAAK,CAAC,gDAAgD,GAAG,GAAG,CAAC,CAAA;IACzE,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAED,SAAS,SAAS,CAAC,IAAgB;IACjC,MAAM,MAAM,GAAa,EAAE,CAAA;IAC3B,IAAI,KAAK,GAAa,EAAE,CAAA;IACxB,IAAI,MAAM,GAAG,CAAC,CAAA;IAEd,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAA;QACnE,IAAI,KAAK,CAAC,MAAM,GAAG,2BAA2B,EAAE,CAAC;YAC/C,MAAM,IAAI,KAAK,CAAC,qBAAqB,2BAA2B,gBAAgB,GAAG,CAAC,IAAI,EAAE,CAAC,CAAA;QAC7F,CAAC;QAED,MAAM,eAAe,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QAChD,MAAM,UAAU,GAAG,MAAM,GAAG,eAAe,GAAG,KAAK,CAAC,MAAM,CAAA;QAC1D,IAAI,KAAK,CAAC,MAAM,KAAK,iBAAiB,IAAI,UAAU,GAAG,2BAA2B,EAAE,CAAC;YACnF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;YAC5B,KAAK,GAAG,EAAE,CAAA;YACV,MAAM,GAAG,CAAC,CAAA;QACZ,CAAC;QAED,MAAM,mBAAmB,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QACpD,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACjB,MAAM,IAAI,mBAAmB,GAAG,KAAK,CAAC,MAAM,CAAA;IAC9C,CAAC;IAED,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;QAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;IAClD,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const cliMarketSkill = "---\nname: market\ndescription: Find, inspect, generate, and use Drawcall Market assets from a coding agent.\n---\n\n# Drawcall Market\n\n## CLI transport\n\nRun commands as `npx @drawcall/market <command>`; do not assume a global `market` binary or switch to MCP after a CLI failure. Use `npx @drawcall/market skill` when these instructions are not already available.\n\nDiscover the current vocabulary and choose an asset:\n\n```sh\nnpx @drawcall/market types\nnpx @drawcall/market search \"<query>\" --type <type> --limit 3\nnpx @drawcall/market preview <name@version> --out /tmp/<name>.png\nnpx @drawcall/market urls <name@version>\n```\n\n`urls` prints one base URL, file subpaths, and a preview URL without changing the project. Install exact refs together when the project needs local files:\n\n```sh\nnpx @drawcall/market install <name@range...> --cwd \"$PWD\"\n```\n\nInstall records `assetDependencies` in the nearest `package.json`. `list --cwd \"$PWD\"` reads that inventory without network access. Run `sync --cwd \"$PWD\"` after moving installed files so aliases continue to resolve. Use `--force` only with permission to overwrite changed files.\n\nGenerate and install one asset with:\n\n```sh\nnpx @drawcall/market generate --type <type> \"<description>\"\n```\n\nIf it returns a continuation, run the printed `generate install <jobId>` command. The Market agent can source a coherent set of assets from a broader goal:\n\n```sh\nnpx @drawcall/market agent \"<goal>\"\n```\n\nPublish only when asked. `pack <source> --out <zip>` creates a Market archive and `upload <name> <source> \"<description>\" --type <type>` publishes it. Use command help for dependency and visibility options. If authentication is required, ask before running `npx @drawcall/market login`.\n\n## Choose assets\n\nSearch one concrete need at a time. Use one result for an exact lookup and up to three when the user should choose. If nothing fits, try one broader noun phrase before generating a replacement.\n\nThe exact `name@version` returned by Market is authoritative. Copy it verbatim. Generated identifiers can legitimately end mid-word at the catalog limit; never expand, normalize, or reconstruct one from its description.\n\nPreview a finalist when appearance determines whether it fits. File, preview, and zip URLs returned by Market are opaque. Capability-bearing private URLs are secrets; never derive a URL from an asset name or preview metadata.\n\n## Generate\n\nGeneration creates one Market asset from a description. The description is provider input, not the eventual asset name. A fast provider may return the asset immediately; a slow provider returns a continuation ID for the matching status operation. Resume that job instead of starting the same generation again.\n\nReference images must be direct fetchable image URLs or image data, never webpage URLs. The current asset-type metadata says which types support references and how many they accept.\n\nA generated humanoid model is one expressive, animation-ready biped: one head, two arms, two legs, open empty hands, and no companions or scene. Describe identity, theme, silhouette, clothing, colors, and materials. Express topology outside the shared skeleton as costume or body-surface design so the result remains riggable.\n\nRequest public or private access only when visibility matters. Private generation requires the account's `market:private` entitlement.\n\n## Failures\n\nAn error means the operation did not happen. Correct invalid inputs, refresh an exact reference after a not-found response, and retry one upstream failure once. Never repeat an unchanged failed generation. Use unapproved assets only when the user explicitly requests and accepts them.\n";
|
|
2
|
+
export declare const mcpMarketSkill = "---\nname: market\ndescription: Find, inspect, generate, and use Drawcall Market assets from a coding agent.\n---\n\n# Drawcall Market\n\n## MCP transport\n\nMCP tools are the only Market transport in this environment. Do not invoke the CLI, make direct API requests, or switch transports after a failed call.\n\nUse the same conceptual workflow as the Market CLI:\n\n```text\nlist_market_asset_types\nsearch_market\nget_market_asset\nget_market_asset_preview\n```\n\n`search_market` requires an asset type and returns exact `name@version` references. Inspect the exact manifest with `get_market_asset`; request its preview only when visual evidence matters. Remote MCP tools return immutable references and fetch-ready URLs. They do not install files into the caller's local project.\n\nWhen generation is available, call `generate_market_asset`. If it returns a `jobId`, continue with `get_market_asset_generation`. Do not start the same generation again.\n\nWhen the Market agent is available, call `start_market_agent_run` with the full goal and continue its returned `runId` with `get_market_agent_run`.\n\nUse an exact Market reference with `create_design_frame` when the selected asset belongs in Drawcall Design.\n\n## Choose assets\n\nSearch one concrete need at a time. Use one result for an exact lookup and up to three when the user should choose. If nothing fits, try one broader noun phrase before generating a replacement.\n\nThe exact `name@version` returned by Market is authoritative. Copy it verbatim. Generated identifiers can legitimately end mid-word at the catalog limit; never expand, normalize, or reconstruct one from its description.\n\nPreview a finalist when appearance determines whether it fits. File, preview, and zip URLs returned by Market are opaque. Capability-bearing private URLs are secrets; never derive a URL from an asset name or preview metadata.\n\n## Generate\n\nGeneration creates one Market asset from a description. The description is provider input, not the eventual asset name. A fast provider may return the asset immediately; a slow provider returns a continuation ID for the matching status operation. Resume that job instead of starting the same generation again.\n\nReference images must be direct fetchable image URLs or image data, never webpage URLs. The current asset-type metadata says which types support references and how many they accept.\n\nA generated humanoid model is one expressive, animation-ready biped: one head, two arms, two legs, open empty hands, and no companions or scene. Describe identity, theme, silhouette, clothing, colors, and materials. Express topology outside the shared skeleton as costume or body-surface design so the result remains riggable.\n\nRequest public or private access only when visibility matters. Private generation requires the account's `market:private` entitlement.\n\n## Failures\n\nAn error means the operation did not happen. Correct invalid inputs, refresh an exact reference after a not-found response, and retry one upstream failure once. Never repeat an unchanged failed generation. Use unapproved assets only when the user explicitly requests and accepts them.\n";
|
|
3
|
+
//# sourceMappingURL=skill.generated.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill.generated.d.ts","sourceRoot":"","sources":["../src/skill.generated.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,cAAc,6pHAConH,CAAA;AAC/oH,eAAO,MAAM,cAAc,4mGACglG,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// Generated from skill/SKILL.template.md.
|
|
2
|
+
export const cliMarketSkill = '---\nname: market\ndescription: Find, inspect, generate, and use Drawcall Market assets from a coding agent.\n---\n\n# Drawcall Market\n\n## CLI transport\n\nRun commands as `npx @drawcall/market <command>`; do not assume a global `market` binary or switch to MCP after a CLI failure. Use `npx @drawcall/market skill` when these instructions are not already available.\n\nDiscover the current vocabulary and choose an asset:\n\n```sh\nnpx @drawcall/market types\nnpx @drawcall/market search "<query>" --type <type> --limit 3\nnpx @drawcall/market preview <name@version> --out /tmp/<name>.png\nnpx @drawcall/market urls <name@version>\n```\n\n`urls` prints one base URL, file subpaths, and a preview URL without changing the project. Install exact refs together when the project needs local files:\n\n```sh\nnpx @drawcall/market install <name@range...> --cwd "$PWD"\n```\n\nInstall records `assetDependencies` in the nearest `package.json`. `list --cwd "$PWD"` reads that inventory without network access. Run `sync --cwd "$PWD"` after moving installed files so aliases continue to resolve. Use `--force` only with permission to overwrite changed files.\n\nGenerate and install one asset with:\n\n```sh\nnpx @drawcall/market generate --type <type> "<description>"\n```\n\nIf it returns a continuation, run the printed `generate install <jobId>` command. The Market agent can source a coherent set of assets from a broader goal:\n\n```sh\nnpx @drawcall/market agent "<goal>"\n```\n\nPublish only when asked. `pack <source> --out <zip>` creates a Market archive and `upload <name> <source> "<description>" --type <type>` publishes it. Use command help for dependency and visibility options. If authentication is required, ask before running `npx @drawcall/market login`.\n\n## Choose assets\n\nSearch one concrete need at a time. Use one result for an exact lookup and up to three when the user should choose. If nothing fits, try one broader noun phrase before generating a replacement.\n\nThe exact `name@version` returned by Market is authoritative. Copy it verbatim. Generated identifiers can legitimately end mid-word at the catalog limit; never expand, normalize, or reconstruct one from its description.\n\nPreview a finalist when appearance determines whether it fits. File, preview, and zip URLs returned by Market are opaque. Capability-bearing private URLs are secrets; never derive a URL from an asset name or preview metadata.\n\n## Generate\n\nGeneration creates one Market asset from a description. The description is provider input, not the eventual asset name. A fast provider may return the asset immediately; a slow provider returns a continuation ID for the matching status operation. Resume that job instead of starting the same generation again.\n\nReference images must be direct fetchable image URLs or image data, never webpage URLs. The current asset-type metadata says which types support references and how many they accept.\n\nA generated humanoid model is one expressive, animation-ready biped: one head, two arms, two legs, open empty hands, and no companions or scene. Describe identity, theme, silhouette, clothing, colors, and materials. Express topology outside the shared skeleton as costume or body-surface design so the result remains riggable.\n\nRequest public or private access only when visibility matters. Private generation requires the account\'s `market:private` entitlement.\n\n## Failures\n\nAn error means the operation did not happen. Correct invalid inputs, refresh an exact reference after a not-found response, and retry one upstream failure once. Never repeat an unchanged failed generation. Use unapproved assets only when the user explicitly requests and accepts them.\n';
|
|
3
|
+
export const mcpMarketSkill = "---\nname: market\ndescription: Find, inspect, generate, and use Drawcall Market assets from a coding agent.\n---\n\n# Drawcall Market\n\n## MCP transport\n\nMCP tools are the only Market transport in this environment. Do not invoke the CLI, make direct API requests, or switch transports after a failed call.\n\nUse the same conceptual workflow as the Market CLI:\n\n```text\nlist_market_asset_types\nsearch_market\nget_market_asset\nget_market_asset_preview\n```\n\n`search_market` requires an asset type and returns exact `name@version` references. Inspect the exact manifest with `get_market_asset`; request its preview only when visual evidence matters. Remote MCP tools return immutable references and fetch-ready URLs. They do not install files into the caller's local project.\n\nWhen generation is available, call `generate_market_asset`. If it returns a `jobId`, continue with `get_market_asset_generation`. Do not start the same generation again.\n\nWhen the Market agent is available, call `start_market_agent_run` with the full goal and continue its returned `runId` with `get_market_agent_run`.\n\nUse an exact Market reference with `create_design_frame` when the selected asset belongs in Drawcall Design.\n\n## Choose assets\n\nSearch one concrete need at a time. Use one result for an exact lookup and up to three when the user should choose. If nothing fits, try one broader noun phrase before generating a replacement.\n\nThe exact `name@version` returned by Market is authoritative. Copy it verbatim. Generated identifiers can legitimately end mid-word at the catalog limit; never expand, normalize, or reconstruct one from its description.\n\nPreview a finalist when appearance determines whether it fits. File, preview, and zip URLs returned by Market are opaque. Capability-bearing private URLs are secrets; never derive a URL from an asset name or preview metadata.\n\n## Generate\n\nGeneration creates one Market asset from a description. The description is provider input, not the eventual asset name. A fast provider may return the asset immediately; a slow provider returns a continuation ID for the matching status operation. Resume that job instead of starting the same generation again.\n\nReference images must be direct fetchable image URLs or image data, never webpage URLs. The current asset-type metadata says which types support references and how many they accept.\n\nA generated humanoid model is one expressive, animation-ready biped: one head, two arms, two legs, open empty hands, and no companions or scene. Describe identity, theme, silhouette, clothing, colors, and materials. Express topology outside the shared skeleton as costume or body-surface design so the result remains riggable.\n\nRequest public or private access only when visibility matters. Private generation requires the account's `market:private` entitlement.\n\n## Failures\n\nAn error means the operation did not happen. Correct invalid inputs, refresh an exact reference after a not-found response, and retry one upstream failure once. Never repeat an unchanged failed generation. Use unapproved assets only when the user explicitly requests and accepts them.\n";
|
|
4
|
+
//# sourceMappingURL=skill.generated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill.generated.js","sourceRoot":"","sources":["../src/skill.generated.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,MAAM,CAAC,MAAM,cAAc,GACzB,6oHAA6oH,CAAA;AAC/oH,MAAM,CAAC,MAAM,cAAc,GACzB,ymGAAymG,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drawcall/market",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/drawcall-ai/market",
|
|
@@ -27,12 +27,15 @@
|
|
|
27
27
|
"market": "./dist/cli.js"
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
|
-
"
|
|
30
|
+
"generate": "node scripts/generate-skill.mjs",
|
|
31
|
+
"build": "pnpm run generate && rm -rf dist && tsc -p tsconfig.build.json",
|
|
31
32
|
"prepack": "npm run build && node scripts/prepare-publish.mjs",
|
|
32
33
|
"postpack": "node scripts/restore-package.mjs",
|
|
33
34
|
"dev": "tsx src/cli.ts",
|
|
35
|
+
"pretest": "pnpm run generate",
|
|
34
36
|
"test": "tsx --test tests/*.test.ts",
|
|
35
37
|
"test:install-layout": "tsx --test tests/install-layout.test.ts tests/install-lock.test.ts tests/install-command.test.ts tests/list-command.test.ts tests/pack.test.ts",
|
|
38
|
+
"pretypecheck": "pnpm run generate",
|
|
36
39
|
"typecheck": "tsc --noEmit"
|
|
37
40
|
},
|
|
38
41
|
"dependencies": {
|
|
@@ -49,7 +52,16 @@
|
|
|
49
52
|
"semver": "^7.7.0",
|
|
50
53
|
"zod": "^4.3.6"
|
|
51
54
|
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"@modelcontextprotocol/server": "^2.0.0"
|
|
57
|
+
},
|
|
58
|
+
"peerDependenciesMeta": {
|
|
59
|
+
"@modelcontextprotocol/server": {
|
|
60
|
+
"optional": true
|
|
61
|
+
}
|
|
62
|
+
},
|
|
52
63
|
"devDependencies": {
|
|
64
|
+
"@modelcontextprotocol/server": "^2.0.0",
|
|
53
65
|
"@types/node": "^25.6.0",
|
|
54
66
|
"@types/semver": "^7.5.0",
|
|
55
67
|
"tsx": "^4.19.0",
|
package/skills/market/SKILL.md
CHANGED
|
@@ -1,58 +1,63 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: market
|
|
3
|
-
description: Find,
|
|
3
|
+
description: Find, inspect, generate, and use Drawcall Market assets from a coding agent.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Drawcall Market
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
## CLI transport
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Run commands as `npx @drawcall/market <command>`; do not assume a global `market` binary or switch to MCP after a CLI failure. Use `npx @drawcall/market skill` when these instructions are not already available.
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
Discover the current vocabulary and choose an asset:
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
```sh
|
|
15
|
+
npx @drawcall/market types
|
|
16
|
+
npx @drawcall/market search "<query>" --type <type> --limit 3
|
|
17
|
+
npx @drawcall/market preview <name@version> --out /tmp/<name>.png
|
|
18
|
+
npx @drawcall/market urls <name@version>
|
|
19
|
+
```
|
|
15
20
|
|
|
16
|
-
`
|
|
21
|
+
`urls` prints one base URL, file subpaths, and a preview URL without changing the project. Install exact refs together when the project needs local files:
|
|
17
22
|
|
|
18
|
-
|
|
23
|
+
```sh
|
|
24
|
+
npx @drawcall/market install <name@range...> --cwd "$PWD"
|
|
25
|
+
```
|
|
19
26
|
|
|
20
|
-
|
|
27
|
+
Install records `assetDependencies` in the nearest `package.json`. `list --cwd "$PWD"` reads that inventory without network access. Run `sync --cwd "$PWD"` after moving installed files so aliases continue to resolve. Use `--force` only with permission to overwrite changed files.
|
|
21
28
|
|
|
22
|
-
|
|
29
|
+
Generate and install one asset with:
|
|
23
30
|
|
|
24
|
-
|
|
31
|
+
```sh
|
|
32
|
+
npx @drawcall/market generate --type <type> "<description>"
|
|
33
|
+
```
|
|
25
34
|
|
|
26
|
-
`
|
|
35
|
+
If it returns a continuation, run the printed `generate install <jobId>` command. The Market agent can source a coherent set of assets from a broader goal:
|
|
27
36
|
|
|
28
|
-
|
|
37
|
+
```sh
|
|
38
|
+
npx @drawcall/market agent "<goal>"
|
|
39
|
+
```
|
|
29
40
|
|
|
30
|
-
|
|
41
|
+
Publish only when asked. `pack <source> --out <zip>` creates a Market archive and `upload <name> <source> "<description>" --type <type>` publishes it. Use command help for dependency and visibility options. If authentication is required, ask before running `npx @drawcall/market login`.
|
|
31
42
|
|
|
32
|
-
|
|
43
|
+
## Choose assets
|
|
33
44
|
|
|
34
|
-
|
|
45
|
+
Search one concrete need at a time. Use one result for an exact lookup and up to three when the user should choose. If nothing fits, try one broader noun phrase before generating a replacement.
|
|
35
46
|
|
|
36
|
-
|
|
47
|
+
The exact `name@version` returned by Market is authoritative. Copy it verbatim. Generated identifiers can legitimately end mid-word at the catalog limit; never expand, normalize, or reconstruct one from its description.
|
|
37
48
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
An `assetDependencies` entry is either a range string or `{ "version": "<range>", "alias": { "<canonical path>": "<current path>" } }`. An alias records where the project keeps a renamed installed file: install writes the file at the aliased path, and packing omits exactly that one copy (extra duplicates ship as project content). Run `sync --cwd "$PWD"` after renaming installed files to record aliases in `package.json`; template packing runs the same update automatically.
|
|
49
|
+
Preview a finalist when appearance determines whether it fits. File, preview, and zip URLs returned by Market are opaque. Capability-bearing private URLs are secrets; never derive a URL from an asset name or preview metadata.
|
|
41
50
|
|
|
42
51
|
## Generate
|
|
43
52
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
The description is provider input, not the installed filename. The command's successful output is the source of truth for consumer paths, so update a consumer with its exact printed browser path after success. If generation fails, leave the current path unchanged.
|
|
47
|
-
|
|
48
|
-
Add repeatable `--reference-image <file-or-url>` when the result should match given images; `types` shows which asset types accept reference images. A remote ref must be a direct fetchable image URL, never a webpage URL; use the page only to find its underlying image. An environment matches the look of the references (at most 4). Types without reference image support reject them.
|
|
53
|
+
Generation creates one Market asset from a description. The description is provider input, not the eventual asset name. A fast provider may return the asset immediately; a slow provider returns a continuation ID for the matching status operation. Resume that job instead of starting the same generation again.
|
|
49
54
|
|
|
50
|
-
|
|
55
|
+
Reference images must be direct fetchable image URLs or image data, never webpage URLs. The current asset-type metadata says which types support references and how many they accept.
|
|
51
56
|
|
|
52
|
-
|
|
57
|
+
A generated humanoid model is one expressive, animation-ready biped: one head, two arms, two legs, open empty hands, and no companions or scene. Describe identity, theme, silhouette, clothing, colors, and materials. Express topology outside the shared skeleton as costume or body-surface design so the result remains riggable.
|
|
53
58
|
|
|
54
|
-
|
|
59
|
+
Request public or private access only when visibility matters. Private generation requires the account's `market:private` entitlement.
|
|
55
60
|
|
|
56
|
-
|
|
61
|
+
## Failures
|
|
57
62
|
|
|
58
|
-
|
|
63
|
+
An error means the operation did not happen. Correct invalid inputs, refresh an exact reference after a not-found response, and retry one upstream failure once. Never repeat an unchanged failed generation. Use unapproved assets only when the user explicitly requests and accepts them.
|
package/src/command.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { previewCommand } from './commands/preview.js'
|
|
|
13
13
|
import { urlsCommand } from './commands/urls.js'
|
|
14
14
|
import { uploadCommand } from './commands/upload.js'
|
|
15
15
|
import { typesCommand } from './commands/types.js'
|
|
16
|
-
import {
|
|
16
|
+
import { cliMarketSkill } from './skill.generated.js'
|
|
17
17
|
|
|
18
18
|
export interface MarketCommandOptions {
|
|
19
19
|
name?: string
|
|
@@ -60,7 +60,7 @@ export function createMarketCommand(options: MarketCommandOptions = {}): Command
|
|
|
60
60
|
.command('skill')
|
|
61
61
|
.description('Print the Market agent skill')
|
|
62
62
|
.action(() => {
|
|
63
|
-
process.stdout.write(
|
|
63
|
+
process.stdout.write(cliMarketSkill)
|
|
64
64
|
})
|
|
65
65
|
|
|
66
66
|
program
|
package/src/commands/preview.ts
CHANGED
|
@@ -2,9 +2,8 @@ import * as fs from 'fs/promises'
|
|
|
2
2
|
import * as path from 'path'
|
|
3
3
|
import ora from 'ora'
|
|
4
4
|
import { getCliClient } from '../cli-client.js'
|
|
5
|
-
import type
|
|
5
|
+
import { resolveAsset, type RefsReader } from '../refs.js'
|
|
6
6
|
import { previewResult } from '../output.js'
|
|
7
|
-
import { resolveAssetRef } from './asset-ref.js'
|
|
8
7
|
|
|
9
8
|
export interface PreviewCommandOptions {
|
|
10
9
|
unapproved?: boolean
|
|
@@ -17,7 +16,7 @@ export async function resolvePreviewRef(
|
|
|
17
16
|
ref: string,
|
|
18
17
|
includeUnapproved: boolean,
|
|
19
18
|
): Promise<{ name: string; version: string; previewUrl: string }> {
|
|
20
|
-
const asset = await
|
|
19
|
+
const asset = await resolveAsset(client, ref, { includeUnapproved })
|
|
21
20
|
if (!asset.previewUrl) {
|
|
22
21
|
throw new Error(`Asset "${ref}" has no preview image`)
|
|
23
22
|
}
|
package/src/commands/urls.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { AssetFileEntry } from '../contract.js'
|
|
|
2
2
|
import { getCliClient } from '../cli-client.js'
|
|
3
3
|
import { assetUrlsResult } from '../output.js'
|
|
4
4
|
import type { RefsReader } from '../refs.js'
|
|
5
|
-
import {
|
|
5
|
+
import { resolveAsset } from '../refs.js'
|
|
6
6
|
|
|
7
7
|
export interface AssetUrls {
|
|
8
8
|
name: string
|
|
@@ -23,7 +23,7 @@ export async function resolveAssetUrls(
|
|
|
23
23
|
ref: string,
|
|
24
24
|
opts: Pick<UrlsCommandOptions, 'unapproved' | 'key'> = {},
|
|
25
25
|
): Promise<AssetUrls> {
|
|
26
|
-
const asset = await
|
|
26
|
+
const asset = await resolveAsset(client, ref, {
|
|
27
27
|
includeUnapproved: opts.unapproved,
|
|
28
28
|
key: opts.key,
|
|
29
29
|
})
|
package/src/index.ts
CHANGED
|
@@ -16,6 +16,16 @@ export async function createMarketCommand(options: MarketCommandModule.MarketCom
|
|
|
16
16
|
// The v1 REST surface (`/api/v1`): routed contract + typed client.
|
|
17
17
|
export * as v1 from './v1/index.js'
|
|
18
18
|
|
|
19
|
+
export {
|
|
20
|
+
registerMarketTools,
|
|
21
|
+
type MarketMcpCapabilities,
|
|
22
|
+
type MarketMcpOptions,
|
|
23
|
+
type MarketMcpServer,
|
|
24
|
+
type MarketMcpToolResult,
|
|
25
|
+
} from './mcp/index.js'
|
|
26
|
+
|
|
27
|
+
export { cliMarketSkill, mcpMarketSkill } from './skill.generated.js'
|
|
28
|
+
|
|
19
29
|
// Client (an alias of the v1 client)
|
|
20
30
|
export { downloadAssetZipBytes } from './client.js'
|
|
21
31
|
export type { MarketClient, MarketClientOptions } from './client.js'
|
package/src/mcp/agent.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { agentStartSchema, agentStatusSchema } from '../schemas.js'
|
|
2
|
+
import type { MarketV1Client } from '../v1/client.js'
|
|
3
|
+
import { result } from './result.js'
|
|
4
|
+
import type { MarketMcpServer } from './types.js'
|
|
5
|
+
|
|
6
|
+
export function registerAgentTools(server: MarketMcpServer, client: MarketV1Client): void {
|
|
7
|
+
server.registerTool(
|
|
8
|
+
'start_market_agent_run',
|
|
9
|
+
{
|
|
10
|
+
title: 'Start Market agent run',
|
|
11
|
+
description:
|
|
12
|
+
'Start a Market agent run that plans, finds, judges, and generates a coherent set of assets for a goal.',
|
|
13
|
+
inputSchema: agentStartSchema,
|
|
14
|
+
annotations: {
|
|
15
|
+
readOnlyHint: false,
|
|
16
|
+
destructiveHint: false,
|
|
17
|
+
openWorldHint: true,
|
|
18
|
+
idempotentHint: false,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
async (input) => result({ run: await client.asset.agent.start(input) }),
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
server.registerTool(
|
|
25
|
+
'get_market_agent_run',
|
|
26
|
+
{
|
|
27
|
+
title: 'Get Market agent run',
|
|
28
|
+
description: 'Get the current state and result of a Market agent run.',
|
|
29
|
+
inputSchema: agentStatusSchema,
|
|
30
|
+
annotations: {
|
|
31
|
+
readOnlyHint: true,
|
|
32
|
+
destructiveHint: false,
|
|
33
|
+
openWorldHint: true,
|
|
34
|
+
idempotentHint: true,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
async (input) => result({ run: await client.asset.agent.status(input) }),
|
|
38
|
+
)
|
|
39
|
+
}
|
package/src/mcp/asset.ts
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import { resolveAsset } from '../refs.js'
|
|
3
|
+
import { assetTypeSchema } from '../schemas.js'
|
|
4
|
+
import type { MarketV1Client } from '../v1/client.js'
|
|
5
|
+
import { base64, result } from './result.js'
|
|
6
|
+
import type { MarketMcpServer } from './types.js'
|
|
7
|
+
|
|
8
|
+
const searchMarketSchema = z
|
|
9
|
+
.object({
|
|
10
|
+
query: z.string().min(1).max(200),
|
|
11
|
+
type: assetTypeSchema,
|
|
12
|
+
limit: z.coerce.number().int().min(1).max(5).default(3),
|
|
13
|
+
includeUnapproved: z.boolean().default(false),
|
|
14
|
+
})
|
|
15
|
+
.strict()
|
|
16
|
+
|
|
17
|
+
const assetRefSchema = z.string().min(1).describe('Asset name or exact name@version')
|
|
18
|
+
const assetInput = z
|
|
19
|
+
.object({
|
|
20
|
+
asset: assetRefSchema,
|
|
21
|
+
includeUnapproved: z.boolean().default(false),
|
|
22
|
+
key: z.string().min(1).max(128).optional(),
|
|
23
|
+
})
|
|
24
|
+
.strict()
|
|
25
|
+
|
|
26
|
+
export function registerAssetTools(
|
|
27
|
+
server: MarketMcpServer,
|
|
28
|
+
client: MarketV1Client,
|
|
29
|
+
fetcher: typeof globalThis.fetch,
|
|
30
|
+
): void {
|
|
31
|
+
server.registerTool(
|
|
32
|
+
'list_market_asset_types',
|
|
33
|
+
{
|
|
34
|
+
title: 'List Market asset types',
|
|
35
|
+
description:
|
|
36
|
+
'List current Drawcall Market asset types with their search, generation, and installation guidance.',
|
|
37
|
+
annotations: {
|
|
38
|
+
readOnlyHint: true,
|
|
39
|
+
destructiveHint: false,
|
|
40
|
+
openWorldHint: true,
|
|
41
|
+
idempotentHint: true,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
async () => result({ types: await client.asset.installMetadata() }),
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
server.registerTool(
|
|
48
|
+
'search_market',
|
|
49
|
+
{
|
|
50
|
+
title: 'Search Market',
|
|
51
|
+
description:
|
|
52
|
+
'Search Drawcall Market for assets matching one concrete need. Returns exact name@version references; call get_market_asset before selecting one.',
|
|
53
|
+
inputSchema: searchMarketSchema,
|
|
54
|
+
annotations: {
|
|
55
|
+
readOnlyHint: true,
|
|
56
|
+
destructiveHint: false,
|
|
57
|
+
openWorldHint: true,
|
|
58
|
+
idempotentHint: true,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
async ({ query, type, limit, includeUnapproved }) => {
|
|
62
|
+
const response = await client.asset.search({
|
|
63
|
+
query,
|
|
64
|
+
type,
|
|
65
|
+
limit,
|
|
66
|
+
page: 1,
|
|
67
|
+
includeUnapproved,
|
|
68
|
+
})
|
|
69
|
+
if (!('items' in response)) {
|
|
70
|
+
throw new Error('Market search unexpectedly returned an exact asset result')
|
|
71
|
+
}
|
|
72
|
+
return result({
|
|
73
|
+
assets: response.items.map((asset) => ({
|
|
74
|
+
asset: `${asset.name}@${asset.latestVersion}`,
|
|
75
|
+
name: asset.name,
|
|
76
|
+
version: asset.latestVersion,
|
|
77
|
+
type: asset.type,
|
|
78
|
+
description: asset.description,
|
|
79
|
+
approved: asset.approved,
|
|
80
|
+
access: asset.access,
|
|
81
|
+
previewUrl: asset.previewUrl,
|
|
82
|
+
})),
|
|
83
|
+
total: response.total,
|
|
84
|
+
})
|
|
85
|
+
},
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
server.registerTool(
|
|
89
|
+
'get_market_asset',
|
|
90
|
+
{
|
|
91
|
+
title: 'Get Market asset',
|
|
92
|
+
description:
|
|
93
|
+
'Get one exact Drawcall Market asset manifest with its version history, dependencies, files, preview URL, and zip URL.',
|
|
94
|
+
inputSchema: assetInput,
|
|
95
|
+
annotations: {
|
|
96
|
+
readOnlyHint: true,
|
|
97
|
+
destructiveHint: false,
|
|
98
|
+
openWorldHint: true,
|
|
99
|
+
idempotentHint: true,
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
async ({ asset, includeUnapproved, key }) =>
|
|
103
|
+
result({
|
|
104
|
+
asset: await resolveAsset(client.asset, asset, {
|
|
105
|
+
includeUnapproved,
|
|
106
|
+
...(key ? { key } : {}),
|
|
107
|
+
}),
|
|
108
|
+
}),
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
server.registerTool(
|
|
112
|
+
'get_market_asset_preview',
|
|
113
|
+
{
|
|
114
|
+
title: 'Get Market asset preview',
|
|
115
|
+
description: 'Return the preview image for one exact Drawcall Market asset.',
|
|
116
|
+
inputSchema: assetInput,
|
|
117
|
+
annotations: {
|
|
118
|
+
readOnlyHint: true,
|
|
119
|
+
destructiveHint: false,
|
|
120
|
+
openWorldHint: true,
|
|
121
|
+
idempotentHint: true,
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
async ({ asset: ref, includeUnapproved, key }) => {
|
|
125
|
+
const asset = await resolveAsset(client.asset, ref, {
|
|
126
|
+
includeUnapproved,
|
|
127
|
+
...(key ? { key } : {}),
|
|
128
|
+
})
|
|
129
|
+
if (!asset.previewUrl) throw new Error(`Asset "${ref}" has no preview image`)
|
|
130
|
+
|
|
131
|
+
const response = await fetcher(asset.previewUrl)
|
|
132
|
+
if (!response.ok) {
|
|
133
|
+
throw new Error(
|
|
134
|
+
`Could not read preview ${asset.previewUrl}: ${response.status} ${response.statusText}`,
|
|
135
|
+
)
|
|
136
|
+
}
|
|
137
|
+
const mimeType = response.headers.get('content-type')?.split(';', 1)[0]
|
|
138
|
+
if (!mimeType?.startsWith('image/')) {
|
|
139
|
+
throw new Error(`Preview ${asset.previewUrl} returned ${mimeType ?? 'no media type'}`)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return {
|
|
143
|
+
content: [
|
|
144
|
+
{
|
|
145
|
+
type: 'image',
|
|
146
|
+
data: base64(new Uint8Array(await response.arrayBuffer())),
|
|
147
|
+
mimeType,
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
structuredContent: {
|
|
151
|
+
asset: `${asset.name}@${asset.version}`,
|
|
152
|
+
url: asset.previewUrl,
|
|
153
|
+
mediaType: mimeType,
|
|
154
|
+
},
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
)
|
|
158
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { assetTypeSchema, generateAssetSchema, generateStatusInputSchema } from '../schemas.js'
|
|
2
|
+
import type { MarketV1Client } from '../v1/client.js'
|
|
3
|
+
import { result } from './result.js'
|
|
4
|
+
import type { MarketMcpServer } from './types.js'
|
|
5
|
+
|
|
6
|
+
const generateMarketAssetSchema = generateAssetSchema.extend({ type: assetTypeSchema }).strict()
|
|
7
|
+
|
|
8
|
+
export function registerGenerationTools(server: MarketMcpServer, client: MarketV1Client): void {
|
|
9
|
+
server.registerTool(
|
|
10
|
+
'generate_market_asset',
|
|
11
|
+
{
|
|
12
|
+
title: 'Generate Market asset',
|
|
13
|
+
description:
|
|
14
|
+
'Generate one Drawcall Market asset. A slow provider returns a jobId to pass to get_market_asset_generation.',
|
|
15
|
+
inputSchema: generateMarketAssetSchema,
|
|
16
|
+
annotations: {
|
|
17
|
+
readOnlyHint: false,
|
|
18
|
+
destructiveHint: false,
|
|
19
|
+
openWorldHint: true,
|
|
20
|
+
idempotentHint: false,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
async (input) => result({ generation: await client.asset.generate(input) }),
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
server.registerTool(
|
|
27
|
+
'get_market_asset_generation',
|
|
28
|
+
{
|
|
29
|
+
title: 'Get Market asset generation',
|
|
30
|
+
description: 'Get the current state of a Market asset generation job.',
|
|
31
|
+
inputSchema: generateStatusInputSchema.strict(),
|
|
32
|
+
annotations: {
|
|
33
|
+
readOnlyHint: true,
|
|
34
|
+
destructiveHint: false,
|
|
35
|
+
openWorldHint: true,
|
|
36
|
+
idempotentHint: true,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
async (input) => result({ generation: await client.asset.generateStatus(input) }),
|
|
40
|
+
)
|
|
41
|
+
}
|
package/src/mcp/index.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import { mcpMarketSkill } from '../skill.generated.js'
|
|
3
|
+
import type { MarketMcpServer } from './types.js'
|
|
4
|
+
|
|
5
|
+
export function registerInstructions(server: MarketMcpServer): void {
|
|
6
|
+
server.registerTool(
|
|
7
|
+
'get_market_instructions',
|
|
8
|
+
{
|
|
9
|
+
title: 'Get Market instructions',
|
|
10
|
+
description:
|
|
11
|
+
'Return instructions for finding, inspecting, generating, and using Drawcall Market assets.',
|
|
12
|
+
inputSchema: z.object({}).strict(),
|
|
13
|
+
annotations: {
|
|
14
|
+
readOnlyHint: true,
|
|
15
|
+
destructiveHint: false,
|
|
16
|
+
openWorldHint: false,
|
|
17
|
+
idempotentHint: true,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
async () => ({ content: [{ type: 'text', text: mcpMarketSkill }] }),
|
|
21
|
+
)
|
|
22
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { MarketV1Client } from '../v1/client.js'
|
|
2
|
+
import { registerAgentTools } from './agent.js'
|
|
3
|
+
import { registerAssetTools } from './asset.js'
|
|
4
|
+
import { registerGenerationTools } from './generation.js'
|
|
5
|
+
import { registerInstructions } from './instructions.js'
|
|
6
|
+
import type { MarketMcpOptions, MarketMcpServer } from './types.js'
|
|
7
|
+
|
|
8
|
+
export function registerMarketTools(
|
|
9
|
+
server: MarketMcpServer,
|
|
10
|
+
client: MarketV1Client,
|
|
11
|
+
options: MarketMcpOptions = {},
|
|
12
|
+
): void {
|
|
13
|
+
registerInstructions(server)
|
|
14
|
+
registerAssetTools(server, client, options.fetch ?? globalThis.fetch)
|
|
15
|
+
if (options.capabilities?.generate) registerGenerationTools(server, client)
|
|
16
|
+
if (options.capabilities?.agent) registerAgentTools(server, client)
|
|
17
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { MarketMcpToolResult } from './types.js'
|
|
2
|
+
|
|
3
|
+
export function result<Structured extends Record<string, unknown>>(
|
|
4
|
+
structuredContent: Structured,
|
|
5
|
+
): MarketMcpToolResult {
|
|
6
|
+
return {
|
|
7
|
+
content: [{ type: 'text', text: JSON.stringify(structuredContent) }],
|
|
8
|
+
structuredContent,
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function base64(bytes: Uint8Array): string {
|
|
13
|
+
let binary = ''
|
|
14
|
+
for (let offset = 0; offset < bytes.length; offset += 32_768) {
|
|
15
|
+
binary += String.fromCharCode(...bytes.subarray(offset, offset + 32_768))
|
|
16
|
+
}
|
|
17
|
+
return btoa(binary)
|
|
18
|
+
}
|