usepaso 0.1.0 → 0.2.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/dist/cli.js +13 -116
- package/dist/cli.js.map +1 -1
- package/dist/commands/init.d.ts +3 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +84 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/inspect.d.ts +3 -0
- package/dist/commands/inspect.d.ts.map +1 -0
- package/dist/commands/inspect.js +43 -0
- package/dist/commands/inspect.js.map +1 -0
- package/dist/commands/serve.d.ts +3 -0
- package/dist/commands/serve.d.ts.map +1 -0
- package/dist/commands/serve.js +57 -0
- package/dist/commands/serve.js.map +1 -0
- package/dist/commands/shared.d.ts +4 -0
- package/dist/commands/shared.d.ts.map +1 -0
- package/dist/commands/shared.js +51 -0
- package/dist/commands/shared.js.map +1 -0
- package/dist/commands/test.d.ts +3 -0
- package/dist/commands/test.d.ts.map +1 -0
- package/dist/commands/test.js +92 -0
- package/dist/commands/test.js.map +1 -0
- package/dist/commands/validate.d.ts +3 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/validate.js +22 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/executor.d.ts +28 -0
- package/dist/executor.d.ts.map +1 -0
- package/dist/executor.js +144 -0
- package/dist/executor.js.map +1 -0
- package/dist/generators/mcp.d.ts +4 -2
- package/dist/generators/mcp.d.ts.map +1 -1
- package/dist/generators/mcp.js +24 -109
- package/dist/generators/mcp.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/openapi.d.ts +12 -0
- package/dist/openapi.d.ts.map +1 -0
- package/dist/openapi.js +441 -0
- package/dist/openapi.js.map +1 -0
- package/dist/parser.d.ts +1 -1
- package/dist/parser.js +1 -1
- package/dist/validator.d.ts.map +1 -1
- package/dist/validator.js +41 -11
- package/dist/validator.js.map +1 -1
- package/package.json +33 -5
- package/src/cli.ts +0 -132
- package/src/generators/mcp.ts +0 -229
- package/src/index.ts +0 -14
- package/src/parser.ts +0 -23
- package/src/types.ts +0 -67
- package/src/validator.ts +0 -188
- package/tests/mcp.test.ts +0 -119
- package/tests/parser.test.ts +0 -67
- package/tests/validator.test.ts +0 -133
- package/tsconfig.json +0 -19
package/dist/cli.js
CHANGED
|
@@ -2,122 +2,19 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const commander_1 = require("commander");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
5
|
+
const init_1 = require("./commands/init");
|
|
6
|
+
const validate_1 = require("./commands/validate");
|
|
7
|
+
const inspect_1 = require("./commands/inspect");
|
|
8
|
+
const test_1 = require("./commands/test");
|
|
9
|
+
const serve_1 = require("./commands/serve");
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
11
|
+
const { version } = require('../package.json');
|
|
10
12
|
const program = new commander_1.Command();
|
|
11
|
-
program
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
program
|
|
16
|
-
|
|
17
|
-
.description('Create a paso.yaml template in the current directory')
|
|
18
|
-
.option('-n, --name <name>', 'Service name')
|
|
19
|
-
.action((opts) => {
|
|
20
|
-
const outPath = (0, path_1.resolve)('paso.yaml');
|
|
21
|
-
if ((0, fs_1.existsSync)(outPath)) {
|
|
22
|
-
console.error('paso.yaml already exists in this directory.');
|
|
23
|
-
process.exit(1);
|
|
24
|
-
}
|
|
25
|
-
const name = opts.name || 'MyService';
|
|
26
|
-
const template = `version: "1.0"
|
|
27
|
-
|
|
28
|
-
service:
|
|
29
|
-
name: ${name}
|
|
30
|
-
description: TODO — describe what your service does
|
|
31
|
-
base_url: https://api.example.com
|
|
32
|
-
auth:
|
|
33
|
-
type: bearer
|
|
34
|
-
|
|
35
|
-
capabilities:
|
|
36
|
-
- name: example_action
|
|
37
|
-
description: TODO — describe what this action does
|
|
38
|
-
method: GET
|
|
39
|
-
path: /example
|
|
40
|
-
permission: read
|
|
41
|
-
inputs:
|
|
42
|
-
id:
|
|
43
|
-
type: string
|
|
44
|
-
required: true
|
|
45
|
-
description: TODO — describe this parameter
|
|
46
|
-
in: query
|
|
47
|
-
output:
|
|
48
|
-
result:
|
|
49
|
-
type: string
|
|
50
|
-
description: TODO — describe the output
|
|
51
|
-
|
|
52
|
-
permissions:
|
|
53
|
-
read:
|
|
54
|
-
- example_action
|
|
55
|
-
`;
|
|
56
|
-
(0, fs_1.writeFileSync)(outPath, template, 'utf-8');
|
|
57
|
-
console.log(`Created paso.yaml for "${name}"`);
|
|
58
|
-
console.log('Edit the file to declare your API capabilities, then run: usepaso serve');
|
|
59
|
-
});
|
|
60
|
-
program
|
|
61
|
-
.command('validate')
|
|
62
|
-
.description('Validate a paso.yaml file')
|
|
63
|
-
.option('-f, --file <path>', 'Path to paso.yaml', 'paso.yaml')
|
|
64
|
-
.action((opts) => {
|
|
65
|
-
const filePath = (0, path_1.resolve)(opts.file);
|
|
66
|
-
if (!(0, fs_1.existsSync)(filePath)) {
|
|
67
|
-
console.error(`File not found: ${filePath}`);
|
|
68
|
-
process.exit(1);
|
|
69
|
-
}
|
|
70
|
-
try {
|
|
71
|
-
const decl = (0, parser_1.parseFile)(filePath);
|
|
72
|
-
const errors = (0, validator_1.validate)(decl);
|
|
73
|
-
if (errors.length === 0) {
|
|
74
|
-
console.log(`${filePath} is valid.`);
|
|
75
|
-
console.log(`Service: ${decl.service.name}`);
|
|
76
|
-
console.log(`Capabilities: ${decl.capabilities.length}`);
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
console.error(`Found ${errors.length} error(s):`);
|
|
80
|
-
for (const err of errors) {
|
|
81
|
-
console.error(` ${err.path}: ${err.message}`);
|
|
82
|
-
}
|
|
83
|
-
process.exit(1);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
catch (err) {
|
|
87
|
-
console.error(`Failed to parse: ${err instanceof Error ? err.message : err}`);
|
|
88
|
-
process.exit(1);
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
program
|
|
92
|
-
.command('serve')
|
|
93
|
-
.description('Start an MCP server from a paso.yaml declaration')
|
|
94
|
-
.option('-f, --file <path>', 'Path to paso.yaml', 'paso.yaml')
|
|
95
|
-
.action(async (opts) => {
|
|
96
|
-
const filePath = (0, path_1.resolve)(opts.file);
|
|
97
|
-
if (!(0, fs_1.existsSync)(filePath)) {
|
|
98
|
-
console.error(`File not found: ${filePath}`);
|
|
99
|
-
process.exit(1);
|
|
100
|
-
}
|
|
101
|
-
try {
|
|
102
|
-
const decl = (0, parser_1.parseFile)(filePath);
|
|
103
|
-
const errors = (0, validator_1.validate)(decl);
|
|
104
|
-
if (errors.length > 0) {
|
|
105
|
-
console.error(`Validation failed with ${errors.length} error(s):`);
|
|
106
|
-
for (const err of errors) {
|
|
107
|
-
console.error(` ${err.path}: ${err.message}`);
|
|
108
|
-
}
|
|
109
|
-
process.exit(1);
|
|
110
|
-
}
|
|
111
|
-
console.error(`Paso MCP server starting for "${decl.service.name}"...`);
|
|
112
|
-
console.error(`Capabilities: ${decl.capabilities.length}`);
|
|
113
|
-
console.error('Transport: stdio');
|
|
114
|
-
console.error('Waiting for MCP client connection...');
|
|
115
|
-
await (0, mcp_1.serveMcp)(decl);
|
|
116
|
-
}
|
|
117
|
-
catch (err) {
|
|
118
|
-
console.error(`Failed to start: ${err instanceof Error ? err.message : err}`);
|
|
119
|
-
process.exit(1);
|
|
120
|
-
}
|
|
121
|
-
});
|
|
13
|
+
program.name('usepaso').description('Make your API agent-ready in minutes').version(version);
|
|
14
|
+
(0, init_1.registerInit)(program);
|
|
15
|
+
(0, validate_1.registerValidate)(program);
|
|
16
|
+
(0, inspect_1.registerInspect)(program);
|
|
17
|
+
(0, test_1.registerTest)(program);
|
|
18
|
+
(0, serve_1.registerServe)(program);
|
|
122
19
|
program.parse();
|
|
123
20
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AAEA,yCAAoC;AACpC
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AAEA,yCAAoC;AACpC,0CAA+C;AAC/C,kDAAuD;AACvD,gDAAqD;AACrD,0CAA+C;AAC/C,4CAAiD;AAEjD,iEAAiE;AACjE,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAE/C,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAC9B,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,sCAAsC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AAE7F,IAAA,mBAAY,EAAC,OAAO,CAAC,CAAC;AACtB,IAAA,2BAAgB,EAAC,OAAO,CAAC,CAAC;AAC1B,IAAA,yBAAe,EAAC,OAAO,CAAC,CAAC;AACzB,IAAA,mBAAY,EAAC,OAAO,CAAC,CAAC;AACtB,IAAA,qBAAa,EAAC,OAAO,CAAC,CAAC;AAEvB,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAqBpC,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAwEnD"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerInit = registerInit;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const openapi_1 = require("../openapi");
|
|
7
|
+
const yaml_1 = require("yaml");
|
|
8
|
+
const FALLBACK_TEMPLATE = `version: "1.0"\n\nservice:\n name: __SERVICE_NAME__\n description: TODO — describe what your service does\n base_url: https://api.example.com\n auth:\n type: bearer\n\ncapabilities:\n - name: example_action\n description: TODO — describe what this action does\n method: GET\n path: /example\n permission: read\n inputs:\n id:\n type: string\n required: true\n description: TODO — describe this parameter\n in: query\n output:\n result:\n type: string\n description: TODO — describe the output\n\npermissions:\n read:\n - example_action\n`;
|
|
9
|
+
function loadTemplate() {
|
|
10
|
+
const candidates = [
|
|
11
|
+
(0, path_1.join)(__dirname, '..', '..', '..', '..', 'examples', 'template', 'usepaso.yaml'),
|
|
12
|
+
(0, path_1.join)(__dirname, '..', '..', '..', 'examples', 'template', 'usepaso.yaml'),
|
|
13
|
+
];
|
|
14
|
+
for (const tp of candidates) {
|
|
15
|
+
if ((0, fs_1.existsSync)(tp)) {
|
|
16
|
+
return (0, fs_1.readFileSync)(tp, 'utf-8');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return FALLBACK_TEMPLATE;
|
|
20
|
+
}
|
|
21
|
+
function registerInit(program) {
|
|
22
|
+
program
|
|
23
|
+
.command('init')
|
|
24
|
+
.description('Create a usepaso.yaml template in the current directory')
|
|
25
|
+
.option('-n, --name <name>', 'Service name')
|
|
26
|
+
.option('--from-openapi <path>', 'Generate from an OpenAPI 3.x spec (JSON, YAML, or URL)')
|
|
27
|
+
.action(async (opts) => {
|
|
28
|
+
const outPath = (0, path_1.resolve)('usepaso.yaml');
|
|
29
|
+
if ((0, fs_1.existsSync)(outPath)) {
|
|
30
|
+
console.error('usepaso.yaml already exists in this directory.');
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
if (opts.fromOpenapi) {
|
|
34
|
+
const source = opts.fromOpenapi;
|
|
35
|
+
try {
|
|
36
|
+
let specContent;
|
|
37
|
+
if (source.startsWith('http://') || source.startsWith('https://')) {
|
|
38
|
+
const res = await fetch(source);
|
|
39
|
+
if (!res.ok) {
|
|
40
|
+
console.error(`Failed to fetch OpenAPI spec: ${res.status} ${res.statusText}`);
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
specContent = await res.text();
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
const specPath = (0, path_1.resolve)(source);
|
|
47
|
+
if (!(0, fs_1.existsSync)(specPath)) {
|
|
48
|
+
console.error(`OpenAPI spec not found: ${specPath}`);
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
specContent = (0, fs_1.readFileSync)(specPath, 'utf-8');
|
|
52
|
+
}
|
|
53
|
+
let spec;
|
|
54
|
+
try {
|
|
55
|
+
spec = JSON.parse(specContent);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
spec = (0, yaml_1.parse)(specContent);
|
|
59
|
+
}
|
|
60
|
+
const result = (0, openapi_1.generateFromOpenApi)(spec);
|
|
61
|
+
(0, fs_1.writeFileSync)(outPath, result.yaml, 'utf-8');
|
|
62
|
+
console.log(`Generated usepaso.yaml from ${source}`);
|
|
63
|
+
console.log(` Service: ${result.serviceName}`);
|
|
64
|
+
console.log(` Capabilities: ${result.generatedCount} (${result.readCount} read, ${result.writeCount} write, ${result.adminCount} admin)`);
|
|
65
|
+
console.log(` Auth: ${result.authType}`);
|
|
66
|
+
if (result.totalOperations > result.generatedCount) {
|
|
67
|
+
console.log(` Note: ${result.totalOperations} operations found, capped at ${result.generatedCount}. Edit usepaso.yaml to add more.`);
|
|
68
|
+
}
|
|
69
|
+
console.log('Review the file, then run: usepaso validate');
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
console.error(`Failed to convert OpenAPI spec: ${err instanceof Error ? err.message : err}`);
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const name = opts.name || 'MyService';
|
|
78
|
+
const template = loadTemplate().replace('__SERVICE_NAME__', name);
|
|
79
|
+
(0, fs_1.writeFileSync)(outPath, template, 'utf-8');
|
|
80
|
+
console.log(`Created usepaso.yaml for "${name}"`);
|
|
81
|
+
console.log('Edit the file to declare your API capabilities, then run: usepaso serve');
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":";;AAqBA,oCAwEC;AA5FD,+BAAqC;AACrC,2BAA6D;AAC7D,wCAAiD;AACjD,+BAA0C;AAE1C,MAAM,iBAAiB,GAAG,6mBAA6mB,CAAC;AAExoB,SAAS,YAAY;IACnB,MAAM,UAAU,GAAG;QACjB,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,CAAC;QAC/E,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,CAAC;KAC1E,CAAC;IACF,KAAK,MAAM,EAAE,IAAI,UAAU,EAAE,CAAC;QAC5B,IAAI,IAAA,eAAU,EAAC,EAAE,CAAC,EAAE,CAAC;YACnB,OAAO,IAAA,iBAAY,EAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IACD,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED,SAAgB,YAAY,CAAC,OAAgB;IAC3C,OAAO;SACJ,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,yDAAyD,CAAC;SACtE,MAAM,CAAC,mBAAmB,EAAE,cAAc,CAAC;SAC3C,MAAM,CAAC,uBAAuB,EAAE,wDAAwD,CAAC;SACzF,MAAM,CAAC,KAAK,EAAE,IAAI,E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AAC,OAAO,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;QAClE,IAAA,kBAAa,EAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC1C,OAAO,CAAC,GAAG,CAAC,6BAA6B,IAAI,GAAG,CAAC,CAAC;QAClD,OAAO,CAAC,GAAG,CAAC,yEAAyE,CAAC,CAAC;IACzF,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../../src/commands/inspect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAuCtD"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerInspect = registerInspect;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const shared_1 = require("./shared");
|
|
6
|
+
function registerInspect(program) {
|
|
7
|
+
program
|
|
8
|
+
.command('inspect')
|
|
9
|
+
.description('Show what MCP tools would be generated (dry run)')
|
|
10
|
+
.option('-f, --file <path>', 'Path to usepaso.yaml', 'usepaso.yaml')
|
|
11
|
+
.action((opts) => {
|
|
12
|
+
try {
|
|
13
|
+
const decl = (0, shared_1.loadAndValidate)((0, path_1.resolve)(opts.file));
|
|
14
|
+
const forbidden = new Set(decl.permissions?.forbidden || []);
|
|
15
|
+
const tools = decl.capabilities.filter((c) => !forbidden.has(c.name));
|
|
16
|
+
console.log(`Service: ${decl.service.name}`);
|
|
17
|
+
console.log(`Tools: ${tools.length}`);
|
|
18
|
+
console.log(`Auth: ${decl.service.auth?.type || 'none'}`);
|
|
19
|
+
console.log('');
|
|
20
|
+
for (const tool of tools) {
|
|
21
|
+
const badge = tool.consent_required ? ' [consent required]' : '';
|
|
22
|
+
console.log(` ${tool.name} (${tool.permission})${badge}`);
|
|
23
|
+
console.log(` ${tool.method} ${tool.path}`);
|
|
24
|
+
console.log(` ${tool.description}`);
|
|
25
|
+
if (tool.inputs) {
|
|
26
|
+
const params = Object.entries(tool.inputs)
|
|
27
|
+
.map(([k, v]) => `${k}${v.required ? '*' : ''}: ${v.type}`)
|
|
28
|
+
.join(', ');
|
|
29
|
+
console.log(` params: ${params}`);
|
|
30
|
+
}
|
|
31
|
+
console.log('');
|
|
32
|
+
}
|
|
33
|
+
if (decl.permissions?.forbidden?.length) {
|
|
34
|
+
console.log(`Forbidden: ${decl.permissions.forbidden.join(', ')}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
console.error(`Failed: ${err instanceof Error ? err.message : err}`);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=inspect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspect.js","sourceRoot":"","sources":["../../src/commands/inspect.ts"],"names":[],"mappings":";;AAIA,0CAuCC;AA1CD,+BAA+B;AAC/B,qCAA2C;AAE3C,SAAgB,eAAe,CAAC,OAAgB;IAC9C,OAAO;SACJ,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,kDAAkD,CAAC;SAC/D,MAAM,CAAC,mBAAmB,EAAE,sBAAsB,EAAE,cAAc,CAAC;SACnE,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;QACf,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,IAAA,wBAAe,EAAC,IAAA,cAAO,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YAEjD,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,IAAI,EAAE,CAAC,CAAC;YAC7D,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC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M,EAAE,CAAC,CAAC;gBACvC,CAAC;gBACD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAClB,CAAC;YAED,IAAI,IAAI,CAAC,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;gBACxC,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACrE,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,WAAW,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;YACrE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../../src/commands/serve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAqEpD"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerServe = registerServe;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const shared_1 = require("./shared");
|
|
7
|
+
const mcp_1 = require("../generators/mcp");
|
|
8
|
+
function registerServe(program) {
|
|
9
|
+
program
|
|
10
|
+
.command('serve')
|
|
11
|
+
.description('Start an MCP server from a usepaso.yaml declaration')
|
|
12
|
+
.option('-f, --file <path>', 'Path to usepaso.yaml', 'usepaso.yaml')
|
|
13
|
+
.option('-v, --verbose', 'Log all requests to stderr')
|
|
14
|
+
.option('-w, --watch', 'Notify when usepaso.yaml changes (requires manual restart)')
|
|
15
|
+
.action(async (opts) => {
|
|
16
|
+
const filePath = (0, path_1.resolve)(opts.file);
|
|
17
|
+
try {
|
|
18
|
+
const decl = (0, shared_1.loadAndValidate)(filePath);
|
|
19
|
+
// Auth warning
|
|
20
|
+
if (decl.service.auth &&
|
|
21
|
+
decl.service.auth.type !== 'none' &&
|
|
22
|
+
!process.env.USEPASO_AUTH_TOKEN) {
|
|
23
|
+
console.error(`Warning: auth type "${decl.service.auth.type}" is configured but USEPASO_AUTH_TOKEN is not set. API requests will likely fail with 401.`);
|
|
24
|
+
}
|
|
25
|
+
console.error(`usepaso serving "${decl.service.name}" (${decl.capabilities.length} capabilities)`);
|
|
26
|
+
console.error('Transport: stdio — waiting for MCP client...');
|
|
27
|
+
// Show MCP config snippet
|
|
28
|
+
console.error((0, shared_1.mcpConfigSnippet)(filePath, decl.service.name));
|
|
29
|
+
console.error('');
|
|
30
|
+
// Verbose logging callback
|
|
31
|
+
const onLog = opts.verbose
|
|
32
|
+
? (capName, result) => {
|
|
33
|
+
const now = new Date().toISOString().slice(11, 19);
|
|
34
|
+
if (result.error) {
|
|
35
|
+
console.error(`[${now}] ${capName} → ERROR: ${result.error}`);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
console.error(`[${now}] ${capName} → ${result.request.method} ${result.request.url} ← ${result.status} (${result.durationMs}ms)`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
: undefined;
|
|
42
|
+
// Watch mode
|
|
43
|
+
if (opts.watch) {
|
|
44
|
+
console.error(`Watching ${filePath} for changes...`);
|
|
45
|
+
(0, fs_1.watchFile)(filePath, { interval: 1000 }, () => {
|
|
46
|
+
console.error(`\nFile changed. Restart the server to pick up changes.`);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
await (0, mcp_1.serveMcp)(decl, onLog);
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
console.error(`Failed to start: ${err instanceof Error ? err.message : err}`);
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=serve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../../src/commands/serve.ts"],"names":[],"mappings":";;AAMA,sCAqEC;AA1ED,+BAA+B;AAC/B,2BAA+B;AAC/B,qCAA6D;AAC7D,2CAA6C;AAE7C,SAAgB,aAAa,CAAC,OAAgB;IAC5C,OAAO;SACJ,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,qDAAqD,CAAC;SAClE,MAAM,CAAC,mBAAmB,EAAE,sBAAsB,EAAE,cAAc,CAAC;SACnE,MAAM,CAAC,eAAe,EAAE,4BAA4B,CAAC;SACrD,MAAM,CAAC,aAAa,EAAE,4DAA4D,CAAC;SACnF,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QACrB,MAAM,QAAQ,GAAG,IAAA,cAAO,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEpC,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,IAAA,wBAAe,EAAC,QAAQ,CAAC,CAAC;YAEvC,eAAe;YACf,IACE,IAAI,CAAC,OAAO,CAAC,IAAI;gBACjB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM;gBACjC,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAC/B,CAAC;gBACD,OAAO,CAAC,KAAK,CACX,uBAAuB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,4FAA4F,CAC1I,CAAC;YACJ,CAAC;YAED,OAAO,CAAC,KAAK,CACX,oBAAoB,IAAI,CAAC,OAAO,CAAC,IAAI,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,gBAAgB,CACpF,CAAC;YACF,OAAO,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAC;YAE9D,0BAA0B;YAC1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AAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;YAC9E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/commands/shared.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,CAejE;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAyB9E"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadAndValidate = loadAndValidate;
|
|
4
|
+
exports.mcpConfigSnippet = mcpConfigSnippet;
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
|
+
const parser_1 = require("../parser");
|
|
8
|
+
const validator_1 = require("../validator");
|
|
9
|
+
function loadAndValidate(filePath) {
|
|
10
|
+
if (!(0, fs_1.existsSync)(filePath)) {
|
|
11
|
+
console.error(`File not found: ${filePath}`);
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
const decl = (0, parser_1.parseFile)(filePath);
|
|
15
|
+
const errors = (0, validator_1.validate)(decl);
|
|
16
|
+
if (errors.length > 0) {
|
|
17
|
+
console.error(`Validation failed with ${errors.length} error(s):`);
|
|
18
|
+
for (const err of errors) {
|
|
19
|
+
console.error(` ${err.path}: ${err.message}`);
|
|
20
|
+
}
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
return decl;
|
|
24
|
+
}
|
|
25
|
+
function mcpConfigSnippet(filePath, serviceName) {
|
|
26
|
+
const absPath = (0, path_1.resolve)(filePath);
|
|
27
|
+
const slug = serviceName.toLowerCase().replace(/[^a-z0-9]+/g, '-');
|
|
28
|
+
return `
|
|
29
|
+
Add this to your MCP client config:
|
|
30
|
+
|
|
31
|
+
Claude Desktop (claude_desktop_config.json):
|
|
32
|
+
{
|
|
33
|
+
"mcpServers": {
|
|
34
|
+
"${slug}": {
|
|
35
|
+
"command": "npx",
|
|
36
|
+
"args": ["usepaso", "serve", "-f", "${absPath}"],
|
|
37
|
+
"env": { "USEPASO_AUTH_TOKEN": "your-token" }
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
Cursor (.cursor/mcp.json):
|
|
43
|
+
{
|
|
44
|
+
"${slug}": {
|
|
45
|
+
"command": "npx",
|
|
46
|
+
"args": ["usepaso", "serve", "-f", "${absPath}"],
|
|
47
|
+
"env": { "USEPASO_AUTH_TOKEN": "your-token" }
|
|
48
|
+
}
|
|
49
|
+
}`;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/commands/shared.ts"],"names":[],"mappings":";;AAMA,0CAeC;AAED,4CAyBC;AAhDD,+BAA+B;AAC/B,2BAAgC;AAChC,sCAAsC;AACtC,4CAAwC;AAGxC,SAAgB,eAAe,CAAC,QAAgB;IAC9C,IAAI,CAAC,IAAA,eAAU,EAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,OAAO,CAAC,KAAK,CAAC,mBAAmB,QAAQ,EAAE,CAAC,CAAC;QAC7C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,MAAM,IAAI,GAAG,IAAA,kBAAS,EAAC,QAAQ,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,IAAA,oBAAQ,EAAC,IAAI,CAAC,CAAC;IAC9B,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,OAAO,CAAC,KAAK,CAAC,0BAA0B,MAAM,CAAC,MAAM,YAAY,CAAC,CAAC;QACnE,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;YACzB,OAAO,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QACjD,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAgB,gBAAgB,CAAC,QAAgB,EAAE,WAAmB;IACpE,MAAM,OAAO,GAAG,IAAA,cAAO,EAAC,QAAQ,CAAC,CAAC;IAClC,MAAM,IAAI,GAAG,WAAW,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;IACnE,OAAO;;;;;;OAMF,IAAI;;4CAEiC,OAAO;;;;;;;;KAQ9C,IAAI;;0CAEiC,OAAO;;;EAG/C,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../src/commands/test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA+FnD"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerTest = registerTest;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const shared_1 = require("./shared");
|
|
6
|
+
const executor_1 = require("../executor");
|
|
7
|
+
function registerTest(program) {
|
|
8
|
+
program
|
|
9
|
+
.command('test <capability>')
|
|
10
|
+
.description('Test a capability by making the actual HTTP request (or --dry-run to preview)')
|
|
11
|
+
.option('-f, --file <path>', 'Path to usepaso.yaml', 'usepaso.yaml')
|
|
12
|
+
.option('-p, --param <key=value...>', 'Parameters (repeatable)', (val, acc) => {
|
|
13
|
+
acc.push(val);
|
|
14
|
+
return acc;
|
|
15
|
+
}, [])
|
|
16
|
+
.option('--dry-run', 'Show the HTTP request without executing it')
|
|
17
|
+
.action(async (capabilityName, opts) => {
|
|
18
|
+
try {
|
|
19
|
+
const decl = (0, shared_1.loadAndValidate)((0, path_1.resolve)(opts.file));
|
|
20
|
+
const cap = decl.capabilities.find((c) => c.name === capabilityName);
|
|
21
|
+
if (!cap) {
|
|
22
|
+
console.error(`Capability "${capabilityName}" not found.`);
|
|
23
|
+
console.error(`Available: ${decl.capabilities.map((c) => c.name).join(', ')}`);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
// Parse params
|
|
27
|
+
const args = {};
|
|
28
|
+
for (const p of opts.param) {
|
|
29
|
+
const eq = p.indexOf('=');
|
|
30
|
+
if (eq === -1) {
|
|
31
|
+
console.error(`Invalid param format: "${p}". Use key=value.`);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
const key = p.slice(0, eq);
|
|
35
|
+
let value = p.slice(eq + 1);
|
|
36
|
+
if (value === 'true')
|
|
37
|
+
value = true;
|
|
38
|
+
else if (value === 'false')
|
|
39
|
+
value = false;
|
|
40
|
+
else if (!isNaN(Number(value)) && value !== '')
|
|
41
|
+
value = Number(value);
|
|
42
|
+
args[key] = value;
|
|
43
|
+
}
|
|
44
|
+
// Check for missing required params
|
|
45
|
+
if (cap.inputs) {
|
|
46
|
+
for (const [name, input] of Object.entries(cap.inputs)) {
|
|
47
|
+
if (input.required && !(name in args)) {
|
|
48
|
+
console.error(`Missing required parameter: ${name} (${input.description})`);
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const req = (0, executor_1.buildRequest)(cap, args, decl);
|
|
54
|
+
if (opts.dryRun) {
|
|
55
|
+
console.log('--- DRY RUN (no request will be made) ---');
|
|
56
|
+
console.log('');
|
|
57
|
+
console.log(`${req.method} ${req.url}`);
|
|
58
|
+
for (const [k, v] of Object.entries(req.headers)) {
|
|
59
|
+
const display = k.toLowerCase() === 'authorization' ? `${v.slice(0, 12)}...` : v;
|
|
60
|
+
console.log(`${k}: ${display}`);
|
|
61
|
+
}
|
|
62
|
+
if (req.body) {
|
|
63
|
+
console.log('');
|
|
64
|
+
console.log(req.body);
|
|
65
|
+
}
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
console.log(`Testing ${cap.name}...`);
|
|
69
|
+
console.log(`→ ${req.method} ${req.url}`);
|
|
70
|
+
if (req.body)
|
|
71
|
+
console.log(`→ Body: ${req.body}`);
|
|
72
|
+
console.log('');
|
|
73
|
+
const result = await (0, executor_1.executeRequest)(req);
|
|
74
|
+
if (result.error) {
|
|
75
|
+
console.error((0, executor_1.formatError)(result, decl));
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
console.log(`← ${result.status} ${result.statusText} (${result.durationMs}ms)`);
|
|
79
|
+
console.log('');
|
|
80
|
+
if (result.status && result.status >= 400) {
|
|
81
|
+
console.error((0, executor_1.formatError)(result, decl));
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
console.log(result.body);
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
console.error(`Failed: ${err instanceof Error ? err.message : err}`);
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test.js","sourceRoot":"","sources":["../../src/commands/test.ts"],"names":[],"mappings":";;AAKA,oCA+FC;AAnGD,+BAA+B;AAC/B,qCAA2C;AAC3C,0CAAwE;AAExE,SAAgB,YAAY,CAAC,OAAgB;IAC3C,OAAO;SACJ,OAAO,C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CAAC;YAClB,CAAC;YAED,OAAO,CAAC,GAAG,CAAC,KAAK,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,UAAU,KAAK,MAAM,CAAC,UAAU,KAAK,CAAC,CAAC;YAChF,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAEhB,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC;gBAC1C,OAAO,CAAC,KAAK,CAAC,IAAA,sBAAW,EAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;gBACzC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC;YAED,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,WAAW,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;YACrE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/commands/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAcvD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerValidate = registerValidate;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const shared_1 = require("./shared");
|
|
6
|
+
function registerValidate(program) {
|
|
7
|
+
program
|
|
8
|
+
.command('validate')
|
|
9
|
+
.description('Validate a usepaso.yaml file')
|
|
10
|
+
.option('-f, --file <path>', 'Path to usepaso.yaml', 'usepaso.yaml')
|
|
11
|
+
.action((opts) => {
|
|
12
|
+
try {
|
|
13
|
+
const decl = (0, shared_1.loadAndValidate)((0, path_1.resolve)(opts.file));
|
|
14
|
+
console.log(`valid (${decl.service.name}, ${decl.capabilities.length} capabilities)`);
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
console.error(`Failed to parse: ${err instanceof Error ? err.message : err}`);
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/commands/validate.ts"],"names":[],"mappings":";;AAIA,4CAcC;AAjBD,+BAA+B;AAC/B,qCAA2C;AAE3C,SAAgB,gBAAgB,CAAC,OAAgB;IAC/C,OAAO;SACJ,OAAO,CAAC,UAAU,CAAC;SACnB,WAAW,CAAC,8BAA8B,CAAC;SAC3C,MAAM,CAAC,mBAAmB,EAAE,sBAAsB,EAAE,cAAc,CAAC;SACnE,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;QACf,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,IAAA,wBAAe,EAAC,IAAA,cAAO,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YACjD,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,IAAI,CAAC,YAAY,CAAC,MAAM,gBAAgB,CAAC,CAAC;QACxF,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,oBAAoB,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;YAC9E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PasoCapability, PasoDeclaration } from './types';
|
|
2
|
+
export interface ExecutionRequest {
|
|
3
|
+
method: string;
|
|
4
|
+
url: string;
|
|
5
|
+
headers: Record<string, string>;
|
|
6
|
+
body?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ExecutionResult {
|
|
9
|
+
request: ExecutionRequest;
|
|
10
|
+
status?: number;
|
|
11
|
+
statusText?: string;
|
|
12
|
+
body: string;
|
|
13
|
+
durationMs: number;
|
|
14
|
+
error?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Build the HTTP request for a capability without executing it.
|
|
18
|
+
*/
|
|
19
|
+
export declare function buildRequest(cap: PasoCapability, args: Record<string, unknown>, decl: PasoDeclaration): ExecutionRequest;
|
|
20
|
+
/**
|
|
21
|
+
* Execute an HTTP request and return the result.
|
|
22
|
+
*/
|
|
23
|
+
export declare function executeRequest(req: ExecutionRequest): Promise<ExecutionResult>;
|
|
24
|
+
/**
|
|
25
|
+
* Format a friendly error message for common HTTP status codes.
|
|
26
|
+
*/
|
|
27
|
+
export declare function formatError(result: ExecutionResult, decl: PasoDeclaration): string;
|
|
28
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../src/executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1D,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,gBAAgB,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,IAAI,EAAE,eAAe,GACpB,gBAAgB,CAoElB;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC,CAwCpF;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,eAAe,GAAG,MAAM,CAqClF"}
|