@trusty-squire/mcp 0.1.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/LICENSE +21 -0
- package/README.md +83 -0
- package/dist/api-client.d.ts +130 -0
- package/dist/api-client.d.ts.map +1 -0
- package/dist/api-client.js +156 -0
- package/dist/api-client.js.map +1 -0
- package/dist/install/agents.d.ts +16 -0
- package/dist/install/agents.d.ts.map +1 -0
- package/dist/install/agents.js +171 -0
- package/dist/install/agents.js.map +1 -0
- package/dist/install/cli.d.ts +24 -0
- package/dist/install/cli.d.ts.map +1 -0
- package/dist/install/cli.js +277 -0
- package/dist/install/cli.js.map +1 -0
- package/dist/server.d.ts +4 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +100 -0
- package/dist/server.js.map +1 -0
- package/dist/session.d.ts +25 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +112 -0
- package/dist/session.js.map +1 -0
- package/dist/tools/cancel.d.ts +12 -0
- package/dist/tools/cancel.d.ts.map +1 -0
- package/dist/tools/cancel.js +34 -0
- package/dist/tools/cancel.js.map +1 -0
- package/dist/tools/get-credential.d.ts +15 -0
- package/dist/tools/get-credential.d.ts.map +1 -0
- package/dist/tools/get-credential.js +44 -0
- package/dist/tools/get-credential.js.map +1 -0
- package/dist/tools/get-usage.d.ts +6 -0
- package/dist/tools/get-usage.d.ts.map +1 -0
- package/dist/tools/get-usage.js +24 -0
- package/dist/tools/get-usage.js.map +1 -0
- package/dist/tools/index.d.ts +23 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +48 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/list-services.d.ts +15 -0
- package/dist/tools/list-services.d.ts.map +1 -0
- package/dist/tools/list-services.js +55 -0
- package/dist/tools/list-services.js.map +1 -0
- package/dist/tools/list-subscriptions.d.ts +6 -0
- package/dist/tools/list-subscriptions.d.ts.map +1 -0
- package/dist/tools/list-subscriptions.js +25 -0
- package/dist/tools/list-subscriptions.js.map +1 -0
- package/dist/tools/provision-any.d.ts +120 -0
- package/dist/tools/provision-any.d.ts.map +1 -0
- package/dist/tools/provision-any.js +243 -0
- package/dist/tools/provision-any.js.map +1 -0
- package/dist/tools/provision.d.ts +30 -0
- package/dist/tools/provision.d.ts.map +1 -0
- package/dist/tools/provision.js +108 -0
- package/dist/tools/provision.js.map +1 -0
- package/dist/tools/rotate-credential.d.ts +12 -0
- package/dist/tools/rotate-credential.d.ts.map +1 -0
- package/dist/tools/rotate-credential.js +43 -0
- package/dist/tools/rotate-credential.js.map +1 -0
- package/dist/tools/wait-for-approval.d.ts +28 -0
- package/dist/tools/wait-for-approval.d.ts.map +1 -0
- package/dist/tools/wait-for-approval.js +82 -0
- package/dist/tools/wait-for-approval.js.map +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { assertPaired } from "./index.js";
|
|
3
|
+
const inputSchema = z.object({
|
|
4
|
+
reference: z.string().min(1),
|
|
5
|
+
purpose: z.string().min(1).max(200),
|
|
6
|
+
});
|
|
7
|
+
const DESCRIPTION = `Retrieve a credential the user previously authorized for this account.
|
|
8
|
+
Returns the secret value so you can plug it into your code's env vars
|
|
9
|
+
or pass it to a request.
|
|
10
|
+
|
|
11
|
+
WHEN TO CALL THIS TOOL:
|
|
12
|
+
- After provision() succeeded and you need the resulting API key
|
|
13
|
+
- When the user has authorized a credential and you need its value
|
|
14
|
+
- Every time you need to make an outbound call to a SaaS API on behalf
|
|
15
|
+
of the user
|
|
16
|
+
|
|
17
|
+
BEHAVIOR:
|
|
18
|
+
- Logs an audit event recording the purpose string — be specific
|
|
19
|
+
("calling Resend send-email API") so the user can review later
|
|
20
|
+
- Rate-limited per (account, agent_session) — don't poll
|
|
21
|
+
- Credentials are scoped to the user's account; cross-account access is rejected`;
|
|
22
|
+
export const getCredentialTool = {
|
|
23
|
+
name: "get_credential",
|
|
24
|
+
description: DESCRIPTION,
|
|
25
|
+
inputSchema,
|
|
26
|
+
jsonInputSchema: {
|
|
27
|
+
type: "object",
|
|
28
|
+
required: ["reference", "purpose"],
|
|
29
|
+
properties: {
|
|
30
|
+
reference: { type: "string" },
|
|
31
|
+
purpose: { type: "string", maxLength: 200 },
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
async handler(args, api) {
|
|
35
|
+
assertPaired(api);
|
|
36
|
+
const res = await api.getCredential(args.reference, args.purpose);
|
|
37
|
+
return {
|
|
38
|
+
value: res.value,
|
|
39
|
+
reference: res.reference,
|
|
40
|
+
retrieved_at: res.retrieved_at,
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=get-credential.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-credential.js","sourceRoot":"","sources":["../../src/tools/get-credential.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAa,MAAM,YAAY,CAAC;AAErD,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;CACpC,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG;;;;;;;;;;;;;;iFAc6D,CAAC;AAElF,MAAM,CAAC,MAAM,iBAAiB,GAAsC;IAClE,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,WAAW;IACxB,WAAW;IACX,eAAe,EAAE;QACf,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,CAAC,WAAW,EAAE,SAAS,CAAC;QAClC,UAAU,EAAE;YACV,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC7B,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE;SAC5C;KACF;IACD,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG;QACrB,YAAY,CAAC,GAAG,CAAC,CAAC;QAClB,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAClE,OAAO;YACL,KAAK,EAAE,GAAG,CAAC,KAAK;YAChB,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,YAAY,EAAE,GAAG,CAAC,YAAY;SAC/B,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type Tool } from "./index.js";
|
|
3
|
+
declare const inputSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
4
|
+
export declare const getUsageTool: Tool<z.infer<typeof inputSchema>>;
|
|
5
|
+
export {};
|
|
6
|
+
//# sourceMappingURL=get-usage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-usage.d.ts","sourceRoot":"","sources":["../../src/tools/get-usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAgB,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAErD,QAAA,MAAM,WAAW,gDAAe,CAAC;AAajC,eAAO,MAAM,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAS1D,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { assertPaired } from "./index.js";
|
|
3
|
+
const inputSchema = z.object({});
|
|
4
|
+
const DESCRIPTION = `Report the user's current spending vs their mandate budget. Lets the
|
|
5
|
+
coding agent answer questions like "how much have I spent on hosting
|
|
6
|
+
this month?" or "do I have room in my budget for another paid service?"
|
|
7
|
+
|
|
8
|
+
BEHAVIOR:
|
|
9
|
+
- Returns monthly spend, monthly budget, monthly remaining
|
|
10
|
+
- Returns daily spend and the daily silent-max threshold
|
|
11
|
+
- All values in cents
|
|
12
|
+
- Reflects the currently-active mandate; if the user just amended the
|
|
13
|
+
mandate, the numbers update immediately`;
|
|
14
|
+
export const getUsageTool = {
|
|
15
|
+
name: "get_usage",
|
|
16
|
+
description: DESCRIPTION,
|
|
17
|
+
inputSchema,
|
|
18
|
+
jsonInputSchema: { type: "object", properties: {} },
|
|
19
|
+
async handler(_args, api) {
|
|
20
|
+
assertPaired(api);
|
|
21
|
+
return api.getUsage();
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=get-usage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-usage.js","sourceRoot":"","sources":["../../src/tools/get-usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAa,MAAM,YAAY,CAAC;AAErD,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAEjC,MAAM,WAAW,GAAG;;;;;;;;;0CASsB,CAAC;AAE3C,MAAM,CAAC,MAAM,YAAY,GAAsC;IAC7D,IAAI,EAAE,WAAW;IACjB,WAAW,EAAE,WAAW;IACxB,WAAW;IACX,eAAe,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE;IACnD,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG;QACtB,YAAY,CAAC,GAAG,CAAC,CAAC;QAClB,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;IACxB,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z, type ZodTypeAny } from "zod";
|
|
2
|
+
import type { ApiClient } from "../api-client.js";
|
|
3
|
+
import { provisionTool } from "./provision.js";
|
|
4
|
+
import { waitForApprovalTool } from "./wait-for-approval.js";
|
|
5
|
+
import { getCredentialTool } from "./get-credential.js";
|
|
6
|
+
import { listServicesTool } from "./list-services.js";
|
|
7
|
+
import { listSubscriptionsTool } from "./list-subscriptions.js";
|
|
8
|
+
import { cancelTool } from "./cancel.js";
|
|
9
|
+
import { getUsageTool } from "./get-usage.js";
|
|
10
|
+
import { rotateCredentialTool } from "./rotate-credential.js";
|
|
11
|
+
export interface Tool<TArgs extends Record<string, unknown> = Record<string, unknown>> {
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
inputSchema: ZodTypeAny;
|
|
15
|
+
jsonInputSchema: Record<string, unknown>;
|
|
16
|
+
handler: (args: TArgs, api: ApiClient | null) => Promise<unknown>;
|
|
17
|
+
}
|
|
18
|
+
export declare function assertPaired(api: ApiClient | null): asserts api is ApiClient;
|
|
19
|
+
export declare const TOOLS: Tool[];
|
|
20
|
+
export declare function findTool(name: string): Tool | null;
|
|
21
|
+
export { z };
|
|
22
|
+
export { provisionTool, waitForApprovalTool, getCredentialTool, listServicesTool, listSubscriptionsTool, cancelTool, getUsageTool, rotateCredentialTool, };
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,CAAC,EAAE,KAAK,UAAU,EAAE,MAAM,KAAK,CAAC;AACzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAG9D,MAAM,WAAW,IAAI,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACnF,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,UAAU,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,OAAO,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,GAAG,IAAI,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CACnE;AAMD,wBAAgB,YAAY,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,GAAG,OAAO,CAAC,GAAG,IAAI,SAAS,CAI5E;AAED,eAAO,MAAM,KAAK,EAAE,IAAI,EAUb,CAAC;AAEZ,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAElD;AAGD,OAAO,EAAE,CAAC,EAAE,CAAC;AAIb,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,UAAU,EACV,YAAY,EACZ,oBAAoB,GACrB,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Tool registry for the MCP server. Each tool exports its name, the
|
|
2
|
+
// JSON-schema input shape, the verbatim description that the coding
|
|
3
|
+
// agent reads to decide when to call, and a `handler(args, api)` that
|
|
4
|
+
// returns a plain JSON response.
|
|
5
|
+
//
|
|
6
|
+
// Tools are pure functions of (args, api-client). The MCP `server.ts`
|
|
7
|
+
// wraps them with the SDK's request handler so they appear as
|
|
8
|
+
// callable tools over stdio. Tests skip the SDK and exercise handlers
|
|
9
|
+
// directly with a mock api-client.
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
import { provisionTool } from "./provision.js";
|
|
12
|
+
import { waitForApprovalTool } from "./wait-for-approval.js";
|
|
13
|
+
import { getCredentialTool } from "./get-credential.js";
|
|
14
|
+
import { listServicesTool } from "./list-services.js";
|
|
15
|
+
import { listSubscriptionsTool } from "./list-subscriptions.js";
|
|
16
|
+
import { cancelTool } from "./cancel.js";
|
|
17
|
+
import { getUsageTool } from "./get-usage.js";
|
|
18
|
+
import { rotateCredentialTool } from "./rotate-credential.js";
|
|
19
|
+
import { provisionAnyTool } from "./provision-any.js";
|
|
20
|
+
// Auth-requiring tools receive `api: ApiClient | null` per the registry
|
|
21
|
+
// contract; server.ts only invokes them after confirming a paired session.
|
|
22
|
+
// This assertion makes that invariant explicit so each handler narrows to a
|
|
23
|
+
// non-null ApiClient without repeating the guard.
|
|
24
|
+
export function assertPaired(api) {
|
|
25
|
+
if (api === null) {
|
|
26
|
+
throw new Error("This tool requires a paired (Tier 1+) session.");
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export const TOOLS = [
|
|
30
|
+
provisionAnyTool,
|
|
31
|
+
provisionTool,
|
|
32
|
+
waitForApprovalTool,
|
|
33
|
+
getCredentialTool,
|
|
34
|
+
listServicesTool,
|
|
35
|
+
listSubscriptionsTool,
|
|
36
|
+
cancelTool,
|
|
37
|
+
getUsageTool,
|
|
38
|
+
rotateCredentialTool,
|
|
39
|
+
];
|
|
40
|
+
export function findTool(name) {
|
|
41
|
+
return TOOLS.find((t) => t.name === name) ?? null;
|
|
42
|
+
}
|
|
43
|
+
// Re-export zod so tool files can `import { z } from "../tools/index.js"`.
|
|
44
|
+
export { z };
|
|
45
|
+
// Per-tool re-exports so callers (tests, custom integrations) can
|
|
46
|
+
// import a single tool without going through the TOOLS array.
|
|
47
|
+
export { provisionTool, waitForApprovalTool, getCredentialTool, listServicesTool, listSubscriptionsTool, cancelTool, getUsageTool, rotateCredentialTool, };
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,oEAAoE;AACpE,sEAAsE;AACtE,iCAAiC;AACjC,EAAE;AACF,sEAAsE;AACtE,8DAA8D;AAC9D,sEAAsE;AACtE,mCAAmC;AAEnC,OAAO,EAAE,CAAC,EAAmB,MAAM,KAAK,CAAC;AAEzC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAUtD,wEAAwE;AACxE,2EAA2E;AAC3E,4EAA4E;AAC5E,kDAAkD;AAClD,MAAM,UAAU,YAAY,CAAC,GAAqB;IAChD,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACpE,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,KAAK,GAAW;IAC3B,gBAAgB;IAChB,aAAa;IACb,mBAAmB;IACnB,iBAAiB;IACjB,gBAAgB;IAChB,qBAAqB;IACrB,UAAU;IACV,YAAY;IACZ,oBAAoB;CACX,CAAC;AAEZ,MAAM,UAAU,QAAQ,CAAC,IAAY;IACnC,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC;AACpD,CAAC;AAED,2EAA2E;AAC3E,OAAO,EAAE,CAAC,EAAE,CAAC;AAEb,kEAAkE;AAClE,8DAA8D;AAC9D,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,UAAU,EACV,YAAY,EACZ,oBAAoB,GACrB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type Tool } from "./index.js";
|
|
3
|
+
declare const inputSchema: z.ZodObject<{
|
|
4
|
+
category: z.ZodOptional<z.ZodString>;
|
|
5
|
+
query: z.ZodOptional<z.ZodString>;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
category?: string | undefined;
|
|
8
|
+
query?: string | undefined;
|
|
9
|
+
}, {
|
|
10
|
+
category?: string | undefined;
|
|
11
|
+
query?: string | undefined;
|
|
12
|
+
}>;
|
|
13
|
+
export declare const listServicesTool: Tool<z.infer<typeof inputSchema>>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=list-services.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-services.d.ts","sourceRoot":"","sources":["../../src/tools/list-services.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAgB,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAErD,QAAA,MAAM,WAAW;;;;;;;;;EAGf,CAAC;AAkBH,eAAO,MAAM,gBAAgB,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAmC9D,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { assertPaired } from "./index.js";
|
|
3
|
+
const inputSchema = z.object({
|
|
4
|
+
category: z.string().min(1).max(60).optional(),
|
|
5
|
+
query: z.string().min(1).max(120).optional(),
|
|
6
|
+
});
|
|
7
|
+
const DESCRIPTION = `List SaaS services that Trusty Squire knows how to provision automatically.
|
|
8
|
+
Returns the canonical service id, display name, category, and homepage
|
|
9
|
+
for each adapter, optionally filtered by category and/or text query.
|
|
10
|
+
|
|
11
|
+
WHEN TO CALL THIS TOOL:
|
|
12
|
+
- Before suggesting that the user "go sign up at example.com" — check if
|
|
13
|
+
there's a Squire adapter first
|
|
14
|
+
- When the user asks "what email service should we use?" or similar
|
|
15
|
+
- When you need to confirm a service is supported before calling provision()
|
|
16
|
+
|
|
17
|
+
BEHAVIOR:
|
|
18
|
+
- Returns the most-recently-published version of each non-disabled adapter
|
|
19
|
+
- Filter by category (e.g. "email", "monitoring") if you know it
|
|
20
|
+
- Filter by query (substring match against service id and display_name)
|
|
21
|
+
- Results are not ranked — present them to the user and let them choose`;
|
|
22
|
+
export const listServicesTool = {
|
|
23
|
+
name: "list_services",
|
|
24
|
+
description: DESCRIPTION,
|
|
25
|
+
inputSchema,
|
|
26
|
+
jsonInputSchema: {
|
|
27
|
+
type: "object",
|
|
28
|
+
properties: {
|
|
29
|
+
category: { type: "string" },
|
|
30
|
+
query: { type: "string" },
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
async handler(args, api) {
|
|
34
|
+
assertPaired(api);
|
|
35
|
+
const directory = await api.listServices(args.category);
|
|
36
|
+
let entries = directory.adapters;
|
|
37
|
+
if (args.query !== undefined) {
|
|
38
|
+
const q = args.query.toLowerCase();
|
|
39
|
+
entries = entries.filter((a) => a.service.toLowerCase().includes(q) ||
|
|
40
|
+
a.display_name.toLowerCase().includes(q) ||
|
|
41
|
+
(a.description?.toLowerCase().includes(q) ?? false));
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
services: entries.map((a) => ({
|
|
45
|
+
service: a.service,
|
|
46
|
+
version: a.latest_version,
|
|
47
|
+
display_name: a.display_name,
|
|
48
|
+
category: a.category,
|
|
49
|
+
homepage: a.homepage,
|
|
50
|
+
description: a.description,
|
|
51
|
+
})),
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=list-services.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-services.js","sourceRoot":"","sources":["../../src/tools/list-services.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAa,MAAM,YAAY,CAAC;AAErD,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;IAC9C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;CAC7C,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG;;;;;;;;;;;;;;wEAcoD,CAAC;AAEzE,MAAM,CAAC,MAAM,gBAAgB,GAAsC;IACjE,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,WAAW;IACxB,WAAW;IACX,eAAe,EAAE;QACf,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC5B,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;SAC1B;KACF;IACD,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG;QACrB,YAAY,CAAC,GAAG,CAAC,CAAC;QAClB,MAAM,SAAS,GAAG,MAAM,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACxD,IAAI,OAAO,GAAG,SAAS,CAAC,QAAQ,CAAC;QACjC,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC7B,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;YACnC,OAAO,GAAG,OAAO,CAAC,MAAM,CACtB,CAAC,CAAC,EAAE,EAAE,CACJ,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;gBACnC,CAAC,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;gBACxC,CAAC,CAAC,CAAC,WAAW,EAAE,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CACtD,CAAC;QACJ,CAAC;QACD,OAAO;YACL,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBAC5B,OAAO,EAAE,CAAC,CAAC,OAAO;gBAClB,OAAO,EAAE,CAAC,CAAC,cAAc;gBACzB,YAAY,EAAE,CAAC,CAAC,YAAY;gBAC5B,QAAQ,EAAE,CAAC,CAAC,QAAQ;gBACpB,QAAQ,EAAE,CAAC,CAAC,QAAQ;gBACpB,WAAW,EAAE,CAAC,CAAC,WAAW;aAC3B,CAAC,CAAC;SACJ,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type Tool } from "./index.js";
|
|
3
|
+
declare const inputSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
4
|
+
export declare const listSubscriptionsTool: Tool<z.infer<typeof inputSchema>>;
|
|
5
|
+
export {};
|
|
6
|
+
//# sourceMappingURL=list-subscriptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-subscriptions.d.ts","sourceRoot":"","sources":["../../src/tools/list-subscriptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAgB,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAErD,QAAA,MAAM,WAAW,gDAAe,CAAC;AAcjC,eAAO,MAAM,qBAAqB,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CASnE,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { assertPaired } from "./index.js";
|
|
3
|
+
const inputSchema = z.object({});
|
|
4
|
+
const DESCRIPTION = `List the user's active subscriptions across all services. Useful
|
|
5
|
+
when the user asks "what am I paying for?" or to find an existing
|
|
6
|
+
subscription before provisioning a duplicate.
|
|
7
|
+
|
|
8
|
+
BEHAVIOR:
|
|
9
|
+
- Returns subscriptions in any non-cancelled state
|
|
10
|
+
- Includes service, plan, project_name, monthly cost (if any),
|
|
11
|
+
and the run_id that created the subscription
|
|
12
|
+
- Idempotency means a re-provision of the same service+project_name
|
|
13
|
+
returns the existing subscription rather than creating a new one;
|
|
14
|
+
use this tool to check what's already in place first`;
|
|
15
|
+
export const listSubscriptionsTool = {
|
|
16
|
+
name: "list_subscriptions",
|
|
17
|
+
description: DESCRIPTION,
|
|
18
|
+
inputSchema,
|
|
19
|
+
jsonInputSchema: { type: "object", properties: {} },
|
|
20
|
+
async handler(_args, api) {
|
|
21
|
+
assertPaired(api);
|
|
22
|
+
return api.listSubscriptions();
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=list-subscriptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-subscriptions.js","sourceRoot":"","sources":["../../src/tools/list-subscriptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAa,MAAM,YAAY,CAAC;AAErD,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAEjC,MAAM,WAAW,GAAG;;;;;;;;;;uDAUmC,CAAC;AAExD,MAAM,CAAC,MAAM,qBAAqB,GAAsC;IACtE,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EAAE,WAAW;IACxB,WAAW;IACX,eAAe,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE;IACnD,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG;QACtB,YAAY,CAAC,GAAG,CAAC,CAAC;QAClB,OAAO,GAAG,CAAC,iBAAiB,EAAE,CAAC;IACjC,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { ApiClient } from "../api-client.js";
|
|
3
|
+
export declare const provisionAnyInputSchema: z.ZodObject<{
|
|
4
|
+
service: z.ZodString;
|
|
5
|
+
signup_url: z.ZodOptional<z.ZodString>;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
service: string;
|
|
8
|
+
signup_url?: string | undefined;
|
|
9
|
+
}, {
|
|
10
|
+
service: string;
|
|
11
|
+
signup_url?: string | undefined;
|
|
12
|
+
}>;
|
|
13
|
+
export type ProvisionAnyInput = z.infer<typeof provisionAnyInputSchema>;
|
|
14
|
+
export declare const provisionAnyTool: {
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
jsonInputSchema: {
|
|
18
|
+
readonly type: "object";
|
|
19
|
+
readonly required: readonly ["service"];
|
|
20
|
+
readonly properties: {
|
|
21
|
+
readonly service: {
|
|
22
|
+
readonly type: "string";
|
|
23
|
+
readonly description: "Name of the service to sign up for (e.g., 'Postmark', 'Mailgun', 'IPInfo')";
|
|
24
|
+
};
|
|
25
|
+
readonly signup_url: {
|
|
26
|
+
readonly type: "string";
|
|
27
|
+
readonly description: "Direct URL to the service's signup page. Optional — the bot will navigate from the service name if omitted.";
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
inputSchema: z.ZodObject<{
|
|
32
|
+
service: z.ZodString;
|
|
33
|
+
signup_url: z.ZodOptional<z.ZodString>;
|
|
34
|
+
}, "strip", z.ZodTypeAny, {
|
|
35
|
+
service: string;
|
|
36
|
+
signup_url?: string | undefined;
|
|
37
|
+
}, {
|
|
38
|
+
service: string;
|
|
39
|
+
signup_url?: string | undefined;
|
|
40
|
+
}>;
|
|
41
|
+
handler: (input: ProvisionAnyInput, _api: ApiClient | null) => Promise<{
|
|
42
|
+
status: string;
|
|
43
|
+
message: string;
|
|
44
|
+
service?: never;
|
|
45
|
+
quota_limit?: never;
|
|
46
|
+
quota_used?: never;
|
|
47
|
+
cta_pair_url?: never;
|
|
48
|
+
error?: never;
|
|
49
|
+
credentials?: never;
|
|
50
|
+
steps?: never;
|
|
51
|
+
captcha_kind?: never;
|
|
52
|
+
browser_channel?: never;
|
|
53
|
+
} | {
|
|
54
|
+
status: string;
|
|
55
|
+
service: string;
|
|
56
|
+
quota_limit: unknown;
|
|
57
|
+
quota_used: unknown;
|
|
58
|
+
cta_pair_url: unknown;
|
|
59
|
+
message: string;
|
|
60
|
+
error?: never;
|
|
61
|
+
credentials?: never;
|
|
62
|
+
steps?: never;
|
|
63
|
+
captcha_kind?: never;
|
|
64
|
+
browser_channel?: never;
|
|
65
|
+
} | {
|
|
66
|
+
status: string;
|
|
67
|
+
service: string;
|
|
68
|
+
error: string;
|
|
69
|
+
message: string;
|
|
70
|
+
quota_limit?: never;
|
|
71
|
+
quota_used?: never;
|
|
72
|
+
cta_pair_url?: never;
|
|
73
|
+
credentials?: never;
|
|
74
|
+
steps?: never;
|
|
75
|
+
captcha_kind?: never;
|
|
76
|
+
browser_channel?: never;
|
|
77
|
+
} | {
|
|
78
|
+
status: string;
|
|
79
|
+
service: string;
|
|
80
|
+
credentials: {
|
|
81
|
+
[key: string]: string | undefined;
|
|
82
|
+
api_key?: string;
|
|
83
|
+
username?: string;
|
|
84
|
+
password?: string;
|
|
85
|
+
};
|
|
86
|
+
steps: string[];
|
|
87
|
+
message: string;
|
|
88
|
+
quota_limit?: never;
|
|
89
|
+
quota_used?: never;
|
|
90
|
+
cta_pair_url?: never;
|
|
91
|
+
error?: never;
|
|
92
|
+
captcha_kind?: never;
|
|
93
|
+
browser_channel?: never;
|
|
94
|
+
} | {
|
|
95
|
+
status: string;
|
|
96
|
+
service: string;
|
|
97
|
+
error: string;
|
|
98
|
+
steps: string[];
|
|
99
|
+
captcha_kind: "turnstile" | "recaptcha";
|
|
100
|
+
browser_channel: string | null;
|
|
101
|
+
message: string;
|
|
102
|
+
quota_limit?: never;
|
|
103
|
+
quota_used?: never;
|
|
104
|
+
cta_pair_url?: never;
|
|
105
|
+
credentials?: never;
|
|
106
|
+
} | {
|
|
107
|
+
status: string;
|
|
108
|
+
service: string;
|
|
109
|
+
error: string;
|
|
110
|
+
steps: string[];
|
|
111
|
+
browser_channel: string | null;
|
|
112
|
+
message: string;
|
|
113
|
+
quota_limit?: never;
|
|
114
|
+
quota_used?: never;
|
|
115
|
+
cta_pair_url?: never;
|
|
116
|
+
credentials?: never;
|
|
117
|
+
captcha_kind?: never;
|
|
118
|
+
}>;
|
|
119
|
+
};
|
|
120
|
+
//# sourceMappingURL=provision-any.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provision-any.d.ts","sourceRoot":"","sources":["../../src/tools/provision-any.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AASxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,eAAO,MAAM,uBAAuB;;;;;;;;;EAGlC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AA2CxE,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAKJ,iBAAiB,QAAQ,SAAS,GAAG,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4JjE,CAAC"}
|