@rowan-agent/agent 0.28.0 → 0.29.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 +1612 -1612
- package/dist/index.js +60 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2235,6 +2235,19 @@ async function loadSkills(targetPath) {
|
|
|
2235
2235
|
var PHASE_MARKER = "PHASE.md";
|
|
2236
2236
|
var SKILL_MARKER2 = "SKILL.md";
|
|
2237
2237
|
var RESOURCE_MARKERS = /* @__PURE__ */ new Set([PHASE_MARKER, SKILL_MARKER2]);
|
|
2238
|
+
var KNOWN_PHASE_KEYS = /* @__PURE__ */ new Set([
|
|
2239
|
+
"name",
|
|
2240
|
+
"description",
|
|
2241
|
+
"target",
|
|
2242
|
+
"input",
|
|
2243
|
+
"prompt-guidelines",
|
|
2244
|
+
"tools",
|
|
2245
|
+
"model",
|
|
2246
|
+
"isolated",
|
|
2247
|
+
"disable-auto-invocation",
|
|
2248
|
+
"disable-implicit-invocation",
|
|
2249
|
+
"skills"
|
|
2250
|
+
]);
|
|
2238
2251
|
function resolvePhasePath(input) {
|
|
2239
2252
|
const resolved = resolve4(input);
|
|
2240
2253
|
return existsSync2(resolved) && statSync2(resolved).isDirectory() ? join2(resolved, PHASE_MARKER) : resolved;
|
|
@@ -2274,6 +2287,15 @@ async function loadPhase(targetPath) {
|
|
|
2274
2287
|
}
|
|
2275
2288
|
diagnostics.push(...description.warnings);
|
|
2276
2289
|
diagnostics.push(...validatePhaseTarget(metadata.target));
|
|
2290
|
+
const extraMetadata = {};
|
|
2291
|
+
for (const [key, value] of Object.entries(metadata)) {
|
|
2292
|
+
if (KNOWN_PHASE_KEYS.has(key)) continue;
|
|
2293
|
+
if (isJsonValue(value)) {
|
|
2294
|
+
extraMetadata[key] = value;
|
|
2295
|
+
} else {
|
|
2296
|
+
diagnostics.push(`metadata key "${key}" must be a JSON-safe value`);
|
|
2297
|
+
}
|
|
2298
|
+
}
|
|
2277
2299
|
warnResourceDiagnostics("phase", resolved, diagnostics);
|
|
2278
2300
|
const baseDir = dirname4(resolved);
|
|
2279
2301
|
const skills = await loadPhaseSkills(baseDir);
|
|
@@ -2299,7 +2321,8 @@ async function loadPhase(targetPath) {
|
|
|
2299
2321
|
content: definition.prompt,
|
|
2300
2322
|
model: definition.model,
|
|
2301
2323
|
disableAutoInvocation: metadata["disable-auto-invocation"] === true,
|
|
2302
|
-
disableImplicitInvocation: metadata["disable-implicit-invocation"] === true
|
|
2324
|
+
disableImplicitInvocation: metadata["disable-implicit-invocation"] === true,
|
|
2325
|
+
...Object.keys(extraMetadata).length > 0 ? { metadata: Object.freeze(extraMetadata) } : {}
|
|
2303
2326
|
};
|
|
2304
2327
|
const codePath = await discoverPhaseCode(baseDir);
|
|
2305
2328
|
if (codePath) {
|
|
@@ -3706,7 +3729,8 @@ async function executeToolCall(input) {
|
|
|
3706
3729
|
contentBlocks: input.contentBlocks,
|
|
3707
3730
|
driver: input.driver,
|
|
3708
3731
|
options: input.options,
|
|
3709
|
-
...input.providerInitiated ? { providerInitiated: true } : {}
|
|
3732
|
+
...input.providerInitiated ? { providerInitiated: true } : {},
|
|
3733
|
+
...input.phase !== void 0 ? { phase: input.phase } : {}
|
|
3710
3734
|
});
|
|
3711
3735
|
} else {
|
|
3712
3736
|
const toolContext = {
|
|
@@ -3736,7 +3760,8 @@ async function executeToolCalls(input) {
|
|
|
3736
3760
|
contentBlocks: input.contentBlocks,
|
|
3737
3761
|
driver: input.driver,
|
|
3738
3762
|
model: input.model,
|
|
3739
|
-
usage: input.usage
|
|
3763
|
+
usage: input.usage,
|
|
3764
|
+
...input.phase !== void 0 ? { phase: input.phase } : {}
|
|
3740
3765
|
});
|
|
3741
3766
|
if (results2.length !== input.toolCalls.length) throw new Error("Runtime returned an invalid Tool batch result");
|
|
3742
3767
|
return results2.map((result, index) => ({
|
|
@@ -3752,6 +3777,10 @@ async function executeToolCalls(input) {
|
|
|
3752
3777
|
return results;
|
|
3753
3778
|
}
|
|
3754
3779
|
function createPhaseExecution(config, state, phase, messageManager, toolExecutionManager, registry) {
|
|
3780
|
+
const phaseInfo = Object.freeze({
|
|
3781
|
+
name: phase.name,
|
|
3782
|
+
...phase.metadata !== void 0 ? { metadata: phase.metadata } : {}
|
|
3783
|
+
});
|
|
3755
3784
|
const interaction = createRunInteractionDriver(state, phase.name, config.signal);
|
|
3756
3785
|
const executePhaseTool = async (phaseContext, toolCall, options, providerInitiated = false) => {
|
|
3757
3786
|
return runTurn(async () => {
|
|
@@ -3770,7 +3799,8 @@ function createPhaseExecution(config, state, phase, messageManager, toolExecutio
|
|
|
3770
3799
|
toolCall,
|
|
3771
3800
|
driver: interaction,
|
|
3772
3801
|
options,
|
|
3773
|
-
providerInitiated
|
|
3802
|
+
providerInitiated,
|
|
3803
|
+
phase: phaseInfo
|
|
3774
3804
|
});
|
|
3775
3805
|
await toolExecutionManager.end(result.toolCallId, result.toolName, result, !result.ok);
|
|
3776
3806
|
return result;
|
|
@@ -3900,7 +3930,8 @@ function createPhaseExecution(config, state, phase, messageManager, toolExecutio
|
|
|
3900
3930
|
contentBlocks,
|
|
3901
3931
|
driver: interaction,
|
|
3902
3932
|
model: meta?.model,
|
|
3903
|
-
usage: meta?.usage
|
|
3933
|
+
usage: meta?.usage,
|
|
3934
|
+
phase: phaseInfo
|
|
3904
3935
|
});
|
|
3905
3936
|
for (const result of results) {
|
|
3906
3937
|
await toolExecutionManager.end(result.toolCallId, result.toolName, result, !result.ok);
|
|
@@ -4684,7 +4715,8 @@ function snapshotPhase(phase) {
|
|
|
4684
4715
|
...phase.promptGuidelines ? { promptGuidelines: Object.freeze([...phase.promptGuidelines]) } : {},
|
|
4685
4716
|
skills: Object.freeze((phase.skills ?? []).map((skill) => Object.freeze({ ...skill }))),
|
|
4686
4717
|
...phase.input ? { input: Object.freeze({ ...phase.input }) } : {},
|
|
4687
|
-
...phase.model ? { model: Object.freeze({ ...phase.model }) } : {}
|
|
4718
|
+
...phase.model ? { model: Object.freeze({ ...phase.model }) } : {},
|
|
4719
|
+
...phase.metadata ? { metadata: Object.freeze({ ...phase.metadata }) } : {}
|
|
4688
4720
|
});
|
|
4689
4721
|
}
|
|
4690
4722
|
function snapshotConfiguration(config) {
|
|
@@ -5250,7 +5282,8 @@ function assembleRegisteredExtensions(snapshot, runner, options = {}) {
|
|
|
5250
5282
|
...input.context.agentMetadata === void 0 ? {} : { agentMetadata: input.context.agentMetadata },
|
|
5251
5283
|
answer: input.answer,
|
|
5252
5284
|
scope: input.context.scope,
|
|
5253
|
-
turn: input.context.turn
|
|
5285
|
+
turn: input.context.turn,
|
|
5286
|
+
...input.context.phase === void 0 ? {} : { phase: input.context.phase }
|
|
5254
5287
|
});
|
|
5255
5288
|
if (decision.interaction !== void 0) {
|
|
5256
5289
|
return { interaction: decision.interaction };
|
|
@@ -5268,7 +5301,8 @@ function assembleRegisteredExtensions(snapshot, runner, options = {}) {
|
|
|
5268
5301
|
toolCallId: input.context.toolCallId,
|
|
5269
5302
|
metadata: input.context.runMetadata,
|
|
5270
5303
|
scope: input.context.scope,
|
|
5271
|
-
turn: input.context.turn
|
|
5304
|
+
turn: input.context.turn,
|
|
5305
|
+
...input.context.phase === void 0 ? {} : { phase: input.context.phase }
|
|
5272
5306
|
}
|
|
5273
5307
|
);
|
|
5274
5308
|
return fromLoopResult(result);
|
|
@@ -8595,7 +8629,8 @@ var ExtensionRunner = class {
|
|
|
8595
8629
|
...context?.agentMetadata !== void 0 ? { agentMetadata: context.agentMetadata } : {},
|
|
8596
8630
|
...context?.answer !== void 0 ? { answer: context.answer } : {},
|
|
8597
8631
|
scope,
|
|
8598
|
-
turn
|
|
8632
|
+
turn,
|
|
8633
|
+
...context?.phase !== void 0 ? { phase: context.phase } : {}
|
|
8599
8634
|
});
|
|
8600
8635
|
return result ?? { allow: true };
|
|
8601
8636
|
}
|
|
@@ -8611,7 +8646,8 @@ var ExtensionRunner = class {
|
|
|
8611
8646
|
...context?.toolCallId !== void 0 ? { toolCallId: context.toolCallId } : {},
|
|
8612
8647
|
...context?.metadata !== void 0 ? { metadata: context.metadata } : {},
|
|
8613
8648
|
scope,
|
|
8614
|
-
turn
|
|
8649
|
+
turn,
|
|
8650
|
+
...context?.phase !== void 0 ? { phase: context.phase } : {}
|
|
8615
8651
|
});
|
|
8616
8652
|
return hookResult?.result ?? result;
|
|
8617
8653
|
}
|
|
@@ -9381,7 +9417,8 @@ function snapshotResourceValue(kind, value) {
|
|
|
9381
9417
|
...phase.promptGuidelines ? { promptGuidelines: Object.freeze([...phase.promptGuidelines]) } : {},
|
|
9382
9418
|
skills: Object.freeze((phase.skills ?? []).map((skill) => Object.freeze({ ...skill }))),
|
|
9383
9419
|
...phase.input ? { input: Object.freeze({ ...phase.input }) } : {},
|
|
9384
|
-
...phase.model ? { model: Object.freeze({ ...phase.model }) } : {}
|
|
9420
|
+
...phase.model ? { model: Object.freeze({ ...phase.model }) } : {},
|
|
9421
|
+
...phase.metadata ? { metadata: Object.freeze({ ...phase.metadata }) } : {}
|
|
9385
9422
|
};
|
|
9386
9423
|
return Object.freeze(snapshot);
|
|
9387
9424
|
}
|
|
@@ -10626,7 +10663,7 @@ var AgentRuntime = class _AgentRuntime {
|
|
|
10626
10663
|
onContext: assembly.setContext,
|
|
10627
10664
|
runtime: {
|
|
10628
10665
|
interact: (request) => this.liveInteract(run.id, request, controller.signal),
|
|
10629
|
-
tools: ({ toolCall, contentBlocks, driver, options, providerInitiated, model: callModel, usage: callUsage }) => {
|
|
10666
|
+
tools: ({ toolCall, contentBlocks, driver, options, providerInitiated, model: callModel, usage: callUsage, phase: callPhase }) => {
|
|
10630
10667
|
const task = toolQueue.then(async () => {
|
|
10631
10668
|
if (!providerInitiated) {
|
|
10632
10669
|
const execution = await this.executeToolBatch({
|
|
@@ -10642,6 +10679,7 @@ var AgentRuntime = class _AgentRuntime {
|
|
|
10642
10679
|
options,
|
|
10643
10680
|
model: callModel ?? model,
|
|
10644
10681
|
usage: callUsage,
|
|
10682
|
+
phase: callPhase,
|
|
10645
10683
|
onRevision: (rev) => {
|
|
10646
10684
|
executionRevision = rev;
|
|
10647
10685
|
}
|
|
@@ -10668,6 +10706,7 @@ var AgentRuntime = class _AgentRuntime {
|
|
|
10668
10706
|
interactionIds,
|
|
10669
10707
|
model: callModel ?? model,
|
|
10670
10708
|
usage: callUsage,
|
|
10709
|
+
phase: callPhase,
|
|
10671
10710
|
onRevision: (rev) => {
|
|
10672
10711
|
executionRevision = rev;
|
|
10673
10712
|
}
|
|
@@ -10758,7 +10797,7 @@ var AgentRuntime = class _AgentRuntime {
|
|
|
10758
10797
|
toolQueue = task.then(() => void 0, () => void 0);
|
|
10759
10798
|
return task;
|
|
10760
10799
|
},
|
|
10761
|
-
toolsBatch: ({ toolCalls, contentBlocks, driver, options, model: batchModel, usage: batchUsage }) => {
|
|
10800
|
+
toolsBatch: ({ toolCalls, contentBlocks, driver, options, model: batchModel, usage: batchUsage, phase: batchPhase }) => {
|
|
10762
10801
|
const task = toolQueue.then(async () => {
|
|
10763
10802
|
const execution = await this.executeToolBatch({
|
|
10764
10803
|
run,
|
|
@@ -10773,6 +10812,7 @@ var AgentRuntime = class _AgentRuntime {
|
|
|
10773
10812
|
options,
|
|
10774
10813
|
model: batchModel ?? model,
|
|
10775
10814
|
usage: batchUsage,
|
|
10815
|
+
phase: batchPhase,
|
|
10776
10816
|
onRevision: (rev) => {
|
|
10777
10817
|
executionRevision = rev;
|
|
10778
10818
|
}
|
|
@@ -10962,6 +11002,7 @@ var AgentRuntime = class _AgentRuntime {
|
|
|
10962
11002
|
scope,
|
|
10963
11003
|
...cwd ? { cwd } : {},
|
|
10964
11004
|
turn,
|
|
11005
|
+
...input.phase === void 0 ? {} : { phase: input.phase },
|
|
10965
11006
|
interaction: createRunInteractionDriver({
|
|
10966
11007
|
currentPhase: "default",
|
|
10967
11008
|
attempt: 0,
|
|
@@ -11102,7 +11143,8 @@ var AgentRuntime = class _AgentRuntime {
|
|
|
11102
11143
|
signal: input.signal,
|
|
11103
11144
|
afterToolCall: input.toolConfig.afterToolCall,
|
|
11104
11145
|
currentToolState,
|
|
11105
|
-
options: input.options
|
|
11146
|
+
options: input.options,
|
|
11147
|
+
...input.phase === void 0 ? {} : { phase: input.phase }
|
|
11106
11148
|
});
|
|
11107
11149
|
results2.push(toolResult2);
|
|
11108
11150
|
}
|
|
@@ -11210,6 +11252,7 @@ var AgentRuntime = class _AgentRuntime {
|
|
|
11210
11252
|
scope,
|
|
11211
11253
|
...cwd ? { cwd } : {},
|
|
11212
11254
|
turn,
|
|
11255
|
+
...input.phase === void 0 ? {} : { phase: input.phase },
|
|
11213
11256
|
interaction: interactionDriver,
|
|
11214
11257
|
reportProgress: () => {
|
|
11215
11258
|
}
|
|
@@ -11422,7 +11465,8 @@ var AgentRuntime = class _AgentRuntime {
|
|
|
11422
11465
|
afterToolCall: input.toolConfig.afterToolCall,
|
|
11423
11466
|
currentToolState,
|
|
11424
11467
|
options: input.options,
|
|
11425
|
-
providerInitiated: input.providerInitiated
|
|
11468
|
+
providerInitiated: input.providerInitiated,
|
|
11469
|
+
...input.phase === void 0 ? {} : { phase: input.phase }
|
|
11426
11470
|
});
|
|
11427
11471
|
results.push(toolResult2);
|
|
11428
11472
|
}
|
|
@@ -11473,6 +11517,7 @@ var AgentRuntime = class _AgentRuntime {
|
|
|
11473
11517
|
scope: input.scope,
|
|
11474
11518
|
...input.cwd ? { cwd: input.cwd } : {},
|
|
11475
11519
|
turn: input.turn,
|
|
11520
|
+
...input.phase === void 0 ? {} : { phase: input.phase },
|
|
11476
11521
|
interaction: interactionDriver,
|
|
11477
11522
|
reportProgress: (progress) => {
|
|
11478
11523
|
const active = this.executions.get(input.runId);
|