@didit-protocol/mcp-server 5.1.36 → 5.1.51

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 (102) hide show
  1. package/README.md +201 -29
  2. package/dist/app-api-key.d.ts +5 -0
  3. package/dist/app-api-key.d.ts.map +1 -0
  4. package/dist/app-api-key.js +108 -0
  5. package/dist/app-api-key.js.map +1 -0
  6. package/dist/auth/cached-verifier.d.ts +38 -0
  7. package/dist/auth/cached-verifier.d.ts.map +1 -0
  8. package/dist/auth/cached-verifier.js +82 -0
  9. package/dist/auth/cached-verifier.js.map +1 -0
  10. package/dist/auth/introspection-verifier.d.ts +12 -0
  11. package/dist/auth/introspection-verifier.d.ts.map +1 -1
  12. package/dist/auth/introspection-verifier.js +40 -14
  13. package/dist/auth/introspection-verifier.js.map +1 -1
  14. package/dist/chatgpt-app.d.ts +1 -0
  15. package/dist/chatgpt-app.d.ts.map +1 -1
  16. package/dist/chatgpt-app.js +2 -0
  17. package/dist/chatgpt-app.js.map +1 -1
  18. package/dist/config.d.ts +12 -3
  19. package/dist/config.d.ts.map +1 -1
  20. package/dist/config.js +55 -8
  21. package/dist/config.js.map +1 -1
  22. package/dist/device-login.d.ts +98 -0
  23. package/dist/device-login.d.ts.map +1 -0
  24. package/dist/device-login.js +455 -0
  25. package/dist/device-login.js.map +1 -0
  26. package/dist/http.d.ts.map +1 -1
  27. package/dist/http.js +61 -5
  28. package/dist/http.js.map +1 -1
  29. package/dist/index.d.ts +1 -0
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +595 -47
  32. package/dist/index.js.map +1 -1
  33. package/dist/investigator-agent.d.ts +4 -0
  34. package/dist/investigator-agent.d.ts.map +1 -0
  35. package/dist/investigator-agent.js +10 -0
  36. package/dist/investigator-agent.js.map +1 -0
  37. package/dist/login-cli.d.ts +6 -0
  38. package/dist/login-cli.d.ts.map +1 -0
  39. package/dist/login-cli.js +47 -0
  40. package/dist/login-cli.js.map +1 -0
  41. package/dist/mcp-modern.d.ts +1 -0
  42. package/dist/mcp-modern.d.ts.map +1 -1
  43. package/dist/mcp-modern.js +1 -1
  44. package/dist/mcp-modern.js.map +1 -1
  45. package/dist/permissions.d.ts.map +1 -1
  46. package/dist/permissions.js +29 -4
  47. package/dist/permissions.js.map +1 -1
  48. package/dist/privileged-tools.d.ts +1 -0
  49. package/dist/privileged-tools.d.ts.map +1 -1
  50. package/dist/privileged-tools.js +2 -1
  51. package/dist/privileged-tools.js.map +1 -1
  52. package/dist/schema/feature-config-schema.json +941 -28
  53. package/dist/security.d.ts +9 -8
  54. package/dist/security.d.ts.map +1 -1
  55. package/dist/security.js +11 -3
  56. package/dist/security.js.map +1 -1
  57. package/dist/signature-download.d.ts +31 -0
  58. package/dist/signature-download.d.ts.map +1 -0
  59. package/dist/signature-download.js +122 -0
  60. package/dist/signature-download.js.map +1 -0
  61. package/dist/tools/auth.d.ts +2 -0
  62. package/dist/tools/auth.d.ts.map +1 -1
  63. package/dist/tools/auth.js +114 -14
  64. package/dist/tools/auth.js.map +1 -1
  65. package/dist/tools/billing.d.ts +33 -2
  66. package/dist/tools/billing.d.ts.map +1 -1
  67. package/dist/tools/billing.js +252 -12
  68. package/dist/tools/billing.js.map +1 -1
  69. package/dist/tools/compliance.d.ts.map +1 -1
  70. package/dist/tools/compliance.js +37 -0
  71. package/dist/tools/compliance.js.map +1 -1
  72. package/dist/tools/investigator.d.ts +19 -0
  73. package/dist/tools/investigator.d.ts.map +1 -0
  74. package/dist/tools/investigator.js +449 -0
  75. package/dist/tools/investigator.js.map +1 -0
  76. package/dist/tools/members.d.ts +8 -0
  77. package/dist/tools/members.d.ts.map +1 -1
  78. package/dist/tools/members.js +73 -4
  79. package/dist/tools/members.js.map +1 -1
  80. package/dist/tools/observability.d.ts +6 -0
  81. package/dist/tools/observability.d.ts.map +1 -1
  82. package/dist/tools/observability.js +11 -3
  83. package/dist/tools/observability.js.map +1 -1
  84. package/dist/tools/search.d.ts.map +1 -1
  85. package/dist/tools/search.js +89 -5
  86. package/dist/tools/search.js.map +1 -1
  87. package/dist/tools/session-explain-levers.d.ts +6 -0
  88. package/dist/tools/session-explain-levers.d.ts.map +1 -1
  89. package/dist/tools/session-explain-levers.js +40 -7
  90. package/dist/tools/session-explain-levers.js.map +1 -1
  91. package/dist/tools/sessions.d.ts +24 -0
  92. package/dist/tools/sessions.d.ts.map +1 -1
  93. package/dist/tools/sessions.js +196 -2
  94. package/dist/tools/sessions.js.map +1 -1
  95. package/dist/tools/settings.d.ts.map +1 -1
  96. package/dist/tools/settings.js +3 -1
  97. package/dist/tools/settings.js.map +1 -1
  98. package/dist/tools/standalone.d.ts +5 -0
  99. package/dist/tools/standalone.d.ts.map +1 -1
  100. package/dist/tools/standalone.js +18 -2
  101. package/dist/tools/standalone.js.map +1 -1
  102. package/package.json +1 -1
