@keystrokehq/keystroke 0.0.173 → 0.0.175

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 +2 -3
  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 +3 -3
  6. package/dist/agent.d.cts +2 -2
  7. package/dist/agent.d.mts +2 -2
  8. package/dist/agent.mjs +3 -3
  9. package/dist/app.cjs +36 -0
  10. package/dist/app.cjs.map +1 -0
  11. package/dist/app.d.cts +52 -0
  12. package/dist/app.d.cts.map +1 -0
  13. package/dist/app.d.mts +52 -0
  14. package/dist/app.d.mts.map +1 -0
  15. package/dist/app.mjs +35 -0
  16. package/dist/app.mjs.map +1 -0
  17. package/dist/client.cjs +3 -1
  18. package/dist/client.cjs.map +1 -1
  19. package/dist/client.d.cts +6 -0
  20. package/dist/client.d.cts.map +1 -1
  21. package/dist/client.d.mts +6 -0
  22. package/dist/client.d.mts.map +1 -1
  23. package/dist/client.mjs +3 -1
  24. package/dist/client.mjs.map +1 -1
  25. package/dist/config.d.cts +1 -1
  26. package/dist/config.d.mts +1 -1
  27. package/dist/credentials.cjs +2 -3
  28. package/dist/credentials.d.cts +2 -2
  29. package/dist/credentials.d.mts +2 -2
  30. package/dist/credentials.mjs +2 -2
  31. package/dist/{dist--zLOSTcG.cjs → dist-B3WT5qgl.cjs} +65 -64
  32. package/dist/dist-B3WT5qgl.cjs.map +1 -0
  33. package/dist/{dist-DT5CSOQc.mjs → dist-BwuyO3oY.mjs} +8 -10
  34. package/dist/dist-BwuyO3oY.mjs.map +1 -0
  35. package/dist/{dist-Dz0i7l87.cjs → dist-CIhk3fW1.cjs} +56 -63
  36. package/dist/dist-CIhk3fW1.cjs.map +1 -0
  37. package/dist/{dist-BF5yN9sB.mjs → dist-DgjcBE-O.mjs} +64 -51
  38. package/dist/dist-DgjcBE-O.mjs.map +1 -0
  39. package/dist/{dist-bGasqeNy.mjs → dist-itGeZOJp.mjs} +56 -63
  40. package/dist/dist-itGeZOJp.mjs.map +1 -0
  41. package/dist/{dist--dtTaEXy.cjs → dist-tKIYuAek.cjs} +8 -10
  42. package/dist/dist-tKIYuAek.cjs.map +1 -0
  43. package/dist/{index-s53YoTdO.d.cts → index-CPCPd4hJ.d.cts} +2 -2
  44. package/dist/{index-BDPrsenN.d.mts.map → index-CPCPd4hJ.d.cts.map} +1 -1
  45. package/dist/{index-BDPrsenN.d.mts → index-Cn6nUPtC.d.mts} +2 -2
  46. package/dist/{index-s53YoTdO.d.cts.map → index-Cn6nUPtC.d.mts.map} +1 -1
  47. package/dist/{index-uWH8vj_f.d.cts → index-DQfGP5X4.d.cts} +4 -4
  48. package/dist/{index-uWH8vj_f.d.cts.map → index-DQfGP5X4.d.cts.map} +1 -1
  49. package/dist/{index-B9hlxKDT.d.cts → index-DpOXmY3P.d.cts} +12 -9
  50. package/dist/index-DpOXmY3P.d.cts.map +1 -0
  51. package/dist/{index-1uEWGKCk.d.mts → index-DsDxuNfg.d.mts} +12 -9
  52. package/dist/index-DsDxuNfg.d.mts.map +1 -0
  53. package/dist/{index-BPC4loSM.d.mts → index-DykbAIg-.d.mts} +2 -2
  54. package/dist/index-DykbAIg-.d.mts.map +1 -0
  55. package/dist/{index-DvJmjY4X.d.mts → index-VCi-jUnh.d.mts} +4 -4
  56. package/dist/{index-DvJmjY4X.d.mts.map → index-VCi-jUnh.d.mts.map} +1 -1
  57. package/dist/{index-DAzE8I-g.d.cts → index-e9f4pcX4.d.cts} +15 -17
  58. package/dist/index-e9f4pcX4.d.cts.map +1 -0
  59. package/dist/{index-DAzE8I-g.d.mts → index-e9f4pcX4.d.mts} +15 -17
  60. package/dist/index-e9f4pcX4.d.mts.map +1 -0
  61. package/dist/{index-Ugto82oH.d.cts → index-nUAXCgEe.d.cts} +2 -2
  62. package/dist/index-nUAXCgEe.d.cts.map +1 -0
  63. package/dist/{mistral-D56Ydau-.mjs → mistral-MfzlP5Os.mjs} +2 -2
  64. package/dist/{mistral-D56Ydau-.mjs.map → mistral-MfzlP5Os.mjs.map} +1 -1
  65. package/dist/{mistral-GXPqP1mo.cjs → mistral-gBakFlvh.cjs} +2 -2
  66. package/dist/{mistral-GXPqP1mo.cjs.map → mistral-gBakFlvh.cjs.map} +1 -1
  67. package/dist/{sse-U_LwOMpt.mjs → sse-CFH10VfF.mjs} +2 -2
  68. package/dist/{sse-U_LwOMpt.mjs.map → sse-CFH10VfF.mjs.map} +1 -1
  69. package/dist/{sse-D1mtozXN.cjs → sse-CO21wkJ1.cjs} +2 -2
  70. package/dist/{sse-D1mtozXN.cjs.map → sse-CO21wkJ1.cjs.map} +1 -1
  71. package/dist/trigger.cjs +1 -1
  72. package/dist/trigger.d.cts +3 -3
  73. package/dist/trigger.d.mts +3 -3
  74. package/dist/trigger.mjs +1 -1
  75. package/dist/workflow.cjs +1 -1
  76. package/dist/workflow.d.cts +2 -2
  77. package/dist/workflow.d.mts +2 -2
  78. package/dist/workflow.mjs +1 -1
  79. package/package.json +7 -1
  80. package/dist/dist--dtTaEXy.cjs.map +0 -1
  81. package/dist/dist--zLOSTcG.cjs.map +0 -1
  82. package/dist/dist-BF5yN9sB.mjs.map +0 -1
  83. package/dist/dist-DT5CSOQc.mjs.map +0 -1
  84. package/dist/dist-Dz0i7l87.cjs.map +0 -1
  85. package/dist/dist-bGasqeNy.mjs.map +0 -1
  86. package/dist/index-1uEWGKCk.d.mts.map +0 -1
  87. package/dist/index-B9hlxKDT.d.cts.map +0 -1
  88. package/dist/index-BPC4loSM.d.mts.map +0 -1
  89. package/dist/index-DAzE8I-g.d.cts.map +0 -1
  90. package/dist/index-DAzE8I-g.d.mts.map +0 -1
  91. package/dist/index-Ugto82oH.d.cts.map +0 -1
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require("./chunk-DHdmVzO2.cjs");
2
- const require_dist$1 = require("./dist--zLOSTcG.cjs");
2
+ const require_dist$1 = require("./dist-B3WT5qgl.cjs");
3
3
  let node_async_hooks = require("node:async_hooks");
