@rzx/ohs 1.2.7 → 1.2.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.
@@ -774,7 +774,10 @@ var init_requests = __esm(() => {
774
774
  constructor(message, field, reason) {
775
775
  super(message);
776
776
  this.name = "ProtocolValidationError";
777
- this.details = field || reason !== undefined ? { ...field ? { field } : {}, ...reason !== undefined ? { reason } : {} } : undefined;
777
+ this.details = field || reason !== undefined ? {
778
+ ...field ? { field } : {},
779
+ ...reason !== undefined ? { reason } : {}
780
+ } : undefined;
778
781
  }
779
782
  toProtocolError() {
780
783
  return {
@@ -1251,7 +1254,6 @@ var init_plugin_ui = __esm(() => {
1251
1254
  jsonDepth: 20
1252
1255
  };
1253
1256
  });
1254
-
1255
1257
  // ../../packages/protocol/src/plugin-ui-requests.ts
1256
1258
  function request(value, fields) {
1257
1259
  if (!isPluginUiRecord(value))
@@ -1286,10 +1288,88 @@ var init_plugin_ui_requests = __esm(() => {
1286
1288
  init_requests();
1287
1289
  });
1288
1290
 
1291
+ // ../../packages/protocol/src/plugin-ui-appearance.ts
1292
+ var init_plugin_ui_appearance = __esm(() => {
1293
+ init_plugin_ui();
1294
+ init_requests();
1295
+ });
1296
+
1297
+ // ../../packages/protocol/src/plugin-ui-conversation.ts
1298
+ function invalid(field) {
1299
+ throw new ProtocolValidationError("Invalid Plugin UI conversation", field);
1300
+ }
1301
+ function exact(value, keys) {
1302
+ if (!isPluginUiRecord(value) || !keys.every((key) => Object.hasOwn(value, key)) || Object.keys(value).some((key) => !keys.includes(key)))
1303
+ invalid();
1304
+ return value;
1305
+ }
1306
+ function payload(r) {
1307
+ if (!isPluginUiRevision(r.expectedRevision))
1308
+ invalid("expectedRevision");
1309
+ if (!nonempty(r.text) || [...r.text].length > 4096)
1310
+ invalid("text");
1311
+ const checked = validatePluginUiJsonRecord(r.data, PLUGIN_UI_CONVERSATION_LIMITS.dataBytes);
1312
+ if (!checked.valid)
1313
+ throw new ProtocolValidationError("Invalid Plugin UI conversation data", "data", checked.reason);
1314
+ }
1315
+ function parsePluginUiConversationRequest(value) {
1316
+ const r = exact(value, ["mode", "expectedRevision", "text", "data"]);
1317
+ if (!mode(r.mode))
1318
+ invalid("mode");
1319
+ payload(r);
1320
+ return structuredClone(r);
1321
+ }
1322
+ function parseSubmitPluginUiConversationInput(value) {
1323
+ const r = exact(value, ["requestId", "expectedRevision", "text", "data"]);
1324
+ if (!isPluginUiUuid(r.requestId))
1325
+ invalid("requestId");
1326
+ payload(r);
1327
+ return structuredClone(r);
1328
+ }
1329
+ function parsePluginUiConversationPrepared(value) {
1330
+ const r = exact(value, ["mode", "instanceId", "revision", "promptText"]);
1331
+ if (!mode(r.mode) || !isPluginUiUuid(r.instanceId) || !isPluginUiRevision(r.revision) || !nonempty(r.promptText))
1332
+ invalid();
1333
+ if (new TextEncoder().encode(r.promptText).byteLength > 64 * 1024)
1334
+ throw new ProtocolValidationError("Plugin UI conversation prompt is too large", "promptText", "payload_too_large");
1335
+ return structuredClone(r);
1336
+ }
1337
+ function parsePluginUiConversationReceipt(value) {
1338
+ if (!isPluginUiRecord(value))
1339
+ invalid();
1340
+ const r = exact(value, value.mode === "draft" ? ["kind", "mode", "instanceId", "revision", "added"] : [
1341
+ "kind",
1342
+ "mode",
1343
+ "instanceId",
1344
+ "revision",
1345
+ "requestId",
1346
+ "inputId",
1347
+ "runId",
1348
+ "status"
1349
+ ]);
1350
+ if (r.kind !== "conversation" || !mode(r.mode) || !isPluginUiUuid(r.instanceId) || !isPluginUiRevision(r.revision))
1351
+ invalid();
1352
+ if (r.mode === "draft") {
1353
+ if (r.added !== true)
1354
+ invalid("added");
1355
+ } else if (!isPluginUiUuid(r.requestId) || !nonempty(r.inputId) || !nonempty(r.runId) || typeof r.status !== "string" || !["pending", "running", "completed", "failed", "interrupted"].includes(r.status))
1356
+ invalid();
1357
+ return structuredClone(r);
1358
+ }
1359
+ var PLUGIN_UI_CONVERSATION_LIMITS, nonempty = (value) => typeof value === "string" && !!value.trim(), mode = (value) => value === "draft" || value === "submit";
1360
+ var init_plugin_ui_conversation = __esm(() => {
1361
+ init_plugin_ui();
1362
+ init_requests();
1363
+ PLUGIN_UI_CONVERSATION_LIMITS = { dataBytes: 32 * 1024 };
1364
+ });
1365
+
1289
1366
  // ../../packages/protocol/src/plugin-ui-bridge.ts
1290
1367
  var PLUGIN_UI_BRIDGE_LIMITS;
1291
1368
  var init_plugin_ui_bridge = __esm(() => {
1292
1369
  init_plugin_ui();
1370
+ init_plugin_ui_appearance();
1371
+ init_requests();
1372
+ init_plugin_ui_conversation();
1293
1373
  PLUGIN_UI_BRIDGE_LIMITS = {
1294
1374
  requestBytes: 64 * 1024,
1295
1375
  snapshotBytes: 512 * 1024,
@@ -1329,6 +1409,8 @@ var init_src = __esm(() => {
1329
1409
  init_plugin_ui();
1330
1410
  init_plugin_ui_requests();
1331
1411
  init_plugin_ui_bridge();
1412
+ init_plugin_ui_appearance();
1413
+ init_plugin_ui_conversation();
1332
1414
  init_notes();
1333
1415
  });
1334
1416
 
@@ -2110,15 +2192,47 @@ class PluginUiResource {
2110
2192
  constructor(transport) {
2111
2193
  this.transport = transport;
2112
2194
  }
2113
- get(sessionId, instanceId, options = {}) {
2114
- return this.transport.request(path(sessionId, instanceId), options);
2195
+ async get(sessionId, instanceId, options = {}) {
2196
+ const response = await this.transport.request(path(sessionId, instanceId), options);
2197
+ if (!response.conversation || typeof response.conversation.draft !== "boolean" || typeof response.conversation.submit !== "boolean")
2198
+ throw new ProtocolValidationError("Plugin UI response requires conversation capability booleans", "conversation");
2199
+ return response;
2200
+ }
2201
+ async prepareConversation(sessionId, instanceId, input, options = {}) {
2202
+ const body = parsePluginUiConversationRequest(input);
2203
+ const prepared = parsePluginUiConversationPrepared(await this.transport.request(path(sessionId, instanceId) + "/conversation/prepare", { ...options, method: "POST", body }));
2204
+ if (prepared.instanceId !== instanceId || prepared.mode !== body.mode || prepared.revision !== body.expectedRevision)
2205
+ throw new ProtocolValidationError("Plugin UI prepared conversation differs from the request");
2206
+ return prepared;
2207
+ }
2208
+ async submitConversation(sessionId, instanceId, input, options = {}) {
2209
+ const body = parseSubmitPluginUiConversationInput(input);
2210
+ const response = await this.transport.request(path(sessionId, instanceId) + "/conversation/submissions", { ...options, method: "POST", body });
2211
+ const receipt = this.conversationReceipt(response.receipt, instanceId, body.requestId);
2212
+ if (receipt.revision !== body.expectedRevision + 1)
2213
+ throw new ProtocolValidationError("Plugin UI submission revision differs from the request");
2214
+ return receipt;
2215
+ }
2216
+ async getConversationSubmission(sessionId, instanceId, requestId, options = {}) {
2217
+ const response = await this.transport.request(path(sessionId, instanceId) + `/conversation/submissions/${encodeURIComponent(requestId)}`, options);
2218
+ return this.conversationReceipt(response.receipt, instanceId, requestId);
2219
+ }
2220
+ conversationReceipt(value, instanceId, requestId) {
2221
+ const receipt = parsePluginUiConversationReceipt(value);
2222
+ if (receipt.mode !== "submit" || receipt.instanceId !== instanceId || receipt.requestId !== requestId)
2223
+ throw new ProtocolValidationError("Plugin UI submission receipt differs from the request");
2224
+ return receipt;
2115
2225
  }
2116
2226
  getDocument(sessionId, instanceId, options = {}) {
2117
2227
  return this.transport.request(path(sessionId, instanceId) + "/document", options);
2118
2228
  }
2119
2229
  async invokeAction(sessionId, instanceId, input, options = {}) {
2120
2230
  const body = structuredClone(parseInvokePluginUiActionInput(input));
2121
- const response = await this.transport.request(path(sessionId, instanceId) + "/actions", { ...options, method: "POST", body });
2231
+ const response = await this.transport.request(path(sessionId, instanceId) + "/actions", {
2232
+ ...options,
2233
+ method: "POST",
2234
+ body
2235
+ });
2122
2236
  return response.receipt;
2123
2237
  }
2124
2238
  getAction(sessionId, instanceId, requestId, options = {}) {
@@ -2126,7 +2240,11 @@ class PluginUiResource {
2126
2240
  }
2127
2241
  async dismiss(sessionId, instanceId, input, options = {}) {
2128
2242
  const body = parseDismissPluginUiInput(input);
2129
- const response = await this.transport.request(path(sessionId, instanceId) + "/dismiss", { ...options, method: "POST", body });
2243
+ const response = await this.transport.request(path(sessionId, instanceId) + "/dismiss", {
2244
+ ...options,
2245
+ method: "POST",
2246
+ body
2247
+ });
2130
2248
  return response.instance;
2131
2249
  }
2132
2250
  }
@@ -2310,7 +2428,10 @@ class SessionResource {
2310
2428
  async interrupt(sessionId, options = {}) {
2311
2429
  return await this.transport.request(`/sessions/${encodeURIComponent(sessionId)}/interrupt`, {
2312
2430
  method: "POST",
2313
- body: options.expectedRunId ? { expectedRunId: options.expectedRunId } : undefined,
2431
+ body: options.expectedRunId || options.source ? {
2432
+ ...options.expectedRunId ? { expectedRunId: options.expectedRunId } : {},
2433
+ ...options.source ? { source: options.source } : {}
2434
+ } : undefined,
2314
2435
  signal: options.signal
2315
2436
  });
2316
2437
  }
@@ -4006,7 +4127,7 @@ async function handleSettingsCommand(slash, host, emit, readPresentation) {
4006
4127
  if (slash?.name === "/reasoning") {
4007
4128
  const arg = slash.args.trim().split(/\s+/).filter(Boolean)[0];
4008
4129
  const settings = await client.system.getSettings();
4009
- const current = settings.showReasoning !== false;
4130
+ const current = settings.showReasoning === true;
4010
4131
  let next;
4011
4132
  if (arg === "on")
4012
4133
  next = true;
@@ -4512,6 +4633,8 @@ var init_src2 = __esm(() => {
4512
4633
  init_src();
4513
4634
  init_src();
4514
4635
  init_src();
4636
+ init_src();
4637
+ init_src();
4515
4638
  init_state();
4516
4639
  init_commands();
4517
4640
  init_src();
@@ -4729,7 +4852,7 @@ function projectBucketToItems(bucket) {
4729
4852
  }
4730
4853
  function bucketToTranscript(bucket, options = {}) {
4731
4854
  const items = projectBucketToItems(bucket);
4732
- if (options.showReasoning === false) {
4855
+ if (options.showReasoning !== true) {
4733
4856
  return items.filter((item) => item.role !== "reasoning");
4734
4857
  }
4735
4858
  return items;
@@ -5400,7 +5523,7 @@ function useServerSync(config, onError) {
5400
5523
  const [localBusy, setLocalBusy] = useState(false);
5401
5524
  const [submittedRun, setSubmittedRun] = useState(null);
5402
5525
  const [ready, setReady] = useState(false);
5403
- const [showReasoning, setShowReasoning] = useState(true);
5526
+ const [showReasoning, setShowReasoning] = useState(false);
5404
5527
  const [globalSystemItems, setGlobalSystemItems] = useState([]);
5405
5528
  const [systemItemsBySession, setSystemItemsBySession] = useState({});
5406
5529
  const [commandCatalog, setCommandCatalog] = useState([]);
@@ -5648,7 +5771,7 @@ function useServerSync(config, onError) {
5648
5771
  if (!client)
5649
5772
  return;
5650
5773
  const settings = await client.system.getSettings();
5651
- setShowReasoning(settings.showReasoning !== false);
5774
+ setShowReasoning(settings.showReasoning === true);
5652
5775
  }, []);
5653
5776
  const cacheFirstRead = useCallback((request) => {
5654
5777
  const cached = presentationCacheRef.current[request.key];
@@ -5771,7 +5894,7 @@ Refresh failed: ${message}` : `Failed to load ${request.title}: ${message}`;
5771
5894
  client.system.listCommands({ cwd }).catch(() => [])
5772
5895
  ]);
5773
5896
  const model = daemon.model ?? stringSetting(settings.model) ?? "default";
5774
- setShowReasoning(settings.showReasoning !== false);
5897
+ setShowReasoning(settings.showReasoning === true);
5775
5898
  const provider = stringSetting(settings.provider);
5776
5899
  const baseUrl = stringSetting(settings.baseUrl);
5777
5900
  const apiFormat = settings.apiFormat === "anthropic" || settings.apiFormat === "openai" ? settings.apiFormat : undefined;
@@ -9833,4 +9956,4 @@ try {
9833
9956
  process.exit(1);
9834
9957
  }
9835
9958
 
9836
- //# debugId=6231F499BD7C9B6D64756E2164756E21
9959
+ //# debugId=2470C0D4380CA1BA64756E2164756E21