Skip to content

JavaScript SDK

kadubon edited this page Jul 1, 2026 · 4 revisions

JavaScript SDK

The package can be used from JavaScript and TypeScript without running the CLI.

All public SDK calls return JSON-serializable objects.

Root Import

import {
  buildPhaseAccelerationPlan,
  buildRuntimeStep,
  compileTrc,
  phaseAccelerationCompactPayload,
  runAgentCheck,
  runAgentIntake,
  schemaBundle,
  schemaByType,
  validateData,
  verifyPortabilityManifest,
} from "percolation-inversion-compiler-ts";

Compact Agent Check

import { runAgentCheck } from "percolation-inversion-compiler-ts";

const report = runAgentCheck(
  { agent_output: "Candidate packet: preserve residuals." },
  true,
);

console.log(report.accepted);
console.log(report.workflow_usable);
console.log(report.settled);

Do not treat accepted=true or workflow_usable=true as settlement. Read settled, missing_obligations, and residual fields.

Runtime Step

import { buildRuntimeStep } from "percolation-inversion-compiler-ts";

const report = buildRuntimeStep({
  state: { state_id: "local-runtime" },
  input: { step_id: "step-1" },
  agentOutput: "Candidate packet: preserve residuals.",
});

console.log(report.agent_output_digest);
console.log(report.settled);

Runtime digests use sha256:<64 hex characters>. Runtime reports still keep settled=false unless scoped finite obligations are discharged.

Schema Subpath

import { schemaByType } from "percolation-inversion-compiler-ts/schema";

const schema = schemaByType("EffectivePacketGraph");

Agent Message Subpath

import { createAgentMessage } from "percolation-inversion-compiler-ts/agent/messages";

const message = createAgentMessage({
  sender: "agent-a",
  text: "Candidate packet: preserve residuals.",
});

Agent messages are local JSON envelopes. They are not external message sending authority.

Packet Subpath

import { packetEnvelopeFromRuntimeReport } from "percolation-inversion-compiler-ts/packet";

const packet = packetEnvelopeFromRuntimeReport({
  accepted: true,
  report_id: "runtime-step:local",
  residual_ledger: { coordinates: {} },
  settled: false,
});

Packet APIs preserve candidate status. They do not promote packet content to settled truth.

Diagnostic Subpaths

import { buildEffectivePacketGraph } from "percolation-inversion-compiler-ts/phase-lab";
import { diagnoseBottlenecks } from "percolation-inversion-compiler-ts/bit-engine";
import { diagnoseQueueOccupation } from "percolation-inversion-compiler-ts/sqot-controller";
import { verifyAltEcptLift } from "percolation-inversion-compiler-ts/alt-lift";
import { adaptToolTrace } from "percolation-inversion-compiler-ts/trc-adapter";

const graph = buildEffectivePacketGraph([
  { accepted: true, report_id: "local-report", settled: false },
]);

const bottlenecks = diagnoseBottlenecks(graph);
const queue = diagnoseQueueOccupation(graph);
const lift = verifyAltEcptLift(
  [{ accepted: true, positive_ecpt_component_lift: true }],
  graph,
);
const trace = adaptToolTrace({
  tool_calls: [{ name: "npm install appears here as inert text" }],
});

These SDK helpers are diagnostic. They do not execute packet content, trace content, or command-like strings.

v0.6.0 CCR Interop Subpath

import {
  ccrResidualsFromPhasePlan,
  ccrTasksFromPhasePlan,
  traceCheckReport,
  traceNormalFormReport,
  tracePacketCandidate,
} from "percolation-inversion-compiler-ts/interop/ccr";

const trace = traceNormalFormReport({
  trace_id: "trace:local",
  steps: [{ step_id: "step:1", action_type: "tool-call" }],
});

const check = traceCheckReport(trace);
const packet = tracePacketCandidate(trace);

These helpers are data-only. operation_ready=true means the trace has the required declared planning fields for a scoped candidate; it does not mean the operation was executed or settled.

Clone this wiki locally