qlogicagent 2.11.2 → 2.11.4
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/cli.js +278 -270
- package/dist/index.js +277 -269
- package/dist/pet-contracts.js +1 -1
- package/dist/protocol.js +1 -1
- package/dist/types/cli/handlers/session-handler.d.ts +3 -3
- package/dist/types/cli/media-runtime-facade.d.ts +8 -0
- package/dist/types/cli/permission-bootstrap.d.ts +7 -0
- package/dist/types/cli/pet-runtime.d.ts +1 -3
- package/dist/types/cli/session-coordinator.d.ts +9 -0
- package/dist/types/cli/session-query-service.d.ts +1 -0
- package/dist/types/cli/tool-bootstrap.d.ts +31 -2
- package/dist/types/cli/turn-permission-sync.d.ts +1 -2
- package/dist/types/protocol/wire/acp-protocol.d.ts +7 -0
- package/dist/types/protocol/wire/chat-types.d.ts +6 -0
- package/dist/types/protocol/wire/gateway-rpc.d.ts +1 -0
- package/dist/types/protocol/wire/notification-payloads.d.ts +12 -0
- package/dist/types/protocol/wire/pet-contracts.d.ts +3 -2
- package/dist/types/runtime/infra/acp-detector.d.ts +21 -0
- package/dist/types/runtime/infra/default-path-service.d.ts +3 -0
- package/dist/types/runtime/infra/project-store.d.ts +1 -0
- package/dist/types/runtime/permission-model.d.ts +19 -0
- package/dist/types/runtime/pet/hatch-pet-runner.d.ts +18 -0
- package/dist/types/runtime/pet/index.d.ts +12 -5
- package/dist/types/runtime/pet/pet-file-loader.d.ts +1 -1
- package/dist/types/runtime/pet/pet-growth-engine.d.ts +2 -58
- package/dist/types/runtime/pet/pet-profile-service.d.ts +5 -7
- package/dist/types/runtime/pet/pet-reaction-engine.d.ts +11 -0
- package/dist/types/runtime/pet/pet-soul-service.d.ts +2 -2
- package/dist/types/runtime/pet/pet-types.d.ts +1 -32
- package/dist/types/runtime/pet/petdex-asset.d.ts +3 -109
- package/dist/types/runtime/pet/petdex-forge-service.d.ts +3 -94
- package/dist/types/runtime/ports/path-service.d.ts +10 -0
- package/dist/types/runtime/ports/permission-contracts.d.ts +20 -3
- package/dist/types/runtime/ports/tool-contracts.d.ts +3 -0
- package/dist/types/runtime/ports/tool-risk.d.ts +7 -0
- package/dist/types/runtime/prompt/fresh-workspace-evidence.d.ts +1 -0
- package/dist/types/runtime/session/session-locator.d.ts +2 -0
- package/dist/types/runtime/session/session-persistence.d.ts +17 -3
- package/dist/types/skills/permissions/hook-runner.d.ts +3 -0
- package/dist/types/skills/permissions/operation-classifier.d.ts +36 -0
- package/dist/types/skills/permissions/rule-engine.d.ts +19 -14
- package/dist/types/skills/portable-tool.d.ts +18 -0
- package/dist/types/skills/tools/exec-tool.d.ts +7 -0
- package/dist/types/skills/tools/patch-tool.d.ts +7 -0
- package/dist/types/skills/tools/petdex-create-tool.d.ts +2 -16
- package/dist/types/skills/tools/shell/sandbox/helper-resolver.d.ts +7 -0
- package/dist/types/skills/tools/shell/sandbox/landlock-argv.d.ts +6 -0
- package/dist/types/skills/tools/shell/sandbox/platform.d.ts +3 -0
- package/dist/types/skills/tools/shell/sandbox/sandbox-launcher.d.ts +15 -0
- package/dist/types/skills/tools/shell/sandbox/sandbox-scope.d.ts +6 -0
- package/dist/types/skills/tools/shell/sandbox/sandbox-types.d.ts +47 -0
- package/dist/types/skills/tools/shell/sandbox/seatbelt-profile.d.ts +6 -0
- package/dist/types/skills/tools/shell/shell-exec.d.ts +3 -0
- package/dist/vendor/hatch-pet/LICENSE.txt +201 -0
- package/dist/vendor/hatch-pet/NOTICE.md +25 -0
- package/dist/vendor/hatch-pet/references/animation-rows.md +29 -0
- package/dist/vendor/hatch-pet/references/codex-pet-contract.md +35 -0
- package/dist/vendor/hatch-pet/references/qa-rubric.md +66 -0
- package/dist/vendor/hatch-pet/scripts/compose_atlas.py +169 -0
- package/dist/vendor/hatch-pet/scripts/derive_running_left_from_running_right.py +150 -0
- package/dist/vendor/hatch-pet/scripts/extract_strip_frames.py +408 -0
- package/dist/vendor/hatch-pet/scripts/inspect_frames.py +256 -0
- package/dist/vendor/hatch-pet/scripts/make_contact_sheet.py +96 -0
- package/dist/vendor/hatch-pet/scripts/prepare_pet_run.py +830 -0
- package/dist/vendor/hatch-pet/scripts/render_animation_previews.py +78 -0
- package/dist/vendor/hatch-pet/scripts/validate_atlas.py +157 -0
- package/package.json +5 -3
- package/dist/types/runtime/pet/pet-reaction-service.d.ts +0 -33
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
export
|
|
1
|
+
import { hasPetAgentBoundaryViolationText, type PetSoul, type PetStats } from "@xiaozhiclaw/pet-core";
|
|
2
|
+
export { hasPetAgentBoundaryViolationText };
|
|
3
3
|
export declare class PetSoulService {
|
|
4
4
|
private soul;
|
|
5
5
|
private profileService;
|
|
@@ -1,32 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
grip: number;
|
|
3
|
-
patience: number;
|
|
4
|
-
curiosity: number;
|
|
5
|
-
appetite: number;
|
|
6
|
-
humor: number;
|
|
7
|
-
}
|
|
8
|
-
export interface PetSoul {
|
|
9
|
-
name: string;
|
|
10
|
-
species: string;
|
|
11
|
-
personality: string;
|
|
12
|
-
catchphrase: string;
|
|
13
|
-
stats: PetStats;
|
|
14
|
-
rarity: string;
|
|
15
|
-
breed?: string;
|
|
16
|
-
breedColors?: {
|
|
17
|
-
primary: string;
|
|
18
|
-
secondary: string;
|
|
19
|
-
};
|
|
20
|
-
level: number;
|
|
21
|
-
experience: number;
|
|
22
|
-
hatchedAt: string;
|
|
23
|
-
}
|
|
24
|
-
export interface PetBreed {
|
|
25
|
-
id: string;
|
|
26
|
-
name: string;
|
|
27
|
-
colors: {
|
|
28
|
-
primary: string;
|
|
29
|
-
secondary: string;
|
|
30
|
-
};
|
|
31
|
-
rarity: string;
|
|
32
|
-
}
|
|
1
|
+
export type { PetStats, PetSoul, PetBreed } from "@xiaozhiclaw/pet-core";
|
|
@@ -1,111 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
readonly format: "webp";
|
|
5
|
-
readonly columns: 8;
|
|
6
|
-
readonly rows: 9;
|
|
7
|
-
readonly frameCount: 72;
|
|
8
|
-
readonly cellWidth: 192;
|
|
9
|
-
readonly cellHeight: 208;
|
|
10
|
-
readonly width: 1536;
|
|
11
|
-
readonly height: 1872;
|
|
12
|
-
};
|
|
13
|
-
export declare const PETDEX_ANIMATION_IDS: readonly ["idle", "thinking", "working", "done", "happy", "error", "attention", "dragging", "sleeping"];
|
|
14
|
-
export type PetdexAnimationId = typeof PETDEX_ANIMATION_IDS[number];
|
|
15
|
-
export interface PetdexAnimation {
|
|
16
|
-
frames: number[];
|
|
17
|
-
fps: number;
|
|
18
|
-
loop: boolean;
|
|
19
|
-
}
|
|
20
|
-
export interface PetdexAtlas {
|
|
21
|
-
image: "spritesheet.webp";
|
|
22
|
-
format: "webp";
|
|
23
|
-
columns: 8;
|
|
24
|
-
rows: 9;
|
|
25
|
-
frameCount: 72;
|
|
26
|
-
cellWidth: 192;
|
|
27
|
-
cellHeight: 208;
|
|
28
|
-
width: 1536;
|
|
29
|
-
height: 1872;
|
|
30
|
-
sha256: string;
|
|
31
|
-
imageUrl?: string;
|
|
32
|
-
}
|
|
33
|
-
export interface PetdexAssetSource {
|
|
34
|
-
kind: "builtin" | "upload" | "forge";
|
|
35
|
-
prompt: string | null;
|
|
36
|
-
}
|
|
37
|
-
export interface PetdexPetAsset {
|
|
38
|
-
schema: typeof PETDEX_SCHEMA;
|
|
39
|
-
id: string;
|
|
40
|
-
assetKind: "petdex";
|
|
41
|
-
name: string;
|
|
42
|
-
description: string;
|
|
43
|
-
createdAt: string;
|
|
44
|
-
updatedAt: string;
|
|
45
|
-
source: PetdexAssetSource;
|
|
46
|
-
atlas: PetdexAtlas;
|
|
47
|
-
animations: Record<PetdexAnimationId, PetdexAnimation>;
|
|
48
|
-
thumbnail: {
|
|
49
|
-
frame: number;
|
|
50
|
-
};
|
|
51
|
-
sourcePrompt?: string;
|
|
52
|
-
}
|
|
53
|
-
export type PetdexAssetManifest = PetdexPetAsset;
|
|
54
|
-
export interface PetdexPetAssetSummary {
|
|
55
|
-
id: string;
|
|
56
|
-
assetKind: "petdex";
|
|
57
|
-
sourceKind: PetdexAssetSource["kind"];
|
|
58
|
-
name: string;
|
|
59
|
-
description: string;
|
|
60
|
-
createdAt: string;
|
|
61
|
-
updatedAt: string;
|
|
62
|
-
atlas: Omit<PetdexAtlas, "image" | "imageUrl"> & {
|
|
63
|
-
imageUrl?: string;
|
|
64
|
-
};
|
|
65
|
-
animations?: Record<PetdexAnimationId, PetdexAnimation>;
|
|
66
|
-
thumbnail?: {
|
|
67
|
-
frame: number;
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
export interface PetdexValidationReport {
|
|
71
|
-
schema: typeof PETDEX_VALIDATION_SCHEMA;
|
|
72
|
-
assetId: string;
|
|
73
|
-
valid: boolean;
|
|
74
|
-
validatedAt: string;
|
|
75
|
-
errors: string[];
|
|
76
|
-
warnings: string[];
|
|
77
|
-
atlas: {
|
|
78
|
-
format: "webp";
|
|
79
|
-
columns: 8;
|
|
80
|
-
rows: 9;
|
|
81
|
-
frameCount: 72;
|
|
82
|
-
cellWidth: 192;
|
|
83
|
-
cellHeight: 208;
|
|
84
|
-
width: number;
|
|
85
|
-
height: number;
|
|
86
|
-
sha256: string;
|
|
87
|
-
};
|
|
88
|
-
animations: {
|
|
89
|
-
ids: PetdexAnimationId[];
|
|
90
|
-
minFrame: number;
|
|
91
|
-
maxFrame: number;
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
export interface LoadedPetdexPackage {
|
|
95
|
-
manifest: PetdexPetAsset;
|
|
96
|
-
spritesheet: Buffer;
|
|
97
|
-
validation: PetdexValidationReport;
|
|
98
|
-
}
|
|
99
|
-
export type PetdexAssetPackage = LoadedPetdexPackage;
|
|
100
|
-
export type PetdexAssetValidation = PetdexValidationReport;
|
|
101
|
-
export interface PetdexImportResult {
|
|
102
|
-
asset: PetdexPetAsset;
|
|
103
|
-
summary: PetdexPetAssetSummary;
|
|
104
|
-
validation: PetdexValidationReport;
|
|
105
|
-
}
|
|
106
|
-
export declare function createDefaultPetdexAnimations(): Record<PetdexAnimationId, PetdexAnimation>;
|
|
107
|
-
export declare function toPetdexAssetSummary(asset: PetdexPetAsset, imageUrl?: string): PetdexPetAssetSummary;
|
|
108
|
-
export declare function validatePetdexAssetManifest(manifest: unknown, spritesheet: Buffer): PetdexValidationReport;
|
|
1
|
+
import { type PetdexAssetSource, type PetdexPetAsset, type PetdexValidationReport, type LoadedPetdexPackage, type PetdexImportResult } from "@xiaozhiclaw/pet-core";
|
|
2
|
+
export { PETDEX_SCHEMA, PETDEX_VALIDATION_SCHEMA, PETDEX_ATLAS_CONTRACT, PETDEX_ANIMATION_IDS, createDefaultPetdexAnimations, toPetdexAssetSummary, validatePetdexAssetManifest, petdexImageDataUrl, } from "@xiaozhiclaw/pet-core";
|
|
3
|
+
export type { PetdexAnimationId, PetdexAnimation, PetdexAtlas, PetdexAssetSource, PetdexPetAsset, PetdexAssetManifest, PetdexPetAssetSummary, PetdexValidationReport, LoadedPetdexPackage, PetdexAssetPackage, PetdexAssetValidation, PetdexImportResult, } from "@xiaozhiclaw/pet-core";
|
|
109
4
|
export declare function loadPetdexAssetPackage(filePath: string): Promise<LoadedPetdexPackage>;
|
|
110
5
|
export declare function buildPetdexAssetImport(filePath: string, targetDir: string): Promise<PetdexImportResult>;
|
|
111
6
|
export declare function writePetdexAssetPackage(params: {
|
|
@@ -135,4 +30,3 @@ export declare function listBuiltinPetdexAssets(): Promise<Array<{
|
|
|
135
30
|
spritesheet: Buffer;
|
|
136
31
|
validation: PetdexValidationReport;
|
|
137
32
|
}>>;
|
|
138
|
-
export declare function petdexImageDataUrl(spritesheet: Buffer): string;
|
|
@@ -1,84 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
name: string;
|
|
5
|
-
description: string;
|
|
6
|
-
prompt?: string | null;
|
|
7
|
-
referenceImageUrl?: string;
|
|
8
|
-
referenceMode?: "identity" | "refine";
|
|
9
|
-
baseSpritesheet?: Buffer;
|
|
10
|
-
refineAnimationId?: PetdexAnimationId;
|
|
11
|
-
refineFrameIndexes?: number[];
|
|
12
|
-
}
|
|
13
|
-
export interface PetdexImageGenerationRequest {
|
|
14
|
-
prompt: string;
|
|
15
|
-
purpose: "petdex-reference" | "petdex-row-strip";
|
|
16
|
-
animationId?: PetdexAnimationId;
|
|
17
|
-
style: string;
|
|
18
|
-
size: string;
|
|
19
|
-
imageUrl?: string;
|
|
20
|
-
referenceImages?: PetdexProductionReferenceImage[];
|
|
21
|
-
n: 1;
|
|
22
|
-
quality: "auto";
|
|
23
|
-
}
|
|
24
|
-
export interface PetdexImageGenerationResult {
|
|
25
|
-
mediaUrls: string[];
|
|
26
|
-
model?: string;
|
|
27
|
-
size?: string;
|
|
28
|
-
durationMs?: number;
|
|
29
|
-
provider?: string;
|
|
30
|
-
billingUnit?: string;
|
|
31
|
-
billingQuantity?: number;
|
|
32
|
-
}
|
|
33
|
-
export interface PetdexForgeOutput {
|
|
34
|
-
asset: PetdexPetAsset;
|
|
35
|
-
spritesheet: Buffer;
|
|
36
|
-
validation: PetdexValidationReport;
|
|
37
|
-
prompt: string;
|
|
38
|
-
productionRun: PetdexProductionRun;
|
|
39
|
-
model?: string;
|
|
40
|
-
size?: string;
|
|
41
|
-
durationMs?: number;
|
|
42
|
-
mediaUsage?: {
|
|
43
|
-
provider: string;
|
|
44
|
-
model: string;
|
|
45
|
-
billingUnit: string;
|
|
46
|
-
billingQuantity: number;
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
export declare const PETDEX_PRODUCTION_SCHEMA: "qlogic.petdex.production.v1";
|
|
50
|
-
export interface PetdexProductionReferenceImage {
|
|
51
|
-
role: "canonical-reference" | "layout-guide" | "existing-atlas";
|
|
52
|
-
imageUrl: string;
|
|
53
|
-
}
|
|
54
|
-
export interface PetdexProductionJob {
|
|
55
|
-
id: string;
|
|
56
|
-
kind: "reference" | "row-strip";
|
|
57
|
-
status: "complete";
|
|
58
|
-
animationId?: PetdexAnimationId;
|
|
59
|
-
prompt: string;
|
|
60
|
-
inputImages: PetdexProductionReferenceImage[];
|
|
61
|
-
outputUrl: string;
|
|
62
|
-
}
|
|
63
|
-
export interface PetdexProductionRun {
|
|
64
|
-
schema: typeof PETDEX_PRODUCTION_SCHEMA;
|
|
65
|
-
status: "complete";
|
|
66
|
-
sourceMode: "text" | "reference" | "refine";
|
|
67
|
-
contract: typeof PETDEX_ATLAS_CONTRACT;
|
|
68
|
-
jobs: PetdexProductionJob[];
|
|
69
|
-
qa: {
|
|
70
|
-
contactSheet: {
|
|
71
|
-
rows: typeof PETDEX_ATLAS_CONTRACT.rows;
|
|
72
|
-
columns: typeof PETDEX_ATLAS_CONTRACT.columns;
|
|
73
|
-
frameCount: typeof PETDEX_ATLAS_CONTRACT.frameCount;
|
|
74
|
-
};
|
|
75
|
-
rowReports: Array<{
|
|
76
|
-
animationId: PetdexAnimationId;
|
|
77
|
-
status: "pass";
|
|
78
|
-
frames: typeof PETDEX_ATLAS_CONTRACT.columns;
|
|
79
|
-
}>;
|
|
80
|
-
};
|
|
81
|
-
}
|
|
1
|
+
import { type PetdexForgeRequest, type PetdexForgeOutput, type GeneratePetdexImage, type UploadPetdexReferenceImage, type PetdexProductionOptions } from "@xiaozhiclaw/pet-core";
|
|
2
|
+
export { PETDEX_PRODUCTION_SCHEMA, } from "@xiaozhiclaw/pet-core";
|
|
3
|
+
export type { PetdexForgeRequest, PetdexImageGenerationRequest, PetdexImageGenerationResult, PetdexForgeOutput, PetdexProductionRun, PetdexProductionJob, PetdexProductionReferenceImage, GeneratePetdexImage, UploadPetdexReferenceImage, PetdexProductionOptions, } from "@xiaozhiclaw/pet-core";
|
|
82
4
|
export interface PetdexForgePackageOutput extends PetdexForgeOutput {
|
|
83
5
|
packagePath: string;
|
|
84
6
|
assetDir: string;
|
|
@@ -87,15 +9,6 @@ export interface PetdexForgePackageOutput extends PetdexForgeOutput {
|
|
|
87
9
|
validationPath: string;
|
|
88
10
|
productionRunPath: string;
|
|
89
11
|
}
|
|
90
|
-
export type GeneratePetdexImage = (request: PetdexImageGenerationRequest) => Promise<PetdexImageGenerationResult>;
|
|
91
|
-
export type UploadPetdexReferenceImage = (input: {
|
|
92
|
-
buffer: Buffer;
|
|
93
|
-
mimeType: string;
|
|
94
|
-
filename: string;
|
|
95
|
-
}) => Promise<string>;
|
|
96
|
-
export interface PetdexProductionOptions {
|
|
97
|
-
uploadReferenceImage?: UploadPetdexReferenceImage;
|
|
98
|
-
}
|
|
99
12
|
export declare function forgePetdexAsset(input: PetdexForgeRequest, generateImage: GeneratePetdexImage, options?: PetdexProductionOptions): Promise<PetdexForgeOutput>;
|
|
100
13
|
export declare function forgePetdexAssetPackage(params: {
|
|
101
14
|
input: PetdexForgeRequest;
|
|
@@ -103,8 +16,4 @@ export declare function forgePetdexAssetPackage(params: {
|
|
|
103
16
|
generateImage: GeneratePetdexImage;
|
|
104
17
|
uploadReferenceImage?: UploadPetdexReferenceImage;
|
|
105
18
|
}): Promise<PetdexForgePackageOutput>;
|
|
106
|
-
export declare function buildPetdexAtlasPrompt(description: string, prompt?: string | null, referenceMode?: "identity" | "refine"): string;
|
|
107
|
-
export declare function buildPetdexCharacterPrompt(description: string, prompt?: string | null, referenceMode?: "identity" | "refine"): string;
|
|
108
|
-
export declare function buildPetdexReferencePrompt(description: string, prompt?: string | null, referenceMode?: "identity" | "refine"): string;
|
|
109
|
-
export declare function buildPetdexRowPrompt(animationId: PetdexAnimationId, description: string, prompt?: string | null, referenceMode?: "identity" | "refine"): string;
|
|
110
19
|
export declare function readGeneratedPetdexImage(mediaUrl: string): Promise<Buffer>;
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
export interface PathService {
|
|
2
2
|
getActiveProjectRoot(): string;
|
|
3
3
|
setActiveWorkdir(dir: string): void;
|
|
4
|
+
/**
|
|
5
|
+
* The directory the file/exec tools actually operate in (where relative tool
|
|
6
|
+
* paths resolve and the shell session's cwd lives). This is the value last set
|
|
7
|
+
* via setActiveWorkdir — it is the authoritative "active workdir" used by the
|
|
8
|
+
* permission pipeline to classify cross-workspace operations. It can differ
|
|
9
|
+
* from getActiveProjectRoot() (which feeds memory/sessions/project-agent-dir):
|
|
10
|
+
* getActiveProjectRoot may be a captured snapshot, while this always tracks the
|
|
11
|
+
* live tool workdir. Falls back to getActiveProjectRoot() if never set.
|
|
12
|
+
*/
|
|
13
|
+
getActiveWorkdir(): string;
|
|
4
14
|
resolveProjectDir(projectId?: string): string | undefined;
|
|
5
15
|
resolveActiveOwnerUserId(): string;
|
|
6
16
|
getUserAgentHome(): string;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export type PermissionMode = "default" | "auto" | "full_access";
|
|
2
2
|
export declare const PERMISSION_MODES: readonly PermissionMode[];
|
|
3
3
|
export type PermissionBehavior = "allow" | "ask" | "deny";
|
|
4
|
+
export type PermissionPromptCategory = "cross_workspace" | "high_risk_delete" | "high_risk_egress" | "destructive";
|
|
4
5
|
export type PermissionRiskLevel = "read" | "write" | "system" | "external_egress";
|
|
5
6
|
export interface PermissionRuleEntry {
|
|
6
7
|
pattern: string;
|
|
8
|
+
pathPrefix?: string;
|
|
7
9
|
behavior: PermissionBehavior;
|
|
8
10
|
reason?: string;
|
|
9
11
|
source?: string;
|
|
@@ -45,6 +47,12 @@ export interface PermissionAskResult {
|
|
|
45
47
|
message: string;
|
|
46
48
|
toolName: string;
|
|
47
49
|
input?: Record<string, unknown>;
|
|
50
|
+
category?: PermissionPromptCategory;
|
|
51
|
+
semanticCheck?: "delete" | "egress";
|
|
52
|
+
rememberScope?: {
|
|
53
|
+
kind: "directory";
|
|
54
|
+
path: string;
|
|
55
|
+
};
|
|
48
56
|
decisionReason?: PermissionDecisionReason;
|
|
49
57
|
}
|
|
50
58
|
export interface PermissionDenyResult {
|
|
@@ -58,7 +66,6 @@ export interface PermissionConfig {
|
|
|
58
66
|
}
|
|
59
67
|
export interface PermissionEngineConfig extends PermissionConfig {
|
|
60
68
|
rules: PermissionRuleEntry[];
|
|
61
|
-
defaultBehavior: PermissionBehavior;
|
|
62
69
|
}
|
|
63
70
|
export interface ToolPermissionCheckInput {
|
|
64
71
|
toolName: string;
|
|
@@ -69,6 +76,9 @@ export interface ToolPermissionCheckInput {
|
|
|
69
76
|
isDangerous?: boolean;
|
|
70
77
|
requiresApproval?: boolean;
|
|
71
78
|
parallelSafe?: boolean;
|
|
79
|
+
isDelete?: boolean;
|
|
80
|
+
isEgress?: boolean;
|
|
81
|
+
egressCarriesData?: boolean;
|
|
72
82
|
};
|
|
73
83
|
}
|
|
74
84
|
export interface ApprovalRequest {
|
|
@@ -77,19 +87,26 @@ export interface ApprovalRequest {
|
|
|
77
87
|
toolName: string;
|
|
78
88
|
arguments?: Record<string, unknown>;
|
|
79
89
|
message: string;
|
|
90
|
+
/** Prompt category carried through from the decision pipeline (UI hint). */
|
|
91
|
+
category?: PermissionPromptCategory;
|
|
92
|
+
/** When set, the host may offer a "remember this directory" scope option. */
|
|
93
|
+
rememberScope?: {
|
|
94
|
+
kind: "directory";
|
|
95
|
+
path: string;
|
|
96
|
+
};
|
|
80
97
|
}
|
|
81
98
|
export interface ApprovalResponse {
|
|
82
99
|
approvalId: string;
|
|
83
100
|
decision: "allow" | "deny";
|
|
84
101
|
updatedInput?: Record<string, unknown>;
|
|
102
|
+
/** Approval scope chosen by the user: just this call, or the whole directory. */
|
|
103
|
+
scope?: "once" | "directory";
|
|
85
104
|
}
|
|
86
105
|
export interface PermissionRuleEnginePort {
|
|
87
106
|
getMode(): PermissionMode;
|
|
88
107
|
setMode(mode: PermissionMode): void;
|
|
89
108
|
getRules(): readonly PermissionRuleEntry[];
|
|
90
109
|
replaceRules(rules: PermissionRuleEntry[]): void;
|
|
91
|
-
getDefaultBehavior(): PermissionBehavior;
|
|
92
|
-
setDefaultBehavior(behavior: PermissionBehavior): void;
|
|
93
110
|
}
|
|
94
111
|
export interface PermissionApprovalResolver {
|
|
95
112
|
resolveApproval(response: ApprovalResponse): void;
|
|
@@ -21,6 +21,9 @@ export interface RuntimeToolContract {
|
|
|
21
21
|
isConcurrencySafe?: boolean;
|
|
22
22
|
isReadOnly?: boolean;
|
|
23
23
|
riskLevel?: PermissionRiskLevel;
|
|
24
|
+
isDelete?: boolean;
|
|
25
|
+
isEgress?: boolean;
|
|
26
|
+
egressCarriesData?: boolean;
|
|
24
27
|
isEnabled?: () => boolean;
|
|
25
28
|
shouldDefer?: boolean;
|
|
26
29
|
execute?(toolCallId: string, params: any, signal?: AbortSignal): Promise<{
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PermissionRiskLevel, ToolPermissionCheckInput } from "./permission-contracts.js";
|
|
2
|
+
/**
|
|
3
|
+
* 唯一风险分级核心。优先级:显式 riskLevel > isDangerous("system") > isReadOnly("read") > isEgress("external_egress") > 默认 "write"。
|
|
4
|
+
* isDangerous 优先于 isReadOnly:工具不应同时为二者,冲突时取更危险的分级。
|
|
5
|
+
* 调用点(tools.ts 的 manifest 构建、tool-eligibility 的资格判定)各自在其上叠加专属逻辑(category 推断 / name-pattern 升级)。
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveToolRisk(meta: ToolPermissionCheckInput["meta"]): PermissionRiskLevel;
|
|
@@ -15,5 +15,6 @@ export interface FreshWorkspaceEvidencePolicy {
|
|
|
15
15
|
allowedToolNames: string[];
|
|
16
16
|
}
|
|
17
17
|
export declare function getFreshWorkspaceEvidencePolicy(messages: readonly PromptMessageLike[] | string): FreshWorkspaceEvidencePolicy;
|
|
18
|
+
export declare function isLightweightChatTurn(messages: readonly PromptMessageLike[] | string): boolean;
|
|
18
19
|
export declare function selectFreshWorkspaceEvidenceTools<TTool extends ToolNameLike>(tools: readonly TTool[], policy: FreshWorkspaceEvidencePolicy): TTool[];
|
|
19
20
|
export declare function createFreshWorkspaceEvidenceSection(policy: FreshWorkspaceEvidencePolicy): SystemPromptSection | null;
|
|
@@ -21,4 +21,6 @@ export declare class SessionLocator {
|
|
|
21
21
|
getActiveProjectWorkspaceDir(): string;
|
|
22
22
|
/** Get the active project's ID. */
|
|
23
23
|
getActiveProjectId(): string;
|
|
24
|
+
/** Get the default project's ID for external personal channel sessions. */
|
|
25
|
+
getDefaultProjectId(): string;
|
|
24
26
|
}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* 3. Feed messages as initial context to agent
|
|
17
17
|
*/
|
|
18
18
|
import type { ChatMessage } from "../../protocol/wire/index.js";
|
|
19
|
+
import type { TokenUsage } from "../../agent/types.js";
|
|
19
20
|
import type { SessionUsageSnapshot } from "./session-state.js";
|
|
20
21
|
export interface SessionMetadata {
|
|
21
22
|
sessionId: string;
|
|
@@ -35,6 +36,7 @@ export interface SessionMetadata {
|
|
|
35
36
|
previousSessionId?: string;
|
|
36
37
|
carryoverSummary?: string;
|
|
37
38
|
type?: "personal" | "group";
|
|
39
|
+
ownerPlatform?: string;
|
|
38
40
|
ownerId?: string;
|
|
39
41
|
groupKey?: string;
|
|
40
42
|
groupName?: string;
|
|
@@ -52,7 +54,12 @@ export interface SessionMetadata {
|
|
|
52
54
|
}
|
|
53
55
|
export interface PersistedSession {
|
|
54
56
|
metadata: SessionMetadata;
|
|
55
|
-
messages:
|
|
57
|
+
messages: PersistedChatMessage[];
|
|
58
|
+
}
|
|
59
|
+
export interface PersistedChatMessage extends ChatMessage {
|
|
60
|
+
timestamp?: string;
|
|
61
|
+
turnId?: string;
|
|
62
|
+
usage?: TokenUsage;
|
|
56
63
|
}
|
|
57
64
|
export interface SessionListEntry {
|
|
58
65
|
sessionId: string;
|
|
@@ -84,7 +91,9 @@ export declare function getSessionMetadata(sessionId: string, projectRoot: strin
|
|
|
84
91
|
* Robustness: catches disk-full and I/O errors without crashing the agent.
|
|
85
92
|
* Returns false if the write fails.
|
|
86
93
|
*/
|
|
87
|
-
export declare function appendMessage(sessionId: string, message: ChatMessage, projectRoot: string, turnId?: string
|
|
94
|
+
export declare function appendMessage(sessionId: string, message: ChatMessage, projectRoot: string, turnId?: string, metadata?: {
|
|
95
|
+
usage?: TokenUsage;
|
|
96
|
+
}): Promise<boolean>;
|
|
88
97
|
/**
|
|
89
98
|
* Save session metadata + usage stats atomically (flat structure).
|
|
90
99
|
*/
|
|
@@ -92,6 +101,9 @@ export declare function saveSessionState(sessionId: string, usageSnapshot: Sessi
|
|
|
92
101
|
/**
|
|
93
102
|
* Update specific metadata fields of a session without touching cost data.
|
|
94
103
|
* Used by session CRUD RPC (rename, pin, archive, move-to-project).
|
|
104
|
+
*
|
|
105
|
+
* Concurrency-bounded via withSessionWriteLimit (see above) so a burst of parallel
|
|
106
|
+
* updates cannot exhaust the fs thread pool and wedge the RPC channel.
|
|
95
107
|
*/
|
|
96
108
|
export declare function updateSessionMetadata(sessionId: string, patch: Partial<Record<keyof SessionMetadata, SessionMetadata[keyof SessionMetadata] | null>>, projectRoot: string): Promise<SessionMetadata | null>;
|
|
97
109
|
/**
|
|
@@ -99,7 +111,9 @@ export declare function updateSessionMetadata(sessionId: string, patch: Partial<
|
|
|
99
111
|
*
|
|
100
112
|
* Returns null if the session doesn't exist or is corrupted.
|
|
101
113
|
*/
|
|
102
|
-
export declare function loadSessionForResume(sessionId: string, projectRoot: string
|
|
114
|
+
export declare function loadSessionForResume(sessionId: string, projectRoot: string, options?: {
|
|
115
|
+
includeDisplayMetadata?: boolean;
|
|
116
|
+
}): Promise<PersistedSession | null>;
|
|
103
117
|
/**
|
|
104
118
|
* List available sessions for resume CC ResumeConversation picker.
|
|
105
119
|
* Returns most-recent-first, up to `limit` entries.
|
|
@@ -9,6 +9,8 @@ export type PermissionRole = "interactive" | "coordinator" | "worker";
|
|
|
9
9
|
export interface PermissionCheckerDeps {
|
|
10
10
|
ruleEngine: PermissionRuleEngine;
|
|
11
11
|
hookRegistry: HookRegistry;
|
|
12
|
+
/** Returns the current workspace root for operation classification. */
|
|
13
|
+
getWorkspaceRoot(): string;
|
|
12
14
|
/**
|
|
13
15
|
* Callback to send an approval request to the host (Gateway/Electron).
|
|
14
16
|
* Must return a promise that resolves when the user responds.
|
|
@@ -52,6 +54,7 @@ export interface PermissionCheckerDeps {
|
|
|
52
54
|
export declare class PermissionChecker {
|
|
53
55
|
private readonly ruleEngine;
|
|
54
56
|
private readonly hookRegistry;
|
|
57
|
+
private readonly getWorkspaceRoot;
|
|
55
58
|
private readonly onRequestApproval;
|
|
56
59
|
private readonly onDenied;
|
|
57
60
|
private readonly classifierLLMCall;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ToolPermissionCheckInput } from "../../runtime/ports/permission-contracts.js";
|
|
2
|
+
/**
|
|
3
|
+
* 确定性操作归类。注意两个危险信号是分工的、互不包含:
|
|
4
|
+
* - `isDestructive`:shell 破坏性操作(rm -rf、dd、管道下载执行等)+ 递归删除 → 下游走"无条件保底必弹"。
|
|
5
|
+
* - `isDelete`:任意删除(含 meta 标注的删除工具)→ 下游单独走"该文件是否有用"的语义复核,不并入 isDestructive。
|
|
6
|
+
* 消费方(决策流水线)分别独立检查 isDestructive 与 isDelete。
|
|
7
|
+
*/
|
|
8
|
+
export interface OperationClassification {
|
|
9
|
+
targetPaths: string[];
|
|
10
|
+
inWorkspace: boolean;
|
|
11
|
+
crossWorkspace: boolean;
|
|
12
|
+
isDelete: boolean;
|
|
13
|
+
isRecursiveDelete: boolean;
|
|
14
|
+
isEgress: boolean;
|
|
15
|
+
egressCarriesData: boolean;
|
|
16
|
+
isDestructive: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface ClassifyContext {
|
|
19
|
+
workspaceRoot: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Canonical set of shell-command tool names. This is the single source of truth,
|
|
23
|
+
* imported and used by BOTH `classifyOperation` (below) AND hook-runner's bash
|
|
24
|
+
* pre-filter, so the two stay aligned. Includes the `Bash` case-variant.
|
|
25
|
+
*/
|
|
26
|
+
export declare const SHELL_TOOL_NAMES: Set<string>;
|
|
27
|
+
export declare function isWithinWorkspace(resolved: string, root: string): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* 提取 shell 命令引用的路径(重定向目标 + Unix/Windows/相对路径),解析为绝对路径。
|
|
30
|
+
* 移植自 exec validateCommand;win32 下把 /c/Users → C:\Users;跳过单字母 flag(/c /s …);
|
|
31
|
+
* /dev/null 不计入(由绝对底线另处理)。供 classifyOperation 与 exec validateCommand 共用(单一源)。
|
|
32
|
+
* 扫描层用聚焦 shell tokenizer(替代正则):正确处理带空格的引号路径、管道/&& 后的路径、
|
|
33
|
+
* 以及单/双引号内的字面 `>`(不当作重定向)。push() 的过滤/解析逻辑保持不变。
|
|
34
|
+
*/
|
|
35
|
+
export declare function extractCommandPaths(command: string, root: string): string[];
|
|
36
|
+
export declare function classifyOperation(input: ToolPermissionCheckInput, ctx: ClassifyContext): OperationClassification;
|
|
@@ -1,34 +1,39 @@
|
|
|
1
|
+
import type { OperationClassification } from "./operation-classifier.js";
|
|
1
2
|
import type { PermissionMode, PermissionBehavior, PermissionResult, PermissionRuleEntry, PermissionEngineConfig, ToolPermissionCheckInput } from "./types.js";
|
|
2
3
|
export declare class PermissionRuleEngine {
|
|
3
4
|
private mode;
|
|
4
5
|
private rules;
|
|
5
|
-
private
|
|
6
|
+
private sessionRules;
|
|
6
7
|
private compiledPatterns;
|
|
7
8
|
constructor(config: PermissionEngineConfig);
|
|
8
9
|
getMode(): PermissionMode;
|
|
9
10
|
setMode(mode: PermissionMode): void;
|
|
10
11
|
getRules(): readonly PermissionRuleEntry[];
|
|
11
|
-
|
|
12
|
-
/** Replace all rules at once (for settings hot-reload). */
|
|
12
|
+
/** Replace all persistent rules at once (for settings hot-reload). Session rules are preserved. */
|
|
13
13
|
replaceRules(rules: PermissionRuleEntry[]): void;
|
|
14
|
-
/** Update the default behavior (for settings hot-reload). */
|
|
15
|
-
setDefaultBehavior(behavior: PermissionBehavior): void;
|
|
16
14
|
addRule(rule: PermissionRuleEntry): void;
|
|
15
|
+
/** Add a session-scoped rule (e.g. "remember directory" approvals). */
|
|
16
|
+
addSessionRule(rule: {
|
|
17
|
+
pathPrefix?: string;
|
|
18
|
+
pattern?: string;
|
|
19
|
+
behavior?: PermissionBehavior;
|
|
20
|
+
}): void;
|
|
21
|
+
/** sandbox 可写根:rules + sessionRules 中 allow 且带 pathPrefix 的目录(去重)。 */
|
|
22
|
+
getAllowedWriteDirectories(): string[];
|
|
17
23
|
/**
|
|
18
|
-
*
|
|
24
|
+
* Workspace + danger decision pipeline.
|
|
19
25
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* Layer 2: Unified tool risk metadata
|
|
23
|
-
* Layer 3: Default behavior
|
|
26
|
+
* `op` is optional and defaults to an all-false classification so callers
|
|
27
|
+
* that have not yet been wired to the classifier keep compiling.
|
|
24
28
|
*/
|
|
25
|
-
check(input: ToolPermissionCheckInput): PermissionResult;
|
|
26
|
-
|
|
29
|
+
check(input: ToolPermissionCheckInput, op?: OperationClassification): PermissionResult;
|
|
30
|
+
/** Rebuild compiledPatterns: [persistent-deny] → [session] → [persistent non-deny]. */
|
|
31
|
+
private recompile;
|
|
27
32
|
}
|
|
28
33
|
/**
|
|
29
34
|
* Parse permission config from Gateway-injected or local settings.
|
|
30
35
|
*
|
|
31
|
-
* Accepts
|
|
32
|
-
*
|
|
36
|
+
* Accepts the user-facing permission mode plus the persistent `rules` channel.
|
|
37
|
+
* Legacy top-level alias keys (allow/deny/ask arrays, default) are still rejected.
|
|
33
38
|
*/
|
|
34
39
|
export declare function parsePermissionConfig(raw: unknown): PermissionEngineConfig;
|
|
@@ -104,6 +104,24 @@ export interface PortableTool<TParams = Record<string, unknown>> {
|
|
|
104
104
|
* Used by permission system to require confirmation.
|
|
105
105
|
*/
|
|
106
106
|
isDestructive?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Whether this tool deletes data (files, records, resources).
|
|
109
|
+
* Distinct from isDestructive (shell-level) — this is a semantic annotation
|
|
110
|
+
* on tools that explicitly delete. Downstream uses separate delete-specific
|
|
111
|
+
* confirmation logic from the general destructive-shell path.
|
|
112
|
+
*/
|
|
113
|
+
isDelete?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Whether this tool sends data to an external service (egress).
|
|
116
|
+
* When true, the tool is classified as external_egress risk.
|
|
117
|
+
*/
|
|
118
|
+
isEgress?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Whether egress carries user data (as opposed to read-only queries).
|
|
121
|
+
* Only meaningful when isEgress is true.
|
|
122
|
+
* Examples: send_message (true), web_search (false).
|
|
123
|
+
*/
|
|
124
|
+
egressCarriesData?: boolean;
|
|
107
125
|
/**
|
|
108
126
|
* Tool-specific permission check before execution.
|
|
109
127
|
* CC parity: Tool.checkPermissions — returns allow/deny with reason.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PortableTool } from "../portable-tool.js";
|
|
2
2
|
import type { CommandClassification } from "./shell/command-classification.js";
|
|
3
|
+
import type { SandboxConfig } from "./shell/sandbox/sandbox-types.js";
|
|
3
4
|
export declare const EXEC_TOOL_NAME: "exec";
|
|
4
5
|
export interface ExecToolParams {
|
|
5
6
|
command: string;
|
|
@@ -72,6 +73,12 @@ export interface ExecToolHost {
|
|
|
72
73
|
* Returns null/undefined if allowed, or an error message if blocked.
|
|
73
74
|
*/
|
|
74
75
|
validateCommand?(command: string): Promise<string | null | undefined>;
|
|
76
|
+
/**
|
|
77
|
+
* Resolve the OS-sandbox context for this exec (snapshot of the permission
|
|
78
|
+
* single-source: mode + active workdir + approved dirs + helper availability).
|
|
79
|
+
* Returns undefined to disable the OS sandbox (degrade to prompt-only).
|
|
80
|
+
*/
|
|
81
|
+
resolveSandbox?(): SandboxConfig | undefined;
|
|
75
82
|
/**
|
|
76
83
|
* Interpret a non-zero exit code.
|
|
77
84
|
* E.g. 127 → "command not found", 137 → "killed by SIGKILL".
|
|
@@ -41,5 +41,12 @@ interface MatchResult {
|
|
|
41
41
|
strategy: MatchStrategy;
|
|
42
42
|
}
|
|
43
43
|
declare function fuzzyFind(content: string, search: string, replaceAll: boolean): MatchResult[];
|
|
44
|
+
export interface PatchTargets {
|
|
45
|
+
/** Every file path the patch adds, updates, deletes, or moves (source + destination). */
|
|
46
|
+
paths: string[];
|
|
47
|
+
/** Paths removed via a *** Delete File: directive. */
|
|
48
|
+
deletes: string[];
|
|
49
|
+
}
|
|
50
|
+
export declare function extractPatchTargets(input: string): PatchTargets;
|
|
44
51
|
export declare function createPatchTool(deps: PatchToolDeps): PortableTool<PatchToolParams>;
|
|
45
52
|
export { fuzzyFind, type MatchResult };
|