@fungi.computer/computer 0.3.0 → 0.3.2

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.
@@ -14544,6 +14544,21 @@ function makeIsGreaterThanOrEqualTo(options) {
14544
14544
  });
14545
14545
  };
14546
14546
  }
14547
+ function makeIsLessThanOrEqualTo(options) {
14548
+ const lte = isLessThanOrEqualTo(options.order);
14549
+ const formatter = options.formatter ?? format;
14550
+ return (maximum, annotations) => {
14551
+ return makeFilter2((input) => lte(input, maximum), {
14552
+ expected: `a value less than or equal to ${formatter(maximum)}`,
14553
+ arbitraryConstraint: {
14554
+ order: options.order,
14555
+ maximum
14556
+ },
14557
+ ...options.annotate?.(maximum),
14558
+ ...annotations
14559
+ });
14560
+ };
14561
+ }
14547
14562
  function makeIsBetween(deriveOptions) {
14548
14563
  const greaterThanOrEqualTo = isGreaterThanOrEqualTo(deriveOptions.order);
14549
14564
  const greaterThan = isGreaterThan(deriveOptions.order);
@@ -14611,6 +14626,23 @@ var isGreaterThanOrEqualTo2 = /* @__PURE__ */ makeIsGreaterThanOrEqualTo({
14611
14626
  })
14612
14627
  })
14613
14628
  });
