@neta-art/cohub-cli 10.28.0 → 10.29.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.
@@ -1,11 +1,11 @@
1
- import { F as Texture, J as Bounds, P as TexturePool, a as Filter, c as UniformGroup, d as GpuProgram, dt as extensions, et as warn, g as CanvasFilterSystem, h as FilterPipe, i as vertex, l as RendererType, ot as Matrix, p as GlProgram, t as Geometry, u as BindGroup, ut as ExtensionType, v as getGlobalRenderableBounds } from "./Geometry.js";
2
- //#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/filters/defaults/passthrough/passthrough.frag.mjs
1
+ import { J as Texture, K as Bounds, N as TexturePool, W as warn, _ as UniformGroup, a as getGlobalRenderableBounds, b as GlProgram, ct as Matrix, f as Filter, ft as ExtensionType, g as BindGroup, h as RendererType, l as Geometry, n as vertex, pt as extensions, r as CanvasFilterSystem, t as FilterPipe, v as GpuProgram } from "./FilterPipe.js";
2
+ //#region ../../node_modules/.pnpm/pixi.js@8.23.0/node_modules/pixi.js/lib/filters/defaults/passthrough/passthrough.frag.mjs
3
3
  var fragment = "in vec2 vTextureCoord;\nout vec4 finalColor;\nuniform sampler2D uTexture;\nvoid main() {\n finalColor = texture(uTexture, vTextureCoord);\n}\n";
4
4
  //#endregion
5
- //#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/filters/defaults/passthrough/passthrough.wgsl.mjs
5
+ //#region ../../node_modules/.pnpm/pixi.js@8.23.0/node_modules/pixi.js/lib/filters/defaults/passthrough/passthrough.wgsl.mjs
6
6
  var source = "struct GlobalFilterUniforms {\n uInputSize: vec4<f32>,\n uInputPixel: vec4<f32>,\n uInputClamp: vec4<f32>,\n uOutputFrame: vec4<f32>,\n uGlobalFrame: vec4<f32>,\n uOutputTexture: vec4<f32>,\n};\n\n@group(0) @binding(0) var <uniform> gfu: GlobalFilterUniforms;\n@group(0) @binding(1) var uTexture: texture_2d<f32>;\n@group(0) @binding(2) var uSampler: sampler;\n\nstruct VSOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) uv: vec2<f32>\n};\n\nfn filterVertexPosition(aPosition: vec2<f32>) -> vec4<f32>\n{\n var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;\n\n position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;\n position.y = position.y * (2.0 * gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;\n\n return vec4(position, 0.0, 1.0);\n}\n\nfn filterTextureCoord(aPosition: vec2<f32>) -> vec2<f32>\n{\n return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);\n}\n\n@vertex\nfn mainVertex(\n @location(0) aPosition: vec2<f32>,\n) -> VSOutput {\n return VSOutput(\n filterVertexPosition(aPosition),\n filterTextureCoord(aPosition)\n );\n}\n\n@fragment\nfn mainFragment(\n @location(0) uv: vec2<f32>,\n) -> @location(0) vec4<f32> {\n return textureSample(uTexture, uSampler, uv);\n}\n";
7
7
  //#endregion
