@ora-ai/cli 0.24.0 → 0.26.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 (149) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/README.md +569 -462
  3. package/dist/command-tree.d.ts +30 -0
  4. package/dist/command-tree.d.ts.map +1 -0
  5. package/dist/command-tree.js +144 -0
  6. package/dist/command-tree.js.map +1 -0
  7. package/dist/core/cli-arguments.d.ts +21 -0
  8. package/dist/core/cli-arguments.d.ts.map +1 -0
  9. package/dist/core/cli-arguments.js +53 -0
  10. package/dist/core/cli-arguments.js.map +1 -0
  11. package/dist/core/error-envelope.d.ts +13 -4
  12. package/dist/core/error-envelope.d.ts.map +1 -1
  13. package/dist/core/error-envelope.js +19 -4
  14. package/dist/core/error-envelope.js.map +1 -1
  15. package/dist/core/error-stories.d.ts +36 -0
  16. package/dist/core/error-stories.d.ts.map +1 -0
  17. package/dist/core/error-stories.js +155 -0
  18. package/dist/core/error-stories.js.map +1 -0
  19. package/dist/core/http.d.ts +14 -3
  20. package/dist/core/http.d.ts.map +1 -1
  21. package/dist/core/http.js +24 -6
  22. package/dist/core/http.js.map +1 -1
  23. package/dist/core/limit-story.d.ts +13 -0
  24. package/dist/core/limit-story.d.ts.map +1 -0
  25. package/dist/core/limit-story.js +21 -0
  26. package/dist/core/limit-story.js.map +1 -0
  27. package/dist/core/operation-command.d.ts +10 -0
  28. package/dist/core/operation-command.d.ts.map +1 -0
  29. package/dist/core/operation-command.js +15 -0
  30. package/dist/core/operation-command.js.map +1 -0
  31. package/dist/core/operation-meta.d.ts +62 -0
  32. package/dist/core/operation-meta.d.ts.map +1 -0
  33. package/dist/core/operation-meta.js +15 -0
  34. package/dist/core/operation-meta.js.map +1 -0
  35. package/dist/core/output.d.ts +7 -5
  36. package/dist/core/output.d.ts.map +1 -1
  37. package/dist/core/output.js +21 -84
  38. package/dist/core/output.js.map +1 -1
  39. package/dist/core/problem.d.ts +34 -0
  40. package/dist/core/problem.d.ts.map +1 -0
  41. package/dist/core/problem.js +44 -0
  42. package/dist/core/problem.js.map +1 -0
  43. package/dist/core/retry-after.d.ts +4 -3
  44. package/dist/core/retry-after.d.ts.map +1 -1
  45. package/dist/core/retry-after.js +4 -3
  46. package/dist/core/retry-after.js.map +1 -1
  47. package/dist/core/run-operation.d.ts +12 -5
  48. package/dist/core/run-operation.d.ts.map +1 -1
  49. package/dist/core/run-operation.js +32 -11
  50. package/dist/core/run-operation.js.map +1 -1
  51. package/dist/generated/operations.d.ts +38 -1
  52. package/dist/generated/operations.d.ts.map +1 -1
  53. package/dist/generated/operations.js +27547 -171
  54. package/dist/generated/operations.js.map +1 -1
  55. package/dist/generated/types.d.ts +2113 -2
  56. package/dist/generated/types.d.ts.map +1 -1
  57. package/dist/generated/types.js +1 -1
  58. package/dist/interactive/derive-prompts.d.ts +13 -5
  59. package/dist/interactive/derive-prompts.d.ts.map +1 -1
  60. package/dist/interactive/derive-prompts.js +25 -1
  61. package/dist/interactive/derive-prompts.js.map +1 -1
  62. package/dist/interactive/session.d.ts +2 -2
  63. package/dist/interactive/session.d.ts.map +1 -1
  64. package/dist/interactive/session.js +35 -4
  65. package/dist/interactive/session.js.map +1 -1
  66. package/dist/mcp/defined-tools/defined-call.d.ts +18 -0
  67. package/dist/mcp/defined-tools/defined-call.d.ts.map +1 -0
  68. package/dist/mcp/defined-tools/defined-call.js +114 -0
  69. package/dist/mcp/defined-tools/defined-call.js.map +1 -0
  70. package/dist/mcp/defined-tools/defined-tool.d.ts +22 -0
  71. package/dist/mcp/defined-tools/defined-tool.d.ts.map +1 -0
  72. package/dist/mcp/defined-tools/defined-tool.js +35 -0
  73. package/dist/mcp/defined-tools/defined-tool.js.map +1 -0
  74. package/dist/mcp/defined-tools/json-conform.d.ts +28 -0
  75. package/dist/mcp/defined-tools/json-conform.d.ts.map +1 -0
  76. package/dist/mcp/defined-tools/json-conform.js +144 -0
  77. package/dist/mcp/defined-tools/json-conform.js.map +1 -0
  78. package/dist/mcp/defined-tools/problem-mapping.d.ts +39 -0
  79. package/dist/mcp/defined-tools/problem-mapping.d.ts.map +1 -0
  80. package/dist/mcp/defined-tools/problem-mapping.js +179 -0
  81. package/dist/mcp/defined-tools/problem-mapping.js.map +1 -0
  82. package/dist/mcp/defined-tools/request-split.d.ts +19 -0
  83. package/dist/mcp/defined-tools/request-split.d.ts.map +1 -0
  84. package/dist/mcp/defined-tools/request-split.js +25 -0
  85. package/dist/mcp/defined-tools/request-split.js.map +1 -0
  86. package/dist/mcp/defined-tools/tool-problem.d.ts +40 -0
  87. package/dist/mcp/defined-tools/tool-problem.d.ts.map +1 -0
  88. package/dist/mcp/defined-tools/tool-problem.js +42 -0
  89. package/dist/mcp/defined-tools/tool-problem.js.map +1 -0
  90. package/dist/mcp/defined-tools/tool-results.d.ts +12 -0
  91. package/dist/mcp/defined-tools/tool-results.d.ts.map +1 -0
  92. package/dist/mcp/defined-tools/tool-results.js +21 -0
  93. package/dist/mcp/defined-tools/tool-results.js.map +1 -0
  94. package/dist/mcp/local-tools/credential-minting.d.ts +24 -0
  95. package/dist/mcp/local-tools/credential-minting.d.ts.map +1 -0
  96. package/dist/mcp/local-tools/credential-minting.js +49 -0
  97. package/dist/mcp/local-tools/credential-minting.js.map +1 -0
  98. package/dist/mcp/local-tools/env-file.d.ts +30 -0
  99. package/dist/mcp/local-tools/env-file.d.ts.map +1 -0
  100. package/dist/mcp/local-tools/env-file.js +71 -0
  101. package/dist/mcp/local-tools/env-file.js.map +1 -0
  102. package/dist/mcp/local-tools/local-tools.d.ts +16 -0
  103. package/dist/mcp/local-tools/local-tools.d.ts.map +1 -0
  104. package/dist/mcp/local-tools/local-tools.js +16 -0
  105. package/dist/mcp/local-tools/local-tools.js.map +1 -0
  106. package/dist/mcp/local-tools/save-transmitter-credential.d.ts +21 -0
  107. package/dist/mcp/local-tools/save-transmitter-credential.d.ts.map +1 -0
  108. package/dist/mcp/local-tools/save-transmitter-credential.js +119 -0
  109. package/dist/mcp/local-tools/save-transmitter-credential.js.map +1 -0
  110. package/dist/mcp/mcp-call.d.ts +2 -2
  111. package/dist/mcp/mcp-call.d.ts.map +1 -1
  112. package/dist/mcp/mcp-call.js +8 -2
  113. package/dist/mcp/mcp-call.js.map +1 -1
  114. package/dist/mcp/mcp-command.d.ts +6 -2
  115. package/dist/mcp/mcp-command.d.ts.map +1 -1
  116. package/dist/mcp/mcp-command.js +36 -12
  117. package/dist/mcp/mcp-command.js.map +1 -1
  118. package/dist/mcp/mcp-install.d.ts +2 -0
  119. package/dist/mcp/mcp-install.d.ts.map +1 -1
  120. package/dist/mcp/mcp-install.js +7 -1
  121. package/dist/mcp/mcp-install.js.map +1 -1
  122. package/dist/mcp/mcp-protocol.d.ts +2 -0
  123. package/dist/mcp/mcp-protocol.d.ts.map +1 -1
  124. package/dist/mcp/mcp-protocol.js.map +1 -1
  125. package/dist/mcp/mcp-tools.d.ts +28 -25
  126. package/dist/mcp/mcp-tools.d.ts.map +1 -1
  127. package/dist/mcp/mcp-tools.js +39 -16
  128. package/dist/mcp/mcp-tools.js.map +1 -1
  129. package/dist/mcp/tool-binding.d.ts +35 -0
  130. package/dist/mcp/tool-binding.d.ts.map +1 -0
  131. package/dist/mcp/tool-binding.js +7 -0
  132. package/dist/mcp/tool-binding.js.map +1 -0
  133. package/dist/mcp/tool-bindings.d.ts +20 -0
  134. package/dist/mcp/tool-bindings.d.ts.map +1 -0
  135. package/dist/mcp/tool-bindings.js +31 -0
  136. package/dist/mcp/tool-bindings.js.map +1 -0
  137. package/dist/mcp/tool-filter.d.ts +26 -0
  138. package/dist/mcp/tool-filter.d.ts.map +1 -0
  139. package/dist/mcp/tool-filter.js +23 -0
  140. package/dist/mcp/tool-filter.js.map +1 -0
  141. package/dist/program.d.ts +9 -9
  142. package/dist/program.d.ts.map +1 -1
  143. package/dist/program.js +11 -65
  144. package/dist/program.js.map +1 -1
  145. package/dist/watch.d.ts +3 -3
  146. package/dist/watch.d.ts.map +1 -1
  147. package/dist/watch.js +10 -2
  148. package/dist/watch.js.map +1 -1
  149. package/package.json +6 -7