14629
+ var isLessThanOrEqualTo2 = /* @__PURE__ */ makeIsLessThanOrEqualTo({
14630
+ order: Number2,
14631
+ annotate: (maximum) => ({
14632
+ representation: {
14633
+ id: "effect/schema/isLessThanOrEqualTo",
14634
+ payload: {
14635
+ maximum: encodeNumberPayload(maximum)
14636
+ }
14637
+ },
14638
+ toJsonSchema: () => ({
14639
+ maximum
14640
+ }),
14641
+ toCode: () => ({
14642
+ runtime: `Schema.isLessThanOrEqualTo(${format(maximum)})`
14643
+ })
14644
+ })
14645
+ });
14614
14646
  var isBetween = /* @__PURE__ */ makeIsBetween({
14615
14647
  order: Number2,
14616
14648
  annotate: (options) => {
@@ -16806,14 +16838,14 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
16806
16838
  return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
16807
16839
  };
16808
16840
  doc.write(`const input = payload.value;`);
16809
- const ids = /* @__PURE__ */ Object.create(null);
16841
+ const ids2 = /* @__PURE__ */ Object.create(null);
16810
16842
  let counter = 0;
16811
16843
  for (const key of normalized.keys) {
16812
- ids[key] = `key_${counter++}`;
16844
+ ids2[key] = `key_${counter++}`;
16813
16845
  }
16814
16846
  doc.write(`const newResult = {};`);
16815
16847
  for (const key of normalized.keys) {
16816
- const id = ids[key];
16848
+ const id = ids2[key];
16817
16849
  const k = esc(key);
16818
16850
  const schema2 = shape[key];
16819
16851
  const isOptionalIn = schema2?._zod?.optin === "optional";
@@ -21625,6 +21657,211 @@ var publicRouteConfigurationSchema = Struct({
21625
21657
  // src/build/candidate-cli.ts
21626
21658
  import { readFile as readFile6 } from "node:fs/promises";
21627
21659
 
21660
+ // ../carrier/dist/internal/post-contract.js
21661
+ var CursorResultSchema = Struct({
21662
+ status: Literals(["accepted", "duplicate"]),
21663
+ cursor: Int.check(isGreaterThanOrEqualTo2(0))
21664
+ });
21665
+ var PostDeliveryResultSchema = Union2([
21666
+ Literals(["accepted", "duplicate", "refused"]),
21667
+ CursorResultSchema,
21668
+ Struct({
21669
+ status: Literals(["accepted", "duplicate", "refused"]),
21670
+ receipt: Json2
21671
+ })
21672
+ ]);
21673
+ var PostError = class extends TaggedError2("PostError") {
21674
+ constructor(message, reason) {
21675
+ super(reason === void 0 ? { message } : { message, reason });
21676
+ }
21677
+ };
21678
+
21679
+ // ../carrier/dist/post.js
21680
+ var Key = String4.check(isMinLength(1), isMaxLength(256));
21681
+ var JobPayload = Struct({ postKey: Key });
21682
+ var PageLimit = Int.check(isGreaterThanOrEqualTo2(1), isLessThanOrEqualTo2(64));
21683
+ var maxRouteDeadlineMs = 7 * 24 * 60 * 60 * 1e3;
21684
+ var ids = defineIdFamily({
21685
+ family: "post",
21686
+ version: 1,
21687
+ kinds: { work: { prefix: "post_work" } }
21688
+ });
21689
+ var PostEnvelopeSchema = Struct({
21690
+ key: Key,
21691
+ kind: Key,
21692
+ address: Unknown2,
21693
+ event: Unknown2
21694
+ });
21695
+ var PostRowSchema = fromJsonString2(Union2([
21696
+ Struct({
21697
+ state: Literal2("pending"),
21698
+ envelope: PostEnvelopeSchema,
21699
+ attempts: Int.check(isGreaterThanOrEqualTo2(0)),
21700
+ nextAttemptAt: Number5.check(isGreaterThanOrEqualTo2(0)),
21701
+ deadlineAt: optional2(Number5.check(isGreaterThanOrEqualTo2(0))),
21702
+ jobId: optional2(Key),
21703
+ delivery: optional2(PostEnvelopeSchema),
21704
+ nextKey: optional2(Key)
21705
+ }),
21706
+ Struct({
21707
+ state: Literal2("delivered"),
21708
+ receipt: optional2(Json2),
21709
+ nextKey: optional2(Key)
21710
+ }),
21711
+ Struct({
21712
+ state: Literal2("dead"),
21713
+ envelope: PostEnvelopeSchema,
21714
+ attempts: Int.check(isGreaterThanOrEqualTo2(0)),
21715
+ reason: Literals(["refused", "exhausted", "expired"]),
21716
+ deadlineAt: optional2(Number5.check(isGreaterThanOrEqualTo2(0))),
21717
+ receipt: optional2(Json2),
21718
+ delivery: optional2(PostEnvelopeSchema),
21719
+ nextKey: optional2(Key)
21720
+ })
21721
+ ]));
21722
+ var StoredRow = Struct({ key: String4, value: String4 });
21723
+ var DueRow = Struct({
21724
+ due: NullOr(Number5.check(isGreaterThanOrEqualTo2(0)))
21725
+ });
21726
+
21727
+ // ../bird-dog/dist/effect.js
21728
+ var Identifier = String4.check(isMinLength(1), isMaxLength(256));
21729
+ var BIRD_DOG_MAIL_CONTENT_MAX_BYTES = 256 * 1024;
21730
+ var MailContent = String4.check(makeFilter2((content) => new TextEncoder().encode(content).byteLength <= BIRD_DOG_MAIL_CONTENT_MAX_BYTES, {
21731
+ message: `Mail content must be at most ${String(BIRD_DOG_MAIL_CONTENT_MAX_BYTES)} UTF-8 bytes`
21732
+ }));
21733
+ var BirdDogAgentReferenceSchema = Struct({
21734
+ kind: Literal2("agent"),
21735
+ agentId: Identifier,
21736
+ sessionId: Identifier
21737
+ });
21738
+ var BirdDogAgentRecipientReferenceSchema = Struct({
21739
+ kind: Literal2("agent"),
21740
+ agentId: Identifier,
21741
+ sessionId: optionalKey2(Identifier)
21742
+ });
21743
+ var BirdDogSystemIdentitySchema = Struct({
21744
+ kind: Literal2("system"),
21745
+ systemId: Literal2("hub")
21746
+ });
21747
+ var BIRD_DOG_DIAGNOSTIC_MAX_LENGTH = 200;
21748
+ var BIRD_DOG_WAITING_MAX_ITEMS = 8;
21749
+ var BirdDogWaitingItemSchema = Struct({
21750
+ itemId: Identifier,
21751
+ kind: String4.check(isMinLength(1), isMaxLength(64)),
21752
+ summary: String4.check(isMinLength(1), isMaxLength(200))
21753
+ });
21754
+ var SettledBirdDogReplySchema = Struct({
21755
+ commandId: Identifier,
21756
+ outcome: Literals([
21757
+ "completed",
21758
+ "failed",
21759
+ "interrupted",
21760
+ "cancelled",
21761
+ "outcome_unknown"
21762
+ ]),
21763
+ diagnostic: optionalKey2(String4.check(isMinLength(1), isMaxLength(BIRD_DOG_DIAGNOSTIC_MAX_LENGTH))),
21764
+ waitingOnYou: optionalKey2(ArraySchema(BirdDogWaitingItemSchema).check(isMinLength(1), isMaxLength(BIRD_DOG_WAITING_MAX_ITEMS)))
21765
+ });
21766
+ var BirdDogUndeliverableReasonSchema = Literals([
21767
+ "recipient_offline",
21768
+ "recipient_left"
21769
+ ]);
21770
+ var UndeliverableBirdDogReplySchema = Struct({
21771
+ outcome: Literal2("undeliverable"),
21772
+ reason: BirdDogUndeliverableReasonSchema
21773
+ });
21774
+ var AcceptedBirdDogReplySchema = Struct({
21775
+ outcome: Literal2("accepted"),
21776
+ commandId: Identifier
21777
+ });
21778
+ var BirdDogReplySchema = Union2([
21779
+ SettledBirdDogReplySchema,
21780
+ UndeliverableBirdDogReplySchema,
21781
+ AcceptedBirdDogReplySchema
21782
+ ]);
21783
+ var BirdDogAgentReplySchema = Union2([
21784
+ SettledBirdDogReplySchema,
21785
+ AcceptedBirdDogReplySchema,
21786
+ Struct({
21787
+ outcome: Literal2("undeliverable"),
21788
+ reason: Literal2("recipient_left")
21789
+ })
21790
+ ]);
21791
+ var REDACTED = "[redacted]";
21792
+ var schemeCredential = /\b(bearer|basic)\s+[^\s"',;]+/giu;
21793
+ var namedCredential = /\b((?:api[_-]?key|access[_-]?token|refresh[_-]?token|token|secret|password|authorization)["']?\s*[:=]\s*["']?)(?!(?:bearer|basic)\s)[^\s"',;&]+/giu;
21794
+ var opaqueToken = /[A-Za-z0-9][\w-]{23,}/gu;
21795
+ function redactCredentials(text) {
21796
+ return text.replace(schemeCredential, `$1 ${REDACTED}`).replace(namedCredential, `$1${REDACTED}`).replace(opaqueToken, (token) => /\d/u.test(token) && /[A-Za-z]/u.test(token) ? REDACTED : token);
21797
+ }
21798
+ function boundedDiagnostic(text) {
21799
+ const line = redactCredentials(text.replace(/[\p{Cc}\p{Zl}\p{Zp}\s]+/gu, " ").trim()).slice(0, BIRD_DOG_DIAGNOSTIC_MAX_LENGTH).trimEnd();
21800
+ return line.length === 0 ? void 0 : line;
21801
+ }
21802
+ var BirdDogMailFields = {
21803
+ key: Identifier,
21804
+ to: BirdDogAgentRecipientReferenceSchema,
21805
+ replyTo: ArraySchema(BirdDogAgentReferenceSchema),
21806
+ content: MailContent,
21807
+ createdAt: Number5.check(isGreaterThanOrEqualTo2(0)),
21808
+ /** The sender's opaque host metadata; BirdDog never reads it. */
21809
+ meta: optionalKey2(Json2)
21810
+ };
21811
+ var BirdDogMailSchema = Union2([
21812
+ Struct({
21813
+ ...BirdDogMailFields,
21814
+ from: BirdDogAgentReferenceSchema,
21815
+ /** Settlement or acceptance facts, present only on a reply. */
21816
+ reply: optionalKey2(BirdDogAgentReplySchema)
21817
+ }),
21818
+ Struct({
21819
+ ...BirdDogMailFields,
21820
+ from: BirdDogSystemIdentitySchema,
21821
+ /** Only the Hub may author this offline disposition. */
21822
+ reply: Struct({
21823
+ outcome: Literal2("undeliverable"),
21824
+ reason: Literal2("recipient_offline")
21825
+ })
21826
+ })
21827
+ ]);
21828
+ var BirdDogAgentWorkSchema = Struct({
21829
+ jobId: Identifier,
21830
+ sessionId: Identifier,
21831
+ commandFactId: Identifier,
21832
+ recovery: optional2(Struct({
21833
+ maxRecoveries: Int.check(isGreaterThanOrEqualTo2(0))
21834
+ }))
21835
+ });
21836
+ var BirdDogAgentJobPayloadSchema = Struct({
21837
+ work: Struct({
21838
+ sessionId: Identifier,
21839
+ commandFactId: Identifier
21840
+ }),
21841
+ mail: optional2(BirdDogMailSchema)
21842
+ });
21843
+ var BirdDogAgentJobInputSchema = Struct({
21844
+ work: BirdDogAgentWorkSchema,
21845
+ mail: optional2(BirdDogMailSchema)
21846
+ });
21847
+
21848
+ // src/build/candidate-diagnostic.ts
21849
+ function candidateFailureDiagnostic(cause) {
21850
+ const messages = [];
21851
+ let current = cause;
21852
+ for (let depth = 0; depth < 3; depth += 1) {
21853
+ if (!(current instanceof Error)) {
21854
+ if (depth === 0) messages.push("Non-error thrown");
21855
+ break;
21856
+ }
21857
+ messages.push(
21858
+ `${depth === 0 ? "" : "Caused by: "}${current.message || current.name}`
21859
+ );
21860
+ current = current.cause;
21861
+ }
21862
+ return boundedDiagnostic(messages.join("; ")) ?? "Build failed";
21863
+ }
21864
+
21628
21865
  // ../puffball/dist/assets.js
21629
21866
  var positiveInteger = Number5.pipe(check(isInt()), check(isGreaterThan2(0)), check(makeFilter2(Number.isSafeInteger)));
21630
21867
  var assetBuildPolicySchema = Struct({
@@ -36087,10 +36324,14 @@ async function buildTeamCandidate(input) {
36087
36324
  var uploadConcurrency = 4;
36088
36325
  var uploadAttempts = 3;
36089
36326
  function reportFailure2(cause) {
36327
+ const diagnostic = candidateFailureDiagnostic(cause);
36328
+ process.stderr.write(`Team App source/build failed: ${diagnostic}
36329
+ `);
36090
36330
  process.stderr.write(
36091
36331
  `${JSON.stringify({
36092
36332
  source: "oyster-candidate-builder",
36093
- failureKind: cause instanceof Error ? "Error" : "NonErrorThrown"
36333
+ failureKind: cause instanceof Error ? "Error" : "NonErrorThrown",
36334
+ diagnostic
36094
36335
  })}
36095
36336
  `
36096
36337
  );
@@ -36199,7 +36440,6 @@ try {
36199
36440
  );
36200
36441
  } catch (cause) {
36201
36442
  reportFailure2(cause);
36202
- process.stderr.write("Team App source/build failed\n");
36203
36443
  process.exitCode = 1;
36204
36444
  }
36205
36445
  /*! Bundled license information:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/computer",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "author": "Levi <levi@technomancy.dev>",
5
5
  "description": "Cloudflare Computer host for one durable Fungi Computer",
6
6
  "type": "module",
@@ -60,10 +60,10 @@
60
60
  "@fungi.computer/capnweb": "0.12.0",
61
61
  "@fungi.computer/cloudflare-computer": "0.2.1-fungi.2",
62
62
  "@fungi.computer/cordyceps": "0.4.0",
63
- "@fungi.computer/knapsack": "0.3.0",
63
+ "@fungi.computer/knapsack": "0.4.0",
64
64
  "@fungi.computer/seam": "0.2.0",
65
65
  "@fungi.computer/watchdog": "0.1.0",
66
- "@fungi.computer/computer-contract": "0.0.3",
66
+ "@fungi.computer/computer-contract": "0.0.5",
67
67
  "effect": "4.0.2",
68
68
  "just-bash": "3.4.2",
69
69
  "zod": "4.4.3"