51 lines
3.5 KiB
Markdown
51 lines
3.5 KiB
Markdown
# Gadget Drone Sub-Processes
|
|
|
|
The Gadget Code agent wants to manage child processes, and give them a fancier name. Because we're fancy.
|
|
|
|
In the Gadget ecosystem, we refer to a child process spawned by gadget-drone as a [SubProcess](../src/services/subprocess.ts). A `SubProcess` is just a child process, but it's also one that's being managed and controlled by gadget-drone based on commands received from the Agentic Workflow Loop using the `subprocess` tool (coming soon).
|
|
|
|
## Intent
|
|
|
|
This document is currently more of a specification to calibrate the model for working on Phase 1 of the SubProcess task.
|
|
|
|
Phase 1: Basic Services, internal to drone.
|
|
Phase 2: Expose SubProcess to gadget-code:frontend (IDE) via gadget-code:backend.
|
|
|
|
We will work together through Phase 1 now in this session. At the end of this session, with the knowledge we gain by implementing the agent tool, we will refine this document. And that will be the end of Phase 1.
|
|
|
|
We will then start a new session, and expose SubProcess to the IDE for User observability of the subprocesses.
|
|
|
|
## SubProcessService
|
|
|
|
[SubProcess](../src/services/subprocess.ts) is a service implemented by Gadget Drone for managing child processes. It offers methods for creating and managing child processes on behalf of Gadget Drone.
|
|
|
|
This is a service, and not entirely implemented within an Agent tool in the toolbox, because the gadget-drone process will also implement TypeScript code to manage and monitor the processes.
|
|
|
|
In the near future, `gadget-drone` will use this service to provide child process listing, status, and log services to `gadget-code:frontend` via `gadget-code:backend`. You can ignore this paragraph for this session because we will implement this in a different session. I mention it so you can include this detail in the refined version of this document at the end of this session.
|
|
|
|
## SubProcess Tool
|
|
|
|
A tool that is needed in the Agent's toolbox is the `subprocess` tool. This is what we are building in this session.
|
|
|
|
The `subprocess` tool will offer the agent `create` (spawn), `list` (ps), `kill(pid:number)`, `killAll`, and `log(which: "stdout" | "stderr")`. We will define a standard Gadget tool that the agent can use to manage child processes.
|
|
|
|
The tool makes use of methods on the `SubProcessService` service to execute tool function intent.
|
|
|
|
## Process Management
|
|
|
|
`gadget-drone` itself will need to close all running child processes when terminating. I have already added this logic to the gadget-drone main process during normal shutdown by registering the service, starting it, and stopping it using the standard Gadget service pattern.
|
|
|
|
I have extended the system prompts for relevant modes with information about the `subprocess` tool using [process-management-block.md](../../gadget-code/data/prompts/common/process-management-block.md). That block is now being integrated into the system prompt for all modes (this work is already completed). Please ensure that the service and tool offer a clearly-defined and well-described path for the agent to take for managing processes related to the project.
|
|
|
|
## Acceptance Criteria
|
|
|
|
Let this section guide the creation of your TODO list.
|
|
|
|
[ ] SubProcessService feature-complete
|
|
[ ] Unit tests for SubProcessService
|
|
[ ] `subprocess` agent tool feature-complete in agent toolbox
|
|
[ ] Unit tests for `subprocess` tool
|
|
[ ] gadget-drone documentation updated with the knowledge gained from this session
|
|
|
|
When done, these become documentation describing what's here in the subprocess feature suite, and how to use it.
|