@keystrokehq/cli 0.1.90 → 0.1.92

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.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { n as __require, t as __commonJSMin } from "./chunk-DiodbrVj.mjs";
3
- import { $r as toJSONSchema, Ar as ZodType, Br as lazy, Cr as parseStoredRouteManifest, Fr as array, Ir as boolean$1, Jr as string, Kr as preprocess, Lr as custom, Mr as _function, Nr as _null, Rr as discriminatedUnion, Ur as number, Vr as literal, Wr as object, Yr as union, cn as PromptResponseSchema, et as DEFAULT_CLOUD_PLATFORM_ORIGIN, fn as ROUTE_MANIFEST_REL_PATH, jr as _enum, ln as PublicModelsResponseSchema, mr as credentialInputSchema, qr as record, wr as requiredDisplayTextSchema, yr as normalizeCredentialList } from "./dist-Ddqfmys3.mjs";
4
- import "./dist-HHZNDjZJ.mjs";
3
+ import { $r as toJSONSchema, Ar as ZodType, Br as lazy, Cr as parseStoredRouteManifest, Fr as array, Ir as boolean$1, Jr as string, Kr as preprocess, Lr as custom, Mr as _function, Nr as _null, Rr as discriminatedUnion, Ur as number, Vr as literal, Wr as object, Yr as union, cn as PromptResponseSchema, et as DEFAULT_CLOUD_PLATFORM_ORIGIN, fn as ROUTE_MANIFEST_REL_PATH, jr as _enum, ln as PublicModelsResponseSchema, mr as credentialInputSchema, qr as record, wr as requiredDisplayTextSchema, yr as normalizeCredentialList } from "./dist-WHAEh05Y.mjs";
4
+ import "./dist-BxVsr24X.mjs";
5
5
  import "./chunk-BZUGFHVS-CPWRFwK8.mjs";
6
6
  import "./chunk-DLL7UR66-BUYgzxnR.mjs";
7
7
  import "./chunk-TN7HHBQW-CSB_R-XD.mjs";
