GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(server): dev servers a Codex agent starts show under its thread (… · pingdotgg/t3code@b7add5a

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/server/src/orchestration-v2/Adapters
    • CodexAdapterV2.test.ts
    • CodexAdapterV2.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts
+61Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ import * as ProviderReplayHarness from "../testkit/ProviderReplayHarness.ts";
7171
import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
7272
import type * as ProviderContinuationRequests from "@t3tools/provider-core/server/ProviderContinuationRequests";
7373
import * as ModelManifest from "../../provider/ModelManifest.ts";
74+
import * as PortScanner from "../../preview/PortScanner.ts";
7475
import { resolveProviderCompatibility } from "../../provider/providerCompatibility.ts";
7576
import * as CodexAdapterV2 from "./CodexAdapterV2.ts";
7677
import { withCodexReplayChildMetadata } from "./CodexAdapterV2.testkit.ts";
@@ -886,6 +887,66 @@ describe("CodexAdapterV2 process exit", () => {
886887
),
887888
),
888889
);
890+
891+
it.effect("counts the app-server as a running agent until its session closes", () => {
892+
let runningAgents = 0;
893+
const factoryLayer = CodexAdapterV2.layerAppServerClientFactory.pipe(
894+
Layer.provide(
895+
Layer.mock(PortScanner.PortDiscovery)({
896+
trackAgent: () => {
897+
runningAgents += 1;
898+
return () => {
899+
runningAgents -= 1;
900+
};
901+
},
902+
}),
903+
),
904+
Layer.provide(
905+
Layer.succeed(ProviderEventLoggers.ProviderEventLoggers, {
906+
native: undefined,
907+
canonical: undefined,
908+
}),
909+
),
910+
Layer.provide(
911+
Layer.succeed(
912+
ChildProcessSpawner.ChildProcessSpawner,
913+
ChildProcessSpawner.make(() =>
914+
Effect.succeed(
915+
ChildProcessSpawner.makeHandle({
916+
pid: ChildProcessSpawner.ProcessId(999_999_999),
917+
exitCode: Effect.never,
918+
isRunning: Effect.succeed(true),
919+
kill: () => Effect.void,
920+
unref: Effect.succeed(Effect.void),
921+
stdin: Sink.drain,
922+
stdout: Stream.never,
923+
stderr: Stream.empty,
924+
all: Stream.empty,
925+
getInputFd: () => Sink.drain,
926+
getOutputFd: () => Stream.empty,
927+
}),
928+
),
929+
),
930+
),
931+
),
932+
);
933+
return Effect.gen(function* () {
934+
const factory = yield* CodexAdapterV2.CodexAppServerClientFactory;
935+
yield* Effect.scoped(
936+
factory
937+
.open({
938+
instanceId: CodexAdapterV2.CODEX_DEFAULT_INSTANCE_ID,
939+
threadId: ThreadId.make("thread-codex-agent"),
940+
providerSessionId: ProviderSessionId.make("session-codex-agent"),
941+
runtimePolicy: CODEX_TEST_RUNTIME_POLICY,
942+
settings: DEFAULT_CODEX_SETTINGS,
943+
environment: {},
944+
})
945+
.pipe(Effect.tap(() => Effect.sync(() => assert.equal(runningAgents, 1)))),
946+
);
947+
assert.equal(runningAgents, 0);
948+
}).pipe(Effect.provide(factoryLayer));
949+
});
889950
});
890951

891952
describe("CodexAdapterV2 session initialize", () => {
Collapse file

‎apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1557,13 +1557,16 @@ function isSensitiveCodexProtocolKey(key: string): boolean {
15571557
export const layerAppServerClientFactory: Layer.Layer<
15581558
CodexAppServerClientFactory,
15591559
never,
1560-
ChildProcessSpawner.ChildProcessSpawner | ProviderEventLoggers.ProviderEventLoggers
1560+
| ChildProcessSpawner.ChildProcessSpawner
1561+
| PortScanner.PortDiscovery
1562+
| ProviderEventLoggers.ProviderEventLoggers
15611563
> = Layer.effect(
15621564
CodexAppServerClientFactory,
15631565
Effect.gen(function* () {
15641566
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
15651567
const { native: nativeEventLogger } = yield* ProviderEventLoggers.ProviderEventLoggers;
15661568
const agentScope = yield* AgentScope;
1569+
const portDiscovery = yield* PortScanner.PortDiscovery;
15671570

15681571
return CodexAppServerClientFactory.of({
15691572
open: Effect.fn("CodexAdapterV2.open")(function* (input) {
@@ -1591,6 +1594,10 @@ export const layerAppServerClientFactory: Layer.Layer<
15911594
}),
15921595
),
15931596
);
1597+
// Its shells carry each thread's T3CODE_THREAD_ID, so port discovery reads listeners' threads.
1598+
yield* Effect.acquireRelease(Effect.sync(portDiscovery.trackAgent), (release) =>
1599+
Effect.sync(release),
1600+
);
15941601
const protocolLogger = makeCodexAppServerProtocolLogger({
15951602
nativeEventLogger,
15961603
threadId: input.threadId,

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.