openpond-sdk 0.0.11 → 0.0.13

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 (43) hide show
  1. package/README.md +47 -0
  2. package/dist/actions-local.js +34 -14551
  3. package/dist/actions-local.js.map +4 -4
  4. package/dist/actions.js +12 -14530
  5. package/dist/actions.js.map +4 -4
  6. package/dist/index.js +582 -29
  7. package/dist/index.js.map +4 -4
  8. package/dist/model-projects.js +215 -0
  9. package/dist/model-projects.js.map +7 -0
  10. package/dist/profile-actions.js +1 -20
  11. package/dist/profile-actions.js.map +3 -3
  12. package/dist/project-actions.js +1 -20
  13. package/dist/project-actions.js.map +3 -3
  14. package/dist/refiner.js +568 -0
  15. package/dist/refiner.js.map +7 -0
  16. package/dist/training.js +470 -0
  17. package/dist/training.js.map +7 -0
  18. package/dist/types/packages/cloud/src/api/core.d.ts.map +1 -1
  19. package/dist/types/packages/cloud/src/hosted-chat.d.ts +20 -0
  20. package/dist/types/packages/cloud/src/hosted-chat.d.ts.map +1 -1
  21. package/dist/types/packages/cloud/src/sandbox/client-handles.d.ts +2 -1
  22. package/dist/types/packages/cloud/src/sandbox/client-handles.d.ts.map +1 -1
  23. package/dist/types/packages/cloud/src/sandbox/client.d.ts +3 -1
  24. package/dist/types/packages/cloud/src/sandbox/client.d.ts.map +1 -1
  25. package/dist/types/packages/cloud/src/sandbox/types/org-project-agent.d.ts +13 -0
  26. package/dist/types/packages/cloud/src/sandbox/types/org-project-agent.d.ts.map +1 -1
  27. package/dist/types/packages/sdk/src/index.d.ts +1 -0
  28. package/dist/types/packages/sdk/src/index.d.ts.map +1 -1
  29. package/dist/types/packages/sdk/src/model-projects.d.ts +804 -0
  30. package/dist/types/packages/sdk/src/model-projects.d.ts.map +1 -0
  31. package/dist/types/packages/sdk/src/refiner.d.ts +6 -0
  32. package/dist/types/packages/sdk/src/refiner.d.ts.map +1 -0
  33. package/dist/types/packages/sdk/src/training.d.ts +682 -0
  34. package/dist/types/packages/sdk/src/training.d.ts.map +1 -0
  35. package/dist/types/packages/sdk/src/types.d.ts +1 -1
  36. package/dist/types/packages/sdk/src/types.d.ts.map +1 -1
  37. package/dist/types/packages/sdk/src/workflows.d.ts +8 -0
  38. package/dist/types/packages/sdk/src/workflows.d.ts.map +1 -1
  39. package/dist/workflows.js +1 -20
  40. package/dist/workflows.js.map +3 -3
  41. package/package.json +17 -3
  42. package/dist/types/packages/cloud/src/api/vercel-protection.d.ts +0 -2
  43. package/dist/types/packages/cloud/src/api/vercel-protection.d.ts.map +0 -1
