@themoltnet/pi-extension 0.19.6 → 0.20.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/dist/index.d.ts CHANGED
@@ -19,8 +19,11 @@ import { TObject } from '@sinclair/typebox';
19
19
  import { ToolDefinition } from '@earendil-works/pi-coding-agent';
20
20
  import { TOptional } from '@sinclair/typebox';
21
21
  import { TRecord } from '@sinclair/typebox';
22
+ import { TRecursive } from '@sinclair/typebox';
23
+ import { TRefUnsafe } from '@sinclair/typebox';
22
24
  import { TSchema } from '@sinclair/typebox';
23
25
  import { TString } from '@sinclair/typebox';
26
+ import { TThis } from '@sinclair/typebox';
24
27
  import { TUnion } from '@sinclair/typebox';
25
28
  import { TUnknown } from '@sinclair/typebox';
26
29
  import { VM } from '@earendil-works/gondolin';
@@ -81,7 +84,7 @@ declare interface ClaimedTask {
81
84
  }
82
85
 
83
86
  /**
84
- * One context entry. Bytes are inlined: the imposer chose them, and the
87
+ * One context entry. Bytes are inlined: the proposer chose them, and the
85
88
  * task's `inputCid` already pins the entire input — including
86
89
  * `context[]` — so we don't need a separate per-entry hash, fetcher, or
87
90
  * flagged-content gate. Tasks reference rendered packs (or any other
@@ -702,15 +705,29 @@ declare const Task: TObject< {
702
705
  }>>;
703
706
  }>>;
704
707
  correlationId: TUnion<[TString, TNull]>;
705
- imposedByAgentId: TUnion<[TString, TNull]>;
706
- imposedByHumanId: TUnion<[TString, TNull]>;
708
+ proposedByAgentId: TUnion<[TString, TNull]>;
709
+ proposedByHumanId: TUnion<[TString, TNull]>;
707
710
  acceptedAttemptN: TUnion<[TNumber, TNull]>;
711
+ claimCondition: TUnion<[TRecursive<TUnion<[TObject< {
712
+ op: TLiteral<"all">;
713
+ conditions: TArray<TThis>;
714
+ }>, TObject< {
715
+ op: TLiteral<"any">;
716
+ conditions: TArray<TThis>;
717
+ }>, TObject< {
718
+ op: TLiteral<"task_status">;
719
+ taskId: TString;
720
+ statuses: TArray<TRefUnsafe<TUnion<[TLiteral<"waiting">, TLiteral<"queued">, TLiteral<"dispatched">, TLiteral<"running">, TLiteral<"completed">, TLiteral<"failed">, TLiteral<"cancelled">, TLiteral<"expired">]>>>;
721
+ }>, TObject< {
722
+ op: TLiteral<"task_accepted">;
723
+ taskId: TString;
724
+ }>]>>, TNull]>;
708
725
  requiredExecutorTrustLevel: TUnion<[TLiteral<"selfDeclared">, TLiteral<"agentSigned">, TLiteral<"releaseVerifiedTool">, TLiteral<"sandboxAttested">]>;
709
726
  allowedExecutors: TArray<TObject< {
710
727
  provider: TString;
711
728
  model: TString;
712
729
  }>>;
713
- status: TUnion<[TLiteral<"queued">, TLiteral<"dispatched">, TLiteral<"running">, TLiteral<"completed">, TLiteral<"failed">, TLiteral<"cancelled">, TLiteral<"expired">]>;
730
+ status: TUnion<[TLiteral<"waiting">, TLiteral<"queued">, TLiteral<"dispatched">, TLiteral<"running">, TLiteral<"completed">, TLiteral<"failed">, TLiteral<"cancelled">, TLiteral<"expired">]>;
714
731
  queuedAt: TString;
715
732
  completedAt: TUnion<[TString, TNull]>;
716
733
  expiresAt: TUnion<[TString, TNull]>;
@@ -813,7 +830,7 @@ declare interface TaskReporter {
813
830
  /** Flush buffers + release resources. Called once. Idempotent. */
814
831
  close(): Promise<void>;
815
832
  /**
816
- * Signal that aborts when the task is cancelled by the imposer (or a
833
+ * Signal that aborts when the task is cancelled by the proposer (or a
817
834
  * diary writer) while the executor is running. `ApiTaskReporter`
818
835
  * aborts this on the next heartbeat that observes `cancelled: true`
819
836
  * in the response (#938). Local reporters (`StdoutReporter`,
package/dist/index.js CHANGED
@@ -2507,7 +2507,7 @@ var MoltNetError = class extends Error {
2507
2507
  /**
2508
2508
  * Populated when the server returned a `VALIDATION_FAILED` problem
2509
2509
  * (status 400) with field-level errors. Empty / undefined for every
2510
- * other problem kind. Imposer scripts surface these to operators so
2510
+ * other problem kind. Proposer scripts surface these to operators so
2511
2511
  * they don't have to re-run with curl to see what was rejected.
2512
2512
  */