@@ -2988,6 +2988,7 @@ const workflowRuns = pgTable("workflow_runs", {
2988
2988
  sourceKind: text("source_kind").$type().notNull().default("api"),
2989
2989
  sourceId: text("source_id"),
2990
2990
  ranByUserId: text("ran_by_user_id"),
2991
+ credentialContext: jsonb("credential_context").$type(),
2991
2992
  status: text("status").$type().notNull(),
2992
2993
  trigger: text("trigger").$type().notNull(),
2993
2994
  triggeredAt: timestamp("triggered_at", { withTimezone: true }).notNull(),
@@ -3009,6 +3010,7 @@ const workflowRunsSqlite = sqliteTable("workflow_runs", {
3009
3010
  sourceKind: text$1("source_kind").$type().notNull().default("api"),
3010
3011
  sourceId: text$1("source_id"),
3011
3012
  ranByUserId: text$1("ran_by_user_id"),
3013
+ credentialContext: text$1("credential_context", { mode: "json" }).$type(),
3012
3014
  status: text$1("status").$type().notNull(),
3013
3015
  trigger: text$1("trigger").$type().notNull(),
3014
3016
  triggeredAt: integer$1("triggered_at", { mode: "timestamp_ms" }).notNull(),
@@ -3145,6 +3147,7 @@ const jobs = pgTable("jobs", {
3145
3147
  runId: text("run_id").notNull(),
3146
3148
  trigger: text("trigger").$type().notNull(),
3147
3149
  payload: jsonb("payload"),
3150
+ parent: jsonb("parent").$type(),
3148
3151
  status: text("status").$type().notNull(),
3149
3152
  scheduledAt: timestamp("scheduled_at", { withTimezone: true }).notNull(),
3150
3153
  attempt: integer("attempt").notNull(),
@@ -3162,6 +3165,7 @@ const jobsSqlite = sqliteTable("jobs", {
3162
3165
  runId: text$1("run_id").notNull(),
3163
3166
  trigger: text$1("trigger").$type().notNull(),
3164
3167
  payload: text$1("payload", { mode: "json" }),
3168
+ parent: text$1("parent", { mode: "json" }).$type(),
3165
3169
  status: text$1("status").$type().notNull(),
3166
3170
  scheduledAt: integer$1("scheduled_at", { mode: "timestamp_ms" }).notNull(),
3167
3171
  attempt: integer$1("attempt").notNull(),
@@ -3350,12 +3354,17 @@ const resourceActivitySqlite = sqliteTable("resource_activity", {
3350
3354
  lastOpenedAt: integer$1("last_opened_at", { mode: "timestamp_ms" }).notNull()
3351
3355
  }, (table) => [uniqueIndex$1("resource_activity_project_user_kind_resource").on(table.projectId, table.userId, table.resourceKind, table.resourceId), index$1("resource_activity_user_last_opened_at").on(table.userId, table.lastOpenedAt)]);
3352
3356
  /**
3357
+ * Legacy org-runtime billing cache. Platform cloud financial authority now
3358
+ * lives in `@keystrokehq/platform-database`; keep this table for existing org
3359
+ * databases and pushed-down runtime plan hints, but do not add new billing
3360
+ * writers here.
3361
+ *
3353
3362
  * Single-row prepaid credit wallet + pushed-down plan config for the org
3354
3363
  * (the org runtime DB is per-org). Cache of `SUM(usage_records.microCredits)`,
3355
3364
  * updated in the same transaction as each ledger insert. Cloud-only: standalone
3356
3365
  * never writes it. All billing logic lives in `packages/cloud/*`.
3357
3366
  */
3358
- const billingWallet = pgTable("billing_wallet", {
3367
+ const billingWallet$1 = pgTable("billing_wallet", {
3359
3368
  organizationId: text("organization_id").primaryKey(),
3360
3369
  planCreditMicroCredits: bigint("plan_credit_micro_credits", { mode: "number" }).notNull().default(0),
3361
3370
  prepaidCreditMicroCredits: bigint("prepaid_credit_micro_credits", { mode: "number" }).notNull().default(0),
@@ -3373,7 +3382,7 @@ const billingWallet = pgTable("billing_wallet", {
3373
3382
  autoTopupThresholdMicroCredits: bigint("auto_topup_threshold_micro_credits", { mode: "number" }),
3374
3383
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
3375
3384
  });
3376
- const billingWalletSqlite = sqliteTable("billing_wallet", {
3385
+ const billingWalletSqlite$1 = sqliteTable("billing_wallet", {
3377
3386
  organizationId: text$1("organization_id").primaryKey(),
3378
3387
  planCreditMicroCredits: integer$1("plan_credit_micro_credits").notNull().default(0),
3379
3388
  prepaidCreditMicroCredits: integer$1("prepaid_credit_micro_credits").notNull().default(0),
@@ -3480,14 +3489,13 @@ const tableRegistry$1 = {
3480
3489
  sqlite: resourceActivitySqlite
3481
3490
  },
3482
3491
  billingWallet: {
3483
- pg: billingWallet,
3484
- sqlite: billingWalletSqlite
3492
+ pg: billingWallet$1,
3493
+ sqlite: billingWalletSqlite$1
3485
3494
  }
3486
3495
  };
3487
3496
  buildPgSchema$1(tableRegistry$1);
3488
3497
  buildSqliteSchema$1(tableRegistry$1);
3489
- //#endregion
3490
- //#region ../../packages/agent/dist/schemas-klJyQbd2.mjs
3498
+ new AsyncLocalStorage();
3491
3499
  const AGENT_MODEL_ID_PATTERN = /^[a-z0-9-]+\/.+/;
3492
3500
  const AgentModelIdSchema = custom((value) => typeof value === "string" && AGENT_MODEL_ID_PATTERN.test(value), "model must be vendor/model-id");
3493
3501
  const GatewayModelPricingSchema = object({
@@ -13961,6 +13969,96 @@ const billingEventsSqlite = sqliteTable("billing_events", {
13961
13969
  metadata: text$1("metadata", { mode: "json" }),
13962
13970
  createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull()
13963
13971
  }, (table) => [uniqueIndex$1("billing_events_stripe_event_id_unique").on(table.stripeEventId), index$1("billing_events_organization_id_idx").on(table.organizationId)]);
13972
+ /**
13973
+ * Platform billing authority: one narrow wallet projection per organization.
13974
+ * Plan limits stay in `organization_billing` / pushed-down runtime config.
13975
+ */
13976
+ const billingWallet = pgTable("billing_wallet", {
13977
+ organizationId: text("organization_id").primaryKey().references(() => organizations.id, { onDelete: "cascade" }),
13978
+ planCreditMicroCredits: bigint("plan_credit_micro_credits", { mode: "number" }).notNull().default(0),
13979
+ prepaidCreditMicroCredits: bigint("prepaid_credit_micro_credits", { mode: "number" }).notNull().default(0),
13980
+ periodStart: timestamp("period_start", { withTimezone: true }),
13981
+ periodEnd: timestamp("period_end", { withTimezone: true }),
13982
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
13983
+ });
13984
+ const billingWalletSqlite = sqliteTable("billing_wallet", {
13985
+ organizationId: text$1("organization_id").primaryKey().references(() => organizationsSqlite.id, { onDelete: "cascade" }),
13986
+ planCreditMicroCredits: integer$1("plan_credit_micro_credits").notNull().default(0),
13987
+ prepaidCreditMicroCredits: integer$1("prepaid_credit_micro_credits").notNull().default(0),
13988
+ periodStart: integer$1("period_start", { mode: "timestamp_ms" }),
13989
+ periodEnd: integer$1("period_end", { mode: "timestamp_ms" }),
13990
+ updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
13991
+ });
13992
+ /** Immutable platform financial history. */
13993
+ const billingLedger = pgTable("billing_ledger", {
13994
+ id: text("id").primaryKey(),
13995
+ organizationId: text("organization_id").notNull().references(() => organizations.id, { onDelete: "cascade" }),
13996
+ entryType: text("entry_type").$type().notNull(),
13997
+ planDeltaMicroCredits: bigint("plan_delta_micro_credits", { mode: "number" }).notNull().default(0),
13998
+ prepaidDeltaMicroCredits: bigint("prepaid_delta_micro_credits", { mode: "number" }).notNull().default(0),
13999
+ source: text("source").notNull(),
14000
+ idempotencyKey: text("idempotency_key").notNull(),
14001
+ runId: text("run_id"),
14002
+ projectId: text("project_id"),
14003
+ providerReference: text("provider_reference"),
14004
+ metadata: jsonb("metadata"),
14005
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull()
14006
+ }, (table) => [uniqueIndex("billing_ledger_org_idempotency_unique").on(table.organizationId, table.idempotencyKey), index("billing_ledger_org_created_at_idx").on(table.organizationId, table.createdAt)]);
14007
+ const billingLedgerSqlite = sqliteTable("billing_ledger", {
14008
+ id: text$1("id").primaryKey(),
14009
+ organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id, { onDelete: "cascade" }),
14010
+ entryType: text$1("entry_type").$type().notNull(),
14011
+ planDeltaMicroCredits: integer$1("plan_delta_micro_credits").notNull().default(0),
14012
+ prepaidDeltaMicroCredits: integer$1("prepaid_delta_micro_credits").notNull().default(0),
14013
+ source: text$1("source").notNull(),
14014
+ idempotencyKey: text$1("idempotency_key").notNull(),
14015
+ runId: text$1("run_id"),
14016
+ projectId: text$1("project_id"),
14017
+ providerReference: text$1("provider_reference"),
14018
+ metadata: text$1("metadata", { mode: "json" }),
14019
+ createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull()
14020
+ }, (table) => [uniqueIndex$1("billing_ledger_org_idempotency_unique").on(table.organizationId, table.idempotencyKey), index$1("billing_ledger_org_created_at_idx").on(table.organizationId, table.createdAt)]);
14021
+ /** Append-only platform meter facts, priced before insertion by the server. */
14022
+ const usageEvents = pgTable("usage_events", {
14023
+ id: text("id").primaryKey(),
14024
+ organizationId: text("organization_id").notNull().references(() => organizations.id, { onDelete: "cascade" }),
14025
+ projectId: text("project_id"),
14026
+ runId: text("run_id"),
14027
+ runKind: text("run_kind").$type(),
14028
+ source: text("source").notNull(),
14029
+ sourceEventId: text("source_event_id").notNull(),
14030
+ meterKey: text("meter_key").notNull(),
14031
+ quantity: doublePrecision("quantity").notNull(),
14032
+ unit: text("unit").notNull(),
14033
+ providerCostUsd: doublePrecision("provider_cost_usd"),
14034
+ keySource: text("key_source").$type(),
14035
+ priceVersion: text("price_version").notNull(),
14036
+ chargeMicroCredits: bigint("charge_micro_credits", { mode: "number" }).notNull(),
14037
+ settledLedgerId: text("settled_ledger_id"),
14038
+ occurredAt: timestamp("occurred_at", { withTimezone: true }).notNull(),
14039
+ acceptedAt: timestamp("accepted_at", { withTimezone: true }).notNull(),
14040
+ metadata: jsonb("metadata")
14041
+ }, (table) => [uniqueIndex("usage_events_org_source_event_unique").on(table.organizationId, table.source, table.sourceEventId), index("usage_events_org_run_occurred_idx").on(table.organizationId, table.runId, table.occurredAt)]);
14042
+ const usageEventsSqlite = sqliteTable("usage_events", {
14043
+ id: text$1("id").primaryKey(),
14044
+ organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id, { onDelete: "cascade" }),
14045
+ projectId: text$1("project_id"),
14046
+ runId: text$1("run_id"),
14047
+ runKind: text$1("run_kind").$type(),
14048
+ source: text$1("source").notNull(),
14049
+ sourceEventId: text$1("source_event_id").notNull(),
14050
+ meterKey: text$1("meter_key").notNull(),
14051
+ quantity: real("quantity").notNull(),
14052
+ unit: text$1("unit").notNull(),
14053
+ providerCostUsd: real("provider_cost_usd"),
14054
+ keySource: text$1("key_source").$type(),
14055
+ priceVersion: text$1("price_version").notNull(),
14056
+ chargeMicroCredits: integer$1("charge_micro_credits").notNull(),
14057
+ settledLedgerId: text$1("settled_ledger_id"),
14058
+ occurredAt: integer$1("occurred_at", { mode: "timestamp_ms" }).notNull(),
14059
+ acceptedAt: integer$1("accepted_at", { mode: "timestamp_ms" }).notNull(),
14060
+ metadata: text$1("metadata", { mode: "json" })
14061
+ }, (table) => [uniqueIndex$1("usage_events_org_source_event_unique").on(table.organizationId, table.source, table.sourceEventId), index$1("usage_events_org_run_occurred_idx").on(table.organizationId, table.runId, table.occurredAt)]);
13964
14062
  const managedServiceCredentials = pgTable("managed_service_credentials", {
13965
14063
  id: text("id").primaryKey(),
13966
14064
  organizationId: text("organization_id").notNull().references(() => organizations.id, { onDelete: "cascade" }),
@@ -14075,6 +14173,18 @@ const tableRegistry = {
14075
14173
  pg: billingEvents,
14076
14174
  sqlite: billingEventsSqlite
14077
14175
  },
14176
+ billingWallet: {
14177
+ pg: billingWallet,
14178
+ sqlite: billingWalletSqlite
14179
+ },
14180
+ billingLedger: {
14181
+ pg: billingLedger,
14182
+ sqlite: billingLedgerSqlite
14183
+ },
14184
+ usageEvents: {
14185
+ pg: usageEvents,
14186
+ sqlite: usageEventsSqlite
14187
+ },
14078
14188
  managedServiceCredentials: {
14079
14189
  pg: managedServiceCredentials,
14080
14190
  sqlite: managedServiceCredentialsSqlite
@@ -31023,4 +31133,4 @@ async function emitStoredRouteManifestForProject(projectRoot) {
31023
31133
  //#endregion
31024
31134
  export { validatePollGroups as A, attachmentSlugFromRecord as B, pollRouteFromSourceSlug as C, validateAttachmentTargets as D, toStoredRouteManifest as E, webhookManifestAttachmentSchemasFromBindings as F, packAssetDirs as G, computeCallSiteIds as H, webhookMatchSchemaForBindings as I, entryIdFromFile as J, discoverEntries as K, webhookRouteFromEndpoint as L, validateTriggerAttachments as M, validateUniqueAttachmentSlugs as N, validateImportedTriggerAttachment as O, validateUniqueTriggerSourceSlugs as P, walkTypeScriptFiles as Q, workflowKeyForAttachment as R, pollGroupRouteFromId as S, serializeRouteManifest as T, diagnoseWorkflowSource as U, classifyCall as V, locateWorkflow as W, shouldSkipKeystrokeModuleFile as X, readKeystrokeIgnoreDirective as Y, validateUniqueModuleKeys as Z, importAgentDefinition as _, buildStoredRouteManifestForProject as a, persistStoredRouteManifest as b, collectAgentAppSlugs as c, discoverAgentEntries as d, discoverSkillManifestEntries as f, emitStoredRouteManifestForProject as g, discoverWorkflows as h, buildPollGroups as i, validateProjectModules as j, validateImportedWorkflowDefinition as k, collectAgentToolSlugs as l, discoverWorkflowEntries as m, agentManifestEntry as n, buildStoredRouteManifestFromContext as o, discoverTriggerAttachments as p, discoverModuleFileEntries as q, agentRouteFromKey as r, buildWebhookBindingsByRoute as s, agentKeyForAttachment as t, countAgentCredentials as u, importTriggerAttachments as v, schemaToJson as w, pollGroupId as x, importWorkflowDefinition as y, workflowRouteFromKey as z };
31025
31135
 
31026
- //# sourceMappingURL=dist-5IqGzCCh.mjs.map
31136
+ //# sourceMappingURL=dist-CMWayagw.mjs.map