@abelxiaoxing/cadence 2.0.19 → 2.0.20

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abelxiaoxing/cadence",
3
- "version": "2.0.19",
3
+ "version": "2.0.20",
4
4
  "description": "Shared Pi task workspace: native terminal and WebUI, persistent service, checks and human review.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -2,5 +2,5 @@
2
2
  export const nativeBuild = {
3
3
  kind: "native",
4
4
  contractHash:
5
- "944f3b53bd5b7f1d3f30868e0947d900e356ae9a2bcfb9f591edd988b3d5eb3a",
5
+ "83a2720c0a5a61f9e18e4f67e9738f184dee61cf07e75d9b98b5728577daaa6d",
6
6
  } as const;
@@ -66,6 +66,9 @@ export interface ChatTurn {
66
66
  status: ChatStatus;
67
67
  items: ChatItem[];
68
68
  notice: string;
69
+ /** Content kinds observed and not retained; never written into `notice`.
70
+ * `other` is a block of a type Cadence does not recognize. */
71
+ omitted: { thinking: boolean; media: boolean; other: boolean };
69
72
  }
70
73
  export interface ChatSummary {
71
74
  id: string;
@@ -199,12 +202,24 @@ export function decodeWorkbenchCommand(v: unknown): WorkbenchCommand {
199
202
  };
200
203
  }
201
204
  export function decodeChatTurn(v: unknown): ChatTurn {
202
- const o = closed(v, ["id", "epoch", "status", "items", "notice"]);
205
+ // Turns saved before `omitted` existed lack it; their flags read as unobserved.
206
+ const keys = ["id", "epoch", "status", "items", "notice"];
207
+ const current =
208
+ v !== null && typeof v === "object" && Object.hasOwn(v, "omitted");
209
+ const o = closed(v, current ? [...keys, "omitted"] : keys);
210
+ const omitted = current
211
+ ? closed(o.omitted, ["thinking", "media", "other"])
212
+ : null;
203
213
  return {
204
214
  id: decodeId(o.id),
205
215
  epoch: decodeId(o.epoch),
206
216
  status: oneOf(o.status, statuses),
207
217
  notice: text(o.notice, 1024),
218
+ omitted: {
219
+ thinking: omitted ? bool(omitted.thinking) : false,
220
+ media: omitted ? bool(omitted.media) : false,
221
+ other: omitted ? bool(omitted.other) : false,
222
+ },
208
223
  items: list(o.items, 256, (v) => {
209
224
  const i = closed(v, ["id", "role", "text", "name", "args", "error"]);
210
225
  return {
@@ -4006,12 +4006,20 @@ function decodeWorkbenchCommand(v) {
4006
4006
  };
4007
4007
  }
4008
4008
  function decodeChatTurn(v) {
4009
- const o = closed(v, ["id", "epoch", "status", "items", "notice"]);
4009
+ const keys2 = ["id", "epoch", "status", "items", "notice"];
4010
+ const current = v !== null && typeof v === "object" && Object.hasOwn(v, "omitted");
4011
+ const o = closed(v, current ? [...keys2, "omitted"] : keys2);
4012
+ const omitted = current ? closed(o.omitted, ["thinking", "media", "other"]) : null;
4010
4013
  return {
4011
4014
  id: decodeId(o.id),
4012
4015
  epoch: decodeId(o.epoch),
4013
4016
  status: oneOf(o.status, statuses),
4014
4017
  notice: text(o.notice, 1024),
4018
+ omitted: {
4019
+ thinking: omitted ? bool(omitted.thinking) : false,
4020
+ media: omitted ? bool(omitted.media) : false,
4021
+ other: omitted ? bool(omitted.other) : false
4022
+ },
4015
4023
  items: list(o.items, 256, (v2) => {
4016
4024
  const i = closed(v2, ["id", "role", "text", "name", "args", "error"]);
4017
4025
  return {
@@ -10285,7 +10293,7 @@ async function createGateway(value, hostUrl, source) {
10285
10293
  const input = decodeGatewayInput(value), store = new GatewayStore(input.serverConfig, input.stateHome);
10286
10294
  const web = loadWebAssets(source?.webDirectory);
10287
10295
  const build2 = {
10288
- contractHash: "944f3b53bd5b7f1d3f30868e0947d900e356ae9a2bcfb9f591edd988b3d5eb3a",
10296
+ contractHash: "83a2720c0a5a61f9e18e4f67e9738f184dee61cf07e75d9b98b5728577daaa6d",
10289
10297
  assets: {
10290
10298
  sourceHash: web.manifest.sourceHash,
10291
10299
  contractHash: web.manifest.contractHash,
@@ -25158,6 +25166,11 @@ import { dirname as dirname14, join as join22 } from "node:path";
25158
25166
  var TURN_BYTES = 384 * 1024;
25159
25167
  var META_BYTES = 64 * 1024;
25160
25168
  var SESSION_LIMIT = 200;
25169
+ var OMITTED_FLAG = {
25170
+ "hidden-thinking": "thinking",
25171
+ binary: "media",
25172
+ unsupported: "other"
25173
+ };
25161
25174
 
25162
25175
  class ConversationCapture {
25163
25176
  turn;
@@ -25251,8 +25264,8 @@ class ConversationCapture {
25251
25264
  item.error = e.isError;
25252
25265
  } else if (e.kind === "worker-failure")
25253
25266
  this.turn.notice = `worker-failure: ${e.code}`;
25254
- else if (e.kind === "omitted-block")
25255
- this.turn.notice = "Hidden thinking, signatures and media are not retained.";
25267
+ else if (e.kind === "omitted-block" && e.block.owner.kind !== "context" && e.block.owner.kind !== "handoff")
25268
+ this.turn.omitted[OMITTED_FLAG[e.block.reason]] = true;
25256
25269
  if ([...this.details.values()].reduce((size, detail) => size + Buffer.byteLength(detail.text) + detail.sanitizer.retainedBytes, 0) > TURN_BYTES)
25257
25270
  throw new ContractError("capacity");
25258
25271
  canonicalJson(this.turn, TURN_BYTES);
@@ -25509,6 +25522,7 @@ class Conversations {
25509
25522
  epoch: input.model.epoch,
25510
25523
  status: "queued",
25511
25524
  notice: "",
25525
+ omitted: { thinking: false, media: false, other: false },
25512
25526
  items: [
25513
25527
  {
25514
25528
  id: "user",
@@ -25934,7 +25948,7 @@ function refuseAt(stage, step) {
25934
25948
  }
25935
25949
  }
25936
25950
  async function createServiceHost(value, sourceBuild) {
25937
- const embedded = "944f3b53bd5b7f1d3f30868e0947d900e356ae9a2bcfb9f591edd988b3d5eb3a";
25951
+ const embedded = "83a2720c0a5a61f9e18e4f67e9738f184dee61cf07e75d9b98b5728577daaa6d";
25938
25952
  if (embedded && sourceBuild)
25939
25953
  throw new ContractError("unsupported-context");
25940
25954
  const contractHash = decodeHash(embedded ?? sourceBuild?.contractHash);