toolfactory 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +166 -0
- package/dist/bindings/index.d.ts +23 -0
- package/dist/bindings/index.js +29 -0
- package/dist/bindings/python.d.ts +33 -0
- package/dist/bindings/python.js +805 -0
- package/dist/bindings/python.test.d.ts +1 -0
- package/dist/bindings/python.test.js +316 -0
- package/dist/bindings/typescript.d.ts +39 -0
- package/dist/bindings/typescript.js +758 -0
- package/dist/bindings/typescript.test.d.ts +1 -0
- package/dist/bindings/typescript.test.js +264 -0
- package/dist/commands.d.ts +188 -0
- package/dist/commands.js +662 -0
- package/dist/commands.test.d.ts +1 -0
- package/dist/commands.test.js +215 -0
- package/dist/e2e.test.d.ts +1 -0
- package/dist/e2e.test.js +124 -0
- package/dist/hosts/browser.d.ts +10 -0
- package/dist/hosts/browser.js +94 -0
- package/dist/hosts/github.d.ts +66 -0
- package/dist/hosts/github.js +247 -0
- package/dist/hosts/openclaw.d.ts +4 -0
- package/dist/hosts/openclaw.js +94 -0
- package/dist/hosts/template.d.ts +15 -0
- package/dist/hosts/template.js +142 -0
- package/dist/hosts/web.d.ts +4 -0
- package/dist/hosts/web.js +89 -0
- package/dist/identity/name.d.ts +20 -0
- package/dist/identity/name.js +33 -0
- package/dist/identity/name.test.d.ts +1 -0
- package/dist/identity/name.test.js +37 -0
- package/dist/identity/read.d.ts +9 -0
- package/dist/identity/read.js +106 -0
- package/dist/identity/read.test.d.ts +1 -0
- package/dist/identity/read.test.js +76 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/introspect/index.d.ts +15 -0
- package/dist/introspect/index.js +63 -0
- package/dist/model.d.ts +236 -0
- package/dist/model.js +214 -0
- package/dist/ops.d.ts +255 -0
- package/dist/ops.js +297 -0
- package/dist/project/apply.d.ts +35 -0
- package/dist/project/apply.js +360 -0
- package/dist/project/apply.test.d.ts +1 -0
- package/dist/project/apply.test.js +285 -0
- package/dist/project/gate.d.ts +129 -0
- package/dist/project/gate.js +597 -0
- package/dist/project/history.d.ts +62 -0
- package/dist/project/history.js +41 -0
- package/dist/project/load.d.ts +21 -0
- package/dist/project/load.js +82 -0
- package/dist/project/lock.d.ts +28 -0
- package/dist/project/lock.js +42 -0
- package/dist/project/plan.d.ts +5 -0
- package/dist/project/plan.js +96 -0
- package/dist/report/coverage.d.ts +22 -0
- package/dist/report/coverage.js +72 -0
- package/dist/report/coverage.test.d.ts +1 -0
- package/dist/report/coverage.test.js +93 -0
- package/dist/surfaces/agent-plugins.d.ts +10 -0
- package/dist/surfaces/agent-plugins.js +36 -0
- package/dist/surfaces/agents.d.ts +35 -0
- package/dist/surfaces/agents.js +609 -0
- package/dist/surfaces/agents.template.d.ts +8 -0
- package/dist/surfaces/agents.template.js +21 -0
- package/dist/surfaces/agents.test.d.ts +1 -0
- package/dist/surfaces/agents.test.js +181 -0
- package/dist/surfaces/browser-extension.d.ts +101 -0
- package/dist/surfaces/browser-extension.js +1034 -0
- package/dist/surfaces/browser-extension.test.d.ts +1 -0
- package/dist/surfaces/browser-extension.test.js +145 -0
- package/dist/surfaces/claude.d.ts +2 -0
- package/dist/surfaces/claude.js +81 -0
- package/dist/surfaces/codex.d.ts +13 -0
- package/dist/surfaces/codex.js +101 -0
- package/dist/surfaces/codex.test.d.ts +1 -0
- package/dist/surfaces/codex.test.js +67 -0
- package/dist/surfaces/cursor.d.ts +2 -0
- package/dist/surfaces/cursor.js +50 -0
- package/dist/surfaces/distribution.test.d.ts +1 -0
- package/dist/surfaces/distribution.test.js +146 -0
- package/dist/surfaces/dsh.d.ts +25 -0
- package/dist/surfaces/dsh.js +147 -0
- package/dist/surfaces/dsh.test.d.ts +1 -0
- package/dist/surfaces/dsh.test.js +100 -0
- package/dist/surfaces/external.d.ts +9 -0
- package/dist/surfaces/external.js +4 -0
- package/dist/surfaces/gemini.d.ts +29 -0
- package/dist/surfaces/gemini.js +68 -0
- package/dist/surfaces/gemini.test.d.ts +1 -0
- package/dist/surfaces/gemini.test.js +74 -0
- package/dist/surfaces/hermes-native.d.ts +53 -0
- package/dist/surfaces/hermes-native.js +507 -0
- package/dist/surfaces/hermes-native.test.d.ts +1 -0
- package/dist/surfaces/hermes-native.test.js +156 -0
- package/dist/surfaces/kernel.d.ts +5 -0
- package/dist/surfaces/kernel.js +63 -0
- package/dist/surfaces/mcp-registry.d.ts +19 -0
- package/dist/surfaces/mcp-registry.js +160 -0
- package/dist/surfaces/mcp-registry.test.d.ts +1 -0
- package/dist/surfaces/mcp-registry.test.js +79 -0
- package/dist/surfaces/mcpb.d.ts +11 -0
- package/dist/surfaces/mcpb.js +118 -0
- package/dist/surfaces/mcpb.test.d.ts +1 -0
- package/dist/surfaces/mcpb.test.js +104 -0
- package/dist/surfaces/npm.d.ts +6 -0
- package/dist/surfaces/npm.js +72 -0
- package/dist/surfaces/openclaw-native.d.ts +93 -0
- package/dist/surfaces/openclaw-native.js +956 -0
- package/dist/surfaces/openclaw-native.test.d.ts +1 -0
- package/dist/surfaces/openclaw-native.test.js +246 -0
- package/dist/surfaces/pypi.d.ts +5 -0
- package/dist/surfaces/pypi.js +82 -0
- package/dist/surfaces/readme.d.ts +7 -0
- package/dist/surfaces/readme.js +181 -0
- package/dist/surfaces/registry.d.ts +6 -0
- package/dist/surfaces/registry.js +73 -0
- package/dist/surfaces/shared.d.ts +49 -0
- package/dist/surfaces/shared.js +112 -0
- package/dist/surfaces/skill.d.ts +7 -0
- package/dist/surfaces/skill.js +118 -0
- package/dist/surfaces/skill.test.d.ts +1 -0
- package/dist/surfaces/skill.test.js +87 -0
- package/dist/surfaces/web.d.ts +97 -0
- package/dist/surfaces/web.js +1285 -0
- package/dist/surfaces/web.test.d.ts +1 -0
- package/dist/surfaces/web.test.js +255 -0
- package/dist/surfaces/workflows.d.ts +2 -0
- package/dist/surfaces/workflows.js +809 -0
- package/dist/surfaces/workflows.test.d.ts +1 -0
- package/dist/surfaces/workflows.test.js +563 -0
- package/dist/toolfactory/cli.d.ts +2 -0
- package/dist/toolfactory/cli.js +65 -0
- package/dist/toolfactory/config.d.ts +3 -0
- package/dist/toolfactory/config.js +27 -0
- package/dist/toolfactory/mcp.d.ts +37 -0
- package/dist/toolfactory/mcp.js +269 -0
- package/dist/toolfactory/types.d.ts +31 -0
- package/dist/toolfactory/types.js +10 -0
- package/dist/toolfactory/web.d.ts +4 -0
- package/dist/toolfactory/web.js +40 -0
- package/dist/validate/agent-plugins.d.ts +5 -0
- package/dist/validate/agent-plugins.js +46 -0
- package/package.json +68 -0
- package/schemas/agent-plugins/mcp.schema.json +120 -0
- package/schemas/agent-plugins/plugin.schema.json +65 -0
- package/src/bindings/index.ts +47 -0
- package/src/bindings/python.test.ts +374 -0
- package/src/bindings/python.ts +862 -0
- package/src/bindings/typescript.test.ts +329 -0
- package/src/bindings/typescript.ts +818 -0
- package/src/commands.test.ts +253 -0
- package/src/commands.ts +886 -0
- package/src/e2e.test.ts +169 -0
- package/src/hosts/browser.ts +106 -0
- package/src/hosts/github.ts +321 -0
- package/src/hosts/openclaw.ts +110 -0
- package/src/hosts/template.ts +149 -0
- package/src/hosts/web.ts +111 -0
- package/src/identity/name.test.ts +43 -0
- package/src/identity/name.ts +39 -0
- package/src/identity/read.test.ts +92 -0
- package/src/identity/read.ts +119 -0
- package/src/index.ts +11 -0
- package/src/introspect/index.ts +72 -0
- package/src/model.ts +386 -0
- package/src/ops.ts +333 -0
- package/src/project/apply.test.ts +348 -0
- package/src/project/apply.ts +417 -0
- package/src/project/gate.ts +717 -0
- package/src/project/history.ts +46 -0
- package/src/project/load.ts +104 -0
- package/src/project/lock.ts +54 -0
- package/src/project/plan.ts +101 -0
- package/src/report/coverage.test.ts +108 -0
- package/src/report/coverage.ts +113 -0
- package/src/surfaces/agent-plugins.ts +47 -0
- package/src/surfaces/agents.template.ts +32 -0
- package/src/surfaces/agents.test.ts +206 -0
- package/src/surfaces/agents.ts +729 -0
- package/src/surfaces/browser-extension.test.ts +175 -0
- package/src/surfaces/browser-extension.ts +1095 -0
- package/src/surfaces/claude.ts +99 -0
- package/src/surfaces/codex.test.ts +71 -0
- package/src/surfaces/codex.ts +105 -0
- package/src/surfaces/cursor.ts +62 -0
- package/src/surfaces/distribution.test.ts +166 -0
- package/src/surfaces/dsh.test.ts +110 -0
- package/src/surfaces/dsh.ts +159 -0
- package/src/surfaces/external.ts +13 -0
- package/src/surfaces/gemini.test.ts +80 -0
- package/src/surfaces/gemini.ts +84 -0
- package/src/surfaces/hermes-native.test.ts +179 -0
- package/src/surfaces/hermes-native.ts +584 -0
- package/src/surfaces/kernel.ts +68 -0
- package/src/surfaces/mcp-registry.test.ts +99 -0
- package/src/surfaces/mcp-registry.ts +190 -0
- package/src/surfaces/mcpb.test.ts +112 -0
- package/src/surfaces/mcpb.ts +130 -0
- package/src/surfaces/npm.ts +78 -0
- package/src/surfaces/openclaw-native.test.ts +283 -0
- package/src/surfaces/openclaw-native.ts +1070 -0
- package/src/surfaces/pypi.ts +84 -0
- package/src/surfaces/readme.ts +218 -0
- package/src/surfaces/registry.ts +79 -0
- package/src/surfaces/shared.ts +140 -0
- package/src/surfaces/skill.test.ts +103 -0
- package/src/surfaces/skill.ts +136 -0
- package/src/surfaces/web.test.ts +303 -0
- package/src/surfaces/web.ts +1310 -0
- package/src/surfaces/workflows.test.ts +677 -0
- package/src/surfaces/workflows.ts +936 -0
- package/src/toolfactory/cli.ts +74 -0
- package/src/toolfactory/config.ts +33 -0
- package/src/toolfactory/mcp.ts +311 -0
- package/src/toolfactory/types.ts +52 -0
- package/src/toolfactory/web.ts +45 -0
- package/src/validate/agent-plugins.ts +53 -0
- package/web/dist/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
- package/web/dist/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
- package/web/dist/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
- package/web/dist/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
- package/web/dist/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
- package/web/dist/assets/index-CCXhQKK3.css +2 -0
- package/web/dist/assets/index-D1PwZ3qS.js +10 -0
- package/web/dist/index.html +14 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import type { Operation, PlannedFile, Project } from "../model.js";
|
|
3
|
+
import {
|
|
4
|
+
surface as browserExtension,
|
|
5
|
+
browserVerdict,
|
|
6
|
+
HOST_DIR,
|
|
7
|
+
permissions,
|
|
8
|
+
WXT_PIN,
|
|
9
|
+
zipName,
|
|
10
|
+
} from "./browser-extension.js";
|
|
11
|
+
|
|
12
|
+
const echo: Operation = { name: "echo", inputSchema: { type: "object" }, requires: [] };
|
|
13
|
+
const scrape: Operation = {
|
|
14
|
+
name: "scrape",
|
|
15
|
+
inputSchema: { type: "object" },
|
|
16
|
+
requires: ["browser"],
|
|
17
|
+
};
|
|
18
|
+
const summarize: Operation = {
|
|
19
|
+
name: "summarize",
|
|
20
|
+
inputSchema: { type: "object" },
|
|
21
|
+
requires: ["model"],
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
function fixture(overrides: Partial<Project["tool"]> = {}): Project {
|
|
25
|
+
return {
|
|
26
|
+
root: "/repo",
|
|
27
|
+
tool: {
|
|
28
|
+
schemaVersion: 1,
|
|
29
|
+
identity: "plugin.json",
|
|
30
|
+
binding: "typescript",
|
|
31
|
+
surfaces: ["mcp", "web", "browser-extension"],
|
|
32
|
+
bundle: { runtime: "package" },
|
|
33
|
+
tests: { examples: { echo: { text: "hi" } } },
|
|
34
|
+
...overrides,
|
|
35
|
+
},
|
|
36
|
+
identity: {
|
|
37
|
+
name: "hello.tool",
|
|
38
|
+
version: "0.1.0",
|
|
39
|
+
repository: "https://github.com/octo/hello",
|
|
40
|
+
},
|
|
41
|
+
identityExtra: {},
|
|
42
|
+
operations: [echo, scrape, summarize],
|
|
43
|
+
toolfactoryVersion: "0.1.0",
|
|
44
|
+
packageManager: "npm",
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function planned(project: Project): Record<string, PlannedFile> {
|
|
49
|
+
return Object.fromEntries(browserExtension.plan(project).map((file) => [file.path, file]));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function content(file: PlannedFile | undefined): string {
|
|
53
|
+
if (file?.kind === "file") return file.content;
|
|
54
|
+
if (file?.kind === "region") return file.regions.map((region) => region.content).join("");
|
|
55
|
+
throw new Error("expected a whole or region file");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
describe("browser-extension", () => {
|
|
59
|
+
it("plans one WXT project: generated whole files, two regions the author owns, one merge", () => {
|
|
60
|
+
const files = planned(fixture());
|
|
61
|
+
expect(Object.keys(files).sort()).toEqual([
|
|
62
|
+
`${HOST_DIR}/.gitignore`,
|
|
63
|
+
`${HOST_DIR}/README.md`,
|
|
64
|
+
`${HOST_DIR}/TARGETS.md`,
|
|
65
|
+
`${HOST_DIR}/entrypoints/background.ts`,
|
|
66
|
+
`${HOST_DIR}/entrypoints/example.content.ts`,
|
|
67
|
+
`${HOST_DIR}/entrypoints/options/index.html`,
|
|
68
|
+
`${HOST_DIR}/entrypoints/options/main.tsx`,
|
|
69
|
+
`${HOST_DIR}/entrypoints/popup/index.html`,
|
|
70
|
+
`${HOST_DIR}/entrypoints/popup/main.tsx`,
|
|
71
|
+
`${HOST_DIR}/env.d.ts`,
|
|
72
|
+
`${HOST_DIR}/package.json`,
|
|
73
|
+
`${HOST_DIR}/tests/background.test.ts`,
|
|
74
|
+
`${HOST_DIR}/tests/smoke.mjs`,
|
|
75
|
+
`${HOST_DIR}/tsconfig.json`,
|
|
76
|
+
`${HOST_DIR}/utils/mcp.ts`,
|
|
77
|
+
`${HOST_DIR}/utils/page.css`,
|
|
78
|
+
`${HOST_DIR}/utils/page.tsx`,
|
|
79
|
+
`${HOST_DIR}/vitest.config.ts`,
|
|
80
|
+
`${HOST_DIR}/web-ext-config.mjs`,
|
|
81
|
+
`${HOST_DIR}/wxt.config.ts`,
|
|
82
|
+
]);
|
|
83
|
+
// The manifest is never written here: WXT emits one per target out of these two inputs.
|
|
84
|
+
expect(Object.keys(files)).not.toContain(`${HOST_DIR}/manifest.json`);
|
|
85
|
+
expect(files[`${HOST_DIR}/package.json`]).toMatchObject({
|
|
86
|
+
kind: "merge",
|
|
87
|
+
patch: { name: "hello.tool-browser", devDependencies: { wxt: WXT_PIN } },
|
|
88
|
+
});
|
|
89
|
+
expect(files[`${HOST_DIR}/entrypoints/background.ts`]?.kind).toBe("region");
|
|
90
|
+
expect(files[`${HOST_DIR}/wxt.config.ts`]?.kind).toBe("region");
|
|
91
|
+
// WXT names an archive after `zip.name`, which the config sets to the tool's own name.
|
|
92
|
+
expect(zipName(fixture(), "firefox")).toBe("hello.tool-0.1.0-firefox.zip");
|
|
93
|
+
expect(content(files[`${HOST_DIR}/wxt.config.ts`])).toContain('zip: { name: "hello.tool" }');
|
|
94
|
+
|
|
95
|
+
// The popup is the `web` surface's tree, imported; without it, only the pairing form ships.
|
|
96
|
+
expect(content(files[`${HOST_DIR}/entrypoints/popup/main.tsx`])).toContain('from "@web/App"');
|
|
97
|
+
// Launching the web app here means popping the same tree out of the 540px popup into a tab;
|
|
98
|
+
// the options page is already that tab, so it gets no button.
|
|
99
|
+
expect(content(files[`${HOST_DIR}/entrypoints/popup/main.tsx`])).toContain("<OpenFullPage />");
|
|
100
|
+
expect(content(files[`${HOST_DIR}/entrypoints/options/main.tsx`])).not.toContain(
|
|
101
|
+
"OpenFullPage",
|
|
102
|
+
);
|
|
103
|
+
expect(content(files[`${HOST_DIR}/utils/page.tsx`])).toContain(
|
|
104
|
+
"browser.runtime.openOptionsPage()",
|
|
105
|
+
);
|
|
106
|
+
const alone = planned(fixture({ surfaces: ["mcp", "browser-extension"] }));
|
|
107
|
+
expect(content(alone[`${HOST_DIR}/entrypoints/popup/main.tsx`])).not.toContain("@web/App");
|
|
108
|
+
expect(alone[`${HOST_DIR}/utils/page.css`]).toBeUndefined();
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("projects the manifest from capabilities, never from a hand-written permission list", () => {
|
|
112
|
+
// `storage` for the pairing store; `activeTab` because an operation declares `browser`.
|
|
113
|
+
expect(permissions(fixture(), [echo, scrape])).toEqual(["storage", "activeTab"]);
|
|
114
|
+
expect(permissions(fixture(), [echo])).toEqual(["storage"]);
|
|
115
|
+
expect(
|
|
116
|
+
permissions(fixture({ browserExtension: { cookieExport: true, sidePanel: true } }), [echo]),
|
|
117
|
+
).toEqual(["storage", "cookies", "sidePanel"]);
|
|
118
|
+
|
|
119
|
+
const config = content(planned(fixture())[`${HOST_DIR}/wxt.config.ts`]);
|
|
120
|
+
// Loopback is portable only without a port (Firefox rejects a port in a match pattern), and
|
|
121
|
+
// the declared session domains are added to it — never `<all_urls>`.
|
|
122
|
+
expect(config).toContain(
|
|
123
|
+
'const HOST_PERMISSIONS = ["http://127.0.0.1/*", "http://localhost/*"];',
|
|
124
|
+
);
|
|
125
|
+
expect(config).toContain('id: "hello.tool@octo.github.io"');
|
|
126
|
+
const vandy = content(
|
|
127
|
+
planned(fixture({ browserExtension: { authDomains: ["*://*.vanderbilt.edu/*"] } }))[
|
|
128
|
+
`${HOST_DIR}/wxt.config.ts`
|
|
129
|
+
],
|
|
130
|
+
);
|
|
131
|
+
expect(vandy).toContain('"*://*.vanderbilt.edu/*"');
|
|
132
|
+
// A Chromium-only permission is dropped from the other engines' manifests, not shipped dead.
|
|
133
|
+
expect(config).toContain("CHROMIUM.includes(browser) || !CHROMIUM_ONLY.includes(permission)");
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it("is native for browser and user-input operations, and degrades the export on Safari", () => {
|
|
137
|
+
const project = fixture();
|
|
138
|
+
expect(browserExtension.verdict?.(scrape, project)).toEqual({ kind: "native" });
|
|
139
|
+
expect(browserExtension.verdict?.(summarize, project)).toEqual({
|
|
140
|
+
kind: "excluded",
|
|
141
|
+
reason: "excluded:no-model-bridge",
|
|
142
|
+
});
|
|
143
|
+
for (const engine of ["chromium", "firefox", "safari"] as const) {
|
|
144
|
+
expect(browserVerdict(scrape, project, engine)).toEqual({ kind: "native" });
|
|
145
|
+
expect(browserVerdict(summarize, project, engine).kind).toBe("excluded");
|
|
146
|
+
}
|
|
147
|
+
// Safari Web Extensions cannot read httpOnly cookies, so an opted-in export degrades there.
|
|
148
|
+
const exporting = fixture({ browserExtension: { cookieExport: true } });
|
|
149
|
+
expect(browserVerdict(scrape, exporting, "firefox")).toEqual({ kind: "native" });
|
|
150
|
+
expect(browserVerdict(scrape, exporting, "safari")).toEqual({
|
|
151
|
+
kind: "degraded",
|
|
152
|
+
reason: "degraded:no-httponly-cookies",
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it("validates with the extension's own pinned CLIs, from inside the extension", () => {
|
|
157
|
+
const project = fixture();
|
|
158
|
+
const commands = browserExtension.validate?.(project) ?? [];
|
|
159
|
+
expect(commands.map((command) => [command.command, ...command.args].join(" "))).toEqual([
|
|
160
|
+
"npm install",
|
|
161
|
+
"npm exec --no -- wxt prepare",
|
|
162
|
+
expect.stringContaining("hosts/browser"),
|
|
163
|
+
"npm exec --no -- wxt build",
|
|
164
|
+
"npm exec --no -- wxt build -b firefox",
|
|
165
|
+
"npm exec --no -- web-ext lint -s .output/firefox-mv2",
|
|
166
|
+
"npm exec --no -- playwright install chromium",
|
|
167
|
+
"npm run test",
|
|
168
|
+
"node tests/smoke.mjs",
|
|
169
|
+
]);
|
|
170
|
+
// wxt reads its entrypoints from the working directory, so every step runs in the host dir.
|
|
171
|
+
expect(new Set(commands.map((command) => command.cwd))).toEqual(
|
|
172
|
+
new Set([`/repo/${HOST_DIR}`, "/repo"]),
|
|
173
|
+
);
|
|
174
|
+
});
|
|
175
|
+
});
|