@gajae-code/coding-agent 0.8.0 → 0.8.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.
- package/CHANGELOG.md +48 -0
- package/dist/types/cli/completion-cli.d.ts +41 -0
- package/dist/types/cli/config-cli.d.ts +1 -0
- package/dist/types/cli/notify-cli.d.ts +7 -0
- package/dist/types/cli.d.ts +124 -1
- package/dist/types/commands/completion.d.ts +29 -0
- package/dist/types/commands/config.d.ts +3 -0
- package/dist/types/commands/deep-interview.d.ts +3 -0
- package/dist/types/config/file-lock.d.ts +7 -6
- package/dist/types/config/keybindings.d.ts +2 -2
- package/dist/types/config/model-profile-activation.d.ts +6 -0
- package/dist/types/config/settings.d.ts +8 -0
- package/dist/types/extensibility/extensions/runner.d.ts +2 -1
- package/dist/types/extensibility/extensions/types.d.ts +8 -0
- package/dist/types/gjc-runtime/deep-interview-ambiguity.d.ts +39 -0
- package/dist/types/gjc-runtime/deep-interview-recorder.d.ts +10 -1
- package/dist/types/gjc-runtime/deep-interview-runtime.d.ts +1 -1
- package/dist/types/gjc-runtime/deep-interview-state.d.ts +12 -0
- package/dist/types/gjc-runtime/team-runtime.d.ts +2 -1
- package/dist/types/gjc-runtime/ultragoal-runtime.d.ts +1 -0
- package/dist/types/main.d.ts +4 -1
- package/dist/types/modes/components/model-selector.d.ts +4 -0
- package/dist/types/modes/components/queued-message-selector.d.ts +12 -0
- package/dist/types/modes/components/settings-selector.d.ts +2 -0
- package/dist/types/modes/controllers/input-controller.d.ts +1 -3
- package/dist/types/modes/print-mode.d.ts +13 -1
- package/dist/types/modes/prompt-action-autocomplete.d.ts +1 -1
- package/dist/types/notifications/config.d.ts +8 -1
- package/dist/types/notifications/daemon-paths.d.ts +1 -0
- package/dist/types/notifications/index.d.ts +6 -3
- package/dist/types/notifications/lifecycle-commands.d.ts +11 -3
- package/dist/types/notifications/telegram-daemon.d.ts +18 -3
- package/dist/types/notifications/telegram-reference.d.ts +0 -5
- package/dist/types/runtime-api-key.d.ts +7 -0
- package/dist/types/session/agent-session.d.ts +10 -0
- package/dist/types/session/agent-storage.d.ts +1 -0
- package/dist/types/task/executor.d.ts +2 -0
- package/dist/types/tools/computer.d.ts +2 -2
- package/dist/types/tools/skill.d.ts +1 -1
- package/dist/types/workflow/workflow-intent-diff.d.ts +8 -2
- package/dist/types/workflow/workflow-intent-report-consumer.d.ts +50 -0
- package/dist/types/workflow/workflow-intent-report-schema.d.ts +2 -0
- package/dist/types/workflow/workflow-intent-report.d.ts +48 -0
- package/package.json +7 -7
- package/src/cli/completion-cli.ts +234 -0
- package/src/cli/config-cli.ts +37 -9
- package/src/cli/fast-help.ts +1 -0
- package/src/cli/notify-cli.ts +91 -7
- package/src/cli.ts +3 -1
- package/src/commands/completion.ts +84 -0
- package/src/commands/config.ts +2 -0
- package/src/commands/deep-interview.ts +2 -1
- package/src/config/file-lock.ts +73 -34
- package/src/config/keybindings.ts +2 -2
- package/src/config/model-profile-activation.ts +65 -0
- package/src/config/model-registry.ts +14 -2
- package/src/config/settings.ts +22 -0
- package/src/coordinator-mcp/server.ts +67 -12
- package/src/defaults/gjc/skills/deep-interview/SKILL.md +38 -5
- package/src/defaults/gjc/skills/ralplan/SKILL.md +15 -11
- package/src/defaults/gjc/skills/team/SKILL.md +1 -1
- package/src/extensibility/extensions/runner.ts +2 -0
- package/src/extensibility/extensions/types.ts +9 -0
- package/src/extensibility/skills.ts +30 -2
- package/src/gjc-runtime/deep-interview-ambiguity.ts +206 -0
- package/src/gjc-runtime/deep-interview-recorder.ts +62 -8
- package/src/gjc-runtime/deep-interview-runtime.ts +210 -2
- package/src/gjc-runtime/deep-interview-state.ts +13 -0
- package/src/gjc-runtime/session-state-sidecar.ts +59 -11
- package/src/gjc-runtime/state-runtime.ts +12 -2
- package/src/gjc-runtime/team-runtime.ts +23 -0
- package/src/gjc-runtime/ultragoal-runtime.ts +73 -19
- package/src/hooks/native-skill-hook.ts +29 -0
- package/src/internal-urls/docs-index.generated.ts +2 -2
- package/src/main.ts +52 -41
- package/src/modes/acp/acp-agent.ts +7 -6
- package/src/modes/components/model-selector.ts +54 -11
- package/src/modes/components/queued-message-selector.ts +92 -0
- package/src/modes/components/settings-selector.ts +4 -0
- package/src/modes/components/welcome.ts +160 -44
- package/src/modes/controllers/command-controller.ts +4 -4
- package/src/modes/controllers/extension-ui-controller.ts +4 -10
- package/src/modes/controllers/input-controller.ts +186 -25
- package/src/modes/controllers/selector-controller.ts +122 -27
- package/src/modes/interactive-mode.ts +43 -16
- package/src/modes/print-mode.ts +43 -4
- package/src/modes/prompt-action-autocomplete.ts +24 -13
- package/src/modes/utils/hotkeys-markdown.ts +1 -0
- package/src/modes/utils/ui-helpers.ts +2 -2
- package/src/notifications/config.ts +9 -1
- package/src/notifications/daemon-paths.ts +2 -0
- package/src/notifications/index.ts +39 -9
- package/src/notifications/lifecycle-commands.ts +37 -7
- package/src/notifications/lifecycle-orchestrator.ts +19 -6
- package/src/notifications/telegram-daemon-control.ts +3 -1
- package/src/notifications/telegram-daemon.ts +231 -43
- package/src/notifications/telegram-reference.ts +0 -16
- package/src/prompts/system/system-prompt.md +3 -0
- package/src/prompts/tools/computer.md +2 -2
- package/src/runtime-api-key.ts +16 -0
- package/src/sdk.ts +20 -6
- package/src/session/agent-session.ts +225 -31
- package/src/session/agent-storage.ts +4 -0
- package/src/session/session-manager.ts +44 -2
- package/src/slash-commands/builtin-registry.ts +153 -71
- package/src/task/executor.ts +7 -4
- package/src/task/index.ts +9 -3
- package/src/task/output-manager.ts +16 -6
- package/src/task/receipt.ts +26 -7
- package/src/tools/computer.ts +246 -43
- package/src/tools/skill.ts +1 -1
- package/src/tools/telegram-send.ts +6 -0
- package/src/workflow/workflow-intent-diff.ts +29 -6
- package/src/workflow/workflow-intent-report-consumer.ts +221 -0
- package/src/workflow/workflow-intent-report-schema.ts +129 -0
- package/src/workflow/workflow-intent-report.ts +135 -0
package/src/tools/computer.ts
CHANGED
|
@@ -98,7 +98,7 @@ export interface ComputerScreenshotDetails {
|
|
|
98
98
|
scaleY?: number;
|
|
99
99
|
originX?: number;
|
|
100
100
|
originY?: number;
|
|
101
|
-
displayEpoch?:
|
|
101
|
+
displayEpoch?: number;
|
|
102
102
|
captureId?: string;
|
|
103
103
|
pngBytes?: number;
|
|
104
104
|
path?: string;
|
|
@@ -144,7 +144,7 @@ type NativeScreenshot = {
|
|
|
144
144
|
scaleY?: number;
|
|
145
145
|
originX?: number;
|
|
146
146
|
originY?: number;
|
|
147
|
-
displayEpoch?:
|
|
147
|
+
displayEpoch?: number;
|
|
148
148
|
captureId?: string;
|
|
149
149
|
};
|
|
150
150
|
|
|
@@ -175,6 +175,7 @@ let controllerFactory: ComputerControllerFactory = createNativeComputerControlle
|
|
|
175
175
|
let platformOverrideForTests: NodeJS.Platform | undefined;
|
|
176
176
|
let archOverrideForTests: NodeJS.Architecture | undefined;
|
|
177
177
|
const screenshotFallbackDirs = new WeakMap<ToolSession, Promise<string>>();
|
|
178
|
+
const latestScreenshotContexts = new WeakMap<ToolSession, ScreenshotContext>();
|
|
178
179
|
|
|
179
180
|
const COMPUTER_INLINE_SCREENSHOT_MAX_WIDTH = 1568;
|
|
180
181
|
const COMPUTER_INLINE_SCREENSHOT_MAX_HEIGHT = 1568;
|
|
@@ -275,12 +276,24 @@ export class ComputerTool implements AgentTool<typeof computerSchema, ComputerTo
|
|
|
275
276
|
const timeoutSeconds = clampTimeout("computer", params.timeout);
|
|
276
277
|
const timeoutMs = timeoutSeconds > 0 ? timeoutSeconds * 1000 : undefined;
|
|
277
278
|
const controller = controllerFactory();
|
|
278
|
-
|
|
279
|
-
// so cancellation is honored before dispatch and wait() is bounded by timeoutMs.
|
|
279
|
+
const deadline = createComputerDeadline(timeoutMs);
|
|
280
280
|
if (params.action === "batch") {
|
|
281
|
-
const batchResult = await dispatchBatchComputerActions(
|
|
281
|
+
const batchResult = await dispatchBatchComputerActions(
|
|
282
|
+
controller,
|
|
283
|
+
params.actions,
|
|
284
|
+
timeoutMs,
|
|
285
|
+
hotkey,
|
|
286
|
+
latestScreenshotContexts.get(this.session),
|
|
287
|
+
shouldCapturePostActionScreenshot(params, this.session),
|
|
288
|
+
Boolean(this.session.settings.get("computer.autoScreenshot")),
|
|
289
|
+
signal,
|
|
290
|
+
deadline,
|
|
291
|
+
);
|
|
282
292
|
details.steps = batchResult.steps;
|
|
283
|
-
if (batchResult.screenshot)
|
|
293
|
+
if (batchResult.screenshot) {
|
|
294
|
+
details.screenshot = batchResult.screenshot;
|
|
295
|
+
rememberLatestScreenshot(this.session, batchResult.screenshot);
|
|
296
|
+
}
|
|
284
297
|
details.status = batchResult.failedStep ? "error" : "success";
|
|
285
298
|
if (batchResult.failedStep) {
|
|
286
299
|
details.code = batchResult.failedStep.code;
|
|
@@ -307,9 +320,21 @@ export class ComputerTool implements AgentTool<typeof computerSchema, ComputerTo
|
|
|
307
320
|
.done()
|
|
308
321
|
: toolResult(details).text(details.message).done();
|
|
309
322
|
}
|
|
310
|
-
|
|
323
|
+
let result = await dispatchComputerAction(
|
|
324
|
+
controller,
|
|
325
|
+
params,
|
|
326
|
+
deadline,
|
|
327
|
+
latestScreenshotContexts.get(this.session),
|
|
328
|
+
signal,
|
|
329
|
+
);
|
|
330
|
+
if (shouldCapturePostActionScreenshot(params, this.session)) {
|
|
331
|
+
result = await captureScreenshot(controller, deadline, signal);
|
|
332
|
+
}
|
|
311
333
|
const screenshot = normalizeScreenshot(result);
|
|
312
|
-
if (screenshot)
|
|
334
|
+
if (screenshot) {
|
|
335
|
+
details.screenshot = screenshot;
|
|
336
|
+
rememberLatestScreenshot(this.session, screenshot);
|
|
337
|
+
}
|
|
313
338
|
details.status = "success";
|
|
314
339
|
details.message = describeComputerSuccess(details);
|
|
315
340
|
if (screenshot) {
|
|
@@ -342,6 +367,10 @@ interface CoordinateBounds {
|
|
|
342
367
|
originY?: number;
|
|
343
368
|
}
|
|
344
369
|
|
|
370
|
+
interface ScreenshotContext extends CoordinateBounds {
|
|
371
|
+
displayEpoch?: number;
|
|
372
|
+
}
|
|
373
|
+
|
|
345
374
|
function validatePointerCoordinates(action: string, x: number, y: number, bounds: CoordinateBounds | undefined): void {
|
|
346
375
|
if (!bounds) return;
|
|
347
376
|
const minX = bounds.originX ?? 0;
|
|
@@ -355,42 +384,189 @@ function validatePointerCoordinates(action: string, x: number, y: number, bounds
|
|
|
355
384
|
}
|
|
356
385
|
}
|
|
357
386
|
|
|
358
|
-
function
|
|
387
|
+
function expectedEpochFromContext(context: ScreenshotContext | undefined): number | undefined {
|
|
388
|
+
return typeof context?.displayEpoch === "number" &&
|
|
389
|
+
Number.isFinite(context.displayEpoch) &&
|
|
390
|
+
context.displayEpoch >= 0
|
|
391
|
+
? context.displayEpoch
|
|
392
|
+
: undefined;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
function rememberLatestScreenshot(session: ToolSession, screenshot: ComputerScreenshotDetails): void {
|
|
396
|
+
latestScreenshotContexts.set(session, {
|
|
397
|
+
widthPx: screenshot.widthPx,
|
|
398
|
+
heightPx: screenshot.heightPx,
|
|
399
|
+
originX: screenshot.originX,
|
|
400
|
+
originY: screenshot.originY,
|
|
401
|
+
displayEpoch: screenshot.displayEpoch,
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
function captureScreenshot(
|
|
359
406
|
controller: NativeController,
|
|
360
|
-
|
|
407
|
+
deadline: ComputerDeadline | undefined,
|
|
408
|
+
signal?: AbortSignal,
|
|
409
|
+
): Promise<unknown> {
|
|
410
|
+
return runComputerOperation(
|
|
411
|
+
() => {
|
|
412
|
+
if (!controller.screenshot) missingNativeMethod("screenshot", "screenshot");
|
|
413
|
+
return controller.screenshot();
|
|
414
|
+
},
|
|
415
|
+
deadline,
|
|
416
|
+
signal,
|
|
417
|
+
);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
function missingNativeMethod(action: string, method: string): never {
|
|
421
|
+
throw new ToolError(`COMPUTER_UNAVAILABLE: Native ComputerController.${method} is unavailable for ${action}.`, {
|
|
422
|
+
code: "COMPUTER_UNAVAILABLE",
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
function shouldCapturePostActionScreenshot(
|
|
427
|
+
params: Pick<ComputerParams, "action" | "include_screenshot">,
|
|
428
|
+
session: Pick<ToolSession, "settings">,
|
|
429
|
+
): boolean {
|
|
430
|
+
return (
|
|
431
|
+
params.action !== "screenshot" &&
|
|
432
|
+
(params.include_screenshot === true || Boolean(session.settings.get("computer.autoScreenshot")))
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
interface ComputerDeadline {
|
|
437
|
+
expiresAtMs: number;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
class ComputerTimeoutError extends Error {
|
|
441
|
+
constructor() {
|
|
442
|
+
super("Computer action timed out.");
|
|
443
|
+
this.name = "TimeoutError";
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
function createComputerDeadline(
|
|
361
448
|
timeoutMs: number | undefined,
|
|
362
|
-
|
|
363
|
-
):
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
449
|
+
parent?: ComputerDeadline,
|
|
450
|
+
): ComputerDeadline | undefined {
|
|
451
|
+
const localExpiresAt = timeoutMs && timeoutMs > 0 ? performance.now() + timeoutMs : undefined;
|
|
452
|
+
const parentExpiresAt = parent?.expiresAtMs;
|
|
453
|
+
const expiresAtMs =
|
|
454
|
+
localExpiresAt === undefined
|
|
455
|
+
? parentExpiresAt
|
|
456
|
+
: parentExpiresAt === undefined
|
|
457
|
+
? localExpiresAt
|
|
458
|
+
: Math.min(localExpiresAt, parentExpiresAt);
|
|
459
|
+
return expiresAtMs === undefined ? undefined : { expiresAtMs };
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
function remainingComputerTimeoutMs(deadline: ComputerDeadline | undefined): number | undefined {
|
|
463
|
+
if (!deadline) return undefined;
|
|
464
|
+
const remaining = Math.ceil(deadline.expiresAtMs - performance.now());
|
|
465
|
+
if (remaining <= 0) throw new ComputerTimeoutError();
|
|
466
|
+
return remaining;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
function assertComputerDeadline(deadline: ComputerDeadline | undefined): void {
|
|
470
|
+
remainingComputerTimeoutMs(deadline);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
async function runComputerOperation<T>(
|
|
474
|
+
operation: () => Promise<T> | T,
|
|
475
|
+
deadline: ComputerDeadline | undefined,
|
|
476
|
+
signal?: AbortSignal,
|
|
477
|
+
): Promise<T> {
|
|
478
|
+
throwIfAborted(signal);
|
|
479
|
+
const timeoutMs = remainingComputerTimeoutMs(deadline);
|
|
480
|
+
let timeout: ReturnType<typeof setTimeout> | undefined;
|
|
481
|
+
let removeAbortListener: (() => void) | undefined;
|
|
482
|
+
const operationPromise = Promise.resolve().then(operation);
|
|
483
|
+
operationPromise.catch(() => undefined);
|
|
484
|
+
const guards: Array<Promise<never>> = [];
|
|
485
|
+
if (timeoutMs !== undefined) {
|
|
486
|
+
guards.push(
|
|
487
|
+
new Promise((_, reject) => {
|
|
488
|
+
timeout = setTimeout(() => reject(new ComputerTimeoutError()), timeoutMs);
|
|
489
|
+
}),
|
|
490
|
+
);
|
|
491
|
+
}
|
|
492
|
+
if (signal) {
|
|
493
|
+
guards.push(
|
|
494
|
+
new Promise((_, reject) => {
|
|
495
|
+
const onAbort = () => reject(new ToolAbortError());
|
|
496
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
497
|
+
removeAbortListener = () => signal.removeEventListener("abort", onAbort);
|
|
498
|
+
}),
|
|
499
|
+
);
|
|
500
|
+
}
|
|
501
|
+
try {
|
|
502
|
+
const result = await (guards.length > 0 ? Promise.race([operationPromise, ...guards]) : operationPromise);
|
|
503
|
+
throwIfAborted(signal);
|
|
504
|
+
assertComputerDeadline(deadline);
|
|
505
|
+
return result;
|
|
506
|
+
} finally {
|
|
507
|
+
if (timeout) clearTimeout(timeout);
|
|
508
|
+
removeAbortListener?.();
|
|
391
509
|
}
|
|
392
510
|
}
|
|
393
511
|
|
|
512
|
+
function dispatchComputerAction(
|
|
513
|
+
controller: NativeController,
|
|
514
|
+
params: SingleComputerParams,
|
|
515
|
+
deadline: ComputerDeadline | undefined,
|
|
516
|
+
context?: ScreenshotContext,
|
|
517
|
+
signal?: AbortSignal,
|
|
518
|
+
): Promise<unknown> {
|
|
519
|
+
const expectedEpoch = expectedEpochFromContext(context);
|
|
520
|
+
return runComputerOperation(
|
|
521
|
+
() => {
|
|
522
|
+
switch (params.action) {
|
|
523
|
+
case "screenshot":
|
|
524
|
+
if (!controller.screenshot) missingNativeMethod("screenshot", "screenshot");
|
|
525
|
+
return controller.screenshot();
|
|
526
|
+
case "click":
|
|
527
|
+
validatePointerCoordinates("click", params.x, params.y, context);
|
|
528
|
+
if (!controller.click) missingNativeMethod("click", "click");
|
|
529
|
+
return controller.click(expectedEpoch, params.x, params.y, params.button ?? "left");
|
|
530
|
+
case "double_click":
|
|
531
|
+
validatePointerCoordinates("double_click", params.x, params.y, context);
|
|
532
|
+
if (!controller.doubleClick) missingNativeMethod("double_click", "doubleClick");
|
|
533
|
+
return controller.doubleClick(expectedEpoch, params.x, params.y, params.button ?? "left");
|
|
534
|
+
case "move":
|
|
535
|
+
validatePointerCoordinates("move", params.x, params.y, context);
|
|
536
|
+
if (!controller.move) missingNativeMethod("move", "move");
|
|
537
|
+
return controller.move(expectedEpoch, params.x, params.y);
|
|
538
|
+
case "drag":
|
|
539
|
+
validatePointerCoordinates("drag start", params.x, params.y, context);
|
|
540
|
+
validatePointerCoordinates("drag end", params.to_x, params.to_y, context);
|
|
541
|
+
if (!controller.drag) missingNativeMethod("drag", "drag");
|
|
542
|
+
return controller.drag(
|
|
543
|
+
expectedEpoch,
|
|
544
|
+
params.x,
|
|
545
|
+
params.y,
|
|
546
|
+
params.to_x,
|
|
547
|
+
params.to_y,
|
|
548
|
+
params.button ?? "left",
|
|
549
|
+
);
|
|
550
|
+
case "scroll":
|
|
551
|
+
validatePointerCoordinates("scroll", params.x, params.y, context);
|
|
552
|
+
if (!controller.scroll) missingNativeMethod("scroll", "scroll");
|
|
553
|
+
return controller.scroll(expectedEpoch, params.x, params.y, params.scroll_x, params.scroll_y);
|
|
554
|
+
case "type":
|
|
555
|
+
if (!controller.type) missingNativeMethod("type", "type");
|
|
556
|
+
return controller.type(undefined, params.text);
|
|
557
|
+
case "keypress":
|
|
558
|
+
if (!controller.keypress) missingNativeMethod("keypress", "keypress");
|
|
559
|
+
return controller.keypress(undefined, params.keys);
|
|
560
|
+
case "wait":
|
|
561
|
+
if (!controller.wait) missingNativeMethod("wait", "wait");
|
|
562
|
+
return controller.wait(undefined, capWaitMs(params.ms, remainingComputerTimeoutMs(deadline)));
|
|
563
|
+
}
|
|
564
|
+
},
|
|
565
|
+
deadline,
|
|
566
|
+
signal,
|
|
567
|
+
);
|
|
568
|
+
}
|
|
569
|
+
|
|
394
570
|
interface BatchDispatchResult {
|
|
395
571
|
steps: ComputerToolDetails[];
|
|
396
572
|
screenshot?: ComputerScreenshotDetails;
|
|
@@ -403,21 +579,34 @@ async function dispatchBatchComputerActions(
|
|
|
403
579
|
actions: readonly SingleComputerParams[],
|
|
404
580
|
timeoutMs: number | undefined,
|
|
405
581
|
hotkey?: string,
|
|
582
|
+
initialContext?: ScreenshotContext,
|
|
583
|
+
includeBatchScreenshot = false,
|
|
584
|
+
autoScreenshot = false,
|
|
585
|
+
signal?: AbortSignal,
|
|
586
|
+
deadline?: ComputerDeadline,
|
|
406
587
|
): Promise<BatchDispatchResult> {
|
|
407
588
|
const steps: ComputerToolDetails[] = [];
|
|
408
589
|
let lastScreenshot: ComputerScreenshotDetails | undefined;
|
|
409
590
|
let lastScreenshotSource: unknown;
|
|
410
|
-
let
|
|
591
|
+
let context = initialContext;
|
|
411
592
|
for (const single of actions) {
|
|
412
593
|
const stepDetails = detailsFromParams(single);
|
|
413
594
|
try {
|
|
414
|
-
|
|
595
|
+
throwIfAborted(signal);
|
|
596
|
+
assertComputerDeadline(deadline);
|
|
597
|
+
const stepTimeoutMs = stepTimeoutFromParams(single, timeoutMs);
|
|
598
|
+
const stepDeadline = createComputerDeadline(stepTimeoutMs, deadline);
|
|
599
|
+
let result = await dispatchComputerAction(controller, single, stepDeadline, context, signal);
|
|
600
|
+
if (single.action !== "screenshot" && (single.include_screenshot === true || autoScreenshot)) {
|
|
601
|
+
result = await captureScreenshot(controller, stepDeadline, signal);
|
|
602
|
+
}
|
|
603
|
+
|
|
415
604
|
const screenshot = normalizeScreenshot(result);
|
|
416
605
|
if (screenshot) {
|
|
417
606
|
stepDetails.screenshot = screenshot;
|
|
418
607
|
lastScreenshot = screenshot;
|
|
419
608
|
lastScreenshotSource = result;
|
|
420
|
-
|
|
609
|
+
context = screenshot;
|
|
421
610
|
}
|
|
422
611
|
stepDetails.status = "success";
|
|
423
612
|
stepDetails.message = describeComputerSuccess(stepDetails);
|
|
@@ -437,9 +626,19 @@ async function dispatchBatchComputerActions(
|
|
|
437
626
|
}
|
|
438
627
|
steps.push(stepDetails);
|
|
439
628
|
}
|
|
629
|
+
if (includeBatchScreenshot) {
|
|
630
|
+
lastScreenshotSource = await captureScreenshot(controller, deadline, signal);
|
|
631
|
+
lastScreenshot = normalizeScreenshot(lastScreenshotSource) ?? lastScreenshot;
|
|
632
|
+
}
|
|
440
633
|
return { steps, screenshot: lastScreenshot, screenshotSource: lastScreenshotSource };
|
|
441
634
|
}
|
|
442
635
|
|
|
636
|
+
function stepTimeoutFromParams(params: SingleComputerParams, batchTimeoutMs: number | undefined): number | undefined {
|
|
637
|
+
if (params.timeout === undefined) return batchTimeoutMs;
|
|
638
|
+
const timeoutSeconds = clampTimeout("computer", params.timeout);
|
|
639
|
+
return timeoutSeconds > 0 ? timeoutSeconds * 1000 : undefined;
|
|
640
|
+
}
|
|
641
|
+
|
|
443
642
|
function detailsFromParams(params: ComputerParams): ComputerToolDetails {
|
|
444
643
|
const details: ComputerToolDetails = { action: params.action, status: "success" };
|
|
445
644
|
if ("x" in params) details.x = params.x;
|
|
@@ -476,12 +675,16 @@ function normalizeScreenshot(value: unknown): ComputerScreenshotDetails | undefi
|
|
|
476
675
|
scaleY: shot.scaleY,
|
|
477
676
|
originX: shot.originX,
|
|
478
677
|
originY: shot.originY,
|
|
479
|
-
displayEpoch: shot.displayEpoch,
|
|
678
|
+
displayEpoch: normalizeDisplayEpoch(shot.displayEpoch),
|
|
480
679
|
captureId: shot.captureId,
|
|
481
680
|
pngBytes: getPngByteLength(shot.png),
|
|
482
681
|
};
|
|
483
682
|
}
|
|
484
683
|
|
|
684
|
+
function normalizeDisplayEpoch(value: unknown): number | undefined {
|
|
685
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : undefined;
|
|
686
|
+
}
|
|
687
|
+
|
|
485
688
|
function fullResolutionImageContentFromNativeResult(value: unknown): ImageContent | undefined {
|
|
486
689
|
const candidate =
|
|
487
690
|
value && typeof value === "object" && "screenshot" in value
|
package/src/tools/skill.ts
CHANGED
|
@@ -50,7 +50,7 @@ export class SkillTool implements AgentTool<typeof skillSchema, SkillToolDetails
|
|
|
50
50
|
readonly name = "skill";
|
|
51
51
|
readonly label = "Skill";
|
|
52
52
|
readonly summary = "Chain into another available skill in the current turn";
|
|
53
|
-
readonly loadMode = "
|
|
53
|
+
readonly loadMode = "essential";
|
|
54
54
|
readonly description: string;
|
|
55
55
|
readonly parameters = skillSchema;
|
|
56
56
|
readonly strict = true;
|
|
@@ -6,6 +6,9 @@ import { getTelegramFileSink } from "../notifications/attachment-registry";
|
|
|
6
6
|
import { getNotificationConfig, isGloballyConfigured } from "../notifications/config";
|
|
7
7
|
import type { ToolSession } from "./index";
|
|
8
8
|
|
|
9
|
+
const TELEGRAM_SEND_MAX_FILE_BYTES = 50 * 1024 * 1024;
|
|
10
|
+
const TELEGRAM_SEND_MAX_FILE_MIB = TELEGRAM_SEND_MAX_FILE_BYTES / (1024 * 1024);
|
|
11
|
+
|
|
9
12
|
const telegramSendSchema = z.object({
|
|
10
13
|
path: z
|
|
11
14
|
.string()
|
|
@@ -75,6 +78,9 @@ export class TelegramSendTool implements AgentTool<typeof telegramSendSchema, Te
|
|
|
75
78
|
if (!stat.isFile()) {
|
|
76
79
|
return { ok: false, error: "not a regular file" };
|
|
77
80
|
}
|
|
81
|
+
if (stat.size > TELEGRAM_SEND_MAX_FILE_BYTES) {
|
|
82
|
+
return { ok: false, error: `file exceeds Telegram document limit (${TELEGRAM_SEND_MAX_FILE_MIB} MiB)` };
|
|
83
|
+
}
|
|
78
84
|
return { ok: true, path: real };
|
|
79
85
|
}
|
|
80
86
|
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildWorkflowIntentReport,
|
|
3
|
+
type WorkflowClaimsLedger,
|
|
4
|
+
type WorkflowConsensusReport,
|
|
5
|
+
} from "./workflow-intent-report";
|
|
6
|
+
|
|
1
7
|
export const WORKFLOW_INTENT_DIFF_CUSTOM_TYPE = "workflow-intent-diff";
|
|
8
|
+
export const WORKFLOW_INTENT_ROUTES = ["direct", "deep-interview", "ralplan", "ultragoal", "team"] as const;
|
|
9
|
+
export const WORKFLOW_ESCALATION_ROUTES = ["deep-interview", "ralplan", "ultragoal", "team"] as const;
|
|
2
10
|
|
|
3
|
-
export type WorkflowIntentRoute =
|
|
11
|
+
export type WorkflowIntentRoute = (typeof WORKFLOW_INTENT_ROUTES)[number];
|
|
12
|
+
export type WorkflowEscalationRoute = (typeof WORKFLOW_ESCALATION_ROUTES)[number];
|
|
4
13
|
export type DirectTrackingMode = "custom-entry-only" | "not-direct";
|
|
5
14
|
export type RootCausePhaseStatus = "active" | "inactive";
|
|
6
15
|
|
|
@@ -9,13 +18,15 @@ export interface WorkflowIntentDiff {
|
|
|
9
18
|
readonly route: WorkflowIntentRoute;
|
|
10
19
|
readonly reason: string;
|
|
11
20
|
readonly directTracking: DirectTrackingMode;
|
|
12
|
-
readonly recommendedSkill?:
|
|
21
|
+
readonly recommendedSkill?: WorkflowEscalationRoute;
|
|
13
22
|
readonly recommendedInvocation?: string;
|
|
14
23
|
readonly triggers: readonly string[];
|
|
15
24
|
readonly rootCausePhase: {
|
|
16
25
|
readonly status: RootCausePhaseStatus;
|
|
17
26
|
readonly triggers: readonly string[];
|
|
18
27
|
};
|
|
28
|
+
readonly claimsLedger: WorkflowClaimsLedger;
|
|
29
|
+
readonly consensusReport: WorkflowConsensusReport;
|
|
19
30
|
readonly promptPreview: string;
|
|
20
31
|
}
|
|
21
32
|
|
|
@@ -182,6 +193,19 @@ export function buildWorkflowIntentDiff(text: string): WorkflowIntentDiff | null
|
|
|
182
193
|
const rootCauseTriggers = collectRootCauseTriggers(text);
|
|
183
194
|
const rootCauseActive = rootCauseTriggers.length > 0;
|
|
184
195
|
const direct = route.route === "direct";
|
|
196
|
+
const rootCauseStatus: RootCausePhaseStatus = rootCauseActive ? "active" : "inactive";
|
|
197
|
+
const rootCausePhase = {
|
|
198
|
+
status: rootCauseStatus,
|
|
199
|
+
triggers: rootCauseTriggers,
|
|
200
|
+
};
|
|
201
|
+
const report = buildWorkflowIntentReport({
|
|
202
|
+
route: route.route,
|
|
203
|
+
reason: route.reason,
|
|
204
|
+
direct,
|
|
205
|
+
recommendedInvocation: route.recommendedInvocation,
|
|
206
|
+
triggers: route.triggers,
|
|
207
|
+
rootCausePhase,
|
|
208
|
+
});
|
|
185
209
|
|
|
186
210
|
return {
|
|
187
211
|
version: 1,
|
|
@@ -190,10 +214,9 @@ export function buildWorkflowIntentDiff(text: string): WorkflowIntentDiff | null
|
|
|
190
214
|
directTracking: direct ? "custom-entry-only" : "not-direct",
|
|
191
215
|
...(direct ? {} : { recommendedSkill: route.route, recommendedInvocation: route.recommendedInvocation }),
|
|
192
216
|
triggers: route.triggers,
|
|
193
|
-
rootCausePhase
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
},
|
|
217
|
+
rootCausePhase,
|
|
218
|
+
claimsLedger: report.claimsLedger,
|
|
219
|
+
consensusReport: report.consensusReport,
|
|
197
220
|
promptPreview,
|
|
198
221
|
};
|
|
199
222
|
}
|