8
- //#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/filters/defaults/passthrough/PassthroughFilter.mjs
8
+ //#region ../../node_modules/.pnpm/pixi.js@8.23.0/node_modules/pixi.js/lib/filters/defaults/passthrough/PassthroughFilter.mjs
9
9
  var PassthroughFilter = class extends Filter {
10
10
  constructor() {
11
11
  const gpuProgram = GpuProgram.from({
@@ -31,7 +31,7 @@ var PassthroughFilter = class extends Filter {
31
31
  }
32
32
  };
33
33
  //#endregion
34
- //#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/filters/FilterSystem.mjs
34
+ //#region ../../node_modules/.pnpm/pixi.js@8.23.0/node_modules/pixi.js/lib/filters/FilterSystem.mjs
35
35
  const quadGeometry = new Geometry({
36
36
  attributes: { aPosition: {
37
37
  buffer: new Float32Array([
@@ -99,16 +99,6 @@ var FilterData = class {
99
99
  * @type {RenderSurface}
100
100
  */
101
101
  this.outputRenderSurface = null;
102
- /**
103
- * The global frame of the filter area.
104
- * @type {{ x: number, y: number, width: number, height: number }}
105
- */
106
- this.globalFrame = {
107
- x: 0,
108
- y: 0,
109
- width: 0,
110
- height: 0
111
- };
112
102
  /** The first enabled filter index in the current filter list. */
113
103
  this.firstEnabledIndex = -1;
114
104
  /** The last enabled filter index in the current filter list. */
@@ -148,6 +138,10 @@ var FilterSystem = class {
148
138
  this._globalFilterBindGroup = new BindGroup({});
149
139
  this.renderer = renderer;
150
140
  }
141
+ /** @internal */
142
+ init() {
143
+ TexturePool.on("evict", this._unbindPassTextures, this);
144
+ }
151
145
  /**
152
146
  * The back texture of the currently active filter. Requires the filter to have `blendRequired` set to true.
153
147
  * @readonly
@@ -180,14 +174,6 @@ var FilterSystem = class {
180
174
  this._calculateFilterBounds(filterData, renderer.renderTarget.rootViewPort, rootAntialias, rootResolution, 1);
181
175
  if (filterData.skip) return;
182
176
  const previousFilterData = this._getPreviousFilterData();
183
- const globalResolution = this._findFilterResolution(rootResolution);
184
- let offsetX = 0;
185
- let offsetY = 0;
186
- if (previousFilterData) {
187
- offsetX = previousFilterData.bounds.minX;
188
- offsetY = previousFilterData.bounds.minY;
189
- }
190
- this._calculateGlobalFrame(filterData, offsetX, offsetY, globalResolution, colorTextureSource.width, colorTextureSource.height);
191
177
  this._setupFilterTextures(filterData, bounds, renderer, previousFilterData);
192
178
  }
193
179
  /**
@@ -207,7 +193,7 @@ var FilterSystem = class {
207
193
  * const filters = [new BlurFilter(), new ColorMatrixFilter()];
208
194
  *
209
195
  * // Apply the filters to the texture
210
- * const resultTexture = filterSystem.applyToTexture({ texture, filters });
196
+ * const resultTexture = renderer.filter.generateFilteredTexture({ texture, filters });
211
197
  *
212
198
  * // Use the resulting texture
213
199
  * sprite.texture = resultTexture;
@@ -218,6 +204,7 @@ var FilterSystem = class {
218
204
  * 2. If all filters are disabled or skipped, the original texture is returned.
219
205
  */
220
206
  generateFilteredTexture({ texture, filters }) {
207
+ if (filters.every((filter) => !filter.enabled)) return texture;
221
208
  const filterData = this._pushFilterData();
222
209
  this._activeFilterData = filterData;
223
210
  filterData.skip = false;
@@ -225,23 +212,27 @@ var FilterSystem = class {
225
212
  const colorTextureSource = texture.source;
226
213
  const rootResolution = colorTextureSource.resolution;
227
214
  const rootAntialias = colorTextureSource.antialias;
228
- if (filters.every((filter) => !filter.enabled)) {
229
- filterData.skip = true;
230
- return texture;
231
- }
232
215
  const bounds = filterData.bounds;
216
+ bounds.clear();
233
217
  bounds.addRect(texture.frame);
234
218
  this._calculateFilterBounds(filterData, bounds.rectangle, rootAntialias, rootResolution, 0);
235
- if (filterData.skip) return texture;
236
- const globalResolution = rootResolution;
237
- this._calculateGlobalFrame(filterData, 0, 0, globalResolution, colorTextureSource.width, colorTextureSource.height);
238
- filterData.outputRenderSurface = TexturePool.getOptimalTexture(bounds.width, bounds.height, filterData.resolution, filterData.antialias);
219
+ if (filterData.skip) {
220
+ this._popFilterData();
221
+ return texture;
222
+ }
223
+ filterData.outputRenderSurface = TexturePool.getOptimalTexture({
224
+ width: bounds.width,
225
+ height: bounds.height,
226
+ resolution: filterData.resolution,
227
+ antialias: filterData.antialias
228
+ });
239
229
  filterData.backTexture = Texture.EMPTY;
240
230
  filterData.inputTexture = texture;
241
231
  this.renderer.renderTarget.finishRenderPass();
242
232
  this._applyFiltersToTexture(filterData, true);
243
233
  const outputTexture = filterData.outputRenderSurface;
244
234
  outputTexture.source.alphaMode = "premultiplied-alpha";
235
+ this._popFilterData();
245
236
  return outputTexture;
246
237
  }
247
238
  /** @internal */
@@ -263,18 +254,34 @@ var FilterSystem = class {
263
254
  * @param previousBounds - The previous bounds to use for offsetting the copy.
264
255
  */
265
256
  getBackTexture(lastRenderSurface, bounds, previousBounds) {
266
- const backgroundResolution = lastRenderSurface.colorTexture.source._resolution;
267
- const backTexture = TexturePool.getOptimalTexture(bounds.width, bounds.height, backgroundResolution, false);
257
+ const { _resolution: resolution, format } = lastRenderSurface.colorTexture.source;
258
+ const backTexture = TexturePool.getOptimalTexture({
259
+ width: bounds.width,
260
+ height: bounds.height,
261
+ resolution,
262
+ format
263
+ });
264
+ return this._copyBackTexture(lastRenderSurface, backTexture, bounds, previousBounds);
265
+ }
266
+ /**
267
+ * Copies an area of a render surface into a texture at the resolution of the surface.
268
+ * @param lastRenderSurface - The render surface to copy from.
269
+ * @param backTexture - The texture to copy to.
270
+ * @param bounds - The bounds of the area to copy.
271
+ * @param previousBounds - The previous bounds to use for offsetting the copy.
272
+ */
273
+ _copyBackTexture(lastRenderSurface, backTexture, bounds, previousBounds) {
274
+ const backgroundResolution = backTexture.source._resolution;
268
275
  let x = bounds.minX;
269
276
  let y = bounds.minY;
270
277
  if (previousBounds) {
271
278
  x -= previousBounds.minX;
272
279
  y -= previousBounds.minY;
273
280
  }
274
- x = Math.floor(x * backgroundResolution);
275
- y = Math.floor(y * backgroundResolution);
276
- const width = Math.ceil(bounds.width * backgroundResolution);
277
- const height = Math.ceil(bounds.height * backgroundResolution);
281
+ x = Math.floor(x * backgroundResolution + 1e-6);
282
+ y = Math.floor(y * backgroundResolution + 1e-6);
283
+ const width = Math.min(Math.ceil(bounds.width * backgroundResolution), backTexture.source.pixelWidth);
284
+ const height = Math.min(Math.ceil(bounds.height * backgroundResolution), backTexture.source.pixelHeight);
278
285
  this.renderer.renderTarget.copyToTexture(lastRenderSurface, backTexture, {
279
286
  x,
280
287
  y
@@ -298,14 +305,13 @@ var FilterSystem = class {
298
305
  const renderer = this.renderer;
299
306
  const filterData = this._activeFilterData;
300
307
  const isFinalTarget = filterData.outputRenderSurface === output;
301
- const rootResolution = renderer.renderTarget.rootRenderTarget.colorTexture.source._resolution;
302
- const resolution = this._findFilterResolution(rootResolution);
308
+ const closestFilterData = this._findClosestFilterData();
309
+ const resolution = closestFilterData ? closestFilterData.inputTexture.source._resolution : renderer.renderTarget.rootRenderTarget.colorTexture.source._resolution;
303
310
  let offsetX = 0;
304
311
  let offsetY = 0;
305
- if (isFinalTarget) {
306
- const offset = this._findPreviousFilterOffset();
307
- offsetX = offset.x;
308
- offsetY = offset.y;
312
+ if (isFinalTarget && closestFilterData) {
313
+ offsetX = closestFilterData.bounds.minX;
314
+ offsetY = closestFilterData.bounds.minY;
309
315
  }
310
316
  this._updateFilterUniforms(input, output, filterData, offsetX, offsetY, resolution, isFinalTarget, clear);
311
317
  const filterToApply = filter.enabled ? filter : this._getPassthroughFilter();
@@ -334,6 +340,18 @@ var FilterSystem = class {
334
340
  destroy() {
335
341
  this._passthroughFilter?.destroy(true);
336
342
  this._passthroughFilter = null;
343
+ TexturePool.off("evict", this._unbindPassTextures, this);
344
+ this._globalFilterBindGroup.destroy();
345
+ }
346
+ /**
347
+ * Swaps the last pass's textures in the filter bind group for the empty texture before the texture pool
348
+ * destroys idle textures, as a bind group warns when a texture bound to it is destroyed.
349
+ */
350
+ _unbindPassTextures() {
351
+ const bindGroup = this._globalFilterBindGroup;
352
+ bindGroup.setResource(Texture.EMPTY.source, 1);
353
+ bindGroup.setResource(Texture.EMPTY.source.style, 2);
354
+ bindGroup.setResource(Texture.EMPTY.source, 3);
337
355
  }
338
356
  _getPassthroughFilter() {
339
357
  this._passthroughFilter ?? (this._passthroughFilter = new PassthroughFilter());
@@ -370,11 +388,18 @@ var FilterSystem = class {
370
388
  */
371
389
  _setupFilterTextures(filterData, bounds, renderer, previousFilterData) {
372
390
  filterData.backTexture = Texture.EMPTY;
373
- filterData.inputTexture = TexturePool.getOptimalTexture(bounds.width, bounds.height, filterData.resolution, filterData.antialias);
391
+ filterData.inputTexture = TexturePool.getOptimalTexture({
392
+ width: bounds.width,
393
+ height: bounds.height,
394
+ resolution: filterData.resolution,
395
+ antialias: filterData.antialias
396
+ });
374
397
  if (filterData.blendRequired) {
375
398
  renderer.renderTarget.finishRenderPass();
376
399
  const renderTarget = renderer.renderTarget.getRenderTarget(filterData.outputRenderSurface);
377
- filterData.backTexture = this.getBackTexture(renderTarget, bounds, previousFilterData?.bounds);
400
+ const surfaceSource = renderTarget.colorTexture.source;
401
+ const backTexture = TexturePool.getAlignedTexture(filterData.inputTexture, surfaceSource._resolution, surfaceSource.format);
402
+ filterData.backTexture = this._copyBackTexture(renderTarget, backTexture, bounds, previousFilterData?.bounds);
378
403
  }
379
404
  renderer.renderTarget.bind({
380
405
  target: filterData.inputTexture,
@@ -383,22 +408,6 @@ var FilterSystem = class {
383
408
  renderer.globalUniforms.push({ offset: bounds });
384
409
  }
385
410
  /**
386
- * Calculates and sets the global frame for the filter.
387
- * @param filterData - The filter data to update
388
- * @param offsetX - The X offset
389
- * @param offsetY - The Y offset
390
- * @param globalResolution - The global resolution
391
- * @param sourceWidth - The source texture width
392
- * @param sourceHeight - The source texture height
393
- */
394
- _calculateGlobalFrame(filterData, offsetX, offsetY, globalResolution, sourceWidth, sourceHeight) {
395
- const globalFrame = filterData.globalFrame;
396
- globalFrame.x = offsetX * globalResolution;
397
- globalFrame.y = offsetY * globalResolution;
398
- globalFrame.width = sourceWidth * globalResolution;
399
- globalFrame.height = sourceHeight * globalResolution;
400
- }
401
- /**
402
411
  * Updates the filter uniforms with the current filter state.
403
412
  * @param input - The input texture
404
413
  * @param output - The output render surface
@@ -460,36 +469,18 @@ var FilterSystem = class {
460
469
  this._filterGlobalUniforms.update();
461
470
  }
462
471
  /**
463
- * Finds the correct resolution by looking back through the filter stack.
464
- * @param rootResolution - The fallback root resolution to use
465
- * @returns The resolution from the previous filter or root resolution
466
- */
467
- _findFilterResolution(rootResolution) {
468
- let currentIndex = this._filterStackIndex - 1;
469
- while (currentIndex > 0 && this._filterStack[currentIndex].skip) --currentIndex;
470
- return currentIndex > 0 && this._filterStack[currentIndex].inputTexture ? this._filterStack[currentIndex].inputTexture.source._resolution : rootResolution;
471
- }
472
- /**
473
- * Finds the offset from the previous non-skipped filter in the stack.
474
- * @returns The offset coordinates from the previous filter
472
+ * Finds the non-skipped entry closest to the top of the filter stack.
473
+ *
474
+ * `pop()` removes its entry before it applies the filters, so the result is the enclosing filter's entry.
475
+ * `generateFilteredTexture()` applies the filters while its entry is still on the stack, so the result is that entry.
476
+ * @returns The entry, or null if there is none
475
477
  */
476
- _findPreviousFilterOffset() {
477
- let offsetX = 0;
478
- let offsetY = 0;
479
- let lastIndex = this._filterStackIndex;
480
- while (lastIndex > 0) {
481
- lastIndex--;
482
- const prevFilterData = this._filterStack[lastIndex];
483
- if (!prevFilterData.skip) {
484
- offsetX = prevFilterData.bounds.minX;
485
- offsetY = prevFilterData.bounds.minY;
486
- break;
487
- }
478
+ _findClosestFilterData() {
479
+ for (let i = this._filterStackIndex - 1; i >= 0; i--) {
480
+ const filterData = this._filterStack[i];
481
+ if (!filterData.skip) return filterData;
488
482
  }
489
- return {
490
- x: offsetX,
491
- y: offsetY
492
- };
483
+ return null;
493
484
  }
494
485
  /**
495
486
  * Calculates the filter area bounds based on the instruction type.
@@ -519,7 +510,11 @@ var FilterSystem = class {
519
510
  if (firstEnabled === lastEnabled) filters[firstEnabled].apply(this, inputTexture, filterData.outputRenderSurface, clear);
520
511
  else {
521
512
  let flip = filterData.inputTexture;
522
- const tempTexture = TexturePool.getOptimalTexture(bounds.width, bounds.height, flip.source._resolution, false);
513
+ const tempTexture = TexturePool.getOptimalTexture({
514
+ width: bounds.width,
515
+ height: bounds.height,
516
+ resolution: flip.source._resolution
517
+ });
523
518
  let flop = tempTexture;
524
519
  for (let i = firstEnabled; i < lastEnabled; i++) {
525
520
  const filter = filters[i];
@@ -587,15 +582,18 @@ var FilterSystem = class {
587
582
  this._filterStackIndex--;
588
583
  return this._filterStack[this._filterStackIndex];
589
584
  }
585
+ /**
586
+ * Finds the closest non-skipped entry that encloses the filter being pushed.
587
+ *
588
+ * `push()` has already added that filter's own entry, so the search starts one entry below it.
589
+ * @returns The entry, or null if there is none
590
+ */
590
591
  _getPreviousFilterData() {
591
- let previousFilterData;
592
- let index = this._filterStackIndex - 1;
593
- while (index > 0) {
594
- index--;
595
- previousFilterData = this._filterStack[index];
596
- if (!previousFilterData.skip) break;
592
+ for (let i = this._filterStackIndex - 2; i >= 0; i--) {
593
+ const filterData = this._filterStack[i];
594
+ if (!filterData.skip) return filterData;
597
595
  }
598
- return previousFilterData;
596
+ return null;
599
597
  }
600
598
  _pushFilterData() {
601
599
  let filterData = this._filterStack[this._filterStackIndex];
@@ -610,7 +608,7 @@ FilterSystem.extension = {
610
608
  name: "filter"
611
609
  };
612
610
  //#endregion
613
- //#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/filters/init.mjs
611
+ //#region ../../node_modules/.pnpm/pixi.js@8.23.0/node_modules/pixi.js/lib/filters/init.mjs
614
612
  extensions.add(FilterSystem, CanvasFilterSystem);
615
613
  extensions.add(FilterPipe);
616
614
  //#endregion
@@ -1,5 +1,5 @@
1
1
  import { C as MODEL_THINKING_LEVELS, i as isApprovalMode, t as APPROVAL_MODES, w as isModelThinkingLevel, x as harnessSchema } from "./runtime.js";
2
- import { C as error, Ct as splitDisplayText, D as json, E as handleHttp, M as truncateText, N as warn, O as jsonRequested, St as normalizeDisplayPoint, T as formatLocalDateTime, _ as failSpaceTarget, _t as displayActStepSchema, b as resolveSpace, bt as DISPLAY_SYSTEM_ACTIONS, ct as buildSpaceInvitePath, dt as localWorkspaceHttpError, g as explicitSpace, gt as DISPLAY_RECORDINGS_DIR, ht as DISPLAY_HANDOVER_WAIT_MS, j as table, k as ok, mt as DISPLAY_HANDOVER_MAX_MS, pt as DISPLAY_HANDOVER_DEFAULT_MS, r as createRealtimeClient, t as createClient, ut as LocalWorkspaceUnavailableError, vt as DISPLAY_ELEMENT_REF_PATTERN, w as formatEpochMs, x as resolveSpaceRef, yt as DISPLAY_ELEMENT_ROLES } from "./client.js";
2
+ import { C as error, Ct as splitDisplayText, D as json, E as handleHttp, L as authSource, M as truncateText, N as warn, O as jsonRequested, St as normalizeDisplayPoint, T as formatLocalDateTime, _ as failSpaceTarget, _t as displayActStepSchema, b as resolveSpace, bt as DISPLAY_SYSTEM_ACTIONS, ct as buildSpaceInvitePath, dt as localWorkspaceHttpError, g as explicitSpace, gt as DISPLAY_RECORDINGS_DIR, ht as DISPLAY_HANDOVER_WAIT_MS, j as table, k as ok, mt as DISPLAY_HANDOVER_MAX_MS, pt as DISPLAY_HANDOVER_DEFAULT_MS, r as createRealtimeClient, t as createClient, ut as LocalWorkspaceUnavailableError, vt as DISPLAY_ELEMENT_REF_PATTERN, w as formatEpochMs, x as resolveSpaceRef, yt as DISPLAY_ELEMENT_ROLES } from "./client.js";
3
3
  import { n as uploadChatImageAsset, o as UPLOAD_MAX_FILE_BYTES, r as uploadLikeStickerAsset, t as uploadAvatarAsset } from "./avatar.js";
4
4
  import { o as mimeTypeForPath } from "./id.js";
5
5
  import { d as normalizeRequestSource, l as joinApiUrl, p as isUuidLike } from "./app-realtime.js";
@@ -278,7 +278,8 @@ const SESSION_TURN_ORIGIN_KINDS = [
278
278
  "prompt",
279
279
  "scheduled_prompt",
280
280
  "background_task",
281
- "hook"
281
+ "hook",
282
+ "reply"
282
283
  ];
283
284
  const record$1 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : null;
284
285
  const normalizeSessionTurnOrigin = (value) => {
@@ -292,7 +293,7 @@ const normalizeSessionTurnOrigin = (value) => {
292
293
  sessionId: source.sessionId,
293
294
  turnId: source.turnId,
294
295
  ...source.toolCallId ? { toolCallId: source.toolCallId } : {},
295
- ...typeof input.depth === "number" && Number.isSafeInteger(input.depth) && input.depth > 0 ? { depth: input.depth } : {}
296
+ ...typeof input.depth === "number" && Number.isSafeInteger(input.depth) && input.depth >= 0 ? { depth: input.depth } : {}
296
297
  };
297
298
  };
298
299
  /** Reads durable provenance; legacy background tasks only knew their caller's Session/Turn. */
@@ -310,6 +311,9 @@ const readSessionTurnOrigin = (meta, spaceId) => {
310
311
  });
311
312
  };
312
313
  //#endregion
314
+ //#region ../protocol/src/turn-reply.ts
315
+ const isSessionTurnReplyMode = (value) => value === "note" || value === "prompt";
316
+ //#endregion
313
317
  //#region ../protocol/src/sent-turns.ts
314
318
  const record = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : null;
315
319
  const normalizeSentTurnRef = (value) => {
@@ -327,7 +331,8 @@ const normalizeSentTurnRef = (value) => {
327
331
  sessionId: input.sessionId,
328
332
  turnId: input.turnId,
329
333
  kind,
330
- ...source?.toolCallId ? { toolCallId: source.toolCallId } : {}
334
+ ...source?.toolCallId ? { toolCallId: source.toolCallId } : {},
335
+ ...isSessionTurnReplyMode(input.reply) ? { reply: input.reply } : {}
331
336
  };
332
337
  };
333
338
  /** Deduplicates by child Turn, so a retried request cannot render one twice. */
@@ -345,6 +350,23 @@ const readSentTurns = (meta) => {
345
350
  return refs;
346
351
  };
347
352
  //#endregion
353
+ //#region ../protocol/src/speech.ts
354
+ function isRecord(value) {
355
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
356
+ }
357
+ function readSegments(value) {
358
+ if (!Array.isArray(value) || value.length === 0) return null;
359
+ return value.every((segment) => isRecord(segment) && typeof segment.taskId === "string" && (segment.status === "pending" || segment.status === "completed" || segment.status === "failed") && (segment.url === void 0 || typeof segment.url === "string")) ? value : null;
360
+ }
361
+ function readTurnSpeech(meta, voice) {
362
+ const speech = isRecord(meta) && isRecord(meta.speech) ? meta.speech : null;
363
+ const segments = speech ? readSegments(speech[voice]) : null;
364
+ return segments ? {
365
+ voice,
366
+ segments
367
+ } : null;
368
+ }
369
+ //#endregion
348
370
  //#region src/space-files/limit.ts
349
371
  function createLimiter(concurrency) {
350
372
  let active = 0;
@@ -1536,6 +1558,7 @@ function registerSpaceWallet(spaces) {
1536
1558
  ]);
1537
1559
  console.log(`Public funding: ${value.publicFunding ? "on" : "off"}`);
1538
1560
  if (value.transfer) console.log(`Transferable balance: ${usd(value.transfer.allowanceUsd)} (whole dollars, ${usd(value.transfer.minUsd)}–${usd(value.transfer.maxUsd)})`);
1561
+ else console.log(authSource() === "execution-token" ? "Transferable balance: requires a signed-in user session (unset COHUB_EXECUTION_TOKEN, then run `cohub auth login`)" : "Transferable balance: unavailable");
1539
1562
  } catch (cause) {
1540
1563
  handleHttp(cause);
1541
1564
  }
@@ -3258,11 +3281,12 @@ async function confirmRestart(opts) {
3258
3281
  }
3259
3282
  async function sendPrompt(command, words, opts) {
3260
3283
  const content = await readPromptContent(words, { allowEmpty: Boolean(opts.image?.length) });
3261
- if ([
3284
+ const scheduleFlags = [
3262
3285
  opts.delayMs,
3263
3286
  opts.at,
3264
3287
  opts.cron
3265
- ].filter((value) => value !== void 0).length > 1) return error("Conflicting schedule", "Use only one of --delay-ms, --at, or --cron");
3288
+ ].filter((value) => value !== void 0);
3289
+ if (scheduleFlags.length > 1) return error("Conflicting schedule", "Use only one of --delay-ms, --at, or --cron");
3266
3290
  if (opts.cron && !opts.timezone) return error("Missing timezone", "--timezone is required with --cron");
3267
3291
  if (opts.note) {
3268
3292
  const agentOnly = Object.entries({
@@ -3281,6 +3305,7 @@ async function sendPrompt(command, words, opts) {
3281
3305
  }).flatMap(([flag, value]) => value ? [flag] : []);
3282
3306
  if (agentOnly.length) return error("Conflicting options", `--note cannot be combined with ${agentOnly.join(", ")}`);
3283
3307
  }
3308
+ if (opts.reply && (opts.note || scheduleFlags.length)) return error("Conflicting options", "--reply cannot be combined with --note or scheduling");
3284
3309
  const requestedThinkingLevel = opts.thinkingLevel?.trim() || void 0;
3285
3310
  const thinkingLevel = isModelThinkingLevel(requestedThinkingLevel) ? requestedThinkingLevel : void 0;
3286
3311
  if (requestedThinkingLevel && !thinkingLevel) return error("Invalid thinking level", `Use ${MODEL_THINKING_LEVELS.join("|")}`);
@@ -3345,10 +3370,14 @@ async function sendPrompt(command, words, opts) {
3345
3370
  intent: opts.steer ? "steer" : void 0,
3346
3371
  env: parseEnvOptions(opts.env),
3347
3372
  schedule,
3348
- labelRefs: opts.label?.length ? opts.label : void 0
3373
+ labelRefs: opts.label?.length ? opts.label : void 0,
3374
+ ...opts.reply ? { reply: "prompt" } : {}
3349
3375
  });
3350
3376
  if (jsonRequested(opts)) return json(result);
3351
- if (result.mode === "immediate") return ok(`${opts.note ? "Note recorded" : "Prompt sent"} — sessionId: ${result.session.id}, turnId: ${result.turn.id}`);
3377
+ if (result.mode === "immediate") {
3378
+ const label = opts.note ? "Note recorded" : opts.reply ? "Prompt sent; the reply will come back to this Chat" : "Prompt sent";
3379
+ return ok(`${label} — sessionId: ${result.session.id}, turnId: ${result.turn.id}`);
3380
+ }
3352
3381
  if (result.mode === "repeat") return ok(`Prompt scheduled — cronJobId: ${result.cronJobId}, nextRunAt: ${result.nextRunAt}`);
3353
3382
  return ok(`Prompt scheduled — taskRunId: ${result.taskRunId}, scheduledAt: ${result.scheduledAt}`);
3354
3383
  } catch (e) {
@@ -3417,7 +3446,7 @@ async function runCompletionCommand(command, words, opts) {
3417
3446
  }
3418
3447
  }
3419
3448
  function registerPrompt(program) {
3420
- program.command("prompt [content...]").description("Send or schedule a prompt in a space").option("--session <id>", "Target session ID").option("--title <title>", "Title for a newly created session or schedule").option("-m, --model <model>", "Model name").option("-p, --provider <provider>", "Provider name").option("--harness <harness>", `Harness: ${harnessSchema.options.join(", ")}`, "cohub").option("--thinking-level <level>", `Thinking level: ${MODEL_THINKING_LEVELS.join("|")}`).option("--context-window <tokens>", "Context window for this session from this prompt on; capped at the platform value").option("--approval-mode <mode>", `Local Harness approval mode: ${APPROVAL_MODES.join("|")}`).option("--service-tier <tier>", "Local Harness service tier, e.g. priority for Codex Fast").option("--read-only", "Use read-only tools").option("--steer", "Interrupt the current turn and run immediately").option("--delay-ms <ms>", "Delay sending by milliseconds").option("--at <iso>", "Send once at an ISO 8601 time with timezone").option("--cron <expression>", "Repeat using a 5-field cron expression").option("--timezone <tz>", "IANA timezone for --cron, e.g. Asia/Shanghai").option("--label <ref>", "Attach a label, e.g. Bug or Area/Frontend", collectOption, []).option("--env <key=value>", "Set an environment variable for this turn", collectOption, []).option("--image <path>", "Attach an image", collectOption, []).option("--note", "Record the message without an AI reply").option("--json", "Output as JSON").action((words, opts) => sendPrompt(program, words, opts));
3449
+ program.command("prompt [content...]").description("Send or schedule a prompt in a space").option("--session <id>", "Target session ID").option("--title <title>", "Title for a newly created session or schedule").option("-m, --model <model>", "Model name").option("-p, --provider <provider>", "Provider name").option("--harness <harness>", `Harness: ${harnessSchema.options.join(", ")}`, "cohub").option("--thinking-level <level>", `Thinking level: ${MODEL_THINKING_LEVELS.join("|")}`).option("--context-window <tokens>", "Context window for this session from this prompt on; capped at the platform value").option("--approval-mode <mode>", `Local Harness approval mode: ${APPROVAL_MODES.join("|")}`).option("--service-tier <tier>", "Local Harness service tier, e.g. priority for Codex Fast").option("--read-only", "Use read-only tools").option("--steer", "Interrupt the current turn and run immediately").option("--delay-ms <ms>", "Delay sending by milliseconds").option("--at <iso>", "Send once at an ISO 8601 time with timezone").option("--cron <expression>", "Repeat using a 5-field cron expression").option("--timezone <tz>", "IANA timezone for --cron, e.g. Asia/Shanghai").option("--label <ref>", "Attach a label, e.g. Bug or Area/Frontend", collectOption, []).option("--env <key=value>", "Set an environment variable for this turn", collectOption, []).option("--image <path>", "Attach an image", collectOption, []).option("--note", "Record the message without an AI reply").option("--reply", "Send the final reply back to the calling Chat and run its Agent").option("--json", "Output as JSON").action((words, opts) => sendPrompt(program, words, opts));
3421
3450
  program.command("completion [content...]").description("Raw LLM completion with full message control").option("-m, --model <model>", "Model name").option("-p, --provider <provider>", "Provider name").option("--system-prompt <path>", "Space-relative system prompt markdown path").option("--stream", "Stream tokens via SSE").option("--temperature <n>", "Sampling temperature").option("--max-tokens <n>", "Maximum output tokens").option("--thinking-level <level>", "Thinking level: off|minimal|low|medium|high|xhigh").option("--json", "Output as JSON").action((words, opts) => runCompletionCommand(program, words, opts));
3422
3451
  registerDecisionCommand(program);
3423
3452
  }
@@ -3855,7 +3884,7 @@ function registerSpaces(program) {
3855
3884
  handleHttp(e);
3856
3885
  }
3857
3886
  });
3858
- spacesCmd.command("prompt [content...]", { hidden: true }).alias("send").description("Send or schedule a prompt in the target space").option("--harness <harness>", `Harness: ${harnessSchema.options.join(", ")}`, "cohub").option("--session <id>", "Target session ID").option("--title <title>", "Title for a newly created session or schedule").option("-m, --model <model>", "Model name").option("-p, --provider <provider>", "Provider name").option("--thinking-level <level>", `Thinking level: ${MODEL_THINKING_LEVELS.join("|")}`).option("--context-window <tokens>", "Context window for this session from this prompt on; capped at the platform value").option("--approval-mode <mode>", `Local Harness approval mode: ${APPROVAL_MODES.join("|")}`).option("--service-tier <tier>", "Local Harness service tier, e.g. priority for Codex Fast").option("--read-only", "Use read-only tools").option("--steer", "Interrupt the current turn and run immediately").option("--delay-ms <ms>", "Delay sending by milliseconds").option("--at <iso>", "Send once at an ISO 8601 time with timezone").option("--cron <expression>", "Repeat using a 5-field cron expression").option("--timezone <tz>", "IANA timezone for --cron, e.g. Asia/Shanghai").option("--label <ref>", "Attach a label, e.g. Bug or Area/Frontend", collectOption, []).option("--env <key=value>", "Set an environment variable for this turn", collectOption, []).option("--image <path>", "Attach an image", collectOption, []).option("--note", "Record the message without an AI reply").option("--json", "Output as JSON").action((words, opts) => sendPrompt(spacesCmd, words, opts));
3887
+ spacesCmd.command("prompt [content...]", { hidden: true }).alias("send").description("Send or schedule a prompt in the target space").option("--harness <harness>", `Harness: ${harnessSchema.options.join(", ")}`, "cohub").option("--session <id>", "Target session ID").option("--title <title>", "Title for a newly created session or schedule").option("-m, --model <model>", "Model name").option("-p, --provider <provider>", "Provider name").option("--thinking-level <level>", `Thinking level: ${MODEL_THINKING_LEVELS.join("|")}`).option("--context-window <tokens>", "Context window for this session from this prompt on; capped at the platform value").option("--approval-mode <mode>", `Local Harness approval mode: ${APPROVAL_MODES.join("|")}`).option("--service-tier <tier>", "Local Harness service tier, e.g. priority for Codex Fast").option("--read-only", "Use read-only tools").option("--steer", "Interrupt the current turn and run immediately").option("--delay-ms <ms>", "Delay sending by milliseconds").option("--at <iso>", "Send once at an ISO 8601 time with timezone").option("--cron <expression>", "Repeat using a 5-field cron expression").option("--timezone <tz>", "IANA timezone for --cron, e.g. Asia/Shanghai").option("--label <ref>", "Attach a label, e.g. Bug or Area/Frontend", collectOption, []).option("--env <key=value>", "Set an environment variable for this turn", collectOption, []).option("--image <path>", "Attach an image", collectOption, []).option("--note", "Record the message without an AI reply").option("--reply", "Send the final reply back to the calling Chat and run its Agent").option("--json", "Output as JSON").action((words, opts) => sendPrompt(spacesCmd, words, opts));
3859
3888
  spacesCmd.command("completion [content...]").description("Raw LLM completion with full message control").option("-m, --model <model>", "Model name").option("-p, --provider <provider>", "Provider name").option("--system-prompt <path>", "Space-relative system prompt markdown path").option("--stream", "Stream tokens via SSE").option("--temperature <n>", "Sampling temperature").option("--max-tokens <n>", "Maximum output tokens").option("--thinking-level <level>", "Thinking level: off|minimal|low|medium|high|xhigh").option("--json", "Output as JSON").action((words, opts) => runCompletionCommand(spacesCmd, words, opts));
3860
3889
  registerDecisionCommand(spacesCmd);
3861
3890
  registerFiles(spacesCmd);
@@ -4735,6 +4764,23 @@ function registerTurns(sessionsCmd) {
4735
4764
  handleHttp(e);
4736
4765
  }
4737
4766
  });
4767
+ turnsCmd.command("speak <sessionId> <turnId>").description("Read a turn's reply aloud with the configured voice and print the audio URLs").option("--no-wait", "Return without waiting for audio still being rendered").option("--json", "Output as JSON").action(async (sessionId, turnId, opts) => {
4768
+ const spaceId = await resolveSpace(sessionsCmd);
4769
+ const session = createClient().space(spaceId).session(sessionId);
4770
+ try {
4771
+ let { speech } = await session.turn(turnId).speak();
4772
+ const deadline = Date.now() + 3e5;
4773
+ while (opts.wait && speech.segments.some((segment) => segment.status === "pending") && Date.now() < deadline) {
4774
+ await new Promise((resolve) => setTimeout(resolve, 2e3));
4775
+ speech = readTurnSpeech((await session.turns.get(turnId)).turn.meta, speech.voice) ?? speech;
4776
+ }
4777
+ if (speech.segments.some((segment) => segment.status !== "completed")) process.exitCode = 1;
4778
+ if (jsonRequested(opts)) return json(speech);
4779
+ for (const [index, segment] of speech.segments.entries()) console.log(segment.url ?? ` Segment ${index + 1}: ${segment.status}`);
4780
+ } catch (e) {
4781
+ handleHttp(e);
4782
+ }
4783
+ });
4738
4784
  turnsCmd.command("index <sessionId>", { hidden: true }).description("List lightweight turn index").option("--cursor <sequence>", "Turn sequence cursor").option("--limit <n>", "Page size", "100").option("--json", "Output as JSON").action(async (sessionId, opts) => {
4739
4785
  const spaceId = await resolveSpace(sessionsCmd);
4740
4786
  const client = createClient();
@@ -1,3 +1,3 @@
1
- import "./Geometry.js";
1
+ import "./FilterPipe.js";
2
2
  import "./init.js";
3
3
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neta-art/cohub-cli",
3
- "version": "10.28.0",
3
+ "version": "10.29.0",
4
4
  "description": "CLI for Cohub — spaces, sessions, and agent collaboration.",
5
5
  "type": "module",
6
6
  "engines": {
@@ -33,11 +33,11 @@
33
33
  "@fontsource-variable/figtree": "^5.3.0",
34
34
  "@fontsource-variable/geist": "^5.3.0",
35
35
  "@fontsource-variable/geist-mono": "^5.3.0",
36
- "@neta-art/cohub": "13.19.0",
36
+ "@neta-art/cohub": "13.21.0",
37
37
  "@types/node": "26.6.4",
38
38
  "@types/ws": "^8.18.1",
39
39
  "commander": "^15.0.0",
40
- "pixi.js": "^8.20.1",
40
+ "pixi.js": "^8.23.0",
41
41
  "tsdown": "^0.22.14",
42
42
  "typescript": "^7.0.2",
43
43
  "ws": "^8.21.3"