@rowan-agent/agent 0.9.17 → 0.9.19
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 +1 -4
- package/dist/index.js +15 -40
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1610,7 +1610,7 @@ type AgentConfig = Readonly<{
|
|
|
1610
1610
|
identity: string;
|
|
1611
1611
|
definition: AgentDefinition;
|
|
1612
1612
|
resources: AgentResources;
|
|
1613
|
-
/** Host-owned Contexts
|
|
1613
|
+
/** Host-owned Contexts rendered in the System Prompt with the selected Contexts. */
|
|
1614
1614
|
additionalContexts?: readonly ContextCandidate[];
|
|
1615
1615
|
cwd?: string;
|
|
1616
1616
|
maxAttempts?: number;
|
|
@@ -1876,7 +1876,6 @@ interface OwnedStore {
|
|
|
1876
1876
|
executionId?: ExecutionId;
|
|
1877
1877
|
messageId?: MessageId;
|
|
1878
1878
|
configToken?: ConfigToken;
|
|
1879
|
-
inputContext?: UserInput;
|
|
1880
1879
|
}): Promise<RunClaim>;
|
|
1881
1880
|
failQueuedRun(input: {
|
|
1882
1881
|
runId: RunId;
|
|
@@ -2291,7 +2290,6 @@ declare class InMemoryStore implements DurableStore {
|
|
|
2291
2290
|
executionId?: ExecutionId;
|
|
2292
2291
|
messageId?: MessageId;
|
|
2293
2292
|
configToken?: ConfigToken;
|
|
2294
|
-
inputContext?: UserInput;
|
|
2295
2293
|
}): RunClaim;
|
|
2296
2294
|
failQueuedRun(lease: OwnerLease, input: {
|
|
2297
2295
|
runId: RunId;
|
|
@@ -2475,7 +2473,6 @@ declare class SqliteStore implements DurableStore {
|
|
|
2475
2473
|
executionId?: ExecutionId;
|
|
2476
2474
|
messageId?: MessageId;
|
|
2477
2475
|
configToken?: ConfigToken;
|
|
2478
|
-
inputContext?: UserInput;
|
|
2479
2476
|
}): Promise<RunClaim>;
|
|
2480
2477
|
failQueuedRun(lease: OwnerLease, input: {
|
|
2481
2478
|
runId: RunId;
|
package/dist/index.js
CHANGED
|
@@ -46,9 +46,6 @@ function buildContextDescription(contexts) {
|
|
|
46
46
|
lines.push("</agent_context>");
|
|
47
47
|
return lines.join("\n");
|
|
48
48
|
}
|
|
49
|
-
function buildAdditionalContextMessage(contexts) {
|
|
50
|
-
return buildContextDescription(contexts);
|
|
51
|
-
}
|
|
52
49
|
function formatResourceOutput(resource) {
|
|
53
50
|
const parts = [`<${resource.type} name="${escapeXml(resource.name)}" location="${escapeXml(resource.location)}">`];
|
|
54
51
|
if (resource.baseDir) {
|
|
@@ -1864,7 +1861,10 @@ async function loadPhaseCode(codePath) {
|
|
|
1864
1861
|
const jiti = createJiti2(import.meta.url, {
|
|
1865
1862
|
fsCache: false,
|
|
1866
1863
|
moduleCache: false,
|
|
1867
|
-
|
|
1864
|
+
// Phase code ships as authored, including TypeScript. Native loading lets a
|
|
1865
|
+
// host that supports it run that code without a transpile step, and jiti
|
|
1866
|
+
// still transforms whatever the host cannot load itself.
|
|
1867
|
+
tryNative: true
|
|
1868
1868
|
});
|
|
1869
1869
|
const mod = await jiti.import(codePath);
|
|
1870
1870
|
const namespace = mod && typeof mod === "object" ? mod : {};
|
|
@@ -3426,7 +3426,6 @@ function isContinuation(value) {
|
|
|
3426
3426
|
}
|
|
3427
3427
|
|
|
3428
3428
|
// src/runtime/contracts.ts
|
|
3429
|
-
var HOST_CONTEXT_MESSAGE_KIND = "host_context";
|
|
3430
3429
|
var THINKING_LEVELS = [
|
|
3431
3430
|
"off",
|
|
3432
3431
|
"minimal",
|
|
@@ -3449,7 +3448,7 @@ function thinkingLevelFromMessages(messages) {
|
|
|
3449
3448
|
if (message?.role !== "user") continue;
|
|
3450
3449
|
const metadata = message.metadata;
|
|
3451
3450
|
const kind = isRecord3(metadata) && typeof metadata.kind === "string" ? metadata.kind : void 0;
|
|
3452
|
-
if (kind === "phase_prompt" || kind === "phase_input"
|
|
3451
|
+
if (kind === "phase_prompt" || kind === "phase_input") continue;
|
|
3453
3452
|
return thinkingLevelFromMetadata(metadata);
|
|
3454
3453
|
}
|
|
3455
3454
|
return void 0;
|
|
@@ -3503,9 +3502,6 @@ function normalizeUserInput(input) {
|
|
|
3503
3502
|
assertJsonValue(normalized, "input");
|
|
3504
3503
|
return normalized;
|
|
3505
3504
|
}
|
|
3506
|
-
function canonicalUserInput(input) {
|
|
3507
|
-
return canonicalJson(normalizeUserInput(input));
|
|
3508
|
-
}
|
|
3509
3505
|
function isAssistantMessage(value) {
|
|
3510
3506
|
return isRecord3(value) && hasOnlyKeys(value, ["id", "agentId", "runId", "messageRevision", "role", "content", "metadata", "sequenceWithinRun", "createdAt", "interrupted"]) && typeof value.id === "string" && typeof value.agentId === "string" && typeof value.runId === "string" && value.role === "assistant" && (value.messageRevision === void 0 || Number.isInteger(value.messageRevision) && value.messageRevision >= 0) && Number.isInteger(value.sequenceWithinRun) && value.sequenceWithinRun >= 0 && typeof value.createdAt === "string" && isAssistantContent(value.content) && (value.metadata === void 0 || isMetadata(value.metadata)) && (value.interrupted === void 0 || typeof value.interrupted === "boolean");
|
|
3511
3507
|
}
|
|
@@ -4186,11 +4182,14 @@ function resolveDefinitionContext(config, assembled = {}) {
|
|
|
4186
4182
|
selectNamedResources(config.resources.skills, config.definition.skills, "Skill"),
|
|
4187
4183
|
config.definition.bundledSkills
|
|
4188
4184
|
);
|
|
4189
|
-
const contexts =
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4185
|
+
const contexts = [
|
|
4186
|
+
...selectNamedResources(
|
|
4187
|
+
config.resources.contexts ?? [],
|
|
4188
|
+
config.definition.contexts,
|
|
4189
|
+
"Context"
|
|
4190
|
+
),
|
|
4191
|
+
...config.additionalContexts ?? []
|
|
4192
|
+
];
|
|
4194
4193
|
const candidateRegistry = assembled.phases ?? config.resources.phases;
|
|
4195
4194
|
const phaseCandidates = [...candidateRegistry?.phases.values() ?? []];
|
|
4196
4195
|
const coreNames = /* @__PURE__ */ new Set([DEFAULT_PHASE_ID, STOP_PHASE_ID, COMPACT_PHASE_ID]);
|
|
@@ -6201,8 +6200,7 @@ var AgentRuntime = class _AgentRuntime {
|
|
|
6201
6200
|
runId: run.id,
|
|
6202
6201
|
expectedRevision: run.revision,
|
|
6203
6202
|
executionId,
|
|
6204
|
-
configToken: token
|
|
6205
|
-
...controlKind ? {} : { inputContext: additionalContextInput(config) }
|
|
6203
|
+
configToken: token
|
|
6206
6204
|
});
|
|
6207
6205
|
executionRevision = claim.run.revision;
|
|
6208
6206
|
const controller = new AbortController();
|
|
@@ -6672,12 +6670,6 @@ var AgentRuntime = class _AgentRuntime {
|
|
|
6672
6670
|
this.heartbeat.unref?.();
|
|
6673
6671
|
}
|
|
6674
6672
|
};
|
|
6675
|
-
function additionalContextInput(config) {
|
|
6676
|
-
const contexts = config.additionalContexts ?? [];
|
|
6677
|
-
if (contexts.length === 0) return void 0;
|
|
6678
|
-
const content = buildAdditionalContextMessage(contexts);
|
|
6679
|
-
return content.length === 0 ? void 0 : { content, metadata: { kind: HOST_CONTEXT_MESSAGE_KIND } };
|
|
6680
|
-
}
|
|
6681
6673
|
var DurableRun = class {
|
|
6682
6674
|
constructor(runtime, id) {
|
|
6683
6675
|
this.runtime = runtime;
|
|
@@ -7226,13 +7218,11 @@ var InMemoryStore = class _InMemoryStore {
|
|
|
7226
7218
|
this.assertOwner(lease);
|
|
7227
7219
|
const executionId = input.executionId ?? createId("exec");
|
|
7228
7220
|
const operationKey = `claim:${executionId}`;
|
|
7229
|
-
const inputContext = input.inputContext === void 0 ? void 0 : normalizeUserInput(input.inputContext);
|
|
7230
7221
|
const operationPayload = canonicalJson([
|
|
7231
7222
|
input.runId,
|
|
7232
7223
|
input.expectedRevision,
|
|
7233
7224
|
input.messageId ?? null,
|
|
7234
|
-
input.configToken ?? null
|
|
7235
|
-
inputContext ?? null
|
|
7225
|
+
input.configToken ?? null
|
|
7236
7226
|
]);
|
|
7237
7227
|
const replay = this.replayOperation(operationKey, operationPayload);
|
|
7238
7228
|
if (replay) return clone(replay);
|
|
@@ -7250,21 +7240,6 @@ var InMemoryStore = class _InMemoryStore {
|
|
|
7250
7240
|
}
|
|
7251
7241
|
if (!run.pinnedConfigToken && input.configToken) run.pinnedConfigToken = input.configToken;
|
|
7252
7242
|
const committedMessages = [];
|
|
7253
|
-
const existingMessages = this.messagesForRun(run.id);
|
|
7254
|
-
if (inputContext && hasUserInput(inputContext) && !isControlRun(run) && !existingMessages.some((message) => message.role === "user" && message.metadata?.kind === HOST_CONTEXT_MESSAGE_KIND && canonicalUserInput({ content: message.content, metadata: message.metadata }) === canonicalUserInput(inputContext))) {
|
|
7255
|
-
const contextMessage = {
|
|
7256
|
-
id: createId("msg"),
|
|
7257
|
-
agentId: run.agentId,
|
|
7258
|
-
runId: run.id,
|
|
7259
|
-
role: "user",
|
|
7260
|
-
content: userInputContent(inputContext),
|
|
7261
|
-
...userInputMetadata(inputContext) ? { metadata: clone(userInputMetadata(inputContext)) } : {},
|
|
7262
|
-
sequenceWithinRun: this.nextMessageSequence(run.id),
|
|
7263
|
-
createdAt: createTimestamp()
|
|
7264
|
-
};
|
|
7265
|
-
this.messages.set(contextMessage.id, contextMessage);
|
|
7266
|
-
committedMessages.push(contextMessage);
|
|
7267
|
-
}
|
|
7268
7243
|
if (!run.checkpoint && !run.initialMessageId && (!isControlRun(run) || hasUserInput(run.input))) {
|
|
7269
7244
|
const userInput = normalizeUserInput(run.input);
|
|
7270
7245
|
const message = {
|