@rowan-agent/agent 0.19.2 → 0.20.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.d.ts +814 -808
- package/dist/index.js +37 -9
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2680,6 +2680,16 @@ function serializeSkills(skills) {
|
|
|
2680
2680
|
function conversationMessages(messages) {
|
|
2681
2681
|
return messages.flatMap((message) => {
|
|
2682
2682
|
if (message.role === "user") {
|
|
2683
|
+
if (message.contexts && message.contexts.length > 0) {
|
|
2684
|
+
const turnContextText = `<turn_context>
|
|
2685
|
+
${buildContextDescription(message.contexts)}
|
|
2686
|
+
</turn_context>`;
|
|
2687
|
+
const contentParts = [
|
|
2688
|
+
{ type: "text", text: turnContextText },
|
|
2689
|
+
...typeof message.content === "string" ? [{ type: "text", text: message.content }] : message.content
|
|
2690
|
+
];
|
|
2691
|
+
return [{ role: "user", content: contentParts }];
|
|
2692
|
+
}
|
|
2683
2693
|
return [{ role: "user", content: message.content }];
|
|
2684
2694
|
}
|
|
2685
2695
|
if (message.role === "assistant") {
|
|
@@ -2714,6 +2724,7 @@ function buildModelRequest(input, options) {
|
|
|
2714
2724
|
return {
|
|
2715
2725
|
model: options?.model ?? { provider: "", id: "" },
|
|
2716
2726
|
...options?.thinkingLevel === void 0 ? {} : { thinkingLevel: options.thinkingLevel },
|
|
2727
|
+
...options?.providerOptions === void 0 ? {} : { providerOptions: options.providerOptions },
|
|
2717
2728
|
system: systemText,
|
|
2718
2729
|
messages,
|
|
2719
2730
|
tools: modelTools.length > 0 ? modelTools : void 0
|
|
@@ -3721,7 +3732,8 @@ function createPhaseExecution(config, state, phase, messageManager, toolExecutio
|
|
|
3721
3732
|
appendSystemPrompt: phaseContext.appendSystemPrompt
|
|
3722
3733
|
}, {
|
|
3723
3734
|
model: phase.model ?? config.model,
|
|
3724
|
-
...config.thinkingLevel === void 0 ? {} : { thinkingLevel: config.thinkingLevel }
|
|
3735
|
+
...config.thinkingLevel === void 0 ? {} : { thinkingLevel: config.thinkingLevel },
|
|
3736
|
+
...config.providerOptions === void 0 ? {} : { providerOptions: config.providerOptions }
|
|
3725
3737
|
});
|
|
3726
3738
|
if (!request.tools) {
|
|
3727
3739
|
if (phaseContext.tools.length > 0) {
|
|
@@ -4061,6 +4073,7 @@ async function executeOnce(input) {
|
|
|
4061
4073
|
execution: input.execution,
|
|
4062
4074
|
model: input.model,
|
|
4063
4075
|
...input.thinkingLevel === void 0 ? {} : { thinkingLevel: input.thinkingLevel },
|
|
4076
|
+
...input.providerOptions === void 0 ? {} : { providerOptions: input.providerOptions },
|
|
4064
4077
|
stream: input.stream,
|
|
4065
4078
|
maxAttempts: input.maxAttempts,
|
|
4066
4079
|
signal: input.signal,
|
|
@@ -4224,6 +4237,9 @@ var THINKING_LEVELS = [
|
|
|
4224
4237
|
function thinkingLevelFromUserInput(input) {
|
|
4225
4238
|
return typeof input === "string" ? void 0 : input.thinkingLevel;
|
|
4226
4239
|
}
|
|
4240
|
+
function providerOptionsFromUserInput(input) {
|
|
4241
|
+
return typeof input === "string" ? void 0 : input.providerOptions;
|
|
4242
|
+
}
|
|
4227
4243
|
var METADATA_LIMIT = 64 * 1024;
|
|
4228
4244
|
var IDENTITY_LIMIT = 256;
|
|
4229
4245
|
function isRecord3(value) {
|
|
@@ -4278,13 +4294,16 @@ function isAssistantContent(value) {
|
|
|
4278
4294
|
}
|
|
4279
4295
|
function normalizeUserInput(input) {
|
|
4280
4296
|
const normalized = typeof input === "string" ? { content: input } : input;
|
|
4281
|
-
if (!isRecord3(normalized) || !hasOnlyKeys(normalized, ["content", "metadata", "thinkingLevel"]) || !isUserContent(normalized.content)) {
|
|
4297
|
+
if (!isRecord3(normalized) || !hasOnlyKeys(normalized, ["content", "metadata", "thinkingLevel", "providerOptions"]) || !isUserContent(normalized.content)) {
|
|
4282
4298
|
throw new TypeError("input must contain only valid UserContent");
|
|
4283
4299
|
}
|
|
4284
4300
|
if (normalized.metadata !== void 0) assertMetadata(normalized.metadata, "input.metadata");
|
|
4285
4301
|
if (normalized.thinkingLevel !== void 0 && !THINKING_LEVELS.includes(normalized.thinkingLevel)) {
|
|
4286
4302
|
throw new TypeError("input.thinkingLevel must be a valid ThinkingLevel");
|
|
4287
4303
|
}
|
|
4304
|
+
if (normalized.providerOptions !== void 0 && (!isRecord3(normalized.providerOptions) || !isJsonValue(normalized.providerOptions))) {
|
|
4305
|
+
throw new TypeError("input.providerOptions must be a JSON object");
|
|
4306
|
+
}
|
|
4288
4307
|
assertJsonValue(normalized, "input");
|
|
4289
4308
|
return normalized;
|
|
4290
4309
|
}
|
|
@@ -5015,7 +5034,14 @@ function durableInterruptedAssistantContent(content) {
|
|
|
5015
5034
|
function projectMessage(message) {
|
|
5016
5035
|
switch (message.role) {
|
|
5017
5036
|
case "user":
|
|
5018
|
-
return {
|
|
5037
|
+
return {
|
|
5038
|
+
id: message.id,
|
|
5039
|
+
role: message.role,
|
|
5040
|
+
content: projectUserContent(message.content),
|
|
5041
|
+
createdAt: message.createdAt,
|
|
5042
|
+
...message.metadata ? { metadata: message.metadata } : {},
|
|
5043
|
+
...message.contexts && message.contexts.length > 0 ? { contexts: message.contexts } : {}
|
|
5044
|
+
};
|
|
5019
5045
|
case "assistant":
|
|
5020
5046
|
return { id: message.id, role: message.role, content: projectAssistantContent(message.content), createdAt: message.createdAt, ...message.metadata ? { metadata: message.metadata } : {} };
|
|
5021
5047
|
case "tool":
|
|
@@ -5200,10 +5226,7 @@ function resolveDefinitionContext(snapshot, assembled) {
|
|
|
5200
5226
|
selectNamedResources(snapshot.resources.skills, snapshot.definition.skills, "Skill"),
|
|
5201
5227
|
snapshot.definition.bundledSkills
|
|
5202
5228
|
);
|
|
5203
|
-
const contexts =
|
|
5204
|
-
...selectNamedResources(snapshot.contexts, snapshot.definition.contexts, "Context"),
|
|
5205
|
-
...snapshot.additionalContexts
|
|
5206
|
-
];
|
|
5229
|
+
const contexts = selectNamedResources(snapshot.contexts, snapshot.definition.contexts, "Context");
|
|
5207
5230
|
const phaseCandidates = [...snapshot.resources.phases?.phases.values() ?? []];
|
|
5208
5231
|
const corePhases = phaseCandidates.filter((phase) => phase.core);
|
|
5209
5232
|
const authoredPhases = phaseCandidates.filter((phase) => !phase.core);
|
|
@@ -7864,7 +7887,8 @@ var AgentRuntime = class _AgentRuntime {
|
|
|
7864
7887
|
runId: run.id,
|
|
7865
7888
|
expectedRevision: run.revision,
|
|
7866
7889
|
executionId,
|
|
7867
|
-
configToken: token
|
|
7890
|
+
configToken: token,
|
|
7891
|
+
...config.additionalContexts && config.additionalContexts.length > 0 ? { additionalContexts: config.additionalContexts } : {}
|
|
7868
7892
|
});
|
|
7869
7893
|
executionRevision = claim.run.revision;
|
|
7870
7894
|
const controller = new AbortController();
|
|
@@ -7937,6 +7961,7 @@ var AgentRuntime = class _AgentRuntime {
|
|
|
7937
7961
|
},
|
|
7938
7962
|
model,
|
|
7939
7963
|
thinkingLevel: thinkingLevelFromUserInput(run.input),
|
|
7964
|
+
providerOptions: providerOptionsFromUserInput(run.input),
|
|
7940
7965
|
stream,
|
|
7941
7966
|
maxAttempts: config.maxAttempts,
|
|
7942
7967
|
checkpoint: claim.run.checkpoint,
|
|
@@ -10093,7 +10118,8 @@ var InMemoryStore = class _InMemoryStore {
|
|
|
10093
10118
|
input.runId,
|
|
10094
10119
|
input.expectedRevision,
|
|
10095
10120
|
input.messageId ?? null,
|
|
10096
|
-
input.configToken ?? null
|
|
10121
|
+
input.configToken ?? null,
|
|
10122
|
+
input.additionalContexts ?? null
|
|
10097
10123
|
]);
|
|
10098
10124
|
const replay = this.replayOperation(operationKey, operationPayload);
|
|
10099
10125
|
if (replay) return clone(replay);
|
|
@@ -10113,6 +10139,7 @@ var InMemoryStore = class _InMemoryStore {
|
|
|
10113
10139
|
const committedMessages = [];
|
|
10114
10140
|
if (!run.checkpoint && !run.initialMessageId && (!isControlRun(run) || hasUserInput(run.input))) {
|
|
10115
10141
|
const userInput = normalizeUserInput(run.input);
|
|
10142
|
+
const turnContexts = input.additionalContexts ?? [];
|
|
10116
10143
|
const message = {
|
|
10117
10144
|
id: input.messageId ?? createId("msg"),
|
|
10118
10145
|
agentId: run.agentId,
|
|
@@ -10120,6 +10147,7 @@ var InMemoryStore = class _InMemoryStore {
|
|
|
10120
10147
|
role: "user",
|
|
10121
10148
|
content: userInputContent(userInput),
|
|
10122
10149
|
...userInputMetadata(userInput) ? { metadata: clone(userInputMetadata(userInput)) } : {},
|
|
10150
|
+
...turnContexts.length > 0 ? { contexts: clone(turnContexts) } : {},
|
|
10123
10151
|
sequenceWithinRun: this.nextMessageSequence(run.id),
|
|
10124
10152
|
createdAt: createTimestamp()
|
|
10125
10153
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rowan-agent/agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"build": "tsup && bun scripts/check-public-interface.ts"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@rowan-agent/models": "0.
|
|
26
|
+
"@rowan-agent/models": "0.9.0",
|
|
27
27
|
"jiti": "2.7.0",
|
|
28
28
|
"typebox": "^1.0.0",
|
|
29
29
|
"yaml": "^2.7.0"
|