@openpond/evals 0.7.1 → 0.7.3
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/JAVASCRIPT_ENVIRONMENTS.md +58 -0
- package/README.md +2 -0
- package/dist/javascript-environment-attempt.js +116 -0
- package/dist/javascript-environment-contract.js +37 -0
- package/dist/javascript-environment-node.js +7 -0
- package/dist/javascript-environment.js +132 -0
- package/dist/javascript-isolate-node.js +55 -0
- package/dist/javascript-isolate.js +67 -0
- package/dist/javascript-verifier-node.js +2 -52
- package/dist/javascript-verifier-worker-source.js +1 -1
- package/dist/javascript-verifier-worker.js +3 -3
- package/dist/javascript-verifier.js +5 -60
- package/dist/learning/authoring-service.js +49 -0
- package/dist/learning/authoring.js +37 -0
- package/dist/learning/index.js +1 -0
- package/dist/learning/operations.js +7 -3
- package/dist/learning/repository.js +2 -0
- package/dist/learning/service.js +12 -0
- package/dist/types/javascript-environment-attempt.d.ts +58 -0
- package/dist/types/javascript-environment-attempt.d.ts.map +1 -0
- package/dist/types/javascript-environment-contract.d.ts +82 -0
- package/dist/types/javascript-environment-contract.d.ts.map +1 -0
- package/dist/types/javascript-environment-node.d.ts +5 -0
- package/dist/types/javascript-environment-node.d.ts.map +1 -0
- package/dist/types/javascript-environment.d.ts +100 -0
- package/dist/types/javascript-environment.d.ts.map +1 -0
- package/dist/types/javascript-isolate-node.d.ts +4 -0
- package/dist/types/javascript-isolate-node.d.ts.map +1 -0
- package/dist/types/javascript-isolate.d.ts +14 -0
- package/dist/types/javascript-isolate.d.ts.map +1 -0
- package/dist/types/javascript-verifier-node.d.ts.map +1 -1
- package/dist/types/javascript-verifier.d.ts +2 -5
- package/dist/types/javascript-verifier.d.ts.map +1 -1
- package/dist/types/learning/authoring-service.d.ts +25 -0
- package/dist/types/learning/authoring-service.d.ts.map +1 -0
- package/dist/types/learning/authoring.d.ts +672 -0
- package/dist/types/learning/authoring.d.ts.map +1 -0
- package/dist/types/learning/index.d.ts +1 -0
- package/dist/types/learning/index.d.ts.map +1 -1
- package/dist/types/learning/operations.d.ts +557 -1
- package/dist/types/learning/operations.d.ts.map +1 -1
- package/dist/types/learning/repository.d.ts +192 -0
- package/dist/types/learning/repository.d.ts.map +1 -1
- package/dist/types/learning/service.d.ts.map +1 -1
- package/dist/types/learning/transport.d.ts +471 -2
- package/dist/types/learning/transport.d.ts.map +1 -1
- package/package.json +14 -1
- package/schemas/learning/v1/command-request.schema.json +757 -366
- package/schemas/learning/v1/draft.schema.json +562 -0
- package/schemas/learning/v1/read-request.schema.json +1 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { parentPort, workerData } from "node:worker_threads";
|
|
2
|
-
import {
|
|
2
|
+
import { executeJavaScriptIsolate } from "./javascript-isolate.js";
|
|
3
3
|
// Only this trusted host program runs in Node. Authored source is interpreter data.
|
|
4
4
|
if (!parentPort)
|
|
5
|
-
throw new Error("
|
|
6
|
-
void
|
|
5
|
+
throw new Error("JavaScript worker requires its execution owner.");
|
|
6
|
+
void executeJavaScriptIsolate(workerData).then((result) => parentPort.postMessage({ ok: true, result }), (error) => parentPort.postMessage({ ok: false, error: error instanceof Error ? error.message : "JavaScript execution failed." })).finally(() => parentPort.close());
|
|
@@ -1,64 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import variant from "@jitl/quickjs-singlefile-cjs-release-sync";
|
|
3
|
-
import { assertBoundedTaskJson } from "./task-schema.js";
|
|
1
|
+
import { executeJavaScriptIsolate } from "./javascript-isolate.js";
|
|
4
2
|
import { JavaScriptVerifierResultSchema } from "./javascript-verifier-contract.js";
|
|
5
3
|
export { JavaScriptVerifierResultSchema } from "./javascript-verifier-contract.js";
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* timers, or module loader. Hosts should run this on a worker to remain responsive
|
|
9
|
-
* and terminate that worker when cancellation is requested.
|
|
10
|
-
*/
|
|
4
|
+
/** A fresh interpreter with no filesystem, network, timers or module loader.
|
|
5
|
+
* Hosts should use the worker entrypoint for cancellation and responsiveness. */
|
|
11
6
|
export async function executeJavaScriptVerifier(input) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (new TextEncoder().encode(input.source).byteLength > 524_288)
|
|
15
|
-
throw new Error("verifier_source_too_large");
|
|
16
|
-
assertBoundedTaskJson(input.value, 4_194_304);
|
|
17
|
-
input.signal?.throwIfAborted();
|
|
18
|
-
const deadline = Date.now() + input.timeoutMs;
|
|
19
|
-
const module = await newQuickJSWASMModuleFromVariant(variant);
|
|
20
|
-
input.signal?.throwIfAborted();
|
|
21
|
-
return Scope.withScope((scope) => {
|
|
22
|
-
const runtime = scope.manage(module.newRuntime());
|
|
23
|
-
runtime.setMemoryLimit(33_554_432);
|
|
24
|
-
runtime.setMaxStackSize(262_144);
|
|
25
|
-
runtime.setInterruptHandler(() => Date.now() >= deadline || input.signal?.aborted === true);
|
|
26
|
-
const context = scope.manage(runtime.newContext());
|
|
27
|
-
const stringify = scope.manage(context.unwrapResult(context.evalCode("JSON.stringify")));
|
|
28
|
-
const argument = scope.manage(context.unwrapResult(context.evalCode(`JSON.parse(${JSON.stringify(JSON.stringify(input.value))})`)));
|
|
29
|
-
const exported = scope.manage(context.unwrapResult(context.evalCode(input.source, "verifier.mjs", { type: "module" })));
|
|
30
|
-
const namespace = scope.manage(settle(context, exported, deadline, input.signal));
|
|
31
|
-
const fn = scope.manage(context.getProp(namespace, input.exportName ?? "verify"));
|
|
32
|
-
if (context.typeof(fn) !== "function")
|
|
33
|
-
throw new Error("verifier_function_export_missing");
|
|
34
|
-
const returned = scope.manage(context.unwrapResult(context.callFunction(fn, context.undefined, argument)));
|
|
35
|
-
const result = scope.manage(settle(context, returned, deadline, input.signal));
|
|
36
|
-
const serialized = scope.manage(context.unwrapResult(context.callFunction(stringify, context.undefined, result)));
|
|
37
|
-
if (context.typeof(serialized) !== "string")
|
|
38
|
-
throw new Error("verifier_result_not_json");
|
|
39
|
-
const json = context.getString(serialized);
|
|
40
|
-
if (new TextEncoder().encode(json).byteLength > 65_536)
|
|
41
|
-
throw new Error("verifier_result_too_large");
|
|
42
|
-
input.signal?.throwIfAborted();
|
|
43
|
-
if (Date.now() >= deadline)
|
|
44
|
-
throw new Error("verifier_timeout");
|
|
45
|
-
const value = JSON.parse(json);
|
|
46
|
-
assertBoundedTaskJson(value, 65_536);
|
|
47
|
-
return JavaScriptVerifierResultSchema.parse(value);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
function settle(context, handle, deadline, signal) {
|
|
51
|
-
for (;;) {
|
|
52
|
-
signal?.throwIfAborted();
|
|
53
|
-
if (Date.now() >= deadline)
|
|
54
|
-
throw new Error("verifier_timeout");
|
|
55
|
-
const state = context.getPromiseState(handle);
|
|
56
|
-
if (state.type === "fulfilled")
|
|
57
|
-
return state.notAPromise ? state.value.dup() : state.value;
|
|
58
|
-
if (state.type === "rejected")
|
|
59
|
-
return context.unwrapResult(state);
|
|
60
|
-
const jobs = context.runtime.executePendingJobs(1);
|
|
61
|
-
if (jobs.unwrap() === 0)
|
|
62
|
-
throw new Error("verifier_unresolved_promise");
|
|
63
|
-
}
|
|
7
|
+
const result = await executeJavaScriptIsolate({ ...input, exportName: input.exportName ?? "verify", maxResultBytes: 65_536, errorPrefix: "verifier" });
|
|
8
|
+
return JavaScriptVerifierResultSchema.parse(result);
|
|
64
9
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { assertBoundedTaskJson } from "../task-schema.js";
|
|
2
|
+
import { AuthoringDraftSchema } from "./authoring.js";
|
|
3
|
+
import { LearningDomainError } from "./errors.js";
|
|
4
|
+
import { learningRef, sameLearningRef, sealLearningContent } from "./contracts.js";
|
|
5
|
+
import { requireLearningRelease } from "./repository.js";
|
|
6
|
+
export async function saveAuthoringDraft(tx, input, now) {
|
|
7
|
+
// A 100-record page remains below the common 16 MiB response limit.
|
|
8
|
+
assertBoundedTaskJson(input.draft, 131_072);
|
|
9
|
+
const previous = await tx.get("draft", input.draft.id);
|
|
10
|
+
if (previous && (previous.status !== "draft" || previous.targetId !== input.draft.targetId || previous.targetKind !== input.draft.targetKind || (previous.baseRelease === null ? input.draft.baseRelease !== null : input.draft.baseRelease === null || !sameLearningRef(previous.baseRelease, input.draft.baseRelease))))
|
|
11
|
+
throw new LearningDomainError("authoring_draft_identity_conflict", 409);
|
|
12
|
+
if (input.draft.baseRelease) {
|
|
13
|
+
if (input.draft.baseRelease.id !== input.draft.targetId)
|
|
14
|
+
throw new LearningDomainError("authoring_draft_base_mismatch", 422);
|
|
15
|
+
await requireLearningRelease(tx, input.draft.targetKind, input.draft.baseRelease);
|
|
16
|
+
}
|
|
17
|
+
const draft = AuthoringDraftSchema.parse(sealLearningContent({ ...input.draft, schemaVersion: "openpond.authoringDraft.v1", revision: input.expectedRevision + 1, status: "draft", publishedRelease: null, createdAt: previous?.createdAt ?? now, updatedAt: now }));
|
|
18
|
+
await tx.put("draft", draft, input.expectedRevision, { parentId: draft.targetKind, status: draft.status });
|
|
19
|
+
return { kind: "draft", id: draft.id, revision: draft.revision };
|
|
20
|
+
}
|
|
21
|
+
export async function archiveAuthoringDraft(tx, ref, now) {
|
|
22
|
+
const draft = await currentDraft(tx, ref);
|
|
23
|
+
const { contentHash: _hash, ...content } = draft;
|
|
24
|
+
const archived = AuthoringDraftSchema.parse(sealLearningContent({ ...content, revision: draft.revision + 1, status: "archived", updatedAt: now }));
|
|
25
|
+
await tx.put("draft", archived, draft.revision, { parentId: draft.targetKind, status: archived.status });
|
|
26
|
+
return { kind: "draft", id: archived.id, revision: archived.revision };
|
|
27
|
+
}
|
|
28
|
+
export async function finalizeAuthoringDraft(tx, input, published, now) {
|
|
29
|
+
const finalization = input.finalizeDraft;
|
|
30
|
+
if (!finalization)
|
|
31
|
+
return null;
|
|
32
|
+
const draft = await currentDraft(tx, finalization.draft);
|
|
33
|
+
if (draft.targetKind !== finalization.targetKind || draft.targetId !== finalization.release.id || finalization.release.revision !== (draft.baseRelease?.revision ?? 0) + 1 || !published.some(value => value.kind === finalization.targetKind && value.id === finalization.release.id && value.revision === finalization.release.revision))
|
|
34
|
+
throw new LearningDomainError("authoring_draft_publication_mismatch", 422);
|
|
35
|
+
await requireLearningRelease(tx, finalization.targetKind, finalization.release);
|
|
36
|
+
const { contentHash: _hash, ...content } = draft;
|
|
37
|
+
const completed = AuthoringDraftSchema.parse(sealLearningContent({ ...content, revision: draft.revision + 1, status: "published", publishedRelease: finalization.release, updatedAt: now }));
|
|
38
|
+
await tx.put("draft", completed, draft.revision, { parentId: draft.targetKind, status: completed.status });
|
|
39
|
+
return { kind: "draft", id: completed.id, revision: completed.revision };
|
|
40
|
+
}
|
|
41
|
+
async function currentDraft(tx, ref) {
|
|
42
|
+
const draft = await requireLearningRelease(tx, "draft", ref);
|
|
43
|
+
const current = await tx.get("draft", ref.id);
|
|
44
|
+
if (!current || !sameLearningRef(learningRef(current), ref))
|
|
45
|
+
throw new LearningDomainError("authoring_draft_revision_stale", 409);
|
|
46
|
+
if (draft.status !== "draft")
|
|
47
|
+
throw new LearningDomainError("authoring_draft_closed", 409);
|
|
48
|
+
return draft;
|
|
49
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ReleaseHashSchema, ReleaseIdSchema, ReleaseTimestampSchema } from "@openpond/harness";
|
|
3
|
+
import { RewardBindingSourceSchema, RewardReleaseRefSchema } from "../rewards.js";
|
|
4
|
+
import { LearningRevisionRefSchema } from "./contracts.js";
|
|
5
|
+
/** Strings intentionally preserve incomplete JSON/code until explicit publication. */
|
|
6
|
+
export const RewardAuthoringFieldsSchema = z.object({
|
|
7
|
+
name: z.string().max(500), description: z.string().max(10_000),
|
|
8
|
+
kind: z.enum(["custom_verifier", "state", "content", "schema", "artifact", "runtime_event", "model_judge", "learned_model", "human"]),
|
|
9
|
+
fields: z.string(), outputField: z.string(), expectedField: z.string(), expectedValue: z.string(),
|
|
10
|
+
schema: z.string(), reference: z.string(), events: z.string(), code: z.string(), exportName: z.string(), timeout: z.string(),
|
|
11
|
+
rubric: z.string(), providerId: z.string(), modelId: z.string(), modelRevision: z.string(), temperature: z.string(),
|
|
12
|
+
reviewerRole: z.string(), learnedId: z.string(), learnedHash: z.string(), inputContract: z.string(), minimum: z.string(), maximum: z.string(),
|
|
13
|
+
}).strict();
|
|
14
|
+
export const TaskFormatAuthoringFieldsSchema = z.object({
|
|
15
|
+
name: z.string().max(500), description: z.string().max(10_000), instructions: z.string().max(20_000),
|
|
16
|
+
input: z.string(), output: z.string(), familyNamespace: z.string(),
|
|
17
|
+
sources: z.array(RewardBindingSourceSchema).max(100), recipeRef: RewardReleaseRefSchema.optional(),
|
|
18
|
+
}).strict();
|
|
19
|
+
export const CombinedRewardAuthoringFieldsSchema = z.object({
|
|
20
|
+
name: z.string().max(500), description: z.string().max(10_000), sources: z.array(RewardBindingSourceSchema).max(100),
|
|
21
|
+
}).strict();
|
|
22
|
+
export const AuthoringTargetKindSchema = z.enum(["definition", "reward", "binding"]);
|
|
23
|
+
const base = z.object({ id: ReleaseIdSchema, targetId: ReleaseIdSchema, baseRelease: LearningRevisionRefSchema.nullable(), editorVersion: z.literal("openpond.modelsEditor.v1") });
|
|
24
|
+
export const AuthoringDraftInputSchema = z.discriminatedUnion("targetKind", [
|
|
25
|
+
base.extend({ targetKind: z.literal("definition"), fields: TaskFormatAuthoringFieldsSchema }).strict(),
|
|
26
|
+
base.extend({ targetKind: z.literal("reward"), fields: RewardAuthoringFieldsSchema }).strict(),
|
|
27
|
+
base.extend({ targetKind: z.literal("binding"), fields: CombinedRewardAuthoringFieldsSchema }).strict(),
|
|
28
|
+
]);
|
|
29
|
+
const history = {
|
|
30
|
+
schemaVersion: z.literal("openpond.authoringDraft.v1"), revision: z.number().int().positive(),
|
|
31
|
+
status: z.enum(["draft", "archived", "published"]), publishedRelease: LearningRevisionRefSchema.nullable(),
|
|
32
|
+
createdAt: ReleaseTimestampSchema, updatedAt: ReleaseTimestampSchema,
|
|
33
|
+
};
|
|
34
|
+
export const AuthoringDraftContentSchema = z.discriminatedUnion("targetKind", [AuthoringDraftInputSchema.options[0].extend(history).strict(), AuthoringDraftInputSchema.options[1].extend(history).strict(), AuthoringDraftInputSchema.options[2].extend(history).strict()]);
|
|
35
|
+
export const AuthoringDraftSchema = z.discriminatedUnion("targetKind", [AuthoringDraftContentSchema.options[0].extend({ contentHash: ReleaseHashSchema }).strict(), AuthoringDraftContentSchema.options[1].extend({ contentHash: ReleaseHashSchema }).strict(), AuthoringDraftContentSchema.options[2].extend({ contentHash: ReleaseHashSchema }).strict()]);
|
|
36
|
+
/** Exact draft and resulting release are finalized in the publication transaction. */
|
|
37
|
+
export const AuthoringDraftFinalizationSchema = z.object({ draft: LearningRevisionRefSchema, targetKind: AuthoringTargetKindSchema, release: LearningRevisionRefSchema }).strict();
|
package/dist/learning/index.js
CHANGED
|
@@ -2,9 +2,10 @@ import { z } from "zod";
|
|
|
2
2
|
import { ReleaseIdSchema } from "@openpond/harness";
|
|
3
3
|
import { LearningJsonObjectSchema, LearningRevisionRefSchema, LearningSourceContentSchema, TaskDefinitionContentSchema, TaskExampleSubmissionSchema, TaskFeedbackSubmissionSchema, LearningPolicyContentSchema } from "./contracts.js";
|
|
4
4
|
import { RewardBindingContentSchema, RewardReleaseContentSchema } from "../rewards.js";
|
|
5
|
+
import { AuthoringDraftInputSchema, AuthoringDraftFinalizationSchema } from "./authoring.js";
|
|
5
6
|
import { LearningTextAssetContentSchema } from "./assets.js";
|
|
6
7
|
const command = z.object({ operationId: ReleaseIdSchema });
|
|
7
|
-
const publish = command.extend({ action: z.literal("publish"), expectedRevision: z.number().int().nonnegative() });
|
|
8
|
+
const publish = command.extend({ action: z.literal("publish"), expectedRevision: z.number().int().nonnegative(), finalizeDraft: AuthoringDraftFinalizationSchema.optional() });
|
|
8
9
|
export const PublishLearningResourceCommandSchema = z.discriminatedUnion("kind", [
|
|
9
10
|
publish.extend({ kind: z.literal("asset"), content: LearningTextAssetContentSchema }).strict(),
|
|
10
11
|
publish.extend({ kind: z.literal("definition"), content: TaskDefinitionContentSchema }).strict(),
|
|
@@ -15,7 +16,8 @@ export const PublishLearningResourceCommandSchema = z.discriminatedUnion("kind",
|
|
|
15
16
|
]);
|
|
16
17
|
export const PublishLearningResourcesCommandSchema = command.extend({
|
|
17
18
|
action: z.literal("publish_resources"),
|
|
18
|
-
|
|
19
|
+
finalizeDraft: AuthoringDraftFinalizationSchema.optional(),
|
|
20
|
+
resources: z.array(z.union(PublishLearningResourceCommandSchema.options.map((schema) => schema.omit({ operationId: true, action: true, finalizeDraft: true })))).min(1).max(20),
|
|
19
21
|
}).strict();
|
|
20
22
|
export const SubmitTaskExampleCommandSchema = command.extend({ action: z.literal("submit_example"), example: TaskExampleSubmissionSchema }).strict();
|
|
21
23
|
export const SubmitTaskFeedbackCommandSchema = command.extend({ action: z.literal("submit_feedback"), feedback: TaskFeedbackSubmissionSchema }).strict();
|
|
@@ -30,4 +32,6 @@ export const ReviewTaskEvidenceCommandSchema = command.extend({
|
|
|
30
32
|
}).strict();
|
|
31
33
|
export const SealTaskBatchCommandSchema = command.extend({ action: z.literal("seal_batch"), batchId: ReleaseIdSchema, taskDefinition: LearningRevisionRefSchema, purpose: z.enum(["supervised_training", "reward_training", "evaluation"]), evidence: z.array(LearningRevisionRefSchema).min(1).max(10_000), decisions: z.array(LearningRevisionRefSchema).min(1).max(10_000) }).strict();
|
|
32
34
|
export const CancelTaskGradeCommandSchema = command.extend({ action: z.literal("cancel_grade"), gradeId: ReleaseIdSchema, expectedRevision: z.number().int().positive() }).strict();
|
|
33
|
-
export const
|
|
35
|
+
export const SaveAuthoringDraftCommandSchema = command.extend({ action: z.literal("save_draft"), expectedRevision: z.number().int().nonnegative(), draft: AuthoringDraftInputSchema }).strict();
|
|
36
|
+
export const ArchiveAuthoringDraftCommandSchema = command.extend({ action: z.literal("archive_draft"), draft: LearningRevisionRefSchema }).strict();
|
|
37
|
+
export const LearningCommandSchema = z.union([SaveAuthoringDraftCommandSchema, ArchiveAuthoringDraftCommandSchema, PublishLearningResourceCommandSchema, PublishLearningResourcesCommandSchema, SubmitTaskExampleCommandSchema, SubmitTaskFeedbackCommandSchema, ApplyTaskCorrectionCommandSchema, ResolveTaskFeedbackCommandSchema, QueueTaskGradeCommandSchema, ReviewTaskEvidenceCommandSchema, SealTaskBatchCommandSchema, CancelTaskGradeCommandSchema]);
|
|
@@ -4,8 +4,10 @@ import { assertLearningContentHash, LearningSourceSchema, TaskAdmissionDecisionS
|
|
|
4
4
|
import { RewardBindingSchema, RewardReleaseSchema } from "../rewards.js";
|
|
5
5
|
import { TasksetReleaseSchema } from "../tasksets.js";
|
|
6
6
|
import { LearningDomainError } from "./errors.js";
|
|
7
|
+
import { AuthoringDraftSchema } from "./authoring.js";
|
|
7
8
|
import { LearningTextAssetSchema } from "./assets.js";
|
|
8
9
|
export const learningResourceSchemas = {
|
|
10
|
+
draft: AuthoringDraftSchema,
|
|
9
11
|
asset: LearningTextAssetSchema,
|
|
10
12
|
definition: TaskDefinitionSchema, reward: RewardReleaseSchema, binding: RewardBindingSchema,
|
|
11
13
|
source: LearningSourceSchema, evidence: TaskEvidenceSchema, feedback: TaskFeedbackSchema,
|
package/dist/learning/service.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { saveAuthoringDraft, archiveAuthoringDraft, finalizeAuthoringDraft } from "./authoring-service.js";
|
|
1
2
|
import { LearningDomainError } from "./errors.js";
|
|
2
3
|
import { contentHash } from "@openpond/harness";
|
|
3
4
|
import { createRewardBinding, createRewardRelease, resolveBoundRewards } from "../rewards.js";
|
|
@@ -27,6 +28,12 @@ export function createLearningService(repository, options = {}) {
|
|
|
27
28
|
}
|
|
28
29
|
let pointers;
|
|
29
30
|
switch (input.action) {
|
|
31
|
+
case "save_draft":
|
|
32
|
+
pointers = [await saveAuthoringDraft(transaction, input, now())];
|
|
33
|
+
break;
|
|
34
|
+
case "archive_draft":
|
|
35
|
+
pointers = [await archiveAuthoringDraft(transaction, input.draft, now())];
|
|
36
|
+
break;
|
|
30
37
|
case "publish":
|
|
31
38
|
pointers = [await publish(transaction, input)];
|
|
32
39
|
break;
|
|
@@ -61,6 +68,11 @@ export function createLearningService(repository, options = {}) {
|
|
|
61
68
|
pointers = await seal(transaction, input, context.actor.id);
|
|
62
69
|
break;
|
|
63
70
|
}
|
|
71
|
+
if (input.action === "publish" || input.action === "publish_resources") {
|
|
72
|
+
const finalized = await finalizeAuthoringDraft(transaction, input, pointers, now());
|
|
73
|
+
if (finalized)
|
|
74
|
+
pointers.push(finalized);
|
|
75
|
+
}
|
|
64
76
|
await transaction.saveOperation(operationId, { requestHash, resources: pointers });
|
|
65
77
|
return { operationId: input.operationId, resources: await Promise.all(pointers.map((pointer) => requireLearningResource(transaction, pointer.kind, pointer.id, pointer.revision))) };
|
|
66
78
|
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type ToolDeclaration } from "@openpond/harness";
|
|
3
|
+
import { createJavaScriptEnvironmentSession, type JavaScriptEnvironmentSnapshot } from "./javascript-environment.js";
|
|
4
|
+
declare const ToolCallSchema: z.ZodObject<{
|
|
5
|
+
id: z.ZodString;
|
|
6
|
+
name: z.ZodString;
|
|
7
|
+
arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
8
|
+
}, z.core.$strict>;
|
|
9
|
+
declare const PolicyTurnSchema: z.ZodObject<{
|
|
10
|
+
text: z.ZodString;
|
|
11
|
+
toolCalls: z.ZodArray<z.ZodObject<{
|
|
12
|
+
id: z.ZodString;
|
|
13
|
+
name: z.ZodString;
|
|
14
|
+
arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
15
|
+
}, z.core.$strict>>;
|
|
16
|
+
}, z.core.$strict>;
|
|
17
|
+
export type JavaScriptEnvironmentToolCall = z.infer<typeof ToolCallSchema>;
|
|
18
|
+
export type JavaScriptEnvironmentPolicyTurn = z.infer<typeof PolicyTurnSchema>;
|
|
19
|
+
export type JavaScriptEnvironmentPolicyMessage = {
|
|
20
|
+
role: "system" | "user";
|
|
21
|
+
text: string;
|
|
22
|
+
} | {
|
|
23
|
+
role: "assistant";
|
|
24
|
+
text: string;
|
|
25
|
+
toolCalls: JavaScriptEnvironmentToolCall[];
|
|
26
|
+
} | {
|
|
27
|
+
role: "tool";
|
|
28
|
+
callId: string;
|
|
29
|
+
name: string;
|
|
30
|
+
observation: Record<string, unknown>;
|
|
31
|
+
};
|
|
32
|
+
export interface JavaScriptEnvironmentAttempt {
|
|
33
|
+
schemaVersion: "openpond.javascriptEnvironmentAttempt.v1";
|
|
34
|
+
taskId: string;
|
|
35
|
+
status: "completed" | "budget_exhausted" | "cancelled" | "timed_out" | "policy_failure" | "environment_failure";
|
|
36
|
+
output: string | null;
|
|
37
|
+
snapshot: JavaScriptEnvironmentSnapshot | null;
|
|
38
|
+
collected: boolean;
|
|
39
|
+
environmentCleanupComplete: boolean;
|
|
40
|
+
messages: JavaScriptEnvironmentPolicyMessage[];
|
|
41
|
+
error: string | null;
|
|
42
|
+
contentHash: string;
|
|
43
|
+
}
|
|
44
|
+
/** The policy receives observations, never source, initial state or evaluator
|
|
45
|
+
* targets. Its final text cannot replace state recorded by the environment.
|
|
46
|
+
* The policy adapter must honor signal and settle after its own cancellation. */
|
|
47
|
+
export declare function runJavaScriptEnvironmentAttempt(input: Parameters<typeof createJavaScriptEnvironmentSession>[0] & {
|
|
48
|
+
taskId: string;
|
|
49
|
+
instructions: string;
|
|
50
|
+
timeoutMs: number;
|
|
51
|
+
policy: (input: {
|
|
52
|
+
messages: JavaScriptEnvironmentPolicyMessage[];
|
|
53
|
+
tools: ToolDeclaration[];
|
|
54
|
+
signal: AbortSignal;
|
|
55
|
+
}) => Promise<JavaScriptEnvironmentPolicyTurn>;
|
|
56
|
+
}): Promise<JavaScriptEnvironmentAttempt>;
|
|
57
|
+
export {};
|
|
58
|
+
//# sourceMappingURL=javascript-environment-attempt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"javascript-environment-attempt.d.ts","sourceRoot":"","sources":["../../../../src/javascript-environment-attempt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,KAAK,eAAe,EAAe,MAAM,mBAAmB,CAAC;AAEtE,OAAO,EAAE,kCAAkC,EAAoC,KAAK,6BAA6B,EAAE,MAAM,6BAA6B,CAAC;AAEvJ,QAAA,MAAM,cAAc;;;;kBAAuI,CAAC;AAC5J,QAAA,MAAM,gBAAgB;;;;;;;kBAAoG,CAAC;AAC3H,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAC3E,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC/E,MAAM,MAAM,kCAAkC,GAC1C;IAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACzC;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,6BAA6B,EAAE,CAAA;CAAE,GAC/E;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,CAAC;AAEzF,MAAM,WAAW,4BAA4B;IAC3C,aAAa,EAAE,0CAA0C,CAAC;IAC1D,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,WAAW,GAAG,kBAAkB,GAAG,WAAW,GAAG,WAAW,GAAG,gBAAgB,GAAG,qBAAqB,CAAC;IAChH,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,EAAE,6BAA6B,GAAG,IAAI,CAAC;IAC/C,SAAS,EAAE,OAAO,CAAC;IACnB,0BAA0B,EAAE,OAAO,CAAC;IACpC,QAAQ,EAAE,kCAAkC,EAAE,CAAC;IAC/C,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;iFAEiF;AACjF,wBAAsB,+BAA+B,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,kCAAkC,CAAC,CAAC,CAAC,CAAC,GAAG;IACtH,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,CAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,kCAAkC,EAAE,CAAC;QAAC,KAAK,EAAE,eAAe,EAAE,CAAC;QAAC,MAAM,EAAE,WAAW,CAAA;KAAE,KAAK,OAAO,CAAC,+BAA+B,CAAC,CAAC;CAChK,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAiFxC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const JavaScriptEnvironmentDefinitionContentSchema: z.ZodObject<{
|
|
3
|
+
schemaVersion: z.ZodLiteral<"openpond.javascriptEnvironment.v1">;
|
|
4
|
+
id: z.ZodString;
|
|
5
|
+
revision: z.ZodNumber;
|
|
6
|
+
module: z.ZodObject<{
|
|
7
|
+
id: z.ZodString;
|
|
8
|
+
path: z.ZodString;
|
|
9
|
+
contentHash: z.ZodString;
|
|
10
|
+
sizeBytes: z.ZodNumber;
|
|
11
|
+
mediaType: z.ZodString;
|
|
12
|
+
visibility: z.ZodEnum<{
|
|
13
|
+
policy: "policy";
|
|
14
|
+
verifier: "verifier";
|
|
15
|
+
host_private: "host_private";
|
|
16
|
+
}>;
|
|
17
|
+
}, z.core.$strict>;
|
|
18
|
+
tools: z.ZodArray<z.ZodObject<{
|
|
19
|
+
name: z.ZodString;
|
|
20
|
+
description: z.ZodString;
|
|
21
|
+
inputSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
22
|
+
inputSchemaHash: z.ZodString;
|
|
23
|
+
sideEffect: z.ZodEnum<{
|
|
24
|
+
read: "read";
|
|
25
|
+
write: "write";
|
|
26
|
+
}>;
|
|
27
|
+
timeoutMs: z.ZodNumber;
|
|
28
|
+
}, z.core.$strict>>;
|
|
29
|
+
maxSteps: z.ZodNumber;
|
|
30
|
+
maxStateBytes: z.ZodNumber;
|
|
31
|
+
maxObservationBytes: z.ZodNumber;
|
|
32
|
+
operationTimeoutMs: z.ZodNumber;
|
|
33
|
+
}, z.core.$strict>;
|
|
34
|
+
export declare const JavaScriptEnvironmentDefinitionSchema: z.ZodObject<{
|
|
35
|
+
schemaVersion: z.ZodLiteral<"openpond.javascriptEnvironment.v1">;
|
|
36
|
+
id: z.ZodString;
|
|
37
|
+
revision: z.ZodNumber;
|
|
38
|
+
module: z.ZodObject<{
|
|
39
|
+
id: z.ZodString;
|
|
40
|
+
path: z.ZodString;
|
|
41
|
+
contentHash: z.ZodString;
|
|
42
|
+
sizeBytes: z.ZodNumber;
|
|
43
|
+
mediaType: z.ZodString;
|
|
44
|
+
visibility: z.ZodEnum<{
|
|
45
|
+
policy: "policy";
|
|
46
|
+
verifier: "verifier";
|
|
47
|
+
host_private: "host_private";
|
|
48
|
+
}>;
|
|
49
|
+
}, z.core.$strict>;
|
|
50
|
+
tools: z.ZodArray<z.ZodObject<{
|
|
51
|
+
name: z.ZodString;
|
|
52
|
+
description: z.ZodString;
|
|
53
|
+
inputSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
54
|
+
inputSchemaHash: z.ZodString;
|
|
55
|
+
sideEffect: z.ZodEnum<{
|
|
56
|
+
read: "read";
|
|
57
|
+
write: "write";
|
|
58
|
+
}>;
|
|
59
|
+
timeoutMs: z.ZodNumber;
|
|
60
|
+
}, z.core.$strict>>;
|
|
61
|
+
maxSteps: z.ZodNumber;
|
|
62
|
+
maxStateBytes: z.ZodNumber;
|
|
63
|
+
maxObservationBytes: z.ZodNumber;
|
|
64
|
+
operationTimeoutMs: z.ZodNumber;
|
|
65
|
+
contentHash: z.ZodString;
|
|
66
|
+
}, z.core.$strict>;
|
|
67
|
+
export type JavaScriptEnvironmentDefinition = z.infer<typeof JavaScriptEnvironmentDefinitionSchema>;
|
|
68
|
+
export declare const JavaScriptEnvironmentOperationSchema: z.ZodEnum<{
|
|
69
|
+
create: "create";
|
|
70
|
+
reset: "reset";
|
|
71
|
+
step: "step";
|
|
72
|
+
collect: "collect";
|
|
73
|
+
destroy: "destroy";
|
|
74
|
+
}>;
|
|
75
|
+
export declare const JavaScriptEnvironmentResultSchema: z.ZodObject<{
|
|
76
|
+
state: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
77
|
+
observation: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
78
|
+
}, z.core.$strict>;
|
|
79
|
+
export type JavaScriptEnvironmentResult = z.infer<typeof JavaScriptEnvironmentResultSchema>;
|
|
80
|
+
export type JavaScriptEnvironmentOperation = z.infer<typeof JavaScriptEnvironmentOperationSchema>;
|
|
81
|
+
export declare function assertJavaScriptEnvironmentDefinition(value: unknown): JavaScriptEnvironmentDefinition;
|
|
82
|
+
//# sourceMappingURL=javascript-environment-contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"javascript-environment-contract.d.ts","sourceRoot":"","sources":["../../../../src/javascript-environment-contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,4CAA4C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAgBvD,CAAC;AACH,eAAO,MAAM,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAA+G,CAAC;AAClK,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qCAAqC,CAAC,CAAC;AAEpG,eAAO,MAAM,oCAAoC;;;;;;EAA4D,CAAC;AAC9G,eAAO,MAAM,iCAAiC;;;kBAGnC,CAAC;AACZ,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAC;AAC5F,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oCAAoC,CAAC,CAAC;AAElG,wBAAgB,qCAAqC,CAAC,KAAK,EAAE,OAAO,GAAG,+BAA+B,CAMrG"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { JavaScriptEnvironmentExecutionInput } from "./javascript-environment.js";
|
|
2
|
+
import { type JavaScriptEnvironmentResult } from "./javascript-environment-contract.js";
|
|
3
|
+
/** The execution owner awaits termination before recording a step or cleanup. */
|
|
4
|
+
export declare function executeJavaScriptEnvironmentInWorker(input: JavaScriptEnvironmentExecutionInput): Promise<JavaScriptEnvironmentResult>;
|
|
5
|
+
//# sourceMappingURL=javascript-environment-node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"javascript-environment-node.d.ts","sourceRoot":"","sources":["../../../../src/javascript-environment-node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,6BAA6B,CAAC;AACvF,OAAO,EAA2E,KAAK,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AAGjK,iFAAiF;AACjF,wBAAsB,oCAAoC,CAAC,KAAK,EAAE,mCAAmC,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAG3I"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { type LearningTextAsset } from "./learning/assets.js";
|
|
2
|
+
import { type JavaScriptEnvironmentDefinition, type JavaScriptEnvironmentOperation, type JavaScriptEnvironmentResult } from "./javascript-environment-contract.js";
|
|
3
|
+
export * from "./javascript-environment-contract.js";
|
|
4
|
+
export interface JavaScriptEnvironmentExecutionInput {
|
|
5
|
+
source: string;
|
|
6
|
+
operation: JavaScriptEnvironmentOperation;
|
|
7
|
+
value: Record<string, unknown>;
|
|
8
|
+
timeoutMs: number;
|
|
9
|
+
signal?: AbortSignal;
|
|
10
|
+
}
|
|
11
|
+
/** Pure, bounded module execution. Server hosts should provide the worker runner. */
|
|
12
|
+
export declare function executeJavaScriptEnvironment(input: JavaScriptEnvironmentExecutionInput): Promise<JavaScriptEnvironmentResult>;
|
|
13
|
+
export interface JavaScriptEnvironmentEvent {
|
|
14
|
+
sequence: number;
|
|
15
|
+
operation: JavaScriptEnvironmentOperation;
|
|
16
|
+
toolName: string | null;
|
|
17
|
+
arguments: Record<string, unknown> | null;
|
|
18
|
+
observation: Record<string, unknown> | null;
|
|
19
|
+
beforeStateHash: string;
|
|
20
|
+
afterStateHash: string;
|
|
21
|
+
error: string | null;
|
|
22
|
+
}
|
|
23
|
+
export interface JavaScriptEnvironmentSnapshot {
|
|
24
|
+
definition: {
|
|
25
|
+
id: string;
|
|
26
|
+
revision: number;
|
|
27
|
+
contentHash: string;
|
|
28
|
+
};
|
|
29
|
+
inputHash: string;
|
|
30
|
+
seed: number;
|
|
31
|
+
initialStateHash: string;
|
|
32
|
+
finalStateHash: string;
|
|
33
|
+
state: Record<string, unknown>;
|
|
34
|
+
events: JavaScriptEnvironmentEvent[];
|
|
35
|
+
}
|
|
36
|
+
export declare class JavaScriptEnvironmentActionError extends Error {
|
|
37
|
+
readonly code: "unknown_tool" | "invalid_arguments" | "step_budget_exhausted";
|
|
38
|
+
constructor(code: "unknown_tool" | "invalid_arguments" | "step_budget_exhausted");
|
|
39
|
+
}
|
|
40
|
+
type Runner = (input: JavaScriptEnvironmentExecutionInput) => Promise<JavaScriptEnvironmentResult>;
|
|
41
|
+
/** One episode, with owner-held state that is never accepted from model output.
|
|
42
|
+
* Read-only tools and collection cannot change it. Call destroy in a finally block. */
|
|
43
|
+
export declare function createJavaScriptEnvironmentSession(input: {
|
|
44
|
+
definition: JavaScriptEnvironmentDefinition;
|
|
45
|
+
asset: LearningTextAsset;
|
|
46
|
+
input: Record<string, unknown>;
|
|
47
|
+
initialState: Record<string, unknown>;
|
|
48
|
+
seed: number;
|
|
49
|
+
execute?: Runner;
|
|
50
|
+
signal?: AbortSignal;
|
|
51
|
+
}): Promise<{
|
|
52
|
+
definition: {
|
|
53
|
+
schemaVersion: "openpond.javascriptEnvironment.v1";
|
|
54
|
+
id: string;
|
|
55
|
+
revision: number;
|
|
56
|
+
module: {
|
|
57
|
+
id: string;
|
|
58
|
+
path: string;
|
|
59
|
+
contentHash: string;
|
|
60
|
+
sizeBytes: number;
|
|
61
|
+
mediaType: string;
|
|
62
|
+
visibility: "policy" | "verifier" | "host_private";
|
|
63
|
+
};
|
|
64
|
+
tools: {
|
|
65
|
+
name: string;
|
|
66
|
+
description: string;
|
|
67
|
+
inputSchema: Record<string, unknown>;
|
|
68
|
+
inputSchemaHash: string;
|
|
69
|
+
sideEffect: "read" | "write";
|
|
70
|
+
timeoutMs: number;
|
|
71
|
+
}[];
|
|
72
|
+
maxSteps: number;
|
|
73
|
+
maxStateBytes: number;
|
|
74
|
+
maxObservationBytes: number;
|
|
75
|
+
operationTimeoutMs: number;
|
|
76
|
+
contentHash: string;
|
|
77
|
+
};
|
|
78
|
+
observation: Record<string, unknown>;
|
|
79
|
+
step(action: {
|
|
80
|
+
name: string;
|
|
81
|
+
arguments: Record<string, unknown>;
|
|
82
|
+
}): Promise<Record<string, unknown>>;
|
|
83
|
+
collect(): Promise<{
|
|
84
|
+
observation: Record<string, unknown>;
|
|
85
|
+
definition: {
|
|
86
|
+
id: string;
|
|
87
|
+
revision: number;
|
|
88
|
+
contentHash: string;
|
|
89
|
+
};
|
|
90
|
+
inputHash: string;
|
|
91
|
+
seed: number;
|
|
92
|
+
initialStateHash: string;
|
|
93
|
+
finalStateHash: string;
|
|
94
|
+
state: Record<string, unknown>;
|
|
95
|
+
events: JavaScriptEnvironmentEvent[];
|
|
96
|
+
}>;
|
|
97
|
+
snapshot: () => JavaScriptEnvironmentSnapshot;
|
|
98
|
+
destroy: () => Promise<void>;
|
|
99
|
+
}>;
|
|
100
|
+
//# sourceMappingURL=javascript-environment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"javascript-environment.d.ts","sourceRoot":"","sources":["../../../../src/javascript-environment.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGvF,OAAO,EAAkH,KAAK,+BAA+B,EAAE,KAAK,8BAA8B,EAAE,KAAK,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AACnR,cAAc,sCAAsC,CAAC;AAErD,MAAM,WAAW,mCAAmC;IAClD,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,8BAA8B,CAAC;IAC1C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,qFAAqF;AACrF,wBAAsB,4BAA4B,CAAC,KAAK,EAAE,mCAAmC,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAGnI;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,8BAA8B,CAAC;IAC1C,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC1C,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC5C,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,6BAA6B;IAC5C,UAAU,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IAClE,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,MAAM,EAAE,0BAA0B,EAAE,CAAC;CACtC;AAED,qBAAa,gCAAiC,SAAQ,KAAK;IAC7C,QAAQ,CAAC,IAAI,EAAE,cAAc,GAAG,mBAAmB,GAAG,uBAAuB;gBAApE,IAAI,EAAE,cAAc,GAAG,mBAAmB,GAAG,uBAAuB;CAI1F;AAED,KAAK,MAAM,GAAG,CAAC,KAAK,EAAE,mCAAmC,KAAK,OAAO,CAAC,2BAA2B,CAAC,CAAC;AAEnG;uFACuF;AACvF,wBAAsB,kCAAkC,CAAC,KAAK,EAAE;IAC9D,UAAU,EAAE,+BAA+B,CAAC;IAC5C,KAAK,EAAE,iBAAiB,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0EwB;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE;;;oBAtG/D;YAAE,EAAE,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAC;YAAC,WAAW,EAAE,MAAM,CAAA;SAAE;mBACtD,MAAM;cACX,MAAM;0BACM,MAAM;wBACR,MAAM;eACf,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;gBACtB,0BAA0B,EAAE;;oBAyFb,6BAA6B;mBAlB1B,OAAO,CAAC,IAAI,CAAC;GAqCxC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type JavaScriptIsolateInput } from "./javascript-isolate.js";
|
|
2
|
+
/** Both environment steps and graders settle only after their worker stops. */
|
|
3
|
+
export declare function executeJavaScriptIsolateInWorker(input: JavaScriptIsolateInput): Promise<unknown>;
|
|
4
|
+
//# sourceMappingURL=javascript-isolate-node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"javascript-isolate-node.d.ts","sourceRoot":"","sources":["../../../../src/javascript-isolate-node.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkC,KAAK,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAGtG,+EAA+E;AAC/E,wBAAsB,gCAAgC,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,OAAO,CAAC,CAsCtG"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface JavaScriptIsolateInput {
|
|
2
|
+
source: string;
|
|
3
|
+
exportName: string;
|
|
4
|
+
value: unknown;
|
|
5
|
+
timeoutMs: number;
|
|
6
|
+
signal?: AbortSignal;
|
|
7
|
+
maxResultBytes: number;
|
|
8
|
+
deterministic?: boolean;
|
|
9
|
+
errorPrefix: "verifier" | "environment";
|
|
10
|
+
}
|
|
11
|
+
/** Authored code is interpreter data, with no host functions or module loader. */
|
|
12
|
+
export declare function executeJavaScriptIsolate(input: JavaScriptIsolateInput): Promise<unknown>;
|
|
13
|
+
export declare function validateJavaScriptIsolateInput(input: JavaScriptIsolateInput): void;
|
|
14
|
+
//# sourceMappingURL=javascript-isolate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"javascript-isolate.d.ts","sourceRoot":"","sources":["../../../../src/javascript-isolate.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,EAAE,UAAU,GAAG,aAAa,CAAC;CACzC;AAED,kFAAkF;AAClF,wBAAsB,wBAAwB,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,OAAO,CAAC,CAkC9F;AAED,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,sBAAsB,GAAG,IAAI,CAKlF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"javascript-verifier-node.d.ts","sourceRoot":"","sources":["../../../../src/javascript-verifier-node.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"javascript-verifier-node.d.ts","sourceRoot":"","sources":["../../../../src/javascript-verifier-node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAC1E,OAAO,EAAkC,KAAK,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAGlH,8EAA8E;AAC9E,wBAAsB,iCAAiC,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAEjJ"}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { type JavaScriptVerifierResult } from "./javascript-verifier-contract.js";
|
|
2
2
|
export { JavaScriptVerifierResultSchema, type JavaScriptVerifierResult } from "./javascript-verifier-contract.js";
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* timers, or module loader. Hosts should run this on a worker to remain responsive
|
|
6
|
-
* and terminate that worker when cancellation is requested.
|
|
7
|
-
*/
|
|
3
|
+
/** A fresh interpreter with no filesystem, network, timers or module loader.
|
|
4
|
+
* Hosts should use the worker entrypoint for cancellation and responsiveness. */
|
|
8
5
|
export declare function executeJavaScriptVerifier(input: {
|
|
9
6
|
source: string;
|
|
10
7
|
exportName?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"javascript-verifier.d.ts","sourceRoot":"","sources":["../../../../src/javascript-verifier.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"javascript-verifier.d.ts","sourceRoot":"","sources":["../../../../src/javascript-verifier.ts"],"names":[],"mappings":"AACA,OAAO,EAAkC,KAAK,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAClH,OAAO,EAAE,8BAA8B,EAAE,KAAK,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAElH;iFACiF;AACjF,wBAAsB,yBAAyB,CAAC,KAAK,EAAE;IACrD,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAGpC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type AuthoringDraftInput } from "./authoring.js";
|
|
2
|
+
import { type LearningRevisionRef } from "./contracts.js";
|
|
3
|
+
import { type LearningResourcePointer, type LearningTransaction } from "./repository.js";
|
|
4
|
+
import type { LearningCommand } from "./operations.js";
|
|
5
|
+
export declare function saveAuthoringDraft(tx: LearningTransaction, input: {
|
|
6
|
+
draft: AuthoringDraftInput;
|
|
7
|
+
expectedRevision: number;
|
|
8
|
+
}, now: string): Promise<{
|
|
9
|
+
kind: "draft";
|
|
10
|
+
id: string;
|
|
11
|
+
revision: number;
|
|
12
|
+
}>;
|
|
13
|
+
export declare function archiveAuthoringDraft(tx: LearningTransaction, ref: LearningRevisionRef, now: string): Promise<{
|
|
14
|
+
kind: "draft";
|
|
15
|
+
id: string;
|
|
16
|
+
revision: number;
|
|
17
|
+
}>;
|
|
18
|
+
export declare function finalizeAuthoringDraft(tx: LearningTransaction, input: Extract<LearningCommand, {
|
|
19
|
+
action: "publish" | "publish_resources";
|
|
20
|
+
}>, published: LearningResourcePointer[], now: string): Promise<{
|
|
21
|
+
kind: "draft";
|
|
22
|
+
id: string;
|
|
23
|
+
revision: number;
|
|
24
|
+
} | null>;
|
|
25
|
+
//# sourceMappingURL=authoring-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authoring-service.d.ts","sourceRoot":"","sources":["../../../../../src/learning/authoring-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAEhF,OAAO,EAAqD,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC7G,OAAO,EAA0B,KAAK,uBAAuB,EAAE,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACjH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,wBAAsB,kBAAkB,CAAC,EAAE,EAAE,mBAAmB,EAAE,KAAK,EAAE;IAAE,KAAK,EAAE,mBAAmB,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAA;CAAE,EAAE,GAAG,EAAE,MAAM;;;;GAY7I;AAED,wBAAsB,qBAAqB,CAAC,EAAE,EAAE,mBAAmB,EAAE,GAAG,EAAE,mBAAmB,EAAE,GAAG,EAAE,MAAM;;;;GAMzG;AAED,wBAAsB,sBAAsB,CAAC,EAAE,EAAE,mBAAmB,EAAE,KAAK,EAAE,OAAO,CAAC,eAAe,EAAE;IAAE,MAAM,EAAE,SAAS,GAAG,mBAAmB,CAAA;CAAE,CAAC,EAAE,SAAS,EAAE,uBAAuB,EAAE,EAAE,GAAG,EAAE,MAAM;;;;UAUpM"}
|