@agentclientprotocol/claude-agent-acp 0.104.2-preview.1 → 0.104.2-preview.2
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/v2/outcome.d.ts +18 -6
- package/dist/v2/outcome.d.ts.map +1 -1
- package/dist/v2/outcome.js +33 -9
- package/dist/v2/reports.d.ts +6 -0
- package/dist/v2/reports.d.ts.map +1 -1
- package/dist/v2/reports.js +18 -1
- package/dist/v2/session.d.ts +7 -0
- package/dist/v2/session.d.ts.map +1 -1
- package/dist/v2/session.js +20 -1
- package/package.json +1 -1
package/dist/v2/outcome.d.ts
CHANGED
|
@@ -26,8 +26,8 @@ export type IdleOutcome = Extract<v2.IdleStateUpdate, {
|
|
|
26
26
|
export declare function idleOutcome(end: TurnEnd | undefined, cancelled: boolean, report?: TurnReport, prompted?: boolean): IdleOutcome;
|
|
27
27
|
/**
|
|
28
28
|
* What the assistant messages of the open turn reported about its end: the
|
|
29
|
-
* error kind of a failed API request, Claude Code's sign-in message,
|
|
30
|
-
* refusal's explanation. Read from the main conversation's messages.
|
|
29
|
+
* error kind and text of a failed API request, Claude Code's sign-in message,
|
|
30
|
+
* and a refusal's explanation. Read from the main conversation's messages.
|
|
31
31
|
*/
|
|
32
32
|
export declare class TurnReport {
|
|
33
33
|
errorKind: SDKAssistantMessageError | undefined;
|
|
@@ -36,12 +36,24 @@ export declare class TurnReport {
|
|
|
36
36
|
/** The explanation of the turn's refusal. */
|
|
37
37
|
refusalExplanation: string | undefined;
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
|
|
39
|
+
* The text of the message that Claude Code wrote for a failed API request,
|
|
40
|
+
* e.g. "API Error: Connection lost mid-response. The response above may be
|
|
41
|
+
* incomplete.", until {@link takeApiError} reads it.
|
|
42
|
+
*/
|
|
43
|
+
private apiError;
|
|
44
|
+
/**
|
|
45
|
+
* An assistant message of the main conversation. Returns whether the
|
|
46
|
+
* client is not shown it as Claude's text:
|
|
47
|
+
*
|
|
48
|
+
* - Claude Code's sign-in message. Its `/login` instruction is for Claude
|
|
49
|
+
* Code's terminal, and the turn's idle fails with `authRequired` instead.
|
|
50
|
+
* - The message that Claude Code wrote for a failed API request (`error` on
|
|
51
|
+
* a `<synthetic>` message). The turn's idle carries it when the turn
|
|
52
|
+
* fails, and a notice otherwise (see {@link takeApiError}).
|
|
43
53
|
*/
|
|
44
54
|
assistant(message: SDKAssistantMessage): boolean;
|
|
55
|
+
/** The text of the turn's failed API request that no notice or idle reported yet. */
|
|
56
|
+
takeApiError(): string | undefined;
|
|
45
57
|
/**
|
|
46
58
|
* Claude Code's `model_refusal_no_fallback`: the explanation when the
|
|
47
59
|
* refused message carried none (older CLIs, gateways that drop
|
package/dist/v2/outcome.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outcome.d.ts","sourceRoot":"","sources":["../../src/v2/outcome.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,KAAK,EAAE,MAAM,mDAAmD,CAAC;AAC7E,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EACxB,gBAAgB,EACjB,MAAM,gCAAgC,CAAC;AAKxC,OAAO,EAIL,SAAS,EAKV,MAAM,qBAAqB,CAAC;AAE7B,4DAA4D;AAC5D,MAAM,MAAM,OAAO,GAAG;IACpB,MAAM,EAAE,gBAAgB,CAAC;IACzB,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC;IAChB,KAAK,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC;CACrC,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,CAC/B,EAAE,CAAC,eAAe,EAClB;IACE,UAAU,EAAE,UAAU,GAAG,YAAY,GAAG,mBAAmB,GAAG,SAAS,GAAG,WAAW,GAAG,OAAO,CAAC;CACjG,CACF,CAAC;AAUF;;;;;;;GAOG;AACH,wBAAgB,WAAW,C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,6CAA6C;IAC7C,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAqB;IAErC;;;;;;;;;OASG;IACH,SAAS,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO;IAiBhD,qFAAqF;IACrF,YAAY,IAAI,MAAM,GAAG,SAAS;IAMlC;;;;;OAKG;IACH,sBAAsB,CAAC,OAAO,EAAE;QAC9B,uBAAuB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACxC,yBAAyB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAC1C,OAAO,EAAE,MAAM,CAAC;KACjB,GAAG,IAAI;IAKR,KAAK,IAAI,IAAI;CAMd;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAOrE;AAED;;;;;;GAMG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,OAAO,CAA8B;IAC7C,OAAO,CAAC,KAAK,CAAuB;gBAExB,OAAO,EAAE,OAAO;IAI5B,iEAAiE;IACjE,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAI1C,kFAAkF;IAClF,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO;CAuB1C"}
|
package/dist/v2/outcome.js
CHANGED
|
@@ -11,7 +11,7 @@ import { RequestError } from "@agentclientprotocol/sdk/unstable";
|
|
|
11
11
|
import { AUTONOMOUS_RESULT_ORIGINS } from "../result-end.js";
|
|
12
12
|
import { isSyntheticLoginMessage } from "../message-filters.js";
|
|
13
13
|
import { resultEnd } from "../result-end.js";
|
|
14
|
-
import { providerFailureCategory } from "../session-failure-extension.js";
|
|
14
|
+
import { assistantMessageText, providerFailureCategory } from "../session-failure-extension.js";
|
|
15
15
|
import { getMatchingModelUsage, modelUsageIncrement, normalizeModelUsage, quotaMeta, resumedFirstResultModelUsage, tallyTotal, } from "../session-usage.js";
|
|
16
16
|
/** What a prompt's turn that ended without a result spent. */
|
|
17
17
|
const NOTHING_SPENT = {
|
|
@@ -67,8 +67,8 @@ function failed(error) {
|
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
69
|
* What the assistant messages of the open turn reported about its end: the
|
|
70
|
-
* error kind of a failed API request, Claude Code's sign-in message,
|
|
71
|
-
* refusal's explanation. Read from the main conversation's messages.
|
|
70
|
+
* error kind and text of a failed API request, Claude Code's sign-in message,
|
|
71
|
+
* and a refusal's explanation. Read from the main conversation's messages.
|
|
72
72
|
*/
|
|
73
73
|
export class TurnReport {
|
|
74
74
|
errorKind;
|
|
@@ -77,10 +77,20 @@ export class TurnReport {
|
|
|
77
77
|
/** The explanation of the turn's refusal. */
|
|
78
78
|
refusalExplanation;
|
|
79
79
|
/**
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
|
|
80
|
+
* The text of the message that Claude Code wrote for a failed API request,
|
|
81
|
+
* e.g. "API Error: Connection lost mid-response. The response above may be
|
|
82
|
+
* incomplete.", until {@link takeApiError} reads it.
|
|
83
|
+
*/
|
|
84
|
+
apiError;
|
|
85
|
+
/**
|
|
86
|
+
* An assistant message of the main conversation. Returns whether the
|
|
87
|
+
* client is not shown it as Claude's text:
|
|
88
|
+
*
|
|
89
|
+
* - Claude Code's sign-in message. Its `/login` instruction is for Claude
|
|
90
|
+
* Code's terminal, and the turn's idle fails with `authRequired` instead.
|
|
91
|
+
* - The message that Claude Code wrote for a failed API request (`error` on
|
|
92
|
+
* a `<synthetic>` message). The turn's idle carries it when the turn
|
|
93
|
+
* fails, and a notice otherwise (see {@link takeApiError}).
|
|
84
94
|
*/
|
|
85
95
|
assistant(message) {
|
|
86
96
|
if (message.error)
|
|
@@ -89,11 +99,24 @@ export class TurnReport {
|
|
|
89
99
|
this.refusalExplanation =
|
|
90
100
|
message.message.stop_details?.explanation ?? this.refusalExplanation;
|
|
91
101
|
}
|
|
92
|
-
if (
|
|
102
|
+
if (isSyntheticLoginMessage(message.message)) {
|
|
103
|
+
this.loginRequired = true;
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
if (!message.error || message.message.model !== "<synthetic>")
|
|
93
107
|
return false;
|
|
94
|
-
|
|
108
|
+
const text = assistantMessageText(message.message);
|
|
109
|
+
if (!text)
|
|
110
|
+
return false;
|
|
111
|
+
this.apiError = text;
|
|
95
112
|
return true;
|
|
96
113
|
}
|
|
114
|
+
/** The text of the turn's failed API request that no notice or idle reported yet. */
|
|
115
|
+
takeApiError() {
|
|
116
|
+
const text = this.apiError;
|
|
117
|
+
this.apiError = undefined;
|
|
118
|
+
return text;
|
|
119
|
+
}
|
|
97
120
|
/**
|
|
98
121
|
* Claude Code's `model_refusal_no_fallback`: the explanation when the
|
|
99
122
|
* refused message carried none (older CLIs, gateways that drop
|
|
@@ -109,6 +132,7 @@ export class TurnReport {
|
|
|
109
132
|
this.errorKind = undefined;
|
|
110
133
|
this.loginRequired = false;
|
|
111
134
|
this.refusalExplanation = undefined;
|
|
135
|
+
this.apiError = undefined;
|
|
112
136
|
}
|
|
113
137
|
}
|
|
114
138
|
/**
|
package/dist/v2/reports.d.ts
CHANGED
|
@@ -114,6 +114,12 @@ export declare class SessionReports {
|
|
|
114
114
|
* turn's result repeats the block reason).
|
|
115
115
|
*/
|
|
116
116
|
repeats(resultText: string): boolean;
|
|
117
|
+
/**
|
|
118
|
+
* A notice of the message that Claude Code wrote for a failed API request
|
|
119
|
+
* (see `TurnReport.takeApiError`). It is a turn's notice, so a result that
|
|
120
|
+
* repeats its text is not shown again.
|
|
121
|
+
*/
|
|
122
|
+
apiError(text: string): void;
|
|
117
123
|
/**
|
|
118
124
|
* Claude Code's session state went `idle`: the idle compaction may arm, and
|
|
119
125
|
* the title may have landed (see {@link SessionTitles.onTurnEnd}).
|
package/dist/v2/reports.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reports.d.ts","sourceRoot":"","sources":["../../src/v2/reports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I,EAAE,SAAS,GAAG,SAAS,GAAG,IAAI;IAM3D;;;;;OAKG;IACH,iBAAiB,IAAI,IAAI;IAYzB,2FAA2F;IAC3F,YAAY,IAAI,IAAI;IASpB,sFAAsF;IACtF,kBAAkB,IAAI,MAAM,GAAG,SAAS;IAKxC,OAAO,IAAI,IAAI;IAMf,4EAA4E;IAC5E,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAMtC,gFAAgF;IAChF,WAAW,CAAC,OAAO,EAAE,0BAA0B,GAAG,IAAI;IA4CtD;;;OAGG;IACH,SAAS,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI;IAS7C;;;OAGG;IACH,MAAM,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI;IAqBvC;;;OAGG;IACH,MAAM,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO;IAiFpC;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;IA4BzB,+EAA+E;IAC/E,OAAO,CAAC,kBAAkB;IAY1B,uEAAuE;IACvE,OAAO,CAAC,cAAc;IAUtB;;;OAGG;IACH,OAAO,CAAC,SAAS;CAclB;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE;IACnC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;CAChC,GAAG,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAqBhC"}
|
package/dist/v2/reports.js
CHANGED
|
@@ -2,7 +2,7 @@ import { ContextCompactionLifecycle, contextCompactionMetadataFromBoundary, } fr
|
|
|
2
2
|
import { cacheResultContextWindow, immediateContextWindow, providerCacheKeyFor, readContextWindow, } from "../context-window.js";
|
|
3
3
|
import { IdleCompaction } from "../idle-compaction.js";
|
|
4
4
|
import { PromptSuggestions } from "../prompt-suggestions.js";
|
|
5
|
-
import { informationalNotice, mcpServerStartupNotice, normalizeNoticeText, noticeUpdate, } from "../session-notices.js";
|
|
5
|
+
import { informationalNotice, mcpServerStartupNotice, normalizeNoticeText, noticeUpdate, splitNoticeText, } from "../session-notices.js";
|
|
6
6
|
import { DEFAULT_CONTEXT_WINDOW, getMatchingModelUsage, inferContextWindowFromModel, snapshotFromUsage, totalTokens, ZERO_USAGE, } from "../session-usage.js";
|
|
7
7
|
import { SessionTitles } from "../session-titles.js";
|
|
8
8
|
import { createTaskHook } from "../tools.js";
|
|
@@ -112,6 +112,23 @@ export class SessionReports {
|
|
|
112
112
|
return (this.compaction.hasDeliveredOutput ||
|
|
113
113
|
this.noticeTexts.includes(normalizeNoticeText(resultText)));
|
|
114
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* A notice of the message that Claude Code wrote for a failed API request
|
|
117
|
+
* (see `TurnReport.takeApiError`). It is a turn's notice, so a result that
|
|
118
|
+
* repeats its text is not shown again.
|
|
119
|
+
*/
|
|
120
|
+
apiError(text) {
|
|
121
|
+
this.host.emit([
|
|
122
|
+
{
|
|
123
|
+
sessionId: this.host.sessionId,
|
|
124
|
+
update: noticeUpdate({
|
|
125
|
+
severity: "error",
|
|
126
|
+
...splitNoticeText(text, "Claude reported an API error"),
|
|
127
|
+
}),
|
|
128
|
+
},
|
|
129
|
+
]);
|
|
130
|
+
this.noticeTexts.push(normalizeNoticeText(text));
|
|
131
|
+
}
|
|
115
132
|
/**
|
|
116
133
|
* Claude Code's session state went `idle`: the idle compaction may arm, and
|
|
117
134
|
* the title may have landed (see {@link SessionTitles.onTurnEnd}).
|
package/dist/v2/session.d.ts
CHANGED
|
@@ -294,6 +294,13 @@ export declare class V2Session implements RequestTarget {
|
|
|
294
294
|
* for them, so the idle follows them.
|
|
295
295
|
*/
|
|
296
296
|
private endTurn;
|
|
297
|
+
/**
|
|
298
|
+
* Sends the text of a failed API request that Claude Code wrote into the
|
|
299
|
+
* conversation (see `TurnReport.assistant`) as a notice. A turn whose idle
|
|
300
|
+
* fails sends none: its error carries the failure. `end` is the turn's
|
|
301
|
+
* result, if it has one.
|
|
302
|
+
*/
|
|
303
|
+
private reportApiError;
|
|
297
304
|
/**
|
|
298
305
|
* Claude Code's `idle`. The one that follows a result is that result's, and
|
|
299
306
|
* can come after the next cycle's first output. Any other ends the open
|
package/dist/v2/session.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/v2/session.ts"],"names":[],"mappings":"AAkCA,OAAO,EAEL,KAAK,+BAA+B,EACpC,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAE9B,KAAK,cAAc,EACpB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,KAAK,EAAE,MAAM,mDAAmD,CAAC;AAC7E,OAAO,KAAK,EAGV,cAAc,EACd,gBAAgB,EAChB,KAAK,EAGL,cAAc,EACf,MAAM,gCAAgC,CAAC;AAGxC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAKjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAQjD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAA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B;IAMzB,OAAO,CAAC,WAAW;IAcnB;;;;OAIG;IACH,OAAO,CAAC,MAAM;IAgHd;;;OAGG;IACH,OAAO,CAAC,MAAM;IAoBd,OAAO,CAAC,SAAS;IAkCjB;;;;;OAKG;IACH,OAAO,CAAC,aAAa;IAUrB,OAAO,CAAC,QAAQ;IAShB;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,MAAM;IA8Dd;;;;OAIG;IACH,OAAO,CAAC,OAAO;IAQf;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAOtB;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAUtB,+EAA+E;IAC/E,OAAO,CAAC,cAAc;IAMtB,8EAA8E;IAC9E,OAAO,CAAC,KAAK;IAwCb,oFAAoF;IACpF,OAAO,CAAC,UAAU;IAQlB;;;OAGG;IACH,OAAO,CAAC,QAAQ;IAehB;;;;OAIG;IACH,OAAO,CAAC,SAAS;IAgCjB;;;;OAIG;IACH,OAAO,CAAC,eAAe;IAMvB;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAgBnB,OAAO,CAAC,WAAW;IAoBnB,OAAO,CAAC,IAAI;IAIZ,gFAAgF;IAChF,OAAO,CAAC,gBAAgB;IAKxB,yFAAyF;IACzF,OAAO,CAAC,UAAU;IAWlB,OAAO,CAAC,WAAW;CAGpB"}
|
package/dist/v2/session.js
CHANGED
|
@@ -773,7 +773,8 @@ export class V2Session {
|
|
|
773
773
|
if (this.stopped.drops(message))
|
|
774
774
|
return;
|
|
775
775
|
if (message.parent_tool_use_id === null) {
|
|
776
|
-
// Claude Code's sign-in message
|
|
776
|
+
// Claude Code's sign-in message and its message for a failed API
|
|
777
|
+
// request are not shown as Claude's text (see `TurnReport`).
|
|
777
778
|
if (this.turnReport.assistant(message))
|
|
778
779
|
return;
|
|
779
780
|
this.outputStarts();
|
|
@@ -979,6 +980,8 @@ export class V2Session {
|
|
|
979
980
|
this.fastModeReported(message);
|
|
980
981
|
}
|
|
981
982
|
this.reports.result(message);
|
|
983
|
+
// Before the result's text below, which can repeat the failed request's.
|
|
984
|
+
this.reportApiError(end);
|
|
982
985
|
// The turn goes on in a fresh context (see `ClearContext`).
|
|
983
986
|
if (this.clearContext.holdsResult(message, end)) {
|
|
984
987
|
this.turnReport.reset();
|
|
@@ -1028,6 +1031,20 @@ export class V2Session {
|
|
|
1028
1031
|
return this.closeTurn();
|
|
1029
1032
|
return reporting.then(() => this.closeTurn());
|
|
1030
1033
|
}
|
|
1034
|
+
/**
|
|
1035
|
+
* Sends the text of a failed API request that Claude Code wrote into the
|
|
1036
|
+
* conversation (see `TurnReport.assistant`) as a notice. A turn whose idle
|
|
1037
|
+
* fails sends none: its error carries the failure. `end` is the turn's
|
|
1038
|
+
* result, if it has one.
|
|
1039
|
+
*/
|
|
1040
|
+
reportApiError(end) {
|
|
1041
|
+
const text = this.turnReport.takeApiError();
|
|
1042
|
+
if (!text)
|
|
1043
|
+
return;
|
|
1044
|
+
if (idleOutcome(end, this.cancelledWork, this.turnReport).stopReason === "error")
|
|
1045
|
+
return;
|
|
1046
|
+
this.reports.apiError(text);
|
|
1047
|
+
}
|
|
1031
1048
|
/**
|
|
1032
1049
|
* Claude Code's `idle`. The one that follows a result is that result's, and
|
|
1033
1050
|
* can come after the next cycle's first output. Any other ends the open
|
|
@@ -1134,6 +1151,8 @@ export class V2Session {
|
|
|
1134
1151
|
request.abort.abort();
|
|
1135
1152
|
}
|
|
1136
1153
|
}
|
|
1154
|
+
// A turn that ends without a result, such as an interrupted one.
|
|
1155
|
+
this.reportApiError(this.lastEnd);
|
|
1137
1156
|
this.reports.turnEnded();
|
|
1138
1157
|
this.elicitations.turnEnded();
|
|
1139
1158
|
this.fileChanges?.turnClosed(cancelled);
|
package/package.json
CHANGED