2513
2513
  validationErrors;
@@ -8942,7 +8942,7 @@ var PROMPT_SEPARATOR = "\n\n---\n\n";
8942
8942
  * declared order, same separator.
8943
8943
  *
8944
8944
  * No fetching, no hashing — bytes are inlined in `ContextRef.content`,
8945
- * and the task's `inputCid` already pins the entire input. The imposer
8945
+ * and the task's `inputCid` already pins the entire input. The proposer
8946
8946
  * chose these bytes; the resolver just dispatches them.
8947
8947
  *
8948
8948
  * The function is pure with respect to its arguments: file writes are
@@ -9029,7 +9029,7 @@ var ContextBinding = Type$1.Union([
9029
9029
  Type$1.Literal("user_inline")
9030
9030
  ], { $id: "ContextBinding" });
9031
9031
  /**
9032
- * One context entry. Bytes are inlined: the imposer chose them, and the
9032
+ * One context entry. Bytes are inlined: the proposer chose them, and the
9033
9033
  * task's `inputCid` already pins the entire input — including
9034
9034
  * `context[]` — so we don't need a separate per-entry hash, fetcher, or
9035
9035
  * flagged-content gate. Tasks reference rendered packs (or any other
@@ -9175,7 +9175,7 @@ function validateRubricWeights(rubric) {
9175
9175
  //#endregion
9176
9176
  //#region ../tasks/src/success-criteria.ts
9177
9177
  /**
9178
- * SuccessCriteria — imposer-stated acceptance criteria, evaluated in two
9178
+ * SuccessCriteria — proposer-stated acceptance criteria, evaluated in two
9179
9179
  * complementary places.
9180
9180
  *
9181
9181
  * Before this envelope existed, criteria were scattered: a vestigial
@@ -9184,7 +9184,7 @@ function validateRubricWeights(rubric) {
9184
9184
  * judgment-task inputs. None of those were machine-verifiable
9185
9185
  * end-to-end.
9186
9186
  *
9187
- * This module defines a single, content-addressable envelope an imposer
9187
+ * This module defines a single, content-addressable envelope a proposer
9188
9188
  * attaches to any task type. It has four orthogonal sections — pick
9189
9189
  * whichever apply per task type:
9190
9190
  *
@@ -9218,7 +9218,7 @@ function validateRubricWeights(rubric) {
9218
9218
  * spec for the judge.
9219
9219
  *
9220
9220
  * The clean chain: producer task with `successCriteria` → producer
9221
- * self-assesses honestly → imposer (or automation) creates a downstream
9221
+ * self-assesses honestly → proposer (or automation) creates a downstream
9222
9222
  * judgment task that references the same `successCriteria` (or a
9223
9223
  * stricter rubric) → judgment task delivers the binding verdict.
9224
9224
  *
@@ -9380,8 +9380,9 @@ var AssessBriefOutput = Type$1.Object({
9380
9380
  * - `targetTaskId` resolves to a real task the caller can see.
9381
9381
  * - The target is a `fulfill_brief` (you cannot grade an arbitrary
9382
9382
  * task type as if it were a brief fulfillment).
9383
- * - The target is `completed` with an accepted attempt — grading
9384
- * an in-flight or failed task would either race or grade nothing.
9383
+ * - Unless readiness checks are explicitly deferred, the target is
9384
+ * `completed` with an accepted attempt grading an in-flight or
9385
+ * failed task would either race or grade nothing.
9385
9386
  *
9386
9387
  * Agent-distinctness ("assessor ≠ producer") is a runtime / auth-
9387
9388
  * layer concern and intentionally NOT checked here. It belongs in
@@ -9402,7 +9403,7 @@ async function validateAssessBriefInputAsync(input, ctx) {
9402
9403
  field: "targetTaskId",
9403
9404
  message: `targetTaskId ${targetTaskId} is a ${target.taskType}, not a fulfill_brief`
9404
9405
  });
9405
- if (target.status !== "completed" || target.acceptedAttemptN === null) errors.push({
9406
+ if (!ctx.deferReadinessChecks && (target.status !== "completed" || target.acceptedAttemptN === null)) errors.push({
9406
9407
  field: "targetTaskId",
9407
9408
  message: `targetTaskId ${targetTaskId} is not completed with an accepted attempt (status=${target.status}, acceptedAttemptN=${target.acceptedAttemptN})`
9408
9409
  });
@@ -9723,11 +9724,11 @@ async function validateJudgeEvalAttemptInputAsync(input, ctx) {
9723
9724
  field: "targetTaskId",
9724
9725
  message: `targetTaskId=${inp.targetTaskId} is a ${target.taskType}, not a run_eval`
9725
9726
  });
9726
- if (target.status !== "completed" || target.acceptedAttemptN === null) errors.push({
9727
+ if (!ctx.deferReadinessChecks && (target.status !== "completed" || target.acceptedAttemptN === null)) errors.push({
9727
9728
  field: "targetTaskId",
9728
9729
  message: `targetTaskId=${inp.targetTaskId} is not completed with an accepted attempt (status=${target.status}, acceptedAttemptN=${target.acceptedAttemptN})`
9729
9730
  });
9730
- else if (target.acceptedAttemptN !== inp.targetAttemptN) errors.push({
9731
+ else if (target.acceptedAttemptN !== null && target.acceptedAttemptN !== inp.targetAttemptN) errors.push({
9731
9732
  field: "targetAttemptN",
9732
9733
  message: `targetAttemptN=${inp.targetAttemptN} does not match the producer's acceptedAttemptN=${target.acceptedAttemptN}`
9733
9734
  });
@@ -9738,6 +9739,7 @@ async function validateJudgeEvalAttemptInputAsync(input, ctx) {
9738
9739
  if (errors.length > 0 || !target.correlationId) return errors;
9739
9740
  const rubric = inp.successCriteria.rubric;
9740
9741
  const duplicate = (await ctx.listTasksByCorrelation(target.correlationId)).find((task) => {
9742
+ if (task.id === ctx.currentTaskId) return false;
9741
9743
  if (task.taskType !== "judge_eval_attempt") return false;
9742
9744
  if (task.status === "failed" || task.status === "cancelled" || task.status === "expired") return false;
9743
9745
  const existing = task.input;
@@ -10205,11 +10207,12 @@ function taskTypeUsesSubagents(taskType) {
10205
10207
  *
10206
10208
  * Identity rule:
10207
10209
  * - claim/execute/sign → agent-only (`task_attempts.claimed_by_agent_id`)
10208
- * - impose/cancel → agent XOR human (dual nullable FK + XOR check)
10210
+ * - propose/cancel → agent XOR human (dual nullable FK + XOR check)
10209
10211
  *
10210
10212
  * See GH issue #852 for the full design snapshot.
10211
10213
  */
