@bf-meishijian/aip 0.0.62 → 0.0.64
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/coding-run-error.d.ts +1 -1
- package/dist/coding-run-error.d.ts.map +1 -1
- package/dist/coding-run-error.js +14 -1
- package/dist/coding-run-error.js.map +1 -1
- package/dist/coding-run-manager.d.ts +31 -2
- package/dist/coding-run-manager.d.ts.map +1 -1
- package/dist/coding-run-manager.js +91 -25
- package/dist/coding-run-manager.js.map +1 -1
- package/dist/command-executor.d.ts.map +1 -1
- package/dist/command-executor.js +6 -1
- package/dist/command-executor.js.map +1 -1
- package/dist/compaction-manager.d.ts.map +1 -1
- package/dist/compaction-manager.js +12 -18
- package/dist/compaction-manager.js.map +1 -1
- package/dist/delivery-files.d.ts +5 -0
- package/dist/delivery-files.d.ts.map +1 -1
- package/dist/delivery-files.js +15 -2
- package/dist/delivery-files.js.map +1 -1
- package/dist/diagnostics.d.ts.map +1 -1
- package/dist/general-run-client.d.ts.map +1 -1
- package/dist/general-run-manager.d.ts.map +1 -1
- package/dist/general-run-manager.js +43 -12
- package/dist/general-run-manager.js.map +1 -1
- package/dist/generated/local-native-tools.js +80 -0
- package/dist/host-file-boundary.d.ts +16 -0
- package/dist/host-file-boundary.d.ts.map +1 -0
- package/dist/host-file-boundary.js +128 -0
- package/dist/host-file-boundary.js.map +1 -0
- package/dist/host-status.d.ts.map +1 -1
- package/dist/live-employee.d.ts +2 -0
- package/dist/live-employee.d.ts.map +1 -1
- package/dist/live-employee.js +8 -1
- package/dist/live-employee.js.map +1 -1
- package/dist/local-employee-runtime.d.ts +2 -0
- package/dist/local-employee-runtime.d.ts.map +1 -1
- package/dist/local-employee-runtime.js +130 -27
- package/dist/local-employee-runtime.js.map +1 -1
- package/dist/pi-model-retry.d.ts +16 -0
- package/dist/pi-model-retry.d.ts.map +1 -0
- package/dist/pi-model-retry.js +79 -0
- package/dist/pi-model-retry.js.map +1 -0
- package/dist/pi-model-service.d.ts.map +1 -1
- package/dist/pi-path-utils.js +141 -0
- package/dist/platform-client.d.ts.map +1 -1
- package/dist/provider-error.js +147 -0
- package/dist/qa-session-manager.d.ts.map +1 -1
- package/dist/qa-session-manager.js +47 -39
- package/dist/qa-session-manager.js.map +1 -1
- package/dist/secure-json.d.ts +1 -0
- package/dist/secure-json.d.ts.map +1 -1
- package/dist/secure-json.js +4 -1
- package/dist/secure-json.js.map +1 -1
- package/dist/session-history-view.d.ts +22 -0
- package/dist/session-history-view.d.ts.map +1 -0
- package/dist/session-history-view.js +103 -0
- package/dist/session-history-view.js.map +1 -0
- package/dist/skill-bundle-cache.js +1 -1
- package/dist/skill-bundle.js +9 -0
- package/dist/skill-directory-names.js +58 -2
- package/dist/skill-storage.js +1 -1
- package/dist/tool-dispatch.d.ts +2 -1
- package/dist/tool-dispatch.d.ts.map +1 -1
- package/dist/tool-dispatch.js +11 -0
- package/dist/tool-dispatch.js.map +1 -1
- package/dist/workflow-guidance.js +2 -7
- package/dist/worktree-state.d.ts +2 -2
- package/dist/worktree-state.d.ts.map +1 -1
- package/dist/worktree-state.js +6 -3
- package/dist/worktree-state.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Pi 将 HTTP 错误放进 errorMessage;在上报边界恢复平台的结构化错误事实。 */
|
|
2
|
-
export declare function codingRunError(error: unknown, fallbackCode: string): {
|
|
2
|
+
export declare function codingRunError(error: unknown, fallbackCode: string, partialOutputMarkdown?: string, retryExhausted?: boolean): {
|
|
3
3
|
traceId?: string;
|
|
4
4
|
nextAction?: string;
|
|
5
5
|
code: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coding-run-error.d.ts","sourceRoot":"","sources":["../src/coding-run-error.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"coding-run-error.d.ts","sourceRoot":"","sources":["../src/coding-run-error.ts"],"names":[],"mappings":"AAIA,qDAAqD;AACrD,wBAAgB,cAAc,CAC5B,KAAK,EAAE,OAAO,EACd,YAAY,EAAE,MAAM,EACpB,qBAAqB,CAAC,EAAE,MAAM,EAC9B,cAAc,UAAQ;;;;;EA2DvB"}
|
package/dist/coding-run-error.js
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
|
+
import { classifyProviderError } from "./provider-error.js";
|
|
1
2
|
import { PlatformClientError } from "./platform-client.js";
|
|
2
3
|
import { isProviderLoginRequired } from "./provider-auth-error.js";
|
|
3
4
|
/** Pi 将 HTTP 错误放进 errorMessage;在上报边界恢复平台的结构化错误事实。 */
|
|
4
|
-
export function codingRunError(error, fallbackCode) {
|
|
5
|
+
export function codingRunError(error, fallbackCode, partialOutputMarkdown, retryExhausted = false) {
|
|
5
6
|
const message = error instanceof Error ? error.message : String(error ?? fallbackCode);
|
|
7
|
+
const providerCode = message.match(/\b(?:PROVIDER_(?:QUOTA_EXHAUSTED|AUTHENTICATION_FAILED|REQUEST_REJECTED|RATE_LIMITED|UNAVAILABLE|STREAM_ERROR|STREAM_INTERRUPTED_AFTER_OUTPUT)|MODEL_(?:CONTEXT_WINDOW_EXCEEDED|OUTPUT_TRUNCATED))\b/u)?.[0];
|
|
8
|
+
if (providerCode || partialOutputMarkdown?.trim()) {
|
|
9
|
+
const failure = classifyProviderError({ code: providerCode }, undefined, {
|
|
10
|
+
visibleTextProduced: Boolean(partialOutputMarkdown?.trim()) && providerCode !== "MODEL_OUTPUT_TRUNCATED",
|
|
11
|
+
});
|
|
12
|
+
if (retryExhausted && failure.retryable)
|
|
13
|
+
return {
|
|
14
|
+
code: "PROVIDER_RETRY_EXHAUSTED",
|
|
15
|
+
message: "模型服务当前仍繁忙,已重试 3 次仍未恢复",
|
|
16
|
+
};
|
|
17
|
+
return { code: failure.code, message: failure.safeMessage };
|
|
18
|
+
}
|
|
6
19
|
if (isProviderLoginRequired(error))
|
|
7
20
|
return {
|
|
8
21
|
code: "PROVIDER_LOGIN_REQUIRED",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coding-run-error.js","sourceRoot":"","sources":["../src/coding-run-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,qDAAqD;AACrD,MAAM,UAAU,cAAc,
|
|
1
|
+
{"version":3,"file":"coding-run-error.js","sourceRoot":"","sources":["../src/coding-run-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,qDAAqD;AACrD,MAAM,UAAU,cAAc,CAC5B,KAAc,EACd,YAAoB,EACpB,qBAA8B,EAC9B,cAAc,GAAG,KAAK;IAEtB,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,IAAI,YAAY,CAAC,CAAC;IACvF,MAAM,YAAY,GAAG,OAAO,CAAC,KAAK,CAChC,uMAAuM,CACxM,EAAE,CAAC,CAAC,CAAC,CAAC;IACP,IAAI,YAAY,IAAI,qBAAqB,EAAE,IAAI,EAAE,EAAE,CAAC;QAClD,MAAM,OAAO,GAAG,qBAAqB,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,SAAS,EAAE;YACvE,mBAAmB,EACjB,OAAO,CAAC,qBAAqB,EAAE,IAAI,EAAE,CAAC,IAAI,YAAY,KAAK,wBAAwB;SACtF,CAAC,CAAC;QACH,IAAI,cAAc,IAAI,OAAO,CAAC,SAAS;YACrC,OAAO;gBACL,IAAI,EAAE,0BAA0B;gBAChC,OAAO,EAAE,uBAAuB;aACjC,CAAC;QACJ,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,IAA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C,KAAK,CAAC,IAAI;YACZ,CAAC,CAAC,0BAA0B,CAAC,IAAI,CAAC,OAAO,CAAC;gBACxC,CAAC,CAAC,OAAO;gBACT,CAAC,CAAC,YAAY;QACpB,OAAO;KACR,CAAC;AACJ,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { DeploymentConfigurationSnapshot, LocalCodingHostClaimedCommand } from "@ai-platform/api-contracts";
|
|
2
2
|
import type { Model } from "@earendil-works/pi-ai";
|
|
3
|
-
import { type AgentSession, type ExtensionFactory, type ModelRuntime } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
import { type AgentSession, type ExtensionFactory, type ModelRuntime, type RetrySettings } from "@earendil-works/pi-coding-agent";
|
|
4
4
|
export { redactHostText } from "./host-log.js";
|
|
5
5
|
export { worktreeTreeHash } from "./project-facts.js";
|
|
6
6
|
import { type MaterialSource } from "./delivery-files.js";
|
|
7
|
+
import { PiMessageQueue } from "./pi-message-queue.js";
|
|
7
8
|
import type { PiModelService } from "./pi-model-service.js";
|
|
8
9
|
import { type PlatformClient } from "./platform-client.js";
|
|
9
10
|
interface HostIdentity {
|
|
@@ -115,6 +116,25 @@ interface RunInput {
|
|
|
115
116
|
modelId: string;
|
|
116
117
|
thinkingLevel: "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
117
118
|
}
|
|
119
|
+
interface ObservedRun {
|
|
120
|
+
userIntervened: boolean;
|
|
121
|
+
awaitingDecision?: boolean;
|
|
122
|
+
executionRevision?: number;
|
|
123
|
+
obsoleteContinuationAudits?: Set<string>;
|
|
124
|
+
handingOffInput?: boolean;
|
|
125
|
+
activeTasks: Map<string, string>;
|
|
126
|
+
stopping: boolean;
|
|
127
|
+
terminalReached: boolean;
|
|
128
|
+
deploymentCheckPaused?: boolean;
|
|
129
|
+
terminalClosed?: boolean;
|
|
130
|
+
lastDeliveryError?: string;
|
|
131
|
+
lastModelStopReason?: string;
|
|
132
|
+
lastModelError?: string;
|
|
133
|
+
partialOutputMarkdown?: string;
|
|
134
|
+
modelRetryExhausted?: boolean;
|
|
135
|
+
nativeWillRetry?: boolean;
|
|
136
|
+
messageQueue?: PiMessageQueue;
|
|
137
|
+
}
|
|
118
138
|
export declare class CodingRunManager {
|
|
119
139
|
private readonly pi;
|
|
120
140
|
private readonly active;
|
|
@@ -141,6 +161,9 @@ export declare class CodingRunManager {
|
|
|
141
161
|
private start;
|
|
142
162
|
private synthetic;
|
|
143
163
|
}
|
|
164
|
+
declare function eventEmitter(client: PlatformClient, host: HostIdentity, runId: string, turnId: string, initialSequence?: number, persistSequence?: (sequence: number) => Promise<void>, redact?: (value: string) => string, preservePersist?: boolean): ((kind: Parameters<PlatformClient["appendCodingEvents"]>[1]["events"][number]["kind"], payload: Record<string, unknown>) => Promise<void>) & {
|
|
165
|
+
flush: () => Promise<void>;
|
|
166
|
+
};
|
|
144
167
|
export declare function openPiSession(options: {
|
|
145
168
|
cwd: string;
|
|
146
169
|
sessionDir: string;
|
|
@@ -150,14 +173,20 @@ export declare function openPiSession(options: {
|
|
|
150
173
|
model: Model<any>;
|
|
151
174
|
thinkingLevel: RunInput["thinkingLevel"];
|
|
152
175
|
extensions: ExtensionFactory[];
|
|
176
|
+
retryPolicy?: RetrySettings | "inherit";
|
|
153
177
|
systemPrompt: string;
|
|
154
178
|
runId: string;
|
|
155
179
|
}): Promise<{
|
|
156
180
|
session: AgentSession;
|
|
157
181
|
sessionId: string;
|
|
158
182
|
}>;
|
|
183
|
+
export declare function subscribeSession(session: AgentSession, emit: (kind: Parameters<ReturnType<typeof eventEmitter>>[0], payload: Record<string, unknown>) => Promise<void>, observed: ObservedRun, redact: (value: string) => string): void;
|
|
184
|
+
export declare function publishRepositoryClone(target: string, clone: (directory: string) => Promise<void>): Promise<void>;
|
|
159
185
|
export declare function prepareDeploymentProjects(runRoot: string, projects: Array<Pick<RunInput["projects"][number], "id" | "name" | "repositoryUrl" | "testBranch">>, configuration?: DeploymentConfigurationSnapshot): Promise<string>;
|
|
160
|
-
export declare function prepareProjects(cacheRoot: string, runRoot: string, workItemKey: string, projects: RunInput["projects"], resume: boolean, verifyRemote?: boolean, uninitializedProjectIds?: string[],
|
|
186
|
+
export declare function prepareProjects(cacheRoot: string, runRoot: string, workItemKey: string, projects: RunInput["projects"], resume: boolean, verifyRemote?: boolean, uninitializedProjectIds?: string[], options?: {
|
|
187
|
+
preserveExisting?: boolean;
|
|
188
|
+
unpublishedMaterialProjectIds?: string[];
|
|
189
|
+
}): Promise<string>;
|
|
161
190
|
export declare function initialPrompt(input: RunInput, materialRoot: string): string;
|
|
162
191
|
/** 检查失败命令自己的已知工作区,不从空准备结果推测初始化状态。 */
|
|
163
192
|
export declare function inspectWorkspaceInitialization(runId: string, input: RunInput): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coding-run-manager.d.ts","sourceRoot":"","sources":["../src/coding-run-manager.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,+BAA+B,EAC/B,6BAA6B,EAC9B,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EACL,KAAK,YAAY,EAGjB,KAAK,gBAAgB,EACrB,KAAK,YAAY,
|
|
1
|
+
{"version":3,"file":"coding-run-manager.d.ts","sourceRoot":"","sources":["../src/coding-run-manager.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,+BAA+B,EAC/B,6BAA6B,EAC9B,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EACL,KAAK,YAAY,EAGjB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,aAAa,EAGnB,MAAM,iCAAiC,CAAC;AAqBzC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD,OAAO,EA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AK,CACb,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,eAAe,GAAG,YAAY,CAAC,CACnF,EACD,aAAa,CAAC,EAAE,+BAA+B,mBAmDhD;AAED,wBAAsB,eAAe,CACnC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,EAC9B,MAAM,EAAE,OAAO,EACf,YAAY,UAAQ,EACpB,uBAAuB,GAAE,MAAM,EAAO,EACtC,OAAO,GAAE;IAAE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAAC,6BAA6B,CAAC,EAAE,MAAM,EAAE,CAAA;CAAO,mBAiLvF;AAqJD,wBAAgB,aAAa,CAAC,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,UAGlE;AAcD,qCAAqC;AACrC,wBAAsB,8BAA8B,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ;;;KAwClF;AAED,wBAAsB,8BAA8B,CAClD,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EAAE,EAChB,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,qBAsD/B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { lstat, mkdir, mkdtemp, open, realpath, rename, rm, stat } from "node:fs/promises";
|
|
3
3
|
import { basename, dirname, join, resolve } from "node:path";
|
|
4
|
-
import { createAgentSession, DefaultResourceLoader, SessionManager, } from "@earendil-works/pi-coding-agent";
|
|
4
|
+
import { createAgentSession, DefaultResourceLoader, SessionManager, SettingsManager, } from "@earendil-works/pi-coding-agent";
|
|
5
5
|
import { codingRunError } from "./coding-run-error.js";
|
|
6
6
|
import { deliveryTools } from "./delivery-tools.js";
|
|
7
7
|
import { execGitFile as execFileAsync, gitFailure, missingGitRef } from "./git-process.js";
|
|
@@ -21,6 +21,7 @@ import { acquireOperationLock, OperationContext, operationCleanupConfirmed, thro
|
|
|
21
21
|
import { paths } from "./paths.js";
|
|
22
22
|
import { piAutoCompaction, piContextUsage } from "./pi-compaction.js";
|
|
23
23
|
import { PiMessageQueue } from "./pi-message-queue.js";
|
|
24
|
+
import { boundedPiRetry, piModelRetryExtension, piModelRetryProgress } from "./pi-model-retry.js";
|
|
24
25
|
import { PlatformClientError } from "./platform-client.js";
|
|
25
26
|
import { inspectRunResources } from "./run-resources.js";
|
|
26
27
|
import { readJson, writeSecureJson } from "./secure-json.js";
|
|
@@ -376,7 +377,12 @@ export class CodingRunManager {
|
|
|
376
377
|
? runRoot
|
|
377
378
|
: deploymentSession
|
|
378
379
|
? await prepareDeploymentProjects(runRoot, input.projects, input.deploymentConfiguration)
|
|
379
|
-
: await prepareProjects(local.repositoryCache, runRoot, input.workItem.key, input.projects, input.sessionRecovery ? recoveryWorkspacePresent : Boolean(storedState?.prepared), input.transferContinuation === true || input.sessionRecovery?.mode === "NEW_SESSION", input.transferWorkspaces?.uninitializedProjectIds,
|
|
380
|
+
: await prepareProjects(local.repositoryCache, runRoot, input.workItem.key, input.projects, input.sessionRecovery ? recoveryWorkspacePresent : Boolean(storedState?.prepared), input.transferContinuation === true || input.sessionRecovery?.mode === "NEW_SESSION", input.transferWorkspaces?.uninitializedProjectIds, {
|
|
381
|
+
preserveExisting: Boolean(input.sessionRecovery) && !newSessionOnDifferentHost,
|
|
382
|
+
unpublishedMaterialProjectIds: input.phase === "PREPARATION" && !storedState?.prepared
|
|
383
|
+
? input.materialPreparation.reviewPublications.map(({ projectId }) => projectId)
|
|
384
|
+
: [],
|
|
385
|
+
});
|
|
380
386
|
const preparationBaselines = storedState?.preparationBaselines ?? {};
|
|
381
387
|
const branchStartCommits = Object.fromEntries(input.projects
|
|
382
388
|
.filter((project) => project.branchStartCommit)
|
|
@@ -534,7 +540,7 @@ export class CodingRunManager {
|
|
|
534
540
|
if (images.length > 0 && !resolved.model.input?.includes("image"))
|
|
535
541
|
throw new Error("MODEL_IMAGES_UNSUPPORTED");
|
|
536
542
|
const availableAgents = stageEmployeeIds(input);
|
|
537
|
-
const live = liveEmployee(client, runId, binding, initialEmployeeConfig, runRoot, Boolean(input.team), input.executionPurpose === "RELEASE", input.phase, () => observed.terminalReached,
|
|
543
|
+
const live = liveEmployee(client, runId, binding, initialEmployeeConfig, runRoot, Boolean(input.team), input.executionPurpose === "RELEASE", input.phase, () => observed.terminalReached, undefined, () => {
|
|
538
544
|
observed.terminalClosed = true;
|
|
539
545
|
}, { workspaceContext });
|
|
540
546
|
const delegation = input.executionPurpose === "RELEASE"
|
|
@@ -580,6 +586,7 @@ export class CodingRunManager {
|
|
|
580
586
|
model: resolved.model,
|
|
581
587
|
thinkingLevel: input.thinkingLevel,
|
|
582
588
|
extensions: [...(delegation ? [delegation.extension] : []), terminal, live.extension],
|
|
589
|
+
retryPolicy: boundedPiRetry,
|
|
583
590
|
systemPrompt: input.team
|
|
584
591
|
? "当前为团队主负责人会话,员工配置由平台下发。"
|
|
585
592
|
: "当前为工单主会话,员工配置由平台下发。",
|
|
@@ -664,11 +671,14 @@ export class CodingRunManager {
|
|
|
664
671
|
throwIfOperationAborted();
|
|
665
672
|
await session.prompt(prompt, images.length ? { images } : undefined);
|
|
666
673
|
await session.waitForIdle();
|
|
667
|
-
if (
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
674
|
+
if (observed.stopping)
|
|
675
|
+
return;
|
|
676
|
+
if (observed.lastModelStopReason === "error" || observed.lastModelStopReason === "aborted")
|
|
677
|
+
throw new Error(observed.lastModelError ?? "MODEL_REQUEST_FAILED");
|
|
678
|
+
await emit("CONVERSATION_COMPLETED", {
|
|
679
|
+
phase: "DEVELOPMENT",
|
|
680
|
+
workspaceChanged: conversationFingerprint !== (await workspaceFingerprint(workspaceContext)),
|
|
681
|
+
});
|
|
672
682
|
};
|
|
673
683
|
if (this.context.signal?.aborted) {
|
|
674
684
|
activeRun.stopping = true;
|
|
@@ -693,11 +703,14 @@ export class CodingRunManager {
|
|
|
693
703
|
reason: "MODEL_ERROR",
|
|
694
704
|
stopReason: "error",
|
|
695
705
|
});
|
|
696
|
-
const failure = codingRunError(error, "PI_RUN_FAILED");
|
|
706
|
+
const failure = codingRunError(error, "PI_RUN_FAILED", observed.partialOutputMarkdown, observed.modelRetryExhausted);
|
|
697
707
|
await emit("RUN_FAILED", {
|
|
698
708
|
phase: input.phase,
|
|
699
709
|
...failure,
|
|
700
710
|
message: redact(failure.message),
|
|
711
|
+
...(observed.partialOutputMarkdown
|
|
712
|
+
? { partialOutputMarkdown: observed.partialOutputMarkdown }
|
|
713
|
+
: {}),
|
|
701
714
|
});
|
|
702
715
|
})
|
|
703
716
|
.finally(async () => {
|
|
@@ -867,10 +880,18 @@ export async function openPiSession(options) {
|
|
|
867
880
|
const sessionFile = sessionManager.getSessionFile();
|
|
868
881
|
if (!sessionFile || !(await exists(sessionFile)))
|
|
869
882
|
throw new Error("PI_SESSION_FILE_NOT_PERSISTED");
|
|
883
|
+
const retryPolicy = options.retryPolicy === "inherit" ? undefined : options.retryPolicy;
|
|
884
|
+
const retryExtension = retryPolicy ? piModelRetryExtension() : undefined;
|
|
885
|
+
const settingsManager = SettingsManager.inMemory(retryPolicy
|
|
886
|
+
? { cacheWarming: "off", retry: retryPolicy }
|
|
887
|
+
: SettingsManager.create(options.cwd, options.agentDir).getSettings());
|
|
870
888
|
const loader = new DefaultResourceLoader({
|
|
871
889
|
cwd: options.cwd,
|
|
872
890
|
agentDir: options.agentDir,
|
|
873
|
-
|
|
891
|
+
settingsManager,
|
|
892
|
+
extensionFactories: retryExtension
|
|
893
|
+
? [...options.extensions, retryExtension]
|
|
894
|
+
: options.extensions,
|
|
874
895
|
noSkills: true,
|
|
875
896
|
noExtensions: true,
|
|
876
897
|
noPromptTemplates: true,
|
|
@@ -887,6 +908,7 @@ export async function openPiSession(options) {
|
|
|
887
908
|
thinkingLevel: options.thinkingLevel,
|
|
888
909
|
resourceLoader: loader,
|
|
889
910
|
sessionManager,
|
|
911
|
+
settingsManager,
|
|
890
912
|
});
|
|
891
913
|
const savedModel = sessionManager.buildSessionContext().model;
|
|
892
914
|
if (options.model &&
|
|
@@ -904,11 +926,12 @@ export async function openPiSession(options) {
|
|
|
904
926
|
if (sessionManager.buildSessionContext().thinkingLevel !== session.thinkingLevel) {
|
|
905
927
|
sessionManager.appendThinkingLevelChange(session.thinkingLevel);
|
|
906
928
|
}
|
|
929
|
+
retryExtension?.attach(session);
|
|
907
930
|
await session.bindExtensions({ mode: "print" });
|
|
908
931
|
session.setAutoCompactionEnabled(true);
|
|
909
932
|
return { session, sessionId };
|
|
910
933
|
}
|
|
911
|
-
function subscribeSession(session, emit, observed, redact) {
|
|
934
|
+
export function subscribeSession(session, emit, observed, redact) {
|
|
912
935
|
const publishContext = (compacting = false, compaction) => {
|
|
913
936
|
const contextUsage = piContextUsage(session, compacting);
|
|
914
937
|
if (contextUsage)
|
|
@@ -916,6 +939,18 @@ function subscribeSession(session, emit, observed, redact) {
|
|
|
916
939
|
};
|
|
917
940
|
publishContext();
|
|
918
941
|
let messageId = crypto.randomUUID();
|
|
942
|
+
let messageStarted = false;
|
|
943
|
+
let producedText = "";
|
|
944
|
+
const startMessage = () => {
|
|
945
|
+
if (messageStarted)
|
|
946
|
+
return;
|
|
947
|
+
messageStarted = true;
|
|
948
|
+
void emit("MESSAGE_STARTED", { messageId });
|
|
949
|
+
};
|
|
950
|
+
const reportRetry = piModelRetryProgress((modelRetry) => {
|
|
951
|
+
observed.modelRetryExhausted = modelRetry.state === "EXHAUSTED" && modelRetry.attempt === 3;
|
|
952
|
+
void emit("MODEL_RETRY", { modelRetry });
|
|
953
|
+
}, () => observed.stopping === true);
|
|
919
954
|
let pendingText = "";
|
|
920
955
|
let textFlushTimer;
|
|
921
956
|
const pendingToolUpdates = new Map();
|
|
@@ -924,7 +959,7 @@ function subscribeSession(session, emit, observed, redact) {
|
|
|
924
959
|
if (textFlushTimer)
|
|
925
960
|
clearTimeout(textFlushTimer);
|
|
926
961
|
textFlushTimer = undefined;
|
|
927
|
-
if (!pendingText)
|
|
962
|
+
if (!pendingText || !messageStarted)
|
|
928
963
|
return;
|
|
929
964
|
const text = pendingText;
|
|
930
965
|
pendingText = "";
|
|
@@ -941,6 +976,7 @@ function subscribeSession(session, emit, observed, redact) {
|
|
|
941
976
|
void emit(update.kind, update.payload);
|
|
942
977
|
};
|
|
943
978
|
session.subscribe((event) => {
|
|
979
|
+
reportRetry(event);
|
|
944
980
|
if (event.type === "agent_start") {
|
|
945
981
|
observed.executionRevision = (observed.executionRevision ?? 0) + 1;
|
|
946
982
|
observed.awaitingDecision = false;
|
|
@@ -955,7 +991,11 @@ function subscribeSession(session, emit, observed, redact) {
|
|
|
955
991
|
}
|
|
956
992
|
else if (event.type === "message_start" && event.message.role === "assistant") {
|
|
957
993
|
messageId = crypto.randomUUID();
|
|
958
|
-
|
|
994
|
+
messageStarted = false;
|
|
995
|
+
producedText = "";
|
|
996
|
+
pendingText = "";
|
|
997
|
+
delete observed.partialOutputMarkdown;
|
|
998
|
+
delete observed.modelRetryExhausted;
|
|
959
999
|
}
|
|
960
1000
|
else if (event.type === "message_start" && event.message.role === "user") {
|
|
961
1001
|
const id = observed.messageQueue?.consumed(event.message);
|
|
@@ -969,11 +1009,17 @@ function subscribeSession(session, emit, observed, redact) {
|
|
|
969
1009
|
observed.nativeWillRetry = false;
|
|
970
1010
|
if (event.success === false && event.finalError)
|
|
971
1011
|
observed.lastModelError = event.finalError;
|
|
1012
|
+
else if (event.success)
|
|
1013
|
+
delete observed.lastModelError;
|
|
972
1014
|
}
|
|
973
1015
|
else if (event.type === "message_update" &&
|
|
974
1016
|
event.assistantMessageEvent.type === "text_delta" &&
|
|
975
1017
|
event.assistantMessageEvent.delta) {
|
|
976
|
-
|
|
1018
|
+
const delta = redact(event.assistantMessageEvent.delta);
|
|
1019
|
+
producedText = (producedText + delta).slice(0, 1_000_000);
|
|
1020
|
+
if (delta.trim())
|
|
1021
|
+
startMessage();
|
|
1022
|
+
pendingText += delta;
|
|
977
1023
|
if (pendingText.length >= 4_000)
|
|
978
1024
|
flushText();
|
|
979
1025
|
else
|
|
@@ -1055,17 +1101,28 @@ function subscribeSession(session, emit, observed, redact) {
|
|
|
1055
1101
|
flushText();
|
|
1056
1102
|
if ("stopReason" in event.message && event.message.stopReason)
|
|
1057
1103
|
observed.lastModelStopReason = String(event.message.stopReason);
|
|
1058
|
-
if ("errorMessage" in event.message && event.message.errorMessage)
|
|
1059
|
-
observed.lastModelError = String(event.message.errorMessage);
|
|
1060
1104
|
const content = textFromMessage(event.message.content);
|
|
1061
|
-
|
|
1105
|
+
if (["error", "aborted", "length"].includes(event.message.stopReason)) {
|
|
1106
|
+
if (event.message.errorMessage)
|
|
1107
|
+
observed.lastModelError = event.message.errorMessage;
|
|
1108
|
+
else
|
|
1109
|
+
delete observed.lastModelError;
|
|
1110
|
+
if (producedText.trim())
|
|
1111
|
+
observed.partialOutputMarkdown = producedText;
|
|
1112
|
+
return;
|
|
1113
|
+
}
|
|
1114
|
+
delete observed.lastModelError;
|
|
1115
|
+
delete observed.partialOutputMarkdown;
|
|
1116
|
+
if (!content.trim() && !event.message.usage)
|
|
1117
|
+
return;
|
|
1118
|
+
if (content.trim())
|
|
1119
|
+
startMessage();
|
|
1062
1120
|
const payload = {
|
|
1063
1121
|
contentMarkdown: redact(content),
|
|
1064
1122
|
messageId,
|
|
1065
1123
|
};
|
|
1066
1124
|
Object.assign(payload, localModelUsage(event.message, session.model));
|
|
1067
|
-
|
|
1068
|
-
void emit("MESSAGE_COMPLETED", payload);
|
|
1125
|
+
void emit("MESSAGE_COMPLETED", payload);
|
|
1069
1126
|
}
|
|
1070
1127
|
});
|
|
1071
1128
|
}
|
|
@@ -1129,7 +1186,7 @@ async function driveToTerminal(session, initial, observed, client, host, runId,
|
|
|
1129
1186
|
}
|
|
1130
1187
|
if (observed.lastModelStopReason === "aborted" ||
|
|
1131
1188
|
(observed.lastModelStopReason === "error" && observed.nativeWillRetry !== true)) {
|
|
1132
|
-
const failure = codingRunError(observed.lastModelError, observed.lastModelStopReason === "aborted" ? "PI_MODEL_ABORTED" : "MODEL_REQUEST_FAILED");
|
|
1189
|
+
const failure = codingRunError(observed.lastModelError, observed.lastModelStopReason === "aborted" ? "PI_MODEL_ABORTED" : "MODEL_REQUEST_FAILED", observed.partialOutputMarkdown, observed.modelRetryExhausted);
|
|
1133
1190
|
await emit("EXECUTION_DECIDED", {
|
|
1134
1191
|
...endFact,
|
|
1135
1192
|
decision: "SKIP",
|
|
@@ -1147,6 +1204,9 @@ async function driveToTerminal(session, initial, observed, client, host, runId,
|
|
|
1147
1204
|
summary: failure.message,
|
|
1148
1205
|
knownIssues: "",
|
|
1149
1206
|
failureCode: failure.code,
|
|
1207
|
+
...(observed.partialOutputMarkdown
|
|
1208
|
+
? { partialOutputMarkdown: observed.partialOutputMarkdown }
|
|
1209
|
+
: {}),
|
|
1150
1210
|
projectFacts: [],
|
|
1151
1211
|
testFacts: [],
|
|
1152
1212
|
});
|
|
@@ -1154,7 +1214,13 @@ async function driveToTerminal(session, initial, observed, client, host, runId,
|
|
|
1154
1214
|
}
|
|
1155
1215
|
finally {
|
|
1156
1216
|
// 终态上报失败也要保留最初的模型错误,随后由外层记录上报错误。
|
|
1157
|
-
await emit("RUN_FAILED", {
|
|
1217
|
+
await emit("RUN_FAILED", {
|
|
1218
|
+
phase,
|
|
1219
|
+
...failure,
|
|
1220
|
+
...(observed.partialOutputMarkdown
|
|
1221
|
+
? { partialOutputMarkdown: observed.partialOutputMarkdown }
|
|
1222
|
+
: {}),
|
|
1223
|
+
});
|
|
1158
1224
|
}
|
|
1159
1225
|
return;
|
|
1160
1226
|
}
|
|
@@ -1226,7 +1292,7 @@ function deploymentTestBranch(project, configuration) {
|
|
|
1226
1292
|
return (configuration?.projects.find((item) => item.projectId === project.id)?.testBranch ??
|
|
1227
1293
|
project.testBranch);
|
|
1228
1294
|
}
|
|
1229
|
-
async function publishRepositoryClone(target, clone) {
|
|
1295
|
+
export async function publishRepositoryClone(target, clone) {
|
|
1230
1296
|
await mkdir(dirname(target), { recursive: true, mode: 0o700 });
|
|
1231
1297
|
const staging = await mkdtemp(`${target}.clone-`);
|
|
1232
1298
|
try {
|
|
@@ -1295,7 +1361,7 @@ export async function prepareDeploymentProjects(runRoot, projects, configuration
|
|
|
1295
1361
|
}
|
|
1296
1362
|
return projects.length === 1 ? join(runRoot, safeName(projects[0].name)) : runRoot;
|
|
1297
1363
|
}
|
|
1298
|
-
export async function prepareProjects(cacheRoot, runRoot, workItemKey, projects, resume, verifyRemote = false, uninitializedProjectIds = [],
|
|
1364
|
+
export async function prepareProjects(cacheRoot, runRoot, workItemKey, projects, resume, verifyRemote = false, uninitializedProjectIds = [], options = {}) {
|
|
1299
1365
|
throwIfOperationAborted();
|
|
1300
1366
|
await mkdir(cacheRoot, { recursive: true, mode: 0o700 });
|
|
1301
1367
|
for (const project of projects) {
|
|
@@ -1310,7 +1376,7 @@ export async function prepareProjects(cacheRoot, runRoot, workItemKey, projects,
|
|
|
1310
1376
|
const expectedBranch = project.devBranch || `aip/${workItemKey}`;
|
|
1311
1377
|
const existingWorktree = await exists(target);
|
|
1312
1378
|
// 会话接续只校验并复用现有现场;远端同步属于交接流程,不应覆盖或阻塞本机成果。
|
|
1313
|
-
if (preserveExisting && existingWorktree) {
|
|
1379
|
+
if (options.preserveExisting && existingWorktree) {
|
|
1314
1380
|
await validateWorktree(mirror, target, expectedBranch, true, project.repositoryUrl);
|
|
1315
1381
|
project.branchStartCommit ??= await readBranchStartCommit(target, expectedBranch, project.baselineBranch);
|
|
1316
1382
|
logHostEvent("repository_preparation_completed", { projectId: project.id, workItemKey });
|
|
@@ -1436,7 +1502,7 @@ export async function prepareProjects(cacheRoot, runRoot, workItemKey, projects,
|
|
|
1436
1502
|
});
|
|
1437
1503
|
await validateWorktree(mirror, target, expectedBranch, resume || existingWorktree, project.repositoryUrl);
|
|
1438
1504
|
if (existingWorktree && verifyRemote)
|
|
1439
|
-
await synchronizeRemoteWorkspace(target, expectedBranch);
|
|
1505
|
+
await synchronizeRemoteWorkspace(target, expectedBranch, options.unpublishedMaterialProjectIds?.includes(project.id));
|
|
1440
1506
|
project.branchStartCommit ??= await readBranchStartCommit(target, expectedBranch, project.baselineBranch);
|
|
1441
1507
|
logHostEvent("repository_preparation_completed", { projectId: project.id, workItemKey });
|
|
1442
1508
|
}
|