@keystrokehq/keystroke 1.0.8 → 1.0.9

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 (91) hide show
  1. package/dist/action.cjs +3 -1
  2. package/dist/action.d.cts +3 -3
  3. package/dist/action.d.mts +3 -3
  4. package/dist/action.mjs +2 -2
  5. package/dist/agent.cjs +21 -10
  6. package/dist/agent.cjs.map +1 -1
  7. package/dist/agent.d.cts +2 -2
  8. package/dist/agent.d.mts +2 -2
  9. package/dist/agent.mjs +21 -10
  10. package/dist/agent.mjs.map +1 -1
  11. package/dist/app.cjs +1 -1
  12. package/dist/app.d.cts +2 -2
  13. package/dist/app.d.mts +2 -2
  14. package/dist/app.mjs +1 -1
  15. package/dist/client.cjs +13 -7
  16. package/dist/client.cjs.map +1 -1
  17. package/dist/client.d.cts.map +1 -1
  18. package/dist/client.d.mts.map +1 -1
  19. package/dist/client.mjs +13 -7
  20. package/dist/client.mjs.map +1 -1
  21. package/dist/config.d.cts +1 -1
  22. package/dist/config.d.mts +1 -1
  23. package/dist/credentials.cjs +1 -1
  24. package/dist/credentials.d.cts +1 -1
  25. package/dist/credentials.d.mts +1 -1
  26. package/dist/credentials.mjs +1 -1
  27. package/dist/{dist-DQL6zTI5.cjs → dist-C0fPHFaM.cjs} +20 -11
  28. package/dist/dist-C0fPHFaM.cjs.map +1 -0
  29. package/dist/{dist-DqFdFpiB.mjs → dist-CppO7361.mjs} +92 -9
  30. package/dist/dist-CppO7361.mjs.map +1 -0
  31. package/dist/{dist-C5otI4u3.cjs → dist-DivFQzKG.cjs} +236 -41
  32. package/dist/dist-DivFQzKG.cjs.map +1 -0
  33. package/dist/{dist-DOMwPx7V.cjs → dist-HI6bM6LK.cjs} +103 -8
  34. package/dist/dist-HI6bM6LK.cjs.map +1 -0
  35. package/dist/{dist-IUl7Bexl.mjs → dist-UzTnzZem.mjs} +231 -42
  36. package/dist/dist-UzTnzZem.mjs.map +1 -0
  37. package/dist/{dist-BpkCqbil.mjs → dist-nvW8vbKn.mjs} +20 -11
  38. package/dist/dist-nvW8vbKn.mjs.map +1 -0
  39. package/dist/{index-BMqj40Li.d.cts → index-3P7ec4Vo.d.cts} +4 -2
  40. package/dist/index-3P7ec4Vo.d.cts.map +1 -0
  41. package/dist/{index-nUAXCgEe.d.cts → index-BTz2OMAM.d.cts} +13 -3
  42. package/dist/index-BTz2OMAM.d.cts.map +1 -0
  43. package/dist/{index-8_UEbXaF.d.mts → index-Cq2F2XdS.d.mts} +13 -3
  44. package/dist/index-Cq2F2XdS.d.mts.map +1 -0
  45. package/dist/{index-Dgy9MjuX.d.cts → index-D4dAsbJr.d.cts} +20 -3
  46. package/dist/index-D4dAsbJr.d.cts.map +1 -0
  47. package/dist/{index-CWZAGTad.d.mts → index-D7UUmswR.d.mts} +4 -2
  48. package/dist/index-D7UUmswR.d.mts.map +1 -0
  49. package/dist/{index-BeBgntxT.d.mts → index-DdAOmbQc.d.mts} +9 -16
  50. package/dist/index-DdAOmbQc.d.mts.map +1 -0
  51. package/dist/{index-BY9SPR2h.d.cts → index-Ohwnfidc.d.cts} +9 -16
  52. package/dist/index-Ohwnfidc.d.cts.map +1 -0
  53. package/dist/{index-Bl4VEelg.d.mts → index-Sx9T2i0u.d.mts} +20 -3
  54. package/dist/index-Sx9T2i0u.d.mts.map +1 -0
  55. package/dist/{index-e9f4pcX4.d.cts → index-WT4ULMiw.d.cts} +14 -3
  56. package/dist/index-WT4ULMiw.d.cts.map +1 -0
  57. package/dist/{index-e9f4pcX4.d.mts → index-WT4ULMiw.d.mts} +14 -3
  58. package/dist/index-WT4ULMiw.d.mts.map +1 -0
  59. package/dist/{mistral-wOLLEgb9.cjs → mistral-CSlOhLAJ.cjs} +2 -2
  60. package/dist/{mistral-wOLLEgb9.cjs.map → mistral-CSlOhLAJ.cjs.map} +1 -1
  61. package/dist/{mistral-CMDejXQt.mjs → mistral-StBMjPiK.mjs} +2 -2
  62. package/dist/{mistral-CMDejXQt.mjs.map → mistral-StBMjPiK.mjs.map} +1 -1
  63. package/dist/{sse-DI7TsPKG.mjs → sse-CDOw-yuH.mjs} +2 -2
  64. package/dist/{sse-DI7TsPKG.mjs.map → sse-CDOw-yuH.mjs.map} +1 -1
  65. package/dist/{sse-Dzs73rQw.cjs → sse-CZOklzgA.cjs} +2 -2
  66. package/dist/{sse-Dzs73rQw.cjs.map → sse-CZOklzgA.cjs.map} +1 -1
  67. package/dist/trigger.cjs +1 -1
  68. package/dist/trigger.d.cts +3 -3
  69. package/dist/trigger.d.mts +3 -3
  70. package/dist/trigger.mjs +1 -1
  71. package/dist/workflow.cjs +1 -1
  72. package/dist/workflow.d.cts +2 -2
  73. package/dist/workflow.d.mts +2 -2
  74. package/dist/workflow.mjs +1 -1
  75. package/package.json +1 -1
  76. package/dist/dist-BpkCqbil.mjs.map +0 -1
  77. package/dist/dist-C5otI4u3.cjs.map +0 -1
  78. package/dist/dist-DOMwPx7V.cjs.map +0 -1
  79. package/dist/dist-DQL6zTI5.cjs.map +0 -1
  80. package/dist/dist-DqFdFpiB.mjs.map +0 -1
  81. package/dist/dist-IUl7Bexl.mjs.map +0 -1
  82. package/dist/index-8_UEbXaF.d.mts.map +0 -1
  83. package/dist/index-BMqj40Li.d.cts.map +0 -1
  84. package/dist/index-BY9SPR2h.d.cts.map +0 -1
  85. package/dist/index-BeBgntxT.d.mts.map +0 -1
  86. package/dist/index-Bl4VEelg.d.mts.map +0 -1
  87. package/dist/index-CWZAGTad.d.mts.map +0 -1
  88. package/dist/index-Dgy9MjuX.d.cts.map +0 -1
  89. package/dist/index-e9f4pcX4.d.cts.map +0 -1
  90. package/dist/index-e9f4pcX4.d.mts.map +0 -1
  91. package/dist/index-nUAXCgEe.d.cts.map +0 -1
