@keystrokehq/hosting 0.1.10 → 0.1.12
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.
- package/dist/index.cjs +529 -230
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -4
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +15 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +527 -229
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -4
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
1
2
|
import Docker from "dockerode";
|
|
2
3
|
import { mkdir } from "node:fs/promises";
|
|
3
4
|
//#region src/constants.ts
|
|
@@ -4807,6 +4808,7 @@ const INFRA_SYSTEM_SLUGS = [
|
|
|
4807
4808
|
"health",
|
|
4808
4809
|
"healthcheck",
|
|
4809
4810
|
"healthz",
|
|
4811
|
+
"hook-resume",
|
|
4810
4812
|
"hooks",
|
|
4811
4813
|
"internal",
|
|
4812
4814
|
"item",
|
|
@@ -4972,14 +4974,14 @@ const OrganizationUserRoleSchema = _enum([
|
|
|
4972
4974
|
"admin",
|
|
4973
4975
|
"builder"
|
|
4974
4976
|
]);
|
|
4975
|
-
const isoDateTime$
|
|
4977
|
+
const isoDateTime$7 = string().datetime();
|
|
4976
4978
|
const OrganizationSchema = object({
|
|
4977
4979
|
id: string(),
|
|
4978
4980
|
name: string(),
|
|
4979
4981
|
slug: OrganizationSlugSchema,
|
|
4980
4982
|
verified: boolean(),
|
|
4981
|
-
createdAt: isoDateTime$
|
|
4982
|
-
updatedAt: isoDateTime$
|
|
4983
|
+
createdAt: isoDateTime$7,
|
|
4984
|
+
updatedAt: isoDateTime$7
|
|
4983
4985
|
});
|
|
4984
4986
|
const ProjectSchema = object({
|
|
4985
4987
|
id: string(),
|
|
@@ -4991,8 +4993,8 @@ const ProjectSchema = object({
|
|
|
4991
4993
|
baseUrl: string().nullable(),
|
|
4992
4994
|
runtimeId: string().nullable(),
|
|
4993
4995
|
lastError: string().nullable(),
|
|
4994
|
-
createdAt: isoDateTime$
|
|
4995
|
-
updatedAt: isoDateTime$
|
|
4996
|
+
createdAt: isoDateTime$7,
|
|
4997
|
+
updatedAt: isoDateTime$7
|
|
4996
4998
|
});
|
|
4997
4999
|
object({
|
|
4998
5000
|
organization: OrganizationSchema,
|
|
@@ -5012,7 +5014,7 @@ const ProjectListMetricsSchema = object({
|
|
|
5012
5014
|
workflowCount: number$1(),
|
|
5013
5015
|
skillCount: number$1(),
|
|
5014
5016
|
credentialCount: number$1(),
|
|
5015
|
-
lastDeploymentAt: isoDateTime$
|
|
5017
|
+
lastDeploymentAt: isoDateTime$7.nullable()
|
|
5016
5018
|
});
|
|
5017
5019
|
record(string(), ProjectListMetricsSchema);
|
|
5018
5020
|
object({
|
|
@@ -5031,6 +5033,14 @@ const AppSlugSchema = ProjectSlugSchema;
|
|
|
5031
5033
|
function resolveExplicitPublicPlatformOrigin(env = process.env) {
|
|
5032
5034
|
return env.PUBLIC_PLATFORM_URL?.replace(/\/$/, "") || void 0;
|
|
5033
5035
|
}
|
|
5036
|
+
function isValidIanaTimezone(value) {
|
|
5037
|
+
try {
|
|
5038
|
+
Intl.DateTimeFormat(void 0, { timeZone: value });
|
|
5039
|
+
return true;
|
|
5040
|
+
} catch {
|
|
5041
|
+
return false;
|
|
5042
|
+
}
|
|
5043
|
+
}
|
|
5034
5044
|
/** How a credential instance is stored (`credential_instances.auth_kind`). */
|
|
5035
5045
|
const CredentialAuthKindSchema = _enum([
|
|
5036
5046
|
"api_key",
|
|
@@ -5288,6 +5298,7 @@ const storedRouteManifestEntryV2Schema = discriminatedUnion("kind", [
|
|
|
5288
5298
|
name: requiredDisplayTextSchema,
|
|
5289
5299
|
description: requiredDisplayTextSchema,
|
|
5290
5300
|
model: string(),
|
|
5301
|
+
compactionModel: string().optional(),
|
|
5291
5302
|
systemPrompt: string(),
|
|
5292
5303
|
toolCount: number$1().int().nonnegative(),
|
|
5293
5304
|
credentialCount: number$1().int().nonnegative(),
|
|
@@ -5321,7 +5332,9 @@ const storedRouteManifestEntryV2Schema = discriminatedUnion("kind", [
|
|
|
5321
5332
|
/** Deterministic AST control-flow skeleton (deploy-time producer). */
|
|
5322
5333
|
flowGraph: WorkflowCanvasGraphSchema.optional(),
|
|
5323
5334
|
/** sha256 of the workflow source the `flowGraph` was produced from (staleness). */
|
|
5324
|
-
flowGraphSourceHash: string().optional()
|
|
5335
|
+
flowGraphSourceHash: string().optional(),
|
|
5336
|
+
/** sha256 of `JSON.stringify(flowGraph)` — baked at build so canvas polls skip re-hashing. */
|
|
5337
|
+
flowGraphHash: string().optional()
|
|
5325
5338
|
}),
|
|
5326
5339
|
object({
|
|
5327
5340
|
kind: literal("trigger-webhook"),
|
|
@@ -5357,6 +5370,8 @@ const storedRouteManifestEntryV2Schema = discriminatedUnion("kind", [
|
|
|
5357
5370
|
moduleFile: string(),
|
|
5358
5371
|
sourceHash: string().optional(),
|
|
5359
5372
|
schedule: string(),
|
|
5373
|
+
/** Static cron payload from `defineCronSource({ payload })` — omitted when the source has none. */
|
|
5374
|
+
payload: unknown().optional(),
|
|
5360
5375
|
name: requiredDisplayTextSchema,
|
|
5361
5376
|
description: requiredDisplayTextSchema
|
|
5362
5377
|
})
|
|
@@ -5367,6 +5382,171 @@ object({
|
|
|
5367
5382
|
skills: array(StoredRouteManifestSkillSchema).default([]),
|
|
5368
5383
|
integrations: array(string()).optional()
|
|
5369
5384
|
});
|
|
5385
|
+
const isoDateTime$6 = string().datetime();
|
|
5386
|
+
const subscriptionStatusSchema = _enum([
|
|
5387
|
+
"none",
|
|
5388
|
+
"trialing",
|
|
5389
|
+
"active",
|
|
5390
|
+
"past_due",
|
|
5391
|
+
"canceled"
|
|
5392
|
+
]);
|
|
5393
|
+
const CreditPackSchema = object({
|
|
5394
|
+
id: string(),
|
|
5395
|
+
usd: number$1(),
|
|
5396
|
+
microCredits: number$1(),
|
|
5397
|
+
label: string()
|
|
5398
|
+
});
|
|
5399
|
+
const AutoTopupSummarySchema = object({
|
|
5400
|
+
enabled: boolean(),
|
|
5401
|
+
thresholdMicroCredits: number$1().nullable(),
|
|
5402
|
+
amountMicroCredits: number$1().nullable(),
|
|
5403
|
+
/** A saved payment method exists to charge off-session. */
|
|
5404
|
+
hasPaymentMethod: boolean(),
|
|
5405
|
+
/** A top-up invoice payment is in flight. */
|
|
5406
|
+
pending: boolean()
|
|
5407
|
+
});
|
|
5408
|
+
/**
|
|
5409
|
+
* The plan's resolved limits. Storage overage is billed from the wallet's
|
|
5410
|
+
* pushed-down `includedStorageGb`; concurrency, per-pass run timeouts, and
|
|
5411
|
+
* API/MCP rate limits are enforced from the wallet (timeouts/concurrency) or
|
|
5412
|
+
* plan preset (rate limits). Log retention is configured but not pruned yet.
|
|
5413
|
+
*/
|
|
5414
|
+
const PlanLimitsSchema = object({
|
|
5415
|
+
includedStorageGb: number$1(),
|
|
5416
|
+
concurrencyLimit: number$1(),
|
|
5417
|
+
agentTimeoutMs: number$1(),
|
|
5418
|
+
workflowTimeoutMs: number$1(),
|
|
5419
|
+
pollTimeoutMs: number$1(),
|
|
5420
|
+
/** Configured retention window; pruning not implemented yet. */
|
|
5421
|
+
logRetentionDays: number$1(),
|
|
5422
|
+
apiRateLimitCapacity: number$1(),
|
|
5423
|
+
apiRateLimitRefillPerSec: number$1(),
|
|
5424
|
+
mcpRateLimitCapacity: number$1(),
|
|
5425
|
+
mcpRateLimitRefillPerSec: number$1()
|
|
5426
|
+
});
|
|
5427
|
+
object({
|
|
5428
|
+
planKey: string(),
|
|
5429
|
+
subscriptionStatus: subscriptionStatusSchema,
|
|
5430
|
+
planCreditMicroCredits: number$1(),
|
|
5431
|
+
prepaidCreditMicroCredits: number$1(),
|
|
5432
|
+
periodStart: isoDateTime$6.nullable(),
|
|
5433
|
+
periodEnd: isoDateTime$6.nullable(),
|
|
5434
|
+
autoTopup: AutoTopupSummarySchema,
|
|
5435
|
+
creditPacks: array(CreditPackSchema),
|
|
5436
|
+
limits: PlanLimitsSchema
|
|
5437
|
+
});
|
|
5438
|
+
const BillingUsageMeterSchema = object({
|
|
5439
|
+
/** Meter key (`llm`, `vm_second`, …); null groups uncategorized rows. */
|
|
5440
|
+
meterKey: string().nullable(),
|
|
5441
|
+
/** Charged this period, µc. */
|
|
5442
|
+
microCredits: number$1(),
|
|
5443
|
+
/** Tracked-but-not-charged usage (e.g. BYOK LLM calls), display USD. */
|
|
5444
|
+
unchargedUsd: number$1()
|
|
5445
|
+
});
|
|
5446
|
+
object({
|
|
5447
|
+
periodStart: isoDateTime$6.nullable(),
|
|
5448
|
+
periodEnd: isoDateTime$6.nullable(),
|
|
5449
|
+
totalMicroCredits: number$1(),
|
|
5450
|
+
byMeter: array(BillingUsageMeterSchema)
|
|
5451
|
+
});
|
|
5452
|
+
const billingLedgerEntryTypeSchema = _enum([
|
|
5453
|
+
"grant_plan",
|
|
5454
|
+
"grant_prepaid",
|
|
5455
|
+
"expire_plan",
|
|
5456
|
+
"adjustment"
|
|
5457
|
+
]);
|
|
5458
|
+
object({
|
|
5459
|
+
entries: array(object({
|
|
5460
|
+
id: string(),
|
|
5461
|
+
entryType: billingLedgerEntryTypeSchema,
|
|
5462
|
+
label: string(),
|
|
5463
|
+
/** Signed: positive grants, negative expirations/adjustments. */
|
|
5464
|
+
microCredits: number$1(),
|
|
5465
|
+
bucket: _enum(["plan", "prepaid"]).nullable(),
|
|
5466
|
+
/** Stripe invoice behind the entry, when there is one — powers "View invoice". */
|
|
5467
|
+
stripeInvoiceId: string().nullable(),
|
|
5468
|
+
createdAt: isoDateTime$6
|
|
5469
|
+
})),
|
|
5470
|
+
/** Set only when the latest payment failure is newer than the latest successful payment. */
|
|
5471
|
+
lastPaymentFailureAt: isoDateTime$6.nullable()
|
|
5472
|
+
});
|
|
5473
|
+
object({
|
|
5474
|
+
/** Web-app path to land on after Checkout (must be a path, not a URL). */
|
|
5475
|
+
returnPath: string().startsWith("/").max(512).optional() });
|
|
5476
|
+
object({
|
|
5477
|
+
packId: string(),
|
|
5478
|
+
returnPath: string().startsWith("/").max(512).optional()
|
|
5479
|
+
});
|
|
5480
|
+
object({ returnPath: string().startsWith("/").max(512).optional() });
|
|
5481
|
+
object({ url: string().url() });
|
|
5482
|
+
object({
|
|
5483
|
+
/** Hosted invoice page (view, download, receipt). */
|
|
5484
|
+
url: string().url(),
|
|
5485
|
+
/** Direct PDF download when Stripe provides one. */
|
|
5486
|
+
pdf: string().url().nullable()
|
|
5487
|
+
});
|
|
5488
|
+
object({
|
|
5489
|
+
/** Stripe Checkout Session id from the `session_id` success-URL param. */
|
|
5490
|
+
sessionId: string().min(1).max(255) });
|
|
5491
|
+
object({
|
|
5492
|
+
/**
|
|
5493
|
+
* `granted` — credits are in the wallet now; `processing` — payment not
|
|
5494
|
+
* complete yet, the webhook will finish it; `ignored` — not a confirmable
|
|
5495
|
+
* session for this org.
|
|
5496
|
+
*/
|
|
5497
|
+
status: _enum([
|
|
5498
|
+
"granted",
|
|
5499
|
+
"processing",
|
|
5500
|
+
"ignored"
|
|
5501
|
+
]),
|
|
5502
|
+
reason: string().optional()
|
|
5503
|
+
});
|
|
5504
|
+
object({
|
|
5505
|
+
enabled: boolean(),
|
|
5506
|
+
thresholdMicroCredits: number$1().int().positive().optional(),
|
|
5507
|
+
packId: string().optional()
|
|
5508
|
+
});
|
|
5509
|
+
const BillingUsageEventSourceSchema = _enum([
|
|
5510
|
+
"ai_gateway",
|
|
5511
|
+
"sandbox",
|
|
5512
|
+
"web_proxy",
|
|
5513
|
+
"storage",
|
|
5514
|
+
"dispatch",
|
|
5515
|
+
"poll"
|
|
5516
|
+
]);
|
|
5517
|
+
const BillingUsageMeterKeySchema = _enum([
|
|
5518
|
+
"llm",
|
|
5519
|
+
"vm_second",
|
|
5520
|
+
"web_search",
|
|
5521
|
+
"web_fetch",
|
|
5522
|
+
"workflow_run",
|
|
5523
|
+
"agent_run",
|
|
5524
|
+
"poll_trigger",
|
|
5525
|
+
"tigris_storage"
|
|
5526
|
+
]);
|
|
5527
|
+
const BillingUsageKeySourceSchema = _enum(["platform", "byok"]);
|
|
5528
|
+
const BillingUsageRunKindSchema = _enum(["agent", "workflow"]);
|
|
5529
|
+
object({ events: array(object({
|
|
5530
|
+
projectId: string().min(1).max(255).nullable().optional(),
|
|
5531
|
+
runId: string().min(1).max(255).nullable().optional(),
|
|
5532
|
+
runKind: BillingUsageRunKindSchema.nullable().optional(),
|
|
5533
|
+
source: BillingUsageEventSourceSchema,
|
|
5534
|
+
sourceEventId: string().min(1).max(512),
|
|
5535
|
+
meterKey: BillingUsageMeterKeySchema,
|
|
5536
|
+
quantity: number$1().finite().nonnegative(),
|
|
5537
|
+
unit: string().min(1).max(64),
|
|
5538
|
+
providerCostUsd: number$1().finite().nonnegative().nullable().optional(),
|
|
5539
|
+
keySource: BillingUsageKeySourceSchema.nullable().optional(),
|
|
5540
|
+
occurredAt: isoDateTime$6,
|
|
5541
|
+
metadata: record(string(), unknown()).nullable().optional()
|
|
5542
|
+
}).strict()).min(1).max(100) }).strict();
|
|
5543
|
+
object({
|
|
5544
|
+
accepted: number$1().int().nonnegative(),
|
|
5545
|
+
inserted: number$1().int().nonnegative(),
|
|
5546
|
+
duplicate: number$1().int().nonnegative(),
|
|
5547
|
+
settledLedgerId: string().nullable(),
|
|
5548
|
+
chargeMicroCredits: number$1().int().nonnegative()
|
|
5549
|
+
});
|
|
5370
5550
|
/** Messaging platforms that support agent gateway bindings. */
|
|
5371
5551
|
const ChannelPlatformKeySchema = _enum(["slack"]);
|
|
5372
5552
|
const ChannelReactionSupportSchema = _enum([
|
|
@@ -5666,15 +5846,18 @@ object({
|
|
|
5666
5846
|
integrationDescription: string().min(1),
|
|
5667
5847
|
logo: string().url().nullable().optional(),
|
|
5668
5848
|
authKind: AppAuthKindSchema,
|
|
5669
|
-
oauthScopes: array(OAuthScopeOptionSchema),
|
|
5670
5849
|
/** Where app metadata and execution are sourced (e.g. composio, custom). */
|
|
5671
5850
|
source: AppSourceSchema,
|
|
5851
|
+
/** Endpoint URL for MCP, OpenAPI, or GraphQL custom apps. */
|
|
5852
|
+
url: string().url().nullable().optional(),
|
|
5853
|
+
/** True when the app has a non-empty credential field template. */
|
|
5854
|
+
hasCredentialFields: boolean().optional()
|
|
5855
|
+
}).extend({
|
|
5856
|
+
oauthScopes: array(OAuthScopeOptionSchema),
|
|
5672
5857
|
/** Custom api_key apps — vault field template for connect UI and sync. */
|
|
5673
5858
|
credentialFields: AppCredentialFieldsSchema.optional(),
|
|
5674
5859
|
/** Composio auth scheme when credentialFields are present. */
|
|
5675
5860
|
credentialScheme: AppCredentialSchemeSchema.optional(),
|
|
5676
|
-
/** Endpoint URL for MCP, OpenAPI, or GraphQL custom apps. */
|
|
5677
|
-
url: string().url().nullable().optional(),
|
|
5678
5861
|
/** When present, the app supports agent gateway bindings (external channels). */
|
|
5679
5862
|
gateway: AppGatewaySchema.optional()
|
|
5680
5863
|
});
|
|
@@ -5796,7 +5979,11 @@ const AppCredentialConnectionKindSchema = _enum(["oauth", "manual"]);
|
|
|
5796
5979
|
const OAuthPermissionModeSchema = _enum(["default", "restricted"]);
|
|
5797
5980
|
const optionalTimestamp$1 = string().optional();
|
|
5798
5981
|
const nullableOptionalTimestamp = string().nullable().optional();
|
|
5799
|
-
|
|
5982
|
+
/**
|
|
5983
|
+
* Summary row for the apps/credentials table and credential detail page.
|
|
5984
|
+
* Plaintext secrets are never returned — only masked `keyPreviews`.
|
|
5985
|
+
*/
|
|
5986
|
+
const AppCredentialSummarySchema = object({
|
|
5800
5987
|
id: string().min(1),
|
|
5801
5988
|
appId: string().min(1),
|
|
5802
5989
|
/** Stable per-scope identifier; pass to `--credential` to pin a specific instance. */
|
|
@@ -5887,7 +6074,19 @@ object({
|
|
|
5887
6074
|
isDefault: boolean().optional(),
|
|
5888
6075
|
value: credentialSecretValueSchema.optional()
|
|
5889
6076
|
}).refine((input) => input.label !== void 0 || input.isDefault !== void 0 || input.value !== void 0, { message: "At least one field is required" });
|
|
5890
|
-
|
|
6077
|
+
object({
|
|
6078
|
+
limit: number().int().min(1).max(200).optional(),
|
|
6079
|
+
cursor: string().min(1).optional()
|
|
6080
|
+
});
|
|
6081
|
+
object({
|
|
6082
|
+
items: array(AppCredentialSummarySchema),
|
|
6083
|
+
nextCursor: string().nullable()
|
|
6084
|
+
});
|
|
6085
|
+
const CredentialAssignmentTargetTypeSchema = _enum([
|
|
6086
|
+
"workflow",
|
|
6087
|
+
"agent",
|
|
6088
|
+
"poll"
|
|
6089
|
+
]);
|
|
5891
6090
|
object({ assignments: array(object({
|
|
5892
6091
|
id: string(),
|
|
5893
6092
|
targetType: CredentialAssignmentTargetTypeSchema,
|
|
@@ -6002,7 +6201,11 @@ const ValidationErrorDetailSchema = object({
|
|
|
6002
6201
|
message: string()
|
|
6003
6202
|
});
|
|
6004
6203
|
/** Machine-readable codes returned in standard API error bodies. */
|
|
6005
|
-
const ErrorResponseCodeSchema = OrganizationSlugErrorCodeSchema.or(_enum([
|
|
6204
|
+
const ErrorResponseCodeSchema = OrganizationSlugErrorCodeSchema.or(_enum([
|
|
6205
|
+
"needs_org_selection",
|
|
6206
|
+
"org_unverified",
|
|
6207
|
+
"connector_unavailable"
|
|
6208
|
+
]));
|
|
6006
6209
|
object({
|
|
6007
6210
|
error: string(),
|
|
6008
6211
|
code: ErrorResponseCodeSchema.optional(),
|
|
@@ -6113,6 +6316,17 @@ union([
|
|
|
6113
6316
|
SkipResponseSchema,
|
|
6114
6317
|
object({ runId: string() })
|
|
6115
6318
|
]);
|
|
6319
|
+
object({
|
|
6320
|
+
sql: string().min(1),
|
|
6321
|
+
params: array(unknown()).default([]),
|
|
6322
|
+
method: string().min(1).optional()
|
|
6323
|
+
});
|
|
6324
|
+
object({ migrations: array(object({
|
|
6325
|
+
sql: array(string().min(1)),
|
|
6326
|
+
hash: string().min(1),
|
|
6327
|
+
folderMillis: number$1()
|
|
6328
|
+
})) });
|
|
6329
|
+
object({ results: array(object({ rows: array(unknown()) })) });
|
|
6116
6330
|
const RunSourceKindSchema = _enum([
|
|
6117
6331
|
"api",
|
|
6118
6332
|
"trigger",
|
|
@@ -6151,6 +6365,191 @@ object({
|
|
|
6151
6365
|
attachmentId: string(),
|
|
6152
6366
|
attachmentSlug: string()
|
|
6153
6367
|
});
|
|
6368
|
+
const HistoryRunKindSchema = _enum(["workflow", "agent"]);
|
|
6369
|
+
const HistoryRunStatusSchema = _enum([
|
|
6370
|
+
"pending",
|
|
6371
|
+
"running",
|
|
6372
|
+
"sleeping",
|
|
6373
|
+
"waiting_hook",
|
|
6374
|
+
"completed",
|
|
6375
|
+
"failed",
|
|
6376
|
+
"canceled"
|
|
6377
|
+
]);
|
|
6378
|
+
const HistoryRunActorSchema = object({
|
|
6379
|
+
userId: string(),
|
|
6380
|
+
name: string(),
|
|
6381
|
+
avatarUrl: string().nullable().optional()
|
|
6382
|
+
});
|
|
6383
|
+
const HistoryRunUsageLineItemSchema = object({
|
|
6384
|
+
id: string(),
|
|
6385
|
+
label: string(),
|
|
6386
|
+
/** Amount debited from the org's Keystroke balance for this line. */
|
|
6387
|
+
billedUsd: number$1(),
|
|
6388
|
+
/** Provider cost for LLM usage on the org's API key (informational; not billed by Keystroke). */
|
|
6389
|
+
providerCostUsd: number$1().nullable().optional(),
|
|
6390
|
+
keySource: _enum(["byok", "platform"]).nullable().optional()
|
|
6391
|
+
});
|
|
6392
|
+
const HistoryRunUsageSchema = object({
|
|
6393
|
+
runDurationMs: number$1().nullable(),
|
|
6394
|
+
lineItems: array(HistoryRunUsageLineItemSchema),
|
|
6395
|
+
/** Sum of `billedUsd` — what Keystroke charged for this run. */
|
|
6396
|
+
totalBilledUsd: number$1().nullable(),
|
|
6397
|
+
/** Sum of BYOK LLM provider costs (billed externally by the org's provider). */
|
|
6398
|
+
externalProviderCostUsd: number$1().nullable().optional()
|
|
6399
|
+
});
|
|
6400
|
+
const HistoryRunSchema = object({
|
|
6401
|
+
id: string(),
|
|
6402
|
+
kind: HistoryRunKindSchema,
|
|
6403
|
+
traceId: string().nullable(),
|
|
6404
|
+
projectId: string(),
|
|
6405
|
+
projectName: string(),
|
|
6406
|
+
resourceKey: string(),
|
|
6407
|
+
resourceId: string(),
|
|
6408
|
+
resourceName: string(),
|
|
6409
|
+
status: HistoryRunStatusSchema,
|
|
6410
|
+
triggeredAt: string(),
|
|
6411
|
+
timeInQueueMs: number$1().nullable(),
|
|
6412
|
+
startedAt: string(),
|
|
6413
|
+
finishedAt: string().nullable(),
|
|
6414
|
+
durationMs: number$1().nullable(),
|
|
6415
|
+
triggerLabel: string(),
|
|
6416
|
+
triggerRaw: string(),
|
|
6417
|
+
ranAs: HistoryRunActorSchema.nullable(),
|
|
6418
|
+
modelsUsed: array(string()),
|
|
6419
|
+
otherServicesUsed: array(string()),
|
|
6420
|
+
totalCostUsd: number$1().nullable(),
|
|
6421
|
+
messageCount: number$1().optional(),
|
|
6422
|
+
stepCount: number$1().optional()
|
|
6423
|
+
});
|
|
6424
|
+
const HistoryTraceSpanSchema = object({
|
|
6425
|
+
id: string(),
|
|
6426
|
+
traceId: string(),
|
|
6427
|
+
parentSpanId: string().nullable(),
|
|
6428
|
+
kind: string(),
|
|
6429
|
+
refId: string(),
|
|
6430
|
+
name: string(),
|
|
6431
|
+
status: string(),
|
|
6432
|
+
startedAt: string(),
|
|
6433
|
+
finishedAt: string().nullable(),
|
|
6434
|
+
metadata: unknown().nullable(),
|
|
6435
|
+
error: unknown().nullable()
|
|
6436
|
+
});
|
|
6437
|
+
const HistoryTraceLogSchema = object({
|
|
6438
|
+
id: string(),
|
|
6439
|
+
traceId: string(),
|
|
6440
|
+
spanId: string(),
|
|
6441
|
+
seq: number$1(),
|
|
6442
|
+
level: string(),
|
|
6443
|
+
message: string(),
|
|
6444
|
+
data: unknown().nullable(),
|
|
6445
|
+
source: string(),
|
|
6446
|
+
createdAt: string()
|
|
6447
|
+
});
|
|
6448
|
+
const HistoryTraceTriggerSchema = object({
|
|
6449
|
+
triggerType: string(),
|
|
6450
|
+
triggerRunId: string(),
|
|
6451
|
+
workflowKey: string().optional(),
|
|
6452
|
+
agentKey: string().optional(),
|
|
6453
|
+
attachmentId: string().nullable().optional(),
|
|
6454
|
+
attachmentSlug: string().nullable().optional(),
|
|
6455
|
+
route: string().optional(),
|
|
6456
|
+
sourcePath: string().nullable().optional()
|
|
6457
|
+
}).nullable();
|
|
6458
|
+
const HistoryTraceGatewaySchema = object({
|
|
6459
|
+
gatewayAttachmentId: string(),
|
|
6460
|
+
gatewayAttachmentKey: string(),
|
|
6461
|
+
threadId: string().optional(),
|
|
6462
|
+
channelId: string().optional(),
|
|
6463
|
+
mode: string().optional()
|
|
6464
|
+
}).nullable();
|
|
6465
|
+
const HistoryTraceSchema = object({
|
|
6466
|
+
traceId: string(),
|
|
6467
|
+
trigger: HistoryTraceTriggerSchema,
|
|
6468
|
+
gateway: HistoryTraceGatewaySchema,
|
|
6469
|
+
spans: array(HistoryTraceSpanSchema),
|
|
6470
|
+
logs: array(HistoryTraceLogSchema)
|
|
6471
|
+
});
|
|
6472
|
+
const HistoryWorkflowStepSchema = object({
|
|
6473
|
+
id: string(),
|
|
6474
|
+
actionKey: string(),
|
|
6475
|
+
output: unknown(),
|
|
6476
|
+
completedAt: string()
|
|
6477
|
+
});
|
|
6478
|
+
const HistoryWorkflowRunDetailSchema = object({
|
|
6479
|
+
kind: literal("workflow"),
|
|
6480
|
+
run: object({
|
|
6481
|
+
id: string(),
|
|
6482
|
+
workflowKey: string(),
|
|
6483
|
+
status: HistoryRunStatusSchema,
|
|
6484
|
+
trigger: string(),
|
|
6485
|
+
triggeredAt: string(),
|
|
6486
|
+
startedAt: string().nullable(),
|
|
6487
|
+
finishedAt: string().nullable(),
|
|
6488
|
+
input: unknown().nullable(),
|
|
6489
|
+
output: unknown().nullable(),
|
|
6490
|
+
error: unknown().nullable()
|
|
6491
|
+
}),
|
|
6492
|
+
trigger: object({
|
|
6493
|
+
id: string(),
|
|
6494
|
+
attachmentSlug: string().nullable(),
|
|
6495
|
+
triggerType: string(),
|
|
6496
|
+
sourcePath: string().nullable(),
|
|
6497
|
+
payload: unknown().nullable(),
|
|
6498
|
+
triggeredAt: string()
|
|
6499
|
+
}).nullable(),
|
|
6500
|
+
steps: array(HistoryWorkflowStepSchema),
|
|
6501
|
+
trace: HistoryTraceSchema.nullable(),
|
|
6502
|
+
ranAs: HistoryRunActorSchema.nullable().optional(),
|
|
6503
|
+
usage: HistoryRunUsageSchema.nullable().optional()
|
|
6504
|
+
});
|
|
6505
|
+
const HistoryAgentCompactionEventSchema = object({
|
|
6506
|
+
seq: number$1(),
|
|
6507
|
+
createdAt: string(),
|
|
6508
|
+
compactionModel: string(),
|
|
6509
|
+
sourceModel: string(),
|
|
6510
|
+
estimatedBeforeTokens: number$1().optional(),
|
|
6511
|
+
retainedTailEstimate: number$1().optional(),
|
|
6512
|
+
durable: boolean()
|
|
6513
|
+
});
|
|
6514
|
+
const HistoryRunDetailSchema = discriminatedUnion("kind", [HistoryWorkflowRunDetailSchema, object({
|
|
6515
|
+
kind: literal("agent"),
|
|
6516
|
+
runId: string(),
|
|
6517
|
+
session: object({
|
|
6518
|
+
id: string(),
|
|
6519
|
+
agentKey: string(),
|
|
6520
|
+
status: HistoryRunStatusSchema,
|
|
6521
|
+
source: _enum([
|
|
6522
|
+
"api",
|
|
6523
|
+
"gateway",
|
|
6524
|
+
"trigger",
|
|
6525
|
+
"workflow",
|
|
6526
|
+
"agent"
|
|
6527
|
+
]),
|
|
6528
|
+
sourceId: string().nullable(),
|
|
6529
|
+
createdAt: string(),
|
|
6530
|
+
updatedAt: string(),
|
|
6531
|
+
messageCount: number$1(),
|
|
6532
|
+
error: unknown().nullable()
|
|
6533
|
+
}),
|
|
6534
|
+
gateway: object({
|
|
6535
|
+
threadId: string(),
|
|
6536
|
+
attachmentSlug: string().nullable()
|
|
6537
|
+
}).nullable(),
|
|
6538
|
+
messages: array(record(string(), unknown())),
|
|
6539
|
+
/** Sanitized context-compaction markers for the conversation timeline. */
|
|
6540
|
+
compactionEvents: array(HistoryAgentCompactionEventSchema).default([]),
|
|
6541
|
+
trace: HistoryTraceSchema.nullable(),
|
|
6542
|
+
ranAs: HistoryRunActorSchema.nullable().optional(),
|
|
6543
|
+
usage: HistoryRunUsageSchema.nullable().optional()
|
|
6544
|
+
})]);
|
|
6545
|
+
object({
|
|
6546
|
+
project: string().min(1).optional(),
|
|
6547
|
+
status: HistoryRunStatusSchema.optional(),
|
|
6548
|
+
kind: HistoryRunKindSchema.optional(),
|
|
6549
|
+
limit: number().int().min(1).max(200).optional()
|
|
6550
|
+
});
|
|
6551
|
+
HistoryRunDetailSchema.nullable();
|
|
6552
|
+
HistoryRunSchema.nullable();
|
|
6154
6553
|
const WorkflowRunStatusSchema = _enum([
|
|
6155
6554
|
"pending",
|
|
6156
6555
|
"running",
|
|
@@ -6332,6 +6731,7 @@ const AgentSessionRecordSchema = object({
|
|
|
6332
6731
|
status: AgentSessionStatusSchema,
|
|
6333
6732
|
source: RunSourceKindSchema,
|
|
6334
6733
|
sourceId: string().nullable(),
|
|
6734
|
+
title: string().nullable(),
|
|
6335
6735
|
createdAt: string(),
|
|
6336
6736
|
updatedAt: string(),
|
|
6337
6737
|
parentSpanId: string().nullable(),
|
|
@@ -6370,17 +6770,18 @@ const AgentEventSchema = object({
|
|
|
6370
6770
|
});
|
|
6371
6771
|
object({
|
|
6372
6772
|
session: AgentSessionRecordSchema,
|
|
6773
|
+
activeRunId: string().nullable().default(null),
|
|
6373
6774
|
gateway: GatewaySessionDetailSchema.nullable(),
|
|
6374
6775
|
messages: array(record(string(), unknown())),
|
|
6375
6776
|
events: array(AgentEventSchema),
|
|
6777
|
+
/**
|
|
6778
|
+
* Sanitized context-compaction markers, populated alongside `messages`.
|
|
6779
|
+
* A cheap indexed lookup (session_id + event_type) — never the full event
|
|
6780
|
+
* log. Defaulted so older servers remain compatible.
|
|
6781
|
+
*/
|
|
6782
|
+
compactionEvents: array(HistoryAgentCompactionEventSchema).default([]),
|
|
6376
6783
|
trace: TraceResponseSchema.nullable()
|
|
6377
6784
|
});
|
|
6378
|
-
object({ sinceSeq: number().int().min(0).optional() });
|
|
6379
|
-
object({
|
|
6380
|
-
status: AgentSessionStatusSchema,
|
|
6381
|
-
messages: array(record(string(), unknown())),
|
|
6382
|
-
live: record(string(), unknown()).nullable()
|
|
6383
|
-
});
|
|
6384
6785
|
const SlackGatewayModeSchema = _enum([
|
|
6385
6786
|
"mention",
|
|
6386
6787
|
"channel",
|
|
@@ -6415,171 +6816,6 @@ object({ agents: array(object({
|
|
|
6415
6816
|
name: string().optional(),
|
|
6416
6817
|
route: string()
|
|
6417
6818
|
})) });
|
|
6418
|
-
const HistoryRunKindSchema = _enum(["workflow", "agent"]);
|
|
6419
|
-
const HistoryRunStatusSchema = _enum([
|
|
6420
|
-
"pending",
|
|
6421
|
-
"running",
|
|
6422
|
-
"sleeping",
|
|
6423
|
-
"waiting_hook",
|
|
6424
|
-
"completed",
|
|
6425
|
-
"failed",
|
|
6426
|
-
"canceled"
|
|
6427
|
-
]);
|
|
6428
|
-
const HistoryRunActorSchema = object({
|
|
6429
|
-
userId: string(),
|
|
6430
|
-
name: string(),
|
|
6431
|
-
avatarUrl: string().nullable().optional()
|
|
6432
|
-
});
|
|
6433
|
-
const HistoryRunUsageLineItemSchema = object({
|
|
6434
|
-
id: string(),
|
|
6435
|
-
label: string(),
|
|
6436
|
-
amountUsd: number$1()
|
|
6437
|
-
});
|
|
6438
|
-
const HistoryRunUsageSchema = object({
|
|
6439
|
-
runDurationMs: number$1().nullable(),
|
|
6440
|
-
lineItems: array(HistoryRunUsageLineItemSchema),
|
|
6441
|
-
totalExcludingDurationUsd: number$1().nullable()
|
|
6442
|
-
});
|
|
6443
|
-
const HistoryRunSchema = object({
|
|
6444
|
-
id: string(),
|
|
6445
|
-
kind: HistoryRunKindSchema,
|
|
6446
|
-
traceId: string().nullable(),
|
|
6447
|
-
projectId: string(),
|
|
6448
|
-
projectName: string(),
|
|
6449
|
-
resourceKey: string(),
|
|
6450
|
-
resourceId: string(),
|
|
6451
|
-
resourceName: string(),
|
|
6452
|
-
status: HistoryRunStatusSchema,
|
|
6453
|
-
triggeredAt: string(),
|
|
6454
|
-
timeInQueueMs: number$1().nullable(),
|
|
6455
|
-
startedAt: string(),
|
|
6456
|
-
finishedAt: string().nullable(),
|
|
6457
|
-
durationMs: number$1().nullable(),
|
|
6458
|
-
triggerLabel: string(),
|
|
6459
|
-
triggerRaw: string(),
|
|
6460
|
-
ranAs: HistoryRunActorSchema.nullable(),
|
|
6461
|
-
modelsUsed: array(string()),
|
|
6462
|
-
otherServicesUsed: array(string()),
|
|
6463
|
-
totalCostUsd: number$1().nullable(),
|
|
6464
|
-
messageCount: number$1().optional(),
|
|
6465
|
-
stepCount: number$1().optional()
|
|
6466
|
-
});
|
|
6467
|
-
const HistoryTraceSpanSchema = object({
|
|
6468
|
-
id: string(),
|
|
6469
|
-
traceId: string(),
|
|
6470
|
-
parentSpanId: string().nullable(),
|
|
6471
|
-
kind: string(),
|
|
6472
|
-
refId: string(),
|
|
6473
|
-
name: string(),
|
|
6474
|
-
status: string(),
|
|
6475
|
-
startedAt: string(),
|
|
6476
|
-
finishedAt: string().nullable(),
|
|
6477
|
-
metadata: unknown().nullable(),
|
|
6478
|
-
error: unknown().nullable()
|
|
6479
|
-
});
|
|
6480
|
-
const HistoryTraceLogSchema = object({
|
|
6481
|
-
id: string(),
|
|
6482
|
-
traceId: string(),
|
|
6483
|
-
spanId: string(),
|
|
6484
|
-
seq: number$1(),
|
|
6485
|
-
level: string(),
|
|
6486
|
-
message: string(),
|
|
6487
|
-
data: unknown().nullable(),
|
|
6488
|
-
source: string(),
|
|
6489
|
-
createdAt: string()
|
|
6490
|
-
});
|
|
6491
|
-
const HistoryTraceTriggerSchema = object({
|
|
6492
|
-
triggerType: string(),
|
|
6493
|
-
triggerRunId: string(),
|
|
6494
|
-
workflowKey: string().optional(),
|
|
6495
|
-
agentKey: string().optional(),
|
|
6496
|
-
attachmentId: string().nullable().optional(),
|
|
6497
|
-
attachmentSlug: string().nullable().optional(),
|
|
6498
|
-
route: string().optional(),
|
|
6499
|
-
sourcePath: string().nullable().optional()
|
|
6500
|
-
}).nullable();
|
|
6501
|
-
const HistoryTraceGatewaySchema = object({
|
|
6502
|
-
gatewayAttachmentId: string(),
|
|
6503
|
-
gatewayAttachmentKey: string(),
|
|
6504
|
-
threadId: string().optional(),
|
|
6505
|
-
channelId: string().optional(),
|
|
6506
|
-
mode: string().optional()
|
|
6507
|
-
}).nullable();
|
|
6508
|
-
const HistoryTraceSchema = object({
|
|
6509
|
-
traceId: string(),
|
|
6510
|
-
trigger: HistoryTraceTriggerSchema,
|
|
6511
|
-
gateway: HistoryTraceGatewaySchema,
|
|
6512
|
-
spans: array(HistoryTraceSpanSchema),
|
|
6513
|
-
logs: array(HistoryTraceLogSchema)
|
|
6514
|
-
});
|
|
6515
|
-
const HistoryWorkflowStepSchema = object({
|
|
6516
|
-
id: string(),
|
|
6517
|
-
actionKey: string(),
|
|
6518
|
-
output: unknown(),
|
|
6519
|
-
completedAt: string()
|
|
6520
|
-
});
|
|
6521
|
-
const HistoryRunDetailSchema = discriminatedUnion("kind", [object({
|
|
6522
|
-
kind: literal("workflow"),
|
|
6523
|
-
run: object({
|
|
6524
|
-
id: string(),
|
|
6525
|
-
workflowKey: string(),
|
|
6526
|
-
status: HistoryRunStatusSchema,
|
|
6527
|
-
trigger: string(),
|
|
6528
|
-
triggeredAt: string(),
|
|
6529
|
-
startedAt: string().nullable(),
|
|
6530
|
-
finishedAt: string().nullable(),
|
|
6531
|
-
input: unknown().nullable(),
|
|
6532
|
-
output: unknown().nullable(),
|
|
6533
|
-
error: unknown().nullable()
|
|
6534
|
-
}),
|
|
6535
|
-
trigger: object({
|
|
6536
|
-
id: string(),
|
|
6537
|
-
attachmentSlug: string().nullable(),
|
|
6538
|
-
triggerType: string(),
|
|
6539
|
-
sourcePath: string().nullable(),
|
|
6540
|
-
payload: unknown().nullable(),
|
|
6541
|
-
triggeredAt: string()
|
|
6542
|
-
}).nullable(),
|
|
6543
|
-
steps: array(HistoryWorkflowStepSchema),
|
|
6544
|
-
trace: HistoryTraceSchema.nullable(),
|
|
6545
|
-
ranAs: HistoryRunActorSchema.nullable().optional(),
|
|
6546
|
-
usage: HistoryRunUsageSchema.nullable().optional()
|
|
6547
|
-
}), object({
|
|
6548
|
-
kind: literal("agent"),
|
|
6549
|
-
runId: string(),
|
|
6550
|
-
session: object({
|
|
6551
|
-
id: string(),
|
|
6552
|
-
agentKey: string(),
|
|
6553
|
-
status: HistoryRunStatusSchema,
|
|
6554
|
-
source: _enum([
|
|
6555
|
-
"api",
|
|
6556
|
-
"gateway",
|
|
6557
|
-
"trigger",
|
|
6558
|
-
"workflow",
|
|
6559
|
-
"agent"
|
|
6560
|
-
]),
|
|
6561
|
-
sourceId: string().nullable(),
|
|
6562
|
-
createdAt: string(),
|
|
6563
|
-
updatedAt: string(),
|
|
6564
|
-
messageCount: number$1(),
|
|
6565
|
-
error: unknown().nullable()
|
|
6566
|
-
}),
|
|
6567
|
-
gateway: object({
|
|
6568
|
-
threadId: string(),
|
|
6569
|
-
attachmentSlug: string().nullable()
|
|
6570
|
-
}).nullable(),
|
|
6571
|
-
messages: array(record(string(), unknown())),
|
|
6572
|
-
trace: HistoryTraceSchema.nullable(),
|
|
6573
|
-
ranAs: HistoryRunActorSchema.nullable().optional(),
|
|
6574
|
-
usage: HistoryRunUsageSchema.nullable().optional()
|
|
6575
|
-
})]);
|
|
6576
|
-
object({
|
|
6577
|
-
project: string().min(1).optional(),
|
|
6578
|
-
status: HistoryRunStatusSchema.optional(),
|
|
6579
|
-
kind: HistoryRunKindSchema.optional()
|
|
6580
|
-
});
|
|
6581
|
-
HistoryRunDetailSchema.nullable();
|
|
6582
|
-
HistoryRunSchema.nullable();
|
|
6583
6819
|
object({ subscriptions: array(object({
|
|
6584
6820
|
id: string(),
|
|
6585
6821
|
workflowKey: string(),
|
|
@@ -6674,7 +6910,8 @@ const TriggerRunRecordSchema = object({
|
|
|
6674
6910
|
object({
|
|
6675
6911
|
limit: number().int().min(1).max(100).optional().default(20),
|
|
6676
6912
|
cursor: string().min(1).optional(),
|
|
6677
|
-
triggerType: TriggerRunTypeSchema.optional()
|
|
6913
|
+
triggerType: TriggerRunTypeSchema.optional(),
|
|
6914
|
+
outcome: TriggerRunOutcomeSchema.optional()
|
|
6678
6915
|
});
|
|
6679
6916
|
object({
|
|
6680
6917
|
items: array(TriggerRunSummarySchema),
|
|
@@ -6742,7 +6979,8 @@ const WorkspaceTriggerRunStatusSchema = _enum([
|
|
|
6742
6979
|
const WorkspaceTriggerSkipReasonSchema = _enum([
|
|
6743
6980
|
"filtered",
|
|
6744
6981
|
"no_new_data",
|
|
6745
|
-
"transform_undefined"
|
|
6982
|
+
"transform_undefined",
|
|
6983
|
+
"payload_mismatch"
|
|
6746
6984
|
]);
|
|
6747
6985
|
/**
|
|
6748
6986
|
* A single downstream run/session a dispatched fire produced. A fan-out fire can
|
|
@@ -6773,7 +7011,9 @@ const WorkspaceTriggerRunOutcomeSchema = discriminatedUnion("kind", [
|
|
|
6773
7011
|
}),
|
|
6774
7012
|
object({
|
|
6775
7013
|
kind: literal("skipped"),
|
|
6776
|
-
reason: WorkspaceTriggerSkipReasonSchema
|
|
7014
|
+
reason: WorkspaceTriggerSkipReasonSchema,
|
|
7015
|
+
/** One-line Zod issue summary when reason is payload_mismatch. */
|
|
7016
|
+
detail: string().nullable().optional()
|
|
6777
7017
|
}),
|
|
6778
7018
|
object({
|
|
6779
7019
|
kind: literal("failed"),
|
|
@@ -6846,6 +7086,30 @@ object({
|
|
|
6846
7086
|
input: TriggerOverviewInputSchema
|
|
6847
7087
|
});
|
|
6848
7088
|
object({ enabled: boolean() });
|
|
7089
|
+
object({
|
|
7090
|
+
input: unknown().optional(),
|
|
7091
|
+
workflow: string().min(1).optional(),
|
|
7092
|
+
agent: string().min(1).optional()
|
|
7093
|
+
});
|
|
7094
|
+
object({ runId: string().min(1) });
|
|
7095
|
+
object({
|
|
7096
|
+
type: TriggerTypeSchema,
|
|
7097
|
+
attachments: array(object({
|
|
7098
|
+
attachmentSlug: string().min(1),
|
|
7099
|
+
kind: TriggerTargetKindSchema,
|
|
7100
|
+
targetSlug: string().min(1),
|
|
7101
|
+
targetName: string().min(1),
|
|
7102
|
+
enabled: boolean(),
|
|
7103
|
+
/** Webhook attachment JSON Schema used to drive the invoke form. */
|
|
7104
|
+
requestSchema: record(string(), unknown()).optional()
|
|
7105
|
+
})),
|
|
7106
|
+
/** Cron source static payload — display only; never overridden on invoke. */
|
|
7107
|
+
staticPayload: unknown().optional()
|
|
7108
|
+
});
|
|
7109
|
+
object({
|
|
7110
|
+
manual: literal(true),
|
|
7111
|
+
attachments: array(string().min(1)).optional()
|
|
7112
|
+
});
|
|
6849
7113
|
const OrganizationMemberRoleSchema = _enum([
|
|
6850
7114
|
"owner",
|
|
6851
7115
|
"admin",
|
|
@@ -6858,16 +7122,24 @@ const OrganizationMemberStatusSchema = _enum([
|
|
|
6858
7122
|
"suspended"
|
|
6859
7123
|
]);
|
|
6860
7124
|
const InvitableOrganizationMemberRoleSchema = _enum(["admin", "builder"]);
|
|
6861
|
-
const isoDateTime$
|
|
6862
|
-
object({
|
|
7125
|
+
const isoDateTime$5 = string().datetime();
|
|
7126
|
+
const OrganizationMemberSchema = object({
|
|
6863
7127
|
id: string(),
|
|
6864
7128
|
name: string(),
|
|
6865
7129
|
email: string().email(),
|
|
6866
7130
|
role: OrganizationMemberRoleSchema,
|
|
6867
7131
|
status: OrganizationMemberStatusSchema,
|
|
6868
7132
|
avatarUrl: string().optional(),
|
|
6869
|
-
joinedAt: isoDateTime$
|
|
6870
|
-
lastActiveAt: isoDateTime$
|
|
7133
|
+
joinedAt: isoDateTime$5.optional(),
|
|
7134
|
+
lastActiveAt: isoDateTime$5.nullable().optional()
|
|
7135
|
+
});
|
|
7136
|
+
object({
|
|
7137
|
+
limit: number().int().min(1).max(200).optional(),
|
|
7138
|
+
cursor: string().min(1).optional()
|
|
7139
|
+
});
|
|
7140
|
+
object({
|
|
7141
|
+
items: array(OrganizationMemberSchema),
|
|
7142
|
+
nextCursor: string().nullable()
|
|
6871
7143
|
});
|
|
6872
7144
|
object({
|
|
6873
7145
|
emails: array(string().trim().email()).min(1),
|
|
@@ -6894,7 +7166,7 @@ object({
|
|
|
6894
7166
|
role: OrganizationMemberRoleSchema
|
|
6895
7167
|
});
|
|
6896
7168
|
object({ success: literal(true) });
|
|
6897
|
-
const isoDateTime$
|
|
7169
|
+
const isoDateTime$4 = string().datetime();
|
|
6898
7170
|
const ApiKeyCreatorSchema = object({
|
|
6899
7171
|
id: string(),
|
|
6900
7172
|
name: string(),
|
|
@@ -6907,12 +7179,37 @@ const ApiKeySummarySchema = object({
|
|
|
6907
7179
|
id: string(),
|
|
6908
7180
|
name: string(),
|
|
6909
7181
|
keyPreview: string(),
|
|
6910
|
-
createdAt: isoDateTime$
|
|
7182
|
+
createdAt: isoDateTime$4,
|
|
6911
7183
|
createdBy: ApiKeyCreatorSchema,
|
|
6912
7184
|
isCreatedByCurrentUser: boolean()
|
|
6913
7185
|
});
|
|
6914
7186
|
object({ name: string().trim().min(1).max(128) });
|
|
6915
7187
|
ApiKeySummarySchema.extend({ secret: string() });
|
|
7188
|
+
const isoDateTime$3 = string().datetime();
|
|
7189
|
+
const ManagedServiceKindSchema = _enum(["llm"]);
|
|
7190
|
+
_enum([
|
|
7191
|
+
"openai",
|
|
7192
|
+
"anthropic",
|
|
7193
|
+
"google",
|
|
7194
|
+
"groq",
|
|
7195
|
+
"xai"
|
|
7196
|
+
]);
|
|
7197
|
+
object({
|
|
7198
|
+
id: string(),
|
|
7199
|
+
kind: ManagedServiceKindSchema,
|
|
7200
|
+
provider: string(),
|
|
7201
|
+
keyPreview: string(),
|
|
7202
|
+
createdAt: isoDateTime$3,
|
|
7203
|
+
updatedAt: isoDateTime$3,
|
|
7204
|
+
createdBy: ApiKeyCreatorSchema,
|
|
7205
|
+
isCreatedByCurrentUser: boolean()
|
|
7206
|
+
});
|
|
7207
|
+
object({
|
|
7208
|
+
kind: ManagedServiceKindSchema.default("llm"),
|
|
7209
|
+
provider: string().trim().min(1),
|
|
7210
|
+
apiKey: string().trim().min(1)
|
|
7211
|
+
});
|
|
7212
|
+
object({ apiKey: string().trim().min(1) });
|
|
6916
7213
|
const ProjectUserRoleSchema = _enum(["admin", "builder"]);
|
|
6917
7214
|
const ProjectInvitePermissionSchema = _enum(["admin", "all"]);
|
|
6918
7215
|
const ProjectMemberStatusSchema = _enum(["active", "invited"]);
|
|
@@ -6962,14 +7259,6 @@ object({
|
|
|
6962
7259
|
uploadUrl: url(),
|
|
6963
7260
|
storageKey: string().min(1)
|
|
6964
7261
|
});
|
|
6965
|
-
function isValidIanaTimezone(value) {
|
|
6966
|
-
try {
|
|
6967
|
-
Intl.DateTimeFormat(void 0, { timeZone: value });
|
|
6968
|
-
return true;
|
|
6969
|
-
} catch {
|
|
6970
|
-
return false;
|
|
6971
|
-
}
|
|
6972
|
-
}
|
|
6973
7262
|
const UserInterfaceThemeSchema = _enum([
|
|
6974
7263
|
"system",
|
|
6975
7264
|
"light",
|
|
@@ -7490,17 +7779,48 @@ function parseOrgArtifactsFromEnv(env = process.env) {
|
|
|
7490
7779
|
});
|
|
7491
7780
|
}
|
|
7492
7781
|
//#endregion
|
|
7782
|
+
//#region src/org-worker-token.ts
|
|
7783
|
+
function sign(secret, organizationId) {
|
|
7784
|
+
return createHmac("sha256", secret).update(`org-worker:${organizationId}`).digest("base64url");
|
|
7785
|
+
}
|
|
7786
|
+
/**
|
|
7787
|
+
* Per-org worker token: `{organizationId}.{hmac}`. Self-describing so the
|
|
7788
|
+
* platform can tell which org a machine is calling as, and stateless — verified
|
|
7789
|
+
* by re-signing with the shared `PLATFORM_WORKER_TOKEN` secret.
|
|
7790
|
+
*/
|
|
7791
|
+
function mintOrgWorkerToken(secret, organizationId) {
|
|
7792
|
+
return `${organizationId}.${sign(secret, organizationId)}`;
|
|
7793
|
+
}
|
|
7794
|
+
function verifyOrgWorkerToken(secret, token) {
|
|
7795
|
+
if (!secret || !token) return;
|
|
7796
|
+
const separator = token.lastIndexOf(".");
|
|
7797
|
+
if (separator <= 0) return;
|
|
7798
|
+
const organizationId = token.slice(0, separator);
|
|
7799
|
+
const signature = Buffer.from(token.slice(separator + 1));
|
|
7800
|
+
const expected = Buffer.from(sign(secret, organizationId));
|
|
7801
|
+
if (signature.length !== expected.length || !timingSafeEqual(signature, expected)) return;
|
|
7802
|
+
return { organizationId };
|
|
7803
|
+
}
|
|
7804
|
+
//#endregion
|
|
7493
7805
|
//#region src/runtime-env.ts
|
|
7806
|
+
/** Non-secret runtime config forwarded into org workers. Never include platform secrets. */
|
|
7494
7807
|
const RUNTIME_ENV_KEYS = [
|
|
7495
|
-
"BETTER_AUTH_SECRET",
|
|
7496
7808
|
"PUBLIC_PLATFORM_URL",
|
|
7497
7809
|
"PUBLIC_PLATFORM_PROXY_URL",
|
|
7498
7810
|
"PUBLIC_WEB_URL",
|
|
7499
|
-
"POSTGRES_SSL",
|
|
7500
7811
|
"UPSTASH_REDIS_URL",
|
|
7501
7812
|
"REDIS_URL",
|
|
7502
7813
|
"KEYSTROKE_QUEUE_PREFIX"
|
|
7503
7814
|
];
|
|
7815
|
+
/** Env keys that must never be forwarded into untrusted org workers. */
|
|
7816
|
+
const FORBIDDEN_WORKER_ENV_KEYS = [
|
|
7817
|
+
"BETTER_AUTH_SECRET",
|
|
7818
|
+
"DATABASE_URL",
|
|
7819
|
+
"POSTGRES_PASSWORD",
|
|
7820
|
+
"PLATFORM_WORKER_TOKEN",
|
|
7821
|
+
"STRIPE_SECRET_KEY",
|
|
7822
|
+
"CREDENTIAL_ENCRYPTION_KEY"
|
|
7823
|
+
];
|
|
7504
7824
|
/** Provider and gateway env forwarded from the platform into project servers. */
|
|
7505
7825
|
const PROVIDER_ENV_KEYS = [
|
|
7506
7826
|
"ANTHROPIC_API_KEY",
|
|
@@ -7510,25 +7830,6 @@ const PROVIDER_ENV_KEYS = [
|
|
|
7510
7830
|
];
|
|
7511
7831
|
/** Shared dev token when `PLATFORM_WORKER_TOKEN` is unset (non-production only). */
|
|
7512
7832
|
const DEV_PLATFORM_WORKER_TOKEN = "dev-platform-worker-token";
|
|
7513
|
-
const PROJECT_DATABASE_ENV_KEYS = [
|
|
7514
|
-
"POSTGRES_HOST",
|
|
7515
|
-
"POSTGRES_PORT",
|
|
7516
|
-
"POSTGRES_DB",
|
|
7517
|
-
"POSTGRES_USER",
|
|
7518
|
-
"POSTGRES_PASSWORD",
|
|
7519
|
-
"DATABASE_SEARCH_PATH"
|
|
7520
|
-
];
|
|
7521
|
-
/** Per-project postgres env injected into every project server container/machine. */
|
|
7522
|
-
function projectDatabaseRuntimeEnv(database) {
|
|
7523
|
-
return {
|
|
7524
|
-
POSTGRES_HOST: rewriteLoopbackHost(database.host),
|
|
7525
|
-
POSTGRES_PORT: String(database.port),
|
|
7526
|
-
POSTGRES_DB: database.database,
|
|
7527
|
-
POSTGRES_USER: database.user,
|
|
7528
|
-
POSTGRES_PASSWORD: database.password,
|
|
7529
|
-
DATABASE_SEARCH_PATH: database.searchPath
|
|
7530
|
-
};
|
|
7531
|
-
}
|
|
7532
7833
|
/**
|
|
7533
7834
|
* Builds the launch spec for an org worker. Each deploy artifact is encoded in
|
|
7534
7835
|
* `KEYSTROKE_ORG_ARTIFACTS` — there is no base image, so at least one artifact is required.
|
|
@@ -7555,10 +7856,7 @@ function buildRuntimeEnv(source, artifacts, database, extraEnv) {
|
|
|
7555
7856
|
]);
|
|
7556
7857
|
for (const key of RUNTIME_ENV_KEYS) {
|
|
7557
7858
|
const value = source[key]?.trim();
|
|
7558
|
-
if (!value)
|
|
7559
|
-
if (key === "POSTGRES_SSL") throw new Error("POSTGRES_SSL is required");
|
|
7560
|
-
continue;
|
|
7561
|
-
}
|
|
7859
|
+
if (!value) continue;
|
|
7562
7860
|
entries.set(key, value);
|
|
7563
7861
|
}
|
|
7564
7862
|
if (!extraEnv) for (const key of PROVIDER_ENV_KEYS) {
|
|
@@ -7567,9 +7865,9 @@ function buildRuntimeEnv(source, artifacts, database, extraEnv) {
|
|
|
7567
7865
|
}
|
|
7568
7866
|
const worker = resolveWorkerRuntimeConfig(source);
|
|
7569
7867
|
entries.set("PLATFORM_URL", worker.platformUrl);
|
|
7570
|
-
entries.set("WORKER_INTERNAL_TOKEN", worker.workerToken);
|
|
7571
|
-
for (const [key, value] of Object.entries(projectDatabaseRuntimeEnv(database))) entries.set(key, value);
|
|
7868
|
+
entries.set("WORKER_INTERNAL_TOKEN", mintOrgWorkerToken(worker.workerToken, database.organizationId));
|
|
7572
7869
|
if (extraEnv) for (const [key, value] of Object.entries(extraEnv)) entries.set(key, value);
|
|
7870
|
+
for (const key of FORBIDDEN_WORKER_ENV_KEYS) entries.delete(key);
|
|
7573
7871
|
return Object.fromEntries(entries);
|
|
7574
7872
|
}
|
|
7575
7873
|
function resolvePlatformWorkerToken(source = process.env) {
|
|
@@ -7820,6 +8118,6 @@ async function fetchDeployStatus(baseUrl, options = {}) {
|
|
|
7820
8118
|
}
|
|
7821
8119
|
}
|
|
7822
8120
|
//#endregion
|
|
7823
|
-
export { DEV_PLATFORM_WORKER_TOKEN,
|
|
8121
|
+
export { DEV_PLATFORM_WORKER_TOKEN, FORBIDDEN_WORKER_ENV_KEYS, PROJECT_SERVER_DEPLOY_STATUS, PROJECT_SERVER_FRAMEWORK_NODE_MODULES, PROJECT_SERVER_FRAMEWORK_ROOT, PROJECT_SERVER_HEALTH, PROJECT_SERVER_IMAGE, PROJECT_SERVER_PORT, PROJECT_SERVER_ROOT, RUNTIME_PING_TIMEOUT_MS, WorkerRuntimeConfigError, buildRuntimeEnv, canPingProjectTarget, defaultHostingPlugin, dockerPlugin, encodeOrgArtifacts, fetchDeployStatus, formatDockerEnv, mintOrgWorkerToken, parseOrgArtifactsFromEnv, pingProject, pingProjectTarget, resolvePlatformWorkerToken, resolveProjectServerImage, resolveRuntimeLaunch, resolveWorkerPlatformUrl, resolveWorkerRuntimeConfig, rewriteLoopbackHost, rewriteLoopbackUrl, verifyOrgWorkerToken, waitForHealth };
|
|
7824
8122
|
|
|
7825
8123
|
//# sourceMappingURL=index.mjs.map
|