4
4
  require("node:fs");
5
5
  let zod_v3 = require("zod/v3");
@@ -13258,7 +13258,7 @@ async function connectMcpServer(name, options) {
13258
13258
  }
13259
13259
  async function createTransport(url, transport, requestInit, fetchImpl) {
13260
13260
  if (transport === "sse") {
13261
- const { SSEClientTransport } = await Promise.resolve().then(() => require("./sse-D1mtozXN.cjs"));
13261
+ const { SSEClientTransport } = await Promise.resolve().then(() => require("./sse-CO21wkJ1.cjs"));
13262
13262
  return new SSEClientTransport(url, {
13263
13263
  requestInit,
13264
13264
  fetch: fetchImpl
@@ -17163,12 +17163,6 @@ function credentialScopeAnd(scopeType, ...conditions) {
17163
17163
  async function selectCredentialInstanceById$1(id) {
17164
17164
  return (await getDb$1().select().from(credentialInstances).where(eq(credentialInstances.id, id)).limit(1))[0];
17165
17165
  }
17166
- async function listCredentialInstancesByScope$1(options) {
17167
- const db = getDb$1();
17168
- const conditions = [options.scopeId === null ? and(eq(credentialInstances.scopeType, options.scopeType), isNull(credentialInstances.scopeId)) : and(eq(credentialInstances.scopeType, options.scopeType), eq(credentialInstances.scopeId, options.scopeId))];
17169
- if (options.slug) conditions.push(eq(credentialInstances.slug, options.slug));
17170
- return db.select().from(credentialInstances).where(credentialScopeAnd(options.scopeType, ...conditions));
17171
- }
17172
17166
  async function selectCredentialInstancesForScope$1(slug, scopeType, scopeId) {
17173
17167
  const db = getDb$1();
17174
17168
  const scopeCondition = scopeId === null ? and(eq(credentialInstances.scopeType, scopeType), isNull(credentialInstances.scopeId)) : and(eq(credentialInstances.scopeType, scopeType), eq(credentialInstances.scopeId, scopeId));
@@ -17570,6 +17564,20 @@ const organizations = pgTable("organizations", {
17570
17564
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull(),
17571
17565
  deletedAt: timestamp("deleted_at", { withTimezone: true })
17572
17566
  }, (table) => [uniqueIndex$1("organizations_slug_unique").on(table.slug)]);
17567
+ const apps = pgTable("apps", {
17568
+ id: text$1("id").primaryKey(),
17569
+ organizationId: text$1("organization_id").references(() => organizations.id, { onDelete: "cascade" }),
17570
+ slug: text$1("slug").notNull(),
17571
+ name: text$1("name").notNull(),
17572
+ description: text$1("description").notNull(),
17573
+ category: text$1("category").notNull(),
17574
+ logo: text$1("logo"),
17575
+ authKind: text$1("auth_kind").$type().notNull(),
17576
+ oauthScopes: jsonb("oauth_scopes").$type().notNull(),
17577
+ source: text$1("source").$type().notNull(),
17578
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull(),
17579
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
17580
+ }, (table) => [uniqueIndex$1("apps_slug_idx").on(table.slug), index$1("apps_organization_id_idx").on(table.organizationId)]);
17573
17581
  const oauthApps = pgTable("oauth_apps", {
17574
17582
  id: text$1("id").primaryKey(),
17575
17583
  organizationId: text$1("organization_id").notNull().references(() => organizations.id, { onDelete: "cascade" }),
@@ -17692,6 +17700,7 @@ buildPgSchema({
17692
17700
  authDeviceCodes: { pg: authDeviceCodes },
17693
17701
  authJwks: { pg: authJwks },
17694
17702
  authApiKeys: { pg: authApiKeys },
17703
+ apps: { pg: apps },
17695
17704
  oauthApps: { pg: oauthApps },
17696
17705
  oauthConnections: { pg: oauthConnections },
17697
17706
  secretValues: { pg: secretValues }
@@ -17848,9 +17857,6 @@ async function selectCredentialInstanceById(id) {
17848
17857
  async function selectCredentialInstancesForScope(key, scopeType, scopeId) {
17849
17858
  return (await selectCredentialInstancesForScope$1(key, scopeType, scopeId)).map(normalizeLocalRow);
17850
17859
  }
17851
- async function listCredentialInstancesByScope(options) {
17852
- return (await listCredentialInstancesByScope$1(options)).map(normalizeLocalRow);
17853
- }
17854
17860
  //#endregion
17855
17861
  //#region ../credentials/dist/index.mjs
17856
17862
  var MissingCredentialsError = class extends Error {
@@ -18026,20 +18032,6 @@ function createCredentialBackend(options = {}) {
18026
18032
  }
18027
18033
  return createLocalCredentialBackend(options);
18028
18034
  }
18029
- const CHAIN_TO_SCOPE = {
18030
- organization: {
18031
- scopeType: require_dist$1.CREDENTIAL_SCOPE_LEVEL_TO_SCOPE_TYPE.organization,
18032
- contextKey: "orgId"
18033
- },
18034
- project: {
18035
- scopeType: require_dist$1.CREDENTIAL_SCOPE_LEVEL_TO_SCOPE_TYPE.project,
18036
- contextKey: "projectId"
18037
- },
18038
- user: {
18039
- scopeType: require_dist$1.CREDENTIAL_SCOPE_LEVEL_TO_SCOPE_TYPE.user,
18040
- contextKey: "userId"
18041
- }
18042
- };
18043
18035
  function toSelectionOption(row) {
18044
18036
  return {
18045
18037
  id: row.id,
@@ -18112,21 +18104,12 @@ function withTenantScope(context) {
18112
18104
  orgId: getServerTenantScopeId()
18113
18105
  };
18114
18106
  }
18115
- async function listSelectionOptions(key, context) {
18116
- const scoped = withTenantScope(context);
18117
- const rows = [];
18118
- rows.push(...await listCredentialInstancesByScope({
18119
- key,
18120
- scopeType: "organization",
18121
- scopeId: scoped.orgId
18122
- }));
18123
- const userId = resolveUserId(key, scoped);
18124
- if (userId) rows.push(...await listCredentialInstancesByScope({
18125
- key,
18126
- scopeType: "user",
18127
- scopeId: userId
18128
- }));
18129
- return rows.map(toSelectionOption);
18107
+ function scopeIdForScope(scope, key, context) {
18108
+ switch (scope) {
18109
+ case "organization": return context.orgId;
18110
+ case "project": return context.projectId;
18111
+ case "user": return resolveUserId(key, context);
18112
+ }
18130
18113
  }
18131
18114
  async function resolveAtScope(key, scopeType, scopeId, consumer) {
18132
18115
  const rows = await selectCredentialInstancesForScope(key, scopeType, scopeId);
@@ -18138,35 +18121,45 @@ async function resolveAtScope(key, scopeType, scopeId, consumer) {
18138
18121
  throw error;
18139
18122
  }
18140
18123
  }
18124
+ /**
18125
+ * Resolution order:
18126
+ * 1. A platform-provided binding (explicit instance id in `context.selection`) wins.
18127
+ * 2. A scope pinned on the requirement (`.scope("user")`) resolves only at that scope.
18128
+ * 3. Otherwise the project default, then the org default. No configurable chain.
18129
+ * If nothing matches, throw — there is no binding.
18130
+ */
18141
18131
  async function resolvePolicy(requirement, context, consumer, backend) {
18142
- const chainAttempted = [];
18143
- const selectionId = context.selection?.[requirement.key];
18132
+ const attempted = [];
18144
18133
  const materialBackend = backend ?? createCredentialBackend();
18145
18134
  const scoped = withTenantScope(context);
18146
- for (let index = 0; index < requirement.chain.length; index++) {
18147
- const level = requirement.chain[index];
18148
- if (level === "selection") {
18149
- if (selectionId) {
18150
- chainAttempted.push("selection");
18151
- return resolveInstanceValue(await resolveSelectedInstance(requirement.key, selectionId, scoped, consumer), requirement, materialBackend);
18152
- }
18153
- if (index === requirement.chain.length - 1) throw new NeedsSelectionError({
18154
- key: requirement.key,
18155
- options: await listSelectionOptions(requirement.key, scoped),
18156
- consumer
18157
- });
18158
- continue;
18159
- }
18160
- const mapping = CHAIN_TO_SCOPE[level];
18161
- const scopeId = level === "user" ? resolveUserId(requirement.key, scoped) : scoped[mapping.contextKey];
18162
- if (!scopeId) continue;
18163
- chainAttempted.push(level);
18164
- const row = await resolveAtScope(requirement.key, mapping.scopeType, scopeId, consumer);
18135
+ const selectionId = context.selection?.[requirement.key];
18136
+ if (selectionId) return resolveInstanceValue(await resolveSelectedInstance(requirement.key, selectionId, scoped, consumer), requirement, materialBackend);
18137
+ if (requirement.scope) {
18138
+ const scopeId = scopeIdForScope(requirement.scope, requirement.key, scoped);
18139
+ if (scopeId) {
18140
+ attempted.push(requirement.scope);
18141
+ const row = await resolveAtScope(requirement.key, requirement.scope, scopeId, consumer);
18142
+ if (row) return resolveInstanceValue(row, requirement, materialBackend);
18143
+ }
18144
+ throw new MissingCredentialsError({
18145
+ key: requirement.key,
18146
+ chainAttempted: attempted.length > 0 ? attempted : [requirement.scope],
18147
+ consumer
18148
+ });
18149
+ }
18150
+ if (scoped.projectId) {
18151
+ attempted.push("project");
18152
+ const row = await resolveAtScope(requirement.key, "project", scoped.projectId, consumer);
18153
+ if (row) return resolveInstanceValue(row, requirement, materialBackend);
18154
+ }
18155
+ if (scoped.orgId) {
18156
+ attempted.push("organization");
18157
+ const row = await resolveAtScope(requirement.key, "organization", scoped.orgId, consumer);
18165
18158
  if (row) return resolveInstanceValue(row, requirement, materialBackend);
18166
18159
  }
18167
18160
  throw new MissingCredentialsError({
18168
18161
  key: requirement.key,
18169
- chainAttempted,
18162
+ chainAttempted: attempted,
18170
18163
  consumer
18171
18164
  });
18172
18165
  }
@@ -18489,4 +18482,4 @@ Object.defineProperty(exports, "zodToJsonSchema", {
18489
18482
  }
18490
18483
  });
18491
18484
 
18492
- //# sourceMappingURL=dist-Dz0i7l87.cjs.map
18485
+ //# sourceMappingURL=dist-CIhk3fW1.cjs.map