@@ -683,7 +683,8 @@ const storedRouteManifestEntryV2Schema = zod.z.discriminatedUnion("kind", [
683
683
  systemPrompt: zod.z.string(),
684
684
  toolCount: zod.z.number().int().nonnegative(),
685
685
  credentialCount: zod.z.number().int().nonnegative(),
686
- credentialKeys: zod.z.array(zod.z.string()).default([])
686
+ appSlugs: zod.z.array(zod.z.string()).default([]),
687
+ toolSlugs: zod.z.array(zod.z.string()).default([])
687
688
  }),
688
689
  zod.z.object({
689
690
  kind: zod.z.literal("workflow"),
@@ -1117,6 +1118,45 @@ zod.z.object({
1117
1118
  }).refine((input) => input.label !== void 0 || input.isDefault !== void 0 || input.value !== void 0, { message: "At least one field is required" });
1118
1119
  zod.z.array(AppCredentialSummarySchema);
1119
1120
  zod.z.array(AppCredentialSummarySchema);
1121
+ const CredentialAssignmentTargetTypeSchema = zod.z.enum(["workflow", "agent"]);
1122
+ const CredentialAssignmentRecordSchema = zod.z.object({
1123
+ id: zod.z.string(),
1124
+ targetType: CredentialAssignmentTargetTypeSchema,
1125
+ targetKey: zod.z.string(),
1126
+ consumerId: zod.z.string(),
1127
+ credentialSlug: zod.z.string(),
1128
+ instanceId: zod.z.string(),
1129
+ credential: zod.z.string().optional(),
1130
+ scopeType: zod.z.enum([
1131
+ "organization",
1132
+ "project",
1133
+ "user"
1134
+ ]).optional(),
1135
+ createdAt: zod.z.string(),
1136
+ updatedAt: zod.z.string()
1137
+ });
1138
+ zod.z.object({ assignments: zod.z.array(CredentialAssignmentRecordSchema) });
1139
+ zod.z.object({
1140
+ targetType: CredentialAssignmentTargetTypeSchema,
1141
+ targetKey: zod.z.string().min(1),
1142
+ /** Omit or '*' for wildcard assignment. */
1143
+ consumerId: zod.z.string().optional(),
1144
+ credential: zod.z.string().min(1)
1145
+ });
1146
+ zod.z.object({
1147
+ targetType: CredentialAssignmentTargetTypeSchema,
1148
+ targetKey: zod.z.string().min(1)
1149
+ });
1150
+ zod.z.object({
1151
+ targetType: CredentialAssignmentTargetTypeSchema,
1152
+ targetKey: zod.z.string().min(1)
1153
+ });
1154
+ const CredentialConsumerSummarySchema = zod.z.object({
1155
+ consumerId: zod.z.string(),
1156
+ label: zod.z.string(),
1157
+ appSlugs: zod.z.array(zod.z.string())
1158
+ });
1159
+ zod.z.object({ consumers: zod.z.array(CredentialConsumerSummarySchema) });
1120
1160
  const McpConnectionStatusSchema = zod.z.enum([
1121
1161
  "INITIATED",
1122
1162
  "ACTIVE",
@@ -1147,12 +1187,20 @@ const KeystrokeCredentialSchema = zod.z.object({
1147
1187
  entityId: zod.z.string(),
1148
1188
  instanceId: zod.z.string()
1149
1189
  });
1190
+ const McpCredentialAssignmentTargetSchema = zod.z.object({
1191
+ type: CredentialAssignmentTargetTypeSchema,
1192
+ key: zod.z.string().trim().min(1)
1193
+ });
1150
1194
  zod.z.object({
1151
1195
  app: zod.z.string().trim().min(1),
1152
1196
  tool: zod.z.string().trim().min(1),
1153
1197
  arguments: zod.z.record(zod.z.string(), zod.z.unknown()).default({}),
1154
1198
  /** Pinned provider toolkit version, sourced from the app definition; forwarded to the provider. */
1155
- version: zod.z.string().trim().min(1)
1199
+ version: zod.z.string().trim().min(1),
1200
+ /** When set, platform MCP resolve checks credential assignments before scope defaults. */
1201
+ assignmentTarget: McpCredentialAssignmentTargetSchema.optional(),
1202
+ /** Tool/step consumer id for assignment lookup (action slug or workflow step correlation id). */
1203
+ consumerId: zod.z.string().trim().min(1).optional()
1156
1204
  });
1157
1205
  const TeamRequestTypeSchema = zod.z.enum([
1158
1206
  "org-deletion",
@@ -1794,7 +1842,9 @@ zod.z.object({
1794
1842
  });
1795
1843
  const CredentialInstanceRecordSchema = zod.z.object({
1796
1844
  id: zod.z.string(),
1797
- key: zod.z.string(),
1845
+ appSlug: zod.z.string(),
1846
+ slug: zod.z.string(),
1847
+ name: zod.z.string().nullable(),
1798
1848
  scopeType: CredentialScopeTypeSchema,
1799
1849
  scopeId: zod.z.string().nullable(),
1800
1850
  label: zod.z.string().nullable(),
@@ -1804,6 +1854,8 @@ const CredentialInstanceRecordSchema = zod.z.object({
1804
1854
  zod.z.object({ instances: zod.z.array(CredentialInstanceRecordSchema) });
1805
1855
  zod.z.object({
1806
1856
  key: zod.z.string().min(1),
1857
+ slug: zod.z.string().min(1).optional(),
1858
+ name: zod.z.string().nullable().optional(),
1807
1859
  scopeType: CredentialScopeTypeSchema,
1808
1860
  scopeId: zod.z.string().nullable().optional(),
1809
1861
  label: zod.z.string().nullable().optional(),
@@ -1811,6 +1863,8 @@ zod.z.object({
1811
1863
  value: zod.z.record(zod.z.string(), zod.z.unknown()).refine((value) => Object.keys(value).length > 0, { message: "value must be a non-empty object" })
1812
1864
  });
1813
1865
  zod.z.object({
1866
+ slug: zod.z.string().min(1).optional(),
1867
+ name: zod.z.string().nullable().optional(),
1814
1868
  label: zod.z.string().nullable().optional(),
1815
1869
  isDefault: zod.z.boolean().optional(),
1816
1870
  value: zod.z.record(zod.z.string(), zod.z.unknown()).refine((value) => Object.keys(value).length > 0, { message: "value must be a non-empty object" }).optional()
@@ -2334,11 +2388,11 @@ function runWithRunSignal(signal, fn) {
2334
2388
  function getRunSignal() {
2335
2389
  return runSignalStorage.getStore() ?? NEVER_ABORT;
2336
2390
  }
2337
- const REGISTRY_KEY$1 = Symbol.for("keystroke.workflowRunGetter");
2391
+ const REGISTRY_KEY$2 = Symbol.for("keystroke.workflowRunGetter");
2338
2392
  function registry$1() {
2339
2393
  const globalScope = globalThis;
2340
- if (!globalScope[REGISTRY_KEY$1]) globalScope[REGISTRY_KEY$1] = {};
2341
- return globalScope[REGISTRY_KEY$1];
2394
+ if (!globalScope[REGISTRY_KEY$2]) globalScope[REGISTRY_KEY$2] = {};
2395
+ return globalScope[REGISTRY_KEY$2];
2342
2396
  }
2343
2397
  function registerWorkflowRunGetter(fn) {
2344
2398
  registry$1().getter = fn;
@@ -2429,6 +2483,32 @@ async function executeAction(action, input, credentials = {}) {
2429
2483
  const result = await action.run(validatedInput, credentials);
2430
2484
  return action.output.parse(result);
2431
2485
  }
2486
+ /**
2487
+ * The store lives in a global `Symbol.for` slot rather than a module-level `const` so a single
2488
+ * `AsyncLocalStorage` instance is shared even when the bundled `@keystrokehq/keystroke` facade
2489
+ * ships its own copy of this module: the worker sets context via `runWithMcpCredentialContext`
2490
+ * and the facade reads it via `getRegisteredMcpCredentialContext` against the same instance.
2491
+ */
2492
+ const REGISTRY_KEY$1 = Symbol.for("keystroke.mcpCredentialContextStore");
2493
+ function store() {
2494
+ const globalScope = globalThis;
2495
+ if (!globalScope[REGISTRY_KEY$1]) globalScope[REGISTRY_KEY$1] = new node_async_hooks.AsyncLocalStorage();
2496
+ return globalScope[REGISTRY_KEY$1];
2497
+ }
2498
+ function getRegisteredMcpCredentialContext() {
2499
+ return store().getStore();
2500
+ }
2501
+ /**
2502
+ * Run `fn` with MCP credential context active for its entire async execution. Nested calls merge
2503
+ * over the enclosing context, so an agent's assignment target and a per-tool consumer id compose.
2504
+ */
2505
+ function runWithMcpCredentialContext(context, fn) {
2506
+ const als = store();
2507
+ return als.run({
2508
+ ...als.getStore(),
2509
+ ...context
2510
+ }, fn);
2511
+ }
2432
2512
  function resolveActionTool(action, options) {
2433
2513
  const consumer = options?.consumer ?? {
2434
2514
  kind: "tool",
@@ -2446,7 +2526,10 @@ function resolveActionTool(action, options) {
2446
2526
  if (!options?.resolveCredentials) throw new Error(`Missing credential resolver for action "${action.slug}"`);
2447
2527
  credentials = await options.resolveCredentials(requirements, consumer, options.contextOverride);
2448
2528
  }
2449
- const output = await runOutsideActionExecution(() => executeAction(action, params, credentials));
2529
+ const output = await runWithMcpCredentialContext({
2530
+ ...options?.mcpCredentialContext,
2531
+ consumerId: consumer.id ?? consumer.name
2532
+ }, () => runOutsideActionExecution(() => executeAction(action, params, credentials)));
2450
2533
  return {
2451
2534
  content: [{
2452
2535
  type: "text",
@@ -2530,6 +2613,12 @@ Object.defineProperty(exports, "getActionCredentialRequirements", {
2530
2613
  return getActionCredentialRequirements;
2531
2614
  }
2532
2615
  });
2616
+ Object.defineProperty(exports, "getRegisteredMcpCredentialContext", {
2617
+ enumerable: true,
2618
+ get: function() {
2619
+ return getRegisteredMcpCredentialContext;
2620
+ }
2621
+ });
2533
2622
  Object.defineProperty(exports, "getRegisteredProjectScopeId", {
2534
2623
  enumerable: true,
2535
2624
  get: function() {
@@ -2608,6 +2697,12 @@ Object.defineProperty(exports, "runOutsideActionExecution", {
2608
2697
  return runOutsideActionExecution;
2609
2698
  }
2610
2699
  });
2700
+ Object.defineProperty(exports, "runWithMcpCredentialContext", {
2701
+ enumerable: true,
2702
+ get: function() {
2703
+ return runWithMcpCredentialContext;
2704
+ }
2705
+ });
2611
2706
  Object.defineProperty(exports, "runWithRunSignal", {
2612
2707
  enumerable: true,
2613
2708
  get: function() {
@@ -2633,4 +2728,4 @@ Object.defineProperty(exports, "toolParameters", {
2633
2728
  }
2634
2729
  });
2635
2730
 
2636
- //# sourceMappingURL=dist-DOMwPx7V.cjs.map
2731
+ //# sourceMappingURL=dist-HI6bM6LK.cjs.map