@themoltnet/pi-extension 0.3.0 → 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.
Files changed (2) hide show
  1. package/dist/index.js +75 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync } fr
4
4
  import path, { join } from "node:path";
5
5
  import { DefaultResourceLoader, SessionManager, createAgentSession, createBashTool, createBashToolDefinition, createEditTool, createEditToolDefinition, createReadTool, createReadToolDefinition, createWriteTool, createWriteToolDefinition, defineTool } from "@mariozechner/pi-coding-agent";
6
6
  import { createHash, randomUUID } from "node:crypto";
7
- import { createHash as createHash$1 } from "crypto";
7
+ import crypto, { createHash as createHash$1 } from "crypto";
8
8
  import { readFile } from "node:fs/promises";
9
9
  import { homedir } from "node:os";
10
10
  import { Type, complete, getModel } from "@mariozechner/pi-ai";
@@ -2810,7 +2810,7 @@ K512[1];
2810
2810
  * To break sha256 using birthday attack, attackers need to try 2^128 hashes.
2811
2811
  * BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.
2812
2812
  */
2813
- var sha256 = /* @__PURE__ */ createHasher(() => new SHA256());
2813
+ var sha256$1 = /* @__PURE__ */ createHasher(() => new SHA256());
2814
2814
  //#endregion
2815
2815
  //#region ../../node_modules/.pnpm/multiformats@13.4.2/node_modules/multiformats/dist/src/bytes.js
2816
2816
  function equals$1(aa, bb) {
@@ -3027,12 +3027,12 @@ var Codec = class {
3027
3027
  return this.decoder.decode(input);
3028
3028
  }
3029
3029
  };
3030
- function from({ name, prefix, encode, decode }) {
3030
+ function from$1({ name, prefix, encode, decode }) {
3031
3031
  return new Codec(name, prefix, encode, decode);
3032
3032
  }
3033
3033
  function baseX({ name, prefix, alphabet }) {
3034
3034
  const { encode, decode } = _brrp__multiformats_scope_baseX(alphabet, name);
3035
- return from({
3035
+ return from$1({
3036
3036
  prefix,
3037
3037
  name,
3038
3038
  encode,
@@ -3087,7 +3087,7 @@ function createAlphabetIdx(alphabet) {
3087
3087
  */
3088
3088
  function rfc4648({ name, prefix, bitsPerChar, alphabet }) {
3089
3089
  const alphabetIdx = createAlphabetIdx(alphabet);
3090
- return from({
3090
+ return from$1({
3091
3091
  prefix,
3092
3092
  name,
3093
3093
  encode(input) {
@@ -3623,7 +3623,7 @@ function buildCanonicalInput(entryType, title, content, tags) {
3623
3623
  */
3624
3624
  function computeCanonicalHash(entryType, title, content, tags) {
3625
3625
  const input = buildCanonicalInput(entryType, title, content, tags);
3626
- return sha256(new TextEncoder().encode(input));
3626
+ return sha256$1(new TextEncoder().encode(input));
3627
3627
  }
3628
3628
  /**
3629
3629
  * Compute a CIDv1 content identifier for a diary entry.
@@ -4069,6 +4069,64 @@ etc.sha512Sync = (...m) => {
4069
4069
  m.forEach((msg) => hash.update(msg));
4070
4070
  return hash.digest();
4071
4071
  };
4072
+ new TextEncoder();
4073
+ new TextDecoder();
4074
+ //#endregion
4075
+ //#region ../../node_modules/.pnpm/multiformats@13.4.2/node_modules/multiformats/dist/src/hashes/hasher.js
4076
+ var DEFAULT_MIN_DIGEST_LENGTH = 20;
4077
+ function from({ name, code, encode, minDigestLength, maxDigestLength }) {
4078
+ return new Hasher(name, code, encode, minDigestLength, maxDigestLength);
4079
+ }
4080
+ /**
4081
+ * Hasher represents a hashing algorithm implementation that produces as
4082
+ * `MultihashDigest`.
4083
+ */
4084
+ var Hasher = class {
4085
+ name;
4086
+ code;
4087
+ encode;
4088
+ minDigestLength;
4089
+ maxDigestLength;
4090
+ constructor(name, code, encode, minDigestLength, maxDigestLength) {
4091
+ this.name = name;
4092
+ this.code = code;
4093
+ this.encode = encode;
4094
+ this.minDigestLength = minDigestLength ?? DEFAULT_MIN_DIGEST_LENGTH;
4095
+ this.maxDigestLength = maxDigestLength;
4096
+ }
4097
+ digest(input, options) {
4098
+ if (options?.truncate != null) {
4099
+ if (options.truncate < this.minDigestLength) throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);
4100
+ if (this.maxDigestLength != null && options.truncate > this.maxDigestLength) throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`);
4101
+ }
4102
+ if (input instanceof Uint8Array) {
4103
+ const result = this.encode(input);
4104
+ if (result instanceof Uint8Array) return createDigest(result, this.code, options?.truncate);
4105
+ return result.then((digest) => createDigest(digest, this.code, options?.truncate));
4106
+ } else throw Error("Unknown type, must be binary type");
4107
+ }
4108
+ };
4109
+ /**
4110
+ * Create a Digest from the passed uint8array and code, optionally truncating it
4111
+ * first.
4112
+ */
4113
+ function createDigest(digest, code, truncate) {
4114
+ if (truncate != null && truncate !== digest.byteLength) {
4115
+ if (truncate > digest.byteLength) throw new Error(`Invalid truncate option, must be less than or equal to ${digest.byteLength}`);
4116
+ digest = digest.subarray(0, truncate);
4117
+ }
4118
+ return create(code, digest);
4119
+ }
4120
+ from({
4121
+ name: "sha2-256",
4122
+ code: 18,
4123
+ encode: (input) => coerce(crypto.createHash("sha256").update(input).digest())
4124
+ });
4125
+ from({
4126
+ name: "sha2-512",
4127
+ code: 19,
4128
+ encode: (input) => coerce(crypto.createHash("sha512").update(input).digest())
4129
+ });
4072
4130
  //#endregion
4073
4131
  //#region ../../node_modules/.pnpm/cborg@4.5.8/node_modules/cborg/lib/is.js
4074
4132
  var objectTypeNames = [
@@ -8509,6 +8567,17 @@ var BUILT_IN_TASK_TYPES = {
8509
8567
  }
8510
8568
  };
8511
8569
  //#endregion
8570
+ //#region ../tasks/src/task-type-registry.ts
8571
+ var schemaCids = null;
8572
+ function getTaskTypeRegistry() {
8573
+ if (!schemaCids) throw new Error("Task type registry not initialized. Call initTaskTypeRegistry() first.");
8574
+ return schemaCids;
8575
+ }
8576
+ new Proxy({}, { get(_, prop) {
8577
+ if (typeof prop !== "string") return void 0;
8578
+ return getTaskTypeRegistry().get(prop);
8579
+ } });
8580
+ //#endregion
8512
8581
  //#region ../tasks/src/wire.ts
8513
8582
  /**
8514
8583
  * Wire-format types for the MoltNet Task model.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@themoltnet/pi-extension",
3
- "version": "0.3.0",
3
+ "version": "0.4.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",