10212
10214
  var TaskStatus = Type$1.Union([
10215
+ Type$1.Literal("waiting"),
10213
10216
  Type$1.Literal("queued"),
10214
10217
  Type$1.Literal("dispatched"),
10215
10218
  Type$1.Literal("running"),
@@ -10252,6 +10255,36 @@ var TaskMessageKind = Type$1.Union([
10252
10255
  var Uuid = Type$1.String({ format: "uuid" });
10253
10256
  var Cid = Type$1.String({ minLength: 1 });
10254
10257
  var IsoTimestamp = Type$1.String({ format: "date-time" });
10258
+ var MAX_CLAIM_CONDITION_BRANCHES = 8;
10259
+ var MAX_CLAIM_CONDITION_STATUSES = 8;
10260
+ var ClaimCondition = Type$1.Recursive((Self) => Type$1.Union([
10261
+ Type$1.Object({
10262
+ op: Type$1.Literal("all"),
10263
+ conditions: Type$1.Array(Self, {
10264
+ minItems: 1,
10265
+ maxItems: MAX_CLAIM_CONDITION_BRANCHES
10266
+ })
10267
+ }, { additionalProperties: false }),
10268
+ Type$1.Object({
10269
+ op: Type$1.Literal("any"),
10270
+ conditions: Type$1.Array(Self, {
10271
+ minItems: 1,
10272
+ maxItems: MAX_CLAIM_CONDITION_BRANCHES
10273
+ })
10274
+ }, { additionalProperties: false }),
10275
+ Type$1.Object({
10276
+ op: Type$1.Literal("task_status"),
10277
+ taskId: Uuid,
10278
+ statuses: Type$1.Array(Type$1.Ref(TaskStatus), {
10279
+ minItems: 1,
10280
+ maxItems: MAX_CLAIM_CONDITION_STATUSES
10281
+ })
10282
+ }, { additionalProperties: false }),
10283
+ Type$1.Object({
10284
+ op: Type$1.Literal("task_accepted"),
10285
+ taskId: Uuid
10286
+ }, { additionalProperties: false })
10287
+ ]), { $id: "ClaimCondition" });
10255
10288
  /**
10256
10289
  * Reference to another task's output or an external artifact.
10257
10290
  * Embedded in `tasks.references` JSONB array.
@@ -10328,9 +10361,10 @@ Type$1.Object({
10328
10361
  inputCid: Cid,
10329
10362
  references: Type$1.Array(TaskRef),
10330
10363
  correlationId: Type$1.Union([Uuid, Type$1.Null()]),
10331
- imposedByAgentId: Type$1.Union([Uuid, Type$1.Null()]),
10332
- imposedByHumanId: Type$1.Union([Uuid, Type$1.Null()]),
10364
+ proposedByAgentId: Type$1.Union([Uuid, Type$1.Null()]),
10365
+ proposedByHumanId: Type$1.Union([Uuid, Type$1.Null()]),
10333
10366
  acceptedAttemptN: Type$1.Union([Type$1.Number(), Type$1.Null()]),
10367
+ claimCondition: Type$1.Union([ClaimCondition, Type$1.Null()]),
10334
10368
  requiredExecutorTrustLevel: ExecutorTrustLevel,
10335
10369
  allowedExecutors: Type$1.Array(ExecutorRef, { maxItems: 16 }),
10336
10370
  status: TaskStatus,
@@ -10787,7 +10821,7 @@ function buildCuratePackUserPrompt(input, ctx) {
10787
10821
  "to defend it in the summary."
10788
10822
  ].join("\n");
10789
10823
  const constraintsLines = [];
10790
- if (entryTypesPinned) constraintsLines.push(`- Entry types pinned by imposer (do not widen): ${entryTypes.map((t) => `\`${t}\``).join(", ")}`);
10824
+ if (entryTypesPinned) constraintsLines.push(`- Entry types pinned by proposer (do not widen): ${entryTypes.map((t) => `\`${t}\``).join(", ")}`);
10791
10825
  else constraintsLines.push("- Entry types: **you choose**. The diary contains three kinds:", " - `episodic` — incident reports, \"what happened and how we fixed it\" narratives.", " - `semantic` — durable decisions, patterns, design rationale.", " - `procedural` — commit audit trails / changelog-style provenance.", " Pick the subset that fits the prompt. For \"failures and workarounds\"", " or \"decisions we made\" you generally do NOT want `procedural` — those", " entries are append-only commit logs and produce changelog-shaped packs.", " Include `procedural` only when the prompt explicitly asks for changelog-", " style content (e.g., \"what shipped this week\"). State your choice", " briefly in the final `summary`.");
10792
10826
  constraintsLines.push(`- Recipe tag: \`${resolvedRecipe}\` (recorded on pack params)`);
10793
10827
  constraintsLines.push(tokenBudget ? `- Token budget (soft cap on final pack): ${tokenBudget}. Pick entry count so the pack fits — estimate ~300 tok/entry as a starting heuristic, tighten after inspecting actual content lengths.` : "- No token budget — size the pack to match the prompt, not an arbitrary target.");
@@ -16594,7 +16628,7 @@ async function executePiTask(claimedTask, reporter, opts) {
16594
16628
  durationMs: Date.now() - startTime,
16595
16629
  error: {
16596
16630
  code: "task_cancelled",
16597
- message: reporter.cancelReason ?? "Task cancelled by imposer while pi session was running.",
16631
+ message: reporter.cancelReason ?? "Task cancelled by proposer while pi session was running.",
16598
16632
  retryable: false
16599
16633
  }
16600
16634
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@themoltnet/pi-extension",
3
- "version": "0.19.6",
3
+ "version": "0.20.0",
4
4
  "type": "module",
5
5
  "description": "MoltNet pi extension — sandboxed tool execution in Gondolin VMs with MoltNet identity and persistent memory",
6
6
  "license": "MIT",
@@ -31,8 +31,8 @@
31
31
  "@earendil-works/gondolin": "^0.9.1",
32
32
  "@opentelemetry/api": "^1.9.0",
33
33
  "@sinclair/typebox": "^0.34.0",
34
- "@themoltnet/agent-runtime": "0.18.5",
35
- "@themoltnet/sdk": "0.105.1"
34
+ "@themoltnet/sdk": "0.106.0",
35
+ "@themoltnet/agent-runtime": "0.19.0"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@earendil-works/pi-coding-agent": ">=0.74.0",