Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions packages/agent-core-v2/src/agent/wireRecord/wireRecordService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { relative } from 'pathe';
import { InstantiationType } from '#/_base/di/extensions';
import { Disposable } from '#/_base/di/lifecycle';
import { LifecycleScope, registerScopedService } from '#/_base/di/scope';
import { IBootstrapService } from '#/app/bootstrap/bootstrap';
import { IAgentScopeContext } from '#/agent/scopeContext/scopeContext';
import { IAppendLogStore } from '#/persistence/interface/appendLogStore';
import { IAgentWireService } from '#/wire/tokens';
import type { IWireService } from '#/wire/wireService';
Expand All @@ -29,18 +29,16 @@ export class AgentWireRecordService extends Disposable implements IAgentWireReco
private readonly wireScope: string;

constructor(
options: { readonly homedir?: string } = {},
@IBootstrapService bootstrap: IBootstrapService,
@IAgentScopeContext scopeContext: IAgentScopeContext,
@IAppendLogStore private readonly log?: IAppendLogStore,
@IAgentWireService private readonly wire?: IWireService,
) {
super();
// Each agent scope seeds its own `homedir` (`<homeDir>/sessions/<ws>/<sid>/
// agents/<aid>`); the wire log is the fixed `wire.jsonl` beneath it. The
// `IAppendLogStore` is App-scoped (shared, rooted at `homeDir`), so the
// store `scope` is the homedir made relative to `homeDir` — keeping every
// agent's records in its own file instead of one shared log.
this.wireScope = relative(bootstrap.homeDir, options.homedir ?? bootstrap.homeDir);
// The agent scope carries its persistence scope (`sessions/<ws>/<sid>/
// agents/<aid>`); the wire log is the fixed `wire.jsonl` beneath it —
// the same scope `WireService` appends to, so `restore()` reads back
// what live dispatch wrote.
this.wireScope = scopeContext.scope();
if (this.log !== undefined) {
this._register(this.log.acquire(this.wireScope, WIRE_RECORD_FILENAME));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,10 @@ export class AgentLifecycleService extends Disposable implements IAgentLifecycle
readonly agentScope: string;
readonly mcpManager: McpConnectionManager;
}): ScopeSeed {
const { agentId, agentHomedir, agentScope, mcpManager } = input;
const { agentId, agentScope, mcpManager } = input;
return [
[IAgentScopeContext, makeAgentScopeContext({ agentId, agentScope })],
[IAgentWireRecordService, new SyncDescriptor(AgentWireRecordService, [{ homedir: agentHomedir }])],
[IAgentWireRecordService, new SyncDescriptor(AgentWireRecordService)],
[
IAgentWireService,
new SyncDescriptor(WireService, [
Expand Down
2 changes: 1 addition & 1 deletion packages/agent-core-v2/test/harness/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,7 @@ export class AgentTestContext {
(reg) => {
reg.defineDescriptor(
IAgentWireRecordService,
new SyncDescriptor(AgentWireRecordService, [{}]),
new SyncDescriptor(AgentWireRecordService),
);
reg.defineDescriptor(
IAgentWireService,
Expand Down
Loading