@ricsam/r5d-worker 0.0.45 → 0.0.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env bun
2
+ import { type WorkspaceProjectManifestEntry } from "./workspace-sync";
2
3
  type WorkerReadFileResult = {
3
4
  type: "read";
4
5
  kind: "text";
@@ -11,6 +12,7 @@ type WorkerReadFileResult = {
11
12
  truncated: boolean;
12
13
  continuation?: string;
13
14
  };
15
+ type WorkerProjectManifestEntry = WorkspaceProjectManifestEntry;
14
16
  type WorkerWriteFileResult = {
15
17
  type: "write";
16
18
  file: string;
@@ -49,6 +51,11 @@ type WorkerViewFileBytesResult = {
49
51
  width: number;
50
52
  height: number;
51
53
  };
54
+ export type WorkerBuiltInToolPaths = {
55
+ artifactsDir?: string;
56
+ plansDir?: string;
57
+ activePlanFile?: string;
58
+ };
52
59
  export declare function isArtifactEnvPath(filePath: string): boolean;
53
60
  export declare function syncSessionArtifacts(input: {
54
61
  baseUrl: string;
@@ -76,6 +83,13 @@ type GitAuth = {
76
83
  extraHeaderUrl: string;
77
84
  header: string;
78
85
  };
86
+ declare function gitAuthArgs(auth?: GitAuth): string[];
87
+ export declare const visibleCheckoutGitTestHarness: {
88
+ gitAuthArgs: typeof gitAuthArgs;
89
+ commandArgs: (args: string[], auth?: GitAuth) => string[];
90
+ cloneArgs: (remoteUrl: string, branchPath: string) => string[];
91
+ fetchArgs: (...args: string[]) => string[];
92
+ };
79
93
  type ResolvedWorkerFilePath = {
80
94
  absolutePath: string;
81
95
  displayPath: string;
@@ -86,39 +100,73 @@ type ResolvedWorkerFilePath = {
86
100
  displayPath: string;
87
101
  repoRelativePath: null;
88
102
  scope: "host";
103
+ } | {
104
+ absolutePath: string;
105
+ displayPath: string;
106
+ repoRelativePath: null;
107
+ scope: "virtual";
108
+ virtualRootPath: string;
109
+ };
110
+ export declare function resolveWorkerFilePath(branchPath: string, inputPath: string, builtInPaths?: WorkerBuiltInToolPaths): ResolvedWorkerFilePath;
111
+ export declare function visibleCheckoutRemoteFor(input: {
112
+ baseUrl: string;
113
+ token: string;
114
+ projectId: string;
115
+ branchName: string;
116
+ manifest?: WorkerProjectManifestEntry;
117
+ }): {
118
+ remoteUrl: string;
119
+ authHeader: string | null;
120
+ persistAuth: boolean;
121
+ reconcileExistingOrigin: boolean;
122
+ requireRemoteBranch: boolean;
123
+ requiredBaseCommit: string | null;
89
124
  };
90
- export declare function resolveWorkerFilePath(branchPath: string, inputPath: string): ResolvedWorkerFilePath;
91
125
  export declare function githubCliEnv(token: string | null | undefined): Record<string, string>;
92
126
  export declare function ensureVisibleGitCheckout(input: {
93
127
  projectRoot: string;
94
128
  branchName: string;
95
- githubRemoteUrl: string;
96
- githubAuth?: GitAuth;
97
- githubAuthHeader?: string | null;
129
+ remoteUrl: string;
130
+ remoteAuth?: GitAuth;
131
+ persistentAuthHeader?: string | null;
98
132
  defaultBranch: string;
99
133
  reconcileExistingOrigin?: boolean;
134
+ requireRemoteBranch?: boolean;
135
+ requiredBaseCommit?: string | null;
136
+ allowRequiredRemoteMigration?: boolean;
137
+ clearPersistentAuth?: boolean;
100
138
  }): string;
101
- export declare function readWorkerTextFile(branchPath: string, filePath: string, offset?: number, limit?: number): WorkerReadFileResult;
102
- export declare function writeWorkerTextFile(branchPath: string, filePath: string, content: string): WorkerWriteFileResult;
139
+ type VisibleCheckoutTarget = {
140
+ projectId: string;
141
+ branchName: string;
142
+ };
143
+ export declare function workspaceSyncCheckoutTargets(input: {
144
+ projects: readonly WorkspaceProjectManifestEntry[];
145
+ pendingTargets: readonly VisibleCheckoutTarget[];
146
+ includeAllManifestCheckouts: boolean;
147
+ canonicalCheckoutOnly?: VisibleCheckoutTarget;
148
+ }): VisibleCheckoutTarget[];
149
+ export declare function readWorkerTextFile(branchPath: string, filePath: string, offset?: number, limit?: number, builtInPaths?: WorkerBuiltInToolPaths): WorkerReadFileResult;
150
+ export declare function writeWorkerTextFile(branchPath: string, filePath: string, content: string, builtInPaths?: WorkerBuiltInToolPaths): WorkerWriteFileResult;
103
151
  export declare function editWorkerTextFile(branchPath: string, filePath: string, edits: Array<{
104
152
  oldText: string;
105
153
  newText: string;
106
- }>): WorkerEditFileResult;
154
+ }>, builtInPaths?: WorkerBuiltInToolPaths): WorkerEditFileResult;
107
155
  export declare function grepWorkerFiles(branchPath: string, input: {
108
156
  pattern: string;
109
157
  path?: string;
110
158
  glob?: string;
111
159
  caseSensitive?: boolean;
112
160
  limit?: number;
113
- }): WorkerGrepResult;
161
+ }, builtInPaths?: WorkerBuiltInToolPaths): WorkerGrepResult;
114
162
  export declare function findWorkerFiles(branchPath: string, input: {
115
163
  pattern?: string;
116
164
  path?: string;
117
165
  entryType?: string;
118
166
  limit?: number;
119
- }): WorkerFindResult;
120
- export declare function listWorkerDirectory(branchPath: string, inputPath?: string, inputLimit?: number): WorkerLsResult;
121
- export declare function readWorkerImageFile(branchPath: string, filePath: string): WorkerViewFileBytesResult;
167
+ }, builtInPaths?: WorkerBuiltInToolPaths): WorkerFindResult;
168
+ export declare function listWorkerDirectory(branchPath: string, inputPath?: string, inputLimit?: number, builtInPaths?: WorkerBuiltInToolPaths): WorkerLsResult;
169
+ export declare function readWorkerImageFile(branchPath: string, filePath: string, builtInPaths?: WorkerBuiltInToolPaths): WorkerViewFileBytesResult;
122
170
  export declare function resolveHostShell(command?: string, platform?: NodeJS.Platform): {
123
171
  file: string;
124
172
  args: string[];
@@ -10,6 +10,10 @@ export type WorkspaceProjectManifestEntry = {
10
10
  repoAuthHeader: string | null;
11
11
  defaultBranch: string;
12
12
  branches: string[];
13
+ canonicalCheckouts: Array<{
14
+ branchName: string;
15
+ scaffoldCommitHash: string;
16
+ }>;
13
17
  };
14
18
  export type WorkspaceSyncTrigger = {
15
19
  type: "connect" | "inbound_head" | "write" | "edit" | "shell_inline" | "process_terminal" | "process_cancel" | "periodic" | "manual" | "remediation" | "remediation_confirm" | "remediation_reset";
@@ -18,6 +22,12 @@ export type WorkspaceSyncTrigger = {
18
22
  toolCallId?: string;
19
23
  projectId?: string;
20
24
  branchName?: string;
25
+ /**
26
+ * Restricts this synchronization to the exact canonical resolver checkout
27
+ * identified by projectId/branchName. Ordinary synchronization never reads
28
+ * or writes canonical resolver checkout subtrees.
29
+ */
30
+ canonicalCheckoutOnly?: boolean;
21
31
  detail?: string;
22
32
  };
23
33
  export type WorkspaceSyncOutcome = "no_change" | "published" | "updated" | "conflict_reset" | "large_diff_blocked" | "reset" | "failed";
@@ -37,6 +47,7 @@ export type WorkspaceSyncResult = {
37
47
  affectedPaths: string[];
38
48
  discardedPaths: string[];
39
49
  localChangesDiscarded: boolean;
50
+ sampledCanonicalCheckoutTreeHash?: string;
40
51
  error?: string;
41
52
  };
42
53
  export type WorkspaceSyncInput = {
@@ -59,16 +70,35 @@ export type WorkspaceSyncInput = {
59
70
  }>;
60
71
  };
61
72
  export declare function encodeWorkspaceBranch(branchName: string): string;
73
+ /**
74
+ * Treat canonical resolver checkouts as a separate synchronization authority.
75
+ * Generic workspace scans omit them; an explicitly scoped request contains
76
+ * exactly one resolver checkout and no sibling branches.
77
+ */
78
+ export declare function workspaceProjectsForSync(projects: readonly WorkspaceProjectManifestEntry[], trigger: WorkspaceSyncTrigger): WorkspaceProjectManifestEntry[];
62
79
  export declare function workspaceProjectBranchRelativePath(projectId: string, branchName: string): string;
63
80
  export declare function workspacePlansRelativePath(projectId: string, branchName: string): string;
64
81
  export declare function visibleProjectBranchPath(projectsRoot: string, manifest: WorkspaceProjectManifestEntry, branchName: string): string;
65
- export declare function mirrorVisibleWorkspaceToShadow(input: WorkspaceSyncInput, excludedCheckouts?: ReadonlySet<string>): void;
66
- export declare function mirrorShadowWorkspaceToVisible(input: WorkspaceSyncInput): void;
82
+ type GitlinkEntry = {
83
+ filePath: string;
84
+ objectId: string;
85
+ };
86
+ type GitlinkProjection = {
87
+ entries: GitlinkEntry[];
88
+ opaqueRoots: string[];
89
+ };
90
+ export declare function assertCanonicalCheckoutIndexMatchesWorktree(checkoutPath: string): void;
91
+ export declare function mirrorVisibleWorkspaceToShadow(input: WorkspaceSyncInput, excludedCheckouts?: ReadonlySet<string>): GitlinkProjection;
92
+ export declare function mirrorShadowWorkspaceToVisible(input: WorkspaceSyncInput, opaqueWorkspaceRoots?: readonly string[]): void;
67
93
  export declare function synchronizeWorkspace(rawInput: WorkspaceSyncInput): Promise<WorkspaceSyncResult>;
68
- export declare function calculateWorkspaceDiffFingerprint(input: WorkspaceSyncInput): string;
94
+ export declare function calculateWorkspaceDiffFingerprint(rawInput: WorkspaceSyncInput): string;
69
95
  export declare class WorkspaceSyncSingleFlight {
70
96
  private queue;
97
+ private enqueue;
71
98
  run(input: WorkspaceSyncInput): Promise<WorkspaceSyncResult>;
99
+ runPrepared(prepare: () => WorkspaceSyncInput): Promise<WorkspaceSyncResult>;
72
100
  fingerprint(input: WorkspaceSyncInput): Promise<string>;
101
+ fingerprintPrepared(prepare: () => WorkspaceSyncInput): Promise<string>;
73
102
  afterCurrent(): Promise<void>;
74
103
  }
104
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ricsam/r5d-worker",
3
- "version": "0.0.45",
3
+ "version": "0.0.47",
4
4
  "type": "module",
5
5
  "main": "./dist/cjs/main.cjs",
6
6
  "module": "./dist/mjs/main.mjs",