@@ -0,0 +1,215 @@
1
+ // src/model-projects.ts
2
+ import { z } from "zod";
3
+ var IdSchema = z.string().trim().min(1).max(500);
4
+ var HashSchema = z.string().regex(/^[a-f0-9]{64}$/);
5
+ var TimestampSchema = z.string().datetime({ offset: true });
6
+ var ModelProjectImmutableRefSchema = z.object({
7
+ id: IdSchema,
8
+ contentHash: HashSchema
9
+ }).strict();
10
+ var ModelProjectVersionedRefSchema = ModelProjectImmutableRefSchema.extend({
11
+ revision: z.number().int().positive()
12
+ }).strict();
13
+ var ModelProjectBaseModelSchema = z.object({
14
+ schemaVersion: z.literal("openpond.baseModelPreference.v1"),
15
+ modelId: IdSchema,
16
+ revision: z.string().trim().min(1).max(256).nullable(),
17
+ tokenizerRevision: z.string().trim().min(1).max(256).nullable(),
18
+ chatTemplateHash: z.string().trim().min(8).max(256).nullable(),
19
+ modelAssetId: IdSchema.nullable(),
20
+ source: z.enum(["managed", "local", "builtin"])
21
+ }).strict();
22
+ var ModelProjectTrainingMethodSchema = z.enum([
23
+ "sft",
24
+ "dpo",
25
+ "grpo",
26
+ "ppo",
27
+ "sdft",
28
+ "opd",
29
+ "opsd",
30
+ "sdpo"
31
+ ]);
32
+ var ModelProjectRecipeDocumentSchema = z.object({
33
+ schemaVersion: z.string().regex(/^openpond\.[A-Za-z0-9]+Recipe\.v\d+$/),
34
+ method: ModelProjectTrainingMethodSchema,
35
+ parameterization: z.enum(["lora", "full"])
36
+ }).catchall(z.unknown());
37
+ var ModelProjectTrainingSetupSchema = z.object({
38
+ tasksetRef: ModelProjectVersionedRefSchema.nullable().default(null),
39
+ tasksetRelease: ModelProjectImmutableRefSchema.nullable().default(null),
40
+ harnessRelease: ModelProjectImmutableRefSchema.nullable().default(null),
41
+ baseModel: ModelProjectBaseModelSchema.nullable().default(null),
42
+ method: ModelProjectTrainingMethodSchema.nullable().default(null),
43
+ destinationId: IdSchema.nullable().default(null),
44
+ managedRolloutPlacement: z.enum(["local", "remote"]).default("remote"),
45
+ runPreset: z.enum(["small", "standard", "custom", "small_experiment"]).nullable().default(null),
46
+ recipe: ModelProjectRecipeDocumentSchema.nullable().default(null),
47
+ preferredMaximumSpendUsd: z.number().nonnegative().nullable().default(null),
48
+ preferredRetentionDays: z.number().int().nonnegative().nullable().default(null)
49
+ }).strict();
50
+ var HostedModelProjectLinkSchema = z.object({
51
+ schemaVersion: z.literal("openpond.hostedModelProjectLink.v1"),
52
+ teamId: IdSchema,
53
+ projectId: IdSchema,
54
+ portableProjectId: IdSchema,
55
+ revision: z.number().int().positive(),
56
+ etag: HashSchema,
57
+ syncedSourceRevision: z.number().int().positive(),
58
+ syncedAt: TimestampSchema,
59
+ tasksets: z.array(
60
+ z.object({
61
+ localTasksetId: IdSchema,
62
+ releaseId: IdSchema,
63
+ releaseRevision: z.number().int().positive(),
64
+ releaseHash: HashSchema,
65
+ hostedTasksetId: IdSchema,
66
+ syncedAt: TimestampSchema
67
+ }).strict()
68
+ ).max(1e4).default([])
69
+ }).strict();
70
+ var ModelProjectTasksetSyncSchema = z.object({
71
+ localTasksetId: IdSchema,
72
+ releaseId: IdSchema,
73
+ releaseRevision: z.number().int().positive(),
74
+ releaseHash: HashSchema,
75
+ state: z.enum(["syncing", "synced", "sync_failed"]),
76
+ hostedTasksetId: IdSchema.nullable().default(null),
77
+ lastAttemptAt: TimestampSchema,
78
+ syncedAt: TimestampSchema.nullable().default(null),
79
+ lastError: z.string().trim().min(1).max(5e3).nullable().default(null)
80
+ }).strict();
81
+ var ModelProjectSchema = z.object({
82
+ schemaVersion: z.literal("openpond.modelProject.v2"),
83
+ id: IdSchema,
84
+ profileId: IdSchema,
85
+ revision: z.number().int().positive().default(1),
86
+ name: z.string().trim().min(1).max(200),
87
+ objective: z.string().trim().max(5e3).nullable(),
88
+ defaultBaseModel: ModelProjectBaseModelSchema.nullable(),
89
+ defaultDestinationId: IdSchema.nullable(),
90
+ trainingSetup: ModelProjectTrainingSetupSchema,
91
+ hosted: HostedModelProjectLinkSchema.nullable().default(null),
92
+ tasksetSyncs: z.array(ModelProjectTasksetSyncSchema).max(1e4).default([]),
93
+ createdAt: TimestampSchema,
94
+ updatedAt: TimestampSchema
95
+ }).strict();
96
+ var HostedModelProjectSyncSchema = z.object({
97
+ schemaVersion: z.literal("openpond.hostedModelProjectSync.v2"),
98
+ portableProjectId: IdSchema,
99
+ name: z.string().trim().min(1).max(200),
100
+ objective: z.string().trim().max(5e3).nullable(),
101
+ defaultBaseModel: ModelProjectBaseModelSchema.nullable(),
102
+ defaultDestinationId: IdSchema.nullable(),
103
+ trainingSetup: ModelProjectTrainingSetupSchema,
104
+ sourceRevision: z.number().int().positive(),
105
+ sourceUpdatedAt: TimestampSchema,
106
+ expectedEtag: HashSchema.nullable().default(null)
107
+ }).strict();
108
+ var HostedModelProjectSummarySchema = z.object({
109
+ id: IdSchema,
110
+ teamId: IdSchema,
111
+ portableProjectId: IdSchema,
112
+ name: z.string().trim().min(1).max(200),
113
+ objective: z.string().trim().max(5e3).nullable(),
114
+ defaultBaseModel: ModelProjectBaseModelSchema.nullable(),
115
+ defaultDestinationId: IdSchema.nullable(),
116
+ trainingSetup: ModelProjectTrainingSetupSchema,
117
+ sourceRevision: z.number().int().positive(),
118
+ sourceUpdatedAt: TimestampSchema,
119
+ revision: z.number().int().positive(),
120
+ etag: HashSchema,
121
+ createdAt: TimestampSchema,
122
+ updatedAt: TimestampSchema
123
+ }).strict();
124
+ var ModelProjectResourceSummarySchema = z.object({
125
+ kind: z.enum([
126
+ "taskset_release",
127
+ "harness_release",
128
+ "dataset_release",
129
+ "evidence_set",
130
+ "model_version",
131
+ "reward_model_version",
132
+ "evaluation_receipt"
133
+ ]),
134
+ ref: ModelProjectImmutableRefSchema,
135
+ role: z.string().trim().min(1).max(200).nullable().default(null),
136
+ updatedAt: TimestampSchema
137
+ }).strict();
138
+ var HostedModelProjectDetailSchema = z.object({
139
+ project: HostedModelProjectSummarySchema,
140
+ resources: z.array(ModelProjectResourceSummarySchema).max(1e4),
141
+ jobCount: z.number().int().nonnegative(),
142
+ latestJobIds: z.array(IdSchema).max(100)
143
+ }).strict();
144
+ function headersRecord(headers) {
145
+ const result = {};
146
+ new Headers(headers).forEach((value, key) => {
147
+ result[key] = value;
148
+ });
149
+ return result;
150
+ }
151
+ function createModelProjectsClient(input) {
152
+ const fetchImpl = input.fetch ?? fetch;
153
+ const baseUrl = input.baseUrl.replace(/\/$/, "");
154
+ async function request(pathname, init) {
155
+ const configuredHeaders = typeof input.headers === "function" ? await input.headers() : input.headers ?? {};
156
+ const response = await fetchImpl(`${baseUrl}${pathname}`, {
157
+ ...init,
158
+ headers: {
159
+ accept: "application/json",
160
+ ...init?.body ? { "content-type": "application/json" } : {},
161
+ ...headersRecord(configuredHeaders),
162
+ ...headersRecord(init?.headers)
163
+ }
164
+ });
165
+ const body = await response.json();
166
+ if (!response.ok) {
167
+ const message = body && typeof body === "object" && "error" in body ? String(body.error) : `Model Project request failed with HTTP ${response.status}.`;
168
+ throw new Error(message);
169
+ }
170
+ return body;
171
+ }
172
+ return {
173
+ async upsert(project) {
174
+ const parsed = HostedModelProjectSyncSchema.parse(project);
175
+ const body = await request(
176
+ `/v1/model-projects/${encodeURIComponent(parsed.portableProjectId)}`,
177
+ { method: "PUT", body: JSON.stringify(parsed) }
178
+ );
179
+ return HostedModelProjectSummarySchema.parse(
180
+ unwrapObject(body, "project")
181
+ );
182
+ },
183
+ async list() {
184
+ const body = await request("/v1/model-projects");
185
+ return z.array(HostedModelProjectSummarySchema).parse(unwrapObject(body, "projects"));
186
+ },
187
+ async get(projectId) {
188
+ const body = await request(
189
+ `/v1/model-projects/${encodeURIComponent(IdSchema.parse(projectId))}`
190
+ );
191
+ return HostedModelProjectDetailSchema.parse(body);
192
+ }
193
+ };
194
+ }
195
+ function unwrapObject(value, key) {
196
+ if (!value || typeof value !== "object" || Array.isArray(value)) return value;
197
+ return key in value ? value[key] : value;
198
+ }
199
+ export {
200
+ HostedModelProjectDetailSchema,
201
+ HostedModelProjectLinkSchema,
202
+ HostedModelProjectSummarySchema,
203
+ HostedModelProjectSyncSchema,
204
+ ModelProjectBaseModelSchema,
205
+ ModelProjectImmutableRefSchema,
206
+ ModelProjectRecipeDocumentSchema,
207
+ ModelProjectResourceSummarySchema,
208
+ ModelProjectSchema,
209
+ ModelProjectTasksetSyncSchema,
210
+ ModelProjectTrainingMethodSchema,
211
+ ModelProjectTrainingSetupSchema,
212
+ ModelProjectVersionedRefSchema,
213
+ createModelProjectsClient
214
+ };
215
+ //# sourceMappingURL=model-projects.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/model-projects.ts"],
4
+ "sourcesContent": ["import { z } from \"zod\";\n\nconst IdSchema = z.string().trim().min(1).max(500);\nconst HashSchema = z.string().regex(/^[a-f0-9]{64}$/);\nconst TimestampSchema = z.string().datetime({ offset: true });\n\nexport const ModelProjectImmutableRefSchema = z\n .object({\n id: IdSchema,\n contentHash: HashSchema,\n })\n .strict();\n\nexport const ModelProjectVersionedRefSchema =\n ModelProjectImmutableRefSchema.extend({\n revision: z.number().int().positive(),\n }).strict();\n\nexport const ModelProjectBaseModelSchema = z\n .object({\n schemaVersion: z.literal(\"openpond.baseModelPreference.v1\"),\n modelId: IdSchema,\n revision: z.string().trim().min(1).max(256).nullable(),\n tokenizerRevision: z.string().trim().min(1).max(256).nullable(),\n chatTemplateHash: z.string().trim().min(8).max(256).nullable(),\n modelAssetId: IdSchema.nullable(),\n source: z.enum([\"managed\", \"local\", \"builtin\"]),\n })\n .strict();\n\nexport const ModelProjectTrainingMethodSchema = z.enum([\n \"sft\",\n \"dpo\",\n \"grpo\",\n \"ppo\",\n \"sdft\",\n \"opd\",\n \"opsd\",\n \"sdpo\",\n]);\n\n/**\n * A versioned recipe document stored while a Project is still mutable.\n * The training endpoint validates the selected recipe version in full before\n * accepting an immutable Job; Project sync preserves newer recipe fields.\n */\nexport const ModelProjectRecipeDocumentSchema = z\n .object({\n schemaVersion: z.string().regex(/^openpond\\.[A-Za-z0-9]+Recipe\\.v\\d+$/),\n method: ModelProjectTrainingMethodSchema,\n parameterization: z.enum([\"lora\", \"full\"]),\n })\n .catchall(z.unknown());\n\nexport const ModelProjectTrainingSetupSchema = z\n .object({\n tasksetRef: ModelProjectVersionedRefSchema.nullable().default(null),\n tasksetRelease: ModelProjectImmutableRefSchema.nullable().default(null),\n harnessRelease: ModelProjectImmutableRefSchema.nullable().default(null),\n baseModel: ModelProjectBaseModelSchema.nullable().default(null),\n method: ModelProjectTrainingMethodSchema.nullable().default(null),\n destinationId: IdSchema.nullable().default(null),\n managedRolloutPlacement: z\n .enum([\"local\", \"remote\"])\n .default(\"remote\"),\n runPreset: z\n .enum([\"small\", \"standard\", \"custom\", \"small_experiment\"])\n .nullable()\n .default(null),\n recipe: ModelProjectRecipeDocumentSchema.nullable().default(null),\n preferredMaximumSpendUsd: z.number().nonnegative().nullable().default(null),\n preferredRetentionDays: z\n .number()\n .int()\n .nonnegative()\n .nullable()\n .default(null),\n })\n .strict();\n\nexport const HostedModelProjectLinkSchema = z\n .object({\n schemaVersion: z.literal(\"openpond.hostedModelProjectLink.v1\"),\n teamId: IdSchema,\n projectId: IdSchema,\n portableProjectId: IdSchema,\n revision: z.number().int().positive(),\n etag: HashSchema,\n syncedSourceRevision: z.number().int().positive(),\n syncedAt: TimestampSchema,\n tasksets: z\n .array(\n z\n .object({\n localTasksetId: IdSchema,\n releaseId: IdSchema,\n releaseRevision: z.number().int().positive(),\n releaseHash: HashSchema,\n hostedTasksetId: IdSchema,\n syncedAt: TimestampSchema,\n })\n .strict(),\n )\n .max(10_000)\n .default([]),\n })\n .strict();\n\nexport const ModelProjectTasksetSyncSchema = z\n .object({\n localTasksetId: IdSchema,\n releaseId: IdSchema,\n releaseRevision: z.number().int().positive(),\n releaseHash: HashSchema,\n state: z.enum([\"syncing\", \"synced\", \"sync_failed\"]),\n hostedTasksetId: IdSchema.nullable().default(null),\n lastAttemptAt: TimestampSchema,\n syncedAt: TimestampSchema.nullable().default(null),\n lastError: z.string().trim().min(1).max(5_000).nullable().default(null),\n })\n .strict();\n\nexport const ModelProjectSchema = z\n .object({\n schemaVersion: z.literal(\"openpond.modelProject.v2\"),\n id: IdSchema,\n profileId: IdSchema,\n revision: z.number().int().positive().default(1),\n name: z.string().trim().min(1).max(200),\n objective: z.string().trim().max(5_000).nullable(),\n defaultBaseModel: ModelProjectBaseModelSchema.nullable(),\n defaultDestinationId: IdSchema.nullable(),\n trainingSetup: ModelProjectTrainingSetupSchema,\n hosted: HostedModelProjectLinkSchema.nullable().default(null),\n tasksetSyncs: z\n .array(ModelProjectTasksetSyncSchema)\n .max(10_000)\n .default([]),\n createdAt: TimestampSchema,\n updatedAt: TimestampSchema,\n })\n .strict();\n\nexport const HostedModelProjectSyncSchema = z\n .object({\n schemaVersion: z.literal(\"openpond.hostedModelProjectSync.v2\"),\n portableProjectId: IdSchema,\n name: z.string().trim().min(1).max(200),\n objective: z.string().trim().max(5_000).nullable(),\n defaultBaseModel: ModelProjectBaseModelSchema.nullable(),\n defaultDestinationId: IdSchema.nullable(),\n trainingSetup: ModelProjectTrainingSetupSchema,\n sourceRevision: z.number().int().positive(),\n sourceUpdatedAt: TimestampSchema,\n expectedEtag: HashSchema.nullable().default(null),\n })\n .strict();\n\nexport const HostedModelProjectSummarySchema = z\n .object({\n id: IdSchema,\n teamId: IdSchema,\n portableProjectId: IdSchema,\n name: z.string().trim().min(1).max(200),\n objective: z.string().trim().max(5_000).nullable(),\n defaultBaseModel: ModelProjectBaseModelSchema.nullable(),\n defaultDestinationId: IdSchema.nullable(),\n trainingSetup: ModelProjectTrainingSetupSchema,\n sourceRevision: z.number().int().positive(),\n sourceUpdatedAt: TimestampSchema,\n revision: z.number().int().positive(),\n etag: HashSchema,\n createdAt: TimestampSchema,\n updatedAt: TimestampSchema,\n })\n .strict();\n\nexport const ModelProjectResourceSummarySchema = z\n .object({\n kind: z.enum([\n \"taskset_release\",\n \"harness_release\",\n \"dataset_release\",\n \"evidence_set\",\n \"model_version\",\n \"reward_model_version\",\n \"evaluation_receipt\",\n ]),\n ref: ModelProjectImmutableRefSchema,\n role: z.string().trim().min(1).max(200).nullable().default(null),\n updatedAt: TimestampSchema,\n })\n .strict();\n\nexport const HostedModelProjectDetailSchema = z\n .object({\n project: HostedModelProjectSummarySchema,\n resources: z.array(ModelProjectResourceSummarySchema).max(10_000),\n jobCount: z.number().int().nonnegative(),\n latestJobIds: z.array(IdSchema).max(100),\n })\n .strict();\n\nexport type ModelProject = z.infer<typeof ModelProjectSchema>;\nexport type ModelProjectTrainingSetup = z.infer<\n typeof ModelProjectTrainingSetupSchema\n>;\nexport type HostedModelProjectSync = z.infer<\n typeof HostedModelProjectSyncSchema\n>;\nexport type HostedModelProjectSummary = z.infer<\n typeof HostedModelProjectSummarySchema\n>;\nexport type HostedModelProjectDetail = z.infer<\n typeof HostedModelProjectDetailSchema\n>;\n\ntype ModelProjectsFetch = typeof fetch;\n\nfunction headersRecord(headers: HeadersInit | undefined): Record<string, string> {\n const result: Record<string, string> = {};\n new Headers(headers).forEach((value, key) => {\n result[key] = value;\n });\n return result;\n}\n\nexport function createModelProjectsClient(input: {\n baseUrl: string;\n fetch?: ModelProjectsFetch;\n headers?: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);\n}) {\n const fetchImpl = input.fetch ?? fetch;\n const baseUrl = input.baseUrl.replace(/\\/$/, \"\");\n\n async function request(pathname: string, init?: RequestInit): Promise<unknown> {\n const configuredHeaders =\n typeof input.headers === \"function\"\n ? await input.headers()\n : (input.headers ?? {});\n const response = await fetchImpl(`${baseUrl}${pathname}`, {\n ...init,\n headers: {\n accept: \"application/json\",\n ...(init?.body ? { \"content-type\": \"application/json\" } : {}),\n ...headersRecord(configuredHeaders),\n ...headersRecord(init?.headers),\n },\n });\n const body = (await response.json()) as unknown;\n if (!response.ok) {\n const message =\n body && typeof body === \"object\" && \"error\" in body\n ? String((body as { error: unknown }).error)\n : `Model Project request failed with HTTP ${response.status}.`;\n throw new Error(message);\n }\n return body;\n }\n\n return {\n async upsert(project: HostedModelProjectSync) {\n const parsed = HostedModelProjectSyncSchema.parse(project);\n const body = await request(\n `/v1/model-projects/${encodeURIComponent(parsed.portableProjectId)}`,\n { method: \"PUT\", body: JSON.stringify(parsed) },\n );\n return HostedModelProjectSummarySchema.parse(\n unwrapObject(body, \"project\"),\n );\n },\n async list() {\n const body = await request(\"/v1/model-projects\");\n return z\n .array(HostedModelProjectSummarySchema)\n .parse(unwrapObject(body, \"projects\"));\n },\n async get(projectId: string) {\n const body = await request(\n `/v1/model-projects/${encodeURIComponent(IdSchema.parse(projectId))}`,\n );\n return HostedModelProjectDetailSchema.parse(body);\n },\n };\n}\n\nfunction unwrapObject(value: unknown, key: string): unknown {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return value;\n return key in value ? (value as Record<string, unknown>)[key] : value;\n}\n"],
5
+ "mappings": ";AAAA,SAAS,SAAS;AAElB,IAAM,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG;AACjD,IAAM,aAAa,EAAE,OAAO,EAAE,MAAM,gBAAgB;AACpD,IAAM,kBAAkB,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,KAAK,CAAC;AAErD,IAAM,iCAAiC,EAC3C,OAAO;AAAA,EACN,IAAI;AAAA,EACJ,aAAa;AACf,CAAC,EACA,OAAO;AAEH,IAAM,iCACX,+BAA+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M,+BAA+B,EACrC,MAAM,aAAa,MAAM,UAAU,CAAC;AAAA,IACzC;AAAA,IACA,MAAM,IAAI,WAAmB;AAC3B,YAAM,OAAO,MAAM;AAAA,QACjB,sBAAsB,mBAAmB,SAAS,MAAM,SAAS,CAAC,CAAC;AAAA,MACrE;AACA,aAAO,+BAA+B,MAAM,IAAI;AAAA,IAClD;AAAA,EACF;AACF;AAEA,SAAS,aAAa,OAAgB,KAAsB;AAC1D,MAAI,CAAC,SAAS,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,EAAG,QAAO;AACxE,SAAO,OAAO,QAAS,MAAkC,GAAG,IAAI;AAClE;",
6
+ "names": []
7
+ }
@@ -1,22 +1,3 @@
1
- // ../cloud/dist/api/vercel-protection.js
2
- var VERCEL_PROTECTION_BYPASS_HEADER = "x-vercel-protection-bypass";
3
- function withVercelProtectionBypass(requestUrl, inputHeaders, env = typeof process === "undefined" ? {} : process.env) {
4
- const headers = new Headers(inputHeaders);
5
- const secret = env.VERCEL_AUTOMATION_BYPASS_SECRET?.trim();
6
- if (!secret || !isOpenPondStagingUrl(requestUrl))
7
- return headers;
8
- headers.set(VERCEL_PROTECTION_BYPASS_HEADER, secret);
9
- return headers;
10
- }
11
- function isOpenPondStagingUrl(requestUrl) {
12
- try {
13
- const hostname = new URL(requestUrl).hostname.toLowerCase();
14
- return hostname === "staging.openpond.ai" || hostname === "staging-api.openpond.ai" || hostname.endsWith(".staging-api.openpond.ai");
15
- } catch {
16
- return false;
17
- }
18
- }
19
-
20
1
  // ../cloud/dist/api/core.js