@@ -0,0 +1,449 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.INVESTIGATOR_TOOL_PERMISSIONS = exports.INVESTIGATOR_WRITE_TOOLS = exports.INVESTIGATOR_DECISION_TOOLS = exports.INVESTIGATOR_TOOL_DEFS = void 0;
4
+ exports.isInvestigatorToolName = isInvestigatorToolName;
5
+ exports.actorViaFromHeaders = actorViaFromHeaders;
6
+ exports.dispatchInvestigatorTool = dispatchInvestigatorTool;
7
+ const config_1 = require("../config");
8
+ const orgapp_1 = require("../orgapp");
9
+ const security_1 = require("../security");
10
+ const QUEUES = ["kyc", "kyb", "aml", "transactions", "cases"];
11
+ const KINDS = ["session", "business_session", "transaction", "case"];
12
+ const RECOMMENDATIONS = ["approve", "decline", "escalate", "request"];
13
+ const OVERRIDE_CATEGORIES = ["missing_context", "needs_information", "policy_differs", "evidence_misread", "other"];
14
+ const POLICY_ANSWERS = ["approve", "decline", "request", "person"];
15
+ const QUESTION_STATUSES = ["open", "answered", "dismissed"];
16
+ const ACTIVITY_GROUPS = ["agent", "decisions", "overrides", "autonomy"];
17
+ const SCOPES = ["all", "identity", "transactions"];
18
+ const BATCH_ACCEPT_LIMIT = 50;
19
+ const NOTE_MAX_LENGTH = 2000;
20
+ /** Why a tool needs confirm:true, in its schema and in the refusal. */
21
+ const DECISION_REASON = "is a human decision the Investigator only recommends";
22
+ const REREVIEW_REASON = "replaces its open report";
23
+ const confirmProp = (why) => ({
24
+ type: "boolean",
25
+ description: `REQUIRED. Must be true - this ${why}. Only set after explicit user confirmation of this exact action.`,
26
+ });
27
+ const CONFIRM_PROP = confirmProp(DECISION_REASON);
28
+ const SCOPE_PROP = {
29
+ type: "string",
30
+ enum: SCOPES,
31
+ description: "all (default), identity (sessions and the cases no transaction rule opened) or transactions.",
32
+ };
33
+ const PAGE_PROPS = {
34
+ limit: { type: "number", description: "Page size." },
35
+ offset: { type: "number", description: "Rows to skip." },
36
+ };
37
+ const APPROVAL_NOTE = " Requires human approval: describe the exact action to the user, wait for their explicit confirmation, then call with confirm:true.";
38
+ exports.INVESTIGATOR_TOOL_DEFS = [
39
+ {
40
+ name: "didit_investigator_queue_list",
41
+ description: "List the Investigator's open reports (the review queue), Ready to accept first. Each row has run_id, the item, " +
42
+ "the recommendation (approve/decline/escalate/request), confidence and ready_to_accept. Read the full report with " +
43
+ "didit_investigator_report_get.",
44
+ inputSchema: {
45
+ type: "object",
46
+ properties: {
47
+ ...orgapp_1.ORG_APP_PROPS,
48
+ scope: SCOPE_PROP,
49
+ kind: { type: "string", description: `Item kind, or several separated by commas: ${KINDS.join(", ")}.` },
50
+ queue: { type: "string", enum: QUEUES },
51
+ recommendation: { type: "string", enum: RECOMMENDATIONS },
52
+ confidence: { type: "string", enum: ["high", "moderate", "low"] },
53
+ ready: { type: "boolean", description: "true: only Ready to accept; false: only the others." },
54
+ search: { type: "string", description: "Name, company, case number or transaction id." },
55
+ ...PAGE_PROPS,
56
+ },
57
+ },
58
+ },
59
+ {
60
+ name: "didit_investigator_report_get",
61
+ description: "Get one Investigator report: recommendation, confidence, risk, narrative, the basis (policy rules), evidence with " +
62
+ "its sources, guardrails, precedents (similar past decisions), questions and provenance (model, prompt hash, " +
63
+ "policy version). Use it to explain why the Investigator recommended something.",
64
+ inputSchema: {
65
+ type: "object",
66
+ properties: { ...orgapp_1.ORG_APP_PROPS, run_id: { type: "string", description: "The report's run_id (from the queue)." } },
67
+ required: ["run_id"],
68
+ },
69
+ },
70
+ {
71
+ name: "didit_investigator_accept",
72
+ description: "Accept the Investigator's recommendation on one item: the item is decided through its normal route (approve, " +
73
+ "decline, request information or escalate) and logged in the Investigator Activity under the user's name. A " +
74
+ "changed narrative makes it 'edited and accepted'." +
75
+ APPROVAL_NOTE,
76
+ inputSchema: {
77
+ type: "object",
78
+ properties: {
79
+ ...orgapp_1.ORG_APP_PROPS,
80
+ run_id: { type: "string" },
81
+ narrative: { type: "string", description: "Optional edited narrative (max 4000 characters)." },
82
+ confirm: CONFIRM_PROP,
83
+ },
84
+ required: ["run_id", "confirm"],
85
+ },
86
+ },
87
+ {
88
+ name: "didit_investigator_override",
89
+ description: "Override the Investigator: decide one item with another action, a category and a reason (10-500 characters). " +
90
+ "Also overrides a decision the Investigator automated while it still stands; repeated overrides become policy " +
91
+ "questions." +
92
+ APPROVAL_NOTE,
93
+ inputSchema: {
94
+ type: "object",
95
+ properties: {
96
+ ...orgapp_1.ORG_APP_PROPS,
97
+ run_id: { type: "string" },
98
+ action: { type: "string", enum: RECOMMENDATIONS, description: "The decision to take instead." },
99
+ category: { type: "string", enum: OVERRIDE_CATEGORIES },
100
+ reason: { type: "string", description: "Why, in 10 to 500 characters." },
101
+ confirm: CONFIRM_PROP,
102
+ },
103
+ required: ["run_id", "action", "category", "reason", "confirm"],
104
+ },
105
+ },
106
+ {
107
+ name: "didit_investigator_batch_accept",
108
+ description: `Accept up to ${BATCH_ACCEPT_LIMIT} ready recommendations at once; each item is its own decision and one that ` +
109
+ "cannot be accepted is skipped with its reason. List the items and their recommendations to the user first." +
110
+ APPROVAL_NOTE,
111
+ inputSchema: {
112
+ type: "object",
113
+ properties: {
114
+ ...orgapp_1.ORG_APP_PROPS,
115
+ run_ids: { type: "array", items: { type: "string" }, description: `1 to ${BATCH_ACCEPT_LIMIT} run ids.` },
116
+ confirm: CONFIRM_PROP,
117
+ },
118
+ required: ["run_ids", "confirm"],
119
+ },
120
+ },
121
+ {
122
+ name: "didit_investigator_add_note",
123
+ description: "Record a fact the user adds about a report's item as a team note (any kind: verification, business, " +
124
+ "transaction, case). The note shows with the report and the Investigator reads it on its NEXT review of the " +
125
+ "item; it does not re-evaluate on its own. To have it review the item again now, use " +
126
+ "didit_investigator_rereview (it can carry the note itself).",
127
+ inputSchema: {
128
+ type: "object",
129
+ properties: {
130
+ ...orgapp_1.ORG_APP_PROPS,
131
+ run_id: { type: "string", description: "The report's run_id." },
132
+ note: { type: "string", description: `The fact, in the user's own words (max ${NOTE_MAX_LENGTH} characters).` },
133
+ },
134
+ required: ["run_id", "note"],
135
+ },
136
+ },
137
+ {
138
+ name: "didit_investigator_rereview",
139
+ description: "Ask the Investigator to review an item again (for example after the user added a fact): a fresh review " +
140
+ "starts in the background and replaces the item's open report when it starts. The usual stage, spending limit " +
141
+ "and guardrails apply and the Investigator never decides that review on its own. Only the item's open, " +
142
+ "finished report can be re-reviewed (409 not_rereviewable), and one at a time (409 rereview_pending). Read the " +
143
+ "new report with didit_investigator_queue_list / didit_investigator_report_get once it is ready." +
144
+ APPROVAL_NOTE,
145
+ inputSchema: {
146
+ type: "object",
147
+ properties: {
148
+ ...orgapp_1.ORG_APP_PROPS,
149
+ run_id: { type: "string", description: "The open report's run_id." },
150
+ note: {
151
+ type: "string",
152
+ description: `Optional fact to record as a team note and give the new review (max ${NOTE_MAX_LENGTH} characters).`,
153
+ },
154
+ confirm: confirmProp(REREVIEW_REASON),
155
+ },
156
+ required: ["run_id", "confirm"],
157
+ },
158
+ },
159
+ {
160
+ name: "didit_investigator_record_get",
161
+ description: "Get the Investigator's review of one verification (session_id, KYC or KYB) or one transaction " +
162
+ "(transaction_id): its newest run, open or decided, with run_id, status, recommendation, confidence, " +
163
+ "summary, whether it was automated and who decided it; null when it never had one. Use it for a record " +
164
+ "the queue does not list (decided items, a record page). Read the full report with " +
165
+ "didit_investigator_report_get once status is completed. A case's run is in didit_case_get's investigator.",
166
+ inputSchema: {
167
+ type: "object",
168
+ properties: {
169
+ ...orgapp_1.ORG_APP_PROPS,
170
+ session_id: { type: "string", description: "The verification's session id." },
171
+ transaction_id: { type: "string", description: "The transaction's id." },
172
+ },
173
+ },
174
+ },
175
+ {
176
+ name: "didit_investigator_question_list",
177
+ description: "List the Investigator's policy questions (situations its policy does not cover, or rules the team keeps " +
178
+ "overriding), newest first, with counts.",
179
+ inputSchema: {
180
+ type: "object",
181
+ properties: { ...orgapp_1.ORG_APP_PROPS, status: { type: "string", enum: QUESTION_STATUSES } },
182
+ },
183
+ },
184
+ {
185
+ name: "didit_investigator_question_get",
186
+ description: "Get one policy question with the team's last 30 days on that situation and the four possible answers.",
187
+ inputSchema: {
188
+ type: "object",
189
+ properties: { ...orgapp_1.ORG_APP_PROPS, question_id: { type: "string" } },
190
+ required: ["question_id"],
191
+ },
192
+ },
193
+ {
194
+ name: "didit_investigator_question_answer",
195
+ description: "Answer a policy question: approve, decline, request (ask for more information) or person (always ask a person). " +
196
+ "Any answer but 'no change' writes a new policy version and re-checks the waiting reports of that queue." +
197
+ APPROVAL_NOTE,
198
+ inputSchema: {
199
+ type: "object",
200
+ properties: {
201
+ ...orgapp_1.ORG_APP_PROPS,
202
+ question_id: { type: "string" },
203
+ answer: { type: "string", enum: POLICY_ANSWERS },
204
+ detail: { type: "string", description: "Optional condition or note for the rule." },
205
+ confirm: CONFIRM_PROP,
206
+ },
207
+ required: ["question_id", "answer", "confirm"],
208
+ },
209
+ },
210
+ {
211
+ name: "didit_investigator_question_dismiss",
212
+ description: "Close a policy question without an answer; the policy stays as it is." + APPROVAL_NOTE,
213
+ inputSchema: {
214
+ type: "object",
215
+ properties: { ...orgapp_1.ORG_APP_PROPS, question_id: { type: "string" }, confirm: CONFIRM_PROP },
216
+ required: ["question_id", "confirm"],
217
+ },
218
+ },
219
+ {
220
+ name: "didit_investigator_backtest_start",
221
+ description: "Start a FREE deterministic backtest: replay the current policy (or the setup or SOP draft) on the last 30 or 90 " +
222
+ "days of decisions and get agreement per queue and tier, with sample warnings. Decides nothing. Read it again " +
223
+ "with didit_investigator_backtest_get.",
224
+ inputSchema: {
225
+ type: "object",
226
+ properties: {
227
+ ...orgapp_1.ORG_APP_PROPS,
228
+ queues: { type: "array", items: { type: "string", enum: QUEUES }, description: "Queues to replay." },
229
+ period_days: { type: "number", enum: [30, 90], description: "Days to replay (30 by default)." },
230
+ source: { type: "string", enum: ["policy", "setup", "sop_draft"], description: "What to replay (policy by default)." },
231
+ },
232
+ required: ["queues"],
233
+ },
234
+ },
235
+ {
236
+ name: "didit_investigator_backtest_get",
237
+ description: "Get a stored free backtest: agreement for every queue, tier and threshold, and its sample warnings.",
238
+ inputSchema: {
239
+ type: "object",
240
+ properties: { ...orgapp_1.ORG_APP_PROPS, backtest_id: { type: "string" } },
241
+ required: ["backtest_id"],
242
+ },
243
+ },
244
+ {
245
+ name: "didit_investigator_performance_get",
246
+ description: "Get the Investigator's performance: agreement with the team, volume, time saved, calibration, per-queue numbers " +
247
+ "and overrides over 7, 30 or 90 days.",
248
+ inputSchema: {
249
+ type: "object",
250
+ properties: { ...orgapp_1.ORG_APP_PROPS, scope: SCOPE_PROP, period: { type: "number", enum: [7, 30, 90] } },
251
+ },
252
+ },
253
+ {
254
+ name: "didit_investigator_dashboard_get",
255
+ description: "Get the Investigator dashboard: 30-day automation, weekly history, spend, overrides and QA since go-live.",
256
+ inputSchema: { type: "object", properties: { ...orgapp_1.ORG_APP_PROPS, scope: SCOPE_PROP } },
257
+ },
258
+ {
259
+ name: "didit_investigator_activity_list",
260
+ description: "List the Investigator's append-only Activity log, newest first: what the agent and people did (reports, " +
261
+ "decisions, overrides, autonomy and guardrail changes), each with its actor and provenance.",
262
+ inputSchema: {
263
+ type: "object",
264
+ properties: {
265
+ ...orgapp_1.ORG_APP_PROPS,
266
+ scope: SCOPE_PROP,
267
+ group: { type: "string", enum: ACTIVITY_GROUPS },
268
+ actor: { type: "string", description: "'agent', or a person's email." },
269
+ since: { type: "string", description: "ISO date-time, inclusive." },
270
+ until: { type: "string", description: "ISO date-time, exclusive." },
271
+ ...PAGE_PROPS,
272
+ },
273
+ },
274
+ },
275
+ ];
276
+ const INVESTIGATOR_TOOL_NAMES = new Set(exports.INVESTIGATOR_TOOL_DEFS.map((tool) => tool.name));
277
+ function isInvestigatorToolName(name) {
278
+ return INVESTIGATOR_TOOL_NAMES.has(name);
279
+ }
280
+ /** The decisions, the policy answers and the re-review (it replaces the open report): annotated destructive,
281
+ * gated on confirm:true. */
282
+ exports.INVESTIGATOR_DECISION_TOOLS = [
283
+ "didit_investigator_accept",
284
+ "didit_investigator_override",
285
+ "didit_investigator_batch_accept",
286
+ "didit_investigator_question_answer",
287
+ "didit_investigator_question_dismiss",
288
+ "didit_investigator_rereview",
289
+ ];
290
+ /** Read-like by name, but it stores a backtest. */
291
+ exports.INVESTIGATOR_WRITE_TOOLS = ["didit_investigator_backtest_start"];
292
+ // What the backend checks for a console user. Reads and decisions accept ANY read/write
293
+ // permission over the item kinds (sessions, cases, transactions), which a single permission
294
+ // string cannot express: no pre-check there, the backend filters by kind.
295
+ exports.INVESTIGATOR_TOOL_PERMISSIONS = {
296
+ didit_investigator_queue_list: null, // GET /v3/investigator/queue/ — any read/list over the item kinds
297
+ didit_investigator_report_get: null, // GET runs/{id}/ — read over the item's kind
298
+ didit_investigator_accept: null, // POST runs/{id}/accept/ — write over the item's kind
299
+ didit_investigator_override: null, // POST runs/{id}/override/ — write over the item's kind
300
+ didit_investigator_batch_accept: null, // POST runs/batch-accept/ — write, per item
301
+ didit_investigator_add_note: null, // POST runs/{id}/notes/ — write over the item's kind
302
+ didit_investigator_rereview: null, // POST runs/{id}/rereview/ — write over the item's kind
303
+ didit_investigator_record_get: null, // GET sessions/{id}/ or transactions/{id}/ — read:sessions or read:transactions
304
+ didit_investigator_question_list: null, // GET questions/ — any read
305
+ didit_investigator_question_get: null, // GET questions/{id}/ — any read
306
+ didit_investigator_question_answer: null, // POST questions/{id}/answer/ — write over the question's item
307
+ didit_investigator_question_dismiss: null, // POST questions/{id}/dismiss/ — write over the question's item
308
+ didit_investigator_backtest_start: "write:applications", // POST backtests/ — InvestigatorConfigView write
309
+ didit_investigator_backtest_get: null, // GET backtests/{id}/ — any read (config read)
310
+ didit_investigator_performance_get: null, // GET performance/ — any read
311
+ didit_investigator_dashboard_get: null, // GET dashboard/ — any read
312
+ didit_investigator_activity_list: null, // GET activity/ — any read
313
+ };
314
+ /** The allowlisted X-Didit-Actor-Via of an incoming MCP request: "copilot" from the console
315
+ * assistant, anything else (absent, unknown) is "mcp". */
316
+ function actorViaFromHeaders(headers) {
317
+ const raw = headers?.["x-didit-actor-via"];
318
+ const value = (Array.isArray(raw) ? raw[0] : raw)?.trim().toLowerCase();
319
+ return value === "copilot" ? "copilot" : "mcp";
320
+ }
321
+ function clientHeaders() {
322
+ return {
323
+ ...(0, config_1.getHeaders)(),
324
+ "X-Didit-Organization-Id": (0, config_1.resolveOrganizationId)(),
325
+ "X-Didit-Application-Id": (0, config_1.resolveApplicationId)(),
326
+ "X-Didit-Actor-Via": config_1.requestContext.getStore()?.actorVia ?? "mcp",
327
+ };
328
+ }
329
+ function call(path, opts = {}) {
330
+ return (0, config_1.apiRequest)(path, { ...opts, headers: clientHeaders() });
331
+ }
332
+ function assertConfirmed(confirm, what, why = DECISION_REASON) {
333
+ (0, security_1.assertBoolean)(confirm, "confirm");
334
+ if (confirm !== true) {
335
+ throw new security_1.DiditError({
336
+ code: "unsafe_operation",
337
+ message: `${what} ${why}.`,
338
+ field: "confirm",
339
+ hint: "Show the user the exact action, and re-call with confirm:true only once they have explicitly approved it.",
340
+ });
341
+ }
342
+ }
343
+ function pick(args, keys) {
344
+ const out = {};
345
+ for (const key of keys) {
346
+ if (args[key] !== undefined && args[key] !== null && args[key] !== "")
347
+ out[key] = args[key];
348
+ }
349
+ return out;
350
+ }
351
+ const runPath = (id) => `/investigator/runs/${(0, security_1.pathSegment)(id, "run_id")}/`;
352
+ const questionPath = (id) => `/investigator/questions/${(0, security_1.pathSegment)(id, "question_id")}/`;
353
+ /** The record path for exactly one of session_id or transaction_id. */
354
+ function recordPath(args) {
355
+ const ids = pick(args, ["session_id", "transaction_id"]);
356
+ if (Object.keys(ids).length !== 1) {
357
+ throw new security_1.DiditError({
358
+ code: "bad_request",
359
+ message: "Pass exactly one of session_id or transaction_id.",
360
+ field: "session_id",
361
+ });
362
+ }
363
+ return ids.session_id
364
+ ? `/investigator/sessions/${(0, security_1.pathSegment)(ids.session_id, "session_id")}/`
365
+ : `/investigator/transactions/${(0, security_1.pathSegment)(ids.transaction_id, "transaction_id")}/`;
366
+ }
367
+ /** The note text: trimmed, required unless optional, at most NOTE_MAX_LENGTH characters. */
368
+ function noteText(value, required) {
369
+ const note = typeof value === "string" ? value.trim() : "";
370
+ if (required && !note) {
371
+ throw new security_1.DiditError({ code: "bad_request", message: "note is required.", field: "note" });
372
+ }
373
+ if (note.length > NOTE_MAX_LENGTH) {
374
+ throw new security_1.DiditError({ code: "bad_request", message: `note must be at most ${NOTE_MAX_LENGTH} characters.`, field: "note" });
375
+ }
376
+ return note;
377
+ }
378
+ async function dispatchInvestigatorTool(name, rawArgs) {
379
+ const args = rawArgs ?? {};
380
+ switch (name) {
381
+ case "didit_investigator_queue_list": {
382
+ const params = pick(args, ["scope", "kind", "queue", "recommendation", "confidence", "search", "limit", "offset"]);
383
+ if (typeof args.ready === "boolean")
384
+ params.ready = String(args.ready);
385
+ return call("/investigator/queue/", { params });
386
+ }
387
+ case "didit_investigator_report_get":
388
+ return call(runPath(args.run_id));
389
+ case "didit_investigator_accept":
390
+ assertConfirmed(args.confirm, "Accepting a recommendation");
391
+ return call(`${runPath(args.run_id)}accept/`, { method: "POST", json: pick(args, ["narrative"]) });
392
+ case "didit_investigator_override":
393
+ assertConfirmed(args.confirm, "Overriding a recommendation");
394
+ return call(`${runPath(args.run_id)}override/`, {
395
+ method: "POST",
396
+ json: pick(args, ["action", "category", "reason"]),
397
+ });
398
+ case "didit_investigator_batch_accept": {
399
+ assertConfirmed(args.confirm, "Accepting a batch of recommendations");
400
+ const runIds = args.run_ids;
401
+ if (!Array.isArray(runIds) || runIds.length === 0 || runIds.length > BATCH_ACCEPT_LIMIT) {
402
+ throw new security_1.DiditError({
403
+ code: "bad_request",
404
+ message: `run_ids must list 1 to ${BATCH_ACCEPT_LIMIT} run ids.`,
405
+ field: "run_ids",
406
+ });
407
+ }
408
+ return call("/investigator/runs/batch-accept/", {
409
+ method: "POST",
410
+ json: { run_ids: runIds.map((id) => (0, security_1.pathSegment)(id, "run_ids")) },
411
+ });
412
+ }
413
+ case "didit_investigator_add_note":
414
+ return call(`${runPath(args.run_id)}notes/`, { method: "POST", json: { text: noteText(args.note, true) } });
415
+ case "didit_investigator_rereview": {
416
+ assertConfirmed(args.confirm, "Re-reviewing an item", REREVIEW_REASON);
417
+ const note = noteText(args.note, false);
418
+ return call(`${runPath(args.run_id)}rereview/`, { method: "POST", json: note ? { note } : {} });
419
+ }
420
+ case "didit_investigator_record_get":
421
+ return call(recordPath(args));
422
+ case "didit_investigator_question_list":
423
+ return call("/investigator/questions/", { params: pick(args, ["status"]) });
424
+ case "didit_investigator_question_get":
425
+ return call(questionPath(args.question_id));
426
+ case "didit_investigator_question_answer":
427
+ assertConfirmed(args.confirm, "Answering a policy question");
428
+ return call(`${questionPath(args.question_id)}answer/`, {
429
+ method: "POST",
430
+ json: pick(args, ["answer", "detail"]),
431
+ });
432
+ case "didit_investigator_question_dismiss":
433
+ assertConfirmed(args.confirm, "Dismissing a policy question");
434
+ return call(`${questionPath(args.question_id)}dismiss/`, { method: "POST" });
435
+ case "didit_investigator_backtest_start":
436
+ return call("/investigator/backtests/", { method: "POST", json: pick(args, ["queues", "period_days", "source"]) });
437
+ case "didit_investigator_backtest_get":
438
+ return call(`/investigator/backtests/${(0, security_1.pathSegment)(args.backtest_id, "backtest_id")}/`);
439
+ case "didit_investigator_performance_get":
440
+ return call("/investigator/performance/", { params: pick(args, ["scope", "period"]) });
441
+ case "didit_investigator_dashboard_get":
442
+ return call("/investigator/dashboard/", { params: pick(args, ["scope"]) });
443
+ case "didit_investigator_activity_list":
444
+ return call("/investigator/activity/", { params: pick(args, ["scope", "group", "actor", "since", "until", "limit", "offset"]) });
445
+ default:
446
+ throw new Error(`Unknown tool: ${name}`);
447
+ }
448
+ }
449
+ //# sourceMappingURL=investigator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"investigator.js","sourceRoot":"","sources":["../../src/tools/investigator.ts"],"names":[],"mappings":";;;AAuTA,wDAEC;AAyCD,kDAIC;AAiED,4DAqEC;AA5eD,sCAAgH;AAChH,sCAA0C;AAC1C,0CAAqE;AAkBrE,MAAM,MAAM,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;AAC9D,MAAM,KAAK,GAAG,CAAC,SAAS,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,CAAC,CAAC;AACrE,MAAM,eAAe,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;AACtE,MAAM,mBAAmB,GAAG,CAAC,iBAAiB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,OAAO,CAAC,CAAC;AACpH,MAAM,cAAc,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;AACnE,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;AAC5D,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;AACxE,MAAM,MAAM,GAAG,CAAC,KAAK,EAAE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K,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC"}
@@ -4,4 +4,12 @@ export declare function updateMember(memberId: string, data: Record<string, any>
4
4
  export declare function removeMember(memberId: string, organizationId?: string): Promise<any>;
5
5
  export declare function listRoles(organizationId?: string): Promise<any>;
6
6
  export declare function listApiKeys(organizationId?: string, applicationId?: string): Promise<any>;
7
+ /**
8
+ * Create the ONE API key this connected app may hold for an application (the x-api-key the integration
9
+ * being built sends to the verification API). The backend enforces every rule: scoped to what the
10
+ * signed-in person can do within the grant (never full access, never API key management), one live
11
+ * key per connected app and application (409 otherwise), rate-limited, audit-logged, listed with the
12
+ * connected app in the console and revoked with it. The secret is in this response only.
13
+ */
14
+ export declare function createApiKey(organizationId: unknown, applicationId: unknown, args: Record<string, any>): Promise<any>;
7
15
  //# sourceMappingURL=members.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"members.d.ts","sourceRoot":"","sources":["../../src/tools/members.ts"],"names":[],"mappings":"AAUA,wBAAsB,WAAW,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAGrG;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAUnG;AAED,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAUrH;AAED,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAI1F;AAED,wBAAsB,SAAS,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAGrE;AAED,wBAAsB,WAAW,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAQ/F"}
1
+ {"version":3,"file":"members.d.ts","sourceRoot":"","sources":["../../src/tools/members.ts"],"names":[],"mappings":"AAUA,wBAAsB,WAAW,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAGrG;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAUnG;AAED,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAUrH;AAED,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAI1F;AAED,wBAAsB,SAAS,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAGrE;AAED,wBAAsB,WAAW,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAc/F;AASD;;;;;;GAMG;AACH,wBAAsB,YAAY,CAChC,cAAc,EAAE,OAAO,EACvB,aAAa,EAAE,OAAO,EACtB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACxB,OAAO,CAAC,GAAG,CAAC,CAgDd"}
@@ -6,6 +6,7 @@ exports.updateMember = updateMember;
6
6
  exports.removeMember = removeMember;
7
7
  exports.listRoles = listRoles;
8
8
  exports.listApiKeys = listApiKeys;
9
+ exports.createApiKey = createApiKey;
9
10
  const config_1 = require("../config");
10
11
  const security_1 = require("../security");
11
12
  // Org members / roles / API keys — served by service-didit-auth (apx/auth/v2), org-level,
@@ -50,11 +51,79 @@ async function listRoles(organizationId) {
50
51
  }
51
52
  async function listApiKeys(organizationId, applicationId) {
52
53
  const org = (0, config_1.resolveOrganizationId)(organizationId);
53
- // Console api-keys are nested under the application; if an app id is given use it.
54
- const path = applicationId
55
- ? `/organizations/${(0, security_1.pathSegment)(org, "organization_id")}/applications/${(0, security_1.pathSegment)(applicationId, "application_id")}/api-keys/`
56
- : authPath(org, "/api-keys/");
54
+ // API keys exist only under their application: there is no organization-level route.
55
+ if (!applicationId) {
56
+ throw new security_1.DiditError({
57
+ code: "bad_request",
58
+ message: "application_id is required: API keys belong to an application.",
59
+ field: "application_id",
60
+ hint: "Read the organization's applications with didit_context_get, then call this once per application.",
61
+ });
62
+ }
63
+ const path = `/organizations/${(0, security_1.pathSegment)(org, "organization_id")}/applications/${(0, security_1.pathSegment)(applicationId, "application_id")}/api-keys/`;
57
64
  const res = await (0, config_1.apiRequest)(path, { baseUrl: config_1.DIDIT_AUTH_BASE_URL });
58
65
  return (0, security_1.redactCollection)(res, security_1.redactApiKey);
59
66
  }
67
+ // What an agent key may be limited to; the auth service caps it at the signed-in person and the
68
+ // grant whatever is asked (service-didit-auth organizations/services/agent_api_keys.py).
69
+ const KEY_RESOURCES = [
70
+ "sessions", "decisions", "media", "users", "businesses", "transactions", "workflows", "webhooks", "applications", "analytics",
71
+ ];
72
+ const KEY_LEVELS = ["read", "write"];
73
+ /**
74
+ * Create the ONE API key this connected app may hold for an application (the x-api-key the integration
75
+ * being built sends to the verification API). The backend enforces every rule: scoped to what the
76
+ * signed-in person can do within the grant (never full access, never API key management), one live
77
+ * key per connected app and application (409 otherwise), rate-limited, audit-logged, listed with the
78
+ * connected app in the console and revoked with it. The secret is in this response only.
79
+ */
80
+ async function createApiKey(organizationId, applicationId, args) {
81
+ if (typeof organizationId !== "string" || !organizationId.trim() || typeof applicationId !== "string" || !applicationId.trim()) {
82
+ throw new security_1.DiditError({
83
+ code: "missing_scope",
84
+ message: "organization_id and application_id must both be passed explicitly to create an API key.",
85
+ hint: "Read them from didit_context_get. Use the application's mode: a sandbox key for building and testing, a live key to go live.",
86
+ });
87
+ }
88
+ (0, security_1.assertBoolean)(args?.confirm, "confirm");
89
+ if (args?.confirm !== true) {
90
+ throw new security_1.DiditError({
91
+ code: "unsafe_operation",
92
+ message: "Creating an API key issues a live credential. Re-call with confirm:true once the person agreed.",
93
+ field: "confirm",
94
+ hint: "Say which application the key is for and where you will store it (a secret manager or the project's .env, never committed).",
95
+ });
96
+ }
97
+ const body = { label: typeof args?.label === "string" && args.label.trim() ? args.label.trim() : "Created by an AI agent" };
98
+ if (args?.scopes !== undefined) {
99
+ const scopes = args.scopes;
100
+ if (!scopes || typeof scopes !== "object" || Array.isArray(scopes)) {
101
+ throw new security_1.DiditError({ code: "bad_request", message: "scopes must be an object of resource to read or write.", field: "scopes", allowed: KEY_RESOURCES });
102
+ }
103
+ for (const [resource, level] of Object.entries(scopes)) {
104
+ if (!KEY_RESOURCES.includes(resource) || !KEY_LEVELS.includes(String(level))) {
105
+ throw new security_1.DiditError({
106
+ code: "bad_request",
107
+ message: `scopes.${resource} must be one of ${KEY_RESOURCES.join(", ")} set to read or write.`,
108
+ field: "scopes",
109
+ allowed: KEY_RESOURCES,
110
+ });
111
+ }
112
+ }
113
+ body.scopes = scopes;
114
+ }
115
+ for (const field of ["workflow_ids", "approved_sessions_only", "allowed_ips", "expires_at"]) {
116
+ if (args?.[field] !== undefined)
117
+ body[field] = args[field];
118
+ }
119
+ const path = `/organizations/${(0, security_1.pathSegment)(organizationId, "organization_id")}/applications/${(0, security_1.pathSegment)(applicationId, "application_id")}/api-keys/`;
120
+ const created = await (0, config_1.apiRequest)(path, { method: "POST", baseUrl: config_1.DIDIT_AUTH_BASE_URL, json: body });
121
+ return {
122
+ ...created,
123
+ shown_once: true,
124
+ next_steps: "Store api_key now in the project's secret store or .env (never commit it, never repeat it in the chat): it is " +
125
+ "never shown again. Send it as the x-api-key header to https://verification.didit.me/v3. The person can see and " +
126
+ "revoke this key in the Didit console under the application's API keys and with this connected app.",
127
+ };
128
+ }
60
129
  //# sourceMappingURL=members.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"members.js","sourceRoot":"","sources":["../../src/tools/members.ts"],"names":[],"mappings":";;AAUA,kCAGC;AAED,oCAUC;AAED,oCAUC;AAED,oCAIC;AAED,8BAGC;AAED,kCAQC;AA1DD,sCAAmF;AACnF,0CAA0E;AAE1E,0FAA0F;AAC1F,gGAAgG;AAEhG,SAAS,QAAQ,CAAC,GAAW,EAAE,QAAgB;IAC7C,OAAO,kBAAkB,IAAA,sBAAW,EAAC,GAAG,EAAE,iBAAiB,CAAC,GAAG,QAAQ,EAAE,CAAC;AAC5E,CAAC;AAEM,KAAK,UAAU,WAAW,CAAC,cAAuB,EAAE,MAA4B;IACrF,MAAM,GAAG,GAAG,IAAA,8BAAqB,EAAC,cAAc,CAAC,CAAC;IAClD,OAAO,IAAA,mBAAU,EAAC,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC,EAAE,EAAE,OAAO,EAAE,4BAAmB,EAAE,MAAM,EAAE,CAAC,CAAC;AAC1F,CAAC;AAEM,KAAK,UAAU,YAAY,CAAC,IAAyB,EAAE,cAAuB;IACnF,MAAM,GAAG,GAAG,IAAA,8BAAqB,EAAC,cAAc,CAAC,CAAC;IAClD,0FAA0F;IAC1F,0FAA0F;IAC1F,4EAA4E;IAC5E,OAAO,IAAA,mBAAU,EAAC,QAAQ,CAAC,GAAG,EAAE,kBAAkB,CAAC,EAAE;QACnD,OAAO,EAAE,4BAAmB;QAC5B,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,E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AAC,CAAC,EAAE,CAAC;gBAC7E,MAAM,IAAI,qBAAU,CAAC;oBACnB,IAAI,EAAE,aAAa;oBACnB,OAAO,EAAE,UAAU,QAAQ,mBAAmB,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,wBAAwB;oBAC9F,KAAK,EAAE,QAAQ;oBACf,OAAO,EAAE,aAAa;iBACvB,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IACD,KAAK,MAAM,KAAK,IAAI,CAAC,cAAc,EAAE,wBAAwB,EAAE,aAAa,EAAE,YAAY,CAAC,EAAE,CAAC;QAC5F,IAAI,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,SAAS;YAAE,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7D,CAAC;IACD,MAAM,IAAI,GAAG,kBAAkB,IAAA,sBAAW,EAAC,cAAc,EAAE,iBAAiB,CAAC,iBAAiB,IAAA,sBAAW,EAAC,aAAa,EAAE,gBAAgB,CAAC,YAAY,CAAC;IACvJ,MAAM,OAAO,GAAG,MAAM,IAAA,mBAAU,EAAC,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,4BAAmB,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IACrG,OAAO;QACL,GAAG,OAAO;QACV,UAAU,EAAE,IAAI;QAChB,UAAU,EACR,gHAAgH;YAChH,iHAAiH;YACjH,oGAAoG;KACvG,CAAC;AACJ,CAAC"}
@@ -1,3 +1,9 @@
1
+ /**
2
+ * The organization's audit log: `/audit/{org}/audit-logs/` on the verification API
3
+ * (service-didit-verification audit/urls.py), outside `/organization/`, so neither orgPath
4
+ * nor orgAppPath builds it. Every other argument is a list filter: an explicit
5
+ * `application_id` narrows the log to that application instead of routing the request.
6
+ */
1
7
  export declare function listAuditLogs(params?: Record<string, any>): Promise<any>;
2
8
  export declare function listAlerts(params?: Record<string, any>): Promise<any>;
3
9
  export declare function configureAlert(alertType: string, data: Record<string, any>): Promise<any>;
@@ -1 +1 @@
1
- {"version":3,"file":"observability.d.ts","sourceRoot":"","sources":["../../src/tools/observability.ts"],"names":[],"mappings":"AAKA,wBAAsB,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAE9E;AAED,wBAAsB,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAE3E;AAED,wBAAsB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAE/F"}
1
+ {"version":3,"file":"observability.d.ts","sourceRoot":"","sources":["../../src/tools/observability.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAKlF;AAED,wBAAsB,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAE3E;AAED,wBAAsB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAE/F"}