@restatedev/agents 0.7.0 → 0.8.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/README.md +29 -5
- package/dist/agentlib/agent.d.ts +32 -0
- package/dist/agentlib/agent.d.ts.map +1 -0
- package/dist/agentlib/agent.js +172 -0
- package/dist/agentlib/agent.js.map +1 -0
- package/dist/agentlib/index.d.ts +5 -0
- package/dist/agentlib/index.d.ts.map +1 -0
- package/dist/agentlib/index.js +15 -0
- package/dist/agentlib/index.js.map +1 -0
- package/dist/agentlib/messages.d.ts +39 -0
- package/dist/agentlib/messages.d.ts.map +1 -0
- package/dist/agentlib/messages.js +177 -0
- package/dist/agentlib/messages.js.map +1 -0
- package/dist/agentlib/model.d.ts +29 -0
- package/dist/agentlib/model.d.ts.map +1 -0
- package/dist/agentlib/model.js +131 -0
- package/dist/agentlib/model.js.map +1 -0
- package/dist/agentlib/options.d.ts +58 -0
- package/dist/agentlib/options.d.ts.map +1 -0
- package/dist/agentlib/options.js +2 -0
- package/dist/agentlib/options.js.map +1 -0
- package/dist/agentlib/runtime.d.ts +37 -0
- package/dist/agentlib/runtime.d.ts.map +1 -0
- package/dist/agentlib/runtime.js +216 -0
- package/dist/agentlib/runtime.js.map +1 -0
- package/dist/agentlib/state.d.ts +114 -0
- package/dist/agentlib/state.d.ts.map +1 -0
- package/dist/agentlib/state.js +52 -0
- package/dist/agentlib/state.js.map +1 -0
- package/dist/agentlib/steering.d.ts +23 -0
- package/dist/agentlib/steering.d.ts.map +1 -0
- package/dist/agentlib/steering.js +48 -0
- package/dist/agentlib/steering.js.map +1 -0
- package/dist/agentlib/tools.d.ts +33 -0
- package/dist/agentlib/tools.d.ts.map +1 -0
- package/dist/agentlib/tools.js +243 -0
- package/dist/agentlib/tools.js.map +1 -0
- package/dist/agentlib/turn.d.ts +82 -0
- package/dist/agentlib/turn.d.ts.map +1 -0
- package/dist/agentlib/turn.js +253 -0
- package/dist/agentlib/turn.js.map +1 -0
- package/dist/common.d.ts +8 -0
- package/dist/common.d.ts.map +1 -1
- package/dist/common.js +12 -0
- package/dist/common.js.map +1 -1
- package/dist/companion.d.ts +2 -1
- package/dist/companion.d.ts.map +1 -1
- package/dist/companion.js.map +1 -1
- package/dist/deepseek/index.d.ts +2 -6
- package/dist/deepseek/index.d.ts.map +1 -1
- package/dist/deepseek/index.js +3 -14
- package/dist/deepseek/index.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/opencode/index.d.ts.map +1 -1
- package/dist/opencode/index.js +11 -18
- package/dist/opencode/index.js.map +1 -1
- package/dist/tools.d.ts +53 -2
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +32 -15
- package/dist/tools.js.map +1 -1
- package/package.json +28 -4
- package/src/agentlib/README.md +229 -0
- package/src/agentlib/agent.ts +214 -0
- package/src/agentlib/index.ts +16 -0
- package/src/agentlib/messages.ts +207 -0
- package/src/agentlib/model.ts +150 -0
- package/src/agentlib/options.ts +62 -0
- package/src/agentlib/runtime.ts +252 -0
- package/src/agentlib/state.ts +93 -0
- package/src/agentlib/steering.ts +53 -0
- package/src/agentlib/tools.ts +353 -0
- package/src/agentlib/turn.ts +302 -0
- package/src/common.ts +15 -0
- package/src/companion.ts +2 -1
- package/src/deepseek/index.ts +5 -18
- package/src/index.ts +6 -4
- package/src/opencode/index.ts +12 -17
- package/src/tools.ts +118 -52
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { sdk as restate } from '@restatedev/sessions/internal';
|
|
2
|
+
import { CHECK_MODEL, ModelError, REFUSED } from '../common.js';
|
|
3
|
+
/** The model of an agent that names none, without MODEL either: OpenAI's (OPENAI_API_KEY). */
|
|
4
|
+
export const DEFAULT_MODEL = 'openai/gpt-6-sol';
|
|
5
|
+
/** The AI SDK's provider packages, by provider. OpenAI's uses its Responses API. */
|
|
6
|
+
const PROVIDERS = {
|
|
7
|
+
openai: async () => (await import('@ai-sdk/openai')).openai,
|
|
8
|
+
anthropic: async () => (await import('@ai-sdk/anthropic')).anthropic,
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Returns what loads agent `agent`'s model on its first turn: `model` itself,
|
|
12
|
+
* or the model it names (`provider/model-id`, else MODEL, else
|
|
13
|
+
* {@link DEFAULT_MODEL}) on the AI SDK. A name it cannot take throws at once.
|
|
14
|
+
*/
|
|
15
|
+
export function modelLoader(agent, model) {
|
|
16
|
+
if (typeof model === 'function')
|
|
17
|
+
return async () => model;
|
|
18
|
+
const id = model ?? process.env.MODEL ?? DEFAULT_MODEL;
|
|
19
|
+
const at = id.indexOf('/');
|
|
20
|
+
if (at <= 0 || at === id.length - 1) {
|
|
21
|
+
throw new Error(`${agent}: the model ${id} is not provider/model-id`);
|
|
22
|
+
}
|
|
23
|
+
const provider = id.slice(0, at);
|
|
24
|
+
const modelId = id.slice(at + 1);
|
|
25
|
+
const loadProvider = PROVIDERS[provider];
|
|
26
|
+
if (!loadProvider) {
|
|
27
|
+
throw new Error(`${agent}: an agentlib agent takes openai/… and anthropic/… models by name, not ${id}. ` +
|
|
28
|
+
'Give any other as a model of agentlib (aiModel of @restatedev/agentlib/provider).');
|
|
29
|
+
}
|
|
30
|
+
return async () => {
|
|
31
|
+
const { aiModel } = await import('@restatedev/agentlib/provider');
|
|
32
|
+
const languageModel = await loadLanguageModel(id, loadProvider, modelId);
|
|
33
|
+
// `retry: {}` sets no retry limit of the model's own: an outage fails the
|
|
34
|
+
// attempt, and Restate retries it, as for every agent.
|
|
35
|
+
const loaded = aiModel({ model: languageModel, retry: {} });
|
|
36
|
+
return provider === 'anthropic' ? withoutSchemaBounds(loaded) : loaded;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/** Creates the AI SDK model `modelId`, with a clear error if its provider package is missing. */
|
|
40
|
+
async function loadLanguageModel(id, loadProvider, modelId) {
|
|
41
|
+
let create;
|
|
42
|
+
try {
|
|
43
|
+
create = await loadProvider();
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
const provider = id.slice(0, id.indexOf('/'));
|
|
47
|
+
const advice = `install it beside @restatedev/agentlib (${String(error)})`;
|
|
48
|
+
throw new ModelError(`${id} needs @ai-sdk/${provider}: ${advice}`);
|
|
49
|
+
}
|
|
50
|
+
return create(modelId);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Whether `error`, thrown by a model, is its provider's refusal that a retry
|
|
54
|
+
* does not change: a request answered with a 4xx (a wrong API key, an unknown
|
|
55
|
+
* model, a rejected request), or a missing API key. Only a plain
|
|
56
|
+
* `TerminalError` qualifies: agentlib's own errors (an overflow, a protocol
|
|
57
|
+
* error) and cancellations are subclasses.
|
|
58
|
+
*/
|
|
59
|
+
export function refused(error) {
|
|
60
|
+
if (!(error instanceof restate.TerminalError))
|
|
61
|
+
return false;
|
|
62
|
+
if (error.constructor !== restate.TerminalError)
|
|
63
|
+
return false;
|
|
64
|
+
const clientError = error.code >= 400 && error.code < 500;
|
|
65
|
+
return clientError || /API key/i.test(error.message);
|
|
66
|
+
}
|
|
67
|
+
/** Wraps `model` so that its provider's refusals end the turn with a 424, as for every agent. */
|
|
68
|
+
export function refusing(model) {
|
|
69
|
+
return function* (request) {
|
|
70
|
+
try {
|
|
71
|
+
return yield* model(request);
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
if (!refused(error))
|
|
75
|
+
throw error;
|
|
76
|
+
const message = `the model's provider refused the request: ${CHECK_MODEL}. ${error.message}`;
|
|
77
|
+
throw new restate.TerminalError(message, { errorCode: REFUSED });
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
const NUMBER_BOUNDS = new Set([
|
|
82
|
+
'minimum',
|
|
83
|
+
'maximum',
|
|
84
|
+
'exclusiveMinimum',
|
|
85
|
+
'exclusiveMaximum',
|
|
86
|
+
'multipleOf',
|
|
87
|
+
]);
|
|
88
|
+
/** Returns `schema` (a JSON schema) without the bounds of its numbers, at any depth. */
|
|
89
|
+
export function withoutBounds(schema) {
|
|
90
|
+
if (Array.isArray(schema))
|
|
91
|
+
return schema.map(withoutBounds);
|
|
92
|
+
if (typeof schema !== 'object' || schema === null)
|
|
93
|
+
return schema;
|
|
94
|
+
const type = schema.type;
|
|
95
|
+
const types = Array.isArray(type) ? type : [type];
|
|
96
|
+
const numeric = types.includes('integer') || types.includes('number');
|
|
97
|
+
const kept = Object.entries(schema).filter(([key]) => !(numeric && NUMBER_BOUNDS.has(key)));
|
|
98
|
+
return Object.fromEntries(kept.map(([key, value]) => [key, withoutBounds(value)]));
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Wraps an Anthropic `model` so that it gets its tools' schemas without
|
|
102
|
+
* numeric bounds. agentlib 0.1.0 asks for strict tools where a schema allows
|
|
103
|
+
* it, and Anthropic refuses strict tools with bounded numbers (such as
|
|
104
|
+
* agentlib's own `read_tool_result`). The tools still check their input.
|
|
105
|
+
*/
|
|
106
|
+
function withoutSchemaBounds(model) {
|
|
107
|
+
return (request) => {
|
|
108
|
+
const tools = request.tools.map((tool) => {
|
|
109
|
+
const inputSchema = withoutBounds(tool.inputSchema);
|
|
110
|
+
return { ...tool, inputSchema };
|
|
111
|
+
});
|
|
112
|
+
return model({ ...request, tools });
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Checks that agent `agent`'s `history` bounds are positive integers. agentlib
|
|
117
|
+
* checks them only when a turn compacts, with an error that a retry would meet
|
|
118
|
+
* again and again.
|
|
119
|
+
*/
|
|
120
|
+
export function checkHistory(agent, history) {
|
|
121
|
+
for (const bound of ['maxMessages', 'maxChars', 'retainMessages']) {
|
|
122
|
+
const value = history[bound];
|
|
123
|
+
if (value === undefined)
|
|
124
|
+
continue;
|
|
125
|
+
if (!Number.isSafeInteger(value) || value <= 0) {
|
|
126
|
+
const given = JSON.stringify(value);
|
|
127
|
+
throw new Error(`${agent}: history.${bound} must be a positive integer, not ${given}`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/agentlib/model.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEhE,8FAA8F;AAC9F,MAAM,CAAC,MAAM,aAAa,GAAG,kBAAkB,CAAC;AAIhD,oFAAoF;AACpF,MAAM,SAAS,GAAsE;IACnF,MAAM,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,MAAM;IAC3D,SAAS,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC,SAAS;CACrE,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,WAAW,CACzB,KAAa,EACb,KAAiC;IAEjC,IAAI,OAAO,KAAK,KAAK,UAAU;QAAE,OAAO,KAAK,IAAI,EAAE,CAAC,KAAK,CAAC;IAE1D,MAAM,EAAE,GAAG,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,aAAa,CAAC;IACvD,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3B,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,eAAe,EAAE,2BAA2B,CAAC,CAAC;IACxE,CAAC;IACD,MAAM,QAAQ,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACjC,M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K,IAAI,CAAC,aAAa,EAAE,UAAU,EAAE,gBAAgB,CAAU,EAAE,CAAC;QAC3E,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;QAC7B,IAAI,KAAK,KAAK,SAAS;YAAE,SAAS;QAClC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;YAC/C,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YACpC,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,aAAa,KAAK,oCAAoC,KAAK,EAAE,CAAC,CAAC;QACzF,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { AgentOptions as LibOptions, CompactionPolicy, Model } from '@restatedev/agentlib';
|
|
2
|
+
import type { sdk as restate } from '@restatedev/sessions/internal';
|
|
3
|
+
import type { AgentlibContext, Approval, Tools } from './tools.ts';
|
|
4
|
+
/** agentlib's options that the agent sets itself, or takes under another name. */
|
|
5
|
+
type Replaced = 'model' | 'name' | 'instructions' | 'tools' | 'onApproval' | 'onHumanApproval';
|
|
6
|
+
/**
|
|
7
|
+
* The options of an agentlib agent. agentlib's other options (`maxSteps`,
|
|
8
|
+
* `compaction`, `contextWindow`, `toolResults`, `skills`, `beforeTool`,
|
|
9
|
+
* `afterRun`...) go to its `agent()` as they are.
|
|
10
|
+
*/
|
|
11
|
+
export interface Options<O = string> extends Omit<LibOptions<AgentlibContext, O>, Replaced> {
|
|
12
|
+
/**
|
|
13
|
+
* `provider/model-id` (`openai/…` or `anthropic/…`), else MODEL, else
|
|
14
|
+
* `openai/gpt-6-sol`; or a model of agentlib (`aiModel` of
|
|
15
|
+
* `@restatedev/agentlib/provider`, for any provider of the AI SDK).
|
|
16
|
+
*/
|
|
17
|
+
model?: string | Model;
|
|
18
|
+
/** The system prompt: a text, or agentlib's function of the run's context that returns one. */
|
|
19
|
+
system?: LibOptions<AgentlibContext, O>['instructions'];
|
|
20
|
+
/**
|
|
21
|
+
* The tools: those of `@restatedev/agents` (`tool()`, `call`, `send`,
|
|
22
|
+
* `workflow`, `signal`, `subagent`), and agentlib's own by the name the
|
|
23
|
+
* model calls them, as in `[weather, { transfer: asyncTool(...) }]`.
|
|
24
|
+
*/
|
|
25
|
+
tools?: Tools;
|
|
26
|
+
/**
|
|
27
|
+
* The tools of `@restatedev/agents` whose calls wait for a person's
|
|
28
|
+
* approval before they run, by name, or a function of a call that says
|
|
29
|
+
* whether it does. `pending` lists the wait, and `signal` approves it
|
|
30
|
+
* (`true`, `"approved"`, `{ "approved": true }`) or denies it (anything
|
|
31
|
+
* else). agentlib's own tools take `needsApproval` instead.
|
|
32
|
+
*/
|
|
33
|
+
approval?: Approval;
|
|
34
|
+
/**
|
|
35
|
+
* How the model's conversation stays short from turn to turn. At a turn's
|
|
36
|
+
* start, once its messages since the last summary pass `maxMessages`
|
|
37
|
+
* (default 64) or `maxChars` (default 64 000), the earliest are summarized
|
|
38
|
+
* by `model` (by default the agent's), and the latest `retainMessages`
|
|
39
|
+
* (default 12) are kept. The summary is kept for the next turns. `false`
|
|
40
|
+
* keeps the whole conversation. `messages` shows every turn either way.
|
|
41
|
+
*/
|
|
42
|
+
history?: false | (CompactionPolicy & {
|
|
43
|
+
model?: Model;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/** An agent's name, and what it is beside its options. */
|
|
47
|
+
export interface Definition<P extends string> {
|
|
48
|
+
name: P;
|
|
49
|
+
/** What it is: for the UI, and for the model of a parent that hands it tasks (`subagent`). */
|
|
50
|
+
description?: string;
|
|
51
|
+
/** It works unwatched (a sub-agent, say): its turn tells its companion at its end only. */
|
|
52
|
+
background?: boolean;
|
|
53
|
+
/** Options of the object, beside the ones the agent sets (its `retryPolicy`, say). */
|
|
54
|
+
options?: restate.ObjectOptions;
|
|
55
|
+
metadata?: Record<string, string>;
|
|
56
|
+
}
|
|
57
|
+
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AAE,OAAO,CAAC;IACrB,sFAAsF;IACtF,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/agentlib/options.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { sdk as restate } from '@restatedev/sessions/internal';
|
|
2
|
+
import type { Options } from './options.ts';
|
|
3
|
+
/**
|
|
4
|
+
* One agentlib agent's turns. Its model, and with it agentlib's agent, load
|
|
5
|
+
* on the first turn (a missing provider package fails that turn, not the
|
|
6
|
+
* process); everything else is checked when the agent is defined.
|
|
7
|
+
*/
|
|
8
|
+
export declare class Runtime<O> {
|
|
9
|
+
private readonly name;
|
|
10
|
+
private readonly background;
|
|
11
|
+
private readonly libOptions;
|
|
12
|
+
private readonly system;
|
|
13
|
+
private readonly tools?;
|
|
14
|
+
private readonly history;
|
|
15
|
+
private readonly loadModel;
|
|
16
|
+
private loading?;
|
|
17
|
+
constructor(name: string, background: boolean, options: Options<O>);
|
|
18
|
+
/** Answers `text` in the turn of `ctx`'s invocation. */
|
|
19
|
+
answer(ctx: restate.ObjectContext, text: string): Promise<O | string>;
|
|
20
|
+
/** What the companion learns as the turn starts. */
|
|
21
|
+
private started;
|
|
22
|
+
/** Loads the agent (once), and gives the turn what summarizes its conversation. */
|
|
23
|
+
private prepare;
|
|
24
|
+
/** Loads the model, and makes agentlib's agent with it. */
|
|
25
|
+
private load;
|
|
26
|
+
/** The options of agentlib's run of the turn. */
|
|
27
|
+
private runOptions;
|
|
28
|
+
/**
|
|
29
|
+
* Records a progress event of the run. A change that clients see is
|
|
30
|
+
* published to the companion, whose answer says which messages are steered
|
|
31
|
+
* to the turn; the run gets them at its next event.
|
|
32
|
+
*/
|
|
33
|
+
private onProgress;
|
|
34
|
+
/** Ends a turn that has no answer, with `note`, at the agent and at its companion. */
|
|
35
|
+
private end;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/agentlib/runtime.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAI/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAc5C;;;;GAIG;AACH,qBAAa,OAAO,CAAC,CAAC;IACpB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAU;IACrC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAGzB;IACF,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuB;IAC9C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAA+B;IACtD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAwB;IAChD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAuB;IACjD,OAAO,CAAC,OAAO,CAAC,CAAqB;IAErC,YAAY,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAajE;IAED,wDAAwD;IAClD,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,CA8B1E;IAED,oDAAoD;YACtC,OAAO;IASrB,mFAAmF;YACrE,OAAO;IAoBrB,2DAA2D;YAC7C,IAAI;IAiBlB,iDAAiD;IACjD,OAAO,CAAC,UAAU;IAelB;;;;OAIG;IACH,OAAO,CAAE,UAAU;IAcnB,sFAAsF;YACxE,GAAG;CAIlB"}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
// How an agentlib agent answers a message: a turn, from its start at the
|
|
2
|
+
// companion, through agentlib's run (journaled), to its end.
|
|
3
|
+
import { agent as agentlibAgent, } from '@restatedev/agentlib';
|
|
4
|
+
import { execute, internal } from '@restatedev/restate-sdk-gen';
|
|
5
|
+
import { sdk as restate } from '@restatedev/sessions/internal';
|
|
6
|
+
import { approves, CANCELLED, ModelError, REFUSED, UNANSWERED } from '../common.js';
|
|
7
|
+
import { checkHistory, modelLoader, refusing } from './model.js';
|
|
8
|
+
import { Steering, takenIds } from './steering.js';
|
|
9
|
+
import { companionAt, companionSendAt, read, TAKEN, waitForSignal } from './state.js';
|
|
10
|
+
import { toolsOf } from './tools.js';
|
|
11
|
+
import { conversationOf, Turn } from './turn.js';
|
|
12
|
+
const { adopt } = internal;
|
|
13
|
+
/**
|
|
14
|
+
* One agentlib agent's turns. Its model, and with it agentlib's agent, load
|
|
15
|
+
* on the first turn (a missing provider package fails that turn, not the
|
|
16
|
+
* process); everything else is checked when the agent is defined.
|
|
17
|
+
*/
|
|
18
|
+
export class Runtime {
|
|
19
|
+
name;
|
|
20
|
+
background;
|
|
21
|
+
libOptions;
|
|
22
|
+
system;
|
|
23
|
+
tools;
|
|
24
|
+
history;
|
|
25
|
+
loadModel;
|
|
26
|
+
loading;
|
|
27
|
+
constructor(name, background, options) {
|
|
28
|
+
const { model, system, tools, approval, history, ...libOptions } = options;
|
|
29
|
+
this.name = name;
|
|
30
|
+
this.background = background;
|
|
31
|
+
this.libOptions = libOptions;
|
|
32
|
+
this.system = system;
|
|
33
|
+
this.history = history;
|
|
34
|
+
this.loadModel = modelLoader(name, model);
|
|
35
|
+
if (history)
|
|
36
|
+
checkHistory(name, history);
|
|
37
|
+
// Restate's tools become agentlib's here, so that a mistake fails now: two tools of one
|
|
38
|
+
// name, or an approval of a tool the agent does not have (with no tools at all, too).
|
|
39
|
+
const named = toolsOf(name, tools ?? [], approval);
|
|
40
|
+
if (tools !== undefined)
|
|
41
|
+
this.tools = named;
|
|
42
|
+
}
|
|
43
|
+
/** Answers `text` in the turn of `ctx`'s invocation. */
|
|
44
|
+
async answer(ctx, text) {
|
|
45
|
+
const steering = new Steering();
|
|
46
|
+
steering.saw(await companionAt(ctx).start(await this.started(ctx)));
|
|
47
|
+
const turn = await Turn.start(ctx, text);
|
|
48
|
+
let lib;
|
|
49
|
+
try {
|
|
50
|
+
lib = await this.prepare(ctx, turn);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
await this.end(ctx, turn, UNANSWERED);
|
|
54
|
+
if (error instanceof restate.TerminalError)
|
|
55
|
+
throw error;
|
|
56
|
+
throw new ModelError(`${this.name}: its model: ${String(error)}`);
|
|
57
|
+
}
|
|
58
|
+
let result;
|
|
59
|
+
try {
|
|
60
|
+
result = await execute(ctx, lib.run(text, this.runOptions(ctx, turn, steering)));
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
// Only a terminal error ends the turn. Any other error fails the attempt:
|
|
64
|
+
// Restate retries it, and replays the run from its journal.
|
|
65
|
+
if (!(error instanceof restate.TerminalError))
|
|
66
|
+
throw error;
|
|
67
|
+
await this.end(ctx, turn, noteOf(error));
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
const answer = answerOf(result);
|
|
71
|
+
// A cancellation that comes after the answer does not undo it: the turn still ends.
|
|
72
|
+
await despiteCancellation(() => turn.answered(answer));
|
|
73
|
+
await despiteCancellation(() => companionAt(ctx).close(ctx.request().id));
|
|
74
|
+
return answer;
|
|
75
|
+
}
|
|
76
|
+
/** What the companion learns as the turn starts. */
|
|
77
|
+
async started(ctx) {
|
|
78
|
+
const since = new Date(await ctx.date.now()).toISOString();
|
|
79
|
+
const started = { invocationId: ctx.request().id, since, steers: !this.background };
|
|
80
|
+
// A watched turn's start is its first publish, which returns the
|
|
81
|
+
// messages already steered to it.
|
|
82
|
+
if (!this.background)
|
|
83
|
+
started.publishes = true;
|
|
84
|
+
return started;
|
|
85
|
+
}
|
|
86
|
+
/** Loads the agent (once), and gives the turn what summarizes its conversation. */
|
|
87
|
+
async prepare(ctx, turn) {
|
|
88
|
+
this.loading ??= this.load();
|
|
89
|
+
let loaded;
|
|
90
|
+
try {
|
|
91
|
+
loaded = await this.loading;
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
// The next turn tries again.
|
|
95
|
+
this.loading = undefined;
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
98
|
+
if (this.history !== false) {
|
|
99
|
+
const policy = policyOf(this.history);
|
|
100
|
+
turn.compactor = conversationOf(ctx, { model: loaded.summarizer, policy });
|
|
101
|
+
}
|
|
102
|
+
return loaded.lib;
|
|
103
|
+
}
|
|
104
|
+
/** Loads the model, and makes agentlib's agent with it. */
|
|
105
|
+
async load() {
|
|
106
|
+
const model = refusing(await this.loadModel());
|
|
107
|
+
const options = {
|
|
108
|
+
...this.libOptions,
|
|
109
|
+
name: this.name,
|
|
110
|
+
model,
|
|
111
|
+
onHumanApproval: askForApproval,
|
|
112
|
+
};
|
|
113
|
+
if (this.system !== undefined)
|
|
114
|
+
options.instructions = this.system;
|
|
115
|
+
if (this.tools !== undefined)
|
|
116
|
+
options.tools = this.tools;
|
|
117
|
+
// A summarizer of its own refuses with a 424, as the agent's model does.
|
|
118
|
+
const custom = this.history ? this.history.model : undefined;
|
|
119
|
+
const summarizer = custom ? refusing(custom) : model;
|
|
120
|
+
return { lib: agentlibAgent(options), summarizer };
|
|
121
|
+
}
|
|
122
|
+
/** The options of agentlib's run of the turn. */
|
|
123
|
+
runOptions(ctx, turn, steering) {
|
|
124
|
+
const options = {
|
|
125
|
+
name: this.name,
|
|
126
|
+
context: { ctx },
|
|
127
|
+
conversation: turn,
|
|
128
|
+
onProgress: (event) => this.onProgress(ctx, turn, steering, event),
|
|
129
|
+
};
|
|
130
|
+
if (!this.background)
|
|
131
|
+
options.controls = { steering: steering.source };
|
|
132
|
+
return options;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Records a progress event of the run. A change that clients see is
|
|
136
|
+
* published to the companion, whose answer says which messages are steered
|
|
137
|
+
* to the turn; the run gets them at its next event.
|
|
138
|
+
*/
|
|
139
|
+
*onProgress(ctx, turn, steering, event) {
|
|
140
|
+
yield* recordTaken(ctx, event);
|
|
141
|
+
const changed = turn.progress(event);
|
|
142
|
+
if (!changed || this.background)
|
|
143
|
+
return;
|
|
144
|
+
steering.saw(yield* adopt(companionAt(ctx).publish()));
|
|
145
|
+
yield* steering.hand();
|
|
146
|
+
}
|
|
147
|
+
/** Ends a turn that has no answer, with `note`, at the agent and at its companion. */
|
|
148
|
+
async end(ctx, turn, note) {
|
|
149
|
+
await turn.close(note);
|
|
150
|
+
await companionAt(ctx).close(ctx.request().id);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Waits for the signal `approval` for a tool call that needs one (agentlib's
|
|
155
|
+
* `needsApproval`, its `humanApprovalTool`, a tool's `approve`). `pending`
|
|
156
|
+
* lists the wait, with the tool and its input; `signal` decides it.
|
|
157
|
+
*/
|
|
158
|
+
function* askForApproval(request, { context }) {
|
|
159
|
+
const { call, question } = request;
|
|
160
|
+
const input = { tool: call.name, input: call.input };
|
|
161
|
+
if (question !== undefined)
|
|
162
|
+
input.question = question;
|
|
163
|
+
// A call may ask more than once: agentlib names each ask (`<agent>:approval:<call>:<n>`).
|
|
164
|
+
const value = yield* waitForSignal(context.ctx, request.signalName, 'approval', input);
|
|
165
|
+
return approves(value);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Remembers the steered messages that the run took, so that their own
|
|
169
|
+
* `steered` turns do nothing, and tells the companion.
|
|
170
|
+
*/
|
|
171
|
+
function* recordTaken(ctx, event) {
|
|
172
|
+
const ids = takenIds(event);
|
|
173
|
+
if (ids.length === 0)
|
|
174
|
+
return;
|
|
175
|
+
const taken = (yield* read(ctx, TAKEN)) ?? [];
|
|
176
|
+
ctx.set(TAKEN, [...taken, ...ids]);
|
|
177
|
+
companionSendAt(ctx).taken(ids);
|
|
178
|
+
}
|
|
179
|
+
/** The bounds of the agent's `history`, without its model. */
|
|
180
|
+
function policyOf(history) {
|
|
181
|
+
if (!history)
|
|
182
|
+
return {};
|
|
183
|
+
const { maxMessages, maxChars, retainMessages } = history;
|
|
184
|
+
return { maxMessages, maxChars, retainMessages };
|
|
185
|
+
}
|
|
186
|
+
/** The answer of a run: its output, or else why it stopped. */
|
|
187
|
+
function answerOf(result) {
|
|
188
|
+
if (result.status === 'completed')
|
|
189
|
+
return result.output;
|
|
190
|
+
if (result.output !== undefined)
|
|
191
|
+
return result.output;
|
|
192
|
+
return `Stopped: ${result.reason}`;
|
|
193
|
+
}
|
|
194
|
+
/** The note that says how a turn that failed for good ended. */
|
|
195
|
+
function noteOf(error) {
|
|
196
|
+
if (error instanceof restate.CancelledError)
|
|
197
|
+
return CANCELLED;
|
|
198
|
+
if (error.code === REFUSED)
|
|
199
|
+
return UNANSWERED;
|
|
200
|
+
return `Failed: ${error.message}`;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Runs `step` of a turn that has its answer. Restate delivers a cancellation
|
|
204
|
+
* once: if it interrupts the step, the step runs again.
|
|
205
|
+
*/
|
|
206
|
+
async function despiteCancellation(step) {
|
|
207
|
+
try {
|
|
208
|
+
await step();
|
|
209
|
+
}
|
|
210
|
+
catch (error) {
|
|
211
|
+
if (!(error instanceof restate.CancelledError))
|
|
212
|
+
throw error;
|
|
213
|
+
await step();
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/agentlib/runtime.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,6DAA6D;AAC7D,OAAO,EACL,KAAK,IAAI,aAAa,GAUvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAkB,MAAM,6BAA6B,CAAC;AAChF,OAA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AAC/D,SAAS,QAAQ,CAAI,MAAoB;IACvC,IAAI,MAAM,CAAC,MAAM,KAAK,WAAW;QAAE,OAAO,MAAM,CAAC,MAAM,CAAC;IACxD,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC,MAAM,CAAC;IACtD,OAAO,YAAY,MAAM,CAAC,MAAM,EAAE,CAAC;AACrC,CAAC;AAED,gEAAgE;AAChE,SAAS,MAAM,CAAC,KAA4B;IAC1C,IAAI,KAAK,YAAY,OAAO,CAAC,cAAc;QAAE,OAAO,SAAS,CAAC;IAC9D,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO;QAAE,OAAO,UAAU,CAAC;IAC9C,OAAO,WAAW,KAAK,CAAC,OAAO,EAAE,CAAC;AACpC,CAAC;AAED;;;GAGG;AACH,KAAK,UAAU,mBAAmB,CAAC,IAA4B;IAC7D,IAAI,CAAC;QACH,MAAM,IAAI,EAAE,CAAC;IACf,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,CAAC,KAAK,YAAY,OAAO,CAAC,cAAc,CAAC;YAAE,MAAM,KAAK,CAAC;QAC5D,MAAM,IAAI,EAAE,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { type Future, type Operation } from '@restatedev/restate-sdk-gen';
|
|
2
|
+
import { sdk as restate } from '@restatedev/sessions/internal';
|
|
3
|
+
type Context = restate.ObjectContext | restate.ObjectSharedContext;
|
|
4
|
+
/** The turn being answered: its invocation, its message, and where its messages are. */
|
|
5
|
+
export interface LiveTurn {
|
|
6
|
+
/** The invocation id of the turn. */
|
|
7
|
+
turn: string;
|
|
8
|
+
/** The user's message that started it. */
|
|
9
|
+
prompt: string;
|
|
10
|
+
/** The id of the turn's first message. */
|
|
11
|
+
from: number;
|
|
12
|
+
/** How many messages the turn has so far. */
|
|
13
|
+
n: number;
|
|
14
|
+
}
|
|
15
|
+
/** The bookkeeping of the messages that clients read, kept under {@link META}. */
|
|
16
|
+
export interface Meta {
|
|
17
|
+
/** How many messages the answered turns have: the id the next turn starts at. */
|
|
18
|
+
chats: number;
|
|
19
|
+
/** The cursor of the latest change. Every message written takes the next one. */
|
|
20
|
+
cursor: number;
|
|
21
|
+
/** The id of the first message, once the conversation was cleared. */
|
|
22
|
+
first?: number;
|
|
23
|
+
/** The turn being answered, if any. */
|
|
24
|
+
live?: LiveTurn;
|
|
25
|
+
}
|
|
26
|
+
export declare const META = "meta";
|
|
27
|
+
/** The ids of steered messages that a turn took, so that their own `steered` turn does nothing. */
|
|
28
|
+
export declare const TAKEN = "taken";
|
|
29
|
+
/** The model's conversation (agentlib's `LazyStateConversation`): chunks `t/<n>`, and `t/meta`. */
|
|
30
|
+
export declare const CONVERSATION = "t";
|
|
31
|
+
export declare const CONVERSATION_META = "t/meta";
|
|
32
|
+
/** The key of the message `id`, as clients read it. */
|
|
33
|
+
export declare const entryKey: (id: number) => string;
|
|
34
|
+
export declare const emptyMeta: () => Meta;
|
|
35
|
+
/** Reads state `key` inside an operation of the generator SDK. */
|
|
36
|
+
export declare function read<T>(ctx: restate.ObjectContext, key: string): Future<T | null>;
|
|
37
|
+
/** The agent's companion (`<agent>.prebuilt.restate`), at the agent's key. */
|
|
38
|
+
export declare function companionAt(ctx: Context): restate.Client<{
|
|
39
|
+
wait: (ctx: restate.ObjectSharedContext<import("../companion.ts").State>, input: {
|
|
40
|
+
id: string;
|
|
41
|
+
name: string;
|
|
42
|
+
input?: unknown;
|
|
43
|
+
}) => Promise<unknown>;
|
|
44
|
+
resolve: (ctx: restate.ObjectContext<import("../companion.ts").State>, input: import("../companion.ts").Signal) => Promise<{
|
|
45
|
+
resolved: null;
|
|
46
|
+
} | {
|
|
47
|
+
resolved: string;
|
|
48
|
+
}>;
|
|
49
|
+
pending: (ctx: restate.ObjectSharedContext<import("../companion.ts").State>) => Promise<import("../companion.ts").Waiting[]>;
|
|
50
|
+
listen: (ctx: restate.ObjectContext<import("../companion.ts").State>, input: import("../companion.ts").Waiting & {
|
|
51
|
+
awakeable: string;
|
|
52
|
+
}) => Promise<void>;
|
|
53
|
+
start: (ctx: restate.ObjectContext<import("../companion.ts").State>, input: import("../companion.ts").Started) => Promise<import("../companion.ts").Published | undefined>;
|
|
54
|
+
awaitTurn: (ctx: restate.ObjectSharedContext<import("../companion.ts").State>, input: string) => Promise<void>;
|
|
55
|
+
status: (ctx: restate.ObjectSharedContext<import("../companion.ts").State>) => Promise<import("../object.ts").Status>;
|
|
56
|
+
watch: (ctx: restate.ObjectSharedContext<import("../companion.ts").State>, input: import("../companion.ts").Watch) => Promise<import("../companion.ts").Notifications>;
|
|
57
|
+
close: (ctx: restate.ObjectContext<import("../companion.ts").State>, input: string) => Promise<void>;
|
|
58
|
+
ended: (ctx: restate.ObjectContext<import("../companion.ts").State>, input: string) => Promise<void>;
|
|
59
|
+
reset: (ctx: restate.ObjectContext<import("../companion.ts").State>) => Promise<void>;
|
|
60
|
+
forget: (ctx: restate.ObjectContext<import("../companion.ts").State>, input: string) => Promise<void>;
|
|
61
|
+
publish: (ctx: restate.ObjectContext<import("../companion.ts").State>) => Promise<import("../companion.ts").Published>;
|
|
62
|
+
steer: (ctx: restate.ObjectContext<import("../companion.ts").State>, input: import("../companion.ts").Steer) => Promise<import("../companion.ts").Steered>;
|
|
63
|
+
taken: (ctx: restate.ObjectContext<import("../companion.ts").State>, input: string[]) => Promise<void>;
|
|
64
|
+
notifications: (ctx: restate.ObjectSharedContext<import("../companion.ts").State>) => Promise<import("../companion.ts").Notifications>;
|
|
65
|
+
subscribe: (ctx: restate.ObjectContext<import("../companion.ts").State>, input: {
|
|
66
|
+
revision: number;
|
|
67
|
+
awakeable: string;
|
|
68
|
+
}) => Promise<void>;
|
|
69
|
+
unsubscribe: (ctx: restate.ObjectContext<import("../companion.ts").State>, input: string) => Promise<void>;
|
|
70
|
+
}>;
|
|
71
|
+
/** The agent's companion, for one-way sends. */
|
|
72
|
+
export declare function companionSendAt(ctx: restate.ObjectContext): restate.SendClient<{
|
|
73
|
+
wait: (ctx: restate.ObjectSharedContext<import("../companion.ts").State>, input: {
|
|
74
|
+
id: string;
|
|
75
|
+
name: string;
|
|
76
|
+
input?: unknown;
|
|
77
|
+
}) => Promise<unknown>;
|
|
78
|
+
resolve: (ctx: restate.ObjectContext<import("../companion.ts").State>, input: import("../companion.ts").Signal) => Promise<{
|
|
79
|
+
resolved: null;
|
|
80
|
+
} | {
|
|
81
|
+
resolved: string;
|
|
82
|
+
}>;
|
|
83
|
+
pending: (ctx: restate.ObjectSharedContext<import("../companion.ts").State>) => Promise<import("../companion.ts").Waiting[]>;
|
|
84
|
+
listen: (ctx: restate.ObjectContext<import("../companion.ts").State>, input: import("../companion.ts").Waiting & {
|
|
85
|
+
awakeable: string;
|
|
86
|
+
}) => Promise<void>;
|
|
87
|
+
start: (ctx: restate.ObjectContext<import("../companion.ts").State>, input: import("../companion.ts").Started) => Promise<import("../companion.ts").Published | undefined>;
|
|
88
|
+
awaitTurn: (ctx: restate.ObjectSharedContext<import("../companion.ts").State>, input: string) => Promise<void>;
|
|
89
|
+
status: (ctx: restate.ObjectSharedContext<import("../companion.ts").State>) => Promise<import("../object.ts").Status>;
|
|
90
|
+
watch: (ctx: restate.ObjectSharedContext<import("../companion.ts").State>, input: import("../companion.ts").Watch) => Promise<import("../companion.ts").Notifications>;
|
|
91
|
+
close: (ctx: restate.ObjectContext<import("../companion.ts").State>, input: string) => Promise<void>;
|
|
92
|
+
ended: (ctx: restate.ObjectContext<import("../companion.ts").State>, input: string) => Promise<void>;
|
|
93
|
+
reset: (ctx: restate.ObjectContext<import("../companion.ts").State>) => Promise<void>;
|
|
94
|
+
forget: (ctx: restate.ObjectContext<import("../companion.ts").State>, input: string) => Promise<void>;
|
|
95
|
+
publish: (ctx: restate.ObjectContext<import("../companion.ts").State>) => Promise<import("../companion.ts").Published>;
|
|
96
|
+
steer: (ctx: restate.ObjectContext<import("../companion.ts").State>, input: import("../companion.ts").Steer) => Promise<import("../companion.ts").Steered>;
|
|
97
|
+
taken: (ctx: restate.ObjectContext<import("../companion.ts").State>, input: string[]) => Promise<void>;
|
|
98
|
+
notifications: (ctx: restate.ObjectSharedContext<import("../companion.ts").State>) => Promise<import("../companion.ts").Notifications>;
|
|
99
|
+
subscribe: (ctx: restate.ObjectContext<import("../companion.ts").State>, input: {
|
|
100
|
+
revision: number;
|
|
101
|
+
awakeable: string;
|
|
102
|
+
}) => Promise<void>;
|
|
103
|
+
unsubscribe: (ctx: restate.ObjectContext<import("../companion.ts").State>, input: string) => Promise<void>;
|
|
104
|
+
}>;
|
|
105
|
+
/** Calls one of the agent's own handlers, at its own key, with JSON in and out. */
|
|
106
|
+
export declare function callOwn<T>(ctx: Context, handler: string, input?: unknown): restate.InvocationPromise<T>;
|
|
107
|
+
/**
|
|
108
|
+
* Waits for the signal `name` and returns its value. The wait's id is
|
|
109
|
+
* `<invocation id>:<id>`; `pending` lists it with `input`, and `signal`
|
|
110
|
+
* resolves it.
|
|
111
|
+
*/
|
|
112
|
+
export declare function waitForSignal(ctx: restate.ObjectContext, id: string, name: string, input?: unknown): Operation<unknown>;
|
|
113
|
+
export {};
|
|
114
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/agentlib/state.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,MAAM,EAAE,KAAK,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACpF,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAK/D,KAAK,OAAO,GAAG,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC,mBAAmB,CAAC;AAEnE,wFAAwF;AACxF,MAAM,WAAW,QAAQ;IACvB,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,0CAA0C;IAC1C,I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