@agentclientprotocol/codex-acp 1.2.0 → 1.3.0
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/index.js +243 -80
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -22777,8 +22777,20 @@ function createTerminalOutputMeta(mode, terminalId, data) {
|
|
|
22777
22777
|
}
|
|
22778
22778
|
}
|
|
22779
22779
|
|
|
22780
|
+
// src/ContextCompactionMeta.ts
|
|
22781
|
+
var CONTEXT_COMPACTION_META_KEY = "contextCompaction";
|
|
22782
|
+
var CONTEXT_COMPACTION_META_VERSION = 1;
|
|
22783
|
+
function createContextCompactionMeta(metadata = {}) {
|
|
22784
|
+
return {
|
|
22785
|
+
[CONTEXT_COMPACTION_META_KEY]: {
|
|
22786
|
+
version: CONTEXT_COMPACTION_META_VERSION,
|
|
22787
|
+
...metadata
|
|
22788
|
+
}
|
|
22789
|
+
};
|
|
22790
|
+
}
|
|
22791
|
+
|
|
22780
22792
|
// src/CodexToolCallMapper.ts
|
|
22781
|
-
var CONTEXT_COMPACTION_META =
|
|
22793
|
+
var CONTEXT_COMPACTION_META = createContextCompactionMeta();
|
|
22782
22794
|
function toAcpStatus(status) {
|
|
22783
22795
|
switch (status) {
|
|
22784
22796
|
case "inProgress":
|
|
@@ -22925,8 +22937,8 @@ function createContextCompactionStartUpdate(item) {
|
|
|
22925
22937
|
return {
|
|
22926
22938
|
sessionUpdate: "tool_call",
|
|
22927
22939
|
toolCallId: item.id,
|
|
22928
|
-
kind: "
|
|
22929
|
-
title: "
|
|
22940
|
+
kind: "think",
|
|
22941
|
+
title: "Compact conversation",
|
|
22930
22942
|
status: "in_progress",
|
|
22931
22943
|
_meta: CONTEXT_COMPACTION_META
|
|
22932
22944
|
};
|
|
@@ -22935,7 +22947,7 @@ function createContextCompactionCompleteUpdate(item) {
|
|
|
22935
22947
|
return {
|
|
22936
22948
|
sessionUpdate: "tool_call_update",
|
|
22937
22949
|
toolCallId: item.id,
|
|
22938
|
-
title: "
|
|
22950
|
+
title: "Compact conversation",
|
|
22939
22951
|
status: "completed",
|
|
22940
22952
|
_meta: CONTEXT_COMPACTION_META
|
|
22941
22953
|
};
|
|
@@ -22944,8 +22956,8 @@ function createCompletedContextCompactionUpdate(item) {
|
|
|
22944
22956
|
return {
|
|
22945
22957
|
sessionUpdate: "tool_call",
|
|
22946
22958
|
toolCallId: item.id,
|
|
22947
|
-
kind: "
|
|
22948
|
-
title: "
|
|
22959
|
+
kind: "think",
|
|
22960
|
+
title: "Compact conversation",
|
|
22949
22961
|
status: "completed",
|
|
22950
22962
|
_meta: CONTEXT_COMPACTION_META
|
|
22951
22963
|
};
|
|
@@ -23608,19 +23620,60 @@ var AIR_SESSION_FAILURE_KEY = "sessionFailure";
|
|
|
23608
23620
|
var AIR_EXTENSION_VERSION = 1;
|
|
23609
23621
|
|
|
23610
23622
|
// src/CodexEventHandler.ts
|
|
23611
|
-
var
|
|
23612
|
-
|
|
23613
|
-
|
|
23614
|
-
|
|
23615
|
-
|
|
23616
|
-
|
|
23617
|
-
|
|
23618
|
-
|
|
23619
|
-
|
|
23620
|
-
|
|
23621
|
-
|
|
23622
|
-
|
|
23623
|
+
var MAX_SESSION_FAILURE_TITLE_LENGTH = 240;
|
|
23624
|
+
var SESSION_FAILURE_POLICY = {
|
|
23625
|
+
transport_lost: {
|
|
23626
|
+
category: "connection",
|
|
23627
|
+
actions: ["retry", "new_session"]
|
|
23628
|
+
},
|
|
23629
|
+
auth_required: {
|
|
23630
|
+
category: "access",
|
|
23631
|
+
actions: ["login"]
|
|
23632
|
+
},
|
|
23633
|
+
rate_limited: {
|
|
23634
|
+
category: "limit",
|
|
23635
|
+
actions: ["retry"]
|
|
23636
|
+
},
|
|
23637
|
+
quota_exhausted: {
|
|
23638
|
+
category: "limit",
|
|
23639
|
+
actions: []
|
|
23640
|
+
},
|
|
23641
|
+
overloaded: {
|
|
23642
|
+
category: "service",
|
|
23643
|
+
actions: ["retry"]
|
|
23644
|
+
},
|
|
23645
|
+
context_exhausted: {
|
|
23646
|
+
category: "limit",
|
|
23647
|
+
actions: ["new_session"]
|
|
23648
|
+
},
|
|
23649
|
+
budget_exhausted: {
|
|
23650
|
+
category: "limit",
|
|
23651
|
+
actions: ["new_session"]
|
|
23652
|
+
},
|
|
23653
|
+
policy_denied: {
|
|
23654
|
+
category: "request",
|
|
23655
|
+
actions: []
|
|
23656
|
+
},
|
|
23657
|
+
bad_request: {
|
|
23658
|
+
category: "request",
|
|
23659
|
+
actions: []
|
|
23660
|
+
},
|
|
23661
|
+
provider_error: {
|
|
23662
|
+
category: "service",
|
|
23663
|
+
actions: ["retry"]
|
|
23664
|
+
},
|
|
23665
|
+
internal_error: {
|
|
23666
|
+
category: "service",
|
|
23667
|
+
actions: ["retry", "new_session"]
|
|
23668
|
+
}
|
|
23623
23669
|
};
|
|
23670
|
+
var SYNTHETIC_FAILURE_TITLE = {
|
|
23671
|
+
transport_lost: "Connection to Codex was lost.",
|
|
23672
|
+
internal_error: "Codex encountered an internal error."
|
|
23673
|
+
};
|
|
23674
|
+
function nextSessionFailureRevision(previous, id) {
|
|
23675
|
+
return previous?.id === id ? previous.revision + 1 : 1;
|
|
23676
|
+
}
|
|
23624
23677
|
var STRING_CODEX_ERROR_CATEGORIES = {
|
|
23625
23678
|
contextWindowExceeded: "context_exhausted",
|
|
23626
23679
|
sessionBudgetExceeded: "budget_exhausted",
|
|
@@ -23648,6 +23701,12 @@ var CodexEventHandler = class _CodexEventHandler {
|
|
|
23648
23701
|
supportsTypedSessionFailures;
|
|
23649
23702
|
sessionFailureEpoch;
|
|
23650
23703
|
pendingErrors = [];
|
|
23704
|
+
failuresById = /* @__PURE__ */ new Map();
|
|
23705
|
+
activeFailureIdByScope = /* @__PURE__ */ new Map();
|
|
23706
|
+
failureTurnIdById = /* @__PURE__ */ new Map();
|
|
23707
|
+
allocatedFailureScopes = /* @__PURE__ */ new Set();
|
|
23708
|
+
lastSessionNotice;
|
|
23709
|
+
nextNoticeId = 1;
|
|
23651
23710
|
failure = null;
|
|
23652
23711
|
completedPlan = null;
|
|
23653
23712
|
activeFuzzyFileSearchSessions = /* @__PURE__ */ new Set();
|
|
@@ -23672,19 +23731,22 @@ var CodexEventHandler = class _CodexEventHandler {
|
|
|
23672
23731
|
this.supportsTypedSessionFailures = supportsTypedSessionFailures;
|
|
23673
23732
|
this.sessionFailureEpoch = sessionFailureEpoch;
|
|
23674
23733
|
this.session = new ACPSessionConnection(connection, sessionState.sessionId);
|
|
23734
|
+
if (sessionState.sessionFailure !== void 0) {
|
|
23735
|
+
this.failuresById.set(sessionState.sessionFailure.id, sessionState.sessionFailure);
|
|
23736
|
+
}
|
|
23675
23737
|
}
|
|
23676
23738
|
getFailure() {
|
|
23677
23739
|
return this.failure;
|
|
23678
23740
|
}
|
|
23679
23741
|
getTerminalSessionFailureMeta(turnId, allowUnattributed = false) {
|
|
23680
23742
|
const failure = this.sessionState.sessionFailure;
|
|
23681
|
-
if (!this.supportsTypedSessionFailures || failure
|
|
23743
|
+
if (!this.supportsTypedSessionFailures || failure === void 0 || (this.failureTurnIdById.get(failure.id) === void 0 ? !allowUnattributed : turnId === null || this.failureTurnIdById.get(failure.id) !== turnId)) {
|
|
23682
23744
|
return null;
|
|
23683
23745
|
}
|
|
23684
23746
|
return this.createSessionFailureMeta(failure);
|
|
23685
23747
|
}
|
|
23686
|
-
recordSyntheticTerminalFailure(
|
|
23687
|
-
this.recordSessionFailure(
|
|
23748
|
+
recordSyntheticTerminalFailure(kind, turnId) {
|
|
23749
|
+
this.recordSessionFailure(kind, turnId ?? void 0, "error", SYNTHETIC_FAILURE_TITLE[kind]);
|
|
23688
23750
|
}
|
|
23689
23751
|
/**
|
|
23690
23752
|
* Handles notifications after the prompt-local handler has been disposed. The app-server subscription
|
|
@@ -23701,12 +23763,16 @@ var CodexEventHandler = class _CodexEventHandler {
|
|
|
23701
23763
|
return;
|
|
23702
23764
|
}
|
|
23703
23765
|
if (notification.params.willRetry) {
|
|
23704
|
-
await this.session.update(this.
|
|
23766
|
+
await this.session.update(this.createSessionFailureUpdate(this.recordRetryWarning(notification.params, false)));
|
|
23705
23767
|
return;
|
|
23706
23768
|
}
|
|
23707
23769
|
const failure = this.recordSessionFailure(
|
|
23708
|
-
this.
|
|
23709
|
-
|
|
23770
|
+
this.sessionFailureKind(notification.params.error.codexErrorInfo),
|
|
23771
|
+
notification.params.turnId,
|
|
23772
|
+
"error",
|
|
23773
|
+
notification.params.error.message,
|
|
23774
|
+
void 0,
|
|
23775
|
+
false
|
|
23710
23776
|
);
|
|
23711
23777
|
await this.session.update(this.createSessionFailureUpdate(failure));
|
|
23712
23778
|
}
|
|
@@ -23732,21 +23798,19 @@ var CodexEventHandler = class _CodexEventHandler {
|
|
|
23732
23798
|
}
|
|
23733
23799
|
}
|
|
23734
23800
|
async clearSessionFailure() {
|
|
23801
|
+
delete this.sessionState.sessionFailure;
|
|
23802
|
+
}
|
|
23803
|
+
async completeSuccessfulTurn(turnId) {
|
|
23804
|
+
this.lastSessionNotice = void 0;
|
|
23805
|
+
if (!this.supportsTypedSessionFailures || turnId === null) return;
|
|
23735
23806
|
const active = this.sessionState.sessionFailure;
|
|
23736
|
-
if (
|
|
23737
|
-
|
|
23738
|
-
|
|
23739
|
-
const cleared = {
|
|
23740
|
-
...active,
|
|
23741
|
-
revision: active.revision + 1,
|
|
23742
|
-
phase: "cleared"
|
|
23743
|
-
};
|
|
23744
|
-
await this.session.update(this.createSessionFailureUpdate(cleared));
|
|
23745
|
-
this.sessionState.sessionFailure = cleared;
|
|
23807
|
+
if (active?.id !== this.activeFailureIdByScope.get(turnId) || active?.severity !== "warning") return;
|
|
23808
|
+
this.activeFailureIdByScope.delete(turnId);
|
|
23809
|
+
delete this.sessionState.sessionFailure;
|
|
23746
23810
|
}
|
|
23747
23811
|
async handleFailedTurn(turn) {
|
|
23748
23812
|
const activeFailure = this.sessionState.sessionFailure;
|
|
23749
|
-
if (!this.supportsTypedSessionFailures || turn.status !== "failed" || this.failure !== null || activeFailure?.
|
|
23813
|
+
if (!this.supportsTypedSessionFailures || turn.status !== "failed" || this.failure !== null || this.failureTurnIdById.get(activeFailure?.id ?? "") === turn.id && activeFailure?.severity === "error") {
|
|
23750
23814
|
return;
|
|
23751
23815
|
}
|
|
23752
23816
|
const error51 = turn.error ?? {
|
|
@@ -23805,14 +23869,19 @@ var CodexEventHandler = class _CodexEventHandler {
|
|
|
23805
23869
|
async createUpdateEvent(notification) {
|
|
23806
23870
|
switch (notification.method) {
|
|
23807
23871
|
case "item/agentMessage/delta":
|
|
23872
|
+
this.completeRetryIncidentOnTurnProgress();
|
|
23808
23873
|
return await this.createTextEvent(notification.params);
|
|
23809
23874
|
case "item/plan/delta":
|
|
23875
|
+
this.completeRetryIncidentOnTurnProgress();
|
|
23810
23876
|
return this.createPlanDeltaEvent(notification.params);
|
|
23811
23877
|
case "item/started":
|
|
23878
|
+
this.completeRetryIncidentOnTurnProgress();
|
|
23812
23879
|
return await this.createItemEvent(notification.params);
|
|
23813
23880
|
case "item/completed":
|
|
23881
|
+
this.completeRetryIncidentOnTurnProgress();
|
|
23814
23882
|
return await this.completeItemEvent(notification.params);
|
|
23815
23883
|
case "turn/plan/updated":
|
|
23884
|
+
this.completeRetryIncidentOnTurnProgress();
|
|
23816
23885
|
return await this.updatePlan(notification.params);
|
|
23817
23886
|
case "error":
|
|
23818
23887
|
return await this.createErrorEvent(notification.params);
|
|
@@ -23851,8 +23920,10 @@ var CodexEventHandler = class _CodexEventHandler {
|
|
|
23851
23920
|
closed: true
|
|
23852
23921
|
});
|
|
23853
23922
|
case "item/commandExecution/outputDelta":
|
|
23923
|
+
this.completeRetryIncidentOnTurnProgress();
|
|
23854
23924
|
return this.createCommandOutputDeltaEvent(notification.params);
|
|
23855
23925
|
case "item/mcpToolCall/progress":
|
|
23926
|
+
this.completeRetryIncidentOnTurnProgress();
|
|
23856
23927
|
return this.createMcpToolProgressEvent(notification.params);
|
|
23857
23928
|
case "account/rateLimits/updated":
|
|
23858
23929
|
this.handleRateLimitsUpdated(notification.params);
|
|
@@ -23863,6 +23934,8 @@ var CodexEventHandler = class _CodexEventHandler {
|
|
|
23863
23934
|
return this.createWarningEvent(notification.params);
|
|
23864
23935
|
case "guardianWarning":
|
|
23865
23936
|
return null;
|
|
23937
|
+
case "deprecationNotice":
|
|
23938
|
+
return this.createDeprecationNoticeEvent(notification.params);
|
|
23866
23939
|
case "item/autoApprovalReview/started":
|
|
23867
23940
|
return this.handleGuardianApprovalReviewStarted(notification.params);
|
|
23868
23941
|
case "item/autoApprovalReview/completed":
|
|
@@ -23870,10 +23943,13 @@ var CodexEventHandler = class _CodexEventHandler {
|
|
|
23870
23943
|
case "thread/compacted":
|
|
23871
23944
|
return this.createContextCompactedEvent();
|
|
23872
23945
|
case "item/reasoning/summaryTextDelta":
|
|
23946
|
+
this.completeRetryIncidentOnTurnProgress();
|
|
23873
23947
|
return this.createReasoningDeltaEvent(notification.params);
|
|
23874
23948
|
case "item/reasoning/textDelta":
|
|
23949
|
+
this.completeRetryIncidentOnTurnProgress();
|
|
23875
23950
|
return this.createReasoningDeltaEvent(notification.params);
|
|
23876
23951
|
case "item/reasoning/summaryPartAdded":
|
|
23952
|
+
this.completeRetryIncidentOnTurnProgress();
|
|
23877
23953
|
return this.createReasoningSectionBreakEvent(notification.params);
|
|
23878
23954
|
case "model/rerouted":
|
|
23879
23955
|
return this.createModelReroutedEvent(notification.params);
|
|
@@ -23916,7 +23992,6 @@ var CodexEventHandler = class _CodexEventHandler {
|
|
|
23916
23992
|
case "windowsSandbox/setupCompleted":
|
|
23917
23993
|
case "account/login/completed":
|
|
23918
23994
|
case "skills/changed":
|
|
23919
|
-
case "deprecationNotice":
|
|
23920
23995
|
case "mcpServer/oauthLogin/completed":
|
|
23921
23996
|
case "externalAgentConfig/import/completed":
|
|
23922
23997
|
case "rawResponseItem/completed":
|
|
@@ -23944,14 +24019,31 @@ var CodexEventHandler = class _CodexEventHandler {
|
|
|
23944
24019
|
return createAgentTextMessageChunk(event.delta, event.itemId, createCodexMessagePhaseMeta(phase));
|
|
23945
24020
|
}
|
|
23946
24021
|
async createConfigWarningEvent(event) {
|
|
23947
|
-
|
|
24022
|
+
if (this.supportsTypedSessionFailures) {
|
|
24023
|
+
return this.createSessionFailureUpdate(this.recordSessionNotice(...this.sessionNoticeContent(event.summary, event.details)));
|
|
24024
|
+
}
|
|
24025
|
+
const text = event.details ? `${event.summary}
|
|
23948
24026
|
|
|
23949
|
-
${event.details}` :
|
|
23950
|
-
return createAgentTextMessageChunk(`Config warning: ${
|
|
24027
|
+
${event.details}` : event.summary;
|
|
24028
|
+
return createAgentTextMessageChunk(`Config warning: ${text}
|
|
23951
24029
|
|
|
23952
24030
|
`);
|
|
23953
24031
|
}
|
|
24032
|
+
/**
|
|
24033
|
+
* Unlike `warning` and `configWarning`, this notification was dropped outright, so there is no
|
|
24034
|
+
* legacy rendering to preserve. It is surfaced only to clients that negotiated typed records;
|
|
24035
|
+
* every other client keeps seeing exactly what it sees today, which is nothing.
|
|
24036
|
+
*/
|
|
24037
|
+
createDeprecationNoticeEvent(event) {
|
|
24038
|
+
if (!this.supportsTypedSessionFailures) return null;
|
|
24039
|
+
return this.createSessionFailureUpdate(
|
|
24040
|
+
this.recordSessionNotice(...this.sessionNoticeContent(event.summary, event.details))
|
|
24041
|
+
);
|
|
24042
|
+
}
|
|
23954
24043
|
createWarningEvent(event) {
|
|
24044
|
+
if (this.supportsTypedSessionFailures) {
|
|
24045
|
+
return this.createSessionFailureUpdate(this.recordSessionNotice(event.message));
|
|
24046
|
+
}
|
|
23955
24047
|
return createAgentTextMessageChunk(`Warning: ${event.message}
|
|
23956
24048
|
|
|
23957
24049
|
`);
|
|
@@ -24329,7 +24421,13 @@ ${event.stdin}
|
|
|
24329
24421
|
}
|
|
24330
24422
|
if (params.turnId !== this.sessionState.currentTurnId) {
|
|
24331
24423
|
if (this.supportsTypedSessionFailures) {
|
|
24332
|
-
|
|
24424
|
+
const failure = params.willRetry ? this.recordRetryWarning(params) : this.recordSessionFailure(
|
|
24425
|
+
this.sessionFailureKind(params.error.codexErrorInfo),
|
|
24426
|
+
params.turnId,
|
|
24427
|
+
"error",
|
|
24428
|
+
params.error.message
|
|
24429
|
+
);
|
|
24430
|
+
return this.createSessionFailureUpdate(failure);
|
|
24333
24431
|
}
|
|
24334
24432
|
return this.createCodexSessionInfoUpdate({
|
|
24335
24433
|
error: { ...params.error, turnId: params.turnId, willRetry: params.willRetry }
|
|
@@ -24337,7 +24435,7 @@ ${event.stdin}
|
|
|
24337
24435
|
}
|
|
24338
24436
|
if (params.willRetry) {
|
|
24339
24437
|
if (this.supportsTypedSessionFailures) {
|
|
24340
|
-
return this.
|
|
24438
|
+
return this.createSessionFailureUpdate(this.recordRetryWarning(params));
|
|
24341
24439
|
}
|
|
24342
24440
|
return this.createCodexSessionInfoUpdate({
|
|
24343
24441
|
error: {
|
|
@@ -24362,39 +24460,86 @@ ${event.stdin}
|
|
|
24362
24460
|
|
|
24363
24461
|
`);
|
|
24364
24462
|
}
|
|
24365
|
-
createSafeErrorDiagnostic(params) {
|
|
24366
|
-
const category = this.sessionFailureCategory(params.error.codexErrorInfo);
|
|
24367
|
-
return this.createCodexSessionInfoUpdate({
|
|
24368
|
-
error: {
|
|
24369
|
-
category,
|
|
24370
|
-
message: SESSION_FAILURE_PRESENTATION[category].message,
|
|
24371
|
-
turnId: params.turnId,
|
|
24372
|
-
willRetry: params.willRetry
|
|
24373
|
-
}
|
|
24374
|
-
});
|
|
24375
|
-
}
|
|
24376
24463
|
recordTypedSessionFailure(params) {
|
|
24377
|
-
const
|
|
24378
|
-
this.recordSessionFailure(
|
|
24379
|
-
}
|
|
24380
|
-
recordSessionFailure(
|
|
24381
|
-
const
|
|
24382
|
-
const
|
|
24383
|
-
const id =
|
|
24464
|
+
const kind = this.sessionFailureKind(params.error.codexErrorInfo);
|
|
24465
|
+
this.recordSessionFailure(kind, params.turnId, "error", params.error.message);
|
|
24466
|
+
}
|
|
24467
|
+
recordSessionFailure(kind, turnId, severity, title, actionsOverride, attributeToTurn = true) {
|
|
24468
|
+
const policy = SESSION_FAILURE_POLICY[kind];
|
|
24469
|
+
const scope = turnId ?? this.sessionState.sessionId;
|
|
24470
|
+
const id = this.activeFailureIdByScope.get(scope) ?? this.allocateFailureId(scope, turnId);
|
|
24471
|
+
const previous = this.failuresById.get(id);
|
|
24384
24472
|
const failure = {
|
|
24385
24473
|
id,
|
|
24386
|
-
revision: previous
|
|
24387
|
-
|
|
24388
|
-
|
|
24389
|
-
|
|
24390
|
-
|
|
24391
|
-
retryable: presentation.retryable,
|
|
24392
|
-
actions: presentation.actions,
|
|
24393
|
-
...turnId === void 0 ? {} : { turnId }
|
|
24474
|
+
revision: nextSessionFailureRevision(previous, id),
|
|
24475
|
+
category: policy.category,
|
|
24476
|
+
severity,
|
|
24477
|
+
title,
|
|
24478
|
+
actions: actionsOverride ?? policy.actions
|
|
24394
24479
|
};
|
|
24480
|
+
this.failuresById.set(id, failure);
|
|
24481
|
+
this.failureTurnIdById.set(id, attributeToTurn ? turnId : void 0);
|
|
24482
|
+
this.activeFailureIdByScope.set(scope, id);
|
|
24395
24483
|
this.sessionState.sessionFailure = failure;
|
|
24484
|
+
this.lastSessionNotice = void 0;
|
|
24396
24485
|
return failure;
|
|
24397
24486
|
}
|
|
24487
|
+
allocateFailureId(scope, turnId) {
|
|
24488
|
+
if (turnId !== void 0 && !this.allocatedFailureScopes.has(scope)) {
|
|
24489
|
+
this.allocatedFailureScopes.add(scope);
|
|
24490
|
+
return `${turnId}:error`;
|
|
24491
|
+
}
|
|
24492
|
+
this.allocatedFailureScopes.add(scope);
|
|
24493
|
+
return `${scope}:error:${this.sessionFailureEpoch}:${this.nextNoticeId++}`;
|
|
24494
|
+
}
|
|
24495
|
+
/**
|
|
24496
|
+
* A retry warning remains the active incident until Codex produces turn content again. That content is
|
|
24497
|
+
* the only positive signal available from app-server that the turn recovered; a later error then starts
|
|
24498
|
+
* a new incident instead of overwriting the historical reconnect entry. Terminal errors remain active so
|
|
24499
|
+
* duplicate late notifications cannot append duplicate transcript rows.
|
|
24500
|
+
*/
|
|
24501
|
+
completeRetryIncidentOnTurnProgress() {
|
|
24502
|
+
const turnId = this.sessionState.currentTurnId;
|
|
24503
|
+
if (turnId === null) return;
|
|
24504
|
+
const activeId = this.activeFailureIdByScope.get(turnId);
|
|
24505
|
+
if (activeId === void 0 || this.failuresById.get(activeId)?.severity !== "warning") return;
|
|
24506
|
+
this.activeFailureIdByScope.delete(turnId);
|
|
24507
|
+
if (this.sessionState.sessionFailure?.id === activeId) {
|
|
24508
|
+
delete this.sessionState.sessionFailure;
|
|
24509
|
+
}
|
|
24510
|
+
}
|
|
24511
|
+
recordRetryWarning(params, attributeToTurn = true) {
|
|
24512
|
+
const kind = this.sessionFailureKind(params.error.codexErrorInfo);
|
|
24513
|
+
return this.recordSessionFailure(
|
|
24514
|
+
kind,
|
|
24515
|
+
params.turnId,
|
|
24516
|
+
"warning",
|
|
24517
|
+
params.error.message,
|
|
24518
|
+
[],
|
|
24519
|
+
attributeToTurn
|
|
24520
|
+
);
|
|
24521
|
+
}
|
|
24522
|
+
recordSessionNotice(title, details) {
|
|
24523
|
+
const key = `${title}\0${details ?? ""}`;
|
|
24524
|
+
const previous = this.lastSessionNotice?.key === key ? this.lastSessionNotice.failure : void 0;
|
|
24525
|
+
const id = previous?.id ?? `${this.sessionState.sessionId}:notice:${this.sessionFailureEpoch}:${this.nextNoticeId++}`;
|
|
24526
|
+
const notice = {
|
|
24527
|
+
id,
|
|
24528
|
+
revision: nextSessionFailureRevision(previous, id),
|
|
24529
|
+
category: "unknown",
|
|
24530
|
+
severity: "warning",
|
|
24531
|
+
title,
|
|
24532
|
+
...details === void 0 ? {} : { details },
|
|
24533
|
+
actions: []
|
|
24534
|
+
};
|
|
24535
|
+
this.lastSessionNotice = { key, failure: notice };
|
|
24536
|
+
return notice;
|
|
24537
|
+
}
|
|
24538
|
+
sessionNoticeContent(summary, details) {
|
|
24539
|
+
if (details === null) return [summary];
|
|
24540
|
+
const combinedTitle = `${summary} \u2014 ${details}`;
|
|
24541
|
+
return combinedTitle.length <= MAX_SESSION_FAILURE_TITLE_LENGTH ? [combinedTitle] : [summary, details];
|
|
24542
|
+
}
|
|
24398
24543
|
createSessionFailureMeta(failure) {
|
|
24399
24544
|
return {
|
|
24400
24545
|
[JETBRAINS_META_KEY]: {
|
|
@@ -24411,7 +24556,7 @@ ${event.stdin}
|
|
|
24411
24556
|
_meta: this.createSessionFailureMeta(failure)
|
|
24412
24557
|
};
|
|
24413
24558
|
}
|
|
24414
|
-
|
|
24559
|
+
sessionFailureKind(error51) {
|
|
24415
24560
|
if (this.isAuthenticationRequiredError(error51)) return "auth_required";
|
|
24416
24561
|
if (this.getHttpStatusCode(error51) === 429) return "rate_limited";
|
|
24417
24562
|
if (typeof error51 === "string") {
|
|
@@ -26386,7 +26531,7 @@ var package_default = {
|
|
|
26386
26531
|
publishConfig: {
|
|
26387
26532
|
access: "public"
|
|
26388
26533
|
},
|
|
26389
|
-
version: "1.
|
|
26534
|
+
version: "1.3.0",
|
|
26390
26535
|
description: "",
|
|
26391
26536
|
main: "dist/index.js",
|
|
26392
26537
|
bin: {
|
|
@@ -26541,6 +26686,8 @@ function isRootPath(value) {
|
|
|
26541
26686
|
|
|
26542
26687
|
// src/CodexAcpClient.ts
|
|
26543
26688
|
var CUSTOM_GATEWAY_PROVIDER_ID = "custom-gateway";
|
|
26689
|
+
var OPENAI_PROVIDER_ID = "openai";
|
|
26690
|
+
var DEFAULT_OPENAI_BASE_URL = "https://api.openai.com/v1";
|
|
26544
26691
|
var SUPPORTED_GATEWAY_PROTOCOLS = {
|
|
26545
26692
|
openai: "responses"
|
|
26546
26693
|
};
|
|
@@ -26754,34 +26901,47 @@ var CodexAcpClient = class {
|
|
|
26754
26901
|
};
|
|
26755
26902
|
}
|
|
26756
26903
|
/**
|
|
26757
|
-
* `providers/list`: returns
|
|
26758
|
-
*
|
|
26759
|
-
* `null` when the provider is not configured/disabled.
|
|
26904
|
+
* `providers/list`: returns Codex's OpenAI slot. With no ACP override, the
|
|
26905
|
+
* slot reports native OpenAI routing; headers are never exposed.
|
|
26760
26906
|
*/
|
|
26761
26907
|
listProviders() {
|
|
26762
26908
|
const gatewayConfig = this.gatewayConfig;
|
|
26763
26909
|
const current = gatewayConfig ? {
|
|
26764
26910
|
apiType: gatewayApiTypeFromConfig(gatewayConfig),
|
|
26765
26911
|
baseUrl: gatewayConfig.config.base_url
|
|
26766
|
-
} :
|
|
26912
|
+
} : this.getNativeProviderConfig();
|
|
26767
26913
|
return [
|
|
26768
26914
|
{
|
|
26769
|
-
providerId:
|
|
26915
|
+
providerId: OPENAI_PROVIDER_ID,
|
|
26770
26916
|
supported: Object.keys(SUPPORTED_GATEWAY_PROTOCOLS),
|
|
26771
26917
|
required: false,
|
|
26772
26918
|
current
|
|
26773
26919
|
}
|
|
26774
26920
|
];
|
|
26775
26921
|
}
|
|
26922
|
+
getNativeProviderConfig() {
|
|
26923
|
+
const configuredProviderId = this.modelProvider ?? (typeof this.config["model_provider"] === "string" ? this.config["model_provider"] : null);
|
|
26924
|
+
const configuredProviders = this.config["model_providers"];
|
|
26925
|
+
if (configuredProviderId && configuredProviders && typeof configuredProviders === "object" && !Array.isArray(configuredProviders)) {
|
|
26926
|
+
const configuredProvider = configuredProviders[configuredProviderId];
|
|
26927
|
+
if (configuredProvider && typeof configuredProvider === "object" && !Array.isArray(configuredProvider)) {
|
|
26928
|
+
const baseUrl = configuredProvider["base_url"];
|
|
26929
|
+
if (typeof baseUrl === "string" && baseUrl.length > 0) {
|
|
26930
|
+
return { apiType: "openai", baseUrl };
|
|
26931
|
+
}
|
|
26932
|
+
}
|
|
26933
|
+
}
|
|
26934
|
+
return { apiType: "openai", baseUrl: DEFAULT_OPENAI_BASE_URL };
|
|
26935
|
+
}
|
|
26776
26936
|
/**
|
|
26777
26937
|
* `providers/set`: replaces the full configuration for the custom gateway
|
|
26778
26938
|
* provider. Rejects unknown provider ids with `invalid_params`.
|
|
26779
26939
|
*/
|
|
26780
26940
|
setProvider(request) {
|
|
26781
|
-
if (request.providerId !==
|
|
26941
|
+
if (request.providerId !== OPENAI_PROVIDER_ID) {
|
|
26782
26942
|
throw RequestError.invalidParams(
|
|
26783
26943
|
{ providerId: request.providerId },
|
|
26784
|
-
`Unknown providerId "${request.providerId}"; only "${
|
|
26944
|
+
`Unknown providerId "${request.providerId}"; only "${OPENAI_PROVIDER_ID}" is configurable`
|
|
26785
26945
|
);
|
|
26786
26946
|
}
|
|
26787
26947
|
this.applyGatewayConfig({
|
|
@@ -26795,7 +26955,7 @@ var CodexAcpClient = class {
|
|
|
26795
26955
|
* unknown provider id is idempotent success (RFD behavior §7).
|
|
26796
26956
|
*/
|
|
26797
26957
|
disableProvider(request) {
|
|
26798
|
-
if (request.providerId ===
|
|
26958
|
+
if (request.providerId === OPENAI_PROVIDER_ID) {
|
|
26799
26959
|
this.gatewayConfig = null;
|
|
26800
26960
|
}
|
|
26801
26961
|
}
|
|
@@ -30559,8 +30719,9 @@ Check ${configPath} and project .codex directories, especially their config.toml
|
|
|
30559
30719
|
let eventHandler = null;
|
|
30560
30720
|
let promptNotificationsActive = true;
|
|
30561
30721
|
const clearRecoveredSessionFailure = async (handler) => {
|
|
30722
|
+
await handler.completeSuccessfulTurn(sessionState.currentTurnId);
|
|
30562
30723
|
const current = sessionState.sessionFailure;
|
|
30563
|
-
if (recoverableSessionFailure
|
|
30724
|
+
if (recoverableSessionFailure !== void 0 && current !== void 0 && current.id === recoverableSessionFailure.id && current.revision === recoverableSessionFailure.revision) {
|
|
30564
30725
|
await handler.clearSessionFailure();
|
|
30565
30726
|
}
|
|
30566
30727
|
};
|
|
@@ -30850,8 +31011,10 @@ Check ${configPath} and project .codex directories, especially their config.toml
|
|
|
30850
31011
|
const isProcessExit = err instanceof RequestError && err.code === CODEX_PROCESS_EXITED_ERROR_CODE;
|
|
30851
31012
|
const isUnexpectedFailure = !(err instanceof RequestError);
|
|
30852
31013
|
if (eventHandler !== null && clientSupportsTypedSessionFailures(this.clientCapabilities) && (isProcessExit || isUnexpectedFailure)) {
|
|
30853
|
-
|
|
30854
|
-
|
|
31014
|
+
eventHandler.recordSyntheticTerminalFailure(
|
|
31015
|
+
isProcessExit ? "transport_lost" : "internal_error",
|
|
31016
|
+
sessionState.currentTurnId
|
|
31017
|
+
);
|
|
30855
31018
|
const failureResponse = this.terminalFailurePromptResponse(
|
|
30856
31019
|
sessionState,
|
|
30857
31020
|
eventHandler,
|