21
2
  var DEFAULT_API_TIMEOUT_MS = 3e4;
22
3
  var DEFAULT_API_RESPONSE_BYTES = 8 * 1024 * 1024;
@@ -59,7 +40,7 @@ var OpenPondApiError = class extends Error {
59
40
  async function apiFetch(baseUrl, token, requestPath, options = {}) {
60
41
  const { timeoutMs = DEFAULT_API_TIMEOUT_MS, maxResponseBytes = DEFAULT_API_RESPONSE_BYTES, ...init } = options;
61
42
  const requestUrl = `${baseUrl}${requestPath}`;
62
- const headers = withVercelProtectionBypass(requestUrl, init.headers);
43
+ const headers = new Headers(init.headers);
63
44
  headers.set("Content-Type", "application/json");
64
45
  const apiKey = process.env.OPENPOND_API_KEY;
65
46
  const trimmedToken = token?.trim() || "";
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../cloud/src/api/vercel-protection.ts", "../../cloud/src/api/core.ts", "../src/profile-actions.ts"],
4
- "sourcesContent": ["const VERCEL_PROTECTION_BYPASS_HEADER = \"x-vercel-protection-bypass\";\n\nexport function withVercelProtectionBypass(\n requestUrl: string,\n inputHeaders?: HeadersInit,\n env: Record<string, string | undefined> =\n typeof process === \"undefined\" ? {} : process.env,\n): Headers {\n const headers = new Headers(inputHeaders);\n const secret = env.VERCEL_AUTOMATION_BYPASS_SECRET?.trim();\n if (!secret || !isOpenPondStagingUrl(requestUrl)) return headers;\n headers.set(VERCEL_PROTECTION_BYPASS_HEADER, secret);\n return headers;\n}\n\nfunction isOpenPondStagingUrl(requestUrl: string): boolean {\n try {\n const hostname = new URL(requestUrl).hostname.toLowerCase();\n return (\n hostname === \"staging.openpond.ai\" ||\n hostname === \"staging-api.openpond.ai\" ||\n hostname.endsWith(\".staging-api.openpond.ai\")\n );\n } catch {\n return false;\n }\n}\n", "import { withVercelProtectionBypass } from \"./vercel-protection.js\";\n\nconst DEFAULT_API_TIMEOUT_MS = 30_000;\nconst DEFAULT_API_RESPONSE_BYTES = 8 * 1024 * 1024;\nexport const LONG_STREAM_API_OPTIONS = { timeoutMs: 15 * 60 * 1000, maxResponseBytes: 64 * 1024 * 1024 } as const;\n\nexport type ApiFetchOptions = RequestInit & {\n timeoutMs?: number;\n maxResponseBytes?: number;\n};\n\nexport class ApiTimeoutError extends Error {\n readonly code = \"OPENPOND_API_TIMEOUT\";\n\n constructor(readonly timeoutMs: number, readonly requestUrl: string) {\n super(`API request timed out after ${timeoutMs}ms: ${requestUrl}`);\n this.name = \"ApiTimeoutError\";\n }\n}\n\nexport class ApiResponseTooLargeError extends Error {\n readonly code = \"OPENPOND_API_RESPONSE_TOO_LARGE\";\n\n constructor(readonly maximumBytes: number, readonly requestUrl: string) {\n super(`API response exceeded ${maximumBytes} bytes: ${requestUrl}`);\n this.name = \"ApiResponseTooLargeError\";\n }\n}\n\nexport class OpenPondApiError extends Error {\n readonly code: string;\n\n constructor(\n readonly status: number,\n errorCode: string | null,\n label: string,\n readonly apiMessage: string | null = null,\n ) {\n const detail = apiMessage || errorCode;\n super(`${label} failed: ${status}${detail ? ` ${detail}` : \"\"}`);\n this.name = \"OpenPondApiError\";\n this.code = errorCode || \"OPENPOND_API_ERROR\";\n }\n}\n\nexport async function apiFetch(\n baseUrl: string,\n token: string | null,\n requestPath: string,\n options: ApiFetchOptions = {},\n): Promise<Response> {\n const { timeoutMs = DEFAULT_API_TIMEOUT_MS, maxResponseBytes = DEFAULT_API_RESPONSE_BYTES, ...init } = options;\n const requestUrl = `${baseUrl}${requestPath}`;\n const headers = withVercelProtectionBypass(requestUrl, init.headers);\n headers.set(\"Content-Type\", \"application/json\");\n const apiKey = process.env.OPENPOND_API_KEY;\n const trimmedToken = token?.trim() || \"\";\n const tokenIsApiKey = trimmedToken.startsWith(\"opk_\");\n const effectiveApiKey = apiKey || (tokenIsApiKey ? trimmedToken : null);\n if (effectiveApiKey && !headers.has(\"openpond-api-key\")) headers.set(\"openpond-api-key\", effectiveApiKey);\n if (token) {\n headers.set(\"Authorization\", tokenIsApiKey ? `ApiKey ${trimmedToken}` : `Bearer ${token}`);\n } else if (apiKey && !headers.has(\"Authorization\")) {\n headers.set(\"Authorization\", `ApiKey ${apiKey}`);\n }\n\n const timeoutController = new AbortController();\n const timeoutError = new ApiTimeoutError(timeoutMs, requestUrl);\n const timer = timeoutMs > 0\n ? setTimeout(() => timeoutController.abort(timeoutError), timeoutMs)\n : null;\n timer?.unref?.();\n const signal = composedSignal(init.signal, timeoutController.signal, timeoutMs);\n const cleanup = () => {\n if (timer) clearTimeout(timer);\n };\n\n try {\n const response = await fetch(requestUrl, { ...init, headers, signal });\n return boundedResponse(response, {\n cleanup,\n maximumBytes: maxResponseBytes,\n requestUrl,\n timeoutController,\n timeoutError,\n });\n } catch (error) {\n cleanup();\n if (timeoutController.signal.aborted) throw timeoutError;\n throw error;\n }\n}\n\nexport async function readApiJson<T>(response: Response, label: string): Promise<T> {\n let payload: T & { error?: unknown; message?: unknown };\n try {\n const text = await response.text();\n payload = (text ? JSON.parse(text) : {}) as T & { error?: unknown; message?: unknown };\n } catch (error) {\n if (error instanceof ApiTimeoutError || error instanceof ApiResponseTooLargeError) throw error;\n payload = {} as T & { error?: unknown; message?: unknown };\n }\n if (!response.ok) {\n const errorCode = typeof payload.error === \"string\" ? payload.error : null;\n const apiMessage =\n typeof payload.message === \"string\" ? payload.message : null;\n throw new OpenPondApiError(response.status, errorCode, label, apiMessage);\n }\n return payload as T;\n}\n\nfunction boundedResponse(\n response: Response,\n input: {\n cleanup: () => void;\n maximumBytes: number;\n requestUrl: string;\n timeoutController: AbortController;\n timeoutError: ApiTimeoutError;\n },\n): Response {\n if (!response.body) {\n input.cleanup();\n return response;\n }\n const contentLength = Number(response.headers.get(\"content-length\"));\n if (input.maximumBytes > 0 && Number.isFinite(contentLength) && contentLength > input.maximumBytes) {\n input.cleanup();\n void response.body.cancel();\n throw new ApiResponseTooLargeError(input.maximumBytes, input.requestUrl);\n }\n\n const reader = response.body.getReader();\n let receivedBytes = 0;\n const body = new ReadableStream<Uint8Array>({\n async pull(controller) {\n try {\n const result = await reader.read();\n if (result.done) {\n input.cleanup();\n controller.close();\n return;\n }\n receivedBytes += result.value.byteLength;\n if (input.maximumBytes > 0 && receivedBytes > input.maximumBytes) {\n input.cleanup();\n await reader.cancel();\n controller.error(new ApiResponseTooLargeError(input.maximumBytes, input.requestUrl));\n return;\n }\n controller.enqueue(result.value);\n } catch (error) {\n input.cleanup();\n controller.error(input.timeoutController.signal.aborted ? input.timeoutError : error);\n }\n },\n async cancel(reason) {\n input.cleanup();\n await reader.cancel(reason);\n },\n });\n return new Response(body, {\n headers: response.headers,\n status: response.status,\n statusText: response.statusText,\n });\n}\n\nfunction composedSignal(\n callerSignal: AbortSignal | null | undefined,\n timeoutSignal: AbortSignal,\n timeoutMs: number,\n): AbortSignal | undefined {\n if (timeoutMs <= 0) return callerSignal ?? undefined;\n return callerSignal ? AbortSignal.any([callerSignal, timeoutSignal]) : timeoutSignal;\n}\n", "import { apiFetch, readApiJson } from \"@openpond/cloud/api/core\";\n\nexport type OpenPondProfileActionSetupRequirement = {\n kind: string;\n key: string;\n label: string | null;\n required: boolean;\n status: string;\n warning: string | null;\n};\n\nexport type OpenPondProfileActionCatalogEntry = {\n /** Stable action key. This is the only action selector accepted by follow-up invocation APIs. */\n key: string;\n agentId: string;\n agentName: string;\n agentSlug: string;\n actionId: string;\n actionLabel: string;\n description: string;\n inputSchema: Record<string, unknown>;\n invokesModel: boolean;\n approvalPolicy: {\n required: boolean;\n risk: \"read\" | \"write\" | \"destructive\";\n };\n setupStatus: \"ready\" | \"setup_required\";\n setupRequirements: OpenPondProfileActionSetupRequirement[];\n requiredCapabilities: string[];\n};\n\nexport type OpenPondProfileActionCatalog = {\n profileId: string;\n profileName: string;\n /** Opaque source/action contract version used to reject catalog drift at invocation time. */\n catalogVersion: string;\n sourceCommitSha: string | null;\n actions: OpenPondProfileActionCatalogEntry[];\n};\n\nexport type OpenPondProfileActionInvocation<TOutput = Record<string, unknown>> = {\n run: {\n id: string;\n status: string;\n conversationId: string | null;\n resultJson: TOutput | null;\n };\n};\n\n/** A short-lived capability granted by the calling product for one Profile Action run. */\nexport type OpenPondExternalCapabilityLease = {\n provider: string;\n capabilities: string[];\n proxyUrl: string;\n bearerToken: string;\n expiresAt?: string;\n resourcePolicy?: Record<string, unknown>;\n};\n\ntype ProfileActionsClientInput = {\n apiKey: string;\n apiBaseUrl: string;\n};\n\nexport class OpenPondProfileActionsClient {\n readonly #apiKey: string;\n readonly #apiBaseUrl: string;\n\n constructor(input: ProfileActionsClientInput) {\n this.#apiKey = input.apiKey;\n this.#apiBaseUrl = input.apiBaseUrl.replace(/\\/+$/, \"\");\n }\n\n async catalog(input: {\n teamId: string;\n profileId?: string;\n profileName?: string;\n }): Promise<OpenPondProfileActionCatalog> {\n const teamId = requiredValue(input.teamId, \"teamId\");\n const search = new URLSearchParams({ teamId });\n if (input.profileId?.trim()) search.set(\"profileId\", input.profileId.trim());\n if (input.profileName?.trim()) {\n search.set(\"profileName\", input.profileName.trim());\n }\n const response = await apiFetch(\n this.#apiBaseUrl,\n this.#apiKey,\n `/v1/profile/actions?${search.toString()}`,\n );\n return (\n await readApiJson<{ catalog: OpenPondProfileActionCatalog }>(\n response,\n \"Get Profile Action catalog\",\n )\n ).catalog;\n }\n\n async run<TOutput = Record<string, unknown>>(input: {\n teamId: string;\n actionKey: string;\n profileId?: string;\n profileName?: string;\n value?: Record<string, unknown>;\n conversationId?: string | null;\n createConversation?: boolean;\n conversationTitle?: string | null;\n idempotencyKey: string;\n catalogVersion: string;\n externalCapabilityLeases?: OpenPondExternalCapabilityLease[];\n }): Promise<OpenPondProfileActionInvocation<TOutput>> {\n const teamId = requiredValue(input.teamId, \"teamId\");\n const actionKey = requiredValue(input.actionKey, \"actionKey\");\n const idempotencyKey = requiredValue(input.idempotencyKey, \"idempotencyKey\");\n const catalogVersion = requiredValue(input.catalogVersion, \"catalogVersion\");\n const response = await apiFetch(\n this.#apiBaseUrl,\n this.#apiKey,\n `/v1/profile/actions/run?${new URLSearchParams({ teamId }).toString()}`,\n {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n ...(input.profileId?.trim() ? { profileId: input.profileId.trim() } : {}),\n ...(input.profileName?.trim() ? { profileName: input.profileName.trim() } : {}),\n actionKey,\n value: input.value ?? {},\n conversationId: input.conversationId ?? null,\n createConversation: input.createConversation,\n conversationTitle: input.conversationTitle ?? null,\n idempotencyKey,\n catalogVersion,\n externalCapabilityLeases: input.externalCapabilityLeases,\n }),\n },\n );\n return readApiJson<OpenPondProfileActionInvocation<TOutput>>(\n response,\n \"Run Profile Action\",\n );\n }\n}\n\nfunction requiredValue(value: string, name: string): string {\n const normalized = value.trim();\n if (!normalized) throw new Error(`${name} is required`);\n return normalized;\n}\n"],
5
- "mappings": ";AAAA,IAAM,kCAAkC;AAElC,SAAU,2BACd,YACA,cACA,MACE,OAAO,YAAY,cAAc,CAAA,IAAK,QAAQ,KAAG;AAEnD,QAAM,UAAU,IAAI,QAAQ,YAAY;AACxC,QAAM,SAAS,IAAI,iCAAiC,KAAI;AACxD,MAAI,CAAC,UAAU,CAAC,qBAAqB,UAAU;AAAG,WAAO;AACzD,UAAQ,IAAI,iCAAiC,MAAM;AACnD,SAAO;AACT;AAEA,SAAS,qBAAqB,YAAkB;AAC9C,MAAI;AACF,UAAM,WAAW,IAAI,IAAI,UAAU,EAAE,SAAS,YAAW;AACzD,WACE,aAAa,yBACb,aAAa,6BACb,SAAS,SAAS,0BAA0B;EAEhD,QAAQ;AACN,WAAO;EACT;AACF;;;ACxBA,IAAM,yBAAyB;AAC/B,IAAM,6BAA6B,IAAI,OAAO;AACvC,IAAM,0BAA0B,EAAE,WAAW,KAAK,KAAK,KAAM,kBAAkB,KAAK,OAAO,KAAI;AAOhG,IAAO,kBAAP,cAA+B,MAAK;EAGnB;EAA4B;EAFxC,OAAO;EAEhB,YAAqB,WAA4B,YAAkB;AACjE,UAAM,+BAA+B,SAAS,OAAO,UAAU,EAAE;AAD9C,SAAA,YAAA;AAA4B,SAAA,aAAA;AAE/C,SAAK,OAAO;EACd;;AAGI,IAAO,2BAAP,cAAwC,MAAK;EAG5B;EAA+B;EAF3C,OAAO;EAEhB,YAAqB,cAA+B,YAAkB;AACpE,UAAM,yBAAyB,YAAY,WAAW,UAAU,EAAE;AAD/C,SAAA,eAAA;AAA+B,SAAA,aAAA;AAElD,SAAK,OAAO;EACd;;AAGI,IAAO,mBAAP,cAAgC,MAAK;EAI9B;E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AULT_API_RESPONSE_BYTES = 8 * 1024 * 1024;\nexport const LONG_STREAM_API_OPTIONS = { timeoutMs: 15 * 60 * 1000, maxResponseBytes: 64 * 1024 * 1024 } as const;\n\nexport type ApiFetchOptions = RequestInit & {\n timeoutMs?: number;\n maxResponseBytes?: number;\n};\n\nexport class ApiTimeoutError extends Error {\n readonly code = \"OPENPOND_API_TIMEOUT\";\n\n constructor(readonly timeoutMs: number, readonly requestUrl: string) {\n super(`API request timed out after ${timeoutMs}ms: ${requestUrl}`);\n this.name = \"ApiTimeoutError\";\n }\n}\n\nexport class ApiResponseTooLargeError extends Error {\n readonly code = \"OPENPOND_API_RESPONSE_TOO_LARGE\";\n\n constructor(readonly maximumBytes: number, readonly requestUrl: string) {\n super(`API response exceeded ${maximumBytes} bytes: ${requestUrl}`);\n this.name = \"ApiResponseTooLargeError\";\n }\n}\n\nexport class OpenPondApiError extends Error {\n readonly code: string;\n\n constructor(\n readonly status: number,\n errorCode: string | null,\n label: string,\n readonly apiMessage: string | null = null,\n ) {\n const detail = apiMessage || errorCode;\n super(`${label} failed: ${status}${detail ? ` ${detail}` : \"\"}`);\n this.name = \"OpenPondApiError\";\n this.code = errorCode || \"OPENPOND_API_ERROR\";\n }\n}\n\nexport async function apiFetch(\n baseUrl: string,\n token: string | null,\n requestPath: string,\n options: ApiFetchOptions = {},\n): Promise<Response> {\n const { timeoutMs = DEFAULT_API_TIMEOUT_MS, maxResponseBytes = DEFAULT_API_RESPONSE_BYTES, ...init } = options;\n const requestUrl = `${baseUrl}${requestPath}`;\n const headers = new Headers(init.headers);\n headers.set(\"Content-Type\", \"application/json\");\n const apiKey = process.env.OPENPOND_API_KEY;\n const trimmedToken = token?.trim() || \"\";\n const tokenIsApiKey = trimmedToken.startsWith(\"opk_\");\n const effectiveApiKey = apiKey || (tokenIsApiKey ? trimmedToken : null);\n if (effectiveApiKey && !headers.has(\"openpond-api-key\")) headers.set(\"openpond-api-key\", effectiveApiKey);\n if (token) {\n headers.set(\"Authorization\", tokenIsApiKey ? `ApiKey ${trimmedToken}` : `Bearer ${token}`);\n } else if (apiKey && !headers.has(\"Authorization\")) {\n headers.set(\"Authorization\", `ApiKey ${apiKey}`);\n }\n\n const timeoutController = new AbortController();\n const timeoutError = new ApiTimeoutError(timeoutMs, requestUrl);\n const timer = timeoutMs > 0\n ? setTimeout(() => timeoutController.abort(timeoutError), timeoutMs)\n : null;\n timer?.unref?.();\n const signal = composedSignal(init.signal, timeoutController.signal, timeoutMs);\n const cleanup = () => {\n if (timer) clearTimeout(timer);\n };\n\n try {\n const response = await fetch(requestUrl, { ...init, headers, signal });\n return boundedResponse(response, {\n cleanup,\n maximumBytes: maxResponseBytes,\n requestUrl,\n timeoutController,\n timeoutError,\n });\n } catch (error) {\n cleanup();\n if (timeoutController.signal.aborted) throw timeoutError;\n throw error;\n }\n}\n\nexport async function readApiJson<T>(response: Response, label: string): Promise<T> {\n let payload: T & { error?: unknown; message?: unknown };\n try {\n const text = await response.text();\n payload = (text ? JSON.parse(text) : {}) as T & { error?: unknown; message?: unknown };\n } catch (error) {\n if (error instanceof ApiTimeoutError || error instanceof ApiResponseTooLargeError) throw error;\n payload = {} as T & { error?: unknown; message?: unknown };\n }\n if (!response.ok) {\n const errorCode = typeof payload.error === \"string\" ? payload.error : null;\n const apiMessage =\n typeof payload.message === \"string\" ? payload.message : null;\n throw new OpenPondApiError(response.status, errorCode, label, apiMessage);\n }\n return payload as T;\n}\n\nfunction boundedResponse(\n response: Response,\n input: {\n cleanup: () => void;\n maximumBytes: number;\n requestUrl: string;\n timeoutController: AbortController;\n timeoutError: ApiTimeoutError;\n },\n): Response {\n if (!response.body) {\n input.cleanup();\n return response;\n }\n const contentLength = Number(response.headers.get(\"content-length\"));\n if (input.maximumBytes > 0 && Number.isFinite(contentLength) && contentLength > input.maximumBytes) {\n input.cleanup();\n void response.body.cancel();\n throw new ApiResponseTooLargeError(input.maximumBytes, input.requestUrl);\n }\n\n const reader = response.body.getReader();\n let receivedBytes = 0;\n const body = new ReadableStream<Uint8Array>({\n async pull(controller) {\n try {\n const result = await reader.read();\n if (result.done) {\n input.cleanup();\n controller.close();\n return;\n }\n receivedBytes += result.value.byteLength;\n if (input.maximumBytes > 0 && receivedBytes > input.maximumBytes) {\n input.cleanup();\n await reader.cancel();\n controller.error(new ApiResponseTooLargeError(input.maximumBytes, input.requestUrl));\n return;\n }\n controller.enqueue(result.value);\n } catch (error) {\n input.cleanup();\n controller.error(input.timeoutController.signal.aborted ? input.timeoutError : error);\n }\n },\n async cancel(reason) {\n input.cleanup();\n await reader.cancel(reason);\n },\n });\n return new Response(body, {\n headers: response.headers,\n status: response.status,\n statusText: response.statusText,\n });\n}\n\nfunction composedSignal(\n callerSignal: AbortSignal | null | undefined,\n timeoutSignal: AbortSignal,\n timeoutMs: number,\n): AbortSignal | undefined {\n if (timeoutMs <= 0) return callerSignal ?? undefined;\n return callerSignal ? AbortSignal.any([callerSignal, timeoutSignal]) : timeoutSignal;\n}\n", "import { apiFetch, readApiJson } from \"@openpond/cloud/api/core\";\n\nexport type OpenPondProfileActionSetupRequirement = {\n kind: string;\n key: string;\n label: string | null;\n required: boolean;\n status: string;\n warning: string | null;\n};\n\nexport type OpenPondProfileActionCatalogEntry = {\n /** Stable action key. This is the only action selector accepted by follow-up invocation APIs. */\n key: string;\n agentId: string;\n agentName: string;\n agentSlug: string;\n actionId: string;\n actionLabel: string;\n description: string;\n inputSchema: Record<string, unknown>;\n invokesModel: boolean;\n approvalPolicy: {\n required: boolean;\n risk: \"read\" | \"write\" | \"destructive\";\n };\n setupStatus: \"ready\" | \"setup_required\";\n setupRequirements: OpenPondProfileActionSetupRequirement[];\n requiredCapabilities: string[];\n};\n\nexport type OpenPondProfileActionCatalog = {\n profileId: string;\n profileName: string;\n /** Opaque source/action contract version used to reject catalog drift at invocation time. */\n catalogVersion: string;\n sourceCommitSha: string | null;\n actions: OpenPondProfileActionCatalogEntry[];\n};\n\nexport type OpenPondProfileActionInvocation<TOutput = Record<string, unknown>> = {\n run: {\n id: string;\n status: string;\n conversationId: string | null;\n resultJson: TOutput | null;\n };\n};\n\n/** A short-lived capability granted by the calling product for one Profile Action run. */\nexport type OpenPondExternalCapabilityLease = {\n provider: string;\n capabilities: string[];\n proxyUrl: string;\n bearerToken: string;\n expiresAt?: string;\n resourcePolicy?: Record<string, unknown>;\n};\n\ntype ProfileActionsClientInput = {\n apiKey: string;\n apiBaseUrl: string;\n};\n\nexport class OpenPondProfileActionsClient {\n readonly #apiKey: string;\n readonly #apiBaseUrl: string;\n\n constructor(input: ProfileActionsClientInput) {\n this.#apiKey = input.apiKey;\n this.#apiBaseUrl = input.apiBaseUrl.replace(/\\/+$/, \"\");\n }\n\n async catalog(input: {\n teamId: string;\n profileId?: string;\n profileName?: string;\n }): Promise<OpenPondProfileActionCatalog> {\n const teamId = requiredValue(input.teamId, \"teamId\");\n const search = new URLSearchParams({ teamId });\n if (input.profileId?.trim()) search.set(\"profileId\", input.profileId.trim());\n if (input.profileName?.trim()) {\n search.set(\"profileName\", input.profileName.trim());\n }\n const response = await apiFetch(\n this.#apiBaseUrl,\n this.#apiKey,\n `/v1/profile/actions?${search.toString()}`,\n );\n return (\n await readApiJson<{ catalog: OpenPondProfileActionCatalog }>(\n response,\n \"Get Profile Action catalog\",\n )\n ).catalog;\n }\n\n async run<TOutput = Record<string, unknown>>(input: {\n teamId: string;\n actionKey: string;\n profileId?: string;\n profileName?: string;\n value?: Record<string, unknown>;\n conversationId?: string | null;\n createConversation?: boolean;\n conversationTitle?: string | null;\n idempotencyKey: string;\n catalogVersion: string;\n externalCapabilityLeases?: OpenPondExternalCapabilityLease[];\n }): Promise<OpenPondProfileActionInvocation<TOutput>> {\n const teamId = requiredValue(input.teamId, \"teamId\");\n const actionKey = requiredValue(input.actionKey, \"actionKey\");\n const idempotencyKey = requiredValue(input.idempotencyKey, \"idempotencyKey\");\n const catalogVersion = requiredValue(input.catalogVersion, \"catalogVersion\");\n const response = await apiFetch(\n this.#apiBaseUrl,\n this.#apiKey,\n `/v1/profile/actions/run?${new URLSearchParams({ teamId }).toString()}`,\n {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n ...(input.profileId?.trim() ? { profileId: input.profileId.trim() } : {}),\n ...(input.profileName?.trim() ? { profileName: input.profileName.trim() } : {}),\n actionKey,\n value: input.value ?? {},\n conversationId: input.conversationId ?? null,\n createConversation: input.createConversation,\n conversationTitle: input.conversationTitle ?? null,\n idempotencyKey,\n catalogVersion,\n externalCapabilityLeases: input.externalCapabilityLeases,\n }),\n },\n );\n return readApiJson<OpenPondProfileActionInvocation<TOutput>>(\n response,\n \"Run Profile Action\",\n );\n }\n}\n\nfunction requiredValue(value: string, name: string): string {\n const normalized = value.trim();\n if (!normalized) throw new Error(`${name} is required`);\n return normalized;\n}\n"],
5
+ "mappings": ";AAAA,IAAM,yBAAyB;AAC/B,IAAM,6BAA6B,IAAI,OAAO;AACvC,IAAM,0BAA0B,EAAE,WAAW,KAAK,KAAK,KAAM,kBAAkB,KAAK,OAAO,KAAI;AAOhG,IAAO,kBAAP,cAA+B,MAAK;EAGnB;EAA4B;EAFxC,OAAO;EAEhB,YAAqB,WAA4B,YAAkB;AACjE,UAAM,+BAA+B,SAAS,OAAO,UAAU,EAAE;AAD9C,SAAA,YAAA;AAA4B,SAAA,aAAA;AAE/C,SAAK,OAAO;EACd;;AAGI,IAAO,2BAAP,cAAwC,MAAK;EAG5B;EAA+B;EAF3C,OAAO;EAEhB,YAAqB,cAA+B,YAAkB;AACpE,UAAM,yBAAyB,YAAY,WAAW,UAAU,EAAE;AAD/C,SAAA,eAAA;AAA+B,SAAA,aAAA;AAElD,SAAK,OAAO;EACd;;AAGI,IAAO,mBAAP,cAAgC,MAAK;EAI9B;EAGA;EANF;EAET,YACW,QACT,WACA,OACS,aAA4B,MAAI;AAEzC,UAAM,SAAS,cAAc;AAC7B,UAAM,GAAG,KAAK,YAAY,MAAM,GAAG,SAAS,IAAI,MAAM,KAAK,EAAE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M,YAAY,cAAc,MAAM,WAAW,WAAW;AAC5D,UAAM,iBAAiB,cAAc,MAAM,gBAAgB,gBAAgB;AAC3E,UAAM,iBAAiB,cAAc,MAAM,gBAAgB,gBAAgB;AAC3E,UAAM,WAAW,MAAM;AAAA,MACrB,KAAK;AAAA,MACL,KAAK;AAAA,MACL,2BAA2B,IAAI,gBAAgB,EAAE,OAAO,CAAC,EAAE,SAAS,CAAC;AAAA,MACrE;AAAA,QACE,QAAQ;AAAA,QACR,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,QAC9C,MAAM,KAAK,UAAU;AAAA,UACnB,GAAI,MAAM,WAAW,KAAK,IAAI,EAAE,WAAW,MAAM,UAAU,KAAK,EAAE,IAAI,CAAC;AAAA,UACvE,GAAI,MAAM,aAAa,KAAK,IAAI,EAAE,aAAa,MAAM,YAAY,KAAK,EAAE,IAAI,CAAC;AAAA,UAC7E;AAAA,UACA,OAAO,MAAM,SAAS,CAAC;AAAA,UACvB,gBAAgB,MAAM,kBAAkB;AAAA,UACxC,oBAAoB,MAAM;AAAA,UAC1B,mBAAmB,MAAM,qBAAqB;AAAA,UAC9C;AAAA,UACA;AAAA,UACA,0BAA0B,MAAM;AAAA,QAClC,CAAC;AAAA,MACH;AAAA,IACF;AACA,WAAO;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,cAAc,OAAe,MAAsB;AAC1D,QAAM,aAAa,MAAM,KAAK;AAC9B,MAAI,CAAC,WAAY,OAAM,IAAI,MAAM,GAAG,IAAI,cAAc;AACtD,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -1,25 +1,6 @@
1
1
  // src/project-actions.ts
2
2
  import { promises as fs } from "node:fs";
3
3
 
4
- // ../cloud/dist/api/vercel-protection.js
5
- var VERCEL_PROTECTION_BYPASS_HEADER = "x-vercel-protection-bypass";
6
- function withVercelProtectionBypass(requestUrl, inputHeaders, env = typeof process === "undefined" ? {} : process.env) {
7
- const headers = new Headers(inputHeaders);
8
- const secret = env.VERCEL_AUTOMATION_BYPASS_SECRET?.trim();
9
- if (!secret || !isOpenPondStagingUrl(requestUrl))
10
- return headers;
11
- headers.set(VERCEL_PROTECTION_BYPASS_HEADER, secret);
12
- return headers;
13
- }
14
- function isOpenPondStagingUrl(requestUrl) {
15
- try {
16
- const hostname = new URL(requestUrl).hostname.toLowerCase();
17
- return hostname === "staging.openpond.ai" || hostname === "staging-api.openpond.ai" || hostname.endsWith(".staging-api.openpond.ai");
18
- } catch {
19
- return false;
20
- }
21
- }
22
-
23
4
  // ../cloud/dist/api/core.js
24
5
  var DEFAULT_API_TIMEOUT_MS = 3e4;
25
6
  var DEFAULT_API_RESPONSE_BYTES = 8 * 1024 * 1024;
@@ -62,7 +43,7 @@ var OpenPondApiError = class extends Error {
62
43
  async function apiFetch(baseUrl, token, requestPath, options = {}) {
63
44
  const { timeoutMs = DEFAULT_API_TIMEOUT_MS, maxResponseBytes = DEFAULT_API_RESPONSE_BYTES, ...init } = options;
64
45
  const requestUrl = `${baseUrl}${requestPath}`;
65
- const headers = withVercelProtectionBypass(requestUrl, init.headers);
46
+ const headers = new Headers(init.headers);
66
47
  headers.set("Content-Type", "application/json");
67
48
  const apiKey = process.env.OPENPOND_API_KEY;
68
49
  const trimmedToken = token?.trim() || "";
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/project-actions.ts", "../../cloud/src/api/vercel-protection.ts", "../../cloud/src/api/core.ts"],
4
- "sourcesContent": ["import { promises as fs } from \"node:fs\";\n\nimport { apiFetch, readApiJson } from \"@openpond/cloud/api/core\";\n\nimport type { ProjectActionBuildResult, ProjectActionRegistry } from \"../../actions/src/types.js\";\n\nexport type ProjectActionRelease = {\n id: string;\n projectId: string;\n sourceCommitSha: string;\n bundleHash: string;\n registryHash: string;\n status: string;\n createdAt: string;\n};\n\nexport type HostedProjectActionCatalog = {\n releaseId: string;\n sourceCommitSha: string;\n bundleHash: string;\n registryHash: string;\n registry: ProjectActionRegistry;\n};\n\nexport type ProjectActionInvocation<TOutput = Record<string, unknown>> = {\n id: string;\n releaseId: string;\n projectId: string;\n actionId: string;\n status: \"running\" | \"succeeded\" | \"failed\";\n resultJson: TOutput;\n traceJson: Record<string, unknown>[];\n outputJson: Record<string, unknown>[];\n failureCode?: string | null;\n failureMessage?: string | null;\n};\n\ntype ProjectActionClientInput = {\n apiKey: string;\n apiBaseUrl: string;\n};\n\nexport class OpenPondProjectActionsClient {\n readonly #apiKey: string;\n readonly #apiBaseUrl: string;\n\n constructor(input: ProjectActionClientInput) {\n this.#apiKey = input.apiKey;\n this.#apiBaseUrl = input.apiBaseUrl.replace(/\\/+$/, \"\");\n }\n\n async list(input: { projectId: string; teamId: string }): Promise<ProjectActionRelease[]> {\n const response = await apiFetch(\n this.#apiBaseUrl,\n this.#apiKey,\n projectActionPath(input.projectId, \"releases\", input.teamId),\n );\n return (await readApiJson<{ releases: ProjectActionRelease[] }>(response, \"List Project Action releases\")).releases;\n }\n\n async catalog(input: { projectId: string; teamId: string }): Promise<HostedProjectActionCatalog> {\n const response = await apiFetch(\n this.#apiBaseUrl,\n this.#apiKey,\n projectActionPath(input.projectId, \"catalog\", input.teamId),\n );\n return (await readApiJson<{ catalog: HostedProjectActionCatalog }>(response, \"Get Project Action catalog\")).catalog;\n }\n\n async publish(input: {\n projectId: string;\n teamId: string;\n sourceRef: string;\n sourceCommitSha: string;\n build: ProjectActionBuildResult;\n metadata?: Record<string, unknown>;\n }): Promise<ProjectActionRelease> {\n const [bundle, runner] = await Promise.all([\n fs.readFile(input.build.bundlePath),\n fs.readFile(input.build.runnerPath),\n ]);\n const response = await apiFetch(\n this.#apiBaseUrl,\n this.#apiKey,\n projectActionPath(input.projectId, \"releases\", input.teamId),\n {\n method: \"POST\",\n body: JSON.stringify({\n sourceRef: input.sourceRef,\n sourceCommitSha: input.sourceCommitSha,\n bundleBase64: bundle.toString(\"base64\"),\n runnerBase64: runner.toString(\"base64\"),\n registry: input.build.registry,\n manifest: input.build.manifest,\n metadata: input.metadata,\n }),\n },\n );\n return (await readApiJson<{ release: ProjectActionRelease }>(response, \"Publish Project Actions\")).release;\n }\n\n async run<TOutput = Record<string, unknown>>(input: {\n projectId: string;\n teamId: string;\n actionId: string;\n value?: Record<string, unknown>;\n releaseId?: string;\n idempotencyKey?: string;\n callerType?: \"sdk\" | \"work\" | \"scheduled_work\" | \"website\" | \"internal\";\n callerId?: string;\n signal?: AbortSignal;\n }): Promise<ProjectActionInvocation<TOutput>> {\n const response = await apiFetch(\n this.#apiBaseUrl,\n this.#apiKey,\n projectActionPath(input.projectId, `actions/${encodeURIComponent(input.actionId)}`, input.teamId),\n {\n method: \"POST\",\n body: JSON.stringify({\n input: input.value ?? {},\n releaseId: input.releaseId,\n idempotencyKey: input.idempotencyKey,\n callerType: input.callerType ?? \"sdk\",\n callerId: input.callerId,\n }),\n signal: input.signal,\n timeoutMs: 15 * 60 * 1000,\n },\n );\n return (await readApiJson<{ invocation: ProjectActionInvocation<TOutput> }>(response, \"Run Project Action\")).invocation;\n }\n}\n\nfunction projectActionPath(projectId: string, suffix: string, teamId: string): string {\n return `/v1/project-actions/${encodeURIComponent(projectId)}/${suffix}?teamId=${encodeURIComponent(teamId)}`;\n}\n", "const VERCEL_PROTECTION_BYPASS_HEADER = \"x-vercel-protection-bypass\";\n\nexport function withVercelProtectionBypass(\n requestUrl: string,\n inputHeaders?: HeadersInit,\n env: Record<string, string | undefined> =\n typeof process === \"undefined\" ? {} : process.env,\n): Headers {\n const headers = new Headers(inputHeaders);\n const secret = env.VERCEL_AUTOMATION_BYPASS_SECRET?.trim();\n if (!secret || !isOpenPondStagingUrl(requestUrl)) return headers;\n headers.set(VERCEL_PROTECTION_BYPASS_HEADER, secret);\n return headers;\n}\n\nfunction isOpenPondStagingUrl(requestUrl: string): boolean {\n try {\n const hostname = new URL(requestUrl).hostname.toLowerCase();\n return (\n hostname === \"staging.openpond.ai\" ||\n hostname === \"staging-api.openpond.ai\" ||\n hostname.endsWith(\".staging-api.openpond.ai\")\n );\n } catch {\n return false;\n }\n}\n", "import { withVercelProtectionBypass } from \"./vercel-protection.js\";\n\nconst DEFAULT_API_TIMEOUT_MS = 30_000;\nconst DEFAULT_API_RESPONSE_BYTES = 8 * 1024 * 1024;\nexport const LONG_STREAM_API_OPTIONS = { timeoutMs: 15 * 60 * 1000, maxResponseBytes: 64 * 1024 * 1024 } as const;\n\nexport type ApiFetchOptions = RequestInit & {\n timeoutMs?: number;\n maxResponseBytes?: number;\n};\n\nexport class ApiTimeoutError extends Error {\n readonly code = \"OPENPOND_API_TIMEOUT\";\n\n constructor(readonly timeoutMs: number, readonly requestUrl: string) {\n super(`API request timed out after ${timeoutMs}ms: ${requestUrl}`);\n this.name = \"ApiTimeoutError\";\n }\n}\n\nexport class ApiResponseTooLargeError extends Error {\n readonly code = \"OPENPOND_API_RESPONSE_TOO_LARGE\";\n\n constructor(readonly maximumBytes: number, readonly requestUrl: string) {\n super(`API response exceeded ${maximumBytes} bytes: ${requestUrl}`);\n this.name = \"ApiResponseTooLargeError\";\n }\n}\n\nexport class OpenPondApiError extends Error {\n readonly code: string;\n\n constructor(\n readonly status: number,\n errorCode: string | null,\n label: string,\n readonly apiMessage: string | null = null,\n ) {\n const detail = apiMessage || errorCode;\n super(`${label} failed: ${status}${detail ? ` ${detail}` : \"\"}`);\n this.name = \"OpenPondApiError\";\n this.code = errorCode || \"OPENPOND_API_ERROR\";\n }\n}\n\nexport async function apiFetch(\n baseUrl: string,\n token: string | null,\n requestPath: string,\n options: ApiFetchOptions = {},\n): Promise<Response> {\n const { timeoutMs = DEFAULT_API_TIMEOUT_MS, maxResponseBytes = DEFAULT_API_RESPONSE_BYTES, ...init } = options;\n const requestUrl = `${baseUrl}${requestPath}`;\n const headers = withVercelProtectionBypass(requestUrl, init.headers);\n headers.set(\"Content-Type\", \"application/json\");\n const apiKey = process.env.OPENPOND_API_KEY;\n const trimmedToken = token?.trim() || \"\";\n const tokenIsApiKey = trimmedToken.startsWith(\"opk_\");\n const effectiveApiKey = apiKey || (tokenIsApiKey ? trimmedToken : null);\n if (effectiveApiKey && !headers.has(\"openpond-api-key\")) headers.set(\"openpond-api-key\", effectiveApiKey);\n if (token) {\n headers.set(\"Authorization\", tokenIsApiKey ? `ApiKey ${trimmedToken}` : `Bearer ${token}`);\n } else if (apiKey && !headers.has(\"Authorization\")) {\n headers.set(\"Authorization\", `ApiKey ${apiKey}`);\n }\n\n const timeoutController = new AbortController();\n const timeoutError = new ApiTimeoutError(timeoutMs, requestUrl);\n const timer = timeoutMs > 0\n ? setTimeout(() => timeoutController.abort(timeoutError), timeoutMs)\n : null;\n timer?.unref?.();\n const signal = composedSignal(init.signal, timeoutController.signal, timeoutMs);\n const cleanup = () => {\n if (timer) clearTimeout(timer);\n };\n\n try {\n const response = await fetch(requestUrl, { ...init, headers, signal });\n return boundedResponse(response, {\n cleanup,\n maximumBytes: maxResponseBytes,\n requestUrl,\n timeoutController,\n timeoutError,\n });\n } catch (error) {\n cleanup();\n if (timeoutController.signal.aborted) throw timeoutError;\n throw error;\n }\n}\n\nexport async function readApiJson<T>(response: Response, label: string): Promise<T> {\n let payload: T & { error?: unknown; message?: unknown };\n try {\n const text = await response.text();\n payload = (text ? JSON.parse(text) : {}) as T & { error?: unknown; message?: unknown };\n } catch (error) {\n if (error instanceof ApiTimeoutError || error instanceof ApiResponseTooLargeError) throw error;\n payload = {} as T & { error?: unknown; message?: unknown };\n }\n if (!response.ok) {\n const errorCode = typeof payload.error === \"string\" ? payload.error : null;\n const apiMessage =\n typeof payload.message === \"string\" ? payload.message : null;\n throw new OpenPondApiError(response.status, errorCode, label, apiMessage);\n }\n return payload as T;\n}\n\nfunction boundedResponse(\n response: Response,\n input: {\n cleanup: () => void;\n maximumBytes: number;\n requestUrl: string;\n timeoutController: AbortController;\n timeoutError: ApiTimeoutError;\n },\n): Response {\n if (!response.body) {\n input.cleanup();\n return response;\n }\n const contentLength = Number(response.headers.get(\"content-length\"));\n if (input.maximumBytes > 0 && Number.isFinite(contentLength) && contentLength > input.maximumBytes) {\n input.cleanup();\n void response.body.cancel();\n throw new ApiResponseTooLargeError(input.maximumBytes, input.requestUrl);\n }\n\n const reader = response.body.getReader();\n let receivedBytes = 0;\n const body = new ReadableStream<Uint8Array>({\n async pull(controller) {\n try {\n const result = await reader.read();\n if (result.done) {\n input.cleanup();\n controller.close();\n return;\n }\n receivedBytes += result.value.byteLength;\n if (input.maximumBytes > 0 && receivedBytes > input.maximumBytes) {\n input.cleanup();\n await reader.cancel();\n controller.error(new ApiResponseTooLargeError(input.maximumBytes, input.requestUrl));\n return;\n }\n controller.enqueue(result.value);\n } catch (error) {\n input.cleanup();\n controller.error(input.timeoutController.signal.aborted ? input.timeoutError : error);\n }\n },\n async cancel(reason) {\n input.cleanup();\n await reader.cancel(reason);\n },\n });\n return new Response(body, {\n headers: response.headers,\n status: response.status,\n statusText: response.statusText,\n });\n}\n\nfunction composedSignal(\n callerSignal: AbortSignal | null | undefined,\n timeoutSignal: AbortSignal,\n timeoutMs: number,\n): AbortSignal | undefined {\n if (timeoutMs <= 0) return callerSignal ?? undefined;\n return callerSignal ? AbortSignal.any([callerSignal, timeoutSignal]) : timeoutSignal;\n}\n"],
5
- "mappings": ";AAAA,SAAS,YAAY,UAAU;;;ACA/B,IAAM,kCAAkC;AAElC,SAAU,2BACd,YACA,cACA,MACE,OAAO,YAAY,cAAc,CAAA,IAAK,QAAQ,KAAG;AAEnD,QAAM,UAAU,IAAI,QAAQ,YAAY;AACxC,QAAM,SAAS,IAAI,iCAAiC,KAAI;AACxD,MAAI,CAAC,UAAU,CAAC,qBAAqB,UAAU;AAAG,WAAO;AACzD,UAAQ,IAAI,iCAAiC,MAAM;AACnD,SAAO;AACT;AAEA,SAAS,qBAAqB,YAAkB;AAC9C,MAAI;AACF,UAAM,WAAW,IAAI,IAAI,UAAU,EAAE,SAAS,YAAW;AACzD,WACE,aAAa,yBACb,aAAa,6BACb,SAAS,SAAS,0BAA0B;EAE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,YAA+C,UAAU,yBAAyB,GAAG;AAAA,EACrG;AAAA,EAEA,MAAM,IAAuC,OAUC;AAC5C,UAAM,WAAW,MAAM;AAAA,MACrB,KAAK;AAAA,MACL,KAAK;AAAA,MACL,kBAAkB,MAAM,WAAW,WAAW,mBAAmB,MAAM,QAAQ,CAAC,IAAI,MAAM,MAAM;AAAA,MAChG;AAAA,QACE,QAAQ;AAAA,QACR,MAAM,KAAK,UAAU;AAAA,UACnB,OAAO,MAAM,SAAS,CAAC;AAAA,UACvB,WAAW,MAAM;AAAA,UACjB,gBAAgB,MAAM;AAAA,UACtB,YAAY,MAAM,cAAc;AAAA,UAChC,UAAU,MAAM;AAAA,QAClB,CAAC;AAAA,QACD,QAAQ,MAAM;AAAA,QACd,WAAW,KAAK,KAAK;AAAA,MACvB;AAAA,IACF;AACA,YAAQ,MAAM,YAA8D,UAAU,oBAAoB,GAAG;AAAA,EAC/G;AACF;AAEA,SAAS,kBAAkB,WAAmB,QAAgB,QAAwB;AACpF,SAAO,uBAAuB,mBAAmB,SAAS,CAAC,IAAI,MAAM,WAAW,mBAAmB,MAAM,CAAC;AAC5G;",
3
+ "sources": ["../src/project-actions.ts", "../../cloud/src/api/core.ts"],
4
+ "sourcesContent": ["import { promises as fs } from \"node:fs\";\n\nimport { apiFetch, readApiJson } from \"@openpond/cloud/api/core\";\n\nimport type { ProjectActionBuildResult, ProjectActionRegistry } from \"../../actions/src/types.js\";\n\nexport type ProjectActionRelease = {\n id: string;\n projectId: string;\n sourceCommitSha: string;\n bundleHash: string;\n registryHash: string;\n status: string;\n createdAt: string;\n};\n\nexport type HostedProjectActionCatalog = {\n releaseId: string;\n sourceCommitSha: string;\n bundleHash: string;\n registryHash: string;\n registry: ProjectActionRegistry;\n};\n\nexport type ProjectActionInvocation<TOutput = Record<string, unknown>> = {\n id: string;\n releaseId: string;\n projectId: string;\n actionId: string;\n status: \"running\" | \"succeeded\" | \"failed\";\n resultJson: TOutput;\n traceJson: Record<string, unknown>[];\n outputJson: Record<string, unknown>[];\n failureCode?: string | null;\n failureMessage?: string | null;\n};\n\ntype ProjectActionClientInput = {\n apiKey: string;\n apiBaseUrl: string;\n};\n\nexport class OpenPondProjectActionsClient {\n readonly #apiKey: string;\n readonly #apiBaseUrl: string;\n\n constructor(input: ProjectActionClientInput) {\n this.#apiKey = input.apiKey;\n this.#apiBaseUrl = input.apiBaseUrl.replace(/\\/+$/, \"\");\n }\n\n async list(input: { projectId: string; teamId: string }): Promise<ProjectActionRelease[]> {\n const response = await apiFetch(\n this.#apiBaseUrl,\n this.#apiKey,\n projectActionPath(input.projectId, \"releases\", input.teamId),\n );\n return (await readApiJson<{ releases: ProjectActionRelease[] }>(response, \"List Project Action releases\")).releases;\n }\n\n async catalog(input: { projectId: string; teamId: string }): Promise<HostedProjectActionCatalog> {\n const response = await apiFetch(\n this.#apiBaseUrl,\n this.#apiKey,\n projectActionPath(input.projectId, \"catalog\", input.teamId),\n );\n return (await readApiJson<{ catalog: HostedProjectActionCatalog }>(response, \"Get Project Action catalog\")).catalog;\n }\n\n async publish(input: {\n projectId: string;\n teamId: string;\n sourceRef: string;\n sourceCommitSha: string;\n build: ProjectActionBuildResult;\n metadata?: Record<string, unknown>;\n }): Promise<ProjectActionRelease> {\n const [bundle, runner] = await Promise.all([\n fs.readFile(input.build.bundlePath),\n fs.readFile(input.build.runnerPath),\n ]);\n const response = await apiFetch(\n this.#apiBaseUrl,\n this.#apiKey,\n projectActionPath(input.projectId, \"releases\", input.teamId),\n {\n method: \"POST\",\n body: JSON.stringify({\n sourceRef: input.sourceRef,\n sourceCommitSha: input.sourceCommitSha,\n bundleBase64: bundle.toString(\"base64\"),\n runnerBase64: runner.toString(\"base64\"),\n registry: input.build.registry,\n manifest: input.build.manifest,\n metadata: input.metadata,\n }),\n },\n );\n return (await readApiJson<{ release: ProjectActionRelease }>(response, \"Publish Project Actions\")).release;\n }\n\n async run<TOutput = Record<string, unknown>>(input: {\n projectId: string;\n teamId: string;\n actionId: string;\n value?: Record<string, unknown>;\n releaseId?: string;\n idempotencyKey?: string;\n callerType?: \"sdk\" | \"work\" | \"scheduled_work\" | \"website\" | \"internal\";\n callerId?: string;\n signal?: AbortSignal;\n }): Promise<ProjectActionInvocation<TOutput>> {\n const response = await apiFetch(\n this.#apiBaseUrl,\n this.#apiKey,\n projectActionPath(input.projectId, `actions/${encodeURIComponent(input.actionId)}`, input.teamId),\n {\n method: \"POST\",\n body: JSON.stringify({\n input: input.value ?? {},\n releaseId: input.releaseId,\n idempotencyKey: input.idempotencyKey,\n callerType: input.callerType ?? \"sdk\",\n callerId: input.callerId,\n }),\n signal: input.signal,\n timeoutMs: 15 * 60 * 1000,\n },\n );\n return (await readApiJson<{ invocation: ProjectActionInvocation<TOutput> }>(response, \"Run Project Action\")).invocation;\n }\n}\n\nfunction projectActionPath(projectId: string, suffix: string, teamId: string): string {\n return `/v1/project-actions/${encodeURIComponent(projectId)}/${suffix}?teamId=${encodeURIComponent(teamId)}`;\n}\n", "const DEFAULT_API_TIMEOUT_MS = 30_000;\nconst DEFAULT_API_RESPONSE_BYTES = 8 * 1024 * 1024;\nexport const LONG_STREAM_API_OPTIONS = { timeoutMs: 15 * 60 * 1000, maxResponseBytes: 64 * 1024 * 1024 } as const;\n\nexport type ApiFetchOptions = RequestInit & {\n timeoutMs?: number;\n maxResponseBytes?: number;\n};\n\nexport class ApiTimeoutError extends Error {\n readonly code = \"OPENPOND_API_TIMEOUT\";\n\n constructor(readonly timeoutMs: number, readonly requestUrl: string) {\n super(`API request timed out after ${timeoutMs}ms: ${requestUrl}`);\n this.name = \"ApiTimeoutError\";\n }\n}\n\nexport class ApiResponseTooLargeError extends Error {\n readonly code = \"OPENPOND_API_RESPONSE_TOO_LARGE\";\n\n constructor(readonly maximumBytes: number, readonly requestUrl: string) {\n super(`API response exceeded ${maximumBytes} bytes: ${requestUrl}`);\n this.name = \"ApiResponseTooLargeError\";\n }\n}\n\nexport class OpenPondApiError extends Error {\n readonly code: string;\n\n constructor(\n readonly status: number,\n errorCode: string | null,\n label: string,\n readonly apiMessage: string | null = null,\n ) {\n const detail = apiMessage || errorCode;\n super(`${label} failed: ${status}${detail ? ` ${detail}` : \"\"}`);\n this.name = \"OpenPondApiError\";\n this.code = errorCode || \"OPENPOND_API_ERROR\";\n }\n}\n\nexport async function apiFetch(\n baseUrl: string,\n token: string | null,\n requestPath: string,\n options: ApiFetchOptions = {},\n): Promise<Response> {\n const { timeoutMs = DEFAULT_API_TIMEOUT_MS, maxResponseBytes = DEFAULT_API_RESPONSE_BYTES, ...init } = options;\n const requestUrl = `${baseUrl}${requestPath}`;\n const headers = new Headers(init.headers);\n headers.set(\"Content-Type\", \"application/json\");\n const apiKey = process.env.OPENPOND_API_KEY;\n const trimmedToken = token?.trim() || \"\";\n const tokenIsApiKey = trimmedToken.startsWith(\"opk_\");\n const effectiveApiKey = apiKey || (tokenIsApiKey ? trimmedToken : null);\n if (effectiveApiKey && !headers.has(\"openpond-api-key\")) headers.set(\"openpond-api-key\", effectiveApiKey);\n if (token) {\n headers.set(\"Authorization\", tokenIsApiKey ? `ApiKey ${trimmedToken}` : `Bearer ${token}`);\n } else if (apiKey && !headers.has(\"Authorization\")) {\n headers.set(\"Authorization\", `ApiKey ${apiKey}`);\n }\n\n const timeoutController = new AbortController();\n const timeoutError = new ApiTimeoutError(timeoutMs, requestUrl);\n const timer = timeoutMs > 0\n ? setTimeout(() => timeoutController.abort(timeoutError), timeoutMs)\n : null;\n timer?.unref?.();\n const signal = composedSignal(init.signal, timeoutController.signal, timeoutMs);\n const cleanup = () => {\n if (timer) clearTimeout(timer);\n };\n\n try {\n const response = await fetch(requestUrl, { ...init, headers, signal });\n return boundedResponse(response, {\n cleanup,\n maximumBytes: maxResponseBytes,\n requestUrl,\n timeoutController,\n timeoutError,\n });\n } catch (error) {\n cleanup();\n if (timeoutController.signal.aborted) throw timeoutError;\n throw error;\n }\n}\n\nexport async function readApiJson<T>(response: Response, label: string): Promise<T> {\n let payload: T & { error?: unknown; message?: unknown };\n try {\n const text = await response.text();\n payload = (text ? JSON.parse(text) : {}) as T & { error?: unknown; message?: unknown };\n } catch (error) {\n if (error instanceof ApiTimeoutError || error instanceof ApiResponseTooLargeError) throw error;\n payload = {} as T & { error?: unknown; message?: unknown };\n }\n if (!response.ok) {\n const errorCode = typeof payload.error === \"string\" ? payload.error : null;\n const apiMessage =\n typeof payload.message === \"string\" ? payload.message : null;\n throw new OpenPondApiError(response.status, errorCode, label, apiMessage);\n }\n return payload as T;\n}\n\nfunction boundedResponse(\n response: Response,\n input: {\n cleanup: () => void;\n maximumBytes: number;\n requestUrl: string;\n timeoutController: AbortController;\n timeoutError: ApiTimeoutError;\n },\n): Response {\n if (!response.body) {\n input.cleanup();\n return response;\n }\n const contentLength = Number(response.headers.get(\"content-length\"));\n if (input.maximumBytes > 0 && Number.isFinite(contentLength) && contentLength > input.maximumBytes) {\n input.cleanup();\n void response.body.cancel();\n throw new ApiResponseTooLargeError(input.maximumBytes, input.requestUrl);\n }\n\n const reader = response.body.getReader();\n let receivedBytes = 0;\n const body = new ReadableStream<Uint8Array>({\n async pull(controller) {\n try {\n const result = await reader.read();\n if (result.done) {\n input.cleanup();\n controller.close();\n return;\n }\n receivedBytes += result.value.byteLength;\n if (input.maximumBytes > 0 && receivedBytes > input.maximumBytes) {\n input.cleanup();\n await reader.cancel();\n controller.error(new ApiResponseTooLargeError(input.maximumBytes, input.requestUrl));\n return;\n }\n controller.enqueue(result.value);\n } catch (error) {\n input.cleanup();\n controller.error(input.timeoutController.signal.aborted ? input.timeoutError : error);\n }\n },\n async cancel(reason) {\n input.cleanup();\n await reader.cancel(reason);\n },\n });\n return new Response(body, {\n headers: response.headers,\n status: response.status,\n statusText: response.statusText,\n });\n}\n\nfunction composedSignal(\n callerSignal: AbortSignal | null | undefined,\n timeoutSignal: AbortSignal,\n timeoutMs: number,\n): AbortSignal | undefined {\n if (timeoutMs <= 0) return callerSignal ?? undefined;\n return callerSignal ? AbortSignal.any([callerSignal, timeoutS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