@@ -0,0 +1,144 @@
1
+ /**
2
+ * A VALUE HELD TO A TOOL'S JSON SCHEMA — the part of validation a tool definition's schemas need, without a schema
3
+ * library (the published CLI takes no runtime dependency for it).
4
+ *
5
+ * What the remote's zod parse does to a tool's input and output, done from the same schemas as JSON: every type,
6
+ * enum and const checked, every required member present (a missing one with a `default` takes it, as zod's parse
7
+ * gives it), unions tried in order (the first that fits wins, as zod's `union` does), and a member an object schema
8
+ * closes (`additionalProperties: false`) either REFUSED (an input: a misspelled argument is the model's to correct)
9
+ * or DROPPED (an output: what an older CLI's schema does not know, a newer API may still send).
10
+ *
11
+ * Structural only: formats, patterns and bounds are left to the API, which validates every request again.
12
+ */
13
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
14
+ const ok = (value) => ({ ok: true, value });
15
+ const fail = (path, message) => ({ ok: false, issues: [{ path, message }] });
16
+ const at = (path, key) => (path === "" ? String(key) : `${path}.${key}`);
17
+ /** The JSON type names a value has (an integer is also a number). */
18
+ function typesOf(value) {
19
+ if (value === null)
20
+ return ["null"];
21
+ if (Array.isArray(value))
22
+ return ["array"];
23
+ if (typeof value === "number")
24
+ return Number.isInteger(value) ? ["integer", "number"] : ["number"];
25
+ return [typeof value];
26
+ }
27
+ function checkType(schema, value, path) {
28
+ const declared = schema.type;
29
+ if (declared === undefined)
30
+ return undefined;
31
+ const allowed = Array.isArray(declared) ? declared : [declared];
32
+ return typesOf(value).some((type) => allowed.includes(type))
33
+ ? undefined
34
+ : fail(path, `must be ${allowed.join(" or ")}`);
35
+ }
36
+ function checkValue(schema, value, path) {
37
+ if (Array.isArray(schema.enum) && !schema.enum.some((option) => Object.is(option, value))) {
38
+ return fail(path, `must be one of ${schema.enum.map((option) => JSON.stringify(option)).join(", ")}`);
39
+ }
40
+ if ("const" in schema && !Object.is(schema.const, value))
41
+ return fail(path, `must be ${JSON.stringify(schema.const)}`);
42
+ return undefined;
43
+ }
44
+ function conformObject(schema, value, undeclared, path) {
45
+ const properties = isRecord(schema.properties) ? schema.properties : {};
46
+ const required = new Set(Array.isArray(schema.required) ? schema.required : []);
47
+ const out = {};
48
+ const issues = [];
49
+ for (const [key, member] of Object.entries(properties)) {
50
+ const present = Object.hasOwn(value, key) && value[key] !== undefined;
51
+ const given = present ? value[key] : isRecord(member) && "default" in member ? member.default : undefined;
52
+ if (given === undefined) {
53
+ if (required.has(key))
54
+ issues.push({ path: at(path, key), message: "is required" });
55
+ continue;
56
+ }
57
+ const result = conform(member, given, undeclared, at(path, key));
58
+ if (result.ok)
59
+ out[key] = result.value;
60
+ else
61
+ issues.push(...result.issues);
62
+ }
63
+ for (const key of required) {
64
+ if (typeof key === "string" && !Object.hasOwn(properties, key) && value[key] === undefined) {
65
+ issues.push({ path: at(path, key), message: "is required" });
66
+ }
67
+ }
68
+ for (const [key, item] of Object.entries(value)) {
69
+ if (Object.hasOwn(properties, key) || item === undefined)
70
+ continue;
71
+ const extra = schema.additionalProperties;
72
+ if (extra === false) {
73
+ if (undeclared === "refuse")
74
+ issues.push({ path: at(path, key), message: "is not a known field" });
75
+ continue;
76
+ }
77
+ const result = isRecord(extra) ? conform(extra, item, undeclared, at(path, key)) : ok(item);
78
+ if (result.ok)
79
+ out[key] = result.value;
80
+ else
81
+ issues.push(...result.issues);
82
+ }
83
+ return issues.length > 0 ? { ok: false, issues } : ok(out);
84
+ }
85
+ function conformArray(schema, value, undeclared, path) {
86
+ const prefix = Array.isArray(schema.prefixItems) ? schema.prefixItems : [];
87
+ const out = [];
88
+ const issues = [];
89
+ value.forEach((item, index) => {
90
+ const member = index < prefix.length ? prefix[index] : schema.items;
91
+ const result = member === undefined ? ok(item) : conform(member, item, undeclared, at(path, index));
92
+ if (result.ok)
93
+ out.push(result.value);
94
+ else
95
+ issues.push(...result.issues);
96
+ });
97
+ return issues.length > 0 ? { ok: false, issues } : ok(out);
98
+ }
99
+ /** The first alternative the value fits, as it fits it. */
100
+ function conformAlternatives(alternatives, value, undeclared, path) {
101
+ for (const alternative of alternatives) {
102
+ const result = conform(alternative, value, undeclared, path);
103
+ if (result.ok)
104
+ return result;
105
+ }
106
+ return fail(path, "matches none of the shapes it may take");
107
+ }
108
+ const describesObject = (schema) => schema.type === "object" ||
109
+ isRecord(schema.properties) ||
110
+ "additionalProperties" in schema ||
111
+ Array.isArray(schema.required);
112
+ const describesArray = (schema) => schema.items !== undefined || Array.isArray(schema.prefixItems);
113
+ /** Hold `value` to `schema`: the value as the schema has it (defaults given, closed members dropped), or what is wrong. */
114
+ export function conform(schema, value, undeclared, path = "") {
115
+ if (schema === true || schema === undefined)
116
+ return ok(value);
117
+ if (schema === false)
118
+ return fail(path, "is not allowed");
119
+ if (!isRecord(schema))
120
+ return ok(value);
121
+ const alternatives = Array.isArray(schema.anyOf)
122
+ ? schema.anyOf
123
+ : Array.isArray(schema.oneOf)
124
+ ? schema.oneOf
125
+ : undefined;
126
+ if (alternatives)
127
+ return conformAlternatives(alternatives, value, undeclared, path);
128
+ let current = value;
129
+ for (const part of Array.isArray(schema.allOf) ? schema.allOf : []) {
130
+ const result = conform(part, current, undeclared, path);
131
+ if (!result.ok)
132
+ return result;
133
+ current = result.value;
134
+ }
135
+ const refused = checkType(schema, current, path) ?? checkValue(schema, current, path);
136
+ if (refused)
137
+ return refused;
138
+ if (isRecord(current) && describesObject(schema))
139
+ return conformObject(schema, current, undeclared, path);
140
+ if (Array.isArray(current) && describesArray(schema))
141
+ return conformArray(schema, current, undeclared, path);
142
+ return ok(current);
143
+ }
144
+ //# sourceMappingURL=json-conform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-conform.js","sourceRoot":"","sources":["../../../src/mcp/defined-tools/json-conform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAeH,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAoC,EAAE,CACpE,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK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AI,YAAY;QAAE,OAAO,mBAAmB,CAAC,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;IACpF,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QACnE,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;QACxD,IAAI,CAAC,MAAM,CAAC,EAAE;YAAE,OAAO,MAAM,CAAC;QAC9B,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC;IACzB,CAAC;IACD,MAAM,OAAO,GAAG,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,IAAI,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACtF,IAAI,OAAO;QAAE,OAAO,OAAO,CAAC;IAC5B,IAAI,QAAQ,CAAC,OAAO,CAAC,IAAI,eAAe,CAAC,MAAM,CAAC;QAAE,OAAO,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;IAC1G,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,cAAc,CAAC,MAAM,CAAC;QAAE,OAAO,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;IAC7G,OAAO,EAAE,CAAC,OAAO,CAAC,CAAC;AACrB,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * HOW A FAILED CALL BECOMES A PROBLEM — a non-2xx answer, no answer at all, or a 2xx whose body is not what the tool
3
+ * declares, each as the problem ora's remote MCP server answers the same failure with.
4
+ *
5
+ * A COPY, held in lockstep with apps/platform-mcp-service/src/operations/upstream-problem.ts by the golden table
6
+ * both are tested against (__fixtures__/tool-problems.json; tool-problems.lockstep.test.ts). Change it only with
7
+ * the remote and the table.
8
+ */
9
+ import { type ToolProblem } from "./tool-problem.js";
10
+ /** A non-2xx answer, as the client received it. */
11
+ export interface FailedResponse {
12
+ readonly method: string;
13
+ readonly status: number;
14
+ readonly headers: Headers;
15
+ /** The parsed JSON body, the raw text when it is not JSON, or `undefined` when empty. */
16
+ readonly body: unknown;
17
+ /** The `X-Request-Id` the call was sent with. */
18
+ readonly requestId: string;
19
+ }
20
+ /** A call that got no answer at all. */
21
+ export interface FailedExchange {
22
+ readonly method: string;
23
+ readonly requestId: string;
24
+ readonly error: unknown;
25
+ /** The client's own deadline fired, rather than the connection failing. */
26
+ readonly timedOut: boolean;
27
+ readonly timeoutMs: number;
28
+ }
29
+ /** A non-2xx answer as a problem: the operation's own problem when it sent one, else a minimal one. */
30
+ export declare function problemFromResponse(response: FailedResponse): ToolProblem;
31
+ /** No answer at all, as a retryable `503 UNAVAILABLE`: `unknown` for a write that may have reached the operation. */
32
+ export declare function problemFromNetworkFailure(failure: FailedExchange): ToolProblem;
33
+ /** A 2xx whose body is not what the tool declares: not retryable, and a write that answered 2xx WAS applied. */
34
+ export declare function problemFromUnexpectedSuccess(answer: {
35
+ method: string;
36
+ status: number;
37
+ requestId: string;
38
+ }): ToolProblem;
39
+ //# sourceMappingURL=problem-mapping.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"problem-mapping.d.ts","sourceRoot":"","sources":["../../../src/mcp/defined-tools/problem-mapping.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAGL,KAAK,WAAW,EAGjB,MAAM,mBAAmB,CAAC;AAE3B,mDAAmD;AACnD,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,yFAAyF;IACzF,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,iDAAiD;IACjD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,wCAAwC;AACxC,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,2EAA2E;IAC3E,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAuJD,uGAAuG;AACvG,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,cAAc,GAAG,WAAW,CASzE;AAQD,qHAAqH;AACrH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,cAAc,GAAG,WAAW,CAa9E;AAED,gHAAgH;AAChH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE;IACnD,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,WAAW,CASd"}
@@ -0,0 +1,179 @@
1
+ /**
2
+ * HOW A FAILED CALL BECOMES A PROBLEM — a non-2xx answer, no answer at all, or a 2xx whose body is not what the tool
3
+ * declares, each as the problem ora's remote MCP server answers the same failure with.
4
+ *
5
+ * A COPY, held in lockstep with apps/platform-mcp-service/src/operations/upstream-problem.ts by the golden table
6
+ * both are tested against (__fixtures__/tool-problems.json; tool-problems.lockstep.test.ts). Change it only with
7
+ * the remote and the table.
8
+ */
9
+ import { PROBLEM_OUTCOMES, } from "./tool-problem.js";
10
+ /** The stable code a status stands for when the body names none (a lookup table: a status's meaning stated once). */
11
+ const CODE_BY_STATUS = new Map([
12
+ [400, "INVALID_REQUEST"],
13
+ [401, "UNAUTHENTICATED"],
14
+ [402, "LIMIT_EXCEEDED"],
15
+ [403, "FORBIDDEN"],
16
+ [404, "NOT_FOUND"],
17
+ [405, "METHOD_NOT_ALLOWED"],
18
+ [409, "CONFLICT"],
19
+ [412, "PRECONDITION_FAILED"],
20
+ [422, "UNPROCESSABLE"],
21
+ [428, "PRECONDITION_REQUIRED"],
22
+ [429, "RATE_LIMITED"],
23
+ [503, "UNAVAILABLE"],
24
+ ]);
25
+ const FALLBACK_CODE = "UPSTREAM_ERROR";
26
+ const UNAVAILABLE_STATUS = 503;
27
+ /** Connection errors that prove the request never left: nothing can have been applied. */
28
+ const NOT_SENT_ERRORS = new Set([
29
+ "ECONNREFUSED",
30
+ "ENOTFOUND",
31
+ "EAI_AGAIN",
32
+ "EHOSTUNREACH",
33
+ "ENETUNREACH",
34
+ "UND_ERR_CONNECT_TIMEOUT",
35
+ ]);
36
+ const PROBLEM_MEDIA_TYPE = "application/problem+json";
37
+ /** RFC 9457 members that mark a JSON body carrying a `code` as a problem rather than a plain `{ error, code }`. */
38
+ const PROBLEM_MEMBERS = ["type", "title", "outcome", "retryable"];
39
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
40
+ const nonEmptyString = (value) => typeof value === "string" && value.length > 0 ? value : undefined;
41
+ const booleanOf = (value) => (typeof value === "boolean" ? value : undefined);
42
+ const secondsOf = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : undefined;
43
+ const isOutcome = (value) => PROBLEM_OUTCOMES.some((outcome) => outcome === value);
44
+ const isMutation = (method) => method.toLowerCase() !== "get";
45
+ /** Drop absent members, so the structured content an agent reads has no `undefined` noise. */
46
+ function withoutUndefined(problem) {
47
+ return Object.fromEntries(Object.entries(problem).filter(([, value]) => value !== undefined));
48
+ }
49
+ function retryAfterSeconds(headers) {
50
+ const value = headers.get("retry-after")?.trim();
51
+ if (!value)
52
+ return undefined;
53
+ if (/^\d+$/.test(value))
54
+ return Number(value);
55
+ const at = Date.parse(value);
56
+ return Number.isNaN(at) ? undefined : Math.max(0, Math.ceil((at - Date.now()) / 1000));
57
+ }
58
+ /**
59
+ * A write whose fate is unknown: repeating it may double it. Its answer is replayed to a re-send of the same
60
+ * request, so the caller checks the state first; `reuseIdempotencyKey` is never implied by it, and comes only
61
+ * from an operation's own problem (IDEMPOTENCY_IN_PROGRESS: the same request is still running).
62
+ */
63
+ const outcomeOf = (method, mayHaveApplied) => isMutation(method) && mayHaveApplied ? "unknown" : "not_applied";
64
+ /** A refusal (4xx) comes before anything is applied; a 5xx — or an answer no client expects — may follow a commit. */
65
+ const mayHaveCommitted = (status) => status >= 500 || status < 400;
66
+ const isRetryableStatus = (status) => status >= 500 || status === 429 || status === 408;
67
+ /** What the status and headers alone say — the answer for a body that is no problem (an HTML 502, nothing at all). */
68
+ function baselineProblem(response) {
69
+ const outcome = outcomeOf(response.method, mayHaveCommitted(response.status));
70
+ return withoutUndefined({
71
+ status: response.status,
72
+ code: CODE_BY_STATUS.get(response.status) ?? FALLBACK_CODE,
73
+ detail: `The operation failed with HTTP ${response.status}.`,
74
+ requestId: response.headers.get("x-request-id") ?? response.requestId,
75
+ retryable: isRetryableStatus(response.status),
76
+ outcome,
77
+ retryAfter: retryAfterSeconds(response.headers),
78
+ });
79
+ }
80
+ function nextStepsOf(value) {
81
+ if (!Array.isArray(value))
82
+ return undefined;
83
+ const steps = value.filter(isRecord).flatMap((step) => {
84
+ const id = nonEmptyString(step.id);
85
+ if (!id)
86
+ return [];
87
+ const title = nonEmptyString(step.title);
88
+ const operation = nonEmptyString(step.operation);
89
+ const done = booleanOf(step.done);
90
+ return [
91
+ { id, ...(title ? { title } : {}), ...(operation ? { operation } : {}), ...(done !== undefined ? { done } : {}) },
92
+ ];
93
+ });
94
+ return steps.length > 0 ? steps : undefined;
95
+ }
96
+ function fieldErrorsOf(value) {
97
+ if (!Array.isArray(value))
98
+ return undefined;
99
+ const errors = value
100
+ .filter(isRecord)
101
+ .flatMap((e) => typeof e.path === "string" && typeof e.message === "string" ? [{ path: e.path, message: e.message }] : []);
102
+ return errors.length > 0 ? errors : undefined;
103
+ }
104
+ /** An RFC 9457 problem: every member it declares, each kept only when well-typed; an outcome this client does not know reads as `unknown`. */
105
+ const rfc9457Problem = (body, response, baseline) => {
106
+ const mediaType = response.headers.get("content-type")?.toLowerCase() ?? "";
107
+ const declared = mediaType.includes(PROBLEM_MEDIA_TYPE) ||
108
+ (typeof body.code === "string" && PROBLEM_MEMBERS.some((member) => member in body));
109
+ if (!declared)
110
+ return undefined;
111
+ const outcome = body.outcome === undefined ? baseline.outcome : isOutcome(body.outcome) ? body.outcome : "unknown";
112
+ return withoutUndefined({
113
+ title: nonEmptyString(body.title),
114
+ status: response.status,
115
+ detail: nonEmptyString(body.detail),
116
+ code: nonEmptyString(body.code) ?? baseline.code,
117
+ requestId: nonEmptyString(body.requestId) ?? baseline.requestId,
118
+ retryable: booleanOf(body.retryable) ?? baseline.retryable,
119
+ outcome,
120
+ retryAfter: secondsOf(body.retryAfter) ?? baseline.retryAfter,
121
+ reuseIdempotencyKey: booleanOf(body.reuseIdempotencyKey),
122
+ nextSteps: nextStepsOf(body.nextSteps),
123
+ errors: fieldErrorsOf(body.errors),
124
+ });
125
+ };
126
+ /** A service's plain `{ error, code }` body: its code and message. */
127
+ const plainErrorBody = (body, _response, baseline) => withoutUndefined({
128
+ ...baseline,
129
+ code: nonEmptyString(body.code) ?? baseline.code,
130
+ detail: nonEmptyString(body.error) ?? nonEmptyString(body.message) ?? baseline.detail,
131
+ });
132
+ /** Tried in order; the first that recognizes the body answers (an ordered chain, the baseline as its fallback). */
133
+ const PROBLEM_READERS = [rfc9457Problem, plainErrorBody];
134
+ /** A non-2xx answer as a problem: the operation's own problem when it sent one, else a minimal one. */
135
+ export function problemFromResponse(response) {
136
+ const baseline = baselineProblem(response);
137
+ if (!isRecord(response.body))
138
+ return baseline;
139
+ const body = response.body;
140
+ for (const read of PROBLEM_READERS) {
141
+ const problem = read(body, response, baseline);
142
+ if (problem)
143
+ return problem;
144
+ }
145
+ return baseline;
146
+ }
147
+ function errorCodeOf(error) {
148
+ const cause = isRecord(error) ? error.cause : undefined;
149
+ if (isRecord(cause) && typeof cause.code === "string")
150
+ return cause.code;
151
+ return isRecord(error) && typeof error.code === "string" ? error.code : undefined;
152
+ }
153
+ /** No answer at all, as a retryable `503 UNAVAILABLE`: `unknown` for a write that may have reached the operation. */
154
+ export function problemFromNetworkFailure(failure) {
155
+ const code = errorCodeOf(failure.error);
156
+ const outcome = outcomeOf(failure.method, code === undefined || !NOT_SENT_ERRORS.has(code));
157
+ return withoutUndefined({
158
+ status: UNAVAILABLE_STATUS,
159
+ code: "UNAVAILABLE",
160
+ detail: failure.timedOut
161
+ ? `The operation did not answer within ${failure.timeoutMs / 1000} seconds.`
162
+ : "The operation could not be reached.",
163
+ requestId: failure.requestId,
164
+ retryable: true,
165
+ outcome,
166
+ });
167
+ }
168
+ /** A 2xx whose body is not what the tool declares: not retryable, and a write that answered 2xx WAS applied. */
169
+ export function problemFromUnexpectedSuccess(answer) {
170
+ return {
171
+ status: answer.status,
172
+ code: "UNEXPECTED_RESPONSE",
173
+ detail: `The operation answered ${answer.status} with a body this tool does not recognize.`,
174
+ requestId: answer.requestId,
175
+ retryable: false,
176
+ outcome: isMutation(answer.method) ? "applied" : "not_applied",
177
+ };
178
+ }
179
+ //# sourceMappingURL=problem-mapping.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"problem-mapping.js","sourceRoot":"","sources":["../../../src/mcp/defined-tools/problem-mapping.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,gBAAgB,GAKjB,MAAM,mBAAmB,CAAC;AAuB3B,qHAAqH;AACrH,MAAM,cAAc,GAAgC,IAAI,GAAG,CAAC;IAC1D,CAAC,GAAG,EAAE,iBAAiB,CAAC;IACxB,CAAC,GAAG,EAAE,iBAAiB,CAAC;IACxB,CAAC,GAAG,EAAE,gBAAgB,CAAC;IACvB,CAAC,GAAG,EAAE,WAAW,CAAC;IAClB,CAAC,GAAG,EAAE,WAAW,CAAC;IAClB,CAAC,GAAG,EAAE,oBAAoB,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with the tool's definition
3
+ * (`x-ora-mcp-tool.request`), exactly as ora's remote MCP server splits it (@ora/front-api's `splitToolInput`, which
4
+ * the published CLI cannot import; request-split.test.ts holds this to the same cases).
5
+ *
6
+ * A part is sent exactly when the map lists it: a listed body whose keys the input leaves out is still `{}`; a key
7
+ * left out is never sent; the map's `ifMatch` key travels as `If-Match`, quoted as an entity-tag.
8
+ */
9
+ import type { McpRequestMapMeta } from "../../core/operation-meta.js";
10
+ export interface SplitRequest {
11
+ readonly params?: Record<string, unknown>;
12
+ readonly query?: Record<string, unknown>;
13
+ readonly body?: Record<string, unknown>;
14
+ readonly headers: Record<string, string>;
15
+ }
16
+ /** `v7` → `"v7"` (RFC 9110 entity-tag); an entity-tag stays as it is. */
17
+ export declare function entityTag(version: string): string;
18
+ export declare function splitToolInput(map: McpRequestMapMeta, input: Readonly<Record<string, unknown>>): SplitRequest;
19
+ //# sourceMappingURL=request-split.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-split.d.ts","sourceRoot":"","sources":["../../../src/mcp/defined-tools/request-split.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEtE,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C;AAED,yEAAyE;AACzE,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEjD;AAUD,wBAAgB,cAAc,CAAC,GAAG,EAAE,iBAAiB,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,YAAY,CAK7G"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * A TOOL CALL'S FLAT INPUT, SPLIT BACK INTO ITS REQUEST — by the request map that travels with the tool's definition
3
+ * (`x-ora-mcp-tool.request`), exactly as ora's remote MCP server splits it (@ora/front-api's `splitToolInput`, which
4
+ * the published CLI cannot import; request-split.test.ts holds this to the same cases).
5
+ *
6
+ * A part is sent exactly when the map lists it: a listed body whose keys the input leaves out is still `{}`; a key
7
+ * left out is never sent; the map's `ifMatch` key travels as `If-Match`, quoted as an entity-tag.
8
+ */
9
+ /** `v7` → `"v7"` (RFC 9110 entity-tag); an entity-tag stays as it is. */
10
+ export function entityTag(version) {
11
+ return version.startsWith('"') || version.startsWith('W/"') ? version : `"${version}"`;
12
+ }
13
+ function pick(keys, input) {
14
+ if (keys === undefined)
15
+ return undefined;
16
+ return Object.fromEntries(keys.filter((key) => input[key] !== undefined).map((key) => [key, input[key]]));
17
+ }
18
+ export function splitToolInput(map, input) {
19
+ const headers = {};
20
+ const version = map.ifMatch === undefined ? undefined : input[map.ifMatch];
21
+ if (typeof version === "string")
22
+ headers["If-Match"] = entityTag(version);
23
+ return { params: pick(map.params, input), query: pick(map.query, input), body: pick(map.body, input), headers };
24
+ }
25
+ //# sourceMappingURL=request-split.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-split.js","sourceRoot":"","sources":["../../../src/mcp/defined-tools/request-split.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAWH,yEAAyE;AACzE,MAAM,UAAU,SAAS,CAAC,OAAe;IACvC,OAAO,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,OAAO,GAAG,CAAC;AACzF,CAAC;AAED,SAAS,IAAI,CACX,IAAmC,EACnC,KAAwC;IAExC,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACzC,OAAO,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5G,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,GAAsB,EAAE,KAAwC;IAC7F,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC3E,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IAC1E,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;AAClH,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * THE PROBLEM A FAILED TOOL CALL ANSWERS — the RFC 9457 problem ora's remote MCP server answers a failed call with
3
+ * (its structured content), and the one paragraph of words that goes with it (its text).
4
+ *
5
+ * A COPY, held in lockstep: the published CLI cannot import platform-mcp-service's code
6
+ * (apps/platform-mcp-service/src/tools/tool-problem.ts), so this file and problem-mapping.ts restate it, and
7
+ * tool-problems.lockstep.test.ts holds both to the golden table that service's own test is held to
8
+ * (__fixtures__/tool-problems.json). The problem's schema is not restated: it travels in each tool's definition.
9
+ */
10
+ export type ProblemOutcome = "not_applied" | "applied" | "unknown";
11
+ export declare const PROBLEM_OUTCOMES: readonly ProblemOutcome[];
12
+ export interface ToolProblemNextStep {
13
+ id: string;
14
+ title?: string;
15
+ operation?: string;
16
+ done?: boolean;
17
+ }
18
+ export interface ToolProblemFieldError {
19
+ path: string;
20
+ message: string;
21
+ }
22
+ export interface ToolProblem {
23
+ title?: string;
24
+ status?: number;
25
+ detail?: string;
26
+ code: string;
27
+ requestId: string;
28
+ retryable: boolean;
29
+ outcome: ProblemOutcome;
30
+ retryAfter?: number;
31
+ reuseIdempotencyKey?: boolean;
32
+ nextSteps?: ToolProblemNextStep[];
33
+ errors?: ToolProblemFieldError[];
34
+ }
35
+ /**
36
+ * The problem as one paragraph of text — the `content` of an error result, which is all a client that ignores
37
+ * structured content (and the model behind it) ever reads, so it carries every fact an agent acts on.
38
+ */
39
+ export declare function summarizeProblem(problem: ToolProblem): string;
40
+ //# sourceMappingURL=tool-problem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-problem.d.ts","sourceRoot":"","sources":["../../../src/mcp/defined-tools/tool-problem.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG,SAAS,GAAG,SAAS,CAAC;AAEnE,eAAO,MAAM,gBAAgB,EAAE,SAAS,cAAc,EAA0C,CAAC;AAEjG,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,cAAc,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,SAAS,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAClC,MAAM,CAAC,EAAE,qBAAqB,EAAE,CAAC;CAClC;AAgBD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAY7D"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * THE PROBLEM A FAILED TOOL CALL ANSWERS — the RFC 9457 problem ora's remote MCP server answers a failed call with
3
+ * (its structured content), and the one paragraph of words that goes with it (its text).
4
+ *
5
+ * A COPY, held in lockstep: the published CLI cannot import platform-mcp-service's code
6
+ * (apps/platform-mcp-service/src/tools/tool-problem.ts), so this file and problem-mapping.ts restate it, and
7
+ * tool-problems.lockstep.test.ts holds both to the golden table that service's own test is held to
8
+ * (__fixtures__/tool-problems.json). The problem's schema is not restated: it travels in each tool's definition.
9
+ */
10
+ export const PROBLEM_OUTCOMES = ["not_applied", "applied", "unknown"];
11
+ /** What each outcome means for the member's data, in the words an agent relays. */
12
+ const OUTCOME_SENTENCES = {
13
+ not_applied: "Nothing was changed.",
14
+ applied: "The change was applied.",
15
+ unknown: "The change may or may not have been applied: check the current state before trying again.",
16
+ };
17
+ function retrySentence(problem) {
18
+ if (!problem.retryable)
19
+ return "Retrying the same call will not help.";
20
+ return problem.retryAfter === undefined
21
+ ? "Retrying may succeed."
22
+ : `Retrying may succeed after ${problem.retryAfter} seconds.`;
23
+ }
24
+ /**
25
+ * The problem as one paragraph of text — the `content` of an error result, which is all a client that ignores
26
+ * structured content (and the model behind it) ever reads, so it carries every fact an agent acts on.
27
+ */
28
+ export function summarizeProblem(problem) {
29
+ const headline = problem.title ?? problem.code;
30
+ const parts = [problem.detail ? `${headline}: ${problem.detail}` : `${headline}.`];
31
+ parts.push(OUTCOME_SENTENCES[problem.outcome], retrySentence(problem));
32
+ if (problem.errors?.length) {
33
+ parts.push(`Invalid input: ${problem.errors.map((e) => `${e.path}: ${e.message}`).join("; ")}.`);
34
+ }
35
+ const pending = problem.nextSteps?.filter((step) => step.done !== true) ?? [];
36
+ if (pending.length > 0)
37
+ parts.push(`Next steps: ${pending.map((step) => step.title ?? step.id).join("; ")}.`);
38
+ const status = problem.status === undefined ? "" : `, status ${problem.status}`;
39
+ parts.push(`(code ${problem.code}${status}, request ${problem.requestId})`);
40
+ return parts.join(" ");
41
+ }
42
+ //# sourceMappingURL=tool-problem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-problem.js","sourceRoot":"","sources":["../../../src/mcp/defined-tools/tool-problem.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,MAAM,CAAC,MAAM,gBAAgB,GAA8B,CAAC,aAAa,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;AA4BjG,mFAAmF;AACnF,MAAM,iBAAiB,GAA6C;IAClE,WAAW,EAAE,sBAAsB;IACnC,OAAO,EAAE,yBAAyB;IAClC,OAAO,EAAE,2FAA2F;CACrG,CAAC;AAEF,SAAS,aAAa,CAAC,OAAoB;IACzC,IAAI,CAAC,OAAO,CAAC,SAAS;QAAE,OAAO,uCAAuC,CAAC;IACvE,OAAO,OAAO,CAAC,UAAU,KAAK,SAAS;QACrC,CAAC,CAAC,uBAAuB;QACzB,CAAC,CAAC,8BAA8B,OAAO,CAAC,UAAU,WAAW,CAAC;AAClE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAoB;IACnD,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAC/C,MAAM,KAAK,GAAG,CAAC,OAAO,CAAC,MAA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WERS A TOOL GIVES, shaped as ora's remote MCP server shapes them
3
+ * (apps/platform-mcp-service/src/mcp/tool-results.ts): the output as structured content and as JSON text; a
4
+ * problem as structured content and as words; and, for what is no problem of the operation's (an argument the
5
+ * call never got past, a programming error), the words alone.
6
+ */
7
+ import type { McpToolResult } from "../mcp-protocol.js";
8
+ import { type ToolProblem } from "./tool-problem.js";
9
+ export declare function successResult(output: Record<string, unknown>): McpToolResult;
10
+ export declare function problemResult(problem: ToolProblem): McpToolResult;
11
+ export declare function textError(message: string): McpToolResult;
12
+ //# sourceMappingURL=tool-results.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-results.d.ts","sourceRoot":"","sources":["../../../src/mcp/defined-tools/tool-results.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAoB,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEvE,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,aAAa,CAE5E;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,WAAW,GAAG,aAAa,CAMjE;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,CAExD"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * THE THREE ANSWERS A TOOL GIVES, shaped as ora's remote MCP server shapes them
3
+ * (apps/platform-mcp-service/src/mcp/tool-results.ts): the output as structured content and as JSON text; a
4
+ * problem as structured content and as words; and, for what is no problem of the operation's (an argument the
5
+ * call never got past, a programming error), the words alone.
6
+ */
7
+ import { summarizeProblem } from "./tool-problem.js";
8
+ export function successResult(output) {
9
+ return { structuredContent: output, content: [{ type: "text", text: JSON.stringify(output) }], isError: false };
10
+ }
11
+ export function problemResult(problem) {
12
+ return {
13
+ structuredContent: { ...problem },
14
+ content: [{ type: "text", text: summarizeProblem(problem) }],
15
+ isError: true,
16
+ };
17
+ }
18
+ export function textError(message) {
19
+ return { content: [{ type: "text", text: message }], isError: true };
20
+ }
21
+ //# sourceMappingURL=tool-results.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-results.js","sourceRoot":"","sources":["../../../src/mcp/defined-tools/tool-results.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,gBAAgB,EAAoB,MAAM,mBAAmB,CAAC;AAEvE,MAAM,UAAU,aAAa,CAAC,MAA+B;IAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAClH,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,OAAoB;IAChD,OAAO;QACL,iBAAiB,EAAE,EAAE,GAAG,OAAO,EAAE;QACjC,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5D,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,OAAe;IACvC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACvE,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * MINTING A TRANSMITTER CREDENTIAL, ITS SECRET KEPT FROM THE MODEL — the mint operation called exactly as a tool the
3
+ * document defines is called (defined-tools/defined-call.ts: its headers, its fresh Idempotency-Key, its deadline and
4
+ * its problems), with one difference: what it answers is never an answer. The secret goes back to the caller, in
5
+ * memory; a failure goes back as words only (a problem's summary), and never with the body.
6
+ */
7
+ import type { CommandOperation } from "../../core/operation-meta.js";
8
+ import type { McpToolResult } from "../mcp-protocol.js";
9
+ import type { ToolCallContext } from "../tool-binding.js";
10
+ export interface MintedCredential {
11
+ readonly id: string;
12
+ readonly fingerprint: string;
13
+ readonly secret: string;
14
+ }
15
+ export type Minting = {
16
+ readonly ok: true;
17
+ readonly credential: MintedCredential;
18
+ } | {
19
+ readonly ok: false;
20
+ readonly result: McpToolResult;
21
+ };
22
+ /** Mint a credential for `site`: the credential, or the failure in words. */
23
+ export declare function mintCredential(mint: CommandOperation, site: string, ctx: ToolCallContext): Promise<Minting>;
24
+ //# sourceMappingURL=credential-minting.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credential-minting.d.ts","sourceRoot":"","sources":["../../../src/mcp/local-tools/credential-minting.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAe,MAAM,8BAA8B,CAAC;AAGlF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,MAAM,OAAO,GACjB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAA;CAAE,CAAC;AA8BxH,6EAA6E;AAC7E,wBAAsB,cAAc,CAAC,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CAYjH"}