@keystrokehq/cli 0.1.90 → 0.1.91

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-CppcpBQ9.mjs";
4
+ import "./dist-CNjsuUwx.mjs";
5
5
  import "./chunk-BZUGFHVS-CPWRFwK8.mjs";
6
6
  import "./chunk-DLL7UR66-BUYgzxnR.mjs";
7
7
  import "./chunk-TN7HHBQW-CSB_R-XD.mjs";
@@ -3350,12 +3350,17 @@ const resourceActivitySqlite = sqliteTable("resource_activity", {
3350
3350
  lastOpenedAt: integer$1("last_opened_at", { mode: "timestamp_ms" }).notNull()
3351
3351
  }, (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
3352
  /**
3353
+ * Legacy org-runtime billing cache. Platform cloud financial authority now
3354
+ * lives in `@keystrokehq/platform-database`; keep this table for existing org
3355
+ * databases and pushed-down runtime plan hints, but do not add new billing
3356
+ * writers here.
3357
+ *
3353
3358
  * Single-row prepaid credit wallet + pushed-down plan config for the org
3354
3359
  * (the org runtime DB is per-org). Cache of `SUM(usage_records.microCredits)`,
3355
3360
  * updated in the same transaction as each ledger insert. Cloud-only: standalone
3356
3361
  * never writes it. All billing logic lives in `packages/cloud/*`.
3357
3362
  */
3358
- const billingWallet = pgTable("billing_wallet", {
3363
+ const billingWallet$1 = pgTable("billing_wallet", {
3359
3364
  organizationId: text("organization_id").primaryKey(),
3360
3365
  planCreditMicroCredits: bigint("plan_credit_micro_credits", { mode: "number" }).notNull().default(0),
3361
3366
  prepaidCreditMicroCredits: bigint("prepaid_credit_micro_credits", { mode: "number" }).notNull().default(0),
@@ -3373,7 +3378,7 @@ const billingWallet = pgTable("billing_wallet", {
3373
3378
  autoTopupThresholdMicroCredits: bigint("auto_topup_threshold_micro_credits", { mode: "number" }),
3374
3379
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
3375
3380
  });
3376
- const billingWalletSqlite = sqliteTable("billing_wallet", {
3381
+ const billingWalletSqlite$1 = sqliteTable("billing_wallet", {
3377
3382
  organizationId: text$1("organization_id").primaryKey(),
3378
3383
  planCreditMicroCredits: integer$1("plan_credit_micro_credits").notNull().default(0),
3379
3384
  prepaidCreditMicroCredits: integer$1("prepaid_credit_micro_credits").notNull().default(0),
@@ -3480,14 +3485,13 @@ const tableRegistry$1 = {
3480
3485
  sqlite: resourceActivitySqlite
3481
3486
  },
3482
3487
  billingWallet: {
3483
- pg: billingWallet,
3484
- sqlite: billingWalletSqlite
3488
+ pg: billingWallet$1,
3489
+ sqlite: billingWalletSqlite$1
3485
3490
  }
3486
3491
  };
3487
3492
  buildPgSchema$1(tableRegistry$1);
3488
3493
  buildSqliteSchema$1(tableRegistry$1);
3489
- //#endregion
3490
- //#region ../../packages/agent/dist/schemas-klJyQbd2.mjs
3494
+ new AsyncLocalStorage();
3491
3495
  const AGENT_MODEL_ID_PATTERN = /^[a-z0-9-]+\/.+/;
3492
3496
  const AgentModelIdSchema = custom((value) => typeof value === "string" && AGENT_MODEL_ID_PATTERN.test(value), "model must be vendor/model-id");
3493
3497
  const GatewayModelPricingSchema = object({
@@ -13961,6 +13965,96 @@ const billingEventsSqlite = sqliteTable("billing_events", {
13961
13965
  metadata: text$1("metadata", { mode: "json" }),
13962
13966
  createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull()
13963
13967
  }, (table) => [uniqueIndex$1("billing_events_stripe_event_id_unique").on(table.stripeEventId), index$1("billing_events_organization_id_idx").on(table.organizationId)]);
13968
+ /**
13969
+ * Platform billing authority: one narrow wallet projection per organization.
13970
+ * Plan limits stay in `organization_billing` / pushed-down runtime config.
13971
+ */
13972
+ const billingWallet = pgTable("billing_wallet", {
13973
+ organizationId: text("organization_id").primaryKey().references(() => organizations.id, { onDelete: "cascade" }),
13974
+ planCreditMicroCredits: bigint("plan_credit_micro_credits", { mode: "number" }).notNull().default(0),
13975
+ prepaidCreditMicroCredits: bigint("prepaid_credit_micro_credits", { mode: "number" }).notNull().default(0),
13976
+ periodStart: timestamp("period_start", { withTimezone: true }),
13977
+ periodEnd: timestamp("period_end", { withTimezone: true }),
13978
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull()
13979
+ });
13980
+ const billingWalletSqlite = sqliteTable("billing_wallet", {
13981
+ organizationId: text$1("organization_id").primaryKey().references(() => organizationsSqlite.id, { onDelete: "cascade" }),
13982
+ planCreditMicroCredits: integer$1("plan_credit_micro_credits").notNull().default(0),
13983
+ prepaidCreditMicroCredits: integer$1("prepaid_credit_micro_credits").notNull().default(0),
13984
+ periodStart: integer$1("period_start", { mode: "timestamp_ms" }),
13985
+ periodEnd: integer$1("period_end", { mode: "timestamp_ms" }),
13986
+ updatedAt: integer$1("updated_at", { mode: "timestamp_ms" }).notNull()
13987
+ });
13988
+ /** Immutable platform financial history. */
13989
+ const billingLedger = pgTable("billing_ledger", {
13990
+ id: text("id").primaryKey(),
13991
+ organizationId: text("organization_id").notNull().references(() => organizations.id, { onDelete: "cascade" }),
13992
+ entryType: text("entry_type").$type().notNull(),
13993
+ planDeltaMicroCredits: bigint("plan_delta_micro_credits", { mode: "number" }).notNull().default(0),
13994
+ prepaidDeltaMicroCredits: bigint("prepaid_delta_micro_credits", { mode: "number" }).notNull().default(0),
13995
+ source: text("source").notNull(),
13996
+ idempotencyKey: text("idempotency_key").notNull(),
13997
+ runId: text("run_id"),
13998
+ projectId: text("project_id"),
13999
+ providerReference: text("provider_reference"),
14000
+ metadata: jsonb("metadata"),
14001
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull()
14002
+ }, (table) => [uniqueIndex("billing_ledger_org_idempotency_unique").on(table.organizationId, table.idempotencyKey), index("billing_ledger_org_created_at_idx").on(table.organizationId, table.createdAt)]);
14003
+ const billingLedgerSqlite = sqliteTable("billing_ledger", {
14004
+ id: text$1("id").primaryKey(),
14005
+ organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id, { onDelete: "cascade" }),
14006
+ entryType: text$1("entry_type").$type().notNull(),
14007
+ planDeltaMicroCredits: integer$1("plan_delta_micro_credits").notNull().default(0),
14008
+ prepaidDeltaMicroCredits: integer$1("prepaid_delta_micro_credits").notNull().default(0),
14009
+ source: text$1("source").notNull(),
14010
+ idempotencyKey: text$1("idempotency_key").notNull(),
14011
+ runId: text$1("run_id"),
14012
+ projectId: text$1("project_id"),
14013
+ providerReference: text$1("provider_reference"),
14014
+ metadata: text$1("metadata", { mode: "json" }),
14015
+ createdAt: integer$1("created_at", { mode: "timestamp_ms" }).notNull()
14016
+ }, (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)]);
14017
+ /** Append-only platform meter facts, priced before insertion by the server. */
14018
+ const usageEvents = pgTable("usage_events", {
14019
+ id: text("id").primaryKey(),
14020
+ organizationId: text("organization_id").notNull().references(() => organizations.id, { onDelete: "cascade" }),
14021
+ projectId: text("project_id"),
14022
+ runId: text("run_id"),
14023
+ runKind: text("run_kind").$type(),
14024
+ source: text("source").notNull(),
14025
+ sourceEventId: text("source_event_id").notNull(),
14026
+ meterKey: text("meter_key").notNull(),
14027
+ quantity: doublePrecision("quantity").notNull(),
14028
+ unit: text("unit").notNull(),
14029
+ providerCostUsd: doublePrecision("provider_cost_usd"),
14030
+ keySource: text("key_source").$type(),
14031
+ priceVersion: text("price_version").notNull(),
14032
+ chargeMicroCredits: bigint("charge_micro_credits", { mode: "number" }).notNull(),
14033
+ settledLedgerId: text("settled_ledger_id"),
14034
+ occurredAt: timestamp("occurred_at", { withTimezone: true }).notNull(),
14035
+ acceptedAt: timestamp("accepted_at", { withTimezone: true }).notNull(),
14036
+ metadata: jsonb("metadata")
14037
+ }, (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)]);
14038
+ const usageEventsSqlite = sqliteTable("usage_events", {
14039
+ id: text$1("id").primaryKey(),
14040
+ organizationId: text$1("organization_id").notNull().references(() => organizationsSqlite.id, { onDelete: "cascade" }),
14041
+ projectId: text$1("project_id"),
14042
+ runId: text$1("run_id"),
14043
+ runKind: text$1("run_kind").$type(),
14044
+ source: text$1("source").notNull(),
14045
+ sourceEventId: text$1("source_event_id").notNull(),
14046
+ meterKey: text$1("meter_key").notNull(),
14047
+ quantity: real("quantity").notNull(),
14048
+ unit: text$1("unit").notNull(),
14049
+ providerCostUsd: real("provider_cost_usd"),
14050
+ keySource: text$1("key_source").$type(),
14051
+ priceVersion: text$1("price_version").notNull(),
14052
+ chargeMicroCredits: integer$1("charge_micro_credits").notNull(),
14053
+ settledLedgerId: text$1("settled_ledger_id"),
14054
+ occurredAt: integer$1("occurred_at", { mode: "timestamp_ms" }).notNull(),
14055
+ acceptedAt: integer$1("accepted_at", { mode: "timestamp_ms" }).notNull(),
14056
+ metadata: text$1("metadata", { mode: "json" })
14057
+ }, (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
14058
  const managedServiceCredentials = pgTable("managed_service_credentials", {
13965
14059
  id: text("id").primaryKey(),
13966
14060
  organizationId: text("organization_id").notNull().references(() => organizations.id, { onDelete: "cascade" }),
@@ -14075,6 +14169,18 @@ const tableRegistry = {
14075
14169
  pg: billingEvents,
14076
14170
  sqlite: billingEventsSqlite
14077
14171
  },
14172
+ billingWallet: {
14173
+ pg: billingWallet,
14174
+ sqlite: billingWalletSqlite
14175
+ },
14176
+ billingLedger: {
14177
+ pg: billingLedger,
14178
+ sqlite: billingLedgerSqlite
14179
+ },
14180
+ usageEvents: {
14181
+ pg: usageEvents,
14182
+ sqlite: usageEventsSqlite
14183
+ },
14078
14184
  managedServiceCredentials: {
14079
14185
  pg: managedServiceCredentials,
14080
14186
  sqlite: managedServiceCredentialsSqlite
@@ -31023,4 +31129,4 @@ async function emitStoredRouteManifestForProject(projectRoot) {
31023
31129
  //#endregion
31024
31130
  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
31131
 
31026
- //# sourceMappingURL=dist-5IqGzCCh.mjs.map
31132
+ //# sourceMappingURL=dist-BAOpw31u.mjs.map