@peer-agent/protocol 0.1.0-rc.5 → 0.1.0-rc.50
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/dist/acceptance-close-gate.d.ts +10 -1
- package/dist/acceptance-close-gate.js +12 -0
- package/dist/agent-supervision.d.ts +81 -0
- package/dist/agent-supervision.js +1 -0
- package/dist/attention.d.ts +44 -0
- package/dist/attention.js +1 -0
- package/dist/bot-access-policy.d.ts +29 -0
- package/dist/bot-access-policy.js +1 -0
- package/dist/bot-conversation-read.d.ts +67 -0
- package/dist/bot-conversation-read.js +9 -0
- package/dist/bot-direct-step.d.ts +11 -0
- package/dist/bot-direct-step.js +1 -0
- package/dist/bot-git.d.ts +55 -0
- package/dist/bot-git.js +1 -0
- package/dist/bot-model-selection.d.ts +13 -0
- package/dist/bot-model-selection.js +1 -0
- package/dist/browser-window.d.ts +48 -0
- package/dist/browser-window.js +23 -0
- package/dist/capability-admission.d.ts +20 -0
- package/dist/capability-admission.js +1 -0
- package/dist/compaction-history-selection.d.ts +15 -0
- package/dist/compaction-history-selection.js +30 -0
- package/dist/compaction.d.ts +5 -0
- package/dist/compaction.js +6 -0
- package/dist/context-accounting.d.ts +3 -0
- package/dist/conversation-execution.d.ts +68 -0
- package/dist/conversation-execution.js +222 -0
- package/dist/delegation-coordination.d.ts +81 -0
- package/dist/delegation-coordination.js +1 -0
- package/dist/delegation.d.ts +260 -7
- package/dist/delegation.js +97 -39
- package/dist/document-reference.d.ts +111 -0
- package/dist/document-reference.js +1 -0
- package/dist/evidence-inspection.d.ts +64 -0
- package/dist/evidence-inspection.js +1 -0
- package/dist/gemini-standard-pricing.json +105 -0
- package/dist/goal.d.ts +50 -2
- package/dist/hook-observation.d.ts +2 -0
- package/dist/hook-observation.js +19 -0
- package/dist/index.d.ts +109 -25
- package/dist/index.js +38 -0
- package/dist/input-prediction.d.ts +86 -0
- package/dist/input-prediction.js +48 -0
- package/dist/intent-coordination.d.ts +201 -0
- package/dist/intent-coordination.js +1 -0
- package/dist/interactive-result.d.ts +363 -0
- package/dist/interactive-result.js +215 -0
- package/dist/interactive-verification.d.ts +41 -0
- package/dist/interactive-verification.js +65 -0
- package/dist/local-git.d.ts +44 -0
- package/dist/local-git.js +3 -0
- package/dist/local-image.d.ts +53 -0
- package/dist/local-image.js +5 -0
- package/dist/local-read.d.ts +9 -0
- package/dist/local-read.js +1 -0
- package/dist/memory.d.ts +71 -11
- package/dist/memory.js +12 -0
- package/dist/model-reasoning.d.ts +16 -0
- package/dist/model-reasoning.js +25 -0
- package/dist/model-routing.d.ts +39 -3
- package/dist/model-routing.js +31 -5
- package/dist/native-process.d.ts +21 -0
- package/dist/native-process.js +51 -0
- package/dist/parent-coordination.d.ts +104 -0
- package/dist/parent-coordination.js +2 -0
- package/dist/project-agent-failure.d.ts +30 -0
- package/dist/project-agent-failure.js +44 -0
- package/dist/project-input-recovery.d.ts +83 -0
- package/dist/project-input-recovery.js +25 -0
- package/dist/project-matter.d.ts +225 -0
- package/dist/project-matter.js +1 -0
- package/dist/project-recovery.d.ts +43 -0
- package/dist/project-recovery.js +1 -0
- package/dist/project.d.ts +136 -0
- package/dist/project.js +130 -5
- package/dist/quiet-reply.d.ts +9 -0
- package/dist/quiet-reply.js +43 -0
- package/dist/remote-access.d.ts +15 -0
- package/dist/remote-access.js +1 -1
- package/dist/reply-delivery.d.ts +28 -0
- package/dist/reply-delivery.js +1 -0
- package/dist/resource-edit-execution.d.ts +68 -0
- package/dist/resource-edit-execution.js +96 -0
- package/dist/resource-edit.d.ts +237 -0
- package/dist/resource-edit.js +134 -0
- package/dist/resource-feedback-transport.d.ts +26 -0
- package/dist/resource-feedback-transport.js +94 -0
- package/dist/resource-feedback.d.ts +98 -0
- package/dist/resource-feedback.js +151 -0
- package/dist/resource-file-replace.d.ts +36 -0
- package/dist/resource-file-replace.js +40 -0
- package/dist/resource-reference-hints.d.ts +3 -0
- package/dist/resource-reference-hints.js +58 -0
- package/dist/resource-window.d.ts +222 -0
- package/dist/resource-window.js +252 -0
- package/dist/runtime-session-facts.d.ts +58 -0
- package/dist/runtime-session-facts.js +57 -0
- package/dist/session-control.d.ts +211 -0
- package/dist/session-control.js +48 -0
- package/dist/session-facts.d.ts +29 -0
- package/dist/session-facts.js +35 -0
- package/dist/skill-marketplace.d.ts +39 -4
- package/dist/spend-budget.d.ts +69 -0
- package/dist/spend-budget.js +1 -0
- package/dist/system-context.d.ts +7 -0
- package/dist/task-overview.d.ts +91 -0
- package/dist/task-overview.js +325 -17
- package/dist/tool-activity-preview.d.ts +4 -0
- package/dist/tool-activity-preview.js +72 -0
- package/dist/updater.d.ts +13 -3
- package/dist/usage-accounting.d.ts +42 -1
- package/dist/user-anchor.d.ts +17 -0
- package/dist/user-anchor.js +1 -0
- package/dist/work-coordination.d.ts +188 -0
- package/dist/work-coordination.js +1 -0
- package/dist/work-hook.d.ts +3 -0
- package/dist/work-hook.js +76 -0
- package/dist/working-plan.d.ts +18 -0
- package/dist/working-plan.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { interactiveDigest, interactiveToken, normalizeInteractiveInspect, normalizeInteractiveOwner } from "./interactive-result.js";
|
|
2
|
+
import { normalizeSessionExecutionIdentity } from "./session-control.js";
|
|
3
|
+
const object = (v) => !!v && typeof v === 'object' && !Array.isArray(v)
|
|
4
|
+
&& [Object.prototype, null].includes(Object.getPrototypeOf(v)) && Object.values(Object.getOwnPropertyDescriptors(v)).every(d => 'value' in d);
|
|
5
|
+
const keys = (v, allowed) => Object.keys(v).every(key => allowed.includes(key));
|
|
6
|
+
const integer = (v) => Number.isSafeInteger(v) && Number(v) >= 0 && Number(v) <= 512 * 1024;
|
|
7
|
+
export function normalizeInteractiveReviewBinding(raw) {
|
|
8
|
+
return object(raw) && keys(raw, ['token']) && interactiveToken(raw.token) ? { token: raw.token } : undefined;
|
|
9
|
+
}
|
|
10
|
+
const INSPECTION_REF_PREFIX = 'interactive-inspection://';
|
|
11
|
+
export function interactiveInspectionEvidenceRef(evidenceId) {
|
|
12
|
+
if (!interactiveToken(evidenceId))
|
|
13
|
+
throw TypeError('invalid inspection evidence ID');
|
|
14
|
+
return `${INSPECTION_REF_PREFIX}${evidenceId}`;
|
|
15
|
+
}
|
|
16
|
+
export function isInteractiveInspectionEvidenceRef(raw) {
|
|
17
|
+
return typeof raw === 'string' && raw.startsWith(INSPECTION_REF_PREFIX) && interactiveToken(raw.slice(INSPECTION_REF_PREFIX.length));
|
|
18
|
+
}
|
|
19
|
+
export function normalizeInteractiveInspectionReceipt(raw) {
|
|
20
|
+
if (!object(raw) || !keys(raw, ['schemaVersion', 'evidenceId', 'owner', 'execution', 'conversationId', 'toolCallId', 'specHash', 'request', 'review', 'range', 'stateSource', 'computationTruncated', 'outputDigest', 'observedAt'])
|
|
21
|
+
|| raw.schemaVersion !== 1 || !interactiveToken(raw.evidenceId) || !interactiveToken(raw.conversationId) || !interactiveToken(raw.toolCallId)
|
|
22
|
+
|| !interactiveDigest(raw.specHash) || !interactiveDigest(raw.outputDigest) || typeof raw.observedAt !== 'string' || raw.observedAt.length > 40 || !Number.isFinite(Date.parse(raw.observedAt))
|
|
23
|
+
|| !object(raw.review) || !keys(raw.review, ['verifierRunId', 'sourceRevision', 'targetsDigest']) || !interactiveToken(raw.review.verifierRunId)
|
|
24
|
+
|| typeof raw.review.sourceRevision !== 'string' || !/^[a-f0-9]{64}$/.test(raw.review.sourceRevision) || !interactiveDigest(raw.review.targetsDigest)
|
|
25
|
+
|| raw.computationTruncated !== undefined && typeof raw.computationTruncated !== 'boolean')
|
|
26
|
+
return;
|
|
27
|
+
const owner = normalizeInteractiveOwner(raw.owner), execution = normalizeSessionExecutionIdentity(raw.execution), request = normalizeInteractiveInspect(raw.request);
|
|
28
|
+
if (!owner || !execution || !request || request.target.kind !== 'result'
|
|
29
|
+
|| owner.workspaceId !== request.target.reference.owner.workspaceId || owner.conversationId !== request.target.reference.owner.conversationId)
|
|
30
|
+
return;
|
|
31
|
+
let range;
|
|
32
|
+
if (raw.range !== undefined) {
|
|
33
|
+
const r = raw.range;
|
|
34
|
+
if (!object(r) || !keys(r, ['offset', 'returned', 'total', 'truncated']) || ![r.offset, r.returned, r.total].every(integer)
|
|
35
|
+
|| Number(r.returned) > (request.limit ?? 4000) || Number(r.offset) + Number(r.returned) > Number(r.total) || typeof r.truncated !== 'boolean'
|
|
36
|
+
|| r.offset !== (request.offset ?? 0) || r.truncated !== (Number(r.offset) + Number(r.returned) < Number(r.total)))
|
|
37
|
+
return;
|
|
38
|
+
range = { offset: Number(r.offset), returned: Number(r.returned), total: Number(r.total), truncated: r.truncated };
|
|
39
|
+
}
|
|
40
|
+
if ((request.view === 'metadata') === !!range)
|
|
41
|
+
return;
|
|
42
|
+
let stateSource;
|
|
43
|
+
if (raw.stateSource !== undefined) {
|
|
44
|
+
const s = raw.stateSource;
|
|
45
|
+
if (!object(s) || !keys(s, ['kind', 'stateDigest', 'followupId', 'stateRevision', 'selectionDigest']) || !interactiveDigest(s.stateDigest))
|
|
46
|
+
return;
|
|
47
|
+
if (s.kind === 'initial' && keys(s, ['kind', 'stateDigest']) && request.followupId === undefined)
|
|
48
|
+
stateSource = { kind: 'initial', stateDigest: s.stateDigest };
|
|
49
|
+
else if (s.kind === 'frozen-followup' && interactiveToken(s.followupId) && s.followupId === request.followupId
|
|
50
|
+
&& Number.isSafeInteger(s.stateRevision) && Number(s.stateRevision) >= 0 && interactiveDigest(s.selectionDigest))
|
|
51
|
+
stateSource = {
|
|
52
|
+
kind: 'frozen-followup', followupId: s.followupId, stateRevision: Number(s.stateRevision), stateDigest: s.stateDigest, selectionDigest: s.selectionDigest
|
|
53
|
+
};
|
|
54
|
+
else
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if ((request.view === 'evaluate') !== !!stateSource || (request.view === 'evaluate'
|
|
58
|
+
? typeof raw.computationTruncated !== 'boolean' : raw.computationTruncated !== undefined))
|
|
59
|
+
return;
|
|
60
|
+
const result = { schemaVersion: 1, evidenceId: raw.evidenceId, owner, execution, conversationId: raw.conversationId,
|
|
61
|
+
toolCallId: raw.toolCallId, specHash: raw.specHash, request, review: { verifierRunId: raw.review.verifierRunId,
|
|
62
|
+
sourceRevision: raw.review.sourceRevision, targetsDigest: raw.review.targetsDigest }, ...(range ? { range } : {}), ...(stateSource ? { stateSource } : {}),
|
|
63
|
+
...(raw.computationTruncated !== undefined ? { computationTruncated: raw.computationTruncated } : {}), outputDigest: raw.outputDigest, observedAt: new Date(raw.observedAt).toISOString() };
|
|
64
|
+
return new TextEncoder().encode(JSON.stringify(result)).byteLength <= 16 * 1024 ? result : undefined;
|
|
65
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** ADR106: bounded repository observations; never arbitrary commands. */
|
|
2
|
+
export declare const LOCAL_GIT_CAPABILITY: "local.git.query";
|
|
3
|
+
export declare const LOCAL_GIT_TOOL: "git_query";
|
|
4
|
+
export type GitReadOperation = 'snapshot' | 'status' | 'log';
|
|
5
|
+
export interface GitReadQuery {
|
|
6
|
+
readonly path: string;
|
|
7
|
+
readonly operation?: GitReadOperation;
|
|
8
|
+
readonly limit?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface GitReadObservation {
|
|
11
|
+
readonly repositoryPath: string;
|
|
12
|
+
readonly gitDirectory: string;
|
|
13
|
+
readonly commonDirectory: string;
|
|
14
|
+
readonly configurationSources: readonly string[];
|
|
15
|
+
readonly operation: GitReadOperation;
|
|
16
|
+
readonly startedAt: string;
|
|
17
|
+
readonly finishedAt: string;
|
|
18
|
+
readonly head: string | null;
|
|
19
|
+
readonly branch: string | null;
|
|
20
|
+
readonly unborn: boolean;
|
|
21
|
+
readonly origin: readonly string[];
|
|
22
|
+
readonly consistent: boolean;
|
|
23
|
+
readonly atomic: false;
|
|
24
|
+
readonly status?: {
|
|
25
|
+
readonly clean: boolean | null;
|
|
26
|
+
readonly submoduleCount: number;
|
|
27
|
+
readonly submodulesInspected: false;
|
|
28
|
+
readonly filtersDisabled: boolean;
|
|
29
|
+
readonly changed: number;
|
|
30
|
+
readonly untracked: number;
|
|
31
|
+
readonly entries: readonly {
|
|
32
|
+
readonly index: string;
|
|
33
|
+
readonly worktree: string;
|
|
34
|
+
readonly path: string;
|
|
35
|
+
readonly from?: string;
|
|
36
|
+
}[];
|
|
37
|
+
readonly truncated: boolean;
|
|
38
|
+
};
|
|
39
|
+
readonly commits: readonly {
|
|
40
|
+
readonly hash: string;
|
|
41
|
+
readonly committedAt: string;
|
|
42
|
+
readonly subject: string;
|
|
43
|
+
}[];
|
|
44
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** ADR 90: local images are factual context, never instructions or persisted pixels. */
|
|
2
|
+
export declare const LOCAL_IMAGE_CAPABILITY: "local.image.read";
|
|
3
|
+
export declare const LOCAL_IMAGE_TOOL: "view_image";
|
|
4
|
+
export declare const LOCAL_IMAGE_MAX_BYTES: number;
|
|
5
|
+
export declare const LOCAL_IMAGE_MAX_PIXELS = 24000000;
|
|
6
|
+
export type LocalImageMediaType = 'image/png' | 'image/jpeg' | 'image/gif' | 'image/webp';
|
|
7
|
+
export interface LocalImageMetadata {
|
|
8
|
+
path: string;
|
|
9
|
+
mediaType: LocalImageMediaType;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
byteLength: number;
|
|
13
|
+
sha256: string;
|
|
14
|
+
artifactRef: string;
|
|
15
|
+
}
|
|
16
|
+
/** Ephemeral host sideband. Object identity must also be validated by its Provider. */
|
|
17
|
+
export interface LocalImageObservation extends LocalImageMetadata {
|
|
18
|
+
kind: 'local_image';
|
|
19
|
+
dataUrl: string;
|
|
20
|
+
}
|
|
21
|
+
import type { ClientToolResult, PermissionGrant } from './index.ts';
|
|
22
|
+
export interface LocalImagePermissionScope {
|
|
23
|
+
capabilityId: typeof LOCAL_IMAGE_CAPABILITY;
|
|
24
|
+
path: string;
|
|
25
|
+
workspacePath: string | null;
|
|
26
|
+
action: 'read_image_for_model';
|
|
27
|
+
fileIdentity?: {
|
|
28
|
+
dev: number;
|
|
29
|
+
ino: number;
|
|
30
|
+
size: number;
|
|
31
|
+
mtimeMs: number;
|
|
32
|
+
ctimeMs: number;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** Local host-issued exact-image read authority; no pixels are persisted. */
|
|
36
|
+
export interface ImageReadGrant {
|
|
37
|
+
policyRevision?: string;
|
|
38
|
+
schemaVersion: 1;
|
|
39
|
+
grantId: string;
|
|
40
|
+
workspaceId: string | null;
|
|
41
|
+
conversationId: string;
|
|
42
|
+
expiresAt: number;
|
|
43
|
+
scope: LocalImagePermissionScope;
|
|
44
|
+
}
|
|
45
|
+
/** Concrete image grant; legacy grant scopes remain unchanged. */
|
|
46
|
+
export interface LocalImagePermissionGrant extends PermissionGrant {
|
|
47
|
+
scope: LocalImagePermissionScope | typeof LOCAL_IMAGE_CAPABILITY;
|
|
48
|
+
}
|
|
49
|
+
export interface LocalImageToolResult extends ClientToolResult {
|
|
50
|
+
modelContext?: {
|
|
51
|
+
visualObservations: readonly LocalImageObservation[];
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** ADR 90: local images are factual context, never instructions or persisted pixels. */
|
|
2
|
+
export const LOCAL_IMAGE_CAPABILITY = 'local.image.read';
|
|
3
|
+
export const LOCAL_IMAGE_TOOL = 'view_image';
|
|
4
|
+
export const LOCAL_IMAGE_MAX_BYTES = 8 * 1024 * 1024;
|
|
5
|
+
export const LOCAL_IMAGE_MAX_PIXELS = 24_000_000;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** ADR106/131: the existing Git Provider's concrete local read approval shape.
|
|
2
|
+
* This is an audit scope, never a deserializable execution authority token.
|
|
3
|
+
*/
|
|
4
|
+
export interface LocalReadPermissionScope {
|
|
5
|
+
readonly kind: 'file-read';
|
|
6
|
+
readonly capabilityId: string;
|
|
7
|
+
readonly path: string;
|
|
8
|
+
readonly workspacePath: string | null;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/memory.d.ts
CHANGED
|
@@ -4,7 +4,43 @@
|
|
|
4
4
|
import type { MessageDisposition } from './delegation.ts';
|
|
5
5
|
export type MemoryKind = 'fact' | 'preference' | 'decision' | 'procedure' | 'responsibility';
|
|
6
6
|
export type MemoryTrust = 'verified' | 'stated' | 'inferred';
|
|
7
|
-
export type MemoryStatus = 'active' | '
|
|
7
|
+
export type MemoryStatus = 'active' | 'needs_reverify' | 'conflicted' | 'quarantined' | 'archived';
|
|
8
|
+
export type LegacyMemoryStatus = Extract<MemoryStatus, 'active' | 'conflicted'> | 'forgotten' | 'expired';
|
|
9
|
+
export type MemoryScopeKey = 'global' | `project:${string}`;
|
|
10
|
+
export type MemoryRevision = string;
|
|
11
|
+
export declare function isMemoryScopeKey(value: unknown): value is MemoryScopeKey;
|
|
12
|
+
export declare function isMemoryRevision(value: unknown): value is MemoryRevision;
|
|
13
|
+
export interface MemoryRef {
|
|
14
|
+
readonly scopeKey: MemoryScopeKey;
|
|
15
|
+
readonly id: string;
|
|
16
|
+
readonly revision: MemoryRevision;
|
|
17
|
+
}
|
|
18
|
+
export type MemorySourceKind = 'user_message_span' | 'local_user_edit' | 'independent_verification' | 'workspace_file' | 'web' | 'attachment' | 'mcp' | 'model' | 'unknown';
|
|
19
|
+
export interface MemoryProvenance {
|
|
20
|
+
readonly sourceKind: MemorySourceKind;
|
|
21
|
+
readonly sources: readonly string[];
|
|
22
|
+
readonly taintSet: readonly MemorySourceKind[];
|
|
23
|
+
readonly refs: readonly MemoryRef[];
|
|
24
|
+
}
|
|
25
|
+
export type MemoryErrorCode = 'parse_warning' | 'quarantined' | 'revision_conflict' | 'commit_unknown' | 'memory_governance_unavailable' | 'invalid_scope' | 'path_escape' | 'duplicate_id' | 'memory_disabled' | 'invalid_id' | 'invalid_revision' | 'needs_reverify' | 'not_eligible' | 'missing_id' | 'not_found' | 'cancelled' | 'revoked' | 'purged' | 'storage_unavailable';
|
|
26
|
+
export type MemoryMutationStatus = 'prepared' | 'committed' | 'conflict' | 'blocked';
|
|
27
|
+
export interface MemoryMutationReceipt {
|
|
28
|
+
readonly mutationId: string;
|
|
29
|
+
readonly scopeKey: MemoryScopeKey;
|
|
30
|
+
readonly id: string;
|
|
31
|
+
readonly revision?: MemoryRevision;
|
|
32
|
+
readonly previousRevision?: MemoryRevision;
|
|
33
|
+
readonly status: MemoryMutationStatus;
|
|
34
|
+
readonly code?: MemoryErrorCode;
|
|
35
|
+
readonly reason?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface MemoryHealth {
|
|
38
|
+
readonly scopeKey: MemoryScopeKey;
|
|
39
|
+
readonly code: MemoryErrorCode;
|
|
40
|
+
readonly line?: number;
|
|
41
|
+
readonly column?: number;
|
|
42
|
+
readonly reason?: string;
|
|
43
|
+
}
|
|
8
44
|
export interface MemoryValidityFields {
|
|
9
45
|
readonly expiresAt?: string;
|
|
10
46
|
readonly topicKey?: string;
|
|
@@ -28,7 +64,7 @@ export interface MemoryItem extends MemoryValidityFields {
|
|
|
28
64
|
readonly trust: MemoryTrust;
|
|
29
65
|
readonly sourceRefs: readonly string[];
|
|
30
66
|
readonly pinned: boolean;
|
|
31
|
-
readonly status:
|
|
67
|
+
readonly status: LegacyMemoryStatus;
|
|
32
68
|
readonly confirmedCount: number;
|
|
33
69
|
readonly createdAt: string;
|
|
34
70
|
readonly lastUsedAt?: string;
|
|
@@ -60,7 +96,7 @@ export interface ProjectMemoryRecord extends MemoryValidityFields {
|
|
|
60
96
|
readonly trust: MemoryTrust;
|
|
61
97
|
readonly sourceRefs: readonly string[];
|
|
62
98
|
readonly pinned: boolean;
|
|
63
|
-
readonly status:
|
|
99
|
+
readonly status: LegacyMemoryStatus;
|
|
64
100
|
readonly confirmedCount: number;
|
|
65
101
|
readonly createdAt: string;
|
|
66
102
|
readonly updatedAt: string;
|
|
@@ -68,23 +104,42 @@ export interface ProjectMemoryRecord extends MemoryValidityFields {
|
|
|
68
104
|
readonly anchorMessageId?: string;
|
|
69
105
|
readonly forgetReason?: string;
|
|
70
106
|
}
|
|
71
|
-
export interface
|
|
72
|
-
readonly
|
|
107
|
+
export interface EffectiveMemoryPolicy {
|
|
108
|
+
readonly workspaceId: string;
|
|
109
|
+
readonly settingsRevision: string;
|
|
110
|
+
readonly profileRevision: string;
|
|
111
|
+
readonly policyEpoch: number;
|
|
112
|
+
readonly globalEnabled: boolean | null;
|
|
113
|
+
readonly projectEnabled: boolean | null;
|
|
114
|
+
readonly rawAutoCurate: boolean | null;
|
|
115
|
+
readonly rawLearnPreferences: boolean | null;
|
|
73
116
|
readonly useMemory: boolean;
|
|
117
|
+
readonly collectEpisodes: boolean;
|
|
118
|
+
readonly autoCurate: boolean;
|
|
74
119
|
readonly learnPreferences: boolean;
|
|
120
|
+
readonly reasonCodes: readonly string[];
|
|
121
|
+
readonly rootStatus: {
|
|
122
|
+
readonly status: string;
|
|
123
|
+
readonly readOnly: boolean;
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
export interface ProjectMemoryPolicyResult {
|
|
127
|
+
readonly ok: boolean;
|
|
128
|
+
readonly code?: string;
|
|
129
|
+
readonly policy?: EffectiveMemoryPolicy;
|
|
75
130
|
}
|
|
76
131
|
export interface ProjectMemoryListRequest {
|
|
77
132
|
readonly workspaceId: string;
|
|
78
133
|
readonly kind?: MemoryKind;
|
|
79
134
|
readonly trust?: MemoryTrust;
|
|
80
|
-
readonly status?:
|
|
135
|
+
readonly status?: LegacyMemoryStatus;
|
|
81
136
|
readonly ids?: readonly string[];
|
|
82
137
|
}
|
|
83
138
|
export interface ProjectMemoryListResult {
|
|
84
139
|
readonly ok: boolean;
|
|
85
140
|
readonly code?: string;
|
|
86
141
|
readonly items?: readonly ProjectMemoryRecord[];
|
|
87
|
-
readonly
|
|
142
|
+
readonly policy?: EffectiveMemoryPolicy;
|
|
88
143
|
}
|
|
89
144
|
export interface ProjectMemoryPinRequest {
|
|
90
145
|
readonly workspaceId: string;
|
|
@@ -124,14 +179,19 @@ export interface ProjectMemoryExportResult {
|
|
|
124
179
|
}
|
|
125
180
|
export interface ProjectMemorySetSwitchesRequest {
|
|
126
181
|
readonly workspaceId: string;
|
|
127
|
-
readonly
|
|
128
|
-
readonly
|
|
129
|
-
readonly learnPreferences?: boolean;
|
|
182
|
+
readonly patch: Partial<Record<'globalEnabled' | 'projectEnabled' | 'autoCurate' | 'learnPreferences', boolean>>;
|
|
183
|
+
readonly expected: Pick<EffectiveMemoryPolicy, 'settingsRevision' | 'profileRevision'>;
|
|
130
184
|
}
|
|
185
|
+
export type MemoryPolicyCommitStatus = 'unchanged' | 'applied' | 'conflict' | 'invalid' | 'failed' | 'unconfirmed';
|
|
131
186
|
export interface ProjectMemorySetSwitchesResult {
|
|
132
187
|
readonly ok: boolean;
|
|
133
188
|
readonly code?: string;
|
|
134
|
-
readonly
|
|
189
|
+
readonly settingsRevision?: string;
|
|
190
|
+
readonly profileRevision?: string;
|
|
191
|
+
readonly policyEpoch?: number;
|
|
192
|
+
readonly settingsCommit?: MemoryPolicyCommitStatus;
|
|
193
|
+
readonly profileCommit?: MemoryPolicyCommitStatus;
|
|
194
|
+
readonly effective?: EffectiveMemoryPolicy;
|
|
135
195
|
}
|
|
136
196
|
export type MemoryAdmission = {
|
|
137
197
|
readonly ok: true;
|
package/dist/memory.js
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Project memory contracts. Entries are facts for continuity, not instructions.
|
|
3
3
|
*/
|
|
4
|
+
export function isMemoryScopeKey(value) {
|
|
5
|
+
if (value === 'global')
|
|
6
|
+
return true;
|
|
7
|
+
if (typeof value !== 'string' || !value.startsWith('project:'))
|
|
8
|
+
return false;
|
|
9
|
+
const workspace = value.slice('project:'.length);
|
|
10
|
+
return /^[a-z0-9][a-z0-9_.-]{0,127}$(?![\s\S])/i.test(workspace) && !workspace.endsWith('.') &&
|
|
11
|
+
!/^(?:CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(?:\.|$)/i.test(workspace);
|
|
12
|
+
}
|
|
13
|
+
export function isMemoryRevision(value) {
|
|
14
|
+
return typeof value === 'string' && /^[a-f0-9]{64}$(?![\s\S])/.test(value);
|
|
15
|
+
}
|
|
4
16
|
const SECRET = /sk-[A-Za-z0-9]{8,}|api[_-]?key\s*[:=]|bearer\s+[A-Za-z0-9._\-]{8,}/i;
|
|
5
17
|
const LOOSENING = /不用确认|跳过批准|跳过审批|always allow|skip approval|full_local|不用我批/i;
|
|
6
18
|
const STANDING_ORDER = /以后都|下次都|always do this/i;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Provider-declared effort values. Unknown capabilities do not create UI choices. */
|
|
2
|
+
export type ModelReasoningEffort = 'off' | 'low' | 'medium' | 'default' | 'high' | 'xhigh' | 'max';
|
|
3
|
+
export declare function isModelReasoningEffort(value: unknown): value is ModelReasoningEffort;
|
|
4
|
+
export declare function modelReasoningLevels(provider: {
|
|
5
|
+
readonly supportsReasoning?: unknown;
|
|
6
|
+
readonly reasoningEffortLevels?: unknown;
|
|
7
|
+
readonly reasoningEffortMap?: unknown;
|
|
8
|
+
}): readonly ModelReasoningEffort[];
|
|
9
|
+
export declare function modelDefaultReasoningEffort(provider: {
|
|
10
|
+
readonly supportsReasoning?: unknown;
|
|
11
|
+
readonly reasoningEffortLevels?: unknown;
|
|
12
|
+
readonly reasoningEffortMap?: unknown;
|
|
13
|
+
readonly reasoningEffort?: unknown;
|
|
14
|
+
readonly reasoningDefaultEffort?: unknown;
|
|
15
|
+
readonly defaultEffort?: unknown;
|
|
16
|
+
}): ModelReasoningEffort | undefined;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const ORDER = ['off', 'low', 'medium', 'default', 'high', 'xhigh', 'max'];
|
|
2
|
+
export function isModelReasoningEffort(value) {
|
|
3
|
+
return ORDER.includes(value);
|
|
4
|
+
}
|
|
5
|
+
export function modelReasoningLevels(provider) {
|
|
6
|
+
if (provider.supportsReasoning === false)
|
|
7
|
+
return [];
|
|
8
|
+
if (Array.isArray(provider.reasoningEffortLevels)) {
|
|
9
|
+
const declared = provider.reasoningEffortLevels;
|
|
10
|
+
return ORDER.filter(value => declared.includes(value));
|
|
11
|
+
}
|
|
12
|
+
if (provider.reasoningEffortMap && typeof provider.reasoningEffortMap === 'object' && !Array.isArray(provider.reasoningEffortMap)) {
|
|
13
|
+
const keys = Object.keys(provider.reasoningEffortMap);
|
|
14
|
+
return ORDER.filter(value => keys.includes(value));
|
|
15
|
+
}
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
export function modelDefaultReasoningEffort(provider) {
|
|
19
|
+
const levels = modelReasoningLevels(provider);
|
|
20
|
+
for (const value of [provider.reasoningEffort, provider.reasoningDefaultEffort, provider.defaultEffort, 'default', 'medium', 'high', 'low', ...levels]) {
|
|
21
|
+
if (isModelReasoningEffort(value) && levels.includes(value))
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
package/dist/model-routing.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { type ModelReasoningEffort } from './model-reasoning.ts';
|
|
1
2
|
/**
|
|
2
3
|
* Role and tier model routing. Resolution is pure; hosts apply the result.
|
|
3
4
|
* Order and filters follow ADR 83. An empty candidate set is an error, not a silent downgrade.
|
|
4
5
|
*/
|
|
5
6
|
export type ModelTier = 'strong' | 'fast' | 'economy' | 'vision';
|
|
6
|
-
export type ModelRole = 'project_agent' | 'session_worker' | 'explorer' | 'verifier' | 'visual_verifier' | 'memory_curator' | 'objective_probe' | 'compactor';
|
|
7
|
-
export type RoleSetting = {
|
|
7
|
+
export type ModelRole = 'project_agent' | 'session_worker' | 'explorer' | 'verifier' | 'visual_verifier' | 'memory_curator' | 'objective_probe' | 'compactor' | 'input_predictor';
|
|
8
|
+
export type RoleSetting = ({
|
|
8
9
|
readonly mode: 'tier';
|
|
9
10
|
readonly tier: ModelTier;
|
|
10
11
|
} | {
|
|
@@ -13,11 +14,26 @@ export type RoleSetting = {
|
|
|
13
14
|
} | {
|
|
14
15
|
readonly mode: 'auto';
|
|
15
16
|
readonly pool: readonly string[];
|
|
17
|
+
}) & {
|
|
18
|
+
/** Undefined inherits the tier; null explicitly uses the model default. */
|
|
19
|
+
readonly reasoningEffort?: ModelReasoningEffort | null;
|
|
20
|
+
/** Undefined inherits the tier; false explicitly selects the normal channel. */
|
|
21
|
+
readonly fastMode?: boolean;
|
|
16
22
|
};
|
|
17
23
|
export interface ModelTierBinding {
|
|
18
24
|
readonly primary: string;
|
|
19
25
|
readonly fallbacks?: readonly string[];
|
|
26
|
+
readonly reasoningEffort?: ModelReasoningEffort;
|
|
27
|
+
readonly fastMode?: boolean;
|
|
20
28
|
}
|
|
29
|
+
/** Admission matches the existing priority request encoders, never a model-name guess. */
|
|
30
|
+
export declare function modelSupportsFastMode(provider: {
|
|
31
|
+
readonly authMethod?: unknown;
|
|
32
|
+
}): boolean;
|
|
33
|
+
export declare function routingParameters(setting: RoleSetting, tiers: Partial<Record<ModelTier, ModelTierBinding>>): {
|
|
34
|
+
reasoningEffort: ModelReasoningEffort | undefined;
|
|
35
|
+
fastMode: boolean;
|
|
36
|
+
};
|
|
21
37
|
export interface ModelRoutingSettings {
|
|
22
38
|
readonly tiers: Partial<Record<ModelTier, ModelTierBinding>>;
|
|
23
39
|
readonly roles: Partial<Record<ModelRole, RoleSetting>>;
|
|
@@ -40,6 +56,8 @@ export interface RuntimeModelSelection {
|
|
|
40
56
|
readonly modelId: string;
|
|
41
57
|
readonly modelProviderId: string;
|
|
42
58
|
readonly reasoningEffort?: string;
|
|
59
|
+
/** Subscription priority channel. Encoding still admits only ChatGPT and Grok OAuth. */
|
|
60
|
+
readonly fastMode?: boolean;
|
|
43
61
|
readonly family: string;
|
|
44
62
|
}
|
|
45
63
|
export interface ModelSelectionSnapshot {
|
|
@@ -65,7 +83,15 @@ export interface ModelRoutingMenuOption {
|
|
|
65
83
|
readonly supportsTools: boolean;
|
|
66
84
|
readonly supportsStructured: boolean;
|
|
67
85
|
readonly contextTokens: number;
|
|
86
|
+
readonly available?: boolean;
|
|
87
|
+
readonly reasoningEffortLevels?: readonly ModelReasoningEffort[];
|
|
88
|
+
readonly defaultReasoningEffort?: ModelReasoningEffort;
|
|
89
|
+
}
|
|
90
|
+
export interface BotRoleModelView {
|
|
91
|
+
readonly resolution: ModelResolution;
|
|
92
|
+
readonly eligibleModelIds: readonly string[];
|
|
68
93
|
}
|
|
94
|
+
export type BotModelViews = Partial<Record<ModelRole, BotRoleModelView>>;
|
|
69
95
|
/** Project one configured provider into the routing menu contract. */
|
|
70
96
|
export declare function projectModelRoutingMenuOption(provider: {
|
|
71
97
|
readonly id?: unknown;
|
|
@@ -81,6 +107,14 @@ export declare function projectModelRoutingMenuOption(provider: {
|
|
|
81
107
|
readonly toolUse?: unknown;
|
|
82
108
|
} | null;
|
|
83
109
|
readonly contextWindow?: unknown;
|
|
110
|
+
readonly apiKeyConfigured?: unknown;
|
|
111
|
+
readonly enabled?: unknown;
|
|
112
|
+
readonly supportsReasoning?: unknown;
|
|
113
|
+
readonly reasoningEffortLevels?: unknown;
|
|
114
|
+
readonly reasoningEffortMap?: unknown;
|
|
115
|
+
readonly reasoningEffort?: unknown;
|
|
116
|
+
readonly reasoningDefaultEffort?: unknown;
|
|
117
|
+
readonly defaultEffort?: unknown;
|
|
84
118
|
} | null | undefined): ModelRoutingMenuOption | null;
|
|
85
119
|
export interface CatalogModel {
|
|
86
120
|
readonly modelProviderId: string;
|
|
@@ -93,6 +127,8 @@ export interface CatalogModel {
|
|
|
93
127
|
readonly contextTokens?: number;
|
|
94
128
|
readonly local?: boolean;
|
|
95
129
|
readonly reasoningEffort?: string;
|
|
130
|
+
readonly reasoningEffortLevels?: readonly ModelReasoningEffort[];
|
|
131
|
+
readonly supportsFastMode?: boolean;
|
|
96
132
|
}
|
|
97
133
|
export type ModelResolution = {
|
|
98
134
|
readonly ok: true;
|
|
@@ -101,7 +137,7 @@ export type ModelResolution = {
|
|
|
101
137
|
readonly sameFamilyAsWorker?: boolean;
|
|
102
138
|
} | {
|
|
103
139
|
readonly ok: false;
|
|
104
|
-
readonly reason: 'capability' | 'scope' | 'auto_pool' | 'empty';
|
|
140
|
+
readonly reason: 'capability' | 'scope' | 'auto_pool' | 'empty' | 'reasoning' | 'fast_mode';
|
|
105
141
|
readonly missing: string;
|
|
106
142
|
};
|
|
107
143
|
export interface RoleModelRequest {
|
package/dist/model-routing.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { modelDefaultReasoningEffort, modelReasoningLevels } from "./model-reasoning.js";
|
|
2
|
+
/** Admission matches the existing priority request encoders, never a model-name guess. */
|
|
3
|
+
export function modelSupportsFastMode(provider) {
|
|
4
|
+
return provider.authMethod === 'oauth_chatgpt' || provider.authMethod === 'oauth_grok';
|
|
5
|
+
}
|
|
6
|
+
export function routingParameters(setting, tiers) {
|
|
7
|
+
const tier = setting.mode === 'tier' ? tiers[setting.tier] : undefined;
|
|
8
|
+
return {
|
|
9
|
+
reasoningEffort: (setting.reasoningEffort === undefined ? tier?.reasoningEffort : setting.reasoningEffort) ?? undefined,
|
|
10
|
+
fastMode: setting.fastMode ?? tier?.fastMode ?? false,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
5
13
|
/** Project one configured provider into the routing menu contract. */
|
|
6
14
|
export function projectModelRoutingMenuOption(provider) {
|
|
7
15
|
if (!provider || typeof provider.id !== 'string' || !provider.id.trim())
|
|
@@ -24,6 +32,9 @@ export function projectModelRoutingMenuOption(provider) {
|
|
|
24
32
|
supportsTools: provider.supportsTools !== false && provider.capabilities?.toolUse !== false,
|
|
25
33
|
supportsStructured: provider.supportsStructured !== false,
|
|
26
34
|
contextTokens: Number.isFinite(context) && context > 0 ? context : 128_000,
|
|
35
|
+
available: provider.enabled !== false && provider.apiKeyConfigured === true,
|
|
36
|
+
reasoningEffortLevels: modelReasoningLevels(provider),
|
|
37
|
+
defaultReasoningEffort: modelDefaultReasoningEffort(provider),
|
|
27
38
|
};
|
|
28
39
|
}
|
|
29
40
|
const EXPLORER_MIN_CONTEXT = 8_000;
|
|
@@ -45,6 +56,7 @@ function roleNeeds(input) {
|
|
|
45
56
|
case 'objective_probe':
|
|
46
57
|
return { tools: true, vision: false, structured: false, minContext: 0 };
|
|
47
58
|
case 'compactor':
|
|
59
|
+
case 'input_predictor':
|
|
48
60
|
return { tools: false, vision: false, structured: false, minContext: Math.max(context, 1) };
|
|
49
61
|
default:
|
|
50
62
|
return { tools: false, vision: false, structured: false, minContext: 0 };
|
|
@@ -75,6 +87,10 @@ function inScope(model, policy) {
|
|
|
75
87
|
return true;
|
|
76
88
|
}
|
|
77
89
|
function missingText(input, reason) {
|
|
90
|
+
if (reason === 'fast_mode')
|
|
91
|
+
return '所选连接不支持快速通道,请选择正常通道或支持的连接';
|
|
92
|
+
if (reason === 'reasoning')
|
|
93
|
+
return '所选模型不支持该推理强度';
|
|
78
94
|
if (reason === 'auto_pool')
|
|
79
95
|
return '所选模型不在自动池内';
|
|
80
96
|
const localOnly = input.projectPolicy?.scope?.localOnly === true;
|
|
@@ -226,10 +242,20 @@ export function resolveRoleModel(input) {
|
|
|
226
242
|
const chosen = ordered[0];
|
|
227
243
|
if (!chosen)
|
|
228
244
|
return fail(input, 'empty');
|
|
245
|
+
const parameters = routingParameters(layer.setting, input.routing.tiers);
|
|
246
|
+
const requestedEffort = parameters.reasoningEffort;
|
|
247
|
+
if (requestedEffort !== undefined && !chosen.reasoningEffortLevels?.includes(requestedEffort))
|
|
248
|
+
return fail(input, 'reasoning');
|
|
249
|
+
if (parameters.fastMode && chosen.supportsFastMode !== true)
|
|
250
|
+
return fail(input, 'fast_mode');
|
|
229
251
|
const source = layer.setting.mode === 'auto' ? 'auto' : layer.source;
|
|
230
252
|
return {
|
|
231
253
|
ok: true,
|
|
232
|
-
selection:
|
|
254
|
+
selection: {
|
|
255
|
+
...toSelection(chosen),
|
|
256
|
+
...(requestedEffort !== undefined ? { reasoningEffort: requestedEffort } : {}),
|
|
257
|
+
fastMode: parameters.fastMode,
|
|
258
|
+
},
|
|
233
259
|
source,
|
|
234
260
|
...(input.role === 'verifier'
|
|
235
261
|
? { sameFamilyAsWorker: sameFamily(chosen, input.workerModel) }
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { SessionControlOperation } from './session-control.ts';
|
|
2
|
+
import { type SessionExecutionIdentity } from './session-control.ts';
|
|
3
|
+
type Recorder = NonNullable<SessionControlOperation['recorder']>;
|
|
4
|
+
export interface NativeOwnedProcess {
|
|
5
|
+
readonly schemaVersion: 1;
|
|
6
|
+
readonly kind: 'command';
|
|
7
|
+
readonly handleId: string;
|
|
8
|
+
readonly toolCallId: string;
|
|
9
|
+
readonly dispatchId: string;
|
|
10
|
+
readonly execution: SessionExecutionIdentity;
|
|
11
|
+
readonly generation: number;
|
|
12
|
+
readonly state: 'not_started' | 'starting' | 'running' | 'ended';
|
|
13
|
+
readonly owner: Recorder;
|
|
14
|
+
readonly child?: Recorder | null;
|
|
15
|
+
readonly stopObservation?: 'owned_completion' | 'owner_dead_not_started' | 'owner_dead_group_absent' | null;
|
|
16
|
+
}
|
|
17
|
+
/** Envelope shape only. Execution identity is validated by each owning contract. */
|
|
18
|
+
export declare function nativeProcessEnvelopeValid(raw: unknown): boolean;
|
|
19
|
+
/** Shape only: no value here proves local execution or process death. */
|
|
20
|
+
export declare function nativeProcessesInWork(work: unknown): readonly NativeOwnedProcess[];
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { normalizeSessionExecutionIdentity } from "./session-control.js";
|
|
2
|
+
const object = (v) => v !== null && typeof v === 'object' && !Array.isArray(v) ? v : {};
|
|
3
|
+
const text = (v, bytes) => typeof v === 'string' && v.length > 0 && v.length <= bytes && new TextEncoder().encode(v).length <= bytes;
|
|
4
|
+
const recorder = (v) => {
|
|
5
|
+
const r = object(v);
|
|
6
|
+
return Number.isInteger(r.pid) && r.pid > 0 && r.pid <= 2147483647
|
|
7
|
+
&& ['bootId', 'pidStart', 'hostId', 'acquiredAt'].every(k => text(r[k], 8192));
|
|
8
|
+
};
|
|
9
|
+
/** Envelope shape only. Execution identity is validated by each owning contract. */
|
|
10
|
+
export function nativeProcessEnvelopeValid(raw) {
|
|
11
|
+
const p = object(raw), owner = object(p.owner), child = object(p.child);
|
|
12
|
+
const keys = ['schemaVersion', 'kind', 'handleId', 'toolCallId', 'dispatchId', 'execution', 'generation', 'state', 'owner', 'child', 'stopObservation'];
|
|
13
|
+
const validChild = p.child == null || recorder(child) && ['hostId', 'acquiredAt', 'bootId'].every(k => child[k] === owner[k]);
|
|
14
|
+
const gen = Number.isInteger(p.generation) && p.generation >= 0 && p.generation <= 64;
|
|
15
|
+
const phase = p.state === 'not_started' ? p.generation === 0 && p.child == null && p.stopObservation == null
|
|
16
|
+
: p.state === 'starting' ? p.generation > 0 && p.child == null && p.stopObservation == null
|
|
17
|
+
: p.state === 'running' ? p.generation > 0 && p.child != null && p.stopObservation == null
|
|
18
|
+
: p.state === 'ended' && (p.stopObservation === 'owned_completion'
|
|
19
|
+
|| p.stopObservation === 'owner_dead_not_started' && p.generation === 0 && p.child == null
|
|
20
|
+
|| p.stopObservation === 'owner_dead_group_absent' && p.generation > 0 && p.child != null);
|
|
21
|
+
return p.schemaVersion === 1 && p.kind === 'command' && !Object.keys(p).some(k => !keys.includes(k))
|
|
22
|
+
&& ['handleId', 'toolCallId', 'dispatchId'].every(k => text(p[k], 200))
|
|
23
|
+
&& !!gen && !!phase && recorder(owner) && !!validChild;
|
|
24
|
+
}
|
|
25
|
+
/** Shape only: no value here proves local execution or process death. */
|
|
26
|
+
export function nativeProcessesInWork(work) {
|
|
27
|
+
const budget = object(object(work).budget);
|
|
28
|
+
const rows = [...Object.values(object(budget.attempts)).flatMap(a => {
|
|
29
|
+
const pending = object(a).pendingTools;
|
|
30
|
+
return Array.isArray(pending) ? pending : [];
|
|
31
|
+
}), ...(Array.isArray(budget.uncertainDispatches) ? budget.uncertainDispatches : [])];
|
|
32
|
+
const result = [];
|
|
33
|
+
for (const raw of rows) {
|
|
34
|
+
const row = object(raw);
|
|
35
|
+
if (!Object.hasOwn(row, 'nativeProcess'))
|
|
36
|
+
continue;
|
|
37
|
+
const p = object(row.nativeProcess), owner = object(p.owner);
|
|
38
|
+
const original = object(object(row.nativeRecorder).recorder);
|
|
39
|
+
const execution = normalizeSessionExecutionIdentity(p.execution);
|
|
40
|
+
const recordedExecution = normalizeSessionExecutionIdentity(object(row.nativeRecorder).execution);
|
|
41
|
+
if (!nativeProcessEnvelopeValid(p) || !recorder(original) || !execution || !recordedExecution
|
|
42
|
+
|| JSON.stringify(execution) !== JSON.stringify(recordedExecution)
|
|
43
|
+
|| !['pid', 'pidStart', 'bootId', 'hostId', 'acquiredAt'].every(k => owner[k] === original[k])
|
|
44
|
+
|| p.toolCallId !== row.toolCallId || p.dispatchId !== row.dispatchId || result.length >= 128
|
|
45
|
+
|| result.some(old => old.handleId === p.handleId || old.toolCallId === p.toolCallId || old.dispatchId === p.dispatchId)) {
|
|
46
|
+
throw new Error('native_process_invalid');
|
|
47
|
+
}
|
|
48
|
+
result.push(structuredClone(p));
|
|
49
|
+
}
|
|
50
|
+
return result;
|
|
51
|
+
}
|