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
29 changes: 14 additions & 15 deletions apps/server/scripts/acp-mock-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -937,21 +937,20 @@ const program = Effect.gen(function* () {
},
});
});
yield* Effect.sleep("1200 millis")
.pipe(
Effect.andThen(
Effect.sync(() => {
writeJsonRpcNotification("_x.ai/task_completed", {
sessionId: cancelledSessionId,
update: {
sessionUpdate: "task_completed",
task_snapshot: { task_id: "task-bg-1", command: "sleep 30" },
},
});
}),
),
)
.pipe(Effect.forkDetach);
yield* Effect.sleep("1200 millis").pipe(
Effect.andThen(
Effect.sync(() => {
writeJsonRpcNotification("_x.ai/task_completed", {
sessionId: cancelledSessionId,
update: {
sessionUpdate: "task_completed",
task_snapshot: { task_id: "task-bg-1", command: "sleep 30" },
},
});
}),
),
Effect.forkDetach,
);
}
}),
);
Expand Down
8 changes: 4 additions & 4 deletions apps/server/src/mcp/toolkits/pullRequests/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,10 @@ const make = Effect.gen(function* () {
if (threadId === undefined) {
return yield* new PullRequestThreadRequiredError();
}
const thread = yield* engine
.getThreadShell(threadId)
.pipe(Effect.map(Option.fromNullishOr))
.pipe(Effect.mapError((cause) => new Failure({ cause })));
const thread = yield* engine.getThreadShell(threadId).pipe(
Effect.map(Option.fromNullishOr),
Effect.mapError((cause) => new Failure({ cause })),
);
if (Option.isNone(thread) || thread.value.deletedAt !== null) {
return yield* new PullRequestThreadNotFoundError({ threadId });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1359,12 +1359,11 @@ describe("ClaudeAdapterV2 resume compaction", () => {
assert.equal(planEvent.value.plan.markdown, longPlan.trim());
}
}
const requestEvent = yield* runtime.events
.pipe(
Stream.filter((event) => event.type === "runtime_request.updated"),
Stream.runHead,
)
.pipe(Effect.forkScoped);
const requestEvent = yield* runtime.events.pipe(
Stream.filter((event) => event.type === "runtime_request.updated"),
Stream.runHead,
Effect.forkScoped,
);
const controller = new AbortController();
const dialog = yield* Effect.promise(() =>
callback!(
Expand Down
43 changes: 21 additions & 22 deletions apps/server/src/orchestration-v2/ThreadManagementService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -724,28 +724,27 @@ const make = Effect.gen(function* () {
fields,
filter,
) =>
ensureProjectionTranscript(input.threadId)
.pipe(Effect.andThen(orchestrator.getThreadRecords(input.threadId, fields, filter)))
.pipe(
Effect.mapError(
(cause) =>
new ThreadManagementProjectionLoadError({
projectId: input.projectId,
threadId: input.threadId,
cause,
}),
),
Effect.flatMap((projection) =>
projection.thread.projectId === input.projectId && projection.thread.deletedAt === null
? Effect.succeed(projection)
: Effect.fail(
new ThreadManagementThreadNotFoundError({
projectId: input.projectId,
threadId: input.threadId,
}),
),
),
);
ensureProjectionTranscript(input.threadId).pipe(
Effect.andThen(orchestrator.getThreadRecords(input.threadId, fields, filter)),
Effect.mapError(
(cause) =>
new ThreadManagementProjectionLoadError({
projectId: input.projectId,
threadId: input.threadId,
cause,
}),
),
Effect.flatMap((projection) =>
projection.thread.projectId === input.projectId && projection.thread.deletedAt === null
? Effect.succeed(projection)
: Effect.fail(
new ThreadManagementThreadNotFoundError({
projectId: input.projectId,
threadId: input.threadId,
}),
),
),
);

const listProjectThreads: ThreadManagementServiceShape["listProjectThreads"] = (input) =>
orchestrator.getShellSnapshot({ projectId: input.projectId, location: "active" }).pipe(
Expand Down
39 changes: 18 additions & 21 deletions apps/server/src/usage/UsageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,30 +623,27 @@ export const make = Effect.gen(function* () {
const scans = Effect.forEach(
scanReaders,
({ driver, reader }) =>
usageInstances(driver, settings)
.pipe(
Effect.flatMap((instances) =>
reader.scan({ instances, settings, windowStartMs, retentionCutoffMs, awaitRefresh }),
),
)
.pipe(
Effect.flatMap((sources) =>
Effect.forEach(sources, ({ volumeId, ...source }) =>
Effect.map(
volumeId === undefined
? Effect.promise(() => readDirectoryVolumeId(source.dir))
: Effect.succeed(volumeId),
(resolved): ScannedDir => ({
...source,
files: source.files?.map((file) => ({ ...file, malformedRecords: 0 })) ?? null,
provider: reader.provider,
volumeId: resolved,
}),
),
usageInstances(driver, settings).pipe(
Effect.flatMap((instances) =>
reader.scan({ instances, settings, windowStartMs, retentionCutoffMs, awaitRefresh }),
),
Effect.flatMap((sources) =>
Effect.forEach(sources, ({ volumeId, ...source }) =>
Effect.map(
volumeId === undefined
? Effect.promise(() => readDirectoryVolumeId(source.dir))
: Effect.succeed(volumeId),
(resolved): ScannedDir => ({
...source,
files: source.files?.map((file) => ({ ...file, malformedRecords: 0 })) ?? null,
provider: reader.provider,
volumeId: resolved,
}),
),
),
Effect.provideContext(readerContext),
),
Effect.provideContext(readerContext),
),
{ concurrency: "unbounded" },
);

Expand Down
1 change: 1 addition & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"namespaceImportPackages": ["@effect/platform-node", "effect"],
"effectFn": ["span", "inferred-span", "suggested-span"],
"diagnosticSeverity": {
"unnecessaryPipeChain": "error",
"effectFnOpportunity": "suggestion",
"anyUnknownInErrorContext": "error",
"unsafeEffectTypeAssertion": "error",
Expand Down
Loading