@deeprelay/mcp 0.0.1 → 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.
Files changed (77) hide show
  1. package/README.md +188 -1
  2. package/dist/auth.d.ts +52 -0
  3. package/dist/auth.js +122 -0
  4. package/dist/auth.js.map +1 -0
  5. package/dist/errors.d.ts +83 -0
  6. package/dist/errors.js +307 -0
  7. package/dist/errors.js.map +1 -0
  8. package/dist/guardrail/budget.d.ts +95 -0
  9. package/dist/guardrail/budget.js +225 -0
  10. package/dist/guardrail/budget.js.map +1 -0
  11. package/dist/guardrail/elicitation.d.ts +12 -0
  12. package/dist/guardrail/elicitation.js +79 -0
  13. package/dist/guardrail/elicitation.js.map +1 -0
  14. package/dist/guardrail/estimate.d.ts +67 -0
  15. package/dist/guardrail/estimate.js +171 -0
  16. package/dist/guardrail/estimate.js.map +1 -0
  17. package/dist/guardrail/handshake.d.ts +32 -0
  18. package/dist/guardrail/handshake.js +164 -0
  19. package/dist/guardrail/handshake.js.map +1 -0
  20. package/dist/guardrail/types.d.ts +61 -0
  21. package/dist/guardrail/types.js +10 -0
  22. package/dist/guardrail/types.js.map +1 -0
  23. package/dist/index.d.ts +18 -0
  24. package/dist/index.js +61 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/roster.d.ts +36 -0
  27. package/dist/roster.js +130 -0
  28. package/dist/roster.js.map +1 -0
  29. package/dist/tools/crypto-deposit-gate.d.ts +21 -0
  30. package/dist/tools/crypto-deposit-gate.js +91 -0
  31. package/dist/tools/crypto-deposit-gate.js.map +1 -0
  32. package/dist/tools/index.d.ts +16 -0
  33. package/dist/tools/index.js +108 -0
  34. package/dist/tools/index.js.map +1 -0
  35. package/dist/tools/readonly/define.d.ts +32 -0
  36. package/dist/tools/readonly/define.js +64 -0
  37. package/dist/tools/readonly/define.js.map +1 -0
  38. package/dist/tools/readonly/index.d.ts +7 -0
  39. package/dist/tools/readonly/index.js +292 -0
  40. package/dist/tools/readonly/index.js.map +1 -0
  41. package/dist/tools/readonly/video-reads.d.ts +11 -0
  42. package/dist/tools/readonly/video-reads.js +170 -0
  43. package/dist/tools/readonly/video-reads.js.map +1 -0
  44. package/dist/tools/result.d.ts +22 -0
  45. package/dist/tools/result.js +63 -0
  46. package/dist/tools/result.js.map +1 -0
  47. package/dist/tools/spend/define.d.ts +93 -0
  48. package/dist/tools/spend/define.js +286 -0
  49. package/dist/tools/spend/define.js.map +1 -0
  50. package/dist/tools/spend/index.d.ts +11 -0
  51. package/dist/tools/spend/index.js +163 -0
  52. package/dist/tools/spend/index.js.map +1 -0
  53. package/dist/tools/spend/media.d.ts +9 -0
  54. package/dist/tools/spend/media.js +164 -0
  55. package/dist/tools/spend/media.js.map +1 -0
  56. package/dist/tools/spend/pricing.d.ts +17 -0
  57. package/dist/tools/spend/pricing.js +58 -0
  58. package/dist/tools/spend/pricing.js.map +1 -0
  59. package/dist/tools/types.d.ts +45 -0
  60. package/dist/tools/types.js +3 -0
  61. package/dist/tools/types.js.map +1 -0
  62. package/dist/tools/write/define.d.ts +60 -0
  63. package/dist/tools/write/define.js +110 -0
  64. package/dist/tools/write/define.js.map +1 -0
  65. package/dist/tools/write/index.d.ts +12 -0
  66. package/dist/tools/write/index.js +159 -0
  67. package/dist/tools/write/index.js.map +1 -0
  68. package/dist/tools/write/payment-links.d.ts +3 -0
  69. package/dist/tools/write/payment-links.js +161 -0
  70. package/dist/tools/write/payment-links.js.map +1 -0
  71. package/dist/tools/write/spending-limit.d.ts +2 -0
  72. package/dist/tools/write/spending-limit.js +229 -0
  73. package/dist/tools/write/spending-limit.js.map +1 -0
  74. package/dist/version.d.ts +3 -0
  75. package/dist/version.js +36 -0
  76. package/dist/version.js.map +1 -0
  77. package/package.json +39 -3
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mediaSpendTools = exports.VIDEO_FLOOR_NOTE = exports.VIDEO_MAX_SECONDS = exports.IMAGE_MAX_COUNT = void 0;
4
+ exports.imageMimeType = imageMimeType;
5
+ // Image generation and video create: the media half of the spend tier
6
+ // (Phase 104, D-02/D-06/D-07). Both go through defineSpendTool, so they share
7
+ // the one session budget, the per-call ceiling and the confirmation handshake
8
+ // with chat and embeddings.
9
+ //
10
+ // Image is synchronous: reserve, generate, settle at the actual image count.
11
+ // Its result is native MCP image content (one block per image) followed by one
12
+ // text block with usage and cost. ok() only builds text, so the execute step
13
+ // returns a prebuilt ToolResult, which the dispatch passes through unchanged;
14
+ // the text block is still built by ok() (sanitized and redacted).
15
+ //
16
+ // Video is asynchronous (RESEARCH Pitfall 2). The create call returns a queued
17
+ // job with no cost, so this handler reserves the catalog from-price (a FLOOR)
18
+ // under the returned job id and does not settle anything itself. The video
19
+ // reads (readonly/video-reads.ts) settle the reservation when they observe the
20
+ // job finished: at cost_cents on completion, released on failed, cancelled or
21
+ // expired.
22
+ //
23
+ // Both media calls send an Idempotency-Key header (RESEARCH Pitfall 3): the
24
+ // confirmation token when the call was confirmed, else the per-call id, so a
25
+ // transport retry cannot charge twice (T-104-29).
26
+ const sdk_1 = require("@deeprelay/sdk");
27
+ const zod_1 = require("zod");
28
+ const budget_js_1 = require("../../guardrail/budget.js");
29
+ const estimate_js_1 = require("../../guardrail/estimate.js");
30
+ const result_js_1 = require("../result.js");
31
+ const define_js_1 = require("./define.js");
32
+ /** "WxH", e.g. 1024x1024. */
33
+ const SIZE_PATTERN = /^\d{2,4}x\d{2,4}$/;
34
+ exports.IMAGE_MAX_COUNT = 4;
35
+ exports.VIDEO_MAX_SECONDS = 30;
36
+ /** The floor wording every video quote carries (D-07). */
37
+ exports.VIDEO_FLOOR_NOTE = "This is a floor, not a cap — the final charge is known when the job completes.";
38
+ /** The image's MIME type from its base64 signature; PNG when unrecognized. */
39
+ function imageMimeType(b64) {
40
+ if (b64.startsWith("/9j/"))
41
+ return "image/jpeg";
42
+ if (b64.startsWith("UklGR"))
43
+ return "image/webp";
44
+ if (b64.startsWith("R0lGOD"))
45
+ return "image/gif";
46
+ return "image/png";
47
+ }
48
+ const imagesGenerate = (0, define_js_1.defineSpendTool)({
49
+ name: "deeprelay_images_generate",
50
+ title: "Generate images",
51
+ description: "Generate 1–4 images from a text prompt with a deeprelay image model and return them as image content, " +
52
+ "with usage and cost. Priced per image, or per megapixel of the requested size, from the model's catalog " +
53
+ "rate; the session budget settles at the number of images actually returned. Use deeprelay_models_list " +
54
+ "(modality image) to find a model id.",
55
+ inputSchema: {
56
+ model: zod_1.z.string().min(1).describe("An image model id from deeprelay_models_list."),
57
+ prompt: zod_1.z.string().min(1).max(4000).describe("What to draw (up to 4000 characters)."),
58
+ n: zod_1.z
59
+ .number()
60
+ .int()
61
+ .min(1)
62
+ .max(exports.IMAGE_MAX_COUNT)
63
+ .default(1)
64
+ .describe(`How many images (1–${exports.IMAGE_MAX_COUNT}, default 1). Each one is billed.`),
65
+ size: zod_1.z
66
+ .string()
67
+ .regex(SIZE_PATTERN)
68
+ .optional()
69
+ .describe("Output size as WIDTHxHEIGHT, e.g. 1024x1024. Per-megapixel models price by it."),
70
+ },
71
+ modality: "image",
72
+ question: "Generate these images at the price shown?",
73
+ context: "generating images",
74
+ describe: (a) => `Generate ${a.n} image(s) on ${a.model}${a.size !== undefined ? ` at ${a.size}` : ""}`,
75
+ async execute(a, run) {
76
+ (0, budget_js_1.recordEstimate)(run.callId, run.estimate.microCents);
77
+ let res;
78
+ let actual;
79
+ try {
80
+ res = await new sdk_1.InferenceApi(run.config).createImage({
81
+ imagesGenerationsRequest: { model: a.model, prompt: a.prompt, n: a.n, size: a.size, responseFormat: "b64_json" },
82
+ idempotencyKey: run.idempotencyKey,
83
+ });
84
+ actual = (0, estimate_js_1.actualMicroCents)("image", res.usage, run.rates, run.estimate.microCents, { size: a.size });
85
+ (0, budget_js_1.reconcileActual)(run.callId, actual);
86
+ }
87
+ catch (err) {
88
+ (0, budget_js_1.releaseEstimate)(run.callId);
89
+ throw err;
90
+ }
91
+ const images = (res.data ?? [])
92
+ .filter((d) => typeof d.b64Json === "string" && d.b64Json !== "")
93
+ .map((d) => ({ type: "image", data: d.b64Json, mimeType: imageMimeType(d.b64Json) }));
94
+ const summary = (0, result_js_1.ok)({
95
+ lead: `Generated ${images.length} image(s).`,
96
+ model: a.model,
97
+ count: images.length,
98
+ usage: { image_count: res.usage?.imageCount },
99
+ cost: { estimated_micro_cents: run.estimate.microCents, actual_micro_cents: actual },
100
+ session_budget: (0, budget_js_1.budgetStatus)(),
101
+ }, { env: run.env });
102
+ return { content: [...images, ...summary.content] };
103
+ },
104
+ });
105
+ // Keep this definition last in the file: a test scans from here to the end
106
+ // and asserts the video path contains no settlement call.
107
+ const videosCreate = (0, define_js_1.defineSpendTool)({
108
+ name: "deeprelay_videos_create",
109
+ title: "Create a video",
110
+ description: "Start an asynchronous text-to-video job on a deeprelay video model. Priced from the catalog's per-clip " +
111
+ "from-price, or per second of the requested length; the quote is a floor, not a cap, and the real charge " +
112
+ "is known only when the job completes. The floor is held against the session budget until " +
113
+ "deeprelay_videos_get or deeprelay_videos_list sees the job finish, which settles it at the actual cost " +
114
+ "(or releases it if the job failed or was cancelled). Download a finished clip with deeprelay_videos_content.",
115
+ inputSchema: {
116
+ model: zod_1.z.string().min(1).describe("A video model id from deeprelay_models_list."),
117
+ prompt: zod_1.z.string().min(1).max(4000).describe("What the clip should show (up to 4000 characters)."),
118
+ seconds: zod_1.z
119
+ .number()
120
+ .int()
121
+ .min(1)
122
+ .max(exports.VIDEO_MAX_SECONDS)
123
+ .optional()
124
+ .describe(`Clip length in seconds (1–${exports.VIDEO_MAX_SECONDS}). Per-second models price by it.`),
125
+ size: zod_1.z.string().regex(SIZE_PATTERN).optional().describe("Output size as WIDTHxHEIGHT, e.g. 1280x720."),
126
+ },
127
+ modality: "video",
128
+ question: "Start this video job at the floor price shown?",
129
+ context: "creating a video job",
130
+ quoteNote: exports.VIDEO_FLOOR_NOTE,
131
+ describe: (a) => `Start a video job on ${a.model}${a.seconds !== undefined ? ` for ${a.seconds}s` : ""}${a.size !== undefined ? ` at ${a.size}` : ""}`,
132
+ async execute(a, run) {
133
+ // Hold the floor while the create call is in flight, so a parallel call
134
+ // cannot spend the same headroom.
135
+ (0, budget_js_1.recordEstimate)(run.callId, run.estimate.microCents);
136
+ let job;
137
+ try {
138
+ job = await new sdk_1.InferenceApi(run.config).createVideo({
139
+ videoCreateRequest: { model: a.model, prompt: a.prompt, seconds: a.seconds, size: a.size },
140
+ idempotencyKey: run.idempotencyKey,
141
+ });
142
+ }
143
+ catch (err) {
144
+ (0, budget_js_1.releaseEstimate)(run.callId);
145
+ throw err;
146
+ }
147
+ // Keyed by the real job id; a video read settles it.
148
+ (0, budget_js_1.registerPendingVideo)(job.id, run.callId, run.estimate.microCents);
149
+ return {
150
+ lead: `Video job ${job.id} queued. Call deeprelay_videos_get to poll; the session budget settles when it completes.`,
151
+ payload: {
152
+ video_id: job.id,
153
+ status: job.status,
154
+ model: job.model ?? a.model,
155
+ seconds: job.seconds ?? a.seconds ?? null,
156
+ floor_micro_cents: run.estimate.microCents,
157
+ session_budget: (0, budget_js_1.budgetStatus)(),
158
+ },
159
+ };
160
+ },
161
+ });
162
+ /** Image then video, in SPEND_TOOLS order. */
163
+ exports.mediaSpendTools = [imagesGenerate, videosCreate];
164
+ //# sourceMappingURL=media.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media.js","sourceRoot":"","sources":["../../../src/tools/spend/media.ts"],"names":[],"mappings":";;;AA8CA,sCAKC;AAnDD,sEAAsE;AACtE,8EAA8E;AAC9E,8EAA8E;AAC9E,4BAA4B;AAC5B,EAAE;AACF,6EAA6E;AAC7E,+EAA+E;AAC/E,6EAA6E;AAC7E,8EAA8E;AAC9E,kEAAkE;AAClE,EAAE;AACF,+EAA+E;AAC/E,8EAA8E;AAC9E,2EAA2E;AAC3E,+EAA+E;AAC/E,8EAA8E;AAC9E,WAAW;AACX,EAAE;AACF,4EAA4E;AAC5E,6EAA6E;AAC7E,kDA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G,GAAG,MAAM,IAAI,kBAAY,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC;gBACnD,kBAAkB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE;gBAC1F,cAAc,EAAE,GAAG,CAAC,cAAc;aACnC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAA,2BAAe,EAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAC5B,MAAM,GAAG,CAAC;QACZ,CAAC;QACD,qDAAqD;QACrD,IAAA,gCAAoB,EAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAClE,OAAO;YACL,IAAI,EAAE,aAAa,GAAG,CAAC,EAAE,2FAA2F;YACpH,OAAO,EAAE;gBACP,QAAQ,EAAE,GAAG,CAAC,EAAE;gBAChB,MAAM,EAAE,GAAG,CAAC,MAAM;gBAClB,KAAK,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK;gBAC3B,OAAO,EAAE,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,IAAI,IAAI;gBACzC,iBAAiB,EAAE,GAAG,CAAC,QAAQ,CAAC,UAAU;gBAC1C,cAAc,EAAE,IAAA,wBAAY,GAAE;aAC/B;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC;AAEH,8CAA8C;AACjC,QAAA,eAAe,GAAqB,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { type Configuration, type ModelModalityEnum } from "@deeprelay/sdk";
2
+ import type { PricingLike } from "../../guardrail/estimate.js";
3
+ /** How long one model's rates are reused before the catalog is read again. */
4
+ export declare const RATE_CACHE_TTL_MS: number;
5
+ /** A model's rates plus the two catalog facts the spend tier checks against. */
6
+ export interface ModelRates extends PricingLike {
7
+ modelId: string;
8
+ /** The catalog modality (chat | embedding | image | video), when published. */
9
+ modality?: ModelModalityEnum;
10
+ }
11
+ /** Test-only: forget every cached rate. */
12
+ export declare function resetPricingCacheForTests(): void;
13
+ /**
14
+ * The model's current rates. The cache is keyed by base URL as well as model
15
+ * id, so a demo override and production never share an entry.
16
+ */
17
+ export declare function ratesFor(config: Configuration, modelId: string, now?: () => number): Promise<ModelRates>;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RATE_CACHE_TTL_MS = void 0;
4
+ exports.resetPricingCacheForTests = resetPricingCacheForTests;
5
+ exports.ratesFor = ratesFor;
6
+ // Catalog rates for the spend tier (Phase 104, D-06). Authored fresh (D-12).
7
+ //
8
+ // Every spend quote prices the call from the model's own catalog entry
9
+ // (InferenceApi.getModel), never from a hard-coded table, so a price change on
10
+ // the platform reaches the next quote without a release. The result is cached
11
+ // per process for RATE_CACHE_TTL_MS: a quote followed by its confirming call a
12
+ // few seconds later should not fetch the catalog twice, and a stale rate lasts
13
+ // at most ten minutes.
14
+ //
15
+ // An unknown model is not handled here: the SDK's 404 propagates to the tool's
16
+ // error funnel (errors.ts), which names it as "not found" without a quote and
17
+ // without minting a token.
18
+ const sdk_1 = require("@deeprelay/sdk");
19
+ const budget_js_1 = require("../../guardrail/budget.js");
20
+ /** How long one model's rates are reused before the catalog is read again. */
21
+ exports.RATE_CACHE_TTL_MS = 10 * 60 * 1000;
22
+ const cache = new Map();
23
+ /** Test-only: forget every cached rate. */
24
+ function resetPricingCacheForTests() {
25
+ cache.clear();
26
+ }
27
+ function pick(value) {
28
+ return typeof value === "number" && Number.isFinite(value) ? value : undefined;
29
+ }
30
+ /**
31
+ * The model's current rates. The cache is keyed by base URL as well as model
32
+ * id, so a demo override and production never share an entry.
33
+ */
34
+ async function ratesFor(config, modelId, now = Date.now) {
35
+ const key = `${config.basePath}\u0000${modelId}`;
36
+ const hit = cache.get(key);
37
+ if (hit !== undefined && hit.expiresAt > now()) {
38
+ return hit.rates;
39
+ }
40
+ const model = await new sdk_1.InferenceApi(config).getModel({ id: modelId });
41
+ const p = model.pricing ?? {};
42
+ const rates = {
43
+ modelId: model.id ?? modelId,
44
+ modality: model.modality,
45
+ inputPer1mTokensCents: pick(p.inputPer1mTokensCents),
46
+ outputPer1mTokensCents: pick(p.outputPer1mTokensCents),
47
+ cachedInputPer1mTokensMicrocents: pick(p.cachedInputPer1mTokensMicrocents),
48
+ perImageCents: pick(p.perImageCents),
49
+ perImageMicrocents: pick(p.perImageMicrocents),
50
+ perMpxlMicrocents: pick(p.perMpxlMicrocents),
51
+ perVideoMicrocents: pick(p.perVideoMicrocents),
52
+ perVideoSecondMicrocents: pick(p.perVideoSecondMicrocents) ??
53
+ (pick(p.perVideoSecondCents) === undefined ? undefined : p.perVideoSecondCents * budget_js_1.MICRO_CENTS_PER_CENT),
54
+ };
55
+ cache.set(key, { rates, expiresAt: now() + exports.RATE_CACHE_TTL_MS });
56
+ return rates;
57
+ }
58
+ //# sourceMappingURL=pricing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pricing.js","sourceRoot":"","sources":["../../../src/tools/spend/pricing.ts"],"names":[],"mappings":";;;AAmCA,8DAEC;AAUD,4BA6BC;AA5ED,6EAA6E;AAC7E,EAAE;AACF,uEAAuE;AACvE,+EAA+E;AAC/E,8EAA8E;AAC9E,+EAA+E;AAC/E,+EAA+E;AAC/E,uBAAuB;AACvB,EAAE;AACF,+EAA+E;AAC/E,8EAA8E;AAC9E,2BAA2B;AAC3B,wCAA0F;AAE1F,yDAAiE;AAGjE,8EAA8E;AACjE,QAAA,iBAAiB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAchD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAsB,CAAC;AAE5C,2CAA2C;AAC3C,SAAgB,yBAAyB;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B,CAAC;QAC5C,kBAAkB,EAAE,IAAI,CAAC,CAAC,CAAC,kBAAkB,CAAC;QAC9C,wBAAwB,EACtB,IAAI,CAAC,CAAC,CAAC,wBAAwB,CAAC;YAChC,CAAC,IAAI,CAAC,CAAC,CAAC,mBAAmB,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAE,CAAC,CAAC,mBAA8B,GAAG,gCAAoB,CAAC;KACrH,CAAC;IACF,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,yBAAiB,EAAE,CAAC,CAAC;IAChE,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,45 @@
1
+ import type { ZodRawShape } from "zod";
2
+ import type { ElicitationHost } from "../guardrail/types.js";
3
+ import type { ToolName } from "../roster.js";
4
+ /** Process environment view (the DEEPRELAY_API_KEY / base-URL override source). */
5
+ export type Env = Record<string, string | undefined>;
6
+ export type ToolTier = "read" | "write" | "spend";
7
+ export type ToolContent = {
8
+ type: "text";
9
+ text: string;
10
+ } | {
11
+ type: "image";
12
+ data: string;
13
+ mimeType: string;
14
+ };
15
+ /** Compatible with MCP's CallToolResult. */
16
+ export interface ToolResult {
17
+ content: ToolContent[];
18
+ isError?: boolean;
19
+ [key: string]: unknown;
20
+ }
21
+ /** Per-call context the registration door threads into a handler. */
22
+ export interface ToolContext {
23
+ env?: Env;
24
+ /** Present only when the server can reach the client's elicitation surface. */
25
+ elicitation?: ElicitationHost;
26
+ }
27
+ /** MCP ToolAnnotations. All four hints are always set explicitly. */
28
+ export interface ToolAnnotations {
29
+ readOnlyHint: boolean;
30
+ destructiveHint: boolean;
31
+ idempotentHint: boolean;
32
+ openWorldHint: boolean;
33
+ }
34
+ export interface ToolDefinition {
35
+ name: ToolName;
36
+ tier: ToolTier;
37
+ title: string;
38
+ /** Hand-authored and written for the agent (Phase 80 D-14 reasoning). */
39
+ description: string;
40
+ inputSchema: ZodRawShape;
41
+ annotations: ToolAnnotations;
42
+ /** See the file header. False for deeprelay_deposits_create_crypto only. */
43
+ enabledAtBoot: boolean;
44
+ handler(args: Record<string, unknown>, ctx?: ToolContext): Promise<ToolResult>;
45
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,60 @@
1
+ import type { Configuration } from "@deeprelay/sdk";
2
+ import { z, type ZodRawShape } from "zod";
3
+ import type { Quote } from "../../guardrail/types.js";
4
+ import type { WriteToolName } from "../../roster.js";
5
+ import type { Env, ToolDefinition } from "../types.js";
6
+ /** Appended to every write description. The tier's contract, stated to the agent. */
7
+ export declare const WRITE_TIER_SENTENCE: string;
8
+ /** The one extra argument every write tool accepts. */
9
+ export declare const CONFIRMATION_TOKEN_SHAPE: {
10
+ confirmation_token: z.ZodOptional<z.ZodString>;
11
+ };
12
+ /** A quote whose resolvedParams are typed for the tool's execute step. */
13
+ export interface WriteQuote<R> extends Omit<Quote, "resolvedParams" | "estimateMicroCents" | "isFloor"> {
14
+ resolvedParams: R;
15
+ }
16
+ /** What a write's execute step returns. */
17
+ export interface WriteExecuted {
18
+ /** One sentence the agent can relay as-is. */
19
+ lead: string;
20
+ /** Sanitized before it reaches the agent. */
21
+ payload: unknown;
22
+ /** One-time reveal, merged AFTER sanitization. Only webhook create sets it. */
23
+ revealOnce?: Record<string, string>;
24
+ }
25
+ /**
26
+ * Thrown from a write's quote or execute when the requested change is already
27
+ * true, e.g. clearing a spending limit on an account that has none. The
28
+ * factory returns `executed` as an ordinary result, not an error: the agent
29
+ * should report "nothing to do", not retry or apologise for a failure. Thrown
30
+ * from quote it mints no token, so nothing is left behind to confirm.
31
+ */
32
+ export declare class WriteNothingToDo extends Error {
33
+ readonly executed: WriteExecuted;
34
+ constructor(executed: WriteExecuted);
35
+ }
36
+ export interface WriteToolSpec<Shape extends ZodRawShape, R extends Record<string, unknown>> {
37
+ name: WriteToolName;
38
+ title: string;
39
+ /** Agent-shaped. The tier sentence is appended automatically. */
40
+ description: string;
41
+ inputSchema: Shape;
42
+ /** True for delete/cancel: the change cannot be undone. */
43
+ destructive: boolean;
44
+ /** Only deeprelay_deposits_create_crypto sets this to false (D-03). */
45
+ enabledAtBoot?: boolean;
46
+ /** The yes/no question put to the user through elicitation. */
47
+ question: string | ((args: z.infer<z.ZodObject<Shape>>) => string);
48
+ /** What was being attempted, for error messages ("creating a webhook endpoint"). */
49
+ context: string;
50
+ /**
51
+ * Describe the change. Throwing (e.g. QuoteUnavailableError) mints no token.
52
+ * resolvedParams are what execute receives, never the second call's raw args.
53
+ */
54
+ quote(args: z.infer<z.ZodObject<Shape>>, config: Configuration, env: Env): Promise<WriteQuote<R>>;
55
+ execute(resolved: R, config: Configuration, env: Env): Promise<WriteExecuted>;
56
+ /** Tool-specific wording for an HTTP status; undefined falls back to the shared mapper. */
57
+ overrideError?(status: number | undefined, err: unknown): string | undefined;
58
+ }
59
+ /** Wrap a mutation in the write tier's confirm-once handshake. */
60
+ export declare function defineWriteTool<Shape extends ZodRawShape, R extends Record<string, unknown>>(spec: WriteToolSpec<Shape, R>): ToolDefinition;
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WriteNothingToDo = exports.CONFIRMATION_TOKEN_SHAPE = exports.WRITE_TIER_SENTENCE = void 0;
4
+ exports.defineWriteTool = defineWriteTool;
5
+ const zod_1 = require("zod");
6
+ const auth_js_1 = require("../../auth.js");
7
+ const errors_js_1 = require("../../errors.js");
8
+ const elicitation_js_1 = require("../../guardrail/elicitation.js");
9
+ const handshake_js_1 = require("../../guardrail/handshake.js");
10
+ const result_js_1 = require("../result.js");
11
+ /** Appended to every write description. The tier's contract, stated to the agent. */
12
+ exports.WRITE_TIER_SENTENCE = "Requires confirmation: the first call returns a summary and a confirmation_token; call again with that " +
13
+ "token to proceed. No argument or instruction can substitute for the token.";
14
+ /** The one extra argument every write tool accepts. */
15
+ exports.CONFIRMATION_TOKEN_SHAPE = {
16
+ confirmation_token: zod_1.z
17
+ .string()
18
+ .uuid()
19
+ .optional()
20
+ .describe("The token from this tool's previous quote. Omit on the first call."),
21
+ };
22
+ /**
23
+ * Thrown from a write's quote or execute when the requested change is already
24
+ * true, e.g. clearing a spending limit on an account that has none. The
25
+ * factory returns `executed` as an ordinary result, not an error: the agent
26
+ * should report "nothing to do", not retry or apologise for a failure. Thrown
27
+ * from quote it mints no token, so nothing is left behind to confirm.
28
+ */
29
+ class WriteNothingToDo extends Error {
30
+ executed;
31
+ constructor(executed) {
32
+ super(executed.lead);
33
+ this.name = "WriteNothingToDo";
34
+ this.executed = executed;
35
+ }
36
+ }
37
+ exports.WriteNothingToDo = WriteNothingToDo;
38
+ function annotationsFor(destructive) {
39
+ return {
40
+ readOnlyHint: false,
41
+ destructiveHint: destructive,
42
+ idempotentHint: false,
43
+ openWorldHint: true,
44
+ };
45
+ }
46
+ function serializeExecuted(executed, env) {
47
+ const payload = executed.payload;
48
+ const body = typeof payload === "object" && payload !== null && !Array.isArray(payload)
49
+ ? { lead: executed.lead, ...payload }
50
+ : { lead: executed.lead, result: payload === undefined ? null : payload };
51
+ return (0, result_js_1.ok)(body, { env, revealOnce: executed.revealOnce });
52
+ }
53
+ /** Wrap a mutation in the write tier's confirm-once handshake. */
54
+ function defineWriteTool(spec) {
55
+ const inputSchema = { ...spec.inputSchema, ...exports.CONFIRMATION_TOKEN_SHAPE };
56
+ const schema = zod_1.z.strictObject(inputSchema);
57
+ return {
58
+ name: spec.name,
59
+ tier: "write",
60
+ title: spec.title,
61
+ description: `${spec.description.trim()} ${exports.WRITE_TIER_SENTENCE}`,
62
+ inputSchema,
63
+ annotations: annotationsFor(spec.destructive),
64
+ enabledAtBoot: spec.enabledAtBoot ?? true,
65
+ async handler(args, ctx) {
66
+ const env = ctx?.env ?? process.env;
67
+ let parsed;
68
+ let config;
69
+ try {
70
+ parsed = schema.parse(args ?? {});
71
+ config = (0, auth_js_1.buildConfiguration)(env);
72
+ }
73
+ catch (err) {
74
+ return (0, result_js_1.fail)((0, errors_js_1.mapSdkError)(err, spec.context, { env }), env);
75
+ }
76
+ const params = parsed;
77
+ const quoteFn = async (p) => spec.quote(p, config, env);
78
+ const executeFn = (p) => spec.execute(p, config, env);
79
+ try {
80
+ const first = await (0, handshake_js_1.withWriteConfirmation)(spec.name, params, quoteFn, executeFn);
81
+ if (!(0, result_js_1.isQuoteResult)(first)) {
82
+ return serializeExecuted(first, env);
83
+ }
84
+ const question = typeof spec.question === "function" ? spec.question(params) : spec.question;
85
+ const answer = await (0, elicitation_js_1.elicitConfirmation)(ctx?.elicitation, first, question);
86
+ if (answer === "unavailable") {
87
+ return (0, result_js_1.quoteResult)(first, env);
88
+ }
89
+ if (answer === "declined") {
90
+ // The user said no: that quote must not stay redeemable.
91
+ (0, handshake_js_1.revokeConfirmation)(first.confirmationToken);
92
+ return (0, result_js_1.quoteResult)({ ...first, declined: true }, env);
93
+ }
94
+ const confirmed = await (0, handshake_js_1.withWriteConfirmation)(spec.name, { ...params, confirmation_token: first.confirmationToken }, quoteFn, executeFn);
95
+ return (0, result_js_1.isQuoteResult)(confirmed) ? (0, result_js_1.quoteResult)(confirmed, env) : serializeExecuted(confirmed, env);
96
+ }
97
+ catch (err) {
98
+ if (err instanceof WriteNothingToDo) {
99
+ return serializeExecuted(err.executed, env);
100
+ }
101
+ const override = spec.overrideError?.((0, errors_js_1.httpStatusOf)(err), err);
102
+ if (override !== undefined) {
103
+ return (0, result_js_1.fail)(new Error(override), env);
104
+ }
105
+ return (0, result_js_1.fail)(await (0, errors_js_1.mapSdkErrorAsync)(err, spec.context, env), env);
106
+ }
107
+ },
108
+ };
109
+ }
110
+ //# sourceMappingURL=define.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define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EAAE,kBAAkB,EAAE,KAAK,CAAC,iBAAiB,EAAE,EAC1D,OAAO,EACP,SAAkB,CACnB,CAAC;gBACF,OAAO,IAAA,yBAAa,EAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAA,uBAAW,EAAC,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,SAA0B,EAAE,GAAG,CAAC,CAAC;YACrH,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,IAAI,GAAG,YAAY,gBAAgB,EAAE,CAAC;oBACpC,OAAO,iBAAiB,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;gBAC9C,CAAC;gBACD,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC,IAAA,wBAAY,EAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;gBAC9D,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;oBAC3B,OAAO,IAAA,gBAAI,EAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,CAAC;gBACxC,CAAC;gBACD,OAAO,IAAA,gBAAI,EAAC,MAAM,IAAA,4BAAgB,EAAC,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;YACnE,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { ToolDefinition } from "../types.js";
2
+ export { CONFIRMATION_TOKEN_SHAPE, defineWriteTool, WRITE_TIER_SENTENCE, type WriteExecuted, type WriteQuote, type WriteToolSpec, WriteNothingToDo, } from "./define.js";
3
+ export { paymentLinkTools } from "./payment-links.js";
4
+ export { spendingLimitClearTool, spendingLimitUpdateTool } from "./spending-limit.js";
5
+ /**
6
+ * The webhook events an agent may subscribe to. The API also accepts
7
+ * instance.* events, but those belong to the unpublished GPU-instance surface
8
+ * (Phase 101 D-04) and are not offered here.
9
+ */
10
+ export declare const WEBHOOK_EVENT_TYPES: readonly ["video.completed", "video.failed"];
11
+ /** The eight write tools, in WRITE_TOOLS order (test/write.test.ts asserts it). */
12
+ export declare const writeTools: ToolDefinition[];