openpond-sdk 0.3.3 → 0.4.0
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/TASKSETS.md +55 -0
- package/dist/actions-local.js +67 -118
- package/dist/actions-local.js.map +4 -4
- package/dist/actions.js +4 -92
- package/dist/actions.js.map +4 -4
- package/dist/chunk-27ETSPHQ.js +83 -0
- package/dist/chunk-27ETSPHQ.js.map +7 -0
- package/dist/chunk-5PRP457R.js +477 -0
- package/dist/chunk-5PRP457R.js.map +7 -0
- package/dist/chunk-65D4C7HP.js +273 -0
- package/dist/chunk-65D4C7HP.js.map +7 -0
- package/dist/chunk-747CMU2Y.js +222 -0
- package/dist/chunk-747CMU2Y.js.map +7 -0
- package/dist/chunk-7O5X7DBU.js +80 -0
- package/dist/chunk-7O5X7DBU.js.map +7 -0
- package/dist/chunk-A4ZDOZKP.js +115 -0
- package/dist/chunk-A4ZDOZKP.js.map +7 -0
- package/dist/chunk-APHPXQEA.js +155 -0
- package/dist/chunk-APHPXQEA.js.map +7 -0
- package/dist/chunk-AVW35YOH.js +574 -0
- package/dist/chunk-AVW35YOH.js.map +7 -0
- package/dist/chunk-AZUCY3E5.js +2395 -0
- package/dist/chunk-AZUCY3E5.js.map +7 -0
- package/dist/chunk-IVEXCIHO.js +1373 -0
- package/dist/chunk-IVEXCIHO.js.map +7 -0
- package/dist/chunk-K5ZCYOZO.js +49 -0
- package/dist/chunk-K5ZCYOZO.js.map +7 -0
- package/dist/chunk-LLHE4BOD.js +220 -0
- package/dist/chunk-LLHE4BOD.js.map +7 -0
- package/dist/chunk-LXXQVGQY.js +1 -0
- package/dist/chunk-LXXQVGQY.js.map +7 -0
- package/dist/chunk-P27DQ65Z.js +138 -0
- package/dist/chunk-P27DQ65Z.js.map +7 -0
- package/dist/chunk-QLEJOCQX.js +72 -0
- package/dist/chunk-QLEJOCQX.js.map +7 -0
- package/dist/chunk-S7I45WJQ.js +57 -0
- package/dist/chunk-S7I45WJQ.js.map +7 -0
- package/dist/chunk-ZPCK222K.js +586 -0
- package/dist/chunk-ZPCK222K.js.map +7 -0
- package/dist/index.js +33 -2488
- package/dist/index.js.map +4 -4
- package/dist/learning.js +16 -2042
- package/dist/learning.js.map +4 -4
- package/dist/model-batch-review.js +5 -42
- package/dist/model-batch-review.js.map +3 -3
- package/dist/model-projects.js +29 -430
- package/dist/model-projects.js.map +3 -3
- package/dist/model-starter-attempts.js +53 -310
- package/dist/model-starter-attempts.js.map +4 -4
- package/dist/model-starter-catalog.js +17 -460
- package/dist/model-starter-catalog.js.map +4 -4
- package/dist/model-starters.js +32 -709
- package/dist/model-starters.js.map +4 -4
- package/dist/model-taskset-authoring.js +11 -44
- package/dist/model-taskset-authoring.js.map +3 -3
- package/dist/profile-actions.js +4 -211
- package/dist/profile-actions.js.map +3 -3
- package/dist/project-actions.js +4 -224
- package/dist/project-actions.js.map +3 -3
- package/dist/refiner.js +14 -554
- package/dist/refiner.js.map +4 -4
- package/dist/taskset-catalog.js +9 -104
- package/dist/taskset-catalog.js.map +3 -3
- package/dist/taskset-drafts.js +465 -0
- package/dist/taskset-drafts.js.map +7 -0
- package/dist/taskset-packages.js +946 -3089
- package/dist/taskset-packages.js.map +4 -4
- package/dist/training.js +43 -822
- package/dist/training.js.map +4 -4
- package/dist/types/packages/sdk/src/index.d.ts +3 -3
- package/dist/types/packages/sdk/src/index.d.ts.map +1 -1
- package/dist/types/packages/sdk/src/learning-client.d.ts +130 -0
- package/dist/types/packages/sdk/src/learning-client.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/learning.d.ts +1 -129
- package/dist/types/packages/sdk/src/learning.d.ts.map +1 -1
- package/dist/types/packages/sdk/src/taskset-authored-contracts.d.ts +1170 -0
- package/dist/types/packages/sdk/src/taskset-authored-contracts.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-authored-files.d.ts +560 -0
- package/dist/types/packages/sdk/src/taskset-authored-files.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-authored-portable-release.d.ts +92 -0
- package/dist/types/packages/sdk/src/taskset-authored-portable-release.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-authored-tool-environment.d.ts +15 -0
- package/dist/types/packages/sdk/src/taskset-authored-tool-environment.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-authored-validation.d.ts +18 -0
- package/dist/types/packages/sdk/src/taskset-authored-validation.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-api-contracts.d.ts +1681 -0
- package/dist/types/packages/sdk/src/taskset-draft-api-contracts.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-authoring.d.ts +19 -0
- package/dist/types/packages/sdk/src/taskset-draft-authoring.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-client.d.ts +2713 -0
- package/dist/types/packages/sdk/src/taskset-draft-client.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-core.d.ts +1000 -0
- package/dist/types/packages/sdk/src/taskset-draft-core.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-dataset-artifacts.d.ts +429 -0
- package/dist/types/packages/sdk/src/taskset-draft-dataset-artifacts.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-dataset-sources.d.ts +284 -0
- package/dist/types/packages/sdk/src/taskset-draft-dataset-sources.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-document.d.ts +846 -0
- package/dist/types/packages/sdk/src/taskset-draft-document.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-files.d.ts +8 -0
- package/dist/types/packages/sdk/src/taskset-draft-files.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-harness-actions.d.ts +28 -0
- package/dist/types/packages/sdk/src/taskset-draft-harness-actions.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-manifests.d.ts +8 -0
- package/dist/types/packages/sdk/src/taskset-draft-manifests.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-package-compiler.d.ts +967 -0
- package/dist/types/packages/sdk/src/taskset-draft-package-compiler.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-publication.d.ts +10 -0
- package/dist/types/packages/sdk/src/taskset-draft-publication.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-source.d.ts +1297 -0
- package/dist/types/packages/sdk/src/taskset-draft-source.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-draft-workspace.d.ts +1597 -0
- package/dist/types/packages/sdk/src/taskset-draft-workspace.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-drafts.d.ts +16 -0
- package/dist/types/packages/sdk/src/taskset-drafts.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-package-grader-projection.d.ts +64 -0
- package/dist/types/packages/sdk/src/taskset-package-grader-projection.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-package-projection.d.ts +1514 -0
- package/dist/types/packages/sdk/src/taskset-package-projection.d.ts.map +1 -0
- package/dist/types/packages/sdk/src/taskset-packages.d.ts +6 -0
- package/dist/types/packages/sdk/src/taskset-packages.d.ts.map +1 -1
- package/dist/workflows.js +4 -221
- package/dist/workflows.js.map +3 -3
- package/package.json +5 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/learning-credentials.ts", "../src/learning-client.ts"],
|
|
4
|
+
"sourcesContent": ["import { z } from \"zod\";\nimport { ReleaseIdSchema } from \"@openpond/harness\";\nimport { LearningRevisionRefSchema } from \"@openpond/evals/learning\";\nimport { TaskSplitSchema } from \"@openpond/evals/tasksets\";\n\n/** Source credentials can submit evidence and feedback for one source only. */\nexport const LearningSourceCredentialSchema = z.object({\n id: ReleaseIdSchema,\n scope: ReleaseIdSchema,\n sourceId: ReleaseIdSchema,\n name: z.string().trim().min(1).max(100),\n keyPrefix: z.string().min(1).max(100),\n createdAt: z.iso.datetime(),\n expiresAt: z.iso.datetime(),\n revokedAt: z.iso.datetime().nullable(),\n}).strict();\nexport type LearningSourceCredential = z.infer<typeof LearningSourceCredentialSchema>;\nexport const LearningSourceCredentialSecretSchema = z.string().regex(/^opk_key_[A-Za-z0-9]{16}_[A-Za-z0-9]{48}$/);\n\nexport const LearningSourceCredentialRequestSchema = z.discriminatedUnion(\"action\", [\n z.object({ action: z.literal(\"create\"), scope: ReleaseIdSchema, sourceId: ReleaseIdSchema, name: z.string().trim().min(1).max(100), expiresAt: z.iso.datetime(), operationId: ReleaseIdSchema, apiKey: LearningSourceCredentialSecretSchema }).strict(),\n z.object({ action: z.literal(\"list\"), scope: ReleaseIdSchema, sourceId: ReleaseIdSchema, afterId: ReleaseIdSchema.optional(), limit: z.number().int().min(1).max(100).default(30) }).strict(),\n z.object({ action: z.literal(\"revoke\"), scope: ReleaseIdSchema, sourceId: ReleaseIdSchema, id: ReleaseIdSchema }).strict(),\n]);\nexport type LearningSourceCredentialRequest = z.infer<typeof LearningSourceCredentialRequestSchema>;\nexport const LearningSourceCredentialCreatedSchema = z.object({ credential: LearningSourceCredentialSchema, apiKey: LearningSourceCredentialSecretSchema }).strict();\nexport const LearningSourceCredentialPageSchema = z.object({ items: z.array(LearningSourceCredentialSchema).max(100), nextCursor: ReleaseIdSchema.nullable() }).strict();\nexport const LearningSourceConfigurationRequestSchema = z.object({ scope: ReleaseIdSchema, sourceId: ReleaseIdSchema }).strict();\nexport const LearningSourceConfigurationSchema = z.object({\n scope: ReleaseIdSchema, source: LearningRevisionRefSchema, taskDefinition: LearningRevisionRefSchema,\n enabled: z.boolean(), allowedSplits: z.array(TaskSplitSchema).min(1).max(4),\n}).strict();\n\n/** Keep this request in memory for retries. Hosts persist hashes, never its secret. */\nexport function createSourceCredentialRequest(input: { sourceId: string; name: string; expiresAt: string }) {\n return { ...input, operationId: crypto.randomUUID(), apiKey: `opk_key_${randomToken(16)}_${randomToken(48)}` };\n}\n\nfunction randomToken(length: number): string {\n const alphabet = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";\n let value = \"\";\n while (value.length < length) {\n for (const byte of crypto.getRandomValues(new Uint8Array(64))) {\n // Rejection sampling avoids modulo bias in the 62-character alphabet.\n if (byte < 248) value += alphabet[byte % 62];\n if (value.length === length) return value;\n }\n }\n return value;\n}\n\n/** Hosts enforce expiry when issuing and authenticating; tokens are never permanent. */\nexport function assertLearningCredentialExpiry(expiresAt: string, now: Date): void {\n const expires = Date.parse(z.iso.datetime().parse(expiresAt));\n if (expires <= now.getTime() || expires > now.getTime() + 90 * 24 * 60 * 60 * 1_000) throw new Error(\"Source credentials must expire within 90 days.\");\n}\n", "import { z } from \"zod\";\nimport {\n LearningCommandRequestSchema, LearningOperationResultSchema, LearningReadRequestSchema,\n TaskEvidenceInspectionResultSchema, sameLearningRef, type LearningRevisionRef,\n assertLearningRequestJson,\n learningResourceSchemas, type LearningCommand, type LearningOperationResult,\n type LearningResourceFor, type LearningResourceKind, type LearningResourcePage,\n type LearningResourceQuery, type TaskExampleSubmission, type TaskFeedbackSubmission,\n} from \"@openpond/evals/learning\";\nimport { assertBoundedTaskJson } from \"@openpond/evals/task-schema\";\nimport { LearningSourceCredentialSchema, LearningSourceCredentialRequestSchema, LearningSourceCredentialCreatedSchema, LearningSourceCredentialPageSchema, LearningSourceConfigurationRequestSchema, LearningSourceConfigurationSchema, type LearningSourceCredentialRequest } from \"./learning-credentials.js\";\n\nexport interface OpenPondLearningClientOptions {\n apiKey: string;\n baseUrl: string;\n /** Local profile or hosted team scope. The server checks the credential's ownership. */\n scope: string;\n fetch?: typeof globalThis.fetch;\n}\nexport interface LearningRequestOptions { signal?: AbortSignal }\nexport const LearningBatchPublicationSchema = z.object({\n batchId: z.string().trim().min(1).max(500), modelProjectId: z.string().trim().min(1).max(500),\n}).strict();\nexport const LearningBatchPublicationResultSchema = z.object({\n batchId: z.string().min(1), projectId: z.string().min(1), tasksetId: z.string().min(1),\n releaseId: z.string().min(1), revision: z.number().int().positive(), contentHash: z.string().regex(/^[a-f0-9]{64}$/),\n}).strict();\nexport class OpenPondLearningError extends Error {\n constructor(readonly status: number, readonly code: string, message: string, readonly details: unknown) {\n super(message);\n this.name = \"OpenPondLearningError\";\n }\n}\n\n/** The same portable commands are sent to the local and hosted execution owner. */\nexport class OpenPondLearningClient {\n readonly #options: OpenPondLearningClientOptions;\n constructor(options: OpenPondLearningClientOptions) {\n if (!options.apiKey.trim() || !options.scope.trim()) throw new Error(\"Learning API key and scope are required.\");\n const url = new URL(options.baseUrl);\n if (![\"http:\", \"https:\"].includes(url.protocol) || url.username || url.password || url.search || url.hash) throw new Error(\"Learning base URL must be an HTTP(S) endpoint without credentials, query, or fragment.\");\n this.#options = { ...options, baseUrl: url.toString().replace(/\\/+$/, \"\") };\n }\n\n async command(command: LearningCommand, options: LearningRequestOptions = {}): Promise<LearningOperationResult> {\n assertLearningRequestJson(command);\n const request = LearningCommandRequestSchema.parse({ scope: this.#options.scope, command });\n const result = LearningOperationResultSchema.parse(await this.#request(\"commands\", request, options));\n if (result.operationId !== command.operationId) throw new OpenPondLearningError(502, \"operation_identity_mismatch\", \"Learning response did not match the submitted operation.\", null);\n return result;\n }\n\n submitExample(example: TaskExampleSubmission, options: LearningRequestOptions = {}) {\n return this.command({ action: \"submit_example\", operationId: example.idempotencyKey, example }, options);\n }\n\n submitFeedback(feedback: TaskFeedbackSubmission, options: LearningRequestOptions = {}) {\n return this.command({ action: \"submit_feedback\", operationId: feedback.idempotencyKey, feedback }, options);\n }\n\n async get<K extends LearningResourceKind>(kind: K, id: string, revision?: number, options: LearningRequestOptions = {}): Promise<LearningResourceFor<K>> {\n const request = LearningReadRequestSchema.parse({ action: \"get\", scope: this.#options.scope, kind, id, ...(revision === undefined ? {} : { revision }) });\n return learningResourceSchemas[kind].parse(await this.#request(\"read\", request, options)) as LearningResourceFor<K>;\n }\n\n async inspectEvidence(evidence: LearningRevisionRef, options: LearningRequestOptions = {}) {\n const request = LearningReadRequestSchema.parse({ action: \"inspect_evidence\", scope: this.#options.scope, evidence });\n const result = TaskEvidenceInspectionResultSchema.parse(await this.#request(\"read\", request, options));\n if (!sameLearningRef(result.evidence, evidence)) throw new OpenPondLearningError(502, \"evidence_identity_mismatch\", \"Inspection did not match the requested evidence release.\", null);\n return result;\n }\n\n /** Prepare once with createSourceCredentialRequest and reuse it for retries. */\n async createSourceCredential(input: Omit<Extract<LearningSourceCredentialRequest, { action: \"create\" }>, \"action\" | \"scope\">, options: LearningRequestOptions = {}) {\n const request = LearningSourceCredentialRequestSchema.parse({ ...input, action: \"create\", scope: this.#options.scope });\n const result = LearningSourceCredentialCreatedSchema.parse(await this.#request(\"credentials\", request, options));\n this.#assertCredentialScope(result.credential, input.sourceId);\n if (result.apiKey !== input.apiKey || !input.apiKey.startsWith(`${result.credential.keyPrefix}_`)) throw new OpenPondLearningError(502, \"credential_identity_mismatch\", \"Credential response did not match the prepared credential.\", null);\n return result;\n }\n\n async listSourceCredentials(sourceId: string, query: { afterId?: string; limit?: number } = {}, options: LearningRequestOptions = {}) {\n const request = LearningSourceCredentialRequestSchema.parse({ ...query, action: \"list\", scope: this.#options.scope, sourceId });\n const result = LearningSourceCredentialPageSchema.parse(await this.#request(\"credentials\", request, options));\n if (result.items.length > (query.limit ?? 30)) throw new OpenPondLearningError(502, \"credential_page_invalid\", \"Credential response exceeded the requested page size.\", null);\n for (const item of result.items) this.#assertCredentialScope(item, sourceId);\n return result;\n }\n\n async revokeSourceCredential(sourceId: string, id: string, options: LearningRequestOptions = {}) {\n const request = LearningSourceCredentialRequestSchema.parse({ action: \"revoke\", scope: this.#options.scope, sourceId, id });\n const result = LearningSourceCredentialSchema.parse(await this.#request(\"credentials\", request, options));\n this.#assertCredentialScope(result, sourceId);\n if (result.id !== id || result.revokedAt === null) throw new OpenPondLearningError(502, \"credential_revocation_mismatch\", \"Credential revocation did not match the requested credential.\", null);\n return result;\n }\n\n async sourceConfiguration(sourceId: string, options: LearningRequestOptions = {}) {\n const request = LearningSourceConfigurationRequestSchema.parse({ scope: this.#options.scope, sourceId });\n const result = LearningSourceConfigurationSchema.parse(await this.#request(\"source-config\", request, options));\n if (result.scope !== this.#options.scope || result.source.id !== sourceId) throw new OpenPondLearningError(502, \"source_identity_mismatch\", \"Source configuration did not match the requested source.\", null);\n return result;\n }\n\n #assertCredentialScope(value: { scope: string; sourceId: string }, sourceId: string) {\n if (value.scope !== this.#options.scope || value.sourceId !== sourceId) throw new OpenPondLearningError(502, \"credential_scope_mismatch\", \"Credential response did not match the requested source.\", null);\n }\n\n async list<K extends LearningResourceKind>(kind: K, query: Partial<LearningResourceQuery> = {}, options: LearningRequestOptions = {}): Promise<LearningResourcePage<K>> {\n const request = LearningReadRequestSchema.parse({ action: \"list\", scope: this.#options.scope, kind, ...query });\n return z.object({ items: z.array(learningResourceSchemas[kind]).max(100), nextCursor: z.string().nullable() }).strict().parse(await this.#request(\"read\", request, options)) as LearningResourcePage<K>;\n }\n\n /** Hosted publication only: stores an immutable package and attaches it, without starting training. */\n async publishBatch(input: z.infer<typeof LearningBatchPublicationSchema>, options: LearningRequestOptions = {}) {\n const request = LearningBatchPublicationSchema.parse(input);\n const result = LearningBatchPublicationResultSchema.parse(await this.#request(\"publish-batch\", { ...request, scope: this.#options.scope }, options));\n if (result.batchId !== request.batchId) throw new OpenPondLearningError(502, \"batch_identity_mismatch\", \"Published batch response did not match the requested batch.\", null);\n return result;\n }\n\n async #request(endpoint: \"commands\" | \"read\" | \"publish-batch\" | \"credentials\" | \"source-config\", body: unknown, options: LearningRequestOptions): Promise<unknown> {\n assertBoundedTaskJson(body, 16_777_216);\n const response = await (this.#options.fetch ?? globalThis.fetch)(`${this.#options.baseUrl}/v1/learning/${endpoint}`, {\n method: \"POST\", headers: { Authorization: `Bearer ${this.#options.apiKey}`, \"Content-Type\": \"application/json\", Accept: \"application/json\", \"X-OpenPond-Team-Id\": this.#options.scope }, body: JSON.stringify(body), signal: options.signal,\n redirect: \"error\",\n });\n const payload = await readBoundedLearningResponse(response);\n if (!response.ok) {\n const error = z.object({ code: z.string().optional(), error: z.string().optional() }).passthrough().safeParse(payload);\n throw new OpenPondLearningError(response.status, error.success ? error.data.code ?? \"learning_request_failed\" : \"learning_request_failed\", error.success ? error.data.error ?? `Learning request failed (${response.status}).` : `Learning request failed (${response.status}).`, payload);\n }\n return payload;\n }\n}\n\nasync function readBoundedLearningResponse(response: Response): Promise<unknown> {\n const maximumBytes = 16_777_216;\n const reader = response.body?.getReader();\n if (!reader) throw new OpenPondLearningError(response.status, \"empty_response\", \"Learning response was empty.\", null);\n const decoder = new TextDecoder();\n let bytes = 0;\n let text = \"\";\n try {\n while (true) {\n const next = await reader.read();\n if (next.done) break;\n bytes += next.value.byteLength;\n if (bytes > maximumBytes) throw new OpenPondLearningError(response.status, \"response_too_large\", \"Learning response exceeded 16 MiB; request a smaller page.\", null);\n text += decoder.decode(next.value, { stream: true });\n }\n text += decoder.decode();\n const value: unknown = JSON.parse(text);\n assertBoundedTaskJson(value, maximumBytes);\n return value;\n } finally {\n await reader.cancel();\n reader.releaseLock();\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;AAAA,SAAS,SAAS;AAElB,SAAS,iCAAiC;AAC1C,SAAS,uBAAuB;AAGzB,IAAM,iCAAiC,EAAE,OAAO;AAAA,EACrD,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,UAAU;AAAA,EACV,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG;AAAA,EACtC,WAAW,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG;AAAA,EACpC,WAAW,EAAE,IAAI,SAAS;AAAA,EAC1B,WAAW,EAAE,IAAI,SAAS;AAAA,EAC1B,WAAW,EAAE,IAAI,SAAS,EAAE,SAAS;AACvC,CAAC,EAAE,OAAO;AAEH,IAAM,uCAAuC,EAAE,OAAO,EAAE,MAAM,2CAA2C;AAEzG,IAAM,wCAAwC,EAAE,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
|
|
1
|
+
// ../actions/src/define-action.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
var ACTION_ID = /^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/;
|
|
4
|
+
function defineAction(id, options) {
|
|
5
|
+
const normalizedId = id.trim();
|
|
6
|
+
if (!ACTION_ID.test(normalizedId) || normalizedId.length > 191) {
|
|
7
|
+
throw new Error(
|
|
8
|
+
`Invalid Project Action id ${JSON.stringify(id)}. Use a lowercase stable id such as analytics.get_summary.`
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
const description = options.description.trim();
|
|
12
|
+
if (!description) throw new Error(`Project Action ${normalizedId} requires a description.`);
|
|
13
|
+
if (description.length > 1e3) throw new Error(`Project Action ${normalizedId} description must be at most 1000 characters.`);
|
|
14
|
+
if (!(options.input instanceof z.ZodType)) {
|
|
15
|
+
throw new Error(`Project Action ${normalizedId} input must be a Zod schema.`);
|
|
16
|
+
}
|
|
17
|
+
if (!(options.output instanceof z.ZodType)) {
|
|
18
|
+
throw new Error(`Project Action ${normalizedId} output must be a Zod schema.`);
|
|
19
|
+
}
|
|
20
|
+
if (typeof options.run !== "function") {
|
|
21
|
+
throw new Error(`Project Action ${normalizedId} requires a run function.`);
|
|
22
|
+
}
|
|
23
|
+
const behavior = options.behavior ?? "read";
|
|
24
|
+
if (behavior !== "read" && behavior !== "write") {
|
|
25
|
+
throw new Error(`Project Action ${normalizedId} behavior must be read or write.`);
|
|
26
|
+
}
|
|
27
|
+
const approval = options.approval ?? {
|
|
28
|
+
mode: behavior === "write" ? "writes" : "never"
|
|
29
|
+
};
|
|
30
|
+
if (!["never", "always", "writes", "sensitive"].includes(approval.mode)) {
|
|
31
|
+
throw new Error(`Project Action ${normalizedId} has an invalid approval mode.`);
|
|
32
|
+
}
|
|
33
|
+
const label = options.label?.trim() || titleFromId(normalizedId);
|
|
34
|
+
if (label.length > 160) throw new Error(`Project Action ${normalizedId} label must be at most 160 characters.`);
|
|
35
|
+
const timeoutMs = options.timeoutMs ?? 6e4;
|
|
36
|
+
if (!Number.isInteger(timeoutMs) || timeoutMs < 1e3 || timeoutMs > 36e5) {
|
|
37
|
+
throw new Error(`Project Action ${normalizedId} timeoutMs must be between 1000 and 3600000.`);
|
|
38
|
+
}
|
|
39
|
+
const concurrency = options.concurrency ?? null;
|
|
40
|
+
if (concurrency !== null && (!Number.isInteger(concurrency) || concurrency < 1 || concurrency > 1e3)) {
|
|
41
|
+
throw new Error(`Project Action ${normalizedId} concurrency must be null or an integer from 1 to 1000.`);
|
|
42
|
+
}
|
|
43
|
+
const setup = [...options.setup ?? []];
|
|
44
|
+
const setupKeys = /* @__PURE__ */ new Set();
|
|
45
|
+
for (const requirement of setup) {
|
|
46
|
+
if (!["connection", "env", "package", "native_tool"].includes(requirement.kind)) {
|
|
47
|
+
throw new Error(`Project Action ${normalizedId} has an invalid setup requirement kind.`);
|
|
48
|
+
}
|
|
49
|
+
if (!requirement.name?.trim()) {
|
|
50
|
+
throw new Error(`Project Action ${normalizedId} has a setup requirement without a name.`);
|
|
51
|
+
}
|
|
52
|
+
const key = `${requirement.kind}:${requirement.name}`;
|
|
53
|
+
if (setupKeys.has(key)) throw new Error(`Project Action ${normalizedId} repeats setup requirement ${key}.`);
|
|
54
|
+
setupKeys.add(key);
|
|
55
|
+
}
|
|
56
|
+
return Object.freeze({
|
|
57
|
+
kind: "openpond-project-action",
|
|
58
|
+
id: normalizedId,
|
|
59
|
+
label,
|
|
60
|
+
description,
|
|
61
|
+
behavior,
|
|
62
|
+
inputSchema: options.input,
|
|
63
|
+
outputSchema: options.output,
|
|
64
|
+
approval,
|
|
65
|
+
setup: Object.freeze(setup),
|
|
66
|
+
invokesModel: options.invokesModel ?? false,
|
|
67
|
+
timeoutMs,
|
|
68
|
+
concurrency,
|
|
69
|
+
run: options.run
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function isProjectActionDefinition(value) {
|
|
73
|
+
return Boolean(
|
|
74
|
+
value && typeof value === "object" && value.kind === "openpond-project-action" && typeof value.id === "string" && typeof value.run === "function"
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
function titleFromId(id) {
|
|
78
|
+
return id.split(/[._-]/g).filter(Boolean).map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ");
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// ../actions/src/configuration.ts
|
|
82
|
+
import { promises as fs } from "node:fs";
|
|
83
|
+
import path from "node:path";
|
|
84
|
+
import { z as z2 } from "zod";
|
|
85
|
+
var PROJECT_ACTION_CONFIG_PATH = "openpond/project-actions.json";
|
|
86
|
+
var connectionSchema = z2.object({
|
|
87
|
+
values: z2.record(z2.string(), z2.unknown()).optional().default({}),
|
|
88
|
+
environment: z2.record(z2.string(), z2.string().trim().min(1)).optional().default({})
|
|
89
|
+
}).strict();
|
|
90
|
+
var configSchema = z2.object({
|
|
91
|
+
sourceDirectory: z2.string().trim().min(1).optional(),
|
|
92
|
+
outputDirectory: z2.string().trim().min(1).optional(),
|
|
93
|
+
environment: z2.record(z2.string(), z2.string().trim().min(1)).optional().default({}),
|
|
94
|
+
connections: z2.record(z2.string(), connectionSchema).optional().default({})
|
|
95
|
+
}).strict();
|
|
96
|
+
async function loadProjectActionConfiguration(projectRoot) {
|
|
97
|
+
const resolvedRoot = path.resolve(projectRoot);
|
|
98
|
+
const configPath = path.join(resolvedRoot, PROJECT_ACTION_CONFIG_PATH);
|
|
99
|
+
const raw = await fs.readFile(configPath, "utf8").catch((error) => {
|
|
100
|
+
if (error.code === "ENOENT") return null;
|
|
101
|
+
throw error;
|
|
102
|
+
});
|
|
103
|
+
if (raw === null) return configSchema.parse({});
|
|
104
|
+
let value;
|
|
105
|
+
try {
|
|
106
|
+
value = JSON.parse(raw);
|
|
107
|
+
} catch (error) {
|
|
108
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
109
|
+
throw new Error(`${PROJECT_ACTION_CONFIG_PATH} is not valid JSON: ${message}`);
|
|
110
|
+
}
|
|
111
|
+
return configSchema.parse(value);
|
|
112
|
+
}
|
|
113
|
+
function resolveProjectActionRuntime(config, hostEnvironment = process.env) {
|
|
114
|
+
const environment = {};
|
|
115
|
+
for (const [runtimeName, hostName] of Object.entries(config.environment)) {
|
|
116
|
+
const value = hostEnvironment[hostName];
|
|
117
|
+
if (value !== void 0) environment[runtimeName] = value;
|
|
118
|
+
}
|
|
119
|
+
const connections = {};
|
|
120
|
+
for (const [name, descriptor] of Object.entries(config.connections)) {
|
|
121
|
+
const value = { ...descriptor.values };
|
|
122
|
+
for (const [property, hostName] of Object.entries(descriptor.environment)) {
|
|
123
|
+
const environmentValue = hostEnvironment[hostName];
|
|
124
|
+
if (environmentValue !== void 0) value[property] = environmentValue;
|
|
125
|
+
}
|
|
126
|
+
connections[name] = value;
|
|
127
|
+
}
|
|
128
|
+
return { environment, connections };
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export {
|
|
132
|
+
defineAction,
|
|
133
|
+
isProjectActionDefinition,
|
|
134
|
+
PROJECT_ACTION_CONFIG_PATH,
|
|
135
|
+
loadProjectActionConfiguration,
|
|
136
|
+
resolveProjectActionRuntime
|
|
137
|
+
};
|
|
138
|
+
//# sourceMappingURL=chunk-P27DQ65Z.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../actions/src/define-action.ts", "../../actions/src/configuration.ts"],
|
|
4
|
+
"sourcesContent": ["import type {\n DefineProjectActionOptions,\n ProjectActionDefinition,\n} from \"./types.js\";\nimport { z } from \"zod\";\n\nconst ACTION_ID = /^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/;\n\nexport function defineAction<TInput, TOutput>(\n id: string,\n options: DefineProjectActionOptions<TInput, TOutput>,\n): ProjectActionDefinition<TInput, TOutput> {\n const normalizedId = id.trim();\n if (!ACTION_ID.test(normalizedId) || normalizedId.length > 191) {\n throw new Error(\n `Invalid Project Action id ${JSON.stringify(id)}. Use a lowercase stable id such as analytics.get_summary.`,\n );\n }\n const description = options.description.trim();\n if (!description) throw new Error(`Project Action ${normalizedId} requires a description.`);\n if (description.length > 1_000) throw new Error(`Project Action ${normalizedId} description must be at most 1000 characters.`);\n if (!(options.input instanceof z.ZodType)) {\n throw new Error(`Project Action ${normalizedId} input must be a Zod schema.`);\n }\n if (!(options.output instanceof z.ZodType)) {\n throw new Error(`Project Action ${normalizedId} output must be a Zod schema.`);\n }\n if (typeof options.run !== \"function\") {\n throw new Error(`Project Action ${normalizedId} requires a run function.`);\n }\n const behavior = options.behavior ?? \"read\";\n if (behavior !== \"read\" && behavior !== \"write\") {\n throw new Error(`Project Action ${normalizedId} behavior must be read or write.`);\n }\n const approval = options.approval ?? {\n mode: behavior === \"write\" ? \"writes\" : \"never\",\n };\n if (![\"never\", \"always\", \"writes\", \"sensitive\"].includes(approval.mode)) {\n throw new Error(`Project Action ${normalizedId} has an invalid approval mode.`);\n }\n const label = options.label?.trim() || titleFromId(normalizedId);\n if (label.length > 160) throw new Error(`Project Action ${normalizedId} label must be at most 160 characters.`);\n const timeoutMs = options.timeoutMs ?? 60_000;\n if (!Number.isInteger(timeoutMs) || timeoutMs < 1_000 || timeoutMs > 3_600_000) {\n throw new Error(`Project Action ${normalizedId} timeoutMs must be between 1000 and 3600000.`);\n }\n const concurrency = options.concurrency ?? null;\n if (concurrency !== null && (!Number.isInteger(concurrency) || concurrency < 1 || concurrency > 1_000)) {\n throw new Error(`Project Action ${normalizedId} concurrency must be null or an integer from 1 to 1000.`);\n }\n const setup = [...(options.setup ?? [])];\n const setupKeys = new Set<string>();\n for (const requirement of setup) {\n if (![\"connection\", \"env\", \"package\", \"native_tool\"].includes(requirement.kind)) {\n throw new Error(`Project Action ${normalizedId} has an invalid setup requirement kind.`);\n }\n if (!requirement.name?.trim()) {\n throw new Error(`Project Action ${normalizedId} has a setup requirement without a name.`);\n }\n const key = `${requirement.kind}:${requirement.name}`;\n if (setupKeys.has(key)) throw new Error(`Project Action ${normalizedId} repeats setup requirement ${key}.`);\n setupKeys.add(key);\n }\n return Object.freeze({\n kind: \"openpond-project-action\" as const,\n id: normalizedId,\n label,\n description,\n behavior,\n inputSchema: options.input,\n outputSchema: options.output,\n approval,\n setup: Object.freeze(setup),\n invokesModel: options.invokesModel ?? false,\n timeoutMs,\n concurrency,\n run: options.run,\n });\n}\n\nexport function isProjectActionDefinition(value: unknown): value is ProjectActionDefinition {\n return Boolean(\n value &&\n typeof value === \"object\" &&\n (value as { kind?: unknown }).kind === \"openpond-project-action\" &&\n typeof (value as { id?: unknown }).id === \"string\" &&\n typeof (value as { run?: unknown }).run === \"function\",\n );\n}\n\nfunction titleFromId(id: string): string {\n return id\n .split(/[._-]/g)\n .filter(Boolean)\n .map((part) => `${part[0]?.toUpperCase() ?? \"\"}${part.slice(1)}`)\n .join(\" \");\n}\n", "import { promises as fs } from \"node:fs\";\nimport path from \"node:path\";\n\nimport { z } from \"zod\";\n\nexport const PROJECT_ACTION_CONFIG_PATH = \"openpond/project-actions.json\";\n\nconst connectionSchema = z.object({\n values: z.record(z.string(), z.unknown()).optional().default({}),\n environment: z.record(z.string(), z.string().trim().min(1)).optional().default({}),\n}).strict();\n\nconst configSchema = z.object({\n sourceDirectory: z.string().trim().min(1).optional(),\n outputDirectory: z.string().trim().min(1).optional(),\n environment: z.record(z.string(), z.string().trim().min(1)).optional().default({}),\n connections: z.record(z.string(), connectionSchema).optional().default({}),\n}).strict();\n\nexport type ProjectActionConfiguration = z.infer<typeof configSchema>;\n\nexport type ResolvedProjectActionRuntime = {\n environment: Record<string, string>;\n connections: Record<string, unknown>;\n};\n\nexport async function loadProjectActionConfiguration(\n projectRoot: string,\n): Promise<ProjectActionConfiguration> {\n const resolvedRoot = path.resolve(projectRoot);\n const configPath = path.join(resolvedRoot, PROJECT_ACTION_CONFIG_PATH);\n const raw = await fs.readFile(configPath, \"utf8\").catch((error: NodeJS.ErrnoException) => {\n if (error.code === \"ENOENT\") return null;\n throw error;\n });\n if (raw === null) return configSchema.parse({});\n let value: unknown;\n try {\n value = JSON.parse(raw);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n throw new Error(`${PROJECT_ACTION_CONFIG_PATH} is not valid JSON: ${message}`);\n }\n return configSchema.parse(value);\n}\n\nexport function resolveProjectActionRuntime(\n config: ProjectActionConfiguration,\n hostEnvironment: NodeJS.ProcessEnv = process.env,\n): ResolvedProjectActionRuntime {\n const environment: Record<string, string> = {};\n for (const [runtimeName, hostName] of Object.entries(config.environment)) {\n const value = hostEnvironment[hostName];\n if (value !== undefined) environment[runtimeName] = value;\n }\n const connections: Record<string, unknown> = {};\n for (const [name, descriptor] of Object.entries(config.connections)) {\n const value: Record<string, unknown> = { ...descriptor.values };\n for (const [property, hostName] of Object.entries(descriptor.environment)) {\n const environmentValue = hostEnvironment[hostName];\n if (environmentValue !== undefined) value[property] = environmentValue;\n }\n connections[name] = value;\n }\n return { environment, connections };\n}\n"],
|
|
5
|
+
"mappings": ";AAIA,SAAS,SAAS;AAElB,IAAM,YAAY;AAEX,SAAS,aACd,IACA,SAC0C;AAC1C,QAAM,eAAe,GAAG,KAAK;AAC7B,MAAI,CAAC,UAAU,KAAK,YAAY,KAAK,aAAa,SAAS,KAAK;AAC9D,UAAM,IAAI;AAAA,MACR,6BAA6B,KAAK,UAAU,EAAE,CAAC;AAAA,IACjD;AAAA,EACF;AACA,QAAM,cAAc,QAAQ,YAAY,KAAK;AAC7C,MAAI,CAAC,YAAa,OAAM,IAAI,MAAM,kBAAkB,YAAY,0BAA0B;AAC1F,MAAI,YAAY,SAAS,IAAO,OAAM,IAAI,MAAM,kBAAkB,YAAY,+CAA+C;AAC7H,MAAI,EAAE,QAAQ,iBAAiB,EAAE,UAAU;AACzC,UAAM,IAAI,MAAM,kBAAkB,YAAY,8BAA8B;AAAA,EAC9E;AACA,MAAI,EAAE,QAAQ,kBAAkB,EAAE,UAAU;AAC1C,UAAM,IAAI,MAAM,kBAAkB,YAAY,+B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IAAI;AAAA,EACtD;AACA,QAAM,cAAuC,CAAC;AAC9C,aAAW,CAAC,MAAM,UAAU,KAAK,OAAO,QAAQ,OAAO,WAAW,GAAG;AACnE,UAAM,QAAiC,EAAE,GAAG,WAAW,OAAO;AAC9D,eAAW,CAAC,UAAU,QAAQ,KAAK,OAAO,QAAQ,WAAW,WAAW,GAAG;AACzE,YAAM,mBAAmB,gBAAgB,QAAQ;AACjD,UAAI,qBAAqB,OAAW,OAAM,QAAQ,IAAI;AAAA,IACxD;AACA,gBAAY,IAAI,IAAI;AAAA,EACtB;AACA,SAAO,EAAE,aAAa,YAAY;AACpC;",
|
|
6
|
+
"names": ["z"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import {
|
|
2
|
+
apiFetch,
|
|
3
|
+
readApiJson
|
|
4
|
+
} from "./chunk-APHPXQEA.js";
|
|
5
|
+
|
|
6
|
+
// src/profile-actions.ts
|
|
7
|
+
var OpenPondProfileActionsClient = class {
|
|
8
|
+
#apiKey;
|
|
9
|
+
#apiBaseUrl;
|
|
10
|
+
constructor(input) {
|
|
11
|
+
this.#apiKey = input.apiKey;
|
|
12
|
+
this.#apiBaseUrl = input.apiBaseUrl.replace(/\/+$/, "");
|
|
13
|
+
}
|
|
14
|
+
async catalog(input) {
|
|
15
|
+
const teamId = requiredValue(input.teamId, "teamId");
|
|
16
|
+
const search = new URLSearchParams({ teamId });
|
|
17
|
+
if (input.profileId?.trim()) search.set("profileId", input.profileId.trim());
|
|
18
|
+
if (input.profileName?.trim()) {
|
|
19
|
+
search.set("profileName", input.profileName.trim());
|
|
20
|
+
}
|
|
21
|
+
const response = await apiFetch(
|
|
22
|
+
this.#apiBaseUrl,
|
|
23
|
+
this.#apiKey,
|
|
24
|
+
`/v1/profile/actions?${search.toString()}`
|
|
25
|
+
);
|
|
26
|
+
return (await readApiJson(
|
|
27
|
+
response,
|
|
28
|
+
"Get Profile Action catalog"
|
|
29
|
+
)).catalog;
|
|
30
|
+
}
|
|
31
|
+
async run(input) {
|
|
32
|
+
const teamId = requiredValue(input.teamId, "teamId");
|
|
33
|
+
const actionKey = requiredValue(input.actionKey, "actionKey");
|
|
34
|
+
const idempotencyKey = requiredValue(input.idempotencyKey, "idempotencyKey");
|
|
35
|
+
const catalogVersion = requiredValue(input.catalogVersion, "catalogVersion");
|
|
36
|
+
const response = await apiFetch(
|
|
37
|
+
this.#apiBaseUrl,
|
|
38
|
+
this.#apiKey,
|
|
39
|
+
`/v1/profile/actions/run?${new URLSearchParams({ teamId }).toString()}`,
|
|
40
|
+
{
|
|
41
|
+
method: "POST",
|
|
42
|
+
headers: { "Content-Type": "application/json" },
|
|
43
|
+
body: JSON.stringify({
|
|
44
|
+
...input.profileId?.trim() ? { profileId: input.profileId.trim() } : {},
|
|
45
|
+
...input.profileName?.trim() ? { profileName: input.profileName.trim() } : {},
|
|
46
|
+
actionKey,
|
|
47
|
+
value: input.value ?? {},
|
|
48
|
+
conversationId: input.conversationId ?? null,
|
|
49
|
+
createConversation: input.createConversation,
|
|
50
|
+
conversationTitle: input.conversationTitle ?? null,
|
|
51
|
+
idempotencyKey,
|
|
52
|
+
catalogVersion,
|
|
53
|
+
externalCapabilityLeases: input.externalCapabilityLeases
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
return readApiJson(
|
|
58
|
+
response,
|
|
59
|
+
"Run Profile Action"
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
function requiredValue(value, name) {
|
|
64
|
+
const normalized = value.trim();
|
|
65
|
+
if (!normalized) throw new Error(`${name} is required`);
|
|
66
|
+
return normalized;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export {
|
|
70
|
+
OpenPondProfileActionsClient
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=chunk-QLEJOCQX.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/profile-actions.ts"],
|
|
4
|
+
"sourcesContent": ["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": ";;;;;;AAgEO,IAAM,+BAAN,MAAm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AAE,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
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// src/model-taskset-authoring-contracts.ts
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { LearningRevisionRefSchema } from "@openpond/evals/learning";
|
|
4
|
+
var IdSchema = LearningRevisionRefSchema.shape.id;
|
|
5
|
+
var HashSchema = z.string().regex(/^[a-f0-9]{64}$/);
|
|
6
|
+
var ModelTasksetAuthoringOwnerSchema = z.object({ scopeId: IdSchema, modelId: IdSchema }).strict();
|
|
7
|
+
var ModelTasksetAuthoringSchema = z.object({
|
|
8
|
+
schemaVersion: z.literal("openpond.modelTasksetAuthoring.v1"),
|
|
9
|
+
owner: ModelTasksetAuthoringOwnerSchema,
|
|
10
|
+
root: LearningRevisionRefSchema,
|
|
11
|
+
parent: LearningRevisionRefSchema
|
|
12
|
+
}).strict();
|
|
13
|
+
var ModelTasksetDraftRequestSchema = z.object({
|
|
14
|
+
schemaVersion: z.literal("openpond.modelTasksetDraftRequest.v1"),
|
|
15
|
+
operationId: IdSchema,
|
|
16
|
+
modelId: IdSchema,
|
|
17
|
+
expectedModelRevision: z.number().int().positive(),
|
|
18
|
+
sourcePackageHash: HashSchema
|
|
19
|
+
}).strict();
|
|
20
|
+
var ModelTasksetDraftPreparationSchema = z.object({
|
|
21
|
+
schemaVersion: z.literal("openpond.modelTasksetDraftPreparation.v1"),
|
|
22
|
+
draftId: IdSchema,
|
|
23
|
+
requestHash: HashSchema,
|
|
24
|
+
sourcePackageHash: HashSchema,
|
|
25
|
+
sourceTasksetRef: LearningRevisionRefSchema,
|
|
26
|
+
tasksetId: IdSchema,
|
|
27
|
+
tasksetRevision: z.number().int().positive(),
|
|
28
|
+
lineage: ModelTasksetAuthoringSchema
|
|
29
|
+
}).strict();
|
|
30
|
+
var TasksetDraftFilePathSchema = z.string().min(1).max(1024).refine((value) => !value.includes("\\") && !value.includes(":") && !value.includes("\0") && !value.startsWith("/") && !value.split("/").some((part) => !part || part === "." || part === ".." || part.startsWith(".env")), "Use a relative Taskset file path without environment files.");
|
|
31
|
+
var TasksetDraftFileInfoSchema = z.object({
|
|
32
|
+
path: TasksetDraftFilePathSchema,
|
|
33
|
+
sizeBytes: z.number().int().nonnegative(),
|
|
34
|
+
writable: z.boolean()
|
|
35
|
+
}).strict();
|
|
36
|
+
var TasksetDraftFileContentSchema = z.object({ encoding: z.enum(["utf8", "base64"]), data: z.string().max(8e6) }).strict();
|
|
37
|
+
var TasksetDraftFileSchema = TasksetDraftFileInfoSchema.extend({ contentHash: HashSchema, content: TasksetDraftFileContentSchema }).strict();
|
|
38
|
+
var TasksetDraftFileMutationSchema = z.object({
|
|
39
|
+
draftId: IdSchema,
|
|
40
|
+
expectedDraftRevision: z.number().int().positive(),
|
|
41
|
+
path: TasksetDraftFilePathSchema,
|
|
42
|
+
expectedFileHash: HashSchema.nullable(),
|
|
43
|
+
content: TasksetDraftFileContentSchema.nullable()
|
|
44
|
+
}).strict();
|
|
45
|
+
|
|
46
|
+
export {
|
|
47
|
+
ModelTasksetAuthoringOwnerSchema,
|
|
48
|
+
ModelTasksetAuthoringSchema,
|
|
49
|
+
ModelTasksetDraftRequestSchema,
|
|
50
|
+
ModelTasksetDraftPreparationSchema,
|
|
51
|
+
TasksetDraftFilePathSchema,
|
|
52
|
+
TasksetDraftFileInfoSchema,
|
|
53
|
+
TasksetDraftFileContentSchema,
|
|
54
|
+
TasksetDraftFileSchema,
|
|
55
|
+
TasksetDraftFileMutationSchema
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=chunk-S7I45WJQ.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/model-taskset-authoring-contracts.ts"],
|
|
4
|
+
"sourcesContent": ["import { z } from \"zod\";\nimport { LearningRevisionRefSchema } from \"@openpond/evals/learning\";\n\nconst IdSchema = LearningRevisionRefSchema.shape.id;\nconst HashSchema = z.string().regex(/^[a-f0-9]{64}$/);\nexport const ModelTasksetAuthoringOwnerSchema = z.object({ scopeId: IdSchema, modelId: IdSchema }).strict();\n\n/** Ordinary authoring preserves its own lineage without inventing a Reward\n * binding or replacing an admitted learning graph. Hosts authorize the owner. */\nexport const ModelTasksetAuthoringSchema = z.object({\n schemaVersion: z.literal(\"openpond.modelTasksetAuthoring.v1\"),\n owner: ModelTasksetAuthoringOwnerSchema,\n root: LearningRevisionRefSchema,\n parent: LearningRevisionRefSchema,\n}).strict();\n\nexport const ModelTasksetDraftRequestSchema = z.object({\n schemaVersion: z.literal(\"openpond.modelTasksetDraftRequest.v1\"),\n operationId: IdSchema,\n modelId: IdSchema,\n expectedModelRevision: z.number().int().positive(),\n sourcePackageHash: HashSchema,\n}).strict();\nexport type ModelTasksetDraftRequest = z.infer<typeof ModelTasksetDraftRequestSchema>;\n\n/** Persist this preparation before materializing the editable workspace. */\nexport const ModelTasksetDraftPreparationSchema = z.object({\n schemaVersion: z.literal(\"openpond.modelTasksetDraftPreparation.v1\"),\n draftId: IdSchema,\n requestHash: HashSchema,\n sourcePackageHash: HashSchema,\n sourceTasksetRef: LearningRevisionRefSchema,\n tasksetId: IdSchema,\n tasksetRevision: z.number().int().positive(),\n lineage: ModelTasksetAuthoringSchema,\n}).strict();\nexport type ModelTasksetDraftPreparation = z.infer<typeof ModelTasksetDraftPreparationSchema>;\n\nexport const TasksetDraftFilePathSchema = z.string().min(1).max(1024).refine(value =>\n !value.includes(\"\\\\\") && !value.includes(\":\") && !value.includes(\"\\0\") && !value.startsWith(\"/\")\n && !value.split(\"/\").some(part => !part || part === \".\" || part === \"..\" || part.startsWith(\".env\")), \"Use a relative Taskset file path without environment files.\");\nexport const TasksetDraftFileInfoSchema = z.object({\n path: TasksetDraftFilePathSchema,\n sizeBytes: z.number().int().nonnegative(),\n writable: z.boolean(),\n}).strict();\nexport const TasksetDraftFileContentSchema = z.object({ encoding: z.enum([\"utf8\", \"base64\"]), data: z.string().max(8_000_000) }).strict();\nexport const TasksetDraftFileSchema = TasksetDraftFileInfoSchema.extend({ contentHash: HashSchema, content: TasksetDraftFileContentSchema }).strict();\nexport const TasksetDraftFileMutationSchema = z.object({\n draftId: IdSchema,\n expectedDraftRevision: z.number().int().positive(),\n path: TasksetDraftFilePathSchema,\n expectedFileHash: HashSchema.nullable(),\n content: TasksetDraftFileContentSchema.nullable(),\n}).strict();\nexport type TasksetDraftFileInfo = z.infer<typeof TasksetDraftFileInfoSchema>;\nexport type TasksetDraftFile = z.infer<typeof TasksetDraftFileSchema>;\nexport type TasksetDraftFileMutation = z.infer<typeof TasksetDraftFileMutationSchema>;\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,SAAS;AAClB,SAAS,iCAAiC;AAE1C,IAAM,WAAW,0BAA0B,MAAM;AACjD,IAAM,aAAa,EAAE,OAAO,EAAE,MAAM,gBAAgB;AAC7C,IAAM,mCAAmC,EAAE,OAAO,EAAE,SAAS,UAAU,SAAS,SAAS,CAAC,EAAE,OAAO;AAInG,IAAM,8BAA8B,EAAE,OAAO;AAAA,EAClD,eAAe,EAAE,QAAQ,mCAAmC;AAAA,EAC5D,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AACV,CAAC,EAAE,OAAO;AAEH,IAAM,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