@omercnet/paseo-omp 5.6.1 → 5.6.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/npm-shrinkwrap.json +18 -18
- package/package.json +8 -8
- package/server/package-version.ts +1 -1
- package/server/provider/catalog.ts +8 -2
- package/server/provider/config-normalization.ts +20 -1
- package/server/provider/connection.ts +49 -17
- package/server/provider/omp-rpc.ts +7 -3
- package/server/provider/security.ts +6 -0
- package/server/provider/timeline-projector.ts +160 -0
- package/server/turn-rows.ts +3 -3
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omercnet/paseo-omp",
|
|
3
|
-
"version": "5.6.
|
|
3
|
+
"version": "5.6.2",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@omercnet/paseo-omp",
|
|
9
|
-
"version": "5.6.
|
|
9
|
+
"version": "5.6.2",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@getpaseo/protocol": "0.15.
|
|
11
|
+
"@getpaseo/protocol": "0.15.3",
|
|
12
12
|
"@modelcontextprotocol/sdk": "1.32.2",
|
|
13
13
|
"yaml": "^2.9.0"
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"node_modules/@getpaseo/protocol": {
|
|
17
|
-
"version": "0.15.
|
|
18
|
-
"resolved": "https://registry.npmjs.org/@getpaseo/protocol/-/protocol-0.15.
|
|
19
|
-
"integrity": "sha512-
|
|
17
|
+
"version": "0.15.3",
|
|
18
|
+
"resolved": "https://registry.npmjs.org/@getpaseo/protocol/-/protocol-0.15.3.tgz",
|
|
19
|
+
"integrity": "sha512-JhAYutwgLUSDdvDhQ8yLjxzqJroR3yqmt+5/rv07iqmOAd/CNtKNJSXZAFaTOavWZcRVlL6DD3tkwaobjgb1Xg==",
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"semver": "^7.8.5",
|
|
22
22
|
"zod": "^4.4.3"
|
|
@@ -435,9 +435,9 @@
|
|
|
435
435
|
}
|
|
436
436
|
},
|
|
437
437
|
"node_modules/express-rate-limit": {
|
|
438
|
-
"version": "8.7.
|
|
439
|
-
"resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-8.7.
|
|
440
|
-
"integrity": "sha512-
|
|
438
|
+
"version": "8.7.4",
|
|
439
|
+
"resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-8.7.4.tgz",
|
|
440
|
+
"integrity": "sha512-LKBXzX700wz3zAGNNmVnjRI5mEbYkLv7UbMI4+9Xa+JPcg2UZh6AgY/2CZh9RrJjFM5ttC/N1lD+KzyFoZITCw==",
|
|
441
441
|
"license": "MIT",
|
|
442
442
|
"dependencies": {
|
|
443
443
|
"debug": "^4.4.3",
|
|
@@ -610,9 +610,9 @@
|
|
|
610
610
|
}
|
|
611
611
|
},
|
|
612
612
|
"node_modules/hono": {
|
|
613
|
-
"version": "4.13.
|
|
614
|
-
"resolved": "https://registry.npmjs.org/hono/-/hono-4.13.
|
|
615
|
-
"integrity": "sha512-
|
|
613
|
+
"version": "4.13.17",
|
|
614
|
+
"resolved": "https://registry.npmjs.org/hono/-/hono-4.13.17.tgz",
|
|
615
|
+
"integrity": "sha512-vZIcbkvjOR5hHRWERbGkr8fGfF0GGM1ooYkuH448iO3b2AdVEr3AXZSw4Z3Kn+1L5z0CVoVeyV29VGYmFh05kQ==",
|
|
616
616
|
"license": "MIT",
|
|
617
617
|
"engines": {
|
|
618
618
|
"node": ">=16.9.0"
|
|
@@ -661,9 +661,9 @@
|
|
|
661
661
|
"license": "ISC"
|
|
662
662
|
},
|
|
663
663
|
"node_modules/ip-address": {
|
|
664
|
-
"version": "10.7.
|
|
665
|
-
"resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.7.
|
|
666
|
-
"integrity": "sha512-
|
|
664
|
+
"version": "10.7.6",
|
|
665
|
+
"resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.7.6.tgz",
|
|
666
|
+
"integrity": "sha512-00LYkM6byILa9eQIx6qoaXCM40xTLd56AZ4vyaPW3YTyb49VZYPo5xsiAq4tuQ54GH4R7gVdYScJ1B7B77PuTg==",
|
|
667
667
|
"license": "MIT",
|
|
668
668
|
"engines": {
|
|
669
669
|
"node": ">= 12"
|
|
@@ -691,9 +691,9 @@
|
|
|
691
691
|
"license": "ISC"
|
|
692
692
|
},
|
|
693
693
|
"node_modules/jose": {
|
|
694
|
-
"version": "6.2.
|
|
695
|
-
"resolved": "https://registry.npmjs.org/jose/-/jose-6.2.
|
|
696
|
-
"integrity": "sha512-
|
|
694
|
+
"version": "6.2.17",
|
|
695
|
+
"resolved": "https://registry.npmjs.org/jose/-/jose-6.2.17.tgz",
|
|
696
|
+
"integrity": "sha512-wOuK9V1yujQFH5S0ZWmLcDZN7+IKh9bUCC2ZPCf2HDlol3WWHy+PPyNjEI75FXRLMp3vDKQcupP59xhVU95hcg==",
|
|
697
697
|
"license": "MIT",
|
|
698
698
|
"funding": {
|
|
699
699
|
"url": "https://github.com/sponsors/panva"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omercnet/paseo-omp",
|
|
3
|
-
"version": "5.6.
|
|
3
|
+
"version": "5.6.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Paseo integration for OMP, including its direct provider and workspace tooling.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -54,18 +54,18 @@
|
|
|
54
54
|
"typecheck": "tsc --noEmit -p tsconfig.client.json && tsc --noEmit -p tsconfig.server.json && tsc --noEmit -p tsconfig.tests.json"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@getpaseo/protocol": "0.15.
|
|
57
|
+
"@getpaseo/protocol": "0.15.3",
|
|
58
58
|
"@modelcontextprotocol/sdk": "1.32.2",
|
|
59
59
|
"yaml": "^2.9.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@biomejs/biome": "^2.5.10",
|
|
63
|
-
"@getpaseo/cli": "0.15.
|
|
64
|
-
"@getpaseo/client": "0.15.
|
|
65
|
-
"@getpaseo/plugin": "0.15.
|
|
66
|
-
"@getpaseo/server": "0.15.
|
|
67
|
-
"@oh-my-pi/pi-agent-core": "18.
|
|
68
|
-
"@oh-my-pi/pi-coding-agent": "18.
|
|
63
|
+
"@getpaseo/cli": "0.15.3",
|
|
64
|
+
"@getpaseo/client": "0.15.3",
|
|
65
|
+
"@getpaseo/plugin": "0.15.3",
|
|
66
|
+
"@getpaseo/server": "0.15.3",
|
|
67
|
+
"@oh-my-pi/pi-agent-core": "18.18.0",
|
|
68
|
+
"@oh-my-pi/pi-coding-agent": "18.18.0",
|
|
69
69
|
"@tanstack/react-query": "^5.102.3",
|
|
70
70
|
"@types/node": "^24.10.1",
|
|
71
71
|
"@types/react": "^19.2.18",
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Release Please keeps this bundle-safe constant aligned with package.json. */
|
|
2
|
-
export const PASEO_OMP_PACKAGE_VERSION = "5.6.
|
|
2
|
+
export const PASEO_OMP_PACKAGE_VERSION = "5.6.2"; // x-release-please-version
|
|
@@ -10,6 +10,7 @@ import type { OmpRuntime, OmpRuntimeSession } from "./omp-rpc";
|
|
|
10
10
|
import type { OmpModel } from "./omp-rpc-protocol";
|
|
11
11
|
import {
|
|
12
12
|
configuredOutputRedactionValues,
|
|
13
|
+
isOmpCleanupFailure,
|
|
13
14
|
OmpCleanupFailure,
|
|
14
15
|
OmpPublicDataSerializer,
|
|
15
16
|
OmpPublicError,
|
|
@@ -141,8 +142,13 @@ async function closeCatalogSession(session: OmpRuntimeSession): Promise<void> {
|
|
|
141
142
|
const cleanup = session.close();
|
|
142
143
|
try {
|
|
143
144
|
await cleanup;
|
|
144
|
-
} catch {
|
|
145
|
-
|
|
145
|
+
} catch (error) {
|
|
146
|
+
// The RPC transport already carries a reverify promise that keeps retrying tree cleanup;
|
|
147
|
+
// wrapping that rejection with `cleanup` (an already-rejected promise) would discard it.
|
|
148
|
+
if (isOmpCleanupFailure(error)) throw error;
|
|
149
|
+
// The close rejection has already been reported by the caller; the gate only has to stay
|
|
150
|
+
// closed on the same settled promise, without counting the failure twice.
|
|
151
|
+
throw new OmpCleanupFailure("OMP catalog cleanup failed", cleanup, undefined, true);
|
|
146
152
|
}
|
|
147
153
|
}
|
|
148
154
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isDeepStrictEqual } from "node:util";
|
|
1
2
|
import type { ProviderSessionConfig } from "@getpaseo/plugin/server/provider";
|
|
2
3
|
import type { OmpStartOptions } from "./omp-rpc-environment";
|
|
3
4
|
|
|
@@ -15,6 +16,24 @@ import { OmpPublicError } from "./security";
|
|
|
15
16
|
import { withoutOmpSessionPurpose } from "./session-purpose";
|
|
16
17
|
import { OmpModeSchema } from "./settings";
|
|
17
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Whether a session asks for provider settings OMP does not expose. Paseo 0.14/0.15 fill
|
|
21
|
+
* `settings` from feature values; Paseo 0.16 mirrors `providerOptions` there instead, so a key
|
|
22
|
+
* that only repeats the same `providerOptions` value is not a setting.
|
|
23
|
+
*/
|
|
24
|
+
export function hasOmpProviderSettings(settings: unknown, providerOptions: unknown): boolean {
|
|
25
|
+
if (!settings || typeof settings !== "object") return false;
|
|
26
|
+
const options =
|
|
27
|
+
providerOptions && typeof providerOptions === "object"
|
|
28
|
+
? (providerOptions as Record<string, unknown>)
|
|
29
|
+
: {};
|
|
30
|
+
for (const [key, value] of Object.entries(settings)) {
|
|
31
|
+
if (!Object.hasOwn(options, key)) return true;
|
|
32
|
+
if (!isDeepStrictEqual(value, options[key])) return true;
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
|
|
18
37
|
const OMP_BUILTIN_TOOL_NAMES = [
|
|
19
38
|
"read",
|
|
20
39
|
"bash",
|
|
@@ -120,7 +139,7 @@ export function normalizeOmpSessionConfig(
|
|
|
120
139
|
permissionSupported = false,
|
|
121
140
|
hostInheritEnv: readonly string[] = [],
|
|
122
141
|
): NormalizedOmpStartOptions {
|
|
123
|
-
if (
|
|
142
|
+
if (hasOmpProviderSettings(config.settings, config.providerOptions)) {
|
|
124
143
|
throw new OmpPublicError("OMP does not expose live provider settings");
|
|
125
144
|
}
|
|
126
145
|
const parsedMode = OmpModeSchema.safeParse(config.mode ?? "full");
|
|
@@ -15,7 +15,7 @@ import type {
|
|
|
15
15
|
} from "../operational-failure-diagnostics";
|
|
16
16
|
import type { OmpSubagentControlRegistry } from "../subagents";
|
|
17
17
|
import { discoverOmpCatalog } from "./catalog";
|
|
18
|
-
import { normalizeOmpCatalogOptions } from "./config-normalization";
|
|
18
|
+
import { hasOmpProviderSettings, normalizeOmpCatalogOptions } from "./config-normalization";
|
|
19
19
|
import type { OmpMcpConnector } from "./host-tools";
|
|
20
20
|
import type { OmpRuntime } from "./omp-rpc";
|
|
21
21
|
import {
|
|
@@ -77,14 +77,6 @@ const MAX_NESTED_OPTION_BYTES = 256 * 1024;
|
|
|
77
77
|
const MAX_ENV_ENTRIES = 256;
|
|
78
78
|
const MAX_NATIVE_SESSION_RESERVATIONS = 256;
|
|
79
79
|
|
|
80
|
-
function hasOwnEntries(value: unknown): boolean {
|
|
81
|
-
if (!value || typeof value !== "object") return false;
|
|
82
|
-
for (const key in value) {
|
|
83
|
-
if (Object.hasOwn(value, key)) return true;
|
|
84
|
-
}
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
80
|
function providerOptionsExceedPreflightLimits(value: unknown): boolean {
|
|
89
81
|
if (
|
|
90
82
|
boundedJsonBytes(value, MAX_NESTED_OPTION_BYTES, MAX_ENV_ENTRIES) === Number.POSITIVE_INFINITY
|
|
@@ -143,7 +135,7 @@ function preflightProviderInput(input: unknown): void {
|
|
|
143
135
|
if (config?.toolPolicy !== undefined) {
|
|
144
136
|
throw new OmpPublicError("OMP does not support host tool policies");
|
|
145
137
|
}
|
|
146
|
-
if (
|
|
138
|
+
if (hasOmpProviderSettings(config?.settings, config?.providerOptions)) {
|
|
147
139
|
throw new OmpPublicError("OMP does not expose live provider settings");
|
|
148
140
|
}
|
|
149
141
|
}
|
|
@@ -710,6 +702,37 @@ export class OmpNativeSessionReservations {
|
|
|
710
702
|
}
|
|
711
703
|
}
|
|
712
704
|
|
|
705
|
+
/**
|
|
706
|
+
* Catalog cleanups that are still unverified. Every failed discovery contributes its own cleanup,
|
|
707
|
+
* so two discoveries that fail concurrently cannot overwrite each other: a fulfilled cleanup leaves
|
|
708
|
+
* the set, a rejected cleanup stays in it, and a non-empty set keeps later discoveries from starting
|
|
709
|
+
* a new OMP process over a process tree that was not confirmed gone.
|
|
710
|
+
*/
|
|
711
|
+
class OmpCatalogCleanupRegistry {
|
|
712
|
+
private readonly pending = new Set<Promise<void>>();
|
|
713
|
+
|
|
714
|
+
get size(): number {
|
|
715
|
+
return this.pending.size;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
track(cleanup: Promise<void>, onCleanupRejected: () => void): void {
|
|
719
|
+
this.pending.add(cleanup);
|
|
720
|
+
void cleanup.then(
|
|
721
|
+
() => this.pending.delete(cleanup),
|
|
722
|
+
// A rejected cleanup stays tracked: the tree was never confirmed gone.
|
|
723
|
+
onCleanupRejected,
|
|
724
|
+
);
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
values(): IterableIterator<Promise<void>> {
|
|
728
|
+
return this.pending.values();
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
clear(): void {
|
|
732
|
+
this.pending.clear();
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
|
|
713
736
|
export function createOmpConnection(
|
|
714
737
|
runtime: OmpRuntime,
|
|
715
738
|
capabilities: readonly string[],
|
|
@@ -779,7 +802,7 @@ export function createOmpConnection(
|
|
|
779
802
|
return new Set([...sessions.keys(), ...opening.keys(), ...failedCleanup.keys()]).size;
|
|
780
803
|
});
|
|
781
804
|
const shutdown = new AbortController();
|
|
782
|
-
|
|
805
|
+
const catalogCleanups = new OmpCatalogCleanupRegistry();
|
|
783
806
|
const activeOperations = new Set<Promise<void>>();
|
|
784
807
|
let closing = false;
|
|
785
808
|
let closed = false;
|
|
@@ -830,7 +853,7 @@ export function createOmpConnection(
|
|
|
830
853
|
const dispatch = async (input: ProviderInput): Promise<void> => {
|
|
831
854
|
switch (input.type) {
|
|
832
855
|
case "catalog":
|
|
833
|
-
if (
|
|
856
|
+
if (catalogCleanups.size > 0) {
|
|
834
857
|
requestFailure(input.requestId, new OmpPublicError("OMP catalog cleanup is incomplete"));
|
|
835
858
|
return;
|
|
836
859
|
}
|
|
@@ -867,7 +890,15 @@ export function createOmpConnection(
|
|
|
867
890
|
if (!closing) {
|
|
868
891
|
recordOperationalFailure({ category: "session-open", stage: "catalog" });
|
|
869
892
|
}
|
|
870
|
-
if (isOmpCleanupFailure(error))
|
|
893
|
+
if (isOmpCleanupFailure(error)) {
|
|
894
|
+
catalogCleanups.track(error.cleanup, () => {
|
|
895
|
+
// A cleanup that had already rejected is the failure reported above; counting its
|
|
896
|
+
// rejection again would report one close failure twice.
|
|
897
|
+
if (!closing && !error.cleanupAlreadyRejected) {
|
|
898
|
+
recordOperationalFailure({ category: "session-open", stage: "catalog" });
|
|
899
|
+
}
|
|
900
|
+
});
|
|
901
|
+
}
|
|
871
902
|
if (!closing) requestFailure(input.requestId, error, "OMP catalog discovery failed");
|
|
872
903
|
}
|
|
873
904
|
return;
|
|
@@ -1250,9 +1281,10 @@ export function createOmpConnection(
|
|
|
1250
1281
|
seenCleanups.add(cleanup);
|
|
1251
1282
|
cleanupBatch.push(cleanup);
|
|
1252
1283
|
}
|
|
1253
|
-
|
|
1254
|
-
seenCleanups.
|
|
1255
|
-
|
|
1284
|
+
for (const cleanup of catalogCleanups.values()) {
|
|
1285
|
+
if (seenCleanups.has(cleanup)) continue;
|
|
1286
|
+
seenCleanups.add(cleanup);
|
|
1287
|
+
cleanupBatch.push(cleanup);
|
|
1256
1288
|
}
|
|
1257
1289
|
const results = await Promise.allSettled(cleanupBatch);
|
|
1258
1290
|
for (const result of results) {
|
|
@@ -1266,7 +1298,7 @@ export function createOmpConnection(
|
|
|
1266
1298
|
sessions.clear();
|
|
1267
1299
|
opening.clear();
|
|
1268
1300
|
failedCleanup.clear();
|
|
1269
|
-
|
|
1301
|
+
catalogCleanups.clear();
|
|
1270
1302
|
};
|
|
1271
1303
|
return {
|
|
1272
1304
|
version: 1,
|
|
@@ -68,7 +68,7 @@ import {
|
|
|
68
68
|
validateBoundedText,
|
|
69
69
|
} from "./omp-rpc-values";
|
|
70
70
|
import { buildOmpPromptRequest } from "./prompt-payload";
|
|
71
|
-
import { OmpCleanupFailure, OmpPublicError } from "./security";
|
|
71
|
+
import { isOmpCleanupFailure, OmpCleanupFailure, OmpPublicError } from "./security";
|
|
72
72
|
import {
|
|
73
73
|
listOmpSessionDescriptors,
|
|
74
74
|
type OmpSessionDescriptor,
|
|
@@ -695,8 +695,12 @@ export class OmpRpcRuntime implements OmpRuntime {
|
|
|
695
695
|
const cleanup = process.close();
|
|
696
696
|
try {
|
|
697
697
|
await cleanup;
|
|
698
|
-
} catch {
|
|
699
|
-
|
|
698
|
+
} catch (cleanupError) {
|
|
699
|
+
// The RPC transport carries a reverify promise that keeps retrying tree cleanup. Wrapping
|
|
700
|
+
// its rejection with `cleanup` (an already-rejected promise) would discard that promise, so
|
|
701
|
+
// a startup cleanup failure could never reopen the catalog gate.
|
|
702
|
+
if (isOmpCleanupFailure(cleanupError)) throw cleanupError;
|
|
703
|
+
throw new OmpCleanupFailure("OMP runtime startup cleanup failed", cleanup, undefined, true);
|
|
700
704
|
}
|
|
701
705
|
throw error;
|
|
702
706
|
}
|
|
@@ -201,6 +201,12 @@ export class OmpCleanupFailure extends Error {
|
|
|
201
201
|
message: string,
|
|
202
202
|
readonly cleanup: Promise<void>,
|
|
203
203
|
readonly nativeSessionId?: string,
|
|
204
|
+
/**
|
|
205
|
+
* True when `cleanup` is the rejection that already produced this failure, such as an
|
|
206
|
+
* already-rejected `session.close()`. Callers that reported the failure once use it to avoid
|
|
207
|
+
* reporting the same rejection a second time when the cleanup settles.
|
|
208
|
+
*/
|
|
209
|
+
readonly cleanupAlreadyRejected = false,
|
|
204
210
|
) {
|
|
205
211
|
void cleanup.catch(() => undefined);
|
|
206
212
|
super(message);
|
|
@@ -32,6 +32,8 @@ const MAX_TODOS = 256;
|
|
|
32
32
|
const MAX_TURN_NATIVE_IDENTITIES = 1_024;
|
|
33
33
|
const MAX_REPLAY_NATIVE_IDENTITIES = 100_000;
|
|
34
34
|
const MAX_PUBLIC_TOOL_PAYLOAD_BYTES = 256 * 1024;
|
|
35
|
+
/** Paseo caps a whole tool_call item at 64K units (0.15), so the ask card keeps clear of it. */
|
|
36
|
+
const MAX_ASK_TEXT_BYTES = 32 * 1024;
|
|
35
37
|
const MAX_ACTIVE_TOOL_BYTES = 4 * 1024 * 1024;
|
|
36
38
|
const MAX_REVERT_TARGETS = MAX_REPLAY_NATIVE_IDENTITIES;
|
|
37
39
|
const REVERT_TOKEN_PATTERN = /^omp-revert:[A-Za-z0-9_-]{43}$/u;
|
|
@@ -261,6 +263,154 @@ function resultDetails(value: JsonValue): Record<string, JsonValue> | undefined
|
|
|
261
263
|
return jsonRecord(envelope?.details);
|
|
262
264
|
}
|
|
263
265
|
|
|
266
|
+
type AskProjectedAnswer = {
|
|
267
|
+
id?: string;
|
|
268
|
+
question: string;
|
|
269
|
+
multi: boolean;
|
|
270
|
+
selected: string[];
|
|
271
|
+
custom?: string;
|
|
272
|
+
note?: string;
|
|
273
|
+
noteOption?: string;
|
|
274
|
+
timedOut: boolean;
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
/** OMP folds `\r` runs in ids and questions inside `execute`, after the call args are published. */
|
|
278
|
+
function askKey(value: string): string {
|
|
279
|
+
return value.replaceAll("\r\n", "\n").replace(/\r+/gu, " ");
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function askQuestionRecords(
|
|
283
|
+
input: Record<string, JsonValue> | undefined,
|
|
284
|
+
): Array<{ id?: string; question: string }> {
|
|
285
|
+
const questions = input?.questions;
|
|
286
|
+
if (!Array.isArray(questions)) return [];
|
|
287
|
+
return questions.flatMap((value) => {
|
|
288
|
+
const record = jsonRecord(value);
|
|
289
|
+
const question = firstString(record, "question");
|
|
290
|
+
return question === undefined ? [] : [{ id: firstString(record, "id"), question }];
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function askAnswerRecord(value: JsonValue | undefined): AskProjectedAnswer | undefined {
|
|
295
|
+
const record = jsonRecord(value);
|
|
296
|
+
const question = firstString(record, "question");
|
|
297
|
+
if (question === undefined) return undefined;
|
|
298
|
+
const selectedOptions = record?.selectedOptions;
|
|
299
|
+
return {
|
|
300
|
+
id: firstString(record, "id"),
|
|
301
|
+
question,
|
|
302
|
+
multi: record?.multi === true,
|
|
303
|
+
selected: Array.isArray(selectedOptions)
|
|
304
|
+
? selectedOptions.flatMap((option) => (typeof option === "string" ? [option] : []))
|
|
305
|
+
: [],
|
|
306
|
+
custom: firstString(record, "customInput"),
|
|
307
|
+
note: firstString(record, "note"),
|
|
308
|
+
noteOption: firstString(record, "noteOption"),
|
|
309
|
+
timedOut: record?.timedOut === true,
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/** OMP reports a single answered question inline and several as `results`; both carry labels. */
|
|
314
|
+
function askAnswerRecords(details: Record<string, JsonValue> | undefined): AskProjectedAnswer[] {
|
|
315
|
+
const results = details?.results;
|
|
316
|
+
if (Array.isArray(results)) {
|
|
317
|
+
return results.flatMap((value) => {
|
|
318
|
+
const answer = askAnswerRecord(value);
|
|
319
|
+
return answer ? [answer] : [];
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
const single = askAnswerRecord(details);
|
|
323
|
+
return single ? [single] : [];
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/** Claims the answer for one asked question; claimed answers are never rendered twice. */
|
|
327
|
+
function takeAskAnswer(
|
|
328
|
+
asked: { id?: string; question: string },
|
|
329
|
+
index: number,
|
|
330
|
+
answers: readonly AskProjectedAnswer[],
|
|
331
|
+
used: Set<number>,
|
|
332
|
+
): AskProjectedAnswer | undefined {
|
|
333
|
+
const open = (candidate: number) => candidate >= 0 && !used.has(candidate);
|
|
334
|
+
const askedId = asked.id === undefined ? undefined : askKey(asked.id);
|
|
335
|
+
let found =
|
|
336
|
+
askedId === undefined
|
|
337
|
+
? -1
|
|
338
|
+
: answers.findIndex(
|
|
339
|
+
(answer, candidate) =>
|
|
340
|
+
open(candidate) && answer.id !== undefined && askKey(answer.id) === askedId,
|
|
341
|
+
);
|
|
342
|
+
// Single-question results are flat and carry no id.
|
|
343
|
+
if (found < 0 && answers.length === 1 && answers[0]?.id === undefined && open(0)) found = 0;
|
|
344
|
+
if (found < 0) {
|
|
345
|
+
const askedQuestion = askKey(asked.question);
|
|
346
|
+
found = answers.findIndex(
|
|
347
|
+
(answer, candidate) => open(candidate) && askKey(answer.question) === askedQuestion,
|
|
348
|
+
);
|
|
349
|
+
}
|
|
350
|
+
if (found < 0 && open(index)) {
|
|
351
|
+
const positional = answers[index];
|
|
352
|
+
if (askedId === undefined || positional?.id === undefined) found = index;
|
|
353
|
+
}
|
|
354
|
+
if (found < 0) return undefined;
|
|
355
|
+
used.add(found);
|
|
356
|
+
return answers[found];
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function askAnswerLines(answer: AskProjectedAnswer): string[] {
|
|
360
|
+
const lines: string[] = [];
|
|
361
|
+
const selected = [...answer.selected];
|
|
362
|
+
if (answer.custom) selected.push(answer.custom);
|
|
363
|
+
if (selected.length > 0) {
|
|
364
|
+
lines.push(`${selected.join(", ")}${answer.timedOut ? " (auto-selected after timeout)" : ""}`);
|
|
365
|
+
} else {
|
|
366
|
+
lines.push(answer.multi ? "(none selected)" : "(no answer)");
|
|
367
|
+
}
|
|
368
|
+
if (answer.note) {
|
|
369
|
+
lines.push(
|
|
370
|
+
answer.noteOption === undefined
|
|
371
|
+
? `Note: ${answer.note}`
|
|
372
|
+
: `Note on ${answer.noteOption}: ${answer.note}`,
|
|
373
|
+
);
|
|
374
|
+
}
|
|
375
|
+
return lines;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/** Renders OMP's `ask` tool as the questions asked plus the answers a user chose. */
|
|
379
|
+
function askToolText(
|
|
380
|
+
input: Record<string, JsonValue> | undefined,
|
|
381
|
+
details: Record<string, JsonValue> | undefined,
|
|
382
|
+
resultText: string | undefined,
|
|
383
|
+
): string | undefined {
|
|
384
|
+
// OMP's chat redirect text already lists every question asked.
|
|
385
|
+
if (details?.chatRedirect === true && resultText !== undefined) return resultText;
|
|
386
|
+
const answers = askAnswerRecords(details);
|
|
387
|
+
const asked = askQuestionRecords(input);
|
|
388
|
+
const chatQuestions = Array.isArray(details?.questions)
|
|
389
|
+
? details.questions.flatMap((value) => (typeof value === "string" ? [value] : []))
|
|
390
|
+
: [];
|
|
391
|
+
const used = new Set<number>();
|
|
392
|
+
let unanswered = false;
|
|
393
|
+
const blocks = asked.map((entry, index) => {
|
|
394
|
+
const answer = takeAskAnswer(entry, index, answers, used);
|
|
395
|
+
if (!answer) unanswered = true;
|
|
396
|
+
return [entry.question, ...(answer ? askAnswerLines(answer) : [])].join("\n");
|
|
397
|
+
});
|
|
398
|
+
// Answers whose question is missing from the published args (cut down, or ids OMP rewrote)
|
|
399
|
+
// still carry their own question text.
|
|
400
|
+
answers.forEach((answer, index) => {
|
|
401
|
+
if (!used.has(index)) blocks.push([answer.question, ...askAnswerLines(answer)].join("\n"));
|
|
402
|
+
});
|
|
403
|
+
if (blocks.length === 0 && chatQuestions.length > 0) {
|
|
404
|
+
blocks.push(...chatQuestions);
|
|
405
|
+
unanswered = true;
|
|
406
|
+
}
|
|
407
|
+
if (blocks.length === 0) return resultText;
|
|
408
|
+
const text = blocks.join("\n\n");
|
|
409
|
+
// Unanswered questions (cancelled, running, or a dropped details payload) keep OMP's own
|
|
410
|
+
// result text, which says why no answer is there without inventing a label for it.
|
|
411
|
+
return !unanswered || resultText === undefined ? text : `${text}\n\n${resultText}`;
|
|
412
|
+
}
|
|
413
|
+
|
|
264
414
|
type NativeImageEnvelope = {
|
|
265
415
|
images: NativeImage[];
|
|
266
416
|
text?: string;
|
|
@@ -1811,6 +1961,16 @@ export class OmpTimelineProjector {
|
|
|
1811
1961
|
if (name === "todo") {
|
|
1812
1962
|
return { type: "plan", text: resultText ?? JSON.stringify(snapshot.input) };
|
|
1813
1963
|
}
|
|
1964
|
+
if (name === "ask") {
|
|
1965
|
+
const text = askToolText(nestedInput, details, resultText);
|
|
1966
|
+
if (text !== undefined) {
|
|
1967
|
+
return {
|
|
1968
|
+
type: "plain_text",
|
|
1969
|
+
label: snapshot.name,
|
|
1970
|
+
text: this.dataFilter.text(text, MAX_ASK_TEXT_BYTES),
|
|
1971
|
+
};
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1814
1974
|
return { type: "unknown", input: snapshot.input, output: snapshot.output };
|
|
1815
1975
|
}
|
|
1816
1976
|
|
package/server/turn-rows.ts
CHANGED
|
@@ -19,18 +19,18 @@ export type OmpTurnRowReader = (
|
|
|
19
19
|
* turn of such an agent, every reader may append one timeline row built from that file.
|
|
20
20
|
*/
|
|
21
21
|
export function registerOmpTurnRows(
|
|
22
|
-
server: Pick<PluginServerContext, "
|
|
22
|
+
server: Pick<PluginServerContext, "on">,
|
|
23
23
|
readers: readonly OmpTurnRowReader[],
|
|
24
24
|
): () => void {
|
|
25
25
|
// One Paseo turn can report several native turn starts; keep the earliest. Hooks run
|
|
26
26
|
// concurrently, so state is read and cleared before the first await.
|
|
27
27
|
const turnStarts = new Map<string, number>();
|
|
28
28
|
const turnKey = (agentId: string, turnId: string | null) => `${agentId}\0${turnId ?? ""}`;
|
|
29
|
-
const removeBefore = server.
|
|
29
|
+
const removeBefore = server.on("agent.turn_started", async ({ agent, turnId }) => {
|
|
30
30
|
const key = turnKey(agent.id, turnId);
|
|
31
31
|
if (agent.provider === "omp" && !turnStarts.has(key)) turnStarts.set(key, Date.now());
|
|
32
32
|
});
|
|
33
|
-
const removeAfter = server.
|
|
33
|
+
const removeAfter = server.on("agent.turn_ended", async ({ agent, turnId }, { paseo }) => {
|
|
34
34
|
const key = turnKey(agent.id, turnId);
|
|
35
35
|
const since = turnStarts.get(key);
|
|
36
36
|
const until = Date.now();
|