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 — feat(server): initialize native task threads (#11) · tomcorke/t3code@3712da5

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/server/src
    • mcp
      • McpToolAccess.testkit.ts
      • OrchestratorMcpService.ts
      • toolkits/project
        • handlers.ts
        • tools.ts
    • orchestration-v2
      • Orchestrator.ts
      • ProjectionStore.ts
      • ThreadForkService.test.ts
      • ThreadForkService.ts
      • ThreadLaunchService.test.ts
      • ThreadLaunchService.ts
      • ThreadMessageIntake.ts
    • provider
      • agentContextBudget.json
    • relay
      • AgentAwarenessRelay.test.ts
    • tasks
      • taskThreadStarter.ts
    • ws.ts
  • evals/mcp-tool-use
    • cases
      • task-initialization.ndjson
    • run.ts
  • packages
    • client-runtime/src/state
      • commandPermissions.test.ts
      • models.ts
    • contracts/src
      • clientRpcPermissions.ts
      • orchestrationV2.test.ts
      • orchestrationV2.ts
      • orchestratorMcp.ts
      • server.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/server/src/mcp/McpToolAccess.testkit.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/mcp/McpToolAccess.testkit.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export const idleThreadProjection = (
8080
...thread
8181
} = shell;
8282
return {
83-
thread: { ...thread, lastVisitedAt: lastVisitedAt ?? null },
83+
thread: { ...thread, taskInitialization: null, lastVisitedAt: lastVisitedAt ?? null },
8484
runs: [],
8585
attempts: [],
8686
nodes: [],
Collapse file

‎apps/server/src/mcp/OrchestratorMcpService.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/mcp/OrchestratorMcpService.ts
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
taskThreadInitializationSummary,
23
CommandId,
34
type RunId,
45
isProviderAvailable,
@@ -806,6 +807,8 @@ function threadDetail(
806807
interactionMode: projection.thread.interactionMode,
807808
linkedPullRequest: projection.thread.linkedPullRequest ?? null,
808809
pullRequests: threadPullRequests(projection.thread.pullRequests),
810+
taskDocumentId: projection.thread.taskDocumentId ?? null,
811+
taskInitialization: taskThreadInitializationSummary(projection.thread.taskInitialization),
809812
titleRegeneration:
810813
projection.thread.titleRegeneration === undefined ||
811814
projection.thread.titleRegeneration === null
Collapse file

‎apps/server/src/mcp/toolkits/project/handlers.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/mcp/toolkits/project/handlers.ts
+40-2Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,42 @@ const access = Effect.gen(function* () {
7575
yield* readCaller();
7676
return yield* Project.ProjectService;
7777
});
78+
// File-system causes stay out of the message; authored reasons are safe to show.
79+
const taskLaunchFailure = (error: ThreadLaunch.ThreadLaunchError) =>
80+
error.operation === "resolve-task"
81+
? new OrchestratorMcpFailure({
82+
code: "invalid_request",
83+
message:
84+
typeof error.cause === "string"
85+
? error.cause
86+
: "The task document or update instructions could not be read.",
87+
})
88+
: unavailable();
89+
7890
export const layer = McpToolAccess.toLayer(ProjectToolkit, {
91+
task_thread_initialization_result: McpToolAccess.writesThreads(
92+
() => [],
93+
(input) =>
94+
Effect.gen(function* () {
95+
const scope = yield* McpInvocationContext.McpInvocationContext;
96+
const { caller } = yield* readCaller();
97+
if (scope.thread === undefined || scope.thread.subagent === true || caller === undefined)
98+
return yield* new OrchestratorMcpFailure({
99+
code: "invalid_request",
100+
message: "Only the initializing thread can report its context outcome.",
101+
});
102+
const launches = yield* ThreadLaunch.ThreadLaunchService;
103+
yield* launches
104+
.reportTaskInitialization({
105+
threadId: caller.id,
106+
projectId: caller.projectId,
107+
providerInstanceId: scope.thread.providerInstanceId,
108+
outcome: input.outcome,
109+
})
110+
.pipe(Effect.mapError(taskLaunchFailure));
111+
return { recorded: true };
112+
}),
113+
),
79114
t3_thread_launch: McpToolAccess.startsThreads(
80115
(input) => input,
81116
(input, { runtimeMode, interactionMode, linkOrigin }) =>
@@ -209,6 +244,7 @@ export const layer = McpToolAccess.toLayer(ProjectToolkit, {
209244
)
210245
: runtimeMode;
211246
const result = yield* ThreadMessageIntake.launchThread({
247+
...(input.task === undefined ? {} : { task: input.task }),
212248
commandId,
213249
threadId,
214250
projectId,
@@ -246,11 +282,13 @@ export const layer = McpToolAccess.toLayer(ProjectToolkit, {
246282
message: error.message,
247283
});
248284
}
249-
return unavailable();
285+
return error._tag === "ThreadLaunchError" ? taskLaunchFailure(error) : unavailable();
250286
}),
251287
);
252288
const thread = result.projection.thread;
253-
const run = result.projection.runs.find((run) => run.userMessageId === messageId);
289+
const run = result.projection.runs.find(
290+
(run) => run.userMessageId === (thread.taskInitialization?.messageId ?? messageId),
291+
);
254292
return {
255293
threadId: thread.id,
256294
link: McpInvocationContext.threadLinkFor(scope, thread.id),
Collapse file

‎apps/server/src/mcp/toolkits/project/tools.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/mcp/toolkits/project/tools.ts
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
OrchestrationV2DelegatedFrom,
99
OrchestrationV2RunStatus,
1010
OrchestrationV2ThreadLaunchWorkspaceStrategy,
11+
TaskThreadLaunchOptions,
1112
RuntimeMode,
1213
ProviderInteractionMode,
1314
Project,
@@ -123,6 +124,12 @@ const ThreadLaunchTool = Tool.make("t3_thread_launch", {
123124
description:
124125
"Create one new top-level thread, bound to its workspace before the agent starts. Task in `message`. Omit `projectId`, model and modes to inherit yours (outside a thread, pass `projectId` or `scratch`); modes cannot exceed yours. After an error or lost reply, retry with the same `clientRequestId`. Follow it with `t3_thread_read` or `t3_thread_wait`. Mention it with its `link`.",
125126
parameters: Schema.Struct({
127+
task: Schema.optional(
128+
TaskThreadLaunchOptions.annotate({
129+
description:
130+
"Optional registered task document and update-discipline path on the destination environment. Runs visible context initialization first. Omit message/attachments; send work after launch. No filesystem permission is added.",
131+
}),
132+
),
126133
environmentId: OrchestratorMcpEnvironmentTarget,
127134
projectId: Schema.optional(ProjectId),
128135
scratch: Schema.optional(
@@ -174,7 +181,17 @@ const ThreadLaunchTool = Tool.make("t3_thread_launch", {
174181
.annotate(Tool.Destructive, true)
175182
.annotate(Tool.OpenWorld, true);
176183

184+
const TaskInitializationResultTool = Tool.make("task_thread_initialization_result", {
185+
...shared,
186+
description:
187+
"Report this task thread's initialization outcome after reading its required context. Use ready only when the task, relevant parents, update discipline and workspace instructions are readable and the selected workspace matches. Otherwise report failed and explain why. This reports context readiness; it does not start user work or change permissions.",
188+
parameters: Schema.Struct({ outcome: Schema.Literals(["ready", "failed"]) }),
189+
success: Schema.Struct({ recorded: Schema.Boolean }),
190+
dependencies: [...shared.dependencies, ThreadLaunchService.ThreadLaunchService],
191+
}).annotate(Tool.Destructive, true);
192+
177193
export const ProjectToolkit = Toolkit.make(
194+
TaskInitializationResultTool,
178195
ThreadLaunchTool,
179196
ProjectListTool,
180197
ProjectReadTool,

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.